From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | Craig Ringer <craig(at)2ndquadrant(dot)com>, Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>, Joe Conway <mail(at)joeconway(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: session server side variables |
Date: | 2016-12-29 08:36:28 |
Message-ID: | alpine.DEB.2.20.1612290914360.4911@lancre |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello Pavel,
>> Hmmm... I know a little bit about that field, ISTM that you are speaking
>> of the current capabilities of a particular static analysis tool, but I'm
>> not sure that the tool capabilities could not be enhanced to manage more
>> things.
>
> It cannot be - the static analyze is limited to function scope - in static
> analyze you don't know a order of calls.
I have been doing interprocedural static analysis for the last 25 years,
and I can assure you that those techniques are not limited to the scope of
a function. As for global variables, I agree that you may proove more
things about them if you know the order of calls.
>> The private session variables I suggested have a fixed (static) name, and
>> their type could be infered by a static analysis tool, eg:
>> ...
>> DECLARE @foo BOOLEAN PRIVATE;
>> -- I know that there is private a boolean variable "@foo" of unknown
>> value
>> SET @foo = TRUE;
>> --- I know that @foo is true...
>> ...
>
> This is not too friendly
Friendly is subjective. ISTM That it gets the job done with minimal syntax
and implementation. It avoids getter/setter functions which are unfriendly
to me.
> - you have to repeat DECLARE in every function.
That is the same in nearly all programming languages, you have to declare
external variables somehow before using them, that is life.
Some declarations could be avoided if an unknown variable is assumed to
have untyped value NULL by default.
> What is somebody somewhere write @fooo
NULL ? Unkown variable error ?
> or use DECLARE @foo integer instead.
It would not matter if it is someone else, because @foo would be their
private version. If it is yourself, an error could be raised if a session
variable is found to be declared with two distinct types. A static
analysis tool would be able to detect that as well.
> There is big space for errors.
Whatever the features and syntax, you can always shoot yourself in the
foot.
I have open a wiki page to help with this discussion:
https://wiki.postgresql.org/wiki/Variable_Design
--
Fabien.
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2016-12-29 08:46:42 | Re: proposal: session server side variables |
Previous Message | Fabien COELHO | 2016-12-29 08:11:22 | Re: proposal: session server side variables |