Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] plPGSQL bug in function creation

From: Richard Huxton <dev(at)archonet(dot)com>
To: <newsy(at)lewczuk(dot)com>,"Lista dyskusyjna pgsql-general" <pgsql-general(at)postgresql(dot)org>,"Lista dyskusyjna pgsql-sql" <pgsql-sql(at)postgresql(dot)org>,"Lista dyskusyjna pgsql-bugs" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [GENERAL] plPGSQL bug in function creation
Date: 2003-09-08 12:09:16
Message-ID: 200309081309.16255.dev@archonet.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-generalpgsql-sql
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

In response to

Responses

pgsql-sql by date

Next:From: George WeaverDate: 2003-09-08 12:41:30
Subject: Re: [SQL] [GENERAL] plPGSQL bug in function creation
Previous:From: Marek LewczukDate: 2003-09-08 08:32:28
Subject: plPGSQL bug in function creation

pgsql-bugs by date

Next:From: George WeaverDate: 2003-09-08 12:41:30
Subject: Re: [SQL] [GENERAL] plPGSQL bug in function creation
Previous:From: A.BhuvaneswaranDate: 2003-09-08 11:37:20
Subject: heap_mark4update: (am)invalid tid

pgsql-general by date

Next:From: George WeaverDate: 2003-09-08 12:41:30
Subject: Re: [SQL] [GENERAL] plPGSQL bug in function creation
Previous:From: ohpDate: 2003-09-08 10:54:52
Subject: Re: Unixware 713 probs

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group