Re: PATCH: make plpgsql IN args mutable (v1)

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Steve Prentice <prentice(at)cisco(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: PATCH: make plpgsql IN args mutable (v1)
Date: 2009-07-31 06:57:39
Message-ID: 162867790907302357y2e27bb3bsb278ad51221d55dd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2009/7/30 Steve Prentice <prentice(at)cisco(dot)com>:
> Since I didn't get completely shot out of the water and a couple people
> seemed to think it was helpful, I'm submitting this patch for consideration
> in the next commitfest.
>
> This patch changes plpgsql IN parameters so they are mutable. Previously,
> they were being forced constant. This patch modifies the plpgsql.sql
> regression test and corresponding .out file. The regression test also makes
> sure the passed in parameter does not get changed in the calling function.
>
> I decided not to update the docs for this change because the docs don't
> currently indicate that an IN parameter is constant and I didn't want to
> encourage it because it isn't universally considered good programming
> practice to assign to an IN parameter. If others think we need a doc change
> for this, I'll update the patch.
>
> The following function will compile with this patch:
>
>  create or replace function param_assign_test(a int, val int) returns void
> as $$
>  begin
>    a := val;
>  end
>  $$ language plpgsql;
>

This behave is in conflict with PL/SQL, what should do some problems.
I thing, so I understand well, why this behave is in PL/SQL. It hasn't
sense in plpgsql, because OUT and INOUT params has little bit
different syntax (calling) and nobody will do similar bugs (perhaps).
What is interesting - this behave is in conformity with SQL/PSM, where
parameters are mutable too.

I am for it. PL/pgSQL doesn't promise compatibility with PL/SQL and
this change should to help some beginners (and this limit is
artificial and unnecessary).

Regards
Pavel Stehule

> This function would have failed to compile previously.
>
> -Steve
>
>
>
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message KaiGai Kohei 2009-07-31 07:19:46 Re: [PATCH] [v8.5] Security checks on largeobjects
Previous Message Pavel Stehule 2009-07-31 06:04:14 Re: mixed, named notation support