Skip to content

sqlc panics on v1.21.0 in sqlite.getTables #2729

Closed
@jamietanna

Description

@jamietanna

Version

1.21.0

What happened?

Panic received when trying to generate code

Relevant log output

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x100 pc=0xf27ae8]

goroutine 6 [running]:
github.com/sqlc-dev/sqlc/internal/engine/sqlite.(*cc).getTables(0x492201?, 0xc000989980)
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/engine/sqlite/convert.go:556 +0x568
github.com/sqlc-dev/sqlc/internal/engine/sqlite.(*cc).convertMultiSelect_stmtContext(0x4931ec?, 0xc000989968)
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/engine/sqlite/convert.go:404 +0x537
github.com/sqlc-dev/sqlc/internal/engine/sqlite.(*cc).convert(0x0?, {0x2842340?, 0xc000989968?})
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/engine/sqlite/convert.go:1159 +0x2df
github.com/sqlc-dev/sqlc/internal/engine/sqlite.(*cc).convertSql_stmtContext(0x4931ec?, 0xc000989950)
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/engine/sqlite/convert.go:718 +0x1988
github.com/sqlc-dev/sqlc/internal/engine/sqlite.(*cc).convert(0xc000c95d50?, {0x2842360?, 0xc000989950?})
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/engine/sqlite/convert.go:1162 +0x2f9
github.com/sqlc-dev/sqlc/internal/engine/sqlite.(*Parser).Parse(0xc00005ea10?, {0x283d180?, 0xc0005c4b60?})
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/engine/sqlite/parse.go:71 +0x54f
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).parseQueries(0xc00029dc00, {{0x0, 0x0, {0x0, 0x0}, 0x0, 0x0, 0x0}})
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/compiler/compile.go:74 +0x25a
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).ParseQueries(...)
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/compiler/engine.go:49
github.com/sqlc-dev/sqlc/internal/cmd.parse({_, _}, {_, _}, {_, _}, {{0xc000321cfa, 0x6}, {0xc0004381a0, 0x1, ...}, ...}, ...)
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/cmd/generate.go:350 +0x293
github.com/sqlc-dev/sqlc/internal/cmd.Generate.func1()
        /home/jamie/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.21.0/internal/cmd/generate.go:224 +0x7d7
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /home/jamie/go/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
        /home/jamie/go/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:72 +0x96
exit status 2
generate.go:3: running "go": exit status 1

Database schema

CREATE TABLE IF NOT EXISTS aws_elasticache_datastores (
  account_id TEXT NOT NULL,
  region TEXT NOT NULL,
  arn TEXT NOT NULL,
  name TEXT NOT NULL,
  engine TEXT NOT NULL,
  engine_version TEXT NOT NULL,

  -- tags is a JSON object
  tags TEXT NOT NULL,

  UNIQUE (account_id, region, arn) ON CONFLICT REPLACE
);

CREATE TABLE IF NOT EXISTS aws_elasticache_datastore_engines (
  engine TEXT NOT NULL,
  engine_version TEXT NOT NULL,
  deprecation TEXT NOT NULL,

  UNIQUE (engine, engine_version) ON CONFLICT REPLACE
);

SQL queries

-- name: RetrieveAllWithDeprecation :many
select
  arn,
  name,
  d.engine,
  d.engine_version,
  e.deprecation
from
  aws_elasticache_datastores d
inner join aws_elasticache_datastore_engines e
where d.engine = e.engine
and d.engine_version like e.engine_version || '.%'

Configuration

No response

Playground URL

https://play.sqlc.dev/p/e3437505ebfba3f93003f631460d29cedd52b246eabbcb030281e3172eb36097

What operating system are you using?

No response

What database engines are you using?

SQLite

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions