Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b170005

Browse files
committed
Fix BuildIndexValueDescription for expressions
In 804b6b6 we modified BuildIndexValueDescription to pay attention to which columns are visible to the user, but unfortunatley that commit neglected to consider indexes which are built on expressions. Handle error-reporting of violations of constraint indexes based on expressions by not returning any detail when the user does not have table-level SELECT rights. Backpatch to 9.0, as the prior commit was. Pointed out by Tom.
1 parent 202621d commit b170005

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/backend/access/index/genam.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,15 @@ BuildIndexValueDescription(Relation indexRelation,
210210
{
211211
AttrNumber attnum = idxrec->indkey.values[keyno];
212212

213-
aclresult = pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
214-
ACL_SELECT);
215-
216-
if (aclresult != ACLCHECK_OK)
213+
/*
214+
* Note that if attnum == InvalidAttrNumber, then this is an
215+
* index based on an expression and we return no detail rather
216+
* than try to figure out what column(s) the expression includes
217+
* and if the user has SELECT rights on them.
218+
*/
219+
if (attnum == InvalidAttrNumber ||
220+
pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
221+
ACL_SELECT) != ACLCHECK_OK)
217222
{
218223
/* No access, so clean up and return */
219224
ReleaseSysCache(ht_idx);

0 commit comments

Comments
 (0)