Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uPLDX-005UVM-DN for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jun 2025 13:10:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uPLDV-002rsW-FT for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jun 2025 13:10:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uPLDV-002rsO-5T for pgsql-hackers@lists.postgresql.org; Wed, 11 Jun 2025 13:10:09 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uPLDS-001Qu1-1c for pgsql-hackers@lists.postgresql.org; Wed, 11 Jun 2025 13:10:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1749647403; bh=5pR4Whb7hrwJZojgMC5R76moVub9OQYa+dCYVsNjurI=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=26oZT9iVObo8uHFKLLqCk6TiywwugBOtykBog+szA+U47sL7hYyTt92klYGrASVXM CsbhEo4npMVlp2IaFyu2lBfe6/iaRC73rMxLZ9Gj3iwOkPOs7D7l7HMMQkjhMa7gjw 1TSXi39b2rglScl8+Dyojah6Uk1lOiHmuuWOCUmlWdyrjPrHsxVK1aSlWBBDdk4SqR eWj6dO8P/0+pyc9MCcXk0Z7ZpepY2OseauKIgHyK5Zsfru4fH/ZF/3wj0+J4DRAtyO bLjJ6W3KbSkEwBnBjDLmq1cb6VLiuDgOz4KgHnAd1tai1t0X2KnmZ1E5hf5t+F7+fL wQLNqb0elsNhg== Received: from [172.30.50.150] (unknown [93.174.131.138]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: d.koval@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id C256B602FF; Wed, 11 Jun 2025 16:10:02 +0300 (MSK) Message-ID: <26fe1a14-89aa-415d-a1b1-176526e54d3b@postgrespro.ru> Date: Wed, 11 Jun 2025 16:10:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands To: Junwang Zhao Cc: pgsql-hackers@lists.postgresql.org References: <171085360143.2046436.7217841141682511557.pgcf@coridan.postgresql.org> <4e2764f7-f6be-478f-8d7f-f921dbd10f5f@postgrespro.ru> <7fdaf3e8-4c05-4739-bee6-98acc068d1c7@postgrespro.ru> <4433b492-9e97-4334-96d9-ddaaa5083099@postgrespro.ru> <67ecf5fb-e63d-4284-be75-d0479eef81aa@postgrespro.ru> <884bcf9e-d6e3-4b0c-8dcb-7f2110070ac9@postgrespro.ru> Content-Language: en-US From: Dmitry Koval In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed X-KSMG-AntiPhishing: NotDetected, bases: 2025/06/11 12:15:00 X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/06/11 12:24:00 #27558864 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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=E2=80=99t use the m= acro, >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 =3D 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 =3D 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=20 relation "t" --=20 With best regards, Dmitry Koval Postgres Professional: http://postgrespro.com