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 1tg3CG-007Ih2-Pu for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Feb 2025 14:49:41 +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 1tg3CF-008Fzq-Ns for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Feb 2025 14:49:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tg3CF-008Fzh-AM for pgsql-hackers@lists.postgresql.org; Thu, 06 Feb 2025 14:49:39 +0000 Received: from mail-vs1-xe31.google.com ([2607:f8b0:4864:20::e31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tg3CD-003Xvm-0Z for pgsql-hackers@lists.postgresql.org; Thu, 06 Feb 2025 14:49:38 +0000 Received: by mail-vs1-xe31.google.com with SMTP id ada2fe7eead31-4ba74d1d4a9so287165137.1 for ; Thu, 06 Feb 2025 06:49:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738853377; x=1739458177; 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=DKvA1zcSkeMfsO/Dou7U4xVvqtIcMa4zqautm83u6h4=; b=CYsr0R057CJTtb4L+o8NPySY6z0T3MMyRsWkXKqV3RzRJ5i2sRRMOOBtXsiXkPNEi9 mJqp7bBzDHncuKlEGllbCepjJaRkYoBoP0gySfrjFkCBP6RIrhKrY40017kdRZlRXq2O wSKqZCkTCWXNg8x6QjJKWB5G2hBvEKwsFay1JZdVCCce2xcyKW99KNbPX0iIcJhFOhEr obDh6f52yiqYZ6+DurGVWha8RccA53UKkZARm3A+Qm1Zg8tu+ucqWsY2N5RapATYX8r+ bEK1VEoHPqmCSkeUmR4W9G84hZjXXkIE1sXfpt9I0jGeDjgsxZ5hat2OqUK+d23ynTdq YvVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738853377; x=1739458177; 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=DKvA1zcSkeMfsO/Dou7U4xVvqtIcMa4zqautm83u6h4=; b=h06/kQwjOq2ld5L7hg/vpjfXL5XBJa/sCU0Zzv6q7Eu5wFdTLc+CUnj2ckPnjl5Ynr 2hSjBMqn3N05Z5eEk0nwmaZ9q+LYFKINn0eDFbPFV5HzRu0PIRedsCAgr+TMm/9yNkMV j+NrOLZ+moKm+mMXcPTgYNmq3F24h9EDuoolzQx+uFKuKw9iGRydIhzgvtIUmTH6eTcI Z9/+vvQNfw0Q76P0QkEFVMmTUqQHWaVelWyzEGh1bvTZhd3TEO2L+hD/9n+ZEBylfxI5 Hd/fjMCOa0TZ0QqBLDKcU3vK0fhaxiL7BRsjV2YefUp4Rimf3MKkPRJLZTKavXMDAb7V 6zsg== X-Forwarded-Encrypted: i=1; AJvYcCXhc3fSOfRb2fxU7e0x0ncWXdkSrmwlGZySiXCASmU4QFVC9jjGgeMsFj8qZIuiJkq0e51FFgj1IOpEMJV6@lists.postgresql.org X-Gm-Message-State: AOJu0Yz8ki5t0Q/kT+1VzihgHPxKGQnI4TOMxITkg0RXcoXMjXqi43YO gpqDTbH+27keepMqEqW0mSXHcF5tT7ngYqzYlTVi/fn6S62lfV7K+sflDKeECMw3bVziwc8Nl/6 X/H0RGEGsMROhp1Y2NDXF3TPNWZw= X-Gm-Gg: ASbGnctshBY0wDhSnFBwqt7kq+uVT7gZSgt/dbwQD0vBrsL8BwXgrkOOJEASx4rhEmq 1DKDCBwmcOH5R9hYTlMKbJJ60NW4brCzPFL02Ti/xha8WuAISy45F+XW9tUQkg3XudlW1+vbDEz rflKtpBydp8X7PFp03Etg+Gm7y35De X-Google-Smtp-Source: AGHT+IEP/Gb9XWSKsoh2pEf8Jr45fdoOTjdwDlKPqE+L3r5tvFWOPGh1txvbRdQq0CmTpd4p0G0qwOmBkfcklhzDAnk= X-Received: by 2002:a05:6102:809e:b0:4b1:16f8:efc4 with SMTP id ada2fe7eead31-4ba4791aa90mr4848991137.12.1738853376664; Thu, 06 Feb 2025 06:49:36 -0800 (PST) MIME-Version: 1.0 References: <3chredgnjcmccym2kczawfih226b4ac6co7p6z4jeofevrcosi@mrsxkx2x2c65> <20241120201313.t4wbhld4ktgielaf@erthalion.local> In-Reply-To: From: jian he Date: Thu, 6 Feb 2025 22:49:00 +0800 X-Gm-Features: AWEUYZliRdK_I8cX3iPnz3tP2BvCpES4VJ8L8kwflrFHhjG71k_uZZ7LOEKgf24 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. git diff --check shows there is some white space there. Adding hack mailing list discussion links in each patch would be great. Others said that the first 6 patches are essential, maybe we can only post the first 6 patches. so the test CI result would be more reliable. also people would not feel intimidated by the bigger patchset. create domain dnn as int not null; CREATE VARIABLE var3 AS dnn; alter domain dnn drop not null; alter domain dnn set not null; ERROR: cannot alter domain "dnn" because session variable "public.var3" uses it This is not great. we allow a constraint, then we drop it, now we cannot re add it again. 0001 and 0002 are simple, but the size is still large. maybe we can not support the domain in the first 2 patches. also CREATE VARIABLE var3 AS dnn; let var3 = 11; create view v1 as select var3; select * from v1; you can see reconnect to session then ERROR: domain dnn does not allow null values this is not ok? also create table t(var3 int); CREATE POLICY p1r ON t AS RESTRICTIVE TO alice USING (var3 <> var3); create table t1(a int); CREATE POLICY p2 ON t1 AS RESTRICTIVE TO alice USING (a <> var3); p1r is so confusing. there is no way to understand the intention. p2 should also not be allowed, since var3 value is volatile, session reconnection will change the value. src/bin/pg_dump/pg_dump.h /* * The VariableInfo struct is used to represent session variables */ typedef struct _VariableInfo { DumpableObject dobj; DumpableAcl dacl; Oid vartype; char *vartypname; char *varacl; char *rvaracl; char *initvaracl; char *initrvaracl; Oid varcollation; const char *rolname; /* name of owner, or empty string */ } VariableInfo; these fields (varacl, rvaracl, initvaracl, initrvaracl) were never being used. we can remove them. CollInfo *coll; coll = findCollationByOid(varcollation); if (coll) appendPQExpBuffer(query, " COLLATE %s", fmtQualifiedDumpable(coll)); here, it should be ```CollInfo *coll = NULL;```? I don't understand the changes made in getAdditionalACLs. I thought pg_init_privs had nothing to do with the session variable. minor issue in getVariables. query = createPQExpBuffer(); resetPQExpBuffer(query); no need to use resetPQExpBuffer here. create type ab as (a int, b text); create type abc as (a ab, c text); create type abcd as (a abc, d text); CREATE VARIABLE var2 AS abcd; select var2.a.c; ERROR: cross-database references are not implemented: var2.a.c Is this error what we expected? I am not 100% sure. --------------------another contrived corner case.----------------------- create type pg_variable as ( oid oid, vartype oid, varcreate_lsn pg_lsn, varname name, varnamespace oid, varowner oid, vartypmod int, varcollation oid, varacl aclitem[]); create variable pg_variable as pg_variable; let pg_variable = row (18041, 10116, '0/25137B0','pg_variable', 2200, 10,-1,0, NULL)::pg_variable; select pg_variable.oid from pg_variable where pg_variable.oid = pg_variable.oid; this query, the WHERE clause, it's really hard to distinguish session variable or column reference. I am not sure if this is fine or not.