nakagami / firebirdsql

Firebird RDBMS sql driver for Go (golang)
MIT License
227 stars 60 forks source link

Cannot disconnect database with open transactions #67

Closed mukexa closed 6 years ago

mukexa commented 6 years ago
package main

import (
    "database/sql"
    "fmt"

    _ "github.com/nakagami/firebirdsql"
)

func main() {
    var n int
    conn, _ := sql.Open("firebirdsql", "sysdba:masterkey@localhost/test")

    conn.QueryRow("SELECT Count(*) FROM rdb$relations").Scan(&n)
    fmt.Println("Relations count=", n)
    err := conn.Close()
    if err != nil {
        fmt.Println(err)
    }
}

return

Relations count= 42 cannot disconnect database with open transactions (1 active)

mukexa commented 6 years ago

This problem is repeated if you use transactions

package main

import (
    "database/sql"
    "fmt"

    _ "github.com/nakagami/firebirdsql"
)

func main() {
    var n int
    conn, _ := sql.Open("firebirdsql", "sysdba:masterkey@localhost/test")

    tx, _ := conn.Begin()
    err := tx.QueryRow("SELECT Count(*) FROM rdb$relations").Scan(&n)
    if err != nil {
        tx.Rollback()
        fmt.Println("TX:", err)
    }
    fmt.Println("Relations count=", n)
    tx.Commit()

    err = conn.Close()
    if err != nil {
        fmt.Println(err)
    }
}

Relations count= 42 cannot disconnect database with open transactions (1 active)

nakagami commented 6 years ago

Oh, sorry

nakagami commented 6 years ago

I have fixed it. Still something wrong ?