Version
1.10.0
What happened?
sqlc generate panics while parsing an invalid SQL file. The good news is that the panic is documented in internal/compiler/find_params.go at line 67. 😁
This is not critical, since it is caused by an invalid query, but an error would have saved me a lot of time. I may have more time in a few weeks to look for a fix.
Relevant log output
panic: runtime error: index out of range [2] with length 2
goroutine 1 [running]:
github.com/kyleconroy/sqlc/internal/compiler.paramSearch.Visit({{0x0, 0x0}, 0x0, 0xc0007cff20, 0xc0004c4de0, {0x0, 0x0}, {0x0, 0x0}}, {0x121fc60, ...})
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/find_params.go:68 +0xb2d
github.com/kyleconroy/sqlc/internal/sql/astutils.Walk({0x1225240, 0xc000820b90}, {0x121fc60, 0xc00052dc40})
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/sql/astutils/walk.go:21 +0x51
github.com/kyleconroy/sqlc/internal/compiler.findParameters({0x121fc60, 0xc00052dc40})
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/find_params.go:11 +0xce
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).parseQuery(0xc0000e6b40, {0x1220180, 0xc00057f460}, {0xc000404000, 0xc9}, {0x8, {0x0, 0x0}})
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/parse.go:80 +0x4cb
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).parseQueries(0xc0000e6b40, {0xa0, {0x98, 0x52}})
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/compile.go:108 +0x4cb
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).ParseQueries(...)
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/engine.go:49
github.com/kyleconroy/sqlc/internal/cmd.parse({_}, {_, _}, {_, _}, {{0xc00051daa6, 0xa}, {0xc0005298a0, 0x1, 0x1}, ...}, ...)
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/cmd/generate.go:223 +0x1d4
github.com/kyleconroy/sqlc/internal/cmd.Generate({0xc0}, {0xc00009e180, 0x57}, {0x0, 0x2}, {0x1224dc0, 0xc000010020})
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/cmd/generate.go:167 +0xb77
github.com/kyleconroy/sqlc/internal/cmd.glob..func3(0x19d0b80, {0xf946f9, 0x0, 0x0})
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/cmd/cmd.go:120 +0xf7
github.com/spf13/cobra.(*Command).execute(0x19d0b80, {0x1f38a58, 0x0, 0x0})
/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:860 +0x5f8
github.com/spf13/cobra.(*Command).ExecuteC(0xc00079f180)
/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
github.com/kyleconroy/sqlc/internal/cmd.Do({0xc00003c050, 0x1, 0x1}, {0x1224d80, 0xc000010010}, {0x1224dc0, 0xc000010018}, {0x1224dc0, 0xc000010020})
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/cmd/cmd.go:34 +0x32e
main.main()
/go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/cmd/sqlc/main.go:10 +0x7a
Database schema
-- Example queries for sqlc
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL,
bio TEXT
);
SQL queries
-- name: CreateAuthor :exec
INSERT INTO authors (name, bio)
SELECT 1, @name, @bio;
Configuration
{
"version": "1",
"packages": [
{
"path": "db",
"engine": "postgresql",
"schema": "query.sql",
"queries": "query.sql"
}
]
}
Playground URL
https://play.sqlc.dev/p/6f89d4c2e96f764b500f527f0ea5e6da6dae58fc714cf41c7986a52bb08e5e86
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
Version
1.10.0
What happened?
sqlc generatepanics while parsing an invalid SQL file. The good news is that the panic is documented ininternal/compiler/find_params.goat line 67. 😁This is not critical, since it is caused by an invalid query, but an error would have saved me a lot of time. I may have more time in a few weeks to look for a fix.
Relevant log output
panic: runtime error: index out of range [2] with length 2 goroutine 1 [running]: github.com/kyleconroy/sqlc/internal/compiler.paramSearch.Visit({{0x0, 0x0}, 0x0, 0xc0007cff20, 0xc0004c4de0, {0x0, 0x0}, {0x0, 0x0}}, {0x121fc60, ...}) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/find_params.go:68 +0xb2d github.com/kyleconroy/sqlc/internal/sql/astutils.Walk({0x1225240, 0xc000820b90}, {0x121fc60, 0xc00052dc40}) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/sql/astutils/walk.go:21 +0x51 github.com/kyleconroy/sqlc/internal/compiler.findParameters({0x121fc60, 0xc00052dc40}) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/find_params.go:11 +0xce github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).parseQuery(0xc0000e6b40, {0x1220180, 0xc00057f460}, {0xc000404000, 0xc9}, {0x8, {0x0, 0x0}}) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/parse.go:80 +0x4cb github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).parseQueries(0xc0000e6b40, {0xa0, {0x98, 0x52}}) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/compile.go:108 +0x4cb github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).ParseQueries(...) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/compiler/engine.go:49 github.com/kyleconroy/sqlc/internal/cmd.parse({_}, {_, _}, {_, _}, {{0xc00051daa6, 0xa}, {0xc0005298a0, 0x1, 0x1}, ...}, ...) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/cmd/generate.go:223 +0x1d4 github.com/kyleconroy/sqlc/internal/cmd.Generate({0xc0}, {0xc00009e180, 0x57}, {0x0, 0x2}, {0x1224dc0, 0xc000010020}) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/cmd/generate.go:167 +0xb77 github.com/kyleconroy/sqlc/internal/cmd.glob..func3(0x19d0b80, {0xf946f9, 0x0, 0x0}) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/cmd/cmd.go:120 +0xf7 github.com/spf13/cobra.(*Command).execute(0x19d0b80, {0x1f38a58, 0x0, 0x0}) /go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:860 +0x5f8 github.com/spf13/cobra.(*Command).ExecuteC(0xc00079f180) /go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc github.com/spf13/cobra.(*Command).Execute(...) /go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902 github.com/kyleconroy/sqlc/internal/cmd.Do({0xc00003c050, 0x1, 0x1}, {0x1224d80, 0xc000010010}, {0x1224dc0, 0xc000010018}, {0x1224dc0, 0xc000010020}) /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/internal/cmd/cmd.go:34 +0x32e main.main() /go/pkg/mod/github.com/kyleconroy/sqlc@v1.10.0/cmd/sqlc/main.go:10 +0x7aDatabase schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/6f89d4c2e96f764b500f527f0ea5e6da6dae58fc714cf41c7986a52bb08e5e86
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go