comparing null value in plpgsql. - Mailing list pgsql-bugs

From Bhuvan A
Subject comparing null value in plpgsql.
Date
Msg-id Pine.LNX.4.20.0203111029130.23906-100000@Larry
Whole thread Raw
Responses Re: comparing null value in plpgsql.
List pgsql-bugs
hi,

here i have a problem in comparing null values in plpgsql. this exist
in 7.1.x and 7.2 as well.

the condition <null value> != <valid value> fails in plpgsql.
consider this function is triggered on every updation on a table.

  create function ftest()
  returns opaque as 'declare

  begin

    if new.comp_code != old.comp_code then
      ...
    end if;
    return new;
  end;'
  language 'plpgsql';

this condition fails if old.comp_code is null and new.comp_code has
some value.

to overcome this, i am practicing..

  create function ftest()
  returns opaque as 'declare

  begin

    if  new.comp_code is not null and
        old.comp_code is null then
        ...
    else if new.comp_code != old.comp_code then
      ...
    end if;
    end if;

    return new;
  end;'
  language 'plpgsql';

is it really a bug or i am wrong? let me know. if its a bug, when can we
expect the fix?

kindly apologize if it has been already discussed.

Regards,
Bhuvaneswaran.

pgsql-bugs by date:

Previous
From: Peter T Mount
Date:
Subject: Fwd: Bug in getTimestamp() of PostgreSQL JDBC driver?
Next
From: Stephan Szabo
Date:
Subject: Re: comparing null value in plpgsql.