Skip to content

Commit

Permalink
Upgrade for pg17 (MobilityDB#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanzimanyi committed Jul 5, 2024
1 parent 376043c commit 072ec58
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions mobilitydb/src/general/span_analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ void
span_compute_stats_generic(VacAttrStats *stats, int non_null_cnt, int *slot_idx,
SpanBound *lowers, SpanBound *uppers, float8 *lengths, bool valuedim)
{
#if POSTGRESQL_VERSION_NUMBER >= 170000
int num_hist, num_bins = stats->attstattarget;
#else
int num_hist, num_bins = stats->attr->attstattarget;
#endif
Datum *bound_hist_values, *length_hist_values;

/* Must copy the target values into anl_context */
Expand Down Expand Up @@ -361,11 +365,20 @@ Span_analyze(PG_FUNCTION_ARGS)
/* Set the callback function to compute statistics. */
stats->compute_stats = &span_compute_stats;


#if POSTGRESQL_VERSION_NUMBER >= 170000
if (stats->attstattarget < 0)
stats->attstattarget = default_statistics_target;

/* same as in std_typanalyze */
stats->minrows = 300 * stats->attstattarget;
#else
if (stats->attr->attstattarget < 0)
stats->attr->attstattarget = default_statistics_target;

/* same as in std_typanalyze */
stats->minrows = 300 * stats->attr->attstattarget;
#endif

PG_RETURN_BOOL(true);
}
Expand Down
7 changes: 5 additions & 2 deletions mobilitydb/src/general/temporal_analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ temporal_extra_info(VacAttrStats *stats)
{
TypeCacheEntry *typentry;
TemporalAnalyzeExtraData *extra_data;
Form_pg_attribute attr = stats->attr;

/* Check attribute data type is a temporal type. */
if (! temporal_type(oid_type(stats->attrtypid)))
Expand Down Expand Up @@ -290,7 +289,11 @@ temporal_extra_info(VacAttrStats *stats)
extra_data->std_extra_data = stats->extra_data;
stats->extra_data = extra_data;

stats->minrows = 300 * attr->attstattarget;
#if POSTGRESQL_VERSION_NUMBER >= 170000
stats->minrows = 300 * stats->attstattarget;
#else
stats->minrows = 300 * stats->attr->attstattarget;
#endif
return;
}

Expand Down
4 changes: 4 additions & 0 deletions mobilitydb/src/point/tpoint_analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,11 @@ gserialized_compute_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
* we have an average of 5 features for each cell so the histogram isn't
* so sparse.
*/
#if POSTGRESQL_VERSION_NUMBER >= 170000
histo_cells_target = (int) pow((double) (stats->attstattarget),
#else
histo_cells_target = (int) pow((double) (stats->attr->attstattarget),
#endif
(double) ndims);
histo_cells_target = Min(histo_cells_target, ndims * 10000);
histo_cells_target = Min(histo_cells_target, (int)(total_rows/5));
Expand Down

0 comments on commit 072ec58

Please sign in to comment.