Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1evPXG-0001Q7-9d for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Mar 2018 15:38:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1evPXF-00068d-5K for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Mar 2018 15:38:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1evPXE-00068E-Nb for pgsql-hackers@lists.postgresql.org; Mon, 12 Mar 2018 15:38:48 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1evPX7-0001N7-Ed for pgsql-hackers@postgresql.org; Mon, 12 Mar 2018 15:38:48 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 8D18B21C05F4; Mon, 12 Mar 2018 18:38:40 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.41] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 3818621C04FE; Mon, 12 Mar 2018 18:38:40 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1520869120; bh=DRFUg9XATor6yN1QkXIeGHzDUBsW1qL4I2ZpYYLIKec=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=omI3NK3rqo+xTsNDymInOegZHzQP/TRukyUCz6E0xwyNYzFhwnw7bmUsuL0kq+4fY csQDNiZHWET5JTO910Wt1/523FbWULxWuL5tEshWaP+TUK8hhzSbuwkmb8U79HTSSq IvFiq9TUBxoCY6FPYt1x4W/3ndCrfo6ShukzjC/E= Subject: Re: [HACKERS] proposal: schema variables To: Pavel Stehule Cc: "David G. Johnston" , Pavel Golub , PostgreSQL Hackers References: <623395617.20171113141500@gf.microolap.com> From: Pavel Luzanov Message-ID: Date: Mon, 12 Mar 2018 18:38:39 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------FFA0A37FC97E557C3F4338B0" Content-Language: ru-RU List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------FFA0A37FC97E557C3F4338B0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 12.03.2018 09:54, Pavel Stehule wrote: > > 2018-03-12 7:49 GMT+01:00 Pavel Luzanov >: > > > Is there any chances that it will work on replicas? > > ... > > sure, it should to work. Now, I am try to solve a issues on concept > level - the LET code is based on DML code base, so probably there is > check for rw transactions. But it is useless for LET command. 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 --------------FFA0A37FC97E557C3F4338B0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 12.03.2018 09:54, Pavel Stehule wrote:

2018-03-12 7:49 GMT+01:00 Pavel Luzanov <p.luzanov@postgrespro.ru>:

Is there any chances that it will work on replicas?
...

sure, it should to work. Now, I am try to solve a issues on concept level - the LET code is based on DML code base, so probably there is check for rw transactions. But it is useless for LET command.

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
--------------FFA0A37FC97E557C3F4338B0--