Re: Boolean partitions syntax

2018-04-23 Thread Kyotaro HORIGUCHI
At Tue, 24 Apr 2018 09:23:03 +0900, Amit Langote wrote in > On 2018/04/24 4:33, Tom Lane wrote: > > Amit Langote writes: > >> On 2018/04/22 2:29, Tom Lane wrote: > >>> I propose

Re: Boolean partitions syntax

2018-04-23 Thread Jonathan S. Katz
> On Apr 23, 2018, at 12:33 PM, Tom Lane wrote: > > Amit Langote writes: >> On 2018/04/22 2:29, Tom Lane wrote: >>> I propose the attached slightly-less-invasive version of Amit's original >>> patch as what we should do in v10 and v11, and

Re: Boolean partitions syntax

2018-04-23 Thread Tom Lane
Amit Langote writes: > On 2018/04/22 2:29, Tom Lane wrote: >> I propose the attached slightly-less-invasive version of Amit's original >> patch as what we should do in v10 and v11, and push the patch currently >> under discussion out to v12. > Here too. Pushed.

Re: Boolean partitions syntax

2018-04-22 Thread Amit Langote
On 2018/04/22 2:29, Tom Lane wrote: > Amit Langote writes: >> I think if this bug/open item can be resolved by adopting the minimal >> patch, then we should use it for that. Maybe, we can discuss the rest of >> the changes independently. If they make things better

Re: using expression syntax for partition bounds (was: Re: Boolean partitions syntax)

2018-04-22 Thread Amit Langote
On 2018/04/23 11:37, Amit Langote wrote: > I tried to update the patch to do things that way. I'm going to create a > new entry in the next CF titled "generalized expression syntax for > partition bounds" and add the patch there. Tweaked the commit message to credit all the authors. Thanks,

using expression syntax for partition bounds (was: Re: Boolean partitions syntax)

2018-04-22 Thread Amit Langote
(patch and discussion for PG 12) On 2018/04/22 1:28, Tom Lane wrote: > Amit Langote writes: >> [ v8-0001-Allow-generalized-expression-syntax-for-partition.patch ] > > I find what you did to a_expr here to be pretty horrid. Thanks for the review. > I think what

Re: Boolean partitions syntax

2018-04-21 Thread Tom Lane
Amit Langote writes: > I think if this bug/open item can be resolved by adopting the minimal > patch, then we should use it for that. Maybe, we can discuss the rest of > the changes independently. If they make things better overall, we should > definitely try to

Re: Boolean partitions syntax

2018-04-21 Thread Tom Lane
Amit Langote writes: > [ v8-0001-Allow-generalized-expression-syntax-for-partition.patch ] I find what you did to a_expr here to be pretty horrid. I think what you should do is lose the partbound_datum and PartitionRangeDatum productions altogether, replacing

Re: Boolean partitions syntax

2018-04-20 Thread Amit Langote
On 2018/04/19 20:35, Kyotaro HORIGUCHI wrote: > At Wed, 18 Apr 2018 19:27:16 +0900, Amit Langote wrote: >> On 2018/04/16 16:17, Kyotaro HORIGUCHI wrote: >>> It was a bother that some rules used c_expr directly but I >>> managed to replace all of them with a_expr by lowering precedence >>> of some

Re: Boolean partitions syntax

2018-04-19 Thread Kyotaro HORIGUCHI
Thanks for reviewing. At Wed, 18 Apr 2018 19:27:16 +0900, Amit Langote wrote in <7ac6b44e-4638-3320-1512-f6c03a28d...@lab.ntt.co.jp> > Horiguchi-san, > > Thank you for updating the patch. > > On 2018/04/16 16:17, Kyotaro HORIGUCHI wrote: > > the attached v6

Re: Boolean partitions syntax

2018-04-19 Thread Amit Langote
On 2018/04/18 19:27, Amit Langote wrote: > Please find attached an updated version of your patch. I think we'll need > to make some documentation changes and think about a way to back-patch > this to PG10. Added documentation changes. Also, noticed that there was no need to change the

Re: Boolean partitions syntax

2018-04-18 Thread Amit Langote
Horiguchi-san, Thank you for updating the patch. On 2018/04/16 16:17, Kyotaro HORIGUCHI wrote: > the attached v6 patch differs only in gram.y since v5. Patch fails to compile, because it adds get_partition_col_collation to rel.h instead of partcache.h: src/include/utils/rel.h: In function

Re: Boolean partitions syntax

2018-04-16 Thread Kyotaro HORIGUCHI
Sorry for a silly typo. At Mon, 16 Apr 2018 16:17:40 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI wrote in <20180416.161740.51264437.horiguchi.kyot...@lab.ntt.co.jp> > Hello. Thank you for the comment. > > the attached v6 patch differs only in gram.y since

Re: Boolean partitions syntax

2018-04-16 Thread Kyotaro HORIGUCHI
Hello. Thank you for the comment. the attached v6 patch differs only in gram.y since v5. At Fri, 13 Apr 2018 18:55:30 +0900, Amit Langote wrote in > Horiguchi-san, > > Thanks for the latest patch. > > On

Re: Boolean partitions syntax

2018-04-13 Thread Amit Langote
Horiguchi-san, Thanks for the latest patch. On 2018/04/12 13:12, Kyotaro HORIGUCHI wrote: > Thank you for verification and the revised patch. The format is > fine and the fix is correct but I noticed that I forgot to remove > plural S's from error messages. The attached is the version with > the

Re: Boolean partitions syntax

2018-04-12 Thread Jonathan S. Katz
Hi, > On Apr 12, 2018, at 12:12 AM, Kyotaro HORIGUCHI > wrote: > > Hello. > > At Wed, 11 Apr 2018 09:43:37 -0400, "Jonathan S. Katz" > > > wrote in

Re: Boolean partitions syntax

2018-04-11 Thread Kyotaro HORIGUCHI
Hello. At Wed, 11 Apr 2018 09:43:37 -0400, "Jonathan S. Katz" wrote in > case EXPR_KIND_PARTITION_BOUNDS: > ^~ .. > 2 errors generated. > > The

Re: Boolean partitions syntax

2018-04-11 Thread Jonathan S. Katz
> On Apr 11, 2018, at 4:33 AM, Kyotaro HORIGUCHI > wrote: > > Thank you for the comments. > > At Wed, 11 Apr 2018 13:51:55 +0900, Amit Langote > wrote in > <3d0fda29-986c-d970-a22c-b4bd44f56...@lab.ntt.co.jp> >> Horiguchi-san,

Re: Boolean partitions syntax

2018-04-11 Thread Kyotaro HORIGUCHI
Thank you for the comments. At Wed, 11 Apr 2018 13:51:55 +0900, Amit Langote wrote in <3d0fda29-986c-d970-a22c-b4bd44f56...@lab.ntt.co.jp> > Horiguchi-san, > > Thanks for working on this. > > On 2018/04/11 13:20, Kyotaro HORIGUCHI wrote: > > At Wed, 11 Apr 2018

Re: Boolean partitions syntax

2018-04-11 Thread Kyotaro HORIGUCHI
At Wed, 11 Apr 2018 14:22:29 +0900, Amit Langote wrote in <6e929961-4160-7338-3d26-ccf84f416...@lab.ntt.co.jp> > On 2018/04/11 13:39, David Rowley wrote: > > On 11 April 2018 at 05:22, Tom Lane wrote: > >> David Rowley

Re: Boolean partitions syntax

2018-04-10 Thread Amit Langote
On 2018/04/11 13:39, David Rowley wrote: > On 11 April 2018 at 05:22, Tom Lane wrote: >> David Rowley writes: >>> On 11 April 2018 at 03:34, Tom Lane wrote: Well, that just begs the question: why do these expressions

Re: Boolean partitions syntax

2018-04-10 Thread Amit Langote
Horiguchi-san, Thanks for working on this. On 2018/04/11 13:20, Kyotaro HORIGUCHI wrote: > At Wed, 11 Apr 2018 11:27:17 +0900, Amit Langote wrote: >> On 2018/04/11 10:44, Tom Lane wrote: >>> Kyotaro HORIGUCHI writes: At least partition bound *must* be a

Re: Boolean partitions syntax

2018-04-10 Thread David Rowley
On 11 April 2018 at 05:22, Tom Lane wrote: > David Rowley writes: >> On 11 April 2018 at 03:34, Tom Lane wrote: >>> Well, that just begs the question: why do these expressions need to >>> be immutable? What we really want, I

Re: Boolean partitions syntax

2018-04-10 Thread Kyotaro HORIGUCHI
At Wed, 11 Apr 2018 11:27:17 +0900, Amit Langote wrote in <1810b14f-3cd7-aff5-8358-c225c0231...@lab.ntt.co.jp> > On 2018/04/11 10:44, Tom Lane wrote: > > Kyotaro HORIGUCHI writes: > >> At least partition bound *must* be a

Re: Boolean partitions syntax

2018-04-10 Thread Amit Langote
On 2018/04/10 23:37, David Rowley wrote: > On 10 April 2018 at 23:13, Kyotaro HORIGUCHI > wrote: >> Note: This is not intended to be committed this time but just for >> information. >> >> At Tue, 10 Apr 2018 10:34:27 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI

Re: Boolean partitions syntax

2018-04-10 Thread Amit Langote
On 2018/04/11 10:44, Tom Lane wrote: > Kyotaro HORIGUCHI writes: >> At least partition bound *must* be a constant. Any expression >> that can be reduced to a constant at parse time ought to be >> accepted but must not be accepted if not. > > My point is that

Re: Boolean partitions syntax

2018-04-10 Thread Tom Lane
Kyotaro HORIGUCHI writes: > At least partition bound *must* be a constant. Any expression > that can be reduced to a constant at parse time ought to be > accepted but must not be accepted if not. My point is that *any* expression can be reduced to a constant, we

Re: Boolean partitions syntax

2018-04-10 Thread Kyotaro HORIGUCHI
At Wed, 11 Apr 2018 02:33:58 +1200, David Rowley wrote in > On 3 February 2018 at 12:04, Tom Lane wrote: > > Perhaps more useful to discuss: would that truly be the semantics

Re: Boolean partitions syntax

2018-04-10 Thread Jonathan S. Katz
> On Apr 10, 2018, at 1:22 PM, Tom Lane wrote: > > David Rowley writes: >> On 11 April 2018 at 03:34, Tom Lane wrote: >>> Well, that just begs the question: why do these expressions need to >>> be immutable? What we really

Re: Boolean partitions syntax

2018-04-10 Thread Tom Lane
David Rowley writes: > On 11 April 2018 at 03:34, Tom Lane wrote: >> Well, that just begs the question: why do these expressions need to >> be immutable? What we really want, I think, is to evaluate them >> and reduce them to constants. After

Re: Boolean partitions syntax

2018-04-10 Thread David Rowley
On 11 April 2018 at 03:34, Tom Lane wrote: > David Rowley writes: >> I imagined this would have had a check for volatile functions and some >> user-friendly error message to say partition bounds must be immutable, >> but instead, it does: > >>

Re: Boolean partitions syntax

2018-04-10 Thread Tom Lane
David Rowley writes: > I imagined this would have had a check for volatile functions and some > user-friendly error message to say partition bounds must be immutable, > but instead, it does: > postgres=# create table d_p1 partition of d for values in (Random()); >

Re: Boolean partitions syntax

2018-04-10 Thread David Rowley
On 10 April 2018 at 23:13, Kyotaro HORIGUCHI wrote: > Note: This is not intended to be committed this time but just for > information. > > At Tue, 10 Apr 2018 10:34:27 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI > wrote in >

Re: Boolean partitions syntax

2018-04-10 Thread David Rowley
On 3 February 2018 at 12:04, Tom Lane wrote: > Perhaps more useful to discuss: would that truly be the semantics we want, > or should we just evaluate the expression and have done? It's certainly > arguable that "IN (random())" ought to draw an error, not compute some >

Re: Boolean partitions syntax

2018-04-10 Thread Kyotaro HORIGUCHI
Hello. Note: This is not intended to be committed this time but just for information. At Tue, 10 Apr 2018 10:34:27 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI wrote in <20180410.103427.244142052.horiguchi.kyot...@lab.ntt.co.jp> > Just adding negation would

Re: Boolean partitions syntax

2018-04-09 Thread Kyotaro HORIGUCHI
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" wrote in <27021281-2ed7-4cde-9d82-366af10b3...@excoventures.com> > > On Apr 9, 2018, at 10:06 AM, Tom Lane

Re: Boolean partitions syntax

2018-04-09 Thread Jonathan S. Katz
> On Apr 9, 2018, at 10:06 AM, Tom Lane wrote: > > "Jonathan S. Katz" writes: >> +1 based on running the above scenario on my 10.3 instance and >> receiving the same error. Is there a chance the fix could make it into >> 10.4 then? > > It's

Re: Boolean partitions syntax

2018-04-09 Thread Tom Lane
"Jonathan S. Katz" writes: > +1 based on running the above scenario on my 10.3 instance and > receiving the same error. Is there a chance the fix could make it into > 10.4 then? It's premature to discuss whether this could be back-patched when we haven't got an

Re: Boolean partitions syntax

2018-04-09 Thread Jonathan S. Katz
> On Apr 9, 2018, at 8:28 AM, Peter Eisentraut > wrote: > > On 4/7/18 11:16, Jonathan S. Katz wrote: >> The last line yielding: >> >> ERROR: syntax error at or near "TRUE" >> LINE 3: FOR VALUES IN (TRUE); >> >> [Omitted from example: the

Re: Boolean partitions syntax

2018-04-09 Thread Peter Eisentraut
On 4/7/18 11:16, Jonathan S. Katz wrote: > The last line yielding: > >     ERROR:  syntax error at or near "TRUE" >     LINE 3: FOR VALUES IN (TRUE); > > [Omitted from example: the “records_active” partition] > > I’m glad to see this was added to the open items. I would strongly > suggest

Re: Boolean partitions syntax

2018-04-07 Thread Jonathan S. Katz
> On Mar 21, 2018, at 10:59 PM, Amit Langote > wrote: > > Hi David. > > On 2018/03/21 23:31, David Steele wrote: >> Hi Amit, >> >> On 3/6/18 9:44 AM, David Steele wrote: >>> On 3/2/18 2:27 AM, Amit Langote wrote: On 2018/03/02 15:58, Andres Freund wrote:

Re: Boolean partitions syntax

2018-03-22 Thread David Steele
On 3/21/18 10:59 PM, Amit Langote wrote: > On 2018/03/21 23:31, David Steele wrote: >> Hi Amit, >> >> On 3/6/18 9:44 AM, David Steele wrote: >>> On 3/2/18 2:27 AM, Amit Langote wrote: On 2018/03/02 15:58, Andres Freund wrote: > On 2018-02-02 17:00:24 -0500, Tom Lane wrote: >> Peter

Re: Boolean partitions syntax

2018-03-21 Thread Amit Langote
Hi David. On 2018/03/21 23:31, David Steele wrote: > Hi Amit, > > On 3/6/18 9:44 AM, David Steele wrote: >> On 3/2/18 2:27 AM, Amit Langote wrote: >>> On 2018/03/02 15:58, Andres Freund wrote: On 2018-02-02 17:00:24 -0500, Tom Lane wrote: > Peter Eisentraut

Re: Re: Re: Boolean partitions syntax

2018-03-21 Thread David Steele
Hi Amit, On 3/6/18 9:44 AM, David Steele wrote: > On 3/2/18 2:27 AM, Amit Langote wrote: >> On 2018/03/02 15:58, Andres Freund wrote: >>> On 2018-02-02 17:00:24 -0500, Tom Lane wrote: Peter Eisentraut writes: > There might be other options, but one way

Re: Re: Boolean partitions syntax

2018-03-06 Thread David Steele
Hi Amit, On 3/2/18 2:27 AM, Amit Langote wrote: > On 2018/03/02 15:58, Andres Freund wrote: >> On 2018-02-02 17:00:24 -0500, Tom Lane wrote: >>> Peter Eisentraut writes: There might be other options, but one way to solve this would be to treat

Re: Boolean partitions syntax

2018-03-01 Thread Amit Langote
Horiguchi-san, On 2018/02/05 18:17, Kyotaro HORIGUCHI wrote: > At Mon, 29 Jan 2018 13:21:54 +0900, Amit Langote wrote: >> Partition bound literals as captured gram.y don't have any type >> information attached. They're carried over in a A_Const to >> transformPartitionBoundValue() and coerced to

Re: Boolean partitions syntax

2018-03-01 Thread Amit Langote
On 2018/03/02 15:58, Andres Freund wrote: > On 2018-02-02 17:00:24 -0500, Tom Lane wrote: >> Peter Eisentraut writes: >>> There might be other options, but one way to solve this would be to >>> treat partition bounds as a general expression in the grammar and

Re: Boolean partitions syntax

2018-03-01 Thread Andres Freund
On 2018-02-02 17:00:24 -0500, Tom Lane wrote: > Peter Eisentraut writes: > > There might be other options, but one way to solve this would be to > > treat partition bounds as a general expression in the grammar and then > > check in post-parse analysis that it's

Re: Boolean partitions syntax

2018-02-05 Thread Kyotaro HORIGUCHI
Hello, At Fri, 02 Feb 2018 18:04:44 -0500, Tom Lane wrote in <14732.1517612...@sss.pgh.pa.us> > Robert Haas writes: > > On Fri, Feb 2, 2018 at 4:40 PM, Peter Eisentraut > > wrote: > >> There might be other options,

Re: Boolean partitions syntax

2018-02-02 Thread Tom Lane
Robert Haas writes: > On Fri, Feb 2, 2018 at 4:40 PM, Peter Eisentraut > wrote: >> There might be other options, but one way to solve this would be to >> treat partition bounds as a general expression in the grammar and then >> check in

Re: Boolean partitions syntax

2018-02-02 Thread Robert Haas
On Fri, Feb 2, 2018 at 4:40 PM, Peter Eisentraut wrote: > There might be other options, but one way to solve this would be to > treat partition bounds as a general expression in the grammar and then > check in post-parse analysis that it's a constant. Yeah --

Re: Boolean partitions syntax

2018-02-02 Thread Tom Lane
Peter Eisentraut writes: > There might be other options, but one way to solve this would be to > treat partition bounds as a general expression in the grammar and then > check in post-parse analysis that it's a constant. That's pretty much what I said upthread.

Re: Boolean partitions syntax

2018-02-02 Thread Amit Langote
On 2018/01/29 14:57, Tom Lane wrote: > Amit Langote writes: >> Partition bound literals as captured gram.y don't have any type >> information attached. > > Isn't that design broken by definition? TRUE is not the same thing > as 't', nor as 'true'. Nor are 1 and

Re: Boolean partitions syntax

2018-01-28 Thread Tom Lane
Amit Langote writes: > Partition bound literals as captured gram.y don't have any type > information attached. Isn't that design broken by definition? TRUE is not the same thing as 't', nor as 'true'. Nor are 1 and '1' the same thing; it's true that in some

Re: Boolean partitions syntax

2018-01-28 Thread Amit Langote
On 2018/01/27 1:31, Tom Lane wrote: > Robert Haas writes: >> On Fri, Jan 26, 2018 at 11:07 AM, Stephen Frost wrote: >>> I've already had two people mention that it'd be neat to have PG support >>> it, so I don't believe it'd go unused. As for if we

Re: Boolean partitions syntax

2018-01-28 Thread Amit Langote
On 2018/01/27 0:30, Robert Haas wrote: > On Thu, Jan 25, 2018 at 8:44 PM, Amit Langote > wrote: >> Attached updated patch. > > I wonder if this patch is just parser bloat without any real benefit. > It can't be very common to want to partition on a Boolean column,

Re: Boolean partitions syntax

2018-01-26 Thread Tom Lane
Robert Haas writes: > On Fri, Jan 26, 2018 at 11:07 AM, Stephen Frost wrote: >> I've already had two people mention that it'd be neat to have PG support >> it, so I don't believe it'd go unused. As for if we should force people >> to use quotes, my

Re: Boolean partitions syntax

2018-01-26 Thread Robert Haas
On Fri, Jan 26, 2018 at 11:07 AM, Stephen Frost wrote: > I've already had two people mention that it'd be neat to have PG support > it, so I don't believe it'd go unused. As for if we should force people > to use quotes, my vote would be no because we don't require that for >

Re: Boolean partitions syntax

2018-01-26 Thread Stephen Frost
Robert, * Robert Haas (robertmh...@gmail.com) wrote: > On Thu, Jan 25, 2018 at 8:44 PM, Amit Langote > wrote: > > Attached updated patch. > > I wonder if this patch is just parser bloat without any real benefit. > It can't be very common to want to partition on a

Re: Boolean partitions syntax

2018-01-26 Thread Robert Haas
On Thu, Jan 25, 2018 at 8:44 PM, Amit Langote wrote: > Attached updated patch. I wonder if this patch is just parser bloat without any real benefit. It can't be very common to want to partition on a Boolean column, and if you do, all this patch does is let you drop

Re: Boolean partitions syntax

2018-01-25 Thread Amit Langote
Hi Stephen. On 2018/01/26 10:16, Stephen Frost wrote: > * Amit Langote (langote_amit...@lab.ntt.co.jp) wrote: > Still compiles and passes regression tests, which is good. Thanks for looking at this. >>> I extended your test a bit to check whether partitions over booleans are >>> useful. >>>

Re: Boolean partitions syntax

2018-01-25 Thread Stephen Frost
Greetings Amit, * Amit Langote (langote_amit...@lab.ntt.co.jp) wrote: > On 2017/12/20 6:46, Mark Dilger wrote: > >> On Dec 12, 2017, at 10:32 PM, Amit Langote > >> wrote: > >> Added to CF: https://commitfest.postgresql.org/16/1410/ > > > > This compiles and

Re: Boolean partitions syntax

2017-12-19 Thread Amit Langote
Hi Mark, On 2017/12/20 6:46, Mark Dilger wrote: >> On Dec 12, 2017, at 10:32 PM, Amit Langote >> wrote: >> Added to CF: https://commitfest.postgresql.org/16/1410/ > > This compiles and passes the regression tests for me. Thanks for the review. > I extended your

Re: Boolean partitions syntax

2017-12-19 Thread Mark Dilger
> On Dec 12, 2017, at 10:32 PM, Amit Langote > wrote: > > On 2017/12/12 15:39, Amit Langote wrote: >> On 2017/12/12 15:35, Amit Langote wrote: >>> Works for me, updated patch attached. >> >> Oops, attached the old one with the last email. >> >> Updated one

Re: Boolean partitions syntax

2017-12-12 Thread Peter Eisentraut
On 12/12/17 04:12, Ashutosh Bapat wrote: > May be you should use opt_boolean_or_string instead of TRUE_P and > FALSE_P. It also supports ON and OFF, which will be bonus. But ON and OFF are not valid boolean literals in SQL. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL

Re: Boolean partitions syntax

2017-12-12 Thread Amit Langote
On 2017/12/12 18:12, Ashutosh Bapat wrote: > On Tue, Dec 12, 2017 at 7:19 AM, Amit Langote wrote: >> Horiguchi-san pointed out [1] on a nearby thread that the partitioning >> syntax (the FOR VALUES clause) doesn't accept true and false as valid >> partition bound datums, which seems to me like an

Re: Boolean partitions syntax

2017-12-12 Thread Ashutosh Bapat
On Tue, Dec 12, 2017 at 7:19 AM, Amit Langote wrote: > Hi. > > Horiguchi-san pointed out [1] on a nearby thread that the partitioning > syntax (the FOR VALUES clause) doesn't accept true and false as valid > partition bound datums, which seems to me like an

Re: Boolean partitions syntax

2017-12-11 Thread Amit Langote
On 2017/12/12 15:35, Amit Langote wrote: > Works for me, updated patch attached. Oops, attached the old one with the last email. Updated one really attached this time. Thanks, Amit From 318c815264b27fcbda5b83e542c6a2970f714399 Mon Sep 17 00:00:00 2001 From: amit Date:

Re: Boolean partitions syntax

2017-12-11 Thread Amit Langote
Hi Dilip. Thanks for the review. On 2017/12/12 15:03, Dilip Kumar wrote: > On Tue, Dec 12, 2017 at 7:19 AM, Amit Langote wrote: >> Horiguchi-san pointed out [1] on a nearby thread that the partitioning >> syntax (the FOR VALUES clause) doesn't accept true and false as valid >> partition bound