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

Commit 9433440

Browse files
committed
Merge branch 'PGPRO10' into PGPROEE10
2 parents bad7c8f + ca8aa8d commit 9433440

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

src/backend/access/nbtree/nbtsearch.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,14 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
11431143
* We support the convention that sk_subtype == InvalidOid means
11441144
* the opclass input type; this is a hack to simplify life for
11451145
* ScanKeyInit().
1146+
*
1147+
* We do not require that included columns have opclass.
1148+
* So do not try to find the comparison function for these
1149+
* attributes.
11461150
*/
1147-
if (cur->sk_subtype == rel->rd_opcintype[i] ||
1148-
cur->sk_subtype == InvalidOid)
1151+
if (i < IndexRelationGetNumberOfKeyAttributes(rel) &&
1152+
(cur->sk_subtype == rel->rd_opcintype[i] ||
1153+
cur->sk_subtype == InvalidOid))
11491154
{
11501155
FmgrInfo *procinfo;
11511156

@@ -1163,14 +1168,27 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
11631168
{
11641169
RegProcedure cmp_proc;
11651170

1166-
cmp_proc = get_opfamily_proc(rel->rd_opfamily[i],
1167-
rel->rd_opcintype[i],
1168-
cur->sk_subtype,
1169-
BTORDER_PROC);
1170-
if (!RegProcedureIsValid(cmp_proc))
1171-
elog(ERROR, "missing support function %d(%u,%u) for attribute %d of index \"%s\"",
1172-
BTORDER_PROC, rel->rd_opcintype[i], cur->sk_subtype,
1173-
cur->sk_attno, RelationGetRelationName(rel));
1171+
if (i < IndexRelationGetNumberOfKeyAttributes(rel))
1172+
{
1173+
cmp_proc = get_opfamily_proc(rel->rd_opfamily[i],
1174+
rel->rd_opcintype[i],
1175+
cur->sk_subtype,
1176+
BTORDER_PROC);
1177+
if (!RegProcedureIsValid(cmp_proc))
1178+
elog(ERROR, "missing support function %d(%u,%u) for attribute %d of index \"%s\"",
1179+
BTORDER_PROC, rel->rd_opcintype[i], cur->sk_subtype,
1180+
cur->sk_attno, RelationGetRelationName(rel));
1181+
}
1182+
else
1183+
{
1184+
/*
1185+
* We do not require that included columns have opclass.
1186+
* So for included attributes scankey here can only
1187+
* be SK_SEARCHNULL or SK_SEARCHNOTNULL
1188+
* so it's ok to init scan key entry with invalid cmp_proc.
1189+
*/
1190+
cmp_proc = InvalidOid;
1191+
}
11741192
ScanKeyEntryInitialize(scankeys + i,
11751193
cur->sk_flags,
11761194
cur->sk_attno,

0 commit comments

Comments
 (0)