summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqltest.c51
-rw-r--r--mysql-test/t/create.test2
-rw-r--r--mysql-test/t/select.test4
3 files changed, 46 insertions, 11 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 05ac68e3176..9e887f61160 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -123,6 +123,17 @@ typedef struct
} code;
} match_err;
+typedef struct
+{
+ const char *name;
+ long code;
+} st_error;
+
+static st_error global_error[] = {
+#include <mysqld_ername.h>
+ { 0, 0 }
+};
+
static match_err global_expected_errno[MAX_EXPECTED_ERRORS];
static uint global_expected_errors;
@@ -1340,6 +1351,7 @@ static uint get_errcodes(match_err *to,struct st_query* q)
{
char* p= q->first_argument;
uint count= 0;
+
DBUG_ENTER("get_errcodes");
if (!*p)
@@ -1350,19 +1362,41 @@ static uint get_errcodes(match_err *to,struct st_query* q)
if (*p == 'S')
{
/* SQLSTATE string */
- int i;
- p++;
- for (i = 0; my_isalnum(charset_info, *p) && i < SQLSTATE_LENGTH; p++, i++)
- to[count].code.sqlstate[i]= *p;
- to[count].code.sqlstate[i]= '\0';
+ char *end= ++p + SQLSTATE_LENGTH;
+ char *to_ptr= to[count].code.sqlstate;
+
+ for (; my_isalnum(charset_info, *p) && p != end; p++)
+ *to_ptr++= *p;
+ *to_ptr= 0;
+
to[count].type= ERR_SQLSTATE;
}
+ else if (*p == 'E')
+ {
+ /* SQL error as string */
+ st_error *e= global_error;
+ char *start= p++;
+
+ for (; *p == '_' || my_isalnum(charset_info, *p); p++)
+ ;
+ for (; e->name; e++)
+ {
+ if (!strncmp(start, e->name, (int) (p - start)))
+ {
+ to[count].code.errnum= (uint) e->code;
+ to[count].type= ERR_ERRNO;
+ break;
+ }
+ }
+ if (!e->name)
+ die("Unknown SQL error '%s'\n", start);
+ }
else
{
long val;
- p=str2int(p,10,(long) INT_MIN, (long) INT_MAX, &val);
- if (p == NULL)
- die("Invalid argument in %s\n", q->query);
+
+ if (!(p= str2int(p,10,(long) INT_MIN, (long) INT_MAX, &val)))
+ die("Invalid argument in %s\n", q->query);
to[count].code.errnum= (uint) val;
to[count].type= ERR_ERRNO;
}
@@ -2855,6 +2889,7 @@ static int normal_handle_error(const char *query, struct st_query *q,
mysql_error(mysql));
DBUG_RETURN(0);
}
+ return 0; /* Keep compiler happy */
}
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 686bf5a97ad..26b467a398d 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -294,7 +294,7 @@ select * from t2;
create table t3 like t1;
--error 1050
create table t3 like mysqltest.t3;
---error 1044,1
+--error ER_DBACCESS_DENIED_ERROR,1
create table non_existing_database.t1 like t1;
--error 1051
create table t3 like non_existing_table;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 47b115cf030..a32b9d06ef9 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -1761,9 +1761,9 @@ DO benchmark(100,1+1),1,1;
# Bug #6449: do default;
#
---error 1064
+--error ER_PARSE_ERROR
do default;
---error 1054
+--error ER_BAD_FIELD_ERROR
do foobar;
#