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

fix cross join panic #673

Merged
merged 1 commit into from
Dec 8, 2021
Merged

fix cross join panic #673

merged 1 commit into from
Dec 8, 2021

Conversation

max-hoffman
Copy link
Contributor

@max-hoffman max-hoffman commented Dec 8, 2021

The cross join expression check would panic for any Comparator outside of the whitelist, instead of returning false to indicate an unmatchable expression.

> SELECT a6, x5, b2+a6, e4  FROM t6, t4, t5, t2 WHERE b4 in (434,267,535,407,331,2,921,469)   AND c5=819   AND d6 in (192,129,970,151)   AND (c2=728 OR 806=c2 OR 141=c2)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1e2c6d3]

goroutine 1 [running]:
github.com/dolthub/go-mysql-server/sql/expression.(*GetField).Name(...)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/expression/get_field.go:82
github.com/dolthub/go-mysql-server/sql/analyzer.comparisonSatisfiesJoinCondition({0x2d03fbe8, 0xc0013df5e0}, 0xc0013df580)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/replace_cross_joins.go:50 +0x2d3
github.com/dolthub/go-mysql-server/sql/analyzer.expressionCoversJoin.func1({0x29e5070, 0xc0013df5e0})
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/replace_cross_joins.go:61 +0x5b
github.com/dolthub/go-mysql-server/sql/expression.InspectUp.func1({0x29e5070, 0xc0013df5e0})
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/expression/transform.go:61 +0x39
github.com/dolthub/go-mysql-server/sql/expression.InspectUp.func2({0x29e5070, 0xc0013df5e0})
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/expression/transform.go:68 +0x27
github.com/dolthub/go-mysql-server/sql/expression.TransformUp({0x29e5070, 0xc0013defc0}, 0xc00016dfc8)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/expression/transform.go:53 +0x13d
github.com/dolthub/go-mysql-server/sql/expression.InspectUp({0x29e5070, 0xc0013defc0}, 0xc00016e020)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/expression/transform.go:67 +0xad
github.com/dolthub/go-mysql-server/sql/analyzer.expressionCoversJoin({0x29e5070, 0xc0013defc0}, 0x3cd6108)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/replace_cross_joins.go:58 +0x3f
github.com/dolthub/go-mysql-server/sql/analyzer.replaceCrossJoins.func1.1({0x29d3b00, 0xc0013df580})
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/replace_cross_joins.go:93 +0x318
github.com/dolthub/go-mysql-server/sql/plan.TransformUp.func1({{0x29d3b00, 0xc0013df580}, {0x29d3b00, 0xc0013df440}, 0x0, {0x37ff6f8, 0x0, 0x0}})
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:98 +0x4f
github.com/dolthub/go-mysql-server/sql/plan.transformUpCtx({{0x29d3b00, 0xc0013df420}, {0x29d3b00, 0xc0013df440}, 0x0, {0x37ff6f8, 0x0, 0x0}}, 0x0, 0xc00016e778)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:91 +0x6ba
github.com/dolthub/go-mysql-server/sql/plan.transformUpCtx({{0x29d3b00, 0xc0013df440}, {0x29d3b00, 0xc0013df460}, 0x0, {0x37ff6f8, 0x0, 0x0}}, 0x0, 0xc00016e778)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:72 +0x41f
github.com/dolthub/go-mysql-server/sql/plan.transformUpCtx({{0x29d3b00, 0xc0013df460}, {0x29d3fc8, 0xc0013df480}, 0x0, {0x37ff6f8, 0x0, 0x0}}, 0x0, 0xc00016e778)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:72 +0x41f
github.com/dolthub/go-mysql-server/sql/plan.transformUpCtx({{0x29d3fc8, 0xc0013df480}, {0x0, 0x0}, 0xffffffffffffffff, {0x37ff6f8, 0x0, 0x0}}, 0x0, 0xc00016e778)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:72 +0x41f
github.com/dolthub/go-mysql-server/sql/plan.TransformUpCtx({0x29d3fc8, 0xc0013df480}, 0x100c00016e7e8, 0x100e674)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:53 +0xbd
github.com/dolthub/go-mysql-server/sql/plan.TransformUp({0x29d3fc8, 0xc0013df480}, 0x203000)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:97 +0x45
github.com/dolthub/go-mysql-server/sql/analyzer.replaceCrossJoins.func1({0x29d3fc8, 0xc0013df480})
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/replace_cross_joins.go:85 +0x159
github.com/dolthub/go-mysql-server/sql/plan.TransformUp.func1({{0x29d3fc8, 0xc0013df480}, {0x29d45f8, 0xc0013cd200}, 0x0, {0x37ff6f8, 0x0, 0x0}})
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:98 +0x4f
github.com/dolthub/go-mysql-server/sql/plan.transformUpCtx({{0x29d3fc8, 0xc0013df2e0}, {0x29d45f8, 0xc0013cd200}, 0x0, {0x37ff6f8, 0x0, 0x0}}, 0x0, 0xc00016eca0)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:91 +0x6ba
github.com/dolthub/go-mysql-server/sql/plan.transformUpCtx({{0x29d45f8, 0xc0013cd200}, {0x0, 0x0}, 0xffffffffffffffff, {0x37ff6f8, 0x0, 0x0}}, 0x0, 0xc00016eca0)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:72 +0x41f
github.com/dolthub/go-mysql-server/sql/plan.TransformUpCtx({0x29d45f8, 0xc0013cd200}, 0x1d9c087, 0xc0013b6ec0)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:53 +0xbd
github.com/dolthub/go-mysql-server/sql/plan.TransformUp({0x29d45f8, 0xc0013cd200}, 0xc0007dbb01)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/plan/transform.go:97 +0x45
github.com/dolthub/go-mysql-server/sql/analyzer.replaceCrossJoins(0x26a3cc2, 0x26a0458, {0x29d45f8, 0xc0013cd200}, 0xc0013cd200)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/replace_cross_joins.go:78 +0x45
github.com/dolthub/go-mysql-server/sql/analyzer.(*Batch).evalOnce(0x29d45f8, 0xc00096d740, 0xc0007dbb60, {0x29d45f8, 0xc0013cc5d0}, 0x104e534)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/batch.go:93 +0x1e7
github.com/dolthub/go-mysql-server/sql/analyzer.(*Batch).Eval(0xc0006b9350, 0x37ff6f8, 0xc0007dbb60, {0x29d45f8, 0xc0013cc5d0}, 0x1)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/batch.go:54 +0x145
github.com/dolthub/go-mysql-server/sql/analyzer.(*Analyzer).analyzeWithSelector(0xc0007dbb60, 0xc00054eb40, {0x29d45f8, 0xc00096d740}, 0x0, 0x271def0)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/analyzer.go:376 +0x314
github.com/dolthub/go-mysql-server/sql/analyzer.(*Analyzer).Analyze(...)
	/Users/vinairachakonda/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.11.1-0.20211201172932-4744e4cc5d2d/sql/analyzer/analyzer.go:348
	...
	```

@max-hoffman max-hoffman merged commit 6950365 into main Dec 8, 2021
@max-hoffman max-hoffman deleted the max/xj-panic branch December 8, 2021 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants