Open DrewKimball opened 1 day ago
Thanks for opening a backport.
Please check the backport criteria before merging:
Also, please add a brief release justification to the body of your PR to justify this backport.
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.
Backport 4/4 commits from #135556.
/cc @cockroachdb/release
sql: refactor functions for handling cat.Trigger
This commit performs some refactoring for the functions that check for the presence of and collect the list of triggers that apply to a given mutation. The functions are now exported to be used in following commits.
Informs #134747 Informs #135155
Release note: None
opt: display BEFORE-trigger names in opt-tester output
This commit adds a
before-triggers
field to the opt-tester output for mutations. Similar to theafter-triggers
field, it displays the names of the triggers that will fire for that mutation.Informs #134747
Release note: None
sql: display BEFORE trigger names for EXPLAIN
This commit adds the names of fired BEFORE triggers to the EXPLAIN output for a mutation. This is visible in both verbose and non-verbose variants, as well as
EXPLAIN ANALYZE
. Note that the verbose EXPLAIN already shows the trigger-function invocations; the benefit of this change is that it makes clear even in non-verbose EXPLAIN which triggers fired.Fixes #134747
Release note (sql change): The names of BEFORE triggers fired by a mutation now show up in the EXPLAIN output. The trigger-function invocations are visible in the output of verbose EXPLAIN.
sql: display AFTER triggers for EXPLAIN
This commit adds AFTER triggers to the
EXPLAIN
andEXPLAIN ANALYZE
outputs. The output displays the names of the fired triggers, and then the expressions used to implement them, including the buffer scan that supplies the mutated rows.There is a subtlety in displaying the plans for triggers for the
ANALYZE
variants that actually execute the query. This is because the transaction may have auto-committed by the time the plan is being explained, and so attempts to resolve objects while building the trigger plan will fail.To avoid this problem, we check if the transaction is still open before attempting to build the plan for
AFTER
triggers, or a cascade withBEFORE
triggers. As a result, if the statement auto-commits, only the trigger plans that were actually involved in the execution will be displayed. Note that this will only affect the EXPLAIN output for mutations that involve triggers.Fixes #135155
Release note (sql change): AFTER triggers will now show up in the output of vanilla
EXPLAIN
, as well asEXPLAIN ANALYZE
.Release justification: observability improvement for new functionality in 24.3