public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v1] Make INSERT SELECT use a BulkInsertState
3+ 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; 3+ 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] 3+ messages in thread

* Improve error message for ICU libraries if pkg-config is absent
@ 2024-08-09 08:16  Michael Banck <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Michael Banck @ 2024-08-09 08:16 UTC (permalink / raw)
  To: pgsql-hackers; +Cc: Holger Jakobs <[email protected]>

Hi,

Holger Jacobs complained in pgsql-admin that in v17, if you have the ICU
development libraries installed but not pkg-config, you get a somewhat
unhelpful error message about ICU not being present:

|checking for pkg-config... no
|checking whether to build with ICU support... yes
|checking for icu-uc icu-i18n... no
|configure: error: ICU library not found
|If you have ICU already installed, see config.log for details on the
|failure.  It is possible the compiler isn't looking in the proper directory.
|Use --without-icu to disable ICU support.

The attached patch improves things to that:

|checking for pkg-config... no
|checking whether to build with ICU support... yes
|configure: error: ICU library not found
|The ICU library could not be found because pkg-config is not available, see
|config.log for details on the failure.  If ICU is installed, the variables
|ICU_CFLAGS and ICU_LIBS can be set explicitly in this case, or use
|--without-icu to disable ICU support.


Michael






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Improve error message for ICU libraries if pkg-config is absent
@ 2024-08-09 08:24  Michael Banck <[email protected]>
  parent: Michael Banck <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Banck @ 2024-08-09 08:24 UTC (permalink / raw)
  To: pgsql-hackers; +Cc: Holger Jakobs <[email protected]>

Meh, forgot the attachment. Also, this should be backpatched to v17 if
accepted.


Michael


Attachments:

  [text/x-diff] 0001-Improve-configure-error-for-ICU-libraries-if-pkg-con.patch (2.0K, ../../[email protected]/2-0001-Improve-configure-error-for-ICU-libraries-if-pkg-con.patch)
  download | inline diff:
From b696949180437a3c7307ac0509cba54828b44259 Mon Sep 17 00:00:00 2001
From: Michael Banck <[email protected]>
Date: Fri, 9 Aug 2024 10:13:27 +0200
Subject: [PATCH] Improve configure error for ICU libraries if pkg-config is
 absent.

If pkg-config is not installed, the ICU libraries cannot be found, but
this was not mentioned in the error message and might lead to confusion
about the actual problem. To improve this, add an additional error
message for the case that pkg-config is not available.

Reported-by: Holger Jakobs
Discussion: https://www.postgresql.org/message-id/ccd579ed-4949-d3de-ab13-9e6456fd2caf%40jakobs.com
---
 configure    | 7 +++++++
 configure.ac | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/configure b/configure
index 4f3aa44756..b3a2774f1b 100755
--- a/configure
+++ b/configure
@@ -8094,6 +8094,13 @@ $as_echo "$with_icu" >&6; }
 
 
 if test "$with_icu" = yes; then
+  if test -z "$PKG_CONFIG"; then
+    as_fn_error $? "ICU library not found
+The ICU library could not be found because pkg-config is not available, see
+config.log for details on the failure.  If ICU is installed, the variables
+ICU_CFLAGS and ICU_LIBS can be set explicitly in this case, or use
+--without-icu to disable ICU support." "$LINENO" 5
+  fi
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for icu-uc icu-i18n" >&5
diff --git a/configure.ac b/configure.ac
index 049bc01491..18472a464a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -829,6 +829,13 @@ AC_MSG_RESULT([$with_icu])
 AC_SUBST(with_icu)
 
 if test "$with_icu" = yes; then
+  if test -z "$PKG_CONFIG"; then
+    AC_MSG_ERROR([ICU library not found
+The ICU library could not be found because pkg-config is not available, see
+config.log for details on the failure.  If ICU is installed, the variables
+ICU_CFLAGS and ICU_LIBS can be set explicitly in this case, or use
+--without-icu to disable ICU support.])
+  fi
   PKG_CHECK_MODULES(ICU, icu-uc icu-i18n, [],
     [AC_MSG_ERROR([ICU library not found
 If you have ICU already installed, see config.log for details on the
-- 
2.39.2



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2024-08-09 08:24 UTC | newest]

Thread overview: 3+ 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]>
2024-08-09 08:16 Improve error message for ICU libraries if pkg-config is absent Michael Banck <[email protected]>
2024-08-09 08:24 ` Re: Improve error message for ICU libraries if pkg-config is absent Michael Banck <[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