sqlc
sqlc copied to clipboard
Crash with unnamed subquery in FROM
Version
1.25.0
What happened?
Queries like SELECT blah FROM (SELECT 1 AS blah); crash sqlc generate.
Changing it to SELECT blah FROM (SELECT 1 AS blah) t1; works as expected.
Relevant log output
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x105a8d1]
goroutine 19 [running]:
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).sourceTables(0x0?, 0xc0000541b0, {0x1d3a060?, 0xc000277d90?})
/home/runner/work/release-workflow/release-workflow/internal/compiler/output_columns.go:601 +0x831
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).outputColumns(0xc00045ad80, 0xc0000541b0, {0x1d3a060?, 0xc000277d90?})
/home/runner/work/release-workflow/release-workflow/internal/compiler/output_columns.go:55 +0x52
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler)._analyzeQuery(0xc00045ad80, 0x1?, {0xc000157180, 0x3e}, 0x1)
/home/runner/work/release-workflow/release-workflow/internal/compiler/analyze.go:180 +0xced
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).analyzeQuery(...)
/home/runner/work/release-workflow/release-workflow/internal/compiler/analyze.go:110
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).parseQuery(0xc00045ad80, {0x1d3a220?, 0xc000353680}, {0xc000157180, 0x3f}, {{0x0, 0x0, {0x0, 0x0}, 0x0, ...}})
/home/runner/work/release-workflow/release-workflow/internal/compiler/parse.go:103 +0x5d5
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).parseQueries(0xc00045ad80, {{0x0, 0x0, {0x0, 0x0}, 0x0, 0x1, 0x0, 0x0}})
/home/runner/work/release-workflow/release-workflow/internal/compiler/compile.go:81 +0x492
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).ParseQueries(...)
/home/runner/work/release-workflow/release-workflow/internal/compiler/engine.go:76
github.com/sqlc-dev/sqlc/internal/cmd.parse({_, _}, {_, _}, {_, _}, {{0x0, 0x0}, {0xc000470096, 0x5}, ...}, ...)
/home/runner/work/release-workflow/release-workflow/internal/cmd/generate.go:308 +0x30b
github.com/sqlc-dev/sqlc/internal/cmd.processQuerySets.func1()
/home/runner/work/release-workflow/release-workflow/internal/cmd/process.go:107 +0x897
golang.org/x/sync/errgroup.(*Group).Go.func1()
/home/runner/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
/home/runner/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:72 +0x96
Database schema
No response
SQL queries
SELECT blah FROM (SELECT 1 AS blah);
Configuration
No response
Playground URL
https://play.sqlc.dev/p/870fad3baf2d6e887996af304cb594f0153c68d70eed5d27884e74aae093d371
What operating system are you using?
Linux
What database engines are you using?
MySQL
What type of code are you generating?
Go