PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ table_get_spatial_index()

static Oid table_get_spatial_index ( Oid  tbl_oid,
text *  col,
int *  key_type 
)
static

Definition at line 2421 of file gserialized_estimate.c.

2422 {
2423  Relation tbl_rel;
2424  ListCell *lc;
2425  List *idx_list;
2426  Oid result = InvalidOid;
2427  char *colname = text_to_cstring(col);
2428 
2429  /* Lookup our spatial index key types */
2430  Oid b2d_oid = postgis_oid(BOX2DFOID);
2431  Oid gdx_oid = postgis_oid(BOX3DOID);
2432 
2433  if (!(b2d_oid && gdx_oid))
2434  return InvalidOid;
2435 
2436  tbl_rel = RelationIdGetRelation(tbl_oid);
2437  idx_list = RelationGetIndexList(tbl_rel);
2438  RelationClose(tbl_rel);
2439 
2440  /* For each index associated with this table... */
2441  foreach(lc, idx_list)
2442  {
2443  Form_pg_class idx_form;
2444  HeapTuple idx_tup;
2445  int idx_relam;
2446  Oid idx_oid = lfirst_oid(lc);
2447 
2448  idx_tup = SearchSysCache1(RELOID, ObjectIdGetDatum(idx_oid));
2449  if (!HeapTupleIsValid(idx_tup))
2450  elog(ERROR, "%s: unable to lookup index %u in syscache", __func__, idx_oid);
2451  idx_form = (Form_pg_class) GETSTRUCT(idx_tup);
2452  idx_relam = idx_form->relam;
2453  ReleaseSysCache(idx_tup);
2454 
2455  /* Does the index use a GIST access method? */
2456  if (idx_relam == GIST_AM_OID)
2457  {
2458  Form_pg_attribute att;
2459  Oid atttypid;
2460  /* Is the index on the column name we are looking for? */
2461  HeapTuple att_tup = SearchSysCache2(ATTNAME,
2462  ObjectIdGetDatum(idx_oid),
2463  PointerGetDatum(colname));
2464  if (!HeapTupleIsValid(att_tup))
2465  continue;
2466 
2467  att = (Form_pg_attribute) GETSTRUCT(att_tup);
2468  atttypid = att->atttypid;
2469  ReleaseSysCache(att_tup);
2470 
2471  /* Is the column actually spatial? */
2472  if (b2d_oid == atttypid || gdx_oid == atttypid)
2473  {
2474  /* Save result, clean up, and break out */
2475  result = idx_oid;
2476  if (key_type)
2477  *key_type = (atttypid == b2d_oid ? STATISTIC_SLOT_2D : STATISTIC_SLOT_ND);
2478  break;
2479  }
2480  }
2481  }
2482  return result;
2483 }
#define STATISTIC_SLOT_ND
#define STATISTIC_SLOT_2D
char * text_to_cstring(const text *textptr)

References STATISTIC_SLOT_2D, STATISTIC_SLOT_ND, and text_to_cstring().

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: