Re: Using Expanded Objects other than Arrays from plpgsql
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrey Borodin <x4mmm@yandex-team.ru>
Cc: Michel Pelletier <pelletier.michel@gmail.com>,
Pavel Stehule <pavel.stehule@gmail.com>,
pgsql-hackers@lists.postgresql.org
Date: 2025-01-26T19:04:41Z
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
Andrey Borodin <x4mmm@yandex-team.ru> writes: > On 26 Jan 2025, at 20:37, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> Maybe we should recast it as an action. What do you think of >> "mark_expr_as_assignment_source"? > Sounds better to me. I found no examples of similar functions nether in pl_gram.y, nor in gram.y, so IMO mark_expr_as_assignment_source() is the best candidate. WFM, I'll make it so in next version. > Got it, many thanks for the explanation. I'll see about incorporating more of that in the comments, too. > I wonder if you plan similar optimizations for array_cat(), array_remove() etc? > + a := a || a; -- not optimizable > Why is it not optimizable? Because there is no support function, because array_cat() has no support function, or something else? plpgsql won't attempt to optimize it because "a" is referenced twice and there is no support function that might say it's safe anyway. array_cat doesn't currently have any special smarts about expanded arrays, so it's all moot because the arrays would get flattened on the way into it. If we did improve it to be able to cope with expanded arrays, I'm not real sure that it could safely manage an in-place update where the two inputs are the same array --- at the least, some extreme care would be needed to get the right answers. I'm not real excited about optimizing additional array operations anyway. Maybe some more will get done at some point, but I don't see that as part of this work. regards, tom lane