Re: MERGE/SPLIT PARTITIONS issues/questions

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: MERGE/SPLIT PARTITIONS issues/questions
Date: 2026-08-06 03:45:22
Message-ID: CACJufxEpBFLJMfSw1oOG8+yYRN=7G1Ue2zFZwFh7U9JLk0kqNQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Thu, Aug 6, 2026 at 1:02 AM Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
>
> Actually, this makes me uneasy. What about restricting SPLIT/MERGE to
> the case when generated columns matching between source partitions and
> parent. This is the only solution I consider appropriate at this
> stage of development.
>

drop table if exists x;
CREATE TABLE x (id int, g int GENERATED ALWAYS AS (NULLIF(tableoid,
18470)) NOT NULL) partition by range(id);
CREATE TABLE x1 PARTITION OF x FOR VALUES FROM (10) TO (20);
CREATE TABLE x2 PARTITION OF x FOR VALUES FROM (20) TO (30);
ALTER TABLE x MERGE PARTITIONS (x1, x2) INTO x12;

It's possible that the new table x12's tableoid is 18470, and
MergePartitionsMoveRows, checkPartitionRowConstraints did nothing
about it.
So at the end of checkPartitionGenExprMatchesParent,
we can use expression_references_system_column(generation_expr) to
guard against such corner case, regardless of the generated column
kind.

Please check the attached diff to address this issue.

expression_references_system_column is a useful helper function that
can be reused in multiple places, so I also added its declaration.
In our context, we can use it in createTableConstraints, which is
better than pull_varattnos i think.
I also did pgindent on tablecmds.c

(I didn't review v2-0001, v2-0002).

Attachment Content-Type Size
v2-0001-misc-fix-for-Don-t-recalculate-generated-columns-during-MERGE-S.nocfbot application/octet-stream 14.6 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2026-08-06 05:43:38 Re: BUG #19608: Error while Reindexing Main Table
Previous Message John Naylor 2026-08-05 22:43:54 Re: BUG #19609: Server crashes when executing a JIT-compiled SQL function on s390x

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-08-06 03:46:28 Re: [PATCH] Release replication slot on error in SQL-callable slot functions
Previous Message Chao Li 2026-08-06 03:40:05 Re: Optimize UUID parse using SIMD