cockroachdb / cockroachdb/cockroach

sql: empty tuple comparison causes "empty end boundary must be inclusive"

Offen
#93,408 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
C-bug O-community S-3 T-sql-queries X-blathers-triaged
Vorherrschende Sprache
Go
Sterne
32.5k
Forks
4.1k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

**Describe the problem**

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

```sql
SET testing_optimizer_disable_rule_probability = 1.0;
create table v0 ();
SELECT * FROM v0 WHERE () < ();
```

**To Reproduce**

Here is the detail steps to reproduce the bug.

1. In system Ubuntu 20.04, download the CockroachDB source code from the github source.
2. Use the latest version of the CockroachDB code (tested version: ec83b9eba5f2b)
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 `SELECT` statement should be executed correctly and return empty result.

**Additional data / screenshots**

Here is the outputted stack trace:

```
ERROR: internal error: an empty end boundary must be inclusive
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/opt/constraint/span.go:140: Init()
github.com/cockroachdb/cockroach/pkg/sql/opt/memo/constraint_builder.go:421: buildConstraintForTupleInequality()
github.com/cockroachdb/cockroach/pkg/sql/opt/memo/constraint_builder.go:580: buildConstraints()
github.com/cockroachdb/cockroach/pkg/sql/opt/memo/logical_props_builder.go:1534: buildFiltersItemProps()
github.com/cockroachdb/cockroach/pkg/sql/opt/memo/expr.og.go:9270: PopulateProps()
github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:12470: ConstructFiltersItem()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1190: buildWhere()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1061: buildSelectClause()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1006: buildSelectStmtWithoutParens()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:975: func1()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/with.go:117: processWiths()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:974: buildSelect()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:305: buildStmt()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:252: buildStmtAtRoot()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:226: 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:1518: makeExecPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1125: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:737: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:130: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2513: execWithProfiling()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:129: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1955: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1960: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1878: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:834: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:728: func1()
runtime/asm_amd64.s:1594: 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.00000000-1124-gec83b9eba5-dirty
Build Time: 2022/12/12 01:12:12
Distribution: CCL
Platform: linux amd64 (x86_64-linux-gnu)
Go Version: go1.19
C Compiler: gcc 9.4.0
Build Commit ID: ec83b9eba5f2b09f9fc8610c8a976e49854d212d
Build Type: development
(use './cockroach version --build-tag' to display only the build tag)
```

**Additional context**

The crashing problem may not happen in the real-world application, since it requires the specific setup: `SET testing_optimizer_disable_rule_probability = 1.0;`, which is a developer option used to control the query optimization. However, having an `Internal Error` is still unexpected from the resulted behavior. Therefore, this problem is reported here.

The Internal Error problem is reproducible on version `v22.2.0 Production Releases`.

Jira issue: CRDB-22318

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.