Re: Add missing CREATE TABLE IF NOT EXISTS table_name AS EXECUTE query;
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Andreas Karlsson <andreas@proxel.se>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2019-02-15T08:14:51Z
Lists: pgsql-hackers
On Mon, Feb 11, 2019 at 09:53:59PM +0900, Michael Paquier wrote: > Let's wait a bit more than the beginning of this week. I forgot about > this week's minor release, and it is too late to do something about > this report now, so we will have to wait until the release had > happened. OK, committed down to 9.5. Another thing I have noticed is the following, which is kind of funky (just rinse and repeat once): =# EXPLAIN ANALYZE CREATE TABLE IF NOT EXISTS ac AS SELECT 1; ERROR: 42P07: relation "ac" already exists LOCATION: heap_create_with_catalog, heap.c:1111 The issue here is that we check for IF NOT EXISTS at the high level of ExecCreateTableAs, however EXPLAIN takes the lower path of create_ctas_internal() which enforces if_not_exists to false when building the CreateStmt object to create the relation. This brings out a more interesting issue: how should an EXPLAIN behave in this case? It has nothing to output as the relation already exists. -- Michael
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