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 1tVSPq-008aUy-Iw for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 09:31:55 +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 1tVSPp-00FbEA-3p for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 09:31:52 +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 1tVSPo-00FbDt-O7 for pgsql-hackers@lists.postgresql.org; Wed, 08 Jan 2025 09:31:52 +0000 Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tVSPl-000VLJ-0v for pgsql-hackers@lists.postgresql.org; Wed, 08 Jan 2025 09:31:51 +0000 Received: by mail-ua1-x935.google.com with SMTP id a1e0cc1a2514c-85c529e72bcso2988353241.0 for ; Wed, 08 Jan 2025 01:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736328708; x=1736933508; 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=cwzRN8Nq/dxLR07KDOKlLakAzdihbRv9Hgs0ZUA2kk4=; b=aBGcaI29vPCyLRMEuVbTflro+PB+wdYgTe/VrNEQ3rubW2wYD/b8aTOIKl0FFznlUl 9+UcHoyC3/40xom1xdZtmjROdX7VYH1MTipQO5P3aUwu9xdFaR13+zcKGoi+QNats/v0 JrF6CWtk7p7SxsCSrCWwLSP0bppaR/dcBw5YPTGfIAnNiVPfVtk1owt/U70mrBvEWUp/ U+8GVg7ctcbZJ0fAa8NSeEliZP6V3LAwPbtDGVgkgq9i7GR4OQPX2XXl0baXJkj05Yxr arDVtG6K9QVwTbGD5YTc1qS7LoAMXnqsJGZJg6lSklocQNuD3FAptJA3OO9EIVYXBsi/ b6zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736328708; x=1736933508; 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=cwzRN8Nq/dxLR07KDOKlLakAzdihbRv9Hgs0ZUA2kk4=; b=ffYrscNJxNRiEfZsIXZ1MvaDNUpBSzw5kgtECRUBx0VWbCQFeu5BpUTe6TGoP/QxLe wdD5lco74ZkJOxLJxg5xShRmDwkRcWwra7WIc3vhgZJp0MFMZGGgxUQJI+8GW0B2LfDp JNlu5TrfZTOJ8ZJZTdX8QYEHQ8NFEb/y3cS2kBAJohdLI+JvVeeWIiNUmYeoYtcBv4A5 prSr0nQq8Q1JfWx5cKJMjLAtLUzdE1+35LE1Tz+g1FwRa26KiREurxxuGGM42kteGbTJ XfneR4PNGrBelKcdRhYX6lBi9IwdM+NkTUmHSEnay9UW1tqwSuUVmkBnu5iukrHfmC/n HLWg== X-Forwarded-Encrypted: i=1; AJvYcCXERZs8dCFhjF6reWvt7DiBm/v3r+Q6SP4qclqcscDC4rsxkGjj4z/q9Pb0eVvGcVbguUSGhDgDumjXdFbM@lists.postgresql.org X-Gm-Message-State: AOJu0Yz2yD+C8wRZdsh75kOP5aFc3wlUjfHF7MXuGbfAEbeBuwvRt3OI gyE8FDICKgJZjeuca/N9w0ziaBvsnDAdrMzAzQi3BFIgj3K1eWFei746w14R9SjcWre/Nxjz+sA Ofba0ogViUKqjAGXTD6q/m5UhBb0= X-Gm-Gg: ASbGncuJ/+e6s5BEuYns0CKtYbYv3/7juS6MGV+YhMMdnwOtFer6U6inxhrfQm+P1xs Vu09hHh1fBnWZJ34NAPWr1Xj1q3uD6mwdeEQR X-Google-Smtp-Source: AGHT+IHsUTKLcPwp9kqso6kI9cBYe5zw7CEnOAIeJkdj09rx9xEmRatgiMayyD87romBDdjAEZ81pGnHZB+XQuq3a6E= X-Received: by 2002:a05:6102:f93:b0:4b2:5c0a:98c0 with SMTP id ada2fe7eead31-4b3d0d68260mr1558644137.0.1736328707639; Wed, 08 Jan 2025 01:31:47 -0800 (PST) MIME-Version: 1.0 References: <3chredgnjcmccym2kczawfih226b4ac6co7p6z4jeofevrcosi@mrsxkx2x2c65> <20241120201313.t4wbhld4ktgielaf@erthalion.local> In-Reply-To: From: jian he Date: Wed, 8 Jan 2025 17:31:11 +0800 X-Gm-Features: AbW1kvZAf4KIPpwUo1FpEbOXcYbSMGq-WgU5o5yd1ZzQ7-uXcRiTxj7216C0Fa0 Message-ID: Subject: Re: Re: proposal: schema variables To: Pavel Stehule Cc: Dmitry Dolgov <9erthalion6@gmail.com>, Laurenz Albe , Erik Rijkers , Michael Paquier , Amit Kapila , DUVAL REMI , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk hi. you forgot change acldefault should add 'V' for SESSION VARIABLE in doc/src/sgml/ddl.sgml maybe some examples () of session variables being shadowed would be great. because doc/src/sgml/ref/create_variable.sgml said Session variables can be shadowed by other identifiers. For details, see . If I click the link, then in ddl.sgml, there is also a bunch of text saying that variable will be shadowed in some situations, but there are no simple examples to demonstrate that. "Create an date session variable var1:" maybe it should be rephrased as "Create a session variable var1 as date data type?" (i am not native english speaker) ----------------------------------------------------------------------- --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -379,7 +379,8 @@ typedef struct Param Expr xpr; ParamKind paramkind; /* kind of parameter. See above */ int paramid; /* numeric ID for parameter */ - Oid paramtype; /* pg_type OID of parameter's datatype */ + /* pg_type OID of parameter's datatype */ + Oid paramtype pg_node_attr(query_jumble_ignore); I think we need the above to make select v2; select v1; normalized as one query. ----------------------------------------------------------------------- when we create a new table, we do something like this: DefineRelation heap_create_with_catalog GetNewRelFileNumber GetNewOidWithIndex relation Oid uniqueness and variable uniqueness is the same thing. If variable oid uniqueness problem ever reached, at that moment, we should care more about relation oid uniqueness problem? and in GetNewRelFileNumber, we have comments: "" * As with GetNewOidWithIndex(), there is some theoretical risk of a race * condition, but it doesn't seem worth worrying about. """ also comments in GetNewOidWithIndex """ * Note that we are effectively assuming that the table has a relatively small * number of entries (much less than 2^32) and there aren't very long runs of * consecutive existing OIDs. This is a mostly reasonable assumption for * system catalogs. """ that means pg_catalog.pg_variable.varcreate_lsn is not really necessary? ----------------------------------------------------------------------- I think the latest patch for LET self assign ACL SELECT is not correct, previously I also tried the same idea. test demo. CREATE TYPE vartest_t1 AS (a int, b int); CREATE VARIABLE var1 AS vartest_t1; CREATE ROLE regress_var_test_role; GRANT UPDATE ON VARIABLE var1 TO regress_var_test_role; GRANT select ON table tenk1 TO regress_var_test_role; SET ROLE TO regress_var_test_role; --both should fail LET var1.a = var1.a + 10; LET var1.a = (select * from (select count(*) from tenk1 where unique1 = var1.a + 10)); --------------------------------------------------------