Re-allow CREATE AS (but not SELECT INTO) in EXECUTE.
authorTom Lane <[email protected]>
Mon, 25 Mar 2002 07:41:21 +0000 (07:41 +0000)
committerTom Lane <[email protected]>
Mon, 25 Mar 2002 07:41:21 +0000 (07:41 +0000)
src/pl/plpgsql/src/pl_exec.c

index d61fac528970498960eed3d516f7d86e0f87c90a..b6d6df21c23896b58d442565d896a548d5fc191d 100644 (file)
@@ -3,7 +3,7 @@
  *                       procedural language
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.52 2001/11/15 23:31:09 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.52.2.1 2002/03/25 07:41:21 tgl Exp $
  *
  *       This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -2019,13 +2019,25 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate,
                case SPI_OK_SELINTO:
 
                        /*
-                        * Disallow this for now, because its behavior is not
-                        * consistent with SELECT INTO in a normal plpgsql context. We
-                        * need to reimplement EXECUTE to parse the string as a
-                        * plpgsql command, not just feed it to SPI_exec.
+                        * We want to disallow SELECT INTO for now, because its behavior
+                        * is not consistent with SELECT INTO in a normal plpgsql
+                        * context. (We need to reimplement EXECUTE to parse the string
+                        * as a plpgsql command, not just feed it to SPI_exec.)
+                        * However, CREATE AS should be allowed ... and since it produces
+                        * the same parsetree as SELECT INTO, there's no way to tell
+                        * the difference except to look at the source text.  Wotta
+                        * kluge!
                         */
-                       elog(ERROR, "EXECUTE of SELECT ... INTO is not implemented yet");
+               {
+                       char   *ptr;
+
+                       for (ptr = querystr; *ptr; ptr++)
+                               if (!isspace((unsigned char) *ptr))
+                                       break;
+                       if (*ptr == 'S' || *ptr == 's')
+                               elog(ERROR, "EXECUTE of SELECT ... INTO is not implemented yet");
                        break;
+               }
 
                default:
                        elog(ERROR, "unexpected error %d in EXECUTE of query '%s'",