From: | Gilles Darold <gilles(dot)darold(at)dalibo(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: proposal: schema variables |
Date: | 2017-10-31 23:02:26 |
Message-ID: | c48dc141-776e-2284-15fa-3863f7b6a1b4@dalibo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-performance |
Le 31/10/2017 à 23:36, Gilles Darold a écrit :
> Le 31/10/2017 à 22:28, srielau a écrit :
>> Pavel,
>>
>> There is no
>> DECLARE TEMP CURSOR
>> or
>> DECLARE TEMP variable in PLpgSQL
>> and
>> CREATE TEMP TABLE has a different meaning from what I understand you
>> envision for variables.
>>
>> But maybe I'm mistaken. Your original post did not describe the entire
>> syntax:
>> CREATE [TEMP] VARIABLE [IF NOT EXISTS] name AS type
>> [ DEFAULT expression ] [[NOT] NULL]
>> [ ON TRANSACTION END { RESET | DROP } ]
>> [ { VOLATILE | STABLE } ];
>>
>> Especially the TEMP is not spelled out and how its presence affects or
>> doesn't ON TRANSACTION END.
>> So may be if you elaborate I understand where you are coming from.
> I think that the TEMP keyword can be removed. If I understand well the
> default scope for variable is the session, every transaction in a
> session will see the same value. For the transaction level, probably the
> reason of the TEMP keyword, I think the [ ON TRANSACTION END { RESET |
> DROP } ] will allow to restrict the scope to this transaction level
> without needing the TEMP keyword. When a variable is created in a
> transaction, it is temporary if "ON TRANSACTION END DROP" is used
> otherwise it will persist after the transaction end. I guess that this
> is the same as using TEMP keyword?
I forgot to say that in the last case the DECLARE statement can be used
so I don't see the reason of this kind of "temporary" variables.
Maybe the variable object like used in DB2 and defined in document :
https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/sqlref/src/tpc/db2z_sql_createvariable.html
could be enough to cover our needs.
--
Gilles Darold
Consultant PostgreSQL
http://dalibo.com - http://dalibo.org
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-10-31 23:05:38 | Re: PostgreSQL 10 parenthesized single-column updates can produce errors |
Previous Message | David G. Johnston | 2017-10-31 22:48:39 | Re: PostgreSQL 10 parenthesized single-column updates can produce errors |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2017-11-01 04:15:58 | Re: proposal: schema variables |
Previous Message | Gilles Darold | 2017-10-31 22:36:53 | Re: proposal: schema variables |