postgresql/src
Tom Lane 88ceac5d77 Fix parallel-safety marking when moving initplans to another node.
Our policy since commit ab77a5a45 has been that a plan node having
any initplans is automatically not parallel-safe.  (This could be
relaxed, but not today.)  clean_up_removed_plan_level neglected
this, and could attach initplans to a parallel-safe child plan
node without clearing the plan's parallel-safe flag.  That could
lead to "subplan was not initialized" errors at runtime, in case
an initplan referenced another one and only the referencing one
got transmitted to parallel workers.

The fix in clean_up_removed_plan_level is trivial enough.
materialize_finished_plan also moves initplans from one node
to another, but it's okay because it already copies the source
node's parallel_safe flag.  The other place that does this kind
of thing is standard_planner's hack to inject a top-level Gather
when debug_parallel_query is active.  But that's actually dead
code given that we're correctly enforcing the "initplans aren't
parallel safe" rule, so just replace it with an Assert that
there are no initplans.

Also improve some related comments.

Normally we'd add a regression test case for this sort of bug.
The mistake itself is already reached by existing tests, but there
is accidentally no visible problem.  The only known test case that
creates an actual failure seems too indirect and fragile to justify
keeping it as a regression test (not least because it fails to fail
in v11, though the bug is clearly present there too).

Per report from Justin Pryzby.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/ZDVt6MaNWkRDO1LQ@telsasoft.com
2023-04-12 10:46:38 -04:00
..
backend Fix parallel-safety marking when moving initplans to another node. 2023-04-12 10:46:38 -04:00
bin Introduce PG_IO_ALIGN_SIZE and align all I/O buffers. 2023-04-08 16:34:50 +12:00
common Introduce PG_IO_ALIGN_SIZE and align all I/O buffers. 2023-04-08 16:34:50 +12:00
fe_utils Revert refactoring of restore command code to shell_restore.c 2023-02-06 08:28:42 +09:00
include Fix detection of unseekable files for fseek() and ftello() with MSVC 2023-04-12 09:09:38 +09:00
interfaces Revert "Add support for Kerberos credential delegation" 2023-04-08 07:21:35 -04:00
makefiles meson: Make auto the default of the ssl option 2023-03-13 07:04:11 +01:00
pl Add a way to get the current function's OID in pl/pgsql. 2023-04-04 13:33:18 -04:00
port Fix detection of unseekable files for fseek() and ftello() with MSVC 2023-04-12 09:09:38 +09:00
template Use unnamed POSIX semaphores on Cygwin. 2023-01-06 10:33:28 +13:00
test 035_standby_logical_decoding: Add missing waits for replication 2023-04-11 11:17:36 -07:00
timezone Fix outdated references to guc.c 2023-03-02 13:49:39 +01:00
tools Fix detection of unseekable files for fseek() and ftello() with MSVC 2023-04-12 09:09:38 +09:00
tutorial Remove useless casts to (void *) in arguments of some system functions 2023-02-07 06:57:59 +01:00
.gitignore
DEVELOPERS
Makefile Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
Makefile.global.in pg_regress: Emit TAP compliant output 2023-03-31 13:00:02 +02:00
Makefile.shlib autoconf: Rely on ar supporting index creation 2022-10-07 11:53:39 -07:00
meson.build Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
nls-global.mk Fix for make unportability 2022-07-13 09:15:01 +02:00