diff options
-rw-r--r-- | .bzrignore | 1 | ||||
-rw-r--r-- | dbug/dbug.c | 2 | ||||
-rw-r--r-- | mysys/lf_alloc-pin.c | 8 | ||||
-rw-r--r-- | mysys/my_bitmap.c | 4 | ||||
-rw-r--r-- | mysys/my_compress.c | 2 | ||||
-rw-r--r-- | sql-bench/myisam.cnf | 3 | ||||
-rw-r--r-- | storage/maria/lockman.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_open.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_recovery.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_rsame.c | 3 | ||||
-rw-r--r-- | storage/maria/ma_scan.c | 7 | ||||
-rw-r--r-- | storage/maria/ma_statrec.c | 22 | ||||
-rw-r--r-- | storage/maria/ma_test2.c | 17 | ||||
-rwxr-xr-x | storage/maria/unittest/ma_test_recovery.pl | 37 | ||||
-rw-r--r-- | storage/myisam/mi_test2.c | 2 | ||||
-rw-r--r-- | strings/ctype.c | 4 |
16 files changed, 92 insertions, 26 deletions
diff --git a/.bzrignore b/.bzrignore index 01d027f2889..eb0e6681b38 100644 --- a/.bzrignore +++ b/.bzrignore @@ -3077,3 +3077,4 @@ maria_log.00000* ma_test_recovery.output test?.MA? dbug/tests +storage/maria/unittest/tmp/* diff --git a/dbug/dbug.c b/dbug/dbug.c index d6f436f5780..b2ba6cd094f 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -124,7 +124,7 @@ #define SANITY_CHECK_ON (1 << 10) /* Check safemalloc on DBUG_ENTER */ #define FLUSH_ON_WRITE (1 << 11) /* Flush on every write */ #define OPEN_APPEND (1 << 12) /* Open for append */ -#define TRACE_ON (1 << 31) /* Trace enabled. MUST be the highest bit!*/ +#define TRACE_ON ((uint)1 << 31) /* Trace enabled. MUST be the highest bit!*/ #define TRACING (cs->stack->flags & TRACE_ON) #define DEBUGGING (cs->stack->flags & DEBUG_ON) diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c index ff9c5a42f81..3e91b70d0f8 100644 --- a/mysys/lf_alloc-pin.c +++ b/mysys/lf_alloc-pin.c @@ -169,7 +169,7 @@ LF_PINS *_lf_pinbox_get_pins(LF_PINBOX *pinbox, void *stack_end) if (!(pins= top_ver % LF_PINBOX_MAX_PINS)) { /* the stack of free elements is empty */ - pins= my_atomic_add32(&pinbox->pins_in_array, 1)+1; + pins= my_atomic_add32((int32 volatile*) &pinbox->pins_in_array, 1)+1; if (unlikely(pins >= LF_PINBOX_MAX_PINS)) return 0; /* @@ -183,7 +183,8 @@ LF_PINS *_lf_pinbox_get_pins(LF_PINBOX *pinbox, void *stack_end) } el= (LF_PINS *)_lf_dynarray_value(&pinbox->pinarray, pins); next= el->link; - } while (!my_atomic_cas32(&pinbox->pinstack_top_ver, &top_ver, + } while (!my_atomic_cas32((int32 volatile*) &pinbox->pinstack_top_ver, + (int32*) &top_ver, top_ver-pins+next+LF_PINBOX_MAX_PINS)); /* set el->link to the index of el in the dynarray (el->link has two usages: @@ -237,7 +238,8 @@ void _lf_pinbox_put_pins(LF_PINS *pins) do { pins->link= top_ver % LF_PINBOX_MAX_PINS; - } while (!my_atomic_cas32(&pinbox->pinstack_top_ver, &top_ver, + } while (!my_atomic_cas32((int32 volatile*) &pinbox->pinstack_top_ver, + (int32*) &top_ver, top_ver-pins->link+nr+LF_PINBOX_MAX_PINS)); return; } diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index e127b2584ae..137127a2fda 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -508,10 +508,8 @@ uint bitmap_get_first_set(const MY_BITMAP *map) if (*byte_ptr & (1 << k)) return (i*32) + (j*8) + k; } - DBUG_ASSERT(0); } } - DBUG_ASSERT(0); } } return MY_BIT_NONE; @@ -542,10 +540,8 @@ uint bitmap_get_first(const MY_BITMAP *map) if (!(*byte_ptr & (1 << k))) return (i*32) + (j*8) + k; } - DBUG_ASSERT(0); } } - DBUG_ASSERT(0); } } return MY_BIT_NONE; diff --git a/mysys/my_compress.c b/mysys/my_compress.c index 70d2960f48e..45c4ab983cc 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -183,7 +183,7 @@ int packfrm(uchar *data, size_t len, DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", (ulong) org_len, (ulong) comp_len)); - DBUG_DUMP("compressed", (char*)data, org_len); + DBUG_DUMP("compressed", data, org_len); error= 2; blob_len= BLOB_HEADER + org_len; diff --git a/sql-bench/myisam.cnf b/sql-bench/myisam.cnf new file mode 100644 index 00000000000..4229f56cefb --- /dev/null +++ b/sql-bench/myisam.cnf @@ -0,0 +1,3 @@ +[mysqld] +data=/data +key_buffer_size=256M diff --git a/storage/maria/lockman.c b/storage/maria/lockman.c index 4c5f69ce7f9..27f76aabf38 100644 --- a/storage/maria/lockman.c +++ b/storage/maria/lockman.c @@ -631,7 +631,7 @@ enum lockman_getlock_result lockman_getlock(LOCKMAN *lm, LOCK_OWNER *lo, /* a new value was added to the hash */ csize= lm->size; if ((my_atomic_add32(&lm->count, 1)+1.0) / csize > MAX_LOAD) - my_atomic_cas32(&lm->size, &csize, csize*2); + my_atomic_cas32(&lm->size, (int*) &csize, csize*2); node->lonext= lo->all_locks; lo->all_locks= node; for ( ; res & NEED_TO_WAIT; res= lockpeek(el, node, pins, &blocker)) diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 7f1676c5d85..fac531aec4e 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -460,6 +460,8 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) if (share->options & HA_OPTION_COMPRESS_RECORD) share->base.max_key_length+=2; /* For safety */ + /* Add space for node pointer */ + share->base.max_key_length+= share->base.key_reflength; if (!my_multi_malloc(MY_WME, &share,sizeof(*share), diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 6423cd342a1..ac6262167b7 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -3265,7 +3265,7 @@ static void print_redo_phase_progress(TRANSLOG_ADDRESS addr) { static uint end_logno= FILENO_IMPOSSIBLE, percentage_printed= 0; static ulong end_offset; - static ulonglong initial_remainder= -1; + static ulonglong initial_remainder= ~(ulonglong) 0; uint cur_logno; ulong cur_offset; diff --git a/storage/maria/ma_rsame.c b/storage/maria/ma_rsame.c index 9c9acac013a..2e4d5a60ed8 100644 --- a/storage/maria/ma_rsame.c +++ b/storage/maria/ma_rsame.c @@ -34,11 +34,13 @@ int maria_rsame(MARIA_HA *info, uchar *record, int inx) if (inx != -1 && ! maria_is_key_active(info->s->state.key_map, inx)) { + DBUG_PRINT("error", ("wrong index usage")); DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); } if (info->cur_row.lastpos == HA_OFFSET_ERROR || info->update & HA_STATE_DELETED) { + DBUG_PRINT("error", ("no current record")); DBUG_RETURN(my_errno=HA_ERR_KEY_NOT_FOUND); /* No current record */ } info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); @@ -65,5 +67,6 @@ int maria_rsame(MARIA_HA *info, uchar *record, int inx) DBUG_RETURN(0); if (my_errno == HA_ERR_RECORD_DELETED) my_errno=HA_ERR_KEY_NOT_FOUND; + DBUG_PRINT("error", ("my_errno: %d", my_errno)); DBUG_RETURN(my_errno); } /* maria_rsame */ diff --git a/storage/maria/ma_scan.c b/storage/maria/ma_scan.c index 48e9e3400ce..cbac463a2c8 100644 --- a/storage/maria/ma_scan.c +++ b/storage/maria/ma_scan.c @@ -40,9 +40,10 @@ int maria_scan_init(register MARIA_HA *info) record Read data here RETURN - 0 ok - HA_ERR_END_OF_FILE End of file - # Error code + 0 ok + HA_ERR_END_OF_FILE End of file + HA_ERR_RECORD_DELETED Record was deleted (can only happen for static rec) + # Error code */ int maria_scan(MARIA_HA *info, uchar *record) diff --git a/storage/maria/ma_statrec.c b/storage/maria/ma_statrec.c index c8ba1d5d234..3e744e12045 100644 --- a/storage/maria/ma_statrec.c +++ b/storage/maria/ma_statrec.c @@ -173,13 +173,14 @@ int _ma_read_static_record(register MARIA_HA *info, register uchar *record, MARIA_RECORD_POS pos) { int error; + DBUG_ENTER("_ma_read_static_record"); if (pos != HA_OFFSET_ERROR) { if (info->opt_flag & WRITE_CACHE_USED && info->rec_cache.pos_in_file <= pos && flush_io_cache(&info->rec_cache)) - return(my_errno); + DBUG_RETURN(my_errno); info->rec_cache.seek_not_done=1; /* We have done a seek */ error= (int) info->s->file_read(info, record,info->s->base.reclength, @@ -190,17 +191,27 @@ int _ma_read_static_record(register MARIA_HA *info, register uchar *record, if (!*record) { /* Record is deleted */ - return ((my_errno=HA_ERR_RECORD_DELETED)); + DBUG_PRINT("warning", ("Record is deleted")); + DBUG_RETURN((my_errno=HA_ERR_RECORD_DELETED)); } info->update|= HA_STATE_AKTIV; /* Record is read */ - return(0); + DBUG_RETURN(0); } } fast_ma_writeinfo(info); /* No such record */ - return(my_errno); + DBUG_RETURN(my_errno); } +/** + @brief Read record from given position or next record + + @note + When scanning, this function will return HA_ERR_RECORD_DELETED + for deleted rows even if skip_deleted_blocks is set. + The reason for this is to allow the caller to calculate the record + position without having to do call maria_position() for each record. +*/ int _ma_read_rnd_static_record(MARIA_HA *info, uchar *buf, MARIA_RECORD_POS filepos, @@ -219,7 +230,8 @@ int _ma_read_rnd_static_record(MARIA_HA *info, uchar *buf, (skip_deleted_blocks || !filepos)) { cache_read=1; /* Read record using cache */ - cache_length=(uint) (info->rec_cache.read_end - info->rec_cache.read_pos); + cache_length= (uint) (info->rec_cache.read_end - + info->rec_cache.read_pos); } else info->rec_cache.seek_not_done=1; /* Filepos is changed */ diff --git a/storage/maria/ma_test2.c b/storage/maria/ma_test2.c index aed7f2b8a04..dfb85df0a2d 100644 --- a/storage/maria/ma_test2.c +++ b/storage/maria/ma_test2.c @@ -660,6 +660,12 @@ int main(int argc, char *argv[]) printf("Got error %d when scanning table\n", tmp); break; } + if (!tmp) + { + /* Remember position to last found row */ + info.recpos= maria_position(file); + bmove(read_record2,read_record,reclength); + } } maria_scan_end(file); if (i != write_count && i != write_count - opt_delete) @@ -668,7 +674,14 @@ int main(int argc, char *argv[]) goto err; } - bmove(read_record2,read_record,reclength); + if (maria_rsame_with_pos(file,read_record,0,info.recpos)) + goto err; + if (bcmp(read_record,read_record2,reclength) != 0) + { + printf("maria_rsame_with_pos didn't find same record\n"); + goto err; + } + for (i=min(2,keys) ; i-- > 0 ;) { if (maria_rsame(file,read_record2,(int) i)) goto err; @@ -860,7 +873,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)) diff --git a/storage/maria/unittest/ma_test_recovery.pl b/storage/maria/unittest/ma_test_recovery.pl index 214e8d1d854..5aabbdc185a 100755 --- a/storage/maria/unittest/ma_test_recovery.pl +++ b/storage/maria/unittest/ma_test_recovery.pl @@ -8,6 +8,7 @@ my $silent= "-s"; my $tmp= "./tmp"; my $maria_path; # path to "storage/maria" my $maria_exe_path; # path to executables (ma_test1, maria_chk etc) +my $md5sum; $maria_path= dirname($0) . "/.."; @@ -29,8 +30,22 @@ if ( ! -f "$maria_exe_path/ma_test1$suffix" ) } } } -} +} + +# Test if we should use md5sum or digest -a md5 +if (defined(my_which("md5sum"))) +{ + $md5sum="md5sum"; +} +elsif (defined(my_which("digest"))) +{ + $md5sum="digest -a md5"; +} +else +{ + die "Can't find either md5sum or digest. Please install one of them" +} # test data is always put in the current directory or a tmp subdirectory of it @@ -307,11 +322,11 @@ sub apply_log print MY_LOG "bad argument '$shouldchangelog'\n"; return 1; } - $log_md5= `md5sum maria_log.*`; + $log_md5= `$md5sum maria_log.*`; print MY_LOG "applying log\n"; `$maria_exe_path/maria_read_log$suffix -a > $tmp/maria_read_log_$table.txt`; - $log_md5_2= `md5sum maria_log.*`; + $log_md5_2= `$md5sum maria_log.*`; if ("$log_md5" ne "$log_md5_2" ) { if ("$shouldchangelog" eq "shouldnotchangelog") @@ -326,3 +341,19 @@ sub apply_log return 1; } } + + +sub my_which +{ + my ($command) = @_; + my (@paths, $path); + + return $command if (-f $command && -x $command); + @paths = split(':', $ENV{'PATH'}); + foreach $path (@paths) + { + $path .= "/$command"; + return $path if (-f $path && -x $path); + } + return undef(); +} 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)) diff --git a/strings/ctype.c b/strings/ctype.c index c313708f3f6..59ebb50b124 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -328,7 +328,9 @@ my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong length) { my_wc_t wc; int chlen; - for (; (chlen= cs->cset->mb_wc(cs, &wc, str, strend)) > 0; str+= chlen) + for (; + (chlen= cs->cset->mb_wc(cs, &wc, (uchar*) str, (uchar*) strend)) > 0; + str+= chlen) { if (wc > 0x7F) return MY_REPERTOIRE_UNICODE30; |