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

Commitd2e17e1

Browse files
committed
Fix mishandling of after-trigger state when a SQL function returns multiple
rows --- if the surrounding query queued any trigger events between the rows,the events would be fired at the wrong time, leading to bizarre behavior.Per report from Merlin Moncure.This is a simple patch that should solve the problem fully in the backbranches, but in HEAD we also need to consider the possibility of querieswith RETURNING clauses. Will look into a fix for that separately.
1 parentb38900c commitd2e17e1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎src/backend/executor/functions.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.107 2006/10/04 00:29:52 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.108 2006/10/12 17:02:24 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -327,7 +327,14 @@ postquel_start(execution_state *es, SQLFunctionCachePtr fcache)
327327
/* Utility commands don't need Executor. */
328328
if (es->qd->operation!=CMD_UTILITY)
329329
{
330-
AfterTriggerBeginQuery();
330+
/*
331+
* Only set up to collect queued triggers if it's not a SELECT.
332+
* This isn't just an optimization, but is necessary in case a SELECT
333+
* returns multiple rows to caller --- we mustn't exit from the
334+
* function execution with a stacked AfterTrigger level still active.
335+
*/
336+
if (es->qd->operation!=CMD_SELECT)
337+
AfterTriggerBeginQuery();
331338
ExecutorStart(es->qd,0);
332339
}
333340

@@ -401,7 +408,8 @@ postquel_end(execution_state *es)
401408
{
402409
ActiveSnapshot=es->qd->snapshot;
403410

404-
AfterTriggerEndQuery(es->qd->estate);
411+
if (es->qd->operation!=CMD_SELECT)
412+
AfterTriggerEndQuery(es->qd->estate);
405413
ExecutorEnd(es->qd);
406414
}
407415
PG_CATCH();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp