Re: BUG #14346: CREATE TABLE xxx (LIKE yyy INCLUDING ALL) fails

From: "M(dot) Roscio" <mroscio(at)tin(dot)it>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14346: CREATE TABLE xxx (LIKE yyy INCLUDING ALL) fails
Date: 2016-09-29 14:29:03
Message-ID: 57ED252F.2070301@tin.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thank you for your reply.

I understand that getting the primary key as xxx_pkey , while I
expected pk_xxx, is not a bug, it's a feature.

However I insist about foreign keys: source table is present with 13
rows in information_schema.key_column_usage,
while destination table only has one.

To provide a complete example, I must "sanitize" the names which are
linked to the product I am working on. It will take some time.

There are ten single-column foreign keys, one three-column foreign key.
Primary key is single-column, numeric, named "oid".

Kind regards
Massimo Roscio

On 29/09/16 14:59, Tom Lane wrote:
> mroscio(at)tin(dot)it writes:
>> When yyy has no primary keys, all constraints are duly created on xxx.
>> When yyy has a primary key named pk_yyy, a primary key named xxx_pkey is
>> created, all other constraints are lost.
> Works for me ...
>
> regression=# create table yyy (f1 int constraint pk_yyy primary key, f2 int unique);
> CREATE TABLE
> regression=# \d yyy
> Table "public.yyy"
> Column | Type | Modifiers
> --------+---------+-----------
> f1 | integer | not null
> f2 | integer |
> Indexes:
> "pk_yyy" PRIMARY KEY, btree (f1)
> "yyy_f2_key" UNIQUE CONSTRAINT, btree (f2)
>
> regression=# create table xxx (like yyy including all);
> CREATE TABLE
> regression=# \d xxx
> Table "public.xxx"
> Column | Type | Modifiers
> --------+---------+-----------
> f1 | integer | not null
> f2 | integer |
> Indexes:
> "xxx_pkey" PRIMARY KEY, btree (f1)
> "xxx_f2_key" UNIQUE CONSTRAINT, btree (f2)
>
>
> regards, tom lane
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2016-09-29 14:32:04 Re: BUG #14336: Using rls on a table, suddenly the table is missing
Previous Message huang 2016-09-29 14:05:18 Re: vacuumdb has a fatal after database rename