summaryrefslogtreecommitdiff
path: root/libmysqld
diff options
context:
space:
mode:
Diffstat (limited to 'libmysqld')
-rw-r--r--libmysqld/CMakeLists.txt248
-rw-r--r--libmysqld/Makefile.am144
-rw-r--r--libmysqld/emb_qcache.cc12
-rw-r--r--libmysqld/emb_qcache.h6
-rw-r--r--libmysqld/embedded_priv.h4
-rw-r--r--libmysqld/examples/CMakeLists.txt51
-rw-r--r--libmysqld/examples/Makefile.am54
-rw-r--r--libmysqld/examples/builder-sample/emb_sample.bpr16
-rw-r--r--libmysqld/examples/builder-sample/emb_sample.cpp16
-rw-r--r--libmysqld/examples/builder-sample/emb_samples.cpp16
-rw-r--r--libmysqld/examples/builder-sample/emb_samples.h16
-rwxr-xr-xlibmysqld/examples/test-run15
-rw-r--r--libmysqld/lib_sql.cc147
-rw-r--r--libmysqld/libmysqld.c37
-rw-r--r--libmysqld/libmysqld.def4
15 files changed, 361 insertions, 425 deletions
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index c751c5fa8c0..14db8327897 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 MySQL AB
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -11,101 +11,41 @@
#
# 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
-
-
-# Need to set USE_TLS, since __declspec(thread) approach to thread local
-# storage does not work properly in DLLs.
-IF(WIN32)
- ADD_DEFINITIONS(-DUSE_TLS)
-ENDIF(WIN32)
-
-ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY -DHAVE_DLOPEN)
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
- ${CMAKE_SOURCE_DIR}/libmysqld
- ${CMAKE_SOURCE_DIR}/libmysql
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/extra/yassl/include
- ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_BINARY_DIR}/sql)
-
-SET(GEN_SOURCES ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
- ${CMAKE_BINARY_DIR}/sql/sql_yacc.h
- ${CMAKE_SOURCE_DIR}/sql/message.h
- ${CMAKE_SOURCE_DIR}/sql/message.rc
- ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
- ${CMAKE_BINARY_DIR}/sql/lex_hash.h)
-
-SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED 1)
-
-# Include and add the directory path
-SET(SOURCE_SUBLIBS TRUE)
-SET(LIB_SOURCES "")
-
-INCLUDE(${CMAKE_SOURCE_DIR}/zlib/CMakeLists.txt)
-FOREACH(rpath ${ZLIB_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../zlib/${rpath})
-ENDFOREACH(rpath)
-
-# FIXME only needed if build type is "Debug", but CMAKE_BUILD_TYPE is
-# not set during configure time.
-INCLUDE(${CMAKE_SOURCE_DIR}/dbug/CMakeLists.txt)
-FOREACH(rpath ${DBUG_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../dbug/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/CMakeLists.txt)
-FOREACH(rpath ${TAOCRYPT_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../extra/yassl/taocrypt/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/extra/yassl/CMakeLists.txt)
-FOREACH(rpath ${YASSL_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../extra/yassl/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/strings/CMakeLists.txt)
-FOREACH(rpath ${STRINGS_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../strings/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/regex/CMakeLists.txt)
-FOREACH(rpath ${REGEX_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../regex/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/mysys/CMakeLists.txt)
-FOREACH(rpath ${MYSYS_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../mysys/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/vio/CMakeLists.txt)
-FOREACH(rpath ${VIO_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../vio/${rpath})
-ENDFOREACH(rpath)
-
-FOREACH (ENGINE_LIB ${MYSQLD_STATIC_ENGINE_LIBS})
- INCLUDE(${CMAKE_SOURCE_DIR}/storage/${plugin_dir_${ENGINE_LIB}}/CMakeLists.txt)
- STRING(TOUPPER ${ENGINE_LIB} ENGINE_LIB_UPPER)
- SET(ENGINE_DIR ${${ENGINE_LIB_UPPER}_DIR})
- INCLUDE(${CMAKE_SOURCE_DIR}/storage/${ENGINE_DIR}/CMakeLists.txt)
- FOREACH(rpath ${${ENGINE_LIB_UPPER}_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ${CMAKE_SOURCE_DIR}/storage/${ENGINE_DIR}/${rpath})
- ENDFOREACH(rpath)
-ENDFOREACH(ENGINE_LIB)
-
-SET(SOURCE_SUBLIBS FALSE)
-
-SET(LIBMYSQLD_SOURCES libmysqld.c emb_qcache.cc lib_sql.cc
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY
+ ${SSL_DEFINES})
+
+INCLUDE_DIRECTORIES(
+${CMAKE_SOURCE_DIR}/include
+${CMAKE_SOURCE_DIR}/libmysql
+${CMAKE_SOURCE_DIR}/libmysqld
+${CMAKE_SOURCE_DIR}/sql
+${CMAKE_BINARY_DIR}/sql
+${CMAKE_SOURCE_DIR}/regex
+${ZLIB_INCLUDE_DIR}
+${SSL_INCLUDE_DIRS}
+${SSL_INTERNAL_INCLUDE_DIRS}
+${CMAKE_SOURCE_DIR}/sql/backup
+)
+
+SET(GEN_SOURCES
+${CMAKE_BINARY_DIR}/sql/sql_yacc.h
+${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
+${CMAKE_BINARY_DIR}/sql/lex_hash.h
+)
+
+SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED TRUE)
+
+SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../libmysql/libmysql.c ../libmysql/errmsg.c ../client/get_password.c
../sql-common/client.c ../sql-common/my_time.c
../sql-common/my_user.c ../sql-common/pack.c
+ ../sql-common/client_plugin.c ../sql-common/mysql_async.c
../sql/password.c ../sql/discover.cc ../sql/derror.cc
- ../sql/field.cc ../sql/field_conv.cc ../sql-common/client_plugin.c
- ../sql-common/mysql_async.c
- ../sql/filesort.cc ../sql/gstream.cc ../sql/ha_partition.cc
+ ../sql/field.cc ../sql/field_conv.cc
+ ../sql/filesort.cc ../sql/gstream.cc ../sql/slave.cc
+ ../sql/signal_handler.cc
../sql/handler.cc ../sql/hash_filo.cc ../sql/hostname.cc
../sql/init.cc ../sql/item_buff.cc ../sql/item_cmpfunc.cc
../sql/item.cc ../sql/item_create.cc ../sql/item_func.cc
@@ -114,10 +54,9 @@ SET(LIBMYSQLD_SOURCES libmysqld.c emb_qcache.cc lib_sql.cc
../sql/item_xmlfunc.cc ../sql/key.cc ../sql/lock.cc ../sql/log.cc
../sql/log_event.cc ../sql/mf_iocache.cc ../sql/my_decimal.cc
../sql/net_serv.cc ../sql/opt_range.cc ../sql/opt_sum.cc
- ../sql/opt_table_elimination.cc
../sql/parse_file.cc ../sql/procedure.cc ../sql/protocol.cc
../sql/records.cc ../sql/repl_failsafe.cc ../sql/rpl_filter.cc
- ../sql/rpl_record.cc
+ ../sql/rpl_record.cc ../sql/sha2.cc ../sql/des_key_file.cc
../sql/rpl_injector.cc ../sql/set_var.cc ../sql/spatial.cc
../sql/sp_cache.cc ../sql/sp.cc ../sql/sp_head.cc
../sql/sp_pcontext.cc ../sql/sp_rcontext.cc ../sql/sql_acl.cc
@@ -125,53 +64,104 @@ SET(LIBMYSQLD_SOURCES libmysqld.c emb_qcache.cc lib_sql.cc
../sql/sql_class.cc ../sql/sql_crypt.cc ../sql/sql_cursor.cc
../sql/sql_db.cc ../sql/sql_delete.cc ../sql/sql_derived.cc
../sql/sql_do.cc ../sql/sql_error.cc ../sql/sql_handler.cc
- ../sql/sql_help.cc ../sql/sql_insert.cc ../sql/sql_lex.cc
+ ../sql/sql_help.cc ../sql/sql_insert.cc ../sql/datadict.cc
+ ../sql/sql_admin.cc ../sql/sql_truncate.cc ../sql/sql_reload.cc
+ ../sql/sql_lex.cc ../sql/keycaches.cc
../sql/sql_list.cc ../sql/sql_load.cc ../sql/sql_locale.cc
- ../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_map.cc
+ ../sql/sql_binlog.cc ../sql/sql_manager.cc
../sql/sql_parse.cc ../sql/sql_partition.cc ../sql/sql_plugin.cc
- ../sql/debug_sync.cc
+ ../sql/debug_sync.cc ../sql/opt_table_elimination.cc
../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc
../sql/sql_select.cc ../sql/sql_servers.cc
../sql/sql_show.cc ../sql/sql_state.c ../sql/sql_string.cc
../sql/sql_tablespace.cc ../sql/sql_table.cc ../sql/sql_test.cc
../sql/sql_trigger.cc ../sql/sql_udf.cc ../sql/sql_union.cc
../sql/sql_update.cc ../sql/sql_view.cc ../sql/sql_profile.cc
+ ../sql/gcalc_tools.cc ../sql/gcalc_slicescan.cc
../sql/strfunc.cc ../sql/table.cc ../sql/thr_malloc.cc
- ../sql/time.cc ../sql/tztime.cc ../sql/uniques.cc ../sql/unireg.cc
+ ../sql/sql_time.cc ../sql/tztime.cc ../sql/uniques.cc ../sql/unireg.cc
../sql/partition_info.cc ../sql/sql_connect.cc
- ../sql/scheduler.cc ../sql/event_parse_data.cc
- ../sql/create_options.cc
+ ../sql/scheduler.cc ../sql/sql_audit.cc
+ ../sql/sql_alter.cc ../sql/sql_partition_admin.cc
+ ../sql/event_parse_data.cc
+ ../sql/sql_signal.cc ../sql/rpl_handler.cc
+ ../sql/sys_vars.cc
+ ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
+ ../sql/mdl.cc ../sql/transaction.cc
+ ../sql/sql_join_cache.cc
+ ../sql/multi_range_read.cc
+ ../sql/opt_index_cond_pushdown.cc
+ ../sql/opt_subselect.cc
+ ../sql/create_options.cc ../sql/rpl_utility.cc
+ ../sql/rpl_reporting.cc
+ ../sql/sql_expression_cache.cc
${GEN_SOURCES}
- ${LIB_SOURCES})
-
-# Seems we cannot make a library without at least one source file. So use a
-# dummy empty file
-FILE(WRITE cmake_dummy.c " ")
-
-# Tried use the correct ${GEN_SOURCES} as dependency, worked on Unix
-# but not on Windows and Visual Studio generators. Likely because they
-# are no real targets from the Visual Studio project files view. Added
-# custom targets to "sql/CMakeLists.txt" and reference them here.
-ADD_LIBRARY(mysqlserver STATIC ${LIBMYSQLD_SOURCES})
-ADD_DEPENDENCIES(mysqlserver GenServerSource GenError)
-TARGET_LINK_LIBRARIES(mysqlserver psapi.lib)
-
-IF(MSVC AND CMAKE_SIZEOF_VOID_P MATCHES 8)
- # Workaround cmake bug http://www.vtk.org/Bug/view.php?id=11240
- SET_TARGET_PROPERTIES(mysqlserver PROPERTIES STATIC_LIBRARY_FLAGS
- "/MACHINE:AMD64")
+ ${MYSYS_LIBWRAP_SOURCE}
+)
+
+
+ADD_CONVENIENCE_LIBRARY(sql_embedded ${SQL_EMBEDDED_SOURCES})
+DTRACE_INSTRUMENT(sql_embedded)
+ADD_DEPENDENCIES(sql_embedded GenError GenServerSource)
+
+# On Windows, static embedded server library is called mysqlserver.lib
+# On Unix, it is libmysqld.a
+IF(WIN32)
+ SET(MYSQLSERVER_OUTPUT_NAME mysqlserver)
+ELSE()
+ SET(MYSQLSERVER_OUTPUT_NAME mysqld)
+ENDIF()
+
+
+SET(LIBS
+ dbug strings regex mysys vio
+ ${ZLIB_LIBRARY} ${SSL_LIBRARIES}
+ ${LIBWRAP} ${LIBCRYPT} ${LIBDL}
+ ${MYSQLD_STATIC_PLUGIN_LIBS}
+ sql_embedded
+)
+
+# Some storage engine were compiled for embedded specifically
+# (with corresponding target ${engine}_embedded)
+SET(EMBEDDED_LIBS)
+FOREACH(LIB ${LIBS})
+ GET_TARGET_PROPERTY(EMBEDDED_LOCATION ${LIB}_embedded LOCATION)
+ IF(EMBEDDED_LOCATION)
+ LIST(APPEND EMBEDDED_LIBS ${LIB}_embedded)
+ ELSE()
+ LIST(APPEND EMBEDDED_LIBS ${LIB})
+ ENDIF()
+ENDFOREACH()
+
+MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS}
+ OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT Embedded)
+
+# Visual Studio users need debug static library
+IF(MSVC)
+ INSTALL_DEBUG_TARGET(mysqlserver DESTINATION ${INSTALL_LIBDIR}/debug)
ENDIF()
-# Add any additional libraries requested by engine(s)
-FOREACH (ENGINE_LIB ${MYSQLD_STATIC_ENGINE_LIBS})
- STRING(TOUPPER ${ENGINE_LIB} ENGINE_LIB_UPPER)
- IF(${ENGINE_LIB_UPPER}_LIBS)
- TARGET_LINK_LIBRARIES(mysqlserver ${${ENGINE_LIB_UPPER}_LIBS})
- ENDIF(${ENGINE_LIB_UPPER}_LIBS)
-ENDFOREACH(ENGINE_LIB)
+IF(UNIX)
+ INSTALL_DEBUG_TARGET(mysqlserver DESTINATION ${INSTALL_LIBDIR} RENAME
+ ${CMAKE_STATIC_LIBRARY_PREFIX}mysqld-debug)
+ENDIF()
-ADD_LIBRARY(libmysqld SHARED cmake_dummy.c libmysqld.def)
-ADD_DEPENDENCIES(libmysqld mysqlserver)
-TARGET_LINK_LIBRARIES(libmysqld mysqlserver wsock32)
+IF(NOT DISABLE_SHARED)
+ MERGE_LIBRARIES(libmysqld SHARED mysqlserver EXPORTS ${CLIENT_API_FUNCTIONS}
+ COMPONENT Embedded)
+ IF(UNIX)
+ # Name the shared library, handle versioning (provides same api as client
+ # library hence the same version)
+ SET_TARGET_PROPERTIES(libmysqld PROPERTIES
+ OUTPUT_NAME mysqld
+ SOVERSION "${SHARED_LIB_MAJOR_VERSION}")
+ # Clean direct output flags, as 2 targets have the same base name
+ # libmysqld
+ SET_TARGET_PROPERTIES(libmysqld PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+ SET_TARGET_PROPERTIES(mysqlserver PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+ IF(LIBMYSQLD_SO_EXTRA_LIBS)
+ TARGET_LINK_LIBRARIES(libmysqld ${LIBMYSQLD_SO_EXTRA_LIBS})
+ ENDIF()
+ ENDIF()
+ENDIF()
-MYSQL_INSTALL_TARGETS(mysqlserver libmysqld DESTINATION lib COMPONENT Embedded)
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
deleted file mode 100644
index 926b339003d..00000000000
--- a/libmysqld/Makefile.am
+++ /dev/null
@@ -1,144 +0,0 @@
-# Copyright (C) 2001-2006 MySQL AB
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; version 2
-# of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with this library; if not, write to the Free
-# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-# MA 02111-1307, USA
-#
-# This file is public domain and comes with NO WARRANTY of any kind
-
-MYSQLDATAdir = $(localstatedir)
-MYSQLSHAREdir = $(pkgdatadir)
-MYSQLBASEdir= $(prefix)
-MYSQLLIBdir= $(libdir)
-pkgplugindir = $(pkglibdir)/plugin
-
-EXTRA_DIST = libmysqld.def CMakeLists.txt
-DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
- -DDEFAULT_MYSQL_HOME='"$(MYSQLBASEdir)"' \
- -DMYSQL_DATADIR='"$(MYSQLDATAdir)"' \
- -DSHAREDIR='"$(MYSQLSHAREdir)"' \
- -DPLUGINDIR='"$(pkgplugindir)"'
-INCLUDES= -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_builddir)/sql -I$(top_srcdir)/sql \
- -I$(top_srcdir)/sql/examples \
- -I$(top_srcdir)/regex \
- $(openssl_includes) @ZLIB_INCLUDES@ \
- @condition_dependent_plugin_includes@ \
- @ndbcluster_includes@
-
-pkglib_LTLIBRARIES = libmysqld.la
-SUBDIRS = . examples
-libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
-libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
- my_time.c client_plugin.c mysql_async.c
-
-noinst_HEADERS = embedded_priv.h emb_qcache.h
-
-sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
- ha_ndbcluster.cc ha_ndbcluster_cond.cc \
- ha_ndbcluster_binlog.cc ha_partition.cc \
- handler.cc sql_handler.cc \
- hostname.cc init.cc password.c \
- item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
- item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
- item_geofunc.cc item_subselect.cc item_row.cc\
- item_xmlfunc.cc \
- key.cc lock.cc log.cc sql_state.c \
- log_event.cc rpl_record.cc \
- log_event_old.cc rpl_record_old.cc \
- protocol.cc net_serv.cc opt_range.cc \
- opt_sum.cc procedure.cc records.cc sql_acl.cc \
- sql_load.cc discover.cc sql_locale.cc \
- sql_profile.cc \
- sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
- sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \
- sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc \
- scheduler.cc sql_connect.cc sql_parse.cc \
- sql_prepare.cc sql_derived.cc sql_rename.cc \
- sql_select.cc sql_do.cc sql_show.cc set_var.cc \
- sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \
- sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
- unireg.cc uniques.cc sql_union.cc hash_filo.cc \
- spatial.cc gstream.cc sql_help.cc tztime.cc sql_cursor.cc \
- sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
- parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
- rpl_filter.cc sql_partition.cc sql_builtin.cc sql_plugin.cc \
- debug_sync.cc \
- sql_tablespace.cc create_options.cc \
- rpl_injector.cc my_user.c partition_info.cc \
- sql_servers.cc event_parse_data.cc opt_table_elimination.cc
-
-# automake misses these
-sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
-# The following libraries should be included in libmysqld.a
-INC_LIB= $(top_builddir)/regex/libregex.la \
- $(top_builddir)/mysys/libmysys.la \
- $(top_builddir)/strings/libmystrings.la \
- $(top_builddir)/dbug/libdbug.la \
- $(top_builddir)/vio/libvio.la \
- @ndbcluster_libs@ @NDB_SCI_LIBS@ \
- @mysql_embedded_plugin_libs@ \
- $(libevent_inc_libs) \
- $(yassl_inc_libs)
-
-if HAVE_YASSL
-yassl_inc_libs= $(top_builddir)/extra/yassl/src/libyassl.la \
- $(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la
-endif
-
-libmysqld_la_SOURCES= $(libmysqld_sources)
-nodist_libmysqld_la_SOURCES= $(libmysqlsources) $(sqlsources)
-libmysqld_la_LIBADD = $(INC_LIB)
-
-## XXX: any time the client interface changes, we'll need to bump
-## the version info for libmysqld; however, it's possible for the
-## libmysqld interface to change without affecting the standard
-## libmysqlclient interface. Should we make a separate version
-## string for the two?
-#libmysqld_la_LDFLAGS = -version-info @SHARED_LIB_VERSION@
-#CLEANFILES = libmysqld.la
-
-BUILT_SOURCES = link_sources
-
-CLEANFILES = $(BUILT_SOURCES)
-
-link_sources:
- for f in $(sqlsources); do \
- rm -f $$f; \
- if test -e $(top_srcdir)/sql/$$f ; \
- then \
- @LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
- else \
- @LN_CP_F@ $(top_builddir)/sql/$$f $$f; \
- fi ; \
- done; \
- for f in $(libmysqlsources); do \
- rm -f $$f; \
- if test -e $(top_srcdir)/libmysql/$$f ; \
- then \
- @LN_CP_F@ $(top_srcdir)/libmysql/$$f $$f; \
- else \
- @LN_CP_F@ $(top_builddir)/libmysql/$$f $$f; \
- fi ; \
- done; \
- rm -f client_settings.h; \
- @LN_CP_F@ $(top_srcdir)/libmysql/client_settings.h \
- client_settings.h; \
- echo timestamp > link_sources
-
-
-clean-local:
- rm -f `echo $(sqlsources) $(libmysqlsources) | sed "s;\.lo;.c;g"`; \
- rm -f client_settings.h
diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc
index b4eddf39c1f..d263e5d5fe8 100644
--- a/libmysqld/emb_qcache.cc
+++ b/libmysqld/emb_qcache.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2003 MySQL AB
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -11,13 +11,16 @@
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#include "sql_priv.h"
+#include "my_global.h" // HAVE_*
-#include "mysql_priv.h"
#ifdef HAVE_QUERY_CACHE
#include <mysql.h>
#include "emb_qcache.h"
#include "embedded_priv.h"
+#include "sql_class.h" // THD
void Querycache_stream::store_uchar(uchar c)
{
@@ -483,7 +486,8 @@ int emb_load_querycache_result(THD *thd, Querycache_stream *src)
*prev_row= NULL;
data->embedded_info->prev_ptr= prev_row;
return_ok:
- net_send_eof(thd, thd->server_status, thd->total_warn_count);
+ net_send_eof(thd, thd->server_status,
+ thd->warning_info->statement_warn_count());
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
diff --git a/libmysqld/emb_qcache.h b/libmysqld/emb_qcache.h
index ecf91487667..8fd166df88d 100644
--- a/libmysqld/emb_qcache.h
+++ b/libmysqld/emb_qcache.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2005 MySQL AB
+/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -11,7 +11,9 @@
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#include "sql_cache.h" /* Query_cache_block */
class Querycache_stream
{
diff --git a/libmysqld/embedded_priv.h b/libmysqld/embedded_priv.h
index c246693594b..c096954a460 100644
--- a/libmysqld/embedded_priv.h
+++ b/libmysqld/embedded_priv.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2004, 2006 MySQL AB
+/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -11,7 +11,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/* Prototypes for the embedded version of MySQL */
diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt
index 1f41d608099..3d67083acc9 100644
--- a/libmysqld/examples/CMakeLists.txt
+++ b/libmysqld/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 MySQL AB
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -11,32 +11,49 @@
#
# 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
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/libmysqld/include
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+ ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/sql
+ ${MY_READLINE_INCLUDE_DIR}
+ )
-# Currently does not work with DBUG, there are missing symbols reported.
-IF(WIN32)
- ADD_DEFINITIONS(-DUSE_TLS)
-ENDIF(WIN32)
-ADD_DEFINITIONS(-DEMBEDDED_LIBRARY)
+ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -UMYSQL_CLIENT)
MYSQL_ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
- ../../client/mysql.cc ../../client/readline.cc
- COMPONENT Test)
-TARGET_LINK_LIBRARIES(mysql_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
+ ../../client/mysql.cc ../../client/readline.cc)
TARGET_LINK_LIBRARIES(mysql_embedded mysqlserver)
+IF(UNIX)
+ TARGET_LINK_LIBRARIES(mysql_embedded ${MY_READLINE_LIBRARY})
+ENDIF(UNIX)
-MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc COMPONENT Test)
-TARGET_LINK_LIBRARIES(mysqltest_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
+MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc)
TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver)
-MYSQL_ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c COMPONENT Test)
-TARGET_LINK_LIBRARIES(mysql_client_test_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
+IF(CMAKE_GENERATOR MATCHES "Xcode")
+# It does not seem possible to tell Xcode the resulting target might need
+# to be linked with C++ runtime. The project needs to have at least one C++
+# file. Add a dummy one.
+ ADD_CUSTOM_COMMAND(OUTPUT
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql_client_test_embedded_dummy.cc
+ COMMAND ${CMAKE_COMMAND} -E touch
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql_client_test_embedded_dummy.cc
+ )
+ MYSQL_ADD_EXECUTABLE(mysql_client_test_embedded
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql_client_test_embedded_dummy.cc
+ ../../tests/mysql_client_test.c)
+ELSE()
+ MYSQL_ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c)
+ SET_TARGET_PROPERTIES(mysql_client_test_embedded PROPERTIES HAS_CXX TRUE)
+ENDIF()
TARGET_LINK_LIBRARIES(mysql_client_test_embedded mysqlserver)
+
+IF(UNIX)
+SET_TARGET_PROPERTIES(mysql_embedded PROPERTIES ENABLE_EXPORTS TRUE)
+SET_TARGET_PROPERTIES(mysqltest_embedded PROPERTIES ENABLE_EXPORTS TRUE)
+SET_TARGET_PROPERTIES(mysql_client_test_embedded PROPERTIES ENABLE_EXPORTS TRUE)
+ENDIF()
diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am
deleted file mode 100644
index a5ed182507a..00000000000
--- a/libmysqld/examples/Makefile.am
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (C) 2000 MySQL AB
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-noinst_PROGRAMS = mysql
-bin_PROGRAMS = mysqltest_embedded mysql_client_test_embedded
-client_sources = $(nodist_mysqltest_embedded_SOURCES) $(nodist_mysql_SOURCES)
-tests_sources = $(nodist_mysql_client_test_embedded_SOURCES)
-BUILT_SOURCES = link_sources
-CLEANFILES = $(client_sources) $(tests_sources) $(BUILT_SOURCES)
-EXTRA_DIST = CMakeLists.txt
-
-link_sources:
- for f in $(client_sources); do \
- rm -f $$f; \
- @LN_CP_F@ $(top_srcdir)/client/$$f $$f; \
- done; \
- for f in $(tests_sources); do \
- rm -f $$f; \
- @LN_CP_F@ $(top_srcdir)/tests/$$f $$f; \
- done
- echo timestamp > link_sources
-
-DEFS = -DEMBEDDED_LIBRARY
-INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir) \
- -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
-LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
-LDADD = @CLIENT_EXTRA_LDFLAGS@ \
- $(top_builddir)/libmysqld/libmysqld.la @LIBDL@ $(CXXLDFLAGS) \
- @ndbcluster_libs@ @NDB_SCI_LIBS@
-
-mysqltest_embedded_LINK = $(CXXLINK)
-nodist_mysqltest_embedded_SOURCES = mysqltest.cc
-mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.la \
- @MYSQLD_EXTRA_LDFLAGS@
-
-nodist_mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
- my_readline.h sql_string.h completion_hash.h
-mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD)
-
-mysql_client_test_embedded_LINK = $(CXXLINK)
-nodist_mysql_client_test_embedded_SOURCES = mysql_client_test.c
diff --git a/libmysqld/examples/builder-sample/emb_sample.bpr b/libmysqld/examples/builder-sample/emb_sample.bpr
index 07b39a6832b..100e5b98dfd 100644
--- a/libmysqld/examples/builder-sample/emb_sample.bpr
+++ b/libmysqld/examples/builder-sample/emb_sample.bpr
@@ -1,3 +1,19 @@
+# Copyright (c) 2002 MySQL AB
+# Use is subject to license terms.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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
+
# ---------------------------------------------------------------------------
!if !$d(BCB)
BCB = $(MAKEDIR)\..
diff --git a/libmysqld/examples/builder-sample/emb_sample.cpp b/libmysqld/examples/builder-sample/emb_sample.cpp
index 5ad3bd69319..0c8f4fa0598 100644
--- a/libmysqld/examples/builder-sample/emb_sample.cpp
+++ b/libmysqld/examples/builder-sample/emb_sample.cpp
@@ -1,3 +1,19 @@
+// Copyright (c) 2002 MySQL AB
+// Use is subject to license terms.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 <vcl.h>
#pragma hdrstop
diff --git a/libmysqld/examples/builder-sample/emb_samples.cpp b/libmysqld/examples/builder-sample/emb_samples.cpp
index be3f1931af5..aab1385f6e6 100644
--- a/libmysqld/examples/builder-sample/emb_samples.cpp
+++ b/libmysqld/examples/builder-sample/emb_samples.cpp
@@ -1,3 +1,19 @@
+// Copyright (c) 2002, 2004, 2007 MySQL AB
+// Use is subject to license terms.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 <vcl.h>
#pragma hdrstop
diff --git a/libmysqld/examples/builder-sample/emb_samples.h b/libmysqld/examples/builder-sample/emb_samples.h
index 0562bc783cd..3024e75d533 100644
--- a/libmysqld/examples/builder-sample/emb_samples.h
+++ b/libmysqld/examples/builder-sample/emb_samples.h
@@ -1,3 +1,19 @@
+// Copyright (c) 2002 MySQL AB
+// Use is subject to license terms.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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
+
//---------------------------------------------------------------------------
#ifndef emb_samplesH
#define emb_samplesH
diff --git a/libmysqld/examples/test-run b/libmysqld/examples/test-run
index aea5b13eaba..1667280a986 100755
--- a/libmysqld/examples/test-run
+++ b/libmysqld/examples/test-run
@@ -1,5 +1,20 @@
#! /bin/sh
+# Copyright (C) 2001, 2006 MySQL AB
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
# This is slapped together as a quick way to run the tests and
# is not meant for prime time. Please hack at it and submit
# changes, though, so we can gradually turn it into something
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 627f67cf170..1ba54350883 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -51,6 +51,23 @@ extern "C" void unireg_clear(int exit_code)
DBUG_VOID_RETURN;
}
+/*
+ Wrapper error handler for embedded server to call client/server error
+ handler based on whether thread is in client/server context
+*/
+
+static void embedded_error_handler(uint error, const char *str, myf MyFlags)
+{
+ DBUG_ENTER("embedded_error_handler");
+
+ /*
+ If current_thd is NULL, it means restore_global has been called and
+ thread is in client context, then call client error handler else call
+ server error handler.
+ */
+ DBUG_RETURN(current_thd ? my_message_sql(error, str, MyFlags):
+ my_message_stderr(error, str, MyFlags));
+}
/*
Reads error information from the MYSQL_DATA and puts
@@ -76,7 +93,7 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data)
strmake(net->last_error, ei->info, sizeof(net->last_error)-1);
memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate));
mysql->server_status= ei->server_status;
- my_free(data, MYF(0));
+ my_free(data);
}
static my_bool
@@ -98,7 +115,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
thd= (THD *) mysql->thd;
}
-#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
+#if defined(ENABLED_PROFILING)
thd->profiling.start_new_query();
#endif
@@ -107,19 +124,20 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
if (mysql->status != MYSQL_STATUS_READY)
{
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
- return 1;
+ result= 1;
+ goto end;
}
/* Clear result variables */
thd->clear_error();
- thd->main_da.reset_diagnostics_area();
+ thd->stmt_da->reset_diagnostics_area();
mysql->affected_rows= ~(my_ulonglong) 0;
mysql->field_count= 0;
net_clear_error(net);
thd->current_stmt= stmt;
+ thd->thread_stack= (char*) &thd;
thd->store_globals(); // Fix if more than one connect
- lex_start(thd);
/*
We have to call free_old_query before we start to fill mysql->fields
for new query. In the case of embedded server we collect field data
@@ -138,19 +156,23 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
result= dispatch_command(command, thd, (char *) arg, arg_length);
thd->cur_data= 0;
+ thd->mysys_var= NULL;
if (!skip_check)
result= thd->is_error() ? -1 : 0;
thd->mysys_var= 0;
-#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
+#if defined(ENABLED_PROFILING)
thd->profiling.finish_current_query();
#endif
+
+end:
+ thd->reset_globals();
return result;
}
-static void emb_flush_use_result(MYSQL *mysql)
+static void emb_flush_use_result(MYSQL *mysql, my_bool)
{
THD *thd= (THD*) mysql->thd;
if (thd->cur_data)
@@ -206,7 +228,7 @@ static MYSQL_FIELD *emb_list_fields(MYSQL *mysql)
res= ((THD*) mysql->thd)->cur_data;
((THD*) mysql->thd)->cur_data= 0;
mysql->field_alloc= res->alloc;
- my_free(res,MYF(0));
+ my_free(res);
mysql->status= MYSQL_STATUS_READY;
return mysql->fields;
}
@@ -219,7 +241,7 @@ static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
stmt->stmt_id= thd->client_stmt_id;
stmt->param_count= thd->client_param_count;
stmt->field_count= 0;
- mysql->warning_count= thd->total_warn_count;
+ mysql->warning_count= thd->warning_info->statement_warn_count();
if (thd->first_data)
{
@@ -235,7 +257,7 @@ static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
stmt->fields= mysql->fields;
stmt->mem_root= res->alloc;
mysql->fields= NULL;
- my_free(res,MYF(0));
+ my_free(res);
}
return 0;
@@ -292,7 +314,7 @@ static my_bool emb_read_query_result(MYSQL *mysql)
thd->cur_data= res;
}
else
- my_free(res, MYF(0));
+ my_free(res);
return 0;
}
@@ -334,7 +356,7 @@ int emb_read_binary_rows(MYSQL_STMT *stmt)
return 1;
}
stmt->result= *data;
- my_free((char *) data, MYF(0));
+ my_free(data);
set_stmt_errmsg(stmt, &stmt->mysql->net);
return 0;
}
@@ -404,7 +426,7 @@ static void emb_free_embedded_thd(MYSQL *mysql)
static const char * emb_read_statistics(MYSQL *mysql)
{
THD *thd= (THD*)mysql->thd;
- return thd->is_error() ? thd->main_da.message() : "";
+ return thd->is_error() ? thd->stmt_da->message() : "";
}
@@ -479,6 +501,10 @@ int init_embedded_server(int argc, char **argv, char **groups)
char *fake_argv[] = { (char *)"", 0 };
const char *fake_groups[] = { "server", "embedded", 0 };
my_bool acl_error;
+
+ if (my_thread_init())
+ return 1;
+
if (argc)
{
argcp= &argc;
@@ -500,15 +526,31 @@ int init_embedded_server(int argc, char **argv, char **groups)
*/
logger.init_base();
- if (init_common_variables("my", *argcp, *argvp, (const char **)groups))
+ orig_argc= *argcp;
+ orig_argv= *argvp;
+ if (load_defaults("my", (const char **)groups, argcp, argvp))
+ return 1;
+ defaults_argc= *argcp;
+ defaults_argv= *argvp;
+ remaining_argc= *argcp;
+ remaining_argv= *argvp;
+
+ /* Must be initialized early for comparison of options name */
+ system_charset_info= &my_charset_utf8_general_ci;
+ sys_var_init();
+
+ if (init_common_variables())
{
mysql_server_end();
return 1;
}
-
+
+ mysql_data_home= mysql_real_data_home;
+ mysql_data_home_len= mysql_real_data_home_len;
+
/* Get default temporary directory */
opt_mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
-#if defined( __WIN__) || defined(OS2)
+#if defined(__WIN__)
if (!opt_mysql_tmpdir)
opt_mysql_tmpdir=getenv("TEMP");
if (!opt_mysql_tmpdir)
@@ -517,6 +559,7 @@ int init_embedded_server(int argc, char **argv, char **groups)
if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0])
opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
+ init_ssl();
umask(((~my_umask) & 0666));
if (init_server_components())
{
@@ -524,7 +567,10 @@ int init_embedded_server(int argc, char **argv, char **groups)
return 1;
}
- error_handler_hook = my_message_sql;
+ /*
+ set error_handler_hook to embedded_error_handler wrapper.
+ */
+ error_handler_hook= embedded_error_handler;
acl_error= 0;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -572,7 +618,7 @@ int init_embedded_server(int argc, char **argv, char **groups)
void end_embedded_server()
{
- my_free((char*) copy_arguments_ptr, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(copy_arguments_ptr);
copy_arguments_ptr=0;
clean_up(0);
clean_up_mutexes();
@@ -585,7 +631,7 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag)
thd->mysql= mysql;
mysql->server_version= server_version;
mysql->client_flag= client_flag;
- mysql->server_capabilities= client_flag;
+ //mysql->server_capabilities= client_flag;
init_alloc_root(&mysql->field_alloc, 8192, 0);
}
@@ -616,10 +662,9 @@ void *create_embedded_thd(int client_flag)
/* TODO - add init_connect command execution */
if (thd->variables.max_join_size == HA_POS_ERROR)
- thd->options |= OPTION_BIG_SELECTS;
+ thd->variables.option_bits |= OPTION_BIG_SELECTS;
thd->proc_info=0; // Remove 'login'
thd->command=COM_SLEEP;
- thd->version=refresh_version;
thd->set_time();
thd->init_for_queries();
thd->client_capabilities= client_flag;
@@ -659,11 +704,12 @@ int check_embedded_connection(MYSQL *mysql, const char *db)
strmake(sctx->priv_host, (char*) my_localhost, MAX_HOSTNAME-1);
strmake(sctx->priv_user, mysql->user, USERNAME_LENGTH-1);
sctx->user= my_strdup(mysql->user, MYF(0));
+ sctx->proxy_user[0]= 0;
sctx->master_access= GLOBAL_ACLS; // Full rights
/* Change database if necessary */
if (!(result= (db && db[0] && mysql_change_db(thd, &db_str, FALSE))))
my_ok(thd);
- net_end_statement(thd);
+ thd->protocol->end_statement();
emb_read_query_result(mysql);
return result;
}
@@ -697,7 +743,7 @@ int check_embedded_connection(MYSQL *mysql, const char *db)
memset(thd->scramble, 55, SCRAMBLE_LENGTH); // dummy scramble
thd->scramble[SCRAMBLE_LENGTH]= 0;
- strcpy(mysql->scramble, thd->scramble);
+ //strcpy(mysql->scramble, thd->scramble);
if (mysql->passwd && mysql->passwd[0])
{
@@ -747,11 +793,6 @@ void THD::clear_data_list()
cur_data= 0;
}
-void THD::clear_error()
-{
- if (main_da.is_error())
- main_da.reset_diagnostics_area();
-}
static char *dup_str_aux(MEM_ROOT *root, const char *from, uint length,
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
@@ -824,7 +865,7 @@ MYSQL_DATA *THD::alloc_new_dataset()
static
bool
-write_eof_packet(THD *thd, uint server_status, uint total_warn_count)
+write_eof_packet(THD *thd, uint server_status, uint statement_warn_count)
{
if (!thd->mysql) // bootstrap file handling
return FALSE;
@@ -841,7 +882,7 @@ write_eof_packet(THD *thd, uint server_status, uint total_warn_count)
is cleared between substatements, and mysqltest gets confused
*/
thd->cur_data->embedded_info->warning_count=
- (thd->spcont ? 0 : min(total_warn_count, 65535));
+ (thd->spcont ? 0 : min(statement_warn_count, 65535));
return FALSE;
}
@@ -898,7 +939,7 @@ void Protocol_text::remove_last_row()
}
-bool Protocol::send_fields(List<Item> *list, uint flags)
+bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
{
List_iterator_fast<Item> it(*list);
Item *item;
@@ -907,7 +948,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
CHARSET_INFO *thd_cs= thd->variables.character_set_results;
CHARSET_INFO *cs= system_charset_info;
MYSQL_DATA *data;
- DBUG_ENTER("send_fields");
+ DBUG_ENTER("send_result_set_metadata");
if (!thd->mysql) // bootstrap file handling
DBUG_RETURN(0);
@@ -942,10 +983,10 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
strlen(server_field.org_table_name), cs, thd_cs);
client_field->org_name= dup_str_aux(field_alloc, server_field.org_col_name,
strlen(server_field.org_col_name), cs, thd_cs);
- if (item->collation.collation == &my_charset_bin || thd_cs == NULL)
+ if (item->charset_for_protocol() == &my_charset_bin || thd_cs == NULL)
{
/* No conversion */
- client_field->charsetnr= server_field.charsetnr;
+ client_field->charsetnr= item->charset_for_protocol()->number;
client_field->length= server_field.length;
}
else
@@ -957,7 +998,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
server_field.type <= (int) MYSQL_TYPE_BLOB) ?
server_field.length / item->collation.collation->mbminlen :
server_field.length / item->collation.collation->mbmaxlen;
- client_field->length= max_char_len * thd_cs->mbmaxlen;
+ client_field->length= char_to_byte_length_safe(max_char_len,
+ thd_cs->mbmaxlen);
}
client_field->type= server_field.type;
client_field->flags= server_field.flags;
@@ -971,7 +1013,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
client_field->catalog= dup_str_aux(field_alloc, "def", 3, cs, thd_cs);
client_field->catalog_length= 3;
- if (INTERNAL_NUM_FIELD(client_field))
+ if (IS_NUM(client_field->type))
client_field->flags|= NUM_FLAG;
if (flags & (int) Protocol::SEND_DEFAULTS)
@@ -998,9 +1040,10 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
}
if (flags & SEND_EOF)
- write_eof_packet(thd, thd->server_status, thd->total_warn_count);
+ write_eof_packet(thd, thd->server_status,
+ thd->warning_info->statement_warn_count());
- DBUG_RETURN(prepare_for_send(list));
+ DBUG_RETURN(prepare_for_send(list->elements));
err:
my_error(ER_OUT_OF_RESOURCES, MYF(0)); /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
@@ -1060,25 +1103,24 @@ bool Protocol_binary::write()
bool
net_send_ok(THD *thd,
- uint server_status, uint total_warn_count,
- ha_rows affected_rows, ulonglong id, const char *message)
+ uint server_status, uint statement_warn_count,
+ ulonglong affected_rows, ulonglong id, const char *message)
{
DBUG_ENTER("emb_net_send_ok");
MYSQL_DATA *data;
- bool error;
MYSQL *mysql= thd->mysql;
if (!mysql) // bootstrap file handling
DBUG_RETURN(FALSE);
if (!(data= thd->alloc_new_dataset()))
- return TRUE;
+ DBUG_RETURN(TRUE);
data->embedded_info->affected_rows= affected_rows;
data->embedded_info->insert_id= id;
if (message)
strmake(data->embedded_info->info, message,
sizeof(data->embedded_info->info)-1);
- error= write_eof_packet(thd, server_status, total_warn_count);
+ bool error= write_eof_packet(thd, server_status, statement_warn_count);
thd->cur_data= 0;
DBUG_RETURN(error);
}
@@ -1095,16 +1137,19 @@ net_send_ok(THD *thd,
*/
bool
-net_send_eof(THD *thd, uint server_status, uint total_warn_count)
+net_send_eof(THD *thd, uint server_status, uint statement_warn_count)
{
- bool error= write_eof_packet(thd, server_status, total_warn_count);
+ bool error= write_eof_packet(thd, server_status, statement_warn_count);
thd->cur_data= 0;
return error;
}
-bool net_send_error_packet(THD *thd, uint sql_errno, const char *err)
+bool net_send_error_packet(THD *thd, uint sql_errno, const char *err,
+ const char *sqlstate)
{
+ uint error;
+ char converted_err[MYSQL_ERRMSG_SIZE];
MYSQL_DATA *data= thd->cur_data;
struct embedded_query_result *ei;
@@ -1119,8 +1164,13 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err)
ei= data->embedded_info;
ei->last_errno= sql_errno;
- strmake(ei->info, err, sizeof(ei->info)-1);
- strmov(ei->sqlstate, mysql_errno_to_sqlstate(sql_errno));
+ convert_error_message(converted_err, sizeof(converted_err),
+ thd->variables.character_set_results,
+ err, strlen(err),
+ system_charset_info, &error);
+ /* Converted error message is always null-terminated. */
+ strmake(ei->info, converted_err, sizeof(ei->info)-1);
+ strmov(ei->sqlstate, sqlstate);
ei->server_status= thd->server_status;
thd->cur_data= 0;
return FALSE;
@@ -1218,3 +1268,4 @@ int vprint_msg_to_log(enum loglevel level __attribute__((unused)),
mysql_server_last_errno= CR_UNKNOWN_ERROR;
return 0;
}
+
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index afb91b7ff81..36728cf573c 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -11,11 +11,10 @@
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include <my_global.h>
#include <mysql.h>
-#include <mysql_embed.h>
#include <mysqld_error.h>
#include <my_pthread.h>
#include <my_sys.h>
@@ -27,12 +26,13 @@
#include <sys/stat.h>
#include <signal.h>
#include <time.h>
+#include <sql_common.h>
#include "embedded_priv.h"
#include "client_settings.h"
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
-#if !defined(MSDOS) && !defined(__WIN__)
+#if !defined(__WIN__)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -54,7 +54,7 @@
extern ulong net_buffer_length;
extern ulong max_allowed_packet;
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(__WIN__)
#define ERRNO WSAGetLastError()
#define perror(A)
#else
@@ -77,18 +77,6 @@ static my_bool is_NT(void)
}
#endif
-/**************************************************************************
-** Shut down connection
-**************************************************************************/
-
-void embedded_end_server(MYSQL *mysql)
-{
- DBUG_ENTER("embedded_end_server");
- free_old_query(mysql);
- DBUG_VOID_RETURN;
-}
-
-
int mysql_init_character_set(MYSQL *mysql);
MYSQL * STDCALL
@@ -99,11 +87,18 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
char name_buff[USERNAME_LENGTH];
DBUG_ENTER("mysql_real_connect");
- DBUG_PRINT("enter",("host: %s db: %s user: %s",
+ DBUG_PRINT("enter",("host: %s db: %s user: %s (libmysqld)",
host ? host : "(Null)",
db ? db : "(Null)",
user ? user : "(Null)"));
+ /* Test whether we're already connected */
+ if (mysql->server_version)
+ {
+ set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
+ DBUG_RETURN(0);
+ }
+
if (!host || !host[0])
host= mysql->options.host;
@@ -123,8 +118,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
(mysql->options.my_cnf_file ?
mysql->options.my_cnf_file : "my"),
mysql->options.my_cnf_group);
- my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.my_cnf_file);
+ my_free(mysql->options.my_cnf_group);
mysql->options.my_cnf_file=mysql->options.my_cnf_group=0;
}
@@ -220,7 +215,7 @@ error:
{
/* Free alloced memory */
my_bool free_me=mysql->free_me;
- embedded_end_server(mysql);
+ free_old_query(mysql);
mysql->free_me=0;
mysql_close(mysql);
mysql->free_me=free_me;
diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def
index 08325cc6180..ebabfef28a3 100644
--- a/libmysqld/libmysqld.def
+++ b/libmysqld/libmysqld.def
@@ -12,9 +12,7 @@ EXPORTS
mysql_commit
mysql_data_seek
mysql_debug
- mysql_disable_rpl_parse
mysql_dump_debug_info
- mysql_enable_rpl_parse
mysql_eof
mysql_errno
mysql_error
@@ -60,8 +58,6 @@ EXPORTS
mysql_rollback
mysql_row_seek
mysql_row_tell
- mysql_rpl_parse_enabled
- mysql_rpl_probe
mysql_select_db
mysql_send_query
mysql_shutdown