Bug #19517 No simple way to detect wether server was compiled with libdbug
Submitted: 3 May 2006 14:00 Modified: 27 Apr 2018 12:23
Reporter: Hartmut Holzgraefe Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Compiling Severity:S4 (Feature request)
Version:any OS:Any (*nix)
Assigned to: CPU Architecture:Any

[3 May 2006 14:00] Hartmut Holzgraefe
Description:
Currently configure only addes DBUG_ON or DBUG_OFF to $CFLAGS,
the setting is not stored in any public include file or reported by mysql_config
in any way

To use DBUG_ macros in UDFs (and plugins starting with MySQL 5.1)
one needs to know whether the server one compiles for was created with
debug support or not to avoid unknown symbol errors on loading a UDF
(or plugin) .so

Right now the only way to figure out whether the installed server is a debug
version or not is to find the actual installed mysqld binary and check for either:

- the version string ("mysqld --version") for "-debug"
- the help output ("mysqld --help --verbose") for "--debug"
- the output of "nm mysqld" for the _db_enter_ symbol being defined

As the servers configure file takes care of setting DBUG_ON/OFF anyway
it could as well put the results into config.h (which later becomes include/my_config.h)

How to repeat:
Compare mysql_config output and $prefix/include/mysql contents for
debug and non-debug builds, there is no way to tell which is which from there

Suggested fix:
===== configure.in 1.386 vs edited =====
--- 1.386/configure.in  2006-05-01 20:03:50 +02:00
+++ edited/configure.in 2006-05-03 15:50:18 +02:00
@@ -1651,15 +1651,18 @@ AC_ARG_WITH(debug,
 if test "$with_debug" = "yes"
 then
   # Medium debug.
+  AC_DEFINE([DBUG_ON], [1], [Use libdbug])
   CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DDBUG_ON -DSAFE_MUTEX $CFLAGS"
   CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DDBUG_ON -DSAFE_MUTEX $CXXFLAGS"
 elif test "$with_debug" = "full"
 then
   # Full debug. Very slow in some cases
+  AC_DEFINE([DBUG_ON], [1], [Use libdbug])
   CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS"
   CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS"
 else
   # Optimized version. No debug
+  AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug])
   CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS"
   CXXFLAGS="$OPTIMIZE_CXXFLAGS -DDBUG_OFF $CXXFLAGS"
 fi
[12 Jun 2006 11:08] 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/7531
[20 Jul 2006 17:21] Magnus Blåudd
Pushed to 5.0.25
[4 Aug 2006 11:41] Magnus Blåudd
The symbol DBUG_ON will be defined in config.h
[4 Aug 2006 17:05] Paul DuBois
Noted in 5.0.25 changelog.

configure now defines the symbol DBUG_ON in config.h to indicate
whether the source tree is configured to be compiled with debugging
support.
[14 Aug 2006 21:27] Konstantin Osipov
Merged into 5.1.12
[15 Aug 2006 3:48] Paul DuBois
Noted in 5.1.12 changelog.
[24 Aug 2006 10:18] Magnus Blåudd
Patch for this bug will be reverted in 5.0.25
[4 Dec 2007 21:29] Konstantin Osipov
Thank you for a valid feature request.
[27 Apr 2018 12:23] Yngve Svendsen
Posted by developer:
 
Obsolete MySQL versions.