2319 char *nsp_tbl = NULL;
2320 Oid tbl_oid, idx_oid = 0;
2323 bool only_parent =
false;
2324 int key_type, att_num;
2328 postgis_initialize_cache();
2330 if ( PG_NARGS() == 4 )
2332 nsp = text_to_cstring(PG_GETARG_TEXT_P(0));
2333 tbl = text_to_cstring(PG_GETARG_TEXT_P(1));
2334 col = PG_GETARG_TEXT_P(2);
2335 only_parent = PG_GETARG_BOOL(3);
2336 sz = strlen(nsp) + strlen(tbl) + 6;
2337 nsp_tbl = palloc(sz);
2338 snprintf(nsp_tbl, sz,
"\"%s\".\"%s\"", nsp, tbl);
2339 tbl_oid = DatumGetObjectId(DirectFunctionCall1(regclassin, CStringGetDatum(nsp_tbl)));
2342 else if ( PG_NARGS() == 3 )
2344 nsp = text_to_cstring(PG_GETARG_TEXT_P(0));
2345 tbl = text_to_cstring(PG_GETARG_TEXT_P(1));
2346 col = PG_GETARG_TEXT_P(2);
2347 sz = strlen(nsp) + strlen(tbl) + 6;
2348 nsp_tbl = palloc(sz);
2349 snprintf(nsp_tbl, sz,
"\"%s\".\"%s\"", nsp, tbl);
2350 tbl_oid = DatumGetObjectId(DirectFunctionCall1(regclassin, CStringGetDatum(nsp_tbl)));
2353 else if ( PG_NARGS() == 2 )
2355 tbl = text_to_cstring(PG_GETARG_TEXT_P(0));
2356 col = PG_GETARG_TEXT_P(1);
2357 sz = strlen(tbl) + 3;
2358 nsp_tbl = palloc(sz);
2359 snprintf(nsp_tbl, sz,
"\"%s\"", tbl);
2360 tbl_oid = DatumGetObjectId(DirectFunctionCall1(regclassin, CStringGetDatum(nsp_tbl)));
2365 elog(ERROR,
"estimated_extent() called with wrong number of arguments");
2376 POSTGIS_DEBUGF(2,
"index for \"%s.%s\" exists, reading gbox from there", tbl, text_to_cstring(col));
2377 if ( ! gbox ) PG_RETURN_NULL();
2381 POSTGIS_DEBUGF(2,
"index for \"%s.%s\" does not exist", tbl, text_to_cstring(col));
2390 elog(WARNING,
"stats for \"%s.%s\" do not exist", tbl, text_to_cstring(col));
2395 gbox = palloc(
sizeof(
GBOX));
2406 PG_RETURN_POINTER(gbox);
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 GBOX * spatial_index_read_extent(Oid idx_oid, int key_type, int att_num)
static Oid table_get_spatial_index(Oid tbl_oid, text *col, int *key_type, int *att_num)
#define FLAGS_SET_GEODETIC(flags, value)
#define FLAGS_SET_M(flags, value)
#define FLAGS_SET_Z(flags, value)
N-dimensional statistics structure.