Crash when partition column specified twice

Started by Amit Langotealmost 9 years ago5 messageshackers
Jump to latest
#1Amit Langote
Langote_Amit_f8@lab.ntt.co.jp

Noticed that a crash occurs if a column is specified twice when creating a
partition:

create table p (a int) partition by list (a);

-- crashes
create table p1 partition of parent (
a not null,
a default 1
) for values in (1);

The logic in MergeAttributes() that merged partition column options with
those of the parent didn't properly check for column being specified twice
and instead tried to delete the same ColumnDef from a list twice, causing
the crash.

Attached fixes that.

Added to the open items list.

Thanks,
Amit

Attachments:

0001-Fix-crash-when-partition-column-specified-twice.patchtext/x-diff; name=0001-Fix-crash-when-partition-column-specified-twice.patchDownload+45-6
#2Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
In reply to: Amit Langote (#1)
Re: Crash when partition column specified twice

On 2017/04/27 12:36, Amit Langote wrote:

Noticed that a crash occurs if a column is specified twice when creating a
partition:

create table p (a int) partition by list (a);

-- crashes
create table p1 partition of parent (
a not null,
a default 1
) for values in (1);

The logic in MergeAttributes() that merged partition column options with
those of the parent didn't properly check for column being specified twice
and instead tried to delete the same ColumnDef from a list twice, causing
the crash.

Attached fixes that.

Patch rebased, because of a conflict with b9a3ef55b2.

Thanks,
Amit

Attachments:

0001-Fix-crash-when-partition-column-specified-twice.patchtext/x-diff; name=0001-Fix-crash-when-partition-column-specified-twice.patchDownload+45-6
#3Beena Emerson
memissemerson@gmail.com
In reply to: Amit Langote (#2)
Re: Crash when partition column specified twice

Hello Amit,

The extra n->is_from_type = false; seems to be added by mistake?

@@ -11888,6 +11891,8 @@ TableFuncElement:   ColId Typename
opt_collate_clause
                    n->is_local = true;
                    n->is_not_null = false;
                    n->is_from_type = false;
+                   n->is_from_type = false;
+                   n->is_from_parent = false;
                    n->storage = 0;
                    n->raw_default = NULL;
                    n->cooked_default = NULL;

On Fri, Apr 28, 2017 at 6:08 AM, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp

wrote:

On 2017/04/27 12:36, Amit Langote wrote:

Noticed that a crash occurs if a column is specified twice when creating

a

partition:

create table p (a int) partition by list (a);

-- crashes
create table p1 partition of parent (
a not null,
a default 1
) for values in (1);

The logic in MergeAttributes() that merged partition column options with
those of the parent didn't properly check for column being specified

twice

and instead tried to delete the same ColumnDef from a list twice, causing
the crash.

Attached fixes that.

Patch rebased, because of a conflict with b9a3ef55b2.

Thanks,
Amit

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--

Beena Emerson

EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#4Robert Haas
robertmhaas@gmail.com
In reply to: Beena Emerson (#3)
Re: Crash when partition column specified twice

On Fri, Apr 28, 2017 at 7:23 AM, Beena Emerson <memissemerson@gmail.com> wrote:

Hello Amit,

The extra n->is_from_type = false; seems to be added by mistake?

@@ -11888,6 +11891,8 @@ TableFuncElement:   ColId Typename
opt_collate_clause
n->is_local = true;
n->is_not_null = false;
n->is_from_type = false;
+                   n->is_from_type = false;
+                   n->is_from_parent = false;
n->storage = 0;
n->raw_default = NULL;
n->cooked_default = NULL;

Good catch. Committed after fixing that issue.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
In reply to: Robert Haas (#4)
Re: Crash when partition column specified twice

On 2017/04/29 2:53, Robert Haas wrote:

On Fri, Apr 28, 2017 at 7:23 AM, Beena Emerson <memissemerson@gmail.com> wrote:

Hello Amit,

The extra n->is_from_type = false; seems to be added by mistake?

@@ -11888,6 +11891,8 @@ TableFuncElement:   ColId Typename
opt_collate_clause
n->is_local = true;
n->is_not_null = false;
n->is_from_type = false;
+                   n->is_from_type = false;
+                   n->is_from_parent = false;
n->storage = 0;
n->raw_default = NULL;
n->cooked_default = NULL;

Good catch. Committed after fixing that issue.

Thanks both.

Regards,
Amit

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers