X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C228FD1B544; Tue, 9 Sep 2003 17:32:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 41574-10; Tue, 9 Sep 2003 14:32:14 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 844C2D1B54E; Tue, 9 Sep 2003 14:32:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h89HW9An003560; Tue, 9 Sep 2003 13:32:09 -0400 (EDT) To: Jan Wieck Cc: pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [HACKERS] plpgsql doesn't coerce boolean expressions to boolean In-reply-to: <3F5E0A5D.2010803@Yahoo.com> References: <15403.1063035632@sss.pgh.pa.us> <3F5E0A5D.2010803@Yahoo.com> Comments: In-reply-to Jan Wieck message dated "Tue, 09 Sep 2003 13:14:05 -0400" Date: Tue, 09 Sep 2003 13:32:09 -0400 Message-ID: <3559.1063128729@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/66 X-Sequence-Number: 15044 Jan Wieck writes: > ERROR is the cleanest way, but I'd vote for conversion to boolean to > keep the damage within reason. Which style of conversion did you like? These were the choices: >> 3. Try to convert nonbooleans to boolean using plpgsql's usual method >> for cross-type coercion, ie run the type's output proc to get a >> string and feed it to bool's input proc. (This seems unlikely to >> avoid throwing an error in very many cases, but it'd be the most >> consistent with other parts of plpgsql.) >> >> 4. Use the parser's coerce_to_boolean procedure, so that nonbooleans >> will be accepted in exactly the same cases where they'd be accepted >> in a boolean-requiring SQL construct (such as CASE). (By default, >> none are, so this isn't really different from #2. But people could >> create casts to boolean to override this behavior in a controlled >> fashion.) At this point I'm kinda leaning to #4, because (for example) people could create a cast from integer to boolean to avoid having to fix their plpgsql functions right away. #3 would not offer any configurability of behavior. regards, tom lane