Separate out LATERAL Issue #73 into xl_known_bugs
authorPallavi Sontakke <[email protected]>
Thu, 16 Jun 2016 08:53:47 +0000 (14:23 +0530)
committerPavan Deolasee <[email protected]>
Tue, 18 Oct 2016 10:05:26 +0000 (15:35 +0530)
src/test/regress/expected/tablesample.out
src/test/regress/expected/xl_known_bugs.out
src/test/regress/sql/tablesample.sql
src/test/regress/sql/xl_known_bugs.sql

index a694c2b42125d7cbada47a5accbec5eee20a33e8..4f5aa480ae02ace59fccda7f3bcfb1d5f143b07b 100644 (file)
@@ -242,22 +242,6 @@ select pct, count(unique1) from
                            Sampling: bernoulli ("*VALUES*".column1)
 (8 rows)
 
-select pct, count(unique1) from
-  (values (0),(100)) v(pct),
-  lateral (select * from tenk1 tablesample bernoulli (pct)) ss
-  group by pct;
- pct | count 
------+-------
-(0 rows)
-
-select pct, count(unique1) from
-  (values (0),(100)) v(pct),
-  lateral (select * from tenk1 tablesample system (pct)) ss
-  group by pct;
- pct | count 
------+-------
-(0 rows)
-
 -- errors
 SELECT id FROM test_tablesample TABLESAMPLE FOOBAR (1);
 ERROR:  tablesample method "foobar" does not exist
index 7fd2c62668283cb82e5c530ce4378ebdc1a2b507..cfef50f9697d613959c4e1d05e2341c972abd2a4 100644 (file)
@@ -693,3 +693,24 @@ SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h ORDER BY 1
 ------+--------+------
 (0 rows)
 
+------------------------------------------
+-- from tablesample
+select pct, count(unique1) from
+  (values (0),(100)) v(pct),
+  lateral (select * from tenk1 tablesample bernoulli (pct)) ss
+  group by pct;
+ pct | count 
+-----+-------
+ 100 | 10000
+(1 row)
+
+select pct, count(unique1) from
+  (values (0),(100)) v(pct),
+  lateral (select * from tenk1 tablesample system (pct)) ss
+  group by pct;
+ pct | count 
+-----+-------
+ 100 | 10000
+(1 row)
+
+------------------------------------------
index 7b3eb9bedf7bb3a82ccd127a65bb1382e10a415b..fbf75369c170e8273383ad572296643462848b58 100644 (file)
@@ -36,8 +36,32 @@ FETCH NEXT FROM tablesample_cur;
 CLOSE tablesample_cur;
 END;
 
-EXPLAIN SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (10);
-EXPLAIN SELECT * FROM test_tablesample_v1;
+EXPLAIN (COSTS OFF)
+  SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (2);
+EXPLAIN (COSTS OFF)
+  SELECT * FROM test_tablesample_v1;
+
+-- check inheritance behavior
+explain (costs off)
+  select count(*) from person tablesample bernoulli (100);
+select count(*) from person tablesample bernoulli (100);
+select count(*) from person;
+
+-- check that collations get assigned within the tablesample arguments
+SELECT count(*) FROM test_tablesample TABLESAMPLE bernoulli (('1'::text < '0'::text)::int);
+
+-- check behavior during rescans, as well as correct handling of min/max pct
+select * from
+  (values (0),(100)) v(pct),
+  lateral (select count(*) from tenk1 tablesample bernoulli (pct)) ss;
+select * from
+  (values (0),(100)) v(pct),
+  lateral (select count(*) from tenk1 tablesample system (pct)) ss;
+explain (costs off)
+select pct, count(unique1) from
+  (values (0),(100)) v(pct),
+  lateral (select * from tenk1 tablesample bernoulli (pct)) ss
+  group by pct;
 
 -- errors
 SELECT id FROM test_tablesample TABLESAMPLE FOOBAR (1);
index 5afcf1272e32c638785a0bf6174c5a416cbeaf73..d1fa0519df79836061cff64be058359ce405b9d2 100644 (file)
@@ -255,3 +255,19 @@ SELECT name(equipment(ROW('skywalking', 'mer')));
 SELECT *, name(equipment(h.*)) FROM hobbies_r h ORDER BY 1,2,3;
 
 SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h ORDER BY 1,2,3;
+
+------------------------------------------
+
+-- from tablesample
+
+select pct, count(unique1) from
+  (values (0),(100)) v(pct),
+  lateral (select * from tenk1 tablesample bernoulli (pct)) ss
+  group by pct;
+
+select pct, count(unique1) from
+  (values (0),(100)) v(pct),
+  lateral (select * from tenk1 tablesample system (pct)) ss
+  group by pct;
+
+------------------------------------------