~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/transaction_services.cc

  • Committer: Joe Daly
  • Date: 2010-07-21 02:15:02 UTC
  • mto: (1666.2.2 build)
  • mto: This revision was merged to the branch mainline in revision 1667.
  • Revision ID: skinny.moey@gmail.com-20100721021502-skcl6ghyq0gsc37n
fix a problem with multiple tables being updated in the same transaction these should go into seperate records

Show diffs side-by-side

added added

removed removed

Lines of Context:
1032
1032
                                                                 Table *in_table)
1033
1033
{
1034
1034
  message::Statement *statement= in_session->getStatementMessage();
1035
 
  /*
1036
 
   * We check to see if the current Statement message is of type INSERT.
1037
 
   * If it is not, we finalize the current Statement and ensure a new
1038
 
   * InsertStatement is created.
 
1035
 
 
1036
  /* 
 
1037
   * Check the type for the current Statement message, if it is anything
 
1038
   * other then INSERT we need to call finalize, this will ensure a 
 
1039
   * new InsertStatement is created. If it is of type INSERT check
 
1040
   * what table the INSERT belongs to, if it is a different table
 
1041
   * call finalize, so a new InsertStatement can be created. 
1039
1042
   */
1040
 
  if (statement != NULL &&
1041
 
      statement->type() != message::Statement::INSERT)
 
1043
  if (statement != NULL && statement->type() != message::Statement::INSERT)
1042
1044
  {
1043
1045
    finalizeStatementMessage(*statement, in_session);
1044
1046
    statement= in_session->getStatementMessage();
1045
 
  }
 
1047
  } 
 
1048
  else if (statement != NULL)
 
1049
  {
 
1050
    const message::InsertHeader &insert_header= statement->insert_header();
 
1051
    string old_table_name= insert_header.table_metadata().table_name();
 
1052
     
 
1053
    string current_table_name;
 
1054
    (void) in_table->getShare()->getTableName(current_table_name);
 
1055
    if (current_table_name.compare(old_table_name))
 
1056
    {
 
1057
      finalizeStatementMessage(*statement, in_session);
 
1058
      statement= in_session->getStatementMessage();
 
1059
    }
 
1060
  } 
1046
1061
 
1047
1062
  if (statement == NULL)
1048
1063
  {
1148
1163
                                                            const unsigned char *new_record)
1149
1164
{
1150
1165
  message::Statement *statement= in_session->getStatementMessage();
 
1166
 
1151
1167
  /*
1152
 
   * We check to see if the current Statement message is of type UPDATE.
1153
 
   * If it is not, we finalize the current Statement and ensure a new
1154
 
   * UpdateStatement is created.
 
1168
   * Check the type for the current Statement message, if it is anything
 
1169
   * other then UPDATE we need to call finalize, this will ensure a
 
1170
   * new UpdateStatement is created. If it is of type UPDATE check
 
1171
   * what table the UPDATE belongs to, if it is a different table
 
1172
   * call finalize, so a new UpdateStatement can be created.
1155
1173
   */
1156
 
  if (statement != NULL &&
1157
 
      statement->type() != message::Statement::UPDATE)
 
1174
  if (statement != NULL && statement->type() != message::Statement::UPDATE)
1158
1175
  {
1159
1176
    finalizeStatementMessage(*statement, in_session);
1160
1177
    statement= in_session->getStatementMessage();
1161
1178
  }
 
1179
  else if (statement != NULL)
 
1180
  {
 
1181
    const message::UpdateHeader &update_header= statement->update_header();
 
1182
    string old_table_name= update_header.table_metadata().table_name();
 
1183
 
 
1184
    string current_table_name;
 
1185
    (void) in_table->getShare()->getTableName(current_table_name);
 
1186
    if (current_table_name.compare(old_table_name))
 
1187
    {
 
1188
      finalizeStatementMessage(*statement, in_session);
 
1189
      statement= in_session->getStatementMessage();
 
1190
    }
 
1191
  }
1162
1192
 
1163
1193
  if (statement == NULL)
1164
1194
  {
1330
1360
                                                            Table *in_table)
1331
1361
{
1332
1362
  message::Statement *statement= in_session->getStatementMessage();
 
1363
 
1333
1364
  /*
1334
 
   * We check to see if the current Statement message is of type DELETE.
1335
 
   * If it is not, we finalize the current Statement and ensure a new
1336
 
   * DeleteStatement is created.
 
1365
   * Check the type for the current Statement message, if it is anything
 
1366
   * other then DELETE we need to call finalize, this will ensure a
 
1367
   * new DeleteStatement is created. If it is of type DELETE check
 
1368
   * what table the DELETE belongs to, if it is a different table
 
1369
   * call finalize, so a new DeleteStatement can be created.
1337
1370
   */
1338
 
  if (statement != NULL &&
1339
 
      statement->type() != message::Statement::DELETE)
 
1371
  if (statement != NULL && statement->type() != message::Statement::DELETE)
1340
1372
  {
1341
1373
    finalizeStatementMessage(*statement, in_session);
1342
1374
    statement= in_session->getStatementMessage();
1343
1375
  }
 
1376
  else if (statement != NULL)
 
1377
  {
 
1378
    const message::DeleteHeader &delete_header= statement->delete_header();
 
1379
    string old_table_name= delete_header.table_metadata().table_name();
 
1380
 
 
1381
    string current_table_name;
 
1382
    (void) in_table->getShare()->getTableName(current_table_name);
 
1383
    if (current_table_name.compare(old_table_name))
 
1384
    {
 
1385
      finalizeStatementMessage(*statement, in_session);
 
1386
      statement= in_session->getStatementMessage();
 
1387
    }
 
1388
  }
1344
1389
 
1345
1390
  if (statement == NULL)
1346
1391
  {