Re: [BUGS] plpgsql bug: `EXECUTE(sql_command) INTO rec` returnssometimes a NULL-able, sometimes not - Mailing list pgsql-bugs

From Manuel Pradal
Subject Re: [BUGS] plpgsql bug: `EXECUTE(sql_command) INTO rec` returnssometimes a NULL-able, sometimes not
Date
Msg-id CABsmV8j4GSR+yuQ7_PUO_+0m-R5+HBsx6P9vtTRoevq0Tw_kNg@mail.gmail.com
Whole thread Raw
In response to Re: [BUGS] plpgsql bug: `EXECUTE(sql_command) INTO rec` returnssometimes a NULL-able, sometimes not  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-bugs
Hi Pavel,

Thanks for your quick answer.
I sent you in the attached file of previous email an example (note that I'm running version 9.3).
When I use "*" in the SELECT statement ("test_record1" function), "rec IS NOT NULL" returns TRUE ("test_record2" function), whereas when I explicit "id", "rec IS NOT NULL" returns FALSE.
In the both cases there is a row in the table.
I just want to know if this behavious is normal or not!

Thanks!

Manuel

2017-04-24 18:53 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:


2017-04-24 17:48 GMT+02:00 Manuel Pradal <manuel.pradal@gmail.com>:
Hi,

Using PL/SQL language, I saw a strange behavior using "EXECUTE(sql_command) INTO", then "IF rec IS NOT NULL THEN" statement.
It seems that record content infers with existence test of whole record.

You can see in attached file the possible bug in action.

Should I use "IF NOT FOUND" syntax? Is it more reliable?

The result should be NULL - but test on NULL is true, only when all fields are NULL. Can you send some examples?

you should to use GET DIAGNOSTICS statement. Variable FOUND is not related to dynamic SQL


Regards

Pavel



Thank you in advance!

Manuel PRADAL


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



pgsql-bugs by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: [BUGS] plpgsql bug: `EXECUTE(sql_command) INTO rec` returnssometimes a NULL-able, sometimes not
Next
From: "David G. Johnston"
Date:
Subject: Re: [BUGS] plpgsql bug: `EXECUTE(sql_command) INTO rec` returnssometimes a NULL-able, sometimes not