Driver loading issue when connecting to PostgreSQL after connecting to Oracle

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by miab3 »

Zeos8 r7018 Android won't compile !!!

-V -VN --description:"Zeos Plain Database API" -NO.\Android\Debug ZPlain.dpk
[DCC Error] ZPlainLoader.pas(203): E2003 Undeclared identifier: 'LoadLibraryEx'
[DCC Error] ZPlainLoader.pas(203): E2003 Undeclared identifier: 'LOAD_WITH_ALTERED_SEARCH_PATH'
[DCC Fatal Error] ZPlainDriver.pas(705): F2063 Could not compile used unit 'ZPlainLoader.pas'
Failed

Michal
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by miab3 »

Now it's compiling - Zeos8 r7019

Michał
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by EgonHugeist »

@both constributors,
i just added a fallback using a define. I'm not aware how to resolve the issue on other platforms except using the default code. Let's wait for a new ticket or forum thread. Anyway thank's for your help and support!
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 799
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by aehimself »

@Egonhugeist,

Which platform was missing it except Android? My original idea was to define the LoadLibraryEx method for these (if they have it) or create one, pointing to the original LoadLibrary method.
Anyway, conditional splitting is also fine if you know which platforms need the extra care :)
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
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by miab3 »

Hi Michael,

Lazarus 2.0.6-64 on Linux(x86) had no problem with build r7018.
Only Delphi 10.3.3 with Android had a problem.

Michal
MJFShark
Expert Boarder
Expert Boarder
Posts: 218
Joined: 04.06.2020, 13:59

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by MJFShark »

I've tested the fix (latest r7020) on all my drivers and it seems to work perfectly, completely solving the original problem. I tested:

Oracle clients (11, 12, 19)
PostgreSQL
MySQL
Firebird

Tested on both 32bit and 64bit, Windows 10, Delphi 10.4. Thanks for the fix!

-Mark
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by EgonHugeist »

@Mark, thanks for confirmation! That's allways helpful.
@aehimself all platforms except UNIX such as
DARWIN (OSx)
ANDROID [ANDROID32,ANDROID64]/Delphi AARACH64/FPC
etc.

so it's not worth it bypassing the issue by reimplementing the Windows idea of LoadLibrayEx.
As i said: We're happy the issue is resolved and i perfectly can live with the {$IF declared(LoadLibraryEx)} define. The more FPC has its own DynLib unit(added to Zeos by Marco Van De Voort/FPC core) and i wouldn't take a look to all the hidden FPC .inc files(compile target related) as long nobody reports similar problems.
From my side the case is close and i thank you all for your support!
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 799
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by aehimself »

MJFShark wrote: 29.10.2020, 12:28I've tested the fix (latest r7020) on all my drivers and it seems to work perfectly, completely solving the original problem.
Good, happy to hear! And with your request a 3 year old bug report was closed, so thank you! :)
EgonHugeist wrote: 29.10.2020, 19:33DARWIN (OSx)
ANDROID [ANDROID32,ANDROID64]/Delphi AARACH64/FPC
etc.
Expected. I only have Delphi Win32/64, I relied on Zeos tests to reveal any compile/behavior breaks. So.... FPC/Lazarus doesn't have LoadLibraryEx? That's a shame. It would worth to define it (even in the same unit) on Windows platforms or else FPC will be still affected by the exactly same "misloading" as Delphi was, before.
EgonHugeist wrote: 29.10.2020, 19:33and i wouldn't take a look to all the hidden FPC .inc files(compile target related) as long nobody reports similar problems.
Understandable. Zeos is pretty old and pretty large. Noone wants those wardrobes open, just to release a ton of skeletons!!!
EgonHugeist wrote: 29.10.2020, 19:33From my side the case is close and i thank you all for your support!
As I already mentioned I feel really good if finally I can give something back to this awesome component. Special thanks to Mark for the ExpandFileName tip!

But not so fast! There is one question left for you, Michal.
aehimself wrote: 26.10.2020, 19:58On the other hand keeping the libraries opened until the end of times is NOT a good solution, I don't like this in Zeos either [...] I'd expect it to be released when the (last) connection is disconnected which is using this library.
Do you think it could be done?
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: 1962
Joined: 17.01.2011, 14:17

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by marsupilami »

aehimself wrote: 29.10.2020, 20:58 But not so fast! There is one question left for you, Michal.
aehimself wrote: 26.10.2020, 19:58On the other hand keeping the libraries opened until the end of times is NOT a good solution, I don't like this in Zeos either [...] I'd expect it to be released when the (last) connection is disconnected which is using this library.
Do you think it could be done?
lol - that sounds like a feature for Zeos 9.0 - or maybe a bugfix for a later 8.x version ;)
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by EgonHugeist »

@aehimself,

of course it can be done. Yet it has a low priority for me. Propose you open a feature request ticket: https://sourceforge.net/p/zeoslib/internaltickets/ so we won't forget it.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
MJFShark
Expert Boarder
Expert Boarder
Posts: 218
Joined: 04.06.2020, 13:59

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by MJFShark »

I just wanted to chime in and mention that since the fix to the dll loading stuff I don't have an actual need for unloading the driver dlls. I really brought it up in case it was something that already existed or something I could use to diagnose/workaround the loading issue. Thanks, as always!

-Mark
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 799
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by aehimself »

MJFShark wrote: 03.11.2020, 17:22I just wanted to chime in and mention that since the fix to the dll loading stuff I don't have an actual need for unloading the driver dlls.
I'm sorry to say this, but it's not about you, nor your request :) It's a really inconvenient way of optimization (?) to keep the library connections open until the application is closed. I don't know how it is being handled, but if a new handle is opened each time a connection is opened but not closed afterwards, your application will crash due to handle / memory outage if it is connecting / disconnecting rapidly.

For me it's annoying because if I want to update library DLLs I have to close my app down.

But yeah, this is something I'd LOVE to see in Zeos.
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
MJFShark
Expert Boarder
Expert Boarder
Posts: 218
Joined: 04.06.2020, 13:59

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by MJFShark »

> I'm sorry to say this, but it's not about you, nor your request :)
My wife said the same thing! :)

-Mark
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1962
Joined: 17.01.2011, 14:17

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by marsupilami »

aehimself wrote: 03.11.2020, 20:45But yeah, this is something I'd LOVE to see in Zeos.
Added to the wish list: https://sourceforge.net/p/zeoslib/wiki/Development objectives for Zeos 9.0/
Fr0sT
Zeos Dev Team
Zeos Dev Team
Posts: 280
Joined: 08.05.2014, 12:08

Re: Driver loading issue when connecting to PostgreSQL after connecting to Oracle

Post by Fr0sT »

aehimself wrote: 03.11.2020, 20:45I don't know how it is being handled, but if a new handle is opened each time a connection is opened but not closed afterwards, your application will crash due to handle / memory outage if it is connecting / disconnecting rapidly.
No matter how many times LoadLibrary is called, Windows only loads single instance of a lib. Different handles just point to the same object. Moreover, FreeLibrary cares about ref counter as well. So it's enough for driver object to call FreeLibrary on destroy.
Post Reply