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

Commit ca8aa8d

Browse files
committed
Merge branch 'PGPRO10_1328' into PGPRO10
2 parents cd58d36 + 7bfe527 commit ca8aa8d

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
@@ -890,9 +890,14 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
890890
* We support the convention that sk_subtype == InvalidOid means
891891
* the opclass input type; this is a hack to simplify life for
892892
* ScanKeyInit().
893+
*
894+
* We do not require that included columns have opclass.
895+
* So do not try to find the comparison function for these
896+
* attributes.
893897
*/
894-
if (cur->sk_subtype == rel->rd_opcintype[i] ||
895-
cur->sk_subtype == InvalidOid)
898+
if (i < IndexRelationGetNumberOfKeyAttributes(rel) &&
899+
(cur->sk_subtype == rel->rd_opcintype[i] ||
900+
cur->sk_subtype == InvalidOid))
896901
{
897902
FmgrInfo *procinfo;
898903

@@ -910,14 +915,27 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
910915
{
911916
RegProcedure cmp_proc;
912917

913-
cmp_proc = get_opfamily_proc(rel->rd_opfamily[i],
914-
rel->rd_opcintype[i],
915-
cur->sk_subtype,
916-
BTORDER_PROC);
917-
if (!RegProcedureIsValid(cmp_proc))
918-
elog(ERROR, "missing support function %d(%u,%u) for attribute %d of index \"%s\"",
919-
BTORDER_PROC, rel->rd_opcintype[i], cur->sk_subtype,
920-
cur->sk_attno, RelationGetRelationName(rel));
918+
if (i < IndexRelationGetNumberOfKeyAttributes(rel))
919+
{
920+
cmp_proc = get_opfamily_proc(rel->rd_opfamily[i],
921+
rel->rd_opcintype[i],
922+
cur->sk_subtype,
923+
BTORDER_PROC);
924+
if (!RegProcedureIsValid(cmp_proc))
925+
elog(ERROR, "missing support function %d(%u,%u) for attribute %d of index \"%s\"",
926+
BTORDER_PROC, rel->rd_opcintype[i], cur->sk_subtype,
927+
cur->sk_attno, RelationGetRelationName(rel));
928+
}
929+
else
930+
{
931+
/*
932+
* We do not require that included columns have opclass.
933+
* So for included attributes scankey here can only
934+
* be SK_SEARCHNULL or SK_SEARCHNOTNULL
935+
* so it's ok to init scan key entry with invalid cmp_proc.
936+
*/
937+
cmp_proc = InvalidOid;
938+
}
921939
ScanKeyEntryInitialize(scankeys + i,
922940
cur->sk_flags,
923941
cur->sk_attno,

0 commit comments

Comments
 (0)