mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0
into rurik.mysql.com:/home/igor/mysql-5.0
This commit is contained in:
commit
0c0a5097cb
7 changed files with 64 additions and 27 deletions
|
@ -800,3 +800,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;
|
||||
|
|
|
@ -529,3 +529,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;
|
||||
|
|
30
sql/field.cc
30
sql/field.cc
|
@ -3317,12 +3317,12 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
|
|||
}
|
||||
if (error)
|
||||
{
|
||||
error= 1;
|
||||
error= error != MY_ERRNO_EDOM ? 1 : 2;
|
||||
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
|
||||
}
|
||||
else if (from+len != end && table->in_use->count_cuted_fields &&
|
||||
check_int(from,len,end,cs))
|
||||
error= 1;
|
||||
error= 2;
|
||||
|
||||
store_tmp= (long) tmp;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
|
@ -3584,7 +3584,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
|
|||
}
|
||||
else if (from+len != end && table->in_use->count_cuted_fields &&
|
||||
check_int(from,len,end,cs))
|
||||
error= 1;
|
||||
error= 2;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (table->s->db_low_byte_first)
|
||||
{
|
||||
|
@ -3806,7 +3806,7 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
|
|||
{
|
||||
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
(error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1);
|
||||
error= 1;
|
||||
error= error ? 1 : 2;
|
||||
}
|
||||
Field_float::store(nr);
|
||||
return error;
|
||||
|
@ -4093,7 +4093,7 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
|
|||
{
|
||||
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
(error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1);
|
||||
error= 1;
|
||||
error= error ? 1 : 2;
|
||||
}
|
||||
Field_double::store(nr);
|
||||
return error;
|
||||
|
@ -4495,6 +4495,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->s->db_low_byte_first)
|
||||
|
@ -4791,7 +4793,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, WARN_DATA_TRUNCATED,
|
||||
from, len, MYSQL_TIMESTAMP_TIME, 1);
|
||||
}
|
||||
|
@ -4813,6 +4815,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)
|
||||
|
@ -5149,7 +5153,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
|
|||
&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);
|
||||
|
@ -5353,7 +5357,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
|
|||
&error) <= MYSQL_TIMESTAMP_ERROR)
|
||||
{
|
||||
tmp=0L;
|
||||
error= 1;
|
||||
error= 2;
|
||||
}
|
||||
else
|
||||
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
|
||||
|
@ -5836,7 +5840,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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5860,7 +5864,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)
|
||||
{
|
||||
|
@ -6242,7 +6246,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
|
|||
table->in_use->abort_on_warning)
|
||||
error_code= ER_DATA_TOO_LONG;
|
||||
set_warning(level, error_code, 1);
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -6822,7 +6826,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();
|
||||
|
@ -6837,7 +6841,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
|
||||
|
|
|
@ -1487,7 +1487,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);
|
||||
|
@ -1540,7 +1540,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);
|
||||
|
|
|
@ -3272,7 +3272,6 @@ end_with_restore_list:
|
|||
|
||||
if (first_table->view && !first_table->contain_auto_increment)
|
||||
thd->last_insert_id= 0; // do not show last insert ID if VIEW have not it
|
||||
|
||||
break;
|
||||
}
|
||||
case SQLCOM_TRUNCATE:
|
||||
|
|
|
@ -11765,10 +11765,12 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref)
|
|||
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;
|
||||
|
|
|
@ -448,6 +448,7 @@ class store_key :public Sql_alloc
|
|||
char *null_ptr;
|
||||
char err;
|
||||
public:
|
||||
enum store_key_result { STORE_KEY_OK, STORE_KEY_FATAL, STORE_KEY_CONV };
|
||||
store_key(THD *thd, Field *field_arg, char *ptr, char *null, uint length)
|
||||
:null_ptr(null),err(0)
|
||||
{
|
||||
|
@ -463,7 +464,7 @@ class store_key :public Sql_alloc
|
|||
ptr, (uchar*) null, 1);
|
||||
}
|
||||
virtual ~store_key() {} /* Not actually needed */
|
||||
virtual bool copy()=0;
|
||||
virtual enum store_key_result copy()=0;
|
||||
virtual const char *name() const=0;
|
||||
};
|
||||
|
||||
|
@ -484,10 +485,10 @@ class store_key_field: public store_key
|
|||
copy_field.set(to_field,from_field,0);
|
||||
}
|
||||
}
|
||||
bool copy()
|
||||
enum store_key_result copy()
|
||||
{
|
||||
copy_field.do_copy(©_field);
|
||||
return err != 0;
|
||||
return err != 0 ? STORE_KEY_FATAL : STORE_KEY_OK;
|
||||
}
|
||||
const char *name() const { return field_name; }
|
||||
};
|
||||
|
@ -504,9 +505,11 @@ public:
|
|||
null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
|
||||
&err : NullS, length), item(item_arg)
|
||||
{}
|
||||
bool copy()
|
||||
enum store_key_result copy()
|
||||
{
|
||||
return item->save_in_field_no_warnings(to_field, 1) || err != 0;
|
||||
int res= item->save_in_field(to_field, 1);
|
||||
return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res);
|
||||
|
||||
}
|
||||
const char *name() const { return "func"; }
|
||||
};
|
||||
|
@ -524,15 +527,19 @@ public:
|
|||
&err : NullS, length, item_arg), inited(0)
|
||||
{
|
||||
}
|
||||
bool copy()
|
||||
enum store_key_result copy()
|
||||
{
|
||||
int res;
|
||||
if (!inited)
|
||||
{
|
||||
inited=1;
|
||||
if (item->save_in_field(to_field, 1))
|
||||
err= 1;
|
||||
if ((res= item->save_in_field(to_field, 1)))
|
||||
{
|
||||
if (!err)
|
||||
err= res;
|
||||
}
|
||||
}
|
||||
return err != 0;
|
||||
return (err > 2 ? STORE_KEY_FATAL : (store_key_result) err);
|
||||
}
|
||||
const char *name() const { return "const"; }
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue