postgresql/src/include
Tom Lane 2bd6dcdeff Fix interaction of CASE and ArrayCoerceExpr.
An array-type coercion appearing within a CASE that has a constant
(after const-folding) test expression was mangled by the planner, causing
all the elements of the resulting array to be equal to the coerced value
of the CASE's test expression.  This is my oversight in commit c12d570fa:
that changed ArrayCoerceExpr to use a subexpression involving a
CaseTestExpr, and I didn't notice that eval_const_expressions needed an
adjustment to keep from folding such a CaseTestExpr to a constant when
it's inside a suitable CASE.

This is another in what's getting to be a depressingly long line of bugs
associated with misidentification of the referent of a CaseTestExpr.
We're overdue to redesign that mechanism; but any such fix is unlikely
to be back-patchable into v11.  As a stopgap, fix eval_const_expressions
to do what it must here.  Also add a bunch of comments pointing out the
restrictions and assumptions that are needed to make this work at all.

Also fix a related oversight: contain_context_dependent_node() was not
aware of the relationship of ArrayCoerceExpr to CaseTestExpr.  That was
somewhat fail-soft, in that the outcome of a wrong answer would be to
prevent optimizations that could have been made, but let's fix it while
we're at it.

Per bug #15471 from Matt Williams.  Back-patch to v11 where the faulty
logic came in.

Discussion: https://postgr.es/m/15471-1117f49271989bad@postgresql.org
2018-10-30 15:26:11 -04:00
..
access Fix logical decoding error when system table w/ toast is repeatedly rewritten. 2018-10-10 13:53:02 -07:00
bootstrap Rationalize handling of array type names in bootstrap data. 2018-04-17 18:29:11 -04:00
catalog Fix event triggers for partitioned tables 2018-10-06 19:17:46 -03:00
commands Fix issues around EXPLAIN with JIT. 2018-10-03 13:11:44 -07:00
common Remove support for tls-unique channel binding. 2018-08-05 13:44:26 +03:00
datatype Update copyright for 2018 2018-01-02 23:30:12 -05:00
executor Advance transaction timestamp for intra-procedure transactions. 2018-10-08 16:16:36 -04:00
fe_utils Ensure schema qualification in pg_restore DISABLE/ENABLE TRIGGER commands. 2018-08-17 17:12:21 -04:00
foreign Allow insert and update tuple routing and COPY for foreign tables. 2018-04-06 19:22:03 -04:00
jit Collect JIT instrumentation from workers. 2018-09-25 13:12:45 -07:00
lib Fix a boatload of typos in C comments. 2018-04-01 15:01:28 -04:00
libpq Remove duplicate function declarations. 2018-08-14 14:25:14 -04:00
mb Fix a boatload of typos in C comments. 2018-04-01 15:01:28 -04:00
nodes Fix interaction of CASE and ArrayCoerceExpr. 2018-10-30 15:26:11 -04:00
optimizer Don't allow LIMIT/OFFSET clause within sub-selects to be pushed to workers. 2018-09-14 09:51:47 +05:30
parser Fix INSERT ON CONFLICT UPDATE through a view that isn't just SELECT *. 2018-08-04 19:38:58 -04:00
partitioning Fix run-time partition pruning for appends with multiple source rels. 2018-08-01 19:42:53 -04:00
port Fix misc typos, mostly in comments. 2018-07-18 16:17:42 +03:00
portability Update copyright for 2018 2018-01-02 23:30:12 -05:00
postmaster Add comment explaining BGWORKER_BYPASS_ALLOWCONN 2018-04-23 10:31:22 +02:00
regex Update copyright for 2018 2018-01-02 23:30:12 -05:00
replication Fix memory leak in TRUNCATE decoding 2018-09-03 02:29:51 +02:00
rewrite Revert MERGE patch 2018-04-12 11:22:56 +01:00
snowball Update copyright for 2018 2018-01-02 23:30:12 -05:00
statistics Update copyright for 2018 2018-01-02 23:30:12 -05:00
storage Fix longstanding recursion hazard in sinval message processing. 2018-09-07 18:04:55 -04:00
tcop Fix event triggers for partitioned tables 2018-10-06 19:17:46 -03:00
tsearch Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
utils Simplify use of AllocSetContextCreate() wrapper macro. 2018-10-12 14:26:56 -04:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:29 -04:00
fmgr.h Add expression compilation support to LLVM JIT provider. 2018-03-22 14:45:59 -07:00
funcapi.h Support INOUT arguments in procedures 2018-03-14 12:07:28 -04:00
getaddrinfo.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
getopt_long.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
Makefile Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
miscadmin.h Allow group access on PGDATA 2018-04-07 17:45:39 -04:00
pg_config.h.in Fix detection of the result type of strerror_r(). 2018-09-30 16:24:56 -04:00
pg_config.h.win32 Stamp 11.0. 2018-10-15 17:12:02 -04:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Improve error reporting for unsupported effective_io_concurrency setting. 2018-09-28 16:12:13 -04:00
pg_getopt.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_trace.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pgstat.h Revert "Allow on-line enabling and disabling of data checksums" 2018-04-09 19:03:42 +02:00
pgtar.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pgtime.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
port.h Revert "Allow concurrent-safe open() and fopen() in frontend code for Windows" 2018-09-18 17:28:27 -04:00
postgres.h Detoast plpgsql variables if they might live across a transaction boundary. 2018-05-16 14:56:52 -04:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
rusagestub.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
windowapi.h Update copyright for 2018 2018-01-02 23:30:12 -05:00