Skip to content

1.26.0 crashes on subquery without alias #3337

@mishak87

Description

@mishak87

Version

1.26.0

What happened?

1.26.0 crashes while
1.25.0 reports query.sql:5:5: subquery in FROM must have an alias

Relevant log output

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

goroutine 13 [running]:
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).sourceTables(0xc00035f208, 0xc000736f60, {0x1d84e80?, 0xc0006e7b80?})
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/compiler/output_columns.go:601 +0xaa7
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).outputColumns(0xc00035f208, 0xc000736f60, {0x1d84e80, 0xc0006e7b80})
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/compiler/output_columns.go:55 +0x45
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler)._analyzeQuery(0xc00035f208, 0xc000052be0, {0xc0006e8be3, 0x3f}, 0x1)
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/compiler/analyze.go:180 +0xced
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).analyzeQuery(...)
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/compiler/analyze.go:110
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).parseQuery(0xc00035f208, {0x1d85040, 0xc000052be0}, {0xc0006e8800, 0x73e}, {{0x0, 0x0, {0x0, 0x0}, 0x0, ...}})
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/compiler/parse.go:103 +0x5d5
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).parseQueries(0xc00035f208, {{0x0, 0x0, {0x0, 0x0}, 0x0, 0x0, 0x0, 0x0}})
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/compiler/compile.go:81 +0x467
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).ParseQueries(...)
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/compiler/engine.go:76
github.com/sqlc-dev/sqlc/internal/cmd.parse({_, _}, {_, _}, {_, _}, {{0x0, 0x0}, {0xc000322eb6, 0xa}, ...}, ...)
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/cmd/generate.go:322 +0x30b
github.com/sqlc-dev/sqlc/internal/cmd.processQuerySets.func1()
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/cmd/process.go:107 +0x877
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /home/mishak/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
        /home/mishak/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x96

Database schema

-- irrelevant

SQL queries

-- name: NoAlias :one
SELECT
    x
FROM (
    SELECT 1 AS x
);

Configuration

No response

Playground URL

https://play.sqlc.dev/p/430a752a2c2c961711ea0f5dc5640e191285d42704d65463a6a0bd8c5e3f8992

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions