Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Pavel Borisov <pashkin.elfe@gmail.com>, Justin Pryzby <pryzby@telsasoft.com>, Dmitry Koval <d.koval@postgrespro.ru>, Alexander Lakhin <exclusion@gmail.com>, pgsql-hackers@lists.postgresql.org, Tomas Vondra <tomas.vondra@enterprisedb.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: 2026-06-16T08:08:39Z
Lists: pgsql-hackers
On Tue, Jun 16, 2026 at 5:37 AM Alexander Korotkov <aekorotkov@gmail.com> wrote:
>
> On Tue, Jun 16, 2026 at 12:36 AM Pavel Borisov <pashkin.elfe@gmail.com> wrote:
> > On Tue, 16 Jun 2026 at 00:50, Alexander Korotkov <aekorotkov@gmail.com> wrote:
> > >
> > > On Mon, Jun 15, 2026 at 2:07 PM Justin Pryzby <pryzby@telsasoft.com> wrote:
> > > >
> > > > I hit an error when I tried this patch.
> > > >
> > > > CREATE TABLE a (a text) PARTITION BY RANGE(a);
> > > > CREATE TABLE a1 PARTITION OF a DEFAULT;
> > > > INSERT INTO a SELECT repeat('1', 9999999);
> > > > CREATE TABLE a2 PARTITION OF a FOR VALUES FROM (2)TO(3);
> > > > ALTER TABLE a MERGE PARTITIONS (a1, a2) INTO a1;
> > > > ERROR:  row is too big: size 39264, maximum size 8160
> > >
> > > Thank you for your report.  It appears that createPartitionTable()
> > > misses NewRelationCreateToastTable() call (for instance, DefineTable()
> > > has this call).  The attached patch implements fix and has tests.  I'm
> > > going to push it if no objections.
> >
> > It looks like the patch is missing in the last message.
>

src5=# explain (analyze, timing, costs off) SELECT repeat('1', 9999999);
                     QUERY PLAN
-----------------------------------------------------
 Result (actual time=0.002..0.003 rows=1.00 loops=1)
 Planning Time: 1454.745 ms
 Execution Time: 0.035 ms
(3 rows)

Time: 1458.413 ms (00:01.458)

The timing above is from an Assert-enabled build.
Could we optimize these tests to make them less expensive to run?



--
jian
https://www.enterprisedb.com/



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. doc: clarify MERGE PARTITIONS adjacency requirement

  2. Take into account default_tablespace during MERGE/SPLIT PARTITION(S)

  3. Create TOAST table for partitions made by MERGE/SPLIT PARTITION

  4. Adjust errcode in checkPartition()

  5. Fix usage of palloc() in MERGE/SPLIT PARTITION(s) code

  6. Implement ALTER TABLE ... SPLIT PARTITION ... command

  7. Implement ALTER TABLE ... MERGE PARTITIONS ... command

  8. Calculate agglevelsup correctly when Aggref contains a CTE.

  9. Use PqMsg_* macros in applyparallelworker.c.

  10. Restrict psql meta-commands in plain-text dumps.

  11. Ensure we have a snapshot when updating various system catalogs.

  12. Use specific collation where needed in new test

  13. Expand virtual generated columns in the planner

  14. Virtual generated columns

  15. Define PG_LOGICAL_DIR for path pg_logical/ in data folder

  16. Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands

  17. Avoid repeated table name lookups in createPartitionTable()

  18. Provide deterministic order for catalog queries in partition_split.sql

  19. Don't copy extended statistics during MERGE/SPLIT partition operations

  20. Fix the name collision detection in MERGE/SPLIT partition operations

  21. Fix regression tests conflict in 3ca43dbbb6

  22. Add permission check for MERGE/SPLIT partition operations

  23. Fix one more portability shortcoming in new test_pg_dump test.

  24. Inherit parent's AM for partition MERGE/SPLIT operations

  25. Add tab completion for partition MERGE/SPLIT operations

  26. Rename tables in tests of partition MERGE/SPLIT operations

  27. Make new partitions with parent's persistence during MERGE/SPLIT

  28. Document the way partition MERGE/SPLIT operations create new partitions

  29. Change the way ATExecMergePartitions() handles the name collision

  30. Grammar fixes for split/merge partitions code

  31. Checks for ALTER TABLE ... SPLIT/MERGE PARTITIONS ... commands

  32. Fix some grammer errors from error messages and codes comments

  33. Support TZ and OF format codes in to_timestamp().

  34. Support identity columns in partitioned tables

  35. Fix indentation in twophase.c

  36. Fix corner-case planner failure for MERGE.

  37. Doc: fix documentation example for bytea hex output format.

  38. Avoid repeated name lookups during table and index DDL.