From: | Neil Conway <neilc(at)samurai(dot)com> |
---|---|
To: | NikhilS <nikkhils(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, Trevor Hardcastle <chizu(at)spicious(dot)com>, pgsql-patches(at)postgresql(dot)org |
Subject: | Re: CREATE TABLE LIKE INCLUDING INDEXES support |
Date: | 2007-07-16 07:46:39 |
Message-ID: | 1184571999.11492.23.camel@goldbach |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
On Tue, 2007-10-07 at 12:53 +0530, NikhilS wrote:
> Yes, in the CREATE..LIKE case, options will be NULL and in the normal
> CREATE..INDEX case inhreloptions will be NULL. Note that options is a
> List of DefElem entries, whereas inhreloptions is a char pointer.
Hmm, right -- ugly. I'll just stick with your approach.
BTW, I notice a problem with the patch as implemented:
# create table abc (a int, b int);
CREATE TABLE
# create index abc_a_idx on abc using hash (a);
CREATE INDEX
# create index abc_a_idx2 on abc (a);
CREATE INDEX
# create table abc2 (like abc including indexes);
CREATE TABLE
# \d abc2
Table "public.abc2"
Column | Type | Modifiers
--------+---------+-----------
a | integer |
b | integer |
Indexes:
"abc2_a_key" hash (a)
This occurs because transformIndexConstraints() eliminates "duplicate"
indexes from the index list by looking for two indexes with equal()
column lists. This makes some sense for the normal CREATE TABLE case,
but the above behavior is certainly objectionable -- when the access
method differs it is merely surprising, but when partial indexes are
involved it is surely a bug.
One way to fix this would be to check for duplicates by comparing all
the fields of the two IndexStmts, *except* the index name and "is PK?"
status. But that's ugly -- it seems much cleaner to keep index
definitions arising from LIKE ... INCLUDING INDEXES in a separate list
from the indexes derived from constraints.
Attached is a revised patch that does that. Barring any objections, I'll
apply this to HEAD tomorrow.
-Neil
Attachment | Content-Type | Size |
---|---|---|
including_indexes_v5.patch | text/x-patch | 39.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | NikhilS | 2007-07-16 08:58:32 | Re: CREATE TABLE LIKE INCLUDING INDEXES support |
Previous Message | Pavel Stehule | 2007-07-16 05:54:23 | Re: plpgsql and qualified variable names |
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2007-07-16 08:41:14 | Re: BUG #3439: pg_standby and path name with space |
Previous Message | Stephan Szabo | 2007-07-16 06:58:49 | Re: Deferred RI trigger for non-key UPDATEs and subxacts |