Re: CREATE TABLE LIKE INCLUDING INDEXES support

From: Neil Conway <neilc(at)samurai(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Trevor Hardcastle <chizu(at)spicious(dot)com>, NikhilS <nikkhils(at)gmail(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: CREATE TABLE LIKE INCLUDING INDEXES support
Date: 2007-04-27 22:59:10
Message-ID: 1177714750.6440.160.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

This patch needs more work. How carefully did you test it?

* the patch failed to copy index constraints if there was not also at
least one CHECK constraint defined on the table

* the patch is broken for expressional indexes, and silently omits
copying the predicate that may be associated with an index. It also
doesn't copy the index's amoptions (WITH clause), or the NULLS
FIRST/etc. options that may be associated with any of the index's
columns.

In other words, copying column names does not suffice to duplicate the
index constraint. Perhaps the right fix is to implement support for
INCLUDING INDEXES, and then use that code to copy the definition of any
constraint indexes in INCLUDING INDEXES?

* should we copy invalid indexes? I suppose there's nothing wrong with
copying them...

* we should probably hold the AccessShareLock on copied indexes till end
of xact, per the comments at the end of transformInhRelation()

* index_open() should be matched with index_close(), not
relation_close(). (In the current implementation, index_close() and
relation_close() happen to be identical, so it still worked.)

I've attached a revised version of the patch, but I didn't fix the
second or third bullets in the list.

-Neil

Attachment Content-Type Size
including_constraints_idx-2.patch text/x-patch 10.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message rancpine cui 2007-04-28 00:58:31 Re: Fwd: How does the partitioned lock manager works?
Previous Message Tom Lane 2007-04-27 22:06:35 Re: BUG #3244: problem with PREPARE

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2007-04-28 22:41:26 Re: Hash function for numeric (WIP)
Previous Message Jim Nasby 2007-04-27 17:33:06 Re: too much WAL volume