Bug #26384 Possible source for ABI breakage in mysql.h
Submitted: 14 Feb 2007 22:55 Modified: 6 Mar 2007 20:21
Reporter: Christian Hammers (Silver Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S2 (Serious)
Version:5.1, 5.0 OS:
Assigned to: Alexey Botchkov CPU Architecture:Any
Tags: qc

[14 Feb 2007 22:55] Christian Hammers
Description:
Hello

mysql.h defines the following structure:
  typedef struct st_mysql
  {
     ...
     my_bool *unbuffered_fetch_owner;
     #if defined(EMBEDDED_LIBRARY) || defined(EMBEDDED_LIBRARY_COMPATIBLE) ||MYSQL_VERSION_ID >= 50100
     /* needed for embedded server - no net buffer to store the 'info' */
     char *info_buffer;
     #endif
   } MYSQL;

This IMHO means that an application compiled on a host with a MySQL installation that has no support for the embedded server builtin does not work on another host which has a libmysqlclient.so.15 installed which comes from a build with
enabled embedded server. 

So there could be the situation of an ABI breakage - which usually leads to crashing applications - even if the same MySQL version has been used on two
hosts, just because one host had activated a totally unrelated compile time
option when building MySQL.

Note that it even seems to be an ABI breakage which is triggered just by the
version number without any other header file changes as the define looks for
MYSQL_VERSION_ID >= 50100 which happened between 5.0.21 and 5.0.32!

bye,

-christian-

How to repeat:
Extract the /usr/include/mysql directories of some packages:

cd include_5.0.21-3ubuntu1
icheck --canonify -I. -o icheck.out mysql.h
cd ..
cd include_5.0.32-4debian
icheck --canonify -I. -o icheck.out mysql.h

icheck --compare include_5.0.21-3ubuntu1/icheck.out \
                 include_5.0.32-4debian/icheck.out

ABI mismatch: size of 10048 versus 9984
API and ABI addition: member info_buffer is new
...

Suggested fix:
Hm, making it unconditional now would probably break packages of many distributions as some have the embedded server and some not but probably none changed this setting in between a release cycle. But if my concerns are correct then better change it in all development versions and improve the big fat warning at the top of mysql.h.
[15 Feb 2007 6:35] Valeriy Kravchuk
Thank you for a problem report. Verified by code review on latest 5.0.36-BK. 

Also it looks like clients compiled on any modern 5.1.x (MYSQL_VERSION_ID>=50100) will be incompatible with libmysqlclient.so.15 from any modern 5.0.x, while library name is the same...
[4 Mar 2007 21:12] Alexey Botchkov
Yes, that's the source for ABI breakage.
The breakage can happen when we link an object compiled with the 4.x header
against the 5.x embedded library.
Fortunately that's really rare case.
So we recommend to recompile sources with 5.x header to be able to use 5.x embedded server with it. That should be documented.
[6 Mar 2007 20:21] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Added a paragraph about ensuring binary compatibility.
This will appear at:
http://dev.mysql.com/doc/refman/4.1/en/libmysqld.html
http://dev.mysql.com/doc/refman/5.0/en/libmysqld.html
http://dev.mysql.com/doc/refman/5.1/en/libmysqld.html
[8 Aug 2009 11:14] Andrey Ponomarenko
Use ABI-compliance-checker instead of icheck because it provides more convenient and appropriate compatibility report
http://ispras.linux-foundation.org/index.php/ABI_compliance_checker