From 46651ce6fe013220ed397add242004d764fc0153 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:15:05 +0200 Subject: Adding upstream version 14.5. Signed-off-by: Daniel Baumann --- src/test/regress/sql/namespace.sql | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test/regress/sql/namespace.sql (limited to 'src/test/regress/sql/namespace.sql') diff --git a/src/test/regress/sql/namespace.sql b/src/test/regress/sql/namespace.sql new file mode 100644 index 0000000..6b12c96 --- /dev/null +++ b/src/test/regress/sql/namespace.sql @@ -0,0 +1,44 @@ +-- +-- Regression tests for schemas (namespaces) +-- + +CREATE SCHEMA test_ns_schema_1 + CREATE UNIQUE INDEX abc_a_idx ON abc (a) + + CREATE VIEW abc_view AS + SELECT a+1 AS a, b+1 AS b FROM abc + + CREATE TABLE abc ( + a serial, + b int UNIQUE + ); + +-- verify that the objects were created +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_1'); + +INSERT INTO test_ns_schema_1.abc DEFAULT VALUES; +INSERT INTO test_ns_schema_1.abc DEFAULT VALUES; +INSERT INTO test_ns_schema_1.abc DEFAULT VALUES; + +SELECT * FROM test_ns_schema_1.abc; +SELECT * FROM test_ns_schema_1.abc_view; + +ALTER SCHEMA test_ns_schema_1 RENAME TO test_ns_schema_renamed; +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_1'); + +-- test IF NOT EXISTS cases +CREATE SCHEMA test_ns_schema_renamed; -- fail, already exists +CREATE SCHEMA IF NOT EXISTS test_ns_schema_renamed; -- ok with notice +CREATE SCHEMA IF NOT EXISTS test_ns_schema_renamed -- fail, disallowed + CREATE TABLE abc ( + a serial, + b int UNIQUE + ); + +DROP SCHEMA test_ns_schema_renamed CASCADE; + +-- verify that the objects were dropped +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_renamed'); -- cgit v1.2.3