Assert failure in ATPrepAddPrimaryKey

Started by Richard Guoabout 3 years ago3 messageshackers
Jump to latest
#1Richard Guo
guofenglinux@gmail.com

I ran into an Assert failure in ATPrepAddPrimaryKey() with the query
below:

CREATE TABLE t0(c0 boolean);
CREATE TABLE t1() INHERITS(t0);

# ALTER TABLE t0 ADD CONSTRAINT m EXCLUDE ((1) WITH =);
server closed the connection unexpectedly

The related codes are

foreach(lc, stmt->indexParams)
{
IndexElem *elem = lfirst_node(IndexElem, lc);
Constraint *nnconstr;

Assert(elem->expr == NULL);

It seems to be introduced by b0e96f3119.

Thanks
Richard

#2Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Richard Guo (#1)
Re: Assert failure in ATPrepAddPrimaryKey

On 2023-Sep-01, Richard Guo wrote:

I ran into an Assert failure in ATPrepAddPrimaryKey() with the query
below:

CREATE TABLE t0(c0 boolean);
CREATE TABLE t1() INHERITS(t0);

# ALTER TABLE t0 ADD CONSTRAINT m EXCLUDE ((1) WITH =);
server closed the connection unexpectedly

Ugh, right, I failed to make the new function do nothing for this case;
this had no coverage. Fix attached, with some additional test cases
based on yours.

Thanks for reporting.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"XML!" Exclaimed C++. "What are you doing here? You're not a programming
language."
"Tell that to the people who use me," said XML.
https://burningbird.net/the-parable-of-the-languages/

Attachments:

0001-Only-process-inheritance-for-primary-keys-not-other-.patchtext/x-diff; charset=us-asciiDownload+47-6
#3Richard Guo
guofenglinux@gmail.com
In reply to: Alvaro Herrera (#2)
Re: Assert failure in ATPrepAddPrimaryKey

On Fri, Sep 1, 2023 at 7:48 PM Alvaro Herrera <alvherre@alvh.no-ip.org>
wrote:

On 2023-Sep-01, Richard Guo wrote:

I ran into an Assert failure in ATPrepAddPrimaryKey() with the query
below:

CREATE TABLE t0(c0 boolean);
CREATE TABLE t1() INHERITS(t0);

# ALTER TABLE t0 ADD CONSTRAINT m EXCLUDE ((1) WITH =);
server closed the connection unexpectedly

Ugh, right, I failed to make the new function do nothing for this case;
this had no coverage. Fix attached, with some additional test cases
based on yours.

Thanks for the fix!

Thanks
Richard