Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index
Date: 2023-10-01 00:39:37
Message-ID: 1614549.1696120777@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Michael Paquier <michael(at)paquier(dot)xyz> 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

In response to

Responses

Browse pgsql-bugs by date

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