pgsql: Fix failure to check whether a rowtype's component types are sor

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix failure to check whether a rowtype's component types are sor
Date: 2011-06-03 19:39:43
Message-ID: E1QSaDf-0001qT-9p@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/ea8e42f3a0848f506d8a1b9c74967248005291cd

Modified Files
--------------
src/backend/optimizer/plan/subselect.c | 1 +
src/backend/parser/parse_oper.c | 36 ----
src/backend/utils/cache/lsyscache.c | 61 +++---
src/backend/utils/cache/typcache.c | 345 +++++++++++++++++++++++++++-----
src/include/catalog/pg_operator.h | 3 +
src/include/utils/typcache.h | 11 +-
src/test/regress/expected/rowtypes.out | 10 +
src/test/regress/sql/rowtypes.sql | 7 +
8 files changed, 348 insertions(+), 126 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2011-06-03 20:06:27 pgsql: Fix pg_get_constraintdef to cope with NOT VALID constraints
Previous Message Peter Eisentraut 2011-06-03 19:25:52 pgsql: Truncate id to <=44 characters