Created
September 10, 2014 16:18
-
-
Save abrightwell/3133fc9e2df09bcd0408 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RESET SESSION AUTHORIZATION; | |
| DROP TABLE IF EXISTS s1, s2 CASCADE; | |
| DROP VIEW IF EXISTS v2; | |
| DROP ROLE IF EXISTS user1; | |
| CREATE ROLE user1; | |
| CREATE TABLE s1 (a int, b text); | |
| INSERT INTO s1 (SELECT x, md5(x::text) FROM generate_series(-10,10) x); | |
| CREATE TABLE s2 (x int, y text); | |
| INSERT INTO s2 (SELECT x, md5(x::text) FROM generate_series(-6,6) x); | |
| CREATE VIEW v2 AS SELECT * FROM s2 WHERE y like '%af%'; | |
| GRANT SELECT ON s1, s2, v2 TO user1; | |
| CREATE POLICY p1 ON s1 FOR SELECT USING (a in (select x from s2 where y like '%2f%')); | |
| CREATE POLICY p2 ON s2 FOR SELECT USING (x % 2 = 0); | |
| SET SESSION AUTHORIZATION user1; | |
| SELECT * FROM s1; | |
| EXPLAIN (COSTS OFF) SELECT * FROM only s1; | |
| QUERY PLAN | |
| ------------------------------------------------------------- | |
| Subquery Scan on s1 | |
| Filter: f_leak(s1.b) | |
| -> Hash Join | |
| Hash Cond: (s1_1.a = s2.x) | |
| -> Seq Scan on s1 s1_1 | |
| -> Hash | |
| -> HashAggregate | |
| Group Key: s2.x | |
| -> Subquery Scan on s2 | |
| Filter: (s2.y ~~ '%2f%'::text) | |
| -> Subquery Scan on s2_1 | |
| Filter: ((s2_1.x % 2) = 0) | |
| -> Seq Scan on s2 s2_2 | |
| Filter: ((x % 2) = 0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment