pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG REPORT: Unable to cast boolean::smallint
4+ messages / 4 participants
[nested] [flat]

* BUG REPORT: Unable to cast boolean::smallint
@ 2014-11-05 14:29 James Pittman <j.pittman@travelaudience.com>
  2014-11-05 15:13 ` Re: BUG REPORT: Unable to cast boolean::smallint Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: James Pittman @ 2014-11-05 14:29 UTC (permalink / raw)
  To: pgsql-bugs; +Cc: Norbert Buchmüller <n.buchmueller@travelaudience.com>

It does not seem possible to be able to cast a boolean to a smallint.

Whilst the following is possible:

SELECT true::int;

 int4
------
    1
(1 row)


The following is not (as of 9.4beta3)

SELECT true::smallint;
ERROR:  cannot cast type boolean to smallint


It would seem logically consistent that both cases would hold true


Apologies if this is more of a 'feature request' than a bug.





Kind regards,


James

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG REPORT: Unable to cast boolean::smallint
  2014-11-05 14:29 BUG REPORT: Unable to cast boolean::smallint James Pittman <j.pittman@travelaudience.com>
@ 2014-11-05 15:13 ` Tom Lane <tgl@sss.pgh.pa.us>
  2014-11-05 16:31   ` Re: BUG REPORT: Unable to cast boolean::smallint David G Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2014-11-05 15:13 UTC (permalink / raw)
  To: James Pittman <j.pittman@travelaudience.com>; +Cc: pgsql-bugs; Norbert Buchmüller <n.buchmueller@travelaudience.com>

James Pittman <j.pittman@travelaudience.com> writes:
> It does not seem possible to be able to cast a boolean to a smallint.

Well, there are also not direct casts provided from boolean to bigint,
numeric, real, or double precision ;-).  I'm not terribly excited about
this.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG REPORT: Unable to cast boolean::smallint
  2014-11-05 14:29 BUG REPORT: Unable to cast boolean::smallint James Pittman <j.pittman@travelaudience.com>
  2014-11-05 15:13 ` Re: BUG REPORT: Unable to cast boolean::smallint Tom Lane <tgl@sss.pgh.pa.us>
@ 2014-11-05 16:31   ` David G Johnston <david.g.johnston@gmail.com>
  2014-11-05 16:37     ` Re: BUG REPORT: Unable to cast boolean::smallint Marko Tiikkaja <marko@joh.to>
  0 siblings, 1 reply; 4+ messages in thread

From: David G Johnston @ 2014-11-05 16:31 UTC (permalink / raw)
  To: pgsql-bugs

Tom Lane-2 wrote
> James Pittman &lt;

> j.pittman@

> &gt; writes:
>> It does not seem possible to be able to cast a boolean to a smallint.
> 
> Well, there are also not direct casts provided from boolean to bigint,
> numeric, real, or double precision ;-).  I'm not terribly excited about
> this.

So why is there one for Boolean to int?

To the OP, why do you think you want one?

While I haven't used it much converting Boolean to zero/one for use in a
math formula is a known use case though likely one where the difference
between int and smallint would probably be marginalized.

David J.



--
View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-REPORT-Unable-to-cast-boolean-smallint-tp5825768p5825784...
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG REPORT: Unable to cast boolean::smallint
  2014-11-05 14:29 BUG REPORT: Unable to cast boolean::smallint James Pittman <j.pittman@travelaudience.com>
  2014-11-05 15:13 ` Re: BUG REPORT: Unable to cast boolean::smallint Tom Lane <tgl@sss.pgh.pa.us>
  2014-11-05 16:31   ` Re: BUG REPORT: Unable to cast boolean::smallint David G Johnston <david.g.johnston@gmail.com>
@ 2014-11-05 16:37     ` Marko Tiikkaja <marko@joh.to>
  0 siblings, 0 replies; 4+ messages in thread

From: Marko Tiikkaja @ 2014-11-05 16:37 UTC (permalink / raw)
  To: David G Johnston <david.g.johnston@gmail.com>; pgsql-bugs

On 11/5/14 5:31 PM, David G Johnston wrote:
> Tom Lane-2 wrote
>> Well, there are also not direct casts provided from boolean to bigint,
>> numeric, real, or double precision ;-).  I'm not terribly excited about
>> this.
>
> So why is there one for Boolean to int?

That can be useful for e.g.  CHECK (bool1::int + bool2::int + bool3::int 
= 1).


.marko


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2014-11-05 16:37 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-11-05 14:29 BUG REPORT: Unable to cast boolean::smallint James Pittman <j.pittman@travelaudience.com>
2014-11-05 15:13 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-11-05 16:31   ` David G Johnston <david.g.johnston@gmail.com>
2014-11-05 16:37     ` Marko Tiikkaja <marko@joh.to>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox