Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2023-10-02T03:04:11Z
Lists: pgsql-bugs
Michael Paquier <michael@paquier.xyz> 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
Commits
-
Fix checking of index expressions in CompareIndexInfo().
- 3caedf246123 11.22 landed
- d6425987ba76 12.17 landed
- 9f71e10d65fa 17.0 landed
- 9d6d8d7049ea 14.10 landed
- 83ba050f92fa 13.13 landed
- 59371f1aeb9a 15.5 landed
- 12402b93117b 16.1 landed