Re: syntax sugar for conditional check

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: syntax sugar for conditional check
Дата
Msg-id CAKFQuwY0x4bHyvmjn+2zthVuF4FUeQo6N70nWczsF0_M8moRTA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: syntax sugar for conditional check  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Список pgsql-hackers
On Fri, Apr 1, 2016 at 3:22 PM, Jim Nasby <Jim.Nasby@bluetreble.com> wrote:
On 4/1/16 1:08 PM, Tom Lane wrote:
Jim Nasby <Jim.Nasby@BlueTreble.com> writes:
Rather than this, I think an exclusive-or operator would be a lot more
useful. The only difficulty I run into with CHECK constaints is when I
want to ensure that only ONE condition is true.

"bool != bool" works as XOR.  If you need "exactly one of N" you could
do something like "(cond1::int + cond2::int + ...) = 1".  We could
wrap some syntactic sugar around either of these, but it's not clear
to me that it'd be any more useful than a custom SQL function.

It would prevent having to re-create that function every time... :)

​And it would nicely complement our recent addition of "
num_nonnulls
​(variadic "any")​"

David J.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robbie Harwood
Дата:
Сообщение: Re: [PATCH v11] GSSAPI encryption support
Следующее
От: "Shulgin, Oleksandr"
Дата:
Сообщение: Re: More stable query plans via more predictable column statistics