summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <joreland@mysql.com>2005-06-09 08:12:14 +0200
committerunknown <joreland@mysql.com>2005-06-09 08:12:14 +0200
commit467b6dc477e905bd3f5f4a8705f5b3aa0fb097e1 (patch)
treea4e41bb500e2bb0d73a098e51c30689ac0ab53ee
parentaf0287be3c97eb1a4e42c6dd1b32e47b918139ce (diff)
parent777899a6f568105ab6242516300acd937a9785ec (diff)
downloadmariadb-git-467b6dc477e905bd3f5f4a8705f5b3aa0fb097e1.tar.gz
Merge mysql.com:/home/jonas/src/mysql-4.1
into mysql.com:/home/jonas/src/mysql-4.1-push
-rw-r--r--myisam/mi_check.c8
-rw-r--r--myisam/mi_key.c6
-rw-r--r--myisam/mi_rnext_same.c4
-rw-r--r--mysql-test/r/analyze.result32
-rw-r--r--mysql-test/r/ctype_utf8.result3
-rw-r--r--mysql-test/r/innodb_handler.result16
-rw-r--r--mysql-test/r/ps_1general.result12
-rw-r--r--mysql-test/r/ps_2myisam.result6
-rw-r--r--mysql-test/r/ps_3innodb.result6
-rw-r--r--mysql-test/r/ps_4heap.result6
-rw-r--r--mysql-test/r/ps_5merge.result12
-rw-r--r--mysql-test/t/analyze.test39
-rw-r--r--mysql-test/t/ctype_utf8.test1
-rw-r--r--mysql-test/t/innodb_handler.test10
-rw-r--r--mysys/my_fopen.c62
-rw-r--r--sql/sql_acl.cc10
-rw-r--r--sql/sql_class.cc10
-rw-r--r--sql/sql_handler.cc42
18 files changed, 215 insertions, 70 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index d59c9b9c697..60a2b664c70 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -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;
diff --git a/myisam/mi_key.c b/myisam/mi_key.c
index 6a8d88f1117..9df22889b22 100644
--- a/myisam/mi_key.c
+++ b/myisam/mi_key.c
@@ -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;
diff --git a/myisam/mi_rnext_same.c b/myisam/mi_rnext_same.c
index 06408f57a3f..4d770258a72 100644
--- a/myisam/mi_rnext_same.c
+++ b/myisam/mi_rnext_same.c
@@ -68,8 +68,8 @@ 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,
- info->last_rkey_length, SEARCH_FIND, &not_used))
+ if (ha_key_cmp(keyinfo->seg, info->lastkey, info->lastkey2,
+ info->last_rkey_length, SEARCH_FIND, &not_used))
{
error=1;
my_errno=HA_ERR_END_OF_FILE;
diff --git a/mysql-test/r/analyze.result b/mysql-test/r/analyze.result
new file mode 100644
index 00000000000..0b44a502b13
--- /dev/null
+++ b/mysql-test/r/analyze.result
@@ -0,0 +1,32 @@
+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;
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index ac421ea1717..29b18f0431c 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -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;
diff --git a/mysql-test/r/innodb_handler.result b/mysql-test/r/innodb_handler.result
index 7f4960ffa35..7e853a55e37 100644
--- a/mysql-test/r/innodb_handler.result
+++ b/mysql-test/r/innodb_handler.result
@@ -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
diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result
index 68d88a454ff..db8dc2e60af 100644
--- a/mysql-test/r/ps_1general.result
+++ b/mysql-test/r/ps_1general.result
@@ -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
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index fd17dc5b1b5..c569c9842f7 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -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
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index 50dc580a930..930aea2e381 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -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
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index 050a63f254c..083a4b221fe 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -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
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index c228ec4672f..1edd617ffc6 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -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
diff --git a/mysql-test/t/analyze.test b/mysql-test/t/analyze.test
new file mode 100644
index 00000000000..faf30279c68
--- /dev/null
+++ b/mysql-test/t/analyze.test
@@ -0,0 +1,39 @@
+#
+# 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;
+
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index a281558e5a1..3c49b2a47f7 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -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;
diff --git a/mysql-test/t/innodb_handler.test b/mysql-test/t/innodb_handler.test
index e8c486caf66..65728519e7b 100644
--- a/mysql-test/t/innodb_handler.test
+++ b/mysql-test/t/innodb_handler.test
@@ -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;
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index 3c6f1b15384..9dbac65b098 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -158,32 +158,52 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
DBUG_RETURN(fd);
} /* my_fdopen */
+/*
+ make_ftype
+ Make a filehandler-open-typestring from ordinary inputflags
- /* 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)
- *to++= 'w';
- else
- { /* Add '+' after theese */
- if (flag == O_RDWR)
+#endif
+ flag&= ~FILE_BINARY; /* remove binary bit */
+
+ /* 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 if (flag & O_APPEND)
+ *to++= 'a';
+ else
*to++= 'r';
- else if (flag & O_APPEND)
- *to++= 'a';
- else
- *to++= 'w'; /* Create file */
- *to++= '+';
- }
-#if FILE_BINARY /* If we have binary-files */
- if (org_flag & FILE_BINARY)
+ *to++= '+';
+ }
+ else
+ *to++= 'r';
+
+#if FILE_BINARY /* If we have binary-files */
+ if (org_flag & FILE_BINARY)
*to++='b';
-#endif
+#endif
*to='\0';
} /* make_ftype */
+
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 5e36978b210..849192154da 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -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;
}
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 805db107370..e845769d7ad 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -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));
}
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index aa791276404..491b82c1c1d 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -429,12 +429,10 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
}
tables->table=table;
- if (cond && ((!cond->fixed &&
+ if (cond && ((!cond->fixed &&
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);
@@ -517,7 +527,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
for (key_len=0 ; (item=it_ke++) ; key_part++)
{
// 'item' can be changed by fix_fields() call
- if ((!item->fixed &&
+ if ((!item->fixed &&
item->fix_fields(thd, tables, it_ke.ref())) ||
(item= *it_ke.ref())->check_cols(1))
goto err;
@@ -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];