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 1w9d4Z-001bGQ-1k for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 06:04:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9d4Y-006p1H-0I for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 06:04:30 +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 1w9d4X-006p17-1j for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 06:04:30 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w9d4V-00000000oAO-3P3S for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 06:04:29 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-66ec3b7b1deso1225100a12.2 for ; Sun, 05 Apr 2026 23:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775455466; cv=none; d=google.com; s=arc-20240605; b=hwZVcY44eFijuP3PBDnZF+WAimdkZTP0SPgXW1jqykNMGfHKh0EBj5wa/56kGZNwgD 2w/Llk/Fj+Sv6c7UEmCY1SXTEPtnP9uFMrsYbEnulBwLkjfNFVOQYfFHPoRiCXvOZ40M q22m159niOImegiAYKgUcbJIq/xFqju5NXTr1kZy7ROJpvfj4a7cawHjKV/GstqjB5R8 KzE7t1E57JDyY8owbwf3TOZBIGtSBAFhJh8Q8SRXtVqebUgQlK3wW7jiMiC8o9aRT166 k1a4d0BNOjyEkR7T9jG42A8QKxsmBl9K6ZgyYx8ta2/umfnqBbZExayxO+I5ZmgMB0js I5wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=22QHIIqYYJtWBkiUanu6XbhlEbRoCIdSS5onhQj0Dxs=; fh=API7pHFvHz//VzzmsjMiZjVU2agzigd09gVcY4RidXg=; b=XA0H2NZCWSx/Is4B7ms5aMNeF1V4rq62TePGusR26xuhi/Q9gGvUs1P4bJfkEzNuOe AcDqOt31E8sUAqkokQbG34Yk4nAZ6Fb5Tk8Qj8t2FZlFEeXqzhyfSsQeLOGzwHCbmCAb GTnK1QDRdzD3rQmWQhhyaOGco26lpvoR3bV0jaaTwpN/X/lzCnyX+oAozbdf7+/3QQSO IFS7sps5wHYGYwzCOya1/ThghrrE6NW+Lr2vUoXiyv6SPRL55JcGZSGSbpS3KYcEEFs0 KyZ8Ofum6W0IA9ok9DxpMss6fGrQxEvi4iIOwQHCm+sGiyWM3Vao6k0YCSEW2pMx9nO+ SHgQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775455466; x=1776060266; 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=22QHIIqYYJtWBkiUanu6XbhlEbRoCIdSS5onhQj0Dxs=; b=j1t6eS1ZgbqfrXjHMA5q+vK/1jaL++zb1TkHQ3aQWsLYVbJnMwT4tICMXCUEnXUU42 Ngu+S2SXQYqOBhOq9554iTwsQ7xFaqz8JZikUPfceFP2ELy6LY+zGL+jt8JyAR83d/ve jeoaQqrxyAio9KlrjXbSbqUZf2BRlLBDtnhlwhb0PprcKuawJlhCSd/q0MG5TltMfS7A sKUk8yHSAMJhq1lreOXhB3Unscb3CQ0+hF4fwoMVE8DvXoFj5cJZQ4yBYA3Ri/3RKrqy bD7z4e6uKLMWMgVOTlIYCHGwk5Zr+6FhTWJYor2/WVBnq3sdv+7KsmL5SVmFQ46J0B6N 9DGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775455466; x=1776060266; h=content-transfer-encoding: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=22QHIIqYYJtWBkiUanu6XbhlEbRoCIdSS5onhQj0Dxs=; b=PQZnrFuBoVzVYx/KQbw2Ay6uCi2fa85NZhMQCNu1/R0GmEngmO8Wm8j7l1gwNaqBx+ 5aDCMYsw2b/DycDdcFLAtddBHd4dCPTCD71PpCplqMqWSkWBIM/Bo96ZSkA4wZIfGgw4 ++ZSZ8z0jyXbSnDn5C/CAL5BPey8a5eek9h/dbN5Jad4587bdyPs1GGCjl7jJQlXppef ZvRd9lBwwdNe7JkcQR5G94W+2qXoaUvfigL6tkJNs+MDw+PeOkRKzDAa/z+4wWv9SU8T bvgVyD3Ii325HbiFbW6zXNvXwiQa7spnEVpxejyaBcP9fYifqOPJZ/WFs3PryGriT0oA btyQ== X-Gm-Message-State: AOJu0YzSrPvJ+ykvImDCaFSNu8upzwLLCT7YdXBxaKcZMZ4ULL8aNQmT RBhQzM7GqCyeN5IFTPyEJxBqdzP1vkzqsUp9ZssQx5Gg/wOqF1IcDmBNfoTRD7LZD7dgWU3RjXs YQai3Yxq2SIqY7w/pe6w1eosiGGSYQq0= X-Gm-Gg: AeBDiesRmcud+6cEgj7bYtLwFw3QXHHHBHNSt1Lr3yxbGnCtDJvjWpoNbSR/NUresLu 0hfLRu3XBkc/jA/ZSZ96t66VCqXJq+6A5m5/uxFwYlxNSmS6uuXJ8sS1vAGrxoBZ62jCjSWxYxi ThXx+dQcO6NfbQ+PmoEotiaRT3sMicObuxCFjOpS9GMycRP3j8O07/WEkHhyn2VsP/OI0WN1v0o WmEp+L/BQFv1dzS3q/oYF2ZMJjIgcELLOm3XdO/E+wr/9IX14eiZrRJKV4Ml8T/IcFzD8JMGa5s jl2sJFogfq4rlB+WMCKfWQdzb9U5Ix2ljLuuniXc7BICEdrT6WZnI1Ur1sMBgjwATff6yf2aMY6 E+bEM2StN X-Received: by 2002:a17:907:a44:b0:b9b:207c:f7b7 with SMTP id a640c23a62f3a-b9c6768d2e2mr567115266b.3.1775455466026; Sun, 05 Apr 2026 23:04:26 -0700 (PDT) MIME-Version: 1.0 References: <0B38B9DC-A53C-437C-B9BD-807F30A032BA@gmail.com> <424A3799-D7FD-4691-BD10-6CBDACB14938@gmail.com> <43825F3D-6156-4030-B5E1-9A0841969022@gmail.com> <260E4616-43B7-4C24-BF53-352DC8DEB7AA@gmail.com> <8F791DCB-0307-4A8C-B5AF-1EF0CF678AC2@gmail.com> In-Reply-To: <8F791DCB-0307-4A8C-B5AF-1EF0CF678AC2@gmail.com> From: Xuneng Zhou Date: Mon, 6 Apr 2026 14:04:14 +0800 X-Gm-Features: AQROBzBiW9HX2yr9SNZTixC16oMWbc6jyDW1B0T1ApQpMx1OBrNmL50mw0vj-kI Message-ID: Subject: Re: tablecmds: fix bug where index rebuild loses replica identity on partitions To: Chao Li Cc: Postgres hackers 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, Mar 24, 2026 at 3:26=E2=80=AFPM Chao Li wr= ote: > > > > > On Mar 23, 2026, at 16:41, Xuneng Zhou wrote: > > > > Hi, > > > > On Mon, Mar 23, 2026 at 3:57=E2=80=AFPM Chao Li wrote: > > > > > > > > > > > > > On Mar 21, 2026, at 18:29, Xuneng Zhou wrote= : > > > > > > > > On Thu, Mar 19, 2026 at 1:07=E2=80=AFPM Chao Li wrote: > > > >> > > > >> > > > >> > > > >>> On Feb 26, 2026, at 14:59, Chao Li wrote= : > > > >>> > > > >>> > > > >>> > > > >>>> On Jan 28, 2026, at 10:49, Chao Li wrot= e: > > > >>>> > > > >>>> > > > >>>> > > > >>>>> On Jan 27, 2026, at 16:30, Chao Li wro= te: > > > >>>>> > > > >>>>> > > > >>>>> > > > >>>>>> On Jan 27, 2026, at 15:59, Chao Li wr= ote: > > > >>>>>> > > > >>>>>> > > > >>>>>> > > > >>>>>>> On Jan 27, 2026, at 15:39, Michael Paquier wrote: > > > >>>>>>> > > > >>>>>>> On Tue, Jan 27, 2026 at 01:13:32PM +0800, Chao Li wrote: > > > >>>>>>>> I found this bug while working on a related patch [1]. > > > >>>>>>>> > > > >>>>>>>> When ALTER TABLE ... ALTER COLUMN TYPE causes an index rebui= ld, and > > > >>>>>>>> that index is used as REPLICA IDENTITY on a partitioned tabl= e, the > > > >>>>>>>> replica identity marking on partitions can be silently lost = after the > > > >>>>>>>> rebuild. > > > >>>>>>> > > > >>>>>>> I am slightly confused by the tests included in the proposed = patch. > > > >>>>>>> On HEAD, if I undo the proposed changes of tablecmds.c, the t= ests > > > >>>>>>> pass. If I run the tests of the patch with the changes of > > > >>>>>>> tablecmds.c, the tests also pass. > > > >>>>>> > > > >>>>>> Oops, that isn=E2=80=99t supposed to be so. I=E2=80=99ll check= the test. > > > >>>>>> > > > >>>>> > > > >>>>> Okay, I see the problem is here: > > > >>>>> ``` > > > >>>>> +CREATE UNIQUE INDEX test_replica_identity_partitioned_pkey ON = test_replica_identity_partitioned (id); > > > >>>>> ``` > > > >>>>> > > > >>>>> I missed to add column =E2=80=9Cval=E2=80=9D into the index, so= that alter type of val didn=E2=80=99t cause index rebuild. > > > >>>>> > > > >>>>> Ideally, it=E2=80=99s better to also verify that index OIDs sho= uld have changed before and after alter column type, but I haven=E2=80=99t = figured out how to do so. Do you have an idea? > > > >>>> > > > >>>> I just updated the test to store index OIDs before and after reb= uild into 2 temp tables, so that we can compare the OIDs to verify rebuild = happens and replica identity preserved. > > > >>>> > > > >>>> I tried to port the test to master branch, and the test failed. =