diff options
author | Michael Widenius <monty@askmonty.org> | 2011-12-11 11:34:44 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-12-11 11:34:44 +0200 |
commit | 6d4224a31c9d32c8f8067a4f7d16daa29bcdee6b (patch) | |
tree | 79e3143528495069ad232f673532573b30afe425 /client | |
parent | 3e2cb35e11cb5ee6668d538a62a3b32e017944a5 (diff) | |
parent | 701c0f822abe4ee9eeafd244fa30dc2fcf067b81 (diff) | |
download | mariadb-git-6d4224a31c9d32c8f8067a4f7d16daa29bcdee6b.tar.gz |
Merge with 5.2.
no_error handling for select (used by INSERT ... SELECT) still needs to be fixed, but I will do that in a separate commit
Diffstat (limited to 'client')
-rwxr-xr-x | client/CMakeLists.txt | 3 | ||||
-rw-r--r-- | client/Makefile.am | 8 | ||||
-rw-r--r-- | client/client_priv.h | 6 | ||||
-rw-r--r-- | client/my_readline.h | 6 | ||||
-rw-r--r-- | client/mysql.cc | 4 | ||||
-rw-r--r-- | client/mysql_upgrade.c | 9 | ||||
-rw-r--r-- | client/mysqladmin.cc | 6 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 9 | ||||
-rw-r--r-- | client/mysqlcheck.c | 8 | ||||
-rw-r--r-- | client/mysqldump.c | 8 | ||||
-rw-r--r-- | client/mysqlimport.c | 12 | ||||
-rw-r--r-- | client/mysqlshow.c | 7 | ||||
-rw-r--r-- | client/mysqlslap.c | 5 | ||||
-rw-r--r-- | client/mysqltest.cc | 72 | ||||
-rw-r--r-- | client/readline.cc | 6 | ||||
-rw-r--r-- | client/sql_string.cc | 13 | ||||
-rw-r--r-- | client/sql_string.h | 6 |
17 files changed, 127 insertions, 61 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 886c6c8b65d..2d51bc3fd0f 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,4 +1,5 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc. +# 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 diff --git a/client/Makefile.am b/client/Makefile.am index b71b180d98d..fc6f632b20e 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2000-2006 MySQL AB +# Copyright (c) 2000, 2011, 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,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 # This file is public domain and comes with NO WARRANTY of any kind @@ -118,9 +118,9 @@ link_sources: @LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \ done; \ for f in $(strings_src) ; do \ - rm -f $(srcdir)/$$f; \ + rm -f $$f; \ @LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \ done; \ - rm -f $(srcdir)/my_user.c; \ + rm -f my_user.c; \ @LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c; echo timestamp > link_sources; diff --git a/client/client_priv.h b/client/client_priv.h index 128a7beca6f..d948fb7f98f 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2001-2006 MySQL AB +/* + Copyright (c) 2001, 2011, 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 +12,8 @@ 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 +*/ /* Common defines for all clients */ diff --git a/client/my_readline.h b/client/my_readline.h index 3376fc81761..30e59b613bc 100644 --- a/client/my_readline.h +++ b/client/my_readline.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 2011, 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,7 +12,8 @@ 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 +*/ /* readline for batch mode */ diff --git a/client/mysql.cc b/client/mysql.cc index 765c44e49c9..34995b413b4 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2000-2009 MySQL AB - Copyright 2000, 2010, Oracle and/or its affiliates. + Copyright 2000, 2010-2011, Oracle and/or its affiliates. Copyright 2000-2010 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -4404,7 +4404,7 @@ sql_real_connect(char *host,char *database,char *user,char *password, { char init_command[100]; sprintf(init_command, - "SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=%lu,SQL_MAX_JOIN_SIZE=%lu", + "SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=%lu,MAX_JOIN_SIZE=%lu", select_limit,max_join_size); mysql_options(&mysql, MYSQL_INIT_COMMAND, init_command); } diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index b67ca5456d7..c6e54cba67b 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1,5 +1,7 @@ -/* Copyright (C) 2000 MySQL AB - Copyright (C) 2010 Monty Program Ab +/* + Copyright (C) 2000 MySQL AB + Copyright (c) 2006, 2011, Oracle and/or its affiliates. + Copyright (C) 2010-2011 Monty Program 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 @@ -12,7 +14,8 @@ 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 "client_priv.h" #include <sslopt-vars.h> diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 3cc315ce1bc..0716e391ab4 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* + Copyright (c) 2000, 2011, 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,7 +12,8 @@ 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 +*/ /* maintaince of mysql databases */ diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 6540361aa02..f562f30313c 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2001-2004 MySQL AB +/* + Copyright (c) 2000, 2011, 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,7 +12,8 @@ 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 +*/ /* @@ -1118,7 +1120,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, passed --short-form, because --short-form disables printing row events. */ - if (!print_event_info->printed_fd_event && !short_form) + if (!print_event_info->printed_fd_event && !short_form && + opt_base64_output_mode != BASE64_OUTPUT_DECODE_ROWS) { const char* type_str= ev->get_type_str(); if (opt_base64_output_mode == BASE64_OUTPUT_NEVER) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 22f4b70ed81..8bf6cbe8d83 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1,5 +1,6 @@ /* Copyright (C) 2000 MySQL AB & Jani Tolonen - Copyright (C) 2010 Monty Program Ab + Copyright (c) 2001, 2011, Oracle and/or its affiliates. + Copyright (C) 2010- 2011 Monty Program 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 @@ -12,9 +13,8 @@ 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 */ - -/* By Jani Tolonen, 2001-04-20, MySQL Development Team */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #define CHECK_VERSION "2.7.0" diff --git a/client/mysqldump.c b/client/mysqldump.c index d7d99e0cc17..4acc4c993c5 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,4 +1,5 @@ -/* Copyright 2000-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. +/* + Copyright (c) 2000, 2011, 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,7 +12,8 @@ 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 +*/ /* mysqldump.c - Dump a tables contents and format to an ASCII file ** @@ -571,7 +573,7 @@ static void short_usage_sub(void) static void usage(void) { print_version(); - puts("By Igor Romanenko, Monty, Jani & Sinisa."); + puts("By Igor Romanenko, Monty, Jani & Sinisa and others."); puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n"); puts("Dumping structure and contents of MySQL databases and tables."); short_usage_sub(); diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 3367eb77cbc..654f19f6f57 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc. +/* + Copyright (c) 2000, 2011, 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,7 +12,8 @@ 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 +*/ /* ** mysqlimport.c - Imports all given files @@ -198,10 +200,10 @@ static void print_version(void) static void usage(void) { - print_version(); puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc."); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n"); - printf("\ + puts("Copyright 2008-2011 Oracle and Monty Program Ab."); + print_version(); + printf("\n\ Loads tables from text files in various formats. The base name of the\n\ text file must be the name of the table that should be used.\n\ If one uses sockets to connect to the MySQL server, the server will open and\n\ diff --git a/client/mysqlshow.c b/client/mysqlshow.c index fafb07cfcbb..e1cbfcb9404 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* + Copyright (c) 2000, 2011, 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,7 +12,8 @@ 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 +*/ /* Show databases, tables or columns */ @@ -255,6 +257,7 @@ static void usage(void) { print_version(); puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc."); + puts("Copyright 2008-2011 Oracle and Monty Program Ab."); puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n"); puts("Shows the structure of a MySQL database (databases, tables, and columns).\n"); printf("Usage: %s [OPTIONS] [database [table [column]]]\n",my_progname); diff --git a/client/mysqlslap.c b/client/mysqlslap.c index a876390db27..fa77a69ec81 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2005 MySQL AB, 2009 Sun Microsystems, Inc. +/* + Copyright (c) 2005, 2011, 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,7 +12,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 original idea: Brian Aker via playing with ab for too many years coded by: Patrick Galbraith diff --git a/client/mysqltest.cc b/client/mysqltest.cc index d94023ccd0c..189da40dbf6 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -12,7 +12,8 @@ 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 +*/ /* mysqltest @@ -30,6 +31,7 @@ Monty Jani Holyfoot + And many others */ #define MTEST_VERSION "3.3" @@ -262,7 +264,7 @@ struct st_connection pthread_cond_t cond; pthread_t tid; int query_done; - my_bool has_thread; + my_bool has_thread, mutex_inited; #endif /*EMBEDDED_LIBRARY*/ }; @@ -474,6 +476,7 @@ TYPELIB command_typelib= {array_elements(command_names),"", command_names, 0}; DYNAMIC_STRING ds_res; +struct st_command *curr_command= 0; char builtin_echo[FN_REFLEN]; @@ -782,10 +785,12 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len, if (flags & QUERY_REAP_FLAG) return mysql_send_query(cn->mysql, q, q_len); - if (pthread_mutex_init(&cn->mutex, NULL) || - pthread_cond_init(&cn->cond, NULL)) + if (!cn->mutex_inited && + (pthread_mutex_init(&cn->mutex, NULL) || + pthread_cond_init(&cn->cond, NULL))) die("Error in the thread library"); + cn->mutex_inited= 1; cn->cur_query= q; cn->cur_query_len= q_len; cn->query_done= 0; @@ -815,9 +820,20 @@ static void wait_query_thread_end(struct st_connection *con) } } +static void free_embedded_data(struct st_connection *con) +{ + if (con->mutex_inited) + { + con->mutex_inited= 0; + pthread_mutex_destroy(&con->mutex); + pthread_cond_destroy(&con->cond); + } +} + #else /*EMBEDDED_LIBRARY*/ #define do_send_query(cn,q,q_len,flags) mysql_send_query(cn->mysql, q, q_len) +#define free_embedded_data(next_con) do { } while(0) #endif /*EMBEDDED_LIBRARY*/ @@ -1171,6 +1187,7 @@ void close_connections() if (next_con->util_mysql) mysql_close(next_con->util_mysql); my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR)); + free_embedded_data(next_con); } my_free(connections, MYF(MY_WME)); DBUG_VOID_RETURN; @@ -2288,9 +2305,16 @@ void var_query_set(VAR *var, const char *query, const char** query_end) init_dynamic_string(&ds_query, 0, (end - query) + 32, 256); do_eval(&ds_query, query, end, FALSE); - if (mysql_real_query(mysql, ds_query.str, ds_query.length)) - die("Error running query '%s': %d %s", ds_query.str, - mysql_errno(mysql), mysql_error(mysql)); + if (mysql_real_query(mysql, ds_query.str, ds_query.length)) + { + handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); + /* If error was acceptable, return empty string */ + dynstr_free(&ds_query); + eval_expr(var, "", 0); + DBUG_VOID_RETURN; + } + if (!(res= mysql_store_result(mysql))) die("Query '%s' didn't return a result set", ds_query.str); dynstr_free(&ds_query); @@ -2391,8 +2415,15 @@ void var_set_query_get_value(struct st_command *command, VAR *var) /* Run the query */ if (mysql_real_query(mysql, ds_query.str, ds_query.length)) - die("Error running query '%s': %d %s", ds_query.str, - mysql_errno(mysql), mysql_error(mysql)); + { + handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); + /* If error was acceptable, return empty string */ + dynstr_free(&ds_query); + eval_expr(var, "", 0); + DBUG_VOID_RETURN; + } + if (!(res= mysql_store_result(mysql))) die("Query '%s' didn't return a result set", ds_query.str); @@ -3046,7 +3077,7 @@ void do_remove_file(struct st_command *command) ' '); DBUG_PRINT("info", ("removing file: %s", ds_filename.str)); - error= my_delete(ds_filename.str, MYF(disable_warnings ? 0 : MY_WME)) != 0; + error= my_delete_allow_opened(ds_filename.str, MYF(disable_warnings ? 0 : MY_WME)) != 0; handle_command_error(command, error, my_errno); dynstr_free(&ds_filename); DBUG_VOID_RETURN; @@ -4543,13 +4574,14 @@ static int my_kill(int pid, int sig) command called command DESCRIPTION - shutdown [<timeout>] + shutdown_server [<timeout>] */ void do_shutdown_server(struct st_command *command) { - int timeout=60, pid; + long timeout=60; + int pid; DYNAMIC_STRING ds_pidfile_name; MYSQL* mysql = cur_con->mysql; static DYNAMIC_STRING ds_timeout; @@ -4564,8 +4596,9 @@ void do_shutdown_server(struct st_command *command) if (ds_timeout.length) { - timeout= atoi(ds_timeout.str); - if (timeout == 0) + char* endptr; + timeout= strtol(ds_timeout.str, &endptr, 10); + if (*endptr != '\0') die("Illegal argument for timeout: '%s'", ds_timeout.str); } dynstr_free(&ds_timeout); @@ -4607,7 +4640,7 @@ void do_shutdown_server(struct st_command *command) DBUG_PRINT("info", ("Process %d does not exist anymore", pid)); DBUG_VOID_RETURN; } - DBUG_PRINT("info", ("Sleeping, timeout: %d", timeout)); + DBUG_PRINT("info", ("Sleeping, timeout: %ld", timeout)); my_sleep(1000000L); } @@ -4985,6 +5018,7 @@ void do_close_connection(struct st_command *command) mysql_close(con->mysql); con->mysql= 0; + free_embedded_data(con); if (con->util_mysql) mysql_close(con->util_mysql); @@ -6219,7 +6253,7 @@ void print_version(void) void usage() { print_version(); - printf("MySQL AB, by Sasha, Matt, Monty & Jani\n"); + printf("MySQL AB, by Sasha, Matt, Monty & Jani and others\n"); printf("This software comes with ABSOLUTELY NO WARRANTY\n\n"); printf("Runs a test against the mysql server and compares output with a results file.\n\n"); printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname); @@ -8287,6 +8321,8 @@ int main(int argc, char **argv) { command->last_argument= command->first_argument; processed = 1; + /* Need to remember this for handle_error() */ + curr_command= command; switch (command->type) { case Q_CONNECT: do_connect(command); @@ -9888,7 +9924,7 @@ int find_set(REP_SETS *sets,REP_SET *find) return i; } } - return i; /* return new postion */ + return i; /* return new position */ } /* find if there is a found_set with same table_offset & found_offset @@ -9908,7 +9944,7 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset) found_set[i].table_offset=table_offset; found_set[i].found_offset=found_offset; found_sets++; - return -i-2; /* return new postion */ + return -i-2; /* return new position */ } /* Return 1 if regexp starts with \b or ends with \b*/ diff --git a/client/readline.cc b/client/readline.cc index 5293f7546e4..b44862062e1 100644 --- a/client/readline.cc +++ b/client/readline.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 2011, 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,7 +12,8 @@ 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 +*/ /* readline for batch mode */ diff --git a/client/sql_string.cc b/client/sql_string.cc index 315c8d786db..04379e552e1 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 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,7 +12,8 @@ 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 +*/ /* This file is originally from the mysql distribution. Coded by monty */ @@ -107,7 +109,7 @@ bool String::set(ulonglong num, CHARSET_INFO *cs) bool String::set(double num,uint decimals, CHARSET_INFO *cs) { - char buff[331]; + char buff[FLOATING_POINT_BUFFER]; uint dummy_errors; str_charset=cs; @@ -176,7 +178,10 @@ end: #else #ifdef HAVE_SNPRINTF buff[sizeof(buff)-1]=0; // Safety - snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num); + IF_DBUG(int num_chars= ) + snprintf(buff, sizeof(buff)-1, "%.*f",(int) decimals, num); + DBUG_ASSERT(num_chars > 0); + DBUG_ASSERT(num_chars < (int) sizeof(buff)); #else sprintf(buff,"%.*f",(int) decimals,num); #endif diff --git a/client/sql_string.h b/client/sql_string.h index f15df68b8a3..be5ae5071f8 100644 --- a/client/sql_string.h +++ b/client/sql_string.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 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,7 +12,8 @@ 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 +*/ /* This file is originally from the mysql distribution. Coded by monty */ |