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

Definition at line 1987 of file gserialized_estimate.c.

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

1988 {
1989  Oid table_oid = PG_GETARG_OID(0);
1990  text *att_text = PG_GETARG_TEXT_P(1);
1991  ND_STATS *nd_stats;
1992  char *str;
1993  text *json;
1994  int mode = 2; /* default to 2D mode */
1995  bool only_parent = FALSE; /* default to whole tree stats */
1996 
1997  /* Check if we've been asked to not use 2d mode */
1998  if ( ! PG_ARGISNULL(2) )
1999  mode = text_p_get_mode(PG_GETARG_TEXT_P(2));
2000 
2001  /* Check if we've been asked to only use stats from parent */
2002  if ( ! PG_ARGISNULL(3) )
2003  only_parent = PG_GETARG_BOOL(3);
2004 
2005  /* Retrieve the stats object */
2006  nd_stats = pg_get_nd_stats_by_name(table_oid, att_text, mode, only_parent);
2007  if ( ! nd_stats )
2008  elog(ERROR, "stats for \"%s.%s\" do not exist", get_rel_name(table_oid), text2cstring(att_text));
2009 
2010  /* Convert to JSON */
2011  str = nd_stats_to_json(nd_stats);
2012  json = cstring2text(str);
2013  pfree(str);
2014  pfree(nd_stats);
2015  PG_RETURN_TEXT_P(json);
2016 }
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 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)
#define FALSE
Definition: dbfopen.c:168
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: