Re: Proposal for fixing numeric type-resolution issues

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew McMillan <Andrew(at)catalyst(dot)net(dot)nz>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal for fixing numeric type-resolution issues
Date: 2000-05-15 18:56:51
Message-ID: Pine.LNX.4.21.0005142037410.915-100000@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane writes:

> I expect what you are after is the ability to produce an 0-or-1
> numeric value from a bool field, so that you could do things like
> sum(boolfield::int) to count the number of true values in a column.
> I agree that we need such an operator (and I'm surprised no one's
> gotten round to contributing one).

Let's contribute one now ...

select count(*) from test4 where a = true;

select sum( case when a then 1 else 0 end ) from test4;

> But I don't agree that there
> should be an implicit, automatic conversion from bool to int; that
> defeats half of the error-checking value of having a separate type for
> truth values in the first place.

Definitely.

--
Peter Eisentraut Sernanders väg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2000-05-15 18:57:27 Re: Casting, again
Previous Message Jim Mercer 2000-05-15 18:44:26 broken links on http://www.postgresql.org/doxlist.html