From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: bit|varbit #, xor operator |
Date: | 2016-10-17 20:50:46 |
Message-ID: | CAKFQuwYC47oFZLO4Q0c2K7zbW86_Tc3n1s53ADV2DqGhFA=WhQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Oct 17, 2016 at 1:39 PM, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com> wrote:
> On 10/17/16 11:29 AM, Tom Lane wrote:
>
>> Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com> writes:
>>
>>> On 10/16/16 3:13 PM, Tom Lane wrote:
>>>
>>>> Related to this I'd also like to add a boolean XOR operator as that's a
>>>>> relatively common request/question.
>>>>>
>>>>
>> We have boolean XOR; it's spelled "<>".
>>>>
>>>
>> I always forget about that...
>>>
>>
>> Maybe it should be mentioned explicitly in the docs.
>>
>
> Hrm, went to go add it and it appears we don't have a section for boolean
> type operators. I guess I should add it to 9.1?
>
>
There are no symbolic operators, just the standard SQL keywords: AND, OR,
NOT.
https://www.postgresql.org/docs/current/static/functions-logical.html
Adding a note there pertaining to XOR should be sufficient.
though, it doesn't work for boolean arrays.
>>>
>>
>> Define doesn't work?
>>
>
> I would expect array[true, false] XOR array[true, true] to return
> array[false, true], but <> just returns a single true (since the arrays are
> !=).
>
> Though, I guess what would make the most sense there is a map function
> that would apply an operator or function to every element of a set of
> arrays. But I don't see any way to do that without major changes to how
> anyarray works.
Yeah, your expectations seem off here given that:
SELECT array[true, false]::boolean[] AND array[true, true]::boolean[]
is invalid...
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2016-10-17 20:53:39 | Re: Non-empty default log_line_prefix |
Previous Message | Tom Lane | 2016-10-17 20:42:30 | Re: Add PGDLLEXPORT to PG_FUNCTION_INFO_V1 |