Re: Boolean partitions syntax

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: jonathan(dot)katz(at)excoventures(dot)com
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, peter(dot)eisentraut(at)2ndquadrant(dot)com, Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp, david(at)pgmasters(dot)net, andres(at)anarazel(dot)de, robertmhaas(at)gmail(dot)com, sfrost(at)snowman(dot)net, hornschnorter(at)gmail(dot)com, dilipbalaut(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Boolean partitions syntax
Date: 2018-04-10 01:34:27
Message-ID: 20180410.103427.244142052.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello, I returned to this.

I'd like to insisnt on prposing to use existing parser element.

At Mon, 9 Apr 2018 10:11:08 -0400, "Jonathan S. Katz" <jonathan(dot)katz(at)excoventures(dot)com> wrote in <27021281-2ED7-4CDE-9D82-366AF10B3B57(at)excoventures(dot)com>
> > On Apr 9, 2018, at 10:06 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > It's premature to discuss whether this could be back-patched when
> > we haven't got an acceptable patch yet.
>
> Understood.

At Fri, 2 Mar 2018 16:49:29 +0900, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> wrote in <2d49cd86-acb9-fc5b-8eb7-e467b01ec25a(at)lab(dot)ntt(dot)co(dot)jp>
> I had tried the approach your patch takes and had noticed that the syntax
> had stopped accepting negative values (a regression test fails due to that).
...
> I had tried fixing that as well, but it didn't readily work.

Just adding negation would work as a_expr is doing.

> | '-' a_expr %prec UMINUS
> { $$ = doNegate($2, @1); }

Boolean and negative values are accepted as partition bound
values with the attached patch.

> =# create table p (a bool, b int) partition by list(a);
> CREATE TABLE
> =# create table ct partition of p for values in (true) partition by list (b);
> CREATE TABLE
> =# create table ct1 partition of ct for values in (-1, -2);
> CREATE TABLE

And illegal negative is rejected.

> =# create table ct3 partition of ct for values in (-true);
> ERROR: operator does not exist: - boolean
> LINE 1: create table ct3 partition of ct for values in (-true);

Interval has a conversion to text so this behaves someshat oddly
but it seems to me that we don't need reject that explicitly.

> create table c2 partition of p for values in (interval '1 year');
> CREATE TABLE
> =# \d+ c2
...
> Partition of: p FOR VALUES IN ('1 year')

or

> =# create table c1 partition of p for values in (interval '1 day');
> ERROR: specified value cannot be cast to type integer for column "a"
> LINE 1: create table c1 partition of p for values in (interval '1 da...

The attached patch is adding lines for error checking in some
functions like transformWindowFuncCall. They are basically
useless as they are to be rejected by parser but it seems to be
needed for consistency.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
allow_bool_as_partbound_v2.patch text/x-patch 7.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-04-10 01:34:31 Re: Excessive PostmasterIsAlive calls slow down WAL redo
Previous Message Alvaro Herrera 2018-04-10 01:31:07 Re: Excessive PostmasterIsAlive calls slow down WAL redo