summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/warnings.result27
-rw-r--r--mysql-test/t/warnings.test13
-rw-r--r--sql/protocol.cc6
3 files changed, 46 insertions, 0 deletions
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index a2e99be62ad..222638f64bb 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -1,6 +1,33 @@
drop table if exists t1, t2;
SET SQL_WARNINGS=1;
create table t1 (a int);
+create table t1 (a int);
+ERROR 42S01: Table 't1' already exists
+show count(*) errors;
+@@session.error_count
+1
+show errors;
+Level Code Message
+Error 1050 Table 't1' already exists
+show warnings;
+Level Code Message
+Error 1050 Table 't1' already exists
+create table t2(a int) default charset qwerty;
+ERROR 42000: Unknown character set: 'qwerty'
+show count(*) errors;
+@@session.error_count
+1
+show errors;
+Level Code Message
+Error 1115 Unknown character set: 'qwerty'
+create table t (i);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+show count(*) errors;
+@@session.error_count
+1
+show errors;
+Level Code Message
+Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
insert into t1 values (1);
insert into t1 values ("hej");
Warnings:
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index 67162e7f84b..c71365c3da6 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -7,6 +7,19 @@ drop table if exists t1, t2;
SET SQL_WARNINGS=1;
create table t1 (a int);
+--error 1050
+create table t1 (a int);
+show count(*) errors;
+show errors;
+show warnings;
+--error 1115
+create table t2(a int) default charset qwerty;
+show count(*) errors;
+show errors;
+--error 1064
+create table t (i);
+show count(*) errors;
+show errors;
insert into t1 values (1);
insert into t1 values ("hej");
insert into t1 values ("hej"),("då");
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 657341b8bdc..b84d170873d 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -59,6 +59,7 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
uint length;
char buff[MYSQL_ERRMSG_SIZE+2], *pos;
#endif
+ const char *orig_err= err;
NET *net= &thd->net;
DBUG_ENTER("net_send_error");
DBUG_PRINT("enter",("sql_errno: %d err: %s", sql_errno,
@@ -85,6 +86,7 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
err=ER(sql_errno); /* purecov: inspected */
}
}
+ orig_err= err;
}
#ifdef EMBEDDED_LIBRARY
@@ -123,6 +125,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
}
VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
#endif /* EMBEDDED_LIBRARY*/
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno,
+ orig_err ? orig_err : ER(sql_errno));
thd->is_fatal_error=0; // Error message is given
thd->net.report_error= 0;
@@ -229,6 +233,8 @@ net_printf_error(THD *thd, uint errcode, ...)
strmake(net->last_error, text_pos, length);
strmake(net->sqlstate, mysql_errno_to_sqlstate(errcode), SQLSTATE_LENGTH);
#endif
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, errcode,
+ text_pos ? text_pos : ER(errcode));
thd->is_fatal_error=0; // Error message is given
DBUG_VOID_RETURN;
}