aboutsummaryrefslogtreecommitdiff
path: root/src/pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/pl')
-rw-r--r--src/pl/plperl/plperl.c4
-rw-r--r--src/pl/plpgsql/src/pl_exec.c27
-rw-r--r--src/pl/plpython/plpython.c13
-rw-r--r--src/pl/tcl/pltcl.c17
4 files changed, 25 insertions, 36 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index c63e9d7b62e..0906d3186ac 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1,7 +1,7 @@
/**********************************************************************
* plperl.c - perl as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.117 2006/08/13 17:31:10 momjian Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.118 2006/08/27 23:47:58 tgl Exp $
*
**********************************************************************/
@@ -1630,7 +1630,7 @@ plperl_spi_execute_fetch_result(SPITupleTable *tuptable, int processed,
hv_store(result, "processed", strlen("processed"),
newSViv(processed), 0);
- if (status == SPI_OK_SELECT)
+ if (status > 0 && tuptable)
{
AV *rows;
SV *row;
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index f8213d4a50f..dedba151178 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.176 2006/08/15 19:01:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.177 2006/08/27 23:47:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2370,23 +2370,16 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
case SPI_OK_INSERT:
case SPI_OK_UPDATE:
case SPI_OK_DELETE:
+ case SPI_OK_INSERT_RETURNING:
+ case SPI_OK_UPDATE_RETURNING:
+ case SPI_OK_DELETE_RETURNING:
Assert(stmt->mod_stmt);
exec_set_found(estate, (SPI_processed != 0));
break;
case SPI_OK_SELINTO:
- Assert(!stmt->mod_stmt);
- break;
-
case SPI_OK_UTILITY:
Assert(!stmt->mod_stmt);
- /*
- * spi.c currently does not update SPI_processed for utility
- * commands. Not clear if this should be considered a bug;
- * for the moment, work around it here.
- */
- if (SPI_tuptable)
- SPI_processed = (SPI_tuptable->alloced - SPI_tuptable->free);
break;
default:
@@ -2505,16 +2498,10 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
case SPI_OK_INSERT:
case SPI_OK_UPDATE:
case SPI_OK_DELETE:
- break;
-
+ case SPI_OK_INSERT_RETURNING:
+ case SPI_OK_UPDATE_RETURNING:
+ case SPI_OK_DELETE_RETURNING:
case SPI_OK_UTILITY:
- /*
- * spi.c currently does not update SPI_processed for utility
- * commands. Not clear if this should be considered a bug;
- * for the moment, work around it here.
- */
- if (SPI_tuptable)
- SPI_processed = (SPI_tuptable->alloced - SPI_tuptable->free);
break;
case 0:
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 289ab2e7b73..f45ecd72222 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -1,7 +1,7 @@
/**********************************************************************
* plpython.c - python as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.85 2006/08/08 19:15:09 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.86 2006/08/27 23:47:58 tgl Exp $
*
*********************************************************************
*/
@@ -2193,24 +2193,19 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status)
Py_DECREF(result->status);
result->status = PyInt_FromLong(status);
- if (status == SPI_OK_UTILITY)
- {
- Py_DECREF(result->nrows);
- result->nrows = PyInt_FromLong(0);
- }
- else if (status != SPI_OK_SELECT)
+ if (status > 0 && tuptable == NULL)
{
Py_DECREF(result->nrows);
result->nrows = PyInt_FromLong(rows);
}
- else
+ else if (status > 0 && tuptable != NULL)
{
PLyTypeInfo args;
int i;
- PLy_typeinfo_init(&args);
Py_DECREF(result->nrows);
result->nrows = PyInt_FromLong(rows);
+ PLy_typeinfo_init(&args);
oldcontext = CurrentMemoryContext;
PG_TRY();
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index 54abd096722..44b2e405f32 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -2,7 +2,7 @@
* pltcl.c - PostgreSQL support for Tcl as
* procedural language (PL)
*
- * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.106 2006/08/08 19:15:09 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.107 2006/08/27 23:47:58 tgl Exp $
*
**********************************************************************/
@@ -1663,10 +1663,6 @@ pltcl_process_SPI_result(Tcl_Interp *interp,
switch (spi_rc)
{
- case SPI_OK_UTILITY:
- Tcl_SetResult(interp, "0", TCL_VOLATILE);
- break;
-
case SPI_OK_SELINTO:
case SPI_OK_INSERT:
case SPI_OK_DELETE:
@@ -1675,7 +1671,18 @@ pltcl_process_SPI_result(Tcl_Interp *interp,
Tcl_SetResult(interp, buf, TCL_VOLATILE);
break;
+ case SPI_OK_UTILITY:
+ if (tuptable == NULL)
+ {
+ Tcl_SetResult(interp, "0", TCL_VOLATILE);
+ break;
+ }
+ /* FALL THRU for utility returning tuples */
+
case SPI_OK_SELECT:
+ case SPI_OK_INSERT_RETURNING:
+ case SPI_OK_DELETE_RETURNING:
+ case SPI_OK_UPDATE_RETURNING:
/*
* Process the tuples we got