PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ table_get_spatial_index()

static Oid table_get_spatial_index ( Oid  tbl_oid,
int16  attnum,
int *  key_type,
int16 *  idx_attnum 
)
static

Definition at line 2387 of file gserialized_estimate.c.

2388 {
2389  Relation table_rel;
2390  List *index_list;
2391  ListCell *lc;
2392 
2393  /* Lookup our spatial index key types */
2394  Oid b2d_oid = postgis_oid(BOX2DFOID);
2395  Oid gdx_oid = postgis_oid(GIDXOID);
2396 
2397  if (!(b2d_oid && gdx_oid))
2398  return InvalidOid;
2399 
2400  /* Read a list of all indexes on this table */
2401  table_rel = RelationIdGetRelation(table_oid);
2402  index_list = RelationGetIndexList(table_rel);
2403  RelationClose(table_rel);
2404 
2405  /* For each index associated with this table... */
2406  foreach(lc, index_list)
2407  {
2408  Oid index_oid = lfirst_oid(lc);
2409  Oid atttypid;
2410 
2411  /* Is our attribute indexed by this index? */
2412  *idx_attnum = index_has_attr(index_oid, table_oid, attnum);
2413 
2414  /* No, move on */
2415  if (*idx_attnum == InvalidAttrNumber)
2416  continue;
2417 
2418  /* We only handle GIST spatial indexes */
2419  if (index_get_am(index_oid) != GIST_AM_OID)
2420  continue;
2421 
2422  /* Is the column actually spatial? */
2423  /* Only if it uses our spatial key types */
2424  atttypid = index_get_keytype (index_oid, *idx_attnum);
2425  if (atttypid == b2d_oid || atttypid == gdx_oid)
2426  {
2427  /* Spatial key found in this index! */
2428  *key_type = (atttypid == b2d_oid ? STATISTIC_KIND_2D : STATISTIC_KIND_ND);
2429  return index_oid;
2430  }
2431  }
2432  return InvalidOid;
2433 }
static int index_get_keytype(Oid index_oid, int16 index_attnum)
#define STATISTIC_KIND_2D
#define STATISTIC_KIND_ND
static int index_get_am(Oid index_oid)
static int16 index_has_attr(Oid index_oid, Oid table_oid, int16 table_attnum)

References index_get_am(), index_get_keytype(), index_has_attr(), STATISTIC_KIND_2D, and STATISTIC_KIND_ND.

Referenced by _postgis_gserialized_index_extent(), and gserialized_estimated_extent().

Here is the call graph for this function:
Here is the caller graph for this function: