From: | Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru> |
---|---|
To: | Junwang Zhao <zhjwpku(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Add SPLIT PARTITION/MERGE PARTITIONS commands |
Date: | 2025-06-11 13:10:00 |
Message-ID: | 26fe1a14-89aa-415d-a1b1-176526e54d3b@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi, Junwang Zhao!
Thank you for note.
1.
>Would it be better to use RELATION_IS_OTHER_TEMP in this case?
>I noticed that while other parts of tablecmds.c don’t use the macro,
>all other files consistently use RELATION_IS_OTHER_TEMP.
Agreed, RELATION_IS_OTHER_TEMP is better. Changed.
The fix will be in the next patch.
2.
>+/*
>+* We intended to create the partition with the same persistence as the
>+* parent table, but we still need to recheck because that might be
>+* affected by the search_path. If the parent is permanent, so must be
>+* all of its partitions.
>+*/
>I have trouble understanding how this is possible, can you kindly
>give me some guidance on this logic?
Perhaps this is best explained with an example.
(see src/test/regress/sql/partition_merge.sql).
(a) Create permanent table "t":
SET search_path = partitions_merge_schema, pg_temp, public;
CREATE TABLE t (i int) PARTITION BY RANGE (i);
CREATE TABLE tp_0_1 PARTITION OF t FOR VALUES FROM (0) TO (1);
CREATE TABLE tp_1_2 PARTITION OF t FOR VALUES FROM (1) TO (2);
(b) Attempt to merge persistent partitions tp_0_1, tp_1_2 into
temporary partition tp_0_2:
SET search_path = pg_temp, partitions_merge_schema, public;
-- Can't merge persistent partitions into a temporary partition
ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2;
(c) "ALTER TABLE ... MERGE PARTITIONS ..." will return an error:
ERROR: cannot create a temporary relation as partition of permanent
relation "t"
--
With best regards,
Dmitry Koval
Postgres Professional: http://postgrespro.com
From | Date | Subject | |
---|---|---|---|
Next Message | Yura Sokolov | 2025-06-11 13:12:39 | Re: Add 64-bit XIDs into PostgreSQL 15 |
Previous Message | Sami Imseih | 2025-06-11 13:00:59 | Re: [PATCH] Re: Proposal to Enable/Disable Index using ALTER INDEX |