Re: Add missing CREATE TABLE IF NOT EXISTS table_name AS EXECUTE query;

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add missing CREATE TABLE IF NOT EXISTS table_name AS EXECUTE query;
Date: 2019-02-15 08:14:51
Message-ID: 20190215081451.GD2240@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-02-15 08:17:11 Re: 2019-03 CF Summary / Review - Tranche #1
Previous Message Peter Eisentraut 2019-02-15 07:59:41 Re: INSTALL file