0

I have table "Table1" and SQL procedure "testProc" which accepts argument of type "Table1". When this procedure gets invoked like this:

select testProc(t.*) from Table1 t; 

is PostgreSQL internally using pointers for passing that argument? Or is it copied in memory for each row?

Thanks!

1 Answer 1

1

There are two distinct cases here, one must involve a copy, and the second must involve pointers.

In the case you are mentioning a copy is made. You can test this like so:

create function test_test(inout test test) returns test as 
$$
begin
   $1.test := $1.test + 1;
   return;
end;
$$ language plpgsql;

select (test_test(t)).test, (test_test(t)).test from test t;

where test.test is an integer. The numbers will be the same.

The second is in triggers, where modifying NEW will be passed to the next trigger. These must be passed by reference.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.