X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8192A52855 for ; Fri, 3 Jun 2005 10:01:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49115-05 for ; Fri, 3 Jun 2005 13:01:36 +0000 (GMT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id BDB3A5280A for ; Fri, 3 Jun 2005 10:01:34 -0300 (ADT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id j53Ckm9W023560; Fri, 3 Jun 2005 15:46:48 +0300 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id j53CkmvW023556; Fri, 3 Jun 2005 15:46:48 +0300 Date: Fri, 3 Jun 2005 15:46:48 +0300 (EEST) From: Achilleus Mantzios To: Michael Glaesemann Cc: =?UTF-8?Q?Markus_Bertheau_=E2=98=AD?= , PostgreSQL Subject: Re: 'true'::TEXT::BOOLEAN In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/43 X-Sequence-Number: 21644 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 boolean. > > Actually, looking at the system tables, I don't think it is. There > don't appear to be any casts to (or from) boolean. I may be looking > at it wrong, but that's how it appears to me. Corrections, anyone? > > select type_source.typname as source, type_target.typname as target > from pg_cast > join pg_type type_source on (castsource = type_source.oid) > join pg_type type_target on (casttarget = type_target.oid) > where type_target.typname = 'bool' > or type_source.typname = 'bool' > order by type_source.typname; > > source | target > --------+-------- > (0 rows) > > This is in v8.0.3 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 using the CASE expression: CASE WHEN boolval THEN 'value if true' ELSE 'value if false' END." I suppose the reverse must be true also. > > Michael Glaesemann > grzm myrealbox com > > PS. Please don't top post. > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- -Achilleus