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 1tKZpn-009V6g-0V for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Dec 2024 09:13:43 +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 1tKZpk-005zKL-GZ for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Dec 2024 09:13:41 +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 1tKZpk-005zKC-1x for pgsql-hackers@lists.postgresql.org; Mon, 09 Dec 2024 09:13:41 +0000 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tKZpi-001pmE-I4 for pgsql-hackers@lists.postgresql.org; Mon, 09 Dec 2024 09:13:40 +0000 Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-84198253240so171719839f.0 for ; Mon, 09 Dec 2024 01:13:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733735618; x=1734340418; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6TN8i2AhNqBz2QHcm9ZdmX/LQrS+E3sT2EsiS165o88=; b=emISVp8u4Det5MeE3+zQU6wPXjD77sBywRNmGvKlwZzSn2TiBEN+2sqjVfdFsUxIOE ZvqIJf1EEuncKGVuS6ilMnWNBOmq7LgrSqe19kVRFaoJEZOoWsM9/orUC+0PrOmrgZKs z1tx3OaFpaOV2K/icLQq50+gS8dzFB11Yo1GmMlIndmCyavsfidsiHVqtEn4EDHhe9gl tbzcdymYxdEjTqFG57bAqU/45APBZYDwxUaMNVM1z7+MFLNNMskqdjc0kjJh3w+S3jW0 2aQGrTTvENqQvT3w2cQHvaaGvjjloDPfkDf7qjEepNiqe3NzbzSqD7iyfS3d6mp/Ar+0 ML2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733735618; x=1734340418; h=content-transfer-encoding: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=6TN8i2AhNqBz2QHcm9ZdmX/LQrS+E3sT2EsiS165o88=; b=PVcIE+RApg9N1xYWDsaTDdIF0BB6RwsLbbpwI90NYQQ069R+lV/dfHlnKQNZnxi1hY T6Ufkgx9J/0tcETkGazjwWiRH0u3l8TgGZaxYZHKZRYo3xZV4zog4Q1H5ExQG/0ZQOx7 NsW7Podv63O5WpyWb722iDdG8Gw+/cl+x7e7SrDqWWa+Q4JLn8vFsL7cl9DNJDJIfxUI 4vdiF/rM1P0py6NA1dAllTaTX/vQq58weOYdMORzmVTJG/DZyiAm+Q0aH7CYTlZfpDuz mWavvRbovxchPZlwPkJEdjvJzojBaqHt0kmm05uUnh1ogRAoaVR7cqd8ugFqdgRLLRP1 D/gQ== X-Forwarded-Encrypted: i=1; AJvYcCXerS/+A+VYtH0fcWmA1BrP0KRu6mXBYvhSn9y/mT5xPNroYxjpRN2e2bd55H755bpAfH0yeKbl/HHQCQLb@lists.postgresql.org X-Gm-Message-State: AOJu0YxM8Z8ijHSA1xi29Xr1gS226pi/dvDeMQlXdOvARM5fzwW30KAD 6DaNOVnajo1ziNF65AeWJ4EmeH3WVdjE1z7HzMYOQ2CWRptHZSTuuGZ/HWEpROw9B98hn23oJfh 425JOHXyuN9WpI5aoDZas3KbpXO3qqGE6llo= X-Gm-Gg: ASbGnctKREvDAY7WCNqxCWQO7JekKT+B1F6D1lfbKUCiUG3AONRYfyBxaexbhxUA2Pd ksPhm8w53SayQw+Q2BvlVNDg3TIJpc2sL X-Google-Smtp-Source: AGHT+IFMWEeifV3KkZXwxlVGz3nMmXONv3Mt1DUopbDNjU8/r36AtVHnBjRc9dJegz8k5q4ZnjeP9/r1u/Zl2BI3xSc= X-Received: by 2002:a05:6102:162b:b0:4af:b45a:cd20 with SMTP id ada2fe7eead31-4afcab15bafmr11164464137.26.1733724975798; Sun, 08 Dec 2024 22:16:15 -0800 (PST) MIME-Version: 1.0 References: <3chredgnjcmccym2kczawfih226b4ac6co7p6z4jeofevrcosi@mrsxkx2x2c65> In-Reply-To: From: jian he Date: Mon, 9 Dec 2024 14:16:04 +0800 Message-ID: Subject: 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" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Dec 9, 2024 at 2:33=E2=80=AFAM Pavel Stehule wrote: > > Hi > again. only applied v20241208-0001-Enhancing-catalog-for-support-session-variables-and-.patch. /* we want SessionVariableCreatePostprocess to see the catalog changes. */ 0001 doesn't have SessionVariableCreatePostprocess, so this comment is wrong in the context of 0001. typo: As above, but if the variable isn't found and is_mussing is not NULL is_mussing should be is_missing. ---------------------------------------------- issue with grant.sgml and revoke.sgml. * there are no regress tests for WITH GRANT OPTION but it seems to work; there are no REVOKE CASCADE tests. the following tests show REVOKE CASCADE works. create variable v1 as int; GRANT select on VARIABLE v1 to alice with grant option; set session authorization alice; GRANT select on VARIABLE v1 to bob with grant option; reset session authorization; select varacl from pg_variable where varname =3D 'v1'; --output {jian=3Drw/jian,alice=3Dr*/jian,bob=3Dr*/alice} revoke all privileges on variable v1 from alice cascade; select varacl from pg_variable where varname =3D 'v1'; --output {jian=3Drw/jian} revoke GRANT OPTION FOR all privileges on variable v1 from alice cascade; also works. * in revoke.sgml and grant.sgml. if you look closely, " | ALL VARIABLES IN SCHEMA schema_name [, ...] }" is = wrong because there is no left-curly-bracket, but there is a right-curly-bracket. * in revoke.sgml. where role_specification can be: [ GROUP ] role_name | PUBLIC | CURRENT_ROLE | CURRENT_USER | SESSION_USER should be at the end of the synopsis section? otherwise it looks weird, maybe we can put the REVOKE VARIABLE code upper. grant.sgml changes position looks fine to me. * The GRANT command has two basic variants: one that grants privileges on a database object (table, column, view, foreign table, sequence, database, foreign-data wrapper, foreign server, function, procedure, procedural language, large object, configuration parameter, schema, tablespace, or type), and one that grants membership in a role. These variants are similar in many ways, but they are different enough to be described separately. this in grant.sgml needs to also mention "variable"? * Privileges on databases, tablespaces, schemas, languages, and configuration parameters are PostgreSQL extensions. this in grant.sgml needs to also mention "variable"? ---------------------------------------------- * + + Inside a query or an expression, a session variable can be + shadowed by a column with the same name. Similarly, th= e + name of a function or procedure argument or a PL/pgSQL variable (see PL/pgSQL should decorated as PL/pgSQL * we already support \dV and \dV+ in v20241208-0001-Enhancing-catalog-for-support-session-variables-and-.patch so we should update doc/src/sgml/ref/psql-ref.sgml also. I briefly searched \dV in v20241208-0002-Storage-for-session-variables-and-SQL-interface.patch, no entry. * in doc/src/sgml/ddl.sgml and
need to change for variable? , need to change for variable? it's kind of tricky. if we only apply v20241208-0001-Enhancing-catalog-for-support-session-variables-and-.patch we can not SELECT or UPDATE variable. so how are we going to mention these privileges for variable? * we can add some tests for EVENT TRIGGER test, since event trigger support CREATE|DROP variable. atually, I think there is a bug. create variable v1 as int; CREATE OR REPLACE FUNCTION event_trigger_report_dropped() RETURNS event_trigger LANGUAGE plpgsql AS $$ DECLARE r record; BEGIN FOR r IN SELECT * from pg_event_trigger_dropped_objects() LOOP IF NOT r.normal AND NOT r.original THEN CONTINUE; END IF; RAISE NOTICE 'NORMAL: orig=3D% normal=3D% istemp=3D% type=3D% identity=3D% = name=3D% args=3D%', r.original, r.normal, r.is_temporary, r.object_type, r.object_identity, r.address_names, r.address_args; END LOOP; END; $$; CREATE EVENT TRIGGER regress_event_trigger_report_dropped ON sql_drop WHEN TAG IN ('DROP VARIABLE') EXECUTE PROCEDURE event_trigger_report_dropped(); --output: src9=3D# drop variable v1; NOTICE: test_event_trigger: ddl_command_start DROP VARIABLE NOTICE: NORMAL: orig=3Dt normal=3Df istemp=3Df type=3Dsession variable identity=3Dpublic.v1 name=3D{public,$} args=3D{} DROP VARIABLE should i expect NOTICE: NORMAL: orig=3Dt normal=3Df istemp=3Df type=3Dsession variable identity=3Dpublic.v1 name=3D{public,$} args=3D{} to be NOTICE: NORMAL: orig=3Dt normal=3Df istemp=3Df type=3Dsession variable identity=3Dpublic.v1 name=3D{public,v1} args=3D{} ?