From a2859aa099089f81516968be28768a51e94a59c2 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Thu, 18 May 2023 18:00:43 -0400 Subject: [PATCH] sql: prevent panic when reading annotation in COPY TO Release note (bug fix): Fixed a panic that could occur if a COPY TO statement that had a subquery was logged with redaction markers. --- pkg/sql/conn_executor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/sql/conn_executor.go b/pkg/sql/conn_executor.go index b54ed4fde584..2b7866412941 100644 --- a/pkg/sql/conn_executor.go +++ b/pkg/sql/conn_executor.go @@ -2887,7 +2887,7 @@ func (ex *connExecutor) setCopyLoggingFields(stmt statements.Statement[tree.Stat ex.planner.stmt = Statement{ Statement: stmt, } - ann := tree.MakeAnnotations(0) + ann := tree.MakeAnnotations(stmt.NumAnnotations) ex.planner.extendedEvalCtx.Context.Annotations = &ann ex.planner.extendedEvalCtx.Context.Placeholders = &tree.PlaceholderInfo{} ex.planner.curPlan.init(&ex.planner.stmt, &ex.planner.instrumentation)