Only DISCARD ALL should be in the command_no_begin list.
authorItagaki Takahiro <[email protected]>
Tue, 28 Sep 2010 06:57:19 +0000 (15:57 +0900)
committerItagaki Takahiro <[email protected]>
Tue, 28 Sep 2010 06:57:19 +0000 (15:57 +0900)
We allowes DISCARD PLANS and TEMP in a transaction.

src/bin/psql/common.c

index c8fc085fa04b49ce5cfac45963b01e3404ff1459..81a633a3d01f21ab3777985d3defb7fe6c0aca9e 100644 (file)
@@ -1369,8 +1369,20 @@ command_no_begin(const char *query)
                        return true;
        }
 
+       /* DISCARD ALL isn't allowed in xacts, but other variants are allowed. */
        if (wordlen == 7 && pg_strncasecmp(query, "discard", 7) == 0)
-               return true;
+       {
+               query += wordlen;
+
+               query = skip_white_space(query);
+
+               wordlen = 0;
+               while (isalpha((unsigned char) query[wordlen]))
+                       wordlen += PQmblen(&query[wordlen], pset.encoding);
+
+               if (wordlen == 3 && pg_strncasecmp(query, "all", 3) == 0)
+                       return true;
+       }
 
        return false;
 }