diff --git a/mobilitydb/src/general/span_analyze.c b/mobilitydb/src/general/span_analyze.c index 40cae5a253..8d13f7fd01 100644 --- a/mobilitydb/src/general/span_analyze.c +++ b/mobilitydb/src/general/span_analyze.c @@ -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 */ @@ -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); } diff --git a/mobilitydb/src/general/temporal_analyze.c b/mobilitydb/src/general/temporal_analyze.c index f626daaf25..99f77c45ad 100644 --- a/mobilitydb/src/general/temporal_analyze.c +++ b/mobilitydb/src/general/temporal_analyze.c @@ -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))) @@ -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; } diff --git a/mobilitydb/src/point/tpoint_analyze.c b/mobilitydb/src/point/tpoint_analyze.c index 48f904e0cc..da13dec2c3 100644 --- a/mobilitydb/src/point/tpoint_analyze.c +++ b/mobilitydb/src/point/tpoint_analyze.c @@ -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));