Re: 'true'::TEXT::BOOLEAN

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Markus Bertheau ??? <twanger(at)bluetwanger(dot)de>, Michael Glaesemann <grzm(at)myrealbox(dot)com>, PostgreSQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: 'true'::TEXT::BOOLEAN
Date: 2005-06-03 15:28:02
Message-ID: 5276.1117812482@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> Markus Bertheau ??? <twanger(at)bluetwanger(dot)de> wrote:
>> I think casting from text to boolean should be possible, and use the
>> same algorithm that's used when casting from "unknown" to boolean.

> You probably want boolin.

That won't actually work either, because boolin wants cstring:

egression=# select boolin('f'::text);
ERROR: function boolin(text) does not exist
HINT: No function matches the given name and argument types. You may need to add explicit type casts.

You can get it to work like this, if you're determined:

regression=# select boolin(textout('f'::text));
boolin
--------
f
(1 row)

and of course

regression=# select textin(boolout(true));
textin
--------
t
(1 row)

There's been discussion of allowing all datatypes to be explicitly
casted to or from text by generating conversions like these
automatically. But I'm not sure if everyone's convinced it's a good
idea or not. You'd also have to argue about whether varchar should
be included in the special dispensation ...

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Bertheau ☭ 2005-06-03 15:36:24 Re: 'true'::TEXT::BOOLEAN
Previous Message Michael Fuhr 2005-06-03 15:23:28 Re: using a selected row as a function parameter