pgsql: Fix handling of pending inserts in nodeModifyTable.c.
От | Etsuro Fujita |
---|---|
Тема | pgsql: Fix handling of pending inserts in nodeModifyTable.c. |
Дата | |
Msg-id | E1oyUTm-000jyh-7A@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
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 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e52245228ecf3a58b031c820332bc56478bb1ba2 Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 123 +++++++++++++++++++++++++ contrib/postgres_fdw/sql/postgres_fdw.sql | 86 +++++++++++++++++ src/backend/executor/execMain.c | 1 + src/backend/executor/execPartition.c | 7 ++ src/backend/executor/execUtils.c | 1 + src/backend/executor/nodeModifyTable.c | 92 +++++++++++++----- src/include/nodes/execnodes.h | 9 ++ 7 files changed, 298 insertions(+), 21 deletions(-)
В списке pgsql-committers по дате отправления: