Commit 4423b8bf authored by unknown's avatar unknown

Fixes to get maria.test and ps_maria.test to work


storage/maria/ma_blockrec.c:
  Reset undo_lsn if not transactional table
  (Avoids assert() when checking LSN in pagecache code)
storage/maria/ma_create.c:
  Don't convert simple FIXED size tables to BLOCK format.
storage/maria/trnman.c:
  Reset undo_lsn
parent ffe437be
...@@ -568,7 +568,10 @@ void _ma_unpin_all_pages(MARIA_HA *info, LSN undo_lsn) ...@@ -568,7 +568,10 @@ void _ma_unpin_all_pages(MARIA_HA *info, LSN undo_lsn)
DBUG_PRINT("info", ("undo_lsn: %lu", (ulong) undo_lsn)); DBUG_PRINT("info", ("undo_lsn: %lu", (ulong) undo_lsn));
/* True if not disk error */ /* True if not disk error */
DBUG_ASSERT(undo_lsn != 0 || info->s->base.transactional == 0); DBUG_ASSERT(undo_lsn != 0 || !info->s->base.transactional);
if (!info->s->base.transactional)
undo_lsn= 0; /* Avoid assert in key cache */
while (pinned_page-- != page_link) while (pinned_page-- != page_link)
pagecache_unlock(info->s->pagecache, pinned_page->link, pagecache_unlock(info->s->pagecache, pinned_page->link,
...@@ -2623,6 +2626,7 @@ my_bool _ma_delete_block_record(MARIA_HA *info, const byte *record) ...@@ -2623,6 +2626,7 @@ my_bool _ma_delete_block_record(MARIA_HA *info, const byte *record)
if (info->cur_row.extents && free_full_pages(info, &info->cur_row)) if (info->cur_row.extents && free_full_pages(info, &info->cur_row))
goto err; goto err;
if (info->s->base.transactional)
{ {
uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE + PAGE_STORE_SIZE + uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE + PAGE_STORE_SIZE +
DIR_COUNT_SIZE]; DIR_COUNT_SIZE];
......
...@@ -48,7 +48,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -48,7 +48,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
uint length,max_key_length,packed,pack_bytes,pointer,real_length_diff, 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_skip,
base_pos,long_varchar_count,varchar_length, base_pos,long_varchar_count,varchar_length,
unique_key_parts,fulltext_keys,offset; unique_key_parts,fulltext_keys,offset, not_block_record_extra_length;
uint max_field_lengths, extra_header_size; uint max_field_lengths, extra_header_size;
ulong reclength, real_reclength,min_pack_length; ulong reclength, real_reclength,min_pack_length;
char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr; char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr;
...@@ -65,6 +65,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -65,6 +65,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
my_off_t key_root[HA_MAX_POSSIBLE_KEY]; my_off_t key_root[HA_MAX_POSSIBLE_KEY];
MARIA_CREATE_INFO tmp_create_info; MARIA_CREATE_INFO tmp_create_info;
my_bool tmp_table= FALSE; /* cache for presence of HA_OPTION_TMP_TABLE */ my_bool tmp_table= FALSE; /* cache for presence of HA_OPTION_TMP_TABLE */
my_bool forced_packed;
myf sync_dir= MY_SYNC_DIR; myf sync_dir= MY_SYNC_DIR;
DBUG_ENTER("maria_create"); DBUG_ENTER("maria_create");
DBUG_PRINT("enter", ("keys: %u columns: %u uniques: %u flags: %u", DBUG_PRINT("enter", ("keys: %u columns: %u uniques: %u flags: %u",
...@@ -114,9 +115,10 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -114,9 +115,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
/* Start by checking fields and field-types used */ /* Start by checking fields and field-types used */
varchar_length=long_varchar_count=packed= varchar_length=long_varchar_count=packed= not_block_record_extra_length=
pack_reclength= max_field_lengths= 0; pack_reclength= max_field_lengths= 0;
reclength= min_pack_length= ci->null_bytes; reclength= min_pack_length= ci->null_bytes;
forced_packed= 0;
for (column= columndef, end_column= column + columns ; for (column= columndef, end_column= column + columns ;
column != end_column ; column != end_column ;
...@@ -139,6 +141,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -139,6 +141,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
column->empty_bit= (1 << (packed & 7)); column->empty_bit= (1 << (packed & 7));
if (type == FIELD_BLOB) if (type == FIELD_BLOB)
{ {
forced_packed= 1;
packed++; packed++;
share.base.blobs++; share.base.blobs++;
if (pack_reclength != INT_MAX32) if (pack_reclength != INT_MAX32)
...@@ -157,17 +160,16 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -157,17 +160,16 @@ int maria_create(const char *name, enum data_file_type datafile_type,
else if (type == FIELD_SKIP_PRESPACE || else if (type == FIELD_SKIP_PRESPACE ||
type == FIELD_SKIP_ENDSPACE) type == FIELD_SKIP_ENDSPACE)
{ {
forced_packed= 1;
max_field_lengths+= column->length > 255 ? 2 : 1; max_field_lengths+= column->length > 255 ? 2 : 1;
if (datafile_type != BLOCK_RECORD) not_block_record_extra_length++;
min_pack_length++;
packed++; packed++;
} }
else if (type == FIELD_VARCHAR) else if (type == FIELD_VARCHAR)
{ {
varchar_length+= column->length-1; /* Used for min_pack_length */ varchar_length+= column->length-1; /* Used for min_pack_length */
pack_reclength++; pack_reclength++;
if (datafile_type != BLOCK_RECORD) not_block_record_extra_length++;
min_pack_length++;
max_field_lengths++; max_field_lengths++;
packed++; packed++;
column->fill_length= 1; column->fill_length= 1;
...@@ -183,23 +185,47 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -183,23 +185,47 @@ int maria_create(const char *name, enum data_file_type datafile_type,
packed++; packed++;
else else
{ {
if (datafile_type != BLOCK_RECORD || !column->null_bit) if (!column->null_bit)
min_pack_length+= column->length; min_pack_length+= column->length;
else
not_block_record_extra_length+= column->length;
column->empty_pos= 0; column->empty_pos= 0;
column->empty_bit= 0; column->empty_bit= 0;
} }
} }
else /* FIELD_NORMAL */ else /* FIELD_NORMAL */
{ {
if (datafile_type != BLOCK_RECORD || !column->null_bit)
min_pack_length+= column->length;
if (!column->null_bit) if (!column->null_bit)
{ {
min_pack_length+= column->length;
share.base.fixed_not_null_fields++; share.base.fixed_not_null_fields++;
share.base.fixed_not_null_fields_length+= column->length; share.base.fixed_not_null_fields_length+= column->length;
} }
else
not_block_record_extra_length+= column->length;
} }
} }
if (datafile_type == STATIC_RECORD && forced_packed)
{
/* Can't use fixed length records, revert to block records */
datafile_type= BLOCK_RECORD;
}
if (datafile_type == DYNAMIC_RECORD)
options|= HA_OPTION_PACK_RECORD; /* Must use packed records */
if (datafile_type == STATIC_RECORD)
{
/* We can't use checksum with static length rows */
flags&= ~HA_CREATE_CHECKSUM;
options&= ~HA_OPTION_CHECKSUM;
min_pack_length+= varchar_length;
packed= 0;
}
if (datafile_type != BLOCK_RECORD)
min_pack_length+= not_block_record_extra_length;
if ((packed & 7) == 1) if ((packed & 7) == 1)
{ {
/* /*
...@@ -229,18 +255,6 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -229,18 +255,6 @@ int maria_create(const char *name, enum data_file_type datafile_type,
if (pack_reclength != INT_MAX32) if (pack_reclength != INT_MAX32)
pack_reclength+= max_field_lengths + long_varchar_count; pack_reclength+= max_field_lengths + long_varchar_count;
if (packed && datafile_type == STATIC_RECORD)
datafile_type= BLOCK_RECORD;
if (datafile_type == DYNAMIC_RECORD)
options|= HA_OPTION_PACK_RECORD; /* Must use packed records */
if (datafile_type == STATIC_RECORD)
{
/* We can't use checksum with static length rows */
flags&= ~HA_CREATE_CHECKSUM;
options&= ~HA_OPTION_CHECKSUM;
min_pack_length+= varchar_length;
}
if (flags & HA_CREATE_TMP_TABLE) if (flags & HA_CREATE_TMP_TABLE)
{ {
options|= HA_OPTION_TMP_TABLE; options|= HA_OPTION_TMP_TABLE;
......
...@@ -253,7 +253,13 @@ TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond, ...@@ -253,7 +253,13 @@ TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond,
/* Nothing in the pool ? Allocate a new one */ /* Nothing in the pool ? Allocate a new one */
if (!trn) if (!trn)
{ {
trn= (TRN *)my_malloc(sizeof(TRN), MYF(MY_WME)); /*
trn should be completely initalized at create time to allow
one to keep a known state on it.
(Like redo_lns, which is assumed to be 0 at start of row handling
and reset to zero before end of row handling)
*/
trn= (TRN *)my_malloc(sizeof(TRN), MYF(MY_WME | MY_ZEROFILL));
if (unlikely(!trn)) if (unlikely(!trn))
{ {
DBUG_PRINT("info", ("pthread_mutex_unlock LOCK_trn_list")); DBUG_PRINT("info", ("pthread_mutex_unlock LOCK_trn_list"));
...@@ -286,6 +292,7 @@ TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond, ...@@ -286,6 +292,7 @@ TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond,
trn->min_read_from= trn->trid; trn->min_read_from= trn->trid;
trn->commit_trid= 0; trn->commit_trid= 0;
trn->undo_lsn= 0;
trn->locks.mutex= mutex; trn->locks.mutex= mutex;
trn->locks.cond= cond; trn->locks.cond= cond;
......
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