Re: proposal: schema variables
Pavel Stehule <pavel.stehule@gmail.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Move WAL sequence code into its own file
- a87987cafca6 19 (unreleased) cited
-
Add ExplainState argument to pg_plan_query() and planner().
- c83ac02ec730 19 (unreleased) cited
-
Don't include access/htup_details.h in executor/tuptable.h
- 1a8b5b11e48a 19 (unreleased) cited
-
Refactor to avoid code duplication in transformPLAssignStmt.
- b0fb2c6aa5a4 19 (unreleased) cited
-
Avoid including commands/dbcommands.h in so many places
- 325fc0ab14d1 19 (unreleased) cited
-
Restrict psql meta-commands in plain-text dumps.
- 71ea0d679543 19 (unreleased) cited
-
Split func.sgml into more manageable pieces
- 4e23c9ef65ac 19 (unreleased) cited
-
Fix squashing algorithm for query texts
- 0f65f3eec478 18.0 cited
-
EXPLAIN: Always use two fractional digits for row counts.
- 95dbd827f2ed 18.0 cited
-
Preliminary refactoring of plpgsql expression construction.
- a654af21ae52 18.0 cited
-
plpgsql: pure parser and reentrant scanner
- 7b27f5fd36cb 18.0 cited
-
Add some sanity checks in executor for query ID reporting
- 24f520594809 18.0 cited
-
Fix misleading error message context
- 4af123ad45bd 18.0 cited
-
Add macros for looping through a List without a ListCell.
- 14dd0f27d7cd 17.0 cited
Attachments
- v20241210-0020-transactional-variables.patch (text/x-patch) patch v20241210-0020
- v20241210-0021-pg_restore-A-variable.patch (text/x-patch) patch v20241210-0021
- v20241210-0018-expression-with-session-variables-can-be-inlined.patch (text/x-patch) patch v20241210-0018
- v20241210-0017-plpgsql-implementation-for-LET-statement.patch (text/x-patch) patch v20241210-0017
- v20241210-0019-this-patch-changes-error-message-column-doesn-t-exis.patch (text/x-patch) patch v20241210-0019
- v20241210-0016-allow-parallel-execution-queries-with-session-variab.patch (text/x-patch) patch v20241210-0016
- v20241210-0015-allow-read-an-value-of-session-variable-directly-fro.patch (text/x-patch) patch v20241210-0015
- v20241210-0014-Implementation-of-NOT-NULL-and-IMMUTABLE-clauses.patch (text/x-patch) patch v20241210-0014
- v20241210-0013-Implementation-of-DEFAULT-clause-default-expressions.patch (text/x-patch) patch v20241210-0013
- v20241210-0012-Implementation-ON-TRANSACTION-END-RESET-clause.patch (text/x-patch) patch v20241210-0012
- v20241210-0011-implementation-of-temporary-session-variables.patch (text/x-patch) patch v20241210-0011
- v20241210-0010-PREPARE-LET-support.patch (text/x-patch) patch v20241210-0010
- v20241210-0008-variable-fence-syntax-support-and-variable-fence-usa.patch (text/x-patch) patch v20241210-0008
- v20241210-0009-EXPLAIN-LET-support.patch (text/x-patch) patch v20241210-0009
- v20241210-0007-GUC-session_variables_ambiguity_warning.patch (text/x-patch) patch v20241210-0007
- v20241210-0006-plpgsql-tests.patch (text/x-patch) patch v20241210-0006
- v20241210-0005-memory-cleaning-after-DROP-VARIABLE.patch (text/x-patch) patch v20241210-0005
- v20241210-0004-DISCARD-VARIABLES.patch (text/x-patch) patch v20241210-0004
- v20241210-0003-function-pg_session_variables-for-cleaning-tests.patch (text/x-patch) patch v20241210-0003
- v20241210-0002-Storage-for-session-variables-and-SQL-interface.patch (text/x-patch) patch v20241210-0002
- v20241210-0001-Enhancing-catalog-for-support-session-variables-and-.patch (text/x-patch) patch v20241210-0001
po 9. 12. 2024 v 7:16 odesílatel jian he <jian.universality@gmail.com>
napsal:
> On Mon, Dec 9, 2024 at 2:33 AM Pavel Stehule <pavel.stehule@gmail.com>
> 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.
>
moved to patch 11
>
> typo:
> As above, but if the variable isn't found and is_mussing is not NULL
> is_mussing should be is_missing.
>
>
fixed
> ----------------------------------------------
> 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 = 'v1';
> --output
> {jian=rw/jian,alice=r*/jian,bob=r*/alice}
> revoke all privileges on variable v1 from alice cascade;
> select varacl from pg_variable where varname = 'v1';
> --output
> {jian=rw/jian}
>
> revoke GRANT OPTION FOR all privileges on variable v1 from alice cascade;
> also works.
>
these features uses generic code, so I didn't wrote regress test, but I
don't see any
reason why don't use your examples in regress tests.
>
> * 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.
>
fixed
>
> * in revoke.sgml.
> <phrase>where <replaceable
> class="parameter">role_specification</replaceable> can be:</phrase>
> [ GROUP ] <replaceable class="parameter">role_name</replaceable>
> | 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.
>
it was wrong, REVOKE VARIABLE should be moved up
fixed
>
>
> * <para>
> The <command>GRANT</command> 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.
> </para>
> this <para> in grant.sgml needs to also mention "variable"?
>
done
>
> * <para>
> Privileges on databases, tablespaces, schemas, languages, and
> configuration parameters are
> <productname>PostgreSQL</productname> extensions.
> </para>
> this <para> in grant.sgml needs to also mention "variable"?
>
>
done
> * 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.
>
done
----------------------------------------------
> *
> + <para>
> + Inside a query or an expression, a session variable can be
> + <quote>shadowed</quote> by a column with the same name. Similarly,
> the
> + name of a function or procedure argument or a PL/pgSQL variable (see
> PL/pgSQL should decorated as <application>PL/pgSQL</application>
>
>
moved this para to patch02
>
>
> * in doc/src/sgml/ddl.sgml
> <table id="privilege-abbrevs-table"> and <table
> id="privileges-summary-table"> need to change for variable?
> <varlistentry id="ddl-priv-select">, <varlistentry
> id="ddl-priv-update"> 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?
>
I did it to 01 patch.
The line between 01 and 02 patch can be fuzzy sometimes little bit
Just note: applying only the 01 patch does not make any sense. These
patches (01 and 02) are separated just for review
and testing, but for any usage both patches should be committed or none.
>
> * 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=% normal=% istemp=% type=% identity=% name=%
> args=%',
> 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=# drop variable v1;
> NOTICE: test_event_trigger: ddl_command_start DROP VARIABLE
> NOTICE: NORMAL: orig=t normal=f istemp=f type=session variable
> identity=public.v1 name={public,$} args={}
> DROP VARIABLE
>
> should i expect
> NOTICE: NORMAL: orig=t normal=f istemp=f type=session variable
> identity=public.v1 name={public,$} args={}
> to be
> NOTICE: NORMAL: orig=t normal=f istemp=f type=session variable
> identity=public.v1 name={public,v1} args={}
> ?
>
fixed - there was missing pstrdup(varname) in the related part in
getObjectIdentityParts
I used your example in regress test
new patchset attached with necessary rebase
Regards
Pavel