diff options
author | Neil Conway <neilc@samurai.com> | 2007-07-17 05:02:03 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2007-07-17 05:02:03 +0000 |
commit | 474774918b4b55e774d2fcc1d7e94c8c632fadef (patch) | |
tree | e66fbdcfb273895d951edbabf44cee998327000a /src/backend/commands | |
parent | 77d27e43e5f204736175a2f6fc45959e0dcb5fd8 (diff) | |
download | postgresql-474774918b4b55e774d2fcc1d7e94c8c632fadef.tar.gz postgresql-474774918b4b55e774d2fcc1d7e94c8c632fadef.zip |
Implement CREATE TABLE LIKE ... INCLUDING INDEXES. Patch from NikhilS,
based in part on an earlier patch from Trevor Hardcastle, and reviewed
by myself.
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/indexcmds.c | 17 | ||||
-rw-r--r-- | src/backend/commands/tablecmds.c | 3 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 98dad737133..943662f8f8b 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.160 2007/06/23 22:12:50 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.161 2007/07/17 05:02:00 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -79,6 +79,8 @@ static bool relationHasPrimaryKey(Relation rel); * to index on. * 'predicate': the partial-index condition, or NULL if none. * 'options': reloptions from WITH (in list-of-DefElem form). + * 'src_options': reloptions from the source index, if this is a cloned + * index produced by CREATE TABLE LIKE ... INCLUDING INDEXES * 'unique': make the index enforce uniqueness. * 'primary': mark the index as a primary key in the catalogs. * 'isconstraint': index is for a PRIMARY KEY or UNIQUE constraint, @@ -100,6 +102,7 @@ DefineIndex(RangeVar *heapRelation, List *attributeList, Expr *predicate, List *options, + char *src_options, bool unique, bool primary, bool isconstraint, @@ -392,9 +395,17 @@ DefineIndex(RangeVar *heapRelation, } /* - * Parse AM-specific options, convert to text array form, validate. + * Parse AM-specific options, convert to text array form, + * validate. The src_options introduced due to using indexes + * via the "CREATE LIKE INCLUDING INDEXES" statement also need to + * be merged here */ - reloptions = transformRelOptions((Datum) 0, options, false, false); + if (src_options) + reloptions = unflatten_reloptions(src_options); + else + reloptions = (Datum) 0; + + reloptions = transformRelOptions(reloptions, options, false, false); (void) index_reloptions(amoptions, reloptions, true); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 4bc2a25fcdd..07e56620428 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.229 2007/07/03 01:30:36 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.230 2007/07/17 05:02:00 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -3794,6 +3794,7 @@ ATExecAddIndex(AlteredTableInfo *tab, Relation rel, stmt->indexParams, /* parameters */ (Expr *) stmt->whereClause, stmt->options, + stmt->src_options, stmt->unique, stmt->primary, stmt->isconstraint, |