X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 45708D1CB99 for ; Wed, 1 Oct 2003 03:27:56 +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 20556-06 for ; Wed, 1 Oct 2003 00:27:09 -0300 (ADT) Received: from www.postgresql.com (unknown [64.117.225.209]) by svr1.postgresql.org (Postfix) with ESMTP id CA9E3D1DB74 for ; Tue, 30 Sep 2003 23:22:44 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by www.postgresql.com (Postfix) with ESMTP id B706CCF8467 for ; Tue, 30 Sep 2003 19:26:49 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id h8UMQq6c023398; Tue, 30 Sep 2003 18:26:53 -0400 (EDT) To: Jan Wieck Cc: pgsql-hackers@postgresql.org Subject: Re: [SQL] plpgsql doesn't coerce boolean expressions to In-reply-to: <9351.1064764963@sss.pgh.pa.us> References: <15403.1063035632@sss.pgh.pa.us> <3F5E0A5D.2010803@Yahoo.com> <3559.1063128729@sss.pgh.pa.us> <3F5E84CF.6090706@Yahoo.com> <3487.1064712513@sss.pgh.pa.us> <3F765672.2020304@Yahoo.com> <9351.1064764963@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sun, 28 Sep 2003 12:02:43 -0400" Date: Tue, 30 Sep 2003 18:26:52 -0400 Message-ID: <23397.1064960812@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/17 X-Sequence-Number: 44699 I said: > If we want to preserve this behavior for IF et al, I don't think there > is any practical way to apply SQL-level type coercion as I had wanted. > We could instead make the code act like it's assigning to a plpgsql > boolean variable --- but it will apply plpgsql's textual conversion > methods, not SQL type coercion. I have now written and tested the patch for this --- it's doing what I originally called option 3: >>> 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.) Unless someone objects, I'll commit this. regards, tom lane