PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ _postgis_gserialized_stats()

Datum _postgis_gserialized_stats ( PG_FUNCTION_ARGS  )

Definition at line 2073 of file gserialized_estimate.c.

2074 {
2075  Oid table_oid = PG_GETARG_OID(0);
2076  text *att_text = PG_GETARG_TEXT_P(1);
2077  ND_STATS *nd_stats;
2078  char *str;
2079  text *json;
2080  int mode = 2; /* default to 2D mode */
2081  bool only_parent = false; /* default to whole tree stats */
2082 
2083  /* Check if we've been asked to not use 2d mode */
2084  if ( ! PG_ARGISNULL(2) )
2085  mode = text_p_get_mode(PG_GETARG_TEXT_P(2));
2086 
2087  /* Retrieve the stats object */
2088  nd_stats = pg_get_nd_stats_by_name(table_oid, att_text, mode, only_parent);
2089  if ( ! nd_stats )
2090  elog(ERROR, "stats for \"%s.%s\" do not exist", get_rel_name(table_oid), text_to_cstring(att_text));
2091 
2092  /* Convert to JSON */
2093  str = nd_stats_to_json(nd_stats);
2094  json = cstring_to_text(str);
2095  pfree(str);
2096  pfree(nd_stats);
2097  PG_RETURN_TEXT_P(json);
2098 }
static ND_STATS * pg_get_nd_stats_by_name(const Oid table_oid, const text *att_text, int mode, bool only_parent)
Pull the stats object from the PgSQL system catalogs.
static char * nd_stats_to_json(const ND_STATS *nd_stats)
Convert an ND_STATS to a JSON representation for external use.
static int text_p_get_mode(const text *txt)
Utility function to see if the first letter of the mode argument is 'N'.
#define str(s)
char * text_to_cstring(const text *textptr)
N-dimensional statistics structure.

References nd_stats_to_json(), pg_get_nd_stats_by_name(), str, text_p_get_mode(), and text_to_cstring().

Here is the call graph for this function: