aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2018-10-08 00:06:54 +0900
committerMichael Paquier <michael@paquier.xyz>2018-10-08 00:06:54 +0900
commitafe9b9e68afb93b6831a939a7a18973ee5286d68 (patch)
treee6c3f9076f6dacf305c5d4c880634848eda5d796 /src
parent101b21ead356023c0b86d28dac3d6c08828c77b5 (diff)
downloadpostgresql-afe9b9e68afb93b6831a939a7a18973ee5286d68.tar.gz
postgresql-afe9b9e68afb93b6831a939a7a18973ee5286d68.zip
Add regression test for ATTACH PARTITION
This test case uses a SQL function as partitioning operator, whose evaluation results in the table's relcache being rebuilt partway through the execution of an ATTACH PARTITION command. It is extracted from 39808e8, which fixed a bug where this test case failed on master and REL_11_STABLE, but passed on REL_10_STABLE. The partitioning code has changed a lot during v11 development, so this makes sure that any patch applied to REL_10_STABLE fixing a partition-related bug does not break it again. Author: Amit Langote Reviewed-by: Michaël Paquier, Álvaro Herrera Discussion: https://postgr.es/m/CAKcux6=nTz9KSfTr_6Z2mpzLJ_09JN-rK6=dWic6gGyTSWueyQ@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/test/regress/expected/alter_table.out15
-rw-r--r--src/test/regress/sql/alter_table.sql16
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 86127ce0df9..bd3f918e482 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -3669,3 +3669,18 @@ alter table temp_part_parent attach partition temp_part_child
for values in (1, 2); -- ok
drop table perm_part_parent cascade;
drop table temp_part_parent cascade;
+-- test case where the partitioning operator is a SQL function whose
+-- evaluation results in the table's relcache being rebuilt partway through
+-- the execution of an ATTACH PARTITION command
+create function at_test_sql_partop (int4, int4) returns int language sql
+as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$;
+create operator class at_test_sql_partop for type int4 using btree as
+ operator 1 < (int4, int4), operator 2 <= (int4, int4),
+ operator 3 = (int4, int4), operator 4 >= (int4, int4),
+ operator 5 > (int4, int4), function 1 at_test_sql_partop(int4, int4);
+create table at_test_sql_partop (a int) partition by range (a at_test_sql_partop);
+create table at_test_sql_partop_1 (a int);
+alter table at_test_sql_partop attach partition at_test_sql_partop_1 for values from (0) to (10);
+drop table at_test_sql_partop;
+drop operator class at_test_sql_partop using btree;
+drop function at_test_sql_partop;
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 519d984fd9f..24b60f9b6e2 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -2388,3 +2388,19 @@ alter table temp_part_parent attach partition temp_part_child
for values in (1, 2); -- ok
drop table perm_part_parent cascade;
drop table temp_part_parent cascade;
+
+-- test case where the partitioning operator is a SQL function whose
+-- evaluation results in the table's relcache being rebuilt partway through
+-- the execution of an ATTACH PARTITION command
+create function at_test_sql_partop (int4, int4) returns int language sql
+as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$;
+create operator class at_test_sql_partop for type int4 using btree as
+ operator 1 < (int4, int4), operator 2 <= (int4, int4),
+ operator 3 = (int4, int4), operator 4 >= (int4, int4),
+ operator 5 > (int4, int4), function 1 at_test_sql_partop(int4, int4);
+create table at_test_sql_partop (a int) partition by range (a at_test_sql_partop);
+create table at_test_sql_partop_1 (a int);
+alter table at_test_sql_partop attach partition at_test_sql_partop_1 for values from (0) to (10);
+drop table at_test_sql_partop;
+drop operator class at_test_sql_partop using btree;
+drop function at_test_sql_partop;