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
ac33c7e2
Commit
ac33c7e2
authored
Jul 15, 2013
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Regression tests for LOCK TABLE.
Robins Tharakan, reviewed by Szymon Guz, substantially revised by me.
parent
67ccbb08
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
1 deletion
+130
-1
src/test/regress/expected/lock.out
src/test/regress/expected/lock.out
+62
-0
src/test/regress/parallel_schedule
src/test/regress/parallel_schedule
+1
-1
src/test/regress/serial_schedule
src/test/regress/serial_schedule
+1
-0
src/test/regress/sql/lock.sql
src/test/regress/sql/lock.sql
+66
-0
No files found.
src/test/regress/expected/lock.out
0 → 100644
View file @
ac33c7e2
--
-- Test the LOCK statement
--
-- Setup
CREATE SCHEMA lock_schema1;
SET search_path = lock_schema1;
CREATE TABLE lock_tbl1 (a BIGINT);
CREATE VIEW lock_view1 AS SELECT 1;
CREATE ROLE regress_rol_lock1;
ALTER ROLE regress_rol_lock1 SET search_path = lock_schema1;
GRANT USAGE ON SCHEMA lock_schema1 TO regress_rol_lock1;
-- Try all valid lock options; also try omitting the optional TABLE keyword.
BEGIN TRANSACTION;
LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE;
LOCK lock_tbl1 IN ROW SHARE MODE;
LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE;
LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE;
LOCK TABLE lock_tbl1 IN SHARE MODE;
LOCK lock_tbl1 IN SHARE ROW EXCLUSIVE MODE;
LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE;
LOCK TABLE lock_tbl1 IN ACCESS EXCLUSIVE MODE;
ROLLBACK;
-- Try using NOWAIT along with valid options.
BEGIN TRANSACTION;
LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN ROW SHARE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN SHARE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN SHARE ROW EXCLUSIVE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN ACCESS EXCLUSIVE MODE NOWAIT;
LOCK TABLE lock_view1 IN EXCLUSIVE MODE; -- Will fail; can't lock a non-table
ERROR: "lock_view1" is not a table
ROLLBACK;
-- Verify that we can lock a table with inheritance children.
CREATE TABLE lock_tbl2 (b BIGINT) INHERITS (lock_tbl1);
CREATE TABLE lock_tbl3 () INHERITS (lock_tbl2);
BEGIN TRANSACTION;
LOCK TABLE lock_tbl1 * IN ACCESS EXCLUSIVE MODE;
ROLLBACK;
-- Verify that we can't lock a child table just because we have permission
-- on the parent, but that we can lock the parent only.
GRANT UPDATE ON TABLE lock_tbl1 TO regress_rol_lock1;
SET ROLE regress_rol_lock1;
BEGIN;
LOCK TABLE lock_tbl1 * IN ACCESS EXCLUSIVE MODE;
ERROR: permission denied for relation lock_tbl2
ROLLBACK;
BEGIN;
LOCK TABLE ONLY lock_tbl1;
ROLLBACK;
RESET ROLE;
--
-- Clean up
--
DROP VIEW lock_view1;
DROP TABLE lock_tbl3;
DROP TABLE lock_tbl2;
DROP TABLE lock_tbl1;
DROP SCHEMA lock_schema1 CASCADE;
DROP ROLE regress_rol_lock1;
src/test/regress/parallel_schedule
View file @
ac33c7e2
...
...
@@ -83,7 +83,7 @@ test: select_into select_distinct select_distinct_on select_implicit select_havi
# ----------
# Another group of parallel tests
# ----------
test: privileges security_label collate matview
test: privileges security_label collate matview
lock
# ----------
# Another group of parallel tests
...
...
src/test/regress/serial_schedule
View file @
ac33c7e2
...
...
@@ -96,6 +96,7 @@ test: privileges
test: security_label
test: collate
test: matview
test: lock
test: alter_generic
test: misc
test: psql
...
...
src/test/regress/sql/lock.sql
0 → 100644
View file @
ac33c7e2
--
-- Test the LOCK statement
--
-- Setup
CREATE
SCHEMA
lock_schema1
;
SET
search_path
=
lock_schema1
;
CREATE
TABLE
lock_tbl1
(
a
BIGINT
);
CREATE
VIEW
lock_view1
AS
SELECT
1
;
CREATE
ROLE
regress_rol_lock1
;
ALTER
ROLE
regress_rol_lock1
SET
search_path
=
lock_schema1
;
GRANT
USAGE
ON
SCHEMA
lock_schema1
TO
regress_rol_lock1
;
-- Try all valid lock options; also try omitting the optional TABLE keyword.
BEGIN
TRANSACTION
;
LOCK
TABLE
lock_tbl1
IN
ACCESS
SHARE
MODE
;
LOCK
lock_tbl1
IN
ROW
SHARE
MODE
;
LOCK
TABLE
lock_tbl1
IN
ROW
EXCLUSIVE
MODE
;
LOCK
TABLE
lock_tbl1
IN
SHARE
UPDATE
EXCLUSIVE
MODE
;
LOCK
TABLE
lock_tbl1
IN
SHARE
MODE
;
LOCK
lock_tbl1
IN
SHARE
ROW
EXCLUSIVE
MODE
;
LOCK
TABLE
lock_tbl1
IN
EXCLUSIVE
MODE
;
LOCK
TABLE
lock_tbl1
IN
ACCESS
EXCLUSIVE
MODE
;
ROLLBACK
;
-- Try using NOWAIT along with valid options.
BEGIN
TRANSACTION
;
LOCK
TABLE
lock_tbl1
IN
ACCESS
SHARE
MODE
NOWAIT
;
LOCK
TABLE
lock_tbl1
IN
ROW
SHARE
MODE
NOWAIT
;
LOCK
TABLE
lock_tbl1
IN
ROW
EXCLUSIVE
MODE
NOWAIT
;
LOCK
TABLE
lock_tbl1
IN
SHARE
UPDATE
EXCLUSIVE
MODE
NOWAIT
;
LOCK
TABLE
lock_tbl1
IN
SHARE
MODE
NOWAIT
;
LOCK
TABLE
lock_tbl1
IN
SHARE
ROW
EXCLUSIVE
MODE
NOWAIT
;
LOCK
TABLE
lock_tbl1
IN
EXCLUSIVE
MODE
NOWAIT
;
LOCK
TABLE
lock_tbl1
IN
ACCESS
EXCLUSIVE
MODE
NOWAIT
;
LOCK
TABLE
lock_view1
IN
EXCLUSIVE
MODE
;
-- Will fail; can't lock a non-table
ROLLBACK
;
-- Verify that we can lock a table with inheritance children.
CREATE
TABLE
lock_tbl2
(
b
BIGINT
)
INHERITS
(
lock_tbl1
);
CREATE
TABLE
lock_tbl3
()
INHERITS
(
lock_tbl2
);
BEGIN
TRANSACTION
;
LOCK
TABLE
lock_tbl1
*
IN
ACCESS
EXCLUSIVE
MODE
;
ROLLBACK
;
-- Verify that we can't lock a child table just because we have permission
-- on the parent, but that we can lock the parent only.
GRANT
UPDATE
ON
TABLE
lock_tbl1
TO
regress_rol_lock1
;
SET
ROLE
regress_rol_lock1
;
BEGIN
;
LOCK
TABLE
lock_tbl1
*
IN
ACCESS
EXCLUSIVE
MODE
;
ROLLBACK
;
BEGIN
;
LOCK
TABLE
ONLY
lock_tbl1
;
ROLLBACK
;
RESET
ROLE
;
--
-- Clean up
--
DROP
VIEW
lock_view1
;
DROP
TABLE
lock_tbl3
;
DROP
TABLE
lock_tbl2
;
DROP
TABLE
lock_tbl1
;
DROP
SCHEMA
lock_schema1
CASCADE
;
DROP
ROLE
regress_rol_lock1
;
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