agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Create TOAST table for partitions made by MERGE/SPLIT PARTITION
Date: Thu, 18 Jun 2026 07:30:29 +0000
Message-ID: <E1wa7Cm-000q78-2f@gemulon.postgresql.org> (raw)

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>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ff8bec8c460a13bedbb416d8697f4675a0709ce8

Modified Files
--------------
src/backend/commands/tablecmds.c              |  9 ++++++++
src/test/regress/expected/partition_merge.out | 26 +++++++++++++++++++++++
src/test/regress/expected/partition_split.out | 30 +++++++++++++++++++++++++++
src/test/regress/sql/partition_merge.sql      | 17 +++++++++++++++
src/test/regress/sql/partition_split.sql      | 19 +++++++++++++++++
5 files changed, 101 insertions(+)



Message-ID: <E1wa7Cm-000q78-2f@gemulon.postgresql.org>
Permalink:  ../E1wa7Cm-000q78-2f@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wa7Cm-000q78-2f@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Create TOAST table for partitions made by MERGE/SPLIT PARTITION
  In-Reply-To: <E1wa7Cm-000q78-2f@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox