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

labelled tuple with IS KNOWN fails with assertion error #106847

Closed
Xiang-Gu opened this issue Jul 14, 2023 · 1 comment
Closed

labelled tuple with IS KNOWN fails with assertion error #106847

Xiang-Gu opened this issue Jul 14, 2023 · 1 comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team

Comments

@Xiang-Gu
Copy link
Contributor

Xiang-Gu commented Jul 14, 2023

Given a table

create table t (i int primary key, j int);
insert into t values (0,0);

the following query fails with an expected error

select (row() as p, q) from t;

ERROR: mismatch in tuple definition: 0 expressions, 2 labels
SQLSTATE: 42601

But the following query fails with an internal error:

select (row() as p, q) in unknown from t;

ERROR: internal error: tuple contents and labels must be of same length: [], [p q]
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/types/pkg/sql/types/types.go:1174: MakeLabeledTuple()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:2806: typeCheckSameTypedTupleExprs()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:2529: typeCheckSameTypedExprs()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:2406: typeCheckComparisonOp()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:860: TypeCheck()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:273: TypeCheck()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/scope.go:468: resolveType()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/project.go:179: analyzeSelectList()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/project.go:95: analyzeProjectionList()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1137: buildSelectClause()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1074: buildSelectStmtWithoutParens()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1043: func1()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/with.go:116: processWiths()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1042: buildSelect()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:337: buildStmt()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:284: buildStmtAtRootWithScope()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:265: buildStmtAtRoot()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:244: Build()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:576: buildExecMemo()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:240: makeOptimizerPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1966: makeExecPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1484: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:964: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:142: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2985: execWithProfiling()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:141: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2219: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2224: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2141: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:953: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:260: func1()
GOROOT/src/runtime/asm_arm64.s:1172: goexit()

Instead we should see the same error as above.

Jira issue: CRDB-29741

@Xiang-Gu Xiang-Gu added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jul 14, 2023
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Jul 14, 2023
@Xiang-Gu Xiang-Gu changed the title labelled tuple with IS KNOWN labelled tuple with IS KNOWN fails with assertion error Jul 14, 2023
@mgartner
Copy link
Collaborator

This was fixed by #106553.

@mgartner mgartner moved this to Done in SQL Queries Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team
Projects
Archived in project
Development

No branches or pull requests

2 participants