Skip to content

fix: avoid panic when parsing the create index on timestamp with/without time zone#5

Open
bbckr wants to merge 2 commits intocovrom:mainfrom
bbckr:bbckr-ts-panic
Open

fix: avoid panic when parsing the create index on timestamp with/without time zone#5
bbckr wants to merge 2 commits intocovrom:mainfrom
bbckr:bbckr-ts-panic

Conversation

@bbckr
Copy link

@bbckr bbckr commented Feb 17, 2025

When running the latest version of goerd against a schema that has a WHERE clause specifying timestamp with/without timezone, it would panic.

panic: runtime error: slice bounds out of range [62:1]

goroutine 1 [running]:
github.com/covrom/goerd/drivers/postgres/idxscan.ParseCreateIndex({0x14000216540?, 0x1400003d878?})
        /Users/user/go/pkg/mod/github.com/covrom/goerd@v1.1.1/drivers/postgres/idxscan/idxscan.go:53 +0x448
github.com/covrom/goerd/drivers/postgres.(*Postgres).Analyze(0x1400003db58, 0x14000146a00)
        /Users/user/go/pkg/mod/github.com/covrom/goerd@v1.1.1/drivers/postgres/postgres.go:253 +0x22f0
github.com/covrom/goerd/datasource.Analyze({0x16d3769c4, 0x84})
        /Users/user/go/pkg/mod/github.com/covrom/goerd@v1.1.1/datasource/datasource.go:24 +0x1d4
github.com/covrom/goerd.SchemaFromPostgresWithConnect(...)
        /Users/user/go/pkg/mod/github.com/covrom/goerd@v1.1.1/goerd.go:14
main.main()
        /Users/user/go/pkg/mod/github.com/covrom/goerd@v1.1.1/cmd/goerd/main.go:185 +0xd34

This is because with utail we index on WITH, and that ends up matching the WITH or WITHOUT in the WHERE clause.

Can be reproduced and validated with the newly added unit tests.

@bbckr bbckr changed the title fix: Panic on timestamp with/without in WHERE clause fix: avoid panic when parsing the create index on WHERE clause timestamp with/without time zone Feb 17, 2025
@bbckr bbckr changed the title fix: avoid panic when parsing the create index on WHERE clause timestamp with/without time zone fix: avoid panic when parsing the create index on timestamp with/without time zone Feb 17, 2025
@bbckr
Copy link
Author

bbckr commented Feb 27, 2025

Hey @covrom, mind taking a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant