]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix SPLIT PARTITION hint for DEFAULT partition bounds
authorAlexander Korotkov <akorotkov@postgresql.org>
Tue, 19 May 2026 10:39:39 +0000 (13:39 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Tue, 19 May 2026 10:54:55 +0000 (13:54 +0300)
When ALTER TABLE ... SPLIT PARTITION specifies a DEFAULT partition, the
explicit partitions do not need to cover the split partition's bound
exactly.  They may cover only part of it, with the DEFAULT partition
covering the remaining range.

However, the existing hint said that the combined bounds of the new
partitions must exactly match the bound of the split partition, which is
misleading for this case and inconsistent with the code comment.

Fix the hint to state the actual requirement: explicit partition bounds
must stay within the bounds of the split partition when a DEFAULT
partition is specified.

Author: Chao Li <lic@highgo.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/C18878AB-DEB2-4A61-9995-A035DD644B81@gmail.com

src/backend/partitioning/partbounds.c
src/test/regress/expected/partition_split.out

index 73dea0375be0ffce7c8cb4ce96f0a645ed5636d8..7d3580cbc10c2c14dd718cad0f6b894b43a7145c 100644 (file)
@@ -5405,7 +5405,7 @@ check_partition_bounds_for_split_range(Relation parent,
                                                        errmsg("lower bound of partition \"%s\" is not equal to lower bound of split partition \"%s\"",
                                                                   relname,
                                                                   get_rel_name(splitPartOid)),
-                                                       errhint("%s require combined bounds of new partitions must exactly match the bound of the split partition.",
+                                                       errhint("%s requires the combined bounds of the new partitions to exactly match the bound of the split partition.",
                                                                        "ALTER TABLE ... SPLIT PARTITION"),
                                                        parser_errposition(pstate, exprLocation((Node *) datum)));
                        }
@@ -5415,8 +5415,7 @@ check_partition_bounds_for_split_range(Relation parent,
                                                errmsg("lower bound of partition \"%s\" is less than lower bound of split partition \"%s\"",
                                                           relname,
                                                           get_rel_name(splitPartOid)),
-                                               errhint("%s require combined bounds of new partitions must exactly match the bound of the split partition.",
-                                                               "ALTER TABLE ... SPLIT PARTITION"),
+                                               errhint("Explicit partition bounds must be contained within the bounds of the split partition when a DEFAULT partition is specified."),
                                                parser_errposition(pstate, exprLocation((Node *) datum)));
                }
 
@@ -5448,7 +5447,7 @@ check_partition_bounds_for_split_range(Relation parent,
                                                        errmsg("upper bound of partition \"%s\" is not equal to upper bound of split partition \"%s\"",
                                                                   relname,
                                                                   get_rel_name(splitPartOid)),
-                                                       errhint("%s require combined bounds of new partitions must exactly match the bound of the split partition.",
+                                                       errhint("%s requires the combined bounds of the new partitions to exactly match the bound of the split partition.",
                                                                        "ALTER TABLE ... SPLIT PARTITION"),
                                                        parser_errposition(pstate, exprLocation((Node *) datum)));
                        }
@@ -5458,8 +5457,7 @@ check_partition_bounds_for_split_range(Relation parent,
                                                errmsg("upper bound of partition \"%s\" is greater than upper bound of split partition \"%s\"",
                                                           relname,
                                                           get_rel_name(splitPartOid)),
-                                               errhint("%s require combined bounds of new partitions must exactly match the bound of the split partition.",
-                                                               "ALTER TABLE ... SPLIT PARTITION"),
+                                               errhint("Explicit partition bounds must be contained within the bounds of the split partition when a DEFAULT partition is specified."),
                                                parser_errposition(pstate, exprLocation((Node *) datum)));
                }
        }
@@ -5654,7 +5652,7 @@ check_parent_values_in_new_partitions(Relation parent,
                                errmsg("new partitions' combined partition bounds do not contain value (%s) but split partition \"%s\" does",
                                           "NULL",
                                           get_rel_name(partOid)),
-                               errhint("%s require combined bounds of new partitions must exactly match the bound of the split partition.",
+                               errhint("%s requires the combined bounds of the new partitions to exactly match the bound of the split partition.",
                                                "ALTER TABLE ... SPLIT PARTITION"));
 
        /*
@@ -5697,7 +5695,7 @@ check_parent_values_in_new_partitions(Relation parent,
                                errmsg("new partitions' combined partition bounds do not contain value (%s) but split partition \"%s\" does",
                                           deparse_expression((Node *) notFoundVal, NIL, false, false),
                                           get_rel_name(partOid)),
-                               errhint("%s require combined bounds of new partitions must exactly match the bound of the split partition.",
+                               errhint("%s requires the combined bounds of the new partitions to exactly match the bound of the split partition.",
                                                "ALTER TABLE ... SPLIT PARTITION"));
        }
 }
index a2ccbe5138be371264c486ee0900c3c7539e1bd5..2b9a6aa50edce09fcb2e4429be775381f3ccdeb9 100644 (file)
@@ -56,7 +56,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO
 ERROR:  lower bound of partition "sales_feb2022" is not equal to lower bound of split partition "sales_feb_mar_apr2022"
 LINE 2:   (PARTITION sales_feb2022 FOR VALUES FROM ('2022-01-01') TO...
                                                     ^
-HINT:  ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition.
+HINT:  ALTER TABLE ... SPLIT PARTITION requires the combined bounds of the new partitions to exactly match the bound of the split partition.
 -- ERROR
 -- (We can create partition with the same name as split partition, but can't create two partitions with the same name)
 ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO
@@ -97,7 +97,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO
 ERROR:  upper bound of partition "sales_apr2022" is not equal to upper bound of split partition "sales_feb_mar_apr2022"
 LINE 4: ... sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-06-0...
                                                              ^
-HINT:  ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition.
+HINT:  ALTER TABLE ... SPLIT PARTITION requires the combined bounds of the new partitions to exactly match the bound of the split partition.
 -- ERROR
 ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO
   (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'),
@@ -118,7 +118,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO
 ERROR:  lower bound of partition "sales_feb2022" is not equal to lower bound of split partition "sales_feb_mar_apr2022"
 LINE 2:   (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-02') TO...
                                                     ^
-HINT:  ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition.
+HINT:  ALTER TABLE ... SPLIT PARTITION requires the combined bounds of the new partitions to exactly match the bound of the split partition.
 -- Check the source partition not in the search path
 SET search_path = partition_split_schema2, public;
 ALTER TABLE partition_split_schema.sales_range
@@ -154,7 +154,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO
 ERROR:  upper bound of partition "sales_apr2022" is not equal to upper bound of split partition "sales_feb_mar_apr2022"
 LINE 4: ... sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-06-0...
                                                              ^
-HINT:  ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition.
+HINT:  ALTER TABLE ... SPLIT PARTITION requires the combined bounds of the new partitions to exactly match the bound of the split partition.
 DROP TABLE sales_range;
 --
 -- Add rows into partitioned table then split partition
@@ -917,14 +917,14 @@ ALTER TABLE sales_list SPLIT PARTITION sales_all INTO
    PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'),
    PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', 'Kyiv'));
 ERROR:  new partitions' combined partition bounds do not contain value (NULL) but split partition "sales_all" does
-HINT:  ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition.
+HINT:  ALTER TABLE ... SPLIT PARTITION requires the combined bounds of the new partitions to exactly match the bound of the split partition.
 -- ERROR
 ALTER TABLE sales_list SPLIT PARTITION sales_all INTO
   (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'),
    PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'),
    PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', NULL));
 ERROR:  new partitions' combined partition bounds do not contain value ('Kyiv'::character varying(20)) but split partition "sales_all" does
-HINT:  ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition.
+HINT:  ALTER TABLE ... SPLIT PARTITION requires the combined bounds of the new partitions to exactly match the bound of the split partition.
 -- ERROR
 ALTER TABLE sales_list SPLIT PARTITION sales_all INTO
   (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'),
@@ -1201,7 +1201,7 @@ ALTER TABLE t SPLIT PARTITION tp_0_51 INTO
 ERROR:  upper bound of partition "tp_0_51" is greater than upper bound of split partition "tp_0_51"
 LINE 2:   (PARTITION tp_0_51 FOR VALUES FROM (0) TO (53),
                                                      ^
-HINT:  ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition.
+HINT:  Explicit partition bounds must be contained within the bounds of the split partition when a DEFAULT partition is specified.
 DROP TABLE t;
 --
 -- Try to SPLIT partition of another table.