mirror of
https://github.com/postgres/postgres.git
synced 2025-08-17 01:02:17 +03:00
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.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
* procedural language
|
* procedural language
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.127.4.5 2006/01/17 17:33:36 tgl Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.127.4.6 2007/01/30 18:02:40 tgl Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@@ -3930,16 +3930,23 @@ make_tuple_from_row(PLpgSQL_execstate *estate,
|
|||||||
static char *
|
static char *
|
||||||
convert_value_to_string(Datum value, Oid valtype)
|
convert_value_to_string(Datum value, Oid valtype)
|
||||||
{
|
{
|
||||||
|
char *str;
|
||||||
Oid typoutput;
|
Oid typoutput;
|
||||||
Oid typioparam;
|
Oid typioparam;
|
||||||
bool typIsVarlena;
|
bool typIsVarlena;
|
||||||
|
|
||||||
getTypeOutputInfo(valtype, &typoutput, &typioparam, &typIsVarlena);
|
getTypeOutputInfo(valtype, &typoutput, &typioparam, &typIsVarlena);
|
||||||
|
|
||||||
return DatumGetCString(OidFunctionCall3(typoutput,
|
SPI_push();
|
||||||
value,
|
|
||||||
ObjectIdGetDatum(typioparam),
|
str = DatumGetCString(OidFunctionCall3(typoutput,
|
||||||
Int32GetDatum(-1)));
|
value,
|
||||||
|
ObjectIdGetDatum(typioparam),
|
||||||
|
Int32GetDatum(-1)));
|
||||||
|
|
||||||
|
SPI_pop();
|
||||||
|
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------
|
/* ----------
|
||||||
@@ -3965,10 +3972,12 @@ exec_cast_value(Datum value, Oid valtype,
|
|||||||
char *extval;
|
char *extval;
|
||||||
|
|
||||||
extval = convert_value_to_string(value, valtype);
|
extval = convert_value_to_string(value, valtype);
|
||||||
|
SPI_push();
|
||||||
value = FunctionCall3(reqinput,
|
value = FunctionCall3(reqinput,
|
||||||
CStringGetDatum(extval),
|
CStringGetDatum(extval),
|
||||||
ObjectIdGetDatum(reqtypioparam),
|
ObjectIdGetDatum(reqtypioparam),
|
||||||
Int32GetDatum(reqtypmod));
|
Int32GetDatum(reqtypmod));
|
||||||
|
SPI_pop();
|
||||||
pfree(extval);
|
pfree(extval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user