public inbox for pgsql-performance@postgresql.org  
help / color / mirror / Atom feed
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Pavel Luzanov <p.luzanov@postgrespro.ru>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Pavel Golub <pavel@gf.microolap.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] proposal: schema variables
Date: Tue, 20 Mar 2018 18:38:47 +0100
Message-ID: <CAFj8pRAHK-6fPiyBGtTCjm4EOXc5ixgjL5ji5933cV3sS58nrQ@mail.gmail.com> (raw)
In-Reply-To: <CAFj8pRAY1KL-yA+ENCdOv+iJgVua773B_rq+Q=gkeUWg5yoLMA@mail.gmail.com>
References: <CAFj8pRDY+m9OOxfO10R7J0PAkCCauM-TweaTrdsrsLGMb1VbEQ@mail.gmail.com>
	<623395617.20171113141500@gf.microolap.com>
	<CAFj8pRDdS7ViLBJ6eA93u=C_x15EBv2deiNQDGkBS=LNrjzLLw@mail.gmail.com>
	<CAFj8pRBfb-GTZSHSRVTpMzGr26-7e-_RmOmRpmuk+xuDTgC=mA@mail.gmail.com>
	<CAKFQuwa00-4HTujbnYNy_OdZ2OfjUO3AX4R91DbQ1wPBZegCfg@mail.gmail.com>
	<CAFj8pRBchBfyPKAVPnJKhDjh7r6kTJ9L1=etMt-pjdDzpsKOUA@mail.gmail.com>
	<CAFj8pRCTsxzsxX1cWgX3cjqsSZb=gqOMd3-2FdbGz5a2+shGMg@mail.gmail.com>
	<CAFj8pRA6YWwV=sZj5iSgDUixr-S+u9W2+v0BJqqxHQDXS2oZww@mail.gmail.com>
	<dde8f23f-a15f-e88b-482e-5c26cce14cca@postgrespro.ru>
	<CAFj8pRDLBtPM9PAVx-VFtLyZJktKL5R4hX4V4O4KvcyjbOPRbw@mail.gmail.com>
	<ef39f19b-9d5c-78d1-6afa-adbe1288a20b@postgrespro.ru>
	<CAFj8pRAY1KL-yA+ENCdOv+iJgVua773B_rq+Q=gkeUWg5yoLMA@mail.gmail.com>

Hi

I am sending new update. The code is less ugly, and the current
functionality is +/- final for first stage. It should be good enough for
playing and testing this concept.

What is supported:

1. scalar, composite and array variables
2. composite can be defined on place or some composite type can be used
3. variable, or any field of variable, can have defined default value
4. variable is database object - the access rights are required
5. the values are stored in binary form with defined typmod

An usage is very simple:

postgres=# create variable foo as numeric default 0;
CREATE VARIABLE
postgres=# select foo;
┌─────┐
│ foo │
╞═════╡
│   0 │
└─────┘
(1 row)

postgres=# let foo = pi();
LET
postgres=# select foo;
┌──────────────────┐
│       foo        │
╞══════════════════╡
│ 3.14159265358979 │
└──────────────────┘
(1 row)

postgres=# create variable boo as (x numeric default 0, y numeric default
0);
CREATE VARIABLE
postgres=# let boo.x = 100;
LET
postgres=# select boo;
┌─────────┐
│   boo   │
╞═════════╡
│ (100,0) │
└─────────┘
(1 row)

postgres=# select boo.x;
┌─────┐
│  x  │
╞═════╡
│ 100 │
└─────┘
(1 row)

Please try it.

Regards

Pavel


Attachments:

  [application/octet-stream] schema-variables-poc-180320-01-diff (174.0K, 3-schema-variables-poc-180320-01-diff)
  download

  [application/octet-stream] schema_variables.out (8.6K, 4-schema_variables.out)
  download

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: pavel.stehule@gmail.com, p.luzanov@postgrespro.ru, david.g.johnston@gmail.com, pavel@gf.microolap.com, pgsql-hackers@postgresql.org
  Subject: Re: [HACKERS] proposal: schema variables
  In-Reply-To: <CAFj8pRAHK-6fPiyBGtTCjm4EOXc5ixgjL5ji5933cV3sS58nrQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox