diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 24 | ||||
-rw-r--r-- | client/mysqldump.c | 13 | ||||
-rw-r--r-- | client/mysqltest.cc | 29 | ||||
-rw-r--r-- | client/sql_string.cc | 19 |
4 files changed, 56 insertions, 29 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index a78e422d686..ccbd4583079 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -250,7 +250,7 @@ static COMMANDS commands[] = { { "connect",'r', com_connect,1, "Reconnect to the server. Optional arguments are db and host." }, { "delimiter", 'd', com_delimiter, 1, - "Set statement delimiter. NOTE: Takes the rest of the line as new delimiter." }, + "Set statement delimiter." }, #ifdef USE_POPEN { "edit", 'e', com_edit, 0, "Edit command with $EDITOR."}, #endif @@ -2255,8 +2255,22 @@ static bool add_line(String &buffer,char *line,char *in_string, } if (out != line || !buffer.is_empty()) { - *out++='\n'; uint length=(uint) (out-line); + + if (length < 9 || + my_strnncoll (charset_info, + (uchar *)line, 9, (const uchar *) "delimiter", 9)) + { + /* + Don't add a new line in case there's a DELIMITER command to be + added to the glob buffer (e.g. on processing a line like + "<command>;DELIMITER <non-eof>") : similar to how a new line is + not added in the case when the DELIMITER is the first command + entered with an empty glob buffer. + */ + *out++='\n'; + length++; + } if (buffer.length() + length >= buffer.alloced_length()) buffer.realloc(buffer.length()+length+IO_SIZE); if ((!*ml_comment || preserve_comments) && buffer.append(line, length)) @@ -2280,8 +2294,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end); if not. */ -#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_LIBEDIT_INTERFACE) +#if defined(USE_NEW_READLINE_INTERFACE) extern "C" char *no_completion(const char*,int) +#elif defined(USE_LIBEDIT_INTERFACE) +extern "C" int no_completion(const char*,int) #else extern "C" char *no_completion() #endif @@ -2863,7 +2879,7 @@ com_charset(String *buffer __attribute__((unused)), char *line) param= get_arg(buff, 0); if (!param || !*param) { - return put_info("Usage: \\C char_setname | charset charset_name", + return put_info("Usage: \\C charset_name | charset charset_name", INFO_ERROR, 0); } new_cs= get_charset_by_csname(param, MY_CS_PRIMARY, MYF(MY_WME)); diff --git a/client/mysqldump.c b/client/mysqldump.c index 44c53a0e4c2..0f75f0b7315 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright 2000-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. 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 @@ -1475,7 +1475,8 @@ static int connect_to_db(char *host, char *user,char *passwd) DB_error(&mysql_connection, "when trying to connect"); DBUG_RETURN(1); } - if (mysql_get_server_version(&mysql_connection) < 40100) + if ((mysql_get_server_version(&mysql_connection) < 40100) || + (opt_compatible_mode & 3)) { /* Don't dump SET NAMES with a pre-4.1 server (bug#7997). */ opt_set_charset= 0; @@ -2421,11 +2422,11 @@ static uint get_table_structure(char *table, char *db, char *table_type, row= mysql_fetch_row(result); - fprintf(sql_file, - "SET @saved_cs_client = @@character_set_client;\n" - "SET character_set_client = utf8;\n" + fprintf(sql_file, (opt_compatible_mode & 3) ? "%s;\n" : + "/*!40101 SET @saved_cs_client = @@character_set_client */;\n" + "/*!40101 SET character_set_client = utf8 */;\n" "%s;\n" - "SET character_set_client = @saved_cs_client;\n", + "/*!40101 SET character_set_client = @saved_cs_client */;\n", row[1]); check_io(sql_file); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 7fc7a707480..d1fa33fcf00 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -4676,6 +4676,10 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host, int failed_attempts= 0; DBUG_ENTER("safe_connect"); + + verbose_msg("Connecting to server %s:%d (socket %s) as '%s'" + ", connection '%s', attempt %d ...", + host, port, sock, user, name, failed_attempts); while(!mysql_real_connect(mysql, host,user, pass, db, port, sock, CLIENT_MULTI_STATEMENTS | CLIENT_REMEMBER_OPTIONS)) { @@ -4707,6 +4711,7 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host, } failed_attempts++; } + verbose_msg("... Connected."); DBUG_VOID_RETURN; } @@ -6904,14 +6909,6 @@ end: dynstr_free(&ds_execute_warnings); } - - /* Close the statement if - no reconnect, need new prepare */ - if (mysql->reconnect) - { - mysql_stmt_close(stmt); - cur_con->stmt= NULL; - } - /* We save the return code (mysql_stmt_errno(stmt)) from the last call sent to the server into the mysqltest builtin variable $mysql_errno. This @@ -6920,6 +6917,13 @@ end: var_set_errno(mysql_stmt_errno(stmt)); + /* Close the statement if reconnect, need new prepare */ + if (mysql->reconnect) + { + mysql_stmt_close(stmt); + cur_con->stmt= NULL; + } + DBUG_VOID_RETURN; } @@ -7561,8 +7565,12 @@ int main(int argc, char **argv) parse_args(argc, argv); log_file.open(opt_logdir, result_file_name, ".log"); + verbose_msg("Logging to '%s'.", log_file.file_name()); if (opt_mark_progress) + { progress_file.open(opt_logdir, result_file_name, ".progress"); + verbose_msg("Tracing progress in '%s'.", progress_file.file_name()); + } var_set_int("$PS_PROTOCOL", ps_protocol); var_set_int("$SP_PROTOCOL", sp_protocol); @@ -7571,6 +7579,8 @@ int main(int argc, char **argv) DBUG_PRINT("info",("result_file: '%s'", result_file_name ? result_file_name : "")); + verbose_msg("Results saved in '%s'.", + result_file_name ? result_file_name : ""); if (mysql_server_init(embedded_server_arg_count, embedded_server_args, (char**) embedded_server_groups)) @@ -7641,6 +7651,7 @@ int main(int argc, char **argv) open_file(opt_include); } + verbose_msg("Start processing test commands from '%s' ...", cur_file->file_name); while (!read_command(&command) && !abort_flag) { int current_line_inc = 1, processed = 0; @@ -7958,6 +7969,7 @@ int main(int argc, char **argv) log_file.close(); start_lineno= 0; + verbose_msg("... Done processing test commands."); if (parsing_disabled) die("Test ended with parsing disabled"); @@ -8008,6 +8020,7 @@ int main(int argc, char **argv) if (!command_executed && result_file_name) die("No queries executed but result file found!"); + verbose_msg("Test has succeeded!"); timer_output(); /* Yes, if we got this far the test has suceeded! Sakila smiles */ cleanup_and_exit(0); diff --git a/client/sql_string.cc b/client/sql_string.cc index c41463999aa..5a922b9361c 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -71,25 +71,22 @@ bool String::realloc(uint32 alloc_length) char *new_ptr; if (alloced) { - if ((new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME)))) - { - Ptr=new_ptr; - Alloced_length=len; - } - else - return TRUE; // Signal error + if (!(new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME)))) + return TRUE; // Signal error } else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME)))) { + if (str_length > len - 1) + str_length= 0; if (str_length) // Avoid bugs in memcpy on AIX memcpy(new_ptr,Ptr,str_length); new_ptr[str_length]=0; - Ptr=new_ptr; - Alloced_length=len; alloced=1; } else return TRUE; // Signal error + Ptr= new_ptr; + Alloced_length= len; } Ptr[alloc_length]=0; // This make other funcs shorter return FALSE; @@ -125,7 +122,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs) str_charset=cs; if (decimals >= NOT_FIXED_DEC) { - uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME + uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME return copy(buff, len, &my_charset_latin1, cs, &dummy_errors); } #ifdef HAVE_FCONVERT @@ -677,7 +674,7 @@ void String::qs_append(const char *str, uint32 len) void String::qs_append(double d) { char *buff = Ptr + str_length; - str_length+= my_sprintf(buff, (buff, "%.14g", d)); + str_length+= my_sprintf(buff, (buff, "%.15g", d)); } void String::qs_append(double *d) |