[fpc-devel] TMySQLConnection.LoadField field length

Bram Kuijvenhoven kuifwaremailinglists at xs4all.nl
Thu May 19 19:03:46 CEST 2005


Joost van der Sluis wrote:
> If you need more help, let me know. (Or else, send in the patch!)

I've tried several things with the mysql connection, with the following results so far:

After understanding what a VARCHAR is (namely some sort of shortstring with a fixed maximum length), I wanted first to know whether a newer MySQL server reports proper field lengths for fields like 'FORMAT(mydoublefield,3) AS myalias', so I switched to a 4.1 server.

However this didn't work, because I needed a newer client also, because the older client didn't support the newer authentication protocol requested by the server (according to the error message I got).

So I used a newer libMySQL.dll file and adjusted mysql4dyn to accepting this version. But now I got a authentication error for user ODBC at localhost. However I didn't connect as user ODBC?!?

The I figured out the TMySQLConnection object connected twice to the database, once in ConnectToServer and once in PrepareStatement. The second time it tries to fetch the Host, UserName, Password from the FMySQL:PMySQL field. But there seem to be nil values in there... and I guess MySQL somehow tries user ODBC because no username is given.

I also tried loading the newer dll statically, but then I had to comment out a lot more functions in mysql4 and mysql4_com than before, in particular some slave, master and the hash_password functions.

So my findings are:
- the fpc mysql headers contain way too much function headers, which causes 'entry point of function blablabla not found' error when statically loading the library. I think it's better only to try to import the functions which are also documented as part of the C API at http://dev.mysql.com/doc/mysql/en/c.html.
- the fpc headers contain declarations of structs (records) that are not in the MySQL documentation. The only struct described there is the MYSQL_FIELD struct (or: TMySQL record), besides the other types of which no members are listed. Perhaps using the other structs isn't very safe and prone to change.
- mysql4dyn only accepts a 4.0 library and no a 4.1 library; I hope this can be made more flexible...

I understand the fpc team has become tired of mysql header changes and incompatibilities, but this problem does not seem to exist with e.g. the php mysql interface. Maybe the problems can be solved by only importing and functions that are also in the documentation. (This would require manual action instead of simply applying h2pas to mysql.h)

Do you think this is an approach with a chance to success?

MySQL is widely used and therefore it would be nice if it can be supported by fpc. (In fact, I've seen people asking things about mysql on the Lazarus mailing list several times)

After getting the mysql headers right and 'compatible', I could try to create a better TMySQLConnection.

Regards,

Bram




More information about the fpc-devel mailing list