OSDN Git Service

Code review for ALTER INDEX patch.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 22 Aug 2004 00:08:28 +0000 (00:08 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 22 Aug 2004 00:08:28 +0000 (00:08 +0000)
src/backend/commands/alter.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/analyze.c
src/backend/parser/gram.y

index 50516e1..7aa3e91 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.8 2004/06/25 21:55:53 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.9 2004/08/22 00:08:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -89,6 +89,7 @@ ExecRenameStmt(RenameStmt *stmt)
                        break;
 
                case OBJECT_TABLE:
+               case OBJECT_INDEX:
                case OBJECT_COLUMN:
                case OBJECT_TRIGGER:
                        {
@@ -101,6 +102,7 @@ ExecRenameStmt(RenameStmt *stmt)
                                switch (stmt->renameType)
                                {
                                        case OBJECT_TABLE:
+                                       case OBJECT_INDEX:
                                                {
                                                        /*
                                                         * RENAME TABLE requires that we (still) hold
index 3d953de..2427877 100644 (file)
@@ -15,7 +15,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.289 2004/08/02 04:26:05 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.290 2004/08/22 00:08:28 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1626,6 +1626,7 @@ _copyAlterTableStmt(AlterTableStmt *from)
 
        COPY_NODE_FIELD(relation);
        COPY_NODE_FIELD(cmds);
+       COPY_SCALAR_FIELD(relkind);
 
        return newnode;
 }
index 436b583..9a78738 100644 (file)
@@ -18,7 +18,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.228 2004/08/02 04:26:05 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.229 2004/08/22 00:08:28 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -727,6 +727,7 @@ _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
 {
        COMPARE_NODE_FIELD(relation);
        COMPARE_NODE_FIELD(cmds);
+       COMPARE_SCALAR_FIELD(relkind);
 
        return true;
 }
index 746975f..28267fc 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *     $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.308 2004/08/02 04:26:29 tgl Exp $
+ *     $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.309 2004/08/22 00:08:28 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1421,6 +1421,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt,
 
                alterstmt->relation = cxt->relation;
                alterstmt->cmds = NIL;
+               alterstmt->relkind = OBJECT_TABLE;
 
                foreach(fkclist, cxt->fkconstraints)
                {
index 5240a69..f16d326 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.472 2004/08/20 04:29:32 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.473 2004/08/22 00:08:28 tgl Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -1166,6 +1166,7 @@ alter_table_cmds:
                        | alter_table_cmds ',' alter_table_cmd  { $$ = lappend($1, $3); }
                ;
 
+/* Subcommands that are for ALTER TABLE only */
 alter_table_cmd:
                        /* ALTER TABLE <relation> ADD [COLUMN] <coldef> */
                        ADD opt_column columnDef
@@ -1293,13 +1294,14 @@ alter_table_cmd:
                                }
                ;
 
-alter_rel_cmds: alter_rel_cmd                         { $$ = list_make1($1); }
-            | alter_rel_cmds ',' alter_rel_cmd  { $$ = lappend($1, $3); }
-        ;
-
+alter_rel_cmds:
+                       alter_rel_cmd                                                   { $$ = list_make1($1); }
+                       | alter_rel_cmds ',' alter_rel_cmd              { $$ = lappend($1, $3); }
+               ;
 
+/* Subcommands that are for ALTER TABLE or ALTER INDEX */
 alter_rel_cmd:
-                       /* ALTER [ TABLE | INDEX ] <name> OWNER TO UserId */
+                       /* ALTER [TABLE|INDEX] <name> OWNER TO UserId */
                        OWNER TO UserId
                                {
                                        AlterTableCmd *n = makeNode(AlterTableCmd);
@@ -1307,7 +1309,7 @@ alter_rel_cmd:
                                        n->name = $3;
                                        $$ = (Node *)n;
                                }
-                       /* ALTER [ TABLE | INDEX ] <name> SET TABLESPACE <tablespacename> */
+                       /* ALTER [TABLE|INDEX] <name> SET TABLESPACE <tablespacename> */
                        | SET TABLESPACE name
                                {
                                        AlterTableCmd *n = makeNode(AlterTableCmd);