Bug #62032 build errors with -DHAVE_EMBEDDED_PRIVILEGE_CONTROL
Submitted: 29 Jul 2011 19:18 Modified: 29 May 2013 12:25
Reporter: Rob Clevenger Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:5.5.15 OS:Linux (Ubuntu 10.04, FC 14)
Assigned to: CPU Architecture:Any

[29 Jul 2011 19:18] Rob Clevenger
Description:
Compile error when using embedded privilege control (similar to old bug 13546)

Here's the error:
/tmp/mysql-5.6.2-m5/libmysqld/lib_sql.cc: In function ‘int check_embedded_connection(MYSQL*, const char*)’:
/tmp/mysql-5.6.2-m5/libmysqld/lib_sql.cc:712: error: ‘struct st_mysql_options’ has no member named ‘client_ip’
/tmp/mysql-5.6.2-m5/libmysqld/lib_sql.cc:714: error: ‘struct st_mysql_options’ has no member named ‘client_ip’
/tmp/mysql-5.6.2-m5/libmysqld/lib_sql.cc:749: error: ‘x_free’ was not declared in this scope
/tmp/mysql-5.6.2-m5/libmysqld/../sql/sql_class.h:2957: error: ‘Diagnostics_area THD::main_da’ is private
/tmp/mysql-5.6.2-m5/libmysqld/lib_sql.cc:754: error: within this context
/tmp/mysql-5.6.2-m5/libmysqld/../sql/sql_class.h:2957: error: ‘Diagnostics_area THD::main_da’ is private
/tmp/mysql-5.6.2-m5/libmysqld/lib_sql.cc:756: error: within this context
[ 56%] make[2]: *** [libmysqld/CMakeFiles/sql_embedded.dir/lib_sql.cc.o] Error 1

How to repeat:
export CXXFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
export CFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
cmake . -DWITH_EMBEDDED_SERVER=1
make
[30 Jul 2011 10:07] Valeriy Kravchuk
What exact version do you try to compile this way? I ask because of that 5.6.2 in pathnames.

FYI, I have no problems compiling current mysq-5.5 (5.5.16) from bzr on Mac OS X:

...
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
macbook-pro:mysql-5.5-work openxs$ echo $?
0
macbook-pro:mysql-5.5-work openxs$ fc -l
...
579	 cd ../mysql-5.5-work/
580	 bzr pull
581	 export CXXFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
582	 export CFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
583	 cmake . -DWITH_EMBEDDED_SERVER=1
584	 make
585	 echo $?
macbook-pro:mysql-5.5-work openxs$
[31 Jul 2011 2:14] Rob Clevenger
I just tried again. I'm on linux, so I'm not sure if that matters.  
I downloaded mysql 5.5 from: http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz/from/http://mysql.he.net/

Here's the error (sorry, last time I tried with both 5.5 and 5.6, and pasted the wrong version).

/tmp/mysql-5.5.15/libmysqld/lib_sql.cc: In function ‘int check_embedded_connection(MYSQL*, const char*)’:
/tmp/mysql-5.5.15/libmysqld/lib_sql.cc:763: error: ‘x_free’ was not declared in this scope
/tmp/mysql-5.5.15/libmysqld/../sql/sql_class.h:2848: error: ‘Diagnostics_area THD::main_da’ is private
/tmp/mysql-5.5.15/libmysqld/lib_sql.cc:768: error: within this context
/tmp/mysql-5.5.15/libmysqld/../sql/sql_class.h:2848: error: ‘Diagnostics_area THD::main_da’ is private
/tmp/mysql-5.5.15/libmysqld/lib_sql.cc:770: error: within this context
make[2]: *** [libmysqld/CMakeFiles/sql_embedded.dir/lib_sql.cc.o] Error 1
make[1]: *** [libmysqld/CMakeFiles/sql_embedded.dir/all] Error 2
make: *** [all] Error 2

From my history:

  499  gcc --version
  500  cd /tmp
  501  tar zxvf /home/rcleveng/Downloads/mysql-5.5.15.tar.gz 
  502  cd mysql-5.5.15/
  503  export CXXFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
  504  export CFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
  505  cmake . -DWITH_EMBEDDED_SERVER=1
  506  make

My GCC version is:
$gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3

cmake is 2.8.0

Looking at the code, my_global.h has this:
#if defined(EMBEDDED_LIBRARY) && !defined(HAVE_EMBEDDED_PRIVILEGE_CONTROL)
#define NO_EMBEDDED_ACCESS_CHECKS
#endif

The code that's failing to compile should fail since x_free isn't defined and main_da isn't accessible. Other code looks like it uses stmt_da in the embedded case, and x_free looks like it should be my_free.

Changing those two makes the code compile, however I'm now perplexed how come it built on Mac OSX, unless that flag isn't being propagated on the mac somehow.  You could #error before the #else (before line 714 on libmysqld/lib_sql.cc to make sure it's compiling the right side of the #ifdef..

Thanks for looking into this!
[1 Aug 2011 10:03] Valeriy Kravchuk
I have to try this on Ubuntu 10.04 one day, but this is what I've got on FC14:

...
Linking C static library libmysqld.a
/usr/bin/ar: creating /home/openxs/bzr/mysql-5.5-work/libmysqld/libmysqld.a
[100%] Built target mysqlserver
[100%] Building C object libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/__/__/tests/mysql_client_test.c.o
Linking CXX executable mysql_client_test_embedded
[100%] Built target mysql_client_test_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/completion_hash.cc.o
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/mysql.cc.o
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o
Linking CXX executable mysql_embedded
[100%] Built target mysql_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[openxs@chief mysql-5.5-work]$ fc -l
80	 bzr pull
81	 cd ../mysql-5.5
82	 bzr pull
83	 cd ../mysql-5.5-work/
84	 bzr pull
85	 cd -
86	 bzr pull
87	 cd ..
88	 bzr branch bzr+ssh://vkravchuk@bk-internal.mysql.com/bzrroot/server/mysql-trunk 
89	 ls
90	 bzr branch `pwd`/mysql-trunk mysql-trunk-work
91	 cd mysql-5.5-work/
92	 export CXXFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
93	 export CFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
94	 cmake . -DWITH_EMBEDDED_SERVER=1
95	 make
[openxs@chief mysql-5.5-work]$ uname -a
Linux chief 2.6.35.11-83.fc14.x86_64 #1 SMP Mon Feb 7 07:06:44 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
[openxs@chief mysql-5.5-work]$ gcc --version
gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[1 Aug 2011 10:23] MySQL Verification Team
funny thing. i can repeat exactly as described on 5.5.15 source code :)
<cut>
[ 86%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/emb_qcache.cc.o
[ 86%] Building C object libmysqld/CMakeFiles/sql_embedded.dir/libmysqld.c.o
[ 86%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/lib_sql.cc.o
/home/sbester/mysql/5.5/mysql-5.5.15/libmysqld/lib_sql.cc: In function âint check_embedded_connection(MYSQL*, const char*)â:
/home/sbester/mysql/5.5/mysql-5.5.15/libmysqld/lib_sql.cc:763: error: âx_freeâ was not declared in this scope
/home/sbester/mysql/5.5/mysql-5.5.15/libmysqld/../sql/sql_class.h:2848: error: âDiagnostics_area THD::main_daâ is private
/home/sbester/mysql/5.5/mysql-5.5.15/libmysqld/lib_sql.cc:768: error: within this context
/home/sbester/mysql/5.5/mysql-5.5.15/libmysqld/../sql/sql_class.h:2848: error: âDiagnostics_area THD::main_daâ is private
/home/sbester/mysql/5.5/mysql-5.5.15/libmysqld/lib_sql.cc:770: error: within this context
make[2]: *** [libmysqld/CMakeFiles/sql_embedded.dir/lib_sql.cc.o] Error 1
make[1]: *** [libmysqld/CMakeFiles/sql_embedded.dir/all] Error 2
make: *** [all] Error 2
[sbester@levovo mysql-5.5.15]$ 

[sbester@levovo mysql-5.5.15]$ cmake --version
cmake version 2.8.0
[sbester@levovo mysql-5.5.15]$ gcc --version
gcc (GCC) 4.4.4 20100630 (Red Hat 4.4.4-10)
[sbester@levovo mysql-5.5.15]$ uname -a
Linux levovo 2.6.33.3-85.fc13.x86_64 #1 SMP Thu May 6 18:09:49 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
[2 Aug 2011 9:38] Valeriy Kravchuk
Verified with 5.5.15 official source code on 64-bit FC14:

Scanning dependencies of target sql_embedded
[ 86%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/emb_qcache.cc.o
[ 86%] Building C object libmysqld/CMakeFiles/sql_embedded.dir/libmysqld.c.o
[ 86%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/lib_sql.cc.o
/home/openxs/mysql-5.5.15/libmysqld/lib_sql.cc: In function ‘int check_embedded_connection(MYSQL*, const char*)’:
/home/openxs/mysql-5.5.15/libmysqld/lib_sql.cc:763:35: error: ‘x_free’ was not declared in this scope
/home/openxs/mysql-5.5.15/libmysqld/../sql/sql_class.h:2848:20: error: ‘Diagnostics_area THD::main_da’ is private
/home/openxs/mysql-5.5.15/libmysqld/lib_sql.cc:768:33: error: within this context
/home/openxs/mysql-5.5.15/libmysqld/../sql/sql_class.h:2848:20: error: ‘Diagnostics_area THD::main_da’ is private
/home/openxs/mysql-5.5.15/libmysqld/lib_sql.cc:770:39: error: within this context
make[2]: *** [libmysqld/CMakeFiles/sql_embedded.dir/lib_sql.cc.o] Error 1
make[1]: *** [libmysqld/CMakeFiles/sql_embedded.dir/all] Error 2
make: *** [all] Error 2

I do not know why current mysql-5.5 source does not have this problem, but there is something for QA to check/add tests for anyway.
[29 May 2013 12:25] Jon Olav Hauglid
Support for -DHAVE_EMBEDDED_PRIVILEGE_CONTROL was removed in MySQL 5.7.2
as a part of an effort to remove options we no longer maintain.