Re: Schema variables - new implementation for Postgres 15

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: Julien Rouhaud <rjuju123(at)gmail(dot)com>, dean(dot)a(dot)rasheed(at)gmail(dot)com, er(at)xs4all(dot)nl, joel(at)compiler(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Schema variables - new implementation for Postgres 15
Date: 2022-11-13 15:01:21
Message-ID: CAFj8pRBp8xza0EJNByhB-22eX8ah=0gKgWjcVWLHAo6Bg9PA9g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

so 5. 11. 2022 v 17:04 odesílatel Tomas Vondra <
tomas(dot)vondra(at)enterprisedb(dot)com> napsal:

> Hi,
>
> I did a quick initial review of this patch series - attached is a
> version with "review" commits for some of the parts. The current patch
> seems in pretty good shape, most of what I noticed are minor issues. I
> plan to do a more thorough review later.
>
> A quick overview of the issues:
>
> 0001
> ----
>
> - AtPreEOXact_SessionVariable_on_xact_actions name seems unnecessarily
> complicated and redundant, and mismatching nearby functions. Why not
> call it AtEOXact_SessionVariable, similar to AtEOXact_LargeObject?
>

renamed

>
> - some whitespace / ordering cleanup
>
> - I'm not sure why find_composite_type_dependencies needs the extra
> "else if" branch (instead of just doing "if" as before)
>

yes, it was not necessary

> - NamesFromList and IdentifyVariable seem introduced unnecessarily
> early, as they are only used in 0002 and 0003 parts (in the original
> patch series). Not sure if the plan is to squash everything into a
> single patch, or commit individual patches.
>

moved to 0002

>
> - AFAIK patches don't need to modify typedefs.list.
>
>
> 0002
> ----
>
> - some whitespace / ordering cleanup
>
> - moving setting hasSessionVariables right after similar fields
>

fixed

>
> - SessionVariableCreatePostprocess prototype is redundant (2x)
>

removed

>
> - I'd probably rename pg_debug_show_used_session_variables to
> pg_session_variables (assuming we want to keep this view)
>

renamed

>
>
> 0003
> ----
>
> - I'd rename svariableState to SVariableState, to keep the naming
> consistent with other similar/related typedefs.
>

renamed

> - some whitespace / ordering cleanup
>
>
> 0007
> ----
>
> - minor wording change
>

fixed

>
>
> Aside from that, I tried running this under valgrind, and that produces
> this report:
>
> ==250595== Conditional jump or move depends on uninitialised value(s)
> ==250595== at 0x731A48: sync_sessionvars_all (session_variable.c:513)
> ==250595== by 0x7321A6: prepare_variable_for_reading
> (session_variable.c:727)
> ==250595== by 0x7320BA: CopySessionVariable (session_variable.c:898)
> ==250595== by 0x7BC3BF: standard_ExecutorStart (execMain.c:252)
> ==250595== by 0x7BC042: ExecutorStart (execMain.c:146)
> ==250595== by 0xA89283: PortalStart (pquery.c:520)
> ==250595== by 0xA84E8D: exec_simple_query (postgres.c:1199)
> ==250595== by 0xA8425B: PostgresMain (postgres.c:4551)
> ==250595== by 0x998B03: BackendRun (postmaster.c:4482)
> ==250595== by 0x9980EC: BackendStartup (postmaster.c:4210)
> ==250595== by 0x996F0D: ServerLoop (postmaster.c:1804)
> ==250595== by 0x9948CA: PostmasterMain (postmaster.c:1476)
> ==250595== by 0x8526B6: main (main.c:197)
> ==250595== Uninitialised value was created by a heap allocation
> ==250595== at 0xCD86F0: MemoryContextAllocExtended (mcxt.c:1138)
> ==250595== by 0xC9FA1F: DynaHashAlloc (dynahash.c:292)
> ==250595== by 0xC9FEC1: element_alloc (dynahash.c:1715)
> ==250595== by 0xCA102A: get_hash_entry (dynahash.c:1324)
> ==250595== by 0xCA0879: hash_search_with_hash_value (dynahash.c:1097)
> ==250595== by 0xCA0432: hash_search (dynahash.c:958)
> ==250595== by 0x731614: SetSessionVariable (session_variable.c:846)
> ==250595== by 0x82FEED: svariableReceiveSlot (svariableReceiver.c:138)
> ==250595== by 0x7BD277: ExecutePlan (execMain.c:1726)
> ==250595== by 0x7BD0C5: standard_ExecutorRun (execMain.c:422)
> ==250595== by 0x7BCE63: ExecutorRun (execMain.c:366)
> ==250595== by 0x7332F0: ExecuteLetStmt (session_variable.c:1310)
> ==250595== by 0xA8CC15: standard_ProcessUtility (utility.c:1076)
> ==250595== by 0xA8BC72: ProcessUtility (utility.c:533)
> ==250595== by 0xA8B2B9: PortalRunUtility (pquery.c:1161)
> ==250595== by 0xA8A454: PortalRunMulti (pquery.c:1318)
> ==250595== by 0xA89A16: PortalRun (pquery.c:794)
> ==250595== by 0xA84F9E: exec_simple_query (postgres.c:1238)
> ==250595== by 0xA8425B: PostgresMain (postgres.c:4551)
> ==250595== by 0x998B03: BackendRun (postmaster.c:4482)
> ==250595==
>
> Which I think means this:
>
> if (filter_lxid && svar->drop_lxid == MyProc->lxid)
> continue;
>
> accesses drop_lxid, which was not initialized in init_session_variable.
>

fixed

Thank you very much for this review.

Today's patch should solve all issues reported by Tomas.

Regards

Pavel

>
> regards
>
> --
> Tomas Vondra
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company

Attachment Content-Type Size
v20221113-1-0010-documentation.patch text/x-patch 43.7 KB
v20221113-1-0008-regress-tests-for-session-variables.patch text/x-patch 59.6 KB
v20221113-1-0007-possibility-to-dump-session-variables-by-pg_dump.patch text/x-patch 19.5 KB
v20221113-1-0006-enhancing-psql-for-session-variables.patch text/x-patch 15.2 KB
v20221113-1-0009-this-patch-changes-error-message-column-doesn-t-exis.patch text/x-patch 23.7 KB
v20221113-1-0005-DISCARD-VARIABLES-command.patch text/x-patch 3.2 KB
v20221113-1-0004-support-of-LET-command-in-PLpgSQL.patch text/x-patch 11.9 KB
v20221113-1-0003-LET-command.patch text/x-patch 44.9 KB
v20221113-1-0002-session-variables.patch text/x-patch 110.2 KB
v20221113-1-0001-catalog-support-for-session-variables.patch text/x-patch 93.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2022-11-13 15:02:06 Re: Typo about subxip in comments
Previous Message Pavel Stehule 2022-11-13 14:58:34 Re: Schema variables - new implementation for Postgres 15