mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user