PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ _postgis_gserialized_stats()

Datum _postgis_gserialized_stats ( PG_FUNCTION_ARGS  )

Definition at line 1908 of file gserialized_estimate.c.

1909{
1910 Oid table_oid = PG_GETARG_OID(0);
1911 text *att_text = PG_GETARG_TEXT_P(1);
1912 ND_STATS *nd_stats;
1913 char *str;
1914 text *json;
1915 int mode = 2; /* default to 2D mode */
1916 bool only_parent = false; /* default to whole tree stats */
1917
1918 /* Check if we've been asked to not use 2d mode */
1919 if ( ! PG_ARGISNULL(2) )
1920 mode = text_p_get_mode(PG_GETARG_TEXT_P(2));
1921
1922 /* Retrieve the stats object */
1923 nd_stats = pg_get_nd_stats_by_name(table_oid, att_text, mode, only_parent);
1924 if ( ! nd_stats )
1925 elog(ERROR, "stats for \"%s.%s\" do not exist", get_rel_name(table_oid), text_to_cstring(att_text));
1926
1927 /* Convert to JSON */
1928 elog(DEBUG1, "stats grid:\n%s", nd_stats_to_grid(nd_stats));
1929 str = nd_stats_to_json(nd_stats);
1930 json = cstring_to_text(str);
1931 pfree(str);
1932 pfree(nd_stats);
1933
1934 PG_RETURN_TEXT_P(json);
1935}
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'.
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_grid(const ND_STATS *stats)
Create a printable view of the ND_STATS histogram.
#define str(s)

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

Here is the call graph for this function: