Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Error op_response:0" with prepared statement

Tags:

sql

go

firebird

I'm using firebird database driver from "github.com/nakagami/firebirdsql" with GO1.11 + FB2.5

But I can't get prepared SELECT to work, it throws "Error op_response:0" error when executing the 2nd QUERYROW(). Any ideas?

Is there any alternative driver? Or am I using incorrect driver?

func test1(tx *sql.Tx) {
    sqlStr := "SELECT number FROM order WHERE id=?"
    stmt, err := tx.Prepare(sqlStr)
    if err != nil {
        panic(err.Error())
    }
    var value string
    err = stmt.QueryRow(123).Scan(&value)
    if err != nil {
        panic(err.Error())
    }
    fmt.Println(value)

    err = stmt.QueryRow(200).Scan(&value)
    if err != nil {
        panic(err.Error())
    }
    fmt.Println(value)    
}

Result:

INV20183121
panic: Error op_response:0

goroutine 1 [running]:
main.test1(0xc00009c000, 0xc0000a8200)
like image 697
Atlas Avatar asked Oct 05 '18 10:10

Atlas


1 Answers

I can venture a guess. Looking at github.com/nakagami/firebirdsql sources, this seems to be the only code path which can produce this error. Looking here, it ignores any network errors returned by recvPackets, which means: any thing on the network socket breaks, and you get this error back (because that's what recvPackets returns in case of network error).

I'd suggest rebuilding your code with debugPrint code uncommented, and see what is actually going on on the network connection.

like image 91
abbot Avatar answered Oct 18 '22 07:10

abbot