You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
155824: sql: fix top-level query stats when "inner" plans are present r=yuzefovich a=yuzefovich
Previously, whenever we ran an "inner" plan (via `runPlanInsidePlan` helper), we ignored the top-level query stats for the "inner" plan. As a result, reads and writes performed by the inner plan weren't reflected in the "outer" top-level query stats. This is now fixed by adjusting the routines, apply joins, and recursive CTEs to propagate their metrics as ProducerMetadata objects.
Note that for routines the access to the DistSQL infra is rather difficult, so we plumbed the access via the planner straight into the DistSQLReceiver, and even though it's ugly, it should work in practice. The only alternative I see is adding the necessary reference into the `eval.Context`, but then it gets tricky to actually set that and ensure the right copy of the eval context is observed by all routines (plus we'd need to make the copy or restore the original state somehow), so I chose to not pursue it.
Epic: None
Release note (bug fix): Previously, CockroachDB didn't include reads and writes performed by routines (user-defined functions and stored procedures) as well as apply joins into `bytes read`, `rows read`, and `rows written` statement execution statistics, and this is now fixed. The bug has been present since before 23.2 version.
155867: sql: fix REPLACE routine logic with multiple DEFAULT expressions r=yuzefovich a=yuzefovich
When we added support for DEFAULT expressions in routine signatures in 41cb974, we introduced a bug for REPLACE functionality. Namely, we need to store the type-checked serialized representation of the default expressions in the proto, so the expressions in the existing Overload must also have been type-checked (so that we can find the correct signature in the proto to update). However, we had the incorrect short-circuiting behavior when type-checking existing default expressions where we'd stop once a "signature change" is discovered. The fix is simple - we need to type-check all default expressions separately from checking whether the signature has changed.
Fixes: #155859.
Release note (bug fix): Previously, CockroachDB could encounter an internal error when replacing (via CREATE OR REPLACE stmt) a user-defined function or a stored procedure when multiple DEFAULT expressions are included in the old signature. The bug has been present since v24.2 (when support for DEFAULT expressions was added) and is now fixed.
Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
0 commit comments