File tree Expand file tree Collapse file tree 3 files changed +34
-3
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +34
-3
lines changed
Original file line number Diff line number Diff line change @@ -14247,9 +14247,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
14247
14247
trigger_name , RelationGetRelationName (attachrel )),
14248
14248
errdetail ("ROW triggers with transition tables are not supported on partitions" )));
14249
14249
14250
- /* OK to create inheritance. Rest of the checks performed there */
14251
- CreateInheritance (attachrel , rel );
14252
-
14253
14250
/*
14254
14251
* Check that the new partition's bound is valid and does not overlap any
14255
14252
* of existing partitions of the parent - note that it does not return on
@@ -14258,6 +14255,9 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
14258
14255
check_new_partition_bound (RelationGetRelationName (attachrel ), rel ,
14259
14256
cmd -> bound );
14260
14257
14258
+ /* OK to create inheritance. Rest of the checks performed there */
14259
+ CreateInheritance (attachrel , rel );
14260
+
14261
14261
/* Update the pg_class entry. */
14262
14262
StorePartitionBound (attachrel , rel , cmd -> bound );
14263
14263
Original file line number Diff line number Diff line change @@ -3960,3 +3960,18 @@ ERROR: cannot attach a temporary relation as partition of permanent relation "p
3960
3960
alter table temp_part_parent attach partition temp_part_child default; -- ok
3961
3961
drop table perm_part_parent cascade;
3962
3962
drop table temp_part_parent cascade;
3963
+ -- test case where the partitioning operator is a SQL function whose
3964
+ -- evaluation results in the table's relcache being rebuilt partway through
3965
+ -- the execution of an ATTACH PARTITION command
3966
+ create function at_test_sql_partop (int4, int4) returns int language sql
3967
+ as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$;
3968
+ create operator class at_test_sql_partop for type int4 using btree as
3969
+ operator 1 < (int4, int4), operator 2 <= (int4, int4),
3970
+ operator 3 = (int4, int4), operator 4 >= (int4, int4),
3971
+ operator 5 > (int4, int4), function 1 at_test_sql_partop(int4, int4);
3972
+ create table at_test_sql_partop (a int) partition by range (a at_test_sql_partop);
3973
+ create table at_test_sql_partop_1 (a int);
3974
+ alter table at_test_sql_partop attach partition at_test_sql_partop_1 for values from (0) to (10);
3975
+ drop table at_test_sql_partop;
3976
+ drop operator class at_test_sql_partop using btree;
3977
+ drop function at_test_sql_partop;
Original file line number Diff line number Diff line change @@ -2618,3 +2618,19 @@ alter table perm_part_parent attach partition temp_part_child default; -- error
2618
2618
alter table temp_part_parent attach partition temp_part_child default; -- ok
2619
2619
drop table perm_part_parent cascade;
2620
2620
drop table temp_part_parent cascade;
2621
+
2622
+ -- test case where the partitioning operator is a SQL function whose
2623
+ -- evaluation results in the table's relcache being rebuilt partway through
2624
+ -- the execution of an ATTACH PARTITION command
2625
+ create function at_test_sql_partop (int4, int4) returns int language sql
2626
+ as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else - 1 end; $$;
2627
+ create operator class at_test_sql_partop for type int4 using btree as
2628
+ operator 1 < (int4, int4), operator 2 <= (int4, int4),
2629
+ operator 3 = (int4, int4), operator 4 >= (int4, int4),
2630
+ operator 5 > (int4, int4), function 1 at_test_sql_partop(int4, int4);
2631
+ create table at_test_sql_partop (a int ) partition by range (a at_test_sql_partop);
2632
+ create table at_test_sql_partop_1 (a int );
2633
+ alter table at_test_sql_partop attach partition at_test_sql_partop_1 for values from (0 ) to (10 );
2634
+ drop table at_test_sql_partop;
2635
+ drop operator class at_test_sql_partop using btree;
2636
+ drop function at_test_sql_partop;
You can’t perform that action at this time.
0 commit comments