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

Commit839484f

Browse files
committed
Avoid scribbling on original parsetree during DECLARE CURSOR. This
prevents problems when the DECLARE is in a portal and is executedrepeatedly, as is possible in v3 protocol. Per analysis by OliverJowett, though I didn't use his patch exactly.
1 parent3ad9f45 commit839484f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

‎src/backend/commands/portalcmds.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.36 2004/09/1616:58:28 tgl Exp $
17+
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.37 2004/11/28 22:16:31 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -61,13 +61,22 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params)
6161
if (!(stmt->options&CURSOR_OPT_HOLD))
6262
RequireTransactionChain((void*)stmt,"DECLARE CURSOR");
6363

64+
/*
65+
* Because the planner is not cool about not scribbling on its input,
66+
* we make a preliminary copy of the source querytree. This prevents
67+
* problems in the case that the DECLARE CURSOR is in a portal and is
68+
* executed repeatedly. XXX the planner really shouldn't modify its
69+
* input ... FIXME someday.
70+
*/
71+
query=copyObject(stmt->query);
72+
6473
/*
6574
* The query has been through parse analysis, but not rewriting or
6675
* planning as yet. Note that the grammar ensured we have a SELECT
6776
* query, so we are not expecting rule rewriting to do anything
6877
* strange.
6978
*/
70-
rewritten=QueryRewrite((Query*)stmt->query);
79+
rewritten=QueryRewrite(query);
7180
if (list_length(rewritten)!=1|| !IsA(linitial(rewritten),Query))
7281
elog(ERROR,"unexpected rewrite result");
7382
query= (Query*)linitial(rewritten);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp