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

8.3 PLpgSQL Can't Compare Records?

From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: 8.3 PLpgSQL Can't Compare Records?
Date: 2009-07-01 17:35:10
Message-ID: 87842292-834B-4CF4-B56B-88EB4A30F7E4@kineticode.com (view raw or flat)
Thread:
Lists: pgsql-hackers
This code:

     CREATE OR REPLACE FUNCTION foo() returns boolean as $$
     DECLARE
         have_rec record;
         want_rec record;
     BEGIN
         have_rec := row(1, 2);
         want_rec := row(3, 5);
         RETURN have_rec IS DISTINCT FROM want_rec;
     END;
     $$ language plpgsql;

     SELECT ROW(1, 2) IS DISTINCT FROM ROW(3, 5);

     SELECT foo();
     DROP FUNCTION foo();

Works as expected on 8.4, outputting:

      ?column?
     ----------
      t
     (1 row)

     Time: 48.626 ms
      foo
     -----
      t
     (1 row)

On 8.3, however, the row comparisons in the SQL statement works, but  
fails in the PL/pgSQL function, with this output:

      ?column?
     ----------
      t
     (1 row)

     psql:huh.sql:14: ERROR:  operator does not exist: record = record
     LINE 1: SELECT   $1  IS DISTINCT FROM  $2
                          ^
     HINT:  No operator matches the given name and argument type(s).  
You might need to add explicit type casts.
     QUERY:  SELECT   $1  IS DISTINCT FROM  $2
     CONTEXT:  PL/pgSQL function "foo" line 7 at RETURN


Is this a known issue in 8.3? If so, is there a known workaround?

Thanks,

David

Responses

pgsql-hackers by date

Next:From: Kevin GrittnerDate: 2009-07-01 17:39:19
Subject: Re: 8.5 development schedule
Previous:From: Bruce MomjianDate: 2009-07-01 17:33:31
Subject: Re: 8.5 development schedule

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