Re: Problem with CREATE TABLE ... (LIKE ... INCLUDING INDEXES)

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Thom Brown <thom(at)linux(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Problem with CREATE TABLE ... (LIKE ... INCLUDING INDEXES)
Date: 2015-06-14 03:25:17
Message-ID: CAB7nPqQhkB3NtWnyD1MsHpq+Kbu9soi2K0e3S16W=6OOS2YAxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jun 14, 2015 at 11:38 AM, Thom Brown <thom(at)linux(dot)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 reading of 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(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2015-06-14 03:30:30 Re: 9.5 release notes
Previous Message Tatsuo Ishii 2015-06-14 02:44:25 Re: 9.5 release notes