Commit d68922e6 authored by unknown's avatar unknown

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
parent ebaf694a
......@@ -266,4 +266,12 @@ typedef struct st_mysql_lex_string LEX_STRING;
#define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1))
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
/* A variant with const and unsigned */
struct st_mysql_const_unsigned_lex_string
{
const uchar *str;
size_t length;
};
typedef struct st_mysql_const_unsigned_lex_string LEX_CUSTRING;
#endif
......@@ -1146,7 +1146,7 @@ typedef char bool; /* Ordinary boolean values 0 1 */
/* Optimized store functions for Intel x86 */
#if defined(__i386__) && !defined(_WIN64)
#define sint2korr(A) (*((int16 *) (A)))
#define sint2korr(A) (*((const int16 *) (A)))
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
(((uint32) 255L << 24) | \
(((uint32) (uchar) (A)[2]) << 16) |\
......@@ -1155,8 +1155,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */
(((uint32) (uchar) (A)[2]) << 16) |\
(((uint32) (uchar) (A)[1]) << 8) | \
((uint32) (uchar) (A)[0])))
#define sint4korr(A) (*((long *) (A)))
#define uint2korr(A) (*((uint16 *) (A)))
#define sint4korr(A) (*((const long *) (A)))
#define uint2korr(A) (*((const uint16 *) (A)))
#ifdef HAVE_purify
#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
......@@ -1168,9 +1168,9 @@ typedef char bool; /* Ordinary boolean values 0 1 */
Please, note, uint3korr reads 4 bytes (not 3) !
It means, that you have to provide enough allocated space !
*/
#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
#define uint3korr(A) (long) (*((const unsigned int *) (A)) & 0xFFFFFF)
#endif
#define uint4korr(A) (*((uint32 *) (A)))
#define uint4korr(A) (*((const uint32 *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16) +\
......@@ -1182,8 +1182,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */
(((uint32) ((uchar) (A)[3])) << 24)) + \
(((ulonglong) ((uchar) (A)[4])) << 32) + \
(((ulonglong) ((uchar) (A)[5])) << 40))
#define uint8korr(A) (*((ulonglong *) (A)))
#define sint8korr(A) (*((longlong *) (A)))
#define uint8korr(A) (*((const ulonglong *) (A)))
#define sint8korr(A) (*((const longlong *) (A)))
#define int2store(T,A) *((uint16*) (T))= (uint16) (A)
#define int3store(T,A) do { *(T)= (uchar) ((A));\
*(T+1)=(uchar) (((uint) (A) >> 8));\
......@@ -1208,17 +1208,17 @@ typedef union {
} doubleget_union;
#define doubleget(V,M) \
do { doubleget_union _tmp; \
_tmp.m[0] = *((long*)(M)); \
_tmp.m[1] = *(((long*) (M))+1); \
_tmp.m[0] = *((const long*)(M)); \
_tmp.m[1] = *(((const long*) (M))+1); \
(V) = _tmp.v; } while(0)
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
*(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
#define doublestore(T,V) do { *((long *) T) = ((const doubleget_union *)&V)->m[0]; \
*(((long *) T)+1) = ((const doubleget_union *)&V)->m[1]; \
} while (0)
#define float4get(V,M) do { *((float *) &(V)) = *((float*) (M)); } while(0)
#define float4get(V,M) do { *((float *) &(V)) = *((const float*) (M)); } while(0)
#define float8get(V,M) doubleget((V),(M))
#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
#define floatstore(T,V) memcpy((uchar*)(T), (uchar*)(&V),sizeof(float))
#define floatget(V,M) memcpy((uchar*) &V,(uchar*) (M),sizeof(float))
#define float4store(V,M) memcpy((uchar*) V,(const uchar*) (&M),sizeof(float))
#define floatstore(T,V) memcpy((uchar*)(T), (const uchar*)(&V),sizeof(float))
#define floatget(V,M) memcpy((uchar*) &V,(const uchar*) (M),sizeof(float))
#define float8store(V,M) doublestore((V),(M))
#endif /* __i386__ */
......
......@@ -58,22 +58,22 @@ typedef struct st_HA_KEYSEG /* Key-portion */
} HA_KEYSEG;
#define get_key_length(length,key) \
{ if (*(uchar*) (key) != 255) \
length= (uint) *(uchar*) ((key)++); \
{ if (*(const uchar*) (key) != 255) \
length= (uint) *(const uchar*) ((key)++); \
else \
{ length= mi_uint2korr((key)+1); (key)+=3; } \
}
#define get_key_length_rdonly(length,key) \
{ if (*(uchar*) (key) != 255) \
length= ((uint) *(uchar*) ((key))); \
{ if (*(const uchar*) (key) != 255) \
length= ((uint) *(const uchar*) ((key))); \
else \
{ length= mi_uint2korr((key)+1); } \
}
#define get_key_pack_length(length,length_pack,key) \
{ if (*(uchar*) (key) != 255) \
{ length= (uint) *(uchar*) ((key)++); length_pack= 1; }\
{ if (*(const uchar*) (key) != 255) \
{ length= (uint) *(const uchar*) ((key)++); length_pack= 1; }\
else \
{ length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \
}
......@@ -109,7 +109,7 @@ extern int ha_key_cmp(register HA_KEYSEG *keyseg, register const uchar *a,
register const uchar *b, uint key_length, uint nextflag,
uint *diff_pos);
extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a);
extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, const uchar *a);
extern void my_handler_error_register(void);
extern void my_handler_error_unregister(void);
/*
......
......@@ -802,7 +802,7 @@ extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array,uint element_size,
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
uint init_alloc,uint alloc_increment
CALLER_INFO_PROTO);
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,uchar * element);
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const uchar * element);
extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array);
extern uchar *pop_dynamic(DYNAMIC_ARRAY*);
extern my_bool set_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index);
......
This diff is collapsed.
......@@ -92,7 +92,7 @@ my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
FALSE Ok
*/
my_bool insert_dynamic(DYNAMIC_ARRAY *array, uchar* element)
my_bool insert_dynamic(DYNAMIC_ARRAY *array, const uchar* element)
{
uchar* buffer;
if (array->elements == array->max_element)
......
......@@ -498,7 +498,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register const uchar *a,
NULLs.
*/
HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, const uchar *a)
{
for (; (enum ha_base_keytype) keyseg->type != HA_KEYTYPE_END; keyseg++)
{
......
......@@ -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
......
This diff is collapsed.
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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 */
......
......@@ -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) */
......
......@@ -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;
......
......@@ -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:
......
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......
......@@ -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++;
......
......@@ -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
......
......@@ -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,
......
......@@ -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)
......
......@@ -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,
......
......@@ -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,
......
......@@ -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
......
......@@ -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 @@ static int maria_rtree_insert_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
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 @@ static int maria_rtree_insert_level(MARIA_HA *info, uint keynr, uchar *key,
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 @@ static int maria_rtree_fill_reinsert_list(stPageList *ReinsertList, my_off_t pag
*/
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 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
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;
......
......@@ -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*/
......
......@@ -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,
......
......@@ -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*/
......
......@@ -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)
{
......
......@@ -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 */
......@@ -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;
......
......@@ -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++;
}
......
......@@ -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*));
......
......@@ -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
......
......@@ -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 +
......
......@@ -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);
......
......@@ -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;
......
......@@ -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]);
......
......@@ -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]);
......
......@@ -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;
......
......@@ -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
......
......@@ -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]);
......
......@@ -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]);
......
......@@ -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]);
......
......@@ -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]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment