Skip to content

Commit

Permalink
Fix flaky rowsecurity test
Browse files Browse the repository at this point in the history
Check sql state code instead of error message in row security foreign
key check.
  • Loading branch information
svenklemm committed Oct 19, 2024
1 parent 5945e01 commit 2e3cf30
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions test/expected/rowsecurity-14.out
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,10 @@ SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.
| | | | | 33 | technology
(6 rows)

\set VERBOSITY sqlstate
DELETE FROM category WHERE cid = 33; -- fails with FK violation
ERROR: update or delete on table "category" violates foreign key constraint "document_cid_fkey" on table "document"
DETAIL: Key is still referenced from table "document".
ERROR: 23503
\set VERBOSITY default
-- can insert FK referencing invisible PK
SET SESSION AUTHORIZATION regress_rls_carol;
SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.did, c.cid;
Expand Down
5 changes: 3 additions & 2 deletions test/expected/rowsecurity-15.out
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,10 @@ SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.
| | | | | 33 | technology
(6 rows)

\set VERBOSITY sqlstate
DELETE FROM category WHERE cid = 33; -- fails with FK violation
ERROR: update or delete on table "category" violates foreign key constraint "document_cid_fkey" on table "document"
DETAIL: Key is still referenced from table "document".
ERROR: 23503
\set VERBOSITY default
-- can insert FK referencing invisible PK
SET SESSION AUTHORIZATION regress_rls_carol;
SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.did, c.cid;
Expand Down
5 changes: 3 additions & 2 deletions test/expected/rowsecurity-16.out
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,10 @@ SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.
| | | | | 33 | technology
(6 rows)

\set VERBOSITY sqlstate
DELETE FROM category WHERE cid = 33; -- fails with FK violation
ERROR: update or delete on table "category" violates foreign key constraint "document_cid_fkey" on table "document"
DETAIL: Key is still referenced from table "document".
ERROR: 23503
\set VERBOSITY default
-- can insert FK referencing invisible PK
SET SESSION AUTHORIZATION regress_rls_carol;
SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.did, c.cid;
Expand Down
5 changes: 3 additions & 2 deletions test/expected/rowsecurity-17.out
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,10 @@ SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.
| | | | | 33 | technology
(6 rows)

\set VERBOSITY sqlstate
DELETE FROM category WHERE cid = 33; -- fails with FK violation
ERROR: update or delete on table "category" violates foreign key constraint "document_cid_fkey" on table "document"
DETAIL: Key is still referenced from table "document".
ERROR: 23503
\set VERBOSITY default
-- can insert FK referencing invisible PK
SET SESSION AUTHORIZATION regress_rls_carol;
SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.did, c.cid;
Expand Down
2 changes: 2 additions & 0 deletions test/sql/rowsecurity.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ ALTER TABLE category ENABLE ROW LEVEL SECURITY;
-- cannot delete PK referenced by invisible FK
SET SESSION AUTHORIZATION regress_rls_bob;
SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.did, c.cid;
\set VERBOSITY sqlstate
DELETE FROM category WHERE cid = 33; -- fails with FK violation
\set VERBOSITY default

-- can insert FK referencing invisible PK
SET SESSION AUTHORIZATION regress_rls_carol;
Expand Down

0 comments on commit 2e3cf30

Please sign in to comment.