Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: index out of range during EXPLAIN (TYPES) of DELETE FROM USING #105803

Closed
cockroach-teamcity opened this issue Jun 29, 2023 · 1 comment · Fixed by #105932
Closed

sql: index out of range during EXPLAIN (TYPES) of DELETE FROM USING #105803

cockroach-teamcity opened this issue Jun 29, 2023 · 1 comment · Fixed by #105932
Assignees
Labels
A-sql-explain Issues related to EXPLAIN and EXPLAIN ANALYZE improvements branch-release-23.1 Used to mark GA and release blockers and technical advisories for 23.1 C-test-failure Broken test (automatically or manually discovered). O-robot Originated from a bot. T-sql-queries SQL Queries Team
Projects
Milestone

Comments

@cockroach-teamcity
Copy link
Member

cockroach-teamcity commented Jun 29, 2023

pkg/ccl/testccl/sqlccl/sqlccl_test.TestExplainRedactDDL failed with artifacts on release-23.1 @ f13c021bb97531ac876c2c1438a9d4bfc80d1c32:

Fatal error:

panic: runtime error: index out of range [2] with length 2 [recovered]
	panic: runtime error: index out of range [2] with length 2 [recovered]
	panic: runtime error: index out of range [2] with length 2 [recovered]
	panic: runtime error: index out of range [2] with length 2 [recovered]
	panic: runtime error: index out of range [2] with length 2

Stack:

goroutine 535549 [running]:
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).closeWrapper(0xc00adec000, {0x73f7f40, 0xc00c8c6720}, {0x5ac9480?, 0xc00dd77098?})
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1159 +0x1b4
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1({0x73f7f40, 0xc00c8c6720}, {0xda1bfc9c?})
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:898 +0x4a
panic({0x5ac9480, 0xc00dd77098})
	GOROOT/src/runtime/panic.go:884 +0x212
github.com/cockroachdb/cockroach/pkg/sql/colexecerror.CatchVectorizedRuntimeError.func1()
	github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:58 +0x407
panic({0x5ac9480, 0xc00dd77098})
	GOROOT/src/runtime/panic.go:884 +0x212
github.com/cockroachdb/cockroach/pkg/sql/colexecerror.CatchVectorizedRuntimeError.func1()
	github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:58 +0x407
panic({0x5ac9480, 0xc00dd77098})
	GOROOT/src/runtime/panic.go:884 +0x212
github.com/cockroachdb/cockroach/pkg/sql.emitExplain.func1()
	github.com/cockroachdb/cockroach/pkg/sql/explain_plan.go:194 +0x4d
panic({0x5ac9480, 0xc00dd77098})
	GOROOT/src/runtime/panic.go:884 +0x212
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.(*OutputBuilder).Expr.func1(0xc00305f740, 0x2)
	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/output.go:159 +0xc8
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*IndexedVar).Format(0x0?, 0x73b27c0?)
	github.com/cockroachdb/cockroach/pkg/sql/sem/tree/indexed_vars.go:86 +0xa7
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*FmtCtx).formatNodeMaybeMarkRedaction(0xc00305f740?, {0x73b27c0?, 0xc0097ba5d0?})
	github.com/cockroachdb/cockroach/pkg/sql/sem/tree/format.go:692 +0x263
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*FmtCtx).FormatNode(0xc00305f740, {0x73b27c0, 0xc0097ba5d0})
	github.com/cockroachdb/cockroach/pkg/sql/sem/tree/format.go:440 +0x2d3
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.(*OutputBuilder).Expr(0xc0048767d0, {0xc003656a80, 0xd}, {0x742e448, 0xc0097ba5d0}, {0xc005ae9d10, 0x2, 0x2})
	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/output.go:163 +0x1b3
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.(*emitter).emitNodeAttributes(0xc004876128, 0xc0097ba500)
	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:601 +0xa419
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.Emit.func1(0xc004876128?)
	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:53 +0x11b
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.Emit.func1(0xc004876138?)
	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:57 +0x1a2
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.Emit(0xc0097baa80, 0xc0048767d0, 0x0?)
	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:103 +0x8c5
github.com/cockroachdb/cockroach/pkg/sql.emitExplain(0xc0048767d0?, 0xc00549bc80?, {{0xc0013b49f0?, 0xc0013b4a08?}, {0xc0013b49f0?}, 0x0?}, 0x0?)
	github.com/cockroachdb/cockroach/pkg/sql/explain_plan.go:228 +0xe5
github.com/cockroachdb/cockroach/pkg/sql.(*explainPlanNode).startExec(0xc003edb000, {{0x73f7f40, 0xc00549bbc0}, 0xc003edc800, 0xc00adec620})
	github.com/cockroachdb/cockroach/pkg/sql/explain_plan.go:132 +0x75d
github.com/cockroachdb/cockroach/pkg/sql.startExec.func2({0xc004876b28?, 0x464904?}, {0x73fa5c0, 0xc003edb000})
	github.com/cockroachdb/cockroach/pkg/sql/plan.go:519 +0x143
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal.func1()
	github.com/cockroachdb/cockroach/pkg/sql/walk.go:112 +0x3e
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal(0xc004876c38, {0x73fa5c0?, 0xc003edb000?}, {0x5e2172c?, 0xc?})
	github.com/cockroachdb/cockroach/pkg/sql/walk.go:299 +0x1523
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visit(0xc004876c38, {0x73fa5c0, 0xc003edb000})
	github.com/cockroachdb/cockroach/pkg/sql/walk.go:79 +0xf7
github.com/cockroachdb/cockroach/pkg/sql.walkPlan(...)
	github.com/cockroachdb/cockroach/pkg/sql/walk.go:43
github.com/cockroachdb/cockroach/pkg/sql.startExec({{0x73f7f40?, 0xc00549bbc0?}, 0xc003edc800?, 0xc00adec620?}, {0x73fa5c0, 0xc003edb000})
	github.com/cockroachdb/cockroach/pkg/sql/plan.go:522 +0x119
github.com/cockroachdb/cockroach/pkg/sql.(*planNodeToRowSource).Start(0xc00b43a840, {0x73f7f40, 0xc00549bb60})
	github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:174 +0x113
github.com/cockroachdb/cockroach/pkg/sql/colexec.(*Columnarizer).Init(0xc004737800, {0x73f7f40, 0xc00549bb00})
	github.com/cockroachdb/cockroach/pkg/sql/colexec/columnarizer.go:183 +0xf3
github.com/cockroachdb/cockroach/pkg/sql/colexec.(*invariantsChecker).Init(0xc003edb500, {0x73f7f40?, 0xc00549bb00?})
	github.com/cockroachdb/cockroach/pkg/sql/colexec/invariants_checker.go:67 +0x4f
github.com/cockroachdb/cockroach/pkg/sql/colflow.(*batchInfoCollector).init(0x557c020?)
	github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:94 +0x2c
github.com/cockroachdb/cockroach/pkg/sql/colexecerror.CatchVectorizedRuntimeError(0xc003edb540?)
	github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:92 +0x62
github.com/cockroachdb/cockroach/pkg/sql/colflow.(*batchInfoCollector).Init(0xc002f23ef0, {0x73f7f40?, 0xc00549bb00?})
	github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:103 +0x7f
github.com/cockroachdb/cockroach/pkg/sql/colflow.(*BatchFlowCoordinator).init.func1()
	github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:245 +0x2e
github.com/cockroachdb/cockroach/pkg/sql/colexecerror.CatchVectorizedRuntimeError(0x2?)
	github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:92 +0x62
github.com/cockroachdb/cockroach/pkg/sql/colflow.(*BatchFlowCoordinator).init(0x73f7e98?, {0x73f7f40?, 0xc00549bb00?})
	github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:244 +0x4f
github.com/cockroachdb/cockroach/pkg/sql/colflow.(*BatchFlowCoordinator).Run(0xc00ed088c0, {0x73f7e98?, 0xc003edb440?})
	github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:278 +0xe7
github.com/cockroachdb/cockroach/pkg/sql/colflow.(*vectorizedFlow).Run(0xc00b01e300, {0x73f7e98, 0xc003edb440}, 0x0)
	github.com/cockroachdb/cockroach/pkg/sql/colflow/vectorized_flow.go:325 +0x20d
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).Run(0xc001220000, {0x73f7f40, 0xc00549b7d0}, 0xc007242580, 0xc001924b00, 0xc0097bad80, 0xc005262700, 0xc00adeca58, 0xc00371f9d0)
	github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:902 +0xb93
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).PlanAndRun(0x0?, {0x73f7f40, 0xc00549b7d0}, 0xc004877b58?, 0xc007242580, 0xc003edb000?, {{0x73fa5c0?, 0xc003edb000?}, 0x0?}, 0xc005262700, ...)
	github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1913 +0x205
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).PlanAndRunAll.func3(0xc00adec620, 0x0?, {0x73f7f40, 0xc00549b7d0}, 0xc00549b800?, 0x0?, 0xc004877b88?)
	github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1645 +0xcb
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).PlanAndRunAll(0xc007242580?, {0x73f7f40?, 0xc00549b7d0}, 0xc00adeca58, 0xc007242580, 0xc00adec620, 0xc005262700, 0x0)
	github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1648 +0x245
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execWithDistSQLEngine(0xc00adec000, {0x73f7f40?, 0xc00549b7d0}, 0xc00adec620, 0xc00549b7d0?, {0x7feec7291d80?, 0xc003346728}, 0xc003346728?, 0xc00259c398)
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2103 +0x5eb
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).dispatchToExecutionEngine(0xc00adec000, {0x73f7f40, 0xc00cc49830}, 0xc00adec620, {0x7feec7291d80, 0xc003346728})
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1656 +0x11b2
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmtInOpenState(0xc00adec000, {0x73f7f40, 0xc00cc49830}, {{0x7423780, 0xc0010e8640}, {0x0, 0x0, 0x0}, {0xc00377b416, 0x171}, ...}, ...)
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:964 +0x3a51
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmt.func1({0x73f7f40?, 0xc00cc49650?})
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:142 +0xbc
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execWithProfiling(0x73f7f40?, {0x73f7f40?, 0xc00cc49650?}, {0x7423780?, 0xc0010e8640?}, 0x64?, 0x0?)
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2986 +0x330
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmt(0xc00adec000, {0x73f7f40, 0xc00cc49650}, {{0x7423780, 0xc0010e8640}, {0x0, 0x0, 0x0}, {0xc00377b416, 0x171}, ...}, ...)
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:141 +0x4dd
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execCmd.func1(0xc004879a78, 0xc00adec000, 0xc0048795d0, 0xc0048796a0, 0xc0048796e0, 0xc0048796c0, 0xc0048796b0, 0xc0048796d0)
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2181 +0x319
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execCmd(0xc00adec000)
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2186 +0x1167
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run(0xc00adec000, {0x73f7f40, 0xc00c8c6720}, 0xc00242a2e0?, 0xc0047fbda0?, 0xc00992e950?)
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2103 +0x216
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn(0xc00242a280?, {0x73f7f40?, 0xc00c8c6720?}, {0x5ded873?}, 0x3?, 0xc002640410?)
	github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:900 +0xe6
github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync.func1()
	github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:310 +0x585
created by github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync
	github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:219 +0x22a
Log preceding fatal error

*   | 	GOROOT/src/runtime/panic.go:113
*   | github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.(*OutputBuilder).Expr.func1
*   | 	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/output.go:159
*   | github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*IndexedVar).Format
*   | 	github.com/cockroachdb/cockroach/pkg/sql/sem/tree/indexed_vars.go:86
*   | github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*FmtCtx).formatNodeMaybeMarkRedaction
*   | 	github.com/cockroachdb/cockroach/pkg/sql/sem/tree/format.go:692
*   | github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*FmtCtx).FormatNode
*   | 	github.com/cockroachdb/cockroach/pkg/sql/sem/tree/format.go:440
*   | github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.(*OutputBuilder).Expr
*   | 	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/output.go:163
*   | github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.(*emitter).emitNodeAttributes
*   | 	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:601
*   | github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.Emit.func1
*   | 	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:53
*   | github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.Emit.func1
*   | 	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:57
*   | github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain.Emit
*   | 	github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:103
*   | github.com/cockroachdb/cockroach/pkg/sql.emitExplain
*   | 	github.com/cockroachdb/cockroach/pkg/sql/explain_plan.go:228
*   | github.com/cockroachdb/cockroach/pkg/sql.(*explainPlanNode).startExec
*   | 	github.com/cockroachdb/cockroach/pkg/sql/explain_plan.go:132
*   | github.com/cockroachdb/cockroach/pkg/sql.startExec.func2
*   | 	github.com/cockroachdb/cockroach/pkg/sql/plan.go:519
*   | github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal.func1
*   | 	github.com/cockroachdb/cockroach/pkg/sql/walk.go:112
*   | github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal
*   | 	github.com/cockroachdb/cockroach/pkg/sql/walk.go:299
*   | github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visit
*   | 	github.com/cockroachdb/cockroach/pkg/sql/walk.go:79
*   | github.com/cockroachdb/cockroach/pkg/sql.walkPlan
*   | 	github.com/cockroachdb/cockroach/pkg/sql/walk.go:43
*   | github.com/cockroachdb/cockroach/pkg/sql.startExec
*   | 	github.com/cockroachdb/cockroach/pkg/sql/plan.go:522
*   | github.com/cockroachdb/cockroach/pkg/sql.(*planNodeToRowSource).Start
*   | 	github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:174
*   | github.com/cockroachdb/cockroach/pkg/sql/colexec.(*Columnarizer).Init
*   | 	github.com/cockroachdb/cockroach/pkg/sql/colexec/columnarizer.go:183
*   | github.com/cockroachdb/cockroach/pkg/sql/colexec.(*invariantsChecker).Init
*   | 	github.com/cockroachdb/cockroach/pkg/sql/colexec/invariants_checker.go:67
*   | github.com/cockroachdb/cockroach/pkg/sql/colflow.(*batchInfoCollector).init
*   | 	github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:94
*   | github.com/cockroachdb/cockroach/pkg/sql/colexecerror.CatchVectorizedRuntimeError
*   | 	github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:92
*   | github.com/cockroachdb/cockroach/pkg/sql/colflow.(*batchInfoCollector).Init
*   | 	github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:103
* Wraps: (4) runtime error: index out of range [2] with length 2
* Error types: (1) *withstack.withStack (2) *safedetails.withSafeDetails (3) *withstack.withStack (4) runtime.boundsError
*

Parameters: TAGS=bazel,gss,deadlock

Help

See also: How To Investigate a Go Test Failure (internal)

/cc @cockroachdb/sql-queries

This test on roachdash | Improve this report!

Jira issue: CRDB-29207

@cockroach-teamcity cockroach-teamcity added branch-release-23.1 Used to mark GA and release blockers and technical advisories for 23.1 C-test-failure Broken test (automatically or manually discovered). O-robot Originated from a bot. labels Jun 29, 2023
@cockroach-teamcity cockroach-teamcity added this to the 23.1 milestone Jun 29, 2023
@cockroach-teamcity cockroach-teamcity added this to Triage in SQL Queries Jun 29, 2023
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Jun 29, 2023
@michae2 michae2 self-assigned this Jun 29, 2023
@michae2 michae2 moved this from Triage to Active in SQL Queries Jun 29, 2023
@michae2
Copy link
Collaborator

michae2 commented Jun 30, 2023

Reduced to:

CREATE TABLE a (a INT);
CREATE TABLE b (b INT);
EXPLAIN (TYPES) SELECT 1 FROM [DELETE FROM a USING b WHERE b > 1 RETURNING a, b, NULL];

Here's the stack:

demo@127.0.0.1:26257/demoapp/defaultdb> EXPLAIN (TYPES) SELECT 1 FROM [DELETE FROM a USING b WHERE b > 1 RETURNING a, b, NULL];
ERROR: internal error: runtime error: index out of range [2] with length 2
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/util/errorutil/catch.go:29: ShouldCatch()
github.com/cockroachdb/cockroach/pkg/sql/explain_plan.go:190: func1()
GOROOT/src/runtime/panic.go:884: gopanic()
GOROOT/src/runtime/panic.go:113: goPanicIndex()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/output.go:159: func1()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/indexed_vars.go:86: Format()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/hide_constants.go:49: formatNodeOrHideConstants()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/format.go:446: FormatNode()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/output.go:163: Expr()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:611: emitNodeAttributes()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:53: func1()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:57: func1()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/emit.go:103: Emit()
github.com/cockroachdb/cockroach/pkg/sql/explain_plan.go:229: emitExplain()
github.com/cockroachdb/cockroach/pkg/sql/explain_plan.go:133: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan.go:519: func2()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:112: func1()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:299: visitInternal()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:79: visit()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:43: walkPlan()
github.com/cockroachdb/cockroach/pkg/sql/plan.go:522: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:174: Start()
github.com/cockroachdb/cockroach/pkg/sql/colexec/columnarizer.go:183: Init()
github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:94: init()
github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:92: CatchVectorizedRuntimeError()
github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:103: Init()
github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:245: func1()
github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:92: CatchVectorizedRuntimeError()
github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:244: init()
github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:278: Run()
github.com/cockroachdb/cockroach/pkg/sql/colflow/vectorized_flow.go:317: Run()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:902: Run()

And removing the NULL in the RETURNING changes it to a nil pointer dereference.

@michae2 michae2 added the A-sql-explain Issues related to EXPLAIN and EXPLAIN ANALYZE improvements label Jun 30, 2023
@michae2 michae2 changed the title pkg/ccl/testccl/sqlccl/sqlccl_test: TestExplainRedactDDL failed sql: index out of range during EXPLAIN (TYPES) of DELETE FROM USING Jun 30, 2023
michae2 added a commit to michae2/cockroach that referenced this issue Jun 30, 2023
Now that we support `DELETE USING`, delete nodes can have passthrough
columns. Add these to the result columns used by `EXPLAIN (TYPES)`.

Fixes: cockroachdb#105803

Release note (sql change): Fix an internal error when using
`EXPLAIN (TYPES)` on a `DELETE FROM ... USING ... RETURNING` statement.
craig bot pushed a commit that referenced this issue Jul 5, 2023
105736: opt: wrap virtual computed column projections in a cast r=mgartner a=mgartner

#### sql/logictest: remove assignment cast TODO

This commit removes a TODO that was partially addressed by #82022.

Informs #73743

Release note: None

#### sql/types: fix T.Identical

This commit fixes a bug in `types.T.Identical` which caused it to return
false for collated string types with a different string-representation
of locales that represents the same locale logically. For example,
collated string types with locales `en_US` and `en_us` would not be
identical, even though these are both valid representations of the same
locale.

There is no release note because this has not caused any known bugs.

Release note: None

#### opt: wrap virtual computed column projections in a cast

optbuilder wraps an assignment cast around a virtual computed column
expression when writing to the table if the expression does not have the
same type as the virtual column. This matches the behavior of all writes
to columns of expressions that don't match the target column type.

However, the same cast was not applied to the projection of the virtual
column expression when reading from the table. This cast is necessary in
order to produce the correct value of the column - the projection must
produce the same value that would have been written to the table if the
column was a stored computed column. This commit corrects optbuilder so
that the cast is correctly added to the projection.

Note that this commit adds a standard cast, not an assignment cast, as a
temporary workaround until #81698 is addressed. This is because an
assignment cast can fail in cases when a regular cast will not. Because
we don't validate that all existing rows can successfully produce a new
virtual column expression during a backfill, adding an assignment cast
to the projection of the virtual column could cause future reads to
error. Once #81698 is addressed, we can change these casts to assignment
casts so that they directly match the values that would be written to
the same column if it were stored.

Fixes #91817
Informs #81698

Release note (bug fix): A bug has been fixed that could produce incorrect
values for virtual computed columns in rare cases. The bug only
presented when the virtual column expression's type did not match the
type of the virtual column.


105932: opt/exec: add passthrough cols to DELETE USING result cols in explain r=yuzefovich,DrewKimball a=michae2

Now that we support `DELETE USING`, delete nodes can have passthrough columns. Add these to the result columns used by `EXPLAIN (TYPES)`.

Fixes: #105803

Release note (sql change): Fix an internal error when using `EXPLAIN (TYPES)` on a `DELETE FROM ... USING ... RETURNING` statement.

Co-authored-by: Marcus Gartner <marcus@cockroachlabs.com>
Co-authored-by: Michael Erickson <michae2@cockroachlabs.com>
@craig craig bot closed this as completed in 5960881 Jul 5, 2023
SQL Queries automation moved this from Active to Done Jul 5, 2023
blathers-crl bot pushed a commit that referenced this issue Jul 5, 2023
Now that we support `DELETE USING`, delete nodes can have passthrough
columns. Add these to the result columns used by `EXPLAIN (TYPES)`.

Fixes: #105803

Release note (bug fix): Fix an internal error when using
`EXPLAIN (TYPES)` on a `DELETE FROM ... USING ... RETURNING` statement
which was introduced in v23.1.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-explain Issues related to EXPLAIN and EXPLAIN ANALYZE improvements branch-release-23.1 Used to mark GA and release blockers and technical advisories for 23.1 C-test-failure Broken test (automatically or manually discovered). O-robot Originated from a bot. T-sql-queries SQL Queries Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants