Commit 2467394e authored by Tom Lane's avatar Tom Lane

Tablespaces. Alternate database locations are dead, long live tablespaces.

There are various things left to do: contrib dbsize and oid2name modules
need work, and so does the documentation.  Also someone should think about
COMMENT ON TABLESPACE and maybe RENAME TABLESPACE.  Also initlocation is
dead, it just doesn't know it yet.

Gavin Sherry and Tom Lane.
parent 474875f4
<!-- <!--
Documentation of the system catalogs, directed toward PostgreSQL developers Documentation of the system catalogs, directed toward PostgreSQL developers
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.87 2004/06/16 01:26:33 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.88 2004/06/18 06:13:02 tgl Exp $
--> -->
<chapter id="catalogs"> <chapter id="catalogs">
...@@ -178,6 +178,11 @@ ...@@ -178,6 +178,11 @@
<entry>planner statistics</entry> <entry>planner statistics</entry>
</row> </row>
<row>
<entry><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link></entry>
<entry>tablespaces within this database cluster</entry>
</row>
<row> <row>
<entry><link linkend="catalog-pg-trigger"><structname>pg_trigger</structname></link></entry> <entry><link linkend="catalog-pg-trigger"><structname>pg_trigger</structname></link></entry>
<entry>triggers</entry> <entry>triggers</entry>
...@@ -1058,6 +1063,17 @@ ...@@ -1058,6 +1063,17 @@
<entry>Name of the on-disk file of this relation; 0 if none</entry> <entry>Name of the on-disk file of this relation; 0 if none</entry>
</row> </row>
<row>
<entry><structfield>reltablespace</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
<entry>
The tablespace in which this relation is stored. If zero,
the database's default tablespace is implied. (Not meaningful
if the relation has no on-disk file.)
</entry>
</row>
<row> <row>
<entry><structfield>relpages</structfield></entry> <entry><structfield>relpages</structfield></entry>
<entry><type>int4</type></entry> <entry><type>int4</type></entry>
...@@ -1602,13 +1618,15 @@ ...@@ -1602,13 +1618,15 @@
</row> </row>
<row> <row>
<entry><structfield>datpath</structfield></entry> <entry><structfield>dattablespace</structfield></entry>
<entry><type>text</type></entry> <entry><type>oid</type></entry>
<entry></entry> <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
<entry> <entry>
If the database is stored at an alternative location then this The default tablespace for the database.
records the location. It's either an environment variable name Within this database, all tables for which
or an absolute path, depending how it was entered. <structname>pg_class</>.<structfield>reltablespace</> is zero
will be stored in this tablespace; in particular, all the non-shared
system catalogs will be there.
</entry> </entry>
</row> </row>
...@@ -2386,6 +2404,17 @@ ...@@ -2386,6 +2404,17 @@
<entry>Owner of the namespace</entry> <entry>Owner of the namespace</entry>
</row> </row>
<row>
<entry><structfield>nsptablespace</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
<entry>
The default tablespace in which to place relations created in this
namespace. If zero, the database's default tablespace is implied.
(Changing this does not affect pre-existing relations.)
</entry>
</row>
<row> <row>
<entry><structfield>nspacl</structfield></entry> <entry><structfield>nspacl</structfield></entry>
<entry><type>aclitem[]</type></entry> <entry><type>aclitem[]</type></entry>
...@@ -3232,6 +3261,73 @@ ...@@ -3232,6 +3261,73 @@
</sect1> </sect1>
<sect1 id="catalog-pg-tablespace">
<title><structname>pg_tablespace</structname></title>
<indexterm zone="catalog-pg-tablespace">
<primary>pg_tablespace</primary>
</indexterm>
<para>
The catalog <structname>pg_tablespace</structname> stores information
about the available tablespaces. Tables can be placed in particular
tablespaces to aid administration of disk layout.
</para>
<para>
Unlike most system catalogs, <structname>pg_tablespace</structname>
is shared across all databases of a cluster: there is only one
copy of <structname>pg_tablespace</structname> per cluster, not
one per database.
</para>
<table>
<title><structname>pg_tablespace</> Columns</title>
<tgroup cols=4>
<thead>
<row>
<entry>Name</entry>
<entry>Type</entry>
<entry>References</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><structfield>spcname</structfield></entry>
<entry><type>name</type></entry>
<entry></entry>
<entry>Tablespace name</entry>
</row>
<row>
<entry><structfield>spcowner</structfield></entry>
<entry><type>int4</type></entry>
<entry><literal><link linkend="catalog-pg-shadow"><structname>pg_shadow</structname></link>.usesysid</literal></entry>
<entry>Owner of the tablespace, usually the user who created it</entry>
</row>
<row>
<entry><structfield>spclocation</structfield></entry>
<entry><type>text</type></entry>
<entry></entry>
<entry>Location (directory path) of the tablespace</entry>
</row>
<row>
<entry><structfield>spcacl</structfield></entry>
<entry><type>aclitem[]</type></entry>
<entry></entry>
<entry>Access privileges</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
<sect1 id="catalog-pg-trigger"> <sect1 id="catalog-pg-trigger">
<title><structname>pg_trigger</structname></title> <title><structname>pg_trigger</structname></title>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.29 2003/11/29 19:51:37 pgsql Exp $ $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.30 2004/06/18 06:13:02 tgl Exp $
--> -->
<chapter id="managing-databases"> <chapter id="managing-databases">
...@@ -298,6 +298,11 @@ ALTER DATABASE mydb SET geqo TO off; ...@@ -298,6 +298,11 @@ ALTER DATABASE mydb SET geqo TO off;
<sect1 id="manage-ag-alternate-locs"> <sect1 id="manage-ag-alternate-locs">
<title>Alternative Locations</title> <title>Alternative Locations</title>
<para>
XXX this is entirely dead now, and needs to be replaced by a DBA-level
description of tablespaces.
</para>
<para> <para>
It is possible to create a database in a location other than the It is possible to create a database in a location other than the
default location for the installation. But remember that all database access default location for the installation. But remember that all database access
...@@ -368,21 +373,6 @@ CREATE DATABASE <replaceable>name</> WITH LOCATION '<replaceable>location</>'; ...@@ -368,21 +373,6 @@ CREATE DATABASE <replaceable>name</> WITH LOCATION '<replaceable>location</>';
Databases created in alternative locations can be Databases created in alternative locations can be
accessed and dropped like any other database. accessed and dropped like any other database.
</para> </para>
<note>
<para>
It can also be possible to specify absolute paths directly to the
<command>CREATE DATABASE</> command without defining environment
variables. This is disallowed by default because it is a security
risk. To allow it, you must compile <productname>PostgreSQL</> with
the C preprocessor macro <literal>ALLOW_ABSOLUTE_DBPATHS</>
defined. One way to do this is to run the compilation step like
this:
<programlisting>
gmake CPPFLAGS=-DALLOW_ABSOLUTE_DBPATHS all
</programlisting>
</para>
</note>
</sect1> </sect1>
<sect1 id="manage-ag-dropdb"> <sect1 id="manage-ag-dropdb">
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.56 2004/04/20 01:11:49 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.57 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
Complete list of usable sgml source files in this directory. Complete list of usable sgml source files in this directory.
--> -->
...@@ -44,6 +44,7 @@ Complete list of usable sgml source files in this directory. ...@@ -44,6 +44,7 @@ Complete list of usable sgml source files in this directory.
<!entity createSequence system "create_sequence.sgml"> <!entity createSequence system "create_sequence.sgml">
<!entity createTable system "create_table.sgml"> <!entity createTable system "create_table.sgml">
<!entity createTableAs system "create_table_as.sgml"> <!entity createTableAs system "create_table_as.sgml">
<!entity createTableSpace system "create_tablespace.sgml">
<!entity createTrigger system "create_trigger.sgml"> <!entity createTrigger system "create_trigger.sgml">
<!entity createType system "create_type.sgml"> <!entity createType system "create_type.sgml">
<!entity createUser system "create_user.sgml"> <!entity createUser system "create_user.sgml">
...@@ -66,6 +67,7 @@ Complete list of usable sgml source files in this directory. ...@@ -66,6 +67,7 @@ Complete list of usable sgml source files in this directory.
<!entity dropSchema system "drop_schema.sgml"> <!entity dropSchema system "drop_schema.sgml">
<!entity dropSequence system "drop_sequence.sgml"> <!entity dropSequence system "drop_sequence.sgml">
<!entity dropTable system "drop_table.sgml"> <!entity dropTable system "drop_table.sgml">
<!entity dropTableSpace system "drop_tablespace.sgml">
<!entity dropTrigger system "drop_trigger.sgml"> <!entity dropTrigger system "drop_trigger.sgml">
<!entity dropType system "drop_type.sgml"> <!entity dropType system "drop_type.sgml">
<!entity dropUser system "drop_user.sgml"> <!entity dropUser system "drop_user.sgml">
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_database.sgml,v 1.38 2004/03/23 02:47:35 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/create_database.sgml,v 1.39 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -22,9 +22,9 @@ PostgreSQL documentation ...@@ -22,9 +22,9 @@ PostgreSQL documentation
<synopsis> <synopsis>
CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
[ [ WITH ] [ OWNER [=] <replaceable class="parameter">dbowner</replaceable> ] [ [ WITH ] [ OWNER [=] <replaceable class="parameter">dbowner</replaceable> ]
[ LOCATION [=] '<replaceable class="parameter">dbpath</replaceable>' ]
[ TEMPLATE [=] <replaceable class="parameter">template</replaceable> ] [ TEMPLATE [=] <replaceable class="parameter">template</replaceable> ]
[ ENCODING [=] <replaceable class="parameter">encoding</replaceable> ] ] [ ENCODING [=] <replaceable class="parameter">encoding</replaceable> ]
[ TABLESPACE [=] <replaceable class="parameter">tablespace</replaceable> ] ]
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -50,29 +50,6 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> ...@@ -50,29 +50,6 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
privilege can only create databases owned by themselves. privilege can only create databases owned by themselves.
</para> </para>
<para>
An alternative location can be specified in order to,
for example, store the database on a different disk.
The path must have been prepared with the
<xref linkend="APP-INITLOCATION" endterm="APP-INITLOCATION-title">
command.
</para>
<para>
If the path name does not contain a slash, it is interpreted
as an environment variable name, which must be known to the
server process. This way the database administrator can
exercise control over locations in which databases can be created.
(A customary choice is, e.g., <envar>PGDATA2</envar>.)
If the server is compiled with <literal>ALLOW_ABSOLUTE_DBPATHS</literal>
(not so by default), absolute path names, as identified by
a leading slash
(e.g., <filename>/usr/local/pgsql/data</filename>),
are allowed as well.
In either case, the final path name must be absolute and must not
contain any single quotes.
</para>
<para> <para>
By default, the new database will be created by cloning the standard By default, the new database will be created by cloning the standard
system database <literal>template1</>. A different template can be system database <literal>template1</>. A different template can be
...@@ -83,13 +60,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> ...@@ -83,13 +60,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
version of <productname>PostgreSQL</productname>. This is useful version of <productname>PostgreSQL</productname>. This is useful
if you wish to avoid copying if you wish to avoid copying
any installation-local objects that may have been added to any installation-local objects that may have been added to
<literal>template1</>. <literal>template1</>.
</para>
<para>
The optional encoding parameter allows selection of the database
encoding. When not specified, it defaults to the encoding used by
the selected template database.
</para> </para>
</refsect1> </refsect1>
...@@ -101,7 +72,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> ...@@ -101,7 +72,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<term><replaceable class="parameter">name</replaceable></term> <term><replaceable class="parameter">name</replaceable></term>
<listitem> <listitem>
<para> <para>
The name of a database to create. The name of a database to create.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -110,41 +81,43 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> ...@@ -110,41 +81,43 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<listitem> <listitem>
<para> <para>
The name of the database user who will own the new database, The name of the database user who will own the new database,
or <literal>DEFAULT</literal> to use the default (namely, the or <literal>DEFAULT</literal> to use the default (namely, the
user executing the command). user executing the command).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><replaceable class="parameter">dbpath</replaceable></term> <term><replaceable class="parameter">template</replaceable></term>
<listitem> <listitem>
<para> <para>
An alternate file-system location in which to store the new database, The name of the template from which to create the new database,
specified as a string literal; or <literal>DEFAULT</literal> to use the default template
or <literal>DEFAULT</literal> to use the default location. (<literal>template1</literal>).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><replaceable class="parameter">template</replaceable></term> <term><replaceable class="parameter">encoding</replaceable></term>
<listitem> <listitem>
<para> <para>
The name of the template from which to create the new database, Character set encoding to use in the new database. Specify
or <literal>DEFAULT</literal> to use the default template a string constant (e.g., <literal>'SQL_ASCII'</literal>),
(<literal>template1</literal>). or an integer encoding number, or <literal>DEFAULT</literal>
to use the default encoding. The character sets supported by the
<productname>PostgreSQL</productname> server are described in
<xref linkend="multibyte-charset-supported">.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><replaceable class="parameter">encoding</replaceable></term> <term><replaceable class="parameter">tablespace</replaceable></term>
<listitem> <listitem>
<para> <para>
Character set encoding to use in the new database. Specify Specifies the default tablespace for the new database.
a string constant (e.g., <literal>'SQL_ASCII'</literal>), If not specified, the same tablespace that is default for
or an integer encoding number, or <literal>DEFAULT</literal> the template database is used. See
to use the default encoding. The character sets supported by the <xref linkend="sql-createtablespace" endterm="sql-createtablespace-title">
<productname>PostgreSQL</productname> server are described in for more information.
<xref linkend="multibyte-charset-supported">.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -167,9 +140,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> ...@@ -167,9 +140,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<para> <para>
Errors along the line of <quote>could not initialize database directory</> Errors along the line of <quote>could not initialize database directory</>
are most likely related to insufficient permissions on the data are most likely related to insufficient permissions on the data
directory, a full disk, or other file system problems. When using an directory, a full disk, or other file system problems.
alternate location, the user under
which the database server is running must have access to the location.
</para> </para>
<para> <para>
...@@ -181,13 +152,6 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> ...@@ -181,13 +152,6 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
wrapper program around this command, provided for convenience. wrapper program around this command, provided for convenience.
</para> </para>
<para>
There are security issues involved with using alternate database
locations specified with absolute path names; this is why the feature
is not enabled by default. See <xref
linkend="manage-ag-alternate-locs"> for more information.
</para>
<para> <para>
Although it is possible to copy a database other than <literal>template1</> Although it is possible to copy a database other than <literal>template1</>
by specifying its name as the template, this is not (yet) intended as by specifying its name as the template, this is not (yet) intended as
...@@ -205,24 +169,6 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> ...@@ -205,24 +169,6 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<programlisting> <programlisting>
CREATE DATABASE lusiadas; CREATE DATABASE lusiadas;
</programlisting>
</para>
<para>
To create a new database in an alternate area
<filename>~/private_db</filename>, execute the following from the
shell:
<programlisting>
mkdir private_db
initlocation ~/private_db
</programlisting>
Then execute the following from within a
<application>psql</application> session:
<programlisting>
CREATE DATABASE elsewhere WITH LOCATION '/home/olly/private_db';
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.47 2004/04/20 12:53:28 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.48 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -22,6 +22,7 @@ PostgreSQL documentation ...@@ -22,6 +22,7 @@ PostgreSQL documentation
<synopsis> <synopsis>
CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table</replaceable> [ USING <replaceable class="parameter">method</replaceable> ] CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table</replaceable> [ USING <replaceable class="parameter">method</replaceable> ]
( { <replaceable class="parameter">column</replaceable> | ( <replaceable class="parameter">expression</replaceable> ) } [ <replaceable class="parameter">opclass</replaceable> ] [, ...] ) ( { <replaceable class="parameter">column</replaceable> | ( <replaceable class="parameter">expression</replaceable> ) } [ <replaceable class="parameter">opclass</replaceable> ] [, ...] )
[ TABLESPACE <replaceable class="parameter">tablespace</replaceable> ]
[ WHERE <replaceable class="parameter">predicate</replaceable> ] [ WHERE <replaceable class="parameter">predicate</replaceable> ]
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -78,7 +79,7 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re ...@@ -78,7 +79,7 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<para> <para>
Indexes are not used for <literal>IS NULL</> clauses by default. Indexes are not used for <literal>IS NULL</> clauses by default.
The best way to use indexes in such cases is to create a partial index The best way to use indexes in such cases is to create a partial index
using an <literal>IS NULL</> comparison. using an <literal>IS NULL</> comparison.
</para> </para>
...@@ -109,11 +110,11 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re ...@@ -109,11 +110,11 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><literal>UNIQUE</literal></term> <term><literal>UNIQUE</literal></term>
<listitem> <listitem>
<para> <para>
Causes the system to check for Causes the system to check for
duplicate values in the table when the index is created (if data duplicate values in the table when the index is created (if data
already exist) and each time data is added. Attempts to already exist) and each time data is added. Attempts to
insert or update data which would result in duplicate entries insert or update data which would result in duplicate entries
will generate an error. will generate an error.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -122,9 +123,9 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re ...@@ -122,9 +123,9 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">name</replaceable></term> <term><replaceable class="parameter">name</replaceable></term>
<listitem> <listitem>
<para> <para>
The name of the index to be created. No schema name can be included The name of the index to be created. No schema name can be included
here; the index is always created in the same schema as its parent here; the index is always created in the same schema as its parent
table. table.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -133,7 +134,7 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re ...@@ -133,7 +134,7 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">table</replaceable></term> <term><replaceable class="parameter">table</replaceable></term>
<listitem> <listitem>
<para> <para>
The name (possibly schema-qualified) of the table to be indexed. The name (possibly schema-qualified) of the table to be indexed.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -154,7 +155,7 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re ...@@ -154,7 +155,7 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">column</replaceable></term> <term><replaceable class="parameter">column</replaceable></term>
<listitem> <listitem>
<para> <para>
The name of a column of the table. The name of a column of the table.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -163,10 +164,10 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re ...@@ -163,10 +164,10 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">expression</replaceable></term> <term><replaceable class="parameter">expression</replaceable></term>
<listitem> <listitem>
<para> <para>
An expression based on one or more columns of the table. The An expression based on one or more columns of the table. The
expression usually must be written with surrounding parentheses, expression usually must be written with surrounding parentheses,
as shown in the syntax. However, the parentheses may be omitted as shown in the syntax. However, the parentheses may be omitted
if the expression has the form of a function call. if the expression has the form of a function call.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -175,7 +176,17 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re ...@@ -175,7 +176,17 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">opclass</replaceable></term> <term><replaceable class="parameter">opclass</replaceable></term>
<listitem> <listitem>
<para> <para>
The name of an operator class. See below for details. The name of an operator class. See below for details.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">tablespace</replaceable></term>
<listitem>
<para>
The tablespace in which to create the index. If not specified,
the tablespace of the parent table is used.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -184,10 +195,11 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re ...@@ -184,10 +195,11 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">predicate</replaceable></term> <term><replaceable class="parameter">predicate</replaceable></term>
<listitem> <listitem>
<para> <para>
The constraint expression for a partial index. The constraint expression for a partial index.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>
...@@ -260,7 +272,7 @@ SELECT * FROM points ...@@ -260,7 +272,7 @@ SELECT * FROM points
--> -->
</refsect1> </refsect1>
<refsect1> <refsect1>
<title>Compatibility</title> <title>Compatibility</title>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.11 2004/01/11 05:46:58 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.12 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -12,7 +12,7 @@ PostgreSQL documentation ...@@ -12,7 +12,7 @@ PostgreSQL documentation
<refnamediv> <refnamediv>
<refname>CREATE SCHEMA</refname> <refname>CREATE SCHEMA</refname>
<refpurpose>define a new schema</refpurpose> <refpurpose>define a new schema</refpurpose>
</refnamediv> </refnamediv>
<indexterm zone="sql-createschema"> <indexterm zone="sql-createschema">
<primary>CREATE SCHEMA</primary> <primary>CREATE SCHEMA</primary>
...@@ -20,8 +20,8 @@ PostgreSQL documentation ...@@ -20,8 +20,8 @@ PostgreSQL documentation
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
CREATE SCHEMA <replaceable class="parameter">schemaname</replaceable> [ AUTHORIZATION <replaceable class="parameter">username</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ] CREATE SCHEMA <replaceable class="parameter">schemaname</replaceable> [ AUTHORIZATION <replaceable class="parameter">username</replaceable> ] [ TABLESPACE <replaceable class="parameter">tablespace</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable> [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ] CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable> [ TABLESPACE <replaceable class="parameter">tablespace</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -54,7 +54,7 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable ...@@ -54,7 +54,7 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
all the created objects will be owned by that user. all the created objects will be owned by that user.
</para> </para>
</refsect1> </refsect1>
<refsect1> <refsect1>
<title>Parameters</title> <title>Parameters</title>
...@@ -63,8 +63,8 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable ...@@ -63,8 +63,8 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
<term><replaceable class="parameter">schemaname</replaceable></term> <term><replaceable class="parameter">schemaname</replaceable></term>
<listitem> <listitem>
<para> <para>
The name of a schema to be created. If this is omitted, the user name The name of a schema to be created. If this is omitted, the user name
is used as the schema name. is used as the schema name.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -74,8 +74,19 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable ...@@ -74,8 +74,19 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
<listitem> <listitem>
<para> <para>
The name of the user who will own the schema. If omitted, The name of the user who will own the schema. If omitted,
defaults to the user executing the command. Only superusers defaults to the user executing the command. Only superusers
may create schemas owned by users other than themselves. may create schemas owned by users other than themselves.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">tablespace</replaceable></term>
<listitem>
<para>
The name of the tablespace that is to be the default tablespace
for all new objects created in the schema. If not supplied, the schema
will inherit the default tablespace of the database.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -102,8 +113,10 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable ...@@ -102,8 +113,10 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
<para> <para>
To create a schema, the invoking user must have the To create a schema, the invoking user must have the
<literal>CREATE</> privilege for the current database. (Of course, <literal>CREATE</> privilege for the current database.
superusers bypass this check.) Also, the <literal>TABLESPACE</> option requires having
<literal>CREATE</> privilege for the specified tablespace.
(Of course, superusers bypass these checks.)
</para> </para>
</refsect1> </refsect1>
...@@ -181,7 +194,8 @@ CREATE VIEW hollywood.winners AS ...@@ -181,7 +194,8 @@ CREATE VIEW hollywood.winners AS
<simplelist type="inline"> <simplelist type="inline">
<member><xref linkend="sql-alterschema" endterm="sql-alterschema-title"></member> <member><xref linkend="sql-alterschema" endterm="sql-alterschema-title"></member>
<member><xref linkend="sql-dropschema" endterm="sql-dropschema-title"></member> <member><xref linkend="sql-dropschema" endterm="sql-dropschema-title"></member>
</simplelist> <member><xref linkend="sql-createtablespace" endterm="sql-createtablespace-title"></member>
</simplelist>
</refsect1> </refsect1>
</refentry> </refentry>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.39 2003/11/29 19:51:38 pgsql Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.40 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -12,7 +12,7 @@ PostgreSQL documentation ...@@ -12,7 +12,7 @@ PostgreSQL documentation
<refnamediv> <refnamediv>
<refname>CREATE SEQUENCE</refname> <refname>CREATE SEQUENCE</refname>
<refpurpose>define a new sequence generator</refpurpose> <refpurpose>define a new sequence generator</refpurpose>
</refnamediv> </refnamediv>
<indexterm zone="sql-createsequence"> <indexterm zone="sql-createsequence">
<primary>CREATE SEQUENCE</primary> <primary>CREATE SEQUENCE</primary>
...@@ -23,6 +23,7 @@ PostgreSQL documentation ...@@ -23,6 +23,7 @@ PostgreSQL documentation
CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ BY ] <replaceable class="parameter">increment</replaceable> ] CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ BY ] <replaceable class="parameter">increment</replaceable> ]
[ MINVALUE <replaceable class="parameter">minvalue</replaceable> | NO MINVALUE ] [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> | NO MAXVALUE ] [ MINVALUE <replaceable class="parameter">minvalue</replaceable> | NO MINVALUE ] [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> | NO MAXVALUE ]
[ START [ WITH ] <replaceable class="parameter">start</replaceable> ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ] [ START [ WITH ] <replaceable class="parameter">start</replaceable> ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ]
[ TABLESPACE <replaceable class="parameter">tablespace</replaceable> ]
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -193,6 +194,19 @@ SELECT * FROM <replaceable>name</replaceable>; ...@@ -193,6 +194,19 @@ SELECT * FROM <replaceable>name</replaceable>;
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><replaceable class="parameter">tablespace</replaceable></term>
<listitem>
<para>
The optional clause <literal>TABLESPACE</> <replaceable
class="parameter">tablespace</replaceable> specifies
the tablespace in which to create the sequence. If this clause
is not supplied, the tablespace of the sequence's schema will be used.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>
...@@ -268,7 +282,7 @@ CREATE SEQUENCE serial START 101; ...@@ -268,7 +282,7 @@ CREATE SEQUENCE serial START 101;
Select the next number from this sequence: Select the next number from this sequence:
<programlisting> <programlisting>
SELECT nextval('serial'); SELECT nextval('serial');
nextval nextval
--------- ---------
114 114
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.81 2004/05/19 23:10:43 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.82 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -28,6 +28,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable class="PAR ...@@ -28,6 +28,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable class="PAR
[ INHERITS ( <replaceable>parent_table</replaceable> [, ... ] ) ] [ INHERITS ( <replaceable>parent_table</replaceable> [, ... ] ) ]
[ WITH OIDS | WITHOUT OIDS ] [ WITH OIDS | WITHOUT OIDS ]
[ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ] [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
[ TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ]
where <replaceable class="PARAMETER">column_constraint</replaceable> is: where <replaceable class="PARAMETER">column_constraint</replaceable> is:
...@@ -48,7 +49,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is: ...@@ -48,7 +49,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
[ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] } [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1 id="SQL-CREATETABLE-description"> <refsect1 id="SQL-CREATETABLE-description">
...@@ -321,7 +322,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is: ...@@ -321,7 +322,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><literal>UNIQUE</> (column constraint)</term> <term><literal>UNIQUE</> (column constraint)</term>
<term><literal>UNIQUE ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] )</> (table constraint)</term> <term><literal>UNIQUE ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] )</> (table constraint)</term>
...@@ -405,9 +406,9 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is: ...@@ -405,9 +406,9 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
<term><literal>REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH <replaceable class="parameter">matchtype</replaceable> ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal> (column constraint)</term> <term><literal>REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH <replaceable class="parameter">matchtype</replaceable> ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal> (column constraint)</term>
<term><literal>FOREIGN KEY ( <replaceable class="parameter">column</replaceable> [, ... ] ) <term><literal>FOREIGN KEY ( <replaceable class="parameter">column</replaceable> [, ... ] )
REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> [, ... ] ) ] REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> [, ... ] ) ]
[ MATCH <replaceable class="parameter">matchtype</replaceable> ] [ MATCH <replaceable class="parameter">matchtype</replaceable> ]
[ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON DELETE <replaceable class="parameter">action</replaceable> ]
[ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal> [ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal>
(table constraint)</term> (table constraint)</term>
...@@ -514,7 +515,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is: ...@@ -514,7 +515,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><literal>DEFERRABLE</literal></term> <term><literal>DEFERRABLE</literal></term>
<term><literal>NOT DEFERRABLE</literal></term> <term><literal>NOT DEFERRABLE</literal></term>
...@@ -553,7 +554,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is: ...@@ -553,7 +554,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
<listitem> <listitem>
<para> <para>
The behavior of temporary tables at the end of a transaction The behavior of temporary tables at the end of a transaction
block can be controlled using <literal>ON COMMIT</literal>. block can be controlled using <literal>ON COMMIT</literal>.
The three options are: The three options are:
<variablelist> <variablelist>
...@@ -561,19 +562,19 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is: ...@@ -561,19 +562,19 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
<term><literal>PRESERVE ROWS</literal></term> <term><literal>PRESERVE ROWS</literal></term>
<listitem> <listitem>
<para> <para>
No special action is taken at the ends of transactions. No special action is taken at the ends of transactions.
This is the default behavior. This is the default behavior.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><literal>DELETE ROWS</literal></term> <term><literal>DELETE ROWS</literal></term>
<listitem> <listitem>
<para> <para>
All rows in the temporary table will be deleted at the All rows in the temporary table will be deleted at the
end of each transaction block. Essentially, an automatic end of each transaction block. Essentially, an automatic
<xref linkend="sql-truncate"> is done at each commit. <xref linkend="sql-truncate"> is done at each commit.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -583,7 +584,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is: ...@@ -583,7 +584,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
<listitem> <listitem>
<para> <para>
The temporary table will be dropped at the end of the current The temporary table will be dropped at the end of the current
transaction block. transaction block.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -591,8 +592,20 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is: ...@@ -591,8 +592,20 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><literal>TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable></literal></term>
<listitem>
<para>
The <replaceable class="PARAMETER">tablespace</replaceable> is the name
of the tablespace in which the new table is to be created. If not
supplied, the default tablespace of the table's schema will be used.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>
<refsect1 id="SQL-CREATETABLE-notes"> <refsect1 id="SQL-CREATETABLE-notes">
<title>Notes</title> <title>Notes</title>
...@@ -696,7 +709,7 @@ CREATE TABLE films ( ...@@ -696,7 +709,7 @@ CREATE TABLE films (
); );
</programlisting> </programlisting>
</para> </para>
<para> <para>
Define a check column constraint: Define a check column constraint:
...@@ -719,7 +732,7 @@ CREATE TABLE distributors ( ...@@ -719,7 +732,7 @@ CREATE TABLE distributors (
); );
</programlisting> </programlisting>
</para> </para>
<para> <para>
Define a primary key table constraint for the table Define a primary key table constraint for the table
<structname>films</>. Primary key table constraints can be defined <structname>films</>. Primary key table constraints can be defined
...@@ -749,7 +762,7 @@ CREATE TABLE distributors ( ...@@ -749,7 +762,7 @@ CREATE TABLE distributors (
did integer, did integer,
name varchar(40), name varchar(40),
PRIMARY KEY(did) PRIMARY KEY(did)
); );
</programlisting> </programlisting>
<programlisting> <programlisting>
...@@ -812,7 +825,7 @@ CREATE TABLE distributors ( ...@@ -812,7 +825,7 @@ CREATE TABLE distributors (
</para> </para>
</refsect1> </refsect1>
<refsect1 id="SQL-CREATETABLE-compatibility"> <refsect1 id="SQL-CREATETABLE-compatibility">
<title id="SQL-CREATETABLE-compatibility-title">Compatibility</title> <title id="SQL-CREATETABLE-compatibility-title">Compatibility</title>
...@@ -827,7 +840,7 @@ CREATE TABLE distributors ( ...@@ -827,7 +840,7 @@ CREATE TABLE distributors (
<para> <para>
Although the syntax of <literal>CREATE TEMPORARY TABLE</literal> Although the syntax of <literal>CREATE TEMPORARY TABLE</literal>
resembles that of the SQL standard, the effect is not the same. In the resembles that of the SQL standard, the effect is not the same. In the
standard, standard,
temporary tables are defined just once and automatically exist (starting temporary tables are defined just once and automatically exist (starting
with empty contents) in every session that needs them. with empty contents) in every session that needs them.
<productname>PostgreSQL</productname> instead <productname>PostgreSQL</productname> instead
...@@ -889,7 +902,7 @@ CREATE TABLE distributors ( ...@@ -889,7 +902,7 @@ CREATE TABLE distributors (
column, its presence is simply noise. column, its presence is simply noise.
</para> </para>
</refsect2> </refsect2>
<refsect2> <refsect2>
<title>Inheritance</title> <title>Inheritance</title>
...@@ -923,6 +936,15 @@ CREATE TABLE distributors ( ...@@ -923,6 +936,15 @@ CREATE TABLE distributors (
DROP COLUMN</>, so it seems cleaner to ignore this spec restriction. DROP COLUMN</>, so it seems cleaner to ignore this spec restriction.
</para> </para>
</refsect2> </refsect2>
<refsect2>
<title>TABLESPACE</title>
<para>
The <productname>PostgreSQL</productname> concept of tablespaces is not
standard.
</para>
</refsect2>
</refsect1> </refsect1>
...@@ -932,6 +954,7 @@ CREATE TABLE distributors ( ...@@ -932,6 +954,7 @@ CREATE TABLE distributors (
<simplelist type="inline"> <simplelist type="inline">
<member><xref linkend="sql-altertable" endterm="sql-altertable-title"></member> <member><xref linkend="sql-altertable" endterm="sql-altertable-title"></member>
<member><xref linkend="sql-droptable" endterm="sql-droptable-title"></member> <member><xref linkend="sql-droptable" endterm="sql-droptable-title"></member>
<member><xref linkend="sql-createtablespace" endterm="sql-createtablespace-title"></member>
</simplelist> </simplelist>
</refsect1> </refsect1>
</refentry> </refentry>
......
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_tablespace.sgml,v 1.1 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
<refentry id="SQL-CREATETABLESPACE">
<refmeta>
<refentrytitle id="sql-createtablespace-title">CREATE TABLESPACE</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>CREATE TABLESPACE</refname>
<refpurpose>define a new tablespace</refpurpose>
</refnamediv>
<indexterm zone="sql-createtablespace">
<primary>CREATE TABLESPACE</primary>
</indexterm>
<refsynopsisdiv>
<synopsis>
CREATE TABLESPACE <replaceable class="parameter">tablespacename</replaceable> [ OWNER <replaceable class="parameter">username</replaceable> ] LOCATION '<replaceable class="parameter">directory</replaceable>'
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>CREATE TABLESPACE</command> registers a new cluster-wide
tablespace. The tablespace name must be distinct from the name of any
existing tablespace in the database cluster.
</para>
<para>
A tablespace allows superusers to define an alternative location on the
file system where the data files representing database objects
(such as tables and indexes) may reside.
</para>
<para>
A user with appropriate privileges can pass
<replaceable class="parameter">tablespacename</> to <command>CREATE
DATABASE</>, <command>CREATE SCHEMA</>, <command>CREATE TABLE</>,
<command>CREATE INDEX</> or <command>CREATE SEQUENCE</> to have the data
files for these objects stored within the specified tablespace.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><replaceable class="parameter">tablespacename</replaceable></term>
<listitem>
<para>
The name of a tablespace to be created.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">username</replaceable></term>
<listitem>
<para>
The name of the user who will own the tablespace. If omitted,
defaults to the user executing the command. Only superusers
may create tablespaces, but they can assign ownership of tablespaces
to non-superusers.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">directory</replaceable></term>
<listitem>
<para>
The directory that will be used for the tablespace. The directory
must be empty and must be owned by the
<productname>PostgreSQL</> system user. The directory must be
specified by an absolute path name.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
Tablespaces are only supported on systems that support symbolic links.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
Create a tablespace <literal>dbspace</> at <literal>/data/dbs</>:
<programlisting>
CREATE TABLESPACE dbspace LOCATION '/data/dbs';
</programlisting>
</para>
<para>
Create a tablespace <literal>indexspace</> at <literal>/data/indexes</>
owned by user <literal>genevieve</>:
<programlisting>
CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';
</programlisting>
</para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
<command>CREATE TABLESPACE</command> is a <productname>PostgreSQL</>
extension.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-createdatabase" endterm="sql-createdatabase-title"></member>
<member><xref linkend="sql-createschema" endterm="sql-createschema-title"></member>
<member><xref linkend="sql-createtable" endterm="sql-createtable-title"></member>
<member><xref linkend="sql-createindex" endterm="sql-createindex-title"></member>
<member><xref linkend="sql-createsequence" endterm="sql-createsequence-title"></member>
<member><xref linkend="sql-droptablespace" endterm="sql-droptablespace-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:
-->
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_tablespace.sgml,v 1.1 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
<refentry id="SQL-DROPTABLESPACE">
<refmeta>
<refentrytitle id="SQL-DROPTABLESPACE-TITLE">DROP TABLESPACE</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>DROP TABLESPACE</refname>
<refpurpose>remove a tablespace</refpurpose>
</refnamediv>
<indexterm zone="sql-droptablespace">
<primary>DROP TABLESPACE</primary>
</indexterm>
<refsynopsisdiv>
<synopsis>
DROP TABLESPACE <replaceable class="PARAMETER">tablespacename</replaceable>
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>DROP TABLESPACE</command> removes a tablespace from the system.
</para>
<para>
A tablespace can only be dropped by its owner or a superuser.
The tablespace must be empty of all database objects before it can be
dropped. It is possible that objects in other databases may still reside
in the tablespace even if no objects in the current database are using
the tablespace.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><replaceable class="PARAMETER">tablespacename</replaceable></term>
<listitem>
<para>
The name of a tablespace.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
To remove tablespace <literal>mystuff</literal> from the system:
<programlisting>
DROP TABLESPACE mystuff;
</programlisting>
</para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
<command>DROP TABLESPACE</command> is a <productname>PostgreSQL</>
extension.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-createtablespace" endterm="sql-createtablespace-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:
-->
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.40 2004/06/01 21:49:21 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.41 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -29,6 +29,10 @@ GRANT { { CREATE | TEMPORARY | TEMP } [,...] | ALL [ PRIVILEGES ] } ...@@ -29,6 +29,10 @@ GRANT { { CREATE | TEMPORARY | TEMP } [,...] | ALL [ PRIVILEGES ] }
ON DATABASE <replaceable>dbname</replaceable> [, ...] ON DATABASE <replaceable>dbname</replaceable> [, ...]
TO { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ] TO { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { CREATE | ALL [ PRIVILEGES ] }
ON TABLESPACE <replaceable>tablespacename</> [, ...]
TO { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { EXECUTE | ALL [ PRIVILEGES ] } GRANT { EXECUTE | ALL [ PRIVILEGES ] }
ON FUNCTION <replaceable>funcname</replaceable> ([<replaceable>type</replaceable>, ...]) [, ...] ON FUNCTION <replaceable>funcname</replaceable> ([<replaceable>type</replaceable>, ...]) [, ...]
TO { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ] TO { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
...@@ -87,7 +91,7 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] } ...@@ -87,7 +91,7 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
<para> <para>
Depending on the type of object, the initial default privileges may Depending on the type of object, the initial default privileges may
include granting some privileges to <literal>PUBLIC</literal>. include granting some privileges to <literal>PUBLIC</literal>.
The default is no public access for tables and schemas; The default is no public access for tables, schemas, and tablespaces;
<literal>TEMP</> table creation privilege for databases; <literal>TEMP</> table creation privilege for databases;
<literal>EXECUTE</> privilege for functions; and <literal>EXECUTE</> privilege for functions; and
<literal>USAGE</> privilege for languages. <literal>USAGE</> privilege for languages.
...@@ -184,6 +188,12 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] } ...@@ -184,6 +188,12 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
<para> <para>
For databases, allows new schemas to be created within the database. For databases, allows new schemas to be created within the database.
</para> </para>
<para>
For tablespaces, allows tables to be created within the tablespace,
and allows databases and schemas to be created that have the tablespace
as their default tablespace. (Note that revoking this privilege
will not alter the behavior of existing databases and schemas.)
</para>
<para> <para>
For schemas, allows new objects to be created within the schema. For schemas, allows new objects to be created within the schema.
To rename an existing object, you must own the object <emphasis>and</> To rename an existing object, you must own the object <emphasis>and</>
...@@ -223,7 +233,7 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] } ...@@ -223,7 +233,7 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
of privilege that is applicable to procedural languages. of privilege that is applicable to procedural languages.
</para> </para>
<para> <para>
For schemas, allows access to objects contained in the specified For schemas, allows access to objects contained in the specified
schema (assuming that the objects' own privilege requirements are schema (assuming that the objects' own privilege requirements are
also met). Essentially this allows the grantee to <quote>look up</> also met). Essentially this allows the grantee to <quote>look up</>
objects within the schema. objects within the schema.
...@@ -385,7 +395,7 @@ GRANT ALL PRIVILEGES ON kinds TO manuel; ...@@ -385,7 +395,7 @@ GRANT ALL PRIVILEGES ON kinds TO manuel;
<refsect1 id="sql-grant-compatibility"> <refsect1 id="sql-grant-compatibility">
<title>Compatibility</title> <title>Compatibility</title>
<para> <para>
According to the SQL standard, the <literal>PRIVILEGES</literal> According to the SQL standard, the <literal>PRIVILEGES</literal>
key word in <literal>ALL PRIVILEGES</literal> is required. The key word in <literal>ALL PRIVILEGES</literal> is required. The
...@@ -412,7 +422,7 @@ GRANT <replaceable class="PARAMETER">privileges</replaceable> ...@@ -412,7 +422,7 @@ GRANT <replaceable class="PARAMETER">privileges</replaceable>
<para> <para>
The <literal>RULE</literal> privilege, and privileges on The <literal>RULE</literal> privilege, and privileges on
databases, schemas, languages, and sequences are databases, tablespaces, schemas, languages, and sequences are
<productname>PostgreSQL</productname> extensions. <productname>PostgreSQL</productname> extensions.
</para> </para>
</refsect1> </refsect1>
......
This diff is collapsed.
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/revoke.sgml,v 1.30 2004/06/01 21:49:21 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/revoke.sgml,v 1.31 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -33,6 +33,12 @@ REVOKE [ GRANT OPTION FOR ] ...@@ -33,6 +33,12 @@ REVOKE [ GRANT OPTION FOR ]
FROM { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...] FROM { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...]
[ CASCADE | RESTRICT ] [ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ CREATE | ALL [ PRIVILEGES ] }
ON TABLESPACE <replaceable>tablespacename</replaceable> [, ...]
FROM { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ] REVOKE [ GRANT OPTION FOR ]
{ EXECUTE | ALL [ PRIVILEGES ] } { EXECUTE | ALL [ PRIVILEGES ] }
ON FUNCTION <replaceable>funcname</replaceable> ([<replaceable>type</replaceable>, ...]) [, ...] ON FUNCTION <replaceable>funcname</replaceable> ([<replaceable>type</replaceable>, ...]) [, ...]
......
<!-- reference.sgml <!-- reference.sgml
$PostgreSQL: pgsql/doc/src/sgml/reference.sgml,v 1.47 2004/04/20 01:14:55 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/reference.sgml,v 1.48 2004/06/18 06:13:02 tgl Exp $
PostgreSQL Reference Manual PostgreSQL Reference Manual
--> -->
...@@ -76,6 +76,7 @@ PostgreSQL Reference Manual ...@@ -76,6 +76,7 @@ PostgreSQL Reference Manual
&createSequence; &createSequence;
&createTable; &createTable;
&createTableAs; &createTableAs;
&createTableSpace;
&createTrigger; &createTrigger;
&createType; &createType;
&createUser; &createUser;
...@@ -98,6 +99,7 @@ PostgreSQL Reference Manual ...@@ -98,6 +99,7 @@ PostgreSQL Reference Manual
&dropSchema; &dropSchema;
&dropSequence; &dropSequence;
&dropTable; &dropTable;
&dropTableSpace;
&dropTrigger; &dropTrigger;
&dropType; &dropType;
&dropUser; &dropUser;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.168 2004/05/27 17:12:37 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.169 2004/06/18 06:13:09 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -2630,8 +2630,8 @@ heap_undo(XLogRecPtr lsn, XLogRecord *record) ...@@ -2630,8 +2630,8 @@ heap_undo(XLogRecPtr lsn, XLogRecord *record)
static void static void
out_target(char *buf, xl_heaptid *target) out_target(char *buf, xl_heaptid *target)
{ {
sprintf(buf + strlen(buf), "node %u/%u; tid %u/%u", sprintf(buf + strlen(buf), "rel %u/%u/%u; tid %u/%u",
target->node.tblNode, target->node.relNode, target->node.spcNode, target->node.dbNode, target->node.relNode,
ItemPointerGetBlockNumber(&(target->tid)), ItemPointerGetBlockNumber(&(target->tid)),
ItemPointerGetOffsetNumber(&(target->tid))); ItemPointerGetOffsetNumber(&(target->tid)));
} }
...@@ -2673,8 +2673,9 @@ heap_desc(char *buf, uint8 xl_info, char *rec) ...@@ -2673,8 +2673,9 @@ heap_desc(char *buf, uint8 xl_info, char *rec)
{ {
xl_heap_clean *xlrec = (xl_heap_clean *) rec; xl_heap_clean *xlrec = (xl_heap_clean *) rec;
sprintf(buf + strlen(buf), "clean: node %u/%u; blk %u", sprintf(buf + strlen(buf), "clean: rel %u/%u/%u; blk %u",
xlrec->node.tblNode, xlrec->node.relNode, xlrec->block); xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block);
} }
else else
strcat(buf, "UNKNOWN"); strcat(buf, "UNKNOWN");
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.13 2004/06/02 17:28:17 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.14 2004/06/18 06:13:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -803,8 +803,8 @@ btree_undo(XLogRecPtr lsn, XLogRecord *record) ...@@ -803,8 +803,8 @@ btree_undo(XLogRecPtr lsn, XLogRecord *record)
static void static void
out_target(char *buf, xl_btreetid *target) out_target(char *buf, xl_btreetid *target)
{ {
sprintf(buf + strlen(buf), "node %u/%u; tid %u/%u", sprintf(buf + strlen(buf), "rel %u/%u/%u; tid %u/%u",
target->node.tblNode, target->node.relNode, target->node.spcNode, target->node.dbNode, target->node.relNode,
ItemPointerGetBlockNumber(&(target->tid)), ItemPointerGetBlockNumber(&(target->tid)),
ItemPointerGetOffsetNumber(&(target->tid))); ItemPointerGetOffsetNumber(&(target->tid)));
} }
...@@ -884,8 +884,9 @@ btree_desc(char *buf, uint8 xl_info, char *rec) ...@@ -884,8 +884,9 @@ btree_desc(char *buf, uint8 xl_info, char *rec)
{ {
xl_btree_delete *xlrec = (xl_btree_delete *) rec; xl_btree_delete *xlrec = (xl_btree_delete *) rec;
sprintf(buf + strlen(buf), "delete: node %u/%u; blk %u", sprintf(buf + strlen(buf), "delete: rel %u/%u/%u; blk %u",
xlrec->node.tblNode, xlrec->node.relNode, xlrec->block); xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block);
break; break;
} }
case XLOG_BTREE_DELETE_PAGE: case XLOG_BTREE_DELETE_PAGE:
...@@ -903,8 +904,9 @@ btree_desc(char *buf, uint8 xl_info, char *rec) ...@@ -903,8 +904,9 @@ btree_desc(char *buf, uint8 xl_info, char *rec)
{ {
xl_btree_newroot *xlrec = (xl_btree_newroot *) rec; xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
sprintf(buf + strlen(buf), "newroot: node %u/%u; root %u lev %u", sprintf(buf + strlen(buf), "newroot: rel %u/%u/%u; root %u lev %u",
xlrec->node.tblNode, xlrec->node.relNode, xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
xlrec->rootblk, xlrec->level); xlrec->rootblk, xlrec->level);
break; break;
} }
...@@ -912,8 +914,9 @@ btree_desc(char *buf, uint8 xl_info, char *rec) ...@@ -912,8 +914,9 @@ btree_desc(char *buf, uint8 xl_info, char *rec)
{ {
xl_btree_newmeta *xlrec = (xl_btree_newmeta *) rec; xl_btree_newmeta *xlrec = (xl_btree_newmeta *) rec;
sprintf(buf + strlen(buf), "newmeta: node %u/%u; root %u lev %u fast %u lev %u", sprintf(buf + strlen(buf), "newmeta: rel %u/%u/%u; root %u lev %u fast %u lev %u",
xlrec->node.tblNode, xlrec->node.relNode, xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
xlrec->meta.root, xlrec->meta.level, xlrec->meta.root, xlrec->meta.level,
xlrec->meta.fastroot, xlrec->meta.fastlevel); xlrec->meta.fastroot, xlrec->meta.fastlevel);
break; break;
...@@ -922,9 +925,9 @@ btree_desc(char *buf, uint8 xl_info, char *rec) ...@@ -922,9 +925,9 @@ btree_desc(char *buf, uint8 xl_info, char *rec)
{ {
xl_btree_newpage *xlrec = (xl_btree_newpage *) rec; xl_btree_newpage *xlrec = (xl_btree_newpage *) rec;
sprintf(buf + strlen(buf), "newpage: node %u/%u; page %u", sprintf(buf + strlen(buf), "newpage: rel %u/%u/%u; page %u",
xlrec->node.tblNode, xlrec->node.relNode, xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->blkno); xlrec->node.relNode, xlrec->blkno);
break; break;
} }
default: default:
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.30 2004/02/11 22:55:24 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.31 2004/06/18 06:13:15 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -354,7 +354,7 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode) ...@@ -354,7 +354,7 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
* though, since we are presumably running by ourselves and can't * though, since we are presumably running by ourselves and can't
* have any lock conflicts ... * have any lock conflicts ...
*/ */
res->reldata.rd_lockInfo.lockRelId.dbId = rnode.tblNode; res->reldata.rd_lockInfo.lockRelId.dbId = rnode.dbNode;
res->reldata.rd_lockInfo.lockRelId.relId = rnode.relNode; res->reldata.rd_lockInfo.lockRelId.relId = rnode.relNode;
hentry = (XLogRelCacheEntry *) hentry = (XLogRelCacheEntry *)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.69 2004/06/03 02:08:02 tgl Exp $ * $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.70 2004/06/18 06:13:17 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "catalog/pg_attribute.h" #include "catalog/pg_attribute.h"
#include "catalog/pg_class.h" #include "catalog/pg_class.h"
#include "catalog/pg_namespace.h" #include "catalog/pg_namespace.h"
#include "catalog/pg_tablespace.h"
#include "commands/defrem.h" #include "commands/defrem.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "nodes/makefuncs.h" #include "nodes/makefuncs.h"
...@@ -181,6 +182,7 @@ Boot_CreateStmt: ...@@ -181,6 +182,7 @@ Boot_CreateStmt:
boot_reldesc = heap_create(LexIDStr($5), boot_reldesc = heap_create(LexIDStr($5),
PG_CATALOG_NAMESPACE, PG_CATALOG_NAMESPACE,
$3 ? GLOBALTABLESPACE_OID : 0,
tupdesc, tupdesc,
$3, $3,
true, true,
...@@ -193,6 +195,7 @@ Boot_CreateStmt: ...@@ -193,6 +195,7 @@ Boot_CreateStmt:
id = heap_create_with_catalog(LexIDStr($5), id = heap_create_with_catalog(LexIDStr($5),
PG_CATALOG_NAMESPACE, PG_CATALOG_NAMESPACE,
$3 ? GLOBALTABLESPACE_OID : 0,
tupdesc, tupdesc,
RELKIND_RELATION, RELKIND_RELATION,
$3, $3,
...@@ -239,6 +242,7 @@ Boot_DeclareIndexStmt: ...@@ -239,6 +242,7 @@ Boot_DeclareIndexStmt:
DefineIndex(makeRangeVar(NULL, LexIDStr($5)), DefineIndex(makeRangeVar(NULL, LexIDStr($5)),
LexIDStr($3), LexIDStr($3),
LexIDStr($7), LexIDStr($7),
NULL,
$9, $9,
NULL, NIL, NULL, NIL,
false, false, false, false, false, false,
...@@ -255,6 +259,7 @@ Boot_DeclareUniqueIndexStmt: ...@@ -255,6 +259,7 @@ Boot_DeclareUniqueIndexStmt:
DefineIndex(makeRangeVar(NULL, LexIDStr($6)), DefineIndex(makeRangeVar(NULL, LexIDStr($6)),
LexIDStr($4), LexIDStr($4),
LexIDStr($8), LexIDStr($8),
NULL,
$10, $10,
NULL, NIL, NULL, NIL,
true, false, false, true, false, false,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# Makefile for backend/catalog # Makefile for backend/catalog
# #
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.50 2004/01/04 05:57:21 tgl Exp $ # $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.51 2004/06/18 06:13:19 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -32,7 +32,7 @@ POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\ ...@@ -32,7 +32,7 @@ POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\
pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \ pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \
pg_rewrite.h pg_trigger.h pg_listener.h pg_description.h pg_cast.h \ pg_rewrite.h pg_trigger.h pg_listener.h pg_description.h pg_cast.h \
pg_namespace.h pg_conversion.h pg_database.h pg_shadow.h pg_group.h \ pg_namespace.h pg_conversion.h pg_database.h pg_shadow.h pg_group.h \
pg_depend.h indexing.h \ pg_tablespace.h pg_depend.h indexing.h \
) )
pg_includes := $(sort -I$(top_srcdir)/src/include -I$(top_builddir)/src/include) pg_includes := $(sort -I$(top_srcdir)/src/include -I$(top_builddir)/src/include)
...@@ -59,5 +59,5 @@ installdirs: ...@@ -59,5 +59,5 @@ installdirs:
uninstall-data: uninstall-data:
rm -f $(addprefix $(DESTDIR)$(datadir)/, $(BKIFILES) system_views.sql information_schema.sql sql_features.txt) rm -f $(addprefix $(DESTDIR)$(datadir)/, $(BKIFILES) system_views.sql information_schema.sql sql_features.txt)
clean: clean:
rm -f SUBSYS.o $(OBJS) $(BKIFILES) rm -f SUBSYS.o $(OBJS) $(BKIFILES)
This diff is collapsed.
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.51 2004/01/06 18:07:31 neilc Exp $ * $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.52 2004/06/18 06:13:19 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -20,30 +20,48 @@ ...@@ -20,30 +20,48 @@
#include "catalog/catalog.h" #include "catalog/catalog.h"
#include "catalog/catname.h" #include "catalog/catname.h"
#include "catalog/pg_namespace.h" #include "catalog/pg_namespace.h"
#include "catalog/pg_tablespace.h"
#include "miscadmin.h" #include "miscadmin.h"
#define OIDCHARS 10 /* max chars printed by %u */
/* /*
* relpath - construct path to a relation's file * relpath - construct path to a relation's file
* *
* Result is a palloc'd string. * Result is a palloc'd string.
*/ */
char * char *
relpath(RelFileNode rnode) relpath(RelFileNode rnode)
{ {
int pathlen;
char *path; char *path;
if (rnode.tblNode == (Oid) 0) /* "global tablespace" */ if (rnode.spcNode == GLOBALTABLESPACE_OID)
{ {
/* Shared system relations live in {datadir}/global */ /* Shared system relations live in {datadir}/global */
path = (char *) palloc(strlen(DataDir) + 8 + sizeof(NameData) + 1); Assert(rnode.dbNode == 0);
sprintf(path, "%s/global/%u", DataDir, rnode.relNode); pathlen = strlen(DataDir) + 8 + OIDCHARS + 1;
path = (char *) palloc(pathlen);
snprintf(path, pathlen, "%s/global/%u",
DataDir, rnode.relNode);
}
else if (rnode.spcNode == DEFAULTTABLESPACE_OID)
{
/* The default tablespace is {datadir}/base */
pathlen = strlen(DataDir) + 6 + OIDCHARS + 1 + OIDCHARS + 1;
path = (char *) palloc(pathlen);
snprintf(path, pathlen, "%s/base/%u/%u",
DataDir, rnode.dbNode, rnode.relNode);
} }
else else
{ {
path = (char *) palloc(strlen(DataDir) + 6 + 2 * sizeof(NameData) + 3); /* All other tablespaces are accessed via symlinks */
sprintf(path, "%s/base/%u/%u", DataDir, rnode.tblNode, rnode.relNode); pathlen = strlen(DataDir) + 16 + OIDCHARS + 1 + OIDCHARS + 1 + OIDCHARS + 1;
path = (char *) palloc(pathlen);
snprintf(path, pathlen, "%s/pg_tablespaces/%u/%u/%u",
DataDir, rnode.spcNode, rnode.dbNode, rnode.relNode);
} }
return path; return path;
} }
...@@ -52,23 +70,39 @@ relpath(RelFileNode rnode) ...@@ -52,23 +70,39 @@ relpath(RelFileNode rnode)
* GetDatabasePath - construct path to a database dir * GetDatabasePath - construct path to a database dir
* *
* Result is a palloc'd string. * Result is a palloc'd string.
*
* XXX this must agree with relpath()!
*/ */
char * char *
GetDatabasePath(Oid tblNode) GetDatabasePath(Oid dbNode, Oid spcNode)
{ {
int pathlen;
char *path; char *path;
if (tblNode == (Oid) 0) /* "global tablespace" */ if (spcNode == GLOBALTABLESPACE_OID)
{ {
/* Shared system relations live in {datadir}/global */ /* Shared system relations live in {datadir}/global */
path = (char *) palloc(strlen(DataDir) + 8); Assert(dbNode == 0);
sprintf(path, "%s/global", DataDir); pathlen = strlen(DataDir) + 7 + 1;
path = (char *) palloc(pathlen);
snprintf(path, pathlen, "%s/global",
DataDir);
}
else if (spcNode == DEFAULTTABLESPACE_OID)
{
/* The default tablespace is {datadir}/base */
pathlen = strlen(DataDir) + 6 + OIDCHARS + 1;
path = (char *) palloc(pathlen);
snprintf(path, pathlen, "%s/base/%u",
DataDir, dbNode);
} }
else else
{ {
path = (char *) palloc(strlen(DataDir) + 6 + sizeof(NameData) + 1); /* All other tablespaces are accessed via symlinks */
sprintf(path, "%s/base/%u", DataDir, tblNode); pathlen = strlen(DataDir) + 16 + OIDCHARS + 1 + OIDCHARS + 1;
path = (char *) palloc(pathlen);
snprintf(path, pathlen, "%s/pg_tablespaces/%u/%u",
DataDir, spcNode, dbNode);
} }
return path; return path;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.270 2004/06/10 17:55:53 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.271 2004/06/18 06:13:19 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "catalog/pg_statistic.h" #include "catalog/pg_statistic.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "commands/tablecmds.h" #include "commands/tablecmds.h"
#include "commands/tablespace.h"
#include "commands/trigger.h" #include "commands/trigger.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "nodes/makefuncs.h" #include "nodes/makefuncs.h"
...@@ -203,15 +204,14 @@ SystemAttributeByName(const char *attname, bool relhasoids) ...@@ -203,15 +204,14 @@ SystemAttributeByName(const char *attname, bool relhasoids)
Relation Relation
heap_create(const char *relname, heap_create(const char *relname,
Oid relnamespace, Oid relnamespace,
Oid reltablespace,
TupleDesc tupDesc, TupleDesc tupDesc,
bool shared_relation, bool shared_relation,
bool storage_create, bool storage_create,
bool allow_system_table_mods) bool allow_system_table_mods)
{ {
Oid relid; Oid relid;
Oid dbid = shared_relation ? InvalidOid : MyDatabaseId;
bool nailme = false; bool nailme = false;
RelFileNode rnode;
Relation rel; Relation rel;
/* /*
...@@ -260,27 +260,23 @@ heap_create(const char *relname, ...@@ -260,27 +260,23 @@ heap_create(const char *relname,
relid = RelOid_pg_group; relid = RelOid_pg_group;
else if (strcmp(DatabaseRelationName, relname) == 0) else if (strcmp(DatabaseRelationName, relname) == 0)
relid = RelOid_pg_database; relid = RelOid_pg_database;
else if (strcmp(TableSpaceRelationName, relname) == 0)
relid = RelOid_pg_tablespace;
else else
relid = newoid(); relid = newoid();
} }
else else
relid = newoid(); relid = newoid();
/*
* For now, the physical identifier of the relation is the same as the
* logical identifier.
*/
rnode.tblNode = dbid;
rnode.relNode = relid;
/* /*
* build the relcache entry. * build the relcache entry.
*/ */
rel = RelationBuildLocalRelation(relname, rel = RelationBuildLocalRelation(relname,
relnamespace, relnamespace,
tupDesc, tupDesc,
relid, dbid, relid,
rnode, reltablespace,
shared_relation,
nailme); nailme);
/* /*
...@@ -296,6 +292,16 @@ heap_create(const char *relname, ...@@ -296,6 +292,16 @@ heap_create(const char *relname,
void void
heap_storage_create(Relation rel) heap_storage_create(Relation rel)
{ {
/*
* We may be using the target table space for the first time in this
* database, so create a per-database subdirectory if needed.
*
* XXX it might be better to do this right in smgrcreate...
*/
TablespaceCreateDbspace(rel->rd_node.spcNode, rel->rd_node.dbNode);
/*
* Now we can make the file.
*/
Assert(rel->rd_smgr == NULL); Assert(rel->rd_smgr == NULL);
rel->rd_smgr = smgropen(rel->rd_node); rel->rd_smgr = smgropen(rel->rd_node);
smgrcreate(rel->rd_smgr, rel->rd_istemp, false); smgrcreate(rel->rd_smgr, rel->rd_istemp, false);
...@@ -692,6 +698,7 @@ AddNewRelationType(const char *typeName, ...@@ -692,6 +698,7 @@ AddNewRelationType(const char *typeName,
Oid Oid
heap_create_with_catalog(const char *relname, heap_create_with_catalog(const char *relname,
Oid relnamespace, Oid relnamespace,
Oid reltablespace,
TupleDesc tupdesc, TupleDesc tupdesc,
char relkind, char relkind,
bool shared_relation, bool shared_relation,
...@@ -726,6 +733,7 @@ heap_create_with_catalog(const char *relname, ...@@ -726,6 +733,7 @@ heap_create_with_catalog(const char *relname,
*/ */
new_rel_desc = heap_create(relname, new_rel_desc = heap_create(relname,
relnamespace, relnamespace,
reltablespace,
tupdesc, tupdesc,
shared_relation, shared_relation,
(relkind != RELKIND_VIEW && (relkind != RELKIND_VIEW &&
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.233 2004/05/31 19:24:05 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.234 2004/06/18 06:13:19 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -467,6 +467,7 @@ index_create(Oid heapRelationId, ...@@ -467,6 +467,7 @@ index_create(Oid heapRelationId,
const char *indexRelationName, const char *indexRelationName,
IndexInfo *indexInfo, IndexInfo *indexInfo,
Oid accessMethodObjectId, Oid accessMethodObjectId,
Oid tableSpaceId,
Oid *classObjectId, Oid *classObjectId,
bool primary, bool primary,
bool isconstraint, bool isconstraint,
...@@ -539,6 +540,7 @@ index_create(Oid heapRelationId, ...@@ -539,6 +540,7 @@ index_create(Oid heapRelationId,
*/ */
indexRelation = heap_create(indexRelationName, indexRelation = heap_create(indexRelationName,
namespaceId, namespaceId,
tableSpaceId,
indexTupDesc, indexTupDesc,
shared_relation, shared_relation,
true, true,
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.66 2004/05/28 16:17:14 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.67 2004/06/18 06:13:19 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1668,7 +1668,7 @@ InitTempTableNamespace(void) ...@@ -1668,7 +1668,7 @@ InitTempTableNamespace(void)
* that access the temp namespace for my own backend skip * that access the temp namespace for my own backend skip
* permissions checks on it. * permissions checks on it.
*/ */
namespaceId = NamespaceCreate(namespaceName, BOOTSTRAP_USESYSID); namespaceId = NamespaceCreate(namespaceName, BOOTSTRAP_USESYSID, 0);
/* Advance command counter to make namespace visible */ /* Advance command counter to make namespace visible */
CommandCounterIncrement(); CommandCounterIncrement();
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/pg_namespace.c,v 1.8 2003/11/29 19:51:46 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/catalog/pg_namespace.c,v 1.9 2004/06/18 06:13:19 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* --------------- * ---------------
*/ */
Oid Oid
NamespaceCreate(const char *nspName, int32 ownerSysId) NamespaceCreate(const char *nspName, int32 ownerSysId, Oid nspTablespace)
{ {
Relation nspdesc; Relation nspdesc;
HeapTuple tup; HeapTuple tup;
...@@ -59,6 +59,7 @@ NamespaceCreate(const char *nspName, int32 ownerSysId) ...@@ -59,6 +59,7 @@ NamespaceCreate(const char *nspName, int32 ownerSysId)
namestrcpy(&nname, nspName); namestrcpy(&nname, nspName);
values[Anum_pg_namespace_nspname - 1] = NameGetDatum(&nname); values[Anum_pg_namespace_nspname - 1] = NameGetDatum(&nname);
values[Anum_pg_namespace_nspowner - 1] = Int32GetDatum(ownerSysId); values[Anum_pg_namespace_nspowner - 1] = Int32GetDatum(ownerSysId);
values[Anum_pg_namespace_nsptablespace - 1] = Int32GetDatum(nspTablespace);
nulls[Anum_pg_namespace_nspacl - 1] = 'n'; nulls[Anum_pg_namespace_nspacl - 1] = 'n';
nspdesc = heap_openr(NamespaceRelationName, RowExclusiveLock); nspdesc = heap_openr(NamespaceRelationName, RowExclusiveLock);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for backend/commands # Makefile for backend/commands
# #
# IDENTIFICATION # IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/commands/Makefile,v 1.33 2003/11/29 19:51:47 pgsql Exp $ # $PostgreSQL: pgsql/src/backend/commands/Makefile,v 1.34 2004/06/18 06:13:22 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -17,8 +17,8 @@ OBJS = aggregatecmds.o alter.o analyze.o async.o cluster.o comment.o \ ...@@ -17,8 +17,8 @@ OBJS = aggregatecmds.o alter.o analyze.o async.o cluster.o comment.o \
dbcommands.o define.o explain.o functioncmds.o \ dbcommands.o define.o explain.o functioncmds.o \
indexcmds.o lockcmds.o operatorcmds.o opclasscmds.o \ indexcmds.o lockcmds.o operatorcmds.o opclasscmds.o \
portalcmds.o prepare.o proclang.o \ portalcmds.o prepare.o proclang.o \
schemacmds.o sequence.o tablecmds.o trigger.o typecmds.o user.o \ schemacmds.o sequence.o tablecmds.o tablespace.o trigger.o \
vacuum.o vacuumlazy.o variable.o view.o typecmds.o user.o vacuum.o vacuumlazy.o variable.o view.o
all: SUBSYS.o all: SUBSYS.o
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.125 2004/05/31 19:24:05 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.126 2004/06/18 06:13:22 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -568,6 +568,7 @@ make_new_heap(Oid OIDOldHeap, const char *NewName) ...@@ -568,6 +568,7 @@ make_new_heap(Oid OIDOldHeap, const char *NewName)
OIDNewHeap = heap_create_with_catalog(NewName, OIDNewHeap = heap_create_with_catalog(NewName,
RelationGetNamespace(OldHeap), RelationGetNamespace(OldHeap),
OldHeap->rd_rel->reltablespace,
tupdesc, tupdesc,
OldHeap->rd_rel->relkind, OldHeap->rd_rel->relkind,
OldHeap->rd_rel->relisshared, OldHeap->rd_rel->relisshared,
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.121 2004/06/10 17:55:56 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.122 2004/06/18 06:13:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
#include "commands/defrem.h" #include "commands/defrem.h"
#include "commands/tablecmds.h" #include "commands/tablecmds.h"
#include "commands/tablespace.h"
#include "executor/executor.h" #include "executor/executor.h"
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#include "miscadmin.h" #include "miscadmin.h"
...@@ -64,6 +65,8 @@ static bool relationHasPrimaryKey(Relation rel); ...@@ -64,6 +65,8 @@ static bool relationHasPrimaryKey(Relation rel);
* 'indexRelationName': the name for the new index, or NULL to indicate * 'indexRelationName': the name for the new index, or NULL to indicate
* that a nonconflicting default name should be picked. * that a nonconflicting default name should be picked.
* 'accessMethodName': name of the AM to use. * 'accessMethodName': name of the AM to use.
* 'tableSpaceName': name of the tablespace to create the index in.
* NULL specifies using the same tablespace as the parent relation.
* 'attributeList': a list of IndexElem specifying columns and expressions * 'attributeList': a list of IndexElem specifying columns and expressions
* to index on. * to index on.
* 'predicate': the partial-index condition, or NULL if none. * 'predicate': the partial-index condition, or NULL if none.
...@@ -83,6 +86,7 @@ void ...@@ -83,6 +86,7 @@ void
DefineIndex(RangeVar *heapRelation, DefineIndex(RangeVar *heapRelation,
char *indexRelationName, char *indexRelationName,
char *accessMethodName, char *accessMethodName,
char *tableSpaceName,
List *attributeList, List *attributeList,
Expr *predicate, Expr *predicate,
List *rangetable, List *rangetable,
...@@ -98,6 +102,7 @@ DefineIndex(RangeVar *heapRelation, ...@@ -98,6 +102,7 @@ DefineIndex(RangeVar *heapRelation,
Oid accessMethodId; Oid accessMethodId;
Oid relationId; Oid relationId;
Oid namespaceId; Oid namespaceId;
Oid tablespaceId;
Relation rel; Relation rel;
HeapTuple tuple; HeapTuple tuple;
Form_pg_am accessMethodForm; Form_pg_am accessMethodForm;
...@@ -151,6 +156,29 @@ DefineIndex(RangeVar *heapRelation, ...@@ -151,6 +156,29 @@ DefineIndex(RangeVar *heapRelation,
get_namespace_name(namespaceId)); get_namespace_name(namespaceId));
} }
/* Determine tablespace to use */
if (tableSpaceName)
{
AclResult aclresult;
tablespaceId = get_tablespace_oid(tableSpaceName);
if (!OidIsValid(tablespaceId))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace \"%s\" does not exist",
tableSpaceName)));
/* check permissions */
aclresult = pg_tablespace_aclcheck(tablespaceId, GetUserId(),
ACL_CREATE);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, ACL_KIND_TABLESPACE,
tableSpaceName);
} else {
/* Use the parent rel's tablespace */
tablespaceId = get_rel_tablespace(relationId);
/* Note there is no additional permission check in this path */
}
/* /*
* Select name for index if caller didn't specify * Select name for index if caller didn't specify
*/ */
...@@ -335,7 +363,7 @@ DefineIndex(RangeVar *heapRelation, ...@@ -335,7 +363,7 @@ DefineIndex(RangeVar *heapRelation,
indexRelationName, RelationGetRelationName(rel)))); indexRelationName, RelationGetRelationName(rel))));
index_create(relationId, indexRelationName, index_create(relationId, indexRelationName,
indexInfo, accessMethodId, classObjectId, indexInfo, accessMethodId, tablespaceId, classObjectId,
primary, isconstraint, primary, isconstraint,
allowSystemTableMods, skip_build); allowSystemTableMods, skip_build);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.18 2004/05/26 04:41:11 neilc Exp $ * $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.19 2004/06/18 06:13:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "catalog/pg_namespace.h" #include "catalog/pg_namespace.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
#include "commands/schemacmds.h" #include "commands/schemacmds.h"
#include "commands/tablespace.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "parser/analyze.h" #include "parser/analyze.h"
#include "tcop/utility.h" #include "tcop/utility.h"
...@@ -41,6 +42,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt) ...@@ -41,6 +42,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
const char *schemaName = stmt->schemaname; const char *schemaName = stmt->schemaname;
const char *authId = stmt->authid; const char *authId = stmt->authid;
Oid namespaceId; Oid namespaceId;
Oid tablespaceId;
List *parsetree_list; List *parsetree_list;
ListCell *parsetree_item; ListCell *parsetree_item;
const char *owner_name; const char *owner_name;
...@@ -100,8 +102,33 @@ CreateSchemaCommand(CreateSchemaStmt *stmt) ...@@ -100,8 +102,33 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
errmsg("unacceptable schema name \"%s\"", schemaName), errmsg("unacceptable schema name \"%s\"", schemaName),
errdetail("The prefix \"pg_\" is reserved for system schemas."))); errdetail("The prefix \"pg_\" is reserved for system schemas.")));
/*
* Select default tablespace for schema. If not given, use zero
* which implies the database's default tablespace.
*/
if (stmt->tablespacename)
{
AclResult aclresult;
tablespaceId = get_tablespace_oid(stmt->tablespacename);
if (!OidIsValid(tablespaceId))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace \"%s\" does not exist",
stmt->tablespacename)));
/* check permissions */
aclresult = pg_tablespace_aclcheck(tablespaceId, GetUserId(),
ACL_CREATE);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, ACL_KIND_TABLESPACE,
stmt->tablespacename);
} else {
tablespaceId = InvalidOid;
/* note there is no permission check in this path */
}
/* Create the schema's namespace */ /* Create the schema's namespace */
namespaceId = NamespaceCreate(schemaName, owner_userid); namespaceId = NamespaceCreate(schemaName, owner_userid, tablespaceId);
/* Advance cmd counter to make the namespace visible */ /* Advance cmd counter to make the namespace visible */
CommandCounterIncrement(); CommandCounterIncrement();
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.111 2004/05/26 04:41:11 neilc Exp $ * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.112 2004/06/18 06:13:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -180,6 +180,7 @@ DefineSequence(CreateSeqStmt *seq) ...@@ -180,6 +180,7 @@ DefineSequence(CreateSeqStmt *seq)
stmt->constraints = NIL; stmt->constraints = NIL;
stmt->hasoids = MUST_NOT_HAVE_OIDS; stmt->hasoids = MUST_NOT_HAVE_OIDS;
stmt->oncommit = ONCOMMIT_NOOP; stmt->oncommit = ONCOMMIT_NOOP;
stmt->tablespacename = seq->tablespacename;
seqoid = DefineRelation(stmt, RELKIND_SEQUENCE); seqoid = DefineRelation(stmt, RELKIND_SEQUENCE);
...@@ -1071,8 +1072,8 @@ seq_redo(XLogRecPtr lsn, XLogRecord *record) ...@@ -1071,8 +1072,8 @@ seq_redo(XLogRecPtr lsn, XLogRecord *record)
buffer = XLogReadBuffer(true, reln, 0); buffer = XLogReadBuffer(true, reln, 0);
if (!BufferIsValid(buffer)) if (!BufferIsValid(buffer))
elog(PANIC, "seq_redo: can't read block of %u/%u", elog(PANIC, "seq_redo: can't read block 0 of rel %u/%u/%u",
xlrec->node.tblNode, xlrec->node.relNode); xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode);
page = (Page) BufferGetPage(buffer); page = (Page) BufferGetPage(buffer);
...@@ -1114,6 +1115,6 @@ seq_desc(char *buf, uint8 xl_info, char *rec) ...@@ -1114,6 +1115,6 @@ seq_desc(char *buf, uint8 xl_info, char *rec)
return; return;
} }
sprintf(buf + strlen(buf), "node %u/%u", sprintf(buf + strlen(buf), "rel %u/%u/%u",
xlrec->node.tblNode, xlrec->node.relNode); xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode);
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.115 2004/06/10 18:34:45 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.116 2004/06/18 06:13:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "commands/cluster.h" #include "commands/cluster.h"
#include "commands/defrem.h" #include "commands/defrem.h"
#include "commands/tablecmds.h" #include "commands/tablecmds.h"
#include "commands/tablespace.h"
#include "commands/trigger.h" #include "commands/trigger.h"
#include "executor/executor.h" #include "executor/executor.h"
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
...@@ -258,6 +259,7 @@ DefineRelation(CreateStmt *stmt, char relkind) ...@@ -258,6 +259,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
Oid namespaceId; Oid namespaceId;
List *schema = stmt->tableElts; List *schema = stmt->tableElts;
Oid relationId; Oid relationId;
Oid tablespaceId;
Relation rel; Relation rel;
TupleDesc descriptor; TupleDesc descriptor;
List *inheritOids; List *inheritOids;
...@@ -301,6 +303,31 @@ DefineRelation(CreateStmt *stmt, char relkind) ...@@ -301,6 +303,31 @@ DefineRelation(CreateStmt *stmt, char relkind)
get_namespace_name(namespaceId)); get_namespace_name(namespaceId));
} }
/*
* Select tablespace to use. If not specified, use containing schema's
* default tablespace (which may in turn default to database's default).
*/
if (stmt->tablespacename)
{
AclResult aclresult;
tablespaceId = get_tablespace_oid(stmt->tablespacename);
if (!OidIsValid(tablespaceId))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace \"%s\" does not exist",
stmt->tablespacename)));
/* check permissions */
aclresult = pg_tablespace_aclcheck(tablespaceId, GetUserId(),
ACL_CREATE);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, ACL_KIND_TABLESPACE,
stmt->tablespacename);
} else {
tablespaceId = get_namespace_tablespace(namespaceId);
/* note no permission check on tablespace in this case */
}
/* /*
* Look up inheritance ancestors and generate relation schema, * Look up inheritance ancestors and generate relation schema,
* including inherited attributes. * including inherited attributes.
...@@ -379,6 +406,7 @@ DefineRelation(CreateStmt *stmt, char relkind) ...@@ -379,6 +406,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
relationId = heap_create_with_catalog(relname, relationId = heap_create_with_catalog(relname,
namespaceId, namespaceId,
tablespaceId,
descriptor, descriptor,
relkind, relkind,
false, false,
...@@ -1770,7 +1798,7 @@ ATController(Relation rel, List *cmds, bool recurse) ...@@ -1770,7 +1798,7 @@ ATController(Relation rel, List *cmds, bool recurse)
/* /*
* ATPrepCmd * ATPrepCmd
* *
* Traffic cop for ALTER TABLE Phase 1 operations, including simple * Traffic cop for ALTER TABLE Phase 1 operations, including simple
* recursion and permission checks. * recursion and permission checks.
* *
* Caller must have acquired AccessExclusiveLock on relation already. * Caller must have acquired AccessExclusiveLock on relation already.
...@@ -2679,7 +2707,7 @@ find_composite_type_dependencies(Oid typeOid, const char *origTblName) ...@@ -2679,7 +2707,7 @@ find_composite_type_dependencies(Oid typeOid, const char *origTblName)
} }
/* /*
* ALTER TABLE ADD COLUMN * ALTER TABLE ADD COLUMN
* *
* Adds an additional attribute to a relation making the assumption that * Adds an additional attribute to a relation making the assumption that
...@@ -3521,6 +3549,7 @@ ATExecAddIndex(AlteredTableInfo *tab, Relation rel, ...@@ -3521,6 +3549,7 @@ ATExecAddIndex(AlteredTableInfo *tab, Relation rel,
DefineIndex(stmt->relation, /* relation */ DefineIndex(stmt->relation, /* relation */
stmt->idxname, /* index name */ stmt->idxname, /* index name */
stmt->accessMethod, /* am name */ stmt->accessMethod, /* am name */
stmt->tableSpace,
stmt->indexParams, /* parameters */ stmt->indexParams, /* parameters */
(Expr *) stmt->whereClause, (Expr *) stmt->whereClause,
stmt->rangetable, stmt->rangetable,
...@@ -3566,7 +3595,7 @@ ATExecAddConstraint(AlteredTableInfo *tab, Relation rel, Node *newConstraint) ...@@ -3566,7 +3595,7 @@ ATExecAddConstraint(AlteredTableInfo *tab, Relation rel, Node *newConstraint)
list_make1(constr)); list_make1(constr));
/* Add each constraint to Phase 3's queue */ /* Add each constraint to Phase 3's queue */
foreach(lcon, newcons) foreach(lcon, newcons)
{ {
CookedConstraint *ccon = (CookedConstraint *) lfirst(lcon); CookedConstraint *ccon = (CookedConstraint *) lfirst(lcon);
NewConstraint *newcon; NewConstraint *newcon;
...@@ -3643,7 +3672,7 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, ...@@ -3643,7 +3672,7 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
int16 fkattnum[INDEX_MAX_KEYS]; int16 fkattnum[INDEX_MAX_KEYS];
Oid pktypoid[INDEX_MAX_KEYS]; Oid pktypoid[INDEX_MAX_KEYS];
Oid fktypoid[INDEX_MAX_KEYS]; Oid fktypoid[INDEX_MAX_KEYS];
Oid opclasses[INDEX_MAX_KEYS]; Oid opclasses[INDEX_MAX_KEYS];
int i; int i;
int numfks, int numfks,
numpks; numpks;
...@@ -3791,7 +3820,7 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, ...@@ -3791,7 +3820,7 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
* will be incurred to check FK validity. * will be incurred to check FK validity.
*/ */
if (!op_in_opclass(oprid(o), opclasses[i])) if (!op_in_opclass(oprid(o), opclasses[i]))
ereport(WARNING, ereport(WARNING,
(errmsg("foreign key constraint \"%s\" " (errmsg("foreign key constraint \"%s\" "
"will require costly sequential scans", "will require costly sequential scans",
fkconstraint->constr_name), fkconstraint->constr_name),
...@@ -4565,7 +4594,7 @@ ATPrepAlterColumnType(List **wqueue, ...@@ -4565,7 +4594,7 @@ ATPrepAlterColumnType(List **wqueue,
/* /*
* Add a work queue item to make ATRewriteTable update the column * Add a work queue item to make ATRewriteTable update the column
* contents. * contents.
*/ */
newval = (NewColumnValue *) palloc0(sizeof(NewColumnValue)); newval = (NewColumnValue *) palloc0(sizeof(NewColumnValue));
newval->attnum = attnum; newval->attnum = attnum;
newval->expr = (Expr *) transform; newval->expr = (Expr *) transform;
...@@ -5272,6 +5301,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent) ...@@ -5272,6 +5301,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
*/ */
toast_relid = heap_create_with_catalog(toast_relname, toast_relid = heap_create_with_catalog(toast_relname,
PG_TOAST_NAMESPACE, PG_TOAST_NAMESPACE,
rel->rd_rel->reltablespace,
tupdesc, tupdesc,
RELKIND_TOASTVALUE, RELKIND_TOASTVALUE,
shared_relation, shared_relation,
...@@ -5309,7 +5339,9 @@ AlterTableCreateToastTable(Oid relOid, bool silent) ...@@ -5309,7 +5339,9 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
classObjectId[1] = INT4_BTREE_OPS_OID; classObjectId[1] = INT4_BTREE_OPS_OID;
toast_idxid = index_create(toast_relid, toast_idxname, indexInfo, toast_idxid = index_create(toast_relid, toast_idxname, indexInfo,
BTREE_AM_OID, classObjectId, BTREE_AM_OID,
rel->rd_rel->reltablespace,
classObjectId,
true, false, true, false); true, false, true, false);
/* /*
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.59 2004/06/10 17:55:56 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.60 2004/06/18 06:13:23 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
...@@ -1110,8 +1110,8 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist) ...@@ -1110,8 +1110,8 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist)
errmsg("composite type must have at least one attribute"))); errmsg("composite type must have at least one attribute")));
/* /*
* now create the parameters for keys/inheritance etc. All of them are * now set the parameters for keys/inheritance etc. All of these
* nil... * are uninteresting for composite types...
*/ */
createStmt->relation = (RangeVar *) typevar; createStmt->relation = (RangeVar *) typevar;
createStmt->tableElts = coldeflist; createStmt->tableElts = coldeflist;
...@@ -1119,6 +1119,7 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist) ...@@ -1119,6 +1119,7 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist)
createStmt->constraints = NIL; createStmt->constraints = NIL;
createStmt->hasoids = MUST_NOT_HAVE_OIDS; createStmt->hasoids = MUST_NOT_HAVE_OIDS;
createStmt->oncommit = ONCOMMIT_NOOP; createStmt->oncommit = ONCOMMIT_NOOP;
createStmt->tablespacename = NULL;
/* /*
* finally create the relation... * finally create the relation...
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.82 2004/05/26 04:41:13 neilc Exp $ * $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.83 2004/06/18 06:13:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -134,8 +134,8 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace) ...@@ -134,8 +134,8 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace)
else else
{ {
/* /*
* now create the parameters for keys/inheritance etc. All of them * now set the parameters for keys/inheritance etc. All of these
* are nil... * are uninteresting for views...
*/ */
createStmt->relation = (RangeVar *) relation; createStmt->relation = (RangeVar *) relation;
createStmt->tableElts = attrList; createStmt->tableElts = attrList;
...@@ -143,6 +143,7 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace) ...@@ -143,6 +143,7 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace)
createStmt->constraints = NIL; createStmt->constraints = NIL;
createStmt->hasoids = MUST_NOT_HAVE_OIDS; createStmt->hasoids = MUST_NOT_HAVE_OIDS;
createStmt->oncommit = ONCOMMIT_NOOP; createStmt->oncommit = ONCOMMIT_NOOP;
createStmt->tablespacename = NULL;
/* /*
* finally create the relation (this will error out if there's an * finally create the relation (this will error out if there's an
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.233 2004/05/30 23:40:26 neilc Exp $ * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.234 2004/06/18 06:13:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -779,6 +779,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) ...@@ -779,6 +779,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
intoRelationId = heap_create_with_catalog(intoName, intoRelationId = heap_create_with_catalog(intoName,
namespaceId, namespaceId,
InvalidOid,
tupdesc, tupdesc,
RELKIND_RELATION, RELKIND_RELATION,
false, false,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.285 2004/06/09 19:08:15 tgl Exp $ * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.286 2004/06/18 06:13:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1753,6 +1753,7 @@ _copyCreateStmt(CreateStmt *from) ...@@ -1753,6 +1753,7 @@ _copyCreateStmt(CreateStmt *from)
COPY_NODE_FIELD(constraints); COPY_NODE_FIELD(constraints);
COPY_SCALAR_FIELD(hasoids); COPY_SCALAR_FIELD(hasoids);
COPY_SCALAR_FIELD(oncommit); COPY_SCALAR_FIELD(oncommit);
COPY_STRING_FIELD(tablespacename);
return newnode; return newnode;
} }
...@@ -1836,6 +1837,7 @@ _copyIndexStmt(IndexStmt *from) ...@@ -1836,6 +1837,7 @@ _copyIndexStmt(IndexStmt *from)
COPY_STRING_FIELD(idxname); COPY_STRING_FIELD(idxname);
COPY_NODE_FIELD(relation); COPY_NODE_FIELD(relation);
COPY_STRING_FIELD(accessMethod); COPY_STRING_FIELD(accessMethod);
COPY_STRING_FIELD(tableSpace);
COPY_NODE_FIELD(indexParams); COPY_NODE_FIELD(indexParams);
COPY_NODE_FIELD(whereClause); COPY_NODE_FIELD(whereClause);
COPY_NODE_FIELD(rangetable); COPY_NODE_FIELD(rangetable);
...@@ -2146,6 +2148,7 @@ _copyCreateSeqStmt(CreateSeqStmt *from) ...@@ -2146,6 +2148,7 @@ _copyCreateSeqStmt(CreateSeqStmt *from)
COPY_NODE_FIELD(sequence); COPY_NODE_FIELD(sequence);
COPY_NODE_FIELD(options); COPY_NODE_FIELD(options);
COPY_STRING_FIELD(tablespacename);
return newnode; return newnode;
} }
...@@ -2193,6 +2196,28 @@ _copyVariableResetStmt(VariableResetStmt *from) ...@@ -2193,6 +2196,28 @@ _copyVariableResetStmt(VariableResetStmt *from)
return newnode; return newnode;
} }
static CreateTableSpaceStmt *
_copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
{
CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
COPY_STRING_FIELD(tablespacename);
COPY_STRING_FIELD(owner);
COPY_STRING_FIELD(location);
return newnode;
}
static DropTableSpaceStmt *
_copyDropTableSpaceStmt(DropTableSpaceStmt *from)
{
DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
COPY_STRING_FIELD(tablespacename);
return newnode;
}
static CreateTrigStmt * static CreateTrigStmt *
_copyCreateTrigStmt(CreateTrigStmt *from) _copyCreateTrigStmt(CreateTrigStmt *from)
{ {
...@@ -2371,6 +2396,7 @@ _copyCreateSchemaStmt(CreateSchemaStmt *from) ...@@ -2371,6 +2396,7 @@ _copyCreateSchemaStmt(CreateSchemaStmt *from)
COPY_STRING_FIELD(schemaname); COPY_STRING_FIELD(schemaname);
COPY_STRING_FIELD(authid); COPY_STRING_FIELD(authid);
COPY_STRING_FIELD(tablespacename);
COPY_NODE_FIELD(schemaElts); COPY_NODE_FIELD(schemaElts);
return newnode; return newnode;
...@@ -2914,6 +2940,12 @@ copyObject(void *from) ...@@ -2914,6 +2940,12 @@ copyObject(void *from)
case T_VariableResetStmt: case T_VariableResetStmt:
retval = _copyVariableResetStmt(from); retval = _copyVariableResetStmt(from);
break; break;
case T_CreateTableSpaceStmt:
retval = _copyCreateTableSpaceStmt(from);
break;
case T_DropTableSpaceStmt:
retval = _copyDropTableSpaceStmt(from);
break;
case T_CreateTrigStmt: case T_CreateTrigStmt:
retval = _copyCreateTrigStmt(from); retval = _copyCreateTrigStmt(from);
break; break;
......
This diff is collapsed.
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.305 2004/06/10 17:55:58 tgl Exp $ * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.306 2004/06/18 06:13:31 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -874,6 +874,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, ...@@ -874,6 +874,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
seqstmt = makeNode(CreateSeqStmt); seqstmt = makeNode(CreateSeqStmt);
seqstmt->sequence = makeRangeVar(snamespace, sname); seqstmt->sequence = makeRangeVar(snamespace, sname);
seqstmt->options = NIL; seqstmt->options = NIL;
seqstmt->tablespacename = NULL;
cxt->blist = lappend(cxt->blist, seqstmt); cxt->blist = lappend(cxt->blist, seqstmt);
...@@ -1199,6 +1200,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) ...@@ -1199,6 +1200,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
index->relation = cxt->relation; index->relation = cxt->relation;
index->accessMethod = DEFAULT_INDEX_TYPE; index->accessMethod = DEFAULT_INDEX_TYPE;
index->tableSpace = NULL;
index->indexParams = NIL; index->indexParams = NIL;
index->whereClause = NULL; index->whereClause = NULL;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment