RE: Direct converting numeric types to bool

From: "Alex Ignatov" <a(dot)ignatov(at)postgrespro(dot)ru>
To: <n(dot)zhuchkov(at)postgrespro(dot)ru>, "'pgsql-hackers'" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Direct converting numeric types to bool
Date: 2018-02-28 15:23:04
Message-ID: 0b9801d3b0a8$07818780$16849680$@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


-----Original Message-----
From: n(dot)zhuchkov(at)postgrespro(dot)ru [mailto:n(dot)zhuchkov(at)postgrespro(dot)ru]
Sent: Wednesday, February 28, 2018 6:04 PM
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Direct converting numeric types to bool

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.

--
Nikita Zhuchkov
Postgres Professional: http://www.postgrespro.com The Russian Postgres
Company

Hello!

What prevent us from:

postgres=# select 1::bigint::int::boolean;
bool
------
t
(1 row)

It is just one additional casting and required no additional patching
--
Alex Ignatov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikhil Sontakke 2018-02-28 15:42:42 Re: [HACKERS] logical decoding of two-phase transactions
Previous Message Robert Haas 2018-02-28 15:20:44 Re: postgres_fdw: perform UPDATE/DELETE .. RETURNING on a join directly