Create TOAST table for partitions made by MERGE/SPLIT PARTITION
Alexander Korotkov <akorotkov@postgresql.org>
Author:
Alexander Korotkov <akorotkov@postgresql.org>
Date: 2026-06-18T07:30:14Z
Releases:
19 (unreleased)
Create TOAST table for partitions made by MERGE/SPLIT PARTITION ALTER TABLE ... MERGE PARTITIONS / SPLIT PARTITION builds a new partition via createPartitionTable(), but never gives it a TOAST table. When the source rows carried out-of-line varlena values, the move into the new partition entered heap_toast_insert_or_update() with reltoastrelid = InvalidOid: the externalization step is skipped, the value falls back to inline storage and heap_insert() fails with "row is too big" error. Also, TOAST table is needed if the new partition receives out-of-line varlena values after the DDL operation is complete. Call NewRelationCreateToastTable() right after the new partition is created in createPartitionTable(), mirroring what DefineRelation() does for regular CREATE TABLE. NewRelationCreateToastTable() decides on its own whether a TOAST table is actually required, so partitions with no toast-eligible columns are unaffected. Reported-by: Justin Pryzby <pryzby@telsasoft.com> Discussion: https://postgr.es/m/ai_c4-v8iLA2kXFV%40pryzbyj2023 Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com> Reviewed-by: Jian He <jian.universality@gmail.com>
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/commands/tablecmds.c | modified | +9 −0 |
| src/test/regress/expected/partition_merge.out | modified | +26 −0 |
| src/test/regress/expected/partition_split.out | modified | +30 −0 |
| src/test/regress/sql/partition_merge.sql | modified | +17 −0 |
| src/test/regress/sql/partition_split.sql | modified | +19 −0 |
Discussion
- Add SPLIT PARTITION/MERGE PARTITIONS commands 298 messages · 2022-05-31 → 2026-06-30