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 1qmkOB-008n46-VD for pgsql-bugs@arkaria.postgresql.org; Sun, 01 Oct 2023 00:32:52 +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 1qmkNB-00HOe4-Cx for pgsql-bugs@arkaria.postgresql.org; Sun, 01 Oct 2023 00:31:49 +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 1qmkNA-00HOas-9i for pgsql-bugs@lists.postgresql.org; Sun, 01 Oct 2023 00:31:49 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qmkN7-007WpF-FV for pgsql-bugs@lists.postgresql.org; Sun, 01 Oct 2023 00:31:47 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 0BD925C0151; Sat, 30 Sep 2023 20:31:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 30 Sep 2023 20:31:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1696120304; x=1696206704; bh=D4 A6Vs2/ZRgN+/zw6bKX8V5ewIJ/yeX0e/2v6lZfhK0=; b=LvSBxxWVP0TkpJjpAX TkI7a6cWUe70uMLUDP7stW8HwJYwChV3Mkq9iEZilpy4I5WzTD29MxE2oo8Lqp9M //gNUi6EP50QlrAuccoYcXoLRP61DBzWb56/M/alhw9ysMJvamk8kYr8a1/DOHWO e3Xdaq0baEY/gktrQ7QE0GiXzd2Fpa31NN3tTfTEZn3Aa0dQvywwtorythEkFqgb As0auXE4ty15OxiDlADbV5+rX6REjV+bS/C/YIZ83Hd7O66lnh4lOFW2U0cBMrBO 5ILWd7enC5rJmdVG7m07jkAHDGp4mX1wzhp5xlZsqAB+acbnEvtENddPMpaxoGTf CUZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1696120304; x=1696206704; bh=D4A6Vs2/ZRgN+ /zw6bKX8V5ewIJ/yeX0e/2v6lZfhK0=; b=YmLWASba/QUwTLYBuuKeuwry3IydA Pg5XKWuxDRq+nAS5PhbflQLxCnvT5JDOHPz0lJz32vloDvaeqwOkIBqWopBjc90A fGHonDc9l+IfPjUzEaeH1AzR1YIkj0oMZPi7ZhrAAyRn9bJ4K7wFHwQVgYdkgzdu bDFJqsfL8ckNwEiW/i+EhsbPp0xQYW29nZ1oXHIxcDPDNEMZ/fieabnVCzM+rDsu lkO3EM7vVIZnhWKRI/o3u+YuydM0o7P4oWwUKkqFl7gYfIZWzTqXNwSELGMxdkFm T7okJLt23FiyRBbM6HlFqmHJKsdyBj32O+rRxzRD/4NJ5Wx3RFHir/aKQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehgddtfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvf evuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrh hnpeetleeifedufffhhfdtteelgeeggeffhfekueevteeigfduudevudetgfegiedvjeen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthh grvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 30 Sep 2023 20:31:42 -0400 (EDT) Date: Sun, 1 Oct 2023 09:31:39 +0900 From: Michael Paquier To: Tom Lane Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index Message-ID: References: <18135-532f4a755e71e4d2@postgresql.org> <1043711.1695922299@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="P+kJnpnCtTxqIV0g" Content-Disposition: inline In-Reply-To: <1043711.1695922299@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --P+kJnpnCtTxqIV0g Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 28, 2023 at 01:31:39PM -0400, Tom Lane wrote: > Agreed, that's pretty broken, and it's not just that it risks an > invalid access. I don't think this reliably rejects cases where > one index has an expression and the other doesn't. Even if it does > work, it's way too complicated to convince oneself that that's > rejected. I think for clarity we should code it as attached. - /* ignore expressions at this stage */ - if ((info1->ii_IndexAttrNumbers[i] != InvalidAttrNumber) && - (attmap->attnums[info2->ii_IndexAttrNumbers[i] - 1] != - info1->ii_IndexAttrNumbers[i])) - return false; + /* ignore expressions for now (but check their collation/opfamily) */ + if (!(info1->ii_IndexAttrNumbers[i] == InvalidAttrNumber && + info2->ii_IndexAttrNumbers[i] == InvalidAttrNumber)) + { + /* fail if just one index has an expression in this column */ + if (info1->ii_IndexAttrNumbers[i] == InvalidAttrNumber || + info2->ii_IndexAttrNumbers[i] == InvalidAttrNumber) + return false; 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]? -- Michael --P+kJnpnCtTxqIV0g Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmUYvesACgkQnvQgOdby QH2trxAAiU/hJOnZLtkCmXhFeoBgwgrDQa5UFackkO7CivLzBk7WAZVKps4MbZpV 4CzN8/iB4lmrHoKeQg7WM28JUQIN0gv1UFfT03en050ot6SbcoD82yj2rz39k3rW lpu7fTzuOaObSfVw4mSJy/KOCQD/hYJknRkgtsOXjxzOtRWSQDk05AQfPLV7KFHl fGzl8o5v2wt3XQ0JE2U0TehAaYokUWVGj1vQNtdmaRhpw+GvdjHNkL/h4FO/SooO xeNbYCWpU02rHRN2Q1LZZp5oc6lQ3QEJfyJw//RsIleTwBfPiZLMt++Ih334kVAy R7Ds86naxHSb0Xz5H5JV0e+zqAQvOI5qtbfAcMc766ejGfbJb3se3a9kN207P1Jg 7Xuq5v4lr90LTWsJzvMfg7lpQlb8XBKSioiEyRf2o2b9vERH6brAeEclH2RKk04o 7a9BL2qNQCkplGTfPy6JeQOUdxEwcPpvbq3VMnRzq4vFdZYO6TGPlCUOpXX7B0da hyDN+NYcqJPODmWNL6Jaj2k13HaW2wYFa86DeAMsNgt9lEnn6iOruvx4IVxAABgC rkG5ARQ/CbSkWNTY+85Gx4wIRy5atRkNibkWqJUkIbgNn8Q/wWtEhryUWedou2+A bceuM+jTlLflLKjwOpGaySXJjZfQJ5XfWvbYnLwX+pimutzAEH0= =V1nh -----END PGP SIGNATURE----- --P+kJnpnCtTxqIV0g--