diff options
-rw-r--r-- | myisam/mi_rnext_same.c | 15 | ||||
-rw-r--r-- | myisam/rt_index.c | 94 | ||||
-rw-r--r-- | mysql-test/r/func_crypt.result | 2 | ||||
-rw-r--r-- | mysql-test/r/func_group.result | 2 | ||||
-rw-r--r-- | mysql-test/r/null_key.result | 4 | ||||
-rw-r--r-- | mysql-test/r/order_by.result | 6 | ||||
-rw-r--r-- | mysql-test/r/query_cache.result | 18 | ||||
-rw-r--r-- | mysql-test/r/range.result | 4 | ||||
-rw-r--r-- | mysql-test/r/rpl_trunc_binlog.result | 4 | ||||
-rw-r--r-- | mysql-test/t/fulltext.test | 4 | ||||
-rw-r--r-- | mysql-test/t/func_crypt.test | 2 | ||||
-rw-r--r-- | mysql-test/t/range.test | 49 | ||||
-rw-r--r-- | mysys/test_charset.c | 2 | ||||
-rw-r--r-- | sql-common/client.c | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 38 | ||||
-rw-r--r-- | sql/log_event.cc | 4 | ||||
-rw-r--r-- | sql/protocol.cc | 2 | ||||
-rw-r--r-- | sql/spatial.cc | 1 | ||||
-rw-r--r-- | sql/sql_class.cc | 2 | ||||
-rw-r--r-- | sql/time.cc | 20 | ||||
-rw-r--r-- | sql/unireg.cc | 1 |
21 files changed, 150 insertions, 126 deletions
diff --git a/myisam/mi_rnext_same.c b/myisam/mi_rnext_same.c index 200e715bddc..19190a60246 100644 --- a/myisam/mi_rnext_same.c +++ b/myisam/mi_rnext_same.c @@ -41,17 +41,20 @@ int mi_rnext_same(MI_INFO *info, byte *buf) if (info->s->concurrent_insert) rw_rdlock(&info->s->key_root_lock[inx]); - switch(keyinfo->key_alg) + switch (keyinfo->key_alg) { case HA_KEY_ALG_RTREE: - if((error=rtree_find_next(info,inx,myisam_read_vec[info->last_key_func]))) - { - /* FIXME: What to do?*/ - } + if ((error=rtree_find_next(info,inx, + myisam_read_vec[info->last_key_func]))) + { + error=1; + my_errno=HA_ERR_END_OF_FILE; + info->lastpos= HA_OFFSET_ERROR; + break; + } break; case HA_KEY_ALG_BTREE: default: - memcpy(info->lastkey2,info->lastkey,info->last_rkey_length); for (;;) { diff --git a/myisam/rt_index.c b/myisam/rt_index.c index 8b877d2e65c..c49c204ce7b 100644 --- a/myisam/rt_index.c +++ b/myisam/rt_index.c @@ -36,16 +36,21 @@ typedef struct st_page_list stPageLevel *pages; } stPageList; + /* -Find next key in r-tree according to search_flag recursively -Used in rtree_find_first() and rtree_find_next() -Result values: --1 - error - 0 - found - 1 - not found + Find next key in r-tree according to search_flag recursively + + NOTES + Used in rtree_find_first() and rtree_find_next() + + RETURN + -1 Error + 0 Found + 1 Not found */ -static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, uint nod_cmp_flag, - my_off_t page, int level) + +static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, + uint nod_cmp_flag, my_off_t page, int level) { uchar *k; uchar *last; @@ -143,13 +148,24 @@ err1: return -1; } + /* -Find first key in r-tree according to search_flag condition -Result values: --1 - error - 0 - found - 1 - not found + Find first key in r-tree according to search_flag condition + + SYNOPSIS + rtree_find_first() + info Handler to MyISAM file + uint keynr Key number to use + key Key to search for + key_length Length of 'key' + search_flag Bitmap of flags how to do the search + + RETURN + -1 Error + 0 Found + 1 Not found */ + int rtree_find_first(MI_INFO *info, uint keynr, uchar *key, uint key_length, uint search_flag) { @@ -175,13 +191,16 @@ int rtree_find_first(MI_INFO *info, uint keynr, uchar *key, uint key_length, return rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root, 0); } + /* -Find next key in r-tree according to search_flag condition -Result values: --1 - error - 0 - found - 1 - not found + Find next key in r-tree according to search_flag condition + + RETURN + -1 Error + 0 Found + 1 Not found */ + int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag) { my_off_t root; @@ -189,14 +208,12 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag) MI_KEYDEF *keyinfo = info->s->keyinfo + keynr; if (info->update & HA_STATE_DELETED) - { return rtree_find_first(info, keynr, info->lastkey, info->lastkey_length, search_flag); - } - + if (!info->buff_used) { - uchar *key = info->int_keypos; + uchar *key= info->int_keypos; while (key < info->int_maxpos) { @@ -205,24 +222,16 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag) { uchar *after_key = key + keyinfo->keylength; - info->lastpos = _mi_dpos(info, 0, after_key); + info->lastpos= _mi_dpos(info, 0, after_key); memcpy(info->lastkey, key, info->lastkey_length); if (after_key < info->int_maxpos) - { - info->int_keypos = after_key; - } + info->int_keypos= after_key; else - { - info->buff_used = 1; - } - + info->buff_used= 1; return 0; } - else - { - key += keyinfo->keylength; - } + key+= keyinfo->keylength; } } if ((root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR) @@ -236,14 +245,19 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag) return rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root, 0); } + /* -Get next key in r-tree recursively -Used in rtree_get_first() and rtree_get_next() -Result values: --1 - error - 0 - found - 1 - not found + Get next key in r-tree recursively + + NOTES + Used in rtree_get_first() and rtree_get_next() + + RETURN + -1 Error + 0 Found + 1 Not found */ + static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length, my_off_t page, int level) { diff --git a/mysql-test/r/func_crypt.result b/mysql-test/r/func_crypt.result index 6b63002fd39..3dad231de2b 100644 --- a/mysql-test/r/func_crypt.result +++ b/mysql-test/r/func_crypt.result @@ -2,7 +2,7 @@ drop table if exists t1; select length(encrypt('foo', 'ff')) <> 0; length(encrypt('foo', 'ff')) <> 0 1 -create table t1 (name varchar(50), pw varchar(16)); +create table t1 (name varchar(50), pw varchar(64)); insert into t1 values ('tom', password('my_pass')); set @pass='my_pass'; select name from t1 where name='tom' and pw=password(@pass); diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 7b084626f39..7ae3bbb0608 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -559,8 +559,8 @@ id select_type table type possible_keys key key_len ref rows Extra explain select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 3 NULL 14 Using index 1 SIMPLE t2 range k2 k2 4 NULL 6 Using where; Using index +1 SIMPLE t1 index NULL PRIMARY 3 NULL 14 Using index drop table t1, t2; CREATE TABLE t1 (a int, b int); select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1; diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result index bacd95d852e..9aaea0d800b 100644 --- a/mysql-test/r/null_key.result +++ b/mysql-test/r/null_key.result @@ -153,12 +153,12 @@ a b 7 NULL explain select * from t1 where (a = 7 or a is null) and (b=7 or b is null); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null a,b a 5 const 4 Using where; Using index +1 SIMPLE t1 range a,b a 10 NULL 3 Using where; Using index select * from t1 where (a = 7 or a is null) and (b=7 or b is null); a b +NULL 7 7 NULL 7 7 -NULL 7 explain select * from t1 where (a = 7 or a is null) and (a = 7 or a is null); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref_or_null a a 5 const 5 Using where; Using index diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index f4878664076..db747e3a7eb 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -306,17 +306,17 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 9 NULL 8 Using where; Using index explain select * from t1 where a = 2 and b >0 order by a desc,b desc; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index +1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index explain select * from t1 where a = 2 and b is null order by a desc,b desc; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref a a 9 const,const 1 Using where; Using index; Using filesort explain select * from t1 where a = 2 and (b is null or b > 0) order by a desc,b desc; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index +1 SIMPLE t1 range a a 9 NULL 6 Using where; Using index explain select * from t1 where a = 2 and b > 0 order by a desc,b desc; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index +1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index explain select * from t1 where a = 2 and b < 2 order by a desc,b desc; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 9 NULL 2 Using where; Using index diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 45e195e89f7..e91153cae15 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -586,7 +586,7 @@ select * from t1; a set GLOBAL query_cache_size=1024; Warnings: -Warning 1280 Query cache failed to set size 1024, new query cache size is 0 +Warning 1285 Query cache failed to set size 1024, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -594,7 +594,7 @@ select * from t1; a set GLOBAL query_cache_size=10240; Warnings: -Warning 1280 Query cache failed to set size 10240, new query cache size is 0 +Warning 1285 Query cache failed to set size 10240, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -602,7 +602,7 @@ select * from t1; a set GLOBAL query_cache_size=20480; Warnings: -Warning 1280 Query cache failed to set size 20480, new query cache size is 0 +Warning 1285 Query cache failed to set size 20480, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -610,7 +610,7 @@ select * from t1; a set GLOBAL query_cache_size=40960; Warnings: -Warning 1280 Query cache failed to set size 40960, new query cache size is 0 +Warning 1285 Query cache failed to set size 40960, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -762,7 +762,6 @@ select * from t3; delete from t4 where a=1; flush query cache; drop table t1,t2,t3,t4; -set GLOBAL query_cache_size=0; SET NAMES koi8r; CREATE TABLE t1 (a char(1) character set koi8r); INSERT INTO t1 VALUES (_koi8r'á'),(_koi8r'Á'); @@ -772,7 +771,7 @@ a  'â'='Â' Á  1 show status like "Qcache_hits"; Variable_name Value -Qcache_hits 12 +Qcache_hits 6 show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 1 @@ -783,7 +782,7 @@ a  'â'='Â' Á  0 show status like "Qcache_hits"; Variable_name Value -Qcache_hits 12 +Qcache_hits 6 show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 @@ -794,7 +793,7 @@ a ÷ '×'='÷' Á ÷ 0 show status like "Qcache_hits"; Variable_name Value -Qcache_hits 12 +Qcache_hits 6 show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 3 @@ -805,8 +804,9 @@ a  'â'='Â' à  0 show status like "Qcache_hits"; Variable_name Value -Qcache_hits 12 +Qcache_hits 6 show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 4 DROP TABLE t1; +SET GLOBAL query_cache_size=0; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 324eb37b334..1b66f442a9a 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -274,8 +274,8 @@ INSERT INTO t1 VALUES (21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), (33,5),(33,5),(33,5),(33,5),(34,5),(35,5); EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; -table type possible_keys key key_len ref rows Extra -t1 range a,b a 5 NULL 2 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a,b a 5 NULL 2 Using where SELECT * FROM t1 WHERE a IN(1,2) AND b=5; a b DROP TABLE t1; diff --git a/mysql-test/r/rpl_trunc_binlog.result b/mysql-test/r/rpl_trunc_binlog.result index bc5e401287d..caca15ab4ef 100644 --- a/mysql-test/r/rpl_trunc_binlog.result +++ b/mysql-test/r/rpl_trunc_binlog.result @@ -8,8 +8,6 @@ stop slave; flush logs; reset slave; start slave; +show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master # 127.0.0.1 root MASTER_PORT 1 master-bin.000002 4 slave-relay-bin.000002 123 master-bin.000001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 326 None 0 No # -show slave status; -Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.002 4 slave-relay-bin.002 161 master-bin.001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 317 diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 467d1aa6f07..3437e0a1440 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -133,9 +133,9 @@ select * from t2 having MATCH inhalt AGAINST ('foobar'); # check of fulltext errors # ---error 1281 +--error 1286 CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i)); ---error 1281 +--error 1286 CREATE TABLE t3 (t int(11),i text, j varchar(200) CHARACTER SET latin2, fulltext tix (i,j)); diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test index 3cf1e15e3ef..61b9ccb4718 100644 --- a/mysql-test/t/func_crypt.test +++ b/mysql-test/t/func_crypt.test @@ -7,7 +7,7 @@ drop table if exists t1; select length(encrypt('foo', 'ff')) <> 0; --replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l. -create table t1 (name varchar(50), pw varchar(16)); +create table t1 (name varchar(50), pw varchar(64)); insert into t1 values ('tom', password('my_pass')); set @pass='my_pass'; select name from t1 where name='tom' and pw=password(@pass); diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 0b39f20e346..65ba2ee6671 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -205,6 +205,30 @@ explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; DROP TABLE t1,t2; +# +# bug #1724: use RANGE on more selective column instead of REF on less +# selective + +CREATE TABLE t1 ( + a int(11) default NULL, + b int(11) default NULL, + KEY a (a), + KEY b (b) +) TYPE=MyISAM; + + +INSERT INTO t1 VALUES +(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2), +(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3), +(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), +(33,5),(33,5),(33,5),(33,5),(34,5),(35,5); + +# we expect that optimizer will choose key on A +EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +SELECT * FROM t1 WHERE a IN(1,2) AND b=5; + +DROP TABLE t1; + # test for a bug with in() and unique key create table t1 (id int(10) primary key); @@ -306,28 +330,3 @@ select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; drop table t1,t2; - -# -# bug #1724: use RANGE on more selective column instead of REF on less -# selective - -CREATE TABLE t1 ( - a int(11) default NULL, - b int(11) default NULL, - KEY a (a), - KEY b (b) -) TYPE=MyISAM; - - -INSERT INTO t1 VALUES -(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2), -(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3), -(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), -(33,5),(33,5),(33,5),(33,5),(34,5),(35,5); - -EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; -SELECT * FROM t1 WHERE a IN(1,2) AND b=5; - -DROP TABLE t1; - -# we expect that optimizer will choose key on A diff --git a/mysys/test_charset.c b/mysys/test_charset.c index 6b0f728593a..419332cb997 100644 --- a/mysys/test_charset.c +++ b/mysys/test_charset.c @@ -78,6 +78,7 @@ int main(int argc, char **argv) { _print_csinfo(cs); fflush(stdout); +#define NOT_USED_ANYMORE cs_list = list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG)); printf("LIST OF CHARSETS (compiled + *.conf):\n%s\n", cs_list); my_free(cs_list,MYF(0)); @@ -85,6 +86,7 @@ int main(int argc, char **argv) { cs_list = list_charsets(MYF(MY_CS_INDEX | MY_CS_LOADED)); printf("LIST OF CHARSETS (index + loaded):\n%s\n", cs_list); my_free(cs_list,MYF(0)); +#endif return 0; } diff --git a/sql-common/client.c b/sql-common/client.c index 15f906f4e34..85308539222 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1419,7 +1419,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, char buff[NAME_LEN+USERNAME_LENGTH+100],charset_name_buff[16]; char *end,*host_info,*charset_name; my_socket sock; - uint32 ip_addr; + in_addr_t ip_addr; struct sockaddr_in sock_addr; ulong pkt_length; NET *net= &mysql->net; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 310faae8380..5579c0f0bea 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2645,46 +2645,46 @@ String *Item_func_compress::val_str(String *str) } buffer.length((uint32)new_size + 4); - return &buffer; } + String *Item_func_uncompress::val_str(String *str) { String *res= args[0]->val_str(str); - if (!res) - { - null_value= 1; - return 0; - } - if (res->is_empty()) return res; - - ulong new_size= uint4korr(res->c_ptr()) & 0x3FFFFFFF; - int err= Z_OK; + ulong new_size; + int err; uint code; + if (!res) + goto err; + if (res->is_empty()) + return res; + + new_size= uint4korr(res->ptr()) & 0x3FFFFFFF; if (new_size > current_thd->variables.max_allowed_packet) { push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR, ER_TOO_BIG_FOR_UNCOMPRESS, ER(ER_TOO_BIG_FOR_UNCOMPRESS), current_thd->variables.max_allowed_packet); - null_value= 0; - return 0; + goto err; } + if (buffer.realloc((uint32)new_size)) + goto err; - buffer.realloc((uint32)new_size); - - if ((err= uncompress((Byte*)buffer.c_ptr(), &new_size, - ((const Bytef*)res->c_ptr())+4,res->length())) == Z_OK) + if ((err= uncompress((Byte*)buffer.ptr(), &new_size, + ((const Bytef*)res->ptr())+4,res->length())) == Z_OK) { - buffer.length((uint32)new_size); + buffer.length((uint32) new_size); return &buffer; } - code= err==Z_BUF_ERROR ? ER_ZLIB_Z_BUF_ERROR : - err==Z_MEM_ERROR ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR; + code= ((err == Z_BUF_ERROR) ? ER_ZLIB_Z_BUF_ERROR : + ((err == Z_MEM_ERROR) ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR)); push_warning(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,code,ER(code)); + +err: null_value= 1; return 0; } diff --git a/sql/log_event.cc b/sql/log_event.cc index c0fd781cede..d0dc0a83b11 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -835,7 +835,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, error_code(thd_arg->killed ? ER_SERVER_SHUTDOWN: thd_arg->net.last_errno), thread_id(thd_arg->thread_id), /* save the original thread id; we already know the server id */ - slave_proxy_id(thd_arg->slave_proxy_id) + slave_proxy_id(thd_arg->variables.pseudo_thread_id) { time_t end_time; time(&end_time); @@ -1357,7 +1357,7 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex, enum enum_duplicates handle_dup, bool using_trans) :Log_event(thd_arg, 0, using_trans), thread_id(thd_arg->thread_id), - slave_proxy_id(thd_arg->slave_proxy_id), + slave_proxy_id(thd_arg->variables.pseudo_thread_id), num_fields(0),fields(0), field_lens(0),field_block_len(0), table_name(table_name_arg ? table_name_arg : ""), diff --git a/sql/protocol.cc b/sql/protocol.cc index d7a745d371d..8ba3cdec8e0 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -496,7 +496,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag) if (thd->client_capabilities & CLIENT_PROTOCOL_41) { - if (prot.store("std", 3, cs, thd_charset) || + if (prot.store("def", 3, cs, thd_charset) || prot.store(field.db_name, (uint) strlen(field.db_name), cs, thd_charset) || prot.store(field.table_name, (uint) strlen(field.table_name), diff --git a/sql/spatial.cc b/sql/spatial.cc index 00db94a07d6..d19429fdd9c 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -1258,6 +1258,7 @@ int GMultiPolygon::geometry_n(uint32 num, String *result) const uint32 n_polygons; const char *data= m_data, *polygon_n; LINT_INIT(polygon_n); + if (no_data(data, 4)) return 1; n_polygons= uint4korr(data); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6b43c2f796e..4fcd6504a2f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -400,7 +400,7 @@ bool THD::store_globals() By default 'slave_proxy_id' is 'thread_id'. They may later become different if this is the slave SQL thread. */ - slave_proxy_id= thread_id; + variables.pseudo_thread_id= thread_id; return 0; } diff --git a/sql/time.cc b/sql/time.cc index 4f2a2a23910..3fa00fc683b 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -335,10 +335,12 @@ static char time_separator=':'; RETURN VALUES TIMESTAMP_NONE String wasn't a timestamp, like - [DD [HH:[MM:[SS]]]].fraction + [DD [HH:[MM:[SS]]]].fraction. + l_time is not changed. TIMESTAMP_DATE DATE string (YY MM and DD parts ok) - TIMESTAMP_DATETIME Full timestamp - TIMESTAMP_DATETIME_ERROR Timestamp with wrong values + TIMESTAMP_DATETIME Full timestamp + TIMESTAMP_DATETIME_ERROR Timestamp with wrong values. + All elements in l_time is set to 0 */ #define MAX_DATE_PARTS 8 @@ -409,9 +411,9 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags) if (pos == end) { if (flags & TIME_DATETIME_ONLY) - return TIMESTAMP_NONE; // Can't be a full datetime + DBUG_RETURN(TIMESTAMP_NONE); // Can't be a full datetime /* Date field. Set hour, minutes and seconds to 0 */ - date[0]= date[1]= date[2]= date[3]= 0; + date[0]= date[1]= date[2]= date[3]= date[4]= 0; start_loop= 5; // Start with first date part } } @@ -535,7 +537,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags) if (format_position[7] != (uchar) 255) { if (l_time->hour > 12) - DBUG_RETURN(TIMESTAMP_DATETIME_ERROR); + goto err; l_time->hour= l_time->hour%12 + add_hours; } } @@ -574,7 +576,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags) } if (not_zero_date) current_thd->cuted_fields++; - DBUG_RETURN(TIMESTAMP_DATETIME_ERROR); + goto err; } if (str != end && current_thd->count_cuted_fields) { @@ -590,6 +592,10 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags) DBUG_RETURN(l_time->time_type= (number_of_fields <= 3 ? TIMESTAMP_DATE : TIMESTAMP_DATETIME)); + +err: + bzero((char*) l_time, sizeof(*l_time)); + DBUG_RETURN(TIMESTAMP_DATETIME_ERROR); } diff --git a/sql/unireg.cc b/sql/unireg.cc index e93e290bd4c..fc948ddd5a6 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -305,6 +305,7 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo) { keybuff[0]=(uchar) key_count; keybuff[1]=(uchar) key_parts; + keybuff[2]= keybuff[3]= 0; } length=(uint) (pos-keyname_pos); int2store(keybuff+4,length); |