From: | Alexander Lakhin <exclusion(at)gmail(dot)com> |
---|---|
To: | Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>, Alexander Korotkov <aekorotkov(at)gmail(dot)com> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Add SPLIT PARTITION/MERGE PARTITIONS commands |
Date: | 2024-04-30 03:00:00 |
Message-ID: | 8034d1c6-5f0e-e858-9af9-45d5e246515e@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
30.04.2024 03:10, Dmitry Koval wrote:
> Hi!
>
> 1.
> 29.04.2024 21:00, Alexander Lakhin wrote:
>> I still wonder, why that constraint (now with a less questionable name) is
>> created during MERGE?
>
> The SPLIT/MERGE PARTITION(S) commands for creating partitions reuse the existing code of CREATE TABLE .. LIKE ...
> command. A new partition was created with the name "merge-16385-26BCB0-tmp" (since there was an old partition with the
> same name). The constraint "merge-16385-26BCB0-tmp_i_not_null" was created too together with the partition.
> Subsequently, the table was renamed, but the constraint was not.
> Now a new partition is immediately created with the correct name (the old partition is renamed).
Maybe I'm doing something wrong, but the following script:
CREATE TABLE t (i int, PRIMARY KEY(i)) PARTITION BY RANGE (i);
CREATE TABLE tp_0 PARTITION OF t FOR VALUES FROM (0) TO (1);
CREATE TABLE tp_1 PARTITION OF t FOR VALUES FROM (1) TO (2);
CREATE TABLE t2 (LIKE t INCLUDING ALL);
CREATE TABLE tp2 (LIKE tp_0 INCLUDING ALL);
creates tables t2, tp2 without not-null constraints.
But after
ALTER TABLE t MERGE PARTITIONS (tp_0, tp_1) INTO tp_0;
I see:
\d+ tp_0
...
Indexes:
"tp_0_pkey" PRIMARY KEY, btree (i)
Not-null constraints:
"tp_0_i_not_null" NOT NULL "i"
Best regards,
Alexander
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2024-04-30 03:15:20 | Re: pg_trgm comparison bug on cross-architecture replication due to different char implementation |
Previous Message | Jingxian Li | 2024-04-30 02:41:39 | [PATCH] Fix bug when calling strncmp in check_authmethod_valid |