agora inbox for [email protected]
help / color / mirror / Atom feedFrom: Mark Dilger <[email protected]>
Subject: [PATCH v1 4/5] Refactoring SPI execute related errors.
Date: Thu, 7 Nov 2019 12:20:46 -0800
Deprecating SPI_ERROR_PARAM in favor of throwing an error. This error
code was only being returned when a caller of SPI_execute_plan,
SPI_execute_snapshot, or SPI_execute_with_args passed in a plan which
has nargs > 0 but then negligently passed in NULL for the Values and/or
argtypes. This would be a C coding error, not a state of affairs that a
user could trigger.
---
doc/src/sgml/spi.sgml | 9 ---------
src/backend/executor/spi.c | 8 +++-----
src/include/executor/spi.h | 2 +-
3 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml
index abe1475256..cca91f6ef6 100644
--- a/doc/src/sgml/spi.sgml
+++ b/doc/src/sgml/spi.sgml
@@ -1439,15 +1439,6 @@ int SPI_execute_plan(SPIPlanPtr <parameter>plan</parameter>, Datum * <parameter>
</listitem>
</varlistentry>
- <varlistentry>
- <term><symbol>SPI_ERROR_PARAM</symbol></term>
- <listitem>
- <para>
- if <parameter>values</parameter> is <symbol>NULL</symbol> and
- <parameter>plan</parameter> was prepared with some parameters
- </para>
- </listitem>
- </varlistentry>
</variablelist>
</para>
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 7d227a11d2..579e80a6a7 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -538,7 +538,7 @@ SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls,
return SPI_ERROR_ARGUMENT;
if (plan->nargs > 0 && Values == NULL)
- return SPI_ERROR_PARAM;
+ elog(ERROR, "SPI_execute_plan passed invalid parameters");
res = _SPI_begin_call(true);
if (res < 0)
@@ -608,7 +608,7 @@ SPI_execute_snapshot(SPIPlanPtr plan,
return SPI_ERROR_ARGUMENT;
if (plan->nargs > 0 && Values == NULL)
- return SPI_ERROR_PARAM;
+ elog(ERROR, "SPI_execute_snapshot passed invalid parameters");
res = _SPI_begin_call(true);
if (res < 0)
@@ -644,7 +644,7 @@ SPI_execute_with_args(const char *src,
return SPI_ERROR_ARGUMENT;
if (nargs > 0 && (argtypes == NULL || Values == NULL))
- return SPI_ERROR_PARAM;
+ elog(ERROR, "SPI_execute_with_args passed invalid parameters");
res = _SPI_begin_call(true);
if (res < 0)
@@ -1717,8 +1717,6 @@ SPI_result_code_string(int code)
return "SPI_ERROR_UNCONNECTED";
case SPI_ERROR_ARGUMENT:
return "SPI_ERROR_ARGUMENT";
- case SPI_ERROR_PARAM:
- return "SPI_ERROR_PARAM";
case SPI_ERROR_TRANSACTION:
return "SPI_ERROR_TRANSACTION";
case SPI_ERROR_NOATTRIBUTE:
diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h
index 7a43b9d21e..575978737f 100644
--- a/src/include/executor/spi.h
+++ b/src/include/executor/spi.h
@@ -42,7 +42,7 @@ typedef struct _SPI_plan *SPIPlanPtr;
#define SPI_ERROR_UNCONNECTED (-4)
#define SPI_ERROR_CURSOR (-5) /* not used anymore */
#define SPI_ERROR_ARGUMENT (-6)
-#define SPI_ERROR_PARAM (-7)
+#define SPI_ERROR_PARAM (-7) /* not used anymore */
#define SPI_ERROR_TRANSACTION (-8)
#define SPI_ERROR_NOATTRIBUTE (-9)
#define SPI_ERROR_NOOUTFUNC (-10) /* not used anymore */
--
2.20.1
--------------EE32DA189D040DF51B4A06B1
Content-Type: text/x-patch;
name="v1-0005-Refactoring-SPI-related-errors.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="v1-0005-Refactoring-SPI-related-errors.patch"
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH v1 4/5] Refactoring SPI execute related errors.
In-Reply-To: <no-message-id-1883341@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox