1342
const message::UpdateHeader &update_header= statement->update_header();
1343
string old_table_name= update_header.table_metadata().table_name();
1345
string current_table_name;
1346
(void) in_table->getShare()->getTableName(current_table_name);
1347
if (current_table_name.compare(old_table_name))
1349
finalizeStatementMessage(*statement, in_session);
1350
statement= in_session->getStatementMessage();
1342
if (useExistingUpdateHeader(*statement, in_table, old_record, new_record))
1354
1344
/* carry forward the existing segment id */
1355
1345
const message::UpdateData ¤t_data= statement->update_data();
1356
1346
*next_segment_id= current_data.segment_id();
1350
finalizeStatementMessage(*statement, in_session);
1351
statement= in_session->getStatementMessage();
1380
1375
return *statement;
1378
bool TransactionServices::useExistingUpdateHeader(message::Statement &statement,
1380
const unsigned char *old_record,
1381
const unsigned char *new_record)
1383
const message::UpdateHeader &update_header= statement.update_header();
1384
string old_table_name= update_header.table_metadata().table_name();
1386
string current_table_name;
1387
(void) in_table->getShare()->getTableName(current_table_name);
1388
if (current_table_name.compare(old_table_name))
1394
/* Compare the set fields in the existing UpdateHeader and see if they
1395
* match the updated fields in the new record, if they do not we must
1396
* create a new UpdateHeader
1398
size_t num_set_fields= update_header.set_field_metadata_size();
1400
Field *current_field;
1401
Field **table_fields= in_table->getFields();
1402
in_table->setReadSet();
1404
size_t num_calculated_updated_fields= 0;
1406
while ((current_field= *table_fields++) != NULL)
1408
if (num_calculated_updated_fields > num_set_fields)
1413
if (isFieldUpdated(current_field, in_table, old_record, new_record))
1415
/* check that this field exists in the UpdateHeader record */
1418
for (size_t x= 0; x < num_set_fields; ++x)
1420
const message::FieldMetadata &field_metadata= update_header.set_field_metadata(x);
1421
string name= field_metadata.name();
1422
if (name.compare(current_field->field_name) == 0)
1425
++num_calculated_updated_fields;
1436
if ((num_calculated_updated_fields == num_set_fields) && found)
1383
1447
void TransactionServices::setUpdateHeader(message::Statement &statement,
1384
1448
Session *in_session,
1385
1449
Table *in_table,