Commit d28f23c1 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Fixed bug in INSERT DELAYED

Fixed some problems in SHOW CREATE TABLE
Fixed calculation of checksums in myisamchk
parent a99b7e77
......@@ -46854,6 +46854,9 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.43
@itemize @bullet
@item
Fixed a bug in @code{INSERT DELAYED} and @code{FLUSH TABLES} introduced
in 3.23.42.
@item
Fixed unlikely bug, which returned not matching rows, in SELECT with
many tables and multi-column indexes and 'range' type.
@item
......@@ -937,7 +937,7 @@ static bool add_line(String &buffer,char *line,char *in_string)
{ // mSQL or postgreSQL style command ?
if (!(inchar = (uchar) *++pos))
break; // readline adds one '\'
if (*in_string || inchar == 'N')
if (*in_string || inchar == 'N') // \N is short for NULL
{ // Don't allow commands in string
*out++='\\';
*out++= (char) inchar;
......
......@@ -1194,8 +1194,6 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
param->glob_crc=0;
if (param->testflag & T_CALC_CHECKSUM)
param->calc_checksum=1;
if (!rep_quick)
share->state.checksum=0;
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
for (i=0 ; i < info->s->base.keys ; i++)
......@@ -1290,9 +1288,9 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
else
{
info->state->data_file_length=sort_info->max_pos;
if (param->testflag & T_CALC_CHECKSUM)
share->state.checksum=param->glob_crc;
}
if (param->testflag & T_CALC_CHECKSUM)
share->state.checksum=param->glob_crc;
if (!(param->testflag & T_SILENT))
{
......@@ -1878,8 +1876,6 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
param->glob_crc=0;
if (param->testflag & T_CALC_CHECKSUM)
param->calc_checksum=1;
if (! rep_quick)
share->state.checksum=0;
rec_per_key_part= param->rec_per_key_part;
for (sort_info->key=0 ; sort_info->key < share->base.keys ;
......@@ -1999,7 +1995,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
"Can't change size of datafile, error: %d",
my_errno);
}
else if (param->testflag & T_CALC_CHECKSUM)
if (param->testflag & T_CALC_CHECKSUM)
share->state.checksum=param->glob_crc;
if (my_chsize(share->kfile,info->state->key_file_length,MYF(0)))
......@@ -2478,7 +2474,7 @@ int sort_write_record(SORT_INFO *sort_info)
DBUG_RETURN(1);
}
sort_info->filepos+=share->base.pack_reclength;
info->s->state.checksum+=mi_static_checksum(info, sort_info->record);
/* sort_info->param->glob_crc+=mi_static_checksum(info, sort_info->record); */
break;
case DYNAMIC_RECORD:
if (! info->blobs)
......@@ -2502,7 +2498,7 @@ int sort_write_record(SORT_INFO *sort_info)
}
info->checksum=mi_checksum(info,sort_info->record);
reclength=_mi_rec_pack(info,from,sort_info->record);
info->s->state.checksum+=info->checksum;
/* sort_info->param->glob_crc+=info->checksum; */
block_length=reclength+ 3 + test(reclength >= (65520-3));
if (block_length < share->base.min_block_length)
block_length=share->base.min_block_length;
......@@ -2516,7 +2512,7 @@ int sort_write_record(SORT_INFO *sort_info)
DBUG_RETURN(1);
}
sort_info->filepos+=block_length;
info->s->state.checksum+=info->checksum;
/* sort_info->param->glob_crc+=info->checksum; */
break;
case COMPRESSED_RECORD:
reclength=info->packed_length;
......@@ -2529,7 +2525,7 @@ int sort_write_record(SORT_INFO *sort_info)
mi_check_print_error(param,"%d when writing to datafile",my_errno);
DBUG_RETURN(1);
}
info->s->state.checksum+=info->checksum;
/* sort_info->param->glob_crc+=info->checksum; */
sort_info->filepos+=reclength+length;
break;
}
......@@ -2746,9 +2742,9 @@ static int sort_delete_record(MI_CHECK *param)
DBUG_RETURN(1);
}
}
if (info->s->calc_checksum)
info->s->state.checksum-=(*info->s->calc_checksum)(info,
sort_info->record);
if (param->calc_checksum)
param->glob_crc-=(*info->s->calc_checksum)(info,
sort_info->record);
}
error=flush_io_cache(&info->rec_cache) || (*info->s->delete_record)(info);
info->dfile=old_file; /* restore actual value */
......
......@@ -841,6 +841,7 @@ void kill_delayed_threads(void)
delayed_insert *tmp;
while ((tmp=it++))
{
/* Ensure that the thread doesn't kill itself while we are looking at it */
pthread_mutex_lock(&tmp->mutex);
tmp->thd.killed=1;
if (tmp->thd.mysys_var)
......@@ -848,9 +849,15 @@ void kill_delayed_threads(void)
pthread_mutex_lock(&tmp->thd.mysys_var->mutex);
if (tmp->thd.mysys_var->current_cond)
{
pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
/*
We need the following test because the main mutex may be locked
in handle_delayed_insert()
*/
if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
pthread_cond_broadcast(tmp->thd.mysys_var->current_cond);
pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex);
if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex);
}
pthread_mutex_unlock(&tmp->thd.mysys_var->mutex);
}
......
......@@ -390,7 +390,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
if (table->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
ptr=strmov(ptr," delay_key_write=1");
if (table->row_type != ROW_TYPE_DEFAULT)
ptr=strxmov(ptr, " format=", ha_row_type[(uint) table->row_type],
ptr=strxmov(ptr, " row_format=", ha_row_type[(uint) table->row_type],
NullS);
if (file->raid_type)
{
......@@ -910,6 +910,12 @@ store_create_info(THD *thd, TABLE *table, String *packet)
p = longlong10_to_str(table->max_rows, buff, 10);
packet->append(buff, (uint) (p - buff));
}
if (table->avg_row_length)
{
packet->append(" AVG_ROW_LENGTH=");
p=longlong10_to_str(table->avg_row_length, buff,10);
packet->append(buff, (uint) (p - buff));
}
if (table->db_create_options & HA_OPTION_PACK_KEYS)
packet->append(" PACK_KEYS=1", 12);
......@@ -919,6 +925,11 @@ store_create_info(THD *thd, TABLE *table, String *packet)
packet->append(" CHECKSUM=1", 11);
if (table->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
packet->append(" DELAY_KEY_WRITE=1",18);
if (table->row_type != ROW_TYPE_DEFAULT)
{
packet->append(" ROW_FORMAT=",12);
packet->append(ha_row_type[(uint) table->row_type]);
}
table->file->append_create_info(packet);
if (table->comment && table->comment[0])
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment