Re: A question about PL/pgSQL DECLAREd variable behavior

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
Cc: Dane Foster <studdugie(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: A question about PL/pgSQL DECLAREd variable behavior
Date: 2015-10-23 16:24:50
Message-ID: CAFj8pRDHDc-9ut80XyiRYCcgmSJuzvfCSM+CuU1CKS=H2fSsAQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2015-10-23 18:05 GMT+02:00 Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>:

> On 10/22/15 8:52 PM, Dane Foster wrote:
>
>> It just occurred to me that another option, for my specific example,
>> would be to record/cache FOUND instead of testing the RECORD variable
>> for its NULLness. Unless of course assigning FOUND to a variable is a
>> pass-by-reference assignment, which in the actual code that I'm writing
>> would be problematic because FOUND is set many times because there are
>> at least 4 SQL commands that my function executes.
>>
>
> AFAIK, functions don't really do pass by reference, except for INOUT
> parameters. In any case, FOUND is definitely reset when you do things like
> SELECT INTO.
>

Anytime parameters are passed by value. OUT variables are emulated via
dynamic composite types. After execution of any SQL statement is FOUND
variable refreshed.

Regards

Pavel

> --
> Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
> Experts in Analytics, Data Architecture and PostgreSQL
> Data in Trouble? Get it in Treble! http://BlueTreble.com
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-10-23 16:49:04 Re: strange connection problem.
Previous Message Jim Nasby 2015-10-23 16:05:59 Re: A question about PL/pgSQL DECLAREd variable behavior