Skip to content

Commit

Permalink
Historical record insert place changed (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
midenok authored and kevgs committed Jan 16, 2017
1 parent 608224d commit d55a2ef
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 38 deletions.
4 changes: 2 additions & 2 deletions mysql-test/r/update.result
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,8 @@ x y
5 5000
6 6000
7 7000
8 8000
9 9000
8 8001
9 9001
8 8000
9 9000
DROP TABLE t1;
42 changes: 18 additions & 24 deletions sql/sql_update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -772,22 +772,6 @@ int mysql_update(THD *thd,
store_record(table,record[1]);

vblobs.make_orphans();

if (table->is_with_system_versioning())
{
// Set end time to now()
if (table->get_row_end_field()->set_time())
{
error= 1;
break;
}

if ( (error= insert_rec_for_system_versioning(table, &updated_sys_ver)) )
break;

restore_record(table,record[1]);
}

if (fill_record_n_invoke_before_triggers(thd, table, fields, values, 0,
TRG_EVENT_UPDATE))
break; /* purecov: inspected */
Expand Down Expand Up @@ -859,16 +843,26 @@ int mysql_update(THD *thd,
error= table->file->ha_update_row(table->record[1],
table->record[0]);
}
if (!error || error == HA_ERR_RECORD_IS_THE_SAME)
if (error == HA_ERR_RECORD_IS_THE_SAME)
{
if (error != HA_ERR_RECORD_IS_THE_SAME)
updated++;
else
error= 0;
}
else if (!ignore ||
error= 0;
}
else if (!error)
{
updated++;

if (table->is_with_system_versioning())
{
store_record(table, record[2]);
if ((error = insert_rec_for_system_versioning(table, &updated_sys_ver)))
break;

restore_record(table, record[2]);
}
}
else if (!ignore ||
table->file->is_fatal_error(error, HA_CHECK_ALL))
{
{
/*
If (ignore && error is ignorable) we don't have to
do anything; otherwise...
Expand Down
27 changes: 16 additions & 11 deletions sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3035,25 +3035,30 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
records=0;
if ((db_stat & HA_OPEN_KEYFILE) || (prgflag & DELAYED_OPEN))
records=1;
if (prgflag & (READ_ALL+EXTRA_RECORD))
if (prgflag & (READ_ALL + EXTRA_RECORD))
{
records++;

if (!(record= (uchar*) alloc_root(&outparam->mem_root,
share->rec_buff_length * records)))
goto err; /* purecov: inspected */
if (share->with_system_versioning)
records++;
}

if (records == 0)
{
/* We are probably in hard repair, and the buffers should not be used */
outparam->record[0]= outparam->record[1]= share->default_values;
record= share->default_values;
}
else
{
outparam->record[0]= record;
if (records > 1)
outparam->record[1]= record+ share->rec_buff_length;
else
outparam->record[1]= outparam->record[0]; // Safety
if (!(record= (uchar*) alloc_root(&outparam->mem_root,
share->rec_buff_length * records)))
goto err; /* purecov: inspected */
}

for (i= 0; i < 3;)
{
outparam->record[i]= record;
if (++i < records)
record+= share->rec_buff_length;
}

if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root,
Expand Down
2 changes: 1 addition & 1 deletion sql/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ struct TABLE
uint32 instance; /** Table cache instance this TABLE is belonging to */
THD *in_use; /* Which thread uses this */

uchar *record[2]; /* Pointer to records */
uchar *record[3]; /* Pointer to records */
uchar *write_row_record; /* Used as optimisation in
THD::write_row */
uchar *insert_values; /* used by INSERT ... UPDATE */
Expand Down

0 comments on commit d55a2ef

Please sign in to comment.