cockroachdb / cockroachdb/cockroach

sql: Internal Error when using EXPLAIN with SET TRACING

Open
#95,872 5 comments 0 reactions 0 assignees View on GitHub
C-bug O-community T-sql-queries X-blathers-triaged
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

The latest version of the CockroachDB (5cf0823e2ab46) shows `Internal Error` when executing the following query:

```
EXPLAIN SET TRACING = 0;
```

**To Reproduce**

Here is the detail steps to reproduce the bug.

1. In operating system Ubuntu 20.04 LTS, download the CockroachDB source code from the github source.
2. Use the latest version of the CockroachDB code (tested version: 5cf0823e2ab46)
3. Directly `make install` in the root repository folder.
4. Run `./cockroach demo`, and then paste the PoC query to the cockroach cli environment.
5. Observe the `Internal Error` and log the stack information.

**Expected behavior**
The query should show semantic error indicating that `EXPLAIN SET TRACING` is not supported.

**Additional data / screenshots**

Here is the outputted stack trace:

```
demo@127.0.0.1:26257/movr> EXPLAIN SET TRACING = 0;
ERROR: internal error: unexpected statement: *tree.SetTracing
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:415: buildStmt()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:253: buildStmtAtRoot()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/explain.go:31: buildExplain()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:337: buildStmt()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:253: buildStmtAtRoot()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:227: Build()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:570: buildExecMemo()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:237: makeOptimizerPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1532: makeExecPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1139: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:744: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:130: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2527: execWithProfiling()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:129: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1959: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1964: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1882: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:836: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:731: func1()
runtime/asm_arm64.s:1165: goexit()

HINT: You have encountered an unexpected error.
```

**Environment:**
- CockroachDB version: v23.1.0-alpha
- Server OS: Ubuntu 20.04 LTS
- Client app: CockroachDB demo command. (`./cockroach demo`)
- Detailed CockroachDB version output:

```
cockroach version details:
Build Tag: v23.1.0-alpha.1-1171-g5cf0823e2a
Build Time: 2023/01/25 21:45:51
Distribution: CCL
Platform: linux arm64 (aarch64-linux-gnu)
Go Version: go1.19
C Compiler: gcc 9.4.0
Build Commit ID: 5cf0823e2ab4646ed98ebf2709ea79f3541935e5
Build Type: development
```

**Additional context**

The bug can be reproduced by CockroachDB release version: `CockroachDB v23.1 Testing Releases` , `v22.2.2` and `v22.1`. We haven't tested CockroachDB release versions before `v22.1`.

Jira issue: CRDB-23785

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.