Commit a5f7d581 authored by Peter Eisentraut's avatar Peter Eisentraut

Add tests for sequence privileges

parent 69fed5b2
......@@ -367,6 +367,41 @@ DROP SEQUENCE seq2;
SELECT lastval();
ERROR: lastval is not yet defined in this session
CREATE USER seq_user;
-- privileges tests
-- nextval
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
REVOKE ALL ON seq3 FROM seq_user;
GRANT SELECT ON seq3 TO seq_user;
SELECT nextval('seq3');
ERROR: permission denied for sequence seq3
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
REVOKE ALL ON seq3 FROM seq_user;
GRANT UPDATE ON seq3 TO seq_user;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
REVOKE ALL ON seq3 FROM seq_user;
GRANT USAGE ON seq3 TO seq_user;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
ROLLBACK;
-- currval
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
......@@ -377,8 +412,96 @@ SELECT nextval('seq3');
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT SELECT ON seq3 TO seq_user;
SELECT currval('seq3');
currval
---------
1
(1 row)
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT UPDATE ON seq3 TO seq_user;
SELECT currval('seq3');
ERROR: permission denied for sequence seq3
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT USAGE ON seq3 TO seq_user;
SELECT currval('seq3');
currval
---------
1
(1 row)
ROLLBACK;
-- lastval
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT SELECT ON seq3 TO seq_user;
SELECT lastval();
lastval
---------
1
(1 row)
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT UPDATE ON seq3 TO seq_user;
SELECT lastval();
ERROR: permission denied for sequence seq3
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT USAGE ON seq3 TO seq_user;
SELECT lastval();
lastval
---------
1
(1 row)
ROLLBACK;
-- Sequences should get wiped out as well:
DROP TABLE serialTest, serialTest2;
......
......@@ -367,6 +367,41 @@ DROP SEQUENCE seq2;
SELECT lastval();
ERROR: lastval is not yet defined in this session
CREATE USER seq_user;
-- privileges tests
-- nextval
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
REVOKE ALL ON seq3 FROM seq_user;
GRANT SELECT ON seq3 TO seq_user;
SELECT nextval('seq3');
ERROR: permission denied for sequence seq3
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
REVOKE ALL ON seq3 FROM seq_user;
GRANT UPDATE ON seq3 TO seq_user;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
REVOKE ALL ON seq3 FROM seq_user;
GRANT USAGE ON seq3 TO seq_user;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
ROLLBACK;
-- currval
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
......@@ -377,8 +412,96 @@ SELECT nextval('seq3');
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT SELECT ON seq3 TO seq_user;
SELECT currval('seq3');
currval
---------
1
(1 row)
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT UPDATE ON seq3 TO seq_user;
SELECT currval('seq3');
ERROR: permission denied for sequence seq3
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT USAGE ON seq3 TO seq_user;
SELECT currval('seq3');
currval
---------
1
(1 row)
ROLLBACK;
-- lastval
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT SELECT ON seq3 TO seq_user;
SELECT lastval();
lastval
---------
1
(1 row)
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT UPDATE ON seq3 TO seq_user;
SELECT lastval();
ERROR: permission denied for sequence seq3
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
nextval
---------
1
(1 row)
REVOKE ALL ON seq3 FROM seq_user;
GRANT USAGE ON seq3 TO seq_user;
SELECT lastval();
lastval
---------
1
(1 row)
ROLLBACK;
-- Sequences should get wiped out as well:
DROP TABLE serialTest, serialTest2;
......
......@@ -168,11 +168,86 @@ SELECT lastval();
CREATE USER seq_user;
-- privileges tests
-- nextval
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
REVOKE ALL ON seq3 FROM seq_user;
GRANT SELECT ON seq3 TO seq_user;
SELECT nextval('seq3');
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
REVOKE ALL ON seq3 FROM seq_user;
GRANT UPDATE ON seq3 TO seq_user;
SELECT nextval('seq3');
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
REVOKE ALL ON seq3 FROM seq_user;
GRANT USAGE ON seq3 TO seq_user;
SELECT nextval('seq3');
ROLLBACK;
-- currval
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
REVOKE ALL ON seq3 FROM seq_user;
GRANT SELECT ON seq3 TO seq_user;
SELECT currval('seq3');
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
REVOKE ALL ON seq3 FROM seq_user;
GRANT UPDATE ON seq3 TO seq_user;
SELECT currval('seq3');
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
REVOKE ALL ON seq3 FROM seq_user;
GRANT USAGE ON seq3 TO seq_user;
SELECT currval('seq3');
ROLLBACK;
-- lastval
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
REVOKE ALL ON seq3 FROM seq_user;
GRANT SELECT ON seq3 TO seq_user;
SELECT lastval();
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
REVOKE ALL ON seq3 FROM seq_user;
GRANT UPDATE ON seq3 TO seq_user;
SELECT lastval();
ROLLBACK;
BEGIN;
SET LOCAL SESSION AUTHORIZATION seq_user;
CREATE SEQUENCE seq3;
SELECT nextval('seq3');
REVOKE ALL ON seq3 FROM seq_user;
GRANT USAGE ON seq3 TO seq_user;
SELECT lastval();
ROLLBACK;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment