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'' --- storage/myisam/Makefile.am | 3 +- storage/myisam/ft_boolean_search.c | 16 +- storage/myisam/ft_myisam.c | 36 ++ storage/myisam/ft_nlq_search.c | 2 +- storage/myisam/ft_parser.c | 2 +- storage/myisam/ft_static.c | 13 - storage/myisam/ft_stopwords.c | 2 +- storage/myisam/ft_update.c | 4 +- storage/myisam/fulltext.h | 10 - storage/myisam/mi_check.c | 112 ++--- storage/myisam/mi_create.c | 8 +- storage/myisam/mi_delete.c | 12 +- storage/myisam/mi_delete_all.c | 1 - storage/myisam/mi_dynrec.c | 10 +- storage/myisam/mi_key.c | 2 +- storage/myisam/mi_log.c | 2 +- storage/myisam/mi_open.c | 15 +- storage/myisam/mi_packrec.c | 6 +- storage/myisam/mi_range.c | 2 +- storage/myisam/mi_search.c | 10 +- storage/myisam/mi_test1.c | 2 +- storage/myisam/mi_test2.c | 2 +- storage/myisam/mi_unique.c | 4 +- storage/myisam/mi_update.c | 2 +- storage/myisam/mi_write.c | 12 +- storage/myisam/myisamchk.c | 33 +- storage/myisam/myisamdef.h | 871 ++++++++++++++++++------------------- storage/myisam/myisamlog.c | 2 +- storage/myisam/myisampack.c | 1 + storage/myisam/rt_index.c | 4 +- storage/myisam/sort.c | 7 +- 31 files changed, 588 insertions(+), 620 deletions(-) create mode 100644 storage/myisam/ft_myisam.c (limited to 'storage/myisam') diff --git a/storage/myisam/Makefile.am b/storage/myisam/Makefile.am index 3c6a5c22234..c67db7c32fb 100644 --- a/storage/myisam/Makefile.am +++ b/storage/myisam/Makefile.am @@ -51,7 +51,8 @@ libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \ mi_delete_table.c mi_rename.c mi_check.c \ mi_keycache.c mi_preload.c \ ft_parser.c ft_stopwords.c ft_static.c \ - ft_update.c ft_boolean_search.c ft_nlq_search.c sort.c \ + ft_update.c ft_boolean_search.c ft_nlq_search.c \ + ft_myisam.c sort.c \ rt_index.c rt_key.c rt_mbr.c rt_split.c sp_key.c CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all rt_test.MY? sp_test.MY? DEFS = -DMAP_TO_USE_RAID diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 4204f211f2e..a4c39f06105 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -150,7 +150,7 @@ static int FTB_WORD_cmp(my_off_t *v, FTB_WORD *a, FTB_WORD *b) static int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b) { /* ORDER BY word DESC, ndepth DESC */ - int i= mi_compare_text(cs, (uchar*) (*b)->word+1,(*b)->len-1, + int i= ha_compare_text(cs, (uchar*) (*b)->word+1,(*b)->len-1, (uchar*) (*a)->word+1,(*a)->len-1,0,0); if (!i) i=CMP_NUM((*b)->ndepth,(*a)->ndepth); @@ -183,7 +183,7 @@ static int ftb_query_add_word(void *param, char *word, int word_len, case FT_TOKEN_WORD: ftbw= (FTB_WORD *)alloc_root(&ftb_param->ftb->mem_root, sizeof(FTB_WORD) + - (info->trunc ? MI_MAX_KEY_BUFF : + (info->trunc ? HA_MAX_KEY_BUFF : word_len * ftb_param->ftb->charset->mbmaxlen + HA_FT_WLEN + ftb_param->ftb->info->s->rec_reflength)); @@ -332,7 +332,6 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) byte *lastkey_buf=ftbw->word+ftbw->off; LINT_INIT(off); - LINT_INIT(off); if (ftbw->flags & FTB_FLAG_TRUNC) lastkey_buf+=ftbw->len; @@ -376,7 +375,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) if (!r && !ftbw->off) { - r= mi_compare_text(ftb->charset, + r= ha_compare_text(ftb->charset, info->lastkey+1, info->lastkey_length-extra-1, (uchar*) ftbw->word+1, @@ -599,8 +598,9 @@ static int ftb_phrase_add_word(void *param, char *word, int word_len, { FT_WORD *phrase_word= (FT_WORD *)phrase->data; FT_WORD *document_word= (FT_WORD *)document->data; - if (my_strnncoll(phrase_param->cs, phrase_word->pos, phrase_word->len, - document_word->pos, document_word->len)) + if (my_strnncoll(phrase_param->cs, (uchar*) phrase_word->pos, + phrase_word->len, + (uchar*) document_word->pos, document_word->len)) return 0; } phrase_param->match++; @@ -829,7 +829,7 @@ static int ftb_find_relevance_add_word(void *param, char *word, int len, for (a= 0, b= ftb->queue.elements, c= (a+b)/2; b-a>1; c= (a+b)/2) { ftbw= ftb->list[c]; - if (mi_compare_text(ftb->charset, (uchar*)word, len, + if (ha_compare_text(ftb->charset, (uchar*)word, len, (uchar*)ftbw->word+1, ftbw->len-1, (my_bool)(ftbw->flags&FTB_FLAG_TRUNC), 0) > 0) b= c; @@ -839,7 +839,7 @@ static int ftb_find_relevance_add_word(void *param, char *word, int len, for (; c >= 0; c--) { ftbw= ftb->list[c]; - if (mi_compare_text(ftb->charset, (uchar*)word, len, + if (ha_compare_text(ftb->charset, (uchar*)word, len, (uchar*)ftbw->word + 1,ftbw->len - 1, (my_bool)(ftbw->flags & FTB_FLAG_TRUNC), 0)) break; diff --git a/storage/myisam/ft_myisam.c b/storage/myisam/ft_myisam.c new file mode 100644 index 00000000000..76c04ba4c0b --- /dev/null +++ b/storage/myisam/ft_myisam.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 */ + +/* Written by Sergei A. Golubchik, who has a shared copyright to this code */ + +/* + This function is for interface functions between fulltext and myisam +*/ + +#include "ftdefs.h" + +FT_INFO *ft_init_search(uint flags, void *info, uint keynr, + byte *query, uint query_len, CHARSET_INFO *cs, + byte *record) +{ + FT_INFO *res; + if (flags & FT_BOOL) + res= ft_init_boolean_search((MI_INFO *)info, keynr, query, query_len,cs); + else + res= ft_init_nlq_search((MI_INFO *)info, keynr, query, query_len, flags, + record); + return res; +} diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index b4468d8bd95..3e79366a81e 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -104,7 +104,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) { if (keylen && - mi_compare_text(aio->charset,info->lastkey+1, + ha_compare_text(aio->charset,info->lastkey+1, info->lastkey_length-extra-1, keybuff+1,keylen-1,0,0)) break; diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index f333a661ea9..713ae8e8aab 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -34,7 +34,7 @@ typedef struct st_my_ft_parser_param static int FT_WORD_cmp(CHARSET_INFO* cs, FT_WORD *w1, FT_WORD *w2) { - return mi_compare_text(cs, (uchar*) w1->pos, w1->len, + return ha_compare_text(cs, (uchar*) w1->pos, w1->len, (uchar*) w2->pos, w2->len, 0, 0); } diff --git a/storage/myisam/ft_static.c b/storage/myisam/ft_static.c index 6cfb0d59e62..19f65b09ae8 100644 --- a/storage/myisam/ft_static.c +++ b/storage/myisam/ft_static.c @@ -56,19 +56,6 @@ const struct _ft_vft _ft_vft_boolean = { }; -FT_INFO *ft_init_search(uint flags, void *info, uint keynr, - byte *query, uint query_len, CHARSET_INFO *cs, - byte *record) -{ - FT_INFO *res; - if (flags & FT_BOOL) - res= ft_init_boolean_search((MI_INFO *)info, keynr, query, query_len,cs); - else - res= ft_init_nlq_search((MI_INFO *)info, keynr, query, query_len, flags, - record); - return res; -} - const char *ft_stopword_file = 0; const char *ft_precompiled_stopwords[] = { diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 3b5a1752ff7..8da32474690 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -30,7 +30,7 @@ static TREE *stopwords3=NULL; static int FT_STOPWORD_cmp(void* cmp_arg __attribute__((unused)), FT_STOPWORD *w1, FT_STOPWORD *w2) { - return mi_compare_text(default_charset_info, + return ha_compare_text(default_charset_info, (uchar *)w1->pos,w1->len, (uchar *)w2->pos,w2->len,0,0); } diff --git a/storage/myisam/ft_update.c b/storage/myisam/ft_update.c index 1ec91b41218..548c5c13f36 100644 --- a/storage/myisam/ft_update.c +++ b/storage/myisam/ft_update.c @@ -186,7 +186,7 @@ int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2) { if ((ftsi1.pos != ftsi2.pos) && (!ftsi1.pos || !ftsi2.pos || - mi_compare_text(cs, (uchar*) ftsi1.pos,ftsi1.len, + ha_compare_text(cs, (uchar*) ftsi1.pos,ftsi1.len, (uchar*) ftsi2.pos,ftsi2.len,0,0))) DBUG_RETURN(THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT); } @@ -214,7 +214,7 @@ int _mi_ft_update(MI_INFO *info, uint keynr, byte *keybuf, error=0; while(old_word->pos && new_word->pos) { - cmp= mi_compare_text(cs, (uchar*) old_word->pos,old_word->len, + cmp= ha_compare_text(cs, (uchar*) old_word->pos,old_word->len, (uchar*) new_word->pos,new_word->len,0,0); cmp2= cmp ? 0 : (fabs(old_word->weight - new_word->weight) > 1.e-5); diff --git a/storage/myisam/fulltext.h b/storage/myisam/fulltext.h index d8c74d4e94b..90f6ba3bb8b 100644 --- a/storage/myisam/fulltext.h +++ b/storage/myisam/fulltext.h @@ -21,18 +21,8 @@ #include "myisamdef.h" #include "ft_global.h" -#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]; - int _mi_ft_cmp(MI_INFO *, uint, const byte *, const byte *); int _mi_ft_add(MI_INFO *, uint, byte *, const byte *, my_off_t); int _mi_ft_del(MI_INFO *, uint, byte *, const byte *, my_off_t); uint _mi_ft_convert_to_ft2(MI_INFO *, uint, uchar *); - diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index eb2f42697ce..e23e220b2d5 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -35,15 +35,15 @@ /* Functions defined in this file */ -static int check_k_link(MI_CHECK *param, MI_INFO *info,uint nr); -static int chk_index(MI_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo, +static int check_k_link(HA_CHECK *param, MI_INFO *info,uint nr); +static int chk_index(HA_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo, my_off_t page, uchar *buff, ha_rows *keys, ha_checksum *key_checksum, uint level); static uint isam_key_length(MI_INFO *info,MI_KEYDEF *keyinfo); static ha_checksum calc_checksum(ha_rows count); -static int writekeys(MI_CHECK *param, MI_INFO *info,byte *buff, +static int writekeys(HA_CHECK *param, MI_INFO *info,byte *buff, my_off_t filepos); -static int sort_one_index(MI_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo, +static int sort_one_index(HA_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo, my_off_t pagepos, File new_file); static int sort_key_read(MI_SORT_PARAM *sort_param,void *key); static int sort_ft_key_read(MI_SORT_PARAM *sort_param,void *key); @@ -57,13 +57,13 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, reg1 SORT_KEY_BLOCKS *key_block, uchar *key, my_off_t prev_block); static int sort_delete_record(MI_SORT_PARAM *sort_param); -/*static int flush_pending_blocks(MI_CHECK *param);*/ -static SORT_KEY_BLOCKS *alloc_key_blocks(MI_CHECK *param, uint blocks, +/*static int flush_pending_blocks(HA_CHECK *param);*/ +static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks, uint buffer_length); static ha_checksum mi_byte_checksum(const byte *buf, uint length); -static void set_data_file_type(SORT_INFO *sort_info, MYISAM_SHARE *share); +static void set_data_file_type(MI_SORT_INFO *sort_info, MYISAM_SHARE *share); -void myisamchk_init(MI_CHECK *param) +void myisamchk_init(HA_CHECK *param) { bzero((gptr) param,sizeof(*param)); param->opt_follow_links=1; @@ -85,7 +85,7 @@ void myisamchk_init(MI_CHECK *param) /* Check the status flags for the table */ -int chk_status(MI_CHECK *param, register MI_INFO *info) +int chk_status(HA_CHECK *param, register MI_INFO *info) { MYISAM_SHARE *share=info->s; @@ -113,7 +113,7 @@ int chk_status(MI_CHECK *param, register MI_INFO *info) /* Check delete links */ -int chk_del(MI_CHECK *param, register MI_INFO *info, uint test_flag) +int chk_del(HA_CHECK *param, register MI_INFO *info, uint test_flag) { reg2 ha_rows i; uint delete_link_length; @@ -222,7 +222,7 @@ wrong: /* Check delete links in index file */ -static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) +static int check_k_link(HA_CHECK *param, register MI_INFO *info, uint nr) { my_off_t next_link; uint block_size=(nr+1)*MI_MIN_KEY_BLOCK_LENGTH; @@ -266,7 +266,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) /* Check sizes of files */ -int chk_size(MI_CHECK *param, register MI_INFO *info) +int chk_size(HA_CHECK *param, register MI_INFO *info) { int error=0; register my_off_t skr,size; @@ -342,7 +342,7 @@ int chk_size(MI_CHECK *param, register MI_INFO *info) /* Check keys */ -int chk_key(MI_CHECK *param, register MI_INFO *info) +int chk_key(HA_CHECK *param, register MI_INFO *info) { uint key,found_keys=0,full_text_keys=0,result=0; ha_rows keys; @@ -528,7 +528,7 @@ do_stat: } /* chk_key */ -static int chk_index_down(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, +static int chk_index_down(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t page, uchar *buff, ha_rows *keys, ha_checksum *key_checksum, uint level) { @@ -651,13 +651,13 @@ int mi_collect_stats_nonulls_next(HA_KEYSEG *keyseg, ulonglong *notnull, /* Check if index is ok */ -static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, +static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t page, uchar *buff, ha_rows *keys, ha_checksum *key_checksum, uint level) { int flag; uint used_length,comp_flag,nod_flag,key_length=0; - uchar key[MI_MAX_POSSIBLE_KEY_BUFF],*temp_buff,*keypos,*old_keypos,*endpos; + uchar key[HA_MAX_POSSIBLE_KEY_BUFF],*temp_buff,*keypos,*old_keypos,*endpos; my_off_t next_page,record; char llbuff[22]; uint diff_pos[2]; @@ -854,7 +854,7 @@ static uint isam_key_length(MI_INFO *info, register MI_KEYDEF *keyinfo) /* Check that record-link is ok */ -int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) +int chk_data_link(HA_CHECK *param, MI_INFO *info,int extend) { int error,got_error,flag; uint key,left_length,b_type,field; @@ -864,7 +864,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) byte *record,*to; char llbuff[22],llbuff2[22],llbuff3[22]; ha_checksum intern_record_checksum; - ha_checksum key_checksum[MI_MAX_POSSIBLE_KEY]; + ha_checksum key_checksum[HA_MAX_POSSIBLE_KEY]; my_bool static_row_size; MI_KEYDEF *keyinfo; MI_BLOCK_INFO block_info; @@ -1296,7 +1296,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) /* Recover old table by reading each record and writing all keys */ /* Save new datafile-name in temp_filename */ -int mi_repair(MI_CHECK *param, register MI_INFO *info, +int mi_repair(HA_CHECK *param, register MI_INFO *info, my_string name, int rep_quick) { int error,got_error; @@ -1306,7 +1306,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, File new_file; MYISAM_SHARE *share=info->s; char llbuff[22],llbuff2[22]; - SORT_INFO sort_info; + MI_SORT_INFO sort_info; MI_SORT_PARAM sort_param; DBUG_ENTER("mi_repair"); @@ -1573,7 +1573,7 @@ err: /* Uppate keyfile when doing repair */ -static int writekeys(MI_CHECK *param, register MI_INFO *info, byte *buff, +static int writekeys(HA_CHECK *param, register MI_INFO *info, byte *buff, my_off_t filepos) { register uint i; @@ -1686,7 +1686,7 @@ int movepoint(register MI_INFO *info, byte *record, my_off_t oldpos, /* Tell system that we want all memory for our cache */ -void lock_memory(MI_CHECK *param __attribute__((unused))) +void lock_memory(HA_CHECK *param __attribute__((unused))) { #ifdef SUN_OS /* Key-cacheing thrases on sun 4.1 */ if (param->opt_lock_memory) @@ -1702,7 +1702,7 @@ void lock_memory(MI_CHECK *param __attribute__((unused))) /* Flush all changed blocks to disk */ -int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file) +int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file) { if (flush_key_blocks(key_cache, file, FLUSH_RELEASE)) { @@ -1717,12 +1717,12 @@ int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file) /* Sort index for more efficent reads */ -int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) +int mi_sort_index(HA_CHECK *param, register MI_INFO *info, my_string name) { reg2 uint key; reg1 MI_KEYDEF *keyinfo; File new_file; - my_off_t index_pos[MI_MAX_POSSIBLE_KEY]; + my_off_t index_pos[HA_MAX_POSSIBLE_KEY]; uint r_locks,w_locks; int old_lock; MYISAM_SHARE *share=info->s; @@ -1811,12 +1811,12 @@ err2: /* Sort records recursive using one index */ -static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, +static int sort_one_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pagepos, File new_file) { uint length,nod_flag,used_length, key_length; uchar *buff,*keypos,*endpos; - uchar key[MI_MAX_POSSIBLE_KEY_BUFF]; + uchar key[HA_MAX_POSSIBLE_KEY_BUFF]; my_off_t new_page_pos,next_page; char llbuff[22]; DBUG_ENTER("sort_one_index"); @@ -1929,7 +1929,7 @@ int change_to_newfile(const char * filename, const char * old_ext, /* Locks a whole file */ /* Gives an error-message if file can't be locked */ -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) { if (my_lock(file,lock_type,start,F_TO_EOF, @@ -1946,7 +1946,7 @@ int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type, /* Copy a block between two files */ -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) { char tmp_buff[IO_SIZE],*buff; @@ -1997,7 +1997,7 @@ err: <>0 Error */ -int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, +int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, const char * name, int rep_quick) { int got_error; @@ -2011,7 +2011,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, HA_KEYSEG *keyseg; ulong *rec_per_key_part; char llbuff[22]; - SORT_INFO sort_info; + MI_SORT_INFO sort_info; ulonglong key_map=share->state.key_map; DBUG_ENTER("mi_repair_by_sort"); @@ -2367,7 +2367,7 @@ err: <>0 Error */ -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) { #ifndef THREAD @@ -2385,7 +2385,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, HA_KEYSEG *keyseg; char llbuff[22]; IO_CACHE_SHARE io_share; - SORT_INFO sort_info; + MI_SORT_INFO sort_info; ulonglong key_map=share->state.key_map; pthread_attr_t thr_attr; DBUG_ENTER("mi_repair_parallel"); @@ -2774,7 +2774,7 @@ err: static int sort_key_read(MI_SORT_PARAM *sort_param, void *key) { int error; - SORT_INFO *sort_info=sort_param->sort_info; + MI_SORT_INFO *sort_info=sort_param->sort_info; MI_INFO *info=sort_info->info; DBUG_ENTER("sort_key_read"); @@ -2801,7 +2801,7 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key) static int sort_ft_key_read(MI_SORT_PARAM *sort_param, void *key) { int error; - SORT_INFO *sort_info=sort_param->sort_info; + MI_SORT_INFO *sort_info=sort_param->sort_info; MI_INFO *info=sort_info->info; FT_WORD *wptr=0; DBUG_ENTER("sort_ft_key_read"); @@ -2858,8 +2858,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) my_off_t pos; byte *to; MI_BLOCK_INFO block_info; - SORT_INFO *sort_info=sort_param->sort_info; - MI_CHECK *param=sort_info->param; + MI_SORT_INFO *sort_info=sort_param->sort_info; + HA_CHECK *param=sort_info->param; MI_INFO *info=sort_info->info; MYISAM_SHARE *share=info->s; char llbuff[22],llbuff2[22]; @@ -3246,8 +3246,8 @@ int sort_write_record(MI_SORT_PARAM *sort_param) ulong block_length,reclength; byte *from; byte block_buff[8]; - SORT_INFO *sort_info=sort_param->sort_info; - MI_CHECK *param=sort_info->param; + MI_SORT_INFO *sort_info=sort_param->sort_info; + HA_CHECK *param=sort_info->param; MI_INFO *info=sort_info->info; MYISAM_SHARE *share=info->s; DBUG_ENTER("sort_write_record"); @@ -3273,7 +3273,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param) { /* must be sure that local buffer is big enough */ reclength=info->s->base.pack_reclength+ - _my_calc_total_blob_length(info,sort_param->record)+ + _mi_calc_total_blob_length(info,sort_param->record)+ ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+ MI_DYN_DELETE_BLOCK_HEADER; if (sort_info->buff_length < reclength) @@ -3361,8 +3361,8 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a) { uint diff_pos[2]; char llbuff[22],llbuff2[22]; - SORT_INFO *sort_info=sort_param->sort_info; - MI_CHECK *param= sort_info->param; + MI_SORT_INFO *sort_info=sort_param->sort_info; + HA_CHECK *param= sort_info->param; int cmp; if (sort_info->key_block->inited) @@ -3423,7 +3423,7 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a) int sort_ft_buf_flush(MI_SORT_PARAM *sort_param) { - SORT_INFO *sort_info=sort_param->sort_info; + MI_SORT_INFO *sort_info=sort_param->sort_info; SORT_KEY_BLOCKS *key_block=sort_info->key_block; MYISAM_SHARE *share=sort_info->info->s; uint val_off, val_len; @@ -3470,7 +3470,7 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) { uint a_len, val_off, val_len, error; uchar *p; - SORT_INFO *sort_info=sort_param->sort_info; + MI_SORT_INFO *sort_info=sort_param->sort_info; SORT_FT_BUF *ft_buf=sort_info->ft_buf; SORT_KEY_BLOCKS *key_block=sort_info->key_block; @@ -3500,7 +3500,7 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) } get_key_full_length_rdonly(val_off, ft_buf->lastkey); - if (mi_compare_text(sort_param->seg->charset, + if (ha_compare_text(sort_param->seg->charset, ((uchar *)a)+1,a_len-1, ft_buf->lastkey+1,val_off-1, 0, 0)==0) { @@ -3575,8 +3575,8 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, MI_KEY_PARAM s_temp; MI_INFO *info; MI_KEYDEF *keyinfo=sort_param->keyinfo; - SORT_INFO *sort_info= sort_param->sort_info; - MI_CHECK *param=sort_info->param; + MI_SORT_INFO *sort_info= sort_param->sort_info; + HA_CHECK *param=sort_info->param; DBUG_ENTER("sort_insert_key"); anc_buff=key_block->buff; @@ -3654,8 +3654,8 @@ static int sort_delete_record(MI_SORT_PARAM *sort_param) uint i; int old_file,error; uchar *key; - SORT_INFO *sort_info=sort_param->sort_info; - MI_CHECK *param=sort_info->param; + MI_SORT_INFO *sort_info=sort_param->sort_info; + HA_CHECK *param=sort_info->param; MI_INFO *info=sort_info->info; DBUG_ENTER("sort_delete_record"); @@ -3711,7 +3711,7 @@ int flush_pending_blocks(MI_SORT_PARAM *sort_param) uint nod_flag,length; my_off_t filepos,key_file_length; SORT_KEY_BLOCKS *key_block; - SORT_INFO *sort_info= sort_param->sort_info; + MI_SORT_INFO *sort_info= sort_param->sort_info; myf myf_rw=sort_info->param->myf_rw; MI_INFO *info=sort_info->info; MI_KEYDEF *keyinfo=sort_param->keyinfo; @@ -3749,7 +3749,7 @@ int flush_pending_blocks(MI_SORT_PARAM *sort_param) /* alloc space and pointers for key_blocks */ -static SORT_KEY_BLOCKS *alloc_key_blocks(MI_CHECK *param, uint blocks, +static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks, uint buffer_length) { reg1 uint i; @@ -3786,7 +3786,7 @@ int test_if_almost_full(MI_INFO *info) /* Recreate table with bigger more alloced record-data */ -int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) +int recreate_table(HA_CHECK *param, MI_INFO **org_info, char *filename) { int error; MI_INFO info; @@ -3953,7 +3953,7 @@ end: /* write suffix to data file if neaded */ -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) { MI_INFO *info=sort_info->info; @@ -3974,7 +3974,7 @@ int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile) /* Update state and myisamchk_time of indexfile */ -int update_state_info(MI_CHECK *param, MI_INFO *info,uint update) +int update_state_info(HA_CHECK *param, MI_INFO *info,uint update) { MYISAM_SHARE *share=info->s; @@ -4046,7 +4046,7 @@ err: param->auto_increment is bigger than the biggest key. */ -void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, +void update_auto_increment_key(HA_CHECK *param, MI_INFO *info, my_bool repair_only) { byte *record; @@ -4278,7 +4278,7 @@ my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, static void -set_data_file_type(SORT_INFO *sort_info, MYISAM_SHARE *share) +set_data_file_type(MI_SORT_INFO *sort_info, MYISAM_SHARE *share) { if ((sort_info->new_data_file_type=share->data_file_type) == COMPRESSED_RECORD && sort_info->param->testflag & T_UNPACK) diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 3be998b2c17..d6ffba596f5 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -56,7 +56,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, HA_KEYSEG *keyseg,tmp_keyseg; MI_COLUMNDEF *rec; ulong *rec_per_key_part; - my_off_t key_root[MI_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE]; + my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE]; MI_CREATE_INFO tmp_create_info; DBUG_ENTER("mi_create"); @@ -92,7 +92,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ci->reloc_rows=ci->max_rows; /* Check if wrong parameter */ if (!(rec_per_key_part= - (ulong*) my_malloc((keys + uniques)*MI_MAX_KEY_SEG*sizeof(long), + (ulong*) my_malloc((keys + uniques)*HA_MAX_KEY_SEG*sizeof(long), MYF(MY_WME | MY_ZEROFILL)))) DBUG_RETURN(my_errno); @@ -414,7 +414,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, } } /* if HA_FULLTEXT */ key_segs+=keydef->keysegs; - if (keydef->keysegs > MI_MAX_KEY_SEG) + if (keydef->keysegs > HA_MAX_KEY_SEG) { my_errno=HA_WRONG_CREATE_OPTION; goto err; @@ -431,7 +431,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, keydef->block_length= MI_BLOCK_SIZE(length-real_length_diff, pointer,MI_MAX_KEYPTR_SIZE); if (keydef->block_length > MI_MAX_KEY_BLOCK_LENGTH || - length >= MI_MAX_KEY_BUFF) + length >= HA_MAX_KEY_BUFF) { my_errno=HA_WRONG_CREATE_OPTION; goto err; diff --git a/storage/myisam/mi_delete.c b/storage/myisam/mi_delete.c index 2bc99d65dd2..ae464936653 100644 --- a/storage/myisam/mi_delete.c +++ b/storage/myisam/mi_delete.c @@ -160,7 +160,7 @@ static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_RETURN(my_errno=HA_ERR_CRASHED); } if (!(root_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ - MI_MAX_KEY_BUFF*2))) + HA_MAX_KEY_BUFF*2))) { DBUG_PRINT("error",("Couldn't allocate memory")); DBUG_RETURN(my_errno=ENOMEM); @@ -222,7 +222,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, my_bool last_key; uchar *leaf_buff,*keypos; my_off_t leaf_page,next_block; - uchar lastkey[MI_MAX_KEY_BUFF]; + uchar lastkey[HA_MAX_KEY_BUFF]; DBUG_ENTER("d_search"); DBUG_DUMP("page",(byte*) anc_buff,mi_getint(anc_buff)); @@ -307,7 +307,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, { leaf_page=_mi_kpos(nod_flag,keypos); if (!(leaf_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ - MI_MAX_KEY_BUFF*2))) + HA_MAX_KEY_BUFF*2))) { DBUG_PRINT("error",("Couldn't allocate memory")); my_errno=ENOMEM; @@ -406,7 +406,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, int ret_value,length; uint a_length,nod_flag,tmp; my_off_t next_page; - uchar keybuff[MI_MAX_KEY_BUFF],*endpos,*next_buff,*key_start, *prev_key; + uchar keybuff[HA_MAX_KEY_BUFF],*endpos,*next_buff,*key_start, *prev_key; MYISAM_SHARE *share=info->s; MI_KEY_PARAM s_temp; DBUG_ENTER("del"); @@ -423,7 +423,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, { next_page= _mi_kpos(nod_flag,endpos); if (!(next_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ - MI_MAX_KEY_BUFF*2))) + HA_MAX_KEY_BUFF*2))) DBUG_RETURN(-1); if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,next_buff,0)) ret_value= -1; @@ -510,7 +510,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, uint length,anc_length,buff_length,leaf_length,p_length,s_length,nod_flag, key_reflength,key_length; my_off_t next_page; - uchar anc_key[MI_MAX_KEY_BUFF],leaf_key[MI_MAX_KEY_BUFF], + uchar anc_key[HA_MAX_KEY_BUFF],leaf_key[HA_MAX_KEY_BUFF], *buff,*endpos,*next_keypos,*anc_pos,*half_pos,*temp_pos,*prev_key, *after_key; MI_KEY_PARAM s_temp; diff --git a/storage/myisam/mi_delete_all.c b/storage/myisam/mi_delete_all.c index 51f1e44d6d2..1e2fcac4486 100644 --- a/storage/myisam/mi_delete_all.c +++ b/storage/myisam/mi_delete_all.c @@ -22,7 +22,6 @@ int mi_delete_all_rows(MI_INFO *info) { uint i; - char buf[22]; MYISAM_SHARE *share=info->s; MI_STATE_INFO *state=&share->state; DBUG_ENTER("mi_delete_all_rows"); diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 36d88bd362a..44367fecc1c 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -240,7 +240,7 @@ int _mi_write_blob_record(MI_INFO *info, const byte *record) extra= (ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+ MI_DYN_DELETE_BLOCK_HEADER+1); reclength= (info->s->base.pack_reclength + - _my_calc_total_blob_length(info,record)+ extra); + _mi_calc_total_blob_length(info,record)+ extra); #ifdef NOT_USED /* We now support big rows */ if (reclength > MI_DYN_MAX_ROW_LENGTH) { @@ -274,7 +274,7 @@ int _mi_update_blob_record(MI_INFO *info, my_off_t pos, const byte *record) extra= (ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+ MI_DYN_DELETE_BLOCK_HEADER); reclength= (info->s->base.pack_reclength+ - _my_calc_total_blob_length(info,record)+ extra); + _mi_calc_total_blob_length(info,record)+ extra); #ifdef NOT_USED /* We now support big rows */ if (reclength > MI_DYN_MAX_ROW_LENGTH) { @@ -1244,7 +1244,7 @@ err: /* Calc length of blob. Update info in blobs->length */ -ulong _my_calc_total_blob_length(MI_INFO *info, const byte *record) +ulong _mi_calc_total_blob_length(MI_INFO *info, const byte *record) { ulong length; MI_BLOB *blob,*end; @@ -1278,7 +1278,7 @@ ulong _mi_calc_blob_length(uint length, const byte *pos) } -void _my_store_blob_length(byte *pos,uint pack_length,uint length) +void _mi_store_blob_length(byte *pos,uint pack_length,uint length) { switch (pack_length) { case 1: @@ -1431,7 +1431,7 @@ int _mi_cmp_dynamic_record(register MI_INFO *info, register const byte *record) if (info->s->base.blobs) { if (!(buffer=(byte*) my_alloca(info->s->base.pack_reclength+ - _my_calc_total_blob_length(info,record)))) + _mi_calc_total_blob_length(info,record)))) DBUG_RETURN(-1); } reclength=_mi_rec_pack(info,buffer,record); diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index f8463a0b6b0..859912dfdab 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -448,7 +448,7 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, /* The above changed info->lastkey2. Inform mi_rnext_same(). */ info->update&= ~HA_STATE_RNEXT_SAME; - _my_store_blob_length(record+keyseg->start, + _mi_store_blob_length(record+keyseg->start, (uint) keyseg->bit_start,length); key+=length; } diff --git a/storage/myisam/mi_log.c b/storage/myisam/mi_log.c index 13842c56828..40566df10d8 100644 --- a/storage/myisam/mi_log.c +++ b/storage/myisam/mi_log.c @@ -134,7 +134,7 @@ void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info, if (!info->s->base.blobs) length=info->s->base.reclength; else - length=info->s->base.reclength+ _my_calc_total_blob_length(info,record); + length=info->s->base.reclength+ _mi_calc_total_blob_length(info,record); buff[0]=(char) command; mi_int2store(buff+1,info->dfile); mi_int4store(buff+3,pid); diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index abf1d1ea9a7..a00bd6be008 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -83,8 +83,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) char *disk_cache, *disk_pos, *end_pos; MI_INFO info,*m_info,*old_info; MYISAM_SHARE share_buff,*share; - ulong rec_per_key_part[MI_MAX_POSSIBLE_KEY*MI_MAX_KEY_SEG]; - my_off_t key_root[MI_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE]; + ulong rec_per_key_part[HA_MAX_POSSIBLE_KEY*HA_MAX_KEY_SEG]; + my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE]; ulonglong max_key_file_length, max_data_file_length; DBUG_ENTER("mi_open"); @@ -105,7 +105,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) share_buff.state.rec_per_key_part=rec_per_key_part; share_buff.state.key_root=key_root; share_buff.state.key_del=key_del; - share_buff.key_cache= multi_key_cache_search(name_buff, strlen(name_buff)); + share_buff.key_cache= multi_key_cache_search(name_buff, strlen(name_buff), + dflt_key_cache); DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_open", if (strstr(name, "/t1")) @@ -211,7 +212,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) len,MI_BASE_INFO_SIZE)); } disk_pos= (char*) - my_n_base_info_read((uchar*) disk_cache + base_pos, &share->base); + mi_n_base_info_read((uchar*) disk_cache + base_pos, &share->base); share->state.state_length=base_pos; if (!(open_flags & HA_OPEN_FOR_REPAIR) && @@ -233,8 +234,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) } key_parts+=fulltext_keys*FT_SEGS; - if (share->base.max_key_length > MI_MAX_KEY_BUFF || keys > MI_MAX_KEY || - key_parts >= MI_MAX_KEY * MI_MAX_KEY_SEG) + if (share->base.max_key_length > HA_MAX_KEY_BUFF || keys > MI_MAX_KEY || + key_parts >= MI_MAX_KEY * HA_MAX_KEY_SEG) { DBUG_PRINT("error",("Wrong key info: Max_key_length: %d keys: %d key_parts: %d", share->base.max_key_length, keys, key_parts)); my_errno=HA_ERR_UNSUPPORTED; @@ -990,7 +991,7 @@ uint mi_base_info_write(File file, MI_BASE_INFO *base) } -uchar *my_n_base_info_read(uchar *ptr, MI_BASE_INFO *base) +uchar *mi_n_base_info_read(uchar *ptr, MI_BASE_INFO *base) { base->keystart = mi_sizekorr(ptr); ptr +=8; base->max_data_file_length = mi_sizekorr(ptr); ptr +=8; diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index aa6ea016070..89b0833742e 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -102,6 +102,7 @@ static void init_bit_buffer(MI_BIT_BUFF *bit_buff,uchar *buffer,uint length); static uint fill_and_get_bits(MI_BIT_BUFF *bit_buff,uint count); static void fill_buffer(MI_BIT_BUFF *bit_buff); static uint max_bit(uint value); +static uint read_pack_length(uint version, const uchar *buf, ulong *length); #ifdef HAVE_MMAP static uchar *_mi_mempack_get_block_info(MI_INFO *myisam,MI_BLOCK_INFO *info, uchar *header); @@ -775,7 +776,7 @@ static void uf_blob(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, return; } decode_bytes(rec,bit_buff,bit_buff->blob_pos,bit_buff->blob_pos+length); - _my_store_blob_length((byte*) to,pack_length,length); + _mi_store_blob_length((byte*) to,pack_length,length); memcpy_fixed((char*) to+pack_length,(char*) &bit_buff->blob_pos, sizeof(char*)); bit_buff->blob_pos+=length; @@ -1178,7 +1179,6 @@ static int _mi_read_rnd_mempack_record(MI_INFO*, byte *,my_off_t, my_bool); my_bool _mi_memmap_file(MI_INFO *info) { - byte *file_map; MYISAM_SHARE *share=info->s; DBUG_ENTER("mi_memmap_file"); @@ -1315,7 +1315,7 @@ uint save_pack_length(uint version, byte *block_buff, ulong length) } -uint read_pack_length(uint version, const uchar *buf, ulong *length) +static uint read_pack_length(uint version, const uchar *buf, ulong *length) { if (buf[0] < 254) { diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c index e78f3b11625..1c41c96e95f 100644 --- a/storage/myisam/mi_range.c +++ b/storage/myisam/mi_range.c @@ -217,7 +217,7 @@ static uint _mi_keynr(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, uchar *keypos, uint *ret_max_key) { uint nod_flag,keynr,max_key; - uchar t_buff[MI_MAX_KEY_BUFF],*end; + uchar t_buff[HA_MAX_KEY_BUFF],*end; end= page+mi_getint(page); nod_flag=mi_test_if_nod(page); diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index a6c2cbd6082..b2c5cba45d9 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -61,7 +61,7 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, int error,flag; uint nod_flag; uchar *keypos,*maxpos; - uchar lastkey[MI_MAX_KEY_BUFF],*buff; + uchar lastkey[HA_MAX_KEY_BUFF],*buff; DBUG_ENTER("_mi_search"); DBUG_PRINT("enter",("pos: %lu nextflag: %u lastpos: %lu", (ulong) pos, nextflag, (ulong) info->lastpos)); @@ -243,7 +243,7 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, { int flag; uint nod_flag,length,not_used[2]; - uchar t_buff[MI_MAX_KEY_BUFF],*end; + uchar t_buff[HA_MAX_KEY_BUFF],*end; DBUG_ENTER("_mi_seq_search"); LINT_INIT(flag); LINT_INIT(length); @@ -296,7 +296,7 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, int key_len_skip, seg_len_pack, key_len_left; uchar *end, *kseg, *vseg; uchar *sort_order=keyinfo->seg->charset->sort_order; - uchar tt_buff[MI_MAX_KEY_BUFF+2], *t_buff=tt_buff+2; + uchar tt_buff[HA_MAX_KEY_BUFF+2], *t_buff=tt_buff+2; uchar *saved_from, *saved_to, *saved_vseg; uint saved_length=0, saved_prefix_len=0; uint length_pack; @@ -919,7 +919,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_ENTER("_mi_get_binary_pack_key"); page= *page_pos; - page_end=page+MI_MAX_KEY_BUFF+1; + page_end=page+HA_MAX_KEY_BUFF+1; start_key=key; /* @@ -1207,7 +1207,7 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo, { int error; uint nod_flag; - uchar lastkey[MI_MAX_KEY_BUFF]; + uchar lastkey[HA_MAX_KEY_BUFF]; DBUG_ENTER("_mi_search_next"); DBUG_PRINT("enter",("nextflag: %u lastpos: %lu int_keypos: %lu", nextflag, (ulong) info->lastpos, diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c index 0e62b074376..9f7c55444c1 100644 --- a/storage/myisam/mi_test1.c +++ b/storage/myisam/mi_test1.c @@ -628,7 +628,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), key_type= HA_KEYTYPE_VARTEXT1; break; case 'k': - if (key_length < 4 || key_length > MI_MAX_KEY_LENGTH) + if (key_length < 4 || key_length > HA_MAX_KEY_LENGTH) { fprintf(stderr,"Wrong key length\n"); exit(1); diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index e77a37d853f..fb118f8cad2 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -813,7 +813,7 @@ end: printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete); if (rec_pointer_size) printf("Record pointer size: %d\n",rec_pointer_size); - printf("myisam_block_size: %u\n", myisam_block_size); + printf("myisam_block_size: %lu\n", myisam_block_size); if (key_cacheing) { puts("Key cache used"); diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c index b698968127b..2779577e317 100644 --- a/storage/myisam/mi_unique.c +++ b/storage/myisam/mi_unique.c @@ -57,7 +57,7 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, if (_mi_search_next(info,info->s->keyinfo+def->key, info->lastkey, MI_UNIQUE_HASH_LENGTH, SEARCH_BIGGER, info->s->state.key_root[def->key]) || - bcmp(info->lastkey, key_buff, MI_UNIQUE_HASH_LENGTH)) + memcmp((char*) info->lastkey, (char*) key_buff, MI_UNIQUE_HASH_LENGTH)) { info->page_changed=1; /* Can't optimize read next */ info->lastpos=lastpos; @@ -213,7 +213,7 @@ int mi_unique_comp(MI_UNIQUEDEF *def, const byte *a, const byte *b, if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 || type == HA_KEYTYPE_VARTEXT2) { - if (mi_compare_text(keyseg->charset, (uchar *) pos_a, a_length, + if (ha_compare_text(keyseg->charset, (uchar *) pos_a, a_length, (uchar *) pos_b, b_length, 0, 1)) return 1; } diff --git a/storage/myisam/mi_update.c b/storage/myisam/mi_update.c index 937c9983b45..063c48bb7f0 100644 --- a/storage/myisam/mi_update.c +++ b/storage/myisam/mi_update.c @@ -24,7 +24,7 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) int flag,key_changed,save_errno; reg3 my_off_t pos; uint i; - uchar old_key[MI_MAX_KEY_BUFF],*new_key; + uchar old_key[HA_MAX_KEY_BUFF],*new_key; bool auto_key_changed=0; ulonglong changed; MYISAM_SHARE *share=info->s; diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 5e79b2937cc..6291d176612 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -334,7 +334,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, int error,flag; uint nod_flag, search_key_length; uchar *temp_buff,*keypos; - uchar keybuff[MI_MAX_KEY_BUFF]; + uchar keybuff[HA_MAX_KEY_BUFF]; my_bool was_last_key; my_off_t next_page, dupp_key_pos; DBUG_ENTER("w_search"); @@ -342,7 +342,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY; if (!(temp_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ - MI_MAX_KEY_BUFF*2))) + HA_MAX_KEY_BUFF*2))) DBUG_RETURN(-1); if (!_mi_fetch_keypage(info,keyinfo,page,DFLT_INIT_HITS,temp_buff,0)) goto err; @@ -533,7 +533,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, get_key_length(alen,a); DBUG_ASSERT(info->ft1_to_ft2==0); if (alen == blen && - mi_compare_text(keyinfo->seg->charset, a, alen, b, blen, 0, 0)==0) + ha_compare_text(keyinfo->seg->charset, a, alen, b, blen, 0, 0)==0) { /* yup. converting */ info->ft1_to_ft2=(DYNAMIC_ARRAY *) @@ -693,7 +693,7 @@ static uchar *_mi_find_last_pos(MI_KEYDEF *keyinfo, uchar *page, { uint keys,length,last_length,key_ref_length; uchar *end,*lastpos,*prevpos; - uchar key_buff[MI_MAX_KEY_BUFF]; + uchar key_buff[HA_MAX_KEY_BUFF]; DBUG_ENTER("_mi_find_last_pos"); key_ref_length=2; @@ -749,7 +749,7 @@ static int _mi_balance_page(register MI_INFO *info, MI_KEYDEF *keyinfo, length,keys; uchar *pos,*buff,*extra_buff; my_off_t next_page,new_pos; - byte tmp_part_key[MI_MAX_KEY_BUFF]; + byte tmp_part_key[HA_MAX_KEY_BUFF]; DBUG_ENTER("_mi_balance_page"); k_length=keyinfo->keylength; @@ -915,7 +915,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) Probably I can use info->lastkey here, but I'm not sure, and to be safe I'd better use local lastkey. */ - uchar lastkey[MI_MAX_KEY_BUFF]; + uchar lastkey[HA_MAX_KEY_BUFF]; uint keylen; MI_KEYDEF *keyinfo; diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index e2c8b446322..192500e432e 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -17,7 +17,6 @@ /* Describe, check and repair of MyISAM tables */ #include "fulltext.h" - #include #include #include @@ -72,9 +71,9 @@ static const char *myisam_stats_method_str="nulls_unequal"; static void get_options(int *argc,char * * *argv); static void print_version(void); static void usage(void); -static int myisamchk(MI_CHECK *param, char *filename); -static void descript(MI_CHECK *param, register MI_INFO *info, my_string name); -static int mi_sort_records(MI_CHECK *param, register MI_INFO *info, +static int myisamchk(HA_CHECK *param, char *filename); +static void descript(HA_CHECK *param, register MI_INFO *info, my_string name); +static int mi_sort_records(HA_CHECK *param, register MI_INFO *info, my_string name, uint sort_key, my_bool write_info, my_bool update_index); static int sort_record_index(MI_SORT_PARAM *sort_param, MI_INFO *info, @@ -82,7 +81,7 @@ static int sort_record_index(MI_SORT_PARAM *sort_param, MI_INFO *info, my_off_t page,uchar *buff,uint sortkey, File new_file, my_bool update_index); -MI_CHECK check_param; +HA_CHECK check_param; /* Main program */ @@ -704,7 +703,7 @@ get_one_option(int optid, case OPT_STATS_METHOD: { int method; - enum_mi_stats_method method_conv; + enum_handler_stats_method method_conv; myisam_stats_method_str= argument; if ((method=find_type(argument, &myisam_stats_method_typelib, 2)) <= 0) { @@ -801,7 +800,7 @@ static void get_options(register int *argc,register char ***argv) /* Check table */ -static int myisamchk(MI_CHECK *param, my_string filename) +static int myisamchk(HA_CHECK *param, my_string filename) { int error,lock_type,recreate; int rep_quick= param->testflag & (T_QUICK | T_FORCE_UNIQUENESS); @@ -1206,7 +1205,7 @@ end2: /* Write info about table */ -static void descript(MI_CHECK *param, register MI_INFO *info, my_string name) +static void descript(HA_CHECK *param, register MI_INFO *info, my_string name) { uint key,keyseg_nr,field,start; reg3 MI_KEYDEF *keyinfo; @@ -1471,7 +1470,7 @@ static void descript(MI_CHECK *param, register MI_INFO *info, my_string name) /* Sort records according to one key */ -static int mi_sort_records(MI_CHECK *param, +static int mi_sort_records(HA_CHECK *param, register MI_INFO *info, my_string name, uint sort_key, my_bool write_info, @@ -1485,7 +1484,7 @@ static int mi_sort_records(MI_CHECK *param, ha_rows old_record_count; MYISAM_SHARE *share=info->s; char llbuff[22],llbuff2[22]; - SORT_INFO sort_info; + MI_SORT_INFO sort_info; MI_SORT_PARAM sort_param; DBUG_ENTER("sort_records"); @@ -1660,10 +1659,10 @@ static int sort_record_index(MI_SORT_PARAM *sort_param,MI_INFO *info, uint nod_flag,used_length,key_length; uchar *temp_buff,*keypos,*endpos; my_off_t next_page,rec_pos; - uchar lastkey[MI_MAX_KEY_BUFF]; + uchar lastkey[HA_MAX_KEY_BUFF]; char llbuff[22]; - SORT_INFO *sort_info= sort_param->sort_info; - MI_CHECK *param=sort_info->param; + MI_SORT_INFO *sort_info= sort_param->sort_info; + HA_CHECK *param=sort_info->param; DBUG_ENTER("sort_record_index"); nod_flag=mi_test_if_nod(buff); @@ -1751,7 +1750,7 @@ err: static int not_killed= 0; -volatile int *killed_ptr(MI_CHECK *param __attribute__((unused))) +volatile int *killed_ptr(HA_CHECK *param __attribute__((unused))) { return ¬_killed; /* always NULL */ } @@ -1759,7 +1758,7 @@ volatile int *killed_ptr(MI_CHECK *param __attribute__((unused))) /* print warnings and errors */ /* VARARGS */ -void mi_check_print_info(MI_CHECK *param __attribute__((unused)), +void mi_check_print_info(HA_CHECK *param __attribute__((unused)), const char *fmt,...) { va_list args; @@ -1772,7 +1771,7 @@ void mi_check_print_info(MI_CHECK *param __attribute__((unused)), /* VARARGS */ -void mi_check_print_warning(MI_CHECK *param, const char *fmt,...) +void mi_check_print_warning(HA_CHECK *param, const char *fmt,...) { va_list args; DBUG_ENTER("mi_check_print_warning"); @@ -1797,7 +1796,7 @@ void mi_check_print_warning(MI_CHECK *param, const char *fmt,...) /* VARARGS */ -void mi_check_print_error(MI_CHECK *param, const char *fmt,...) +void mi_check_print_error(HA_CHECK *param, const char *fmt,...) { va_list args; DBUG_ENTER("mi_check_print_error"); diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index caf6254c321..44b868fedb2 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -16,8 +16,8 @@ /* This file is included by all internal myisam files */ -#include "myisam.h" /* Structs & some defines */ -#include "myisampack.h" /* packing of keys */ +#include "myisam.h" /* Structs & some defines */ +#include "myisampack.h" /* packing of keys */ #include #ifdef THREAD #include @@ -27,15 +27,16 @@ #endif #if defined(my_write) && !defined(MAP_TO_USE_RAID) -#undef my_write /* undef map from my_nosys; We need test-if-disk full */ +/* undef map from my_nosys; We need test-if-disk full */ +#undef my_write #endif typedef struct st_mi_status_info { - ha_rows records; /* Rows in table */ - ha_rows del; /* Removed rows */ - my_off_t empty; /* lost space in datafile */ - my_off_t key_empty; /* lost space in indexfile */ + ha_rows records; /* Rows in table */ + ha_rows del; /* Removed rows */ + my_off_t empty; /* lost space in datafile */ + my_off_t key_empty; /* lost space in indexfile */ my_off_t key_file_length; my_off_t data_file_length; ha_checksum checksum; @@ -43,333 +44,293 @@ typedef struct st_mi_status_info typedef struct st_mi_state_info { - struct { /* Fileheader */ + struct + { /* Fileheader */ uchar file_version[4]; uchar options[2]; uchar header_length[2]; uchar state_info_length[2]; uchar base_info_length[2]; uchar base_pos[2]; - uchar key_parts[2]; /* Key parts */ - uchar unique_key_parts[2]; /* Key parts + unique parts */ - uchar keys; /* number of keys in file */ - uchar uniques; /* number of UNIQUE definitions */ - uchar language; /* Language for indexes */ - uchar max_block_size; /* max keyblock size */ + uchar key_parts[2]; /* Key parts */ + uchar unique_key_parts[2]; /* Key parts + unique parts */ + uchar keys; /* number of keys in file */ + uchar uniques; /* number of UNIQUE definitions */ + uchar language; /* Language for indexes */ + uchar max_block_size; /* max keyblock size */ uchar fulltext_keys; uchar not_used; /* To align to 8 */ } header; MI_STATUS_INFO state; - ha_rows split; /* number of split blocks */ - my_off_t dellink; /* Link to next removed block */ + ha_rows split; /* number of split blocks */ + my_off_t dellink; /* Link to next removed block */ ulonglong auto_increment; - ulong process; /* process that updated table last */ - ulong unique; /* Unique number for this process */ - ulong update_count; /* Updated for each write lock */ + ulong process; /* process that updated table last */ + ulong unique; /* Unique number for this process */ + ulong update_count; /* Updated for each write lock */ ulong status; ulong *rec_per_key_part; - my_off_t *key_root; /* Start of key trees */ - my_off_t *key_del; /* delete links for trees */ - my_off_t rec_per_key_rows; /* Rows when calculating rec_per_key */ - - ulong sec_index_changed; /* Updated when new sec_index */ - ulong sec_index_used; /* which extra index are in use */ - ulonglong key_map; /* Which keys are in use */ - ulong version; /* timestamp of create */ - time_t create_time; /* Time when created database */ - time_t recover_time; /* Time for last recover */ - time_t check_time; /* Time for last check */ - uint sortkey; /* sorted by this key (not used) */ + my_off_t *key_root; /* Start of key trees */ + my_off_t *key_del; /* delete links for trees */ + my_off_t rec_per_key_rows; /* Rows when calculating rec_per_key */ + + ulong sec_index_changed; /* Updated when new sec_index */ + ulong sec_index_used; /* which extra index are in use */ + ulonglong key_map; /* Which keys are in use */ + ulong version; /* timestamp of create */ + time_t create_time; /* Time when created database */ + time_t recover_time; /* Time for last recover */ + time_t check_time; /* Time for last check */ + uint sortkey; /* sorted by this key (not used) */ uint open_count; - uint8 changed; /* Changed since myisamchk */ + uint8 changed; /* Changed since myisamchk */ /* the following isn't saved on disk */ - uint state_diff_length; /* Should be 0 */ - uint state_length; /* Length of state header in file */ + uint state_diff_length; /* Should be 0 */ + uint state_length; /* Length of state header in file */ ulong *key_info; } MI_STATE_INFO; -#define MI_STATE_INFO_SIZE (24+14*8+7*4+2*2+8) -#define MI_STATE_KEY_SIZE 8 +#define MI_STATE_INFO_SIZE (24+14*8+7*4+2*2+8) +#define MI_STATE_KEY_SIZE 8 #define MI_STATE_KEYBLOCK_SIZE 8 -#define MI_STATE_KEYSEG_SIZE 4 -#define MI_STATE_EXTRA_SIZE ((MI_MAX_KEY+MI_MAX_KEY_BLOCK_SIZE)*MI_STATE_KEY_SIZE + MI_MAX_KEY*MI_MAX_KEY_SEG*MI_STATE_KEYSEG_SIZE) -#define MI_KEYDEF_SIZE (2+ 5*2) -#define MI_UNIQUEDEF_SIZE (2+1+1) -#define HA_KEYSEG_SIZE (6+ 2*2 + 4*2) -#define MI_COLUMNDEF_SIZE (2*3+1) -#define MI_BASE_INFO_SIZE (5*8 + 8*4 + 4 + 4*2 + 16) -#define MI_INDEX_BLOCK_MARGIN 16 /* Safety margin for .MYI tables */ +#define MI_STATE_KEYSEG_SIZE 4 +#define MI_STATE_EXTRA_SIZE ((MI_MAX_KEY+MI_MAX_KEY_BLOCK_SIZE)*MI_STATE_KEY_SIZE + MI_MAX_KEY*HA_MAX_KEY_SEG*MI_STATE_KEYSEG_SIZE) +#define MI_KEYDEF_SIZE (2+ 5*2) +#define MI_UNIQUEDEF_SIZE (2+1+1) +#define HA_KEYSEG_SIZE (6+ 2*2 + 4*2) +#define MI_COLUMNDEF_SIZE (2*3+1) +#define MI_BASE_INFO_SIZE (5*8 + 8*4 + 4 + 4*2 + 16) +#define MI_INDEX_BLOCK_MARGIN 16 /* Safety margin for .MYI tables */ typedef struct st_mi_base_info { - my_off_t keystart; /* Start of keys */ + my_off_t keystart; /* Start of keys */ my_off_t max_data_file_length; my_off_t max_key_file_length; my_off_t margin_key_file_length; - ha_rows records,reloc; /* Create information */ - ulong mean_row_length; /* Create information */ - ulong reclength; /* length of unpacked record */ - ulong pack_reclength; /* Length of full packed rec. */ + ha_rows records, reloc; /* Create information */ + ulong mean_row_length; /* Create information */ + ulong reclength; /* length of unpacked record */ + ulong pack_reclength; /* Length of full packed rec. */ ulong min_pack_length; - ulong max_pack_length; /* Max possibly length of packed rec.*/ + ulong max_pack_length; /* Max possibly length of packed rec.*/ ulong min_block_length; - ulong fields, /* fields in table */ - pack_fields; /* packed fields in table */ - uint rec_reflength; /* = 2-8 */ - uint key_reflength; /* = 2-8 */ - uint keys; /* same as in state.header */ - uint auto_key; /* Which key-1 is a auto key */ - uint blobs; /* Number of blobs */ - uint pack_bits; /* Length of packed bits */ - uint max_key_block_length; /* Max block length */ - uint max_key_length; /* Max key length */ + ulong fields, /* fields in table */ + pack_fields; /* packed fields in table */ + uint rec_reflength; /* = 2-8 */ + uint key_reflength; /* = 2-8 */ + uint keys; /* same as in state.header */ + uint auto_key; /* Which key-1 is a auto key */ + uint blobs; /* Number of blobs */ + uint pack_bits; /* Length of packed bits */ + uint max_key_block_length; /* Max block length */ + uint max_key_length; /* Max key length */ /* Extra allocation when using dynamic record format */ uint extra_alloc_bytes; uint extra_alloc_procent; /* Info about raid */ - uint raid_type,raid_chunks; + uint raid_type, raid_chunks; ulong raid_chunksize; /* The following are from the header */ - uint key_parts,all_key_parts; + uint key_parts, all_key_parts; } MI_BASE_INFO; - /* Structs used intern in database */ + /* Structs used intern in database */ -typedef struct st_mi_blob /* Info of record */ +typedef struct st_mi_blob /* Info of record */ { - ulong offset; /* Offset to blob in record */ - uint pack_length; /* Type of packed length */ - ulong length; /* Calc:ed for each record */ + ulong offset; /* Offset to blob in record */ + uint pack_length; /* Type of packed length */ + ulong length; /* Calc:ed for each record */ } MI_BLOB; -typedef struct st_mi_isam_pack { +typedef struct st_mi_isam_pack +{ ulong header_length; uint ref_length; uchar version; } MI_PACK; -#define MAX_NONMAPPED_INSERTS 1000 +#define MAX_NONMAPPED_INSERTS 1000 -typedef struct st_mi_isam_share { /* Shared between opens */ +typedef struct st_mi_isam_share +{ /* Shared between opens */ MI_STATE_INFO state; MI_BASE_INFO base; - MI_KEYDEF ft2_keyinfo; /* Second-level ft-key definition */ - MI_KEYDEF *keyinfo; /* Key definitions */ - MI_UNIQUEDEF *uniqueinfo; /* unique definitions */ - HA_KEYSEG *keyparts; /* key part info */ - MI_COLUMNDEF *rec; /* Pointer to field information */ - MI_PACK pack; /* Data about packed records */ - MI_BLOB *blobs; /* Pointer to blobs */ - char *unique_file_name; /* realpath() of index file */ - char *data_file_name, /* Resolved path names from symlinks */ - *index_file_name; - byte *file_map; /* mem-map of file if possible */ - KEY_CACHE *key_cache; /* ref to the current key cache */ + MI_KEYDEF ft2_keyinfo; /* Second-level ft-key definition */ + MI_KEYDEF *keyinfo; /* Key definitions */ + MI_UNIQUEDEF *uniqueinfo; /* unique definitions */ + HA_KEYSEG *keyparts; /* key part info */ + MI_COLUMNDEF *rec; /* Pointer to field information */ + MI_PACK pack; /* Data about packed records */ + MI_BLOB *blobs; /* Pointer to blobs */ + char *unique_file_name; /* realpath() of index file */ + char *data_file_name, /* Resolved path names from symlinks */ + *index_file_name; + byte *file_map; /* mem-map of file if possible */ + KEY_CACHE *key_cache; /* ref to the current key cache */ MI_DECODE_TREE *decode_trees; uint16 *decode_tables; - int (*read_record)(struct st_myisam_info*, my_off_t, byte*); - int (*write_record)(struct st_myisam_info*, const byte*); - int (*update_record)(struct st_myisam_info*, my_off_t, const byte*); - int (*delete_record)(struct st_myisam_info*); - int (*read_rnd)(struct st_myisam_info*, byte*, my_off_t, my_bool); - int (*compare_record)(struct st_myisam_info*, const byte *); - ha_checksum (*calc_checksum)(struct st_myisam_info*, const byte *); - int (*compare_unique)(struct st_myisam_info*, MI_UNIQUEDEF *, - const byte *record, my_off_t pos); - uint (*file_read)(MI_INFO *, byte *, uint, my_off_t, myf); - uint (*file_write)(MI_INFO *, byte *, uint, my_off_t, myf); + int(*read_record) (struct st_myisam_info *, my_off_t, byte *); + int(*write_record) (struct st_myisam_info *, const byte *); + int(*update_record) (struct st_myisam_info *, my_off_t, const byte *); + int(*delete_record) (struct st_myisam_info *); + int(*read_rnd) (struct st_myisam_info *, byte *, my_off_t, my_bool); + int(*compare_record) (struct st_myisam_info *, const byte *); + ha_checksum(*calc_checksum) (struct st_myisam_info *, const byte *); + int(*compare_unique) (struct st_myisam_info *, MI_UNIQUEDEF *, + const byte * record, my_off_t pos); + uint(*file_read) (MI_INFO *, byte *, uint, my_off_t, myf); + uint(*file_write) (MI_INFO *, byte *, uint, my_off_t, myf); invalidator_by_filename invalidator; /* query cache invalidator */ - ulong this_process; /* processid */ - ulong last_process; /* For table-change-check */ - ulong last_version; /* Version on start */ - ulong options; /* Options used */ - ulong min_pack_length; /* Theese are used by packed data */ + ulong this_process; /* processid */ + ulong last_process; /* For table-change-check */ + ulong last_version; /* Version on start */ + ulong options; /* Options used */ + ulong min_pack_length; /* Theese are used by packed data */ ulong max_pack_length; ulong state_diff_length; - uint rec_reflength; /* rec_reflength in use now */ - uint unique_name_length; + uint rec_reflength; /* rec_reflength in use now */ + uint unique_name_length; uint32 ftparsers; /* Number of distinct ftparsers + 1 */ - File kfile; /* Shared keyfile */ - File data_file; /* Shared data file */ - int mode; /* mode of file on open */ - uint reopen; /* How many times reopened */ - uint w_locks,r_locks,tot_locks; /* Number of read/write locks */ - uint blocksize; /* blocksize of keyfile */ + File kfile; /* Shared keyfile */ + File data_file; /* Shared data file */ + int mode; /* mode of file on open */ + uint reopen; /* How many times reopened */ + uint w_locks, r_locks, tot_locks; /* Number of read/write locks */ + uint blocksize; /* blocksize of keyfile */ myf write_flag; enum data_file_type data_file_type; - my_bool changed, /* If changed since lock */ - global_changed, /* If changed since open */ - not_flushed, - temporary,delay_key_write, - concurrent_insert; + my_bool changed, /* If changed since lock */ + global_changed, /* If changed since open */ + not_flushed, temporary, delay_key_write, concurrent_insert; #ifdef THREAD THR_LOCK lock; - pthread_mutex_t intern_lock; /* Locking for use with _locking */ + pthread_mutex_t intern_lock; /* Locking for use with _locking */ rw_lock_t *key_root_lock; #endif my_off_t mmaped_length; - uint nonmmaped_inserts; /* counter of writing in non-mmaped - area */ + /* counter of writing in non-mmaped area */ + uint nonmmaped_inserts; rw_lock_t mmap_lock; } MYISAM_SHARE; typedef uint mi_bit_type; -typedef struct st_mi_bit_buff { /* Used for packing of record */ +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; + uchar *pos, *end, *blob_pos, *blob_end; uint error; } MI_BIT_BUFF; -struct st_myisam_info { - MYISAM_SHARE *s; /* Shared between open:s */ - MI_STATUS_INFO *state,save_state; - MI_BLOB *blobs; /* Pointer to blobs */ - MI_BIT_BUFF bit_buff; +struct st_myisam_info +{ + MYISAM_SHARE *s; /* Shared between open:s */ + MI_STATUS_INFO *state, save_state; + MI_BLOB *blobs; /* Pointer to blobs */ + MI_BIT_BUFF bit_buff; /* accumulate indexfile changes between write's */ - TREE *bulk_insert; + TREE *bulk_insert; DYNAMIC_ARRAY *ft1_to_ft2; /* used only in ft1->ft2 conversion */ - MYSQL_FTPARSER_PARAM *ftparser_param; /* share info between init/deinit */ - char *filename; /* parameter to open filename */ - uchar *buff, /* Temp area for key */ - *lastkey,*lastkey2; /* Last used search key */ - uchar *first_mbr_key; /* Searhed spatial key */ - byte *rec_buff; /* Tempbuff for recordpack */ - uchar *int_keypos, /* Save position for next/previous */ - *int_maxpos; /* -""- */ - uint int_nod_flag; /* -""- */ - uint32 int_keytree_version; /* -""- */ - int (*read_record)(struct st_myisam_info*, my_off_t, byte*); + MYSQL_FTPARSER_PARAM *ftparser_param; /* share info between init/deinit */ + char *filename; /* parameter to open filename */ + uchar *buff, /* Temp area for key */ + *lastkey, *lastkey2; /* Last used search key */ + uchar *first_mbr_key; /* Searhed spatial key */ + byte *rec_buff; /* Tempbuff for recordpack */ + uchar *int_keypos, /* Save position for next/previous */ + *int_maxpos; /* -""- */ + uint int_nod_flag; /* -""- */ + uint32 int_keytree_version; /* -""- */ + int(*read_record) (struct st_myisam_info *, my_off_t, byte *); invalidator_by_filename invalidator; /* query cache invalidator */ - ulong this_unique; /* uniq filenumber or thread */ - ulong last_unique; /* last unique number */ - ulong this_loop; /* counter for this open */ - ulong last_loop; /* last used counter */ - my_off_t lastpos, /* Last record position */ - nextpos; /* Position to next record */ + ulong this_unique; /* uniq filenumber or thread */ + ulong last_unique; /* last unique number */ + ulong this_loop; /* counter for this open */ + ulong last_loop; /* last used counter */ + my_off_t lastpos, /* Last record position */ + nextpos; /* Position to next record */ my_off_t save_lastpos; - my_off_t pos; /* Intern variable */ - my_off_t last_keypage; /* Last key page read */ - my_off_t last_search_keypage; /* Last keypage when searching */ + my_off_t pos; /* Intern variable */ + my_off_t last_keypage; /* Last key page read */ + my_off_t last_search_keypage; /* Last keypage when searching */ my_off_t dupp_key_pos; ha_checksum checksum; - /* QQ: the folloing two xxx_length fields should be removed, - as they are not compatible with parallel repair */ - ulong packed_length,blob_length; /* Length of found, packed record */ - int dfile; /* The datafile */ - uint opt_flag; /* Optim. for space/speed */ - uint update; /* If file changed since open */ - int lastinx; /* Last used index */ - uint lastkey_length; /* Length of key in lastkey */ - uint last_rkey_length; /* Last length in mi_rkey() */ + /* + QQ: the folloing two xxx_length fields should be removed, + as they are not compatible with parallel repair + */ + ulong packed_length, blob_length; /* Length of found, packed record */ + int dfile; /* The datafile */ + uint opt_flag; /* Optim. for space/speed */ + uint update; /* If file changed since open */ + int lastinx; /* Last used index */ + uint lastkey_length; /* Length of key in lastkey */ + uint last_rkey_length; /* Last length in mi_rkey() */ enum ha_rkey_function last_key_func; /* CONTAIN, OVERLAP, etc */ - uint save_lastkey_length; - uint pack_key_length; /* For MYISAMMRG */ - int errkey; /* Got last error on this key */ - int lock_type; /* How database was locked */ - int tmp_lock_type; /* When locked by readinfo */ - uint data_changed; /* Somebody has changed data */ - uint save_update; /* When using KEY_READ */ - int save_lastinx; - LIST open_list; - IO_CACHE rec_cache; /* When cacheing records */ - uint preload_buff_size; /* When preloading indexes */ - myf lock_wait; /* is 0 or MY_DONT_WAIT */ - my_bool was_locked; /* Was locked in panic */ - my_bool append_insert_at_end; /* Set if concurrent insert */ + uint save_lastkey_length; + uint pack_key_length; /* For MYISAMMRG */ + int errkey; /* Got last error on this key */ + int lock_type; /* How database was locked */ + int tmp_lock_type; /* When locked by readinfo */ + uint data_changed; /* Somebody has changed data */ + uint save_update; /* When using KEY_READ */ + int save_lastinx; + LIST open_list; + IO_CACHE rec_cache; /* When cacheing records */ + uint preload_buff_size; /* When preloading indexes */ + myf lock_wait; /* is 0 or MY_DONT_WAIT */ + my_bool was_locked; /* Was locked in panic */ + my_bool append_insert_at_end; /* Set if concurrent insert */ my_bool quick_mode; - my_bool page_changed; /* If info->buff can't be used for rnext */ - my_bool buff_used; /* If info->buff has to be reread for rnext */ - my_bool once_flags; /* For MYISAMMRG */ + /* If info->buff can't be used for rnext */ + my_bool page_changed; + /* If info->buff has to be reread for rnext */ + my_bool buff_used; + my_bool once_flags; /* For MYISAMMRG */ #ifdef THREAD THR_LOCK_DATA lock; #endif - uchar *rtree_recursion_state; /* For RTREE */ - int rtree_recursion_depth; + uchar *rtree_recursion_state; /* For RTREE */ + int rtree_recursion_depth; }; -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; +#define USE_WHOLE_KEY HA_MAX_KEY_BUFF*2 /* Use whole key in _mi_search() */ +#define F_EXTRA_LCK -1 -typedef struct st_mi_sort_param -{ - pthread_t thr; - IO_CACHE read_cache, tempfile, tempfile_for_exceptions; - DYNAMIC_ARRAY buffpek; - - /* - The next two are used to collect statistics, see update_key_parts for - description. - */ - ulonglong unique[MI_MAX_KEY_SEG+1]; - ulonglong notnull[MI_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; - MI_KEYDEF *keyinfo; - HA_KEYSEG *seg; - SORT_INFO *sort_info; - uchar **sort_keys; - byte *rec_buff; - void *wordlist, *wordptr; - char *record; - MY_TMPDIR *tmpdir; - 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)(MI_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; - /* Some defines used by isam-funktions */ - -#define USE_WHOLE_KEY MI_MAX_KEY_BUFF*2 /* Use whole key in _mi_search() */ -#define F_EXTRA_LCK -1 - - /* bits in opt_flag */ -#define MEMMAP_USED 32 +/* bits in opt_flag */ +#define MEMMAP_USED 32 #define REMEMBER_OLD_POS 64 -#define WRITEINFO_UPDATE_KEYFILE 1 -#define WRITEINFO_NO_UNLOCK 2 +#define WRITEINFO_UPDATE_KEYFILE 1 +#define WRITEINFO_NO_UNLOCK 2 - /* once_flags */ +/* once_flags */ #define USE_PACKED_KEYS 1 #define RRND_PRESERVE_LASTINX 2 - /* bits in state.changed */ - -#define STATE_CHANGED 1 -#define STATE_CRASHED 2 +/* bits in state.changed */ +#define STATE_CHANGED 1 +#define STATE_CRASHED 2 #define STATE_CRASHED_ON_REPAIR 4 -#define STATE_NOT_ANALYZED 8 +#define STATE_NOT_ANALYZED 8 #define STATE_NOT_OPTIMIZED_KEYS 16 -#define STATE_NOT_SORTED_PAGES 32 +#define STATE_NOT_SORTED_PAGES 32 - /* options to mi_read_cache */ +/* options to mi_read_cache */ +#define READING_NEXT 1 +#define READING_HEADER 2 -#define READING_NEXT 1 -#define READING_HEADER 2 - -#define mi_getint(x) ((uint) mi_uint2korr(x) & 32767) +#define mi_getint(x) ((uint) mi_uint2korr(x) & 32767) #define mi_putint(x,y,nod) { uint16 boh=(nod ? (uint16) 32768 : 0) + (uint16) (y);\ - mi_int2store(x,boh); } + mi_int2store(x,boh); } #define mi_test_if_nod(x) (x[0] & 128 ? info->s->base.key_reflength : 0) #define mi_mark_crashed(x) (x)->s->state.changed|=STATE_CRASHED #define mi_mark_crashed_on_repair(x) { (x)->s->state.changed|=STATE_CRASHED|STATE_CRASHED_ON_REPAIR ; (x)->update|= HA_STATE_CHANGED; } @@ -380,13 +341,6 @@ typedef struct st_mi_sort_param /* Functions to store length of space packed keys, VARCHAR or BLOB keys */ -#define store_key_length_inc(key,length) \ -{ if ((length) < 255) \ - { *(key)++=(length); } \ - else \ - { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \ -} - #define store_key_length(key,length) \ { if ((length) < 255) \ { *(key)=(length); } \ @@ -410,39 +364,39 @@ typedef struct st_mi_sort_param #define get_pack_length(length) ((length) >= 255 ? 3 : 1) -#define MI_MIN_BLOCK_LENGTH 20 /* Because of delete-link */ -#define MI_EXTEND_BLOCK_LENGTH 20 /* Don't use to small record-blocks */ -#define MI_SPLIT_LENGTH ((MI_EXTEND_BLOCK_LENGTH+4)*2) -#define MI_MAX_DYN_BLOCK_HEADER 20 /* Max prefix of record-block */ +#define MI_MIN_BLOCK_LENGTH 20 /* Because of delete-link */ +#define MI_EXTEND_BLOCK_LENGTH 20 /* Don't use to small record-blocks */ +#define MI_SPLIT_LENGTH ((MI_EXTEND_BLOCK_LENGTH+4)*2) +#define MI_MAX_DYN_BLOCK_HEADER 20 /* Max prefix of record-block */ #define MI_BLOCK_INFO_HEADER_LENGTH 20 -#define MI_DYN_DELETE_BLOCK_HEADER 20 /* length of delete-block-header */ -#define MI_DYN_MAX_BLOCK_LENGTH ((1L << 24)-4L) -#define MI_DYN_MAX_ROW_LENGTH (MI_DYN_MAX_BLOCK_LENGTH - MI_SPLIT_LENGTH) -#define MI_DYN_ALIGN_SIZE 4 /* Align blocks on this */ -#define MI_MAX_DYN_HEADER_BYTE 13 /* max header byte for dynamic rows */ -#define MI_MAX_BLOCK_LENGTH ((((ulong) 1 << 24)-1) & (~ (ulong) (MI_DYN_ALIGN_SIZE-1))) +#define MI_DYN_DELETE_BLOCK_HEADER 20 /* length of delete-block-header */ +#define MI_DYN_MAX_BLOCK_LENGTH ((1L << 24)-4L) +#define MI_DYN_MAX_ROW_LENGTH (MI_DYN_MAX_BLOCK_LENGTH - MI_SPLIT_LENGTH) +#define MI_DYN_ALIGN_SIZE 4 /* Align blocks on this */ +#define MI_MAX_DYN_HEADER_BYTE 13 /* max header byte for dynamic rows */ +#define MI_MAX_BLOCK_LENGTH ((((ulong) 1 << 24)-1) & (~ (ulong) (MI_DYN_ALIGN_SIZE-1))) #define MI_REC_BUFF_OFFSET ALIGN_SIZE(MI_DYN_DELETE_BLOCK_HEADER+sizeof(uint32)) -#define MEMMAP_EXTRA_MARGIN 7 /* Write this as a suffix for file */ +#define MEMMAP_EXTRA_MARGIN 7 /* Write this as a suffix for file */ -#define PACK_TYPE_SELECTED 1 /* Bits in field->pack_type */ -#define PACK_TYPE_SPACE_FIELDS 2 -#define PACK_TYPE_ZERO_FILL 4 -#define MI_FOUND_WRONG_KEY 32738 /* Impossible value from ha_key_cmp */ +#define PACK_TYPE_SELECTED 1 /* Bits in field->pack_type */ +#define PACK_TYPE_SPACE_FIELDS 2 +#define PACK_TYPE_ZERO_FILL 4 +#define MI_FOUND_WRONG_KEY 32738 /* Impossible value from ha_key_cmp */ -#define MI_MAX_KEY_BLOCK_SIZE (MI_MAX_KEY_BLOCK_LENGTH/MI_MIN_KEY_BLOCK_LENGTH) +#define MI_MAX_KEY_BLOCK_SIZE (MI_MAX_KEY_BLOCK_LENGTH/MI_MIN_KEY_BLOCK_LENGTH) #define MI_BLOCK_SIZE(key_length,data_pointer,key_pointer) (((((key_length)+(data_pointer)+(key_pointer))*4+(key_pointer)+2)/myisam_block_size+1)*myisam_block_size) -#define MI_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */ -#define MI_MIN_KEYBLOCK_LENGTH 50 /* When to split delete blocks */ +#define MI_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */ +#define MI_MIN_KEYBLOCK_LENGTH 50 /* When to split delete blocks */ -#define MI_MIN_SIZE_BULK_INSERT_TREE 16384 /* this is per key */ +#define MI_MIN_SIZE_BULK_INSERT_TREE 16384 /* this is per key */ #define MI_MIN_ROWS_TO_USE_BULK_INSERT 100 #define MI_MIN_ROWS_TO_DISABLE_INDEXES 100 #define MI_MIN_ROWS_TO_USE_WRITE_CACHE 10 /* The UNIQUE check is done with a hashed long key */ -#define MI_UNIQUE_HASH_TYPE HA_KEYTYPE_ULONG_INT +#define MI_UNIQUE_HASH_TYPE HA_KEYTYPE_ULONG_INT #define mi_unique_store(A,B) mi_int4store((A),(B)) #ifdef THREAD @@ -454,174 +408,181 @@ extern pthread_mutex_t THR_LOCK_myisam; #define rw_unlock(A) {} #endif - /* Some extern variables */ +/* Some extern variables */ extern LIST *myisam_open_list; -extern uchar NEAR myisam_file_magic[],NEAR myisam_pack_file_magic[]; -extern uint NEAR myisam_read_vec[],NEAR myisam_readnext_vec[]; +extern uchar NEAR myisam_file_magic[], NEAR myisam_pack_file_magic[]; +extern uint NEAR myisam_read_vec[], NEAR myisam_readnext_vec[]; extern uint myisam_quick_table_bits; extern File myisam_log_file; extern ulong myisam_pid; - /* This is used by _mi_calc_xxx_key_length och _mi_store_key */ +/* This is used by _mi_calc_xxx_key_length och _mi_store_key */ typedef struct st_mi_s_param { - uint ref_length,key_length, - n_ref_length, - n_length, - totlength, - part_of_prev_key,prev_length,pack_marker; - uchar *key, *prev_key,*next_key_pos; - bool store_not_null; + uint ref_length, key_length, + n_ref_length, + n_length, totlength, part_of_prev_key, prev_length, pack_marker; + uchar *key, *prev_key, *next_key_pos; + bool store_not_null; } MI_KEY_PARAM; - /* Prototypes for intern functions */ +/* Prototypes for intern functions */ -extern int _mi_read_dynamic_record(MI_INFO *info,my_off_t filepos,byte *buf); -extern int _mi_write_dynamic_record(MI_INFO*, const byte*); -extern int _mi_update_dynamic_record(MI_INFO*, my_off_t, const byte*); +extern int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, byte *buf); +extern int _mi_write_dynamic_record(MI_INFO *, const byte *); +extern int _mi_update_dynamic_record(MI_INFO *, my_off_t, const byte *); extern int _mi_delete_dynamic_record(MI_INFO *info); -extern int _mi_cmp_dynamic_record(MI_INFO *info,const byte *record); -extern int _mi_read_rnd_dynamic_record(MI_INFO *, byte *,my_off_t, my_bool); -extern int _mi_write_blob_record(MI_INFO*, const byte*); -extern int _mi_update_blob_record(MI_INFO*, my_off_t, const byte*); -extern int _mi_read_static_record(MI_INFO *info, my_off_t filepos,byte *buf); -extern int _mi_write_static_record(MI_INFO*, const byte*); -extern int _mi_update_static_record(MI_INFO*, my_off_t, const byte*); +extern int _mi_cmp_dynamic_record(MI_INFO *info, const byte *record); +extern int _mi_read_rnd_dynamic_record(MI_INFO *, byte *, my_off_t, my_bool); +extern int _mi_write_blob_record(MI_INFO *, const byte *); +extern int _mi_update_blob_record(MI_INFO *, my_off_t, const byte *); +extern int _mi_read_static_record(MI_INFO *info, my_off_t filepos, byte *buf); +extern int _mi_write_static_record(MI_INFO *, const byte *); +extern int _mi_update_static_record(MI_INFO *, my_off_t, const byte *); extern int _mi_delete_static_record(MI_INFO *info); -extern int _mi_cmp_static_record(MI_INFO *info,const byte *record); -extern int _mi_read_rnd_static_record(MI_INFO*, byte *,my_off_t, my_bool); -extern int _mi_ck_write(MI_INFO *info,uint keynr,uchar *key,uint length); +extern int _mi_cmp_static_record(MI_INFO *info, const byte *record); +extern int _mi_read_rnd_static_record(MI_INFO *, byte *, my_off_t, my_bool); +extern int _mi_ck_write(MI_INFO *info, uint keynr, uchar *key, uint length); extern int _mi_ck_real_write_btree(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, uint key_length, my_off_t *root, uint comp_flag); -extern int _mi_enlarge_root(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key, my_off_t *root); -extern int _mi_insert(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key, - uchar *anc_buff,uchar *key_pos,uchar *key_buff, - uchar *father_buff, uchar *father_keypos, - my_off_t father_page, my_bool insert_last); -extern int _mi_split_page(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key, - uchar *buff,uchar *key_buff, my_bool insert_last); -extern uchar *_mi_find_half_pos(uint nod_flag,MI_KEYDEF *keyinfo,uchar *page, - uchar *key,uint *return_key_length, - uchar **after_key); -extern int _mi_calc_static_key_length(MI_KEYDEF *keyinfo,uint nod_flag, - uchar *key_pos, uchar *org_key, - uchar *key_buff, - uchar *key, MI_KEY_PARAM *s_temp); -extern int _mi_calc_var_key_length(MI_KEYDEF *keyinfo,uint nod_flag, - uchar *key_pos, uchar *org_key, - uchar *key_buff, - uchar *key, MI_KEY_PARAM *s_temp); -extern int _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag, - uchar *key_pos, uchar *org_key, - uchar *prev_key, - uchar *key, MI_KEY_PARAM *s_temp); -extern int _mi_calc_bin_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag, - uchar *key_pos,uchar *org_key, - uchar *prev_key, - uchar *key, MI_KEY_PARAM *s_temp); -void _mi_store_static_key(MI_KEYDEF *keyinfo, uchar *key_pos, - MI_KEY_PARAM *s_temp); -void _mi_store_var_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos, - MI_KEY_PARAM *s_temp); +extern int _mi_enlarge_root(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, + my_off_t *root); +extern int _mi_insert(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, + uchar *anc_buff, uchar *key_pos, uchar *key_buff, + uchar *father_buff, uchar *father_keypos, + my_off_t father_page, my_bool insert_last); +extern int _mi_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, + uchar *buff, uchar *key_buff, my_bool insert_last); +extern uchar *_mi_find_half_pos(uint nod_flag, MI_KEYDEF *keyinfo, + uchar *page, uchar *key, + uint *return_key_length, uchar ** after_key); +extern int _mi_calc_static_key_length(MI_KEYDEF *keyinfo, uint nod_flag, + uchar *key_pos, uchar *org_key, + uchar *key_buff, uchar *key, + MI_KEY_PARAM *s_temp); +extern int _mi_calc_var_key_length(MI_KEYDEF *keyinfo, uint nod_flag, + uchar *key_pos, uchar *org_key, + uchar *key_buff, uchar *key, + MI_KEY_PARAM *s_temp); +extern int _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo, uint nod_flag, + uchar *key_pos, uchar *org_key, + uchar *prev_key, uchar *key, + MI_KEY_PARAM *s_temp); +extern int _mi_calc_bin_pack_key_length(MI_KEYDEF *keyinfo, uint nod_flag, + uchar *key_pos, uchar *org_key, + uchar *prev_key, uchar *key, + MI_KEY_PARAM *s_temp); +void _mi_store_static_key(MI_KEYDEF *keyinfo, uchar *key_pos, + MI_KEY_PARAM *s_temp); +void _mi_store_var_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos, + MI_KEY_PARAM *s_temp); #ifdef NOT_USED -void _mi_store_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos, - MI_KEY_PARAM *s_temp); +void _mi_store_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos, + MI_KEY_PARAM *s_temp); #endif -void _mi_store_bin_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos, - MI_KEY_PARAM *s_temp); +void _mi_store_bin_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos, + MI_KEY_PARAM *s_temp); -extern int _mi_ck_delete(MI_INFO *info,uint keynr,uchar *key,uint key_length); -extern int _mi_readinfo(MI_INFO *info,int lock_flag,int check_keybuffer); -extern int _mi_writeinfo(MI_INFO *info,uint options); +extern int _mi_ck_delete(MI_INFO *info, uint keynr, uchar *key, + uint key_length); +extern int _mi_readinfo(MI_INFO *info, int lock_flag, int check_keybuffer); +extern int _mi_writeinfo(MI_INFO *info, uint options); extern int _mi_test_if_changed(MI_INFO *info); extern int _mi_mark_file_changed(MI_INFO *info); extern int _mi_decrement_open_count(MI_INFO *info); -extern int _mi_check_index(MI_INFO *info,int inx); -extern int _mi_search(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key,uint key_len, - uint nextflag,my_off_t pos); -extern int _mi_bin_search(struct st_myisam_info *info,MI_KEYDEF *keyinfo, - uchar *page,uchar *key,uint key_len,uint comp_flag, - uchar * *ret_pos,uchar *buff, my_bool *was_last_key); -extern int _mi_seq_search(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *page, - uchar *key,uint key_len,uint comp_flag, - uchar **ret_pos,uchar *buff, my_bool *was_last_key); -extern int _mi_prefix_search(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *page, - uchar *key,uint key_len,uint comp_flag, - uchar **ret_pos,uchar *buff, my_bool *was_last_key); -extern my_off_t _mi_kpos(uint nod_flag,uchar *after_key); -extern void _mi_kpointer(MI_INFO *info,uchar *buff,my_off_t pos); -extern my_off_t _mi_dpos(MI_INFO *info, uint nod_flag,uchar *after_key); +extern int _mi_check_index(MI_INFO *info, int inx); +extern int _mi_search(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, + uint key_len, uint nextflag, my_off_t pos); +extern int _mi_bin_search(struct st_myisam_info *info, MI_KEYDEF *keyinfo, + uchar *page, uchar *key, uint key_len, + uint comp_flag, uchar **ret_pos, uchar *buff, + my_bool *was_last_key); +extern int _mi_seq_search(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, + uchar *key, uint key_len, uint comp_flag, + uchar ** ret_pos, uchar *buff, + my_bool *was_last_key); +extern int _mi_prefix_search(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, + uchar *key, uint key_len, uint comp_flag, + uchar ** ret_pos, uchar *buff, + my_bool *was_last_key); +extern my_off_t _mi_kpos(uint nod_flag, uchar *after_key); +extern void _mi_kpointer(MI_INFO *info, uchar *buff, my_off_t pos); +extern my_off_t _mi_dpos(MI_INFO *info, uint nod_flag, uchar *after_key); extern my_off_t _mi_rec_pos(MYISAM_SHARE *info, uchar *ptr); -extern void _mi_dpointer(MI_INFO *info, uchar *buff,my_off_t pos); -extern int ha_key_cmp(HA_KEYSEG *keyseg, uchar *a,uchar *b, - uint key_length,uint nextflag,uint *diff_length); -extern uint _mi_get_static_key(MI_KEYDEF *keyinfo,uint nod_flag,uchar * *page, - uchar *key); -extern uint _mi_get_pack_key(MI_KEYDEF *keyinfo,uint nod_flag,uchar * *page, - uchar *key); +extern void _mi_dpointer(MI_INFO *info, uchar *buff, my_off_t pos); +extern int ha_key_cmp(HA_KEYSEG *keyseg, uchar *a, uchar *b, + uint key_length, uint nextflag, uint *diff_length); +extern uint _mi_get_static_key(MI_KEYDEF *keyinfo, uint nod_flag, + uchar **page, uchar *key); +extern uint _mi_get_pack_key(MI_KEYDEF *keyinfo, uint nod_flag, uchar **page, + uchar *key); extern uint _mi_get_binary_pack_key(MI_KEYDEF *keyinfo, uint nod_flag, - uchar **page_pos, uchar *key); -extern uchar *_mi_get_last_key(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *keypos, - uchar *lastkey,uchar *endpos, - uint *return_key_length); + uchar ** page_pos, uchar *key); +extern uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, + uchar *keypos, uchar *lastkey, uchar *endpos, + uint *return_key_length); extern uchar *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, - uchar *key, uchar *keypos, uint *return_key_length); -extern uint _mi_keylength(MI_KEYDEF *keyinfo,uchar *key); + uchar *key, uchar *keypos, + uint *return_key_length); +extern uint _mi_keylength(MI_KEYDEF *keyinfo, uchar *key); extern uint _mi_keylength_part(MI_KEYDEF *keyinfo, register uchar *key, - HA_KEYSEG *end); -extern uchar *_mi_move_key(MI_KEYDEF *keyinfo,uchar *to,uchar *from); -extern int _mi_search_next(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key, - uint key_length,uint nextflag,my_off_t pos); -extern int _mi_search_first(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos); -extern int _mi_search_last(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos); -extern uchar *_mi_fetch_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page, - int level,uchar *buff,int return_buffer); -extern int _mi_write_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page, - int level, uchar *buff); -extern int _mi_dispose(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos, - int level); -extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo,int level); -extern uint _mi_make_key(MI_INFO *info,uint keynr,uchar *key, - const byte *record,my_off_t filepos); -extern uint _mi_pack_key(MI_INFO *info,uint keynr,uchar *key,uchar *old, - uint key_length, HA_KEYSEG **last_used_keyseg); -extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,byte *buf); -extern int _mi_read_cache(IO_CACHE *info,byte *buff,my_off_t pos, - uint length,int re_read_if_possibly); -extern void update_auto_increment(MI_INFO *info,const byte *record); - -extern byte *mi_alloc_rec_buff(MI_INFO *,ulong, byte**); + HA_KEYSEG *end); +extern uchar *_mi_move_key(MI_KEYDEF *keyinfo, uchar *to, uchar *from); +extern int _mi_search_next(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, + uint key_length, uint nextflag, my_off_t pos); +extern int _mi_search_first(MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos); +extern int _mi_search_last(MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos); +extern uchar *_mi_fetch_keypage(MI_INFO *info, MI_KEYDEF *keyinfo, + my_off_t page, int level, uchar *buff, + int return_buffer); +extern int _mi_write_keypage(MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t page, + int level, uchar *buff); +extern int _mi_dispose(MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos, + int level); +extern my_off_t _mi_new(MI_INFO *info, MI_KEYDEF *keyinfo, int level); +extern uint _mi_make_key(MI_INFO *info, uint keynr, uchar *key, + const byte *record, my_off_t filepos); +extern uint _mi_pack_key(MI_INFO *info, uint keynr, uchar *key, uchar *old, + uint key_length, HA_KEYSEG ** last_used_keyseg); +extern int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf); +extern int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, + uint length, int re_read_if_possibly); +extern void update_auto_increment(MI_INFO *info, const byte *record); + +extern byte *mi_alloc_rec_buff(MI_INFO *, ulong, byte **); #define mi_get_rec_buff_ptr(info,buf) \ ((((info)->s->options & HA_OPTION_PACK_RECORD) && (buf)) ? \ (buf) - MI_REC_BUFF_OFFSET : (buf)) #define mi_get_rec_buff_len(info,buf) \ (*((uint32 *)(mi_get_rec_buff_ptr(info,buf)))) -extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from, - ulong reclength); -extern my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *packpos, +extern ulong _mi_rec_unpack(MI_INFO *info, byte *to, byte *from, + ulong reclength); +extern my_bool _mi_rec_check(MI_INFO *info, const char *record, byte *packpos, ulong packed_length, my_bool with_checkum); -extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length, - my_off_t next_filepos,byte **record, - ulong *reclength,int *flag); -extern void _mi_print_key(FILE *stream,HA_KEYSEG *keyseg,const uchar *key, - uint length); -extern my_bool _mi_read_pack_info(MI_INFO *info,pbool fix_keys); -extern int _mi_read_pack_record(MI_INFO *info,my_off_t filepos,byte *buf); -extern int _mi_read_rnd_pack_record(MI_INFO*, byte *,my_off_t, my_bool); -extern int _mi_pack_rec_unpack(MI_INFO *info,byte *to,byte *from, - ulong reclength); -extern ulonglong mi_safe_mul(ulonglong a,ulonglong b); +extern int _mi_write_part_record(MI_INFO *info, my_off_t filepos, ulong length, + my_off_t next_filepos, byte ** record, + ulong *reclength, int *flag); +extern void _mi_print_key(FILE *stream, HA_KEYSEG *keyseg, const uchar *key, + uint length); +extern my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys); +extern int _mi_read_pack_record(MI_INFO *info, my_off_t filepos, byte *buf); +extern int _mi_read_rnd_pack_record(MI_INFO *, byte *, my_off_t, my_bool); +extern int _mi_pack_rec_unpack(MI_INFO *info, byte *to, byte *from, + ulong reclength); +extern ulonglong mi_safe_mul(ulonglong a, ulonglong b); extern int _mi_ft_update(MI_INFO *info, uint keynr, byte *keybuf, - const byte *oldrec, const byte *newrec, my_off_t pos); + const byte *oldrec, const byte *newrec, + my_off_t pos); struct st_sort_info; -typedef struct st_mi_block_info { /* Parameter to _mi_get_block_info */ +typedef struct st_mi_block_info /* Parameter to _mi_get_block_info */ +{ uchar header[MI_BLOCK_INFO_HEADER_LENGTH]; ulong rec_len; ulong data_len; @@ -634,35 +595,37 @@ typedef struct st_mi_block_info { /* Parameter to _mi_get_block_info */ uint offset; } MI_BLOCK_INFO; - /* bits in return from _mi_get_block_info */ - -#define BLOCK_FIRST 1 -#define BLOCK_LAST 2 -#define BLOCK_DELETED 4 -#define BLOCK_ERROR 8 /* Wrong data */ -#define BLOCK_SYNC_ERROR 16 /* Right data at wrong place */ -#define BLOCK_FATAL_ERROR 32 /* hardware-error */ - -#define NEED_MEM ((uint) 10*4*(IO_SIZE+32)+32) /* Nead for recursion */ -#define MAXERR 20 -#define BUFFERS_WHEN_SORTING 16 /* Alloc for sort-key-tree */ -#define WRITE_COUNT MY_HOW_OFTEN_TO_WRITE -#define INDEX_TMP_EXT ".TMM" -#define DATA_TMP_EXT ".TMD" - -#define UPDATE_TIME 1 -#define UPDATE_STAT 2 -#define UPDATE_SORT 4 -#define UPDATE_AUTO_INC 8 -#define UPDATE_OPEN_COUNT 16 - -#define USE_BUFFER_INIT (((1024L*512L-MALLOC_OVERHEAD)/IO_SIZE)*IO_SIZE) -#define READ_BUFFER_INIT (1024L*256L-MALLOC_OVERHEAD) -#define SORT_BUFFER_INIT (2048L*1024L-MALLOC_OVERHEAD) -#define MIN_SORT_BUFFER (4096-MALLOC_OVERHEAD) - -enum myisam_log_commands { - MI_LOG_OPEN,MI_LOG_WRITE,MI_LOG_UPDATE,MI_LOG_DELETE,MI_LOG_CLOSE,MI_LOG_EXTRA,MI_LOG_LOCK,MI_LOG_DELETE_ALL + /* bits in return from _mi_get_block_info */ + +#define BLOCK_FIRST 1 +#define BLOCK_LAST 2 +#define BLOCK_DELETED 4 +#define BLOCK_ERROR 8 /* Wrong data */ +#define BLOCK_SYNC_ERROR 16 /* Right data at wrong place */ +#define BLOCK_FATAL_ERROR 32 /* hardware-error */ + +#define NEED_MEM ((uint) 10*4*(IO_SIZE+32)+32) /* Nead for recursion */ +#define MAXERR 20 +#define BUFFERS_WHEN_SORTING 16 /* Alloc for sort-key-tree */ +#define WRITE_COUNT MY_HOW_OFTEN_TO_WRITE +#define INDEX_TMP_EXT ".TMM" +#define DATA_TMP_EXT ".TMD" + +#define UPDATE_TIME 1 +#define UPDATE_STAT 2 +#define UPDATE_SORT 4 +#define UPDATE_AUTO_INC 8 +#define UPDATE_OPEN_COUNT 16 + +#define USE_BUFFER_INIT (((1024L*512L-MALLOC_OVERHEAD)/IO_SIZE)*IO_SIZE) +#define READ_BUFFER_INIT (1024L*256L-MALLOC_OVERHEAD) +#define SORT_BUFFER_INIT (2048L*1024L-MALLOC_OVERHEAD) +#define MIN_SORT_BUFFER (4096-MALLOC_OVERHEAD) + +enum myisam_log_commands +{ + MI_LOG_OPEN, MI_LOG_WRITE, MI_LOG_UPDATE, MI_LOG_DELETE, MI_LOG_CLOSE, + MI_LOG_EXTRA, MI_LOG_LOCK, MI_LOG_DELETE_ALL }; #define myisam_log(a,b,c,d) if (myisam_log_file >= 0) _myisam_log(a,b,c,d) @@ -672,34 +635,32 @@ enum myisam_log_commands { #define fast_mi_writeinfo(INFO) if (!(INFO)->s->tot_locks) (void) _mi_writeinfo((INFO),0) #define fast_mi_readinfo(INFO) ((INFO)->lock_type == F_UNLCK) && _mi_readinfo((INFO),F_RDLCK,1) -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif - -extern uint _mi_get_block_info(MI_BLOCK_INFO *,File, my_off_t); -extern uint _mi_rec_pack(MI_INFO *info,byte *to,const byte *from); + extern uint _mi_get_block_info(MI_BLOCK_INFO *, File, my_off_t); +extern uint _mi_rec_pack(MI_INFO *info, byte *to, const byte *from); extern uint _mi_pack_get_block_info(MI_INFO *, MI_BLOCK_INFO *, File, my_off_t); -extern void _my_store_blob_length(byte *pos,uint pack_length,uint length); -extern void _myisam_log(enum myisam_log_commands command,MI_INFO *info, - const byte *buffert,uint length); +extern void _mi_store_blob_length(byte *pos, uint pack_length, uint length); +extern void _myisam_log(enum myisam_log_commands command, MI_INFO *info, + const byte *buffert, uint length); extern void _myisam_log_command(enum myisam_log_commands command, - MI_INFO *info, const byte *buffert, - uint length, int result); -extern void _myisam_log_record(enum myisam_log_commands command,MI_INFO *info, - const byte *record,my_off_t filepos, - int result); + MI_INFO *info, const byte *buffert, + uint length, int result); +extern void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info, + const byte *record, my_off_t filepos, + int result); extern void mi_report_error(int errcode, const char *file_name); extern my_bool _mi_memmap_file(MI_INFO *info); extern void _mi_unmap_file(MI_INFO *info); extern uint save_pack_length(uint version, byte *block_buff, ulong length); -extern uint read_pack_length(uint version, const uchar *buf, ulong *length); extern uint calc_pack_length(uint version, ulong length); extern uint mi_mmap_pread(MI_INFO *info, byte *Buffer, - uint Count, my_off_t offset, myf MyFlags); + uint Count, my_off_t offset, myf MyFlags); extern uint mi_mmap_pwrite(MI_INFO *info, byte *Buffer, - uint Count, my_off_t offset, myf MyFlags); + uint Count, my_off_t offset, myf MyFlags); extern uint mi_nommap_pread(MI_INFO *info, byte *Buffer, - uint Count, my_off_t offset, myf MyFlags); + uint Count, my_off_t offset, myf MyFlags); extern uint mi_nommap_pwrite(MI_INFO *info, byte *Buffer, uint Count, my_off_t offset, myf MyFlags); @@ -707,7 +668,7 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite); uchar *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state); uint mi_state_info_read_dsk(File file, MI_STATE_INFO *state, my_bool pRead); uint mi_base_info_write(File file, MI_BASE_INFO *base); -uchar *my_n_base_info_read(uchar *ptr, MI_BASE_INFO *base); +uchar *mi_n_base_info_read(uchar *ptr, MI_BASE_INFO *base); int mi_keyseg_write(File file, const HA_KEYSEG *keyseg); char *mi_keyseg_read(char *ptr, HA_KEYSEG *keyseg); uint mi_keydef_write(File file, MI_KEYDEF *keydef); @@ -719,22 +680,22 @@ char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo); extern int mi_disable_indexes(MI_INFO *info); extern int mi_enable_indexes(MI_INFO *info); extern int mi_indexes_are_disabled(MI_INFO *info); -ulong _my_calc_total_blob_length(MI_INFO *info, const byte *record); +ulong _mi_calc_total_blob_length(MI_INFO *info, const byte *record); ha_checksum mi_checksum(MI_INFO *info, const byte *buf); ha_checksum mi_static_checksum(MI_INFO *info, const byte *buf); my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, - ha_checksum unique_hash, my_off_t pos); + ha_checksum unique_hash, my_off_t pos); ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *buf); int _mi_cmp_static_unique(MI_INFO *info, MI_UNIQUEDEF *def, - const byte *record, my_off_t pos); + const byte *record, my_off_t pos); int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def, - const byte *record, my_off_t pos); + const byte *record, my_off_t pos); int mi_unique_comp(MI_UNIQUEDEF *def, const byte *a, const byte *b, - my_bool null_are_equal); -void mi_get_status(void* param, int concurrent_insert); -void mi_update_status(void* param); -void mi_copy_status(void* to,void *from); -my_bool mi_check_status(void* param); + my_bool null_are_equal); +void mi_get_status(void *param, int concurrent_insert); +void mi_update_status(void *param); +void mi_copy_status(void *to, void *from); +my_bool mi_check_status(void *param); void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows); extern MI_INFO *test_if_reopen(char *filename); @@ -742,24 +703,18 @@ my_bool check_table_is_closed(const char *name, const char *where); int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup); int mi_open_keyfile(MYISAM_SHARE *share); void mi_setup_functions(register MYISAM_SHARE *share); +my_bool mi_dynmap_file(MI_INFO *info, my_off_t size); +void mi_remap_file(MI_INFO *info, my_off_t size); /* Functions needed by mi_check */ -volatile int *killed_ptr(MI_CHECK *param); -void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...)); -void mi_check_print_warning _VARARGS((MI_CHECK *param, const char *fmt,...)); -void mi_check_print_info _VARARGS((MI_CHECK *param, const char *fmt,...)); -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); +volatile int *killed_ptr(HA_CHECK *param); +void mi_check_print_error _VARARGS((HA_CHECK *param, const char *fmt, ...)); +void mi_check_print_warning _VARARGS((HA_CHECK *param, const char *fmt, ...)); +void mi_check_print_info _VARARGS((HA_CHECK *param, const char *fmt, ...)); #ifdef THREAD pthread_handler_t thr_find_all_keys(void *arg); #endif -int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file); - -int sort_write_record(MI_SORT_PARAM *sort_param); -int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong); - +int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file); #ifdef __cplusplus } #endif - diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index de55b86252c..2b36e6438c1 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -806,7 +806,7 @@ static int find_record_with_key(struct file_info *file_info, byte *record) { uint key; MI_INFO *info=file_info->isam; - uchar tmp_key[MI_MAX_KEY_BUFF]; + uchar tmp_key[HA_MAX_KEY_BUFF]; for (key=0 ; key < info->s->base.keys ; key++) { diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index e80a3ffacd9..18313603394 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -2726,6 +2726,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) break; } case FIELD_LAST: + case FIELD_enum_val_count: abort(); /* Impossible */ } start_pos+=count->max_zero_fill; diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c index 97554dca4e6..9803b4e110b 100644 --- a/storage/myisam/rt_index.c +++ b/storage/myisam/rt_index.c @@ -540,7 +540,7 @@ static int rtree_insert_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, int res; if (!(page_buf = (uchar*)my_alloca((uint)keyinfo->block_length + - MI_MAX_KEY_BUFF))) + HA_MAX_KEY_BUFF))) { my_errno = HA_ERR_OUT_OF_MEM; return -1; @@ -654,7 +654,7 @@ static int rtree_insert_level(MI_INFO *info, uint keynr, uchar *key, uint nod_flag = info->s->base.key_reflength; if (!(new_root_buf = (uchar*)my_alloca((uint)keyinfo->block_length + - MI_MAX_KEY_BUFF))) + HA_MAX_KEY_BUFF))) { my_errno = HA_ERR_OUT_OF_MEM; return -1; diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index c9562461f56..443d2b11afe 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -16,7 +16,7 @@ /* Creates a index for a database by reading keys, sorting them and outputing - them in sorted order through SORT_INFO functions. + them in sorted order through MI_SORT_INFO functions. */ #include "fulltext.h" @@ -459,8 +459,8 @@ ok: int thr_write_keys(MI_SORT_PARAM *sort_param) { - SORT_INFO *sort_info=sort_param->sort_info; - MI_CHECK *param=sort_info->param; + MI_SORT_INFO *sort_info=sort_param->sort_info; + HA_CHECK *param=sort_info->param; ulong length, keys; ulong *rec_per_key_part=param->rec_per_key_part; int got_error=sort_info->got_error; @@ -870,7 +870,6 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, BUFFPEK *buffpek,**refpek; QUEUE queue; volatile int *killed= killed_ptr(info->sort_info->param); - DBUG_ENTER("merge_buffers"); count=error=0; -- 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) --- storage/myisam/mi_create.c | 3 ++- storage/myisam/mi_test2.c | 1 + storage/myisam/myisamchk.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 22cbde278be..1f45b2ce070 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -18,6 +18,7 @@ #include "ftdefs.h" #include "sp_defs.h" +#include #if defined(MSDOS) || defined(__WIN__) #ifdef __WIN__ @@ -430,7 +431,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, share.state.rec_per_key_part[key_segs-1]=1L; length+=key_length; /* Get block length for key, if defined by user */ - block_length= (keydef->block_length ? + block_length= (keydef->block_length ? my_round_up_to_next_power(keydef->block_length) : myisam_block_size); block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH); diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 357128b7a40..498b433f846 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -27,6 +27,7 @@ #endif #include "myisamdef.h" #include +#include #define STANDARD_LENGTH 37 #define MYISAM_KEYS 6 diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 7fcfb8fc65a..3a688613a4d 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef HAVE_SYS_VADVICE_H #include #endif -- cgit v1.2.1 From 4c6971b40225446e3f142d485ce6e93766122136 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Sep 2006 17:07:17 +0200 Subject: Manually merging changes made to MyISAM into Maria. End of merge. storage/maria/ft_maria.c: Rename: BitKeeper/deleted/.del-ft_maria.c -> storage/maria/ft_maria.c configure.in: maria moves to its plug.in storage/maria/Makefile.am: merging changes made to MyISAM into Maria. ft_maria.c is still needed. storage/maria/ha_maria.cc: merging changes made to MyISAM into Maria storage/maria/ma_dynrec.c: merging changes made to MyISAM into Maria storage/maria/ma_extra.c: merging changes made to MyISAM into Maria storage/maria/ma_ft_parser.c: merging changes made to MyISAM into Maria storage/maria/ma_open.c: merging changes made to MyISAM into Maria storage/maria/ma_sort.c: merging changes made to MyISAM into Maria storage/maria/ma_update.c: merging changes made to MyISAM into Maria storage/maria/ma_write.c: merging changes made to MyISAM into Maria storage/maria/maria_def.h: merging changes made to MyISAM into Maria storage/myisam/Makefile.am: merging changes made to MyISAM into Maria storage/maria/plug.in: merging changes made to MyISAM into Maria --- storage/myisam/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/Makefile.am b/storage/myisam/Makefile.am index e4766bfa05b..fb73635463d 100644 --- a/storage/myisam/Makefile.am +++ b/storage/myisam/Makefile.am @@ -99,7 +99,7 @@ libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \ mi_keycache.c mi_preload.c \ ft_parser.c ft_stopwords.c ft_static.c \ ft_update.c ft_boolean_search.c ft_nlq_search.c \ - sort.c ha_myisam.cc \ + sort.c ha_myisam.cc ft_myisam.c \ rt_index.c rt_key.c rt_mbr.c rt_split.c sp_key.c CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all rt_test.MY? sp_test.MY? -- 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) --- storage/myisam/myisamdef.h | 12 ++---------- storage/myisam/myisampack.c | 8 ++++---- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index d579213d7f9..be27c13dbe5 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -84,6 +84,7 @@ typedef struct st_mi_state_info time_t recover_time; /* Time for last recover */ time_t check_time; /* Time for last check */ uint sortkey; /* sorted by this key (not used) */ + uint open_count; uint8 changed; /* Changed since myisamchk */ /* the following isn't saved on disk */ @@ -224,16 +225,6 @@ typedef struct st_mi_isam_share } MYISAM_SHARE; -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; - struct st_myisam_info { MYISAM_SHARE *s; /* Shared between open:s */ @@ -309,6 +300,7 @@ struct st_myisam_info uchar *rtree_recursion_state; /* For RTREE */ int rtree_recursion_depth; }; + #define USE_WHOLE_KEY HA_MAX_KEY_BUFF*2 /* Use whole key in _mi_search() */ #define F_EXTRA_LCK -1 /* bits in opt_flag */ diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index be68ffbdc5a..d67fa8fa918 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -1105,16 +1105,16 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) my_off_t total_count; char llbuf[32]; - DBUG_PRINT("info", ("column: %3u", count - huff_counts + 1)); + DBUG_PRINT("info", ("column: %3lu", count - huff_counts + 1)); if (verbose >= 2) - VOID(printf("column: %3u\n", count - huff_counts + 1)); + VOID(printf("column: %3lu\n", count - huff_counts + 1)); if (count->tree_buff) { - DBUG_PRINT("info", ("number of distinct values: %u", + DBUG_PRINT("info", ("number of distinct values: %lu", (count->tree_pos - count->tree_buff) / count->field_length)); if (verbose >= 2) - VOID(printf("number of distinct values: %u\n", + VOID(printf("number of distinct values: %lu\n", (count->tree_pos - count->tree_buff) / count->field_length)); } -- 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 --- storage/myisam/myisampack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index 623d65f7ce3..2753ed5f7b2 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -1110,11 +1110,11 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) VOID(printf("column: %3u\n", (uint) (count - huff_counts + 1))); if (count->tree_buff) { - DBUG_PRINT("info", ("number of distinct values: %lu", + DBUG_PRINT("info", ("number of distinct values: %u", (uint) ((count->tree_pos - count->tree_buff) / count->field_length))); if (verbose >= 2) - VOID(printf("number of distinct values: %lu\n", + VOID(printf("number of distinct values: %u\n", (uint) ((count->tree_pos - count->tree_buff) / count->field_length))); } -- cgit v1.2.1 From b635df555adec7ebdc4cd40e102d51006c802639 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Jan 2007 12:41:51 +0100 Subject: very minor comments and merges from MyISAM into Maria. storage/maria/ma_checkpoint.c: comments storage/maria/ma_close.c: comments storage/maria/ma_write.c: merge from myisam storage/maria/maria_def.h: typo storage/myisam/mi_delete.c: unneeded {}, making it identical to Maria --- storage/myisam/mi_delete.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_delete.c b/storage/myisam/mi_delete.c index 7972ef614a0..1a683e2ac30 100644 --- a/storage/myisam/mi_delete.c +++ b/storage/myisam/mi_delete.c @@ -366,9 +366,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, { /* This happens only with packed keys */ DBUG_PRINT("test",("Enlarging of key when deleting")); if (!_mi_get_last_key(info,keyinfo,anc_buff,lastkey,keypos,&length)) - { goto err; - } ret_value=_mi_insert(info,keyinfo,key,anc_buff,keypos,lastkey, (uchar*) 0,(uchar*) 0,(my_off_t) 0,(my_bool) 0); } -- 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'' --- storage/myisam/mi_check.c | 63 ++++++++++++++++++++++++++------------------ storage/myisam/mi_create.c | 10 +++---- storage/myisam/mi_rsamepos.c | 3 ++- storage/myisam/mi_test2.c | 2 +- storage/myisam/sort.c | 10 +++---- 5 files changed, 50 insertions(+), 38 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 22860698a3a..05d4e5d77cf 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -911,6 +911,9 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info,int extend) if (*killed_ptr(param)) goto err2; switch (info->s->data_file_type) { + case BLOCK_RECORD: + DBUG_ASSERT(0); /* Impossible */ + break; case STATIC_RECORD: if (my_b_read(¶m->read_cache,(byte*) record, info->s->base.pack_reclength)) @@ -2897,6 +2900,9 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) DBUG_RETURN(1); switch (share->data_file_type) { + case BLOCK_RECORD: + DBUG_ASSERT(0); /* Impossible */ + break; case STATIC_RECORD: for (;;) { @@ -3283,6 +3289,9 @@ int sort_write_record(MI_SORT_PARAM *sort_param) if (sort_param->fix_datafile) { switch (sort_info->new_data_file_type) { + case BLOCK_RECORD: + DBUG_ASSERT(0); /* Impossible */ + break; case STATIC_RECORD: if (my_b_write(&info->rec_cache,sort_param->record, share->base.pack_reclength)) @@ -3395,18 +3404,19 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a) if (sort_info->key_block->inited) { - cmp=ha_key_cmp(sort_param->seg,sort_info->key_block->lastkey, + cmp=ha_key_cmp(sort_param->seg, (uchar*) sort_info->key_block->lastkey, (uchar*) a, USE_WHOLE_KEY,SEARCH_FIND | SEARCH_UPDATE, diff_pos); if (param->stats_method == MI_STATS_METHOD_NULLS_NOT_EQUAL) - ha_key_cmp(sort_param->seg,sort_info->key_block->lastkey, + ha_key_cmp(sort_param->seg, (uchar*) sort_info->key_block->lastkey, (uchar*) a, USE_WHOLE_KEY, SEARCH_FIND | SEARCH_NULL_ARE_NOT_EQUAL, diff_pos); else if (param->stats_method == MI_STATS_METHOD_IGNORE_NULLS) { diff_pos[0]= mi_collect_stats_nonulls_next(sort_param->seg, sort_param->notnull, - sort_info->key_block->lastkey, + (uchar*) sort_info-> + key_block->lastkey, (uchar*)a); } sort_param->unique[diff_pos[0]-1]++; @@ -3429,8 +3439,8 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a) llstr(sort_info->info->lastpos,llbuff), llstr(get_record_for_key(sort_info->info, sort_param->keyinfo, - sort_info->key_block-> - lastkey), + (uchar*) sort_info-> + key_block->lastkey), llbuff2)); param->testflag|=T_RETRY_WITHOUT_QUICK; if (sort_info->param->testflag & T_VERBOSE) @@ -3461,19 +3471,19 @@ int sort_ft_buf_flush(MI_SORT_PARAM *sort_param) val_len=share->ft2_keyinfo.keylength; get_key_full_length_rdonly(val_off, ft_buf->lastkey); - to=ft_buf->lastkey+val_off; + to= (uchar*) ft_buf->lastkey+val_off; if (ft_buf->buf) { /* flushing first-level tree */ - error=sort_insert_key(sort_param,key_block,ft_buf->lastkey, + error=sort_insert_key(sort_param,key_block, (uchar*) ft_buf->lastkey, HA_OFFSET_ERROR); for (from=to+val_len; - !error && from < ft_buf->buf; + !error && from < (uchar*) ft_buf->buf; from+= val_len) { memcpy(to, from, val_len); - error=sort_insert_key(sort_param,key_block,ft_buf->lastkey, + error=sort_insert_key(sort_param,key_block, (uchar*) ft_buf->lastkey, HA_OFFSET_ERROR); } return error; @@ -3482,8 +3492,8 @@ int sort_ft_buf_flush(MI_SORT_PARAM *sort_param) error=flush_pending_blocks(sort_param); /* updating lastkey with second-level tree info */ ft_intXstore(ft_buf->lastkey+val_off, -ft_buf->count); - _mi_dpointer(sort_info->info, ft_buf->lastkey+val_off+HA_FT_WLEN, - share->state.key_root[sort_param->key]); + _mi_dpointer(sort_info->info, (uchar*) ft_buf->lastkey+val_off+HA_FT_WLEN, + share->state.key_root[sort_param->key]); /* restoring first level tree data in sort_info/sort_param */ sort_info->key_block=sort_info->key_block_end- sort_info->param->sort_key_blocks; sort_param->keyinfo=share->keyinfo+sort_param->key; @@ -3491,7 +3501,7 @@ int sort_ft_buf_flush(MI_SORT_PARAM *sort_param) /* writing lastkey in first-level tree */ return error ? error : sort_insert_key(sort_param,sort_info->key_block, - ft_buf->lastkey,HA_OFFSET_ERROR); + (uchar*) ft_buf->lastkey,HA_OFFSET_ERROR); } static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) @@ -3530,7 +3540,7 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) if (ha_compare_text(sort_param->seg->charset, ((uchar *)a)+1,a_len-1, - ft_buf->lastkey+1,val_off-1, 0, 0)==0) + (uchar*) ft_buf->lastkey+1,val_off-1, 0, 0)==0) { if (!ft_buf->buf) /* store in second-level tree */ { @@ -3546,16 +3556,16 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) return 0; /* converting to two-level tree */ - p=ft_buf->lastkey+val_off; + p= (uchar*) ft_buf->lastkey+val_off; while (key_block->inited) key_block++; sort_info->key_block=key_block; sort_param->keyinfo=& sort_info->info->s->ft2_keyinfo; - ft_buf->count=(ft_buf->buf - p)/val_len; + ft_buf->count=((uchar*) ft_buf->buf - p)/val_len; /* flushing buffer to second-level tree */ - for (error=0; !error && p < ft_buf->buf; p+= val_len) + for (error=0; !error && p < (uchar*) ft_buf->buf; p+= val_len) error=sort_insert_key(sort_param,key_block,p,HA_OFFSET_ERROR); ft_buf->buf=0; return error; @@ -3607,9 +3617,9 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, HA_CHECK *param=sort_info->param; DBUG_ENTER("sort_insert_key"); - anc_buff=key_block->buff; + anc_buff= (uchar*) key_block->buff; info=sort_info->info; - lastkey=key_block->lastkey; + lastkey= (uchar*) key_block->lastkey; nod_flag= (key_block == sort_info->key_block ? 0 : info->s->base.key_reflength); @@ -3622,7 +3632,7 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, DBUG_RETURN(1); } a_length=2+nod_flag; - key_block->end_pos=anc_buff+2; + key_block->end_pos= (char*) anc_buff+2; lastkey=0; /* No previous key in block */ } else @@ -3630,18 +3640,18 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, /* Save pointer to previous block */ if (nod_flag) - _mi_kpointer(info,key_block->end_pos,prev_block); + _mi_kpointer(info,(uchar*) key_block->end_pos,prev_block); t_length=(*keyinfo->pack_key)(keyinfo,nod_flag, (uchar*) 0,lastkey,lastkey,key, &s_temp); - (*keyinfo->store_key)(keyinfo, key_block->end_pos+nod_flag,&s_temp); + (*keyinfo->store_key)(keyinfo, (uchar*) key_block->end_pos+nod_flag,&s_temp); a_length+=t_length; mi_putint(anc_buff,a_length,nod_flag); key_block->end_pos+=t_length; if (a_length <= keyinfo->block_length) { - VOID(_mi_move_key(keyinfo,key_block->lastkey,key)); + VOID(_mi_move_key(keyinfo,(uchar*) key_block->lastkey,key)); key_block->last_length=a_length-t_length; DBUG_RETURN(0); } @@ -3666,7 +3676,8 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, DBUG_DUMP("buff",(byte*) anc_buff,mi_getint(anc_buff)); /* Write separator-key to block in next level */ - if (sort_insert_key(sort_param,key_block+1,key_block->lastkey,filepos)) + if (sort_insert_key(sort_param,key_block+1,(uchar*) key_block->lastkey, + filepos)) DBUG_RETURN(1); /* clear old block and write new key in it */ @@ -3752,7 +3763,7 @@ int flush_pending_blocks(MI_SORT_PARAM *sort_param) key_block->inited=0; length=mi_getint(key_block->buff); if (nod_flag) - _mi_kpointer(info,key_block->end_pos,filepos); + _mi_kpointer(info,(uchar*) key_block->end_pos,filepos); key_file_length=info->state->key_file_length; bzero((byte*) key_block->buff+length, keyinfo->block_length-length); if ((filepos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR) @@ -3762,7 +3773,7 @@ int flush_pending_blocks(MI_SORT_PARAM *sort_param) if (key_file_length == info->state->key_file_length) { if (_mi_write_keypage(info, keyinfo, filepos, - DFLT_INIT_HITS, key_block->buff)) + DFLT_INIT_HITS, (uchar*) key_block->buff)) DBUG_RETURN(1); } else if (my_pwrite(info->s->kfile,(byte*) key_block->buff, @@ -3794,7 +3805,7 @@ static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks, for (i=0 ; i < blocks ; i++) { block[i].inited=0; - block[i].buff=(uchar*) (block+blocks)+(buffer_length+IO_SIZE)*i; + block[i].buff=(byte*) (block+blocks)+(buffer_length+IO_SIZE)*i; } DBUG_RETURN(block); } /* alloc_key_blocks */ diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index ad824bef009..cbd431cc222 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -41,7 +41,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, File dfile,file; int errpos,save_errno, create_mode= O_RDWR | O_TRUNC; myf create_flag; - uint fields,length,max_key_length,packed,pointer,real_length_diff, + uint fields,length,max_key_length,packed,pack_bytes,pointer,real_length_diff, key_length,info_length,key_segs,options,min_key_length_skip, base_pos,long_varchar_count,varchar_length, max_key_block_length,unique_key_parts,fulltext_keys,offset; @@ -189,11 +189,11 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (flags & HA_CREATE_RELIES_ON_SQL_LAYER) options|= HA_OPTION_RELIES_ON_SQL_LAYER; - packed=(packed+7)/8; + pack_bytes= (packed+7)/8; if (pack_reclength != INT_MAX32) pack_reclength+= reclength+packed + test(test_all_bits(options, HA_OPTION_CHECKSUM | HA_PACK_RECORD)); - min_pack_length+=packed; + min_pack_length+= pack_bytes; if (!ci->data_file_length && ci->max_rows) { @@ -547,9 +547,9 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, share.base.pack_reclength=reclength+ test(options & HA_OPTION_CHECKSUM); share.base.max_pack_length=pack_reclength; share.base.min_pack_length=min_pack_length; - share.base.pack_bits=packed; + share.base.pack_bits= pack_bytes; share.base.fields=fields; - share.base.pack_fields=packed; + share.base.pack_fields= packed; #ifdef USE_RAID share.base.raid_type=ci->raid_type; share.base.raid_chunks=ci->raid_chunks; diff --git a/storage/myisam/mi_rsamepos.c b/storage/myisam/mi_rsamepos.c index c4bd5fa16fa..d2dba64b0fd 100644 --- a/storage/myisam/mi_rsamepos.c +++ b/storage/myisam/mi_rsamepos.c @@ -33,7 +33,8 @@ int mi_rsame_with_pos(MI_INFO *info, byte *record, int inx, my_off_t filepos) DBUG_ENTER("mi_rsame_with_pos"); DBUG_PRINT("enter",("index: %d filepos: %ld", inx, (long) filepos)); - if (inx < -1 || inx >= 0 && ! mi_is_key_active(info->s->state.key_map, inx)) + if (inx < -1 || + (inx >= 0 && ! mi_is_key_active(info->s->state.key_map, inx))) { DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); } diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 357128b7a40..cf603f85630 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -603,7 +603,7 @@ int main(int argc, char *argv[]) if (mi_rsame(file,read_record2,(int) i)) goto err; if (bcmp(read_record,read_record2,reclength) != 0) { - printf("is_rsame didn't find same record\n"); + printf("mi_rsame didn't find same record\n"); goto end; } } diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index 0369be5db9d..50ba22e8beb 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -802,7 +802,7 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, register uint count; uint16 length_of_key = 0; uint idx; - uchar *buffp; + byte *buffp; if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count))) { @@ -889,7 +889,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, for (buffpek= Fb ; buffpek <= Tb ; buffpek++) { count+= buffpek->count; - buffpek->base= strpos; + buffpek->base= (byte*) strpos; buffpek->max_keys=maxcount; strpos+= (uint) (error=(int) info->read_to_buffer(from_file,buffpek, sort_length)); @@ -927,7 +927,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, { if (!(error=(int) info->read_to_buffer(from_file,buffpek,sort_length))) { - uchar *base=buffpek->base; + byte *base= buffpek->base; uint max_keys=buffpek->max_keys; VOID(queue_remove(&queue,0)); @@ -959,7 +959,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, } } buffpek=(BUFFPEK*) queue_top(&queue); - buffpek->base=(uchar *) sort_keys; + buffpek->base= (byte*) sort_keys; buffpek->max_keys=keys; do { @@ -974,7 +974,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, else { register uchar *end; - strpos= buffpek->key; + strpos= (uchar*) buffpek->key; for (end=strpos+buffpek->mem_count*sort_length; strpos != end ; strpos+=sort_length) -- cgit v1.2.1 From 3411bfe05a2a77c6c5b9911237792eb436f16543 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 18:23:58 +0100 Subject: merge from MyISAM into Maria (last step of merge of 5.1 into Maria). Tests: "maria" and "ps_maria" fail like before merge (assertions), "ma_test_all" fails like before merge (ma_test2 segfaults, I'll try to find out why). mysys/mf_pagecache.c: using a more distinctive tag storage/maria/ha_maria.cc: merge from MyISAM into Maria storage/maria/ma_check.c: merge from MyISAM into Maria storage/maria/ma_close.c: TODO as a word storage/maria/ma_create.c: merge from MyISAM into Maria storage/maria/ma_delete_all.c: TODO as a word storage/maria/ma_delete_table.c: TODO as a word storage/maria/ma_dynrec.c: merge from MyISAM into Maria storage/maria/ma_extra.c: merge from MyISAM into Maria storage/maria/ma_ft_boolean_search.c: merge from MyISAM into Maria storage/maria/ma_locking.c: merge from MyISAM into Maria storage/maria/ma_loghandler.c: fix for compiler warning storage/maria/ma_open.c: merge from MyISAM into Maria. I will ask Monty to check the ASKMONTY-marked piece of code. storage/maria/ma_packrec.c: merge from MyISAM into Maria storage/maria/ma_range.c: merge from MyISAM into Maria storage/maria/ma_rename.c: TODO as a word storage/maria/ma_rt_index.c: merge from MyISAM into Maria storage/maria/ma_rt_split.c: merge from MyISAM into Maria storage/maria/ma_search.c: merge from MyISAM into Maria storage/maria/ma_sort.c: merge from MyISAM into Maria storage/maria/ma_update.c: merge from MyISAM into Maria storage/maria/ma_write.c: merge from MyISAM into Maria storage/maria/maria_chk.c: merge from MyISAM into Maria storage/maria/maria_def.h: merge from MyISAM into Maria storage/maria/maria_pack.c: merge from MyISAM into Maria storage/maria/unittest/ma_test_loghandler_pagecache-t.c: fix for compiler warning storage/myisam/ha_myisam.cc: merge from MyISAM into Maria storage/myisammrg/ha_myisammrg.cc: merge from MyISAM into Maria --- storage/myisam/ha_myisam.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 0113fe80a08..f0bee43c4c6 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -293,7 +293,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, Check for underlying table conformance SYNOPSIS - check_definition() + myisam_check_definition() t1_keyinfo in First table key definition t1_recinfo in First table record definition t1_keys in Number of keys in first table @@ -323,13 +323,13 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, 1 - Different definitions. */ -int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, - uint t1_keys, uint t1_recs, - MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, - uint t2_keys, uint t2_recs, bool strict) +int myisam_check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, + uint t1_keys, uint t1_recs, + MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, + uint t2_keys, uint t2_recs, bool strict) { uint i, j; - DBUG_ENTER("check_definition"); + DBUG_ENTER("myisam_check_definition"); if ((strict ? t1_keys != t2_keys : t1_keys > t2_keys)) { DBUG_PRINT("error", ("Number of keys differs: t1_keys=%u, t2_keys=%u", -- cgit v1.2.1 From 0abffa05a60e3fccb31a81828fdc99986ce4b7c5 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Apr 2007 14:38:05 +0300 Subject: Fixed that maria.test works BUILD/SETUP.sh: Update from 5.1 include/maria.h: Moved structs into size order mysql-test/include/varchar.inc: Fixed error numbers (as in 5.1) mysql-test/mysql-test-run.pl: Updated from 5.1 Create a dummy mysql.err file if using --valgrind --debug mysql-test/lib/init_db.sql: Update from 5.1 mysql-test/lib/mtr_cases.pl: Update from 5.1 mysql-test/lib/mtr_diff.pl: Update from 5.1 mysql-test/lib/mtr_gcov.pl: Update from 5.1 mysql-test/lib/mtr_gprof.pl: Update from 5.1 mysql-test/lib/mtr_im.pl: Update from 5.1 mysql-test/lib/mtr_io.pl: Update from 5.1 mysql-test/lib/mtr_match.pl: Update from 5.1 mysql-test/lib/mtr_misc.pl: Update from 5.1 mysql-test/lib/mtr_process.pl: Update from 5.1 mysql-test/lib/mtr_report.pl: Update from 5.1 mysql-test/lib/mtr_stress.pl: Update from 5.1 mysql-test/lib/mtr_timer.pl: Update from 5.1 mysql-test/lib/mtr_unique.pl: Update from 5.1 mysql-test/r/maria.result: Updated results. The reason for the new results are: - Maria doesn't support REPAIR TABLE or OPTIMIZE table yet - Some statistics information is different, so MySQL prefers index reads instead of table scans - No support for concurrent writes in the default BLOCK_RECORD mode - No support for different KEY_BLOCK sizes (will not be fixed) mysql-test/t/disabled.def: Enable maria test mysql-test/t/maria.test: No support for concurrent writes in the default BLOCK_RECORD mode No support for different KEY_BLOCK sizes (will not be fixed) mysql-test/t/myisam.test: Fix to be able to run with --extern mysql-test/t/query_cache_notembedded.test: Fix to be able to run with --extern sql/filesort.cc: Fixed compiler warning sql/handler.cc: Use new error message (as in 5.1) sql/share/errmsg.txt: Update error messages (as in 5.1) sql/slave.cc: Fixed compiler warning sql/slave.h: Fixed compiler warning sql/sql_table.cc: Fixed compiler warning storage/maria/ha_maria.cc: Added better scan_time() Disble REPAIR on BLOCK_RECORD tables Added rnd_end() to free memory after scan Don't pack numerical primary keys Don't allow fast alter table if row type changes storage/maria/ha_maria.h: Added get_row_type(), scan_time() and rnd_end() BitKeeper/etc/ignore: Added storage/maria/unittest/mf_pagecache_consist_1k-t-big storage/maria/unittest/mf_pagecache_consist_1kHC-t-big storage/maria/unittest/mf_pagecache_consist_1kRD-t-big storage/maria/unittest/mf_pagecache_consist_1kWR-t-big storage/maria/unittest/mf_pagecache_consist_64k-t-big storage/maria/unittest/mf_pagecache_consist_64kHC-t-big storage/maria/unittest/mf_pagecache_consist_64kRD-t-big storage/maria/unittest/mf_pagecache_consist_64kWR-t-big storage/maria/unittest/mf_pagecache_single_64k-t-big to the ignore list storage/maria/ma_bitmap.c: Fixed some bugs found with maria.test Added more DBUG_PRINT and some more comments storage/maria/ma_blockrec.c: Fixed some bugs found with maria.test Simplified code More comments storage/maria/ma_blockrec.h: Added DBUG_ASSERT() storage/maria/ma_check.c: Don't check record data links with block_records Update state.changed properly storage/maria/ma_checksum.c: Fixed bug in checksum handling (only first field was calculated) storage/maria/ma_create.c: Set rec->fill_length properly Added extra testing needed for BLOCK_RECORD Fixed bug in unlock of not locked mutex Fixed memory leak storage/maria/ma_delete.c: Update state.changed storage/maria/ma_delete_all.c: Update state.changed storage/maria/ma_extra.c: Disable caching of rows if we are using BLOCK_RECORD (scan_init will enable caching of rows when using BLOCK_RECORD) storage/maria/ma_info.c: Added data_file_type storage/maria/ma_search.c: Fixed bug with signed bytes storage/maria/ma_test2.c: Fixed wrong pointer handling (caused crash on 64 bit machines) storage/maria/ma_write.c: Added DBUG_ statements storage/maria/maria_def.h: Added STATE_NOT_OPTIMIZED_ROWS storage/myisam/mi_create.c: Fixed bug with unlocking of not locked mutex (in case of error condition) storage/myisam/mi_test2.c: Fixed wrong pointer handling (caused crash on 64 bit machines) --- storage/myisam/mi_create.c | 21 ++++++++++++--------- storage/myisam/mi_test2.c | 3 +-- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index a675325f0a1..b98c7af19cc 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -46,7 +46,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, key_length,info_length,key_segs,options,min_key_length_skip, base_pos,long_varchar_count,varchar_length, max_key_block_length,unique_key_parts,fulltext_keys,offset; - uint aligned_key_start, block_length; + uint aligned_key_start, block_length, res; ulong reclength, real_reclength,min_pack_length; char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr; ulong pack_reclength; @@ -271,7 +271,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, keyseg->type != HA_KEYTYPE_VARBINARY2) { my_errno=HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } } keydef->keysegs+=sp_segs; @@ -280,7 +280,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, min_key_length_skip+=SPLEN*2*SPDIMS; #else my_errno= HA_ERR_UNSUPPORTED; - goto err; + goto err_no_lock; #endif /*HAVE_SPATIAL*/ } else if (keydef->flag & HA_FULLTEXT) @@ -296,7 +296,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, keyseg->type != HA_KEYTYPE_VARTEXT2) { my_errno=HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } if (!(keyseg->flag & HA_BLOB_PART) && (keyseg->type == HA_KEYTYPE_VARTEXT1 || @@ -421,7 +421,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (keydef->keysegs > HA_MAX_KEY_SEG) { my_errno=HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } /* key_segs may be 0 in the case when we only want to be able to @@ -446,7 +446,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, length >= HA_MAX_KEY_BUFF) { my_errno=HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } set_if_bigger(max_key_block_length,keydef->block_length); keydef->keylength= (uint16) key_length; @@ -493,7 +493,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, "indexes and/or unique constraints.", MYF(0), name + dirname_length(name)); my_errno= HA_WRONG_CREATE_OPTION; - goto err; + goto err_no_lock; } bmove(share.state.header.file_version,(byte*) myisam_file_magic,4); @@ -815,13 +815,16 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, } errpos=0; pthread_mutex_unlock(&THR_LOCK_myisam); + res= 0; if (my_close(file,MYF(0))) - goto err; + res= my_errno; my_free((char*) rec_per_key_part,MYF(0)); - DBUG_RETURN(0); + DBUG_RETURN(res); err: pthread_mutex_unlock(&THR_LOCK_myisam); +err_no_lock: + save_errno=my_errno; switch (errpos) { case 3: diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 9cf47e1555b..f68c9746cc2 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -778,8 +778,7 @@ int main(int argc, char *argv[]) { ulong blob_length,pos; uchar *ptr; - longget(blob_length,read_record+blob_pos+4); - ptr=(uchar*) blob_length; + memcpy_fixed(&ptr, read_record+blob_pos+4, sizeof(ptr)); longget(blob_length,read_record+blob_pos); for (pos=0 ; pos < blob_length ; pos++) { -- cgit v1.2.1 From eb7d9500a9909ce594c4d169e70fb5cecbb33e2b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Apr 2007 13:18:56 +0300 Subject: Fixes after review of guilhem of block record patch Short overview: Changed a lot of variable, functions, defines and struct elements to use more readable names More comments (mostly function and structure slot comments) Other things: Changed 'USE_WHOLE_KEY' to a big number to not interfer with long keys Ensure that tail block are at least of size 'MIN_TAIL_SIZE' Allow longer keys and key parts than before (don't limit Maria interface by HA_MAX_KEY_LENGTH) Use ma_chsize() to write initial bitmap page Added checking if using file with wrong block_size Added issing types to type_names[] (for maria_chk -d) Added maria_max_key_length() include/maria.h: Changed maria_portable_size_char_ptr to portable_size_char_ptr and moved it to my_handler.h Removed not used variable maria_delay_rec_write. More comments include/my_handler.h: Added portable_sizeof_char_ptr include/myisam.h: Changed mi_portable_size_char_ptr to portable_size_char_ptr and moved it to my_handler.h mysql-test/r/maria.result: Fix results when we now have a longer key length mysql-test/t/maria.test: More tests mysys/my_pread.c: Code cleanup sql/net_serv.cc: Changed warning to note (as in main 5.1 tree) to avoid not critical failing tests sql/sql_select.cc: Use portable_sizeof_char_ptr storage/maria/ha_maria.cc: Added max_supported_key_length(), as this is not a trival function anymore storage/maria/ha_maria.h: Moved max_supported_key_length(), as this is not a trival function anymore storage/maria/ma_bitmap.c: Lots of new comments Added maria_bitmap_marker[] to mark 2 last bytes of each bitmap (for corruption detection) Trivial code changes (based on review comments) storage/maria/ma_blockrec.c: More code comments Renamed _block_row() functions to _block_record() Trivial code changes, based on review comments Moved Code from maria_close() to _ma_end_block_record() Some function renames to make things more understandable DIR_ENTRY_OFFSET -> DIR_COUNT_OFFSET keybuff_used -> keyread_buff_used ma_recordpos_to_offset -> ma_recordpos_to_dir_entry Changed some 'rec' named variables to 'column'. Ensure that tail block are at least of size 'MIN_TAIL_SIZE' storage/maria/ma_blockrec.h: More comments DIRCOUNT_SIZE -> DIR_COUNT_SIZE Added define for maira_bitmap_marker[] ma_recordpos_to_offset -> ma_recordpos_to_dir_entry xxx_block_row() -> xxx_block_record() Made _ma_read_bitmap_page() static storage/maria/ma_check.c: More comments ma_recordpos_to_offset() -> ma_recordpos_to_dir_entry() DIR_ENTRY_OFFSET -> DIR_COUNT_OFFSET rec variables -> column variables recdef -> columndef storage/maria/ma_checksum.c: rec -> column Avoid an 'if' in _ma_checksum() for the common case storage/maria/ma_close.c: Moved resetting of info->dfile to ma_end_once_block_record() storage/maria/ma_create.c: Some variable changes to make things more readable: recinfo -> columndef rec -> column rec_end -> end_column record_type -> datafile_type ma_recinfo_write() -> ma_columndef_write() Fixed wrong setting of 'data_file_length'; Now max_rows should be calculated correctly New check if too long key. Use ma_chsize() to write bitmap page. storage/maria/ma_delete.c: keybuff_used -> keyread_buff_used storage/maria/ma_dynrec.c: rec -> columndef rec_length -> column_length maria_portable_sizeof_char_ptr -> portable_sizeof_char_ptr Better comment for _ma_read_rnd_dynamic_record() storage/maria/ma_ft_eval.c: maria_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/maria/ma_ft_test1.c: maria_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/maria/ma_ft_update.c: keybuff_used -> keyread_buff_used storage/maria/ma_info.c: More comments storage/maria/ma_open.c: Added checking if using file with wrong block_size New checking of max_key_length rec -> columndef _ma_recinfo_write -> _ma_columndef_write Don't change block_size (as this is checked in ma_create()) More comments storage/maria/ma_packrec.c: Trivial code changes rec -> columndef maria_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/maria/ma_page.c: keybuff_used -> keyread_buff_used storage/maria/ma_rkey.c: Removed not needded empty line storage/maria/ma_rrnd.c: Removed not used variable storage/maria/ma_rt_index.c: keybuff_used -> keyread_buff_used storage/maria/ma_search.c: keybuff_used -> keyread_buff_used Trivial code changes storage/maria/ma_sp_test.c: maria_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/maria/ma_test1.c: maria_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/maria/ma_test2.c: maria_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/maria/ma_update.c: Updated comment storage/maria/ma_write.c: keybuff_used -> keyread_buff_used storage/maria/maria_chk.c: Added missing types to type_names[] Removed not used variable rec -> columndef Replaced some numbers with define flags storage/maria/maria_def.h: More comments Added 'MARIA_INDEX_MIN_OVERHEAD_SIZE' rec -> columndef keybuff_used -> keyread_buff_used _ma_recinfo_write -> _ma_culumndef_write _ma_recinfo_read -> _ma_columndef_read Changed 'USE_WHOLE_KEY' to a big number to not interfer with long keys Added maria_max_key_length() storage/maria/maria_pack.c: Updated message strings rec -> columndef maria_portable_sizeof_char_ptr -> portable_sizeof_char_ptr More comments storage/myisam/ft_eval.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/ft_test1.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_checksum.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_create.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_dynrec.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_open.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_packrec.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_rkey.c: Unlock mutex also in case of error storage/myisam/mi_test1.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_test2.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/myisampack.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/sp_test.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr support-files/magic: Fixed typo --- storage/myisam/ft_eval.c | 2 +- storage/myisam/ft_test1.c | 4 ++-- storage/myisam/mi_checksum.c | 4 ++-- storage/myisam/mi_create.c | 4 ++-- storage/myisam/mi_dynrec.c | 8 ++++---- storage/myisam/mi_open.c | 2 +- storage/myisam/mi_packrec.c | 2 +- storage/myisam/mi_rkey.c | 2 ++ storage/myisam/mi_test1.c | 4 ++-- storage/myisam/mi_test2.c | 2 +- storage/myisam/myisampack.c | 8 ++++---- storage/myisam/sp_test.c | 2 +- 12 files changed, 23 insertions(+), 21 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_eval.c b/storage/myisam/ft_eval.c index 7eb78861e5e..de01510fdd7 100644 --- a/storage/myisam/ft_eval.c +++ b/storage/myisam/ft_eval.c @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) recinfo[0].type=FIELD_SKIP_ENDSPACE; recinfo[0].length=docid_length; recinfo[1].type=FIELD_BLOB; - recinfo[1].length= 4+mi_portable_sizeof_char_ptr; + recinfo[1].length= 4+portable_sizeof_char_ptr; /* Define a key over the first column */ keyinfo[0].seg=keyseg; diff --git a/storage/myisam/ft_test1.c b/storage/myisam/ft_test1.c index e49c47bb268..b37935a0d7a 100644 --- a/storage/myisam/ft_test1.c +++ b/storage/myisam/ft_test1.c @@ -75,12 +75,12 @@ static int run_test(const char *filename) /* First define 2 columns */ recinfo[0].type=extra_field; - recinfo[0].length= (extra_field == FIELD_BLOB ? 4 + mi_portable_sizeof_char_ptr : + recinfo[0].length= (extra_field == FIELD_BLOB ? 4 + portable_sizeof_char_ptr : extra_length); if (extra_field == FIELD_VARCHAR) recinfo[0].length+= HA_VARCHAR_PACKLENGTH(extra_length); recinfo[1].type=key_field; - recinfo[1].length= (key_field == FIELD_BLOB ? 4+mi_portable_sizeof_char_ptr : + recinfo[1].length= (key_field == FIELD_BLOB ? 4+portable_sizeof_char_ptr : key_length); if (key_field == FIELD_VARCHAR) recinfo[1].length+= HA_VARCHAR_PACKLENGTH(key_length); diff --git a/storage/myisam/mi_checksum.c b/storage/myisam/mi_checksum.c index 711e87c1547..273b0779e26 100644 --- a/storage/myisam/mi_checksum.c +++ b/storage/myisam/mi_checksum.c @@ -31,9 +31,9 @@ ha_checksum mi_checksum(MI_INFO *info, const byte *buf) case FIELD_BLOB: { length=_mi_calc_blob_length(rec->length- - mi_portable_sizeof_char_ptr, + portable_sizeof_char_ptr, buf); - memcpy((char*) &pos, buf+rec->length- mi_portable_sizeof_char_ptr, + memcpy((char*) &pos, buf+rec->length- portable_sizeof_char_ptr, sizeof(char*)); break; } diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 2c2e6b9e101..9afe3d57ab6 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -117,10 +117,10 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, share.base.blobs++; if (pack_reclength != INT_MAX32) { - if (rec->length == 4+mi_portable_sizeof_char_ptr) + if (rec->length == 4+portable_sizeof_char_ptr) pack_reclength= INT_MAX32; else - pack_reclength+=(1 << ((rec->length-mi_portable_sizeof_char_ptr)*8)); /* Max blob length */ + pack_reclength+=(1 << ((rec->length-portable_sizeof_char_ptr)*8)); /* Max blob length */ } } else if (type == FIELD_SKIP_PRESPACE || diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index d56df7b269b..534d5d9563b 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -900,7 +900,7 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) else { char *temp_pos; - size_t tmp_length=length-mi_portable_sizeof_char_ptr; + size_t tmp_length=length-portable_sizeof_char_ptr; memcpy((byte*) to,from,tmp_length); memcpy_fixed(&temp_pos,from+tmp_length,sizeof(char*)); memcpy(to+tmp_length,temp_pos,(size_t) blob->length); @@ -1021,11 +1021,11 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff, if (type == FIELD_BLOB) { uint blob_length= - _mi_calc_blob_length(length-mi_portable_sizeof_char_ptr,record); + _mi_calc_blob_length(length-portable_sizeof_char_ptr,record); if (!blob_length && !(flag & bit)) goto err; if (blob_length) - to+=length - mi_portable_sizeof_char_ptr+ blob_length; + to+=length - portable_sizeof_char_ptr+ blob_length; } else if (type == FIELD_SKIP_ZERO) { @@ -1208,7 +1208,7 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, } else if (type == FIELD_BLOB) { - uint size_length=rec_length- mi_portable_sizeof_char_ptr; + uint size_length=rec_length- portable_sizeof_char_ptr; ulong blob_length=_mi_calc_blob_length(size_length,from); ulong from_left= (ulong) (from_end - from); if (from_left < size_length || diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 6fd7d7a571f..af7206dd335 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -453,7 +453,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) if (share->rec[i].type == (int) FIELD_BLOB) { share->blobs[j].pack_length= - share->rec[i].length-mi_portable_sizeof_char_ptr;; + share->rec[i].length-portable_sizeof_char_ptr;; share->blobs[j].offset=offset; j++; } diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index c74bfb5af41..d2676572569 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -1036,7 +1036,7 @@ static void uf_blob(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, else { ulong length=get_bits(bit_buff,rec->space_length_bits); - uint pack_length=(uint) (end-to)-mi_portable_sizeof_char_ptr; + uint pack_length=(uint) (end-to)-portable_sizeof_char_ptr; if (bit_buff->blob_pos+length > bit_buff->blob_end) { bit_buff->error=1; diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c index 917ba381504..77b2783cf56 100644 --- a/storage/myisam/mi_rkey.c +++ b/storage/myisam/mi_rkey.c @@ -83,6 +83,8 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len, { mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; + if (share->concurrent_insert) + rw_unlock(&share->key_root_lock[inx]); goto err; } break; diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c index c5a1ffcd5d7..0a11c3dbb74 100644 --- a/storage/myisam/mi_test1.c +++ b/storage/myisam/mi_test1.c @@ -71,12 +71,12 @@ static int run_test(const char *filename) /* First define 2 columns */ recinfo[0].type=FIELD_NORMAL; recinfo[0].length=1; /* For NULL bits */ recinfo[1].type=key_field; - recinfo[1].length= (key_field == FIELD_BLOB ? 4+mi_portable_sizeof_char_ptr : + recinfo[1].length= (key_field == FIELD_BLOB ? 4+portable_sizeof_char_ptr : key_length); if (key_field == FIELD_VARCHAR) recinfo[1].length+= HA_VARCHAR_PACKLENGTH(key_length);; recinfo[2].type=extra_field; - recinfo[2].length= (extra_field == FIELD_BLOB ? 4 + mi_portable_sizeof_char_ptr : 24); + recinfo[2].length= (extra_field == FIELD_BLOB ? 4 + portable_sizeof_char_ptr : 24); if (extra_field == FIELD_VARCHAR) recinfo[2].length+= HA_VARCHAR_PACKLENGTH(recinfo[2].length); if (opt_unique) diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index ef58f8776b5..6f7c1c980c5 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) if (use_blob) { recinfo[6].type=FIELD_BLOB; - recinfo[6].length=4+mi_portable_sizeof_char_ptr; + recinfo[6].length=4+portable_sizeof_char_ptr; recinfo[6].null_bit=0; recinfo[6].null_pos=0; } diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index fb631b5e63e..70dd7835c67 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -305,7 +305,7 @@ static void usage(void) puts("and you are welcome to modify and redistribute it under the GPL license\n"); puts("Pack a MyISAM-table to take much less space."); - puts("Keys are not updated, you must run myisamchk -rq on the datafile"); + puts("Keys are not updated, you must run myisamchk -rq on the index (.MYI) file"); puts("afterwards to update the keys."); puts("You should give the .MYI file as the filename argument."); @@ -1008,7 +1008,7 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) /* Calculate pos, end_pos, and max_length for variable length fields. */ if (count->field_type == FIELD_BLOB) { - uint field_length=count->field_length -mi_portable_sizeof_char_ptr; + uint field_length=count->field_length -portable_sizeof_char_ptr; ulong blob_length= _mi_calc_blob_length(field_length, start_pos); memcpy_fixed((char*) &pos, start_pos+field_length,sizeof(char*)); end_pos=pos+blob_length; @@ -2650,7 +2650,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) case FIELD_BLOB: { ulong blob_length=_mi_calc_blob_length(field_length- - mi_portable_sizeof_char_ptr, + portable_sizeof_char_ptr, start_pos); /* Empty blobs are encoded with a single 1 bit. */ if (!blob_length) @@ -2667,7 +2667,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) DBUG_PRINT("fields", ("FIELD_BLOB %lu bytes, bits: %2u", blob_length, count->length_bits)); write_bits(blob_length,count->length_bits); - memcpy_fixed(&blob,end_pos-mi_portable_sizeof_char_ptr, + memcpy_fixed(&blob,end_pos-portable_sizeof_char_ptr, sizeof(char*)); blob_end=blob+blob_length; /* Encode the blob bytes. */ diff --git a/storage/myisam/sp_test.c b/storage/myisam/sp_test.c index c7226589811..8078942e44a 100644 --- a/storage/myisam/sp_test.c +++ b/storage/myisam/sp_test.c @@ -79,7 +79,7 @@ int run_test(const char *filename) /* Define spatial column */ recinfo[1].type=FIELD_BLOB; - recinfo[1].length=4 + mi_portable_sizeof_char_ptr; + recinfo[1].length=4 + portable_sizeof_char_ptr; -- cgit v1.2.1 From fdfb51484c9b1e239fd9eb738051020967c99c7f Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 9 Jun 2007 14:52:17 +0300 Subject: Fixed compiler warnings Fixed bug in ma_dbug.c that gave valgrind warning (only relevant when using --debug) Fixed bug in blob logging (Fixes valgrind warning) maria_getint() -> maria_data_on_page() mysys/safemalloc.c: Added debug function to print out where a piece of memory was allocated sql/opt_range.cc: Remove DBUG_PRINT of unitailized memory storage/maria/ma_blockrec.c: Fixed bug in blob logging storage/maria/ma_check.c: Fixed compiler warning storage/maria/ma_dbug.c: Added missed end++; Caused usage of unitialized memory for nullable keys that was not NULL storage/maria/ma_delete.c: maria_getint() -> maria_data_on_page() storage/maria/ma_init.c: Added header file to get rid of warning storage/maria/ma_key.c: More debugging storage/maria/ma_loghandler.c: Removed some wrong ';' to get rid of compiler errors when compiling without debugging Indentation fixes Removed not needed 'break's Fixed some compiler warnings Added code to detect logging of unitialized memory storage/maria/ma_page.c: maria_getint() -> maria_data_on_page() Clear rest of index page before writing when used with valgrind (Fixes warning of writing pages with unitialized data) storage/maria/ma_range.c: maria_getint() -> maria_data_on_page() storage/maria/ma_rt_index.c: maria_getint() -> maria_data_on_page() storage/maria/ma_rt_index.h: maria_getint() -> maria_data_on_page() storage/maria/ma_rt_key.c: maria_getint() -> maria_data_on_page() storage/maria/ma_rt_split.c: maria_getint() -> maria_data_on_page() storage/maria/ma_search.c: maria_getint() -> maria_data_on_page() storage/maria/ma_test1.c: Fixed compiler warning storage/maria/ma_write.c: maria_getint() -> maria_data_on_page() storage/maria/maria_chk.c: maria_getint() -> maria_data_on_page() storage/maria/maria_def.h: maria_getint() -> maria_data_on_page() storage/maria/unittest/ma_pagecache_consist.c: Fixed compiler warning storage/maria/unittest/ma_pagecache_single.c: Fixed compiler warning storage/maria/unittest/ma_test_loghandler-t.c: Fixed compiler warning storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Fixed compiler warning storage/maria/unittest/ma_test_loghandler_multithread-t.c: Fixed compiler warning storage/maria/unittest/ma_test_loghandler_pagecache-t.c: Fixed compiler warning storage/myisam/mi_dbug.c: Added missed end++; Caused usage of unitialized memory for nullable keys that was not NULL --- storage/myisam/mi_dbug.c | 1 + 1 file changed, 1 insertion(+) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_dbug.c b/storage/myisam/mi_dbug.c index 07c314c43e6..0808a7e85dd 100644 --- a/storage/myisam/mi_dbug.c +++ b/storage/myisam/mi_dbug.c @@ -45,6 +45,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg, fprintf(stream,"NULL"); continue; } + end++; } switch (keyseg->type) { -- cgit v1.2.1 From adac9798bff81a682b346f438eb7b58264b1b541 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Jun 2007 16:49:23 +0200 Subject: WL#3072 Maria Recovery - new program maria_read_log to display and apply log records found in a Maria log (see file's revision comment) - minor, misc fixes storage/maria/Makefile.am: new program maria_read_log storage/maria/ha_maria.cc: create control file if missing storage/maria/ma_blockrec.c: 0 -> LSN_IMPOSSIBLE; comments storage/maria/ma_checkpoint.h: preparations for Checkpoint module storage/maria/ma_close.c: comment storage/maria/ma_control_file.c: renaming constants. Possibility to say "open control file but don't create it if it's missing" (used by maria_read_log which does not want to create anything) storage/maria/ma_control_file.h: renaming constants storage/maria/ma_create.c: I had duplicated "linkname" and "linkname_ptr", now I see it's not needed, reverting. Indeed those variables don't contain interesting information; fixing log record accordingly (the links are in ci->data/index_file_name). Storing keystart in log record is needed, to know at which size we must extend the file if we replay LOGREC_CREATE_TABLE. storage/maria/ma_loghandler.c: some structures need to be known to maria_read_log.c, taking them to ma_loghandler.h storage/maria/ma_loghandler.h: we have page_store, adding page_korr. translog_lock() made public, because Checkpoint will need it (to write to control file). Some structures moved from ma_loghandler.c because maria_read_log.c needs them (needs to know the execute-in-REDO-phase hooks of each record). storage/maria/ma_loghandler_lsn.h: constants defined in ma_control_file.h serve everywhere, and they relate to LSNs, so putting them in ma_loghandler_lsn.h. Stronger constraints in LSN_VALID(). storage/maria/ma_pagecache.c: renaming constants storage/maria/ma_recovery.h: copyright storage/maria/ma_test1.c: new prototype storage/maria/ma_test2.c: new prototype storage/maria/trnman_public.h: double-inclusion safe storage/maria/unittest/ma_control_file-t.c: constants renamed, new prototype storage/maria/unittest/ma_test_loghandler-t.c: constants renamed, new prototype storage/maria/unittest/ma_test_loghandler_multigroup-t.c: constants renamed, new prototype storage/maria/unittest/ma_test_loghandler_multithread-t.c: constants renamed, new prototype storage/maria/unittest/ma_test_loghandler_pagecache-t.c: constants renamed, new prototype storage/myisam/mi_close.c: comment storage/maria/maria_read_log.c: program to read and print log records from a Maria transaction log, and optionally apply them to tables. Very basic, early version. Should serve as a base for Recovery's code. Designed to be idempotent. Create a log by running maria.test, then cd to var/master-data and run "maria_read_log --only-display" to see info about records; run "maria_read_log --display-and-apply" to also apply the records to tables (it's more interesting if you first wipe out the tables in var/master-data/test, to see how they get re-created). Only a few records are handled by now: LONG_TRANSACTION_ID, COMMIT, FILE_ID, REDO_CREATE_TABLE; place is ready for REDO_INSERT_ROW_HEAD where I could use Monty's help (search for "Monty" in the file). Note: changes to the index pages, index's header and bitmap pages are not properly logged yet, so don't expect the program to work with that. --- storage/myisam/mi_close.c | 1 + 1 file changed, 1 insertion(+) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c index 47b7ba855c0..270a5dff056 100644 --- a/storage/myisam/mi_close.c +++ b/storage/myisam/mi_close.c @@ -75,6 +75,7 @@ int mi_close(register MI_INFO *info) not change the crashed state. We can NOT write the state in other cases as other threads may be using the file at this point + IF using --external-locking. */ if (share->mode != O_RDONLY && mi_is_crashed(info)) mi_state_info_write(share->kfile, &share->state, 1); -- cgit v1.2.1 From d6f2fda680ec2be373ff5694e91cfccf792f4eb0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Jul 2007 16:20:57 +0300 Subject: Fixed REPAIR/CHECK/ANALYZE TABLE for tables with new BLOCK-ROW format. Fixed maria_chk to repair BLOCK-ROW tables. Added CREATE options ROW_FORMAT=PAGE & TRANSACTIONAL= 0|1 More DBUG information in a lot of functions Some minor code cleanups Enable handler errors earlier for better clear text error messages at handler startup / standalone usage. Don't print NULL strings in my_create_with_symlink(); Fixes core dump when used with --debug include/maria.h: Added extra variables needed for REPAIR with BLOCK records include/my_base.h: Added argument for opening copy of maria table without a shared object include/my_handler.h: Prototypes for my_handler_error_register() & my_handler_error_unregister() include/pagecache.h: Added PAGECACHE_READ_UNKNOWN_PAGE mysql-test/include/ps_conv.inc: Enforce creation of table as MyISAM (to allow one to use --default-storage-engine) mysql-test/r/maria.result: Moved some things to maria-connect.test Updared results as REPAIR now works Added tests for creation option TRANSACTIONAL mysql-test/r/ps_2myisam.result: Enforce creation of table as MyISAM (to allow one to use --default-storage-engine) mysql-test/r/ps_3innodb.result: Enforce creation of table as MyISAM (to allow one to use --default-storage-engine) mysql-test/r/ps_4heap.result: Enforce creation of table as MyISAM (to allow one to use --default-storage-engine) mysql-test/r/ps_5merge.result: Enforce creation of table as MyISAM (to allow one to use --default-storage-engine) mysql-test/r/ps_7ndb.result: Enforce creation of table as MyISAM (to allow one to use --default-storage-engine) mysql-test/r/ps_maria.result: Enforce creation of table as MyISAM (to allow one to use --default-storage-engine) mysql-test/t/maria.test: Moved some things to maria-connect.test Updared results as REPAIR now works Added tests for creation option TRANSACTIONAL mysys/mf_iocache.c: More debugging mysys/mf_tempfile.c: Added missing close() mysys/my_error.c: init_glob_errs() is now done in my_init() mysys/my_handler.c: Added functions to initialize handler error messages mysys/my_init.c: Moevd init_glob_errs() here. mysys/my_open.c: More comments More debugging Code cleanup (join multiple code paths) and indentation fixes. No change in logic. mysys/my_symlink2.c: Don't print NULL strings sql/handler.cc: Added printing of PAGE row type Moved out initializing of handler errors to allow handler to give better error messages at startup sql/handler.h: ROW_TYPE_PAGES -> ROW_TYPE_PAGE sql/lex.h: Added 'PAGE' and 'TRANSACTIONAL' sql/mysqld.cc: Initialize handler error messages early to get better error messages from handler startup sql/sql_show.cc: ROW_TYPE_PAGES -> ROW_TYPE_PAGE sql/sql_table.cc: Removed not needed initializer sql/sql_yacc.yy: Added CREATE options ROW_FORMAT=PAGE and TRANSACTIONAL=[0|1] sql/table.cc: Store transactional flag in .frm More comments sql-bench/example: Better example sql/table.h: Added transactional table option storage/maria/ha_maria.cc: More debug information Enable REPAIR Detect usage of TRANSACTIONAL table option storage/maria/ma_bitmap.c: More comments (from Guilhem) storage/maria/ma_blockrec.c: SANITY_CHECK -> SANITY_CHECKS (fixed typo) Write out pages on delete even if there is no rows. (Fixed problem with REPAIR) Removed some ASSERTS to runtime checks (for better REPAIR) Fixed bug when scanning rows More DBUG information storage/maria/ma_check.c: Partial rewrite to allow REPAIR of BLOCK/PAGE format. Repair of BLOCK format rows is for now only done with 'maria_repair()' (= repair through key cache) The new logic to repair rows with BLOCK format is: - Create new, unrelated MARIA_HA of the table - Create new datafile and associate it with new handler - Reset all statistic information in new handler - Copy all data to new handler with normal write operations - Move state of new handler to old handler - Close new handler - Close data file in old handler - Rename old data file to new data file. - Reopen data file in old handler storage/maria/ma_close.c: REmoved not needed block storage/maria/ma_create.c: Swap arguments to _ma_initialize_data_file() storage/maria/ma_delete_all.c: Split maria_delete_all_rows() to two functions to allow REPAIR to easily reset all status information. storage/maria/ma_dynrec.c: Added checksum argument to _ma_rec_check (multi-thread fix) storage/maria/ma_info.c: Indentation fix storage/maria/ma_init.c: Register error message to get better error message on init and when using as standalone module. storage/maria/ma_loghandler.c: Fixed typo that disabled some error detection by valgrind storage/maria/ma_open.c: Added 'calc_check_checksum()' Don't log things during repair Added option HA_OPEN_COPY to allow one to open a Maria table with an independent share (required by REPAIR) storage/maria/ma_pagecache.c: Fixed some compiler warnings Added support for PAGECACHE_READ_UNKNOWN_PAGE (used for scanning file without knowing page types) storage/maria/ma_test_all.sh: More test of REPAIR storage/maria/ma_update.c: Optimized checksum code storage/maria/maria_chk.c: Use DBUG_SET_INITIAL() to get DBUG to work with --parallel-repair Ensure we always use maria_repair() for BLOCK format (for now) More DBUG information storage/maria/maria_def.h: For now, always run with more checkings (SANITY_CHECKS) Added share->calc_check_checksum to be used with REPAIR / CHECK table. Swaped arguments to _ma_initialize_data_file() storage/myisam/ft_stopwords.c: Added DBUG information mysql-test/r/maria-connect.result: New BitKeeper file ``mysql-test/r/maria-connect.result'' mysql-test/t/maria-connect.test: New BitKeeper file ``mysql-test/t/maria-connect.test'' --- storage/myisam/ft_stopwords.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 1b6cff5e903..b95e0f4d857 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -51,10 +51,11 @@ static int ft_add_stopword(const char *w) int ft_init_stopwords() { + DBUG_ENTER("ft_init_stopwords"); if (!stopwords3) { if (!(stopwords3=(TREE *)my_malloc(sizeof(TREE),MYF(0)))) - return -1; + DBUG_RETURN(-1); init_tree(stopwords3,0,0,sizeof(FT_STOPWORD),(qsort_cmp2)&FT_STOPWORD_cmp, 0, (ft_stopword_file ? (tree_element_free)&FT_STOPWORD_free : 0), @@ -70,10 +71,10 @@ int ft_init_stopwords() int error=-1; if (!*ft_stopword_file) - return 0; + DBUG_RETURN(0); if ((fd=my_open(ft_stopword_file, O_RDONLY, MYF(MY_WME))) == -1) - return -1; + DBUG_RETURN(-1); len=(uint)my_seek(fd, 0L, MY_SEEK_END, MYF(0)); my_seek(fd, 0L, MY_SEEK_SET, MYF(0)); if (!(start=buffer=my_malloc(len+1, MYF(MY_WME)))) @@ -90,7 +91,7 @@ err1: my_free(buffer, MYF(0)); err0: my_close(fd, MYF(MY_WME)); - return error; + DBUG_RETURN(error); } else { @@ -100,13 +101,14 @@ err0: for (;*sws;sws++) { if (ft_add_stopword(*sws)) - return -1; + DBUG_RETURN(-1); } ft_stopword_file="(built-in)"; /* for SHOW VARIABLES */ } - return 0; + DBUG_RETURN(0); } + int is_stopword(char *word, uint len) { FT_STOPWORD sw; @@ -118,6 +120,8 @@ int is_stopword(char *word, uint len) void ft_free_stopwords() { + DBUG_ENTER("ft_free_stopwords"); + if (stopwords3) { delete_tree(stopwords3); /* purecov: inspected */ @@ -125,4 +129,5 @@ void ft_free_stopwords() stopwords3=0; } ft_stopword_file= 0; + DBUG_VOID_RETURN; } -- cgit v1.2.1 From 631ecaabea7336a8f28367c0d1c291f0433f7e88 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Jul 2007 20:45:15 +0300 Subject: Merged with mysql-5.1 main tree. BUILD/compile-pentium-debug-max: Added definition after macro was removed from main tree. This will be fixed back in main tree later. --- storage/myisam/ft_myisam.c | 4 ++-- storage/myisam/ha_myisam.cc | 9 +++++---- storage/myisam/myisamdef.h | 7 ++++--- storage/myisam/sort.c | 8 ++++---- 4 files changed, 15 insertions(+), 13 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_myisam.c b/storage/myisam/ft_myisam.c index 76c04ba4c0b..bef3fbfd5f5 100644 --- a/storage/myisam/ft_myisam.c +++ b/storage/myisam/ft_myisam.c @@ -23,8 +23,8 @@ #include "ftdefs.h" FT_INFO *ft_init_search(uint flags, void *info, uint keynr, - byte *query, uint query_len, CHARSET_INFO *cs, - byte *record) + uchar *query, uint query_len, CHARSET_INFO *cs, + uchar *record) { FT_INFO *res; if (flags & FT_BOOL) diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 3472bbcabd5..4f02705c18c 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1244,7 +1244,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) if (error != HA_ADMIN_OK) { /* Send error to user */ - MI_CHECK param; + HA_CHECK param; myisamchk_init(¶m); param.thd= thd; param.op_name= "assign_to_keycache"; @@ -1415,7 +1415,7 @@ int ha_myisam::enable_indexes(uint mode) else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE) { THD *thd=current_thd; - MI_CHECK param; + HA_CHECK param; const char *save_proc_info=thd->proc_info; thd->proc_info="Creating index"; myisamchk_init(¶m); @@ -1424,7 +1424,8 @@ int ha_myisam::enable_indexes(uint mode) T_CREATE_MISSING_KEYS); param.myf_rw&= ~MY_WAIT_IF_FULL; param.sort_buffer_length= thd->variables.myisam_sort_buff_size; - param.stats_method= (enum_mi_stats_method)thd->variables.myisam_stats_method; + param.stats_method= + (enum_handler_stats_method)thd->variables.myisam_stats_method; param.tmpdir=&mysql_tmpdir_list; if ((error= (repair(thd,param,0) != HA_ADMIN_OK)) && param.retry_repair) { @@ -1922,7 +1923,7 @@ void ha_myisam::get_auto_increment(ulonglong offset, ulonglong increment, { ulonglong nr; int error; - uchar key[MI_MAX_KEY_LENGTH]; + uchar key[HA_MAX_KEY_LENGTH]; if (!table->s->next_number_key_offset) { // Autoincrement at key-start diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 0daa6a7fc72..004e8cce8bb 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -550,8 +550,9 @@ extern int _mi_dispose(MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos, extern my_off_t _mi_new(MI_INFO *info, MI_KEYDEF *keyinfo, int level); extern uint _mi_make_key(MI_INFO *info, uint keynr, uchar *key, const uchar *record, my_off_t filepos); -extern uint _mi_pack_key(MI_INFO *info, uint keynr, uchar *key, uchar *old, - uint key_length, HA_KEYSEG ** last_used_keyseg); +extern uint _mi_pack_key(MI_INFO *info, uint keynr, uchar *key, + uchar *old, key_part_map keypart_map, + HA_KEYSEG ** last_used_keyseg); extern int _mi_read_key_record(MI_INFO *info, my_off_t filepos, uchar *buf); extern int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length, int re_read_if_possibly); @@ -566,7 +567,7 @@ extern uchar *mi_alloc_rec_buff(MI_INFO *, ulong, uchar **); extern ulong _mi_rec_unpack(MI_INFO *info, uchar *to, uchar *from, ulong reclength); -extern my_bool _mi_rec_check(MI_INFO *info, const char *record, uchar *packpos, +extern my_bool _mi_rec_check(MI_INFO *info,const uchar *record, uchar *packpos, ulong packed_length, my_bool with_checkum); extern int _mi_write_part_record(MI_INFO *info, my_off_t filepos, ulong length, my_off_t next_filepos, uchar ** record, diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index 2e2684230e7..3ab478682c6 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -831,7 +831,7 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, register uint count; uint16 length_of_key = 0; uint idx; - byte *buffp; + uchar *buffp; if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count))) { @@ -918,7 +918,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, for (buffpek= Fb ; buffpek <= Tb ; buffpek++) { count+= buffpek->count; - buffpek->base= (byte*) strpos; + buffpek->base= (uchar*) strpos; buffpek->max_keys=maxcount; strpos+= (uint) (error=(int) info->read_to_buffer(from_file,buffpek, sort_length)); @@ -956,7 +956,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, { if (!(error=(int) info->read_to_buffer(from_file,buffpek,sort_length))) { - byte *base= buffpek->base; + uchar *base= buffpek->base; uint max_keys=buffpek->max_keys; VOID(queue_remove(&queue,0)); @@ -988,7 +988,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, } } buffpek=(BUFFPEK*) queue_top(&queue); - buffpek->base= (byte*) sort_keys; + buffpek->base= (uchar*) sort_keys; buffpek->max_keys=keys; do { -- cgit v1.2.1 From fcdc76c28952608524d6e5a388bc7b04ad8de09f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Jul 2007 22:27:58 +0200 Subject: in mysql_unlock_tables(), do thr_unlock() AFTER external_unlock(). it means, {update,restore}_status() should be called in external_lock, not in thr_unlock. Only affects storage engines that support TL_WRITE_CONCURRENT. --- storage/myisam/mi_locking.c | 52 +++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index e822ea9e6da..d142b5eaa53 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -56,9 +56,15 @@ int mi_lock_database(MI_INFO *info, int lock_type) case F_UNLCK: ftparser_call_deinitializer(info); if (info->lock_type == F_RDLCK) + { count= --share->r_locks; + mi_restore_status(info); + } else + { count= --share->w_locks; + mi_update_status(info); + } --share->tot_locks; if (info->lock_type == F_WRLCK && !share->w_locks && !share->delay_key_write && flush_key_blocks(share->key_cache, @@ -84,16 +90,16 @@ int mi_lock_database(MI_INFO *info, int lock_type) if (share->changed && !share->w_locks) { #ifdef HAVE_MMAP - if ((info->s->mmaped_length != info->s->state.state.data_file_length) && - (info->s->nonmmaped_inserts > MAX_NONMAPPED_INSERTS)) - { - if (info->s->concurrent_insert) - rw_wrlock(&info->s->mmap_lock); - mi_remap_file(info, info->s->state.state.data_file_length); - info->s->nonmmaped_inserts= 0; - if (info->s->concurrent_insert) - rw_unlock(&info->s->mmap_lock); - } + if ((info->s->mmaped_length != info->s->state.state.data_file_length) && + (info->s->nonmmaped_inserts > MAX_NONMAPPED_INSERTS)) + { + if (info->s->concurrent_insert) + rw_wrlock(&info->s->mmap_lock); + mi_remap_file(info, info->s->state.state.data_file_length); + info->s->nonmmaped_inserts= 0; + if (info->s->concurrent_insert) + rw_unlock(&info->s->mmap_lock); + } #endif share->state.process= share->last_process=share->this_process; share->state.unique= info->last_unique= info->this_unique; @@ -300,6 +306,7 @@ void mi_get_status(void* param, int concurrent_insert) void mi_update_status(void* param) { MI_INFO *info=(MI_INFO*) param; + DBUG_ENTER("mi_update_status"); /* Because someone may have closed the table we point at, we only update the state if its our own state. This isn't a problem as @@ -336,20 +343,32 @@ void mi_update_status(void* param) } info->opt_flag&= ~WRITE_CACHE_USED; } + DBUG_VOID_RETURN; } void mi_restore_status(void *param) { MI_INFO *info= (MI_INFO*) param; + DBUG_ENTER("mi_restore_status"); + DBUG_PRINT("info",("key_file: %ld data_file: %ld", + (long) info->s->state.state.key_file_length, + (long) info->s->state.state.data_file_length)); info->state= &info->s->state.state; info->append_insert_at_end= 0; + DBUG_VOID_RETURN; } void mi_copy_status(void* to,void *from) { - ((MI_INFO*) to)->state= &((MI_INFO*) from)->save_state; + MI_INFO *info= (MI_INFO*) to; + DBUG_ENTER("mi_copy_status"); + info->state= &((MI_INFO*) from)->save_state; + DBUG_PRINT("info",("key_file: %ld data_file: %ld", + (long) info->state->key_file_length, + (long) info->state->data_file_length)); + DBUG_VOID_RETURN; } @@ -377,17 +396,18 @@ void mi_copy_status(void* to,void *from) my_bool mi_check_status(void *param) { MI_INFO *info=(MI_INFO*) param; + DBUG_ENTER("mi_check_status"); + DBUG_PRINT("info",("dellink: %ld r_locks: %u w_locks: %u", + (long) info->s->state.dellink, (uint) info->s->r_locks, + (uint) info->s->w_locks)); /* The test for w_locks == 1 is here because this thread has already done an external lock (in other words: w_locks == 1 means no other threads has a write lock) */ - DBUG_PRINT("info",("dellink: %ld r_locks: %u w_locks: %u", - (long) info->s->state.dellink, (uint) info->s->r_locks, - (uint) info->s->w_locks)); - return (my_bool) !(info->s->state.dellink == HA_OFFSET_ERROR || + DBUG_RETURN((my_bool) !(info->s->state.dellink == HA_OFFSET_ERROR || (myisam_concurrent_insert == 2 && info->s->r_locks && - info->s->w_locks == 1)); + info->s->w_locks == 1))); } -- cgit v1.2.1 From 5183a4b00b0cadf74b9ed5c92734617ec3c9270b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Sep 2007 12:05:17 +0300 Subject: Fixed several bugs found by running *.test with maria engine Renamed HA_EXTRA_PREAPRE_FOR_DELETE to HA_EXTRA_PERPARE_FOR_DROP Added HA_EXTRA_PREPARE_FOR_RENAME (as we in the code before used HA_EXTRA_PREPARE_FOR_DELETE also for renames which confused things) Allow multiple write locks for same page by same file handle Don't write table state if table is not changed include/my_base.h: Renamed HA_EXTRA_PREAPRE_FOR_DELETE to HA_EXTRA_PERPARE_FOR_DROP Added HA_EXTRA_PREPARE_FOR_RENAME (as we in the code before used HA_EXTRA_PREPARE_FOR_DELETE also for renames which confused things) mysql-test/r/maria.result: More tests of things that failed in other tests mysql-test/t/maria.test: More tests of things that failed in other tests sql/ha_partition.cc: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP Use HA_EXTRA_PREPARE_FOR_RENAME for renames sql/ha_partition.h: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP Use HA_EXTRA_PREPARE_FOR_RENAME for renames sql/lock.cc: Fixed comment sql/sql_table.cc: Fixed wrong usage of HA_EXTRA_PREAPRE_FOR_DELETE storage/maria/ha_maria.cc: Added missing _ma_renable_logging_for_table() (When using with ALTER TABLE + repair index) Enabled fast generation of index storage/maria/ma_bitmap.c: Fixed bug when resetting full pages when page was a tail page storage/maria/ma_blockrec.c: Fixed several bugs found by running *.test with maria engine: During update we keep old changed pages locked with a write lock to be able to reuse them. - Fixed bug with allocated but not used tail part - Fixed bug with blob that only had tail part - Fixed bug when update reused a page (needed multiple write locks for same page) - Fixed bug when first extent was a tail block storage/maria/ma_check.c: Better error message when bitmap is destroyed storage/maria/ma_close.c: Only write status if file was changed. Fixed bug when maria_chk -e file_name changed the file. storage/maria/ma_dynrec.c: Removed not used argument to _ma_state_info_read_dsk storage/maria/ma_extra.c: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP Use HA_EXTRA_PREPARE_FOR_RENAME for renames Only ignore flushing of pages for DROP (not rename) storage/maria/ma_locking.c: Removed not used argument to _ma_state_info_read_dsk storage/maria/ma_open.c: Removed not used argument to _ma_state_info_read_dsk storage/maria/ma_pagecache.c: Allow multiple write locks for same page by same file handle (Not yet complete, Sanja will fix) storage/maria/ma_recovery.c: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP storage/maria/maria_def.h: Removed not used argument to _ma_state_info_read_dsk storage/myisam/mi_extra.c: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP Use HA_EXTRA_PREPARE_FOR_RENAME for renames Only ignore flushing of pages for DROP (not rename) storage/myisammrg/ha_myisammrg.cc: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP Use HA_EXTRA_PREPARE_FOR_RENAME for renames --- storage/myisam/mi_extra.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 72c40741a22..f425d41a27e 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -255,15 +255,16 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) share->last_version= 0L; /* Impossible version */ pthread_mutex_unlock(&THR_LOCK_myisam); break; - case HA_EXTRA_PREPARE_FOR_DELETE: + case HA_EXTRA_PREPARE_FOR_RENAME: + case HA_EXTRA_PREPARE_FOR_DROP: pthread_mutex_lock(&THR_LOCK_myisam); share->last_version= 0L; /* Impossible version */ #ifdef __WIN__ /* Close the isam and data files as Win32 can't drop an open table */ pthread_mutex_lock(&share->intern_lock); if (flush_key_blocks(share->key_cache, share->kfile, - (function == HA_EXTRA_FORCE_REOPEN ? - FLUSH_RELEASE : FLUSH_IGNORE_CHANGED))) + (function == HA_EXTRA_PREPARE_FOR_DROP ? + FLUSH_IGNORE_CHANGED : FLUSH_RELEASE))) { error=my_errno; share->changed=1; -- cgit v1.2.1 From 6aef814d98ee2c8c4f3199e9505a988f7609e3a7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 11 Sep 2007 01:58:15 +0300 Subject: Fixed some bugs when using undo of VARCHAR fields Fixed bug in undo_delete Fixed wrong error output from maria_check include/my_base.h: Added marker if we have null fields in table mysql-test/r/maria.result: checksum in maria now ignore null fields that are null sql/sql_table.cc: Ignore null fields that are now (Before enabling this, we have to change MyISAM to also skip null fields) storage/maria/ma_blockrec.c: More logging After merge fixes Fixed some bugs when using undo of VARCHAR fields Fixed bug in undo_delete (We can't use info->rec_buff here as this is used in write_block_record()) storage/maria/ma_blockrec.h: ma_recordpos_to_dir_entry changed to return uint storage/maria/ma_check.c: Fixed wrong output in case of errors storage/maria/ma_create.c: Set share.base.pack_reclength more correct for block record Delete support for RAID storage/maria/ma_open.c: Don't calculate checksum fields with value NULL storage/maria/ma_test1.c: Fixed output from -v for VARCHAR keys storage/maria/ma_test_recovery.expected: Update results after adding new printf New checksums (because we now ignore nulls) Some file lengths are different, but think they are ok (didn't have time to investigate) storage/myisam/ha_myisam.cc: Fixed comment storage/myisam/mi_test1.c: Fixed bug --- storage/myisam/ha_myisam.cc | 3 ++- storage/myisam/mi_test1.c | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 4f02705c18c..a9a9f44049f 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -252,7 +252,8 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, DBUG_PRINT("loop", ("found: 0x%lx recpos: %d minpos: %d length: %d", (long) found, recpos, minpos, length)); if (recpos != minpos) - { // Reserved space (Null bits?) + { + /* reserve space for null bits */ bzero((char*) recinfo_pos, sizeof(*recinfo_pos)); recinfo_pos->type= (int) FIELD_NORMAL; recinfo_pos++->length= (uint16) (minpos - recpos); diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c index 1ceedf7f86a..4137b33fe42 100644 --- a/storage/myisam/mi_test1.c +++ b/storage/myisam/mi_test1.c @@ -79,6 +79,8 @@ static int run_test(const char *filename) recinfo[2].length= (extra_field == FIELD_BLOB ? 4 + portable_sizeof_char_ptr : 24); if (extra_field == FIELD_VARCHAR) recinfo[2].length+= HA_VARCHAR_PACKLENGTH(recinfo[2].length); + recinfo[1].null_bit= null_fields ? 2 : 0; + if (opt_unique) { recinfo[3].type=FIELD_CHECK; @@ -258,7 +260,8 @@ static int run_test(const char *filename) continue; create_key(key,j); my_errno=0; - if ((error = mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT))) + if ((error = mi_rkey(file,read_record,0,key,HA_WHOLE_KEY, + HA_READ_KEY_EXACT))) { if (verbose || (flags[j] >= 1 || (error && my_errno != HA_ERR_KEY_NOT_FOUND))) @@ -285,7 +288,7 @@ static int run_test(const char *filename) { create_key(key,i); my_errno=0; - error=mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT); + error=mi_rkey(file,read_record,0,key,HA_WHOLE_KEY,HA_READ_KEY_EXACT); if (verbose || (error == 0 && flags[i] == 0 && unique_key) || (error && (flags[i] != 0 || my_errno != HA_ERR_KEY_NOT_FOUND))) -- cgit v1.2.1 From a1bb4afa7ed8c77122c508bf2536e7a3f93ae1df Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Oct 2007 11:39:26 +0200 Subject: after-merge fixes for 64bit storage/maria/ma_test1.c: typo (?) fixed --- storage/myisam/myisamdef.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index b0b6da03015..fde80172643 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -185,8 +185,8 @@ typedef struct st_mi_isam_share ha_checksum(*calc_checksum) (struct st_myisam_info *, const uchar*); int(*compare_unique) (struct st_myisam_info *, MI_UNIQUEDEF *, const uchar *record, my_off_t pos); - uint(*file_read) (MI_INFO *, uchar *, size_t, my_off_t, myf); - uint(*file_write) (MI_INFO *, const uchar *, size_t, my_off_t, myf); + size_t (*file_read) (MI_INFO *, uchar *, size_t, my_off_t, myf); + size_t (*file_write) (MI_INFO *, const uchar *, size_t, my_off_t, myf); invalidator_by_filename invalidator; /* query cache invalidator */ ulong this_process; /* processid */ ulong last_process; /* For table-change-check */ @@ -664,13 +664,13 @@ extern void _mi_unmap_file(MI_INFO *info); extern uint save_pack_length(uint version, uchar *block_buff, ulong length); extern uint calc_pack_length(uint version, ulong length); extern size_t mi_mmap_pread(MI_INFO *info, uchar *Buffer, - uint Count, my_off_t offset, myf MyFlags); + size_t Count, my_off_t offset, myf MyFlags); extern size_t mi_mmap_pwrite(MI_INFO *info, const uchar *Buffer, - uint Count, my_off_t offset, myf MyFlags); + size_t Count, my_off_t offset, myf MyFlags); extern size_t mi_nommap_pread(MI_INFO *info, uchar *Buffer, - uint Count, my_off_t offset, myf MyFlags); + size_t Count, my_off_t offset, myf MyFlags); extern size_t mi_nommap_pwrite(MI_INFO *info, const uchar *Buffer, - uint Count, my_off_t offset, myf MyFlags); + size_t Count, my_off_t offset, myf MyFlags); uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite); uchar *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state); -- cgit v1.2.1 From 496741d5761f14dba39c7cfd01c31bcc0fe810b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Oct 2007 21:09:50 +0300 Subject: Moved randomize and my_rnd under mysys Added my_uuid Added pre-support for PAGE_CHECKSUM Added syntax for CREATE ... PAGE_CHECKSUM=# TABLE_CHECKSUM=# Reserved place for page checksums on index, bitmap and block pages Added index number to header of index pages Added linked list for free directory entries (speeds up inserts with BLOCK format) Calculate checksums in original column order (fixes bug with checksum on rows with BLOCK format) Cleaned up all index handling to use 'info->s->keypage_header' (variable size) as the header for index pages (before this was '2') Added 0xffffffff to end of index and block data bases and 0xfffffffe at end of bitmap pages when page checksums are not enabled Added _ma_get_page_used() and _ma_get_used_and_node() to simplify index page header handling rec_per_key_part is now in double precision Reserved place in index file for my_guid and nulls_per_key_part Give error HA_ERR_NEW_FILE if trying to open a Maria file with new, not yet supported extensions Lots of renames to increase readability: randomize() -> my_rnd_init() st_maria_info -> st_maria_handler st_maria_info -> MARIA_HA st_maria_isaminfo -> st_maria_info rand_struct -> my_rand_struct rec_per_key_rows -> records_at_analyze client/mysqladmin.cc: rand_struct -> my_rrnd_struct include/maria.h: st_maria_info -> MARIA_HA st_maria_isaminfo -> st_maria_info Changed analyze statistics to be of double precission Changed offset to field to be 32bits instead of 64 (safe as a record without blobs can't be that big) include/my_base.h: Added HA_OPTION_PAGE_CHECKSUM & HA_CREATE_PAGE_CHECKSUM Fixed comments Added HA_ERR_NEW_FILE include/my_sys.h: Added prototypes and structures for my_uuid() and my_rnd() include/myisamchk.h: Changed some buffers to size_t Added possibility to have key statistics with double precission include/mysql_com.h: Move rand functions to mysys libmysql/Makefile.shared: Added my_rnd mysql-test/r/maria.result: Updated results mysql-test/t/maria.test: More tests for checksum mysys/Makefile.am: Added my_rnd.c and my_uuid.c server-tools/instance-manager/listener.cc: Fixed include order (my_global.h should always be first) server-tools/instance-manager/mysql_connection.cc: Fixed include order (my_global.h should always be first) Use my_rnd_init() server-tools/instance-manager/mysql_connection.h: rand_struct -> my_rand_struct sql/handler.h: Added flag for page checksums sql/item_func.cc: Use new my_rnd() interface sql/item_func.h: Use new my_rnd() interface sql/item_strfunc.cc: Use new my_rnd() interface sql/lex.h: Added PAGE_CHECKSUM and TABLE_CHECKSUM sql/mysql_priv.h: Use new my_rnd() interface sql/mysqld.cc: Use new my_rnd() interface sql/password.c: Move my_rnd() to mysys Use new my_rnd() interface sql/sql_class.cc: Use new my_rnd() interface sql/sql_class.h: Use new my_rnd() interface sql/sql_crypt.cc: Use new my_rnd() interface sql/sql_crypt.h: Use new my_rnd() interface sql/sql_show.cc: Simpler handling of ha_choice_values Added PAGE_CHECKSUM sql/sql_table.cc: Enable correct checksum handling (for now) if not running in compatible mode sql/sql_yacc.yy: Added table option PAGE_CHECKSUM Added future compatible table option TABLE_CHECKSUM (alias for CHECKSUM) Added 'choice' target to simplify code sql/table.cc: Store flag for PAGE_CHECKSUM sql/table.h: Added support for PAGE_CHECKSUM storage/maria/ha_maria.cc: Remove protection for incompatbile frm and MAI (Slow, not needed test) Rec_per_key is now in double Remember row type for table Give warning if one Maria uses another row type than requested Removed some old ASK_MONTY entries (added comments instead) Added handling of PAGE_CHECKSUM flags storage/maria/ma_bitmap.c: Added page checksums to bitmap pages Added special bitmap marker for bitmap pages (Used to find bugs when running without page checksums) storage/maria/ma_blockrec.c: Added a free-link list over directory entries. This makes insert of small rows faster as we don't have to scan the whole directory to find a not used entry. Moved SANITY_CHECKS to maria_def.h Simplify code by introducing dir_entry_pos() Added support for PAGE_CHECKSUM storage/maria/ma_blockrec.h: Added DIR_FREE_SIZE (linked list of free directory entries) Added PAGE_CHECKSUM Added 'dir_entry_pos()' storage/maria/ma_check.c: Check that index pages has correct index number Calculate rec_per_key with double precission Simplify code by using '_ma_get_used_and_node()' Check free directory list Remove wrong end \n from messages maria_data_on_page() -> _ma_get_page_used() maria_putint() -> _ma_store_page_used() rec_per_key_rows -> records_at_analyze storage/maria/ma_checksum.c: Calculate checksum in original column order storage/maria/ma_create.c: Store original column order in index file Reserve place for nulls_per_key_part (future) Added support for PAGE_CHECKSUM storage/maria/ma_dbug.c: Fixed wrong debug output of key of type 'ulong' storage/maria/ma_delete.c: maria_data_on_page() -> _ma_get_used_and_node() maria_data_on_page() -> _ma_get_page_used() maria_putint() -> _ma_store_page_used() Added page header (index key number) to all index pages Reserved page for checksum on index pages Use keypage_header storage/maria/ma_ft_update.c: maria_putint() -> _ma_store_page_used() Store key number at start of page storage/maria/ma_loghandler.h: st_maria_info -> MARIA_HA storage/maria/ma_open.c: rec_per_key is now in double precission Added 'nulls_per_key_part' Added 'extra_options' (flags for future) Added support for PAGE_CHECKSUM Give error HA_ERR_NEW_FILE when using unsupported maria extensions Added comments Add maria_uuid to index file Added functions to store and read column_nr map. Changed some functions to return my_bool instead of uint storage/maria/ma_page.c: Added checks that pages has correct key nr Store 0xffffffff in checksum position if page checksums are not enabled Moved key-page-delete link to take into account keypage header storage/maria/ma_preload.c: Remove old MyISAM dependent code When scanning pages, only add pages to page cache for the requested index storage/maria/ma_range.c: maria_data_on_page() -> _ma_get_used_and_node() Use keypage_header storage/maria/ma_rt_index.c: Fixed indentation storage/maria/ma_rt_index.h: Added support for dynamic index page header Reserved place for PAGE_CHECKSUM storage/maria/ma_rt_key.c: Fixed indentation maria_data_on_page() -> _ma_get_page_used() maria_putint() -> maria_store_page_used() storage/maria/ma_rt_mbr.c: Fixed indentation storage/maria/ma_rt_split.c: Fixed indentation maria_data_on_page () -> _ma_get_page_used() storage/maria/ma_rt_test.c: Fixed indentation storage/maria/ma_search.c: Remove support of using -1 as 'last used index' to _ma_check_index() maria_data_on_page() -> _ma_get_page_used() maria_data_on_page() -> _ma_get_used_and_node() Use keypage_header storage/maria/ma_sort.c: Changed some buffers to size_t Changed rec_per_key_part to double storage/maria/ma_static.c: Removed NEAR Added maria_uuid storage/maria/ma_test2.c: Moevd testflag == 2 to correct place Remove test of reading with index number -1 (not supported anymore) storage/maria/ma_test_recovery.expected: Updated results storage/maria/ma_test_recovery: Changed tmp table names so that one can run maria_chk on them storage/maria/ma_write.c: Fixed indentation Use keypage_header Store index number on index pages maria_putint() -> _ma_store_page_used() maria_data_on_page() -> ma_get_used_and_node() maria_data_on_page() -> _ma_get_page_used() Added PAGE_CHECKSUM Added Maria handler to some functions Removed some not needed casts storage/maria/maria_chk.c: Added error handling for HA_ERR_NEW_FILE Added information about page checksums rec_per_key_part changed to double maria_data_on_page() -> _ma_get_page_used() Use keypage_header storage/maria/maria_def.h: Added IDENTICAL_PAGES_AFTER_RECOVERY and SANITY_CHECKS Changed rec_per_key_part to double Added nulls_per_key_part rec_per_key_rows -> records_at_analyze st_maria_info -> MARIA_HA Reserve place for new statistics variables, uuid, checksums per page etc. Removed NEAR tags Changed some prototypes to use my_bool and size_t storage/maria/maria_pack.c: st_maria_info -> MARIA_HA Fixed indentation storage/myisam/mi_dbug.c: Fix wrong debug output for ULONG mysys/my_rnd.c: New BitKeeper file ``mysys/my_rnd.c'' mysys/my_uuid.c: New BitKeeper file ``mysys/my_uuid.c'' --- storage/myisam/mi_dbug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_dbug.c b/storage/myisam/mi_dbug.c index 0808a7e85dd..659abdce131 100644 --- a/storage/myisam/mi_dbug.c +++ b/storage/myisam/mi_dbug.c @@ -92,7 +92,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg, key=end; break; case HA_KEYTYPE_ULONG_INT: - l_1=mi_sint4korr(key); + l_1=mi_uint4korr(key); VOID(fprintf(stream,"%lu",(ulong) l_1)); key=end; break; -- cgit v1.2.1 From 21fd2a5a3656813c3d97760a5e7eef987dc6879d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Nov 2007 19:08:06 +0200 Subject: First part of redo/undo for key pages Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion For transactional tables, shift record number in keys up with 1 bit to have place to indicate if transid follows Checksum for MyISAM now ignores NULL and not used part of VARCHAR Renamed some variables that caused shadow compiler warnings Moved extra() call when waiting for tables to not be used to after tables are removed from cache. Fixed crashing bugs when using Maria TEMPORARY tables with TRUNCATE. Removed 'hack' code in sql directory to go around this bug. pagecache_unlock_by_ulink() now has extra argument to say if page was changed. Give error message if we fail to open control file Mark page cache variables as not flushable include/maria.h: Made min page cache larger (needed for pinning key page) Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion Added write_comp_flag to move some runtime code to maria_open() include/my_base.h: Added new error message to be used when handler initialization failed include/my_global.h: Renamed dummy to swap_dummy to avoid conflicts with local 'dummy' variables include/my_handler.h: Added const to some parameters mysys/array.c: More DBUG mysys/my_error.c: Fixed indentation mysys/my_handler.c: Added const to some parameters Added missing error messages sql/field.h: Renamed variables to avoid variable shadowing sql/handler.h: Renamed parameter to avoid variable name conflict sql/item.h: Renamed variables to avoid variable shadowing sql/log_event_old.h: Renamed variables to avoid variable shadowing sql/set_var.h: Renamed variables to avoid variable shadowing sql/sql_delete.cc: Removed maria hack for temporary tables Fixed indentation sql/sql_table.cc: Moved extra() call when waiting for tables to not be used to after tables are removed from cache. This was needed to ensure we don't do a PREPARE_FOR_DROP or similar call while the table is still in use. sql/table.cc: Copy page_checksum from share Removed Maria hack storage/maria/Makefile.am: Added new files storage/maria/ha_maria.cc: Renamed records -> record_count and info -> create_info to avoid variable name conflicts Mark page cache variables as not flushable storage/maria/ma_blockrec.c: Moved _ma_unpin_all_pages() to ma_key_recover.c Moved init of info->pinned_pages to ma_open.c Moved _ma_finalize_row() to maria_key_recover.h Renamed some variables to avoid variable name conflicts Mark page_link.changed for blocks we change directly Simplify handling of undo link when writing LOGREC_UNDO_ROW_INSERT (old code crashed when having redo for index) storage/maria/ma_blockrec.h: Removed extra empty line storage/maria/ma_checkpoint.c: Remove not needed trnman.h storage/maria/ma_close.c: Free pinned pages (which are now always allocated) storage/maria/ma_control_file.c: Give error message if we fail to open control file storage/maria/ma_delete.c: Changes for redo logging (first part, logging of underflow not yet done) - Log undo-key-delete - Log delete of key - Updated arguments to _ma_fetch_keypage(), _ma_dispose(), _ma_write_keypage(), _ma_insert() - Added new arguments to some functions to be able to write redo information - Mark key pages as changed when we write with PAGECACHE_LOCK_LEFT_WRITELOCKED Remove one not needed _ma_write_keypage() in d_search() when upper level will do the write anyway Changed 2 bmove_upp() to bmove() as this made code easer to understand More function comments Indentation fixes storage/maria/ma_ft_update.c: New arguments to _ma_write_keypage() storage/maria/ma_loghandler.c: Fixed some DBUG_PRINT messages Simplify code Added new log entrys for key page redo Renamed some variables to avoid variable name shadowing storage/maria/ma_loghandler.h: Moved some defines here Added define for storing key number on key pages Added new translog record types Added enum for type of operations in LOGREC_REDO_INDEX storage/maria/ma_open.c: Always allocate info.pinned_pages (we need now also for normal key page usage) Update keyinfo->key_nr Added virtual functions to convert record position o number to be stored on key pages Update keyinfo->write_comp_flag to value of search flag to be used when writing key storage/maria/ma_page.c: Added redo for key pages - Extended _ma_fetch_keypage() with type of lock to put on page and address to used MARIA_PINNED_PAGE - _ma_fetch_keypage() now pin's pages if needed - Extended _ma_write_keypage() with type of locks to be used - ma_dispose() now locks info->s->state.key_del from other threads - ma_dispose() writes redo log record - ma_new() locks info->s->state.key_del from other threads if it was used - ma_new() now pins read page Other things: - Removed some not needed arguments from _ma_new() and _ma_dispose) - Added some new variables to simplify code - If EXTRA_DEBUG is used, do crc on full page to catch not unitialized bytes storage/maria/ma_pagecache.h: Applied patch from Sanja to add extra argument to pagecache_unlock_by_ulink() to mark if page was changed Added some defines for pagecache priority levels that one can use storage/maria/ma_range.c: Added new arguments for call to _ma_fetch_keypage() storage/maria/ma_recovery.c: - Added hooks for new translog types: REDO_INDEX, REDO_INDEX_NEW_PAGE, REDO_INDEX_FREE_PAGE, UNDO_KEY_INSERT, UNDO_KEY_DELETE and UNDO_KEY_DELETE_WITH_ROOT. - Moved variable declarations to start of function (portability fixes) - Removed some not needed initializations - Set only relevant state changes for each redo/undo entry storage/maria/lockman.c: Removed end space storage/maria/ma_check.c: Removed end space storage/maria/ma_create.c: Removed end space storage/maria/ma_locking.c: Removed end space storage/maria/ma_packrec.c: Removed end space storage/maria/ma_pagecache.c: Removed end space storage/maria/ma_panic.c: Removed end space storage/maria/ma_rt_index.c: Added new arguments for call to _ma_fetch_keypage(), _ma_write_keypage(), _ma_dispose() and _ma_new() Fixed indentation storage/maria/ma_rt_key.c: Added new arguments for call to _ma_fetch_keypage() storage/maria/ma_rt_split.c: Added new arguments for call to _ma_new() Use new keypage header Added new arguments for call to _ma_write_keypage() storage/maria/ma_search.c: Updated comments & indentation Added new arguments for call to _ma_fetch_keypage() Made some variables and arguments const Added virtual functions for converting row position to number to be stored in key use MARIA_RECORD_POS of record position instead of my_off_t Record in MARIA_KEY_PARAM how page was changed one key insert (needed for REDO) storage/maria/ma_sort.c: Removed end space storage/maria/ma_statrec.c: Updated arguments for call to _ma_rec_pos() storage/maria/ma_test1.c: Fixed too small buffer to init_pagecache() Fixed bug when using insert_count and test_flag storage/maria/ma_test2.c: Use more resonable pagecache size Remove not used code Reset blob_length to fix wrong output message storage/maria/ma_test_all.sh: Fixed wrong test storage/maria/ma_write.c: Lots of new code to handle REDO of key pages No logic changes because of REDO code, mostly adding new arguments and adding new code for logging Added new arguments for calls to _ma_fetch_keypage(), _ma_write_keypage() and similar functions Move setting of comp_flag in ma_ck_wrte_btree() from runtime to maria_open() Zerofill new used pages for: - To remove possible sensitive data left in buffer - To get idenitical data on pages after running redo - Better compression of pages if archived storage/maria/maria_chk.c: Added information if table is crash safe storage/maria/maria_def.h: New virtual function to convert between record position on key and normal record position Aded mutex and extra variables to handle locking of share->state.key_del Moved some structure variables to get things more aligned Added extra arguments to MARIA_KEY_PARAM to be able to remember what was changed on key page on key insert Added argument to MARIA_PINNED_PAGE to indicate if page was changed Updated prototypes for functions Added some structures for signaling changes in REDO handling storage/maria/unittest/ma_pagecache_single.c: Updated arguments for changed function calls storage/myisam/mi_check.c: Made calc_check_checksum virtual storage/myisam/mi_checksum.c: Update checksums to ignore null columns storage/myisam/mi_create.c: Mark if table has null column (to know when we have to use mi_checksum()) storage/myisam/mi_open.c: Added virtual function for calculating checksum to be able to easily ignore NULL fields storage/myisam/mi_test2.c: Fixed bug storage/myisam/myisamdef.h: Added virtual function for calculating checksum during check table Removed ha_key_cmp() as this is in handler.h storage/maria/ma_key_recover.c: New BitKeeper file ``storage/maria/ma_key_recover.c'' storage/maria/ma_key_recover.h: New BitKeeper file ``storage/maria/ma_key_recover.h'' storage/maria/ma_key_redo.c: New BitKeeper file ``storage/maria/ma_key_redo.c'' --- storage/myisam/mi_check.c | 24 ++++++++++++------------ storage/myisam/mi_checksum.c | 27 +++++++++++++++++---------- storage/myisam/mi_create.c | 4 ++++ storage/myisam/mi_open.c | 17 ++++++++++++----- storage/myisam/mi_test2.c | 4 ++-- storage/myisam/myisamdef.h | 6 +++--- 6 files changed, 50 insertions(+), 32 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index b41f06a5fb8..152ffd3bb55 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1008,7 +1008,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info,int extend) del_length+=info->s->base.pack_reclength; continue; /* Record removed */ } - param->glob_crc+= mi_static_checksum(info,record); + param->glob_crc+= (*info->s->calc_check_checksum)(info,record); used+=info->s->base.pack_reclength; break; case DYNAMIC_RECORD: @@ -1162,7 +1162,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info,int extend) } else { - info->checksum=mi_checksum(info,record); + info->checksum= (*info->s->calc_check_checksum)(info,record); if (param->testflag & (T_EXTEND | T_MEDIUM | T_VERBOSE)) { if (_mi_rec_check(info,record, info->rec_buff,block_info.rec_len, @@ -1208,10 +1208,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info,int extend) llstr(start_recpos,llbuff)); got_error=1; } - if (static_row_size) - param->glob_crc+= mi_static_checksum(info,record); - else - param->glob_crc+= mi_checksum(info,record); + param->glob_crc+= (*info->s->calc_check_checksum)(info,record); link_used+= (block_info.filepos - start_recpos); used+= (pos-start_recpos); } /* switch */ @@ -3164,7 +3161,9 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) { if (sort_param->calc_checksum) param->glob_crc+= (info->checksum= - mi_static_checksum(info,sort_param->record)); + (*info->s->calc_check_checksum)(info, + sort_param-> + record)); DBUG_RETURN(0); } if (!sort_param->fix_datafile && sort_param->master) @@ -3440,7 +3439,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if (sort_param->read_cache.error < 0) DBUG_RETURN(1); if (sort_param->calc_checksum) - info->checksum= mi_checksum(info, sort_param->record); + info->checksum= (*info->s->calc_check_checksum)(info, + sort_param->record); if ((param->testflag & (T_EXTEND | T_REP)) || searching) { if (_mi_rec_check(info, sort_param->record, sort_param->rec_buff, @@ -3525,7 +3525,9 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) info->packed_length=block_info.rec_len; if (sort_param->calc_checksum) param->glob_crc+= (info->checksum= - mi_checksum(info, sort_param->record)); + (*info->s->calc_check_checksum)(info, + sort_param-> + record)); DBUG_RETURN(0); } } @@ -3576,7 +3578,6 @@ int sort_write_record(MI_SORT_PARAM *sort_param) } sort_param->filepos+=share->base.pack_reclength; info->s->state.split++; - /* sort_info->param->glob_crc+=mi_static_checksum(info, sort_param->record); */ break; case DYNAMIC_RECORD: if (! info->blobs) @@ -3599,10 +3600,9 @@ int sort_write_record(MI_SORT_PARAM *sort_param) from= sort_info->buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER); } /* We can use info->checksum here as only one thread calls this. */ - info->checksum=mi_checksum(info,sort_param->record); + info->checksum= (*info->s->calc_check_checksum)(info,sort_param->record); reclength=_mi_rec_pack(info,from,sort_param->record); flag=0; - /* sort_info->param->glob_crc+=info->checksum; */ do { diff --git a/storage/myisam/mi_checksum.c b/storage/myisam/mi_checksum.c index 1aa56e571e3..8c408ef7ff5 100644 --- a/storage/myisam/mi_checksum.c +++ b/storage/myisam/mi_checksum.c @@ -19,27 +19,34 @@ ha_checksum mi_checksum(MI_INFO *info, const uchar *buf) { - uint i; ha_checksum crc=0; - MI_COLUMNDEF *rec=info->s->rec; + const uchar *record= buf; + MI_COLUMNDEF *column= info->s->rec; + MI_COLUMNDEF *column_end= column+ info->s->base.fields; + my_bool skip_null_bits= test(info->s->options & HA_OPTION_NULL_FIELDS); - for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length) + for ( ; column != column_end ; buf+= column++->length) { const uchar *pos; ulong length; - switch (rec->type) { + + if ((record[column->null_pos] & column->null_bit) && + skip_null_bits) + continue; /* Null field */ + + switch (column->type) { case FIELD_BLOB: { - length=_mi_calc_blob_length(rec->length- - portable_sizeof_char_ptr, - buf); - memcpy((char*) &pos, buf+rec->length- portable_sizeof_char_ptr, + length=_mi_calc_blob_length(column->length- + portable_sizeof_char_ptr, + buf); + memcpy((char*) &pos, buf+column->length- portable_sizeof_char_ptr, sizeof(char*)); break; } case FIELD_VARCHAR: { - uint pack_length= HA_VARCHAR_PACKLENGTH(rec->length-1); + uint pack_length= HA_VARCHAR_PACKLENGTH(column->length-1); if (pack_length == 1) length= (ulong) *(uchar*) buf; else @@ -48,7 +55,7 @@ ha_checksum mi_checksum(MI_INFO *info, const uchar *buf) break; } default: - length=rec->length; + length=column->length; pos=buf; break; } diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index fc5b31e7689..38e518fd823 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -108,6 +108,9 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, rec++,fields++) { reclength+=rec->length; + if (rec->null_bit) + options|= HA_OPTION_NULL_FIELDS; + if ((type=(enum en_fieldtype) rec->type) != FIELD_NORMAL && type != FIELD_CHECK) { @@ -142,6 +145,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, long_varchar_count++; pack_reclength+= 2; /* May be packed on 3 bytes */ } + options|= HA_OPTION_NULL_FIELDS; /* Use of mi_checksum() */ } else if (type != FIELD_SKIP_ZERO) { diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index b0cc2e54ca7..5ce8ec0275a 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -144,7 +144,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA | HA_OPTION_TEMP_COMPRESS_RECORD | HA_OPTION_CHECKSUM | HA_OPTION_TMP_TABLE | HA_OPTION_DELAY_KEY_WRITE | - HA_OPTION_RELIES_ON_SQL_LAYER)) + HA_OPTION_RELIES_ON_SQL_LAYER | HA_OPTION_NULL_FIELDS)) { DBUG_PRINT("error",("wrong options: 0x%lx", share->options)); my_errno=HA_ERR_OLD_FILE; @@ -737,12 +737,14 @@ void mi_setup_functions(register MYISAM_SHARE *share) { share->read_record=_mi_read_pack_record; share->read_rnd=_mi_read_rnd_pack_record; - if (!(share->options & HA_OPTION_TEMP_COMPRESS_RECORD)) - share->calc_checksum=0; /* No checksum */ - else if (share->options & HA_OPTION_PACK_RECORD) + if ((share->options & + (HA_OPTION_PACK_RECORD | HA_OPTION_NULL_FIELDS))) share->calc_checksum= mi_checksum; else share->calc_checksum= mi_static_checksum; + share->calc_check_checksum= share->calc_checksum; + if (!(share->options & HA_OPTION_TEMP_COMPRESS_RECORD)) + share->calc_checksum=0; /* No checksum */ } else if (share->options & HA_OPTION_PACK_RECORD) { @@ -752,6 +754,7 @@ void mi_setup_functions(register MYISAM_SHARE *share) share->compare_record=_mi_cmp_dynamic_record; share->compare_unique=_mi_cmp_dynamic_unique; share->calc_checksum= mi_checksum; + share->calc_check_checksum= share->calc_checksum; /* add bits used to pack data to pack_reclength for faster allocation */ share->base.pack_reclength+= share->base.pack_bits; @@ -775,7 +778,11 @@ void mi_setup_functions(register MYISAM_SHARE *share) share->update_record=_mi_update_static_record; share->write_record=_mi_write_static_record; share->compare_unique=_mi_cmp_static_unique; - share->calc_checksum= mi_static_checksum; + if (share->options & HA_OPTION_NULL_FIELDS) + share->calc_checksum= mi_checksum; + else + share->calc_checksum= mi_static_checksum; + share->calc_check_checksum= share->calc_checksum; } share->file_read= mi_nommap_pread; share->file_write= mi_nommap_pwrite; diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index fd8adeed1c5..6fb71feb1e7 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -657,10 +657,10 @@ int main(int argc, char *argv[]) sprintf((char*) key2,"%6d",k); min_key.key= key; - min_key.length= USE_WHOLE_KEY; + min_key.keypart_map= HA_WHOLE_KEY; min_key.flag= HA_READ_AFTER_KEY; max_key.key= key2; - max_key.length= USE_WHOLE_KEY; + max_key.keypart_map= HA_WHOLE_KEY; max_key.flag= HA_READ_BEFORE_KEY; range_records= mi_records_in_range(file, 0, &min_key, &max_key); records=0; diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index fde80172643..59d54bdc542 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -182,7 +182,9 @@ typedef struct st_mi_isam_share int(*delete_record) (struct st_myisam_info *); int(*read_rnd) (struct st_myisam_info *, uchar*, my_off_t, my_bool); int(*compare_record) (struct st_myisam_info *, const uchar*); - ha_checksum(*calc_checksum) (struct st_myisam_info *, const uchar*); + ha_checksum(*calc_checksum) (struct st_myisam_info *, const uchar*); + /* calculate checksum for a row during check table */ + ha_checksum(*calc_check_checksum)(struct st_myisam_info *, const uchar *); int(*compare_unique) (struct st_myisam_info *, MI_UNIQUEDEF *, const uchar *record, my_off_t pos); size_t (*file_read) (MI_INFO *, uchar *, size_t, my_off_t, myf); @@ -518,8 +520,6 @@ extern void _mi_kpointer(MI_INFO *info, uchar *buff, my_off_t pos); extern my_off_t _mi_dpos(MI_INFO *info, uint nod_flag, uchar *after_key); extern my_off_t _mi_rec_pos(MYISAM_SHARE *info, uchar *ptr); extern void _mi_dpointer(MI_INFO *info, uchar *buff, my_off_t pos); -extern int ha_key_cmp(HA_KEYSEG *keyseg, uchar *a, uchar *b, - uint key_length, uint nextflag, uint *diff_length); extern uint _mi_get_static_key(MI_KEYDEF *keyinfo, uint nod_flag, uchar **page, uchar *key); extern uint _mi_get_pack_key(MI_KEYDEF *keyinfo, uint nod_flag, uchar **page, -- cgit v1.2.1 From fc0a25ec49f32fd292cb87c8a855e1569ccf8878 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Nov 2007 17:09:51 +0100 Subject: WL#3071 Maria checkpoint, WL#3072 Maria recovery instead of fprintf(stderr) when a task (with no user connected) gets an error, use my_printf_error(). Flags ME_JUST_WARNING and ME_JUST_INFO added to my_error()/my_printf_error(), which pass it to my_message_sql() which is modified to call the appropriate sql_print_*(). This way recovery can signal its start and end with [Note] and not [ERROR] (but failure with [ERROR]). Recovery's detailed progress (percents etc) still uses stderr as they have to stay on one single line. sql_print_error() changed to use my_progname_short (nicer display). mysql-test-run.pl --gdb/--ddd does not run mysqld, because a breakpoint in mysql_parse is too late to debug startup problems; instead, dev should set the breakpoints it wants and then "run" ("r"). include/my_sys.h: new flags to tell error_handler_hook that this is not an error but an information or warning mysql-test/mysql-test-run.pl: when running with --gdb/--ddd to debug mysqld, breaking at mysql_parse is too late to debug startup problems; now, it does not run mysqld, does not set breakpoints, developer can set as early breakpoints as it wants and is responsible for typing "run" (or "r") mysys/my_init.c: set my_progname_short mysys/my_static.c: my_progname_short added sql/mysqld.cc: * my_message_sql() can now receive info or warning, not only error; this allows mysys to tell the user (or the error log if no user) about an info or warning. Used from Maria. * plugins (or engines like Maria) may want to call my_error(), so set up the error handler hook (my_message_sql) before initializing plugins; otherwise they get my_message_no_curses which is less integrated into mysqld (is just fputs()) * using my_progname_short instead of my_progname, in my_message_sql() (less space on screen) storage/maria/ma_checkpoint.c: fprintf(stderr) -> ma_message_no_user() storage/maria/ma_checkpoint.h: function for any Maria task, not connected to a user (example: checkpoint, recovery; soon could be deleted records purger) to report a message (calls my_printf_error() which, when inside ha_maria, leads to sql_print_*(), and when outside, leads to my_message_no_curses i.e. stderr). storage/maria/ma_recovery.c: To tell that recovery starts and ends we use ma_message_no_user() (sql_print_*() in practice). Detailed progress info still uses stderr as sql_print() cannot put several messages on one line. 071116 18:42:16 [Note] mysqld: Maria engine: starting recovery recovered pages: 0% 67% 100% (0.0 seconds); transactions to roll back: 1 0 (0.0 seconds); tables to flush: 1 0 (0.0 seconds); 071116 18:42:16 [Note] mysqld: Maria engine: recovery done storage/maria/maria_chk.c: my_progname_short moved to mysys storage/maria/maria_read_log.c: my_progname_short moved to mysys storage/myisam/myisamchk.c: my_progname_short moved to mysys --- storage/myisam/myisamchk.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 80159518cd0..6ddb7cb743b 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -40,7 +40,6 @@ static const char *set_collation_name, *opt_tmpdir; static CHARSET_INFO *set_collation; static long opt_myisam_block_size; static long opt_key_cache_block_size; -static const char *my_progname_short; static int stopwords_inited= 0; static MY_TMPDIR myisamchk_tmpdir; @@ -85,7 +84,6 @@ int main(int argc, char **argv) { int error; MY_INIT(argv[0]); - my_progname_short= my_progname+dirname_length(my_progname); myisamchk_init(&check_param); check_param.opt_lock_memory=1; /* Lock memory if possible */ -- cgit v1.2.1 From ebf7ab7bce003093745337be43cd6107726aa0fb Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Dec 2007 23:23:42 +0200 Subject: Added error HA_ERR_FILE_TOO_SHORT to be used when files are shorter than expected (by my_read/my_pread) Added debugger hook _my_dbug_put_break_here() that is called if we get a CRC that matches --debug-crc-break (my_crc_dbug_break) Fixed REDO_REPAIR to use all repair modes (repair, repair_by_sort, repair_paralell REDO_REPAIR now also logs used key map Fixed some bugs in REDO logging of key pages Better error messages from maria_read_log Added my_readwrite_flags to init_pagecache() to be able to get better error messages and simplify code. Don't allow pagecaches with less than 8 blocks (Causes strange crashes) Added EXTRA_DEBUG_KEY_CHANGES. When this is defined some REDO_INDEX entries contains page checksums (these are calculated and checked in DBUG mode, ignored otherwise) Fixed bug in ma_pagecache unit tests that caused program to sometimes fail Added some missing calls to MY_INIT() that caused some unit tests to fail Fixed that TRUNCATE works properly on temporary MyISAM files Updates some result files to new table checksums results (checksum when NULL fields are ignored) perl test-insert can be replayed with maria_read_log! sql/share/Makefile.am: Change mode to -rw-rw-r-- BitKeeper/etc/ignore: added storage/maria/unittest/page_cache_test_file_1 storage/maria/unittest/pagecache_debug.log include/maria.h: Added maria_tmpdir include/my_base.h: Added error HA_ERR_FILE_TOO_SHORT include/my_sys.h: Added variable my_crc_dbug_check Added function my_dbug_put_break_here() include/myisamchk.h: Added org_key_map (Needed for writing REDO record for REPAIR) mysql-test/r/innodb.result: Updated to new checksum algorithm (NULL ignored) mysql-test/r/mix2_myisam.result: Updated to new checksum algorithm (NULL ignored) mysql-test/r/myisam.result: Updated to new checksum algorithm (NULL ignored) mysql-test/t/myisam.test: Added used table mysys/checksum.c: Added DBUG for checksum results Added debugger hook so that _my_dbug_put_break_here() is called if we get matching CRC mysys/lf_alloc-pin.c: Fixed compiler warning mysys/my_handler.c: Added new error message mysys/my_init.c: If my_progname is not given, use 'unknown' form my_progname_short Added debugger function my_debug_put_break_here() mysys/my_pread.c: In case of too short file when MY_NABP or MY_FNABP is specified, give error HA_ERR_FILE_TO_SHORT mysys/my_read.c: In case of too short file when MY_NABP or MY_FNABP is specified, give error HA_ERR_FILE_TO_SHORT sql/mysqld.cc: Added debug option --debug-crc-break sql/sql_parse.cc: Trivial optimization storage/maria/ha_maria.cc: Renamed variable to be more logical Ensure that param.testflag is correct when calling repair Added extra argument to init_pagecache Set default value for maria_tempdir storage/maria/ma_blockrec.c: Test for HA_ERR_FILE_TOO_SHORT instead for -1 storage/maria/ma_cache.c: Test for HA_ERR_FILE_TOO_SHORT instead for -1 storage/maria/ma_check.c: Set param->testflag to match how repair is run (needed for REDO logging) Simple optimization Moved flag if page is node from pagelength to keypage-flag byte Log used key map in REDO log. storage/maria/ma_delete.c: Remember previous UNDO entry when writing undo (for future CLR records) Moved flag if page is node from pagelength to keypage-flag byte Fixed some bugs in redo logging Added CRC for some translog REDO_INDEX entries storage/maria/ma_dynrec.c: Test for HA_ERR_FILE_TOO_SHORT instead for -1 storage/maria/ma_ft_update.c: Fixed call to _ma_store_page_used() storage/maria/ma_key_recover.c: Added CRC for some translog REDO_INDEX entries Removed not needed pagecache_write() in _ma_apply_redo_index() storage/maria/ma_locking.c: Test for HA_ERR_FILE_TOO_SHORT instead for -1 storage/maria/ma_loghandler.c: Added used key map to REDO_REPAIR_TABLE storage/maria/ma_loghandler.h: Added operation for checksum of key pages storage/maria/ma_open.c: Allocate storage for undo lsn pointers storage/maria/ma_pagecache.c: Remove not needed include file Change logging to use fd: for file descritors as other code Added my_readwrite_flags to init_pagecache() to be able to get better error messages for maria_chk/maria_read_log Don't allow pagecaches with less than 8 blocks Remove wrong DBUG_ASSERT() storage/maria/ma_pagecache.h: Added readwrite_flags storage/maria/ma_recovery.c: Better error messages for maria_read_log: - Added eprint() for printing error messages - Print extra \n before error message if we are printing %0 %10 ... Added used key_map to REDO_REPAIR log entry More DBUG Call same repair method that was used by mysqld storage/maria/ma_rt_index.c: Moved flag if page is node from pagelength to keypage-flag byte storage/maria/ma_rt_key.c: Fixed call to _ma_store_page_used() storage/maria/ma_rt_split.c: Moved flag if page is node from pagelength to keypage-flag byte storage/maria/ma_static.c: Added maria_tmpdir storage/maria/ma_test1.c: Updated call to init_pagecache() storage/maria/ma_test2.c: Updated call to init_pagecache() storage/maria/ma_test3.c: Updated call to init_pagecache() storage/maria/ma_write.c: Removed #ifdef NOT_YET Moved flag if page is node from pagelength to keypage-flag byte Fixed bug in _ma_log_del_prefix() storage/maria/maria_chk.c: Fixed wrong min limit for page_buffer_size Updated call to init_pagecache() storage/maria/maria_def.h: Added EXTRA_DEBUG_KEY_CHANGES. When this is defined some REDO_INDEX entries contains page checksums Moved flag if page is node from pagelength to keypage-flag byte storage/maria/maria_ftdump.c: Updated call to init_pagecache() storage/maria/maria_pack.c: Updated call to init_pagecache() Reset share->state.create_rename_lsn & share->state.is_of_horizon storage/maria/maria_read_log.c: Better error messages Added --tmpdir option (needed to set temporary directory for REDO_REPAIR) Added --start-from-lsn Changed option for --display-only to 'd' (wanted to use -o for 'offset') storage/maria/unittest/lockman2-t.c: Added missing call to MY_INIT() storage/maria/unittest/ma_pagecache_consist.c: Updated call to init_pagecache() storage/maria/unittest/ma_pagecache_single.c: Fixed bug that caused program to sometimes fail Added some DBUG_ASSERTS() Changed some calls to malloc()/free() to my_malloc()/my_free() Create extra file to expose original hard-to-find bug storage/maria/unittest/ma_test_loghandler-t.c: Updated call to init_pagecache() storage/maria/unittest/ma_test_loghandler_first_lsn-t.c: Updated call to init_pagecache() storage/maria/unittest/ma_test_loghandler_max_lsn-t.c: Updated call to init_pagecache() storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Updated call to init_pagecache() storage/maria/unittest/ma_test_loghandler_multithread-t.c: Updated call to init_pagecache() storage/maria/unittest/ma_test_loghandler_noflush-t.c: Updated call to init_pagecache() storage/maria/unittest/ma_test_loghandler_pagecache-t.c: Updated call to init_pagecache() storage/maria/unittest/ma_test_loghandler_purge-t.c: Updated call to init_pagecache() storage/maria/unittest/test_file.c: Changed malloc()/free() to my_malloc()/my_free() Fixed memory leak Changd logic a bit while trying to find bug in reset_file() storage/maria/unittest/trnman-t.c: Added missing call to MY_INIT() storage/myisam/mi_cache.c: Test for HA_ERR_FILE_TOO_SHORT instead for -1 storage/myisam/mi_create.c: Removed O_EXCL to get TRUNCATE to work for temporary files storage/myisam/mi_dynrec.c: Test for HA_ERR_FILE_TOO_SHORT instead for -1 storage/myisam/mi_locking.c: Test for HA_ERR_FILE_TOO_SHORT instead for -1 mysql-test/r/old-mode.result: New BitKeeper file ``mysql-test/r/old-mode.result'' mysql-test/t/old-mode-master.opt: New BitKeeper file ``mysql-test/t/old-mode-master.opt'' mysql-test/t/old-mode.test: New BitKeeper file ``mysql-test/t/old-mode.test'' --- storage/myisam/mi_cache.c | 4 ++-- storage/myisam/mi_create.c | 2 +- storage/myisam/mi_dynrec.c | 2 +- storage/myisam/mi_locking.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_cache.c b/storage/myisam/mi_cache.c index d6dcc431a8d..1ccf038a570 100644 --- a/storage/myisam/mi_cache.c +++ b/storage/myisam/mi_cache.c @@ -97,8 +97,8 @@ int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length, DBUG_PRINT("error", ("Error %d reading next-multi-part block (Got %d bytes)", my_errno, (int) read_length)); - if (!my_errno || my_errno == -1) - my_errno=HA_ERR_WRONG_IN_RECORD; + if (!my_errno || my_errno == -1 || my_errno == HA_ERR_FILE_TOO_SHORT) + my_errno= HA_ERR_WRONG_IN_RECORD; DBUG_RETURN(1); } bzero(buff+read_length,MI_BLOCK_INFO_HEADER_LENGTH - in_buff_length - diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 38e518fd823..23f84819949 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -185,7 +185,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (flags & HA_CREATE_TMP_TABLE) { options|= HA_OPTION_TMP_TABLE; - create_mode|= O_EXCL | O_NOFOLLOW; + create_mode|= O_NOFOLLOW; } if (flags & HA_CREATE_CHECKSUM || (options & HA_OPTION_CHECKSUM)) { diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 2a12fd04641..0811de2b968 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -1764,7 +1764,7 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, uchar *buf, /* VOID(my_seek(info->dfile,filepos,MY_SEEK_SET,MYF(0))); */ if (my_read(info->dfile,(uchar*) to,block_info.data_len,MYF(MY_NABP))) { - if (my_errno == -1) + if (my_errno == HA_ERR_FILE_TOO_SHORT) my_errno= HA_ERR_WRONG_IN_RECORD; /* Unexpected end of file */ goto err; } diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index 2d89fce2a81..ad23a42ab83 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -429,10 +429,10 @@ int _mi_readinfo(register MI_INFO *info, int lock_type, int check_keybuffer) DBUG_RETURN(1); if (mi_state_info_read_dsk(share->kfile, &share->state, 1)) { - int error=my_errno ? my_errno : -1; + int error= my_errno ? my_errno : HA_ERR_FILE_TOO_SHORT; VOID(my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF, MYF(MY_SEEK_NOT_DONE))); - my_errno=error; + my_errno= error; DBUG_RETURN(1); } } -- cgit v1.2.1 From bcf526b72a540447940ca021750614c1fff15b79 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 Dec 2007 13:28:35 +0100 Subject: fixes for make distclean, solaris, macosx, windows BitKeeper/deleted/.del-plug.in: Delete: storage/myisam/plug.in configure.in: MyISAM should be the first plugin in the list for now check for thr_yield, just in case include/my_pthread.h: pthread_yield for windows, solaris, macosx storage/Makefile.am: fix for make distclean (myisam was listed twice in SUBDIRS) --- storage/myisam/plug.in | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 storage/myisam/plug.in (limited to 'storage/myisam') diff --git a/storage/myisam/plug.in b/storage/myisam/plug.in deleted file mode 100644 index 051ec2d54aa..00000000000 --- a/storage/myisam/plug.in +++ /dev/null @@ -1,7 +0,0 @@ -MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine], - [Traditional non-transactional MySQL tables]) -MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam]) -MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a]) -MYSQL_PLUGIN_MANDATORY(myisam) dnl Default -MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc]) - -- cgit v1.2.1 From 92fe98d7d7df522f1913b74e0c74d2319234ef3d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 Dec 2007 14:48:50 +0100 Subject: restore plug.in - referenced by Makefile.am --- storage/myisam/plug.in | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 storage/myisam/plug.in (limited to 'storage/myisam') diff --git a/storage/myisam/plug.in b/storage/myisam/plug.in new file mode 100644 index 00000000000..e92b5e56d7f --- /dev/null +++ b/storage/myisam/plug.in @@ -0,0 +1,7 @@ +dnl MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine], +dnl [Traditional non-transactional MySQL tables]) +dnl MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam]) +dnl MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a]) +dnl MYSQL_PLUGIN_MANDATORY(myisam) dnl Default +dnl MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc]) + -- cgit v1.2.1 From be71f3ccb61d3c4f1ebc096ba4e5e1563f578681 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 16 Dec 2007 20:37:22 +0200 Subject: Fixed after-merge problems. --- storage/myisam/mi_check.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 4ba84ab6ca8..a3a92f345e1 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1429,7 +1429,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info,int extend) then recrate all indexes. */ -static int mi_drop_all_indexes(MI_CHECK *param, MI_INFO *info, my_bool force) +static int mi_drop_all_indexes(HA_CHECK *param, MI_INFO *info, my_bool force) { MYISAM_SHARE *share= info->s; MI_STATE_INFO *state= &share->state; @@ -2671,14 +2671,14 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, /* Quick repair (not touching data file, rebuilding indexes): { - Read cache is (MI_CHECK *param)->read_cache using info->dfile. + Read cache is (HA_CHECK *param)->read_cache using info->dfile. } Non-quick repair (rebuilding data file and indexes): { Master thread: - Read cache is (MI_CHECK *param)->read_cache using info->dfile. + Read cache is (HA_CHECK *param)->read_cache using info->dfile. Write cache is (MI_INFO *info)->rec_cache using new_file. Slave threads: -- cgit v1.2.1 From cc589bef15c16b48cd5715645abb545df284fb5a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Dec 2007 01:17:37 +0200 Subject: Fixed bug in undo_key_delete; Caused crashed key files in recovery Maria is now used for internal temporary tables in MySQL Better usage of VARCHAR and long strings in temporary tables Use packed fields if BLOCK_RECORD is used null_bytes are not anymore stored in a separate field New interface to remember and restore scan position Fixed bugs in unique handling Don't sync Maria temporary tables Lock control file while it's used to stop several processes from using it Changed value of MA_DONT_OVERWRITE_FILE as it collided with MY_SYNC_DIR Split MY_DONT_WAIT into MY_NO_WAIT and MY_SHORT_WAIT (for my_lock()) Added MY_FORCE_LOCK include/my_sys.h: Changed value of MA_DONT_OVERWRITE_FILE as it collided with MY_SYNC_DIR Split MY_DONT_WAIT into MY_NO_WAIT and MY_SHORT_WAIT (for my_lock()) Added MY_FORCE_LOCK include/myisam.h: Make MyISAM columndef compile time compatible with Maria mysql-test/lib/mtr_process.pl: Removed confusing warning (It's common that there is a lot of other files than pid files) mysql-test/mysql-test-run.pl: Added --sync-frm to speed up tests mysql-test/r/maria-recovery.result: Updated results from wrong push mysql-test/suite/rpl/t/rpl_innodb_bug28430.test: Marked test as --big mysys/my_lock.c: If MY_FORCE_LOCK is given, use locking even if my_disable_locking is given If MY_NO_WAIT is given, return at once if lock is occupied If MY_SHORT_WAIT is given, wait some time for lock before returning (This was called MY_DONT_WAIT before) mysys/my_thr_init.c: Fix that we don't give name to thread before it's properly initied sql/handler.cc: Added myisam.h sql/handler.h: Changes to use Maria for internal temporary tables Removed not needed argument to restart_rnd_next() Added function remember_rnd_pos() sql/my_lock.c: If MY_FORCE_LOCK is given, use locking even if my_disable_locking is given If MY_NO_WAIT is given, return at once if lock is occupied If MY_SHORT_WAIT is given, wait some time for lock before returning (This was called MY_DONT_WAIT before) sql/mysql_priv.h: Added maria_hton sql/sql_class.h: Changes to use Maria for internal temporary tables sql/sql_select.cc: Changes to use Maria for internal temporary tables Temporary tables didn't properly switch to dynamic row format if long strings was used Better usage of VARCHAR in temporary tables Use new interface to restart scan in duplicate removal sql/sql_select.h: Changes to use Maria for internal temporary tables sql/sql_show.cc: Changes to use Maria for internal temporary tables Removed all end space sql/sql_table.cc: Set HA_OPTION_PACK_RECORD if we are not using default or static record sql/sql_union.cc: If MY_FORCE_LOCK is given, use locking even if my_disable_locking is given If MY_NO_WAIT is given, return at once if lock is occupied If MY_SHORT_WAIT is given, wait some time for lock before returning (This was called MY_DONT_WAIT before) sql/sql_update.cc: If MY_FORCE_LOCK is given, use locking even if my_disable_locking is given If MY_NO_WAIT is given, return at once if lock is occupied If MY_SHORT_WAIT is given, wait some time for lock before returning (This was called MY_DONT_WAIT before) storage/maria/ha_maria.cc: Use packed fields null_bytes are not anymore stored in a separate field Changes to use Maria for internal temporary tables Give warning if we try to do an ALTER TABLE to a unusable row format storage/maria/ha_maria.h: Allow Maria with block format to restart scanning at given position storage/maria/ma_blockrec.c: Added functions to remember and restore scan position Allocate cur_row.extents so that we don't have to do a malloc on first read Fixed bug when using packed row without packed strings Removed unneeded calls to free_full_pages() Fixed unlikely bug when using old bitmap to read head page and head page had gone away Remember row position when doing undo of delete and update row (needed for undo of key delete) storage/maria/ma_blockrec.h: Added functions to remember and restore scan position storage/maria/ma_close.c: Don't sync temporary tables storage/maria/ma_control_file.c: Lock control file while it's used to stop several processes from using it storage/maria/ma_create.c: Fixed bug when using FIELD_NORMAL that was longer than FULL_PAGE_SIZE Fixed bug that casued fields to not be ordered according to offset Fixed bug in unique creation storage/maria/ma_delete.c: Don't write record reference when deleting key. (Rowid is likely to be different when we undo this) storage/maria/ma_dynrec.c: Fixed core dump when comparing records (happended in unique handling) storage/maria/ma_extra.c: MY_DONT_WAIT -> MY_SHORT_WAIT Removed TODO comment. (Was not relevant as all other instances are guranteed to be closed when we the code is excecuted) Added DBUG_ASSERT() to prove above. storage/maria/ma_key_recover.c: CLR's for UNDO_ROW_DELETE and UNDO_ROW_UPDATE now include rowid for the row. This was needed for undo_key_delete to work, as undo of delete row is likely to put row in a new position. undo_delete_key now doesn't include row position storage/maria/ma_open.c: Added virtual functions for remembering and restoring scan position Fixed wrong key search method when using multi-byte character sets (Bug#32705) Store original column number in index file NOTE: Index files are now incompatible with previous versions! (Ok as we haven't yet made a public Maria release) storage/maria/ma_recovery.c: Set info->cur_row.lastpos when reading CLR's for UNDO_ROW_DELETE or UNDO_ROW_UPDATE storage/maria/ma_scan.c: Added default function to remember and restore scan position storage/maria/maria_def.h: Added virtual functions & variables to remember and restore scan position Added MARIA_MAX_CONTROL_FILE_LOCK_RETRY storage/myisam/ha_myisam.cc: Fixed compiler errors as columdef->type is now an enum, not an integer Added functions to remember and restore scan position storage/myisam/ha_myisam.h: Added functions to remember and restore scan position storage/myisam/mi_check.c: MY_DONT_WAIT -> MY_SHORT_WAIT storage/myisam/mi_extra.c: MY_DONT_WAIT -> MY_SHORT_WAIT storage/myisam/mi_open.c: MY_DONT_WAIT -> MY_SHORT_WAIT storage/myisam/myisamdef.h: MY_DONT_WAIT -> MY_SHORT_WAIT --- storage/myisam/ha_myisam.cc | 32 +++++++++++++++++++------------- storage/myisam/ha_myisam.h | 3 ++- storage/myisam/mi_check.c | 2 +- storage/myisam/mi_extra.c | 2 +- storage/myisam/mi_open.c | 2 +- storage/myisam/myisamdef.h | 2 +- 6 files changed, 25 insertions(+), 18 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 5e58565364c..4aea0ebee98 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -255,28 +255,28 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, { /* reserve space for null bits */ bzero((char*) recinfo_pos, sizeof(*recinfo_pos)); - recinfo_pos->type= (int) FIELD_NORMAL; + recinfo_pos->type= FIELD_NORMAL; recinfo_pos++->length= (uint16) (minpos - recpos); } if (!found) break; if (found->flags & BLOB_FLAG) - recinfo_pos->type= (int) FIELD_BLOB; + recinfo_pos->type= FIELD_BLOB; else if (found->type() == MYSQL_TYPE_VARCHAR) recinfo_pos->type= FIELD_VARCHAR; else if (!(options & HA_OPTION_PACK_RECORD)) - recinfo_pos->type= (int) FIELD_NORMAL; + recinfo_pos->type= FIELD_NORMAL; else if (found->zero_pack()) - recinfo_pos->type= (int) FIELD_SKIP_ZERO; + recinfo_pos->type= FIELD_SKIP_ZERO; else - recinfo_pos->type= (int) ((length <= 3 || - (found->flags & ZEROFILL_FLAG)) ? - FIELD_NORMAL : - found->type() == MYSQL_TYPE_STRING || - found->type() == MYSQL_TYPE_VAR_STRING ? - FIELD_SKIP_ENDSPACE : - FIELD_SKIP_PRESPACE); + recinfo_pos->type= ((length <= 3 || + (found->flags & ZEROFILL_FLAG)) ? + FIELD_NORMAL : + found->type() == MYSQL_TYPE_STRING || + found->type() == MYSQL_TYPE_VAR_STRING ? + FIELD_SKIP_ENDSPACE : + FIELD_SKIP_PRESPACE); if (found->null_ptr) { recinfo_pos->null_bit= found->null_bit; @@ -1675,9 +1675,15 @@ int ha_myisam::rnd_next(uchar *buf) return error; } -int ha_myisam::restart_rnd_next(uchar *buf, uchar *pos) +int ha_myisam::remember_rnd_pos() { - return rnd_pos(buf,pos); + position((uchar*) 0); + return 0; +} + +int ha_myisam::restart_rnd_next(uchar *buf) +{ + return rnd_pos(buf, ref); } int ha_myisam::rnd_pos(uchar *buf, uchar *pos) diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 96440b74c9d..74780abf42b 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -94,7 +94,8 @@ class ha_myisam: public handler int rnd_init(bool scan); int rnd_next(uchar *buf); int rnd_pos(uchar * buf, uchar *pos); - int restart_rnd_next(uchar *buf, uchar *pos); + int remember_rnd_pos(); + int restart_rnd_next(uchar *buf); void position(const uchar *record); int info(uint); int extra(enum ha_extra_function operation); diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 152ffd3bb55..c07ed3424d2 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -2028,7 +2028,7 @@ int lock_file(HA_CHECK *param, File file, my_off_t start, int lock_type, { if (my_lock(file,lock_type,start,F_TO_EOF, param->testflag & T_WAIT_FOREVER ? MYF(MY_SEEK_NOT_DONE) : - MYF(MY_SEEK_NOT_DONE | MY_DONT_WAIT))) + MYF(MY_SEEK_NOT_DONE | MY_SHORT_WAIT))) { mi_check_print_error(param," %d when locking %s '%s'",my_errno,filetype,filename); param->error_printed=2; /* Don't give that data is crashed */ diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 33c9d1210ca..d798ef50d7e 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -216,7 +216,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) info->lock_wait=0; break; case HA_EXTRA_NO_WAIT_LOCK: - info->lock_wait=MY_DONT_WAIT; + info->lock_wait= MY_SHORT_WAIT; break; case HA_EXTRA_NO_KEYS: if (info->lock_type == F_UNLCK) diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 5ce8ec0275a..3e877513098 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -180,7 +180,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) { if ((lock_error=my_lock(kfile,F_RDLCK,0L,F_TO_EOF, MYF(open_flags & HA_OPEN_WAIT_IF_LOCKED ? - 0 : MY_DONT_WAIT))) && + 0 : MY_SHORT_WAIT))) && !(open_flags & HA_OPEN_IGNORE_IF_LOCKED)) goto err; } diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 59d54bdc542..64c1a8214c3 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -284,7 +284,7 @@ struct st_myisam_info LIST open_list; IO_CACHE rec_cache; /* When cacheing records */ uint preload_buff_size; /* When preloading indexes */ - myf lock_wait; /* is 0 or MY_DONT_WAIT */ + myf lock_wait; /* is 0 or MY_SHORT_WAIT */ my_bool was_locked; /* Was locked in panic */ my_bool append_insert_at_end; /* Set if concurrent insert */ my_bool quick_mode; -- cgit v1.2.1 From bfd5c273c4fb16396279a8a7b396a6558e5a59b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 30 Dec 2007 22:40:03 +0200 Subject: UNDO of rows now puts back all part of the row on their original pages and positions Added variable _dbug_on_ to speed up execution when DBUG is not going to be used Added --debug-on option to mysqld (to be able to turn of DBUG with --debug-on=0) Fixed some bugs with 'non_flushable' marking of bitmap pages Don't use 'non_flushable' marking of bitmap pages for not transactional tables SHOW CREATE TABLE now shows if table was created with page checksums Fixed a lot of bugs with BLOB handling in case of update/REDO and UNDO More tests (especially for blobs) and DBUG_ASSERTS() More readable output from maria_read_log and maria_chk Fixed wrong shift that caused Maria to crash on files > 4G Mark tables as crashed of REDO fails dbug/dbug.c: Changed to use my_bool (allowed me to remove some windows specific code) Added variable _dbug_on_ to speed up execution when DBUG is not going to be used Removed initialization of variables if not needed include/my_dbug.h: Use my_bool for some functions that was defined as BOOLEAN in dbug.c code Added DBUGGER_ON/DEBUGGER_OFF to speed up execution when DBUG is not used include/my_global.h: Define my_bool early Increase MY_HOW_OFTEN_TO_WRITE as computers are now faster than 10 years ago mysql-test/mysql-test-run.pl: Added debug-on=0 to speed up tests mysql-test/r/maria-recovery.result: Added new test by Guilhem to test if UNDO_ROW_DELETE preserves rowid mysql-test/r/maria.result: Added testing of page checksums mysql-test/t/crash_commit_before-master.opt: Added --debug-on as test require DBUG to work mysql-test/t/maria-recovery-bitmap-master.opt: Added --debug-on as test require DBUG to work mysql-test/t/maria-recovery-master.opt: Added --debug-on as test require DBUG to work mysql-test/t/maria-recovery.test: Added new test by Guilhem to test if UNDO_ROW_DELETE preserves rowid mysql-test/t/maria.test: Added testing of page checksums sql/mysqld.cc: Added --debug-on option (to be able to turn of DBUG with --debug-on=0) Indentation fixes Removed end spaces sql/sql_show.cc: Allow update_create_info() to inform MySQL if PACK_KEYS, NO_PACK_KEYS, CHECKSUM, PAGE_CHECKSUM or DELAY_KEY_WRITE is used storage/maria/Makefile.am: Added ma_test_big.sh storage/maria/ha_maria.cc: Store in create_info if page checksums are used (For SHOW CREATE TABLE) storage/maria/ma_bitmap.c: Added _ma_bitmap_wait_or_flush() to cause reader of bitmap pages to wait with reading until bitmap is flushed. Use TAIL_PAGE_COUNT_MARKER for tail pages Set 'sub_blocks' for and only for the head page or for the first extent of a blob. This is needed for store_extent_info() to be able to set START_EXTENT_BIT's Don't allocate more than 0x3ffff pages in one extent (We need bit 0x4000 as a START_EXTENT_BIT) Increase the calculated 'head_length' with the number of bytes used for extents. Update row->space_on_head_page also in _ma_bitmap_find_new_place() Make _ma_bitmap_get_page_bits() global. (Needed for UNDO handling) Changed _ma_bitmap_flushable() to take MARIA_HA instead of MARIA_SHARE. This was needed to be able to mark the handler if we had a 'non_flushable' call pending or not. Don't use 'non_flushable' marking of bitmap pages for not transactional tables. Added BLOCKUSED_USE_ORG_BITMAP handling also for tail pages. Added more DBUG_ASSERT() to find possible errors in other code Some code simplications by adding new local variables storage/maria/ma_blockrec.c: UNDO of rows now puts back all part of the row on their original pages and positions. Changed UNDO of DELETE and UNDO of UPDATE to contain information about the original length of data on head block and also extent information This changes a lot of logic as now an insert of a row on a page may happen to any position (and not just to the first or next free) Use PAGE_COUNT to mark if an extent is the start of of a blob. (Needed for extent_to_bitmap_blocks()) Added check_directory() for checking that directroy entries are correct. Added checking of row checksums when reading rows (with EXTRA_DEBUG) Added make_space_for_directory() and extend_directory() for doing expansion of directory Added get_rowpos_in_head_or_tail_page() to be able to store head/tail on original position in UNDO Added extent_to_bitmap_blocks() to be able to generate original bitmap blocks from UNDO entry Added _ma_update_at_original_place() for UNDO of DELETES Added row->min_length to hold minmum required space needed on head page Changed find_free_position() to use make_space_for_directory() Changed make_empty_page() to allow optional creation of directory entry Changed delete_head_or_tail() and _ma_apply_undo_row_isnert() to not copy pagecache block (speed optimization) Changed _ma_apply_redo_insert_row_head_or_tail() to be able to insert new row at any position on 'new' page Changed _ma_apply_undo_row_delete() and _ma_apply_undo_row_update() to put row in it's original position Ensure allocation of tail blocks are of at least MIN_TAIL_SIZE. Ensure we store pages in pinned pages even if read failed. (If not we will have pages pinned forever in page cache) Write original extent information in UNDO entry, not compacted ones (we need position to tails!) When setting BLOCKUSED_USED, don't clear other bits (we have to preserve BLOCKUSED_USE_ORG_BITMAP) Fixed som bugs in directory handling Fixed bug where we wrote wrong lsn to blob pages Added separate blob_buffer for fixing bug when updating row that had char/varchar that spanned several pages and also had blobs Ensure we call _ma_bitmap_flushable() also in case of errors When doing an update, first delete old entries, then search in bitmap for where to put new information Info->s -> share Rowid -> rowid More DBUG_ASSERT() storage/maria/ma_blockrec.h: Added START_EXTENT_BIT and TAIL_PAGE_COUNT_MARKER Added _ma_bitmap_wait_or_flush() and _ma_bitmap_get_page_bits() storage/maria/ma_check.c: Don't write extra empty line if there is no deleted blocks Ignore START_EXTENT_BIT's in page count Call _ma_fast_unlock_key_del() to free key_del link storage/maria/ma_close.c: Ensure that used_key_del is 0. (If not, someone forgot to call _ma_unlock_key_del()) storage/maria/ma_create.c: Changed constant to macro storage/maria/ma_delete.c: For deleted keys, log also position to row storage/maria/ma_extra.c: Release blob buffer at maria_reset() if bigger than MARIA_SMALL_BLOB_BUFFER storage/maria/ma_key_recover.c: Added bzero() of LSN that confused paged cache in case of uninitialized block Mark file crashed if applying of index changes fails Added calls to _ma_fast_unlock_key_del() for protection of shared key_del link. storage/maria/ma_locking.c: Added usage of MARIA_FILE_OPEN_COUNT_OFFSET Added _ma_mark_file_crashed() storage/maria/ma_loghandler.c: Fixed bug where we logged uninitialized memory storage/maria/ma_open.c: Moved state->changed to be at start of state info on disk to allow one to easly mark files as crashed storage/maria/ma_page.c: Disable 'dummy' checksumming of pages as this gave false warnings. (Need to investigate if this is ever needed) storage/maria/ma_pagecache.c: Fixed wrong shift that caused Maria to crash on files > 4G storage/maria/ma_recovery.c: In case of errors, start writing on new line if we where in %## %## printing mode (Made errors more readable) Changed global variable name from warnings -> recovery_warnings Use MARIA_FILE_CREATE_RENAME_LSN_OFFSET instead of constant Removed special handling of row position for deleted keys. Keys now always includes row positions _ma_apply_undo_row_delete() now gets page and row position Added check that we don't loop forever when handling undo's (in case of bug in undo chain) Print name of failed REDO/UNDO storage/maria/ma_recovery.h: Removed old comment storage/maria/ma_static.c: Chaned version number of Maria files to not accidently use old ones (becasue of change of ordering of status variables) storage/maria/ma_test2.c: Added option -u to specify number of rows to update Changed old option -u to be -A, as for ma_test1 Fixed bug in update of rows with blobs (before blobs was always reset to empty on update) First created blob is now of max blob length to ensure we have at least one big blob in the table storage/maria/ma_test_all.sh: More tests storage/maria/ma_test_recovery.expected: Updated results storage/maria/ma_test_recovery: Changed tests to use bigger blobs (not just 1K) Added new tests that tests recovery of update with blobs Removed comparision of .MAD file as it's not guranteed that recovery from scratch gives identical data file as original update (compact_page() may be called at different times during normal execution and during REDO) storage/maria/ma_update.c: Simplify code (changed * to if) storage/maria/maria_chk.c: Make output more readable storage/maria/maria_def.h: Changed 'changed' to int to prepare for more bits Added 2 more bytes to status information Added 'st_mara_row->min_length' for storing min length needed on head page Added 'st_mara_handler->blob_buff & blob_buff_size' for storing blobs Moved all tunning parameters into one block Added MARIA_SMALL_BLOB_BUFFER Added _ma_mark_file_crashed() storage/myisam/mi_test2.c: Fixed bug in update of rows with blobs (before blobs was always reset to empty on update) storage/maria/ma_test_big.sh: Testing of insert, update, delete, recovery and undo of rows with blobs Thanks to the random-ness of ma_test2 this is likely to find most bugs in the row handling --- storage/myisam/mi_test2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 6fb71feb1e7..e75a09702ce 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -334,9 +334,9 @@ int main(int argc, char *argv[]) if (use_blob) { if (i & 1) - put_blob_in_record(record+blob_pos,&blob_buffer); + put_blob_in_record(record2+blob_pos,&blob_buffer); else - bmove(record+blob_pos,read_record+blob_pos,8); + bmove(record2+blob_pos,read_record+blob_pos,8); } if (mi_update(file,read_record,record2)) { -- cgit v1.2.1 From ce8de7afdffd46507f000048a17722f81eec7688 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jan 2008 13:21:53 +0100 Subject: Windows fixes -new option WITH_MARIA_STORAGE_ENGINE for config.js -correct build errors -build test executables -downport changes for atomic functions from 5.2 -remove LOCK_uuid_generator from C++ files to avoid linker errors -new function my_uuid2str() BitKeeper/deleted/.del-x86-msvc.h: Delete: include/atomic/x86-msvc.h CMakeLists.txt: Windows fixes: -New option WITH_MARIA_STORAGE_ENGINE -Add unit tests include/Makefile.am: replace x86-msvc.h with generic-msvc.h include/config-win.h: my_chmod() support include/my_atomic.h: Downport my_atomic from 5.2 tree include/my_bit.h: Correct unresolved symbol errors on Windows include/my_pthread.h: pthread_mutex_unlock now returns 0 (was void previously) defined PTHREAD_STACK_MIN include/my_sys.h: New function my_uuid2str() define MY_UUID_STRING_LENGTH include/atomic/nolock.h: Downport my_atomic from 5.2 tree libmysqld/CMakeLists.txt: New option WITH_MARIA_STORAGE_ENGINE mysys/CMakeLists.txt: Add missing files mysys/lf_dynarray.c: Fix compiler errors on Windows mysys/my_getncpus.c: Windows port mysys/my_uuid.c: Windows fixes: there is no random() on Windows, use ANSI rand() New function my_uuid2str() mysys/my_winthread.c: Downport from 5.2 tree -Call my_thread_end() before pthread_exit() -Avoid crash if pthread_create is called with NULL attributes sql/CMakeLists.txt: Link mysqld with Maria storage engine sql/item_func.cc: Remove LOCK_uuid_generator from C++ to avoid linker errors. Use dedicated mutex for short uuids sql/item_strfunc.cc: Use my_uuid() and my_uuid2str() functions from mysys. sql/item_strfunc.h: Define MY_UUID_STRING_LENGTH in my_sys.h sql/mysql_priv.h: LOCK_uuid_generator must be declared as extern "C" sql/mysqld.cc: Init and destroy LOCK_uuid_short mutex storage/maria/CMakeLists.txt: -Use the same source files as in Makefile.am -Build test binaries storage/maria/ha_maria.cc: snprintf->my_snprintf storage/maria/lockman.c: Fix compiler error on Windows storage/maria/ma_check.c: Fix compiler error on Windows storage/maria/ma_loghandler.c: Fix compile errors my_open()/my_sync() do not work for directories on Windows storage/maria/ma_recovery.c: Fix compile error on Windows storage/maria/ma_test2.c: Rename variable to avoid naming conflict with Microsoft C runtime function storage/maria/ma_test3.c: Fix build errors on Windows storage/maria/tablockman.c: Fix build errors on Windows storage/maria/unittest/Makefile.am: Add CMakeLists.txt storage/maria/unittest/ma_pagecache_consist.c: Fix build errors on Windows remove loop from get_len() storage/maria/unittest/ma_pagecache_single.c: Fix build errors on Windows storage/maria/unittest/ma_test_loghandler-t.c: Windows fixes -Avoid division by 0 in expressions like x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows) storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Windows fixes -Avoid division by 0 in expressions like x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows) -remove loop in get_len() storage/maria/unittest/ma_test_loghandler_multithread-t.c: Windows fixes -Avoid division by 0 in expressions like x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows) -remove loop in get_len() storage/maria/unittest/ma_test_loghandler_noflush-t.c: Fix build errors on Windows storage/maria/unittest/test_file.c: Correct the code to get file size on Windows. stat() information can be outdated and thus cannot be trusted. On Vista,stat() returns file size=0 until the file is closed at the first time. storage/myisam/CMakeLists.txt: Fix compiler errors on Windows Build test executables storage/myisam/mi_test2.c: Rename variable to avoid naming conflict with Microsoft C runtime function storage/myisam/mi_test3.c: Fix build errors on Windows strings/CMakeLists.txt: Add missing file unittest/unit.pl: Windows: downport unittest changes from 5.2 bk tree unittest/mysys/Makefile.am: Windows: downport unittest changes from 5.2 bk tree unittest/mysys/my_atomic-t.c: Windows: downport unittest changes from 5.2 bk tree unittest/mytap/Makefile.am: Windows: downport unittest changes from 5.2 bk tree unittest/mytap/tap.c: Windows: downport unittest changes from 5.2 bk tree win/configure.js: Add WITH_MARIA_STORAGE_ENGINE configure option unittest/mytap/CMakeLists.txt: Add missing file unittest/mysys/CMakeLists.txt: Add missing file storage/maria/unittest/CMakeLists.txt: Add missing file BitKeeper/etc/ignore: Added comments maria-win.patch to the ignore list include/atomic/generic-msvc.h: Implement atomic operations with MSVC intrinsics --- storage/myisam/CMakeLists.txt | 16 ++++++++++++++++ storage/myisam/mi_test2.c | 12 ++++++------ storage/myisam/mi_test3.c | 10 +++++----- 3 files changed, 27 insertions(+), 11 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt index 9d91bf0560a..3d1fb4ba583 100755 --- a/storage/myisam/CMakeLists.txt +++ b/storage/myisam/CMakeLists.txt @@ -24,6 +24,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib SET(MYISAM_SOURCES ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c ft_stem.c ha_myisam.cc + ft_myisam.c ft_stopwords.c ft_update.c mi_cache.c mi_changed.c mi_check.c mi_checksum.c mi_close.c mi_create.c mi_dbug.c mi_delete.c mi_delete_all.c mi_delete_table.c mi_dynrec.c mi_extra.c mi_info.c @@ -50,6 +51,21 @@ IF(NOT SOURCE_SUBLIBS) ADD_EXECUTABLE(myisampack myisampack.c) TARGET_LINK_LIBRARIES(myisampack myisam mysys debug dbug strings zlib wsock32) + ADD_EXECUTABLE(mi_test1 mi_test1.c) + TARGET_LINK_LIBRARIES(mi_test1 myisam mysys debug dbug strings zlib wsock32) + + ADD_EXECUTABLE(mi_test2 mi_test2.c) + TARGET_LINK_LIBRARIES(mi_test2 myisam mysys debug dbug strings zlib wsock32) + + ADD_EXECUTABLE(mi_test3 mi_test3.c) + TARGET_LINK_LIBRARIES(mi_test3 myisam mysys debug dbug strings zlib wsock32) + + ADD_EXECUTABLE(sp_test sp_test.c) + TARGET_LINK_LIBRARIES(sp_test myisam mysys debug dbug strings zlib wsock32) + + ADD_EXECUTABLE(rt_test rt_test.c) + TARGET_LINK_LIBRARIES(rt_test myisam mysys debug dbug strings zlib wsock32) + IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker") MYSQL_EMBED_MANIFEST("myisamchk" "asInvoker") diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index e75a09702ce..5804af736df 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -43,7 +43,7 @@ static void copy_key(struct st_myisam_info *info,uint inx, uchar *record,uchar *key); static int verbose=0,testflag=0, - first_key=0,async_io=0,key_cacheing=0,write_cacheing=0,locking=0, + first_key=0,async_io=0,key_cacheing=0,write_cacheing=0,do_locking=0, rec_pointer_size=0,pack_fields=1,use_log=0,silent=0, opt_quick_mode=0; static int pack_seg=HA_SPACE_PACK,pack_type=HA_PACK_KEY,remove_count=-1, @@ -222,7 +222,7 @@ int main(int argc, char *argv[]) printf("- Writing key:s\n"); if (key_cacheing) init_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size,0,0); - if (locking) + if (do_locking) mi_lock_database(file,F_WRLCK); if (write_cacheing) mi_extra(file,HA_EXTRA_WRITE_CACHE,0); @@ -713,7 +713,7 @@ int main(int argc, char *argv[]) printf("- mi_extra(CACHE) + mi_rrnd.... + mi_extra(NO_CACHE)\n"); if (mi_reset(file) || mi_extra(file,HA_EXTRA_CACHE,0)) { - if (locking || (!use_blob && !pack_fields)) + if (do_locking || (!use_blob && !pack_fields)) { puts("got error from mi_extra(HA_EXTRA_CACHE)"); goto end; @@ -833,9 +833,9 @@ end: puts("Write cacheing used"); if (write_cacheing) puts("quick mode"); - if (async_io && locking) + if (async_io && do_locking) puts("Asyncron io with locking used"); - else if (locking) + else if (do_locking) puts("Locking used"); if (use_blob) puts("blobs used"); @@ -904,7 +904,7 @@ static void get_options(int argc, char **argv) use_log=1; break; case 'L': - locking=1; + do_locking=1; break; case 'A': /* use asyncron io */ async_io=1; diff --git a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c index 5bdc33b8518..93f2b10fd3e 100644 --- a/storage/myisam/mi_test3.c +++ b/storage/myisam/mi_test3.c @@ -15,7 +15,7 @@ /* Test av locking */ -#ifndef __NETWARE__ +#if !(defined (__NETWARE_) || defined (_WIN32)) /*no fork() in Windows*/ #include "myisam.h" #include @@ -488,14 +488,14 @@ int test_update(MI_INFO *file,int id,int lock_type) return 0; } -#else /* __NETWARE__ */ +#else /* __NETWARE__ || __WIN__*/ #include -main() +int main() { - fprintf(stderr,"this test has not been ported to NetWare\n"); + fprintf(stderr,"this test has not been ported to NetWare or Windows\n"); return 0; } -#endif /* __NETWARE__ */ +#endif /* __NETWARE__ || __WIN__ */ -- cgit v1.2.1 From 5ad477f6cb765025ce240a47b71532bb7e5f286b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jan 2008 21:21:36 +0200 Subject: Added --with-maria-tmp-tables (default one) to allow on to configure if Maria should be used for internal temporary tables Abort mysqld if Maria engine didn't start and we are using Maria for temporary tables Fixed bug that caused update of big blobs to crash Use pagecache_page_no_t as type for pages (to get rid of compiler warnings) Added cast to get rid of compiler warning Fixed wrong types of variables and arguments that caused lost information Fixed wrong DBUG_ASSERT() that caused REDO of big blobs to fail Removed some historical ifdefs that caused problem with windows compilations BUILD/SETUP.sh: Added --with-maria-tmp-tables include/maria.h: Use pagecache_page_no_t as type for pages Use my_bool as parameter for 'rep_quick' option include/my_base.h: Added comment mysql-test/r/maria-big.result: Added test that uses big blobs mysql-test/t/maria-big.test: Added test that uses big blobs sql/mysqld.cc: Abort mysqld if Maria engine didn't start and we are using Maria for temporary tables sql/sql_class.h: Don't use Maria for temporary tables if --with-maria-tmp-tables is not defined sql/sql_select.cc: Don't use Maria for temporary tables if --with-maria-tmp-tables is not defined storage/maria/ha_maria.cc: Fixed compiler warnings reported by MCC - Fixed usage of wrong types that caused data loss - Changed parameter for rep_quick to my_bool - Added safe casts Fixed indentation storage/maria/ma_bitmap.c: Use pagecache_page_no_t as type for pages Fixed compiler warnings Fixed bug that caused update of big blobs to crash storage/maria/ma_blockrec.c: Use pagecache_page_no_t as type for pages Use my_bool as parameter for 'rep_quick' option Fixed compiler warnings Fixed wrong DBUG_ASSERT() storage/maria/ma_blockrec.h: Use pagecache_page_no_t as type for pages storage/maria/ma_check.c: Fixed some wrong parameters where we didn't get all bits for test_flag Changed rep_quick to be of type my_bool Use pagecache_page_no_t as type for pages Added cast's to get rid of compiler warnings Changed type of record_pos to get rid of compiler warning storage/maria/ma_create.c: Added safe cast's to get rid of compiler warnings storage/maria/ma_dynrec.c: Fixed usage of wrong type storage/maria/ma_key.c: Fixed compiler warning storage/maria/ma_key_recover.c: Use pagecache_page_no_t as type for pages storage/maria/ma_loghandler_lsn.h: Added cast's to get rid of compiler warnings storage/maria/ma_page.c: Changed variable name from 'page' to 'pos' as it was an offset and not a page address Moved page_size inside block to get rid of compiler warning storage/maria/ma_pagecache.c: Fixed compiler warnings Replaced compile time assert with TODO storage/maria/ma_pagecache.h: Use pagecache_page_no_t as type for pages storage/maria/ma_pagecrc.c: Allow bitmap pages that is all zero storage/maria/ma_preload.c: Added cast to get rid of compiler warning storage/maria/ma_recovery.c: Changed types to get rid of compiler warnings Use bool for quick_repair to get rid of compiler warning Fixed some variables that was wrongly declared (not enough precission) Added cast to get rid of compiler warning storage/maria/ma_test2.c: Remove historical undefs storage/maria/maria_chk.c: Changed rep_quick to bool Fixed wrong parameter to maria_chk_data_link() storage/maria/maria_def.h: Use pagecache_page_no_t as type for pages storage/maria/maria_pack.c: Renamed isam -> maria storage/maria/plug.in: Added option --with-maria-tmp-tables storage/maria/trnman.c: Added cast to get rid of compiler warning storage/myisam/mi_test2.c: Remove historical undefs --- storage/myisam/mi_test2.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index e75a09702ce..c29d495194f 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -18,12 +18,6 @@ #ifndef USE_MY_FUNC /* We want to be able to dbug this !! */ #define USE_MY_FUNC #endif -#ifdef DBUG_OFF -#undef DBUG_OFF -#endif -#ifndef SAFEMALLOC -#define SAFEMALLOC -#endif #include "myisamdef.h" #include #include -- cgit v1.2.1 From 266fde77b283237fa2dd6db0f97fb68289fe0c21 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Jan 2008 01:47:52 +0200 Subject: Added --loose-skip-maria to MYSQLD_BOOTSTRAP_CMD to get bootstrap.test to work Allow one to run bootstrap even if --skip-maria is used (needed for bootstrap.test) Fixed lots of compiler warnings NOTE: maria-big and maria-recover tests failes becasue of bugs in transaction log handling. Sanja knows about this and is working on it! mysql-test/mysql-test-run.pl: Added --loose-skip-maria to MYSQLD_BOOTSTRAP_CMD to get bootstrap.test to work mysql-test/r/maria-recovery.result: Updated results mysql-test/t/bootstrap.test: Removed not needed empty line mysql-test/t/change_user.test: Fixed results for 32 bit systems mysql-test/t/maria-big.test: Only run this when you use --big mysql-test/t/maria-recovery.test: Added test case for recovery with big blobs mysys/my_uuid.c: Fixed compiler warning sql/mysqld.cc: Allow one to run bootstrap even if --skip-maria is used (needed for bootstrap.test) sql/set_var.cc: Compare max_join_size with ULONG_MAX instead of HA_POS_ERROR as we set max_join_size to ULONG_MAX by default storage/maria/ma_bitmap.c: Added __attribute((unused)) to fix compiler warning storage/maria/ma_blockrec.c: Added casts to remove compiler warnings Change variable types to avoid compiler warnings storage/maria/ma_check.c: Added casts to remove compiler warnings storage/maria/ma_checkpoint.c: Change variable types to avoid compiler warnings storage/maria/ma_create.c: Change variable types to avoid compiler warnings storage/maria/ma_delete.c: Added casts to remove compiler warnings storage/maria/ma_key_recover.c: Added casts to remove compiler warnings storage/maria/ma_loghandler.c: Moved initiazation of prev_buffer first as this could otherwise not be set in case of errors storage/maria/ma_page.c: Added casts to remove compiler warnings storage/maria/ma_pagecache.c: Added __attribute((unused)) to fix compiler warning storage/maria/ma_pagecrc.c: Added #ifndef DBUG_OFF to remove compiler warning storage/maria/ma_recovery.c: Added casts to remove compiler warnings storage/maria/ma_write.c: Added casts to remove compiler warnings storage/maria/maria_chk.c: Split long string into two to avoid compiler warnings storage/myisam/ft_boolean_search.c: Added LINT_INIT() to remove compiler warning support-files/compiler_warnings.supp: Suppress wrong compiler warning unittest/mytap/tap.c: Fixed declaration to match prototypes to remove compiler warnings --- storage/myisam/ft_boolean_search.c | 1 + 1 file changed, 1 insertion(+) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 03d6bdb2cde..0fac5d06379 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -344,6 +344,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) MI_INFO *info=ftb->info; uint off, extra=HA_FT_WLEN+info->s->base.rec_reflength; uchar *lastkey_buf=ftbw->word+ftbw->off; + LINT_INIT(off); if (ftbw->flags & FTB_FLAG_TRUNC) lastkey_buf+=ftbw->len; -- cgit v1.2.1 From e689fbc4582de1b5f81cb69d98f5fe54b7064db1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Jan 2008 19:39:43 +0200 Subject: Fixed compiler warnings by adding casts and changing variable types Fixed bug that caused change_user.test to fail Fixed bug that caused mysql_client_test to fail include/myisam.h: Fixed prototypes mysql-test/r/create.result: Fix that test works even if Maria is not used for temporary tables mysql-test/t/create.test: Fix that test works even if Maria is not used for temporary tables sql/mysqld.cc: Fixed that default value of max_join_size is set correctly; It needs to match usage in set_var.cc sql/set_var.cc: Fixed test, now when max_join_size is initialized correctly sql/sql_select.cc: Fixed that one can compile without -DUSE_MARIA_FOR_TMP_TABLES storage/maria/ma_blockrec.c: Fixed compiler warnings by adding casts storage/maria/ma_checkpoint.c: Fixed compiler warnings by adding casts storage/maria/ma_create.c: Fixed compiler warnings by adding casts storage/maria/ma_delete_table.c: Fixed compiler warnings by adding casts storage/maria/ma_loghandler.c: Fixed compiler warnings by adding casts and changing types for variables Changed translog_new_page_header to use changing integer instead of calling time() as time() is a slow call and will give same results when calling many times withing one second storage/maria/ma_pagecrc.c: Fixed compiler warnings by adding casts storage/maria/ma_recovery.c: Fixed indentation storage/myisam/ha_myisam.cc: Fixed wrong types for variables Changed chk_data_link() and repair*() functions to take my_bool as argument storage/myisam/mi_check.c: Fixes to handle that param.test_flag is now ulonglong storage/myisam/myisamchk.c: Fixes to handle that param.test_flag is now ulonglong support-files/compiler_warnings.supp: Fixed line numbers --- storage/myisam/ha_myisam.cc | 14 +++++++------- storage/myisam/mi_check.c | 8 ++++---- storage/myisam/myisamchk.c | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 70116b80c1f..42e3215403c 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -767,13 +767,13 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) (param.testflag & (T_EXTEND | T_MEDIUM)))) || mi_is_crashed(file)) { - uint old_testflag=param.testflag; + ulonglong old_testflag= param.testflag; param.testflag|=T_MEDIUM; if (!(error= init_io_cache(¶m.read_cache, file->dfile, my_default_record_cache_size, READ_CACHE, share->pack.header_length, 1, MYF(MY_WME)))) { - error= chk_data_link(¶m, file, param.testflag & T_EXTEND); + error= chk_data_link(¶m, file, test(param.testflag & T_EXTEND)); end_io_cache(&(param.read_cache)); } param.testflag= old_testflag; @@ -1030,7 +1030,7 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt) int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) { int error=0; - uint local_testflag=param.testflag; + ulonglong local_testflag= param.testflag; bool optimize_done= !do_optimize, statistics_done=0; const char *old_proc_info=thd->proc_info; char fixed_name[FN_REFLEN]; @@ -1079,7 +1079,7 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ? mi_get_mask_all_keys_active(share->base.keys) : share->state.key_map); - uint testflag=param.testflag; + ulonglong testflag= param.testflag; if (mi_test_if_sort_rep(file,file->state->records,key_map,0) && (local_testflag & T_REP_BY_SORT)) { @@ -1093,7 +1093,7 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map)); thd_proc_info(thd, buf); error = mi_repair_parallel(¶m, file, fixed_name, - param.testflag & T_QUICK); + test(param.testflag & T_QUICK)); thd_proc_info(thd, "Repair done"); // to reset proc_info, as // it was pointing to local buffer } @@ -1101,7 +1101,7 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) { thd_proc_info(thd, "Repair by sorting"); error = mi_repair_by_sort(¶m, file, fixed_name, - param.testflag & T_QUICK); + test(param.testflag & T_QUICK)); } } else @@ -1109,7 +1109,7 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) thd_proc_info(thd, "Repair with keycache"); param.testflag &= ~T_REP_BY_SORT; error= mi_repair(¶m, file, fixed_name, - param.testflag & T_QUICK); + test(param.testflag & T_QUICK)); } param.testflag=testflag; optimize_done=1; diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index fc9d3a346dd..e45fe872d2d 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -136,7 +136,7 @@ int chk_status(HA_CHECK *param, register MI_INFO *info) /* Check delete links */ -int chk_del(HA_CHECK *param, register MI_INFO *info, uint test_flag) +int chk_del(HA_CHECK *param, register MI_INFO *info, ulonglong test_flag) { reg2 ha_rows i; uint delete_link_length; @@ -934,7 +934,7 @@ static uint isam_key_length(MI_INFO *info, register MI_KEYDEF *keyinfo) /* Check that record-link is ok */ -int chk_data_link(HA_CHECK *param, MI_INFO *info,int extend) +int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) { int error,got_error,flag; uint key,left_length,b_type,field; @@ -2494,7 +2494,7 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, goto err; } - if (rep_quick & T_FORCE_UNIQUENESS) + if (rep_quick && (param->testflag & T_FORCE_UNIQUENESS)) { my_off_t skr=info->state->data_file_length+ (share->options & HA_OPTION_COMPRESS_RECORD ? @@ -3014,7 +3014,7 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, goto err; } - if (rep_quick & T_FORCE_UNIQUENESS) + if (rep_quick && (param->testflag & T_FORCE_UNIQUENESS)) { my_off_t skr=info->state->data_file_length+ (share->options & HA_OPTION_COMPRESS_RECORD ? diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 9f86f14d2ba..694ebeb7f5d 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -103,7 +103,7 @@ int main(int argc, char **argv) (!(check_param.testflag & (T_REP | T_REP_BY_SORT | T_SORT_RECORDS | T_SORT_INDEX)))) { - uint old_testflag=check_param.testflag; + ulonglong old_testflag=check_param.testflag; if (!(check_param.testflag & T_REP)) check_param.testflag|= T_REP_BY_SORT; check_param.testflag&= ~T_EXTEND; /* Don't needed */ @@ -795,7 +795,7 @@ static void get_options(register int *argc,register char ***argv) static int myisamchk(HA_CHECK *param, char * filename) { int error,lock_type,recreate; - int rep_quick= param->testflag & (T_QUICK | T_FORCE_UNIQUENESS); + int rep_quick= test(param->testflag & (T_QUICK | T_FORCE_UNIQUENESS)); uint raid_chunks; MI_INFO *info; File datafile; @@ -935,7 +935,7 @@ static int myisamchk(HA_CHECK *param, char * filename) param->testflag|=T_REP_BY_SORT; /* if only STATISTICS */ if (!(param->testflag & T_SILENT)) printf("- '%s' has old table-format. Recreating index\n",filename); - rep_quick|=T_QUICK; + rep_quick= 1; } share=info->s; share->tot_locks-= share->r_locks; @@ -1111,7 +1111,7 @@ static int myisamchk(HA_CHECK *param, char * filename) if ((info->s->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) || (param->testflag & (T_EXTEND | T_MEDIUM))) - error|=chk_data_link(param, info, param->testflag & T_EXTEND); + error|=chk_data_link(param, info, test(param->testflag & T_EXTEND)); error|=flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(¶m->read_cache)); } -- cgit v1.2.1 From 89ff50d4296e849cec70799f7bda8c6217601867 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 13 Jan 2008 00:30:38 +0200 Subject: Fixed compiler warnings Fixed type that caused windows builds to fail include/my_alloc.h: Use size_t for memory areas instead of uint mysys/mf_iocache.c: Fixed compiler warnings by adding casts mysys/my_compress.c: Fixed compiler warnings by adding casts mysys/my_getsystime.c: Fixed typo mysys/my_static.h: Use size_t for memory areas mysys/safemalloc.c: Use size_t for memory areas storage/maria/ma_bitmap.c: Fixed compiler warnings by adding casts storage/maria/ma_blockrec.c: Fixed compiler warnings by adding casts storage/maria/ma_cache.c: Use size_t for memory areas storage/maria/ma_info.c: Use size_t for memory areas storage/maria/ma_key.c: Fixed compiler warnings by adding casts storage/maria/ma_locking.c: Fixed compiler warnings by adding casts storage/maria/ma_open.c: Fixed compiler warnings by adding casts storage/maria/ma_packrec.c: Fixed compiler warnings by fixing type for variable storage/maria/ma_statrec.c: Fixed compiler warnings by adding casts storage/maria/ma_write.c: Fixed compiler warnings by adding casts storage/maria/maria_def.h: Use size_t for memory areas storage/myisam/mi_search.c: Fixed compiler warnings by adding casts --- storage/myisam/mi_search.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index f4cac27a43f..b930877d26f 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -409,7 +409,7 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, } from+=keyseg->length; page=from+nod_flag; - length=from-vseg; + length= (uint) (from-vseg); } if (page > end) -- cgit v1.2.1 From cd15ea74f77c24ad875a5ea5992b276d984fee54 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 19 Jan 2008 04:51:38 +0100 Subject: - fix for bug when creating bitmaps - fix for bug seen when running test "type_datetime" with Maria (wrong data_file_length in maria_repair()) - fix for bug seen when running test "repair" with Maria (myisam_sort_buffer_size was influencing Maria) sql/handler.cc: Sounds illogical to store myisam_sort_buffer_size into a structure used by all engines. There are only MyISAM and Maria which used sort_buffer_size: they can get their value from their respective system variable (myisam|maria_sort_buffer_size). Using MyISAM's value for all engines was wrong (myisam_sort_buffer_size influenced Maria). sql/handler.h: not needed storage/maria/ha_maria.cc: check_opt->sort_buffer_size was myisam_sort_buffer_size; Maria must use maria_sort_buffer_size instead. storage/maria/ma_bitmap.c: don't use my_chsize() now that Monty re-explained the problem to me :) storage/maria/ma_check.c: making maria_repair() work like maria_repair_by_sort(): sort_param.filepos must be set at start then possibly corrected by create_new_data_handle(); in the opposite order, filepos is finally set to 0, and if the table has no records, it stays 0 and this causes state.data_file_length to be 0 which is incorrect for a BLOCK_RECORD table having always at least one bitmap page. storage/maria/ma_pagecache.c: Comments storage/myisam/ha_myisam.cc: check_opt->sort_buffer_size is gone --- storage/myisam/ha_myisam.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 42e3215403c..4e8f300fcf5 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -969,7 +969,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) param.testflag= ((check_opt->flags & ~(T_EXTEND)) | T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM | (check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT)); - param.sort_buffer_length= check_opt->sort_buffer_size; + param.sort_buffer_length= thd->variables.myisam_sort_buff_size; start_records=file->state->records; while ((error=repair(thd,param,0)) && param.retry_repair) { @@ -1015,7 +1015,7 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt) param.op_name= "optimize"; param.testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE | T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX); - param.sort_buffer_length= check_opt->sort_buffer_size; + param.sort_buffer_length= thd->variables.myisam_sort_buff_size; if ((error= repair(thd,param,1)) && param.retry_repair) { sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying", -- cgit v1.2.1 From df843c4ce26e2c5d152098302b209252c712382e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Feb 2008 02:45:02 +0200 Subject: Fixed problems with ma_test2 and mi_test2 on high-byte-first system Fixed bug in ma_test2 when last row in table is deleted Fixed that ma_test_recovery.pl works on Solaris (by using digest instead of md5sum) Fixed some compiler warnings generated by the Forte compiler dbug/dbug.c: Added cast to get rid of compiler warning mysys/lf_alloc-pin.c: Added cast to get rid of compiler warning mysys/my_bitmap.c: Removed impossible DBUG_ASSERT()'s to get rid of compiler warnings mysys/my_compress.c: Removed wrong cast to get rid of compiler warning storage/maria/lockman.c: Added cast to get rid of compiler warning storage/maria/ma_open.c: Added fix from MyISAM to allocate space in key buffer for nod pointer storage/maria/ma_recovery.c: Fixed initialization that caused compiler warning storage/maria/ma_rsame.c: More DBUG_PRINT storage/maria/ma_scan.c: Better comment storage/maria/ma_statrec.c: More DBUG_PRINT and comments Fixed indentation BitKeeper/etc/ignore: added storage/maria/unittest/tmp/* storage/maria/ma_test2.c: Fixed bug that caused maria_rsame() to fail if test removed last row Fixed wrong usage of longget(); Should be uint4korr() storage/maria/unittest/ma_test_recovery.pl: Use md5sum or digest to calculate md5. This allows this script to be run on Linux and Solaris storage/myisam/mi_test2.c: Fixed wrong usage of longget(); Should be uint4korr() strings/ctype.c: Added casts to get rid of compiler warnings sql-bench/myisam.cnf: New BitKeeper file ``sql-bench/myisam.cnf'' --- storage/myisam/mi_test2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 4a727a9dad0..9844126e7dd 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -775,7 +775,7 @@ int main(int argc, char *argv[]) ulong blob_length,pos; uchar *ptr; memcpy_fixed(&ptr, read_record+blob_pos+4, sizeof(ptr)); - longget(blob_length,read_record+blob_pos); + blob_length= uint4korr(read_record+blob_pos); for (pos=0 ; pos < blob_length ; pos++) { if (ptr[pos] != (uchar) (blob_length+pos)) -- cgit v1.2.1 From 126c1228f5385411fbff586cbc1a48a6c61abfe9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Apr 2008 05:26:36 +0300 Subject: Added versioning of row data Will in future changeset (soon) av versioning of status variables (number of rows) and index Changed some LEX_STRING to LEX_CUSTRING to avoid casts and warnings Removed some not needed variables (as noticed by Guilhem) include/maria.h: Added prototypes for maria_chk_init_for_check(), maria_versioning() and maria_ignore_trids() include/my_base.h: Add new error HA_ERR_ROW_NOT_VISIBLE include/myisamchk.h: Added variables for checking visibility of rows during maria_chk include/thr_lock.h: Changed argument type from int to my_bool for get_status Added variable allow_multiple_concurrent_insert, to signal if table supports multiple concurrent inserts mysql-test/r/maria-page-checksum.result: Added missing drop table mysql-test/t/maria-page-checksum.test: Added missing drop table mysys/my_handler.c: Added new error messages mysys/thr_lock.c: Added support for multiple concurrent inserts, if table handler supports it sql/sql_yacc.yy: Added LOCK TABLE table_name WRITE CONCURRENT This was added (temporarly?) to be able to check versioning with Maria storage/csv/ha_tina.cc: Updated parameter for get_status storage/maria/ha_maria.cc: Added calls to maria_chk_init_status() Fixed call to ma_control_file_open() storage/maria/ma_blockrec.c: Changed some LEX_STRING to LEX_CUSTRING to avoid casts and warnings Changed back some 'header' parameters to const char* Removed some casts Added support for versioning: - If info->row_flag & ROW_FLAG_TRANSID is set, store transaction id together with the row - When reading rows, check if rows are visible. Give error if not - When scanning table, ignore not visible rows - Added function parameters to some functions, to be able to call _ma_compact_block_page() with different parameters depending of if the page is a HEAD or TAIL page - _ma_compact_block_page() deletes transaction id's that are visible by all running transactions - Added functions for thr_lock() to enable multiple concurrent inserts - Added helper function 'mysql_versioning()' to enable/disable versioning - Added helper function maria_ignore_trids(), used by maria_chk and maria_pack to see all rows. storage/maria/ma_blockrec.h: Updated parameters for some functions. Added new functions to read/store state with thr_lock storage/maria/ma_check.c: Enable handling of transaction id's in rows Give a readable error if a table contains a transation id that makes rows not visible storage/maria/ma_control_file.c: Added option to not give warning if control file doesn't exists. storage/maria/ma_control_file.h: Updated parameter lists for ma_control_file_open() storage/maria/ma_delete.c: Removed not used variable (suggestion by Guilhem) storage/maria/ma_locking.c: Changed type of argument from int -> my_bool storage/maria/ma_open.c: Removed not used variables 'key_write_undo_lsn' and 'key_delete_undo_lsn' Added new thr_lock interface functions for BLOCK_RECORD to enable multiple concurrent insert storage/maria/ma_test1.c: Added option --versioning (-C) to check versioning storage/maria/ma_test2.c: Added option -C to check versioning storage/maria/ma_test_recovery: Forward argumetns to ma_test_recovery.pl storage/maria/ma_write.c: Removed not used variable key_write_undo_lsn storage/maria/maria_chk.c: Always read control file (if exist) at start Initialize checking of tables by calling maria_chk_init_for_check() In verbose mode and in case of error, print max found transaction id storage/maria/maria_def.h: Added Trid to MARIA_ROW to be able to check transaction id for found row Moved 'base_length' from MARIA_ROW to MARIA_HA to be able to handle different base length (with and without TRANSID) without if's Added default row_flag to MARIA_HA for the same reason Changed LEX_STRING -> LEX_CUSTRING to avoid casts in ma_blockrec.c Removed not needed variables key_write_undo_lsn and key_delete_undo_lsn Added prototypes for new functions and fixed those that had changed storage/maria/maria_pack.c: Ensure we can read all rows from the file, independent of the used transaction id storage/maria/maria_read_log.c: Updated arguments to ma_control_file_open() storage/maria/trnman.c: If we have only one transaction, fixed that min_read_from contains current transaction Fixed that trnman_can_read_from() returns that row is readable if it was written by current transaction storage/maria/unittest/ma_control_file-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_all-t: Added test of versioning Removed printing of one extra space storage/maria/unittest/ma_test_loghandler-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_first_lsn-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_max_lsn-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_multithread-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_noflush-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_nologs-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_pagecache-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_purge-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_recovery.expected: Updated file with result from new tests storage/maria/unittest/ma_test_recovery.pl: Added options --abort-on-error and --verbose In case of --verbose, print all excuted shell commands Added test of versioning storage/myisam/mi_locking.c: Updated type of parameter storage/myisam/myisamdef.h: Updated type of parameter mysql-test/r/maria-mvcc.result: New BitKeeper file ``mysql-test/r/maria-mvcc.result'' mysql-test/t/maria-mvcc.test: New BitKeeper file ``mysql-test/t/maria-mvcc.test'' --- storage/myisam/mi_locking.c | 2 +- storage/myisam/myisamdef.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index ad23a42ab83..2edeefad45f 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -281,7 +281,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) (THR_WRITE_CONCURRENT_INSERT was used) */ -void mi_get_status(void* param, int concurrent_insert) +void mi_get_status(void* param, my_bool concurrent_insert) { MI_INFO *info=(MI_INFO*) param; DBUG_ENTER("mi_get_status"); diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index b0b9226749d..db6344e14f8 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -700,7 +700,7 @@ int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def, const uchar *record, my_off_t pos); int mi_unique_comp(MI_UNIQUEDEF *def, const uchar *a, const uchar *b, my_bool null_are_equal); -void mi_get_status(void *param, int concurrent_insert); +void mi_get_status(void *param, my_bool concurrent_insert); void mi_update_status(void *param); void mi_restore_status(void *param); void mi_copy_status(void *to, void *from); -- cgit v1.2.1 From c9a825810d90e86683bd055acfa22c05445f1347 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Apr 2008 17:22:51 +0200 Subject: WL#3072 - Maria Recovery Recovery of R-tree and fulltext indices. Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method". Fix for bug (see ma_rt_index.c) where we could have a wrong page_link pointer causing wrong memory access during some R-tree index insert/delete. Making ma_rt_test work again (it had been neglected over time) and adding options (record type etc) to prepare it for integration into ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash) mysql-test/r/maria.result: correct result mysql-test/t/maria.test: now we get no error storage/maria/ma_blockrec.c: delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff. ma_get_length() does not change **packet, marking it with 'const' to remove some casts in callers of this function. The (const uchar**)&header casts will be removed when Monty changes 'header' to const uchar*. _ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read() so its initialization was superfluous. storage/maria/ma_check.c: Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method" (see comment in code) storage/maria/ma_create.c: FULLTEXT and SPATIAL indices have logging now, they are recoverable. storage/maria/ma_delete.c: Logging done by _ma_ck_delete() is moved to a function (_ma_write_undo_key_delete()), for reusal by R-tree logging. _ma_log_delete() is made non-static for same reason, and some of its parameters are made pointers to const. Removed wrong comment ("Note that for delete key" etc, contradicted by code and comment "Log also position to row" a few lines above) storage/maria/ma_ft_update.c: unneeded cast, comment for future storage/maria/ma_key_recover.c: Comment about possible deadlock. Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC. Support operation KEY_OP_MULTI_COPY. When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call the proper key insertion|deletion depending on if this is R-tree or B-tree. Explanation of of _ma_[un]lock_key_del() work, maybe useful for mortals like me. storage/maria/ma_key_recover.h: change of prototypes storage/maria/ma_loghandler.h: New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY storage/maria/ma_page.c: Comments storage/maria/ma_pagecache.c: typo storage/maria/ma_rt_index.c: Fix for bug: the page_link pointer in maria_rtree_insert_req() could be wrong when we set its 'changed' member; for the solution see ma_key_recover.h. It is needed only in cases when we manipulate several pages. Logging of changes done to pages by key insert/delete. maria_rtree_delete()'s main work is moved to a new function maria_rtree_real_delete(), which is used by maria_rtree_delete() and by applying of UNDO_KEY_INSERT. storage/maria/ma_rt_index.h: new prototypes and macros for ma_rt_index.c storage/maria/ma_rt_key.c: Logging of maria_rtree_add_key() and maria_rtree_delete_key(). When inserting, split is necessary if there is not enough room for key: take checksum's occupied space in this calculation. storage/maria/ma_rt_key.h: new prototypes (those functions need to know the page's id because they do logging) storage/maria/ma_rt_mbr.c: Comments about what the functions change. storage/maria/ma_rt_split.c: maria_rtree_split_page() needs to know the page's id, because it does logging. Logging of what a split operation does to the split page (see comment of _ma_log_rt_split(): moves of keys inside the page, sometimes insertion of the new key, and shrinking of the page) and to the new page (receives some keys from split page, and sometimes the new key). storage/maria/ma_rt_test.c: ma_rt_test had been forgotten when maria_rkey() was changed some months ago (0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR) were rewritten to maria_scan() calls (which implies maria_scan_init()). The 'max_i' change is to adapt to the fact that maria_scan() does not return deleted records for BLOCK_RECORD but does so for other formats; the initial code assumed a certain number of deleted records would be returned, we change it to rather count only non-deleted ones. We also add more features to this test, like ma_test1 (the plan is to run ma_rt_test in ma_test_all-t): options to choose records' format, table checksum, transactions, checkpoints, end at specific stages, abort without committing, and debug trace. storage/maria/ma_test1.c: MY_INIT() does my_init(). storage/maria/ma_write.c: Logging done by _ma_ck_write_btree_with_log() is moved to a function (_ma_write_undo_key_insert()), for reusal by R-tree logging. _ma_log_new() and _ma_log_change() are made non-static for same reason. Some parameters of logging functions are made pointers to const. If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too (better checks, bigger record). storage/maria/maria_read_log.c: Program takes no arguments, bail out if any, instead of silently discarding them storage/myisam/rt_test.c: rt_test had been forgotten when mi_rkey() was changed some months ago (0->HA_WHOLE_KEY change). The 'max_i' change is to make it symmetric with ma_rt_test.c mysql-test/r/maria-gis-rtree-dynamic.result: correct result mysql-test/r/maria-gis-rtree-trans.result: correct result mysql-test/r/maria-recovery-rtree-ft.result: almost correct result (hitting BUG# in the end) mysql-test/t/maria-gis-rtree-dynamic.test: test R-tree & dynamic row format mysql-test/t/maria-gis-rtree-trans.test: Test R-tree and page row format and transactional mysql-test/t/maria-recovery-rtree-ft-master.opt: usual options for recovery testing mysql-test/t/maria-recovery-rtree-ft.test: test of recovery of R-tree and fulltext indices. --- storage/myisam/rt_test.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c index 7d15afd12ef..92f329baa81 100644 --- a/storage/myisam/rt_test.c +++ b/storage/myisam/rt_test.c @@ -105,7 +105,7 @@ static int run_test(const char *filename) int nrecords=sizeof(rt_data)/(sizeof(double)*4);/* 3000;*/ int rec_length=0; int uniques=0; - int i; + int i, max_i; int error; int row_count=0; uchar record[MAX_REC_LENGTH]; @@ -194,7 +194,7 @@ static int run_test(const char *filename) create_record(record,i); bzero((char*) read_record,MAX_REC_LENGTH); - error=mi_rkey(file,read_record,0,record+1,0,HA_READ_MBR_EQUAL); + error=mi_rkey(file,read_record,0,record+1,HA_WHOLE_KEY,HA_READ_MBR_EQUAL); if (error && error!=HA_ERR_KEY_NOT_FOUND) { @@ -233,7 +233,8 @@ static int run_test(const char *filename) if (!silent) printf("- Updating rows with position\n"); - for (i=0; i < (nrecords - nrecords/4) ; i++) + /* We are looking for nrecords-necords/2 non-deleted records */ + for (i=0, max_i= nrecords - nrecords/2; i < max_i ; i++) { my_errno=0; bzero((char*) read_record,MAX_REC_LENGTH); @@ -241,7 +242,11 @@ static int run_test(const char *filename) if (error) { if (error==HA_ERR_RECORD_DELETED) + { + printf("found deleted record\n"); + max_i++; /* don't count such record */ continue; + } printf("pos: %2d mi_rrnd: %3d errno: %3d\n",i,error,my_errno); goto err; } @@ -266,7 +271,8 @@ static int run_test(const char *filename) create_record(record, nrecords*4/5); print_record(record,0," search for\n"); - if ((error=mi_rkey(file,read_record,0,record+1,0,HA_READ_MBR_INTERSECT))) + if ((error=mi_rkey(file,read_record,0,record+1,HA_WHOLE_KEY, + HA_READ_MBR_INTERSECT))) { printf("mi_rkey: %3d errno: %3d\n",error,my_errno); goto err; -- cgit v1.2.1 From 663f971b8d6fd121825c41bf1fffcab72aaa885f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 Apr 2008 09:26:37 +0300 Subject: After merge fixes. BitKeeper/deleted/.del-my_bit.h: Delete: include/my_bit.h --- storage/myisam/mi_check.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 5d857d6e20d..7ee1b4702ad 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1211,8 +1211,6 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) param->glob_crc+= (*info->s->calc_check_checksum)(info,record); link_used+= (block_info.filepos - start_recpos); used+= (pos-start_recpos); - case BLOCK_RECORD: - assert(0); /* Impossible */ } /* switch */ if (! got_error) { @@ -3646,8 +3644,6 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) record)); DBUG_RETURN(0); } - case BLOCK_RECORD: - assert(0); /* Impossible */ } DBUG_RETURN(1); /* Impossible */ } @@ -3760,8 +3756,6 @@ int sort_write_record(MI_SORT_PARAM *sort_param) sort_param->filepos+=reclength+length; info->s->state.split++; break; - case BLOCK_RECORD: - assert(0); /* Impossible */ } } if (sort_param->master) -- cgit v1.2.1 From 5099033c26826fd2625b6424134999853e33a29d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 May 2008 18:33:33 +0300 Subject: WL#3138: Maria - fast "SELECT COUNT(*) FROM t;" and "CHECKSUM TABLE t" Added argument to maria_end_bulk_insert() to know if the table will be deleted after the operation Fixed wrong call to strmake Don't call bulk insert in case of inserting only one row (speed optimization as starting/stopping bulk insert Allow storing year 2155 in year field When running with purify/valgrind avoid copying structures over themself Added hook 'trnnam_end_trans_hook' that is called when transaction ends Added trn->used_tables that is used to an entry for all tables used by transaction Fixed that ndb doesn't crash on duplicate key error when start_bulk_insert/end_bulk_insert are not called include/maria.h: Added argument to maria_end_bulk_insert() to know if the table will be deleted after the operation include/my_tree.h: Added macro 'reset_free_element()' to be able to ignore calls to the external free function. Is used to optimize end-bulk-insert in case of failures, in which case we don't want write the remaining keys in the tree mysql-test/install_test_db.sh: Upgrade to new mysql_install_db options mysql-test/r/maria-mvcc.result: New tests mysql-test/r/maria.result: New tests mysql-test/suite/ndb/r/ndb_auto_increment.result: Fixed error message now when bulk insert is not always called mysql-test/suite/ndb/t/ndb_auto_increment.test: Fixed error message now when bulk insert is not always called mysql-test/t/maria-mvcc.test: Added testing of versioning of count(*) mysql-test/t/maria-page-checksum.test: Added comment mysql-test/t/maria.test: More tests mysys/hash.c: Code style change sql/field.cc: Allow storing year 2155 in year field sql/ha_ndbcluster.cc: Added new argument to end_bulk_insert() to signal if the bulk insert should ignored sql/ha_ndbcluster.h: Added new argument to end_bulk_insert() to signal if the bulk insert should ignored sql/ha_partition.cc: Added new argument to end_bulk_insert() to signal if the bulk insert should ignored sql/ha_partition.h: Added new argument to end_bulk_insert() to signal if the bulk insert should ignored sql/handler.cc: Don't call get_dup_key() if there is no table object. This can happen if the handler generates a duplicate key error on commit sql/handler.h: Added new argument to end_bulk_insert() to signal if the bulk insert should ignored (ie, the table will be deleted) sql/item.cc: Style fix Removed compiler warning sql/log_event.cc: Added new argument to ha_end_bulk_insert() sql/log_event_old.cc: Added new argument to ha_end_bulk_insert() sql/mysqld.cc: Removed compiler warning sql/protocol.cc: Added DBUG sql/sql_class.cc: Added DBUG Fixed wrong call to strmake sql/sql_insert.cc: Don't call bulk insert in case of inserting only one row (speed optimization as starting/stopping bulk insert involves a lot of if's) Added new argument to ha_end_bulk_insert() sql/sql_load.cc: Added new argument to ha_end_bulk_insert() sql/sql_parse.cc: Style fixes Avoid goto in common senario sql/sql_select.cc: When running with purify/valgrind avoid copying structures over themself. This is not a real bug in itself, but it's a waste of cycles and causes valgrind warnings sql/sql_select.h: Avoid copying structures over themself. This is not a real bug in itself, but it's a waste of cycles and causes valgrind warnings sql/sql_table.cc: Call HA_EXTRA_PREPARE_FOR_DROP if table created by ALTER TABLE is going to be dropped Added new argument to ha_end_bulk_insert() storage/archive/ha_archive.cc: Added new argument to end_bulk_insert() storage/archive/ha_archive.h: Added new argument to end_bulk_insert() storage/federated/ha_federated.cc: Added new argument to end_bulk_insert() storage/federated/ha_federated.h: Added new argument to end_bulk_insert() storage/maria/Makefile.am: Added ma_state.c and ma_state.h storage/maria/ha_maria.cc: Versioning of count(*) and checksum - share->state.state is now assumed to be correct, not handler->state - Call _ma_setup_live_state() in external lock to get count(*)/checksum versioning. In case of not versioned and not concurrent insertable table, file->s->state.state contains the correct state information Other things: - file->s -> share - Added DBUG_ASSERT() for unlikely case - Optimized end_bulk_insert() to not write anything if table is going to be deleted (as in failed alter table) - Indentation changes in external_lock becasue of removed 'goto' caused a big conflict even if very little was changed storage/maria/ha_maria.h: New argument to end_bulk_insert() storage/maria/ma_blockrec.c: Update for versioning of count(*) and checksum Keep share->state.state.data_file_length up to date (not info->state->data_file_length) Moved _ma_block_xxxx_status() and maria_versioning() functions to ma_state.c storage/maria/ma_check.c: Update and use share->state.state instead of info->state info->s to share Update info->state at end of repair Call _ma_reset_state() to update share->state_history at end of repair storage/maria/ma_checkpoint.c: Call _ma_remove_not_visible_states() on checkpoint to clean up not visible state history from tables storage/maria/ma_close.c: Remember state history for running transaction even if table is closed storage/maria/ma_commit.c: Ensure we always call trnman_commit_trn() even if other calls fails. If we don't do that, the translog and state structures will not be freed storage/maria/ma_delete.c: Versioning of count(*) and checksum: - Always update info->state->checksum and info->state->records storage/maria/ma_delete_all.c: Versioning of count(*) and checksum: - Ensure that share->state.state is updated, as here is where we store the primary information storage/maria/ma_dynrec.c: Use lock_key_trees instead of concurrent_insert to check if trees should be locked. This allows us to lock trees both for concurrent_insert and for index versioning. storage/maria/ma_extra.c: Versioning of count(*) and checksum: - Use share->state.state instead of info->state - share->concurrent_insert -> share->non_transactional_concurrent_insert - Don't update share->state.state from info->state if transactional table Optimization: - Don't flush io_cache or bitmap if we are using FLUSH_IGNORE_CHANGED storage/maria/ma_info.c: Get most state information from current state storage/maria/ma_init.c: Add hash table and free function to store states for closed tables Install hook for transaction commit/rollback to update history state storage/maria/ma_key_recover.c: Versioning of count(*) and checksum: - Use share->state.state instead of info->state storage/maria/ma_locking.c: Versioning of count(*) and checksum: - Call virtual functions (if exists) to restore/update status - Move _ma_xxx_status() functions to ma_state.c info->s -> share storage/maria/ma_open.c: Versioning of count(*) and checksum: - For not transactional tables, set info->state to point to new allocated state structure. - Initialize new info->state_start variable that points to state at start of transaction - Copy old history states from hash table (maria_stored_states) first time the table is opened - Split flag share->concurrent_insert to non_transactional_concurrent_insert & lock_key_tree - For now, only enable versioning of tables without keys (to be fixed in soon!) - Added new virtual function to restore status in maria_lock_database) More DBUG storage/maria/ma_page.c: Versioning of count(*) and checksum: - Use share->state.state instead of info->state - Modify share->state.state.key_file_length under share->intern_lock storage/maria/ma_range.c: Versioning of count(*) and checksum: - Lock trees based on share->lock_key_trees info->s -> share storage/maria/ma_recovery.c: Versioning of count(*) and checksum: - Use share->state.state instead of info->state - Update state information on close and when reenabling logging storage/maria/ma_rkey.c: Versioning of count(*) and checksum: - Lock trees based on share->lock_key_trees storage/maria/ma_rnext.c: Versioning of count(*) and checksum: - Lock trees based on share->lock_key_trees storage/maria/ma_rnext_same.c: Versioning of count(*) and checksum: - Lock trees based on share->lock_key_trees - Only skip rows based on file length if non_transactional_concurrent_insert is set storage/maria/ma_rprev.c: Versioning of count(*) and checksum: - Lock trees based on share->lock_key_trees storage/maria/ma_rsame.c: Versioning of count(*) and checksum: - Lock trees based on share->lock_key_trees storage/maria/ma_sort.c: Use share->state.state instead of info->state Fixed indentation storage/maria/ma_static.c: Added maria_stored_state storage/maria/ma_update.c: Versioning of count(*) and checksum: - Always update info->state->checksum and info->state->records - Remove optimization for index file update as it doesn't work for transactional tables storage/maria/ma_write.c: Versioning of count(*) and checksum: - Always update info->state->checksum and info->state->records storage/maria/maria_def.h: Move MARIA_STATUS_INFO to ma_state.h Changes to MARIA_SHARE: - Added state_history to store count(*)/checksum states - Added in_trans as counter if table is used by running transactions - Split concurrent_insert into lock_key_trees and on_transactional_concurrent_insert. - Added virtual function lock_restore_status Changes to MARIA_HA: - save_state -> state_save - Added state_start to store state at start of transaction storage/maria/maria_pack.c: Versioning of count(*) and checksum: - Use share->state.state instead of info->state Indentation fixes storage/maria/trnman.c: Added hook 'trnnam_end_trans_hook' that is called when transaction ends Added trn->used_tables that is used to an entry for all tables used by transaction More DBUG Changed return type of trnman_end_trn() to my_bool Added trnman_get_min_trid() to get minimum trid in use. Added trnman_exists_active_transactions() to check if there exist a running transaction started between two commit id storage/maria/trnman.h: Added 'used_tables' Moved all pointers into same groups to get better memory alignment storage/maria/trnman_public.h: Added prototypes for new functions and variables Chagned return type of trnman_end_trn() to my_bool storage/myisam/ha_myisam.cc: Added argument to end_bulk_insert() if operation should be aborted storage/myisam/ha_myisam.h: Added argument to end_bulk_insert() if operation should be aborted storage/maria/ma_state.c: Functions to handle state of count(*) and checksum storage/maria/ma_state.h: Structures and declarations to handle state of count(*) and checksum --- storage/myisam/ha_myisam.cc | 6 +++--- storage/myisam/ha_myisam.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 4e8f300fcf5..71012e61e76 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1511,12 +1511,12 @@ void ha_myisam::start_bulk_insert(ha_rows rows) != 0 Error */ -int ha_myisam::end_bulk_insert() +int ha_myisam::end_bulk_insert(bool abort) { mi_end_bulk_insert(file); int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0); - return err ? err : can_enable_indexes ? - enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE) : 0; + return (err || abort ? err : can_enable_indexes ? + enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE) : 0); } diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 076e31c07e8..606d5ca354f 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -107,7 +107,7 @@ class ha_myisam: public handler int enable_indexes(uint mode); int indexes_are_disabled(void); void start_bulk_insert(ha_rows rows); - int end_bulk_insert(); + int end_bulk_insert(bool abort); ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); void update_create_info(HA_CREATE_INFO *create_info); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); -- cgit v1.2.1 From f89c61f5bbb45ae056bae0aee20317a019de6f66 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Tue, 10 Jun 2008 15:44:41 +0200 Subject: Fix for Valgrind errors when running rt_test and ma_rt_test, and segmentation fault in ma_rt_test -M (BUG#36321); keyinfo/recinfo/keyseg had non-initialized parts. maria_scan() was not wrapped in maria_scan_init()/end() so "ma_rt_test -M" found no rows. Preparing for inclusion into ma_test_all-t and ma_test_recovery.pl (still prevented by BUG#37307 "Maria: R-tree unit test produces corrupted table"). storage/maria/ma_rt_test.c: Some members of keyinfo, recinfo, keyseg had non-initialized parts, led to Valgrind errors, and also segmentation fault when running with -M (=BLOCK_RECORD) (BUG#36321). We now bzero them like they are in mi_test1. Other problems: - maria_scan() was not wrapped in maria_scan_init()/end() so "ma_rt_test -M" found no rows. - --silent had almost no effect, now it really silences normal output. - Some errors were going to stdout, they now go to stderr. Added option for testing versioning, to fit well into ma_test_all-t. storage/maria/unittest/ma_test_all-t: preparing for running ma_rt_test when ma_rt_test remaining bugs are fixed storage/maria/unittest/ma_test_recovery.pl: preparing for running ma_rt_test when ma_rt_test remaining bugs are fixed storage/myisam/rt_test.c: Some members of keyinfo, recinfo, keyseg were not initialized, led to Valgrind errors. We now bzero them like they are in mi_test1. --- storage/myisam/rt_test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c index 92f329baa81..6c73c9db13c 100644 --- a/storage/myisam/rt_test.c +++ b/storage/myisam/rt_test.c @@ -112,7 +112,13 @@ static int run_test(const char *filename) uchar read_record[MAX_REC_LENGTH]; int upd= 10; ha_rows hrows; - + + bzero(&uniquedef, sizeof(uniquedef)); + bzero(&create_info, sizeof(create_info)); + bzero(recinfo, sizeof(recinfo)); + bzero(keyinfo, sizeof(keyinfo)); + bzero(keyseg, sizeof(keyseg)); + /* Define a column for NULLs and DEL markers*/ recinfo[0].type=FIELD_NORMAL; @@ -147,7 +153,6 @@ static int run_test(const char *filename) if (!silent) printf("- Creating isam-file\n"); - bzero((char*) &create_info,sizeof(create_info)); create_info.max_rows=10000000; if (mi_create(filename, -- cgit v1.2.1 From 52cb0c24a6a6674ee17c4bb86fa02527043ed90f Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 26 Jun 2008 08:18:28 +0300 Subject: Added versioning of Maria index Store max_trid in index file as state.create_trid. This is used to pack all transids in the index pages relative to max possible transid for file. Enable versioning for transactional tables with index. Tables with an auto-increment key, rtree or fulltext keys are not versioned. Changed info->lastkey to type MARIA_KEY. Removed info->lastkey_length as this is now part of info->lastkey Renamed old info->lastkey to info->lastkey_buff Use exact key lenghts for keys, not USE_WHOLE_KEY For partial key searches, use SEARCH_PART_KEY When searching to insert new key on page, use SEARCH_INSERT to mark that key has rowid Changes done in a lot of files: - Modified functions to use MARIA_KEY instead of key pointer and key length - Use keyinfo->root_lock instead of share->key_root_lock[keynr] - Simplify code by using local variable keyinfo instead if share->keyinfo[i] - Added #fdef EXTERNAL_LOCKING around removed state elements - HA_MAX_KEY_BUFF -> MARIA_MAX_KEY_BUFF (to reserve space for transid) - Changed type of 'nextflag' to uint32 to ensure all SEARCH_xxx flags fits into it .bzrignore: Added missing temporary directory extra/Makefile.am: comp_err is now deleted on make distclean include/maria.h: Added structure MARIA_KEY, which is used for intern key objects in Maria. Changed functions to take MARIA_KEY as an argument instead of pointer to packed key. Changed some functions that always return true or false to my_bool. Added virtual function make_key() to avoid if in _ma_make_key() Moved rw_lock_t for locking trees from share->key_root_lock to MARIA_KEYDEF. This makes usage of the locks simpler and faster include/my_base.h: Added HA_RTREE_INDEX flag to mark rtree index. Used for easier checks in ma_check() Added SEARCH_INSERT to be used when inserting new keys Added SEARCH_PART_KEY for partial searches Added SEARCH_USER_KEY_HAS_TRANSID to be used when key we use for searching in btree has a TRANSID Added SEARCH_PAGE_KEY_HAS_TRANSID to be used when key we found in btree has a transid include/my_handler.h: Make next_flag 32 bit to make sure we can handle all SEARCH_ bits mysql-test/include/maria_empty_logs.inc: Read and restore current database; Don't assume we are using mysqltest. Don't log use databasename to log. Using this include should not cause any result changes. mysql-test/r/maria-gis-rtree-dynamic.result: Updated results after adding some check table commands to help pinpoint errors mysql-test/r/maria-mvcc.result: New tests mysql-test/r/maria-purge.result: New result after adding removal of logs mysql-test/r/maria-recovery-big.result: maria_empty_logs doesn't log 'use mysqltest' anymore mysql-test/r/maria-recovery-bitmap.result: maria_empty_logs doesn't log 'use mysqltest' anymore mysql-test/r/maria-recovery-rtree-ft.result: maria_empty_logs doesn't log 'use mysqltest' anymore mysql-test/r/maria-recovery.result: maria_empty_logs doesn't log 'use mysqltest' anymore mysql-test/r/maria.result: New tests mysql-test/r/variables-big.result: Don't log id as it's not predictable mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb_2.result: Updated results to new binlog results. (Test has not been run in a long time as it requires --big) mysql-test/suite/rpl_ndb/t/rpl_truncate_7ndb_2-master.opt: Moved file to ndb replication test directory mysql-test/suite/rpl_ndb/t/rpl_truncate_7ndb_2.test: Fixed wrong path to included tests mysql-test/t/maria-gis-rtree-dynamic.test: Added some check table commands to help pinpoint errors mysql-test/t/maria-mvcc.test: New tests mysql-test/t/maria-purge.test: Remove logs to make test results predictable mysql-test/t/maria.test: New tests for some possible problems mysql-test/t/variables-big.test: Don't log id as it's not predictable mysys/my_handler.c: Updated function comment to reflect old code Changed nextflag to be uint32 to ensure we can have flags > 16 bit Changed checking if we are in insert with NULL keys as next_flag can now include additional bits that have to be ignored. Added SEARCH_INSERT flag to be used when inserting new keys in btree. This flag tells us the that the keys includes row position and it's thus safe to remove SEARCH_FIND Added comparision of transid. This is only done if the keys actually have a transid, which is indicated by nextflag mysys/my_lock.c: Fixed wrong test (Found by Guilhem) scripts/Makefile.am: Ensure that test programs are deleted by make clean sql/rpl_rli.cc: Moved assignment order to fix compiler warning storage/heap/hp_write.c: Add SEARCH_INSERT to signal ha_key_cmp that we we should also compare rowid for keys storage/maria/Makefile.am: Remove also maria log files when doing make distclean storage/maria/ha_maria.cc: Use 'file->start_state' as default state for transactional tables without versioning At table unlock, set file->state to point to live state. (Needed for information schema to pick up right number of rows) In ha_maria::implicit_commit() move all locked (ie open) tables to new transaction. This is needed to ensure ha_maria->info doesn't point to a deleted history event. Disable concurrent inserts for insert ... select and table changes with subqueries if statement based replication as this would cause wrong results on slave storage/maria/ma_blockrec.c: Updated comment storage/maria/ma_check.c: Compact key pages (removes transid) when doing --zerofill Check that 'page_flag' on key pages contains KEYPAGE_FLAG_HAS_TRANSID if there is a single key on the page with a transid Modified functions to use MARIA_KEY instead of key pointer and key length Use new interface to _ma_rec_pos(), _ma_dpointer(), _ma_ft_del(), ma_update_state_lsn() Removed not needed argument from get_record_for_key() Fixed that we check doesn't give errors for RTREE; We now treath these like SPATIAL Remove some SPATIAL specific code where the virtual functions can handle this in a general manner Use info->lastkey_buff instead of info->lastkey _ma_dpos() -> _ma_row_pos_from_key() _ma_make_key() -> keyinfo->make_key() _ma_print_key() -> _ma_print_keydata() _ma_move_key() -> ma_copy_copy() Add SEARCH_INSERT to signal ha_key_cmp that we we should also compare rowid for keys Ensure that data on page doesn't overwrite page checksum position Use DBUG_DUMP_KEY instead of DBUG_DUMP Use exact key lengths instead of USE_WHOLE_KEY to ha_key_cmp() Fixed check if rowid points outside of BLOCK_RECORD data file Use info->lastkey_buff instead of key on stack in some safe places Added #fdef EXTERNAL_LOCKING around removed state elements storage/maria/ma_close.c: Use keyinfo->root_lock instead of share->key_root_lock[keynr] storage/maria/ma_create.c: Removed assert that is already checked in maria_init() Force transactinal tables to be of type BLOCK_RECORD Fixed wrong usage of HA_PACK_RECORD (should be HA_OPTION_PACK_RECORD) Mark keys that uses HA_KEY_ALG_RTREE with HA_RTREE_INDEX for easier handling of these in ma_check Store max_trid in index file as state.create_trid. This is used to pack all transids in the index pages relative to max possible transid for file. storage/maria/ma_dbug.c: Changed _ma_print_key() to use MARIA_KEY storage/maria/ma_delete.c: Modified functions to use MARIA_KEY instead of key pointer and key length info->lastkey2-> info->lastkey_buff2 Added SEARCH_INSERT to signal ha_key_cmp that we we should also compare rowid for keys Use new interface for get_key(), _ma_get_last_key() and others _ma_dpos() -> ma_row_pos_from_key() Simplify setting of prev_key in del() Ensure that KEYPAGE_FLAG_HAS_TRANSID is set in page_flag if key page has transid Treath key pages that may have a transid as if keys would be of variable length storage/maria/ma_delete_all.c: Reset history state if maria_delete_all_rows() are called Update parameters to _ma_update_state_lsns() call storage/maria/ma_extra.c: Store and restore info->lastkey storage/maria/ma_ft_boolean_search.c: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_ft_nlq_search.c: Modified functions to use MARIA_KEY instead of key pointer and key length Use lastkey_buff2 instead of info->lastkey+info->s->base.max_key_length (same thing) storage/maria/ma_ft_update.c: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_ftdefs.h: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_fulltext.h: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_init.c: Check if blocksize is legal (Moved test here from ma_open()) storage/maria/ma_key.c: Added functions for storing/reading of transid Modified functions to use MARIA_KEY instead of key pointer and key length Moved _ma_sp_make_key() out of _ma_make_key() as we now use keyinfo->make_key to create keys Add transid to keys if table is versioned Added _ma_copy_key() storage/maria/ma_key_recover.c: Add logging of page_flag (holds information if there are keys with transid on page) Changed DBUG_PRINT("info" -> DBUG_PRINT("redo" as the redo logging can be quite extensive Added lots of DBUG_PRINT() Added support for index page operations: KEY_OP_SET_PAGEFLAG and KEY_OP_COMPACT_PAGE storage/maria/ma_key_recover.h: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_locking.c: Added new arguments to _ma_update_state_lsns_sub() storage/maria/ma_loghandler.c: Fixed all logging of LSN to look similar in DBUG log Changed if (left != 0) to if (left) as the later is used also later in the code storage/maria/ma_loghandler.h: Added new index page operations storage/maria/ma_open.c: Removed allocated "state_dummy" and instead use share->state.common for transactional tables that are not versioned This is needed to not get double increments of state.records (one in ma_write.c and on when log is written) Changed info->lastkey to MARIA_KEY type Removed resetting of MARIA_HA variables that have 0 as default value (as info is zerofilled) Enable versioning for transactional tables with index. Tables with an auto-increment key, rtree or fulltext keys are not versioned. Check on open that state.create_trid is correct Extend share->base.max_key_length in case of transactional table so that it can hold transid Removed 4.0 compatible fulltext key mode as this is not relevant for Maria Removed old and wrong #ifdef ENABLE_WHEN_WE_HAVE_TRANS_ROW_ID code block Initialize all new virtual function pointers Removed storing of state->unique, state->process and store state->create_trid instead storage/maria/ma_page.c: Added comment to describe key page structure Added functions to compact key page and log the compact operation storage/maria/ma_range.c: Modified functions to use MARIA_KEY instead of key pointer and key length Use SEARCH_PART_KEY indicator instead of USE_WHOLE_KEY to detect if we are doing a part key search Added handling of pages with transid storage/maria/ma_recovery.c: Don't assert if table we opened are not transactional. This may be a table which has been changed from transactional to not transactinal Added new arguments to _ma_update_state_lsns() storage/maria/ma_rename.c: Added new arguments to _ma_update_state_lsns() storage/maria/ma_rkey.c: Modified functions to use MARIA_KEY instead of key pointer and key length Don't use USE_WHOLE_KEY, use real length of key Use share->row_is_visible() to test if row is visible Moved search_flag == HA_READ_KEY_EXACT out of 'read-next-row' loop as this only need to be tested once Removed test if last_used_keyseg != 0 as this is always true storage/maria/ma_rnext.c: Modified functions to use MARIA_KEY instead of key pointer and key length Simplify code by using local variable keyinfo instead if share->keyinfo[i] Use share->row_is_visible() to test if row is visible storage/maria/ma_rnext_same.c: Modified functions to use MARIA_KEY instead of key pointer and key length lastkey2 -> lastkey_buff2 storage/maria/ma_rprev.c: Modified functions to use MARIA_KEY instead of key pointer and key length Simplify code by using local variable keyinfo instead if share->keyinfo[i] Use share->row_is_visible() to test if row is visible storage/maria/ma_rsame.c: Updated comment Simplify code by using local variable keyinfo instead if share->keyinfo[i] Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_rsamepos.c: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_rt_index.c: Modified functions to use MARIA_KEY instead of key pointer and key length Use better variable names Removed not needed casts _ma_dpos() -> _ma_row_pos_from_key() Use info->last_rtree_keypos to save position to key instead of info->int_keypos Simplify err: condition Changed return type for maria_rtree_insert() to my_bool as we are only intressed in ok/fail from this function storage/maria/ma_rt_index.h: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_rt_key.c: Modified functions to use MARIA_KEY instead of key pointer and key length Simplify maria_rtree_add_key by combining idenitcal code and removing added_len storage/maria/ma_rt_key.h: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_rt_mbr.c: Changed type of 'nextflag' to uint32 Added 'to' argument to RT_PAGE_MBR_XXX functions to more clearly see which variables changes value storage/maria/ma_rt_mbr.h: Changed type of 'nextflag' to uint32 storage/maria/ma_rt_split.c: Modified functions to use MARIA_KEY instead of key pointer and key length key_length -> key_data_length to catch possible errors storage/maria/ma_rt_test.c: Fixed wrong comment Reset recinfo to avoid valgrind varnings Fixed wrong argument to create_record() that caused test to fail storage/maria/ma_search.c: Modified functions to use MARIA_KEY instead of key pointer and key length Added support of keys with optional trid Test for SEARCH_PART_KEY instead of USE_WHOLE_KEY to detect part key reads _ma_dpos() -> _ma_row_pos_from_key() If there may be keys with transid on the page, have _ma_bin_search() call _ma_seq_search() Add _ma_skip_xxx() functions to quickly step over keys (faster than calling get_key() in most cases as we don't have to copy key data) Combine similar code at end of _ma_get_binary_pack_key() Removed not used function _ma_move_key() In _ma_search_next() don't call _ma_search() if we aren't on a nod page. Update info->cur_row.trid with trid for found key Removed some not needed casts Added _ma_trid_from_key() Use MARIA_SHARE instead of MARIA_HA as arguments to _ma_rec_pos(), _ma_dpointer() and _ma_xxx_keypos_to_recpos() to make functions faster and smaller storage/maria/ma_sort.c: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_sp_defs.h: _ma_sp_make_key() now fills in and returns (MARIA_KEY *) value storage/maria/ma_sp_key.c: _ma_sp_make_key() now fills in and returns (MARIA_KEY *) value Don't test sizeof(double), test against 8 as we are using float8store() Use mi_float8store() instead of doing swap of value (same thing but faster) storage/maria/ma_state.c: maria_versioning() now only calls _ma_block_get_status() if table supports versioning Added _ma_row_visible_xxx() functions for different occasions When emptying history, set info->state to point to the first history event. storage/maria/ma_state.h: Added _ma_row_visible_xxx() prototypes storage/maria/ma_static.c: Indentation changes storage/maria/ma_statrec.c: Fixed arguments to _ma_dpointer() and _ma_rec_pos() storage/maria/ma_test1.c: Call init_thr_lock() if we have versioning storage/maria/ma_test2.c: Call init_thr_lock() if we have versioning storage/maria/ma_unique.c: Modified functions to use MARIA_KEY storage/maria/ma_update.c: Modified functions to use MARIA_KEY instead of key pointer and key length storage/maria/ma_write.c: Modified functions to use MARIA_KEY instead of key pointer and key length Simplify code by using local variable keyinfo instead if share->keyinfo[i] In _ma_enlarge_root(), mark in page_flag if new key has transid _ma_dpos() -> _ma_row_pos_from_key() Changed return type of _ma_ck_write_tree() to my_bool as we are only testing if result is true or not Moved 'reversed' to outside block as area was used later storage/maria/maria_chk.c: Added error if trying to sort with HA_BINARY_PACK_KEY Use new interface to get_key() and _ma_dpointer() _ma_dpos() -> _ma_row_pos_from_key() storage/maria/maria_def.h: Modified functions to use MARIA_KEY instead of key pointer and key length Added 'common' to MARIA_SHARE->state for storing state for transactional tables without versioning Added create_trid to MARIA_SHARE Removed not used state variables 'process' and 'unique' Added defines for handling TRID's in index pages Changed to use MARIA_SHARE instead of MARIA_HA for some functions Added 'have_versioning' flag if table supports versioning Moved key_root_lock from MARIA_SHARE to MARIA_KEYDEF Changed last_key to be of type MARIA_KEY. Removed lastkey_length lastkey -> lastkey_buff, lastkey2 -> lastkey_buff2 Added _ma_get_used_and_nod_with_flag() for faster access to page data when page_flag is read Added DBUG_DUMP_KEY for easier DBUG_DUMP of a key Changed 'nextflag' and assocaited variables to uint32 storage/maria/maria_ftdump.c: lastkey -> lastkey_buff storage/maria/trnman.c: Fixed wrong initialization of min_read_from and max_commit_trid Added trnman_get_min_safe_trid() storage/maria/unittest/ma_test_all-t: Added --start-from storage/myisam/mi_check.c: Added SEARCH_INSERT, as ha_key_cmp() needs it when doing key comparision for inserting key on page in rowid order storage/myisam/mi_delete.c: Added SEARCH_INSERT, as ha_key_cmp() needs it when doing key comparision for inserting key on page in rowid order storage/myisam/mi_range.c: Updated comment storage/myisam/mi_write.c: Added SEARCH_INSERT, as ha_key_cmp() needs it when doing key comparision for inserting key on page in rowid order storage/myisam/rt_index.c: Fixed wrong parameter to rtree_get_req() which could cause crash --- storage/myisam/mi_check.c | 8 ++++++-- storage/myisam/mi_delete.c | 5 +++-- storage/myisam/mi_range.c | 4 ++-- storage/myisam/mi_write.c | 2 +- storage/myisam/rt_index.c | 5 ++--- 5 files changed, 14 insertions(+), 10 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 7ee1b4702ad..d05d30543ed 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -755,7 +755,10 @@ static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, } if (keyinfo->flag & HA_NOSAME) - comp_flag=SEARCH_FIND | SEARCH_UPDATE; /* Not real duplicates */ + { + /* Not real duplicates */ + comp_flag= SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT; + } else comp_flag=SEARCH_SAME; /* Keys in positionorder */ nod_flag=mi_test_if_nod(buff); @@ -3795,7 +3798,8 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a) if (sort_info->key_block->inited) { cmp=ha_key_cmp(sort_param->seg, (uchar*) sort_info->key_block->lastkey, - (uchar*) a, USE_WHOLE_KEY,SEARCH_FIND | SEARCH_UPDATE, + (uchar*) a, USE_WHOLE_KEY, + SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT, diff_pos); if (param->stats_method == MI_STATS_METHOD_NULLS_NOT_EQUAL) ha_key_cmp(sort_param->seg, (uchar*) sort_info->key_block->lastkey, diff --git a/storage/myisam/mi_delete.c b/storage/myisam/mi_delete.c index 88b31d616de..8ebdb477183 100644 --- a/storage/myisam/mi_delete.c +++ b/storage/myisam/mi_delete.c @@ -171,8 +171,9 @@ static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, goto err; } if ((error=d_search(info,keyinfo, - (keyinfo->flag & HA_FULLTEXT ? SEARCH_FIND | SEARCH_UPDATE - : SEARCH_SAME), + (keyinfo->flag & HA_FULLTEXT ? + SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT : + SEARCH_SAME), key,key_length,old_root,root_buff)) >0) { if (error == 2) diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c index 0efccae9972..aabbe1277c4 100644 --- a/storage/myisam/mi_range.c +++ b/storage/myisam/mi_range.c @@ -152,7 +152,7 @@ static ha_rows _mi_record_pos(MI_INFO *info, const uchar *key, operations with a comment like "Not real duplicates", whatever this means. From the condition above we can see that 'skip_end_space' is always false for these operations. The result is that trailing space - counts in key comparison and hence, emtpy strings ('', string length + counts in key comparison and hence, empty strings ('', string length zero, but not NULL) compare less that strings starting with control characters and these in turn compare less than strings starting with blanks. @@ -166,7 +166,7 @@ static ha_rows _mi_record_pos(MI_INFO *info, const uchar *key, This is the reason that we add the SEARCH_UPDATE flag here. It makes the key estimation compare in the same way like key write operations - do. Olny so we will find the keys where they have been inserted. + do. Only so we will find the keys where they have been inserted. Adding the flag unconditionally does not hurt as it is used in the above mentioned condition only. So it can safely be used together diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 0f2350ded12..6d9dea51177 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -272,7 +272,7 @@ int _mi_ck_write_btree(register MI_INFO *info, uint keynr, uchar *key, comp_flag=SEARCH_BIGGER; /* Put after same key */ else if (keyinfo->flag & (HA_NOSAME|HA_FULLTEXT)) { - comp_flag=SEARCH_FIND | SEARCH_UPDATE; /* No duplicates */ + comp_flag=SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT; /* No duplicates */ if (keyinfo->flag & HA_NULL_ARE_EQUAL) comp_flag|= SEARCH_NULL_ARE_EQUAL; } diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c index 9db7fe88030..86d556c879a 100644 --- a/storage/myisam/rt_index.c +++ b/storage/myisam/rt_index.c @@ -378,7 +378,6 @@ err1: int rtree_get_first(MI_INFO *info, uint keynr, uint key_length) { my_off_t root; - MI_KEYDEF *keyinfo = info->s->keyinfo + keynr; if ((root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR) { @@ -389,7 +388,7 @@ int rtree_get_first(MI_INFO *info, uint keynr, uint key_length) info->rtree_recursion_depth = -1; info->buff_used = 1; - return rtree_get_req(info, &keyinfo[keynr], key_length, root, 0); + return rtree_get_req(info, info->s->keyinfo + keynr, key_length, root, 0); } @@ -436,7 +435,7 @@ int rtree_get_next(MI_INFO *info, uint keynr, uint key_length) return -1; } - return rtree_get_req(info, &keyinfo[keynr], key_length, root, 0); + return rtree_get_req(info, keyinfo, key_length, root, 0); } } -- cgit v1.2.1 From 9f589947b8b1e06a3e6b46bb6204670705aad21f Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 28 Jun 2008 11:27:14 +0300 Subject: Fix for Bug #36578 Maria: maria-recover may fail to autorepair a table Fixed also some similar issues in MyISAM. This was not noticed before as MyISAM did a second retry without key cache (which just made the second repair attempty slower) storage/maria/ha_maria.cc: Print information if we retry without quick in case of CHECK TABLE table_name QUICK Remove T_QUICK flag when retrying repair, but set T_SAFE_REPAIR to ensure we don't loose any rows Remember T_RETRY_WITH_QUICK flag when restoring repair flags Don't print 'checking table' if we are not checking table in auto-repair Don't use T_QUICK in auto repair (safer) Changed parameter of type HA_PARAM ¶m to HA_PARAM *param storage/maria/ha_maria.h: Changed parameter of type HA_PARAM ¶m to HA_PARAM *param storage/maria/ma_check.c: Added retry without T_QUICK if there is a problem reading a row in BLOCK_RECORD storage/myisam/ha_myisam.cc: Remove T_QUICK flag when retrying repair, but set T_SAFE_REPAIR to ensure we don't loose any rows Remember T_RETRY_WITH_QUICK flag when restoring repair flags --- storage/myisam/ha_myisam.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 8c8f3e6495d..ee453d34b75 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -996,7 +996,9 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) if (test_all_bits(param.testflag, (uint) (T_RETRY_WITHOUT_QUICK | T_QUICK))) { - param.testflag&= ~T_RETRY_WITHOUT_QUICK; + param.testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK); + /* Ensure we don't loose any rows when retrying without quick */ + param.testflag|= T_SAFE_REPAIR; sql_print_information("Retrying repair of: '%s' without quick", table->s->path.str); continue; @@ -1130,7 +1132,7 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) error= mi_repair(¶m, file, fixed_name, test(param.testflag & T_QUICK)); } - param.testflag=testflag; + param.testflag= testflag | (param.testflag & T_RETRY_WITHOUT_QUICK); optimize_done=1; } if (!error) -- cgit v1.2.1 From d29e7f747209f428458a97c128678a21abf2680d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 28 Jun 2008 15:45:15 +0300 Subject: Fix for Bug #37007 Maria: different checksum for MyISAM table depending on CHECKSUM=0|1 This also adds a check that MyISAM tables with incompatible checksums are detected by CHECK TABLE ... [FOR UPGRADE] and thus also by mysql_upgrade. The tables that are incomatible are MyISAM tables with ROW_FORMAT=fixed and has VARCHAR fields and have CHECKSUM enabled. Before these tables gave different checksum if you used CHECK TABLE with or without EXTENDED mysql-test/r/old-mode.result: Now we get same results with and without EXTENDED mysql-test/r/row-checksum-old.result: Initial results mysql-test/r/row-checksum.result: Initial results mysql-test/t/old-mode.test: Added test with QUICK to show that the live checksum is not used when running with --old mysql-test/t/row-checksum-old-master.opt: Start mysqld with --old mode to enable old checksum code mysql-test/t/row-checksum-old.test: Run row-checksum test under mysqld --old mysql-test/t/row-checksum.test: Verify that checksum are calculated the same way with and without EXTENDED We run this with several storage engines to ensure results are the same over storage engines sql/ha_partition.cc: Use new HA_HAS_xxx_CHECKSUM flags sql/handler.cc: Use new HA_HAS_xxx_CHECKSUM flags sql/handler.h: Split HA_HAS_CHECKSUM into HA_HAS_NEW_CHECKSUM and HA_HAS_OLD_CHECKSUM flags. This is a safe API change as only MyISAM and Maria should use these handler flags. sql/sql_show.cc: Use new HA_HAS_xxx_CHECKSUM flags sql/sql_table.cc: Use file->checksum() for live checksums if the life checksum method corresponds to the mysqld --old flag storage/maria/ha_maria.cc: Use new HA_HAS_xxx_CHECKSUM flags storage/myisam/ha_myisam.cc: Set HA_HAS_OLD_CHECKSUM and/or HA_HAS_NEW_CHECKSUM flags depending on if this is a new myisam or old myisam file Add method check_for_upgrade() to detect if the table is of old version with a checksum that is incompatible with CHECK TABLE ... EXTENDED storage/myisam/ha_myisam.h: Added check_for_upgrade() storage/myisam/mi_open.c: Removed not neede cast Initialize share->has_null_fields and share->has_varchar_fields variables storage/myisam/myisamdef.h: Added share->has_null_fields and share->has_varchar_fields --- storage/myisam/ha_myisam.cc | 35 ++++++++++++++++++++++++++++++++++- storage/myisam/ha_myisam.h | 1 + storage/myisam/mi_open.c | 10 +++++++++- storage/myisam/myisamdef.h | 3 +++ 4 files changed, 47 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index ee453d34b75..8e755567a5b 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -690,7 +690,19 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) if (!table->s->db_record_offset) int_table_flags|=HA_REC_NOT_IN_SEQ; if (file->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) - int_table_flags|=HA_HAS_CHECKSUM; + { + /* + Set which type of automatic checksum we have + The old checksum and new checksum are identical if there is no + null fields. + Files with new checksum has the HA_OPTION_NULL_FIELDS bit set. + */ + if ((file->s->options & HA_OPTION_NULL_FIELDS) || + !file->s->has_null_fields) + int_table_flags|= HA_HAS_NEW_CHECKSUM; + if (!(file->s->options & HA_OPTION_NULL_FIELDS)) + int_table_flags|= HA_HAS_OLD_CHECKSUM; + } for (i= 0; i < table->s->keys; i++) { @@ -2042,6 +2054,27 @@ bool ha_myisam::check_if_incompatible_data(HA_CREATE_INFO *info, return COMPATIBLE_DATA_YES; } + +/** + Check if a table is incompatible with the current version. + + The cases are: + - Table has checksum, varchars and are not of dynamic record type +*/ + +int ha_myisam::check_for_upgrade(HA_CHECK_OPT *check_opt) +{ + if (!(file->s->options & HA_OPTION_NULL_FIELDS) && + !(file->s->options & HA_OPTION_PACK_RECORD) && + file->s->has_varchar_fields) + { + /* We need alter there to get the HA_OPTION_NULL_FIELDS flag to be set */ + return HA_ADMIN_NEEDS_ALTER; + } + return HA_ADMIN_OK; +} + + extern int mi_panic(enum ha_panic_function flag); int myisam_panic(handlerton *hton, ha_panic_function flag) { diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 606d5ca354f..62792a10a20 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -119,6 +119,7 @@ class ha_myisam: public handler ulonglong *nb_reserved_values); int rename_table(const char * from, const char * to); int delete_table(const char *name); + int check_for_upgrade(HA_CHECK_OPT *check_opt); int check(THD* thd, HA_CHECK_OPT* check_opt); int analyze(THD* thd,HA_CHECK_OPT* check_opt); int repair(THD* thd, HA_CHECK_OPT* check_opt); diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index ec8fb7ed1d9..1537633bd9d 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -19,6 +19,7 @@ #include "sp_defs.h" #include "rt_index.h" #include +#include #if defined(MSDOS) || defined(__WIN__) #ifdef __WIN__ @@ -453,13 +454,20 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) share->rec[i].pack_type=0; share->rec[i].huff_tree=0; share->rec[i].offset=offset; - if (share->rec[i].type == (int) FIELD_BLOB) + if (share->rec[i].type == FIELD_BLOB) { share->blobs[j].pack_length= share->rec[i].length - portable_sizeof_char_ptr; share->blobs[j].offset=offset; j++; } +#if MYSQL_VERSION_ID <= 60100 + /* This is to detect old checksum option */ + if (share->rec[i].null_bit) + share->has_null_fields= 1; + if (share->rec[i].type == FIELD_VARCHAR) + share->has_varchar_fields= 1; +#endif offset+=share->rec[i].length; } share->rec[i].type=(int) FIELD_LAST; /* End marker */ diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index db6344e14f8..e432708dba2 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -210,6 +210,9 @@ typedef struct st_mi_isam_share enum data_file_type data_file_type; /* Below flag is needed to make log tables work with concurrent insert */ my_bool is_log_table; + /* This is 1 if they table checksum is of old type */ + my_bool has_null_fields; + my_bool has_varchar_fields; my_bool changed, /* If changed since lock */ global_changed, /* If changed since open */ -- cgit v1.2.1 From d145362edf0c6c640b46eb08db18e2781d128075 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 24 Aug 2008 16:29:34 +0300 Subject: Fix for bug#38484 DELETE causes crash or index corruption There is no test cases as it's not trivial to do a test case for this. The new code for Maria is however executed by the test case in the bug report. mysql-test/mysql-test-run.pl: Avoid warnings when running with --extern storage/maria/ha_maria.cc: Disable not complete assert until Sanja can push a proper fix storage/maria/ma_delete.c: Fix that pageflag for page is calculated based on original values storage/maria/ma_search.c: Ensure that prev_length structure variable is properly reset when not used storage/myisam/mi_search.c: Ensure that prev_length structure variable is properly reset when not used --- storage/myisam/mi_search.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index 1af5e8c5585..9bdac0d6bca 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -1802,13 +1802,13 @@ _mi_calc_bin_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key, } /* Check how many characters are identical to next key */ key= s_temp->key+next_length; + s_temp->prev_length= 0; while (*key++ == *next_key++) ; if ((ref_length= (uint) (key - s_temp->key)-1) == next_length) { s_temp->next_key_pos=0; return length; /* can't pack next key */ } - s_temp->prev_length=0; s_temp->n_ref_length=ref_length; return (int) (length-(ref_length - next_length) - next_length_pack + get_pack_length(ref_length)); -- cgit v1.2.1 From 942651ea6cc2b7537aa45ff1d55d64be4e191a16 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 28 Aug 2008 14:43:44 +0200 Subject: wt: comments, OOM checks, test case for deadlock detection include/waiting_threads.h: make wt_thd_dontwait private mysql-test/r/maria.result: deadlock example mysql-test/t/maria.test: deadlock example mysys/waiting_threads.c: comments, OOM checks sql/mysqld.cc: fix variables sql/sql_class.cc: move wt_lazy_init to THD constructor sql/sql_class.h: move wt_lazy_init to THD constructor storage/maria/ha_maria.cc: backport from 6.0 storage/maria/ma_write.c: poset-review fixes, set thd->proc_info storage/maria/trnman.c: bugfixing storage/myisam/mi_check.c: warnings storage/myisam/mi_page.c: warnings storage/myisam/mi_search.c: warnings storage/myisammrg/myrg_create.c: warnings unittest/mysys/waiting_threads-t.c: fixes --- storage/myisam/mi_check.c | 12 ++++++------ storage/myisam/mi_page.c | 2 +- storage/myisam/mi_search.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index d05d30543ed..b8dbdaa44c8 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -803,9 +803,9 @@ static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, (flag=ha_key_cmp(keyinfo->seg,info->lastkey,key,key_length, comp_flag, diff_pos)) >=0) { - DBUG_DUMP("old",(uchar*) info->lastkey, info->lastkey_length); - DBUG_DUMP("new",(uchar*) key, key_length); - DBUG_DUMP("new_in_page",(char*) old_keypos,(uint) (keypos-old_keypos)); + DBUG_DUMP("old",info->lastkey, info->lastkey_length); + DBUG_DUMP("new",key, key_length); + DBUG_DUMP("new_in_page",old_keypos,(uint) (keypos-old_keypos)); if (comp_flag & SEARCH_FIND && flag == 0) mi_check_print_error(param,"Found duplicated key at page %s",llstr(page,llbuff)); @@ -874,8 +874,8 @@ static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_PRINT("test",("page: %s record: %s filelength: %s", llstr(page,llbuff),llstr(record,llbuff2), llstr(info->state->data_file_length,llbuff3))); - DBUG_DUMP("key",(uchar*) key,key_length); - DBUG_DUMP("new_in_page",(char*) old_keypos,(uint) (keypos-old_keypos)); + DBUG_DUMP("key",key,key_length); + DBUG_DUMP("new_in_page",old_keypos,(uint) (keypos-old_keypos)); goto err; } param->record_checksum+=(ha_checksum) record; @@ -4026,7 +4026,7 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, DBUG_RETURN(1); } a_length=2+nod_flag; - key_block->end_pos= (char*) anc_buff+2; + key_block->end_pos= anc_buff+2; lastkey=0; /* No previous key in block */ } else diff --git a/storage/myisam/mi_page.c b/storage/myisam/mi_page.c index 23a2526f756..3ea00fa44db 100644 --- a/storage/myisam/mi_page.c +++ b/storage/myisam/mi_page.c @@ -49,7 +49,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, { DBUG_PRINT("error",("page %lu had wrong page length: %u", (ulong) page, page_size)); - DBUG_DUMP("page", (char*) tmp, keyinfo->block_length); + DBUG_DUMP("page",tmp, keyinfo->block_length); info->last_keypage = HA_OFFSET_ERROR; mi_print_error(info->s, HA_ERR_CRASHED); my_errno = HA_ERR_CRASHED; diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index 1af5e8c5585..f7d8d2c901c 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -816,7 +816,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error", ("Found too long null packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); - DBUG_DUMP("key",(char*) *page_pos,16); + DBUG_DUMP("key",*page_pos,16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; @@ -873,7 +873,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, { DBUG_PRINT("error",("Found too long packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); - DBUG_DUMP("key",(char*) *page_pos,16); + DBUG_DUMP("key",*page_pos,16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; /* Error */ @@ -945,7 +945,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error", ("Found too long binary packed key: %u of %u at 0x%lx", length, keyinfo->maxlength, (long) *page_pos)); - DBUG_DUMP("key",(char*) *page_pos,16); + DBUG_DUMP("key",*page_pos,16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); /* Wrong key */ -- cgit v1.2.1 From 058916ae024baaf8a092e0130654f67ef7b9bcf1 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 12 Oct 2008 13:09:52 +0300 Subject: Fix for bug#39226 Maria: crash with FLUSH TABLES WITH READ LOCK after LOCK TABLES - The problem was that we didn't inform the handler that we are going to close tables that are locked and may have (at least in Maria) be part of an active transaction. Fix for Bug#39227 Maria: crash with ALTER TABLE PARTITION Fix for Bug #39987 main.partition_not_windows fails under debug build Fixed some compiler errors & warnings found by pushbuild include/my_base.h: Added HA_EXTRA_PREPARE_FOR_FORCED_CLOSE for signaling the handler that the file will be forced closed include/my_global.h: Removed 'register' from 'swap_variables' as this gives a warnings when the variables are structs. Compilers should also now be smart enough to figure out this themselves mysql-test/r/subselect_debug.result: Reset value of the debug variable; Without setting this the subselect_innodb test will fail when run after this one mysql-test/suite/maria/r/maria.result: Merged test with myisam.test Added tests for new fixed bugs mysql-test/suite/maria/t/maria.test: Merged test with myisam.test Added tests for new fixed bugs mysql-test/t/subselect_debug.test: Reset value of the debug variable; Without setting this the subselect_innodb test will fail when run after this one mysys/my_uuid.c: Fixed compiler error on windows sql/ha_partition.cc: Added support for the new extra flag: HA_EXTRA_PREPARE_FOR_FORCED_CLOSE (Bug #39226) Ensure that we call extra() for HA_EXTRA_PREPARE_FOR_DROP (Bug#39227) sql/mysqld.cc: Fix for Bug #39987 main.partition_not_windows fails under debug build The problem was that when compiling for purify/valgrind realpath() is not used, which causes test_if_data_home_dir to fail when it shouldn't sql/sql_base.cc: Call HA_EXTRA_PREPARE_FOR_FORCED_CLOSE for tables that are locked but we are going to force close without doing a commit sql/sql_parse.cc: More DBUG_PRINT. Fixed comments storage/maria/ma_extra.c: If HA_EXTRA_PREPARE_FOR_FORCED_CLOSE is called and the table is part of a transaction, remove the table from beeing part of a transaction. This is safe as this is only used as part of flush tables or when the table is not part of a transaction storage/myisam/mi_open.c: Indentation fix unittest/mysys/waiting_threads-t.c: Remove not needed 'volatile' to get rid of compiler warnings on windows --- storage/myisam/mi_open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 3f9c1e7f155..6f5c29fa1e6 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -96,7 +96,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) bzero((uchar*) &info,sizeof(info)); realpath_err= my_realpath(name_buff, - fn_format(org_name,name,"",MI_NAME_IEXT,4),MYF(0)); + fn_format(org_name,name,"",MI_NAME_IEXT,4),MYF(0)); if (my_is_symlink(org_name) && (realpath_err || (*myisam_test_invalid_symlink)(name_buff))) { -- cgit v1.2.1 From d83f6470243057fdd542bed0410dcabe09766713 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 4 Dec 2008 02:36:55 +0200 Subject: Fixed warnings and errors discovered by pushbuild2 mysys/my_init.c: Fixed link error when compiling without thread support sql/item_create.cc: Fixed compiler warning sql/mysqld.cc: Fixed compile error on windows sql/protocol.cc: Fixed compiler warning sql/sql_class.cc: Fixed compiler warning sql/sql_class.h: Fixed compiler warning storage/myisam/mi_open.c: Fixed compiler warning storage/myisammrg/ha_myisammrg.cc: Fixed compiler warning (shadow variable) --- storage/myisam/mi_open.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 6f5c29fa1e6..6af1ba1fbae 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -141,8 +141,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) (uchar*) myisam_file_magic, 4)) { DBUG_PRINT("error",("Wrong header in %s",name_buff)); - DBUG_DUMP("error_dump",(char*) share->state.header.file_version, - head_length); + DBUG_DUMP("error_dump", share->state.header.file_version, + (size_t) head_length); my_errno=HA_ERR_NOT_A_TABLE; goto err; } -- cgit v1.2.1 From 3fca23902cdf36bdc52f2d5826bfd24c2024feb8 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 16 Jan 2009 00:25:53 +0200 Subject: Log queries to maria_log if compiled with EXTRA_DEBUG Added DBUG_ASSERT() to unlikely error senario Don't use errno == 0 in maria_create() / myisam_create() sql/sql_insert.cc: Added DBUG_ASSERT() for case that should never happen in real life Added my_error() to avoid assert if mysql_lock() or postlock() doesn't call my_error() storage/maria/ha_maria.cc: Log queries to maria_log if compiled with EXTRA_DEBUG storage/maria/ma_create.c: Don't use errno == 0 storage/maria/ma_loghandler.c: Added logging of debug info to maria_log storage/maria/ma_loghandler.h: Added logging of debug info to maria_log storage/maria/ma_recovery.c: Added printing of debug info from maria_log storage/maria/trnman.c: Added functions to read/store state in TRN storage/maria/trnman.h: Added functions to read/store state in TRN storage/maria/trnman_public.h: Added state in TRN to remmeber if we have already logged the query storage/myisam/mi_create.c: Don't use errno == 0 --- storage/myisam/mi_create.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 560a537e87c..1ad58bee3e3 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -496,7 +496,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, /* There are only 16 bits for the total header length. */ if (info_length > 65535) { - my_printf_error(0, "MyISAM table '%s' has too many columns and/or " + my_printf_error(HA_WRONG_CREATE_OPTION, + "MyISAM table '%s' has too many columns and/or " "indexes and/or unique constraints.", MYF(0), name + dirname_length(name)); my_errno= HA_WRONG_CREATE_OPTION; -- cgit v1.2.1 From 45f7a939149e457403935db8c6b131baf6193f36 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Mon, 26 Jan 2009 22:14:43 +0100 Subject: Putting back some fixes lost in a colleague's merge a while back; that was about problems when the R-tree index is not the first index. --- storage/myisam/rt_index.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c index b1375d99bd0..822983b718c 100644 --- a/storage/myisam/rt_index.c +++ b/storage/myisam/rt_index.c @@ -378,6 +378,7 @@ err1: int rtree_get_first(MI_INFO *info, uint keynr, uint key_length) { my_off_t root; + MI_KEYDEF *keyinfo = info->s->keyinfo + keynr; if ((root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR) { @@ -388,7 +389,7 @@ int rtree_get_first(MI_INFO *info, uint keynr, uint key_length) info->rtree_recursion_depth = -1; info->buff_used = 1; - return rtree_get_req(info, info->s->keyinfo, key_length, root, 0); + return rtree_get_req(info, keyinfo, key_length, root, 0); } -- cgit v1.2.1 From b125770aaadd09e839ad9211047e88095984308b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 May 2009 14:03:24 +0200 Subject: We are now using Valgrind rather than purify, and have for quite some time. Consequently, rename HAVE_purify to HAVE_valgrind, and related changes. Leave some comments about purify when not clear that they apply also to Valgrind. Fix redundant IF_VALGRIND declaration. Misc. small fixes: - Fixes for pool-of-threads patch. - Fixes for push of PBXT storage engine. - mysql-test-run.pl fix. - Fix build problem in compile-pentium64-max. BUILD/SETUP.sh: Rename purify -> valgrind. BUILD/build_mccge.sh: Rename purify -> valgrind. BUILD/compile-dist: Fix that PBXT was missing in source tarball after `BUILD/compile-dist && make dist` BUILD/compile-pentium64-max: Fix a build problem with BUILD/compile-pentium64-max on CentOS/Fedora Core 10 amd64. On these systems, there is libz.so but no libz.a. Finding libz.so, ./configure decides to use system zlib. But since BUILD/compile-pentium64-max builds a fully static binary with -all-static, the link of mysqld fails due to missing libz.a. Fix by using bundled zlib in the build script. BUILD/compile-solaris-sparc-purify: Rename purify -> valgrind. include/m_string.h: Rename purify -> valgrind. include/my_global.h: Rename purify -> valgrind. mysql-test/Makefile.am: Fix that PBXT test suite was missing from `make dist` source tarball. mysql-test/lib/mtr_unique.pm: Better fix to avoid races when chmod'ing the semaphore file. (Though using chmod 666 shared files in /tmp/ is still not a very good solution). mysql-test/t/pool_of_threads.cnf: Fix that test case pool_of_threads fails if run on mysqld with no --with-libevent support. mysys/mf_qsort.c: Rename purify -> valgrind. mysys/my_alloc.c: Rename purify -> valgrind. mysys/my_init.c: Rename purify -> valgrind. mysys/my_rnd.c: Rename purify -> valgrind. mysys/safemalloc.c: Rename purify -> valgrind. scripts/mysql_config.pl.in: Rename purify -> valgrind. scripts/mysql_config.sh: Rename purify -> valgrind. sql/field_conv.cc: Rename purify -> valgrind. sql/filesort.cc: Rename purify -> valgrind. sql/ha_partition.cc: Rename purify -> valgrind. sql/hostname.cc: Rename purify -> valgrind. sql/item_timefunc.cc: Rename purify -> valgrind. sql/log_event.cc: Rename purify -> valgrind. sql/log_event_old.cc: Rename purify -> valgrind. sql/my_decimal.h: Rename purify -> valgrind. sql/mysqld.cc: Rename purify -> valgrind. Fix redundant IF_VALGRIND declaration. sql/opt_range.cc: Rename purify -> valgrind. sql/opt_range.h: Rename purify -> valgrind. sql/records.cc: Rename purify -> valgrind. sql/rpl_rli.cc: Rename purify -> valgrind. sql/rpl_rli.h: Rename purify -> valgrind. sql/set_var.cc: Fix missing static declaration on pool_of_threads. sql/slave.cc: Rename purify -> valgrind. sql/sql_base.cc: Rename purify -> valgrind. sql/sql_binlog.cc: Rename purify -> valgrind. sql/sql_class.cc: Rename purify -> valgrind. sql/sql_list.h: Rename purify -> valgrind. sql/sql_load.cc: Rename purify -> valgrind. sql/sql_select.cc: Rename purify -> valgrind. sql/table.cc: Rename purify -> valgrind. storage/archive/azio.c: Rename purify -> valgrind. storage/innobase/buf/buf0buf.c: Rename purify -> valgrind. storage/innobase/include/univ.i: Rename purify -> valgrind. storage/innobase/srv/srv0start.c: Rename purify -> valgrind. storage/maria/ha_maria.cc: Rename purify -> valgrind. storage/maria/ma_blockrec.c: Rename purify -> valgrind. storage/maria/ma_check.c: Rename purify -> valgrind. storage/maria/ma_loghandler.c: Rename purify -> valgrind. storage/maria/ma_packrec.c: Rename purify -> valgrind. storage/maria/ma_page.c: Rename purify -> valgrind. storage/maria/ma_pagecrc.c: Rename purify -> valgrind. storage/maria/ma_search.c: Rename purify -> valgrind. storage/myisam/mi_check.c: Rename purify -> valgrind. storage/myisam/mi_page.c: Rename purify -> valgrind. storage/myisam/mi_search.c: Rename purify -> valgrind. storage/myisammrg/ha_myisammrg.cc: Rename purify -> valgrind. strings/bcmp.c: Rename purify -> valgrind. strings/decimal.c: Rename purify -> valgrind. strings/strmake.c: Rename purify -> valgrind. --- storage/myisam/mi_check.c | 4 ++-- storage/myisam/mi_page.c | 2 +- storage/myisam/mi_search.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index a61b71150ac..dc19d790ec9 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -3147,7 +3147,7 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key) (info->s->rec_reflength+ _mi_make_key(info, sort_param->key, (uchar*) key, sort_param->record, sort_param->filepos)); -#ifdef HAVE_purify +#ifdef HAVE_valgrind bzero(key+sort_param->real_key_length, (sort_param->key_length-sort_param->real_key_length)); #endif @@ -3187,7 +3187,7 @@ static int sort_ft_key_read(MI_SORT_PARAM *sort_param, void *key) sort_param->real_key_length=(info->s->rec_reflength+ _ft_make_key(info, sort_param->key, key, wptr++, sort_param->filepos)); -#ifdef HAVE_purify +#ifdef HAVE_valgrind if (sort_param->key_length > sort_param->real_key_length) bzero(key+sort_param->real_key_length, (sort_param->key_length-sort_param->real_key_length)); diff --git a/storage/myisam/mi_page.c b/storage/myisam/mi_page.c index 3ea00fa44db..a05a96e514b 100644 --- a/storage/myisam/mi_page.c +++ b/storage/myisam/mi_page.c @@ -86,7 +86,7 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, if ((length=keyinfo->block_length) > IO_SIZE*2 && info->state->key_file_length != page+length) length= ((mi_getint(buff)+IO_SIZE-1) & (uint) ~(IO_SIZE-1)); -#ifdef HAVE_purify +#ifdef HAVE_valgrind { length=mi_getint(buff); bzero((uchar*) buff+length,keyinfo->block_length-length); diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index 2c346ea18f7..2844b25ee81 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -1749,7 +1749,7 @@ _mi_calc_bin_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key, uint length,key_length,ref_length; s_temp->totlength=key_length=_mi_keylength(keyinfo,key)+nod_flag; -#ifdef HAVE_purify +#ifdef HAVE_valgrind s_temp->n_length= s_temp->n_ref_length=0; /* For valgrind */ #endif s_temp->key=key; -- cgit v1.2.1 From bb55791994deb9677b487e7fcfde233cafbf9dbe Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 30 Jun 2009 00:03:30 +0300 Subject: Added some changes inspired by Zardosht Kasheff: - Added a handler call (prepare_index_scan()) to inform storage engines that an index scan is about to take place. - Extended the maximun key parts for an index from 16 to 32 - Extended MyISAM and Maria engines to support up to 32 parts Added checks for return value from ha_index_init() include/my_handler.h: Extended number of key parts for MyISAM and Maria from 16 to 32 include/my_pthread.h: Ensure we always have 256M of stack. (Required to be able to handle the current number of keys and key parts in MyISAM) mysql-test/r/create.result: Extended to test for 32 key parts mysql-test/r/myisam.result: Test that we can create 32 but not 33 key parts mysql-test/r/ps_1general.result: Length of ref is now 2048 as we can have more key parts mysql-test/r/ps_2myisam.result: Length of ref is now 2048 as we can have more key parts mysql-test/r/ps_3innodb.result: Length of ref is now 2048 as we can have more key parts mysql-test/r/ps_4heap.result: Length of ref is now 2048 as we can have more key parts mysql-test/r/ps_5merge.result: Length of ref is now 2048 as we can have more key parts mysql-test/suite/maria/r/maria.result: Max key length is now 1208 bytes mysql-test/suite/maria/r/maria3.result: Max key length is now 1208 bytes mysql-test/suite/maria/r/ps_maria.result: Max key length is now 1208 byte mysql-test/t/create.test: Extended to test for 32 key parts mysql-test/t/myisam.test: Test that we can create 32 but not 33 key parts sql/handler.cc: Check return value from ha_index_init() sql/handler.h: Added a handler call (prepare_index_scan()) to inform storage engines that an index scan is about to take place. sql/sql_select.cc: Checks all return values from ha_index_init() Call prepare_index_scan()) to inform storage engines that an index scan is about to take place. Fixed indentation sql/table.cc: Fixed wrong types for key_length (rest of code assumed this was 32 bit) sql/unireg.h: Extended the maximun key parts for an index from 16 to 32 storage/maria/ha_maria.cc: Don't allocate HA_CHECK on the stack in functions where we call repair() as HA_CHECK is HUGE and will overflow stack storage/myisam/ha_myisam.cc: Don't allocate HA_CHECK on the stack in functions where we call repair() as HA_CHECK is HUGE and will overflow stack storage/myisam/mi_check.c: Fixed wrong check if value overflow tests/mysql_client_test.c: Added fflush() to fix output in case of error Fixed wrong check of 'ref' length in EXPLAIN --- storage/myisam/ha_myisam.cc | 23 +++++++++++++++-------- storage/myisam/mi_check.c | 5 +++-- 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index f7a322dde18..160e6dfed6c 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -910,14 +910,21 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt) err: { - HA_CHECK param; - myisamchk_init(¶m); - param.thd= thd; - param.op_name= "restore"; - param.db_name= table->s->db.str; - param.table_name= table->s->table_name.str; - param.testflag= 0; - mi_check_print_error(¶m, errmsg, my_errno); + /* + Don't allocate param on stack here as this may be huge and it's + also allocated by repair() + */ + HA_CHECK *param; + if (!(param= (HA_CHECK*) my_malloc(sizeof(*param), MYF(MY_WME | MY_FAE)))) + DBUG_RETURN(error); + myisamchk_init(param); + param->thd= thd; + param->op_name= "restore"; + param->db_name= table->s->db.str; + param->table_name= table->s->table_name.str; + param->testflag= 0; + mi_check_print_error(param, errmsg, my_errno); + my_free(param, MYF(0)); DBUG_RETURN(error); } } diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index b3f0106aed1..3de667ee4e2 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -4629,8 +4629,9 @@ void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part, let's ensure it is not */ set_if_bigger(tmp,1); - if (tmp >= (ulonglong) ~(ulong) 0) - tmp=(ulonglong) ~(ulong) 0; + /* Keys are stored as 32 byte int's; Ensure we don't get an overflow */ + if (tmp >= (ulonglong) ~(uint32) 0) + tmp=(ulonglong) ~(uint32) 0; *rec_per_key_part=(ulong) tmp; rec_per_key_part++; -- cgit v1.2.1 From cd3047fc89fec8821dd6fcd931897468dfc1ee19 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 3 Sep 2009 17:05:38 +0300 Subject: Updated documentation files to reflect MariaDB and not the Maria storage engine or MySQL Added (rewritten) patch from Percona to get extended statistics in slow.log: - Added handling of 'set' variables to set_var.cc. Changed sql_mode to use this - Added extra logging to slow log of 'Thread_id, Schema, Query Cache hit, Rows sent and Rows examined' - Added optional logging to slow log, through log_slow_verbosity, of query plan statistics - Added new user variables log_slow_rate_limit, log_slow_verbosity, log_slow_filter - Added log-slow-file as synonym for 'slow-log-file', as most slow-log variables starts with 'log-slow' - Added log-slow-time as synonym for long-query-time Some trivial MyISAM optimizations: - In prepare for drop, flush key blocks - Don't call mi_lock_database if my_disable_locking is used KNOWN_BUGS.txt: Updated file to reflect MariaDB and not the Maria storage engine README: Updated file to reflect MariaDB mysql-test/r/log_slow.result: Test new options for slow query log mysql-test/r/variables.result: Updated result (old version cut of things at 79 characters) mysql-test/t/log_slow.test: Test new options for slow query log sql/Makefile.am: Added log_slow.h sql/event_data_objects.cc: Removed not needed test for enable_slow_log (is done when the flag is tested elsewhere) sql/events.cc: Use the general make_set() function instead of 'symbolic_mode_representation' sql/filesort.cc: Added status for used query plans sql/log.cc: Reset counters if no query_length (from Percona's patch; Not sure if needed, but can do no harm) Added extra logging to slow log of 'Thread_id, Schema, Query Cache hit, Rows sent and Rows examined' Added optional logging to slow log, through log_slow_verbosity, of query plan statistics Fixed wrong test of error condition sql/log_slow.h: Defines and variables for log_slow_verbosity and log_slow_filter sql/mysql_priv.h: Include log_slow.h sql/mysqld.cc: Added new user variables log_slow_rate_limit, log_slow_verbosity, log_slow_filter Added log-slow-file as synonym for 'slow-log-file', as most slow-log variables starts with 'log-slow' Added log-slow-time as synonym for long-query-time Added note that one should use log-slow-filter instead of log-slow-admin-statements Updated comment from 'slow_query_log_file' sql/set_var.cc: Added long_slow_time as synonym for long_query_time Added new user variables log_slow_rate_limit, log_slow_verbosity, log_slow_filter dded handling of 'set' variables to set_var.cc. Changed sql_mode to use this sql/set_var.h: - Added handling of 'set' variables. Changed sql_mode to use this sql/slave.cc: Use global filter also for slaves sql/sp_head.cc: Simplify saving of general_slow_log state Use the general make_set() function instead of 'symbolic_mode_representation' sql/sql_cache.cc: Added status for used query plans sql/sql_class.cc: Remember/restore query_plan_flags over complex statements sql/sql_class.h: Added variables to handle extended slow log statistics sql/sql_parse.cc: Added status for used query plans Added test for filtering slow_query_log sql/sql_select.cc: Added status for used query plans sql/sql_show.cc: Use the general make_set() function instead of 'symbolic_mode_representation' sql/strfunc.cc: Report first error (not last) if something is wrong in a set Removed compiler warning storage/myisam/mi_extra.c: In prepare for drop, flush key blocks (speed optimization) storage/myisam/mi_locking.c: Don't call mi_lock_database if my_disable_locking is used (speed optimization) --- storage/myisam/mi_extra.c | 7 ++++--- storage/myisam/mi_locking.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index d798ef50d7e..239fdb3fbc4 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -260,9 +260,8 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) case HA_EXTRA_PREPARE_FOR_DROP: pthread_mutex_lock(&THR_LOCK_myisam); share->last_version= 0L; /* Impossible version */ -#ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND - /* Close the isam and data files as Win32 can't drop an open table */ pthread_mutex_lock(&share->intern_lock); + /* Flush pages that we don't need anymore */ if (flush_key_blocks(share->key_cache, share->kfile, (function == HA_EXTRA_PREPARE_FOR_DROP ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE))) @@ -272,6 +271,8 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); /* Fatal error found */ } +#ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND + /* Close the isam and data files as Win32 can't drop an open table */ if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) { info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); @@ -304,8 +305,8 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) } } share->kfile= -1; /* Files aren't open anymore */ - pthread_mutex_unlock(&share->intern_lock); #endif + pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&THR_LOCK_myisam); break; case HA_EXTRA_FLUSH: diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index f3d9934ed8c..ebee8826c3b 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -582,7 +582,7 @@ int _mi_decrement_open_count(MI_INFO *info) { uint old_lock=info->lock_type; share->global_changed=0; - lock_error=mi_lock_database(info,F_WRLCK); + lock_error= my_disable_locking ? 0 : mi_lock_database(info,F_WRLCK); /* Its not fatal even if we couldn't get the lock ! */ if (share->state.open_count > 0) { @@ -592,7 +592,7 @@ int _mi_decrement_open_count(MI_INFO *info) sizeof(share->state.header), MYF(MY_NABP)); } - if (!lock_error) + if (!lock_error && !my_disable_locking) lock_error=mi_lock_database(info,old_lock); } return test(lock_error || write_error); -- cgit v1.2.1 From cbb8c3f0b0fa5aa7bc63054d48b4a7b6260509e5 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 19 Sep 2009 14:21:29 -0700 Subject: Fixed bug #47455 - a failure with main.myisam_crash_before_flush_keys.test on Windows. --- storage/myisam/myisamchk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 446c3aa2464..6b3ea48e040 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -83,7 +83,9 @@ HA_CHECK check_param; int main(int argc, char **argv) { int error; + uchar rc; MY_INIT(argv[0]); + my_progname_short= "myisamchk"; myisamchk_init(&check_param); check_param.opt_lock_memory=1; /* Lock memory if possible */ @@ -132,7 +134,8 @@ int main(int argc, char **argv) free_tmpdir(&myisamchk_tmpdir); ft_free_stopwords(); my_end(check_param.testflag & T_INFO ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR); - exit(error); + rc= (uchar) error; + exit(rc); #ifndef _lint return 0; /* No compiler warning */ #endif -- cgit v1.2.1 From e147ca15617a4f7d3d1ce328c054540dc2fda46d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 6 Oct 2009 09:13:56 +0300 Subject: Don't call _ma_decrement_open_count() for ma_extra(HA_EXTRA_PREPARE_FOR_DROP). Don't call _mi_decrement_open_count() for mi_extra(HA_EXTRA_PREPARE_FOR_DROP). This ensures that if we empty the key cache and a drop table fails later, the index will be automaticly rebuilt storage/maria/ma_extra.c: Don't call _ma_decrement_open_count() for ma_extra(HA_EXTRA_PREPARE_FOR_DROP). This ensures that if we empty the key cache and a drop table fails later, the index will be automaticly rebuilt storage/maria/ma_locking.c: Simple optimization: Don't call maria_lock_database() if locking is disabled storage/myisam/mi_extra.c: Don't call _mi_decrement_open_count() for mi_extra(HA_EXTRA_PREPARE_FOR_DROP). Simplify code to remove if --- storage/myisam/mi_extra.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 239fdb3fbc4..9c5dade28ab 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -286,9 +286,19 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) info->lock_type = F_UNLCK; } if (share->kfile >= 0) + { + /* + We don't need to call _mi_decrement_open_count() if we are + dropping the table, as the files will be removed anyway. If we + are aborted before the files is removed, it's better to not + call it as in that case the automatic repair on open will add + the missing index entries + */ + if (function != HA_EXTRA_PREPARE_FOR_DROP) _mi_decrement_open_count(info); - if (share->kfile >= 0 && my_close(share->kfile,MYF(0))) - error=my_errno; + if (my_close(share->kfile,MYF(0))) + error=my_errno; + } { LIST *list_element ; for (list_element=myisam_open_list ; -- cgit v1.2.1 From 0c0e1f2e351923c2fecdf38641734ec796ec9c15 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Oct 2009 09:57:22 +0300 Subject: BUG#39249 Maria:query cache returns out of date results BUG#41098 Query Cache returns wrong result with concurent insert BUILD/SETUP.sh: test build without query cache setup BUILD/compile-pentium-debug-max-no-qc: test build without query cache sql/mysql_priv.h: removed double declaration storage/maria/ha_maria.cc: query cache invalidation fixed storage/maria/ma_state.c: query cache invalidation fixed storage/maria/maria_def.h: last transaction ID added invalidation fixed storage/myisam/ha_myisam.cc: invalidation fixed storage/myisam/mi_locking.c: invalidation fixed storage/myisam/myisamdef.h: invalidation fixed --- storage/myisam/ha_myisam.cc | 3 +++ storage/myisam/mi_locking.c | 6 ++++++ storage/myisam/myisamdef.h | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 160e6dfed6c..39c157f2e64 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -660,6 +660,9 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) if (!(file=mi_open(name, mode, test_if_locked | HA_OPEN_FROM_SQL_LAYER))) return (my_errno ? my_errno : -1); + + file->s->chst_invalidator= query_cache_invalidate_by_MyISAM_filename_ref; + if (!table->s->tmp_table) /* No need to perform a check for tmp table */ { if ((my_errno= table2myisam(table, &keyinfo, &recinfo, &recs))) diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index ebee8826c3b..b935d517c81 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -329,6 +329,12 @@ void mi_update_status(void* param) #endif info->s->state.state= *info->state; info->state= &info->s->state.state; +#ifdef HAVE_QUERY_CACHE + DBUG_PRINT("info", ("invalidator... '%s' (status update)", + info->filename)); + DBUG_ASSERT(info->s->chst_invalidator != NULL); + (*info->s->chst_invalidator)((const char *)info->filename); +#endif } info->append_insert_at_end= 0; diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index f311202e47a..c2841c49199 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -190,7 +190,10 @@ typedef struct st_mi_isam_share const uchar *record, my_off_t pos); size_t (*file_read) (MI_INFO *, uchar *, size_t, my_off_t, myf); size_t (*file_write) (MI_INFO *, const uchar *, size_t, my_off_t, myf); - invalidator_by_filename invalidator; /* query cache invalidator */ + /* query cache invalidator for merged tables */ + invalidator_by_filename invalidator; + /* query cache invalidator for changing state */ + invalidator_by_filename chst_invalidator; ulong this_process; /* processid */ ulong last_process; /* For table-change-check */ ulong last_version; /* Version on start */ -- cgit v1.2.1 From f7a75b999b4b0e51c647fa19df35db517e0b6721 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 16 Oct 2009 15:57:48 -0700 Subject: The main commit of Andrey Zhakov's patch introducing vurtual(computed) columns. The original patch has been ameliorated by Sanja and Igor. --- storage/myisam/ha_myisam.cc | 2 +- storage/myisam/ha_myisam.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index ea9ba7012c3..dc5454db1cf 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -252,7 +252,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, record= table_arg->record[0]; recpos= 0; recinfo_pos= recinfo; - while (recpos < (uint) share->reclength) + while (recpos < (uint) share->stored_rec_length) { Field **field, *found= 0; minpos= share->reclength; diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 1b7e948b928..7a1595573d4 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -133,6 +133,7 @@ class ha_myisam: public handler int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt); int preload_keys(THD* thd, HA_CHECK_OPT* check_opt); bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); + bool check_if_supported_virtual_columns(void) { return TRUE;} #ifdef HAVE_REPLICATION int dump(THD* thd, int fd); int net_read_dump(NET* net); -- cgit v1.2.1 From afd0a45639279c8de44f1358cc83c1f1b76ebb30 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 23 Oct 2009 19:48:54 +0300 Subject: Fixes for binary distribution in tar file - mysql_install_db doesn't require --basedir option anymore - Fix that mysql_install_db mysqld_safe mysql_fix_privilege_tables has right paths for tar binary install - Move some files from share/mysql to where they have always been (1.0 - 5.0) - Move scripts used when installing MariaDB to the scripts directory (Added symlinks in old place for compatibility) - Move man files to 'man' (from 'share/man') - Ensure that all scripts are executable mysql_secure_installation.sh - Added support for --basedir flag - Don't assume that the mysql binary is in the path Other: - Fixed crash when one got kill signal during bootstrap Docs/INSTALL-BINARY: Change references from MySQL to MariaDB Docs/mysql.info: Change references from MySQL to MariaDB README: Removed duplicate row configure.in: Change references from MySQL to MariaDB libmysql/libmysql.c: Assume that if version string contains '-maria-' we are also using MariaDB scripts/make_binary_distribution.sh: Fix that mysql_install_db mysqld_safe mysql_fix_privilege_tables has right paths for tar binary install Remove some files that should not be part of a MariaDB binary install Move some files from share/mysql to where they have always been (1.0 - 5.0) Move man files to 'man' (from 'share/man') Move scripts used when installing MariaDB to the scripts directory (Added symlinks in old place for compatibility) Removed generation of 'netware/init_db.sql', as it was never used Remove old reference to bk tree scripts/mysql_secure_installation.sh: Added support for --basedir flag Don't assume that the mysql binary is in the path Use .my.cnf files Removed a lot of useless 'echo' rows sql/mysqld.cc: Fixed crash when one got kill signal during bootstrap storage/maria/Makefile.am: Don't add internal test files to binary distributions storage/myisam/Makefile.am: Don't add internal test files to binary distributions support-files/Makefile.am: Make scripts executable support-files/config.huge.ini.sh: Removed execution bit support-files/config.medium.ini.sh: Removed execution bit support-files/config.small.ini.sh: Removed execution bit support-files/mysql.server.sh: Ensure this works also mysqld is in the 'bin' directory --- storage/myisam/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/Makefile.am b/storage/myisam/Makefile.am index 4bd0b177daa..ea942672856 100644 --- a/storage/myisam/Makefile.am +++ b/storage/myisam/Makefile.am @@ -28,7 +28,7 @@ LDADD = DEFS = @DEFS@ EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in -pkgdata_DATA = mi_test_all mi_test_all.res +pkgdata_DATA = pkglib_LIBRARIES = libmyisam.a bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump -- cgit v1.2.1 From d13c54351dd7ec5c538ff746704c6a8096b25776 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 30 Nov 2009 01:08:56 +0200 Subject: Remove compiler warnings (Including some warnings from -Wstrict-aliasing) Don't use static link by default (in compile-pentium) as some new systems doesn't have all static libraries available Change type for functions in plugin.h:str_mysql_ftparser_param() to const unsigned char and string lengths to size_t. One effect of the above change is that one needs to include mysql_global.h or define size_t before including plugin.h This fixes a case where mysql_client_test failed with newer gcc that enables strict-aliasing by default BUILD/compile-pentium: Don't use static link by default as some new systems doesn't have all static libraries available client/mysql_upgrade.c: Remove not used variable cmd-line-utils/readline/config_readline.h: Define some constants to get rid of compiler warnings on Linux cmd-line-utils/readline/display.c: Get rid of compiler warnings cmd-line-utils/readline/history.c: Got rid of compiler warnings: - Defining some strings as const - Added cast cmd-line-utils/readline/rlmbutil.h: Added cast to get rid of compiler warnings cmd-line-utils/readline/text.c: Remove not needed initialization to get rid of compiler warnings cmd-line-utils/readline/xmalloc.c: Changed types to 'const char* to get rid of compiler warnings configure.in: Ensure that we use MariaDB as suffix include/mysql/plugin.h: Changed types to 'const unsigned char* to get rid of compiler warnings (in other parts of the code) Change length for not \0 terminated string to size_t include/mysql/plugin.h.pp: Update related to plugin.h libmysql/libmysql.c: Fixed bug that caused core dump with newer gcc when strict aliasing is not turned off mysql-test/t/information_schema.test: Test is depending on innodb mysql-test/t/not_partition.test: Fixed wrong directory name (Not noticed before as we don't ususally run this test) mysys/lf_hash.c: Got rid of compiler warnings from -Wstrict-aliasing mysys/my_redel.c: Removed not used variable regex/engine.c: Changed types to 'const char* to get rid of compiler warnings regex/engine.ih: Changed types to 'const char* to get rid of compiler warnings sql/sp_head.cc: Got rid of compiler warning from -Wstrict-aliasing sql/sql_base.cc: Got rid of compiler warnings from -Wstrict-aliasing (The original code was probably wrong as nj_col->table_field was sql/sql_builtin.cc.in: plugin.h needs to have size_t defined sql/sql_parse.cc: Remove used variable sql/sql_select.cc: Got rid of compiler warnings from -Wstrict-aliasing sql/sql_show.cc: Added #ifdef to get rid of compiler warning when not using partition engine sql/table.cc: Got rid of compiler warning from -Wstrict-aliasing storage/maria/ha_maria.cc: Got rid of compiler warnings from -Wstrict-aliasing: - Use the thd_killed() API function storage/maria/lockman.c: Got rid of compiler warnings from -Wstrict-aliasing storage/maria/ma_check.c: Got rid of compiler warnings from -Wstrict-aliasing Change to use new version of _ma_killed_ptr; Don't call it as often as before storage/maria/ma_check_standalone.h: Update to compatible _ma_killed_ptr() from ha_maria.cc storage/maria/ma_ft_boolean_search.c: Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts) storage/maria/ma_ft_nlq_search.c: Got rid of compiler warnings from -Wstrict-aliasing Ensure that 'subkeys' is 32 bit storage/maria/ma_ft_parser.c: Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts) storage/maria/ma_ftdefs.h: Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts) storage/maria/ma_sort.c: Change to use new version of _ma_killed_ptr; Don't call it as often as before storage/maria/ma_state.c: Got rid of compiler warnings from -Wstrict-aliasing storage/maria/maria_def.h: Redefine ma_killed_ptr() storage/maria/maria_ftdump.c: Got rid of compiler warnings from -Wstrict-aliasing storage/maria/trnman.c: Got rid of compiler warnings from -Wstrict-aliasing storage/myisam/ft_boolean_search.c: Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts) storage/myisam/ft_nlq_search.c: Got rid of compiler warnings from -Wstrict-aliasing storage/myisam/ft_parser.c: Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts) storage/myisam/ft_stopwords.c: Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts) storage/myisam/ftdefs.h: Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts) storage/myisam/ha_myisam.cc: Got rid of compiler warnings from -Wstrict-aliasing: - Use the thd_killed() API function storage/myisam/mi_check.c: Use new killed_ptr() function storage/myisam/myisam_ftdump.c: Got rid of compiler warnings from -Wstrict-aliasing storage/myisam/myisamchk.c: Update to compatible killed_ptr() from ha_myisam.cc storage/myisam/myisamdef.h: Redefine killed_ptr() storage/myisam/myisamlog.c: Got rid of compiler warnings from -Wstrict-aliasing storage/myisam/sort.c: Change to use new version of killed_ptr; Don't call it as often as before storage/xtradb/fil/fil0fil.c: Fixedc ompiler warning storage/xtradb/trx/trx0i_s.c: Include mysql_plugin.h later to ensure that size_t is defined --- storage/myisam/ft_boolean_search.c | 36 ++++++++++++++++++------------------ storage/myisam/ft_nlq_search.c | 6 ++++-- storage/myisam/ft_parser.c | 32 +++++++++++++++++--------------- storage/myisam/ft_stopwords.c | 5 +++-- storage/myisam/ftdefs.h | 10 +++++----- storage/myisam/ha_myisam.cc | 5 ++--- storage/myisam/mi_check.c | 10 +++++----- storage/myisam/myisam_ftdump.c | 2 +- storage/myisam/myisamchk.c | 6 ++---- storage/myisam/myisamdef.h | 2 +- storage/myisam/myisamlog.c | 2 +- storage/myisam/sort.c | 11 ++++++----- 12 files changed, 65 insertions(+), 62 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index ddb932e234e..193ce510f98 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -180,7 +180,7 @@ typedef struct st_my_ftb_param static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, - char *word, int word_len, + const uchar *word, size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *info) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; @@ -282,19 +282,19 @@ static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, - char *query, int len) + const uchar *query, size_t len) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; MYSQL_FTPARSER_BOOLEAN_INFO info; CHARSET_INFO *cs= ftb_param->ftb->charset; - uchar **start= (uchar**) &query; - uchar *end= (uchar*) query + len; + const uchar **start= &query; + const uchar *end= query + len; FT_WORD w; info.prev= ' '; info.quot= 0; while (ft_get_word(cs, start, end, &w, &info)) - param->mysql_add_word(param, (char*) w.pos, w.len, &info); + param->mysql_add_word(param, w.pos, w.len, &info); return(0); } @@ -616,7 +616,7 @@ typedef struct st_my_ftb_phrase_param static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, - char *word, int word_len, + const uchar *word, size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) { MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; @@ -648,15 +648,15 @@ static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, - char *document, int len) + const uchar *document, size_t len) { FT_WORD word; MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; const uchar *docend= (uchar*) document + len; - while (ft_simple_get_word(phrase_param->cs, (uchar**) &document, docend, + while (ft_simple_get_word(phrase_param->cs, &document, docend, &word, FALSE)) { - param->mysql_add_word(param, (char*) word.pos, word.len, 0); + param->mysql_add_word(param, word.pos, word.len, 0); if (phrase_param->match) break; } @@ -874,7 +874,7 @@ typedef struct st_my_ftb_find_param static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, - char *word, int len, + const uchar *word, size_t len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; @@ -888,8 +888,8 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, for (a= 0, b= ftb->queue.elements, c= (a+b)/2; b-a>1; c= (a+b)/2) { ftbw= ftb->list[c]; - if (ha_compare_text(ftb->charset, (uchar*)word, len, - (uchar*)ftbw->word+1, ftbw->len-1, + if (ha_compare_text(ftb->charset, word, len, + ftbw->word+1, ftbw->len-1, (my_bool) (ftbw->flags & FTB_FLAG_TRUNC), 0) < 0) b= c; else @@ -915,8 +915,8 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, for (; c >= 0; c--) { ftbw= ftb->list[c]; - if (ha_compare_text(ftb->charset, (uchar*)word, len, - (uchar*)ftbw->word + 1,ftbw->len - 1, + if (ha_compare_text(ftb->charset, word, len, + ftbw->word + 1,ftbw->len - 1, (my_bool)(ftbw->flags & FTB_FLAG_TRUNC), 0)) { if (ftb->with_scan & FTB_FLAG_TRUNC) @@ -935,14 +935,14 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_find_relevance_parse(MYSQL_FTPARSER_PARAM *param, - char *doc, int len) + const uchar *doc, size_t len) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; FT_INFO *ftb= ftb_param->ftb; - uchar *end= (uchar*) doc + len; + const uchar *end= doc + len; FT_WORD w; - while (ft_simple_get_word(ftb->charset, (uchar**) &doc, end, &w, TRUE)) - param->mysql_add_word(param, (char*) w.pos, w.len, 0); + while (ft_simple_get_word(ftb->charset, &doc, end, &w, TRUE)) + param->mysql_add_word(param, w.pos, w.len, 0); return(0); } diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index eb563638d36..da593a3debc 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -63,7 +63,8 @@ static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)), static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) { - int subkeys, r; + int32 subkeys; + int r; uint keylen, doc_cnt; FT_SUPERDOC sdoc, *sptr; TREE_ELEMENT *selem; @@ -123,7 +124,8 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) goto do_skip; } #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT - tmp_weight=*(float*)&subkeys; + /* The weight we read was actually a float */ + tmp_weight=*(float*) (char*) &subkeys; #else #error #endif diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index 4cde3834ed7..cacedaaeea0 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -106,10 +106,10 @@ my_bool ft_boolean_check_syntax_string(const uchar *str) 3 - right bracket 4 - stopword found */ -uchar ft_get_word(CHARSET_INFO *cs, uchar **start, uchar *end, +uchar ft_get_word(CHARSET_INFO *cs, const uchar **start, const uchar *end, FT_WORD *word, MYSQL_FTPARSER_BOOLEAN_INFO *param) { - uchar *doc=*start; + const uchar *doc= *start; int ctype; uint mwc, length; int mbl; @@ -201,10 +201,11 @@ ret: return param->type; } -uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, - FT_WORD *word, my_bool skip_stopwords) +uchar ft_simple_get_word(CHARSET_INFO *cs, const uchar **start, + const uchar *end, FT_WORD *word, + my_bool skip_stopwords) { - uchar *doc= *start; + const uchar *doc= *start; uint mwc, length; int mbl; int ctype; @@ -216,7 +217,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, { if (doc >= end) DBUG_RETURN(0); - mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end); + mbl= cs->cset->ctype(cs, &ctype, doc, end); if (true_word_char(ctype, *doc)) break; } @@ -225,7 +226,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end); + mbl= cs->cset->ctype(cs, &ctype, doc, end); if (true_word_char(ctype, *doc)) mwc= 0; else if (!misc_word_char(*doc) || mwc) @@ -238,7 +239,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, if (skip_stopwords == FALSE || (length >= ft_min_word_len && length < ft_max_word_len && - !is_stopword((char*) word->pos, word->len))) + !is_stopword(word->pos, word->len))) { *start= doc; DBUG_RETURN(1); @@ -257,8 +258,9 @@ void ft_parse_init(TREE *wtree, CHARSET_INFO *cs) static int ft_add_word(MYSQL_FTPARSER_PARAM *param, - char *word, int word_len, - MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) + const uchar *word, size_t word_len, + MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info + __attribute__((unused))) { TREE *wtree; FT_WORD w; @@ -286,10 +288,10 @@ static int ft_add_word(MYSQL_FTPARSER_PARAM *param, static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, - char *doc_arg, int doc_len) + const uchar *doc_arg, size_t doc_len) { - uchar *doc= (uchar*) doc_arg; - uchar *end= doc + doc_len; + const uchar *doc= doc_arg; + const uchar *end= doc + doc_len; MY_FT_PARSER_PARAM *ft_param=param->mysql_ftparam; TREE *wtree= ft_param->wtree; FT_WORD w; @@ -302,7 +304,7 @@ static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, } -int ft_parse(TREE *wtree, uchar *doc, int doclen, +int ft_parse(TREE *wtree, const uchar *doc, int doclen, struct st_mysql_ftparser *parser, MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root) { @@ -377,7 +379,7 @@ MYSQL_FTPARSER_PARAM *ftparser_call_initializer(MI_INFO *info, mysql_add_word != 0 - parser is initialized, or no initialization needed. */ info->ftparser_param[ftparser_nr].mysql_add_word= - (int (*)(struct st_mysql_ftparser_param *, char *, int, + (int (*)(struct st_mysql_ftparser_param *, const uchar *, size_t, MYSQL_FTPARSER_BOOLEAN_INFO *)) 1; if (parser->init && parser->init(&info->ftparser_param[ftparser_nr])) return 0; diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 8aefffbee1d..db4cd3b32b6 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -66,7 +66,8 @@ int ft_init_stopwords() { File fd; uint len; - uchar *buffer, *start, *end; + uchar *buffer; + const uchar *start, *end; FT_WORD w; int error=-1; @@ -109,7 +110,7 @@ err0: } -int is_stopword(char *word, uint len) +int is_stopword(const uchar *word, size_t len) { FT_STOPWORD sw; sw.pos=word; diff --git a/storage/myisam/ftdefs.h b/storage/myisam/ftdefs.h index ddcf1a8dc26..2b4c46c78ad 100644 --- a/storage/myisam/ftdefs.h +++ b/storage/myisam/ftdefs.h @@ -96,18 +96,18 @@ #define FTB_RQUOT (ft_boolean_syntax[11]) typedef struct st_ft_word { - uchar * pos; + const uchar *pos; uint len; double weight; } FT_WORD; -int is_stopword(char *word, uint len); +int is_stopword(const uchar *word, size_t len); uint _ft_make_key(MI_INFO *, uint , uchar *, FT_WORD *, my_off_t); -uchar ft_get_word(CHARSET_INFO *, uchar **, uchar *, FT_WORD *, +uchar ft_get_word(CHARSET_INFO *, const uchar **, const uchar *, FT_WORD *, MYSQL_FTPARSER_BOOLEAN_INFO *); -uchar ft_simple_get_word(CHARSET_INFO *, uchar **, const uchar *, +uchar ft_simple_get_word(CHARSET_INFO *, const uchar **, const uchar *, FT_WORD *, my_bool); typedef struct _st_ft_seg_iterator { @@ -121,7 +121,7 @@ void _mi_ft_segiterator_dummy_init(const uchar *, uint, FT_SEG_ITERATOR *); uint _mi_ft_segiterator(FT_SEG_ITERATOR *); void ft_parse_init(TREE *, CHARSET_INFO *); -int ft_parse(TREE *, uchar *, int, struct st_mysql_ftparser *parser, +int ft_parse(TREE *, const uchar *, int, struct st_mysql_ftparser *parser, MYSQL_FTPARSER_PARAM *, MEM_ROOT *); FT_WORD * ft_linearize(TREE *, MEM_ROOT *); FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, const uchar *, MEM_ROOT *); diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index fd35410682e..930f8ed8c59 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -497,10 +497,9 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, extern "C" { -volatile int *killed_ptr(HA_CHECK *param) +int killed_ptr(HA_CHECK *param) { - /* In theory Unsafe conversion, but should be ok for now */ - return (int*) &(((THD *)(param->thd))->killed); + return thd_killed((THD*)param->thd); } void mi_check_print_error(HA_CHECK *param, const char *fmt,...) diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index c6140e0bcd8..ac90f41e80d 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -166,7 +166,7 @@ int chk_del(HA_CHECK *param, register MI_INFO *info, ulonglong test_flag) empty=0; for (i= info->state->del ; i > 0L && next_link != HA_OFFSET_ERROR ; i--) { - if (*killed_ptr(param)) + if (killed_ptr(param)) DBUG_RETURN(1); if (test_flag & T_VERBOSE) printf(" %9s",llstr(next_link,buff)); @@ -261,7 +261,7 @@ static int check_k_link(HA_CHECK *param, register MI_INFO *info, uint nr) records= (ha_rows) (info->state->key_file_length / block_size); while (next_link != HA_OFFSET_ERROR && records > 0) { - if (*killed_ptr(param)) + if (killed_ptr(param)) DBUG_RETURN(1); if (param->testflag & T_VERBOSE) printf("%16s",llstr(next_link,llbuff)); @@ -778,7 +778,7 @@ static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, } for ( ;; ) { - if (*killed_ptr(param)) + if (killed_ptr(param)) goto err; memcpy((char*) info->lastkey,(char*) key,key_length); info->lastkey_length=key_length; @@ -990,7 +990,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) bzero((char*) key_checksum, info->s->base.keys * sizeof(key_checksum[0])); while (pos < info->state->data_file_length) { - if (*killed_ptr(param)) + if (killed_ptr(param)) goto err2; switch (info->s->data_file_type) { case BLOCK_RECORD: @@ -3247,7 +3247,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) char llbuff[22],llbuff2[22]; DBUG_ENTER("sort_get_next_record"); - if (*killed_ptr(param)) + if (killed_ptr(param)) DBUG_RETURN(1); switch (share->data_file_type) { diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c index 63d954242a0..b7b035559f7 100644 --- a/storage/myisam/myisam_ftdump.c +++ b/storage/myisam/myisam_ftdump.c @@ -113,7 +113,7 @@ int main(int argc,char *argv[]) subkeys=ft_sintXkorr(info->lastkey+keylen+1); if (subkeys >= 0) - weight=*(float*)&subkeys; + weight= *(float*) (char*) &subkeys; #ifdef HAVE_SNPRINTF snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey+1); diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 6b3ea48e040..b4b4a0215c2 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1745,11 +1745,9 @@ err: sorting */ -static int not_killed= 0; - -volatile int *killed_ptr(HA_CHECK *param __attribute__((unused))) +int killed_ptr(HA_CHECK *param __attribute__((unused))) { - return ¬_killed; /* always NULL */ + return 0; } /* print warnings and errors */ diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index c2841c49199..680bdbf16dd 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -725,7 +725,7 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size); void mi_remap_file(MI_INFO *info, my_off_t size); /* Functions needed by mi_check */ -volatile int *killed_ptr(HA_CHECK *param); +int killed_ptr(HA_CHECK *param); void mi_check_print_error _VARARGS((HA_CHECK *param, const char *fmt, ...)); void mi_check_print_warning _VARARGS((HA_CHECK *param, const char *fmt, ...)); void mi_check_print_info _VARARGS((HA_CHECK *param, const char *fmt, ...)); diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index 6e681676c12..679dc0b731b 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -385,7 +385,7 @@ static int examine_log(char * file_name, char **table_names) file_info.name=0; file_info.show_name=0; file_info.record=0; - if (read_string(&cache,(uchar**) &file_info.name, + if (read_string(&cache,(uchar**) (char*) &file_info.name, (uint) mi_uint2korr(head))) goto err; { diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index 3aaef41e1dd..607ddd66d3c 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -900,7 +900,6 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, uchar *strpos; BUFFPEK *buffpek,**refpek; QUEUE queue; - volatile int *killed= killed_ptr(info->sort_info->param); DBUG_ENTER("merge_buffers"); count=error=0; @@ -933,10 +932,6 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, { for (;;) { - if (*killed) - { - error=1; goto err; - } buffpek=(BUFFPEK*) queue_top(&queue); if (to_file) { @@ -956,6 +951,12 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, buffpek->key+=sort_length; if (! --buffpek->mem_count) { + /* It's enough to check for killedptr before a slow operation */ + if (killed_ptr(info->sort_info->param)) + { + error=1; + goto err; + } if (!(error=(int) info->read_to_buffer(from_file,buffpek,sort_length))) { uchar *base= buffpek->base; -- cgit v1.2.1 From 0df8279c468235f4feaf9eb25aa2beb5032ee1dc Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 30 Nov 2009 15:36:06 +0200 Subject: Fixes after comments from last push: - Removed some not needed casts - Change plugin.h to be 'binary compatible' with old versions - Added mysql_ft_size_t typedef to plugin.h to make it trivial to change string lengths to size_t on next ABI change - Made some fixes suggested by Kristian to make things more portable and future safe (when it comes to strict aliasing) include/ft_global.h: Introduced FT_WEIGTH, to handle fulltext weights in a slightly more portable manner include/mysql/plugin.h: Change plugin.h to be 'binary compatible' with old versions Added mysql_ft_size_t typedef to plugin.h to make it trivial to change string lengths to size_t on next ABI change Changed flags to unsigned (as flags should always be unsigned) mysql-test/t/information_schema.test: Fixed typo sql/sp_head.cc: Removed cast sql/sql_select.cc: Removed cast sql/table.cc: Removed cast storage/maria/ma_ft_boolean_search.c: Use mysql_ft_size_t instead of size_t for plugin.h code Changed some other string lengths to size_t storage/maria/ma_ft_nlq_search.c: Use FT_WEIGTH to make code more portable storage/maria/ma_ft_parser.c: Use mysql_ft_size_t instead of size_t for plugin.h code Changed some other string lengths to size_t storage/maria/ma_ftdefs.h: Changed some string lengths to size_t storage/maria/maria_ftdump.c: Use FT_WEIGTH to make code more portable storage/myisam/ft_boolean_search.c: Use mysql_ft_size_t instead of size_t for plugin.h code storage/myisam/ft_nlq_search.c: Use FT_WEIGTH to make code more portable storage/myisam/ft_parser.c: Use mysql_ft_size_t instead of size_t for plugin.h code storage/myisam/myisam_ftdump.c: Use FT_WEIGTH to make code more portable --- storage/myisam/ft_boolean_search.c | 16 +++++++++------- storage/myisam/ft_nlq_search.c | 10 +++++----- storage/myisam/ft_parser.c | 8 ++++---- storage/myisam/myisam_ftdump.c | 15 ++++++++------- 4 files changed, 26 insertions(+), 23 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 193ce510f98..b09d8c43321 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -180,7 +180,7 @@ typedef struct st_my_ftb_param static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t word_len, + const uchar *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *info) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; @@ -282,7 +282,7 @@ static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, - const uchar *query, size_t len) + const uchar *query, mysql_ft_size_t len) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; MYSQL_FTPARSER_BOOLEAN_INFO info; @@ -616,7 +616,7 @@ typedef struct st_my_ftb_phrase_param static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t word_len, + const uchar *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) { MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; @@ -648,7 +648,8 @@ static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, - const uchar *document, size_t len) + const uchar *document, + mysql_ft_size_t len) { FT_WORD word; MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; @@ -874,8 +875,9 @@ typedef struct st_my_ftb_find_param static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t len, - MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) + const uchar *word, mysql_ft_size_t len, + MYSQL_FTPARSER_BOOLEAN_INFO + *boolean_info __attribute__((unused))) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; FT_INFO *ftb= ftb_param->ftb; @@ -935,7 +937,7 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_find_relevance_parse(MYSQL_FTPARSER_PARAM *param, - const uchar *doc, size_t len) + const uchar *doc, mysql_ft_size_t len) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; FT_INFO *ftb= ftb_param->ftb; diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index da593a3debc..c4d27bcbd8e 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -63,7 +63,7 @@ static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)), static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) { - int32 subkeys; + FT_WEIGTH subkeys; int r; uint keylen, doc_cnt; FT_SUPERDOC sdoc, *sptr; @@ -91,7 +91,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) /* Skip rows inserted by current inserted */ for (r=_mi_search(info, keyinfo, keybuff, keylen, SEARCH_FIND, key_root) ; !r && - (subkeys=ft_sintXkorr(info->lastkey+info->lastkey_length-extra)) > 0 && + (subkeys.i= ft_sintXkorr(info->lastkey+info->lastkey_length-extra)) > 0 && info->lastpos >= info->state->data_file_length ; r= _mi_search_next(info, keyinfo, info->lastkey, info->lastkey_length, SEARCH_BIGGER, key_root)) @@ -108,7 +108,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) info->lastkey_length-extra-1, keybuff+1,keylen-1,0,0)) break; - if (subkeys<0) + if (subkeys.i < 0) { if (doc_cnt) DBUG_RETURN(1); /* index is corrupted */ @@ -125,7 +125,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) } #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT /* The weight we read was actually a float */ - tmp_weight=*(float*) (char*) &subkeys; + tmp_weight= subkeys.f; #else #error #endif @@ -162,7 +162,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) r=_mi_search(info, keyinfo, info->lastkey, info->lastkey_length, SEARCH_BIGGER, key_root); do_skip: - while ((subkeys=ft_sintXkorr(info->lastkey+info->lastkey_length-extra)) > 0 && + while ((subkeys.i= ft_sintXkorr(info->lastkey+info->lastkey_length-extra)) > 0 && !r && info->lastpos >= info->state->data_file_length) r= _mi_search_next(info, keyinfo, info->lastkey, info->lastkey_length, SEARCH_BIGGER, key_root); diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index cacedaaeea0..e4d500f6d8a 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -258,7 +258,7 @@ void ft_parse_init(TREE *wtree, CHARSET_INFO *cs) static int ft_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t word_len, + const uchar *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) { @@ -288,7 +288,7 @@ static int ft_add_word(MYSQL_FTPARSER_PARAM *param, static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, - const uchar *doc_arg, size_t doc_len) + const uchar *doc_arg, mysql_ft_size_t doc_len) { const uchar *doc= doc_arg; const uchar *end= doc + doc_len; @@ -379,8 +379,8 @@ MYSQL_FTPARSER_PARAM *ftparser_call_initializer(MI_INFO *info, mysql_add_word != 0 - parser is initialized, or no initialization needed. */ info->ftparser_param[ftparser_nr].mysql_add_word= - (int (*)(struct st_mysql_ftparser_param *, const uchar *, size_t, - MYSQL_FTPARSER_BOOLEAN_INFO *)) 1; + (int (*)(struct st_mysql_ftparser_param *, const uchar *, + mysql_ft_size_t, MYSQL_FTPARSER_BOOLEAN_INFO *)) 1; if (parser->init && parser->init(&info->ftparser_param[ftparser_nr])) return 0; } diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c index b7b035559f7..3eecb08bd99 100644 --- a/storage/myisam/myisam_ftdump.c +++ b/storage/myisam/myisam_ftdump.c @@ -53,7 +53,7 @@ static struct my_option my_long_options[] = int main(int argc,char *argv[]) { - int error=0, subkeys; + int error=0; uint keylen, keylen2=0, inx, doc_cnt=0; float weight= 1.0; double gws, min_gws=0, avg_gws=0; @@ -109,11 +109,12 @@ int main(int argc,char *argv[]) while (!(error=mi_rnext(info,NULL,inx))) { + FT_WEIGTH subkeys; keylen=*(info->lastkey); - subkeys=ft_sintXkorr(info->lastkey+keylen+1); - if (subkeys >= 0) - weight= *(float*) (char*) &subkeys; + subkeys.i =ft_sintXkorr(info->lastkey+keylen+1); + if (subkeys.i >= 0) + weight= subkeys.f; #ifdef HAVE_SNPRINTF snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey+1); @@ -150,14 +151,14 @@ int main(int argc,char *argv[]) keylen2=keylen; doc_cnt=0; } - doc_cnt+= (subkeys >= 0 ? 1 : -subkeys); + doc_cnt+= (subkeys.i >= 0 ? 1 : -subkeys.i); } if (dump) { - if (subkeys>=0) + if (subkeys.i >= 0) printf("%9lx %20.7f %s\n", (long) info->lastpos,weight,buf); else - printf("%9lx => %17d %s\n",(long) info->lastpos,-subkeys,buf); + printf("%9lx => %17d %s\n",(long) info->lastpos,-subkeys.i,buf); } if (verbose && (total%HOW_OFTEN_TO_WRITE)==0) printf("%10ld\r",total); -- cgit v1.2.1 From 96e092dc73529978053c1e41aa09b70fd2c7c408 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 15 Dec 2009 10:16:46 +0300 Subject: Backport into MariaDB-5.2 the following: WL#2474 "Multi Range Read: Change the default MRR implementation to implement new MRR interface" WL#2475 "Batched range read functions for MyISAM/InnoDb" "Index condition pushdown for MyISAM/InnoDB" Igor's fix from sp1r-igor@olga.mysql.com-20080330055902-07614: There could be observed the following problems: 1. EXPLAIN did not mention pushdown conditions from on expressions in the 'extra' column. As a result if a query had no where conditions pushed down to a table, but had on conditions pushed to this table the 'extra' column in the EXPLAIN for the table missed 'using where'. 2. Conditions for ref access were not eliminated from on expressions though such conditions were eliminated from the where condition. --- storage/myisam/ha_myisam.cc | 103 +++++++++++++++++++++++++++++++++++++++++ storage/myisam/ha_myisam.h | 29 +++++++++++- storage/myisam/mi_extra.c | 6 +++ storage/myisam/mi_key.c | 57 ++++++++++++++++++----- storage/myisam/mi_rkey.c | 92 +++++++++++++++++++----------------- storage/myisam/mi_rnext.c | 40 ++++++++++------ storage/myisam/mi_rnext_same.c | 3 +- storage/myisam/mi_rprev.c | 38 ++++++++++----- storage/myisam/myisamdef.h | 6 +++ 9 files changed, 294 insertions(+), 80 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index d92a576a5d7..7e319fc80f6 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1676,6 +1676,48 @@ int ha_myisam::delete_row(const uchar *buf) return mi_delete(file,buf); } + +C_MODE_START + +ICP_RESULT index_cond_func_myisam(void *arg) +{ + ha_myisam *h= (ha_myisam*)arg; + if (h->end_range) + { + if (h->compare_key2(h->end_range) > 0) + return ICP_OUT_OF_RANGE; /* caller should return HA_ERR_END_OF_FILE already */ + } + return (ICP_RESULT) test(h->pushed_idx_cond->val_int()); +} + +C_MODE_END + + +int ha_myisam::index_init(uint idx, bool sorted) +{ + active_index=idx; + if (pushed_idx_cond_keyno == idx) + mi_set_index_cond_func(file, index_cond_func_myisam, this); + return 0; +} + + +int ha_myisam::index_end() +{ + active_index=MAX_KEY; + //pushed_idx_cond_keyno= MAX_KEY; + mi_set_index_cond_func(file, NULL, 0); + in_range_check_pushed_down= FALSE; + ds_mrr.dsmrr_close(); + return 0; +} + +int ha_myisam::rnd_end() +{ + ds_mrr.dsmrr_close(); + return 0; +} + int ha_myisam::index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) @@ -1878,8 +1920,13 @@ int ha_myisam::extra(enum ha_extra_function operation) return mi_extra(file, operation, 0); } + int ha_myisam::reset(void) { + pushed_idx_cond= NULL; + pushed_idx_cond_keyno= MAX_KEY; + mi_set_index_cond_func(file, NULL, 0); + ds_mrr.dsmrr_close(); return mi_reset(file); } @@ -2164,6 +2211,62 @@ static int myisam_init(void *p) return 0; } +/**************************************************************************** + * MyISAM MRR implementation: use DS-MRR + ***************************************************************************/ + +int ha_myisam::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, + uint n_ranges, uint mode, + HANDLER_BUFFER *buf) +{ + return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf); +} + +int ha_myisam::multi_range_read_next(char **range_info) +{ + return ds_mrr.dsmrr_next(range_info); +} + +ha_rows ha_myisam::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, uint *bufsz, + uint *flags, COST_VECT *cost) +{ + /* + This call is here because there is no location where this->table would + already be known. + TODO: consider moving it into some per-query initialization call. + */ + ds_mrr.init(this, table); + return ds_mrr.dsmrr_info_const(keyno, seq, seq_init_param, n_ranges, bufsz, + flags, cost); +} + +ha_rows ha_myisam::multi_range_read_info(uint keyno, uint n_ranges, uint keys, + uint *bufsz, uint *flags, + COST_VECT *cost) +{ + ds_mrr.init(this, table); + return ds_mrr.dsmrr_info(keyno, n_ranges, keys, bufsz, flags, cost); +} + +/* MyISAM MRR implementation ends */ + + +/* Index condition pushdown implementation*/ + + +Item *ha_myisam::idx_cond_push(uint keyno_arg, Item* idx_cond_arg) +{ + pushed_idx_cond_keyno= keyno_arg; + pushed_idx_cond= idx_cond_arg; + in_range_check_pushed_down= TRUE; + if (active_index == pushed_idx_cond_keyno) + mi_set_index_cond_func(file, index_cond_func_myisam, this); + return NULL; +} + + struct st_mysql_storage_engine myisam_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 7a1595573d4..76db0e89536 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -34,6 +34,10 @@ extern ulong myisam_sort_buffer_size; extern TYPELIB myisam_recover_typelib; extern ulong myisam_recover_options; +C_MODE_START +ICP_RESULT index_cond_func_myisam(void *arg); +C_MODE_END + class ha_myisam: public handler { MI_INFO *file; @@ -50,11 +54,15 @@ class ha_myisam: public handler const char *index_type(uint key_number); const char **bas_ext() const; ulonglong table_flags() const { return int_table_flags; } + int index_init(uint idx, bool sorted); + int index_end(); + int rnd_end(); + ulong index_flags(uint inx, uint part, bool all_parts) const { return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | - HA_READ_ORDER | HA_KEYREAD_ONLY); + HA_READ_ORDER | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN); } uint max_supported_keys() const { return MI_MAX_KEY; } uint max_supported_key_length() const { return HA_MAX_KEY_LENGTH; } @@ -149,4 +157,23 @@ class ha_myisam: public handler { return file; } +public: + /** + * Multi Range Read interface + */ + int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, + uint n_ranges, uint mode, HANDLER_BUFFER *buf); + int multi_range_read_next(char **range_info); + ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, uint *bufsz, + uint *flags, COST_VECT *cost); + ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, + uint *bufsz, uint *flags, COST_VECT *cost); + + /* Index condition pushdown implementation */ + Item *idx_cond_push(uint keyno, Item* idx_cond); +private: + DsMrr_impl ds_mrr; + friend ICP_RESULT index_cond_func_myisam(void *arg); }; diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 9c5dade28ab..7bb79108357 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -403,6 +403,12 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) DBUG_RETURN(error); } /* mi_extra */ +void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t func, + void *func_arg) +{ + info->index_cond_func= func; + info->index_cond_func_arg= func_arg; +} /* Start/Stop Inserting Duplicates Into a Table, WL#1648. diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index 94f3f34ec58..aab5797a03b 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -31,7 +31,8 @@ set_if_smaller(char_length,length); \ } while(0) -static int _mi_put_key_in_record(MI_INFO *info,uint keynr,uchar *record); +static int _mi_put_key_in_record(MI_INFO *info,uint keynr, + my_bool unpack_blobs, uchar *record); /* Make a intern key from a record @@ -312,6 +313,9 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, _mi_put_key_in_record() info MyISAM handler keynr Key number that was used + unpack_blobs TRUE <=> Unpack blob columns + FALSE <=> Skip them. This is used by index condition + pushdown check function record Store key here Last read key is in info->lastkey @@ -325,7 +329,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, */ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, - uchar *record) + my_bool unpack_blobs, uchar *record) { reg2 uchar *key; uchar *pos,*key_end; @@ -418,16 +422,19 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, if (length > keyseg->length || key+length > key_end) goto err; #endif - memcpy(record+keyseg->start+keyseg->bit_start, - (char*) &blob_ptr,sizeof(char*)); - memcpy(blob_ptr,key,length); - blob_ptr+=length; + if (unpack_blobs) + { + memcpy(record+keyseg->start+keyseg->bit_start, + (char*) &blob_ptr,sizeof(char*)); + memcpy(blob_ptr,key,length); + blob_ptr+=length; - /* The above changed info->lastkey2. Inform mi_rnext_same(). */ - info->update&= ~HA_STATE_RNEXT_SAME; + /* The above changed info->lastkey2. Inform mi_rnext_same(). */ + info->update&= ~HA_STATE_RNEXT_SAME; - _mi_store_blob_length(record+keyseg->start, - (uint) keyseg->bit_start,length); + _mi_store_blob_length(record+keyseg->start, + (uint) keyseg->bit_start,length); + } key+=length; } else if (keyseg->flag & HA_SWAP_KEY) @@ -471,7 +478,7 @@ int _mi_read_key_record(MI_INFO *info, my_off_t filepos, uchar *buf) { if (info->lastinx >= 0) { /* Read only key */ - if (_mi_put_key_in_record(info,(uint) info->lastinx,buf)) + if (_mi_put_key_in_record(info,(uint) info->lastinx, TRUE, buf)) { mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; @@ -486,6 +493,34 @@ int _mi_read_key_record(MI_INFO *info, my_off_t filepos, uchar *buf) } +/* + Save current key tuple to record and call index condition check function + + SYNOPSIS + mi_check_index_cond() + info MyISAM handler + keynr Index we're running a scan on + record Record buffer to use (it is assumed that index check function + will look for column values there) + + RETURN + -1 Error + 0 Index condition is not satisfied, continue scanning + 1 Index condition is satisfied + 2 Index condition is not satisfied, end the scan. +*/ + +int mi_check_index_cond(register MI_INFO *info, uint keynr, uchar *record) +{ + if (_mi_put_key_in_record(info, keynr, FALSE, record)) + { + mi_print_error(info->s, HA_ERR_CRASHED); + my_errno=HA_ERR_CRASHED; + return -1; + } + return info->index_cond_func(info->index_cond_func_arg); +} + /* Retrieve auto_increment info diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c index f20b0366683..47e2ce51a9e 100644 --- a/storage/myisam/mi_rkey.c +++ b/storage/myisam/mi_rkey.c @@ -29,6 +29,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, MI_KEYDEF *keyinfo; HA_KEYSEG *last_used_keyseg; uint pack_key_length, use_key_length, nextflag; + int res= 0; DBUG_ENTER("mi_rkey"); DBUG_PRINT("enter", ("base: 0x%lx buf: 0x%lx inx: %d search_flag: %d", (long) info, (long) buf, inx, search_flag)); @@ -105,55 +106,62 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, saved the current data_file_length. Concurrent inserts always go to the end of the file. So we can test if the found key references a new record. + + If we are searching for a partial key (or using >, >=, < or <=) and + the data is outside of the data file, we need to continue searching + for the first key inside the data file. + + We do also continue searching if an index condition check function + is available. */ - if (info->lastpos >= info->state->data_file_length) + while ((info->lastpos >= info->state->data_file_length && + (search_flag != HA_READ_KEY_EXACT || + last_used_keyseg != keyinfo->seg + keyinfo->keysegs)) || + (info->index_cond_func && + !(res= mi_check_index_cond(info, inx, buf)))) { - /* The key references a concurrently inserted record. */ + uint not_used[2]; + /* + Skip rows that are inserted by other threads since we got a lock + Note that this can only happen if we are not searching after an + full length exact key, because the keys are sorted + according to position + */ + if (_mi_search_next(info, keyinfo, info->lastkey, + info->lastkey_length, + myisam_readnext_vec[search_flag], + info->s->state.key_root[inx])) + break; + /* + Check that the found key does still match the search. + _mi_search_next() delivers the next key regardless of its + value. + */ if (search_flag == HA_READ_KEY_EXACT && - last_used_keyseg == keyinfo->seg + keyinfo->keysegs) + ha_key_cmp(keyinfo->seg, key_buff, info->lastkey, use_key_length, + SEARCH_FIND, not_used)) { - /* Simply ignore the key if it matches exactly. (Bug #29838) */ my_errno= HA_ERR_KEY_NOT_FOUND; info->lastpos= HA_OFFSET_ERROR; + break; } - else - { - /* - If searching for a partial key (or using >, >=, < or <=) and - the data is outside of the data file, we need to continue - searching for the first key inside the data file. - */ - do - { - uint not_used[2]; - /* - Skip rows that are inserted by other threads since we got - a lock. Note that this can only happen if we are not - searching after a full length exact key, because the keys - are sorted according to position. - */ - if (_mi_search_next(info, keyinfo, info->lastkey, - info->lastkey_length, - myisam_readnext_vec[search_flag], - info->s->state.key_root[inx])) - break; /* purecov: inspected */ - /* - Check that the found key does still match the search. - _mi_search_next() delivers the next key regardless of its - value. - */ - if (search_flag == HA_READ_KEY_EXACT && - ha_key_cmp(keyinfo->seg, key_buff, info->lastkey, - use_key_length, SEARCH_FIND, not_used)) - { - /* purecov: begin inspected */ - my_errno= HA_ERR_KEY_NOT_FOUND; - info->lastpos= HA_OFFSET_ERROR; - break; - /* purecov: end */ - } - } while (info->lastpos >= info->state->data_file_length); - } + } + if (res == 2) + { + info->lastpos= HA_OFFSET_ERROR; + if (share->concurrent_insert) + rw_unlock(&share->key_root_lock[inx]); + DBUG_RETURN((my_errno= HA_ERR_KEY_NOT_FOUND)); + } + /* + Error if no row found within the data file. (Bug #29838) + Do not overwrite my_errno if already at HA_OFFSET_ERROR. + */ + if (info->lastpos != HA_OFFSET_ERROR && + info->lastpos >= info->state->data_file_length) + { + info->lastpos= HA_OFFSET_ERROR; + my_errno= HA_ERR_KEY_NOT_FOUND; } } } diff --git a/storage/myisam/mi_rnext.c b/storage/myisam/mi_rnext.c index 7ce66d41e0f..ad5ec60dc98 100644 --- a/storage/myisam/mi_rnext.c +++ b/storage/myisam/mi_rnext.c @@ -28,6 +28,7 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx) { int error,changed; uint flag; + int res= 0; DBUG_ENTER("mi_rnext"); if ((inx = _mi_check_index(info,inx)) < 0) @@ -81,23 +82,36 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx) } } - if (info->s->concurrent_insert) + if (!error) { - if (!error) + while ((info->s->concurrent_insert && + info->lastpos >= info->state->data_file_length) || + (info->index_cond_func && + !(res= mi_check_index_cond(info, inx, buf)))) { - while (info->lastpos >= info->state->data_file_length) - { - /* Skip rows inserted by other threads since we got a lock */ - if ((error=_mi_search_next(info,info->s->keyinfo+inx, - info->lastkey, - info->lastkey_length, - SEARCH_BIGGER, - info->s->state.key_root[inx]))) - break; - } + /* + Skip rows that are either inserted by other threads since + we got a lock or do not match pushed index conditions + */ + if ((error=_mi_search_next(info,info->s->keyinfo+inx, + info->lastkey, + info->lastkey_length, + SEARCH_BIGGER, + info->s->state.key_root[inx]))) + break; + } + if (!error && res == 2) + { + if (info->s->concurrent_insert) + rw_unlock(&info->s->key_root_lock[inx]); + info->lastpos= HA_OFFSET_ERROR; + DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE); } - rw_unlock(&info->s->key_root_lock[inx]); } + + if (info->s->concurrent_insert) + rw_unlock(&info->s->key_root_lock[inx]); + /* Don't clear if database-changed */ info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update|= HA_STATE_NEXT_FOUND; diff --git a/storage/myisam/mi_rnext_same.c b/storage/myisam/mi_rnext_same.c index 1892fe3e1e0..76775dec8ac 100644 --- a/storage/myisam/mi_rnext_same.c +++ b/storage/myisam/mi_rnext_same.c @@ -76,7 +76,8 @@ int mi_rnext_same(MI_INFO *info, uchar *buf) break; } /* Skip rows that are inserted by other threads since we got a lock */ - if (info->lastpos < info->state->data_file_length) + if (info->lastpos < info->state->data_file_length && + (!info->index_cond_func || mi_check_index_cond(info, inx, buf))) break; } } diff --git a/storage/myisam/mi_rprev.c b/storage/myisam/mi_rprev.c index d1407012590..93bd224bd56 100644 --- a/storage/myisam/mi_rprev.c +++ b/storage/myisam/mi_rprev.c @@ -51,22 +51,36 @@ int mi_rprev(MI_INFO *info, uchar *buf, int inx) error=_mi_search(info,share->keyinfo+inx,info->lastkey, USE_WHOLE_KEY, flag, share->state.key_root[inx]); - if (share->concurrent_insert) + if (!error) { - if (!error) + int res= 0; + while ((share->concurrent_insert && + info->lastpos >= info->state->data_file_length) || + (info->index_cond_func && + !(res= mi_check_index_cond(info, inx, buf)))) { - while (info->lastpos >= info->state->data_file_length) - { - /* Skip rows that are inserted by other threads since we got a lock */ - if ((error=_mi_search_next(info,share->keyinfo+inx,info->lastkey, - info->lastkey_length, - SEARCH_SMALLER, - share->state.key_root[inx]))) - break; - } + /* + Skip rows that are either inserted by other threads since + we got a lock or do not match pushed index conditions + */ + if ((error=_mi_search_next(info,share->keyinfo+inx,info->lastkey, + info->lastkey_length, + SEARCH_SMALLER, + share->state.key_root[inx]))) + break; + } + if (!error && res == 2) + { + if (share->concurrent_insert) + rw_unlock(&share->key_root_lock[inx]); + info->lastpos= HA_OFFSET_ERROR; + DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE); } - rw_unlock(&share->key_root_lock[inx]); } + + if (share->concurrent_insert) + rw_unlock(&share->key_root_lock[inx]); + info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update|= HA_STATE_PREV_FOUND; if (error) diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index c2841c49199..2dcd008da58 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -232,6 +232,7 @@ typedef struct st_mi_isam_share rw_lock_t mmap_lock; } MYISAM_SHARE; +typedef ICP_RESULT (*index_cond_func_t)(void *param); struct st_myisam_info { @@ -300,6 +301,8 @@ struct st_myisam_info /* If info->buff has to be reread for rnext */ my_bool buff_used; my_bool once_flags; /* For MYISAMMRG */ + index_cond_func_t index_cond_func; /* Index condition function */ + void *index_cond_func_arg; /* parameter for the func */ #ifdef __WIN__ my_bool owned_by_merge; /* This MyISAM table is part of a merge union */ #endif @@ -724,6 +727,7 @@ void mi_setup_functions(register MYISAM_SHARE *share); my_bool mi_dynmap_file(MI_INFO *info, my_off_t size); void mi_remap_file(MI_INFO *info, my_off_t size); +int mi_check_index_cond(register MI_INFO *info, uint keynr, uchar *record); /* Functions needed by mi_check */ volatile int *killed_ptr(HA_CHECK *param); void mi_check_print_error _VARARGS((HA_CHECK *param, const char *fmt, ...)); @@ -732,6 +736,8 @@ void mi_check_print_info _VARARGS((HA_CHECK *param, const char *fmt, ...)); #ifdef THREAD pthread_handler_t thr_find_all_keys(void *arg); #endif +extern void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t func, + void *func_arg); int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file); #ifdef __cplusplus } -- cgit v1.2.1 From 4449a5f489da9810c8e0870230572f0c548e5c63 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sun, 20 Dec 2009 18:26:15 -0800 Subject: Backport into MariaDB-5.2 the following: WL#2771 "Block Nested Loop Join and Batched Key Access Join" --- storage/myisam/ha_myisam.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 7e319fc80f6..5676f9345b8 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1865,6 +1865,16 @@ int ha_myisam::info(uint flag) stats.max_data_file_length= misam_info.max_data_file_length; stats.max_index_file_length= misam_info.max_index_file_length; stats.create_time= (ulong) misam_info.create_time; + /* + We want the value of stats.mrr_length_per_rec to be platform independent. + The size of the chunk at the end of the join buffer used for MRR needs + is calculated now basing on the values passed in the stats structure. + The remaining part of the join buffer is used for records. A different + number of records in the buffer results in a different number of buffer + refills and in a different order of records in the result set. + */ + stats.mrr_length_per_rec= misam_info.reflength + 8; // 8=max(sizeof(void *)) + ref_length= misam_info.reflength; share->db_options_in_use= misam_info.options; stats.block_size= myisam_block_size; /* record block size */ -- cgit v1.2.1 From da5edf5057d392f3647570606220d80106c81a7b Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 22 Dec 2009 15:33:21 +0300 Subject: MWL#67: MRR backport - Make index condition pushdown be controlled by an @@optimizer_switch flag, not by @@engine_condition_pushdown - Make MRR buffer size be controlled by @@mrr_buffer_size, not by @@read_rnd_buffer_size - Move parts of code to separate files - Code cleanup - Add --sorted_result to some SELECTs in tests. --- storage/myisam/mi_key.c | 10 +++++----- storage/myisam/mi_rkey.c | 6 +++--- storage/myisam/mi_rnext.c | 6 +++--- storage/myisam/mi_rnext_same.c | 8 ++++++-- 4 files changed, 17 insertions(+), 13 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index aab5797a03b..52273f013ec 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -504,10 +504,10 @@ int _mi_read_key_record(MI_INFO *info, my_off_t filepos, uchar *buf) will look for column values there) RETURN - -1 Error - 0 Index condition is not satisfied, continue scanning - 1 Index condition is satisfied - 2 Index condition is not satisfied, end the scan. + ICP_ERROR Error + ICP_NO_MATCH Index condition is not satisfied, continue scanning + ICP_MATCH Index condition is satisfied + ICP_OUT_OF_RANGE Index condition is not satisfied, end the scan. */ int mi_check_index_cond(register MI_INFO *info, uint keynr, uchar *record) @@ -516,7 +516,7 @@ int mi_check_index_cond(register MI_INFO *info, uint keynr, uchar *record) { mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; - return -1; + return ICP_ERROR; } return info->index_cond_func(info->index_cond_func_arg); } diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c index 47e2ce51a9e..da757d270bc 100644 --- a/storage/myisam/mi_rkey.c +++ b/storage/myisam/mi_rkey.c @@ -29,7 +29,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, MI_KEYDEF *keyinfo; HA_KEYSEG *last_used_keyseg; uint pack_key_length, use_key_length, nextflag; - int res= 0; + ICP_RESULT res= ICP_NO_MATCH; DBUG_ENTER("mi_rkey"); DBUG_PRINT("enter", ("base: 0x%lx buf: 0x%lx inx: %d search_flag: %d", (long) info, (long) buf, inx, search_flag)); @@ -118,7 +118,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, (search_flag != HA_READ_KEY_EXACT || last_used_keyseg != keyinfo->seg + keyinfo->keysegs)) || (info->index_cond_func && - !(res= mi_check_index_cond(info, inx, buf)))) + (res= mi_check_index_cond(info, inx, buf)) == ICP_NO_MATCH)) { uint not_used[2]; /* @@ -146,7 +146,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, break; } } - if (res == 2) + if (res == ICP_OUT_OF_RANGE) { info->lastpos= HA_OFFSET_ERROR; if (share->concurrent_insert) diff --git a/storage/myisam/mi_rnext.c b/storage/myisam/mi_rnext.c index ad5ec60dc98..584b7194ed1 100644 --- a/storage/myisam/mi_rnext.c +++ b/storage/myisam/mi_rnext.c @@ -28,7 +28,7 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx) { int error,changed; uint flag; - int res= 0; + ICP_RESULT res= 0; DBUG_ENTER("mi_rnext"); if ((inx = _mi_check_index(info,inx)) < 0) @@ -87,7 +87,7 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx) while ((info->s->concurrent_insert && info->lastpos >= info->state->data_file_length) || (info->index_cond_func && - !(res= mi_check_index_cond(info, inx, buf)))) + (res= mi_check_index_cond(info, inx, buf)) == ICP_NO_MATCH)) { /* Skip rows that are either inserted by other threads since @@ -100,7 +100,7 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx) info->s->state.key_root[inx]))) break; } - if (!error && res == 2) + if (!error && res == ICP_OUT_OF_RANGE) { if (info->s->concurrent_insert) rw_unlock(&info->s->key_root_lock[inx]); diff --git a/storage/myisam/mi_rnext_same.c b/storage/myisam/mi_rnext_same.c index 76775dec8ac..df3b678d663 100644 --- a/storage/myisam/mi_rnext_same.c +++ b/storage/myisam/mi_rnext_same.c @@ -75,9 +75,13 @@ int mi_rnext_same(MI_INFO *info, uchar *buf) info->lastpos= HA_OFFSET_ERROR; break; } - /* Skip rows that are inserted by other threads since we got a lock */ + /* + Skip + - rows that are inserted by other threads since we got a lock + - rows that don't match index condition */ if (info->lastpos < info->state->data_file_length && - (!info->index_cond_func || mi_check_index_cond(info, inx, buf))) + (!info->index_cond_func || + mi_check_index_cond(info, inx, buf) != ICP_NO_MATCH)) break; } } -- cgit v1.2.1 From f83113df07d6ef8e8a6d1db8f6dc3bb90fb0652a Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 6 Jan 2010 21:20:16 +0200 Subject: Applied Antony T Curtis patch for declaring many CHARSET objects as const Removed compiler warnings extra/libevent/epoll.c: Removed compiler warnings extra/libevent/evbuffer.c: Removed compiler warnings extra/libevent/event.c: Removed compiler warnings extra/libevent/select.c: Removed compiler warnings extra/libevent/signal.c: Removed compiler warnings include/m_ctype.h: Define CHARSET_INFO, MY_CHARSET_HANDLER, MY_COLLATION_HANDLER, MY_UNICASE_INFO, MY_UNI_CTYPE and MY_UNI_IDX as const structures. Declare that pointers point to const data include/m_string.h: Declare that pointers point to const data include/my_sys.h: Redefine variables and function prototypes include/mysql.h: Declare charset as const include/mysql.h.pp: Declare charset as const include/mysql/plugin.h: Declare charset as const include/mysql/plugin.h.pp: Declare charset as const mysys/charset-def.c: Charset can't be of type CHARSET_INFO as they are changed when they are initialized. mysys/charset.c: Functions that change CHARSET_INFO must use 'struct charset_info_st' Add temporary variables to not have to change all_charsets[] (Which now is const) sql-common/client.c: Added cast to const sql/item_cmpfunc.h: Added cast to avoid compiler error. sql/sql_class.cc: Added cast to const sql/sql_lex.cc: Added cast to const storage/maria/ma_ft_boolean_search.c: Added cast to avoid compiler error. storage/maria/ma_ft_parser.c: Added cast to avoid compiler error. storage/maria/ma_search.c: Added cast to const storage/myisam/ft_boolean_search.c: Added cast to avoid compiler error storage/myisam/ft_parser.c: Added cast to avoid compiler error storage/myisam/mi_search.c: Added cast to const storage/pbxt/src/datadic_xt.cc: Added cast to const storage/pbxt/src/ha_pbxt.cc: Added cast to const Removed compiler warning by changing prototype of XTThreadPtr() storage/pbxt/src/myxt_xt.h: Character sets should be const storage/pbxt/src/xt_defs.h: Character sets should be const storage/xtradb/btr/btr0cur.c: Removed compiler warning strings/conf_to_src.c: Added const Functions that change CHARSET_INFO must use 'struct charset_info_st' strings/ctype-big5.c: Made arrays const strings/ctype-bin.c: Made arrays const strings/ctype-cp932.c: Made arrays const strings/ctype-czech.c: Made arrays const strings/ctype-euc_kr.c: Made arrays const strings/ctype-eucjpms.c: Made arrays const strings/ctype-extra.c: Made arrays const strings/ctype-gb2312.c: Made arrays const strings/ctype-gbk.c: Made arrays const strings/ctype-latin1.c: Made arrays const strings/ctype-mb.c: Made arrays const strings/ctype-simple.c: Made arrays const strings/ctype-sjis.c: Made arrays const strings/ctype-tis620.c: Made arrays const strings/ctype-uca.c: Made arrays const strings/ctype-ucs2.c: Made arrays const strings/ctype-ujis.c: Made arrays const strings/ctype-utf8.c: Made arrays const strings/ctype-win1250ch.c: Made arrays const strings/ctype.c: Made arrays const Added cast to const Functions that change CHARSET_INFO must use 'struct charset_info_st' strings/int2str.c: Added cast to const --- storage/myisam/ft_boolean_search.c | 2 +- storage/myisam/ft_parser.c | 3 ++- storage/myisam/mi_search.c | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index b09d8c43321..96107bdcaf6 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -593,7 +593,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query, sizeof(FTB_WORD *)*ftb->queue.elements); memcpy(ftb->list, ftb->queue.root+1, sizeof(FTB_WORD *)*ftb->queue.elements); my_qsort2(ftb->list, ftb->queue.elements, sizeof(FTB_WORD *), - (qsort2_cmp)FTB_WORD_cmp_list, ftb->charset); + (qsort2_cmp)FTB_WORD_cmp_list, (void*) ftb->charset); if (ftb->queue.elements<2) ftb->with_scan &= ~FTB_FLAG_TRUNC; ftb->state=READY; return ftb; diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index e4d500f6d8a..83eb068f151 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -252,7 +252,8 @@ void ft_parse_init(TREE *wtree, CHARSET_INFO *cs) { DBUG_ENTER("ft_parse_init"); if (!is_tree_inited(wtree)) - init_tree(wtree,0,0,sizeof(FT_WORD),(qsort_cmp2)&FT_WORD_cmp,0,NULL, cs); + init_tree(wtree,0,0,sizeof(FT_WORD),(qsort_cmp2)&FT_WORD_cmp,0,NULL, + (void*) cs); DBUG_VOID_RETURN; } diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index 52d2eb6e10c..03e0c72d7e0 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -300,7 +300,7 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, uint prefix_len,suffix_len; int key_len_skip, seg_len_pack, key_len_left; uchar *end, *kseg, *vseg; - uchar *sort_order=keyinfo->seg->charset->sort_order; + const uchar *sort_order= keyinfo->seg->charset->sort_order; uchar tt_buff[HA_MAX_KEY_BUFF+2], *t_buff=tt_buff+2; uchar *UNINIT_VAR(saved_from), *UNINIT_VAR(saved_to); uchar *UNINIT_VAR(saved_vseg); @@ -1471,7 +1471,8 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key, int length; uint key_length,ref_length,org_key_length=0, length_pack,new_key_length,diff_flag,pack_marker; - uchar *start,*end,*key_end,*sort_order; + uchar *start,*end,*key_end; + const uchar *sort_order; my_bool same_length; length_pack=s_temp->ref_length=s_temp->n_ref_length=s_temp->n_length=0; -- cgit v1.2.1 From b96f268acc3a693b673fceccc62311e169496731 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 6 Jan 2010 23:27:53 +0200 Subject: Removed compiler warnings Fixed sporadic test failure for suit/pbxt/t/lock_multi.test Fixed sporadic test faulure for suit/rpl/t/do_grant.test OpenSolaris 5.11-x86 now compiles (tested with 32 bit) BUILD/compile-solaris-amd64-debug-forte: Added execute bit BUILD/compile-solaris-x86-32: Added execute bit BUILD/compile-solaris-x86-32-debug: Added execute bit BUILD/compile-solaris-x86-32-debug-forte: Added execute bit BUILD/compile-solaris-x86-forte-32: Added execute bit extra/libevent/devpoll.c: Removed compiler warning extra/libevent/evbuffer.c: Removed compiler warning extra/libevent/select.c: Removed compiler warning mysql-test/mysql-test-run.pl: Fixed sporadic test faulure for suit/rpl/t/do_grant.test (Seen on OpenSolaris) mysql-test/suite/pbxt/r/lock_multi.result: Fixed sporadic test failure for suit/pbxt/t/lock_multi.test (seen in buildbot) This was done by merging the test with main/lock_multi.test mysql-test/suite/pbxt/t/lock_multi.test: Fixed sporadic test failure for suit/pbxt/t/lock_multi.test (seen in buildbot) This was done by merging the test with main/lock_multi.test mysys/my_sync.c: Removed compiler warnings sql/ha_ndbcluster.cc: Fixed linking error on OpenSolaris when compiling without ndb Bug #34866 Can't compile on Solaris 9/Sparc with gcc storage/archive/azlib.h: Removed compiler warning about redefined symbols storage/maria/ma_blockrec.c: Removed compiler warning storage/maria/ma_loghandler.c: Removed compiler warning storage/maria/ma_test3.c: Removed compiler warning storage/myisam/mi_test3.c: Removed compiler warning storage/pbxt/src/ha_pbxt.cc: Removed compiler warning thr_main -> thr_main_pbxt storage/pbxt/src/restart_xt.cc: thr_main -> thr_main_pbxt storage/pbxt/src/thread_xt.cc: thr_main -> thr_main_pbxt This was needed as thr_main() is an internal thread function on OpenSolaris() storage/pbxt/src/thread_xt.h: thr_main -> thr_main_pbxt storage/xtradb/srv/srv0srv.c: Use compatiblity macro to get code to work on OpenSolaris support-files/compiler_warnings.supp: Ignore compiler warning from yassl --- storage/myisam/mi_test3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c index 93f2b10fd3e..e792612a313 100644 --- a/storage/myisam/mi_test3.c +++ b/storage/myisam/mi_test3.c @@ -178,7 +178,8 @@ void start_test(int id) } if (key_cacheing && rnd(2) == 0) init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE, 65536L, 0, 0); - printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout); + printf("Process %d, pid: %ld\n", id, (long) getpid()); + fflush(stdout); for (error=i=0 ; i < tests && !error; i++) { @@ -362,7 +363,7 @@ int test_write(MI_INFO *file,int id,int lock_type) mi_extra(file,HA_EXTRA_WRITE_CACHE,0); } - sprintf((char*) record.id,"%7d",getpid()); + sprintf((char*) record.id,"%7ld",(long) getpid()); strnmov((char*) record.text,"Testing...", sizeof(record.text)); tries=(uint) rnd(100)+10; -- cgit v1.2.1 From d121e6630519a66eec7c953ee0eae623f592ce87 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 14 Jan 2010 18:51:00 +0200 Subject: Fix for compiler warnings on windows Fix wrong cast of time() include/my_pthread.h: Safety fix that also removes compiler warnings sql/handler.h: Changed timestamp columns to be of type time_t storage/maria/ma_check.c: Removed wrong cast storage/maria/ma_create.c: Removed wrong cast storage/myisam/mi_check.c: Removed wrong cast storage/myisam/mi_create.c: Removed wrong cast storage/xtradb/handler/ha_innodb.cc: Removed compiler warning on windows --- storage/myisam/mi_check.c | 2 +- storage/myisam/mi_create.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 5939e7ea786..9fe954273fe 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -4447,7 +4447,7 @@ int update_state_info(HA_CHECK *param, MI_INFO *info,uint update) { if (update & UPDATE_TIME) { - share->state.check_time= (long) time((time_t*) 0); + share->state.check_time= time((time_t*) 0); if (!share->state.create_time) share->state.create_time=share->state.check_time; } diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 3e7045d35a4..1b92d64d529 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -575,7 +575,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) : MI_EXTEND_BLOCK_LENGTH; if (! (flags & HA_DONT_TOUCH_DATA)) - share.state.create_time= (long) time((time_t*) 0); + share.state.create_time= time((time_t*) 0); pthread_mutex_lock(&THR_LOCK_myisam); -- cgit v1.2.1 From e2efd9338574c87177e0c00273e6e49a32ce2aa6 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 27 Jan 2010 23:53:08 +0200 Subject: Fixed some compiler warnings and errors in test suite found by buildbot include/ft_global.h: Changed string size to 'size_t' (to avoid compiler warnings later) include/maria.h: Changed string size to 'size_t' (to avoid compiler warnings later) mysql-test/r/show_check.result: Don't use logging to tables, as there is no guarantee in which order tables are showed in 'show open tables' mysql-test/suite/rpl/t/rpl_rotate_logs.test: Use HIGH_PRIORITY inserts to avoid problem with concurrent inserts on the slave. mysql-test/t/show_check-master.opt: Don't use logging to tables, as there is no guarantee in which order tables are showed in 'show open tables' sql/item.cc: Fixed compiler warning storage/maria/ft_maria.c: Changed string size to 'size_t' (to avoid compiler warnings later) storage/myisam/ft_boolean_search.c: Fixed compiler warnings storage/myisam/ft_myisam.c: Changed string size to 'size_t' (to avoid compiler warnings later) storage/myisam/ft_nlq_search.c: Changed string size to 'size_t' (to avoid compiler warnings later) storage/myisam/ft_parser.c: Changed string size to 'size_t' (to avoid compiler warnings) storage/myisam/ft_stopwords.c: Changed string size to 'size_t' (to avoid compiler warnings) storage/myisam/ftdefs.h: Changed string size to 'size_t' (to avoid compiler warnings) --- storage/myisam/ft_boolean_search.c | 9 +++++---- storage/myisam/ft_myisam.c | 4 ++-- storage/myisam/ft_nlq_search.c | 3 ++- storage/myisam/ft_parser.c | 2 +- storage/myisam/ft_stopwords.c | 2 +- storage/myisam/ftdefs.h | 10 ++++++---- 6 files changed, 17 insertions(+), 13 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 5df88a230a9..ae494cda385 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -299,7 +299,7 @@ static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, } -static int _ftb_parse_query(FTB *ftb, uchar *query, uint len, +static int _ftb_parse_query(FTB *ftb, uchar *query, mysql_ft_size_t len, struct st_mysql_ftparser *parser) { MYSQL_FTPARSER_PARAM *param; @@ -540,7 +540,7 @@ static void _ftb_init_index_search(FT_INFO *ftb) FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query, - uint query_len, CHARSET_INFO *cs) + mysql_ft_size_t query_len, CHARSET_INFO *cs) { FTB *ftb; FTB_EXPR *ftbe; @@ -679,8 +679,9 @@ static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, -1 is returned if error occurs. */ -static int _ftb_check_phrase(FTB *ftb, const uchar *document, uint len, - FTB_EXPR *ftbe, struct st_mysql_ftparser *parser) +static int _ftb_check_phrase(FTB *ftb, const uchar *document, + mysql_ft_size_t len, + FTB_EXPR *ftbe, struct st_mysql_ftparser *parser) { MY_FTB_PHRASE_PARAM ftb_param; MYSQL_FTPARSER_PARAM *param; diff --git a/storage/myisam/ft_myisam.c b/storage/myisam/ft_myisam.c index bef3fbfd5f5..7bcc62d5bf5 100644 --- a/storage/myisam/ft_myisam.c +++ b/storage/myisam/ft_myisam.c @@ -23,8 +23,8 @@ #include "ftdefs.h" FT_INFO *ft_init_search(uint flags, void *info, uint keynr, - uchar *query, uint query_len, CHARSET_INFO *cs, - uchar *record) + uchar *query, size_t query_len, + CHARSET_INFO *cs, uchar *record) { FT_INFO *res; if (flags & FT_BOOL) diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index c4d27bcbd8e..90ad2d635b7 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -204,7 +204,8 @@ static int FT_DOC_cmp(void *unused __attribute__((unused)), FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query, - uint query_len, uint flags, uchar *record) + mysql_ft_size_t query_len, uint flags, + uchar *record) { TREE wtree; ALL_IN_ONE aio; diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index e4d500f6d8a..f585038f0b8 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -304,7 +304,7 @@ static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, } -int ft_parse(TREE *wtree, const uchar *doc, int doclen, +int ft_parse(TREE *wtree, const uchar *doc, mysql_ft_size_t doclen, struct st_mysql_ftparser *parser, MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root) { diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index db4cd3b32b6..9544c577c70 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -21,7 +21,7 @@ typedef struct st_ft_stopwords { const char * pos; - uint len; + size_t len; } FT_STOPWORD; static TREE *stopwords3=NULL; diff --git a/storage/myisam/ftdefs.h b/storage/myisam/ftdefs.h index 2b4c46c78ad..b26fa523b42 100644 --- a/storage/myisam/ftdefs.h +++ b/storage/myisam/ftdefs.h @@ -97,8 +97,8 @@ typedef struct st_ft_word { const uchar *pos; - uint len; double weight; + size_t len; } FT_WORD; int is_stopword(const uchar *word, size_t len); @@ -111,7 +111,8 @@ uchar ft_simple_get_word(CHARSET_INFO *, const uchar **, const uchar *, FT_WORD *, my_bool); typedef struct _st_ft_seg_iterator { - uint num, len; + uint num; + mysql_ft_size_t len; HA_KEYSEG *seg; const uchar *rec, *pos; } FT_SEG_ITERATOR; @@ -128,8 +129,9 @@ FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, const uchar *, MEM_ROOT *); uint _mi_ft_parse(TREE *, MI_INFO *, uint, const uchar *, MYSQL_FTPARSER_PARAM *, MEM_ROOT *); -FT_INFO *ft_init_nlq_search(MI_INFO *, uint, uchar *, uint, uint, uchar *); -FT_INFO *ft_init_boolean_search(MI_INFO *, uint, uchar *, uint, CHARSET_INFO *); +FT_INFO *ft_init_nlq_search(MI_INFO *, uint, uchar *, mysql_ft_size_t, uint, + uchar *); +FT_INFO *ft_init_boolean_search(MI_INFO *, uint, uchar *, mysql_ft_size_t, CHARSET_INFO *); extern const struct _ft_vft _ft_vft_nlq; int ft_nlq_read_next(FT_INFO *, char *); -- cgit v1.2.1 From a0417475678013914fb91c44be279b4107e3ffdb Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 28 Jan 2010 16:49:14 +0200 Subject: Fixed compiler warnings & failing test cases When compiling with debug, don't clear buffer in 'net_clear()' - This allows us to easier find bugs in the protocol and also get repeatable test failures in test cases where someone forgot to do --reap client/mysqltest.cc: Fixed compiler warning mysql-test/t/partition_innodb_semi_consistent.test: Added missing --reap (fixes random failure) sql/net_serv.cc: When compiling with debug, don't clear buffer in 'net_clear()' - This allows us to easier find bugs in the protocol and also get repeatable test failures in test cases where someone forgot to do --reap storage/myisam/ft_boolean_search.c: Fixed compiler warnings storage/myisam/ft_parser.c: Fixed compiler warnings storage/myisam/ft_stopwords.c: Fixed compiler warnings support-files/compiler_warnings.supp: Added a lot of new suppression of not relevant warnings and warnings in systems we are not in charge of unittest/mysys/waiting_threads-t.c: Fixed compiler warnings --- storage/myisam/ft_boolean_search.c | 6 +++--- storage/myisam/ft_parser.c | 6 +++--- storage/myisam/ft_stopwords.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index ae494cda385..3cc47576827 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -321,7 +321,7 @@ static int _ftb_parse_query(FTB *ftb, uchar *query, mysql_ft_size_t len, param->mysql_add_word= ftb_query_add_word; param->mysql_ftparam= (void *)&ftb_param; param->cs= ftb->charset; - param->doc= (char*) query; + param->doc= query; param->length= len; param->flags= 0; param->mode= MYSQL_FTPARSER_FULL_BOOLEAN_INFO; @@ -702,7 +702,7 @@ static int _ftb_check_phrase(FTB *ftb, const uchar *document, param->mysql_add_word= ftb_phrase_add_word; param->mysql_ftparam= (void *)&ftb_param; param->cs= ftb->charset; - param->doc= (char *) document; + param->doc= document; param->length= len; param->flags= 0; param->mode= MYSQL_FTPARSER_WITH_STOPWORDS; @@ -1000,7 +1000,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, uchar *record, uint length) { if (!ftsi.pos) continue; - param->doc= (char *)ftsi.pos; + param->doc= ftsi.pos; param->length= ftsi.len; if (unlikely(parser->parse(param))) return 0; diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index f585038f0b8..3c3efbf0906 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -175,7 +175,7 @@ uchar ft_get_word(CHARSET_INFO *cs, const uchar **start, const uchar *end, if ((param->trunc=(doc= ft_min_word_len && !is_stopword((char*) word->pos, + if (((length >= ft_min_word_len && !is_stopword(word->pos, word->len)) || param->trunc) && length < ft_max_word_len) { @@ -298,7 +298,7 @@ static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, DBUG_ENTER("ft_parse_internal"); while (ft_simple_get_word(wtree->custom_arg, &doc, end, &w, TRUE)) - if (param->mysql_add_word(param, (char*) w.pos, w.len, 0)) + if (param->mysql_add_word(param, w.pos, w.len, 0)) DBUG_RETURN(1); DBUG_RETURN(0); } @@ -319,7 +319,7 @@ int ft_parse(TREE *wtree, const uchar *doc, mysql_ft_size_t doclen, param->mysql_add_word= ft_add_word; param->mysql_ftparam= &my_param; param->cs= wtree->custom_arg; - param->doc= (char*) doc; + param->doc= doc; param->length= doclen; param->mode= MYSQL_FTPARSER_SIMPLE_MODE; DBUG_RETURN(parser->parse(param)); diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 9544c577c70..5e550b9dff5 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -20,7 +20,7 @@ typedef struct st_ft_stopwords { - const char * pos; + const uchar* pos; size_t len; } FT_STOPWORD; @@ -30,15 +30,15 @@ static int FT_STOPWORD_cmp(void* cmp_arg __attribute__((unused)), FT_STOPWORD *w1, FT_STOPWORD *w2) { return ha_compare_text(default_charset_info, - (uchar *)w1->pos,w1->len, - (uchar *)w2->pos,w2->len,0,0); + w1->pos, w1->len, + w2->pos, w2->len, 0, 0); } static void FT_STOPWORD_free(FT_STOPWORD *w, TREE_FREE action, void *arg __attribute__((unused))) { if (action == free_free) - my_free((uchar*) w->pos, MYF(0)); + my_free((void*) w->pos, MYF(0)); } static int ft_add_stopword(const char *w) -- cgit v1.2.1 From d77e3cde5f43426271f7ac64a922e5ddbf6e675d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 10 Feb 2010 21:06:24 +0200 Subject: When one does a drop table, the indexes are not flushed to disk before drop anymore (with MyISAM/Maria) myisam-recover options changed from OFF to 'DEFAULT' to get less change of data loss when using MyISAM. (The disadvantage is that changed MyISAM tables will be checked at access time; Use --myisam-recover=OFF for old behavior) Don't call extra(HA_EXTRA_FORCE_REOPEN) in ALTER TABLE if table is locked as this will mark table as crashed! Added assert to detect if we accidently would use MyISAM versioning in MySQL include/my_base.h: Mark NOT_USED as USED, as we now use this as a flag to not call extra() mysql-test/mysql-test-run.pl: Don't write all options when there is something wrong with the arguments mysql-test/r/sp-destruct.result: Add missing flush of mysql.proc (as the test copied live tables) mysql-test/r/variables.result: myisam-recover options changed to 'default' mysql-test/r/view.result: Don't show create time in result mysql-test/suite/maria/t/maria-recovery2-master.opt: Don't run test with myisam-recover (as this produces extra warnings during simulated death) mysql-test/t/sp-destruct.test: Add missing flush of mysql.proc (as the test copied live tables) mysql-test/t/view.test: Don't show create time in result sql/lock.cc: Added marker if table was deleted to argument list sql/mysql_priv.h: Added marker if table was deleted to argument list sql/mysqld.cc: myisam-recover options changed from OFF to 'DEFAULT' to get less change of data loss when using MyISAM Allow one to specify OFF as argument to myisam-recover (was default before but one couldn't specify it) sql/sql_base.cc: Mark if table is going to be deleted sql/sql_delete.cc: Mark if table is going to be deleted sql/sql_table.cc: Mark if table is going to be deleted Don't call extra(HA_EXTRA_FORCE_REOPEN) in ALTER TABLE if table is locked as this will mark table as crashed! sql/table.cc: Signal to handler if table is getting deleted as part of getting droped from table cache. sql/table.h: Added marker if table is going to be deleted. storage/maria/ha_maria.cc: Don't search for transaction handler if file is not transactional or outside of transaction (Fixed possible core dump) storage/maria/ma_blockrec.c: Don't write changed information if table is going to be deleted. storage/maria/ma_close.c: Don't write changed information if table is going to be deleted. storage/maria/ma_extra.c: Mark tables that are deleted as crased, to ensure good behavior on restart if we suddenly crash. storage/maria/ma_locking.c: Cleanup storage/maria/ma_recovery.c: We need trnman to be inited during redo phase (to be able to open tables checked with maria_chk) storage/maria/maria_def.h: Added marker if table is going to be deleted. storage/myisam/mi_close.c: Don't write changed information if table is going to be deleted. storage/myisam/mi_extra.c: Mark tables that are deleted as crased, to ensure good behavior on restart if we suddenly crash. storage/myisam/mi_open.c: Added assert to detect if we accidently would use MyISAM versioning in MySQL storage/myisam/myisamdef.h: Added marker if table is going to be deleted. --- storage/myisam/mi_close.c | 5 +++-- storage/myisam/mi_extra.c | 7 ++++++- storage/myisam/mi_open.c | 2 ++ storage/myisam/myisamdef.h | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c index 3d860bbead6..fbd24237286 100644 --- a/storage/myisam/mi_close.c +++ b/storage/myisam/mi_close.c @@ -64,8 +64,9 @@ int mi_close(register MI_INFO *info) if (share->kfile >= 0) abort();); if (share->kfile >= 0 && flush_key_blocks(share->key_cache, share->kfile, - share->temporary ? FLUSH_IGNORE_CHANGED : - FLUSH_RELEASE)) + ((share->temporary || share->deleting) ? + FLUSH_IGNORE_CHANGED : + FLUSH_RELEASE))) error=my_errno; if (share->kfile >= 0) { diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 9c5dade28ab..64e7a55231d 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -256,8 +256,13 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) share->last_version= 0L; /* Impossible version */ pthread_mutex_unlock(&THR_LOCK_myisam); break; - case HA_EXTRA_PREPARE_FOR_RENAME: case HA_EXTRA_PREPARE_FOR_DROP: + /* Signals about intent to delete this table */ + share->deleting= TRUE; + share->global_changed= FALSE; /* force writing changed flag */ + _mi_mark_file_changed(info); + /* Fall trough */ + case HA_EXTRA_PREPARE_FOR_RENAME: pthread_mutex_lock(&THR_LOCK_myisam); share->last_version= 0L; /* Impossible version */ pthread_mutex_lock(&share->intern_lock); diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 964501aa979..2ded6a8e8cd 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -58,6 +58,8 @@ MI_INFO *test_if_reopen(char *filename) { MI_INFO *info=(MI_INFO*) pos->data; MYISAM_SHARE *share=info->s; + DBUG_ASSERT(strcmp(share->unique_file_name,filename) || + share->last_version); if (!strcmp(share->unique_file_name,filename) && share->last_version) return info; } diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 680bdbf16dd..48e5d92a9a9 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -221,6 +221,7 @@ typedef struct st_mi_isam_share my_bool changed, /* If changed since lock */ global_changed, /* If changed since open */ not_flushed, temporary, delay_key_write, concurrent_insert; + my_bool deleting; /* we are going to delete this table */ #ifdef THREAD THR_LOCK lock; pthread_mutex_t intern_lock; /* Locking for use with _locking */ -- cgit v1.2.1 From 7e4d89c97379249ace6633bc406ff2ec2418252a Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Tue, 16 Feb 2010 08:41:11 -0800 Subject: WL#86: Partitioned key cache for MyISAM. This is the base patch for the task. --- storage/myisam/mi_check.c | 24 ++++++++++++++++-------- storage/myisam/mi_close.c | 1 + storage/myisam/mi_delete_all.c | 3 ++- storage/myisam/mi_extra.c | 4 +++- storage/myisam/mi_keycache.c | 7 +++++-- storage/myisam/mi_locking.c | 7 +++++-- storage/myisam/mi_page.c | 12 +++++++----- storage/myisam/mi_panic.c | 3 ++- storage/myisam/mi_preload.c | 5 +++-- storage/myisam/mi_test1.c | 3 ++- storage/myisam/mi_test2.c | 3 ++- storage/myisam/mi_test3.c | 3 ++- storage/myisam/myisam_ftdump.c | 2 +- storage/myisam/myisamchk.c | 11 ++++++----- storage/myisam/myisamdef.h | 5 ++++- storage/myisam/myisamlog.c | 2 +- 16 files changed, 62 insertions(+), 33 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 9fe954273fe..a13387b140d 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -332,7 +332,8 @@ int chk_size(HA_CHECK *param, register MI_INFO *info) /* The following is needed if called externally (not from myisamchk) */ flush_key_blocks(info->s->key_cache, - info->s->kfile, FLUSH_FORCE_WRITE); + info->s->kfile, &info->s->dirty_part_map, + FLUSH_FORCE_WRITE); size= my_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(MY_THREADSAFE)); if ((skr=(my_off_t) info->state->key_file_length) != size) @@ -1474,6 +1475,7 @@ static int mi_drop_all_indexes(HA_CHECK *param, MI_INFO *info, my_bool force) */ DBUG_PRINT("repair", ("all disabled are empty: create missing")); error= flush_key_blocks(share->key_cache, share->kfile, + &share->dirty_part_map, FLUSH_FORCE_WRITE); goto end; } @@ -1488,6 +1490,7 @@ static int mi_drop_all_indexes(HA_CHECK *param, MI_INFO *info, my_bool force) /* Remove all key blocks of this index file from key cache. */ if ((error= flush_key_blocks(share->key_cache, share->kfile, + &share->dirty_part_map, FLUSH_IGNORE_CHANGED))) goto end; /* purecov: inspected */ @@ -1549,7 +1552,7 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info, if (!param->using_global_keycache) VOID(init_key_cache(dflt_key_cache, param->key_cache_block_size, - (size_t) param->use_buffers, 0, 0)); + (size_t) param->use_buffers, 0, 0, 0)); if (init_io_cache(¶m->read_cache,info->dfile, (uint) param->read_buffer_length, @@ -1762,7 +1765,8 @@ err: VOID(end_io_cache(¶m->read_cache)); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); VOID(end_io_cache(&info->rec_cache)); - got_error|=flush_blocks(param, share->key_cache, share->kfile); + got_error|=flush_blocks(param, share->key_cache, share->kfile, + &share->dirty_part_map); if (!got_error && param->testflag & T_UNPACK) { share->state.header.options[0]&= (uchar) ~HA_OPTION_COMPRESS_RECORD; @@ -1908,9 +1912,10 @@ void lock_memory(HA_CHECK *param __attribute__((unused))) /* Flush all changed blocks to disk */ -int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file) +int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file, + ulonglong *dirty_part_map) { - if (flush_key_blocks(key_cache, file, FLUSH_RELEASE)) + if (flush_key_blocks(key_cache, file, dirty_part_map, FLUSH_RELEASE)) { mi_check_print_error(param,"%d when trying to write bufferts",my_errno); return(1); @@ -1977,7 +1982,8 @@ int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name) } /* Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map, + FLUSH_IGNORE_CHANGED); share->state.version=(ulong) time((time_t*) 0); old_state= share->state; /* save state if not stored */ @@ -2535,7 +2541,8 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, memcpy( &share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param, share->key_cache, share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile, + &share->dirty_part_map); VOID(end_io_cache(&info->rec_cache)); if (!got_error) { @@ -3059,7 +3066,8 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, memcpy(&share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param, share->key_cache, share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile, + &share->dirty_part_map); /* Destroy the write cache. The master thread did already detach from the share by remove_io_thread() or it was not yet started (if the diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c index fbd24237286..a8d678494f5 100644 --- a/storage/myisam/mi_close.c +++ b/storage/myisam/mi_close.c @@ -64,6 +64,7 @@ int mi_close(register MI_INFO *info) if (share->kfile >= 0) abort();); if (share->kfile >= 0 && flush_key_blocks(share->key_cache, share->kfile, + &share->dirty_part_map, ((share->temporary || share->deleting) ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE))) diff --git a/storage/myisam/mi_delete_all.c b/storage/myisam/mi_delete_all.c index e2bbb04ab3c..18fcdee77e2 100644 --- a/storage/myisam/mi_delete_all.c +++ b/storage/myisam/mi_delete_all.c @@ -52,7 +52,8 @@ int mi_delete_all_rows(MI_INFO *info) If we are using delayed keys or if the user has done changes to the tables since it was locked then there may be key blocks in the key cache */ - flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map, + FLUSH_IGNORE_CHANGED); #ifdef HAVE_MMAP if (share->file_map) _mi_unmap_file(info); diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 64e7a55231d..32516d0115e 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -268,6 +268,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) pthread_mutex_lock(&share->intern_lock); /* Flush pages that we don't need anymore */ if (flush_key_blocks(share->key_cache, share->kfile, + &share->dirty_part_map, (function == HA_EXTRA_PREPARE_FOR_DROP ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE))) { @@ -326,7 +327,8 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) break; case HA_EXTRA_FLUSH: if (!share->temporary) - flush_key_blocks(share->key_cache, share->kfile, FLUSH_KEEP); + flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map, + FLUSH_KEEP); #ifdef HAVE_PWRITE _mi_decrement_open_count(info); #endif diff --git a/storage/myisam/mi_keycache.c b/storage/myisam/mi_keycache.c index 5cf3fede1ae..be0cdc470f1 100644 --- a/storage/myisam/mi_keycache.c +++ b/storage/myisam/mi_keycache.c @@ -75,7 +75,8 @@ int mi_assign_to_key_cache(MI_INFO *info, in the old key cache. */ - if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map, + FLUSH_RELEASE)) { error= my_errno; mi_print_error(info->s, HA_ERR_CRASHED); @@ -90,7 +91,8 @@ int mi_assign_to_key_cache(MI_INFO *info, (This can never fail as there is never any not written data in the new key cache) */ - (void) flush_key_blocks(key_cache, share->kfile, FLUSH_RELEASE); + (void) flush_key_blocks(key_cache, share->kfile, &share->dirty_part_map, + FLUSH_RELEASE); /* ensure that setting the key cache and changing the multi_key_cache @@ -102,6 +104,7 @@ int mi_assign_to_key_cache(MI_INFO *info, This should be seen at the lastes for the next call to an myisam function. */ share->key_cache= key_cache; + share->dirty_part_map= 0; /* store the key cache in the global hash structure for future opens */ if (multi_key_cache_set((uchar*) share->unique_file_name, diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index b935d517c81..a76790c7d7d 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -68,7 +68,9 @@ int mi_lock_database(MI_INFO *info, int lock_type) --share->tot_locks; if (info->lock_type == F_WRLCK && !share->w_locks && !share->delay_key_write && flush_key_blocks(share->key_cache, - share->kfile,FLUSH_KEEP)) + share->kfile, + &share->dirty_part_map, + FLUSH_KEEP)) { error=my_errno; mi_print_error(info->s, HA_ERR_CRASHED); @@ -513,7 +515,8 @@ int _mi_test_if_changed(register MI_INFO *info) { /* Keyfile has changed */ DBUG_PRINT("info",("index file changed")); if (share->state.process != share->this_process) - VOID(flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)); + VOID(flush_key_blocks(share->key_cache, share->kfile, + &share->dirty_part_map, FLUSH_RELEASE)); share->last_process=share->state.process; info->last_unique= share->state.unique; info->last_loop= share->state.update_count; diff --git a/storage/myisam/mi_page.c b/storage/myisam/mi_page.c index a05a96e514b..70a26c5ba25 100644 --- a/storage/myisam/mi_page.c +++ b/storage/myisam/mi_page.c @@ -94,10 +94,11 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, } #endif DBUG_RETURN((key_cache_write(info->s->key_cache, - info->s->kfile,page, level, (uchar*) buff,length, - (uint) keyinfo->block_length, - (int) ((info->lock_type != F_UNLCK) || - info->s->delay_key_write)))); + info->s->kfile, &info->s->dirty_part_map, + page, level, (uchar*) buff, length, + (uint) keyinfo->block_length, + (int) ((info->lock_type != F_UNLCK) || + info->s->delay_key_write)))); } /* mi_write_keypage */ @@ -116,7 +117,8 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos, mi_sizestore(buff,old_link); info->s->state.changed|= STATE_NOT_SORTED_PAGES; DBUG_RETURN(key_cache_write(info->s->key_cache, - info->s->kfile, pos , level, buff, + info->s->kfile, &info->s->dirty_part_map, + pos , level, buff, sizeof(buff), (uint) keyinfo->block_length, (int) (info->lock_type != F_UNLCK))); diff --git a/storage/myisam/mi_panic.c b/storage/myisam/mi_panic.c index 74c93761b61..2d06b66f834 100644 --- a/storage/myisam/mi_panic.c +++ b/storage/myisam/mi_panic.c @@ -47,7 +47,8 @@ int mi_panic(enum ha_panic_function flag) if (info->s->options & HA_OPTION_READ_ONLY_DATA) break; #endif - if (flush_key_blocks(info->s->key_cache, info->s->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(info->s->key_cache, info->s->kfile, + &info->s->dirty_part_map, FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & WRITE_CACHE_USED) if (flush_io_cache(&info->rec_cache)) diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c index 60ab55106cb..115f0f0c70c 100644 --- a/storage/myisam/mi_preload.c +++ b/storage/myisam/mi_preload.c @@ -65,7 +65,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) } } else - block_length= share->key_cache->key_cache_block_size; + block_length= share->key_cache->param_block_size; length= info->preload_buff_size/block_length * block_length; set_if_bigger(length, block_length); @@ -73,7 +73,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME)))) DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM); - if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map, + FLUSH_RELEASE)) goto err; do diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c index 8e491823939..aea8d86e380 100644 --- a/storage/myisam/mi_test1.c +++ b/storage/myisam/mi_test1.c @@ -49,7 +49,8 @@ int main(int argc,char *argv[]) MY_INIT(argv[0]); my_init(); if (key_cacheing) - init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0,0); + init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0,0, + DEFAULT_KEY_CACHE_PARTITIONS); get_options(argc,argv); exit(run_test("test1")); diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 9844126e7dd..67da89e55ef 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -215,7 +215,8 @@ int main(int argc, char *argv[]) if (!silent) printf("- Writing key:s\n"); if (key_cacheing) - init_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size,0,0); + init_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size,0,0, + DEFAULT_KEY_CACHE_PARTITIONS); if (do_locking) mi_lock_database(file,F_WRLCK); if (write_cacheing) diff --git a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c index e792612a313..e4527bf441d 100644 --- a/storage/myisam/mi_test3.c +++ b/storage/myisam/mi_test3.c @@ -177,7 +177,8 @@ void start_test(int id) exit(1); } if (key_cacheing && rnd(2) == 0) - init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE, 65536L, 0, 0); + init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE, 65536L, 0, 0, + DEFAULT_KEY_CACHE_PARTITIONS); printf("Process %d, pid: %ld\n", id, (long) getpid()); fflush(stdout); diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c index 3eecb08bd99..4436d06e36b 100644 --- a/storage/myisam/myisam_ftdump.c +++ b/storage/myisam/myisam_ftdump.c @@ -83,7 +83,7 @@ int main(int argc,char *argv[]) usage(); } - init_key_cache(dflt_key_cache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0); + init_key_cache(dflt_key_cache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0, 0); if (!(info=mi_open(argv[0], O_RDONLY, HA_OPEN_ABORT_IF_LOCKED|HA_OPEN_FROM_SQL_LAYER))) diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index f8dd3b9c51f..d5d1c548717 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1102,7 +1102,7 @@ static int myisamchk(HA_CHECK *param, char * filename) { if (param->testflag & (T_EXTEND | T_MEDIUM)) VOID(init_key_cache(dflt_key_cache,opt_key_cache_block_size, - (size_t) param->use_buffers, 0, 0)); + (size_t) param->use_buffers, 0, 0, 0)); VOID(init_io_cache(¶m->read_cache,datafile, (uint) param->read_buffer_length, READ_CACHE, @@ -1116,7 +1116,8 @@ static int myisamchk(HA_CHECK *param, char * filename) HA_OPTION_COMPRESS_RECORD)) || (param->testflag & (T_EXTEND | T_MEDIUM))) error|=chk_data_link(param, info, test(param->testflag & T_EXTEND)); - error|=flush_blocks(param, share->key_cache, share->kfile); + error|=flush_blocks(param, share->key_cache, share->kfile, + &share->dirty_part_map); VOID(end_io_cache(¶m->read_cache)); } if (!error) @@ -1526,7 +1527,7 @@ static int mi_sort_records(HA_CHECK *param, DBUG_RETURN(0); /* Nothing to do */ init_key_cache(dflt_key_cache, opt_key_cache_block_size, - (size_t) param->use_buffers, 0, 0); + (size_t) param->use_buffers, 0, 0, 0); if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) @@ -1641,8 +1642,8 @@ err: my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR)); sort_info.buff=0; share->state.sortkey=sort_key; - DBUG_RETURN(flush_blocks(param, share->key_cache, share->kfile) | - got_error); + DBUG_RETURN(flush_blocks(param, share->key_cache, share->kfile, + &share->dirty_part_map) | got_error); } /* sort_records */ diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 48e5d92a9a9..20e5afbe1e2 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -174,6 +174,8 @@ typedef struct st_mi_isam_share *index_file_name; uchar *file_map; /* mem-map of file if possible */ KEY_CACHE *key_cache; /* ref to the current key cache */ + /* To mark the key cache partitions containing dirty pages for this file */ + ulonglong dirty_part_map; MI_DECODE_TREE *decode_trees; uint16 *decode_tables; /* Function to use for a row checksum. */ @@ -733,7 +735,8 @@ void mi_check_print_info _VARARGS((HA_CHECK *param, const char *fmt, ...)); #ifdef THREAD pthread_handler_t thr_find_all_keys(void *arg); #endif -int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file); +int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file, + ulonglong *dirty_part_map); #ifdef __cplusplus } #endif diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index 679dc0b731b..8b4ccfe3256 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -333,7 +333,7 @@ static int examine_log(char * file_name, char **table_names) init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (tree_element_free) file_info_free, NULL); VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, - 0, 0)); + 0, 0, 0)); files_open=0; access_time=0; while (access_time++ != number_of_commands && -- cgit v1.2.1 From 3e32ba3ff1068c19dbf0c69de991da426cf7f327 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Mar 2010 11:32:14 +0100 Subject: Fix some compiler warnings seen in Buildbot. Add some extra error output and code cleanup in an attempt to fix/debug a rare random testsuite problem in check_warnings, where the exit code from mysqltest is somehow corrupted inside mysql-test-run.pl. include/my_global.h: Fix compiler warnings on some platforms. mysql-test/lib/My/SafeProcess.pm: Move dereference of $? subprocess exit code closer to where it is generated, to make the code more robust and on the chance that this will fix the occasional problems in check_warnings we see in Buildbot. mysql-test/mysql-test-run.pl: When check_warnings failed, also log the mysqld server for which it failed. sql/sql_lex.cc: Fix compiler warning about possibly uninitialised value, by rewriting a for() loop that is always executed at least once into a do .. while() loop with an assert. sql/table.cc: Fix compiler warning about uninitialised value. storage/federatedx/ha_federatedx.cc: Fix uninitialised variable. storage/maria/ma_delete.c: Fix compiler warning about uninitialised value. storage/maria/ma_loghandler.c: Fix compiler warning about uninitialised value. storage/myisam/ft_stopwords.c: Fix compiler warning. storage/myisam/mi_write.c: Fix compiler warning about possibly uninitialised value, by rewriting a while() loop that is always executed at least once into a do .. while() loop with an assert. storage/xtradb/btr/btr0cur.c: Fix compiler warning about possibly uninitialised value. support-files/compiler_warnings.supp: Fix warning suppression to cover all cases in yassl. vio/viossl.c: Fix compiler warning. --- storage/myisam/ft_stopwords.c | 2 +- storage/myisam/mi_write.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 5e550b9dff5..aa209e082e0 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -45,7 +45,7 @@ static int ft_add_stopword(const char *w) { FT_STOPWORD sw; return !w || - (((sw.len= (uint) strlen(sw.pos=w)) >= ft_min_word_len) && + (((sw.len= (uint) strlen(sw.pos=(const uchar *)w)) >= ft_min_word_len) && (tree_insert(stopwords3, &sw, 0, stopwords3->custom_arg)==NULL)); } diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index f2528f2ec60..6ad23154b45 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -735,10 +735,12 @@ static uchar *_mi_find_last_pos(MI_KEYDEF *keyinfo, uchar *page, } end=page+length-key_ref_length; + DBUG_ASSERT(page < end); *key='\0'; length=0; lastpos=page; - while (page < end) + + do { prevpos=lastpos; lastpos=page; last_length=length; @@ -749,7 +751,8 @@ static uchar *_mi_find_last_pos(MI_KEYDEF *keyinfo, uchar *page, my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); } - } + } while (page < end); + *return_key_length=last_length; *after_key=lastpos; DBUG_PRINT("exit",("returns: 0x%lx page: 0x%lx end: 0x%lx", -- cgit v1.2.1 From e14291c1ff343287344f945bf0ad1b4edf5ab8d8 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 10 Mar 2010 21:00:34 +0200 Subject: Fix for Bug #534626 MyISAM table created in MariaDB not readable by MySQL storage/myisam/mi_create.c: Don't set HA_OPTION_NULL_FIELDS if table is not using CHECKSUM as this makes the table incompatible with MySQL. --- storage/myisam/mi_create.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 1b92d64d529..bbe58143af5 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -175,6 +175,13 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, } } + /* + Don't set HA_OPTION_NULL_FIELDS if no checksums, as this flag makes + that file incompatible with MySQL. This is ok, as this flag is only + used if one specifics table level checksums. + */ + if (!(options & HA_OPTION_CHECKSUM)) + options&= ~HA_OPTION_NULL_FIELDS; if (packed || (flags & HA_PACK_RECORD)) options|=HA_OPTION_PACK_RECORD; /* Must use packed records */ /* We can't use checksum with static length rows */ -- cgit v1.2.1 From edfd875fc1620964d68c9acbd3d36213f1c1663a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 12 Mar 2010 20:03:37 +0100 Subject: Fix myisam checksum patch to check for HA_OPTION_CHECKSUM after it was set, not before --- storage/myisam/mi_create.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index bbe58143af5..d5ce941bf75 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -175,13 +175,6 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, } } - /* - Don't set HA_OPTION_NULL_FIELDS if no checksums, as this flag makes - that file incompatible with MySQL. This is ok, as this flag is only - used if one specifics table level checksums. - */ - if (!(options & HA_OPTION_CHECKSUM)) - options&= ~HA_OPTION_NULL_FIELDS; if (packed || (flags & HA_PACK_RECORD)) options|=HA_OPTION_PACK_RECORD; /* Must use packed records */ /* We can't use checksum with static length rows */ @@ -199,6 +192,13 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, options|= HA_OPTION_CHECKSUM; min_pack_length++; } + /* + Don't set HA_OPTION_NULL_FIELDS if no checksums, as this flag makes + that file incompatible with MySQL. This is ok, as this flag is only + used if one specifics table level checksums. + */ + if (!(options & HA_OPTION_CHECKSUM)) + options&= ~HA_OPTION_NULL_FIELDS; if (flags & HA_CREATE_DELAY_KEY_WRITE) options|= HA_OPTION_DELAY_KEY_WRITE; if (flags & HA_CREATE_RELIES_ON_SQL_LAYER) -- cgit v1.2.1 From 1fec5af772809d4d67ebc3c84286bc4956b80773 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 28 Mar 2010 21:10:00 +0300 Subject: Fixed compiler warnings and sporadic failures in test cases mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test: Added missing sync_slave_with_master; Fixes random failures mysql-test/include/default_mysqld.cnf: default-character-set -> character-set-server (removes warning in error files for usage of deprecated options) mysql-test/lib/My/SafeProcess/safe_process.cc: Fixed compiler warning mysql-test/lib/v1/mysql-test-run.pl: default-character-set -> character-set-server (removes warning in error files for usage of deprecated options) mysql-test/suite/rpl/r/rpl_do_grant.result: Updated test results mysql-test/suite/rpl/t/rpl_do_grant.test: Added missing sync_slave_with_master; Fixes random failures Had to explictely do stop slave before DROP USER to avoid failure on slave as the user is already dropped on slave. mysql-test/suite/rpl/t/rpl_name_const.test: Added missing sync_slave_with_master; Fixes random failures mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test: Added missing sync_slave_with_master; Fixes random failures mysql-test/t/bug47671-master.opt: default-character-set -> character-set-server (removes warning in error files for usage of deprecated options) mysql-test/t/ctype_latin1_de-master.opt: default-character-set -> character-set-server (removes warning in error files for usage of deprecated options) mysql-test/t/ctype_ucs2_def-master.opt: default-character-set -> character-set-server (removes warning in error files for usage of deprecated options) sql-common/client.c: Fixed compiler warning sql/item.cc: Renamed function to remove compiler warnings (with gcc) sql/item.h: Renamed function to remove compiler warnings (with gcc) sql/item_cmpfunc.cc: Renamed function to remove compiler warnings (with gcc) sql/item_create.cc: Renamed function to remove compiler warnings (with gcc) sql/item_create.h: Renamed function to remove compiler warnings (with gcc) sql/item_sum.cc: Renamed function to remove compiler warnings (with gcc) sql/item_sum.h: Renamed function to remove compiler warnings (with gcc) sql/set_var.cc: Don't use bit_do_set() / bot_is_set() / bit_do_clear() as this generates compiler warnings (They are also of no use as we know the value can hold the bits) sql/sql_yacc.yy: Renamed function to remove compiler warnings (with gcc) storage/example/ha_example.h: Fixed old read_time() prototype storage/maria/ma_search.c: Added extra variables to remove compiler warnings storage/maria/maria_def.h: Added extra variables to remove compiler warnings storage/myisam/ft_stopwords.c: Added cast to get rid of compiler warning storage/xtradb/fil/fil0fil.c: Added cast to get rid of compiler warning storage/xtradb/include/page0page.h: Added const to get rid of compiler warning storage/xtradb/include/page0page.ic: Added const to get rid of compiler warning support-files/compiler_warnings.supp: Added suppression of strict-aliasing --- storage/myisam/ft_stopwords.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index aa209e082e0..05948a936a6 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -44,9 +44,10 @@ static void FT_STOPWORD_free(FT_STOPWORD *w, TREE_FREE action, static int ft_add_stopword(const char *w) { FT_STOPWORD sw; - return !w || - (((sw.len= (uint) strlen(sw.pos=(const uchar *)w)) >= ft_min_word_len) && - (tree_insert(stopwords3, &sw, 0, stopwords3->custom_arg)==NULL)); + return (!w || + (((sw.len= (uint) strlen((char*) (sw.pos=(const uchar *)w))) >= + ft_min_word_len) && + (tree_insert(stopwords3, &sw, 0, stopwords3->custom_arg)==NULL))); } int ft_init_stopwords() -- cgit v1.2.1 From 20739646d793d658d1ec6ded46e1d9b90f5d5fb4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Apr 2010 17:34:51 +0300 Subject: Maria WL#61 Interface for maria extensions. Alternative plugin interface with additional info (maturity and string version). CMakeLists.txt: Maria plugin interface used. config/ac-macros/plugins.m4: Maria plugin interface used. configure.in: Maria plugin interface used. include/mysql/plugin.h: Maria plugin interface added. include/mysql/plugin_auth.h.pp: Maria plugin interface added. plugin/auth/auth_socket.c: Maria plugin interface added. plugin/auth/dialog.c: Maria plugin interface added. plugin/daemon_example/daemon_example.cc: Maria plugin interface added. plugin/fulltext/plugin_example.c: Maria plugin interface added. sql/ha_ndbcluster.cc: Maria plugin interface added. sql/ha_partition.cc: Maria plugin interface added. sql/log.cc: Maria plugin interface added. sql/sql_acl.cc: Maria plugin interface added. sql/sql_builtin.cc.in: Maria plugin interface used. sql/sql_plugin.cc: Maria plugin interface added. sql/sql_plugin.h: Maria plugin interface used. sql/sql_show.cc: Maria plugin interface added. storage/archive/ha_archive.cc: Maria plugin interface added. storage/blackhole/ha_blackhole.cc: Maria plugin interface added. storage/csv/ha_tina.cc: Maria plugin interface added. storage/example/ha_example.cc: Maria plugin interface added. storage/federated/ha_federated.cc: Maria plugin interface added. storage/federatedx/ha_federatedx.cc: Maria plugin interface added. storage/heap/ha_heap.cc: Maria plugin interface added. storage/ibmdb2i/ha_ibmdb2i.cc: Maria plugin interface added. storage/innobase/handler/ha_innodb.cc: Maria plugin interface added. storage/innodb_plugin/handler/i_s.cc: Maria plugin interface added. storage/maria/ha_maria.cc: Maria plugin interface added. storage/myisam/ha_myisam.cc: Maria plugin interface added. storage/myisammrg/ha_myisammrg.cc: Maria plugin interface added. storage/pbxt/src/ha_pbxt.cc: Maria plugin interface added. storage/xtradb/handler/ha_innodb.cc: Maria plugin interface added. storage/xtradb/handler/i_s.cc: Maria plugin interface added. storage/xtradb/handler/i_s.h: Maria plugin interface added. --- storage/myisam/ha_myisam.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index d9ad1d58b5d..5edb79e7984 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -2174,6 +2174,23 @@ mysql_declare_plugin(myisam) NULL /* config options */ } mysql_declare_plugin_end; +maria_declare_plugin(myisam) +{ + MYSQL_STORAGE_ENGINE_PLUGIN, + &myisam_storage_engine, + "MyISAM", + "MySQL AB", + "Default engine as of MySQL 3.23 with great performance", + PLUGIN_LICENSE_GPL, + myisam_init, /* Plugin Init */ + NULL, /* Plugin Deinit */ + 0x0100, /* 1.0 */ + NULL, /* status variables */ + NULL, /* system variables */ + "1.0", /* string version */ + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ +} +maria_declare_plugin_end; #ifdef HAVE_QUERY_CACHE -- cgit v1.2.1 From ac6b3c44308b61ebf0ed5ac20e93a1ee3cd61b99 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 5 Jun 2010 16:53:36 +0200 Subject: few small MySQL bugs/issues that impact the engines, as discussed in the SE summit * remove handler::index_read_last() * create handler::keyread_read_time() (was get_index_only_read_time() in opt_range.cc) * ha_show_status() allows engine's show_status() to fail * remove HTON_FLUSH_AFTER_RENAME * fix key_cmp_if_same() to work for floats and doubles * set table->status in the server, don't force engines to do it * increment status vars in the server, don't force engines to do it mysql-test/r/status_user.result: correct test results - innodb was wrongly counting internal index searches as handler_read_* calls. sql/ha_partition.cc: compensate for handler incrementing status counters - we want to count only calls to underlying engines sql/handler.h: inline methods moved to sql_class.h sql/key.cc: simplify the check sql/opt_range.cc: move get_index_only_read_time to the handler class sql/sp.cc: don't use a key that's stored in the record buffer - the engine can overwrite the buffer with anything, destroying the key sql/sql_class.h: inline handler methods that need to see THD and TABLE definitions sql/sql_select.cc: no ha_index_read_last_map anymore sql/sql_table.cc: remove HTON_FLUSH_AFTER_RENAME sql/table.cc: set HA_CAN_MEMCMP as appropriate sql/tztime.cc: don't use a key that's stored in the record buffer - the engine can overwrite the buffer with anything, destroying the key storage/myisam/ha_myisam.cc: engines don't need to update table->status or use ha_statistic_increment anymore storage/myisam/ha_myisam.h: index_read_last_map is no more --- storage/myisam/ha_myisam.cc | 70 +++++++-------------------------------------- storage/myisam/ha_myisam.h | 1 - 2 files changed, 11 insertions(+), 60 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index d2bbb4bd405..d5577eb09be 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -776,8 +776,6 @@ int ha_myisam::close(void) int ha_myisam::write_row(uchar *buf) { - ha_statistic_increment(&SSV::ha_write_count); - /* If we have a timestamp column, update it to the current time */ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) table->timestamp_field->set_time(); @@ -1663,7 +1661,6 @@ bool ha_myisam::is_crashed() const int ha_myisam::update_row(const uchar *old_data, uchar *new_data) { - ha_statistic_increment(&SSV::ha_update_count); if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) table->timestamp_field->set_time(); return mi_update(file,old_data,new_data); @@ -1671,7 +1668,6 @@ int ha_myisam::update_row(const uchar *old_data, uchar *new_data) int ha_myisam::delete_row(const uchar *buf) { - ha_statistic_increment(&SSV::ha_delete_count); return mi_delete(file,buf); } @@ -1679,84 +1675,48 @@ int ha_myisam::index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) { - DBUG_ASSERT(inited==INDEX); - ha_statistic_increment(&SSV::ha_read_key_count); - int error=mi_rkey(file, buf, active_index, key, keypart_map, find_flag); - table->status=error ? STATUS_NOT_FOUND: 0; - return error; + return mi_rkey(file, buf, active_index, key, keypart_map, find_flag); } int ha_myisam::index_read_idx_map(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) { - ha_statistic_increment(&SSV::ha_read_key_count); - int error=mi_rkey(file, buf, index, key, keypart_map, find_flag); - table->status=error ? STATUS_NOT_FOUND: 0; - return error; -} - -int ha_myisam::index_read_last_map(uchar *buf, const uchar *key, - key_part_map keypart_map) -{ - DBUG_ENTER("ha_myisam::index_read_last"); - DBUG_ASSERT(inited==INDEX); - ha_statistic_increment(&SSV::ha_read_key_count); - int error=mi_rkey(file, buf, active_index, key, keypart_map, - HA_READ_PREFIX_LAST); - table->status=error ? STATUS_NOT_FOUND: 0; - DBUG_RETURN(error); + return mi_rkey(file, buf, index, key, keypart_map, find_flag); } int ha_myisam::index_next(uchar *buf) { - DBUG_ASSERT(inited==INDEX); - ha_statistic_increment(&SSV::ha_read_next_count); - int error=mi_rnext(file,buf,active_index); - table->status=error ? STATUS_NOT_FOUND: 0; - return error; + return mi_rnext(file,buf,active_index); } int ha_myisam::index_prev(uchar *buf) { - DBUG_ASSERT(inited==INDEX); - ha_statistic_increment(&SSV::ha_read_prev_count); - int error=mi_rprev(file,buf, active_index); - table->status=error ? STATUS_NOT_FOUND: 0; - return error; + return mi_rprev(file,buf, active_index); } int ha_myisam::index_first(uchar *buf) { - DBUG_ASSERT(inited==INDEX); - ha_statistic_increment(&SSV::ha_read_first_count); - int error=mi_rfirst(file, buf, active_index); - table->status=error ? STATUS_NOT_FOUND: 0; - return error; + return mi_rfirst(file, buf, active_index); } int ha_myisam::index_last(uchar *buf) { - DBUG_ASSERT(inited==INDEX); - ha_statistic_increment(&SSV::ha_read_last_count); - int error=mi_rlast(file, buf, active_index); - table->status=error ? STATUS_NOT_FOUND: 0; - return error; + return mi_rlast(file, buf, active_index); } int ha_myisam::index_next_same(uchar *buf, const uchar *key __attribute__((unused)), uint length __attribute__((unused))) { + DBUG_ENTER("ha_myisam::index_next_same"); int error; - DBUG_ASSERT(inited==INDEX); - ha_statistic_increment(&SSV::ha_read_next_count); do { error= mi_rnext_same(file,buf); } while (error == HA_ERR_RECORD_DELETED); - table->status=error ? STATUS_NOT_FOUND: 0; - return error; + DBUG_PRINT("return",("%i", error)); + DBUG_RETURN(error); } @@ -1769,10 +1729,7 @@ int ha_myisam::rnd_init(bool scan) int ha_myisam::rnd_next(uchar *buf) { - ha_statistic_increment(&SSV::ha_read_rnd_next_count); - int error=mi_scan(file, buf); - table->status=error ? STATUS_NOT_FOUND: 0; - return error; + return mi_scan(file, buf); } int ha_myisam::remember_rnd_pos() @@ -1788,10 +1745,7 @@ int ha_myisam::restart_rnd_next(uchar *buf) int ha_myisam::rnd_pos(uchar *buf, uchar *pos) { - ha_statistic_increment(&SSV::ha_read_rnd_count); - int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length)); - table->status=error ? STATUS_NOT_FOUND: 0; - return error; + return mi_rrnd(file, buf, my_get_ptr(pos,ref_length)); } void ha_myisam::position(const uchar *record) @@ -2092,8 +2046,6 @@ int ha_myisam::ft_read(uchar *buf) &LOCK_status); // why ? error=ft_handler->please->read_next(ft_handler,(char*) buf); - - table->status=error ? STATUS_NOT_FOUND: 0; return error; } diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 7a1595573d4..271aad66e6e 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -71,7 +71,6 @@ class ha_myisam: public handler int index_read_idx_map(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map); int index_next(uchar * buf); int index_prev(uchar * buf); int index_first(uchar * buf); -- cgit v1.2.1 From cfbee9359c4282cbff7426d6e71994205964f2df Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 16 Jun 2010 01:00:51 +0300 Subject: Fixed compiler warnings sql/log_event.cc: Fixed compiler warning on windows storage/maria/ma_state.c: Fixed compiler warning storage/maria/maria_chk.c: Fixed compiler warning storage/myisam/mi_dynrec.c: Fixed compiler warning support-files/compiler_warnings.supp: Fixed suppression rule --- storage/myisam/mi_dynrec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index adae7076858..dae8fbe50a8 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -116,7 +116,7 @@ int mi_munmap_file(MI_INFO *info) { int ret; DBUG_ENTER("mi_unmap_file"); - if ((ret= my_munmap(info->s->file_map, info->s->mmaped_length))) + if ((ret= my_munmap(info->s->file_map, (size_t) info->s->mmaped_length))) DBUG_RETURN(ret); info->s->file_read= mi_nommap_pread; info->s->file_write= mi_nommap_pwrite; -- cgit v1.2.1 From 5c4e95f83b16caa75e2e93d1b2c9f39a214684d6 Mon Sep 17 00:00:00 2001 From: Bo Thorsen Date: Fri, 25 Jun 2010 15:09:45 +0200 Subject: Implement an NSIS based installer --- storage/myisam/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'storage/myisam') diff --git a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt index 1a667e271af..7744f4337ef 100644 --- a/storage/myisam/CMakeLists.txt +++ b/storage/myisam/CMakeLists.txt @@ -70,4 +70,6 @@ IF(NOT SOURCE_SUBLIBS) MYSQL_EMBED_MANIFEST("myisampack" "asInvoker") ENDIF(EMBED_MANIFESTS) + INSTALL(TARGETS myisam_ftdump myisamchk myisamlog myisampack DESTINATION bin COMPONENT runtime) + ENDIF(NOT SOURCE_SUBLIBS) -- cgit v1.2.1 From ceb5468fd8bc9675d514949dd60c5bd7276bf3f4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Jul 2010 13:37:30 +0300 Subject: Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation. --- storage/myisam/ha_myisam.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index b8c612e0731..8f30f31f0db 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -770,6 +770,8 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) int ha_myisam::close(void) { MI_INFO *tmp=file; + if (!tmp) + return 0; file=0; return mi_close(tmp); } -- cgit v1.2.1 From ecbcddc03dc298ea1e6c0aa1a120bd0b4b04b3fd Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 16 Jul 2010 10:33:01 +0300 Subject: Improved speed of thr_alarm from O(N) to O(1). thr_alarm is used to handle timeouts and kill of connections. Fixed compiler warnings. queues.h and queues.c are now based on the UNIREG code and thus made BSD. Fix code to use new queue() interface. This mostly affects how you access elements in the queue. If USE_NET_CLEAR is not set, don't clear connection from unexpected characters. This should give a speed up when doing a lot of fast queries. Fixed some code in ma_ft_boolean_search.c that had not made it from myisam/ft_boolean_search.c include/queues.h: Use UNIREG code base (BSD) Changed init_queue() to take all initialization arguments. New interface to access elements in queue include/thr_alarm.h: Changed to use time_t instead of ulong (portability) Added index_in_queue, to be able to remove random element from queue in O(1) mysys/queues.c: Use UNIREG code base (BSD) init_queue() and reinit_queue() now takes more initialization arguments. (No need for init_queue_ex() anymore) Now one can tell queue_insert() to store in the element a pointer to where element is in queue. This allows one to remove elements from queue in O(1) instead of O(N) mysys/thr_alarm.c: Use new option in queue() to allow fast removal of elements. Do less inside LOCK_alarm mutex. This should give a major speed up of thr_alarm usage when there is many threads sql/create_options.cc: Fixed wrong printf sql/event_queue.cc: Use new queue interface() sql/filesort.cc: Use new queue interface() sql/ha_partition.cc: Use new queue interface() sql/ha_partition.h: Fixed compiler warning sql/item_cmpfunc.cc: Fixed compiler warning sql/item_subselect.cc: Use new queue interface() Removed not used variable sql/net_serv.cc: If USE_NET_CLEAR is not set, don't clear connection from unexpected characters. This should give a speed up when doing a lot of fast queries at the disadvantage that if there is a bug in the client protocol the connection will be dropped instead of being unnoticed. sql/opt_range.cc: Use new queue interface() Fixed compiler warnings sql/uniques.cc: Use new queue interface() storage/maria/ma_ft_boolean_search.c: Copy code from myisam/ft_boolean_search.c Use new queue interface() storage/maria/ma_ft_nlq_search.c: Use new queue interface() storage/maria/ma_sort.c: Use new queue interface() storage/maria/maria_pack.c: Use new queue interface() Use queue_fix() instead of own loop to fix queue. storage/myisam/ft_boolean_search.c: Use new queue interface() storage/myisam/ft_nlq_search.c: Use new queue interface() storage/myisam/mi_test_all.sh: Remove temporary file from last run storage/myisam/myisampack.c: Use new queue interface() Use queue_fix() instead of own loop to fix queue. storage/myisam/sort.c: Use new queue interface() storage/myisammrg/myrg_queue.c: Use new queue interface() storage/myisammrg/myrg_rnext.c: Use new queue interface() storage/myisammrg/myrg_rnext_same.c: Use new queue interface() storage/myisammrg/myrg_rprev.c: Use new queue interface() --- storage/myisam/ft_boolean_search.c | 14 ++++++++------ storage/myisam/ft_nlq_search.c | 4 ++-- storage/myisam/mi_test_all.sh | 1 + storage/myisam/myisampack.c | 36 ++++++++++++++---------------------- storage/myisam/sort.c | 6 +++--- 5 files changed, 28 insertions(+), 33 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 3a6368f338d..dc7eb763b77 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -482,16 +482,18 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) static void _ftb_init_index_search(FT_INFO *ftb) { - int i; + uint i; FTB_WORD *ftbw; if (ftb->state == UNINITIALIZED || ftb->keynr == NO_SUCH_KEY) return; ftb->state=INDEX_SEARCH; - for (i=ftb->queue.elements; i; i--) + for (i= queue_last_element(&ftb->queue); + (int) i >= (int) queue_first_element(&ftb->queue); + i--) { - ftbw=(FTB_WORD *)(ftb->queue.root[i]); + ftbw=(FTB_WORD *)(queue_element(&ftb->queue, i)); if (ftbw->flags & FTB_FLAG_TRUNC) { @@ -595,12 +597,12 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query, sizeof(void *)))) goto err; reinit_queue(&ftb->queue, ftb->queue.max_elements, 0, 0, - (int (*)(void*, uchar*, uchar*))FTB_WORD_cmp, 0); + (int (*)(void*, uchar*, uchar*))FTB_WORD_cmp, 0, 0, 0); for (ftbw= ftb->last_word; ftbw; ftbw= ftbw->prev) queue_insert(&ftb->queue, (uchar *)ftbw); ftb->list=(FTB_WORD **)alloc_root(&ftb->mem_root, sizeof(FTB_WORD *)*ftb->queue.elements); - memcpy(ftb->list, ftb->queue.root+1, sizeof(FTB_WORD *)*ftb->queue.elements); + memcpy(ftb->list, &queue_top(&ftb->queue), sizeof(FTB_WORD *)*ftb->queue.elements); my_qsort2(ftb->list, ftb->queue.elements, sizeof(FTB_WORD *), (qsort2_cmp)FTB_WORD_cmp_list, (void*) ftb->charset); if (ftb->queue.elements<2) ftb->with_scan &= ~FTB_FLAG_TRUNC; @@ -839,7 +841,7 @@ int ft_boolean_read_next(FT_INFO *ftb, char *record) /* update queue */ _ft2_search(ftb, ftbw, 0); - queue_replaced(& ftb->queue); + queue_replace_top(&ftb->queue); } ftbe=ftb->root; diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index 90ad2d635b7..bcce2cc8d60 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -250,12 +250,12 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query, { QUEUE best; init_queue(&best,ft_query_expansion_limit,0,0, (queue_compare) &FT_DOC_cmp, - 0); + 0, 0, 0); tree_walk(&aio.dtree, (tree_walk_action) &walk_and_push, &best, left_root_right); while (best.elements) { - my_off_t docid=((FT_DOC *)queue_remove(& best, 0))->dpos; + my_off_t docid= ((FT_DOC *)queue_remove_top(&best))->dpos; if (!(*info->read_record)(info,docid,record)) { info->update|= HA_STATE_AKTIV; diff --git a/storage/myisam/mi_test_all.sh b/storage/myisam/mi_test_all.sh index 5989d9cfaf0..c6bc686e885 100755 --- a/storage/myisam/mi_test_all.sh +++ b/storage/myisam/mi_test_all.sh @@ -5,6 +5,7 @@ valgrind="valgrind --alignment=8 --leak-check=yes" silent="-s" +rm -f test1.TMD if test -f mi_test1$MACH ; then suffix=$MACH ; else suffix=""; fi ./mi_test1$suffix $silent diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index 3d96dfaafa1..300bab58305 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -576,7 +576,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table) Create a global priority queue in preparation for making temporary Huffman trees. */ - if (init_queue(&queue,256,0,0,compare_huff_elements,0)) + if (init_queue(&queue, 256, 0, 0, compare_huff_elements, 0, 0, 0)) goto err; /* @@ -1511,7 +1511,7 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) if (queue.max_elements < found) { delete_queue(&queue); - if (init_queue(&queue,found,0,0,compare_huff_elements,0)) + if (init_queue(&queue,found, 0, 0, compare_huff_elements, 0, 0, 0)) return -1; } @@ -1615,8 +1615,7 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) Make a priority queue from the queue. Construct its index so that we have a partially ordered tree. */ - for (i=found/2 ; i > 0 ; i--) - _downheap(&queue,i); + queue_fix(&queue); /* The Huffman algorithm. */ bytes_packed=0; bits_packed=0; @@ -1627,12 +1626,9 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) Popping from a priority queue includes a re-ordering of the queue, to get the next least incidence element to the top. */ - a=(HUFF_ELEMENT*) queue_remove(&queue,0); - /* - Copy the next least incidence element. The queue implementation - reserves root[0] for temporary purposes. root[1] is the top. - */ - b=(HUFF_ELEMENT*) queue.root[1]; + a=(HUFF_ELEMENT*) queue_remove_top(&queue); + /* Copy the next least incidence element */ + b=(HUFF_ELEMENT*) queue_top(&queue); /* Get a new element from the element buffer. */ new_huff_el=huff_tree->element_buffer+found+i; /* The new element gets the sum of the two least incidence elements. */ @@ -1654,8 +1650,8 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) Replace the copied top element by the new element and re-order the queue. */ - queue.root[1]=(uchar*) new_huff_el; - queue_replaced(&queue); + queue_top(&queue)= (uchar*) new_huff_el; + queue_replace_top(&queue); } huff_tree->root=(HUFF_ELEMENT*) queue.root[1]; huff_tree->bytes_packed=bytes_packed+(bits_packed+7)/8; @@ -1786,8 +1782,7 @@ static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts, Make a priority queue from the queue. Construct its index so that we have a partially ordered tree. */ - for (i=(found+1)/2 ; i > 0 ; i--) - _downheap(&queue,i); + queue_fix(&queue); /* The Huffman algorithm. */ for (i=0 ; i < found-1 ; i++) @@ -1801,12 +1796,9 @@ static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts, incidence). Popping from a priority queue includes a re-ordering of the queue, to get the next least incidence element to the top. */ - a= (my_off_t*) queue_remove(&queue, 0); - /* - Copy the next least incidence element. The queue implementation - reserves root[0] for temporary purposes. root[1] is the top. - */ - b= (my_off_t*) queue.root[1]; + a= (my_off_t*) queue_remove_top(&queue); + /* Copy the next least incidence element. */ + b= (my_off_t*) queue_top(&queue); /* Create a new element in a local (automatic) buffer. */ new_huff_el= element_buffer + i; /* The new element gets the sum of the two least incidence elements. */ @@ -1826,8 +1818,8 @@ static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts, queue. This successively replaces the references to counts by references to HUFF_ELEMENTs. */ - queue.root[1]=(uchar*) new_huff_el; - queue_replaced(&queue); + queue_top(&queue)= (uchar*) new_huff_el; + queue_replace_top(&queue); } DBUG_RETURN(bytes_packed+(bits_packed+7)/8); } diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index fd0bd971e10..2b6d5167c93 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -920,7 +920,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, if (init_queue(&queue,(uint) (Tb-Fb)+1,offsetof(BUFFPEK,key),0, (int (*)(void*, uchar *,uchar*)) info->key_cmp, - (void*) info)) + (void*) info, 0, 0)) DBUG_RETURN(1); /* purecov: inspected */ for (buffpek= Fb ; buffpek <= Tb ; buffpek++) @@ -969,7 +969,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, uchar *base= buffpek->base; uint max_keys=buffpek->max_keys; - VOID(queue_remove(&queue,0)); + VOID(queue_remove_top(&queue)); /* Put room used by buffer to use in other buffer */ for (refpek= (BUFFPEK**) &queue_top(&queue); @@ -994,7 +994,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, } else if (error == -1) goto err; /* purecov: inspected */ - queue_replaced(&queue); /* Top element has been replaced */ + queue_replace_top(&queue); /* Top element has been replaced */ } } buffpek=(BUFFPEK*) queue_top(&queue); -- cgit v1.2.1 From 069a068c90d8fa6ccb8028f3f2cd42c238b04699 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 23 Jul 2010 22:37:21 +0200 Subject: restore the unintentinally broken ABI --- storage/myisam/ha_myisam.cc | 4 ++-- storage/myisam/ha_myisam.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 9597f848616..5f807be2374 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1591,11 +1591,11 @@ void ha_myisam::start_bulk_insert(ha_rows rows) != 0 Error */ -int ha_myisam::end_bulk_insert(bool abort) +int ha_myisam::end_bulk_insert() { mi_end_bulk_insert(file); int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0); - if (!err && !abort) + if (!err && !file->s->deleting) { if (can_enable_indexes) { diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 1b7e948b928..b7d15a6e8b7 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -108,7 +108,7 @@ class ha_myisam: public handler int enable_indexes(uint mode); int indexes_are_disabled(void); void start_bulk_insert(ha_rows rows); - int end_bulk_insert(bool abort); + int end_bulk_insert(); ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); void update_create_info(HA_CREATE_INFO *create_info); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); -- cgit v1.2.1 From 1f5b93e7720874c2b4a31e11af3fd8729d2beea7 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 4 Aug 2010 21:36:11 +0300 Subject: Fixed compiler warnings Fixed some wrong test cases Fixed bug in null handling in XtraDB extra/comp_err.c: Fixed compiler warnings extra/my_print_defaults.c: Fixed compiler warnings mysql-test/suite/binlog/t/binlog_killed.test: Added support for timeouts mysql-test/suite/funcs_1/r/is_columns_is.result: Updated results (INNODB_SYS_TABLES had got new column) scripts/mysql_install_db.sh: Fixed typo sql/mysql_priv.h: Removed not needed argument for compare_record() sql/sql_insert.cc: Removed not needed argument for compare_record() sql/sql_update.cc: Removed not needed argument for compare_record() The argument is not needed becasue we copy the full record[0] to record[1] and the comparison should work even if all columns are not read sql/table.cc: The comparison of rows is independent of HA_PARTIAL_COLUMN_READ storage/maria/maria_chk.c: Fixed compiler warnings storage/maria/maria_read_log.c: Fixed compiler warnings storage/myisam/myisamchk.c: Fixed compiler warnings storage/myisam/myisampack.c: Fixed compiler warnings storage/xtradb/dict/dict0load.c: Fixed compiler warnings storage/xtradb/row/row0sel.c: Fixed null handling in XtraDB. (See comment) storage/xtradb/trx/trx0sys.c: Fixed compiler warnings support-files/compiler_warnings.supp: Fixed compiler warnings --- storage/myisam/myisamchk.c | 12 ++++++------ storage/myisam/myisampack.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 86ddd03fc30..9ecbe76369f 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -168,7 +168,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, "Directory where character sets are.", - &charsets_dir, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (char**) &charsets_dir, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -251,7 +251,8 @@ static struct my_option my_long_options[] = 0, GET_ULL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"set-collation", OPT_SET_COLLATION, "Change the collation used by the index", - &set_collation_name, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (char**) &set_collation_name, 0, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, {"set-variable", 'O', "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -267,8 +268,7 @@ static struct my_option my_long_options[] = &check_param.opt_sort_key, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', - "Path for temporary files.", - &opt_tmpdir, + "Path for temporary files.", (char**) &opt_tmpdir, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"update-state", 'U', "Mark tables as crashed if any errors were found.", @@ -327,13 +327,13 @@ static struct my_option my_long_options[] = HA_FT_MAXCHARLEN, 0, 1, 0}, { "ft_stopword_file", OPT_FT_STOPWORD_FILE, "Use stopwords from this file instead of built-in list.", - &ft_stopword_file, &ft_stopword_file, 0, GET_STR, + (char**) &ft_stopword_file, (char**) &ft_stopword_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"stats_method", OPT_STATS_METHOD, "Specifies how index statistics collection code should treat NULLs. " "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), " "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".", - &myisam_stats_method_str, &myisam_stats_method_str, 0, + (char**) &myisam_stats_method_str, (char**) &myisam_stats_method_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index 255d8f39479..f2b28a008fc 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -259,8 +259,8 @@ static struct my_option my_long_options[] = {"backup", 'b', "Make a backup of the table as table_name.OLD.", &backup, &backup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR_MP, - "Directory where character sets are.", &charsets_dir, - &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (char**) &charsets_dir, + (char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', -- cgit v1.2.1 From 165eb1186cb6f8e9a9595ffd7c172c54a6dfb6dc Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 7 Aug 2010 15:27:23 +0300 Subject: Added extra argument to longlong2str() to make it have same prototype is int2str() Changed to use longlong10_to_str() instead of longlong2str() when base is 10 or -10 as former is much faster than later Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit. client/mysqltest.cc: longlong2str() -> longlong10_to_str() include/m_string.h: Added extra argument to longlong2str() to make it have same prototype is int2str() mysys/charset.c: Fixed compiler warning mysys/mf_soundex.c: Fixed compiler warning mysys/my_getopt.c: longlong2str() -> longlong10_to_str() sql/create_options.cc: Fixed compiler warning sql/item_strfunc.cc: Added extra argument to longlong2str sql/opt_range.cc: longlong2str() -> longlong10_to_str() sql/partition_info.cc: longlong2str() -> longlong10_to_str() sql/slave.cc: longlong2str() -> longlong10_to_str() sql/sql_bitmap.h: Added extra argument to longlong2str sql/sql_partition.cc: Added extra argument to longlong2str sql/sql_select.cc: longlong2str() -> longlong10_to_str() sql/sql_show.cc: Added extra argument to longlong2str storage/innodb_plugin/handler/ha_innodb.cc: Update to new parameters for longlong2str() storage/maria/ma_dbug.c: longlong2str() -> longlong10_to_str() storage/maria/maria_chk.c: Added extra argument to longlong2str storage/myisam/mi_dbug.c: longlong2str() -> longlong10_to_str() storage/myisam/myisamchk.c: Added extra argument to longlong2str storage/xtradb/handler/ha_innodb.cc: Update to new parameters for longlong2str() strings/longlong2str.c: Added extra argument to longlong2str() to make it have same prototype is int2str() strings/my_vsnprintf.c: Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit. Added cast to get rid of compiler warnings --- storage/myisam/mi_dbug.c | 4 ++-- storage/myisam/myisamchk.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_dbug.c b/storage/myisam/mi_dbug.c index 659abdce131..1a61d4823b5 100644 --- a/storage/myisam/mi_dbug.c +++ b/storage/myisam/mi_dbug.c @@ -118,7 +118,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg, case HA_KEYTYPE_LONGLONG: { char buff[21]; - longlong2str(mi_sint8korr(key),buff,-10); + longlong10_to_str(mi_sint8korr(key),buff,-10); VOID(fprintf(stream,"%s",buff)); key=end; break; @@ -126,7 +126,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg, case HA_KEYTYPE_ULONGLONG: { char buff[21]; - longlong2str(mi_sint8korr(key),buff,10); + longlong10_to_str(mi_sint8korr(key),buff,10); VOID(fprintf(stream,"%s",buff)); key=end; break; diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index c7ab2baa87c..592426a3690 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1314,7 +1314,7 @@ static void descript(HA_CHECK *param, register MI_INFO *info, char * name) printf("Recordlength: %13d\n",(int) share->base.pack_reclength); if (! mi_is_all_keys_active(share->state.key_map, share->base.keys)) { - longlong2str(share->state.key_map,buff,2); + longlong2str(share->state.key_map,buff,2,1); printf("Using only keys '%s' of %d possibly keys\n", buff, share->base.keys); } -- cgit v1.2.1 From 236141d4f637ee993947270c74ee17a4d4311a2d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 12 Oct 2010 20:40:46 +0300 Subject: Use less memory on stack in sql_parse.cc and in repair/check for MyISAM & Aria sql/sql_parse.cc: Make some not commonly used functions with big local variables to separate functions to make default stack usage smaller. Decrease size of db_buff[] (Was bigger than needed) Allocate current_global_status_var with malloc(). storage/maria/ha_maria.cc: Don't allocate HA_CHECK on stack (it's > 100K) storage/maria/ma_check.c: Removed duplicated code --- storage/myisam/ha_myisam.cc | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 5f807be2374..ae4c9131c42 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -799,10 +799,13 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) { if (!file) return HA_ADMIN_INTERNAL_ERROR; int error; - HA_CHECK param; + HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); MYISAM_SHARE* share = file->s; const char *old_proc_info=thd->proc_info; + if (!¶m) + return HA_ADMIN_INTERNAL_ERROR; + thd_proc_info(thd, "Checking table"); myisamchk_init(¶m); param.thd = thd; @@ -891,9 +894,12 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt) { int error=0; - HA_CHECK param; + HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); MYISAM_SHARE* share = file->s; + if (!¶m) + return HA_ADMIN_INTERNAL_ERROR; + myisamchk_init(¶m); param.thd = thd; param.op_name= "analyze"; @@ -1021,7 +1027,9 @@ int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt) err: { - HA_CHECK param; + HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); + if (!¶m) + return HA_ADMIN_INTERNAL_ERROR; myisamchk_init(¶m); param.thd= thd; param.op_name= "backup"; @@ -1037,10 +1045,10 @@ int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt) int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) { int error; - HA_CHECK param; + HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); ha_rows start_records; - if (!file) return HA_ADMIN_INTERNAL_ERROR; + if (!file || !¶m) return HA_ADMIN_INTERNAL_ERROR; myisamchk_init(¶m); param.thd = thd; @@ -1088,8 +1096,9 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt) { int error; - if (!file) return HA_ADMIN_INTERNAL_ERROR; - HA_CHECK param; + HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); + + if (!file || !¶m) return HA_ADMIN_INTERNAL_ERROR; myisamchk_init(¶m); param.thd = thd; @@ -1283,7 +1292,10 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) if (error != HA_ADMIN_OK) { /* Send error to user */ - HA_CHECK param; + HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); + if (!¶m) + return HA_ADMIN_INTERNAL_ERROR; + myisamchk_init(¶m); param.thd= thd; param.op_name= "assign_to_keycache"; @@ -1347,7 +1359,9 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt) err: { - HA_CHECK param; + HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); + if (!¶m) + return HA_ADMIN_INTERNAL_ERROR; myisamchk_init(¶m); param.thd= thd; param.op_name= "preload_keys"; @@ -1457,8 +1471,12 @@ int ha_myisam::enable_indexes(uint mode) else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE) { THD *thd=current_thd; - HA_CHECK param; + HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); const char *save_proc_info=thd->proc_info; + + if (!¶m) + return HA_ADMIN_INTERNAL_ERROR; + thd_proc_info(thd, "Creating index"); myisamchk_init(¶m); param.op_name= "recreating_index"; -- cgit v1.2.1 From 716f7843757f96649cca1f5dc3df5d9659b17da9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 29 Oct 2010 20:29:43 +0200 Subject: sane implementation of Key_% status variables. --- storage/myisam/mi_test2.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 527c5e03a27..c463f0e3daa 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -812,6 +812,8 @@ end: mi_panic(HA_PANIC_CLOSE); /* Should close log */ if (!silent) { + KEY_CACHE_STATISTICS stats; + printf("\nFollowing test have been made:\n"); printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete); if (rec_pointer_size) @@ -834,6 +836,7 @@ end: puts("Locking used"); if (use_blob) puts("blobs used"); + get_key_cache_statistics(dflt_key_cache, 0, &stats); printf("key cache status: \n\ blocks used:%10lu\n\ not flushed:%10lu\n\ @@ -841,12 +844,12 @@ w_requests: %10lu\n\ writes: %10lu\n\ r_requests: %10lu\n\ reads: %10lu\n", - dflt_key_cache->blocks_used, - dflt_key_cache->global_blocks_changed, - (ulong) dflt_key_cache->global_cache_w_requests, - (ulong) dflt_key_cache->global_cache_write, - (ulong) dflt_key_cache->global_cache_r_requests, - (ulong) dflt_key_cache->global_cache_read); + (ulong) stats.blocks_used, + (ulong) stats.blocks_changed, + (ulong) stats.write_requests, + (ulong) stats.writes, + (ulong) stats.read_requests, + (ulong) stats.reads); } end_key_cache(dflt_key_cache,1); if (blob_buffer) -- cgit v1.2.1 From 20acfbf30da2eca66f9e5d602d50ac18e38272b8 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 2 Nov 2010 17:22:57 +0200 Subject: Fix for: LP #634955: Assert in _ma_update_at_original_place() Added locking of lock mutex when updating status in external_unlock() for Aria and MyISAM tables. Fixed that 'source' command doesn't cause mysql command line tool to exit on error. DEBUG_EXECUTE() and DEBUG_EVALUATE_IF() should not execute things based on wildcards. (Allows one to run --debug with mysql-test-run scripts that uses @debug) Fixed several core dump, deadlock and crashed table bugs in handling of LOCK TABLE with MERGE tables: - Added priority of locks to avoid crashes with MERGE tables. - Added thr_lock_merge() to allow one to merge two results of thr_lock(). Fixed 'not found row' bug in REPLACE with Aria tables. Mark MyISAM tables that are part of MERGE with HA_OPEN_MERGE_TABLE and set the locks to have priority THR_LOCK_MERGE_PRIV. - By sorting MERGE tables last in thr_multi_unlock() it's safer to release and relock them many times (can happen when TRIGGERS are created) Avoid printing (null) in debug file (to easier find out wrong NULL pointer usage with %s). client/mysql.cc: Fixed that 'source' command doesn't cause mysql command line tool to exit on error. client/mysqltest.cc: Don't send NULL to fn_format(). (Can cause crash on Solaris when using --debug) dbug/dbug.c: DEBUG_EXECUTE() and DEBUG_EVALUATE_IF() should not execute things based on wildcards. include/my_base.h: Added flag to signal if one opens a MERGE table. Added extra() command to signal that one is not part of a MERGE table anymore. include/thr_lock.h: Added priority for locks (needed to fix bug in thr_lock when using MERGE tables) Added option to thr_unlock() if get_status() should be called. Added prototype for thr_merge_locks(). mysql-test/mysql-test-run.pl: Ignore crashed table warnings for tables named 'crashed'. mysql-test/r/merge.result: Renamed triggers to make debugging easier. Added some CHECK TABLES to catch errors earlier. Additional tests. mysql-test/r/merge_debug.result: Test of error handling when reopening MERGE tables. mysql-test/r/udf_query_cache.result: Added missing flush status mysql-test/suite/parts/r/partition_repair_myisam.result: Update results mysql-test/t/merge.test: Renamed triggers to make debugging easier. Added some CHECK TABLES to catch errors earlier. Additional tests. mysql-test/t/merge_debug.test: Test of error handling when reopening MERGE tables. mysql-test/t/udf_query_cache.test: Added missing flush status mysys/my_getopt.c: Removed not used variable mysys/my_symlink2.c: Changed (null) to (NULL) to make it easier to find NULL arguments to DBUG_PRINT() functions. (On linux, NULL to sprintf is printed 'null') mysys/thr_lock.c: Added priority of locks to avoid crashes with MERGE tables. Added thr_lock_merge() to allow one to merge two results of thr_lock(). - This is needed for MyISAM as all locked table must share the same status. If not, you will not see newly inserted rows in other instances of the table. If calling thr_unlock() with THR_UNLOCK_UPDATE_STATUS, call update_status() and restore_status() for the locks. This is needed in some rare cases where we call thr_unlock() followed by thr_lock() without calling external_unlock/external_lock in between. Simplify loop in thr_multi_lock(). Added 'start_trans', which is called at end of thr_multi_lock() when all locks are taken. - This was needed by Aria to ensure that transaction is started when we got all locks, not at get_status(). Without this, some rows could not be visible when we lock two tables at the same time, causing REPLACE using two tables to fail unexpectedly. sql/handler.cc: Add an assert() in handler::print_error() for "impossible errors" (like table is crashed) when --debug-assert-if-crashed-table is used. sql/lock.cc: Simplify mysql_lock_tables() code if get_lock_data() returns 0 locks. Added new parameter to thr_multi_unlock() In mysql_unlock_read_tables(), call first externa_unlock(), then thr_multi_unlock(); This is same order as we do in mysql_unlock_tables(). Don't abort locks in mysql_lock_abort() for merged tables when a MERGE table is deleted; Would cause a spin lock. Added call to thr_merge_locks() in mysql_lock_merge() to ensure consistency in thr_locks(). - New locks of same type and table is stored after the old lock to ensure that we get the status from the original lock. sql/mysql_priv.h: Added debug_assert_if_crashed_table sql/mysqld.cc: Added --debug-assert-if-crashed-table sql/parse_file.cc: Don't print '(null)' in DBUG_PRINT of no dir given sql/set_var.cc: Increase default size of buffer for @debug variable. sql/sql_base.cc: In case of error from reopen_table() in reopen_tables(), call unlock_open_table() and restart loop. - This fixed bug when we twice deleted same table from open_cache. Don't take name lock for already name locked table in open_unireg_entry(). - Fixed bug when doing repair in reopen_table(). - In detach_merge_children(), always detach if 'clear_refs' is given. We can't trust parent->children_attached as this function can be called twice, first time with clear_refs set to 0. sql/sql_class.cc: Changed printing of (null) to "" in set_thd_proc_info() sql/sql_parse.cc: Added DBUG sql/sql_trigger.cc: Don't call unlink_open_table() if reopen_table() fails as the table may already be freed. storage/maria/ma_bitmap.c: Fixed DBUG_ASSERT() in allocate_tail() storage/maria/ma_blockrec.c: Fixed wrong calculation of row length for very small rows in undo_row_update(). - Fixes ASSERT() when doing undo. storage/maria/ma_blockrec.h: Added _ma_block_start_trans() and _ma_block_start_trans_no_versioning() storage/maria/ma_locking.c: Call _ma_update_status_with_lock() when releasing write locks. - Fixes potential problem with updating status without the proper lock. storage/maria/ma_open.c: Changed to use start_trans() instead of get_status() to ensure that we see all rows in all locked tables when we got the locks. - Fixed 'not found row' bug in REPLACE with Aria tables. storage/maria/ma_state.c: Added _ma_update_status_with_lock() and _ma_block_start_trans(). This is to ensure that we see all rows in all locked tables when we got the locks. storage/maria/ma_state.h: Added _ma_update_status_with_lock() storage/maria/ma_write.c: More DBUG_PRINT storage/myisam/mi_check.c: Fixed error message storage/myisam/mi_extra.c: Added HA_EXTRA_DETACH_CHILD: - Detach MyISAM table to not be part of MERGE table (remove flag & lock priority). storage/myisam/mi_locking.c: Call mi_update_status_with_lock() when releasing write locks. - Fixes potential problem with updating status without the proper lock. Change to use new HA_OPEN_MERGE_TABLE flag to test if MERGE table. Added mi_fix_status(), called by thr_merge(). storage/myisam/mi_open.c: Added marker if part of MERGE table. Call mi_fix_status() in thr_lock() for transactional tables. storage/myisam/myisamdef.h: Change my_once_flag to uint, as it stored different values than just 0/1 Added 'open_flag' to store state given to mi_open() storage/myisammrg/ha_myisammrg.cc: Add THR_LOCK_MERGE_PRIV to THR_LOCK_DATA to get MERGE locks sorted after other types of locks. storage/myisammrg/myrg_locking.c: Remove windows specific code. storage/myisammrg/myrg_open.c: Use HA_OPEN_MERGE_TABLE to mi_open(). Set HA_OPEN_MERGE_TABLE for linked MyISAM tables. storage/xtradb/buf/buf0buf.c: Fixed compiler warning storage/xtradb/buf/buf0lru.c: Initialize variable that could be used not initialized. --- storage/myisam/mi_check.c | 2 +- storage/myisam/mi_extra.c | 5 ++++ storage/myisam/mi_locking.c | 66 +++++++++++++++++++++++++++++++++++++++------ storage/myisam/mi_open.c | 4 ++- storage/myisam/myisamdef.h | 7 +++-- 5 files changed, 70 insertions(+), 14 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 7096c03cf7d..8f732db234c 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1337,7 +1337,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) if (splits != info->s->state.split) { mi_check_print_warning(param, - "Found %10s key parts. Should be: %s", + "Found %10s parts. Should be: %s", llstr(splits,llbuff), llstr(info->s->state.split,llbuff2)); } diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 3b14e5eb98e..4c5a65f900f 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -390,6 +390,11 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) share->is_log_table= TRUE; pthread_mutex_unlock(&share->intern_lock); break; + case HA_EXTRA_DETACH_CHILD: /* When used with MERGE tables */ + info->open_flag&= ~HA_OPEN_MERGE_TABLE; + info->lock.priority&= ~THR_LOCK_MERGE_PRIV; + break; + case HA_EXTRA_KEY_CACHE: case HA_EXTRA_NO_KEY_CACHE: default: diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index 40a04293731..19ec8337539 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -22,6 +22,8 @@ #include "ftdefs.h" +static void mi_update_status_with_lock(MI_INFO *info); + /* lock table by F_UNLCK, F_RDLCK or F_WRLCK */ int mi_lock_database(MI_INFO *info, int lock_type) @@ -62,7 +64,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) else { count= --share->w_locks; - mi_update_status(info); + mi_update_status_with_lock(info); } --share->tot_locks; if (info->lock_type == F_WRLCK && !share->w_locks && @@ -244,7 +246,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) a crash on windows if the table is renamed and later on referenced by the merge table. */ - if( info->owned_by_merge && (info->s)->kfile < 0 ) + if ((info->open_flags & HA_OPEN_MERGE_TABLE) && (info->s)->kfile < 0) { error = HA_ERR_NO_SUCH_TABLE; } @@ -273,9 +275,11 @@ void mi_get_status(void* param, my_bool concurrent_insert) { MI_INFO *info=(MI_INFO*) param; DBUG_ENTER("mi_get_status"); - DBUG_PRINT("info",("key_file: %ld data_file: %ld concurrent_insert: %d", - (long) info->s->state.state.key_file_length, - (long) info->s->state.state.data_file_length, + DBUG_PRINT("info",("name: %s key_file: %lu data_file: %lu rows: %lu concurrent_insert: %d", + info->s->index_file_name, + (ulong) info->s->state.state.key_file_length, + (ulong) info->s->state.state.data_file_length, + (ulong) info->s->state.state.records, concurrent_insert)); #ifndef DBUG_OFF if (info->state->key_file_length > info->s->state.state.key_file_length || @@ -306,9 +310,11 @@ void mi_update_status(void* param) if (info->state == &info->save_state) { #ifndef DBUG_OFF - DBUG_PRINT("info",("updating status: key_file: %ld data_file: %ld", - (long) info->state->key_file_length, - (long) info->state->data_file_length)); + DBUG_PRINT("info", + ("updating status: key_file: %lu data_file: %lu rows: %lu", + (ulong) info->state->key_file_length, + (ulong) info->state->data_file_length, + (ulong) info->state->records)); if (info->state->key_file_length < info->s->state.state.key_file_length || info->state->data_file_length < info->s->state.state.data_file_length) DBUG_PRINT("warning",("old info: key_file: %ld data_file: %ld", @@ -342,6 +348,24 @@ void mi_update_status(void* param) DBUG_VOID_RETURN; } +/* + Same as mi_update_status() but take a lock in the table lock, to protect + against someone calling mi_get_status() from thr_lock() at the same time. +*/ + +static void mi_update_status_with_lock(MI_INFO *info) +{ + my_bool locked= 0; + if (info->state == &info->save_state) + { + locked= 1; + pthread_mutex_lock(&info->s->lock.mutex); + } + mi_update_status(info); + if (locked) + pthread_mutex_unlock(&info->s->lock.mutex); +} + void mi_restore_status(void *param) { @@ -407,6 +431,32 @@ my_bool mi_check_status(void *param) } +/** + Fix status for thr_lock_merge() + + @param org_table + @param new_table that should point on org_lock. new_table is 0 + in case this is the first occurence of the table in the lock + structure. +*/ + +void mi_fix_status(MI_INFO *org_table, MI_INFO *new_table) +{ + DBUG_ENTER("mi_fix_status"); + if (!new_table) + { + /* First in group. Set state as in mi_get_status() */ + org_table->state= &org_table->save_state; + } + else + { + /* Set new_table to use state from org_table (first lock of this table) */ + new_table->state= org_table->state; + } + DBUG_VOID_RETURN; +} + + /**************************************************************************** ** functions to read / write the state ****************************************************************************/ diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index e4240dec90c..9fc82846e91 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -119,7 +119,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) dflt_key_cache); DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_open", - if (strstr(name, "/t1")) + if (strstr(name, "/crashed")) { my_errno= HA_ERR_CRASHED; goto err; @@ -556,6 +556,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) share->lock.update_status=mi_update_status; share->lock.restore_status= mi_restore_status; share->lock.check_status=mi_check_status; + share->lock.fix_status= (void (*)(void *, void *)) mi_fix_status; } } #endif @@ -606,6 +607,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) info.s=share; info.lastpos= HA_OFFSET_ERROR; info.update= (short) (HA_STATE_NEXT_FOUND+HA_STATE_PREV_FOUND); + info.open_flag= open_flags; info.opt_flag=READ_CHECK_USED; info.this_unique= (ulong) info.dfile; /* Uniq number in process */ if (share->data_file_type == COMPRESSED_RECORD) diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 3262808803c..e03f88b1a1f 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -274,7 +274,9 @@ struct st_myisam_info */ ulong packed_length, blob_length; /* Length of found, packed record */ int dfile; /* The datafile */ + uint open_flag; /* Parameters for open */ uint opt_flag; /* Optim. for space/speed */ + uint once_flags; /* For MYISAMMRG */ uint update; /* If file changed since open */ int lastinx; /* Last used index */ uint lastkey_length; /* Length of key in lastkey */ @@ -300,10 +302,6 @@ struct st_myisam_info my_bool page_changed; /* If info->buff has to be reread for rnext */ my_bool buff_used; - my_bool once_flags; /* For MYISAMMRG */ -#ifdef __WIN__ - my_bool owned_by_merge; /* This MyISAM table is part of a merge union */ -#endif #ifdef THREAD THR_LOCK_DATA lock; #endif @@ -712,6 +710,7 @@ void mi_update_status(void *param); void mi_restore_status(void *param); void mi_copy_status(void *to, void *from); my_bool mi_check_status(void *param); +void mi_fix_status(MI_INFO *org_table, MI_INFO *new_table); void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows); extern MI_INFO *test_if_reopen(char *filename); -- cgit v1.2.1 From c68d3759b2455467a9eb79440d4e845a28445505 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 Nov 2010 21:01:25 +0200 Subject: #endif fixed. --- storage/myisam/mi_dbug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_dbug.c b/storage/myisam/mi_dbug.c index 659abdce131..0e839cd8379 100644 --- a/storage/myisam/mi_dbug.c +++ b/storage/myisam/mi_dbug.c @@ -131,6 +131,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg, key=end; break; } +#endif case HA_KEYTYPE_BIT: { uint i; @@ -140,8 +141,6 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg, key= end; break; } - -#endif case HA_KEYTYPE_VARTEXT1: /* VARCHAR and TEXT */ case HA_KEYTYPE_VARTEXT2: /* VARCHAR and TEXT */ case HA_KEYTYPE_VARBINARY1: /* VARBINARY and BLOB */ -- cgit v1.2.1 From 5b3159dbc797f7254b4850813c3bf3dfbbf66623 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 3 Nov 2010 14:14:02 +0200 Subject: Fixed compiler & valgrind warnings from my previous push. Fixed a bug in Aria when two threads was inserting into the same table and row page and one thread did an abort becasue of duplicate key. mysys/thr_lock.c: Fixed valgrind warning sql/sql_base.cc: Remove not used variable storage/maria/ma_bitmap.c: Added ma_bitmap_lock() & ma_bitmap_unlock() to protect against two threads using the bitmap at the same time. More DBUG_PRINT() storage/maria/ma_blockrec.c: Fixed a bug in Aria when two threads was inserting into the same table and row page and one thread did an abort becasue of duplicate key. Fix was that we block other threads to modify the bitmap while we are removing the row with a duplicate key. storage/maria/ma_blockrec.h: Added ma_bitmap_lock() & ma_bitmap_unlock() to protect against two threads using the bitmap at the same time. storage/maria/maria_def.h: Changed flush_all_requested to be a counter. storage/myisam/mi_locking.c: Fixed compiler error on windows (typo). --- storage/myisam/mi_locking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index 19ec8337539..9de043b8867 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -246,7 +246,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) a crash on windows if the table is renamed and later on referenced by the merge table. */ - if ((info->open_flags & HA_OPEN_MERGE_TABLE) && (info->s)->kfile < 0) + if ((info->open_flag & HA_OPEN_MERGE_TABLE) && (info->s)->kfile < 0) { error = HA_ERR_NO_SUCH_TABLE; } -- cgit v1.2.1 From 7b33534b472b8f8f0579a3f18d361bd6fa02543c Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Mon, 8 Nov 2010 19:06:26 +0300 Subject: [Patch from Monty] Fix stack-overrun crash in subselect_notembedded.test - Make mi_open() use less stack space --- storage/myisam/mi_open.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 9fc82846e91..994df663d4a 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -85,12 +85,13 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) uchar *disk_cache, *disk_pos, *end_pos; MI_INFO info,*m_info,*old_info; MYISAM_SHARE share_buff,*share; - ulong rec_per_key_part[HA_MAX_POSSIBLE_KEY*HA_MAX_KEY_SEG]; - my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE]; + ulong *rec_per_key_part; + my_off_t *key_root, *key_del; ulonglong max_key_file_length, max_data_file_length; DBUG_ENTER("mi_open"); LINT_INIT(m_info); + LINT_INIT(rec_per_key_part); kfile= -1; lock_error=1; errpos=0; @@ -111,9 +112,6 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) { share= &share_buff; bzero((uchar*) &share_buff,sizeof(share_buff)); - share_buff.state.rec_per_key_part=rec_per_key_part; - share_buff.state.key_root=key_root; - share_buff.state.key_del=key_del; share_buff.key_cache= multi_key_cache_search((uchar*) name_buff, strlen(name_buff), dflt_key_cache); @@ -213,7 +211,12 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) } share->state_diff_length=len-MI_STATE_INFO_SIZE; - mi_state_info_read(disk_cache, &share->state); + if (!mi_state_info_read(disk_cache, &share->state)) + goto err; + rec_per_key_part= share->state.rec_per_key_part; + key_root= share->state.key_root; + key_del= share->state.key_del; + len= mi_uint2korr(share->state.header.base_info_length); if (len != MI_BASE_INFO_SIZE) { @@ -666,6 +669,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) pthread_mutex_unlock(&THR_LOCK_myisam); bzero(info.buff, share->base.max_key_block_length * 2); + my_free(rec_per_key_part, MYF(0)); if (myisam_log_file >= 0) { @@ -695,6 +699,8 @@ err: case 3: if (! lock_error) VOID(my_lock(kfile, F_UNLCK, 0L, F_TO_EOF, MYF(MY_SEEK_NOT_DONE))); + if (rec_per_key_part) + my_free(rec_per_key_part, MYF(MY_ALLOW_ZERO_PTR)); /* fall through */ case 2: my_afree(disk_cache); @@ -982,6 +988,16 @@ uchar *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state) ptr+= state->state_diff_length; + if (!state->rec_per_key_part) + { + if (!my_multi_malloc(MY_WME, + &state->rec_per_key_part,sizeof(long)*key_parts, + &state->key_root, keys*sizeof(my_off_t), + &state->key_del, key_blocks*sizeof(my_off_t), + NullS)) + return(0); + } + for (i=0; i < keys; i++) { state->key_root[i]= mi_sizekorr(ptr); ptr +=8; -- cgit v1.2.1 From 476e90fc976fa27fc2f207960848b85e6e676ce9 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Mon, 8 Nov 2010 20:51:31 +0300 Subject: Fix buildbot errors: rec_per_key_part can be 0 if re-opening --- storage/myisam/mi_open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 994df663d4a..59bf36b3cb2 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -669,7 +669,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) pthread_mutex_unlock(&THR_LOCK_myisam); bzero(info.buff, share->base.max_key_block_length * 2); - my_free(rec_per_key_part, MYF(0)); + my_free(rec_per_key_part, MYF(MY_ALLOW_ZERO_PTR)); if (myisam_log_file >= 0) { -- cgit v1.2.1 From ea13c776529ab7b982f9ba94da5215e10a3a3bd8 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Mon, 8 Nov 2010 23:25:12 +0200 Subject: Fix buildbot failures caused by two previous pushes. --- storage/myisam/mi_open.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 59bf36b3cb2..bea95ead7f9 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -85,13 +85,12 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) uchar *disk_cache, *disk_pos, *end_pos; MI_INFO info,*m_info,*old_info; MYISAM_SHARE share_buff,*share; - ulong *rec_per_key_part; + ulong *rec_per_key_part= 0; my_off_t *key_root, *key_del; ulonglong max_key_file_length, max_data_file_length; DBUG_ENTER("mi_open"); LINT_INIT(m_info); - LINT_INIT(rec_per_key_part); kfile= -1; lock_error=1; errpos=0; @@ -683,6 +682,7 @@ err: if ((save_errno == HA_ERR_CRASHED) || (save_errno == HA_ERR_CRASHED_ON_USAGE) || (save_errno == HA_ERR_CRASHED_ON_REPAIR)) + rec_per_key_part= 0; mi_report_error(save_errno, name); switch (errpos) { case 6: @@ -699,8 +699,7 @@ err: case 3: if (! lock_error) VOID(my_lock(kfile, F_UNLCK, 0L, F_TO_EOF, MYF(MY_SEEK_NOT_DONE))); - if (rec_per_key_part) - my_free(rec_per_key_part, MYF(MY_ALLOW_ZERO_PTR)); + my_free(rec_per_key_part, MYF(MY_ALLOW_ZERO_PTR)); /* fall through */ case 2: my_afree(disk_cache); -- cgit v1.2.1 From b67be0b23bc07c2e7b7418c5b6bcc848b260b84f Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 9 Nov 2010 09:52:22 +0200 Subject: Fix buildbot failure introduced by the previous push --- storage/myisam/mi_open.c | 1 - 1 file changed, 1 deletion(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index bea95ead7f9..c40f894b14d 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -682,7 +682,6 @@ err: if ((save_errno == HA_ERR_CRASHED) || (save_errno == HA_ERR_CRASHED_ON_USAGE) || (save_errno == HA_ERR_CRASHED_ON_REPAIR)) - rec_per_key_part= 0; mi_report_error(save_errno, name); switch (errpos) { case 6: -- cgit v1.2.1