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

Commit4863829

Browse files
committed
If user re-DECLAREs an existing cursor name, close the old cursor of
that name and issue a NOTICE to the effect that we did. Previously,code would try to assign the new cursor declaration to the old portal,but this didn't work reliably since new parsetree is still sitting inblank portal and is likely to get clobbered.
1 parent9b5410a commit4863829

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

‎src/backend/tcop/pquery.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.31 2000/06/0401:44:33 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.32 2000/06/0422:08:53 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515

1616
#include"postgres.h"
1717

18+
#include"commands/command.h"
1819
#include"executor/execdefs.h"
1920
#include"executor/executor.h"
2021
#include"tcop/pquery.h"
2122
#include"utils/ps_status.h"
2223

23-
#include"commands/command.h"
24-
2524
staticchar*CreateOperationTag(intoperationType);
2625
staticvoidProcessQueryDesc(QueryDesc*queryDesc,Node*limoffset,
2726
Node*limcount);
@@ -140,15 +139,32 @@ ProcessPortal(char *portalName,
140139
MemoryContextportalContext;
141140

142141
/* ----------------
143-
* convert the current blank portal into the user-specified
144-
* portal and initialize the state and query descriptor.
142+
* Check for reserved or already-in-use portal name.
145143
* ----------------
146144
*/
147145

148146
if (PortalNameIsSpecial(portalName))
149147
elog(ERROR,
150-
"The portal name %s is reserved for internal use",
148+
"The portal name \"%s\" is reserved for internal use",
149+
portalName);
150+
151+
portal=GetPortalByName(portalName);
152+
if (PortalIsValid(portal))
153+
{
154+
/* XXX Should we raise an error rather than closing the old portal? */
155+
elog(NOTICE,"Closing pre-existing portal \"%s\"",
151156
portalName);
157+
PortalDrop(&portal);
158+
}
159+
160+
/* ----------------
161+
* Convert the current blank portal into the user-specified
162+
* portal and initialize the state and query descriptor.
163+
*
164+
* Since the parsetree has been created in the current blank portal,
165+
* we don't have to do any work to copy it into the user-named portal.
166+
* ----------------
167+
*/
152168

153169
portal=BlankPortalAssignName(portalName);
154170

@@ -159,8 +175,8 @@ ProcessPortal(char *portalName,
159175
PortalCleanup);
160176

161177
/* ----------------
162-
*now create a new blank portal and switch to it.
163-
*Otherwise, the new named portal will be cleaned.
178+
*Now create a new blank portal and switch to it.
179+
*Otherwise, the new named portal will be cleaned at statement end.
164180
*
165181
*Note: portals will only be supported within a BEGIN...END
166182
*block in the near future. Later, someone will fix it to

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp