diff options
author | unknown <guilhem@gbichot4.local> | 2008-04-03 15:40:25 +0200 |
---|---|---|
committer | unknown <guilhem@gbichot4.local> | 2008-04-03 15:40:25 +0200 |
commit | f094eff1d9d0c3cc101c6506b710a054228c8691 (patch) | |
tree | be93a10c6b779c7ccf85949a660b4c8aa236cf57 /storage | |
parent | 50808b211527a165386b771c6f13d3ca7ba29f1a (diff) | |
download | mariadb-git-f094eff1d9d0c3cc101c6506b710a054228c8691.tar.gz |
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
Diffstat (limited to 'storage')
44 files changed, 301 insertions, 262 deletions
diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index 5cc72f38d50..ee3364bf59c 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -2733,10 +2733,10 @@ static my_bool _ma_bitmap_create_missing(MARIA_HA *info, { LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE * 2]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; page_store(log_data + FILEID_STORE_SIZE, from); page_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE, page); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); /* We don't use info->trn so that this REDO is always executed even though diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index c9b508626e5..7ac1df772d5 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -1794,7 +1794,7 @@ static my_bool write_tail(MARIA_HA *info, { /* Log changes in tail block */ uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + DIRPOS_STORE_SIZE]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; LSN lsn; /* @@ -1806,9 +1806,9 @@ static my_bool write_tail(MARIA_HA *info, page_store(log_data + FILEID_STORE_SIZE, block->page); dirpos_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE, row_pos.rownr); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) row_pos.data; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= row_pos.data; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= length; if (translog_write_record(&lsn, (block_is_read ? LOGREC_REDO_INSERT_ROW_TAIL : @@ -2208,7 +2208,7 @@ static my_bool extent_to_bitmap_blocks(MARIA_HA *info, static my_bool free_full_pages(MARIA_HA *info, MARIA_ROW *row) { uchar log_data[FILEID_STORE_SIZE + PAGERANGE_STORE_SIZE]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; LSN lsn; size_t extents_length; uchar *extents= row->extents; @@ -2267,9 +2267,9 @@ static my_bool free_full_pages(MARIA_HA *info, MARIA_ROW *row) } extents_count= (uint) (extents_length / ROW_EXTENT_SIZE); pagerange_store(log_data + FILEID_STORE_SIZE, extents_count); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) compact_extent_info; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= compact_extent_info; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= extents_length; res= translog_write_record(&lsn, LOGREC_REDO_FREE_BLOCKS, info->trn, info, @@ -2315,14 +2315,14 @@ static my_bool free_full_page_range(MARIA_HA *info, pgcache_page_no_t page, /** @todo unify log_data's shape with delete_head_or_tail() */ uchar log_data[FILEID_STORE_SIZE + PAGERANGE_STORE_SIZE + ROW_EXTENT_SIZE]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; DBUG_ASSERT(info->trn->rec_lsn); pagerange_store(log_data + FILEID_STORE_SIZE, 1); page_store(log_data + FILEID_STORE_SIZE + PAGERANGE_STORE_SIZE, page); int2store(log_data + FILEID_STORE_SIZE + PAGERANGE_STORE_SIZE + PAGE_STORE_SIZE, count); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); if (translog_write_record(&lsn, LOGREC_REDO_FREE_BLOCKS, @@ -2560,7 +2560,7 @@ static my_bool write_block_record(MARIA_HA *info, tmp_data_used= tmp_data; tmp_data= info->rec_buff; } - memcpy((char*) tmp_data, (char*) field_pos, length); + memcpy((char*) tmp_data, field_pos, length); tmp_data+= length; } @@ -2861,15 +2861,15 @@ static my_bool write_block_record(MARIA_HA *info, if (share->now_transactional) { uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + DIRPOS_STORE_SIZE]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; /* Log REDO changes of head page */ page_store(log_data + FILEID_STORE_SIZE, head_block->page); dirpos_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE, row_pos->rownr); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) row_pos->data; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= row_pos->data; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= head_length; if (translog_write_record(&lsn, head_block_is_read ? @@ -2944,9 +2944,9 @@ static my_bool write_block_record(MARIA_HA *info, (ROW_EXTENT_SIZE + BLOCK_FILLER_SIZE + SUB_RANGE_SIZE) * ROW_EXTENTS_ON_STACK]; uchar *log_data, *log_pos; - LEX_STRING tmp_log_array[TRANSLOG_INTERNAL_PARTS + 2 + - ROW_EXTENTS_ON_STACK]; - LEX_STRING *log_array_pos, *log_array; + LEX_CUSTRING tmp_log_array[TRANSLOG_INTERNAL_PARTS + 2 + + ROW_EXTENTS_ON_STACK]; + LEX_CUSTRING *log_array_pos, *log_array; int error; translog_size_t log_entry_length= 0; uint ext_length, extents= 0, sub_extents= 0; @@ -3025,7 +3025,7 @@ static my_bool write_block_record(MARIA_HA *info, } } - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; ext_length= (uint) (log_pos - log_data); log_array[TRANSLOG_INTERNAL_PARTS + 0].length= ext_length; pagerange_store(log_data+ FILEID_STORE_SIZE, extents); @@ -3081,7 +3081,7 @@ static my_bool write_block_record(MARIA_HA *info, PAGE_STORE_SIZE, row_pos->rownr); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (LSN_STORE_SIZE + FILEID_STORE_SIZE + PAGE_STORE_SIZE + DIRPOS_STORE_SIZE); @@ -3102,7 +3102,8 @@ static my_bool write_block_record(MARIA_HA *info, (translog_size_t) log_array[TRANSLOG_INTERNAL_PARTS + 0].length, - TRANSLOG_INTERNAL_PARTS + 1, log_array, + TRANSLOG_INTERNAL_PARTS + 1, + (LEX_CUSTRING *)log_array, log_data + LSN_STORE_SIZE, &checksum_delta)) goto disk_err; } @@ -3124,7 +3125,7 @@ static my_bool write_block_record(MARIA_HA *info, log_array[TRANSLOG_INTERNAL_PARTS + 0].length+= (2 + PAGERANGE_STORE_SIZE); info->log_row_parts[TRANSLOG_INTERNAL_PARTS+1].str= - (char *) info->cur_row.extents; + info->cur_row.extents; info->log_row_parts[TRANSLOG_INTERNAL_PARTS+1].length= extents_length= info->cur_row.extents_count * ROW_EXTENT_SIZE; @@ -3140,7 +3141,8 @@ static my_bool write_block_record(MARIA_HA *info, row_length), TRANSLOG_INTERNAL_PARTS + 2 + row_parts_count, - log_array, log_data + LSN_STORE_SIZE, + (LEX_CUSTRING *)log_array, + log_data + LSN_STORE_SIZE, &checksum_delta)) goto disk_err; } @@ -3864,7 +3866,7 @@ static my_bool delete_head_or_tail(MARIA_HA *info, if (res == 0) /* after our deletion, page is still not empty */ { uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + DIRPOS_STORE_SIZE]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; if (share->now_transactional) { /* Log REDO data */ @@ -3872,7 +3874,7 @@ static my_bool delete_head_or_tail(MARIA_HA *info, dirpos_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE, record_number); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); if (translog_write_record(&lsn, (head ? LOGREC_REDO_PURGE_ROW_HEAD : LOGREC_REDO_PURGE_ROW_TAIL), @@ -3888,9 +3890,9 @@ static my_bool delete_head_or_tail(MARIA_HA *info, if (share->now_transactional) { uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; page_store(log_data + FILEID_STORE_SIZE, page); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); if (translog_write_record(&lsn, LOGREC_REDO_FREE_HEAD_OR_TAIL, info->trn, info, @@ -4006,7 +4008,7 @@ my_bool _ma_delete_block_record(MARIA_HA *info, const uchar *record) pagerange_store(log_pos, info->cur_row.extents_count); log_pos+= PAGERANGE_STORE_SIZE; - info->log_row_parts[TRANSLOG_INTERNAL_PARTS].str= (char*) log_data; + info->log_row_parts[TRANSLOG_INTERNAL_PARTS].str= log_data; info->log_row_parts[TRANSLOG_INTERNAL_PARTS].length= sizeof(log_data) - HA_CHECKSUM_STORE_SIZE; store_checksum_in_rec(share, checksum_delta, @@ -4014,12 +4016,13 @@ my_bool _ma_delete_block_record(MARIA_HA *info, const uchar *record) info->log_row_parts[TRANSLOG_INTERNAL_PARTS + 0].length); info->log_row_parts[TRANSLOG_INTERNAL_PARTS+1].str= - (char *) info->cur_row.extents; + info->cur_row.extents; info->log_row_parts[TRANSLOG_INTERNAL_PARTS+1].length= extents_length= info->cur_row.extents_count * ROW_EXTENT_SIZE; - row_length= fill_insert_undo_parts(info, record, info->log_row_parts + - TRANSLOG_INTERNAL_PARTS + 2, + row_length= fill_insert_undo_parts(info, record, + (info->log_row_parts + + TRANSLOG_INTERNAL_PARTS + 2), &row_parts_count); if (translog_write_record(&lsn, LOGREC_UNDO_ROW_DELETE, info->trn, @@ -4029,7 +4032,8 @@ my_bool _ma_delete_block_record(MARIA_HA *info, const uchar *record) 0].length + row_length + extents_length), TRANSLOG_INTERNAL_PARTS + 2 + row_parts_count, - info->log_row_parts, log_data + LSN_STORE_SIZE, + (LEX_CUSTRING *)info->log_row_parts, + log_data + LSN_STORE_SIZE, &checksum_delta)) goto err; } @@ -5269,7 +5273,8 @@ static size_t fill_insert_undo_parts(MARIA_HA *info, const uchar *record, start_log_parts= log_parts; /* Store null bits */ - log_parts->str= (char*) record; + /* We cast "const uchar*" to char* but won't change its pointed content */ + log_parts->str= (char*)record; log_parts->length= share->base.null_bytes; row_length= log_parts->length; log_parts++; @@ -5462,6 +5467,7 @@ static size_t fill_update_undo_parts(MARIA_HA *info, const uchar *oldrec, { /* Store changed null bits */ *field_data++= (uchar) 255; /* Special case */ + /* We cast "const uchar*" to char* but won't change its pointed content */ log_parts->str= (char*) oldrec; log_parts->length= share->base.null_bytes; row_length= log_parts->length; @@ -6485,8 +6491,7 @@ err: /** Execute undo of a row delete (insert the row back where it was) */ my_bool _ma_apply_undo_row_delete(MARIA_HA *info, LSN undo_lsn, - const uchar *header, - size_t header_length + uchar *header, size_t header_length __attribute__((unused))) { MARIA_SHARE *share= info->s; @@ -6544,16 +6549,16 @@ my_bool _ma_apply_undo_row_delete(MARIA_HA *info, LSN undo_lsn, null_bits= header; header+= share->base.null_bytes; - row.empty_bits= (uchar*) header; + row.empty_bits= header; header+= share->base.pack_bytes; if (share->base.max_field_lengths) { row.field_lengths_length= uint2korr(header); - row.field_lengths= (uchar*) header + 2 ; + row.field_lengths= header + 2 ; header+= 2 + row.field_lengths_length; } if (share->base.blobs) - row.blob_length= ma_get_length((uchar**) &header); + row.blob_length= ma_get_length(&header); /* We need to build up a record (without blobs) in rec_buff */ if (!(record= my_malloc(share->base.reclength, MYF(MY_WME)))) @@ -6729,13 +6734,13 @@ err: */ my_bool _ma_apply_undo_row_update(MARIA_HA *info, LSN undo_lsn, - const uchar *header, - size_t header_length + uchar *header, size_t header_length __attribute__((unused))) { MARIA_SHARE *share= info->s; MARIA_RECORD_POS record_pos; - const uchar *field_length_data, *field_length_data_end, *extent_info; + uchar *field_length_data; + const uchar *field_length_data_end, *extent_info; uchar *current_record, *orig_record; pgcache_page_no_t page; ha_checksum checksum_delta; @@ -6768,7 +6773,7 @@ my_bool _ma_apply_undo_row_update(MARIA_HA *info, LSN undo_lsn, Set header to point to old field values, generated by fill_update_undo_parts() */ - field_length_header= ma_get_length((uchar**) &header); + field_length_header= ma_get_length(&header); field_length_data= header; header+= field_length_header; field_length_data_end= header; @@ -6795,14 +6800,14 @@ my_bool _ma_apply_undo_row_update(MARIA_HA *info, LSN undo_lsn, while (field_length_data < field_length_data_end) { - uint field_nr= ma_get_length((uchar**) &field_length_data), field_length; + uint field_nr= ma_get_length(&field_length_data), field_length; MARIA_COLUMNDEF *column= share->columndef + field_nr; uchar *orig_field_pos= orig_record + column->offset; bitmap_set_bit(&info->changed_fields, field_nr); if (field_nr >= share->base.fixed_not_null_fields) { - if (!(field_length= ma_get_length((uchar**) &field_length_data))) + if (!(field_length= ma_get_length(&field_length_data))) { /* Null field or empty field */ bfill(orig_field_pos, column->fill_length, diff --git a/storage/maria/ma_blockrec.h b/storage/maria/ma_blockrec.h index 6d7e4475868..05c5b99e8d0 100644 --- a/storage/maria/ma_blockrec.h +++ b/storage/maria/ma_blockrec.h @@ -243,9 +243,9 @@ my_bool _ma_apply_redo_bitmap_new_page(MARIA_HA *info, LSN lsn, my_bool _ma_apply_undo_row_insert(MARIA_HA *info, LSN undo_lsn, const uchar *header); my_bool _ma_apply_undo_row_delete(MARIA_HA *info, LSN undo_lsn, - const uchar *header, size_t length); + uchar *header, size_t length); my_bool _ma_apply_undo_row_update(MARIA_HA *info, LSN undo_lsn, - const uchar *header, size_t length); + uchar *header, size_t length); my_bool _ma_apply_undo_bulk_insert(MARIA_HA *info, LSN undo_lsn); my_bool write_hook_for_redo(enum translog_record_type type, diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 9a7d189d291..69fede7b91a 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -703,7 +703,7 @@ void maria_collect_stats_nonulls_first(HA_KEYSEG *keyseg, ulonglong *notnull, const uchar *key) { uint first_null, kp; - first_null= ha_find_null(keyseg, (uchar*) key) - keyseg; + first_null= ha_find_null(keyseg, key) - keyseg; /* All prefix tuples that don't include keypart_{first_null} are not-null tuples (and all others aren't), increment counters for them. @@ -755,12 +755,12 @@ int maria_collect_stats_nonulls_next(HA_KEYSEG *keyseg, ulonglong *notnull, last_key that is NULL or different from corresponding value in prev_key. */ - ha_key_cmp(keyseg, (uchar*) prev_key, (uchar*) last_key, USE_WHOLE_KEY, + ha_key_cmp(keyseg, prev_key, last_key, USE_WHOLE_KEY, SEARCH_FIND | SEARCH_NULL_ARE_NOT_EQUAL, diffs); seg= keyseg + diffs[0] - 1; /* Find first NULL in last_key */ - first_null_seg= ha_find_null(seg, (uchar*) last_key + diffs[1]) - keyseg; + first_null_seg= ha_find_null(seg, last_key + diffs[1]) - keyseg; for (kp= 0; kp < first_null_seg; kp++) notnull[kp]++; @@ -5051,7 +5051,8 @@ static int sort_key_cmp(MARIA_SORT_PARAM *sort_param, const void *a, const void *b) { uint not_used[2]; - return (ha_key_cmp(sort_param->seg, *((uchar**) a), *((uchar**) b), + return (ha_key_cmp(sort_param->seg, *((uchar* const *) a), + *((uchar* const *) b), USE_WHOLE_KEY, SEARCH_SAME, not_used)); } /* sort_key_cmp */ @@ -5067,11 +5068,11 @@ static int sort_key_write(MARIA_SORT_PARAM *sort_param, const uchar *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, + 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, (uchar*) sort_info->key_block->lastkey, - (uchar*) a, USE_WHOLE_KEY, + a, USE_WHOLE_KEY, SEARCH_FIND | SEARCH_NULL_ARE_NOT_EQUAL, diff_pos); else if (param->stats_method == MI_STATS_METHOD_IGNORE_NULLS) { @@ -5178,7 +5179,7 @@ static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param, MARIA_SHARE *share= sort_info->info->s; val_len=HA_FT_WLEN+share->base.rec_reflength; - get_key_full_length_rdonly(a_len, (uchar *)a); + get_key_full_length_rdonly(a_len, a); if (!ft_buf) { @@ -5204,7 +5205,7 @@ static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param, get_key_full_length_rdonly(val_off, ft_buf->lastkey); if (ha_compare_text(sort_param->seg->charset, - ((uchar *)a)+1,a_len-1, + a+1,a_len-1, (uchar*) ft_buf->lastkey+1,val_off-1, 0, 0)==0) { uchar *p; @@ -5216,7 +5217,7 @@ static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param, } /* storing the key in the buffer. */ - memcpy (ft_buf->buf, (char *)a+a_len, val_len); + memcpy (ft_buf->buf, (const char *)a+a_len, val_len); ft_buf->buf+=val_len; if (ft_buf->buf < ft_buf->end) return 0; @@ -5971,7 +5972,7 @@ static ha_checksum maria_byte_checksum(const uchar *buf, uint length) ha_checksum crc; const uchar *end=buf+length; for (crc=0; buf != end; buf++) - crc=((crc << 1) + *((uchar*) buf)) + + crc=((crc << 1) + *buf) + test(crc & (((ha_checksum) 1) << (8*sizeof(ha_checksum)-1))); return crc; } @@ -6355,7 +6356,7 @@ my_bool write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info) was it was at the start of the original repair (should be stored in log record). */ - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; uchar log_data[FILEID_STORE_SIZE + 8 + 8]; LSN lsn; @@ -6367,7 +6368,7 @@ my_bool write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info) /* org_key_map is used when recreating index after a load data infile */ int8store(log_data + FILEID_STORE_SIZE + 8, param->org_key_map); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); share->now_transactional= 1; @@ -6408,11 +6409,11 @@ my_bool write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info) */ my_bool write_log_record_for_bulk_insert(MARIA_HA *info) { - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE]; LSN lsn; lsn_store(log_data, info->trn->undo_lsn); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); return translog_write_record(&lsn, LOGREC_UNDO_BULK_INSERT, info->trn, info, diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c index 33f7176fc08..8d61094899f 100644 --- a/storage/maria/ma_checkpoint.c +++ b/storage/maria/ma_checkpoint.c @@ -220,14 +220,15 @@ static int really_execute_checkpoint(void) of its argument, so we must not pass it record_pieces directly, otherwise we would later not know what memory pieces to my_free(). */ - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 5]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 5]; log_array[TRANSLOG_INTERNAL_PARTS + 0].str= checkpoint_start_log_horizon_char; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= total_rec_length= sizeof(checkpoint_start_log_horizon_char); for (i= 0; i < (sizeof(record_pieces)/sizeof(record_pieces[0])); i++) { - log_array[TRANSLOG_INTERNAL_PARTS + 1 + i]= record_pieces[i]; + log_array[TRANSLOG_INTERNAL_PARTS + 1 + i]= + *(LEX_CUSTRING *)&record_pieces[i]; total_rec_length+= (translog_size_t) record_pieces[i].length; } if (unlikely(translog_write_record(&lsn, LOGREC_CHECKPOINT, diff --git a/storage/maria/ma_checksum.c b/storage/maria/ma_checksum.c index b48eae1c27d..61ec638053a 100644 --- a/storage/maria/ma_checksum.c +++ b/storage/maria/ma_checksum.c @@ -67,7 +67,7 @@ ha_checksum _ma_checksum(MARIA_HA *info, const uchar *record) { uint pack_length= column->fill_length; if (pack_length == 1) - length= (ulong) *(uchar*) pos; + length= (ulong) *pos; else length= uint2korr(pos); pos+= pack_length; /* Skip length information */ diff --git a/storage/maria/ma_commit.c b/storage/maria/ma_commit.c index 9dfbd1da24f..2d36293b697 100644 --- a/storage/maria/ma_commit.c +++ b/storage/maria/ma_commit.c @@ -30,7 +30,7 @@ int ma_commit(TRN *trn) { int res; LSN commit_lsn; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS]; DBUG_ENTER("ma_commit"); if (trn->undo_lsn == 0) /* no work done, rollback (cheaper than commit) */ diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c index e99bbe8970e..abfb4c0c514 100644 --- a/storage/maria/ma_create.c +++ b/storage/maria/ma_create.c @@ -990,7 +990,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, not log 1 KB of mostly zeroes if this is a small table. */ char empty_string[]= ""; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; translog_size_t total_rec_length= 0; uint k; LSN lsn; @@ -1009,17 +1009,17 @@ int maria_create(const char *name, enum data_file_type datafile_type, log_data[0]= test(flags & HA_DONT_TOUCH_DATA); int2store(log_data + 1, kfile_size_before_extension); int2store(log_data + 1 + 2, share.base.keystart); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char *)name; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= name; /* we store the end-zero, for Recovery to just pass it to my_create() */ log_array[TRANSLOG_INTERNAL_PARTS + 0].length= strlen(log_array[TRANSLOG_INTERNAL_PARTS + 0].str) + 1; - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char *) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= log_data; /* symlink description is also needed for re-creation by Recovery: */ - log_array[TRANSLOG_INTERNAL_PARTS + 2].str= (char *) + log_array[TRANSLOG_INTERNAL_PARTS + 2].str= (ci->data_file_name ? ci->data_file_name : empty_string); log_array[TRANSLOG_INTERNAL_PARTS + 2].length= strlen(log_array[TRANSLOG_INTERNAL_PARTS + 2].str) + 1; - log_array[TRANSLOG_INTERNAL_PARTS + 3].str= (char *) + log_array[TRANSLOG_INTERNAL_PARTS + 3].str= (ci->index_file_name ? ci->index_file_name : empty_string); log_array[TRANSLOG_INTERNAL_PARTS + 3].length= strlen(log_array[TRANSLOG_INTERNAL_PARTS + 3].str) + 1; diff --git a/storage/maria/ma_dbug.c b/storage/maria/ma_dbug.c index c706fd253cd..3fea275cfe5 100644 --- a/storage/maria/ma_dbug.c +++ b/storage/maria/ma_dbug.c @@ -70,7 +70,7 @@ void _ma_print_key(FILE *stream, register HA_KEYSEG *keyseg, } break; case HA_KEYTYPE_INT8: - VOID(fprintf(stream,"%d",(int) *((signed char*) key))); + VOID(fprintf(stream,"%d",(int) *((const signed char*) key))); key=end; break; case HA_KEYTYPE_SHORT_INT: diff --git a/storage/maria/ma_delete.c b/storage/maria/ma_delete.c index 129380736b8..d0757b8f274 100644 --- a/storage/maria/ma_delete.c +++ b/storage/maria/ma_delete.c @@ -180,7 +180,7 @@ int _ma_ck_delete(register MARIA_HA *info, uint keynr, uchar *key, { uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE + KEY_NR_STORE_SIZE + PAGE_STORE_SIZE], *log_pos; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; struct st_msg_to_write_hook_for_undo_key msg; enum translog_record_type log_type= LOGREC_UNDO_KEY_DELETE; @@ -207,9 +207,9 @@ int _ma_ck_delete(register MARIA_HA *info, uint keynr, uchar *key, This is because the row may be inserted at a different place when we exceute the undo */ - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) key_buff; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= key_buff; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= key_length; msg.root= &share->state.key_root[keynr]; @@ -1377,7 +1377,7 @@ static my_bool _ma_log_delete(MARIA_HA *info, my_off_t page, uchar *buff, { LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 9 + 7], *log_pos; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; MARIA_SHARE *share= info->s; uint translog_parts; uint offset= (uint) (key_pos - buff); @@ -1403,7 +1403,7 @@ static my_bool _ma_log_delete(MARIA_HA *info, my_off_t page, uchar *buff, int2store(log_pos+1, changed_length); log_pos+= 3; translog_parts= 2; - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char *) buff + offset; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= buff + offset; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= changed_length; } @@ -1416,14 +1416,14 @@ static my_bool _ma_log_delete(MARIA_HA *info, my_off_t page, uchar *buff, int2store(log_pos+1, page_length); int4store(log_pos+3, crc); - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= (char *) log_pos; + log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; changed_length+= 7; translog_parts++; } #endif - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); if (translog_write_record(&lsn, LOGREC_REDO_INDEX, diff --git a/storage/maria/ma_delete_all.c b/storage/maria/ma_delete_all.c index c209196ff9a..3f7f3110e28 100644 --- a/storage/maria/ma_delete_all.c +++ b/storage/maria/ma_delete_all.c @@ -61,9 +61,9 @@ int maria_delete_all_rows(MARIA_HA *info) This record will be used by Recovery to finish the deletion if it crashed. We force it to have a complete history in the log. */ - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; uchar log_data[FILEID_STORE_SIZE]; - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); if (unlikely(translog_write_record(&lsn, LOGREC_REDO_DELETE_ALL, info->trn, info, 0, diff --git a/storage/maria/ma_delete_table.c b/storage/maria/ma_delete_table.c index bdfece7ada7..43e15b614aa 100644 --- a/storage/maria/ma_delete_table.c +++ b/storage/maria/ma_delete_table.c @@ -84,8 +84,8 @@ int maria_delete_table(const char *name) it. */ LSN lsn; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char *)name; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= name; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= strlen(name) + 1; if (unlikely(translog_write_record(&lsn, LOGREC_REDO_DROP_TABLE, &dummy_transaction_object, NULL, diff --git a/storage/maria/ma_dynrec.c b/storage/maria/ma_dynrec.c index daf170b4cbe..4c124a31221 100644 --- a/storage/maria/ma_dynrec.c +++ b/storage/maria/ma_dynrec.c @@ -318,7 +318,11 @@ my_bool _ma_delete_dynamic_record(MARIA_HA *info, } - /* Write record to data-file */ +/** + Write record to data-file. + + @todo it's cheating: it casts "const uchar*" to uchar*. +*/ static my_bool write_dynamic_record(MARIA_HA *info, const uchar *record, ulong reclength) @@ -943,7 +947,8 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to, register const uchar *from) { uint length,new_length,flag,bit,i; - uchar *pos,*end,*startpos,*packpos; + const uchar *pos,*end; + uchar *startpos,*packpos; enum en_fieldtype type; reg3 MARIA_COLUMNDEF *column; MARIA_BLOB *blob; @@ -984,7 +989,7 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to, } else if (type == FIELD_SKIP_ZERO) { - if (memcmp((uchar*) from, maria_zero_string, length) == 0) + if (memcmp(from, maria_zero_string, length) == 0) flag|=bit; else { @@ -995,7 +1000,7 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to, else if (type == FIELD_SKIP_ENDSPACE || type == FIELD_SKIP_PRESPACE) { - pos= (uchar*) from; end= (uchar*) from + length; + pos= from; end= from + length; if (type == FIELD_SKIP_ENDSPACE) { /* Pack trailing spaces */ while (end > from && *(end-1) == ' ') @@ -1032,7 +1037,7 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to, uint tmp_length; if (pack_length == 1) { - tmp_length= (uint) *(uchar*) from; + tmp_length= (uint) *from; *to++= *from; } else @@ -1080,7 +1085,8 @@ my_bool _ma_rec_check(MARIA_HA *info,const uchar *record, uchar *rec_buff, ha_checksum checksum) { uint length,new_length,flag,bit,i; - uchar *pos,*end,*packpos,*to; + const uchar *pos,*end; + uchar *packpos,*to; enum en_fieldtype type; reg3 MARIA_COLUMNDEF *column; DBUG_ENTER("_ma_rec_check"); @@ -1107,7 +1113,7 @@ my_bool _ma_rec_check(MARIA_HA *info,const uchar *record, uchar *rec_buff, } else if (type == FIELD_SKIP_ZERO) { - if (memcmp((uchar*) record, maria_zero_string, length) == 0) + if (memcmp(record, maria_zero_string, length) == 0) { if (!(flag & bit)) goto err; @@ -1118,7 +1124,7 @@ my_bool _ma_rec_check(MARIA_HA *info,const uchar *record, uchar *rec_buff, else if (type == FIELD_SKIP_ENDSPACE || type == FIELD_SKIP_PRESPACE) { - pos= (uchar*) record; end= (uchar*) record + length; + pos= record; end= record + length; if (type == FIELD_SKIP_ENDSPACE) { /* Pack trailing spaces */ while (end > record && *(end-1) == ' ') @@ -1155,7 +1161,7 @@ my_bool _ma_rec_check(MARIA_HA *info,const uchar *record, uchar *rec_buff, uint tmp_length; if (pack_length == 1) { - tmp_length= (uint) *(uchar*) record; + tmp_length= (uint) *record; to+= 1+ tmp_length; continue; } diff --git a/storage/maria/ma_ft_parser.c b/storage/maria/ma_ft_parser.c index 11dafb39f5c..de29d9de816 100644 --- a/storage/maria/ma_ft_parser.c +++ b/storage/maria/ma_ft_parser.c @@ -85,7 +85,7 @@ my_bool maria_ft_boolean_check_syntax_string(const uchar *str) uint i, j; if (!str || - (strlen((char *) str) + 1 != sizeof(ft_boolean_syntax)) || + (strlen((const char *) str) + 1 != sizeof(ft_boolean_syntax)) || (str[0] != ' ' && str[1] != ' ')) return 1; for (i=0; i<sizeof(ft_boolean_syntax); i++) @@ -215,7 +215,7 @@ uchar maria_ft_simple_get_word(CHARSET_INFO *cs, uchar **start, { 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; } @@ -223,7 +223,7 @@ uchar maria_ft_simple_get_word(CHARSET_INFO *cs, uchar **start, mwc= length= 0; for (word->pos= doc; doc < end; length++, doc+= (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) diff --git a/storage/maria/ma_ft_update.c b/storage/maria/ma_ft_update.c index c6bed0e8e51..264cb90e4f4 100644 --- a/storage/maria/ma_ft_update.c +++ b/storage/maria/ma_ft_update.c @@ -75,7 +75,7 @@ uint _ma_ft_segiterator(register FT_SEG_ITERATOR *ftsi) if (ftsi->seg->flag & HA_VAR_LENGTH_PART) { uint pack_length= (ftsi->seg->bit_start); - ftsi->len= (pack_length == 1 ? (uint) *(uchar*) ftsi->pos : + ftsi->len= (pack_length == 1 ? (uint) * ftsi->pos : uint2korr(ftsi->pos)); ftsi->pos+= pack_length; /* Skip VARCHAR length */ DBUG_RETURN(1); @@ -107,6 +107,7 @@ uint _ma_ft_parse(TREE *parsed, MARIA_HA *info, uint keynr, const uchar *record, parser= info->s->keyinfo[keynr].parser; while (_ma_ft_segiterator(&ftsi)) { + /** @todo this casts ftsi.pos (const) to non-const */ if (ftsi.pos) if (maria_ft_parse(parsed, (uchar *)ftsi.pos, ftsi.len, parser, param, mem_root)) @@ -182,8 +183,8 @@ int _ma_ft_cmp(MARIA_HA *info, uint keynr, const uchar *rec1, const uchar *rec2) { if ((ftsi1.pos != ftsi2.pos) && (!ftsi1.pos || !ftsi2.pos || - ha_compare_text(cs, (uchar*) ftsi1.pos,ftsi1.len, - (uchar*) ftsi2.pos,ftsi2.len,0,0))) + ha_compare_text(cs, ftsi1.pos,ftsi1.len, + ftsi2.pos,ftsi2.len,0,0))) DBUG_RETURN(THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT); } DBUG_RETURN(GEE_THEY_ARE_ABSOLUTELY_IDENTICAL); diff --git a/storage/maria/ma_key.c b/storage/maria/ma_key.c index afa4c1e4679..ac384821caf 100644 --- a/storage/maria/ma_key.c +++ b/storage/maria/ma_key.c @@ -95,7 +95,7 @@ uint _ma_make_key(register MARIA_HA *info, uint keynr, uchar *key, { if (keyseg->bit_length) { - uchar bits= get_rec_bits((uchar*) record + keyseg->bit_pos, + uchar bits= get_rec_bits(record + keyseg->bit_pos, keyseg->bit_start, keyseg->bit_length); *key++= (char) bits; length--; @@ -108,7 +108,7 @@ uint _ma_make_key(register MARIA_HA *info, uint keynr, uchar *key, { if (type != HA_KEYTYPE_NUM) { - length= (uint) cs->cset->lengthsp(cs, (char*) pos, length); + length= (uint) cs->cset->lengthsp(cs, (const char*)pos, length); } else { @@ -126,7 +126,7 @@ uint _ma_make_key(register MARIA_HA *info, uint keynr, uchar *key, if (keyseg->flag & HA_VAR_LENGTH_PART) { uint pack_length= (keyseg->bit_start == 1 ? 1 : 2); - uint tmp_length= (pack_length == 1 ? (uint) *(uchar*) pos : + uint tmp_length= (pack_length == 1 ? (uint) *pos : uint2korr(pos)); pos+= pack_length; /* Skip VARCHAR length */ set_if_smaller(length,tmp_length); @@ -513,10 +513,10 @@ ulonglong ma_retrieve_auto_increment(const uchar *key, uint8 key_type) switch (key_type) { case HA_KEYTYPE_INT8: - s_value= (longlong) *(char*)key; + s_value= (longlong) *(const char*)key; break; case HA_KEYTYPE_BINARY: - value=(ulonglong) *(uchar*) key; + value=(ulonglong) *key; break; case HA_KEYTYPE_SHORT_INT: s_value= (longlong) sint2korr(key); diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c index f615d643271..23cda84add6 100644 --- a/storage/maria/ma_key_recover.c +++ b/storage/maria/ma_key_recover.c @@ -85,7 +85,7 @@ my_bool _ma_write_clr(MARIA_HA *info, LSN undo_lsn, uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE + CLR_TYPE_STORE_SIZE + HA_CHECKSUM_STORE_SIZE+ KEY_NR_STORE_SIZE + PAGE_STORE_SIZE]; uchar *log_pos; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; struct st_msg_to_write_hook_for_clr_end msg; my_bool res; DBUG_ENTER("_ma_write_clr"); @@ -119,7 +119,7 @@ my_bool _ma_write_clr(MARIA_HA *info, LSN undo_lsn, page_store(log_pos + KEY_NR_STORE_SIZE, page); log_pos+= KEY_NR_STORE_SIZE + PAGE_STORE_SIZE; } - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); res= translog_write_record(res_lsn, LOGREC_CLR_END, @@ -302,7 +302,7 @@ my_bool _ma_log_prefix(MARIA_HA *info, my_off_t page, uint translog_parts; LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 7 + 7], *log_pos; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; DBUG_ENTER("_ma_log_prefix"); DBUG_PRINT("enter", ("page: %lu changed_length: %u move_length: %d", (ulong) page, changed_length, move_length)); @@ -340,12 +340,12 @@ my_bool _ma_log_prefix(MARIA_HA *info, my_off_t page, } translog_parts= 1; - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char *)log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); if (changed_length) { - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= ((char*) buff + + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (buff + info->s->keypage_header); log_array[TRANSLOG_INTERNAL_PARTS + 1].length= changed_length; translog_parts= 2; @@ -360,7 +360,7 @@ my_bool _ma_log_prefix(MARIA_HA *info, my_off_t page, int2store(log_pos+1, page_length); int4store(log_pos+3, crc); - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= (char *)log_pos; + log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; changed_length+= 7; translog_parts++; @@ -386,7 +386,7 @@ my_bool _ma_log_suffix(MARIA_HA *info, my_off_t page, uchar *buff, uint org_length, uint new_length) { LSN lsn; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 10 + 7], *log_pos; int diff; uint translog_parts, extra_length; @@ -413,13 +413,13 @@ my_bool _ma_log_suffix(MARIA_HA *info, my_off_t page, log_pos[0]= KEY_OP_ADD_SUFFIX; int2store(log_pos+1, diff); log_pos+= 3; - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) buff + org_length; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= buff + org_length; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= (uint) diff; translog_parts= 2; extra_length= (uint) diff; } - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char *) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); @@ -431,7 +431,7 @@ my_bool _ma_log_suffix(MARIA_HA *info, my_off_t page, int2store(log_pos+1, new_length); int4store(log_pos+3, crc); - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= (char *) log_pos; + log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; extra_length+= 7; translog_parts++; @@ -469,7 +469,7 @@ my_bool _ma_log_add(MARIA_HA *info, my_off_t page, uchar *buff, LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 3 + 3 + 3 + 3 + 7]; uchar *log_pos; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; uint offset= (uint) (key_pos - buff); uint page_length= info->s->block_size - KEYPAGE_CHECKSUM_SIZE; uint translog_parts; @@ -531,10 +531,10 @@ my_bool _ma_log_add(MARIA_HA *info, my_off_t page, uchar *buff, log_pos+= 3; translog_parts= 2; - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char *) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char *) key_pos; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= key_pos; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= changed_length; #ifdef EXTRA_DEBUG_KEY_CHANGES @@ -549,7 +549,7 @@ my_bool _ma_log_add(MARIA_HA *info, my_off_t page, uchar *buff, int2store(log_pos+1, new_length); int4store(log_pos+3, crc); - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= (char *) log_pos; + log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; changed_length+= 7; translog_parts++; diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index fb5e7749844..b09bc45e7a7 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -4136,12 +4136,12 @@ static my_bool translog_write_parts_on_page(TRANSLOG_ADDRESS *horizon, do { translog_size_t len; - LEX_STRING *part; - uchar *buff; + LEX_CUSTRING *part; + const uchar *buff; DBUG_ASSERT(cur < parts->elements); part= parts->parts + cur; - buff= (uchar*) part->str; + buff= part->str; DBUG_PRINT("info", ("Part: %u Length: %lu left: %lu buff: 0x%lx", (uint) (cur + 1), (ulong) part->length, (ulong) left, (ulong) buff)); @@ -4217,11 +4217,11 @@ translog_write_variable_record_1group_header(struct st_translog_parts *parts, uint16 header_length, uchar *chunk0_header) { - LEX_STRING *part; + LEX_CUSTRING *part; DBUG_ASSERT(parts->current != 0); /* first part is left for header */ part= parts->parts + (--parts->current); parts->total_record_length+= (translog_size_t) (part->length= header_length); - part->str= (char*)chunk0_header; + part->str= chunk0_header; /* puts chunk type */ *chunk0_header= (uchar) (type | TRANSLOG_CHUNK_LSN); int2store(chunk0_header + 1, short_trid); @@ -4364,7 +4364,7 @@ translog_write_variable_record_chunk3_page(struct st_translog_parts *parts, TRANSLOG_ADDRESS *horizon, struct st_buffer_cursor *cursor) { - LEX_STRING *part; + LEX_CUSTRING *part; uchar chunk3_header[1 + 2]; DBUG_ENTER("translog_write_variable_record_chunk3_page"); @@ -4381,7 +4381,7 @@ translog_write_variable_record_chunk3_page(struct st_translog_parts *parts, DBUG_ASSERT(parts->current != 0); /* first part is left for header */ part= parts->parts + (--parts->current); parts->total_record_length+= (translog_size_t) (part->length= 1 + 2); - part->str= (char*)chunk3_header; + part->str= chunk3_header; /* Puts chunk type */ *chunk3_header= (uchar) (TRANSLOG_CHUNK_LNGTH); /* Puts chunk length */ @@ -5051,10 +5051,11 @@ static void translog_relative_LSN_encode(struct st_translog_parts *parts, LSN base_lsn, uint lsns, uchar *compressed_LSNs) { - LEX_STRING *part; + LEX_CUSTRING *part; uint lsns_len= lsns * LSN_STORE_SIZE; char buffer_src[MAX_NUMBER_OF_LSNS_PER_RECORD * LSN_STORE_SIZE]; char *buffer= buffer_src; + const char *cbuffer; DBUG_ENTER("translog_relative_LSN_encode"); @@ -5065,16 +5066,16 @@ static void translog_relative_LSN_encode(struct st_translog_parts *parts, if (part->length < lsns_len) { uint copied= part->length; - LEX_STRING *next_part; + LEX_CUSTRING *next_part; DBUG_PRINT("info", ("Using buffer: 0x%lx", (ulong) compressed_LSNs)); - memcpy(buffer, (uchar*)part->str, part->length); + memcpy(buffer, part->str, part->length); next_part= parts->parts + parts->current + 1; do { DBUG_ASSERT(next_part < parts->parts + parts->elements); if ((next_part->length + copied) < lsns_len) { - memcpy(buffer + copied, (uchar*)next_part->str, + memcpy(buffer + copied, next_part->str, next_part->length); copied+= next_part->length; next_part->length= 0; next_part->str= 0; @@ -5086,16 +5087,17 @@ static void translog_relative_LSN_encode(struct st_translog_parts *parts, else { uint len= lsns_len - copied; - memcpy(buffer + copied, (uchar*)next_part->str, len); + memcpy(buffer + copied, next_part->str, len); copied= lsns_len; next_part->str+= len; next_part->length-= len; } } while (copied < lsns_len); + cbuffer= buffer; } else { - buffer= part->str; + cbuffer= part->str; part->str+= lsns_len; part->length-= lsns_len; parts->current--; @@ -5106,15 +5108,15 @@ static void translog_relative_LSN_encode(struct st_translog_parts *parts, /* Compress */ LSN ref; int economy; - uchar *src_ptr; + const uchar *src_ptr; uchar *dst_ptr= compressed_LSNs + (MAX_NUMBER_OF_LSNS_PER_RECORD * COMPRESSED_LSN_MAX_STORE_SIZE); /* We write the result in backward direction with no special sense or tricks both directions are equal in complicity */ - for (src_ptr= ((uchar*) buffer) + lsns_len - LSN_STORE_SIZE; - src_ptr >= (uchar*) buffer; + for (src_ptr= cbuffer + lsns_len - LSN_STORE_SIZE; + src_ptr >= (const uchar*)cbuffer; src_ptr-= LSN_STORE_SIZE) { ref= lsn_korr(src_ptr); @@ -5765,7 +5767,7 @@ static my_bool translog_write_fixed_record(LSN *lsn, /* Max number of such LSNs per record is 2 */ uchar compressed_LSNs[MAX_NUMBER_OF_LSNS_PER_RECORD * COMPRESSED_LSN_MAX_STORE_SIZE]; - LEX_STRING *part; + LEX_CUSTRING *part; int rc= 1; DBUG_ENTER("translog_write_fixed_record"); DBUG_ASSERT((log_record_type_descriptor[type].rclass == @@ -5895,12 +5897,12 @@ my_bool translog_write_record(LSN *lsn, TRN *trn, MARIA_HA *tbl_info, translog_size_t rec_len, uint part_no, - LEX_STRING *parts_data, + LEX_CUSTRING *parts_data, uchar *store_share_id, void *hook_arg) { struct st_translog_parts parts; - LEX_STRING *part; + LEX_CUSTRING *part; int rc; uint short_trid= trn->short_id; DBUG_ENTER("translog_write_record"); @@ -5935,10 +5937,10 @@ my_bool translog_write_record(LSN *lsn, if (unlikely(!(trn->first_undo_lsn & TRANSACTION_LOGGED_LONG_ID))) { LSN dummy_lsn; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; uchar log_data[6]; int6store(log_data, trn->trid); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); trn->first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID; /* no recursion */ if (unlikely(translog_write_record(&dummy_lsn, LOGREC_LONG_TRANSACTION_ID, @@ -7521,7 +7523,7 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn) if (likely(share->id == 0)) { LSN lsn; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; uchar log_data[FILEID_STORE_SIZE]; /* Inspired by set_short_trid() of trnman.c */ uint i= share->kfile.file % SHARE_ID_MAX + 1; @@ -7542,7 +7544,7 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn) i= 1; /* scan the whole array */ } while (share->id == 0); DBUG_PRINT("info", ("id_to_share: 0x%lx -> %u", (ulong)share, share->id)); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); /* open_file_name is an unresolved name (symlinks are not resolved, datadir diff --git a/storage/maria/ma_loghandler.h b/storage/maria/ma_loghandler.h index 4c8cbc0488d..afd72cb770c 100644 --- a/storage/maria/ma_loghandler.h +++ b/storage/maria/ma_loghandler.h @@ -82,10 +82,10 @@ struct st_maria_handler; #define ha_checksum_store(T,A) int4store(T,A) #define fileid_korr(P) uint2korr(P) #define page_korr(P) uint5korr(P) -#define dirpos_korr(P) (*(uchar *) (P)) +#define dirpos_korr(P) (*(const uchar *) (P)) #define pagerange_korr(P) uint2korr(P) -#define clr_type_korr(P) (*(uchar *) (P)) -#define key_nr_korr(P) (*(uchar *) (P)) +#define clr_type_korr(P) (*(const uchar *) (P)) +#define key_nr_korr(P) (*(const uchar *) (P)) #define ha_checksum_korr(P) uint4korr(P) /* @@ -276,7 +276,7 @@ extern my_bool translog_write_record(LSN *lsn, enum translog_record_type type, TRN *trn, MARIA_HA *tbl_info, translog_size_t rec_len, uint part_no, - LEX_STRING *parts_data, uchar *store_share_id, + LEX_CUSTRING *parts_data, uchar *store_share_id, void *hook_arg); extern void translog_destroy(); @@ -352,8 +352,8 @@ struct st_translog_parts uint current; /* total number of elements in parts */ uint elements; - /* array of parts (LEX_STRING) */ - LEX_STRING *parts; + /* array of parts */ + LEX_CUSTRING *parts; }; typedef my_bool(*prewrite_rec_hook) (enum translog_record_type type, diff --git a/storage/maria/ma_loghandler_lsn.h b/storage/maria/ma_loghandler_lsn.h index c5ffb3cdc96..650fcf58ffa 100644 --- a/storage/maria/ma_loghandler_lsn.h +++ b/storage/maria/ma_loghandler_lsn.h @@ -71,7 +71,7 @@ typedef TRANSLOG_ADDRESS LSN; } while (0) /* Unpacks LSN from the buffer (P) */ -#define lsn_korr(P) MAKE_LSN(uint3korr(P), uint4korr((char*)(P) + 3)) +#define lsn_korr(P) MAKE_LSN(uint3korr(P), uint4korr((const char*)(P) + 3)) /* what we need to add to LSN to increase it on one file */ #define LSN_ONE_FILE ((int64)0x100000000LL) diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index 4fb680ef6d5..75e93a2229e 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -22,7 +22,7 @@ /* Fetch a key-page in memory */ uchar *_ma_fetch_keypage(register MARIA_HA *info, - MARIA_KEYDEF *keyinfo __attribute__ ((unused)), + const MARIA_KEYDEF *keyinfo __attribute__ ((unused)), my_off_t pos, enum pagecache_page_lock lock, int level, uchar *buff, int return_buffer __attribute__ ((unused)), @@ -85,7 +85,8 @@ uchar *_ma_fetch_keypage(register MARIA_HA *info, /* Write a key-page on disk */ int _ma_write_keypage(register MARIA_HA *info, - register MARIA_KEYDEF *keyinfo __attribute__((unused)), + register const MARIA_KEYDEF *keyinfo + __attribute__((unused)), my_off_t pos, enum pagecache_page_lock lock, int level, uchar *buff) { @@ -209,7 +210,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read) { LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE * 2]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; my_off_t page; /* Store address of deleted page */ @@ -220,7 +221,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read) old_link / block_size); page_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE, page); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); if (translog_write_record(&lsn, LOGREC_REDO_INDEX_FREE_PAGE, diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index ccbc385fdfe..faf1fc777d4 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -2556,7 +2556,7 @@ static uint end_of_redo_phase(my_bool prepare_for_undo_phase) and thus execute the first REDO (finding it in "a complete group"). To prevent that: */ - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS]; LSN lsn; if (translog_write_record(&lsn, LOGREC_INCOMPLETE_GROUP, trn, NULL, 0, @@ -3170,9 +3170,9 @@ void _ma_tmp_disable_logging_for_table(MARIA_HA *info, if (log_incomplete) { uchar log_data[FILEID_STORE_SIZE]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; LSN lsn; - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); translog_write_record(&lsn, LOGREC_INCOMPLETE_LOG, &dummy_transaction_object, info, diff --git a/storage/maria/ma_rename.c b/storage/maria/ma_rename.c index 50b10f526a1..24a5e15d9cf 100644 --- a/storage/maria/ma_rename.c +++ b/storage/maria/ma_rename.c @@ -67,11 +67,11 @@ int maria_rename(const char *old_name, const char *new_name) if (sync_dir) { LSN lsn; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; uint old_name_len= strlen(old_name)+1, new_name_len= strlen(new_name)+1; - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char *)old_name; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= old_name; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= old_name_len; - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char *)new_name; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= new_name; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= new_name_len; /* For this record to be of any use for Recovery, we need the upper diff --git a/storage/maria/ma_rt_index.c b/storage/maria/ma_rt_index.c index fea8b7c2d29..1608900d8f3 100644 --- a/storage/maria/ma_rt_index.c +++ b/storage/maria/ma_rt_index.c @@ -455,10 +455,11 @@ int maria_rtree_get_next(MARIA_HA *info, uint keynr, uint key_length) */ #ifdef PICK_BY_PERIMETER -static uchar *maria_rtree_pick_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, - uchar *key, - uint key_length, uchar *page_buf, - uint nod_flag) +static const uchar *maria_rtree_pick_key(const MARIA_HA *info, + const MARIA_KEYDEF *keyinfo, + const uchar *key, + uint key_length, const uchar *page_buf, + uint nod_flag) { double increase; double best_incr; @@ -491,22 +492,22 @@ static uchar *maria_rtree_pick_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, #endif /*PICK_BY_PERIMETER*/ #ifdef PICK_BY_AREA -static uchar *maria_rtree_pick_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, - uchar *key, - uint key_length, uchar *page_buf, - uint nod_flag) +static const uchar *maria_rtree_pick_key(const MARIA_HA *info, + const MARIA_KEYDEF *keyinfo, + const uchar *key, + uint key_length, const uchar *page_buf, + uint nod_flag) { MARIA_SHARE *share= info->s; double increase; double best_incr= DBL_MAX; double area; double best_area; - uchar *best_key; - uchar *k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag); - uchar *last= rt_PAGE_END(share, page_buf); + const uchar *best_key= NULL; + const uchar *k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag); + const uchar *last= rt_PAGE_END(share, page_buf); LINT_INIT(best_area); - LINT_INIT(best_key); for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, key_length, nod_flag)) { @@ -537,8 +538,9 @@ static uchar *maria_rtree_pick_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, 1 Child was split */ -static int maria_rtree_insert_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo, - uchar *key, +static int maria_rtree_insert_req(MARIA_HA *info, + const MARIA_KEYDEF *keyinfo, + const uchar *key, uint key_length, my_off_t page, my_off_t *new_page, int ins_level, int level) @@ -565,9 +567,10 @@ static int maria_rtree_insert_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo, if ((ins_level == -1 && nod_flag) || /* key: go down to leaf */ (ins_level > -1 && ins_level > level)) /* branch: go down to ins_level */ { - if ((k= maria_rtree_pick_key(info, keyinfo, key, key_length, page_buf, - nod_flag)) == NULL) + if ((k= (uchar *)maria_rtree_pick_key(info, keyinfo, key, key_length, + page_buf, nod_flag)) == NULL) goto err1; + /* k is now a pointer inside the page_buf buffer */ switch ((res= maria_rtree_insert_req(info, keyinfo, key, key_length, _ma_kpos(nod_flag, k), new_page, ins_level, level + 1))) @@ -639,8 +642,9 @@ err1: 1 Root was split */ -static int maria_rtree_insert_level(MARIA_HA *info, uint keynr, uchar *key, - uint key_length, int ins_level) +int maria_rtree_insert_level(MARIA_HA *info, uint keynr, + const uchar *key, + uint key_length, int ins_level) { my_off_t old_root; MARIA_SHARE *share= info->s; @@ -754,7 +758,8 @@ err1: 0 OK */ -int maria_rtree_insert(MARIA_HA *info, uint keynr, uchar *key, uint key_length) +int maria_rtree_insert(MARIA_HA *info, uint keynr, + uchar *key, uint key_length) { int res; DBUG_ENTER("maria_rtree_insert"); @@ -809,7 +814,7 @@ err1: */ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo, - uchar *key, + const uchar *key, uint key_length, my_off_t page, uint *page_size, stPageList *ReinsertList, int level) @@ -970,7 +975,8 @@ err1: 0 Deleted */ -int maria_rtree_delete(MARIA_HA *info, uint keynr, uchar *key, uint key_length) +int maria_rtree_delete(MARIA_HA *info, uint keynr, + uchar *key, uint key_length) { MARIA_SHARE *share= info->s; uint page_size; diff --git a/storage/maria/ma_rt_index.h b/storage/maria/ma_rt_index.h index 999b41bc805..29731bf7272 100644 --- a/storage/maria/ma_rt_index.h +++ b/storage/maria/ma_rt_index.h @@ -41,8 +41,9 @@ int maria_rtree_get_next(MARIA_HA *info, uint keynr, uint key_length); ha_rows maria_rtree_estimate(MARIA_HA *info, uint keynr, uchar *key, uint key_length, uint flag); -int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page, - uchar *key, uint key_length, +int maria_rtree_split_page(MARIA_HA *info, const MARIA_KEYDEF *keyinfo, + uchar *page, + const uchar *key, uint key_length, my_off_t *new_page_offs); #endif /*HAVE_RTREE_KEYS*/ diff --git a/storage/maria/ma_rt_key.c b/storage/maria/ma_rt_key.c index a7b43406d4f..96a1b6725fd 100644 --- a/storage/maria/ma_rt_key.c +++ b/storage/maria/ma_rt_key.c @@ -29,8 +29,10 @@ 1 Split */ -int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key, - uint key_length, uchar *page_buf, my_off_t *new_page) +int maria_rtree_add_key(MARIA_HA *info, const MARIA_KEYDEF *keyinfo, + const uchar *key, + uint key_length, uchar *page_buf, + my_off_t *new_page) { MARIA_SHARE *share= info->s; uint page_size= _ma_get_page_used(share, page_buf); @@ -97,8 +99,9 @@ int maria_rtree_delete_key(MARIA_HA *info, uchar *page_buf, uchar *key, Calculate and store key MBR */ -int maria_rtree_set_key_mbr(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key, - uint key_length, my_off_t child_page) +int maria_rtree_set_key_mbr(MARIA_HA *info, const MARIA_KEYDEF *keyinfo, + uchar *key, + uint key_length, my_off_t child_page) { DBUG_ENTER("maria_rtree_set_key_mbr"); if (!_ma_fetch_keypage(info, keyinfo, child_page, diff --git a/storage/maria/ma_rt_key.h b/storage/maria/ma_rt_key.h index 3f95d3d3e67..3bb3fff0bff 100644 --- a/storage/maria/ma_rt_key.h +++ b/storage/maria/ma_rt_key.h @@ -21,11 +21,14 @@ #ifdef HAVE_RTREE_KEYS -int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key, - uint key_length, uchar *page_buf, my_off_t *new_page); -int maria_rtree_delete_key(MARIA_HA *info, uchar *page, uchar *key, +int maria_rtree_add_key(MARIA_HA *info, const MARIA_KEYDEF *keyinfo, + const uchar *key, + uint key_length, uchar *page_buf, + my_off_t *new_page); +int maria_rtree_delete_key(MARIA_HA *info, uchar *page_buf, uchar *key, uint key_length, uint nod_flag); -int maria_rtree_set_key_mbr(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key, +int maria_rtree_set_key_mbr(MARIA_HA *info, const MARIA_KEYDEF *keyinfo, + uchar *key, uint key_length, my_off_t child_page); #endif /*HAVE_RTREE_KEYS*/ diff --git a/storage/maria/ma_rt_mbr.c b/storage/maria/ma_rt_mbr.c index 91e62c56839..c486e1c8601 100644 --- a/storage/maria/ma_rt_mbr.c +++ b/storage/maria/ma_rt_mbr.c @@ -93,8 +93,8 @@ Returns 0 on success. */ -int maria_rtree_key_cmp(HA_KEYSEG *keyseg, uchar *b, uchar *a, uint key_length, - uint nextflag) +int maria_rtree_key_cmp(HA_KEYSEG *keyseg, const uchar *b, const uchar *a, + uint key_length, uint nextflag) { for (; (int) key_length > 0; keyseg += 2 ) { @@ -153,7 +153,7 @@ int maria_rtree_key_cmp(HA_KEYSEG *keyseg, uchar *b, uchar *a, uint key_length, end: if (nextflag & MBR_DATA) { - uchar *end= a + keyseg->length; + const uchar *end= a + keyseg->length; do { if (*a++ != *b++) @@ -263,7 +263,8 @@ double maria_rtree_rect_volume(HA_KEYSEG *keyseg, uchar *a, uint key_length) Creates an MBR as an array of doubles. */ -int maria_rtree_d_mbr(HA_KEYSEG *keyseg, uchar *a, uint key_length, double *res) +int maria_rtree_d_mbr(const HA_KEYSEG *keyseg, const uchar *a, + uint key_length, double *res) { for (; (int)key_length > 0; keyseg += 2) { @@ -352,8 +353,9 @@ int maria_rtree_d_mbr(HA_KEYSEG *keyseg, uchar *a, uint key_length, double *res) Result is written to c */ -int maria_rtree_combine_rect(HA_KEYSEG *keyseg, uchar* a, uchar* b, uchar* c, - uint key_length) +int maria_rtree_combine_rect(const HA_KEYSEG *keyseg, const uchar* a, + const uchar* b, uchar* c, + uint key_length) { for ( ; (int) key_length > 0 ; keyseg += 2) { @@ -531,7 +533,8 @@ double maria_rtree_overlapping_area(HA_KEYSEG *keyseg, uchar* a, uchar* b, can return 'inf' as a result. */ -double maria_rtree_area_increase(HA_KEYSEG *keyseg, uchar *a, uchar *b, +double maria_rtree_area_increase(const HA_KEYSEG *keyseg, const uchar *a, + const uchar *b, uint key_length, double *ab_area) { double a_area= 1.0; @@ -737,15 +740,16 @@ double maria_rtree_perimeter_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b, /* Calculates key page total MBR= MBR(key1) + MBR(key2) + ... */ -int maria_rtree_page_mbr(MARIA_HA *info, HA_KEYSEG *keyseg, uchar *page_buf, +int maria_rtree_page_mbr(const MARIA_HA *info, const HA_KEYSEG *keyseg, + const uchar *page_buf, uchar *c, uint key_length) { MARIA_SHARE *share= info->s; uint inc= 0; uint k_len= key_length; uint nod_flag= _ma_test_if_nod(share, page_buf); - uchar *k; - uchar *last= rt_PAGE_END(share, page_buf); + const uchar *k; + const uchar *last= rt_PAGE_END(share, page_buf); for (; (int)key_length > 0; keyseg += 2) { diff --git a/storage/maria/ma_rt_mbr.h b/storage/maria/ma_rt_mbr.h index ad855518e62..7f436151dd3 100644 --- a/storage/maria/ma_rt_mbr.h +++ b/storage/maria/ma_rt_mbr.h @@ -19,20 +19,23 @@ #ifdef HAVE_RTREE_KEYS -int maria_rtree_key_cmp(HA_KEYSEG *keyseg, uchar *a, uchar *b, uint key_length, - uint nextflag); -int maria_rtree_combine_rect(HA_KEYSEG *keyseg,uchar *, uchar *, uchar*, +int maria_rtree_key_cmp(HA_KEYSEG *keyseg, const uchar *a, const uchar *b, + uint key_length, uint nextflag); +int maria_rtree_combine_rect(const HA_KEYSEG *keyseg, + const uchar *, const uchar *, uchar*, uint key_length); double maria_rtree_rect_volume(HA_KEYSEG *keyseg, uchar*, uint key_length); -int maria_rtree_d_mbr(HA_KEYSEG *keyseg, uchar *a, uint key_length, - double *res); +int maria_rtree_d_mbr(const HA_KEYSEG *keyseg, const uchar *a, + uint key_length, double *res); double maria_rtree_overlapping_area(HA_KEYSEG *keyseg, uchar *a, uchar *b, uint key_length); -double maria_rtree_area_increase(HA_KEYSEG *keyseg, uchar *a, uchar *b, +double maria_rtree_area_increase(const HA_KEYSEG *keyseg, const uchar *a, + const uchar *b, uint key_length, double *ab_area); double maria_rtree_perimeter_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b, uint key_length, double *ab_perim); -int maria_rtree_page_mbr(MARIA_HA *info, HA_KEYSEG *keyseg, uchar *page_buf, +int maria_rtree_page_mbr(const MARIA_HA *info, const HA_KEYSEG *keyseg, + const uchar *page_buf, uchar* c, uint key_length); #endif /*HAVE_RTREE_KEYS*/ #endif /* _rt_mbr_h */ diff --git a/storage/maria/ma_rt_split.c b/storage/maria/ma_rt_split.c index 3e2c96a4858..f00dea6b677 100644 --- a/storage/maria/ma_rt_split.c +++ b/storage/maria/ma_rt_split.c @@ -26,7 +26,7 @@ typedef struct { double square; int n_node; - uchar *key; + const uchar *key; double *coords; } SplitStruct; @@ -247,8 +247,8 @@ static int split_maria_rtree_node(SplitStruct *node, int n_entries, return 0; } -int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, - uchar *page, uchar *key, +int maria_rtree_split_page(MARIA_HA *info, const MARIA_KEYDEF *keyinfo, + uchar *page, const uchar *key, uint key_length, my_off_t *new_page_offs) { MARIA_SHARE *share= info->s; diff --git a/storage/maria/ma_search.c b/storage/maria/ma_search.c index c50027616a9..e39fb832fbd 100644 --- a/storage/maria/ma_search.c +++ b/storage/maria/ma_search.c @@ -209,7 +209,7 @@ int _ma_bin_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, { mid= (start+end)/2; if ((flag=ha_key_cmp(keyinfo->seg,(uchar*) page+(uint) mid*totlength, - (uchar*) key, key_len, comp_flag, not_used)) + key, key_len, comp_flag, not_used)) >= 0) end=mid; else @@ -217,7 +217,7 @@ int _ma_bin_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, } if (mid != start) flag=ha_key_cmp(keyinfo->seg, (uchar*) page+(uint) start*totlength, - (uchar*) key, key_len, comp_flag, not_used); + key, key_len, comp_flag, not_used); if (flag < 0) start++; /* point at next, bigger key */ *ret_pos= (page + (uint) start * totlength); @@ -284,7 +284,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, length, (long) page, (long) end)); DBUG_RETURN(MARIA_FOUND_WRONG_KEY); } - if ((flag= ha_key_cmp(keyinfo->seg, (uchar*) t_buff,(uchar*) key, + if ((flag= ha_key_cmp(keyinfo->seg, t_buff, key, key_len,comp_flag, not_used)) >= 0) break; #ifdef EXTRA_DEBUG @@ -584,7 +584,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, /* Get pos to a key_block */ -my_off_t _ma_kpos(uint nod_flag, uchar *after_key) +my_off_t _ma_kpos(uint nod_flag, const uchar *after_key) { after_key-=nod_flag; switch (nod_flag) { @@ -1634,7 +1634,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag, if (sort_order) /* SerG */ { while (key < end && - sort_order[* (uchar*) key] == sort_order[* (uchar*) prev_key]) + sort_order[*key] == sort_order[*prev_key]) { key++; prev_key++; } @@ -1716,7 +1716,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag, if (sort_order) /* SerG */ { while (key < end && - sort_order[*(uchar*) key] == sort_order[*(uchar*) org_key]) + sort_order[*key] == sort_order[*org_key]) { key++; org_key++; } @@ -1801,7 +1801,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag, if (sort_order) /* SerG */ { while (key < key_end && - sort_order[*(uchar*) key] == sort_order[*(uchar*) next_key]) + sort_order[*key] == sort_order[*next_key]) { key++; next_key++; } diff --git a/storage/maria/ma_sp_key.c b/storage/maria/ma_sp_key.c index 5f83b432228..3c0833366fd 100644 --- a/storage/maria/ma_sp_key.c +++ b/storage/maria/ma_sp_key.c @@ -37,14 +37,14 @@ uint _ma_sp_make_key(register MARIA_HA *info, uint keynr, uchar *key, HA_KEYSEG *keyseg; MARIA_KEYDEF *keyinfo = &info->s->keyinfo[keynr]; uint len = 0; - uchar *pos; + const uchar *pos; uint dlen; uchar *dptr; double mbr[SPDIMS * 2]; uint i; keyseg = &keyinfo->seg[-1]; - pos = (uchar*)record + keyseg->start; + pos = record + keyseg->start; dlen = _ma_calc_blob_length(keyseg->bit_start, pos); memcpy_fixed(&dptr, pos + keyseg->bit_start, sizeof(char*)); diff --git a/storage/maria/ma_unique.c b/storage/maria/ma_unique.c index 3ab717887c7..51c21f0a085 100644 --- a/storage/maria/ma_unique.c +++ b/storage/maria/ma_unique.c @@ -106,7 +106,7 @@ ha_checksum _ma_unique_hash(MARIA_UNIQUEDEF *def, const uchar *record) if (keyseg->flag & HA_VAR_LENGTH_PART) { uint pack_length= keyseg->bit_start; - uint tmp_length= (pack_length == 1 ? (uint) *(uchar*) pos : + uint tmp_length= (pack_length == 1 ? (uint) *pos : uint2korr(pos)); pos+= pack_length; /* Skip VARCHAR length */ set_if_smaller(length,tmp_length); @@ -130,7 +130,7 @@ ha_checksum _ma_unique_hash(MARIA_UNIQUEDEF *def, const uchar *record) else while (pos != end) crc=((crc << 8) + - (((uchar) *(uchar*) pos++))) + + (((uchar) *pos++))) + (crc >> (8*sizeof(ha_checksum)-8)); } return crc; @@ -181,8 +181,8 @@ my_bool _ma_unique_comp(MARIA_UNIQUEDEF *def, const uchar *a, const uchar *b, uint pack_length= keyseg->bit_start; if (pack_length == 1) { - a_length= (uint) *(uchar*) pos_a++; - b_length= (uint) *(uchar*) pos_b++; + a_length= (uint) *pos_a++; + b_length= (uint) *pos_b++; } else { @@ -215,8 +215,8 @@ my_bool _ma_unique_comp(MARIA_UNIQUEDEF *def, const uchar *a, const uchar *b, if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 || type == HA_KEYTYPE_VARTEXT2) { - if (ha_compare_text(keyseg->charset, (uchar *) pos_a, a_length, - (uchar *) pos_b, b_length, 0, 1)) + if (ha_compare_text(keyseg->charset, pos_a, a_length, + pos_b, b_length, 0, 1)) return 1; } else diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index a2498eed05c..fe0182e9a19 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -399,7 +399,7 @@ static int _ma_ck_write_btree_with_log(MARIA_HA *info, MARIA_KEYDEF *keyinfo, { uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE + KEY_NR_STORE_SIZE]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; struct st_msg_to_write_hook_for_undo_key msg; /* Save if we need to write a clr record */ @@ -408,9 +408,9 @@ static int _ma_ck_write_btree_with_log(MARIA_HA *info, MARIA_KEYDEF *keyinfo, key_nr_store(log_data + LSN_STORE_SIZE + FILEID_STORE_SIZE, keyinfo->key_nr); key_length+= share->rec_reflength; - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) key_buff; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= key_buff; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= key_length; msg.root= root; @@ -779,13 +779,13 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, #if HA_FT_MAXLEN >= 127 blen= mi_uint2korr(b); b+=2; #else - blen= *(uchar*) b++; + blen= *b++; #endif get_key_length(alen,a); DBUG_ASSERT(info->ft1_to_ft2==0); if (alen == blen && - ha_compare_text(keyinfo->seg->charset, (uchar*) a, alen, - (uchar*) 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 *) @@ -804,7 +804,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, */ b+=blen+ft2len+2; for (a=anc_buff+a_length ; b < a ; b+=ft2len+2) - insert_dynamic(info->ft1_to_ft2, (uchar*) b); + insert_dynamic(info->ft1_to_ft2, b); /* fixing the page's length - it contains only one key now */ _ma_store_page_used(share, anc_buff, share->keypage_header + blen + @@ -1653,7 +1653,7 @@ static my_bool _ma_log_new(MARIA_HA *info, my_off_t page, uchar *buff, LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE * 2 + KEY_NR_STORE_SIZE +1]; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; MARIA_SHARE *share= info->s; DBUG_ENTER("_ma_log_new"); DBUG_PRINT("enter", ("page: %lu", (ulong) page)); @@ -1676,11 +1676,11 @@ static my_bool _ma_log_new(MARIA_HA *info, my_off_t page, uchar *buff, log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE*2 + KEY_NR_STORE_SIZE]= (uchar) root_page; - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); page_length-= LSN_STORE_SIZE; - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char *) buff + LSN_STORE_SIZE; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= buff + LSN_STORE_SIZE; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= page_length; if (translog_write_record(&lsn, LOGREC_REDO_INDEX_NEW_PAGE, @@ -1703,7 +1703,7 @@ static my_bool _ma_log_change(MARIA_HA *info, my_off_t page, uchar *buff, { LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 6], *log_pos; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; uint offset= (uint) (key_pos - buff); DBUG_ENTER("_ma_log_change"); DBUG_PRINT("enter", ("page: %lu", (ulong) page)); @@ -1719,9 +1719,9 @@ static my_bool _ma_log_change(MARIA_HA *info, my_off_t page, uchar *buff, log_pos[3]= KEY_OP_CHANGE; int2store(log_pos+4, length); - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char *) buff + offset; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= buff + offset; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= length; if (translog_write_record(&lsn, LOGREC_REDO_INDEX, @@ -1760,7 +1760,7 @@ static my_bool _ma_log_split(MARIA_HA *info, my_off_t page, uchar *buff, LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 3+3+3+3+3+2]; uchar *log_pos; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; uint offset= (uint) (key_pos - buff); uint translog_parts, extra_length; DBUG_ENTER("_ma_log_split"); @@ -1829,7 +1829,7 @@ static my_bool _ma_log_split(MARIA_HA *info, my_off_t page, uchar *buff, key_pos+= data_length; translog_parts= 2; - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) key_pos; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= key_pos; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= extra_length; } @@ -1845,13 +1845,13 @@ static my_bool _ma_log_split(MARIA_HA *info, my_off_t page, uchar *buff, log_pos+= 2; data_length= changed_length; } - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= (char*) data; + log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= data; log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= data_length; translog_parts++; extra_length+= data_length; } - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char *) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); DBUG_RETURN(translog_write_record(&lsn, LOGREC_REDO_INDEX, @@ -1892,7 +1892,7 @@ static my_bool _ma_log_del_prefix(MARIA_HA *info, my_off_t page, uchar *buff, { LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 12], *log_pos; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; uint offset= (uint) (key_pos - buff); uint diff_length= org_length + move_length - new_length; uint translog_parts, extra_length; @@ -1949,12 +1949,12 @@ static my_bool _ma_log_del_prefix(MARIA_HA *info, my_off_t page, uchar *buff, log_pos[0]= KEY_OP_CHANGE; int2store(log_pos+1, key_length); log_pos+= 3; - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) key_pos; + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= key_pos; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= key_length; translog_parts= 2; extra_length= key_length; } - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char *) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); DBUG_RETURN(translog_write_record(&lsn, LOGREC_REDO_INDEX, @@ -1984,7 +1984,7 @@ static my_bool _ma_log_key_middle(MARIA_HA *info, my_off_t page, uchar *buff, LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 3+5+3+3+3]; uchar *log_pos; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; uint key_offset; uint translog_parts, extra_length; DBUG_ENTER("_ma_log_key_middle"); @@ -2026,10 +2026,10 @@ static my_bool _ma_log_key_middle(MARIA_HA *info, my_off_t page, uchar *buff, int2store(log_pos+3, data_changed_first); log_pos+= 5; - log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char *) log_data; + log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= ((char*) buff + + log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (buff + info->s->keypage_header); log_array[TRANSLOG_INTERNAL_PARTS + 1].length= data_changed_first; translog_parts= 2; @@ -2054,11 +2054,11 @@ static my_bool _ma_log_key_middle(MARIA_HA *info, my_off_t page, uchar *buff, int2store(log_pos+1, key_length); log_pos+= 3; - log_array[TRANSLOG_INTERNAL_PARTS + 2].str= (char*) start_log_pos; + log_array[TRANSLOG_INTERNAL_PARTS + 2].str= start_log_pos; log_array[TRANSLOG_INTERNAL_PARTS + 2].length= (uint) (log_pos - start_log_pos); - log_array[TRANSLOG_INTERNAL_PARTS + 3].str= (char*) key_pos; + log_array[TRANSLOG_INTERNAL_PARTS + 3].str= key_pos; log_array[TRANSLOG_INTERNAL_PARTS + 3].length= key_length; translog_parts+=2; extra_length+= (uint) (log_array[TRANSLOG_INTERNAL_PARTS + 2].length + diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 8f3a94d2784..5b5503fb02c 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -654,15 +654,15 @@ struct st_maria_handler } #define get_key_full_length(length,key) \ - { if (*(uchar*) (key) != 255) \ - length= ((uint) *(uchar*) ((key)++))+1; \ + { if (*(const uchar*) (key) != 255) \ + length= ((uint) *(const uchar*) ((key)++))+1; \ else \ { length=mi_uint2korr((key)+1)+3; (key)+=3; } \ } #define get_key_full_length_rdonly(length,key) \ -{ if (*(uchar*) (key) != 255) \ - length= ((uint) *(uchar*) ((key)))+1; \ +{ if (*(const uchar*) (key) != 255) \ + length= ((uint) *(const uchar*) ((key)))+1; \ else \ { length=mi_uint2korr((key)+1)+3; } \ } @@ -858,7 +858,7 @@ extern int _ma_prefix_search(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page, const uchar *key, uint key_len, uint comp_flag, uchar ** ret_pos, uchar *buff, my_bool *was_last_key); -extern my_off_t _ma_kpos(uint nod_flag, uchar *after_key); +extern my_off_t _ma_kpos(uint nod_flag, const uchar *after_key); extern void _ma_kpointer(MARIA_HA *info, uchar *buff, my_off_t pos); extern MARIA_RECORD_POS _ma_dpos(MARIA_HA *info, uint nod_flag, const uchar *after_key); @@ -893,11 +893,13 @@ extern my_off_t _ma_transparent_recpos(MARIA_HA *info, my_off_t pos); extern my_off_t _ma_transaction_keypos_to_recpos(MARIA_HA *info, my_off_t pos); extern my_off_t _ma_transaction_recpos_to_keypos(MARIA_HA *info, my_off_t pos); -extern uchar *_ma_fetch_keypage(MARIA_HA *info, MARIA_KEYDEF *keyinfo, +extern uchar *_ma_fetch_keypage(MARIA_HA *info, + const MARIA_KEYDEF *keyinfo, my_off_t page, enum pagecache_page_lock lock, int level, uchar *buff, int return_buffer, MARIA_PINNED_PAGE **page_link); -extern int _ma_write_keypage(MARIA_HA *info, MARIA_KEYDEF *keyinfo, +extern int _ma_write_keypage(MARIA_HA *info, + const MARIA_KEYDEF *keyinfo, my_off_t page, enum pagecache_page_lock lock, int level, uchar *buff); extern int _ma_dispose(MARIA_HA *info, my_off_t pos, my_bool page_not_read); diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c index 306b89b3d5a..3c54ee717d9 100644 --- a/storage/maria/unittest/ma_test_loghandler-t.c +++ b/storage/maria/unittest/ma_test_loghandler-t.c @@ -160,7 +160,7 @@ int main(int argc __attribute__((unused)), char *argv[]) PAGECACHE pagecache; LSN lsn, lsn_base, first_lsn; TRANSLOG_HEADER_BUFFER rec; - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 3]; struct st_translog_scanner_data scanner; int rc; diff --git a/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c b/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c index 96c368746ba..33a22c49adf 100644 --- a/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c +++ b/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c @@ -39,7 +39,7 @@ int main(int argc __attribute__((unused)), char *argv[]) uchar long_tr_id[6]; PAGECACHE pagecache; LSN lsn, first_lsn, theor_lsn; - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; MY_INIT(argv[0]); diff --git a/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c b/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c index 553ecedd694..84e8c266ed7 100644 --- a/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c +++ b/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c @@ -39,7 +39,7 @@ int main(int argc __attribute__((unused)), char *argv[]) uchar long_tr_id[6]; PAGECACHE pagecache; LSN lsn, max_lsn, last_lsn= LSN_IMPOSSIBLE; - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; MY_INIT(argv[0]); diff --git a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c index eb8691973aa..a3823a0a8cd 100644 --- a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c @@ -149,7 +149,7 @@ int main(int argc __attribute__((unused)), char *argv[]) PAGECACHE pagecache; LSN lsn, lsn_base, first_lsn; TRANSLOG_HEADER_BUFFER rec; - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 2]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 2]; struct st_translog_scanner_data scanner; int rc; diff --git a/storage/maria/unittest/ma_test_loghandler_multithread-t.c b/storage/maria/unittest/ma_test_loghandler_multithread-t.c index 9815621dd09..f4c8efe535d 100644 --- a/storage/maria/unittest/ma_test_loghandler_multithread-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multithread-t.c @@ -140,7 +140,7 @@ void writer(int num) for (i= 0; i < ITERATIONS; i++) { uint len= get_len(); - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; lens[num][i]= len; int2store(long_tr_id, num); @@ -306,7 +306,7 @@ int main(int argc __attribute__((unused)), srand(122334817L); { - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; uchar long_tr_id[6]= { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 diff --git a/storage/maria/unittest/ma_test_loghandler_noflush-t.c b/storage/maria/unittest/ma_test_loghandler_noflush-t.c index a4267fed327..0114fc54d68 100644 --- a/storage/maria/unittest/ma_test_loghandler_noflush-t.c +++ b/storage/maria/unittest/ma_test_loghandler_noflush-t.c @@ -41,7 +41,7 @@ int main(int argc __attribute__((unused)), char *argv[]) PAGECACHE pagecache; LSN first_lsn; TRANSLOG_HEADER_BUFFER rec; - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; translog_size_t len; MY_INIT(argv[0]); diff --git a/storage/maria/unittest/ma_test_loghandler_nologs-t.c b/storage/maria/unittest/ma_test_loghandler_nologs-t.c index e31da979b33..d4b62fee595 100644 --- a/storage/maria/unittest/ma_test_loghandler_nologs-t.c +++ b/storage/maria/unittest/ma_test_loghandler_nologs-t.c @@ -40,7 +40,7 @@ int main(int argc __attribute__((unused)), char *argv[]) uchar long_tr_id[6]; PAGECACHE pagecache; LSN lsn; - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; uchar *long_buffer= malloc(LONG_BUFFER_SIZE); MY_INIT(argv[0]); diff --git a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c index 33e6ef5f493..0a11e340345 100644 --- a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c +++ b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c @@ -67,7 +67,7 @@ int main(int argc __attribute__((unused)), char *argv[]) PAGECACHE pagecache; LSN lsn; my_off_t file_size; - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; MY_INIT(argv[0]); diff --git a/storage/maria/unittest/ma_test_loghandler_purge-t.c b/storage/maria/unittest/ma_test_loghandler_purge-t.c index 924c9ee4fcb..31efb79639e 100644 --- a/storage/maria/unittest/ma_test_loghandler_purge-t.c +++ b/storage/maria/unittest/ma_test_loghandler_purge-t.c @@ -40,7 +40,7 @@ int main(int argc __attribute__((unused)), char *argv[]) uchar long_tr_id[6]; PAGECACHE pagecache; LSN lsn; - LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1]; + LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; uchar *long_buffer= malloc(LONG_BUFFER_SIZE); MY_INIT(argv[0]); |