2289{
2290 BOX2DF *bounds_2df = NULL;
2291 GIDX *bounds_gidx = NULL;
2293 Relation idx_rel;
2295 Page page;
2296 unsigned long offset;
2297 unsigned long offset_max;
2298
2299 if (!idx_oid)
2300 return NULL;
2301
2302 idx_rel = index_open(idx_oid, AccessShareLock);
2303 buffer = ReadBuffer(idx_rel, GIST_ROOT_BLKNO);
2304 page = (Page) BufferGetPage(
buffer);
2305 offset = FirstOffsetNumber;
2306 offset_max = PageGetMaxOffsetNumber(page);
2307 while (offset <= offset_max)
2308 {
2309 ItemId iid = PageGetItemId(page, offset);
2310 IndexTuple ituple;
2311 if (!iid)
2312 {
2314 index_close(idx_rel, AccessShareLock);
2315 return NULL;
2316 }
2317 ituple = (IndexTuple) PageGetItem(page, iid);
2318 if (!GistTupleIsInvalid(ituple))
2319 {
2320 bool isnull;
2321 Datum idx_attr = index_getattr(ituple, idx_att_num, idx_rel->rd_att, &isnull);
2322 if (!isnull)
2323 {
2325 {
2326 BOX2DF *b = (BOX2DF*)DatumGetPointer(idx_attr);
2327 if (bounds_2df)
2329 else
2331 }
2332 else
2333 {
2334 GIDX *b = (GIDX*)DatumGetPointer(idx_attr);
2335 if (bounds_gidx)
2337 else
2339 }
2340 }
2341 }
2342 offset++;
2343 }
2344
2346 index_close(idx_rel, AccessShareLock);
2347
2349 {
2351 return NULL;
2354 }
2356 {
2359 return NULL;
2363 gbox_from_gidx(bounds_gidx, gbox, flags);
2364 }
2365 else
2366 return NULL;
2367
2368 return gbox;
2369}
GBOX * gbox_new(lwflags_t flags)
Create a new gbox with the dimensionality indicated by the flags.
#define STATISTIC_KIND_2D
#define STATISTIC_KIND_ND
void box2df_merge(BOX2DF *b_union, BOX2DF *b_new)
bool box2df_is_empty(const BOX2DF *a)
int box2df_to_gbox_p(BOX2DF *a, GBOX *box)
BOX2DF * box2df_copy(BOX2DF *b)
bool gidx_is_unknown(const GIDX *a)
GIDX * gidx_copy(GIDX *b)
void gidx_merge(GIDX **b_union, GIDX *b_new)
#define FLAGS_SET_M(flags, value)
#define FLAGS_SET_Z(flags, value)
Datum buffer(PG_FUNCTION_ARGS)