From: | Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> |
---|---|
To: | Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Boolean partitions syntax |
Date: | 2017-12-12 06:35:59 |
Message-ID: | 0bb6cc57-17c0-1cc2-047c-c452300a75d1@lab.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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 datums, which seems to me like an oversight. Attached a
>> patch to fix that.
>>
>> create table bools (a bool) partition by list (a);
>>
>> Before patch:
>>
>> create table bools_t partition of bools for values in (true);
>> ERROR: syntax error at or near "true"
>> LINE 1: ...reate table bools_t partition of bools for values in (true);
>>
>> After:
>>
>> create table bools_t partition of bools for values in (true);
>> CREATE TABLE
>> \d bools_t
>> Table "public.bools_t"
>> Column | Type | Collation | Nullable | Default
>> --------+---------+-----------+----------+---------
>> a | boolean | | |
>> Partition of: bools FOR VALUES IN (true)
>
> +makeBoolAConstNoCast(bool state, int location)
> +{
> + A_Const *n = makeNode(A_Const);
> +
> + n->val.type = T_String;
> + n->val.val.str = (state ? "t" : "f");
> + n->location = location;
> +
> + return (Node *) n;
> +}
> +
>
> I think we can change makeBoolAConst as below so that we can avoid
> duplicate code.
>
> static Node *
> makeBoolAConst(bool state, int location)
> {
> Node *n = makeBoolAConstNoCast(state, location);
>
> return makeTypeCast(n, SystemTypeName("bool"), -1);
> }
Works for me, updated patch attached.
Thanks,
Amit
Attachment | Content-Type | Size |
---|---|---|
0001-Allow-Boolean-values-in-partition-FOR-VALUES-clause-v2.patch | text/plain | 5.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Langote | 2017-12-12 06:39:19 | Re: Boolean partitions syntax |
Previous Message | Craig Ringer | 2017-12-12 06:30:29 | Re: proposal: alternative psql commands quit and exit |