Bug #59473 mysql-connector-odbc does not compile: too many arguments to function "my_free"
Submitted: 13 Jan 2011 16:38 Modified: 15 Sep 2011 14:48
Reporter: Adam Spragg Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1.8 OS:Linux (SLES 10; Linux 2.6.16.21/i686)
Assigned to: Bogdan Degtyariov CPU Architecture:Any

[13 Jan 2011 16:38] Adam Spragg
Description:
Trying to compile mysql-connector-odbc, I get the following error:

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../driver -I.. -I/usr/include -O3 -DDBUG_OFF -I/usr/local/mysql/include -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -g -O2 -MT stringutil.lo -MD -MP -MF .deps/stringutil.Tpo -c stringutil.c  -fPIC -DPIC -o .libs/stringutil.o
stringutil.c: In function ‘sqlchar_as_sqlwchar’:
stringutil.c:127: error: too many arguments to function ‘my_free’

The line in question is:

    x_free(str);

This references the macro x_free(), which is defined in "stringutil.h" as:

    #ifndef x_free
    #define x_free(A) { void *tmp= (A); if (tmp) my_free((char *) tmp,MYF(MY_WME+MY_FAE)); }
    #endif

calling my_free() with 2 arguments. There are no (re)defintions of my_free() in the connector itself. my_free() is defined in mysql's "my_sys.h" as:

    extern void my_free(void *ptr);

clearly only taking 1 argument.

This is mysql version mysql-5.5.8-linux2.6-i686.

How to repeat:
$ gzip -cd mysql-connector-odbc-5.1.8.tar.gz | tar -xf -
$ cd mysql-connector-odbc-5.1.8
$ ./configure --disable-gui
$ make

Suggested fix:
I did try fixing up the definition as:

#define x_free(A) my_free(A)

but then got the same error further on:

catalog.c: In function ‘create_fake_resultset’:
catalog.c:97: error: too many arguments to function ‘my_free’
catalog.c:101: error: too many arguments to function ‘my_free’
[14 Jan 2011 12:58] Bogdan Degtyariov
Hi Adam,

Thank you for reporting the problem in Connector/ODBC driver.

Unfortunately, it is not quite clear which driver manager is being used. 
Please provide the following details:

 - driver manager name 
 - driver manager version

Thanks.
[14 Jan 2011 14:00] Adam Spragg
Um, I'm not sure. How do I find out what version of the driver manager I'm using? Why would it be different from the other parts of MySQL?
[14 Jan 2011 14:19] 1 2
my_free() in mysql 5.5.x accepts only 1 parameter vs. 2 in 5.1.x
[14 Jan 2011 14:33] Adam Spragg
I'm not sure I see the relevance there.

Last I checked, the MySQL odbc connector version was not tied to the MySQL server/client library version. After all, the last version of the odbc connector before the 5.x series was the 3.x series, and that worked with MySQL 5 fine.

Has that changed? Do I need an odbc connector version 5.5 to work with MySQL 5.5? If that's not available (can't find it on the website) do I need to downgrade my MySQL version to 5.1 instead?

If there's been an API change from MySQL 5.1 to 5.5, why was 5.5 not given a major version number increase instead and called MySQL 6?
[17 Jan 2011 3:37] Bogdan Degtyariov
Adam,

Sorry, I did not know my_free() was changed.
This is an internal function, which does not belong to MySQL C API as you can see here:

http://dev.mysql.com/doc/refman/5.5/en/c-api-function-overview.html

So, changing the number of parameters in my_free() is OK for version 5.5.

The problem is in MySQL ODBC driver source code, which should make the proper use of my_free() using different includes.
Setting the status "Verified".
[17 Jan 2011 9:34] Adam Spragg
"[my_free()] is an internal function, which does not belong to MySQL C API"

Slightly offtopic, but I can't help wondering ... should it even be defined in the public header files installed to ${prefix}/include then?

"Setting the status "Verified"."

Great! Thanks.
[14 Sep 2011 2:38] Philip Orleans
I need to compile the connector for Red Hat 6.1, 64 bits. So far, it blows up when I type make, with the error shown in the bug. The question is: How do I get a corrected version of the source code? Does anybody have access to it?
[15 Sep 2011 14:41] Lawrenty Novitsky
In latest revisions that problem is solved. You need bazaar cvs to get the sources.
bzr co lp:myodbc
[15 Sep 2011 14:48] Lawrenty Novitsky
I think that bug can be closed. latest revisions of 5.1 and 3.51 can be compiled with 5.5 mysql client. if i not forget anything - 5.1 from rev#955, 3.51 - from rev#748
[17 Sep 2011 11:31] Philip Orleans
I need to get the cvs latest version in order to compile this. Can somebody please publish the CVS commands? I tried "cvs up" but it fails because I need to log in first. Is there a place where I could read this information? Also I downloaded version 5.5 from sources, and I am sure it also has a cvs up command that I could use.
[17 Sep 2011 21:19] Philip Orleans
I downloaded the current code from bazaar. But when I try to compile it, wit cmake, I get this
[root@nvidia lib64]# cd /usr/src/myodbc
[root@nvidia myodbc]# make
[  6%] Built target myodbc3u
Linking C shared library ../lib/libmyodbc5.so
/usr/bin/ld: cannot find -liodbcinst
collect2: ld returned 1 exit status
make[2]: *** [lib/libmyodbc5.so] Error 1
make[1]: *** [driver/CMakeFiles/myodbc5.dir/all] Error 2
make: *** [all] Error 2

I am using unixODBC, and the OS is RHEl 6.1.
I created a soft link to libodbcinst.so with the name that the compiler is looking for:

ls liodbcinst.* -hls
0 lrwxrwxrwx 1 root root 25 Sep 17 14:16 liodbcinst.so -> /usr/lib64/libodbcinst.so

But it does not compile.
My odbc prefix is /usr. Before I issued the "make", I executed "cmake -i" and supplied the location of my odbc.  There was no error.
Any help is welcome.
[8 Mar 2016 10:19] Bogdan Degtyariov
Posted by developer:
 
The new versions had superseded the problem. Closing the bug