]> granicus.if.org Git - postgresql/commitdiff
Check that default_tablespace affects ALTER TABLE ADD UNIQUE/PRIMARY KEY.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 24 Nov 2016 19:13:19 +0000 (14:13 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 24 Nov 2016 19:13:31 +0000 (14:13 -0500)
Seems like a good thing to test, considering that we nearly broke it
yesterday.

Michael Paquier

src/test/regress/input/tablespace.source
src/test/regress/output/tablespace.source

index 2e676e9cc74ec8c006e0ec1bde2a8f3f549e0760..743c4b982c1507e54b51cfb7c4d11dcca9b73af6 100644 (file)
@@ -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);
index 6e0dfd187bda92386c203491ca10df8bce99ba49..31f2ac0ebdc9dfe9a90447ff6dcaab79b04e8b7d 100644 (file)
@@ -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);