From 4817542cf7eb6d2f9f26cdab95084f5505aa30ad Mon Sep 17 00:00:00 2001
From: "df@pippilotta.erinye.com" <>
Date: Fri, 20 Apr 2007 14:01:49 +0200
Subject: [PATCH 01/14] win32 build fix
---
VC++Files/sql/mysqld.vcproj | 78 ++-----------------------------------
1 file changed, 3 insertions(+), 75 deletions(-)
diff --git a/VC++Files/sql/mysqld.vcproj b/VC++Files/sql/mysqld.vcproj
index 1caa66c7519..802ca638c90 100644
--- a/VC++Files/sql/mysqld.vcproj
+++ b/VC++Files/sql/mysqld.vcproj
@@ -908,81 +908,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1091,6 +1016,9 @@
+
+
From ab7153791a419cbac901d97ffba7c1e43559a6a1 Mon Sep 17 00:00:00 2001
From: "dfischer/mysqldev@mysql.com/production.mysql.com" <>
Date: Mon, 30 Apr 2007 11:41:19 +0200
Subject: [PATCH 02/14] backport vista manifest patch
---
CMakeLists.txt | 27 ++++++++++++++++++++
client/CMakeLists.txt | 14 ++++++++++
extra/CMakeLists.txt | 7 +++++
libmysql/CMakeLists.txt | 5 ++++
myisam/CMakeLists.txt | 8 ++++++
server-tools/instance-manager/CMakeLists.txt | 5 ++++
sql/CMakeLists.txt | 5 ++++
win/Makefile.am | 3 ++-
win/README | 2 ++
win/configure.js | 1 +
10 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a286071bb0..ec2a875ee92 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -128,6 +128,33 @@ ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR
ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D _CRT_SECURE_NO_DEPRECATE")
+IF(EMBED_MANIFESTS)
+ # Search for the Manifest tool. CMake will first search it's defaults
+ # (CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH, CMAKE_PROGRAM_PATH and
+ # the system PATH) followed by the listed paths which are the current
+ # possible defaults and should be updated when necessary. The custom
+ # manifests are designed to be compatible with all mt versions.
+ FIND_PROGRAM(HAVE_MANIFEST_TOOL NAMES mt
+ PATHS
+ "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/VC/bin"
+ "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin"
+ "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin")
+ IF(HAVE_MANIFEST_TOOL)
+ MESSAGE(STATUS "Found Mainfest Tool. Embedding custom manifests.")
+ ELSE(HAVE_MANIFEST_TOOL)
+ MESSAGE(FATAL_ERROR "Manifest tool, mt.exe, can't be found.")
+ ENDIF(HAVE_MANIFEST_TOOL)
+ # Disable automatic manifest generation.
+ STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
+ ${CMAKE_EXE_LINKER_FLAGS})
+ # Set the processor architecture.
+ IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
+ SET(PROCESSOR_ARCH "X64")
+ ELSE(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
+ SET(PROCESSOR_ARCH "X86")
+ ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
+ENDIF(EMBED_MANIFESTS)
+
ADD_SUBDIRECTORY(vio)
ADD_SUBDIRECTORY(dbug)
ADD_SUBDIRECTORY(strings)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 785bba738bf..8fd56cb92b5 100755
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -12,6 +12,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
@@ -97,3 +98,16 @@ TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug yassl taocrypt zlib wsoc
ADD_EXECUTABLE(echo echo.c)
+IF(EMBED_MANIFESTS)
+ MYSQL_EMBED_MANIFEST("mysql" "asInvoker")
+ MYSQL_EMBED_MANIFEST("mysqltest" "asInvoker")
+ MYSQL_EMBED_MANIFEST("mysqlcheck" "asInvoker")
+ MYSQL_EMBED_MANIFEST("mysqldump" "asInvoker")
+ MYSQL_EMBED_MANIFEST("mysqlimport" "asInvoker")
+ MYSQL_EMBED_MANIFEST("mysql_upgrade" "asInvoker")
+ MYSQL_EMBED_MANIFEST("mysqlshow" "asInvoker")
+ MYSQL_EMBED_MANIFEST("mysqlbinlog" "asInvoker")
+ MYSQL_EMBED_MANIFEST("mysqladmin" "asInvoker")
+ MYSQL_EMBED_MANIFEST("echo" "asInvoker")
+ENDIF(EMBED_MANIFESTS)
+
diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt
index a7a5e3e7b66..8608e72127b 100755
--- a/extra/CMakeLists.txt
+++ b/extra/CMakeLists.txt
@@ -12,6 +12,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
@@ -45,3 +46,9 @@ TARGET_LINK_LIBRARIES(perror strings mysys dbug wsock32)
ADD_EXECUTABLE(replace replace.c)
TARGET_LINK_LIBRARIES(replace strings mysys dbug wsock32)
+
+IF(EMBED_MANIFESTS)
+ MYSQL_EMBED_MANIFEST("my_print_defaults" "asInvoker")
+ MYSQL_EMBED_MANIFEST("perror" "asInvoker")
+ MYSQL_EMBED_MANIFEST("replace" "asInvoker")
+ENDIF(EMBED_MANIFESTS)
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index db4368a3534..647f6bd5e33 100755
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -12,6 +12,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
# Need to set USE_TLS, since __declspec(thread) approach to thread local
# storage does not work properly in DLLs.
@@ -67,3 +68,7 @@ TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32)
ADD_EXECUTABLE(myTest mytest.c)
TARGET_LINK_LIBRARIES(myTest libmysql)
+
+IF(EMBED_MANIFESTS)
+ MYSQL_EMBED_MANIFEST("myTest" "asInvoker")
+ENDIF(EMBED_MANIFESTS)
diff --git a/myisam/CMakeLists.txt b/myisam/CMakeLists.txt
index 28d06254e8a..94a7ffc9952 100755
--- a/myisam/CMakeLists.txt
+++ b/myisam/CMakeLists.txt
@@ -12,6 +12,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
@@ -39,3 +40,10 @@ TARGET_LINK_LIBRARIES(myisamlog myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(myisampack myisampack.c)
TARGET_LINK_LIBRARIES(myisampack myisam mysys dbug strings zlib wsock32)
+
+IF(EMBED_MANIFESTS)
+ MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker")
+ MYSQL_EMBED_MANIFEST("myisamchk" "asInvoker")
+ MYSQL_EMBED_MANIFEST("myisamlog" "asInvoker")
+ MYSQL_EMBED_MANIFEST("myisampack" "asInvoker")
+ENDIF(EMBED_MANIFESTS)
diff --git a/server-tools/instance-manager/CMakeLists.txt b/server-tools/instance-manager/CMakeLists.txt
index 861c44e9f71..b7e2f08ff6e 100755
--- a/server-tools/instance-manager/CMakeLists.txt
+++ b/server-tools/instance-manager/CMakeLists.txt
@@ -12,6 +12,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
@@ -30,3 +31,7 @@ ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instanc
ADD_DEPENDENCIES(mysqlmanager GenError)
TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32)
+
+IF(EMBED_MANIFESTS)
+ MYSQL_EMBED_MANIFEST("mysqlmanager" "asInvoker")
+ENDIF(EMBED_MANIFESTS)
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 9058f9077d9..537a441925c 100755
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -12,6 +12,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
SET(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi")
@@ -85,6 +86,10 @@ ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc
TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg mysys yassl zlib dbug yassl
taocrypt strings vio regex wsock32)
+IF(EMBED_MANIFESTS)
+ MYSQL_EMBED_MANIFEST("mysqld" "requireAdministrator")
+ENDIF(EMBED_MANIFESTS)
+
IF(WITH_EXAMPLE_STORAGE_ENGINE)
TARGET_LINK_LIBRARIES(mysqld example)
ENDIF(WITH_EXAMPLE_STORAGE_ENGINE)
diff --git a/win/Makefile.am b/win/Makefile.am
index b087675793b..c6632737d7b 100755
--- a/win/Makefile.am
+++ b/win/Makefile.am
@@ -14,7 +14,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
## Process this file with automake to create Makefile.in
-EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README
+EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README \
+ mysql_manifest.cmake create_manifest.js
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/win/README b/win/README
index 871ae4efee7..118d619226a 100644
--- a/win/README
+++ b/win/README
@@ -50,6 +50,8 @@ The options right now are
MYSQL_TCP_PORT= Server port, default 3306
DISABLE_GRANT_OPTIONS Disables the use of --init-file and --skip-grant-tables
options of mysqld.exe
+ EMBED_MANIFESTS Embed custom manifests into final exes, otherwise VS
+ default will be used.
So the command line could look like:
diff --git a/win/configure.js b/win/configure.js
index 3488efacba3..a2502d96b80 100755
--- a/win/configure.js
+++ b/win/configure.js
@@ -47,6 +47,7 @@ try
case "WITH_PARTITION_STORAGE_ENGINE":
case "__NT__":
case "DISABLE_GRANT_OPTIONS":
+ case "EMBED_MANIFESTS":
configfile.WriteLine("SET (" + args.Item(i) + " TRUE)");
break;
case "MYSQL_SERVER_SUFFIX":
From d177c5be8a69a4f390619fc449b956e9caf44405 Mon Sep 17 00:00:00 2001
From: "dfischer/mysqldev@mysql.com/production.mysql.com" <>
Date: Mon, 30 Apr 2007 13:30:58 +0200
Subject: [PATCH 03/14] Makefile.am: fix typo
---
win/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/win/Makefile.am b/win/Makefile.am
index c6632737d7b..89f0d65b528 100755
--- a/win/Makefile.am
+++ b/win/Makefile.am
@@ -14,7 +14,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
## Process this file with automake to create Makefile.in
-EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README \
+EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README \
mysql_manifest.cmake create_manifest.js
# Don't update the files from bitkeeper
From 6f99acc246a39e33fbd77e7ec29dfa1d13fa6d20 Mon Sep 17 00:00:00 2001
From: "dfischer/mysqldev@mysql.com/production.mysql.com" <>
Date: Mon, 30 Apr 2007 14:22:38 +0200
Subject: [PATCH 04/14] create_manifest.js, mysql_manifest.cmake: add files
for patch
---
win/create_manifest.js | 85 ++++++++++++++++++++++++++++++++++++++++
win/mysql_manifest.cmake | 20 ++++++++++
2 files changed, 105 insertions(+)
create mode 100644 win/create_manifest.js
create mode 100644 win/mysql_manifest.cmake
diff --git a/win/create_manifest.js b/win/create_manifest.js
new file mode 100644
index 00000000000..5605f57ef74
--- /dev/null
+++ b/win/create_manifest.js
@@ -0,0 +1,85 @@
+/*
+ manifest.js - Writes a custom XML manifest for each executable/library
+ 6 command line options must be supplied:
+ name - Name of the executable/library into which the mainfest will be
+ embedded.
+ version - Version of the executable
+ arch - Architecture intended.
+ type - Application type.
+ exe_level - Application execution level.
+ [asInvoker|highestAvailable|requireAdministrator]
+ outfile - Final destination where mainfest will be written.
+
+ Example:
+ cscript manifest.js name=mysql version=5.0.32 arch=X86 type=win32
+ exe_level=asInvoker outfile=out.xml
+*/
+
+try
+{
+ var args = WScript.Arguments
+ for (i=0; i < args.Count(); i++)
+ {
+ var parts = args.Item(i).split('=');
+ switch (parts[0])
+ {
+ case "name":
+ var app_name= parts[1];
+ break;
+ case "version":
+ var app_version= parts[1];
+ break;
+ case "arch":
+ var app_arch= parts[1];
+ break;
+ case "type":
+ var app_type= parts[1];
+ break;
+ case "exe_level":
+ var app_exe_level= parts[1];
+ break;
+ case "outfile":
+ var manifest_file= parts[1];
+ break;
+ default:
+ WScript.echo("Invalid argument supplied.");
+ }
+ }
+ if (i != 6)
+ throw new Error(1, "Incorrect number of arguments.");
+
+ var manifest_xml= "\r\n";
+ manifest_xml+= "\r\n";
+ // Application Information
+ manifest_xml+= "\t\r\n";
+ // Identify the application security requirements.
+ manifest_xml+= "\t\r\n";
+ manifest_xml+= "\t\t\r\n\t\t\t\r\n\t\t\t\t";
+ manifest_xml+= "\r\n";
+ manifest_xml+= "\t\t\t\r\n\t\t\r\n";
+ manifest_xml+= "\t\r\n\r\n";
+
+ // Write the valid XML to it's final destination.
+ var outfileXML = WScript.CreateObject("Msxml2.DOMDocument.3.0");
+ outfileXML.async = false;
+ if (!outfileXML.loadXML(manifest_xml))
+ {
+ WScript.Echo(manifest_xml);
+ throw new Error(2, "Invalid XML");
+ }
+ outfileXML.save(manifest_file);
+
+ WScript.Echo("Success, created custom manifest!");
+ WScript.Quit(0);
+}
+catch (e)
+{
+ WScript.Echo("Error: " + e.description);
+ WScript.Quit(1);
+}
diff --git a/win/mysql_manifest.cmake b/win/mysql_manifest.cmake
new file mode 100644
index 00000000000..b5bb6fda8fb
--- /dev/null
+++ b/win/mysql_manifest.cmake
@@ -0,0 +1,20 @@
+
+# - MYSQL_EMBED_MANIFEST(target_name required_privs)
+# Create a manifest for target_name. Set the execution level to require_privs
+#
+# NOTE. PROCESSOR_ARCH must be defined before this MACRO is called.
+
+MACRO(MYSQL_EMBED_MANIFEST _target_name _required_privs)
+ ADD_CUSTOM_COMMAND(
+ TARGET ${_target_name}
+ PRE_LINK
+ COMMAND cscript.exe
+ ARGS "${PROJECT_SOURCE_DIR}/win/create_manifest.js" name=$(ProjectName) version=${VERSION} arch=${PROCESSOR_ARCH} type=$(PlatformName) exe_level=${_required_privs} outfile=$(IntDir)\\$(TargetFileName).intermediate.manifest
+ COMMENT "Generates the contents of the manifest contents.")
+ ADD_CUSTOM_COMMAND(
+ TARGET ${_target_name}
+ POST_BUILD
+ COMMAND mt.exe
+ ARGS -nologo -manifest $(IntDir)\\$(TargetFileName).intermediate.manifest -outputresource:$(TargetPath)
+ COMMENT "Embeds the manifest contents.")
+ENDMACRO(MYSQL_EMBED_MANIFEST)
From 634ece765f617b0d3b712b1935ec72a60c98ccb0 Mon Sep 17 00:00:00 2001
From: "df@pippilotta.erinye.com" <>
Date: Fri, 4 May 2007 09:46:33 +0200
Subject: [PATCH 05/14] backport a manifest fix
---
CMakeLists.txt | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9cde3e222ec..11f9100b7ad 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,6 +150,11 @@ IF(EMBED_MANIFESTS)
# Disable automatic manifest generation.
STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
${CMAKE_EXE_LINKER_FLAGS})
+ # Explicitly disable it since it is the default for newer versions of VS
+ STRING(REGEX MATCH "MANIFEST:NO" tmp_manifest ${CMAKE_EXE_LINKER_FLAGS})
+ IF(NOT tmp_manifest)
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
+ ENDIF(tmp_manifest)
# Set the processor architecture.
IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
SET(PROCESSOR_ARCH "X64")
From 18c733a5e2b44b86366f59db837fa50b93f435a6 Mon Sep 17 00:00:00 2001
From: "df@pippilotta.erinye.com" <>
Date: Mon, 7 May 2007 08:25:47 +0200
Subject: [PATCH 06/14] specfile fixes
---
support-files/mysql.spec.sh | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index accf0f1d201..c49fa645a90 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -315,7 +315,7 @@ for servertype in '--with-debug=full' ' '
do
BuildMySQL "\
%if %{STATIC_BUILD}
- --disable-shared \
+ --enable-shared \
--with-mysqld-ldflags='-all-static' \
--with-client-ldflags='-all-static' \
$USE_OTHER_LIBC_DIR \
@@ -347,6 +347,22 @@ done
./libtool --mode=execute nm --numeric-sort sql/mysqld > sql/mysqld.sym
+# Include libgcc.a in the devel subpackage (BUG 4921)
+if expr "$CC" : ".*gcc.*" > /dev/null ;
+then
+ libgcc=`$CC $CFLAGS --print-libgcc-file`
+ if [ -f $libgcc ]
+ then
+ %define have_libgcc 1
+ install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a
+ fi
+fi
+
+# Save the libraries
+(cd libmysql/.libs; tar cf $RBR/shared-libs.tar *.so*)
+(cd libmysql_r/.libs; tar rf $RBR/shared-libs.tar *.so*)
+(cd ndb/src/.libs; tar rf $RBR/shared-libs.tar *.so*)
+
# We might want to save the config log file
if test -n "$MYSQL_CONFLOG_DEST"
then
@@ -379,18 +395,7 @@ make install-strip DESTDIR=$RBR benchdir_root=%{_datadir}
install -s -m 755 $MBD/sql/mysqld-debug $RBR%{_sbindir}/mysqld-debug
# Install shared libraries (Disable for architectures that don't support it)
-# (cd $RBR%{_libdir}; tar xf $RBR/shared-libs.tar; rm -f $RBR/shared-libs.tar)
-
-# Include libgcc.a in the devel subpackage (BUG 4921)
-if expr "$CC" : ".*gcc.*" > /dev/null ;
-then
- libgcc=`$CC $CFLAGS --print-libgcc-file`
- if [ -f $libgcc ]
- then
- %define have_libgcc 1
- install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a
- fi
-fi
+(cd $RBR%{_libdir}; tar xf $RBR/shared-libs.tar; rm -f $RBR/shared-libs.tar)
# install symbol files ( for stack trace resolution)
# install -m 644 $MBD/sql/mysqld-max.sym $RBR%{_libdir}/mysql/mysqld-max.sym
@@ -540,7 +545,7 @@ fi
%doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1
+%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1*
From f3c5627a792fc5b1b531e13bb15921a4de244a33 Mon Sep 17 00:00:00 2001
From: "df@pippilotta.erinye.com" <>
Date: Mon, 7 May 2007 19:48:11 +0200
Subject: [PATCH 07/14] raise version number
---
configure.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.in b/configure.in
index 260c9a9f0fd..5184587f453 100644
--- a/configure.in
+++ b/configure.in
@@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line!
# remember to also change ndb version below and update version.c in ndb
-AM_INIT_AUTOMAKE(mysql, 5.0.41)
+AM_INIT_AUTOMAKE(mysql, 5.0.43)
AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10
@@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0
# ndb version
NDB_VERSION_MAJOR=5
NDB_VERSION_MINOR=0
-NDB_VERSION_BUILD=41
+NDB_VERSION_BUILD=43
NDB_VERSION_STATUS=""
# Set all version vars based on $VERSION. How do we do this more elegant ?
From 01f572052d0d50a06745d5b6d96e20db81530d7b Mon Sep 17 00:00:00 2001
From: "cmiller@zippy.cornsilk.net" <>
Date: Mon, 2 Jul 2007 07:27:39 -0400
Subject: [PATCH 08/14] Unify profiling SHOW code and INFORMATION_SCHEMA code
for profiling. Also,
Bug#26938: profiling client hang if used before enabled
In the SHOW command, not sending header data because we had no
rows to send was a protocol violation. Porting the SHOW PROFILE
command to use the Information Schema table avoids that problem.
---
mysql-test/r/profiling.result | 4 +
mysql-test/t/profiling.test | 5 +
sql/sql_parse.cc | 26 +--
sql/sql_profile.cc | 348 ++++++++++------------------------
sql/sql_profile.h | 7 +-
sql/sql_show.cc | 3 +-
sql/sql_yacc.yy | 8 +-
sql/table.h | 2 +-
8 files changed, 124 insertions(+), 279 deletions(-)
diff --git a/mysql-test/r/profiling.result b/mysql-test/r/profiling.result
index 9f478d68b8d..b99870e3564 100644
--- a/mysql-test/r/profiling.result
+++ b/mysql-test/r/profiling.result
@@ -1,3 +1,7 @@
+show profiles;
+Query_ID Duration Query
+show profile all;
+Status Duration CPU_user CPU_system Context_voluntary Context_involuntary Block_ops_in Block_ops_out Messages_sent Messages_received Page_faults_major Page_faults_minor Swaps Source_function Source_file Source_line
show session variables like 'profil%';
Variable_name Value
profiling OFF
diff --git a/mysql-test/t/profiling.test b/mysql-test/t/profiling.test
index fd7562f6f16..960aa496731 100644
--- a/mysql-test/t/profiling.test
+++ b/mysql-test/t/profiling.test
@@ -1,3 +1,8 @@
+# Verify that the protocol isn't violated if we ask for profiling info
+# before profiling has recorded anything.
+show profiles;
+show profile all;
+
# default is OFF
show session variables like 'profil%';
select @@profiling;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 34702dce957..8c1d627c5f5 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2315,6 +2315,15 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
break;
}
#endif
+ case SCH_PROFILES:
+ /*
+ Mark this current profiling record to be discarded. We don't
+ wish to have SHOW commands show up in profiling.
+ */
+#ifdef ENABLED_PROFILING
+ thd->profiling.discard();
+#endif
+ break;
case SCH_OPEN_TABLES:
case SCH_VARIABLES:
case SCH_STATUS:
@@ -2755,23 +2764,6 @@ mysql_execute_command(THD *thd)
#else
my_error(ER_FEATURE_DISABLED, MYF(0), "SHOW PROFILES", "enable-profiling");
goto error;
-#endif
- break;
- }
- case SQLCOM_SHOW_PROFILE:
- {
-#ifdef ENABLED_PROFILING
- thd->profiling.store();
- thd->profiling.discard(); // will get re-enabled by reset()
- if (lex->profile_query_id != 0)
- res= thd->profiling.show(lex->profile_options, lex->profile_query_id);
- else
- res= thd->profiling.show_last(lex->profile_options);
- if (res)
- goto error;
-#else
- my_error(ER_FEATURE_DISABLED, MYF(0), "SHOW PROFILE", "enable-profiling");
- goto error;
#endif
break;
}
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index 91b0b062e4f..fbb05a988c5 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -41,27 +41,77 @@ int fill_query_profile_statistics_info(THD *thd, struct st_table_list *tables,
ST_FIELD_INFO query_profile_statistics_info[]=
{
/* name, length, type, value, maybe_null, old_name */
- {"QUERY_ID", 20, MYSQL_TYPE_LONG, 0, false, NULL},
- {"SEQ", 20, MYSQL_TYPE_LONG, 0, false, NULL},
- {"STATE", 30, MYSQL_TYPE_STRING, 0, false, NULL},
- {"DURATION", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, false, NULL},
- {"CPU_USER", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, NULL},
- {"CPU_SYSTEM", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, NULL},
- {"CONTEXT_VOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, NULL},
- {"CONTEXT_INVOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, NULL},
- {"BLOCK_OPS_IN", 20, MYSQL_TYPE_LONG, 0, true, NULL},
- {"BLOCK_OPS_OUT", 20, MYSQL_TYPE_LONG, 0, true, NULL},
- {"MESSAGES_SENT", 20, MYSQL_TYPE_LONG, 0, true, NULL},
- {"MESSAGES_RECEIVED", 20, MYSQL_TYPE_LONG, 0, true, NULL},
- {"PAGE_FAULTS_MAJOR", 20, MYSQL_TYPE_LONG, 0, true, NULL},
- {"PAGE_FAULTS_MINOR", 20, MYSQL_TYPE_LONG, 0, true, NULL},
- {"SWAPS", 20, MYSQL_TYPE_LONG, 0, true, NULL},
- {"SOURCE_FUNCTION", 30, MYSQL_TYPE_STRING, 0, true, NULL},
- {"SOURCE_FILE", 20, MYSQL_TYPE_STRING, 0, true, NULL},
- {"SOURCE_LINE", 20, MYSQL_TYPE_LONG, 0, true, NULL},
+ {"QUERY_ID", 20, MYSQL_TYPE_LONG, 0, false, "Query_id"},
+ {"SEQ", 20, MYSQL_TYPE_LONG, 0, false, "Seq"},
+ {"STATE", 30, MYSQL_TYPE_STRING, 0, false, "Status"},
+ {"DURATION", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, false, "Duration"},
+ {"CPU_USER", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, "CPU_user"},
+ {"CPU_SYSTEM", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, "CPU_system"},
+ {"CONTEXT_VOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, "Context_voluntary"},
+ {"CONTEXT_INVOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, "Context_involuntary"},
+ {"BLOCK_OPS_IN", 20, MYSQL_TYPE_LONG, 0, true, "Block_ops_in"},
+ {"BLOCK_OPS_OUT", 20, MYSQL_TYPE_LONG, 0, true, "Block_ops_out"},
+ {"MESSAGES_SENT", 20, MYSQL_TYPE_LONG, 0, true, "Messages_sent"},
+ {"MESSAGES_RECEIVED", 20, MYSQL_TYPE_LONG, 0, true, "Messages_received"},
+ {"PAGE_FAULTS_MAJOR", 20, MYSQL_TYPE_LONG, 0, true, "Page_faults_major"},
+ {"PAGE_FAULTS_MINOR", 20, MYSQL_TYPE_LONG, 0, true, "Page_faults_minor"},
+ {"SWAPS", 20, MYSQL_TYPE_LONG, 0, true, "Swaps"},
+ {"SOURCE_FUNCTION", 30, MYSQL_TYPE_STRING, 0, true, "Source_function"},
+ {"SOURCE_FILE", 20, MYSQL_TYPE_STRING, 0, true, "Source_file"},
+ {"SOURCE_LINE", 20, MYSQL_TYPE_LONG, 0, true, "Source_line"},
{NULL, 0, MYSQL_TYPE_STRING, 0, true, NULL}
};
+
+int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table)
+{
+ int profile_options = thd->lex->profile_options;
+ int fields_include_condition_truth_values[]= {
+ FALSE, /* Query_id */
+ FALSE, /* Seq */
+ TRUE, /* Status */
+ TRUE, /* Duration */
+ profile_options & PROFILE_CPU, /* CPU_user */
+ profile_options & PROFILE_CPU, /* CPU_system */
+ profile_options & PROFILE_CONTEXT, /* Context_voluntary */
+ profile_options & PROFILE_CONTEXT, /* Context_involuntary */
+ profile_options & PROFILE_BLOCK_IO, /* Block_ops_in */
+ profile_options & PROFILE_BLOCK_IO, /* Block_ops_out */
+ profile_options & PROFILE_IPC, /* Messages_sent */
+ profile_options & PROFILE_IPC, /* Messages_received */
+ profile_options & PROFILE_PAGE_FAULTS, /* Page_faults_major */
+ profile_options & PROFILE_PAGE_FAULTS, /* Page_faults_minor */
+ profile_options & PROFILE_SWAPS, /* Swaps */
+ profile_options & PROFILE_SOURCE, /* Source_function */
+ profile_options & PROFILE_SOURCE, /* Source_file */
+ profile_options & PROFILE_SOURCE, /* Source_line */
+ };
+
+ ST_FIELD_INFO *field_info;
+ Name_resolution_context *context= &thd->lex->select_lex.context;
+ int i;
+
+ for (i= 0; schema_table->fields_info[i].field_name != NULL; i++)
+ {
+ if (! fields_include_condition_truth_values[i])
+ continue;
+
+ field_info= &schema_table->fields_info[i];
+ Item_field *field= new Item_field(context,
+ NullS, NullS, field_info->field_name);
+ if (field)
+ {
+ field->set_name(field_info->old_name,
+ strlen(field_info->old_name),
+ system_charset_info);
+ if (add_item_to_list(thd, field))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
#ifdef ENABLED_PROFILING
#define RUSAGE_USEC(tv) ((tv).tv_sec*1000*1000 + (tv).tv_usec)
@@ -242,212 +292,6 @@ void QUERY_PROFILE::reset()
DBUG_VOID_RETURN;
}
-bool QUERY_PROFILE::show(uint options)
-{
- THD *thd= profiling->thd;
- List- field_list;
- DBUG_ENTER("QUERY_PROFILE::show");
-
- field_list.push_back(new Item_empty_string("Status", MYSQL_ERRMSG_SIZE));
- field_list.push_back(new Item_return_int("Duration", TIME_FLOAT_DIGITS,
- MYSQL_TYPE_DOUBLE));
-
- if (options & PROFILE_CPU)
- {
- field_list.push_back(new Item_return_int("CPU_user", TIME_FLOAT_DIGITS,
- MYSQL_TYPE_DOUBLE));
- field_list.push_back(new Item_return_int("CPU_system", TIME_FLOAT_DIGITS,
- MYSQL_TYPE_DOUBLE));
- }
-
- if (options & PROFILE_MEMORY)
- {
- }
-
- if (options & PROFILE_CONTEXT)
- {
- field_list.push_back(new Item_return_int("Context_voluntary", 10,
- MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int("Context_involuntary", 10,
- MYSQL_TYPE_LONG));
- }
-
- if (options & PROFILE_BLOCK_IO)
- {
- field_list.push_back(new Item_return_int("Block_ops_in", 10,
- MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int("Block_ops_out", 10,
- MYSQL_TYPE_LONG));
- }
-
- if (options & PROFILE_IPC)
- {
- field_list.push_back(new Item_return_int("Messages_sent", 10,
- MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int("Messages_received", 10,
- MYSQL_TYPE_LONG));
- }
-
- if (options & PROFILE_PAGE_FAULTS)
- {
- field_list.push_back(new Item_return_int("Page_faults_major", 10,
- MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int("Page_faults_minor", 10,
- MYSQL_TYPE_LONG));
- }
-
- if (options & PROFILE_SWAPS)
- {
- field_list.push_back(new Item_return_int("Swaps", 10, MYSQL_TYPE_LONG));
- }
-
- if (options & PROFILE_SOURCE)
- {
- field_list.push_back(new Item_empty_string("Source_function",
- MYSQL_ERRMSG_SIZE));
- field_list.push_back(new Item_empty_string("Source_file",
- MYSQL_ERRMSG_SIZE));
- field_list.push_back(new Item_return_int("Source_line", 10,
- MYSQL_TYPE_LONG));
- }
-
- if (thd->protocol->send_fields(&field_list,
- Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
- DBUG_RETURN(TRUE);
-
- Protocol *protocol= thd->protocol;
- SELECT_LEX *sel= &thd->lex->select_lex;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows idx= 0;
- unit->set_limit(sel);
- PROFILE_ENTRY *previous= &profile_start;
-
- PROFILE_ENTRY *entry;
- void *iterator;
- for (iterator= entries.new_iterator();
- iterator != NULL;
- iterator= entries.iterator_next(iterator))
- {
- entry= entries.iterator_value(iterator);
-
-#ifdef HAVE_GETRUSAGE
- struct rusage *rusage= &(entry->rusage);
-#endif
- String elapsed;
-
- if (++idx <= unit->offset_limit_cnt)
- continue;
- if (idx > unit->select_limit_cnt)
- break;
-
- protocol->prepare_for_resend();
-
- /*
- This entry, n, has a point in time, T(n), and a status phrase, S(n). The
- status phrase S(n) describes the period of time that begins at T(n). The
- previous status phrase S(n-1) describes the period of time that starts at
- T(n-1) and ends at T(n). Since we want to describe the time that a status
- phrase took T(n)-T(n-1), this line must describe the previous status.
- */
- protocol->store(previous->status, strlen(previous->status),
- system_charset_info);
- protocol->store((double)(entry->time_usecs -
- previous->time_usecs)/(1000.0*1000),
- (uint32) TIME_FLOAT_DIGITS-1, &elapsed);
-
- if (options & PROFILE_CPU)
- {
-#ifdef HAVE_GETRUSAGE
- String cpu_utime, cpu_stime;
- protocol->store((double)(RUSAGE_DIFF_USEC(rusage->ru_utime,
- previous->rusage.ru_utime))/(1000.0*1000),
- (uint32) TIME_FLOAT_DIGITS-1, &cpu_utime);
- protocol->store((double)(RUSAGE_DIFF_USEC(rusage->ru_stime,
- previous->rusage.ru_stime))/(1000.0*1000),
- (uint32) TIME_FLOAT_DIGITS-1, &cpu_stime);
-#else
- protocol->store_null();
- protocol->store_null();
-#endif
- }
-
- if (options & PROFILE_CONTEXT)
- {
-#ifdef HAVE_GETRUSAGE
- protocol->store((uint32)(rusage->ru_nvcsw - previous->rusage.ru_nvcsw));
- protocol->store((uint32)(rusage->ru_nivcsw - previous->rusage.ru_nivcsw));
-#else
- protocol->store_null();
- protocol->store_null();
-#endif
- }
-
- if (options & PROFILE_BLOCK_IO)
- {
-#ifdef HAVE_GETRUSAGE
- protocol->store((uint32)(rusage->ru_inblock - previous->rusage.ru_inblock));
- protocol->store((uint32)(rusage->ru_oublock - previous->rusage.ru_oublock));
-#else
- protocol->store_null();
- protocol->store_null();
-#endif
- }
-
- if (options & PROFILE_IPC)
- {
-#ifdef HAVE_GETRUSAGE
- protocol->store((uint32)(rusage->ru_msgsnd - previous->rusage.ru_msgsnd));
- protocol->store((uint32)(rusage->ru_msgrcv - previous->rusage.ru_msgrcv));
-#else
- protocol->store_null();
- protocol->store_null();
-#endif
- }
-
- if (options & PROFILE_PAGE_FAULTS)
- {
-#ifdef HAVE_GETRUSAGE
- protocol->store((uint32)(rusage->ru_majflt - previous->rusage.ru_majflt));
- protocol->store((uint32)(rusage->ru_minflt - previous->rusage.ru_minflt));
-#else
- protocol->store_null();
- protocol->store_null();
-#endif
- }
-
- if (options & PROFILE_SWAPS)
- {
-#ifdef HAVE_GETRUSAGE
- protocol->store((uint32)(rusage->ru_nswap - previous->rusage.ru_nswap));
-#else
- protocol->store_null();
-#endif
- }
-
- if (options & PROFILE_SOURCE)
- {
- if ((entry->function != NULL) && (entry->file != NULL))
- {
- protocol->store(entry->function, strlen(entry->function),
- system_charset_info);
- protocol->store(entry->file, strlen(entry->file), system_charset_info);
- protocol->store((uint32) entry->line);
- } else {
- protocol->store_null();
- protocol->store_null();
- protocol->store_null();
- }
- }
-
- if (protocol->write())
- DBUG_RETURN(TRUE);
-
- previous= entry;
- }
- send_eof(thd);
- DBUG_RETURN(FALSE);
-}
-
PROFILING::PROFILING()
:profile_id_counter(1), keeping(TRUE), enabled(FALSE), current(NULL), last(NULL)
{
@@ -630,38 +474,11 @@ void PROFILING::set_query_source(char *query_source_arg, uint query_length_arg)
DBUG_VOID_RETURN;
}
-bool PROFILING::show(uint options, uint profiling_query_id)
-{
- DBUG_ENTER("PROFILING::show");
- QUERY_PROFILE *prof;
-
- void *iterator;
- for (iterator= history.new_iterator();
- iterator != NULL;
- iterator= history.iterator_next(iterator))
- {
- prof= history.iterator_value(iterator);
-
- if(prof->profiling_query_id == profiling_query_id)
- DBUG_RETURN(prof->show(options));
- }
-
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "SHOW PROFILE");
- DBUG_RETURN(TRUE);
-}
-
-bool PROFILING::show_last(uint options)
-{
- DBUG_ENTER("PROFILING::show_last");
- if (!history.is_empty()) {
- DBUG_RETURN(last->show(options));
- }
- DBUG_RETURN(TRUE);
-}
-
/**
Fill the information schema table, "query_profile", as defined in show.cc .
+ There are two ways to get to this function: Selecting from the information
+ schema, and a SHOW command.
*/
int PROFILING::fill_statistics_info(THD *thd, struct st_table_list *tables, Item *cond)
{
@@ -696,6 +513,31 @@ int PROFILING::fill_statistics_info(THD *thd, struct st_table_list *tables, Item
{
entry= query->entries.iterator_value(entry_iterator);
+ if (thd->lex->orig_sql_command == SQLCOM_SHOW_PROFILE)
+ {
+ /*
+ We got here via a SHOW command. That means that we stored
+ information about the query we wish to show and that isn't
+ in a WHERE clause at a higher level to filter out rows we
+ wish to exclude.
+
+ Because that functionality isn't available in the server yet,
+ we must filter here, at the wrong level. Once one can con-
+ struct where and having conditions at the SQL layer, then this
+ condition should be ripped out.
+ */
+ if (thd->lex->profile_query_id == 0) /* 0 == show final query */
+ {
+ if (query != last)
+ continue;
+ }
+ else
+ {
+ if (thd->lex->profile_query_id != query->profiling_query_id)
+ continue;
+ }
+ }
+
/* Set default values for this row. */
restore_record(table, s->default_values);
diff --git a/sql/sql_profile.h b/sql/sql_profile.h
index b82b5ce090c..56022de0dcc 100644
--- a/sql/sql_profile.h
+++ b/sql/sql_profile.h
@@ -39,6 +39,7 @@ extern const char * const _unknown_func_;
extern ST_FIELD_INFO query_profile_statistics_info[];
int fill_query_profile_statistics_info(THD *thd, struct st_table_list *tables, Item *cond);
+int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
#define PROFILE_NONE 0
@@ -332,12 +333,6 @@ public:
/* SHOW PROFILES */
bool show_profiles();
- /* SHOW PROFILE FOR QUERY query_id */
- bool show(uint options, uint profiling_query_id);
-
- /* SHOW PROFILE */
- bool show_last(uint options);
-
/* ... from INFORMATION_SCHEMA.PROFILING ... */
int fill_statistics_info(THD *thd, struct st_table_list *tables, Item *cond);
};
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index c59e2845c14..a26c3b41fcb 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4344,7 +4344,8 @@ ST_SCHEMA_TABLE schema_tables[]=
{"OPEN_TABLES", open_tables_fields_info, create_schema_table,
fill_open_tables, make_old_format, 0, -1, -1, 1},
{"PROFILING", query_profile_statistics_info, create_schema_table,
- fill_query_profile_statistics_info, NULL, NULL, -1, -1, false},
+ fill_query_profile_statistics_info, make_profile_table_for_show,
+ NULL, -1, -1, false},
{"ROUTINES", proc_fields_info, create_schema_table,
fill_schema_proc, make_proc_old_format, 0, -1, -1, 0},
{"SCHEMATA", schema_fields_info, create_schema_table,
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 54a6a6dc462..6cff3090da3 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -7044,7 +7044,13 @@ show_param:
| PROFILES_SYM
{ Lex->sql_command = SQLCOM_SHOW_PROFILES; }
| PROFILE_SYM opt_profile_defs opt_profile_args opt_limit_clause_init
- { Lex->sql_command = SQLCOM_SHOW_PROFILE; }
+ {
+ LEX *lex= Lex;
+ lex->sql_command= SQLCOM_SELECT;
+ lex->orig_sql_command= SQLCOM_SHOW_PROFILE;
+ if (prepare_schema_table(YYTHD, lex, NULL, SCH_PROFILES) != 0)
+ YYABORT;
+ }
| opt_var_type STATUS_SYM wild_and_where
{
LEX *lex= Lex;
diff --git a/sql/table.h b/sql/table.h
index 9dbdbeb7264..c982eb90cd5 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -320,7 +320,7 @@ enum enum_schema_tables
SCH_COLUMN_PRIVILEGES,
SCH_KEY_COLUMN_USAGE,
SCH_OPEN_TABLES,
- SCH_PROFILING,
+ SCH_PROFILES,
SCH_PROCEDURES,
SCH_SCHEMATA,
SCH_SCHEMA_PRIVILEGES,
From 22afbc0ab05e3184759b29112d6a4c04dc638509 Mon Sep 17 00:00:00 2001
From: "cmiller@zippy.cornsilk.net" <>
Date: Mon, 2 Jul 2007 12:29:07 -0400
Subject: [PATCH 09/14] Merge fix-up.
---
mysql-test/r/information_schema.result | 14 +++++++-------
win/mysql_manifest.cmake | 0
2 files changed, 7 insertions(+), 7 deletions(-)
mode change 100644 => 100755 win/mysql_manifest.cmake
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index aff0ba94f13..62b81ea260c 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -1319,6 +1319,13 @@ TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
TRIGGERS information_schema.TRIGGERS 1
USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
VIEWS information_schema.VIEWS 1
+show global status like "Uptime_%";
+Variable_name Value
+Uptime_since_flush_status #
+flush status;
+show global status like "Uptime_%";
+Variable_name Value
+Uptime_since_flush_status #
create table t1(f1 int);
create view v1 as select f1+1 as a from t1;
create table t2 (f1 int, f2 int);
@@ -1330,10 +1337,3 @@ v2 YES
delete from v1;
drop view v1,v2;
drop table t1,t2;
-show global status like "Uptime_%";
-Variable_name Value
-Uptime_since_flush_status #
-flush status;
-show global status like "Uptime_%";
-Variable_name Value
-Uptime_since_flush_status #
diff --git a/win/mysql_manifest.cmake b/win/mysql_manifest.cmake
old mode 100644
new mode 100755
From 0483091a8ce3cb566d495cdbd064d37f25828fed Mon Sep 17 00:00:00 2001
From: "cmiller@zippy.cornsilk.net" <>
Date: Tue, 3 Jul 2007 11:25:32 -0400
Subject: [PATCH 10/14] Avoid a warning on windows about a missing case enum.
---
sql/sql_parse.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 9b0fce13678..17ae8fee0ea 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5502,6 +5502,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table)
case SCH_COLUMN_PRIVILEGES:
case SCH_TABLE_CONSTRAINTS:
case SCH_KEY_COLUMN_USAGE:
+ case SCH_PROFILES:
break;
}
From da78d3b7a3a244ea50e294502561bcea7b369101 Mon Sep 17 00:00:00 2001
From: "cmiller@zippy.cornsilk.net" <>
Date: Tue, 3 Jul 2007 12:20:19 -0400
Subject: [PATCH 11/14] In 5.0, Field_double::val_str uses "%g" to render
floating point numbers, which uses "X.YeZ" notation when the exponent Z would
be less than -4. That behavior at -4 is not exactly what we want, and our
Decimal type offers smarter number representation. By changing profiling to
use Decimal types, we get more readable output.
---
sql/sql_profile.cc | 35 +++++++++++++++++++++++++----------
sql/sql_show.cc | 11 +++++++++--
2 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index fbb05a988c5..d4e3568f592 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -44,9 +44,9 @@ ST_FIELD_INFO query_profile_statistics_info[]=
{"QUERY_ID", 20, MYSQL_TYPE_LONG, 0, false, "Query_id"},
{"SEQ", 20, MYSQL_TYPE_LONG, 0, false, "Seq"},
{"STATE", 30, MYSQL_TYPE_STRING, 0, false, "Status"},
- {"DURATION", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, false, "Duration"},
- {"CPU_USER", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, "CPU_user"},
- {"CPU_SYSTEM", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, "CPU_system"},
+ {"DURATION", TIME_FLOAT_DIGITS, MYSQL_TYPE_DECIMAL, 0, false, "Duration"},
+ {"CPU_USER", TIME_FLOAT_DIGITS, MYSQL_TYPE_DECIMAL, 0, true, "CPU_user"},
+ {"CPU_SYSTEM", TIME_FLOAT_DIGITS, MYSQL_TYPE_DECIMAL, 0, true, "CPU_system"},
{"CONTEXT_VOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, "Context_voluntary"},
{"CONTEXT_INVOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, "Context_involuntary"},
{"BLOCK_OPS_IN", 20, MYSQL_TYPE_LONG, 0, true, "Block_ops_in"},
@@ -557,16 +557,31 @@ int PROFILING::fill_statistics_info(THD *thd, struct st_table_list *tables, Item
*/
table->field[2]->store(previous->status, strlen(previous->status),
system_charset_info);
- table->field[3]->store((double)(entry->time_usecs -
- previous->time_usecs)/(1000*1000));
+
+ my_decimal duration;
+ double2my_decimal(E_DEC_FATAL_ERROR,
+ (entry->time_usecs-previous->time_usecs)/(1000.0*1000),
+ &duration);
+ table->field[3]->store_decimal(&duration);
#ifdef HAVE_GETRUSAGE
- table->field[4]->store((double)RUSAGE_DIFF_USEC(entry->rusage.ru_utime,
- previous->rusage.ru_utime)/(1000.0*1000));
- table->field[4]->set_notnull();
- table->field[5]->store((double)RUSAGE_DIFF_USEC(entry->rusage.ru_stime,
- previous->rusage.ru_stime)/(1000.0*1000));
+ my_decimal cpu_utime, cpu_stime;
+ double2my_decimal(E_DEC_FATAL_ERROR,
+ RUSAGE_DIFF_USEC(entry->rusage.ru_utime,
+ previous->rusage.ru_utime) /
+ (1000.0*1000),
+ &cpu_utime);
+
+ double2my_decimal(E_DEC_FATAL_ERROR,
+ RUSAGE_DIFF_USEC(entry->rusage.ru_stime,
+ previous->rusage.ru_stime) /
+ (1000.0*1000),
+ &cpu_stime);
+
+ table->field[4]->store_decimal(&cpu_utime);
+ table->field[5]->store_decimal(&cpu_stime);
+ table->field[4]->set_notnull();
table->field[5]->set_notnull();
#else
/* TODO: Add CPU-usage info for non-BSD systems */
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index d37fb3fb6a9..e1e332ff03d 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3657,11 +3657,18 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
fields_info->field_length)) == NULL)
DBUG_RETURN(NULL);
break;
+ case MYSQL_TYPE_DECIMAL:
+ case MYSQL_TYPE_STRING:
default:
/* Don't let unimplemented types pass through. Could be a grave error. */
- DBUG_ASSERT(fields_info->field_type == MYSQL_TYPE_STRING);
+ DBUG_ASSERT(fields_info->field_type == MYSQL_TYPE_STRING ||
+ fields_info->field_type == MYSQL_TYPE_DECIMAL);
- /* this should be changed when Item_empty_string is fixed(in 4.1) */
+ /**
+ @todo Change when Item_empty_string is fixed (in 4.1). [Presumably,
+ this means removing the first of two steps: setting a useless, bogus
+ value; and then setting the attributes.]
+ */
if (!(item= new Item_empty_string("", 0, cs)))
{
DBUG_RETURN(0);
From 71d5c5350aadc7312a917e2c0b87a8d271432f40 Mon Sep 17 00:00:00 2001
From: "cmiller@zippy.cornsilk.net" <>
Date: Thu, 4 Oct 2007 10:35:09 -0400
Subject: [PATCH 12/14] Track typedef'd struct. Name changed in Enterprise
tree, but community-exclusive file also referred to struct.
---
sql/sql_profile.cc | 4 ++--
sql/sql_profile.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index d4e3568f592..30bedcfc813 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -28,7 +28,7 @@ const char * const _unknown_func_ = "";
/**
Connects Information_Schema and Profiling.
*/
-int fill_query_profile_statistics_info(THD *thd, struct st_table_list *tables,
+int fill_query_profile_statistics_info(THD *thd, TABLE_LIST *tables,
Item *cond)
{
#ifdef ENABLED_PROFILING
@@ -480,7 +480,7 @@ void PROFILING::set_query_source(char *query_source_arg, uint query_length_arg)
There are two ways to get to this function: Selecting from the information
schema, and a SHOW command.
*/
-int PROFILING::fill_statistics_info(THD *thd, struct st_table_list *tables, Item *cond)
+int PROFILING::fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond)
{
DBUG_ENTER("PROFILING::fill_statistics_info");
TABLE *table= tables->table;
diff --git a/sql/sql_profile.h b/sql/sql_profile.h
index 56022de0dcc..5a28bc32442 100644
--- a/sql/sql_profile.h
+++ b/sql/sql_profile.h
@@ -38,7 +38,7 @@ extern const char * const _unknown_func_;
#endif
extern ST_FIELD_INFO query_profile_statistics_info[];
-int fill_query_profile_statistics_info(THD *thd, struct st_table_list *tables, Item *cond);
+int fill_query_profile_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
@@ -334,7 +334,7 @@ public:
bool show_profiles();
/* ... from INFORMATION_SCHEMA.PROFILING ... */
- int fill_statistics_info(THD *thd, struct st_table_list *tables, Item *cond);
+ int fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
};
# endif /* HAVE_PROFILING */
From af8fe98cfcfd39a37298bd04a967c5705ef208b0 Mon Sep 17 00:00:00 2001
From: "cmiller@zippy.cornsilk.net" <>
Date: Wed, 10 Oct 2007 08:19:01 -0400
Subject: [PATCH 13/14] Bug#27433: Parser error for MySQL 5.0.37 with Bison
1.75 for \ sql_yacc.yy
Yacc rules lacked semicolons to terminate rules, which is illegal in
old versions of bison.
Added semicolons.
---
sql/sql_yacc.yy | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 21eb7cbc14c..9952cc7e659 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -6900,11 +6900,11 @@ opt_table_sym:
opt_profile_defs:
/* empty */
- | profile_defs
+ | profile_defs;
profile_defs:
profile_def
- | profile_defs ',' profile_def
+ | profile_defs ',' profile_def;
profile_def:
CPU_SYM
From 8d836dd38a847fbe1c21986dae97faaf5ef83dd5 Mon Sep 17 00:00:00 2001
From: "cmiller@zippy.cornsilk.net" <>
Date: Wed, 31 Oct 2007 12:29:32 -0400
Subject: [PATCH 14/14] Push history-limiting code until after the code that
adds new history entries. Lazy deletion isn't smart or useful here.
---
sql/sql_profile.cc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index 30bedcfc813..1ef7363c3a8 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -338,9 +338,6 @@ void PROFILING::store()
DBUG_VOID_RETURN;
}
- while (history.elements > thd->variables.profiling_history_size)
- delete history.pop();
-
if (likely(((thd)->options & OPTION_PROFILING) == 0))
DBUG_VOID_RETURN;
@@ -370,6 +367,9 @@ void PROFILING::store()
if (enabled)
current= new QUERY_PROFILE(this, thd->query, thd->query_length);
+ while (history.elements > thd->variables.profiling_history_size)
+ delete history.pop();
+
DBUG_VOID_RETURN;
}