Looks heap_create_with_catalog ignored the if_not_exists options

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Looks heap_create_with_catalog ignored the if_not_exists options
Date: 2019-03-01 11:17:04
Message-ID: CAKU4AWpGFMgp3zF-8TUkpydPZ5kJcY-yWcdN92mwRnSbJW2zhQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

for a createStmt, it will call transformCreateStmt, and then
heap_create_with_catalog.
but looks it just check the if_not_exists in transformCreateStmt.

so there is a chance that when the transformCreateStmt is called, the table
is not created, but before the heap_create_with_catalog is called, the
table was created. if so, the "if not exits" will raise error "ERROR:
relation "xxxx" already exists"

I can reproduce this with gdb,

demo=# create table if not exists dddd2 (a int);
ERROR: relation "dddd2" already exists

is it designed as this on purpose or is it a bug?

I am using the lates commit on github now.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Švorc Martin 2019-03-01 11:25:03 pg_background and BGWH_STOPPED
Previous Message Antonin Houska 2019-03-01 11:16:58 Re: Problems with plan estimates in postgres_fdw