Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
cf589c9c
Commit
cf589c9c
authored
Dec 11, 2013
by
Simon Riggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Regression tests for SCHEMA commands
Hari Babu Kommi reviewed by David Rowley
parent
b921a26f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
14 deletions
+81
-14
src/test/regress/expected/namespace.out
src/test/regress/expected/namespace.out
+17
-9
src/test/regress/expected/privileges.out
src/test/regress/expected/privileges.out
+28
-0
src/test/regress/sql/namespace.sql
src/test/regress/sql/namespace.sql
+9
-5
src/test/regress/sql/privileges.sql
src/test/regress/sql/privileges.sql
+27
-0
No files found.
src/test/regress/expected/namespace.out
View file @
cf589c9c
...
...
@@ -36,12 +36,20 @@ SELECT * FROM test_schema_1.abc_view;
4 |
(3 rows)
ALTER SCHEMA test_schema_1 RENAME TO test_schema_renamed;
SELECT COUNT(*) FROM pg_class WHERE relnamespace =
(SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
count
-------
0
(1 row)
-- test IF NOT EXISTS cases
CREATE SCHEMA test_schema_
1
; -- fail, already exists
ERROR: schema "test_schema_
1
" already exists
CREATE SCHEMA IF NOT EXISTS test_schema_
1
; -- ok with notice
NOTICE: schema "test_schema_
1
" already exists, skipping
CREATE SCHEMA IF NOT EXISTS test_schema_
1
-- fail, disallowed
CREATE SCHEMA test_schema_
renamed
; -- fail, already exists
ERROR: schema "test_schema_
renamed
" already exists
CREATE SCHEMA IF NOT EXISTS test_schema_
renamed
; -- ok with notice
NOTICE: schema "test_schema_
renamed
" already exists, skipping
CREATE SCHEMA IF NOT EXISTS test_schema_
renamed
-- fail, disallowed
CREATE TABLE abc (
a serial,
b int UNIQUE
...
...
@@ -49,13 +57,13 @@ CREATE SCHEMA IF NOT EXISTS test_schema_1 -- fail, disallowed
ERROR: CREATE SCHEMA IF NOT EXISTS cannot include schema elements
LINE 2: CREATE TABLE abc (
^
DROP SCHEMA test_schema_
1
CASCADE;
DROP SCHEMA test_schema_
renamed
CASCADE;
NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to table test_schema_
1
.abc
drop cascades to view test_schema_
1
.abc_view
DETAIL: drop cascades to table test_schema_
renamed
.abc
drop cascades to view test_schema_
renamed
.abc_view
-- verify that the objects were dropped
SELECT COUNT(*) FROM pg_class WHERE relnamespace =
(SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_
1
');
(SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_
renamed
');
count
-------
0
...
...
src/test/regress/expected/privileges.out
View file @
cf589c9c
...
...
@@ -1350,6 +1350,34 @@ SELECT has_function_privilege('regressuser1', 'testns.testfunc(int)', 'EXECUTE')
SET client_min_messages TO 'warning';
DROP SCHEMA testns CASCADE;
RESET client_min_messages;
-- Change owner of the schema & and rename of new schema owner
\c -
CREATE ROLE schemauser1 superuser login;
CREATE ROLE schemauser2 superuser login;
SET SESSION ROLE schemauser1;
CREATE SCHEMA testns;
SELECT nspname, rolname FROM pg_namespace, pg_roles WHERE pg_namespace.nspname = 'testns' AND pg_namespace.nspowner = pg_roles.oid;
nspname | rolname
---------+-------------
testns | schemauser1
(1 row)
ALTER SCHEMA testns OWNER TO schemauser2;
ALTER ROLE schemauser2 RENAME TO schemauser_renamed;
SELECT nspname, rolname FROM pg_namespace, pg_roles WHERE pg_namespace.nspname = 'testns' AND pg_namespace.nspowner = pg_roles.oid;
nspname | rolname
---------+--------------------
testns | schemauser_renamed
(1 row)
set session role schemauser_renamed;
SET client_min_messages TO 'warning';
DROP SCHEMA testns CASCADE;
RESET client_min_messages;
-- clean up
\c -
DROP ROLE schemauser1;
DROP ROLE schemauser_renamed;
-- test that dependent privileges are revoked (or not) properly
\c -
set session role regressuser1;
...
...
src/test/regress/sql/namespace.sql
View file @
cf589c9c
...
...
@@ -24,17 +24,21 @@ INSERT INTO test_schema_1.abc DEFAULT VALUES;
SELECT
*
FROM
test_schema_1
.
abc
;
SELECT
*
FROM
test_schema_1
.
abc_view
;
ALTER
SCHEMA
test_schema_1
RENAME
TO
test_schema_renamed
;
SELECT
COUNT
(
*
)
FROM
pg_class
WHERE
relnamespace
=
(
SELECT
oid
FROM
pg_namespace
WHERE
nspname
=
'test_schema_1'
);
-- test IF NOT EXISTS cases
CREATE
SCHEMA
test_schema_
1
;
-- fail, already exists
CREATE
SCHEMA
IF
NOT
EXISTS
test_schema_
1
;
-- ok with notice
CREATE
SCHEMA
IF
NOT
EXISTS
test_schema_
1
-- fail, disallowed
CREATE
SCHEMA
test_schema_
renamed
;
-- fail, already exists
CREATE
SCHEMA
IF
NOT
EXISTS
test_schema_
renamed
;
-- ok with notice
CREATE
SCHEMA
IF
NOT
EXISTS
test_schema_
renamed
-- fail, disallowed
CREATE
TABLE
abc
(
a
serial
,
b
int
UNIQUE
);
DROP
SCHEMA
test_schema_
1
CASCADE
;
DROP
SCHEMA
test_schema_
renamed
CASCADE
;
-- verify that the objects were dropped
SELECT
COUNT
(
*
)
FROM
pg_class
WHERE
relnamespace
=
(
SELECT
oid
FROM
pg_namespace
WHERE
nspname
=
'test_schema_
1
'
);
(
SELECT
oid
FROM
pg_namespace
WHERE
nspname
=
'test_schema_
renamed
'
);
src/test/regress/sql/privileges.sql
View file @
cf589c9c
...
...
@@ -813,6 +813,33 @@ DROP SCHEMA testns CASCADE;
RESET
client_min_messages
;
-- Change owner of the schema & and rename of new schema owner
\
c
-
CREATE
ROLE
schemauser1
superuser
login
;
CREATE
ROLE
schemauser2
superuser
login
;
SET
SESSION
ROLE
schemauser1
;
CREATE
SCHEMA
testns
;
SELECT
nspname
,
rolname
FROM
pg_namespace
,
pg_roles
WHERE
pg_namespace
.
nspname
=
'testns'
AND
pg_namespace
.
nspowner
=
pg_roles
.
oid
;
ALTER
SCHEMA
testns
OWNER
TO
schemauser2
;
ALTER
ROLE
schemauser2
RENAME
TO
schemauser_renamed
;
SELECT
nspname
,
rolname
FROM
pg_namespace
,
pg_roles
WHERE
pg_namespace
.
nspname
=
'testns'
AND
pg_namespace
.
nspowner
=
pg_roles
.
oid
;
set
session
role
schemauser_renamed
;
SET
client_min_messages
TO
'warning'
;
DROP
SCHEMA
testns
CASCADE
;
RESET
client_min_messages
;
-- clean up
\
c
-
DROP
ROLE
schemauser1
;
DROP
ROLE
schemauser_renamed
;
-- test that dependent privileges are revoked (or not) properly
\
c
-
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment