Commit f763d4c3 authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

Removed some warnings reported by valgrind

After merge fixes.
Now code compiles, but there is still some valgrind warnings that needs to be fixed
parent 4e472537
...@@ -41,17 +41,20 @@ int mi_rnext_same(MI_INFO *info, byte *buf) ...@@ -41,17 +41,20 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]); rw_rdlock(&info->s->key_root_lock[inx]);
switch(keyinfo->key_alg) switch (keyinfo->key_alg)
{ {
case HA_KEY_ALG_RTREE: case HA_KEY_ALG_RTREE:
if((error=rtree_find_next(info,inx,myisam_read_vec[info->last_key_func]))) if ((error=rtree_find_next(info,inx,
{ myisam_read_vec[info->last_key_func])))
/* FIXME: What to do?*/ {
} error=1;
my_errno=HA_ERR_END_OF_FILE;
info->lastpos= HA_OFFSET_ERROR;
break;
}
break; break;
case HA_KEY_ALG_BTREE: case HA_KEY_ALG_BTREE:
default: default:
memcpy(info->lastkey2,info->lastkey,info->last_rkey_length); memcpy(info->lastkey2,info->lastkey,info->last_rkey_length);
for (;;) for (;;)
{ {
......
...@@ -36,16 +36,21 @@ typedef struct st_page_list ...@@ -36,16 +36,21 @@ typedef struct st_page_list
stPageLevel *pages; stPageLevel *pages;
} stPageList; } stPageList;
/* /*
Find next key in r-tree according to search_flag recursively Find next key in r-tree according to search_flag recursively
Used in rtree_find_first() and rtree_find_next()
Result values: NOTES
-1 - error Used in rtree_find_first() and rtree_find_next()
0 - found
1 - not found 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 *k;
uchar *last; uchar *last;
...@@ -143,13 +148,24 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u ...@@ -143,13 +148,24 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u
return -1; return -1;
} }
/* /*
Find first key in r-tree according to search_flag condition Find first key in r-tree according to search_flag condition
Result values:
-1 - error SYNOPSIS
0 - found rtree_find_first()
1 - not found 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, int rtree_find_first(MI_INFO *info, uint keynr, uchar *key, uint key_length,
uint search_flag) uint search_flag)
{ {
...@@ -175,13 +191,16 @@ int rtree_find_first(MI_INFO *info, uint keynr, uchar *key, uint key_length, ...@@ -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); return rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root, 0);
} }
/* /*
Find next key in r-tree according to search_flag condition Find next key in r-tree according to search_flag condition
Result values:
-1 - error RETURN
0 - found -1 Error
1 - not found 0 Found
1 Not found
*/ */
int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag) int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
{ {
my_off_t root; my_off_t root;
...@@ -189,14 +208,12 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag) ...@@ -189,14 +208,12 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
MI_KEYDEF *keyinfo = info->s->keyinfo + keynr; MI_KEYDEF *keyinfo = info->s->keyinfo + keynr;
if (info->update & HA_STATE_DELETED) if (info->update & HA_STATE_DELETED)
{
return rtree_find_first(info, keynr, info->lastkey, info->lastkey_length, return rtree_find_first(info, keynr, info->lastkey, info->lastkey_length,
search_flag); search_flag);
}
if (!info->buff_used) if (!info->buff_used)
{ {
uchar *key = info->int_keypos; uchar *key= info->int_keypos;
while (key < info->int_maxpos) while (key < info->int_maxpos)
{ {
...@@ -205,24 +222,16 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag) ...@@ -205,24 +222,16 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
{ {
uchar *after_key = key + keyinfo->keylength; 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); memcpy(info->lastkey, key, info->lastkey_length);
if (after_key < info->int_maxpos) if (after_key < info->int_maxpos)
{ info->int_keypos= after_key;
info->int_keypos = after_key;
}
else else
{ info->buff_used= 1;
info->buff_used = 1;
}
return 0; return 0;
} }
else key+= keyinfo->keylength;
{
key += keyinfo->keylength;
}
} }
} }
if ((root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR) 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) ...@@ -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); return rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root, 0);
} }
/* /*
Get next key in r-tree recursively Get next key in r-tree recursively
Used in rtree_get_first() and rtree_get_next()
Result values: NOTES
-1 - error Used in rtree_get_first() and rtree_get_next()
0 - found
1 - not found RETURN
-1 Error
0 Found
1 Not found
*/ */
static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length, static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length,
my_off_t page, int level) my_off_t page, int level)
{ {
......
...@@ -2,7 +2,7 @@ drop table if exists t1; ...@@ -2,7 +2,7 @@ drop table if exists t1;
select length(encrypt('foo', 'ff')) <> 0; select length(encrypt('foo', 'ff')) <> 0;
length(encrypt('foo', 'ff')) <> 0 length(encrypt('foo', 'ff')) <> 0
1 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')); insert into t1 values ('tom', password('my_pass'));
set @pass='my_pass'; set @pass='my_pass';
select name from t1 where name='tom' and pw=password(@pass); select name from t1 where name='tom' and pw=password(@pass);
......
...@@ -559,8 +559,8 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -559,8 +559,8 @@ id select_type table type possible_keys key key_len ref rows Extra
explain explain
select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME'; 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 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 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; drop table t1, t2;
CREATE TABLE t1 (a int, b int); 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; select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1;
......
...@@ -153,12 +153,12 @@ a b ...@@ -153,12 +153,12 @@ a b
7 NULL 7 NULL
explain select * from t1 where (a = 7 or a is null) and (b=7 or b is 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 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); select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
a b a b
NULL 7
7 NULL 7 NULL
7 7 7 7
NULL 7
explain select * from t1 where (a = 7 or a is null) and (a = 7 or a is null); 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 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 1 SIMPLE t1 ref_or_null a a 5 const 5 Using where; Using index
......
...@@ -306,17 +306,17 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -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 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; 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 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; 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 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 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 explain select * from t1 where a = 2 and (b is null or b > 0) order by a
desc,b desc; desc,b desc;
id select_type table type possible_keys key key_len ref rows Extra 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; 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 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; 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 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 1 SIMPLE t1 range a a 9 NULL 2 Using where; Using index
......
...@@ -586,7 +586,7 @@ select * from t1; ...@@ -586,7 +586,7 @@ select * from t1;
a a
set GLOBAL query_cache_size=1024; set GLOBAL query_cache_size=1024;
Warnings: 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"; show global variables like "query_cache_size";
Variable_name Value Variable_name Value
query_cache_size 0 query_cache_size 0
...@@ -594,7 +594,7 @@ select * from t1; ...@@ -594,7 +594,7 @@ select * from t1;
a a
set GLOBAL query_cache_size=10240; set GLOBAL query_cache_size=10240;
Warnings: 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"; show global variables like "query_cache_size";
Variable_name Value Variable_name Value
query_cache_size 0 query_cache_size 0
...@@ -602,7 +602,7 @@ select * from t1; ...@@ -602,7 +602,7 @@ select * from t1;
a a
set GLOBAL query_cache_size=20480; set GLOBAL query_cache_size=20480;
Warnings: 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"; show global variables like "query_cache_size";
Variable_name Value Variable_name Value
query_cache_size 0 query_cache_size 0
...@@ -610,7 +610,7 @@ select * from t1; ...@@ -610,7 +610,7 @@ select * from t1;
a a
set GLOBAL query_cache_size=40960; set GLOBAL query_cache_size=40960;
Warnings: 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"; show global variables like "query_cache_size";
Variable_name Value Variable_name Value
query_cache_size 0 query_cache_size 0
...@@ -762,7 +762,6 @@ select * from t3; ...@@ -762,7 +762,6 @@ select * from t3;
delete from t4 where a=1; delete from t4 where a=1;
flush query cache; flush query cache;
drop table t1,t2,t3,t4; drop table t1,t2,t3,t4;
set GLOBAL query_cache_size=0;
SET NAMES koi8r; SET NAMES koi8r;
CREATE TABLE t1 (a char(1) character set koi8r); CREATE TABLE t1 (a char(1) character set koi8r);
INSERT INTO t1 VALUES (_koi8r''),(_koi8r''); INSERT INTO t1 VALUES (_koi8r''),(_koi8r'');
...@@ -772,7 +771,7 @@ a ...@@ -772,7 +771,7 @@ a
1 1
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 12 Qcache_hits 6
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 1 Qcache_queries_in_cache 1
...@@ -783,7 +782,7 @@ a ...@@ -783,7 +782,7 @@ a
0 0
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 12 Qcache_hits 6
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 2
...@@ -794,7 +793,7 @@ a ...@@ -794,7 +793,7 @@ a
0 0
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 12 Qcache_hits 6
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 3 Qcache_queries_in_cache 3
...@@ -805,8 +804,9 @@ a ...@@ -805,8 +804,9 @@ a
0 0
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 12 Qcache_hits 6
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 4 Qcache_queries_in_cache 4
DROP TABLE t1; DROP TABLE t1;
SET GLOBAL query_cache_size=0;
...@@ -274,8 +274,8 @@ INSERT INTO t1 VALUES ...@@ -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), (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); (33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t1 range a,b a 5 NULL 2 Using where 1 SIMPLE t1 range a,b a 5 NULL 2 Using where
SELECT * FROM t1 WHERE a IN(1,2) AND b=5; SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
a b a b
DROP TABLE t1; DROP TABLE t1;
......
...@@ -8,8 +8,6 @@ stop slave; ...@@ -8,8 +8,6 @@ stop slave;
flush logs; flush logs;
reset slave; reset slave;
start 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 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 # # 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
...@@ -133,9 +133,9 @@ select * from t2 having MATCH inhalt AGAINST ('foobar'); ...@@ -133,9 +133,9 @@ select * from t2 having MATCH inhalt AGAINST ('foobar');
# check of fulltext errors # check of fulltext errors
# #
--error 1281 --error 1286
CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i)); CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i));
--error 1281 --error 1286
CREATE TABLE t3 (t int(11),i text, CREATE TABLE t3 (t int(11),i text,
j varchar(200) CHARACTER SET latin2, j varchar(200) CHARACTER SET latin2,
fulltext tix (i,j)); fulltext tix (i,j));
......
...@@ -7,7 +7,7 @@ drop table if exists t1; ...@@ -7,7 +7,7 @@ drop table if exists t1;
select length(encrypt('foo', 'ff')) <> 0; select length(encrypt('foo', 'ff')) <> 0;
--replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l. --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')); insert into t1 values ('tom', password('my_pass'));
set @pass='my_pass'; set @pass='my_pass';
select name from t1 where name='tom' and pw=password(@pass); select name from t1 where name='tom' and pw=password(@pass);
......
...@@ -205,6 +205,30 @@ explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; ...@@ -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; explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
DROP TABLE t1,t2; 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 # test for a bug with in() and unique key
create table t1 (id int(10) primary 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; ...@@ -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; select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
drop table t1,t2; 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
...@@ -78,6 +78,7 @@ int main(int argc, char **argv) { ...@@ -78,6 +78,7 @@ int main(int argc, char **argv) {
_print_csinfo(cs); _print_csinfo(cs);
fflush(stdout); fflush(stdout);
#define NOT_USED_ANYMORE
cs_list = list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG)); cs_list = list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG));
printf("LIST OF CHARSETS (compiled + *.conf):\n%s\n", cs_list); printf("LIST OF CHARSETS (compiled + *.conf):\n%s\n", cs_list);
my_free(cs_list,MYF(0)); my_free(cs_list,MYF(0));
...@@ -85,6 +86,7 @@ int main(int argc, char **argv) { ...@@ -85,6 +86,7 @@ int main(int argc, char **argv) {
cs_list = list_charsets(MYF(MY_CS_INDEX | MY_CS_LOADED)); cs_list = list_charsets(MYF(MY_CS_INDEX | MY_CS_LOADED));
printf("LIST OF CHARSETS (index + loaded):\n%s\n", cs_list); printf("LIST OF CHARSETS (index + loaded):\n%s\n", cs_list);
my_free(cs_list,MYF(0)); my_free(cs_list,MYF(0));
#endif
return 0; return 0;
} }
...@@ -1419,7 +1419,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -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 buff[NAME_LEN+USERNAME_LENGTH+100],charset_name_buff[16];
char *end,*host_info,*charset_name; char *end,*host_info,*charset_name;
my_socket sock; my_socket sock;
uint32 ip_addr; in_addr_t ip_addr;
struct sockaddr_in sock_addr; struct sockaddr_in sock_addr;
ulong pkt_length; ulong pkt_length;
NET *net= &mysql->net; NET *net= &mysql->net;
......
...@@ -2645,46 +2645,46 @@ String *Item_func_compress::val_str(String *str) ...@@ -2645,46 +2645,46 @@ String *Item_func_compress::val_str(String *str)
} }
buffer.length((uint32)new_size + 4); buffer.length((uint32)new_size + 4);
return &buffer; return &buffer;
} }
String *Item_func_uncompress::val_str(String *str) String *Item_func_uncompress::val_str(String *str)
{ {
String *res= args[0]->val_str(str); String *res= args[0]->val_str(str);
if (!res) ulong new_size;
{ int err;
null_value= 1;
return 0;
}
if (res->is_empty()) return res;
ulong new_size= uint4korr(res->c_ptr()) & 0x3FFFFFFF;
int err= Z_OK;
uint code; 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) if (new_size > current_thd->variables.max_allowed_packet)
{ {
push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR, push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_TOO_BIG_FOR_UNCOMPRESS, ER_TOO_BIG_FOR_UNCOMPRESS,
ER(ER_TOO_BIG_FOR_UNCOMPRESS), ER(ER_TOO_BIG_FOR_UNCOMPRESS),
current_thd->variables.max_allowed_packet); current_thd->variables.max_allowed_packet);
null_value= 0; goto err;
return 0;
} }
if (buffer.realloc((uint32)new_size))
goto err;
buffer.realloc((uint32)new_size); if ((err= uncompress((Byte*)buffer.ptr(), &new_size,
((const Bytef*)res->ptr())+4,res->length())) == Z_OK)
if ((err= uncompress((Byte*)buffer.c_ptr(), &new_size,
((const Bytef*)res->c_ptr())+4,res->length())) == Z_OK)
{ {
buffer.length((uint32)new_size); buffer.length((uint32) new_size);
return &buffer; return &buffer;
} }
code= err==Z_BUF_ERROR ? ER_ZLIB_Z_BUF_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; ((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)); push_warning(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,code,ER(code));
err:
null_value= 1; null_value= 1;
return 0; return 0;
} }
......
...@@ -835,7 +835,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, ...@@ -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), error_code(thd_arg->killed ? ER_SERVER_SHUTDOWN: thd_arg->net.last_errno),
thread_id(thd_arg->thread_id), thread_id(thd_arg->thread_id),
/* save the original thread id; we already know the server 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_t end_time;
time(&end_time); time(&end_time);
...@@ -1357,7 +1357,7 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex, ...@@ -1357,7 +1357,7 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
enum enum_duplicates handle_dup, enum enum_duplicates handle_dup,
bool using_trans) bool using_trans)
:Log_event(thd_arg, 0, using_trans), thread_id(thd_arg->thread_id), :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), num_fields(0),fields(0),
field_lens(0),field_block_len(0), field_lens(0),field_block_len(0),
table_name(table_name_arg ? table_name_arg : ""), table_name(table_name_arg ? table_name_arg : ""),
......
...@@ -496,7 +496,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag) ...@@ -496,7 +496,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
if (thd->client_capabilities & CLIENT_PROTOCOL_41) 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), prot.store(field.db_name, (uint) strlen(field.db_name),
cs, thd_charset) || cs, thd_charset) ||
prot.store(field.table_name, (uint) strlen(field.table_name), prot.store(field.table_name, (uint) strlen(field.table_name),
......
...@@ -1258,6 +1258,7 @@ int GMultiPolygon::geometry_n(uint32 num, String *result) const ...@@ -1258,6 +1258,7 @@ int GMultiPolygon::geometry_n(uint32 num, String *result) const
uint32 n_polygons; uint32 n_polygons;
const char *data= m_data, *polygon_n; const char *data= m_data, *polygon_n;
LINT_INIT(polygon_n); LINT_INIT(polygon_n);
if (no_data(data, 4)) if (no_data(data, 4))
return 1; return 1;
n_polygons= uint4korr(data); n_polygons= uint4korr(data);
......
...@@ -400,7 +400,7 @@ bool THD::store_globals() ...@@ -400,7 +400,7 @@ bool THD::store_globals()
By default 'slave_proxy_id' is 'thread_id'. They may later become different By default 'slave_proxy_id' is 'thread_id'. They may later become different
if this is the slave SQL thread. if this is the slave SQL thread.
*/ */
slave_proxy_id= thread_id; variables.pseudo_thread_id= thread_id;
return 0; return 0;
} }
......
...@@ -335,10 +335,12 @@ static char time_separator=':'; ...@@ -335,10 +335,12 @@ static char time_separator=':';
RETURN VALUES RETURN VALUES
TIMESTAMP_NONE String wasn't a timestamp, like 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_DATE DATE string (YY MM and DD parts ok)
TIMESTAMP_DATETIME Full timestamp TIMESTAMP_DATETIME Full timestamp
TIMESTAMP_DATETIME_ERROR Timestamp with wrong values TIMESTAMP_DATETIME_ERROR Timestamp with wrong values.
All elements in l_time is set to 0
*/ */
#define MAX_DATE_PARTS 8 #define MAX_DATE_PARTS 8
...@@ -409,9 +411,9 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags) ...@@ -409,9 +411,9 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
if (pos == end) if (pos == end)
{ {
if (flags & TIME_DATETIME_ONLY) 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 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 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) ...@@ -535,7 +537,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
if (format_position[7] != (uchar) 255) if (format_position[7] != (uchar) 255)
{ {
if (l_time->hour > 12) if (l_time->hour > 12)
DBUG_RETURN(TIMESTAMP_DATETIME_ERROR); goto err;
l_time->hour= l_time->hour%12 + add_hours; 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) ...@@ -574,7 +576,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
} }
if (not_zero_date) if (not_zero_date)
current_thd->cuted_fields++; current_thd->cuted_fields++;
DBUG_RETURN(TIMESTAMP_DATETIME_ERROR); goto err;
} }
if (str != end && current_thd->count_cuted_fields) 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) ...@@ -590,6 +592,10 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
DBUG_RETURN(l_time->time_type= DBUG_RETURN(l_time->time_type=
(number_of_fields <= 3 ? TIMESTAMP_DATE : TIMESTAMP_DATETIME)); (number_of_fields <= 3 ? TIMESTAMP_DATE : TIMESTAMP_DATETIME));
err:
bzero((char*) l_time, sizeof(*l_time));
DBUG_RETURN(TIMESTAMP_DATETIME_ERROR);
} }
......
...@@ -305,6 +305,7 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo) ...@@ -305,6 +305,7 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo)
{ {
keybuff[0]=(uchar) key_count; keybuff[0]=(uchar) key_count;
keybuff[1]=(uchar) key_parts; keybuff[1]=(uchar) key_parts;
keybuff[2]= keybuff[3]= 0;
} }
length=(uint) (pos-keyname_pos); length=(uint) (pos-keyname_pos);
int2store(keybuff+4,length); int2store(keybuff+4,length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment