intercept / intercept-database

A database library for Intercept
MIT License
14 stars 9 forks source link

dbIsConnected does not work immediately after dbCreateConnection #5

Closed Xeno69 closed 5 years ago

Xeno69 commented 5 years ago

When I create a connection with dbCreateConnection and call dbIsConnected immediately afterwards it returns nothing.

Furthermore, calling a dbPing also immediately after dbCreateConnection crashes the game.

I run something like the following code in preinit (CfgFunctions):

_interceptdb = true;
DB_CON = dbCreateConnection "mydb"; if (dbIsConnected DB_CON) then { diag_log ["InterceptDB connected!!!"]; if (dbPing DB_CON) exitWith { diag_log ["InterceptDB mydb DB found!!!"]; }; _interceptdb = false; } else { _interceptdb = false; diag_log ["InterceptDB NOT connected!!!"]; };

If I try a dbIsConnected later it works fine.

Btw, parse array works fine.

dedmen commented 5 years ago

That is expected behavior. Connection is only established at the first query being executed. Though I didn't write that down in the wiki #TODO

Furthermore, calling a dbPing also immediately after dbCreateConnection crashes the game.

Yeah I seem to have failed something in there. dbPing in general seems to be broken.

and call dbIsConnected immediately afterwards it returns nothing.

Nothing? aka nil? or nothing aka false? According to code it cannot return nil. So I assume it returns false, which is correct.

Xeno69 commented 5 years ago

I'm not at home so yeah, could be false for dbIsConnected (tested last night and wrote all that from my head).

So would a dbPing (if it is working) also create a DB connection?

dedmen commented 5 years ago

So would a dbPing (if it is working) also create a DB connection?

Yes definitely. I already have a crashdump of dbPing crashing so that should be easy to fix. Already on it right now.

dedmen commented 5 years ago

Quick and dirty on the go build with a fix for dbPing. Not sure if I can push the real release today or tomorrow. intercept-database_x64.zip 701ab05952e7ce1a8eaba63087734e831abf8e53

Xeno69 commented 5 years ago

Hm, this is what I get now (with the latest intercept-database_x64.dll from the file above):

"Intercept-DB ping exception type error"

when running a dbPing connection.

dedmen commented 5 years ago

Ugh... I hate this :D Apparently SELECT 1 doesn't return a unsigned number then -.-

Xeno69 commented 5 years ago

Other than that it seems to work quite fine now.

Will do some real MP mission tests over the next days, I have both now running, extDB3 and interceptDB.

One thing, please add in the Wiki that dbCreateConnection is case sensitive (maybe other commands too) Others might save some time by knowing that :)

dedmen commented 5 years ago

One thing, please add in the Wiki that dbCreateConnection is case sensitive

Didn't even know it was :D Never thought about it.

The prepareQueryConfig commands are also case sensitive.

I added all that to the wiki, together with the note that connection is only established at first query.

dedmen commented 5 years ago

https://cdn.discordapp.com/attachments/462378164971372564/564878801348067374/intercept-database_x64.dll build with dbPing fixed. Sorry that I can't push a real release currently.