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 50516e1f0465d877254634c6c04eea3c26497b75..7aa3e91729c6253963ff6df1605893662c326abc 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 3d953dec18c3716a7bad7df90e111138f2a71355..24278773847824a0797a2e9267112e9bf3b491f6 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 436b5832815300401efe91591c54c581d8774fa7..9a787381cc8a53936027cc4e95d59f94e0a1d12f 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 746975f90b4377c196f1b81f9fec268e1473ab1c..28267fc866d623e913a3a77a1872c4ae8979dcf3 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 5240a69dd23385a5959b72c159c54663795146ea..f16d326842db6fd3d29201e26a27f17ece747e83 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);