2692 Georgi Kodinov 2008-09-08
Bug #39186: Crash in String::append when inserting duplicate empty strings an uft8 SET col
Fixed a problem in constructing a string representation of a ENUM field when reporting
key duplicate error.
Note : no test case as the one for bug #38701 covers this one as well.
modified:
sql/key.cc
2691 Georgi Kodinov 2008-09-08 [merge]
merged the fix for bug 38701 to 6.0-5.1.29-rc
modified:
mysql-test/r/type_set.result
mysql-test/t/type_set.test
sql/handler.cc
2690 Ramil Kalimullin 2008-09-08 [merge]
Merge
modified:
mysql-test/include/grant_cache.inc
mysql-test/r/grant2.result
mysql-test/r/grant_cache_no_prot.result
mysql-test/r/grant_cache_ps_prot.result
mysql-test/r/view_grant.result
mysql-test/t/grant2.test
mysql-test/t/view_grant.test
sql/item.cc
sql/sql_acl.cc
sql/sql_base.cc
sql/sql_cache.cc
sql/sql_derived.cc
sql/sql_parse.cc
sql/table.cc
sql/table.h
=== modified file 'mysql-test/r/type_set.result'
--- a/mysql-test/r/type_set.result 2008-03-14 20:40:21 +0000
+++ b/mysql-test/r/type_set.result 2008-09-05 15:21:59 +0000
@@ -93,4 +93,14 @@ c
1,2,3
64
DROP TABLE t1;
+CREATE TABLE t1 (
+set_unique_utf8 set ('a','b','c','d','e','f','g','h','i','j','k','l',
+'m','n','o','p','q','r','s','t','u','v','w','x',
+'y','z') CHARACTER SET utf8,
+unique (set_unique_utf8)
+);
+INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' );
+INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' );
+ERROR 23000: Duplicate entry '' for key 'set_unique_utf8'
+DROP TABLE t1;
End of 5.0 tests
=== modified file 'mysql-test/t/type_set.test'
--- a/mysql-test/t/type_set.test 2008-03-14 20:40:21 +0000
+++ b/mysql-test/t/type_set.test 2008-09-05 15:21:59 +0000
@@ -75,4 +75,23 @@ INSERT INTO t1 VALUES(922337203685477580
SELECT * FROM t1;
DROP TABLE t1;
+#
+# Bug #38701: Crash in String::append when inserting duplicate empty strings
+# an uft8 SET col
+#
+
+CREATE TABLE t1 (
+ set_unique_utf8 set ('a','b','c','d','e','f','g','h','i','j','k','l',
+ 'm','n','o','p','q','r','s','t','u','v','w','x',
+ 'y','z') CHARACTER SET utf8,
+ unique (set_unique_utf8)
+);
+
+INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' );
+--error ER_DUP_ENTRY
+INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' );
+
+DROP TABLE t1;
+
+
--echo End of 5.0 tests
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2008-09-03 14:40:19 +0000
+++ b/sql/handler.cc 2008-09-08 13:52:04 +0000
@@ -2535,7 +2535,7 @@ void handler::print_keydup_error(uint ke
str.append(STRING_WITH_LEN("..."));
}
my_printf_error(ER_DUP_ENTRY, msg,
- MYF(0), str.c_ptr(), table->key_info[key_nr].name);
+ MYF(0), str.c_ptr_safe(), table->key_info[key_nr].name);
}
}
@@ -2606,7 +2606,7 @@ void handler::print_error(int error, myf
str.append(STRING_WITH_LEN("..."));
}
my_error(ER_FOREIGN_DUPLICATE_KEY, MYF(0), table_share->table_name.str,
- str.c_ptr(), key_nr+1);
+ str.c_ptr_safe(), key_nr+1);
DBUG_VOID_RETURN;
}
textno= ER_DUP_KEY;
=== modified file 'sql/key.cc'
--- a/sql/key.cc 2008-03-27 19:02:15 +0000
+++ b/sql/key.cc 2008-09-08 14:54:16 +0000
@@ -368,7 +368,7 @@ void key_unpack(String *to,TABLE *table,
{
CHARSET_INFO *cs= field->charset();
field->val_str(&tmp);
- if (cs->mbmaxlen > 1 &&
+ if (cs->mbmaxlen > 1 && tmp.length() > 0 &&
table->field[key_part->fieldnr - 1]->field_length !=
key_part->length)
{
| Thread |
|---|
| • bzr push into mysql-6.0 branch (kgeorge:2690 to 2692) Bug#39186 | Georgi Kodinov | 9 Sep |