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: exclusion(at)gmail(dot)com
Cc: 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-09-28 17:31:39
Message-ID: 1043711.1695922299@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> The function CompareIndexInfo() contains the code:
> /* ignore expressions at this stage */
> if ((info1->ii_IndexAttrNumbers[i] != InvalidAttrNumber) &&
> (attmap->attnums[info2->ii_IndexAttrNumbers[i] - 1] !=
> info1->ii_IndexAttrNumbers[i]))
> return false;

> where info1->ii_IndexAttrNumbers[i] is checked for InvalidAttrNumber
> (i. e. it's not an expression), but info2->ii_IndexAttrNumbers[i] is not.

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.

regards, tom lane

Attachment Content-Type Size
fix-CompareIndexInfo.patch text/x-diff 1.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-09-28 18:50:05 Re: BUG #18139: Causing FATAL error on database using function last() or first()
Previous Message PG Bug reporting form 2023-09-28 17:02:51 BUG #18139: Causing FATAL error on database using function last() or first()