diff --git a/mysql-test/README b/mysql-test/README index bccb05c555c..65e6186613a 100644 --- a/mysql-test/README +++ b/mysql-test/README @@ -17,7 +17,7 @@ http://dev.mysql.com/doc/mysql/en/MySQL_test_suite.html You can create your own test cases. To create a test case: - xeamacs t/test_case_name.test + xemacs t/test_case_name.test in the file, put a set of SQL commands that will create some tables, load test data, run some queries to manipulate it. diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 908709efba3..e3b6c2c5917 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -520,3 +520,11 @@ SHOW VARIABLES LIKE 'table_cache'; Variable_name Value table_cache 1 SET GLOBAL table_cache=DEFAULT; +create table t1 (a int); +select a into @x from t1; +Warnings: +Warning 1329 No data to FETCH +show warnings; +Level Code Message +Warning 1329 No data to FETCH +drop table t1; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 5310d50b7cb..ebd6edf4045 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -388,3 +388,12 @@ SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE'; SET GLOBAL table_cache=-1; SHOW VARIABLES LIKE 'table_cache'; SET GLOBAL table_cache=DEFAULT; + +# +# Bug#6282 Packet error with SELECT INTO +# +create table t1 (a int); +select a into @x from t1; +show warnings; +drop table t1; + diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 24f1579544b..89e6be3cdeb 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2439,7 +2439,14 @@ ha_innobase::store_key_val_for_row( (byte*) (record + (ulint)get_field_offset(table, field)), lenlen); + + /* In a column prefix index, we may need to truncate + the stored value: */ + if (len > key_part->length) { + len = key_part->length; + } + /* The length in a key value is always stored in 2 bytes */ @@ -2476,6 +2483,11 @@ ha_innobase::store_key_val_for_row( ut_a(get_field_offset(table, field) == key_part->offset); + + /* All indexes on BLOB and TEXT are column prefix + indexes, and we may need to truncate the data to be + stored in the kay value: */ + if (blob_len > key_part->length) { blob_len = key_part->length; } @@ -2494,11 +2506,17 @@ ha_innobase::store_key_val_for_row( buff += key_part->length; } else { + /* Here we handle all other data types except the + true VARCHAR, BLOB and TEXT. Note that the column + value we store may be also in a column prefix + index. */ + if (is_null) { buff += key_part->length; continue; } + memcpy(buff, record + key_part->offset, key_part->length); buff += key_part->length; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5fb91d9c1a4..cf7240e4dba 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -193,6 +193,7 @@ THD::THD() variables.pseudo_thread_id= 0; one_shot_set= 0; file_id = 0; + query_id= 0; warn_id= 0; db_charset= global_system_variables.collation_database; bzero(ha_data, sizeof(ha_data)); diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 3b52577c358..cfb169043dc 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2276,7 +2276,7 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs, } if (dst < de) /* Clear the last byte, if "dstlen" was an odd number */ - *de= 0x00; + *dst= 0x00; return dstlen; }