Fix segfault in caggs on 32-bit systems

While DatumGetInt64 and Int64GetDatum are noops on 64-bit systems
calling them on the wrong underlying type can lead to segfaults
on 32-bit systems.
This commit is contained in:
Sven Klemm 2020-09-01 23:16:37 +02:00 committed by Sven Klemm
parent b355a86b4e
commit 3d880ecd2b
2 changed files with 6 additions and 5 deletions

View File

@ -515,7 +515,8 @@ mattablecolumninfo_create_materialization_table(MatTableColumnInfo *matcolinfo,
/* Initialize the invalidation log for the cagg. Initially, everything is
* invalid. */
if (OidIsValid(origquery_tblinfo->nowfunc))
current_time = DatumGetInt64(OidFunctionCall0(origquery_tblinfo->nowfunc));
current_time = ts_time_value_to_internal(OidFunctionCall0(origquery_tblinfo->nowfunc),
get_func_rettype(origquery_tblinfo->nowfunc));
else
current_time = GetCurrentTransactionStartTimestamp();

View File

@ -207,10 +207,10 @@ continuous_agg_refresh_with_window(ContinuousAgg *cagg, const InternalTimeRange
if (client_min_messages <= DEBUG1)
{
Datum start_ts = ts_internal_to_time_value(DatumGetInt64(bucketed_refresh_window.start),
refresh_window->type);
Datum end_ts = ts_internal_to_time_value(DatumGetInt64(bucketed_refresh_window.end),
refresh_window->type);
Datum start_ts =
ts_internal_to_time_value(bucketed_refresh_window.start, refresh_window->type);
Datum end_ts =
ts_internal_to_time_value(bucketed_refresh_window.end, refresh_window->type);
Oid outfuncid = InvalidOid;
bool isvarlena;