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

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Manuel Pradal <manuel(dot)pradal(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 16:53:25
Message-ID: CAFj8pRBE25f75ZiuMLoGh5Xod+zzePqH-s0f3x9rN-H1P3Jomw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Manuel Pradal 2017-04-24 17:09:21 Re: plpgsql bug: `EXECUTE(sql_command) INTO rec` returns sometimes a NULL-able, sometimes not
Previous Message Manuel Pradal 2017-04-24 15:48:25 plpgsql bug: `EXECUTE(sql_command) INTO rec` returns sometimes a NULL-able, sometimes not