Test sql and output changes for LATERAL issue
authorPallavi Sontakke <[email protected]>
Fri, 12 Feb 2016 12:50:37 +0000 (18:20 +0530)
committerPallavi Sontakke <[email protected]>
Fri, 12 Feb 2016 12:50:37 +0000 (18:20 +0530)
Separate out Issue #73 in Issue Tracker.
Accept XL query plans.

contrib/tsm_system_time/Makefile
contrib/tsm_system_time/expected/tsm_system_time.out
contrib/tsm_system_time/expected/xl_known_bugs.out [new file with mode: 0644]
contrib/tsm_system_time/sql/tsm_system_time.sql
contrib/tsm_system_time/sql/xl_known_bugs.sql [new file with mode: 0644]

index 4c08a9935ab68ea80bd28f8b99059689aae9112d..0176e9a5ddc2e11a4dc9ade890d3fa560def119e 100644 (file)
@@ -7,7 +7,7 @@ PGFILEDESC = "tsm_system_time - TABLESAMPLE method which accepts time in millise
 EXTENSION = tsm_system_time
 DATA = tsm_system_time--1.0.sql
 
-REGRESS = tsm_system_time
+REGRESS = tsm_system_time xl_known_bugs
 
 SHLIB_LINK += $(filter -lm, $(LIBS))
 
index ac44f30be90386407273b213239aa234a5dd0bd1..02c2ed72621ae92f6e0925a8eb77e753825fc6b2 100644 (file)
@@ -21,11 +21,13 @@ SELECT count(*) FROM test_tablesample TABLESAMPLE system_time (100000);
 -- bad parameters should get through planning, but not execution:
 EXPLAIN (COSTS OFF)
 SELECT id FROM test_tablesample TABLESAMPLE system_time (-1);
-                    QUERY PLAN                    
---------------------------------------------------
- Sample Scan on test_tablesample
-   Sampling: system_time ('-1'::double precision)
-(2 rows)
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Remote Fast Query Execution
+   Node/s: datanode_1, datanode_2
+   ->  Sample Scan on test_tablesample
+         Sampling: system_time ('-1'::double precision)
+(4 rows)
 
 SELECT id FROM test_tablesample TABLESAMPLE system_time (-1);
 ERROR:  sample collection time must not be negative
@@ -40,15 +42,17 @@ SELECT * FROM
   (VALUES (0),(100000)) v(time),
   LATERAL (SELECT COUNT(*) FROM test_tablesample
            TABLESAMPLE system_time (100000)) ss;
-                               QUERY PLAN                               
-------------------------------------------------------------------------
+                                     QUERY PLAN                                     
+------------------------------------------------------------------------------------
  Nested Loop
    ->  Aggregate
-         ->  Materialize
-               ->  Sample Scan on test_tablesample
-                     Sampling: system_time ('100000'::double precision)
+         ->  Remote Subquery Scan on all (datanode_1,datanode_2)
+               ->  Aggregate
+                     ->  Materialize
+                           ->  Sample Scan on test_tablesample
+                                 Sampling: system_time ('100000'::double precision)
    ->  Values Scan on "*VALUES*"
-(6 rows)
+(8 rows)
 
 SELECT * FROM
   (VALUES (0),(100000)) v(time),
@@ -65,36 +69,32 @@ SELECT * FROM
   (VALUES (0),(100000)) v(time),
   LATERAL (SELECT COUNT(*) FROM test_tablesample
            TABLESAMPLE system_time (time)) ss;
-                           QUERY PLAN                           
-----------------------------------------------------------------
+                                 QUERY PLAN                                 
+----------------------------------------------------------------------------
  Nested Loop
    ->  Values Scan on "*VALUES*"
    ->  Aggregate
-         ->  Materialize
-               ->  Sample Scan on test_tablesample
-                     Sampling: system_time ("*VALUES*".column1)
-(6 rows)
-
-SELECT * FROM
-  (VALUES (0),(100000)) v(time),
-  LATERAL (SELECT COUNT(*) FROM test_tablesample
-           TABLESAMPLE system_time (time)) ss;
-  time  | count 
---------+-------
-      0 |     0
- 100000 |    31
-(2 rows)
+         ->  Remote Subquery Scan on all (datanode_1,datanode_2)
+               ->  Aggregate
+                     ->  Materialize
+                           ->  Sample Scan on test_tablesample
+                                 Sampling: system_time ("*VALUES*".column1)
+(8 rows)
 
 CREATE VIEW vv AS
   SELECT * FROM test_tablesample TABLESAMPLE system_time (20);
 EXPLAIN (COSTS OFF) SELECT * FROM vv;
-                    QUERY PLAN                    
---------------------------------------------------
- Sample Scan on test_tablesample
-   Sampling: system_time ('20'::double precision)
-(2 rows)
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Remote Subquery Scan on all (datanode_1,datanode_2)
+   ->  Sample Scan on test_tablesample
+         Sampling: system_time ('20'::double precision)
+(3 rows)
 
 DROP EXTENSION tsm_system_time;  -- fail, view depends on extension
 ERROR:  cannot drop extension tsm_system_time because other objects depend on it
 DETAIL:  view vv depends on function system_time(internal)
 HINT:  Use DROP ... CASCADE to drop the dependent objects too.
+DROP VIEW vv;
+DROP TABLE test_tablesample;
+DROP EXTENSION tsm_system_time;
diff --git a/contrib/tsm_system_time/expected/xl_known_bugs.out b/contrib/tsm_system_time/expected/xl_known_bugs.out
new file mode 100644 (file)
index 0000000..69998b0
--- /dev/null
@@ -0,0 +1,33 @@
+CREATE EXTENSION tsm_system_time;
+CREATE TABLE test_tablesample (id int, name text);
+INSERT INTO test_tablesample SELECT i, repeat(i::text, 1000)
+  FROM generate_series(0, 30) s(i);
+EXPLAIN (COSTS OFF)
+SELECT * FROM
+  (VALUES (0),(100000)) v(time),
+  LATERAL (SELECT COUNT(*) FROM test_tablesample
+           TABLESAMPLE system_time (time)) ss;
+                                 QUERY PLAN                                 
+----------------------------------------------------------------------------
+ Nested Loop
+   ->  Values Scan on "*VALUES*"
+   ->  Aggregate
+         ->  Remote Subquery Scan on all (datanode_1,datanode_2)
+               ->  Aggregate
+                     ->  Materialize
+                           ->  Sample Scan on test_tablesample
+                                 Sampling: system_time ("*VALUES*".column1)
+(8 rows)
+
+SELECT * FROM
+  (VALUES (0),(100000)) v(time),
+  LATERAL (SELECT COUNT(*) FROM test_tablesample
+           TABLESAMPLE system_time (time)) ss;
+  time  | count 
+--------+-------
+      0 |     0
+ 100000 |    31
+(2 rows)
+
+DROP TABLE test_tablesample;
+DROP EXTENSION tsm_system_time;  -- fail, view depends on extension
index 117de163d85059f362cda878ef94f5f6b43aa65e..1c5e159956284ce1319ce1bc928dd3f6474f76d4 100644 (file)
@@ -38,14 +38,13 @@ SELECT * FROM
   LATERAL (SELECT COUNT(*) FROM test_tablesample
            TABLESAMPLE system_time (time)) ss;
 
-SELECT * FROM
-  (VALUES (0),(100000)) v(time),
-  LATERAL (SELECT COUNT(*) FROM test_tablesample
-           TABLESAMPLE system_time (time)) ss;
-
 CREATE VIEW vv AS
   SELECT * FROM test_tablesample TABLESAMPLE system_time (20);
 
 EXPLAIN (COSTS OFF) SELECT * FROM vv;
 
 DROP EXTENSION tsm_system_time;  -- fail, view depends on extension
+
+DROP VIEW vv;
+DROP TABLE test_tablesample;
+DROP EXTENSION tsm_system_time;
diff --git a/contrib/tsm_system_time/sql/xl_known_bugs.sql b/contrib/tsm_system_time/sql/xl_known_bugs.sql
new file mode 100644 (file)
index 0000000..2778b70
--- /dev/null
@@ -0,0 +1,18 @@
+CREATE EXTENSION tsm_system_time;
+CREATE TABLE test_tablesample (id int, name text);
+INSERT INTO test_tablesample SELECT i, repeat(i::text, 1000)
+  FROM generate_series(0, 30) s(i);
+
+EXPLAIN (COSTS OFF)
+SELECT * FROM
+  (VALUES (0),(100000)) v(time),
+  LATERAL (SELECT COUNT(*) FROM test_tablesample
+           TABLESAMPLE system_time (time)) ss;
+
+SELECT * FROM
+  (VALUES (0),(100000)) v(time),
+  LATERAL (SELECT COUNT(*) FROM test_tablesample
+           TABLESAMPLE system_time (time)) ss;
+
+DROP TABLE test_tablesample;
+DROP EXTENSION tsm_system_time;  -- fail, view depends on extension