From d2b8d744d9f9ab32478416885d7929ad00d3b276 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 11 Apr 2006 16:45:10 +0300 Subject: Added storage/maria (based on MyISAM). WL#3245 Moved things into ft_global.h, my_handler.h and myisamchk.h to allow MyISAM and Maria to share code and defines Rename of not properly renamed functions in MyISAM and my_handler.c Renamed some MI_ defines to HA_ to allow MyISAM and Maria to share Added maria variables to mysqld.cc and set_var.cc Fixed compiler warnings BitKeeper/etc/ignore: added storage/maria/*.MAI BUILD/SETUP.sh: Compile maria by default BitKeeper/triggers/post-commit: No public maria emails. Mark changesets emails with 'maria' configure.in: Add maria include/ft_global.h: Move defines needed by maria and MyISAM here include/keycache.h: Add support for default key_cache if cache not found include/my_base.h: Add invalidator_by_filename include/my_handler.h: Remove duplicate header files Add defines that are typical for handlers (MyISAM and Maria) include/myisam.h: Move things to my_handler.h to allow Maria and MyISAM to share things (Some things needed to be shared to allow sharing of HA_CHECK structure) libmysqld/Makefile.am: Added ha_maria.cc mysys/mf_keycaches.c: Added default value for multi_key_cache_search mysys/my_handler.c: mi_compare_text -> ha_compare_text Removed compiler warnings sql/ha_myisam.cc: MI_CHECK -> HA_CHECK MI_MAX_KEY_LENGTH -> HA_MAX_KEY_LENGTH sql/ha_myisam.h: MI_CHECK -> HA_CHECK MI_MAX_KEY_LENGTH -> HA_MAX_KEY_LENGTH sql/ha_myisammrg.h: MI_CHECK -> HA_CHECK MI_MAX_KEY_LENGTH -> HA_MAX_KEY_LENGTH sql/handler.h: Added MARIA Added inclusion of my_handler.h sql/item_func.h: Remove duplicate include sql/mysql_priv.h: Added maria variables sql/mysqld.cc: Added maria sql/set_var.cc: Added maria status variables sql/set_var.h: Added maria sql/sql_class.h: Added maria status variables sql/sql_sort.h: Remove duplicate BUFFPEK struct storage/Makefile.am: Added maria storage/csv/ha_tina.cc: Removed compiler warning storage/myisam/Makefile.am: Added ft_myisam.c storage/myisam/ft_boolean_search.c: mi_compare_text -> ha_compare_text MI_MAX_KEY_BUFF -> HA_MAX_KEY_BUFF Remove compiler warnings storage/myisam/ft_nlq_search.c: mi_compare_text -> ha_compare_text storage/myisam/ft_parser.c: mi_compare_text -> ha_compare_text storage/myisam/ft_static.c: Move ft_init_search() to ft_myisam.c to make ft_static.c independent of MyISAM storage/myisam/ft_stopwords.c: mi_compare_text -> ha_compare_text storage/myisam/ft_update.c: mi_compare_text -> ha_compare_text storage/myisam/fulltext.h: Move things to ft_global.h to allow to share more things between MyISAM and Maria storage/myisam/mi_check.c: MI_CHECK -> HA_CHECK storage/myisam/mi_create.c: MI_MAX_POSSIBLE_KEY -> HA_MAX_POSSIBLE_KEY MI_MAX_KEY_BLOCK_SIZE -> HA_MAX_KEY_BLOCK_SIZE MI_MAX_KEY_SEG -> HA_MAX_KEY_SEG MI_MAX_KEY_BUFF -> HA_MAX_KEY_BUFF storage/myisam/mi_delete.c: MI_MAX_KEY_BUFF -> HA_MAX_KEY_BUFF storage/myisam/mi_delete_all.c: Remove not used variable storage/myisam/mi_dynrec.c: _my_calc_total_blob_length -> _mi_calc_total_blob_length storage/myisam/mi_key.c: _my_store_blob_length -> _mi_store_blob_length storage/myisam/mi_log.c: _my_calc_total_blob_length -> _mi_calc_total_blob_length storage/myisam/mi_open.c: MI_MAX_POSSIBLE_KEY -> HA_MAX_POSSIBLE_KEY MI_MAX_KEY_SEG -> HA_MAX_KEY_SEG MI_MAX_KEY_BUFF -> HA_MAX_KEY_BUFF my_n_base_info_read -> mi_n_base_info_read storage/myisam/mi_packrec.c: Made read_pack_length static _my_store_blob_length -> _mi_store_blob_length Remove not used variable storage/myisam/mi_range.c: MI_MAX_KEY_BUFF -> HA_MAX_KEY_BUFF storage/myisam/mi_search.c: MI_MAX_KEY_BUFF -> HA_MAX_KEY_BUFF storage/myisam/mi_test1.c: MI_MAX_KEY_LENGTH -> HA_MAX_KEY_LENGTH storage/myisam/mi_test2.c: Fixed compiler warning storage/myisam/mi_unique.c: Fixed compiler warning mi_compare_text -> ha_compare_text storage/myisam/mi_update.c: MI_MAX_KEY_BUFF -> HA_MAX_KEY_BUFF storage/myisam/mi_write.c: Rename of defines and functions storage/myisam/myisamchk.c: Rename of defines and functions storage/myisam/myisamdef.h: Remove tabs Indentation fixes (Large changes as I did run indent-ex on the file) Move some things to myisamchk.h Added missing functions that gave compiler warnings storage/myisam/myisamlog.c: Rename of defines and functions storage/myisam/myisampack.c: Remove compiler warning storage/myisam/rt_index.c: Rename of defines and functions storage/myisam/sort.c: Rename of defines, functions and structures config/ac-macros/ha_maria.m4: New BitKeeper file ``config/ac-macros/ha_maria.m4'' include/maria.h: New BitKeeper file ``include/maria.h'' include/myisamchk.h: New BitKeeper file ``include/myisamchk.h'' libmysqld/ha_maria.cc: New BitKeeper file ``libmysqld/ha_maria.cc'' mysql-test/include/have_maria.inc: New BitKeeper file ``mysql-test/include/have_maria.inc'' mysql-test/r/have_maria.require: New BitKeeper file ``mysql-test/r/have_maria.require'' mysql-test/r/maria.result: New BitKeeper file ``mysql-test/r/maria.result'' mysql-test/r/ps_maria.result: New BitKeeper file ``mysql-test/r/ps_maria.result'' mysql-test/t/maria.test: New BitKeeper file ``mysql-test/t/maria.test'' mysql-test/t/ps_maria.test: New BitKeeper file ``mysql-test/t/ps_maria.test'' sql/ha_maria.cc: New BitKeeper file ``sql/ha_maria.cc'' sql/ha_maria.h: New BitKeeper file ``sql/ha_maria.h'' storage/maria/Makefile.am: New BitKeeper file ``storage/maria/Makefile.am'' storage/maria/cmakelists.txt: New BitKeeper file ``storage/maria/cmakelists.txt'' storage/maria/ft_maria.c: New BitKeeper file ``storage/maria/ft_maria.c'' storage/maria/ma_cache.c: New BitKeeper file ``storage/maria/ma_cache.c'' storage/maria/ma_changed.c: New BitKeeper file ``storage/maria/ma_changed.c'' storage/maria/ma_check.c: New BitKeeper file ``storage/maria/ma_check.c'' storage/maria/ma_checksum.c: New BitKeeper file ``storage/maria/ma_checksum.c'' storage/maria/ma_close.c: New BitKeeper file ``storage/maria/ma_close.c'' storage/maria/ma_create.c: New BitKeeper file ``storage/maria/ma_create.c'' storage/maria/ma_dbug.c: New BitKeeper file ``storage/maria/ma_dbug.c'' storage/maria/ma_delete.c: New BitKeeper file ``storage/maria/ma_delete.c'' storage/maria/ma_delete_all.c: New BitKeeper file ``storage/maria/ma_delete_all.c'' storage/maria/ma_delete_table.c: New BitKeeper file ``storage/maria/ma_delete_table.c'' storage/maria/ma_dynrec.c: New BitKeeper file ``storage/maria/ma_dynrec.c'' storage/maria/ma_extra.c: New BitKeeper file ``storage/maria/ma_extra.c'' storage/maria/ma_ft_boolean_search.c: New BitKeeper file ``storage/maria/ma_ft_boolean_search.c'' storage/maria/ma_ft_eval.c: New BitKeeper file ``storage/maria/ma_ft_eval.c'' storage/maria/ma_ft_eval.h: New BitKeeper file ``storage/maria/ma_ft_eval.h'' storage/maria/ma_ft_nlq_search.c: New BitKeeper file ``storage/maria/ma_ft_nlq_search.c'' storage/maria/ma_ft_parser.c: New BitKeeper file ``storage/maria/ma_ft_parser.c'' storage/maria/ma_ft_stem.c: New BitKeeper file ``storage/maria/ma_ft_stem.c'' storage/maria/ma_ft_test1.c: New BitKeeper file ``storage/maria/ma_ft_test1.c'' storage/maria/ma_ft_test1.h: New BitKeeper file ``storage/maria/ma_ft_test1.h'' storage/maria/ma_ft_update.c: New BitKeeper file ``storage/maria/ma_ft_update.c'' storage/maria/ma_ftdefs.h: New BitKeeper file ``storage/maria/ma_ftdefs.h'' storage/maria/ma_fulltext.h: New BitKeeper file ``storage/maria/ma_fulltext.h'' storage/maria/ma_info.c: New BitKeeper file ``storage/maria/ma_info.c'' storage/maria/ma_init.c: New BitKeeper file ``storage/maria/ma_init.c'' storage/maria/ma_key.c: New BitKeeper file ``storage/maria/ma_key.c'' storage/maria/ma_keycache.c: New BitKeeper file ``storage/maria/ma_keycache.c'' storage/maria/ma_locking.c: New BitKeeper file ``storage/maria/ma_locking.c'' storage/maria/ma_log.c: New BitKeeper file ``storage/maria/ma_log.c'' storage/maria/ma_open.c: New BitKeeper file ``storage/maria/ma_open.c'' storage/maria/ma_packrec.c: New BitKeeper file ``storage/maria/ma_packrec.c'' storage/maria/ma_page.c: New BitKeeper file ``storage/maria/ma_page.c'' storage/maria/ma_panic.c: New BitKeeper file ``storage/maria/ma_panic.c'' storage/maria/ma_preload.c: New BitKeeper file ``storage/maria/ma_preload.c'' storage/maria/ma_range.c: New BitKeeper file ``storage/maria/ma_range.c'' storage/maria/ma_rename.c: New BitKeeper file ``storage/maria/ma_rename.c'' storage/maria/ma_rfirst.c: New BitKeeper file ``storage/maria/ma_rfirst.c'' storage/maria/ma_rkey.c: New BitKeeper file ``storage/maria/ma_rkey.c'' storage/maria/ma_rlast.c: New BitKeeper file ``storage/maria/ma_rlast.c'' storage/maria/ma_rnext.c: New BitKeeper file ``storage/maria/ma_rnext.c'' storage/maria/ma_rnext_same.c: New BitKeeper file ``storage/maria/ma_rnext_same.c'' storage/maria/ma_rprev.c: New BitKeeper file ``storage/maria/ma_rprev.c'' storage/maria/ma_rrnd.c: New BitKeeper file ``storage/maria/ma_rrnd.c'' storage/maria/ma_rsame.c: New BitKeeper file ``storage/maria/ma_rsame.c'' storage/maria/ma_rsamepos.c: New BitKeeper file ``storage/maria/ma_rsamepos.c'' storage/maria/ma_rt_index.c: New BitKeeper file ``storage/maria/ma_rt_index.c'' storage/maria/ma_rt_index.h: New BitKeeper file ``storage/maria/ma_rt_index.h'' storage/maria/ma_rt_key.c: New BitKeeper file ``storage/maria/ma_rt_key.c'' storage/maria/ma_rt_key.h: New BitKeeper file ``storage/maria/ma_rt_key.h'' storage/maria/ma_rt_mbr.c: New BitKeeper file ``storage/maria/ma_rt_mbr.c'' storage/maria/ma_rt_mbr.h: New BitKeeper file ``storage/maria/ma_rt_mbr.h'' storage/maria/ma_rt_split.c: New BitKeeper file ``storage/maria/ma_rt_split.c'' storage/maria/ma_rt_test.c: New BitKeeper file ``storage/maria/ma_rt_test.c'' storage/maria/ma_scan.c: New BitKeeper file ``storage/maria/ma_scan.c'' storage/maria/ma_search.c: New BitKeeper file ``storage/maria/ma_search.c'' storage/maria/ma_sort.c: New BitKeeper file ``storage/maria/ma_sort.c'' storage/maria/ma_sp_defs.h: New BitKeeper file ``storage/maria/ma_sp_defs.h'' storage/maria/ma_sp_key.c: New BitKeeper file ``storage/maria/ma_sp_key.c'' storage/maria/ma_sp_test.c: New BitKeeper file ``storage/maria/ma_sp_test.c'' storage/maria/ma_static.c: New BitKeeper file ``storage/maria/ma_static.c'' storage/maria/ma_statrec.c: New BitKeeper file ``storage/maria/ma_statrec.c'' storage/maria/ma_test1.c: New BitKeeper file ``storage/maria/ma_test1.c'' storage/maria/ma_test2.c: New BitKeeper file ``storage/maria/ma_test2.c'' storage/maria/ma_test3.c: New BitKeeper file ``storage/maria/ma_test3.c'' storage/maria/ma_test_all.sh: New BitKeeper file ``storage/maria/ma_test_all.sh'' storage/maria/ma_unique.c: New BitKeeper file ``storage/maria/ma_unique.c'' storage/maria/ma_update.c: New BitKeeper file ``storage/maria/ma_update.c'' storage/maria/ma_write.c: New BitKeeper file ``storage/maria/ma_write.c'' storage/maria/maria_chk.c: New BitKeeper file ``storage/maria/maria_chk.c'' storage/maria/maria_def.h: New BitKeeper file ``storage/maria/maria_def.h'' storage/maria/maria_ftdump.c: New BitKeeper file ``storage/maria/maria_ftdump.c'' storage/maria/maria_log.c: New BitKeeper file ``storage/maria/maria_log.c'' storage/maria/maria_pack.c: New BitKeeper file ``storage/maria/maria_pack.c'' storage/maria/maria_rename.sh: New BitKeeper file ``storage/maria/maria_rename.sh'' storage/maria/test_pack: New BitKeeper file ``storage/maria/test_pack'' storage/myisam/ft_myisam.c: New BitKeeper file ``storage/myisam/ft_myisam.c'' --- include/ft_global.h | 11 ++ include/keycache.h | 3 +- include/maria.h | 418 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/my_base.h | 4 +- include/my_handler.h | 27 +++- include/myisam.h | 258 ++++++++++--------------------- include/myisamchk.h | 160 ++++++++++++++++++++ 7 files changed, 696 insertions(+), 185 deletions(-) create mode 100644 include/maria.h create mode 100644 include/myisamchk.h (limited to 'include') diff --git a/include/ft_global.h b/include/ft_global.h index 8f02e48f61d..494e89af8aa 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -66,6 +66,17 @@ void ft_free_stopwords(void); FT_INFO *ft_init_search(uint,void *, uint, byte *, uint,CHARSET_INFO *, byte *); my_bool ft_boolean_check_syntax_string(const byte *); +/* Internal symbols for fulltext between maria and MyISAM */ + +#define HA_FT_WTYPE HA_KEYTYPE_FLOAT +#define HA_FT_WLEN 4 +#define FT_SEGS 2 + +#define ft_sintXkorr(A) mi_sint4korr(A) +#define ft_intXstore(T,A) mi_int4store(T,A) + +extern const HA_KEYSEG ft_keysegs[FT_SEGS]; + #ifdef __cplusplus } #endif diff --git a/include/keycache.h b/include/keycache.h index 9fe1cce5da5..ba5ef1c3560 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -128,7 +128,8 @@ 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 KEY_CACHE *multi_key_cache_search(byte *key, uint length, + KEY_CACHE *def); 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, diff --git a/include/maria.h b/include/maria.h new file mode 100644 index 00000000000..c7586143fe7 --- /dev/null +++ b/include/maria.h @@ -0,0 +1,418 @@ +/* Copyright (C) 2006 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 */ + +/* This file should be included when using maria_funktions */ + +#ifndef _maria_h +#define _maria_h +#ifdef __cplusplus +extern "C" { +#endif +#ifndef _my_base_h +#include +#endif +#ifndef _m_ctype_h +#include +#endif +#ifndef _keycache_h +#include "keycache.h" +#endif +#include "my_handler.h" +#include "ft_global.h" +#include +#include + +/* + Limit max keys according to HA_MAX_POSSIBLE_KEY; See myisamchk.h for details +*/ + +#if MAX_INDEXES > HA_MAX_POSSIBLE_KEY +#define MARIA_MAX_KEY HA_MAX_POSSIBLE_KEY /* Max allowed keys */ +#else +#define MARIA_MAX_KEY MAX_INDEXES /* Max allowed keys */ +#endif + +#define MARIA_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */ +#define MARIA_NAME_IEXT ".MAI" +#define MARIA_NAME_DEXT ".MAD" +/* Max extra space to use when sorting keys */ +#define MARIA_MAX_TEMP_LENGTH 2*1024L*1024L*1024L +/* Possible values for maria_block_size (must be power of 2) */ +#define MARIA_KEY_BLOCK_LENGTH 8192 /* default key block length */ +#define MARIA_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */ +#define MARIA_MAX_KEY_BLOCK_LENGTH 32768 +#define maria_portable_sizeof_char_ptr 8 + +/* + In the following macros '_keyno_' is 0 .. keys-1. + If there can be more keys than bits in the key_map, the highest bit + is for all upper keys. They cannot be switched individually. + This means that clearing of high keys is ignored, setting one high key + sets all high keys. +*/ +#define MARIA_KEYMAP_BITS (8 * SIZEOF_LONG_LONG) +#define MARIA_KEYMAP_HIGH_MASK (ULL(1) << (MARIA_KEYMAP_BITS - 1)) +#define maria_get_mask_all_keys_active(_keys_) \ + (((_keys_) < MARIA_KEYMAP_BITS) ? \ + ((ULL(1) << (_keys_)) - ULL(1)) : \ + (~ ULL(0))) +#if MARIA_MAX_KEY > MARIA_KEYMAP_BITS +#define maria_is_key_active(_keymap_,_keyno_) \ + (((_keyno_) < MARIA_KEYMAP_BITS) ? \ + test((_keymap_) & (ULL(1) << (_keyno_))) : \ + test((_keymap_) & MARIA_KEYMAP_HIGH_MASK)) +#define maria_set_key_active(_keymap_,_keyno_) \ + (_keymap_)|= (((_keyno_) < MARIA_KEYMAP_BITS) ? \ + (ULL(1) << (_keyno_)) : \ + MARIA_KEYMAP_HIGH_MASK) +#define maria_clear_key_active(_keymap_,_keyno_) \ + (_keymap_)&= (((_keyno_) < MARIA_KEYMAP_BITS) ? \ + (~ (ULL(1) << (_keyno_))) : \ + (~ (ULL(0))) /*ignore*/ ) +#else +#define maria_is_key_active(_keymap_,_keyno_) \ + test((_keymap_) & (ULL(1) << (_keyno_))) +#define maria_set_key_active(_keymap_,_keyno_) \ + (_keymap_)|= (ULL(1) << (_keyno_)) +#define maria_clear_key_active(_keymap_,_keyno_) \ + (_keymap_)&= (~ (ULL(1) << (_keyno_))) +#endif +#define maria_is_any_key_active(_keymap_) \ + test((_keymap_)) +#define maria_is_all_keys_active(_keymap_,_keys_) \ + ((_keymap_) == maria_get_mask_all_keys_active(_keys_)) +#define maria_set_all_keys_active(_keymap_,_keys_) \ + (_keymap_)= maria_get_mask_all_keys_active(_keys_) +#define maria_clear_all_keys_active(_keymap_) \ + (_keymap_)= 0 +#define maria_intersect_keys_active(_to_,_from_) \ + (_to_)&= (_from_) +#define maria_is_any_intersect_keys_active(_keymap1_,_keys_,_keymap2_) \ + ((_keymap1_) & (_keymap2_) & \ + maria_get_mask_all_keys_active(_keys_)) +#define maria_copy_keys_active(_to_,_maxkeys_,_from_) \ + (_to_)= (maria_get_mask_all_keys_active(_maxkeys_) & \ + (_from_)) + + /* Param to/from maria_info */ + +typedef struct st_maria_isaminfo /* Struct from h_info */ +{ + ha_rows records; /* Records in database */ + ha_rows deleted; /* Deleted records in database */ + my_off_t recpos; /* Pos for last used record */ + my_off_t newrecpos; /* Pos if we write new record */ + my_off_t dupp_key_pos; /* Position to record with dup key */ + my_off_t data_file_length; /* Length of data file */ + my_off_t max_data_file_length, index_file_length; + my_off_t max_index_file_length, delete_length; + ulong reclength; /* Recordlength */ + ulong mean_reclength; /* Mean recordlength (if packed) */ + ulonglong auto_increment; + ulonglong key_map; /* Which keys are used */ + char *data_file_name, *index_file_name; + uint keys; /* Number of keys in use */ + uint options; /* HA_OPTION_... used */ + int errkey, /* With key was dupplicated on err */ + sortkey; /* clustered by this key */ + File filenr; /* (uniq) filenr for datafile */ + time_t create_time; /* When table was created */ + time_t check_time; + time_t update_time; + uint reflength; + ulong record_offset; + ulong *rec_per_key; /* for sql optimizing */ +} MARIA_INFO; + + +typedef struct st_maria_create_info +{ + const char *index_file_name, *data_file_name; /* If using symlinks */ + ha_rows max_rows; + ha_rows reloc_rows; + ulonglong auto_increment; + ulonglong data_file_length; + ulonglong key_file_length; + uint old_options; + uint8 language; + my_bool with_auto_increment; +} MARIA_CREATE_INFO; + +struct st_maria_info; /* For referense */ +struct st_maria_share; +typedef struct st_maria_info MARIA_HA; +struct st_maria_s_param; + +typedef struct st_maria_keydef /* Key definition with open & info */ +{ + struct st_maria_share *share; /* Pointer to base (set in open) */ + uint16 keysegs; /* Number of key-segment */ + uint16 flag; /* NOSAME, PACK_USED */ + + uint8 key_alg; /* BTREE, RTREE */ + uint16 block_length; /* Length of keyblock (auto) */ + uint16 underflow_block_length; /* When to execute underflow */ + uint16 keylength; /* Tot length of keyparts (auto) */ + uint16 minlength; /* min length of (packed) key (auto) */ + uint16 maxlength; /* max length of (packed) key (auto) */ + uint16 block_size; /* block_size (auto) */ + uint32 version; /* For concurrent read/write */ + uint32 ftparser_nr; /* distinct ftparser number */ + + HA_KEYSEG *seg, *end; + struct st_mysql_ftparser *parser; /* Fulltext [pre]parser */ + int(*bin_search) (struct st_maria_info *info, + struct st_maria_keydef *keyinfo, uchar *page, uchar *key, + uint key_len, uint comp_flag, uchar **ret_pos, + uchar *buff, my_bool *was_last_key); + uint(*get_key) (struct st_maria_keydef *keyinfo, uint nod_flag, + uchar **page, uchar *key); + int(*pack_key) (struct st_maria_keydef *keyinfo, uint nod_flag, + uchar *next_key, uchar *org_key, uchar *prev_key, + uchar *key, struct st_maria_s_param *s_temp); + void(*store_key) (struct st_maria_keydef *keyinfo, uchar *key_pos, + struct st_maria_s_param *s_temp); + int(*ck_insert) (struct st_maria_info *inf, uint k_nr, uchar *k, uint klen); + int(*ck_delete) (struct st_maria_info *inf, uint k_nr, uchar *k, uint klen); +} MARIA_KEYDEF; + + +#define MARIA_UNIQUE_HASH_LENGTH 4 + +typedef struct st_maria_unique_def /* Segment definition of unique */ +{ + uint16 keysegs; /* Number of key-segment */ + uchar key; /* Mapped to which key */ + uint8 null_are_equal; + HA_KEYSEG *seg, *end; +} MARIA_UNIQUEDEF; + +typedef struct st_maria_decode_tree /* Decode huff-table */ +{ + uint16 *table; + uint quick_table_bits; + byte *intervalls; +} MARIA_DECODE_TREE; + + +struct st_maria_bit_buff; + +/* + Note that null markers should always be first in a row ! + When creating a column, one should only specify: + type, length, null_bit and null_pos +*/ + +typedef struct st_maria_columndef /* column information */ +{ + int16 type; /* en_fieldtype */ + uint16 length; /* length of field */ + uint32 offset; /* Offset to position in row */ + uint8 null_bit; /* If column may be 0 */ + uint16 null_pos; /* position for null marker */ + +#ifndef NOT_PACKED_DATABASES + void(*unpack) (struct st_maria_columndef *rec, + struct st_maria_bit_buff *buff, + uchar *start, uchar *end); + enum en_fieldtype base_type; + uint space_length_bits, pack_type; + MARIA_DECODE_TREE *huff_tree; +#endif +} MARIA_COLUMNDEF; + + +extern my_string maria_log_filename; /* Name of logfile */ +extern ulong maria_block_size; +extern ulong maria_concurrent_insert; +extern my_bool maria_flush, maria_delay_key_write, maria_single_user; +extern my_off_t maria_max_temp_length; +extern ulong maria_bulk_insert_tree_size, maria_data_pointer_size; +extern KEY_CACHE maria_key_cache_var, *maria_key_cache; + + + /* Prototypes for maria-functions */ + +extern int maria_init(void); +extern void maria_end(void); +extern int maria_close(struct st_maria_info *file); +extern int maria_delete(struct st_maria_info *file, const byte *buff); +extern struct st_maria_info *maria_open(const char *name, int mode, + uint wait_if_locked); +extern int maria_panic(enum ha_panic_function function); +extern int maria_rfirst(struct st_maria_info *file, byte *buf, int inx); +extern int maria_rkey(struct st_maria_info *file, byte *buf, int inx, + const byte *key, + uint key_len, enum ha_rkey_function search_flag); +extern int maria_rlast(struct st_maria_info *file, byte *buf, int inx); +extern int maria_rnext(struct st_maria_info *file, byte *buf, int inx); +extern int maria_rnext_same(struct st_maria_info *info, byte *buf); +extern int maria_rprev(struct st_maria_info *file, byte *buf, int inx); +extern int maria_rrnd(struct st_maria_info *file, byte *buf, my_off_t pos); +extern int maria_scan_init(struct st_maria_info *file); +extern int maria_scan(struct st_maria_info *file, byte *buf); +extern int maria_rsame(struct st_maria_info *file, byte *record, int inx); +extern int maria_rsame_with_pos(struct st_maria_info *file, byte *record, + int inx, my_off_t pos); +extern int maria_update(struct st_maria_info *file, const byte *old, + byte *new_record); +extern int maria_write(struct st_maria_info *file, byte *buff); +extern my_off_t maria_position(struct st_maria_info *file); +extern int maria_status(struct st_maria_info *info, MARIA_INFO *x, uint flag); +extern int maria_lock_database(struct st_maria_info *file, int lock_type); +extern int maria_create(const char *name, uint keys, MARIA_KEYDEF *keydef, + uint columns, MARIA_COLUMNDEF *columndef, + uint uniques, MARIA_UNIQUEDEF *uniquedef, + MARIA_CREATE_INFO *create_info, uint flags); +extern int maria_delete_table(const char *name); +extern int maria_rename(const char *from, const char *to); +extern int maria_extra(struct st_maria_info *file, + enum ha_extra_function function, void *extra_arg); +extern ha_rows maria_records_in_range(struct st_maria_info *info, int inx, + key_range *min_key, key_range *max_key); +extern int maria_logging(int activate_log); +extern int maria_is_changed(struct st_maria_info *info); +extern int maria_delete_all_rows(struct st_maria_info *info); +extern uint maria_get_pointer_length(ulonglong file_length, uint def); + + +/* this is used to pass to mysql_mariachk_table */ + +#define MARIA_CHK_REPAIR 1 /* equivalent to mariachk -r */ +#define MARIA_CHK_VERIFY 2 /* Verify, run repair if failure */ + +typedef struct st_maria_sort_info +{ +#ifdef THREAD + /* sync things */ + pthread_mutex_t mutex; + pthread_cond_t cond; +#endif + MARIA_HA *info; + HA_CHECK *param; + char *buff; + SORT_KEY_BLOCKS *key_block, *key_block_end; + SORT_FT_BUF *ft_buf; + + my_off_t filelength, dupp, buff_length; + ha_rows max_records; + uint current_key, total_keys; + uint got_error, threads_running; + myf myf_rw; + enum data_file_type new_data_file_type; +} MARIA_SORT_INFO; + + +typedef struct st_maria_sort_param +{ + pthread_t thr; + IO_CACHE read_cache, tempfile, tempfile_for_exceptions; + DYNAMIC_ARRAY buffpek; + + MARIA_KEYDEF *keyinfo; + MARIA_SORT_INFO *sort_info; + HA_KEYSEG *seg; + uchar **sort_keys; + byte *rec_buff; + void *wordlist, *wordptr; + char *record; + MY_TMPDIR *tmpdir; + + /* + The next two are used to collect statistics, see maria_update_key_parts for + description. + */ + ulonglong unique[HA_MAX_KEY_SEG+1]; + ulonglong notnull[HA_MAX_KEY_SEG+1]; + + my_off_t pos,max_pos,filepos,start_recpos; + uint key, key_length,real_key_length,sortbuff_size; + uint maxbuffers, keys, find_length, sort_keys_length; + my_bool fix_datafile, master; + + int (*key_cmp)(struct st_maria_sort_param *, const void *, const void *); + int (*key_read)(struct st_maria_sort_param *,void *); + int (*key_write)(struct st_maria_sort_param *, const void *); + void (*lock_in_memory)(HA_CHECK *); + NEAR int (*write_keys)(struct st_maria_sort_param *, register uchar **, + uint , struct st_buffpek *, IO_CACHE *); + NEAR uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint); + NEAR int (*write_key)(struct st_maria_sort_param *, IO_CACHE *,char *, + uint, uint); +} MARIA_SORT_PARAM; + + +/* functions in maria_check */ +void mariachk_init(HA_CHECK *param); +int maria_chk_status(HA_CHECK *param, MARIA_HA *info); +int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag); +int maria_chk_size(HA_CHECK *param, MARIA_HA *info); +int maria_chk_key(HA_CHECK *param, MARIA_HA *info); +int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info, int extend); +int maria_repair(HA_CHECK *param, register MARIA_HA *info, + my_string name, int rep_quick); +int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, + my_string name); +int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info, + const char *name, int rep_quick); +int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, + const char *name, int rep_quick); +int maria_change_to_newfile(const char *filename, const char *old_ext, + const char *new_ext, uint raid_chunks, myf myflags); +int maria_lock_file(HA_CHECK *param, File file, my_off_t start, int lock_type, + const char *filetype, const char *filename); +void maria_lock_memory(HA_CHECK *param); +int maria_update_state_info(HA_CHECK *param, MARIA_HA *info, uint update); +void maria_update_key_parts(MARIA_KEYDEF *keyinfo, ulong *rec_per_key_part, + ulonglong *unique, ulonglong *notnull, + ulonglong records); +int maria_filecopy(HA_CHECK *param, File to, File from, my_off_t start, + my_off_t length, const char *type); +int maria_movepoint(MARIA_HA *info, byte *record, my_off_t oldpos, + my_off_t newpos, uint prot_key); +int maria_write_data_suffix(MARIA_SORT_INFO *sort_info, my_bool fix_datafile); +int maria_test_if_almost_full(MARIA_HA *info); +int maria_recreate_table(HA_CHECK *param, MARIA_HA ** org_info, char *filename); +int maria_disable_indexes(MARIA_HA *info); +int maria_enable_indexes(MARIA_HA *info); +int maria_indexes_are_disabled(MARIA_HA *info); +void maria_disable_non_unique_index(MARIA_HA *info, ha_rows rows); +my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows, ulonglong key_map, + my_bool force); + +int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows); +void maria_flush_bulk_insert(MARIA_HA *info, uint inx); +void maria_end_bulk_insert(MARIA_HA *info); +int maria_assign_to_key_cache(MARIA_HA *info, ulonglong key_map, + KEY_CACHE *key_cache); +void maria_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache); +int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves); + +/* fulltext functions */ +FT_INFO *maria_ft_init_search(uint,void *, uint, byte *, uint, + CHARSET_INFO *, byte *); + +/* 'Almost-internal' Maria functions */ + +void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info, + my_bool repair); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/my_base.h b/include/my_base.h index b9a806cc02f..5378f4f470b 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -15,7 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* This file includes constants used with all databases */ -/* Author: Michael Widenius */ #ifndef _my_base_h #define _my_base_h @@ -487,4 +486,7 @@ typedef ulong ha_rows; #define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2) +/* invalidator function reference for Query Cache */ +typedef void (* invalidator_by_filename)(const char * filename); + #endif /* _my_base_h */ diff --git a/include/my_handler.h b/include/my_handler.h index d531e0fb3e1..9b086036389 100644 --- a/include/my_handler.h +++ b/include/my_handler.h @@ -18,11 +18,30 @@ #ifndef _my_handler_h #define _my_handler_h -#include "my_global.h" -#include "my_base.h" -#include "m_ctype.h" #include "myisampack.h" +/* + There is a hard limit for the maximum number of keys as there are only + 8 bits in the index file header for the number of keys in a table. + This means that 0..255 keys can exist for a table. The idea of + HA_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on + a MyISAM table for which one has more keys than MyISAM is normally + compiled for. If you don't have this, you will get a core dump when + running myisamchk compiled for 128 keys on a table with 255 keys. +*/ + +#define HA_MAX_POSSIBLE_KEY 255 /* For myisamchk */ +/* + The following defines can be increased if necessary. + But beware the dependency of HA_MAX_POSSIBLE_KEY_BUFF and HA_MAX_KEY_LENGTH. +*/ + +#define HA_MAX_KEY_LENGTH 1000 /* Max length in bytes */ +#define HA_MAX_KEY_SEG 16 /* Max segments for key */ + +#define HA_MAX_POSSIBLE_KEY_BUFF (HA_MAX_KEY_LENGTH + 24+ 6+6) +#define HA_MAX_KEY_BUFF (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8) + typedef struct st_HA_KEYSEG /* Key-portion */ { CHARSET_INFO *charset; @@ -82,7 +101,7 @@ typedef struct st_HA_KEYSEG /* Key-portion */ #define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \ set_rec_bits(0, bit_ptr, bit_ofs, bit_len) -extern int mi_compare_text(CHARSET_INFO *, uchar *, uint, uchar *, uint , +extern int ha_compare_text(CHARSET_INFO *, uchar *, uint, uchar *, uint , my_bool, my_bool); extern int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, register uchar *b, uint key_length, uint nextflag, diff --git a/include/myisam.h b/include/myisam.h index 5116f48eeb5..b5f29741be0 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -32,33 +32,19 @@ extern "C" { #include "keycache.h" #endif #include "my_handler.h" +#include #include /* - There is a hard limit for the maximum number of keys as there are only - 8 bits in the index file header for the number of keys in a table. - This means that 0..255 keys can exist for a table. The idea of - MI_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on - a MyISAM table for which one has more keys than MyISAM is normally - compiled for. If you don't have this, you will get a core dump when - running myisamchk compiled for 128 keys on a table with 255 keys. + Limit max keys according to HA_MAX_POSSIBLE_KEY; See myisamchk.h for details */ -#define MI_MAX_POSSIBLE_KEY 255 /* For myisam_chk */ -#if MAX_INDEXES > MI_MAX_POSSIBLE_KEY -#define MI_MAX_KEY MI_MAX_POSSIBLE_KEY /* Max allowed keys */ + +#if MAX_INDEXES > HA_MAX_POSSIBLE_KEY +#define MI_MAX_KEY HA_MAX_POSSIBLE_KEY /* Max allowed keys */ #else #define MI_MAX_KEY MAX_INDEXES /* Max allowed keys */ #endif -#define MI_MAX_POSSIBLE_KEY_BUFF (1024+6+6) /* For myisam_chk */ -/* - The following defines can be increased if necessary. - But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and MI_MAX_KEY_LENGTH. -*/ -#define MI_MAX_KEY_LENGTH 1000 /* Max length in bytes */ -#define MI_MAX_KEY_SEG 16 /* Max segments for key */ - -#define MI_MAX_KEY_BUFF (MI_MAX_KEY_LENGTH+MI_MAX_KEY_SEG*6+8+8) #define MI_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */ #define MI_NAME_IEXT ".MYI" #define MI_NAME_DEXT ".MYD" @@ -257,9 +243,6 @@ typedef struct st_columndef /* column information */ #endif } MI_COLUMNDEF; -/* invalidator function reference for Query Cache */ -typedef void (* invalidator_by_filename)(const char * filename); - extern my_string myisam_log_filename; /* Name of logfile */ extern ulong myisam_block_size; extern ulong myisam_concurrent_insert; @@ -311,195 +294,105 @@ extern int mi_delete_all_rows(struct st_myisam_info *info); extern ulong _mi_calc_blob_length(uint length , const byte *pos); extern uint mi_get_pointer_length(ulonglong file_length, uint def); -/* this is used to pass to mysql_myisamchk_table -- by Sasha Pachev */ +/* this is used to pass to mysql_myisamchk_table */ #define MYISAMCHK_REPAIR 1 /* equivalent to myisamchk -r */ #define MYISAMCHK_VERIFY 2 /* Verify, run repair if failure */ -/* - Definitions needed for myisamchk.c - - Entries marked as "QQ to be removed" are NOT used to - pass check/repair options to mi_check.c. They are used - internally by myisamchk.c or/and ha_myisam.cc and should NOT - be stored together with other flags. They should be removed - from the following list to make addition of new flags possible. -*/ - -#define T_AUTO_INC 1 -#define T_AUTO_REPAIR 2 /* QQ to be removed */ -#define T_BACKUP_DATA 4 -#define T_CALC_CHECKSUM 8 -#define T_CHECK 16 /* QQ to be removed */ -#define T_CHECK_ONLY_CHANGED 32 /* QQ to be removed */ -#define T_CREATE_MISSING_KEYS 64 -#define T_DESCRIPT 128 -#define T_DONT_CHECK_CHECKSUM 256 -#define T_EXTEND 512 -#define T_FAST (1L << 10) /* QQ to be removed */ -#define T_FORCE_CREATE (1L << 11) /* QQ to be removed */ -#define T_FORCE_UNIQUENESS (1L << 12) -#define T_INFO (1L << 13) -#define T_MEDIUM (1L << 14) -#define T_QUICK (1L << 15) /* QQ to be removed */ -#define T_READONLY (1L << 16) /* QQ to be removed */ -#define T_REP (1L << 17) -#define T_REP_BY_SORT (1L << 18) /* QQ to be removed */ -#define T_REP_PARALLEL (1L << 19) /* QQ to be removed */ -#define T_RETRY_WITHOUT_QUICK (1L << 20) -#define T_SAFE_REPAIR (1L << 21) -#define T_SILENT (1L << 22) -#define T_SORT_INDEX (1L << 23) /* QQ to be removed */ -#define T_SORT_RECORDS (1L << 24) /* QQ to be removed */ -#define T_STATISTICS (1L << 25) -#define T_UNPACK (1L << 26) -#define T_UPDATE_STATE (1L << 27) -#define T_VERBOSE (1L << 28) -#define T_VERY_SILENT (1L << 29) -#define T_WAIT_FOREVER (1L << 30) -#define T_WRITE_LOOP ((ulong) 1L << 31) - -#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL) - -/* - Flags used by myisamchk.c or/and ha_myisam.cc that are NOT passed - to mi_check.c follows: -*/ - -#define TT_USEFRM 1 -#define TT_FOR_UPGRADE 2 - -#define O_NEW_INDEX 1 /* Bits set in out_flag */ -#define O_NEW_DATA 2 -#define O_DATA_LOST 4 - -/* these struct is used by my_check to tell it what to do */ - -typedef struct st_sort_key_blocks /* Used when sorting */ +typedef struct st_sort_info { - uchar *buff,*end_pos; - uchar lastkey[MI_MAX_POSSIBLE_KEY_BUFF]; - uint last_length; - int inited; -} SORT_KEY_BLOCKS; +#ifdef THREAD + /* sync things */ + pthread_mutex_t mutex; + pthread_cond_t cond; +#endif + MI_INFO *info; + HA_CHECK *param; + char *buff; + SORT_KEY_BLOCKS *key_block, *key_block_end; + SORT_FT_BUF *ft_buf; + my_off_t filelength, dupp, buff_length; + ha_rows max_records; + uint current_key, total_keys; + uint got_error, threads_running; + myf myf_rw; + enum data_file_type new_data_file_type; +} MI_SORT_INFO; -/* - MyISAM supports several statistics collection methods. Currently statistics - collection method is not stored in MyISAM file and has to be specified for - each table analyze/repair operation in MI_CHECK::stats_method. -*/ -typedef enum -{ - /* Treat NULLs as inequal when collecting statistics (default for 4.1/5.0) */ - MI_STATS_METHOD_NULLS_NOT_EQUAL, - /* Treat NULLs as equal when collecting statistics (like 4.0 did) */ - MI_STATS_METHOD_NULLS_EQUAL, - /* Ignore NULLs - count only tuples without NULLs in the index components */ - MI_STATS_METHOD_IGNORE_NULLS -} enum_mi_stats_method; - -typedef struct st_mi_check_param +typedef struct st_mi_sort_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; - ha_rows total_records,total_deleted; - ha_checksum record_checksum,glob_crc; - ulong use_buffers,read_buffer_length,write_buffer_length, - sort_buffer_length,sort_key_blocks; - uint out_flag,warning_printed,error_printed,verbose; - uint opt_sort_key,total_files,max_level; - uint testflag, key_cache_block_size; - uint8 language; - my_bool using_global_keycache, opt_lock_memory, opt_follow_links; - my_bool retry_repair, force_sort, calc_checksum; - char temp_filename[FN_REFLEN],*isam_file_name; - MY_TMPDIR *tmpdir; - int tmpfile_createflag; - myf myf_rw; - IO_CACHE read_cache; + pthread_t thr; + IO_CACHE read_cache, tempfile, tempfile_for_exceptions; + DYNAMIC_ARRAY buffpek; + MI_KEYDEF *keyinfo; + MI_SORT_INFO *sort_info; + HA_KEYSEG *seg; + uchar **sort_keys; + byte *rec_buff; + void *wordlist, *wordptr; + char *record; + MY_TMPDIR *tmpdir; + /* The next two are used to collect statistics, see update_key_parts for description. */ - ulonglong unique_count[MI_MAX_KEY_SEG+1]; - ulonglong notnull_count[MI_MAX_KEY_SEG+1]; - - ha_checksum key_crc[MI_MAX_POSSIBLE_KEY]; - ulong rec_per_key_part[MI_MAX_KEY_SEG*MI_MAX_POSSIBLE_KEY]; - void *thd; - const char *db_name, *table_name; - const char *op_name; - enum_mi_stats_method stats_method; -} MI_CHECK; - -typedef struct st_sort_ft_buf -{ - uchar *buf, *end; - int count; - uchar lastkey[MI_MAX_KEY_BUFF]; -} SORT_FT_BUF; + ulonglong unique[HA_MAX_KEY_SEG+1]; + ulonglong notnull[HA_MAX_KEY_SEG+1]; + + my_off_t pos,max_pos,filepos,start_recpos; + uint key, key_length,real_key_length,sortbuff_size; + uint maxbuffers, keys, find_length, sort_keys_length; + my_bool fix_datafile, master; + + int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *); + int (*key_read)(struct st_mi_sort_param *,void *); + int (*key_write)(struct st_mi_sort_param *, const void *); + void (*lock_in_memory)(HA_CHECK *); + NEAR int (*write_keys)(struct st_mi_sort_param *, register uchar **, + uint , struct st_buffpek *, IO_CACHE *); + NEAR uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint); + NEAR int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,char *, + uint, uint); +} MI_SORT_PARAM; -typedef struct st_sort_info -{ - my_off_t filelength,dupp,buff_length; - ha_rows max_records; - uint current_key, total_keys; - myf myf_rw; - enum data_file_type new_data_file_type; - MI_INFO *info; - MI_CHECK *param; - char *buff; - SORT_KEY_BLOCKS *key_block,*key_block_end; - SORT_FT_BUF *ft_buf; - /* sync things */ - uint got_error, threads_running; -#ifdef THREAD - pthread_mutex_t mutex; - pthread_cond_t cond; -#endif -} SORT_INFO; /* functions in mi_check */ -void myisamchk_init(MI_CHECK *param); -int chk_status(MI_CHECK *param, MI_INFO *info); -int chk_del(MI_CHECK *param, register MI_INFO *info, uint test_flag); -int chk_size(MI_CHECK *param, MI_INFO *info); -int chk_key(MI_CHECK *param, MI_INFO *info); -int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend); -int mi_repair(MI_CHECK *param, register MI_INFO *info, +void myisamchk_init(HA_CHECK *param); +int chk_status(HA_CHECK *param, MI_INFO *info); +int chk_del(HA_CHECK *param, register MI_INFO *info, uint test_flag); +int chk_size(HA_CHECK *param, MI_INFO *info); +int chk_key(HA_CHECK *param, MI_INFO *info); +int chk_data_link(HA_CHECK *param, MI_INFO *info,int extend); +int mi_repair(HA_CHECK *param, register MI_INFO *info, my_string name, int rep_quick); -int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name); -int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, +int mi_sort_index(HA_CHECK *param, register MI_INFO *info, my_string name); +int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, const char * name, int rep_quick); -int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, +int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, const char * name, int rep_quick); int change_to_newfile(const char * filename, const char * old_ext, const char * new_ext, uint raid_chunks, myf myflags); -int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type, +int lock_file(HA_CHECK *param, File file, my_off_t start, int lock_type, const char *filetype, const char *filename); -void lock_memory(MI_CHECK *param); -void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, +void lock_memory(HA_CHECK *param); +void update_auto_increment_key(HA_CHECK *param, MI_INFO *info, my_bool repair); -int update_state_info(MI_CHECK *param, MI_INFO *info,uint update); +int update_state_info(HA_CHECK *param, MI_INFO *info,uint update); void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part, ulonglong *unique, ulonglong *notnull, ulonglong records); -int filecopy(MI_CHECK *param, File to,File from,my_off_t start, +int filecopy(HA_CHECK *param, File to,File from,my_off_t start, my_off_t length, const char *type); int movepoint(MI_INFO *info,byte *record,my_off_t oldpos, my_off_t newpos, uint prot_key); -int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile); +int write_data_suffix(MI_SORT_INFO *sort_info, my_bool fix_datafile); int test_if_almost_full(MI_INFO *info); -int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename); +int recreate_table(HA_CHECK *param, MI_INFO **org_info, char *filename); void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows); my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map, my_bool force); @@ -513,6 +406,13 @@ 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); +int write_data_suffix(MI_SORT_INFO *sort_info, my_bool fix_datafile); +int flush_pending_blocks(MI_SORT_PARAM *param); +int sort_ft_buf_flush(MI_SORT_PARAM *sort_param); +int thr_write_keys(MI_SORT_PARAM *sort_param); +int sort_write_record(MI_SORT_PARAM *sort_param); +int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong); + #ifdef __cplusplus } #endif diff --git a/include/myisamchk.h b/include/myisamchk.h new file mode 100644 index 00000000000..442fe5f7ece --- /dev/null +++ b/include/myisamchk.h @@ -0,0 +1,160 @@ +/* Copyright (C) 2006 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 */ + +/* Definitions needed for myisamchk/mariachk.c */ + +/* + Entries marked as "QQ to be removed" are NOT used to + pass check/repair options to xxx_check.c. They are used + internally by xxxchk.c or/and ha_xxxx.cc and should NOT + be stored together with other flags. They should be removed + from the following list to make addition of new flags possible. +*/ + +#ifndef _myisamchk_h +#define _myisamchk_h + +#define T_AUTO_INC 1 +#define T_AUTO_REPAIR 2 /* QQ to be removed */ +#define T_BACKUP_DATA 4 +#define T_CALC_CHECKSUM 8 +#define T_CHECK 16 /* QQ to be removed */ +#define T_CHECK_ONLY_CHANGED 32 /* QQ to be removed */ +#define T_CREATE_MISSING_KEYS 64 +#define T_DESCRIPT 128 +#define T_DONT_CHECK_CHECKSUM 256 +#define T_EXTEND 512 +#define T_FAST (1L << 10) /* QQ to be removed */ +#define T_FORCE_CREATE (1L << 11) /* QQ to be removed */ +#define T_FORCE_UNIQUENESS (1L << 12) +#define T_INFO (1L << 13) +#define T_MEDIUM (1L << 14) +#define T_QUICK (1L << 15) /* QQ to be removed */ +#define T_READONLY (1L << 16) /* QQ to be removed */ +#define T_REP (1L << 17) +#define T_REP_BY_SORT (1L << 18) /* QQ to be removed */ +#define T_REP_PARALLEL (1L << 19) /* QQ to be removed */ +#define T_RETRY_WITHOUT_QUICK (1L << 20) +#define T_SAFE_REPAIR (1L << 21) +#define T_SILENT (1L << 22) +#define T_SORT_INDEX (1L << 23) /* QQ to be removed */ +#define T_SORT_RECORDS (1L << 24) /* QQ to be removed */ +#define T_STATISTICS (1L << 25) +#define T_UNPACK (1L << 26) +#define T_UPDATE_STATE (1L << 27) +#define T_VERBOSE (1L << 28) +#define T_VERY_SILENT (1L << 29) +#define T_WAIT_FOREVER (1L << 30) +#define T_WRITE_LOOP ((ulong) 1L << 31) + +#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL) + +/* + Flags used by xxxxchk.c or/and ha_xxxx.cc that are NOT passed + to xxxcheck.c follows: +*/ + +#define TT_USEFRM 1 +#define TT_FOR_UPGRADE 2 + +#define O_NEW_INDEX 1 /* Bits set in out_flag */ +#define O_NEW_DATA 2 +#define O_DATA_LOST 4 + +typedef struct st_sort_key_blocks /* Used when sorting */ +{ + uchar *buff, *end_pos; + uchar lastkey[HA_MAX_POSSIBLE_KEY_BUFF]; + uint last_length; + int inited; +} SORT_KEY_BLOCKS; + + +/* + MARIA/MYISAM supports several statistics collection + methods. Currently statistics collection method is not stored in + MARIA file and has to be specified for each table analyze/repair + operation in MI_CHECK::stats_method. +*/ + +typedef enum +{ + /* Treat NULLs as inequal when collecting statistics (default for 4.1/5.0) */ + MI_STATS_METHOD_NULLS_NOT_EQUAL, + /* Treat NULLs as equal when collecting statistics (like 4.0 did) */ + MI_STATS_METHOD_NULLS_EQUAL, + /* Ignore NULLs - count only tuples without NULLs in the index components */ + MI_STATS_METHOD_IGNORE_NULLS +} enum_handler_stats_method; + + +typedef struct st_handler_check_param +{ + char *isam_file_name; + MY_TMPDIR *tmpdir; + void *thd; + const char *db_name, *table_name, *op_name; + ulonglong auto_increment_value; + ulonglong max_data_file_length; + ulonglong keys_in_use; + ulonglong max_record_length; + /* + The next two are used to collect statistics, see update_key_parts for + description. + */ + ulonglong unique_count[HA_MAX_KEY_SEG + 1]; + ulonglong notnull_count[HA_MAX_KEY_SEG + 1]; + + 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; + ha_rows total_records, total_deleted; + ha_checksum record_checksum, glob_crc; + ha_checksum key_crc[HA_MAX_POSSIBLE_KEY]; + ulong use_buffers, read_buffer_length, write_buffer_length; + ulong sort_buffer_length, sort_key_blocks; + ulong rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY]; + uint out_flag, warning_printed, error_printed, verbose; + uint opt_sort_key, total_files, max_level; + uint testflag, key_cache_block_size; + int tmpfile_createflag; + myf myf_rw; + uint8 language; + my_bool using_global_keycache, opt_lock_memory, opt_follow_links; + my_bool retry_repair, force_sort, calc_checksum; + char temp_filename[FN_REFLEN]; + IO_CACHE read_cache; + enum_handler_stats_method stats_method; +} HA_CHECK; + + +typedef struct st_sort_ftbuf +{ + uchar *buf, *end; + int count; + uchar lastkey[HA_MAX_KEY_BUFF]; +} SORT_FT_BUF; + + +typedef struct st_buffpek { + my_off_t file_pos; /* Where we are in the sort file */ + uchar *base,*key; /* Key pointers */ + ha_rows count; /* Number of rows in table */ + ulong mem_count; /* numbers of keys in memory */ + ulong max_keys; /* Max keys in buffert */ +} BUFFPEK; + +#endif /* _myisamchk_h */ -- cgit v1.2.1 From 157002b12f4134eb6ca2b84ba95558e3b6638929 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 5 May 2006 20:32:02 +0200 Subject: WL#3270 "Maria - cleanups of inherited MyISAM functionality" Removing the "external lock" functionality from Maria (as two separate processes wanting to share a table should not only my_lock() the data and index files but also the log files, and share memory (as the latest data is in the page cache), it sounds useless to feature this). Removing the MyISAM logging from Maria (as REDO logging will be done differently). BitKeeper/deleted/.del-maria_log.c~1fb295a18c3f5d4c: Delete: storage/maria/maria_log.c BitKeeper/deleted/.del-ma_log.c~4a44ec11d547772f: Delete: storage/maria/ma_log.c include/maria.h: unneeded storage/maria/Makefile.am: log removed storage/maria/ma_check.c: external locking removed storage/maria/ma_close.c: log removed storage/maria/ma_delete.c: log removed storage/maria/ma_delete_all.c: log removed. Unused var. storage/maria/ma_dynrec.c: external locking removed storage/maria/ma_extra.c: log removed storage/maria/ma_init.c: log removed storage/maria/ma_locking.c: external locking removed, log removed storage/maria/ma_open.c: external locking removed, log removed storage/maria/ma_static.c: log removed storage/maria/ma_statrec.c: external locking removed storage/maria/ma_test2.c: log removed storage/maria/ma_test3.c: log removed storage/maria/ma_update.c: log removed storage/maria/ma_write.c: external locking removed, log removed storage/maria/maria_chk.c: external locking removed storage/maria/maria_def.h: log removed, maria_pid unused. storage/maria/maria_pack.c: fixes for warnings (where pointers are like ulong and so %u is not enough). --- include/maria.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/maria.h b/include/maria.h index c7586143fe7..72fb1cf2dff 100644 --- a/include/maria.h +++ b/include/maria.h @@ -372,8 +372,6 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, const char *name, int rep_quick); int maria_change_to_newfile(const char *filename, const char *old_ext, const char *new_ext, uint raid_chunks, myf myflags); -int maria_lock_file(HA_CHECK *param, File file, my_off_t start, int lock_type, - const char *filetype, const char *filename); void maria_lock_memory(HA_CHECK *param); int maria_update_state_info(HA_CHECK *param, MARIA_HA *info, uint update); void maria_update_key_parts(MARIA_KEYDEF *keyinfo, ulong *rec_per_key_part, -- cgit v1.2.1 From fbe22b6020a5d41e5cc0819192d437f3963fd298 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Jul 2006 11:10:34 +0300 Subject: The pagae cache added. mysys/Makefile.am: the page cache and test proms for it added include/pagecache.h: New BitKeeper file ``include/pagecache.h'' mysys/mf_pagecache.c: New BitKeeper file ``mysys/mf_pagecache.c'' mysys/test_file.c: New BitKeeper file ``mysys/test_file.c'' mysys/test_file.h: New BitKeeper file ``mysys/test_file.h'' mysys/test_pagecache_consist.c: New BitKeeper file ``mysys/test_pagecache_consist.c'' mysys/test_pagecache_single.c: New BitKeeper file ``mysys/test_pagecache_single.c'' --- include/pagecache.h | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 include/pagecache.h (limited to 'include') diff --git a/include/pagecache.h b/include/pagecache.h new file mode 100644 index 00000000000..018e695fa27 --- /dev/null +++ b/include/pagecache.h @@ -0,0 +1,226 @@ +/* Copyright (C) 2006 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 */ + +/* Page cache variable structures */ + +#ifndef _pagecache_h +#define _pagecache_h +C_MODE_START + +/* Type of the page */ +enum pagecache_page_type +{ +#ifndef DBUG_OFF + /* used only for control page type chenging during debugging */ + PAGECACHE_EMPTY_PAGE, +#endif + /* the page does not contain LSN */ + PAGECACHE_PLAIN_PAGE, + /* the page contain LSN (maria tablespace page) */ + PAGECACHE_LSN_PAGE +}; + +/* + This enum describe lock status changing. every typr of page cache will + interpret WRITE/READ lock as it need. +*/ +enum pagecache_page_lock +{ + PAGECACHE_LOCK_LEFT_UNLOCKED, /* free -> free */ + PAGECACHE_LOCK_LEFT_READLOCKED, /* read -> read */ + PAGECACHE_LOCK_LEFT_WRITELOCKED, /* write -> write */ + PAGECACHE_LOCK_READ, /* free -> read */ + PAGECACHE_LOCK_WRITE, /* free -> write */ + PAGECACHE_LOCK_READ_UNLOCK, /* read -> free */ + PAGECACHE_LOCK_WRITE_UNLOCK, /* write -> free */ + PAGECACHE_LOCK_WRITE_TO_READ /* write -> read */ +}; +/* + This enum describe pin status changing +*/ +enum pagecache_page_pin +{ + PAGECACHE_PIN_LEFT_PINNED, /* pinned -> pinned */ + PAGECACHE_PIN_LEFT_UNPINNED, /* unpinned -> unpinned */ + PAGECACHE_PIN, /* unpinned -> pinned */ + PAGECACHE_UNPIN /* pinned -> unpinned */ +}; +/* How to write the page */ +enum pagecache_write_mode +{ + /* do not write immediately, i.e. it will be dirty page */ + PAGECACHE_WRITE_DELAY, + /* write page to the file and put it to the cache */ + PAGECACHE_WRITE_NOW, + /* page already is in the file. (key cache insert analogue) */ + PAGECACHE_WRITE_DONE +}; + +typedef void *PAGECACHE_PAGE_LINK; + +/* TODO: move to loghandler emulator */ +typedef void LOG_HANDLER; +typedef void *LSN; + +/* file descriptor for Maria */ +typedef struct st_pagecache_file +{ + int file; /* it is for debugging purposes then it will be uint32 file_no */ +} PAGECACHE_FILE; + +/* page number for maria */ +typedef uint32 maria_page_no_t; + +/* declare structures that is used by st_pagecache */ + +struct st_pagecache_block_link; +typedef struct st_pagecache_block_link PAGECACHE_BLOCK_LINK; +struct st_pagecache_page; +typedef struct st_pagecache_page PAGECACHE_PAGE; +struct st_pagecache_hash_link; +typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK; + +/* info about requests in a waiting queue */ +typedef struct st_pagecache_wqueue +{ + struct st_my_thread_var *last_thread; /* circular list of waiting threads */ +} PAGECACHE_WQUEUE; + +#define PAGECACHE_CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ + +/* + The page cache structure + It also contains read-only statistics parameters. +*/ + +typedef struct st_pagecache +{ + my_bool 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 shift; /* block size = 2 ^ shift */ + my_size_t mem_size; /* specified size of the cache memory */ + uint32 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 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; /* maximum number of concurrently used blocks */ + ulong blocks_unused; /* number of currently unused 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 */ + PAGECACHE_HASH_LINK **hash_root;/* arr. of entries into hash table buckets */ + PAGECACHE_HASH_LINK *hash_link_root;/* memory for hash table links */ + PAGECACHE_HASH_LINK *free_hash_list;/* list of free hash links */ + PAGECACHE_BLOCK_LINK *free_block_list;/* list of free blocks */ + PAGECACHE_BLOCK_LINK *block_root;/* memory for block links */ + byte HUGE_PTR *block_mem; /* memory for block buffers */ + PAGECACHE_BLOCK_LINK *used_last;/* ptr to the last block of the LRU chain */ + PAGECACHE_BLOCK_LINK *used_ins;/* ptr to the insertion block in LRU chain */ + pthread_mutex_t cache_lock; /* to lock access to the cache structure */ + PAGECACHE_WQUEUE resize_queue; /* threads waiting during resize operation */ + PAGECACHE_WQUEUE waiting_for_hash_link;/* waiting for a free hash link */ + PAGECACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ + /* hash for dirty file bl.*/ + PAGECACHE_BLOCK_LINK *changed_blocks[PAGECACHE_CHANGED_BLOCKS_HASH]; + /* hash for other file bl.*/ + PAGECACHE_BLOCK_LINK *file_blocks[PAGECACHE_CHANGED_BLOCKS_HASH]; + + LOG_HANDLER *loghandler; /* loghandler structure */ + + /* + 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. These are reset in reset_key_cache_counters(). */ + ulong global_blocks_changed; /* number of currently dirty blocks */ + ulonglong global_cache_w_requests;/* number of write requests (write hits) */ + ulonglong global_cache_write; /* number of writes from cache to files */ + ulonglong global_cache_r_requests;/* number of read requests (read hits) */ + ulonglong global_cache_read; /* number of reads from files to cache */ + + int blocks; /* max number of blocks in the cache */ + my_bool in_init; /* Set to 1 in MySQL during init/resize */ +} PAGECACHE; + +extern int init_pagecache(PAGECACHE *pagecache, my_size_t use_mem, + uint division_limit, uint age_threshold, + uint block_size, + LOG_HANDLER *loghandler); +extern int resize_pagecache(PAGECACHE *pagecache, + my_size_t use_mem, uint division_limit, + uint age_threshold); +extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit, + uint age_threshold); +extern byte *pagecache_read(PAGECACHE *pagecache, + PAGECACHE_FILE *file, + maria_page_no_t pageno, + uint level, + byte *buff, + enum pagecache_page_type type, + enum pagecache_page_lock lock, + PAGECACHE_PAGE_LINK *link); +extern my_bool pagecache_write(PAGECACHE *pagecache, + PAGECACHE_FILE *file, + maria_page_no_t pageno, + uint level, + byte *buff, + enum pagecache_page_type type, + enum pagecache_page_lock lock, + enum pagecache_page_pin pin, + enum pagecache_write_mode write_mode, + PAGECACHE_PAGE_LINK *link); +void pagecache_unlock_page(PAGECACHE *pagecache, + PAGECACHE_FILE *file, + maria_page_no_t pageno, + enum pagecache_page_lock lock, + enum pagecache_page_pin pin, + my_bool stamp_this_page, + LSN first_REDO_LSN_for_page); +void pagecache_unlock(PAGECACHE *pagecache, + PAGECACHE_PAGE_LINK *link, + enum pagecache_page_lock lock, + enum pagecache_page_pin pin, + my_bool stamp_this_page, + LSN first_REDO_LSN_for_page); +void pagecache_unpin_page(PAGECACHE *pagecache, + PAGECACHE_FILE *file, + maria_page_no_t pageno); +void pagecache_unpin(PAGECACHE *pagecache, + PAGECACHE_PAGE_LINK *link); +extern int flush_pagecache_blocks(PAGECACHE *keycache, + PAGECACHE_FILE *file, + enum flush_type type); +my_bool pagecache_delete_page(PAGECACHE *pagecache, + PAGECACHE_FILE *file, + maria_page_no_t pageno, + enum pagecache_page_lock lock, + my_bool flush); +extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup); + +C_MODE_END +#endif /* _keycache_h */ -- cgit v1.2.1 From 832776fd2d4d11825eaeb945e57d6eeab816cefc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jul 2006 09:47:44 +0200 Subject: two include files were missing in the source tarball, causing pushbuild build failures. include/Makefile.am: two include files missing in the source tarball --- include/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index e1ddadb933a..457e49c338b 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -24,7 +24,7 @@ pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ mysql_time.h mysql/plugin.h $(BUILT_SOURCES) noinst_HEADERS = config-win.h config-netware.h \ - heap.h my_bitmap.h my_uctype.h \ + heap.h maria.h myisamchk.h my_bitmap.h my_uctype.h \ myisam.h myisampack.h myisammrg.h ft_global.h\ mysys_err.h my_base.h help_start.h help_end.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \ -- cgit v1.2.1 From 99c431db92f8904bf50f6944e1488a0172c4ebd8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Aug 2006 16:36:54 +0200 Subject: Completion of merge of mysql-5.1 into mysql-maria. Manually imported changes done to MyISAM (include/myisam.h, storage/myisam/*, sql/ha_myisam.*, mysql-test/t/myisam.test, mysql-test/t/ps_2myisam.test) the last months into Maria (tedious, should do it more frequently in the future), including those not done at the previous 5.1->Maria merge (please in the future don't forget to apply MyISAM changes to Maria when you merge 5.1 into Maria). Note: I didn't try to import anything which could be MyISAM-related in other tests of mysql-test (I didn't want to dig in all csets), but as QA is working to make most tests re-usable for other engines (Falcon), it is likely that we'll benefit from this and just have to set engine=Maria somewhere to run those tests on Maria. func_group and partition tests fail but they already do in main 5.1 on my machine. No Valgrind error in t/*maria*.test. Monty: please see the commit comment of maria.result and check. BitKeeper/deleted/.del-ha_maria.m4: Delete: config/ac-macros/ha_maria.m4 configure.in: fix for the new way of enabling engines include/maria.h: importing changes done to MyISAM the last months into Maria include/my_handler.h: importing changes done to MyISAM the last months into Maria include/myisam.h: importing changes done to MyISAM the last months into Maria mysql-test/r/maria.result: identical to myisam.result, except the engine name in some places AND in the line testing key_block_size=1000000000000000000: Maria gives a key block size of 8192 while MyISAM gives 4096; is it explainable by the difference between MARIA_KEY_BLOCK_LENGTH and the same constant in MyISAM? Monty? mysql-test/r/ps_maria.result: identical to ps_2myisam.result (except the engine name in some places) mysql-test/t/maria.test: instead of engine=maria everywhere, I use @@storage_engine (reduces the diff with myisam.test). importing changes done to MyISAM the last months into Maria mysys/my_handler.c: importing changes done to MyISAM the last months into Maria sql/ha_maria.cc: importing changes done to MyISAM the last months into Maria sql/ha_maria.h: importing changes done to MyISAM the last months into Maria sql/mysqld.cc: unneeded storage/maria/Makefile.am: importing changes done to MyISAM the last months into Maria storage/maria/ma_check.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_create.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_delete_table.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_dynrec.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_extra.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_ft_boolean_search.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_ft_eval.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_ft_nlq_search.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_ft_parser.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_ft_test1.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_ft_update.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_ftdefs.h: importing changes done to MyISAM the last months into Maria storage/maria/ma_key.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_open.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_page.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_rkey.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_rsamepos.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_rt_index.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_rt_mbr.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_search.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_sort.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_test1.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_test2.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_test3.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_update.c: importing changes done to MyISAM the last months into Maria storage/maria/ma_write.c: importing changes done to MyISAM the last months into Maria storage/maria/maria_chk.c: importing changes done to MyISAM the last months into Maria storage/maria/maria_def.h: importing changes done to MyISAM the last months into Maria storage/maria/maria_ftdump.c: importing changes done to MyISAM the last months into Maria storage/maria/maria_pack.c: importing changes done to MyISAM the last months into Maria --- include/maria.h | 6 +++--- include/my_handler.h | 2 -- include/myisam.h | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/maria.h b/include/maria.h index 72fb1cf2dff..705ba7c91c7 100644 --- a/include/maria.h +++ b/include/maria.h @@ -168,7 +168,7 @@ typedef struct st_maria_keydef /* Key definition with open & info */ uint16 keylength; /* Tot length of keyparts (auto) */ uint16 minlength; /* min length of (packed) key (auto) */ uint16 maxlength; /* max length of (packed) key (auto) */ - uint16 block_size; /* block_size (auto) */ + uint16 block_size_index; /* block_size (auto) */ uint32 version; /* For concurrent read/write */ uint32 ftparser_nr; /* distinct ftparser number */ @@ -235,7 +235,6 @@ typedef struct st_maria_columndef /* column information */ } MARIA_COLUMNDEF; -extern my_string maria_log_filename; /* Name of logfile */ extern ulong maria_block_size; extern ulong maria_concurrent_insert; extern my_bool maria_flush, maria_delay_key_write, maria_single_user; @@ -281,9 +280,9 @@ extern int maria_delete_table(const char *name); extern int maria_rename(const char *from, const char *to); extern int maria_extra(struct st_maria_info *file, enum ha_extra_function function, void *extra_arg); +extern int maria_reset(struct st_maria_info *file); extern ha_rows maria_records_in_range(struct st_maria_info *info, int inx, key_range *min_key, key_range *max_key); -extern int maria_logging(int activate_log); extern int maria_is_changed(struct st_maria_info *info); extern int maria_delete_all_rows(struct st_maria_info *info); extern uint maria_get_pointer_length(ulonglong file_length, uint def); @@ -328,6 +327,7 @@ typedef struct st_maria_sort_param uchar **sort_keys; byte *rec_buff; void *wordlist, *wordptr; + MEM_ROOT wordroot; char *record; MY_TMPDIR *tmpdir; diff --git a/include/my_handler.h b/include/my_handler.h index ea027b18725..9b086036389 100644 --- a/include/my_handler.h +++ b/include/my_handler.h @@ -18,8 +18,6 @@ #ifndef _my_handler_h #define _my_handler_h -#include "my_base.h" -#include "m_ctype.h" #include "myisampack.h" /* diff --git a/include/myisam.h b/include/myisam.h index 07e8346f981..99c8c8d73ae 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -334,6 +334,7 @@ typedef struct st_mi_sort_param uchar **sort_keys; byte *rec_buff; void *wordlist, *wordptr; + MEM_ROOT wordroot; char *record; MY_TMPDIR *tmpdir; -- cgit v1.2.1 From cd876fb11883f68f93027a70b5f3f99ad9234f27 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Aug 2006 19:19:47 +0200 Subject: amd64 atomic ops lock-free alloc (WL#3229), lock-free hash (WL#3230) bit functions made inline include/Makefile.am: lf.h added mysys/Makefile.am: lf_hash.c lf_dynarray.c lf_alloc-pin.c include/atomic/nolock.h: amd64 atomic ops include/atomic/rwlock.h: s/rw_lock/mutex/g include/atomic/x86-gcc.h: amd64 atomic ops try PAUSE include/my_global.h: STATIC_INLINE mysys/mf_keycache.c: make bit functions inline mysys/my_atomic.c: STATIC_INLINE mysys/my_bitmap.c: make bit functions inline sql/ha_myisam.cc: make bit functions inline sql/item_func.cc: make bit functions inline include/my_atomic.h: STATIC_INLINE mysys/my_bit.c: make bit functions inline sql/sql_select.cc: make bit functions inline storage/myisam/mi_create.c: make bit functions inline storage/myisam/mi_test2.c: make bit functions inline storage/myisam/myisamchk.c: make bit functions inline mysys/my_init.c: thread_size moved to mysys sql/mysql_priv.h: thread_size moved to mysys sql/set_var.cc: thread_size moved to mysys include/my_sys.h: thread_size moved to mysys sql/mysqld.cc: thread_size moved to mysys sql/sql_parse.cc: thread_size moved to mysys sql/sql_test.cc: thread_size moved to mysys include/lf.h: dylf_dynarray refactored to remove 65536 elements limit mysys/lf_alloc-pin.c: dylf_dynarray refactored to remove 65536 elements limit mysys/lf_dynarray.c: dylf_dynarray refactored to remove 65536 elements limit mysys/lf_hash.c: dylf_dynarray refactored to remove 65536 elements limit unittest/mysys/my_atomic-t.c: fix to commit (remove debug code) --- include/Makefile.am | 2 +- include/atomic/nolock.h | 27 +++--- include/atomic/rwlock.h | 21 +++-- include/atomic/x86-gcc.h | 19 +++- include/lf.h | 238 +++++++++++++++++++++++++++++++++++++++++++++++ include/my_atomic.h | 14 ++- include/my_bit.h | 107 +++++++++++++++++++++ include/my_global.h | 2 + include/my_sys.h | 7 +- 9 files changed, 401 insertions(+), 36 deletions(-) create mode 100644 include/lf.h create mode 100644 include/my_bit.h (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index 26161b36ab8..fe0ac1be31a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -24,7 +24,7 @@ pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ mysql_time.h mysql/plugin.h $(BUILT_SOURCES) noinst_HEADERS = config-win.h config-netware.h \ - heap.h my_bitmap.h my_uctype.h \ + heap.h my_bitmap.h my_uctype.h lf.h \ myisam.h myisampack.h myisammrg.h ft_global.h\ mysys_err.h my_base.h help_start.h help_end.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \ diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h index 1151a334b06..21f41484ac9 100644 --- a/include/atomic/nolock.h +++ b/include/atomic/nolock.h @@ -14,19 +14,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#if defined(__i386__) || defined(_M_IX86) - -#ifdef MY_ATOMIC_MODE_DUMMY -# define LOCK "" -#else -# define LOCK "lock" -#endif - -#ifdef __GNUC__ -#include "x86-gcc.h" -#elif defined(_MSC_VER) -#include "x86-msvc.h" -#endif +#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) + +# ifdef MY_ATOMIC_MODE_DUMMY +# define LOCK "" +# else +# define LOCK "lock" +# endif + +# ifdef __GNUC__ +# include "x86-gcc.h" +# elif defined(_MSC_VER) +# error Broken! +# include "x86-msvc.h" +# endif #endif #ifdef make_atomic_cas_body diff --git a/include/atomic/rwlock.h b/include/atomic/rwlock.h index 12d0dd3f069..3d8edb9e27e 100644 --- a/include/atomic/rwlock.h +++ b/include/atomic/rwlock.h @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t; +typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t; #ifdef MY_ATOMIC_MODE_DUMMY /* @@ -32,13 +32,18 @@ typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t; #define my_atomic_rwlock_wrunlock(name) #define MY_ATOMIC_MODE "dummy (non-atomic)" #else -#define my_atomic_rwlock_destroy(name) pthread_rwlock_destroy(& (name)->rw) -#define my_atomic_rwlock_init(name) pthread_rwlock_init(& (name)->rw, 0) -#define my_atomic_rwlock_rdlock(name) pthread_rwlock_rdlock(& (name)->rw) -#define my_atomic_rwlock_wrlock(name) pthread_rwlock_wrlock(& (name)->rw) -#define my_atomic_rwlock_rdunlock(name) pthread_rwlock_unlock(& (name)->rw) -#define my_atomic_rwlock_wrunlock(name) pthread_rwlock_unlock(& (name)->rw) -#define MY_ATOMIC_MODE "rwlocks" +/* + we're using read-write lock macros but map them to mutex locks, and they're + faster. Still, having semantically rich API we can change the + underlying implementation, if necessary. +*/ +#define my_atomic_rwlock_destroy(name) pthread_mutex_destroy(& (name)->rw) +#define my_atomic_rwlock_init(name) pthread_mutex_init(& (name)->rw, 0) +#define my_atomic_rwlock_rdlock(name) pthread_mutex_lock(& (name)->rw) +#define my_atomic_rwlock_wrlock(name) pthread_mutex_lock(& (name)->rw) +#define my_atomic_rwlock_rdunlock(name) pthread_mutex_unlock(& (name)->rw) +#define my_atomic_rwlock_wrunlock(name) pthread_mutex_unlock(& (name)->rw) +#define MY_ATOMIC_MODE "mutex" #endif #define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav; diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index 5a72f318a61..3f0a82a9400 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -20,10 +20,18 @@ architectures support double-word (128-bit) cas. */ -#ifdef MY_ATOMIC_NO_XADD -#define MY_ATOMIC_MODE "gcc-x86" LOCK "-no-xadd" +#ifdef __x86_64__ +# ifdef MY_ATOMIC_NO_XADD +# define MY_ATOMIC_MODE "gcc-amd64" LOCK "-no-xadd" +# else +# define MY_ATOMIC_MODE "gcc-amd64" LOCK +# endif #else -#define MY_ATOMIC_MODE "gcc-x86" LOCK +# ifdef MY_ATOMIC_NO_XADD +# define MY_ATOMIC_MODE "gcc-x86" LOCK "-no-xadd" +# else +# define MY_ATOMIC_MODE "gcc-x86" LOCK +# endif #endif /* fix -ansi errors while maintaining readability */ @@ -54,6 +62,9 @@ asm volatile (LOCK "; cmpxchg %2, %0" \ : "+m" (*a), "+a" (ret): "r" (ret)) #define make_atomic_store_body(S) \ - asm volatile ("; xchg %0, %1;" : "+m" (*a) : "r" (v)) + asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v)) #endif +/* TODO test on intel whether the below helps. on AMD it makes no difference */ +//#define LF_BACKOFF ({asm volatile ("rep; nop"); 1; }) + diff --git a/include/lf.h b/include/lf.h new file mode 100644 index 00000000000..299b4e07aa5 --- /dev/null +++ b/include/lf.h @@ -0,0 +1,238 @@ + +/* + TODO + 1. copyright + 6. reduce the number of memory barriers +*/ + +#ifndef _lf_h +#define _lf_h + +#include + +/* + Generic helpers +*/ + +#define lock_wrap(f,t,proto_args, args, lock) \ +t _ ## f proto_args; \ +static inline t f proto_args \ +{ \ + t ret; \ + my_atomic_rwlock_wrlock(lock); \ + ret= _ ## f args; \ + my_atomic_rwlock_wrunlock(lock); \ + return ret; \ +} + +#define lock_wrap_void(f,proto_args, args, lock) \ +void _ ## f proto_args; \ +static inline void f proto_args \ +{ \ + my_atomic_rwlock_wrlock(lock); \ + _ ## f args; \ + my_atomic_rwlock_wrunlock(lock); \ +} + +#define nolock_wrap(f,t,proto_args, args) \ +t _ ## f proto_args; \ +static inline t f proto_args \ +{ \ + return _ ## f args; \ +} + +#define nolock_wrap_void(f,proto_args, args) \ +void _ ## f proto_args; \ +static inline void f proto_args \ +{ \ + _ ## f args; \ +} + +/* + dynamic array + + 4 levels of 256 elements each mean 4311810304 elements in an array - it + should be enough for a while +*/ +#define LF_DYNARRAY_LEVEL_LENGTH 256 +#define LF_DYNARRAY_LEVELS 4 + +typedef struct { + void * volatile level[LF_DYNARRAY_LEVELS]; + uint size_of_element; + my_atomic_rwlock_t lock; +} LF_DYNARRAY; + +typedef int (*lf_dynarray_func)(void *, void *); + +void lf_dynarray_init(LF_DYNARRAY *array, uint element_size); +void lf_dynarray_end(LF_DYNARRAY *array); + +nolock_wrap(lf_dynarray_nr, int, + (LF_DYNARRAY *array, void *el), + (array,el)); + +nolock_wrap(lf_dynarray_value, void *, + (LF_DYNARRAY *array, uint idx), + (array,idx)); + +lock_wrap(lf_dynarray_lvalue, void *, + (LF_DYNARRAY *array, uint idx), + (array,idx), + &array->lock); +nolock_wrap(lf_dynarray_iterate, int, + (LF_DYNARRAY *array, lf_dynarray_func func, void *arg), + (array,func,arg)); + +/* + pin manager for memory allocator +*/ + +#define LF_PINBOX_PINS 3 +#define LF_PURGATORY_SIZE 11 + +typedef void lf_pinbox_free_func(void *, void *); + +typedef struct { + LF_DYNARRAY pinstack; + lf_pinbox_free_func *free_func; + void * free_func_arg; + uint32 volatile pinstack_top_ver; /* this is a versioned pointer */ + uint32 volatile pins_in_stack; /* number of elements in array */ +} LF_PINBOX; + +/* we want sizeof(LF_PINS) to be close to 128 to avoid false sharing */ +typedef struct { + void * volatile pin[LF_PINBOX_PINS]; + void * purgatory[LF_PURGATORY_SIZE]; + LF_PINBOX *pinbox; + uint32 purgatory_count; + uint32 volatile link; + char pad[128-sizeof(uint32)*2 + -sizeof(void *)*(LF_PINBOX_PINS+LF_PURGATORY_SIZE+1)]; +} LF_PINS; + +#define lf_lock_by_pins(PINS) \ + my_atomic_rwlock_wrlock(&(PINS)->pinbox->pinstack.lock) +#define lf_unlock_by_pins(PINS) \ + my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinstack.lock) + +/* + compile-time assert, to require "no less than N" pins + it's enough if it'll fail on at least one compiler, so + we'll enable it on GCC only, which supports zero-length arrays. +*/ +#if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG) +#define LF_REQUIRE_PINS(N) \ + static const char require_pins[LF_PINBOX_PINS-N]; \ + static const int LF_NUM_PINS_IN_THIS_FILE=N; +#define _lf_pin(PINS, PIN, ADDR) \ + ( \ + my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)), \ + assert(PIN < LF_NUM_PINS_IN_THIS_FILE) \ + ) +#else +#define LF_REQUIRE_PINS(N) +#define _lf_pin(PINS, PIN, ADDR) my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) +#endif + +#define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL) +#define lf_pin(PINS, PIN, ADDR) \ + do { \ + lf_lock_pins(PINS); \ + _lf_pin(PINS, PIN, ADDR); \ + lf_unlock_pins(PINS); \ + } while (0) +#define lf_unpin(PINS, PIN) lf_pin(PINS, PIN, NULL) + +void lf_pinbox_init(LF_PINBOX *pinbox, lf_pinbox_free_func *free_func, + void * free_func_arg); +void lf_pinbox_end(LF_PINBOX *pinbox); + +lock_wrap(lf_pinbox_get_pins, LF_PINS *, + (LF_PINBOX *pinbox), + (pinbox), + &pinbox->pinstack.lock); +lock_wrap_void(lf_pinbox_put_pins, + (LF_PINS *pins), + (pins), + &pins->pinbox->pinstack.lock); +#if 0 +lock_wrap_void(lf_pinbox_real_free, + (LF_PINS *pins), + (pins), + &pins->pinbox->pinstack.lock); +#endif +lock_wrap_void(lf_pinbox_free, + (LF_PINS *pins, void *addr), + (pins,addr), + &pins->pinbox->pinstack.lock); + +/* + memory allocator +*/ + +typedef struct st_lf_allocator { + LF_PINBOX pinbox; + void * volatile top; + uint element_size; + uint32 volatile mallocs; +} LF_ALLOCATOR; + +void lf_alloc_init(LF_ALLOCATOR *allocator, uint size); +void lf_alloc_end(LF_ALLOCATOR *allocator); +uint lf_alloc_in_pool(LF_ALLOCATOR *allocator); +#define _lf_alloc_free(PINS, PTR) _lf_pinbox_free((PINS), (PTR)) +#define lf_alloc_free(PINS, PTR) lf_pinbox_free((PINS), (PTR)) +#define _lf_alloc_get_pins(ALLOC) _lf_pinbox_get_pins(&(ALLOC)->pinbox) +#define lf_alloc_get_pins(ALLOC) lf_pinbox_get_pins(&(ALLOC)->pinbox) +#define _lf_alloc_put_pins(PINS) _lf_pinbox_put_pins(PINS) +#define lf_alloc_put_pins(PINS) lf_pinbox_put_pins(PINS) +#define lf_alloc_real_free(ALLOC,ADDR) my_free((gptr)(ADDR), MYF(0)) + +lock_wrap(lf_alloc_new, void *, + (LF_PINS *pins), + (pins), + &pins->pinbox->pinstack.lock); + +/* + extendible hash +*/ +#include + +#define LF_HASH_UNIQUE 1 + +typedef struct { + LF_DYNARRAY array; /* hash itself */ + LF_ALLOCATOR alloc; /* allocator for elements */ + hash_get_key get_key; /* see HASH */ + CHARSET_INFO *charset; /* see HASH */ + uint key_offset, key_length; /* see HASH */ + uint element_size, flags; /* LF_HASH_UNIQUE, etc */ + int32 volatile size; /* size of array */ + int32 volatile count; /* number of elements in the hash */ +} LF_HASH; + +void lf_hash_init(LF_HASH *hash, uint element_size, uint flags, + uint key_offset, uint key_length, hash_get_key get_key, + CHARSET_INFO *charset); +void lf_hash_end(LF_HASH *hash); +int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data); +int lf_hash_search(LF_HASH *hash, LF_PINS *pins, const uchar *key, uint keylen); +int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const uchar *key, uint keylen); +#define _lf_hash_get_pins(HASH) _lf_alloc_get_pins(&(HASH)->alloc) +#define lf_hash_get_pins(HASH) lf_alloc_get_pins(&(HASH)->alloc) +#define _lf_hash_put_pins(PINS) _lf_pinbox_put_pins(PINS) +#define lf_hash_put_pins(PINS) lf_pinbox_put_pins(PINS) + +/* + cleanup +*/ + +#undef lock_wrap_void +#undef lock_wrap +#undef nolock_wrap_void +#undef nolock_wrap + +#endif + diff --git a/include/my_atomic.h b/include/my_atomic.h index 9a319f84451..d3e4e0055d3 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -36,7 +36,7 @@ #ifdef HAVE_INLINE #define make_atomic_add(S) \ -static inline int ## S my_atomic_add ## S( \ +STATIC_INLINE int ## S my_atomic_add ## S( \ int ## S volatile *a, int ## S v) \ { \ make_atomic_add_body(S); \ @@ -44,7 +44,7 @@ static inline int ## S my_atomic_add ## S( \ } #define make_atomic_swap(S) \ -static inline int ## S my_atomic_swap ## S( \ +STATIC_INLINE int ## S my_atomic_swap ## S( \ int ## S volatile *a, int ## S v) \ { \ make_atomic_swap_body(S); \ @@ -52,7 +52,7 @@ static inline int ## S my_atomic_swap ## S( \ } #define make_atomic_cas(S) \ -static inline int my_atomic_cas ## S(int ## S volatile *a, \ +STATIC_INLINE int my_atomic_cas ## S(int ## S volatile *a, \ int ## S *cmp, int ## S set) \ { \ int8 ret; \ @@ -61,7 +61,7 @@ static inline int my_atomic_cas ## S(int ## S volatile *a, \ } #define make_atomic_load(S) \ -static inline int ## S my_atomic_load ## S(int ## S volatile *a) \ +STATIC_INLINE int ## S my_atomic_load ## S(int ## S volatile *a) \ { \ int ## S ret; \ make_atomic_load_body(S); \ @@ -69,7 +69,7 @@ static inline int ## S my_atomic_load ## S(int ## S volatile *a) \ } #define make_atomic_store(S) \ -static inline void my_atomic_store ## S( \ +STATIC_INLINE void my_atomic_store ## S( \ int ## S volatile *a, int ## S v) \ { \ make_atomic_store_body(S); \ @@ -135,6 +135,10 @@ make_atomic_swap(ptr) #undef _atomic_h_cleanup_ #endif +#ifndef LF_BACKOFF +#define LF_BACKOFF (1) +#endif + #if SIZEOF_CHARP == SIZEOF_INT typedef int intptr; #elif SIZEOF_CHARP == SIZEOF_LONG diff --git a/include/my_bit.h b/include/my_bit.h new file mode 100644 index 00000000000..71bbe2d4ba3 --- /dev/null +++ b/include/my_bit.h @@ -0,0 +1,107 @@ +/* + Some useful bit functions +*/ + +#ifdef HAVE_INLINE + +extern const char _my_bits_nbits[256]; +extern const uchar _my_bits_reverse_table[256]; + +/* + Find smallest X in 2^X >= value + This can be used to divide a number with value by doing a shift instead +*/ + +STATIC_INLINE uint my_bit_log2(ulong value) +{ + uint bit; + for (bit=0 ; value > 1 ; value>>=1, bit++) ; + return bit; +} + +STATIC_INLINE uint my_count_bits(ulonglong v) +{ +#if SIZEOF_LONG_LONG > 4 + /* The following code is a bit faster on 16 bit machines than if we would + only shift v */ + ulong v2=(ulong) (v >> 32); + return (uint) (uchar) (_my_bits_nbits[(uchar) v] + + _my_bits_nbits[(uchar) (v >> 8)] + + _my_bits_nbits[(uchar) (v >> 16)] + + _my_bits_nbits[(uchar) (v >> 24)] + + _my_bits_nbits[(uchar) (v2)] + + _my_bits_nbits[(uchar) (v2 >> 8)] + + _my_bits_nbits[(uchar) (v2 >> 16)] + + _my_bits_nbits[(uchar) (v2 >> 24)]); +#else + return (uint) (uchar) (_my_bits_nbits[(uchar) v] + + _my_bits_nbits[(uchar) (v >> 8)] + + _my_bits_nbits[(uchar) (v >> 16)] + + _my_bits_nbits[(uchar) (v >> 24)]); +#endif +} + +STATIC_INLINE uint my_count_bits_ushort(ushort v) +{ + return _my_bits_nbits[v]; +} + + +/* + Next highest power of two + + SYNOPSIS + my_round_up_to_next_power() + v Value to check + + RETURN + Next or equal power of 2 + Note: 0 will return 0 + + NOTES + Algorithm by Sean Anderson, according to: + http://graphics.stanford.edu/~seander/bithacks.html + (Orignal code public domain) + + Comments shows how this works with 01100000000000000000000000001011 +*/ + +STATIC_INLINE uint32 my_round_up_to_next_power(uint32 v) +{ + v--; /* 01100000000000000000000000001010 */ + v|= v >> 1; /* 01110000000000000000000000001111 */ + v|= v >> 2; /* 01111100000000000000000000001111 */ + v|= v >> 4; /* 01111111110000000000000000001111 */ + v|= v >> 8; /* 01111111111111111100000000001111 */ + v|= v >> 16; /* 01111111111111111111111111111111 */ + return v+1; /* 10000000000000000000000000000000 */ +} + +STATIC_INLINE uint32 my_clear_highest_bit(uint32 v) +{ + uint32 w=v >> 1; + w|= w >> 1; + w|= w >> 2; + w|= w >> 4; + w|= w >> 8; + w|= w >> 16; + return v & w; +} + +STATIC_INLINE uint32 my_reverse_bits(uint key) +{ + return + (_my_bits_reverse_table[ key & 255] << 24) | + (_my_bits_reverse_table[(key>> 8) & 255] << 16) | + (_my_bits_reverse_table[(key>>16) & 255] << 8) | + _my_bits_reverse_table[(key>>24) ]; +} + +#else +extern uint my_bit_log2(ulong value); +extern uint32 my_round_up_to_next_power(uint32 v); +uint32 my_clear_highest_bit(uint32 v); +uint32 my_reverse_bits(uint key); +extern uint my_count_bits(ulonglong v); +extern uint my_count_bits_ushort(ushort v); +#endif diff --git a/include/my_global.h b/include/my_global.h index 21b2251af1d..563ef379252 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -192,6 +192,8 @@ #endif #undef inline_test_2 #undef inline_test_1 +/* helper macro for "instantiating" inline functions */ +#define STATIC_INLINE static inline /* The following macros are used to control inlining a bit more than diff --git a/include/my_sys.h b/include/my_sys.h index 2dc4053f70d..81e5380be96 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -216,6 +216,7 @@ extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags); extern int (*fatal_error_handler_hook)(uint my_err, const char *str, myf MyFlags); extern uint my_file_limit; +extern ulong my_thread_stack_size; #ifdef HAVE_LARGE_PAGES extern my_bool my_use_large_pages; @@ -821,10 +822,6 @@ extern int packfrm(const void *, uint, const void **, uint *); extern int unpackfrm(const void **, uint *, const void *); extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count); -extern uint my_bit_log2(ulong value); -extern uint32 my_round_up_to_next_power(uint32 v); -extern uint my_count_bits(ulonglong v); -extern uint my_count_bits_ushort(ushort v); extern void my_sleep(ulong m_seconds); extern ulong crc32(ulong crc, const uchar *buf, uint len); extern uint my_set_max_open_files(uint files); @@ -840,7 +837,7 @@ extern int my_getncpus(); #ifndef MAP_NOSYNC #define MAP_NOSYNC 0 #endif -#ifndef MAP_NORESERVE +#ifndef MAP_NORESERVE #define MAP_NORESERVE 0 /* For irix and AIX */ #endif -- cgit v1.2.1 From 74d050d000ff9db79e36931988386fe7988f8dd2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Aug 2006 15:20:58 +0200 Subject: maria transaction manager with unit tests include/lf.h: few lf API changes mysys/lf_alloc-pin.c: few lf API changes mysys/lf_dynarray.c: few lf API changes mysys/lf_hash.c: few lf API changes storage/maria/Makefile.am: transaction manager unittest/Makefile.am: maria transaction manager unittest/mysys/my_atomic-t.c: ensure that values are positive storage/maria/trxman.h: New BitKeeper file ``storage/maria/trxman.h'' unittest/maria/Makefile.am: New BitKeeper file ``unittest/maria/Makefile.am'' unittest/maria/trxman-t.c: New BitKeeper file ``unittest/maria/trxman-t.c'' storage/maria/trxman.c: comment clarified --- include/lf.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/lf.h b/include/lf.h index 299b4e07aa5..6a5047f6052 100644 --- a/include/lf.h +++ b/include/lf.h @@ -66,7 +66,7 @@ typedef struct { typedef int (*lf_dynarray_func)(void *, void *); void lf_dynarray_init(LF_DYNARRAY *array, uint element_size); -void lf_dynarray_end(LF_DYNARRAY *array); +void lf_dynarray_destroy(LF_DYNARRAY *array); nolock_wrap(lf_dynarray_nr, int, (LF_DYNARRAY *array, void *el), @@ -139,15 +139,15 @@ typedef struct { #define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL) #define lf_pin(PINS, PIN, ADDR) \ do { \ - lf_lock_pins(PINS); \ + lf_lock_by_pins(PINS); \ _lf_pin(PINS, PIN, ADDR); \ - lf_unlock_pins(PINS); \ + lf_unlock_by_pins(PINS); \ } while (0) #define lf_unpin(PINS, PIN) lf_pin(PINS, PIN, NULL) void lf_pinbox_init(LF_PINBOX *pinbox, lf_pinbox_free_func *free_func, void * free_func_arg); -void lf_pinbox_end(LF_PINBOX *pinbox); +void lf_pinbox_destroy(LF_PINBOX *pinbox); lock_wrap(lf_pinbox_get_pins, LF_PINS *, (LF_PINBOX *pinbox), @@ -180,7 +180,7 @@ typedef struct st_lf_allocator { } LF_ALLOCATOR; void lf_alloc_init(LF_ALLOCATOR *allocator, uint size); -void lf_alloc_end(LF_ALLOCATOR *allocator); +void lf_alloc_destroy(LF_ALLOCATOR *allocator); uint lf_alloc_in_pool(LF_ALLOCATOR *allocator); #define _lf_alloc_free(PINS, PTR) _lf_pinbox_free((PINS), (PTR)) #define lf_alloc_free(PINS, PTR) lf_pinbox_free((PINS), (PTR)) @@ -216,10 +216,10 @@ typedef struct { void lf_hash_init(LF_HASH *hash, uint element_size, uint flags, uint key_offset, uint key_length, hash_get_key get_key, CHARSET_INFO *charset); -void lf_hash_end(LF_HASH *hash); +void lf_hash_destroy(LF_HASH *hash); int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data); -int lf_hash_search(LF_HASH *hash, LF_PINS *pins, const uchar *key, uint keylen); -int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const uchar *key, uint keylen); +void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen); +int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen); #define _lf_hash_get_pins(HASH) _lf_alloc_get_pins(&(HASH)->alloc) #define lf_hash_get_pins(HASH) lf_alloc_get_pins(&(HASH)->alloc) #define _lf_hash_put_pins(PINS) _lf_pinbox_put_pins(PINS) -- cgit v1.2.1 From fa793bca310a208242d315b763bb512c252cfa49 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Sep 2006 16:53:09 +0200 Subject: WL#3234 "Maria - control file manager": added checksum of the file. Now we have size + magic string + checksum to detect that all is ok. Plus misc fixes for "make dist" to work and the resulting tarball to build include/Makefile.am: adding pagecache.h to help the tarball build. The model of pagecache.h, keycache.h, is in pkginclude_HEADERS, wonder why. Adding pagecache.h to noinst_HEADERS for now. storage/maria/Makefile.am: adding ma_control_file.h to help the tarball build storage/maria/ma_control_file.c: adding a simple checksum to the control file. We protect against corruption of this file like this: - test size - test magic string at start - test checksum I also add some simple my_message() errors (to be changed to a better reporting later). storage/maria/ma_control_file.h: comments storage/maria/ma_control_file_test.c: test of wrong checksum in control file storage/maria/CMakeLists.txt: just to make "make dist" happy for now. --- include/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index e81fa3a6520..bf7dcd265be 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -33,7 +33,7 @@ noinst_HEADERS = config-win.h config-netware.h \ mysql_version.h.in my_handler.h my_time.h decimal.h \ my_vle.h my_user.h my_atomic.h atomic/nolock.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \ - my_libwrap.h + my_libwrap.h pagecache.h # mysql_version.h are generated CLEANFILES = mysql_version.h my_config.h readline openssl -- cgit v1.2.1 From c2872bafde6d6ec2444c293f7a8aa397eb1dbb59 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Oct 2006 11:37:27 +0200 Subject: push for trnman review (lockmanager still fails unit tests) BitKeeper/deleted/.del-Makefile.am~4375ae3d4de2bdf0: Delete: unittest/maria/Makefile.am configure.in: silence up configure warnings, don't generate unittest/maria/Makefile include/atomic/nolock.h: s/LOCK/LOCK_prefix/ include/atomic/x86-gcc.h: s/LOCK/LOCK_prefix/ include/atomic/x86-msvc.h: s/LOCK/LOCK_prefix/ include/lf.h: pin asserts, renames include/my_atomic.h: move cleanup include/my_bit.h: s/uint/uint32/ mysys/lf_dynarray.c: style fixes, split for() in two, remove if()s mysys/lf_hash.c: renames, minor fixes mysys/my_atomic.c: run-time assert -> compile-time assert storage/maria/Makefile.am: lockman here storage/maria/unittest/Makefile.am: new unit tests storage/maria/unittest/trnman-t.c: lots of changes storage/maria/lockman.c: many changes: second meaning of "blocker" portability: s/gettimeofday/my_getsystime/ move mutex/cond out of LOCK_OWNER - it creates a race condition that will be fixed in a separate changeset increment lm->count for every element, not only for distinct ones - because we cannot decrease it for distinct elements only :( storage/maria/lockman.h: move mutex/cond out of LOCK_OWNER storage/maria/trnman.c: move mutex/cond out of LOCK_OWNER atomic-ops to access short_trid_to_trn[] storage/maria/trnman.h: move mutex/cond out of LOCK_OWNER storage/maria/unittest/lockman-t.c: unit stress test --- include/atomic/nolock.h | 4 ++-- include/atomic/x86-gcc.h | 18 +++++++++--------- include/atomic/x86-msvc.h | 10 +++++----- include/lf.h | 14 ++++++++------ include/my_atomic.h | 10 +++++----- include/my_bit.h | 4 ++-- 6 files changed, 31 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h index 21f41484ac9..a696e008f03 100644 --- a/include/atomic/nolock.h +++ b/include/atomic/nolock.h @@ -17,9 +17,9 @@ #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) # ifdef MY_ATOMIC_MODE_DUMMY -# define LOCK "" +# define LOCK_prefix "" # else -# define LOCK "lock" +# define LOCK_prefix "lock" # endif # ifdef __GNUC__ diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index 3f0a82a9400..0be8fdf9244 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -22,15 +22,15 @@ #ifdef __x86_64__ # ifdef MY_ATOMIC_NO_XADD -# define MY_ATOMIC_MODE "gcc-amd64" LOCK "-no-xadd" +# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix "-no-xadd" # else -# define MY_ATOMIC_MODE "gcc-amd64" LOCK +# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix # endif #else # ifdef MY_ATOMIC_NO_XADD -# define MY_ATOMIC_MODE "gcc-x86" LOCK "-no-xadd" +# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix "-no-xadd" # else -# define MY_ATOMIC_MODE "gcc-x86" LOCK +# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix # endif #endif @@ -41,12 +41,12 @@ #ifndef MY_ATOMIC_NO_XADD #define make_atomic_add_body(S) \ - asm volatile (LOCK "; xadd %0, %1;" : "+r" (v) , "+m" (*a)) + asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a)) #endif #define make_atomic_swap_body(S) \ - asm volatile ("; xchg %0, %1;" : "+r" (v) , "+m" (*a)) + asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a)) #define make_atomic_cas_body(S) \ - asm volatile (LOCK "; cmpxchg %3, %0; setz %2;" \ + asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \ : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set)) #ifdef MY_ATOMIC_MODE_DUMMY @@ -55,11 +55,11 @@ #else /* Actually 32-bit reads/writes are always atomic on x86 - But we add LOCK here anyway to force memory barriers + But we add LOCK_prefix here anyway to force memory barriers */ #define make_atomic_load_body(S) \ ret=0; \ - asm volatile (LOCK "; cmpxchg %2, %0" \ + asm volatile (LOCK_prefix "; cmpxchg %2, %0" \ : "+m" (*a), "+a" (ret): "r" (ret)) #define make_atomic_store_body(S) \ asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v)) diff --git a/include/atomic/x86-msvc.h b/include/atomic/x86-msvc.h index d4024a854fb..8f3e55aaed7 100644 --- a/include/atomic/x86-msvc.h +++ b/include/atomic/x86-msvc.h @@ -26,19 +26,19 @@ #ifndef _atomic_h_cleanup_ #define _atomic_h_cleanup_ "atomic/x86-msvc.h" -#define MY_ATOMIC_MODE "msvc-x86" LOCK +#define MY_ATOMIC_MODE "msvc-x86" LOCK_prefix #define make_atomic_add_body(S) \ _asm { \ _asm mov reg_ ## S, v \ - _asm LOCK xadd *a, reg_ ## S \ + _asm LOCK_prefix xadd *a, reg_ ## S \ _asm movzx v, reg_ ## S \ } #define make_atomic_cas_body(S) \ _asm { \ _asm mov areg_ ## S, *cmp \ _asm mov reg2_ ## S, set \ - _asm LOCK cmpxchg *a, reg2_ ## S \ + _asm LOCK_prefix cmpxchg *a, reg2_ ## S \ _asm mov *cmp, areg_ ## S \ _asm setz al \ _asm movzx ret, al \ @@ -56,13 +56,13 @@ #else /* Actually 32-bit reads/writes are always atomic on x86 - But we add LOCK here anyway to force memory barriers + But we add LOCK_prefix here anyway to force memory barriers */ #define make_atomic_load_body(S) \ _asm { \ _asm mov areg_ ## S, 0 \ _asm mov reg2_ ## S, areg_ ## S \ - _asm LOCK cmpxchg *a, reg2_ ## S \ + _asm LOCK_prefix cmpxchg *a, reg2_ ## S \ _asm mov ret, areg_ ## S \ } #define make_atomic_store_body(S) \ diff --git a/include/lf.h b/include/lf.h index 6a5047f6052..4c6765b2d40 100644 --- a/include/lf.h +++ b/include/lf.h @@ -88,8 +88,8 @@ nolock_wrap(lf_dynarray_iterate, int, pin manager for memory allocator */ -#define LF_PINBOX_PINS 3 -#define LF_PURGATORY_SIZE 11 +#define LF_PINBOX_PINS 4 +#define LF_PURGATORY_SIZE 10 typedef void lf_pinbox_free_func(void *, void *); @@ -112,9 +112,9 @@ typedef struct { -sizeof(void *)*(LF_PINBOX_PINS+LF_PURGATORY_SIZE+1)]; } LF_PINS; -#define lf_lock_by_pins(PINS) \ +#define lf_rwlock_by_pins(PINS) \ my_atomic_rwlock_wrlock(&(PINS)->pinbox->pinstack.lock) -#define lf_unlock_by_pins(PINS) \ +#define lf_rwunlock_by_pins(PINS) \ my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinstack.lock) /* @@ -139,11 +139,13 @@ typedef struct { #define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL) #define lf_pin(PINS, PIN, ADDR) \ do { \ - lf_lock_by_pins(PINS); \ + lf_rwlock_by_pins(PINS); \ _lf_pin(PINS, PIN, ADDR); \ - lf_unlock_by_pins(PINS); \ + lf_rwunlock_by_pins(PINS); \ } while (0) #define lf_unpin(PINS, PIN) lf_pin(PINS, PIN, NULL) +#define _lf_assert_pin(PINS, PIN) assert((PINS)->pin[PIN] != 0) +#define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN]==0) void lf_pinbox_init(LF_PINBOX *pinbox, lf_pinbox_free_func *free_func, void * free_func_arg); diff --git a/include/my_atomic.h b/include/my_atomic.h index d3e4e0055d3..921b55e68a2 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -118,6 +118,11 @@ make_atomic_swap(16) make_atomic_swap(32) make_atomic_swap(ptr) +#ifdef _atomic_h_cleanup_ +#include _atomic_h_cleanup_ +#undef _atomic_h_cleanup_ +#endif + #undef make_atomic_add #undef make_atomic_cas #undef make_atomic_load @@ -130,11 +135,6 @@ make_atomic_swap(ptr) #undef make_atomic_swap_body #undef intptr -#ifdef _atomic_h_cleanup_ -#include _atomic_h_cleanup_ -#undef _atomic_h_cleanup_ -#endif - #ifndef LF_BACKOFF #define LF_BACKOFF (1) #endif diff --git a/include/my_bit.h b/include/my_bit.h index 71bbe2d4ba3..58e8bb39683 100644 --- a/include/my_bit.h +++ b/include/my_bit.h @@ -88,7 +88,7 @@ STATIC_INLINE uint32 my_clear_highest_bit(uint32 v) return v & w; } -STATIC_INLINE uint32 my_reverse_bits(uint key) +STATIC_INLINE uint32 my_reverse_bits(uint32 key) { return (_my_bits_reverse_table[ key & 255] << 24) | @@ -101,7 +101,7 @@ STATIC_INLINE uint32 my_reverse_bits(uint key) extern uint my_bit_log2(ulong value); extern uint32 my_round_up_to_next_power(uint32 v); uint32 my_clear_highest_bit(uint32 v); -uint32 my_reverse_bits(uint key); +uint32 my_reverse_bits(uint32 key); extern uint my_count_bits(ulonglong v); extern uint my_count_bits_ushort(ushort v); #endif -- cgit v1.2.1 From 12a55aeabc353fdc1c3829ddd8baacb142160c80 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Oct 2006 17:24:07 +0200 Subject: lock manager passed unit tests storage/maria/trnman.c: comments include/my_dbug.h: make DBUG_ASSERT always a statement storage/maria/lockman.h: comments include/lf.h: lf_pinbox - don't use a fixed-size purgatory. mysys/lf_alloc-pin.c: lf_pinbox - don't use a fixed-size purgatory. mysys/lf_hash.c: lf_pinbox - don't use a fixed-size purgatory. storage/maria/lockman.c: removed IGNORE_ME/UPGDARED matching - it was wrong in the first place. updated for "lf_pinbox - don't use a fixed-size purgatory" storage/maria/unittest/lockman-t.c: IGNORE_ME/UPGRADED pair counting bugtest. more tests unittest/mysys/my_atomic-t.c: lf_pinbox - don't use a fixed-size purgatory. --- include/lf.h | 15 ++++++++------- include/my_dbug.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/lf.h b/include/lf.h index 4c6765b2d40..45c5f109e1c 100644 --- a/include/lf.h +++ b/include/lf.h @@ -96,20 +96,21 @@ typedef void lf_pinbox_free_func(void *, void *); typedef struct { LF_DYNARRAY pinstack; lf_pinbox_free_func *free_func; - void * free_func_arg; + void *free_func_arg; + uint free_ptr_offset; uint32 volatile pinstack_top_ver; /* this is a versioned pointer */ uint32 volatile pins_in_stack; /* number of elements in array */ } LF_PINBOX; -/* we want sizeof(LF_PINS) to be close to 128 to avoid false sharing */ +/* we want sizeof(LF_PINS) to be 128 to avoid false sharing */ typedef struct { void * volatile pin[LF_PINBOX_PINS]; - void * purgatory[LF_PURGATORY_SIZE]; LF_PINBOX *pinbox; + void *purgatory; uint32 purgatory_count; uint32 volatile link; char pad[128-sizeof(uint32)*2 - -sizeof(void *)*(LF_PINBOX_PINS+LF_PURGATORY_SIZE+1)]; + -sizeof(void *)*(LF_PINBOX_PINS+2)]; } LF_PINS; #define lf_rwlock_by_pins(PINS) \ @@ -147,8 +148,8 @@ typedef struct { #define _lf_assert_pin(PINS, PIN) assert((PINS)->pin[PIN] != 0) #define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN]==0) -void lf_pinbox_init(LF_PINBOX *pinbox, lf_pinbox_free_func *free_func, - void * free_func_arg); +void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset, + lf_pinbox_free_func *free_func, void * free_func_arg); void lf_pinbox_destroy(LF_PINBOX *pinbox); lock_wrap(lf_pinbox_get_pins, LF_PINS *, @@ -181,7 +182,7 @@ typedef struct st_lf_allocator { uint32 volatile mallocs; } LF_ALLOCATOR; -void lf_alloc_init(LF_ALLOCATOR *allocator, uint size); +void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset); void lf_alloc_destroy(LF_ALLOCATOR *allocator); uint lf_alloc_in_pool(LF_ALLOCATOR *allocator); #define _lf_alloc_free(PINS, PTR) _lf_pinbox_free((PINS), (PTR)) diff --git a/include/my_dbug.h b/include/my_dbug.h index a397861c1af..e3fdf9d6461 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -100,7 +100,7 @@ extern FILE *_db_fp_(void); #define DBUG_LONGJMP(a1) longjmp(a1) #define DBUG_DUMP(keyword,a1,a2) #define DBUG_END() -#define DBUG_ASSERT(A) +#define DBUG_ASSERT(A) do { } while(0) #define DBUG_LOCK_FILE #define DBUG_FILE (stderr) #define DBUG_UNLOCK_FILE -- cgit v1.2.1 From aea73116c14da8e946422de8e49c93acc85817d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Oct 2006 12:21:30 +0200 Subject: post-review fixes (style) include/lf.h: comments --- include/lf.h | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/lf.h b/include/lf.h index 45c5f109e1c..3a3b5b28ade 100644 --- a/include/lf.h +++ b/include/lf.h @@ -1,9 +1,18 @@ +/* Copyright (C) 2006 MySQL AB -/* - TODO - 1. copyright - 6. reduce the number of memory barriers -*/ + 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 */ #ifndef _lf_h #define _lf_h @@ -11,7 +20,8 @@ #include /* - Generic helpers + Helpers to define both func() and _func(), where + func() is a _func() protected by my_atomic_rwlock_wrlock() */ #define lock_wrap(f,t,proto_args, args, lock) \ @@ -49,7 +59,7 @@ static inline void f proto_args \ } /* - dynamic array + wait-free dynamic array, see lf_dynarray.c 4 levels of 256 elements each mean 4311810304 elements in an array - it should be enough for a while @@ -68,14 +78,9 @@ typedef int (*lf_dynarray_func)(void *, void *); void lf_dynarray_init(LF_DYNARRAY *array, uint element_size); void lf_dynarray_destroy(LF_DYNARRAY *array); -nolock_wrap(lf_dynarray_nr, int, - (LF_DYNARRAY *array, void *el), - (array,el)); - nolock_wrap(lf_dynarray_value, void *, (LF_DYNARRAY *array, uint idx), (array,idx)); - lock_wrap(lf_dynarray_lvalue, void *, (LF_DYNARRAY *array, uint idx), (array,idx), @@ -85,7 +90,7 @@ nolock_wrap(lf_dynarray_iterate, int, (array,func,arg)); /* - pin manager for memory allocator + pin manager for memory allocator, lf_alloc-pin.c */ #define LF_PINBOX_PINS 4 @@ -102,13 +107,13 @@ typedef struct { uint32 volatile pins_in_stack; /* number of elements in array */ } LF_PINBOX; -/* we want sizeof(LF_PINS) to be 128 to avoid false sharing */ typedef struct { void * volatile pin[LF_PINBOX_PINS]; LF_PINBOX *pinbox; void *purgatory; uint32 purgatory_count; uint32 volatile link; +/* we want sizeof(LF_PINS) to be 128 to avoid false sharing */ char pad[128-sizeof(uint32)*2 -sizeof(void *)*(LF_PINBOX_PINS+2)]; } LF_PINS; @@ -160,19 +165,13 @@ lock_wrap_void(lf_pinbox_put_pins, (LF_PINS *pins), (pins), &pins->pinbox->pinstack.lock); -#if 0 -lock_wrap_void(lf_pinbox_real_free, - (LF_PINS *pins), - (pins), - &pins->pinbox->pinstack.lock); -#endif lock_wrap_void(lf_pinbox_free, (LF_PINS *pins, void *addr), (pins,addr), &pins->pinbox->pinstack.lock); /* - memory allocator + memory allocator, lf_alloc-pin.c */ typedef struct st_lf_allocator { @@ -199,7 +198,7 @@ lock_wrap(lf_alloc_new, void *, &pins->pinbox->pinstack.lock); /* - extendible hash + extendible hash, lf_hash.c */ #include -- cgit v1.2.1 From fb818dd7b0be3b4facd159de14bc3d9afcbcf16e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 Oct 2006 14:02:18 +0200 Subject: more post-review fixes - comments, renames, error checks in unit tests concurrency bug in lock manager include/my_global.h: compile-time assert macro mysys/my_atomic.c: use compile_time_assert() macro storage/maria/lockman.c: bug in concurrent lockdelete (with retries) storage/maria/trnman.c: more post-review fixes - comments, renames storage/maria/trnman.h: more post-review fixes - comments storage/maria/unittest/lockman-t.c: friendlier error checks storage/maria/unittest/trnman-t.c: friendlier error checks --- include/my_global.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/my_global.h b/include/my_global.h index 7f57b43f89f..7f7b502e1a7 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -428,6 +428,13 @@ C_MODE_END */ #include +/* an assert that works at compile-time. only for constant expression */ +#define compile_time_assert(X) \ + do \ + { \ + char compile_time_assert[(X) ? 1 : -1]; \ + } while(0) + /* Go around some bugs in different OS and compilers */ #if defined (HPUX11) && defined(_LARGEFILE_SOURCE) #define _LARGEFILE64_SOURCE -- cgit v1.2.1 From d1852da743be3a636bba35114d1342b4b11039f0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 21 Oct 2006 20:06:56 +0200 Subject: less confusing and more correct name for my_atomic_swap --- include/atomic/rwlock.h | 2 +- include/atomic/x86-gcc.h | 2 +- include/atomic/x86-msvc.h | 2 +- include/my_atomic.h | 22 +++++++++++----------- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/atomic/rwlock.h b/include/atomic/rwlock.h index 3d8edb9e27e..5a3ca5a434e 100644 --- a/include/atomic/rwlock.h +++ b/include/atomic/rwlock.h @@ -47,7 +47,7 @@ typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t; #endif #define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav; -#define make_atomic_swap_body(S) int ## S sav; sav= *a; *a= v; v=sav; +#define make_atomic_fas_body(S) int ## S sav; sav= *a; *a= v; v=sav; #define make_atomic_cas_body(S) if ((ret= (*a == *cmp))) *a= set; else *cmp=*a; #define make_atomic_load_body(S) ret= *a; #define make_atomic_store_body(S) *a= v; diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index 0be8fdf9244..cd84faeee31 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -43,7 +43,7 @@ #define make_atomic_add_body(S) \ asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a)) #endif -#define make_atomic_swap_body(S) \ +#define make_atomic_fas_body(S) \ asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a)) #define make_atomic_cas_body(S) \ asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \ diff --git a/include/atomic/x86-msvc.h b/include/atomic/x86-msvc.h index 8f3e55aaed7..bd5a7fdd96c 100644 --- a/include/atomic/x86-msvc.h +++ b/include/atomic/x86-msvc.h @@ -43,7 +43,7 @@ _asm setz al \ _asm movzx ret, al \ } -#define make_atomic_swap_body(S) \ +#define make_atomic_fas_body(S) \ _asm { \ _asm mov reg_ ## S, v \ _asm xchg *a, reg_ ## S \ diff --git a/include/my_atomic.h b/include/my_atomic.h index 921b55e68a2..aad69295998 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -43,11 +43,11 @@ STATIC_INLINE int ## S my_atomic_add ## S( \ return v; \ } -#define make_atomic_swap(S) \ -STATIC_INLINE int ## S my_atomic_swap ## S( \ +#define make_atomic_fas(S) \ +STATIC_INLINE int ## S my_atomic_fas ## S( \ int ## S volatile *a, int ## S v) \ { \ - make_atomic_swap_body(S); \ + make_atomic_fas_body(S); \ return v; \ } @@ -80,8 +80,8 @@ STATIC_INLINE void my_atomic_store ## S( \ #define make_atomic_add(S) \ extern int ## S my_atomic_add ## S(int ## S volatile *a, int ## S v); -#define make_atomic_swap(S) \ -extern int ## S my_atomic_swap ## S(int ## S volatile *a, int ## S v); +#define make_atomic_fas(S) \ +extern int ## S my_atomic_fas ## S(int ## S volatile *a, int ## S v); #define make_atomic_cas(S) \ extern int my_atomic_cas ## S(int ## S volatile *a, int ## S *cmp, int ## S set); @@ -113,10 +113,10 @@ make_atomic_store(16) make_atomic_store(32) make_atomic_store(ptr) -make_atomic_swap( 8) -make_atomic_swap(16) -make_atomic_swap(32) -make_atomic_swap(ptr) +make_atomic_fas( 8) +make_atomic_fas(16) +make_atomic_fas(32) +make_atomic_fas(ptr) #ifdef _atomic_h_cleanup_ #include _atomic_h_cleanup_ @@ -127,12 +127,12 @@ make_atomic_swap(ptr) #undef make_atomic_cas #undef make_atomic_load #undef make_atomic_store -#undef make_atomic_swap +#undef make_atomic_fas #undef make_atomic_add_body #undef make_atomic_cas_body #undef make_atomic_load_body #undef make_atomic_store_body -#undef make_atomic_swap_body +#undef make_atomic_fas_body #undef intptr #ifndef LF_BACKOFF -- cgit v1.2.1 From ce707d9f7fb589a1a928ccc58b34b03a9a3a48d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 23 Oct 2006 15:13:51 +0200 Subject: include/my_atomic.h: comment include/my_atomic.h: comment --- include/my_atomic.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include') diff --git a/include/my_atomic.h b/include/my_atomic.h index aad69295998..8efad2802c0 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -14,6 +14,40 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* + This header defines five atomic operations: + + my_atomic_add#(&var, what) + add 'what' to *var, and return the old value of *var + + my_atomic_fas#(&var, what) + 'Fetch And Store' + store 'what' in *var, and return the old value of *var + + my_atomic_cas#(&var, &old, new) + 'Compare And Swap' + if *var is equal to *old, then store 'new' in *var, and return TRUE + otherwise store *var in *old, and return FALSE + + my_atomic_load#(&var) + return *var + + my_atomic_store#(&var, what) + store 'what' in *var + + '#' is substituted by a size suffix - 8, 16, 32, or ptr + (e.g. my_atomic_add8, my_atomic_fas32, my_atomic_casptr). + + NOTE This operations are not always atomic, so they always must be + enclosed in my_atomic_rwlock_rdlock(lock)/my_atomic_rwlock_rdunlock(lock) + or my_atomic_rwlock_wrlock(lock)/my_atomic_rwlock_wrunlock(lock). + Hint: if a code block makes intensive use of atomic ops, it make sense + to take/release rwlock once for the whole block, not for every statement. + + On architectures where these operations are really atomic, rwlocks will + be optimized away. +*/ + #ifndef my_atomic_rwlock_init #define intptr void * -- cgit v1.2.1 From e5858e1fb429617bf16f94031b660a3694e2acdd Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Nov 2006 00:26:29 +0200 Subject: postreview fixes fixed bug in the pagecache which lead to assertion in multithread test include/pagecache.h: post review fixes: - comments fixed - types fixed - keyword 'extern' added to all interface functions mysys/mf_pagecache.c: postreview fixes: - comments fixed and added - types fixed - typo fixed Added write locking flag set when we took a block from LRU and going to free it (to prevent locking/using it for write) mysys/test_pagecache_consist.c: pagecache size reduced (to be able reproduce problems found by Guilhem) typo in the comment fixed --- include/pagecache.h | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'include') diff --git a/include/pagecache.h b/include/pagecache.h index 018e695fa27..4d64070ad62 100644 --- a/include/pagecache.h +++ b/include/pagecache.h @@ -119,14 +119,14 @@ typedef struct st_pagecache ulonglong 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 hash_links_used; /* number of hash links taken from free links pool */ int disk_blocks; /* max number of blocks in the cache */ ulong blocks_used; /* maximum number of concurrently used blocks */ ulong blocks_unused; /* number of currently unused 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 */ + ulong blocks_available; /* number of blocks available in the LRU chain */ PAGECACHE_HASH_LINK **hash_root;/* arr. of entries into hash table buckets */ PAGECACHE_HASH_LINK *hash_link_root;/* memory for hash table links */ PAGECACHE_HASH_LINK *free_hash_list;/* list of free hash links */ @@ -194,32 +194,32 @@ extern my_bool pagecache_write(PAGECACHE *pagecache, enum pagecache_page_pin pin, enum pagecache_write_mode write_mode, PAGECACHE_PAGE_LINK *link); -void pagecache_unlock_page(PAGECACHE *pagecache, - PAGECACHE_FILE *file, - maria_page_no_t pageno, - enum pagecache_page_lock lock, - enum pagecache_page_pin pin, - my_bool stamp_this_page, - LSN first_REDO_LSN_for_page); -void pagecache_unlock(PAGECACHE *pagecache, - PAGECACHE_PAGE_LINK *link, - enum pagecache_page_lock lock, - enum pagecache_page_pin pin, - my_bool stamp_this_page, - LSN first_REDO_LSN_for_page); -void pagecache_unpin_page(PAGECACHE *pagecache, - PAGECACHE_FILE *file, - maria_page_no_t pageno); -void pagecache_unpin(PAGECACHE *pagecache, - PAGECACHE_PAGE_LINK *link); +extern void pagecache_unlock_page(PAGECACHE *pagecache, + PAGECACHE_FILE *file, + maria_page_no_t pageno, + enum pagecache_page_lock lock, + enum pagecache_page_pin pin, + my_bool stamp_this_page, + LSN first_REDO_LSN_for_page); +extern void pagecache_unlock(PAGECACHE *pagecache, + PAGECACHE_PAGE_LINK *link, + enum pagecache_page_lock lock, + enum pagecache_page_pin pin, + my_bool stamp_this_page, + LSN first_REDO_LSN_for_page); +extern void pagecache_unpin_page(PAGECACHE *pagecache, + PAGECACHE_FILE *file, + maria_page_no_t pageno); +extern void pagecache_unpin(PAGECACHE *pagecache, + PAGECACHE_PAGE_LINK *link); extern int flush_pagecache_blocks(PAGECACHE *keycache, PAGECACHE_FILE *file, enum flush_type type); -my_bool pagecache_delete_page(PAGECACHE *pagecache, - PAGECACHE_FILE *file, - maria_page_no_t pageno, - enum pagecache_page_lock lock, - my_bool flush); +extern my_bool pagecache_delete_page(PAGECACHE *pagecache, + PAGECACHE_FILE *file, + maria_page_no_t pageno, + enum pagecache_page_lock lock, + my_bool flush); extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup); C_MODE_END -- cgit v1.2.1 From 915cebdd53fe5071dc9443a236a798764f504c22 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Nov 2006 15:40:08 +0100 Subject: post-review fixes. tablockman: fixed a bug in finding a blocker lock mysys/my_getsystime.c: this is no longer true storage/maria/lockman.h: post-review fixes storage/maria/tablockman.h: post-review fixes storage/maria/unittest/lockman-t.c: post-review fixes storage/maria/unittest/lockman1-t.c: post-review fixes storage/maria/unittest/lockman2-t.c: post-review fixes include/my_atomic.h: moved intptr definition to my_global.h storage/maria/tablockman.c: post-review fixes BUILD/SETUP.sh: add -DMY_LF_EXTRA_DEBUG to debug builds include/atomic/nolock.h: suppress warning include/my_global.h: suppress warning mysys/lf_alloc-pin.c: post-review fixes mysys/lf_dynarray.c: post-review fixes mysys/lf_hash.c: post-review fixes storage/maria/trnman.c: suppress warning include/lf.h: post-review fix --- include/atomic/nolock.h | 2 +- include/lf.h | 47 ++++++++++++++++++++++++++++++++--------------- include/my_atomic.h | 8 -------- include/my_global.h | 11 ++++++++++- 4 files changed, 43 insertions(+), 25 deletions(-) (limited to 'include') diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h index a696e008f03..9d367657a69 100644 --- a/include/atomic/nolock.h +++ b/include/atomic/nolock.h @@ -32,7 +32,7 @@ #ifdef make_atomic_cas_body -typedef struct { } my_atomic_rwlock_t; +typedef struct { } my_atomic_rwlock_t __attribute__ ((unused)); #define my_atomic_rwlock_destroy(name) #define my_atomic_rwlock_init(name) #define my_atomic_rwlock_rdlock(name) diff --git a/include/lf.h b/include/lf.h index 3a3b5b28ade..c7198ab75b6 100644 --- a/include/lf.h +++ b/include/lf.h @@ -24,7 +24,7 @@ func() is a _func() protected by my_atomic_rwlock_wrlock() */ -#define lock_wrap(f,t,proto_args, args, lock) \ +#define lock_wrap(f, t, proto_args, args, lock) \ t _ ## f proto_args; \ static inline t f proto_args \ { \ @@ -35,7 +35,7 @@ static inline t f proto_args \ return ret; \ } -#define lock_wrap_void(f,proto_args, args, lock) \ +#define lock_wrap_void(f, proto_args, args, lock) \ void _ ## f proto_args; \ static inline void f proto_args \ { \ @@ -44,14 +44,14 @@ static inline void f proto_args \ my_atomic_rwlock_wrunlock(lock); \ } -#define nolock_wrap(f,t,proto_args, args) \ +#define nolock_wrap(f, t, proto_args, args) \ t _ ## f proto_args; \ static inline t f proto_args \ { \ return _ ## f args; \ } -#define nolock_wrap_void(f,proto_args, args) \ +#define nolock_wrap_void(f, proto_args, args) \ void _ ## f proto_args; \ static inline void f proto_args \ { \ @@ -80,14 +80,14 @@ void lf_dynarray_destroy(LF_DYNARRAY *array); nolock_wrap(lf_dynarray_value, void *, (LF_DYNARRAY *array, uint idx), - (array,idx)); + (array, idx)); lock_wrap(lf_dynarray_lvalue, void *, (LF_DYNARRAY *array, uint idx), - (array,idx), + (array, idx), &array->lock); nolock_wrap(lf_dynarray_iterate, int, (LF_DYNARRAY *array, lf_dynarray_func func, void *arg), - (array,func,arg)); + (array, func, arg)); /* pin manager for memory allocator, lf_alloc-pin.c @@ -115,9 +115,14 @@ typedef struct { uint32 volatile link; /* we want sizeof(LF_PINS) to be 128 to avoid false sharing */ char pad[128-sizeof(uint32)*2 - -sizeof(void *)*(LF_PINBOX_PINS+2)]; + -sizeof(LF_PINBOX *) + -sizeof(void *)*(LF_PINBOX_PINS+1)]; } LF_PINS; +/* + shortcut macros to do an atomic_wrlock on a structure that uses pins + (e.g. lf_hash). +*/ #define lf_rwlock_by_pins(PINS) \ my_atomic_rwlock_wrlock(&(PINS)->pinbox->pinstack.lock) #define lf_rwunlock_by_pins(PINS) \ @@ -131,11 +136,11 @@ typedef struct { #if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG) #define LF_REQUIRE_PINS(N) \ static const char require_pins[LF_PINBOX_PINS-N]; \ - static const int LF_NUM_PINS_IN_THIS_FILE=N; + static const int LF_NUM_PINS_IN_THIS_FILE= N; #define _lf_pin(PINS, PIN, ADDR) \ ( \ - my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)), \ - assert(PIN < LF_NUM_PINS_IN_THIS_FILE) \ + assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \ + my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) \ ) #else #define LF_REQUIRE_PINS(N) @@ -151,7 +156,7 @@ typedef struct { } while (0) #define lf_unpin(PINS, PIN) lf_pin(PINS, PIN, NULL) #define _lf_assert_pin(PINS, PIN) assert((PINS)->pin[PIN] != 0) -#define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN]==0) +#define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN] == 0) void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset, lf_pinbox_free_func *free_func, void * free_func_arg); @@ -167,16 +172,20 @@ lock_wrap_void(lf_pinbox_put_pins, &pins->pinbox->pinstack.lock); lock_wrap_void(lf_pinbox_free, (LF_PINS *pins, void *addr), - (pins,addr), + (pins, addr), &pins->pinbox->pinstack.lock); /* memory allocator, lf_alloc-pin.c */ +struct st_lf_alloc_node { + struct st_lf_alloc_node *next; +}; + typedef struct st_lf_allocator { LF_PINBOX pinbox; - void * volatile top; + struct st_lf_alloc_node * volatile top; uint element_size; uint32 volatile mallocs; } LF_ALLOCATOR; @@ -184,13 +193,17 @@ typedef struct st_lf_allocator { void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset); void lf_alloc_destroy(LF_ALLOCATOR *allocator); uint lf_alloc_in_pool(LF_ALLOCATOR *allocator); +/* + shortcut macros to access underlying pinbox functions from an LF_ALLOCATOR + see _lf_pinbox_get_pins() and _lf_pinbox_put_pins() +*/ #define _lf_alloc_free(PINS, PTR) _lf_pinbox_free((PINS), (PTR)) #define lf_alloc_free(PINS, PTR) lf_pinbox_free((PINS), (PTR)) #define _lf_alloc_get_pins(ALLOC) _lf_pinbox_get_pins(&(ALLOC)->pinbox) #define lf_alloc_get_pins(ALLOC) lf_pinbox_get_pins(&(ALLOC)->pinbox) #define _lf_alloc_put_pins(PINS) _lf_pinbox_put_pins(PINS) #define lf_alloc_put_pins(PINS) lf_pinbox_put_pins(PINS) -#define lf_alloc_real_free(ALLOC,ADDR) my_free((gptr)(ADDR), MYF(0)) +#define lf_alloc_real_free(ALLOC, ADDR) my_free((gptr)(ADDR), MYF(0)) lock_wrap(lf_alloc_new, void *, (LF_PINS *pins), @@ -222,6 +235,10 @@ void lf_hash_destroy(LF_HASH *hash); int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data); void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen); int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen); +/* + shortcut macros to access underlying pinbox functions from an LF_HASH + see _lf_pinbox_get_pins() and _lf_pinbox_put_pins() +*/ #define _lf_hash_get_pins(HASH) _lf_alloc_get_pins(&(HASH)->alloc) #define lf_hash_get_pins(HASH) lf_alloc_get_pins(&(HASH)->alloc) #define _lf_hash_put_pins(PINS) _lf_pinbox_put_pins(PINS) diff --git a/include/my_atomic.h b/include/my_atomic.h index 8efad2802c0..78121c59c40 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -173,14 +173,6 @@ make_atomic_fas(ptr) #define LF_BACKOFF (1) #endif -#if SIZEOF_CHARP == SIZEOF_INT -typedef int intptr; -#elif SIZEOF_CHARP == SIZEOF_LONG -typedef long intptr; -#else -#error -#endif - #define MY_ATOMIC_OK 0 #define MY_ATOMIC_NOT_1CPU 1 extern int my_atomic_initialize(); diff --git a/include/my_global.h b/include/my_global.h index 7f7b502e1a7..6831a76c945 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -432,7 +432,8 @@ C_MODE_END #define compile_time_assert(X) \ do \ { \ - char compile_time_assert[(X) ? 1 : -1]; \ + char compile_time_assert[(X) ? 1 : -1] \ + __attribute__ ((unused)); \ } while(0) /* Go around some bugs in different OS and compilers */ @@ -964,6 +965,14 @@ typedef unsigned __int64 my_ulonglong; typedef unsigned long long my_ulonglong; #endif +#if SIZEOF_CHARP == SIZEOF_INT +typedef int intptr; +#elif SIZEOF_CHARP == SIZEOF_LONG +typedef long intptr; +#else +#error +#endif + #ifdef USE_RAID /* The following is done with a if to not get problems with pre-processors -- cgit v1.2.1 From a41ac15b960aee306e3464835b05a835fd98771d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Nov 2006 22:22:59 +0100 Subject: Maria - various fixes around durability of files: 1) on Mac OS X >=10.3, fcntl() is recommended over fsync (from the man page: "[With fsync()] the disk drive may also re-order the data so that later writes may be present while earlier writes are not. Applications such as databases that require a strict ordering of writes should use F_FULLFSYNC to ensure their data is written in the order they expect"). I have seen two other pieces of software changing from fsync to F_FULLFSYNC on Mac OS X. 2) to make a file creation/deletion/renaming durable on Linux (at least ext2 as I have tested) (see "man fsync"), a fsync() on the directory is needed: new functions to do that, and a flag MY_SYNC_DIR to do it in my_create/my_delete/my_rename. 3) now using this directory syncing when creating he frm if opt_sync_frm, and for Maria's control file when it is created. include/my_sys.h: new flag to my_create/my_delete/my_rename, which asks to sync the directory after the operation is done (currently does nothing except on Linux) libmysql/CMakeLists.txt: my_create() now depends on my_sync() so my_sync is needed for libmysql libmysql/Makefile.shared: my_create() now depends on my_sync() so my_sync is needed for libmysql mysys/my_create.c: my_create() can now sync the directory if asked for mysys/my_delete.c: my_delete() can now sync the directory if asked for mysys/my_open.c: it was a bug that my_close() is done on fd but a positive fd would still be returned, by my_register_filename(). mysys/my_rename.c: my_rename() can now sync the two directories (the one of "from" and the one of "to") if asked for. mysys/my_sync.c: On recent Mac OS X, fcntl(F_FULLFSYNC) is recommended over fsync() (see "man fsync" on Mac OS X 10.3). my_sync_dir(): to sync a directory after a file creation/deletion/ renaming; can be called directly or via MY_SYNC_DIR in my_create/ my_delete/my_rename(). No-op except on Linux (see "man fsync" on Linux). my_sync_dir_from_file(): same as above, just more practical when the caller has a file name but no directory name ready. Should the #warning even be a #error? I mean do we want to release binaries which don't guarantee any durability? sql/log.cc: a TODO for the future. sql/unireg.cc: If we sync the frm it makes sense to also sync its creation in the directory. storage/maria/ma_control_file.c: control file is vital, try to make it to disk --- include/my_sys.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/my_sys.h b/include/my_sys.h index fc83c583201..3c5b5e6cbf4 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -55,6 +55,7 @@ extern int NEAR my_errno; /* Last error in mysys */ #define MY_WME 16 /* Write message on error */ #define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ #define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ +#define MY_SYNC_DIR 1024 /* my_create/delete/rename: sync directory */ #define MY_RAID 64 /* Support for RAID */ #define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ @@ -622,6 +623,8 @@ extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); extern int my_fclose(FILE *fd,myf MyFlags); extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags); extern int my_sync(File fd, myf my_flags); +extern void my_sync_dir(const char *dir_name, myf my_flags); +extern void my_sync_dir_by_file(const char *file_name, myf my_flags); extern int my_error _VARARGS((int nr,myf MyFlags, ...)); extern int my_printf_error _VARARGS((uint my_err, const char *format, myf MyFlags, ...)) -- cgit v1.2.1 From 354d4a7e06074beb0a08afab06b0f5dfd63d7d1d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Nov 2006 15:53:26 +0100 Subject: shut up signedness warnings in atomic ops in gcc unittest/mysys/my_atomic-t.c: try both signed and unsigned arguments for atomic ops --- include/my_atomic.h | 139 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 98 insertions(+), 41 deletions(-) (limited to 'include') diff --git a/include/my_atomic.h b/include/my_atomic.h index 78121c59c40..7b1b56815e0 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -61,70 +61,115 @@ #endif #ifndef make_atomic_add_body -#define make_atomic_add_body(S) \ +#define make_atomic_add_body(S) \ int ## S tmp=*a; \ while (!my_atomic_cas ## S(a, &tmp, tmp+v)); \ v=tmp; #endif +#ifdef __GNUC__ +/* + we want to be able to use my_atomic_xxx functions with + both signed and unsigned integers. But gcc will issue a warning + "passing arg N of `my_atomic_XXX' as [un]signed due to prototype" + if the signedness of the argument doesn't match the prototype, or + "pointer targets in passing argument N of my_atomic_XXX differ in signedness" + if int* is used where uint* is expected (or vice versa). + Let's shut these warnings up +*/ +#define make_transparent_unions(S) \ + typedef union { \ + int ## S i; \ + uint ## S u; \ + } U_ ## S __attribute__ ((transparent_union)); \ + typedef union { \ + int ## S volatile *i; \ + uint ## S volatile *u; \ + } Uv_ ## S __attribute__ ((transparent_union)); +#define uintptr intptr +make_transparent_unions(8) +make_transparent_unions(16) +make_transparent_unions(32) +make_transparent_unions(ptr) +#undef uintptr +#undef make_transparent_unions +#define a U_a.i +#define cmp U_cmp.i +#define v U_v.i +#define set U_set.i +#else +#define U_8 int8 +#define U_16 int16 +#define U_32 int32 +#define U_ptr intptr +#define Uv_8 int8 +#define Uv_16 int16 +#define Uv_32 int32 +#define Uv_ptr intptr +#define U_a volatile *a +#define U_cmp *cmp +#define U_v v +#define U_set set +#endif /* __GCC__ transparent_union magic */ + #ifdef HAVE_INLINE -#define make_atomic_add(S) \ -STATIC_INLINE int ## S my_atomic_add ## S( \ - int ## S volatile *a, int ## S v) \ -{ \ - make_atomic_add_body(S); \ - return v; \ +#define make_atomic_add(S) \ +STATIC_INLINE int ## S my_atomic_add ## S( \ + Uv_ ## S U_a, U_ ## S U_v) \ +{ \ + make_atomic_add_body(S); \ + return v; \ } -#define make_atomic_fas(S) \ -STATIC_INLINE int ## S my_atomic_fas ## S( \ - int ## S volatile *a, int ## S v) \ -{ \ - make_atomic_fas_body(S); \ - return v; \ +#define make_atomic_fas(S) \ +STATIC_INLINE int ## S my_atomic_fas ## S( \ + Uv_ ## S U_a, U_ ## S U_v) \ +{ \ + make_atomic_fas_body(S); \ + return v; \ } -#define make_atomic_cas(S) \ -STATIC_INLINE int my_atomic_cas ## S(int ## S volatile *a, \ - int ## S *cmp, int ## S set) \ -{ \ - int8 ret; \ - make_atomic_cas_body(S); \ - return ret; \ +#define make_atomic_cas(S) \ +STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \ + Uv_ ## S U_cmp, U_ ## S U_set) \ +{ \ + int8 ret; \ + make_atomic_cas_body(S); \ + return ret; \ } -#define make_atomic_load(S) \ -STATIC_INLINE int ## S my_atomic_load ## S(int ## S volatile *a) \ -{ \ - int ## S ret; \ - make_atomic_load_body(S); \ - return ret; \ +#define make_atomic_load(S) \ +STATIC_INLINE int ## S my_atomic_load ## S(Uv_ ## S U_a) \ +{ \ + int ## S ret; \ + make_atomic_load_body(S); \ + return ret; \ } -#define make_atomic_store(S) \ -STATIC_INLINE void my_atomic_store ## S( \ - int ## S volatile *a, int ## S v) \ -{ \ - make_atomic_store_body(S); \ +#define make_atomic_store(S) \ +STATIC_INLINE void my_atomic_store ## S( \ + Uv_ ## S U_a, U_ ## S U_v) \ +{ \ + make_atomic_store_body(S); \ } #else /* no inline functions */ -#define make_atomic_add(S) \ -extern int ## S my_atomic_add ## S(int ## S volatile *a, int ## S v); +#define make_atomic_add(S) \ +extern int ## S my_atomic_add ## S(Uv_ ## S, U_ ## S); -#define make_atomic_fas(S) \ -extern int ## S my_atomic_fas ## S(int ## S volatile *a, int ## S v); +#define make_atomic_fas(S) \ +extern int ## S my_atomic_fas ## S(Uv_ ## S, U_ ## S); -#define make_atomic_cas(S) \ -extern int my_atomic_cas ## S(int ## S volatile *a, int ## S *cmp, int ## S set); +#define make_atomic_cas(S) \ +extern int my_atomic_cas ## S(Uv_ ## S, Uv_ ## S, U_ ## S); -#define make_atomic_load(S) \ -extern int ## S my_atomic_load ## S(int ## S volatile *a); +#define make_atomic_load(S) \ +extern int ## S my_atomic_load ## S(Uv_ ## S); -#define make_atomic_store(S) \ -extern void my_atomic_store ## S(int ## S volatile *a, int ## S v); +#define make_atomic_store(S) \ +extern void my_atomic_store ## S(Uv_ ## S, U_ ## S); #endif @@ -157,6 +202,18 @@ make_atomic_fas(ptr) #undef _atomic_h_cleanup_ #endif +#undef U_8 +#undef U_16 +#undef U_32 +#undef U_ptr +#undef a +#undef cmp +#undef v +#undef set +#undef U_a +#undef U_cmp +#undef U_v +#undef U_set #undef make_atomic_add #undef make_atomic_cas #undef make_atomic_load -- cgit v1.2.1 From adfba203ffd1bd89d74a63ff09de9b9a40fb64d7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Nov 2006 23:38:10 +0100 Subject: Maria - post-review fixes about my_sync_dir(): make it return an error (except if certain errno), test this error in callers. Do a single my_sync_dir() in my_rename() if possible. include/my_global.h: better have a symbol name talking about the feature, use it in the code of the feature, and define the symbol once depending on the platform, rather than have the platform "tested" in the code of the feature several times. include/my_sys.h: my_sync_dir() now can return error mysys/my_create.c: my_sync_dir() can now return an error mysys/my_delete.c: my_sync_dir() can now return an error mysys/my_rename.c: my_sync_dir() can now return an error. Do a single sync if "from" and "to" are the same directory. #ifdef here to not even compile dirname_part() if useless. mysys/my_sync.c: more comments. A compilation error if no way to make my_sync() work (I guess we don't want to ship a binary which cannot do any sync at all; users of strange OSes compile from source and can remove the #error). my_sync_dir() now returns an error (except for certain errno values considered ok; EIO "input/output error" is not ok). sql/unireg.cc: my_sync_dir() now returns an error which must be tested --- include/my_global.h | 8 ++++++++ include/my_sys.h | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/my_global.h b/include/my_global.h index 6831a76c945..f337c079c82 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1468,4 +1468,12 @@ do { doubleget_union _tmp; \ #define dlerror() "" #endif +/* + Only Linux is known to need an explicit sync of the directory to make sure a + file creation/deletion/renaming in(from,to) this directory durable. +*/ +#ifdef TARGET_OS_LINUX +#define NEED_EXPLICIT_SYNC_DIR 1 +#endif + #endif /* my_global_h */ diff --git a/include/my_sys.h b/include/my_sys.h index 3c5b5e6cbf4..f235c4d3fed 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -623,8 +623,8 @@ extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); extern int my_fclose(FILE *fd,myf MyFlags); extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags); extern int my_sync(File fd, myf my_flags); -extern void my_sync_dir(const char *dir_name, myf my_flags); -extern void my_sync_dir_by_file(const char *file_name, myf my_flags); +extern int my_sync_dir(const char *dir_name, myf my_flags); +extern int my_sync_dir_by_file(const char *file_name, myf my_flags); extern int my_error _VARARGS((int nr,myf MyFlags, ...)); extern int my_printf_error _VARARGS((uint my_err, const char *format, myf MyFlags, ...)) -- cgit v1.2.1 From 7a5d0c2e6efbffd95998b723e52a22de51c21dae Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 27 Nov 2006 22:09:06 +0100 Subject: Maria - Fixes to help some pushbuild hosts compile. include/Makefile.am: put my_bit.h in the tarball (need it for mf_keycache.c) mysys/lf_alloc-pin.c: // in .c file mysys/lf_hash.c: // in .c file --- include/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index d5e75d31593..dd7c25e91f4 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -23,7 +23,7 @@ pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \ my_getopt.h sslopt-longopts.h my_dir.h typelib.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ mysql_time.h mysql/plugin.h $(BUILT_SOURCES) -noinst_HEADERS = config-win.h config-netware.h lf.h \ +noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \ heap.h maria.h myisamchk.h my_bitmap.h my_uctype.h \ myisam.h myisampack.h myisammrg.h ft_global.h\ mysys_err.h my_base.h help_start.h help_end.h \ -- cgit v1.2.1 From b72903fe54cf83c3dcbec7e3532e23bf946249ba Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Dec 2006 17:06:27 +0100 Subject: Maria: * merging changes done to the key cache since May 2006 into Maria * enabling two small enough page cache's unit tests by default * fix to have non-buffered output in unit tests (to not have a false timeout killing in pushbuild) (patch given by Serg) * removing some warnings of gcc -ansi include/lf.h: getting rid of "warning: ISO C does not allow extra `;' outside of a function" (gcc -ansi) mysys/lf_hash.c: getting rid of "warning: ISO C does not allow extra `;' outside of a function" (gcc -ansi) mysys/mf_pagecache.c: Cosmetic changes to minimize the diff with the key cache. #define PAGECACHE_DEBUG_LOG is not needed (just define PAGECACHE_DEBUG if you want) (this change removes "warning: 'pagecache_debug_print' declared `static' but never defined"). Importing changes made to mf_keycache.c since May 2006, into the page cache. Disabling online resizing in the page cache. Fix for "warning: ISO C90 forbids mixed declarations and code". unittest/mysys/Makefile.am: Of the page cache's unit tests, two are small enough to run on pushbuild, renaming them to a -t suffix. unittest/mytap/tap.c: pushbuild kills a test after seeing no output from it for 10 minutes; so we set the mytap framework to not buffer output (patch given by Serg) so that output is seen more frequently and not "all at the end of the test". --- include/lf.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/lf.h b/include/lf.h index c7198ab75b6..ba29b6e9ca5 100644 --- a/include/lf.h +++ b/include/lf.h @@ -80,14 +80,14 @@ void lf_dynarray_destroy(LF_DYNARRAY *array); nolock_wrap(lf_dynarray_value, void *, (LF_DYNARRAY *array, uint idx), - (array, idx)); + (array, idx)) lock_wrap(lf_dynarray_lvalue, void *, (LF_DYNARRAY *array, uint idx), (array, idx), - &array->lock); + &array->lock) nolock_wrap(lf_dynarray_iterate, int, (LF_DYNARRAY *array, lf_dynarray_func func, void *arg), - (array, func, arg)); + (array, func, arg)) /* pin manager for memory allocator, lf_alloc-pin.c @@ -165,15 +165,15 @@ void lf_pinbox_destroy(LF_PINBOX *pinbox); lock_wrap(lf_pinbox_get_pins, LF_PINS *, (LF_PINBOX *pinbox), (pinbox), - &pinbox->pinstack.lock); + &pinbox->pinstack.lock) lock_wrap_void(lf_pinbox_put_pins, (LF_PINS *pins), (pins), - &pins->pinbox->pinstack.lock); + &pins->pinbox->pinstack.lock) lock_wrap_void(lf_pinbox_free, (LF_PINS *pins, void *addr), (pins, addr), - &pins->pinbox->pinstack.lock); + &pins->pinbox->pinstack.lock) /* memory allocator, lf_alloc-pin.c @@ -208,7 +208,7 @@ uint lf_alloc_in_pool(LF_ALLOCATOR *allocator); lock_wrap(lf_alloc_new, void *, (LF_PINS *pins), (pins), - &pins->pinbox->pinstack.lock); + &pins->pinbox->pinstack.lock) /* extendible hash, lf_hash.c -- cgit v1.2.1 From 5750daa4cf73eba0a6f1d9909844bf106228ae80 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Dec 2006 15:31:04 +0100 Subject: Maria - post-review change of "fixes for gcc -ansi". And reducing the time taken by my_atomic-t. include/lf.h: fix to be able to add a ";" at the end of the macro's invokation (removing it here, removes a warning from "gcc -ansi" about a standalone ";"). mysys/lf_hash.c: ";" is ok now after LF_REQUIRE_PINS mysys/mf_pagecache.c: comment fix unittest/mysys/my_atomic-t.c: decreasing number of iterations to make test take less time. --- include/lf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/lf.h b/include/lf.h index ba29b6e9ca5..c161bd5044d 100644 --- a/include/lf.h +++ b/include/lf.h @@ -136,7 +136,7 @@ typedef struct { #if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG) #define LF_REQUIRE_PINS(N) \ static const char require_pins[LF_PINBOX_PINS-N]; \ - static const int LF_NUM_PINS_IN_THIS_FILE= N; + static const int LF_NUM_PINS_IN_THIS_FILE= N #define _lf_pin(PINS, PIN, ADDR) \ ( \ assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \ -- cgit v1.2.1 From 7199c905590391f64802913369aab7d288eff4c8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Dec 2006 17:24:02 +0100 Subject: WL#3071 Maria checkpoint - cleanups, simplifications - moving the construction of the "dirty pages table" into the pagecache where it belongs (because it's the pagecache which knows dirty pages). TODO: do the same soon for the "transactions table". - fix for a small bug in the pagecache (decrementation of "changed_blocks") include/pagecache.h: prototype mysys/mf_pagecache.c: m_string.h moves up for LEX_STRING to be known for pagecache.h. In pagecache_delete_page(), we must decrement "blocks_changed" even if we just delete the page without flushing it. A new function pagecache_collect_changed_blocks_with_LSN() (used by the Checkpoint module), which stores information about the changed blocks (a.k.a. "the dirty pages table") into a LEX_STRING. This function is not tested now, it will be when there is a Checkpoint. storage/maria/ma_checkpoint.c: refining the checkpoint code: factoring functions, moving the construction of the "dirty pages table" into mf_pagecache.c (I'll do the same with the construction of the "transactions table" once Serg tells me what's the best way to do it). storage/maria/ma_least_recently_dirtied.c: Simplifying the thread which does background flushing of least-recently-dirtied pages: - in first version that thread will not flush, just do checkpoints - in 2nd version, flushing should re-use existing page cache functions like flush_pagecache_blocks(). unittest/mysys/test_file.h: m_string.h moves up for LEX_STRING to be known in pagecache.h --- include/pagecache.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/pagecache.h b/include/pagecache.h index 4d64070ad62..9f215325ae5 100644 --- a/include/pagecache.h +++ b/include/pagecache.h @@ -221,6 +221,9 @@ extern my_bool pagecache_delete_page(PAGECACHE *pagecache, enum pagecache_page_lock lock, my_bool flush); extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup); +extern my_bool pagecache_collect_changed_blocks_with_LSN(PAGECACHE *pagecache, + LEX_STRING *str, + LSN *max_lsn); C_MODE_END #endif /* _keycache_h */ -- cgit v1.2.1 From c2f2a41ed32522fa89f5c79fec42ab60e0b4aa62 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Dec 2006 19:15:53 +0100 Subject: Maria - merging recent changes done to MyISAM into Maria. Plus compiler warnings, and a fix to the pagecache unit tests for IA64 include/maria.h: merging MyISAM into Maria include/myisam.h: post-merge fixes mysql-test/r/maria.result: merging MyISAM into Maria mysql-test/t/maria.test: merging MyISAM into Maria sql/mysqld.cc: post-merge fixes storage/maria/ha_maria.cc: merging MyISAM into Maria storage/maria/ha_maria.h: merging MyISAM into Maria storage/maria/ma_check.c: merging MyISAM into Maria storage/maria/ma_open.c: merging MyISAM into Maria storage/maria/ma_packrec.c: merging MyISAM into Maria storage/maria/ma_range.c: merging MyISAM into Maria storage/maria/ma_sort.c: merging MyISAM into Maria storage/maria/maria_def.h: merging MyISAM into Maria storage/maria/maria_pack.c: merging MyISAM into Maria storage/maria/plug.in: merging MyISAM into Maria storage/myisam/myisamdef.h: merging MyISAM into Maria storage/myisam/myisampack.c: fix for compiler warnings unittest/mysys/mf_pagecache_consist.c: this sets the stack size lower than the minimum on IA64, we remove it (it made the test fail) unittest/mysys/mf_pagecache_single.c: this sets the stack size lower than the minimum on IA64, we remove it (it made the test fail) --- include/maria.h | 15 +++++++++++++-- include/myisam.h | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/maria.h b/include/maria.h index 705ba7c91c7..da9cbd49688 100644 --- a/include/maria.h +++ b/include/maria.h @@ -293,6 +293,17 @@ extern uint maria_get_pointer_length(ulonglong file_length, uint def); #define MARIA_CHK_REPAIR 1 /* equivalent to mariachk -r */ #define MARIA_CHK_VERIFY 2 /* Verify, run repair if failure */ +typedef uint maria_bit_type; + +typedef struct st_maria_bit_buff +{ /* Used for packing of record */ + maria_bit_type current_byte; + uint bits; + uchar *pos, *end, *blob_pos, *blob_end; + uint error; +} MARIA_BIT_BUFF; + + typedef struct st_maria_sort_info { #ifdef THREAD @@ -305,7 +316,6 @@ typedef struct st_maria_sort_info char *buff; SORT_KEY_BLOCKS *key_block, *key_block_end; SORT_FT_BUF *ft_buf; - my_off_t filelength, dupp, buff_length; ha_rows max_records; uint current_key, total_keys; @@ -314,12 +324,12 @@ typedef struct st_maria_sort_info enum data_file_type new_data_file_type; } MARIA_SORT_INFO; - typedef struct st_maria_sort_param { pthread_t thr; IO_CACHE read_cache, tempfile, tempfile_for_exceptions; DYNAMIC_ARRAY buffpek; + MARIA_BIT_BUFF bit_buff; /* For parallel repair of packrec. */ MARIA_KEYDEF *keyinfo; MARIA_SORT_INFO *sort_info; @@ -342,6 +352,7 @@ typedef struct st_maria_sort_param uint key, key_length,real_key_length,sortbuff_size; uint maxbuffers, keys, find_length, sort_keys_length; my_bool fix_datafile, master; + my_bool calc_checksum; /* calculate table checksum */ int (*key_cmp)(struct st_maria_sort_param *, const void *, const void *); int (*key_read)(struct st_maria_sort_param *,void *); diff --git a/include/myisam.h b/include/myisam.h index fc7468a382d..9171fec0b95 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -300,6 +300,17 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def); #define MYISAMCHK_REPAIR 1 /* equivalent to myisamchk -r */ #define MYISAMCHK_VERIFY 2 /* Verify, run repair if failure */ +typedef uint mi_bit_type; + +typedef struct st_mi_bit_buff +{ /* Used for packing of record */ + mi_bit_type current_byte; + uint bits; + uchar *pos, *end, *blob_pos, *blob_end; + uint error; +} MI_BIT_BUFF; + + typedef struct st_sort_info { #ifdef THREAD @@ -319,10 +330,13 @@ typedef struct st_sort_info myf myf_rw; enum data_file_type new_data_file_type; } MI_SORT_INFO; + typedef struct st_mi_sort_param +{ pthread_t thr; IO_CACHE read_cache, tempfile, tempfile_for_exceptions; DYNAMIC_ARRAY buffpek; + MI_BIT_BUFF bit_buff; /* For parallel repair of packrec. */ MI_KEYDEF *keyinfo; MI_SORT_INFO *sort_info; @@ -345,6 +359,7 @@ typedef struct st_mi_sort_param uint key, key_length,real_key_length,sortbuff_size; uint maxbuffers, keys, find_length, sort_keys_length; my_bool fix_datafile, master; + my_bool calc_checksum; /* calculate table checksum */ int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *); int (*key_read)(struct st_mi_sort_param *,void *); -- cgit v1.2.1 From 714f3b73e513f2d12fb45e8256fa6299e60cd5a2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Dec 2006 18:58:35 +0100 Subject: merge of recent MyISAM changes into Maria. Only failure is ndb_restore - could have been worse!! include/pagecache.h: LSN->lsn mysys/mf_keycache.c: page_status is int mysys/mf_pagecache.c: merge of recent key cache changes sql/mysqld.cc: post-merge fixes sql/set_var.cc: post-merge fixes storage/maria/ha_maria.cc: merge of recent MyISAM changes into Maria storage/maria/ha_maria.h: merge of recent MyISAM changes into Maria storage/maria/ma_close.c: merge of recent MyISAM changes into Maria storage/maria/ma_create.c: merge of recent MyISAM changes into Maria storage/maria/ma_delete.c: merge of recent MyISAM changes into Maria storage/maria/ma_dynrec.c: merge of recent MyISAM changes into Maria storage/maria/ma_ft_boolean_search.c: merge of recent MyISAM changes into Maria storage/maria/ma_key.c: merge of recent MyISAM changes into Maria storage/maria/ma_keycache.c: merge of recent MyISAM changes into Maria storage/maria/ma_open.c: merge of recent MyISAM changes into Maria storage/maria/ma_page.c: merge of recent MyISAM changes into Maria storage/maria/ma_rsamepos.c: merge of recent MyISAM changes into Maria storage/maria/ma_statrec.c: merge of recent MyISAM changes into Maria storage/maria/ma_unique.c: merge of recent MyISAM changes into Maria storage/maria/maria_chk.c: merge of recent MyISAM changes into Maria storage/maria/maria_pack.c: merge of recent MyISAM changes into Maria storage/myisam/myisampack.c: compiler warning --- include/pagecache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/pagecache.h b/include/pagecache.h index 9f215325ae5..418e0203f64 100644 --- a/include/pagecache.h +++ b/include/pagecache.h @@ -221,7 +221,7 @@ extern my_bool pagecache_delete_page(PAGECACHE *pagecache, enum pagecache_page_lock lock, my_bool flush); extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup); -extern my_bool pagecache_collect_changed_blocks_with_LSN(PAGECACHE *pagecache, +extern my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, LEX_STRING *str, LSN *max_lsn); -- cgit v1.2.1 From 345959c660d7401c9dc991a2c572ba145d6e199c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Jan 2007 21:38:14 +0200 Subject: Implementation of rows-in-block - Fixes some things missed in myisam->maria port - Moved variables that holds the state for the current row to 'cur_row' - Changed most uchar * to byte * to be able to remove a lot of casts - Removed RAID support - Added CHECK for rows-in-block - Added allocate_dynamic() for easier usage of dynamic rows when we know how many entries we will need - Reorder columns after CREATE for more optimal row storage (for rows-in-block) - Removed flag 'RRND_PRESERVER_LASTINX' (not needed) - Extended ma_test_all.sh to test more completely all row formats - New structs and variables to hold rows-in-block and bitmap information - Added org_data_file_type in header to allow easy restore of old record format when doing maria_pack / maria_chk -u - More virtual functions to handle different row types - Pointer to row is now MARIA_RECORD_POS instead of my_off_t - New header signature for MARIA index files - Fixed bugs in ma_test1.c and ma_test2.c - All key and row blocks are now of same size - We now only have one link chain for deleted key blocks include/m_string.h: Define bzero_if_purify include/maria.h: Implementation of rows-in-block include/my_base.h: Implementation of rows-in-block include/my_handler.h: Cleanup macros Added size_to_store_key_length() include/my_sys.h: Added 'allocate_dynamic()' include/myisamchk.h: Implementation of rows-in-block mysys/array.c: Added allocate_dynamic() mysys/mf_keycache.c: Moved DBUG_ENTER to it's right position mysys/my_pread.c: Ensure my_errno is always set sql/filesort.cc: Fixed some compiler warnings sql/gen_lex_hash.cc: Removed not needed 'inline' sql/ha_maria.cc: Implementation of rows-in-block Fixed compiler warnings sql/mysqld.cc: Fixed setting of wrong variable sql/uniques.cc: Fixed compiler warnings storage/maria/Makefile.am: Implementation of rows-in-block storage/maria/ma_check.c: Removed RAID functions Added support for CHECK of rows-in-blocks rows storage/maria/ma_checksum.c: Implementation of rows-in-block storage/maria/ma_close.c: Implementation of rows-in-block storage/maria/ma_create.c: Implementation of rows-in-block: - Reorder columns - All key blocks are now of same size - Removed old RAID support storage/maria/ma_dbug.c: Implementation of rows-in-block storage/maria/ma_delete.c: Implementation of rows-in-block storage/maria/ma_delete_all.c: Implementation of rows-in-block storage/maria/ma_dynrec.c: info->rec_buff is now allocated through _ma_alloc_buffer() Use new info->cur_row structure storage/maria/ma_extra.c: Implementation of rows-in-block storage/maria/ma_ft_boolean_search.c: Removed compiler warnings Indentation fixes storage/maria/ma_ft_nlq_search.c: Removed compiler warnings Indentation fixes storage/maria/ma_ft_update.c: Removed some casts storage/maria/ma_fulltext.h: Changed pointer type storage/maria/ma_info.c: Implementation of rows-in-block More general _ma_report_error() storage/maria/ma_init.c: Implementation of rows-in-block storage/maria/ma_key.c: Implementation of rows-in-block Removed some casts storage/maria/ma_keycache.c: Fixed DBUG entry storage/maria/ma_locking.c: Implementation of rows-in-block storage/maria/ma_open.c: Implementation of rows-in-block storage/maria/ma_packrec.c: Indentation fixes Changed uchar * to byte * to make it possible to remove some casts storage/maria/ma_page.c: Implementation of rows-in-block storage/maria/ma_range.c: Implementation of rows-in-block storage/maria/ma_rfirst.c: Implementation of rows-in-block storage/maria/ma_rkey.c: Implementation of rows-in-block Indentation fixes storage/maria/ma_rlast.c: Implementation of rows-in-block storage/maria/ma_rnext.c: Implementation of rows-in-block storage/maria/ma_rnext_same.c: Implementation of rows-in-block storage/maria/ma_rprev.c: Implementation of rows-in-block storage/maria/ma_rrnd.c: Implementation of rows-in-block Removed flag 'RRND_PRESERVER_LASTINX', by not resetting lastinx (This is reset by maria_scan_init()) storage/maria/ma_rsame.c: Implementation of rows-in-block storage/maria/ma_rsamepos.c: Implementation of rows-in-block storage/maria/ma_rt_index.c: Implementation of rows-in-block storage/maria/ma_rt_index.h: Implementation of rows-in-block storage/maria/ma_rt_key.c: Implementation of rows-in-block storage/maria/ma_rt_key.h: Implementation of rows-in-block storage/maria/ma_rt_mbr.c: Implementation of rows-in-block storage/maria/ma_rt_mbr.h: Implementation of rows-in-block storage/maria/ma_rt_split.c: Implementation of rows-in-block storage/maria/ma_rt_test.c: Indentation fix storage/maria/ma_scan.c: Implementation of rows-in-block Added 'maria_scan_end()' storage/maria/ma_search.c: Implementation of rows-in-block storage/maria/ma_sort.c: Indentation fixes uchar -> byte to be able to remove some casts storage/maria/ma_sp_defs.h: uchar * -> byte * storage/maria/ma_sp_key.c: uchar * -> byte * storage/maria/ma_sp_test.c: Indentation fixes storage/maria/ma_static.c: New header signature for MARIA storage/maria/ma_statrec.c: int -> my_bool functions my_off_t -> MARIA_RECORD_POS Fixed argument order for _ma_read_static_record() storage/maria/ma_test1.c: Implementation of rows-in-block Fixed some bugs in VARCHAR and BLOB testing storage/maria/ma_test2.c: Implementation of rows-in-block Fixed bug in BLOB testing storage/maria/ma_test3.c: Implementation of rows-in-block storage/maria/ma_test_all.sh: Run all tests with dynamic, static and block row formats (For the moment we skip REPAIR test of rows-in-block as this is not yet implemented) storage/maria/ma_unique.c: Implementation of rows-in-block storage/maria/ma_update.c: Implementation of rows-in-block storage/maria/ma_write.c: Implementation of rows-in-block Write of row is split into two parts, as rows-in-block format require us to do write of row before keys (to get row position) in contrast to all other row formats storage/maria/maria_chk.c: Implementation of rows-in-block storage/maria/maria_def.h: Implementation of rows-in-block - New structs and variables to hold rows-in-block and bitmap information - Added org_data_file_type in header to allow easy restore of old record format when doing maria_pack / maria_chk -u - More virtual functions to handle different row types - Pointer to row is now MARIA_RECORD_POS instead of my_off_t - uchar -> byte for many parameters to avoid casts storage/maria/maria_ftdump.c: Implementation of rows-in-block storage/maria/maria_pack.c: Implementation of rows-in-block storage/myisam/mi_check.c: Added new row types into switch to avoid compiler warnings Added some casts to avoid warnings after changing type of lastkey and buff storage/myisam/mi_create.c: Fix that 'pack_fields' is calculated correctly storage/myisam/mi_rsamepos.c: Implementation of rows-in-block storage/myisam/mi_test2.c: Fixed wrong printf storage/myisam/sort.c: uchar * -> byte * support-files/magic: Added support for Maria files Fided wrong entry's for MyISAM files storage/maria/ma_bitmap.c: New BitKeeper file ``storage/maria/ma_bitmap.c'' storage/maria/ma_blockrec.c: New BitKeeper file ``storage/maria/ma_blockrec.c'' storage/maria/ma_blockrec.h: New BitKeeper file ``storage/maria/ma_blockrec.h'' --- include/m_string.h | 7 ++-- include/maria.h | 96 +++++++++++++++++++++++++++++----------------------- include/my_base.h | 4 +-- include/my_handler.h | 22 ++++++------ include/my_sys.h | 1 + include/myisamchk.h | 20 ++++++----- 6 files changed, 86 insertions(+), 64 deletions(-) (limited to 'include') diff --git a/include/m_string.h b/include/m_string.h index e009447c192..6ba1f5f8914 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -68,7 +68,7 @@ # define bcopy(s, d, n) memcpy((d), (s), (n)) # define bcmp(A,B,C) memcmp((A),(B),(C)) # define bzero(A,B) memset((A),0,(B)) -# define bmove_align(A,B,C) memcpy((A),(B),(C)) +# define bmove_align(A,B,C) memcpy((A),(B),(C)) #endif #if defined(__cplusplus) @@ -127,7 +127,10 @@ extern int bcmp(const char *s1,const char *s2,uint len); extern int my_bcmp(const char *s1,const char *s2,uint len); #undef bcmp #define bcmp(A,B,C) my_bcmp((A),(B),(C)) -#endif +#define bzero_if_purify(A,B) bzero(A,B) +#else +#define bzero_if_purify(A,B) +#endif /* HAVE_purify */ #ifndef bmove512 extern void bmove512(gptr dst,const gptr src,uint len); diff --git a/include/maria.h b/include/maria.h index 705ba7c91c7..b917efe1f6c 100644 --- a/include/maria.h +++ b/include/maria.h @@ -55,6 +55,7 @@ extern "C" { #define MARIA_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */ #define MARIA_MAX_KEY_BLOCK_LENGTH 32768 #define maria_portable_sizeof_char_ptr 8 +#define MARIA_MAX_KEY_LENGTH 1000 /* Max length in bytes */ /* In the following macros '_keyno_' is 0 .. keys-1. @@ -109,13 +110,15 @@ extern "C" { /* Param to/from maria_info */ +typedef ulonglong MARIA_RECORD_POS; + typedef struct st_maria_isaminfo /* Struct from h_info */ { ha_rows records; /* Records in database */ ha_rows deleted; /* Deleted records in database */ - my_off_t recpos; /* Pos for last used record */ - my_off_t newrecpos; /* Pos if we write new record */ - my_off_t dupp_key_pos; /* Position to record with dup key */ + MARIA_RECORD_POS recpos; /* Pos for last used record */ + MARIA_RECORD_POS newrecpos; /* Pos if we write new record */ + MARIA_RECORD_POS dup_key_pos; /* Position to record with dup key */ my_off_t data_file_length; /* Length of data file */ my_off_t max_data_file_length, index_file_length; my_off_t max_index_file_length, delete_length; @@ -146,9 +149,11 @@ typedef struct st_maria_create_info ulonglong auto_increment; ulonglong data_file_length; ulonglong key_file_length; + uint null_bytes; uint old_options; + enum data_file_type org_data_file_type; uint8 language; - my_bool with_auto_increment; + my_bool with_auto_increment, transactional; } MARIA_CREATE_INFO; struct st_maria_info; /* For referense */ @@ -168,25 +173,24 @@ typedef struct st_maria_keydef /* Key definition with open & info */ uint16 keylength; /* Tot length of keyparts (auto) */ uint16 minlength; /* min length of (packed) key (auto) */ uint16 maxlength; /* max length of (packed) key (auto) */ - uint16 block_size_index; /* block_size (auto) */ uint32 version; /* For concurrent read/write */ uint32 ftparser_nr; /* distinct ftparser number */ HA_KEYSEG *seg, *end; struct st_mysql_ftparser *parser; /* Fulltext [pre]parser */ - int(*bin_search) (struct st_maria_info *info, - struct st_maria_keydef *keyinfo, uchar *page, uchar *key, - uint key_len, uint comp_flag, uchar **ret_pos, - uchar *buff, my_bool *was_last_key); - uint(*get_key) (struct st_maria_keydef *keyinfo, uint nod_flag, - uchar **page, uchar *key); - int(*pack_key) (struct st_maria_keydef *keyinfo, uint nod_flag, - uchar *next_key, uchar *org_key, uchar *prev_key, - uchar *key, struct st_maria_s_param *s_temp); - void(*store_key) (struct st_maria_keydef *keyinfo, uchar *key_pos, + int (*bin_search)(struct st_maria_info *info, + struct st_maria_keydef *keyinfo, byte *page, byte *key, + uint key_len, uint comp_flag, byte **ret_pos, + byte *buff, my_bool *was_last_key); + uint(*get_key)(struct st_maria_keydef *keyinfo, uint nod_flag, + byte **page, byte *key); + int (*pack_key)(struct st_maria_keydef *keyinfo, uint nod_flag, + byte *next_key, byte *org_key, byte *prev_key, + const byte *key, struct st_maria_s_param *s_temp); + void (*store_key)(struct st_maria_keydef *keyinfo, byte *key_pos, struct st_maria_s_param *s_temp); - int(*ck_insert) (struct st_maria_info *inf, uint k_nr, uchar *k, uint klen); - int(*ck_delete) (struct st_maria_info *inf, uint k_nr, uchar *k, uint klen); + int (*ck_insert)(struct st_maria_info *inf, uint k_nr, byte *k, uint klen); + int (*ck_delete)(struct st_maria_info *inf, uint k_nr, byte *k, uint klen); } MARIA_KEYDEF; @@ -195,7 +199,7 @@ typedef struct st_maria_keydef /* Key definition with open & info */ typedef struct st_maria_unique_def /* Segment definition of unique */ { uint16 keysegs; /* Number of key-segment */ - uchar key; /* Mapped to which key */ + uint8 key; /* Mapped to which key */ uint8 null_are_equal; HA_KEYSEG *seg, *end; } MARIA_UNIQUEDEF; @@ -218,16 +222,19 @@ struct st_maria_bit_buff; typedef struct st_maria_columndef /* column information */ { - int16 type; /* en_fieldtype */ + uint64 offset; /* Offset to position in row */ + enum en_fieldtype type; uint16 length; /* length of field */ - uint32 offset; /* Offset to position in row */ - uint8 null_bit; /* If column may be 0 */ - uint16 null_pos; /* position for null marker */ + uint16 fill_length; + uint16 null_pos; /* Position for null marker */ + uint16 empty_pos; /* Position for empty marker */ + uint8 null_bit; /* If column may be NULL */ + uint8 empty_bit; /* If column may be empty */ #ifndef NOT_PACKED_DATABASES - void(*unpack) (struct st_maria_columndef *rec, - struct st_maria_bit_buff *buff, - uchar *start, uchar *end); + void(*unpack)(struct st_maria_columndef *rec, + struct st_maria_bit_buff *buff, + byte *start, byte *end); enum en_fieldtype base_type; uint space_length_bits, pack_type; MARIA_DECODE_TREE *huff_tree; @@ -237,7 +244,8 @@ typedef struct st_maria_columndef /* column information */ extern ulong maria_block_size; extern ulong maria_concurrent_insert; -extern my_bool maria_flush, maria_delay_key_write, maria_single_user; +extern my_bool maria_flush, maria_single_user; +extern my_bool maria_delay_key_write, maria_delay_rec_write; extern my_off_t maria_max_temp_length; extern ulong maria_bulk_insert_tree_size, maria_data_pointer_size; extern KEY_CACHE maria_key_cache_var, *maria_key_cache; @@ -260,19 +268,22 @@ extern int maria_rlast(struct st_maria_info *file, byte *buf, int inx); extern int maria_rnext(struct st_maria_info *file, byte *buf, int inx); extern int maria_rnext_same(struct st_maria_info *info, byte *buf); extern int maria_rprev(struct st_maria_info *file, byte *buf, int inx); -extern int maria_rrnd(struct st_maria_info *file, byte *buf, my_off_t pos); +extern int maria_rrnd(struct st_maria_info *file, byte *buf, + MARIA_RECORD_POS pos); extern int maria_scan_init(struct st_maria_info *file); extern int maria_scan(struct st_maria_info *file, byte *buf); +extern void maria_scan_end(struct st_maria_info *file); extern int maria_rsame(struct st_maria_info *file, byte *record, int inx); extern int maria_rsame_with_pos(struct st_maria_info *file, byte *record, - int inx, my_off_t pos); + int inx, MARIA_RECORD_POS pos); extern int maria_update(struct st_maria_info *file, const byte *old, byte *new_record); extern int maria_write(struct st_maria_info *file, byte *buff); -extern my_off_t maria_position(struct st_maria_info *file); +extern MARIA_RECORD_POS maria_position(struct st_maria_info *file); extern int maria_status(struct st_maria_info *info, MARIA_INFO *x, uint flag); extern int maria_lock_database(struct st_maria_info *file, int lock_type); -extern int maria_create(const char *name, uint keys, MARIA_KEYDEF *keydef, +extern int maria_create(const char *name, enum data_file_type record_type, + uint keys, MARIA_KEYDEF *keydef, uint columns, MARIA_COLUMNDEF *columndef, uint uniques, MARIA_UNIQUEDEF *uniquedef, MARIA_CREATE_INFO *create_info, uint flags); @@ -324,7 +335,7 @@ typedef struct st_maria_sort_param MARIA_KEYDEF *keyinfo; MARIA_SORT_INFO *sort_info; HA_KEYSEG *seg; - uchar **sort_keys; + byte **sort_keys; byte *rec_buff; void *wordlist, *wordptr; MEM_ROOT wordroot; @@ -338,16 +349,17 @@ typedef struct st_maria_sort_param ulonglong unique[HA_MAX_KEY_SEG+1]; ulonglong notnull[HA_MAX_KEY_SEG+1]; - my_off_t pos,max_pos,filepos,start_recpos; + MARIA_RECORD_POS pos,max_pos,filepos,start_recpos; uint key, key_length,real_key_length,sortbuff_size; uint maxbuffers, keys, find_length, sort_keys_length; my_bool fix_datafile, master; + my_size_t rec_buff_size; int (*key_cmp)(struct st_maria_sort_param *, const void *, const void *); - int (*key_read)(struct st_maria_sort_param *,void *); - int (*key_write)(struct st_maria_sort_param *, const void *); + int (*key_read)(struct st_maria_sort_param *, byte *); + int (*key_write)(struct st_maria_sort_param *, const byte *); void (*lock_in_memory)(HA_CHECK *); - NEAR int (*write_keys)(struct st_maria_sort_param *, register uchar **, + NEAR int (*write_keys)(struct st_maria_sort_param *, register byte **, uint , struct st_buffpek *, IO_CACHE *); NEAR uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint); NEAR int (*write_key)(struct st_maria_sort_param *, IO_CACHE *,char *, @@ -356,7 +368,7 @@ typedef struct st_maria_sort_param /* functions in maria_check */ -void mariachk_init(HA_CHECK *param); +void maria_chk_init(HA_CHECK *param); int maria_chk_status(HA_CHECK *param, MARIA_HA *info); int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag); int maria_chk_size(HA_CHECK *param, MARIA_HA *info); @@ -371,19 +383,19 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info, int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, const char *name, int rep_quick); int maria_change_to_newfile(const char *filename, const char *old_ext, - const char *new_ext, uint raid_chunks, myf myflags); + const char *new_ext, myf myflags); void maria_lock_memory(HA_CHECK *param); int maria_update_state_info(HA_CHECK *param, MARIA_HA *info, uint update); void maria_update_key_parts(MARIA_KEYDEF *keyinfo, ulong *rec_per_key_part, - ulonglong *unique, ulonglong *notnull, - ulonglong records); + ulonglong *unique, ulonglong *notnull, + ulonglong records); int maria_filecopy(HA_CHECK *param, File to, File from, my_off_t start, - my_off_t length, const char *type); + my_off_t length, const char *type); int maria_movepoint(MARIA_HA *info, byte *record, my_off_t oldpos, - my_off_t newpos, uint prot_key); + my_off_t newpos, uint prot_key); int maria_write_data_suffix(MARIA_SORT_INFO *sort_info, my_bool fix_datafile); int maria_test_if_almost_full(MARIA_HA *info); -int maria_recreate_table(HA_CHECK *param, MARIA_HA ** org_info, char *filename); +int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename); int maria_disable_indexes(MARIA_HA *info); int maria_enable_indexes(MARIA_HA *info); int maria_indexes_are_disabled(MARIA_HA *info); diff --git a/include/my_base.h b/include/my_base.h index 5ad7ac57fe1..76a67e3f3e7 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -48,7 +48,7 @@ #define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */ #define HA_OPEN_FROM_SQL_LAYER 64 - /* The following is parameter to ha_rkey() how to use key */ +/* The following is parameter to ha_rkey() how to use key */ /* We define a complete-field prefix of a key value as a prefix where @@ -433,7 +433,7 @@ enum en_fieldtype { }; enum data_file_type { - STATIC_RECORD,DYNAMIC_RECORD,COMPRESSED_RECORD + STATIC_RECORD, DYNAMIC_RECORD, COMPRESSED_RECORD, BLOCK_RECORD }; /* For key ranges */ diff --git a/include/my_handler.h b/include/my_handler.h index 9b086036389..fd1bafe8d5c 100644 --- a/include/my_handler.h +++ b/include/my_handler.h @@ -58,33 +58,35 @@ typedef struct st_HA_KEYSEG /* Key-portion */ } HA_KEYSEG; #define get_key_length(length,key) \ -{ if ((uchar) *(key) != 255) \ - length= (uint) (uchar) *((key)++); \ +{ if (*(uchar*) (key) != 255) \ + length= (uint) *(uchar*) ((key)++); \ else \ - { length=mi_uint2korr((key)+1); (key)+=3; } \ + { length= mi_uint2korr((key)+1); (key)+=3; } \ } #define get_key_length_rdonly(length,key) \ -{ if ((uchar) *(key) != 255) \ - length= ((uint) (uchar) *((key))); \ +{ if (*(uchar*) (key) != 255) \ + length= ((uint) *(uchar*) ((key))); \ else \ - { length=mi_uint2korr((key)+1); } \ + { length= mi_uint2korr((key)+1); } \ } #define get_key_pack_length(length,length_pack,key) \ -{ if ((uchar) *(key) != 255) \ - { length= (uint) (uchar) *((key)++); length_pack=1; }\ +{ if (*(uchar*) (key) != 255) \ + { length= (uint) *(uchar*) ((key)++); length_pack= 1; }\ else \ - { length=mi_uint2korr((key)+1); (key)+=3; length_pack=3; } \ + { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \ } #define store_key_length_inc(key,length) \ { if ((length) < 255) \ - { *(key)++=(length); } \ + { *(key)++= (length); } \ else \ { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \ } +#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3) + #define get_rec_bits(bit_ptr, bit_ofs, bit_len) \ (((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \ ((1 << (bit_len)) - 1)) diff --git a/include/my_sys.h b/include/my_sys.h index 4b31f6bcd2b..3a491baf47f 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -760,6 +760,7 @@ extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element); extern byte *alloc_dynamic(DYNAMIC_ARRAY *array); extern byte *pop_dynamic(DYNAMIC_ARRAY*); extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); +extern my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements); extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); extern void delete_dynamic(DYNAMIC_ARRAY *array); extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); diff --git a/include/myisamchk.h b/include/myisamchk.h index 442fe5f7ece..66d0a77b62f 100644 --- a/include/myisamchk.h +++ b/include/myisamchk.h @@ -76,8 +76,8 @@ typedef struct st_sort_key_blocks /* Used when sorting */ { - uchar *buff, *end_pos; - uchar lastkey[HA_MAX_POSSIBLE_KEY_BUFF]; + byte *buff, *end_pos; + byte lastkey[HA_MAX_POSSIBLE_KEY_BUFF]; uint last_length; int inited; } SORT_KEY_BLOCKS; @@ -121,20 +121,24 @@ typedef struct st_handler_check_param 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; - ha_rows total_records, total_deleted; + my_off_t used, empty, splits, del_length, link_used; + ha_rows total_records, total_deleted, records,del_blocks; + ha_rows full_page_count, tail_count; ha_checksum record_checksum, glob_crc; ha_checksum key_crc[HA_MAX_POSSIBLE_KEY]; + ha_checksum tmp_key_crc[HA_MAX_POSSIBLE_KEY]; + ha_checksum tmp_record_checksum; ulong use_buffers, read_buffer_length, write_buffer_length; ulong sort_buffer_length, sort_key_blocks; ulong rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY]; uint out_flag, warning_printed, error_printed, verbose; uint opt_sort_key, total_files, max_level; uint testflag, key_cache_block_size; - int tmpfile_createflag; + int tmpfile_createflag, err_count; myf myf_rw; uint8 language; my_bool using_global_keycache, opt_lock_memory, opt_follow_links; - my_bool retry_repair, force_sort, calc_checksum; + my_bool retry_repair, force_sort, calc_checksum, static_row_size; char temp_filename[FN_REFLEN]; IO_CACHE read_cache; enum_handler_stats_method stats_method; @@ -143,15 +147,15 @@ typedef struct st_handler_check_param typedef struct st_sort_ftbuf { - uchar *buf, *end; + byte *buf, *end; int count; - uchar lastkey[HA_MAX_KEY_BUFF]; + byte lastkey[HA_MAX_KEY_BUFF]; } SORT_FT_BUF; typedef struct st_buffpek { my_off_t file_pos; /* Where we are in the sort file */ - uchar *base,*key; /* Key pointers */ + byte *base, *key; /* Key pointers */ ha_rows count; /* Number of rows in table */ ulong mem_count; /* numbers of keys in memory */ ulong max_keys; /* Max keys in buffert */ -- cgit v1.2.1 From 7412f0fa0cd498f06fe04966a6f6161e8b32d0a2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 26 Jan 2007 13:32:02 +0200 Subject: After merge fixes Removed compiler warnings Fixed clashing function name in maria Disable maria tests from MySQL level for now BitKeeper/deleted/.del-ha_maria.cc: Rename: libmysqld/ha_maria.cc -> BitKeeper/deleted/.del-ha_maria.cc BitKeeper/etc/ignore: added libmysqld/ha_maria.cc --- added storage/maria/unittest/maria_control unittest/maria_control --- added *.Tpo --- added unittest/page_cache_test_file_1 --- added unittest/pagecache_debug.log --- added unittest/mysys/mf_pagecache_consist_1k-t-big unittest/mysys/mf_pagecache_consist_1kHC-t-big unittest/mysys/mf_pagecache_consist_1kRD-t-big unittest/mysys/mf_pagecache_consist_1kWR-t-big unittest/mysys/mf_pagecache_consist_64k-t-big unittest/mysys/mf_pagecache_consist_64kHC-t-big unittest/mysys/mf_pagecache_consist_64kRD-t-big unittest/mysys/mf_pagecache_consist_64kWR-t-big --- added unittest/mysys/mf_pagecache_single_64k-t-big Makefile.am: Don't run 'test-unit' by default (takes too long time) client/mysqldump.c: Fixed compiler warning include/lf.h: Remove compiler warnings about not used require_pins constant include/pagecache.h: LSN should be of type ulonglong (This fixes some compiler warnings) mysql-test/r/events_logs_tests.result: Make test predictable mysql-test/r/view.result: Make test results predictable mysql-test/t/disabled.def: Disable maria tests for a while mysql-test/t/events_logs_tests.test: Make test predictable mysql-test/t/view.test: Make test results predictable mysys/lf_alloc-pin.c: #warning ->QQ mysys/lf_hash.c: #warning ->QQ Removed compiler warnings mysys/mf_pagecache.c: Removed compiler warnings mysys/my_rename.c: Removed compiler warnings plugin/daemon_example/daemon_example.c: Remove compiler warning sql/ha_ndbcluster.cc: Remove compiler warning sql/udf_example.c: Remove compiler warning storage/maria/lockman.c: Changed #warnings to QQ comment Removed compiler warnings storage/maria/ma_blockrec.c: Removed compiler warnings storage/maria/ma_check.c: After merge fixes storage/maria/ma_key.c: After merge fixes storage/maria/ma_packrec.c: After merge fixes storage/maria/ma_rkey.c: After merge fixes storage/maria/ma_sort.c: After merge fixes storage/maria/ma_sp_defs.h: Rename clashing function name storage/maria/ma_sp_key.c: Rename clashing function name storage/maria/ma_test_all.res: New test results storage/maria/ma_unique.c: Fixed compiler warning storage/maria/tablockman.c: #warning -> QQ storage/maria/tablockman.h: #warning -> QQ storage/maria/trnman.c: #warning -> QQ storage/maria/unittest/lockman2-t.c: Removed compiler warnings storage/maria/unittest/ma_control_file-t.c: Removed warning for 'maria_control' file not found storage/maria/unittest/trnman-t.c: Removed compiler warnings storage/ndb/src/mgmapi/mgmapi.cpp: Remove compiler warnings unittest/mysys/mf_pagecache_consist.c: Removed compiler warnings unittest/mysys/my_atomic-t.c: Removed compiler warnings --- include/lf.h | 3 ++- include/pagecache.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/lf.h b/include/lf.h index c161bd5044d..39a47e6568a 100644 --- a/include/lf.h +++ b/include/lf.h @@ -135,8 +135,9 @@ typedef struct { */ #if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG) #define LF_REQUIRE_PINS(N) \ - static const char require_pins[LF_PINBOX_PINS-N]; \ + static const char require_pins[LF_PINBOX_PINS-N] __attribute__ ((unused)); \ static const int LF_NUM_PINS_IN_THIS_FILE= N + #define _lf_pin(PINS, PIN, ADDR) \ ( \ assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \ diff --git a/include/pagecache.h b/include/pagecache.h index 418e0203f64..b698a36a5e4 100644 --- a/include/pagecache.h +++ b/include/pagecache.h @@ -73,7 +73,7 @@ typedef void *PAGECACHE_PAGE_LINK; /* TODO: move to loghandler emulator */ typedef void LOG_HANDLER; -typedef void *LSN; +typedef ulonglong LSN; /* file descriptor for Maria */ typedef struct st_pagecache_file -- cgit v1.2.1 From 025400922118f11a15be54c66455f20e2f72c0b4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Feb 2007 09:41:32 +0200 Subject: postreview changes for page cache and pre review commit for loghandler storage/maria/unittest/test_file.c: Rename: unittest/mysys/test_file.c -> storage/maria/unittest/test_file.c storage/maria/unittest/test_file.h: Rename: unittest/mysys/test_file.h -> storage/maria/unittest/test_file.h include/pagecache.h: A waiting queue mechanism moved to separate file wqueue.* Pointer name changed for compatibility mysys/Makefile.am: A waiting queue mechanism moved to separate file wqueue.* mysys/mf_keycache.c: fixed unsigned comparison mysys/mf_pagecache.c: A waiting queue mechanism moved to separate file wqueue.* Fixed bug in unregistering block during write storage/maria/Makefile.am: The loghandler files added storage/maria/ma_control_file.h: Now we have loghandler and can compile control file storage/maria/maria_def.h: Including files need for compilation of maria storage/maria/unittest/Makefile.am: unit tests of loghandler storage/maria/unittest/ma_control_file-t.c: Used maria def storage/maria/unittest/mf_pagecache_consist.c: fixed memory overrun storage/maria/unittest/mf_pagecache_single.c: fixed used uninitialized memory unittest/mysys/Makefile.am: unittests of pagecache moved to maria becase pagecache need loghandler include/wqueue.h: New BitKeeper file ``include/wqueue.h'' mysys/wqueue.c: New BitKeeper file ``mysys/wqueue.c'' storage/maria/ma_loghandler.c: New BitKeeper file ``storage/maria/ma_loghandler.c'' storage/maria/ma_loghandler.h: New BitKeeper file ``storage/maria/ma_loghandler.h'' storage/maria/ma_loghandler_lsn.h: New BitKeeper file ``storage/maria/ma_loghandler_lsn.h'' storage/maria/unittest/ma_test_loghandler-t.c: New BitKeeper file ``storage/maria/unittest/ma_test_loghandler-t.c'' storage/maria/unittest/ma_test_loghandler_multigroup-t.c: New BitKeeper file ``storage/maria/unittest/ma_test_loghandler_multigroup-t.c'' storage/maria/unittest/ma_test_loghandler_multithread-t.c: New BitKeeper file ``storage/maria/unittest/ma_test_loghandler_multithread-t.c'' storage/maria/unittest/ma_test_loghandler_pagecache-t.c: New BitKeeper file ``storage/maria/unittest/ma_test_loghandler_pagecache-t.c'' --- include/pagecache.h | 65 +++++++++++++++++++++++++++-------------------------- include/wqueue.h | 26 +++++++++++++++++++++ 2 files changed, 59 insertions(+), 32 deletions(-) create mode 100644 include/wqueue.h (limited to 'include') diff --git a/include/pagecache.h b/include/pagecache.h index 4d64070ad62..2f745eae0b3 100644 --- a/include/pagecache.h +++ b/include/pagecache.h @@ -20,11 +20,13 @@ #define _pagecache_h C_MODE_START +#include "../storage/maria/ma_loghandler_lsn.h" + /* Type of the page */ enum pagecache_page_type { #ifndef DBUG_OFF - /* used only for control page type chenging during debugging */ + /* used only for control page type changing during debugging */ PAGECACHE_EMPTY_PAGE, #endif /* the page does not contain LSN */ @@ -34,7 +36,7 @@ enum pagecache_page_type }; /* - This enum describe lock status changing. every typr of page cache will + This enum describe lock status changing. every type of page cache will interpret WRITE/READ lock as it need. */ enum pagecache_page_lock @@ -71,9 +73,7 @@ enum pagecache_write_mode typedef void *PAGECACHE_PAGE_LINK; -/* TODO: move to loghandler emulator */ -typedef void LOG_HANDLER; -typedef void *LSN; +typedef void *LSN_PTR; /* file descriptor for Maria */ typedef struct st_pagecache_file @@ -82,7 +82,7 @@ typedef struct st_pagecache_file } PAGECACHE_FILE; /* page number for maria */ -typedef uint32 maria_page_no_t; +typedef uint32 pgcache_page_no_t; /* declare structures that is used by st_pagecache */ @@ -93,11 +93,9 @@ typedef struct st_pagecache_page PAGECACHE_PAGE; struct st_pagecache_hash_link; typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK; -/* info about requests in a waiting queue */ -typedef struct st_pagecache_wqueue -{ - struct st_my_thread_var *last_thread; /* circular list of waiting threads */ -} PAGECACHE_WQUEUE; +#include + +typedef my_bool (*pagecache_disk_read_validator)(byte *page, gptr data); #define PAGECACHE_CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ @@ -136,16 +134,14 @@ typedef struct st_pagecache PAGECACHE_BLOCK_LINK *used_last;/* ptr to the last block of the LRU chain */ PAGECACHE_BLOCK_LINK *used_ins;/* ptr to the insertion block in LRU chain */ pthread_mutex_t cache_lock; /* to lock access to the cache structure */ - PAGECACHE_WQUEUE resize_queue; /* threads waiting during resize operation */ - PAGECACHE_WQUEUE waiting_for_hash_link;/* waiting for a free hash link */ - PAGECACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ + WQUEUE resize_queue; /* threads waiting during resize operation */ + WQUEUE waiting_for_hash_link;/* waiting for a free hash link */ + WQUEUE waiting_for_block; /* requests waiting for a free block */ /* hash for dirty file bl.*/ PAGECACHE_BLOCK_LINK *changed_blocks[PAGECACHE_CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/ PAGECACHE_BLOCK_LINK *file_blocks[PAGECACHE_CHANGED_BLOCKS_HASH]; - LOG_HANDLER *loghandler; /* loghandler structure */ - /* The following variables are and variables used to hold parameters for initializing the key cache. @@ -169,24 +165,29 @@ typedef struct st_pagecache extern int init_pagecache(PAGECACHE *pagecache, my_size_t use_mem, uint division_limit, uint age_threshold, - uint block_size, - LOG_HANDLER *loghandler); + uint block_size); extern int resize_pagecache(PAGECACHE *pagecache, my_size_t use_mem, uint division_limit, uint age_threshold); extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit, uint age_threshold); -extern byte *pagecache_read(PAGECACHE *pagecache, - PAGECACHE_FILE *file, - maria_page_no_t pageno, - uint level, - byte *buff, - enum pagecache_page_type type, - enum pagecache_page_lock lock, - PAGECACHE_PAGE_LINK *link); + +#define pagecache_read(P,F,N,L,B,T,K,I) \ + pagecache_valid_read(P,F,N,L,B,T,K,I,0,0) + +extern byte *pagecache_valid_read(PAGECACHE *pagecache, + PAGECACHE_FILE *file, + pgcache_page_no_t pageno, + uint level, + byte *buff, + enum pagecache_page_type type, + enum pagecache_page_lock lock, + PAGECACHE_PAGE_LINK *link, + pagecache_disk_read_validator validator, + gptr validator_data); extern my_bool pagecache_write(PAGECACHE *pagecache, PAGECACHE_FILE *file, - maria_page_no_t pageno, + pgcache_page_no_t pageno, uint level, byte *buff, enum pagecache_page_type type, @@ -196,20 +197,20 @@ extern my_bool pagecache_write(PAGECACHE *pagecache, PAGECACHE_PAGE_LINK *link); extern void pagecache_unlock_page(PAGECACHE *pagecache, PAGECACHE_FILE *file, - maria_page_no_t pageno, + pgcache_page_no_t pageno, enum pagecache_page_lock lock, enum pagecache_page_pin pin, my_bool stamp_this_page, - LSN first_REDO_LSN_for_page); + LSN_PTR first_REDO_LSN_for_page); extern void pagecache_unlock(PAGECACHE *pagecache, PAGECACHE_PAGE_LINK *link, enum pagecache_page_lock lock, enum pagecache_page_pin pin, my_bool stamp_this_page, - LSN first_REDO_LSN_for_page); + LSN_PTR first_REDO_LSN_for_page); extern void pagecache_unpin_page(PAGECACHE *pagecache, PAGECACHE_FILE *file, - maria_page_no_t pageno); + pgcache_page_no_t pageno); extern void pagecache_unpin(PAGECACHE *pagecache, PAGECACHE_PAGE_LINK *link); extern int flush_pagecache_blocks(PAGECACHE *keycache, @@ -217,7 +218,7 @@ extern int flush_pagecache_blocks(PAGECACHE *keycache, enum flush_type type); extern my_bool pagecache_delete_page(PAGECACHE *pagecache, PAGECACHE_FILE *file, - maria_page_no_t pageno, + pgcache_page_no_t pageno, enum pagecache_page_lock lock, my_bool flush); extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup); diff --git a/include/wqueue.h b/include/wqueue.h new file mode 100644 index 00000000000..bacabb8c401 --- /dev/null +++ b/include/wqueue.h @@ -0,0 +1,26 @@ + +#ifndef _wqueue_h +#define _wqueue_h + +#include +#include + +/* info about requests in a waiting queue */ +typedef struct st_pagecache_wqueue +{ + struct st_my_thread_var *last_thread; /* circular list of waiting + threads */ +} WQUEUE; + +#ifdef THREAD +void wqueue_link_into_queue(WQUEUE *wqueue, struct st_my_thread_var *thread); +void wqueue_unlink_from_queue(WQUEUE *wqueue, struct st_my_thread_var *thread); +void wqueue_add_to_queue(WQUEUE *wqueue, struct st_my_thread_var *thread); +void wqueue_add_and_wait(WQUEUE *wqueue, + struct st_my_thread_var *thread, + pthread_mutex_t *lock); +void wqueue_release_queue(WQUEUE *wqueue); + +#endif + +#endif -- cgit v1.2.1 From 91a8199773a8ee6b4d5a00b337d9b49a69dfc1ea Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Feb 2007 14:23:43 +0200 Subject: Postmerge fix (including changing type of LSN) Some debug info and comments added include/pagecache.h: postmerge fix mysys/mf_pagecache.c: Postmerge fix (including changing type of LSN) Additional DBUG_ASSERTs added Comment about pinning mechanism added storage/maria/ma_control_file.c: Used the same LSN storing procedure everywhere Postmerge fix (including changing type of LSN) storage/maria/ma_control_file.h: Postmerge fix (including changing type of LSN) storage/maria/ma_loghandler.c: Postmerge fix (including changing type of LSN) storage/maria/ma_loghandler.h: Postmerge fix (including changing type of LSN) storage/maria/ma_loghandler_lsn.h: Postmerge fix (including changing type of LSN) storage/maria/unittest/Makefile.am: Postmerge fix storage/maria/unittest/ma_control_file-t.c: Postmerge fix (including changing type of LSN) storage/maria/unittest/ma_test_loghandler-t.c: Postmerge fix (including changing type of LSN) storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Postmerge fix (including changing type of LSN) storage/maria/unittest/ma_test_loghandler_multithread-t.c: Postmerge fix (including changing type of LSN) storage/maria/unittest/ma_test_loghandler_pagecache-t.c: Postmerge fix (including changing type of LSN) storage/maria/unittest/mf_pagecache_consist.c: Postmerge fix (including changing type of LSN) storage/maria/unittest/mf_pagecache_single.c: Postmerge fix (including changing type of LSN) --- include/pagecache.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/pagecache.h b/include/pagecache.h index b507c1fb4ae..32e23fb54ea 100644 --- a/include/pagecache.h +++ b/include/pagecache.h @@ -21,6 +21,7 @@ C_MODE_START #include "../storage/maria/ma_loghandler_lsn.h" +#include /* Type of the page */ enum pagecache_page_type @@ -73,8 +74,6 @@ enum pagecache_write_mode typedef void *PAGECACHE_PAGE_LINK; -typedef uint64 LSN; - /* file descriptor for Maria */ typedef struct st_pagecache_file { @@ -152,8 +151,8 @@ typedef struct st_pagecache ulong param_division_limit; /* min. percentage of warm blocks */ ulong param_age_threshold; /* determines when hot block is downgraded */ - /* Statistics variables. These are reset in reset_key_cache_counters(). */ - ulong global_blocks_changed; /* number of currently dirty blocks */ + /* Statistics variables. These are reset in reset_pagecache_counters(). */ + ulong global_blocks_changed; /* number of currently dirty blocks */ ulonglong global_cache_w_requests;/* number of write requests (write hits) */ ulonglong global_cache_write; /* number of writes from cache to files */ ulonglong global_cache_r_requests;/* number of read requests (read hits) */ @@ -200,14 +199,12 @@ extern void pagecache_unlock_page(PAGECACHE *pagecache, pgcache_page_no_t pageno, enum pagecache_page_lock lock, enum pagecache_page_pin pin, - my_bool stamp_this_page, - LSN_PTR first_REDO_LSN_for_page); + LSN first_REDO_LSN_for_page); extern void pagecache_unlock(PAGECACHE *pagecache, PAGECACHE_PAGE_LINK *link, enum pagecache_page_lock lock, enum pagecache_page_pin pin, - my_bool stamp_this_page, - LSN_PTR first_REDO_LSN_for_page); + LSN first_REDO_LSN_for_page); extern void pagecache_unpin_page(PAGECACHE *pagecache, PAGECACHE_FILE *file, pgcache_page_no_t pageno); @@ -225,6 +222,7 @@ extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup); extern my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, LEX_STRING *str, LSN *max_lsn); +extern int reset_pagecache_counters(const char *name, PAGECACHE *pagecache); C_MODE_END #endif /* _keycache_h */ -- cgit v1.2.1