summaryrefslogtreecommitdiff
path: root/libmysqld
diff options
context:
space:
mode:
Diffstat (limited to 'libmysqld')
-rw-r--r--libmysqld/CMakeLists.txt4
-rw-r--r--libmysqld/Makefile.am235
-rw-r--r--libmysqld/copyright14
-rw-r--r--libmysqld/examples/Makefile.am53
-rwxr-xr-xlibmysqld/examples/test-run15
-rw-r--r--libmysqld/lib_sql.cc45
6 files changed, 53 insertions, 313 deletions
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 4d9785a4f35..d83c91c5ec3 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -26,7 +26,6 @@ ${CMAKE_SOURCE_DIR}/regex
${ZLIB_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${SSL_INTERNAL_INCLUDE_DIRS}
-${NDB_CLUSTER_INCLUDES}
${CMAKE_SOURCE_DIR}/sql/backup
)
@@ -42,6 +41,7 @@ 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/password.c ../sql/discover.cc ../sql/derror.cc
../sql/field.cc ../sql/field_conv.cc
../sql/filesort.cc ../sql/gstream.cc
@@ -115,7 +115,7 @@ SET(LIBS
dbug strings regex mysys vio
${ZLIB_LIBRARY} ${SSL_LIBRARIES}
${LIBWRAP} ${LIBCRYPT} ${LIBDL}
- ${MYSQLD_STATIC_PLUGIN_LIBS} ${NDB_CLIENT_LIBS}
+ ${MYSQLD_STATIC_PLUGIN_LIBS}
sql_embedded
)
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
deleted file mode 100644
index 98674552812..00000000000
--- a/libmysqld/Makefile.am
+++ /dev/null
@@ -1,235 +0,0 @@
-# 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
-# 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
-
-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)"'
- -DDISABLE_DTRACE \
- @DEFS@
-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@
-
-noinst_LIBRARIES = libmysqld_int.a
-pkglib_LIBRARIES = libmysqld.a
-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
-
-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 \
- sha2.cc des_key_file.cc \
- key.cc lock.cc log.cc sql_state.c \
- log_event.cc rpl_record.cc rpl_utility.cc \
- log_event_old.cc rpl_record_old.cc \
- protocol.cc net_serv.cc opt_range.cc \
- opt_subselect.cc \
- opt_sum.cc procedure.cc records.cc sql_acl.cc \
- sql_load.cc discover.cc sql_locale.cc \
- sql_profile.cc sql_admin.cc sql_truncate.cc datadict.cc \
- sql_reload.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_join_cache.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 sys_vars.cc \
- sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \
- sql_update.cc sql_yacc.cc table.cc thr_malloc.cc sql_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 transaction.cc \
- rpl_injector.cc my_user.c partition_info.cc sql_alter.cc \
- sql_servers.cc event_parse_data.cc sql_signal.cc \
- rpl_handler.cc mdl.cc keycaches.cc sql_audit.cc \
- sql_partition_admin.cc \
- create_options.cc opt_table_elimination.cc \
- multi_range_read.cc opt_index_cond_pushdown.cc \
- sql_expression_cache.cc
-
-libmysqld_int_a_SOURCES= $(libmysqld_sources)
-nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
-libmysqld_a_SOURCES=
-
-sqlstoragesources = $(EXTRA_libmysqld_a_SOURCES)
-storagesources = @condition_dependent_plugin_modules@
-storageobjects = @condition_dependent_plugin_objects@
-storagesourceslinks = @condition_dependent_plugin_links@
-
-# 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.a \
- $(top_builddir)/mysys/libmysys.a \
- $(top_builddir)/strings/libmystrings.a \
- $(top_builddir)/dbug/libdbug.a \
- $(top_builddir)/vio/libvio.a \
- @NDB_SCI_LIBS@ \
- @mysql_plugin_libs@ \
- $(libevent_inc_libs) \
- $(yassl_inc_libs)
-
-if HAVE_YASSL
-yassl_inc_libs= $(top_builddir)/extra/yassl/src/.libs/libyassl.a \
- $(top_builddir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a
-endif
-
-# Storage engine specific compilation options
-ha_ndbcluster.o:ha_ndbcluster.cc
- $(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
-
-ha_ndbcluster_cond.o:ha_ndbcluster_cond.cc
- $(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
-
-ha_ndbcluster_binlog.o: ha_ndbcluster_binlog.cc
- $(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
-
-# Until we can remove dependency on ha_ndbcluster.h
-handler.o: handler.cc
- $(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
-
-# We need rules to compile these as no good way
-# found to append fileslists that collected by configure
-# to the sources list
-
-ha_federatedx.o:ha_federatedx.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
-ha_heap.o:ha_heap.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
-ha_innodb.o:ha_innodb.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
-ha_myisam.o:ha_myisam.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
-ha_myisammrg.o:ha_myisammrg.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
-#
-# To make it easy for the end user to use the embedded library we
-# generate a total libmysqld.a from all library files,
-
-# note - InnoDB libraries have circular dependencies, so in INC_LIB
-# few libraries are present two times. Metrowerks linker doesn't like
-# it at all. Traditional ar has no problems with it, but still there's no
-# need to add the same file twice to the library, so 'sort -u' save us
-# some time and spares unnecessary work.
-
-libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobjects)
-if DARWIN_MWCC
- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects)
-else
- -rm -f libmysqld.a
- current_dir=`pwd`; \
- rm -rf tmp; mkdir tmp; \
- (for arc in $(INC_LIB) ./libmysqld_int.a; do \
- arpath=`echo $$arc|sed 's|[^/]*$$||'|sed 's|\.libs/$$||'`; \
- artmp=`echo $$arc|sed 's|^.*/|tmp/lib-|'`; \
- for F in `$(AR) t $$arc | grep -v SYMDEF`; do \
- if test -e "$$arpath/$$F" ; then echo "$$arpath/$$F"; else \
- mkdir $$artmp; cd $$artmp > /dev/null; \
- $(AR) x ../../$$arc; \
- cd $$current_dir > /dev/null; \
- ls $$artmp/* | grep -v SYMDEF; \
- continue 2; fi; done; \
- done; echo $(libmysqld_a_DEPENDENCIES) ) | sort -u | xargs $(AR) cq libmysqld.a; \
- $(AR) r libmysqld.a $(storageobjects); \
- $(RANLIB) libmysqld.a ; \
- rm -rf tmp
-endif
-
-## 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_LIBADD) 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; \
- if test -n "$(sqlstoragesources)" ; \
- then \
- for f in "$(sqlstoragesources)"; do \
- rm -f "$$f"; \
- @LN_CP_F@ `find $(srcdir)/../sql -name "$$f"` "$$f"; \
- done; \
- fi; \
- if test -n "$(storagesources)" ; \
- then \
- rm -f $(storagesources); \
- for f in $(storagesourceslinks); do \
- @LN_CP_F@ $(top_srcdir)/$$f . ; \
- done; \
- fi; \
- 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) $(sqlstoragesources) $(storagesources) | sed "s;\.lo;.c;g"`; \
- rm -f client_settings.h
diff --git a/libmysqld/copyright b/libmysqld/copyright
deleted file mode 100644
index 0b4dd1725a2..00000000000
--- a/libmysqld/copyright
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Copyright (c) 2000
- * SWsoft company
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am
deleted file mode 100644
index 66c40d88e29..00000000000
--- a/libmysqld/examples/Makefile.am
+++ /dev/null
@@ -1,53 +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 @DEFS@
-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@ ../libmysqld.a @LIBDL@ $(CXXLDFLAGS) \
- @NDB_SCI_LIBS@
-
-mysqltest_embedded_LINK = $(CXXLINK)
-nodist_mysqltest_embedded_SOURCES = mysqltest.cc
-mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a \
- @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/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 847b1fd7ad9..2f34ea8c224 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -50,6 +50,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
@@ -106,7 +123,8 @@ 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 */
@@ -147,6 +165,9 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
#if defined(ENABLED_PROFILING)
thd->profiling.finish_current_query();
#endif
+
+end:
+ thd->restore_globals();
return result;
}
@@ -506,11 +527,12 @@ int init_embedded_server(int argc, char **argv, char **groups)
orig_argc= *argcp;
orig_argv= *argvp;
- load_defaults("my", (const char **)groups, argcp, argvp);
+ if (load_defaults("my", (const char **)groups, argcp, argvp))
+ return 1;
defaults_argc= *argcp;
defaults_argv= *argvp;
- remaining_argc= argc;
- remaining_argv= argv;
+ remaining_argc= *argcp;
+ remaining_argv= *argvp;
/* Must be initialized early for comparison of options name */
system_charset_info= &my_charset_utf8_general_ci;
@@ -544,7 +566,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
@@ -604,7 +629,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);
}
@@ -677,6 +702,7 @@ 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))))
@@ -715,7 +741,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])
{
@@ -742,8 +768,9 @@ int check_embedded_connection(MYSQL *mysql, const char *db)
return 0;
err:
- strmake(net->last_error, thd->stmt_da->message(), sizeof(net->last_error)-1);
- memcpy(net->sqlstate, mysql_errno_to_sqlstate(thd->stmt_da->sql_errno()),
+ strmake(net->last_error, thd->main_da.message(), sizeof(net->last_error)-1);
+ memcpy(net->sqlstate,
+ mysql_errno_to_sqlstate(thd->main_da.sql_errno()),
sizeof(net->sqlstate)-1);
return 1;
}