PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum _postgis_gserialized_stats ( PG_FUNCTION_ARGS  )

Definition at line 1925 of file gserialized_estimate.c.

References nd_stats_to_json(), pg_get_nd_stats_by_name(), text2cstring(), and text_p_get_mode().

1926 {
1927  Oid table_oid = PG_GETARG_OID(0);
1928  text *att_text = PG_GETARG_TEXT_P(1);
1929  ND_STATS *nd_stats;
1930  char *str;
1931  text *json;
1932  int mode = 2; /* default to 2D mode */
1933 
1934  /* Check if we've been asked to not use 2d mode */
1935  if ( ! PG_ARGISNULL(2) )
1936  mode = text_p_get_mode(PG_GETARG_TEXT_P(2));
1937 
1938  /* Retrieve the stats object */
1939  nd_stats = pg_get_nd_stats_by_name(table_oid, att_text, mode);
1940  if ( ! nd_stats )
1941  elog(ERROR, "stats for \"%s.%s\" do not exist", get_rel_name(table_oid), text2cstring(att_text));
1942 
1943  /* Convert to JSON */
1944  str = nd_stats_to_json(nd_stats);
1945  json = cstring2text(str);
1946  pfree(str);
1947  pfree(nd_stats);
1948  PG_RETURN_TEXT_P(json);
1949 }
static int text_p_get_mode(const text *txt)
Utility function to see if the first letter of the mode argument is 'N'.
char * text2cstring(const text *textptr)
static ND_STATS * pg_get_nd_stats_by_name(const Oid table_oid, const text *att_text, int mode)
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.
N-dimensional statistics structure.

Here is the call graph for this function: