Re: BUG #15668: Server crash in transformPartitionRangeBounds

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Amit Langote <amitlangote09(at)gmail(dot)com>, exclusion(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: BUG #15668: Server crash in transformPartitionRangeBounds
Date: 2019-03-11 06:44:39
Message-ID: ab51ec5a-b2d3-a25f-5695-7555ad63d344@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi,

On 2019/03/06 17:27, Michael Paquier wrote:
> On Wed, Mar 06, 2019 at 04:00:42PM +0900, Amit Langote wrote:
>> Thanks for looking at this. Your patch seems better, because it allows us
>> to keep the error message consistent with the message one would get with
>> list-partitioned syntax.
>
> Thanks for confirming. I think that it would be nice as well to add
> more test coverage for such error patterns with all the strategies.
> It would be good to fix that first, so I can take care of that.

I've added some tests to your patch. Also improved the comments a bit.

I noticed another issue with the code -- it's using strcmp() to compare
specified string against "minvalue" and "maxvalue", which causes the
following silly error:

create table q2 partition of q for values from ("MINVALUE") to (maxvalue);
ERROR: column "MINVALUE" does not exist
LINE 1: create table q2 partition of q for values from ("MINVALUE") ...

It should be using pg_strncasecmp().

> Now I don't really find the error "missing FROM-clause entry for
> table" quite convincing when this is applied to a partition bound when
> using a column defined in the relation. Adding more error classes in
> the set of CRERR_NO_RTE would be perhaps nice, still I am not sure how
> elegant it could be made when looking at expressions for partition
> bounds.

Note that this is not just a problem for partition bounds. You can see it
with default expressions too.

create table foo (a int default (aa.a));
ERROR: missing FROM-clause entry for table "aa"
LINE 1: create table foo (a int default (aa.a));

create table foo (a int default (a.a.aa.a.a.a.a.aa));
ERROR: improper qualified name (too many dotted names): a.a.aa.a.a.a.a.aa
LINE 1: create table foo (a int default (a.a.aa.a.a.a.a.aa));

We could make the error message more meaningful depending on the context,
but maybe it'd better be pursue it as a separate project.

Thanks,
Amit

Attachment Content-Type Size
partition-bound-crash-v2.patch text/plain 8.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message lichuancheng@highgo.com 2019-03-11 06:52:50 Re: Re: BUG #15567: Wal receiver process restart failed when a damaged wal record arrived at standby.
Previous Message Amit Langote 2019-03-11 05:04:03 Re: BUG #15677: Crash while deleting from partitioned table

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-03-11 07:21:14 Re: BUG #15668: Server crash in transformPartitionRangeBounds
Previous Message Masahiko Sawada 2019-03-11 06:23:53 Re: A separate table level option to control compression