pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix handling of pending inserts in nodeModifyTable.c. 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix handling of pending inserts in nodeModifyTable.c. @ 2022-11-25 08:54 Etsuro Fujita <efujita@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Etsuro Fujita @ 2022-11-25 08:54 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ffbb7e65a873e8f1584d2e593416fbe3adc130b6 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 | 96 ++++++++++++++----- src/include/nodes/execnodes.h | 9 ++ 7 files changed, 302 insertions(+), 21 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix handling of pending inserts in nodeModifyTable.c. @ 2022-11-25 08:54 Etsuro Fujita <efujita@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Etsuro Fujita @ 2022-11-25 08:54 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fc02019c09feab1f371fb5881f2f050ce6e30ea9 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 | 96 ++++++++++++++----- src/include/nodes/execnodes.h | 9 ++ 7 files changed, 302 insertions(+), 21 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix handling of pending inserts in nodeModifyTable.c. @ 2022-11-25 08:54 Etsuro Fujita <efujita@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Etsuro Fujita @ 2022-11-25 08:54 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-11-25 08:54 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-11-25 08:54 pgsql: Fix handling of pending inserts in nodeModifyTable.c. Etsuro Fujita <efujita@postgresql.org> 2022-11-25 08:54 pgsql: Fix handling of pending inserts in nodeModifyTable.c. Etsuro Fujita <efujita@postgresql.org> 2022-11-25 08:54 pgsql: Fix handling of pending inserts in nodeModifyTable.c. Etsuro Fujita <efujita@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox