~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_table.cc

  • Committer: Brian Aker
  • Date: 2010-06-03 09:06:27 UTC
  • mto: (1578.6.10 explain-drizzle)
  • mto: This revision was merged to the branch mainline in revision 1589.
  • Revision ID: brian@gir-2.local-20100603090627-6doyyne204s9wo1r
PAss through the code removing current_session

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
extern pid_t current_pid;
53
53
 
54
 
static int copy_data_between_tables(Table *from,Table *to,
 
54
static int copy_data_between_tables(Session *session,
 
55
                                    Table *from,Table *to,
55
56
                                    List<CreateField> &create,
56
57
                                    bool ignore,
57
58
                                    uint32_t order_num,
685
686
    false  OK
686
687
    true   Error
687
688
*/
688
 
static bool alter_table_manage_keys(Table *table, int indexes_were_disabled,
 
689
static bool alter_table_manage_keys(Session *session,
 
690
                                    Table *table, int indexes_were_disabled,
689
691
                                    enum enum_enable_or_disable keys_onoff)
690
692
{
691
693
  int error= 0;
703
705
 
704
706
  if (error == HA_ERR_WRONG_COMMAND)
705
707
  {
706
 
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
 
708
    push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
707
709
                        ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
708
710
                        table->getMutableShare()->getTableName());
709
711
    error= 0;
962
964
        }
963
965
        else
964
966
        {
965
 
          if (mysql_rename_table(original_engine, original_table_identifier, new_table_identifier))
 
967
          if (mysql_rename_table(*session, original_engine, original_table_identifier, new_table_identifier))
966
968
          {
967
969
            error= -1;
968
970
          }
1046
1048
    /* We don't want update TIMESTAMP fields during ALTER Table. */
1047
1049
    new_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
1048
1050
    new_table->next_number_field= new_table->found_next_number_field;
1049
 
    error= copy_data_between_tables(table,
 
1051
    error= copy_data_between_tables(session,
 
1052
                                    table,
1050
1053
                                    new_table,
1051
1054
                                    alter_info->create_list,
1052
1055
                                    ignore,
1163
1166
 
1164
1167
    new_table_identifier.setPath(new_table_as_temporary.getPath());
1165
1168
 
1166
 
    if (mysql_rename_table(new_engine, new_table_as_temporary, new_table_identifier) != 0)
 
1169
    if (mysql_rename_table(*session, new_engine, new_table_as_temporary, new_table_identifier) != 0)
1167
1170
    {
1168
1171
      return true;
1169
1172
    }
1230
1233
    TableIdentifier original_table_to_drop(original_table_identifier.getSchemaName(),
1231
1234
                                           old_name, message::Table::TEMPORARY);
1232
1235
 
1233
 
    if (mysql_rename_table(original_engine, original_table_identifier, original_table_to_drop))
 
1236
    if (mysql_rename_table(*session, original_engine, original_table_identifier, original_table_to_drop))
1234
1237
    {
1235
1238
      error= 1;
1236
1239
      quick_rm_table(*session, new_table_as_temporary);
1237
1240
    }
1238
1241
    else
1239
1242
    {
1240
 
      if (mysql_rename_table(new_engine, new_table_as_temporary, new_table_identifier) != 0)
 
1243
      if (mysql_rename_table(*session, new_engine, new_table_as_temporary, new_table_identifier) != 0)
1241
1244
      {
1242
1245
        /* Try to get everything back. */
1243
1246
        error= 1;
1246
1249
 
1247
1250
        quick_rm_table(*session, new_table_as_temporary);
1248
1251
 
1249
 
        mysql_rename_table(original_engine, original_table_to_drop, original_table_identifier);
 
1252
        mysql_rename_table(*session, original_engine, original_table_to_drop, original_table_identifier);
1250
1253
      }
1251
1254
      else
1252
1255
      {
1361
1364
/* alter_table */
1362
1365
 
1363
1366
static int
1364
 
copy_data_between_tables(Table *from, Table *to,
 
1367
copy_data_between_tables(Session *session,
 
1368
                         Table *from, Table *to,
1365
1369
                         List<CreateField> &create,
1366
1370
                         bool ignore,
1367
1371
                         uint32_t order_num, order_st *order,
1373
1377
  int error= 0;
1374
1378
  CopyField *copy,*copy_end;
1375
1379
  ulong found_count,delete_count;
1376
 
  Session *session= current_session;
1377
1380
  uint32_t length= 0;
1378
1381
  SORT_FIELD *sortorder;
1379
1382
  ReadRecord info;
1409
1412
    return -1;
1410
1413
 
1411
1414
  /* We need external lock before we can disable/enable keys */
1412
 
  alter_table_manage_keys(to, from->cursor->indexes_are_disabled(), keys_onoff);
 
1415
  alter_table_manage_keys(session, to, from->cursor->indexes_are_disabled(), keys_onoff);
1413
1416
 
1414
1417
  /* We can abort alter table for any table type */
1415
1418
  session->abort_on_warning= !ignore;