mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Create 'default_tablespace' GUC variable that supplies a TABLESPACE
clause implicitly whenever one is not given explicitly. Remove concept of a schema having an associated tablespace, and simplify the rules for selecting a default tablespace for a table or index. It's now just (a) explicit TABLESPACE clause; (b) default_tablespace if that's not an empty string; (c) database's default. This will allow pg_dump to use SET commands instead of tablespace clauses to determine object locations (but I didn't actually make it do so). All per recent discussions.
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
-- create a tablespace we can use
|
||||
CREATE TABLESPACE testspace LOCATION '@testtablespace@';
|
||||
|
||||
-- create a schema in the tablespace
|
||||
CREATE SCHEMA testschema TABLESPACE testspace;
|
||||
|
||||
-- sanity check
|
||||
SELECT nspname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_namespace n
|
||||
where n.nsptablespace = t.oid and n.nspname = 'testschema';
|
||||
-- create a schema we can use
|
||||
CREATE SCHEMA testschema;
|
||||
|
||||
-- try a table
|
||||
CREATE TABLE testschema.foo (i int);
|
||||
CREATE TABLE testschema.foo (i int) 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';
|
||||
|
||||
@@ -17,7 +13,7 @@ INSERT INTO testschema.foo VALUES(1);
|
||||
INSERT INTO testschema.foo VALUES(2);
|
||||
|
||||
-- index
|
||||
CREATE INDEX foo_idx on testschema.foo(i);
|
||||
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';
|
||||
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
-- create a tablespace we can use
|
||||
CREATE TABLESPACE testspace LOCATION '@testtablespace@';
|
||||
-- create a schema in the tablespace
|
||||
CREATE SCHEMA testschema TABLESPACE testspace;
|
||||
-- sanity check
|
||||
SELECT nspname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_namespace n
|
||||
where n.nsptablespace = t.oid and n.nspname = 'testschema';
|
||||
nspname | spcname
|
||||
------------+-----------
|
||||
testschema | testspace
|
||||
(1 row)
|
||||
|
||||
-- create a schema we can use
|
||||
CREATE SCHEMA testschema;
|
||||
-- try a table
|
||||
CREATE TABLE testschema.foo (i int);
|
||||
CREATE TABLE testschema.foo (i int) 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';
|
||||
relname | spcname
|
||||
@@ -22,7 +14,7 @@ SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
|
||||
INSERT INTO testschema.foo VALUES(1);
|
||||
INSERT INTO testschema.foo VALUES(2);
|
||||
-- index
|
||||
CREATE INDEX foo_idx on testschema.foo(i);
|
||||
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';
|
||||
relname | spcname
|
||||
|
||||
Reference in New Issue
Block a user