Re: proposal: schema PL session variables

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Marko Tiikkaja <marko(at)joh(dot)to>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Oleg Bartunov <obartunov(at)gmail(dot)com>
Subject: Re: proposal: schema PL session variables
Date: 2016-02-08 13:16:30
Message-ID: CAFj8pRCqFRVPvJ=1pVfKKyzc5QVgpgX-tzB=in4MSf21En-uBg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2016-02-08 13:53 GMT+01:00 Marko Tiikkaja <marko(at)joh(dot)to>:

> On 08/02/16 13:41, Pavel Stehule wrote:
>
>> 2016-02-08 13:22 GMT+01:00 Marko Tiikkaja <marko(at)joh(dot)to>:
>>
>>> Personally I find that undesirable. I don't know what oracle does, but
>>> variables being visible without schema-qualifying them can introduce
>>> variable conflicts in PL/PgSQL. I'd prefer if you could only refer to
>>> them
>>> by prefixing them with the schema name (or maybe allow search_path to be
>>> used).
>>>
>>
>> I hope so there are not new conflicts - schema variable is not directly
>> visible from SQL (in this iteration) - they are visible only from
>> functions
>> - and the behave is same like global plpgsql variable. So schema variable
>> can be in conflict with SQL identifier only exactly identically as plpgsql
>> variable
>>
>
> Yeah, and that's exactly what I don't want, because that means that CREATE
> SCHEMA VARIABLE suddenly breaks existing code.
>

theoretically yes, but this conflict can be 100% detected - so no quiet bug
is possible, and plpgsql_check can find this issue well. If you don't use
schema variable, then your code will be correct. You have to explicitly
create the variable, and if there will be any problem, then the problem
will be only in PL functions in one schema. And you can identify it by
statical analyse.

>
> But prefix can be used.
>>
>
> Sure, but I don't see the point. Is there a reason not to require such
> variable references to be prefixed with the schema name? Or explicitly
> bring them into scope in the DECLARE section somehow.
>

we can define any rules, but I see better to be consistent with current
variables design. I don't prefer any mandatory prefixes when it is not
necessary.

explicit safe prefixing can be used by developers "_" local variable, "__"
schema variable.

I though about DECLARE section too. But more declarations, more copy/paste
or different bugs, and these bugs can be worse detected by static analyse.

>
>
> .m
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2016-02-08 13:30:38 Re: proposal: schema PL session variables
Previous Message Michael Paquier 2016-02-08 13:11:19 Re: pgbench stats per script & other stuff