Commit 6cc9f4ac authored by Michael Widenius's avatar Michael Widenius

Added usage of handler error names to mysqltest


include/CMakeLists.txt:
  Added handler_ername.h
include/handler_ername.h:
  Names of handler error messages
mysql-test/extra/binlog_tests/binlog.test:
  Test using handler error names
mysql-test/r/mysqltest.result:
  Update for new error message
mysql-test/t/auto_increment.test:
  Test using handler error names
mysql-test/t/auto_increment_ranges.inc:
  Test using handler error names
mysql-test/t/replace.test:
  Test using handler error names
parent afa49d79
......@@ -5161,11 +5161,17 @@ static st_error global_error_names[] =
{ 0, 0, 0 }
};
uint get_errcode_from_name(char *error_name, char *error_end)
#include <my_base.h>
static st_error handler_error_names[] =
{
/* SQL error as string */
st_error *e= global_error_names;
{ "<No error>", -1U, "" },
#include <handler_ername.h>
{ 0, 0, 0 }
};
uint get_errcode_from_name(const char *error_name, const char *error_end,
st_error *e)
{
DBUG_ENTER("get_errcode_from_name");
DBUG_PRINT("enter", ("error_name: %s", error_name));
......@@ -5183,15 +5189,26 @@ uint get_errcode_from_name(char *error_name, char *error_end)
DBUG_RETURN(e->code);
}
}
if (!e->name)
die("Unknown SQL error name '%s'", error_name);
DBUG_RETURN(0);
}
const char *get_errname_from_code (uint error_code)
uint get_errcode_from_name(const char *error_name, const char *error_end)
{
st_error *e= global_error_names;
uint tmp;
if ((tmp= get_errcode_from_name(error_name, error_end,
global_error_names)))
return tmp;
if ((tmp= get_errcode_from_name(error_name, error_end,
handler_error_names)))
return tmp;
die("Unknown SQL error name '%s'", error_name);
}
const char *unknown_error= "<Unknown>";
const char *get_errname_from_code (uint error_code, st_error *e)
{
DBUG_ENTER("get_errname_from_code");
DBUG_PRINT("enter", ("error_code: %d", error_code));
......@@ -5207,9 +5224,18 @@ const char *get_errname_from_code (uint error_code)
}
}
/* Apparently, errors without known names may occur */
DBUG_RETURN("<Unknown>");
DBUG_RETURN(unknown_error);
}
const char *get_errname_from_code(uint error_code)
{
const char *name;
if ((name= get_errname_from_code(error_code, global_error_names)) !=
unknown_error)
return name;
return get_errname_from_code(error_code, handler_error_names);
}
void do_get_errcodes(struct st_command *command)
{
struct st_match_err *to= saved_expected_errors.err;
......@@ -5294,7 +5320,7 @@ void do_get_errcodes(struct st_command *command)
{
die("The sqlstate definition must start with an uppercase S");
}
else if (*p == 'E')
else if (*p == 'E' || *p == 'H')
{
/* Error name string */
......@@ -5303,9 +5329,9 @@ void do_get_errcodes(struct st_command *command)
to->type= ERR_ERRNO;
DBUG_PRINT("info", ("ERR_ERRNO: %d", to->code.errnum));
}
else if (*p == 'e')
else if (*p == 'e' || *p == 'h')
{
die("The error name definition must start with an uppercase E");
die("The error name definition must start with an uppercase E or H");
}
else
{
......
......@@ -52,6 +52,7 @@ SET(HEADERS
my_attribute.h
my_compiler.h
handler_state.h
handler_ername.h
)
INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)
......
/* Copyright (c) 2013 SkySQL 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
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 Street, Suite 500, Boston, MA 02110-1335 USA */
/* Names of all handler error numbers. Used by mysqltest */
{ "HA_ERR_KEY_NOT_FOUND", HA_ERR_KEY_NOT_FOUND, "" },
{ "HA_ERR_FOUND_DUPP_KEY", HA_ERR_FOUND_DUPP_KEY, "" },
{ "HA_ERR_INTERNAL_ERROR", HA_ERR_INTERNAL_ERROR, "" },
{ "HA_ERR_RECORD_CHANGED", HA_ERR_RECORD_CHANGED, "" },
{ "HA_ERR_WRONG_INDEX", HA_ERR_WRONG_INDEX, "" },
{ "HA_ERR_CRASHED", HA_ERR_CRASHED, "" },
{ "HA_ERR_WRONG_IN_RECORD", HA_ERR_WRONG_IN_RECORD, "" },
{ "HA_ERR_OUT_OF_MEM", HA_ERR_OUT_OF_MEM, "" },
{ "HA_ERR_NOT_A_TABLE", HA_ERR_NOT_A_TABLE, "" },
{ "HA_ERR_WRONG_COMMAND", HA_ERR_WRONG_COMMAND, "" },
{ "HA_ERR_OLD_FILE", HA_ERR_OLD_FILE, "" },
{ "HA_ERR_NO_ACTIVE_RECORD", HA_ERR_NO_ACTIVE_RECORD, "" },
{ "HA_ERR_RECORD_DELETED", HA_ERR_RECORD_DELETED, "" },
{ "HA_ERR_RECORD_FILE_FULL", HA_ERR_RECORD_FILE_FULL, "" },
{ "HA_ERR_INDEX_FILE_FULL", HA_ERR_INDEX_FILE_FULL, "" },
{ "HA_ERR_END_OF_FILE", HA_ERR_END_OF_FILE, "" },
{ "HA_ERR_UNSUPPORTED", HA_ERR_UNSUPPORTED, "" },
{ "HA_ERR_TO_BIG_ROW", HA_ERR_TO_BIG_ROW, "" },
{ "HA_WRONG_CREATE_OPTION", HA_WRONG_CREATE_OPTION, "" },
{ "HA_ERR_FOUND_DUPP_UNIQUE", HA_ERR_FOUND_DUPP_UNIQUE, "" },
{ "HA_ERR_UNKNOWN_CHARSET", HA_ERR_UNKNOWN_CHARSET, "" },
{ "HA_ERR_WRONG_MRG_TABLE_DEF", HA_ERR_WRONG_MRG_TABLE_DEF, "" },
{ "HA_ERR_CRASHED_ON_REPAIR", HA_ERR_CRASHED_ON_REPAIR, "" },
{ "HA_ERR_CRASHED_ON_USAGE", HA_ERR_CRASHED_ON_USAGE, "" },
{ "HA_ERR_LOCK_WAIT_TIMEOUT", HA_ERR_LOCK_WAIT_TIMEOUT, "" },
{ "HA_ERR_LOCK_TABLE_FULL", HA_ERR_LOCK_TABLE_FULL, "" },
{ "HA_ERR_READ_ONLY_TRANSACTION", HA_ERR_READ_ONLY_TRANSACTION, "" },
{ "HA_ERR_LOCK_DEADLOCK", HA_ERR_LOCK_DEADLOCK, "" },
{ "HA_ERR_CANNOT_ADD_FOREIGN", HA_ERR_CANNOT_ADD_FOREIGN, "" },
{ "HA_ERR_NO_REFERENCED_ROW", HA_ERR_NO_REFERENCED_ROW, "" },
{ "HA_ERR_ROW_IS_REFERENCED", HA_ERR_ROW_IS_REFERENCED, "" },
{ "HA_ERR_NO_SAVEPOINT", HA_ERR_NO_SAVEPOINT, "" },
{ "HA_ERR_NON_UNIQUE_BLOCK_SIZE", HA_ERR_NON_UNIQUE_BLOCK_SIZE, "" },
{ "HA_ERR_NO_SUCH_TABLE", HA_ERR_NO_SUCH_TABLE, "" },
{ "HA_ERR_TABLE_EXIST", HA_ERR_TABLE_EXIST, "" },
{ "HA_ERR_NO_CONNECTION", HA_ERR_NO_CONNECTION, "" },
{ "HA_ERR_NULL_IN_SPATIAL", HA_ERR_NULL_IN_SPATIAL, "" },
{ "HA_ERR_TABLE_DEF_CHANGED", HA_ERR_TABLE_DEF_CHANGED, "" },
{ "HA_ERR_NO_PARTITION_FOUND", HA_ERR_NO_PARTITION_FOUND, "" },
{ "HA_ERR_RBR_LOGGING_FAILED", HA_ERR_RBR_LOGGING_FAILED, "" },
{ "HA_ERR_DROP_INDEX_FK", HA_ERR_DROP_INDEX_FK, "" },
{ "HA_ERR_FOREIGN_DUPLICATE_KEY", HA_ERR_FOREIGN_DUPLICATE_KEY, "" },
{ "HA_ERR_TABLE_NEEDS_UPGRADE", HA_ERR_TABLE_NEEDS_UPGRADE, "" },
{ "HA_ERR_TABLE_READONLY", HA_ERR_TABLE_READONLY, "" },
{ "HA_ERR_AUTOINC_READ_FAILED", HA_ERR_AUTOINC_READ_FAILED, "" },
{ "HA_ERR_AUTOINC_ERANGE", HA_ERR_AUTOINC_ERANGE, "" },
{ "HA_ERR_GENERIC", HA_ERR_GENERIC, "" },
{ "HA_ERR_RECORD_IS_THE_SAME", HA_ERR_RECORD_IS_THE_SAME, "" },
{ "HA_ERR_LOGGING_IMPOSSIBLE", HA_ERR_LOGGING_IMPOSSIBLE, "" },
{ "HA_ERR_CORRUPT_EVENT", HA_ERR_CORRUPT_EVENT, "" },
{ "HA_ERR_NEW_FILE", HA_ERR_NEW_FILE, "" },
{ "HA_ERR_ROWS_EVENT_APPLY", HA_ERR_ROWS_EVENT_APPLY, "" },
{ "HA_ERR_INITIALIZATION", HA_ERR_INITIALIZATION, "" },
{ "HA_ERR_FILE_TOO_SHORT", HA_ERR_FILE_TOO_SHORT, "" },
{ "HA_ERR_WRONG_CRC", HA_ERR_WRONG_CRC, "" },
{ "HA_ERR_TOO_MANY_CONCURRENT_TRXS", HA_ERR_TOO_MANY_CONCURRENT_TRXS, "" },
{ "HA_ERR_INDEX_COL_TOO_LONG", HA_ERR_INDEX_COL_TOO_LONG, "" },
{ "HA_ERR_INDEX_CORRUPT", HA_ERR_INDEX_CORRUPT, "" },
{ "HA_ERR_UNDO_REC_TOO_BIG", HA_ERR_UNDO_REC_TOO_BIG, "" },
{ "HA_ERR_TABLE_IN_FK_CHECK", HA_ERR_TABLE_IN_FK_CHECK, "" },
{ "HA_ERR_ROW_NOT_VISIBLE", HA_ERR_ROW_NOT_VISIBLE, "" },
{ "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" },
{ "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" },
......@@ -213,7 +213,7 @@ reset master;
create table t1 (id tinyint auto_increment primary key);
insert into t1 values(5);
set insert_id=128;
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(null) /* Not binlogged */;
# The followin insert ignore will be put in binlog
......@@ -235,7 +235,7 @@ drop table t1;
create table t1 (id tinyint auto_increment primary key) engine=myisam;
set insert_id=128;
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(5),(null) /* Insert_id 128 */;
# The followin insert ignore will be put in binlog
......
......@@ -232,7 +232,7 @@ mysqltest: At line 2: Spurious text after `query` expression
mysqltest: At line 1: Missing argument(s) to 'error'
mysqltest: At line 1: Missing argument(s) to 'error'
mysqltest: At line 1: The sqlstate definition must start with an uppercase S
mysqltest: At line 1: The error name definition must start with an uppercase E
mysqltest: At line 1: The error name definition must start with an uppercase E or H
mysqltest: At line 1: Invalid argument to error: '9eeeee' - the errno may only consist of digits[0-9]
mysqltest: At line 1: Invalid argument to error: '1sssss' - the errno may only consist of digits[0-9]
mysqltest: At line 1: The sqlstate must be exactly 5 chars long
......
......@@ -104,7 +104,7 @@ explain extended select last_insert_id();
--error ER_DUP_ENTRY
insert into t1 set i = 254;
select last_insert_id();
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 set i = null;
select last_insert_id();
drop table t1;
......@@ -113,7 +113,7 @@ create table t1 (i tinyint unsigned not null auto_increment, key (i));
insert into t1 set i = 254;
insert into t1 set i = null;
select last_insert_id();
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 set i = null;
select last_insert_id();
drop table t1;
......@@ -354,7 +354,7 @@ INSERT INTO t1 VALUES (18446744073709551601);
SET @@SESSION.AUTO_INCREMENT_INCREMENT=10;
SELECT @@SESSION.AUTO_INCREMENT_OFFSET;
--error 167
--error HA_ERR_AUTOINC_ERANGE
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT * FROM t1;
......
......@@ -13,25 +13,25 @@ let $range_max=32767;
eval create table t1 (a $type primary key auto_increment);
eval insert into t1 values($range_max);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
truncate table t1;
eval insert into t1 values($range_max-1);
insert into t1 values(NULL);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max),(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max-1),(NULL),(NULL);
truncate table t1;
eval insert into t1 values($range_max+1);
select * from t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values(NULL);
drop table t1;
......@@ -44,25 +44,25 @@ let $range_max=65535;
eval create table t1 (a $type primary key auto_increment);
eval insert into t1 values($range_max);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
truncate table t1;
eval insert into t1 values($range_max-1);
insert into t1 values(NULL);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max),(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max-1),(NULL),(NULL);
truncate table t1;
eval insert into t1 values($range_max+1);
select * from t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values(NULL);
drop table t1;
......@@ -75,25 +75,25 @@ let $range_max=2147483647;
eval create table t1 (a $type primary key auto_increment);
eval insert into t1 values($range_max);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
truncate table t1;
eval insert into t1 values($range_max-1);
insert into t1 values(NULL);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max),(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max-1),(NULL),(NULL);
truncate table t1;
eval insert into t1 values($range_max+1);
select * from t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values(NULL);
drop table t1;
......@@ -106,25 +106,25 @@ let $range_max=4294967295;
eval create table t1 (a $type primary key auto_increment);
eval insert into t1 values($range_max);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
truncate table t1;
eval insert into t1 values($range_max-1);
insert into t1 values(NULL);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max),(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max-1),(NULL),(NULL);
truncate table t1;
eval insert into t1 values($range_max+1);
select * from t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values(NULL);
drop table t1;
......@@ -137,25 +137,25 @@ let $range_max=cast(9223372036854775807 as unsigned);
eval create table t1 (a $type primary key auto_increment);
eval insert into t1 values($range_max);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
truncate table t1;
eval insert into t1 values($range_max-1);
insert into t1 values(NULL);
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max),(NULL);
select * from t1;
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values($range_max-1),(NULL),(NULL);
truncate table t1;
eval insert into t1 values($range_max+1);
select * from t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
eval insert into t1 values(NULL);
drop table t1;
......@@ -200,7 +200,7 @@ set @org_mode=@@sql_mode;
set @@sql_mode='ansi,traditional';
insert ignore into t1 values(32766),(NULL),(NULL);
truncate table t1;
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(32766),(NULL),(NULL);
set @@sql_mode=@org_mode;
drop table t1;
......@@ -223,7 +223,7 @@ DROP TABLE t1;
CREATE TABLE t1 (a smallint AUTO_INCREMENT, PRIMARY KEY (a));
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (32768);
--error 167
--error HA_ERR_AUTOINC_ERANGE
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
DROP TABLE t1;
......@@ -235,6 +235,6 @@ DROP TABLE t1;
create table t1 (a smallint primary key auto_increment);
insert into t1 values(32766),(NULL);
delete from t1 where a=32767;
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values(NULL);
drop table t1;
......@@ -25,9 +25,9 @@ drop table t1;
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
--error 167
--error HA_ERR_AUTOINC_ERANGE
insert into t1 values (0,"error");
--error 167
--error HA_ERR_AUTOINC_ERANGE
replace into t1 values (0,"error");
replace into t1 values (126,"first updated");
replace into t1 values (63,default);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment