Bug #26818 MySQL 5.2.3 - PHP 5.2.1 - Internal Function Conflict in base64.h
Submitted: 3 Mar 2007 9:15 Modified: 10 Apr 2009 14:41
Reporter: Sietse van Zanen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.2.3 OS:Solaris (Solaris 10 / All)
Assigned to: Jim Winstead CPU Architecture:Any
Tags: 5.2.1, 5.2.3, base64, library, MySQL, php, xmlrpc

[3 Mar 2007 9:15] Sietse van Zanen
Description:
Hi, I was compiling php 5.2.1 against mysql 5.2.3 with embedded mysqli support.

I came across a conflict when linking libphp5.so.

Seems that both MySQL's NDB (include/base64.h) and PHP's XMLRPC (ext/xmlrpc/libxmlrpc/base64.h) both define internal base64_encode() and base64_decode() functions.

I think gcc4.x will be able to fix this, as you have the ability to set visibility of internal functions. But good practice is always to name your internal functions as explicitely and descriptively as possible.

I have opened the same bug @ PHP. They should name there internal functions more explicitely too.

How to repeat:
Compile php5.2.1 against mysql 5.2.3 with mysqli-embedded support.

Suggested fix:
Name internal functions more explicitely like mysql_ndb_base64_encode.

To quickly patch, add:
#define base64_encode base64_encode_bla
#define base64_decode base64_decode_bla

to either MySQL's include/base64.h OR PHP's ext/xmlrpc/libxmlrpc/base64.h
[3 Mar 2007 12:11] Sietse van Zanen
PHP Bug #40703
[3 Mar 2007 13:45] Sietse van Zanen
lol, I knew I had seen this somewhere before:

Bug #13859

You guys should have learned.... :-)
[5 Mar 2007 13:23] Valeriy Kravchuk
Thank you for a bug report. Verified just as described by code review.
[1 May 2008 23:18] Jim Winstead
Add my_ prefix to base64 functions to avoid conflicts

Attachment: bug26818.patch (text/plain), 6.16 KiB.

[7 Oct 2008 12:00] Konstantin Osipov
Jim, could you please push the patch into 6.0?
Thanks,
[25 Mar 2009 0:05] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/70286

2835 Jim Winstead	2009-03-24
      Added 'my_' prefix to base64 functions to avoid conflicts with
      other libraries. (Bug #26818)
      modified:
        include/base64.h
        mysys/base64.c
        sql/log_event.cc
        sql/sql_binlog.cc
        storage/ndb/src/mgmapi/mgmapi.cpp
        unittest/mysys/base64-t.c
[9 Apr 2009 20:25] Bugs System
Pushed into 6.0.11-alpha (revid:jimw@mysql.com-20090408194522-lqgich3cstc1okj2) (version source revid:jimw@mysql.com-20090325000441-yy8fyf1oslylj6cz) (merge vers: 6.0.11-alpha) (pib:6)
[10 Apr 2009 14:42] Paul DuBois
Noted in 6.0.11 changelog.

Internal base64_xxx() functions were renamed to have a prefix of my_
to avoid conflicts with other libraries.