diff options
author | unknown <hf@deer.(none)> | 2003-11-26 13:39:18 +0400 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2003-11-26 13:39:18 +0400 |
commit | 7d784b20aee7b58adaa26817af897612fc331bd0 (patch) | |
tree | 8bc889a23db1d39670ffc9aa128b61a9c859a084 /include | |
parent | 6943b3236b516ee9cb1c66c42aa1f3c3ffbbcbef (diff) | |
parent | ceb0ce5002edf0824ce01f156cd8343a047e6b7a (diff) | |
download | mariadb-git-7d784b20aee7b58adaa26817af897612fc331bd0.tar.gz |
Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1
into deer.(none):/home/hf/work/mysql-4.1-w1284
sql/sql_acl.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 2 | ||||
-rw-r--r-- | include/hash.h | 11 | ||||
-rw-r--r-- | include/keycache.h | 135 | ||||
-rw-r--r-- | include/m_ctype.h | 8 | ||||
-rw-r--r-- | include/my_base.h | 1 | ||||
-rw-r--r-- | include/my_pthread.h | 4 | ||||
-rw-r--r-- | include/my_sys.h | 68 | ||||
-rw-r--r-- | include/myisam.h | 10 | ||||
-rw-r--r-- | include/mysql.h | 44 | ||||
-rw-r--r-- | include/mysql_com.h | 2 | ||||
-rw-r--r-- | include/sql_common.h | 2 | ||||
-rw-r--r-- | include/violite.h | 2 |
12 files changed, 185 insertions, 104 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 2ec06d71fbe..3adbb31f235 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -21,7 +21,7 @@ pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \ my_semaphore.h my_pthread.h my_no_pthread.h raid.h \ errmsg.h my_global.h my_net.h my_alloc.h \ my_getopt.h sslopt-longopts.h my_dir.h typelib.h \ - sslopt-vars.h sslopt-case.h sql_common.h \ + sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ sql_state.h $(BUILT_SOURCES) noinst_HEADERS = config-win.h config-os2.h config-netware.h \ nisam.h heap.h merge.h my_bitmap.h\ diff --git a/include/hash.h b/include/hash.h index 3c2ae32c70e..c7cc118b7bd 100644 --- a/include/hash.h +++ b/include/hash.h @@ -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; diff --git a/include/keycache.h b/include/keycache.h new file mode 100644 index 00000000000..b882f3127f5 --- /dev/null +++ b/include/keycache.h @@ -0,0 +1,135 @@ +/* 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; + my_bool resize_in_flush; /* true during flush of resize operation */ + my_bool can_be_used; /* usage of cache for read/write is allowed */ + 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 */ + ulong cnt_for_resize_op; /* counter to block resize operation */ + 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 resize_queue; /* threads waiting during resize operation */ + 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 */ +} 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 */ diff --git a/include/m_ctype.h b/include/m_ctype.h index e2b2f7f1668..0228b359111 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -335,6 +335,14 @@ uint my_instr_mb(struct charset_info_st *, extern my_bool my_parse_charset_xml(const char *bug, uint len, int (*add)(CHARSET_INFO *cs)); +#undef _U +#undef _L +#undef _NMR +#undef _SPC +#undef _PNT +#undef _CTR +#undef _B +#undef _X #define _U 01 /* Upper case */ #define _L 02 /* Lower case */ diff --git a/include/my_base.h b/include/my_base.h index 1bd0f47afa4..25521d7b13d 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -46,7 +46,6 @@ #define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */ #define HA_OPEN_ABORT_IF_CRASHED 16 #define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */ -#define HA_OPEN_TO_ASSIGN 64 /* Open for key cache assignment */ /* The following is parameter to ha_rkey() how to use key */ diff --git a/include/my_pthread.h b/include/my_pthread.h index a4ea88b20f0..44e6edcddec 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -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 */ diff --git a/include/my_sys.h b/include/my_sys.h index d1c7b658665..59d5767d204 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -265,8 +265,7 @@ enum cache_type enum flush_type { - FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE, - FLUSH_REMOVE + FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE }; typedef struct st_record_cache /* Used when cacheing records */ @@ -505,44 +504,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 +643,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); diff --git a/include/myisam.h b/include/myisam.h index 52f2948aaef..2285f996464 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -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 */ @@ -315,6 +318,7 @@ typedef struct st_mi_check_param ulonglong auto_increment_value; ulonglong max_data_file_length; ulonglong keys_in_use; + ulonglong max_record_length; my_off_t search_after_block; my_off_t new_file_pos,key_file_blocks; my_off_t keydata,totaldata,key_blocks,start_check_pos; @@ -408,9 +412,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 diff --git a/include/mysql.h b/include/mysql.h index 7df42460c6d..23d89fd531f 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -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; diff --git a/include/mysql_com.h b/include/mysql_com.h index 3031b883e98..39e9c48146d 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -118,7 +118,7 @@ enum enum_server_command #define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ #define CLIENT_MULTI_STATEMENTS 65536 /* Enable/disable multi-stmt support */ #define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */ -#define CLIENT_REMEMBER_OPTIONS (1L << 31) +#define CLIENT_REMEMBER_OPTIONS ((ulong) (1L << 31)) #define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ diff --git a/include/sql_common.h b/include/sql_common.h index 1f442339c4f..1c374030a55 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -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); diff --git a/include/violite.h b/include/violite.h index 37c5abbbe67..e8f30288d34 100644 --- a/include/violite.h +++ b/include/violite.h @@ -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); |