Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit33d78c9

Browse files
committed
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 caseof 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. Giventhe lack of prior complaints, it doesn't seem critical for 7.x.
1 parentae875d3 commit33d78c9

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.185 2007/01/28 17:58:13 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.186 2007/01/30 18:02:22 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -4282,12 +4282,27 @@ make_tuple_from_row(PLpgSQL_execstate *estate,
42824282
staticchar*
42834283
convert_value_to_string(Datumvalue,Oidvaltype)
42844284
{
4285+
char*str;
42854286
Oidtypoutput;
42864287
booltypIsVarlena;
42874288

42884289
getTypeOutputInfo(valtype,&typoutput,&typIsVarlena);
42894290

4290-
returnOidOutputFunctionCall(typoutput,value);
4291+
/*
4292+
* We do SPI_push to allow the datatype output function to use SPI.
4293+
* However we do not mess around with CommandCounterIncrement or advancing
4294+
* the snapshot, which means that a stable output function would not see
4295+
* updates made so far by our own function. The use-case for such
4296+
* scenarios seems too narrow to justify the cycles that would be
4297+
* expended.
4298+
*/
4299+
SPI_push();
4300+
4301+
str=OidOutputFunctionCall(typoutput,value);
4302+
4303+
SPI_pop();
4304+
4305+
returnstr;
42914306
}
42924307

42934308
/* ----------
@@ -4313,14 +4328,25 @@ exec_cast_value(Datum value, Oid valtype,
43134328
char*extval;
43144329

43154330
extval=convert_value_to_string(value,valtype);
4331+
4332+
/* Allow input function to use SPI ... see notes above */
4333+
SPI_push();
4334+
43164335
value=InputFunctionCall(reqinput,extval,
43174336
reqtypioparam,reqtypmod);
4337+
4338+
SPI_pop();
4339+
43184340
pfree(extval);
43194341
}
43204342
else
43214343
{
4344+
SPI_push();
4345+
43224346
value=InputFunctionCall(reqinput,NULL,
43234347
reqtypioparam,reqtypmod);
4348+
4349+
SPI_pop();
43244350
}
43254351
}
43264352

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp