Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpcLQ-0000TR-LU for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Sep 2016 14:29:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bpcLQ-0006Zu-85 for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Sep 2016 14:29:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bpcKl-0005MG-AM for pgsql-bugs@postgresql.org; Thu, 29 Sep 2016 14:29:11 +0000 Received: from vsmtpvtin1.tin.it ([212.216.176.105]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpcKh-0008UN-Il for pgsql-bugs@postgresql.org; Thu, 29 Sep 2016 14:29:10 +0000 Received: from [10.70.219.25] (5.170.111.108) by vsmtpvtin1.tin.it (8.6.060.43) (authenticated as mroscio) id 57ED13BB0001276A; Thu, 29 Sep 2016 16:29:04 +0200 Message-ID: <57ED252F.2070301@tin.it> Date: Thu, 29 Sep 2016 16:29:03 +0200 From: "M. Roscio" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Tom Lane CC: pgsql-bugs@postgresql.org Subject: Re: BUG #14346: CREATE TABLE xxx (LIKE yyy INCLUDING ALL) fails References: <20160929113732.20224.74918@wrigleys.postgresql.org> <4645.1475153940@sss.pgh.pa.us> In-Reply-To: <4645.1475153940@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------050004090504080206020402" X-Pg-Spam-Score: -4.4 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------050004090504080206020402 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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@tin.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 > --------------050004090504080206020402 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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@tin.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


--------------050004090504080206020402--