-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql,*: rework plan hooks to type check separately from execution
Prior to this change, plan hooks would be invokved twice, once during prepare and again during execution. At prepare time, the placeholder values are not known, but, critically, the placeholders were being type-checked. This type checking informs the sql layer how to interpret the placeholder values when we are trying to bind them. Importantly, the sql layer does not ever use the `planNode` produced via the `PlanHookRowFn` returned from the planning invocation. The above dance meant that these plan hooks had quite a bit of complexity to eagerly type check but lazily evaluate expressions passed in via the statement. This complexity became a problem more recently: one cannot and should not access many planner data structures from the row func because such functions can, theoretically, run concurrently and these data structures are not thread safe. Note that the above problem is not commonly a real problem. Most plan hook statements don't permit concurrency and those than do, via, say, `UNION ALL` don't commonly get executed in such a setting. In some ways, the real reason for this change is to unwind some unneeded complexity and clarify the bounds of what one can do in a plan hook. The big change which unearthed the problem is that we now support privileges on external URLs. These URLs may be provided via placeholders or expressions. If we couldn't access the expressions until we were in the row fn, then we'd be at risk of performing privilege checking concurrently, which is not safe. One thing that this commit does is introduce a new package `exprutil` with helpers for type checking. It is so named because I'd like to also remove the methods from the `PlanHookState` which we now use for expr evaluation and place them in this new package. Fixes #88385 Release note: None
- Loading branch information
Showing
42 changed files
with
1,334 additions
and
992 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.