Re: plpgsql bug: `EXECUTE(sql_command) INTO rec` returns sometimes a NULL-able, sometimes not

From: Manuel Pradal <manuel(dot)pradal(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: plpgsql bug: `EXECUTE(sql_command) INTO rec` returns sometimes a NULL-able, sometimes not
Date: 2017-04-24 17:09:21
Message-ID: CABsmV8j4GSR+yuQ7_PUO_+0m-R5+HBsx6P9vtTRoevq0Tw_kNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)stehule(at)gmail(dot)com>:

>
>
> 2017-04-24 17:48 GMT+02:00 Manuel Pradal <manuel(dot)pradal(at)gmail(dot)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
>
> https://www.postgresql.org/docs/current/static//plpgsql-
> statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
>
> Regards
>
> Pavel
>
>
>
>> Thank you in advance!
>>
>> Manuel PRADAL
>>
>>
>> --
>> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-bugs
>>
>>
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2017-04-24 17:19:35 Re: plpgsql bug: `EXECUTE(sql_command) INTO rec` returns sometimes a NULL-able, sometimes not
Previous Message Pavel Stehule 2017-04-24 16:53:25 Re: plpgsql bug: `EXECUTE(sql_command) INTO rec` returns sometimes a NULL-able, sometimes not