postgresql/src/backend
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
..
access Fix calculation for WAL segment recycling and removal 2018-07-24 10:32:56 +09:00
bootstrap Use a ResourceOwner to track buffer pins in all cases. 2018-07-18 12:15:16 -04:00
catalog Add toast tables to most system catalogs 2018-07-20 07:43:41 +09:00
commands Refactor cluster_rel() to handle more options 2018-07-24 11:37:32 +09:00
executor LLVMJIT: Release JIT context after running ExprContext shutdown callbacks. 2018-07-25 16:31:49 -07:00
foreign Remove bogus "extern" annotations on function definitions. 2018-02-19 12:07:44 -05:00
jit LLVMJIT: Check for 'noinline' attribute in recursively inlined functions. 2018-07-25 16:23:59 -07:00
lib doc: Update redirecting links 2018-07-16 10:48:05 +02:00
libpq Hand code string to integer conversion for performance. 2018-07-22 14:58:23 -07:00
main Update copyright for 2018 2018-01-02 23:30:12 -05:00
nodes Refactor cluster_rel() to handle more options 2018-07-24 11:37:32 +09:00
optimizer Avoid crash in eval_const_expressions if a Param's type changes. 2018-07-26 16:08:45 -04:00
parser Refactor cluster_rel() to handle more options 2018-07-24 11:37:32 +09:00
partitioning Fix partition pruning with IS [NOT] NULL clauses 2018-07-16 18:38:59 -04:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Pad semaphores to avoid false sharing. 2018-07-25 11:00:29 +12:00
postmaster Use a ResourceOwner to track buffer pins in all cases. 2018-07-18 12:15:16 -04:00
regex Clean up warnings from -Wimplicit-fallthrough. 2018-05-01 19:35:08 -04:00
replication Add proper errcodes to new error messages for read() failures 2018-07-23 09:37:36 +09:00
rewrite Simplify view-expansion code in rewriteHandler.c. 2018-04-14 21:01:03 -04:00
snowball Avoid unnecessary use of pg_strcasecmp for already-downcased identifiers. 2018-01-26 18:25:14 -05:00
statistics Fix bogus code for extracting extended-statistics data from syscache. 2018-05-02 12:23:00 -04:00
storage Fix inadequate buffer locking in FSM and VM page re-initialization. 2018-07-13 11:53:10 -04:00
tcop Add UtilityReturnsTuples() support for CALL 2018-07-09 13:58:08 +02:00
tsearch Hand code string to integer conversion for performance. 2018-07-22 14:58:23 -07:00
utils Defend against some potential spurious compiler warnings in 86eaf208e. 2018-07-24 10:10:22 -07:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00