Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uHcLK-005tcB-HI for pgsql-hackers@arkaria.postgresql.org; Wed, 21 May 2025 05:50:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uHcLJ-003A9o-F4 for pgsql-hackers@arkaria.postgresql.org; Wed, 21 May 2025 05:50:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uHcLJ-003A9R-4U for pgsql-hackers@lists.postgresql.org; Wed, 21 May 2025 05:50:17 +0000 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uHcLG-0004iv-1U for pgsql-hackers@lists.postgresql.org; Wed, 21 May 2025 05:50:16 +0000 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-70dfa8424c7so511007b3.2 for ; Tue, 20 May 2025 22:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747806613; x=1748411413; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7mK0CB097Vrx1Tka8o1lxq3Fxugnek79Lxj1tf2VZJU=; b=MeE6ZjoqgMTV3wqQvtWUtcSaAxMKZuEndv4hO/7Yv2BtSV4kqhpWLWBwS1ls8KNHKI m60jZEAZ4atgfMBPHD+qW6KjjA0XtmZskbX1cT19Iz9ZED7TFvI6/TTKukK5YBo4y9iE LaeBNXj7LyikwETHx1Q3u3RrcpPjM8+o9jye7Svlo+U5a+pT/mZO8zSaJ31+2Hhhqmnb +icV8RyI4DRN2zXolDhZGbNZzqJt2+d7dcn6MLne+GMQLvn/MbhqrUvENgELknM4qXMz FKgCg1z38GzETRcSN1PhzaQudJA3yf9s6xoNv/5wCukDWJz8z2Me4MX3B0RXUf6JwKTh t7bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747806613; x=1748411413; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7mK0CB097Vrx1Tka8o1lxq3Fxugnek79Lxj1tf2VZJU=; b=HWixfDPvJFez523KeL3farkMRjDXxpB8xeJmVTYHtLhYwVO0MVQ4k95VVtcygjCrnT S8CAhLWmkwmoB2q9Hv5+oyFQ6EAndwdCUO3KSou8iMx5Ag33VOA4ErdmnXv/BDpyzB7p IYiVSof/ZyVRvG4t9ZGNE8yGtI0DGusL05ZgHLb2uljCQ+8gWsY745Ro0TG2GkOr0GqI 7DpTXvQXXtjD8HF9mw61wee1O6OkVDtGGQW14qoCf0cVetyxjMHP7FpBILCc5eNiSl7w 8TL1XOFQjuiYH5Jkn+5ts/twPMc78+CAExLmqeyJjtNKau+n+CNfr/5moSwMOB/hiDxD 09ew== X-Forwarded-Encrypted: i=1; AJvYcCUx3w1Zbbi0V0pVtFOGDAAKT4zke2X/q+tlKZHJZKhONmLCyNr/Dmp0KW1UCjm4nf/ibPhy5nl7NAog95jn@lists.postgresql.org X-Gm-Message-State: AOJu0YzEfBGAofqo8mtjYPGv4u3eerPpsPH3FhFjn6EiE2YXb7bZTGZf 9ifu5xSAgr40wkzcWxydsxO/xeeZXz/C3LB4hBqOy4OFBKukDHJz/ZCmRFrC2PiJUQ3sb4RKBgv YT5X3ie/Qcm2IDmLMYF+VwdSRotVdHPs= X-Gm-Gg: ASbGnct3/ajrjObJovy68pMHi1LZLsL0DYK1Z3xz76Q3XF9wNNa8rpc/3HuC+TIk4K+ MrqDvRSLpw0K/RXB5mEbYyLIc0HaWyJ1qy3w9nB+JzwET5h8Wbxm7rD3kPM++AJQl+GbnTjQDCa mpNrRh8uLrdmtKkXntFN5i/vyFFyW49vcPanIGfW3GuaHhTsa7Doaa/aLDJyRENYBID1HR4FYSQ DiP X-Google-Smtp-Source: AGHT+IH1f3qcdwiXnkicN+DwLQChq5kfEiUnKmv6cJrfYtZLT7sog8ZbBgwPEsEumlaSQZWMWOqi/Ev4FFJiKjMN6zA= X-Received: by 2002:a05:690c:4b8a:b0:6ee:8363:96d3 with SMTP id 00721157ae682-70cab0bb32cmr270456117b3.27.1747806613124; Tue, 20 May 2025 22:50:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Stehule Date: Wed, 21 May 2025 07:49:34 +0200 X-Gm-Features: AX0GCFvyyI6_Mg6RvSunLR4--uECLkPbW8skIKF2O6EpQDicQLZVMUwElWA7Ne4 Message-ID: Subject: Re: Re: proposal: schema variables To: Michael Paquier , Peter Eisentraut Cc: Bruce Momjian , Marcos Pegoraro , jian he , Dmitry Dolgov <9erthalion6@gmail.com>, Laurenz Albe , Erik Rijkers , Amit Kapila , DUVAL REMI , PostgreSQL Hackers Content-Type: multipart/alternative; boundary="0000000000004fc11906359ef0fc" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004fc11906359ef0fc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable st 21. 5. 2025 v 2:21 odes=C3=ADlatel Michael Paquier napsal: > On Tue, May 20, 2025 at 10:28:31PM +0200, Pavel Stehule wrote: > > This topic is difficult, because there is no common solution. SQL/PSM i= s > > almost dead. T-SQL (and MySQL) design is weak and cannot be used for > > security. > > Oracle's design is joined with just one environment. And although almos= t > > all widely used databases have supported session variables for decades, > no > > one design > > is perfect. Proposed design is not perfect too (it introduces possible > > ambiguity) , but I think it can support most wanted use cases (can be > > enhanced in future), > > and it is consistent with Postgres. There are more ways to reduce risk = of > > unwanted ambiguity to zero. But it increases the size of the patch. > > One thing that I keep hearing about this feature is that this would be > really helpful for migration from Oracle to PostgreSQL, helping a lot > with rewrites of pl/pgsql functions. > > There is one page on the wiki about private variables, dating back to > 2016: > https://wiki.postgresql.org/wiki/CREATE_PRIVATE_VARIABLE > > I wrote mail https://www.postgresql.org/message-id/CAFj8pRB8kdWQCdN2X1_63c58+07Oy4Z+ruDK= _xPTUP+Pe8R2Pw@mail.gmail.com and there is another wiki page https://wiki.postgresql.org/wiki/Variable_Design > Perhaps it would help to summarize a bit the pros and cons of existing > implementations to drive which implementation would be the most suited > on a wiki page? The way standards are defined is by overwriting > existing standards, and we don't have one in the SQL specification. > It's hard to say if there will be one at some point, but if the main > SQL products around the world have one, it pretty much is a point in > favor of having a standard. > Although it is maybe a peccant idea - I can imagine two different implementations of server side session variables with different syntaxes (and different advantages and disadvantages, and different use cases). The implementations are not going against, but we should to accept fact, so one feature is implemented twice. We should choose just one, that will be implemented first. Proposed helps with migration from PL/SQL. > > Another possible angle that could be taken is to invest in a proposal > for the SQL committee to consider, forcing an actual standard that > PostgreSQL could rely on rather than having one behavior implemented > to have it standard-incompatible a few years after. And luckily, we > have Vik Fearing and Peter Eisentraut in this community who invest > time and resources in this area. > Theoretically the proposed design is a subset of implementation from DB2 - I designed it without knowledge of this DB2 feature. But without introduction of concept of modules (that is partially redundant to schemas), this design is very natural and I am very sure, so there is not another way, how to design it. We can ask Peter or Vik about real possibilities in this area. I have not any information from this area, just I haven't seen the changes in SQL/PSM for decades, so I didn't think about it. > FWIW, I do agree with the opinion that if you want to propose rebased > versions of this patch set on a periodic basis, you are free to do so. > This is the core concept of an open community. In terms of my > committer time, I'm pretty much already booked in terms of features > planned for the next release, so I guess that I won't be able to > invest time on this thread. Just saying. > thank you for an info > I know that this patch set has been discussed at FOSDEM at some point, > so others may be able to comment more about that. That's just one > opinion among many others. > -- > Michael > --0000000000004fc11906359ef0fc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


st 21. 5. 2025 = v=C2=A02:21 odes=C3=ADlatel Michael Paquier <michael@paquier.xyz> napsal:
On Tue, May 20, 2025 at 10:28:31PM +0200, = Pavel Stehule wrote:
> This topic is difficult, because there is no common solution. SQL/PSM = is
> almost dead. T-SQL (and MySQL) design is weak and cannot be used for > security.
> Oracle's design is joined with just one environment. And although = almost
> all widely used databases have supported session variables for decades= , no
> one design
> is perfect. Proposed design is not perfect too (it introduces possible=
> ambiguity) , but I think it can support most wanted use cases (can be<= br> > enhanced in future),
> and it is consistent with Postgres. There are more ways to reduce risk= of
> unwanted ambiguity to zero. But it increases the size of the patch.
One thing that I keep hearing about this feature is that this would be
really helpful for migration from Oracle to PostgreSQL, helping a lot
with rewrites of pl/pgsql functions.

There is one page on the wiki about private variables, dating back to
2016:
https://wiki.postgresql.org/wiki/CREATE_PRIV= ATE_VARIABLE


I wrote mail=C2=A0



=C2=A0
Perhaps it would help to summarize a bit the pros and cons of existing
implementations to drive which implementation would be the most suited
on a wiki page?=C2=A0 The way standards are defined is by overwriting
existing standards, and we don't have one in the SQL specification.
It's hard to say if there will be one at some point, but if the main SQL products around the world have one, it pretty much is a point in
favor of having a standard.

Although it= is=C2=A0 maybe a peccant idea - I can imagine two different implementation= s of server side session variables with different syntaxes
(and d= ifferent advantages and disadvantages, and different use cases). The implem= entations are not going against, but we should to accept
fact, so= one feature is implemented twice. We should choose just one, that will be = implemented first. Proposed helps with migration from
PL/SQL.
=C2=A0

Another possible angle that could be taken is to invest in a proposal
for the SQL committee to consider, forcing an actual standard that
PostgreSQL could rely on rather than having one behavior implemented
to have it standard-incompatible a few years after.=C2=A0 And luckily, we have Vik Fearing and Peter Eisentraut in this community who invest
time and resources in this area.

Theore= tically the proposed design is a subset of implementation from DB2 - I desi= gned it without knowledge of this DB2 feature. But without
introd= uction of concept of modules (that is partially redundant to schemas), this= design is very natural and I am very sure, so there is not
anoth= er way, how to design it. We can ask Peter or Vik about real possibilities = in this area. I have not any information from this area, just
I h= aven't seen the changes in SQL/PSM for decades, so I didn't think= =C2=A0 about it.



FWIW, I do agree with the opinion that if you want to propose rebased
versions of this patch set on a periodic basis, you are free to do so.
This is the core concept of an open community.=C2=A0 In terms of my
committer time, I'm pretty much already booked in terms of features
planned for the next release, so I guess that I won't be able to
invest time on this thread.=C2=A0 Just saying.

thank you for an info


I know that this patch set has been discussed at FOSDEM at some point,
so others may be able to comment more about that.=C2=A0 That's just one=
opinion among many others.
--
Michael
--0000000000004fc11906359ef0fc--