New MySQL Generic Driver

Code samples and contributions from users for ZeosLib's DBOs of version 6.x

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
tohenk
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 02.08.2006, 04:53
Location: Sidoarjo, East Java

New MySQL Generic Driver

Post by tohenk »

Hi All.

This driver use single driver as ideas of mdaems, use the right protocol when library loaded.
To use the new driver enable ENABLE_MYSQL_NEW_DRIVER in Zeos.inc
set protocol to `mysql` then specify the library to load in Connection properties.
Here we are:

Code: Select all

...
Library=libmysql.dll
ForceVersion=500009
...
Note:
- if Library is not specified then default libmysql.dll or libmysqlclient.so is used.
- ForceVersion used when the client library have no mysql_get_client_version function.

This driver was initially tested with D7.
I also added new language for INDONESIAN.

Regards


Tohenk.
You do not have the required permissions to view the files attached to this post.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

@tohenk

This seems excellent to me. (I can't say anything else as I was calling for this before :D ) As I understand it, to the user all different mysql versions disapear in the future? I must admit I did not test it, but reading the changes it looks like a very good start.

Some remarks :
- Not so smart to include the indonesion translations at once. I can manage that, however.
- You added the 'SConnect2Server' constant only to indonesian version. I can manage that as well, but don't know yet if I'll do that. Are all logged messages localized?
- When using the deprecated versions it's not so bad to use the Mysql structures. (They'll probably be dropped after next official release) For the other mysql versions (that's outside the ifdefs) you MUST use the corresponding library functions. (To get rid once and for ever of these ever changing structures)
- Do you think it would be possible to keep the different protocols as choice and check first if the libmysqlxx.dll's exist in case the user chooses one?
- Very close to previous remark : what about embedded mysql? Maybe same solution as we used in the old version? Subclassing your Plaindriver?
- Do you think we could remove all old stuff, as now you duplicated a lot to avoid breaking our version, which we appreciate very much.
- Don't be angry if we only accept this change after next official production release (whatever number that will be). We're trying to freeze current version, because we want to start a real beta test period. (and a release afterwards).

@fduenas, @michael, @zippo, @others

What do you think of this as a concept, details are not important yet. I support it for the release after the next one.

If we agree on adding:
Should we add it to SVN now with the 'ENABLE_MYSQL_NEW_DRIVER' NOT defined in Zeos.inc? This gives us (and other users) the possibility to play with it already. And tohenk doesn't have to keep his new version updated himself.

Mark
User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Post by fduenas »

Hi mdaems: thanks for the private message.

Well I think we can post this changes to see how it works. and i think this is the first step to create the new base class for the plain driver so we can get rid of repeating the structure in each driver. Personally i have alot of problesm with BDS 2006, because it locks sometimes ZPlainMysql.inc file, so i can' get the compilation to work and have to close BDS and open it again to compile the ZeosLib.

I have only the question, if it works with all versions including mysql embedded server? if it does it ,then i give a thumbs up to apply it. :D

Also i think at least after this we can add the sam functoionality to the other protocols.

Good work tohenk.
Regards to all.
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

Seems OK to me, too.

I'll test it ASAP.

For the embedded MySQL can remain as a separate driver type (mysql, mysqld), so the automatic version detection would work separately.

@tohenk: Great idea!

@mdaems: The idea is great, but it must be applied carefully. Is it included in any SVN version or I need to apply the patch separately?
tohenk
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 02.08.2006, 04:53
Location: Sidoarjo, East Java

Post by tohenk »

Hi All.

This new driver work okay on both client library or as embedded.

The difference is, to use mysql embedded you can specify in connection
property:

Code: Select all

...
Library=libmysqld.dll
ForceVersion=500009
ServerArgument1=...
ServerArgument2=...
...
ForceVersion needed because not all of mysql library have mysql_get_client_version.

This driver can handle embedded and non embedded, because only embedded driver have mysql_server_init and mysql_server_end.

I have use it in my application that switch between these two driver and work nice.

Regards.


tohenk
User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Post by fduenas »

So are 'Library' and 'ForceVersion' optional parameters?.

Yes Mysql_get_client_version does't exists in old drivers, so i can gues youre testing that @mysql_API.mysql_get_client_version is not nil, itit so so the you use 'ForceVersion' value ?
tohenk
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 02.08.2006, 04:53
Location: Sidoarjo, East Java

Post by tohenk »

Hi All,
So are 'Library' and 'ForceVersion' optional parameters?.
Both Library and ForceVersion are optional, by default Library would be
libmysql.dll or libmysqlclient.so. ForceVersion if doesn't specified doesn't affect the driver, it would guess the version.

Finally, I have a sample code that test the new driver, it show how to use the driver to handle client library or embedded library.

With this new 'Library' in connection properties, we can specifiy or change the library to use without any application recompile (put in .ini file for example), even we can specifiy Library=full/path/to/library/of/libmysql.dll. Or we can specify library name with odd name like Library=libmysql5.0.24.dll.

With this new driver, old driver are all still available. SO anybody courious to know, try this example.
Actually it was embedded example writen by fduenas, and I modified using my small part of my own framework.

Hope it would be useful.


Regards.


Tohenk
You do not have the required permissions to view the files attached to this post.
User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Post by fduenas »

Well the i think this patch should be applied so we can test the features.
Mark did you applied them already?
User avatar
firmos
n00blet
n00blet
Posts: 40
Joined: 23.01.2006, 10:02

Post by firmos »

Hello Tohenk,
Hello Zippo

are you willing to join the devteam?

greets, helmut
Post Reply