postgresql/src
Tom Lane 662d12aea1 Avoid crash in eval_const_expressions if a Param's type changes.
Since commit 6719b238e it's been possible for the values of plpgsql
record field variables to be exposed to the planner as Params.
(Before that, plpgsql never supplied values for such variables during
planning, so that the problematic code wasn't reached.)  Other places
that touch potentially-type-mutable Params either cope gracefully or
do runtime-test-and-ereport checks that the type is what they expect.
But eval_const_expressions() just had an Assert, meaning that it either
failed the assertion or risked crashes due to using an incompatible
value.

In this case, rather than throwing an ereport immediately, we can just
not perform a const-substitution in case of a mismatch.  This seems
important for the same reason that the Param fetch was speculative:
we might not actually reach this part of the expression at runtime.

Test case will follow in a separate commit.

Patch by me, pursuant to bug report from Andrew Gierth.
Back-patch to v11 where the previous commit appeared.

Discussion: https://postgr.es/m/87wotkfju1.fsf@news-spur.riddles.org.uk
2018-07-26 16:08:45 -04:00
..
backend Avoid crash in eval_const_expressions if a Param's type changes. 2018-07-26 16:08:45 -04:00
bin psql: Add option for procedures to \df 2018-07-24 11:38:53 +02:00
common Add proper errcodes to new error messages for read() failures 2018-07-23 09:37:36 +09:00
fe_utils Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
include Refactor cluster_rel() to handle more options 2018-07-24 11:37:32 +09:00
interfaces Fix error message when a hostaddr cannot be parsed. 2018-07-19 20:24:29 +03:00
makefiles Remove Windows module-list-dumping code. 2018-04-30 13:20:13 -04:00
pl Add strict_multi_assignment and too_many_rows plpgsql checks 2018-07-25 01:46:32 +02:00
port Guard against rare RAND_bytes() failures in pg_strong_random(). 2018-07-20 08:55:44 +01:00
template Force "restrict" not to be used when compiling with xlc. 2017-10-13 12:15:06 -07:00
test Add strict_multi_assignment and too_many_rows plpgsql checks 2018-07-25 01:46:32 +02:00
timezone Update time zone data files to tzdata release 2018e. 2018-05-09 13:56:22 -04:00
tools Refactor cluster_rel() to handle more options 2018-07-24 11:37:32 +09:00
tutorial Deduplicate "invalid input syntax" messages for various types. 2018-07-22 14:58:01 -07:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Un-break contrib install with llvm. 2018-04-28 14:45:39 -04:00
Makefile.shlib Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-04-03 16:26:05 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00