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

From Pavel Stehule
Subject Re: [HACKERS] proposal: schema variables
Date
Msg-id CAFj8pRBfb-GTZSHSRVTpMzGr26-7e-_RmOmRpmuk+xuDTgC=mA@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] proposal: schema variables  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: [HACKERS] proposal: schema variables  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: [HACKERS] proposal: schema variables  (Gilles Darold <gilles.darold@dalibo.com>)
List pgsql-hackers
Hi

I wrote proof concept of schema variables. The patch is not nice, but the functionality is almost complete (for scalars only) and can be good enough for playing with this concept.

I recap a goals (the order is random):

1. feature like PL/SQL package variables (with similar content life cycle)
2. available from any PL used by PostgreSQL, data can be shared between different PL
3. possibility to store short life data in fast secured storage
4. possibility to pass parameters and results to/from anonymous blocks
5. session variables with possibility to process static code check
6. multiple API available from different environments - SQL commands, SQL functions, internal functions
7. data are stored in binary form

Example:

CREATE VARIABLE public.foo AS integer;

LET foo = 10 + 20;

DO $$
declare x int = random() * 1000;
BEGIN
  RAISE NOTICE '%', foo;
  LET foo = x + 100;
END;
$$;

SELECT public.foo + 10;
SELECT * FROM data WHERE col = foo;

All implemented features are described by regress tests

Interesting note - it is running without any modification of plpgsql code.

Regards

Pavel
Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Boolean partitions syntax
Next
From: Tom Lane
Date:
Subject: Draft release notes for 10.2 et al