X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5FEB7D1B502; Mon, 8 Sep 2003 12:09:54 +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 27139-09; Mon, 8 Sep 2003 09:09:25 -0300 (ADT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by svr1.postgresql.org (Postfix) with ESMTP id 941C6D1B4F5; Mon, 8 Sep 2003 09:09:16 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 19wKpa-0001rF-0W; Mon, 08 Sep 2003 13:09:19 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id BDBFB168B5; Mon, 8 Sep 2003 13:09:17 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 0C804168B4; Mon, 8 Sep 2003 13:09:17 +0100 (BST) From: Richard Huxton To: , "Lista dyskusyjna pgsql-general" , "Lista dyskusyjna pgsql-sql" , "Lista dyskusyjna pgsql-bugs" Subject: Re: [GENERAL] plPGSQL bug in function creation Date: Mon, 8 Sep 2003 13:09:16 +0100 User-Agent: KMail/1.5 References: <004901c375e3$bd31f660$4701a8c0@marek> In-Reply-To: <004901c375e3$bd31f660$4701a8c0@marek> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200309081309.16255.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/86 X-Sequence-Number: 6717 On Monday 08 September 2003 09:32, Marek Lewczuk wrote: > Hello, > I think that there is a bug in plPGSQL - or maybe I don't know something > about this language. Try to create this function [snip] > And when i execute: SELECT test(NULL, 'buuu'); -> it returns me NULL > value, when it should return "buuu". Well I think that something is > wrong here. > > If I will modify this function again to this: > > CREATE FUNCTION "public"."test" (varchar, varchar) RETURNS text AS' [snip] > Everything is working OK.. So the problem is in TEXT type definition. > > I'm using PG 7.3.1 on Win/Cyg Can't reproduce here: CREATE OR REPLACE FUNCTION functest1(varchar, varchar) RETURNS varchar AS ' BEGIN IF $1 THEN RETURN $1; ELSE RETURN $2; END IF; END; 'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; CREATE OR REPLACE FUNCTION functest2(text, text) RETURNS varchar AS ' BEGIN IF $1 THEN RETURN $1; ELSE RETURN $2; END IF; END; 'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; SELECT functest1('A','B'), functest1(null,'B'), functest2('A','B'), functest2(null,'B'); CREATE FUNCTION CREATE FUNCTION functest1 | functest1 | functest2 | functest2 -----------+-----------+-----------+----------- A | B | A | B (1 row) richardh=# select version(); version ------------------------------------------------------------- PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.96 Not sure whether this is because of the change 7.3.1->7.3.2 or cygwin vs linux. Don't have a copy of 7.3.1 to check against, sorry. Perhaps check the changes list to see if it mentions something like this. -- Richard Huxton Archonet Ltd