diff options
author | unknown <igor@rurik.mysql.com> | 2003-06-12 06:22:35 -0700 |
---|---|---|
committer | unknown <igor@rurik.mysql.com> | 2003-06-12 06:22:35 -0700 |
commit | 4678681895363ee9366ac1567d94458230020c16 (patch) | |
tree | 148b8c692128d7dcdb3d773ae94f069f283fce24 /mysys | |
parent | 2aab83ccdfc3626808882df4f08e2113f2d52f6d (diff) | |
parent | f3ecad8cc99f0db0c891fe51d1099c7bc5273078 (diff) | |
download | mariadb-git-4678681895363ee9366ac1567d94458230020c16.tar.gz |
Merge rurik.mysql.com:/home/igor/mysql-4.1
into rurik.mysql.com:/home/igor/dev/mysql-4.1-0
include/my_base.h:
Auto merged
include/my_sys.h:
Auto merged
myisam/myisamdef.h:
Auto merged
sql/ha_myisam.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/handler.h:
Auto merged
sql/lex.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/mf_keycache.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 264037e9a70..3276044fc2f 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -1259,6 +1259,86 @@ byte *key_cache_read(File file, my_off_t filepos, byte *buff, uint length, /* + Insert a block of file data from a buffer into key cache + + SYNOPSIS + key_cache_insert() + file file descriptor + filepos file offset of the data from the buffer + buff buffer with data to insert into key cache + length length of the data in the buffer + + RETURN VALUE + 0 if a success, 1 -otherwise. +*/ + +int key_cache_insert(File file, my_off_t filepos, byte *buff, uint length) +{ + DBUG_ENTER("key_cache_insert"); + DBUG_PRINT("enter", ("file %u, filepos %lu, length %u", + (uint) file,(ulong) filepos, length)); + + if (my_disk_blocks > 0) + { + /* Key cache is used */ + reg1 BLOCK_LINK *block; + uint offset= (uint) (filepos & (key_cache_block_size-1)); + uint read_length; + int page_st; + + /* Read data into key cache from buff in key_cache_block_size increments */ + filepos-= offset; + do + { + read_length= length > key_cache_block_size ? + key_cache_block_size : length; + KEYCACHE_DBUG_ASSERT(read_length > 0); + keycache_pthread_mutex_lock(&THR_LOCK_keycache); + my_cache_r_requests++; + block=find_key_block(file, filepos, 0, &page_st); + if (block->status != BLOCK_ERROR && page_st != PAGE_READ) + { + /* The requested page is to be read into the block buffer */ +#if !defined(SERIALIZED_READ_FROM_CACHE) + keycache_pthread_mutex_unlock(&THR_LOCK_keycache); +#endif + + /* Copy data from buff */ + if (!(read_length & 511)) + bmove512(block->buffer+offset, buff, read_length); + else + memcpy(block->buffer+offset, buff, (size_t) read_length); + +#if !defined(SERIALIZED_READ_FROM_CACHE) + keycache_pthread_mutex_lock(&THR_LOCK_keycache); +#endif + block->status= BLOCK_READ; + block->length= read_length+offset; + } + + remove_reader(block); + /* + Link the block into the LRU chain + if it's the last submitted request for the block + */ + unreg_request(block,1); + + keycache_pthread_mutex_unlock(&THR_LOCK_keycache); + + if (block->status & BLOCK_ERROR) + DBUG_RETURN(1); + + buff+=read_length; + filepos+=read_length; + offset=0; + + } while ((length-= read_length)); + } + DBUG_RETURN(0); +} + + +/* Write a buffer into disk; filepos must be a multiple of 'block_length', but it doesn't have to be a multiple of key cache block size; |