Skip to content

Is somehow possible to import multiple versions? #1480

@prochac

Description

@prochac

Describe the bug
If two pgx/stdlib versions are imported, it leads to panic.

To Reproduce
Steps to reproduce the behavior:

package main

import (
        "fmt"

        _ "github.com/jackc/pgx/v4/stdlib"
        _ "github.com/jackc/pgx/v5/stdlib"
)

func main() {
        fmt.Println("Hello, 世界")
}

Expected behavior
Could import both at the same time, when Go modules allow it thanks to version suffix /v2.

Actual behavior
Panics.
It doesn't allow A/B release behind feature flag.

panic: sql: Register called twice for driver pgx

goroutine 1 [running]:
database/sql.Register({0x56796b, 0x3}, {0x5af900, 0xc0000a2228})
        /usr/lib/go/src/database/sql/sql.go:51 +0x13d
github.com/jackc/pgx/v5/stdlib.init.0()
        /home/prochac/go/pkg/mod/github.com/jackc/pgx/[email protected]/stdlib/sql.go:88 +0x85
exit status 2

Version
go version go1.19.5 linux/amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions