summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRobert Haas2017-04-12 15:13:44 +0000
committerRobert Haas2017-04-12 15:35:11 +0000
commit1d5fede4a900d135745c1fa5a70dcfe0b3359e3d (patch)
tree620b3a368e148c593da95dd2bbed8f63656c723a /src/test
parentb935eb7da37254a18c48acc7b07517c8dfbb2339 (diff)
Code review for c94e6942cefe7d20c5feed856e27f672734b1e2b.
validateCheckConstraint() shouldn't try to access the storage for a partitioned table, because it no longer has any. Creating a _RETURN table on a partitioned table shouldn't be allowed, both because there's no value in it and because trying to do so would involve a validation scan against its nonexistent storage. Amit Langote, reviewed by Tom Lane. Regression test outputs updated to pass by me. Discussion: http://postgr.es/m/e5c3cbd3-1551-d6f8-c9e2-51777d632fd2@lab.ntt.co.jp
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/alter_table.out6
-rw-r--r--src/test/regress/expected/rules.out5
-rw-r--r--src/test/regress/sql/alter_table.sql7
-rw-r--r--src/test/regress/sql/rules.sql5
4 files changed, 23 insertions, 0 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 2227f2d9770..883a5c9864f 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -3372,3 +3372,9 @@ ERROR: partition constraint is violated by some row
-- cleanup
drop table p;
drop table p1;
+-- validate constraint on partitioned tables should only scan leaf partitions
+create table parted_validate_test (a int) partition by list (a);
+create table parted_validate_test_1 partition of parted_validate_test for values in (0, 1);
+alter table parted_validate_test add constraint parted_validate_test_chka check (a > 0) not valid;
+alter table parted_validate_test validate constraint parted_validate_test_chka;
+drop table parted_validate_test;
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index f55c8c47eb5..b2779d9698a 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -2574,6 +2574,11 @@ select reltoastrelid, relkind, relfrozenxid
(1 row)
drop view fooview;
+-- trying to convert a partitioned table to view is not allowed
+create table fooview (x int, y text) partition by list (x);
+create rule "_RETURN" as on select to fooview do instead
+ select 1 as x, 'aaa'::text as y;
+ERROR: could not convert partitioned table "fooview" to a view
--
-- check for planner problems with complex inherited UPDATES
--
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 8cd6786a90a..eb1b4b536ff 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -2228,3 +2228,10 @@ alter table p attach partition p1 for values from (1, 2) to (1, 10);
-- cleanup
drop table p;
drop table p1;
+
+-- validate constraint on partitioned tables should only scan leaf partitions
+create table parted_validate_test (a int) partition by list (a);
+create table parted_validate_test_1 partition of parted_validate_test for values in (0, 1);
+alter table parted_validate_test add constraint parted_validate_test_chka check (a > 0) not valid;
+alter table parted_validate_test validate constraint parted_validate_test_chka;
+drop table parted_validate_test;
diff --git a/src/test/regress/sql/rules.sql b/src/test/regress/sql/rules.sql
index d4a61813e44..4fff2662163 100644
--- a/src/test/regress/sql/rules.sql
+++ b/src/test/regress/sql/rules.sql
@@ -898,6 +898,11 @@ select reltoastrelid, relkind, relfrozenxid
drop view fooview;
+-- trying to convert a partitioned table to view is not allowed
+create table fooview (x int, y text) partition by list (x);
+create rule "_RETURN" as on select to fooview do instead
+ select 1 as x, 'aaa'::text as y;
+
--
-- check for planner problems with complex inherited UPDATES
--