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

Appearance settings

Commit 7e04160

Browse filesBrowse files
committed
Fix handling of non-key columns get_index_column_opclass()
f2e4038 introduces support of non-key attributes in GiST indexes. Then if get_index_column_opclass() is asked by gistproperty() to get an opclass of non-key column, it returns garbage past oidvector value. This commit fixes that by making get_index_column_opclass() return InvalidOid in this case. Discussion: https://postgr.es/m/20190902231948.GA5343%40alvherre.pgsql Author: Nikita Glukhov, Alexander Korotkov Backpatch-through: 12
1 parent 89b160c commit 7e04160
Copy full SHA for 7e04160

File tree

Expand file treeCollapse file tree

1 file changed

+11
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-1
lines changed

‎src/backend/utils/cache/lsyscache.c

Copy file name to clipboardExpand all lines: src/backend/utils/cache/lsyscache.c
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3157,7 +3157,8 @@ get_range_subtype(Oid rangeOid)
31573157
*
31583158
* Given the index OID and column number,
31593159
* return opclass of the index column
3160-
* or InvalidOid if the index was not found.
3160+
* or InvalidOid if the index was not found
3161+
* or column is non-key one.
31613162
*/
31623163
Oid
31633164
get_index_column_opclass(Oid index_oid, int attno)
@@ -3180,11 +3181,20 @@ get_index_column_opclass(Oid index_oid, int attno)
31803181
/* caller is supposed to guarantee this */
31813182
Assert(attno > 0 && attno <= rd_index->indnatts);
31823183

3184+
/* Non-key attributes don't have an opclass */
3185+
if (attno > rd_index->indnkeyatts)
3186+
{
3187+
ReleaseSysCache(tuple);
3188+
return InvalidOid;
3189+
}
3190+
31833191
datum = SysCacheGetAttr(INDEXRELID, tuple,
31843192
Anum_pg_index_indclass, &isnull);
31853193
Assert(!isnull);
31863194

31873195
indclass = ((oidvector *) DatumGetPointer(datum));
3196+
3197+
Assert(attno <= indclass->dim1);
31883198
opclass = indclass->values[attno - 1];
31893199

31903200
ReleaseSysCache(tuple);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.