diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/input/tablespace.source | 31 | ||||
| -rw-r--r-- | src/test/regress/output/tablespace.source | 105 |
2 files changed, 136 insertions, 0 deletions
diff --git a/src/test/regress/input/tablespace.source b/src/test/regress/input/tablespace.source index dba96f4547f..ecc47124a5d 100644 --- a/src/test/regress/input/tablespace.source +++ b/src/test/regress/input/tablespace.source @@ -34,6 +34,37 @@ CREATE INDEX foo_idx on testschema.foo(i) TABLESPACE testspace; SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c where c.reltablespace = t.oid AND c.relname = 'foo_idx'; +-- check that default_tablespace doesn't affect ALTER TABLE index rebuilds +CREATE TABLE testschema.test_default_tab(id bigint) TABLESPACE testspace; +INSERT INTO testschema.test_default_tab VALUES (1); +CREATE INDEX test_index1 on testschema.test_default_tab (id); +CREATE INDEX test_index2 on testschema.test_default_tab (id) TABLESPACE testspace; +\d testschema.test_index1 +\d testschema.test_index2 +-- use a custom tablespace for default_tablespace +SET default_tablespace TO testspace; +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE bigint; +\d testschema.test_index1 +\d testschema.test_index2 +SELECT * FROM testschema.test_default_tab; +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE int; +\d testschema.test_index1 +\d testschema.test_index2 +SELECT * FROM testschema.test_default_tab; +-- now use the default tablespace for default_tablespace +SET default_tablespace TO ''; +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE int; +\d testschema.test_index1 +\d testschema.test_index2 +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE bigint; +\d testschema.test_index1 +\d testschema.test_index2 +DROP TABLE testschema.test_default_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 1260c968880..7b63ad872a4 100644 --- a/src/test/regress/output/tablespace.source +++ b/src/test/regress/output/tablespace.source @@ -48,6 +48,111 @@ SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c foo_idx | testspace (1 row) +-- check that default_tablespace doesn't affect ALTER TABLE index rebuilds +CREATE TABLE testschema.test_default_tab(id bigint) TABLESPACE testspace; +INSERT INTO testschema.test_default_tab VALUES (1); +CREATE INDEX test_index1 on testschema.test_default_tab (id); +CREATE INDEX test_index2 on testschema.test_default_tab (id) TABLESPACE testspace; +\d testschema.test_index1 +Index "testschema.test_index1" + Column | Type | Definition +--------+--------+------------ + id | bigint | id +btree, for table "testschema.test_default_tab" + +\d testschema.test_index2 +Index "testschema.test_index2" + Column | Type | Definition +--------+--------+------------ + id | bigint | id +btree, for table "testschema.test_default_tab" +Tablespace: "testspace" + +-- use a custom tablespace for default_tablespace +SET default_tablespace TO testspace; +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE bigint; +\d testschema.test_index1 +Index "testschema.test_index1" + Column | Type | Definition +--------+--------+------------ + id | bigint | id +btree, for table "testschema.test_default_tab" + +\d testschema.test_index2 +Index "testschema.test_index2" + Column | Type | Definition +--------+--------+------------ + id | bigint | id +btree, for table "testschema.test_default_tab" +Tablespace: "testspace" + +SELECT * FROM testschema.test_default_tab; + id +---- + 1 +(1 row) + +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE int; +\d testschema.test_index1 +Index "testschema.test_index1" + Column | Type | Definition +--------+---------+------------ + id | integer | id +btree, for table "testschema.test_default_tab" + +\d testschema.test_index2 +Index "testschema.test_index2" + Column | Type | Definition +--------+---------+------------ + id | integer | id +btree, for table "testschema.test_default_tab" +Tablespace: "testspace" + +SELECT * FROM testschema.test_default_tab; + id +---- + 1 +(1 row) + +-- now use the default tablespace for default_tablespace +SET default_tablespace TO ''; +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE int; +\d testschema.test_index1 +Index "testschema.test_index1" + Column | Type | Definition +--------+---------+------------ + id | integer | id +btree, for table "testschema.test_default_tab" + +\d testschema.test_index2 +Index "testschema.test_index2" + Column | Type | Definition +--------+---------+------------ + id | integer | id +btree, for table "testschema.test_default_tab" +Tablespace: "testspace" + +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE bigint; +\d testschema.test_index1 +Index "testschema.test_index1" + Column | Type | Definition +--------+--------+------------ + id | bigint | id +btree, for table "testschema.test_default_tab" + +\d testschema.test_index2 +Index "testschema.test_index2" + Column | Type | Definition +--------+--------+------------ + id | bigint | id +btree, for table "testschema.test_default_tab" +Tablespace: "testspace" + +DROP TABLE testschema.test_default_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); |
