From cfc445a232db4e8146242db3920a378d93fad261 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Mon, 22 Aug 2022 15:58:27 -0400 Subject: [PATCH] sql: add nil guard when formatting placeholders Release note (bug fix): Fixed a crash that could happen when formatting queries that have placeholder BitArray arguments. Release note: Fix a panic. --- pkg/sql/conn_executor_exec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/sql/conn_executor_exec.go b/pkg/sql/conn_executor_exec.go index 63419254bfc9..9f85c87cfdde 100644 --- a/pkg/sql/conn_executor_exec.go +++ b/pkg/sql/conn_executor_exec.go @@ -803,7 +803,7 @@ func formatWithPlaceholders(ast tree.Statement, evalCtx *eval.Context) string { fmtFlags, tree.FmtPlaceholderFormat(func(ctx *tree.FmtCtx, placeholder *tree.Placeholder) { d, err := eval.Expr(evalCtx, placeholder) - if err != nil { + if err != nil || d == nil { // Fall back to the default behavior if something goes wrong. ctx.Printf("$%d", placeholder.Idx+1) return