This patch has a fix for a 'thought-o' in the docs.

Gavin
Index: doc/src/sgml/ref/alter_index.sgml
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/doc/src/sgml/ref/alter_index.sgml,v
retrieving revision 1.1
diff -2 -c -r1.1 alter_index.sgml
*** doc/src/sgml/ref/alter_index.sgml   13 Aug 2004 04:32:27 -0000      1.1
--- doc/src/sgml/ref/alter_index.sgml   13 Aug 2004 06:35:17 -0000
***************
*** 0 ****
--- 1,188 ----
+ <!--
+ $PostgreSQL$
+ PostgreSQL documentation
+ -->
+ 
+ <refentry id="SQL-ALTERINDEX">
+  <refmeta>
+   <refentrytitle id="sql-alterindex-title">ALTER INDEX</refentrytitle>
+   <refmiscinfo>SQL - Language Statements</refmiscinfo>
+  </refmeta>
+ 
+  <refnamediv>
+   <refname>ALTER INDEX</refname>
+   <refpurpose>change the definition of an index</refpurpose>
+  </refnamediv>
+ 
+  <indexterm zone="sql-alterindex">
+   <primary>ALTER INDEX</primary>
+  </indexterm>
+ 
+  <refsynopsisdiv>
+ <synopsis>
+ ALTER INDEX <replaceable class="PARAMETER">name</replaceable> 
+     <replaceable class="PARAMETER">action</replaceable> [, ... ]
+ ALTER INDEX <replaceable class="PARAMETER">name</replaceable>
+     RENAME TO <replaceable class="PARAMETER">new_name</replaceable>
+ 
+ where <replaceable class="PARAMETER">action</replaceable> is one of:
+ 
+     OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
+     SET INDEXSPACE <replaceable class="PARAMETER">indexspace_name</replaceable>
+ </synopsis>
+  </refsynopsisdiv>
+ 
+  <refsect1>
+   <title>Description</title>
+ 
+   <para>
+    <command>ALTER INDEX</command> changes the definition of an existing index.
+    There are several subforms:
+ 
+   <variablelist>
+ 
+    <varlistentry>
+     <term><literal>OWNER</literal></term>
+     <listitem>
+      <para>
+       This form changes the owner of the index to the
+       specified user.
+      </para>
+     </listitem>
+    </varlistentry>
+ 
+    <varlistentry>
+     <term><literal>SET TABLESPACE</literal></term>
+     <listitem>
+      <para>
+       This form changes the index's tablespace to the specified tablespace and
+       moves the data file(s) associated with the index to the new tablespace.
+       See also 
+       <xref linkend="SQL-CREATETABLESPACE" endterm="sql-createtablespace-title">.
+      </para>
+     </listitem>
+    </varlistentry>
+ 
+    <varlistentry>
+     <term><literal>RENAME</literal></term>
+     <listitem>
+      <para>
+       The <literal>RENAME</literal> forms change the name of the index. 
+         There is no effect on the stored data.
+      </para>
+     </listitem>
+    </varlistentry>
+ 
+   </variablelist>
+   </para>
+ 
+   <para>
+    All the actions except <literal>RENAME</literal> can be combined into
+    a list of multiple alterations to apply in parallel.
+   </para>
+ 
+  </refsect1>
+ 
+  <refsect1>
+   <title>Parameters</title>
+ 
+     <variablelist>
+ 
+      <varlistentry>
+       <term><replaceable class="PARAMETER">name</replaceable></term>
+       <listitem>
+        <para>
+       The name (possibly schema-qualified) of an existing index to
+       alter.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+ 
+      <varlistentry>
+       <term><replaceable class="PARAMETER">new_name</replaceable></term>
+       <listitem>
+        <para>
+       New name for the index.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+ 
+      <varlistentry>
+       <term><replaceable class="PARAMETER">new_owner</replaceable></term>
+       <listitem>
+        <para>
+       The user name of the new owner of the index.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><replaceable class="PARAMETER">tablespace_name</replaceable></term>
+       <listitem>
+        <para>
+       The tablespace name to which the index will be moved.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+     </variablelist>
+  </refsect1>
+ 
+  <refsect1>
+   <title>Notes</title>
+ 
+    <para>
+       This same operations are supported by <literal>ALTER TABLE</>. See also
+       <xref linkend="SQL-ALTERTABLE" endterm="SQL-ALTERTABLE-TITLE">.
+    </para>
+ 
+    <para>
+     Changing any part of a system catalog index is not permitted.
+    </para>
+  </refsect1>
+ 
+  <refsect1>
+   <title>Examples</title>
+   <para>
+    To rename an existing index:
+ <programlisting>
+ ALTER INDEX distributors RENAME TO suppliers;
+ </programlisting>
+   </para>
+ 
+   <para> 
+       To move a index to a different tablespace:
+ <programlisting>
+ ALTER INDEX distributors SET TABLESPACE fasttablespace;
+ </programlisting>
+   </para>
+ 
+  </refsect1>
+ 
+  <refsect1>
+   <title>Compatibility</title>
+ 
+   <para>
+       <literal>ALTER INDEX</> is a PostgreSQL extension.
+   </para>
+  </refsect1>
+ </refentry>
+ 
+ <!-- Keep this comment at the end of the file
+ Local variables:
+ mode: sgml
+ sgml-omittag:nil
+ sgml-shorttag:t
+ sgml-minimize-attributes:nil
+ sgml-always-quote-attributes:t
+ sgml-indent-step:1
+ sgml-indent-data:t
+ sgml-parent-document:nil
+ sgml-default-dtd-file:"../reference.ced"
+ sgml-exposed-tags:nil
+ sgml-local-catalogs:"/usr/lib/sgml/catalog"
+ sgml-local-ecat-files:nil
+ End:
+ -->
Index: src/backend/parser/gram.y
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/src/backend/parser/gram.y,v
retrieving revision 2.469
diff -2 -c -r2.469 gram.y
*** src/backend/parser/gram.y   2 Aug 2004 04:26:35 -0000       2.469
--- src/backend/parser/gram.y   13 Aug 2004 03:50:25 -0000
***************
*** 157,162 ****
  %type <ival>  add_drop
  
! %type <node>  alter_table_cmd
! %type <list>  alter_table_cmds
  
  %type <dbehavior>     opt_drop_behavior
--- 157,162 ----
  %type <ival>  add_drop
  
! %type <node>  alter_table_cmd alter_rel_cmd
! %type <list>  alter_table_cmds alter_rel_cmds
  
  %type <dbehavior>     opt_drop_behavior
***************
*** 1139,1143 ****
  /*****************************************************************************
   *
!  *    ALTER TABLE variations
   *
   *****************************************************************************/
--- 1139,1143 ----
  /*****************************************************************************
   *
!  *    ALTER [ TABLE | INDEX ] variations
   *
   *****************************************************************************/
***************
*** 1149,1152 ****
--- 1149,1161 ----
                                        n->relation = $3;
                                        n->cmds = $4;
+                                       n->relkind = OBJECT_TABLE; 
+                                       $$ = (Node *)n;
+                               }
+               |       ALTER INDEX relation_expr alter_rel_cmds
+                               {
+                                       AlterTableStmt *n = makeNode(AlterTableStmt);
+                                       n->relation = $3;
+                                       n->cmds = $4;
+                                       n->relkind = OBJECT_INDEX;
                                        $$ = (Node *)n;
                                }
***************
*** 1263,1274 ****
                                        $$ = (Node *)n;
                                }
-                       /* ALTER TABLE <name> OWNER TO UserId */
-                       |  OWNER TO UserId
-                               {
-                                       AlterTableCmd *n = makeNode(AlterTableCmd);
-                                       n->subtype = AT_ChangeOwner;
-                                       n->name = $3;
-                                       $$ = (Node *)n;
-                               }
                        /* ALTER TABLE <name> CLUSTER ON <indexname> */
                        | CLUSTER ON name
--- 1272,1275 ----
***************
*** 1287,1291 ****
                                        $$ = (Node *)n;
                                }
!                       /* ALTER TABLE <name> SET TABLESPACE <tablespacename> */
                        | SET TABLESPACE name
                                {
--- 1288,1312 ----
                                        $$ = (Node *)n;
                                }
!                       | alter_rel_cmd
!                               {
!                                       $$ = $1;
!                               }
!               ;
! 
! alter_rel_cmds: alter_rel_cmd                         { $$ = list_make1($1); }
!             | alter_rel_cmds ',' alter_rel_cmd  { $$ = lappend($1, $3); }
!         ;
! 
! 
! alter_rel_cmd:
!                       /* ALTER [ TABLE | INDEX ] <name> OWNER TO UserId */
!                       OWNER TO UserId
!                               {
!                                       AlterTableCmd *n = makeNode(AlterTableCmd);
!                                       n->subtype = AT_ChangeOwner;
!                                       n->name = $3;
!                                       $$ = (Node *)n;
!                               }
!                       /* ALTER [ TABLE | INDEX ] <name> SET TABLESPACE 
<tablespacename> */
                        | SET TABLESPACE name
                                {
***************
*** 1320,1323 ****
--- 1341,1346 ----
                ;
  
+ 
+ 
  /*****************************************************************************
   *
***************
*** 3656,3659 ****
--- 3679,3691 ----
                                        RenameStmt *n = makeNode(RenameStmt);
                                        n->renameType = OBJECT_TABLE;
+                                       n->relation = $3;
+                                       n->subname = NULL;
+                                       n->newname = $6;
+                                       $$ = (Node *)n;
+                               }
+                       | ALTER INDEX relation_expr RENAME TO name
+                               {
+                                       RenameStmt *n = makeNode(RenameStmt);
+                                       n->renameType = OBJECT_INDEX;
                                        n->relation = $3;
                                        n->subname = NULL;
Index: src/backend/tcop/utility.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/src/backend/tcop/utility.c,v
retrieving revision 1.223
diff -2 -c -r1.223 utility.c
*** src/backend/tcop/utility.c  2 Aug 2004 01:30:45 -0000       1.223
--- src/backend/tcop/utility.c  13 Aug 2004 03:52:06 -0000
***************
*** 1272,1275 ****
--- 1272,1278 ----
                                        tag = "ALTER GROUP";
                                        break;
+                               case OBJECT_INDEX:
+                                       tag = "ALTER INDEX";
+                                       break;
                                case OBJECT_LANGUAGE:
                                        tag = "ALTER LANGUAGE";
***************
*** 1334,1340 ****
  
                case T_AlterTableStmt:
!                       tag = "ALTER TABLE";
!                       break;
  
                case T_AlterDomainStmt:
                        tag = "ALTER DOMAIN";
--- 1337,1355 ----
  
                case T_AlterTableStmt:
!                       {
!                               AlterTableStmt *stmt = (AlterTableStmt *) parsetree;
! 
!                               /* 
!                                * We might be supporting ALTER INDEX here, so
!                                * set the completion table appropriately.
!                                * Catch all other possibilities with ALTER TABLE
!                                */
  
+                               if(stmt->relkind == OBJECT_INDEX) 
+                                       tag = "ALTER INDEX";
+                               else
+                                       tag = "ALTER TABLE";
+                       }
+                       break;
                case T_AlterDomainStmt:
                        tag = "ALTER DOMAIN";
Index: src/bin/psql/tab-complete.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/src/bin/psql/tab-complete.c,v
retrieving revision 1.109
diff -2 -c -r1.109 tab-complete.c
*** src/bin/psql/tab-complete.c 28 Jul 2004 14:23:30 -0000      1.109
--- src/bin/psql/tab-complete.c 13 Aug 2004 06:34:55 -0000
***************
*** 633,637 ****
        {
                static const char *const list_ALTER[] =
!               {"DATABASE", "GROUP", "SCHEMA", "TABLE", "TRIGGER", "USER", NULL};
  
                COMPLETE_WITH_LIST(list_ALTER);
--- 633,638 ----
        {
                static const char *const list_ALTER[] =
!               {"DATABASE", "GROUP", "SCHEMA", "TABLE", "TRIGGER", "USER", "INDEX",
!                        NULL};
  
                COMPLETE_WITH_LIST(list_ALTER);
***************
*** 647,650 ****
--- 648,661 ----
                COMPLETE_WITH_LIST(list_ALTERDATABASE);
        }
+       /* ALTER INDEX <name> */
+       else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
+              pg_strcasecmp(prev2_wd, "INDEX") == 0)
+     {
+         static const char *const list_ALTERDATABASE[] =
+         {"SET TABLESPACE", "OWNER TO", "RENAME TO", NULL};
+                                                                                 
+         COMPLETE_WITH_LIST(list_ALTERDATABASE);
+     }
+ 
        /* ALTER TRIGGER <name>, add ON */
        else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
Index: src/include/nodes/parsenodes.h
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/src/include/nodes/parsenodes.h,v
retrieving revision 1.265
diff -2 -c -r1.265 parsenodes.h
*** src/include/nodes/parsenodes.h      4 Aug 2004 21:34:24 -0000       1.265
--- src/include/nodes/parsenodes.h      13 Aug 2004 03:50:47 -0000
***************
*** 782,785 ****
--- 782,786 ----
        RangeVar   *relation;           /* table to work on */
        List       *cmds;                       /* list of subcommands */
+       ObjectType      relkind;                /* type of object */
  } AlterTableStmt;
  
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to