nakagami / firebirdsql

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

Interbase 2007 Connection #30

Closed ricardoseriani closed 7 years ago

ricardoseriani commented 8 years ago

Hi

Please, when I try to connect to a remote Interbase 2007 using the example in README.md, I get no errors, but always return count = 0. If I use fmt.Println(conn.Ping()), I get this error: opAccept() protocol error

I know that this driver is not specificaly for Interbase, but Firebird and Interbase are usualy interchangable. And if i use this driver https://github.com/rowland/go-fb it's work, but the driver does not currently conform to database/sql/driver interfaces.

Thanks in advance

PS: I use ubuntu 14.04 x64 with packages: firebird-dev firebird2.5-classic-common firebird2.5-common firebird2.5-common-doc firebird2.5-server-common

tbenest commented 8 years ago

It might just be your connection string format that you are using.

The connection string format in this driver is different from the standard firebird/interbase format.

so : yourserver:/thedirectory/thedb.fdb

becomes

yourserver/thedirectory/thedb.fdb

i.e. get rid of the :

I use the following

dbname = strings.Replace(dbname, ":", "", 1)

Regards Tim Benest General Manager

EnterAcc S.A.

thb@enteracc.ch +41 (22) 550 8965 @tbenest (Telegram)

C.P. 1436 Rue de Berne 11 1211 Genève 1 Suisse

On 14 June 2016 at 09:55, Ricardo Seriani notifications@github.com wrote:

Hi

Please, when I try to connect to a remote Interbase 2007 using the example in README.md, I get no errors, but always return count = 0. If I use fmt.Println(conn.Ping()), I get this error: opAccept() protocol error

I know that this driver is not specificaly for Interbase, but Firebird and Interbase are usualy interchangable. And if i use this driver https://github.com/rowland/go-fb it's work, but the driver does not currently conform to database/sql/driver interfaces.

Thanks in advance

PS: I use ubuntu 14.04 x64 with packages: firebird-dev firebird2.5-classic-common firebird2.5-common firebird2.5-common-doc firebird2.5-server-common

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nakagami/firebirdsql/issues/30, or mute the thread https://github.com/notifications/unsubscribe/AAFaTe6yP5bbeFbCf6F6PZ-xtPy-XP3dks5qLrK7gaJpZM4I1WPb .

ricardoseriani commented 8 years ago

Unfortunately, I'm already using that format user:password@servername/dbpath given that the dbpath is pointing to a windows machine , for example: d:/bd/database.ib And still yet getting the error

tbenest commented 8 years ago

For windows, try using \ rather than / after the drive letter.

i.e user:password@servername/d:\bd\database.ib

FB and IB are diverging, so do not expect as much compatibility as in the past, especially with V3 onward.

Regards Tim Benest

eMail : thb@taskforce.uk Phone PA : +44 (0)8456 58 34 43 Direct : +41 (22) 550 8965 Telegram : @tbenest

On 14 June 2016 at 10:25, Ricardo Seriani notifications@github.com wrote:

Unfortunately, I'm already using that format user:password@servername/dbpath given that the dbpath is pointing to a windows machine , for example: d:/bd/database.ib And still yet getting the error

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nakagami/firebirdsql/issues/30#issuecomment-225897996, or mute the thread https://github.com/notifications/unsubscribe/AAFaTe7C-207OKM-TOmfkpzLUKZxh_5Kks5qLrn3gaJpZM4I1WPb .

ricardoseriani commented 8 years ago

Didn't work too. Thanks for your advice about diverging FB and IB. Unfortunately I need to maintain a connection with a legacy server, but I want to use some new technology to speed up whatever I can.

tbenest commented 8 years ago

Looks like the err is being raised in the opAccept function in wireprotocol.go. You could try uncommenting the fmt.Printf line in the debugPrint function and see if you can any additional hints. Sry, but I haven't used interbase for 10 years +

func debugPrint(p *wireProtocol, s string) { //fmt.Printf("[%x] %s\n", uintptr(unsafe.Pointer(p)), s) }

nakagami commented 8 years ago

Is this patch resolve this problem ?

diff --git a/wireprotocol.go b/wireprotocol.go
index b910e62..921a3ba 100644
--- a/wireprotocol.go
+++ b/wireprotocol.go
@@ -507,9 +507,6 @@ func (p *wireProtocol) opConnect(dbName string, user string,
        protocols := []string{
                // PROTOCOL_VERSION, Arch type (Generic=1), min, max, weight
                "0000000a00000001000000000000000500000002", // 10, 1, 0, 5, 2
-               "ffff800b00000001000000000000000500000004", // 11, 1, 0, 5, 4
-               "ffff800c00000001000000000000000500000006", // 12, 1, 0, 5, 6
-               "ffff800d00000001000000000000000500000008", // 13, 1, 0, 5, 8
        }
        p.packInt(op_connect)
        p.packInt(op_attach)
ricardoseriani commented 8 years ago

Apparently not.

The steps I did are: 1 - Edit wireprotocol.go to apply your patch 2 - glide rebuild 3 - go run test.go

Errors: conn.Ping() = opAccept() protocol error And in server, I get this interbase.log message: C:\Borland\InterBase\bin\ibserver.exe: terminated abnormally (-1073741819)

nakagami commented 8 years ago

Thanks

Umm, but sorry I don't know how to connect to Interbase 2007

ricardoseriani commented 8 years ago

No problem.

As I said, I know that Interbase 2007 is too old, but unfortunately I need to maintain a connection with a legacy server, but I want to use some new technology to speed up whatever I can. And your project is very Awesome and is following the go sql interface. I tried to use https://github.com/rowland/ and that worked, but it's not go sql interface compliant, so I can't use things like prepare, etc.

Anyway, thanks for your help

nakagami commented 8 years ago

One more modification Is this wrong too ?

diff --git a/wireprotocol.go b/wireprotocol.go
index b910e62..6f03bc5 100644
--- a/wireprotocol.go
+++ b/wireprotocol.go
@@ -507,13 +507,10 @@ func (p *wireProtocol) opConnect(dbName string, user string, password string, au
        protocols := []string{
                // PROTOCOL_VERSION, Arch type (Generic=1), min, max, weight
                "0000000a00000001000000000000000500000002", // 10, 1, 0, 5, 2
-               "ffff800b00000001000000000000000500000004", // 11, 1, 0, 5, 4
-               "ffff800c00000001000000000000000500000006", // 12, 1, 0, 5, 6
-               "ffff800d00000001000000000000000500000008", // 13, 1, 0, 5, 8
        }
        p.packInt(op_connect)
        p.packInt(op_attach)
-       p.packInt(3) // CONNECT_VERSION3
+       p.packInt(2) // CONNECT_VERSION2
        p.packInt(1) // Arch type(GENERIC)
        p.packString(dbName)
        p.packInt(int32(len(protocols)))
ricardoseriani commented 8 years ago

Not work too :worried: But thanks again

nakagami commented 7 years ago

Not support Interbase 2007