pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Amit Langote <amitlangote09@gmail.com>
Cc: Alexander Lakhin <exclusion@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Subject: Re: BUG #15668: Server crash in transformPartitionRangeBounds
Date: Wed, 13 Mar 2019 13:08:01 +0900
Message-ID: <1f9aaa7a-43d4-43ae-e270-14dbca926167@lab.ntt.co.jp> (raw)
In-Reply-To: <7846.1552408520@sss.pgh.pa.us>
References: <15668-0377b1981aa1a393@postgresql.org>
	<CA+HiwqEGoa485g18mt9GUdF8fH4mKDgpeoc32XiW-dRUFpN5Lw@mail.gmail.com>
	<20190306064825.GH30982@paquier.xyz>
	<6ed2c24c-2f73-fa1c-0ed1-ed3597f13d0d@lab.ntt.co.jp>
	<20190306082730.GJ30982@paquier.xyz>
	<ab51ec5a-b2d3-a25f-5695-7555ad63d344@lab.ntt.co.jp>
	<CA+TgmoY7UWpd-01_vwhQ62yivvnvmFM=6BQq-G-HJzzwvCed9g@mail.gmail.com>
	<7846.1552408520@sss.pgh.pa.us>

On 2019/03/13 1:35, Tom Lane wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>> On Mon, Mar 11, 2019 at 2:45 AM Amit Langote
>> <Langote_Amit_f8@lab.ntt.co.jp> wrote:
>>> 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().
> 
>> Uh, why?  Generally, an unquoted keyword is equivalent to a quoted
>> lowercase version of that same keyword, not anything else.  Like
>> CREATE TABLE "foo" = CREATE TABLE FOO <> CREATE TABLE "FOO".

OK.  Perhaps, I reacted too strongly to encountering the following
behavior with HEAD:

create table p1 partition of p for values from ("minValue") to (1);
ERROR:  column "minValue" does not exist

but,

create table p1 partition of p for values from ("minvalue") to (1);
\d p1
                 Table "public.p1"
 Column │  Type   │ Collation │ Nullable │ Default
────────┼─────────┼───────────┼──────────┼─────────
 a      │ integer │           │          │
Partition of: p FOR VALUES FROM (MINVALUE) TO (1)

But as you and Tom have pointed out, maybe it's normal.

> Yeah.  The behavior shown above is entirely correct, and accepting the
> statement would be flat out wrong; it would cause trouble if somebody
> created a table containing multiple case-variations of MINVALUE.

Sorry, I didn't understand this last part.  Different case-variations will
all be interpreted as a minvalue (negative infinity) range bound and
flagged if the resulting range bound constraint would be invalid.

Did you mean something like the following:

create table p1 partition of ... from ("minValue") to ("MINVALUE");


which using pg_strncasecmp() comparisons gives:

create table p1 partition of p for values from ("minValue") to ("MINVALUE");
ERROR:  empty range bound specified for partition "p1"
DETAIL:  Specified lower bound (MINVALUE) is greater than or equal to
upper bound (MINVALUE).

which is same as the behavior with unquoted keyword syntax:

create table p1 partition of p for values from (minValue) to (MINVALUE);
ERROR:  empty range bound specified for partition "p1"
DETAIL:  Specified lower bound (MINVALUE) is greater than or equal to
upper bound (MINVALUE).

whereas quoted identifier syntax on HEAD gives:

create table p1 partition of p for values from ("minValue") to ("MINVALUE");
ERROR:  column "minValue" does not exist
LINE 1: create table p1 partition of p for values from ("minValue") ...

However, as you guys said, HEAD is behaving sanely.

Thanks,
Amit





view thread (20+ messages)  latest in thread

Message-ID: <1f9aaa7a-43d4-43ae-e270-14dbca926167@lab.ntt.co.jp>
Permalink:  ../1f9aaa7a-43d4-43ae-e270-14dbca926167@lab.ntt.co.jp/
Also on:    postgresql.org/message-id/1f9aaa7a-43d4-43ae-e270-14dbca926167@lab.ntt.co.jp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: Langote_Amit_f8@lab.ntt.co.jp, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, michael@paquier.xyz, amitlangote09@gmail.com, exclusion@gmail.com, pgsql-hackers@postgresql.org, peter.eisentraut@2ndquadrant.com
  Subject: Re: BUG #15668: Server crash in transformPartitionRangeBounds
  In-Reply-To: <1f9aaa7a-43d4-43ae-e270-14dbca926167@lab.ntt.co.jp>
  References: <15668-0377b1981aa1a393@postgresql.org> <CA+HiwqEGoa485g18mt9GUdF8fH4mKDgpeoc32XiW-dRUFpN5Lw@mail.gmail.com> <20190306064825.GH30982@paquier.xyz> <6ed2c24c-2f73-fa1c-0ed1-ed3597f13d0d@lab.ntt.co.jp> <20190306082730.GJ30982@paquier.xyz> <ab51ec5a-b2d3-a25f-5695-7555ad63d344@lab.ntt.co.jp> <CA+TgmoY7UWpd-01_vwhQ62yivvnvmFM=6BQq-G-HJzzwvCed9g@mail.gmail.com> <7846.1552408520@sss.pgh.pa.us> <1f9aaa7a-43d4-43ae-e270-14dbca926167@lab.ntt.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox