postgresql/src/test/regress
Tom Lane 2afe282a37 Fix reporting of column typmods for multi-row VALUES constructs.
expandRTE() and get_rte_attribute_type() reported the exprType() and
exprTypmod() values of the expressions in the first row of the VALUES as
being the column type/typmod returned by the VALUES RTE.  That's fine for
the data type, since we coerce all expressions in a column to have the same
common type.  But we don't coerce them to have a common typmod, so it was
possible for rows after the first one to return values that violate the
claimed column typmod.  This leads to the incorrect result seen in bug
#14448 from Hassan Mahmood, as well as some other corner-case misbehaviors.

The desired behavior is the same as we use in other type-unification
cases: report the common typmod if there is one, but otherwise return -1
indicating no particular constraint.

We fixed this in HEAD by deriving the typmods during transformValuesClause
and storing them in the RTE, but that's not a feasible solution in the back
branches.  Instead, just use a brute-force approach of determining the
correct common typmod during expandRTE() and get_rte_attribute_type().
Simple testing says that that doesn't really cost much, at least not in
common cases where expandRTE() is only used once per query.  It turns out
that get_rte_attribute_type() is typically never used at all on VALUES
RTEs, so the inefficiency there is of no great concern.

Report: https://postgr.es/m/20161205143037.4377.60754@wrigleys.postgresql.org
Discussion: https://postgr.es/m/27429.1480968538@sss.pgh.pa.us
2016-12-09 12:01:14 -05:00
..
data Fix GIN to support null keys, empty and null items, and full index scans. 2011-01-07 19:16:24 -05:00
expected Fix reporting of column typmods for multi-row VALUES constructs. 2016-12-09 12:01:14 -05:00
input Make sure ALTER TABLE preserves index tablespaces. 2016-11-23 13:45:56 -05:00
output Make sure ALTER TABLE preserves index tablespaces. 2016-11-23 13:45:56 -05:00
sql Fix reporting of column typmods for multi-row VALUES constructs. 2016-12-09 12:01:14 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
GNUmakefile Fix regression test parallel-make hazard. 2016-08-12 20:51:59 -04:00
Makefile Remove remains of old depend target. 2007-01-20 17:16:17 +00:00
parallel_schedule Factor out encoding specific tests for json 2015-10-07 22:19:38 -04:00
pg_regress.c Honor PGCTLTIMEOUT environment variable for pg_regress' startup wait. 2016-04-20 23:48:13 -04:00
pg_regress.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
pg_regress_main.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
README Don't generate plain-text HISTORY and src/test/regress/README anymore. 2014-02-10 20:48:12 -05:00
regress.c Clean up code for widget_in() and widget_out(). 2016-01-09 13:44:27 -05:00
regressplans.sh Tweak regressplans.sh to use any already-set PGOPTIONS. 2000-12-18 02:45:47 +00:00
resultmap Enable compiling with the mingw-w64 32 bit compiler. 2011-12-10 15:35:41 -05:00
serial_schedule Factor out encoding specific tests for json 2015-10-07 22:19:38 -04:00
standby_schedule Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00

Documentation concerning how to run these regression tests and interpret
the results can be found in the PostgreSQL manual, in the chapter
"Regression Tests".