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

Commitf224847

Browse files
committed
Remove broken Assertions that failed if a statement executed in PL/pgSQL is
rewritten into another kind of statement, for example if an INSERT isrewritten into an UPDATE.Back-patch to 8.3 and 8.2. For HEAD, Tom suggested inventing a newSPI_OK_REWRITTEN return code, but that's not a backportable solution. I'lldo that as a separate patch, this patch will do as a stopgap measure for HEADtoo in the meanwhile.
1 parent03b4fc7 commitf224847

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 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.228 2009/01/07 20:38:56 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.229 2009/01/14 09:53:51 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2782,13 +2782,19 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
27822782

27832783
/*
27842784
* Check for error, and set FOUND if appropriate (for historical reasons
2785-
* we set FOUND only for certain query types).Also Assert that we
2786-
* identified the statement type the same as SPI did.
2785+
* we set FOUND only for certain query types).
2786+
*
2787+
* Note: the command type indicated by return code might not match
2788+
* mod_stmt, if there is an INSTEAD OF rule rewriting an UPDATE into an
2789+
* INSERT, for example. In that case, the INSERT doesn't have canSetTag
2790+
* set, mod_stmt is false, and SPI_execute_plan sets SPI_processed to
2791+
* zero. We'll set FOUND to false here in that case. If the statement is
2792+
* rewritten into a utility statement, however, FOUND is left unchanged.
2793+
* Arguably that's a bug, but changing it now could break applications.
27872794
*/
27882795
switch (rc)
27892796
{
27902797
caseSPI_OK_SELECT:
2791-
Assert(!stmt->mod_stmt);
27922798
exec_set_found(estate, (SPI_processed!=0));
27932799
break;
27942800

@@ -2798,13 +2804,11 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
27982804
caseSPI_OK_INSERT_RETURNING:
27992805
caseSPI_OK_UPDATE_RETURNING:
28002806
caseSPI_OK_DELETE_RETURNING:
2801-
Assert(stmt->mod_stmt);
28022807
exec_set_found(estate, (SPI_processed!=0));
28032808
break;
28042809

28052810
caseSPI_OK_SELINTO:
28062811
caseSPI_OK_UTILITY:
2807-
Assert(!stmt->mod_stmt);
28082812
break;
28092813

28102814
default:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp