Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j7KJ4-00009X-Kn for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Feb 2020 14:38:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j7KJ3-00079I-6K for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Feb 2020 14:38:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j7KJ2-00079B-R3 for pgsql-hackers@lists.postgresql.org; Thu, 27 Feb 2020 14:38:28 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j7KJ0-0004z9-AU for pgsql-hackers@lists.postgresql.org; Thu, 27 Feb 2020 14:38:28 +0000 Received: by mail-lj1-x22a.google.com with SMTP id x7so3720887ljc.1 for ; Thu, 27 Feb 2020 06:38:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lXsnkrOgF81DPA/4PibWsPVDWY87Ako45cre4NdL4xY=; b=OLNn7dwGXt/X54g3kSRMx9ieCpRUjDCGMlq8GGj8WfID3cHHadUPXHyx5oDvntjVmF Y8uSP6rKB5DKPBfjyeWgDylMKJYqAQHIwkl8MzX1euvrTuIFZx88J+BBf1USERUTesCb ZddN1iMZzrRCXk8ETnDH5nG2S//45Vm6lVJlAcGUG1ryCeWN8H2AVG8WEwdYHy5a+XZf wZiBEbQYR7qAbvm/uYbx2glttNRQ4cSa1aLfsQ8HKwxr5mvA0RoccPJUORCt49cNs6/b XN2ty/npJNdsX9fEGFUcmdJw3V9uNFW16qZtkYtZ9kNcuc4Q3dtsWgdbVuKAWITpCF+3 fOEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lXsnkrOgF81DPA/4PibWsPVDWY87Ako45cre4NdL4xY=; b=Abnx8IcJ6UpXqRAK+QjkIfUf0hblObeaW3VfY5PoyaA9cX85AE/d9sZhbItKZbve5t iG18Nz1ui5UG/ne/cWoaCZJgjuZDKccLXBmsZqmcsuICbWtQrDOEaeQdDC3pTsIEYT7T ag4GnbvRRIXP9rBPxQjaX79NMTQ7A5kaJNwksKtNagSsaA7nq/Gik60mGVxFnCCzHsut LZFFCUJfpLs1j1mF6Y26CK7l7AHh6KGv7ZUhJVky2Q2qJeAze8aKjcCWuUgSLF/mwHp7 GXWQ59OW+a/qrkaBnKOy93oWOWTE5tJ47euWqIL6Nc2hET70w4doy1L2AQIrAWpBLkjj 9Yvw== X-Gm-Message-State: ANhLgQ0C5x6PQ+l1ngNZ7tgLO49UP/aGf1lBfl2ukj+dX2lP2XnCfjO6 taF/vrT6GdbUxYcHp7ee4BsajHm3MoPVoFUO2xw= X-Google-Smtp-Source: ADFU+vu8fTNM8Dp2Is7+7D0X/bGJZq+TpVefX7RP2S3q9N3oPAwHtsgvqRko4samjCOhXBtMnwNr+JYYK2KaIraYN50= X-Received: by 2002:a2e:3a0c:: with SMTP id h12mr3215804lja.200.1582814305087; Thu, 27 Feb 2020 06:38:25 -0800 (PST) MIME-Version: 1.0 References: <158272883575.1651.2316685587547965508.pgcf@coridan.postgresql.org> In-Reply-To: From: Pavel Stehule Date: Thu, 27 Feb 2020 15:37:48 +0100 Message-ID: Subject: Re: proposal: schema variables To: remi duval Cc: PostgreSQL Hackers Content-Type: multipart/alternative; boundary="000000000000667232059f8facfd" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000667232059f8facfd Content-Type: text/plain; charset="UTF-8" Hi > 3) Any way to define CONSTANTs ? > We already talked a bit about this subject and also Gilles Darold > introduces it in this mailing-list topic but I'd like to insist on it. > I think it would be nice to have a way to say that a variable should not > be changed once defined. > Maybe it's hard to implement and can be implemented later, but I just want > to know if this concern is open. > I played little bit with it and I didn't find any nice solution, but maybe I found the solution. I had ideas about some variants, but almost all time I had a problem with parser's shifts because all potential keywords are not reserved. last variant, but maybe best is using keyword WITH So the syntax can looks like CREATE [ TEMP ] VARIABLE varname [ AS ] type [ NOT NULL ] [ DEFAULT expression ] [ WITH [ OPTIONS ] '(' ... ')' ] ] What do you think about this syntax? It doesn't need any new keyword, and it easy to enhance it. CREATE VARIABLE foo AS int DEFAULT 10 WITH OPTIONS ( CONSTANT); ? Regards Pavel --000000000000667232059f8facfd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi


3) Any way to define CONSTANTs ?
We already talked a bit about this subject and also Gilles Darold introduce= s it in this mailing-list topic but I'd like to insist on it.
I think it would be nice to have a way to say that a variable should not be= changed once defined.
Maybe it's hard to implement and can be implemented later, but I just w= ant to know if this concern is open.

I playe= d little bit with it and I didn't find any nice solution, but maybe I f= ound the solution. I had ideas about some variants, but almost all time I h= ad a problem with parser's shifts because all potential keywords are no= t reserved.

last variant, but maybe best is using keyword WITH

So the syntax can looks = like

C= REATE [ TEMP ] VARIABLE varname [ AS ] type [ NOT NULL ] [ DEFAULT expressi= on ] [ WITH [ OPTIONS ] '(' ... ')' ] ]

What do you think ab= out this syntax? It doesn't need any new keyword, and it easy to enhanc= e it.

= CREATE VARIABLE foo AS int DEFAULT 10 WITH OPTIONS ( CONSTANT);

?

Reg= ards

Pavel


--000000000000667232059f8facfd--