aboutsummaryrefslogtreecommitdiff
path: root/src/include/nodes/parsenodes.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-07-16 13:25:18 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-07-16 13:25:18 -0400
commitc92be3c0595d504a1516e7e158d085150ff1c4dc (patch)
tree028234f315cc68ee4369e93a4bead271292f9095 /src/include/nodes/parsenodes.h
parent54fd196ffc6432b62fe075e564f457db64fb288c (diff)
downloadpostgresql-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/nodes/parsenodes.h')
-rw-r--r--src/include/nodes/parsenodes.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 50111cba3c0..a4591cc9aa4 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2018,10 +2018,11 @@ typedef struct FetchStmt
* Create Index Statement
*
* This represents creation of an index and/or an associated constraint.
- * If indexOid isn't InvalidOid, we are not creating an index, just a
- * UNIQUE/PKEY constraint using an existing index. isconstraint must always
- * be true in this case, and the fields describing the index properties are
- * empty.
+ * If isconstraint is true, we should create a pg_constraint entry along
+ * with the index. But if indexOid isn't InvalidOid, we are not creating an
+ * index, just a UNIQUE/PKEY constraint using an existing index. isconstraint
+ * must always be true in this case, and the fields describing the index
+ * properties are empty.
* ----------------------
*/
typedef struct IndexStmt
@@ -2031,15 +2032,16 @@ typedef struct IndexStmt
RangeVar *relation; /* relation to build index on */
char *accessMethod; /* name of access method (eg. btree) */
char *tableSpace; /* tablespace, or NULL for default */
- List *indexParams; /* a list of IndexElem */
- List *options; /* options from WITH clause */
+ List *indexParams; /* columns to index: a list of IndexElem */
+ List *options; /* WITH clause options: a list of DefElem */
Node *whereClause; /* qualification (partial-index predicate) */
List *excludeOpNames; /* exclusion operator names, or NIL if none */
+ char *idxcomment; /* comment to apply to index, or NULL */
Oid indexOid; /* OID of an existing index, if any */
- Oid oldNode; /* relfilenode of my former self */
+ Oid oldNode; /* relfilenode of existing storage, if any */
bool unique; /* is index unique? */
- bool primary; /* is index on primary key? */
- bool isconstraint; /* is it from a CONSTRAINT clause? */
+ bool primary; /* is index a primary key? */
+ bool isconstraint; /* is it for a pkey/unique constraint? */
bool deferrable; /* is the constraint DEFERRABLE? */
bool initdeferred; /* is the constraint INITIALLY DEFERRED? */
bool concurrent; /* should this be a concurrent index build? */