mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Fix failure to check whether a rowtype's component types are sortable.
The existence of a btree opclass accepting composite types caused us to assume that every composite type is sortable. This isn't true of course; we need to check if the column types are all sortable. There was logic for this for the case of array comparison (ie, check that the element type is sortable), but we missed the point for rowtypes. Per Teodor's report of an ANALYZE failure for an unsortable composite type. Rather than just add some more ad-hoc logic for this, I moved knowledge of the issue into typcache.c. The typcache will now only report out array_eq, record_cmp, and friends as usable operators if the array or composite type will work with those functions. Unfortunately we don't have enough info to do this for anonymous RECORD types; in that case, just assume it will work, and take the runtime failure as before if it doesn't. This patch might be a candidate for back-patching at some point, but given the lack of complaints from the field, I'd rather just test it in HEAD for now. Note: most of the places touched in this patch will need further work when we get around to supporting hashing of record types.
This commit is contained in:
@ -39,7 +39,9 @@ typedef struct TypeCacheEntry
|
||||
* Information obtained from opfamily entries
|
||||
*
|
||||
* These will be InvalidOid if no match could be found, or if the
|
||||
* information hasn't yet been requested.
|
||||
* information hasn't yet been requested. Also note that for array and
|
||||
* composite types, typcache.c checks that the contained types are
|
||||
* comparable or hashable before allowing eq_opr etc to become set.
|
||||
*/
|
||||
Oid btree_opf; /* the default btree opclass' family */
|
||||
Oid btree_opintype; /* the default btree opclass' opcintype */
|
||||
@ -55,8 +57,8 @@ typedef struct TypeCacheEntry
|
||||
* Pre-set-up fmgr call info for the equality operator, the btree
|
||||
* comparison function, and the hash calculation function. These are kept
|
||||
* in the type cache to avoid problems with memory leaks in repeated calls
|
||||
* to array_eq, array_cmp, hash_array. There is not currently a need to
|
||||
* maintain call info for the lt_opr or gt_opr.
|
||||
* to functions such as array_eq, array_cmp, hash_array. There is not
|
||||
* currently a need to maintain call info for the lt_opr or gt_opr.
|
||||
*/
|
||||
FmgrInfo eq_opr_finfo;
|
||||
FmgrInfo cmp_proc_finfo;
|
||||
@ -69,6 +71,9 @@ typedef struct TypeCacheEntry
|
||||
*/
|
||||
TupleDesc tupDesc;
|
||||
|
||||
/* Private data, for internal use of typcache.c only */
|
||||
int flags; /* flags about what we've computed */
|
||||
|
||||
/*
|
||||
* Private information about an enum type. NULL if not enum or
|
||||
* information hasn't been requested.
|
||||
|
Reference in New Issue
Block a user