PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ index_has_attr()

static int16 index_has_attr ( Oid  index_oid,
Oid  table_oid,
int16  table_attnum 
)
static

Definition at line 2302 of file gserialized_estimate.c.

2303 {
2304  HeapTuple index_tuple;
2305  Form_pg_index index_form;
2306  int16 index_attnum = InvalidAttrNumber;
2307 
2308  /* Check if the index is on the desired column */
2309  index_tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
2310  if (!HeapTupleIsValid(index_tuple))
2311  elog(ERROR, "cache lookup failed for index %u", index_oid);
2312 
2313  index_form = (Form_pg_index) GETSTRUCT(index_tuple);
2314 
2315  /* Something went wrong, this index isn't on our table of interest */
2316  if (index_form->indrelid != table_oid)
2317  elog(ERROR, "table=%u and index=%u are not related", table_oid, index_oid);
2318 
2319  /* Check if the attnum is in the indkey array */
2320  for (int16 i = 0; i < (int16)(index_form->indkey.dim1); i++)
2321  {
2322  if (index_form->indkey.values[i] == table_attnum)
2323  {
2324  index_attnum = i+1;
2325  break;
2326  }
2327  }
2328  ReleaseSysCache(index_tuple);
2329  return index_attnum;
2330 }

Referenced by table_get_spatial_index().

Here is the caller graph for this function: