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

Commitafeb8c4

Browse files
committed
Clean up some unnecessary fragility in EXECUTE command.
1 parentf9d6ffc commitafeb8c4

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.33 2000/12/01 20:43:59 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.34 2001/01/04 02:38:02 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -1951,6 +1951,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate,
19511951
HeapTupletypetup;
19521952
Form_pg_typetypeStruct;
19531953
FmgrInfofinfo_output;
1954+
intexec_res;
19541955

19551956
/* ----------
19561957
* First we evaluate the string expression after the
@@ -1960,7 +1961,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate,
19601961
*/
19611962
query=exec_eval_expr(estate,stmt->query,&isnull,&restype);
19621963
if (isnull)
1963-
elog(ERROR,"cannot EXECUTE NULL-query");
1964+
elog(ERROR,"cannot EXECUTE NULLquery");
19641965

19651966
/* ----------
19661967
* Get the C-String representation.
@@ -1986,26 +1987,30 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate,
19861987

19871988
/* ----------
19881989
* Call SPI_exec() without preparing a saved plan.
1989-
* The returncode can be any OK except for OK_SELECT.
1990+
* The returncode can be any standard OK. Note that
1991+
* while a SELECT is allowed, its results will be discarded.
19901992
* ----------
19911993
*/
1992-
switch(SPI_exec(querystr,0))
1994+
exec_res=SPI_exec(querystr,0);
1995+
switch (exec_res)
19931996
{
1994-
caseSPI_OK_UTILITY:
1997+
caseSPI_OK_SELECT:
19951998
caseSPI_OK_SELINTO:
19961999
caseSPI_OK_INSERT:
19972000
caseSPI_OK_UPDATE:
19982001
caseSPI_OK_DELETE:
2002+
caseSPI_OK_UTILITY:
19992003
break;
20002004

2001-
caseSPI_OK_SELECT:
2002-
elog(ERROR,"unexpected SELECT operation in EXECUTE of query '%s'",
2003-
querystr);
2005+
case0:
2006+
/* Also allow a zero return, which implies the querystring
2007+
* contained no commands.
2008+
*/
20042009
break;
20052010

20062011
default:
2007-
elog(ERROR,"unexpected error in EXECUTEfor query '%s'",
2008-
querystr);
2012+
elog(ERROR,"unexpected error%din EXECUTEof query '%s'",
2013+
exec_res,querystr);
20092014
break;
20102015
}
20112016

@@ -2095,7 +2100,7 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt)
20952100
* ----------
20962101
*/
20972102
if (SPI_exec(querystr,0)!=SPI_OK_SELECT)
2098-
elog(ERROR,"FOR ... EXECUTE query '%s' wasno SELECT",querystr);
2103+
elog(ERROR,"FOR ... EXECUTE query '%s' wasnot SELECT",querystr);
20992104
pfree(querystr);
21002105

21012106
n=SPI_processed;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp