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 1qmkVp-008nLM-Ib for pgsql-bugs@arkaria.postgresql.org; Sun, 01 Oct 2023 00:40:45 +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 1qmkVn-00HWO9-Px for pgsql-bugs@arkaria.postgresql.org; Sun, 01 Oct 2023 00:40:43 +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 1qmkVn-00HWNB-GR for pgsql-bugs@lists.postgresql.org; Sun, 01 Oct 2023 00:40:43 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qmkVj-007X0u-L7 for pgsql-bugs@lists.postgresql.org; Sun, 01 Oct 2023 00:40:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3910db6C1614550; Sat, 30 Sep 2023 20:39:37 -0400 From: Tom Lane To: Michael Paquier cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index In-reply-to: References: <18135-532f4a755e71e4d2@postgresql.org> <1043711.1695922299@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Sun, 01 Oct 2023 09:31:39 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1614548.1696120777.1@sss.pgh.pa.us> Date: Sat, 30 Sep 2023 20:39:37 -0400 Message-ID: <1614549.1696120777@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > I can see that this has already been committed as 9f71e10d65, but are > you sure that this is correct? I didn't take the time to reply back, > because I got the feeling that even what I proposed is not correct. > The previous code was careful enough to look at the information from > info2 only *through* the attribute map, which is not what this new > code is doing. Rather than looking directly at the elements in info2 > at each iteration, shouldn't this stuff loop over the elements in > attmap->attnums for each info1->ii_IndexAttrNumbers[i]? I think it's OK as is. What we are comparing in the modified logic is whether index columns at the same column positions are expressions or not, and that's not a matter for mapping. Once we've verified that the current column is a non-expression in both indexes, then it's appropriate to use the attmap to see whether the columns correspond. (Or to put it another way: running "column zero" through the attmap is always the wrong thing.) regards, tom lane