@@ -180,7 +180,6 @@ BuildIndexValueDescription(Relation indexRelation,
180
180
{
181
181
StringInfoData buf ;
182
182
Form_pg_index idxrec ;
183
- HeapTuple ht_idx ;
184
183
int indnkeyatts ;
185
184
int i ;
186
185
int keyno ;
@@ -200,24 +199,13 @@ BuildIndexValueDescription(Relation indexRelation,
200
199
* Next we need to check table-level SELECT access and then, if there is
201
200
* no access there, check column-level permissions.
202
201
*/
203
-
204
- /*
205
- * Fetch the pg_index tuple by the Oid of the index
206
- */
207
- ht_idx = SearchSysCache1 (INDEXRELID , ObjectIdGetDatum (indexrelid ));
208
- if (!HeapTupleIsValid (ht_idx ))
209
- elog (ERROR , "cache lookup failed for index %u" , indexrelid );
210
- idxrec = (Form_pg_index ) GETSTRUCT (ht_idx );
211
-
202
+ idxrec = indexRelation -> rd_index ;
212
203
indrelid = idxrec -> indrelid ;
213
204
Assert (indexrelid == idxrec -> indexrelid );
214
205
215
206
/* RLS check- if RLS is enabled then we don't return anything. */
216
207
if (check_enable_rls (indrelid , InvalidOid , true) == RLS_ENABLED )
217
- {
218
- ReleaseSysCache (ht_idx );
219
208
return NULL ;
220
- }
221
209
222
210
/* Table-level SELECT is enough, if the user has it */
223
211
aclresult = pg_class_aclcheck (indrelid , GetUserId (), ACL_SELECT );
@@ -227,7 +215,7 @@ BuildIndexValueDescription(Relation indexRelation,
227
215
* No table-level access, so step through the columns in the index and
228
216
* make sure the user has SELECT rights on all of them.
229
217
*/
230
- for (keyno = 0 ; keyno < idxrec -> indnkeyatts ; keyno ++ )
218
+ for (keyno = 0 ; keyno < indnkeyatts ; keyno ++ )
231
219
{
232
220
AttrNumber attnum = idxrec -> indkey .values [keyno ];
233
221
@@ -242,12 +230,10 @@ BuildIndexValueDescription(Relation indexRelation,
242
230
ACL_SELECT ) != ACLCHECK_OK )
243
231
{
244
232
/* No access, so clean up and return */
245
- ReleaseSysCache (ht_idx );
246
233
return NULL ;
247
234
}
248
235
}
249
236
}
250
- ReleaseSysCache (ht_idx );
251
237
252
238
initStringInfo (& buf );
253
239
appendStringInfo (& buf , "(%s)=(" ,
0 commit comments