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 1qn9EL-009xKu-JG for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Oct 2023 03:04:21 +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 1qn9EJ-00GMMx-VT for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Oct 2023 03:04:19 +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 1qn9EJ-00GMMp-MT for pgsql-bugs@lists.postgresql.org; Mon, 02 Oct 2023 03:04:19 +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 1qn9EC-007i62-VC for pgsql-bugs@lists.postgresql.org; Mon, 02 Oct 2023 03:04:18 +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 39234BUm1914032; Sun, 1 Oct 2023 23:04:11 -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> <1614549.1696120777@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Mon, 02 Oct 2023 11:56:35 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1914030.1696215851.1@sss.pgh.pa.us> Date: Sun, 01 Oct 2023 23:04:11 -0400 Message-ID: <1914031.1696215851@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > FWIW, I was thinking about a case like that with 2 index attributes: > info1->attr[0] = 0, info1->attr[1] = 1 > info2->attr[0] = 1, info2->attr[1] = 0 > With a mapping from info2 to info1 like that: > attmap[0] = 1, attmap[1] = 0. > The code before 9f71e10d6 would have accessed an incorrect pointer. > The new code would return false, which would not be correct if the > expressions stored in ii_Expressions for info1/attr0 and info2/attr1 > match? I think "false" is correct. Otherwise you're claiming that an index on (expr, col1) is equivalent to an index on (col1, expr). Maybe it is equivalent for some purposes, but I don't think this function has any business assuming that it is so for all purposes. Also, the pre-existing comment clearly intends that false is the proper result here: * might differ!) Note that this implies that index columns that are * expressions appear in the same positions. We will next compare the * expressions themselves. The code just failed to enforce that fully. regards, tom lane