PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ index_has_attr()

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

Definition at line 2144 of file gserialized_estimate.c.

2145{
2146 HeapTuple index_tuple;
2147 Form_pg_index index_form;
2148 int16 index_attnum = InvalidAttrNumber;
2149
2150 /* Check if the index is on the desired column */
2151 index_tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
2152 if (!HeapTupleIsValid(index_tuple))
2153 elog(ERROR, "cache lookup failed for index %u", index_oid);
2154
2155 index_form = (Form_pg_index) GETSTRUCT(index_tuple);
2156
2157 /* Something went wrong, this index isn't on our table of interest */
2158 if (index_form->indrelid != table_oid)
2159 elog(ERROR, "table=%u and index=%u are not related", table_oid, index_oid);
2160
2161 /* Check if the attnum is in the indkey array */
2162 for (int16 i = 0; i < (int16)(index_form->indkey.dim1); i++)
2163 {
2164 if (index_form->indkey.values[i] == table_attnum)
2165 {
2166 index_attnum = i+1;
2167 break;
2168 }
2169 }
2170 ReleaseSysCache(index_tuple);
2171 return index_attnum;
2172}

Referenced by table_get_spatial_index().

Here is the caller graph for this function: