Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf0efe26

Browse files
committed
Support USING INDEX TABLESPACE clause for PRIMARY KEY and UNIQUE
constraints. Christopher Kings-Lynne.
1 parentf622c54 commitf0efe26

File tree

11 files changed

+196
-34
lines changed

11 files changed

+196
-34
lines changed

‎doc/src/sgml/ref/create_table.sgml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.83 2004/07/12 01:22:53 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.84 2004/08/02 04:25:31 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -33,7 +33,10 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable class="PAR
3333
where <replaceable class="PARAMETER">column_constraint</replaceable> is:
3434

3535
[ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
36-
{ NOT NULL | NULL | UNIQUE | PRIMARY KEY |
36+
{ NOT NULL |
37+
NULL |
38+
UNIQUE [ USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ] |
39+
PRIMARY KEY [ USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ] |
3740
CHECK (<replaceable class="PARAMETER">expression</replaceable>) |
3841
REFERENCES <replaceable class="PARAMETER">reftable</replaceable> [ ( <replaceable class="PARAMETER">refcolumn</replaceable> ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
3942
[ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
@@ -42,8 +45,8 @@ where <replaceable class="PARAMETER">column_constraint</replaceable> is:
4245
and <replaceable class="PARAMETER">table_constraint</replaceable> is:
4346

4447
[ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
45-
{ UNIQUE ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] ) |
46-
PRIMARY KEY ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] ) |
48+
{ UNIQUE ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] )[ USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ]|
49+
PRIMARY KEY ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] )[ USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ]|
4750
CHECK ( <replaceable class="PARAMETER">expression</replaceable> ) |
4851
FOREIGN KEY ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] ) REFERENCES <replaceable class="PARAMETER">reftable</replaceable> [ ( <replaceable class="PARAMETER">refcolumn</replaceable> [, ... ] ) ]
4952
[ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
@@ -604,6 +607,18 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
604607
</listitem>
605608
</varlistentry>
606609

610+
<varlistentry>
611+
<term><literal>USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable></literal></term>
612+
<listitem>
613+
<para>
614+
This clause allows selection of the tablespace in which the index
615+
associated with a <literal>UNIQUE</literal> or <literal>PRIMARY
616+
KEY</literal> constraint will be created. If not supplied, the index
617+
will be created in the same tablespace as the table.
618+
</para>
619+
</listitem>
620+
</varlistentry>
621+
607622
</variablelist>
608623
</refsect1>
609624

@@ -950,7 +965,7 @@ CREATE TABLE cinemas (
950965
</refsect2>
951966

952967
<refsect2>
953-
<title>TABLESPACE</title>
968+
<title>TABLESPACE and USING INDEX TABLESPACE</title>
954969

955970
<para>
956971
The <productname>PostgreSQL</productname> concept of tablespaces is not

‎doc/src/sgml/ref/create_tablespace.sgml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_tablespace.sgml,v 1.2 2004/06/25 21:55:50 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_tablespace.sgml,v 1.3 2004/08/02 04:25:37 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -43,7 +43,7 @@ CREATE TABLESPACE <replaceable class="parameter">tablespacename</replaceable> [
4343
A user with appropriate privileges can pass
4444
<replaceable class="parameter">tablespacename</> to <command>CREATE
4545
DATABASE</>, <command>CREATE SCHEMA</>, <command>CREATE TABLE</>,
46-
<command>CREATE INDEX</> or <command>CREATE SEQUENCE</> to have the data
46+
<command>CREATE INDEX</> or <command>ADD CONSTRAINT</> to have the data
4747
files for these objects stored within the specified tablespace.
4848
</para>
4949
</refsect1>
@@ -133,7 +133,6 @@ CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';
133133
<member><xref linkend="sql-createschema" endterm="sql-createschema-title"></member>
134134
<member><xref linkend="sql-createtable" endterm="sql-createtable-title"></member>
135135
<member><xref linkend="sql-createindex" endterm="sql-createindex-title"></member>
136-
<member><xref linkend="sql-createsequence" endterm="sql-createsequence-title"></member>
137136
<member><xref linkend="sql-droptablespace" endterm="sql-droptablespace-title"></member>
138137
<member><xref linkend="sql-altertablespace" endterm="sql-altertablespace-title"></member>
139138
</simplelist>

‎src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.288 2004/07/12 05:37:21 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.289 2004/08/02 04:26:05 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1485,6 +1485,7 @@ _copyConstraint(Constraint *from)
14851485
COPY_NODE_FIELD(raw_expr);
14861486
COPY_STRING_FIELD(cooked_expr);
14871487
COPY_NODE_FIELD(keys);
1488+
COPY_STRING_FIELD(indexspace);
14881489

14891490
returnnewnode;
14901491
}

‎src/backend/nodes/equalfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Portions Copyright (c) 1994, Regents of the University of California
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.227 2004/07/12 05:37:24 tgl Exp $
21+
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.228 2004/08/02 04:26:05 tgl Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -1611,6 +1611,7 @@ _equalConstraint(Constraint *a, Constraint *b)
16111611
COMPARE_NODE_FIELD(raw_expr);
16121612
COMPARE_STRING_FIELD(cooked_expr);
16131613
COMPARE_NODE_FIELD(keys);
1614+
COMPARE_STRING_FIELD(indexspace);
16141615

16151616
return true;
16161617
}

‎src/backend/nodes/outfuncs.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.240 2004/06/18 06:13:28 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.241 2004/08/02 04:26:05 tgl Exp $
1212
*
1313
* NOTES
1414
* Every node type that can appear in stored rules' parsetrees *must*
@@ -1537,6 +1537,13 @@ _outConstraint(StringInfo str, Constraint *node)
15371537
caseCONSTR_PRIMARY:
15381538
appendStringInfo(str,"PRIMARY_KEY");
15391539
WRITE_NODE_FIELD(keys);
1540+
WRITE_STRING_FIELD(indexspace);
1541+
break;
1542+
1543+
caseCONSTR_UNIQUE:
1544+
appendStringInfo(str,"UNIQUE");
1545+
WRITE_NODE_FIELD(keys);
1546+
WRITE_STRING_FIELD(indexspace);
15401547
break;
15411548

15421549
caseCONSTR_CHECK:
@@ -1555,11 +1562,6 @@ _outConstraint(StringInfo str, Constraint *node)
15551562
appendStringInfo(str,"NOT_NULL");
15561563
break;
15571564

1558-
caseCONSTR_UNIQUE:
1559-
appendStringInfo(str,"UNIQUE");
1560-
WRITE_NODE_FIELD(keys);
1561-
break;
1562-
15631565
default:
15641566
appendStringInfo(str,"<unrecognized_constraint>");
15651567
break;

‎src/backend/parser/analyze.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.307 2004/07/12 05:37:44 tgl Exp $
9+
*$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.308 2004/08/02 04:26:29 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -1199,7 +1199,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
11991199

12001200
index->relation=cxt->relation;
12011201
index->accessMethod=DEFAULT_INDEX_TYPE;
1202-
index->tableSpace=NULL;
1202+
index->tableSpace=constraint->indexspace;
12031203
index->indexParams=NIL;
12041204
index->whereClause=NULL;
12051205

‎src/backend/parser/gram.y

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.468 2004/07/27 05:10:55 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.469 2004/08/02 04:26:35 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -320,7 +320,7 @@ static void doNegateFloat(Value *v);
320320

321321
%type<list>constraints_set_list
322322
%type<boolean>constraints_set_mode
323-
%type<str>OptTableSpaceOptTableSpaceOwner
323+
%type<str>OptTableSpaceOptConsTableSpaceOptTableSpaceOwner
324324

325325

326326
/*
@@ -1609,6 +1609,7 @@ ColConstraintElem:
16091609
n->raw_expr =NULL;
16101610
n->cooked_expr =NULL;
16111611
n->keys =NULL;
1612+
n->indexspace =NULL;
16121613
$$ = (Node *)n;
16131614
}
16141615
|NULL_P
@@ -1619,26 +1620,29 @@ ColConstraintElem:
16191620
n->raw_expr =NULL;
16201621
n->cooked_expr =NULL;
16211622
n->keys =NULL;
1623+
n->indexspace =NULL;
16221624
$$ = (Node *)n;
16231625
}
1624-
|UNIQUE
1626+
|UNIQUEOptConsTableSpace
16251627
{
16261628
Constraint *n = makeNode(Constraint);
16271629
n->contype = CONSTR_UNIQUE;
16281630
n->name =NULL;
16291631
n->raw_expr =NULL;
16301632
n->cooked_expr =NULL;
16311633
n->keys =NULL;
1634+
n->indexspace =$2;
16321635
$$ = (Node *)n;
16331636
}
1634-
|PRIMARYKEY
1637+
|PRIMARYKEYOptConsTableSpace
16351638
{
16361639
Constraint *n = makeNode(Constraint);
16371640
n->contype = CONSTR_PRIMARY;
16381641
n->name =NULL;
16391642
n->raw_expr =NULL;
16401643
n->cooked_expr =NULL;
16411644
n->keys =NULL;
1645+
n->indexspace =$3;
16421646
$$ = (Node *)n;
16431647
}
16441648
|CHECK'('a_expr')'
@@ -1649,6 +1653,7 @@ ColConstraintElem:
16491653
n->raw_expr =$3;
16501654
n->cooked_expr =NULL;
16511655
n->keys =NULL;
1656+
n->indexspace =NULL;
16521657
$$ = (Node *)n;
16531658
}
16541659
|DEFAULTb_expr
@@ -1667,6 +1672,7 @@ ColConstraintElem:
16671672
}
16681673
n->cooked_expr =NULL;
16691674
n->keys =NULL;
1675+
n->indexspace =NULL;
16701676
$$ = (Node *)n;
16711677
}
16721678
|REFERENCESqualified_nameopt_column_listkey_matchkey_actions
@@ -1787,26 +1793,29 @@ ConstraintElem:
17871793
n->name =NULL;
17881794
n->raw_expr =$3;
17891795
n->cooked_expr =NULL;
1796+
n->indexspace =NULL;
17901797
$$ = (Node *)n;
17911798
}
1792-
|UNIQUE'('columnList')'
1799+
|UNIQUE'('columnList')'OptConsTableSpace
17931800
{
17941801
Constraint *n = makeNode(Constraint);
17951802
n->contype = CONSTR_UNIQUE;
17961803
n->name =NULL;
17971804
n->raw_expr =NULL;
17981805
n->cooked_expr =NULL;
17991806
n->keys =$3;
1807+
n->indexspace =$5;
18001808
$$ = (Node *)n;
18011809
}
1802-
|PRIMARYKEY'('columnList')'
1810+
|PRIMARYKEY'('columnList')'OptConsTableSpace
18031811
{
18041812
Constraint *n = makeNode(Constraint);
18051813
n->contype = CONSTR_PRIMARY;
18061814
n->name =NULL;
18071815
n->raw_expr =NULL;
18081816
n->cooked_expr =NULL;
18091817
n->keys =$4;
1818+
n->indexspace =$6;
18101819
$$ = (Node *)n;
18111820
}
18121821
|FOREIGNKEY'('columnList')'REFERENCESqualified_name
@@ -1916,6 +1925,10 @@ OptTableSpace: TABLESPACE name{ $$ = $2; }
19161925
|/*EMPTY*/{$$ =NULL; }
19171926
;
19181927

1928+
OptConsTableSpace:USINGINDEXTABLESPACEname{$$ =$4; }
1929+
|/*EMPTY*/{$$ =NULL; }
1930+
;
1931+
19191932

19201933
/*
19211934
* Note: CREATE TABLE ... AS SELECT ... is just another spelling for

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp