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 1vEcOB-00EJyZ-Rd for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Oct 2025 23:49:07 +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 1vEcOA-00BBCZ-MZ for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Oct 2025 23:49:05 +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 1vEcOA-00BBCR-Cn for pgsql-hackers@lists.postgresql.org; Thu, 30 Oct 2025 23:49:05 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vEcO7-004dtg-2W for pgsql-hackers@lists.postgresql.org; Thu, 30 Oct 2025 23:49:04 +0000 Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-430abca3354so14718545ab.2 for ; Thu, 30 Oct 2025 16:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761868143; x=1762472943; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UPPOCEx7ZK7plzUVvVJmhgWj/jRp3ZIVdlql3vb5Q2Y=; b=Bjk4OwzT2V+QVsAO4e/Vn81pILs3swZkGfI7DC8dAepncIyYXF8hquMNW32W2LFWFu X+Kes8xSnGBL+atGZN5s1hXsjY0xZl7XZeWKghAUQk0RR4FsDSDR2nptTQX5CuqyYq4k x5WMsMil/HRIzYJOizDxSENp2A7jp1XJjlmwW3x5cHZkgRYWrJcukbrxV+jubeH4RJ+y jzeahNhM7GhHSgUwpesPXTiA1BEANzQu2yRcQuw3Q7EFcAdLQd5SKFXdXYHzrpsuNz4a Mb/qO/ntP13BKfm7r/6zCw6JctBvvbp5xbwx0JNdnnP6LKAiXw0l3cSocHcUaNxNrIzX CMCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761868143; x=1762472943; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UPPOCEx7ZK7plzUVvVJmhgWj/jRp3ZIVdlql3vb5Q2Y=; b=AKBnrlsCWka7RGXy9UXICBL8fgDFmHB+C67X9scND7Pz5jfPsQESTCRntHE4bJY7Bn 8BWnsZ3A9ZVEA7HRvC661+d+7pRayvNhQyxt4KIbcbufJqbO65vjeoPrR/0tS17a7x8v z/+cx1bCMQ6Aef6WBWGvxSVXePneu5B3oxqx9HxNV5xbBhy46qZJynU8NEANG9Zfu3VV ukMZ9RnYfy43qx76kdNtvvpMvqJnQxmW8zdnGpR36ObmPNE1LRuufsaLkyg9ke9Wtbec 2fmcD8AChnoR9CRqIvk/Fnk1BiI6MJbkRAcHKoYjRZTRv8fKhJ5JW4RJOr3VP7RQxFFK YcTw== X-Gm-Message-State: AOJu0Yz/x0aH5YBd/0yzOVwCPYbrGO4g5ONC8Ul2j8vUoOoXI9AMaUdB nzAL6FQzOE+DU/RnfQI/4hd9dS6AqJps2m3gLcZBmhUfsPM/GwVfjmbXo/oP4/njckUGS9uhO0l j8oIhhxMp9NblPP4mmcxq1GH2BE7BCw1QbKS3u1nfwA== X-Gm-Gg: ASbGncvn9TsMncSKDrw5lUFlpI+RXGRjv/dcRnDs3o2HyyCVpddK10Fd+uX2RQFBCeR ZnXczdz6YipPzCgK7TZ2ETizqUTzB8sMSIscPXvDw4S+PtiThHZryx+KaRECgRaMXVv4ookcKdT 9Ky7RVUY2gl/5iaQsnujj70NaOp3xLdA1Q+HdbUYvPanVzAKfvFTkR3FKtdRCutBnK3bRulY24e Az3RkUHoq6fMSTu7u7pw0glKh76lacaT2VF4fUYpF9DAXNWs0e+akSAyPQGKlBih/2CfYMSKCae sjNA4z7m6GsUn41AiSABLzVZzmUOh78lK4MRAQ3QkkwsAuhT21pSmR0fBC5+FAqpaiw0Ww== X-Google-Smtp-Source: AGHT+IEtEgkqCZzox30Ku3okdw0UINY5ezpfFTRRt6Sf4Z7GqH9lVzSDa9nM4zI5qyfAQnxMW715dxhpokT/N847GQg= X-Received: by 2002:a92:c245:0:b0:430:cf19:e682 with SMTP id e9e14a558f8ab-4330d12d50dmr31661205ab.13.1761868142892; Thu, 30 Oct 2025 16:49:02 -0700 (PDT) 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> In-Reply-To: From: Alexander Korotkov Date: Fri, 31 Oct 2025 01:48:50 +0200 X-Gm-Features: AWmQ_bmAmC4vhf8Os8QdVzAe3REtIz--Z5ctxRdhGlcCvNfXP7mzzyDGbgwWgiE Message-ID: Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands To: Dmitry Koval Cc: pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Oct 28, 2025 at 1:12=E2=80=AFAM Dmitry Koval wrote: > 1. > > The second CommandCounterIncrement() is needed to make the renamed > > relation visible within our transaction. Why do we need the first > >one? I see tests pass without it. > > It's strange. If I comment the first "CommandCounterIncrement();", in blo= ck > ----------------------------------------------------------------------- > /* > * We must bump the command counter to make the split partition tuple > * visible for renaming. > */ > CommandCounterIncrement(); > /* Rename partition. */ > sprintf(tmpRelName, "split-%u-%X-tmp", RelationGetRelid(rel), ...); > RenameRelationInternal(splitRelOid, tmpRelName, true, false); > /* > * We must bump the command counter to make the split partition tuple > * visible after renaming. > */ > CommandCounterIncrement(); > ----------------------------------------------------------------------- > , I got the error "ERROR: tuple already updated by self" in the > partition_split.sql test (Ubuntu). If I comment the second > "CommandCounterIncrement();", I got the error "ERROR: relation > "sales_others" already exists" in the same test. Sorry, actually it fails. It appears that the first CommandCounterIncrement() is needed to see the result of detachPartitionTable(). > 2. > >The branch handling null value in the outer loop, uses null2 flag from > >the inner loop. I think for the null value of the outer loop we still > >need to run inner loop to search for the matching null value. > > This code looks a little confusing, but it probably works correctly. > This can be verified using two typical examples: > ----------------------------------------------------------------------- > list1: (NULL, 1) > list2: (2, NULL) > > (1) isnull1 =3D true, (2) "if (isnull1) lappend(NULL)" > ----------------------------------------------------------------------- > list1: (1, NULL) > list2: (NULL, 2) > > (1) isnull2 =3D true, (2) "if (isnull2) lappend(NULL)" > ----------------------------------------------------------------------- > In both cases, we return from the function immediately after lappend. > This works because we need to find exactly one repeating value. How this function could handle this case? list1: (NULL) list2: whatever containing NULL The outer loop will just quit after iterating the only element of list1 without even iterating list2. ------ Regards, Alexander Korotkov Supabase