8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
15
15
16
16
#include "postgres.h"
17
17
18
+ #include "commands/command.h"
18
19
#include "executor/execdefs.h"
19
20
#include "executor/executor.h"
20
21
#include "tcop/pquery.h"
21
22
#include "utils/ps_status.h"
22
23
23
- #include "commands/command.h"
24
-
25
24
static char * CreateOperationTag (int operationType );
26
25
static void ProcessQueryDesc (QueryDesc * queryDesc ,Node * limoffset ,
27
26
Node * limcount );
@@ -140,15 +139,32 @@ ProcessPortal(char *portalName,
140
139
MemoryContext portalContext ;
141
140
142
141
/* ----------------
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.
145
143
* ----------------
146
144
*/
147
145
148
146
if (PortalNameIsSpecial (portalName ))
149
147
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\"" ,
151
156
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
+ */
152
168
153
169
portal = BlankPortalAssignName (portalName );
154
170
@@ -159,8 +175,8 @@ ProcessPortal(char *portalName,
159
175
PortalCleanup );
160
176
161
177
/* ----------------
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 .
164
180
*
165
181
*Note: portals will only be supported within a BEGIN...END
166
182
*block in the near future. Later, someone will fix it to