forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6719b23
committed
Rearrange execution of PARAM_EXTERN Params for plpgsql's benefit.
This patch does three interrelated things:* Create a new expression execution step type EEOP_PARAM_CALLBACKand add the infrastructure needed for add-on modules to generate that.As discussed, the best control mechanism for that seems to be to addanother hook function to ParamListInfo, which will be called byExecInitExpr if it's supplied and a PARAM_EXTERN Param is found.For stand-alone expressions, we add a new entry point to allow theParamListInfo to be specified directly, since it can't be retrievedfrom the parent plan node's EState.* Redesign the API for the ParamListInfo paramFetch hook so that theParamExternData array can be entirely virtual. This also lets us get ridof ParamListInfo.paramMask, instead leaving it to the paramFetch hook todecide which param IDs should be accessible or not. plpgsql_param_fetchwas already doing the identical masking check, so having callers do it tooseemed redundant. While I was at it, I added a "speculative" flag toparamFetch that the planner can specify as TRUE to avoid unwanted failures.This solves an ancient problem for plpgsql that it couldn't provide valuesof non-DTYPE_VAR variables to the planner for fear of triggering premature"record not assigned yet" or "field not found" errors during planning.* Rework plpgsql to get rid of the need for "unshared" parameter lists,by dint of turning the single ParamListInfo per estate into a nearlyread-only data structure that doesn't instantiate any per-variable data.Instead, the paramFetch hook controls access to per-variable data and canmake the right decisions on the fly, replacing the cases that we used toneed multiple ParamListInfos for. This might perhaps have been aperformance loss on its own, but by using a paramCompile hook we canbypass plpgsql_param_fetch entirely during normal query execution.(It's now only called when, eg, we copy the ParamListInfo into a cursorportal. copyParamList() or SerializeParamList() effectively instantiatethe virtual parameter array as a simple physical array without aparamFetch hook, which is what we want in those cases.) This allowsreverting most of commit6c82d8d, though I kept the cosmeticcode-consolidation aspects of that (eg the assign_simple_var function).Performance testing shows this to be at worst a break-even change,and it can provide wins ranging up to 20% in test cases involvingaccesses to fields of "record" variables. The fact that values ofsuch variables can now be exposed to the planner might produce winsin some situations, too, but I've not pursued that angle.In passing, remove the "parent" pointer from the arguments toExecInitExprRec and related functions, instead storing that pointer in atransient field in ExprState. The ParamListInfo pointer for a stand-aloneexpression is handled the same way; we'd otherwise have had to addyet another recursively-passed-down argument in expression compilation.Discussion:https://postgr.es/m/32589.1513706441@sss.pgh.pa.us1 parent8a0596c commit6719b23
File tree
16 files changed
+613
-406
lines changed- src
- backend
- commands
- executor
- nodes
- optimizer/util
- tcop
- include
- executor
- nodes
- pl/plpgsql/src
16 files changed
+613
-406
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
399 | 399 |
| |
400 | 400 |
| |
401 | 401 |
| |
| 402 | + | |
| 403 | + | |
402 | 404 |
| |
403 | 405 |
| |
404 | 406 |
| |
405 |
| - | |
406 | 407 |
| |
407 | 408 |
| |
408 | 409 |
| |
|
Lines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
216 | 216 |
| |
217 | 217 |
| |
218 | 218 |
| |
219 |
| - | |
| 219 | + | |
| 220 | + | |
220 | 221 |
| |
221 | 222 |
| |
222 |
| - | |
223 |
| - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
224 | 227 |
| |
225 | 228 |
| |
226 | 229 |
| |
|
0 commit comments
Comments
(0)