[SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Markus Bertheau ☭
Hi, What's the type I need to convert text to before I can convert it to boolean? Markus -- Markus Bertheau [EMAIL PROTECTED] ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Achilleus Mantzios
O Markus Bertheau ^ Jun 3, 2005 : Hi, What's the type I need to convert text to before I can convert it to boolean? just 't' will suffice. Markus -- -Achilleus ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Markus Bertheau ☭
, 03/06/2005 14:20 +0300, Achilleus Mantzios : O Markus Bertheau ^ Jun 3, 2005 : Hi, What's the type I need to convert text to before I can convert it to boolean? just 't' will suffice. Well, that's not my question. I have a plpgsql function like that: CREATE FUNCTION

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Achilleus Mantzios
O Markus Bertheau ^ Jun 3, 2005 : ? ??, 03/06/2005 14:20 +0300, Achilleus Mantzios ??: O Markus Bertheau ^ ?? ??? Jun 3, 2005 : Hi, What's the type I need to convert text to before I can convert it to boolean? just 't' will suffice. Well, that's not my question. I

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Markus Bertheau ☭
, 03/06/2005 14:45 +0300, Achilleus Mantzios : Then use the case when ... then ... when ... then ... else ... end construct, e.g. case when mytext='true' then 't'::boolean else 'f'::boolean end Because I don't want to reimplement postgres' boolean parsing. Hmm, why dont you leave it as

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Michael Glaesemann
On Jun 3, 2005, at 8:52 PM, Markus Bertheau wrote: And I can't call it with a TEXT variable, because casting from TEXT to BOOLEAN isn't possible. I'd be surprised if there weren't a some way to coerce the cast from text to boolean, but you might want to just make a simple convenience

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Michael Glaesemann
On Jun 3, 2005, at 9:23 PM, Markus Bertheau wrote: This also bypasses the built in postgresql boolean literal parsing. I think casting from text to boolean should be possible, and use the same algorithm that's used when casting from unknown to boolean. Actually, looking at the system

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Markus Bertheau ☭
This also bypasses the built in postgresql boolean literal parsing. I think casting from text to boolean should be possible, and use the same algorithm that's used when casting from unknown to boolean. Markus , 03/06/2005 21:14 +0900, Michael Glaesemann : On Jun 3, 2005, at 8:52 PM, Markus

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Achilleus Mantzios
O Michael Glaesemann Jun 3, 2005 : On Jun 3, 2005, at 9:23 PM, Markus Bertheau ? wrote: This also bypasses the built in postgresql boolean literal parsing. I think casting from text to boolean should be possible, and use the same algorithm that's used when casting from unknown to

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Markus Bertheau ☭
, 03/06/2005 15:46 +0300, Achilleus Mantzios : Also according to the docs: http://www.postgresql.org/docs/current/static/datatype-boolean.html Tip: Values of the boolean type cannot be cast directly to other types (e.g., CAST (boolval AS integer) does not work). This can be accomplished

Re: [SQL] 'true'::TEXT::BOOLEAN doesn't work

2005-06-03 Thread Markus Bertheau ☭
, 03/06/2005 15:07 +0200, Markus Bertheau : , 03/06/2005 15:46 +0300, Achilleus Mantzios : Also according to the docs: http://www.postgresql.org/docs/current/static/datatype-boolean.html Tip: Values of the boolean type cannot be cast directly to other types (e.g., CAST (boolval

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Tom Lane
Markus Bertheau =?UTF-8?Q?=E2=98=AD?= [EMAIL PROTECTED] writes: Well, that's not my question. I have a plpgsql function like that: ... And I can't call it with a TEXT variable, because casting from TEXT to BOOLEAN isn't possible. In plpgsql it is: just assign the text value to a boolean

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Bruno Wolff III
On Fri, Jun 03, 2005 at 14:23:37 +0200, Markus Bertheau ??? [EMAIL PROTECTED] wrote: This also bypasses the built in postgresql boolean literal parsing. 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

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Tom Lane
Bruno Wolff III [EMAIL PROTECTED] writes: Markus Bertheau ??? [EMAIL PROTECTED] 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

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Markus Bertheau ☭
, 03/06/2005 11:28 -0400, Tom Lane : 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. I certainly consider the way you proposed

Re: [SQL] 'true'::TEXT::BOOLEAN

2005-06-03 Thread Bruno Wolff III
On Fri, Jun 03, 2005 at 11:28:02 -0400, Tom Lane [EMAIL PROTECTED] wrote: That won't actually work either, because boolin wants cstring: Thanks for pointing that out. I was actually surprised to see my test work, since I knew boolin expected cstring. I forgot that by not providing a type