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.96) (envelope-from ) id 1vXDeT-004UYv-00 for pgsql-hackers@arkaria.postgresql.org; Sun, 21 Dec 2025 07:14:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vXDeQ-00BNJN-2z for pgsql-hackers@arkaria.postgresql.org; Sun, 21 Dec 2025 07:14:47 +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.96) (envelope-from ) id 1vXDeQ-00BNJF-13 for pgsql-hackers@lists.postgresql.org; Sun, 21 Dec 2025 07:14:47 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vXDeP-001mD6-18 for pgsql-hackers@lists.postgresql.org; Sun, 21 Dec 2025 07:14:45 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-b804646c718so183932866b.2 for ; Sat, 20 Dec 2025 23:14:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766301282; x=1766906082; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=BusSBMeN9KHGOMbenNSwxSTJIIFRCqf8pAyvqTbS9S0=; b=FdNYB5Dy5hnGcMTc6x9uadv44oG+nITMqZxL82uW0NMds8eBVIO3uWJV4CCWIz/lCH 7Yvr2CF29gWTAMry/Nq9zYxoP+Nk764xKLa9jFm+acqwvS9vx48D3HVhvF73k6UcMwSL ZTMMC072WyvrTm6X7e81sJKyrX5YrfM+QOMNZ8NlIDgWh2P9ApDeLlI98qupRGcxDIHe NZhZEOjVEVbNRQ2MjG3ggpniKUzXbH5z+uOEGIUM1ZCm/QJoqUqB6UP5N7PPK6BHsajs IJV1t89jwA4n2fAad8A+4QefyKT9B1EtcM9Cf8rbQlPYhNa+nPpyy4+SzSlYXPO47kQQ SDcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766301282; x=1766906082; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BusSBMeN9KHGOMbenNSwxSTJIIFRCqf8pAyvqTbS9S0=; b=Is1N1bc6UnfUIGtjbE6t1Q2T2hkdmacHP7apbycwKfB1cR3+sllz+6h4RZAZQXMfJR k1sqvaoNASawqHXh/BXe7GDdRrToqgvDYB4iUr8Fh28k0n3TfxgscBnEfPuJGvsnFKJ4 sMXWGoy2j9mSSycTop58LPUiw5m8s3dS21g16VVM1n+c0CPACUUTx1PRHLDGJQK16UWg eolU1cacYbdUyY9u5keHwKcdukmDm2wcNCBFonUgkQQWsvVpHuiIETg54S6YpeG6JbT9 UfLaR00Cb6w00H1godDle3LRJUB3caaI9J0t//m1geJfl85dmXPHOcGR2HVK+UwN8Xyx h1wA== X-Gm-Message-State: AOJu0Yy7FHUFyS2C4gFwdIdeorLonYlYNYeQkOJHW0LddAsHxzICqN7X lQQ9ekQWas4FmrygU1ooSQQdZp9Zb81gbLbqdKAseJApZzV7dimI9NIAWK4gRzFFG7HUh/c4C+9 QDozyfx5INZcQ3bXLx6D92A+OC9cT/yg= X-Gm-Gg: AY/fxX57Kzvz2p8psodV51/dxfYi6jmUc2A74nrB9qH7RzTQ1CWX/ZnaGUOm5p2Q/pE KCwARW1ofuu7ThxLn+Ffgnq2rxgpR41sejzuE1NCJfbk5O+uSHFY8GCXUU33vlOOF+8UdHX0VHI BNIjnbrdEec8ltcALyBojUmIIxRt0XI0x9eUdCQjArNmGabGp8eHixH/mh+AvbrVt4VmhSre5Xq fy0bGiX5t/+BqKIPHxuH30t30ubKAP2CixemTUk1vjp1JPd2rhsM2IQVSoDHNvwyyp2xqpunO1P Nx4= X-Google-Smtp-Source: AGHT+IGJo12MSLU0thR6Za6BxIouAfz6XEUu4JxhLgMGzBvrmB/rfmonGwLnNzhIxY+BOD7U+TLHpP52us/w/O2Uh3g= X-Received: by 2002:a17:907:968d:b0:b7f:fa99:2cde with SMTP id a640c23a62f3a-b8037153916mr797827166b.40.1766301281528; Sat, 20 Dec 2025 23:14:41 -0800 (PST) MIME-Version: 1.0 References: <171085360143.2046436.7217841141682511557.pgcf@coridan.postgresql.org> <2643645f-2a02-43de-9321-c995ab1b7ef8@postgrespro.ru> <57a94d8a-d7b6-4c5e-9001-be1cd403b172@postgrespro.ru> <54414932-9E82-47AA-902B-2DED18F07F64@gmail.com> <3280c458-a886-4c58-8e2b-4d220b73161d@postgrespro.ru> <09414bf8-9326-431c-9422-b13bddf5f554@postgrespro.ru> <29ff27f5-d359-4479-b11c-ce28e525d806@postgrespro.ru> In-Reply-To: From: Tender Wang Date: Sun, 21 Dec 2025 15:14:01 +0800 X-Gm-Features: AQt7F2oQG6w6qtAgaCjyu82b0BCGRZdsNOD-gnVTZLsKBBfEAXQGVQJP2cwRxvU Message-ID: Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands To: Alexander Korotkov Cc: PostgreSQL Hackers Content-Type: multipart/mixed; boundary="00000000000073e38f0646711078" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000073e38f0646711078 Content-Type: multipart/alternative; boundary="00000000000073e38e0646711076" --00000000000073e38e0646711076 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Alexander Korotkov =E4=BA=8E2025=E5=B9=B412=E6=9C=88= 20=E6=97=A5=E5=91=A8=E5=85=AD 19:08=E5=86=99=E9=81=93=EF=BC=9A > Hi Tender, > > On Sat, Dec 20, 2025 at 5:18=E2=80=AFAM Tender Wang = wrote: > > I found this feature merged; thanks for this work. > > I tested it and found that one place in the error errcode may need to b= e > changed. > > In checkPartition(): > > ... > > if (get_partition_parent(partRelOid, false) !=3D RelationGetRelid(rel)) > > ereport(ERROR, > > errcode(ERRCODE_UNDEFINED_TABLE), > > errmsg("relation \"%s\" is not a partition of relation \"%s\"", > > ... > > > > ERRCODE_UNDEFINED_TABLE usually means "table does not exist." > > When entering here, the table should exist, otherwise table_open() > already reports an error. > > I found another two errcode in checkPartition() use > ERRCODE_WRONG_OBJECT_TYPE, > > In the attached patch, I replace ERRCODE_UNDEFINED_TABLE with > ERRCODE_WRONG_OBJECT_TYPE. > > I agree with you that ERRCODE_UNDEFINED_TABLE is certainly wrong error > code because the table actually exists. ERRCODE_WRONG_OBJECT_TYPE is > better. For example, we throw it when trying to attach a partition to > non-partitioned table. So, the parent table type is wrong. However, > are objects in the situation under consideration really have wrong > type? The problem is that one table is not partition of another. > However, it's possibly that they could be attached without changing of > their types. So, I think about > ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE. What do you think? > It's ok for me. Please check the v2 patch. --=20 Thanks, Tender Wang --00000000000073e38e0646711076 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Alexander Korot= kov <aekorotkov@gmail.com>= ; =E4=BA=8E2025=E5=B9=B412=E6=9C=8820=E6=97=A5=E5=91=A8=E5=85=AD 19:08=E5= =86=99=E9=81=93=EF=BC=9A
Hi Tender,

On Sat, Dec 20, 2025 at 5:18=E2=80=AFAM Tender Wang <tndrwang@gmail.com> wrote:
> I found this feature merged; thanks for this work.
> I tested it and found that one place in the error errcode may need to = be changed.
> In checkPartition():
> ...
> if (get_partition_parent(partRelOid, false) !=3D RelationGetRelid(rel)= )
>=C2=A0 =C2=A0 =C2=A0ereport(ERROR,
>=C2=A0 =C2=A0 =C2=A0errcode(ERRCODE_UNDEFINED_TABLE),
>=C2=A0 =C2=A0 =C2=A0errmsg("relation \"%s\" is not a par= tition of relation \"%s\"",
> ...
>
> ERRCODE_UNDEFINED_TABLE usually means "table does not exist."= ;
> When entering here, the table should exist, otherwise table_open() alr= eady reports an error.
> I found another two errcode in checkPartition() use ERRCODE_WRONG_OBJE= CT_TYPE,
> In the attached patch, I replace ERRCODE_UNDEFINED_TABLE with ERRCODE_= WRONG_OBJECT_TYPE.

I agree with you that ERRCODE_UNDEFINED_TABLE is certainly wrong error
code because the table actually exists.=C2=A0 ERRCODE_WRONG_OBJECT_TYPE is<= br> better.=C2=A0 For example, we throw it when trying to attach a partition to=
non-partitioned table.=C2=A0 So, the parent table type is wrong.=C2=A0 Howe= ver,
are objects in the situation under consideration really have wrong
type?=C2=A0 The problem is that one table is not partition of another.
However, it's possibly that they could be attached without changing of<= br> their types.=C2=A0 So, I think about
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE.=C2=A0 What do you think?

It's ok for me. Please check the v2 patch.= =C2=A0

-- =
Thanks,
Tender Wang
--00000000000073e38e0646711076-- --00000000000073e38f0646711078 Content-Type: text/plain; charset="US-ASCII"; name="v2-0001-Adjust-errcode-in-checkPartition.patch" Content-Disposition: attachment; filename="v2-0001-Adjust-errcode-in-checkPartition.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_mjfe5h7n0 RnJvbSA0OTJjNTk1Y2Y0ODFjNjdlYjJiNDgyM2FlM2UzODlkMGE2ZmI3ZjgzIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBUZW5kZXIgV2FuZyA8dG5kcndhbmdAZ21haWwuY29tPgpEYXRl OiBTYXQsIDIwIERlYyAyMDI1IDEwOjU2OjM2ICswODAwClN1YmplY3Q6IFtQQVRDSCB2Ml0gQWRq dXN0IGVycmNvZGUgaW4gY2hlY2tQYXJ0aXRpb24oKS4KClJlcGxhY2UgRVJSQ09ERV9VTkRFRklO RURfVEFCTEUgd2l0aCBFUlJDT0RFX09CSkVDVF9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