Hi
I wrote POC of VARIABLE(varname) syntax support
here is a copy from regress test
SET session_variables_ambiguity_warning TO on;
SET session_variables_use_fence_warning_guard TO on;
SET search_path TO 'public';
CREATE VARIABLE a AS int;
LET a = 10;
CREATE TABLE test_table(a int, b int);
INSERT INTO test_table VALUES(20, 20);
-- no warning
SELECT a;
a..
----
10
(1 row)
-- warning variable is shadowed
SELECT a, b FROM test_table;
WARNING: session variable "a" is shadowed
LINE 1: SELECT a, b FROM test_table;
^
DETAIL: Session variables can be shadowed by columns, routine's variables and routine's arguments with the same name.
a | b..
----+----
20 | 20
(1 row)
-- no warning
SELECT variable(a) FROM test_table;
a..
----
10
(1 row)
ALTER TABLE test_table DROP COLUMN a;
-- warning - variable fence is not used
SELECT a, b FROM test_table;
WARNING: session variable "a" is not used inside variable fence
LINE 1: SELECT a, b FROM test_table;
^
DETAIL: The collision of session variable' names and column names is possible.
a | b..
----+----
10 | 20
(1 row)
-- no warning
SELECT variable(a), b FROM test_table;
a | b..
----+----
10 | 20
(1 row)
DROP VARIABLE a;
DROP TABLE test_table;
SET session_variables_ambiguity_warning TO DEFAULT;
SET session_variables_use_fence_warning_guard TO DEFAULT;
SET search_path TO DEFAULT;
Regards
Pavel