1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-12 02:37:31 +03:00

Tablespaces. Alternate database locations are dead, long live tablespaces.

There are various things left to do: contrib dbsize and oid2name modules
need work, and so does the documentation.  Also someone should think about
COMMENT ON TABLESPACE and maybe RENAME TABLESPACE.  Also initlocation is
dead, it just doesn't know it yet.

Gavin Sherry and Tom Lane.
This commit is contained in:
Tom Lane
2004-06-18 06:14:31 +00:00
parent 474875f443
commit 2467394ee1
94 changed files with 3765 additions and 1588 deletions

View File

@@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.46 2004/03/03 04:22:47 momjian Exp $
# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.47 2004/06/18 06:14:25 tgl Exp $
#
#-------------------------------------------------------------------------
@@ -67,7 +67,7 @@ all: $(DLOBJS)
# Build test input and expected files
file_list := copy create_function_1 create_function_2 misc constraints
file_list := copy create_function_1 create_function_2 misc constraints tablespace
input_files := $(foreach file, $(file_list), sql/$(file).sql)
output_files := $(foreach file, $(file_list), expected/$(file).out)
@@ -81,10 +81,13 @@ abs_srcdir := $(shell cd $(srcdir) && pwd -W)
abs_builddir := $(shell pwd -W)
endif
testtablespace := $(abs_builddir)/testtablespace
define sed-command
sed -e 's,@abs_srcdir@,$(abs_srcdir),g' \
-e 's,@abs_builddir@,$(abs_builddir),g' \
-e 's,@testtablespace@,$(testtablespace),g' \
-e 's/@DLSUFFIX@/$(DLSUFFIX)/g' $< >$@
endef
@@ -125,9 +128,13 @@ all-spi:
##
check: all
-rm -rf ./testtablespace
mkdir ./testtablespace
$(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) $(MAXCONNOPT)
installcheck: all
-rm -rf ./testtablespace
mkdir ./testtablespace
$(SHELL) ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE)
@@ -152,6 +159,7 @@ clean distclean maintainer-clean:
$(MAKE) -C $(contribdir)/spi clean
rm -f $(output_files) $(input_files) $(DLOBJS) regress.o pg_regress
# things created by various check targets
rm -rf testtablespace
rm -rf results tmp_check log
rm -f regression.diffs regression.out regress.out run_check.out
ifeq ($(PORTNAME), cygwin)

View File

@@ -56,13 +56,14 @@ SELECT relname, relhasindex
pg_rewrite | t
pg_shadow | t
pg_statistic | t
pg_tablespace | t
pg_trigger | t
pg_type | t
road | t
shighway | t
tenk1 | t
tenk2 | t
(52 rows)
(53 rows)
--
-- another sanity check: every system catalog that has OIDs should have

View File

@@ -0,0 +1,36 @@
-- 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';
-- try a table
CREATE TABLE testschema.foo (i int);
SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
where c.reltablespace = t.oid AND c.relname = 'foo';
INSERT INTO testschema.foo VALUES(1);
INSERT INTO testschema.foo VALUES(2);
-- index
CREATE INDEX foo_idx on testschema.foo(i);
SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
where c.reltablespace = t.oid AND c.relname = 'foo_idx';
-- Will fail with bad path
CREATE TABLESPACE badspace LOCATION '/no/such/location';
-- No such tablespace
CREATE TABLE bar (i int) TABLESPACE nosuchspace;
-- Fail, not empty
DROP TABLESPACE testspace;
DROP SCHEMA testschema CASCADE;
-- Should succeed
DROP TABLESPACE testspace;

View File

@@ -0,0 +1,45 @@
-- 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)
-- try a table
CREATE TABLE testschema.foo (i int);
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
---------+-----------
foo | testspace
(1 row)
INSERT INTO testschema.foo VALUES(1);
INSERT INTO testschema.foo VALUES(2);
-- index
CREATE INDEX foo_idx on testschema.foo(i);
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
---------+-----------
foo_idx | testspace
(1 row)
-- Will fail with bad path
CREATE TABLESPACE badspace LOCATION '/no/such/location';
ERROR: could not set permissions on directory "/no/such/location": No such file or directory
-- No such tablespace
CREATE TABLE bar (i int) TABLESPACE nosuchspace;
ERROR: tablespace "nosuchspace" does not exist
-- Fail, not empty
DROP TABLESPACE testspace;
ERROR: tablespace "testspace" is not empty
DROP SCHEMA testschema CASCADE;
NOTICE: drop cascades to table testschema.foo
-- Should succeed
DROP TABLESPACE testspace;

View File

@@ -16,7 +16,7 @@ test: point lseg box path polygon circle date time timetz timestamp timestamptz
# Depends on point, lseg, box, path, polygon and circle
test: geometry
# Depends on interval, timetz, timestamp, timestamptz, reltime and abstime
test: horology
test: horology
# ----------
# These four each depend on the previous one
@@ -78,3 +78,6 @@ test: limit plpgsql copy2 temp domain rangefuncs prepare without_oid conversion
# run stats by itself because its delay may be insufficient under heavy load
test: stats
# run tablespace by itself
test: tablespace

View File

@@ -1,4 +1,4 @@
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.25 2004/06/06 21:20:46 tgl Exp $
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.26 2004/06/18 06:14:25 tgl Exp $
# This should probably be in an order similar to parallel_schedule.
test: boolean
test: char
@@ -96,3 +96,4 @@ test: sequence
test: polymorphism
test: rowtypes
test: stats
test: tablespace