[fpc-pascal] MySQL5

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Tue Jan 17 14:19:40 CET 2012



On Tue, 17 Jan 2012, Mattias Gaertner wrote:

>
> michael.vancanneyt at wisa.be hat am 17. Januar 2012 um 13:28 geschrieben:
>
>>
>>
>> On Tue, 17 Jan 2012, Mattias Gaertner wrote:
>>
>>> Hi,
>>>
>>> I tried connecting to a mysql 5.5 database and used the fpc unit
> mysql51.
>>> There are only examples for 3 and 4, so I started with testdb4.pp and
>>> adapted it.
>>> It turned out that the MYSQL record is missing some new fields, so the
>>> mysql_init overwrites the memory behind.
>>> After adding some dummy bytes at the end it worked nice.
>>>
>>> Is there a better way?
>>
>> Yes, convert the mysql 5.5. headers. Or adapt the 5.1 headers to match
> the
>> 5.5 specs.
>
>
> ;)

You asked for a better way. not a faster :-)

>
>
>
>
>> That is how we bring it up-to-date whenever a new MySQL version appears.
>
>
> I only found mysql51 headers. Are there some newer ones?

Not to my knowlegde.

>
> I would like my program to still run when the next small upgrade comes.

We cannot guarantee that. You even can't guarantee that in C. An upgrade of
the mysql library may break your perfectly running program. 
(I have known it to happen for a client of mine)

Most people don't notice this, since all distributions recompile everything 
that depends on MySQL from scratch anyway. But for FPC, the case is different.

> As
> far as I can see new things are only added at the end, so adding some dummy
> bytes for "future extensions" may help here. Is this wishful thinking?

No, because sometimes they change the size or position of a field, 
and then resolve it with macros in C. Since we need the correct size and
position this does not guarantee you solve everything. They also change 
the number of arguments to calls and change the export symbols, again 
they mask this with C macros.

In short: You never know, hence you must upgrade the headers.

This mess is why I urge people not to use MySQL. Their API is not stable.
e.g. Firebird's API has been stable for the last 12 years, but features are
nevertheless added all the time.

So: upgrade the 5.1 to 5.5, and I'll add it in FPC and create a 5.5 mysql
connection object as soon as I have received the upgraded headers.

Michael.



More information about the fpc-pascal mailing list