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

1.26.0 crashes on subquery without alias #3337

Open
mishak87 opened this issue Apr 15, 2024 · 0 comments
Open

1.26.0 crashes on subquery without alias #3337

mishak87 opened this issue Apr 15, 2024 · 0 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@mishak87
Copy link

mishak87 commented Apr 15, 2024

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/sqlc@v1.26.0/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/sqlc@v1.26.0/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/sqlc@v1.26.0/internal/compiler/analyze.go:180 +0xced
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).analyzeQuery(...)
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.26.0/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/sqlc@v1.26.0/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/sqlc@v1.26.0/internal/compiler/compile.go:81 +0x467
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).ParseQueries(...)
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.26.0/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/sqlc@v1.26.0/internal/cmd/generate.go:322 +0x30b
github.com/sqlc-dev/sqlc/internal/cmd.processQuerySets.func1()
        /home/mishak/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.26.0/internal/cmd/process.go:107 +0x877
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /home/mishak/go/pkg/mod/golang.org/x/sync@v0.6.0/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/sync@v0.6.0/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

@mishak87 mishak87 added bug Something isn't working triage New issues that hasn't been reviewed labels Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

1 participant