Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index
Date
Msg-id ZRoxY3X1tGZRZQ2A@paquier.xyz
Whole thread Raw
In response to Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Sat, Sep 30, 2023 at 08:39:37PM -0400, Tom Lane wrote:
> 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.

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?
--
Michael

Attachment

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #18134: ROW_COUNT do not set to 0 when psql's \gset command get no rows returned
Next
From: Tom Lane
Date:
Subject: Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index