SELECT count(*) FROM point_tbl WHERE f1 <@ box '(0,0,100,100)';
QUERY PLAN
----------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Aggregate
-> Index Only Scan using gpointind on point_tbl
Index Cond: (f1 <@ '(100,100),(0,0)'::box)
SELECT count(*) FROM point_tbl WHERE box '(0,0,100,100)' @> f1;
QUERY PLAN
----------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Aggregate
-> Index Only Scan using gpointind on point_tbl
Index Cond: (f1 <@ '(100,100),(0,0)'::box)
SELECT count(*) FROM point_tbl WHERE f1 <@ polygon '(0,0),(0,100),(100,100),(50,50),(100,0),(0,0)';
QUERY PLAN
----------------------------------------------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Aggregate
-> Index Only Scan using gpointind on point_tbl
Index Cond: (f1 <@ '((0,0),(0,100),(100,100),(50,50),(100,0),(0,0))'::polygon)
SELECT count(*) FROM point_tbl WHERE f1 <@ circle '<(50,50),50>';
QUERY PLAN
----------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Aggregate
-> Index Only Scan using gpointind on point_tbl
Index Cond: (f1 <@ '<(50,50),50>'::circle)
SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)';
QUERY PLAN
------------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Aggregate
-> Index Only Scan using gpointind on point_tbl p
Index Cond: (f1 << '(0,0)'::point)
SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)';
QUERY PLAN
------------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Aggregate
-> Index Only Scan using gpointind on point_tbl p
Index Cond: (f1 >> '(0,0)'::point)
SELECT count(*) FROM point_tbl p WHERE p.f1 <^ '(0.0, 0.0)';
QUERY PLAN
------------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Aggregate
-> Index Only Scan using gpointind on point_tbl p
Index Cond: (f1 <^ '(0,0)'::point)
SELECT count(*) FROM point_tbl p WHERE p.f1 >^ '(0.0, 0.0)';
QUERY PLAN
------------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Aggregate
-> Index Only Scan using gpointind on point_tbl p
Index Cond: (f1 >^ '(0,0)'::point)
SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)';
QUERY PLAN
------------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Aggregate
-> Index Only Scan using gpointind on point_tbl p
Index Cond: (f1 ~= '(-5,-12)'::point)
SELECT * FROM point_tbl ORDER BY f1 <-> '0,1';
QUERY PLAN
----------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Index Only Scan using gpointind on point_tbl
Order By: (f1 <-> '(0,1)'::point)
(3 rows)
SELECT * FROM point_tbl WHERE f1 IS NULL;
QUERY PLAN
----------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Index Only Scan using gpointind on point_tbl
Index Cond: (f1 IS NULL)
(3 rows)
SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1';
QUERY PLAN
----------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Index Only Scan using gpointind on point_tbl
Index Cond: (f1 IS NOT NULL)
Order By: (f1 <-> '(0,1)'::point)
SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1';
QUERY PLAN
------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Index Only Scan using gpointind on point_tbl
Index Cond: (f1 <@ '(10,10),(-10,-10)'::box)
Order By: (f1 <-> '(0,1)'::point)
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef';
- QUERY PLAN
-------------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Index Only Scan using sp_radix_ind on radix_text_tbl
- Index Cond: (t = 'P0123456789abcdef'::text)
-(5 rows)
+ QUERY PLAN
+------------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Index Only Scan using sp_radix_ind on radix_text_tbl
+ Index Cond: (t = 'P0123456789abcdef'::text)
+(4 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef';
count
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde';
- QUERY PLAN
-------------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Index Only Scan using sp_radix_ind on radix_text_tbl
- Index Cond: (t = 'P0123456789abcde'::text)
-(5 rows)
+ QUERY PLAN
+------------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Index Only Scan using sp_radix_ind on radix_text_tbl
+ Index Cond: (t = 'P0123456789abcde'::text)
+(4 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde';
count
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF';
- QUERY PLAN
-------------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Index Only Scan using sp_radix_ind on radix_text_tbl
- Index Cond: (t = 'P0123456789abcdefF'::text)
-(5 rows)
+ QUERY PLAN
+------------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Index Only Scan using sp_radix_ind on radix_text_tbl
+ Index Cond: (t = 'P0123456789abcdefF'::text)
+(4 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF';
count
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ';
- QUERY PLAN
-----------------------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Index Only Scan using sp_radix_ind on radix_text_tbl
- Index Cond: (t = 'Aztec Ct '::text)
-(5 rows)
+ QUERY PLAN
+----------------------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Index Only Scan using sp_radix_ind on radix_text_tbl
+ Index Cond: (t = 'Aztec Ct '::text)
+(4 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ';
count
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ';
- QUERY PLAN
-----------------------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Index Only Scan using sp_radix_ind on radix_text_tbl
- Index Cond: (t = 'Worth St '::text)
-(5 rows)
+ QUERY PLAN
+----------------------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Index Only Scan using sp_radix_ind on radix_text_tbl
+ Index Cond: (t = 'Worth St '::text)
+(4 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ';
count
-> Index Only Scan using sp_radix_ind on radix_text_tbl
Index Cond: (t > 'Worth St '::text)
(5 rows)
+
SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ';
count
-------
SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1';
QUERY PLAN
------------------------------------------------------------------
- Remote Subquery Scan on all
+ Remote Fast Query Execution
-> Sort
Sort Key: ((f1 <-> '(0,1)'::point))
-> Bitmap Heap Scan on point_tbl
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef';
- QUERY PLAN
------------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Bitmap Heap Scan on radix_text_tbl
- Recheck Cond: (t = 'P0123456789abcdef'::text)
- -> Bitmap Index Scan on sp_radix_ind
- Index Cond: (t = 'P0123456789abcdef'::text)
-(7 rows)
+ QUERY PLAN
+-----------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Bitmap Heap Scan on radix_text_tbl
+ Recheck Cond: (t = 'P0123456789abcdef'::text)
+ -> Bitmap Index Scan on sp_radix_ind
+ Index Cond: (t = 'P0123456789abcdef'::text)
+(6 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef';
count
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde';
- QUERY PLAN
-----------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Bitmap Heap Scan on radix_text_tbl
- Recheck Cond: (t = 'P0123456789abcde'::text)
- -> Bitmap Index Scan on sp_radix_ind
- Index Cond: (t = 'P0123456789abcde'::text)
-(7 rows)
+ QUERY PLAN
+----------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Bitmap Heap Scan on radix_text_tbl
+ Recheck Cond: (t = 'P0123456789abcde'::text)
+ -> Bitmap Index Scan on sp_radix_ind
+ Index Cond: (t = 'P0123456789abcde'::text)
+(6 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde';
count
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF';
- QUERY PLAN
-------------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Bitmap Heap Scan on radix_text_tbl
- Recheck Cond: (t = 'P0123456789abcdefF'::text)
- -> Bitmap Index Scan on sp_radix_ind
- Index Cond: (t = 'P0123456789abcdefF'::text)
-(7 rows)
+ QUERY PLAN
+------------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Bitmap Heap Scan on radix_text_tbl
+ Recheck Cond: (t = 'P0123456789abcdefF'::text)
+ -> Bitmap Index Scan on sp_radix_ind
+ Index Cond: (t = 'P0123456789abcdefF'::text)
+(6 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF';
count
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ';
- QUERY PLAN
-----------------------------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Bitmap Heap Scan on radix_text_tbl
- Recheck Cond: (t = 'Aztec Ct '::text)
- -> Bitmap Index Scan on sp_radix_ind
- Index Cond: (t = 'Aztec Ct '::text)
-(7 rows)
+ QUERY PLAN
+----------------------------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Bitmap Heap Scan on radix_text_tbl
+ Recheck Cond: (t = 'Aztec Ct '::text)
+ -> Bitmap Index Scan on sp_radix_ind
+ Index Cond: (t = 'Aztec Ct '::text)
+(6 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ';
count
EXPLAIN (NODES OFF, COSTS OFF)
SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ';
- QUERY PLAN
-----------------------------------------------------------------------------------------
- Aggregate
- -> Remote Subquery Scan on all
- -> Aggregate
- -> Bitmap Heap Scan on radix_text_tbl
- Recheck Cond: (t = 'Worth St '::text)
- -> Bitmap Index Scan on sp_radix_ind
- Index Cond: (t = 'Worth St '::text)
-(7 rows)
+ QUERY PLAN
+----------------------------------------------------------------------------------
+ Remote Fast Query Execution
+ -> Aggregate
+ -> Bitmap Heap Scan on radix_text_tbl
+ Recheck Cond: (t = 'Worth St '::text)
+ -> Bitmap Index Scan on sp_radix_ind
+ Index Cond: (t = 'Worth St '::text)
+(6 rows)
SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ';
count
-> Bitmap Index Scan on sp_radix_ind
Index Cond: (t ~>~ 'Worth St '::text)
(7 rows)
+
SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ';
count
-------
EXPLAIN (NODES OFF, COSTS OFF)
SELECT * FROM tenk1
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
- QUERY PLAN
------------------------------------------------------------------------
- Remote Subquery Scan on all
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------
+ Remote Fast Query Execution
-> Bitmap Heap Scan on tenk1
- Recheck Cond: (thousand = 42)
- Filter: ((tenthous = 1) OR (tenthous = 3) OR (tenthous = 42))
- -> Bitmap Index Scan on tenk1_thous_tenthous
- Index Cond: (thousand = 42)
-(6 rows)
+ Recheck Cond: (((thousand = 42) AND (tenthous = 1)) OR ((thousand = 42) AND (tenthous = 3)) OR ((thousand = 42) AND (tenthous = 42)))
+ -> BitmapOr
+ -> Bitmap Index Scan on tenk1_thous_tenthous
+ Index Cond: ((thousand = 42) AND (tenthous = 1))
+ -> Bitmap Index Scan on tenk1_thous_tenthous
+ Index Cond: ((thousand = 42) AND (tenthous = 3))
+ -> Bitmap Index Scan on tenk1_thous_tenthous
+ Index Cond: ((thousand = 42) AND (tenthous = 42))
+(10 rows)
SELECT * FROM tenk1
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
SELECT thousand, tenthous FROM tenk1
WHERE thousand < 2 AND tenthous IN (1001,3000)
ORDER BY thousand;
- QUERY PLAN
---------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------
Remote Subquery Scan on all (datanode_1,datanode_2)
-> Sort
Sort Key: thousand
- -> Bitmap Heap Scan on tenk1
- Recheck Cond: ((thousand < 2) AND (tenthous = ANY ('{1001,3000}'::integer[])))
- -> Bitmap Index Scan on tenk1_thous_tenthous
- Index Cond: ((thousand < 2) AND (tenthous = ANY ('{1001,3000}'::integer[])))
-(7 rows)
+ -> Index Only Scan using tenk1_thous_tenthous on tenk1
+ Index Cond: ((thousand < 2) AND (tenthous = ANY ('{1001,3000}'::integer[])))
+(5 rows)
SELECT thousand, tenthous FROM tenk1
WHERE thousand < 2 AND tenthous IN (1001,3000)
SELECT thousand, tenthous FROM tenk1
WHERE thousand < 2 AND tenthous IN (1001,3000)
ORDER BY thousand;
- QUERY PLAN
---------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------
Remote Subquery Scan on all (datanode_1,datanode_2)
-> Sort
Sort Key: thousand
- -> Bitmap Heap Scan on tenk1
- Recheck Cond: ((thousand < 2) AND (tenthous = ANY ('{1001,3000}'::integer[])))
- -> Bitmap Index Scan on tenk1_thous_tenthous
- Index Cond: ((thousand < 2) AND (tenthous = ANY ('{1001,3000}'::integer[])))
-(7 rows)
+ -> Index Scan using tenk1_thous_tenthous on tenk1
+ Index Cond: ((thousand < 2) AND (tenthous = ANY ('{1001,3000}'::integer[])))
+(5 rows)
SELECT thousand, tenthous FROM tenk1
WHERE thousand < 2 AND tenthous IN (1001,3000)
select * from tenk1 where (thousand, tenthous) in ((1,1001), (null,null));
QUERY PLAN
------------------------------------------------------------
- Remote Subquery Scan on all (datanode_1,datanode_2)
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
-> Index Scan using tenk1_thous_tenthous on tenk1
Index Cond: ((thousand = 1) AND (tenthous = 1001))
-(3 rows)
+(4 rows)
--
-- REINDEX (VERBOSE)
ELSE 'relfilenode has changed' END
FROM reindex_before b JOIN pg_class a ON b.oid = a.oid
ORDER BY 1;
- relname | relkind | case
-----------------------+---------+--------------------------
- matview | m | relfilenode is unchanged
- matview_col1_idx | i | relfilenode has changed
- pg_toast_TABLE | t | relfilenode is unchanged
- pg_toast_TABLE_index | i | relfilenode has changed
- table1 | r | relfilenode is unchanged
- table1_col1_seq | S | relfilenode is unchanged
- table1_pkey | i | relfilenode has changed
- table2 | r | relfilenode is unchanged
- table2_col1_seq | S | relfilenode is unchanged
- table2_col2_idx | i | relfilenode has changed
- table2_pkey | i | relfilenode has changed
- view | v | relfilenode is unchanged
-(12 rows)
+ relname | relkind | case
+---------+---------+------
+(0 rows)
REINDEX SCHEMA schema_to_reindex;
BEGIN;
--
explain (costs off)
select * from ec0 where ff = f1 and f1 = '42'::int8;
- QUERY PLAN
-------------------------------------------
- Remote Subquery Scan on all (datanode_1)
+ QUERY PLAN
+-----------------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
-> Index Scan using ec0_pkey on ec0
Index Cond: (ff = '42'::bigint)
Filter: (f1 = '42'::bigint)
-(4 rows)
+(5 rows)
explain (costs off)
select * from ec0 where ff = f1 and f1 = '42'::int8alias1;
- QUERY PLAN
------------------------------------------------------
- Remote Subquery Scan on all (datanode_1,datanode_2)
+ QUERY PLAN
+---------------------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
-> Index Scan using ec0_pkey on ec0
Index Cond: (ff = '42'::int8alias1)
Filter: (f1 = '42'::int8alias1)
-(4 rows)
+(5 rows)
explain (costs off)
select * from ec1 where ff = f1 and f1 = '42'::int8alias1;
- QUERY PLAN
------------------------------------------------------
- Remote Subquery Scan on all (datanode_1,datanode_2)
+ QUERY PLAN
+---------------------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
-> Index Scan using ec1_pkey on ec1
Index Cond: (ff = '42'::int8alias1)
Filter: (f1 = '42'::int8alias1)
-(4 rows)
+(5 rows)
explain (costs off)
select * from ec1 where ff = f1 and f1 = '42'::int8alias2;
QUERY PLAN
---------------------------------------------------------
- Remote Subquery Scan on all (datanode_1,datanode_2)
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
-> Seq Scan on ec1
Filter: ((ff = f1) AND (f1 = '42'::int8alias2))
-(3 rows)
+(4 rows)
explain (costs off)
select * from ec1, ec2 where ff = x1 and ff = '42'::int8;
Nested Loop
Join Filter: ((((ec1_1.ff + 2) + 1)) = (((ec1_4.ff + 2) + 1)))
-> Append
- -> Index Scan using ec1_expr2 on ec1 ec1_4
- Index Cond: (((ff + 2) + 1) = (((ec1_1.ff + 2) + 1)))
- -> Index Scan using ec1_expr3 on ec1 ec1_5
- Index Cond: (((ff + 3) + 1) = (((ec1_1.ff + 2) + 1)))
- -> Index Scan using ec1_expr4 on ec1 ec1_6
- Index Cond: ((ff + 4) = (((ec1_1.ff + 2) + 1)))
-(18 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on ec1 ec1_4
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on ec1 ec1_5
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on ec1 ec1_6
+ -> Materialize
+ -> Nested Loop
+ Join Filter: ((((ec1_1.ff + 2) + 1)) = ec1.f1)
+ -> Remote Subquery Scan on all (datanode_1)
+ -> Index Scan using ec1_pkey on ec1
+ Index Cond: (ff = '42'::bigint)
+ -> Append
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on ec1 ec1_1
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on ec1 ec1_2
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on ec1 ec1_3
+(22 rows)
-- let's try that as a mergejoin
set enable_mergejoin = on;
set enable_nestloop = off;
-explain (costs off)
- select * from ec1,
- (select ff + 1 as x from
- (select ff + 2 as ff from ec1
- union all
- select ff + 3 as ff from ec1) ss0
- union all
- select ff + 4 as x from ec1) as ss1,
- (select ff + 1 as x from
- (select ff + 2 as ff from ec1
- union all
- select ff + 3 as ff from ec1) ss0
- union all
- select ff + 4 as x from ec1) as ss2
- where ss1.x = ec1.f1 and ss1.x = ss2.x and ec1.ff = 42::int8;
- QUERY PLAN
------------------------------------------------------------------
- Merge Join
- Merge Cond: ((((ec1_4.ff + 2) + 1)) = (((ec1_1.ff + 2) + 1)))
- -> Merge Append
- Sort Key: (((ec1_4.ff + 2) + 1))
- -> Index Scan using ec1_expr2 on ec1 ec1_4
- -> Index Scan using ec1_expr3 on ec1 ec1_5
- -> Index Scan using ec1_expr4 on ec1 ec1_6
- -> Materialize
- -> Merge Join
- Merge Cond: ((((ec1_1.ff + 2) + 1)) = ec1.f1)
- -> Merge Append
- Sort Key: (((ec1_1.ff + 2) + 1))
- -> Index Scan using ec1_expr2 on ec1 ec1_1
- -> Index Scan using ec1_expr3 on ec1 ec1_2
- -> Index Scan using ec1_expr4 on ec1 ec1_3
- -> Materialize
- -> Sort
- Sort Key: ec1.f1 USING <
- -> Index Scan using ec1_pkey on ec1
- Index Cond: (ff = '42'::bigint)
-(20 rows)
-
+-- excluding as XL does not support complex queries
+-- with 'union all'
-- check partially indexed scan
set enable_nestloop = on;
set enable_mergejoin = off;
drop index ec1_expr3;
+ERROR: index "ec1_expr3" does not exist
explain (costs off)
select * from ec1,
(select ff + 1 as x from
-- let's try that as a mergejoin
set enable_mergejoin = on;
set enable_nestloop = off;
-explain (costs off)
- select * from ec1,
- (select ff + 1 as x from
- (select ff + 2 as ff from ec1
- union all
- select ff + 3 as ff from ec1) ss0
- union all
- select ff + 4 as x from ec1) as ss1
- where ss1.x = ec1.f1 and ec1.ff = 42::int8;
- QUERY PLAN
------------------------------------------------------
- Merge Join
- Merge Cond: ((((ec1_1.ff + 2) + 1)) = ec1.f1)
- -> Merge Append
- Sort Key: (((ec1_1.ff + 2) + 1))
- -> Index Scan using ec1_expr2 on ec1 ec1_1
- -> Sort
- Sort Key: (((ec1_2.ff + 3) + 1))
- -> Seq Scan on ec1 ec1_2
- -> Index Scan using ec1_expr4 on ec1 ec1_3
- -> Materialize
- -> Sort
- Sort Key: ec1.f1 USING <
- -> Index Scan using ec1_pkey on ec1
- Index Cond: (ff = '42'::bigint)
-(14 rows)
-
select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5));
QUERY PLAN
--------------------------------------------------------------
- Remote Subquery Scan on all (datanode_1,datanode_2)
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
-> Index Only Scan using gist_tbl_point_index on gist_tbl
Index Cond: (p <@ '(0.5,0.5),(0,0)'::box)
-(3 rows)
+(4 rows)
-- execute the same
select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5));
-- Also test an index-only knn-search
explain (costs off)
select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5))
-order by p <-> point(0.2, 0.2);
+order by p <-> point(0.201, 0.201);
QUERY PLAN
--------------------------------------------------------------
Remote Subquery Scan on all (datanode_1,datanode_2)
-- Check commuted case as well
explain (costs off)
select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5))
-order by point(0.1, 0.1) <-> p;
+order by point(0.101, 0.101) <-> p;
QUERY PLAN
--------------------------------------------------------------
Remote Subquery Scan on all (datanode_1,datanode_2)
select b from gist_tbl where b <@ box(point(5,5), point(6,6));
QUERY PLAN
------------------------------------------------------------
- Remote Subquery Scan on all (datanode_1,datanode_2)
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
-> Index Only Scan using gist_tbl_box_index on gist_tbl
Index Cond: (b <@ '(6,6),(5,5)'::box)
-(3 rows)
+(4 rows)
-- execute the same
select b from gist_tbl where b <@ box(point(5,5), point(6,6));
where p <@ box(point(5,5), point(6, 6));
QUERY PLAN
---------------------------------------------------------
- Remote Subquery Scan on all (datanode_1,datanode_2)
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
-> Index Scan using gist_tbl_multi_index on gist_tbl
Index Cond: (p <@ '(6,6),(5,5)'::box)
-(3 rows)
+(4 rows)
-- execute the same
select b, p from gist_tbl
-- (and with ordering differing from grouping)
select a, b, grouping(a,b), sum(v), count(*), max(v)
from gstest1 group by rollup (a,b);
- a | b | grouping | sum | count | max
----+---+----------+-----+-------+-----
- 1 | 1 | 0 | 21 | 2 | 11
- 1 | 2 | 0 | 25 | 2 | 13
- 1 | 3 | 0 | 14 | 1 | 14
- 1 | | 1 | 60 | 5 | 14
- 2 | 3 | 0 | 15 | 1 | 15
- 2 | | 1 | 15 | 1 | 15
- 3 | 3 | 0 | 16 | 1 | 16
- 3 | 4 | 0 | 17 | 1 | 17
- 3 | | 1 | 33 | 2 | 17
- 4 | 1 | 0 | 37 | 2 | 19
- 4 | | 1 | 37 | 2 | 19
- | | 3 | 145 | 10 | 19
-(12 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b, grouping(a,b), sum(v), count(*), max(v)
from gstest1 group by rollup (a,b) order by a,b;
- a | b | grouping | sum | count | max
----+---+----------+-----+-------+-----
- 1 | 1 | 0 | 21 | 2 | 11
- 1 | 2 | 0 | 25 | 2 | 13
- 1 | 3 | 0 | 14 | 1 | 14
- 1 | | 1 | 60 | 5 | 14
- 2 | 3 | 0 | 15 | 1 | 15
- 2 | | 1 | 15 | 1 | 15
- 3 | 3 | 0 | 16 | 1 | 16
- 3 | 4 | 0 | 17 | 1 | 17
- 3 | | 1 | 33 | 2 | 17
- 4 | 1 | 0 | 37 | 2 | 19
- 4 | | 1 | 37 | 2 | 19
- | | 3 | 145 | 10 | 19
-(12 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b, grouping(a,b), sum(v), count(*), max(v)
from gstest1 group by rollup (a,b) order by b desc, a;
- a | b | grouping | sum | count | max
----+---+----------+-----+-------+-----
- 1 | | 1 | 60 | 5 | 14
- 2 | | 1 | 15 | 1 | 15
- 3 | | 1 | 33 | 2 | 17
- 4 | | 1 | 37 | 2 | 19
- | | 3 | 145 | 10 | 19
- 3 | 4 | 0 | 17 | 1 | 17
- 1 | 3 | 0 | 14 | 1 | 14
- 2 | 3 | 0 | 15 | 1 | 15
- 3 | 3 | 0 | 16 | 1 | 16
- 1 | 2 | 0 | 25 | 2 | 13
- 1 | 1 | 0 | 21 | 2 | 11
- 4 | 1 | 0 | 37 | 2 | 19
-(12 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b, grouping(a,b), sum(v), count(*), max(v)
from gstest1 group by rollup (a,b) order by coalesce(a,0)+coalesce(b,0);
- a | b | grouping | sum | count | max
----+---+----------+-----+-------+-----
- | | 3 | 145 | 10 | 19
- 1 | | 1 | 60 | 5 | 14
- 1 | 1 | 0 | 21 | 2 | 11
- 2 | | 1 | 15 | 1 | 15
- 3 | | 1 | 33 | 2 | 17
- 1 | 2 | 0 | 25 | 2 | 13
- 1 | 3 | 0 | 14 | 1 | 14
- 4 | | 1 | 37 | 2 | 19
- 4 | 1 | 0 | 37 | 2 | 19
- 2 | 3 | 0 | 15 | 1 | 15
- 3 | 3 | 0 | 16 | 1 | 16
- 3 | 4 | 0 | 17 | 1 | 17
-(12 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- various types of ordered aggs
select a, b, grouping(a,b),
array_agg(v order by v),
percentile_disc(0.5) within group (order by v),
rank(1,2,12) within group (order by a,b,v)
from gstest1 group by rollup (a,b) order by a,b;
- a | b | grouping | array_agg | string_agg | percentile_disc | rank
----+---+----------+---------------------------------+-------------------------------+-----------------+------
- 1 | 1 | 0 | {10,11} | 11:10 | 10 | 3
- 1 | 2 | 0 | {12,13} | 13:12 | 12 | 1
- 1 | 3 | 0 | {14} | 14 | 14 | 1
- 1 | | 1 | {10,11,12,13,14} | 14:13:12:11:10 | 12 | 3
- 2 | 3 | 0 | {15} | 15 | 15 | 1
- 2 | | 1 | {15} | 15 | 15 | 1
- 3 | 3 | 0 | {16} | 16 | 16 | 1
- 3 | 4 | 0 | {17} | 17 | 17 | 1
- 3 | | 1 | {16,17} | 17:16 | 16 | 1
- 4 | 1 | 0 | {18,19} | 19:18 | 18 | 1
- 4 | | 1 | {18,19} | 19:18 | 18 | 1
- | | 3 | {10,11,12,13,14,15,16,17,18,19} | 19:18:17:16:15:14:13:12:11:10 | 14 | 3
-(12 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- test usage of grouped columns in direct args of aggs
select grouping(a), a, array_agg(b),
rank(a) within group (order by b nulls first),
rank(a) within group (order by b nulls last)
from (values (1,1),(1,4),(1,5),(3,1),(3,2)) v(a,b)
group by rollup (a) order by a;
- grouping | a | array_agg | rank | rank
-----------+---+-------------+------+------
- 0 | 1 | {1,4,5} | 1 | 1
- 0 | 3 | {1,2} | 3 | 3
- 1 | | {1,4,5,1,2} | 1 | 6
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- nesting with window functions
select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum
from gstest2 group by rollup (a,b) order by rsum, a, b;
- a | b | sum | rsum
----+---+-----+------
- 1 | 1 | 8 | 8
- 1 | 2 | 2 | 10
- 1 | | 10 | 20
- 2 | 2 | 2 | 22
- 2 | | 2 | 24
- | | 12 | 36
-(6 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- nesting with grouping sets
select sum(c) from gstest2
group by grouping sets((), grouping sets((), grouping sets(())))
order by 1 desc;
- sum
------
- 12
- 12
- 12
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(c) from gstest2
group by grouping sets((), grouping sets((), grouping sets(((a, b)))))
order by 1 desc;
- sum
------
- 12
- 12
- 8
- 2
- 2
-(5 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(c) from gstest2
group by grouping sets(grouping sets(rollup(c), grouping sets(cube(c))))
order by 1 desc;
- sum
------
- 12
- 12
- 6
- 6
- 6
- 6
-(6 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(c) from gstest2
group by grouping sets(a, grouping sets(a, cube(b)))
order by 1 desc;
- sum
------
- 12
- 10
- 10
- 8
- 4
- 2
- 2
-(7 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(c) from gstest2
group by grouping sets(grouping sets((a, (b))))
order by 1 desc;
- sum
------
- 8
- 2
- 2
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(c) from gstest2
group by grouping sets(grouping sets((a, b)))
order by 1 desc;
- sum
------
- 8
- 2
- 2
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(c) from gstest2
group by grouping sets(grouping sets(a, grouping sets(a), a))
order by 1 desc;
- sum
------
- 10
- 10
- 10
- 2
- 2
- 2
-(6 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(c) from gstest2
group by grouping sets(grouping sets(a, grouping sets(a, grouping sets(a), ((a)), a, grouping sets(a), (a)), a))
order by 1 desc;
- sum
------
- 10
- 10
- 10
- 10
- 10
- 10
- 10
- 10
- 2
- 2
- 2
- 2
- 2
- 2
- 2
- 2
-(16 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(c) from gstest2
group by grouping sets((a,(a,b)), grouping sets((a,(a,b)),a))
order by 1 desc;
- sum
------
- 10
- 8
- 8
- 2
- 2
- 2
- 2
- 2
-(8 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- empty input: first is 0 rows, second 1, third 3 etc.
select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),a);
- a | b | sum | count
----+---+-----+-------
-(0 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),());
- a | b | sum | count
----+---+-----+-------
- | | | 0
-(1 row)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),(),(),());
- a | b | sum | count
----+---+-----+-------
- | | | 0
- | | | 0
- | | | 0
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(v), count(*) from gstest_empty group by grouping sets ((),(),());
- sum | count
------+-------
- | 0
- | 0
- | 0
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- empty input with joins tests some important code paths
select t1.a, t2.b, sum(t1.v), count(*) from gstest_empty t1, gstest_empty t2
group by grouping sets ((t1.a,t2.b),());
- a | b | sum | count
----+---+-----+-------
- | | | 0
-(1 row)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- simple joins, var resolution, GROUPING on join vars
select t1.a, t2.b, grouping(t1.a, t2.b), sum(t1.v), max(t2.a)
from gstest1 t1, gstest2 t2
group by grouping sets ((t1.a, t2.b), ());
- a | b | grouping | sum | max
----+---+----------+------+-----
- 1 | 1 | 0 | 420 | 1
- 1 | 2 | 0 | 120 | 2
- 2 | 1 | 0 | 105 | 1
- 2 | 2 | 0 | 30 | 2
- 3 | 1 | 0 | 231 | 1
- 3 | 2 | 0 | 66 | 2
- 4 | 1 | 0 | 259 | 1
- 4 | 2 | 0 | 74 | 2
- | | 3 | 1305 | 2
-(9 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select t1.a, t2.b, grouping(t1.a, t2.b), sum(t1.v), max(t2.a)
from gstest1 t1 join gstest2 t2 on (t1.a=t2.a)
group by grouping sets ((t1.a, t2.b), ());
- a | b | grouping | sum | max
----+---+----------+-----+-----
- 1 | 1 | 0 | 420 | 1
- 1 | 2 | 0 | 60 | 1
- 2 | 2 | 0 | 15 | 2
- | | 3 | 495 | 2
-(4 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b, grouping(a, b), sum(t1.v), max(t2.c)
from gstest1 t1 join gstest2 t2 using (a,b)
group by grouping sets ((a, b), ());
- a | b | grouping | sum | max
----+---+----------+-----+-----
- 1 | 1 | 0 | 147 | 2
- 1 | 2 | 0 | 25 | 2
- | | 3 | 172 | 2
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- check that functionally dependent cols are not nulled
select a, d, grouping(a,b,c)
from gstest3
group by grouping sets ((a,b), (a,c));
- a | d | grouping
----+---+----------
- 1 | 1 | 1
- 2 | 2 | 1
- 1 | 1 | 2
- 2 | 2 | 2
-(4 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- simple rescan tests
select a, b, sum(v.x)
from (values (1),(2)) v(x), gstest_data(v.x)
group by rollup (a,b);
- a | b | sum
----+---+-----
- 1 | 1 | 1
- 1 | 2 | 1
- 1 | 3 | 1
- 1 | | 3
- 2 | 1 | 2
- 2 | 2 | 2
- 2 | 3 | 2
- 2 | | 6
- | | 9
-(9 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select *
from (values (1),(2)) v(x),
lateral (select a, b, sum(v.x) from gstest_data(v.x) group by rollup (a,b)) s;
-- min max optimisation should still work with GROUP BY ()
explain (costs off)
select min(unique1) from tenk1 GROUP BY ();
- QUERY PLAN
-------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------
Result
InitPlan 1 (returns $0)
-> Limit
- -> Index Only Scan using tenk1_unique1 on tenk1
- Index Cond: (unique1 IS NOT NULL)
-(5 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Limit
+ -> Index Only Scan using tenk1_unique1 on tenk1
+ Index Cond: (unique1 IS NOT NULL)
+(7 rows)
-- Views with GROUPING SET queries
CREATE VIEW gstest_view AS select a, b, grouping(a,b), sum(c), count(*), max(c)
from gstest2 group by rollup ((a,b,c),(c,d));
-NOTICE: view "gstest_view" will be a temporary view
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select pg_get_viewdef('gstest_view'::regclass, true);
- pg_get_viewdef
--------------------------------------------------------------------------------
- SELECT gstest2.a, +
- gstest2.b, +
- GROUPING(gstest2.a, gstest2.b) AS "grouping", +
- sum(gstest2.c) AS sum, +
- count(*) AS count, +
- max(gstest2.c) AS max +
- FROM gstest2 +
- GROUP BY ROLLUP((gstest2.a, gstest2.b, gstest2.c), (gstest2.c, gstest2.d));
-(1 row)
-
+ERROR: relation "gstest_view" does not exist
+LINE 1: select pg_get_viewdef('gstest_view'::regclass, true);
+ ^
-- Nested queries with 3 or more levels of nesting
select(select (select grouping(a,b) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP(e,f);
- grouping
-----------
- 0
- 0
- 0
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select(select (select grouping(e,f) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP(e,f);
- grouping
-----------
- 0
- 1
- 3
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select(select (select grouping(c) from (values (1)) v2(c) GROUP BY c) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP(e,f);
- grouping
-----------
- 0
- 0
- 0
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- Combinations of operations
select a, b, c, d from gstest2 group by rollup(a,b),grouping sets(c,d);
- a | b | c | d
----+---+---+---
- 1 | 1 | 1 |
- 1 | | 1 |
- | | 1 |
- 1 | 1 | 2 |
- 1 | 2 | 2 |
- 1 | | 2 |
- 2 | 2 | 2 |
- 2 | | 2 |
- | | 2 |
- 1 | 1 | | 1
- 1 | | | 1
- | | | 1
- 1 | 1 | | 2
- 1 | 2 | | 2
- 1 | | | 2
- 2 | 2 | | 2
- 2 | | | 2
- | | | 2
-(18 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b from (values (1,2),(2,3)) v(a,b) group by a,b, grouping sets(a);
- a | b
----+---
- 1 | 2
- 2 | 3
-(2 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- Tests for chained aggregates
select a, b, grouping(a,b), sum(v), count(*), max(v)
from gstest1 group by grouping sets ((a,b),(a+1,b+1),(a+2,b+2));
- a | b | grouping | sum | count | max
----+---+----------+-----+-------+-----
- 1 | 1 | 0 | 21 | 2 | 11
- 1 | 2 | 0 | 25 | 2 | 13
- 1 | 3 | 0 | 14 | 1 | 14
- 2 | 3 | 0 | 15 | 1 | 15
- 3 | 3 | 0 | 16 | 1 | 16
- 3 | 4 | 0 | 17 | 1 | 17
- 4 | 1 | 0 | 37 | 2 | 19
- | | 3 | 21 | 2 | 11
- | | 3 | 25 | 2 | 13
- | | 3 | 14 | 1 | 14
- | | 3 | 15 | 1 | 15
- | | 3 | 16 | 1 | 16
- | | 3 | 17 | 1 | 17
- | | 3 | 37 | 2 | 19
- | | 3 | 21 | 2 | 11
- | | 3 | 25 | 2 | 13
- | | 3 | 14 | 1 | 14
- | | 3 | 15 | 1 | 15
- | | 3 | 16 | 1 | 16
- | | 3 | 17 | 1 | 17
- | | 3 | 37 | 2 | 19
-(21 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select(select (select grouping(a,b) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP((e+1),(f+1));
- grouping
-----------
- 0
- 0
- 0
-(3 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select(select (select grouping(a,b) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY CUBE((e+1),(f+1)) ORDER BY (e+1),(f+1);
- grouping
-----------
- 0
- 0
- 0
- 0
-(4 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum
from gstest2 group by cube (a,b) order by rsum, a, b;
- a | b | sum | rsum
----+---+-----+------
- 1 | 1 | 8 | 8
- 1 | 2 | 2 | 10
- 1 | | 10 | 20
- 2 | 2 | 2 | 22
- 2 | | 2 | 24
- | 1 | 8 | 32
- | 2 | 4 | 36
- | | 12 | 48
-(8 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b, sum(c) from (values (1,1,10),(1,1,11),(1,2,12),(1,2,13),(1,3,14),(2,3,15),(3,3,16),(3,4,17),(4,1,18),(4,1,19)) v(a,b,c) group by rollup (a,b);
- a | b | sum
----+---+-----
- 1 | 1 | 21
- 1 | 2 | 25
- 1 | 3 | 14
- 1 | | 60
- 2 | 3 | 15
- 2 | | 15
- 3 | 3 | 16
- 3 | 4 | 17
- 3 | | 33
- 4 | 1 | 37
- 4 | | 37
- | | 145
-(12 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select a, b, sum(v.x)
from (values (1),(2)) v(x), gstest_data(v.x)
group by cube (a,b) order by a,b;
- a | b | sum
----+---+-----
- 1 | 1 | 1
- 1 | 2 | 1
- 1 | 3 | 1
- 1 | | 3
- 2 | 1 | 2
- 2 | 2 | 2
- 2 | 3 | 2
- 2 | | 6
- | 1 | 3
- | 2 | 3
- | 3 | 3
- | | 9
-(12 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- Agg level check. This query should error out.
select (select grouping(a,b) from gstest2) from gstest2 group by a,b;
ERROR: arguments to GROUPING must be grouping expressions of the associated query level
^
--Nested queries
select a, b, sum(c), count(*) from gstest2 group by grouping sets (rollup(a,b),a);
- a | b | sum | count
----+---+-----+-------
- 1 | 1 | 8 | 7
- 1 | 2 | 2 | 1
- 1 | | 10 | 8
- 1 | | 10 | 8
- 2 | 2 | 2 | 1
- 2 | | 2 | 1
- 2 | | 2 | 1
- | | 12 | 9
-(8 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- HAVING queries
select ten, sum(distinct four) from onek a
group by grouping sets((ten,four),(ten))
having exists (select 1 from onek b where sum(distinct a.four) = b.four);
- ten | sum
------+-----
- 0 | 0
- 0 | 2
- 0 | 2
- 1 | 1
- 1 | 3
- 2 | 0
- 2 | 2
- 2 | 2
- 3 | 1
- 3 | 3
- 4 | 0
- 4 | 2
- 4 | 2
- 5 | 1
- 5 | 3
- 6 | 0
- 6 | 2
- 6 | 2
- 7 | 1
- 7 | 3
- 8 | 0
- 8 | 2
- 8 | 2
- 9 | 1
- 9 | 3
-(25 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- HAVING with GROUPING queries
select ten, grouping(ten) from onek
group by grouping sets(ten) having grouping(ten) >= 0
order by 2,1;
- ten | grouping
------+----------
- 0 | 0
- 1 | 0
- 2 | 0
- 3 | 0
- 4 | 0
- 5 | 0
- 6 | 0
- 7 | 0
- 8 | 0
- 9 | 0
-(10 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select ten, grouping(ten) from onek
group by grouping sets(ten, four) having grouping(ten) > 0
order by 2,1;
- ten | grouping
------+----------
- | 1
- | 1
- | 1
- | 1
-(4 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select ten, grouping(ten) from onek
group by rollup(ten) having grouping(ten) > 0
order by 2,1;
- ten | grouping
------+----------
- | 1
-(1 row)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select ten, grouping(ten) from onek
group by cube(ten) having grouping(ten) > 0
order by 2,1;
- ten | grouping
------+----------
- | 1
-(1 row)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select ten, grouping(ten) from onek
group by (ten) having grouping(ten) >= 0
order by 2,1;
-- FILTER queries
select ten, sum(distinct four) filter (where four::text ~ '123') from onek a
group by rollup(ten);
- ten | sum
------+-----
- 0 |
- 1 |
- 2 |
- 3 |
- 4 |
- 5 |
- 6 |
- 7 |
- 8 |
- 9 |
- |
-(11 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- More rescan tests
select * from (values (1),(2)) v(a) left join lateral (select v.a, four, ten, count(*) from onek group by cube(four,ten)) s on true order by v.a,four,ten;
- a | a | four | ten | count
----+---+------+-----+-------
- 1 | 1 | 0 | 0 | 50
- 1 | 1 | 0 | 2 | 50
- 1 | 1 | 0 | 4 | 50
- 1 | 1 | 0 | 6 | 50
- 1 | 1 | 0 | 8 | 50
- 1 | 1 | 0 | | 250
- 1 | 1 | 1 | 1 | 50
- 1 | 1 | 1 | 3 | 50
- 1 | 1 | 1 | 5 | 50
- 1 | 1 | 1 | 7 | 50
- 1 | 1 | 1 | 9 | 50
- 1 | 1 | 1 | | 250
- 1 | 1 | 2 | 0 | 50
- 1 | 1 | 2 | 2 | 50
- 1 | 1 | 2 | 4 | 50
- 1 | 1 | 2 | 6 | 50
- 1 | 1 | 2 | 8 | 50
- 1 | 1 | 2 | | 250
- 1 | 1 | 3 | 1 | 50
- 1 | 1 | 3 | 3 | 50
- 1 | 1 | 3 | 5 | 50
- 1 | 1 | 3 | 7 | 50
- 1 | 1 | 3 | 9 | 50
- 1 | 1 | 3 | | 250
- 1 | 1 | | 0 | 100
- 1 | 1 | | 1 | 100
- 1 | 1 | | 2 | 100
- 1 | 1 | | 3 | 100
- 1 | 1 | | 4 | 100
- 1 | 1 | | 5 | 100
- 1 | 1 | | 6 | 100
- 1 | 1 | | 7 | 100
- 1 | 1 | | 8 | 100
- 1 | 1 | | 9 | 100
- 1 | 1 | | | 1000
- 2 | 2 | 0 | 0 | 50
- 2 | 2 | 0 | 2 | 50
- 2 | 2 | 0 | 4 | 50
- 2 | 2 | 0 | 6 | 50
- 2 | 2 | 0 | 8 | 50
- 2 | 2 | 0 | | 250
- 2 | 2 | 1 | 1 | 50
- 2 | 2 | 1 | 3 | 50
- 2 | 2 | 1 | 5 | 50
- 2 | 2 | 1 | 7 | 50
- 2 | 2 | 1 | 9 | 50
- 2 | 2 | 1 | | 250
- 2 | 2 | 2 | 0 | 50
- 2 | 2 | 2 | 2 | 50
- 2 | 2 | 2 | 4 | 50
- 2 | 2 | 2 | 6 | 50
- 2 | 2 | 2 | 8 | 50
- 2 | 2 | 2 | | 250
- 2 | 2 | 3 | 1 | 50
- 2 | 2 | 3 | 3 | 50
- 2 | 2 | 3 | 5 | 50
- 2 | 2 | 3 | 7 | 50
- 2 | 2 | 3 | 9 | 50
- 2 | 2 | 3 | | 250
- 2 | 2 | | 0 | 100
- 2 | 2 | | 1 | 100
- 2 | 2 | | 2 | 100
- 2 | 2 | | 3 | 100
- 2 | 2 | | 4 | 100
- 2 | 2 | | 5 | 100
- 2 | 2 | | 6 | 100
- 2 | 2 | | 7 | 100
- 2 | 2 | | 8 | 100
- 2 | 2 | | 9 | 100
- 2 | 2 | | | 1000
-(70 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select array(select row(v.a,s1.*) from (select two,four, count(*) from onek group by cube(two,four) order by two,four) s1) from (values (1),(2)) v(a);
- array
-------------------------------------------------------------------------------------------------------------------------------------------------------
- {"(1,0,0,250)","(1,0,2,250)","(1,0,,500)","(1,1,1,250)","(1,1,3,250)","(1,1,,500)","(1,,0,250)","(1,,1,250)","(1,,2,250)","(1,,3,250)","(1,,,1000)"}
- {"(2,0,0,250)","(2,0,2,250)","(2,0,,500)","(2,1,1,250)","(2,1,3,250)","(2,1,,500)","(2,,0,250)","(2,,1,250)","(2,,2,250)","(2,,3,250)","(2,,,1000)"}
-(2 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- Grouping on text columns
select sum(ten) from onek group by two, rollup(four::text) order by 1;
- sum
-------
- 1000
- 1000
- 1250
- 1250
- 2000
- 2500
-(6 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
select sum(ten) from onek group by rollup(four::text), two order by 1;
- sum
-------
- 1000
- 1000
- 1250
- 1250
- 2000
- 2500
-(6 rows)
-
+ERROR: GROUPING SETS, ROLLUP or CUBE is not yet supported
-- end
insert into bar2 values(3,3,3);
insert into bar2 values(4,4,4);
update bar set f2 = f2 + 100 where f1 in (select f1 from foo);
-SELECT relname, bar.* FROM bar, pg_class where bar.tableoid = pg_class.oid
-order by 1,2;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+select tableoid::regclass::text as relname, bar.* from bar order by 1,2;
relname | f1 | f2
---------+----+----
-(0 rows)
+ 42770 | 3 | 3
+ 42770 | 4 | 4
+ 42773 | 3 | 3
+ 42773 | 4 | 4
+ 43042 | 1 | 1
+ 43042 | 2 | 2
+ 43045 | 1 | 1
+ 43045 | 2 | 2
+(8 rows)
-- In Postgres-XL OIDs are not consistent across the cluster. Hence above
-- queries do not show any result. Hence in order to ensure data consistency, we
-- add following SQLs. In case above set of queries start producing valid
-- results in XC, we should remove the following set
SELECT * FROM bar ORDER BY f1, f2;
- f1 | f2
-----+-----
- 1 | 101
- 1 | 101
- 2 | 102
- 2 | 102
- 3 | 103
- 3 | 103
- 4 | 4
- 4 | 4
+ f1 | f2
+----+----
+ 1 | 1
+ 1 | 1
+ 2 | 2
+ 2 | 2
+ 3 | 3
+ 3 | 3
+ 4 | 4
+ 4 | 4
(8 rows)
SELECT * FROM ONLY bar ORDER BY f1, f2;
- f1 | f2
-----+-----
- 1 | 101
- 2 | 102
- 3 | 103
- 4 | 4
+ f1 | f2
+----+----
+ 1 | 1
+ 2 | 2
+ 3 | 3
+ 4 | 4
(4 rows)
SELECT * FROM bar2 ORDER BY f1, f2;
- f1 | f2 | f3
-----+-----+----
- 1 | 101 | 1
- 2 | 102 | 2
- 3 | 103 | 3
- 4 | 4 | 4
+ f1 | f2 | f3
+----+----+----
+ 1 | 1 | 1
+ 2 | 2 | 2
+ 3 | 3 | 3
+ 4 | 4 | 4
(4 rows)
+-- Check UPDATE with inherited target and an appendrel subquery
+update bar set f2 = f2 + 100
+from
+ ( select f1 from foo union all select f1+3 from foo ) ss
+where bar.f1 = ss.f1;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+select tableoid::regclass::text as relname, bar.* from bar order by 1,2;
+ relname | f1 | f2
+---------+----+----
+ 42770 | 3 | 3
+ 42770 | 4 | 4
+ 42773 | 3 | 3
+ 42773 | 4 | 4
+ 43042 | 1 | 1
+ 43042 | 2 | 2
+ 43045 | 1 | 1
+ 43045 | 2 | 2
+(8 rows)
+
/* Test multiple inheritance of column defaults */
CREATE TABLE firstparent (tomorrow date default now()::date + 1);
CREATE TABLE secondparent (tomorrow date default now() :: date + 1);
WHERE inhparent IN (SELECT inhrelid FROM r) GROUP BY inhrelid) e
JOIN pg_attribute a ON e.inhrelid = a.attrelid WHERE NOT attislocal
ORDER BY a.attrelid::regclass::name, a.attnum;
-ERROR: WITH RECURSIVE currently not supported on distributed tables.
+ attrelid | attname | attinhcount | expected
+----------+---------+-------------+----------
+ inht2 | aaaa | 1 | 1
+ inht2 | b | 1 | 1
+ inht3 | aaaa | 1 | 1
+ inht3 | b | 1 | 1
+ inht4 | aaaa | 2 | 2
+ inht4 | b | 2 | 2
+ inht4 | x | 1 | 2
+ inht4 | y | 1 | 2
+ inhts | aaaa | 1 | 1
+ inhts | b | 2 | 1
+ inhts | x | 1 | 1
+ inhts | c | 1 | 1
+(12 rows)
+
DROP TABLE inht1, inhs1 CASCADE;
NOTICE: drop cascades to 4 other objects
DETAIL: drop cascades to table inht2
----+--------
6 | Test 6
5 | Test 5
- 4 | Test 4
- 3 | Test 3
+ 4 | Test 3
+ 3 | Test 4
2 | Test 2
1 | Test 1
(6 rows)
----+--------
6 | Test 6
5 | Test 5
- 4 | Test 4
- 3 | Test 3
+ 4 | Test 3
+ 3 | Test 4
2 | Test 2
1 | Test 1
(6 rows)
select t1.* from matest0 t1, matest0 t2
where t1.b = t2.b and t2.c = t2.d
order by t1.b limit 10;
- QUERY PLAN
--------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------
Limit
-> Merge Join
Merge Cond: (t1.b = t2.b)
-> Merge Append
Sort Key: t1.b
- -> Index Scan using matest0i on matest0 t1
- -> Index Scan using matest1i on matest1 t1_1
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Index Scan using matest0i on matest0 t1
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Index Scan using matest1i on matest1 t1_1
-> Materialize
-> Merge Append
Sort Key: t2.b
- -> Index Scan using matest0i on matest0 t2
- Filter: (c = d)
- -> Index Scan using matest1i on matest1 t2_1
- Filter: (c = d)
-(14 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Index Scan using matest0i on matest0 t2
+ Filter: (c = d)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Index Scan using matest1i on matest1 t2_1
+ Filter: (c = d)
+(18 rows)
reset enable_nestloop;
drop table matest0 cascade;
select * from int8_tbl i1 left join (int8_tbl i2 join
(select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2
order by 1, 2;
- QUERY PLAN
--------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------
Sort
Sort Key: i1.q1, i1.q2
-> Hash Left Join
Hash Cond: (i1.q2 = i2.q2)
- -> Seq Scan on int8_tbl i1
+ -> Remote Subquery Scan on all (datanode_1)
+ -> Seq Scan on int8_tbl i1
-> Hash
-> Hash Join
Hash Cond: (i2.q1 = (123))
- -> Seq Scan on int8_tbl i2
+ -> Remote Subquery Scan on all (datanode_2)
+ -> Seq Scan on int8_tbl i2
-> Hash
-> Result
-(11 rows)
+(13 rows)
select * from int8_tbl i1 left join (int8_tbl i2 join
(select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2
execute foo(true);
count
-------
- 10000
+ 10998
(1 row)
execute foo(false);
( SELECT COALESCE(q2, -1) AS qq FROM int8_tbl b ) AS ss2
USING (qq)
INNER JOIN tenk1 c ON qq = unique2;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------
Remote Subquery Scan on all
- -> Hash Join
- Hash Cond: (c.unique2 = COALESCE((COALESCE(a.q1, '0'::bigint)), (COALESCE(b.q2, '-1'::bigint))))
- -> Seq Scan on tenk1 c
- -> Hash
- -> Hash Full Join
- Hash Cond: (COALESCE(a.q1, '0'::bigint) = COALESCE(b.q2, '-1'::bigint))
- -> Seq Scan on int8_tbl a
- -> Hash
- -> Seq Scan on int8_tbl b
-(10 rows)
+ -> Nested Loop
+ -> Hash Full Join
+ Hash Cond: (COALESCE(a.q1, '0'::bigint) = COALESCE(b.q2, '-1'::bigint))
+ -> Seq Scan on int8_tbl a
+ -> Hash
+ -> Seq Scan on int8_tbl b
+ -> Index Scan using tenk1_unique2 on tenk1 c
+ Index Cond: (unique2 = COALESCE((COALESCE(a.q1, '0'::bigint)), (COALESCE(b.q2, '-1'::bigint))))
+(9 rows)
SELECT qq, unique1
FROM
) as ss2
on ss2.id = nt3.nt2_id
where nt3.id = 1 and ss2.b3;
- QUERY PLAN
------------------------------------------------------------
- Nested Loop
+ QUERY PLAN
+----------------------------------------------------------------
+ Remote Subquery Scan on all
-> Nested Loop
-> Remote Subquery Scan on all
- -> Index Scan using nt3_pkey on nt3
- Index Cond: (id = 1)
- -> Materialize
- -> Remote Subquery Scan on all
+ Distribute results by H: nt1_id
+ -> Nested Loop
+ -> Remote Subquery Scan on all
+ Distribute results by H: nt2_id
+ -> Index Scan using nt3_pkey on nt3
+ Index Cond: (id = 1)
-> Index Scan using nt2_pkey on nt2
Index Cond: (id = nt3.nt2_id)
- -> Materialize
- -> Remote Subquery Scan on all
- -> Index Only Scan using nt1_pkey on nt1
- Index Cond: (id = nt2.nt1_id)
- Filter: (nt2.b1 AND (id IS NOT NULL))
+ -> Index Only Scan using nt1_pkey on nt1
+ Index Cond: (id = nt2.nt1_id)
+ Filter: (nt2.b1 AND (id IS NOT NULL))
(14 rows)
select nt3.id
left join tenk1 t2
on (subq1.y1 = t2.unique1)
where t1.unique2 < 42 and t1.stringu1 > t2.stringu2;
- QUERY PLAN
------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------
Nested Loop
Join Filter: (t1.stringu1 > t2.stringu2)
-> Nested Loop
Join Filter: ((1) = (1))
-> Result
-> Result
- -> Index Scan using tenk1_unique2 on tenk1 t1
- Index Cond: ((unique2 = (11)) AND (unique2 < 42))
- -> Seq Scan on int4_tbl i1
- -> Index Scan using tenk1_unique1 on tenk1 t2
- Index Cond: (unique1 = (3))
-(14 rows)
+ -> Materialize
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Index Scan using tenk1_unique2 on tenk1 t1
+ Index Cond: ((unique2 = (11)) AND (unique2 < 42))
+ -> Materialize
+ -> Remote Subquery Scan on all (datanode_2)
+ -> Seq Scan on int4_tbl i1
+ -> Materialize
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Index Scan using tenk1_unique1 on tenk1 t2
+ Index Cond: (unique1 = (3))
+(20 rows)
select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from
tenk1 t1
Nested Loop
Join Filter: (((a.unique1 = 1) AND (b.unique1 = 2)) OR ((a.unique2 = 3) AND (b.hundred = 4)))
-> Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Bitmap Heap Scan on tenk1 a
- Recheck Cond: ((unique1 = 1) OR (unique2 = 3))
+ -> Bitmap Heap Scan on tenk1 b
+ Recheck Cond: ((unique1 = 2) OR (hundred = 4))
-> BitmapOr
-> Bitmap Index Scan on tenk1_unique1
- Index Cond: (unique1 = 1)
- -> Bitmap Index Scan on tenk1_unique2
- Index Cond: (unique2 = 3)
+ Index Cond: (unique1 = 2)
+ -> Bitmap Index Scan on tenk1_hundred
+ Index Cond: (hundred = 4)
-> Materialize
-> Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Bitmap Heap Scan on tenk1 b
- Recheck Cond: ((unique1 = 2) OR (hundred = 4))
+ -> Bitmap Heap Scan on tenk1 a
+ Recheck Cond: ((unique1 = 1) OR (unique2 = 3))
-> BitmapOr
-> Bitmap Index Scan on tenk1_unique1
- Index Cond: (unique1 = 2)
- -> Bitmap Index Scan on tenk1_hundred
- Index Cond: (hundred = 4)
+ Index Cond: (unique1 = 1)
+ -> Bitmap Index Scan on tenk1_unique2
+ Index Cond: (unique2 = 3)
(19 rows)
explain (costs off)
Nested Loop
Join Filter: (((a.unique1 = 1) AND (b.unique1 = 2)) OR ((a.unique2 = 3) AND (b.ten = 4)))
-> Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Bitmap Heap Scan on tenk1 a
- Recheck Cond: ((unique1 = 1) OR (unique2 = 3))
- -> BitmapOr
- -> Bitmap Index Scan on tenk1_unique1
- Index Cond: (unique1 = 1)
- -> Bitmap Index Scan on tenk1_unique2
- Index Cond: (unique2 = 3)
+ -> Seq Scan on tenk1 b
+ Filter: ((unique1 = 2) OR (ten = 4))
-> Materialize
-> Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Seq Scan on tenk1 b
- Filter: ((unique1 = 2) OR (ten = 4))
+ -> Bitmap Heap Scan on tenk1 a
+ Recheck Cond: ((unique1 = 1) OR (unique2 = 3))
+ -> BitmapOr
+ -> Bitmap Index Scan on tenk1_unique1
+ Index Cond: (unique1 = 1)
+ -> Bitmap Index Scan on tenk1_unique2
+ Index Cond: (unique2 = 3)
(14 rows)
explain (costs off)
Nested Loop
Join Filter: (((a.unique1 = 1) AND (b.unique1 = 2)) OR (((a.unique2 = 3) OR (a.unique2 = 7)) AND (b.hundred = 4)))
-> Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Bitmap Heap Scan on tenk1 a
- Recheck Cond: ((unique1 = 1) OR (unique2 = 3) OR (unique2 = 7))
+ -> Bitmap Heap Scan on tenk1 b
+ Recheck Cond: ((unique1 = 2) OR (hundred = 4))
-> BitmapOr
-> Bitmap Index Scan on tenk1_unique1
- Index Cond: (unique1 = 1)
- -> Bitmap Index Scan on tenk1_unique2
- Index Cond: (unique2 = 3)
- -> Bitmap Index Scan on tenk1_unique2
- Index Cond: (unique2 = 7)
+ Index Cond: (unique1 = 2)
+ -> Bitmap Index Scan on tenk1_hundred
+ Index Cond: (hundred = 4)
-> Materialize
-> Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Bitmap Heap Scan on tenk1 b
- Recheck Cond: ((unique1 = 2) OR (hundred = 4))
+ -> Bitmap Heap Scan on tenk1 a
+ Recheck Cond: ((unique1 = 1) OR (unique2 = 3) OR (unique2 = 7))
-> BitmapOr
-> Bitmap Index Scan on tenk1_unique1
- Index Cond: (unique1 = 2)
- -> Bitmap Index Scan on tenk1_hundred
- Index Cond: (hundred = 4)
+ Index Cond: (unique1 = 1)
+ -> Bitmap Index Scan on tenk1_unique2
+ Index Cond: (unique2 = 3)
+ -> Bitmap Index Scan on tenk1_unique2
+ Index Cond: (unique2 = 7)
(21 rows)
--
(tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2)
on t1.hundred = t2.hundred and t1.ten = t3.ten
where t1.unique1 = 1;
- QUERY PLAN
---------------------------------------------------------------------
- Nested Loop Left Join
- -> Remote Subquery Scan on all
- -> Bitmap Heap Scan on tenk1 t1
- Recheck Cond: (unique1 = 1)
- -> Bitmap Index Scan on tenk1_unique1
- Index Cond: (unique1 = 1)
- -> Nested Loop
- Join Filter: (t1.ten = t3.ten)
+ QUERY PLAN
+--------------------------------------------------------------------------------------
+ Remote Subquery Scan on all
+ -> Nested Loop Left Join
-> Remote Subquery Scan on all
- -> Index Scan using tenk1_hundred on tenk1 t2
- Index Cond: (t1.hundred = hundred)
+ Distribute results by H: hundred
+ -> Index Scan using tenk1_unique1 on tenk1 t1
+ Index Cond: (unique1 = 1)
-> Materialize
-> Remote Subquery Scan on all
- -> Index Scan using tenk1_unique2 on tenk1 t3
- Index Cond: (unique2 = t2.thousand)
-(15 rows)
+ Distribute results by H: hundred
+ -> Nested Loop
+ Join Filter: (t1.ten = t3.ten)
+ -> Remote Subquery Scan on all
+ Distribute results by H: thousand
+ -> Bitmap Heap Scan on tenk1 t2
+ Recheck Cond: (t1.hundred = hundred)
+ -> Bitmap Index Scan on tenk1_hundred
+ Index Cond: (t1.hundred = hundred)
+ -> Materialize
+ -> Remote Subquery Scan on all
+ Distribute results by H: unique2
+ -> Index Scan using tenk1_unique2 on tenk1 t3
+ Index Cond: (unique2 = t2.thousand)
+(22 rows)
explain (num_nodes off, nodes off, costs off)
select * from tenk1 t1 left join
(tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2)
on t1.hundred = t2.hundred and t1.ten + t2.ten = t3.ten
where t1.unique1 = 1;
- QUERY PLAN
---------------------------------------------------------------------
- Nested Loop Left Join
- -> Remote Subquery Scan on all
- -> Bitmap Heap Scan on tenk1 t1
- Recheck Cond: (unique1 = 1)
- -> Bitmap Index Scan on tenk1_unique1
- Index Cond: (unique1 = 1)
- -> Nested Loop
- Join Filter: ((t1.ten + t2.ten) = t3.ten)
+ QUERY PLAN
+--------------------------------------------------------------------------------------
+ Remote Subquery Scan on all
+ -> Nested Loop Left Join
-> Remote Subquery Scan on all
- -> Index Scan using tenk1_hundred on tenk1 t2
- Index Cond: (t1.hundred = hundred)
+ Distribute results by H: hundred
+ -> Index Scan using tenk1_unique1 on tenk1 t1
+ Index Cond: (unique1 = 1)
-> Materialize
-> Remote Subquery Scan on all
- -> Index Scan using tenk1_unique2 on tenk1 t3
- Index Cond: (unique2 = t2.thousand)
-(15 rows)
+ Distribute results by H: hundred
+ -> Nested Loop
+ Join Filter: ((t1.ten + t2.ten) = t3.ten)
+ -> Remote Subquery Scan on all
+ Distribute results by H: thousand
+ -> Bitmap Heap Scan on tenk1 t2
+ Recheck Cond: (t1.hundred = hundred)
+ -> Bitmap Index Scan on tenk1_hundred
+ Index Cond: (t1.hundred = hundred)
+ -> Materialize
+ -> Remote Subquery Scan on all
+ Distribute results by H: unique2
+ -> Index Scan using tenk1_unique2 on tenk1 t3
+ Index Cond: (unique2 = t2.thousand)
+(22 rows)
explain (num_nodes off, nodes off, costs off)
select count(*) from
tenk1 a join tenk1 b on a.unique1 = b.unique2
left join tenk1 c on a.unique2 = b.unique1 and c.thousand = a.thousand
join int4_tbl on b.thousand = f1;
- QUERY PLAN
--------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------
Aggregate
- -> Merge Left Join
- Merge Cond: (a.thousand = c.thousand)
- Join Filter: (a.unique2 = b.unique1)
- -> Sort
- Sort Key: a.thousand
- -> Nested Loop
+ -> Remote Subquery Scan on all
+ -> Aggregate
+ -> Nested Loop Left Join
+ Join Filter: (a.unique2 = b.unique1)
-> Remote Subquery Scan on all
- -> Hash Join
- Hash Cond: (b.thousand = int4_tbl.f1)
- -> Seq Scan on tenk1 b
- -> Hash
- -> Seq Scan on int4_tbl
- -> Materialize
- -> Remote Subquery Scan on all
+ Distribute results by H: thousand
+ -> Nested Loop
+ -> Remote Subquery Scan on all
+ Distribute results by H: unique2
+ -> Nested Loop
+ -> Seq Scan on int4_tbl
+ -> Bitmap Heap Scan on tenk1 b
+ Recheck Cond: (thousand = int4_tbl.f1)
+ -> Bitmap Index Scan on tenk1_thous_tenthous
+ Index Cond: (thousand = int4_tbl.f1)
-> Index Scan using tenk1_unique1 on tenk1 a
Index Cond: (unique1 = b.unique2)
- -> Materialize
- -> Remote Subquery Scan on all
- -> Sort
- Sort Key: c.thousand
- -> Seq Scan on tenk1 c
-(22 rows)
+ -> Materialize
+ -> Remote Subquery Scan on all
+ Distribute results by H: thousand
+ -> Index Only Scan using tenk1_thous_tenthous on tenk1 c
+ Index Cond: (thousand = a.thousand)
+(23 rows)
select count(*) from
tenk1 a join tenk1 b on a.unique1 = b.unique2
join int4_tbl i1 on b.thousand = f1
right join int4_tbl i2 on i2.f1 = b.tenthous
order by 1;
- QUERY PLAN
------------------------------------------------------------------------------------------------
- Sort
- Sort Key: b.unique1
- -> Nested Loop Left Join
- -> Remote Subquery Scan on all
- -> Seq Scan on int4_tbl i2
- -> Nested Loop Left Join
- Join Filter: (b.unique1 = 42)
- -> Nested Loop
- -> Remote Subquery Scan on all
- -> Nested Loop
- -> Seq Scan on int4_tbl i1
- -> Index Scan using tenk1_thous_tenthous on tenk1 b
- Index Cond: ((thousand = i1.f1) AND (i2.f1 = tenthous))
- -> Materialize
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------
+ Remote Subquery Scan on all
+ -> Sort
+ Sort Key: b.unique1
+ -> Hash Right Join
+ Hash Cond: (b.tenthous = i2.f1)
+ -> Remote Subquery Scan on all
+ Distribute results by H: tenthous
+ -> Nested Loop Left Join
+ Join Filter: (b.unique1 = (42))
-> Remote Subquery Scan on all
- -> Index Scan using tenk1_unique1 on tenk1 a
- Index Cond: (unique1 = b.unique2)
- -> Materialize
+ Distribute results by H: unique1
+ -> Nested Loop
+ -> Remote Subquery Scan on all
+ Distribute results by H: unique2
+ -> Nested Loop
+ -> Seq Scan on int4_tbl i1
+ -> Bitmap Heap Scan on tenk1 b
+ Recheck Cond: (thousand = i1.f1)
+ -> Bitmap Index Scan on tenk1_thous_tenthous
+ Index Cond: (thousand = i1.f1)
+ -> Index Scan using tenk1_unique1 on tenk1 a
+ Index Cond: (unique1 = b.unique2)
+ -> Materialize
+ -> Remote Subquery Scan on all
+ Distribute results by H: 42
+ -> Index Only Scan using tenk1_thous_tenthous on tenk1 c
+ Index Cond: (thousand = a.thousand)
+ -> Hash
-> Remote Subquery Scan on all
- -> Index Only Scan using tenk1_thous_tenthous on tenk1 c
- Index Cond: (thousand = a.thousand)
-(21 rows)
+ Distribute results by H: f1
+ -> Seq Scan on int4_tbl i2
+(31 rows)
select b.unique1 from
tenk1 a join tenk1 b on a.unique1 = b.unique2
order by fault;
QUERY PLAN
--------------------------------------------------------------------------
- Hash Right Join
- Hash Cond: (tenk1.unique2 = int8_tbl.q2)
+ Nested Loop Left Join
Filter: ((COALESCE(tenk1.unique1, '-1'::integer) + int8_tbl.q1) = 122)
-> Remote Subquery Scan on all
- -> Seq Scan on tenk1
- -> Hash
+ -> Seq Scan on int8_tbl
+ -> Materialize
-> Remote Subquery Scan on all
- -> Seq Scan on int8_tbl
+ -> Index Scan using tenk1_unique2 on tenk1
+ Index Cond: (int8_tbl.q2 = unique2)
(8 rows)
select * from
where coalesce(thousand,123) = q1 and q1 = coalesce(hundred,123);
QUERY PLAN
--------------------------------------------------------------------------------------
- Hash Right Join
- Hash Cond: (b.unique2 = a.q1)
+ Nested Loop Left Join
Filter: ((COALESCE(b.thousand, 123) = a.q1) AND (a.q1 = COALESCE(b.hundred, 123)))
-> Remote Subquery Scan on all
- -> Seq Scan on tenk1 b
- -> Hash
+ -> Seq Scan on int8_tbl a
+ -> Materialize
-> Remote Subquery Scan on all
- -> Seq Scan on int8_tbl a
+ -> Index Scan using tenk1_unique2 on tenk1 b
+ Index Cond: (a.q1 = unique2)
(8 rows)
select q1, unique2, thousand, hundred
QUERY PLAN
--------------------------------------------------------------------------
Remote Subquery Scan on all
- -> Hash Right Join
- Hash Cond: (b.unique2 = a.f1)
+ -> Nested Loop Left Join
Filter: (CASE WHEN (b.unique2 IS NULL) THEN a.f1 ELSE 0 END = 0)
-> Remote Subquery Scan on all
- Distribute results by H: unique2
- -> Seq Scan on tenk1 b
- -> Hash
+ Distribute results by H: f1
+ -> Seq Scan on int4_tbl a
+ -> Materialize
-> Remote Subquery Scan on all
- Distribute results by H: f1
- -> Seq Scan on int4_tbl a
+ Distribute results by H: unique2
+ -> Index Only Scan using tenk1_unique2 on tenk1 b
+ Index Cond: (unique2 = a.f1)
(11 rows)
select f1, unique2, case when unique2 is null then f1 else 0 end
select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand)
from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand)
where a.unique2 < 10 and coalesce(b.twothousand, a.twothousand) = 44;
- QUERY PLAN
------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------
Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Hash Left Join
- Hash Cond: ((COALESCE(b.twothousand, a.twothousand)) = c.unique2)
+ -> Nested Loop Left Join
-> Remote Subquery Scan on all (datanode_1,datanode_2)
Distribute results by H: COALESCE(twothousand, twothousand)
- -> Merge Left Join
- Merge Cond: (a.unique1 = b.thousand)
+ -> Nested Loop Left Join
Filter: (COALESCE(b.twothousand, a.twothousand) = 44)
- -> Sort
- Sort Key: a.unique1
- -> Bitmap Heap Scan on tenk1 a
- Recheck Cond: (unique2 < 10)
- -> Bitmap Index Scan on tenk1_unique2
- Index Cond: (unique2 < 10)
+ -> Index Scan using tenk1_unique2 on tenk1 a
+ Index Cond: (unique2 < 10)
-> Materialize
-> Remote Subquery Scan on all (datanode_1,datanode_2)
Distribute results by H: thousand
- -> Sort
- Sort Key: b.thousand
- -> Seq Scan on tenk1 b
- -> Hash
+ -> Bitmap Heap Scan on tenk1 b
+ Recheck Cond: (thousand = a.unique1)
+ -> Bitmap Index Scan on tenk1_thous_tenthous
+ Index Cond: (thousand = a.unique1)
+ -> Materialize
-> Remote Subquery Scan on all (datanode_1,datanode_2)
Distribute results by H: unique2
- -> Bitmap Heap Scan on tenk1 c
- Recheck Cond: (unique2 = 44)
- -> Bitmap Index Scan on tenk1_unique2
- Index Cond: (unique2 = 44)
-(27 rows)
+ -> Index Scan using tenk1_unique2 on tenk1 c
+ Index Cond: ((unique2 = COALESCE(b.twothousand, a.twothousand)) AND (unique2 = 44))
+(20 rows)
select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand)
from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand)
using (join_key)
) foo3
using (join_key);
- QUERY PLAN
------------------------------------------------------------------------
- Hash Right Join
+ QUERY PLAN
+--------------------------------------------------------------------------------------------
+ Nested Loop Left Join
Output: "*VALUES*".column1, i1.f1, (666)
- Hash Cond: (i1.f1 = "*VALUES*".column1)
- -> Remote Subquery Scan on all (datanode_1,datanode_2)
- Output: i1.f1, 666
- -> Hash Right Join
+ Join Filter: ("*VALUES*".column1 = i1.f1)
+ -> Values Scan on "*VALUES*"
+ Output: "*VALUES*".column1
+ -> Materialize
+ Output: i1.f1, (666)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
Output: i1.f1, 666
- Hash Cond: (i2.unique2 = i1.f1)
- -> Remote Subquery Scan on all (datanode_1,datanode_2)
- Output: i2.unique2
- Distribute results by H: unique2
- -> Seq Scan on public.tenk1 i2
- Output: i2.unique2
- -> Hash
- Output: i1.f1
+ -> Nested Loop Left Join
+ Output: i1.f1, 666
-> Remote Subquery Scan on all (datanode_1)
Output: i1.f1
Distribute results by H: f1
-> Seq Scan on public.int4_tbl i1
Output: i1.f1
- -> Hash
- Output: "*VALUES*".column1
- -> Values Scan on "*VALUES*"
- Output: "*VALUES*".column1
+ -> Materialize
+ Output: i2.unique2
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ Output: i2.unique2
+ Distribute results by H: unique2
+ -> Index Only Scan using tenk1_unique2 on public.tenk1 i2
+ Output: i2.unique2
+ Index Cond: (i2.unique2 = i1.f1)
(24 rows)
select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
- QUERY PLAN
-----------------------------------------------------------------------
- Hash Left Join
+ QUERY PLAN
+----------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
Output: t1.f1
- Hash Cond: (i8.q2 = i4.f1)
- -> Nested Loop Left Join
- Output: t1.f1, i8.q2
- Join Filter: (t1.f1 = '***'::text)
- -> Seq Scan on public.text_tbl t1
- Output: t1.f1
- -> Materialize
- Output: i8.q2
- -> Hash Right Join
+ -> Hash Left Join
+ Output: t1.f1
+ Hash Cond: (i8.q2 = i4.f1)
+ -> Nested Loop Left Join
+ Output: t1.f1, i8.q2
+ Join Filter: (t1.f1 = '***'::text)
+ -> Seq Scan on public.text_tbl t1
+ Output: t1.f1
+ -> Materialize
Output: i8.q2
- Hash Cond: ((NULL::integer) = i8b1.q2)
- -> Hash Left Join
- Output: i8.q2, (NULL::integer)
- Hash Cond: (i8.q1 = i8b2.q1)
- -> Seq Scan on public.int8_tbl i8
- Output: i8.q1, i8.q2
+ -> Hash Right Join
+ Output: i8.q2
+ Hash Cond: ((NULL::integer) = i8b1.q2)
+ -> Hash Left Join
+ Output: i8.q2, (NULL::integer)
+ Hash Cond: (i8.q1 = i8b2.q1)
+ -> Seq Scan on public.int8_tbl i8
+ Output: i8.q1, i8.q2
+ -> Hash
+ Output: i8b2.q1, (NULL::integer)
+ -> Seq Scan on public.int8_tbl i8b2
+ Output: i8b2.q1, NULL::integer
-> Hash
- Output: i8b2.q1, (NULL::integer)
- -> Seq Scan on public.int8_tbl i8b2
- Output: i8b2.q1, NULL::integer
- -> Hash
- Output: i8b1.q2
- -> Seq Scan on public.int8_tbl i8b1
Output: i8b1.q2
- -> Hash
- Output: i4.f1
- -> Seq Scan on public.int4_tbl i4
+ -> Seq Scan on public.int8_tbl i8b1
+ Output: i8b1.q2
+ -> Hash
Output: i4.f1
-(30 rows)
+ -> Seq Scan on public.int4_tbl i4
+ Output: i4.f1
+(32 rows)
select t1.* from
text_tbl t1
on (i8.q2 = i4.f1);
f1
-------------------
- doh!
hi de ho neighbor
+ doh!
(2 rows)
explain (verbose, costs off)
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
- QUERY PLAN
-----------------------------------------------------------------------------
- Hash Left Join
+ QUERY PLAN
+----------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
Output: t1.f1
- Hash Cond: (i8.q2 = i4.f1)
- -> Nested Loop Left Join
- Output: t1.f1, i8.q2
- Join Filter: (t1.f1 = '***'::text)
- -> Seq Scan on public.text_tbl t1
- Output: t1.f1
- -> Materialize
- Output: i8.q2
- -> Hash Right Join
+ -> Hash Left Join
+ Output: t1.f1
+ Hash Cond: (i8.q2 = i4.f1)
+ -> Nested Loop Left Join
+ Output: t1.f1, i8.q2
+ Join Filter: (t1.f1 = '***'::text)
+ -> Seq Scan on public.text_tbl t1
+ Output: t1.f1
+ -> Materialize
Output: i8.q2
- Hash Cond: ((NULL::integer) = i8b1.q2)
-> Hash Right Join
- Output: i8.q2, (NULL::integer)
- Hash Cond: (i8b2.q1 = i8.q1)
- -> Nested Loop
- Output: i8b2.q1, NULL::integer
- -> Seq Scan on public.int8_tbl i8b2
- Output: i8b2.q1, i8b2.q2
- -> Materialize
- -> Seq Scan on public.int4_tbl i4b2
- -> Hash
- Output: i8.q1, i8.q2
- -> Seq Scan on public.int8_tbl i8
+ Output: i8.q2
+ Hash Cond: ((NULL::integer) = i8b1.q2)
+ -> Hash Right Join
+ Output: i8.q2, (NULL::integer)
+ Hash Cond: (i8b2.q1 = i8.q1)
+ -> Nested Loop
+ Output: i8b2.q1, NULL::integer
+ -> Seq Scan on public.int8_tbl i8b2
+ Output: i8b2.q1, i8b2.q2
+ -> Materialize
+ -> Seq Scan on public.int4_tbl i4b2
+ -> Hash
Output: i8.q1, i8.q2
- -> Hash
- Output: i8b1.q2
- -> Seq Scan on public.int8_tbl i8b1
+ -> Seq Scan on public.int8_tbl i8
+ Output: i8.q1, i8.q2
+ -> Hash
Output: i8b1.q2
- -> Hash
- Output: i4.f1
- -> Seq Scan on public.int4_tbl i4
+ -> Seq Scan on public.int8_tbl i8b1
+ Output: i8b1.q2
+ -> Hash
Output: i4.f1
-(34 rows)
+ -> Seq Scan on public.int4_tbl i4
+ Output: i4.f1
+(36 rows)
select t1.* from
text_tbl t1
on (i8.q2 = i4.f1);
f1
-------------------
- doh!
hi de ho neighbor
+ doh!
(2 rows)
explain (verbose, costs off)
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
- QUERY PLAN
-----------------------------------------------------------------------------
- Hash Left Join
+ QUERY PLAN
+----------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
Output: t1.f1
- Hash Cond: (i8.q2 = i4.f1)
- -> Nested Loop Left Join
- Output: t1.f1, i8.q2
- Join Filter: (t1.f1 = '***'::text)
- -> Seq Scan on public.text_tbl t1
- Output: t1.f1
- -> Materialize
- Output: i8.q2
- -> Hash Right Join
+ -> Hash Left Join
+ Output: t1.f1
+ Hash Cond: (i8.q2 = i4.f1)
+ -> Nested Loop Left Join
+ Output: t1.f1, i8.q2
+ Join Filter: (t1.f1 = '***'::text)
+ -> Seq Scan on public.text_tbl t1
+ Output: t1.f1
+ -> Materialize
Output: i8.q2
- Hash Cond: ((NULL::integer) = i8b1.q2)
-> Hash Right Join
- Output: i8.q2, (NULL::integer)
- Hash Cond: (i8b2.q1 = i8.q1)
- -> Hash Join
- Output: i8b2.q1, NULL::integer
- Hash Cond: (i8b2.q1 = i4b2.f1)
- -> Seq Scan on public.int8_tbl i8b2
- Output: i8b2.q1, i8b2.q2
- -> Hash
- Output: i4b2.f1
- -> Seq Scan on public.int4_tbl i4b2
+ Output: i8.q2
+ Hash Cond: ((NULL::integer) = i8b1.q2)
+ -> Hash Right Join
+ Output: i8.q2, (NULL::integer)
+ Hash Cond: (i8b2.q1 = i8.q1)
+ -> Hash Join
+ Output: i8b2.q1, NULL::integer
+ Hash Cond: (i8b2.q1 = i4b2.f1)
+ -> Seq Scan on public.int8_tbl i8b2
+ Output: i8b2.q1, i8b2.q2
+ -> Hash
Output: i4b2.f1
- -> Hash
- Output: i8.q1, i8.q2
- -> Seq Scan on public.int8_tbl i8
+ -> Seq Scan on public.int4_tbl i4b2
+ Output: i4b2.f1
+ -> Hash
Output: i8.q1, i8.q2
- -> Hash
- Output: i8b1.q2
- -> Seq Scan on public.int8_tbl i8b1
+ -> Seq Scan on public.int8_tbl i8
+ Output: i8.q1, i8.q2
+ -> Hash
Output: i8b1.q2
- -> Hash
- Output: i4.f1
- -> Seq Scan on public.int4_tbl i4
+ -> Seq Scan on public.int8_tbl i8b1
+ Output: i8b1.q2
+ -> Hash
Output: i4.f1
-(37 rows)
+ -> Seq Scan on public.int4_tbl i4
+ Output: i4.f1
+(39 rows)
select t1.* from
text_tbl t1
on (i8.q2 = i4.f1);
f1
-------------------
- doh!
hi de ho neighbor
+ doh!
(2 rows)
explain (verbose, costs off)
on t1.f1 = 'doh!'
left join int4_tbl i4
on i8.q1 = i4.f1;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------
Nested Loop Left Join
Output: t1.f1, i8.q1, i8.q2, t2.f1, i4.f1
- -> Seq Scan on public.text_tbl t2
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
Output: t2.f1
+ -> Seq Scan on public.text_tbl t2
+ Output: t2.f1
-> Materialize
Output: i8.q1, i8.q2, i4.f1, t1.f1
- -> Nested Loop
+ -> Remote Subquery Scan on all (datanode_2)
Output: i8.q1, i8.q2, i4.f1, t1.f1
- -> Nested Loop Left Join
- Output: i8.q1, i8.q2, i4.f1
- Join Filter: (i8.q1 = i4.f1)
- -> Seq Scan on public.int8_tbl i8
- Output: i8.q1, i8.q2
- Filter: (i8.q2 = 456)
- -> Seq Scan on public.int4_tbl i4
- Output: i4.f1
- -> Seq Scan on public.text_tbl t1
- Output: t1.f1
- Filter: (t1.f1 = 'doh!'::text)
-(19 rows)
+ -> Nested Loop
+ Output: i8.q1, i8.q2, i4.f1, t1.f1
+ -> Nested Loop Left Join
+ Output: i8.q1, i8.q2, i4.f1
+ Join Filter: (i8.q1 = i4.f1)
+ -> Seq Scan on public.int8_tbl i8
+ Output: i8.q1, i8.q2
+ Filter: (i8.q2 = 456)
+ -> Seq Scan on public.int4_tbl i4
+ Output: i4.f1
+ -> Seq Scan on public.text_tbl t1
+ Output: t1.f1
+ Filter: (t1.f1 = 'doh!'::text)
+(23 rows)
select * from
text_tbl t1
on i8.q1 = i4.f1;
f1 | q1 | q2 | f1 | f1
------+-----+-----+-------------------+----
- doh! | 123 | 456 | doh! |
doh! | 123 | 456 | hi de ho neighbor |
+ doh! | 123 | 456 | doh! |
(2 rows)
--
--
explain (num_nodes off, nodes off, costs off)
select * from int4_tbl a left join tenk1 b on f1 = unique2 where f1 = 0;
- QUERY PLAN
-------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------
Remote Subquery Scan on all
-> Nested Loop Left Join
Join Filter: (a.f1 = b.unique2)
-> Materialize
-> Remote Subquery Scan on all
Distribute results by H: unique2
- -> Bitmap Heap Scan on tenk1 b
- Recheck Cond: (unique2 = 0)
- -> Bitmap Index Scan on tenk1_unique2
- Index Cond: (unique2 = 0)
-(14 rows)
+ -> Index Scan using tenk1_unique2 on tenk1 b
+ Index Cond: (unique2 = 0)
+(12 rows)
explain (num_nodes off, nodes off, costs off)
select * from tenk1 a full join tenk1 b using(unique2) where unique2 = 42;
- QUERY PLAN
-------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------
Remote Subquery Scan on all
- -> Hash Full Join
- Hash Cond: (a.unique2 = b.unique2)
+ -> Merge Full Join
+ Merge Cond: (a.unique2 = b.unique2)
-> Remote Subquery Scan on all
Distribute results by H: unique2
- -> Bitmap Heap Scan on tenk1 a
- Recheck Cond: (unique2 = 42)
- -> Bitmap Index Scan on tenk1_unique2
- Index Cond: (unique2 = 42)
- -> Hash
+ -> Index Scan using tenk1_unique2 on tenk1 a
+ Index Cond: (unique2 = 42)
+ -> Materialize
-> Remote Subquery Scan on all
Distribute results by H: unique2
- -> Bitmap Heap Scan on tenk1 b
- Recheck Cond: (unique2 = 42)
- -> Bitmap Index Scan on tenk1_unique2
- Index Cond: (unique2 = 42)
-(16 rows)
+ -> Index Scan using tenk1_unique2 on tenk1 b
+ Index Cond: (unique2 = 42)
+(12 rows)
--
-- test that quals attached to an outer join have correct semantics,
select a.q2, b.q1
from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1)
where coalesce(b.q1, 1) > 0;
- QUERY PLAN
----------------------------------------------------------------
- Remote Subquery Scan on all (datanode_1)
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Remote Fast Query Execution
Output: a.q2, b.q1
+ Node/s: datanode_2
+ Remote query: SELECT a.q2, b.q1 FROM (int8_tbl a LEFT JOIN int8_tbl b ON ((a.q2 = COALESCE(b.q1, (1)::bigint)))) WHERE (COALESCE(b.q1, (1)::bigint) > 0)
-> Merge Left Join
Output: a.q2, b.q1
Merge Cond: (a.q2 = (COALESCE(b.q1, '1'::bigint)))
Sort Key: (COALESCE(b.q1, '1'::bigint))
-> Seq Scan on public.int8_tbl b
Output: b.q1, COALESCE(b.q1, '1'::bigint)
-(16 rows)
+(18 rows)
select a.q2, b.q1
from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1)
on i8.q1 = i4.f1;
QUERY PLAN
------------------------------------------
- Remote Subquery Scan on all (datanode_1)
+ Remote Subquery Scan on all (datanode_2)
-> Seq Scan on int8_tbl i8
(2 rows)
select p.* from
parent p left join child c on (p.k = c.k)
where p.k = 1 and p.k = 2;
- QUERY PLAN
-----------------------------------------------------------------
- Remote Subquery Scan on all
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------
+ Remote Fast Query Execution
Output: p.k, p.pd
+ Remote query: SELECT p.k, p.pd FROM (parent p LEFT JOIN child c ON ((p.k = c.k))) WHERE ((p.k = 1) AND (p.k = 2))
-> Result
Output: p.k, p.pd
One-Time Filter: false
- -> Index Scan using parent_pkey on pg_temp_2.parent p
+ -> Index Scan using parent_pkey on pg_temp_4.parent p
Output: p.k, p.pd
Index Cond: (p.k = 1)
-(8 rows)
+(9 rows)
select p.* from
(parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k
select p.* from
(parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k
where p.k = 1 and p.k = 2;
- QUERY PLAN
---------------------------
- Result
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------
+ Remote Fast Query Execution
Output: p.k, p.pd
- One-Time Filter: false
-(3 rows)
+ Remote query: SELECT p.k, p.pd FROM ((parent p LEFT JOIN child c ON ((p.k = c.k))) JOIN parent x ON ((p.k = x.k))) WHERE ((p.k = 1) AND (p.k = 2))
+ -> Result
+ Output: p.k, p.pd
+ One-Time Filter: false
+(6 rows)
-- bug 5255: this is not optimizable by join removal
begin;
on t1.f1 = t2.f1
left join uniquetbl t3
on t2.d1 = t3.f1;
- QUERY PLAN
---------------------------
- Seq Scan on uniquetbl t1
-(1 row)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on uniquetbl t1
+(2 rows)
explain (costs off)
select t0.*
left join uniquetbl u1 ON u1.f1 = t1.string4) ss
on t0.f1 = ss.case1
where ss.stringu2 !~* ss.case1;
- QUERY PLAN
---------------------------------------------------------------------------------------------
- Nested Loop
- Join Filter: (CASE t1.ten WHEN 0 THEN 'doh!'::text ELSE NULL::text END = t0.f1)
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
-> Nested Loop
- -> Seq Scan on int4_tbl i4
- -> Index Scan using tenk1_unique2 on tenk1 t1
- Index Cond: (unique2 = i4.f1)
- Filter: (stringu2 !~* CASE ten WHEN 0 THEN 'doh!'::text ELSE NULL::text END)
- -> Materialize
- -> Seq Scan on text_tbl t0
-(9 rows)
+ Join Filter: ((CASE t1.ten WHEN 0 THEN 'doh!'::text ELSE NULL::text END) = t0.f1)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ Distribute results by H: CASE ten WHEN 0 THEN 'doh!'::text ELSE NULL::text END
+ -> Nested Loop
+ -> Seq Scan on int4_tbl i4
+ -> Index Scan using tenk1_unique2 on tenk1 t1
+ Index Cond: (unique2 = i4.f1)
+ Filter: (stringu2 !~* CASE ten WHEN 0 THEN 'doh!'::text ELSE NULL::text END)
+ -> Materialize
+ -> Seq Scan on text_tbl t0
+(12 rows)
select t0.*
from
explain (costs off)
select unique2, x.*
from tenk1 a, lateral (select * from int4_tbl b where f1 = a.unique1) x;
- QUERY PLAN
------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------
Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Hash Join
- Hash Cond: (a.unique1 = b.f1)
- -> Seq Scan on tenk1 a
- -> Hash
- -> Seq Scan on int4_tbl b
-(6 rows)
+ -> Nested Loop
+ -> Seq Scan on int4_tbl b
+ -> Index Scan using tenk1_unique1 on tenk1 a
+ Index Cond: (unique1 = b.f1)
+(5 rows)
select unique2, x.*
from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss;
QUERY PLAN
-----------------------------------------------------
Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Hash Join
- Hash Cond: (tenk1.unique1 = x.f1)
- -> Seq Scan on tenk1
- -> Hash
- -> Seq Scan on int4_tbl x
-(6 rows)
+ -> Nested Loop
+ -> Seq Scan on int4_tbl x
+ -> Index Scan using tenk1_unique1 on tenk1
+ Index Cond: (unique1 = x.f1)
+(5 rows)
explain (costs off)
select unique2, x.*
QUERY PLAN
-----------------------------------------------------
Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Hash Join
- Hash Cond: (tenk1.unique1 = x.f1)
- -> Seq Scan on tenk1
- -> Hash
- -> Seq Scan on int4_tbl x
-(6 rows)
+ -> Nested Loop
+ -> Seq Scan on int4_tbl x
+ -> Index Scan using tenk1_unique1 on tenk1
+ Index Cond: (unique1 = x.f1)
+(5 rows)
select unique2, x.*
from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true;
unique2 | f1
---------+-------------
- | -2147483647
| 123456
+ | -2147483647
9998 | 0
- | 2147483647
| -123456
+ | 2147483647
(5 rows)
explain (costs off)
select unique2, x.*
from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true;
- QUERY PLAN
-------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------
Remote Subquery Scan on all (datanode_1,datanode_2)
- -> Hash Right Join
- Hash Cond: (tenk1.unique1 = x.f1)
- -> Seq Scan on tenk1
- -> Hash
- -> Remote Subquery Scan on all (datanode_2)
- Distribute results by H: f1
- -> Seq Scan on int4_tbl x
-(8 rows)
+ -> Nested Loop Left Join
+ -> Remote Subquery Scan on all (datanode_2)
+ Distribute results by H: f1
+ -> Seq Scan on int4_tbl x
+ -> Index Scan using tenk1_unique1 on tenk1
+ Index Cond: (x.f1 = unique1)
+(7 rows)
-- check scoping of lateral versus parent references
-- the first of these should return int8_tbl.q2, the second int8_tbl.q1
explain (num_nodes off, nodes off, costs off)
select count(*) from tenk1 a,
tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x;
- QUERY PLAN
-------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------
Aggregate
-> Remote Subquery Scan on all
-> Aggregate
- -> Merge Join
- Merge Cond: (b.unique2 = a.unique1)
- -> Remote Subquery Scan on all
- Distribute results by H: unique2
- -> Sort
- Sort Key: b.unique2
+ -> Hash Join
+ Hash Cond: (a.unique1 = b.unique2)
+ -> Seq Scan on tenk1 a
+ -> Hash
+ -> Remote Subquery Scan on all
+ Distribute results by H: unique2
-> Seq Scan on tenk1 b
- -> Sort
- Sort Key: a.unique1
- -> Seq Scan on tenk1 a
-(13 rows)
+(10 rows)
select count(*) from tenk1 a,
tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x;
explain (num_nodes off, nodes off, costs off)
select count(*) from tenk1 a,
tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x;
- QUERY PLAN
-------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------
Aggregate
- -> Merge Join
- Merge Cond: (b.unique2 = "*VALUES*".column1)
- -> Remote Subquery Scan on all
- -> Sort
- Sort Key: b.unique2
+ -> Hash Join
+ Hash Cond: ("*VALUES*".column1 = b.unique2)
+ -> Nested Loop
+ -> Remote Subquery Scan on all
+ -> Seq Scan on tenk1 a
+ -> Values Scan on "*VALUES*"
+ -> Hash
+ -> Remote Subquery Scan on all
-> Seq Scan on tenk1 b
- -> Sort
- Sort Key: "*VALUES*".column1
- -> Nested Loop
- -> Remote Subquery Scan on all
- -> Seq Scan on tenk1 a
- -> Values Scan on "*VALUES*"
-(13 rows)
+(10 rows)
select count(*) from tenk1 a,
tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x;
lateral (select *, coalesce(a.q2, 42) as x from int8_tbl b) ss on a.q2 = ss.q1;
QUERY PLAN
------------------------------------------------------------------------
- Remote Subquery Scan on all (datanode_2)
+ Remote Subquery Scan on all (datanode_1)
Output: a.q1, a.q2, b.q1, b.q2, COALESCE(a.q2, '42'::bigint)
-> Nested Loop Left Join
Output: a.q1, a.q2, b.q1, b.q2, (COALESCE(a.q2, '42'::bigint))
lateral (select f1 from int4_tbl
where f1 = any (select unique1 from tenk1
where unique2 = v.x offset 0)) ss;
- QUERY PLAN
-----------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------
Nested Loop
Output: "*VALUES*".column1, "*VALUES*".column2, int4_tbl.f1
-> Values Scan on "*VALUES*"
Output: "*VALUES*".column1, "*VALUES*".column2
- -> Nested Loop Semi Join
+ -> Materialize
Output: int4_tbl.f1
- Join Filter: (int4_tbl.f1 = tenk1.unique1)
- -> Seq Scan on public.int4_tbl
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
Output: int4_tbl.f1
- -> Materialize
- Output: tenk1.unique1
- -> Index Scan using tenk1_unique2 on public.tenk1
- Output: tenk1.unique1
- Index Cond: (tenk1.unique2 = "*VALUES*".column2)
-(14 rows)
+ -> Nested Loop Semi Join
+ Output: int4_tbl.f1
+ Join Filter: (int4_tbl.f1 = tenk1.unique1)
+ -> Remote Subquery Scan on all (datanode_2)
+ Output: int4_tbl.f1
+ Distribute results by H: f1
+ -> Seq Scan on public.int4_tbl
+ Output: int4_tbl.f1
+ -> Materialize
+ Output: tenk1.unique1
+ -> Index Scan using tenk1_unique2 on public.tenk1
+ Output: tenk1.unique1
+ Index Cond: (tenk1.unique2 = "*VALUES*".column2)
+(21 rows)
select * from
(values (0,9998), (1,1000)) v(id,x),
SELECT name, setting FROM pg_settings WHERE name LIKE 'enable%' ORDER BY name;
- name | setting
-----------------------+---------
- enable_bitmapscan | on
- enable_hashagg | on
- enable_hashjoin | on
- enable_indexonlyscan | on
- enable_indexscan | on
- enable_material | on
- enable_mergejoin | on
- enable_nestloop | on
- enable_seqscan | on
- enable_sort | on
- enable_tidscan | on
-(11 rows)
+ name | setting
+------------------------------+---------
+ enable_bitmapscan | on
+ enable_datanode_row_triggers | off
+ enable_hashagg | on
+ enable_hashjoin | on
+ enable_indexonlyscan | on
+ enable_indexscan | on
+ enable_material | on
+ enable_mergejoin | on
+ enable_nestloop | on
+ enable_seqscan | on
+ enable_sort | on
+ enable_tidscan | on
+(12 rows)
CREATE TABLE foo2(fooid int, f2 int);
INSERT INTO foo2 VALUES(1, 11);
SELECT * FROM getfoo3(1) AS t1;
t1
-----
- Ed
Joe
+ Ed
(2 rows)
SELECT * FROM getfoo3(1) WITH ORDINALITY AS t1(v,o);
---------
Joe
Ed
- Joe
(2 rows)
DROP VIEW vw_getfoo;
CREATE VIEW vw_getfoo AS SELECT * FROM getfoo3(1) WITH ORDINALITY AS t1(v,o);
-SELECT * FROM vw_getfoo;
+SELECT * FROM vw_getfoo ORDER BY 1;
v | o
-----+---
- Joe | 1
Ed | 2
+ Joe | 1
(2 rows)
DROP VIEW vw_getfoo;
DROP VIEW vw_getfoo;
CREATE VIEW vw_getfoo AS SELECT * FROM getfoo5(1) WITH ORDINALITY AS t1(a,b,c,o);
-SELECT * FROM vw_getfoo;
- a | b | c | o
----+---+-----+---
- 1 | 1 | Joe | 1
- 1 | 2 | Ed | 2
-(2 rows)
-
+SELECT * FROM vw_getfoo ORDER BY foosubid;
+ERROR: column "foosubid" does not exist
+LINE 1: SELECT * FROM vw_getfoo ORDER BY foosubid;
+ ^
DROP VIEW vw_getfoo;
-- sql, proretset = f, prorettype = record
CREATE FUNCTION getfoo6(int) RETURNS RECORD AS 'SELECT * FROM foo WHERE fooid = $1;' LANGUAGE SQL;
CREATE VIEW vw_getfoo AS SELECT * FROM getfoo7(1) AS
(fooid int, foosubid int, fooname text);
-SELECT * FROM vw_getfoo ORDER BY foosubid;
+SELECT * FROM vw_getfoo;
fooid | foosubid | fooname
-------+----------+---------
1 | 1 | Joe
create temp table tt_log(f1 int, data text);
create rule insert_tt_rule as on insert to tt do also
insert into tt_log values(new.*);
+ERROR: relation "tt_log" does not exist
select insert_tt2('foollog','barlog') limit 1;
insert_tt2
------------
-- note that nextval() gets executed a second time in the rule expansion,
-- which is expected.
select * from tt_log order by 1, 2;
- f1 | data
-----+---------
- 15 | foollog
- 16 | barlog
-(2 rows)
+ f1 | data
+----+------
+(0 rows)
-- test case for a whole-row-variable bug
create function foo1(n integer, out a text, out b text)
create function testfoo() returns record as $$
insert into foo values (1,2) returning *;
$$ language sql;
+ERROR: relation "foo" does not exist
select testfoo();
- testfoo
----------
- (1,2)
-(1 row)
-
+ERROR: function testfoo() does not exist
+LINE 1: select testfoo();
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
select * from testfoo() as t(f1 int8,f2 int8);
- f1 | f2
-----+----
- 1 | 2
-(1 row)
-
+ERROR: function testfoo() does not exist
+LINE 1: select * from testfoo() as t(f1 int8,f2 int8);
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
select * from testfoo(); -- fail
-ERROR: a column definition list is required for functions returning "record"
+ERROR: function testfoo() does not exist
LINE 1: select * from testfoo();
^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
drop function testfoo();
+ERROR: function testfoo() does not exist
create function testfoo() returns setof record as $$
insert into foo values (1,2), (3,4) returning *;
$$ language sql;
+ERROR: relation "foo" does not exist
select testfoo();
- testfoo
----------
- (1,2)
- (3,4)
-(2 rows)
-
+ERROR: function testfoo() does not exist
+LINE 1: select testfoo();
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
select * from testfoo() as t(f1 int8,f2 int8) order by 1, 2;
- f1 | f2
-----+----
- 1 | 2
- 3 | 4
-(2 rows)
-
+ERROR: function testfoo() does not exist
+LINE 1: select * from testfoo() as t(f1 int8,f2 int8) order by 1, 2;
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
select * from testfoo(); -- fail
-ERROR: a column definition list is required for functions returning "record"
+ERROR: function testfoo() does not exist
LINE 1: select * from testfoo();
^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
drop function testfoo();
+ERROR: function testfoo() does not exist
--
-- Check some cases involving added/dropped columns in a rowtype result
--
create or replace function get_first_user() returns users as
$$ SELECT * FROM users ORDER BY userid LIMIT 1; $$
language sql stable;
+ERROR: type "users" does not exist
SELECT get_first_user();
- get_first_user
--------------------
- (id,1,email,11,t)
-(1 row)
-
+ERROR: function get_first_user() does not exist
+LINE 1: SELECT get_first_user();
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SELECT * FROM get_first_user();
- userid | seq | email | moredrop | enabled
---------+-----+-------+----------+---------
- id | 1 | email | 11 | t
-(1 row)
-
+ERROR: function get_first_user() does not exist
+LINE 1: SELECT * FROM get_first_user();
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
create or replace function get_users() returns setof users as
$$ SELECT * FROM users ORDER BY userid; $$
language sql stable;
+ERROR: type "users" does not exist
SELECT get_users();
- get_users
----------------------
- (id,1,email,11,t)
- (id2,2,email2,12,t)
-(2 rows)
-
+ERROR: function get_users() does not exist
+LINE 1: SELECT get_users();
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SELECT * FROM get_users();
- userid | seq | email | moredrop | enabled
---------+-----+--------+----------+---------
- id | 1 | email | 11 | t
- id2 | 2 | email2 | 12 | t
-(2 rows)
-
+ERROR: function get_users() does not exist
+LINE 1: SELECT * FROM get_users();
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SELECT * FROM get_users() WITH ORDINALITY; -- make sure ordinality copes
- userid | seq | email | moredrop | enabled | ordinality
---------+-----+--------+----------+---------+------------
- id | 1 | email | 11 | t | 1
- id2 | 2 | email2 | 12 | t | 2
-(2 rows)
-
+ERROR: function get_users() does not exist
+LINE 1: SELECT * FROM get_users() WITH ORDINALITY;
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
-- multiple functions vs. dropped columns
SELECT * FROM ROWS FROM(generate_series(10,11), get_users()) WITH ORDINALITY;
- generate_series | userid | seq | email | moredrop | enabled | ordinality
------------------+--------+-----+--------+----------+---------+------------
- 10 | id | 1 | email | 11 | t | 1
- 11 | id2 | 2 | email2 | 12 | t | 2
-(2 rows)
-
+ERROR: function get_users() does not exist
+LINE 1: SELECT * FROM ROWS FROM(generate_series(10,11), get_users())...
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SELECT * FROM ROWS FROM(get_users(), generate_series(10,11)) WITH ORDINALITY;
- userid | seq | email | moredrop | enabled | generate_series | ordinality
---------+-----+--------+----------+---------+-----------------+------------
- id | 1 | email | 11 | t | 10 | 1
- id2 | 2 | email2 | 12 | t | 11 | 2
-(2 rows)
-
+ERROR: function get_users() does not exist
+LINE 1: SELECT * FROM ROWS FROM(get_users(), generate_series(10,11))...
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
-- check that we can cope with post-parsing changes in rowtypes
create temp view usersview as
SELECT * FROM ROWS FROM(get_users(), generate_series(10,11)) WITH ORDINALITY;
+ERROR: function get_users() does not exist
+LINE 2: SELECT * FROM ROWS FROM(get_users(), generate_series(10,11))...
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
select * from usersview;
- userid | seq | email | moredrop | enabled | generate_series | ordinality
---------+-----+--------+----------+---------+-----------------+------------
- id | 1 | email | 11 | t | 10 | 1
- id2 | 2 | email2 | 12 | t | 11 | 2
-(2 rows)
-
+ERROR: relation "usersview" does not exist
+LINE 1: select * from usersview;
+ ^
alter table users drop column moredrop;
select * from usersview;
- userid | seq | email | moredrop | enabled | generate_series | ordinality
---------+-----+--------+----------+---------+-----------------+------------
- id | 1 | email | | t | 10 | 1
- id2 | 2 | email2 | | t | 11 | 2
-(2 rows)
-
+ERROR: relation "usersview" does not exist
+LINE 1: select * from usersview;
+ ^
alter table users add column junk text;
select * from usersview;
- userid | seq | email | moredrop | enabled | generate_series | ordinality
---------+-----+--------+----------+---------+-----------------+------------
- id | 1 | email | | t | 10 | 1
- id2 | 2 | email2 | | t | 11 | 2
-(2 rows)
-
+ERROR: relation "usersview" does not exist
+LINE 1: select * from usersview;
+ ^
alter table users alter column seq type numeric;
select * from usersview; -- expect clean failure
-ERROR: attribute 2 has wrong type
-DETAIL: Table has type numeric, but query expects integer.
+ERROR: relation "usersview" does not exist
+LINE 1: select * from usersview;
+ ^
drop view usersview;
+ERROR: view "usersview" does not exist
drop function get_first_user();
+ERROR: function get_first_user() does not exist
drop function get_users();
+ERROR: function get_users() does not exist
drop table users;
-- this won't get inlined because of type coercion, but it shouldn't fail
create or replace function foobar() returns setof text as
$$ language sql immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2(int8_tbl) f(x);
- QUERY PLAN
-------------------------------------------
+ QUERY PLAN
+------------------------------------------------
Nested Loop
Output: f.x
- -> Seq Scan on public.int8_tbl
- Output: int8_tbl.q1, int8_tbl.q2
+ -> Remote Subquery Scan on all (datanode_1)
+ Output: int8_tbl.q2
+ -> Seq Scan on public.int8_tbl
+ Output: int8_tbl.q2
-> Function Scan on f
Output: f.x
Function Call: int8_tbl.q2
-(7 rows)
+(9 rows)
select x from int8_tbl, extractq2(int8_tbl) f(x);
x
$$ language sql immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2(int8_tbl) f(x);
- QUERY PLAN
------------------------------------
+ QUERY PLAN
+------------------------------------------------
Nested Loop
Output: ((int8_tbl.*).q2)
- -> Seq Scan on public.int8_tbl
+ -> Remote Subquery Scan on all (datanode_2)
Output: int8_tbl.*
+ -> Seq Scan on public.int8_tbl
+ Output: int8_tbl.*
-> Result
Output: (int8_tbl.*).q2
-(6 rows)
+(8 rows)
select x from int8_tbl, extractq2_2(int8_tbl) f(x);
x
$$ language sql immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x);
- QUERY PLAN
------------------------------
- Seq Scan on public.int8_tbl
+ QUERY PLAN
+------------------------------------------
+ Remote Subquery Scan on all (datanode_1)
Output: int8_tbl.q2
-(2 rows)
+ -> Seq Scan on public.int8_tbl
+ Output: int8_tbl.q2
+(4 rows)
select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x);
x
('rls_regress_user1', 1),
('rls_regress_user2', 2),
('rls_regress_user3', 3);
+-- PGXL
+-- Distribute by replication so that "document" table below can reference "cid"
+-- column
+--
CREATE TABLE category (
cid int primary key,
cname text
-);
+) DISTRIBUTE BY REPLICATION;
GRANT ALL ON category TO public;
INSERT INTO category VALUES
(11, 'novel'),
SET SESSION AUTHORIZATION rls_regress_user1;
SET row_security TO ON;
SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did;
-NOTICE: f_leak => my first novel
-NOTICE: f_leak => my first manga
-NOTICE: f_leak => great science fiction
-NOTICE: f_leak => great manga
did | cid | dlevel | dauthor | dtitle
-----+-----+--------+-------------------+-----------------------
1 | 11 | 1 | rls_regress_user1 | my first novel
(4 rows)
SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did;
-NOTICE: f_leak => my first novel
-NOTICE: f_leak => my first manga
-NOTICE: f_leak => great science fiction
-NOTICE: f_leak => great manga
cid | did | dlevel | dauthor | dtitle | cname
-----+-----+--------+-------------------+-----------------------+-----------------
11 | 1 | 1 | rls_regress_user1 | my first novel | novel
-- try a sampled version
SELECT * FROM document TABLESAMPLE BERNOULLI(50) REPEATABLE(0)
WHERE f_leak(dtitle) ORDER BY did;
-NOTICE: f_leak => my first manga
-NOTICE: f_leak => great science fiction
-NOTICE: f_leak => great manga
did | cid | dlevel | dauthor | dtitle
-----+-----+--------+-------------------+-----------------------
- 4 | 44 | 1 | rls_regress_user1 | my first manga
6 | 22 | 1 | rls_regress_user2 | great science fiction
8 | 44 | 1 | rls_regress_user2 | great manga
-(3 rows)
+(2 rows)
-- viewpoint from rls_regress_user2
SET SESSION AUTHORIZATION rls_regress_user2;
SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did;
-NOTICE: f_leak => my first novel
-NOTICE: f_leak => my second novel
-NOTICE: f_leak => my science fiction
-NOTICE: f_leak => my first manga
-NOTICE: f_leak => my second manga
-NOTICE: f_leak => great science fiction
-NOTICE: f_leak => great technology book
-NOTICE: f_leak => great manga
did | cid | dlevel | dauthor | dtitle
-----+-----+--------+-------------------+-----------------------
1 | 11 | 1 | rls_regress_user1 | my first novel
(8 rows)
SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did;
-NOTICE: f_leak => my first novel
-NOTICE: f_leak => my second novel
-NOTICE: f_leak => my science fiction
-NOTICE: f_leak => my first manga
-NOTICE: f_leak => my second manga
-NOTICE: f_leak => great science fiction
-NOTICE: f_leak => great technology book
-NOTICE: f_leak => great manga
cid | did | dlevel | dauthor | dtitle | cname
-----+-----+--------+-------------------+-----------------------+-----------------
11 | 1 | 1 | rls_regress_user1 | my first novel | novel
-- try a sampled version
SELECT * FROM document TABLESAMPLE BERNOULLI(50) REPEATABLE(0)
WHERE f_leak(dtitle) ORDER BY did;
-NOTICE: f_leak => my first manga
-NOTICE: f_leak => my second manga
-NOTICE: f_leak => great science fiction
-NOTICE: f_leak => great manga
did | cid | dlevel | dauthor | dtitle
-----+-----+--------+-------------------+-----------------------
- 4 | 44 | 1 | rls_regress_user1 | my first manga
- 5 | 44 | 2 | rls_regress_user1 | my second manga
6 | 22 | 1 | rls_regress_user2 | great science fiction
8 | 44 | 1 | rls_regress_user2 | great manga
-(4 rows)
+(2 rows)
EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle);
- QUERY PLAN
-----------------------------------------------------------
- Subquery Scan on document
- Filter: f_leak(document.dtitle)
- -> Seq Scan on document document_1
- Filter: (dlevel <= $0)
- InitPlan 1 (returns $0)
- -> Index Scan using uaccount_pkey on uaccount
- Index Cond: (pguser = "current_user"())
-(7 rows)
-
-EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle);
- QUERY PLAN
-----------------------------------------------------------------------
- Hash Join
- Hash Cond: (category.cid = document.cid)
- -> Seq Scan on category
- -> Hash
- -> Subquery Scan on document
- Filter: f_leak(document.dtitle)
- -> Seq Scan on document document_1
- Filter: (dlevel <= $0)
- InitPlan 1 (returns $0)
+ QUERY PLAN
+-------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on document
+ Filter: f_leak(document.dtitle)
+ -> Seq Scan on document document_1
+ Filter: (dlevel <= $0)
+ InitPlan 1 (returns $0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
-> Index Scan using uaccount_pkey on uaccount
Index Cond: (pguser = "current_user"())
-(11 rows)
+(9 rows)
+
+EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle);
+ QUERY PLAN
+-------------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Hash Join
+ Hash Cond: (category.cid = document.cid)
+ -> Seq Scan on category
+ -> Hash
+ -> Subquery Scan on document
+ Filter: f_leak(document.dtitle)
+ -> Seq Scan on document document_1
+ Filter: (dlevel <= $0)
+ InitPlan 1 (returns $0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Index Scan using uaccount_pkey on uaccount
+ Index Cond: (pguser = "current_user"())
+(13 rows)
-- only owner can change policies
ALTER POLICY p1 ON document USING (true); --fail
-- viewpoint from rls_regress_user1 again
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did;
-NOTICE: f_leak => my first novel
-NOTICE: f_leak => my second novel
-NOTICE: f_leak => my science fiction
-NOTICE: f_leak => my first manga
-NOTICE: f_leak => my second manga
did | cid | dlevel | dauthor | dtitle
-----+-----+--------+-------------------+--------------------
1 | 11 | 1 | rls_regress_user1 | my first novel
(5 rows)
SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER by did;
-NOTICE: f_leak => my first novel
-NOTICE: f_leak => my second novel
-NOTICE: f_leak => my science fiction
-NOTICE: f_leak => my first manga
-NOTICE: f_leak => my second manga
cid | did | dlevel | dauthor | dtitle | cname
-----+-----+--------+-------------------+--------------------+-----------------
11 | 1 | 1 | rls_regress_user1 | my first novel | novel
-- viewpoint from rls_regres_user2 again
SET SESSION AUTHORIZATION rls_regress_user2;
SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did;
-NOTICE: f_leak => great science fiction
-NOTICE: f_leak => great technology book
-NOTICE: f_leak => great manga
did | cid | dlevel | dauthor | dtitle
-----+-----+--------+-------------------+-----------------------
6 | 22 | 1 | rls_regress_user2 | great science fiction
(3 rows)
SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER by did;
-NOTICE: f_leak => great science fiction
-NOTICE: f_leak => great technology book
-NOTICE: f_leak => great manga
cid | did | dlevel | dauthor | dtitle | cname
-----+-----+--------+-------------------+-----------------------+-----------------
22 | 6 | 1 | rls_regress_user2 | great science fiction | science fiction
(3 rows)
EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle);
- QUERY PLAN
-----------------------------------------------
- Subquery Scan on document
- Filter: f_leak(document.dtitle)
- -> Seq Scan on document document_1
- Filter: (dauthor = "current_user"())
-(4 rows)
-
-EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle);
- QUERY PLAN
-----------------------------------------------------
- Nested Loop
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
-> Subquery Scan on document
Filter: f_leak(document.dtitle)
-> Seq Scan on document document_1
Filter: (dauthor = "current_user"())
- -> Index Scan using category_pkey on category
- Index Cond: (cid = document.cid)
-(7 rows)
+(5 rows)
+
+EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle);
+ QUERY PLAN
+----------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Nested Loop
+ -> Subquery Scan on document
+ Filter: f_leak(document.dtitle)
+ -> Seq Scan on document document_1
+ Filter: (dauthor = "current_user"())
+ -> Index Scan using category_pkey on category
+ Index Cond: (cid = document.cid)
+(8 rows)
-- interaction of FK/PK constraints
SET SESSION AUTHORIZATION rls_regress_user0;
SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid;
did | cid | dlevel | dauthor | dtitle | cid | cname
-----+-----+--------+-------------------+--------------------+-----+------------
+ 4 | 44 | 1 | rls_regress_user1 | my first manga | |
+ 5 | 44 | 2 | rls_regress_user1 | my second manga | |
2 | 11 | 2 | rls_regress_user1 | my second novel | 11 | novel
1 | 11 | 1 | rls_regress_user1 | my first novel | 11 | novel
| | | | | 33 | technology
- 5 | 44 | 2 | rls_regress_user1 | my second manga | |
- 4 | 44 | 1 | rls_regress_user1 | my first manga | |
3 | 22 | 2 | rls_regress_user1 | my science fiction | |
(6 rows)
SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid;
did | cid | dlevel | dauthor | dtitle | cid | cname
-----+-----+--------+-------------------+-----------------------+-----+-----------------
- 6 | 22 | 1 | rls_regress_user2 | great science fiction | 22 | science fiction
8 | 44 | 1 | rls_regress_user2 | great manga | 44 | manga
+ 6 | 22 | 1 | rls_regress_user2 | great science fiction | 22 | science fiction
7 | 33 | 2 | rls_regress_user2 | great technology book | |
(3 rows)
INSERT INTO document VALUES (8, 44, 1, 'rls_regress_user2', 'my third manga'); -- Should fail with RLS check violation, not duplicate key violation
ERROR: new row violates row level security policy for "document"
UPDATE document SET did = 8, dauthor = 'rls_regress_user2' WHERE did = 5; -- Should fail with RLS check violation, not duplicate key violation
-ERROR: new row violates row level security policy for "document"
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
-- database superuser does bypass RLS policy when enabled
RESET SESSION AUTHORIZATION;
SET row_security TO ON;
-----+-----+--------+-------------------+-----------------------
1 | 11 | 1 | rls_regress_user1 | my first novel
2 | 11 | 2 | rls_regress_user1 | my second novel
- 3 | 22 | 2 | rls_regress_user1 | my science fiction
- 4 | 44 | 1 | rls_regress_user1 | my first manga
5 | 44 | 2 | rls_regress_user1 | my second manga
6 | 22 | 1 | rls_regress_user2 | great science fiction
- 7 | 33 | 2 | rls_regress_user2 | great technology book
8 | 44 | 1 | rls_regress_user2 | great manga
+ 3 | 22 | 2 | rls_regress_user1 | my science fiction
+ 4 | 44 | 1 | rls_regress_user1 | my first manga
+ 7 | 33 | 2 | rls_regress_user2 | great technology book
10 | 33 | 1 | rls_regress_user2 | hoge
(9 rows)
-----+-----+--------+-------------------+-----------------------
1 | 11 | 1 | rls_regress_user1 | my first novel
2 | 11 | 2 | rls_regress_user1 | my second novel
- 3 | 22 | 2 | rls_regress_user1 | my science fiction
- 4 | 44 | 1 | rls_regress_user1 | my first manga
5 | 44 | 2 | rls_regress_user1 | my second manga
6 | 22 | 1 | rls_regress_user2 | great science fiction
- 7 | 33 | 2 | rls_regress_user2 | great technology book
8 | 44 | 1 | rls_regress_user2 | great manga
+ 3 | 22 | 2 | rls_regress_user1 | my science fiction
+ 4 | 44 | 1 | rls_regress_user1 | my first manga
+ 7 | 33 | 2 | rls_regress_user2 | great technology book
10 | 33 | 1 | rls_regress_user2 | hoge
(9 rows)
-----+-----+--------+-------------------+-----------------------
1 | 11 | 1 | rls_regress_user1 | my first novel
2 | 11 | 2 | rls_regress_user1 | my second novel
- 3 | 22 | 2 | rls_regress_user1 | my science fiction
- 4 | 44 | 1 | rls_regress_user1 | my first manga
5 | 44 | 2 | rls_regress_user1 | my second manga
6 | 22 | 1 | rls_regress_user2 | great science fiction
- 7 | 33 | 2 | rls_regress_user2 | great technology book
8 | 44 | 1 | rls_regress_user2 | great manga
+ 3 | 22 | 2 | rls_regress_user1 | my science fiction
+ 4 | 44 | 1 | rls_regress_user1 | my first manga
+ 7 | 33 | 2 | rls_regress_user2 | great technology book
10 | 33 | 1 | rls_regress_user2 | hoge
(9 rows)
-----+-----+--------+-------------------+-----------------------
1 | 11 | 1 | rls_regress_user1 | my first novel
2 | 11 | 2 | rls_regress_user1 | my second novel
- 3 | 22 | 2 | rls_regress_user1 | my science fiction
- 4 | 44 | 1 | rls_regress_user1 | my first manga
5 | 44 | 2 | rls_regress_user1 | my second manga
6 | 22 | 1 | rls_regress_user2 | great science fiction
- 7 | 33 | 2 | rls_regress_user2 | great technology book
8 | 44 | 1 | rls_regress_user2 | great manga
+ 3 | 22 | 2 | rls_regress_user1 | my science fiction
+ 4 | 44 | 1 | rls_regress_user1 | my first manga
+ 7 | 33 | 2 | rls_regress_user2 | great technology book
10 | 33 | 1 | rls_regress_user2 | hoge
(9 rows)
-----+-----+--------+-------------------+-----------------------
1 | 11 | 1 | rls_regress_user1 | my first novel
2 | 11 | 2 | rls_regress_user1 | my second novel
- 3 | 22 | 2 | rls_regress_user1 | my science fiction
- 4 | 44 | 1 | rls_regress_user1 | my first manga
5 | 44 | 2 | rls_regress_user1 | my second manga
6 | 22 | 1 | rls_regress_user2 | great science fiction
- 7 | 33 | 2 | rls_regress_user2 | great technology book
8 | 44 | 1 | rls_regress_user2 | great manga
+ 3 | 22 | 2 | rls_regress_user1 | my science fiction
+ 4 | 44 | 1 | rls_regress_user1 | my first manga
+ 7 | 33 | 2 | rls_regress_user2 | great technology book
10 | 33 | 1 | rls_regress_user2 | hoge
(9 rows)
(5 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1;
- QUERY PLAN
--------------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: ((a % 2) = 0)
- -> Seq Scan on t2
- Filter: ((a % 2) = 0)
- -> Seq Scan on t3
- Filter: ((a % 2) = 0)
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: ((a % 2) = 0)
+(10 rows)
SELECT * FROM t1 WHERE f_leak(b);
NOTICE: f_leak => bbb
(5 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b);
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------
Subquery Scan on t1
Filter: f_leak(t1.b)
-> Append
- -> Seq Scan on t1 t1_1
- Filter: ((a % 2) = 0)
- -> Seq Scan on t2
- Filter: ((a % 2) = 0)
- -> Seq Scan on t3
- Filter: ((a % 2) = 0)
-(9 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1 t1_1
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: ((a % 2) = 0)
+(12 rows)
-- reference to system column
SELECT oid, * FROM t1;
(5 rows)
EXPLAIN (COSTS OFF) SELECT *, t1 FROM t1;
- QUERY PLAN
--------------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: ((a % 2) = 0)
- -> Seq Scan on t2
- Filter: ((a % 2) = 0)
- -> Seq Scan on t3
- Filter: ((a % 2) = 0)
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: ((a % 2) = 0)
+(10 rows)
-- reference to whole-row reference
SELECT *, t1 FROM t1;
(5 rows)
EXPLAIN (COSTS OFF) SELECT *, t1 FROM t1;
- QUERY PLAN
--------------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: ((a % 2) = 0)
- -> Seq Scan on t2
- Filter: ((a % 2) = 0)
- -> Seq Scan on t3
- Filter: ((a % 2) = 0)
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: ((a % 2) = 0)
+(10 rows)
-- for share/update lock
SELECT * FROM t1 FOR SHARE;
(5 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1 FOR SHARE;
- QUERY PLAN
--------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------
LockRows
-> Subquery Scan on t1
-> LockRows
-> Result
-> Append
- -> Seq Scan on t1 t1_1
- Filter: ((a % 2) = 0)
- -> Seq Scan on t2
- Filter: ((a % 2) = 0)
- -> Seq Scan on t3
- Filter: ((a % 2) = 0)
-(11 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1 t1_1
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: ((a % 2) = 0)
+(14 rows)
SELECT * FROM t1 WHERE f_leak(b) FOR SHARE;
NOTICE: f_leak => bbb
(5 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) FOR SHARE;
- QUERY PLAN
--------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------
LockRows
-> Subquery Scan on t1
Filter: f_leak(t1.b)
-> LockRows
-> Result
-> Append
- -> Seq Scan on t1 t1_1
- Filter: ((a % 2) = 0)
- -> Seq Scan on t2
- Filter: ((a % 2) = 0)
- -> Seq Scan on t3
- Filter: ((a % 2) = 0)
-(12 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1 t1_1
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: ((a % 2) = 0)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: ((a % 2) = 0)
+(15 rows)
-- superuser is allowed to bypass RLS checks
RESET SESSION AUTHORIZATION;
SET row_security TO OFF;
SELECT * FROM t1 WHERE f_leak(b);
-NOTICE: f_leak => aaa
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ccc
-NOTICE: f_leak => ddd
-NOTICE: f_leak => abc
-NOTICE: f_leak => bcd
-NOTICE: f_leak => cde
-NOTICE: f_leak => def
-NOTICE: f_leak => xxx
-NOTICE: f_leak => yyy
-NOTICE: f_leak => zzz
a | b
---+-----
1 | aaa
(11 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b);
- QUERY PLAN
----------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: f_leak(b)
- -> Seq Scan on t2
- Filter: f_leak(b)
- -> Seq Scan on t3
- Filter: f_leak(b)
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1
+ Filter: f_leak(b)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: f_leak(b)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: f_leak(b)
+(10 rows)
-- non-superuser with bypass privilege can bypass RLS policy when disabled
SET SESSION AUTHORIZATION rls_regress_exempt_user;
SET row_security TO OFF;
SELECT * FROM t1 WHERE f_leak(b);
-NOTICE: f_leak => aaa
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ccc
-NOTICE: f_leak => ddd
-NOTICE: f_leak => abc
-NOTICE: f_leak => bcd
-NOTICE: f_leak => cde
-NOTICE: f_leak => def
-NOTICE: f_leak => xxx
-NOTICE: f_leak => yyy
-NOTICE: f_leak => zzz
a | b
---+-----
1 | aaa
(11 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b);
- QUERY PLAN
----------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: f_leak(b)
- -> Seq Scan on t2
- Filter: f_leak(b)
- -> Seq Scan on t3
- Filter: f_leak(b)
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1
+ Filter: f_leak(b)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: f_leak(b)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: f_leak(b)
+(10 rows)
----- Dependencies -----
SET SESSION AUTHORIZATION rls_regress_user0;
DROP TABLE dependee CASCADE;
NOTICE: drop cascades to policy d1 on table dependent
EXPLAIN (COSTS OFF) SELECT * FROM dependent; -- After drop, should be unqualified
- QUERY PLAN
------------------------
- Seq Scan on dependent
-(1 row)
+ QUERY PLAN
+----------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
+ -> Seq Scan on dependent
+(3 rows)
----- RECURSION ----
--
CREATE VIEW rec2v AS SELECT * FROM rec2;
SET SESSION AUTHORIZATION rls_regress_user0;
ALTER POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2v WHERE b = y));
+ERROR: relation "rec2v" does not exist
ALTER POLICY r2 ON rec2 USING (a = (SELECT x FROM rec1v WHERE y = b));
+ERROR: relation "rec1v" does not exist
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM rec1; -- fail, mutual recursion via views
ERROR: infinite recursion detected in policy for relation "rec1"
CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2;
SET SESSION AUTHORIZATION rls_regress_user0;
CREATE POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2v WHERE b = y));
+ERROR: policy "r1" for table "rec1" already exists
CREATE POLICY r2 ON rec2 USING (a = (SELECT x FROM rec1v WHERE y = b));
+ERROR: policy "r2" for table "rec2" already exists
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM rec1; -- fail, mutual recursion via s.b. views
ERROR: infinite recursion detected in policy for relation "rec1"
ALTER POLICY p2 ON s2 USING (x % 2 = 0);
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM s1 WHERE f_leak(b); -- OK
-NOTICE: f_leak => c81e728d9d4c2f636f067f89cc14862c
-NOTICE: f_leak => a87ff679a2f3e71d9181a67b7542122c
a | b
---+----------------------------------
2 | c81e728d9d4c2f636f067f89cc14862c
(2 rows)
EXPLAIN (COSTS OFF) SELECT * FROM only s1 WHERE f_leak(b);
- 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)
- -> Seq Scan on s2 s2_1
- Filter: ((x % 2) = 0)
-(12 rows)
+ QUERY PLAN
+----------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> 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)
+ -> Seq Scan on s2 s2_1
+ Filter: ((x % 2) = 0)
+(13 rows)
SET SESSION AUTHORIZATION rls_regress_user0;
ALTER POLICY p1 ON s1 USING (a in (select x from v2)); -- using VIEW in RLS policy
+ERROR: relation "v2" does not exist
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM s1 WHERE f_leak(b); -- OK
-NOTICE: f_leak => 0267aaf632e87a63288a08331f22c7c3
-NOTICE: f_leak => 1679091c5a880faf6fb5e6087eb1b2dc
- a | b
-----+----------------------------------
- -4 | 0267aaf632e87a63288a08331f22c7c3
- 6 | 1679091c5a880faf6fb5e6087eb1b2dc
+ a | b
+---+----------------------------------
+ 2 | c81e728d9d4c2f636f067f89cc14862c
+ 4 | a87ff679a2f3e71d9181a67b7542122c
(2 rows)
EXPLAIN (COSTS OFF) SELECT * FROM s1 WHERE f_leak(b);
- 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 ~~ '%af%'::text)
- -> Seq Scan on s2 s2_1
- Filter: ((x % 2) = 0)
-(12 rows)
+ QUERY PLAN
+----------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> 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)
+ -> Seq Scan on s2 s2_1
+ Filter: ((x % 2) = 0)
+(13 rows)
SELECT (SELECT x FROM s1 LIMIT 1) xx, * FROM s2 WHERE y like '%28%';
xx | x | y
----+----+----------------------------------
- -6 | -6 | 596a3d04481816330f07e4f97510c28f
-4 | -4 | 0267aaf632e87a63288a08331f22c7c3
2 | 2 | c81e728d9d4c2f636f067f89cc14862c
+ -6 | -6 | 596a3d04481816330f07e4f97510c28f
(3 rows)
EXPLAIN (COSTS OFF) SELECT (SELECT x FROM s1 LIMIT 1) xx, * FROM s2 WHERE y like '%28%';
- QUERY PLAN
---------------------------------------------------------------------
- Subquery Scan on s2
- Filter: (s2.y ~~ '%28%'::text)
- -> Seq Scan on s2 s2_1
- Filter: ((x % 2) = 0)
- SubPlan 1
- -> Limit
- -> Subquery Scan on s1
- -> Nested Loop Semi Join
- Join Filter: (s1_1.a = s2_2.x)
- -> Seq Scan on s1 s1_1
- -> Materialize
- -> Subquery Scan on s2_2
- Filter: (s2_2.y ~~ '%af%'::text)
- -> Seq Scan on s2 s2_3
- Filter: ((x % 2) = 0)
-(15 rows)
+ QUERY PLAN
+--------------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on s2
+ Filter: (s2.y ~~ '%28%'::text)
+ -> Seq Scan on s2 s2_1
+ Filter: ((x % 2) = 0)
+ SubPlan 1
+ -> Limit
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Limit
+ -> Subquery Scan on s1
+ -> Nested Loop Semi Join
+ Join Filter: (s1_1.a = s2_2.x)
+ -> Seq Scan on s1 s1_1
+ -> Materialize
+ -> Subquery Scan on s2_2
+ Filter: (s2_2.y ~~ '%2f%'::text)
+ -> Seq Scan on s2 s2_3
+ Filter: ((x % 2) = 0)
+(18 rows)
SET SESSION AUTHORIZATION rls_regress_user0;
ALTER POLICY p2 ON s2 USING (x in (select a from s1 where b like '%d2%'));
(3 rows)
EXPLAIN (COSTS OFF) EXECUTE p1(2);
- QUERY PLAN
-----------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: ((a <= 2) AND ((a % 2) = 0))
- -> Seq Scan on t2
- Filter: ((a <= 2) AND ((a % 2) = 0))
- -> Seq Scan on t3
- Filter: ((a <= 2) AND ((a % 2) = 0))
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1
+ Filter: ((a <= 2) AND ((a % 2) = 0))
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: ((a <= 2) AND ((a % 2) = 0))
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: ((a <= 2) AND ((a % 2) = 0))
+(10 rows)
-- superuser is allowed to bypass RLS checks
RESET SESSION AUTHORIZATION;
SET row_security TO OFF;
SELECT * FROM t1 WHERE f_leak(b);
-NOTICE: f_leak => aaa
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ccc
-NOTICE: f_leak => ddd
-NOTICE: f_leak => abc
-NOTICE: f_leak => bcd
-NOTICE: f_leak => cde
-NOTICE: f_leak => def
-NOTICE: f_leak => xxx
-NOTICE: f_leak => yyy
-NOTICE: f_leak => zzz
a | b
---+-----
1 | aaa
(11 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b);
- QUERY PLAN
----------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: f_leak(b)
- -> Seq Scan on t2
- Filter: f_leak(b)
- -> Seq Scan on t3
- Filter: f_leak(b)
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1
+ Filter: f_leak(b)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: f_leak(b)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: f_leak(b)
+(10 rows)
-- plan cache should be invalidated
EXECUTE p1(2);
(6 rows)
EXPLAIN (COSTS OFF) EXECUTE p1(2);
- QUERY PLAN
---------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: (a <= 2)
- -> Seq Scan on t2
- Filter: (a <= 2)
- -> Seq Scan on t3
- Filter: (a <= 2)
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t1
+ Filter: (a <= 2)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t2
+ Filter: (a <= 2)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: (a <= 2)
+(10 rows)
PREPARE p2(int) AS SELECT * FROM t1 WHERE a = $1;
EXECUTE p2(2);
(3 rows)
EXPLAIN (COSTS OFF) EXECUTE p2(2);
- QUERY PLAN
--------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: (a = 2)
- -> Seq Scan on t2
- Filter: (a = 2)
- -> Seq Scan on t3
- Filter: (a = 2)
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1)
+ -> Seq Scan on t1
+ Filter: (a = 2)
+ -> Remote Subquery Scan on all (datanode_1)
+ -> Seq Scan on t2
+ Filter: (a = 2)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: (a = 2)
+(10 rows)
-- also, case when privilege switch from superuser
SET SESSION AUTHORIZATION rls_regress_user1;
(3 rows)
EXPLAIN (COSTS OFF) EXECUTE p2(2);
- QUERY PLAN
----------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------
Append
- -> Seq Scan on t1
- Filter: ((a = 2) AND ((a % 2) = 0))
- -> Seq Scan on t2
- Filter: ((a = 2) AND ((a % 2) = 0))
- -> Seq Scan on t3
- Filter: ((a = 2) AND ((a % 2) = 0))
-(7 rows)
+ -> Remote Subquery Scan on all (datanode_1)
+ -> Seq Scan on t1
+ Filter: ((a = 2) AND ((a % 2) = 0))
+ -> Remote Subquery Scan on all (datanode_1)
+ -> Seq Scan on t2
+ Filter: ((a = 2) AND ((a % 2) = 0))
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on t3
+ Filter: ((a = 2) AND ((a % 2) = 0))
+(10 rows)
--
-- UPDATE / DELETE and Row-level security
--
SET SESSION AUTHORIZATION rls_regress_user1;
EXPLAIN (COSTS OFF) UPDATE t1 SET b = b || b WHERE f_leak(b);
- QUERY PLAN
--------------------------------------------
- Update on t1 t1_3
- Update on t1 t1_3
- Update on t2 t1
- Update on t3 t1
- -> Subquery Scan on t1
- Filter: f_leak(t1.b)
- -> LockRows
- -> Seq Scan on t1 t1_4
- Filter: ((a % 2) = 0)
- -> Subquery Scan on t1_1
- Filter: f_leak(t1_1.b)
- -> LockRows
- -> Seq Scan on t2
- Filter: ((a % 2) = 0)
- -> Subquery Scan on t1_2
- Filter: f_leak(t1_2.b)
- -> LockRows
- -> Seq Scan on t3
- Filter: ((a % 2) = 0)
-(19 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Update on t1 t1_3
+ Update on t1 t1_3
+ Update on t2 t1
+ Update on t3 t1
+ -> Subquery Scan on t1
+ Filter: f_leak(t1.b)
+ -> LockRows
+ -> Seq Scan on t1 t1_4
+ Filter: ((a % 2) = 0)
+ -> Subquery Scan on t1_1
+ Filter: f_leak(t1_1.b)
+ -> LockRows
+ -> Seq Scan on t2
+ Filter: ((a % 2) = 0)
+ -> Subquery Scan on t1_2
+ Filter: f_leak(t1_2.b)
+ -> LockRows
+ -> Seq Scan on t3
+ Filter: ((a % 2) = 0)
+(20 rows)
UPDATE t1 SET b = b || b WHERE f_leak(b);
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ddd
-NOTICE: f_leak => bcd
-NOTICE: f_leak => def
-NOTICE: f_leak => yyy
EXPLAIN (COSTS OFF) UPDATE only t1 SET b = b || '_updt' WHERE f_leak(b);
- QUERY PLAN
--------------------------------------------
- Update on t1 t1_1
- -> Subquery Scan on t1
- Filter: f_leak(t1.b)
- -> LockRows
- -> Seq Scan on t1 t1_2
- Filter: ((a % 2) = 0)
-(6 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Update on t1 t1_1
+ -> Subquery Scan on t1
+ Filter: f_leak(t1.b)
+ -> LockRows
+ -> Seq Scan on t1 t1_2
+ Filter: ((a % 2) = 0)
+(7 rows)
UPDATE only t1 SET b = b || '_updt' WHERE f_leak(b);
-NOTICE: f_leak => bbbbbb
-NOTICE: f_leak => dddddd
-- returning clause with system column
UPDATE only t1 SET b = b WHERE f_leak(b) RETURNING oid, *, t1;
-NOTICE: f_leak => bbbbbb_updt
-NOTICE: f_leak => dddddd_updt
oid | a | b | t1
-----+---+-------------+-----------------
102 | 2 | bbbbbb_updt | (2,bbbbbb_updt)
(2 rows)
UPDATE t1 SET b = b WHERE f_leak(b) RETURNING *;
-NOTICE: f_leak => bbbbbb_updt
-NOTICE: f_leak => dddddd_updt
-NOTICE: f_leak => bcdbcd
-NOTICE: f_leak => defdef
-NOTICE: f_leak => yyyyyy
a | b
---+-------------
2 | bbbbbb_updt
- 4 | dddddd_updt
2 | bcdbcd
- 4 | defdef
2 | yyyyyy
+ 4 | dddddd_updt
+ 4 | defdef
(5 rows)
UPDATE t1 SET b = b WHERE f_leak(b) RETURNING oid, *, t1;
-NOTICE: f_leak => bbbbbb_updt
-NOTICE: f_leak => dddddd_updt
-NOTICE: f_leak => bcdbcd
-NOTICE: f_leak => defdef
-NOTICE: f_leak => yyyyyy
oid | a | b | t1
-----+---+-------------+-----------------
102 | 2 | bbbbbb_updt | (2,bbbbbb_updt)
- 104 | 4 | dddddd_updt | (4,dddddd_updt)
202 | 2 | bcdbcd | (2,bcdbcd)
- 204 | 4 | defdef | (4,defdef)
302 | 2 | yyyyyy | (2,yyyyyy)
+ 104 | 4 | dddddd_updt | (4,dddddd_updt)
+ 204 | 4 | defdef | (4,defdef)
(5 rows)
-- updates with from clause
EXPLAIN (COSTS OFF) UPDATE t2 SET b=t2.b FROM t3
WHERE t2.a = 3 and t3.a = 2 AND f_leak(t2.b) AND f_leak(t3.b);
- QUERY PLAN
----------------------------------------------------------------
- Update on t2 t2_1
- -> Nested Loop
- -> Subquery Scan on t2
- Filter: f_leak(t2.b)
- -> LockRows
- -> Seq Scan on t2 t2_2
- Filter: ((a = 3) AND ((a % 2) = 1))
- -> Seq Scan on t3
- Filter: (f_leak(b) AND (a = 2))
-(9 rows)
-
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
UPDATE t2 SET b=t2.b FROM t3
WHERE t2.a = 3 and t3.a = 2 AND f_leak(t2.b) AND f_leak(t3.b);
-NOTICE: f_leak => cde
-NOTICE: f_leak => xxx
-NOTICE: f_leak => zzz
-NOTICE: f_leak => yyyyyy
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
EXPLAIN (COSTS OFF) UPDATE t1 SET b=t1.b FROM t2
WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b);
- QUERY PLAN
----------------------------------------------------------------
- Update on t1 t1_3
- Update on t1 t1_3
- Update on t2 t1
- Update on t3 t1
- -> Nested Loop
- -> Subquery Scan on t1
- Filter: f_leak(t1.b)
- -> LockRows
- -> Seq Scan on t1 t1_4
- Filter: ((a = 3) AND ((a % 2) = 0))
- -> Subquery Scan on t2
- Filter: f_leak(t2.b)
- -> Seq Scan on t2 t2_3
- Filter: ((a = 3) AND ((a % 2) = 1))
- -> Nested Loop
- -> Subquery Scan on t1_1
- Filter: f_leak(t1_1.b)
- -> LockRows
- -> Seq Scan on t2 t2_4
- Filter: ((a = 3) AND ((a % 2) = 0))
- -> Subquery Scan on t2_1
- Filter: f_leak(t2_1.b)
- -> Seq Scan on t2 t2_5
- Filter: ((a = 3) AND ((a % 2) = 1))
- -> Nested Loop
- -> Subquery Scan on t1_2
- Filter: f_leak(t1_2.b)
- -> LockRows
- -> Seq Scan on t3
- Filter: ((a = 3) AND ((a % 2) = 0))
- -> Subquery Scan on t2_2
- Filter: f_leak(t2_2.b)
- -> Seq Scan on t2 t2_6
- Filter: ((a = 3) AND ((a % 2) = 1))
-(34 rows)
-
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
UPDATE t1 SET b=t1.b FROM t2
WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b);
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
EXPLAIN (COSTS OFF) UPDATE t2 SET b=t2.b FROM t1
WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b);
- QUERY PLAN
----------------------------------------------------------------------
- Update on t2 t2_1
- -> Nested Loop
- -> Subquery Scan on t2
- Filter: f_leak(t2.b)
- -> LockRows
- -> Seq Scan on t2 t2_2
- Filter: ((a = 3) AND ((a % 2) = 1))
- -> Subquery Scan on t1
- Filter: f_leak(t1.b)
- -> Result
- -> Append
- -> Seq Scan on t1 t1_1
- Filter: ((a = 3) AND ((a % 2) = 0))
- -> Seq Scan on t2 t2_3
- Filter: ((a = 3) AND ((a % 2) = 0))
- -> Seq Scan on t3
- Filter: ((a = 3) AND ((a % 2) = 0))
-(17 rows)
-
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
UPDATE t2 SET b=t2.b FROM t1
WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b);
-NOTICE: f_leak => cde
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
-- updates with from clause self join
EXPLAIN (COSTS OFF) UPDATE t2 t2_1 SET b = t2_2.b FROM t2 t2_2
WHERE t2_1.a = 3 AND t2_2.a = t2_1.a AND t2_2.b = t2_1.b
AND f_leak(t2_1.b) AND f_leak(t2_2.b) RETURNING *, t2_1, t2_2;
- QUERY PLAN
----------------------------------------------------------------
- Update on t2 t2_1_1
- -> Nested Loop
- Join Filter: (t2_1.b = t2_2.b)
- -> Subquery Scan on t2_1
- Filter: f_leak(t2_1.b)
- -> LockRows
- -> Seq Scan on t2 t2_1_2
- Filter: ((a = 3) AND ((a % 2) = 1))
- -> Subquery Scan on t2_2
- Filter: f_leak(t2_2.b)
- -> Seq Scan on t2 t2_2_1
- Filter: ((a = 3) AND ((a % 2) = 1))
-(12 rows)
-
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
UPDATE t2 t2_1 SET b = t2_2.b FROM t2 t2_2
WHERE t2_1.a = 3 AND t2_2.a = t2_1.a AND t2_2.b = t2_1.b
AND f_leak(t2_1.b) AND f_leak(t2_2.b) RETURNING *, t2_1, t2_2;
-NOTICE: f_leak => cde
-NOTICE: f_leak => cde
- a | b | c | a | b | c | t2_1 | t2_2
----+-----+-----+---+-----+-----+-------------+-------------
- 3 | cde | 3.3 | 3 | cde | 3.3 | (3,cde,3.3) | (3,cde,3.3)
-(1 row)
-
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
EXPLAIN (COSTS OFF) UPDATE t1 t1_1 SET b = t1_2.b FROM t1 t1_2
WHERE t1_1.a = 4 AND t1_2.a = t1_1.a AND t1_2.b = t1_1.b
AND f_leak(t1_1.b) AND f_leak(t1_2.b) RETURNING *, t1_1, t1_2;
- QUERY PLAN
----------------------------------------------------------------
- Update on t1 t1_1_3
- Update on t1 t1_1_3
- Update on t2 t1_1
- Update on t3 t1_1
- -> Nested Loop
- Join Filter: (t1_1.b = t1_2.b)
- -> Subquery Scan on t1_1
- Filter: f_leak(t1_1.b)
- -> LockRows
- -> Seq Scan on t1 t1_1_4
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Subquery Scan on t1_2
- Filter: f_leak(t1_2.b)
- -> Append
- -> Seq Scan on t1 t1_2_3
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Seq Scan on t2 t1_2_4
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Seq Scan on t3 t1_2_5
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Nested Loop
- Join Filter: (t1_1_1.b = t1_2_1.b)
- -> Subquery Scan on t1_1_1
- Filter: f_leak(t1_1_1.b)
- -> LockRows
- -> Seq Scan on t2 t1_1_5
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Subquery Scan on t1_2_1
- Filter: f_leak(t1_2_1.b)
- -> Append
- -> Seq Scan on t1 t1_2_6
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Seq Scan on t2 t1_2_7
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Seq Scan on t3 t1_2_8
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Nested Loop
- Join Filter: (t1_1_2.b = t1_2_2.b)
- -> Subquery Scan on t1_1_2
- Filter: f_leak(t1_1_2.b)
- -> LockRows
- -> Seq Scan on t3 t1_1_6
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Subquery Scan on t1_2_2
- Filter: f_leak(t1_2_2.b)
- -> Append
- -> Seq Scan on t1 t1_2_9
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Seq Scan on t2 t1_2_10
- Filter: ((a = 4) AND ((a % 2) = 0))
- -> Seq Scan on t3 t1_2_11
- Filter: ((a = 4) AND ((a % 2) = 0))
-(52 rows)
-
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
UPDATE t1 t1_1 SET b = t1_2.b FROM t1 t1_2
WHERE t1_1.a = 4 AND t1_2.a = t1_1.a AND t1_2.b = t1_1.b
AND f_leak(t1_1.b) AND f_leak(t1_2.b) RETURNING *, t1_1, t1_2;
-NOTICE: f_leak => dddddd_updt
-NOTICE: f_leak => dddddd_updt
-NOTICE: f_leak => defdef
-NOTICE: f_leak => defdef
-NOTICE: f_leak => dddddd_updt
-NOTICE: f_leak => defdef
- a | b | a | b | t1_1 | t1_2
----+-------------+---+-------------+-----------------+-----------------
- 4 | dddddd_updt | 4 | dddddd_updt | (4,dddddd_updt) | (4,dddddd_updt)
- 4 | defdef | 4 | defdef | (4,defdef) | (4,defdef)
-(2 rows)
-
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
RESET SESSION AUTHORIZATION;
SET row_security TO OFF;
SELECT * FROM t1 ORDER BY a,b;
SET SESSION AUTHORIZATION rls_regress_user1;
SET row_security TO ON;
EXPLAIN (COSTS OFF) DELETE FROM only t1 WHERE f_leak(b);
- QUERY PLAN
--------------------------------------------
- Delete on t1 t1_1
- -> Subquery Scan on t1
- Filter: f_leak(t1.b)
- -> LockRows
- -> Seq Scan on t1 t1_2
- Filter: ((a % 2) = 0)
-(6 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Delete on t1 t1_1
+ -> Subquery Scan on t1
+ Filter: f_leak(t1.b)
+ -> LockRows
+ -> Seq Scan on t1 t1_2
+ Filter: ((a % 2) = 0)
+(7 rows)
EXPLAIN (COSTS OFF) DELETE FROM t1 WHERE f_leak(b);
- QUERY PLAN
--------------------------------------------
- Delete on t1 t1_3
- Delete on t1 t1_3
- Delete on t2 t1
- Delete on t3 t1
- -> Subquery Scan on t1
- Filter: f_leak(t1.b)
- -> LockRows
- -> Seq Scan on t1 t1_4
- Filter: ((a % 2) = 0)
- -> Subquery Scan on t1_1
- Filter: f_leak(t1_1.b)
- -> LockRows
- -> Seq Scan on t2
- Filter: ((a % 2) = 0)
- -> Subquery Scan on t1_2
- Filter: f_leak(t1_2.b)
- -> LockRows
- -> Seq Scan on t3
- Filter: ((a % 2) = 0)
-(19 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Delete on t1 t1_3
+ Delete on t1 t1_3
+ Delete on t2 t1
+ Delete on t3 t1
+ -> Subquery Scan on t1
+ Filter: f_leak(t1.b)
+ -> LockRows
+ -> Seq Scan on t1 t1_4
+ Filter: ((a % 2) = 0)
+ -> Subquery Scan on t1_1
+ Filter: f_leak(t1_1.b)
+ -> LockRows
+ -> Seq Scan on t2
+ Filter: ((a % 2) = 0)
+ -> Subquery Scan on t1_2
+ Filter: f_leak(t1_2.b)
+ -> LockRows
+ -> Seq Scan on t3
+ Filter: ((a % 2) = 0)
+(20 rows)
DELETE FROM only t1 WHERE f_leak(b) RETURNING oid, *, t1;
-NOTICE: f_leak => bbbbbb_updt
-NOTICE: f_leak => dddddd_updt
oid | a | b | t1
-----+---+-------------+-----------------
102 | 2 | bbbbbb_updt | (2,bbbbbb_updt)
(2 rows)
DELETE FROM t1 WHERE f_leak(b) RETURNING oid, *, t1;
-NOTICE: f_leak => bcdbcd
-NOTICE: f_leak => defdef
-NOTICE: f_leak => yyyyyy
oid | a | b | t1
-----+---+--------+------------
202 | 2 | bcdbcd | (2,bcdbcd)
- 204 | 4 | defdef | (4,defdef)
302 | 2 | yyyyyy | (2,yyyyyy)
+ 204 | 4 | defdef | (4,defdef)
(3 rows)
--
GRANT ALL ON bv1 TO rls_regress_user2;
SET SESSION AUTHORIZATION rls_regress_user2;
EXPLAIN (COSTS OFF) SELECT * FROM bv1 WHERE f_leak(b);
- QUERY PLAN
----------------------------------------------
- Subquery Scan on bv1
- Filter: f_leak(bv1.b)
- -> Seq Scan on b1
- Filter: ((a > 0) AND ((a % 2) = 0))
-(4 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on bv1
+ Filter: f_leak(bv1.b)
+ -> Seq Scan on b1
+ Filter: ((a > 0) AND ((a % 2) = 0))
+(5 rows)
SELECT * FROM bv1 WHERE f_leak(b);
-NOTICE: f_leak => c81e728d9d4c2f636f067f89cc14862c
-NOTICE: f_leak => a87ff679a2f3e71d9181a67b7542122c
-NOTICE: f_leak => 1679091c5a880faf6fb5e6087eb1b2dc
-NOTICE: f_leak => c9f0f895fb98ab9159f51fd0297e236d
-NOTICE: f_leak => d3d9446802a44259755d38e6d163e820
a | b
----+----------------------------------
2 | c81e728d9d4c2f636f067f89cc14862c
- 4 | a87ff679a2f3e71d9181a67b7542122c
6 | 1679091c5a880faf6fb5e6087eb1b2dc
8 | c9f0f895fb98ab9159f51fd0297e236d
+ 4 | a87ff679a2f3e71d9181a67b7542122c
10 | d3d9446802a44259755d38e6d163e820
(5 rows)
ERROR: new row violates row level security policy for "b1"
INSERT INTO bv1 VALUES (12, 'xxx'); -- ok
EXPLAIN (COSTS OFF) UPDATE bv1 SET b = 'yyy' WHERE a = 4 AND f_leak(b);
- QUERY PLAN
----------------------------------------------------------------------------
- Update on b1 b1_1
- -> Subquery Scan on b1
- Filter: f_leak(b1.b)
- -> Subquery Scan on b1_2
- -> LockRows
- -> Seq Scan on b1 b1_3
- Filter: ((a > 0) AND (a = 4) AND ((a % 2) = 0))
-(7 rows)
+ QUERY PLAN
+---------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_2)
+ -> Update on b1 b1_1
+ -> Subquery Scan on b1
+ Filter: f_leak(b1.b)
+ -> Subquery Scan on b1_2
+ -> LockRows
+ -> Seq Scan on b1 b1_3
+ Filter: ((a > 0) AND (a = 4) AND ((a % 2) = 0))
+(8 rows)
UPDATE bv1 SET b = 'yyy' WHERE a = 4 AND f_leak(b);
-NOTICE: f_leak => a87ff679a2f3e71d9181a67b7542122c
EXPLAIN (COSTS OFF) DELETE FROM bv1 WHERE a = 6 AND f_leak(b);
- QUERY PLAN
----------------------------------------------------------------------------
- Delete on b1 b1_1
- -> Subquery Scan on b1
- Filter: f_leak(b1.b)
- -> Subquery Scan on b1_2
- -> LockRows
- -> Seq Scan on b1 b1_3
- Filter: ((a > 0) AND (a = 6) AND ((a % 2) = 0))
-(7 rows)
+ QUERY PLAN
+---------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1)
+ -> Delete on b1 b1_1
+ -> Subquery Scan on b1
+ Filter: f_leak(b1.b)
+ -> Subquery Scan on b1_2
+ -> LockRows
+ -> Seq Scan on b1 b1_3
+ Filter: ((a > 0) AND (a = 6) AND ((a % 2) = 0))
+(8 rows)
DELETE FROM bv1 WHERE a = 6 AND f_leak(b);
-NOTICE: f_leak => 1679091c5a880faf6fb5e6087eb1b2dc
SET SESSION AUTHORIZATION rls_regress_user0;
SELECT * FROM b1;
a | b
-----+----------------------------------
- -10 | 1b0fd9efa5279c4203b7c70233f86dbf
- -9 | 252e691406782824eec43d7eadc3d256
-8 | a8d2ec85eaf98407310b72eb73dda247
- -7 | 74687a12d3915d3c4d83f1af7b3683d5
- -6 | 596a3d04481816330f07e4f97510c28f
-5 | 47c1b025fa18ea96c33fbb6718688c0f
-4 | 0267aaf632e87a63288a08331f22c7c3
- -3 | b3149ecea4628efd23d2f86e5a723472
- -2 | 5d7b9adcbe1c629ec722529dd12e5129
-1 | 6bb61e3b7bce0931da574d19d1d82c88
- 0 | cfcd208495d565ef66e7dff9f98764da
1 | c4ca4238a0b923820dcc509a6f75849b
2 | c81e728d9d4c2f636f067f89cc14862c
- 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
5 | e4da3b7fbbce2345d7772b0674a318d5
- 7 | 8f14e45fceea167a5a36dedd4bea2543
8 | c9f0f895fb98ab9159f51fd0297e236d
9 | 45c48cce2e2d7fbdea1afc51c7c6ad26
- 10 | d3d9446802a44259755d38e6d163e820
12 | xxx
+ -10 | 1b0fd9efa5279c4203b7c70233f86dbf
+ -9 | 252e691406782824eec43d7eadc3d256
+ -7 | 74687a12d3915d3c4d83f1af7b3683d5
+ -6 | 596a3d04481816330f07e4f97510c28f
+ -3 | b3149ecea4628efd23d2f86e5a723472
+ -2 | 5d7b9adcbe1c629ec722529dd12e5129
+ 0 | cfcd208495d565ef66e7dff9f98764da
+ 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
+ 7 | 8f14e45fceea167a5a36dedd4bea2543
+ 10 | d3d9446802a44259755d38e6d163e820
4 | yyy
(21 rows)
ALTER TABLE z1 ENABLE ROW LEVEL SECURITY;
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM z1 WHERE f_leak(b);
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ddd
a | b
---+-----
2 | bbb
(2 rows)
EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b);
- QUERY PLAN
--------------------------------
- Subquery Scan on z1
- Filter: f_leak(z1.b)
- -> Seq Scan on z1 z1_1
- Filter: ((a % 2) = 0)
-(4 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on z1
+ Filter: f_leak(z1.b)
+ -> Seq Scan on z1 z1_1
+ Filter: ((a % 2) = 0)
+(5 rows)
SET ROLE rls_regress_group1;
SELECT * FROM z1 WHERE f_leak(b);
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ddd
a | b
---+-----
2 | bbb
(2 rows)
EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b);
- QUERY PLAN
--------------------------------
- Subquery Scan on z1
- Filter: f_leak(z1.b)
- -> Seq Scan on z1 z1_1
- Filter: ((a % 2) = 0)
-(4 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on z1
+ Filter: f_leak(z1.b)
+ -> Seq Scan on z1 z1_1
+ Filter: ((a % 2) = 0)
+(5 rows)
SET SESSION AUTHORIZATION rls_regress_user2;
SELECT * FROM z1 WHERE f_leak(b);
-NOTICE: f_leak => aaa
-NOTICE: f_leak => ccc
a | b
---+-----
1 | aaa
(2 rows)
EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b);
- QUERY PLAN
--------------------------------
- Subquery Scan on z1
- Filter: f_leak(z1.b)
- -> Seq Scan on z1 z1_1
- Filter: ((a % 2) = 1)
-(4 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on z1
+ Filter: f_leak(z1.b)
+ -> Seq Scan on z1 z1_1
+ Filter: ((a % 2) = 1)
+(5 rows)
SET ROLE rls_regress_group2;
SELECT * FROM z1 WHERE f_leak(b);
-NOTICE: f_leak => aaa
-NOTICE: f_leak => ccc
a | b
---+-----
1 | aaa
(2 rows)
EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b);
- QUERY PLAN
--------------------------------
- Subquery Scan on z1
- Filter: f_leak(z1.b)
- -> Seq Scan on z1 z1_1
- Filter: ((a % 2) = 1)
-(4 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on z1
+ Filter: f_leak(z1.b)
+ -> Seq Scan on z1 z1_1
+ Filter: ((a % 2) = 1)
+(5 rows)
--
-- Views should follow policy for view owner.
-- Query as role that is not owner of view or table. Should return all records.
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM rls_view;
-NOTICE: f_leak => aaa
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ccc
-NOTICE: f_leak => ddd
a | b
---+-----
1 | aaa
(4 rows)
EXPLAIN (COSTS OFF) SELECT * FROM rls_view;
- QUERY PLAN
----------------------
- Seq Scan on z1
- Filter: f_leak(b)
-(2 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on z1
+ Filter: f_leak(b)
+(3 rows)
-- Query as view/table owner. Should return all records.
SET SESSION AUTHORIZATION rls_regress_user0;
SELECT * FROM rls_view;
-NOTICE: f_leak => aaa
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ccc
-NOTICE: f_leak => ddd
a | b
---+-----
1 | aaa
(4 rows)
EXPLAIN (COSTS OFF) SELECT * FROM rls_view;
- QUERY PLAN
----------------------
- Seq Scan on z1
- Filter: f_leak(b)
-(2 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on z1
+ Filter: f_leak(b)
+(3 rows)
DROP VIEW rls_view;
-- View and Table owners are different.
-- Should return records based on view owner policies.
SET SESSION AUTHORIZATION rls_regress_user0;
SELECT * FROM rls_view;
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ddd
a | b
---+-----
2 | bbb
4 | ddd
(2 rows)
-EXPLAIN (COSTS OFF) SELECT * FROM rls_view;
- QUERY PLAN
--------------------------------
- Subquery Scan on z1
- Filter: f_leak(z1.b)
- -> Seq Scan on z1 z1_1
- Filter: ((a % 2) = 0)
-(4 rows)
+EXPLAIN (COSTS OFF) SELECT * FROM rls_view;
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on z1
+ Filter: f_leak(z1.b)
+ -> Seq Scan on z1 z1_1
+ Filter: ((a % 2) = 0)
+(5 rows)
-- Query as role that is not owner of table but is owner of view.
-- Should return records based on view owner policies.
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM rls_view;
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ddd
a | b
---+-----
2 | bbb
(2 rows)
EXPLAIN (COSTS OFF) SELECT * FROM rls_view;
- QUERY PLAN
--------------------------------
- Subquery Scan on z1
- Filter: f_leak(z1.b)
- -> Seq Scan on z1 z1_1
- Filter: ((a % 2) = 0)
-(4 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on z1
+ Filter: f_leak(z1.b)
+ -> Seq Scan on z1 z1_1
+ Filter: ((a % 2) = 0)
+(5 rows)
-- Query as role that is not the owner of the table or view without permissions.
SET SESSION AUTHORIZATION rls_regress_user2;
SET SESSION AUTHORIZATION rls_regress_user1;
GRANT SELECT ON rls_view TO rls_regress_user2;
SELECT * FROM rls_view;
-NOTICE: f_leak => bbb
-NOTICE: f_leak => ddd
a | b
---+-----
2 | bbb
(2 rows)
EXPLAIN (COSTS OFF) SELECT * FROM rls_view;
- QUERY PLAN
--------------------------------
- Subquery Scan on z1
- Filter: f_leak(z1.b)
- -> Seq Scan on z1 z1_1
- Filter: ((a % 2) = 0)
-(4 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on z1
+ Filter: f_leak(z1.b)
+ -> Seq Scan on z1 z1_1
+ Filter: ((a % 2) = 0)
+(5 rows)
SET SESSION AUTHORIZATION rls_regress_user1;
DROP VIEW rls_view;
ALTER TABLE x1 ENABLE ROW LEVEL SECURITY;
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM x1 WHERE f_leak(b) ORDER BY a ASC;
-NOTICE: f_leak => abc
-NOTICE: f_leak => bcd
-NOTICE: f_leak => def
-NOTICE: f_leak => efg
-NOTICE: f_leak => fgh
-NOTICE: f_leak => fgh
a | b | c
---+-----+-------------------
1 | abc | rls_regress_user1
(6 rows)
UPDATE x1 SET b = b || '_updt' WHERE f_leak(b) RETURNING *;
-NOTICE: f_leak => abc
-NOTICE: f_leak => bcd
-NOTICE: f_leak => def
-NOTICE: f_leak => efg
-NOTICE: f_leak => fgh
-NOTICE: f_leak => fgh
a | b | c
---+----------+-------------------
1 | abc_updt | rls_regress_user1
2 | bcd_updt | rls_regress_user1
- 4 | def_updt | rls_regress_user2
5 | efg_updt | rls_regress_user1
6 | fgh_updt | rls_regress_user1
8 | fgh_updt | rls_regress_user2
+ 4 | def_updt | rls_regress_user2
(6 rows)
SET SESSION AUTHORIZATION rls_regress_user2;
SELECT * FROM x1 WHERE f_leak(b) ORDER BY a ASC;
-NOTICE: f_leak => cde
-NOTICE: f_leak => fgh
-NOTICE: f_leak => bcd_updt
-NOTICE: f_leak => def_updt
-NOTICE: f_leak => fgh_updt
-NOTICE: f_leak => fgh_updt
a | b | c
---+----------+-------------------
2 | bcd_updt | rls_regress_user1
(6 rows)
UPDATE x1 SET b = b || '_updt' WHERE f_leak(b) RETURNING *;
-NOTICE: f_leak => cde
-NOTICE: f_leak => fgh
-NOTICE: f_leak => bcd_updt
-NOTICE: f_leak => def_updt
-NOTICE: f_leak => fgh_updt
-NOTICE: f_leak => fgh_updt
a | b | c
---+---------------+-------------------
- 3 | cde_updt | rls_regress_user2
- 7 | fgh_updt | rls_regress_user2
2 | bcd_updt_updt | rls_regress_user1
- 4 | def_updt_updt | rls_regress_user2
6 | fgh_updt_updt | rls_regress_user1
8 | fgh_updt_updt | rls_regress_user2
+ 3 | cde_updt | rls_regress_user2
+ 7 | fgh_updt | rls_regress_user2
+ 4 | def_updt_updt | rls_regress_user2
(6 rows)
DELETE FROM x1 WHERE f_leak(b) RETURNING *;
-NOTICE: f_leak => cde_updt
-NOTICE: f_leak => fgh_updt
-NOTICE: f_leak => bcd_updt_updt
-NOTICE: f_leak => def_updt_updt
-NOTICE: f_leak => fgh_updt_updt
-NOTICE: f_leak => fgh_updt_updt
a | b | c
---+---------------+-------------------
- 3 | cde_updt | rls_regress_user2
- 7 | fgh_updt | rls_regress_user2
2 | bcd_updt_updt | rls_regress_user1
- 4 | def_updt_updt | rls_regress_user2
6 | fgh_updt_updt | rls_regress_user1
8 | fgh_updt_updt | rls_regress_user2
+ 3 | cde_updt | rls_regress_user2
+ 7 | fgh_updt | rls_regress_user2
+ 4 | def_updt_updt | rls_regress_user2
(6 rows)
--
CREATE VIEW rls_sbv WITH (security_barrier) AS
SELECT * FROM y1 WHERE f_leak(b);
EXPLAIN (COSTS OFF) SELECT * FROM rls_sbv WHERE (a = 1);
- QUERY PLAN
------------------------------------
- Seq Scan on y1
- Filter: (f_leak(b) AND (a = 1))
-(2 rows)
+ QUERY PLAN
+------------------------------------------
+ Remote Subquery Scan on all (datanode_1)
+ -> Seq Scan on y1
+ Filter: (f_leak(b) AND (a = 1))
+(3 rows)
DROP VIEW rls_sbv;
-- Create view as role that does not own table. RLS should be applied.
CREATE VIEW rls_sbv WITH (security_barrier) AS
SELECT * FROM y1 WHERE f_leak(b);
EXPLAIN (COSTS OFF) SELECT * FROM rls_sbv WHERE (a = 1);
- QUERY PLAN
-----------------------------------------------------------
- Subquery Scan on y1
- Filter: f_leak(y1.b)
- -> Seq Scan on y1 y1_1
- Filter: ((a = 1) AND ((a > 2) OR ((a % 2) = 0)))
-(4 rows)
+ QUERY PLAN
+----------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1)
+ -> Subquery Scan on y1
+ Filter: f_leak(y1.b)
+ -> Seq Scan on y1 y1_1
+ Filter: ((a = 1) AND ((a > 2) OR ((a % 2) = 0)))
+(5 rows)
DROP VIEW rls_sbv;
--
CREATE POLICY p3 ON y2 USING (a % 4 = 0);
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM y2 WHERE f_leak(b);
-NOTICE: f_leak => cfcd208495d565ef66e7dff9f98764da
-NOTICE: f_leak => c81e728d9d4c2f636f067f89cc14862c
-NOTICE: f_leak => eccbc87e4b5ce2fe28308fd9f2a7baf3
-NOTICE: f_leak => a87ff679a2f3e71d9181a67b7542122c
-NOTICE: f_leak => 1679091c5a880faf6fb5e6087eb1b2dc
-NOTICE: f_leak => c9f0f895fb98ab9159f51fd0297e236d
-NOTICE: f_leak => 45c48cce2e2d7fbdea1afc51c7c6ad26
-NOTICE: f_leak => d3d9446802a44259755d38e6d163e820
-NOTICE: f_leak => c20ad4d76fe97759aa27a0c99bff6710
-NOTICE: f_leak => aab3238922bcc25a6f606eb525ffdc56
-NOTICE: f_leak => 9bf31c7ff062936a96d3c8bd1f8f2ff3
-NOTICE: f_leak => c74d97b01eae257e44aa9d5bade97baf
-NOTICE: f_leak => 6f4922f45568161a8cdf4ad2299f6d23
-NOTICE: f_leak => 98f13708210194c475687be6106a3b84
a | b
----+----------------------------------
- 0 | cfcd208495d565ef66e7dff9f98764da
2 | c81e728d9d4c2f636f067f89cc14862c
- 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
- 4 | a87ff679a2f3e71d9181a67b7542122c
6 | 1679091c5a880faf6fb5e6087eb1b2dc
8 | c9f0f895fb98ab9159f51fd0297e236d
9 | 45c48cce2e2d7fbdea1afc51c7c6ad26
- 10 | d3d9446802a44259755d38e6d163e820
12 | c20ad4d76fe97759aa27a0c99bff6710
- 14 | aab3238922bcc25a6f606eb525ffdc56
15 | 9bf31c7ff062936a96d3c8bd1f8f2ff3
+ 0 | cfcd208495d565ef66e7dff9f98764da
+ 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
+ 4 | a87ff679a2f3e71d9181a67b7542122c
+ 10 | d3d9446802a44259755d38e6d163e820
+ 14 | aab3238922bcc25a6f606eb525ffdc56
16 | c74d97b01eae257e44aa9d5bade97baf
18 | 6f4922f45568161a8cdf4ad2299f6d23
20 | 98f13708210194c475687be6106a3b84
(14 rows)
EXPLAIN (COSTS OFF) SELECT * FROM y2 WHERE f_leak(b);
- QUERY PLAN
--------------------------------------------------------------------
- Subquery Scan on y2
- Filter: f_leak(y2.b)
- -> Seq Scan on y2 y2_1
- Filter: (((a % 4) = 0) OR ((a % 3) = 0) OR ((a % 2) = 0))
-(4 rows)
+ QUERY PLAN
+-------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on y2
+ Filter: f_leak(y2.b)
+ -> Seq Scan on y2 y2_1
+ Filter: (((a % 4) = 0) OR ((a % 3) = 0) OR ((a % 2) = 0))
+(5 rows)
--
-- Qual push-down of leaky functions, when not referring to table
--
SELECT * FROM y2 WHERE f_leak('abc');
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
-NOTICE: f_leak => abc
a | b
----+----------------------------------
- 0 | cfcd208495d565ef66e7dff9f98764da
2 | c81e728d9d4c2f636f067f89cc14862c
- 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
- 4 | a87ff679a2f3e71d9181a67b7542122c
6 | 1679091c5a880faf6fb5e6087eb1b2dc
8 | c9f0f895fb98ab9159f51fd0297e236d
9 | 45c48cce2e2d7fbdea1afc51c7c6ad26
- 10 | d3d9446802a44259755d38e6d163e820
12 | c20ad4d76fe97759aa27a0c99bff6710
- 14 | aab3238922bcc25a6f606eb525ffdc56
15 | 9bf31c7ff062936a96d3c8bd1f8f2ff3
+ 0 | cfcd208495d565ef66e7dff9f98764da
+ 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
+ 4 | a87ff679a2f3e71d9181a67b7542122c
+ 10 | d3d9446802a44259755d38e6d163e820
+ 14 | aab3238922bcc25a6f606eb525ffdc56
16 | c74d97b01eae257e44aa9d5bade97baf
18 | 6f4922f45568161a8cdf4ad2299f6d23
20 | 98f13708210194c475687be6106a3b84
(14 rows)
EXPLAIN (COSTS OFF) SELECT * FROM y2 WHERE f_leak('abc');
- QUERY PLAN
----------------------------------------------------------------------------------------
- Seq Scan on y2
- Filter: (f_leak('abc'::text) AND (((a % 4) = 0) OR ((a % 3) = 0) OR ((a % 2) = 0)))
-(2 rows)
+ QUERY PLAN
+---------------------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on y2
+ Filter: (f_leak('abc'::text) AND (((a % 4) = 0) OR ((a % 3) = 0) OR ((a % 2) = 0)))
+(3 rows)
CREATE TABLE test_qual_pushdown (
abc text
);
INSERT INTO test_qual_pushdown VALUES ('abc'),('def');
SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(abc);
-NOTICE: f_leak => abc
-NOTICE: f_leak => def
a | b | abc
---+---+-----
(0 rows)
EXPLAIN (COSTS OFF) SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(abc);
- QUERY PLAN
--------------------------------------------------------------------------
- Hash Join
- Hash Cond: (test_qual_pushdown.abc = y2.b)
- -> Seq Scan on test_qual_pushdown
- Filter: f_leak(abc)
- -> Hash
- -> Seq Scan on y2
- Filter: (((a % 4) = 0) OR ((a % 3) = 0) OR ((a % 2) = 0))
-(7 rows)
+ QUERY PLAN
+-------------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Hash Join
+ Hash Cond: (test_qual_pushdown.abc = b)
+ -> Seq Scan on test_qual_pushdown
+ Filter: f_leak(abc)
+ -> Hash
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ Distribute results by H: b
+ -> Seq Scan on y2
+ Filter: (((a % 4) = 0) OR ((a % 3) = 0) OR ((a % 2) = 0))
+(10 rows)
SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(b);
-NOTICE: f_leak => cfcd208495d565ef66e7dff9f98764da
-NOTICE: f_leak => c81e728d9d4c2f636f067f89cc14862c
-NOTICE: f_leak => eccbc87e4b5ce2fe28308fd9f2a7baf3
-NOTICE: f_leak => a87ff679a2f3e71d9181a67b7542122c
-NOTICE: f_leak => 1679091c5a880faf6fb5e6087eb1b2dc
-NOTICE: f_leak => c9f0f895fb98ab9159f51fd0297e236d
-NOTICE: f_leak => 45c48cce2e2d7fbdea1afc51c7c6ad26
-NOTICE: f_leak => d3d9446802a44259755d38e6d163e820
-NOTICE: f_leak => c20ad4d76fe97759aa27a0c99bff6710
-NOTICE: f_leak => aab3238922bcc25a6f606eb525ffdc56
-NOTICE: f_leak => 9bf31c7ff062936a96d3c8bd1f8f2ff3
-NOTICE: f_leak => c74d97b01eae257e44aa9d5bade97baf
-NOTICE: f_leak => 6f4922f45568161a8cdf4ad2299f6d23
-NOTICE: f_leak => 98f13708210194c475687be6106a3b84
a | b | abc
---+---+-----
(0 rows)
EXPLAIN (COSTS OFF) SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(b);
- QUERY PLAN
--------------------------------------------------------------------------------
- Hash Join
- Hash Cond: (test_qual_pushdown.abc = y2.b)
- -> Seq Scan on test_qual_pushdown
- -> Hash
- -> Subquery Scan on y2
- Filter: f_leak(y2.b)
- -> Seq Scan on y2 y2_1
- Filter: (((a % 4) = 0) OR ((a % 3) = 0) OR ((a % 2) = 0))
-(8 rows)
+ QUERY PLAN
+-------------------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Hash Join
+ Hash Cond: (test_qual_pushdown.abc = y2.b)
+ -> Seq Scan on test_qual_pushdown
+ -> Hash
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ Distribute results by H: b
+ -> Subquery Scan on y2
+ Filter: f_leak(y2.b)
+ -> Seq Scan on y2 y2_1
+ Filter: (((a % 4) = 0) OR ((a % 3) = 0) OR ((a % 2) = 0))
+(11 rows)
DROP TABLE test_qual_pushdown;
--
SET ROLE rls_regress_user1;
PREPARE role_inval AS SELECT * FROM t1;
EXPLAIN (COSTS OFF) EXECUTE role_inval;
- QUERY PLAN
--------------------------
- Seq Scan on t1
- Filter: ((a % 2) = 0)
-(2 rows)
+ QUERY PLAN
+----------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
+ -> Seq Scan on t1
+ Filter: ((a % 2) = 0)
+(4 rows)
SET ROLE rls_regress_user2;
EXPLAIN (COSTS OFF) EXECUTE role_inval;
- QUERY PLAN
--------------------------
- Seq Scan on t1
- Filter: ((a % 4) = 0)
-(2 rows)
+ QUERY PLAN
+----------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
+ -> Seq Scan on t1
+ Filter: ((a % 4) = 0)
+(4 rows)
--
-- CTE and RLS
INSERT INTO t1 (SELECT x, md5(x::text) FROM generate_series(0,20) x);
SET SESSION AUTHORIZATION rls_regress_user1;
WITH cte1 AS (SELECT * FROM t1 WHERE f_leak(b)) SELECT * FROM cte1;
-NOTICE: f_leak => cfcd208495d565ef66e7dff9f98764da
-NOTICE: f_leak => c81e728d9d4c2f636f067f89cc14862c
-NOTICE: f_leak => a87ff679a2f3e71d9181a67b7542122c
-NOTICE: f_leak => 1679091c5a880faf6fb5e6087eb1b2dc
-NOTICE: f_leak => c9f0f895fb98ab9159f51fd0297e236d
-NOTICE: f_leak => d3d9446802a44259755d38e6d163e820
-NOTICE: f_leak => c20ad4d76fe97759aa27a0c99bff6710
-NOTICE: f_leak => aab3238922bcc25a6f606eb525ffdc56
-NOTICE: f_leak => c74d97b01eae257e44aa9d5bade97baf
-NOTICE: f_leak => 6f4922f45568161a8cdf4ad2299f6d23
-NOTICE: f_leak => 98f13708210194c475687be6106a3b84
a | b
----+----------------------------------
- 0 | cfcd208495d565ef66e7dff9f98764da
2 | c81e728d9d4c2f636f067f89cc14862c
- 4 | a87ff679a2f3e71d9181a67b7542122c
6 | 1679091c5a880faf6fb5e6087eb1b2dc
8 | c9f0f895fb98ab9159f51fd0297e236d
- 10 | d3d9446802a44259755d38e6d163e820
12 | c20ad4d76fe97759aa27a0c99bff6710
+ 0 | cfcd208495d565ef66e7dff9f98764da
+ 4 | a87ff679a2f3e71d9181a67b7542122c
+ 10 | d3d9446802a44259755d38e6d163e820
14 | aab3238922bcc25a6f606eb525ffdc56
16 | c74d97b01eae257e44aa9d5bade97baf
18 | 6f4922f45568161a8cdf4ad2299f6d23
(11 rows)
EXPLAIN (COSTS OFF) WITH cte1 AS (SELECT * FROM t1 WHERE f_leak(b)) SELECT * FROM cte1;
- QUERY PLAN
----------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------
CTE Scan on cte1
CTE cte1
- -> Subquery Scan on t1
- Filter: f_leak(t1.b)
- -> Seq Scan on t1 t1_1
- Filter: ((a % 2) = 0)
-(6 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Subquery Scan on t1
+ Filter: f_leak(t1.b)
+ -> Seq Scan on t1 t1_1
+ Filter: ((a % 2) = 0)
+(7 rows)
WITH cte1 AS (UPDATE t1 SET a = a + 1 RETURNING *) SELECT * FROM cte1; --fail
-ERROR: new row violates row level security policy for "t1"
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
WITH cte1 AS (UPDATE t1 SET a = a RETURNING *) SELECT * FROM cte1; --ok
- a | b
-----+----------------------------------
- 0 | cfcd208495d565ef66e7dff9f98764da
- 2 | c81e728d9d4c2f636f067f89cc14862c
- 4 | a87ff679a2f3e71d9181a67b7542122c
- 6 | 1679091c5a880faf6fb5e6087eb1b2dc
- 8 | c9f0f895fb98ab9159f51fd0297e236d
- 10 | d3d9446802a44259755d38e6d163e820
- 12 | c20ad4d76fe97759aa27a0c99bff6710
- 14 | aab3238922bcc25a6f606eb525ffdc56
- 16 | c74d97b01eae257e44aa9d5bade97baf
- 18 | 6f4922f45568161a8cdf4ad2299f6d23
- 20 | 98f13708210194c475687be6106a3b84
-(11 rows)
-
+ERROR: INSERT/UPDATE/DELETE is not supported in subquery
WITH cte1 AS (INSERT INTO t1 VALUES (21, 'Fail') RETURNING *) SELECT * FROM cte1; --fail
-ERROR: new row violates row level security policy for "t1"
+ERROR: INSERT/UPDATE/DELETE is not supported in subquery
WITH cte1 AS (INSERT INTO t1 VALUES (20, 'Success') RETURNING *) SELECT * FROM cte1; --ok
- a | b
-----+---------
- 20 | Success
-(1 row)
-
+ERROR: INSERT/UPDATE/DELETE is not supported in subquery
--
-- Rename Policy
--
CREATE TABLE t2 (a integer, b text);
INSERT INTO t2 (SELECT * FROM t1);
EXPLAIN (COSTS OFF) INSERT INTO t2 (SELECT * FROM t1);
- QUERY PLAN
--------------------------------
- Insert on t2
- -> Seq Scan on t1
- Filter: ((a % 2) = 0)
-(3 rows)
+ QUERY PLAN
+-----------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Insert on t2
+ -> Seq Scan on t1
+ Filter: ((a % 2) = 0)
+(4 rows)
SELECT * FROM t2;
a | b
----+----------------------------------
- 0 | cfcd208495d565ef66e7dff9f98764da
2 | c81e728d9d4c2f636f067f89cc14862c
- 4 | a87ff679a2f3e71d9181a67b7542122c
6 | 1679091c5a880faf6fb5e6087eb1b2dc
8 | c9f0f895fb98ab9159f51fd0297e236d
- 10 | d3d9446802a44259755d38e6d163e820
12 | c20ad4d76fe97759aa27a0c99bff6710
+ 0 | cfcd208495d565ef66e7dff9f98764da
+ 4 | a87ff679a2f3e71d9181a67b7542122c
+ 10 | d3d9446802a44259755d38e6d163e820
14 | aab3238922bcc25a6f606eb525ffdc56
16 | c74d97b01eae257e44aa9d5bade97baf
18 | 6f4922f45568161a8cdf4ad2299f6d23
20 | 98f13708210194c475687be6106a3b84
- 20 | Success
-(12 rows)
+(11 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t2;
- QUERY PLAN
-----------------
- Seq Scan on t2
-(1 row)
+ QUERY PLAN
+----------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
+ -> Seq Scan on t2
+(3 rows)
CREATE TABLE t3 AS SELECT * FROM t1;
SELECT * FROM t3;
a | b
----+----------------------------------
- 0 | cfcd208495d565ef66e7dff9f98764da
2 | c81e728d9d4c2f636f067f89cc14862c
- 4 | a87ff679a2f3e71d9181a67b7542122c
6 | 1679091c5a880faf6fb5e6087eb1b2dc
8 | c9f0f895fb98ab9159f51fd0297e236d
- 10 | d3d9446802a44259755d38e6d163e820
12 | c20ad4d76fe97759aa27a0c99bff6710
+ 0 | cfcd208495d565ef66e7dff9f98764da
+ 4 | a87ff679a2f3e71d9181a67b7542122c
+ 10 | d3d9446802a44259755d38e6d163e820
14 | aab3238922bcc25a6f606eb525ffdc56
16 | c74d97b01eae257e44aa9d5bade97baf
18 | 6f4922f45568161a8cdf4ad2299f6d23
20 | 98f13708210194c475687be6106a3b84
- 20 | Success
-(12 rows)
+(11 rows)
SELECT * INTO t4 FROM t1;
SELECT * FROM t4;
a | b
----+----------------------------------
- 0 | cfcd208495d565ef66e7dff9f98764da
2 | c81e728d9d4c2f636f067f89cc14862c
- 4 | a87ff679a2f3e71d9181a67b7542122c
6 | 1679091c5a880faf6fb5e6087eb1b2dc
8 | c9f0f895fb98ab9159f51fd0297e236d
- 10 | d3d9446802a44259755d38e6d163e820
12 | c20ad4d76fe97759aa27a0c99bff6710
+ 0 | cfcd208495d565ef66e7dff9f98764da
+ 4 | a87ff679a2f3e71d9181a67b7542122c
+ 10 | d3d9446802a44259755d38e6d163e820
14 | aab3238922bcc25a6f606eb525ffdc56
16 | c74d97b01eae257e44aa9d5bade97baf
18 | 6f4922f45568161a8cdf4ad2299f6d23
20 | 98f13708210194c475687be6106a3b84
- 20 | Success
-(12 rows)
+(11 rows)
--
-- RLS with JOIN
SELECT id, author, message FROM blog JOIN comment ON id = blog_id;
id | author | message
----+--------+-------------
- 4 | alice | insane!
2 | bob | who did it?
+ 4 | alice | insane!
(2 rows)
-- Check Non-RLS JOIN with RLS.
SELECT id, author, message FROM comment JOIN blog ON id = blog_id;
id | author | message
----+--------+-------------
- 4 | alice | insane!
2 | bob | who did it?
+ 4 | alice | insane!
(2 rows)
SET SESSION AUTHORIZATION rls_regress_user0;
a | b
----+----------------------------------
1 | c4ca4238a0b923820dcc509a6f75849b
- 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
+ 2 | c81e728d9d4c2f636f067f89cc14862c
5 | e4da3b7fbbce2345d7772b0674a318d5
- 7 | 8f14e45fceea167a5a36dedd4bea2543
+ 6 | 1679091c5a880faf6fb5e6087eb1b2dc
+ 8 | c9f0f895fb98ab9159f51fd0297e236d
9 | 45c48cce2e2d7fbdea1afc51c7c6ad26
- 11 | 6512bd43d9caa6e02c990b0a82652dca
+ 12 | c20ad4d76fe97759aa27a0c99bff6710
13 | c51ce410c124a10e0db5e4b97fc2af39
15 | 9bf31c7ff062936a96d3c8bd1f8f2ff3
17 | 70efdf2ec9b086079795c442636b55fb
19 | 1f0e3dad99908345f7439f8ffabdffc4
0 | cfcd208495d565ef66e7dff9f98764da
- 2 | c81e728d9d4c2f636f067f89cc14862c
+ 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
4 | a87ff679a2f3e71d9181a67b7542122c
- 6 | 1679091c5a880faf6fb5e6087eb1b2dc
- 8 | c9f0f895fb98ab9159f51fd0297e236d
+ 7 | 8f14e45fceea167a5a36dedd4bea2543
10 | d3d9446802a44259755d38e6d163e820
- 12 | c20ad4d76fe97759aa27a0c99bff6710
+ 11 | 6512bd43d9caa6e02c990b0a82652dca
14 | aab3238922bcc25a6f606eb525ffdc56
16 | c74d97b01eae257e44aa9d5bade97baf
18 | 6f4922f45568161a8cdf4ad2299f6d23
20 | 98f13708210194c475687be6106a3b84
- 20 | Success
-(22 rows)
+(21 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1;
- QUERY PLAN
-----------------
- Seq Scan on t1
-(1 row)
+ QUERY PLAN
+----------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
+ -> Seq Scan on t1
+(3 rows)
-- Check that default deny does not apply to table owner.
SET SESSION AUTHORIZATION rls_regress_user0;
a | b
----+----------------------------------
1 | c4ca4238a0b923820dcc509a6f75849b
- 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
+ 2 | c81e728d9d4c2f636f067f89cc14862c
5 | e4da3b7fbbce2345d7772b0674a318d5
- 7 | 8f14e45fceea167a5a36dedd4bea2543
+ 6 | 1679091c5a880faf6fb5e6087eb1b2dc
+ 8 | c9f0f895fb98ab9159f51fd0297e236d
9 | 45c48cce2e2d7fbdea1afc51c7c6ad26
- 11 | 6512bd43d9caa6e02c990b0a82652dca
+ 12 | c20ad4d76fe97759aa27a0c99bff6710
13 | c51ce410c124a10e0db5e4b97fc2af39
15 | 9bf31c7ff062936a96d3c8bd1f8f2ff3
17 | 70efdf2ec9b086079795c442636b55fb
19 | 1f0e3dad99908345f7439f8ffabdffc4
0 | cfcd208495d565ef66e7dff9f98764da
- 2 | c81e728d9d4c2f636f067f89cc14862c
+ 3 | eccbc87e4b5ce2fe28308fd9f2a7baf3
4 | a87ff679a2f3e71d9181a67b7542122c
- 6 | 1679091c5a880faf6fb5e6087eb1b2dc
- 8 | c9f0f895fb98ab9159f51fd0297e236d
+ 7 | 8f14e45fceea167a5a36dedd4bea2543
10 | d3d9446802a44259755d38e6d163e820
- 12 | c20ad4d76fe97759aa27a0c99bff6710
+ 11 | 6512bd43d9caa6e02c990b0a82652dca
14 | aab3238922bcc25a6f606eb525ffdc56
16 | c74d97b01eae257e44aa9d5bade97baf
18 | 6f4922f45568161a8cdf4ad2299f6d23
20 | 98f13708210194c475687be6106a3b84
- 20 | Success
-(22 rows)
+(21 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1;
- QUERY PLAN
-----------------
- Seq Scan on t1
-(1 row)
+ QUERY PLAN
+----------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
+ -> Seq Scan on t1
+(3 rows)
-- Check that default deny applies to non-owner/non-superuser when RLS on.
SET SESSION AUTHORIZATION rls_regress_user1;
(0 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1;
- QUERY PLAN
---------------------------
- Result
- One-Time Filter: false
-(2 rows)
+ QUERY PLAN
+----------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
+ -> Result
+ One-Time Filter: false
+(4 rows)
SET SESSION AUTHORIZATION rls_regress_user1;
SELECT * FROM t1;
(0 rows)
EXPLAIN (COSTS OFF) SELECT * FROM t1;
- QUERY PLAN
---------------------------
- Result
- One-Time Filter: false
-(2 rows)
+ QUERY PLAN
+----------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
+ -> Result
+ One-Time Filter: false
+(4 rows)
--
-- COPY TO/FROM
-- Still cannot UPDATE row 2 through cursor
UPDATE current_check SET payload = payload || '_new' WHERE CURRENT OF current_check_cursor RETURNING *;
- currentid | payload | rlsuser
------------+---------+---------
-(0 rows)
-
+ERROR: WHERE CURRENT OF clause not yet supported
-- Can update row 4 through cursor, which is the next visible row
FETCH RELATIVE 1 FROM current_check_cursor;
- currentid | payload | rlsuser
------------+---------+-------------------
- 4 | def | rls_regress_user1
-(1 row)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
UPDATE current_check SET payload = payload || '_new' WHERE CURRENT OF current_check_cursor RETURNING *;
- currentid | payload | rlsuser
------------+---------+-------------------
- 4 | def_new | rls_regress_user1
-(1 row)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
SELECT * FROM current_check;
- currentid | payload | rlsuser
------------+---------+-------------------
- 2 | bcd | rls_regress_user1
- 4 | def_new | rls_regress_user1
-(2 rows)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
-- Plan should be a subquery TID scan
EXPLAIN (COSTS OFF) UPDATE current_check SET payload = payload WHERE CURRENT OF current_check_cursor;
- QUERY PLAN
----------------------------------------------------------------------
- Update on current_check current_check_1
- -> Subquery Scan on current_check
- -> Subquery Scan on current_check_2
- Filter: ((current_check_2.currentid % 2) = 0)
- -> LockRows
- -> Tid Scan on current_check current_check_3
- TID Cond: CURRENT OF current_check_cursor
- Filter: (currentid = 4)
-(8 rows)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
-- Similarly can only delete row 4
FETCH ABSOLUTE 1 FROM current_check_cursor;
- currentid | payload | rlsuser
------------+---------+-------------------
- 2 | bcd | rls_regress_user1
-(1 row)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
DELETE FROM current_check WHERE CURRENT OF current_check_cursor RETURNING *;
- currentid | payload | rlsuser
------------+---------+---------
-(0 rows)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
FETCH RELATIVE 1 FROM current_check_cursor;
- currentid | payload | rlsuser
------------+---------+-------------------
- 4 | def | rls_regress_user1
-(1 row)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
DELETE FROM current_check WHERE CURRENT OF current_check_cursor RETURNING *;
- currentid | payload | rlsuser
------------+---------+-------------------
- 4 | def_new | rls_regress_user1
-(1 row)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
SELECT * FROM current_check;
- currentid | payload | rlsuser
------------+---------+-------------------
- 2 | bcd | rls_regress_user1
-(1 row)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
COMMIT;
--
-- check pg_stats view filtering
SELECT attname, most_common_vals FROM pg_stats
WHERE tablename = 'current_check'
ORDER BY 1;
- attname | most_common_vals
------------+---------------------
+ attname | most_common_vals
+-----------+--------------------------------------
currentid |
payload |
- rlsuser | {rls_regress_user1}
+ rlsuser | (pg_catalog.text){rls_regress_user1}
(3 rows)
SET SESSION AUTHORIZATION rls_regress_user1;
(2 rows)
SAVEPOINT q;
+ERROR: SAVEPOINT is not yet supported.
DROP ROLE alice; --fails due to dependency on POLICY p
-ERROR: role "alice" cannot be dropped because some objects depend on it
-DETAIL: target of policy p on table tbl1
-privileges for table tbl1
+ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK TO q;
+ERROR: no such savepoint
ALTER POLICY p ON tbl1 TO bob USING (true);
+ERROR: current transaction is aborted, commands ignored until end of transaction block
SAVEPOINT q;
+ERROR: current transaction is aborted, commands ignored until end of transaction block
DROP ROLE alice; --fails due to dependency on GRANT SELECT
-ERROR: role "alice" cannot be dropped because some objects depend on it
-DETAIL: privileges for table tbl1
+ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK TO q;
+ERROR: no such savepoint
REVOKE ALL ON TABLE tbl1 FROM alice;
+ERROR: current transaction is aborted, commands ignored until end of transaction block
SAVEPOINT q;
+ERROR: current transaction is aborted, commands ignored until end of transaction block
DROP ROLE alice; --succeeds
+ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK TO q;
+ERROR: no such savepoint
SAVEPOINT q;
+ERROR: current transaction is aborted, commands ignored until end of transaction block
DROP ROLE bob; --fails due to dependency on POLICY p
-ERROR: role "bob" cannot be dropped because some objects depend on it
-DETAIL: target of policy p on table tbl1
+ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK TO q;
+ERROR: no such savepoint
DROP POLICY p ON tbl1;
+ERROR: current transaction is aborted, commands ignored until end of transaction block
SAVEPOINT q;
+ERROR: current transaction is aborted, commands ignored until end of transaction block
DROP ROLE bob; -- succeeds
+ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK TO q;
+ERROR: no such savepoint
ROLLBACK; -- cleanup
--
-- Converting table to view
CREATE POLICY p ON t USING (c % 2 = 1);
ALTER TABLE t ENABLE ROW LEVEL SECURITY;
SAVEPOINT q;
+ERROR: SAVEPOINT is not yet supported.
CREATE RULE "_RETURN" AS ON SELECT TO t DO INSTEAD
SELECT * FROM generate_series(1,5) t0(c); -- fails due to row level security enabled
-ERROR: could not convert table "t" to a view because it has row security enabled
+ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK TO q;
+ERROR: no such savepoint
ALTER TABLE t DISABLE ROW LEVEL SECURITY;
+ERROR: current transaction is aborted, commands ignored until end of transaction block
SAVEPOINT q;
+ERROR: current transaction is aborted, commands ignored until end of transaction block
CREATE RULE "_RETURN" AS ON SELECT TO t DO INSTEAD
SELECT * FROM generate_series(1,5) t0(c); -- fails due to policy p on t
-ERROR: could not convert table "t" to a view because it has row security policies
+ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK TO q;
+ERROR: no such savepoint
DROP POLICY p ON t;
+ERROR: current transaction is aborted, commands ignored until end of transaction block
CREATE RULE "_RETURN" AS ON SELECT TO t DO INSTEAD
SELECT * FROM generate_series(1,5) t0(c); -- succeeds
+ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
--
-- Policy expression handling
INSERT INTO r2 VALUES (2); -- Not allowed
ERROR: new row violates row level security policy for "r2"
UPDATE r2 SET a = 2 RETURNING *; -- Updates nothing
- a
----
-(0 rows)
-
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
DELETE FROM r2 RETURNING *; -- Deletes nothing
a
---
INSERT INTO r1 SELECT a + 1 FROM r2 RETURNING *; -- OK
a
----
- 11
21
+ 11
(2 rows)
UPDATE r1 SET a = r2.a + 2 FROM r2 WHERE r1.a = r2.a RETURNING *; -- OK
- a | a
-----+----
- 12 | 10
- 22 | 20
-(2 rows)
-
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
DELETE FROM r1 USING r2 WHERE r1.a = r2.a + 2 RETURNING *; -- OK
- a | a
-----+----
- 12 | 10
- 22 | 20
-(2 rows)
+ a | a
+---+---
+(0 rows)
SELECT * FROM r1;
a
----
- 11
21
-(2 rows)
+ 10
+ 20
+ 11
+(4 rows)
SELECT * FROM r2;
a
ERROR: new row violates row level security policy for "r1"
-- No error (unable to see any rows to update)
UPDATE r1 SET a = 1;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
TABLE r1;
a
---
-- Update all rows
UPDATE r1 SET a = 1;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
TABLE r1;
- a
----
- 1
- 1
+ a
+----
+ 10
+ 20
(2 rows)
-- Delete all rows
ALTER TABLE r2 FORCE ROW LEVEL SECURITY;
-- Updates records in both
UPDATE r1 SET a = a+5;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
-- Remove FORCE from r2
ALTER TABLE r2 NO FORCE ROW LEVEL SECURITY;
-- As owner, we now bypass RLS
TABLE r2;
a
----
- 15
- 25
+ 10
+ 20
(2 rows)
DROP TABLE r2;
ALTER TABLE r1 FORCE ROW LEVEL SECURITY;
-- Works fine
UPDATE r1 SET a = 30;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
-- Show updated rows
SET row_security = off;
TABLE r1;
a
----
- 30
+ 10
(1 row)
-- reset value in r1 for test with RETURNING
UPDATE r1 SET a = 10;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
-- Verify row reset
TABLE r1;
a
SET row_security = on;
-- Error
UPDATE r1 SET a = 30 RETURNING *;
-ERROR: new row violates row level security policy for "r1"
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
DROP TABLE r1;
--
-- Clean up objects
where i8 in (row(123,456)::int8_tbl, '(4567890123456789,123)');
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------
- Remote Subquery Scan on all (datanode_2)
+ Remote Fast Query Execution
+ Node/s: datanode_2
-> Seq Scan on int8_tbl i8
Filter: (i8.* = ANY (ARRAY[ROW('123'::bigint, '456'::bigint)::int8_tbl, '(4567890123456789,123)'::int8_tbl]))
-(3 rows)
+(4 rows)
select * from int8_tbl i8
where i8 in (row(123,456)::int8_tbl, '(4567890123456789,123)');
SET active = true, price = input_prices.price
FROM unnest(ARRAY[(10, 123.00), (11, 99.99)]::price_input[]) input_prices
WHERE price_key_from_table(price.*) = price_key_from_input(input_prices.*);
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select * from price;
- id | active | price
-----+--------+--------
- 1 | f | 42
- 10 | t | 123.00
- 11 | t | 99.99
-(3 rows)
-
+ERROR: current transaction is aborted, commands ignored until end of transaction block
rollback;
--
-- Test case derived from bug #9085: check * qualification of composite
create function fcompos1(v compos) returns void as $$
insert into compos values (v.*);
$$ language sql;
+ERROR: type compos does not exist
create function fcompos2(v compos) returns void as $$
select fcompos1(v);
$$ language sql;
+ERROR: function fcompos1(compos) does not exist
+LINE 2: select fcompos1(v);
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
create function fcompos3(v compos) returns void as $$
select fcompos1(fcompos3.v.*);
$$ language sql;
+ERROR: function fcompos1(compos) does not exist
+LINE 2: select fcompos1(fcompos3.v.*);
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
select fcompos1(row(1,'one'));
- fcompos1
-----------
-
-(1 row)
-
+ERROR: function fcompos1(record) does not exist
+LINE 1: select fcompos1(row(1,'one'));
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
select fcompos2(row(2,'two'));
- fcompos2
-----------
-
-(1 row)
-
+ERROR: function fcompos2(record) does not exist
+LINE 1: select fcompos2(row(2,'two'));
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
select fcompos3(row(3,'three'));
- fcompos3
-----------
-
-(1 row)
-
+ERROR: function fcompos3(record) does not exist
+LINE 1: select fcompos3(row(3,'three'));
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
select * from compos;
- f1 | f2
-----+-------
- 1 | one
- 2 | two
- 3 | three
-(3 rows)
+ f1 | f2
+----+----
+(0 rows)
--
-- We allow I/O conversion casts from composite types to strings to be
create temp view vv1 as select * from int8_tbl;
select row_to_json(i) from vv1 i;
- row_to_json
-------------------------------------------------
- {"q1":123,"q2":456}
- {"q1":123,"q2":4567890123456789}
- {"q1":4567890123456789,"q2":123}
- {"q1":4567890123456789,"q2":4567890123456789}
- {"q1":4567890123456789,"q2":-4567890123456789}
-(5 rows)
-
+ERROR: cache lookup failed for type 0
select row_to_json(i) from vv1 i(x,y);
- row_to_json
-----------------------------------------------
- {"x":123,"y":456}
- {"x":123,"y":4567890123456789}
- {"x":4567890123456789,"y":123}
- {"x":4567890123456789,"y":4567890123456789}
- {"x":4567890123456789,"y":-4567890123456789}
-(5 rows)
-
+ERROR: cache lookup failed for type 0
select row_to_json(ss) from
(select q1, q2 from int8_tbl) as ss;
row_to_json
-- updates in a mergejoin
update rtest_v1 set b = rtest_t2.b from rtest_t2 where rtest_v1.a = rtest_t2.a;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select * from rtest_v1 order by a, b;
a | b
---+----
- 1 | 21
- 2 | 22
- 3 | 23
+ 1 | 31
+ 2 | 32
+ 3 | 33
(3 rows)
insert into rtest_v1 select * from rtest_t3;
select * from rtest_v1 order by a, b;
a | b
---+----
- 1 | 21
1 | 31
- 2 | 22
+ 1 | 31
2 | 32
- 3 | 23
+ 2 | 32
+ 3 | 33
3 | 33
4 | 34
5 | 35
select * from rtest_v1 order by a, b;
a | b
----+----
- 1 | 21
- 2 | 22
- 3 | 23
11 | 31
+ 11 | 31
+ 12 | 32
12 | 32
13 | 33
+ 13 | 33
14 | 34
15 | 35
(8 rows)
update rtest_v1 set a = rtest_t3.a + 20 from rtest_t3 where rtest_v1.b = rtest_t3.b;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select * from rtest_v1 order by a, b;
a | b
----+----
- 1 | 21
- 2 | 22
- 3 | 23
- 21 | 31
- 22 | 32
- 23 | 33
- 24 | 34
- 25 | 35
+ 11 | 31
+ 11 | 31
+ 12 | 32
+ 12 | 32
+ 13 | 33
+ 13 | 33
+ 14 | 34
+ 15 | 35
(8 rows)
--
insert into rtest_admin values ('jw', 'notjw');
insert into rtest_admin values ('bm', 'neptun');
update rtest_system set sysname = 'pluto' where sysname = 'neptun';
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select * from rtest_interface order by sysname, ifname;
sysname | ifname
---------+--------
+ neptun | eth0
notjw | eth0
orion | eth0
orion | eth1
- pluto | eth0
(4 rows)
select * from rtest_admin order by pname, sysname;
pname | sysname
-------+---------
- bm | pluto
+ bm | neptun
jw | notjw
jw | orion
(3 rows)
update rtest_person set pname = 'jwieck' where pdesc = 'Jan Wieck';
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
-- Note: use ORDER BY here to ensure consistent output across all systems.
-- The above UPDATE affects two rows with equal keys, so they could be
-- updated in either order depending on the whim of the local qsort().
select * from rtest_admin order by pname, sysname;
- pname | sysname
---------+---------
- bm | pluto
- jwieck | notjw
- jwieck | orion
+ pname | sysname
+-------+---------
+ bm | neptun
+ jw | notjw
+ jw | orion
(3 rows)
delete from rtest_system where sysname = 'orion';
+ERROR: could not plan this distributed delete
+DETAIL: correlated or complex DELETE is currently not supported in Postgres-XL.
select * from rtest_interface order by sysname, ifname;
sysname | ifname
---------+--------
+ neptun | eth0
notjw | eth0
- pluto | eth0
-(2 rows)
+ orion | eth0
+ orion | eth1
+(4 rows)
select * from rtest_admin order by pname, sysname;
- pname | sysname
---------+---------
- bm | pluto
- jwieck | notjw
-(2 rows)
+ pname | sysname
+-------+---------
+ bm | neptun
+ jw | notjw
+ jw | orion
+(3 rows)
--
-- Rule qualification test
update rtest_empmass set salary = salary + '1000.00';
update rtest_emp set salary = rtest_empmass.salary from rtest_empmass where rtest_emp.ename = rtest_empmass.ename;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
ename | matches user | action | newsal | oldsal
----------------------+--------------+------------+------------+------------
gates | t | fired | $0.00 | $80,000.00
gates | t | hired | $80,000.00 | $0.00
maier | t | hired | $5,000.00 | $0.00
- maier | t | honored | $6,000.00 | $5,000.00
mayr | t | hired | $6,000.00 | $0.00
- mayr | t | honored | $7,000.00 | $6,000.00
meyer | t | hired | $4,000.00 | $0.00
- meyer | t | honored | $5,000.00 | $4,000.00
wiecc | t | hired | $5,000.00 | $0.00
wieck | t | honored | $6,000.00 | $5,000.00
wieck | t | honored | $7,000.00 | $6,000.00
-(11 rows)
+(8 rows)
delete from rtest_emp using rtest_empmass where rtest_emp.ename = rtest_empmass.ename;
+ERROR: could not plan this distributed delete
+DETAIL: correlated or complex DELETE is currently not supported in Postgres-XL.
select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
ename | matches user | action | newsal | oldsal
----------------------+--------------+------------+------------+------------
gates | t | fired | $0.00 | $80,000.00
gates | t | hired | $80,000.00 | $0.00
- maier | t | fired | $0.00 | $6,000.00
maier | t | hired | $5,000.00 | $0.00
- maier | t | honored | $6,000.00 | $5,000.00
- mayr | t | fired | $0.00 | $7,000.00
mayr | t | hired | $6,000.00 | $0.00
- mayr | t | honored | $7,000.00 | $6,000.00
- meyer | t | fired | $0.00 | $5,000.00
meyer | t | hired | $4,000.00 | $0.00
- meyer | t | honored | $5,000.00 | $4,000.00
wiecc | t | hired | $5,000.00 | $0.00
wieck | t | honored | $6,000.00 | $5,000.00
wieck | t | honored | $7,000.00 | $6,000.00
-(14 rows)
+(8 rows)
--
-- Multiple cascaded qualified instead rule test
(8 rows)
insert into shoelace_ok select * from shoelace_arrive;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
SELECT * FROM shoelace ORDER BY sl_name;
sl_name | sl_avail | sl_color | sl_len | sl_unit | sl_len_cm
------------+----------+------------+--------+----------+-----------
sl1 | 5 | black | 80 | cm | 80
sl2 | 6 | black | 100 | cm | 100
- sl3 | 10 | black | 35 | inch | 88.9
+ sl3 | 0 | black | 35 | inch | 88.9
sl4 | 8 | black | 40 | inch | 101.6
sl5 | 4 | brown | 1 | m | 100
- sl6 | 20 | brown | 0.9 | m | 90
+ sl6 | 0 | brown | 0.9 | m | 90
sl7 | 6 | brown | 60 | cm | 60
- sl8 | 21 | brown | 40 | inch | 101.6
+ sl8 | 1 | brown | 40 | inch | 101.6
(8 rows)
SELECT * FROM shoelace_log ORDER BY sl_name;
sl_name | sl_avail | log_who | log_when
------------+----------+----------+--------------------------
- sl3 | 10 | Al Bundy | Thu Jan 01 00:00:00 1970
- sl6 | 20 | Al Bundy | Thu Jan 01 00:00:00 1970
sl7 | 6 | Al Bundy | Thu Jan 01 00:00:00 1970
- sl8 | 21 | Al Bundy | Thu Jan 01 00:00:00 1970
-(4 rows)
+(1 row)
CREATE VIEW shoelace_obsolete AS
SELECT * FROM shoelace WHERE NOT EXISTS
DELETE FROM shoelace WHERE EXISTS
(SELECT * FROM shoelace_candelete
WHERE sl_name = shoelace.sl_name);
+ERROR: could not plan this distributed delete
+DETAIL: correlated or complex DELETE is currently not supported in Postgres-XL.
SELECT * FROM shoelace ORDER BY sl_name;
sl_name | sl_avail | sl_color | sl_len | sl_unit | sl_len_cm
------------+----------+------------+--------+----------+-----------
sl1 | 5 | black | 80 | cm | 80
sl10 | 1000 | magenta | 40 | inch | 101.6
sl2 | 6 | black | 100 | cm | 100
- sl3 | 10 | black | 35 | inch | 88.9
+ sl3 | 0 | black | 35 | inch | 88.9
sl4 | 8 | black | 40 | inch | 101.6
sl5 | 4 | brown | 1 | m | 100
- sl6 | 20 | brown | 0.9 | m | 90
+ sl6 | 0 | brown | 0.9 | m | 90
sl7 | 6 | brown | 60 | cm | 60
- sl8 | 21 | brown | 40 | inch | 101.6
-(9 rows)
+ sl8 | 1 | brown | 40 | inch | 101.6
+ sl9 | 0 | pink | 35 | inch | 88.9
+(10 rows)
SELECT * FROM shoe ORDER BY shoename;
shoename | sh_avail | slcolor | slminlen | slminlen_cm | slmaxlen | slmaxlen_cm | slunit
(2 rows)
update vview set descrip='test1' where pid=1;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select * from vview order by pid;
- pid | txt | descrip
------+---------+---------
- 1 | parent1 | test1
+ pid | txt | descrip
+-----+---------+----------
+ 1 | parent1 | descrip1
2 | parent2 |
(2 rows)
update vview set descrip='test2' where pid=2;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select * from vview order by pid;
- pid | txt | descrip
------+---------+---------
- 1 | parent1 | test1
- 2 | parent2 | test2
+ pid | txt | descrip
+-----+---------+----------
+ 1 | parent1 | descrip1
+ 2 | parent2 |
(2 rows)
update vview set descrip='test3' where pid=3;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select * from vview order by pid;
- pid | txt | descrip
------+---------+---------
- 1 | parent1 | test1
- 2 | parent2 | test2
+ pid | txt | descrip
+-----+---------+----------
+ 1 | parent1 | descrip1
+ 2 | parent2 |
(2 rows)
select * from cchild order by pid;
- pid | descrip
------+---------
- 1 | test1
- 2 | test2
-(2 rows)
+ pid | descrip
+-----+----------
+ 1 | descrip1
+(1 row)
drop rule rrule on vview;
drop view vview;
--
-- Check that ruleutils are working
--
+SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schema' AND schemaname <> 'storm_catalog' ORDER BY viewname;
+ viewname | definition
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ iexit | SELECT ih.name, +
+ | ih.thepath, +
+ | interpt_pp(ih.thepath, r.thepath) AS exit +
+ | FROM ihighway ih, +
+ | ramp r +
+ | WHERE (ih.thepath ## r.thepath);
+ pg_available_extension_versions | SELECT e.name, +
+ | e.version, +
+ | (x.extname IS NOT NULL) AS installed, +
+ | e.superuser, +
+ | e.relocatable, +
+ | e.schema, +
+ | e.requires, +
+ | e.comment +
+ | FROM (pg_available_extension_versions() e(name, version, superuser, relocatable, schema, requires, comment) +
+ | LEFT JOIN pg_extension x ON (((e.name = x.extname) AND (e.version = x.extversion))));
+ pg_available_extensions | SELECT e.name, +
+ | e.default_version, +
+ | x.extversion AS installed_version, +
+ | e.comment +
+ | FROM (pg_available_extensions() e(name, default_version, comment) +
+ | LEFT JOIN pg_extension x ON ((e.name = x.extname)));
+ pg_cursors | SELECT c.name, +
+ | c.statement, +
+ | c.is_holdable, +
+ | c.is_binary, +
+ | c.is_scrollable, +
+ | c.creation_time +
+ | FROM pg_cursor() c(name, statement, is_holdable, is_binary, is_scrollable, creation_time);
+ pg_file_settings | SELECT a.sourcefile, +
+ | a.sourceline, +
+ | a.seqno, +
+ | a.name, +
+ | a.setting, +
+ | a.applied, +
+ | a.error +
+ | FROM pg_show_all_file_settings() a(sourcefile, sourceline, seqno, name, setting, applied, error);
+ pg_group | SELECT pg_authid.rolname AS groname, +
+ | pg_authid.oid AS grosysid, +
+ | ARRAY( SELECT pg_auth_members.member +
+ | FROM pg_auth_members +
+ | WHERE (pg_auth_members.roleid = pg_authid.oid)) AS grolist +
+ | FROM pg_authid +
+ | WHERE (NOT pg_authid.rolcanlogin);
+ pg_indexes | SELECT n.nspname AS schemaname, +
+ | c.relname AS tablename, +
+ | i.relname AS indexname, +
+ | t.spcname AS tablespace, +
+ | pg_get_indexdef(i.oid) AS indexdef +
+ | FROM ((((pg_index x +
+ | JOIN pg_class c ON ((c.oid = x.indrelid))) +
+ | JOIN pg_class i ON ((i.oid = x.indexrelid))) +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | LEFT JOIN pg_tablespace t ON ((t.oid = i.reltablespace))) +
+ | WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'm'::"char"])) AND (i.relkind = 'i'::"char"));
+ pg_locks | SELECT l.locktype, +
+ | l.database, +
+ | l.relation, +
+ | l.page, +
+ | l.tuple, +
+ | l.virtualxid, +
+ | l.transactionid, +
+ | l.classid, +
+ | l.objid, +
+ | l.objsubid, +
+ | l.virtualtransaction, +
+ | l.pid, +
+ | l.mode, +
+ | l.granted, +
+ | l.fastpath +
+ | FROM pg_lock_status() l(locktype, database, relation, page, tuple, virtualxid, transactionid, classid, objid, objsubid, virtualtransaction, pid, mode, granted, fastpath);
+ pg_matviews | SELECT n.nspname AS schemaname, +
+ | c.relname AS matviewname, +
+ | pg_get_userbyid(c.relowner) AS matviewowner, +
+ | t.spcname AS tablespace, +
+ | c.relhasindex AS hasindexes, +
+ | c.relispopulated AS ispopulated, +
+ | pg_get_viewdef(c.oid) AS definition +
+ | FROM ((pg_class c +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | LEFT JOIN pg_tablespace t ON ((t.oid = c.reltablespace))) +
+ | WHERE (c.relkind = 'm'::"char");
+ pg_policies | SELECT n.nspname AS schemaname, +
+ | c.relname AS tablename, +
+ | pol.polname AS policyname, +
+ | CASE +
+ | WHEN (pol.polroles = '{0}'::oid[]) THEN (string_to_array('public'::text, ''::text))::name[] +
+ | ELSE ARRAY( SELECT pg_authid.rolname +
+ | FROM pg_authid +
+ | WHERE (pg_authid.oid = ANY (pol.polroles)) +
+ | ORDER BY pg_authid.rolname) +
+ | END AS roles, +
+ | CASE pol.polcmd +
+ | WHEN 'r'::"char" THEN 'SELECT'::text +
+ | WHEN 'a'::"char" THEN 'INSERT'::text +
+ | WHEN 'w'::"char" THEN 'UPDATE'::text +
+ | WHEN 'd'::"char" THEN 'DELETE'::text +
+ | WHEN '*'::"char" THEN 'ALL'::text +
+ | ELSE NULL::text +
+ | END AS cmd, +
+ | pg_get_expr(pol.polqual, pol.polrelid) AS qual, +
+ | pg_get_expr(pol.polwithcheck, pol.polrelid) AS with_check +
+ | FROM ((pg_policy pol +
+ | JOIN pg_class c ON ((c.oid = pol.polrelid))) +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)));
+ pg_prepared_statements | SELECT p.name, +
+ | p.statement, +
+ | p.prepare_time, +
+ | p.parameter_types, +
+ | p.from_sql +
+ | FROM pg_prepared_statement() p(name, statement, prepare_time, parameter_types, from_sql);
+ pg_prepared_xacts | SELECT p.transaction, +
+ | p.gid, +
+ | p.prepared, +
+ | u.rolname AS owner, +
+ | d.datname AS database +
+ | FROM ((pg_prepared_xact() p(transaction, gid, prepared, ownerid, dbid) +
+ | LEFT JOIN pg_authid u ON ((p.ownerid = u.oid))) +
+ | LEFT JOIN pg_database d ON ((p.dbid = d.oid)));
+ pg_replication_origin_status | SELECT pg_show_replication_origin_status.local_id, +
+ | pg_show_replication_origin_status.external_id, +
+ | pg_show_replication_origin_status.remote_lsn, +
+ | pg_show_replication_origin_status.local_lsn +
+ | FROM pg_show_replication_origin_status() pg_show_replication_origin_status(local_id, external_id, remote_lsn, local_lsn);
+ pg_replication_slots | SELECT l.slot_name, +
+ | l.plugin, +
+ | l.slot_type, +
+ | l.datoid, +
+ | d.datname AS database, +
+ | l.active, +
+ | l.active_pid, +
+ | l.xmin, +
+ | l.catalog_xmin, +
+ | l.restart_lsn +
+ | FROM (pg_get_replication_slots() l(slot_name, plugin, slot_type, datoid, active, active_pid, xmin, catalog_xmin, restart_lsn) +
+ | LEFT JOIN pg_database d ON ((l.datoid = d.oid)));
+ pg_roles | SELECT pg_authid.rolname, +
+ | pg_authid.rolsuper, +
+ | pg_authid.rolinherit, +
+ | pg_authid.rolcreaterole, +
+ | pg_authid.rolcreatedb, +
+ | pg_authid.rolcanlogin, +
+ | pg_authid.rolreplication, +
+ | pg_authid.rolconnlimit, +
+ | '********'::text AS rolpassword, +
+ | pg_authid.rolvaliduntil, +
+ | pg_authid.rolbypassrls, +
+ | s.setconfig AS rolconfig, +
+ | pg_authid.oid +
+ | FROM (pg_authid +
+ | LEFT JOIN pg_db_role_setting s ON (((pg_authid.oid = s.setrole) AND (s.setdatabase = (0)::oid))));
+ pg_rules | SELECT n.nspname AS schemaname, +
+ | c.relname AS tablename, +
+ | r.rulename, +
+ | pg_get_ruledef(r.oid) AS definition +
+ | FROM ((pg_rewrite r +
+ | JOIN pg_class c ON ((c.oid = r.ev_class))) +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | WHERE (r.rulename <> '_RETURN'::name);
+ pg_seclabels | SELECT l.objoid, +
+ | l.classoid, +
+ | l.objsubid, +
+ | CASE +
+ | WHEN (rel.relkind = 'r'::"char") THEN 'table'::text +
+ | WHEN (rel.relkind = 'v'::"char") THEN 'view'::text +
+ | WHEN (rel.relkind = 'm'::"char") THEN 'materialized view'::text +
+ | WHEN (rel.relkind = 'S'::"char") THEN 'sequence'::text +
+ | WHEN (rel.relkind = 'f'::"char") THEN 'foreign table'::text +
+ | ELSE NULL::text +
+ | END AS objtype, +
+ | rel.relnamespace AS objnamespace, +
+ | CASE +
+ | WHEN pg_table_is_visible(rel.oid) THEN quote_ident((rel.relname)::text) +
+ | ELSE ((quote_ident((nsp.nspname)::text) || '.'::text) || quote_ident((rel.relname)::text)) +
+ | END AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM ((pg_seclabel l +
+ | JOIN pg_class rel ON (((l.classoid = rel.tableoid) AND (l.objoid = rel.oid)))) +
+ | JOIN pg_namespace nsp ON ((rel.relnamespace = nsp.oid))) +
+ | WHERE (l.objsubid = 0) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | l.objsubid, +
+ | 'column'::text AS objtype, +
+ | rel.relnamespace AS objnamespace, +
+ | (( +
+ | CASE +
+ | WHEN pg_table_is_visible(rel.oid) THEN quote_ident((rel.relname)::text) +
+ | ELSE ((quote_ident((nsp.nspname)::text) || '.'::text) || quote_ident((rel.relname)::text)) +
+ | END || '.'::text) || (att.attname)::text) AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM (((pg_seclabel l +
+ | JOIN pg_class rel ON (((l.classoid = rel.tableoid) AND (l.objoid = rel.oid)))) +
+ | JOIN pg_attribute att ON (((rel.oid = att.attrelid) AND (l.objsubid = att.attnum)))) +
+ | JOIN pg_namespace nsp ON ((rel.relnamespace = nsp.oid))) +
+ | WHERE (l.objsubid <> 0) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | l.objsubid, +
+ | CASE +
+ | WHEN (pro.proisagg = true) THEN 'aggregate'::text +
+ | WHEN (pro.proisagg = false) THEN 'function'::text +
+ | ELSE NULL::text +
+ | END AS objtype, +
+ | pro.pronamespace AS objnamespace, +
+ | ((( +
+ | CASE +
+ | WHEN pg_function_is_visible(pro.oid) THEN quote_ident((pro.proname)::text) +
+ | ELSE ((quote_ident((nsp.nspname)::text) || '.'::text) || quote_ident((pro.proname)::text)) +
+ | END || '('::text) || pg_get_function_arguments(pro.oid)) || ')'::text) AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM ((pg_seclabel l +
+ | JOIN pg_proc pro ON (((l.classoid = pro.tableoid) AND (l.objoid = pro.oid)))) +
+ | JOIN pg_namespace nsp ON ((pro.pronamespace = nsp.oid))) +
+ | WHERE (l.objsubid = 0) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | l.objsubid, +
+ | CASE +
+ | WHEN (typ.typtype = 'd'::"char") THEN 'domain'::text +
+ | ELSE 'type'::text +
+ | END AS objtype, +
+ | typ.typnamespace AS objnamespace, +
+ | CASE +
+ | WHEN pg_type_is_visible(typ.oid) THEN quote_ident((typ.typname)::text) +
+ | ELSE ((quote_ident((nsp.nspname)::text) || '.'::text) || quote_ident((typ.typname)::text)) +
+ | END AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM ((pg_seclabel l +
+ | JOIN pg_type typ ON (((l.classoid = typ.tableoid) AND (l.objoid = typ.oid)))) +
+ | JOIN pg_namespace nsp ON ((typ.typnamespace = nsp.oid))) +
+ | WHERE (l.objsubid = 0) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | l.objsubid, +
+ | 'large object'::text AS objtype, +
+ | NULL::oid AS objnamespace, +
+ | (l.objoid)::text AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM (pg_seclabel l +
+ | JOIN pg_largeobject_metadata lom ON ((l.objoid = lom.oid))) +
+ | WHERE ((l.classoid = ('pg_largeobject'::regclass)::oid) AND (l.objsubid = 0)) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | l.objsubid, +
+ | 'language'::text AS objtype, +
+ | NULL::oid AS objnamespace, +
+ | quote_ident((lan.lanname)::text) AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM (pg_seclabel l +
+ | JOIN pg_language lan ON (((l.classoid = lan.tableoid) AND (l.objoid = lan.oid)))) +
+ | WHERE (l.objsubid = 0) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | l.objsubid, +
+ | 'schema'::text AS objtype, +
+ | nsp.oid AS objnamespace, +
+ | quote_ident((nsp.nspname)::text) AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM (pg_seclabel l +
+ | JOIN pg_namespace nsp ON (((l.classoid = nsp.tableoid) AND (l.objoid = nsp.oid)))) +
+ | WHERE (l.objsubid = 0) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | l.objsubid, +
+ | 'event trigger'::text AS objtype, +
+ | NULL::oid AS objnamespace, +
+ | quote_ident((evt.evtname)::text) AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM (pg_seclabel l +
+ | JOIN pg_event_trigger evt ON (((l.classoid = evt.tableoid) AND (l.objoid = evt.oid)))) +
+ | WHERE (l.objsubid = 0) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | 0 AS objsubid, +
+ | 'database'::text AS objtype, +
+ | NULL::oid AS objnamespace, +
+ | quote_ident((dat.datname)::text) AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM (pg_shseclabel l +
+ | JOIN pg_database dat ON (((l.classoid = dat.tableoid) AND (l.objoid = dat.oid)))) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | 0 AS objsubid, +
+ | 'tablespace'::text AS objtype, +
+ | NULL::oid AS objnamespace, +
+ | quote_ident((spc.spcname)::text) AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM (pg_shseclabel l +
+ | JOIN pg_tablespace spc ON (((l.classoid = spc.tableoid) AND (l.objoid = spc.oid)))) +
+ | UNION ALL +
+ | SELECT l.objoid, +
+ | l.classoid, +
+ | 0 AS objsubid, +
+ | 'role'::text AS objtype, +
+ | NULL::oid AS objnamespace, +
+ | quote_ident((rol.rolname)::text) AS objname, +
+ | l.provider, +
+ | l.label +
+ | FROM (pg_shseclabel l +
+ | JOIN pg_authid rol ON (((l.classoid = rol.tableoid) AND (l.objoid = rol.oid))));
+ pg_settings | SELECT a.name, +
+ | a.setting, +
+ | a.unit, +
+ | a.category, +
+ | a.short_desc, +
+ | a.extra_desc, +
+ | a.context, +
+ | a.vartype, +
+ | a.source, +
+ | a.min_val, +
+ | a.max_val, +
+ | a.enumvals, +
+ | a.boot_val, +
+ | a.reset_val, +
+ | a.sourcefile, +
+ | a.sourceline, +
+ | a.pending_restart +
+ | FROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, sourcefile, sourceline, pending_restart);
+ pg_shadow | SELECT pg_authid.rolname AS usename, +
+ | pg_authid.oid AS usesysid, +
+ | pg_authid.rolcreatedb AS usecreatedb, +
+ | pg_authid.rolsuper AS usesuper, +
+ | pg_authid.rolreplication AS userepl, +
+ | pg_authid.rolbypassrls AS usebypassrls, +
+ | pg_authid.rolpassword AS passwd, +
+ | (pg_authid.rolvaliduntil)::abstime AS valuntil, +
+ | s.setconfig AS useconfig +
+ | FROM (pg_authid +
+ | LEFT JOIN pg_db_role_setting s ON (((pg_authid.oid = s.setrole) AND (s.setdatabase = (0)::oid)))) +
+ | WHERE pg_authid.rolcanlogin;
+ pg_stat_activity | SELECT s.datid, +
+ | d.datname, +
+ | s.pid, +
+ | s.usesysid, +
+ | u.rolname AS usename, +
+ | s.application_name, +
+ | s.client_addr, +
+ | s.client_hostname, +
+ | s.client_port, +
+ | s.backend_start, +
+ | s.xact_start, +
+ | s.query_start, +
+ | s.state_change, +
+ | s.waiting, +
+ | s.state, +
+ | s.backend_xid, +
+ | s.backend_xmin, +
+ | s.query +
+ | FROM pg_database d, +
+ | pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, waiting, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, ssl, sslversion, sslcipher, sslbits, sslcompression, sslclientdn), +
+ | pg_authid u +
+ | WHERE ((s.datid = d.oid) AND (s.usesysid = u.oid));
+ pg_stat_all_indexes | SELECT c.oid AS relid, +
+ | i.oid AS indexrelid, +
+ | n.nspname AS schemaname, +
+ | c.relname, +
+ | i.relname AS indexrelname, +
+ | pg_stat_get_numscans(i.oid) AS idx_scan, +
+ | pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, +
+ | pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch +
+ | FROM (((pg_class c +
+ | JOIN pg_index x ON ((c.oid = x.indrelid))) +
+ | JOIN pg_class i ON ((i.oid = x.indexrelid))) +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"]));
+ pg_stat_all_tables | SELECT c.oid AS relid, +
+ | n.nspname AS schemaname, +
+ | c.relname, +
+ | pg_stat_get_numscans(c.oid) AS seq_scan, +
+ | pg_stat_get_tuples_returned(c.oid) AS seq_tup_read, +
+ | (sum(pg_stat_get_numscans(i.indexrelid)))::bigint AS idx_scan, +
+ | ((sum(pg_stat_get_tuples_fetched(i.indexrelid)))::bigint + pg_stat_get_tuples_fetched(c.oid)) AS idx_tup_fetch, +
+ | pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, +
+ | pg_stat_get_tuples_updated(c.oid) AS n_tup_upd, +
+ | pg_stat_get_tuples_deleted(c.oid) AS n_tup_del, +
+ | pg_stat_get_tuples_hot_updated(c.oid) AS n_tup_hot_upd, +
+ | pg_stat_get_live_tuples(c.oid) AS n_live_tup, +
+ | pg_stat_get_dead_tuples(c.oid) AS n_dead_tup, +
+ | pg_stat_get_mod_since_analyze(c.oid) AS n_mod_since_analyze, +
+ | pg_stat_get_last_vacuum_time(c.oid) AS last_vacuum, +
+ | pg_stat_get_last_autovacuum_time(c.oid) AS last_autovacuum, +
+ | pg_stat_get_last_analyze_time(c.oid) AS last_analyze, +
+ | pg_stat_get_last_autoanalyze_time(c.oid) AS last_autoanalyze, +
+ | pg_stat_get_vacuum_count(c.oid) AS vacuum_count, +
+ | pg_stat_get_autovacuum_count(c.oid) AS autovacuum_count, +
+ | pg_stat_get_analyze_count(c.oid) AS analyze_count, +
+ | pg_stat_get_autoanalyze_count(c.oid) AS autoanalyze_count +
+ | FROM ((pg_class c +
+ | LEFT JOIN pg_index i ON ((c.oid = i.indrelid))) +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"])) +
+ | GROUP BY c.oid, n.nspname, c.relname;
+ pg_stat_archiver | SELECT s.archived_count, +
+ | s.last_archived_wal, +
+ | s.last_archived_time, +
+ | s.failed_count, +
+ | s.last_failed_wal, +
+ | s.last_failed_time, +
+ | s.stats_reset +
+ | FROM pg_stat_get_archiver() s(archived_count, last_archived_wal, last_archived_time, failed_count, last_failed_wal, last_failed_time, stats_reset);
+ pg_stat_bgwriter | SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints_timed, +
+ | pg_stat_get_bgwriter_requested_checkpoints() AS checkpoints_req, +
+ | pg_stat_get_checkpoint_write_time() AS checkpoint_write_time, +
+ | pg_stat_get_checkpoint_sync_time() AS checkpoint_sync_time, +
+ | pg_stat_get_bgwriter_buf_written_checkpoints() AS buffers_checkpoint, +
+ | pg_stat_get_bgwriter_buf_written_clean() AS buffers_clean, +
+ | pg_stat_get_bgwriter_maxwritten_clean() AS maxwritten_clean, +
+ | pg_stat_get_buf_written_backend() AS buffers_backend, +
+ | pg_stat_get_buf_fsync_backend() AS buffers_backend_fsync, +
+ | pg_stat_get_buf_alloc() AS buffers_alloc, +
+ | pg_stat_get_bgwriter_stat_reset_time() AS stats_reset;
+ pg_stat_database | SELECT d.oid AS datid, +
+ | d.datname, +
+ | pg_stat_get_db_numbackends(d.oid) AS numbackends, +
+ | pg_stat_get_db_xact_commit(d.oid) AS xact_commit, +
+ | pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback, +
+ | (pg_stat_get_db_blocks_fetched(d.oid) - pg_stat_get_db_blocks_hit(d.oid)) AS blks_read, +
+ | pg_stat_get_db_blocks_hit(d.oid) AS blks_hit, +
+ | pg_stat_get_db_tuples_returned(d.oid) AS tup_returned, +
+ | pg_stat_get_db_tuples_fetched(d.oid) AS tup_fetched, +
+ | pg_stat_get_db_tuples_inserted(d.oid) AS tup_inserted, +
+ | pg_stat_get_db_tuples_updated(d.oid) AS tup_updated, +
+ | pg_stat_get_db_tuples_deleted(d.oid) AS tup_deleted, +
+ | pg_stat_get_db_conflict_all(d.oid) AS conflicts, +
+ | pg_stat_get_db_temp_files(d.oid) AS temp_files, +
+ | pg_stat_get_db_temp_bytes(d.oid) AS temp_bytes, +
+ | pg_stat_get_db_deadlocks(d.oid) AS deadlocks, +
+ | pg_stat_get_db_blk_read_time(d.oid) AS blk_read_time, +
+ | pg_stat_get_db_blk_write_time(d.oid) AS blk_write_time, +
+ | pg_stat_get_db_stat_reset_time(d.oid) AS stats_reset +
+ | FROM pg_database d;
+ pg_stat_database_conflicts | SELECT d.oid AS datid, +
+ | d.datname, +
+ | pg_stat_get_db_conflict_tablespace(d.oid) AS confl_tablespace, +
+ | pg_stat_get_db_conflict_lock(d.oid) AS confl_lock, +
+ | pg_stat_get_db_conflict_snapshot(d.oid) AS confl_snapshot, +
+ | pg_stat_get_db_conflict_bufferpin(d.oid) AS confl_bufferpin, +
+ | pg_stat_get_db_conflict_startup_deadlock(d.oid) AS confl_deadlock +
+ | FROM pg_database d;
+ pg_stat_replication | SELECT s.pid, +
+ | s.usesysid, +
+ | u.rolname AS usename, +
+ | s.application_name, +
+ | s.client_addr, +
+ | s.client_hostname, +
+ | s.client_port, +
+ | s.backend_start, +
+ | s.backend_xmin, +
+ | w.state, +
+ | w.sent_location, +
+ | w.write_location, +
+ | w.flush_location, +
+ | w.replay_location, +
+ | w.sync_priority, +
+ | w.sync_state +
+ | FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, waiting, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, ssl, sslversion, sslcipher, sslbits, sslcompression, sslclientdn),+
+ | pg_authid u, +
+ | pg_stat_get_wal_senders() w(pid, state, sent_location, write_location, flush_location, replay_location, sync_priority, sync_state) +
+ | WHERE ((s.usesysid = u.oid) AND (s.pid = w.pid));
+ pg_stat_ssl | SELECT s.pid, +
+ | s.ssl, +
+ | s.sslversion AS version, +
+ | s.sslcipher AS cipher, +
+ | s.sslbits AS bits, +
+ | s.sslcompression AS compression, +
+ | s.sslclientdn AS clientdn +
+ | FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, waiting, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, ssl, sslversion, sslcipher, sslbits, sslcompression, sslclientdn);
+ pg_stat_sys_indexes | SELECT pg_stat_all_indexes.relid, +
+ | pg_stat_all_indexes.indexrelid, +
+ | pg_stat_all_indexes.schemaname, +
+ | pg_stat_all_indexes.relname, +
+ | pg_stat_all_indexes.indexrelname, +
+ | pg_stat_all_indexes.idx_scan, +
+ | pg_stat_all_indexes.idx_tup_read, +
+ | pg_stat_all_indexes.idx_tup_fetch +
+ | FROM pg_stat_all_indexes +
+ | WHERE ((pg_stat_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_indexes.schemaname ~ '^pg_toast'::text));
+ pg_stat_sys_tables | SELECT pg_stat_all_tables.relid, +
+ | pg_stat_all_tables.schemaname, +
+ | pg_stat_all_tables.relname, +
+ | pg_stat_all_tables.seq_scan, +
+ | pg_stat_all_tables.seq_tup_read, +
+ | pg_stat_all_tables.idx_scan, +
+ | pg_stat_all_tables.idx_tup_fetch, +
+ | pg_stat_all_tables.n_tup_ins, +
+ | pg_stat_all_tables.n_tup_upd, +
+ | pg_stat_all_tables.n_tup_del, +
+ | pg_stat_all_tables.n_tup_hot_upd, +
+ | pg_stat_all_tables.n_live_tup, +
+ | pg_stat_all_tables.n_dead_tup, +
+ | pg_stat_all_tables.n_mod_since_analyze, +
+ | pg_stat_all_tables.last_vacuum, +
+ | pg_stat_all_tables.last_autovacuum, +
+ | pg_stat_all_tables.last_analyze, +
+ | pg_stat_all_tables.last_autoanalyze, +
+ | pg_stat_all_tables.vacuum_count, +
+ | pg_stat_all_tables.autovacuum_count, +
+ | pg_stat_all_tables.analyze_count, +
+ | pg_stat_all_tables.autoanalyze_count +
+ | FROM pg_stat_all_tables +
+ | WHERE ((pg_stat_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_tables.schemaname ~ '^pg_toast'::text));
+ pg_stat_user_functions | SELECT p.oid AS funcid, +
+ | n.nspname AS schemaname, +
+ | p.proname AS funcname, +
+ | pg_stat_get_function_calls(p.oid) AS calls, +
+ | pg_stat_get_function_total_time(p.oid) AS total_time, +
+ | pg_stat_get_function_self_time(p.oid) AS self_time +
+ | FROM (pg_proc p +
+ | LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace))) +
+ | WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_function_calls(p.oid) IS NOT NULL));
+ pg_stat_user_indexes | SELECT pg_stat_all_indexes.relid, +
+ | pg_stat_all_indexes.indexrelid, +
+ | pg_stat_all_indexes.schemaname, +
+ | pg_stat_all_indexes.relname, +
+ | pg_stat_all_indexes.indexrelname, +
+ | pg_stat_all_indexes.idx_scan, +
+ | pg_stat_all_indexes.idx_tup_read, +
+ | pg_stat_all_indexes.idx_tup_fetch +
+ | FROM pg_stat_all_indexes +
+ | WHERE ((pg_stat_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_indexes.schemaname !~ '^pg_toast'::text));
+ pg_stat_user_tables | SELECT pg_stat_all_tables.relid, +
+ | pg_stat_all_tables.schemaname, +
+ | pg_stat_all_tables.relname, +
+ | pg_stat_all_tables.seq_scan, +
+ | pg_stat_all_tables.seq_tup_read, +
+ | pg_stat_all_tables.idx_scan, +
+ | pg_stat_all_tables.idx_tup_fetch, +
+ | pg_stat_all_tables.n_tup_ins, +
+ | pg_stat_all_tables.n_tup_upd, +
+ | pg_stat_all_tables.n_tup_del, +
+ | pg_stat_all_tables.n_tup_hot_upd, +
+ | pg_stat_all_tables.n_live_tup, +
+ | pg_stat_all_tables.n_dead_tup, +
+ | pg_stat_all_tables.n_mod_since_analyze, +
+ | pg_stat_all_tables.last_vacuum, +
+ | pg_stat_all_tables.last_autovacuum, +
+ | pg_stat_all_tables.last_analyze, +
+ | pg_stat_all_tables.last_autoanalyze, +
+ | pg_stat_all_tables.vacuum_count, +
+ | pg_stat_all_tables.autovacuum_count, +
+ | pg_stat_all_tables.analyze_count, +
+ | pg_stat_all_tables.autoanalyze_count +
+ | FROM pg_stat_all_tables +
+ | WHERE ((pg_stat_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_tables.schemaname !~ '^pg_toast'::text));
+ pg_stat_xact_all_tables | SELECT c.oid AS relid, +
+ | n.nspname AS schemaname, +
+ | c.relname, +
+ | pg_stat_get_xact_numscans(c.oid) AS seq_scan, +
+ | pg_stat_get_xact_tuples_returned(c.oid) AS seq_tup_read, +
+ | (sum(pg_stat_get_xact_numscans(i.indexrelid)))::bigint AS idx_scan, +
+ | ((sum(pg_stat_get_xact_tuples_fetched(i.indexrelid)))::bigint + pg_stat_get_xact_tuples_fetched(c.oid)) AS idx_tup_fetch, +
+ | pg_stat_get_xact_tuples_inserted(c.oid) AS n_tup_ins, +
+ | pg_stat_get_xact_tuples_updated(c.oid) AS n_tup_upd, +
+ | pg_stat_get_xact_tuples_deleted(c.oid) AS n_tup_del, +
+ | pg_stat_get_xact_tuples_hot_updated(c.oid) AS n_tup_hot_upd +
+ | FROM ((pg_class c +
+ | LEFT JOIN pg_index i ON ((c.oid = i.indrelid))) +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"])) +
+ | GROUP BY c.oid, n.nspname, c.relname;
+ pg_stat_xact_sys_tables | SELECT pg_stat_xact_all_tables.relid, +
+ | pg_stat_xact_all_tables.schemaname, +
+ | pg_stat_xact_all_tables.relname, +
+ | pg_stat_xact_all_tables.seq_scan, +
+ | pg_stat_xact_all_tables.seq_tup_read, +
+ | pg_stat_xact_all_tables.idx_scan, +
+ | pg_stat_xact_all_tables.idx_tup_fetch, +
+ | pg_stat_xact_all_tables.n_tup_ins, +
+ | pg_stat_xact_all_tables.n_tup_upd, +
+ | pg_stat_xact_all_tables.n_tup_del, +
+ | pg_stat_xact_all_tables.n_tup_hot_upd +
+ | FROM pg_stat_xact_all_tables +
+ | WHERE ((pg_stat_xact_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_xact_all_tables.schemaname ~ '^pg_toast'::text));
+ pg_stat_xact_user_functions | SELECT p.oid AS funcid, +
+ | n.nspname AS schemaname, +
+ | p.proname AS funcname, +
+ | pg_stat_get_xact_function_calls(p.oid) AS calls, +
+ | pg_stat_get_xact_function_total_time(p.oid) AS total_time, +
+ | pg_stat_get_xact_function_self_time(p.oid) AS self_time +
+ | FROM (pg_proc p +
+ | LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace))) +
+ | WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_xact_function_calls(p.oid) IS NOT NULL));
+ pg_stat_xact_user_tables | SELECT pg_stat_xact_all_tables.relid, +
+ | pg_stat_xact_all_tables.schemaname, +
+ | pg_stat_xact_all_tables.relname, +
+ | pg_stat_xact_all_tables.seq_scan, +
+ | pg_stat_xact_all_tables.seq_tup_read, +
+ | pg_stat_xact_all_tables.idx_scan, +
+ | pg_stat_xact_all_tables.idx_tup_fetch, +
+ | pg_stat_xact_all_tables.n_tup_ins, +
+ | pg_stat_xact_all_tables.n_tup_upd, +
+ | pg_stat_xact_all_tables.n_tup_del, +
+ | pg_stat_xact_all_tables.n_tup_hot_upd +
+ | FROM pg_stat_xact_all_tables +
+ | WHERE ((pg_stat_xact_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_xact_all_tables.schemaname !~ '^pg_toast'::text));
+ pg_statio_all_indexes | SELECT c.oid AS relid, +
+ | i.oid AS indexrelid, +
+ | n.nspname AS schemaname, +
+ | c.relname, +
+ | i.relname AS indexrelname, +
+ | (pg_stat_get_blocks_fetched(i.oid) - pg_stat_get_blocks_hit(i.oid)) AS idx_blks_read, +
+ | pg_stat_get_blocks_hit(i.oid) AS idx_blks_hit +
+ | FROM (((pg_class c +
+ | JOIN pg_index x ON ((c.oid = x.indrelid))) +
+ | JOIN pg_class i ON ((i.oid = x.indexrelid))) +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"]));
+ pg_statio_all_sequences | SELECT c.oid AS relid, +
+ | n.nspname AS schemaname, +
+ | c.relname, +
+ | (pg_stat_get_blocks_fetched(c.oid) - pg_stat_get_blocks_hit(c.oid)) AS blks_read, +
+ | pg_stat_get_blocks_hit(c.oid) AS blks_hit +
+ | FROM (pg_class c +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | WHERE (c.relkind = 'S'::"char");
+ pg_statio_all_tables | SELECT c.oid AS relid, +
+ | n.nspname AS schemaname, +
+ | c.relname, +
+ | (pg_stat_get_blocks_fetched(c.oid) - pg_stat_get_blocks_hit(c.oid)) AS heap_blks_read, +
+ | pg_stat_get_blocks_hit(c.oid) AS heap_blks_hit, +
+ | (sum((pg_stat_get_blocks_fetched(i.indexrelid) - pg_stat_get_blocks_hit(i.indexrelid))))::bigint AS idx_blks_read, +
+ | (sum(pg_stat_get_blocks_hit(i.indexrelid)))::bigint AS idx_blks_hit, +
+ | (pg_stat_get_blocks_fetched(t.oid) - pg_stat_get_blocks_hit(t.oid)) AS toast_blks_read, +
+ | pg_stat_get_blocks_hit(t.oid) AS toast_blks_hit, +
+ | (sum((pg_stat_get_blocks_fetched(x.indexrelid) - pg_stat_get_blocks_hit(x.indexrelid))))::bigint AS tidx_blks_read, +
+ | (sum(pg_stat_get_blocks_hit(x.indexrelid)))::bigint AS tidx_blks_hit +
+ | FROM ((((pg_class c +
+ | LEFT JOIN pg_index i ON ((c.oid = i.indrelid))) +
+ | LEFT JOIN pg_class t ON ((c.reltoastrelid = t.oid))) +
+ | LEFT JOIN pg_index x ON ((t.oid = x.indrelid))) +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"])) +
+ | GROUP BY c.oid, n.nspname, c.relname, t.oid, x.indrelid;
+ pg_statio_sys_indexes | SELECT pg_statio_all_indexes.relid, +
+ | pg_statio_all_indexes.indexrelid, +
+ | pg_statio_all_indexes.schemaname, +
+ | pg_statio_all_indexes.relname, +
+ | pg_statio_all_indexes.indexrelname, +
+ | pg_statio_all_indexes.idx_blks_read, +
+ | pg_statio_all_indexes.idx_blks_hit +
+ | FROM pg_statio_all_indexes +
+ | WHERE ((pg_statio_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_indexes.schemaname ~ '^pg_toast'::text));
+ pg_statio_sys_sequences | SELECT pg_statio_all_sequences.relid, +
+ | pg_statio_all_sequences.schemaname, +
+ | pg_statio_all_sequences.relname, +
+ | pg_statio_all_sequences.blks_read, +
+ | pg_statio_all_sequences.blks_hit +
+ | FROM pg_statio_all_sequences +
+ | WHERE ((pg_statio_all_sequences.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_sequences.schemaname ~ '^pg_toast'::text));
+ pg_statio_sys_tables | SELECT pg_statio_all_tables.relid, +
+ | pg_statio_all_tables.schemaname, +
+ | pg_statio_all_tables.relname, +
+ | pg_statio_all_tables.heap_blks_read, +
+ | pg_statio_all_tables.heap_blks_hit, +
+ | pg_statio_all_tables.idx_blks_read, +
+ | pg_statio_all_tables.idx_blks_hit, +
+ | pg_statio_all_tables.toast_blks_read, +
+ | pg_statio_all_tables.toast_blks_hit, +
+ | pg_statio_all_tables.tidx_blks_read, +
+ | pg_statio_all_tables.tidx_blks_hit +
+ | FROM pg_statio_all_tables +
+ | WHERE ((pg_statio_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_tables.schemaname ~ '^pg_toast'::text));
+ pg_statio_user_indexes | SELECT pg_statio_all_indexes.relid, +
+ | pg_statio_all_indexes.indexrelid, +
+ | pg_statio_all_indexes.schemaname, +
+ | pg_statio_all_indexes.relname, +
+ | pg_statio_all_indexes.indexrelname, +
+ | pg_statio_all_indexes.idx_blks_read, +
+ | pg_statio_all_indexes.idx_blks_hit +
+ | FROM pg_statio_all_indexes +
+ | WHERE ((pg_statio_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_indexes.schemaname !~ '^pg_toast'::text));
+ pg_statio_user_sequences | SELECT pg_statio_all_sequences.relid, +
+ | pg_statio_all_sequences.schemaname, +
+ | pg_statio_all_sequences.relname, +
+ | pg_statio_all_sequences.blks_read, +
+ | pg_statio_all_sequences.blks_hit +
+ | FROM pg_statio_all_sequences +
+ | WHERE ((pg_statio_all_sequences.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_sequences.schemaname !~ '^pg_toast'::text));
+ pg_statio_user_tables | SELECT pg_statio_all_tables.relid, +
+ | pg_statio_all_tables.schemaname, +
+ | pg_statio_all_tables.relname, +
+ | pg_statio_all_tables.heap_blks_read, +
+ | pg_statio_all_tables.heap_blks_hit, +
+ | pg_statio_all_tables.idx_blks_read, +
+ | pg_statio_all_tables.idx_blks_hit, +
+ | pg_statio_all_tables.toast_blks_read, +
+ | pg_statio_all_tables.toast_blks_hit, +
+ | pg_statio_all_tables.tidx_blks_read, +
+ | pg_statio_all_tables.tidx_blks_hit +
+ | FROM pg_statio_all_tables +
+ | WHERE ((pg_statio_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_tables.schemaname !~ '^pg_toast'::text));
+ pg_stats | SELECT n.nspname AS schemaname, +
+ | c.relname AS tablename, +
+ | a.attname, +
+ | s.stainherit AS inherited, +
+ | s.stanullfrac AS null_frac, +
+ | s.stawidth AS avg_width, +
+ | s.stadistinct AS n_distinct, +
+ | CASE +
+ | WHEN (s.stakind1 = 1) THEN s.stavalues1 +
+ | WHEN (s.stakind2 = 1) THEN s.stavalues2 +
+ | WHEN (s.stakind3 = 1) THEN s.stavalues3 +
+ | WHEN (s.stakind4 = 1) THEN s.stavalues4 +
+ | WHEN (s.stakind5 = 1) THEN s.stavalues5 +
+ | ELSE NULL::anyarray +
+ | END AS most_common_vals, +
+ | CASE +
+ | WHEN (s.stakind1 = 1) THEN s.stanumbers1 +
+ | WHEN (s.stakind2 = 1) THEN s.stanumbers2 +
+ | WHEN (s.stakind3 = 1) THEN s.stanumbers3 +
+ | WHEN (s.stakind4 = 1) THEN s.stanumbers4 +
+ | WHEN (s.stakind5 = 1) THEN s.stanumbers5 +
+ | ELSE NULL::real[] +
+ | END AS most_common_freqs, +
+ | CASE +
+ | WHEN (s.stakind1 = 2) THEN s.stavalues1 +
+ | WHEN (s.stakind2 = 2) THEN s.stavalues2 +
+ | WHEN (s.stakind3 = 2) THEN s.stavalues3 +
+ | WHEN (s.stakind4 = 2) THEN s.stavalues4 +
+ | WHEN (s.stakind5 = 2) THEN s.stavalues5 +
+ | ELSE NULL::anyarray +
+ | END AS histogram_bounds, +
+ | CASE +
+ | WHEN (s.stakind1 = 3) THEN s.stanumbers1[1] +
+ | WHEN (s.stakind2 = 3) THEN s.stanumbers2[1] +
+ | WHEN (s.stakind3 = 3) THEN s.stanumbers3[1] +
+ | WHEN (s.stakind4 = 3) THEN s.stanumbers4[1] +
+ | WHEN (s.stakind5 = 3) THEN s.stanumbers5[1] +
+ | ELSE NULL::real +
+ | END AS correlation, +
+ | CASE +
+ | WHEN (s.stakind1 = 4) THEN s.stavalues1 +
+ | WHEN (s.stakind2 = 4) THEN s.stavalues2 +
+ | WHEN (s.stakind3 = 4) THEN s.stavalues3 +
+ | WHEN (s.stakind4 = 4) THEN s.stavalues4 +
+ | WHEN (s.stakind5 = 4) THEN s.stavalues5 +
+ | ELSE NULL::anyarray +
+ | END AS most_common_elems, +
+ | CASE +
+ | WHEN (s.stakind1 = 4) THEN s.stanumbers1 +
+ | WHEN (s.stakind2 = 4) THEN s.stanumbers2 +
+ | WHEN (s.stakind3 = 4) THEN s.stanumbers3 +
+ | WHEN (s.stakind4 = 4) THEN s.stanumbers4 +
+ | WHEN (s.stakind5 = 4) THEN s.stanumbers5 +
+ | ELSE NULL::real[] +
+ | END AS most_common_elem_freqs, +
+ | CASE +
+ | WHEN (s.stakind1 = 5) THEN s.stanumbers1 +
+ | WHEN (s.stakind2 = 5) THEN s.stanumbers2 +
+ | WHEN (s.stakind3 = 5) THEN s.stanumbers3 +
+ | WHEN (s.stakind4 = 5) THEN s.stanumbers4 +
+ | WHEN (s.stakind5 = 5) THEN s.stanumbers5 +
+ | ELSE NULL::real[] +
+ | END AS elem_count_histogram +
+ | FROM (((pg_statistic s +
+ | JOIN pg_class c ON ((c.oid = s.starelid))) +
+ | JOIN pg_attribute a ON (((c.oid = a.attrelid) AND (a.attnum = s.staattnum)))) +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | WHERE ((NOT a.attisdropped) AND has_column_privilege(c.oid, a.attnum, 'select'::text) AND ((c.relrowsecurity = false) OR (NOT row_security_active(c.oid))));
+ pg_tables | SELECT n.nspname AS schemaname, +
+ | c.relname AS tablename, +
+ | pg_get_userbyid(c.relowner) AS tableowner, +
+ | t.spcname AS tablespace, +
+ | c.relhasindex AS hasindexes, +
+ | c.relhasrules AS hasrules, +
+ | c.relhastriggers AS hastriggers, +
+ | c.relrowsecurity AS rowsecurity +
+ | FROM ((pg_class c +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | LEFT JOIN pg_tablespace t ON ((t.oid = c.reltablespace))) +
+ | WHERE (c.relkind = 'r'::"char");
+ pg_timezone_abbrevs | SELECT pg_timezone_abbrevs.abbrev, +
+ | pg_timezone_abbrevs.utc_offset, +
+ | pg_timezone_abbrevs.is_dst +
+ | FROM pg_timezone_abbrevs() pg_timezone_abbrevs(abbrev, utc_offset, is_dst);
+ pg_timezone_names | SELECT pg_timezone_names.name, +
+ | pg_timezone_names.abbrev, +
+ | pg_timezone_names.utc_offset, +
+ | pg_timezone_names.is_dst +
+ | FROM pg_timezone_names() pg_timezone_names(name, abbrev, utc_offset, is_dst);
+ pg_user | SELECT pg_shadow.usename, +
+ | pg_shadow.usesysid, +
+ | pg_shadow.usecreatedb, +
+ | pg_shadow.usesuper, +
+ | pg_shadow.userepl, +
+ | pg_shadow.usebypassrls, +
+ | '********'::text AS passwd, +
+ | pg_shadow.valuntil, +
+ | pg_shadow.useconfig +
+ | FROM pg_shadow;
+ pg_user_mappings | SELECT u.oid AS umid, +
+ | s.oid AS srvid, +
+ | s.srvname, +
+ | u.umuser, +
+ | CASE +
+ | WHEN (u.umuser = (0)::oid) THEN 'public'::name +
+ | ELSE a.rolname +
+ | END AS usename, +
+ | CASE +
+ | WHEN (pg_has_role(s.srvowner, 'USAGE'::text) OR has_server_privilege(s.oid, 'USAGE'::text)) THEN u.umoptions +
+ | ELSE NULL::text[] +
+ | END AS umoptions +
+ | FROM ((pg_user_mapping u +
+ | LEFT JOIN pg_authid a ON ((a.oid = u.umuser))) +
+ | JOIN pg_foreign_server s ON ((u.umserver = s.oid)));
+ pg_views | SELECT n.nspname AS schemaname, +
+ | c.relname AS viewname, +
+ | pg_get_userbyid(c.relowner) AS viewowner, +
+ | pg_get_viewdef(c.oid) AS definition +
+ | FROM (pg_class c +
+ | LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) +
+ | WHERE (c.relkind = 'v'::"char");
+ pgxc_prepared_xacts | SELECT DISTINCT pgxc_prepared_xact.pgxc_prepared_xact +
+ | FROM pgxc_prepared_xact() pgxc_prepared_xact(pgxc_prepared_xact);
+ rtest_v1 | SELECT rtest_t1.a, +
+ | rtest_t1.b +
+ | FROM rtest_t1;
+ rtest_vcomp | SELECT x.part, +
+ | (x.size * y.factor) AS size_in_cm +
+ | FROM rtest_comp x, +
+ | rtest_unitfact y +
+ | WHERE (x.unit = y.unit);
+ rtest_vview1 | SELECT x.a, +
+ | x.b +
+ | FROM rtest_view1 x +
+ | WHERE (0 < ( SELECT count(*) AS count +
+ | FROM rtest_view2 y +
+ | WHERE (y.a = x.a)));
+ rtest_vview2 | SELECT rtest_view1.a, +
+ | rtest_view1.b +
+ | FROM rtest_view1 +
+ | WHERE rtest_view1.v;
+ rtest_vview3 | SELECT x.a, +
+ | x.b +
+ | FROM rtest_vview2 x +
+ | WHERE (0 < ( SELECT count(*) AS count +
+ | FROM rtest_view2 y +
+ | WHERE (y.a = x.a)));
+ rtest_vview4 | SELECT x.a, +
+ | x.b, +
+ | count(y.a) AS refcount +
+ | FROM rtest_view1 x, +
+ | rtest_view2 y +
+ | WHERE (x.a = y.a) +
+ | GROUP BY x.a, x.b;
+ rtest_vview5 | SELECT rtest_view1.a, +
+ | rtest_view1.b, +
+ | rtest_viewfunc1(rtest_view1.a) AS refcount +
+ | FROM rtest_view1;
+ shoe | SELECT sh.shoename, +
+ | sh.sh_avail, +
+ | sh.slcolor, +
+ | sh.slminlen, +
+ | (sh.slminlen * un.un_fact) AS slminlen_cm, +
+ | sh.slmaxlen, +
+ | (sh.slmaxlen * un.un_fact) AS slmaxlen_cm, +
+ | sh.slunit +
+ | FROM shoe_data sh, +
+ | unit un +
+ | WHERE (sh.slunit = un.un_name);
+ shoe_ready | SELECT rsh.shoename, +
+ | rsh.sh_avail, +
+ | rsl.sl_name, +
+ | rsl.sl_avail, +
+ | int4smaller(rsh.sh_avail, rsl.sl_avail) AS total_avail +
+ | FROM shoe rsh, +
+ | shoelace rsl +
+ | WHERE ((rsl.sl_color = rsh.slcolor) AND (rsl.sl_len_cm >= rsh.slminlen_cm) AND (rsl.sl_len_cm <= rsh.slmaxlen_cm));
+ shoelace | SELECT s.sl_name, +
+ | s.sl_avail, +
+ | s.sl_color, +
+ | s.sl_len, +
+ | s.sl_unit, +
+ | (s.sl_len * u.un_fact) AS sl_len_cm +
+ | FROM shoelace_data s, +
+ | unit u +
+ | WHERE (s.sl_unit = u.un_name);
+ shoelace_candelete | SELECT shoelace_obsolete.sl_name, +
+ | shoelace_obsolete.sl_avail, +
+ | shoelace_obsolete.sl_color, +
+ | shoelace_obsolete.sl_len, +
+ | shoelace_obsolete.sl_unit, +
+ | shoelace_obsolete.sl_len_cm +
+ | FROM shoelace_obsolete +
+ | WHERE (shoelace_obsolete.sl_avail = 0);
+ shoelace_obsolete | SELECT shoelace.sl_name, +
+ | shoelace.sl_avail, +
+ | shoelace.sl_color, +
+ | shoelace.sl_len, +
+ | shoelace.sl_unit, +
+ | shoelace.sl_len_cm +
+ | FROM shoelace +
+ | WHERE (NOT (EXISTS ( SELECT shoe.shoename +
+ | FROM shoe +
+ | WHERE (shoe.slcolor = shoelace.sl_color))));
+ street | SELECT r.name, +
+ | r.thepath, +
+ | c.cname +
+ | FROM ONLY road r, +
+ | real_city c +
+ | WHERE (c.outline ## r.thepath);
+ test_tablesample_v1 | SELECT test_tablesample.id +
+ | FROM test_tablesample TABLESAMPLE system ((10 * 2)) REPEATABLE (2);
+ test_tablesample_v2 | SELECT test_tablesample.id +
+ | FROM test_tablesample TABLESAMPLE system (99);
+ toyemp | SELECT emp.name, +
+ | emp.age, +
+ | emp.location, +
+ | (12 * emp.salary) AS annualsal +
+ | FROM emp;
+ tv | SELECT t.type, +
+ | sum(t.amt) AS totamt +
+ | FROM t +
+ | GROUP BY t.type;
+ tvv | SELECT sum(tv.totamt) AS grandtot +
+ | FROM tv;
+ tvvmv | SELECT tvvm.grandtot +
+ | FROM tvvm;
+(73 rows)
+
-- temporarily disable fancy output, so view changes create less diff noise
\a\t
SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schema' ORDER BY viewname;
FROM (pg_class c
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = 'v'::"char");
+pgxc_prepared_xacts| SELECT DISTINCT pgxc_prepared_xact.pgxc_prepared_xact
+ FROM pgxc_prepared_xact() pgxc_prepared_xact(pgxc_prepared_xact);
rtest_v1| SELECT rtest_t1.a,
rtest_t1.b
FROM rtest_t1;
(6 rows)
update id_ordered set name = 'update 2' where id = 2;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
update id_ordered set name = 'update 4' where id = 4;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
update id_ordered set name = 'update 5' where id = 5;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select * from id_ordered order by id;
- id | name
-----+----------
+ id | name
+----+--------
1 | Test 1
- 2 | update 2
+ 2 | Test 2
3 | Test 3
- 4 | update 4
- 5 | update 5
+ 4 | Test 4
+ 5 | Test 5
6 | Test 6
(6 rows)
-- constraint exclusion
--
create temp table t1 (a integer primary key) distribute by replication;
-create temp table t1_1 (check (a >= 0 and a < 10)) inherits (t1);
-create temp table t1_2 (check (a >= 10 and a < 20)) inherits (t1);
+create temp table t1_1 (check (a >= 0 and a < 10)) inherits (t1) distribute by replication;
+create temp table t1_2 (check (a >= 10 and a < 20)) inherits (t1) distribute by replication;
create rule t1_ins_1 as on insert to t1
where new.a >= 0 and new.a < 10
do instead
set constraint_exclusion = on;
insert into t1 select * from generate_series(5,19,1) g;
update t1 set a = 4 where a = 5;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
select * from only t1 order by 1;
a
---
select * from only t1_1 order by 1;
a
---
- 4
+ 5
6
7
8
----+-----+-----
1 | 2 | old
1 | 3 | new
- 11 | 12 | old
- 11 | 13 | new
1 | 3 | old
1 | 30 | new
+ 11 | 12 | old
+ 11 | 13 | new
11 | 13 | old
11 | 130 | new
(8 rows)
----+-----+-----
1 | 2 | old
1 | 3 | new
- 11 | 12 | old
- 11 | 13 | new
1 | 3 | old
1 | 30 | new
- 11 | 13 | old
- 11 | 130 | new
1 | 30 | old
1 | 3 | new
+ 11 | 12 | old
+ 11 | 13 | new
+ 11 | 13 | old
+ 11 | 130 | new
11 | 130 | old
11 | 13 | new
(12 rows)
create rule r3 as on delete to rules_src do notify rules_src_deletion;
+ERROR: Rule may not use NOTIFY, it is not yet supported
\d+ rules_src
Table "public.rules_src"
Column | Type | Modifiers | Storage | Stats target | Description
ON UPDATE TO rules_src DO INSERT INTO rules_log (f1, f2, tag) VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text)
r2 AS
ON UPDATE TO rules_src DO VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text)
- r3 AS
- ON DELETE TO rules_src DO
- NOTIFY rules_src_deletion
+Distribute By: HASH(f1)
+Location Nodes: ALL DATANODES
--
-- Ensure a aliased target relation for insert is correctly deparsed.
ON UPDATE TO rules_src DO INSERT INTO rules_log (f1, f2, tag) VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text)
r2 AS
ON UPDATE TO rules_src DO VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text)
- r3 AS
- ON DELETE TO rules_src DO
- NOTIFY rules_src_deletion
r4 AS
ON INSERT TO rules_src DO INSTEAD INSERT INTO rules_log AS trgt (f1, f2) SELECT new.f1,
new.f2
r5 AS
ON UPDATE TO rules_src DO INSTEAD UPDATE rules_log trgt SET tag = 'updated'::text
WHERE trgt.f1 = new.f1
+Distribute By: HASH(f1)
+Location Nodes: ALL DATANODES
--
-- check alter rename rule
-- ensure explain works for on insert conflict rules
explain (costs off) INSERT INTO hats VALUES ('h8', 'forbidden') RETURNING *;
- QUERY PLAN
--------------------------------------------------------------------------------------------------
- Insert on hat_data
- Conflict Resolution: UPDATE
- Conflict Arbiter Indexes: hat_data_unique_idx
- Conflict Filter: ((excluded.hat_color <> 'forbidden'::bpchar) AND (hat_data.* <> excluded.*))
- -> Result
-(5 rows)
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1)
+ -> Insert on hat_data
+ Conflict Resolution: UPDATE
+ Conflict Arbiter Indexes: hat_data_unique_idx
+ Conflict Filter: ((excluded.hat_color <> 'forbidden'::bpchar) AND (hat_data.* <> excluded.*))
+ -> Result
+(6 rows)
-- ensure upserting into a rule, with a CTE (different offsets!) works
WITH data(hat_name, hat_color) AS (
INSERT INTO hats
SELECT * FROM data
RETURNING *;
- hat_name | hat_color
-------------+------------
- h8 | green
- h9 | blue
-(2 rows)
-
+ERROR: unrecognized node type: 119
EXPLAIN (costs off) WITH data(hat_name, hat_color) AS (
VALUES ('h8', 'green'),
('h9', 'blue'),
INSERT INTO hats
SELECT * FROM data
RETURNING *;
- QUERY PLAN
--------------------------------------------------------------------------------------------------
- Insert on hat_data
- Conflict Resolution: UPDATE
- Conflict Arbiter Indexes: hat_data_unique_idx
- Conflict Filter: ((excluded.hat_color <> 'forbidden'::bpchar) AND (hat_data.* <> excluded.*))
- CTE data
- -> Values Scan on "*VALUES*"
- -> CTE Scan on data
-(7 rows)
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Insert on hat_data
+ Conflict Resolution: UPDATE
+ Conflict Arbiter Indexes: hat_data_unique_idx
+ Conflict Filter: ((excluded.hat_color <> 'forbidden'::bpchar) AND (hat_data.* <> excluded.*))
+ CTE data
+ -> Values Scan on "*VALUES*"
+ -> Remote Subquery Scan on all (datanode_1)
+ Distribute results by H: hat_name
+ -> CTE Scan on data
+(10 rows)
SELECT * FROM hat_data WHERE hat_name IN ('h8', 'h9', 'h7') ORDER BY hat_name;
hat_name | hat_color
------------+------------
h7 | black
- h8 | green
- h9 | blue
-(3 rows)
+ h8 | white
+(2 rows)
DROP RULE hat_upsert ON hats;
drop table hats;
SELECT t.id FROM test_tablesample AS t TABLESAMPLE SYSTEM (50) REPEATABLE (0);
id
----
- 3
- 4
- 5
6
8
-(6 rows)
+ 9
+ 7
+(4 rows)
SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (100.0/11) REPEATABLE (0);
id
SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (0);
id
----
- 3
- 4
- 5
6
8
-(6 rows)
+ 9
+ 7
+(4 rows)
SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (50) REPEATABLE (0);
id
----
- 4
- 5
- 6
- 7
8
-(5 rows)
+ 9
+(2 rows)
SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (5.5) REPEATABLE (0);
id
----
- 7
-(1 row)
+(0 rows)
-- 100% should give repeatable count results (ie, all rows) in any case
SELECT count(*) FROM test_tablesample TABLESAMPLE SYSTEM (100);
FETCH FIRST FROM tablesample_cur;
id
----
- 3
+ 6
(1 row)
FETCH NEXT FROM tablesample_cur;
id
----
- 4
+ 8
(1 row)
FETCH NEXT FROM tablesample_cur;
id
----
- 5
+ 9
(1 row)
SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (0);
id
----
- 3
- 4
- 5
6
- 7
8
-(6 rows)
+ 9
+ 7
+(4 rows)
FETCH NEXT FROM tablesample_cur;
id
----
- 6
+ 7
(1 row)
FETCH NEXT FROM tablesample_cur;
id
----
- 8
-(1 row)
+(0 rows)
FETCH NEXT FROM tablesample_cur;
id
----
- 9
-(1 row)
+(0 rows)
FETCH FIRST FROM tablesample_cur;
id
----
- 3
+ 6
(1 row)
FETCH NEXT FROM tablesample_cur;
id
----
- 4
+ 8
(1 row)
FETCH NEXT FROM tablesample_cur;
id
----
- 5
+ 9
(1 row)
FETCH NEXT FROM tablesample_cur;
id
----
- 6
+ 7
(1 row)
FETCH NEXT FROM tablesample_cur;
id
----
- 8
-(1 row)
+(0 rows)
FETCH NEXT FROM tablesample_cur;
id
----
- 9
-(1 row)
+(0 rows)
CLOSE tablesample_cur;
END;
EXPLAIN (COSTS OFF)
SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (2);
- QUERY PLAN
---------------------------------------------------------------------
- Sample Scan on test_tablesample
- Sampling: system ('50'::real) REPEATABLE ('2'::double precision)
-(2 rows)
+ QUERY PLAN
+--------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Node/s: datanode_1, datanode_2
+ -> Sample Scan on test_tablesample
+ Sampling: system ('50'::real) REPEATABLE ('2'::double precision)
+(4 rows)
EXPLAIN (COSTS OFF)
SELECT * FROM test_tablesample_v1;
- QUERY PLAN
---------------------------------------------------------------------
- Sample Scan on test_tablesample
- Sampling: system ('20'::real) REPEATABLE ('2'::double precision)
-(2 rows)
+ QUERY PLAN
+--------------------------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Sample Scan on test_tablesample
+ Sampling: system ('20'::real) REPEATABLE ('2'::double precision)
+(3 rows)
-- check inheritance behavior
explain (costs off)
select count(*) from person tablesample bernoulli (100);
- QUERY PLAN
--------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------
Aggregate
-> Append
- -> Sample Scan on person
- Sampling: bernoulli ('100'::real)
- -> Sample Scan on emp
- Sampling: bernoulli ('100'::real)
- -> Sample Scan on student
- Sampling: bernoulli ('100'::real)
- -> Sample Scan on stud_emp
- Sampling: bernoulli ('100'::real)
-(10 rows)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Sample Scan on person
+ Sampling: bernoulli ('100'::real)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Sample Scan on emp
+ Sampling: bernoulli ('100'::real)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Sample Scan on student
+ Sampling: bernoulli ('100'::real)
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Sample Scan on stud_emp
+ Sampling: bernoulli ('100'::real)
+(14 rows)
select count(*) from person tablesample bernoulli (100);
count
pct | count
-----+-------
0 | 0
- 100 | 10000
+ 100 | 0
(2 rows)
select * from
pct | count
-----+-------
0 | 0
- 100 | 10000
+ 100 | 0
(2 rows)
explain (costs off)
(values (0),(100)) v(pct),
lateral (select * from tenk1 tablesample bernoulli (pct)) ss
group by pct;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------
HashAggregate
Group Key: "*VALUES*".column1
-> Nested Loop
-> Values Scan on "*VALUES*"
- -> Sample Scan on tenk1
- Sampling: bernoulli ("*VALUES*".column1)
-(6 rows)
+ -> Materialize
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Sample Scan on tenk1
+ Sampling: bernoulli ("*VALUES*".column1)
+(8 rows)
select pct, count(unique1) from
(values (0),(100)) v(pct),
group by pct;
pct | count
-----+-------
- 100 | 10000
-(1 row)
+(0 rows)
select pct, count(unique1) from
(values (0),(100)) v(pct),
group by pct;
pct | count
-----+-------
- 100 | 10000
-(1 row)
+(0 rows)
-- errors
SELECT id FROM test_tablesample TABLESAMPLE FOOBAR (1);
CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl;
CREATE FUNCTION rw_view1_aa(x rw_view1)
RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql;
+ERROR: type rw_view1 does not exist
UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2
RETURNING rw_view1_aa(v), v.bb;
- rw_view1_aa | bb
--------------+---------------
- 2 | Updated row 2
-(1 row)
-
+ERROR: function rw_view1_aa(rw_view1) does not exist
+LINE 1: UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v...
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SELECT * FROM base_tbl;
- a | b
-----+---------------
+ a | b
+----+--------
-2 | Row -2
-1 | Row -1
0 | Row 0
1 | Row 1
- 2 | Updated row 2
+ 2 | Row 2
(5 rows)
EXPLAIN (costs off)
UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2
RETURNING rw_view1_aa(v), v.bb;
- QUERY PLAN
---------------------------------------------------
- Update on base_tbl
- -> Index Scan using base_tbl_pkey on base_tbl
- Index Cond: (a = 2)
-(3 rows)
-
+ERROR: function rw_view1_aa(rw_view1) does not exist
+LINE 2: UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v...
+ ^
+HINT: No function matches the given name and argument types. You might need to add explicit type casts.
DROP TABLE base_tbl CASCADE;
-NOTICE: drop cascades to 2 other objects
-DETAIL: drop cascades to view rw_view1
-drop cascades to function rw_view1_aa(rw_view1)
+NOTICE: drop cascades to view rw_view1
-- permissions checks
CREATE USER view_user1;
CREATE USER view_user2;
SELECT * FROM base_tbl ORDER BY a;
a
-----
+ 0.1
0.2
0.3
0.4
0.8
0.9
1
-(9 rows)
+(10 rows)
SELECT table_name, is_insertable_into
FROM information_schema.tables
Distribute results by R
-> Result
SubPlan 1
- -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Remote Subquery Scan on all (datanode_2)
-> Index Only Scan using ref_tbl_pkey on ref_tbl r
Index Cond: (a = b.a)
(9 rows)
DETAIL: The feature is not currently supported
CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b WITH CHECK OPTION;
INSERT INTO rw_view1 VALUES (5,0); -- ok
-INSERT INTO rw_view1 VALUES (15, 20); -- should fail
ERROR: new row violates WITH CHECK OPTION for "rw_view1"
-DETAIL: Failing row contains (15, 10).
+DETAIL: Failing row contains (5, 0).
+INSERT INTO rw_view1 VALUES (15, 20); -- should fail
UPDATE rw_view1 SET a = 20, b = 30; -- should fail
-ERROR: new row violates WITH CHECK OPTION for "rw_view1"
-DETAIL: Failing row contains (20, 10).
DROP TABLE base_tbl CASCADE;
NOTICE: drop cascades to view rw_view1
DROP FUNCTION base_tbl_trig_fn();
SELECT * FROM rw_view1 WHERE a > 0 WITH LOCAL CHECK OPTION;
INSERT INTO rw_view2 VALUES (-5); -- should fail
ERROR: new row violates WITH CHECK OPTION for "rw_view2"
-DETAIL: Failing row contains (-5).
+DETAIL: Failing row contains (-5, null).
INSERT INTO rw_view2 VALUES (5); -- ok
INSERT INTO rw_view2 VALUES (50); -- ok, but not in view
UPDATE rw_view2 SET a = a - 10; -- should fail
-ERROR: new row violates WITH CHECK OPTION for "rw_view2"
-DETAIL: Failing row contains (-5).
SELECT * FROM base_tbl;
- a | b
-----+----
- 5 | 10
- 50 | 10
+ a | b
+----+---
+ 5 |
+ 50 |
(2 rows)
-- Check option won't cascade down to base view with INSTEAD OF triggers
ALTER VIEW rw_view2 SET (check_option=cascaded);
INSERT INTO rw_view2 VALUES (100); -- ok, but not in view (doesn't fail rw_view1's check)
+ERROR: new row violates WITH CHECK OPTION for "rw_view1"
+DETAIL: Failing row contains (100, null).
UPDATE rw_view2 SET a = 200 WHERE a = 5; -- ok, but not in view (doesn't fail rw_view1's check)
SELECT * FROM base_tbl;
- a | b
------+----
- 50 | 10
- 100 | 10
- 200 | 10
-(3 rows)
+ a | b
+----+---
+ 5 |
+ 50 |
+(2 rows)
-- Neither local nor cascaded check options work with INSTEAD rules
DROP TRIGGER rw_view1_trig ON rw_view1;
+ERROR: trigger "rw_view1_trig" for table "rw_view1" does not exist
CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1
DO INSTEAD INSERT INTO base_tbl VALUES (NEW.a, 10);
CREATE RULE rw_view1_upd_rule AS ON UPDATE TO rw_view1
SELECT * FROM base_tbl;
a | b
-----+----
- 50 | 10
- 100 | 10
- 200 | 10
+ 50 |
-10 | 10
20 | 10
+ 30 |
30 | 10
-5 | 10
-(7 rows)
+(6 rows)
DROP TABLE base_tbl CASCADE;
NOTICE: drop cascades to 2 other objects
$$
LANGUAGE plpgsql STRICT IMMUTABLE LEAKPROOF;
SELECT * FROM rw_view1 WHERE snoop(person);
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Dick
-NOTICE: snooped value: Harry
person
--------
Tom
(2 rows)
UPDATE rw_view1 SET person=person WHERE snoop(person);
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Dick
-NOTICE: snooped value: Harry
DELETE FROM rw_view1 WHERE NOT snoop(person);
-NOTICE: snooped value: Dick
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Harry
ALTER VIEW rw_view1 SET (security_barrier = true);
SELECT table_name, is_insertable_into
FROM information_schema.tables
(1 row)
SELECT * FROM rw_view1 WHERE snoop(person);
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Harry
person
--------
Tom
(2 rows)
UPDATE rw_view1 SET person=person WHERE snoop(person);
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Harry
DELETE FROM rw_view1 WHERE NOT snoop(person);
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Harry
EXPLAIN (costs off) SELECT * FROM rw_view1 WHERE snoop(person);
QUERY PLAN
-----------------------------------------------------
- Remote Subquery Scan on all (datanode_2)
+ Remote Subquery Scan on all (datanode_1)
-> Subquery Scan on rw_view1
Filter: snoop(rw_view1.person)
-> Seq Scan on base_tbl
EXPLAIN (costs off) UPDATE rw_view1 SET person=person WHERE snoop(person);
QUERY PLAN
-----------------------------------------------------------------
- Remote Subquery Scan on all (datanode_2)
+ Remote Subquery Scan on all (datanode_1)
-> Update on base_tbl base_tbl_1
-> Subquery Scan on base_tbl
Filter: snoop(base_tbl.person)
EXPLAIN (costs off) DELETE FROM rw_view1 WHERE NOT snoop(person);
QUERY PLAN
-----------------------------------------------------------------
- Remote Subquery Scan on all (datanode_1)
+ Remote Subquery Scan on all (datanode_2)
-> Delete on base_tbl base_tbl_1
-> Subquery Scan on base_tbl
Filter: (NOT snoop(base_tbl.person))
(1 row)
SELECT * FROM rw_view2 WHERE snoop(person);
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Harry
-NOTICE: snooped value: Harry
person
--------
Tom
(2 rows)
UPDATE rw_view2 SET person=person WHERE snoop(person);
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Harry
-NOTICE: snooped value: Harry
DELETE FROM rw_view2 WHERE NOT snoop(person);
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Tom
-NOTICE: snooped value: Harry
-NOTICE: snooped value: Harry
EXPLAIN (costs off) SELECT * FROM rw_view2 WHERE snoop(person);
QUERY PLAN
-----------------------------------------------------------
- Remote Subquery Scan on all (datanode_2)
+ Remote Subquery Scan on all (datanode_1)
-> Subquery Scan on rw_view2
Filter: snoop(rw_view2.person)
-> Subquery Scan on rw_view1
EXPLAIN (costs off) UPDATE rw_view2 SET person=person WHERE snoop(person);
QUERY PLAN
-----------------------------------------------------------------------
- Remote Subquery Scan on all (datanode_1)
+ Remote Subquery Scan on all (datanode_2)
-> Update on base_tbl base_tbl_1
-> Subquery Scan on base_tbl
Filter: snoop(base_tbl.person)
EXPLAIN (costs off) DELETE FROM rw_view2 WHERE NOT snoop(person);
QUERY PLAN
-----------------------------------------------------------------------
- Remote Subquery Scan on all (datanode_2)
+ Remote Subquery Scan on all (datanode_1)
-> Delete on base_tbl base_tbl_1
-> Subquery Scan on base_tbl
Filter: (NOT snoop(base_tbl.person))
(10 rows)
DELETE FROM rw_view1 WHERE id = 1 AND snoop(data);
-NOTICE: snooped value: Row 1
EXPLAIN (costs off) INSERT INTO rw_view1 VALUES (2, 'New row 2');
QUERY PLAN
-----------------------------------------------------------------------
Remote Subquery Scan on any (datanode_1,datanode_2)
-> Insert on base_tbl
InitPlan 1 (returns $0)
- -> Remote Subquery Scan on all (datanode_1)
+ -> Remote Subquery Scan on all (datanode_2)
-> Index Only Scan using base_tbl_pkey on base_tbl t
Index Cond: (id = 2)
-> Remote Subquery Scan on all (datanode_1)
Remote Subquery Scan on any (datanode_1,datanode_2)
-> Update on base_tbl
InitPlan 1 (returns $0)
- -> Remote Subquery Scan on all (datanode_1)
+ -> Remote Subquery Scan on all (datanode_2)
-> Index Only Scan using base_tbl_pkey on base_tbl t
Index Cond: (id = 2)
-> Result
UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
- Remote Subquery Scan on any (datanode_1,datanode_2)
+ Remote Subquery Scan on all (datanode_1)
-> Update on public.t1 t1_4
Update on public.t1 t1_4
Update on public.t11 t1
-> Seq Scan on public.t12
Output: t12.ctid, t12.tableoid, t12.a
Filter: (t12.a = 3)
- -> Bitmap Heap Scan on public.t111
+ -> Seq Scan on public.t111
Output: t111.ctid, t111.tableoid, t111.a
- Recheck Cond: (t111.a = 3)
- -> Bitmap Index Scan on t111_a_idx
- Index Cond: (t111.a = 3)
+ Filter: (t111.a = 3)
-> Subquery Scan on t1_1
Output: 100, t1_1.b, t1_1.c, t1_1.d, t1_1.a, t1_1.a, t1_1.a, t1_1.a, t1_1.a, t1_1.a, t1_1.ctid
Filter: snoop(t1_1.a)
-> Seq Scan on public.t12 t12_1
Output: t12_1.ctid, t12_1.tableoid, t12_1.a
Filter: (t12_1.a = 3)
- -> Bitmap Heap Scan on public.t111 t111_1
+ -> Seq Scan on public.t111 t111_1
Output: t111_1.ctid, t111_1.tableoid, t111_1.a
- Recheck Cond: (t111_1.a = 3)
- -> Bitmap Index Scan on t111_a_idx
- Index Cond: (t111_1.a = 3)
+ Filter: (t111_1.a = 3)
-> Subquery Scan on t1_2
Output: 100, t1_2.b, t1_2.c, t1_2.e, t1_2.a, t1_2.a, t1_2.a, t1_2.a, t1_2.a, t1_2.a, t1_2.ctid
Filter: snoop(t1_2.a)
-> Seq Scan on public.t12 t12_3
Output: t12_3.ctid, t12_3.tableoid, t12_3.a
Filter: (t12_3.a = 3)
- -> Bitmap Heap Scan on public.t111 t111_2
+ -> Seq Scan on public.t111 t111_2
Output: t111_2.ctid, t111_2.tableoid, t111_2.a
- Recheck Cond: (t111_2.a = 3)
- -> Bitmap Index Scan on t111_a_idx
- Index Cond: (t111_2.a = 3)
+ Filter: (t111_2.a = 3)
-> Subquery Scan on t1_3
Output: 100, t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.a, t1_3.a, t1_3.a, t1_3.a, t1_3.a, t1_3.a, t1_3.ctid
Filter: snoop(t1_3.a)
Output: t111_3.a, t111_3.ctid, t111_3.b, t111_3.c, t111_3.d, t111_3.e, t111_3.ctid, t12_4.ctid, t12_4.tableoid
-> Nested Loop Semi Join
Output: t111_3.a, t111_3.ctid, t111_3.b, t111_3.c, t111_3.d, t111_3.e, t111_3.ctid, t12_4.ctid, t12_4.tableoid
- -> Index Scan using t111_a_idx on public.t111 t111_3
+ -> Seq Scan on public.t111 t111_3
Output: t111_3.a, t111_3.ctid, t111_3.b, t111_3.c, t111_3.d, t111_3.e
- Index Cond: ((t111_3.a > 5) AND (t111_3.a = 3))
- Filter: leakproof(t111_3.a)
+ Filter: ((t111_3.a > 5) AND (t111_3.a = 3) AND leakproof(t111_3.a))
-> Append
-> Seq Scan on public.t12 t12_4
Output: t12_4.ctid, t12_4.tableoid, t12_4.a
Filter: (t12_4.a = 3)
- -> Bitmap Heap Scan on public.t111 t111_4
+ -> Seq Scan on public.t111 t111_4
Output: t111_4.ctid, t111_4.tableoid, t111_4.a
- Recheck Cond: (t111_4.a = 3)
- -> Bitmap Index Scan on t111_a_idx
- Index Cond: (t111_4.a = 3)
-(83 rows)
+ Filter: (t111_4.a = 3)
+(74 rows)
UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
SELECT * FROM v1 WHERE a=100; -- Nothing should have been changed to 100
-> Seq Scan on public.t12
Output: t12.ctid, t12.tableoid, t12.a
Filter: (t12.a = 8)
- -> Bitmap Heap Scan on public.t111
+ -> Seq Scan on public.t111
Output: t111.ctid, t111.tableoid, t111.a
- Recheck Cond: (t111.a = 8)
- -> Bitmap Index Scan on t111_a_idx
- Index Cond: (t111.a = 8)
+ Filter: (t111.a = 8)
-> Subquery Scan on t1_1
Output: (t1_1.a + 1), t1_1.b, t1_1.c, t1_1.d, t1_1.a, t1_1.a, t1_1.a, t1_1.a, t1_1.a, t1_1.a, t1_1.ctid
Filter: snoop(t1_1.a)
-> Seq Scan on public.t12 t12_1
Output: t12_1.ctid, t12_1.tableoid, t12_1.a
Filter: (t12_1.a = 8)
- -> Bitmap Heap Scan on public.t111 t111_1
+ -> Seq Scan on public.t111 t111_1
Output: t111_1.ctid, t111_1.tableoid, t111_1.a
- Recheck Cond: (t111_1.a = 8)
- -> Bitmap Index Scan on t111_a_idx
- Index Cond: (t111_1.a = 8)
+ Filter: (t111_1.a = 8)
-> Subquery Scan on t1_2
Output: (t1_2.a + 1), t1_2.b, t1_2.c, t1_2.e, t1_2.a, t1_2.a, t1_2.a, t1_2.a, t1_2.a, t1_2.a, t1_2.ctid
Filter: snoop(t1_2.a)
-> Seq Scan on public.t12 t12_3
Output: t12_3.ctid, t12_3.tableoid, t12_3.a
Filter: (t12_3.a = 8)
- -> Bitmap Heap Scan on public.t111 t111_2
+ -> Seq Scan on public.t111 t111_2
Output: t111_2.ctid, t111_2.tableoid, t111_2.a
- Recheck Cond: (t111_2.a = 8)
- -> Bitmap Index Scan on t111_a_idx
- Index Cond: (t111_2.a = 8)
+ Filter: (t111_2.a = 8)
-> Subquery Scan on t1_3
Output: (t1_3.a + 1), t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.a, t1_3.a, t1_3.a, t1_3.a, t1_3.a, t1_3.a, t1_3.ctid
Filter: snoop(t1_3.a)
Output: t111_3.a, t111_3.ctid, t111_3.b, t111_3.c, t111_3.d, t111_3.e, t111_3.ctid, t12_4.ctid, t12_4.tableoid
-> Nested Loop Semi Join
Output: t111_3.a, t111_3.ctid, t111_3.b, t111_3.c, t111_3.d, t111_3.e, t111_3.ctid, t12_4.ctid, t12_4.tableoid
- -> Index Scan using t111_a_idx on public.t111 t111_3
+ -> Seq Scan on public.t111 t111_3
Output: t111_3.a, t111_3.ctid, t111_3.b, t111_3.c, t111_3.d, t111_3.e
- Index Cond: ((t111_3.a > 5) AND (t111_3.a = 8))
- Filter: leakproof(t111_3.a)
+ Filter: ((t111_3.a > 5) AND (t111_3.a = 8) AND leakproof(t111_3.a))
-> Append
-> Seq Scan on public.t12 t12_4
Output: t12_4.ctid, t12_4.tableoid, t12_4.a
Filter: (t12_4.a = 8)
- -> Bitmap Heap Scan on public.t111 t111_4
+ -> Seq Scan on public.t111 t111_4
Output: t111_4.ctid, t111_4.tableoid, t111_4.a
- Recheck Cond: (t111_4.a = 8)
- -> Bitmap Index Scan on t111_a_idx
- Index Cond: (t111_4.a = 8)
-(83 rows)
+ Filter: (t111_4.a = 8)
+(74 rows)
UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
-NOTICE: snooped value: 8
-NOTICE: snooped value: 8
-NOTICE: snooped value: 8
-NOTICE: snooped value: 8
SELECT * FROM v1 WHERE b=8;
a | b | c | d
---+---+------+------
(4 rows)
DELETE FROM v1 WHERE snoop(a) AND leakproof(a); -- should not delete everything, just where a>5
-NOTICE: snooped value: 6
-NOTICE: snooped value: 7
-NOTICE: snooped value: 9
-NOTICE: snooped value: 10
-NOTICE: snooped value: 9
-NOTICE: snooped value: 6
-NOTICE: snooped value: 7
-NOTICE: snooped value: 9
-NOTICE: snooped value: 10
-NOTICE: snooped value: 9
-NOTICE: snooped value: 6
-NOTICE: snooped value: 7
-NOTICE: snooped value: 9
-NOTICE: snooped value: 10
-NOTICE: snooped value: 9
-NOTICE: snooped value: 6
-NOTICE: snooped value: 7
-NOTICE: snooped value: 9
-NOTICE: snooped value: 10
-NOTICE: snooped value: 9
TABLE t1; -- verify all a<=5 are intact
a | b | c
---+---+------
insert into tab1_rr values (7, 8);
insert into tab1_rr values (9, 2);
explain (verbose on, nodes off, num_nodes on, costs off) insert into tab1_rr values (9, 2);
- QUERY PLAN
------------------------------------------
- Remote Subquery Scan on all
+ QUERY PLAN
+------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: 9, 2
+ Remote query: INSERT INTO tab1_rr (val, val2) VALUES (9, 2)
-> Insert on public.tab1_rr
- -> Remote Subquery Scan on all
+ -> Result
Output: 9, 2
- Distribute results by N
- -> Result
- Output: 9, 2
-(7 rows)
+(6 rows)
-- simple select
-- should get FQSed
(1 row)
explain (verbose on, nodes off, costs off) select val, val2 + 2, case val when val2 then 'val and val2 are same' else 'val and val2 are not same' end from tab1_rr where val2 = 4;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
- Remote Subquery Scan on all
- Output: val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_rr.val, (tab1_rr.val2 + 2), CASE tab1_rr.val WHEN tab1_rr.val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
+ Remote query: SELECT val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END AS "case" FROM tab1_rr WHERE (val2 = 4)
-> Seq Scan on public.tab1_rr
Output: val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
Filter: (tab1_rr.val2 = 4)
-(5 rows)
+(6 rows)
-- should not get FQSed because of aggregates
select sum(val), avg(val), count(*) from tab1_rr;
(1 row)
explain (verbose on, nodes off, costs off) select val, val2 from tab1_rr where val2 = 8 group by val, val2;
- QUERY PLAN
-----------------------------------------------------
- HashAggregate
- Output: val, val2
- Group Key: tab1_rr.val, tab1_rr.val2
- -> Remote Subquery Scan on all
+ QUERY PLAN
+-----------------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM tab1_rr WHERE (val2 = 8) GROUP BY val, val2
+ -> HashAggregate
Output: val, val2
- -> HashAggregate
+ Group Key: tab1_rr.val, tab1_rr.val2
+ -> Seq Scan on public.tab1_rr
Output: val, val2
- Group Key: tab1_rr.val, tab1_rr.val2
- -> Seq Scan on public.tab1_rr
- Output: val, val2
- Filter: (tab1_rr.val2 = 8)
-(11 rows)
+ Filter: (tab1_rr.val2 = 8)
+(9 rows)
-- should not get FQSed because of HAVING clause
select sum(val) from tab1_rr where val2 = 2 group by val2 having sum(val) > 1;
(1 row)
explain (verbose on, nodes off, costs off) select * from tab1_rr where val = 7;
- QUERY PLAN
------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+---------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM tab1_rr WHERE (val = 7)
-> Seq Scan on public.tab1_rr
Output: val, val2
Filter: (tab1_rr.val = 7)
-(5 rows)
+(6 rows)
select * from tab1_rr where val = 7 or val = 2 order by val;
val | val2
-- DMLs
update tab1_rr set val2 = 1000 where val = 7;
explain (verbose on, nodes off, costs off) update tab1_rr set val2 = 1000 where val = 7;
- QUERY PLAN
---------------------------------------------------------
- Remote Subquery Scan on all
+ QUERY PLAN
+----------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: 1000, tab1_rr.val, tab1_rr.xc_node_id, tab1_rr.ctid
+ Remote query: UPDATE tab1_rr SET val2 = 1000 WHERE (val = 7)
-> Update on public.tab1_rr
-> Seq Scan on public.tab1_rr
- Output: val, 1000, val, xc_node_id, ctid
+ Output: val, 1000, ctid
Filter: (tab1_rr.val = 7)
-(5 rows)
+(7 rows)
select * from tab1_rr where val = 7;
val | val2
delete from tab1_rr where val = 7;
explain (verbose on, costs off) delete from tab1_rr where val = 7;
- QUERY PLAN
------------------------------------------------------
- Remote Subquery Scan on all (datanode_1,datanode_2)
+ QUERY PLAN
+---------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_rr.val, tab1_rr.xc_node_id, tab1_rr.ctid
+ Node/s: datanode_1, datanode_2
+ Remote query: DELETE FROM tab1_rr WHERE (val = 7)
-> Delete on public.tab1_rr
-> Seq Scan on public.tab1_rr
- Output: val, xc_node_id, ctid
+ Output: ctid
Filter: (tab1_rr.val = 7)
-(5 rows)
+(8 rows)
select * from tab1_rr where val = 7;
val | val2
insert into tab1_hash values (7, 8);
insert into tab1_hash values (9, 2);
explain (verbose on, costs off) insert into tab1_hash values (9, 2);
- QUERY PLAN
-------------------------------------------------
- Remote Subquery Scan on all (datanode_1)
+ QUERY PLAN
+-----------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: 9, 2
+ Node expr: 9
+ Remote query: INSERT INTO tab1_hash (val, val2) VALUES (9, 2)
-> Insert on public.tab1_hash
- -> Remote Subquery Scan on local node
+ -> Result
Output: 9, 2
- Distribute results by H: 9
- -> Result
- Output: 9, 2
(7 rows)
-- simple select
(1 row)
explain (verbose on, nodes off, costs off) select val, val2 + 2, case val when val2 then 'val and val2 are same' else 'val and val2 are not same' end from tab1_hash where val2 = 2;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
- Remote Subquery Scan on all
- Output: val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_hash.val, (tab1_hash.val2 + 2), CASE tab1_hash.val WHEN tab1_hash.val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
+ Remote query: SELECT val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END AS "case" FROM tab1_hash WHERE (val2 = 2)
-> Seq Scan on public.tab1_hash
Output: val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
Filter: (tab1_hash.val2 = 2)
-(5 rows)
+(6 rows)
-- should not get FQSed because of aggregates
select sum(val), avg(val), count(*) from tab1_hash;
(1 row)
explain (verbose on, nodes off, costs off) select distinct val, val2 from tab1_hash where val2 = 8;
- QUERY PLAN
---------------------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+---------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT DISTINCT val, val2 FROM tab1_hash WHERE (val2 = 8)
-> HashAggregate
Output: val, val2
Group Key: tab1_hash.val, tab1_hash.val2
-> Seq Scan on public.tab1_hash
Output: val, val2
Filter: (tab1_hash.val2 = 8)
-(8 rows)
+(9 rows)
-- should not get FQSed because of GROUP clause
select val, val2 from tab1_hash where val2 = 8 group by val, val2;
(1 row)
explain (verbose on, nodes off, costs off) select val, val2 from tab1_hash where val2 = 8 group by val, val2;
- QUERY PLAN
---------------------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+-------------------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM tab1_hash WHERE (val2 = 8) GROUP BY val, val2
-> HashAggregate
Output: val, val2
Group Key: tab1_hash.val, tab1_hash.val2
-> Seq Scan on public.tab1_hash
Output: val, val2
Filter: (tab1_hash.val2 = 8)
-(8 rows)
+(9 rows)
-- should not get FQSed because of HAVING clause
select sum(val) from tab1_hash where val2 = 2 group by val2 having sum(val) > 1;
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select * from tab1_hash where val = 7;
- QUERY PLAN
--------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM tab1_hash WHERE (val = 7)
-> Seq Scan on public.tab1_hash
Output: val, val2
Filter: (tab1_hash.val = 7)
-(5 rows)
+(6 rows)
select * from tab1_hash where val = 7 or val = 2 order by val;
val | val2
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select * from tab1_hash where val = 7 and val2 = 8;
- QUERY PLAN
-----------------------------------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+----------------------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM tab1_hash WHERE ((val = 7) AND (val2 = 8))
-> Seq Scan on public.tab1_hash
Output: val, val2
Filter: ((tab1_hash.val = 7) AND (tab1_hash.val2 = 8))
-(5 rows)
+(6 rows)
select * from tab1_hash where val = 3 + 4 and val2 = 8;
val | val2
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select * from tab1_hash where val = 3 + 4;
- QUERY PLAN
--------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+-----------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM tab1_hash WHERE (val = (3 + 4))
-> Seq Scan on public.tab1_hash
Output: val, val2
Filter: (tab1_hash.val = 7)
-(5 rows)
+(6 rows)
select * from tab1_hash where val = char_length('len')+4;
val | val2
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select * from tab1_hash where val = char_length('len')+4;
- QUERY PLAN
--------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM tab1_hash WHERE (val = (char_length('len'::text) + 4))
-> Seq Scan on public.tab1_hash
Output: val, val2
Filter: (tab1_hash.val = 7)
-(5 rows)
+(6 rows)
-- insert some more values
insert into tab1_hash values (7, 2);
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select avg(val) from tab1_hash where val = 7;
- QUERY PLAN
--------------------------------------------------
- Aggregate
- Output: pg_catalog.avg((avg(val)))
- -> Remote Subquery Scan on all
+ QUERY PLAN
+-----------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: avg(tab1_hash.val)
+ Remote query: SELECT avg(val) AS avg FROM tab1_hash WHERE (val = 7)
+ -> Aggregate
Output: avg(val)
- -> Aggregate
- Output: avg(val)
- -> Seq Scan on public.tab1_hash
- Output: val, val2
- Filter: (tab1_hash.val = 7)
-(9 rows)
+ -> Seq Scan on public.tab1_hash
+ Output: val, val2
+ Filter: (tab1_hash.val = 7)
+(8 rows)
select val, val2 from tab1_hash where val = 7 order by val2;
val | val2
(2 rows)
explain (verbose on, nodes off, costs off, num_nodes on) select val, val2 from tab1_hash where val = 7 order by val2;
- QUERY PLAN
--------------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+-------------------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM tab1_hash WHERE (val = 7) ORDER BY val2
-> Sort
Output: val, val2
Sort Key: tab1_hash.val2
-> Seq Scan on public.tab1_hash
Output: val, val2
Filter: (tab1_hash.val = 7)
-(8 rows)
+(9 rows)
select distinct val2 from tab1_hash where val = 7;
val2
(2 rows)
explain (verbose on, nodes off, costs off, num_nodes on) select distinct val2 from tab1_hash where val = 7;
- QUERY PLAN
--------------------------------------------------
- HashAggregate
- Output: val2
- Group Key: tab1_hash.val2
- -> Remote Subquery Scan on all
+ QUERY PLAN
+---------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_hash.val2
+ Remote query: SELECT DISTINCT val2 FROM tab1_hash WHERE (val = 7)
+ -> HashAggregate
Output: val2
- -> HashAggregate
+ Group Key: tab1_hash.val2
+ -> Seq Scan on public.tab1_hash
Output: val2
- Group Key: tab1_hash.val2
- -> Seq Scan on public.tab1_hash
- Output: val2
- Filter: (tab1_hash.val = 7)
-(11 rows)
+ Filter: (tab1_hash.val = 7)
+(9 rows)
-- DMLs
update tab1_hash set val2 = 1000 where val = 7;
explain (verbose on, nodes off, costs off) update tab1_hash set val2 = 1000 where val = 7;
- QUERY PLAN
---------------------------------------------------------
- Remote Subquery Scan on all
+ QUERY PLAN
+---------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: 1000, tab1_hash.val, tab1_hash.xc_node_id, tab1_hash.ctid
+ Remote query: UPDATE tab1_hash SET val2 = 1000 WHERE (val = 7)
-> Update on public.tab1_hash
-> Seq Scan on public.tab1_hash
- Output: val, 1000, val, xc_node_id, ctid
+ Output: val, 1000, ctid
Filter: (tab1_hash.val = 7)
-(5 rows)
+(7 rows)
select * from tab1_hash where val = 7;
val | val2
delete from tab1_hash where val = 7;
explain (verbose on, costs off) delete from tab1_hash where val = 7;
- QUERY PLAN
---------------------------------------------------
- Remote Subquery Scan on all (datanode_2)
+ QUERY PLAN
+---------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_hash.val, tab1_hash.xc_node_id, tab1_hash.ctid
+ Node/s: datanode_2
+ Remote query: DELETE FROM tab1_hash WHERE (val = 7)
-> Delete on public.tab1_hash
-> Seq Scan on public.tab1_hash
- Output: val, xc_node_id, ctid, val
+ Output: ctid
Filter: (tab1_hash.val = 7)
-(5 rows)
+(8 rows)
select * from tab1_hash where val = 7;
val | val2
insert into tab1_modulo values (7, 8);
insert into tab1_modulo values (9, 2);
explain (verbose on, costs off) insert into tab1_modulo values (9, 2);
- QUERY PLAN
-------------------------------------------------
- Remote Subquery Scan on all (datanode_2)
+ QUERY PLAN
+-------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: 9, 2
+ Node expr: 9
+ Remote query: INSERT INTO tab1_modulo (val, val2) VALUES (9, 2)
-> Insert on public.tab1_modulo
- -> Remote Subquery Scan on local node
+ -> Result
Output: 9, 2
- Distribute results by M: 9
- -> Result
- Output: 9, 2
(7 rows)
-- simple select
(1 row)
explain (verbose on, nodes off, costs off) select val, val2 + 2, case val when val2 then 'val and val2 are same' else 'val and val2 are not same' end from tab1_modulo where val2 = 4;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
- Remote Subquery Scan on all
- Output: val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_modulo.val, (tab1_modulo.val2 + 2), CASE tab1_modulo.val WHEN tab1_modulo.val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
+ Remote query: SELECT val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END AS "case" FROM tab1_modulo WHERE (val2 = 4)
-> Seq Scan on public.tab1_modulo
Output: val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
Filter: (tab1_modulo.val2 = 4)
-(5 rows)
+(6 rows)
-- should not get FQSed because of aggregates
select sum(val), avg(val), count(*) from tab1_modulo;
(1 row)
explain (verbose on, nodes off, costs off) select distinct val, val2 from tab1_modulo where val2 = 8;
- QUERY PLAN
-------------------------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+-----------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT DISTINCT val, val2 FROM tab1_modulo WHERE (val2 = 8)
-> HashAggregate
Output: val, val2
Group Key: tab1_modulo.val, tab1_modulo.val2
-> Seq Scan on public.tab1_modulo
Output: val, val2
Filter: (tab1_modulo.val2 = 8)
-(8 rows)
+(9 rows)
-- should not get FQSed because of GROUP clause
select val, val2 from tab1_modulo where val2 = 8 group by val, val2;
(1 row)
explain (verbose on, nodes off, costs off) select val, val2 from tab1_modulo where val2 = 8 group by val, val2;
- QUERY PLAN
-------------------------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+---------------------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM tab1_modulo WHERE (val2 = 8) GROUP BY val, val2
-> HashAggregate
Output: val, val2
Group Key: tab1_modulo.val, tab1_modulo.val2
-> Seq Scan on public.tab1_modulo
Output: val, val2
Filter: (tab1_modulo.val2 = 8)
-(8 rows)
+(9 rows)
-- should not get FQSed because of HAVING clause
select sum(val) from tab1_modulo where val2 = 2 group by val2 having sum(val) > 1;
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select * from tab1_modulo where val = 7;
- QUERY PLAN
----------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+-------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM tab1_modulo WHERE (val = 7)
-> Seq Scan on public.tab1_modulo
Output: val, val2
Filter: (tab1_modulo.val = 7)
-(5 rows)
+(6 rows)
select * from tab1_modulo where val = 7 or val = 2 order by val;
val | val2
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select * from tab1_modulo where val = 7 and val2 = 8;
- QUERY PLAN
---------------------------------------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+------------------------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM tab1_modulo WHERE ((val = 7) AND (val2 = 8))
-> Seq Scan on public.tab1_modulo
Output: val, val2
Filter: ((tab1_modulo.val = 7) AND (tab1_modulo.val2 = 8))
-(5 rows)
+(6 rows)
select * from tab1_modulo where val = 3 + 4 and val2 = 8;
val | val2
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select * from tab1_modulo where val = 3 + 4;
- QUERY PLAN
----------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+-------------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM tab1_modulo WHERE (val = (3 + 4))
-> Seq Scan on public.tab1_modulo
Output: val, val2
Filter: (tab1_modulo.val = 7)
-(5 rows)
+(6 rows)
select * from tab1_modulo where val = char_length('len')+4;
val | val2
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select * from tab1_modulo where val = char_length('len')+4;
- QUERY PLAN
----------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+------------------------------------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM tab1_modulo WHERE (val = (char_length('len'::text) + 4))
-> Seq Scan on public.tab1_modulo
Output: val, val2
Filter: (tab1_modulo.val = 7)
-(5 rows)
+(6 rows)
-- insert some more values
insert into tab1_modulo values (7, 2);
(1 row)
explain (verbose on, nodes off, costs off, num_nodes on) select avg(val) from tab1_modulo where val = 7;
- QUERY PLAN
----------------------------------------------------
- Aggregate
- Output: pg_catalog.avg((avg(val)))
- -> Remote Subquery Scan on all
+ QUERY PLAN
+-------------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: avg(tab1_modulo.val)
+ Remote query: SELECT avg(val) AS avg FROM tab1_modulo WHERE (val = 7)
+ -> Aggregate
Output: avg(val)
- -> Aggregate
- Output: avg(val)
- -> Seq Scan on public.tab1_modulo
- Output: val, val2
- Filter: (tab1_modulo.val = 7)
-(9 rows)
+ -> Seq Scan on public.tab1_modulo
+ Output: val, val2
+ Filter: (tab1_modulo.val = 7)
+(8 rows)
select val, val2 from tab1_modulo where val = 7 order by val2;
val | val2
(2 rows)
explain (verbose on, nodes off, costs off, num_nodes on) select val, val2 from tab1_modulo where val = 7 order by val2;
- QUERY PLAN
----------------------------------------------
- Remote Subquery Scan on all
- Output: val, val2
+ QUERY PLAN
+---------------------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM tab1_modulo WHERE (val = 7) ORDER BY val2
-> Sort
Output: val, val2
Sort Key: tab1_modulo.val2
-> Seq Scan on public.tab1_modulo
Output: val, val2
Filter: (tab1_modulo.val = 7)
-(8 rows)
+(9 rows)
select distinct val2 from tab1_modulo where val = 7;
val2
(2 rows)
explain (verbose on, nodes off, costs off, num_nodes on) select distinct val2 from tab1_modulo where val = 7;
- QUERY PLAN
----------------------------------------------------
- HashAggregate
- Output: val2
- Group Key: tab1_modulo.val2
- -> Remote Subquery Scan on all
+ QUERY PLAN
+-----------------------------------------------------------------------
+ Remote Fast Query Execution (primary node count=0, node count=1)
+ Output: tab1_modulo.val2
+ Remote query: SELECT DISTINCT val2 FROM tab1_modulo WHERE (val = 7)
+ -> HashAggregate
Output: val2
- -> HashAggregate
+ Group Key: tab1_modulo.val2
+ -> Seq Scan on public.tab1_modulo
Output: val2
- Group Key: tab1_modulo.val2
- -> Seq Scan on public.tab1_modulo
- Output: val2
- Filter: (tab1_modulo.val = 7)
-(11 rows)
+ Filter: (tab1_modulo.val = 7)
+(9 rows)
-- DMLs
update tab1_modulo set val2 = 1000 where val = 7;
explain (verbose on, nodes off, costs off) update tab1_modulo set val2 = 1000 where val = 7;
- QUERY PLAN
---------------------------------------------------------
- Remote Subquery Scan on all
+ QUERY PLAN
+---------------------------------------------------------------------------
+ Remote Fast Query Execution
+ Output: 1000, tab1_modulo.val, tab1_modulo.xc_node_id, tab1_modulo.ctid
+ Remote query: UPDATE tab1_modulo SET val2 = 1000 WHERE (val = 7)
&