Re: Using Expanded Objects other than Arrays from plpgsql
Pavel Borisov <pashkin.elfe@gmail.com>
From: Pavel Borisov <pashkin.elfe@gmail.com>
To: Michel Pelletier <pelletier.michel@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andrey Borodin <x4mmm@yandex-team.ru>, Pavel Stehule <pavel.stehule@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-02-03T11:42:04Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Allow extension functions to participate in in-place updates.
- c366d2bdba7c 18.0 landed
-
Implement new optimization rule for updates of expanded variables.
- 6c7251db0ce1 18.0 landed
-
Detect whether plpgsql assignment targets are "local" variables.
- 36fb9ef269a0 18.0 landed
-
Preliminary refactoring of plpgsql expression construction.
- a654af21ae52 18.0 landed
-
Refactor pl_funcs.c to provide a usage-independent tree walker.
- 6a7283dd2f1c 18.0 landed
-
Generalize plpgsql's heuristic for importing expanded objects.
- 534d0ea6c2b9 18.0 landed
Hi, Tom On Mon, 3 Feb 2025 at 07:02, Michel Pelletier <pelletier.michel@gmail.com> wrote: > > On Sun, Feb 2, 2025 at 1:57 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: >> >> I wrote: >> > Hmm, it seemed to still apply for me. But anyway, I needed to make >> > the other changes, so here's v4. >> >> PFA v5. The new 0001 patch refactors the free_xxx infrastructure >> to create plpgsql_statement_tree_walker(), and then in what's now >> 0003 we can use that instead of writing a lot of duplicate code. > > > Thanks Tom! These patches apply for me and all my tests and benchmarks are still good. I've looked at the patches v4 and v5. v5 logic of patch 0003 is much more understandable with refactoring free_* functions to a walker. So I think it's much better than v4 even regarding the principle have not changed. Using support functions in 0005 complicates things. But I think it's justified by extensibility and benchmarks demonstrated by Michel above in the thread. Overall patch to me looks well-structured, beneficial for performance and extensibility and it looks good to me. Minor notes on the patches: If dump_* functions could use the newly added walker, the code would look better. I suppose the main complication is that dump_* functions contain a lot of per-statement prints/formatting. So maybe a way to implement this is to put these statements into the existing tree walker i.e. plpgsql_statement_tree_walker_impl() and add an argument bool dump_debug into it. So in effect called with dump_debug=false plpgsql_statement_tree_walker_impl() would walk silent, and with dump_debug=false it would walk and print what is supposed to be printed currently in dump_* functions. Maybe there are other problems besides this? For exec_check_rw_parameter(): I think renaming expr->expr_simple_expr to sexpr saves few bytes but doesn't makes anything simpler, so if possible I'd prefer using just expr->expr_simple_expr with necessary casts. Furtermore in this function mostly we use cast results fexpr, opexpr and sbsref of expr->expr_simple_expr that already has separate names. Transferring target param as int paramid looks completely ok. But we have unconditional checking Assert(paramid == expr->target_param + 1), so it looks as a redundant split as of now. Do we plan a true split and removal of this assert in the future? Thanks for creating and working on this patch! Regards, Pavel Borisov Supabase