summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authormonty@donna.mysql.com <>2000-11-16 03:58:58 +0200
committermonty@donna.mysql.com <>2000-11-16 03:58:58 +0200
commita9097ca323bf399c5fc45d94a9b121c304f7681e (patch)
tree4b8f3df4d2aef33906b1e7e311b909e12f38539e /myisam
parentb689a1a752cceae61420ae05c237f550710b954c (diff)
downloadmariadb-git-a9097ca323bf399c5fc45d94a9b121c304f7681e.tar.gz
changed to use IO_CACHE instead of FILE
Diffstat (limited to 'myisam')
-rw-r--r--myisam/mi_create.c1
-rw-r--r--myisam/mi_locking.c6
-rw-r--r--myisam/mi_open.c5
-rw-r--r--myisam/mi_search.c6
-rw-r--r--myisam/myisamdef.h1
5 files changed, 15 insertions, 4 deletions
diff --git a/myisam/mi_create.c b/myisam/mi_create.c
index 048bbb427a2..89bdcdf3fbc 100644
--- a/myisam/mi_create.c
+++ b/myisam/mi_create.c
@@ -417,6 +417,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
share.state.dellink = HA_OFFSET_ERROR;
share.state.process= (ulong) getpid();
share.state.unique= (ulong) 0;
+ share.state.update_count=(ulong) 0;
share.state.version= (ulong) time((time_t*) 0);
share.state.sortkey= (ushort) ~0;
share.state.auto_increment=ci->auto_increment;
diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c
index 4797584627a..45bb2cd7164 100644
--- a/myisam/mi_locking.c
+++ b/myisam/mi_locking.c
@@ -70,6 +70,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
{
share->state.process= share->last_process=share->this_process;
share->state.unique= info->last_unique= info->this_unique;
+ share->state.update_count= info->last_loop= ++info->this_loop;
if (mi_state_info_write(share->kfile, &share->state, 1))
error=my_errno;
share->changed=0;
@@ -346,6 +347,7 @@ int _mi_writeinfo(register MI_INFO *info, uint operation)
{ /* Two threads can't be here */
share->state.process= share->last_process= share->this_process;
share->state.unique= info->last_unique= info->this_unique;
+ share->state.update_count= info->last_loop= ++info->this_loop;
if ((error=mi_state_info_write(share->kfile, &share->state, 1)))
olderror=my_errno;
#ifdef __WIN__
@@ -377,12 +379,14 @@ int _mi_test_if_changed(register MI_INFO *info)
{
MYISAM_SHARE *share=info->s;
if (share->state.process != share->last_process ||
- share->state.unique != info->last_unique)
+ share->state.unique != info->last_unique ||
+ share->state.update_count != info->last_loop)
{ /* Keyfile has changed */
if (share->state.process != share->this_process)
VOID(flush_key_blocks(share->kfile,FLUSH_RELEASE));
share->last_process=share->state.process;
info->last_unique= share->state.unique;
+ info->last_loop= share->state.update_count;
info->update|= HA_STATE_WRITTEN; /* Must use file on next */
info->data_changed= 1; /* For mi_is_changed */
return 1;
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index aeaf9e5e9b4..c29a4a843ca 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -445,8 +445,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
info.this_unique= (ulong) info.dfile; /* Uniq number in process */
if (share->data_file_type == COMPRESSED_RECORD)
info.this_unique= share->state.unique;
- info.this_loop=0; /* Update counter */
+ info.this_loop=0; /* Update counter */
info.last_unique= share->state.unique;
+ info.last_loop= share->state.update_count;
if (mode == O_RDONLY)
share->options|=HA_OPTION_READ_ONLY_DATA;
info.lock_type=F_UNLCK;
@@ -669,7 +670,7 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite)
mi_int4store(ptr,state->process); ptr +=4;
mi_int4store(ptr,state->unique); ptr +=4;
mi_int4store(ptr,state->status); ptr +=4;
- *ptr++=0; *ptr++=0; *ptr++=0; *ptr++=0; /* extra */
+ mi_int4store(ptr,state->update_count); ptr +=4;
ptr+=state->state_diff_length;
diff --git a/myisam/mi_search.c b/myisam/mi_search.c
index eead2a84c29..3ffc348ca5c 100644
--- a/myisam/mi_search.c
+++ b/myisam/mi_search.c
@@ -1214,7 +1214,11 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo,
DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg,key,key_length););
/* Force full read if we are at last key or if we are not on a leaf
- and the key tree has changed since we used it last time */
+ and the key tree has changed since we used it last time
+ Note that even if the key tree has changed since last read, we can use
+ the last read data from the leaf if we haven't used the buffer for
+ something else.
+ */
if (((nextflag & SEARCH_BIGGER) && info->int_keypos >= info->int_maxpos) ||
info->page_changed ||
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index a65694dbd94..ad153d58b70 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -64,6 +64,7 @@ typedef struct st_mi_state_info
ulonglong auto_increment;
ulong process; /* process that updated table last */
ulong unique; /* Unique number for this process */
+ ulong update_count; /* Updated for each write lock */
ulong status;
my_off_t *key_root; /* Start of key trees */
my_off_t *key_del; /* delete links for trees */