summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
authorunknown <holyfoot@deer.(none)>2006-05-12 18:02:42 +0500
committerunknown <holyfoot@deer.(none)>2006-05-12 18:02:42 +0500
commit273e1e01fede7508c3b4905e90a25d573c4dd610 (patch)
tree8a98bab5c8013718b49b0907550f96d5008152ca /sql/handler.cc
parent77dedc31e922d3bfdc4379f4be5b7a9ec02a309d (diff)
downloadmariadb-git-273e1e01fede7508c3b4905e90a25d573c4dd610.tar.gz
bug #14573 (Error on adding auto_increment on to a column with '0' values)
mysql-test/r/auto_increment.result: test result mysql-test/t/auto_increment.test: test case sql/handler.cc: print_keydupp_error implemented sql/handler.h: handler::print_keydupp_error declared sql/share/errmsg.txt: error message added sql/sql_table.cc: now we return different error message for auto_increment case
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index b9ef05a33c2..f51e91f1882 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1818,6 +1818,24 @@ ulonglong handler::get_auto_increment()
}
+void handler::print_keydupp_error(uint key_nr, const char *msg)
+{
+ /* Write the duplicated key in the error message */
+ char key[MAX_KEY_LENGTH];
+ String str(key,sizeof(key),system_charset_info);
+ /* Table is opened and defined at this point */
+ key_unpack(&str,table,(uint) key_nr);
+ uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(msg);
+ if (str.length() >= max_length)
+ {
+ str.length(max_length-4);
+ str.append(STRING_WITH_LEN("..."));
+ }
+ my_printf_error(ER_DUP_ENTRY, msg,
+ MYF(0), str.c_ptr(), table->key_info[key_nr].name);
+}
+
+
/*
Print error that we got from handler function
@@ -1857,18 +1875,7 @@ void handler::print_error(int error, myf errflag)
uint key_nr=get_dup_key(error);
if ((int) key_nr >= 0)
{
- /* Write the duplicated key in the error message */
- char key[MAX_KEY_LENGTH];
- String str(key,sizeof(key),system_charset_info);
- /* Table is opened and defined at this point */
- key_unpack(&str,table,(uint) key_nr);
- uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(ER(ER_DUP_ENTRY));
- if (str.length() >= max_length)
- {
- str.length(max_length-4);
- str.append(STRING_WITH_LEN("..."));
- }
- my_error(ER_DUP_ENTRY, MYF(0), str.c_ptr(), table->key_info[key_nr].name);
+ print_keydupp_error(key_nr, ER(ER_DUP_ENTRY));
DBUG_VOID_RETURN;
}
textno=ER_DUP_KEY;