diff options
author | Tomas Vondra <tomas.vondra@postgresql.org> | 2021-01-21 03:23:24 +0100 |
---|---|---|
committer | Tomas Vondra <tomas.vondra@postgresql.org> | 2021-01-21 03:34:32 +0100 |
commit | 920f853dc948b98a5dc96580c4ee011a302e33e4 (patch) | |
tree | 53513146154c1778f6a845ce6aec8c351e1626ee /src/backend/executor/nodeModifyTable.c | |
parent | 733d670073efd2c3a9df07c225006668009ab793 (diff) | |
download | postgresql-920f853dc948b98a5dc96580c4ee011a302e33e4.tar.gz postgresql-920f853dc948b98a5dc96580c4ee011a302e33e4.zip |
Fix initialization of FDW batching in ExecInitModifyTable
ExecInitModifyTable has to initialize batching for all result relations,
not just the first one. Furthermore, when junk filters were necessary,
the pointer pointed past the mtstate->resultRelInfo array.
Per reports from multiple non-x86 animals (florican, locust, ...).
Discussion: https://postgr.es/m/20200628151002.7x5laxwpgvkyiu3q@development
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
-rw-r--r-- | src/backend/executor/nodeModifyTable.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 9c36860704a..5d903374983 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -2797,18 +2797,29 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) * Determine if the FDW supports batch insert and determine the batch * size (a FDW may support batching, but it may be disabled for the * server/table). + * + * We only do this for INSERT, so that for UPDATE/DELETE the batch + * size remains set to 0. */ - if (!resultRelInfo->ri_usesFdwDirectModify && - operation == CMD_INSERT && - resultRelInfo->ri_FdwRoutine != NULL && - resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize && - resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert) - resultRelInfo->ri_BatchSize = - resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize(resultRelInfo); - else - resultRelInfo->ri_BatchSize = 1; + if (operation == CMD_INSERT) + { + resultRelInfo = mtstate->resultRelInfo; + for (i = 0; i < nplans; i++) + { + if (!resultRelInfo->ri_usesFdwDirectModify && + resultRelInfo->ri_FdwRoutine != NULL && + resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize && + resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert) + resultRelInfo->ri_BatchSize = + resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize(resultRelInfo); + else + resultRelInfo->ri_BatchSize = 1; + + Assert(resultRelInfo->ri_BatchSize >= 1); - Assert(resultRelInfo->ri_BatchSize >= 1); + resultRelInfo++; + } + } /* * Lastly, if this is not the primary (canSetTag) ModifyTable node, add it |