Re: Schema variables - new implementation for Postgres 15 - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: Schema variables - new implementation for Postgres 15
Date
Msg-id CAFj8pRD03hwZK+541KDt4Eo5YuC81CBBX_P0Sa5A7g5TQFsTww@mail.gmail.com
Whole thread Raw
In response to Re: Schema variables - new implementation for Postgres 15  (Marcos Pegoraro <marcos@f10.com.br>)
List pgsql-hackers


pá 14. 1. 2022 v 11:49 odesílatel Marcos Pegoraro <marcos@f10.com.br> napsal:
For example, if I define a variable called "relkind", then psql's \sv
meta-command is broken because the query it performs can't distinguish
between the column and the variable.

If variables use : as prefix you´ll never have these conflicts.

select relkind from pg_class where relkind = :relkind

This syntax is used for client side variables already.

This is similar to MSSQL or MySQL philosophy. But the disadvantage of this method is the impossibility of modularization - all variables are in one space (although there are nested scopes).

The different syntax disallows any collision well, it is far to what is more usual standard in this area. And if we introduce special syntax, then there is no way back. We cannot use :varname - this syntax is used already, but we can use, theoretically, @var or $var. But, personally, I don't want to use it, if there is possibility to do without it. The special syntax can be used maybe for direct access to function arguments, or for not persistent (temporal) session variables like MSSQL. There is a relatively big space of functionality for session variables, and the system that I used is based on ANSI SQL/PSM or DB2 and it is near to Oracle. It has a lot of advantages for writing stored procedures. On other hand, for adhoc work the session variables like MySQL (without declaration) can be handy, so I don't want to use (and block) syntax that can be used for something different.




 

pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: Schema variables - new implementation for Postgres 15
Next
From: Amit Kapila
Date:
Subject: Re: row filtering for logical replication