summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc2
-rw-r--r--client/mysqltest.cc27
-rw-r--r--client/sql_string.cc7
3 files changed, 28 insertions, 8 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 26cbbc33c97..4d761945068 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -4325,7 +4325,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/mysqltest.cc b/client/mysqltest.cc
index bb06433d0b0..668d9ba45ba 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -471,6 +471,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];
@@ -2276,9 +2277,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);
@@ -2379,8 +2387,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);
@@ -8259,6 +8274,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);
diff --git a/client/sql_string.cc b/client/sql_string.cc
index 3c2ac139d14..ccb633c6d8e 100644
--- a/client/sql_string.cc
+++ b/client/sql_string.cc
@@ -118,7 +118,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;
@@ -187,7 +187,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