<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.53 2003/03/20 07:02:07 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.54 2003/06/27 14:45:25 petere Exp $
PostgreSQL documentation
Complete list of usable sgml source files in this directory.
-->
-<!-- these will go into the "operators" reference chapter -->
-<!entity all system "all.sgml">
-<!entity any system "any.sgml">
-<!entity between system "between.sgml">
-<!entity in system "in.sgml">
-<!entity like system "like.sgml">
-
-<!-- these will go into the "functions" reference chapter -->
-<!entity avg system "avg.sgml">
-<!entity cast system "cast.sgml">
-<!entity charLength system "char_length.sgml">
-<!entity count system "count.sgml">
-<!entity currentDate system "current_date.sgml">
-<!entity currentTime system "current_time.sgml">
-<!entity currentTimestamp system "current_timestamp.sgml">
-<!entity currentUser system "current_user.sgml">
-<!entity exists system "exists.sgml">
-<!entity extract system "extract.sgml">
-<!entity initcap system "initcap.sgml">
-<!entity lower system "lower.sgml">
-<!entity lpad system "lpad.sgml">
-<!entity max system "max.sgml">
-<!entity min system "min.sgml">
-<!entity position system "position.sgml">
-<!entity rpad system "rpad.sgml">
-<!entity substring system "substring.sgml">
-<!entity sum system "sum.sgml">
-<!entity translate system "translate.sgml">
-<!entity trim system "trim.sgml">
-<!entity upper system "upper.sgml">
-
<!-- SQL commands -->
<!entity abort system "abort.sgml">
+<!entity alterAggregate system "alter_aggregate.sgml">
+<!entity alterConversion system "alter_conversion.sgml">
<!entity alterDatabase system "alter_database.sgml">
<!entity alterDomain system "alter_domain.sgml">
+<!entity alterFunction system "alter_function.sgml">
<!entity alterGroup system "alter_group.sgml">
+<!entity alterLanguage system "alter_language.sgml">
+<!entity alterOperatorClass system "alter_opclass.sgml">
+<!entity alterSchema system "alter_schema.sgml">
<!entity alterSequence system "alter_sequence.sgml">
<!entity alterTable system "alter_table.sgml">
<!entity alterTrigger system "alter_trigger.sgml">
--- /dev/null
+<!--
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_aggregate.sgml,v 1.1 2003/06/27 14:45:25 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-ALTERAGGREGATE">
+ <refmeta>
+ <refentrytitle id="SQL-ALTERAGGREGATE-TITLE">ALTER AGGREGATE</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>ALTER AGGREGATE</refname>
+ <refpurpose>change the definition of an aggregate function</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+<synopsis>
+ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable> ) RENAME TO <replaceable>newname</replaceable>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>ALTER AGGREGATE</command> changes the definition of an
+ aggregate function. The only functionality is to rename the
+ aggregate function.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name (optionally schema-qualified) of an existing aggregate function.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">type</replaceable></term>
+ <listitem>
+ <para>
+ The argument data type of the aggregate function, or
+ <literal>*</literal> if the function accepts any data type.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">newname</replaceable></term>
+ <listitem>
+ <para>
+ The new name of the aggregate function.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Diagnostics</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>ALTER AGGREGATE</computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the command was successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ To rename the aggregate function <literal>myavg</literal> for type
+ <type>integer</type> to <literal>my_average</literal>:
+<programlisting>
+ALTER AGGREGATE myavg(integer) RENAME TO my_average;
+</programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ There is no <command>ALTER AGGREGATE</command> statement in the SQL
+ standard.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createaggregate" endterm="sql-createaggregate-title"></member>
+ <member><xref linkend="sql-dropaggregate" endterm="sql-dropaggregate-title"></member>
+ </simplelist>
+ </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:
+-->
--- /dev/null
+<!--
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_conversion.sgml,v 1.1 2003/06/27 14:45:25 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-ALTERCONVERSION">
+ <refmeta>
+ <refentrytitle id="SQL-ALTERCONVERSION-TITLE">ALTER CONVERSION</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>ALTER CONVERSION</refname>
+ <refpurpose>change the definition of a conversion</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+<synopsis>
+ALTER CONVERSION <replaceable>name</replaceable> RENAME TO <replaceable>newname</replaceable>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>ALTER CONVERSION</command> changes the definition of a
+ conversion. The only functionality is to rename the conversion.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name (optionally schema-qualified) of an existing conversion.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">newname</replaceable></term>
+ <listitem>
+ <para>
+ The new name of the conversion.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Diagnostics</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>ALTER CONVERSION</computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the command was successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ To rename the conversion <literal>iso_8859_1_to_utf_8</literal> to
+ <literal>latin1_to_unicode</literal>:
+<programlisting>
+ALTER CONVERSION iso_8859_1_to_utf_8 RENAME TO latin1_to_unicode;
+</programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ There is no <command>ALTER CONVERSION</command> statement in the SQL
+ standard.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createconversion" endterm="sql-createconversion-title"></member>
+ <member><xref linkend="sql-dropconversion" endterm="sql-dropconversion-title"></member>
+ </simplelist>
+ </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:
+-->
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_database.sgml,v 1.6 2003/04/15 13:25:08 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_database.sgml,v 1.7 2003/06/27 14:45:25 petere Exp $
PostgreSQL documentation
-->
<synopsis>
ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> SET <replaceable>variable</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> RESET <replaceable>variable</replaceable>
+
+ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable>newname</replaceable>
</synopsis>
</refsynopsisdiv>
<title>Description</title>
<para>
- <command>ALTER DATABASE</command> is used to change the session
- default of a run-time configuration variable for a
- <productname>PostgreSQL</productname> database. Whenever a new
- session is subsequently started in that database, the specified
- value becomes the session default value.
- The database-specific default
- overrides whatever setting is present in <filename>postgresql.conf</>
- or has been received from the <command>postmaster</command> command line.
+ <command>ALTER DATABASE</command> is used to change the attributes
+ of a database.
</para>
<para>
- Only the database owner or a superuser can change the session defaults for a
+ The first two forms change the session default of a run-time
+ configuration variable for a <productname>PostgreSQL</productname>
+ database. Whenever a new session is subsequently started in that
+ database, the specified value becomes the session default value.
+ The database-specific default overrides whatever setting is present
+ in <filename>postgresql.conf</> or has been received from the
+ <command>postmaster</command> command line. Only the database
+ owner or a superuser can change the session defaults for a
database.
</para>
+
+ <para>
+ The third form changes the name of the database. Only the database
+ owner can rename a database, and only if he has the
+ <literal>CREATEDB</literal> privilege. The current database cannot
+ be renamed. (Connect to a different database if you need to do
+ that.)
+ </para>
</refsect1>
<refsect1>
</para>
</listitem>
</varlistentry>
- </variablelist>
+
+ <varlistentry>
+ <term><replaceable>newname</replaceable></term>
+ <listitem>
+ <para>
+ The new name of the database.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</refsect1>
<refsect1>
--- /dev/null
+<!--
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_function.sgml,v 1.1 2003/06/27 14:45:25 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-ALTERFUNCTION">
+ <refmeta>
+ <refentrytitle id="SQL-ALTERFUNCTION-TITLE">ALTER FUNCTION</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>ALTER FUNCTION</refname>
+ <refpurpose>change the definition of a function</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+<synopsis>
+ALTER FUNCTION <replaceable>name</replaceable> ( [ <replaceable class="parameter">type</replaceable> [, ...] ] ) RENAME TO <replaceable>newname</replaceable>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>ALTER FUNCTION</command> changes the definition of a
+ function. The only functionality is to rename the function.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name (optionally schema-qualified) of an existing function.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">type</replaceable></term>
+ <listitem>
+ <para>
+ The data type of an argument of the function.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">newname</replaceable></term>
+ <listitem>
+ <para>
+ The new name of the function.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Diagnostics</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>ALTER FUNCTION</computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the command was successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ To rename the function <literal>sqrt</literal> for type
+ <type>integer</type> to <literal>square_root</literal>:
+<programlisting>
+ALTER FUNCTION sqrt(integer) RENAME TO square_root;
+</programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ There is an <command>ALTER FUNCTION</command> statement in the SQL
+ standard, but it does not provide the option to rename the
+ function.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createfunction" endterm="sql-createfunction-title"></member>
+ <member><xref linkend="sql-dropfunction" endterm="sql-dropfunction-title"></member>
+ </simplelist>
+ </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:
+-->
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_group.sgml,v 1.9 2003/04/15 13:25:08 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_group.sgml,v 1.10 2003/06/27 14:45:25 petere Exp $
PostgreSQL documentation
-->
<refnamediv>
<refname>ALTER GROUP</refname>
- <refpurpose>add users to a group or remove users from a group</refpurpose>
+ <refpurpose>change a user group</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
ALTER GROUP <replaceable class="PARAMETER">groupname</replaceable> ADD USER <replaceable class="PARAMETER">username</replaceable> [, ... ]
ALTER GROUP <replaceable class="PARAMETER">groupname</replaceable> DROP USER <replaceable class="PARAMETER">username</replaceable> [, ... ]
+
+ALTER GROUP <replaceable class="PARAMETER">groupname</replaceable> RENAME TO <replaceable>newname</replaceable>
</synopsis>
</refsynopsisdiv>
<title>Description</title>
<para>
- <command>ALTER GROUP</command> is used to add or remove users from a
- group. Only database superusers can use this command.
- Adding a user to a group does not create the user. Similarly, removing
- a user from a group does not drop the user itself.
+ <command>ALTER GROUP</command> is used to change a user group. The
+ first two variants add or remove users from a group. Only database
+ superusers can use this command. Adding a user to a group does not
+ create the user. Similarly, removing a user from a group does not
+ drop the user itself.
</para>
<para>
- Use <xref linkend="SQL-CREATEGROUP" endterm="SQL-CREATEGROUP-title">
- to create a new group and <xref linkend="SQL-DROPGROUP"
- endterm="SQL-DROPGROUP-title"> to remove a group.
+ The third variant changes the name of the group. Only a database
+ superuser can rename groups.
</para>
</refsect1>
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><replaceable>newname</replaceable></term>
+ <listitem>
+ <para>
+ The new name of the group.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
standard. The concept of roles is similar.
</para>
</refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-creategroup" endterm="sql-creategroup-title"></member>
+ <member><xref linkend="sql-dropgroup" endterm="sql-dropgroup-title"></member>
+ </simplelist>
+ </refsect1>
+
</refentry>
<!-- Keep this comment at the end of the file
--- /dev/null
+<!--
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_language.sgml,v 1.1 2003/06/27 14:45:25 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-ALTERLANGUAGE">
+ <refmeta>
+ <refentrytitle id="SQL-ALTERLANGUAGE-title">ALTER LANGUAGE</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>ALTER LANGUAGE</refname>
+ <refpurpose>change the definition of a procedural language</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+<synopsis>
+ALTER LANGUAGE <replaceable>name</replaceable> RENAME TO <replaceable>newname</replaceable>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>ALTER LANGUAGE</command> changes the definition of a
+ language. The only functionality is to rename the language. Only
+ a superuser can rename languages.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameter</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable>name</replaceable></term>
+ <listitem>
+ <para>
+ Name of a language
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable>newname</replaceable></term>
+ <listitem>
+ <para>
+ The new name of the language
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Diagnostics</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>ALTER LANGUAGE</computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the alteration was successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ There is no <command>ALTER LANGUAGE</command> statement in the SQL
+ standard.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createlanguage" endterm="sql-createlanguage-title"></member>
+ <member><xref linkend="sql-droplanguage" endterm="sql-droplanguage-title"></member>
+ </simplelist>
+ </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:
+-->
--- /dev/null
+<!--
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_opclass.sgml,v 1.1 2003/06/27 14:45:26 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-ALTEROPCLASS">
+ <refmeta>
+ <refentrytitle id="SQL-ALTEROPCLASS-TITLE">ALTER OPERATOR CLASS</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>ALTER OPERATOR CLASS</refname>
+ <refpurpose>change the definition of an operator class</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+<synopsis>
+ALTER OPERATOR CLASS <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable> RENAME TO <replaceable>newname</replaceable>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>ALTER OPERATOR CLASS</command> changes the definition of
+ an operator class. The only functionality is to rename the
+ operator class.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name (optionally schema-qualified) of an existing operator
+ class.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">index_method</replaceable></term>
+ <listitem>
+ <para>
+ The name of the index method this operator class is for.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">newname</replaceable></term>
+ <listitem>
+ <para>
+ The new name of the operator class.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Diagnostics</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>ALTER OPERATOR CLASS</computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the command was successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ There is no <command>ALTER OPERATOR CLASS</command> statement in
+ the SQL standard.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createopclass" endterm="sql-createopclass-title"></member>
+ <member><xref linkend="sql-dropopclass" endterm="sql-dropopclass-title"></member>
+ </simplelist>
+ </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:
+-->
--- /dev/null
+<!--
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_schema.sgml,v 1.1 2003/06/27 14:45:26 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-ALTERSCHEMA">
+ <refmeta>
+ <refentrytitle id="SQL-ALTERSCHEMA-title">ALTER SCHEMA</refentrytitle>
+ <refmiscinfo>SQL - Schema Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>ALTER SCHEMA</refname>
+ <refpurpose>change the definition of a schema</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+<synopsis>
+ALTER SCHEMA <replaceable>name</replaceable> RENAME TO <replaceable>newname</replaceable>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>ALTER SCHEMA</command> changes the definition of a schema.
+ The only functionality is to rename the schema. To rename a schema
+ you must own the schema and have the privilege
+ <literal>CREATE</literal> for the database.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameter</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable>name</replaceable></term>
+ <listitem>
+ <para>
+ Name of a schema
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable>newname</replaceable></term>
+ <listitem>
+ <para>
+ The new name of the schema
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Diagnostics</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>ALTER SCHEMA</computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the alteration was successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ There is no <command>ALTER SCHEMA</command> statement in the SQL
+ standard.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createschema" endterm="sql-createschema-title"></member>
+ <member><xref linkend="sql-dropschema" endterm="sql-dropschema-title"></member>
+ </simplelist>
+ </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:
+-->
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_user.sgml,v 1.27 2003/04/15 13:25:08 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_user.sgml,v 1.28 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
| CREATEUSER | NOCREATEUSER
| VALID UNTIL '<replaceable class="PARAMETER">abstime</replaceable>'
+ALTER USER <replaceable class="PARAMETER">username</replaceable> RENAME TO <replaceable>newname</replaceable>
+
ALTER USER <replaceable class="PARAMETER">username</replaceable> SET <replaceable>variable</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
ALTER USER <replaceable class="PARAMETER">username</replaceable> RESET <replaceable>variable</replaceable>
</synopsis>
</para>
<para>
- The second and the third variant change a user's session default for
+ The second variant changes the name of the user. Only a database
+ superuser can rename user accounts. The session user cannot be
+ renamed. (Connect as a different user if you need to do that.)
+ </para>
+
+ <para>
+ The third and the fourth variant change a user's session default for
a specified configuration variable. Whenever the user subsequently
starts a new session, the specified value becomes the session default,
overriding whatever setting is present in <filename>postgresql.conf</>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><replaceable>newname</replaceable></term>
+ <listitem>
+ <para>
+ The new name of the user.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><replaceable>variable</replaceable></term>
<term><replaceable>value</replaceable></term>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_aggregate.sgml,v 1.25 2003/04/22 10:08:08 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_aggregate.sgml,v 1.26 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
</variablelist>
</refsect1>
- <refsect1>
- <title>Notes</title>
-
- <para>
- Use <command>DROP AGGREGATE</command> to drop aggregate functions.
- </para>
- </refsect1>
-
<refsect1>
<title>Examples</title>
standard does not provide for user-defined aggregate function.
</para>
</refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-alteraggregate" endterm="sql-alteraggregate-title"></member>
+ <member><xref linkend="sql-dropaggregate" endterm="sql-dropaggregate-title"></member>
+ </simplelist>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
-<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.9 2003/06/24 23:29:25 momjian Exp $ -->
+<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.10 2003/06/27 14:45:26 petere Exp $ -->
<refentry id="SQL-CREATECONVERSION">
<refmeta>
<refsect1 id="sql-createconversion-seealso">
<title>See Also</title>
- <para>
- <xref linkend="sql-createfunction" endterm="sql-createfunction-title">,
- <xref linkend="sql-dropconversion" endterm="sql-dropconversion-title">
- </para>
+ <simplelist type="inline">
+ <member><xref linkend="sql-alterconversion" endterm="sql-alterconversion-title"></member>
+ <member><xref linkend="sql-createfunction" endterm="sql-createfunction-title"></member>
+ <member><xref linkend="sql-dropconversion" endterm="sql-dropconversion-title"></member>
+ </simplelist>
</refsect1>
</refentry>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.47 2003/04/22 10:08:08 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.48 2003/06/27 14:45:26 petere Exp $
-->
<refentry id="SQL-CREATEFUNCTION">
<title>See Also</title>
<para>
+ <xref linkend="sql-alterfunction" endterm="sql-alterfunction-title">,
<xref linkend="sql-dropfunction" endterm="sql-dropfunction-title">,
<xref linkend="sql-grant" endterm="sql-grant-title">,
<xref linkend="sql-load" endterm="sql-load-title">,
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.32 2003/04/22 10:08:08 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.33 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
<refsect1>
<title>See Also</title>
- <para>
- <simplelist type="inline">
- <member><xref linkend="app-createlang"></member>
- <member><xref linkend="sql-createfunction" endterm="sql-createfunction-title"></member>
- <member><xref linkend="app-droplang"></member>
- <member><xref linkend="sql-droplanguage" endterm="sql-droplanguage-title"></member>
- <member><xref linkend="sql-grant" endterm="sql-grant-title"></member>
- <member><xref linkend="sql-revoke" endterm="sql-revoke-title"></member>
- </simplelist>
- </para>
+ <simplelist type="inline">
+ <member><xref linkend="sql-alterlanguage" endterm="sql-alterlanguage-title"></member>
+ <member><xref linkend="sql-createfunction" endterm="sql-createfunction-title"></member>
+ <member><xref linkend="sql-droplanguage" endterm="sql-droplanguage-title"></member>
+ <member><xref linkend="sql-grant" endterm="sql-grant-title"></member>
+ <member><xref linkend="sql-revoke" endterm="sql-revoke-title"></member>
+ <member><xref linkend="app-createlang"></member>
+ <member><xref linkend="app-droplang"></member>
+ </simplelist>
</refsect1>
</refentry>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_opclass.sgml,v 1.7 2003/04/22 10:08:08 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_opclass.sgml,v 1.8 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
</variablelist>
</refsect1>
- <refsect1>
- <title>Notes</title>
-
- <para>
- Refer to
- <xref linkend="sql-dropopclass" endterm="sql-dropopclass-title">
- to delete user-defined operator classes from a database.
- </para>
- </refsect1>
-
<refsect1>
<title>Examples</title>
standard.
</para>
</refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-alteropclass" endterm="sql-alteropclass-title"></member>
+ <member><xref linkend="sql-dropopclass" endterm="sql-dropopclass-title"></member>
+ </simplelist>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.5 2003/04/22 10:08:08 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.6 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
privilege for the current database. (Of course, superusers bypass
this check.)
</para>
-
- <para>
- Use <command>DROP SCHEMA</command> to remove a schema.
- </para>
</refsect1>
<refsect1>
<literal>CREATE</> privilege on his schema to someone else.
</para>
</refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-alterschema" endterm="sql-alterschema-title"></member>
+ <member><xref linkend="sql-dropschema" endterm="sql-dropschema-title"></member>
+ </simplelist>
+ </refsect1>
+
</refentry>
<!-- Keep this comment at the end of the file
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_aggregate.sgml,v 1.22 2003/05/04 02:23:16 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_aggregate.sgml,v 1.23 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
<title>See Also</title>
<simplelist type="inline">
+ <member><xref linkend="sql-alteraggregate" endterm="sql-alteraggregate-title"></member>
<member><xref linkend="sql-createaggregate" endterm="sql-createaggregate-title"></member>
</simplelist>
</refsect1>
-<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_conversion.sgml,v 1.4 2003/05/04 02:23:16 petere Exp $ -->
+<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_conversion.sgml,v 1.5 2003/06/27 14:45:26 petere Exp $ -->
<refentry id="SQL-DROPCONVERSION">
<refmeta>
<title>See Also</title>
<simplelist type="inline">
+ <member><xref linkend="sql-alterconversion" endterm="sql-alterconversion-title"></member>
<member><xref linkend="sql-createconversion" endterm="sql-createconversion-title"></member>
</simplelist>
</refsect1>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_function.sgml,v 1.24 2003/05/04 02:23:16 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_function.sgml,v 1.25 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
<simplelist type="inline">
<member><xref linkend="sql-createfunction" endterm="sql-createfunction-title"></member>
+ <member><xref linkend="sql-alterfunction" endterm="sql-alterfunction-title"></member>
</simplelist>
</refsect1>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_language.sgml,v 1.16 2003/05/04 02:23:16 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_language.sgml,v 1.17 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
<title>See Also</title>
<simplelist type="inline">
+ <member><xref linkend="sql-alterlanguage" endterm="sql-alterlanguage-title"></member>
<member><xref linkend="sql-createlanguage" endterm="sql-createlanguage-title"></member>
+ <member><xref linkend="app-droplang"></member>
</simplelist>
</refsect1>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_opclass.sgml,v 1.3 2003/05/04 02:23:16 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_opclass.sgml,v 1.4 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
<title>See Also</title>
<simplelist type="inline">
+ <member><xref linkend="sql-alteropclass" endterm="sql-alteropclass-title"></member>
<member><xref linkend="sql-createopclass" endterm="sql-createopclass-title"></member>
</simplelist>
</refsect1>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_schema.sgml,v 1.2 2003/05/04 02:23:16 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_schema.sgml,v 1.3 2003/06/27 14:45:26 petere Exp $
PostgreSQL documentation
-->
<title>See Also</title>
<simplelist type="inline">
+ <member><xref linkend="sql-alterschema" endterm="sql-alterschema-title"></member>
<member><xref linkend="sql-createschema" endterm="sql-createschema-title"></member>
</simplelist>
</refsect1>
<!-- reference.sgml
-$Header: /cvsroot/pgsql/doc/src/sgml/reference.sgml,v 1.44 2003/03/25 16:15:38 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/reference.sgml,v 1.45 2003/06/27 14:45:25 petere Exp $
PostgreSQL Reference Manual
-->
</partintro>
&abort;
+ &alterAggregate;
+ &alterConversion;
&alterDatabase;
&alterDomain;
+ &alterFunction;
&alterGroup;
+ &alterLanguage;
+ &alterOperatorClass;
+ &alterSchema;
&alterSequence;
&alterTable;
&alterTrigger;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.81 2003/05/27 17:49:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.82 2003/06/27 14:45:26 petere Exp $
*
* NOTES
* See acl.h.
return userid == owner_id;
}
+
+
+/*
+ * Ownership check for database (specified as OID)
+ */
+bool
+pg_database_ownercheck(Oid db_oid, AclId userid)
+{
+ Relation pg_database;
+ ScanKeyData entry[1];
+ HeapScanDesc scan;
+ HeapTuple dbtuple;
+ int32 dba;
+
+ /* Superusers bypass all permission checking. */
+ if (superuser_arg(userid))
+ return true;
+
+ /* There's no syscache for pg_database, so must look the hard way */
+ pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
+ ScanKeyEntryInitialize(&entry[0], 0x0,
+ ObjectIdAttributeNumber, F_OIDEQ,
+ ObjectIdGetDatum(db_oid));
+ scan = heap_beginscan(pg_database, SnapshotNow, 1, entry);
+
+ dbtuple = heap_getnext(scan, ForwardScanDirection);
+
+ if (!HeapTupleIsValid(dbtuple))
+ elog(ERROR, "database %u does not exist", db_oid);
+
+ dba = ((Form_pg_database) GETSTRUCT(dbtuple))->datdba;
+
+ heap_endscan(scan);
+ heap_close(pg_database, AccessShareLock);
+
+ return userid == dba;
+}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.51 2003/05/14 03:26:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.52 2003/06/27 14:45:27 petere Exp $
*
*-------------------------------------------------------------------------
*/
*/
if (relation->catalogname)
{
- if (strcmp(relation->catalogname, DatabaseName) != 0)
+ if (strcmp(relation->catalogname, get_database_name(MyDatabaseId)) != 0)
elog(ERROR, "Cross-database references are not implemented");
}
*/
if (newRelation->catalogname)
{
- if (strcmp(newRelation->catalogname, DatabaseName) != 0)
+ if (strcmp(newRelation->catalogname, get_database_name(MyDatabaseId)) != 0)
elog(ERROR, "Cross-database references are not implemented");
}
/*
* We check the catalog name and then ignore it.
*/
- if (strcmp(catalogname, DatabaseName) != 0)
+ if (strcmp(catalogname, get_database_name(MyDatabaseId)) != 0)
elog(ERROR, "Cross-database references are not implemented");
break;
default:
if (pg_database_aclcheck(MyDatabaseId, GetSessionUserId(),
ACL_CREATE_TEMP) != ACLCHECK_OK)
elog(ERROR, "%s: not authorized to create temp tables",
- DatabaseName);
+ get_database_name(MyDatabaseId));
snprintf(namespaceName, sizeof(namespaceName), "pg_temp_%d", MyBackendId);
# Makefile for backend/commands
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.31 2002/08/27 04:55:07 tgl Exp $
+# $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.32 2003/06/27 14:45:27 petere Exp $
#
#-------------------------------------------------------------------------
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
-OBJS = aggregatecmds.o analyze.o async.o cluster.o comment.o \
+OBJS = aggregatecmds.o alter.o analyze.o async.o cluster.o comment.o \
conversioncmds.o copy.o \
dbcommands.o define.o explain.o functioncmds.o \
indexcmds.o lockcmds.o operatorcmds.o opclasscmds.o \
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.7 2003/06/25 21:30:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.8 2003/06/27 14:45:27 petere Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
#include "access/heapam.h"
#include "catalog/catname.h"
#include "catalog/dependency.h"
+#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_proc.h"
performDeletion(&object, stmt->behavior);
}
+
+
+void
+RenameAggregate(List *name, TypeName *basetype, const char *newname)
+{
+ Oid basetypeOid;
+ Oid procOid;
+ Oid namespaceOid;
+ Oid oid_array[FUNC_MAX_ARGS];
+ HeapTuple tup;
+ Relation rel;
+ AclResult aclresult;
+
+ /*
+ * if a basetype is passed in, then attempt to find an aggregate for
+ * that specific type.
+ *
+ * else attempt to find an aggregate with a basetype of ANYOID. This
+ * means that the aggregate is to apply to all basetypes (eg, COUNT).
+ */
+ if (basetype)
+ basetypeOid = typenameTypeId(basetype);
+ else
+ basetypeOid = ANYOID;
+
+ rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
+
+ procOid = find_aggregate_func("RenameAggregate", name, basetypeOid);
+
+ tup = SearchSysCacheCopy(PROCOID,
+ ObjectIdGetDatum(procOid),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(tup)) /* should not happen */
+ elog(ERROR, "RenameAggregate: couldn't find pg_proc tuple for %s",
+ NameListToString(name));
+
+ namespaceOid = ((Form_pg_proc) GETSTRUCT(tup))->pronamespace;
+
+ /* make sure the new name doesn't exist */
+ MemSet(oid_array, 0, sizeof(oid_array));
+ oid_array[0] = basetypeOid;
+ if (SearchSysCacheExists(PROCNAMENSP,
+ CStringGetDatum(newname),
+ Int16GetDatum(1),
+ PointerGetDatum(oid_array),
+ ObjectIdGetDatum(namespaceOid)))
+ {
+ if (basetypeOid == ANYOID)
+ elog(ERROR, "function %s(*) already exists in schema %s",
+ newname, get_namespace_name(namespaceOid));
+ else
+ elog(ERROR, "function %s(%s) already exists in schema %s",
+ newname, format_type_be(basetypeOid), get_namespace_name(namespaceOid));
+ }
+
+ /* must be owner */
+ if (!pg_proc_ownercheck(procOid, GetUserId()))
+ aclcheck_error(ACLCHECK_NOT_OWNER, NameListToString(name));
+
+ /* must have CREATE privilege on namespace */
+ aclresult = pg_namespace_aclcheck(namespaceOid, GetUserId(), ACL_CREATE);
+ if (aclresult != ACLCHECK_OK)
+ aclcheck_error(aclresult, get_namespace_name(namespaceOid));
+
+ /* rename */
+ namestrcpy(&(((Form_pg_proc) GETSTRUCT(tup))->proname), newname);
+ simple_heap_update(rel, &tup->t_self, tup);
+ CatalogUpdateIndexes(rel, tup);
+
+ heap_close(rel, NoLock);
+ heap_freetuple(tup);
+}
--- /dev/null
+/*-------------------------------------------------------------------------
+ *
+ * alter.c
+ * Drivers for generic alter commands
+ *
+ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/backend/commands/alter.c,v 1.1 2003/06/27 14:45:27 petere Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#include "postgres.h"
+
+#include "access/htup.h"
+#include "catalog/catalog.h"
+#include "catalog/namespace.h"
+#include "catalog/pg_class.h"
+#include "commands/alter.h"
+#include "commands/conversioncmds.h"
+#include "commands/dbcommands.h"
+#include "commands/defrem.h"
+#include "commands/proclang.h"
+#include "commands/schemacmds.h"
+#include "commands/tablecmds.h"
+#include "commands/trigger.h"
+#include "commands/user.h"
+#include "miscadmin.h"
+#include "parser/parse_clause.h"
+#include "utils/acl.h"
+#include "utils/lsyscache.h"
+#include "utils/syscache.h"
+
+
+static void
+CheckOwnership(RangeVar *rel, bool noCatalogs)
+{
+ Oid relOid;
+ HeapTuple tuple;
+
+ relOid = RangeVarGetRelid(rel, false);
+ tuple = SearchSysCache(RELOID,
+ ObjectIdGetDatum(relOid),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(tuple))
+ elog(ERROR, "Relation \"%s\" does not exist", rel->relname);
+
+ if (!pg_class_ownercheck(relOid, GetUserId()))
+ aclcheck_error(ACLCHECK_NOT_OWNER, rel->relname);
+
+ if (noCatalogs)
+ {
+ if (!allowSystemTableMods &&
+ IsSystemClass((Form_pg_class) GETSTRUCT(tuple)))
+ elog(ERROR, "relation \"%s\" is a system catalog",
+ rel->relname);
+ }
+
+ ReleaseSysCache(tuple);
+}
+
+
+void
+ExecRenameStmt(RenameStmt *stmt)
+{
+ switch (stmt->renameType)
+ {
+ case OBJECT_AGGREGATE:
+ RenameAggregate(stmt->object, (TypeName *) lfirst(stmt->objarg), stmt->newname);
+ break;
+
+ case OBJECT_CONVERSION:
+ RenameConversion(stmt->object, stmt->newname);
+ break;
+
+ case OBJECT_DATABASE:
+ RenameDatabase(stmt->subname, stmt->newname);
+ break;
+
+ case OBJECT_FUNCTION:
+ RenameFunction(stmt->object, stmt->objarg, stmt->newname);
+ break;
+
+ case OBJECT_GROUP:
+ RenameGroup(stmt->subname, stmt->newname);
+ break;
+
+ case OBJECT_LANGUAGE:
+ RenameLanguage(stmt->subname, stmt->newname);
+ break;
+
+ case OBJECT_OPCLASS:
+ RenameOpClass(stmt->object, stmt->subname, stmt->newname);
+ break;
+
+ case OBJECT_SCHEMA:
+ RenameSchema(stmt->subname, stmt->newname);
+ break;
+
+ case OBJECT_USER:
+ RenameUser(stmt->subname, stmt->newname);
+ break;
+
+ case OBJECT_TABLE:
+ case OBJECT_COLUMN:
+ case OBJECT_TRIGGER:
+ {
+ Oid relid;
+
+ CheckOwnership(stmt->relation, true);
+
+ relid = RangeVarGetRelid(stmt->relation, false);
+
+ switch (stmt->renameType)
+ {
+ case OBJECT_TABLE:
+ {
+ /*
+ * RENAME TABLE requires that we (still) hold
+ * CREATE rights on the containing namespace, as
+ * well as ownership of the table.
+ */
+ Oid namespaceId = get_rel_namespace(relid);
+ AclResult aclresult;
+
+ aclresult = pg_namespace_aclcheck(namespaceId,
+ GetUserId(),
+ ACL_CREATE);
+ if (aclresult != ACLCHECK_OK)
+ aclcheck_error(aclresult,
+ get_namespace_name(namespaceId));
+
+ renamerel(relid, stmt->newname);
+ break;
+ }
+ case OBJECT_COLUMN:
+ renameatt(relid,
+ stmt->subname, /* old att name */
+ stmt->newname, /* new att name */
+ interpretInhOption(stmt->relation->inhOpt), /* recursive? */
+ false); /* recursing already? */
+ break;
+ case OBJECT_TRIGGER:
+ renametrig(relid,
+ &n