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

Commitc6ce5f7

Browse files
committed
Fix handling of non-key columns get_index_column_opclass()
f2e4038 introduces support of non-key attributes in GiST indexes. Then ifget_index_column_opclass() is asked by gistproperty() to get an opclass ofnon-key column, it returns garbage past oidvector value. This commit fixesthat by making get_index_column_opclass() return InvalidOid in this case.Discussion:https://postgr.es/m/20190902231948.GA5343%40alvherre.pgsqlAuthor: Nikita Glukhov, Alexander KorotkovBackpatch-through: 12
1 parent55a808c commitc6ce5f7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines 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(Oidindex_oid,intattno)
@@ -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+
returnInvalidOid;
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)

[8]ページ先頭

©2009-2025 Movatter.jp