aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-11-24 14:13:19 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2016-11-24 14:13:31 -0500
commit4cc6a3f1106034187be3a371e61a02915bb93c11 (patch)
treecfd909846d91f71a87839458e8996ed386dd6385
parent4aaddf2f009821e29aea3735e44332ad9ca47aaa (diff)
downloadpostgresql-4cc6a3f1106034187be3a371e61a02915bb93c11.tar.gz
postgresql-4cc6a3f1106034187be3a371e61a02915bb93c11.zip
Check that default_tablespace affects ALTER TABLE ADD UNIQUE/PRIMARY KEY.
Seems like a good thing to test, considering that we nearly broke it yesterday. Michael Paquier
-rw-r--r--src/test/regress/input/tablespace.source12
-rw-r--r--src/test/regress/output/tablespace.source29
2 files changed, 41 insertions, 0 deletions
diff --git a/src/test/regress/input/tablespace.source b/src/test/regress/input/tablespace.source
index 2e676e9cc74..743c4b982c1 100644
--- a/src/test/regress/input/tablespace.source
+++ b/src/test/regress/input/tablespace.source
@@ -75,6 +75,18 @@ ALTER TABLE testschema.test_default_tab ALTER id TYPE bigint;
\d testschema.test_index2
DROP TABLE testschema.test_default_tab;
+-- check that default_tablespace affects index additions in ALTER TABLE
+CREATE TABLE testschema.test_tab(id int) TABLESPACE regress_tblspace;
+INSERT INTO testschema.test_tab VALUES (1);
+SET default_tablespace TO regress_tblspace;
+ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_unique UNIQUE (id);
+SET default_tablespace TO '';
+ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_pkey PRIMARY KEY (id);
+\d testschema.test_tab_unique
+\d testschema.test_tab_pkey
+SELECT * FROM testschema.test_tab;
+DROP TABLE testschema.test_tab;
+
-- let's try moving a table from one place to another
CREATE TABLE testschema.atable AS VALUES (1), (2);
CREATE UNIQUE INDEX anindex ON testschema.atable(column1);
diff --git a/src/test/regress/output/tablespace.source b/src/test/regress/output/tablespace.source
index 6e0dfd187bd..31f2ac0ebdc 100644
--- a/src/test/regress/output/tablespace.source
+++ b/src/test/regress/output/tablespace.source
@@ -166,6 +166,35 @@ btree, for table "testschema.test_default_tab"
Tablespace: "regress_tblspace"
DROP TABLE testschema.test_default_tab;
+-- check that default_tablespace affects index additions in ALTER TABLE
+CREATE TABLE testschema.test_tab(id int) TABLESPACE regress_tblspace;
+INSERT INTO testschema.test_tab VALUES (1);
+SET default_tablespace TO regress_tblspace;
+ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_unique UNIQUE (id);
+SET default_tablespace TO '';
+ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_pkey PRIMARY KEY (id);
+\d testschema.test_tab_unique
+Index "testschema.test_tab_unique"
+ Column | Type | Definition
+--------+---------+------------
+ id | integer | id
+unique, btree, for table "testschema.test_tab"
+Tablespace: "regress_tblspace"
+
+\d testschema.test_tab_pkey
+Index "testschema.test_tab_pkey"
+ Column | Type | Definition
+--------+---------+------------
+ id | integer | id
+primary key, btree, for table "testschema.test_tab"
+
+SELECT * FROM testschema.test_tab;
+ id
+----
+ 1
+(1 row)
+
+DROP TABLE testschema.test_tab;
-- let's try moving a table from one place to another
CREATE TABLE testschema.atable AS VALUES (1), (2);
CREATE UNIQUE INDEX anindex ON testschema.atable(column1);