Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c04d4b

Browse files
committed
Revise BuildIndexValueDescription to simplify it
Getting a pg_index tuple from syscache when the open index relation isavailable is pointless -- just use the one from relcache.Noticed while reviewing code forcb9db2a.No backpatch.
1 parentcb9db2a commit1c04d4b

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

‎src/backend/access/index/genam.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ BuildIndexValueDescription(Relation indexRelation,
180180
{
181181
StringInfoDatabuf;
182182
Form_pg_indexidxrec;
183-
HeapTupleht_idx;
184183
intindnkeyatts;
185184
inti;
186185
intkeyno;
@@ -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
returnNULL;
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
AttrNumberattnum=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
returnNULL;
247234
}
248235
}
249236
}
250-
ReleaseSysCache(ht_idx);
251237

252238
initStringInfo(&buf);
253239
appendStringInfo(&buf,"(%s)=(",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp