summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRobert Haas2017-02-24 06:51:46 +0000
committerRobert Haas2017-02-24 06:53:28 +0000
commit5dbdb2f799232cb1b6df7d7a85d59ade3234d30c (patch)
tree6ee90ab65f715022e61707733df02656d8da932e /src/test
parent6d493e1a013514a6f0abb5d30d08219c1831cfec (diff)
Make tablesample work with partitioned tables.
This was an oversight in the original partitioning commit. Amit Langote, reviewed by David Fetter Discussion: http://postgr.es/m/59af6590-8ace-04c4-c36c-ea35d435c60e@lab.ntt.co.jp
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/tablesample.out18
-rw-r--r--src/test/regress/sql/tablesample.sql8
2 files changed, 26 insertions, 0 deletions
diff --git a/src/test/regress/expected/tablesample.out b/src/test/regress/expected/tablesample.out
index 7e91b958aea..b18e420e9b5 100644
--- a/src/test/regress/expected/tablesample.out
+++ b/src/test/regress/expected/tablesample.out
@@ -313,3 +313,21 @@ SELECT q.* FROM (SELECT * FROM test_tablesample) as q TABLESAMPLE BERNOULLI (5);
ERROR: syntax error at or near "TABLESAMPLE"
LINE 1: ...CT q.* FROM (SELECT * FROM test_tablesample) as q TABLESAMPL...
^
+-- check partitioned tables support tablesample
+create table parted_sample (a int) partition by list (a);
+create table parted_sample_1 partition of parted_sample for values in (1);
+create table parted_sample_2 partition of parted_sample for values in (2);
+explain (costs off)
+ select * from parted_sample tablesample bernoulli (100);
+ QUERY PLAN
+-------------------------------------------
+ Append
+ -> Sample Scan on parted_sample
+ Sampling: bernoulli ('100'::real)
+ -> Sample Scan on parted_sample_1
+ Sampling: bernoulli ('100'::real)
+ -> Sample Scan on parted_sample_2
+ Sampling: bernoulli ('100'::real)
+(7 rows)
+
+drop table parted_sample, parted_sample_1, parted_sample_2;
diff --git a/src/test/regress/sql/tablesample.sql b/src/test/regress/sql/tablesample.sql
index eec97934966..c39fe4b7509 100644
--- a/src/test/regress/sql/tablesample.sql
+++ b/src/test/regress/sql/tablesample.sql
@@ -100,3 +100,11 @@ WITH query_select AS (SELECT * FROM test_tablesample)
SELECT * FROM query_select TABLESAMPLE BERNOULLI (5.5) REPEATABLE (1);
SELECT q.* FROM (SELECT * FROM test_tablesample) as q TABLESAMPLE BERNOULLI (5);
+
+-- check partitioned tables support tablesample
+create table parted_sample (a int) partition by list (a);
+create table parted_sample_1 partition of parted_sample for values in (1);
+create table parted_sample_2 partition of parted_sample for values in (2);
+explain (costs off)
+ select * from parted_sample tablesample bernoulli (100);
+drop table parted_sample, parted_sample_1, parted_sample_2;