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

Panic in CheckNamedValue() for an INSERT prepared statement which receives a nil value #87

Closed
mihaitodor opened this issue Sep 11, 2023 · 1 comment

Comments

@mihaitodor
Copy link

Try running the following code with trino-go-client v0.312.0:

package main

import (
        "context"
        "database/sql"
        "log"

        _ "github.com/trinodb/trino-go-client/trino"
)

func main() {
        db, err := sql.Open("trino", "http://localhost:666")
        if err != nil {
                log.Fatal(err)
        }
        if _, err := db.ExecContext(context.Background(), "INSERT INTO TEST (FOO) VALUES (?)", nil); err != nil {
                log.Fatal(err)
        }
}

You'll observe the following panic:

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

goroutine 1 [running]:
github.com/trinodb/trino-go-client/trino.(*driverStmt).CheckNamedValue(0x12fde01?, 0xc000098bd0)
	/Users/mihaitodor/Projects/go/pkg/mod/github.com/trinodb/[email protected]/trino/trino.go:663 +0xd9
database/sql.driverArgsConnLocked({0x13ba5e0, 0xc0000f2000}, 0xc000058c00, {0xc000058f20, 0x1, 0x15ce480?})
	/usr/local/Cellar/go/1.21.1/libexec/src/database/sql/convert.go:178 +0x5b3
database/sql.resultFromStatement({0x13bab30, 0x15ce480}, {0x13ba5e0, 0xc0000f2000}, 0xc000058c00, {0xc000058f20, 0x1, 0x1})
	/usr/local/Cellar/go/1.21.1/libexec/src/database/sql/sql.go:2637 +0xfa
database/sql.(*DB).execDC(0x1?, {0x13bab30, 0x15ce480}, 0xc0000f0090, 0x30?, {0x133c2ea, 0x21}, {0xc000058f20, 0x1, 0x1})
	/usr/local/Cellar/go/1.21.1/libexec/src/database/sql/sql.go:1694 +0x45f
database/sql.(*DB).exec(0x4b15c80?, {0x13bab30, 0x15ce480}, {0x133c2ea, 0x21}, {0xc000058f20, 0x1, 0x1}, 0x0?)
	/usr/local/Cellar/go/1.21.1/libexec/src/database/sql/sql.go:1655 +0xdb
database/sql.(*DB).ExecContext.func1(0x30?)
	/usr/local/Cellar/go/1.21.1/libexec/src/database/sql/sql.go:1634 +0x4f
database/sql.(*DB).retry(0x13b9840?, 0xc000058e70)
	/usr/local/Cellar/go/1.21.1/libexec/src/database/sql/sql.go:1538 +0x42
database/sql.(*DB).ExecContext(0x13310a2?, {0x13bab30?, 0x15ce480?}, {0x133c2ea?, 0x0?}, {0xc000058f20?, 0x10013e0?, 0xc00008e058?})
	/usr/local/Cellar/go/1.21.1/libexec/src/database/sql/sql.go:1633 +0xc8
main.main()
	/Users/mihaitodor/test/main.go:16 +0xa5
exit status 2
@nineinchnick
Copy link
Member

Duplicate of #84

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

No branches or pull requests

2 participants