From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | n(dot)zhuchkov(at)postgrespro(dot)ru |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Direct converting numeric types to bool |
Date: | 2018-02-28 15:14:26 |
Message-ID: | CAFj8pRBnVqYNx8V1qmBL5GjOeu2jt6CUEayAZE7gV-yX9ZSa0w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2018-02-28 16:13 GMT+01:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
> Hi
>
> 2018-02-28 16:06 GMT+01:00 <n(dot)zhuchkov(at)postgrespro(dot)ru>:
>
>> n(dot)zhuchkov(at)postgrespro(dot)ru писал 2018-02-28 18:04:
>>
>> Attached patch allow direct convertion of numeric types to bool like
>>> integer::bool.
>>> Supported types:
>>> - smallint;
>>> - bigint;
>>> - real;
>>> - double precision;
>>> - decimal(numeric).
>>>
>>> This functionality is helped with migration from Oracle.
>>>
>>
> Looks little bit obscure to upstream code (can lives as extension outside)
>
> all work can be done be function
>
> CREATE OR REPLACE FUNCTION public.to_bool(anyelement)
> RETURNS boolean
> LANGUAGE sql
> IMMUTABLE STRICT
> AS $function$
> select $1::int::boolean $function$
>
> I really doesn't see any sense to allow cast from double to boolean
>
Long time Oracle had not boolean, so some ugly tricks was necessary there.
There are not reason do same in Postgres.
>
> -1 from me
>
> Regards
>
> Pavel
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2018-02-28 15:20:44 | Re: postgres_fdw: perform UPDATE/DELETE .. RETURNING on a join directly |
Previous Message | Pavel Stehule | 2018-02-28 15:13:21 | Re: Direct converting numeric types to bool |