postgres.git / summary / log / commit / refs
commit 458e9169d682f5aa94c5a4342ee2344d82da8a47
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue Jan 30 18:02:34 2007 +0000
First released in: 8.3.0, 8.0.11, 8.1.7, 8.2.2
Add SPI_push/SPI_pop calls so that datatype input and output functions called
by plpgsql can themselves use SPI --- possibly indirectly, as in the case
of domain_in() invoking plpgsql functions in a domain check constraint.
Per bug #2945 from Sergiy Vyshnevetskiy.
Somewhat arbitrarily, I've chosen to back-patch this as far as 8.0. Given
the lack of prior complaints, it doesn't seem critical for 7.x.
src/pl/plpgsql/src/pl_exec.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 49128ee0276..f537175414a 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.154.2.4 2006/03/02 05:34:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.154.2.5 2007/01/30 18:02:34 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -4086,12 +4086,19 @@ make_tuple_from_row(PLpgSQL_execstate *estate,
static char *
convert_value_to_string(Datum value, Oid valtype)
{
+ char *str;
Oid typoutput;
bool typIsVarlena;
getTypeOutputInfo(valtype, &typoutput, &typIsVarlena);
- return DatumGetCString(OidFunctionCall1(typoutput, value));
+ SPI_push();
+
+ str = DatumGetCString(OidFunctionCall1(typoutput, value));
+
+ SPI_pop();
+
+ return str;
}
/* ----------
@@ -4117,10 +4124,12 @@ exec_cast_value(Datum value, Oid valtype,
char *extval;
extval = convert_value_to_string(value, valtype);
+ SPI_push();
value = FunctionCall3(reqinput,
CStringGetDatum(extval),
ObjectIdGetDatum(reqtypioparam),
Int32GetDatum(reqtypmod));
+ SPI_pop();
pfree(extval);
}
}
[parent: 5e6c06f04074]