@@ -180,7 +180,6 @@ BuildIndexValueDescription(Relation indexRelation,
180180{
181181 StringInfoData buf ;
182182 Form_pg_index idxrec ;
183- HeapTuple ht_idx ;
184183 int indnkeyatts ;
185184 int i ;
186185 int keyno ;
@@ -200,24 +199,13 @@ BuildIndexValueDescription(Relation indexRelation,
200199 * Next we need to check table-level SELECT access and then, if there is
201200 * no access there, check column-level permissions.
202201 */
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 ;
212203 indrelid = idxrec -> indrelid ;
213204 Assert (indexrelid == idxrec -> indexrelid );
214205
215206 /* RLS check- if RLS is enabled then we don't return anything. */
216207 if (check_enable_rls (indrelid , InvalidOid , true) == RLS_ENABLED )
217- {
218- ReleaseSysCache (ht_idx );
219208 return NULL ;
220- }
221209
222210 /* Table-level SELECT is enough, if the user has it */
223211 aclresult = pg_class_aclcheck (indrelid , GetUserId (), ACL_SELECT );
@@ -227,7 +215,7 @@ BuildIndexValueDescription(Relation indexRelation,
227215 * No table-level access, so step through the columns in the index and
228216 * make sure the user has SELECT rights on all of them.
229217 */
230- for (keyno = 0 ; keyno < idxrec -> indnkeyatts ; keyno ++ )
218+ for (keyno = 0 ; keyno < indnkeyatts ; keyno ++ )
231219 {
232220 AttrNumber attnum = idxrec -> indkey .values [keyno ];
233221
@@ -242,12 +230,10 @@ BuildIndexValueDescription(Relation indexRelation,
242230 ACL_SELECT ) != ACLCHECK_OK )
243231 {
244232 /* No access, so clean up and return */
245- ReleaseSysCache (ht_idx );
246233 return NULL ;
247234 }
248235 }
249236 }
250- ReleaseSysCache (ht_idx );
251237
252238 initStringInfo (& buf );
253239 appendStringInfo (& buf , "(%s)=(" ,
0 commit comments