From 20cfd8fd4e4167ddc5b0b7b1d447fa7f3ed0be6a Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 14 Nov 2004 10:25:38 +0200 Subject: [PATCH 1/8] fixed incorrect using of THD::is_fatal_error --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9d755731cb7..7420f9de100 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1106,7 +1106,7 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg) if (buff[length-1]!='\n' && !feof(file)) { send_error(thd,ER_NET_PACKET_TOO_LARGE, NullS); - thd->is_fatal_error= 1; + thd->fatal_error(); break; } while (length && (my_isspace(thd->charset(), buff[length-1]) || From bbe9e857e6aff7116bd816d2c2e3f39905abee43 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 14 Nov 2004 11:02:06 +0000 Subject: [PATCH 2/8] moved ndb_restore together with rest of the ndb tools kernel includes needed by ndb_restore changed link order moved LocalConfig to mgmapi Moved NdbConfig to Portlib mgmapi to use LocalConfig for connectstring parsing instead of it's own enable usage of "NULL" connectstring for default new ndbmgmclient lib that can be used by e.g. mysqladmin later LocalConfig no longer needed here, now in mgmapi Send connectstring to mgmapi instead added valid connectstring to be with only host without port i.e. valid connectstring =host1,host2,host3 default port will be added ndb/src/common/portlib/NdbConfig.c: Rename: ndb/src/common/mgmcommon/NdbConfig.c -> ndb/src/common/portlib/NdbConfig.c ndb/include/portlib/NdbConfig.h: Rename: ndb/include/mgmcommon/NdbConfig.h -> ndb/include/portlib/NdbConfig.h ndb/include/mgmapi/LocalConfig.hpp: Rename: ndb/include/mgmcommon/LocalConfig.hpp -> ndb/include/mgmapi/LocalConfig.hpp ndb/tools/restore/Makefile.am: Rename: ndb/src/kernel/blocks/backup/restore/Makefile.am -> ndb/tools/restore/Makefile.am ndb/tools/restore/consumer.cpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer.cpp -> ndb/tools/restore/consumer.cpp ndb/tools/restore/consumer.hpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer.hpp -> ndb/tools/restore/consumer.hpp ndb/tools/restore/consumer_printer.hpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer_printer.hpp -> ndb/tools/restore/consumer_printer.hpp ndb/tools/restore/consumer_printer.cpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer_printer.cpp -> ndb/tools/restore/consumer_printer.cpp ndb/tools/restore/consumer_restore.hpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer_restore.hpp -> ndb/tools/restore/consumer_restore.hpp ndb/tools/restore/main.cpp: Rename: ndb/src/kernel/blocks/backup/restore/main.cpp -> ndb/tools/restore/main.cpp ndb/tools/restore/consumer_restorem.cpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer_restorem.cpp -> ndb/tools/restore/consumer_restorem.cpp configure.in: moved ndb_restore together with rest of the ndb tools ndb/config/type_ndbapitools.mk.am: kernel includes needed by ndb_restore ndb/src/Makefile.am: changed link order ndb/src/common/mgmcommon/Makefile.am: mived LocalConfig to mgmapi ndb/src/common/portlib/Makefile.am: Moved NdbConfig to Portlib ndb/src/kernel/blocks/backup/Makefile.am: moved restore together with rest of ndb tools ndb/src/mgmapi/LocalConfig.cpp: added valid connectstring to be with only host without port i.e. valid connectstring =host1,host2,host3 default port will be added ndb/src/mgmapi/Makefile.am: LocalConfig part of the libmgmapi ndb/src/mgmapi/mgmapi.cpp: mgmapi to use LocalConfig for connectstring parsing instead of it's own ndb/src/mgmclient/CommandInterpreter.cpp: enable usage of "NULL" connectstring for default ndb/src/mgmclient/Makefile.am: new ndbmgmclient lib that can be used by e.g. mysqladmin later ndb/src/mgmclient/main.cpp: LocalConfig no longer needed here, now in mgmapi Send connectstring to mgmapi instead ndb/tools/Makefile.am: add ndb_restore to make of tools ndb/tools/restore/Restore.cpp: moved include BackupFormat and NdbDictionaryImpl to Restore.hpp ndb/tools/restore/Restore.hpp: moved include BackupFormat and NdbDictionaryImpl to Restore.hpp ndb/tools/restore/consumer_restore.cpp: moved include BackupFormat and NdbDictionaryImpl to Restore.hpp ndb/tools/waiter.cpp: LocalConfig moved --- configure.in | 1 - ndb/config/type_ndbapitools.mk.am | 3 +- .../{mgmcommon => mgmapi}/LocalConfig.hpp | 0 .../{mgmcommon => portlib}/NdbConfig.h | 0 ndb/src/Makefile.am | 2 +- ndb/src/common/mgmcommon/Makefile.am | 5 +- ndb/src/common/portlib/Makefile.am | 3 +- .../common/{mgmcommon => portlib}/NdbConfig.c | 0 ndb/src/kernel/blocks/backup/Makefile.am | 2 - .../mgmcommon => mgmapi}/LocalConfig.cpp | 28 +++--- ndb/src/mgmapi/Makefile.am | 7 +- ndb/src/mgmapi/mgmapi.cpp | 86 ++++++++----------- ndb/src/mgmclient/CommandInterpreter.cpp | 8 +- ndb/src/mgmclient/Makefile.am | 11 ++- ndb/src/mgmclient/main.cpp | 30 ++----- ndb/tools/Makefile.am | 17 +++- .../backup => tools}/restore/Makefile.am | 0 .../backup => tools}/restore/Restore.cpp | 4 - .../backup => tools}/restore/Restore.hpp | 3 +- .../backup => tools}/restore/consumer.cpp | 0 .../backup => tools}/restore/consumer.hpp | 0 .../restore/consumer_printer.cpp | 0 .../restore/consumer_printer.hpp | 0 .../restore/consumer_restore.cpp | 1 - .../restore/consumer_restore.hpp | 0 .../restore/consumer_restorem.cpp | 0 .../blocks/backup => tools}/restore/main.cpp | 0 ndb/tools/waiter.cpp | 5 +- 28 files changed, 107 insertions(+), 109 deletions(-) rename ndb/include/{mgmcommon => mgmapi}/LocalConfig.hpp (100%) rename ndb/include/{mgmcommon => portlib}/NdbConfig.h (100%) rename ndb/src/common/{mgmcommon => portlib}/NdbConfig.c (100%) rename ndb/src/{common/mgmcommon => mgmapi}/LocalConfig.cpp (92%) rename ndb/{src/kernel/blocks/backup => tools}/restore/Makefile.am (100%) rename ndb/{src/kernel/blocks/backup => tools}/restore/Restore.cpp (99%) rename ndb/{src/kernel/blocks/backup => tools}/restore/Restore.hpp (98%) rename ndb/{src/kernel/blocks/backup => tools}/restore/consumer.cpp (100%) rename ndb/{src/kernel/blocks/backup => tools}/restore/consumer.hpp (100%) rename ndb/{src/kernel/blocks/backup => tools}/restore/consumer_printer.cpp (100%) rename ndb/{src/kernel/blocks/backup => tools}/restore/consumer_printer.hpp (100%) rename ndb/{src/kernel/blocks/backup => tools}/restore/consumer_restore.cpp (99%) rename ndb/{src/kernel/blocks/backup => tools}/restore/consumer_restore.hpp (100%) rename ndb/{src/kernel/blocks/backup => tools}/restore/consumer_restorem.cpp (100%) rename ndb/{src/kernel/blocks/backup => tools}/restore/main.cpp (100%) diff --git a/configure.in b/configure.in index d4688d70484..1fcba6b8f5f 100644 --- a/configure.in +++ b/configure.in @@ -3114,7 +3114,6 @@ AC_CONFIG_FILES(ndb/Makefile ndb/include/Makefile dnl ndb/src/kernel/blocks/qmgr/Makefile dnl ndb/src/kernel/blocks/trix/Makefile dnl ndb/src/kernel/blocks/backup/Makefile dnl - ndb/src/kernel/blocks/backup/restore/Makefile dnl ndb/src/kernel/blocks/dbutil/Makefile dnl ndb/src/kernel/blocks/suma/Makefile dnl ndb/src/kernel/blocks/grep/Makefile dnl diff --git a/ndb/config/type_ndbapitools.mk.am b/ndb/config/type_ndbapitools.mk.am index ed6d8699e05..d4eb090112d 100644 --- a/ndb/config/type_ndbapitools.mk.am +++ b/ndb/config/type_ndbapitools.mk.am @@ -11,4 +11,5 @@ INCLUDES += -I$(srcdir) -I$(top_srcdir)/include \ -I$(top_srcdir)/ndb/include/util \ -I$(top_srcdir)/ndb/include/portlib \ -I$(top_srcdir)/ndb/test/include \ - -I$(top_srcdir)/ndb/include/mgmapi + -I$(top_srcdir)/ndb/include/mgmapi \ + -I$(top_srcdir)/ndb/include/kernel diff --git a/ndb/include/mgmcommon/LocalConfig.hpp b/ndb/include/mgmapi/LocalConfig.hpp similarity index 100% rename from ndb/include/mgmcommon/LocalConfig.hpp rename to ndb/include/mgmapi/LocalConfig.hpp diff --git a/ndb/include/mgmcommon/NdbConfig.h b/ndb/include/portlib/NdbConfig.h similarity index 100% rename from ndb/include/mgmcommon/NdbConfig.h rename to ndb/include/portlib/NdbConfig.h diff --git a/ndb/src/Makefile.am b/ndb/src/Makefile.am index bed43438e91..36a4c3f247f 100644 --- a/ndb/src/Makefile.am +++ b/ndb/src/Makefile.am @@ -11,8 +11,8 @@ libndbclient_la_LIBADD = \ common/transporter/libtransporter.la \ common/debugger/libtrace.la \ common/debugger/signaldata/libsignaldataprint.la \ - common/mgmcommon/libmgmsrvcommon.la \ mgmapi/libmgmapi.la \ + common/mgmcommon/libmgmsrvcommon.la \ common/logger/liblogger.la \ common/portlib/libportlib.la \ common/util/libgeneral.la diff --git a/ndb/src/common/mgmcommon/Makefile.am b/ndb/src/common/mgmcommon/Makefile.am index b787da51ab9..a0aca3e68f1 100644 --- a/ndb/src/common/mgmcommon/Makefile.am +++ b/ndb/src/common/mgmcommon/Makefile.am @@ -1,14 +1,11 @@ noinst_LTLIBRARIES = libmgmsrvcommon.la libmgmsrvcommon_la_SOURCES = \ - LocalConfig.cpp \ ConfigRetriever.cpp \ - IPCConfig.cpp NdbConfig.c + IPCConfig.cpp INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi -I$(top_srcdir)/ndb/src/mgmsrv -DEFS_LOC = -DNDB_PORT="\"@ndb_port@\"" - include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am include $(top_srcdir)/ndb/config/type_mgmapiclient.mk.am diff --git a/ndb/src/common/portlib/Makefile.am b/ndb/src/common/portlib/Makefile.am index 6f3a3fe01a9..73125ad918d 100644 --- a/ndb/src/common/portlib/Makefile.am +++ b/ndb/src/common/portlib/Makefile.am @@ -5,7 +5,8 @@ noinst_LTLIBRARIES = libportlib.la libportlib_la_SOURCES = \ NdbCondition.c NdbMutex.c NdbSleep.c NdbTick.c \ NdbEnv.c NdbThread.c NdbHost.c NdbTCP.cpp \ - NdbDaemon.c NdbMem.c + NdbDaemon.c NdbMem.c \ + NdbConfig.c include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_util.mk.am diff --git a/ndb/src/common/mgmcommon/NdbConfig.c b/ndb/src/common/portlib/NdbConfig.c similarity index 100% rename from ndb/src/common/mgmcommon/NdbConfig.c rename to ndb/src/common/portlib/NdbConfig.c diff --git a/ndb/src/kernel/blocks/backup/Makefile.am b/ndb/src/kernel/blocks/backup/Makefile.am index 85bf5b12415..e669febdc0d 100644 --- a/ndb/src/kernel/blocks/backup/Makefile.am +++ b/ndb/src/kernel/blocks/backup/Makefile.am @@ -1,6 +1,4 @@ -SUBDIRS = restore - noinst_LIBRARIES = libbackup.a libbackup_a_SOURCES = Backup.cpp BackupInit.cpp diff --git a/ndb/src/common/mgmcommon/LocalConfig.cpp b/ndb/src/mgmapi/LocalConfig.cpp similarity index 92% rename from ndb/src/common/mgmcommon/LocalConfig.cpp rename to ndb/src/mgmapi/LocalConfig.cpp index 679de716be0..d0ff97cdedf 100644 --- a/ndb/src/common/mgmcommon/LocalConfig.cpp +++ b/ndb/src/mgmapi/LocalConfig.cpp @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "LocalConfig.hpp" +#include #include #include #include @@ -164,17 +164,25 @@ LocalConfig::parseNodeId(const char * buf){ bool LocalConfig::parseHostName(const char * buf){ char tempString[1024]; + char tempString2[1024]; int port; - for(int i = 0; hostNameTokens[i] != 0; i++) { - if (sscanf(buf, hostNameTokens[i], tempString, &port) == 2) { - MgmtSrvrId mgmtSrvrId; - mgmtSrvrId.type = MgmId_TCP; - mgmtSrvrId.name.assign(tempString); - mgmtSrvrId.port = port; - ids.push_back(mgmtSrvrId); - return true; + do { + for(int i = 0; hostNameTokens[i] != 0; i++) { + if (sscanf(buf, hostNameTokens[i], tempString, &port) == 2) { + MgmtSrvrId mgmtSrvrId; + mgmtSrvrId.type = MgmId_TCP; + mgmtSrvrId.name.assign(tempString); + mgmtSrvrId.port = port; + ids.push_back(mgmtSrvrId); + return true; + } } - } + if (buf == tempString2) + break; + // try to add default port to see if it works + snprintf(tempString2, sizeof(tempString2),"%s:%s", buf, NDB_PORT); + buf= tempString2; + } while(1); return false; } diff --git a/ndb/src/mgmapi/Makefile.am b/ndb/src/mgmapi/Makefile.am index 0f0e1cea5d8..d64216b56c0 100644 --- a/ndb/src/mgmapi/Makefile.am +++ b/ndb/src/mgmapi/Makefile.am @@ -1,10 +1,11 @@ noinst_LTLIBRARIES = libmgmapi.la -libmgmapi_la_SOURCES = mgmapi.cpp mgmapi_configuration.cpp +libmgmapi_la_SOURCES = mgmapi.cpp mgmapi_configuration.cpp LocalConfig.cpp -INCLUDES_LOC = -I$(top_srcdir)/ndb/include/mgmapi -I$(top_srcdir)/ndb/src/common/mgmcommon -DEFS_LOC = -DNO_DEBUG_MESSAGES +INCLUDES_LOC = -I$(top_srcdir)/ndb/include/mgmapi + +DEFS_LOC = -DNO_DEBUG_MESSAGES -DNDB_PORT="\"@ndb_port@\"" include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_util.mk.am diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index 66f0dbb1842..51f2d7cee01 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -94,6 +95,8 @@ struct ndb_mgm_handle { NDB_SOCKET_TYPE socket; + char cfg_ptr[sizeof(LocalConfig)]; + #ifdef MGMAPI_LOG FILE* logfile; #endif @@ -146,10 +149,12 @@ ndb_mgm_create_handle() h->last_error = 0; h->last_error_line = 0; h->hostname = 0; - h->socket = -1; + h->socket = NDB_INVALID_SOCKET; h->read_timeout = 50000; h->write_timeout = 100; + new (h->cfg_ptr) LocalConfig; + strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE); #ifdef MGMAPI_LOG h->logfile = 0; @@ -177,6 +182,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle) (* handle)->logfile = 0; } #endif + ((LocalConfig*)((*handle)->cfg_ptr))->~LocalConfig(); my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR)); * handle = 0; } @@ -220,42 +226,6 @@ ndb_mgm_get_latest_error_msg(const NdbMgmHandle h) return "Error"; // Unknown Error message } -static -int -parse_connect_string(const char * connect_string, - NdbMgmHandle handle) -{ - if(connect_string == 0){ - SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, ""); - return -1; - } - - char * line = my_strdup(connect_string,MYF(MY_WME)); - My_auto_ptr ap1(line); - if(line == 0){ - SET_ERROR(handle, NDB_MGM_OUT_OF_MEMORY, ""); - return -1; - } - - char * tmp = strchr(line, ':'); - if(tmp == 0){ - SET_ERROR(handle, NDB_MGM_OUT_OF_MEMORY, ""); - return -1; - } - * tmp = 0; tmp++; - - int port = 0; - if(sscanf(tmp, "%d", &port) != 1){ - SET_ERROR(handle, NDB_MGM_ILLEGAL_PORT_NUMBER, ""); - return -1; - } - - my_free(handle->hostname,MYF(MY_ALLOW_ZERO_PTR)); - handle->hostname = my_strdup(line,MYF(MY_WME)); - handle->port = port; - return 0; -} - /* * Call an operation, and return the reply */ @@ -348,11 +318,6 @@ ndb_mgm_connect(NdbMgmHandle handle, const char * mgmsrv) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_connect"); CHECK_HANDLE(handle, -1); - - if(parse_connect_string(mgmsrv, handle) != 0) { - SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, ""); - return -1; - } #ifdef MGMAPI_LOG /** @@ -366,14 +331,37 @@ ndb_mgm_connect(NdbMgmHandle handle, const char * mgmsrv) /** * Do connect */ - SocketClient s(handle->hostname, handle->port); - const NDB_SOCKET_TYPE sockfd = s.connect(); - if (sockfd < 0) { - setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, - "Unable to connect to %s", mgmsrv); + LocalConfig *cfg= (LocalConfig*)(handle->cfg_ptr); + new (cfg) LocalConfig; + if (!cfg->init(mgmsrv, 0) || + cfg->ids.size() == 0) + { + SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, ""); return -1; } - + + NDB_SOCKET_TYPE sockfd= NDB_INVALID_SOCKET; + Uint32 i; + for (i = 0; i < cfg->ids.size(); i++) + { + if (cfg->ids[i].type != MgmId_TCP) + continue; + SocketClient s(cfg->ids[i].name.c_str(), cfg->ids[i].port); + sockfd = s.connect(); + if (sockfd != NDB_INVALID_SOCKET) + break; + } + if (sockfd == NDB_INVALID_SOCKET) + { + setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, + "Unable to connect using connectstring %s", mgmsrv); + return -1; + } + + my_free(handle->hostname,MYF(MY_ALLOW_ZERO_PTR)); + handle->hostname = my_strdup(cfg->ids[i].name.c_str(),MYF(MY_WME)); + handle->port = cfg->ids[i].port; + handle->socket = sockfd; handle->connected = 1; @@ -392,7 +380,7 @@ ndb_mgm_disconnect(NdbMgmHandle handle) CHECK_CONNECTED(handle, -1); NDB_CLOSE_SOCKET(handle->socket); - handle->socket = -1; + handle->socket = NDB_INVALID_SOCKET; handle->connected = 0; return 0; diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index fde4e5a2e91..d940f6e165a 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -384,8 +384,10 @@ CommandInterpreter::CommandInterpreter(const char *_host) connected = false; try_reconnect = 0; - - host = my_strdup(_host,MYF(MY_WME)); + if (_host) + host= my_strdup(_host,MYF(MY_WME)); + else + host= 0; #ifdef HAVE_GLOBAL_REPLICATION rep_host = NULL; m_repserver = NULL; @@ -400,7 +402,7 @@ CommandInterpreter::~CommandInterpreter() { connected = false; ndb_mgm_destroy_handle(&m_mgmsrv); - my_free((char *)host,MYF(0)); + my_free((char *)host,MYF(MY_ALLOW_ZERO_PTR)); host = NULL; } diff --git a/ndb/src/mgmclient/Makefile.am b/ndb/src/mgmclient/Makefile.am index cd6ddb0ad57..b8f9f82e501 100644 --- a/ndb/src/mgmclient/Makefile.am +++ b/ndb/src/mgmclient/Makefile.am @@ -3,17 +3,24 @@ noinst_LTLIBRARIES = libndbmgmclient.la ndbtools_PROGRAMS = ndb_mgm libndbmgmclient_la_SOURCES = CommandInterpreter.cpp +libndbmgmclient_la_LIBADD = ../mgmapi/libmgmapi.la \ + ../common/logger/liblogger.la \ + ../common/portlib/libportlib.la \ + ../common/util/libgeneral.la \ + ../common/portlib/libportlib.la + ndb_mgm_SOURCES = main.cpp include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am -INCLUDES += -I$(top_srcdir)/ndb/include/mgmapi -I$(top_srcdir)/ndb/src/common/mgmcommon +INCLUDES += -I$(top_srcdir)/ndb/include/mgmapi \ + -I$(top_srcdir)/ndb/src/common/mgmcommon LDADD_LOC = $(noinst_LTLIBRARIES) \ + ../common/portlib/libportlib.la \ @readline_link@ \ - $(top_builddir)/ndb/src/libndbclient.la \ $(top_builddir)/dbug/libdbug.a \ $(top_builddir)/mysys/libmysys.a \ $(top_builddir)/strings/libmystrings.a \ diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp index 8f5d9e6656c..401a9198f30 100644 --- a/ndb/src/mgmclient/main.cpp +++ b/ndb/src/mgmclient/main.cpp @@ -145,33 +145,21 @@ int main(int argc, char** argv){ if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); - LocalConfig cfg; - - if(argc >= 1) { - _host = argv[0]; - if(argc >= 2) { - _port = atoi(argv[1]); - } - } else { - if(cfg.init(opt_connect_str, 0) && cfg.ids.size() > 0 && cfg.ids[0].type == MgmId_TCP){ - _host = cfg.ids[0].name.c_str(); - _port = cfg.ids[0].port; - } else { - cfg.printError(); - cfg.printUsage(); - return 1; - } - } - char buf[MAXHOSTNAMELEN+10]; - BaseString::snprintf(buf, sizeof(buf), "%s:%d", _host, _port); + if(argc == 1) { + BaseString::snprintf(buf, sizeof(buf), "%s", argv[0]); + opt_connect_str= buf; + } else if (argc >= 2) { + BaseString::snprintf(buf, sizeof(buf), "%s:%s", argv[0], argv[1]); + opt_connect_str= buf; + } ndbout << "-- NDB Cluster -- Management Client --" << endl; - printf("Connecting to Management Server: %s\n", buf); + printf("Connecting to Management Server: %s\n", opt_connect_str ? opt_connect_str : "default"); signal(SIGPIPE, handler); - com = new Ndb_mgmclient(buf); + com = new Ndb_mgmclient(opt_connect_str); while(read_and_execute(_try_reconnect)); delete com; diff --git a/ndb/tools/Makefile.am b/ndb/tools/Makefile.am index fad9bf9ff84..9c086d665c1 100644 --- a/ndb/tools/Makefile.am +++ b/ndb/tools/Makefile.am @@ -8,9 +8,12 @@ ndbtools_PROGRAMS = \ ndb_drop_index \ ndb_show_tables \ ndb_select_all \ - ndb_select_count + ndb_select_count \ + ndb_restore -tools_common_sources = ../test/src/NDBT_ReturnCodes.cpp ../test/src/NDBT_Table.cpp ../test/src/NDBT_Output.cpp +tools_common_sources = ../test/src/NDBT_ReturnCodes.cpp \ + ../test/src/NDBT_Table.cpp \ + ../test/src/NDBT_Output.cpp ndb_test_platform_SOURCES = ndb_test_platform.cpp ndb_waiter_SOURCES = waiter.cpp $(tools_common_sources) @@ -19,8 +22,15 @@ ndb_desc_SOURCES = desc.cpp $(tools_common_sources) ndb_drop_index_SOURCES = drop_index.cpp $(tools_common_sources) ndb_drop_table_SOURCES = drop_tab.cpp $(tools_common_sources) ndb_show_tables_SOURCES = listTables.cpp $(tools_common_sources) -ndb_select_all_SOURCES = select_all.cpp ../test/src/NDBT_ResultRow.cpp $(tools_common_sources) +ndb_select_all_SOURCES = select_all.cpp \ + ../test/src/NDBT_ResultRow.cpp \ + $(tools_common_sources) ndb_select_count_SOURCES = select_count.cpp $(tools_common_sources) +ndb_restore_SOURCES = restore/main.cpp \ + restore/consumer.cpp \ + restore/consumer_restore.cpp \ + restore/consumer_printer.cpp \ + restore/Restore.cpp include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapitools.mk.am @@ -34,6 +44,7 @@ ndb_drop_index_LDFLAGS = @ndb_bin_am_ldflags@ ndb_show_tables_LDFLAGS = @ndb_bin_am_ldflags@ ndb_select_all_LDFLAGS = @ndb_bin_am_ldflags@ ndb_select_count_LDFLAGS = @ndb_bin_am_ldflags@ +ndb_restore_LDFLAGS = @ndb_bin_am_ldflags@ # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/ndb/src/kernel/blocks/backup/restore/Makefile.am b/ndb/tools/restore/Makefile.am similarity index 100% rename from ndb/src/kernel/blocks/backup/restore/Makefile.am rename to ndb/tools/restore/Makefile.am diff --git a/ndb/src/kernel/blocks/backup/restore/Restore.cpp b/ndb/tools/restore/Restore.cpp similarity index 99% rename from ndb/src/kernel/blocks/backup/restore/Restore.cpp rename to ndb/tools/restore/Restore.cpp index fb3bde6bdef..6e2fcaed3af 100644 --- a/ndb/src/kernel/blocks/backup/restore/Restore.cpp +++ b/ndb/tools/restore/Restore.cpp @@ -15,7 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Restore.hpp" -#include "BackupFormat.hpp" #include #include #include @@ -25,9 +24,6 @@ #include #include -// from src/ndbapi -#include - Uint16 Twiddle16(Uint16 in); // Byte shift 16-bit data Uint32 Twiddle32(Uint32 in); // Byte shift 32-bit data Uint64 Twiddle64(Uint64 in); // Byte shift 64-bit data diff --git a/ndb/src/kernel/blocks/backup/restore/Restore.hpp b/ndb/tools/restore/Restore.hpp similarity index 98% rename from ndb/src/kernel/blocks/backup/restore/Restore.hpp rename to ndb/tools/restore/Restore.hpp index 0ec1ab852e9..82fcdcdb183 100644 --- a/ndb/src/kernel/blocks/backup/restore/Restore.hpp +++ b/ndb/tools/restore/Restore.hpp @@ -19,7 +19,8 @@ #include #include -#include +#include "../src/kernel/blocks/backup/BackupFormat.hpp" +#include "../src/ndbapi/NdbDictionaryImpl.hpp" #include #include diff --git a/ndb/src/kernel/blocks/backup/restore/consumer.cpp b/ndb/tools/restore/consumer.cpp similarity index 100% rename from ndb/src/kernel/blocks/backup/restore/consumer.cpp rename to ndb/tools/restore/consumer.cpp diff --git a/ndb/src/kernel/blocks/backup/restore/consumer.hpp b/ndb/tools/restore/consumer.hpp similarity index 100% rename from ndb/src/kernel/blocks/backup/restore/consumer.hpp rename to ndb/tools/restore/consumer.hpp diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_printer.cpp b/ndb/tools/restore/consumer_printer.cpp similarity index 100% rename from ndb/src/kernel/blocks/backup/restore/consumer_printer.cpp rename to ndb/tools/restore/consumer_printer.cpp diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_printer.hpp b/ndb/tools/restore/consumer_printer.hpp similarity index 100% rename from ndb/src/kernel/blocks/backup/restore/consumer_printer.hpp rename to ndb/tools/restore/consumer_printer.hpp diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp similarity index 99% rename from ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp rename to ndb/tools/restore/consumer_restore.cpp index a35d9d22c65..e2c55e5a0b1 100644 --- a/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp +++ b/ndb/tools/restore/consumer_restore.cpp @@ -16,7 +16,6 @@ #include "consumer_restore.hpp" #include -#include extern FilteredNdbOut err; extern FilteredNdbOut info; diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restore.hpp b/ndb/tools/restore/consumer_restore.hpp similarity index 100% rename from ndb/src/kernel/blocks/backup/restore/consumer_restore.hpp rename to ndb/tools/restore/consumer_restore.hpp diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restorem.cpp b/ndb/tools/restore/consumer_restorem.cpp similarity index 100% rename from ndb/src/kernel/blocks/backup/restore/consumer_restorem.cpp rename to ndb/tools/restore/consumer_restorem.cpp diff --git a/ndb/src/kernel/blocks/backup/restore/main.cpp b/ndb/tools/restore/main.cpp similarity index 100% rename from ndb/src/kernel/blocks/backup/restore/main.cpp rename to ndb/tools/restore/main.cpp diff --git a/ndb/tools/waiter.cpp b/ndb/tools/waiter.cpp index be572d7c275..e24164ea807 100644 --- a/ndb/tools/waiter.cpp +++ b/ndb/tools/waiter.cpp @@ -23,12 +23,13 @@ #include #include #include -#include "../include/mgmcommon/LocalConfig.hpp" +#include #include int -waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, unsigned int _timeout); +waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, + unsigned int _timeout); static const char* opt_connect_str= 0; static int _no_contact = 0; From 6a8bfdbe106c9f61abb765f0b4703339c8f4d1ab Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 14 Nov 2004 17:18:31 +0100 Subject: [PATCH 3/8] allowing --master-data without arg to be compatible with < 4.1.8 mysqldump. --- client/mysqldump.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 83967d62813..540f0d78c50 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -254,7 +254,7 @@ static struct my_option my_long_options[] = "any action on logs will happen at the exact moment of the dump." "Option automatically turns --lock-tables off.", (gptr*) &opt_master_data, (gptr*) &opt_master_data, 0, - GET_UINT, REQUIRED_ARG, 0, 0, MYSQL_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0}, + GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0}, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "", (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, @@ -548,6 +548,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case '?': usage(); exit(0); + case (int) OPT_MASTER_DATA: + if (!argument) /* work like in old versions */ + opt_master_data= MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL; + break; case (int) OPT_OPTIMIZE: extended_insert= opt_drop= opt_lock= quick= create_options= opt_disable_keys= lock_tables= opt_set_charset= 1; From ce85816690ce8a7cc52a4010463bf33a8d231a0f Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 14 Nov 2004 17:45:37 +0100 Subject: [PATCH 4/8] Try to lower the probability of a stall of mysqldump AND most client connections, when mysqldump does a FLUSH TABLES WITH READ LOCK (doing FLUSH TABLES first). client/mysqldump.c: try to lower the probability of a stall of mysqldump AND most client connections, when mysqldump does a FLUSH TABLES WITH READ LOCK (doing FLUSH TABLES first). --- client/mysqldump.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 540f0d78c50..498a10041a9 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2050,8 +2050,18 @@ static int do_show_master_status(MYSQL *mysql_con) static int do_flush_tables_read_lock(MYSQL *mysql_con) { + /* + We do first a FLUSH TABLES. If a long update is running, the FLUSH TABLES + will wait but will not stall the whole mysqld, and when the long update is + done the FLUSH TABLES WITH READ LOCK will start and succeed quickly. So, + FLUSH TABLES is to lower the probability of a stage where both mysqldump + and most client connections are stalled. Of course, if a second long + update starts between the two FLUSHes, we have that bad stall. + */ return - mysql_query_with_error_report(mysql_con, 0, "FLUSH TABLES WITH READ LOCK"); + ( mysql_query_with_error_report(mysql_con, 0, "FLUSH TABLES") || + mysql_query_with_error_report(mysql_con, 0, + "FLUSH TABLES WITH READ LOCK") ); } From fe37a1472c22b0a48244b932664925cad68f3e96 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Nov 2004 12:20:05 +0000 Subject: [PATCH 5/8] always let traffic through to api cluster manager in transporter print some info event on api connects with wrong versions BitKeeper/deleted/.del-Makefile.am~91c159ff4011609: Delete: ndb/tools/restore/Makefile.am ndb/src/common/transporter/TransporterRegistry.cpp: let traffic through to api cluster manager as well ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: print some info event on api connects with wrong versions --- .../common/transporter/TransporterRegistry.cpp | 12 +++++++----- ndb/src/kernel/blocks/qmgr/QmgrMain.cpp | 14 ++++++++++++-- ndb/tools/restore/Makefile.am | 16 ---------------- 3 files changed, 19 insertions(+), 23 deletions(-) delete mode 100644 ndb/tools/restore/Makefile.am diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index cacbbed00f1..a2fab8f9806 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -467,8 +467,9 @@ TransporterRegistry::prepareSend(const SignalHeader * const signalHeader, Transporter *t = theTransporters[nodeId]; if(t != NULL && (((ioStates[nodeId] != HaltOutput) && (ioStates[nodeId] != HaltIO)) || - (signalHeader->theReceiversBlockNumber == 252))) { - + ((signalHeader->theReceiversBlockNumber == 252) || + (signalHeader->theReceiversBlockNumber == 4002)))) { + if(t->isConnected()){ Uint32 lenBytes = t->m_packer.getMessageLength(signalHeader, ptr); if(lenBytes <= MAX_MESSAGE_SIZE){ @@ -538,8 +539,9 @@ TransporterRegistry::prepareSend(const SignalHeader * const signalHeader, Transporter *t = theTransporters[nodeId]; if(t != NULL && (((ioStates[nodeId] != HaltOutput) && (ioStates[nodeId] != HaltIO)) || - (signalHeader->theReceiversBlockNumber == 252))) { - + ((signalHeader->theReceiversBlockNumber == 252)|| + (signalHeader->theReceiversBlockNumber == 4002)))) { + if(t->isConnected()){ Uint32 lenBytes = t->m_packer.getMessageLength(signalHeader, ptr); if(lenBytes <= MAX_MESSAGE_SIZE){ @@ -550,7 +552,7 @@ TransporterRegistry::prepareSend(const SignalHeader * const signalHeader, return SEND_OK; } - + /** * @note: on linux/i386 the granularity is 10ms * so sleepTime = 2 generates a 10 ms sleep. diff --git a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index 41deb3403c8..a433d72744e 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -1934,17 +1934,27 @@ void Qmgr::execAPI_REGREQ(Signal* signal) switch(getNodeInfo(apiNodePtr.i).getType()){ case NodeInfo::API: compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version); + if (!compatability_check) + infoEvent("Connection attempt from api or mysqld id=%d with %s " + "incompatible with %s", apiNodePtr.i, + getVersionString(version,""), NDB_VERSION_STRING); break; case NodeInfo::MGM: compatability_check = ndbCompatible_ndb_mgmt(NDB_VERSION, version); + if (!compatability_check) + infoEvent("Connection attempt from management server id=%d with %s " + "incompatible with %s", apiNodePtr.i, + getVersionString(version,""), NDB_VERSION_STRING); break; case NodeInfo::REP: - compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version); - break; + // compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version); + // break; case NodeInfo::DB: case NodeInfo::INVALID: default: sendApiRegRef(signal, ref, ApiRegRef::WrongType); + infoEvent("Invalid connection attempt with type %d", + getNodeInfo(apiNodePtr.i).getType()); return; } diff --git a/ndb/tools/restore/Makefile.am b/ndb/tools/restore/Makefile.am deleted file mode 100644 index 16550f13546..00000000000 --- a/ndb/tools/restore/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ - -ndbtools_PROGRAMS = ndb_restore - -ndb_restore_SOURCES = main.cpp consumer.cpp consumer_restore.cpp consumer_printer.cpp Restore.cpp - -LDADD_LOC = \ - $(top_builddir)/ndb/src/libndbclient.la \ - $(top_builddir)/dbug/libdbug.a \ - $(top_builddir)/mysys/libmysys.a \ - $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@ - -include $(top_srcdir)/ndb/config/common.mk.am - -INCLUDES += -I.. -I$(top_srcdir)/include -I$(top_srcdir)/ndb/include -I$(top_srcdir)/ndb/src/ndbapi -I$(top_srcdir)/ndb/include/ndbapi -I$(top_srcdir)/ndb/include/util -I$(top_srcdir)/ndb/include/portlib -I$(top_srcdir)/ndb/include/kernel - -ndb_restore_LDFLAGS = @ndb_bin_am_ldflags@ From 595d467d0c8052c507894fce843a39fdca3070ce Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Nov 2004 12:40:32 +0000 Subject: [PATCH 6/8] changed compile order, mysqladmin with ndbcluster extensions needs ndb to be compiled first added libs variable for ndbmgmclient used by mysqladmin add linkage with @ndb_mgmclient_libs@ additional options for ndbcluster added support for managing the cluster to mysqladmin added DEFINE_CXA_PURE_VIRTUAL flag to CFLAGS to enable linkage with c++ libs use macros for C_MODE_START/END so that define of FIX_GCC_LINKING_PROBLEM works in c-programs Makefile.am: changed compile order, mysqladming with ndbcluster extensions needs ndb to be compiled first acinclude.m4: added libs variable for ndbmgmclient used by mysqladmin client/Makefile.am: add linkage with @ndb_mgmclient_libs@ client/client_priv.h: additional options for ndbcluster client/mysqladmin.c: added support for managing the cluster to mysqladmin configure.in: added DEFINE_CXA_PURE_VIRTUAL flag to CFLAGS to enable linkage with c++ libs include/my_global.h: use macros for C_MODE_START/END so that define of FIX_GCC_LINKING_PROBLEM works in c-programs --- Makefile.am | 8 ++++---- acinclude.m4 | 3 +++ client/Makefile.am | 3 ++- client/client_priv.h | 3 +++ client/mysqladmin.c | 47 +++++++++++++++++++++++++++++++++++++++++++- configure.in | 1 + include/my_global.h | 4 ++-- 7 files changed, 61 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0dbb5032e15..0770854f176 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,15 +22,15 @@ AUTOMAKE_OPTIONS = foreign EXTRA_DIST = INSTALL-SOURCE README COPYING EXCEPTIONS-CLIENT SUBDIRS = . include @docs_dirs@ @zlib_dir@ \ @readline_topdir@ sql-common \ - @thread_dirs@ pstack @sql_client_dirs@ \ - @sql_server_dirs@ scripts man tests \ + @thread_dirs@ pstack \ + @sql_server_dirs@ @sql_client_dirs@ scripts man tests \ netware @libmysqld_dirs@ \ @bench_dirs@ support-files @fs_dirs@ @tools_dirs@ DIST_SUBDIRS = . include @docs_dirs@ zlib \ @readline_topdir@ sql-common \ - @thread_dirs@ pstack @sql_client_dirs@ \ - @sql_server_dirs@ scripts @man_dirs@ tests SSL\ + @thread_dirs@ pstack \ + @sql_server_dirs@ @sql_client_dirs@ scripts @man_dirs@ tests SSL\ BUILD netware os2 @libmysqld_dirs@ \ @bench_dirs@ support-files @fs_dirs@ @tools_dirs@ diff --git a/acinclude.m4 b/acinclude.m4 index 448bf7a2653..81917372206 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1678,6 +1678,7 @@ AC_DEFUN([MYSQL_CHECK_NDBCLUSTER], [ have_ndbcluster=no ndbcluster_includes= ndbcluster_libs= + ndb_mgmclient_libs= case "$ndbcluster" in yes ) AC_MSG_RESULT([Using NDB Cluster]) @@ -1686,6 +1687,7 @@ AC_DEFUN([MYSQL_CHECK_NDBCLUSTER], [ ndbcluster_includes="-I../ndb/include -I../ndb/include/ndbapi" ndbcluster_libs="\$(top_builddir)/ndb/src/.libs/libndbclient.a" ndbcluster_system_libs="" + ndb_mgmclient_libs="\$(top_builddir)/ndb/src/mgmclient/libndbmgmclient.la" MYSQL_CHECK_NDB_OPTIONS ;; * ) @@ -1697,6 +1699,7 @@ AC_DEFUN([MYSQL_CHECK_NDBCLUSTER], [ AC_SUBST(ndbcluster_includes) AC_SUBST(ndbcluster_libs) AC_SUBST(ndbcluster_system_libs) + AC_SUBST(ndb_mgmclient_libs) ]) dnl --------------------------------------------------------------------------- diff --git a/client/Makefile.am b/client/Makefile.am index a9da284a753..58398548b75 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -20,7 +20,8 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/regex \ $(openssl_includes) LIBS = @CLIENT_LIBS@ -DEPLIB= ../libmysql/libmysqlclient.la +DEPLIB= ../libmysql/libmysqlclient.la \ + @ndb_mgmclient_libs@ LDADD = @CLIENT_EXTRA_LDFLAGS@ $(DEPLIB) bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \ mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc mysqlmanager-pwgen diff --git a/client/client_priv.h b/client/client_priv.h index f16ec0e802b..184eed241ed 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -46,4 +46,7 @@ enum options_client OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_CREATE_OPTIONS, OPT_START_POSITION, OPT_STOP_POSITION, OPT_START_DATETIME, OPT_STOP_DATETIME, OPT_SIGINT_IGNORE, OPT_HEXBLOB +#ifdef HAVE_NDBCLUSTER_DB + ,OPT_NDBCLUSTER,OPT_NDB_CONNECTSTRING +#endif }; diff --git a/client/mysqladmin.c b/client/mysqladmin.c index 6258b9685a5..a32dfa14d28 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -16,7 +16,6 @@ /* maintaince of mysql databases */ - #include "client_priv.h" #include #ifdef THREAD @@ -25,6 +24,10 @@ #include #include +#ifdef HAVE_NDBCLUSTER_DB +#include "../ndb/src/mgmclient/ndb_mgmclient.h" +#endif + #define ADMIN_VERSION "8.41" #define MAX_MYSQL_VAR 256 #define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */ @@ -42,6 +45,10 @@ static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations, opt_count_iterations= 0; static ulong opt_connect_timeout, opt_shutdown_timeout; static my_string unix_port=0; +#ifdef HAVE_NDBCLUSTER_DB +static my_bool opt_ndbcluster=0; +static char *opt_ndb_connectstring=0; +#endif #ifdef HAVE_SMEM static char *shared_memory_base_name=0; @@ -94,6 +101,9 @@ enum commands { ADMIN_PING, ADMIN_EXTENDED_STATUS, ADMIN_FLUSH_STATUS, ADMIN_FLUSH_PRIVILEGES, ADMIN_START_SLAVE, ADMIN_STOP_SLAVE, ADMIN_FLUSH_THREADS, ADMIN_OLD_PASSWORD +#ifdef HAVE_NDBCLUSTER_DB + ,ADMIN_NDB_MGM +#endif }; static const char *command_names[]= { "create", "drop", "shutdown", @@ -104,6 +114,9 @@ static const char *command_names[]= { "ping", "extended-status", "flush-status", "flush-privileges", "start-slave", "stop-slave", "flush-threads","old-password", +#ifdef HAVE_NDBCLUSTER_DB + "ndb-mgm", +#endif NullS }; @@ -184,6 +197,14 @@ static struct my_option my_long_options[] = {"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", (gptr*) &opt_shutdown_timeout, (gptr*) &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG, SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0}, +#ifdef HAVE_NDBCLUSTER_DB + {"ndbcluster", OPT_NDBCLUSTER, "" + "", (gptr*) &opt_ndbcluster, + (gptr*) &opt_ndbcluster, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"ndb-connectstring", OPT_NDB_CONNECTSTRING, "" + "", (gptr*) &opt_ndb_connectstring, + (gptr*) &opt_ndb_connectstring, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, +#endif { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -882,6 +903,24 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) } mysql->reconnect=1; /* Automatic reconnect is default */ break; +#ifdef HAVE_NDBCLUSTER_DB + case ADMIN_NDB_MGM: + { + if (argc < 2) + { + my_printf_error(0,"Too few arguments to ndb-mgm",MYF(ME_BELL)); + return 1; + } + { + Ndb_mgmclient_handle cmd= + ndb_mgmclient_handle_create(opt_ndb_connectstring); + ndb_mgmclient_execute(cmd, --argc, ++argv); + ndb_mgmclient_handle_destroy(cmd); + } + argc= 0; + } + break; +#endif default: my_printf_error(0,"Unknown command: '%-.60s'",MYF(ME_BELL),argv[0]); return 1; @@ -1248,3 +1287,9 @@ static my_bool wait_pidfile(char *pidfile, time_t last_modified, } DBUG_RETURN(error); } +#ifdef HAVE_NDBCLUSTER_DB +/* lib linked in contains c++ code */ +#ifdef __GNUC__ +FIX_GCC_LINKING_PROBLEM +#endif +#endif diff --git a/configure.in b/configure.in index 1fcba6b8f5f..f360ee46453 100644 --- a/configure.in +++ b/configure.in @@ -399,6 +399,7 @@ then then if $CXX -v 2>&1 | grep 'version 3' > /dev/null 2>&1 then + CFLAGS="$CFLAGS -DDEFINE_CXA_PURE_VIRTUAL" CXXFLAGS="$CXXFLAGS -DUSE_MYSYS_NEW -DDEFINE_CXA_PURE_VIRTUAL" fi fi diff --git a/include/my_global.h b/include/my_global.h index 07d4d8dc1cc..ff59f7bfc55 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -194,10 +194,10 @@ C_MODE_END /* Fix problem when linking c++ programs with gcc 3.x */ #ifdef DEFINE_CXA_PURE_VIRTUAL #define FIX_GCC_LINKING_PROBLEM \ -extern "C" { int __cxa_pure_virtual() {\ +C_MODE_START int __cxa_pure_virtual() {\ DBUG_ASSERT("Pure virtual method called." == "Aborted");\ return 0;\ -} } +} C_MODE_END #else #define FIX_GCC_LINKING_PROBLEM #endif From 58f984add28bba67add38efb0c19d67a154b47ea Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Nov 2004 17:03:54 +0100 Subject: [PATCH 7/8] BUG#6353 V2: Replication using replicate-rewrite-db did not work for LOAD DATA INFILE. Now is does. There was one place in the code that used current database instead of the rewrite database. mysql-test/r/rpl_rewrite_db.result: New tests mysql-test/t/rpl_rewrite_db-slave.opt: New tests mysql-test/t/rpl_rewrite_db.test: New tests sql/log_event.cc: Added db to set_fields function so that current db is used. sql/log_event.h: Added db to set_fields function so that current db is used. --- mysql-test/r/rpl_rewrite_db.result | 70 +++++++++++++++++++++++++++ mysql-test/t/rpl_rewrite_db-slave.opt | 2 +- mysql-test/t/rpl_rewrite_db.test | 58 ++++++++++++++++++++++ sql/log_event.cc | 26 ++++++---- sql/log_event.h | 2 +- 5 files changed, 146 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/rpl_rewrite_db.result b/mysql-test/r/rpl_rewrite_db.result index 2804b98dea1..a2c8706e3e1 100644 --- a/mysql-test/r/rpl_rewrite_db.result +++ b/mysql-test/r/rpl_rewrite_db.result @@ -20,3 +20,73 @@ a 9 drop table t1; drop database mysqltest1; +drop database if exists rewrite; +create database rewrite; +use test; +create table t1 (a date, b date, c date not null, d date); +load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ','; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'd' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'd' at row 2 +load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; +select * from rewrite.t1; +a b c d +0000-00-00 NULL 0000-00-00 0000-00-00 +0000-00-00 0000-00-00 0000-00-00 0000-00-00 +2003-03-03 2003-03-03 2003-03-03 NULL +2003-03-03 2003-03-03 2003-03-03 NULL +truncate table t1; +load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); +Warnings: +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'd' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'd' at row 2 +select * from rewrite.t1; +a b c d +NULL NULL 0000-00-00 0000-00-00 +NULL 0000-00-00 0000-00-00 0000-00-00 +NULL 2003-03-03 2003-03-03 NULL +drop table t1; +create table t1 (a text, b text); +load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; +Warnings: +Warning 1261 Row 3 doesn't contain data for all columns +select concat('|',a,'|'), concat('|',b,'|') from rewrite.t1; +concat('|',a,'|') concat('|',b,'|') +|Field A| |Field B| +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +drop table t1; +create table t1 (a int, b char(10)); +load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; +Warnings: +Warning 1265 Data truncated for column 'a' at row 3 +Warning 1262 Row 3 was truncated; it contained more data than there were input columns +Warning 1265 Data truncated for column 'a' at row 5 +Warning 1262 Row 5 was truncated; it contained more data than there were input columns +select * from rewrite.t1; +a b +1 row 1 +2 row 2 +0 1234567890 +3 row 3 +0 1234567890 +truncate table t1; +load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; +Warnings: +Warning 1265 Data truncated for column 'a' at row 4 +Warning 1261 Row 4 doesn't contain data for all columns +select * from rewrite.t1; +a b +1 row 1 +2 row 2 +3 row 3 +0 +drop table t1; diff --git a/mysql-test/t/rpl_rewrite_db-slave.opt b/mysql-test/t/rpl_rewrite_db-slave.opt index b9cd29e9205..a462ad19ba0 100644 --- a/mysql-test/t/rpl_rewrite_db-slave.opt +++ b/mysql-test/t/rpl_rewrite_db-slave.opt @@ -1 +1 @@ -"--replicate-rewrite-db=mysqltest1->test" +"--replicate-rewrite-db=test->rewrite" "--replicate-rewrite-db=mysqltest1->test" diff --git a/mysql-test/t/rpl_rewrite_db.test b/mysql-test/t/rpl_rewrite_db.test index 4cc8ae4b676..b6118854037 100644 --- a/mysql-test/t/rpl_rewrite_db.test +++ b/mysql-test/t/rpl_rewrite_db.test @@ -17,3 +17,61 @@ drop table t1; drop database mysqltest1; sync_slave_with_master; +# +# BUG#6353: +# Option --replicate-rewrite-db should work together with LOAD DATA INFILE +# + +connection slave; +--disable_warnings +drop database if exists rewrite; +--enable_warnings +create database rewrite; + +connection master; +use test; +create table t1 (a date, b date, c date not null, d date); +load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ','; +load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; +sync_slave_with_master; + +connection slave; +select * from rewrite.t1; + +connection master; +truncate table t1; +load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); +sync_slave_with_master; + +connection slave; +select * from rewrite.t1; + +connection master; +drop table t1; +create table t1 (a text, b text); +load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; +sync_slave_with_master; + +connection slave; +select concat('|',a,'|'), concat('|',b,'|') from rewrite.t1; + +connection master; +drop table t1; +create table t1 (a int, b char(10)); +load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; +sync_slave_with_master; + +connection slave; +select * from rewrite.t1; + +connection master; +truncate table t1; +load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; +sync_slave_with_master; + +connection slave; +# The empty line last comes from the end line field in the file +select * from rewrite.t1; + +connection master; +drop table t1; diff --git a/sql/log_event.cc b/sql/log_event.cc index 091566c5d90..301c8ec222c 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1655,16 +1655,22 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db, /* Load_log_event::set_fields() + + Note that this function can not use the member variable + for the database, since LOAD DATA INFILE on the slave + can be for a different database than the current one. + This is the reason for the affected_db argument to this method. */ #ifndef MYSQL_CLIENT -void Load_log_event::set_fields(List &field_list) +void Load_log_event::set_fields(const char* affected_db, + List &field_list) { uint i; const char* field = fields; for (i= 0; i < num_fields; i++) { - field_list.push_back(new Item_field(db, table_name, field)); + field_list.push_back(new Item_field(affected_db, table_name, field)); field+= field_lens[i] + 1; } } @@ -1820,7 +1826,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, ex.skip_lines = skip_lines; List field_list; - set_fields(field_list); + set_fields(thd->db,field_list); thd->variables.pseudo_thread_id= thread_id; if (net) { @@ -1837,13 +1843,13 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, if (thd->cuted_fields) { /* log_pos is the position of the LOAD event in the master log */ - sql_print_error("\ -Slave: load data infile on table '%s' at log position %s in log \ -'%s' produced %ld warning(s). Default database: '%s'", - (char*) table_name, - llstr(log_pos,llbuff), RPL_LOG_NAME, - (ulong) thd->cuted_fields, - print_slave_db_safe(thd->db)); + sql_print_warning("Slave: load data infile on table '%s' at " + "log position %s in log '%s' produced %ld " + "warning(s). Default database: '%s'", + (char*) table_name, + llstr(log_pos,llbuff), RPL_LOG_NAME, + (ulong) thd->cuted_fields, + print_slave_db_safe(thd->db)); } if (net) net->pkt_nr= thd->net.pkt_nr; diff --git a/sql/log_event.h b/sql/log_event.h index 8070c334d8b..1606659e21e 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -587,7 +587,7 @@ public: const char* table_name_arg, List& fields_arg, enum enum_duplicates handle_dup, bool using_trans); - void set_fields(List &fields_arg); + void set_fields(const char* db, List &fields_arg); const char* get_db() { return db; } #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); From b478635110d05f644c7fcca476f5cfc6c9ba1e40 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Nov 2004 21:26:16 +0400 Subject: [PATCH 8/8] Bug#6608: MySQL server crash in some query with tis620 character set. The bug was that the function allocates 'a', then changes the value of 'a' with the operator ++, and then tries to free 'a'! --- mysql-test/r/ctype_tis620.result | 38 ++++++++++++++++++++++++++++++++ mysql-test/t/ctype_tis620.test | 35 +++++++++++++++++++++++++++++ strings/ctype-tis620.c | 10 +++------ 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/ctype_tis620.result b/mysql-test/r/ctype_tis620.result index 1fece515f9f..fa99c2d1318 100644 --- a/mysql-test/r/ctype_tis620.result +++ b/mysql-test/r/ctype_tis620.result @@ -2899,3 +2899,41 @@ hex(a) STRCMP(a,'a') STRCMP(a,'a ') 6109 -1 -1 61 0 0 DROP TABLE t1; +CREATE TABLE t1 ( +`id` int(11) NOT NULL auto_increment, +`url` varchar(200) NOT NULL default '', +`name` varchar(250) NOT NULL default '', +`type` int(11) NOT NULL default '0', +`website` varchar(250) NOT NULL default '', +`adddate` date NOT NULL default '0000-00-00', +`size` varchar(20) NOT NULL default '', +`movieid` int(11) NOT NULL default '0', +`musicid` int(11) NOT NULL default '0', +`star` varchar(20) NOT NULL default '', +`download` int(11) NOT NULL default '0', +`lastweek` int(11) NOT NULL default '0', +`thisweek` int(11) NOT NULL default '0', +`page` varchar(250) NOT NULL default '', +PRIMARY KEY (`id`), +UNIQUE KEY `url` (`url`) +) CHARACTER SET tis620; +INSERT INTO t1 VALUES +(1,'http://www.siamzone.com/download/download/000001-frodo_1024.jpg','The Lord +of the Rings +Wallpapers',1,'http://www.lordoftherings.net','2002-01-22','',448,0,'',3805,0,0, +''); +INSERT INTO t1 VALUES (2,'http://www.othemovie.com/OScreenSaver1.EXE','O +Screensaver',2,'','2002-01-22','',491,0,'',519,0,0,''); +INSERT INTO t1 VALUES +(3,'http://www.siamzone.com/download/download/000003-jasonx2(800x600).jpg','Jaso +n X Wallpapers',1,'','2002-05-31','',579,0,'',1091,0,0,''); +select * from t1 order by id; +id url name type website adddate size movieid musicid star download lastweek thisweek page +1 http://www.siamzone.com/download/download/000001-frodo_1024.jpg The Lord +of the Rings +Wallpapers 1 http://www.lordoftherings.net 2002-01-22 448 0 3805 0 0 +2 http://www.othemovie.com/OScreenSaver1.EXE O +Screensaver 2 2002-01-22 491 0 519 0 0 +3 http://www.siamzone.com/download/download/000003-jasonx2(800x600).jpg Jaso +n X Wallpapers 1 2002-05-31 579 0 1091 0 0 +DROP TABLE t1; diff --git a/mysql-test/t/ctype_tis620.test b/mysql-test/t/ctype_tis620.test index 92a9eada05f..21ec314dca7 100644 --- a/mysql-test/t/ctype_tis620.test +++ b/mysql-test/t/ctype_tis620.test @@ -116,3 +116,38 @@ CREATE TABLE t1 (a char(10) not null) CHARACTER SET tis620; INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a '); SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1; DROP TABLE t1; + +# +# Bug#6608 +# +CREATE TABLE t1 ( + `id` int(11) NOT NULL auto_increment, + `url` varchar(200) NOT NULL default '', + `name` varchar(250) NOT NULL default '', + `type` int(11) NOT NULL default '0', + `website` varchar(250) NOT NULL default '', + `adddate` date NOT NULL default '0000-00-00', + `size` varchar(20) NOT NULL default '', + `movieid` int(11) NOT NULL default '0', + `musicid` int(11) NOT NULL default '0', + `star` varchar(20) NOT NULL default '', + `download` int(11) NOT NULL default '0', + `lastweek` int(11) NOT NULL default '0', + `thisweek` int(11) NOT NULL default '0', + `page` varchar(250) NOT NULL default '', + PRIMARY KEY (`id`), + UNIQUE KEY `url` (`url`) +) CHARACTER SET tis620; + +INSERT INTO t1 VALUES +(1,'http://www.siamzone.com/download/download/000001-frodo_1024.jpg','The Lord +of the Rings +Wallpapers',1,'http://www.lordoftherings.net','2002-01-22','',448,0,'',3805,0,0, +''); +INSERT INTO t1 VALUES (2,'http://www.othemovie.com/OScreenSaver1.EXE','O +Screensaver',2,'','2002-01-22','',491,0,'',519,0,0,''); +INSERT INTO t1 VALUES +(3,'http://www.siamzone.com/download/download/000003-jasonx2(800x600).jpg','Jaso +n X Wallpapers',1,'','2002-05-31','',579,0,'',1091,0,0,''); +select * from t1 order by id; +DROP TABLE t1; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index a2ba4783591..68bfefafe6a 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -562,17 +562,13 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)), const uchar *b0, uint b_length) { uchar buf[80] ; - uchar *end, *a, *b; + uchar *end, *a, *b, *alloced= NULL; uint length; int res= 0; - int alloced= 0; a= buf; if ((a_length + b_length +2) > (int) sizeof(buf)) - { - a= (uchar*) malloc(a_length+b_length); - alloced= 1; - } + alloced= a= (uchar*) malloc(a_length+b_length); b= a + a_length+1; memcpy((char*) a, (char*) a0, a_length); @@ -618,7 +614,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)), ret: if (alloced) - free(a); + free(alloced); return res; }