Thread: call by reference vs call by value

call by reference vs call by value

From
Michael Moore
Date:
How are variables in pg/psql functions passed? I'm sure this is documented somewhere. I looked but no joy. A link would be great! TIA
Mike

Re: call by reference vs call by value

From
"David G. Johnston"
Date:
On Tue, Dec 8, 2015 at 12:07 PM, Michael Moore <michaeljmoore@gmail.com> wrote:
How are variables in pg/psql functions passed? I'm sure this is documented somewhere. I looked but no joy. A link would be great! TIA

​I doubt its documented anywhere since the concept of "by reference" is not part of the language.  The concept is also not part of SQL.

If you want a better explanation you should provide some code for us to comment upon.

David J.


Re: call by reference vs call by value

From
Michael Moore
Date:
I am trying to translate some Oracle PL/SQL code which has the following signature:
    PROCEDURE dGetQuestionSetKeyOrder
        (pweb_site_name_i          IN               tx_web_site.web_site_name%TYPE,
         p_sid_i                   IN               varchar2, 
         pqs_table_i               IN OUT NOCOPY    XPORTAL_QUESTION_SET_TABLE
        )
"NOCOPY" tells oracle that pqs_table_i is call by reference. I was wondering if pgplsql has a similar mechanism. Apparently not. Thanks!


On Tue, Dec 8, 2015 at 11:15 AM, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tue, Dec 8, 2015 at 12:07 PM, Michael Moore <michaeljmoore@gmail.com> wrote:
How are variables in pg/psql functions passed? I'm sure this is documented somewhere. I looked but no joy. A link would be great! TIA

​I doubt its documented anywhere since the concept of "by reference" is not part of the language.  The concept is also not part of SQL.

If you want a better explanation you should provide some code for us to comment upon.

David J.



Re: call by reference vs call by value

From
Pavel Stehule
Date:
Hi

2015-12-08 20:07 GMT+01:00 Michael Moore <michaeljmoore@gmail.com>:
How are variables in pg/psql functions passed? I'm sure this is documented somewhere. I looked but no joy. A link would be great! TIA

It is simply - small values are passed by value (to 8bytes), bigger are passed as reference - but all is internal and cannot be controlled from user space.
Search keywords "varlena", "datum", "toast"


Regards

Pavel




 
Mike


Re: call by reference vs call by value

From
Pavel Stehule
Date:


2015-12-08 21:25 GMT+01:00 Michael Moore <michaeljmoore@gmail.com>:
I am trying to translate some Oracle PL/SQL code which has the following signature:
    PROCEDURE dGetQuestionSetKeyOrder
        (pweb_site_name_i          IN               tx_web_site.web_site_name%TYPE,
         p_sid_i                   IN               varchar2, 
         pqs_table_i               IN OUT NOCOPY    XPORTAL_QUESTION_SET_TABLE
        )
"NOCOPY" tells oracle that pqs_table_i is call by reference. I was wondering if pgplsql has a similar mechanism. Apparently not. Thanks!

It is totally different - NOCOPY hasn't any sense in Postgres

Pavel
 


On Tue, Dec 8, 2015 at 11:15 AM, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tue, Dec 8, 2015 at 12:07 PM, Michael Moore <michaeljmoore@gmail.com> wrote:
How are variables in pg/psql functions passed? I'm sure this is documented somewhere. I looked but no joy. A link would be great! TIA

​I doubt its documented anywhere since the concept of "by reference" is not part of the language.  The concept is also not part of SQL.

If you want a better explanation you should provide some code for us to comment upon.

David J.




Re: call by reference vs call by value

From
Michael Moore
Date:
Thanks guys.

On Tue, Dec 8, 2015 at 12:31 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2015-12-08 21:25 GMT+01:00 Michael Moore <michaeljmoore@gmail.com>:
I am trying to translate some Oracle PL/SQL code which has the following signature:
    PROCEDURE dGetQuestionSetKeyOrder
        (pweb_site_name_i          IN               tx_web_site.web_site_name%TYPE,
         p_sid_i                   IN               varchar2, 
         pqs_table_i               IN OUT NOCOPY    XPORTAL_QUESTION_SET_TABLE
        )
"NOCOPY" tells oracle that pqs_table_i is call by reference. I was wondering if pgplsql has a similar mechanism. Apparently not. Thanks!

It is totally different - NOCOPY hasn't any sense in Postgres

Pavel
 


On Tue, Dec 8, 2015 at 11:15 AM, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tue, Dec 8, 2015 at 12:07 PM, Michael Moore <michaeljmoore@gmail.com> wrote:
How are variables in pg/psql functions passed? I'm sure this is documented somewhere. I looked but no joy. A link would be great! TIA

​I doubt its documented anywhere since the concept of "by reference" is not part of the language.  The concept is also not part of SQL.

If you want a better explanation you should provide some code for us to comment upon.

David J.