Re: [HACKERS] proposal: schema variables - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: [HACKERS] proposal: schema variables
Date
Msg-id CAFj8pRC3Eq1xGZ9F7LsqXnyh_851EL7ReoZfE0BxJm4GFVMk7w@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] proposal: schema variables  (Mark Dilger <hornschnorter@gmail.com>)
List pgsql-hackers


2017-11-01 19:03 GMT+01:00 Mark Dilger <hornschnorter@gmail.com>:

> Comments, notes?

How would variables behave on transaction rollback?

CREATE TEMP VARIABLE myvar;
SET myvar := 1;
BEGIN;
SET myvar := 2;
COMMIT;
BEGIN;
SET myvar := 3;
ROLLBACK;
SELECT myvar;

How would variables behave when modified in a procedure
that aborts rather than returning cleanly?


The result is 3

When you create variable like you did, then there are not any relation between variable content and transactions. Almost every where session - package - schema variables are untransactional. It can be changed, but with negative impact on performance - so I propose relative simply solution - reset to default on rollback, when variables was changed in transaction - but it is not default behave.

Variables are variables like you know from PlpgSQL. But the holder is not the plpgsql function. The holder is a schema in this case. The variable (meta) is permanent. The content of variable is session based untransactional.

Regards

Pavel


mark

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] [PATCH] Pageinspect - add functions on GIN and GiSTindexes from gevel
Next
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] Custom compression methods