Commit 5c9dee55 authored by joreland@mysql.com's avatar joreland@mysql.com

Merge mysql.com:/home/jonas/src/mysql-4.1

into mysql.com:/home/jonas/src/mysql-4.1-push
parents a5a13ea8 e23f2491
......@@ -3870,6 +3870,14 @@ int update_state_info(MI_CHECK *param, MI_INFO *info,uint update)
if (!share->state.create_time)
share->state.create_time=share->state.check_time;
}
/*
When tables are locked we haven't synched the share state and the
real state for a while so we better do it here before synching
the share state to disk. Only when table is write locked is it
necessary to perform this synch.
*/
if (info->lock_type == F_WRLCK)
share->state.state= *info->state;
if (mi_state_info_write(share->kfile,&share->state,1+2))
goto err;
share->changed=0;
......
......@@ -84,8 +84,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
pos= (byte*) record+keyseg->start;
if (keyseg->flag & HA_SPACE_PACK)
{
FIX_LENGTH(cs, pos, length, char_length);
end= pos + char_length;
end= pos + length;
if (type != HA_KEYTYPE_NUM)
{
while (end > pos && end[-1] == ' ')
......@@ -96,7 +95,8 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
while (pos < end && pos[0] == ' ')
pos++;
}
char_length= (uint) (end - pos);
length=(uint) (end-pos);
FIX_LENGTH(cs, pos, length, char_length);
store_key_length_inc(key,char_length);
memcpy((byte*) key,(byte*) pos,(size_t) char_length);
key+=char_length;
......
......@@ -68,7 +68,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
info->lastkey_length,SEARCH_BIGGER,
info->s->state.key_root[inx])))
break;
if (ha_key_cmp(keyinfo->seg,info->lastkey2,info->lastkey,
if (ha_key_cmp(keyinfo->seg, info->lastkey, info->lastkey2,
info->last_rkey_length, SEARCH_FIND, &not_used))
{
error=1;
......
create table t1 (a bigint);
lock tables t1 write;
insert into t1 values(0);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
unlock tables;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (a bigint);
insert into t1 values(0);
lock tables t1 write;
delete from t1;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
unlock tables;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (a bigint);
insert into t1 values(0);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
......@@ -901,4 +901,7 @@ insert into t1 values (2,'Durban');
select * from t1 where city = 'Durban';
id city
2 Durban
select * from t1 where city = 'Durban ';
id city
2 Durban
drop table t1;
......@@ -132,6 +132,22 @@ a b
handler t2 read last;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
handler t2 close;
handler t1 open;
handler t1 read a next;
a b
14 aaa
handler t1 read a next;
a b
15 bbb
handler t1 close;
handler t1 open;
handler t1 read a prev;
a b
22 iii
handler t1 read a prev;
a b
21 hhh
handler t1 close;
handler t1 open as t2;
handler t2 read first;
a b
......
......@@ -468,13 +468,13 @@ execute stmt1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
def type 253 10 3 N 1 31 8
def table 253 64 2 Y 0 31 8
def type 253 10 3 Y 0 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32928 0 63
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32929 0 63
def rows 8 10 1 Y 32928 0 63
def Extra 253 255 14 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
......@@ -484,13 +484,13 @@ execute stmt1 using @arg00;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
def type 253 10 5 N 1 31 8
def table 253 64 2 Y 0 31 8
def type 253 10 5 Y 0 31 8
def possible_keys 253 4096 7 Y 0 31 8
def key 253 64 7 Y 0 31 8
def key_len 8 3 1 Y 32928 0 63
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32929 0 63
def rows 8 10 1 Y 32928 0 63
def Extra 253 255 27 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using filesort
......
......@@ -1151,13 +1151,13 @@ execute stmt1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
def type 253 10 3 N 1 31 8
def table 253 64 2 Y 0 31 8
def type 253 10 3 Y 0 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32928 0 63
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32929 0 63
def rows 8 10 1 Y 32928 0 63
def Extra 253 255 0 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
......
......@@ -1151,13 +1151,13 @@ execute stmt1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
def type 253 10 3 N 1 31 8
def table 253 64 2 Y 0 31 8
def type 253 10 3 Y 0 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32928 0 63
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32929 0 63
def rows 8 10 1 Y 32928 0 63
def Extra 253 255 0 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
......
......@@ -1152,13 +1152,13 @@ execute stmt1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
def type 253 10 3 N 1 31 8
def table 253 64 2 Y 0 31 8
def type 253 10 3 Y 0 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32928 0 63
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32929 0 63
def rows 8 10 1 Y 32928 0 63
def Extra 253 255 0 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
......
......@@ -1194,13 +1194,13 @@ execute stmt1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
def type 253 10 3 N 1 31 8
def table 253 64 2 Y 0 31 8
def type 253 10 3 Y 0 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32928 0 63
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32929 0 63
def rows 8 10 1 Y 32928 0 63
def Extra 253 255 0 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
......@@ -4208,13 +4208,13 @@ execute stmt1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
def type 253 10 3 N 1 31 8
def table 253 64 2 Y 0 31 8
def type 253 10 3 Y 0 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32928 0 63
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32929 0 63
def rows 8 10 1 Y 32928 0 63
def Extra 253 255 0 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
......
#
# Bug #10901 Analyze Table on new table destroys table
# This is minimal test case to get error
# The problem was that analyze table wrote the shared state to the file and this
# didn't include the inserts while locked. A check was needed to ensure that
# state information was not updated when executing analyze table for a locked table.
# The analyze table had to be within locks and check table had to be after unlocking
# since then it brings the wrong state from disk rather than from the currently
# correct internal state. The insert is needed since it changes the file state,
# number of records.
# The fix is to synchronise the state of the shared state and the current state before
# calling mi_state_info_write
#
create table t1 (a bigint);
lock tables t1 write;
insert into t1 values(0);
analyze table t1;
unlock tables;
check table t1;
drop table t1;
create table t1 (a bigint);
insert into t1 values(0);
lock tables t1 write;
delete from t1;
analyze table t1;
unlock tables;
check table t1;
drop table t1;
create table t1 (a bigint);
insert into t1 values(0);
analyze table t1;
check table t1;
drop table t1;
......@@ -744,4 +744,5 @@ create table t1 (
insert into t1 values (1,'Durban North');
insert into t1 values (2,'Durban');
select * from t1 where city = 'Durban';
select * from t1 where city = 'Durban ';
drop table t1;
......@@ -69,6 +69,16 @@ handler t2 read next;
handler t2 read last;
handler t2 close;
handler t1 open;
handler t1 read a next; # this used to crash as a bug#5373
handler t1 read a next;
handler t1 close;
handler t1 open;
handler t1 read a prev; # this used to crash as a bug#5373
handler t1 read a prev;
handler t1 close;
handler t1 open as t2;
handler t2 read first;
alter table t1 engine=innodb;
......
......@@ -158,32 +158,52 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
DBUG_RETURN(fd);
} /* my_fdopen */
/* Make a filehandler-open-typestring from ordinary inputflags */
/*
make_ftype
Make a filehandler-open-typestring from ordinary inputflags
Note: This routine attempts to find the best possible match
between a numeric option and a string option that could be
fed to fopen. There is not a 1 to 1 mapping between the two.
r == O_RDONLY
w == O_WRONLY|O_TRUNC|O_CREAT
a == O_WRONLY|O_APPEND|O_CREAT
r+ == O_RDWR
w+ == O_RDWR|O_TRUNC|O_CREAT
a+ == O_RDWR|O_APPEND|O_CREAT
*/
static void make_ftype(register my_string to, register int flag)
{
#if FILE_BINARY /* If we have binary-files */
#if FILE_BINARY
/* If we have binary-files */
reg3 int org_flag=flag;
#endif
flag&= ~FILE_BINARY; /* remove binary bit */
if (flag == O_RDONLY)
*to++= 'r';
else if (flag == O_WRONLY)
/* check some possible invalid combinations */
DBUG_ASSERT(flag & (O_TRUNC|O_APPEND) != O_TRUNC|O_APPEND);
if (flag & (O_RDONLY|O_WRONLY) == O_WRONLY)
*to++= (flag & O_TRUNC) ? 'w' : 'a';
else if (flag & O_RDWR)
{
/* Add '+' after theese */
if (flag & O_TRUNC)
*to++= 'w';
else
{ /* Add '+' after theese */
if (flag == O_RDWR)
*to++= 'r';
else if (flag & O_APPEND)
*to++= 'a';
else
*to++= 'w'; /* Create file */
*to++= 'r';
*to++= '+';
}
else
*to++= 'r';
#if FILE_BINARY /* If we have binary-files */
if (org_flag & FILE_BINARY)
*to++='b';
#endif
*to='\0';
} /* make_ftype */
......@@ -198,7 +198,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
ACL_HOST host;
update_hostname(&host.host,get_field(&mem, table->field[0]));
host.db= get_field(&mem, table->field[1]);
if (lower_case_table_names)
if (lower_case_table_names && host.db)
{
/*
We make a temporary copy of the database, force it to lower case,
......@@ -222,7 +222,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
{
sql_print_warning("'host' entry '%s|%s' "
"ignored in --skip-name-resolve mode.",
host.host.hostname, host.db, host.host.hostname);
host.host.hostname, host.db?host.db:"");
continue;
}
#ifndef TO_BE_REMOVED
......@@ -290,7 +290,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
{
sql_print_warning("'user' entry '%s@%s' "
"ignored in --skip-name-resolve mode.",
user.user, user.host.hostname, user.host.hostname);
user.user, user.host.hostname);
continue;
}
......@@ -393,7 +393,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
{
sql_print_warning("'db' entry '%s %s@%s' "
"ignored in --skip-name-resolve mode.",
db.db, db.user, db.host.hostname, db.host.hostname);
db.db, db.user, db.host.hostname);
continue;
}
db.access=get_access(table,3);
......@@ -2690,7 +2690,7 @@ my_bool grant_init(THD *org_thd)
sql_print_warning("'tables_priv' entry '%s %s@%s' "
"ignored in --skip-name-resolve mode.",
mem_check->tname, mem_check->user,
mem_check->host, mem_check->host);
mem_check->host);
continue;
}
}
......
......@@ -667,8 +667,10 @@ int THD::send_explain_fields(select_result *result)
CHARSET_INFO *cs= system_charset_info;
field_list.push_back(new Item_return_int("id",3, MYSQL_TYPE_LONGLONG));
field_list.push_back(new Item_empty_string("select_type", 19, cs));
field_list.push_back(new Item_empty_string("table", NAME_LEN, cs));
field_list.push_back(new Item_empty_string("type", 10, cs));
field_list.push_back(item= new Item_empty_string("table", NAME_LEN, cs));
item->maybe_null= 1;
field_list.push_back(item= new Item_empty_string("type", 10, cs));
item->maybe_null= 1;
field_list.push_back(item=new Item_empty_string("possible_keys",
NAME_LEN*MAX_KEY, cs));
item->maybe_null=1;
......@@ -680,7 +682,9 @@ int THD::send_explain_fields(select_result *result)
field_list.push_back(item=new Item_empty_string("ref",
NAME_LEN*MAX_REF_PARTS, cs));
item->maybe_null=1;
field_list.push_back(new Item_return_int("rows", 10, MYSQL_TYPE_LONGLONG));
field_list.push_back(item= new Item_return_int("rows", 10,
MYSQL_TYPE_LONGLONG));
item->maybe_null= 1;
field_list.push_back(new Item_empty_string("Extra", 255, cs));
return (result->send_fields(field_list,1));
}
......
......@@ -433,8 +433,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
cond->fix_fields(thd, tables, &cond)) || cond->check_cols(1)))
goto err0;
table->file->init_table_handle_for_HANDLER(); // Only InnoDB requires it
if (keyname)
{
if ((keyno=find_type(keyname, &table->keynames, 1+2)-1)<0)
......@@ -443,8 +441,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
keyname,tables->alias);
goto err0;
}
table->file->ha_index_or_rnd_end();
table->file->ha_index_init(keyno);
}
if (insert_fields(thd,tables,tables->db,tables->alias,&it))
......@@ -471,9 +467,22 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
for (num_rows=0; num_rows < select_limit; )
{
switch (mode) {
case RNEXT:
if (table->file->inited != handler::NONE)
{
err=keyname ?
table->file->index_next(table->record[0]) :
table->file->rnd_next(table->record[0]);
break;
}
/* else fall through */
case RFIRST:
if (keyname)
{
table->file->ha_index_or_rnd_end();
table->file->ha_index_init(keyno);
err=table->file->index_first(table->record[0]);
}
else
{
table->file->ha_index_or_rnd_end();
......@@ -482,20 +491,21 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
}
mode=RNEXT;
break;
case RPREV:
DBUG_ASSERT(keyname != 0);
if (table->file->inited != handler::NONE)
{
err=table->file->index_prev(table->record[0]);
break;
}
/* else fall through */
case RLAST:
DBUG_ASSERT(keyname != 0);
table->file->ha_index_or_rnd_end();
table->file->ha_index_init(keyno);
err=table->file->index_last(table->record[0]);
mode=RPREV;
break;
case RNEXT:
err=keyname ?
table->file->index_next(table->record[0]) :
table->file->rnd_next(table->record[0]);
break;
case RPREV:
DBUG_ASSERT(keyname != 0);
err=table->file->index_prev(table->record[0]);
break;
case RNEXT_SAME:
/* Continue scan on "(keypart1,keypart2,...)=(c1, c2, ...) */
DBUG_ASSERT(keyname != 0);
......@@ -535,6 +545,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
goto err;
}
key_copy(key, table, keyno, key_len);
table->file->ha_index_or_rnd_end();
table->file->ha_index_init(keyno);
err=table->file->index_read(table->record[0],
key,key_len,ha_rkey_mode);
mode=rkey_to_rnext[(int)ha_rkey_mode];
......
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