On 12.03.2018 09:54, Pavel Stehule wrote:
Very, very good!
As I understand, the work on this patch now in progress and it not in commitfest.
Please explain what features of schema variables I can review now.
From first post of this thread the syntax of the CREATE VARIABLE command:
CREATE [TEMP] VARIABLE [IF NOT EXISTS] name AS type
[ DEFAULT expression ] [[NOT] NULL] [ ON TRANSACTION END { RESET | DROP } ]
[ { VOLATILE | STABLE } ];
But in psql I see only:
\h create variable
Command: CREATE VARIABLE
Description: define a new permissioned typed schema variable
Syntax:
CREATE VARIABLE [ IF NOT EXISTS ] name [ AS ] data_type ]
I can include DEFAULT clause in CREATE VARIABLE command, but the value not used:
postgres=# create variable i int default 0;
CREATE VARIABLE
postgres=# select i;
i
---
(1 row)
postgres=# \d+ i
schema variable "public.i"
Column | Type | Storage
--------+---------+---------
i | integer | plain
BTW, I found an error in handling of table aliases:
postgres=# create variable x text;
CREATE VARIABLE
postgres=# select * from pg_class AS x where x.relname = 'x';
ERROR: type text is not composite
It thinks that x.relname is an attribute of x variable instead of an alias for pg_class table.
-----
Pavel Luzanov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company