public inbox for [email protected]
help / color / mirror / Atom feed[PATCH v1] Make INSERT SELECT use a BulkInsertState
2+ messages / 2 participants
[nested] [flat]
* [PATCH v1] Make INSERT SELECT use a BulkInsertState
@ 2020-05-08 07:17 Justin Pryzby <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Justin Pryzby @ 2020-05-08 07:17 UTC (permalink / raw)
---
src/backend/executor/nodeModifyTable.c | 21 +++++++++++++++++++--
src/include/nodes/execnodes.h | 2 ++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index 20a4c474cc..aa85245f39 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -578,7 +578,7 @@ ExecInsert(ModifyTableState *mtstate,
table_tuple_insert_speculative(resultRelationDesc, slot,
estate->es_output_cid,
0,
- NULL,
+ NULL, /* Bulk insert not supported */
specToken);
/* insert index entries for tuple */
@@ -617,7 +617,7 @@ ExecInsert(ModifyTableState *mtstate,
/* insert the tuple normally */
table_tuple_insert(resultRelationDesc, slot,
estate->es_output_cid,
- 0, NULL);
+ 0, mtstate->bistate);
/* insert index entries for tuple */
if (resultRelInfo->ri_NumIndices > 0)
@@ -2332,6 +2332,17 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
mtstate->mt_arowmarks = (List **) palloc0(sizeof(List *) * nplans);
mtstate->mt_nplans = nplans;
+ mtstate->bistate = NULL;
+ if (operation == CMD_INSERT &&
+ node->onConflictAction != ONCONFLICT_UPDATE &&
+ node->rootResultRelIndex < 0)
+ {
+ Plan *p = linitial(node->plans);
+ Assert(nplans == 1);
+
+ if (!IsA(p, Result) && !IsA(p, ProjectSet) && !IsA(p, ValuesScan))
+ mtstate->bistate = GetBulkInsertState();
+ }
/* set up epqstate with dummy subplan data for the moment */
EvalPlanQualInit(&mtstate->mt_epqstate, estate, NULL, NIL, node->epqParam);
@@ -2776,6 +2787,12 @@ ExecEndModifyTable(ModifyTableState *node)
resultRelInfo);
}
+ if (node->bistate)
+ {
+ FreeBulkInsertState(node->bistate);
+ table_finish_bulk_insert((getTargetResultRelInfo(node))->ri_RelationDesc, 0);
+ }
+
/*
* Close all the partitioned tables, leaf partitions, and their indices
* and release the slot used for tuple routing, if set.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 4fee043bb2..daf365f181 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -14,6 +14,7 @@
#ifndef EXECNODES_H
#define EXECNODES_H
+#include "access/heapam.h"
#include "access/tupconvert.h"
#include "executor/instrument.h"
#include "fmgr.h"
@@ -1177,6 +1178,7 @@ typedef struct ModifyTableState
List **mt_arowmarks; /* per-subplan ExecAuxRowMark lists */
EPQState mt_epqstate; /* for evaluating EvalPlanQual rechecks */
bool fireBSTriggers; /* do we need to fire stmt triggers? */
+ BulkInsertState bistate; /* State for bulk insert like INSERT SELECT */
/*
* Slot for storing tuples in the root partitioned table's rowtype during
--
2.17.0
--4Ckj6UjgE2iN1+kY--
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Is pg_regress --use-existing used by anyone or is it broken?
@ 2023-08-29 21:38 Nathan Bossart <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Nathan Bossart @ 2023-08-29 21:38 UTC (permalink / raw)
To: Daniel Gustafsson <[email protected]>; +Cc: PostgreSQL Hackers <[email protected]>
On Mon, Aug 28, 2023 at 03:11:15PM +0200, Daniel Gustafsson wrote:
> When looking at pg_regress I noticed that the --use-existing support didn't
> seem to work. ISTM that the removal/creation of test databases and roles
> doesn't run since the conditional is reversed. There is also no support for
> using a non-default socket directory with PG_REGRESS_SOCK_DIR. The attached
> hack fixes these and allows the tests to execute for me, but even with that the
> test_setup suite fails due to the tablespace not being dropped and recreated
> like databases and roles.
>
> Is it me who is too thick to get it working, or is it indeed broken? If it's
> the latter, it's been like that for a long time which seems to indicate that it
> isn't really used and should probably be removed rather than fixed?
>
> Does anyone here use it?
I don't think I've ever used it. AFAICT it was added with hot standby mode
(efc16ea) to support 'make standbycheck', which was removed last year
(4483b2cf). Unless someone claims to be using it, it's probably fine to
just remove it.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-08-29 21:38 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08 07:17 [PATCH v1] Make INSERT SELECT use a BulkInsertState Justin Pryzby <[email protected]>
2023-08-29 21:38 Re: Is pg_regress --use-existing used by anyone or is it broken? Nathan Bossart <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox