2299 char *nsp_tbl = NULL;
2300 Oid tbl_oid, idx_oid = 0;
2303 bool only_parent =
false;
2304 int key_type, att_num;
2308 postgis_initialize_cache();
2310 if ( PG_NARGS() == 4 )
2312 nsp = text_to_cstring(PG_GETARG_TEXT_P(0));
2313 tbl = text_to_cstring(PG_GETARG_TEXT_P(1));
2314 col = PG_GETARG_TEXT_P(2);
2315 only_parent = PG_GETARG_BOOL(3);
2316 sz = strlen(nsp) + strlen(tbl) + 6;
2317 nsp_tbl = palloc(sz);
2318 snprintf(nsp_tbl, sz,
"\"%s\".\"%s\"", nsp, tbl);
2319 tbl_oid = DatumGetObjectId(DirectFunctionCall1(regclassin, CStringGetDatum(nsp_tbl)));
2322 else if ( PG_NARGS() == 3 )
2324 nsp = text_to_cstring(PG_GETARG_TEXT_P(0));
2325 tbl = text_to_cstring(PG_GETARG_TEXT_P(1));
2326 col = PG_GETARG_TEXT_P(2);
2327 sz = strlen(nsp) + strlen(tbl) + 6;
2328 nsp_tbl = palloc(sz);
2329 snprintf(nsp_tbl, sz,
"\"%s\".\"%s\"", nsp, tbl);
2330 tbl_oid = DatumGetObjectId(DirectFunctionCall1(regclassin, CStringGetDatum(nsp_tbl)));
2333 else if ( PG_NARGS() == 2 )
2335 tbl = text_to_cstring(PG_GETARG_TEXT_P(0));
2336 col = PG_GETARG_TEXT_P(1);
2337 sz = strlen(tbl) + 3;
2338 nsp_tbl = palloc(sz);
2339 snprintf(nsp_tbl, sz,
"\"%s\"", tbl);
2340 tbl_oid = DatumGetObjectId(DirectFunctionCall1(regclassin, CStringGetDatum(nsp_tbl)));
2345 elog(ERROR,
"estimated_extent() called with wrong number of arguments");
2356 POSTGIS_DEBUGF(2,
"index for \"%s.%s\" exists, reading gbox from there", tbl, text_to_cstring(col));
2357 if ( ! gbox ) PG_RETURN_NULL();
2361 POSTGIS_DEBUGF(2,
"index for \"%s.%s\" does not exist", tbl, text_to_cstring(col));
2370 elog(WARNING,
"stats for \"%s.%s\" do not exist", tbl, text_to_cstring(col));
2375 gbox = palloc(
sizeof(
GBOX));
2386 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.