Loading mysql-test/r/func_str.result +11 −0 Original line number Diff line number Diff line Loading @@ -789,3 +789,14 @@ field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0) select field(NULL,1,2,NULL), field(NULL,1,2,0); field(NULL,1,2,NULL) field(NULL,1,2,0) 0 0 CREATE TABLE t1 (str varchar(20) PRIMARY KEY); CREATE TABLE t2 (num int primary key); INSERT INTO t1 VALUES ('notnumber'); INSERT INTO t2 VALUES (0), (1); SELECT * FROM t1, t2 WHERE num=str; str num notnumber 0 SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6); str num notnumber 0 DROP TABLE t1,t2; mysql-test/t/func_str.test +14 −0 Original line number Diff line number Diff line Loading @@ -527,3 +527,17 @@ DROP TABLE t1, t2; # select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0); select field(NULL,1,2,NULL), field(NULL,1,2,0); # # Bug #10124: access by integer index with a string key that is not a number # CREATE TABLE t1 (str varchar(20) PRIMARY KEY); CREATE TABLE t2 (num int primary key); INSERT INTO t1 VALUES ('notnumber'); INSERT INTO t2 VALUES (0), (1); SELECT * FROM t1, t2 WHERE num=str; SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6); DROP TABLE t1,t2; sql/field.cc +24 −17 Original line number Diff line number Diff line Loading @@ -2473,7 +2473,10 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) if (error || (from+len != end && table->in_use->count_cuted_fields && !test_if_int(from,len,end,cs))) error= 1; { if (error != 1) error= 2; } #if SIZEOF_LONG > 4 if (unsigned_flag) { Loading Loading @@ -2501,10 +2504,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) } #endif if (error) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); error= 1; } #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) { Loading Loading @@ -2769,9 +2769,12 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs) if (error || (from+len != end && table->in_use->count_cuted_fields && !test_if_int(from,len,end,cs))) { if (error != 1) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); error= 1; error= 2; } } #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) Loading Loading @@ -2991,7 +2994,7 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs) double nr= my_strntod(cs,(char*) from,len,&end,&error); if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields)) { error= 1; error= 2; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); } Field_float::store(nr); Loading Loading @@ -3277,7 +3280,7 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs) double nr= my_strntod(cs,(char*) from, len, &end, &error); if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields)) { error= 1; error= 2; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); } Field_double::store(nr); Loading Loading @@ -3659,6 +3662,8 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) error= 1; } } if (error > 1) error= 2; #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) Loading Loading @@ -3947,7 +3952,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) if (str_to_time(from, len, <ime, &error)) { tmp=0L; error= 1; error= 2; set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_TIME, 1); } Loading @@ -3969,6 +3974,8 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) from, len, MYSQL_TIMESTAMP_TIME, !error); error= 1; } if (error > 1) error= 2; } if (ltime.neg) Loading Loading @@ -4298,7 +4305,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR) { tmp=0; error= 1; error= 2; } else tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day); Loading Loading @@ -4489,7 +4496,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR) { tmp=0L; error= 1; error= 2; } else tmp= l_time.day + l_time.month*32 + l_time.year*16*32; Loading Loading @@ -4931,7 +4938,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) from= tmpstr.ptr(); length= tmpstr.length(); if (conv_errors) error= 1; error= 2; } /* Loading @@ -4955,7 +4962,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) from+= field_charset->cset->scan(field_charset, from, end, MY_SEQ_SPACES); if (from != end) error= 1; error= 2; } if (error) set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); Loading Loading @@ -5210,12 +5217,12 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) from= tmpstr.ptr(); length= tmpstr.length(); if (conv_errors) error= 1; error= 2; } if (length > field_length) { length=field_length; error= 1; error= 2; } if (error) set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); Loading Loading @@ -5568,7 +5575,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) from= tmpstr.ptr(); length= tmpstr.length(); if (conv_errors) error= 1; error= 2; } copy_length= max_data_length(); Loading @@ -5583,7 +5590,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) copy_length, &well_formed_error); if (copy_length < length) error= 1; error= 2; Field_blob::store_length(copy_length); if (was_conversion || table->copy_blobs || copy_length <= MAX_FIELD_WIDTH) { // Must make a copy Loading sql/item_subselect.cc +2 −2 Original line number Diff line number Diff line Loading @@ -1361,7 +1361,7 @@ int subselect_uniquesubquery_engine::exec() TABLE *table= tab->table; for (store_key **copy=tab->ref.key_copy ; *copy ; copy++) { if (tab->ref.key_err= (*copy)->copy()) if ((tab->ref.key_err= (*copy)->copy()) & 1) { table->status= STATUS_NOT_FOUND; DBUG_RETURN(1); Loading Loading @@ -1414,7 +1414,7 @@ int subselect_indexsubquery_engine::exec() for (store_key **copy=tab->ref.key_copy ; *copy ; copy++) { if (tab->ref.key_err= (*copy)->copy()) if ((tab->ref.key_err= (*copy)->copy()) & 1) { table->status= STATUS_NOT_FOUND; DBUG_RETURN(1); Loading sql/sql_select.cc +6 −2 Original line number Diff line number Diff line Loading @@ -8223,10 +8223,14 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref) enum enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; thd->count_cuted_fields= CHECK_FIELD_IGNORE; for (store_key **copy=ref->key_copy ; *copy ; copy++) if ((*copy)->copy()) { int res; if ((res= (*copy)->copy())) { thd->count_cuted_fields= save_count_cuted_fields; return 1; // Something went wrong if ((res= res & 1)) return res; // Something went wrong } } thd->count_cuted_fields= save_count_cuted_fields; return 0; Loading Loading
mysql-test/r/func_str.result +11 −0 Original line number Diff line number Diff line Loading @@ -789,3 +789,14 @@ field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0) select field(NULL,1,2,NULL), field(NULL,1,2,0); field(NULL,1,2,NULL) field(NULL,1,2,0) 0 0 CREATE TABLE t1 (str varchar(20) PRIMARY KEY); CREATE TABLE t2 (num int primary key); INSERT INTO t1 VALUES ('notnumber'); INSERT INTO t2 VALUES (0), (1); SELECT * FROM t1, t2 WHERE num=str; str num notnumber 0 SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6); str num notnumber 0 DROP TABLE t1,t2;
mysql-test/t/func_str.test +14 −0 Original line number Diff line number Diff line Loading @@ -527,3 +527,17 @@ DROP TABLE t1, t2; # select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0); select field(NULL,1,2,NULL), field(NULL,1,2,0); # # Bug #10124: access by integer index with a string key that is not a number # CREATE TABLE t1 (str varchar(20) PRIMARY KEY); CREATE TABLE t2 (num int primary key); INSERT INTO t1 VALUES ('notnumber'); INSERT INTO t2 VALUES (0), (1); SELECT * FROM t1, t2 WHERE num=str; SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6); DROP TABLE t1,t2;
sql/field.cc +24 −17 Original line number Diff line number Diff line Loading @@ -2473,7 +2473,10 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) if (error || (from+len != end && table->in_use->count_cuted_fields && !test_if_int(from,len,end,cs))) error= 1; { if (error != 1) error= 2; } #if SIZEOF_LONG > 4 if (unsigned_flag) { Loading Loading @@ -2501,10 +2504,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) } #endif if (error) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); error= 1; } #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) { Loading Loading @@ -2769,9 +2769,12 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs) if (error || (from+len != end && table->in_use->count_cuted_fields && !test_if_int(from,len,end,cs))) { if (error != 1) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); error= 1; error= 2; } } #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) Loading Loading @@ -2991,7 +2994,7 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs) double nr= my_strntod(cs,(char*) from,len,&end,&error); if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields)) { error= 1; error= 2; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); } Field_float::store(nr); Loading Loading @@ -3277,7 +3280,7 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs) double nr= my_strntod(cs,(char*) from, len, &end, &error); if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields)) { error= 1; error= 2; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); } Field_double::store(nr); Loading Loading @@ -3659,6 +3662,8 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) error= 1; } } if (error > 1) error= 2; #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) Loading Loading @@ -3947,7 +3952,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) if (str_to_time(from, len, <ime, &error)) { tmp=0L; error= 1; error= 2; set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_TIME, 1); } Loading @@ -3969,6 +3974,8 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) from, len, MYSQL_TIMESTAMP_TIME, !error); error= 1; } if (error > 1) error= 2; } if (ltime.neg) Loading Loading @@ -4298,7 +4305,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR) { tmp=0; error= 1; error= 2; } else tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day); Loading Loading @@ -4489,7 +4496,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR) { tmp=0L; error= 1; error= 2; } else tmp= l_time.day + l_time.month*32 + l_time.year*16*32; Loading Loading @@ -4931,7 +4938,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) from= tmpstr.ptr(); length= tmpstr.length(); if (conv_errors) error= 1; error= 2; } /* Loading @@ -4955,7 +4962,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) from+= field_charset->cset->scan(field_charset, from, end, MY_SEQ_SPACES); if (from != end) error= 1; error= 2; } if (error) set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); Loading Loading @@ -5210,12 +5217,12 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) from= tmpstr.ptr(); length= tmpstr.length(); if (conv_errors) error= 1; error= 2; } if (length > field_length) { length=field_length; error= 1; error= 2; } if (error) set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); Loading Loading @@ -5568,7 +5575,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) from= tmpstr.ptr(); length= tmpstr.length(); if (conv_errors) error= 1; error= 2; } copy_length= max_data_length(); Loading @@ -5583,7 +5590,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) copy_length, &well_formed_error); if (copy_length < length) error= 1; error= 2; Field_blob::store_length(copy_length); if (was_conversion || table->copy_blobs || copy_length <= MAX_FIELD_WIDTH) { // Must make a copy Loading
sql/item_subselect.cc +2 −2 Original line number Diff line number Diff line Loading @@ -1361,7 +1361,7 @@ int subselect_uniquesubquery_engine::exec() TABLE *table= tab->table; for (store_key **copy=tab->ref.key_copy ; *copy ; copy++) { if (tab->ref.key_err= (*copy)->copy()) if ((tab->ref.key_err= (*copy)->copy()) & 1) { table->status= STATUS_NOT_FOUND; DBUG_RETURN(1); Loading Loading @@ -1414,7 +1414,7 @@ int subselect_indexsubquery_engine::exec() for (store_key **copy=tab->ref.key_copy ; *copy ; copy++) { if (tab->ref.key_err= (*copy)->copy()) if ((tab->ref.key_err= (*copy)->copy()) & 1) { table->status= STATUS_NOT_FOUND; DBUG_RETURN(1); Loading
sql/sql_select.cc +6 −2 Original line number Diff line number Diff line Loading @@ -8223,10 +8223,14 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref) enum enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; thd->count_cuted_fields= CHECK_FIELD_IGNORE; for (store_key **copy=ref->key_copy ; *copy ; copy++) if ((*copy)->copy()) { int res; if ((res= (*copy)->copy())) { thd->count_cuted_fields= save_count_cuted_fields; return 1; // Something went wrong if ((res= res & 1)) return res; // Something went wrong } } thd->count_cuted_fields= save_count_cuted_fields; return 0; Loading