mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Fix CheckAttributeType's handling of collations for ranges.
Commit fc7695891
changed CheckAttributeType to recurse into ranges,
but made it pass down the wrong collation (always InvalidOid, since
ranges as such have no collation). This would result in guaranteed
failure when considering a range type whose subtype is collatable.
Embarrassingly, we lack any regression tests that would expose such
a problem (but fortunately, somebody noticed before we shipped this
bug in any release).
Fix it to pass down the range's subtype collation property instead,
and add some regression test cases to exercise collatable-subtype
ranges a bit more. Back-patch to all supported branches, as the
previous patch was.
Report and patch by Julien Rouhaud, test cases tweaked by me
Discussion: https://postgr.es/m/CAOBaU_aBWqNweiGUFX0guzBKkcfJ8mnnyyGC_KBQmO12Mj5f_A@mail.gmail.com
This commit is contained in:
26
src/backend/utils/cache/lsyscache.c
vendored
26
src/backend/utils/cache/lsyscache.c
vendored
@ -3150,6 +3150,32 @@ get_range_subtype(Oid rangeOid)
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_range_collation
|
||||
* Returns the collation of a given range type
|
||||
*
|
||||
* Returns InvalidOid if the type is not a range type,
|
||||
* or if its subtype is not collatable.
|
||||
*/
|
||||
Oid
|
||||
get_range_collation(Oid rangeOid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
|
||||
Oid result;
|
||||
|
||||
result = rngtup->rngcollation;
|
||||
ReleaseSysCache(tp);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
/* ---------- PG_INDEX CACHE ---------- */
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user