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

panic: expected range var #844

Closed
egtann opened this issue Dec 29, 2020 · 1 comment · Fixed by #883
Closed

panic: expected range var #844

egtann opened this issue Dec 29, 2020 · 1 comment · Fixed by #883
Labels
📚 mysql bug Something isn't working
Milestone

Comments

@egtann
Copy link
Contributor

egtann commented Dec 29, 2020

Using MySQL, I get a panic on sqlc generate. I've added some debug logs to narrow down the migration/statement causing the issue, and it's from an ETL step, which is in our migrations but doesn't need to be considered by sqlc:

UPDATE x INNER JOIN y ON y.a = x.a SET x.b = y.b;

Ideally, sqlc would either report an error with the statement in question to make this much easier to debug, or just ignore statements that are irrelevant to sqlc, like UPDATE. My current workaround is to create a small tool to remove these ETL steps before running sqlc generate.

Here's the full text of the panic (the line numbers are slightly off in parse.go, since I added logs, line 66 in the panic below is line 64 in the current master).

panic: expected range var

goroutine 1 [running]:
github.com/kyleconroy/sqlc/internal/engine/dolphin.(*cc).convertUpdateStmt(0xc00042f0e8, 0xc0003b3900, 0xfc2e28)
        /home/myuser/go/src/github.com/sqlc-test/sqlc/internal/engine/dolphin/convert.go:462 +0x3b5
github.com/kyleconroy/sqlc/internal/engine/dolphin.(*cc).convert(0xc00042f0e8, 0x11e4860, 0xc0003b3900, 0x11e4860, 0xc0003b3900)
        /home/myuser/go/src/github.com/sqlc-test/sqlc/internal/engine/dolphin/convert.go:1426 +0x18ba
github.com/kyleconroy/sqlc/internal/engine/dolphin.(*Parser).Parse(0xc000367878, 0x11cdf20, 0xc0005928a0, 0xed, 0xee, 0x0, 0x0, 0x0)
        /home/myuser/go/src/github.com/sqlc-test/sqlc/internal/engine/dolphin/parse.go:66 +0x27d
github.com/kyleconroy/sqlc/internal/compiler.parseCatalog(0x11da780, 0xc000367878, 0xc000475570, 0xc000408960, 0x2, 0x2, 0x1, 0x1)
        /home/myuser/go/src/github.com/sqlc-test/sqlc/internal/compiler/compile.go:70 +0x272
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).ParseCatalog(...)
        /home/myuser/go/src/github.com/sqlc-test/sqlc/internal/compiler/engine.go:45
github.com/kyleconroy/sqlc/internal/cmd.parse(0xc0003c7b30, 0x5, 0xc000046044, 0x33, 0xc0003c7b66, 0x5, 0xc000408960, 0x2, 0x2, 0xc0003c5a70, ...)
        /home/myuser/go/src/github.com/sqlc-test/sqlc/internal/cmd/generate.go:187 +0xf7
github.com/kyleconroy/sqlc/internal/cmd.Generate(0xc000046044, 0x33, 0x11cde20, 0xc000010020, 0xc000010020, 0x5ccf05, 0xe7a600)
        /home/myuser/go/src/github.com/sqlc-test/sqlc/internal/cmd/generate.go:149 +0xc9f
github.com/kyleconroy/sqlc/internal/cmd.glob..func3(0x17ecd20, 0x1d238a0, 0x0, 0x0)
        /home/myuser/go/src/github.com/sqlc-test/sqlc/internal/cmd/cmd.go:89 +0xb1
github.com/spf13/cobra.(*Command).execute(0x17ecd20, 0x1d238a0, 0x0, 0x0, 0x17ecd20, 0x1d238a0)
        /home/myuser/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:854 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0xc0003ba580, 0xc0000c9f10, 0x1, 0x1)
        /home/myuser/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/myuser/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:895
github.com/kyleconroy/sqlc/internal/cmd.Do(0xc00000e090, 0x1, 0x1, 0x11cde00, 0xc000010010, 0x11cde20, 0xc000010018, 0x11cde20, 0xc000010020, 0xc000040118)
        /home/myuser/go/src/github.com/sqlc-test/sqlc/internal/cmd/cmd.go:30 +0x205
main.main()
        /home/myuser/go/src/github.com/sqlc-test/sqlc/cmd/sqlc/main.go:10 +0xb7
@kyleconroy kyleconroy added bug Something isn't working 📚 mysql labels Jan 22, 2021
@kyleconroy kyleconroy added this to the v1.7.0 milestone Feb 2, 2021
@kyleconroy
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 mysql bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants