From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
Cc: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Erik Rijkers <er(at)xs4all(dot)nl>, Michael Paquier <michael(at)paquier(dot)xyz>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, DUVAL REMI <REMI(dot)DUVAL(at)cheops(dot)fr>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: proposal: schema variables |
Date: | 2024-11-19 19:14:01 |
Message-ID: | CAFj8pRB_E1GM_YGT-ti4bXka6mhLdAAFeTe+BHgHFYC+qb-76g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-performance |
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
From | Date | Subject | |
---|---|---|---|
Next Message | James Coleman | 2024-11-19 19:16:59 | Parallel safety docs for CTEs |
Previous Message | Peter Geoghegan | 2024-11-19 19:06:35 | Re: Adding skip scan (including MDAM style range skip scan) to nbtree |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2024-11-19 21:30:00 | Re: proposal: schema variables |
Previous Message | Pavel Stehule | 2024-11-17 04:53:17 | Re: proposal: schema variables |