2285{
2286 BOX2DF *bounds_2df = NULL;
2287 GIDX *bounds_gidx = NULL;
2289 Relation idx_rel;
2291 Page page;
2292 unsigned long offset;
2293 unsigned long offset_max;
2294
2295 if (!idx_oid)
2296 return NULL;
2297
2298 idx_rel = index_open(idx_oid, AccessShareLock);
2299 buffer = ReadBuffer(idx_rel, GIST_ROOT_BLKNO);
2300 page = (Page) BufferGetPage(
buffer);
2301 offset = FirstOffsetNumber;
2302 offset_max = PageGetMaxOffsetNumber(page);
2303 while (offset <= offset_max)
2304 {
2305 ItemId iid = PageGetItemId(page, offset);
2306 IndexTuple ituple;
2307 if (!iid)
2308 {
2310 index_close(idx_rel, AccessShareLock);
2311 return NULL;
2312 }
2313 ituple = (IndexTuple) PageGetItem(page, iid);
2314 if (!GistTupleIsInvalid(ituple))
2315 {
2316 bool isnull;
2317 Datum idx_attr = index_getattr(ituple, idx_att_num, idx_rel->rd_att, &isnull);
2318 if (!isnull)
2319 {
2321 {
2322 BOX2DF *b = (BOX2DF*)DatumGetPointer(idx_attr);
2323 if (bounds_2df)
2325 else
2327 }
2328 else
2329 {
2330 GIDX *b = (GIDX*)DatumGetPointer(idx_attr);
2331 if (bounds_gidx)
2333 else
2335 }
2336 }
2337 }
2338 offset++;
2339 }
2340
2342 index_close(idx_rel, AccessShareLock);
2343
2345 {
2347 return NULL;
2350 }
2352 {
2355 return NULL;
2359 gbox_from_gidx(bounds_gidx, gbox, flags);
2360 }
2361 else
2362 return NULL;
2363
2364 return gbox;
2365}
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)