Merge key cache structures to one

Fixed compiler warnings (IRIX C compiler and VC++)


VC++Files/client/mysqlclient.dsp:
  Add missing file to project
VC++Files/libmysql/libmysql.dsp:
  Add missing file to project
VC++Files/myisam/myisam.dsp:
  Add missing file to project
VC++Files/mysys/mysys.dsp:
  Add missing file to project
heap/hp_test1.c:
  Fixed wrong call to heap_rkey()
heap/hp_test2.c:
  Fixed wrong call to heap_rkey()
include/hash.h:
  Move not used (internal) struct to hash.c
include/my_pthread.h:
  Made some structs 'const char*' to avoid warnings
include/my_sys.h:
  Moved key cache structs and functions to keycache.h
include/myisam.h:
  Merge key cache structures to one
include/mysql.h:
  Remove STDCALL from internal functions
include/sql_common.h:
  Remove STDCALL from internal functions
include/violite.h:
  Fixed compiler warning
isam/_locking.c:
  Merge key cache structures to one
isam/_page.c:
  Merge key cache structures to one
isam/close.c:
  Merge key cache structures to one
isam/extra.c:
  Merge key cache structures to one
isam/isamchk.c:
  Merge key cache structures to one
isam/isamdef.h:
  Merge key cache structures to one
isam/isamlog.c:
  Merge key cache structures to one
isam/panic.c:
  Merge key cache structures to one
isam/test2.c:
  Merge key cache structures to one
isam/test3.c:
  Merge key cache structures to one
libmysql/client_settings.h:
  Remove STDCALL from internal functions
libmysql/libmysql.c:
  Remove STDCALL from internal functions
myisam/ft_boolean_search.c:
  Fixed compiler warning
myisam/ft_dump.c:
  Fixed compiler warnings (%qx is not portable)
myisam/ft_update.c:
  Fixed compiler warnings
myisam/mi_check.c:
  Merge key cache structures to one
myisam/mi_close.c:
  Merge key cache structures to one
myisam/mi_delete_all.c:
  Merge key cache structures to one
myisam/mi_extra.c:
  Merge key cache structures to one
myisam/mi_keycache.c:
  Merge key cache structures to one
myisam/mi_locking.c:
  Merge key cache structures to one
myisam/mi_page.c:
  Merge key cache structures to one
myisam/mi_panic.c:
  Merge key cache structures to one
myisam/mi_preload.c:
  Merge key cache structures to one
myisam/mi_test1.c:
  Merge key cache structures to one
myisam/mi_test2.c:
  Merge key cache structures to one
myisam/mi_test3.c:
  Merge key cache structures to one
myisam/myisamchk.c:
  Merge key cache structures to one
myisam/myisamdef.h:
  Merge key cache structures to one
myisam/myisamlog.c:
  Merge key cache structures to one
  Removed not used option
myisam/sort.c:
  Fixed compiler warnings
myisam/sp_test.c:
  Fixed compiler warnings
mysql-test/r/case.result:
  Updated results after fix of correct NULL detection in WHEN
mysql-test/r/date_formats.result:
  Updated results after fixing date handling
mysql-test/r/symlink.result:
  Updated results after adding DEFAULT CHARSET
mysql-test/t/case.test:
  New test
mysql-test/t/symlink.test:
  Updated error numbers
mysys/hash.c:
  Made HASH_LINK struct local
mysys/mf_keycache.c:
  Merge key cache structures to one
  Fixed key_cache_read() and key_cache_write() to be resize-safe.
mysys/mf_keycaches.c:
  Merge key cache structures to one
mysys/thr_mutex.c:
  Added test if mutex is initalized
sql-common/client.c:
  Remove STDCALL from internal functions
sql/derror.cc:
  Added comment
sql/field.cc:
  Removed not used variables
sql/ha_innodb.cc:
  Fixed compiler warnings (removed not used variables)
sql/ha_myisam.cc:
  Merge key cache structures to one
sql/ha_myisammrg.cc:
  Removed not used variables
sql/handler.cc:
  Merge key cache structures to one
sql/handler.h:
  Merge key cache structures to one
sql/item.cc:
  Fixed compiler warning
sql/item_cmpfunc.cc:
  Remove not used variables
sql/item_func.cc:
  Remove not used variables
sql/item_strfunc.cc:
  Removed not used variables
sql/item_sum.cc:
  Removed not used variables
  Moved setting of item_thd to fix_fields()
sql/item_timefunc.cc:
  Removed not used variables
sql/mysql_priv.h:
  Merge key cache structures to one
sql/mysqld.cc:
  Merge key cache structures to one
  init_thread_environment() is not called before mysql_init_variables(). This fixes a case where a mutex was not initialized before it was used
sql/opt_sum.cc:
  Remove not used variables
sql/protocol.cc:
  Don't send errors after ok has been sent
sql/protocol_cursor.cc:
  Remove not used variable
  Simple optimization
sql/repl_failsafe.cc:
  Remove not used variables
sql/set_var.cc:
  Merge key cache structures to one
sql/set_var.h:
  Merge key cache structures to one
sql/sql_acl.cc:
  Remove not used variables
sql/sql_base.cc:
  Remove not used function
sql/sql_db.cc:
  Remove not used variables
sql/sql_handler.cc:
  Remove not used variables
sql/sql_insert.cc:
  More DBUG statements
  Simple code cleanup
sql/sql_lex.cc:
  Remove not used variables
sql/sql_parse.cc:
  Remove not used variables
sql/sql_prepare.cc:
  Remove not used variables
sql/sql_repl.cc:
  Remove not used variables
sql/sql_select.cc:
  Remove not used variables
sql/sql_show.cc:
  Remove not used variables
sql/sql_table.cc:
  Merge key cache structures to one
  Removed not used variables
sql/sql_test.cc:
  Merge key cache structures to one
sql/strfunc.cc:
  Fixed that find_type() returns correct value for partly matched words.
  (This fixed the error found by date_formats.test)
sql/time.cc:
  Remove not used variables
strings/my_strtoll10.c:
  Fixed compiler warnings
This commit is contained in:
unknown 2003-11-20 22:06:25 +02:00
parent f25cbdd914
commit 35da5e43fb
93 changed files with 739 additions and 712 deletions

View file

@ -100,6 +100,10 @@ SOURCE=..\strings\bmove_upp.c
# End Source File
# Begin Source File
SOURCE="..\mysys\charset-def.c"
# End Source File
# Begin Source File
SOURCE=..\mysys\charset.c
# End Source File
# Begin Source File

View file

@ -119,6 +119,10 @@ SOURCE=..\strings\bmove_upp.c
# End Source File
# Begin Source File
SOURCE="..\mysys\charset-def.c"
# End Source File
# Begin Source File
SOURCE=..\mysys\charset.c
# End Source File
# Begin Source File

View file

@ -25,7 +25,7 @@ CFG=myisam - Win32 Debug
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "myisam - Win32 Release"
@ -47,7 +47,7 @@ RSC=rc.exe
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib_release\myisam.lib"
@ -70,7 +70,7 @@ LIB32=link.exe -lib
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib_Debug\myisam.lib"
@ -169,6 +169,10 @@ SOURCE=.\mi_key.c
# End Source File
# Begin Source File
SOURCE=.\mi_keycache.c
# End Source File
# Begin Source File
SOURCE=.\mi_locking.c
# End Source File
# Begin Source File

View file

@ -126,6 +126,10 @@ SOURCE=.\array.c
# End Source File
# Begin Source File
SOURCE=".\charset-def.c"
# End Source File
# Begin Source File
SOURCE=.\charset.c
# End Source File
# Begin Source File

View file

@ -91,7 +91,7 @@ int main(int argc, char **argv)
{
if (i == remove_ant) { VOID(heap_close(file)) ; return (0) ; }
sprintf(key,"%6d",(j=(int) ((rand() & 32767)/32767.*25)));
if ((error = heap_rkey(file,record,0,key,0,6)))
if ((error = heap_rkey(file,record,0,key,6,HA_READ_KEY_EXACT)))
{
if (verbose || (flags[j] == 1 ||
(error && my_errno != HA_ERR_KEY_NOT_FOUND)))
@ -119,7 +119,7 @@ int main(int argc, char **argv)
sprintf(key,"%6d",i);
bmove(record+1,key,6);
my_errno=0;
error=heap_rkey(file,record,0,key,0,6);
error=heap_rkey(file,record,0,key,6,HA_READ_KEY_EXACT);
if (verbose ||
(error == 0 && flags[i] != 1) ||
(error && (flags[i] != 0 || my_errno != HA_ERR_KEY_NOT_FOUND)))

View file

@ -179,7 +179,7 @@ int main(int argc, char *argv[])
if (j != 0)
{
sprintf(key,"%6d",j);
if (heap_rkey(file,record,0,key,6,0))
if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT))
{
printf("can't find key1: \"%s\"\n",key);
goto err;
@ -239,7 +239,7 @@ int main(int argc, char *argv[])
if (!key1[j])
continue;
sprintf(key,"%6d",j);
if (heap_rkey(file,record,0,key,6,0))
if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT))
{
printf("can't find key1: \"%s\"\n",key);
goto err;
@ -289,7 +289,7 @@ int main(int argc, char *argv[])
printf("- Read first key - next - delete - next -> last\n");
DBUG_PRINT("progpos",("first - next - delete - next -> last"));
if (heap_rkey(file,record,0,key,6,0))
if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT))
goto err;
if (heap_rnext(file,record3)) goto err;
if (heap_delete(file,record3)) goto err;
@ -513,7 +513,7 @@ int main(int argc, char *argv[])
}
printf("- Read through all keys with first-next-last-prev\n");
ant=0;
for (error=heap_rkey(file,record,0,key,6,0);
for (error=heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT);
! error ;
error=heap_rnext(file,record))
ant++;
@ -550,7 +550,8 @@ int main(int argc, char *argv[])
{
if (error == 0)
{
if (heap_rkey(file2,record2,2,record+keyinfo[2].seg[0].start,8,0))
if (heap_rkey(file2,record2,2,record+keyinfo[2].seg[0].start,8,
HA_READ_KEY_EXACT))
{
printf("can't find key3: \"%.8s\"\n",
record+keyinfo[2].seg[0].start);

View file

@ -22,14 +22,15 @@
extern "C" {
#endif
/*
Overhead to store an element in hash
Can be used to approximate memory consumption for a hash
*/
#define HASH_OVERHEAD (sizeof(char*)*2)
typedef byte *(*hash_get_key)(const byte *,uint*,my_bool);
typedef void (*hash_free_key)(void *);
typedef struct st_hash_info {
uint next; /* index to next key */
byte *data; /* data for current entry */
} HASH_LINK;
typedef struct st_hash {
uint key_offset,key_length; /* Length of key if const length */
uint records,blength,current_record;

134
include/keycache.h Normal file
View file

@ -0,0 +1,134 @@
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Key cache variable structures */
#ifndef _keycache_h
#define _keycache_h
C_MODE_START
/* declare structures that is used by st_key_cache */
struct st_block_link;
typedef struct st_block_link BLOCK_LINK;
struct st_keycache_page;
typedef struct st_keycache_page KEYCACHE_PAGE;
struct st_hash_link;
typedef struct st_hash_link HASH_LINK;
/* info about requests in a waiting queue */
typedef struct st_keycache_wqueue
{
struct st_my_thread_var *last_thread; /* circular list of waiting threads */
} KEYCACHE_WQUEUE;
#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */
/*
The key cache structure
It also contains read-only statistics parameters.
*/
typedef struct st_key_cache
{
my_bool key_cache_inited;
uint key_cache_shift;
ulong key_cache_mem_size; /* specified size of the cache memory */
uint key_cache_block_size; /* size of the page buffer of a cache block */
ulong min_warm_blocks; /* min number of warm blocks; */
ulong age_threshold; /* age threshold for hot blocks */
ulonglong keycache_time; /* total number of block link operations */
uint hash_entries; /* max number of entries in the hash table */
int hash_links; /* max number of hash links */
int hash_links_used; /* number of hash links currently used */
int disk_blocks; /* max number of blocks in the cache */
ulong blocks_used; /* number of currently used blocks */
ulong blocks_changed; /* number of currently dirty blocks */
ulong warm_blocks; /* number of blocks in warm sub-chain */
long blocks_available; /* number of blocks available in the LRU chain */
HASH_LINK **hash_root; /* arr. of entries into hash table buckets */
HASH_LINK *hash_link_root; /* memory for hash table links */
HASH_LINK *free_hash_list; /* list of free hash links */
BLOCK_LINK *block_root; /* memory for block links */
byte HUGE_PTR *block_mem; /* memory for block buffers */
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
pthread_mutex_t cache_lock; /* to lock access to the cache structure */
KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */
KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */
BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/
BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/
/*
The following variables are and variables used to hold parameters for
initializing the key cache.
*/
ulonglong param_buff_size; /* size the memory allocated for the cache */
ulong param_block_size; /* size of the blocks in the key cache */
ulong param_division_limit; /* min. percentage of warm blocks */
ulong param_age_threshold; /* determines when hot block is downgraded */
/* Statistics variables */
ulong global_blocks_used; /* number of currently used blocks */
ulong global_blocks_changed; /* number of currently dirty blocks */
ulong global_cache_w_requests;/* number of write requests (write hits) */
ulong global_cache_write; /* number of writes from the cache to files */
ulong global_cache_r_requests;/* number of read requests (read hits) */
ulong global_cache_read; /* number of reads from files to the cache */
int blocks; /* max number of blocks in the cache */
my_bool in_init; /* Set to 1 in MySQL during init/resize */
/* optional call back function */
void (*action)(struct st_key_cache *);
} KEY_CACHE;
/* The default key cache */
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit,
uint age_threshold);
extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit,
uint age_threshold);
extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit,
uint age_threshold);
extern byte *key_cache_read(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
byte *buff, uint length,
uint block_length,int return_buffer);
extern int key_cache_insert(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
byte *buff, uint length);
extern int key_cache_write(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
byte *buff, uint length,
uint block_length,int force_write);
extern int flush_key_blocks(KEY_CACHE *keycache,
int file, enum flush_type type);
extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup);
/* Functions to handle multiple key caches */
extern my_bool multi_keycache_init(void);
extern void multi_keycache_free(void);
extern KEY_CACHE *multi_key_cache_search(byte *key, uint length);
extern my_bool multi_key_cache_set(const byte *key, uint length,
KEY_CACHE *key_cache);
extern void multi_key_cache_change(KEY_CACHE *old_data,
KEY_CACHE *new_data);
C_MODE_END
#endif /* _keycache_h */

View file

@ -468,7 +468,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
typedef struct st_safe_mutex_t
{
pthread_mutex_t global,mutex;
char *file;
const char *file;
uint line,count;
pthread_t thread;
#ifdef SAFE_MUTEX_DETECT_DESTROY
@ -487,7 +487,7 @@ typedef struct st_safe_mutex_info_t
{
struct st_safe_mutex_info_t *next;
struct st_safe_mutex_info_t *prev;
char *init_file;
const char *init_file;
uint32 init_line;
} safe_mutex_info_t;
#endif /* SAFE_MUTEX_DETECT_DESTROY */

View file

@ -505,44 +505,6 @@ my_off_t my_b_append_tell(IO_CACHE* info);
typedef uint32 ha_checksum;
/* Pointer to a key cache data structure (see the key cache module) */
typedef struct st_key_cache* KEY_CACHE_HANDLE;
/* Key cache variable structure */
/*
The structure contains the parameters of a key cache that can
be set and undated by regular set global statements.
It also contains read-only statistics parameters.
If the corresponding key cache data structure has been already
created the variable contains the key cache handle.
The variables are put into a named list called key_caches.
At present the variables are only added to this list.
*/
typedef struct st_key_cache_var
{
ulonglong buff_size; /* size the memory allocated for the cache */
ulong block_size; /* size of the blocks in the key cache */
ulong division_limit; /* min. percentage of warm blocks */
ulong age_threshold; /* determines when hot block is downgraded */
KEY_CACHE_HANDLE cache; /* handles for the current and registered */
ulong blocks_used; /* number of currently used blocks */
ulong blocks_changed; /* number of currently dirty blocks */
ulong cache_w_requests; /* number of write requests (write hits) */
ulong cache_write; /* number of writes from the cache to files */
ulong cache_r_requests; /* number of read requests (read hits) */
ulong cache_read; /* number of reads from files to the cache */
int blocks; /* max number of blocks in the cache */
my_bool in_init; /* Set to 1 in MySQL during init/resize */
struct st_key_cache_asmt *assign_list; /* list of assignments to the cache */
int assignments; /* number of not completed assignments */
void (*action)(void *); /* optional call back function */
void *extra_info; /* ptr to extra info */
} KEY_CACHE_VAR;
extern KEY_CACHE_HANDLE *dflt_keycache;
extern KEY_CACHE_VAR dflt_key_cache_var;
#include <my_alloc.h>
/* Prototypes for mysys and my_func functions */
@ -682,33 +644,6 @@ extern int flush_write_cache(RECORD_CACHE *info);
extern long my_clock(void);
extern sig_handler sigtstp_handler(int signal_number);
extern void handle_recived_signals(void);
extern int init_key_cache(KEY_CACHE_HANDLE *pkeycache,
uint key_cache_block_size,
ulong use_mem, KEY_CACHE_VAR* env);
extern int resize_key_cache(KEY_CACHE_HANDLE *pkeycache,
uint key_cache_block_size, ulong use_mem);
extern void change_key_cache_param(KEY_CACHE_HANDLE keycache);
extern byte *key_cache_read(KEY_CACHE_HANDLE keycache,
File file, my_off_t filepos, int level,
byte* buff, uint length,
uint block_length,int return_buffer);
extern int key_cache_insert(KEY_CACHE_HANDLE keycache,
File file, my_off_t filepos, int level,
byte *buff, uint length);
extern int key_cache_write(KEY_CACHE_HANDLE keycache,
File file, my_off_t filepos, int level,
byte* buff, uint length,
uint block_length,int force_write);
extern int flush_key_blocks(KEY_CACHE_HANDLE keycache,
int file, enum flush_type type);
extern void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup);
extern my_bool multi_keycache_init(void);
extern void multi_keycache_free(void);
extern KEY_CACHE_HANDLE *multi_key_cache_search(byte *key, uint length);
extern my_bool multi_key_cache_set(const byte *key, uint length,
KEY_CACHE_HANDLE *key_cache);
extern void multi_key_cache_change(KEY_CACHE_HANDLE *old_data,
KEY_CACHE_HANDLE *new_data);
extern sig_handler my_set_alarm_variable(int signo);
extern void my_string_ptr_sort(void *base,uint items,size_s size);

View file

@ -28,6 +28,9 @@ extern "C" {
#ifndef _m_ctype_h
#include <m_ctype.h>
#endif
#ifndef _keycache_h
#include "keycache.h"
#endif
#include "my_handler.h"
/* defines used by myisam-funktions */
@ -408,9 +411,9 @@ int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows);
void mi_flush_bulk_insert(MI_INFO *info, uint inx);
void mi_end_bulk_insert(MI_INFO *info);
int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map,
KEY_CACHE_VAR *key_cache);
void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache,
KEY_CACHE_VAR *new_key_cache);
KEY_CACHE *key_cache);
void mi_change_key_cache(KEY_CACHE *old_key_cache,
KEY_CACHE *new_key_cache);
int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves);
#ifdef __cplusplus

View file

@ -535,10 +535,10 @@ typedef struct st_mysql_stmt
char *query; /* query buffer */
MEM_ROOT mem_root; /* root allocations */
my_ulonglong last_fetched_column; /* last fetched column */
unsigned long param_count; /* parameters count */
unsigned long field_count; /* fields count */
unsigned long stmt_id; /* Id for prepared statement */
unsigned int last_errno; /* error code */
unsigned int param_count; /* parameters count */
unsigned int field_count; /* fields count */
enum PREP_STMT_STATE state; /* statement state */
char last_error[MYSQL_ERRMSG_SIZE]; /* error message */
char sqlstate[SQLSTATE_LENGTH+1];
@ -552,27 +552,27 @@ typedef struct st_mysql_stmt
typedef struct st_mysql_methods
{
my_bool (* STDCALL read_query_result)(MYSQL *mysql);
my_bool (* STDCALL advanced_command)(MYSQL *mysql,
enum enum_server_command command,
const char *header,
unsigned long header_length,
const char *arg,
unsigned long arg_length,
my_bool skip_check);
MYSQL_DATA *(* STDCALL read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
unsigned int fields);
MYSQL_RES * (* STDCALL use_result)(MYSQL *mysql);
void (* STDCALL fetch_lengths)(unsigned long *to,
MYSQL_ROW column, unsigned int field_count);
my_bool (*read_query_result)(MYSQL *mysql);
my_bool (*advanced_command)(MYSQL *mysql,
enum enum_server_command command,
const char *header,
unsigned long header_length,
const char *arg,
unsigned long arg_length,
my_bool skip_check);
MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
unsigned int fields);
MYSQL_RES * (*use_result)(MYSQL *mysql);
void (*fetch_lengths)(unsigned long *to,
MYSQL_ROW column, unsigned int field_count);
#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
MYSQL_FIELD * (* STDCALL list_fields)(MYSQL *mysql);
my_bool (* STDCALL read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
int (* STDCALL stmt_execute)(MYSQL_STMT *stmt);
MYSQL_DATA *(* STDCALL read_binary_rows)(MYSQL_STMT *stmt);
int (* STDCALL unbuffered_fetch)(MYSQL *mysql, char **row);
void (* STDCALL free_embedded_thd)(MYSQL *mysql);
const char *(* STDCALL read_statistic)(MYSQL *mysql);
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
int (*stmt_execute)(MYSQL_STMT *stmt);
MYSQL_DATA *(*read_binary_rows)(MYSQL_STMT *stmt);
int (*unbuffered_fetch)(MYSQL *mysql, char **row);
void (*free_embedded_thd)(MYSQL *mysql);
const char *(*read_statistic)(MYSQL *mysql);
#endif
} MYSQL_METHODS;

View file

@ -34,7 +34,7 @@ void end_server(MYSQL *mysql);
my_bool mysql_reconnect(MYSQL *mysql);
void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group);
my_bool STDCALL
my_bool
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length,
const char *arg, ulong arg_length, my_bool skip_check);

View file

@ -177,7 +177,7 @@ struct st_vio
void (*viodelete)(Vio*);
int (*vioerrno)(Vio*);
int (*read)(Vio*, gptr, int);
int (*write)(Vio*, gptr, int);
int (*write)(Vio*, const gptr, int);
int (*vioblocking)(Vio*, my_bool, my_bool *);
my_bool (*is_blocking)(Vio*);
int (*viokeepalive)(Vio*, my_bool);

View file

@ -50,7 +50,7 @@ int nisam_lock_database(N_INFO *info, int lock_type)
else
count= --share->w_locks;
if (info->lock_type == F_WRLCK && !share->w_locks &&
flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_KEEP))
flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_KEEP))
error=my_errno;
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
if (end_io_cache(&info->rec_cache))
@ -329,7 +329,7 @@ int _nisam_test_if_changed(register N_INFO *info)
share->state.uniq != info->last_uniq)
{ /* Keyfile has changed */
if (share->state.process != share->this_process)
VOID(flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_RELEASE));
VOID(flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_RELEASE));
share->last_process=share->state.process;
info->last_loop= share->state.loop;
info->last_uniq= share->state.uniq;

View file

@ -27,7 +27,7 @@ uchar *_nisam_fetch_keypage(register N_INFO *info, N_KEYDEF *keyinfo,
my_off_t page, uchar *buff, int return_buffer)
{
uchar *tmp;
tmp=(uchar*) key_cache_read(*dflt_keycache,
tmp=(uchar*) key_cache_read(dflt_key_cache,
info->s->kfile,page,DFLT_INIT_HITS,(byte*) buff,
(uint) keyinfo->base.block_length,
(uint) keyinfo->base.block_length,
@ -84,7 +84,7 @@ int _nisam_write_keypage(register N_INFO *info, register N_KEYDEF *keyinfo,
length=keyinfo->base.block_length;
}
#endif
return (key_cache_write(*dflt_keycache,
return (key_cache_write(dflt_key_cache,
info->s->kfile,page,DFLT_INIT_HITS,
(byte*) buff,length,
(uint) keyinfo->base.block_length,
@ -102,7 +102,7 @@ int _nisam_dispose(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t pos)
old_link=info->s->state.key_del[keynr];
info->s->state.key_del[keynr]=(ulong) pos;
DBUG_RETURN(key_cache_write(*dflt_keycache,
DBUG_RETURN(key_cache_write(dflt_key_cache,
info->s->kfile,pos,DFLT_INIT_HITS,
(byte*) &old_link,
sizeof(long),
@ -131,7 +131,7 @@ ulong _nisam_new(register N_INFO *info, N_KEYDEF *keyinfo)
}
else
{
if (!key_cache_read(*dflt_keycache,
if (!key_cache_read(dflt_key_cache,
info->s->kfile,pos,DFLT_INIT_HITS,
(byte*) &info->s->state.key_del[keynr],
(uint) sizeof(long),

View file

@ -57,7 +57,7 @@ int nisam_close(register N_INFO *info)
if (flag)
{
if (share->kfile >= 0 &&
flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_RELEASE))
flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_RELEASE))
error=my_errno;
if (share->kfile >= 0 && my_close(share->kfile,MYF(0)))
error = my_errno;

View file

@ -215,7 +215,7 @@ int nisam_extra(N_INFO *info, enum ha_extra_function function)
info->s->last_version= 0L; /* Impossible version */
#ifdef __WIN__
/* Close the isam and data files as Win32 can't drop an open table */
if (flush_key_blocks(info->s->kfile,FLUSH_RELEASE))
if (flush_key_blocks(dflt_key_cache, info->s->kfile, FLUSH_RELEASE))
error=my_errno;
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
{

View file

@ -516,8 +516,8 @@ static int nisamchk(my_string filename)
if (!rep_quick)
{
if (testflag & T_EXTEND)
VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,
use_buffers,&dflt_key_cache_var));
VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,
use_buffers,0,0));
VOID(init_io_cache(&read_cache,datafile,(uint) read_buffer_length,
READ_CACHE,share->pack.header_length,1,
MYF(MY_WME)));
@ -1460,8 +1460,7 @@ my_string name;
printf("Data records: %lu\n",(ulong) share->state.records);
}
VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,use_buffers,
&dflt_key_cache_var));
VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,use_buffers,0,0));
if (init_io_cache(&read_cache,info->dfile,(uint) read_buffer_length,
READ_CACHE,share->pack.header_length,1,MYF(MY_WME)))
goto err;
@ -1889,12 +1888,12 @@ static void lock_memory(void)
static int flush_blocks(file)
File file;
{
if (flush_key_blocks(dflt_keycache,file,FLUSH_RELEASE))
if (flush_key_blocks(dflt_key_cache,file,FLUSH_RELEASE))
{
print_error("%d when trying to write bufferts",my_errno);
return(1);
}
end_key_cache(dflt_keycache,1);
end_key_cache(dflt_key_cache,1);
return 0;
} /* flush_blocks */
@ -1938,8 +1937,7 @@ int write_info;
if (share->state.key_root[sort_key] == NI_POS_ERROR)
DBUG_RETURN(0); /* Nothing to do */
init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,use_buffers,
&dflt_key_cache_var);
init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,use_buffers, 0, 0);
if (init_io_cache(&info->rec_cache,-1,(uint) write_buffer_length,
WRITE_CACHE,share->pack.header_length,1,
MYF(MY_WME | MY_WAIT_IF_FULL)))

View file

@ -24,6 +24,7 @@
#else
#include <my_no_pthread.h>
#endif
#include <keycache.h>
#ifdef my_write
#undef my_write /* We want test if disk full */

View file

@ -329,8 +329,8 @@ static int examine_log(my_string file_name, char **table_names)
bzero((gptr) com_count,sizeof(com_count));
init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1,
(tree_element_free) file_info_free, NULL);
VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE,
&dflt_key_cache_var));
VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE,
0,0));
files_open=0; access_time=0;
while (access_time++ != number_of_commands &&
!my_b_read(&cache,(byte*) head,9))
@ -622,7 +622,7 @@ static int examine_log(my_string file_name, char **table_names)
goto end;
}
}
end_key_cache(dflt_keycache,1);
end_key_cache(dflt_key_cache,1);
delete_tree(&tree);
VOID(end_io_cache(&cache));
VOID(my_close(file,MYF(0)));
@ -642,7 +642,7 @@ static int examine_log(my_string file_name, char **table_names)
llstr(isamlog_filepos,llbuff)));
fflush(stderr);
end:
end_key_cache(dflt_keycache,1);
end_key_cache(dflt_key_cache,1);
delete_tree(&tree);
VOID(end_io_cache(&cache));
VOID(my_close(file,MYF(0)));

View file

@ -48,7 +48,7 @@ int nisam_panic(enum ha_panic_function flag)
if (info->s->base.options & HA_OPTION_READ_ONLY_DATA)
break;
#endif
if (flush_key_blocks(*dflt_keycache,info->s->kfile,FLUSH_RELEASE))
if (flush_key_blocks(dflt_key_cache,info->s->kfile,FLUSH_RELEASE))
error=my_errno;
if (info->opt_flag & WRITE_CACHE_USED)
if (flush_io_cache(&info->rec_cache))

View file

@ -156,7 +156,7 @@ int main(int argc, char *argv[])
goto err;
printf("- Writing key:s\n");
if (key_cacheing)
init_key_cache(dflt_keycache,512,IO_SIZE*16,0); /* Use a small cache */
init_key_cache(dflt_key_cache,512,IO_SIZE*16,0,0); /* Use a small cache */
if (locking)
nisam_lock_database(file,F_WRLCK);
if (write_cacheing)
@ -674,7 +674,7 @@ end:
puts("Locking used");
if (use_blob)
puts("blobs used");
end_key_cache(&dflt_keycache,1);
end_key_cache(dflt_key_cache,1);
if (blob_buffer)
my_free(blob_buffer,MYF(0));
my_end(MY_CHECK_ERROR | MY_GIVE_INFO);

View file

@ -20,6 +20,7 @@
#include "nisam.h"
#include <sys/types.h>
#include <keycache.h>
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
@ -173,7 +174,7 @@ void start_test(int id)
exit(1);
}
if (key_cacheing && rnd(2) == 0)
init_key_cache(dflt_keycache,512,65536L,0);
init_key_cache(dflt_key_cache,512,65536L,0,0);
printf("Process %d, pid: %d\n",id,(int) getpid()); fflush(stdout);
for (error=i=0 ; i < tests && !error; i++)

View file

@ -43,18 +43,18 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename);
void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group);
MYSQL * STDCALL
MYSQL *
cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,ulong client_flag);
void STDCALL cli_mysql_close(MYSQL *mysql);
void cli_mysql_close(MYSQL *mysql);
MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql);
my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt);
MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
MYSQL_FIELD * cli_list_fields(MYSQL *mysql);
my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt);
MYSQL_DATA * cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
uint fields);
int STDCALL cli_stmt_execute(MYSQL_STMT *stmt);
MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt);
int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row);
const char * STDCALL cli_read_statistic(MYSQL *mysql);
int cli_stmt_execute(MYSQL_STMT *stmt);
MYSQL_DATA * cli_read_binary_rows(MYSQL_STMT *stmt);
int cli_unbuffered_fetch(MYSQL *mysql, char **row);
const char * cli_read_statistic(MYSQL *mysql);

View file

@ -973,16 +973,16 @@ mysql_list_tables(MYSQL *mysql, const char *wild)
DBUG_RETURN (mysql_store_result(mysql));
}
MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql)
MYSQL_FIELD *cli_list_fields(MYSQL *mysql)
{
MYSQL_DATA *query;
if (!(query= cli_read_rows(mysql,(MYSQL_FIELD*) 0,
protocol_41(mysql) ? 8 : 6)))
return NULL;
mysql->field_count= query->rows;
mysql->field_count= (uint) query->rows;
return unpack_fields(query,&mysql->field_alloc,
query->rows, 1, mysql->server_capabilities);
mysql->field_count, 1, mysql->server_capabilities);
}
@ -1112,7 +1112,7 @@ mysql_dump_debug_info(MYSQL *mysql)
DBUG_RETURN(simple_command(mysql,COM_DEBUG,0,0,0));
}
const char * STDCALL cli_read_statistic(MYSQL *mysql)
const char *cli_read_statistic(MYSQL *mysql)
{
mysql->net.read_pos[mysql->packet_length]=0; /* End of stat string */
if (!mysql->net.read_pos[0])
@ -1589,7 +1589,7 @@ static my_bool my_realloc_str(NET *net, ulong length)
1 error
*/
my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
{
uchar *pos;
uint field_count;
@ -2010,7 +2010,8 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length)
DBUG_RETURN(0);
}
int STDCALL cli_stmt_execute(MYSQL_STMT *stmt)
int cli_stmt_execute(MYSQL_STMT *stmt)
{
DBUG_ENTER("cli_stmt_execute");
@ -2985,7 +2986,7 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row)
return 0;
}
int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row)
int cli_unbuffered_fetch(MYSQL *mysql, char **row)
{
if (packet_error == net_safe_read(mysql))
return 1;
@ -3109,7 +3110,7 @@ no_data:
Read all rows of data from server (binary format)
*/
MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt)
MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt)
{
ulong pkt_len;
uchar *cp;

View file

@ -251,7 +251,8 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
}
/* going up to the first-level tree to continue search there */
_mi_dpointer(info, ftbw->word+ftbw->off+HA_FT_WLEN, ftbw->key_root);
_mi_dpointer(info, (uchar*) (ftbw->word+ftbw->off+HA_FT_WLEN),
ftbw->key_root);
ftbw->key_root=info->s->state.key_root[ftb->keynr];
ftbw->keyinfo=info->s->keyinfo+ftb->keynr;
ftbw->off=0;

View file

@ -80,7 +80,7 @@ int main(int argc,char *argv[])
if (argc < 2)
usage();
init_key_cache(dflt_keycache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT,0);
init_key_cache(dflt_key_cache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0);
if (!(info=mi_open(argv[0],2,HA_OPEN_ABORT_IF_LOCKED)))
goto err;
@ -172,9 +172,9 @@ int main(int argc,char *argv[])
if (dump)
{
if (subkeys>=0)
printf("%9qx %20.7f %s\n",info->lastpos,weight,buf);
printf("%9lx %20.7f %s\n", (long) info->lastpos,weight,buf);
else
printf("%9qx => %17d %s\n",info->lastpos,-subkeys,buf);
printf("%9lx => %17d %s\n",(long) info->lastpos,-subkeys,buf);
}
if (verbose && (total%HOW_OFTEN_TO_WRITE)==0)
printf("%10ld\r",total);
@ -189,12 +189,12 @@ int main(int argc,char *argv[])
if ((ulong) count >= total/2)
break;
}
printf("Total rows: %qu\nTotal words: %lu\n"
printf("Total rows: %lu\nTotal words: %lu\n"
"Unique words: %lu\nLongest word: %lu chars (%s)\n"
"Median length: %u\n"
"Average global weight: %f\n"
"Most common word: %lu times, weight: %f (%s)\n",
(ulonglong)info->state->records, total, uniq, maxlen, buf_maxlen,
(long) info->state->records, total, uniq, maxlen, buf_maxlen,
inx, avg_gws/uniq, max_doc_cnt, min_gws, buf_min_gws);
}
if (lstats)

View file

@ -304,7 +304,7 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key)
my_off_t root;
DYNAMIC_ARRAY *da=info->ft1_to_ft2;
MI_KEYDEF *keyinfo=&info->s->ft2_keyinfo;
uchar *key_ptr=dynamic_array_ptr(da, 0), *end;
uchar *key_ptr= (uchar*) dynamic_array_ptr(da, 0), *end;
uint length, key_length;
DBUG_ENTER("_mi_ft_convert_to_ft2");
@ -329,13 +329,13 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key)
DBUG_RETURN(-1);
/* inserting the rest of key values */
end=dynamic_array_ptr(da, da->elements);
end= (uchar*) dynamic_array_ptr(da, da->elements);
for (key_ptr+=length; key_ptr < end; key_ptr+=keyinfo->keylength)
if(_mi_ck_real_write_btree(info, keyinfo, key_ptr, 0, &root, SEARCH_SAME))
DBUG_RETURN(-1);
/* now, writing the word key entry */
ft_intXstore(key+key_length, -da->elements);
ft_intXstore(key+key_length, - (int) da->elements);
_mi_dpointer(info, key+key_length+HA_FT_WLEN, root);
DBUG_RETURN(_mi_ck_real_write_btree(info,

View file

@ -242,7 +242,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr)
if (next_link > info->state->key_file_length ||
next_link & (info->s->blocksize-1))
DBUG_RETURN(1);
if (!(buff=key_cache_read(*info->s->key_cache,
if (!(buff=key_cache_read(info->s->key_cache,
info->s->kfile, next_link, DFLT_INIT_HITS,
(byte*) info->buff,
myisam_block_size, block_size, 1)))
@ -262,7 +262,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr)
} /* check_k_link */
/* Kontrollerar storleken p} filerna */
/* Check sizes of files */
int chk_size(MI_CHECK *param, register MI_INFO *info)
{
@ -273,8 +273,9 @@ int chk_size(MI_CHECK *param, register MI_INFO *info)
if (!(param->testflag & T_SILENT)) puts("- check file-size");
flush_key_blocks(*info->s->key_cache,
info->s->kfile, FLUSH_FORCE_WRITE); /* If called externally */
/* The following is needed if called externally (not from myisamchk) */
flush_key_blocks(info->s->key_cache,
info->s->kfile, FLUSH_FORCE_WRITE);
size=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0));
if ((skr=(my_off_t) info->state->key_file_length) != size)
@ -502,7 +503,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
param->record_checksum=old_record_checksum-init_checksum; /* Remove delete links */
else
param->record_checksum=0;
DBUG_RETURN(0);
DBUG_RETURN(result);
} /* chk_key */
@ -1143,8 +1144,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
param->testflag|=T_REP; /* for easy checking */
if (!param->using_global_keycache)
VOID(init_key_cache(dflt_keycache, param->key_cache_block_size,
param->use_buffers, &dflt_key_cache_var));
VOID(init_key_cache(dflt_key_cache, param->key_cache_block_size,
param->use_buffers, 0, 0));
if (init_io_cache(&param->read_cache,info->dfile,
(uint) param->read_buffer_length,
@ -1365,7 +1366,7 @@ err:
VOID(end_io_cache(&param->read_cache));
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
VOID(end_io_cache(&info->rec_cache));
got_error|=flush_blocks(param, *share->key_cache, share->kfile);
got_error|=flush_blocks(param, share->key_cache, share->kfile);
if (!got_error && param->testflag & T_UNPACK)
{
share->state.header.options[0]&= (uchar) ~HA_OPTION_COMPRESS_RECORD;
@ -1501,7 +1502,7 @@ void lock_memory(MI_CHECK *param __attribute__((unused)))
/* Flush all changed blocks to disk */
int flush_blocks(MI_CHECK *param, KEY_CACHE_HANDLE key_cache, File file)
int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file)
{
if (flush_key_blocks(key_cache, file, FLUSH_RELEASE))
{
@ -1564,7 +1565,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name)
}
/* Flush key cache for this file if we are calling this outside myisamchk */
flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED);
flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED);
share->state.version=(ulong) time((time_t*) 0);
old_state= share->state; /* save state if not stored */
@ -1874,7 +1875,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
Flush key cache for this file if we are calling this outside
myisamchk
*/
flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED);
flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED);
/* Clear the pointers to the given rows */
for (i=0 ; i < share->base.keys ; i++)
share->state.key_root[i]= HA_OFFSET_ERROR;
@ -1884,7 +1885,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
}
else
{
if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_FORCE_WRITE))
if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE))
goto err;
key_map= ~key_map; /* Create the missing keys */
}
@ -2076,7 +2077,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
memcpy( &share->state.state, info->state, sizeof(*info->state));
err:
got_error|= flush_blocks(param, *share->key_cache, share->kfile);
got_error|= flush_blocks(param, share->key_cache, share->kfile);
VOID(end_io_cache(&info->rec_cache));
if (!got_error)
{
@ -2237,7 +2238,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
Flush key cache for this file if we are calling this outside
myisamchk
*/
flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED);
flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED);
/* Clear the pointers to the given rows */
for (i=0 ; i < share->base.keys ; i++)
share->state.key_root[i]= HA_OFFSET_ERROR;
@ -2247,7 +2248,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
}
else
{
if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_FORCE_WRITE))
if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE))
goto err;
key_map= ~key_map; /* Create the missing keys */
}
@ -2483,7 +2484,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
memcpy(&share->state.state, info->state, sizeof(*info->state));
err:
got_error|= flush_blocks(param, *share->key_cache, share->kfile);
got_error|= flush_blocks(param, share->key_cache, share->kfile);
VOID(end_io_cache(&info->rec_cache));
if (!got_error)
{

View file

@ -64,7 +64,7 @@ int mi_close(register MI_INFO *info)
if (flag)
{
if (share->kfile >= 0 &&
flush_key_blocks(*share->key_cache, share->kfile,
flush_key_blocks(share->key_cache, share->kfile,
share->temporary ? FLUSH_IGNORE_CHANGED :
FLUSH_RELEASE))
error=my_errno;

View file

@ -53,7 +53,7 @@ int mi_delete_all_rows(MI_INFO *info)
If we are using delayed keys or if the user has done changes to the tables
since it was locked then there may be key blocks in the key cache
*/
flush_key_blocks(*share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED);
flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED);
if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) ||
my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) )
goto err;

View file

@ -283,7 +283,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
#ifdef __WIN__
/* Close the isam and data files as Win32 can't drop an open table */
pthread_mutex_lock(&share->intern_lock);
if (flush_key_blocks(*share->keycache, share->kfile,
if (flush_key_blocks(share->key_cache, share->kfile,
(function == HA_EXTRA_FORCE_REOPEN ?
FLUSH_RELEASE : FLUSH_IGNORE_CHANGED)))
{
@ -329,7 +329,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
break;
case HA_EXTRA_FLUSH:
if (!share->temporary)
flush_key_blocks(*share->key_cache, share->kfile, FLUSH_KEEP);
flush_key_blocks(share->key_cache, share->kfile, FLUSH_KEEP);
#ifdef HAVE_PWRITE
_mi_decrement_open_count(info);
#endif

View file

@ -49,19 +49,19 @@
int mi_assign_to_key_cache(MI_INFO *info,
ulonglong key_map __attribute__((unused)),
KEY_CACHE_VAR *key_cache)
KEY_CACHE *key_cache)
{
int error= 0;
MYISAM_SHARE* share= info->s;
DBUG_ENTER("mi_assign_to_key_cache");
DBUG_PRINT("enter",("old_key_cache_handle: %lx new_key_cache_handle: %lx",
share->key_cache, &key_cache->cache));
share->key_cache, key_cache));
/*
Skip operation if we didn't change key cache. This can happen if we
call this for all open instances of the same table
*/
if (*share->key_cache == key_cache->cache)
if (share->key_cache == key_cache)
DBUG_RETURN(0);
/*
@ -76,7 +76,7 @@ int mi_assign_to_key_cache(MI_INFO *info,
in the old key cache.
*/
if (flush_key_blocks(*share->key_cache, share->kfile, FLUSH_REMOVE))
if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_REMOVE))
{
error= my_errno;
mi_mark_crashed(info); /* Mark that table must be checked */
@ -90,13 +90,13 @@ int mi_assign_to_key_cache(MI_INFO *info,
(This can never fail as there is never any not written data in the
new key cache)
*/
(void) flush_key_blocks(key_cache->cache, share->kfile, FLUSH_REMOVE);
(void) flush_key_blocks(key_cache, share->kfile, FLUSH_REMOVE);
/*
Tell all threads to use the new key cache
This should be seen at the lastes for the next call to an myisam function.
*/
share->key_cache= &key_cache->cache;
share->key_cache= key_cache;
/* store the key cache in the global hash structure for future opens */
if (multi_key_cache_set(share->unique_file_name, share->unique_name_length,
@ -127,8 +127,8 @@ int mi_assign_to_key_cache(MI_INFO *info,
*/
void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache,
KEY_CACHE_VAR *new_key_cache)
void mi_change_key_cache(KEY_CACHE *old_key_cache,
KEY_CACHE *new_key_cache)
{
LIST *pos;
DBUG_ENTER("mi_change_key_cache");
@ -141,7 +141,7 @@ void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache,
{
MI_INFO *info= (MI_INFO*) pos->data;
MYISAM_SHARE *share= info->s;
if (share->key_cache == &old_key_cache->cache)
if (share->key_cache == old_key_cache)
mi_assign_to_key_cache(info, (ulonglong) ~0, new_key_cache);
}
@ -150,6 +150,6 @@ void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache,
MyISAM list structure to ensure that another thread is not trying to
open a new table that will be associted with the old key cache
*/
multi_key_cache_change(&old_key_cache->cache, &new_key_cache->cache);
multi_key_cache_change(old_key_cache, new_key_cache);
pthread_mutex_unlock(&THR_LOCK_myisam);
}

View file

@ -61,7 +61,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
count= --share->w_locks;
--share->tot_locks;
if (info->lock_type == F_WRLCK && !share->w_locks &&
!share->delay_key_write && flush_key_blocks(*share->key_cache,
!share->delay_key_write && flush_key_blocks(share->key_cache,
share->kfile,FLUSH_KEEP))
{
error=my_errno;
@ -389,7 +389,7 @@ int _mi_test_if_changed(register MI_INFO *info)
{ /* Keyfile has changed */
DBUG_PRINT("info",("index file changed"));
if (share->state.process != share->this_process)
VOID(flush_key_blocks(*share->key_cache, share->kfile, FLUSH_RELEASE));
VOID(flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE));
share->last_process=share->state.process;
info->last_unique= share->state.unique;
info->last_loop= share->state.update_count;

View file

@ -32,7 +32,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo,
DBUG_ENTER("_mi_fetch_keypage");
DBUG_PRINT("enter",("page: %ld",page));
tmp=(uchar*) key_cache_read(*info->s->key_cache,
tmp=(uchar*) key_cache_read(info->s->key_cache,
info->s->kfile, page, level, (byte*) buff,
(uint) keyinfo->block_length,
(uint) keyinfo->block_length,
@ -95,7 +95,7 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo,
length=keyinfo->block_length;
}
#endif
DBUG_RETURN((key_cache_write(*info->s->key_cache,
DBUG_RETURN((key_cache_write(info->s->key_cache,
info->s->kfile,page, level, (byte*) buff,length,
(uint) keyinfo->block_length,
(int) ((info->lock_type != F_UNLCK) ||
@ -117,7 +117,7 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos,
info->s->state.key_del[keyinfo->block_size]=pos;
mi_sizestore(buff,old_link);
info->s->state.changed|= STATE_NOT_SORTED_PAGES;
DBUG_RETURN(key_cache_write(*info->s->key_cache,
DBUG_RETURN(key_cache_write(info->s->key_cache,
info->s->kfile, pos , level, buff,
sizeof(buff),
(uint) keyinfo->block_length,
@ -146,7 +146,7 @@ my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level)
}
else
{
if (!key_cache_read(*info->s->key_cache,
if (!key_cache_read(info->s->key_cache,
info->s->kfile, pos, level,
buff,
(uint) sizeof(buff),

View file

@ -48,7 +48,7 @@ int mi_panic(enum ha_panic_function flag)
if (info->s->options & HA_OPTION_READ_ONLY_DATA)
break;
#endif
if (flush_key_blocks(*info->s->key_cache, info->s->kfile, FLUSH_RELEASE))
if (flush_key_blocks(info->s->key_cache, info->s->kfile, FLUSH_RELEASE))
error=my_errno;
if (info->opt_flag & WRITE_CACHE_USED)
if (flush_io_cache(&info->rec_cache))

View file

@ -69,7 +69,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME))))
DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM);
if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_RELEASE))
if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE))
goto err;
do
@ -87,7 +87,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
{
if (mi_test_if_nod(buff))
{
if (key_cache_insert(*share->key_cache,
if (key_cache_insert(share->key_cache,
share->kfile, pos, DFLT_INIT_HITS,
(byte*) buff, block_length))
goto err;
@ -99,7 +99,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
}
else
{
if (key_cache_insert(*share->key_cache,
if (key_cache_insert(share->key_cache,
share->kfile, pos, DFLT_INIT_HITS,
(byte*) buff, length))
goto err;

View file

@ -50,7 +50,7 @@ int main(int argc,char *argv[])
MY_INIT(argv[0]);
my_init();
if (key_cacheing)
init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0);
init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0,0);
get_options(argc,argv);
exit(run_test("test1"));

View file

@ -215,7 +215,7 @@ int main(int argc, char *argv[])
if (!silent)
printf("- Writing key:s\n");
if (key_cacheing)
init_key_cache(dflt_keycache,key_cache_block_size,key_cache_size,0); /* Use a small cache */
init_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size,0,0);
if (locking)
mi_lock_database(file,F_WRLCK);
if (write_cacheing)
@ -276,7 +276,7 @@ int main(int argc, char *argv[])
}
}
if (key_cacheing)
resize_key_cache(dflt_keycache,key_cache_block_size,key_cache_size*2);
resize_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size*2,0,0);
if (!silent)
printf("- Delete\n");
@ -829,7 +829,7 @@ reads: %10lu\n",
my_cache_r_requests, my_cache_read);
#endif
}
end_key_cache(*dflt_keycache,1);
end_key_cache(dflt_key_cache,1);
if (blob_buffer)
my_free(blob_buffer,MYF(0));
my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO);

View file

@ -177,7 +177,7 @@ void start_test(int id)
exit(1);
}
if (key_cacheing && rnd(2) == 0)
init_key_cache(dflt_keycache, KEY_CACHE_BLOCK_SIZE, 65536L,0);
init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE, 65536L, 0, 0);
printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout);
for (error=i=0 ; i < tests && !error; i++)

View file

@ -321,7 +321,7 @@ static struct my_option my_long_options[] =
{ "ft_max_word_len", OPT_FT_MAX_WORD_LEN, "", (gptr*) &ft_max_word_len,
(gptr*) &ft_max_word_len, 0, GET_ULONG, REQUIRED_ARG, HA_FT_MAXLEN, 10,
HA_FT_MAXLEN, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@ -1032,8 +1032,8 @@ static int myisamchk(MI_CHECK *param, my_string filename)
!(param->testflag & (T_FAST | T_FORCE_CREATE)))
{
if (param->testflag & (T_EXTEND | T_MEDIUM))
VOID(init_key_cache(dflt_keycache,opt_key_cache_block_size,
param->use_buffers,&dflt_key_cache_var));
VOID(init_key_cache(dflt_key_cache,opt_key_cache_block_size,
param->use_buffers, 0, 0));
VOID(init_io_cache(&param->read_cache,datafile,
(uint) param->read_buffer_length,
READ_CACHE,
@ -1047,7 +1047,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
HA_OPTION_COMPRESS_RECORD)) ||
(param->testflag & (T_EXTEND | T_MEDIUM)))
error|=chk_data_link(param, info, param->testflag & T_EXTEND);
error|=flush_blocks(param, *share->key_cache, share->kfile);
error|=flush_blocks(param, share->key_cache, share->kfile);
VOID(end_io_cache(&param->read_cache));
}
if (!error)
@ -1456,8 +1456,8 @@ static int mi_sort_records(MI_CHECK *param,
if (share->state.key_root[sort_key] == HA_OFFSET_ERROR)
DBUG_RETURN(0); /* Nothing to do */
init_key_cache(dflt_keycache, opt_key_cache_block_size, param->use_buffers,
&dflt_key_cache_var);
init_key_cache(dflt_key_cache, opt_key_cache_block_size, param->use_buffers,
0, 0);
if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length,
WRITE_CACHE,share->pack.header_length,1,
MYF(MY_WME | MY_WAIT_IF_FULL)))
@ -1571,7 +1571,7 @@ err:
my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR));
sort_info.buff=0;
share->state.sortkey=sort_key;
DBUG_RETURN(flush_blocks(param, *share->key_cache, share->kfile) |
DBUG_RETURN(flush_blocks(param, share->key_cache, share->kfile) |
got_error);
} /* sort_records */

View file

@ -166,7 +166,7 @@ typedef struct st_mi_isam_share { /* Shared between opens */
char *data_file_name, /* Resolved path names from symlinks */
*index_file_name;
byte *file_map; /* mem-map of file if possible */
KEY_CACHE_HANDLE *key_cache; /* ref to the current key cache */
KEY_CACHE *key_cache; /* ref to the current key cache */
MI_DECODE_TREE *decode_trees;
uint16 *decode_tables;
int (*read_record)(struct st_myisam_info*, my_off_t, byte*);
@ -713,7 +713,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param);
#ifdef THREAD
pthread_handler_decl(thr_find_all_keys,arg);
#endif
int flush_blocks(MI_CHECK *param, KEY_CACHE_HANDLE key_cache, File file);
int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file);
int sort_write_record(MI_SORT_PARAM *sort_param);
int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong);

View file

@ -71,7 +71,7 @@ static void printf_log(const char *str,...);
static bool cmp_filename(struct file_info *file_info,my_string name);
static uint verbose=0,update=0,test_info=0,max_files=0,re_open_count=0,
recover=0,prefix_remove=0,opt_processes=0,opt_myisam_with_debug=0;
recover=0,prefix_remove=0,opt_processes=0;
static my_string log_filename=0,filepath=0,write_filename=0,record_pos_file=0;
static ulong com_count[10][3],number_of_commands=(ulong) ~0L,
isamlog_process;
@ -201,9 +201,6 @@ static void get_options(register int *argc, register char ***argv)
update=1;
recover++;
break;
case 'D':
opt_myisam_with_debug=1;
break;
case 'P':
opt_processes=1;
break;
@ -333,8 +330,8 @@ static int examine_log(my_string file_name, char **table_names)
bzero((gptr) com_count,sizeof(com_count));
init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1,
(tree_element_free) file_info_free, NULL);
VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE,
&dflt_key_cache_var));
VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE,
0, 0));
files_open=0; access_time=0;
while (access_time++ != number_of_commands &&
@ -648,7 +645,7 @@ static int examine_log(my_string file_name, char **table_names)
goto end;
}
}
end_key_cache(*dflt_keycache,1);
end_key_cache(dflt_key_cache,1);
delete_tree(&tree);
VOID(end_io_cache(&cache));
VOID(my_close(file,MYF(0)));
@ -668,7 +665,7 @@ static int examine_log(my_string file_name, char **table_names)
llstr(isamlog_filepos,llbuff)));
fflush(stderr);
end:
end_key_cache(*dflt_keycache, 1);
end_key_cache(dflt_key_cache, 1);
delete_tree(&tree);
VOID(end_io_cache(&cache));
VOID(my_close(file,MYF(0)));

View file

@ -84,7 +84,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info,
IO_CACHE *to_file,
char* key, uint sort_length,
uint count);
inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs);
inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file, byte *bufs);
/*
Creates a index of sorted keys
@ -622,21 +622,25 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys,
DBUG_RETURN(0);
} /* write_keys */
inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs)
inline int my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, byte *bufs)
{
int err;
uint16 len = _mi_keylength(info->keyinfo,bufs);
uint16 len = _mi_keylength(info->keyinfo, (uchar*) bufs);
if ((err= my_b_write(to_file,(byte*)&len,sizeof(len))))
/* The following is safe as this is a local file */
if ((err= my_b_write(to_file, (byte*)&len, sizeof(len))))
return (err);
if ((err= my_b_write(to_file,(byte*)bufs,(uint) len)))
if ((err= my_b_write(to_file,bufs, (uint) len)))
return (err);
return (0);
}
static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_keys,
uint count, BUFFPEK *buffpek, IO_CACHE *tempfile)
static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info,
register uchar **sort_keys,
uint count, BUFFPEK *buffpek,
IO_CACHE *tempfile)
{
uchar **end;
int err;
@ -653,7 +657,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k
buffpek->count=count;
for (end=sort_keys+count ; sort_keys != end ; sort_keys++)
{
if ((err= my_var_write(info,tempfile,*sort_keys)))
if ((err= my_var_write(info,tempfile, (byte*) *sort_keys)))
DBUG_RETURN(err);
}
DBUG_RETURN(0);
@ -816,7 +820,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info,
for (idx=1;idx<=count;idx++)
{
int err;
if ((err= my_var_write(info,to_file,bufs)))
if ((err= my_var_write(info,to_file, (byte*) bufs)))
return (err);
bufs=bufs+sort_length;
}

View file

@ -271,7 +271,8 @@ int run_test(const char *filename)
create_key(key, nrecords*upd);
print_key(key," INTERSECT\n");
hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0,0);
hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0,
HA_READ_KEY_EXACT);
printf(" %ld rows\n", (long) hrows);
@ -351,7 +352,7 @@ static void print_record(char * record, my_off_t offs,const char * tail)
printf(" len=%d ",len);
memcpy_fixed(&ptr,pos,sizeof(char*));
if(ptr)
rtree_PrintWKB(ptr,SPDIMS);
rtree_PrintWKB((uchar*) ptr,SPDIMS);
else
printf("<NULL> ");
printf(" offs=%ld ",(long int)offs);
@ -406,7 +407,7 @@ static void create_linestring(char *record,uint rownr)
pos++;
memset(blob_key,0,sizeof(blob_key));
tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints,blob_key);
tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints, (uchar*) blob_key);
int4store(pos,tmp);
pos+=4;

View file

@ -90,19 +90,21 @@ CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
CASE WHEN 1 THEN 1.0 END AS c9
;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` char(1) character set latin1 collate latin1_danish_ci default NULL,
`c2` char(1) character set latin1 collate latin1_danish_ci default NULL,
`c3` char(1) default NULL,
`c4` char(1) default NULL,
`c5` char(3) default NULL,
`c6` char(3) default NULL,
`c7` double(3,1) default NULL,
`c8` double(3,1) default NULL
`c1` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
`c2` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
`c3` char(1) NOT NULL default '',
`c4` char(1) NOT NULL default '',
`c5` char(3) NOT NULL default '',
`c6` char(3) NOT NULL default '',
`c7` double(3,1) NOT NULL default '0.0',
`c8` double(3,1) NOT NULL default '0.0',
`c9` double(3,1) default NULL
) TYPE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SELECT CASE

View file

@ -120,7 +120,7 @@ date format str_to_date
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
15 September 2001 %d %M %Y 2001-09-15 00:00:00
15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
@ -144,7 +144,7 @@ date format con
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
15 September 2001 %d %M %Y 2001-09-15 00:00:00
15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
@ -168,7 +168,7 @@ date format datetime
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
15 September 2001 %d %M %Y 2001-09-15 00:00:00
15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
@ -192,7 +192,7 @@ date format date2
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15
15 September 2001 %d %M %Y 2001-09-15
15 SEPTEMB 2001 %d %M %Y 2001-01-15
15 SEPTEMB 2001 %d %M %Y 2001-09-15
15 MAY 2001 %d %b %Y 2001-05-15
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15

View file

@ -40,7 +40,7 @@ t9 CREATE TABLE `t9` (
`b` char(16) NOT NULL default '',
`c` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) TYPE=MyISAM CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
alter table t9 rename t8, add column d int not null;
alter table t8 rename t7;
rename table t7 to t9;
@ -62,5 +62,5 @@ t9 CREATE TABLE `t9` (
`c` int(11) NOT NULL default '0',
`d` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) TYPE=MyISAM CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
drop database mysqltest;

View file

@ -57,7 +57,8 @@ CREATE TABLE t1 SELECT
CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
CASE WHEN 1 THEN 1.0 END AS c9
;
SHOW CREATE TABLE t1;
DROP TABLE t1;

View file

@ -65,7 +65,7 @@ drop table t1;
#
disable_query_log;
--error 1279,1279
--error 1103,1103
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam data directory="tmp";
# Check that we cannot link over a table from another database.
@ -75,7 +75,7 @@ create database mysqltest;
--error 1,1
create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam index directory="/this-dir-does-not-exist";
--error 1279,1279
--error 1103,1103
create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam index directory="not-hard-path";
--error 1,1

View file

@ -29,6 +29,11 @@
#define HIGHFIND 4
#define HIGHUSED 8
typedef struct st_hash_info {
uint next; /* index to next key */
byte *data; /* data for current entry */
} HASH_LINK;
static uint hash_mask(uint hashnr,uint buffmax,uint maxlength);
static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink);
static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length);

View file

@ -23,6 +23,7 @@
*/
#include "mysys_priv.h"
#include <keycache.h>
#include "my_static.h"
#include <m_string.h>
#include <errno.h>
@ -85,28 +86,22 @@
typedef pthread_cond_t KEYCACHE_CONDVAR;
/* info about requests in a waiting queue */
typedef struct st_keycache_wqueue
{
struct st_my_thread_var *last_thread; /* circular list of waiting threads */
} KEYCACHE_WQUEUE;
/* descriptor of the page in the key cache block buffer */
typedef struct st_keycache_page
struct st_keycache_page
{
int file; /* file to which the page belongs to */
my_off_t filepos; /* position of the page in the file */
} KEYCACHE_PAGE;
};
/* element in the chain of a hash table bucket */
typedef struct st_hash_link
struct st_hash_link
{
struct st_hash_link *next, **prev; /* to connect links in the same bucket */
struct st_block_link *block; /* reference to the block for the page: */
File file; /* from such a file */
my_off_t diskpos; /* with such an offset */
uint requests; /* number of requests for the page */
} HASH_LINK; /* offset is always alighed for key_cache_block_size */
};
/* simple states of a block */
#define BLOCK_ERROR 1 /* an error occured when performing disk i/o */
@ -122,7 +117,7 @@ typedef struct st_hash_link
#define PAGE_WAIT_TO_BE_READ 2
/* key cache block */
typedef struct st_block_link
struct st_block_link
{
struct st_block_link
*next_used, **prev_used; /* to connect links in the LRU chain (ring) */
@ -138,52 +133,14 @@ typedef struct st_block_link
uint hits_left; /* number of hits left until promotion */
ulonglong last_hit_time; /* timestamp of the last hit */
KEYCACHE_CONDVAR *condvar; /* condition variable for 'no readers' event */
} BLOCK_LINK;
KEY_CACHE_VAR dflt_key_cache_var=
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
KEY_CACHE_HANDLE *dflt_keycache= &dflt_key_cache_var.cache;
#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */
KEY_CACHE dflt_key_cache_var;
KEY_CACHE *dflt_key_cache= &dflt_key_cache_var;
#define FLUSH_CACHE 2000 /* sort this many blocks at once */
typedef struct st_key_cache
{
KEY_CACHE_VAR *env; /* pointer to key cache variables (if any) */
my_bool key_cache_inited;
uint key_cache_shift;
ulong key_cache_mem_size; /* specified size of the cache memory */
uint key_cache_block_size; /* size of the page buffer of a cache block */
ulong min_warm_blocks; /* min number of warm blocks; */
ulong age_threshold; /* age threshold for hot blocks */
ulonglong keycache_time; /* total number of block link operations */
uint hash_entries; /* max number of entries in the hash table */
int hash_links; /* max number of hash links */
int hash_links_used; /* number of hash links currently used */
int disk_blocks; /* max number of blocks in the cache */
ulong blocks_used; /* number of currently used blocks */
ulong blocks_changed; /* number of currently dirty blocks */
ulong warm_blocks; /* number of blocks in warm sub-chain */
#if defined(KEYCACHE_DEBUG)
long blocks_available; /* number of blocks available in the LRU chain */
#endif
HASH_LINK **hash_root; /* arr. of entries into hash table buckets */
HASH_LINK *hash_link_root; /* memory for hash table links */
HASH_LINK *free_hash_list; /* list of free hash links */
BLOCK_LINK *block_root; /* memory for block links */
byte HUGE_PTR *block_mem; /* memory for block buffers */
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
pthread_mutex_t cache_lock; /* to lock access to the cache structure */
KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */
KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */
BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/
BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/
} KEY_CACHE;
static int flush_all_key_blocks(KEY_CACHE_HANDLE keycache);
static int flush_all_key_blocks(KEY_CACHE *keycache);
static void test_key_cache(KEY_CACHE *keycache,
const char *where, my_bool lock);
@ -202,10 +159,10 @@ static void test_key_cache(KEY_CACHE *keycache,
static FILE *keycache_debug_log=NULL;
static void keycache_debug_print _VARARGS((const char *fmt,...));
#define KEYCACHE_DEBUG_OPEN \
keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w")
if (!keycache_debug_log) keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w")
#define KEYCACHE_DEBUG_CLOSE \
if (keycache_debug_log) fclose(keycache_debug_log)
if (keycache_debug_log) { fclose(keycache_debug_log); keycache_debug_log=0; }
#else
#define KEYCACHE_DEBUG_OPEN
#define KEYCACHE_DEBUG_CLOSE
@ -283,76 +240,56 @@ static uint next_power(uint value)
SYNOPSIS
init_ky_cache()
pkeycache in/out pointer to the key cache handle
key_cache_block_size size of blocks to keep cached data
use_mem total memory to use for the key cache
env ref to other parameters of the key cache, if any
keycache pointer to the key cache handle to initialize
key_cache_block_size size of blocks to keep cached data
use_mem total memory to use for the key cache
division_limit division limit (may be zero)
age_threshold age threshold (may be zero)
RETURN VALUE
number of blocks in the key cache, if successful,
0 - otherwise.
NOTES.
If pkeycache points to an undefined handle (NULL), a new KEY_CACHE
data structure is created and a pointer to it is returned as a new
key cache handle, otherwise *pkeycache is considered as a reused
handle for a key cache with new blocks.
if keycache->key_cache_inited != 0 we assume that the key cache
is already initialized. This is for now used by myisamchk, but shouldn't
be something that a program should rely on!
It's assumed that no two threads call this function simultaneously
referring to the same key cache handle.
*/
int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size,
ulong use_mem, KEY_CACHE_VAR *env)
int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit,
uint age_threshold)
{
uint blocks, hash_links, length;
int error;
KEY_CACHE *keycache;
DBUG_ENTER("init_key_cache");
DBUG_ASSERT(key_cache_block_size >= 512);
if (!(keycache= (KEY_CACHE *) *pkeycache) &&
!(keycache= (KEY_CACHE *) my_malloc(sizeof(KEY_CACHE),
MYF(MY_ZEROFILL))))
DBUG_RETURN(0);
keycache->env= env;
KEYCACHE_DEBUG_OPEN;
if (keycache->key_cache_inited && keycache->disk_blocks > 0)
{
DBUG_PRINT("warning",("key cache already in use"));
DBUG_RETURN(0);
}
if (env && ! keycache->key_cache_inited)
{
env->cache_w_requests= env->cache_r_requests= 0;
env->cache_read= env->cache_write=0;
}
keycache->global_cache_w_requests= keycache->global_cache_r_requests= 0;
keycache->global_cache_read= keycache->global_cache_write= 0;
keycache->disk_blocks= -1;
if (! keycache->key_cache_inited)
{
keycache->key_cache_inited= 1;
keycache->disk_blocks= -1;
pthread_mutex_init(&keycache->cache_lock, MY_MUTEX_INIT_FAST);
keycache->key_cache_shift= my_bit_log2(key_cache_block_size);
keycache->key_cache_mem_size= use_mem;
keycache->key_cache_block_size= key_cache_block_size;
DBUG_PRINT("info", ("key_cache_block_size: %u",
key_cache_block_size));
}
/*
These are safety deallocations: actually we always call the
function after having called end_key_cache that deallocates
these memory itself.
*/
if (keycache->block_mem)
my_free_lock((gptr) keycache->block_mem, MYF(0));
keycache->block_mem= NULL;
if (keycache->block_root)
my_free((gptr) keycache->block_root, MYF(0));
keycache->block_root= NULL;
keycache->key_cache_mem_size= use_mem;
keycache->key_cache_block_size= key_cache_block_size;
keycache->key_cache_shift= my_bit_log2(key_cache_block_size);
DBUG_PRINT("info", ("key_cache_block_size: %u",
key_cache_block_size));
blocks= (uint) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) +
sizeof(HASH_LINK*) * 5/4 + key_cache_block_size));
@ -412,21 +349,20 @@ int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size,
keycache->hash_links_used= 0;
keycache->free_hash_list= NULL;
keycache->blocks_used= keycache->blocks_changed= 0;
if (env)
env->blocks_used= env->blocks_changed= 0;
#if defined(KEYCACHE_DEBUG)
keycache->blocks_available=0;
#endif
keycache->global_blocks_used= keycache->global_blocks_changed= 0;
keycache->blocks_available=0; /* For debugging */
/* The LRU chain is empty after initialization */
keycache->used_last= NULL;
keycache->used_ins= NULL;
keycache->keycache_time= 0;
keycache->warm_blocks= 0;
keycache->min_warm_blocks= (env && env->division_limit ?
blocks * env->division_limit / 100 + 1 :
keycache->min_warm_blocks= (division_limit ?
blocks * division_limit / 100 + 1 :
blocks);
keycache->age_threshold= (env && env->age_threshold ?
blocks * env->age_threshold / 100 :
keycache->age_threshold= (age_threshold ?
blocks * age_threshold / 100 :
blocks);
keycache->waiting_for_hash_link.last_thread= NULL;
@ -437,23 +373,19 @@ int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size,
keycache->disk_blocks, keycache->block_root,
keycache->hash_entries, keycache->hash_root,
keycache->hash_links, keycache->hash_link_root));
bzero((gptr) keycache->changed_blocks,
sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH);
bzero((gptr) keycache->file_blocks,
sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH);
}
bzero((gptr) keycache->changed_blocks,
sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH);
bzero((gptr) keycache->file_blocks,
sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH);
if (env)
env->blocks= keycache->disk_blocks > 0 ? keycache->disk_blocks : 0;
*pkeycache= keycache;
DBUG_PRINT("exit", ("key_cache: %lx", keycache));
keycache->blocks= keycache->disk_blocks > 0 ? keycache->disk_blocks : 0;
DBUG_RETURN((int) blocks);
err:
error= my_errno;
keycache->disk_blocks= 0;
if (env)
env->blocks= 0;
keycache->blocks= 0;
if (keycache->block_mem)
{
my_free_lock((gptr) keycache->block_mem, MYF(0));
@ -474,9 +406,11 @@ err:
SYNOPSIS
resize_key_cache()
pkeycache in/out pointer to the key cache handle
key_cache_block_size size of blocks to keep cached data
use_mem total memory to use for the new key cache
keycache in/out key cache handle
key_cache_block_size size of blocks to keep cached data
use_mem total memory to use for the new key cache
division_limit new division limit (if not zero)
age_threshold new age threshold (if not zero)
RETURN VALUE
number of blocks in the key cache, if successful,
@ -484,35 +418,38 @@ err:
NOTES.
The function first compares the memory size and the block size parameters
with the corresponding parameters of the key cache referred by
*pkeycache. If they differ the function free the the memory allocated
for the old key cache blocks by calling the end_key_cache function
and then rebuilds the key cache with new blocks by calling init_key_cache.
with the key cache values.
If they differ the function free the the memory allocated for the
old key cache blocks by calling the end_key_cache function and
then rebuilds the key cache with new blocks by calling
init_key_cache.
*/
int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size,
ulong use_mem)
int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit,
uint age_threshold)
{
int blocks;
KEY_CACHE *keycache= *pkeycache;
DBUG_ENTER("resize_key_cache");
if (key_cache_block_size == keycache->key_cache_block_size &&
use_mem == keycache->key_cache_mem_size)
return keycache->disk_blocks;
if (!keycache->key_cache_inited ||
(key_cache_block_size == keycache->key_cache_block_size &&
use_mem == keycache->key_cache_mem_size))
DBUG_RETURN(keycache->disk_blocks);
keycache_pthread_mutex_lock(&keycache->cache_lock);
if (flush_all_key_blocks(keycache))
{
/* TODO: if this happens, we should write a warning in the log file ! */
keycache_pthread_mutex_unlock(&keycache->cache_lock);
return 0;
DBUG_RETURN(0);
}
end_key_cache(keycache, 0); /* Don't free mutex */
/* the following will work even if use_mem is 0 */
blocks= init_key_cache(keycache, key_cache_block_size, use_mem,
division_limit, age_threshold);
keycache_pthread_mutex_unlock(&keycache->cache_lock);
end_key_cache(keycache, 0);
/* the following will work even if memory is 0 */
blocks= init_key_cache(pkeycache, key_cache_block_size, use_mem,
keycache->env);
return blocks;
}
@ -522,7 +459,9 @@ int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size,
SYNOPSIS
change_key_cache_param()
keycache the key cache handle
keycache key cache handle
division_limit new division limit (if not zero)
age_threshold new age threshold (if not zero)
RETURN VALUE
none
@ -530,24 +469,20 @@ int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size,
NOTES.
Presently the function resets the key cache parameters
concerning midpoint insertion strategy - division_limit and
age_threshold. It corresponding values are passed through
the keycache->env structure.
age_threshold.
*/
void change_key_cache_param(KEY_CACHE_HANDLE keycache)
void change_key_cache_param(KEY_CACHE *keycache, uint division_limit,
uint age_threshold)
{
KEY_CACHE_VAR *env= keycache->env;
DBUG_ENTER("change_key_cache_param");
if (env)
{
if (env->division_limit)
keycache->min_warm_blocks= (keycache->disk_blocks *
env->division_limit / 100 + 1);
if (env->age_threshold)
keycache->age_threshold= (keycache->disk_blocks *
env->age_threshold / 100);
}
if (division_limit)
keycache->min_warm_blocks= (keycache->disk_blocks *
division_limit / 100 + 1);
if (age_threshold)
keycache->age_threshold= (keycache->disk_blocks *
age_threshold / 100);
DBUG_VOID_RETURN;
}
@ -557,26 +492,21 @@ void change_key_cache_param(KEY_CACHE_HANDLE keycache)
SYNOPSIS
end_key_cache()
pkeycache in/out pointer to the key cache handle
cleanup <-> the key cache data structure is freed as well
keycache key cache handle
cleanup Complete free (Free also mutex for key cache)
RETURN VALUE
none
NOTES.
If the cleanup parameter is TRUE the data structure with all associated
elements are freed completely
Otherwise only memory used by the key cache blocks is freed.
*/
void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup)
void end_key_cache(KEY_CACHE *keycache, my_bool cleanup)
{
KEY_CACHE_VAR *env;
DBUG_ENTER("end_key_cache");
DBUG_PRINT("enter", ("key_cache: %lx", keycache));
if (!keycache)
if (!keycache->key_cache_inited)
DBUG_VOID_RETURN;
if (keycache->disk_blocks > 0)
{
if (keycache->block_mem)
@ -587,22 +517,22 @@ void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup)
keycache->block_root= NULL;
}
keycache->disk_blocks= -1;
/* Reset blocks_changed to be safe if flush_all_key_blocks is called */
keycache->blocks_changed= 0;
}
KEYCACHE_DEBUG_CLOSE;
keycache->key_cache_inited= 0;
if ((env= keycache->env))
{
DBUG_PRINT("status",
("used: %d changed: %d w_requests: %ld \
writes: %ld r_requests: %ld reads: %ld",
env->blocks_used, env->blocks_changed,
env->cache_w_requests, env->cache_write,
env->cache_r_requests, env->cache_read));
}
DBUG_PRINT("status",
("used: %d changed: %d w_requests: %ld \
writes: %ld r_requests: %ld reads: %ld",
keycache->global_blocks_used, keycache->global_blocks_changed,
keycache->global_cache_w_requests, keycache->global_cache_write,
keycache->global_cache_r_requests, keycache->global_cache_read));
if (cleanup)
{
pthread_mutex_destroy(&keycache->cache_lock);
my_free((gptr) keycache, MYF(0));
keycache->key_cache_inited= 0;
KEYCACHE_DEBUG_CLOSE;
}
DBUG_VOID_RETURN;
} /* end_key_cache */
@ -786,8 +716,7 @@ static void link_to_file_list(KEY_CACHE *keycache,
{
block->status&= ~BLOCK_CHANGED;
keycache->blocks_changed--;
if (keycache->env)
keycache->env->blocks_changed--;
keycache->global_blocks_changed--;
}
}
@ -805,8 +734,7 @@ static inline void link_to_changed_list(KEY_CACHE *keycache,
&keycache->changed_blocks[FILE_HASH(block->hash_link->file)]);
block->status|=BLOCK_CHANGED;
keycache->blocks_changed++;
if (keycache->env)
keycache->env->blocks_changed++;
keycache->global_blocks_changed++;
}
@ -1328,8 +1256,7 @@ restart:
block->offset= keycache->key_cache_block_size;
block->requests= 1;
keycache->blocks_used++;
if (keycache->env)
keycache->env->blocks_used++;
keycache->global_blocks_used++;
keycache->warm_blocks++;
block->hits_left= init_hits_left;
block->last_hit_time= 0;
@ -1401,8 +1328,7 @@ restart:
block->hash_link->diskpos+ block->offset,
MYF(MY_NABP | MY_WAIT_IF_FULL));
keycache_pthread_mutex_lock(&keycache->cache_lock);
if (keycache->env)
keycache->env->cache_write++;
keycache->global_cache_write++;
}
block->status|= BLOCK_REASSIGNED;
@ -1441,8 +1367,7 @@ restart:
PAGE_READ : PAGE_WAIT_TO_BE_READ;
}
}
if (keycache->env)
keycache->env->cache_read++;
keycache->global_cache_read++;
}
else
{
@ -1582,42 +1507,47 @@ static void read_block(KEY_CACHE *keycache,
have to be a multiple of key_cache_block_size;
*/
byte *key_cache_read(KEY_CACHE_HANDLE keycache,
byte *key_cache_read(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
byte *buff, uint length,
uint block_length __attribute__((unused)),
int return_buffer __attribute__((unused)))
{
int error=0;
uint offset= 0;
byte *start= buff;
DBUG_ENTER("key_cache_read");
DBUG_PRINT("enter", ("file %u, filepos %lu, length %u",
(uint) file, (ulong) filepos, length));
if (keycache && keycache->disk_blocks > 0)
if (keycache->disk_blocks > 0)
{
/* Key cache is used */
reg1 BLOCK_LINK *block;
uint offset= (uint) (filepos & (keycache->key_cache_block_size-1));
byte *start= buff;
uint read_length;
uint status;
int page_st;
#ifndef THREAD
if (block_length > keycache->key_cache_block_size || offset)
return_buffer=0;
#endif
/* Read data in key_cache_block_size increments */
filepos-= offset;
do
{
keycache_pthread_mutex_lock(&keycache->cache_lock);
if (keycache->disk_blocks <= 0) /* Resize failed */
{
keycache_pthread_mutex_unlock(&keycache->cache_lock);
goto no_key_cache;
}
read_length= length > keycache->key_cache_block_size ?
keycache->key_cache_block_size : length;
KEYCACHE_DBUG_ASSERT(read_length > 0);
keycache_pthread_mutex_lock(&keycache->cache_lock);
if (keycache->env)
keycache->env->cache_r_requests++;
offset= (uint) (filepos & (keycache->key_cache_block_size-1));
filepos-= offset;
#ifndef THREAD
if (block_length > keycache->key_cache_block_size || offset)
return_buffer=0;
#endif
keycache->global_cache_r_requests++;
block=find_key_block(keycache, file, filepos, level, 0, &page_st);
if (block->status != BLOCK_ERROR && page_st != PAGE_READ)
{
@ -1673,29 +1603,25 @@ byte *key_cache_read(KEY_CACHE_HANDLE keycache,
DBUG_RETURN((byte *) 0);
#ifndef THREAD
/* This is only true if we where able to read everything in one block */
if (return_buffer)
return (block->buffer);
return (block->buffer);
#endif
buff+= read_length;
filepos+= read_length;
offset= 0;
} while ((length-= read_length));
DBUG_RETURN(start);
}
/* Key cache is not used */
if (keycache && keycache->env)
{
statistic_increment(keycache->env->cache_r_requests,
&keycache->cache_lock);
statistic_increment(keycache->env->cache_read,
&keycache->cache_lock);
}
if (my_pread(file, (byte*) buff, length, filepos, MYF(MY_NABP)))
no_key_cache: /* Key cache is not used */
/* We can't use mutex here as the key cache may not be initialized */
keycache->global_cache_r_requests++;
keycache->global_cache_read++;
if (my_pread(file, (byte*) buff, length, filepos+offset, MYF(MY_NABP)))
error= 1;
DBUG_RETURN(error? (byte*) 0 : buff);
DBUG_RETURN(error ? (byte*) 0 : start);
}
@ -1703,20 +1629,23 @@ byte *key_cache_read(KEY_CACHE_HANDLE keycache,
Insert a block of file data from a buffer into key cache
SYNOPSIS
key_cache_insert()
keycache pointer to a key cache data structure
file handler for the file to insert data from
filepos position of the block of data in the file to insert
level determines the weight of the data
buff buffer to read data from
length length of the data in the buffer
keycache pointer to a key cache data structure
file handler for the file to insert data from
filepos position of the block of data in the file to insert
level determines the weight of the data
buff buffer to read data from
length length of the data in the buffer
NOTES
This is used by MyISAM to move all blocks from a index file to the key
cache
RETURN VALUE
0 if a success, 1 - otherwise.
*/
int key_cache_insert(KEY_CACHE_HANDLE keycache,
int key_cache_insert(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
byte *buff, uint length)
{
@ -1728,20 +1657,27 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache,
{
/* Key cache is used */
reg1 BLOCK_LINK *block;
uint offset= (uint) (filepos & (keycache->key_cache_block_size-1));
uint read_length;
int page_st;
int error;
/* Read data into key cache from buff in key_cache_block_size increments */
filepos-= offset;
do
{
uint offset;
keycache_pthread_mutex_lock(&keycache->cache_lock);
if (keycache->disk_blocks <= 0) /* Resize failed */
{
keycache_pthread_mutex_unlock(&keycache->cache_lock);
DBUG_RETURN(0);
}
read_length= length > keycache->key_cache_block_size ?
keycache->key_cache_block_size : length;
KEYCACHE_DBUG_ASSERT(read_length > 0);
keycache_pthread_mutex_lock(&keycache->cache_lock);
if (keycache->env)
keycache->env->cache_r_requests++;
offset= (uint) (filepos & (keycache->key_cache_block_size-1));
/* Read data into key cache from buff in key_cache_block_size incr. */
filepos-= offset;
keycache->global_cache_r_requests++;
block= find_key_block(keycache, file, filepos, level, 0, &page_st);
if (block->status != BLOCK_ERROR && page_st != PAGE_READ)
{
@ -1770,14 +1706,14 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache,
*/
unreg_request(keycache, block, 1);
error= (block->status & BLOCK_ERROR);
keycache_pthread_mutex_unlock(&keycache->cache_lock);
if (block->status & BLOCK_ERROR)
if (error)
DBUG_RETURN(1);
buff+= read_length;
filepos+= read_length;
offset=0;
} while ((length-= read_length));
}
@ -1812,7 +1748,7 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache,
have to be a multiple of key_cache_block_size;
*/
int key_cache_write(KEY_CACHE_HANDLE keycache,
int key_cache_write(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
byte *buff, uint length,
uint block_length __attribute__((unused)),
@ -1829,9 +1765,7 @@ int key_cache_write(KEY_CACHE_HANDLE keycache,
if (!dont_write)
{
/* Force writing from buff into disk */
if (keycache && keycache->env)
statistic_increment(keycache->env->cache_write,
&keycache->cache_lock);
keycache->global_cache_write++;
if (my_pwrite(file, buff, length, filepos, MYF(MY_NABP | MY_WAIT_IF_FULL)))
DBUG_RETURN(1);
}
@ -1841,23 +1775,29 @@ int key_cache_write(KEY_CACHE_HANDLE keycache,
test_key_cache(keycache, "start of key_cache_write", 1););
#endif
if (keycache && keycache->disk_blocks > 0)
if (keycache->disk_blocks > 0)
{
/* Key cache is used */
uint read_length;
uint offset= (uint) (filepos & (keycache->key_cache_block_size-1));
int page_st;
/* Write data in key_cache_block_size increments */
filepos-= offset;
do
{
read_length= length > keycache->key_cache_block_size ?
keycache->key_cache_block_size : length;
KEYCACHE_DBUG_ASSERT(read_length > 0);
uint offset;
keycache_pthread_mutex_lock(&keycache->cache_lock);
if (keycache->env)
keycache->env->cache_w_requests++;
if (keycache->disk_blocks <= 0) /* Resize failed */
{
keycache_pthread_mutex_unlock(&keycache->cache_lock);
goto no_key_cache;
}
read_length= length > keycache->key_cache_block_size ?
keycache->key_cache_block_size : length;
KEYCACHE_DBUG_ASSERT(read_length > 0);
offset= (uint) (filepos & (keycache->key_cache_block_size-1));
/* Write data in key_cache_block_size increments */
filepos-= offset;
keycache->global_cache_w_requests++;
block= find_key_block(keycache, file, filepos, level, 1, &page_st);
if (block->status != BLOCK_ERROR && page_st != PAGE_READ &&
(offset || read_length < keycache->key_cache_block_size))
@ -1907,25 +1847,21 @@ int key_cache_write(KEY_CACHE_HANDLE keycache,
offset= 0;
} while ((length-= read_length));
}
else
{
/* Key cache is not used */
if (dont_write)
{
if (keycache && keycache->env)
{
statistic_increment(keycache->env->cache_w_requests,
&keycache->cache_lock);
statistic_increment(keycache->env->cache_write,
&keycache->cache_lock);
}
if (my_pwrite(file, (byte*) buff, length, filepos,
MYF(MY_NABP | MY_WAIT_IF_FULL)))
error=1;
}
goto end;
}
no_key_cache:
/* Key cache is not used */
if (dont_write)
{
keycache->global_cache_w_requests++;
keycache->global_cache_write++;
if (my_pwrite(file, (byte*) buff, length, filepos,
MYF(MY_NABP | MY_WAIT_IF_FULL)))
error=1;
}
end:
#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
DBUG_EXECUTE("exec",
test_key_cache(keycache, "end of key_cache_write", 1););
@ -2007,8 +1943,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache,
block->hash_link->diskpos+ block->offset,
MYF(MY_NABP | MY_WAIT_IF_FULL));
keycache_pthread_mutex_lock(&keycache->cache_lock);
if (keycache->env)
keycache->env->cache_write++;
keycache->global_cache_write++;
if (error)
{
block->status|= BLOCK_ERROR;
@ -2019,8 +1954,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache,
if (! (type == FLUSH_KEEP || type == FLUSH_FORCE_WRITE))
{
keycache->blocks_changed--;
if (keycache->env)
keycache->env->blocks_changed--;
keycache->global_blocks_changed--;
free_block(keycache, block);
}
else
@ -2053,10 +1987,9 @@ static int flush_cached_blocks(KEY_CACHE *keycache,
1 error
*/
static int flush_key_blocks_int(KEY_CACHE_HANDLE keycache,
static int flush_key_blocks_int(KEY_CACHE *keycache,
File file, enum flush_type type)
{
KEY_CACHE_VAR *env;
BLOCK_LINK *cache_buff[FLUSH_CACHE],**cache;
int last_errno= 0;
DBUG_ENTER("flush_key_blocks_int");
@ -2161,8 +2094,7 @@ restart:
{
/* It's a temporary file */
keycache->blocks_changed--;
if (keycache->env)
keycache->env->blocks_changed--;
keycache->global_blocks_changed--;
free_block(keycache, block);
}
}
@ -2227,8 +2159,8 @@ restart:
}
}
if (type == FLUSH_REMOVE && (env= keycache->env) && (env->action))
(*env->action)((void *) env);
if (type == FLUSH_REMOVE && keycache->action)
(*keycache->action)(keycache);
#ifndef DBUG_OFF
DBUG_EXECUTE("check_keycache",
@ -2257,14 +2189,14 @@ restart:
1 error
*/
int flush_key_blocks(KEY_CACHE_HANDLE key_cache,
int flush_key_blocks(KEY_CACHE *key_cache,
File file, enum flush_type type)
{
int res;
DBUG_ENTER("flush_key_blocks");
DBUG_PRINT("enter", ("key_cache: %lx", key_cache));
if (!key_cache || !key_cache->disk_blocks)
if (key_cache->disk_blocks <= 0)
DBUG_RETURN(0);
keycache_pthread_mutex_lock(&key_cache->cache_lock);
res= flush_key_blocks_int(key_cache, file, type);

View file

@ -23,6 +23,7 @@
*/
#include "mysys_priv.h"
#include <keycache.h>
#include <hash.h>
#include <m_string.h>
@ -295,7 +296,7 @@ static SAFE_HASH key_cache_hash;
my_bool multi_keycache_init(void)
{
return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_keycache);
return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_key_cache);
}
@ -321,11 +322,11 @@ void multi_keycache_free(void)
key cache to use
*/
KEY_CACHE_HANDLE *multi_key_cache_search(byte *key, uint length)
KEY_CACHE *multi_key_cache_search(byte *key, uint length)
{
if (!key_cache_hash.hash.records)
return dflt_keycache;
return (KEY_CACHE_HANDLE*) safe_hash_search(&key_cache_hash, key, length);
return dflt_key_cache;
return (KEY_CACHE*) safe_hash_search(&key_cache_hash, key, length);
}
@ -346,14 +347,14 @@ KEY_CACHE_HANDLE *multi_key_cache_search(byte *key, uint length)
my_bool multi_key_cache_set(const byte *key, uint length,
KEY_CACHE_HANDLE *key_cache)
KEY_CACHE *key_cache)
{
return safe_hash_set(&key_cache_hash, key, length, (byte*) key_cache);
}
void multi_key_cache_change(KEY_CACHE_HANDLE *old_data,
KEY_CACHE_HANDLE *new_data)
void multi_key_cache_change(KEY_CACHE *old_data,
KEY_CACHE *new_data)
{
safe_hash_change(&key_cache_hash, (byte*) old_data, (byte*) new_data);
}

View file

@ -54,12 +54,15 @@ void safe_mutex_global_init(void)
int safe_mutex_init(safe_mutex_t *mp,
const pthread_mutexattr_t *attr __attribute__((unused)),
const char *file __attribute__((unused)),
uint line __attribute__((unused)))
const char *file,
uint line)
{
bzero((char*) mp,sizeof(*mp));
pthread_mutex_init(&mp->global,MY_MUTEX_INIT_ERRCHK);
pthread_mutex_init(&mp->mutex,attr);
/* Mark that mutex is initialized */
mp->file= file;
mp->line= line;
#ifdef SAFE_MUTEX_DETECT_DESTROY
/*
@ -70,7 +73,7 @@ int safe_mutex_init(safe_mutex_t *mp,
{
struct st_safe_mutex_info_t *info =mp->info;
info->init_file= (char *) file;
info->init_file= file;
info->init_line= line;
info->prev= NULL;
info->next= NULL;
@ -92,6 +95,13 @@ int safe_mutex_init(safe_mutex_t *mp,
int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
{
int error;
if (!mp->file)
{
fprintf(stderr,"safe_mutex: Trying to lock unitialized mutex at %s, line %d", file, line);
fflush(stderr);
abort();
}
pthread_mutex_lock(&mp->global);
if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread))
{
@ -117,7 +127,7 @@ line %d more than 1 time\n", file,line);
abort();
}
mp->thread=pthread_self();
mp->file= (char*) file;
mp->file= file;
mp->line=line;
pthread_mutex_unlock(&mp->global);
return error;
@ -204,7 +214,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
abort();
}
mp->thread=pthread_self();
mp->file= (char*) file;
mp->file= file;
mp->line=line;
pthread_mutex_unlock(&mp->global);
return error;
@ -242,7 +252,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
abort();
}
mp->thread=pthread_self();
mp->file= (char*) file;
mp->file= file;
mp->line=line;
pthread_mutex_unlock(&mp->global);
return error;
@ -268,6 +278,7 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
if (pthread_mutex_destroy(&mp->mutex))
error=1;
#endif
mp->file= 0; /* Mark destroyed */
#ifdef SAFE_MUTEX_DETECT_DESTROY
if (mp->info)

View file

@ -634,7 +634,7 @@ void free_rows(MYSQL_DATA *cur)
}
}
my_bool STDCALL
my_bool
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length,
const char *arg, ulong arg_length, my_bool skip_check)
@ -1014,7 +1014,8 @@ void mysql_read_default_options(struct st_mysql_options *options,
else the lengths are calculated from the offset between pointers.
**************************************************************************/
static void STDCALL cli_fetch_lengths(ulong *to, MYSQL_ROW column, unsigned int field_count)
static void cli_fetch_lengths(ulong *to, MYSQL_ROW column,
unsigned int field_count)
{
ulong *prev_length;
byte *start=0;
@ -1145,8 +1146,8 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
/* Read all rows (fields or data) from server */
MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
unsigned int fields)
MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
unsigned int fields)
{
uint field;
ulong pkt_len;
@ -1402,8 +1403,8 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
before calling mysql_real_connect !
*/
static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql);
static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql);
static my_bool cli_mysql_read_query_result(MYSQL *mysql);
static MYSQL_RES *cli_mysql_use_result(MYSQL *mysql);
static MYSQL_METHODS client_methods=
{
@ -2227,7 +2228,7 @@ void STDCALL mysql_close(MYSQL *mysql)
DBUG_VOID_RETURN;
}
static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql)
static my_bool cli_mysql_read_query_result(MYSQL *mysql)
{
uchar *pos;
ulong field_count;
@ -2402,7 +2403,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql)
have to wait for the client (and will not wait more than 30 sec/packet).
**************************************************************************/
static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql)
static MYSQL_RES * cli_mysql_use_result(MYSQL *mysql)
{
MYSQL_RES *result;
DBUG_ENTER("cli_mysql_use_result");

View file

@ -75,6 +75,7 @@ Please install the latest version of this file.",name);
goto err1;
}
/* TODO: Convert the character set to server system character set */
if (!(cset= get_charset(head[30],MYF(MY_WME))))
{
sql_print_error("Character set #%d is not supported for messagefile '%s'",

View file

@ -2850,7 +2850,7 @@ String *Field_timestamp::val_str(String *val_buffer,
struct tm tm_tmp;
val_buffer->alloc(field_length+1);
char *to=(char*) val_buffer->ptr(),*end=to+field_length;
char *to= (char*) val_buffer->ptr();
val_buffer->length(field_length);
#ifdef WORDS_BIGENDIAN
@ -3987,7 +3987,6 @@ longlong Field_string::val_int(void)
String *Field_string::val_str(String *val_buffer __attribute__((unused)),
String *val_ptr)
{
char *end=ptr+field_length;
uint length= field_charset->cset->lengthsp(field_charset, ptr, field_length);
val_ptr->set((const char*) ptr, length, field_charset);
return val_ptr;

View file

@ -546,7 +546,6 @@ innobase_query_caching_of_table_permitted(
{
ibool is_autocommit;
trx_t* trx;
char* ptr;
char norm_name[1000];
ut_a(full_name_len < 999);
@ -606,7 +605,7 @@ innobase_query_caching_of_table_permitted(
#ifdef __WIN__
/* Put to lower case */
ptr = norm_name;
char* ptr = norm_name;
while (*ptr != '\0') {
*ptr = tolower(*ptr);
@ -1391,7 +1390,6 @@ ha_innobase::open(
uint test_if_locked) /* in: not used */
{
dict_table_t* ib_table;
int error = 0;
char norm_name[1000];
DBUG_ENTER("ha_innobase::open");

View file

@ -226,7 +226,6 @@ err:
int ha_myisam::open(const char *name, int mode, uint test_if_locked)
{
KEY_CACHE_VAR *key_cache;
if (!(file=mi_open(name, mode, test_if_locked)))
return (my_errno ? my_errno : -1);
@ -698,7 +697,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
{
KEY_CACHE_VAR *new_key_cache= check_opt->key_cache;
KEY_CACHE *new_key_cache= check_opt->key_cache;
const char *errmsg= 0;
int error= HA_ADMIN_OK;
ulonglong map= ~(ulonglong) 0;

View file

@ -39,7 +39,6 @@ const char **ha_myisammrg::bas_ext() const
int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
{
char name_buff[FN_REFLEN];
KEY_CACHE_VAR *key_cache;
DBUG_PRINT("info", ("ha_myisammrg::open"));
if (!(file=myrg_open(fn_format(name_buff,name,"","",2 | 4), mode,
@ -312,11 +311,11 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd,
static void split_file_name(const char *file_name,
LEX_STRING *db, LEX_STRING *name)
{
uint name_length, dir_length, prefix_length;
uint dir_length, prefix_length;
char buff[FN_REFLEN];
db->length= 0;
name_length= (uint) (strmake(buff, file_name, sizeof(buff)-1) - buff);
strmake(buff, file_name, sizeof(buff)-1);
dir_length= dirname_length(buff);
if (dir_length > 1)
{

View file

@ -1132,20 +1132,22 @@ void st_ha_check_opt::init()
/* Init a key cache if it has not been initied before */
int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache)
int ha_init_key_cache(const char *name, KEY_CACHE *key_cache)
{
DBUG_ENTER("ha_init_key_cache");
if (!key_cache->cache)
if (!key_cache->key_cache_inited)
{
pthread_mutex_lock(&LOCK_global_system_variables);
long tmp_buff_size= (long) key_cache->buff_size;
long tmp_block_size= (long) key_cache->block_size;
long tmp_buff_size= (long) key_cache->param_buff_size;
long tmp_block_size= (long) key_cache->param_block_size;
uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold;
pthread_mutex_unlock(&LOCK_global_system_variables);
DBUG_RETURN(!init_key_cache(&key_cache->cache,
DBUG_RETURN(!init_key_cache(key_cache,
tmp_block_size,
tmp_buff_size,
key_cache));
division_limit, age_threshold));
}
DBUG_RETURN(0);
}
@ -1153,18 +1155,21 @@ int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache)
/* Resize key cache */
int ha_resize_key_cache(KEY_CACHE_VAR *key_cache)
int ha_resize_key_cache(KEY_CACHE *key_cache)
{
DBUG_ENTER("ha_resize_key_cache");
if (key_cache->cache)
if (key_cache->key_cache_inited)
{
pthread_mutex_lock(&LOCK_global_system_variables);
long tmp_buff_size= (long) key_cache->buff_size;
long tmp_block_size= (long) key_cache->block_size;
long tmp_buff_size= (long) key_cache->param_buff_size;
long tmp_block_size= (long) key_cache->param_block_size;
uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold;
pthread_mutex_unlock(&LOCK_global_system_variables);
DBUG_RETURN(!resize_key_cache(&key_cache->cache, tmp_block_size,
tmp_buff_size));
DBUG_RETURN(!resize_key_cache(key_cache, tmp_block_size,
tmp_buff_size,
division_limit, age_threshold));
}
DBUG_RETURN(0);
}
@ -1172,29 +1177,31 @@ int ha_resize_key_cache(KEY_CACHE_VAR *key_cache)
/* Change parameters for key cache (like size) */
int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache)
int ha_change_key_cache_param(KEY_CACHE *key_cache)
{
if (key_cache->cache)
change_key_cache_param(key_cache->cache);
if (key_cache->key_cache_inited)
{
pthread_mutex_lock(&LOCK_global_system_variables);
uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold;
pthread_mutex_unlock(&LOCK_global_system_variables);
change_key_cache_param(key_cache, division_limit, age_threshold);
}
return 0;
}
/* Free memory allocated by a key cache */
int ha_end_key_cache(KEY_CACHE_VAR *key_cache)
int ha_end_key_cache(KEY_CACHE *key_cache)
{
if (key_cache->cache)
{
end_key_cache(key_cache->cache, 1); // Can never fail
key_cache->cache= 0;
}
end_key_cache(key_cache, 1); // Can never fail
return 0;
}
/* Move all tables from one key cache to another one */
int ha_change_key_cache(KEY_CACHE_VAR *old_key_cache,
KEY_CACHE_VAR *new_key_cache)
int ha_change_key_cache(KEY_CACHE *old_key_cache,
KEY_CACHE *new_key_cache)
{
mi_change_key_cache(old_key_cache, new_key_cache);
return 0;

View file

@ -22,6 +22,7 @@
#endif
#include <ft_global.h>
#include <keycache.h>
#ifndef NO_HASH
#define NO_HASH /* Not yet implemented */
@ -181,14 +182,13 @@ typedef struct st_ha_create_information
struct st_table;
typedef struct st_table TABLE;
typedef struct st_key_cache_asmt KEY_CACHE_ASMT;
typedef struct st_ha_check_opt
{
ulong sort_buffer_size;
uint flags; /* isam layer flags (e.g. for myisamchk) */
uint sql_flags; /* sql layer flags - for something myisamchk cannot do */
KEY_CACHE_VAR *key_cache; /* new key cache when changing key cache */
KEY_CACHE *key_cache; /* new key cache when changing key cache */
void init();
} HA_CHECK_OPT;
@ -394,10 +394,10 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
bool update_create_info);
int ha_delete_table(enum db_type db_type, const char *path);
void ha_drop_database(char* path);
int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache);
int ha_resize_key_cache(KEY_CACHE_VAR *key_cache);
int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache);
int ha_end_key_cache(KEY_CACHE_VAR *key_cache);
int ha_init_key_cache(const char *name, KEY_CACHE *key_cache);
int ha_resize_key_cache(KEY_CACHE *key_cache);
int ha_change_key_cache_param(KEY_CACHE *key_cache);
int ha_end_key_cache(KEY_CACHE *key_cache);
int ha_start_stmt(THD *thd);
int ha_report_binlog_offset_and_commit(THD *thd, char *log_file_name,
my_off_t end_offset);
@ -411,5 +411,5 @@ int ha_autocommit_or_rollback(THD *thd, int error);
void ha_set_spin_retries(uint retries);
bool ha_flush_logs(void);
int ha_recovery_logging(THD *thd, bool on);
int ha_change_key_cache(KEY_CACHE_VAR *old_key_cache,
KEY_CACHE_VAR *new_key_cache);
int ha_change_key_cache(KEY_CACHE *old_key_cache,
KEY_CACHE *new_key_cache);

View file

@ -1347,7 +1347,7 @@ bool Item::send(Protocol *protocol, String *buffer)
case MYSQL_TYPE_FLOAT:
{
float nr;
nr= val();
nr= (float) val();
if (!null_value)
result= protocol->store(nr, decimals, buffer);
break;

View file

@ -397,13 +397,12 @@ int Arg_comparator::compare_row()
int Arg_comparator::compare_e_row()
{
int res= 0;
(*a)->bring_value();
(*b)->bring_value();
uint n= (*a)->cols();
for (uint i= 0; i<n; i++)
{
if ((res= !comparators[i].compare()))
if (!comparators[i].compare())
return 0;
}
return 1;
@ -1096,8 +1095,10 @@ void Item_func_case::fix_length_and_dec()
return;
// Aggregate first expression and all THEN expression types
// and collations when string comparison
/*
Aggregate first expression and all THEN expression types
and collations when string comparison
*/
if (first_expr_num != -1)
{
agg[0]= args[first_expr_num];
@ -1110,7 +1111,7 @@ void Item_func_case::fix_length_and_dec()
return;
}
if (!else_expr_num != -1 || args[else_expr_num]->maybe_null)
if (else_expr_num == -1 || args[else_expr_num]->maybe_null)
maybe_null=1;
max_length=0;
@ -1127,6 +1128,7 @@ void Item_func_case::fix_length_and_dec()
}
}
/* TODO: Fix this so that it prints the whole CASE expression */
void Item_func_case::print(String *str)
@ -1538,7 +1540,6 @@ void Item_func_in::fix_length_and_dec()
{
switch (cmp_type) {
case STRING_RESULT:
uint i;
array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
cmp_collation.collation);
break;

View file

@ -2321,9 +2321,7 @@ String *user_var_entry::val_str(my_bool *null_value, String *str,
bool
Item_func_set_user_var::check()
{
bool res;
DBUG_ENTER("Item_func_set_user_var::check");
LINT_INIT(res);
switch (cached_result_type) {
case REAL_RESULT:
@ -3013,7 +3011,6 @@ longlong Item_func_is_free_lock::val_int()
String *res=args[0]->val_str(&value);
THD *thd=current_thd;
ULL *ull;
int error=0;
null_value=0;
if (!res || !res->length())

View file

@ -324,7 +324,6 @@ null:
void Item_func_concat::fix_length_and_dec()
{
bool first_coll= 1;
max_length=0;
if (agg_arg_collations(collation, args, arg_count))
@ -2018,7 +2017,7 @@ void Item_func_lpad::fix_length_and_dec()
String *Item_func_lpad::val_str(String *str)
{
uint32 res_byte_length,res_char_length,pad_byte_length,pad_char_length;
uint32 res_char_length,pad_char_length;
ulong count= (long) args[1]->val_int(), byte_count;
String a1,a3;
String *res= args[0]->val_str(&a1);
@ -2028,7 +2027,6 @@ String *Item_func_lpad::val_str(String *str)
goto err;
null_value=0;
res_byte_length= res->length();
res_char_length= res->numchars();
if (count <= res_char_length)
@ -2037,7 +2035,6 @@ String *Item_func_lpad::val_str(String *str)
return res;
}
pad_byte_length= pad->length();
pad_char_length= pad->numchars();
byte_count= count * collation.collation->mbmaxlen;

View file

@ -1642,10 +1642,8 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct,
original= 0;
quick_group= 0;
mark_as_sum_func();
item_thd= current_thd;
SELECT_LEX *select_lex= item_thd->lex.current_select;
order= 0;
group_concat_max_len= item_thd->variables.group_concat_max_len;
group_concat_max_len= current_thd->variables.group_concat_max_len;
arg_show_fields= arg_count_field= is_select->elements;
@ -1791,6 +1789,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
thd->allow_sum_func= 0;
maybe_null= 0;
item_thd= thd;
for (i= 0 ; i < arg_count ; i++)
{
if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1))
@ -1969,6 +1968,7 @@ String* Item_func_group_concat::val_str(String* str)
return &result;
}
void Item_func_group_concat::print(String *str)
{
str->append("group_concat(", 13);

View file

@ -137,14 +137,12 @@ static bool make_datetime(date_time_format_types format, TIME *ltime,
static bool extract_date_time(DATE_TIME_FORMAT *format,
const char *val, uint length, TIME *l_time)
{
int weekday= 0, yearday= 0, daypart= 0, len;
int weekday= 0, yearday= 0, daypart= 0;
int week_number= -1;
CHARSET_INFO *cs= &my_charset_bin;
int error= 0;
bool usa_time= 0;
bool sunday_first= 0;
uint part_len= 0;
const char *val_ptr= val;
const char *val_end= val + length;
const char *ptr= format->format.str;
const char *end= ptr+ format->format.length;
@ -1385,7 +1383,6 @@ String *Item_func_from_unixtime::val_str(String *str)
{
struct tm tm_tmp,*start;
time_t tmp=(time_t) args[0]->val_int();
CHARSET_INFO *cs= &my_charset_bin;
TIME ltime;
if ((null_value=args[0]->null_value))
@ -1759,6 +1756,7 @@ bool Item_extract::eq(const Item *item, bool binary_cmp) const
return 1;
}
void Item_typecast::print(String *str)
{
str->append("cast(", 5);
@ -1768,6 +1766,7 @@ void Item_typecast::print(String *str)
str->append(')');
}
void Item_char_typecast::print(String *str)
{
str->append("cast(", 5);

View file

@ -432,8 +432,6 @@ bool check_stack_overrun(THD *thd,char *dummy);
void table_cache_init(void);
void table_cache_free(void);
uint cached_tables(void);
void reassign_key_cache(KEY_CACHE_ASMT *key_cache_asmt,
KEY_CACHE_VAR *new_key_cache);
void kill_mysql(void);
void close_connection(THD *thd, uint errcode, bool lock);
bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
@ -466,8 +464,8 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* table_list,
int mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list,
LEX_STRING *key_cache_name);
int mysql_preload_keys(THD* thd, TABLE_LIST* table_list);
int reassign_keycache_tables(THD* thd, KEY_CACHE_VAR *src_cache,
KEY_CACHE_VAR *dst_cache);
int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
KEY_CACHE *dst_cache);
bool check_simple_select();
@ -870,8 +868,7 @@ extern SHOW_COMP_OPTION have_berkeley_db;
extern struct system_variables global_system_variables;
extern struct system_variables max_system_variables;
extern struct rand_struct sql_rand;
extern KEY_CACHE_VAR *sql_key_cache;
extern KEY_CACHE_HANDLE sql_key_cache_handle;
extern KEY_CACHE *sql_key_cache;
extern const char *opt_date_time_formats[];
extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];

View file

@ -355,7 +355,7 @@ struct system_variables max_system_variables;
MY_TMPDIR mysql_tmpdir_list;
MY_BITMAP temp_pool;
KEY_CACHE_VAR *sql_key_cache;
KEY_CACHE *sql_key_cache;
CHARSET_INFO *system_charset_info, *files_charset_info ;
CHARSET_INFO *national_charset_info, *table_alias_charset;
@ -1565,14 +1565,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\
the problem, but since we have already crashed, something is definitely wrong\n\
and this may fail.\n\n");
fprintf(stderr, "key_buffer_size=%lu\n",
(ulong) sql_key_cache->buff_size);
(ulong) sql_key_cache->key_cache_mem_size);
fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size);
fprintf(stderr, "max_used_connections=%ld\n", max_used_connections);
fprintf(stderr, "max_connections=%ld\n", max_connections);
fprintf(stderr, "threads_connected=%d\n", thread_count);
fprintf(stderr, "It is possible that mysqld could use up to \n\
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\
bytes of memory\n", ((ulong) sql_key_cache->buff_size +
bytes of memory\n", ((ulong) sql_key_cache->key_cache_mem_size +
(global_system_variables.read_buff_size +
global_system_variables.sortbuff_size) *
max_connections)/ 1024);
@ -2037,7 +2037,6 @@ bool init_global_datetime_format(timestamp_type format_type,
{
/* Get command line option */
const char *str= opt_date_time_formats[format_type];
DATE_TIME_FORMAT *format;
if (!str) // No specified format
{
@ -2068,6 +2067,8 @@ static int init_common_variables(const char *conf_file_name, int argc,
max_system_variables.pseudo_thread_id= (ulong)~0;
start_time=time((time_t*) 0);
if (init_thread_environment())
return 1;
mysql_init_variables();
#ifdef OS2
@ -2111,8 +2112,6 @@ static int init_common_variables(const char *conf_file_name, int argc,
load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv;
get_options(argc,argv);
if (init_thread_environment())
return 1;
if (opt_log || opt_update_log || opt_slow_log || opt_bin_log)
strcat(server_version,"-log");
DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname,
@ -2326,7 +2325,7 @@ Now disabling --log-slave-updates.");
/* call ha_init_key_cache() on all key caches to init them */
process_key_caches(&ha_init_key_cache);
/* We must set dflt_key_cache in case we are using ISAM tables */
dflt_keycache= &sql_key_cache->cache;
dflt_key_cache= sql_key_cache;
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
if (locked_in_memory && !geteuid())
@ -4316,26 +4315,26 @@ replicating a LOAD DATA INFILE command.",
IO_SIZE, 0},
{"key_buffer_size", OPT_KEY_BUFFER_SIZE,
"The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.",
(gptr*) &dflt_key_cache_var.buff_size,
(gptr*) &dflt_key_cache_var.param_buff_size,
(gptr*) 0,
0, (enum get_opt_var_type) (GET_ULL | GET_ASK_ADDR),
REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD,
IO_SIZE, 0},
{"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
"The default size of key cache blocks",
(gptr*) &dflt_key_cache_var.block_size,
(gptr*) &dflt_key_cache_var.param_block_size,
(gptr*) 0,
0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0},
{"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT,
"The minimum percentage of warm blocks in key cache",
(gptr*) &dflt_key_cache_var.division_limit,
(gptr*) &dflt_key_cache_var.param_division_limit,
(gptr*) 0,
0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
1, 100, 0, 1, 0},
{"key_cache_division_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
"This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache",
(gptr*) &dflt_key_cache_var.age_threshold,
(gptr*) &dflt_key_cache_var.param_age_threshold,
(gptr*) 0,
0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
300, 100, ~0L, 0, 100, 0},
@ -4757,17 +4756,17 @@ struct show_var_st status_vars[]= {
{"Handler_rollback", (char*) &ha_rollback_count, SHOW_LONG},
{"Handler_update", (char*) &ha_update_count, SHOW_LONG},
{"Handler_write", (char*) &ha_write_count, SHOW_LONG},
{"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.blocks_changed,
{"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed,
SHOW_KEY_CACHE_LONG},
{"Key_blocks_used", (char*) &dflt_key_cache_var.blocks_used,
{"Key_blocks_used", (char*) &dflt_key_cache_var.global_blocks_used,
SHOW_KEY_CACHE_LONG},
{"Key_read_requests", (char*) &dflt_key_cache_var.cache_r_requests,
{"Key_read_requests", (char*) &dflt_key_cache_var.global_cache_r_requests,
SHOW_KEY_CACHE_LONG},
{"Key_reads", (char*) &dflt_key_cache_var.cache_read,
{"Key_reads", (char*) &dflt_key_cache_var.global_cache_read,
SHOW_KEY_CACHE_LONG},
{"Key_write_requests", (char*) &dflt_key_cache_var.cache_w_requests,
{"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests,
SHOW_KEY_CACHE_LONG},
{"Key_writes", (char*) &dflt_key_cache_var.cache_write,
{"Key_writes", (char*) &dflt_key_cache_var.global_cache_write,
SHOW_KEY_CACHE_LONG},
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
{"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_CONST},
@ -5608,18 +5607,18 @@ mysql_getopt_value(const char *keyname, uint key_length,
case OPT_KEY_CACHE_DIVISION_LIMIT:
case OPT_KEY_CACHE_AGE_THRESHOLD:
{
KEY_CACHE_VAR *key_cache;
KEY_CACHE *key_cache;
if (!(key_cache= get_or_create_key_cache(keyname, key_length)))
exit(1);
switch (option->id) {
case OPT_KEY_BUFFER_SIZE:
return (gptr*) &key_cache->buff_size;
return (gptr*) &key_cache->param_buff_size;
case OPT_KEY_CACHE_BLOCK_SIZE:
return (gptr*) &key_cache->block_size;
return (gptr*) &key_cache->param_block_size;
case OPT_KEY_CACHE_DIVISION_LIMIT:
return (gptr*) &key_cache->division_limit;
return (gptr*) &key_cache->param_division_limit;
case OPT_KEY_CACHE_AGE_THRESHOLD:
return (gptr*) &key_cache->age_threshold;
return (gptr*) &key_cache->param_age_threshold;
}
}
}

View file

@ -83,7 +83,6 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
table_map removed_tables= 0, outer_tables= 0, used_tables= 0;
table_map where_tables= 0;
Item *item;
COND *org_conds= conds;
int error;
if (conds)

View file

@ -302,6 +302,8 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message)
pos=net_store_data((char*) pos, message, strlen(message));
VOID(my_net_write(net,buff,(uint) (pos-buff)));
VOID(net_flush(net));
/* We can't anymore send an error to the client */
thd->net.report_error= 0;
DBUG_VOID_RETURN;
}

View file

@ -30,7 +30,7 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flag)
{
List_iterator_fast<Item> it(*list);
Item *item;
MYSQL_FIELD *field, *client_field;
MYSQL_FIELD *client_field;
DBUG_ENTER("send_fields");
if (prepare_for_send(list))
@ -71,9 +71,9 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flag)
String tmp(buff, sizeof(buff), default_charset_info), *res;
if (!(res=item->val_str(&tmp)))
client_field->def= strdup_root(alloc, "");
client_field->def= (char*) "";
else
client_field->def= strdup_root(alloc, tmp.ptr());
client_field->def= strmake_root(alloc, res->ptr(), res->length());
}
else
client_field->def=0;

View file

@ -623,7 +623,6 @@ err:
int show_slave_hosts(THD* thd)
{
List<Item> field_list;
NET* net = &thd->net;
Protocol *protocol= thd->protocol;
DBUG_ENTER("show_slave_hosts");

View file

@ -92,7 +92,7 @@ static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
static void fix_max_binlog_size(THD *thd, enum_var_type type);
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
static void fix_max_connections(THD *thd, enum_var_type type);
static KEY_CACHE_VAR *create_key_cache(const char *name, uint length);
static KEY_CACHE *create_key_cache(const char *name, uint length);
void fix_sql_mode_var(THD *thd, enum_var_type type);
static byte *get_error_count(THD *thd);
static byte *get_warning_count(THD *thd);
@ -144,14 +144,14 @@ sys_var_thd_ulong sys_join_buffer_size("join_buffer_size",
&SV::join_buff_size);
sys_var_key_buffer_size sys_key_buffer_size("key_buffer_size");
sys_var_key_cache_long sys_key_cache_block_size("key_cache_block_size",
offsetof(KEY_CACHE_VAR,
block_size));
offsetof(KEY_CACHE,
param_block_size));
sys_var_key_cache_long sys_key_cache_division_limit("key_cache_division_limit",
offsetof(KEY_CACHE_VAR,
division_limit));
offsetof(KEY_CACHE,
param_division_limit));
sys_var_key_cache_long sys_key_cache_age_threshold("key_cache_age_threshold",
offsetof(KEY_CACHE_VAR,
age_threshold));
offsetof(KEY_CACHE,
param_age_threshold));
sys_var_bool_ptr sys_local_infile("local_infile",
&opt_local_infile);
sys_var_thd_bool sys_log_warnings("log_warnings", &SV::log_warnings);
@ -1778,15 +1778,14 @@ void sys_var_collation_server::set_default(THD *thd, enum_var_type type)
LEX_STRING default_key_cache_base= {(char *) "default", 7 };
static KEY_CACHE_VAR zero_key_cache=
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static KEY_CACHE zero_key_cache;
KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name)
KEY_CACHE *get_key_cache(LEX_STRING *cache_name)
{
safe_mutex_assert_owner(&LOCK_global_system_variables);
if (!cache_name || ! cache_name->length)
cache_name= &default_key_cache_base;
return ((KEY_CACHE_VAR*) find_named(&key_caches,
return ((KEY_CACHE*) find_named(&key_caches,
cache_name->str, cache_name->length, 0));
}
@ -1794,7 +1793,7 @@ KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name)
byte *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
KEY_CACHE_VAR *key_cache= get_key_cache(base);
KEY_CACHE *key_cache= get_key_cache(base);
if (!key_cache)
key_cache= &zero_key_cache;
return (byte*) key_cache + offset ;
@ -1805,7 +1804,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
LEX_STRING *base_name= &var->base;
KEY_CACHE_VAR *key_cache;
KEY_CACHE *key_cache;
bool error= 0;
/* If no basename, assume it's for the key cache named 'default' */
@ -1840,14 +1839,14 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
if (key_cache == sql_key_cache)
goto end; // Ignore default key cache
if (key_cache->cache) // If initied
if (key_cache->key_cache_inited) // If initied
{
/*
Move tables using this key cache to the default key cache
and clear the old key cache.
*/
NAMED_LIST *list;
key_cache= (KEY_CACHE_VAR *) find_named(&key_caches, base_name->str,
key_cache= (KEY_CACHE *) find_named(&key_caches, base_name->str,
base_name->length, &list);
key_cache->in_init= 1;
pthread_mutex_unlock(&LOCK_global_system_variables);
@ -1862,13 +1861,14 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
goto end;
}
key_cache->buff_size= (ulonglong) getopt_ull_limit_value(tmp, option_limits);
key_cache->param_buff_size=
(ulonglong) getopt_ull_limit_value(tmp, option_limits);
/* If key cache didn't existed initialize it, else resize it */
key_cache->in_init= 1;
pthread_mutex_unlock(&LOCK_global_system_variables);
if (!key_cache->cache)
if (!key_cache->key_cache_inited)
error= (bool) (ha_init_key_cache("", key_cache));
else
error= (bool)(ha_resize_key_cache(key_cache));
@ -1892,7 +1892,7 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var)
base_name= &default_key_cache_base;
pthread_mutex_lock(&LOCK_global_system_variables);
KEY_CACHE_VAR *key_cache= get_key_cache(base_name);
KEY_CACHE *key_cache= get_key_cache(base_name);
if (!key_cache && !(key_cache= create_key_cache(base_name->str,
base_name->length)))
@ -2413,7 +2413,6 @@ byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type,
ulong val;
char buff[256];
String tmp(buff, sizeof(buff), &my_charset_latin1);
my_bool found= 0;
tmp.length(0);
val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
@ -2543,13 +2542,13 @@ void delete_elements(I_List<NAMED_LIST> *list,
/* Key cache functions */
static KEY_CACHE_VAR *create_key_cache(const char *name, uint length)
static KEY_CACHE *create_key_cache(const char *name, uint length)
{
KEY_CACHE_VAR *key_cache;
KEY_CACHE *key_cache;
DBUG_ENTER("create_key_cache");
DBUG_PRINT("enter",("name: %.*s", length, name));
if ((key_cache= (KEY_CACHE_VAR*) my_malloc(sizeof(KEY_CACHE_VAR),
if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
MYF(MY_ZEROFILL | MY_WME))))
{
if (!new NAMED_LIST(&key_caches, name, length, (gptr) key_cache))
@ -2565,19 +2564,19 @@ static KEY_CACHE_VAR *create_key_cache(const char *name, uint length)
We don't set 'buff_size' as this is used to enable the key cache
*/
key_cache->block_size= dflt_key_cache_var.block_size;
key_cache->division_limit= dflt_key_cache_var.division_limit;
key_cache->age_threshold= dflt_key_cache_var.age_threshold;
key_cache->param_block_size= dflt_key_cache_var.param_block_size;
key_cache->param_division_limit= dflt_key_cache_var.param_division_limit;
key_cache->param_age_threshold= dflt_key_cache_var.param_age_threshold;
}
}
DBUG_RETURN(key_cache);
}
KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length)
KEY_CACHE *get_or_create_key_cache(const char *name, uint length)
{
LEX_STRING key_cache_name;
KEY_CACHE_VAR *key_cache;
KEY_CACHE *key_cache;
key_cache_name.str= (char *) name;
key_cache_name.length= length;
@ -2589,21 +2588,21 @@ KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length)
}
void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache)
void free_key_cache(const char *name, KEY_CACHE *key_cache)
{
ha_end_key_cache(key_cache);
my_free((char*) key_cache, MYF(0));
}
bool process_key_caches(int (* func) (const char *name, KEY_CACHE_VAR *))
bool process_key_caches(int (* func) (const char *name, KEY_CACHE *))
{
I_List_iterator<NAMED_LIST> it(key_caches);
NAMED_LIST *element;
while ((element= it++))
{
KEY_CACHE_VAR *key_cache= (KEY_CACHE_VAR *) element->data;
KEY_CACHE *key_cache= (KEY_CACHE *) element->data;
func(element->name, key_cache);
}
return 0;

View file

@ -560,7 +560,7 @@ class sys_var_key_buffer_size :public sys_var_key_cache_param
{
public:
sys_var_key_buffer_size(const char *name_arg)
:sys_var_key_cache_param(name_arg, offsetof(KEY_CACHE_VAR, buff_size))
:sys_var_key_cache_param(name_arg, offsetof(KEY_CACHE, param_buff_size))
{}
bool update(THD *thd, set_var *var);
SHOW_TYPE type() { return SHOW_LONGLONG; }
@ -755,7 +755,7 @@ public:
my_free((char*) name, MYF(0));
}
friend bool process_key_caches(int (* func) (const char *name,
KEY_CACHE_VAR *));
KEY_CACHE *));
friend void delete_elements(I_List<NAMED_LIST> *list,
void (*free_element)(const char*, gptr));
};
@ -788,9 +788,9 @@ gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
NAMED_LIST **found);
/* key_cache functions */
KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name);
KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length);
void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache);
bool process_key_caches(int (* func) (const char *name, KEY_CACHE_VAR *));
KEY_CACHE *get_key_cache(LEX_STRING *cache_name);
KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
void free_key_cache(const char *name, KEY_CACHE *key_cache);
bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
void delete_elements(I_List<NAMED_LIST> *list,
void (*free_element)(const char*, gptr));

View file

@ -632,8 +632,8 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh,
if (acl_user)
{
/* OK. User found and password checked continue validation */
Vio *vio=thd->net.vio;
#ifdef HAVE_OPENSSL
Vio *vio=thd->net.vio;
SSL *ssl= (SSL*) vio->ssl_arg;
#endif
@ -3457,7 +3457,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
{
uint counter;
int result;
ACL_USER *acl_user; ACL_DB *acl_db;
ACL_DB *acl_db;
TABLE_LIST tables[4];
DBUG_ENTER("mysql_revoke_all");
@ -3471,7 +3471,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
List_iterator <LEX_USER> user_list(list);
while ((lex_user=user_list++))
{
if (!(acl_user= check_acl_user(lex_user, &counter)))
if (!check_acl_user(lex_user, &counter))
{
sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' not exists",
lex_user->user.str,

View file

@ -35,7 +35,6 @@ HASH assign_cache;
static int open_unireg_entry(THD *thd,TABLE *entry,const char *db,
const char *name, const char *alias);
static void free_cache_entry(TABLE *entry);
static void free_assign_entry(KEY_CACHE_ASMT *key_cache_asmt);
static void mysql_rm_tmp_tables(void);

View file

@ -265,7 +265,6 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
char path[FN_REFLEN+16];
long result=1;
int error = 0;
uint create_options = create_info ? create_info->options : 0;
DBUG_ENTER("mysql_alter_db");
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));

View file

@ -253,7 +253,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
continue;
if (num_rows >= offset_limit)
{
String *packet = &thd->packet;
Item *item;
protocol->prepare_for_resend();
it.rewind();

View file

@ -1488,6 +1488,8 @@ void select_insert::send_error(uint errcode,const char *err)
bool select_insert::send_eof()
{
int error,error2;
DBUG_ENTER("select_insert::send_eof");
if (!(error=table->file->extra(HA_EXTRA_NO_CACHE)))
error=table->file->activate_all_index(thd);
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
@ -1521,20 +1523,18 @@ bool select_insert::send_eof()
table->file->print_error(error,MYF(0));
//TODO error should be sent at the query processing end
::send_error(thd);
return 1;
DBUG_RETURN(1);
}
char buff[160];
if (info.handle_duplicates == DUP_IGNORE)
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
else
{
char buff[160];
if (info.handle_duplicates == DUP_IGNORE)
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
else
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) info.deleted, (ulong) thd->cuted_fields);
::send_ok(thd,info.copied+info.deleted,last_insert_id,buff);
return 0;
}
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) info.deleted, (ulong) thd->cuted_fields);
::send_ok(thd,info.copied+info.deleted,last_insert_id,buff);
DBUG_RETURN(0);
}

View file

@ -432,7 +432,7 @@ int yylex(void *arg, void *yythd)
reg1 uchar c;
int tokval, result_state;
uint length;
enum my_lex_states state,prev_state;
enum my_lex_states state;
LEX *lex= &(((THD *)yythd)->lex);
YYSTYPE *yylval=(YYSTYPE*) arg;
CHARSET_INFO *cs= ((THD *) yythd)->charset();
@ -441,7 +441,7 @@ int yylex(void *arg, void *yythd)
lex->yylval=yylval; // The global state
lex->tok_start=lex->tok_end=lex->ptr;
prev_state=state=lex->next_state;
state=lex->next_state;
lex->next_state=MY_LEX_OPERATOR_OR_IDENT;
LINT_INIT(c);
for (;;)
@ -1175,7 +1175,7 @@ void st_select_lex_unit::exclude_level()
*/
void st_select_lex_unit::exclude_tree()
{
SELECT_LEX_UNIT *units= 0, **units_last= &units;
SELECT_LEX_UNIT *units= 0;
for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
{
// unlink current level from global SELECTs list

View file

@ -128,7 +128,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
USER_RESOURCES *mqh)
{
int return_val=0;
uint temp_len, user_len, host_len;
uint temp_len, user_len;
char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2];
struct user_conn *uc;
@ -136,7 +136,6 @@ static int get_or_create_user_conn(THD *thd, const char *user,
DBUG_ASSERT(host != 0);
user_len=strlen(user);
host_len=strlen(host);
temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;
(void) pthread_mutex_lock(&LOCK_user_conn);
if (!(uc = (struct user_conn *) hash_search(&hash_user_connections,

View file

@ -1059,7 +1059,7 @@ void mysql_stmt_free(THD *thd, char *packet)
PREP_STMT *stmt;
DBUG_ENTER("mysql_stmt_free");
if (!(stmt=find_prepared_statement(thd, stmt_id, "close")))
if (!find_prepared_statement(thd, stmt_id, "close"))
{
send_error(thd); // Not seen by the client
DBUG_VOID_RETURN;

View file

@ -1291,9 +1291,7 @@ int show_binlogs(THD* thd)
{
IO_CACHE *index_file;
char fname[FN_REFLEN];
NET* net = &thd->net;
List<Item> field_list;
String *packet = &thd->packet;
uint length;
Protocol *protocol= thd->protocol;
DBUG_ENTER("show_binlogs");

View file

@ -7228,7 +7228,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
entry->file->info(HA_STATUS_VARIABLE);
if (entry->db_type == DB_TYPE_HEAP ||
(!entry->blob_fields &&
((ALIGN_SIZE(reclength) +sizeof(HASH_LINK)) * entry->file->records <
((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->file->records <
thd->variables.sortbuff_size)))
error=remove_dup_with_hash_index(join->thd, entry,
field_count, first_field,
@ -7738,8 +7738,6 @@ find_order_in_list(THD *thd, Item **ref_pointer_array,
Item *itemptr=*order->item;
if (itemptr->type() == Item::INT_ITEM)
{ /* Order by position */
Item *item=0;
uint count= (uint) ((Item_int*)itemptr)->value;
if (!count || count > fields.elements)
{

View file

@ -702,7 +702,6 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
restore_record(table,default_values); // Get empty record
Field **ptr,*field;
String *packet= &thd->packet;
for (ptr=table->field; (field= *ptr) ; ptr++)
{
if (!wild || !wild[0] ||
@ -892,7 +891,6 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
if (protocol->send_fields(&field_list,1))
DBUG_RETURN(1);
String *packet= &thd->packet;
KEY *key_info=table->key_info;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME);
for (uint i=0 ; i < table->keys ; i++,key_info++)

View file

@ -1637,7 +1637,7 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
LEX_STRING *key_cache_name)
{
HA_CHECK_OPT check_opt;
KEY_CACHE_VAR *key_cache;
KEY_CACHE *key_cache;
DBUG_ENTER("mysql_assign_to_keycache");
check_opt.init();
@ -1682,14 +1682,14 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
0 ok
*/
int reassign_keycache_tables(THD *thd, KEY_CACHE_VAR *src_cache,
KEY_CACHE_VAR *dst_cache)
int reassign_keycache_tables(THD *thd, KEY_CACHE *src_cache,
KEY_CACHE *dst_cache)
{
DBUG_ENTER("reassign_keycache_tables");
DBUG_ASSERT(src_cache != dst_cache);
DBUG_ASSERT(src_cache->in_init);
src_cache->buff_size= 0; // Free key cache
src_cache->param_buff_size= 0; // Free key cache
ha_resize_key_cache(src_cache);
ha_change_key_cache(src_cache, dst_cache);
DBUG_RETURN(0);
@ -1955,7 +1955,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
ulonglong next_insert_id;
uint save_time_stamp,db_create_options, used_fields;
enum db_type old_db_type,new_db_type;
thr_lock_type lock_type;
DBUG_ENTER("mysql_alter_table");
thd->proc_info="init";
@ -2798,7 +2797,6 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
for (table= tables; table; table= table->next)
{
char table_name[NAME_LEN*2+2];
bool fatal_error= 0;
TABLE *t;
strxmov(table_name, table->db ,".", table->real_name, NullS);

View file

@ -303,9 +303,9 @@ end:
}
static int print_key_cache_status(const char *name, KEY_CACHE_VAR *key_cache)
static int print_key_cache_status(const char *name, KEY_CACHE *key_cache)
{
if (!key_cache->cache)
if (!key_cache->key_cache_inited)
{
printf("%s: Not in use\n", name);
}
@ -323,11 +323,11 @@ writes: %10lu\n\
r_requests: %10lu\n\
reads: %10lu\n\n",
name,
(ulong) key_cache->buff_size, key_cache->block_size,
key_cache->division_limit, key_cache->age_threshold,
key_cache->blocks_used,key_cache->blocks_changed,
key_cache->cache_w_requests,key_cache->cache_write,
key_cache->cache_r_requests,key_cache->cache_read);
(ulong) key_cache->param_buff_size, key_cache->param_block_size,
key_cache->param_division_limit, key_cache->param_age_threshold,
key_cache->global_blocks_used,key_cache->global_blocks_changed,
key_cache->global_cache_w_requests,key_cache->global_cache_write,
key_cache->global_cache_r_requests,key_cache->global_cache_read);
}
return 0;
}

View file

@ -112,7 +112,7 @@ uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match)
found_pos= pos;
}
}
return(found_count == 1 && part_match ? found_count : 0);
return(found_count == 1 && part_match ? found_pos : 0);
}

View file

@ -357,7 +357,6 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
const char *end=str+length;
const uchar *format_position;
bool found_delimitier= 0, found_space= 0;
DATE_TIME_FORMAT *format;
DBUG_ENTER("str_to_TIME");
DBUG_PRINT("ENTER",("str: %.*s",length,str));

View file

@ -82,7 +82,7 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error)
unsigned long i, j, k;
ulonglong li;
int negative;
long cutoff, cutoff2, cutoff3;
ulong cutoff, cutoff2, cutoff3;
s= nptr;
/* If fixed length string */