diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-07-16 13:25:18 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-07-16 13:25:18 -0400 |
commit | c92be3c0595d504a1516e7e158d085150ff1c4dc (patch) | |
tree | 028234f315cc68ee4369e93a4bead271292f9095 /src/include/commands/defrem.h | |
parent | 54fd196ffc6432b62fe075e564f457db64fb288c (diff) | |
download | postgresql-c92be3c0595d504a1516e7e158d085150ff1c4dc.tar.gz postgresql-c92be3c0595d504a1516e7e158d085150ff1c4dc.zip |
Avoid pre-determining index names during CREATE TABLE LIKE parsing.
Formerly, when trying to copy both indexes and comments, CREATE TABLE LIKE
had to pre-assign names to indexes that had comments, because it made up an
explicit CommentStmt command to apply the comment and so it had to know the
name for the index. This creates bad interactions with other indexes, as
shown in bug #6734 from Daniele Varrazzo: the preassignment logic couldn't
take any other indexes into account so it could choose a conflicting name.
To fix, add a field to IndexStmt that allows it to carry a comment to be
assigned to the new index. (This isn't a user-exposed feature of CREATE
INDEX, only an internal option.) Now we don't need preassignment of index
names in any situation.
I also took the opportunity to refactor DefineIndex to accept the IndexStmt
as such, rather than passing all its fields individually in a mile-long
parameter list.
Back-patch to 9.2, but no further, because it seems too dangerous to change
IndexStmt or DefineIndex's API in released branches. The bug exists back
to 9.0 where CREATE TABLE LIKE grew the ability to copy comments, but given
the lack of prior complaints we'll just let it go unfixed before 9.2.
Diffstat (limited to 'src/include/commands/defrem.h')
-rw-r--r-- | src/include/commands/defrem.h | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index 8f3d2c358dc..9b6d57a21e2 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -20,26 +20,12 @@ extern void RemoveObjects(DropStmt *stmt); /* commands/indexcmds.c */ -extern Oid DefineIndex(RangeVar *heapRelation, - char *indexRelationName, +extern Oid DefineIndex(IndexStmt *stmt, Oid indexRelationId, - Oid relFileNode, - char *accessMethodName, - char *tableSpaceName, - List *attributeList, - Expr *predicate, - List *options, - List *exclusionOpNames, - bool unique, - bool primary, - bool isconstraint, - bool deferrable, - bool initdeferred, bool is_alter_table, bool check_rights, bool skip_build, - bool quiet, - bool concurrent); + bool quiet); extern void ReindexIndex(RangeVar *indexRelation); extern void ReindexTable(RangeVar *relation); extern void ReindexDatabase(const char *databaseName, @@ -48,10 +34,6 @@ extern char *makeObjectName(const char *name1, const char *name2, const char *label); extern char *ChooseRelationName(const char *name1, const char *name2, const char *label, Oid namespaceid); -extern char *ChooseIndexName(const char *tabname, Oid namespaceId, - List *colnames, List *exclusionOpNames, - bool primary, bool isconstraint); -extern List *ChooseIndexColumnNames(List *indexElems); extern bool CheckIndexCompatible(Oid oldId, RangeVar *heapRelation, char *accessMethodName, |