Skip to content

sql: unexpected error when using crdb_internal_mvcc_timestamp in a view #62798

@solongordon

Description

@solongordon

If you reference crdb_internal_mvcc_timestamp when creating a view or materialized view, it results in an unexpected error.

demo@127.0.0.1:26257/defaultdb> create table t (x int);
CREATE TABLE

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

demo@127.0.0.1:26257/defaultdb> create view v as select crdb_internal_mvcc_timestamp from t;
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/opt/exec/execbuilder/builder.go:149: func1()
runtime/panic.go:969: gopanic()
runtime/panic.go:88: goPanicIndex()
github.com/cockroachdb/cockroach/pkg/sql/opt_exec_factory.go:1695: func1()
github.com/cockroachdb/cockroach/pkg/util/fast_int_set.go:165: ForEach()
github.com/cockroachdb/cockroach/pkg/sql/opt_exec_factory.go:1694: ConstructCreateView()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain/explain_factory.og.go:1265: ConstructCreateView()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/execbuilder/statement.go:58: buildCreateView()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/execbuilder/relational.go:263: buildRelational()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/execbuilder/builder.go:173: build()
github.com/cockroachdb/cockroach/pkg/sql/opt/exec/execbuilder/builder.go:135: Build()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:566: runExecBuilder()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:262: makeOptimizerPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:937: makeExecPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:818: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:656: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:120: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1514: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1516: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1437: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:482: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:626: func1()
runtime/asm_amd64.s:1374: 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.

We appreciate your feedback.

Metadata

Metadata

Assignees

Labels

A-sql-optimizerSQL logical planning and optimizations.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions