Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mysql-test/r/update.result
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,8 @@ x y
5 5000
6 6000
7 7000
8 8000
9 9000
8 8001
9 9001
8 8000
9 9000
DROP TABLE t1;
35 changes: 15 additions & 20 deletions sql/sql_update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -775,21 +775,6 @@ int mysql_update(THD *thd,
explain->tracker.on_record_after_where();
store_record(table,record[1]);

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 @@ -861,12 +846,22 @@ 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;
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_DUP_KEY))
Expand Down
27 changes: 16 additions & 11 deletions sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2693,25 +2693,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 @@ -1054,7 +1054,7 @@ struct TABLE
ulonglong tc_time;
Field **field; /* Pointer to fields */

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