Commit 05b1ea83 authored by unknown's avatar unknown

Added MARIA_SHARE *share to a lot of places to make code simpler

Changed info->s -> share to get more efficent code
Updated arguments to page accessor functions to use MARIA_SHARE * instead of MARIA_HA *.
Tested running tests in quick mode (no balance page on insert and only when critical on delete)
Fixed bug in underflow handling in quick mode
Fixed bug in log handler where it accessed not initialized variable
Fixed bug in log handler where it didn't free mutex in unlikely error condition
Removed double write of page in case of of some underflow conditions
Added DBUG_PRINT in safemutex lock/unlock


dbug/dbug.c:
  Compile without SAFE_MUTEX (to be able to use DBUG_PRINT in safe_mutex code)
  Use calls to get/set my_thread_var->dbug. (Make dbug independent of compile time options for mysys)
include/my_pthread.h:
  Added prototypes for my_thread_var_get_dbug() & my_thread_var_set_dbug()
mysql-test/lib/mtr_report.pl:
  Don't check warnings in log files if we are using --extern
mysys/my_thr_init.c:
  Added my_thread_var_get_dbug() & my_thread_var_set_dbug()
mysys/thr_mutex.c:
  Added DBUG printing of addresses to mutex for lock/unlock
storage/maria/ma_blockrec.c:
  Fixed comment
storage/maria/ma_check.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
storage/maria/ma_close.c:
  Indentation fixes
storage/maria/ma_create.c:
  Calculate min_key_length correctly
storage/maria/ma_dbug.c:
  Indentation fixes
storage/maria/ma_delete.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
  Removed some writing of key pages that underflow (will be written by caller)
  Fixed crashing bug in underflow handling when using quick mode
storage/maria/ma_delete_all.c:
  Indentation fixes
storage/maria/ma_dynrec.c:
  Indentation fixes
storage/maria/ma_extra.c:
  Fixed indentation
  Removed old useless code
  Reset share->changed if we have written state
storage/maria/ma_ft_update.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
storage/maria/ma_info.c:
  Indentation fixes
storage/maria/ma_key_recover.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
storage/maria/ma_locking.c:
  Indentation fixes
storage/maria/ma_loghandler.c:
  Removed wrapper functions translog_mutex_lock and translog_mutex_unlock (safemutex now does same kind of printing)
  Renamed LOGREC_REDO_INSERT_ROW_BLOB to LOGREC_REDO_INSERT_NOT_USED to mark it free
  Fixed some DBUG_PRINT to ensure that convert-dbug-for-diff works
  Fixed bug in translog_flush() that caused log to stop syncing to disk
  Added missing mutex_unlock in case of error
storage/maria/ma_loghandler.h:
  Renamed LOGREC_REDO_INSERT_ROW_BLOB to LOGREC_REDO_INSERT_NOT_USED to mark it free
storage/maria/ma_open.c:
  Indentation fixes
storage/maria/ma_packrec.c:
  Indentation fixes
storage/maria/ma_page.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
  Added check that we never write a key page without content (except in recovery where a key page may temporary be without content)
storage/maria/ma_preload.c:
  Updated arguments to page accessor functions
storage/maria/ma_range.c:
  Updated arguments to page accessor functions
storage/maria/ma_rkey.c:
  Indentation fixes
storage/maria/ma_rprev.c:
  Indentation fixes
storage/maria/ma_rt_index.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
storage/maria/ma_rt_index.h:
  Updated arguments to page accessor functions
storage/maria/ma_rt_key.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
storage/maria/ma_rt_mbr.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
storage/maria/ma_rt_split.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
storage/maria/ma_search.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
storage/maria/ma_sort.c:
  Indentation fixes
storage/maria/ma_statrec.c:
  Indentation fixes
storage/maria/ma_test1.c:
  Added extra undo test
  Flush also keys in -u1, to ensure that the full log is flushed
storage/maria/ma_test2.c:
  Added extra undo test
  Flush also keys in -u1, to ensure that the full log is flushed
storage/maria/ma_test_recovery.expected:
  Updated results
storage/maria/ma_test_recovery:
  Added extra undo test
storage/maria/ma_update.c:
  Indentation fixes
storage/maria/ma_write.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
  Prepare for quick mode for insert (don't balance page)
storage/maria/maria_chk.c:
  Added MARIA_SHARE *share to a lot of places to make code simpler
  info->s -> share
  Updated arguments to page accessor functions
storage/maria/maria_def.h:
  Updated arguments to page accessor functions
parent da3c8790
......@@ -71,7 +71,12 @@
*
*/
/*
We can't have SAFE_MUTEX defined here as this will cause recursion
in pthread_mutex_lock
*/
#undef SAFE_MUTEX
#include <my_global.h>
#include <m_string.h>
#include <errno.h>
......@@ -79,7 +84,6 @@
#include <process.h>
#endif
#ifndef DBUG_OFF
......@@ -322,12 +326,12 @@ static unsigned long Clock(void);
#ifdef THREAD
#include <my_pthread.h>
pthread_mutex_t THR_LOCK_dbug;
static pthread_mutex_t THR_LOCK_dbug;
static CODE_STATE *code_state(void)
{
CODE_STATE *cs=0;
struct st_my_thread_var *tmp;
my_bool error;
if (!init_done)
{
......@@ -338,9 +342,7 @@ static CODE_STATE *code_state(void)
init_done=TRUE;
}
if ((tmp=my_thread_var))
{
if (!(cs=(CODE_STATE *) tmp->dbug))
if (!(cs= (CODE_STATE*) my_thread_var_get_dbug(&error)) && !error)
{
cs=(CODE_STATE*) DbugMalloc(sizeof(*cs));
bzero((uchar*) cs,sizeof(*cs));
......@@ -348,8 +350,7 @@ static CODE_STATE *code_state(void)
cs->func="?func";
cs->file="?file";
cs->stack=&init_settings;
tmp->dbug= (void*) cs;
}
my_thread_var_set_dbug((void*) cs);
}
return cs;
}
......
......@@ -680,6 +680,8 @@ struct st_my_thread_var
};
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
extern void *my_thread_var_get_dbug(my_bool *error);
extern void my_thread_var_set_dbug(void *dbug);
extern uint my_thread_end_wait_time;
#define my_thread_var (_my_thread_var())
#define my_errno my_thread_var->thr_errno
......
......@@ -216,7 +216,7 @@ sub mtr_report_stats ($) {
# the "var/log/*.err" files. We save this info in "var/log/warnings"
# ----------------------------------------------------------------------
if ( ! $::glob_use_running_server )
if ( ! $::glob_use_running_server && !$::opt_extern)
{
# Save and report if there was any fatal warnings/errors in err logs
......
......@@ -347,6 +347,9 @@ void my_thread_end(void)
tmp->init= 0;
#endif
#if !defined(__WIN__) || defined(USE_TLS)
pthread_setspecific(THR_KEY_mysys,0);
#endif
/*
Decrement counter for number of running threads. We are using this
in my_thread_global_end() to wait until all threads have called
......@@ -359,10 +362,12 @@ void my_thread_end(void)
pthread_cond_signal(&THR_COND_threads);
pthread_mutex_unlock(&THR_LOCK_threads);
}
/* The following free has to be done, even if my_thread_var() is 0 */
else
{
#if !defined(__WIN__) || defined(USE_TLS)
pthread_setspecific(THR_KEY_mysys,0);
#endif
}
}
struct st_my_thread_var *_my_thread_var(void)
......@@ -380,6 +385,28 @@ struct st_my_thread_var *_my_thread_var(void)
return tmp;
}
extern void *my_thread_var_get_dbug(my_bool *error)
{
struct st_my_thread_var *tmp=
my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
my_bool tmp_error;
if (!error)
error= &tmp_error;
if (tmp)
{
*error= 0;
return tmp->dbug;
}
*error= 1; /* no THR_KEY_mysys */
return (void*) 0;
}
extern void my_thread_var_set_dbug(void *dbug)
{
struct st_my_thread_var *tmp= _my_thread_var();
tmp->dbug= dbug;
}
/****************************************************************************
Get name of current thread.
......
......@@ -94,6 +94,10 @@ int safe_mutex_init(safe_mutex_t *mp,
int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
{
int error;
#ifndef DBUG_OFF
if (my_thread_var_get_dbug((my_bool*) 0))
DBUG_PRINT("mutex", ("Locking mutex: 0x%lx", (ulong) mp));
#endif
if (!mp->file)
{
fprintf(stderr,
......@@ -131,6 +135,10 @@ line %d more than 1 time\n", file,line);
mp->file= file;
mp->line=line;
pthread_mutex_unlock(&mp->global);
#ifndef DBUG_OFF
if (my_thread_var_get_dbug((my_bool*) 0))
DBUG_PRINT("mutex", ("mutex: 0x%lx locked", (ulong) mp));
#endif
return error;
}
......@@ -138,6 +146,10 @@ line %d more than 1 time\n", file,line);
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line)
{
int error;
#ifndef DBUG_OFF
if (my_thread_var_get_dbug((my_bool*) 0))
DBUG_PRINT("mutex", ("Unlocking mutex 0x%lx", (ulong) mp));
#endif
pthread_mutex_lock(&mp->global);
if (mp->count == 0)
{
......
This diff is collapsed.
......@@ -26,7 +26,7 @@ int maria_close(register MARIA_HA *info)
{
int error=0,flag;
my_bool share_can_be_freed= FALSE;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_close");
DBUG_PRINT("enter",("base: 0x%lx reopen: %u locks: %u",
(long) info, (uint) share->reopen,
......
......@@ -47,7 +47,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
int errpos,save_errno, create_mode= O_RDWR | O_TRUNC, res;
myf create_flag;
uint length,max_key_length,packed,pack_bytes,pointer,real_length_diff,
key_length,info_length,key_segs,options,min_key_length_skip,
key_length,info_length,key_segs,options,min_key_length,
base_pos,long_varchar_count,varchar_length,
unique_key_parts,fulltext_keys,offset, not_block_record_extra_length;
uint max_field_lengths, extra_header_size, column_nr;
......@@ -396,8 +396,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
for (i=0, keydef=keydefs ; i < keys ; i++ , keydef++)
{
share.state.key_root[i]= HA_OFFSET_ERROR;
min_key_length_skip=length=real_length_diff=0;
key_length=pointer;
length= real_length_diff= 0;
min_key_length= key_length= pointer;
if (keydef->flag & HA_SPATIAL)
{
#ifdef HAVE_SPATIAL
......@@ -431,7 +431,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
keydef->keysegs+=sp_segs;
key_length+=SPLEN*sp_segs;
length++; /* At least one length uchar */
min_key_length_skip+=SPLEN*2*SPDIMS;
min_key_length++;
#else
my_errno= HA_ERR_UNSUPPORTED;
goto err_no_lock;
......@@ -467,7 +467,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
fulltext_keys++;
key_length+= HA_FT_MAXBYTELEN+HA_FT_WLEN;
length++; /* At least one length uchar */
min_key_length_skip+=HA_FT_MAXBYTELEN;
min_key_length+= 1 + HA_FT_WLEN;
real_length_diff=HA_FT_MAXBYTELEN-FT_MAX_WORD_LEN_FOR_SORT;
}
else
......@@ -536,35 +536,44 @@ int maria_create(const char *name, enum data_file_type datafile_type,
}
if (keyseg->flag & HA_SPACE_PACK)
{
DBUG_ASSERT(!(keyseg->flag & HA_VAR_LENGTH_PART));
DBUG_ASSERT(!(keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART)));
keydef->flag |= HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY;
options|=HA_OPTION_PACK_KEYS; /* Using packed keys */
length++; /* At least one length uchar */
min_key_length_skip+=keyseg->length;
min_key_length++;
key_length+= keyseg->length;
if (keyseg->length >= 255)
{ /* prefix may be 3 bytes */
min_key_length_skip+=2;
length+=2;
{
/* prefix may be 3 bytes */
length+= 2;
}
}
if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
else if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
{
DBUG_ASSERT(!test_all_bits(keyseg->flag,
(HA_VAR_LENGTH_PART | HA_BLOB_PART)));
keydef->flag|=HA_VAR_LENGTH_KEY;
length++; /* At least one length uchar */
min_key_length++;
options|=HA_OPTION_PACK_KEYS; /* Using packed keys */
min_key_length_skip+=keyseg->length;
key_length+= keyseg->length;
if (keyseg->length >= 255)
{ /* prefix may be 3 bytes */
min_key_length_skip+=2;
length+=2;
{
/* prefix may be 3 bytes */
length+= 2;
}
}
else
{
key_length+= keyseg->length;
if (!keyseg->null_bit)
min_key_length+= keyseg->length;
}
if (keyseg->null_bit)
{
key_length++;
/* min key part is 1 byte */
min_key_length++;
options|=HA_OPTION_PACK_KEYS;
keyseg->flag|=HA_NULL_PART;
keydef->flag|=HA_VAR_LENGTH_KEY | HA_NULL_PART_KEY;
......@@ -598,7 +607,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
}
keydef->block_length= maria_block_size;
keydef->keylength= (uint16) key_length;
keydef->minlength= (uint16) (length-min_key_length_skip);
keydef->minlength= (uint16) min_key_length;
keydef->maxlength= (uint16) length;
if (length > max_key_length)
......
......@@ -177,7 +177,7 @@ my_bool _ma_check_table_is_closed(const char *name, const char *where)
for (pos=maria_open_list ; pos ; pos=pos->next)
{
MARIA_HA *info=(MARIA_HA*) pos->data;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
if (!strcmp(share->unique_file_name,filename))
{
if (share->last_version)
......
This diff is collapsed.
......@@ -31,7 +31,7 @@
int maria_delete_all_rows(MARIA_HA *info)
{
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
my_bool log_record;
DBUG_ENTER("maria_delete_all_rows");
......
......@@ -1671,7 +1671,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info,
uint left_len,b_type;
uchar *to;
MARIA_BLOCK_INFO block_info;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_read_rnd_dynamic_record");
info_read=0;
......
This diff is collapsed.
......@@ -304,9 +304,10 @@ uint _ma_ft_make_key(MARIA_HA *info, uint keynr, uchar *keybuf, FT_WORD *wptr,
uint _ma_ft_convert_to_ft2(MARIA_HA *info, uint keynr, uchar *key)
{
MARIA_SHARE *share= info->s;
my_off_t root;
DYNAMIC_ARRAY *da=info->ft1_to_ft2;
MARIA_KEYDEF *keyinfo=&info->s->ft2_keyinfo;
MARIA_KEYDEF *keyinfo=&share->ft2_keyinfo;
uchar *key_ptr= (uchar*) dynamic_array_ptr(da, 0), *end;
uint length, key_length;
MARIA_PINNED_PAGE tmp_page_link, *page_link= &tmp_page_link;
......@@ -328,10 +329,10 @@ uint _ma_ft_convert_to_ft2(MARIA_HA *info, uint keynr, uchar *key)
}
/* creating pageful of keys */
bzero(info->buff, info->s->keypage_header);
_ma_store_keynr(info, info->buff, keynr);
_ma_store_page_used(info, info->buff, length + info->s->keypage_header);
memcpy(info->buff + info->s->keypage_header, key_ptr, length);
bzero(info->buff, share->keypage_header);
_ma_store_keynr(share, info->buff, keynr);
_ma_store_page_used(share, info->buff, length + share->keypage_header);
memcpy(info->buff + share->keypage_header, key_ptr, length);
info->keyread_buff_used= info->page_changed=1; /* info->buff is used */
if ((root= _ma_new(info, DFLT_INIT_HITS, &page_link)) == HA_OFFSET_ERROR ||
_ma_write_keypage(info, keyinfo, root, page_link->write_lock,
......@@ -349,8 +350,8 @@ uint _ma_ft_convert_to_ft2(MARIA_HA *info, uint keynr, uchar *key)
_ma_dpointer(info, key+key_length+HA_FT_WLEN, root);
DBUG_RETURN(_ma_ck_real_write_btree(info,
info->s->keyinfo+keynr,
share->keyinfo+keynr,
key, 0,
&info->s->state.key_root[keynr],
&share->state.key_root[keynr],
SEARCH_SAME));
}
......@@ -34,7 +34,7 @@ MARIA_RECORD_POS maria_position(MARIA_HA *info)
int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag)
{
MY_STAT state;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_status");
x->recpos= info->cur_row.lastpos;
......
......@@ -258,7 +258,7 @@ my_bool _ma_log_prefix(MARIA_HA *info, my_off_t page,
#ifdef EXTRA_DEBUG_KEY_CHANGES
{
int page_length= _ma_get_page_used(info, buff);
int page_length= _ma_get_page_used(info->s, buff);
ha_checksum crc;
crc= my_checksum(0, buff + LSN_STORE_SIZE, page_length - LSN_STORE_SIZE);
log_pos[0]= KEY_OP_CHECK;
......@@ -442,10 +442,11 @@ my_bool _ma_log_add(MARIA_HA *info, my_off_t page, uchar *buff,
#ifdef EXTRA_DEBUG_KEY_CHANGES
{
MARIA_SHARE *share= info->s;
ha_checksum crc;
uint save_page_length= _ma_get_page_used(info, buff);
uint save_page_length= _ma_get_page_used(share, buff);
uint new_length= buff_length + move_length;
_ma_store_page_used(info, buff, new_length);
_ma_store_page_used(share, buff, new_length);
crc= my_checksum(0, buff + LSN_STORE_SIZE, new_length - LSN_STORE_SIZE);
log_pos[0]= KEY_OP_CHECK;
int2store(log_pos+1, new_length);
......@@ -455,7 +456,7 @@ my_bool _ma_log_add(MARIA_HA *info, my_off_t page, uchar *buff,
log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7;
changed_length+= 7;
translog_parts++;
_ma_store_page_used(info, buff, save_page_length);
_ma_store_page_used(share, buff, save_page_length);
}
#endif
......@@ -635,7 +636,7 @@ uint _ma_apply_redo_index_free_page(MARIA_HA *info,
}
/* Free page */
bzero(buff + LSN_STORE_SIZE, share->keypage_header - LSN_STORE_SIZE);
_ma_store_keynr(info, buff, (uchar) MARIA_DELETE_KEY_NR);
_ma_store_keynr(info->s, buff, (uchar) MARIA_DELETE_KEY_NR);
mi_sizestore(buff + share->keypage_header, old_link);
share->state.changed|= STATE_NOT_SORTED_PAGES;
......@@ -727,7 +728,7 @@ uint _ma_apply_redo_index(MARIA_HA *info,
goto err;
}
_ma_get_used_and_nod(info, buff, page_length, nod_flag);
_ma_get_used_and_nod(share, buff, page_length, nod_flag);
keypage_header= share->keypage_header;
org_page_length= page_length;
DBUG_PRINT("info", ("page_length: %u", page_length));
......@@ -818,7 +819,7 @@ uint _ma_apply_redo_index(MARIA_HA *info,
ha_checksum crc;
check_page_length= uint2korr(header);
crc= uint4korr(header+2);
_ma_store_page_used(info, buff, page_length);
_ma_store_page_used(share, buff, page_length);
DBUG_ASSERT(check_page_length == page_length);
DBUG_ASSERT(crc == (uint32) my_checksum(0, buff + LSN_STORE_SIZE,
page_length- LSN_STORE_SIZE));
......@@ -836,7 +837,7 @@ uint _ma_apply_redo_index(MARIA_HA *info,
DBUG_ASSERT(header == header_end);
/* Write modified page */
_ma_store_page_used(info, buff, page_length);
_ma_store_page_used(share, buff, page_length);
/*
Clean old stuff up. Gives us better compression of we archive things
......
......@@ -28,7 +28,7 @@ int maria_lock_database(MARIA_HA *info, int lock_type)
{
int error;
uint count;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_lock_database");
DBUG_PRINT("enter",("lock_type: %d old lock %d r_locks: %u w_locks: %u "
"global_changed: %d open_count: %u name: '%s'",
......@@ -383,7 +383,7 @@ int _ma_readinfo(register MARIA_HA *info __attribute__ ((unused)),
if (info->lock_type == F_UNLCK)
{
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
if (!share->tot_locks)
{
/* should not be done for transactional tables */
......@@ -471,7 +471,7 @@ int _ma_writeinfo(register MARIA_HA *info, uint operation)
int _ma_test_if_changed(register MARIA_HA *info)
{
#ifdef EXTERNAL_LOCKING
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
if (share->state.process != share->last_process ||
share->state.unique != info->last_unique ||
share->state.update_count != info->last_loop)
......@@ -518,7 +518,7 @@ int _ma_test_if_changed(register MARIA_HA *info)
int _ma_mark_file_changed(MARIA_HA *info)
{
uchar buff[3];
register MARIA_SHARE *share=info->s;
register MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_mark_file_changed");
if (!(share->state.changed & STATE_CHANGED) || ! share->global_changed)
......@@ -556,7 +556,7 @@ int _ma_mark_file_changed(MARIA_HA *info)
int _ma_decrement_open_count(MARIA_HA *info)
{
uchar buff[2];
register MARIA_SHARE *share=info->s;
register MARIA_SHARE *share= info->s;
int lock_error=0,write_error=0;
if (share->global_changed)
{
......
This diff is collapsed.
......@@ -105,7 +105,7 @@ enum translog_record_type
LOGREC_RESERVED_FOR_CHUNKS23= 0,
LOGREC_REDO_INSERT_ROW_HEAD,
LOGREC_REDO_INSERT_ROW_TAIL,
LOGREC_REDO_INSERT_ROW_BLOB,
LOGREC_REDO_NOT_USED, /* Reserver for next tag */
LOGREC_REDO_INSERT_ROW_BLOBS,
LOGREC_REDO_PURGE_ROW_HEAD,
LOGREC_REDO_PURGE_ROW_TAIL,
......
......@@ -64,7 +64,7 @@ MARIA_HA *_ma_test_if_reopen(const char *filename)
for (pos=maria_open_list ; pos ; pos=pos->next)
{
MARIA_HA *info=(MARIA_HA*) pos->data;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
if (!strcmp(share->unique_file_name,filename) && share->last_version)
return info;
}
......
......@@ -774,7 +774,7 @@ int _ma_pack_rec_unpack(register MARIA_HA *info, MARIA_BIT_BUFF *bit_buff,
uchar *end_field;
reg3 MARIA_COLUMNDEF *end;
MARIA_COLUMNDEF *current_field;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_pack_rec_unpack");
if (info->s->base.null_bytes)
......@@ -1349,7 +1349,7 @@ int _ma_read_rnd_pack_record(MARIA_HA *info,
{
File file;
MARIA_BLOCK_INFO block_info;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_read_rnd_pack_record");
if (filepos >= info->state->data_file_length)
......@@ -1544,7 +1544,7 @@ static int _ma_read_rnd_mempack_record(MARIA_HA*, uchar *, MARIA_RECORD_POS,
my_bool _ma_memmap_file(MARIA_HA *info)
{
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_memmap_file");
if (!info->s->file_map)
......@@ -1601,7 +1601,7 @@ static int _ma_read_mempack_record(MARIA_HA *info, uchar *buf,
MARIA_RECORD_POS filepos)
{
MARIA_BLOCK_INFO block_info;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
uchar *pos;
DBUG_ENTER("maria_read_mempack_record");
......@@ -1627,7 +1627,7 @@ static int _ma_read_rnd_mempack_record(MARIA_HA *info,
__attribute__((unused)))
{
MARIA_BLOCK_INFO block_info;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
uchar *pos,*start;
DBUG_ENTER("_ma_read_rnd_mempack_record");
......
......@@ -30,14 +30,15 @@ uchar *_ma_fetch_keypage(register MARIA_HA *info,
{
uchar *tmp;
uint page_size;
uint block_size= info->s->block_size;
MARIA_PINNED_PAGE page_link;
MARIA_SHARE *share= info->s;
uint block_size= share->block_size;
DBUG_ENTER("_ma_fetch_keypage");
DBUG_PRINT("enter",("page: %ld", (long) page));
tmp= pagecache_read(info->s->pagecache, &info->s->kfile,
tmp= pagecache_read(share->pagecache, &share->kfile,
page / block_size, level, buff,
info->s->page_type, lock, &page_link.link);
share->page_type, lock, &page_link.link);
if (lock != PAGECACHE_LOCK_LEFT_UNLOCKED)
{
......@@ -56,22 +57,22 @@ uchar *_ma_fetch_keypage(register MARIA_HA *info,
{
DBUG_PRINT("error",("Got errno: %d from pagecache_read",my_errno));
info->last_keypage=HA_OFFSET_ERROR;
maria_print_error(info->s, HA_ERR_CRASHED);
maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_RETURN(0);
}
info->last_keypage=page;
#ifdef EXTRA_DEBUG
page_size= _ma_get_page_used(info, tmp);
page_size= _ma_get_page_used(share, tmp);
if (page_size < 4 || page_size > block_size ||
_ma_get_keynr(info, tmp) != keyinfo->key_nr)
_ma_get_keynr(share, tmp) != keyinfo->key_nr)
{
DBUG_PRINT("error",("page %lu had wrong page length: %u keynr: %u",
(ulong) page, page_size,
_ma_get_keynr(info, tmp)));
_ma_get_keynr(share, tmp)));
DBUG_DUMP("page", (char*) tmp, page_size);
info->last_keypage = HA_OFFSET_ERROR;
maria_print_error(info->s, HA_ERR_CRASHED);
maria_print_error(share, HA_ERR_CRASHED);
my_errno= HA_ERR_CRASHED;
tmp= 0;
}
......@@ -86,30 +87,38 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
my_off_t page, enum pagecache_page_lock lock,
int level, uchar *buff)
{
uint block_size= info->s->block_size;
MARIA_SHARE *share= info->s;
MARIA_PINNED_PAGE page_link;
uint block_size= share->block_size;
int res;
DBUG_ENTER("_ma_write_keypage");
#ifdef EXTRA_DEBUG /* Safety check */
if (page < info->s->base.keystart ||
{
uint page_length, nod;
_ma_get_used_and_nod(share, buff, page_length, nod);
if (page < share->base.keystart ||
page+block_size > info->state->key_file_length ||
(page & (MARIA_MIN_KEY_BLOCK_LENGTH-1)))
{
DBUG_PRINT("error",("Trying to write inside key status region: "
"key_start: %lu length: %lu page: %lu",
(long) info->s->base.keystart,
(long) share->base.keystart,
(long) info->state->key_file_length,
(long) page));
my_errno=EINVAL;
DBUG_ASSERT(0);
DBUG_RETURN((-1));
}
DBUG_PRINT("page",("write page at: %lu",(long) page));
DBUG_DUMP("buff", buff,_ma_get_page_used(info, buff));
DBUG_DUMP("buff", buff, page_length);
DBUG_ASSERT(page_length >= share->keypage_header + nod +
keyinfo->minlength || maria_in_recovery);
}
#endif
/* Verify that keynr is correct */
DBUG_ASSERT(_ma_get_keynr(info, buff) == keyinfo->key_nr);
DBUG_ASSERT(_ma_get_keynr(share, buff) == keyinfo->key_nr);
#if defined(EXTRA_DEBUG) && defined(HAVE_purify)
{
......@@ -121,19 +130,19 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
#ifdef IDENTICAL_PAGES_AFTER_RECOVERY
{
uint length= _ma_get_page_used(info, buff);
uint length= _ma_get_page_used(share, buff);
DBUG_ASSERT(length <= block_size - KEYPAGE_CHECKSUM_SIZE);
bzero(buff + length, block_size - length);
}
#endif
DBUG_ASSERT(info->s->pagecache->block_size == block_size);
if (!(info->s->options & HA_OPTION_PAGE_CHECKSUM))
DBUG_ASSERT(share->pagecache->block_size == block_size);
if (!(share->options & HA_OPTION_PAGE_CHECKSUM))
bfill(buff + block_size - KEYPAGE_CHECKSUM_SIZE,
KEYPAGE_CHECKSUM_SIZE, (uchar) 255);
res= pagecache_write(info->s->pagecache,
&info->s->kfile, page / block_size,
level, buff, info->s->page_type,
res= pagecache_write(share->pagecache,
&share->kfile, page / block_size,
level, buff, share->page_type,
lock,
lock == PAGECACHE_LOCK_LEFT_WRITELOCKED ?
PAGECACHE_PIN_LEFT_PINNED :
......@@ -191,11 +200,11 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read)
share->current_key_del= pos;
page_no= pos / block_size;
bzero(buff, share->keypage_header);
_ma_store_keynr(info, buff, (uchar) MARIA_DELETE_KEY_NR);
_ma_store_keynr(share, buff, (uchar) MARIA_DELETE_KEY_NR);
mi_sizestore(buff + share->keypage_header, old_link);
share->state.changed|= STATE_NOT_SORTED_PAGES;
if (info->s->now_transactional)
if (share->now_transactional)
{
LSN lsn;
uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE * 2];
......@@ -207,7 +216,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read)
/* Store link to next unused page (the link that is written to page) */
page= (old_link == HA_OFFSET_ERROR ? IMPOSSIBLE_PAGE_NO :
old_link / info->s->block_size);
old_link / block_size);
page_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE, page);
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
......@@ -315,7 +324,7 @@ my_off_t _ma_new(register MARIA_HA *info, int level,
else
{
share->current_key_del= mi_sizekorr(buff+share->keypage_header);
DBUG_ASSERT(share->current_key_del != info->s->state.key_del &&
DBUG_ASSERT(share->current_key_del != share->state.key_del &&
share->current_key_del);
}
......
......@@ -73,8 +73,8 @@ int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves)
for (end= buff + length ; buff < end ; buff+= block_length)
{
uint keynr= _ma_get_keynr(info, buff);
if ((ignore_leaves && !_ma_test_if_nod(info, buff)) ||
uint keynr= _ma_get_keynr(share, buff);
if ((ignore_leaves && !_ma_test_if_nod(share, buff)) ||
keynr == MARIA_DELETE_KEY_NR ||
!(key_map & ((ulonglong) 1 << keynr)))
{
......
......@@ -217,7 +217,7 @@ static double _ma_search_pos(register MARIA_HA *info,
goto err;
flag=(*keyinfo->bin_search)(info, keyinfo, buff, key, key_len, nextflag,
&keypos,info->lastkey, &after_key);
nod_flag=_ma_test_if_nod(info, buff);
nod_flag=_ma_test_if_nod(info->s, buff);
keynr= _ma_keynr(info,keyinfo,buff,keypos,&max_keynr);
if (flag)
......@@ -272,7 +272,7 @@ static uint _ma_keynr(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uint nod_flag, used_length, keynr, max_key;
uchar t_buff[HA_MAX_KEY_BUFF],*end;
_ma_get_used_and_nod(info, page, used_length, nod_flag);
_ma_get_used_and_nod(info->s, page, used_length, nod_flag);
end= page+ used_length;
page+= info->s->keypage_header + nod_flag;
......
......@@ -25,7 +25,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key,
key_part_map keypart_map, enum ha_rkey_function search_flag)
{
uchar *key_buff;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
MARIA_KEYDEF *keyinfo;
HA_KEYSEG *last_used_keyseg;
uint pack_key_length, use_key_length, nextflag;
......
......@@ -26,7 +26,7 @@ int maria_rprev(MARIA_HA *info, uchar *buf, int inx)
{
int error,changed;
register uint flag;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_rprev");
if ((inx = _ma_check_index(info,inx)) < 0)
......
This diff is collapsed.
......@@ -19,10 +19,10 @@
#ifdef HAVE_RTREE_KEYS
#define rt_PAGE_FIRST_KEY(info, page, nod_flag) (page + info->s->keypage_header + nod_flag)
#define rt_PAGE_NEXT_KEY(key, key_length, nod_flag) (key + key_length + \
(nod_flag ? nod_flag : info->s->base.rec_reflength))
#define rt_PAGE_END(info, page) (page + _ma_get_page_used(info, page))
#define rt_PAGE_FIRST_KEY(share, page, nod_flag) (page + share->keypage_header + nod_flag)
#define rt_PAGE_NEXT_KEY(share, key, key_length, nod_flag) (key + key_length +\
(nod_flag ? nod_flag : share->base.rec_reflength))
#define rt_PAGE_END(share, page) (page + _ma_get_page_used(share, page))
#define rt_PAGE_MIN_SIZE(block_length) ((uint)(block_length - KEYPAGE_CHECKSUM_SIZE) / 3)
......
......@@ -32,11 +32,12 @@
int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key,
uint key_length, uchar *page_buf, my_off_t *new_page)
{
uint page_size= _ma_get_page_used(info, page_buf);
uint nod_flag= _ma_test_if_nod(info, page_buf);
MARIA_SHARE *share= info->s;
uint page_size= _ma_get_page_used(share, page_buf);
uint nod_flag= _ma_test_if_nod(share, page_buf);
DBUG_ENTER("maria_rtree_add_key");
if (page_size + key_length + info->s->base.rec_reflength <=
if (page_size + key_length + share->base.rec_reflength <=
keyinfo->block_length)
{
/* split won't be necessary */
......@@ -44,7 +45,7 @@ int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key,
{
/* save key */
DBUG_ASSERT(_ma_kpos(nod_flag, key) < info->state->key_file_length);
memcpy(rt_PAGE_END(info, page_buf), key - nod_flag,
memcpy(rt_PAGE_END(share, page_buf), key - nod_flag,
key_length + nod_flag);
page_size+= key_length + nod_flag;
}
......@@ -52,14 +53,14 @@ int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key,
{
/* save key */
DBUG_ASSERT(_ma_dpos(info, nod_flag, key + key_length +
info->s->base.rec_reflength) <
share->base.rec_reflength) <
info->state->data_file_length +
info->s->base.pack_reclength);
memcpy(rt_PAGE_END(info, page_buf), key, key_length +
info->s->base.rec_reflength);
page_size+= key_length + info->s->base.rec_reflength;
share->base.pack_reclength);
memcpy(rt_PAGE_END(share, page_buf), key, key_length +
share->base.rec_reflength);
page_size+= key_length + share->base.rec_reflength;
}
_ma_store_page_used(info, page_buf, page_size);
_ma_store_page_used(share, page_buf, page_size);
DBUG_RETURN(0);
}
......@@ -75,18 +76,19 @@ int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key,
int maria_rtree_delete_key(MARIA_HA *info, uchar *page_buf, uchar *key,
uint key_length, uint nod_flag)
{
uint16 page_size= _ma_get_page_used(info, page_buf);
MARIA_SHARE *share= info->s;
uint16 page_size= _ma_get_page_used(share, page_buf);
uchar *key_start;
key_start= key - nod_flag;
if (!nod_flag)
key_length+= info->s->base.rec_reflength;
key_length+= share->base.rec_reflength;
memmove(key_start, key + key_length, page_size - key_length -
(key - page_buf));
page_size-= key_length + nod_flag;
_ma_store_page_used(info, page_buf, page_size);
_ma_store_page_used(share, page_buf, page_size);
return 0;
}
......
......@@ -687,13 +687,13 @@ double maria_rtree_perimeter_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
}
#define RT_PAGE_MBR_KORR(type, korr_func, store_func, len) \
#define RT_PAGE_MBR_KORR(share, type, korr_func, store_func, len) \
{ \
type amin, amax, bmin, bmax; \
amin= korr_func(k + inc); \
amax= korr_func(k + inc + len); \
k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag); \
for (; k < last; k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag)) \
k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag); \
for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag)) \
{ \
bmin= korr_func(k + inc); \
bmax= korr_func(k + inc + len); \
......@@ -709,13 +709,13 @@ double maria_rtree_perimeter_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
inc += 2 * len; \
}
#define RT_PAGE_MBR_GET(type, get_func, store_func, len) \
#define RT_PAGE_MBR_GET(share, type, get_func, store_func, len) \
{ \
type amin, amax, bmin, bmax; \
get_func(amin, k + inc); \
get_func(amax, k + inc + len); \
k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag); \
for (; k < last; k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag)) \
k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag); \
for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag)) \
{ \
get_func(bmin, k + inc); \
get_func(bmax, k + inc + len); \
......@@ -737,11 +737,12 @@ double maria_rtree_perimeter_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
int maria_rtree_page_mbr(MARIA_HA *info, HA_KEYSEG *keyseg, uchar *page_buf,
uchar *c, uint key_length)
{
MARIA_SHARE *share= info->s;
uint inc= 0;
uint k_len= key_length;
uint nod_flag= _ma_test_if_nod(info, page_buf);
uint nod_flag= _ma_test_if_nod(share, page_buf);
uchar *k;
uchar *last= rt_PAGE_END(info, page_buf);
uchar *last= rt_PAGE_END(share, page_buf);
for (; (int)key_length > 0; keyseg += 2)
{
......@@ -753,46 +754,46 @@ int maria_rtree_page_mbr(MARIA_HA *info, HA_KEYSEG *keyseg, uchar *page_buf,
return 1;
}
k= rt_PAGE_FIRST_KEY(info, page_buf, nod_flag);
k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag);
switch ((enum ha_base_keytype) keyseg->type) {
case HA_KEYTYPE_INT8:
RT_PAGE_MBR_KORR(int8, mi_sint1korr, mi_int1store, 1);
RT_PAGE_MBR_KORR(share, int8, mi_sint1korr, mi_int1store, 1);
break;
case HA_KEYTYPE_BINARY:
RT_PAGE_MBR_KORR(uint8, mi_uint1korr, mi_int1store, 1);
RT_PAGE_MBR_KORR(share, uint8, mi_uint1korr, mi_int1store, 1);
break;
case HA_KEYTYPE_SHORT_INT:
RT_PAGE_MBR_KORR(int16, mi_sint2korr, mi_int2store, 2);
RT_PAGE_MBR_KORR(share, int16, mi_sint2korr, mi_int2store, 2);
break;
case HA_KEYTYPE_USHORT_INT:
RT_PAGE_MBR_KORR(uint16, mi_uint2korr, mi_int2store, 2);
RT_PAGE_MBR_KORR(share, uint16, mi_uint2korr, mi_int2store, 2);
break;
case HA_KEYTYPE_INT24:
RT_PAGE_MBR_KORR(int32, mi_sint3korr, mi_int3store, 3);
RT_PAGE_MBR_KORR(share, int32, mi_sint3korr, mi_int3store, 3);
break;
case HA_KEYTYPE_UINT24:
RT_PAGE_MBR_KORR(uint32, mi_uint3korr, mi_int3store, 3);
RT_PAGE_MBR_KORR(share, uint32, mi_uint3korr, mi_int3store, 3);
break;
case HA_KEYTYPE_LONG_INT:
RT_PAGE_MBR_KORR(int32, mi_sint4korr, mi_int4store, 4);
RT_PAGE_MBR_KORR(share, int32, mi_sint4korr, mi_int4store, 4);
break;
case HA_KEYTYPE_ULONG_INT:
RT_PAGE_MBR_KORR(uint32, mi_uint4korr, mi_int4store, 4);
RT_PAGE_MBR_KORR(share, uint32, mi_uint4korr, mi_int4store, 4);
break;
#ifdef HAVE_LONG_LONG
case HA_KEYTYPE_LONGLONG:
RT_PAGE_MBR_KORR(longlong, mi_sint8korr, mi_int8store, 8);
RT_PAGE_MBR_KORR(share, longlong, mi_sint8korr, mi_int8store, 8);
break;
case HA_KEYTYPE_ULONGLONG:
RT_PAGE_MBR_KORR(ulonglong, mi_uint8korr, mi_int8store, 8);
RT_PAGE_MBR_KORR(share, ulonglong, mi_uint8korr, mi_int8store, 8);
break;
#endif
case HA_KEYTYPE_FLOAT:
RT_PAGE_MBR_GET(float, mi_float4get, mi_float4store, 4);
RT_PAGE_MBR_GET(share, float, mi_float4get, mi_float4store, 4);
break;
case HA_KEYTYPE_DOUBLE:
RT_PAGE_MBR_GET(double, mi_float8get, mi_float8store, 8);
RT_PAGE_MBR_GET(share, double, mi_float8get, mi_float8store, 8);
break;
case HA_KEYTYPE_END:
return 0;
......
......@@ -251,6 +251,7 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uchar *page, uchar *key,
uint key_length, my_off_t *new_page_offs)
{
MARIA_SHARE *share= info->s;
int n1, n2; /* Number of items in groups */
SplitStruct *task;
SplitStruct *cur;
......@@ -262,10 +263,10 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uchar *source_cur, *cur1, *cur2;
uchar *new_page;
int err_code= 0;
uint nod_flag= _ma_test_if_nod(info, page);
uint nod_flag= _ma_test_if_nod(share, page);
uint full_length= key_length + (nod_flag ? nod_flag :
info->s->base.rec_reflength);
int max_keys= ((_ma_get_page_used(info, page) - info->s->keypage_header) /
share->base.rec_reflength);
int max_keys= ((_ma_get_page_used(share, page) - share->keypage_header) /
(full_length));
MARIA_PINNED_PAGE tmp_page_link, *page_link= &tmp_page_link;
DBUG_ENTER("maria_rtree_split_page");
......@@ -283,10 +284,12 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
next_coord= coord_buf;
stop= task + max_keys;
source_cur= rt_PAGE_FIRST_KEY(info, page, nod_flag);
source_cur= rt_PAGE_FIRST_KEY(share, page, nod_flag);
for (cur= task; cur < stop; cur++, source_cur= rt_PAGE_NEXT_KEY(source_cur,
key_length, nod_flag))
for (cur= task;
cur < stop;
cur++, source_cur= rt_PAGE_NEXT_KEY(share, source_cur, key_length,
nod_flag))
{
cur->coords= reserve_coords(&next_coord, n_dim);
cur->key= source_cur;
......@@ -300,7 +303,7 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
old_coord= next_coord;
if (split_maria_rtree_node(task, max_keys + 1,
_ma_get_page_used(info, page) + full_length + 2,
_ma_get_page_used(share, page) + full_length + 2,
full_length,
rt_PAGE_MIN_SIZE(keyinfo->block_length),
2, 2, &next_coord, n_dim))
......@@ -316,8 +319,8 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
}
stop= task + (max_keys + 1);
cur1= rt_PAGE_FIRST_KEY(info, page, nod_flag);
cur2= rt_PAGE_FIRST_KEY(info, new_page, nod_flag);
cur1= rt_PAGE_FIRST_KEY(share, page, nod_flag);
cur2= rt_PAGE_FIRST_KEY(share, new_page, nod_flag);
n1= n2= 0;
for (cur= task; cur < stop; cur++)
......@@ -326,25 +329,25 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (cur->n_node == 1)
{
to= cur1;
cur1= rt_PAGE_NEXT_KEY(cur1, key_length, nod_flag);
cur1= rt_PAGE_NEXT_KEY(share, cur1, key_length, nod_flag);
n1++;
}
else
{
to= cur2;
cur2= rt_PAGE_NEXT_KEY(cur2, key_length, nod_flag);
cur2= rt_PAGE_NEXT_KEY(share, cur2, key_length, nod_flag);
n2++;
}
if (to != cur->key)
memcpy(to - nod_flag, cur->key - nod_flag, full_length);
}
bzero(new_page, info->s->keypage_header);
bzero(new_page, share->keypage_header);
if (nod_flag)
_ma_store_keypage_flag(info, new_page, KEYPAGE_FLAG_ISNOD);
_ma_store_keynr(info, new_page, keyinfo->key_nr);
_ma_store_page_used(info, page, info->s->keypage_header + n1 * full_length)
_ma_store_page_used(info, new_page, info->s->keypage_header +
_ma_store_keypage_flag(share, new_page, KEYPAGE_FLAG_ISNOD);
_ma_store_keynr(share, new_page, keyinfo->key_nr);
_ma_store_page_used(share, page, share->keypage_header + n1 * full_length)
_ma_store_page_used(share, new_page, share->keypage_header +
n2 * full_length);
if ((*new_page_offs= _ma_new(info, DFLT_INIT_HITS, &page_link)) ==
......
......@@ -84,13 +84,13 @@ int _ma_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
DFLT_INIT_HITS, info->keyread_buff,
test(!(nextflag & SEARCH_SAVE_BUFF)), 0)))
goto err;
DBUG_DUMP("page", buff, _ma_get_page_used(info, buff));
DBUG_DUMP("page", buff, _ma_get_page_used(info->s, buff));
flag=(*keyinfo->bin_search)(info,keyinfo,buff,key,key_len,nextflag,
&keypos,lastkey, &last_key);
if (flag == MARIA_FOUND_WRONG_KEY)
DBUG_RETURN(-1);
_ma_get_used_and_nod(info, buff, used_length, nod_flag);
_ma_get_used_and_nod(info->s, buff, used_length, nod_flag);
maxpos= buff + used_length -1;
if (flag)
......@@ -189,18 +189,21 @@ int _ma_bin_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
int flag;
uint start, mid, end, save_end, totlength, nod_flag, used_length;
uint not_used[2];
MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_bin_search");
LINT_INIT(flag);
_ma_get_used_and_nod(info, page, used_length, nod_flag);
_ma_get_used_and_nod(share, page, used_length, nod_flag);
totlength= keyinfo->keylength + nod_flag;
DBUG_ASSERT(used_length >= share->keypage_header + nod_flag + totlength);
start=0;
mid=1;
save_end= end= ((used_length - nod_flag - info->s->keypage_header) /
save_end= end= ((used_length - nod_flag - share->keypage_header) /
totlength-1);
DBUG_PRINT("test",("page_length: %u end: %u", used_length, end));
page+= info->s->keypage_header + nod_flag;
page+= share->keypage_header + nod_flag;
while (start != end)
{
......@@ -255,6 +258,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uint comp_flag, uchar **ret_pos,
uchar *buff, my_bool *last_key)
{
MARIA_SHARE *share= info->s;
int flag;
uint nod_flag, length, used_length, not_used[2];
uchar t_buff[HA_MAX_KEY_BUFF], *end;
......@@ -263,9 +267,9 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
LINT_INIT(flag);
LINT_INIT(length);
_ma_get_used_and_nod(info, page, used_length, nod_flag);
_ma_get_used_and_nod(share, page, used_length, nod_flag);
end= page + used_length;
page+= info->s->keypage_header + nod_flag;
page+= share->keypage_header + nod_flag;
*ret_pos= (uchar*) page;
t_buff[0]=0; /* Avoid bugs */
while (page < end)
......@@ -273,7 +277,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,t_buff);
if (length == 0 || page > end)
{
maria_print_error(info->s, HA_ERR_CRASHED);
maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_PRINT("error",
("Found wrong key: length: %u page: 0x%lx end: 0x%lx",
......@@ -303,6 +307,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uint nextflag, uchar **ret_pos, uchar *buff,
my_bool *last_key)
{
MARIA_SHARE *share= info->s;
/*
my_flag is raw comparison result to be changed according to
SEARCH_NO_FIND,SEARCH_LAST and HA_REVERSE_SORT flags.
......@@ -330,9 +335,9 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
LINT_INIT(saved_vseg);
t_buff[0]=0; /* Avoid bugs */
_ma_get_used_and_nod(info, page, used_length, nod_flag);
_ma_get_used_and_nod(share, page, used_length, nod_flag);
end= page + used_length;
page+= info->s->keypage_header + nod_flag;
page+= share->keypage_header + nod_flag;
*ret_pos= page;
kseg= key;
......@@ -434,7 +439,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (page > end)
{
maria_print_error(info->s, HA_ERR_CRASHED);
maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_PRINT("error",
("Found wrong key: length: %u page: 0x%lx end: %lx",
......@@ -1112,7 +1117,7 @@ uchar *_ma_get_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page,
uint nod_flag;
DBUG_ENTER("_ma_get_key");
nod_flag=_ma_test_if_nod(info, page);
nod_flag=_ma_test_if_nod(info->s, page);
if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)))
{
bmove((uchar*) key,(uchar*) keypos,keyinfo->keylength+nod_flag);
......@@ -1154,7 +1159,7 @@ static my_bool _ma_get_prev_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uint nod_flag;
DBUG_ENTER("_ma_get_prev_key");
nod_flag=_ma_test_if_nod(info, page);
nod_flag=_ma_test_if_nod(info->s, page);
if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)))
{
*return_key_length=keyinfo->keylength;
......@@ -1200,7 +1205,7 @@ uchar *_ma_get_last_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page,
DBUG_PRINT("enter",("page: 0x%lx endpos: 0x%lx", (long) page,
(long) endpos));
nod_flag=_ma_test_if_nod(info, page);
nod_flag= _ma_test_if_nod(info->s, page);
if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)))
{
lastpos=endpos-keyinfo->keylength-nod_flag;
......@@ -1348,7 +1353,7 @@ int _ma_search_next(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
}
/* Last used buffer is in info->keyread_buff */
nod_flag=_ma_test_if_nod(info, info->keyread_buff);
nod_flag= _ma_test_if_nod(info->s, info->keyread_buff);
if (nextflag & SEARCH_BIGGER) /* Next key */
{
......@@ -1400,6 +1405,7 @@ int _ma_search_first(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
{
uint nod_flag;
uchar *page;
MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_search_first");
if (pos == HA_OFFSET_ERROR)
......@@ -1417,8 +1423,8 @@ int _ma_search_first(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
info->cur_row.lastpos= HA_OFFSET_ERROR;
DBUG_RETURN(-1);
}
nod_flag=_ma_test_if_nod(info, info->keyread_buff);
page= info->keyread_buff + info->s->keypage_header + nod_flag;
nod_flag=_ma_test_if_nod(share, info->keyread_buff);
page= info->keyread_buff + share->keypage_header + nod_flag;
} while ((pos= _ma_kpos(nod_flag,page)) != HA_OFFSET_ERROR);
if (!(info->lastkey_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,
......@@ -1427,7 +1433,7 @@ int _ma_search_first(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
info->int_keypos=page;
info->int_maxpos= (info->keyread_buff +
_ma_get_page_used(info, info->keyread_buff)-1);
_ma_get_page_used(share, info->keyread_buff)-1);
info->int_nod_flag=nod_flag;
info->int_keytree_version=keyinfo->version;
info->last_search_keypage=info->last_keypage;
......@@ -1466,7 +1472,7 @@ int _ma_search_last(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
info->cur_row.lastpos= HA_OFFSET_ERROR;
DBUG_RETURN(-1);
}
_ma_get_used_and_nod(info, buff, used_length, nod_flag);
_ma_get_used_and_nod(info->s, buff, used_length, nod_flag);
end_of_page= buff + used_length;
} while ((pos= _ma_kpos(nod_flag, end_of_page)) != HA_OFFSET_ERROR);
......
......@@ -499,7 +499,7 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param)
int got_error=sort_info->got_error;
uint i;
MARIA_HA *info=sort_info->info;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
MARIA_SORT_PARAM *sinfo;
uchar *mergebuf=0;
DBUG_ENTER("_ma_thr_write_keys");
......
......@@ -208,7 +208,7 @@ int _ma_read_rnd_static_record(MARIA_HA *info, uchar *buf,
{
int locked,error,cache_read;
uint cache_length;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_read_rnd_static_record");
cache_read=0;
......
......@@ -452,8 +452,8 @@ static int run_test(const char *filename)
Flush changed pages go to disk. That will also flush log. Recovery
will skip REDOs and apply UNDOs.
*/
_ma_flush_table_files(file, MARIA_FLUSH_DATA, FLUSH_RELEASE,
FLUSH_RELEASE);
_ma_flush_table_files(file, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
FLUSH_RELEASE, FLUSH_RELEASE);
break;
case 2:
/*
......@@ -469,6 +469,20 @@ static int run_test(const char *filename)
will then do nothing.
*/
break;
case 4:
/*
Flush changed data pages go to disk. Changed index pages are not
flushed. Recovery will skip some REDOs and apply UNDOs.
*/
_ma_flush_table_files(file, MARIA_FLUSH_DATA, FLUSH_RELEASE,
FLUSH_RELEASE);
/*
We have to flush log separately as the redo for the last key page
may not be flushed
*/
if (translog_flush(file->trn->undo_lsn))
goto err;
break;
}
printf("Dying on request without maria_commit()/maria_close()\n");
exit(0);
......
......@@ -901,11 +901,11 @@ int main(int argc, char *argv[])
switch (die_in_middle_of_transaction) {
case 1:
/*
Flush changed pages go to disk. That will also flush log. Recovery
will skip REDOs and apply UNDOs.
Flush changed data and index pages go to disk
That will also flush log. Recovery will skip REDOs and apply UNDOs.
*/
_ma_flush_table_files(file, MARIA_FLUSH_DATA, FLUSH_RELEASE,
FLUSH_RELEASE);
_ma_flush_table_files(file, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
FLUSH_RELEASE, FLUSH_RELEASE);
break;
case 2:
/*
......@@ -921,6 +921,20 @@ int main(int argc, char *argv[])
will then do nothing.
*/
break;
case 4:
/*
Flush changed data pages go to disk. Changed index pages are not
flushed. Recovery will skip some REDOs and apply UNDOs.
*/
_ma_flush_table_files(file, MARIA_FLUSH_DATA, FLUSH_RELEASE,
FLUSH_RELEASE);
/*
We have to flush log separately as the redo for the last key page
may not be flushed
*/
if (translog_flush(file->trn->undo_lsn))
goto err;
break;
}
printf("Dying on request without maria_commit()/maria_close()\n");
exit(0);
......
#!/bin/sh
#set -x -v
set -e
silent="-s"
if [ -z "$maria_path" ]
......@@ -121,7 +122,7 @@ for take_checkpoint in "no" "yes"
do
for blobs in "" "-b" # we test table without blobs and then table with blobs
do
for test_undo in 1 2 3
for test_undo in 1 2 3 4
do
# first iteration tests rollback of insert, second tests rollback of delete
set -- "ma_test1 $silent -M -T -c -N $blobs -H1" "--testflag=1" "--testflag=2 --test-undo=" "ma_test1 $silent -M -T -c -N $blobs -H2" "--testflag=3" "--testflag=4 --test-undo=" "ma_test1 $silent -M -T -c -N $blobs -H2 " "--testflag=2" "--testflag=3 --test-undo=" "ma_test2 $silent -L -K -W -P -M -T -c $blobs -H1" "-t1" "-t2 -u"
......@@ -154,7 +155,7 @@ do
rm -f $tmp/maria_log.* $tmp/maria_log_control
cp $maria_path/maria_log* $tmp
if [ $test_undo -lt 3 ]
if [ "$test_undo" != "3" ]
then
apply_log "shouldchangelog" # should undo aborted work
else
......
This diff is collapsed.
......@@ -26,7 +26,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
uchar old_key[HA_MAX_KEY_BUFF],*new_key;
bool auto_key_changed=0;
ulonglong changed;
MARIA_SHARE *share=info->s;
MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_update");
LINT_INIT(new_key);
LINT_INIT(changed);
......
This diff is collapsed.
This diff is collapsed.
......@@ -550,26 +550,26 @@ struct st_maria_handler
TRANSID_SIZE)
#define KEYPAGE_FLAG_ISNOD 1
#define _ma_get_page_used(info,x) \
((uint) mi_uint2korr((x) + (info)->s->keypage_header - KEYPAGE_USED_SIZE))
#define _ma_store_page_used(info,x,y) \
mi_int2store((x) + (info)->s->keypage_header - KEYPAGE_USED_SIZE, (y))
#define _ma_test_if_nod(info,x) \
((_ma_get_keypage_flag(info,x) & KEYPAGE_FLAG_ISNOD) ? (info)->s->base.key_reflength : 0)
#define _ma_get_used_and_nod(info,buff,length,nod) \
#define _ma_get_page_used(share,x) \
((uint) mi_uint2korr((x) + (share)->keypage_header - KEYPAGE_USED_SIZE))
#define _ma_store_page_used(share,x,y) \
mi_int2store((x) + (share)->keypage_header - KEYPAGE_USED_SIZE, (y))
#define _ma_test_if_nod(share,x) \
((_ma_get_keypage_flag(share,x) & KEYPAGE_FLAG_ISNOD) ? (share)->base.key_reflength : 0)
#define _ma_get_used_and_nod(share,buff,length,nod) \
{ \
nod= _ma_test_if_nod((info),(buff)); \
length= _ma_get_page_used((info),(buff)); \
nod= _ma_test_if_nod((share),(buff)); \
length= _ma_get_page_used((share),(buff)); \
}
#define _ma_store_keynr(info, x, nr) x[(info)->s->keypage_header - KEYPAGE_KEYID_SIZE - KEYPAGE_FLAG_SIZE - KEYPAGE_USED_SIZE]= (nr)
#define _ma_get_keynr(info, x) ((uchar) x[(info)->s->keypage_header - KEYPAGE_KEYID_SIZE - KEYPAGE_FLAG_SIZE - KEYPAGE_USED_SIZE])
#define _ma_store_keynr(share, x, nr) x[(share)->keypage_header - KEYPAGE_KEYID_SIZE - KEYPAGE_FLAG_SIZE - KEYPAGE_USED_SIZE]= (nr)
#define _ma_get_keynr(share, x) ((uchar) x[(share)->keypage_header - KEYPAGE_KEYID_SIZE - KEYPAGE_FLAG_SIZE - KEYPAGE_USED_SIZE])
#define _ma_store_transid(buff, transid) \
int6store((buff) + LSN_STORE_SIZE, (transid))
#define _ma_korr_transid(buff) \
uint6korr((buff) + LSN_STORE_SIZE)
#define _ma_get_keypage_flag(info,x) x[(info)->s->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]
#define _ma_store_keypage_flag(info,x,flag) x[(info)->s->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (flag)
#define _ma_get_keypage_flag(share,x) x[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]
#define _ma_store_keypage_flag(share,x,flag) x[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (flag)
#define maria_mark_crashed(x) do{(x)->s->state.changed|= STATE_CRASHED; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment