From 714f3b73e513f2d12fb45e8256fa6299e60cd5a2 Mon Sep 17 00:00:00 2001 From: unknown <guilhem@gbichot3.local> Date: Wed, 20 Dec 2006 18:58:35 +0100 Subject: [PATCH] merge of recent MyISAM changes into Maria. Only failure is ndb_restore - could have been worse!! include/pagecache.h: LSN->lsn mysys/mf_keycache.c: page_status is int mysys/mf_pagecache.c: merge of recent key cache changes sql/mysqld.cc: post-merge fixes sql/set_var.cc: post-merge fixes storage/maria/ha_maria.cc: merge of recent MyISAM changes into Maria storage/maria/ha_maria.h: merge of recent MyISAM changes into Maria storage/maria/ma_close.c: merge of recent MyISAM changes into Maria storage/maria/ma_create.c: merge of recent MyISAM changes into Maria storage/maria/ma_delete.c: merge of recent MyISAM changes into Maria storage/maria/ma_dynrec.c: merge of recent MyISAM changes into Maria storage/maria/ma_ft_boolean_search.c: merge of recent MyISAM changes into Maria storage/maria/ma_key.c: merge of recent MyISAM changes into Maria storage/maria/ma_keycache.c: merge of recent MyISAM changes into Maria storage/maria/ma_open.c: merge of recent MyISAM changes into Maria storage/maria/ma_page.c: merge of recent MyISAM changes into Maria storage/maria/ma_rsamepos.c: merge of recent MyISAM changes into Maria storage/maria/ma_statrec.c: merge of recent MyISAM changes into Maria storage/maria/ma_unique.c: merge of recent MyISAM changes into Maria storage/maria/maria_chk.c: merge of recent MyISAM changes into Maria storage/maria/maria_pack.c: merge of recent MyISAM changes into Maria storage/myisam/myisampack.c: compiler warning --- include/pagecache.h | 2 +- mysys/mf_keycache.c | 4 +-- mysys/mf_pagecache.c | 54 ++++++++++++++-------------- sql/mysqld.cc | 2 ++ sql/set_var.cc | 2 ++ storage/maria/ha_maria.cc | 18 ++++++---- storage/maria/ha_maria.h | 2 +- storage/maria/ma_close.c | 5 +-- storage/maria/ma_create.c | 6 ++-- storage/maria/ma_delete.c | 9 ++--- storage/maria/ma_dynrec.c | 4 +-- storage/maria/ma_ft_boolean_search.c | 1 - storage/maria/ma_key.c | 15 ++++---- storage/maria/ma_keycache.c | 4 +-- storage/maria/ma_open.c | 23 ++++++++++-- storage/maria/ma_page.c | 4 +-- storage/maria/ma_rsamepos.c | 3 +- storage/maria/ma_statrec.c | 4 +-- storage/maria/ma_unique.c | 4 +-- storage/maria/maria_chk.c | 1 + storage/maria/maria_pack.c | 36 ++++++++++--------- storage/myisam/myisampack.c | 4 +-- 22 files changed, 121 insertions(+), 86 deletions(-) diff --git a/include/pagecache.h b/include/pagecache.h index 9f215325ae5..418e0203f64 100644 --- a/include/pagecache.h +++ b/include/pagecache.h @@ -221,7 +221,7 @@ extern my_bool pagecache_delete_page(PAGECACHE *pagecache, enum pagecache_page_lock lock, my_bool flush); extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup); -extern my_bool pagecache_collect_changed_blocks_with_LSN(PAGECACHE *pagecache, +extern my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, LEX_STRING *str, LSN *max_lsn); diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 111a28d01a4..12be01184b6 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -1642,9 +1642,9 @@ static BLOCK_LINK *find_key_block(KEY_CACHE *keycache, KEYCACHE_DBUG_ASSERT(page_status != -1); *page_st=page_status; KEYCACHE_DBUG_PRINT("find_key_block", - ("fd: %d pos: %lu block->status: %u page_status: %u", + ("fd: %d pos: %lu block->status: %u page_status: %d", file, (ulong) filepos, block->status, - (uint) page_status)); + page_status)); #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("check_keycache2", diff --git a/mysys/mf_pagecache.c b/mysys/mf_pagecache.c index 96c855fda0a..5f4e8d1a97d 100755 --- a/mysys/mf_pagecache.c +++ b/mysys/mf_pagecache.c @@ -759,9 +759,9 @@ int init_pagecache(PAGECACHE *pagecache, my_size_t use_mem, DBUG_PRINT("exit", ("disk_blocks: %d block_root: 0x%lx hash_entries: %d\ hash_root: 0x%lx hash_links: %d hash_link_root: 0x%lx", - pagecache->disk_blocks, pagecache->block_root, - pagecache->hash_entries, pagecache->hash_root, - pagecache->hash_links, pagecache->hash_link_root)); + pagecache->disk_blocks, (long) pagecache->block_root, + pagecache->hash_entries, (long) pagecache->hash_root, + pagecache->hash_links, (long) pagecache->hash_link_root)); bzero((gptr) pagecache->changed_blocks, sizeof(pagecache->changed_blocks[0]) * PAGECACHE_CHANGED_BLOCKS_HASH); @@ -985,7 +985,7 @@ void change_pagecache_param(PAGECACHE *pagecache, uint division_limit, void end_pagecache(PAGECACHE *pagecache, my_bool cleanup) { DBUG_ENTER("end_pagecache"); - DBUG_PRINT("enter", ("key_cache: 0x%lx", pagecache)); + DBUG_PRINT("enter", ("key_cache: 0x%lx", (long) pagecache)); if (!pagecache->inited) DBUG_VOID_RETURN; @@ -1004,7 +1004,7 @@ void end_pagecache(PAGECACHE *pagecache, my_bool cleanup) pagecache->blocks_changed= 0; } - DBUG_PRINT("status", ("used: %d changed: %d w_requests: %lu " + DBUG_PRINT("status", ("used: %lu changed: %lu w_requests: %lu " "writes: %lu r_requests: %lu reads: %lu", pagecache->blocks_used, pagecache->global_blocks_changed, (ulong) pagecache->global_cache_w_requests, @@ -1466,7 +1466,7 @@ static void unreg_request(PAGECACHE *pagecache, if (block->temperature == BLOCK_WARM) pagecache->warm_blocks--; block->temperature= BLOCK_HOT; - KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks=%u", + KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %lu", pagecache->warm_blocks)); } link_block(pagecache, block, hot, (my_bool)at_end); @@ -1485,7 +1485,7 @@ static void unreg_request(PAGECACHE *pagecache, pagecache->warm_blocks++; block->temperature= BLOCK_WARM; } - KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks=%u", + KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %lu", pagecache->warm_blocks)); } } @@ -1789,11 +1789,11 @@ static PAGECACHE_BLOCK_LINK *find_key_block(PAGECACHE *pagecache, DBUG_ENTER("find_key_block"); KEYCACHE_THREAD_TRACE("find_key_block:begin"); - DBUG_PRINT("enter", ("fd: %u pos %lu wrmode: %lu", - (uint) file->file, (ulong) pageno, (uint) wrmode)); - KEYCACHE_DBUG_PRINT("find_key_block", ("fd: %u pos: %lu wrmode: %lu", - (uint) file->file, (ulong) pageno, - (uint) wrmode)); + DBUG_PRINT("enter", ("fd: %d pos: %lu wrmode: %d", + file->file, (ulong) pageno, wrmode)); + KEYCACHE_DBUG_PRINT("find_key_block", ("fd: %d pos: %lu wrmode: %d", + file->file, (ulong) pageno, + wrmode)); #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("check_pagecache", test_key_cache(pagecache, "start of find_key_block", 0);); @@ -2103,14 +2103,14 @@ static PAGECACHE_BLOCK_LINK *find_key_block(PAGECACHE *pagecache, KEYCACHE_DBUG_ASSERT(page_status != -1); *page_st=page_status; DBUG_PRINT("info", - ("block: 0x%lx fd: %u pos %lu block->status %u page_status %lu", + ("block: 0x%lx fd: %u pos %lu block->status %u page_status %u", (ulong) block, (uint) file->file, (ulong) pageno, block->status, (uint) page_status)); KEYCACHE_DBUG_PRINT("find_key_block", - ("block: 0x%lx fd: %u pos %lu block->status %u page_status %lu", + ("block: 0x%lx fd: %d pos: %lu block->status: %u page_status: %d", (ulong) block, - (uint) file->file, (ulong) pageno, block->status, - (uint) page_status)); + file->file, (ulong) pageno, block->status, + page_status)); #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("check_pagecache", @@ -3502,7 +3502,7 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache, PAGECACHE_BLOCK_LINK *cache_buff[FLUSH_CACHE],**cache; int last_errno= 0; DBUG_ENTER("flush_pagecache_blocks_int"); - DBUG_PRINT("enter",("file: %d blocks_used: %d blocks_changed: %d", + DBUG_PRINT("enter",("file: %d blocks_used: %lu blocks_changed: %lu", file->file, pagecache->blocks_used, pagecache->blocks_changed)); #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) @@ -3714,7 +3714,7 @@ int flush_pagecache_blocks(PAGECACHE *pagecache, { int res; DBUG_ENTER("flush_pagecache_blocks"); - DBUG_PRINT("enter", ("pagecache: 0x%lx", pagecache)); + DBUG_PRINT("enter", ("pagecache: 0x%lx", (long) pagecache)); if (pagecache->disk_blocks <= 0) DBUG_RETURN(0); @@ -3800,7 +3800,7 @@ int reset_key_cache_counters(const char *name, PAGECACHE *key_cache) of type PAGECACHE_LSN_PAGE. SYNOPSIS - pagecache_collect_changed_blocks_with_LSN() + pagecache_collect_changed_blocks_with_lsn() pagecache pointer to the page cache str (OUT) pointer to a LEX_STRING where the allocated buffer, and its size, will be put @@ -3809,7 +3809,8 @@ int reset_key_cache_counters(const char *name, PAGECACHE *key_cache) DESCRIPTION Does the allocation because the caller cannot know the size itself. - Memory freeing is done by the caller. + Memory freeing is to be done by the caller (if the "str" member of the + LEX_STRING is not NULL). Ignores all pages of another type than PAGECACHE_LSN_PAGE, because they are not interesting for a checkpoint record. The caller has the intention of doing checkpoints. @@ -3818,17 +3819,18 @@ int reset_key_cache_counters(const char *name, PAGECACHE *key_cache) 0 on success 1 on error */ -my_bool pagecache_collect_changed_blocks_with_LSN(PAGECACHE *pagecache, +my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, LEX_STRING *str, LSN *max_lsn) { my_bool error; - ulong stored_LRD_size= 0; + ulong stored_list_size= 0; uint file_hash; char *ptr; DBUG_ENTER("pagecache_collect_changed_blocks_with_LSN"); *max_lsn= 0; + DBUG_ASSERT(NULL == str->str); /* We lock the entire cache but will be quick, just reading/writing a few MBs of memory at most. @@ -3879,17 +3881,17 @@ my_bool pagecache_collect_changed_blocks_with_LSN(PAGECACHE *pagecache, DBUG_ASSERT(0); goto err; } - stored_LRD_size++; + stored_list_size++; } } - str->length= 8+(4+4+8)*stored_LRD_size; + str->length= 8+(4+4+8)*stored_list_size; if (NULL == (str->str= my_malloc(str->length, MYF(MY_WME)))) goto err; ptr= str->str; - int8store(ptr, stored_LRD_size); + int8store(ptr, stored_list_size); ptr+= 8; - if (0 == stored_LRD_size) + if (0 == stored_list_size) goto end; for (file_hash= 0; file_hash < PAGECACHE_CHANGED_BLOCKS_HASH; file_hash++) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8b54efb1199..22c1b6937fb 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8187,11 +8187,13 @@ void refresh_status(THD *thd) #undef have_innodb #undef have_ndbcluster #undef have_csv_db +#undef have_maria_db SHOW_COMP_OPTION have_innodb= SHOW_OPTION_NO; SHOW_COMP_OPTION have_ndbcluster= SHOW_OPTION_NO; SHOW_COMP_OPTION have_csv_db= SHOW_OPTION_NO; SHOW_COMP_OPTION have_partition_db= SHOW_OPTION_NO; +SHOW_COMP_OPTION have_maria_db= SHOW_OPTION_NO; #ifndef WITH_INNOBASE_STORAGE_ENGINE uint innobase_flush_log_at_trx_commit; diff --git a/sql/set_var.cc b/sql/set_var.cc index c72fe6fd6fe..bd68863ff97 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -674,6 +674,7 @@ sys_var_have_variable sys_have_csv_db("have_csv", &have_csv_db); sys_var_have_variable sys_have_dlopen("have_dynamic_loading", &have_dlopen); sys_var_have_variable sys_have_geometry("have_geometry", &have_geometry); sys_var_have_variable sys_have_innodb("have_innodb", &have_innodb); +sys_var_have_variable sys_have_maria_db("have_maria", &have_maria_db); sys_var_have_variable sys_have_ndbcluster("have_ndbcluster", &have_ndbcluster); sys_var_have_variable sys_have_openssl("have_openssl", &have_openssl); sys_var_have_variable sys_have_partition_db("have_partitioning", @@ -800,6 +801,7 @@ SHOW_VAR init_vars[]= { {sys_have_dlopen.name, (char*) &have_dlopen, SHOW_HAVE}, {sys_have_geometry.name, (char*) &have_geometry, SHOW_HAVE}, {sys_have_innodb.name, (char*) &have_innodb, SHOW_HAVE}, + {sys_have_maria_db.name, (char*) &have_maria_db, SHOW_HAVE}, {sys_have_ndbcluster.name, (char*) &have_ndbcluster, SHOW_HAVE}, {sys_have_openssl.name, (char*) &have_openssl, SHOW_HAVE}, {sys_have_partition_db.name,(char*) &have_partition_db, SHOW_HAVE}, diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 56f33693528..13f468b41aa 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -635,7 +635,7 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) { param.testflag &= ~T_RETRY_WITHOUT_QUICK; sql_print_information("Retrying repair of: '%s' without quick", - table->s->path); + table->s->path.str); continue; } param.testflag &= ~T_QUICK; @@ -643,7 +643,7 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) { param.testflag= (param.testflag & ~T_REP_BY_SORT) | T_REP; sql_print_information("Retrying repair of: '%s' with keycache", - table->s->path); + table->s->path.str); continue; } break; @@ -654,7 +654,8 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) char llbuff[22], llbuff2[22]; sql_print_information("Found %s of %s rows when repairing '%s'", llstr(file->state->records, llbuff), - llstr(start_records, llbuff2), table->s->path); + llstr(start_records, llbuff2), + table->s->path.str); } return error; } @@ -1183,7 +1184,7 @@ bool ha_maria::check_and_repair(THD *thd) // Don't use quick if deleted rows if (!file->state->del && (maria_recover_options & HA_RECOVER_QUICK)) check_opt.flags |= T_QUICK; - sql_print_warning("Checking table: '%s'", table->s->path); + sql_print_warning("Checking table: '%s'", table->s->path.str); old_query= thd->query; old_query_length= thd->query_length; @@ -1194,7 +1195,7 @@ bool ha_maria::check_and_repair(THD *thd) if ((marked_crashed= maria_is_crashed(file)) || check(thd, &check_opt)) { - sql_print_warning("Recovering table: '%s'", table->s->path); + sql_print_warning("Recovering table: '%s'", table->s->path.str); check_opt.flags= ((maria_recover_options & HA_RECOVER_BACKUP ? T_BACKUP_DATA : 0) | (marked_crashed ? 0 : T_QUICK) | @@ -1506,6 +1507,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg, bool found_real_auto_increment= 0; enum ha_base_keytype type; char buff[FN_REFLEN]; + byte *record; KEY *pos; MARIA_KEYDEF *keydef; MARIA_COLUMNDEF *recinfo, *recinfo_pos; @@ -1608,6 +1610,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg, found_real_auto_increment= share->next_number_key_offset == 0; } + record= table_arg->record[0]; recpos= 0; recinfo_pos= recinfo; while (recpos < (uint) share->reclength) @@ -1618,7 +1621,8 @@ int ha_maria::create(const char *name, register TABLE *table_arg, for (field= table_arg->field; *field; field++) { - if ((fieldpos= (*field)->offset()) >= recpos && fieldpos <= minpos) + if ((fieldpos=(*field)->offset(record)) >= recpos && + fieldpos <= minpos) { /* skip null fields */ if (!(temp_length= (*field)->pack_length_in_rec())) @@ -1633,7 +1637,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg, } } DBUG_PRINT("loop", ("found: 0x%lx recpos: %d minpos: %d length: %d", - found, recpos, minpos, length)); + (long) found, recpos, minpos, length)); if (recpos != minpos) { // Reserved space (Null bits?) bzero((char*) recinfo_pos, sizeof(*recinfo_pos)); diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h index 52f289a7428..1f243f9ec59 100644 --- a/storage/maria/ha_maria.h +++ b/storage/maria/ha_maria.h @@ -36,7 +36,7 @@ extern ulong maria_recover_options; class ha_maria :public handler { MARIA_HA *file; - ulong int_table_flags; + ulonglong int_table_flags; char *data_file_name, *index_file_name; bool can_enable_indexes; int repair(THD * thd, HA_CHECK ¶m, bool optimize); diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c index 73764cf444a..5d7b24cc314 100644 --- a/storage/maria/ma_close.c +++ b/storage/maria/ma_close.c @@ -28,8 +28,9 @@ int maria_close(register MARIA_HA *info) int error=0,flag; MARIA_SHARE *share=info->s; DBUG_ENTER("maria_close"); - DBUG_PRINT("enter",("base: %lx reopen: %u locks: %u", - info,(uint) share->reopen, (uint) share->tot_locks)); + DBUG_PRINT("enter",("base: 0x%lx reopen: %u locks: %u", + (long) info, (uint) share->reopen, + (uint) share->tot_locks)); pthread_mutex_lock(&THR_LOCK_maria); if (info->lock_type == F_EXTRA_LCK) diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c index 76942e3d5e8..d99c4fcc26b 100644 --- a/storage/maria/ma_create.c +++ b/storage/maria/ma_create.c @@ -441,9 +441,9 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, block_length= max(block_length, MARIA_MIN_KEY_BLOCK_LENGTH); block_length= min(block_length, MARIA_MAX_KEY_BLOCK_LENGTH); - keydef->block_length= MARIA_BLOCK_SIZE(length-real_length_diff, - pointer,MARIA_MAX_KEYPTR_SIZE, - block_length); + keydef->block_length= (uint16) MARIA_BLOCK_SIZE(length-real_length_diff, + pointer,MARIA_MAX_KEYPTR_SIZE, + block_length); if (keydef->block_length > MARIA_MAX_KEY_BLOCK_LENGTH || length >= HA_MAX_KEY_BUFF) { diff --git a/storage/maria/ma_delete.c b/storage/maria/ma_delete.c index 8849c89e30c..f0295a3c413 100644 --- a/storage/maria/ma_delete.c +++ b/storage/maria/ma_delete.c @@ -163,7 +163,7 @@ static int _ma_ck_real_delete(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, DBUG_PRINT("error",("Couldn't allocate memory")); DBUG_RETURN(my_errno=ENOMEM); } - DBUG_PRINT("info",("root_page: %ld",old_root)); + DBUG_PRINT("info",("root_page: %ld", (long) old_root)); if (!_ma_fetch_keypage(info,keyinfo,old_root,DFLT_INIT_HITS,root_buff,0)) { error= -1; @@ -406,7 +406,7 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *k MARIA_SHARE *share=info->s; MARIA_KEY_PARAM s_temp; DBUG_ENTER("del"); - DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", leaf_page, + DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", (long) leaf_page, (ulong) keypos)); DBUG_DUMP("leaf_buff",(byte*) leaf_buff,maria_getint(leaf_buff)); @@ -593,7 +593,8 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, else { /* Page is full */ endpos=anc_buff+anc_length; - DBUG_PRINT("test",("anc_buff: %lx endpos: %lx",anc_buff,endpos)); + DBUG_PRINT("test",("anc_buff: 0x%lx endpos: 0x%lx", + (long) anc_buff, (long) endpos)); if (keypos != anc_buff+2+key_reflength && !_ma_get_last_key(info,keyinfo,anc_buff,anc_key,keypos,&length)) goto err; @@ -771,7 +772,7 @@ static uint remove_key(MARIA_KEYDEF *keyinfo, uint nod_flag, int s_length; uchar *start; DBUG_ENTER("remove_key"); - DBUG_PRINT("enter",("keypos: %lx page_end: %lx",keypos,page_end)); + DBUG_PRINT("enter",("keypos: 0x%lx page_end: 0x%lx",(long) keypos, (long) page_end)); start=keypos; if (!(keyinfo->flag & diff --git a/storage/maria/ma_dynrec.c b/storage/maria/ma_dynrec.c index 253a538861a..e0f87addb43 100644 --- a/storage/maria/ma_dynrec.c +++ b/storage/maria/ma_dynrec.c @@ -1240,8 +1240,8 @@ ulong _ma_rec_unpack(register MARIA_HA *info, register byte *to, byte *from, err: my_errno= HA_ERR_WRONG_IN_RECORD; - DBUG_PRINT("error",("to_end: %lx -> %lx from_end: %lx -> %lx", - to,to_end,from,from_end)); + DBUG_PRINT("error",("to_end: 0x%lx -> 0x%lx from_end: 0x%lx -> 0x%lx", + (long) to, (long) to_end, (long) from, (long) from_end)); DBUG_DUMP("from",(byte*) info->rec_buff,info->s->base.min_pack_length); DBUG_RETURN(MY_FILE_ERROR); } /* _ma_rec_unpack */ diff --git a/storage/maria/ma_ft_boolean_search.c b/storage/maria/ma_ft_boolean_search.c index 83901cb5e47..24b51ef469c 100644 --- a/storage/maria/ma_ft_boolean_search.c +++ b/storage/maria/ma_ft_boolean_search.c @@ -333,7 +333,6 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) MARIA_HA *info=ftb->info; uint off, extra=HA_FT_WLEN+info->s->base.rec_reflength; byte *lastkey_buf=ftbw->word+ftbw->off; - LINT_INIT(off); if (ftbw->flags & FTB_FLAG_TRUNC) lastkey_buf+=ftbw->len; diff --git a/storage/maria/ma_key.c b/storage/maria/ma_key.c index ecd51f5dc92..78465ca729f 100644 --- a/storage/maria/ma_key.c +++ b/storage/maria/ma_key.c @@ -52,7 +52,7 @@ static int _ma_put_key_in_record(MARIA_HA *info,uint keynr,byte *record); uint _ma_make_key(register MARIA_HA *info, uint keynr, uchar *key, const byte *record, my_off_t filepos) { - byte *pos,*end; + byte *pos; uchar *start; reg1 HA_KEYSEG *keyseg; my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT; @@ -107,18 +107,17 @@ uint _ma_make_key(register MARIA_HA *info, uint keynr, uchar *key, } if (keyseg->flag & HA_SPACE_PACK) { - end= pos + length; if (type != HA_KEYTYPE_NUM) { - while (end > pos && end[-1] == ' ') - end--; + length= cs->cset->lengthsp(cs, pos, length); } else { + byte *end= pos + length; while (pos < end && pos[0] == ' ') pos++; + length=(uint) (end-pos); } - length=(uint) (end-pos); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); memcpy((byte*) key,(byte*) pos,(size_t) char_length); @@ -403,8 +402,10 @@ static int _ma_put_key_in_record(register MARIA_HA *info, uint keynr, pos= record+keyseg->start; if (keyseg->type != (int) HA_KEYTYPE_NUM) { - memcpy(pos,key,(size_t) length); - bfill(pos+length,keyseg->length-length,' '); + memcpy(pos,key,(size_t) length); + keyseg->charset->cset->fill(keyseg->charset, + pos + length, keyseg->length - length, + ' '); } else { diff --git a/storage/maria/ma_keycache.c b/storage/maria/ma_keycache.c index 837b0fbac66..4f150d905ed 100644 --- a/storage/maria/ma_keycache.c +++ b/storage/maria/ma_keycache.c @@ -54,8 +54,8 @@ int maria_assign_to_key_cache(MARIA_HA *info, int error= 0; MARIA_SHARE* share= info->s; DBUG_ENTER("maria_assign_to_key_cache"); - DBUG_PRINT("enter",("old_key_cache_handle: %lx new_key_cache_handle: %lx", - share->key_cache, key_cache)); + DBUG_PRINT("enter",("old_key_cache_handle: 0x%lx new_key_cache_handle: 0x%lx", + (long) share->key_cache, (long) key_cache)); /* Skip operation if we didn't change key cache. This can happen if we diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 4041c101bde..ab38d2baea1 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -340,6 +340,8 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) goto err; } } + else if (pos->type == HA_KEYTYPE_BINARY) + pos->charset= &my_charset_bin; } if (share->keyinfo[i].flag & HA_SPATIAL) { @@ -1259,12 +1261,29 @@ int maria_enable_indexes(MARIA_HA *info) RETURN 0 indexes are not disabled 1 all indexes are disabled - [2 non-unique indexes are disabled - NOT YET IMPLEMENTED] + 2 non-unique indexes are disabled */ int maria_indexes_are_disabled(MARIA_HA *info) { MARIA_SHARE *share= info->s; - return (! maria_is_any_key_active(share->state.key_map) && share->base.keys); + /* + No keys or all are enabled. keys is the number of keys. Left shifted + gives us only one bit set. When decreased by one, gives us all all bits + up to this one set and it gets unset. + */ + if (!share->base.keys || + (maria_is_all_keys_active(share->state.key_map, share->base.keys))) + return 0; + + /* All are disabled */ + if (maria_is_any_key_active(share->state.key_map)) + return 1; + + /* + We have keys. Some enabled, some disabled. + Don't check for any non-unique disabled but return directly 2 + */ + return 2; } diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index 054b8e16468..e5f9f47eaa5 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -27,7 +27,7 @@ uchar *_ma_fetch_keypage(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *tmp; uint page_size; DBUG_ENTER("_ma_fetch_keypage"); - DBUG_PRINT("enter",("page: %ld",page)); + DBUG_PRINT("enter",("page: %ld", (long) page)); tmp=(uchar*) key_cache_read(info->s->key_cache, info->s->kfile, page, level, (byte*) buff, @@ -80,7 +80,7 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, my_errno=EINVAL; DBUG_RETURN((-1)); } - DBUG_PRINT("page",("write page at: %lu",(long) page,buff)); + DBUG_PRINT("page",("write page at: %lu",(long) page)); DBUG_DUMP("buff",(byte*) buff,maria_getint(buff)); #endif diff --git a/storage/maria/ma_rsamepos.c b/storage/maria/ma_rsamepos.c index 09861c03c32..b49ef8d294a 100644 --- a/storage/maria/ma_rsamepos.c +++ b/storage/maria/ma_rsamepos.c @@ -33,7 +33,8 @@ int maria_rsame_with_pos(MARIA_HA *info, byte *record, int inx, my_off_t filepos DBUG_ENTER("maria_rsame_with_pos"); DBUG_PRINT("enter",("index: %d filepos: %ld", inx, (long) filepos)); - if (inx < -1 || (inx >= 0 && !maria_is_key_active(info->s->state.key_map, inx))) + if (inx < -1 || + (inx >= 0 && ! maria_is_key_active(info->s->state.key_map, inx))) { DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); } diff --git a/storage/maria/ma_statrec.c b/storage/maria/ma_statrec.c index 0aef24f40a9..82e31115ec7 100644 --- a/storage/maria/ma_statrec.c +++ b/storage/maria/ma_statrec.c @@ -251,8 +251,8 @@ int _ma_read_rnd_static_record(MARIA_HA *info, byte *buf, if (filepos >= info->state->data_file_length) { DBUG_PRINT("test",("filepos: %ld (%ld) records: %ld del: %ld", - filepos/share->base.reclength,filepos, - info->state->records, info->state->del)); + (long) filepos/share->base.reclength, (long) filepos, + (long) info->state->records, (long) info->state->del)); fast_ma_writeinfo(info); DBUG_RETURN(my_errno=HA_ERR_END_OF_FILE); } diff --git a/storage/maria/ma_unique.c b/storage/maria/ma_unique.c index bc1aa71966b..e2c7ca3c80c 100644 --- a/storage/maria/ma_unique.c +++ b/storage/maria/ma_unique.c @@ -57,8 +57,8 @@ my_bool _ma_check_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, byte *record, if (_ma_search_next(info,info->s->keyinfo+def->key, info->lastkey, MARIA_UNIQUE_HASH_LENGTH, SEARCH_BIGGER, info->s->state.key_root[def->key]) || - memcmp((char*) info->lastkey, (char*) key_buff, - MARIA_UNIQUE_HASH_LENGTH)) + bcmp((char*) info->lastkey, (char*) key_buff, + MARIA_UNIQUE_HASH_LENGTH)) { info->page_changed=1; /* Can't optimize read next */ info->lastpos=lastpos; diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index 89858ee2d07..6ba5200918e 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -701,6 +701,7 @@ get_one_option(int optid, { int method; enum_handler_stats_method method_conv; + LINT_INIT(method_conv); maria_stats_method_str= argument; if ((method=find_type(argument, &maria_stats_method_typelib, 2)) <= 0) { diff --git a/storage/maria/maria_pack.c b/storage/maria/maria_pack.c index 5a5aaf037f0..24de45a89bc 100644 --- a/storage/maria/maria_pack.c +++ b/storage/maria/maria_pack.c @@ -1107,18 +1107,18 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) my_off_t total_count; char llbuf[32]; - DBUG_PRINT("info", ("column: %3lu", count - huff_counts + 1)); + DBUG_PRINT("info", ("column: %3u", (uint) (count - huff_counts + 1))); if (verbose >= 2) - VOID(printf("column: %3lu\n", count - huff_counts + 1)); + VOID(printf("column: %3u\n", (uint) (count - huff_counts + 1))); if (count->tree_buff) { - DBUG_PRINT("info", ("number of distinct values: %lu", - (count->tree_pos - count->tree_buff) / - count->field_length)); + 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", - (count->tree_pos - count->tree_buff) / - count->field_length)); + VOID(printf("number of distinct values: %u\n", + (uint) ((count->tree_pos - count->tree_buff) / + count->field_length))); } total_count= 0; for (idx= 0; idx < 256; idx++) @@ -2038,7 +2038,7 @@ static void write_field_info(HUFF_COUNTS *counts, uint fields, uint trees) uint huff_tree_bits; huff_tree_bits=max_bit(trees ? trees-1 : 0); - DBUG_PRINT("info", ("")); + DBUG_PRINT("info", (" ")); DBUG_PRINT("info", ("column types:")); DBUG_PRINT("info", ("FIELD_NORMAL 0")); DBUG_PRINT("info", ("FIELD_SKIP_ENDSPACE 1")); @@ -2050,12 +2050,12 @@ static void write_field_info(HUFF_COUNTS *counts, uint fields, uint trees) DBUG_PRINT("info", ("FIELD_ZERO 7")); DBUG_PRINT("info", ("FIELD_VARCHAR 8")); DBUG_PRINT("info", ("FIELD_CHECK 9")); - DBUG_PRINT("info", ("")); + DBUG_PRINT("info", (" ")); DBUG_PRINT("info", ("pack type as a set of flags:")); DBUG_PRINT("info", ("PACK_TYPE_SELECTED 1")); DBUG_PRINT("info", ("PACK_TYPE_SPACE_FIELDS 2")); DBUG_PRINT("info", ("PACK_TYPE_ZERO_FILL 4")); - DBUG_PRINT("info", ("")); + DBUG_PRINT("info", (" ")); if (verbose >= 2) { VOID(printf("\n")); @@ -2128,7 +2128,7 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) return 0; } - DBUG_PRINT("info", ("")); + DBUG_PRINT("info", (" ")); if (verbose >= 2) VOID(printf("\n")); tree_no= 0; @@ -2139,7 +2139,7 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) if (huff_tree->tree_number == 0) continue; /* Deleted tree */ tree_no++; - DBUG_PRINT("info", ("")); + DBUG_PRINT("info", (" ")); if (verbose >= 3) VOID(printf("\n")); /* Count the total number of elements (byte codes or column values). */ @@ -2281,8 +2281,8 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) if (bits > 8 * sizeof(code)) { VOID(fflush(stdout)); - VOID(fprintf(stderr, "error: Huffman code too long: %u/%lu\n", - bits, 8 * sizeof(code))); + VOID(fprintf(stderr, "error: Huffman code too long: %u/%u\n", + bits, (uint) (8 * sizeof(code)))); errors++; break; } @@ -2331,7 +2331,7 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) } flush_bits(); } - DBUG_PRINT("info", ("")); + DBUG_PRINT("info", (" ")); if (verbose >= 2) VOID(printf("\n")); my_afree((gptr) packed_tree); @@ -2509,7 +2509,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) end_pos-=count->max_zero_fill; field_length-=count->max_zero_fill; - switch(count->field_type) { + switch (count->field_type) { case FIELD_SKIP_ZERO: if (!memcmp((byte*) start_pos,zero_string,field_length)) { @@ -2925,6 +2925,8 @@ static void flush_bits(void) bits-= 8; *file_buffer.pos++= (uchar) (bit_buffer >> bits); } + if (file_buffer.pos >= file_buffer.end) + VOID(flush_buffer(~ (ulong) 0)); file_buffer.bits= BITS_SAVED; file_buffer.bitbucket= 0; } 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))); } -- 2.30.9