Commit a0b75a41 authored by Tom Lane's avatar Tom Lane

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.
parent 1abd146d
...@@ -80,11 +80,13 @@ uint32 ...@@ -80,11 +80,13 @@ uint32
_hash_datum2hashkey(Relation rel, Datum key) _hash_datum2hashkey(Relation rel, Datum key)
{ {
FmgrInfo *procinfo; FmgrInfo *procinfo;
Oid collation;
/* XXX assumes index has only one attribute */ /* XXX assumes index has only one attribute */
procinfo = index_getprocinfo(rel, 1, HASHPROC); procinfo = index_getprocinfo(rel, 1, HASHPROC);
collation = rel->rd_indcollation[0];
return DatumGetUInt32(FunctionCall1(procinfo, key)); return DatumGetUInt32(FunctionCall1Coll(procinfo, collation, key));
} }
/* /*
...@@ -98,6 +100,7 @@ uint32 ...@@ -98,6 +100,7 @@ uint32
_hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype) _hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype)
{ {
RegProcedure hash_proc; RegProcedure hash_proc;
Oid collation;
/* XXX assumes index has only one attribute */ /* XXX assumes index has only one attribute */
hash_proc = get_opfamily_proc(rel->rd_opfamily[0], hash_proc = get_opfamily_proc(rel->rd_opfamily[0],
...@@ -108,8 +111,9 @@ _hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype) ...@@ -108,8 +111,9 @@ _hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype)
elog(ERROR, "missing support function %d(%u,%u) for index \"%s\"", elog(ERROR, "missing support function %d(%u,%u) for index \"%s\"",
HASHPROC, keytype, keytype, HASHPROC, keytype, keytype,
RelationGetRelationName(rel)); RelationGetRelationName(rel));
collation = rel->rd_indcollation[0];
return DatumGetUInt32(OidFunctionCall1(hash_proc, key)); return DatumGetUInt32(OidFunctionCall1Coll(hash_proc, collation, key));
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment