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

opt: panic in optbuilder #32270

Closed
jordanlewis opened this issue Nov 13, 2018 · 4 comments · Fixed by #32443
Closed

opt: panic in optbuilder #32270

jordanlewis opened this issue Nov 13, 2018 · 4 comments · Fixed by #32443
Assignees
Labels
A-sql-optimizer SQL logical planning and optimizations. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@jordanlewis
Copy link
Member

panic: interface conversion: *memo.ProjectExpr is not opt.ScalarExpr: missing method DataType [recovered]
        panic: interface conversion: *memo.ProjectExpr is not opt.ScalarExpr: missing method DataType [recovered]
        panic: panic while executing 1 statements: SELECT _._ AS _, _._ AS _, _._ AS _, _._ AS _, CASE WHEN array_remove(CAST(CASE WHEN (SELECT _ FROM _._ LIMIT _ OFFSET _) < (SELECT _ FROM _._ LIMIT _ OFFSET _) THEN CASE WHEN (SELECT json_agg(_) FROM _._) @> (SELECT json_agg(_) FROM _._) THEN CAST(_ AS UUID[]) ELSE CAST(_ AS UUID[]) END ELSE CASE WHEN (SELECT json_agg(_) FROM _._) @> (SELECT json_agg(_) FROM _._) THEN CAST(_ AS UUID[]) ELSE CAST(_ AS UUID[]) END END AS UUID[]), CAST(CAST(_ AS UUID) AS UUID)) IS DISTINCT FROM CAST(COALESCE(CASE  [...]; caused by interface conversion: *memo.ProjectExpr is not opt.ScalarExpr: missing method DataType

goroutine 560 [running]:
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).closeWrapper(0xc008159300, 0x6e46a00, 0xc006436c80, 0x63ce9c0, 0xc008778150)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:647 +0x36f
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1(0xc008159300, 0x6e46a00, 0xc006436c80)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:388 +0x61
panic(0x63ce9c0, 0xc008778150)
        /usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).Build.func1(0xc009b0eae8)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:137 +0x9a
panic(0x63ce9c0, 0xc008778150)
        /usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll.func1(0x6e52ec0, 0xc0071228f8, 0xc0071228f8, 0x6e52ec0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:791 +0x4e
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).Reconstruct(0xc00815a278, 0x6e533c0, 0xc0066cf230, 0xc000457940, 0xc0066cf230, 0x4014a26)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:12659 +0xef7f
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll(0xc008778120, 0x6e5e0e0, 0xc0066cf230, 0x6e5e0e0, 0xc0066cf230)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:789 +0x18d
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll.func1(0x6e533c0, 0xc0066cf230, 0xc0066cf230, 0x6e533c0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:791 +0x70
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).Reconstruct(0xc00815a278, 0x6e52940, 0xc006c82be0, 0xc000457930, 0xc006c82be0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:12755 +0x68ba
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll(0xc008778120, 0x6e5d6c0, 0xc006c82be0, 0x6e5d6c0, 0xc006c82be0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:789 +0x18d
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll.func1(0x6e52940, 0xc006c82be0, 0xc006c82be0, 0x6e52940)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:791 +0x70
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).Reconstruct(0xc00815a278, 0x6e53740, 0xc0066cf380, 0xc000457920, 0xc0066cf380, 0x6482cc0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:13113 +0x8729
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll(0xc008778120, 0x6e5e4a0, 0xc0066cf380, 0x6e5e4a0, 0xc0066cf380)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:789 +0x18d
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll.func1(0x6e53740, 0xc0066cf380, 0xc0066cf380, 0x6e53740)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:791 +0x70
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).reconstructScalarListExpr(0xc00815a278, 0xc006c82bc0, 0x1, 0x2, 0xc000457900, 0x0, 0x6e5fca0, 0xc008547b30, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:13388 +0xc6
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).Reconstruct(0xc00815a278, 0x6e51b40, 0xc007b0b900, 0xc000457900, 0xc007b0b900, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:13105 +0x5275
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll(0xc008778120, 0x6e5c7c0, 0xc007b0b900, 0x6e5c7c0, 0xc007b0b900)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:789 +0x18d
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll.func1(0x6e51b40, 0xc007b0b900, 0xc007b0b900, 0x6e51b40)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:791 +0x70
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).reconstructScalarListExpr(0xc00815a278, 0xc006c82ba0, 0x2, 0x2, 0xc0004578f0, 0x0, 0x0, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:13388 +0xc6
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).Reconstruct(0xc00815a278, 0x6e522c0, 0xc007b0b950, 0xc0004578f0, 0xc007b0b950, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:13136 +0x98c2
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll(0xc008778120, 0x6e5d0c0, 0xc007b0b950, 0x6e5d0c0, 0xc007b0b950)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:789 +0x18d
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll.func1(0x6e522c0, 0xc007b0b950, 0xc007b0b950, 0x6e522c0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:791 +0x70
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).Reconstruct(0xc00815a278, 0x6e52600, 0xc006c82d00, 0xc0004578e0, 0xc006c82d00, 0xc00836da40)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:12899 +0x2fbe
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll(0xc008778120, 0x6e5d360, 0xc006c82d00, 0x6e5d360, 0xc006c82d00)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:789 +0x18d
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll.func1(0x6e52600, 0xc006c82d00, 0xc006c82d00, 0x6e52600)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:791 +0x70
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).Reconstruct(0xc00815a278, 0x6e53740, 0xc0066cf710, 0xc0004578d0, 0xc0066cf710, 0x6482cc0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:13113 +0x8729
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll(0xc008778120, 0x6e5e4a0, 0xc0066cf710, 0x6e5e4a0, 0xc0066cf710)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:789 +0x18d
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll.func1(0x6e53740, 0xc0066cf710, 0xc0066cf710, 0x6e53740)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:791 +0x70
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).reconstructScalarListExpr(0xc00815a278, 0xc006c82b80, 0x1, 0x2, 0xc0004578b0, 0x0, 0x40731f7, 0xc006226066, 0x671bbb0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:13388 +0xc6
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).Reconstruct(0xc00815a278, 0x6e51b40, 0xc007b0b9f0, 0xc0004578b0, 0xc007b0b9f0, 0x6e51b40)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:13105 +0x5275
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*subqueryHoister).hoistAll(0xc008778120, 0x6e5c7c0, 0xc007b0b9f0, 0xc00772b900, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:789 +0x18d
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*CustomFuncs).HoistProjectSubquery(0xc00815a288, 0x6e77340, 0xc007adacb8, 0xc007c40f00, 0x2, 0x8, 0x10, 0x0, 0xc006227b6b, 0x2)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/decorrelate.go:165 +0x323
github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).ConstructProject(0xc00815a278, 0x6e77340, 0xc007adacb8, 0xc007c40f00, 0x2, 0x8, 0x10, 0x0, 0xc009b0e668, 0x44c8889)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/norm/factory.og.go:1035 +0x860
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).constructProject(0xc008b85d10, 0x6e77340, 0xc007adacb8, 0xc007308d80, 0x8, 0x8, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/project.go:61 +0x37c
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).constructProjectForScope(0xc008b85d10, 0xc008b01de0, 0xc0055ae2d0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/project.go:33 +0x1d1
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelectClause(0xc008b85d10, 0xc007b08d80, 0x0, 0x0, 0x0, 0xc008b01c00, 0xc009b0e908)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:524 +0x2c1
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelect(0xc008b85d10, 0xc007b0c040, 0xc008b01c00, 0xe8)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:449 +0x1d1
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildStmt(0xc008b85d10, 0x6e4a100, 0xc007b0c040, 0xc008b01c00, 0x4)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:187 +0xf1
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).Build(0xc008b85d10, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:144 +0xf6
github.com/cockroachdb/cockroach/pkg/sql.(*planner).makeOptimizerPlan(0xc008159718, 0x6e46ac0, 0xc009819d10, 0x6e4a100, 0xc007b0c040, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:425 +0x2ca
github.com/cockroachdb/cockroach/pkg/sql.(*planner).optionallyUseOptimizer(0xc008159718, 0x6e46ac0, 0xc009819d10, 0xc007c5e2e0, 0xd, 0xc005377017, 0x9, 0x0, 0x1, 0x0, ...)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/planner.go:552 +0xc4
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).dispatchToExecutionEngine(0xc008159300, 0x6e46ac0, 0xc009819d10, 0x6e4a100, 0xc007b0c040, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:765 +0x189
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmtInOpenState(0xc008159300, 0x6e46ac0, 0xc009819d10, 0x6e4a100, 0xc007b0c040, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:402 +0xaa7
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmt(0xc008159300, 0x6e46ac0, 0xc009819d10, 0x6e4a100, 0xc007b0c040, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:96 +0x333
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run(0xc008159300, 0x6e46a00, 0xc006436c80, 0xc0007c9998, 0x5400, 0x15000, 0xc0007c9a30, 0xc008604300, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1113 +0x2131
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn(0xc0008dcb40, 0x6e46a00, 0xc006436c80, 0xc008159300, 0x5400, 0x15000, 0xc0007c9a30, 0xc008604300, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:390 +0xce
github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).serveImpl.func4(0xc0008dcb40, 0x6e46a00, 0xc006436c80, 0xc008159300, 0x5400, 0x15000, 0xc0007c9a30, 0xc008604300, 0xc008604310, 0xc007c5e224)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:309 +0x81
created by github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).serveImpl
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:308 +0x1018```

Found with sqlsmith
@jordanlewis jordanlewis added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-optimizer SQL logical planning and optimizations. labels Nov 13, 2018
@jordanlewis
Copy link
Member Author

cc @BramGruneir

@andy-kimball
Copy link
Contributor

@jordanlewis, can I get the schema and complete query that failed? This is only a fragment of the query, with no schema, so it can't easily be repro'd.

@jordanlewis
Copy link
Member Author

Sorry about that.

[email protected]:60533/defaultdb> create table a (a int primary key);
CREATE TABLE

Time: 7.879ms

[email protected]:60533/defaultdb> SELECT subq_1.c1 AS c0, subq_1.c2 AS c1, subq_1.c7 AS c2, subq_1.c8 AS c3, subq_1.c1 AS c4, subq_1.c7 AS c5, subq_1.c0 AS c6, 90 AS c7, CASE WHEN subq_1.c7 IS NOT NULL THEN subq_1.c3 ELSE subq_1.c3 END AS c8, subq_1.c1 AS c9, subq_1.c2 AS c10, subq_1.c2 AS c11, subq_1.c7 AS c12, subq_1.c1 AS c13, subq_1.c5 AS c14, (SELECT locality FROM crdb_internal.gossip_nodes LIMIT 1 OFFSET 1) AS c15, subq_1.c2 AS c16, subq_1.c2 AS c17, CASE WHEN (55 IS NOT NULL) AND (false) THEN CASE WHEN false THEN subq_1.c2 ELSE subq_1.c2 END ELSE CASE WHEN false THEN subq_1.c2 ELSE subq_1.c2 END END AS c18, subq_1.c7 AS c19, (SELECT rolreplication FROM pg_catalog.pg_roles LIMIT 1 OFFSET 6) AS c20 FROM (SELECT subq_0.c2 AS c0, (SELECT datetime_precision FROM information_schema.parameters LIMIT 1 OFFSET 3) AS c1, subq_0.c21 AS c2, subq_0.c10 AS c3, subq_0.c2 AS c4, subq_0.c1 AS c5, subq_0.c4 AS c6, subq_0.c12 AS c7, subq_0.c7 AS c8 FROM (SELECT ref_0.table_schema AS c0, ref_0.is_deferrable AS c1, ref_0.constraint_name AS c2, ref_0.table_name AS c3, ref_0.constraint_catalog AS c4, ref_0.table_name AS c5, ref_0.table_catalog AS c6, (SELECT pg_catalog.sqrdiff(procost) FROM pg_catalog.pg_proc) AS c7, ref_0.initially_deferred AS c8, (SELECT key FROM crdb_internal.node_statement_statistics LIMIT 1 OFFSET 2) AS c9, ref_0.constraint_name AS c10, ref_0.table_name AS c11, ref_0.is_deferrable AS c12, ref_0.initially_deferred AS c13, (SELECT name FROM crdb_internal.node_metrics LIMIT 1 OFFSET 6) AS c14, ref_0.table_schema AS c15, (SELECT feature_name FROM crdb_internal.feature_usage LIMIT 1 OFFSET 58) AS c16, ref_0.table_name AS c17, ref_0.initially_deferred AS c18, ref_0.table_catalog AS c19, ref_0.constraint_catalog AS c20, ref_0.table_catalog AS c21, ref_0.table_schema AS c22 FROM information_schema.table_constraints AS ref_0 WHERE CAST(NULL AS TIME[]) = CAST(NULL AS TIME[]) LIMIT 176) AS subq_0 WHERE subq_0.c13 IS NOT DISTINCT FROM pg_catalog.current_database() LIMIT 110) AS subq_1 WHERE CAST(NULLIF(CASE WHEN EXISTS (SELECT subq_1.c7 AS c0, subq_1.c5 AS c1, (SELECT inhseqno FROM pg_catalog.pg_inherits LIMIT 1 OFFSET 3) AS c2, subq_1.c4 AS c3, (SELECT pg_catalog.min(value) FROM crdb_internal.node_metrics) AS c4, ref_1.a AS c5, (SELECT rulename FROM pg_catalog.pg_rewrite LIMIT 1 OFFSET 90) AS c6, (SELECT rolsuper FROM pg_catalog.pg_roles LIMIT 1 OFFSET 2) AS c7, subq_1.c1 AS c8 FROM public.a AS ref_1 WHERE ref_1.a = subq_1.c8 LIMIT 113) THEN (SELECT valuntil FROM pg_catalog.pg_user LIMIT 1 OFFSET 5) ELSE (SELECT valuntil FROM pg_catalog.pg_user LIMIT 1 OFFSET 5) END, CASE WHEN subq_1.c5 IS DISTINCT FROM subq_1.c3 THEN pg_catalog.transaction_timestamp() ELSE pg_catalog.transaction_timestamp() END) AS TIMESTAMP) >= CASE WHEN (true) AND (subq_1.c2 IS NULL) THEN (SELECT start FROM crdb_internal.node_queries LIMIT 1 OFFSET 4) ELSE (SELECT start FROM crdb_internal.node_queries LIMIT 1 OFFSET 4) END;

E181113 17:20:19.279836 584 sql/conn_executor.go:633  [n1,client=127.0.0.1:60535,user=root] a SQL panic has occurred while executing "SELECT subq_1.c1 AS c0, subq_1.c2 AS c1, subq_1.c7 AS c2, subq_1.c8 AS c3, subq_1.c1 AS c4, subq_1.c7 AS c5, subq_1.c0 AS c6, 90 AS c7, CASE WHEN subq_1.c7 IS NOT NULL THEN subq_1.c3 ELSE subq_1.c3 END AS c8, subq_1.c1 AS c9, subq_1.c2 AS c10, subq_1.c2 AS c11, subq_1.c7 AS c12, subq_1.c1 AS c13, subq_1.c5 AS c14, (SELECT locality FROM crdb_internal.gossip_nodes LIMIT 1 OFFSET 1) AS c15, subq_1.c2 AS c16, subq_1.c2 AS c17, CASE WHEN (55 IS NOT NULL) AND (false) THEN CASE WHEN false THEN subq_1.c [...]": interface conversion: *memo.ProjectExpr is not opt.ScalarExpr: missing method DataType
E181113 17:20:19.280819 584 util/log/crash_reporting.go:203  [n1,client=127.0.0.1:60535,user=root] a panic has occurred!
E181113 17:20:19.285289 584 util/log/crash_reporting.go:477  [n1,client=127.0.0.1:60535,user=root] Reported as error efcb90f573c040359744f9df313ebd3c
panic: interface conversion: *memo.ProjectExpr is not opt.ScalarExpr: missing method DataType [recovered]
        panic: interface conversion: *memo.ProjectExpr is not opt.ScalarExpr: missing method DataType [recovered]
        panic: panic while executing 1 statements: SELECT _._ AS _, _._ AS _, _._ AS _, _._ AS _, _._ AS _, _._ AS _, _._ AS _, _ AS _, CASE WHEN _._ IS NOT _ THEN _._ ELSE _._ END AS _, _._ AS _, _._ AS _, _._ AS _, _._ AS _, _._ AS _, _._ AS _, (SELECT _ FROM _._ LIMIT _ OFFSET _) AS _, _._ AS _, _._ AS _, CASE WHEN (_ IS NOT _) AND (_) THEN CASE WHEN _ THEN _._ ELSE _._ END ELSE CASE WHEN _ THEN _._ ELSE _._ END END AS _, _._ AS _, (SELECT _ FROM _._ LIMIT _ OFFSET _) AS _ FROM (SELECT _._ AS _, (SELECT _ FROM _._ LIMIT _ OFFSET _) AS _, _._  [...]; caused by interface conversion: *memo.ProjectExpr is not opt.ScalarExpr: missing method DataType

BramGruneir added a commit to BramGruneir/cockroach that referenced this issue Nov 15, 2018
This add a new nightly roachtest that run SQLsmith against the latest master
looking for panics.

If this crashes, the cause of the crash can be found in the logs for the first
(and only) node.

This test is being checked in as a skip due to cockroachdb#32270.

Release note: None
@BramGruneir
Copy link
Member

Just a head's up, the this is currently blocking the SQLsmith roachtest. Once it's fixed, please don't forget to re-enable that test.

andy-kimball added a commit to andy-kimball/cockroach that referenced this issue Nov 28, 2018
Fixes cockroachdb#32270.

The panic occurs when hoisting an expression that has both a correlated
and an uncorrelated subquery. The current code panics when calling
Reconstruct on the relational input to the uncorrelated subquery. The
fix is to test for relational inputs and skip over them. They are not
correlated, and so no hoisting needs to be done within their subtree.

Release note (sql change): Fix panic when expression contains both a
correlated and uncorrelated subquery.
craig bot pushed a commit that referenced this issue Nov 29, 2018
32443: opt: Fix panic when hoisting expr with correlated subquery r=andy-kimball a=andy-kimball

Fixes #32270.

The panic occurs when hoisting an expression that has both a correlated
and an uncorrelated subquery. The current code panics when calling
Reconstruct on the relational input to the uncorrelated subquery. The
fix is to test for relational inputs and skip over them. They are not
correlated, and so no hoisting needs to be done within their subtree.

Release note (sql change): Fix panic when expression contains both a
correlated and uncorrelated subquery.

Co-authored-by: Andrew Kimball <[email protected]>
@craig craig bot closed this as completed in #32443 Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-optimizer SQL logical planning and optimizations. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants