Add missing CREATE TABLE IF NOT EXISTS table_name AS EXECUTE query;
Andreas Karlsson <andreas@proxel.se>
From: Andreas Karlsson <andreas@proxel.se>
To: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2019-02-06T02:20:41Z
Lists: pgsql-hackers
Attachments
- ctas-exec-ifne-v1.sql (application/sql)
Hi,
The first example below works while the second one is a syntax error
despite that the documentation
(https://www.postgresql.org/docs/11/sql-createtableas.html) makes it
seem like both should be valid. I do not see any reason to not support
CTAS with both IF NOT EXISTS and EXECUTE at the same time so i am
guessing that this was an oversight.
I have attached a patch which fixes this. What do you think? Should I
add a new test case for this or is the change simple enough to not
require any new test?
# CREATE TABLE IF NOT EXISTS a AS SELECT 1;
SELECT 1
# PREPARE q AS SELECT 1;
PREPARE
Time: 0.209 ms
foo=# CREATE TABLE IF NOT EXISTS a AS EXECUTE q;
ERROR: syntax error at or near "EXECUTE"
LINE 1: CREATE TABLE IF NOT EXISTS a AS EXECUTE q;
^
Andreas
Commits
-
Fix support for CREATE TABLE IF NOT EXISTS AS EXECUTE
- 06cdab9df413 9.5.17 landed
- d08fae3773ea 9.6.13 landed
- 3a2923a9bfd8 10.8 landed
- 75aba11ec5ed 11.3 landed
- 331a613e9d36 12.0 landed