Skip to content

sql: query causes Internal Error #91532

@SteveLeungYL

Description

@SteveLeungYL

Describe the problem

The latest version of CockroachDB (fd0934b) causes an Internal Error when executing the following query:

# poc
CREATE TABLE v0 (c1 TIME); 
SELECT * FROM v0 WHERE () < '06:57:30'; 

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: fd0934b)
  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.
# poc
CREATE TABLE v0 (c1 TIME); 
SELECT * FROM v0 WHERE () < '06:57:30'; 

Expected behavior

The CockroachDB server should return the following error:

ERROR: unsupported comparison operator: <tuple> < <string>
SQLSTATE: 22023

Additional data / screenshots

Internal Error information:

demo@127.0.0.1:26257/movr> CREATE TABLE v0 (c1 TIME);
CREATE TABLE


Time: 5ms total (execution 5ms / network 0ms)

demo@127.0.0.1:26257/movr> SELECT * FROM v0 WHERE () < '06:57:30';
ERROR: internal error: comparison overload not found (lt, tuple, string)
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/opt/memo/logical_props_builder.go:1676: BuildSharedProps()
github.com/cockroachdb/cockroach/pkg/sql/opt/memo/logical_props_builder.go:1523: buildFiltersItemProps()
github.com/cockroachdb/cockroach/pkg/sql/opt/memo/expr.og.go:9266: PopulateProps()
github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:12421: 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:116: 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:563: buildExecMemo()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:231: makeOptimizerPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1469: makeExecPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1094: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:723: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:127: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2417: execWithProfiling()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:126: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1927: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1932: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1852: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:830: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:728: func1()
runtime/asm_arm64.s:1165: goexit()

HINT: You have encountered an unexpected error.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.
# poc
CREATE TABLE v0 (c1 TIME); 
SELECT * FROM v0 WHERE () < '06:57:30'; 

Environment:

  • CockroachDB version: v23.1.0-alpha.00000000-103-gfd0934bf92-dirty
  • 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-103-gfd0934bf92-dirty
Build Time:       2022/11/08 16:36:59
Distribution:     CCL
Platform:         linux arm64 (aarch64-linux-gnu)
Go Version:       go1.19
C Compiler:       gcc 9.4.0
Build Commit ID:  fd0934bf92815b4ef3a98f093d89e41180ff13d5
Build Type:       development

Additional context

The problem is reproducible on all versions from v22.2.* and v22.1.*. But it CANNOT trace back to version v21.2.* and the versions before (the history versions are behaving correctly). Seems the problem is introduced in a commit in version v21.1.

Jira issue: CRDB-21307

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityT-sql-queriesSQL Queries TeamX-blathers-triagedblathers was able to find an owner

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions