postgresql/src/backend
Etsuro Fujita e52245228e Fix handling of pending inserts in nodeModifyTable.c.
Commit b663a4136, which allowed FDWs to INSERT rows in bulk, added to
nodeModifyTable.c code to flush pending inserts to the foreign-table
result relation(s) before completing processing of the ModifyTable node,
but the code failed to take into account the case where the INSERT query
has modifying CTEs, leading to incorrect results.

Also, that commit failed to flush pending inserts before firing BEFORE
ROW triggers so that rows are visible to such triggers.

In that commit we scanned through EState's
es_tuple_routing_result_relations or es_opened_result_relations list to
find the foreign-table result relations to which pending inserts are
flushed, but that would be inefficient in some cases.  So to fix, 1) add
a List member to EState to record the insert-pending result relations,
and 2) modify nodeModifyTable.c so that it adds the foreign-table result
relation to the list in ExecInsert() if appropriate, and flushes pending
inserts properly using the list where needed.

While here, fix a copy-and-pasteo in a comment in ExecBatchInsert(),
which was added by that commit.

Back-patch to v14 where that commit appeared.

Discussion: https://postgr.es/m/CAPmGK16qutyCmyJJzgQOhfBq%3DNoGDqTB6O0QBZTihrbqre%2BoxA%40mail.gmail.com
2022-11-25 17:45:03 +09:00
..
access Make multixact error message more explicit 2022-11-24 10:45:10 +01:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog Replace RelationOpenSmgr() with RelationGetSmgr(). 2022-11-17 16:54:30 -05:00
commands Replace RelationOpenSmgr() with RelationGetSmgr(). 2022-11-17 16:54:30 -05:00
executor Fix handling of pending inserts in nodeModifyTable.c. 2022-11-25 17:45:03 +09:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Track LLVM 15 changes. 2022-10-19 22:32:14 +13:00
lib Fix lock assertions in dshash.c. 2022-07-11 15:47:12 +12:00
libpq Remove misguided SSL key file ownership check in libpq. 2022-05-26 14:14:05 -04:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:38 +09:00
nodes Add missing fields to _outConstraint() 2022-08-13 10:37:45 +02:00
optimizer Guard against table-AM-less relations in planner. 2022-10-17 11:35:23 -04:00
parser Rename parser token REF to REF_P to avoid a symbol conflict. 2022-10-16 15:27:04 -04:00
partitioning Avoid using ambiguous word "non-negative" in error messages. 2021-07-28 01:21:35 +09:00
po Translation updates 2022-11-07 13:59:56 +01:00
port Reject huge_pages=on if shared_memory_type=sysv. 2021-10-26 13:09:00 +13:00
postmaster Prevent long-term memory leakage in autovacuum launcher. 2022-08-31 16:23:20 -04:00
regex Defend against stack overrun in a few more places. 2022-08-24 13:01:40 -04:00
replication Fix uninitialized access to InitialRunningXacts during decoding. 2022-11-25 09:25:50 +05:30
rewrite Reject non-ON-SELECT rules that are named "_RETURN". 2022-10-17 12:14:39 -04:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Partially undo commit 94da73281. 2022-08-05 15:57:46 -04:00
storage Ignore invalidated slots while computing oldest catalog Xmin 2022-11-22 10:56:07 +01:00
tcop Force immediate commit after CREATE DATABASE etc in extended protocol. 2022-07-26 13:07:03 -04:00
tsearch Add comments and a missing CHECK_FOR_INTERRUPTS in ts_headline. 2022-11-21 17:07:07 -05:00
utils YA attempt at taming worst-case behavior of get_actual_variable_range. 2022-11-22 14:40:45 -05:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-09-20 16:23:13 +02:00