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 20C7ED1B4E3 for ; Wed, 10 Sep 2003 02:01:44 +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 36822-05 for ; Tue, 9 Sep 2003 23:01:15 -0300 (ADT) Received: from smtp014.mail.yahoo.com (smtp014.mail.yahoo.com [216.136.173.58]) by svr1.postgresql.org (Postfix) with SMTP id 139CFD1B4EC for ; Tue, 9 Sep 2003 23:01:11 -0300 (ADT) Received: from pcp01341166pcs.wilog301.pa.comcast.net (HELO europa.janwieck.net) (janwieck@68.80.245.191 with login) by smtp.mail.vip.sc5.yahoo.com with SMTP; 10 Sep 2003 02:01:12 -0000 Received: from Yahoo.com (ganymed.janwieck.net [192.168.192.17]) (authenticated) by europa.janwieck.net (8.11.6/8.11.6) with ESMTP id h8A1vq105799; Tue, 9 Sep 2003 21:58:41 -0400 Message-ID: <3F5E84CF.6090706@Yahoo.com> Date: Tue, 09 Sep 2003 21:56:31 -0400 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Jan Wieck , pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [HACKERS] plpgsql doesn't coerce boolean expressions to boolean References: <15403.1063035632@sss.pgh.pa.us> <3F5E0A5D.2010803@Yahoo.com> <3559.1063128729@sss.pgh.pa.us> In-Reply-To: <3559.1063128729@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/77 X-Sequence-Number: 15055 Tom Lane wrote: > 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. Agreed - #4. Thinking of the problem about deprication of features and transition time, it would be nice for this kind of compatibility breaking changes to have a _per database_ config option that controls old vs. new behaviour, wouldn't it? Don't know exactly how you'd like that to be. Maybe with a pg_config catalog that inherits default settings from template1 but can then be changed in every database. This would even include the possibility to *switch* one single prod database back to the old behaviour in case the supposedly cleaned up application isn't as clean as supposed to. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com #