DBLib .ClientVersion

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 796
Joined: 18.11.2018, 17:37
Location: Hungary

DBLib .ClientVersion

Post by aehimself »

Hello,

As it turns out, dblib exports a function called "dbversion" which returns the client engine version in use as a string. I managed to implement it to Zeos, so now for example "freetds v1.4.dev.20211204" properly returns "1.4" if we call ZConnection.ClientVersionStr.
As FreeTDS is being used for other than MSSQL I'm a bit hesitant to send it as a patch, plus I have no idea if all FreeTDS editions will actually return their version in this format...?

In theory I safeguarded it with a string start check, otherwise I simply return 0 so it should be fine, but...

I'm also sure that performance wise my implementation is suboptimal - PAnsiChars can be accessed with pointer magic which I'm not experienced with.

What do you guys think? Just send it and we'll adjust based on the long run?
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: DBLib .ClientVersion

Post by marsupilami »

aehimself wrote: 14.12.2021, 15:51 What do you guys think? Just send it and we'll adjust based on the long run?
Yes - exactly this :) Make it work first - make it work fast afterwards. Also I doubt that the decoding of a client library version is performance critical ;)

Best regards,

Jan
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 796
Joined: 18.11.2018, 17:37
Location: Hungary

Re: DBLib .ClientVersion

Post by aehimself »

Done, pull request is created on GitHub.
I copied the loading implementation of an other function but DBLib seems to be a mess from this perspective (what is the purpose of the _stdcall functions if we never assign them...?!) so I only can hope I did it right.

Just review before applying it, please :)
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: DBLib .ClientVersion

Post by marsupilami »

I applied the patch - without a review. Let's see what happens. I will have a look at the stdcall thing.
Post Reply