Re: Problem with CREATE TABLE ... (LIKE ... INCLUDING INDEXES) - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Problem with CREATE TABLE ... (LIKE ... INCLUDING INDEXES)
Date
Msg-id CAB7nPqQhkB3NtWnyD1MsHpq+Kbu9soi2K0e3S16W=6OOS2YAxQ@mail.gmail.com
Whole thread Raw
In response to Problem with CREATE TABLE ... (LIKE ... INCLUDING INDEXES)  (Thom Brown <thom@linux.com>)
Responses Re: Problem with CREATE TABLE ... (LIKE ... INCLUDING INDEXES)  (Thom Brown <thom@linux.com>)
List pgsql-hackers
On Sun, Jun 14, 2015 at 11:38 AM, Thom Brown <thom@linux.com> wrote:
> As you can see, 3 indexes are missing, which happen to be ones that
> would duplicate the column definition of another index.  Is this
> intentional?  If so, shouldn't it be documented behaviour?

Looking at the code (transformIndexConstraints in parse_utilcmd.c),
this is intentional behavior:       /*        * Scan the index list and remove any redundant index
specifications. This        * can happen if, for instance, the user writes UNIQUE PRIMARY KEY. A        * strict
readingof SQL would suggest raising an error
 
instead, but that        * strikes me as too anal-retentive. - tgl 2001-02-14        *        * XXX in ALTER TABLE
case,it'd be nice to look for duplicate        * pre-existing indexes, too.        */
 
Per this commit:
commit: c7d2ce7bc6eb02eac0c10fae9caf2936a71ad25c
author: Tom Lane <tgl@sss.pgh.pa.us>
date: Wed, 14 Feb 2001 23:32:38 +0000
Repair problems with duplicate index names generated when CREATE TABLE
specifies redundant UNIQUE conditions.

Perhaps a mention in the docs in the page of CREATE TABLE would be
welcome. Something like "Redundant index definitions are ignored with
INCLUDING INDEXES".

Thoughts?
-- 
Michael



pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: 9.5 release notes
Next
From: Bruce Momjian
Date:
Subject: Re: 9.5 release notes