]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Create TOAST table for partitions made by MERGE/SPLIT PARTITION
authorAlexander Korotkov <akorotkov@postgresql.org>
Thu, 18 Jun 2026 07:30:14 +0000 (10:30 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Thu, 18 Jun 2026 07:30:14 +0000 (10:30 +0300)
commitff8bec8c460a13bedbb416d8697f4675a0709ce8
treeb89e171e981df9a0fef817030e890ed31d9f7f02
parent29fb598b9cad898ef851b9a7704f980218057562
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>
src/backend/commands/tablecmds.c
src/test/regress/expected/partition_merge.out
src/test/regress/expected/partition_split.out
src/test/regress/sql/partition_merge.sql
src/test/regress/sql/partition_split.sql