1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-10 14:22:35 +03:00

Add CREATE TRIGGER, CREATE INDEX, and CREATE SEQUENCE to the list of

expressions supported by CREATE SCHEMA.

Also added the beginning of some regression tests for CREATE SCHEMA;
plenty more work is needed here.
This commit is contained in:
Neil Conway
2004-01-11 04:58:17 +00:00
parent 4cdf51e646
commit e97b8f2da9
7 changed files with 155 additions and 31 deletions

View File

@@ -0,0 +1,52 @@
--
-- Regression tests for schemas (namespaces)
--
CREATE SCHEMA test_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
);
NOTICE: CREATE TABLE will create implicit sequence "abc_a_seq" for "serial" column "abc.a"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "abc_b_key" for table "abc"
-- verify that the objects were created
SELECT COUNT(*) FROM pg_class WHERE relnamespace =
(SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
count
-------
5
(1 row)
INSERT INTO test_schema_1.abc DEFAULT VALUES;
INSERT INTO test_schema_1.abc DEFAULT VALUES;
INSERT INTO test_schema_1.abc DEFAULT VALUES;
SELECT * FROM test_schema_1.abc;
a | b
---+---
1 |
2 |
3 |
(3 rows)
SELECT * FROM test_schema_1.abc_view;
a | b
---+---
2 |
3 |
4 |
(3 rows)
DROP SCHEMA test_schema_1 CASCADE;
NOTICE: drop cascades to view test_schema_1.abc_view
NOTICE: drop cascades to rule _RETURN on view test_schema_1.abc_view
NOTICE: drop cascades to table test_schema_1.abc
-- verify that the objects were dropped
SELECT COUNT(*) FROM pg_class WHERE relnamespace =
(SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
count
-------
0
(1 row)

View File

@@ -60,7 +60,7 @@ ignore: random
# ----------
# The fourth group of parallel test
# ----------
test: select_into select_distinct select_distinct_on select_implicit select_having subselect union case join aggregates transactions random portals arrays btree_index hash_index update
test: select_into select_distinct select_distinct_on select_implicit select_having subselect union case join aggregates transactions random portals arrays btree_index hash_index update namespace
test: privileges
test: misc

View File

@@ -1,4 +1,4 @@
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.23 2003/11/29 19:52:14 pgsql Exp $
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.24 2004/01/11 04:58:17 neilc Exp $
# This should probably be in an order similar to parallel_schedule.
test: boolean
test: char
@@ -73,6 +73,7 @@ test: arrays
test: btree_index
test: hash_index
test: update
test: namespace
test: privileges
test: misc
test: select_views

View File

@@ -0,0 +1,31 @@
--
-- Regression tests for schemas (namespaces)
--
CREATE SCHEMA test_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_schema_1');
INSERT INTO test_schema_1.abc DEFAULT VALUES;
INSERT INTO test_schema_1.abc DEFAULT VALUES;
INSERT INTO test_schema_1.abc DEFAULT VALUES;
SELECT * FROM test_schema_1.abc;
SELECT * FROM test_schema_1.abc_view;
DROP SCHEMA test_schema_1 CASCADE;
-- verify that the objects were dropped
SELECT COUNT(*) FROM pg_class WHERE relnamespace =
(SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');