diff options
author | Sven Sandberg <sven@mysql.com> | 2008-07-06 19:07:30 +0200 |
---|---|---|
committer | Sven Sandberg <sven@mysql.com> | 2008-07-06 19:07:30 +0200 |
commit | d9249cad45ab281e235b7c8b8f3fc89feef5c1d5 (patch) | |
tree | 863c48cef3323705adc937eec09a0ba909568f00 /client | |
parent | 43e396c8d58035e98afd3942dc893766bd2a60dd (diff) | |
parent | 2ed83dd95ff3e142c37cb098a39422205cd14b21 (diff) | |
download | mariadb-git-d9249cad45ab281e235b7c8b8f3fc89feef5c1d5.tar.gz |
Merge 5.1 -> 5.1-rpl
Diffstat (limited to 'client')
-rwxr-xr-x | client/CMakeLists.txt | 8 | ||||
-rw-r--r-- | client/Makefile.am | 12 | ||||
-rw-r--r-- | client/mysql.cc | 42 | ||||
-rw-r--r-- | client/mysqltest.c | 110 |
4 files changed, 130 insertions, 42 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index a20db4134c2..cbd4a1f306b 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -15,7 +15,7 @@ INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") # We use the "mysqlclient_notls" library here just as safety, in case -# any of the clients here would go beond the client API and access the +# any of the clients here would go beyond the client API and access the # Thread Local Storage directly. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") @@ -32,9 +32,9 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c) TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32) -ADD_EXECUTABLE(mysqltest mysqltest.c ../mysys/my_getsystime.c - ../mysys/my_copy.c ../mysys/my_mkdir.c) -TARGET_LINK_LIBRARIES(mysqltest mysqlclient_notls regex wsock32) +ADD_EXECUTABLE(mysqltest mysqltest.c) +SET_SOURCE_FILES_PROPERTIES(mysqltest.c PROPERTIES COMPILE_FLAGS "-DTHREADS") +TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex wsock32 dbug) ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient_notls wsock32) diff --git a/client/Makefile.am b/client/Makefile.am index c57a5673367..940766ac66c 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -86,11 +86,13 @@ mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ $(LIBMYSQLCLIENT_LA) \ $(top_builddir)/mysys/libmysys.a -mysqltest_SOURCES= mysqltest.c \ - $(top_srcdir)/mysys/my_getsystime.c \ - $(top_srcdir)/mysys/my_copy.c \ - $(top_srcdir)/mysys/my_mkdir.c -mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD) +mysqltest_SOURCES= mysqltest.c +mysqltest_CFLAGS= -DTHREAD -UUNDEF_THREADS_HACK +mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ + @CLIENT_EXTRA_LDFLAGS@ \ + $(LIBMYSQLCLIENT_LA) \ + $(top_builddir)/mysys/libmysys.a \ + $(top_builddir)/regex/libregex.a mysql_upgrade_SOURCES= mysql_upgrade.c \ $(top_srcdir)/mysys/my_getpagesize.c diff --git a/client/mysql.cc b/client/mysql.cc index 234180c3c75..73e8973c097 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1821,7 +1821,7 @@ static int read_and_execute(bool interactive) the very beginning of a text file when you save the file using "Unicode UTF-8" format. */ - if (!line_number && + if (line && !line_number && (uchar) line[0] == 0xEF && (uchar) line[1] == 0xBB && (uchar) line[2] == 0xBF) @@ -2101,37 +2101,6 @@ static bool add_line(String &buffer,char *line,char *in_string, continue; } } - else if (!*ml_comment && !*in_string && - (end_of_line - pos) >= 10 && - !my_strnncoll(charset_info, (uchar*) pos, 10, - (const uchar*) "delimiter ", 10)) - { - // Flush previously accepted characters - if (out != line) - { - buffer.append(line, (uint32) (out - line)); - out= line; - } - - // Flush possible comments in the buffer - if (!buffer.is_empty()) - { - if (com_go(&buffer, 0) > 0) // < 0 is not fatal - DBUG_RETURN(1); - buffer.length(0); - } - - /* - Delimiter wants the get rest of the given line as argument to - allow one to change ';' to ';;' and back - */ - buffer.append(pos); - if (com_delimiter(&buffer, pos) > 0) - DBUG_RETURN(1); - - buffer.length(0); - break; - } else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter)) { // Found a statement. Continue parsing after the delimiter @@ -2176,7 +2145,14 @@ static bool add_line(String &buffer,char *line,char *in_string, } else if (!*ml_comment && (!*in_string && (inchar == '#' || inchar == '-' && pos[1] == '-' && - my_isspace(charset_info,pos[2])))) + /* + The third byte is either whitespace or is the + end of the line -- which would occur only + because of the user sending newline -- which is + itself whitespace and should also match. + */ + (my_isspace(charset_info,pos[2]) || + !pos[2])))) { // Flush previously accepted characters if (out != line) diff --git a/client/mysqltest.c b/client/mysqltest.c index aea64c88247..544b3a2bd6a 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -48,7 +48,15 @@ #ifdef __WIN__ #include <direct.h> #endif +#include <signal.h> +#include <my_stacktrace.h> +#ifdef __WIN__ +#include <crtdbg.h> +#define SIGNAL_FMT "exception 0x%x" +#else +#define SIGNAL_FMT "signal %d" +#endif /* Use cygwin for --exec and --system before 5.0 */ #if MYSQL_VERSION_ID < 50000 @@ -214,6 +222,7 @@ struct st_connection /* Used when creating views and sp, to avoid implicit commit */ MYSQL* util_mysql; char *name; + size_t name_len; MYSQL_STMT* stmt; #ifdef EMBEDDED_LIBRARY @@ -4613,6 +4622,7 @@ void do_connect(struct st_command *command) ds_connection_name.str)); if (!(con_slot->name= my_strdup(ds_connection_name.str, MYF(MY_WME)))) die("Out of memory"); + con_slot->name_len= strlen(con_slot->name); cur_con= con_slot; if (con_slot == next_con) @@ -7015,6 +7025,104 @@ void mark_progress(struct st_command* command __attribute__((unused)), } +#ifdef HAVE_STACKTRACE + +static void dump_backtrace(void) +{ + struct st_connection *conn= cur_con; + + my_safe_print_str("read_command_buf", read_command_buf, + sizeof(read_command_buf)); + if (conn) + { + my_safe_print_str("conn->name", conn->name, conn->name_len); +#ifdef EMBEDDED_LIBRARY + my_safe_print_str("conn->cur_query", conn->cur_query, conn->cur_query_len); +#endif + } + fputs("Attempting backtrace...\n", stderr); + my_print_stacktrace(NULL, my_thread_stack_size); +} + +#else + +static void dump_backtrace(void) +{ + fputs("Backtrace not available.\n", stderr); +} + +#endif + +static sig_handler signal_handler(int sig) +{ + fprintf(stderr, "mysqltest got " SIGNAL_FMT "\n", sig); + dump_backtrace(); +} + +#ifdef __WIN__ + +LONG WINAPI exception_filter(EXCEPTION_POINTERS *exp) +{ + __try + { + my_set_exception_pointers(exp); + signal_handler(exp->ExceptionRecord->ExceptionCode); + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + fputs("Got exception in exception handler!\n", stderr); + } + + return EXCEPTION_CONTINUE_SEARCH; +} + + +static void init_signal_handling(void) +{ + UINT mode; + + /* Set output destination of messages to the standard error stream. */ + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); + + /* Do not not display the a error message box. */ + mode= SetErrorMode(0) | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX; + SetErrorMode(mode); + + SetUnhandledExceptionFilter(exception_filter); +} + +#else /* __WIN__ */ + +static void init_signal_handling(void) +{ + struct sigaction sa; + DBUG_ENTER("init_signal_handling"); + +#ifdef HAVE_STACKTRACE + my_init_stacktrace(); +#endif + + sa.sa_flags = SA_RESETHAND | SA_NODEFER; + sigemptyset(&sa.sa_mask); + sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL); + + sa.sa_handler= signal_handler; + + sigaction(SIGSEGV, &sa, NULL); + sigaction(SIGABRT, &sa, NULL); +#ifdef SIGBUS + sigaction(SIGBUS, &sa, NULL); +#endif + sigaction(SIGILL, &sa, NULL); + sigaction(SIGFPE, &sa, NULL); +} + +#endif /* !__WIN__ */ int main(int argc, char **argv) { @@ -7028,6 +7136,8 @@ int main(int argc, char **argv) save_file[0]= 0; TMPDIR[0]= 0; + init_signal_handling(); + /* Init expected errors */ memset(&saved_expected_errors, 0, sizeof(saved_expected_errors)); |