aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-08-30 22:16:50 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-10-04 22:14:21 -0400
commit036166f26e00ab3286ef29a6519525d6291fdfd7 (patch)
tree2efdc8207d5cfef2dfe32db174741418647bf10c /src
parent582bbcf37fb45ea2e6a851bf9a3c7d7364c7ad32 (diff)
downloadpostgresql-036166f26e00ab3286ef29a6519525d6291fdfd7.tar.gz
postgresql-036166f26e00ab3286ef29a6519525d6291fdfd7.zip
Document and use SPI_result_code_string()
A lot of semi-internal code just prints out numeric SPI error codes, which is not very helpful. We already have an API function to convert the codes to a string, so let's make more use of that. Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/ri_triggers.c10
-rw-r--r--src/test/regress/regress.c2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index b63a7775b7c..ba0e3ad87d2 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -2435,8 +2435,8 @@ RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
qplan = SPI_prepare(querybuf.data, 0, NULL);
if (qplan == NULL)
- elog(ERROR, "SPI_prepare returned %d for %s",
- SPI_result, querybuf.data);
+ elog(ERROR, "SPI_prepare returned %s for %s",
+ SPI_result_code_string(SPI_result), querybuf.data);
/*
* Run the plan. For safety we force a current snapshot to be used. (In
@@ -2453,7 +2453,7 @@ RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
/* Check result */
if (spi_result != SPI_OK_SELECT)
- elog(ERROR, "SPI_execute_snapshot returned %d", spi_result);
+ elog(ERROR, "SPI_execute_snapshot returned %s", SPI_result_code_string(spi_result));
/* Did we find a tuple violating the constraint? */
if (SPI_processed > 0)
@@ -3016,7 +3016,7 @@ ri_PlanCheck(const char *querystr, int nargs, Oid *argtypes,
qplan = SPI_prepare(querystr, nargs, argtypes);
if (qplan == NULL)
- elog(ERROR, "SPI_prepare returned %d for %s", SPI_result, querystr);
+ elog(ERROR, "SPI_prepare returned %s for %s", SPI_result_code_string(SPI_result), querystr);
/* Restore UID and security context */
SetUserIdAndSecContext(save_userid, save_sec_context);
@@ -3144,7 +3144,7 @@ ri_PerformCheck(const RI_ConstraintInfo *riinfo,
/* Check result */
if (spi_result < 0)
- elog(ERROR, "SPI_execute_snapshot returned %d", spi_result);
+ elog(ERROR, "SPI_execute_snapshot returned %s", SPI_result_code_string(spi_result));
if (expect_OK >= 0 && spi_result != expect_OK)
ereport(ERROR,
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index 0a123f2b39e..0e9e46e6678 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -612,7 +612,7 @@ ttdummy(PG_FUNCTION_ARGS)
/* Prepare plan for query */
pplan = SPI_prepare(query, natts, ctypes);
if (pplan == NULL)
- elog(ERROR, "ttdummy (%s): SPI_prepare returned %d", relname, SPI_result);
+ elog(ERROR, "ttdummy (%s): SPI_prepare returned %s", relname, SPI_result_code_string(SPI_result));
if (SPI_keepplan(pplan))
elog(ERROR, "ttdummy (%s): SPI_keepplan failed", relname);