Browse Source

After merge fixes. Applied changes made in myisam manually to maria.

storage/maria/ma_test1.c:
  After merge fixes. Applied changes made in myisam manually to maria.
  
  Fixed memory leak.
storage/maria/ma_test2.c:
  After merge fixes. Applied changes made in myisam manually to maria.
  
  Fixed memory leak.
pull/374/head
unknown 18 years ago
parent
commit
4eb383e06c
  1. 6
      include/maria.h
  2. 8
      mysql-test/r/maria.result
  3. 65
      storage/maria/CMakeLists.txt
  4. 91
      storage/maria/ha_maria.cc
  5. 13
      storage/maria/ha_maria.h
  6. 13
      storage/maria/ma_check.c
  7. 5
      storage/maria/ma_create.c
  8. 12
      storage/maria/ma_delete.c
  9. 36
      storage/maria/ma_dynrec.c
  10. 45
      storage/maria/ma_extra.c
  11. 1
      storage/maria/ma_init.c
  12. 5
      storage/maria/ma_key.c
  13. 3
      storage/maria/ma_keycache.c
  14. 4
      storage/maria/ma_locking.c
  15. 21
      storage/maria/ma_open.c
  16. 8
      storage/maria/ma_packrec.c
  17. 5
      storage/maria/ma_page.c
  18. 3
      storage/maria/ma_pagecache.c
  19. 49
      storage/maria/ma_rkey.c
  20. 2
      storage/maria/ma_search.c
  21. 65
      storage/maria/ma_sort.c
  22. 59
      storage/maria/ma_sp_key.c
  23. 34
      storage/maria/ma_sp_test.c
  24. 34
      storage/maria/ma_statrec.c
  25. 74
      storage/maria/ma_test1.c
  26. 46
      storage/maria/ma_test2.c
  27. 20
      storage/maria/ma_test3.c
  28. 6
      storage/maria/ma_update.c
  29. 8
      storage/maria/ma_write.c
  30. 4
      storage/maria/maria_chk.c
  31. 28
      storage/maria/maria_def.h
  32. 6
      storage/maria/maria_pack.c

6
include/maria.h

@ -375,10 +375,10 @@ typedef struct st_maria_sort_param
int (*key_read)(struct st_maria_sort_param *, uchar *); int (*key_read)(struct st_maria_sort_param *, uchar *);
int (*key_write)(struct st_maria_sort_param *, const uchar *); int (*key_write)(struct st_maria_sort_param *, const uchar *);
void (*lock_in_memory)(HA_CHECK *); void (*lock_in_memory)(HA_CHECK *);
NEAR int (*write_keys)(struct st_maria_sort_param *, register uchar **,
int (*write_keys)(struct st_maria_sort_param *, register uchar **,
uint , struct st_buffpek *, IO_CACHE *); uint , struct st_buffpek *, IO_CACHE *);
NEAR uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
NEAR int (*write_key)(struct st_maria_sort_param *, IO_CACHE *,char *,
uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
int (*write_key)(struct st_maria_sort_param *, IO_CACHE *,uchar *,
uint, uint); uint, uint);
} MARIA_SORT_PARAM; } MARIA_SORT_PARAM;

8
mysql-test/r/maria.result

@ -860,7 +860,7 @@ _id
DELETE FROM t1 WHERE _id < 8; DELETE FROM t1 WHERE _id < 8;
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MARIA 10 Page 2 # # # # 0 # # # # # #
t1 MARIA 10 Paged 2 # # # # 0 # # # # # #
CHECK TABLE t1 EXTENDED; CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
@ -872,7 +872,7 @@ Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MARIA 10 Page 2 # # # # 0 # # # # # #
t1 MARIA 10 Paged 2 # # # # 0 # # # # # #
SELECT _id FROM t1; SELECT _id FROM t1;
_id _id
8 8
@ -919,7 +919,7 @@ _id
DELETE FROM t1 WHERE _id < 8; DELETE FROM t1 WHERE _id < 8;
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MARIA 10 Page 2 # # # # 0 # # # # # #
t1 MARIA 10 Paged 2 # # # # 0 # # # # # #
CHECK TABLE t1 EXTENDED; CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
@ -931,7 +931,7 @@ Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MARIA 10 Page 2 # # # # 0 # # # # # #
t1 MARIA 10 Paged 2 # # # # 0 # # # # # #
SELECT _id FROM t1; SELECT _id FROM t1;
_id _id
8 8

65
storage/maria/CMakeLists.txt

@ -1 +1,64 @@
# empty for the moment; will fill it when we build under Windows
# Copyright (C) 2007 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/regex
${CMAKE_SOURCE_DIR}/extra/yassl/include)
SET(MARIA_SOURCES ft_maria.c ha_maria.cc lockman.c ma_bitmap.c ma_blockrec.c
ma_cache.c ma_changed.c ma_check.c ma_checkpoint.c ma_checksum.c
ma_close.c ma_commit.c ma_control_file.c ma_create.c ma_dbug.c
ma_delete.c ma_delete_all.c ma_delete_table.c ma_dynrec.c
ma_extra.c ma_ft_boolean_search.c ma_ft_eval.c ma_ft_nlq_search.c
ma_ft_parser.c ma_ft_stem.c ma_ft_test1.c ma_ft_update.c ma_info.c
ma_init.c ma_key.c ma_keycache.c ma_least_recently_dirtied.c
ma_locking.c ma_loghandler.c ma_open.c ma_packrec.c ma_page.c
ma_pagecache.c ma_pagecaches.c ma_panic.c ma_preload.c ma_range.c
ma_recovery.c ma_rename.c ma_rfirst.c ma_rkey.c ma_rlast.c
ma_rnext.c ma_rnext_same.c ma_rprev.c ma_rrnd.c ma_rsame.c
ma_rsamepos.c ma_rt_index.c ma_rt_key.c ma_rt_mbr.c ma_rt_split.c
ma_rt_test.c ma_scan.c ma_search.c ma_sort.c ma_sp_key.c
ma_sp_test.c ma_static.c ma_statrec.c
ma_unique.c ma_update.c ma_write.c tablockman.c trnman.c
ha_maria.h maria_def.h)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(maria ${MARIA_SOURCES})
ADD_EXECUTABLE(maria_ftdump maria_ftdump.c)
TARGET_LINK_LIBRARIES(maria_ftdump maria myisam mysys debug dbug strings zlib wsock32)
ADD_EXECUTABLE(maria_chk maria_chk.c)
TARGET_LINK_LIBRARIES(maria_chk maria myisam mysys debug dbug strings zlib wsock32)
ADD_EXECUTABLE(maria_read_log maria_read_log.c)
TARGET_LINK_LIBRARIES(maria_read_log maria myisam mysys debug dbug strings zlib wsock32)
ADD_EXECUTABLE(maria_pack maria_pack.c)
TARGET_LINK_LIBRARIES(maria_pack maria myisam mysys debug dbug strings zlib wsock32)
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("maria_ftdump" "asInvoker")
MYSQL_EMBED_MANIFEST("maria_chk" "asInvoker")
MYSQL_EMBED_MANIFEST("maria_read_log" "asInvoker")
MYSQL_EMBED_MANIFEST("maria_pack" "asInvoker")
ENDIF(EMBED_MANIFESTS)
ENDIF(NOT SOURCE_SUBLIBS)

91
storage/maria/ha_maria.cc

@ -289,7 +289,8 @@ int table2maria(TABLE *table_arg, MARIA_KEYDEF **keydef_out,
DBUG_PRINT("loop", ("found: 0x%lx recpos: %d minpos: %d length: %d", DBUG_PRINT("loop", ("found: 0x%lx recpos: %d minpos: %d length: %d",
(long) found, recpos, minpos, length)); (long) found, recpos, minpos, length));
if (recpos != minpos) if (recpos != minpos)
{ // Reserved space (Null bits?)
{
/* reserve space for null bits */
bzero((char*) recinfo_pos, sizeof(*recinfo_pos)); bzero((char*) recinfo_pos, sizeof(*recinfo_pos));
recinfo_pos->type= FIELD_NORMAL; recinfo_pos->type= FIELD_NORMAL;
recinfo_pos++->length= (uint16) (minpos - recpos); recinfo_pos++->length= (uint16) (minpos - recpos);
@ -1593,7 +1594,7 @@ void ha_maria::start_bulk_insert(ha_rows rows)
DBUG_ENTER("ha_maria::start_bulk_insert"); DBUG_ENTER("ha_maria::start_bulk_insert");
THD *thd= current_thd; THD *thd= current_thd;
ulong size= min(thd->variables.read_buff_size, ulong size= min(thd->variables.read_buff_size,
table->s->avg_row_length * rows);
(ulong) (table->s->avg_row_length * rows));
DBUG_PRINT("info", ("start_bulk_insert: rows %lu size %lu", DBUG_PRINT("info", ("start_bulk_insert: rows %lu size %lu",
(ulong) rows, size)); (ulong) rows, size));
@ -1714,7 +1715,7 @@ int ha_maria::delete_row(const uchar * buf)
} }
int ha_maria::index_read(uchar * buf, const uchar * key,
int ha_maria::index_read_map(uchar * buf, const uchar * key,
key_part_map keypart_map, key_part_map keypart_map,
enum ha_rkey_function find_flag) enum ha_rkey_function find_flag)
{ {
@ -1726,7 +1727,7 @@ int ha_maria::index_read(uchar * buf, const uchar * key,
} }
int ha_maria::index_read_idx(uchar * buf, uint index, const uchar * key,
int ha_maria::index_read_idx_map(uchar * buf, uint index, const uchar * key,
key_part_map keypart_map, key_part_map keypart_map,
enum ha_rkey_function find_flag) enum ha_rkey_function find_flag)
{ {
@ -1737,10 +1738,10 @@ int ha_maria::index_read_idx(uchar * buf, uint index, const uchar * key,
} }
int ha_maria::index_read_last(uchar * buf, const uchar * key,
int ha_maria::index_read_last_map(uchar * buf, const uchar * key,
key_part_map keypart_map) key_part_map keypart_map)
{ {
DBUG_ENTER("ha_maria::index_read_last");
DBUG_ENTER("ha_maria::index_read_last_map");
DBUG_ASSERT(inited == INDEX); DBUG_ASSERT(inited == INDEX);
ha_statistic_increment(&SSV::ha_read_key_count); ha_statistic_increment(&SSV::ha_read_key_count);
int error= maria_rkey(file, buf, active_index, key, keypart_map, int error= maria_rkey(file, buf, active_index, key, keypart_map,
@ -2157,6 +2158,8 @@ int ha_maria::create(const char *name, register TABLE *table_arg,
if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE) if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE)
create_flags|= HA_CREATE_TMP_TABLE; create_flags|= HA_CREATE_TMP_TABLE;
if (ha_create_info->options & HA_CREATE_KEEP_FILES)
create_flags|= HA_CREATE_KEEP_FILES;
if (options & HA_OPTION_PACK_RECORD) if (options & HA_OPTION_PACK_RECORD)
create_flags|= HA_PACK_RECORD; create_flags|= HA_PACK_RECORD;
if (options & HA_OPTION_CHECKSUM) if (options & HA_OPTION_CHECKSUM)
@ -2380,6 +2383,82 @@ static int ha_maria_init(void *p)
} }
#ifdef HAVE_QUERY_CACHE
/**
@brief Register a named table with a call back function to the query cache.
@param thd The thread handle
@param table_key A pointer to the table name in the table cache
@param key_length The length of the table name
@param[out] engine_callback The pointer to the storage engine call back
function, currently 0
@param[out] engine_data Engine data will be set to 0.
@note Despite the name of this function, it is used to check each statement
before it is cached and not to register a table or callback function.
@see handler::register_query_cache_table
@return The error code. The engine_data and engine_callback will be set to 0.
@retval TRUE Success
@retval FALSE An error occured
*/
my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name,
uint table_name_len,
qc_engine_callback
*engine_callback,
ulonglong *engine_data)
{
/*
No call back function is needed to determine if a cached statement
is valid or not.
*/
*engine_callback= 0;
/*
No engine data is needed.
*/
*engine_data= 0;
/*
If a concurrent INSERT has happened just before the currently processed
SELECT statement, the total size of the table is unknown.
To determine if the table size is known, the current thread's snap shot of
the table size with the actual table size are compared.
If the table size is unknown the SELECT statement can't be cached.
*/
ulonglong actual_data_file_length;
ulonglong current_data_file_length;
/*
POSIX visibility rules specify that "2. Whatever memory values a
thread can see when it unlocks a mutex <...> can also be seen by any
thread that later locks the same mutex". In this particular case,
concurrent insert thread had modified the data_file_length in
MYISAM_SHARE before it has unlocked (or even locked)
structure_guard_mutex. So, here we're guaranteed to see at least that
value after we've locked the same mutex. We can see a later value
(modified by some other thread) though, but it's ok, as we only want
to know if the variable was changed, the actual new value doesn't matter
*/
actual_data_file_length= file->s->state.state.data_file_length;
current_data_file_length= file->save_state.data_file_length;
if (current_data_file_length != actual_data_file_length)
{
/* Don't cache current statement. */
return FALSE;
}
/* It is ok to try to cache current statement. */
return TRUE;
}
#endif
struct st_mysql_storage_engine maria_storage_engine= struct st_mysql_storage_engine maria_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION }; { MYSQL_HANDLERTON_INTERFACE_VERSION };

13
storage/maria/ha_maria.h

@ -71,12 +71,12 @@ public:
int write_row(uchar * buf); int write_row(uchar * buf);
int update_row(const uchar * old_data, uchar * new_data); int update_row(const uchar * old_data, uchar * new_data);
int delete_row(const uchar * buf); int delete_row(const uchar * buf);
int index_read(uchar * buf, const uchar * key, key_part_map keypart_map,
int index_read_map(uchar * buf, const uchar * key, key_part_map keypart_map,
enum ha_rkey_function find_flag); enum ha_rkey_function find_flag);
int index_read_idx(uchar * buf, uint idx, const uchar * key,
int index_read_idx_map(uchar * buf, uint idx, const uchar * key,
key_part_map keypart_map, key_part_map keypart_map,
enum ha_rkey_function find_flag); enum ha_rkey_function find_flag);
int index_read_last(uchar * buf, const uchar * key,
int index_read_last_map(uchar * buf, const uchar * key,
key_part_map keypart_map); key_part_map keypart_map);
int index_next(uchar * buf); int index_next(uchar * buf);
int index_prev(uchar * buf); int index_prev(uchar * buf);
@ -143,4 +143,11 @@ public:
int dump(THD * thd, int fd); int dump(THD * thd, int fd);
int net_read_dump(NET * net); int net_read_dump(NET * net);
#endif #endif
#ifdef HAVE_QUERY_CACHE
my_bool register_query_cache_table(THD *thd, char *table_key,
uint key_length,
qc_engine_callback
*engine_callback,
ulonglong *engine_data);
#endif
}; };

13
storage/maria/ma_check.c

@ -187,7 +187,7 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag)
printf(" %9s",llstr(next_link,buff)); printf(" %9s",llstr(next_link,buff));
if (next_link >= info->state->data_file_length) if (next_link >= info->state->data_file_length)
goto wrong; goto wrong;
if (my_pread(info->dfile.file, (char*) buff, delete_link_length,
if (my_pread(info->dfile.file, (uchar*) buff, delete_link_length,
next_link,MYF(MY_NABP))) next_link,MYF(MY_NABP)))
{ {
if (test_flag & T_VERBOSE) puts(""); if (test_flag & T_VERBOSE) puts("");
@ -264,7 +264,8 @@ static int check_k_link(HA_CHECK *param, register MARIA_HA *info,
{ {
uint block_size= info->s->block_size; uint block_size= info->s->block_size;
ha_rows records; ha_rows records;
char llbuff[21], llbuff2[21], *buff;
char llbuff[21], llbuff2[21];
uchar *buff;
DBUG_ENTER("check_k_link"); DBUG_ENTER("check_k_link");
records= (ha_rows) (info->state->key_file_length / block_size); records= (ha_rows) (info->state->key_file_length / block_size);
@ -2347,7 +2348,7 @@ static int writekeys(MARIA_SORT_PARAM *sort_param)
{ {
if (info->s->keyinfo[i].flag & HA_FULLTEXT ) if (info->s->keyinfo[i].flag & HA_FULLTEXT )
{ {
if (_ma_ft_add(info,i,(char*) key,buff,filepos))
if (_ma_ft_add(info,i, key,buff,filepos))
goto err; goto err;
} }
#ifdef HAVE_SPATIAL #ifdef HAVE_SPATIAL
@ -2378,7 +2379,7 @@ static int writekeys(MARIA_SORT_PARAM *sort_param)
{ {
if (info->s->keyinfo[i].flag & HA_FULLTEXT) if (info->s->keyinfo[i].flag & HA_FULLTEXT)
{ {
if (_ma_ft_del(info,i,(char*) key,buff,filepos))
if (_ma_ft_del(info,i,key,buff,filepos))
break; break;
} }
else else
@ -3421,7 +3422,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
sort_param[i].filepos=new_header_length; sort_param[i].filepos=new_header_length;
sort_param[i].max_pos=sort_param[i].pos=share->pack.header_length; sort_param[i].max_pos=sort_param[i].pos=share->pack.header_length;
sort_param[i].record= (((char *)(sort_param+share->base.keys))+
sort_param[i].record= (((uchar *)(sort_param+share->base.keys))+
(share->base.pack_reclength * i)); (share->base.pack_reclength * i));
if (_ma_alloc_buffer(&sort_param[i].rec_buff, &sort_param[i].rec_buff_size, if (_ma_alloc_buffer(&sort_param[i].rec_buff, &sort_param[i].rec_buff_size,
share->base.default_rec_buff_size)) share->base.default_rec_buff_size))
@ -5051,7 +5052,7 @@ int maria_write_data_suffix(MARIA_SORT_INFO *sort_info, my_bool fix_datafile)
if (info->s->data_file_type == COMPRESSED_RECORD && fix_datafile) if (info->s->data_file_type == COMPRESSED_RECORD && fix_datafile)
{ {
char buff[MEMMAP_EXTRA_MARGIN];
uchar buff[MEMMAP_EXTRA_MARGIN];
bzero(buff,sizeof(buff)); bzero(buff,sizeof(buff));
if (my_b_write(&info->rec_cache,buff,sizeof(buff))) if (my_b_write(&info->rec_cache,buff,sizeof(buff)))
{ {

5
storage/maria/ma_create.c

@ -764,7 +764,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
Replace the current file. Replace the current file.
Don't sync dir now if the data file has the same path. Don't sync dir now if the data file has the same path.
*/ */
create_flag= MY_DELETE_OLD | (!ci->data_file_name ? 0 : sync_dir);
create_flag= (flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
create_flag|= (!ci->data_file_name ? 0 : sync_dir);
} }
/* /*
@ -1042,7 +1043,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
fn_format(filename,name,"", MARIA_NAME_DEXT, fn_format(filename,name,"", MARIA_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT); MY_UNPACK_FILENAME | MY_APPEND_EXT);
linkname_ptr= NullS; linkname_ptr= NullS;
create_flag=MY_DELETE_OLD;
create_flag= (flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
} }
if ((dfile= if ((dfile=
my_create_with_symlink(linkname_ptr, filename, 0, create_mode, my_create_with_symlink(linkname_ptr, filename, 0, create_mode,

12
storage/maria/ma_delete.c

@ -75,13 +75,15 @@ int maria_delete(MARIA_HA *info,const uchar *record)
info->s->keyinfo[i].version++; info->s->keyinfo[i].version++;
if (info->s->keyinfo[i].flag & HA_FULLTEXT ) if (info->s->keyinfo[i].flag & HA_FULLTEXT )
{ {
if (_ma_ft_del(info,i,(char*) old_key,record,info->cur_row.lastpos))
if (_ma_ft_del(info, i, old_key, record, info->cur_row.lastpos))
goto err; goto err;
} }
else else
{ {
if (info->s->keyinfo[i].ck_delete(info,i,old_key, if (info->s->keyinfo[i].ck_delete(info,i,old_key,
_ma_make_key(info,i,old_key,record,info->cur_row.lastpos)))
_ma_make_key(info, i, old_key,
record,
info->cur_row.lastpos)))
goto err; goto err;
} }
/* The above changed info->lastkey2. Inform maria_rnext_same(). */ /* The above changed info->lastkey2. Inform maria_rnext_same(). */
@ -255,7 +257,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (info->ft1_to_ft2) if (info->ft1_to_ft2)
{ {
/* we're in ft1->ft2 conversion mode. Saving key data */ /* we're in ft1->ft2 conversion mode. Saving key data */
insert_dynamic(info->ft1_to_ft2, (char*) (lastkey+off));
insert_dynamic(info->ft1_to_ft2, (lastkey+off));
} }
else else
{ {
@ -806,7 +808,7 @@ static uint remove_key(MARIA_KEYDEF *keyinfo, uint nod_flag,
if (next_length > prev_length) if (next_length > prev_length)
{ {
/* We have to copy data from the current key to the next key */ /* We have to copy data from the current key to the next key */
bmove_upp((char*) keypos,(char*) (lastkey+next_length),
bmove_upp(keypos, (lastkey+next_length),
(next_length-prev_length)); (next_length-prev_length));
keypos-=(next_length-prev_length)+prev_pack_length; keypos-=(next_length-prev_length)+prev_pack_length;
store_key_length(keypos,prev_length); store_key_length(keypos,prev_length);
@ -853,7 +855,7 @@ static uint remove_key(MARIA_KEYDEF *keyinfo, uint nod_flag,
if (next_length >= prev_length) if (next_length >= prev_length)
{ /* Key after is based on deleted key */ { /* Key after is based on deleted key */
uint pack_length,tmp; uint pack_length,tmp;
bmove_upp((char*) keypos,(char*) (lastkey+next_length),
bmove_upp(keypos, (lastkey+next_length),
tmp=(next_length-prev_length)); tmp=(next_length-prev_length));
rest_length+=tmp; rest_length+=tmp;
pack_length= prev_length ? get_pack_length(rest_length): 0; pack_length= prev_length ? get_pack_length(rest_length): 0;

36
storage/maria/ma_dynrec.c

@ -88,7 +88,7 @@ my_bool _ma_dynmap_file(MARIA_HA *info, my_off_t size)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
#if defined(HAVE_MADVISE) #if defined(HAVE_MADVISE)
madvise(info->s->file_map, size, MADV_RANDOM);
madvise((char*) info->s->file_map, size, MADV_RANDOM);
#endif #endif
info->s->mmaped_length= size; info->s->mmaped_length= size;
DBUG_RETURN(0); DBUG_RETURN(0);
@ -109,7 +109,7 @@ void _ma_remap_file(MARIA_HA *info, my_off_t size)
{ {
if (info->s->file_map) if (info->s->file_map)
{ {
VOID(my_munmap(info->s->file_map,
VOID(my_munmap((char*) info->s->file_map,
(size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN)); (size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN));
_ma_dynmap_file(info, size); _ma_dynmap_file(info, size);
} }
@ -132,8 +132,8 @@ void _ma_remap_file(MARIA_HA *info, my_off_t size)
0 ok 0 ok
*/ */
uint _ma_mmap_pread(MARIA_HA *info, uchar *Buffer,
uint Count, my_off_t offset, myf MyFlags)
size_t _ma_mmap_pread(MARIA_HA *info, uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags)
{ {
DBUG_PRINT("info", ("maria_read with mmap %d\n", info->dfile.file)); DBUG_PRINT("info", ("maria_read with mmap %d\n", info->dfile.file));
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
@ -164,8 +164,8 @@ uint _ma_mmap_pread(MARIA_HA *info, uchar *Buffer,
/* wrapper for my_pread in case if mmap isn't used */ /* wrapper for my_pread in case if mmap isn't used */
uint _ma_nommap_pread(MARIA_HA *info, uchar *Buffer,
uint Count, my_off_t offset, myf MyFlags)
size_t _ma_nommap_pread(MARIA_HA *info, uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags)
{ {
return my_pread(info->dfile.file, Buffer, Count, offset, MyFlags); return my_pread(info->dfile.file, Buffer, Count, offset, MyFlags);
} }
@ -187,8 +187,8 @@ uint _ma_nommap_pread(MARIA_HA *info, uchar *Buffer,
!=0 error. In this case return error from pwrite !=0 error. In this case return error from pwrite
*/ */
uint _ma_mmap_pwrite(MARIA_HA *info, uchar *Buffer,
uint Count, my_off_t offset, myf MyFlags)
size_t _ma_mmap_pwrite(MARIA_HA *info, const uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags)
{ {
DBUG_PRINT("info", ("maria_write with mmap %d\n", info->dfile.file)); DBUG_PRINT("info", ("maria_write with mmap %d\n", info->dfile.file));
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
@ -221,8 +221,8 @@ uint _ma_mmap_pwrite(MARIA_HA *info, uchar *Buffer,
/* wrapper for my_pwrite in case if mmap isn't used */ /* wrapper for my_pwrite in case if mmap isn't used */
uint _ma_nommap_pwrite(MARIA_HA *info, uchar *Buffer,
uint Count, my_off_t offset, myf MyFlags)
size_t _ma_nommap_pwrite(MARIA_HA *info, const uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags)
{ {
return my_pwrite(info->dfile.file, Buffer, Count, offset, MyFlags); return my_pwrite(info->dfile.file, Buffer, Count, offset, MyFlags);
} }
@ -428,7 +428,7 @@ static bool unlink_deleted_block(MARIA_HA *info, MARIA_BLOCK_INFO *block_info)
& BLOCK_DELETED)) & BLOCK_DELETED))
DBUG_RETURN(1); /* Something is wrong */ DBUG_RETURN(1); /* Something is wrong */
mi_sizestore(tmp.header+4,block_info->next_filepos); mi_sizestore(tmp.header+4,block_info->next_filepos);
if (info->s->file_write(info,(char*) tmp.header+4,8,
if (info->s->file_write(info, tmp.header+4,8,
block_info->prev_filepos+4, MYF(MY_NABP))) block_info->prev_filepos+4, MYF(MY_NABP)))
DBUG_RETURN(1); DBUG_RETURN(1);
/* Unlink block from next block */ /* Unlink block from next block */
@ -439,7 +439,7 @@ static bool unlink_deleted_block(MARIA_HA *info, MARIA_BLOCK_INFO *block_info)
& BLOCK_DELETED)) & BLOCK_DELETED))
DBUG_RETURN(1); /* Something is wrong */ DBUG_RETURN(1); /* Something is wrong */
mi_sizestore(tmp.header+12,block_info->prev_filepos); mi_sizestore(tmp.header+12,block_info->prev_filepos);
if (info->s->file_write(info,(char*) tmp.header+12,8,
if (info->s->file_write(info, tmp.header+12,8,
block_info->next_filepos+12, block_info->next_filepos+12,
MYF(MY_NABP))) MYF(MY_NABP)))
DBUG_RETURN(1); DBUG_RETURN(1);
@ -489,7 +489,7 @@ static my_bool update_backward_delete_link(MARIA_HA *info,
if (_ma_get_block_info(&block_info, info->dfile.file, delete_block) if (_ma_get_block_info(&block_info, info->dfile.file, delete_block)
& BLOCK_DELETED) & BLOCK_DELETED)
{ {
char buff[8];
uchar buff[8];
mi_sizestore(buff,filepos); mi_sizestore(buff,filepos);
if (info->s->file_write(info,buff, 8, delete_block+12, MYF(MY_NABP))) if (info->s->file_write(info,buff, 8, delete_block+12, MYF(MY_NABP)))
DBUG_RETURN(1); /* Error on write */ DBUG_RETURN(1); /* Error on write */
@ -1610,7 +1610,7 @@ static my_bool _ma_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
uint length) uint length)
{ {
uint next_length; uint next_length;
char temp_buff[IO_SIZE*2];
uchar temp_buff[IO_SIZE*2];
DBUG_ENTER("_ma_cmp_buffer"); DBUG_ENTER("_ma_cmp_buffer");
next_length= IO_SIZE*2 - (uint) (filepos & (IO_SIZE-1)); next_length= IO_SIZE*2 - (uint) (filepos & (IO_SIZE-1));
@ -1618,7 +1618,7 @@ static my_bool _ma_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
while (length > IO_SIZE*2) while (length > IO_SIZE*2)
{ {
if (my_pread(file,temp_buff,next_length,filepos, MYF(MY_NABP)) || if (my_pread(file,temp_buff,next_length,filepos, MYF(MY_NABP)) ||
memcmp((uchar*) buff,temp_buff,next_length))
memcmp(buff, temp_buff, next_length))
goto err; goto err;
filepos+=next_length; filepos+=next_length;
buff+=next_length; buff+=next_length;
@ -1627,7 +1627,7 @@ static my_bool _ma_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
} }
if (my_pread(file,temp_buff,length,filepos,MYF(MY_NABP))) if (my_pread(file,temp_buff,length,filepos,MYF(MY_NABP)))
goto err; goto err;
DBUG_RETURN(memcmp((uchar*) buff,temp_buff,length) != 0);
DBUG_RETURN(memcmp(buff, temp_buff, length) != 0);
err: err:
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -1851,11 +1851,11 @@ uint _ma_get_block_info(MARIA_BLOCK_INFO *info, File file, my_off_t filepos)
my_pread() may leave the file pointer untouched. my_pread() may leave the file pointer untouched.
*/ */
VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0))); VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
if (my_read(file,(char*) header,sizeof(info->header),MYF(0)) !=
if (my_read(file, header, sizeof(info->header),MYF(0)) !=
sizeof(info->header)) sizeof(info->header))
goto err; goto err;
} }
DBUG_DUMP("header",(uchar*) header,MARIA_BLOCK_INFO_HEADER_LENGTH);
DBUG_DUMP("header",header,MARIA_BLOCK_INFO_HEADER_LENGTH);
if (info->second_read) if (info->second_read)
{ {
if (info->header[0] <= 6 || info->header[0] == 13) if (info->header[0] <= 6 || info->header[0] == 13)

45
storage/maria/ma_extra.c

@ -85,7 +85,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (_ma_memmap_file(info)) if (_ma_memmap_file(info))
{ {
/* We don't nead MADV_SEQUENTIAL if small file */ /* We don't nead MADV_SEQUENTIAL if small file */
madvise(share->file_map,share->state.state.data_file_length,
madvise((char*) share->file_map, share->state.state.data_file_length,
share->state.state.data_file_length <= RECORD_CACHE_SIZE*16 ? share->state.state.data_file_length <= RECORD_CACHE_SIZE*16 ?
MADV_RANDOM : MADV_SEQUENTIAL); MADV_RANDOM : MADV_SEQUENTIAL);
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
@ -167,7 +167,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
} }
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) #if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
if (info->opt_flag & MEMMAP_USED) if (info->opt_flag & MEMMAP_USED)
madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM);
madvise((char*) share->file_map, share->state.state.data_file_length,
MADV_RANDOM);
#endif #endif
break; break;
case HA_EXTRA_FLUSH_CACHE: case HA_EXTRA_FLUSH_CACHE:
@ -313,8 +314,6 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
blocks to disk if this is not for a DROP TABLE. Otherwise they would be blocks to disk if this is not for a DROP TABLE. Otherwise they would be
invisible to future openers; and they could even go to disk late and invisible to future openers; and they could even go to disk late and
cancel the work of future openers. cancel the work of future openers.
On Windows, which cannot delete an open file (cannot drop an open table)
we have to close the table's files.
*/ */
if (info->lock_type != F_UNLCK && !info->was_locked) if (info->lock_type != F_UNLCK && !info->was_locked)
{ {
@ -343,11 +342,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
{ {
if (do_flush) if (do_flush)
{ {
/*
Save the state so that others can find it from disk.
We have to sync now, as on Windows we are going to close the file
(so cannot sync later).
*/
/* Save the state so that others can find it from disk. */
if (_ma_state_info_write(share, 1 | 2) || if (_ma_state_info_write(share, 1 | 2) ||
my_sync(share->kfile.file, MYF(0))) my_sync(share->kfile.file, MYF(0)))
error= my_errno; error= my_errno;
@ -361,42 +356,13 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
/* be sure that state is not tried for write as file may be closed */ /* be sure that state is not tried for write as file may be closed */
share->changed= 0; share->changed= 0;
} }
#ifdef __WIN__
if (my_close(share->kfile, MYF(0)))
error=my_errno;
share->kfile.file= -1;
#endif
} }
if (share->data_file_type == BLOCK_RECORD && if (share->data_file_type == BLOCK_RECORD &&
share->bitmap.file.file >= 0) share->bitmap.file.file >= 0)
{ {
if (do_flush && my_sync(share->bitmap.file.file, MYF(0))) if (do_flush && my_sync(share->bitmap.file.file, MYF(0)))
error= my_errno; error= my_errno;
#ifdef __WIN__
if (my_close(share->bitmap.file.file, MYF(0)))
error= my_errno;
share->bitmap.file.file= -1;
#endif
}
#ifdef __WIN__
{
LIST *list_element ;
for (list_element=maria_open_list ;
list_element ;
list_element=list_element->next)
{
MARIA_HA *tmpinfo=(MARIA_HA*) list_element->data;
if (tmpinfo->s == info->s)
{
if (share->data_file_type != BLOCK_RECORD &&
tmpinfo->dfile.file >= 0 &&
my_close(tmpinfo->dfile.file, MYF(0)))
error = my_errno;
tmpinfo->dfile.file= -1;
} }
}
}
#endif
/* For protection against Checkpoint, we set under intern_lock: */ /* For protection against Checkpoint, we set under intern_lock: */
share->last_version= 0L; /* Impossible version */ share->last_version= 0L; /* Impossible version */
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
@ -544,7 +510,8 @@ int maria_reset(MARIA_HA *info)
} }
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) #if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
if (info->opt_flag & MEMMAP_USED) if (info->opt_flag & MEMMAP_USED)
madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM);
madvise((char*) share->file_map, share->state.state.data_file_length,
MADV_RANDOM);
#endif #endif
info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS);
info->quick_mode=0; info->quick_mode=0;

1
storage/maria/ma_init.c

@ -61,6 +61,7 @@ void maria_end(void)
trnman_destroy(); trnman_destroy();
translog_destroy(); translog_destroy();
end_pagecache(maria_log_pagecache, TRUE); end_pagecache(maria_log_pagecache, TRUE);
end_pagecache(maria_pagecache, TRUE);
ma_control_file_end(); ma_control_file_end();
pthread_mutex_destroy(&THR_LOCK_maria); pthread_mutex_destroy(&THR_LOCK_maria);
} }

5
storage/maria/ma_key.c

@ -108,7 +108,7 @@ uint _ma_make_key(register MARIA_HA *info, uint keynr, uchar *key,
{ {
if (type != HA_KEYTYPE_NUM) if (type != HA_KEYTYPE_NUM)
{ {
length= cs->cset->lengthsp(cs, pos, length);
length= cs->cset->lengthsp(cs, (char*) pos, length);
} }
else else
{ {
@ -383,7 +383,8 @@ static int _ma_put_key_in_record(register MARIA_HA *info, uint keynr,
{ {
memcpy(pos,key,(size_t) length); memcpy(pos,key,(size_t) length);
keyseg->charset->cset->fill(keyseg->charset, keyseg->charset->cset->fill(keyseg->charset,
pos + length, keyseg->length - length,
(char*) pos + length,
keyseg->length - length,
' '); ' ');
} }
else else

3
storage/maria/ma_keycache.c

@ -105,7 +105,8 @@ int maria_assign_to_pagecache(MARIA_HA *info,
share->pagecache= pagecache; share->pagecache= pagecache;
/* store the key cache in the global hash structure for future opens */ /* store the key cache in the global hash structure for future opens */
if (multi_pagecache_set(share->unique_file_name, share->unique_name_length,
if (multi_pagecache_set((uchar*) share->unique_file_name,
share->unique_name_length,
share->pagecache)) share->pagecache))
error= my_errno; error= my_errno;
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);

4
storage/maria/ma_locking.c

@ -505,7 +505,7 @@ int _ma_test_if_changed(register MARIA_HA *info)
int _ma_mark_file_changed(MARIA_HA *info) int _ma_mark_file_changed(MARIA_HA *info)
{ {
char buff[3];
uchar buff[3];
register MARIA_SHARE *share=info->s; register MARIA_SHARE *share=info->s;
DBUG_ENTER("_ma_mark_file_changed"); DBUG_ENTER("_ma_mark_file_changed");
@ -543,7 +543,7 @@ int _ma_mark_file_changed(MARIA_HA *info)
int _ma_decrement_open_count(MARIA_HA *info) int _ma_decrement_open_count(MARIA_HA *info)
{ {
char buff[2];
uchar buff[2];
register MARIA_SHARE *share=info->s; register MARIA_SHARE *share=info->s;
int lock_error=0,write_error=0; int lock_error=0,write_error=0;
if (share->global_changed) if (share->global_changed)

21
storage/maria/ma_open.c

@ -249,7 +249,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
key_parts,unique_key_parts,fulltext_keys,uniques; key_parts,unique_key_parts,fulltext_keys,uniques;
char name_buff[FN_REFLEN], org_name[FN_REFLEN], index_name[FN_REFLEN], char name_buff[FN_REFLEN], org_name[FN_REFLEN], index_name[FN_REFLEN],
data_name[FN_REFLEN]; data_name[FN_REFLEN];
char *disk_cache, *disk_pos, *end_pos;
uchar *disk_cache, *disk_pos, *end_pos;
MARIA_HA info,*m_info,*old_info; MARIA_HA info,*m_info,*old_info;
MARIA_SHARE share_buff,*share; MARIA_SHARE share_buff,*share;
ulong rec_per_key_part[HA_MAX_POSSIBLE_KEY*HA_MAX_KEY_SEG]; ulong rec_per_key_part[HA_MAX_POSSIBLE_KEY*HA_MAX_KEY_SEG];
@ -275,7 +275,8 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
bzero((uchar*) &share_buff,sizeof(share_buff)); bzero((uchar*) &share_buff,sizeof(share_buff));
share_buff.state.rec_per_key_part=rec_per_key_part; share_buff.state.rec_per_key_part=rec_per_key_part;
share_buff.state.key_root=key_root; share_buff.state.key_root=key_root;
share_buff.pagecache= multi_pagecache_search(name_buff, strlen(name_buff),
share_buff.pagecache= multi_pagecache_search((uchar*) name_buff,
strlen(name_buff),
maria_pagecache); maria_pagecache);
DBUG_EXECUTE_IF("maria_pretend_crashed_table_on_open", DBUG_EXECUTE_IF("maria_pretend_crashed_table_on_open",
@ -293,7 +294,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
} }
share->mode=open_mode; share->mode=open_mode;
errpos= 1; errpos= 1;
if (my_read(kfile,(char*) share->state.header.file_version,head_length,
if (my_read(kfile,share->state.header.file_version, head_length,
MYF(MY_NABP))) MYF(MY_NABP)))
{ {
my_errno= HA_ERR_NOT_A_TABLE; my_errno= HA_ERR_NOT_A_TABLE;
@ -337,7 +338,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
info_length=mi_uint2korr(share->state.header.header_length); info_length=mi_uint2korr(share->state.header.header_length);
base_pos= mi_uint2korr(share->state.header.base_pos); base_pos= mi_uint2korr(share->state.header.base_pos);
if (!(disk_cache=(char*) my_alloca(info_length+128)))
if (!(disk_cache= (uchar*) my_alloca(info_length+128)))
{ {
my_errno=ENOMEM; my_errno=ENOMEM;
goto err; goto err;
@ -688,7 +689,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
(keys ? MARIA_INDEX_BLOCK_MARGIN * (keys ? MARIA_INDEX_BLOCK_MARGIN *
share->block_size * keys : 0)); share->block_size * keys : 0));
share->block_size= share->base.block_size; share->block_size= share->base.block_size;
my_afree((uchar*) disk_cache);
my_afree(disk_cache);
_ma_setup_functions(share); _ma_setup_functions(share);
if ((*share->once_init)(share, info.dfile.file)) if ((*share->once_init)(share, info.dfile.file))
goto err; goto err;
@ -1175,7 +1176,7 @@ static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state)
uint _ma_state_info_read_dsk(File file, MARIA_STATE_INFO *state) uint _ma_state_info_read_dsk(File file, MARIA_STATE_INFO *state)
{ {
char buff[MARIA_STATE_INFO_SIZE + MARIA_STATE_EXTRA_SIZE];
uchar buff[MARIA_STATE_INFO_SIZE + MARIA_STATE_EXTRA_SIZE];
/* trick to detect transactional tables */ /* trick to detect transactional tables */
DBUG_ASSERT(state->create_rename_lsn == LSN_IMPOSSIBLE); DBUG_ASSERT(state->create_rename_lsn == LSN_IMPOSSIBLE);
@ -1297,7 +1298,7 @@ uint _ma_keydef_write(File file, MARIA_KEYDEF *keydef)
return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
} }
char *_ma_keydef_read(char *ptr, MARIA_KEYDEF *keydef)
uchar *_ma_keydef_read(uchar *ptr, MARIA_KEYDEF *keydef)
{ {
keydef->keysegs = (uint) *ptr++; keydef->keysegs = (uint) *ptr++;
keydef->key_alg = *ptr++; /* Rtree or Btree */ keydef->key_alg = *ptr++; /* Rtree or Btree */
@ -1341,7 +1342,7 @@ int _ma_keyseg_write(File file, const HA_KEYSEG *keyseg)
} }
char *_ma_keyseg_read(char *ptr, HA_KEYSEG *keyseg)
uchar *_ma_keyseg_read(uchar *ptr, HA_KEYSEG *keyseg)
{ {
keyseg->type = *ptr++; keyseg->type = *ptr++;
keyseg->language = *ptr++; keyseg->language = *ptr++;
@ -1380,7 +1381,7 @@ uint _ma_uniquedef_write(File file, MARIA_UNIQUEDEF *def)
return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
} }
char *_ma_uniquedef_read(char *ptr, MARIA_UNIQUEDEF *def)
uchar *_ma_uniquedef_read(uchar *ptr, MARIA_UNIQUEDEF *def)
{ {
def->keysegs = mi_uint2korr(ptr); def->keysegs = mi_uint2korr(ptr);
def->key = ptr[2]; def->key = ptr[2];
@ -1408,7 +1409,7 @@ uint _ma_columndef_write(File file, MARIA_COLUMNDEF *columndef)
return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
} }
char *_ma_columndef_read(char *ptr, MARIA_COLUMNDEF *columndef)
uchar *_ma_columndef_read(uchar *ptr, MARIA_COLUMNDEF *columndef)
{ {
columndef->offset= mi_uint6korr(ptr); ptr+= 6; columndef->offset= mi_uint6korr(ptr); ptr+= 6;
columndef->type= mi_sint2korr(ptr); ptr+= 2; columndef->type= mi_sint2korr(ptr); ptr+= 2;

8
storage/maria/ma_packrec.c

@ -170,7 +170,7 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file,
uint i,trees,huff_tree_bits,rec_reflength,length; uint i,trees,huff_tree_bits,rec_reflength,length;
uint16 *decode_table,*tmp_buff; uint16 *decode_table,*tmp_buff;
ulong elements,intervall_length; ulong elements,intervall_length;
char *disk_cache;
uchar *disk_cache;
uchar *intervall_buff; uchar *intervall_buff;
uchar header[HEAD_LENGTH]; uchar header[HEAD_LENGTH];
MARIA_BIT_BUFF bit_buff; MARIA_BIT_BUFF bit_buff;
@ -257,7 +257,7 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file,
goto err2; goto err2;
huff_tree_bits=max_bit(trees ? trees-1 : 0); huff_tree_bits=max_bit(trees ? trees-1 : 0);
init_bit_buffer(&bit_buff, (uchar*) disk_cache,
init_bit_buffer(&bit_buff, disk_cache,
(uint) (share->pack.header_length-sizeof(header))); (uint) (share->pack.header_length-sizeof(header)));
/* Read new info for each field */ /* Read new info for each field */
for (i=0 ; i < share->base.fields ; i++) for (i=0 ; i < share->base.fields ; i++)
@ -1416,7 +1416,7 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff,
position is ok position is ok
*/ */
VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0))); VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
if (my_read(file,(char*) header,ref_length,MYF(MY_NABP)))
if (my_read(file, header,ref_length,MYF(MY_NABP)))
return BLOCK_FATAL_ERROR; return BLOCK_FATAL_ERROR;
DBUG_DUMP("header",(uchar*) header,ref_length); DBUG_DUMP("header",(uchar*) header,ref_length);
} }
@ -1559,7 +1559,7 @@ my_bool _ma_memmap_file(MARIA_HA *info)
void _ma_unmap_file(MARIA_HA *info) void _ma_unmap_file(MARIA_HA *info)
{ {
VOID(my_munmap(info->s->file_map,
VOID(my_munmap((char*) info->s->file_map,
(size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN)); (size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN));
} }

5
storage/maria/ma_page.c

@ -116,7 +116,7 @@ int _ma_dispose(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, my_off_t pos,
int level) int level)
{ {
my_off_t old_link; my_off_t old_link;
char buff[8];
uchar buff[8];
uint offset; uint offset;
pgcache_page_no_t page_no; pgcache_page_no_t page_no;
DBUG_ENTER("_ma_dispose"); DBUG_ENTER("_ma_dispose");
@ -166,7 +166,7 @@ my_off_t _ma_new(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, int level)
} }
else else
{ {
buff= alloca(info->s->block_size);
buff= my_alloca(info->s->block_size);
DBUG_ASSERT(info->s->pagecache->block_size == keyinfo->block_length && DBUG_ASSERT(info->s->pagecache->block_size == keyinfo->block_length &&
info->s->pagecache->block_size == info->s->block_size); info->s->pagecache->block_size == info->s->block_size);
/* /*
@ -181,6 +181,7 @@ my_off_t _ma_new(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, int level)
pos= HA_OFFSET_ERROR; pos= HA_OFFSET_ERROR;
else else
info->s->state.key_del= mi_sizekorr(buff); info->s->state.key_del= mi_sizekorr(buff);
my_afree(buff);
} }
info->s->state.changed|= STATE_NOT_SORTED_PAGES; info->s->state.changed|= STATE_NOT_SORTED_PAGES;
DBUG_PRINT("exit",("Pos: %ld",(long) pos)); DBUG_PRINT("exit",("Pos: %ld",(long) pos));

3
storage/maria/ma_pagecache.c

@ -726,8 +726,7 @@ int init_pagecache(PAGECACHE *pagecache, size_t use_mem,
For each block 2 hash links are allocated For each block 2 hash links are allocated
*/ */
if ((pagecache->block_root= if ((pagecache->block_root=
(PAGECACHE_BLOCK_LINK*) my_malloc((uint) length,
MYF(0))))
(PAGECACHE_BLOCK_LINK*) my_malloc((uint) length, MYF(0))))
break; break;
my_large_free(pagecache->block_mem, MYF(0)); my_large_free(pagecache->block_mem, MYF(0));
pagecache->block_mem= 0; pagecache->block_mem= 0;

49
storage/maria/ma_rkey.c

@ -45,6 +45,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key,
info->once_flags&= ~USE_PACKED_KEYS; /* Reset flag */ info->once_flags&= ~USE_PACKED_KEYS; /* Reset flag */
/* /*
key is already packed!; This happens when we are using a MERGE TABLE key is already packed!; This happens when we are using a MERGE TABLE
In this key 'key_part_map' is the length of the key !
*/ */
key_buff= info->lastkey+info->s->base.max_key_length; key_buff= info->lastkey+info->s->base.max_key_length;
pack_key_length= keypart_map; pack_key_length= keypart_map;
@ -95,46 +96,66 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key,
share->concurrent_insert) share->concurrent_insert)
{ {
/* /*
If we searching for a partial key (or using >, >=, < or <=) and
the data is outside of the data file, we need to continue searching
for the first key inside the data file
Found a key, but it might not be usable. We cannot use rows that
are inserted by other threads after we got our table lock
("concurrent inserts"). The record may not even be present yet.
Keys are inserted into the index(es) before the record is
inserted into the data file. When we got our table lock, we
saved the current data_file_length. Concurrent inserts always go
to the end of the file. So we can test if the found key
references a new record.
*/ */
if (info->cur_row.lastpos >= info->state->data_file_length &&
(search_flag != HA_READ_KEY_EXACT ||
last_used_keyseg != keyinfo->seg + keyinfo->keysegs))
if (info->cur_row.lastpos >= info->state->data_file_length)
{ {
/* The key references a concurrently inserted record. */
if (search_flag == HA_READ_KEY_EXACT &&
last_used_keyseg == keyinfo->seg + keyinfo->keysegs)
{
/* Simply ignore the key if it matches exactly. (Bug #29838) */
my_errno= HA_ERR_KEY_NOT_FOUND;
info->cur_row.lastpos= HA_OFFSET_ERROR;
}
else
{
/*
If searching for a partial key (or using >, >=, < or <=) and
the data is outside of the data file, we need to continue
searching for the first key inside the data file.
*/
do do
{ {
uint not_used[2]; uint not_used[2];
/* /*
Skip rows that are inserted by other threads since we got a lock
Note that this can only happen if we are not searching after an
full length exact key, because the keys are sorted
according to position
Skip rows that are inserted by other threads since we got
a lock. Note that this can only happen if we are not
searching after a full length exact key, because the keys
are sorted according to position.
*/ */
if (_ma_search_next(info, keyinfo, info->lastkey, if (_ma_search_next(info, keyinfo, info->lastkey,
info->lastkey_length, info->lastkey_length,
maria_readnext_vec[search_flag], maria_readnext_vec[search_flag],
info->s->state.key_root[inx])) info->s->state.key_root[inx]))
break;
break; /* purecov: inspected */
/* /*
Check that the found key does still match the search. Check that the found key does still match the search.
_ma_search_next() delivers the next key regardless of its _ma_search_next() delivers the next key regardless of its
value. value.
*/ */
if (search_flag == HA_READ_KEY_EXACT && if (search_flag == HA_READ_KEY_EXACT &&
ha_key_cmp(keyinfo->seg, (uchar*) key_buff,
(uchar*) info->lastkey, use_key_length,
SEARCH_FIND, not_used))
ha_key_cmp(keyinfo->seg, key_buff, info->lastkey,
use_key_length, SEARCH_FIND, not_used))
{ {
/* purecov: begin inspected */
my_errno= HA_ERR_KEY_NOT_FOUND; my_errno= HA_ERR_KEY_NOT_FOUND;
info->cur_row.lastpos= HA_OFFSET_ERROR; info->cur_row.lastpos= HA_OFFSET_ERROR;
break; break;
/* purecov: end */
} }
} while (info->cur_row.lastpos >= info->state->data_file_length); } while (info->cur_row.lastpos >= info->state->data_file_length);
} }
} }
} }
}
if (share->concurrent_insert) if (share->concurrent_insert)
rw_unlock(&share->key_root_lock[inx]); rw_unlock(&share->key_root_lock[inx]);

2
storage/maria/ma_search.c

@ -837,7 +837,7 @@ uint _ma_get_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag,
if (tot_length >= 255 && *start != 255) if (tot_length >= 255 && *start != 255)
{ {
/* length prefix changed from a length of one to a length of 3 */ /* length prefix changed from a length of one to a length of 3 */
bmove_upp((char*) key+length+3,(char*) key+length+1,length);
bmove_upp(key+length+3, key+length+1, length);
*key=255; *key=255;
mi_int2store(key+1,tot_length); mi_int2store(key+1,tot_length);
key+=3+length; key+=3+length;

65
storage/maria/ma_sort.c

@ -47,42 +47,41 @@ extern void print_error _VARARGS((const char *fmt,...));
/* Functions defined in this file */ /* Functions defined in this file */
static ha_rows NEAR_F find_all_keys(MARIA_SORT_PARAM *info,uint keys,
static ha_rows find_all_keys(MARIA_SORT_PARAM *info,uint keys,
uchar **sort_keys, uchar **sort_keys,
DYNAMIC_ARRAY *buffpek,int *maxbuffer, DYNAMIC_ARRAY *buffpek,int *maxbuffer,
IO_CACHE *tempfile, IO_CACHE *tempfile,
IO_CACHE *tempfile_for_exceptions); IO_CACHE *tempfile_for_exceptions);
static int NEAR_F write_keys(MARIA_SORT_PARAM *info, uchar **sort_keys,
static int write_keys(MARIA_SORT_PARAM *info, uchar **sort_keys,
uint count, BUFFPEK *buffpek,IO_CACHE *tempfile); uint count, BUFFPEK *buffpek,IO_CACHE *tempfile);
static int NEAR_F write_key(MARIA_SORT_PARAM *info, uchar *key,
static int write_key(MARIA_SORT_PARAM *info, uchar *key,
IO_CACHE *tempfile); IO_CACHE *tempfile);
static int NEAR_F write_index(MARIA_SORT_PARAM *info, uchar **sort_keys,
static int write_index(MARIA_SORT_PARAM *info, uchar **sort_keys,
uint count); uint count);
static int NEAR_F merge_many_buff(MARIA_SORT_PARAM *info,uint keys,
static int merge_many_buff(MARIA_SORT_PARAM *info,uint keys,
uchar **sort_keys, uchar **sort_keys,
BUFFPEK *buffpek,int *maxbuffer, BUFFPEK *buffpek,int *maxbuffer,
IO_CACHE *t_file); IO_CACHE *t_file);
static uint NEAR_F read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
static uint read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
uint sort_length); uint sort_length);
static int NEAR_F merge_buffers(MARIA_SORT_PARAM *info,uint keys,
static int merge_buffers(MARIA_SORT_PARAM *info,uint keys,
IO_CACHE *from_file, IO_CACHE *to_file, IO_CACHE *from_file, IO_CACHE *to_file,
uchar **sort_keys, BUFFPEK *lastbuff, uchar **sort_keys, BUFFPEK *lastbuff,
BUFFPEK *Fb, BUFFPEK *Tb); BUFFPEK *Fb, BUFFPEK *Tb);
static int NEAR_F merge_index(MARIA_SORT_PARAM *,uint, uchar **,BUFFPEK *, int,
static int merge_index(MARIA_SORT_PARAM *,uint, uchar **,BUFFPEK *, int,
IO_CACHE *); IO_CACHE *);
static int flush_maria_ft_buf(MARIA_SORT_PARAM *info); static int flush_maria_ft_buf(MARIA_SORT_PARAM *info);
static int NEAR_F write_keys_varlen(MARIA_SORT_PARAM *info, uchar **sort_keys,
static int write_keys_varlen(MARIA_SORT_PARAM *info, uchar **sort_keys,
uint count, BUFFPEK *buffpek, uint count, BUFFPEK *buffpek,
IO_CACHE *tempfile); IO_CACHE *tempfile);
static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek,
static uint read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek,
uint sort_length); uint sort_length);
static int NEAR_F write_merge_key(MARIA_SORT_PARAM *info, IO_CACHE *to_file,
char *key, uint sort_length, uint count);
static int NEAR_F write_merge_key_varlen(MARIA_SORT_PARAM *info,
IO_CACHE *to_file,
char* key, uint sort_length,
uint count);
static int write_merge_key(MARIA_SORT_PARAM *info, IO_CACHE *to_file,
uchar *key, uint sort_length, uint count);
static int write_merge_key_varlen(MARIA_SORT_PARAM *info,
IO_CACHE *to_file, uchar *key,
uint sort_length, uint count);
static inline int static inline int
my_var_write(MARIA_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs); my_var_write(MARIA_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs);
@ -141,7 +140,7 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
if ((records < UINT_MAX32) && if ((records < UINT_MAX32) &&
((my_off_t) (records + 1) * ((my_off_t) (records + 1) *
(sort_length + sizeof(char*)) <= (my_off_t) memavl)) (sort_length + sizeof(char*)) <= (my_off_t) memavl))
keys= records+1;
keys= (uint)records+1;
else else
do do
{ {
@ -257,7 +256,7 @@ err:
/* Search after all keys and place them in a temp. file */ /* Search after all keys and place them in a temp. file */
static ha_rows NEAR_F find_all_keys(MARIA_SORT_PARAM *info, uint keys,
static ha_rows find_all_keys(MARIA_SORT_PARAM *info, uint keys,
uchar **sort_keys, DYNAMIC_ARRAY *buffpek, uchar **sort_keys, DYNAMIC_ARRAY *buffpek,
int *maxbuffer, IO_CACHE *tempfile, int *maxbuffer, IO_CACHE *tempfile,
IO_CACHE *tempfile_for_exceptions) IO_CACHE *tempfile_for_exceptions)
@ -350,7 +349,7 @@ pthread_handler_t _ma_thr_find_all_keys(void *arg)
bzero((char*) &sort_param->unique, sizeof(sort_param->unique)); bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY); memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
idx= sort_param->sort_info->max_records;
idx= (uint)sort_param->sort_info->max_records;
sort_length= sort_param->key_length; sort_length= sort_param->key_length;
maxbuffer= 1; maxbuffer= 1;
@ -685,7 +684,7 @@ my_var_write(MARIA_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs)
} }
static int NEAR_F write_keys_varlen(MARIA_SORT_PARAM *info,
static int write_keys_varlen(MARIA_SORT_PARAM *info,
register uchar **sort_keys, register uchar **sort_keys,
uint count, BUFFPEK *buffpek, uint count, BUFFPEK *buffpek,
IO_CACHE *tempfile) IO_CACHE *tempfile)
@ -712,7 +711,7 @@ static int NEAR_F write_keys_varlen(MARIA_SORT_PARAM *info,
} /* write_keys_varlen */ } /* write_keys_varlen */
static int NEAR_F write_key(MARIA_SORT_PARAM *info, uchar *key,
static int write_key(MARIA_SORT_PARAM *info, uchar *key,
IO_CACHE *tempfile) IO_CACHE *tempfile)
{ {
uint key_length=info->real_key_length; uint key_length=info->real_key_length;
@ -732,7 +731,7 @@ static int NEAR_F write_key(MARIA_SORT_PARAM *info, uchar *key,
/* Write index */ /* Write index */
static int NEAR_F write_index(MARIA_SORT_PARAM *info,
static int write_index(MARIA_SORT_PARAM *info,
register uchar **sort_keys, register uchar **sort_keys,
register uint count) register uint count)
{ {
@ -751,7 +750,7 @@ static int NEAR_F write_index(MARIA_SORT_PARAM *info,
/* Merge buffers to make < MERGEBUFF2 buffers */ /* Merge buffers to make < MERGEBUFF2 buffers */
static int NEAR_F merge_many_buff(MARIA_SORT_PARAM *info, uint keys,
static int merge_many_buff(MARIA_SORT_PARAM *info, uint keys,
uchar **sort_keys, BUFFPEK *buffpek, uchar **sort_keys, BUFFPEK *buffpek,
int *maxbuffer, IO_CACHE *t_file) int *maxbuffer, IO_CACHE *t_file)
{ {
@ -809,7 +808,7 @@ cleanup:
-1 Error -1 Error
*/ */
static uint NEAR_F read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
static uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
uint sort_length) uint sort_length)
{ {
register uint count; register uint count;
@ -828,7 +827,7 @@ static uint NEAR_F read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
return (count*sort_length); return (count*sort_length);
} /* read_to_buffer */ } /* read_to_buffer */
static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
static uint read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
uint sort_length) uint sort_length)
{ {
register uint count; register uint count;
@ -860,17 +859,17 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
} /* read_to_buffer_varlen */ } /* read_to_buffer_varlen */
static int NEAR_F write_merge_key_varlen(MARIA_SORT_PARAM *info,
IO_CACHE *to_file,char* key,
static int write_merge_key_varlen(MARIA_SORT_PARAM *info,
IO_CACHE *to_file, uchar* key,
uint sort_length, uint count) uint sort_length, uint count)
{ {
uint idx; uint idx;
uchar *bufs = key;
char *bufs = key;
for (idx=1;idx<=count;idx++) for (idx=1;idx<=count;idx++)
{ {
int err; int err;
if ((err= my_var_write(info,to_file, (uchar*) bufs)))
if ((err= my_var_write(info, to_file, bufs)))
return (err); return (err);
bufs=bufs+sort_length; bufs=bufs+sort_length;
} }
@ -878,11 +877,11 @@ static int NEAR_F write_merge_key_varlen(MARIA_SORT_PARAM *info,
} }
static int NEAR_F write_merge_key(MARIA_SORT_PARAM *info __attribute__((unused)),
IO_CACHE *to_file, char* key,
static int write_merge_key(MARIA_SORT_PARAM *info __attribute__((unused)),
IO_CACHE *to_file, uchar *key,
uint sort_length, uint count) uint sort_length, uint count)
{ {
return my_b_write(to_file,(uchar*) key,(uint) sort_length*count);
return my_b_write(to_file, key, (size_t) sort_length*count);
} }
/* /*
@ -927,7 +926,7 @@ merge_buffers(MARIA_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
sort_length)); sort_length));
if (error == -1) if (error == -1)
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
queue_insert(&queue,(char*) buffpek);
queue_insert(&queue,(uchar*) buffpek);
} }
while (queue.elements > 1) while (queue.elements > 1)

59
storage/maria/ma_sp_key.c

@ -31,11 +31,6 @@ static int sp_get_geometry_mbr(uchar *(*wkb), uchar *end, uint n_dims,
double *mbr, int top); double *mbr, int top);
static int sp_mbr_from_wkb(uchar (*wkb), uint size, uint n_dims, double *mbr); static int sp_mbr_from_wkb(uchar (*wkb), uint size, uint n_dims, double *mbr);
static void get_double(double *d, const uchar *pos)
{
float8get(*d, pos);
}
uint _ma_sp_make_key(register MARIA_HA *info, uint keynr, uchar *key, uint _ma_sp_make_key(register MARIA_HA *info, uint keynr, uchar *key,
const uchar *record, my_off_t filepos) const uchar *record, my_off_t filepos)
{ {
@ -62,48 +57,40 @@ uint _ma_sp_make_key(register MARIA_HA *info, uint keynr, uchar *key,
for (i = 0, keyseg = keyinfo->seg; keyseg->type; keyseg++, i++) for (i = 0, keyseg = keyinfo->seg; keyseg->type; keyseg++, i++)
{ {
uint length = keyseg->length;
uint length = keyseg->length, start= keyseg->start;
double val;
pos = ((uchar*)mbr) + keyseg->start;
if (keyseg->flag & HA_SWAP_KEY)
{
DBUG_ASSERT(length == sizeof(double));
DBUG_ASSERT(!(start % sizeof(double)));
DBUG_ASSERT(start < sizeof(mbr));
DBUG_ASSERT(keyseg->type == HA_KEYTYPE_DOUBLE);
val= mbr[start / sizeof (double)];
#ifdef HAVE_ISNAN #ifdef HAVE_ISNAN
if (keyseg->type == HA_KEYTYPE_FLOAT)
{
float nr;
float4get(nr, pos);
if (isnan(nr))
{
/* Replace NAN with zero */
bzero(key, length);
key+= length;
continue;
}
}
else if (keyseg->type == HA_KEYTYPE_DOUBLE)
{
double nr;
get_double(&nr, pos);
if (isnan(nr))
if (isnan(val))
{ {
bzero(key, length); bzero(key, length);
key+= length; key+= length;
len+= length;
continue; continue;
} }
}
#endif #endif
pos += length;
while (length--)
if (keyseg->flag & HA_SWAP_KEY)
{ {
uchar buf[sizeof(double)];
float8store(buf, val);
pos= &buf[length];
while (pos > buf)
*key++ = *--pos; *key++ = *--pos;
} }
}
else else
{ {
memcpy((uchar*)key, pos, length);
key += keyseg->length;
float8store((uchar *)key, val);
key += length;
} }
len += keyseg->length;
len+= length;
} }
_ma_dpointer(info, key, filepos); _ma_dpointer(info, key, filepos);
return len; return len;
@ -141,13 +128,13 @@ static int sp_add_point_to_mbr(uchar *(*wkb), uchar *end, uint n_dims,
{ {
if ((*wkb) > end - 8) if ((*wkb) > end - 8)
return -1; return -1;
get_double(&ord, (const uchar*) *wkb);
float8get(ord, (const uchar*) *wkb);
(*wkb)+= 8; (*wkb)+= 8;
if (ord < *mbr) if (ord < *mbr)
float8store((char*) mbr, ord);
*mbr= ord;
mbr++; mbr++;
if (ord > *mbr) if (ord > *mbr)
float8store((char*) mbr, ord);
*mbr= ord;
mbr++; mbr++;
} }
return 0; return 0;

34
storage/maria/ma_sp_test.c

@ -24,11 +24,11 @@
#define MAX_REC_LENGTH 1024 #define MAX_REC_LENGTH 1024
#define KEYALG HA_KEY_ALG_RTREE #define KEYALG HA_KEY_ALG_RTREE
static void create_linestring(char *record,uint rownr);
static void print_record(char * record,my_off_t offs,const char * tail);
static void create_linestring(uchar *record,uint rownr);
static void print_record(uchar * record,my_off_t offs,const char * tail);
static void create_key(char *key,uint rownr);
static void print_key(const char *key,const char * tail);
static void create_key(uchar *key,uint rownr);
static void print_key(const uchar *key,const char * tail);
static int run_test(const char *filename); static int run_test(const char *filename);
static int read_with_pos(MARIA_HA * file, int silent); static int read_with_pos(MARIA_HA * file, int silent);
@ -65,9 +65,9 @@ int run_test(const char *filename)
int i; int i;
int error; int error;
int row_count=0; int row_count=0;
char record[MAX_REC_LENGTH];
char key[MAX_REC_LENGTH];
char read_record[MAX_REC_LENGTH];
uchar record[MAX_REC_LENGTH];
uchar key[MAX_REC_LENGTH];
uchar read_record[MAX_REC_LENGTH];
int upd=10; int upd=10;
ha_rows hrows; ha_rows hrows;
@ -277,7 +277,7 @@ static int read_with_pos (MARIA_HA * file,int silent)
{ {
int error; int error;
int i; int i;
char read_record[MAX_REC_LENGTH];
uchar read_record[MAX_REC_LENGTH];
int rows=0; int rows=0;
if (!silent) if (!silent)
@ -305,7 +305,7 @@ static int read_with_pos (MARIA_HA * file,int silent)
#ifdef NOT_USED #ifdef NOT_USED
static void bprint_record(char * record,
static void bprint_record(uchar * record,
my_off_t offs __attribute__((unused)), my_off_t offs __attribute__((unused)),
const char * tail) const char * tail)
{ {
@ -324,9 +324,9 @@ static void bprint_record(char * record,
#endif #endif
static void print_record(char * record, my_off_t offs,const char * tail)
static void print_record(uchar * record, my_off_t offs,const char * tail)
{ {
char *pos;
uchar *pos;
char *ptr; char *ptr;
uint len; uint len;
@ -346,7 +346,7 @@ static void print_record(char * record, my_off_t offs,const char * tail)
#ifdef NOT_USED #ifdef NOT_USED
static void create_point(char *record,uint rownr)
static void create_point(uchar *record,uint rownr)
{ {
uint tmp; uint tmp;
char *ptr; char *ptr;
@ -373,11 +373,11 @@ static void create_point(char *record,uint rownr)
#endif #endif
static void create_linestring(char *record,uint rownr)
static void create_linestring(uchar *record,uint rownr)
{ {
uint tmp; uint tmp;
char *ptr; char *ptr;
char *pos=record;
uchar *pos= record;
double x[200]; double x[200];
int i,j; int i,j;
int npoints=2; int npoints=2;
@ -401,10 +401,10 @@ static void create_linestring(char *record,uint rownr)
} }
static void create_key(char *key,uint rownr)
static void create_key(uchar *key,uint rownr)
{ {
double c=rownr; double c=rownr;
char *pos;
uchar *pos;
uint i; uint i;
bzero(key,MAX_REC_LENGTH); bzero(key,MAX_REC_LENGTH);
@ -415,7 +415,7 @@ static void create_key(char *key,uint rownr)
} }
} }
static void print_key(const char *key,const char * tail)
static void print_key(const uchar *key,const char * tail)
{ {
double c; double c;
uint i; uint i;

34
storage/maria/ma_statrec.c

@ -26,16 +26,15 @@ my_bool _ma_write_static_record(MARIA_HA *info, const uchar *record)
{ {
my_off_t filepos=info->s->state.dellink; my_off_t filepos=info->s->state.dellink;
info->rec_cache.seek_not_done=1; /* We have done a seek */ info->rec_cache.seek_not_done=1; /* We have done a seek */
if (info->s->file_read(info,(char*) &temp[0],info->s->base.rec_reflength,
if (info->s->file_read(info, &temp[0],info->s->base.rec_reflength,
info->s->state.dellink+1, info->s->state.dellink+1,
MYF(MY_NABP))) MYF(MY_NABP)))
goto err; goto err;
info->s->state.dellink= _ma_rec_pos(info->s,temp); info->s->state.dellink= _ma_rec_pos(info->s,temp);
info->state->del--; info->state->del--;
info->state->empty-=info->s->base.pack_reclength; info->state->empty-=info->s->base.pack_reclength;
if (info->s->file_write(info, (char*) record, info->s->base.reclength,
filepos,
MYF(MY_NABP)))
if (info->s->file_write(info, record, info->s->base.reclength,
filepos, MYF(MY_NABP)))
goto err; goto err;
} }
else else
@ -48,29 +47,29 @@ my_bool _ma_write_static_record(MARIA_HA *info, const uchar *record)
} }
if (info->opt_flag & WRITE_CACHE_USED) if (info->opt_flag & WRITE_CACHE_USED)
{ /* Cash in use */ { /* Cash in use */
if (my_b_write(&info->rec_cache, (uchar*) record,
if (my_b_write(&info->rec_cache, record,
info->s->base.reclength)) info->s->base.reclength))
goto err; goto err;
if (info->s->base.pack_reclength != info->s->base.reclength) if (info->s->base.pack_reclength != info->s->base.reclength)
{ {
uint length=info->s->base.pack_reclength - info->s->base.reclength; uint length=info->s->base.pack_reclength - info->s->base.reclength;
bzero((char*) temp,length);
if (my_b_write(&info->rec_cache, (uchar*) temp,length))
bzero(temp,length);
if (my_b_write(&info->rec_cache, temp,length))
goto err; goto err;
} }
} }
else else
{ {
info->rec_cache.seek_not_done=1; /* We have done a seek */ info->rec_cache.seek_not_done=1; /* We have done a seek */
if (info->s->file_write(info,(char*) record,info->s->base.reclength,
if (info->s->file_write(info, record, info->s->base.reclength,
info->state->data_file_length, info->state->data_file_length,
info->s->write_flag)) info->s->write_flag))
goto err; goto err;
if (info->s->base.pack_reclength != info->s->base.reclength) if (info->s->base.pack_reclength != info->s->base.reclength)
{ {
uint length=info->s->base.pack_reclength - info->s->base.reclength; uint length=info->s->base.pack_reclength - info->s->base.reclength;
bzero((char*) temp,length);
if (info->s->file_write(info, (uchar*) temp,length,
bzero(temp,length);
if (info->s->file_write(info, temp,length,
info->state->data_file_length+ info->state->data_file_length+
info->s->base.reclength, info->s->base.reclength,
info->s->write_flag)) info->s->write_flag))
@ -91,7 +90,7 @@ my_bool _ma_update_static_record(MARIA_HA *info, MARIA_RECORD_POS pos,
{ {
info->rec_cache.seek_not_done=1; /* We have done a seek */ info->rec_cache.seek_not_done=1; /* We have done a seek */
return (info->s->file_write(info, return (info->s->file_write(info,
(char*) record,info->s->base.reclength,
record, info->s->base.reclength,
pos, pos,
MYF(MY_NABP)) != 0); MYF(MY_NABP)) != 0);
} }
@ -132,13 +131,10 @@ my_bool _ma_cmp_static_record(register MARIA_HA *info,
if ((info->opt_flag & READ_CHECK_USED)) if ((info->opt_flag & READ_CHECK_USED))
{ /* If check isn't disabled */ { /* If check isn't disabled */
info->rec_cache.seek_not_done=1; /* We have done a seek */ info->rec_cache.seek_not_done=1; /* We have done a seek */
if (info->s->file_read(info, (char*) info->rec_buff,
info->s->base.reclength,
info->cur_row.lastpos,
MYF(MY_NABP)))
if (info->s->file_read(info, info->rec_buff, info->s->base.reclength,
info->cur_row.lastpos, MYF(MY_NABP)))
DBUG_RETURN(1); DBUG_RETURN(1);
if (memcmp((uchar*) info->rec_buff, (uchar*) old,
(uint) info->s->base.reclength))
if (memcmp(info->rec_buff, old, (uint) info->s->base.reclength))
{ {
DBUG_DUMP("read",old,info->s->base.reclength); DBUG_DUMP("read",old,info->s->base.reclength);
DBUG_DUMP("disk",info->rec_buff,info->s->base.reclength); DBUG_DUMP("disk",info->rec_buff,info->s->base.reclength);
@ -156,7 +152,7 @@ my_bool _ma_cmp_static_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def,
DBUG_ENTER("_ma_cmp_static_unique"); DBUG_ENTER("_ma_cmp_static_unique");
info->rec_cache.seek_not_done=1; /* We have done a seek */ info->rec_cache.seek_not_done=1; /* We have done a seek */
if (info->s->file_read(info, (char*) info->rec_buff, info->s->base.reclength,
if (info->s->file_read(info, info->rec_buff, info->s->base.reclength,
pos, MYF(MY_NABP))) pos, MYF(MY_NABP)))
DBUG_RETURN(1); DBUG_RETURN(1);
DBUG_RETURN(_ma_unique_comp(def, record, (uchar*) info->rec_buff, DBUG_RETURN(_ma_unique_comp(def, record, (uchar*) info->rec_buff,
@ -186,7 +182,7 @@ int _ma_read_static_record(register MARIA_HA *info, register uchar *record,
return(my_errno); return(my_errno);
info->rec_cache.seek_not_done=1; /* We have done a seek */ info->rec_cache.seek_not_done=1; /* We have done a seek */
error=info->s->file_read(info,(char*) record,info->s->base.reclength,
error=info->s->file_read(info, record,info->s->base.reclength,
pos, MYF(MY_NABP)); pos, MYF(MY_NABP));
if (! error) if (! error)
{ {

74
storage/maria/ma_test1.c

@ -48,9 +48,9 @@ static HA_KEYSEG uniqueseg[10];
static int run_test(const char *filename); static int run_test(const char *filename);
static void get_options(int argc, char *argv[]); static void get_options(int argc, char *argv[]);
static void create_key(char *key,uint rownr);
static void create_record(char *record,uint rownr);
static void update_record(char *record);
static void create_key(uchar *key,uint rownr);
static void create_record(uchar *record,uint rownr);
static void update_record(uchar *record);
/* /*
@ -98,7 +98,7 @@ static int run_test(const char *filename)
int i,j,error,deleted,rec_length,uniques=0; int i,j,error,deleted,rec_length,uniques=0;
uint offset_to_key; uint offset_to_key;
ha_rows found,row_count; ha_rows found,row_count;
char record[MAX_REC_LENGTH],key[MAX_REC_LENGTH],read_record[MAX_REC_LENGTH];
uchar record[MAX_REC_LENGTH],key[MAX_REC_LENGTH],read_record[MAX_REC_LENGTH];
MARIA_UNIQUEDEF uniquedef; MARIA_UNIQUEDEF uniquedef;
MARIA_CREATE_INFO create_info; MARIA_CREATE_INFO create_info;
@ -420,6 +420,7 @@ static int run_test(const char *filename)
i-1,error,my_errno,read_record+1); i-1,error,my_errno,read_record+1);
} }
} }
maria_scan_end(file);
end: end:
if (die_in_middle_of_transaction) if (die_in_middle_of_transaction)
@ -467,20 +468,20 @@ err:
} }
static void create_key_part(char *key,uint rownr)
static void create_key_part(uchar *key,uint rownr)
{ {
if (!unique_key) if (!unique_key)
rownr&=7; /* Some identical keys */ rownr&=7; /* Some identical keys */
if (keyinfo[0].seg[0].type == HA_KEYTYPE_NUM) if (keyinfo[0].seg[0].type == HA_KEYTYPE_NUM)
{ {
sprintf(key,"%*d",keyinfo[0].seg[0].length,rownr);
sprintf((char*) key,"%*d",keyinfo[0].seg[0].length,rownr);
} }
else if (keyinfo[0].seg[0].type == HA_KEYTYPE_VARTEXT1 || else if (keyinfo[0].seg[0].type == HA_KEYTYPE_VARTEXT1 ||
keyinfo[0].seg[0].type == HA_KEYTYPE_VARTEXT2) keyinfo[0].seg[0].type == HA_KEYTYPE_VARTEXT2)
{ /* Alpha record */ { /* Alpha record */
/* Create a key that may be easily packed */ /* Create a key that may be easily packed */
bfill(key,keyinfo[0].seg[0].length,rownr < 10 ? 'A' : 'B'); bfill(key,keyinfo[0].seg[0].length,rownr < 10 ? 'A' : 'B');
sprintf(key+keyinfo[0].seg[0].length-2,"%-2d",rownr);
sprintf((char*) key+keyinfo[0].seg[0].length-2,"%-2d",rownr);
if ((rownr & 7) == 0) if ((rownr & 7) == 0)
{ {
/* Change the key to force a unpack of the next key */ /* Change the key to force a unpack of the next key */
@ -490,12 +491,12 @@ static void create_key_part(char *key,uint rownr)
else else
{ /* Alpha record */ { /* Alpha record */
if (keyinfo[0].seg[0].flag & HA_SPACE_PACK) if (keyinfo[0].seg[0].flag & HA_SPACE_PACK)
sprintf(key,"%-*d",keyinfo[0].seg[0].length,rownr);
sprintf((char*) key,"%-*d",keyinfo[0].seg[0].length,rownr);
else else
{ {
/* Create a key that may be easily packed */ /* Create a key that may be easily packed */
bfill(key,keyinfo[0].seg[0].length,rownr < 10 ? 'A' : 'B'); bfill(key,keyinfo[0].seg[0].length,rownr < 10 ? 'A' : 'B');
sprintf(key+keyinfo[0].seg[0].length-2,"%-2d",rownr);
sprintf((char*) key+keyinfo[0].seg[0].length-2,"%-2d",rownr);
if ((rownr & 7) == 0) if ((rownr & 7) == 0)
{ {
/* Change the key to force a unpack of the next key */ /* Change the key to force a unpack of the next key */
@ -506,7 +507,7 @@ static void create_key_part(char *key,uint rownr)
} }
static void create_key(char *key,uint rownr)
static void create_key(uchar *key,uint rownr)
{ {
if (keyinfo[0].seg[0].null_bit) if (keyinfo[0].seg[0].null_bit)
{ {
@ -522,7 +523,7 @@ static void create_key(char *key,uint rownr)
{ {
uint tmp; uint tmp;
create_key_part(key+2,rownr); create_key_part(key+2,rownr);
tmp=strlen(key+2);
tmp=strlen((char*) key+2);
int2store(key,tmp); int2store(key,tmp);
} }
else else
@ -530,13 +531,13 @@ static void create_key(char *key,uint rownr)
} }
static char blob_key[MAX_REC_LENGTH];
static char blob_record[MAX_REC_LENGTH+20*20];
static uchar blob_key[MAX_REC_LENGTH];
static uchar blob_record[MAX_REC_LENGTH+20*20];
static void create_record(char *record,uint rownr)
static void create_record(uchar *record,uint rownr)
{ {
char *pos;
uchar *pos;
bzero((char*) record,MAX_REC_LENGTH); bzero((char*) record,MAX_REC_LENGTH);
record[0]=1; /* delete marker */ record[0]=1; /* delete marker */
if (rownr == 0 && keyinfo[0].seg[0].null_bit) if (rownr == 0 && keyinfo[0].seg[0].null_bit)
@ -546,9 +547,9 @@ static void create_record(char *record,uint rownr)
if (recinfo[0].type == FIELD_BLOB) if (recinfo[0].type == FIELD_BLOB)
{ {
uint tmp; uint tmp;
char *ptr;
uchar *ptr;
create_key_part(blob_key,rownr); create_key_part(blob_key,rownr);
tmp=strlen(blob_key);
tmp=strlen((char*) blob_key);
int4store(pos,tmp); int4store(pos,tmp);
ptr=blob_key; ptr=blob_key;
memcpy_fixed(pos+4,&ptr,sizeof(char*)); memcpy_fixed(pos+4,&ptr,sizeof(char*));
@ -558,7 +559,7 @@ static void create_record(char *record,uint rownr)
{ {
uint tmp, pack_length= HA_VARCHAR_PACKLENGTH(recinfo[0].length-1); uint tmp, pack_length= HA_VARCHAR_PACKLENGTH(recinfo[0].length-1);
create_key_part(pos+pack_length,rownr); create_key_part(pos+pack_length,rownr);
tmp= strlen(pos+pack_length);
tmp= strlen((char*) pos+pack_length);
if (pack_length == 1) if (pack_length == 1)
*(uchar*) pos= (uchar) tmp; *(uchar*) pos= (uchar) tmp;
else else
@ -573,10 +574,10 @@ static void create_record(char *record,uint rownr)
if (recinfo[1].type == FIELD_BLOB) if (recinfo[1].type == FIELD_BLOB)
{ {
uint tmp; uint tmp;
char *ptr;;
sprintf(blob_record,"... row: %d", rownr);
strappend(blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
tmp=strlen(blob_record);
uchar *ptr;;
sprintf((char*) blob_record,"... row: %d", rownr);
strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
tmp=strlen((char*) blob_record);
int4store(pos,tmp); int4store(pos,tmp);
ptr=blob_record; ptr=blob_record;
memcpy_fixed(pos+4,&ptr,sizeof(char*)); memcpy_fixed(pos+4,&ptr,sizeof(char*));
@ -584,28 +585,28 @@ static void create_record(char *record,uint rownr)
else if (recinfo[1].type == FIELD_VARCHAR) else if (recinfo[1].type == FIELD_VARCHAR)
{ {
uint tmp, pack_length= HA_VARCHAR_PACKLENGTH(recinfo[1].length-1); uint tmp, pack_length= HA_VARCHAR_PACKLENGTH(recinfo[1].length-1);
sprintf(pos+pack_length, "... row: %d", rownr);
tmp= strlen(pos+pack_length);
sprintf((char*) pos+pack_length, "... row: %d", rownr);
tmp= strlen((char*) pos+pack_length);
if (pack_length == 1) if (pack_length == 1)
*(uchar*) pos= (uchar) tmp;
pos= (uchar) tmp;
else else
int2store(pos,tmp); int2store(pos,tmp);
} }
else else
{ {
sprintf(pos,"... row: %d", rownr);
strappend(pos,recinfo[1].length,' ');
sprintf((char*) pos,"... row: %d", rownr);
strappend((char*) pos,recinfo[1].length,' ');
} }
} }
/* change row to test re-packing of rows and reallocation of keys */ /* change row to test re-packing of rows and reallocation of keys */
static void update_record(char *record)
static void update_record(uchar *record)
{ {
char *pos=record+1;
uchar *pos=record+1;
if (recinfo[0].type == FIELD_BLOB) if (recinfo[0].type == FIELD_BLOB)
{ {
char *column,*ptr;
uchar *column,*ptr;
int length; int length;
length=uint4korr(pos); /* Long blob */ length=uint4korr(pos); /* Long blob */
memcpy_fixed(&column,pos+4,sizeof(char*)); memcpy_fixed(&column,pos+4,sizeof(char*));
@ -614,7 +615,8 @@ static void update_record(char *record)
memcpy_fixed(pos+4,&ptr,sizeof(char*)); /* Store pointer to new key */ memcpy_fixed(pos+4,&ptr,sizeof(char*)); /* Store pointer to new key */
if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM) if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM)
default_charset_info->cset->casedn(default_charset_info, default_charset_info->cset->casedn(default_charset_info,
blob_key, length, blob_key, length);
(char*) blob_key, length,
(char*) blob_key, length);
pos+=recinfo[0].length; pos+=recinfo[0].length;
} }
else if (recinfo[0].type == FIELD_VARCHAR) else if (recinfo[0].type == FIELD_VARCHAR)
@ -622,22 +624,22 @@ static void update_record(char *record)
uint pack_length= HA_VARCHAR_PACKLENGTH(recinfo[0].length-1); uint pack_length= HA_VARCHAR_PACKLENGTH(recinfo[0].length-1);
uint length= pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos); uint length= pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos);
default_charset_info->cset->casedn(default_charset_info, default_charset_info->cset->casedn(default_charset_info,
pos + pack_length, length,
pos + pack_length, length);
(char*) pos + pack_length, length,
(char*) pos + pack_length, length);
pos+=recinfo[0].length; pos+=recinfo[0].length;
} }
else else
{ {
if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM) if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM)
default_charset_info->cset->casedn(default_charset_info, default_charset_info->cset->casedn(default_charset_info,
pos, keyinfo[0].seg[0].length,
pos, keyinfo[0].seg[0].length);
(char*) pos, keyinfo[0].seg[0].length,
(char*) pos, keyinfo[0].seg[0].length);
pos+=recinfo[0].length; pos+=recinfo[0].length;
} }
if (recinfo[1].type == FIELD_BLOB) if (recinfo[1].type == FIELD_BLOB)
{ {
char *column;
uchar *column;
int length; int length;
length=uint4korr(pos); length=uint4korr(pos);
memcpy_fixed(&column,pos+4,sizeof(char*)); memcpy_fixed(&column,pos+4,sizeof(char*));

46
storage/maria/ma_test2.c

@ -40,7 +40,7 @@
static void get_options(int argc, char *argv[]); static void get_options(int argc, char *argv[]);
static uint rnd(uint max_value); static uint rnd(uint max_value);
static void fix_length(uchar *record,uint length); static void fix_length(uchar *record,uint length);
static void put_blob_in_record(char *blob_pos,char **blob_buffer,
static void put_blob_in_record(uchar *blob_pos,char **blob_buffer,
ulong *length); ulong *length);
static void copy_key(struct st_maria_info *info,uint inx, static void copy_key(struct st_maria_info *info,uint inx,
uchar *record,uchar *key); uchar *record,uchar *key);
@ -58,8 +58,8 @@ static enum data_file_type record_type= DYNAMIC_RECORD;
static uint keys=MARIA_KEYS,recant=1000; static uint keys=MARIA_KEYS,recant=1000;
static uint use_blob=0; static uint use_blob=0;
static uint16 key1[1001],key3[5000]; static uint16 key1[1001],key3[5000];
static char record[300],record2[300],key[100],key2[100],
read_record[300],read_record2[300],read_record3[300];
static uchar record[300],record2[300],key[100],key2[100];
static uchar read_record[300],read_record2[300],read_record3[300];
static HA_KEYSEG glob_keyseg[MARIA_KEYS][MAX_PARTS]; static HA_KEYSEG glob_keyseg[MARIA_KEYS][MAX_PARTS];
/* Test program */ /* Test program */
@ -261,7 +261,7 @@ int main(int argc, char *argv[])
if (i == 72) goto end; if (i == 72) goto end;
#endif #endif
n1=rnd(1000); n2=rnd(100); n3=rnd(5000); n1=rnd(1000); n2=rnd(100); n3=rnd(5000);
sprintf(record,"%6d:%4d:%8d:Pos: %4d ",n1,n2,n3,write_count);
sprintf((char*) record,"%6d:%4d:%8d:Pos: %4d ",n1,n2,n3,write_count);
int4store(record+STANDARD_LENGTH-4,(long) i); int4store(record+STANDARD_LENGTH-4,(long) i);
fix_length(record,(uint) STANDARD_LENGTH+rnd(60)); fix_length(record,(uint) STANDARD_LENGTH+rnd(60));
put_blob_in_record(record+blob_pos,&blob_buffer, &blob_length); put_blob_in_record(record+blob_pos,&blob_buffer, &blob_length);
@ -292,7 +292,7 @@ int main(int argc, char *argv[])
for (j=rnd(1000)+1 ; j>0 && key1[j] == 0 ; j--) ; for (j=rnd(1000)+1 ; j>0 && key1[j] == 0 ; j--) ;
if (!j) if (!j)
for (j=999 ; j>0 && key1[j] == 0 ; j--) ; for (j=999 ; j>0 && key1[j] == 0 ; j--) ;
sprintf(key,"%6d",j);
sprintf((char*) key,"%6d",j);
if (maria_rkey(file,read_record,0,key,HA_WHOLE_KEY,HA_READ_KEY_EXACT)) if (maria_rkey(file,read_record,0,key,HA_WHOLE_KEY,HA_READ_KEY_EXACT))
{ {
printf("Test in loop: Can't find key: \"%s\"\n",key); printf("Test in loop: Can't find key: \"%s\"\n",key);
@ -325,7 +325,7 @@ int main(int argc, char *argv[])
for (j=rnd(1000)+1 ; j>0 && key1[j] == 0 ; j--) ; for (j=rnd(1000)+1 ; j>0 && key1[j] == 0 ; j--) ;
if (j != 0) if (j != 0)
{ {
sprintf(key,"%6d",j);
sprintf((char*) key,"%6d",j);
if (maria_rkey(file,read_record,0,key,HA_WHOLE_KEY,HA_READ_KEY_EXACT)) if (maria_rkey(file,read_record,0,key,HA_WHOLE_KEY,HA_READ_KEY_EXACT))
{ {
printf("can't find key1: \"%s\"\n",key); printf("can't find key1: \"%s\"\n",key);
@ -345,8 +345,8 @@ int main(int argc, char *argv[])
goto err; goto err;
} }
opt_delete++; opt_delete++;
key1[atoi(read_record+keyinfo[0].seg[0].start)]--;
key3[atoi(read_record+keyinfo[2].seg[0].start)]=0;
key1[atoi((char*) read_record+keyinfo[0].seg[0].start)]--;
key3[atoi((char*) read_record+keyinfo[2].seg[0].start)]=0;
} }
else else
puts("Warning: Skipping delete test because no dupplicate keys"); puts("Warning: Skipping delete test because no dupplicate keys");
@ -361,17 +361,17 @@ int main(int argc, char *argv[])
for (i=0 ; i<recant/10 ; i++) for (i=0 ; i<recant/10 ; i++)
{ {
n1=rnd(1000); n2=rnd(100); n3=rnd(5000); n1=rnd(1000); n2=rnd(100); n3=rnd(5000);
sprintf(record2,"%6d:%4d:%8d:XXX: %4d ",n1,n2,n3,update);
sprintf((char*) record2,"%6d:%4d:%8d:XXX: %4d ",n1,n2,n3,update);
int4store(record2+STANDARD_LENGTH-4,(long) i); int4store(record2+STANDARD_LENGTH-4,(long) i);
fix_length(record2,(uint) STANDARD_LENGTH+rnd(60)); fix_length(record2,(uint) STANDARD_LENGTH+rnd(60));
for (j=rnd(1000)+1 ; j>0 && key1[j] == 0 ; j--) ; for (j=rnd(1000)+1 ; j>0 && key1[j] == 0 ; j--) ;
if (j != 0) if (j != 0)
{ {
sprintf(key,"%6d",j);
sprintf((char*) key,"%6d",j);
if (maria_rkey(file,read_record,0,key,HA_WHOLE_KEY,HA_READ_KEY_EXACT)) if (maria_rkey(file,read_record,0,key,HA_WHOLE_KEY,HA_READ_KEY_EXACT))
{ {
printf("can't find key1: \"%s\"\n",key);
printf("can't find key1: \"%s\"\n", (char*) key);
goto err; goto err;
} }
if (bcmp(read_record+keyinfo[0].seg[0].start, if (bcmp(read_record+keyinfo[0].seg[0].start,
@ -405,8 +405,8 @@ int main(int argc, char *argv[])
} }
else else
{ {
key1[atoi(read_record+keyinfo[0].seg[0].start)]--;
key3[atoi(read_record+keyinfo[2].seg[0].start)]=0;
key1[atoi((char*) read_record+keyinfo[0].seg[0].start)]--;
key3[atoi((char*) read_record+keyinfo[2].seg[0].start)]=0;
key1[n1]++; key3[n3]=1; key1[n1]++; key3[n3]=1;
update++; update++;
} }
@ -422,7 +422,7 @@ int main(int argc, char *argv[])
dupp_keys=key1[i]; j=i; dupp_keys=key1[i]; j=i;
} }
} }
sprintf(key,"%6d",j);
sprintf((char*) key,"%6d",j);
start=keyinfo[0].seg[0].start; start=keyinfo[0].seg[0].start;
length=keyinfo[0].seg[0].length; length=keyinfo[0].seg[0].length;
if (dupp_keys) if (dupp_keys)
@ -720,8 +720,8 @@ int main(int argc, char *argv[])
key_range min_key, max_key; key_range min_key, max_key;
if (j > k) if (j > k)
swap_variables(int, j, k); swap_variables(int, j, k);
sprintf(key,"%6d",j);
sprintf(key2,"%6d",k);
sprintf((char*) key,"%6d",j);
sprintf((char*) key2,"%6d",k);
min_key.key= key; min_key.key= key;
min_key.keypart_map= HA_WHOLE_KEY; min_key.keypart_map= HA_WHOLE_KEY;
@ -797,13 +797,16 @@ int main(int argc, char *argv[])
{ {
printf("scan with cache: I can only find: %d records of %d\n", printf("scan with cache: I can only find: %d records of %d\n",
ant,write_count-opt_delete); ant,write_count-opt_delete);
maria_scan_end(file);
goto err; goto err;
} }
if (maria_extra(file,HA_EXTRA_NO_CACHE,0)) if (maria_extra(file,HA_EXTRA_NO_CACHE,0))
{ {
puts("got error from maria_extra(HA_EXTRA_NO_CACHE)"); puts("got error from maria_extra(HA_EXTRA_NO_CACHE)");
maria_scan_end(file);
goto err; goto err;
} }
maria_scan_end(file);
ant=0; ant=0;
maria_scan_init(file); maria_scan_init(file);
@ -814,8 +817,10 @@ int main(int argc, char *argv[])
{ {
printf("scan with cache: I can only find: %d records of %d\n", printf("scan with cache: I can only find: %d records of %d\n",
ant,write_count-opt_delete); ant,write_count-opt_delete);
maria_scan_end(file);
goto err; goto err;
} }
maria_scan_end(file);
if (testflag == 5) if (testflag == 5)
goto end; goto end;
@ -885,16 +890,17 @@ int main(int argc, char *argv[])
else else
found_parts++; found_parts++;
} }
maria_scan_end(file);
if (my_errno != HA_ERR_END_OF_FILE && my_errno != HA_ERR_RECORD_DELETED) if (my_errno != HA_ERR_END_OF_FILE && my_errno != HA_ERR_RECORD_DELETED)
printf("error: %d from maria_rrnd\n",my_errno); printf("error: %d from maria_rrnd\n",my_errno);
if (write_count != opt_delete) if (write_count != opt_delete)
{ {
printf("Deleted only %d of %d records (%d parts)\n",opt_delete,write_count, printf("Deleted only %d of %d records (%d parts)\n",opt_delete,write_count,
found_parts); found_parts);
maria_scan_end(file);
goto err; goto err;
} }
end: end:
maria_scan_end(file);
if (die_in_middle_of_transaction) if (die_in_middle_of_transaction)
{ {
/* As commit record is not done, UNDO entries needs to be rolled back */ /* As commit record is not done, UNDO entries needs to be rolled back */
@ -967,7 +973,7 @@ reads: %10lu\n",
(ulong) maria_pagecache->global_cache_r_requests, (ulong) maria_pagecache->global_cache_r_requests,
(ulong) maria_pagecache->global_cache_read); (ulong) maria_pagecache->global_cache_read);
} }
end_pagecache(maria_pagecache,1);
maria_end();
my_free(blob_buffer, MYF(MY_ALLOW_ZERO_PTR)); my_free(blob_buffer, MYF(MY_ALLOW_ZERO_PTR));
my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO); my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO);
return(0); return(0);
@ -1130,13 +1136,13 @@ static void fix_length(uchar *rec, uint length)
bmove(rec+STANDARD_LENGTH, bmove(rec+STANDARD_LENGTH,
"0123456789012345678901234567890123456789012345678901234567890", "0123456789012345678901234567890123456789012345678901234567890",
length-STANDARD_LENGTH); length-STANDARD_LENGTH);
strfill(rec+length,STANDARD_LENGTH+60-length,' ');
strfill((char*) rec+length,STANDARD_LENGTH+60-length,' ');
} /* fix_length */ } /* fix_length */
/* Put maybe a blob in record */ /* Put maybe a blob in record */
static void put_blob_in_record(char *blob_pos, char **blob_buffer,
static void put_blob_in_record(uchar *blob_pos, char **blob_buffer,
ulong *blob_length) ulong *blob_length)
{ {
ulong i,length; ulong i,length;

20
storage/maria/ma_test3.c

@ -48,9 +48,9 @@ int test_read(MARIA_HA *,int),test_write(MARIA_HA *,int,int),
test_update(MARIA_HA *,int,int),test_rrnd(MARIA_HA *,int); test_update(MARIA_HA *,int,int),test_rrnd(MARIA_HA *,int);
struct record { struct record {
char id[8];
char nr[4];
char text[10];
uchar id[8];
uchar nr[4];
uchar text[10];
} record; } record;
@ -242,8 +242,8 @@ int test_read(MARIA_HA *file,int id)
for (i=0 ; i < 100 ; i++) for (i=0 ; i < 100 ; i++)
{ {
find=rnd(100000); find=rnd(100000);
if (!maria_rkey(file,record.id,1,(uchar*) &find,
HA_WHOLE_KEY,HA_READ_KEY_EXACT))
if (!maria_rkey(file,record.id,1,(uchar*) &find, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
found++; found++;
else else
{ {
@ -361,8 +361,8 @@ int test_write(MARIA_HA *file,int id,int lock_type)
maria_extra(file,HA_EXTRA_WRITE_CACHE,0); maria_extra(file,HA_EXTRA_WRITE_CACHE,0);
} }
sprintf(record.id,"%7d",getpid());
strnmov(record.text,"Testing...", sizeof(record.text));
sprintf((char*) record.id,"%7d",getpid());
strnmov((char*) record.text,"Testing...", sizeof(record.text));
tries=(uint) rnd(100)+10; tries=(uint) rnd(100)+10;
for (i=count=0 ; i < tries ; i++) for (i=count=0 ; i < tries ; i++)
@ -418,15 +418,15 @@ int test_update(MARIA_HA *file,int id,int lock_type)
} }
} }
bzero((char*) &new_record,sizeof(new_record)); bzero((char*) &new_record,sizeof(new_record));
strmov(new_record.text,"Updated");
strmov((char*) new_record.text,"Updated");
found=next=prev=update=0; found=next=prev=update=0;
for (i=0 ; i < 100 ; i++) for (i=0 ; i < 100 ; i++)
{ {
tmp=rnd(100000); tmp=rnd(100000);
int4store(find,tmp); int4store(find,tmp);
if (!maria_rkey(file,record.id,1,(uchar*) find,
HA_WHOLE_KEY,HA_READ_KEY_EXACT))
if (!maria_rkey(file,record.id,1,(uchar*) find, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
found++; found++;
else else
{ {

6
storage/maria/ma_update.c

@ -110,7 +110,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
key_changed|=HA_STATE_WRITTEN; key_changed|=HA_STATE_WRITTEN;
} }
changed|=((ulonglong) 1 << i); changed|=((ulonglong) 1 << i);
if (_ma_ft_update(info,i,(char*) old_key,oldrec,newrec,pos))
if (_ma_ft_update(info,i,old_key,oldrec,newrec,pos))
goto err; goto err;
} }
} }
@ -215,8 +215,8 @@ err:
{ {
if (share->keyinfo[i].flag & HA_FULLTEXT) if (share->keyinfo[i].flag & HA_FULLTEXT)
{ {
if ((flag++ && _ma_ft_del(info,i,(char*) new_key,newrec,pos)) ||
_ma_ft_add(info,i,(char*) old_key,oldrec,pos))
if ((flag++ && _ma_ft_del(info,i,new_key,newrec,pos)) ||
_ma_ft_add(info,i,old_key,oldrec,pos))
break; break;
} }
else else

8
storage/maria/ma_write.c

@ -134,7 +134,7 @@ int maria_write(MARIA_HA *info, uchar *record)
} }
if (share->keyinfo[i].flag & HA_FULLTEXT ) if (share->keyinfo[i].flag & HA_FULLTEXT )
{ {
if (_ma_ft_add(info,i,(char*) buff,record,filepos))
if (_ma_ft_add(info,i, buff,record,filepos))
{ {
if (local_lock_tree) if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]); rw_unlock(&share->key_root_lock[i]);
@ -243,7 +243,7 @@ err:
*/ */
if (share->keyinfo[i].flag & HA_FULLTEXT) if (share->keyinfo[i].flag & HA_FULLTEXT)
{ {
if (_ma_ft_del(info,i,(char*) buff,record,filepos))
if (_ma_ft_del(info,i,buff,record,filepos))
{ {
if (local_lock_tree) if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]); rw_unlock(&share->key_root_lock[i]);
@ -615,7 +615,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
we cannot easily dispatch an empty page here */ we cannot easily dispatch an empty page here */
b+=blen+ft2len+2; b+=blen+ft2len+2;
for (a=anc_buff+a_length ; b < a ; b+=ft2len+2) for (a=anc_buff+a_length ; b < a ; b+=ft2len+2)
insert_dynamic(info->ft1_to_ft2, (char*) b);
insert_dynamic(info->ft1_to_ft2, b);
/* fixing the page's length - it contains only one key now */ /* fixing the page's length - it contains only one key now */
maria_putint(anc_buff,2+blen+ft2len+2,0); maria_putint(anc_buff,2+blen+ft2len+2,0);
@ -1041,7 +1041,7 @@ int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows)
DBUG_RETURN(0); DBUG_RETURN(0);
if (rows && rows*total_keylength < cache_size) if (rows && rows*total_keylength < cache_size)
cache_size=rows;
cache_size= (ulong)rows;
else else
cache_size/=total_keylength*16; cache_size/=total_keylength*16;

4
storage/maria/maria_chk.c

@ -332,7 +332,7 @@ static struct my_option my_long_options[] =
(uchar**) &ft_stopword_file, (uchar**) &ft_stopword_file, 0, GET_STR, (uchar**) &ft_stopword_file, (uchar**) &ft_stopword_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"stats_method", OPT_STATS_METHOD, {"stats_method", OPT_STATS_METHOD,
"Specifies how index statistics collection code should threat NULLs. "
"Specifies how index statistics collection code should treat NULLs. "
"Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), " "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), "
"\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".", "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".",
(uchar**) &maria_stats_method_str, (uchar**) &maria_stats_method_str, 0, (uchar**) &maria_stats_method_str, (uchar**) &maria_stats_method_str, 0,
@ -447,7 +447,7 @@ static void usage(void)
MySQL faster. You can check the calculated distribution\n\ MySQL faster. You can check the calculated distribution\n\
by using '--description --verbose table_name'.\n\ by using '--description --verbose table_name'.\n\
--stats_method=name Specifies how index statistics collection code should\n\ --stats_method=name Specifies how index statistics collection code should\n\
threat NULLs. Possible values of name are \"nulls_unequal\"\n\
treat NULLs. Possible values of name are \"nulls_unequal\"\n\
(default for 4.1/5.0), \"nulls_equal\" (emulate 4.0), and \n\ (default for 4.1/5.0), \"nulls_equal\" (emulate 4.0), and \n\
\"nulls_ignored\".\n\ \"nulls_ignored\".\n\
-d, --description Prints some information about table.\n\ -d, --description Prints some information about table.\n\

28
storage/maria/maria_def.h

@ -281,8 +281,8 @@ typedef struct st_maria_share
my_bool (*compare_unique)(struct st_maria_info *, MARIA_UNIQUEDEF *, my_bool (*compare_unique)(struct st_maria_info *, MARIA_UNIQUEDEF *,
const uchar *record, MARIA_RECORD_POS pos); const uchar *record, MARIA_RECORD_POS pos);
/* Mapings to read/write the data file */ /* Mapings to read/write the data file */
uint (*file_read)(MARIA_HA *, uchar *, uint, my_off_t, myf);
uint (*file_write)(MARIA_HA *, uchar *, uint, my_off_t, myf);
uint (*file_read)(MARIA_HA *, uchar *, size_t, my_off_t, myf);
uint (*file_write)(MARIA_HA *, const uchar *, size_t, my_off_t, myf);
invalidator_by_filename invalidator; /* query cache invalidator */ invalidator_by_filename invalidator; /* query cache invalidator */
ulong this_process; /* processid */ ulong this_process; /* processid */
ulong last_process; /* For table-change-check */ ulong last_process; /* For table-change-check */
@ -864,27 +864,27 @@ extern uint _ma_save_pack_length(uint version, uchar * block_buff,
ulong length); ulong length);
extern uint _ma_calc_pack_length(uint version, ulong length); extern uint _ma_calc_pack_length(uint version, ulong length);
extern ulong _ma_calc_blob_length(uint length, const uchar *pos); extern ulong _ma_calc_blob_length(uint length, const uchar *pos);
extern uint _ma_mmap_pread(MARIA_HA *info, uchar *Buffer,
uint Count, my_off_t offset, myf MyFlags);
extern uint _ma_mmap_pwrite(MARIA_HA *info, uchar *Buffer,
uint Count, my_off_t offset, myf MyFlags);
extern uint _ma_nommap_pread(MARIA_HA *info, uchar *Buffer,
uint Count, my_off_t offset, myf MyFlags);
extern uint _ma_nommap_pwrite(MARIA_HA *info, uchar *Buffer,
uint Count, my_off_t offset, myf MyFlags);
extern size_t _ma_mmap_pread(MARIA_HA *info, uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags);
extern size_t _ma_mmap_pwrite(MARIA_HA *info, const uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags);
extern size_t _ma_nommap_pread(MARIA_HA *info, uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags);
extern size_t _ma_nommap_pwrite(MARIA_HA *info, const uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags);
uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite); uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite);
uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite); uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite);
uint _ma_state_info_read_dsk(File file, MARIA_STATE_INFO *state); uint _ma_state_info_read_dsk(File file, MARIA_STATE_INFO *state);
uint _ma_base_info_write(File file, MARIA_BASE_INFO *base); uint _ma_base_info_write(File file, MARIA_BASE_INFO *base);
int _ma_keyseg_write(File file, const HA_KEYSEG *keyseg); int _ma_keyseg_write(File file, const HA_KEYSEG *keyseg);
char *_ma_keyseg_read(char *ptr, HA_KEYSEG *keyseg);
uchar *_ma_keyseg_read(uchar *ptr, HA_KEYSEG *keyseg);
uint _ma_keydef_write(File file, MARIA_KEYDEF *keydef); uint _ma_keydef_write(File file, MARIA_KEYDEF *keydef);
char *_ma_keydef_read(char *ptr, MARIA_KEYDEF *keydef);
uchar *_ma_keydef_read(uchar *ptr, MARIA_KEYDEF *keydef);
uint _ma_uniquedef_write(File file, MARIA_UNIQUEDEF *keydef); uint _ma_uniquedef_write(File file, MARIA_UNIQUEDEF *keydef);
char *_ma_uniquedef_read(char *ptr, MARIA_UNIQUEDEF *keydef);
uchar *_ma_uniquedef_read(uchar *ptr, MARIA_UNIQUEDEF *keydef);
uint _ma_columndef_write(File file, MARIA_COLUMNDEF *columndef); uint _ma_columndef_write(File file, MARIA_COLUMNDEF *columndef);
char *_ma_columndef_read(char *ptr, MARIA_COLUMNDEF *columndef);
uchar *_ma_columndef_read(uchar *ptr, MARIA_COLUMNDEF *columndef);
ulong _ma_calc_total_blob_length(MARIA_HA *info, const uchar *record); ulong _ma_calc_total_blob_length(MARIA_HA *info, const uchar *record);
ha_checksum _ma_checksum(MARIA_HA *info, const uchar *buf); ha_checksum _ma_checksum(MARIA_HA *info, const uchar *buf);
ha_checksum _ma_static_checksum(MARIA_HA *info, const uchar *buf); ha_checksum _ma_static_checksum(MARIA_HA *info, const uchar *buf);

6
storage/maria/maria_pack.c

@ -526,14 +526,14 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
{ {
/* Make a new indexfile based on first file in list */ /* Make a new indexfile based on first file in list */
uint length; uint length;
char *buff;
uchar *buff;
strmov(org_name,result_table); /* Fix error messages */ strmov(org_name,result_table); /* Fix error messages */
VOID(fn_format(new_name,result_table,"",MARIA_NAME_IEXT,2)); VOID(fn_format(new_name,result_table,"",MARIA_NAME_IEXT,2));
if ((join_isam_file=my_create(new_name,0,tmpfile_createflag,MYF(MY_WME))) if ((join_isam_file=my_create(new_name,0,tmpfile_createflag,MYF(MY_WME)))
< 0) < 0)
goto err; goto err;
length=(uint) share->base.keystart; length=(uint) share->base.keystart;
if (!(buff=my_malloc(length,MYF(MY_WME))))
if (!(buff= (uchar*) my_malloc(length,MYF(MY_WME))))
goto err; goto err;
if (my_pread(share->kfile.file, buff, length, 0L, MYF(MY_WME | MY_NABP)) || if (my_pread(share->kfile.file, buff, length, 0L, MYF(MY_WME | MY_NABP)) ||
my_write(join_isam_file,buff,length, my_write(join_isam_file,buff,length,
@ -657,7 +657,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
new_length=file_buffer.pos_in_file; new_length=file_buffer.pos_in_file;
if (!error && !test_only) if (!error && !test_only)
{ {
char buff[MEMMAP_EXTRA_MARGIN]; /* End marginal for memmap */
uchar buff[MEMMAP_EXTRA_MARGIN]; /* End marginal for memmap */
bzero(buff,sizeof(buff)); bzero(buff,sizeof(buff));
error=my_write(file_buffer.file,buff,sizeof(buff), error=my_write(file_buffer.file,buff,sizeof(buff),
MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL)) != 0; MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL)) != 0;

Loading…
Cancel
Save