Skip to content

Commit a0b75a4

Browse files
committed
Hash indexes had better pass the index collation to support functions, too.
Per experimentation with contrib/citext, whose hash function assumes that it'll be passed a collation.
1 parent 1abd146 commit a0b75a4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/access/hash/hashutil.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ uint32
8080
_hash_datum2hashkey(Relation rel, Datum key)
8181
{
8282
FmgrInfo *procinfo;
83+
Oid collation;
8384

8485
/* XXX assumes index has only one attribute */
8586
procinfo = index_getprocinfo(rel, 1, HASHPROC);
87+
collation = rel->rd_indcollation[0];
8688

87-
return DatumGetUInt32(FunctionCall1(procinfo, key));
89+
return DatumGetUInt32(FunctionCall1Coll(procinfo, collation, key));
8890
}
8991

9092
/*
@@ -98,6 +100,7 @@ uint32
98100
_hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype)
99101
{
100102
RegProcedure hash_proc;
103+
Oid collation;
101104

102105
/* XXX assumes index has only one attribute */
103106
hash_proc = get_opfamily_proc(rel->rd_opfamily[0],
@@ -108,8 +111,9 @@ _hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype)
108111
elog(ERROR, "missing support function %d(%u,%u) for index \"%s\"",
109112
HASHPROC, keytype, keytype,
110113
RelationGetRelationName(rel));
114+
collation = rel->rd_indcollation[0];
111115

112-
return DatumGetUInt32(OidFunctionCall1(hash_proc, key));
116+
return DatumGetUInt32(OidFunctionCall1Coll(hash_proc, collation, key));
113117
}
114118

115119
/*

0 commit comments

Comments
 (0)