public inbox for [email protected]
help / color / mirror / Atom feedFrom: Jim Jones <[email protected]>
To: Pavel Stehule <[email protected]>
Cc: Bruce Momjian <[email protected]>
Cc: Dmitry Dolgov <[email protected]>
Cc: Laurenz Albe <[email protected]>
Cc: Erik Rijkers <[email protected]>
Cc: Michael Paquier <[email protected]>
Cc: Amit Kapila <[email protected]>
Cc: DUVAL REMI <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: jian he <[email protected]>
Cc: Alvaro Herrera <[email protected]>
Cc: PegoraroF10 <[email protected]>
Subject: Re: proposal: schema variables
Date: Wed, 3 Dec 2025 14:44:16 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAFj8pRDisL7v_t9-QYqxYOLvdQJCbZBY8hjzXNHMWxqEoVun4g@mail.gmail.com>
References: <CAFj8pRDJ9cq00VYSHxs6LsoHNWjhYXyWWBtV6UgeWwhs0AHa9A@mail.gmail.com>
<[email protected]>
<CAFj8pRBDVrm_Ju9RJe1J1Yhb5BPtOq49cQH7RvQ_ZPuh__Nrcw@mail.gmail.com>
<CAFj8pRAe1BN1iLoVaD4CLtMY4pg2XROVqmU8HngqBaFRhF4zCg@mail.gmail.com>
<CAFj8pRBryCY4LqtrPu9E_mtZYkNfZb64-MetWE0232whdOLgjA@mail.gmail.com>
<CAFj8pRCPjHT8xfnMHRroc_wx4wBT4ocqzjH--jqo0xHqec4qhA@mail.gmail.com>
<CAFj8pRBTmSPUPET-Jo=REsLLx15kmHqYXmXwL2BKLeZjZqUUEg@mail.gmail.com>
<CAFj8pRAOTQ5BkKvCFHkUE=HWzirZhVzxE5iugbcOsz=z5R0ogA@mail.gmail.com>
<CAFj8pRDmCF05tVDbzkwL45WHLhdZnbkQLn9HA3RA-5LGu=wEXg@mail.gmail.com>
<CAFj8pRCACo9_fwfe3ixgrRfThon+Nu26b1phd-ge7v5XCx4=9A@mail.gmail.com>
<CAFj8pRDNBHEf2nrU3Xx3S-Vmtj+YUiGxc0CV78u7uwbxXP_acw@mail.gmail.com>
<CAFj8pRAnWR5TV=kRu9L-xUUkxoeoWUXDKS_Qixfqj4YptjGUsA@mail.gmail.com>
<CAFj8pRBHjSEE3A500MLyOPQogqaYGu=XVKvq4LnSnuHsFSxeJg@mail.gmail.com>
<CAFj8pRDisL7v_t9-QYqxYOLvdQJCbZBY8hjzXNHMWxqEoVun4g@mail.gmail.com>
Hi Pavel
On 03/12/2025 05:27, Pavel Stehule wrote:
> Hi
>
> fresh rebase after a87987cafca683e9076c424f99bae117211a83a4
I'm going through the patch again and have a few initial comments.
== Memory Management ==
DROP VARIABLE seems to be leaking memory:
postgres=# CREATE TEMPORARY VARIABLE var AS text;
CREATE VARIABLE
postgres=# LET var = repeat('🐘', 100000000);
LET
postgres=# SELECT pg_size_pretty(used_bytes)
FROM pg_backend_memory_contexts
WHERE name = 'session variables';
pg_size_pretty
----------------
381 MB
(1 row)
postgres=# DROP VARIABLE var;
DROP VARIABLE
postgres=# SELECT pg_size_pretty(used_bytes)
FROM pg_backend_memory_contexts
WHERE name = 'session variables';
pg_size_pretty
----------------
381 MB
(1 row)
If we simply set the variable to NULL it works as expected:
postgres=# LET var = repeat('🐘', 100000000);
LET
postgres=# SELECT pg_size_pretty(used_bytes)
FROM pg_backend_memory_contexts
WHERE name = 'session variables';
pg_size_pretty
----------------
381 MB
(1 row)
postgres=# LET var = NULL;
LET
postgres=# SELECT pg_size_pretty(used_bytes)
FROM pg_backend_memory_contexts
WHERE name = 'session variables';
pg_size_pretty
----------------
240 bytes
(1 row)
Most likely you forgot to pfree "svar->value" at DropVariableByName(), e.g.
void
DropVariableByName(char *varname)
{
...
if (!svar->typbyval && !svar->isnull)
pfree(DatumGetPointer(svar->value));
(void) hash_search(sessionvars,
varname,
HASH_REMOVE,
NULL);
}
== TAB completion ==
Why suggest CREATE VARIABLE (non-temporary) if it is not supported?
postgres=# CREATE V<TAB>
VARIABLE VIEW
postgres=# CREATE VARIABLE var AS int;
ERROR: only temporal session variables are supported
It would be nice to have tab completion for DROP VARIABLE and LET as well:
postgres=# DROP VARIABLE <TAB>
postgres=# LET <TAB>
== Missing IF EXISTS in DROP VARIABLE ==
DROP VARIABLE IF EXISTS var;
ERROR: syntax error at or near "EXISTS"
LINE 1: DROP VARIABLE IF EXISTS var;
^
Best, Jim
view thread (439+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: proposal: schema variables
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox