Change warnings for non-existing or pre-existing cursors to errors.
authorPeter Eisentraut <peter_e@gmx.net>
Sun, 24 Aug 2003 21:02:43 +0000 (21:02 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Sun, 24 Aug 2003 21:02:43 +0000 (21:02 +0000)
doc/src/sgml/ref/close.sgml
doc/src/sgml/ref/declare.sgml
doc/src/sgml/ref/fetch.sgml
src/backend/commands/portalcmds.c
src/backend/utils/mmgr/portalmem.c
src/test/regress/expected/portals.out

index c86e945a3dc8ea6f419b2e500fd8d46aceba897d..63b2f15d16c0301d266060a5d2bf85b61ca2d964 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/close.sgml,v 1.15 2003/08/17 04:46:00 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/close.sgml,v 1.16 2003/08/24 21:02:42 petere Exp $
 PostgreSQL documentation
 -->
 
@@ -70,10 +70,10 @@ CLOSE <replaceable class="PARAMETER">cursor</replaceable>
    </varlistentry>
 
    <varlistentry>
-    <term><computeroutput>WARNING:  PerformPortalClose: portal "<replaceable class="PARAMETER">cursor</replaceable>" not found</computeroutput></term>
+    <term><computeroutput>ERROR:  cursor "<replaceable class="PARAMETER">cursor</replaceable>" does not exist</computeroutput></term>
     <listitem>
      <para>
-      This warning is given if <replaceable
+      Message returned if <replaceable
       class="PARAMETER">cursor</replaceable> is not declared or has
       already been closed.
      </para>
index 0aaf0dde43d0038f43fb5df75e011c872ca7e597..14ce71f4a6624562dffbc47d848dad02fbac9090 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/declare.sgml,v 1.24 2003/05/04 02:23:16 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/declare.sgml,v 1.25 2003/08/24 21:02:42 petere Exp $
 PostgreSQL documentation
 -->
 
@@ -202,11 +202,10 @@ DECLARE <replaceable class="parameter">cursorname</replaceable> [ BINARY ] [ INS
    </varlistentry>
 
    <varlistentry>
-    <term><computeroutput>WARNING:  Closing pre-existing portal "<replaceable class="parameter">cursorname</replaceable>"</computeroutput></term>
+    <term><computeroutput>ERROR:  cursor "<replaceable class="parameter">cursorname</replaceable>" already exists</computeroutput></term>
     <listitem>
      <para>
-      This message is reported if a cursor with the same name already
-      exists. The previous definition is discarded.
+      This error occurs if a cursor with the same name already exists.
      </para>
     </listitem>
    </varlistentry>
index 305e5fc02ccaa66e2f1c8731fe531d9e055268e8..05960eb2e0fac1a2d39a582e0f056fc4655db745 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/fetch.sgml,v 1.29 2003/05/04 02:23:16 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/fetch.sgml,v 1.30 2003/08/24 21:02:43 petere Exp $
 PostgreSQL documentation
 -->
 
@@ -281,7 +281,7 @@ where <replaceable class="PARAMETER">direction</replaceable> can be empty or one
 
   <variablelist>
    <varlistentry>
-    <term><computeroutput>WARNING:  PerformPortalFetch: portal "<replaceable class="PARAMETER">cursor</replaceable>" not found</computeroutput></term>
+    <term><computeroutput>ERROR:  cursor "<replaceable class="PARAMETER">cursor</replaceable>" does not exist</computeroutput></term>
     <listitem>
      <para>
       There is no cursor with the specified name.
index c11b48db4c1ad1b803f52069c7477d3c6a23cf8e..27cd7503c30ce4ba1f92454fd269e43e7e43b821 100644 (file)
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.23 2003/08/08 21:41:32 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.24 2003/08/24 21:02:43 petere Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -88,10 +88,9 @@ PerformCursorOpen(DeclareCursorStmt *stmt)
 
    /*
     * Create a portal and copy the query and plan into its memory
-    * context. (If a duplicate cursor name already exists, warn and drop
-    * it.)
+    * context.
     */
-   portal = CreatePortal(stmt->portalname, true, false);
+   portal = CreatePortal(stmt->portalname, false, false);
 
    oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
 
@@ -168,13 +167,10 @@ PerformPortalFetch(FetchStmt *stmt,
    portal = GetPortalByName(stmt->portalname);
    if (!PortalIsValid(portal))
    {
-       /* FIXME: shouldn't this be an ERROR? */
-       ereport(WARNING,
+       ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_CURSOR),
-             errmsg("portal \"%s\" does not exist", stmt->portalname)));
-       if (completionTag)
-           strcpy(completionTag, stmt->ismove ? "MOVE 0" : "FETCH 0");
-       return;
+                errmsg("cursor \"%s\" does not exist", stmt->portalname)));
+       return; /* keep compiler happy */
    }
 
    /* Adjust dest if needed.  MOVE wants destination None */
@@ -218,11 +214,10 @@ PerformPortalClose(const char *name)
    portal = GetPortalByName(name);
    if (!PortalIsValid(portal))
    {
-       ereport(WARNING,
+       ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_CURSOR),
-                errmsg("portal \"%s\" does not exist", name),
-                errfunction("PerformPortalClose")));   /* for ecpg */
-       return;
+                errmsg("cursor \"%s\" does not exist", name)));
+       return; /* keep compiler happy */
    }
 
    /*
index 3e51ad2b36c96e493f0fff4d823e93cf42904f54..00bf3e23d2395f586551b7c33177e75f8ac2e34a 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.61 2003/08/04 02:40:08 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.62 2003/08/24 21:02:43 petere Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -167,11 +167,11 @@ CreatePortal(const char *name, bool allowDup, bool dupSilent)
        if (!allowDup)
            ereport(ERROR,
                    (errcode(ERRCODE_DUPLICATE_CURSOR),
-                    errmsg("portal \"%s\" already exists", name)));
+                    errmsg("cursor \"%s\" already exists", name)));
        if (!dupSilent)
            ereport(WARNING,
                    (errcode(ERRCODE_DUPLICATE_CURSOR),
-                    errmsg("closing pre-existing portal \"%s\"",
+                    errmsg("closing existing cursor \"%s\"",
                            name)));
        PortalDrop(portal, false);
    }
index 245edffe543db67f259d9943be0171f645728b3f..b8f834189823e1462dee43f512058b0744c8854b 100644 (file)
@@ -737,4 +737,4 @@ DECLARE foo26 CURSOR WITH HOLD FOR SELECT * FROM tenk1;
 ROLLBACK;
 -- should fail
 FETCH FROM foo26;
-WARNING:  portal "foo26" does not exist
+ERROR:  cursor "foo26" does not exist