Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-01

MySQL5

7 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

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?
If not, maybe this should be done by default?

Mattias

Reply by email

Unknown author
to Mattias Gaertner
Mattias Gaertner wrote 10 lines
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.

That is how we bring it up-to-date whenever a new MySQL version appears.

Michael.

Reply by email

Marco van de Voort
to Unknown author

In our previous episode, said:

Show quoted text 12 lines
> 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. That is how we bring it up-to-date whenever a new MySQL version appears.

http://bugs.freepascal.org/view.php?id=19736

Reply by email

Mattias Gaertner
to Unknown author: Yes, convert the mysql 5.5. headers. Or adapt the 5.1 headers to match the 5.5 specs.…

hat am 17. Januar 2012 um 13:28 geschrieben:

Show quoted text 7 lines
On Tue, 17 Jan 2012, Mattias Gaertner wrote: > Hi, > > I tried connecting to a mysql 5.5 database and used the fpc unit

mysql51.

Show quoted text 9 lines
> 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.

;)

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?

I would like my program to still run when the next small upgrade comes. 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?

Mattias

Reply by email

Unknown author
to Mattias Gaertner
Mattias Gaertner wrote 25 lines
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 :-)

Show quoted text 8 lines
> 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.

Reply by email

ik
to Unknown author
Show quoted text 38 lines
On Tue, 17 Jan 2012, Mattias Gaertner wrote: > 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 :-)

The best way imho is not to use this "db" toy. Unless you do not have a way to avoid it, and then "it sucks to be you" ;)

Show quoted text 27 lines
> > > > 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.

MySQL is "deprecated", and there are several open source projects that uses the same code base, but try to provide better support (http://mariadb.org/for example).
The problem is, that most people know "MySQL". so here is the problem you describe :(

Show quoted text 29 lines
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. ______________________________**_________________ fpc-pascal maillist - http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal>

Reply by email

Unknown author
to ik
ik wrote 12 lines
> > 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. MySQL is "deprecated", and there are several open source projects that uses the same code base, but try to provide better support (http://mariadb.org/for example). The problem is, that most people know "MySQL". so here is the problem you describe :(

If these forks use the same tactics, they are not better suited for a FPC program. Since the same people that started MySQL are now working on these forks, I think the chances are high that they use the same mechanisms...

So, use a more stable DB. If you need open source: Postgres or Firebird...

Michael.

Reply by email