diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index d883feb7ce2..e03d72351d1 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 4bd659606f6..23ab5aa1f05 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 95cd8415c85..4cecd016553 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -58,6 +58,7 @@ void 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("send_error"); DBUG_PRINT("enter",("sql_errno: %d err: %s", sql_errno, @@ -82,6 +83,7 @@ void send_error(THD *thd, uint sql_errno, const char *err) err=ER(sql_errno); /* purecov: inspected */ } } + orig_err= err; } #ifdef EMBEDDED_LIBRARY @@ -120,6 +122,8 @@ void 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; @@ -247,6 +251,8 @@ net_printf(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; }