| From: | "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com> |
|---|---|
| To: | "Robert Haas" <robertmhaas(at)gmail(dot)com> |
| Cc: | <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Lukas Fittl" <lukas(at)fittl(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Subject: | Re: Add custom EXPLAIN options support to auto_explain |
| Date: | 2026-04-02 21:41:35 |
| Message-ID: | DHIZV2B6QRO0.3PX0A6T2M0QB7@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu Apr 2, 2026 at 3:17 PM -03, Robert Haas wrote:
> On Tue, Mar 31, 2026 at 6:10 PM Matheus Alcantara
> <matheusssilv97(at)gmail(dot)com> wrote:
>> I think that we are safe against overflow because on
>> auto_explain_split_options() it has intval == (int) intval, but I'm
>> wondering if it's worth documenting this?
>
> We could add a comment here that the validity checks have already been
> done at an earlier stage, but I felt like that was overkill. Possibly
> not?
>
I think that it's useful but reading the new version I think that with a
bit of debugging we can find that auto_explain_split_options() is the
only function that set auto_explain_option->value and we check it for
overflow before assigning. So yeah, I don't think that is mandatory for
now.
>> extension_options is being added to REGRESS in both Makefile and
>> meson.build, but the actual test files are not included.
>
> Well, that sucks. I accidentally erased that file instead of
> committing it. Here's a new version with mostly the same tests, plus I
> updated the TAP test with a related test case as well.
>
+SET auto_explain.log_extension_options = $$'$$;
+ERROR: unrecognized EXPLAIN option "'"
IICU this is testing syntax errors and although we have the same error
message when setting the GUC to an option that doesn't exists (e.g SET
auto_explain.log_extension_options = 'wrong') I'm wondering if it should
have a test case for this scenario, to ensure the behaviour? What do you
think?
>> + an associated value. The module that provides the
>> + <literal>EXPLAIN</literal> option, such as
>> + <link linkend="pgplanadvice"><literal>pg_plan_advice</literal></link> or
>> + <link linkend="pgoverexplain"><literal>pg_overexplain</literal></link>,
>> + should be loaded before this parameter is set.
>>
>> Wondering if this is clear enough about the shared_preload_libraries
>> order (auto_explain should be loaded after extensions that include
>> explain options) or if we should mention this explicitly.
>
> I actually thought that this might not be true until I tested it and
> found that it sort of is. If you don't set
> auto_explain.log_extension_options in postgresql.conf, then you can
> load the modules in either order and it's fine. But if you do set it,
> then you need to have the EXPLAIN option provider before auto_explain,
> or else you get something like this:
>
> 2026-04-02 14:03:19.282 EDT [4614] WARNING: unrecognized EXPLAIN option "debug"
>
> ...because we read the whole postgresql.conf file before applying any
> of it, and so if auto_explain's _PG_init() runs first, the GUC value
> is already visible but the EXPLAIN option doesn't exist yet. That's
> annoying, but I'm not sure it's worth any more of a documentation
> reference than what I have already. "Before this parameter is set"
> could be read to encompass "put it earlier in
> shared_preload_libraries," and if someone does it wrong, it will
> become obvious quickly enough. If you (or someone else) doesn't agree,
> feel free to propose better wording -- I just don't want to expand the
> description so much that it becomes a distraction.
Yeah, make sense, agree.
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matthias van de Meent | 2026-04-02 22:10:21 | Re: Better shared data structure management and resizable shared data structures |
| Previous Message | Andres Freund | 2026-04-02 21:30:05 | Re: AIO / read stream heuristics adjustments for index prefetching |