postgresql/src
Tom Lane 7a980dfc6c Fix matching of sub-partitions when a partitioned plan is stale.
Since we no longer require AccessExclusiveLock to add a partition,
the executor may see that a partitioned table has more partitions
than the planner saw.  ExecCreatePartitionPruneState's code for
matching up the partition lists in such cases was faulty, and would
misbehave if the planner had successfully pruned any partitions from
the query.  (Thus, trouble would occur only if a partition addition
happens concurrently with a query that uses both static and dynamic
partition pruning.)  This led to an Assert failure in debug builds,
and probably to crashes or query misbehavior in production builds.

To repair the bug, just explicitly skip zeroes in the plan's
relid_map[] list.  I also made some cosmetic changes to make the code
more readable (IMO anyway).  Also, convert the cross-checking Assert
to a regular test-and-elog, since it's now apparent that this logic
is more fragile than one would like.

Currently, there's no way to repeatably exercise this code, except
with manual use of a debugger to stop the backend between planning
and execution.  Hence, no test case in this patch.  We oughta do
something about that testability gap, but that's for another day.

Amit Langote and Tom Lane, per report from Justin Pryzby.  Oversight
in commit 898e5e329; backpatch to v12 where that appeared.

Discussion: https://postgr.es/m/20200802181131.GA27754@telsasoft.com
2020-08-05 15:38:55 -04:00
..
backend Fix matching of sub-partitions when a partitioned plan is stale. 2020-08-05 15:38:55 -04:00
bin Remove unnecessary "DISTINCT" in psql's queries for \dAc and \dAf. 2020-08-03 14:02:35 -04:00
common Prevent compilation of frontend-only files in src/common/ with backend 2020-06-30 13:26:11 +09:00
fe_utils Mop up some no-longer-necessary hacks around printf %.*s format. 2020-06-29 17:12:38 -04:00
include Correct comment in simplehash.h. 2020-08-03 12:23:05 +12:00
interfaces Increase hard-wired timeout values in ecpg regression tests. 2020-08-04 15:20:31 -04:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Fix -Wcast-function-type warnings 2020-07-14 19:55:25 +02:00
port Remove optimization for RAND_poll() failing. 2020-07-25 14:50:59 -07:00
template Fix compiler warning for ppoll() on Cygwin 2019-12-22 23:20:00 +01:00
test Make new SSL TAP test for channel_binding more robust 2020-08-04 14:36:01 +09:00
timezone Ensure that distributed timezone abbreviation files are plain ASCII. 2020-07-17 11:03:55 -04:00
tools Rename configure.in to configure.ac 2020-07-24 10:42:08 +02:00
tutorial Update copyrights for 2020 2020-01-01 12:21:45 -05: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 Update Unicode data to Unicode 13.0.0 and CLDR 37 2020-04-24 09:52:59 +02:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00