~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-08-07 14:14:58 UTC
  • mfrom: (1112 staging)
  • mto: (1115.3.4 captain)
  • mto: This revision was merged to the branch mainline in revision 1117.
  • Revision ID: osullivan.padraig@gmail.com-20090807141458-qrc3don58s304ore
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1900
1900
  if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
1901
1901
  {
1902
1902
    /* Open table and put in temporary table list */
1903
 
    if (!(open_temporary_table(session, path, db, table_name, 1, OTM_OPEN)))
 
1903
    if (!(session->open_temporary_table(path, db, table_name, 1, OTM_OPEN)))
1904
1904
    {
1905
 
      (void) rm_temporary_table(create_info->db_type, path);
 
1905
      (void) session->rm_temporary_table(create_info->db_type, path);
1906
1906
      goto unlock_and_end;
1907
1907
    }
1908
1908
  }
2229
2229
      lex->query_tables_own_last= 0;
2230
2230
      session->no_warnings_for_error= no_warnings_for_error;
2231
2231
 
2232
 
      session->open_and_lock_tables(table);
 
2232
      session->openTablesLock(table);
2233
2233
      session->no_warnings_for_error= 0;
2234
2234
      table->next_global= save_next_global;
2235
2235
      table->next_local= save_next_local;
2419
2419
      session->close_thread_tables();
2420
2420
      if (!result_code) // recreation went ok
2421
2421
      {
2422
 
        if ((table->table= session->open_ltable(table, lock_type)) &&
 
2422
        if ((table->table= session->openTableLock(table, lock_type)) &&
2423
2423
            ((result_code= table->table->file->ha_analyze(session, check_opt)) > 0))
2424
2424
          result_code= 0; // analyze went ok
2425
2425
      }
2611
2611
    we ensure that our statement is properly isolated from all concurrent
2612
2612
    operations which matter.
2613
2613
  */
2614
 
  if (session->open_tables_from_list(&src_table, &not_used, 0))
 
2614
  if (session->open_tables_from_list(&src_table, &not_used))
2615
2615
    return true;
2616
2616
 
2617
2617
  strncpy(src_path, src_table->table->s->path.str, sizeof(src_path));
2710
2710
 
2711
2711
  if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
2712
2712
  {
2713
 
    if (err || !open_temporary_table(session, dst_path, db, table_name, 1,
2714
 
                                     OTM_OPEN))
 
2713
    if (err || !session->open_temporary_table(dst_path, db, table_name, 1, OTM_OPEN))
2715
2714
    {
2716
 
      (void) rm_temporary_table(create_info->db_type,
2717
 
                                dst_path);
 
2715
      (void) session->rm_temporary_table(create_info->db_type, dst_path);
2718
2716
      goto err;     /* purecov: inspected */
2719
2717
    }
2720
2718
  }
2850
2848
   not complain when we lock the table
2851
2849
 */
2852
2850
  session->tablespace_op= true;
2853
 
  if (!(table= session->open_ltable(table_list, TL_WRITE)))
 
2851
  if (!(table= session->openTableLock(table_list, TL_WRITE)))
2854
2852
  {
2855
2853
    session->tablespace_op= false;
2856
2854
    return -1;
3458
3456
    true   Error
3459
3457
*/
3460
3458
 
3461
 
bool mysql_alter_table(Session *session, char *new_db, char *new_name,
 
3459
bool mysql_alter_table(Session *session, 
 
3460
                       char *new_db, 
 
3461
                       char *new_name,
3462
3462
                       HA_CREATE_INFO *create_info,
3463
3463
                       TableList *table_list,
3464
3464
                       Alter_info *alter_info,
3465
 
                       uint32_t order_num, order_st *order, bool ignore)
 
3465
                       uint32_t order_num, 
 
3466
                       order_st *order, 
 
3467
                       bool ignore)
3466
3468
{
3467
 
  Table *table, *new_table=0, *name_lock= 0;;
 
3469
  Table *table;
 
3470
  Table *new_table= NULL;
 
3471
  Table *name_lock= NULL;
3468
3472
  string new_name_str;
3469
3473
  int error= 0;
3470
 
  char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN];
3471
 
  char new_alias_buff[FN_REFLEN], *table_name, *db;
 
3474
  char tmp_name[80];
 
3475
  char old_name[32];
 
3476
  char new_name_buff[FN_REFLEN];
 
3477
  char new_alias_buff[FN_REFLEN];
 
3478
  char *table_name;
 
3479
  char *db;
3472
3480
  const char *new_alias;
3473
3481
  char path[FN_REFLEN];
3474
 
  ha_rows copied= 0,deleted= 0;
3475
 
  StorageEngine *old_db_type, *new_db_type, *save_old_db_type;
 
3482
  ha_rows copied= 0;
 
3483
  ha_rows deleted= 0;
 
3484
  StorageEngine *old_db_type;
 
3485
  StorageEngine *new_db_type;
 
3486
  StorageEngine *save_old_db_type;
3476
3487
  bitset<32> tmp;
3477
3488
 
3478
3489
  new_name_buff[0]= '\0';
3483
3494
    return true;
3484
3495
  }
3485
3496
 
 
3497
  session->set_proc_info("init");
 
3498
 
3486
3499
  /*
3487
3500
    Assign variables table_name, new_name, db, new_db, path
3488
3501
    to simplify further comparisons: we want to see if it's a RENAME
3489
3502
    later just by comparing the pointers, avoiding the need for strcmp.
3490
3503
  */
3491
 
  session->set_proc_info("init");
3492
3504
  table_name= table_list->table_name;
3493
 
  db=table_list->db;
3494
 
  if (!new_db || !my_strcasecmp(table_alias_charset, new_db, db))
 
3505
  db= table_list->db;
 
3506
  if (! new_db || ! my_strcasecmp(table_alias_charset, new_db, db))
3495
3507
    new_db= db;
 
3508
 
 
3509
  if (alter_info->tablespace_op != NO_TABLESPACE_OP)
 
3510
  {
 
3511
    /* DISCARD/IMPORT TABLESPACE is always alone in an ALTER Table */
 
3512
    return mysql_discard_or_import_tablespace(session, table_list, alter_info->tablespace_op);
 
3513
  }
 
3514
 
3496
3515
  build_table_filename(path, sizeof(path), db, table_name, false);
3497
3516
 
3498
 
  /* DISCARD/IMPORT TABLESPACE is always alone in an ALTER Table */
3499
 
  if (alter_info->tablespace_op != NO_TABLESPACE_OP)
3500
 
    /* Conditionally writes to binlog. */
3501
 
    return(mysql_discard_or_import_tablespace(session,table_list,
3502
 
                                              alter_info->tablespace_op));
3503
3517
  ostringstream oss;
3504
3518
  oss << drizzle_data_home << "/" << db << "/" << table_name;
3505
3519
 
3506
3520
  (void) unpack_filename(new_name_buff, oss.str().c_str());
 
3521
 
3507
3522
  /*
3508
3523
    If this is just a rename of a view, short cut to the
3509
3524
    following scenario: 1) lock LOCK_open 2) do a RENAME
3512
3527
    ALTER (sic:) Table .. RENAME works for views. ALTER VIEW is handled
3513
3528
    as an independent branch in mysql_execute_command. The need
3514
3529
    for a copy-paste arose because the main code flow of ALTER Table
3515
 
    ... RENAME tries to use open_ltable, which does not work for views
3516
 
    (open_ltable was never modified to merge table lists of child tables
 
3530
    ... RENAME tries to use openTableLock, which does not work for views
 
3531
    (openTableLock was never modified to merge table lists of child tables
3517
3532
    into the main table list, like open_tables does).
3518
3533
    This code is wrong and will be removed, please do not copy.
3519
3534
  */
3520
3535
 
3521
 
  if (!(table= session->open_ltable(table_list, TL_WRITE_ALLOW_READ)))
 
3536
  if (!(table= session->openTableLock(table_list, TL_WRITE_ALLOW_READ)))
3522
3537
    return true;
 
3538
  
3523
3539
  table->use_all_columns();
3524
3540
 
3525
3541
  /* Check that we are not trying to rename to an existing table */
3530
3546
    new_alias= new_alias_buff;
3531
3547
 
3532
3548
    my_casedn_str(files_charset_info, new_name_buff);
3533
 
    new_alias= new_name;                        // Create lower case table name
 
3549
    new_alias= new_name; // Create lower case table name
3534
3550
    my_casedn_str(files_charset_info, new_name);
3535
3551
 
3536
3552
    if (new_db == db &&
3537
 
        !my_strcasecmp(table_alias_charset, new_name_buff, table_name))
 
3553
        ! my_strcasecmp(table_alias_charset, new_name_buff, table_name))
3538
3554
    {
3539
3555
      /*
3540
 
        Source and destination table names are equal: make later check
3541
 
        easier.
 
3556
        Source and destination table names are equal: make later check
 
3557
        easier.
3542
3558
      */
3543
3559
      new_alias= new_name= table_name;
3544
3560
    }
3546
3562
    {
3547
3563
      if (table->s->tmp_table != NO_TMP_TABLE)
3548
3564
      {
3549
 
        if (session->find_temporary_table(new_db, new_name_buff))
3550
 
        {
3551
 
          my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_name_buff);
3552
 
          return true;
3553
 
        }
 
3565
        if (session->find_temporary_table(new_db, new_name_buff))
 
3566
        {
 
3567
          my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_name_buff);
 
3568
          return true;
 
3569
        }
3554
3570
      }
3555
3571
      else
3556
3572
      {
3557
3573
        if (session->lock_table_name_if_not_cached(new_db, new_name, &name_lock))
3558
3574
          return true;
3559
3575
 
3560
 
        if (!name_lock)
 
3576
        if (! name_lock)
3561
3577
        {
3562
 
          my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
3563
 
          return true;
 
3578
          my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
 
3579
          return true;
3564
3580
        }
3565
3581
 
3566
 
        build_table_filename(new_name_buff, sizeof(new_name_buff),
3567
 
                             new_db, new_name_buff, false);
 
3582
        build_table_filename(new_name_buff, sizeof(new_name_buff), new_db, new_name_buff, false);
 
3583
 
3568
3584
        if (StorageEngine::getTableProto(new_name_buff, NULL) == EEXIST)
3569
 
        {
3570
 
          /* Table will be closed by Session::executeCommand() */
3571
 
          my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
3572
 
          goto err;
3573
 
        }
 
3585
        {
 
3586
          /* Table will be closed by Session::executeCommand() */
 
3587
          my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
 
3588
          goto err;
 
3589
        }
3574
3590
      }
3575
3591
    }
3576
3592
  }
3581
3597
  }
3582
3598
 
3583
3599
  old_db_type= table->s->db_type();
3584
 
  if (!create_info->db_type)
 
3600
  if (! create_info->db_type)
3585
3601
  {
3586
3602
    create_info->db_type= old_db_type;
3587
3603
  }
3588
3604
 
3589
 
  if(table->s->tmp_table != NO_TMP_TABLE)
 
3605
  if (table->s->tmp_table != NO_TMP_TABLE)
3590
3606
    create_info->options|= HA_LEX_CREATE_TMP_TABLE;
3591
3607
 
3592
3608
  if (check_engine(session, new_name, create_info))
3593
3609
    goto err;
 
3610
 
3594
3611
  new_db_type= create_info->db_type;
3595
3612
 
3596
3613
  if (new_db_type != old_db_type &&
3612
3629
  }
3613
3630
 
3614
3631
  session->set_proc_info("setup");
 
3632
  
3615
3633
  /*
3616
3634
   * test if no other bits except ALTER_RENAME and ALTER_KEYS_ONOFF are set
3617
3635
   */
3622
3640
  if (! (tmp.any()) &&
3623
3641
      ! table->s->tmp_table) // no need to touch frm
3624
3642
  {
3625
 
    switch (alter_info->keys_onoff) {
 
3643
    switch (alter_info->keys_onoff)
 
3644
    {
3626
3645
    case LEAVE_AS_IS:
3627
3646
      break;
3628
3647
    case ENABLE:
3653
3672
      error= 0;
3654
3673
      break;
3655
3674
    }
 
3675
 
3656
3676
    if (error == HA_ERR_WRONG_COMMAND)
3657
3677
    {
3658
3678
      error= 0;
3671
3691
      access() and mysql_rename_table() calls.
3672
3692
    */
3673
3693
 
3674
 
    if (!error && (new_name != table_name || new_db != db))
 
3694
    if (error == 0 && 
 
3695
        (new_name != table_name || new_db != db))
3675
3696
    {
3676
3697
      session->set_proc_info("rename");
3677
3698
      /*
3694
3715
      }
3695
3716
      else
3696
3717
      {
3697
 
        *fn_ext(new_name)=0;
 
3718
        *fn_ext(new_name)= 0;
3698
3719
        if (mysql_rename_table(old_db_type, db, table_name, new_db, new_alias, 0))
3699
3720
          error= -1;
3700
 
        else if (0)
3701
 
        {
3702
 
          mysql_rename_table(old_db_type, new_db, new_alias, db,
3703
 
                             table_name, 0);
3704
 
          error= -1;
3705
 
        }
3706
3721
      }
3707
3722
    }
3708
3723
 
3714
3729
                          table->alias);
3715
3730
    }
3716
3731
 
3717
 
    if (!error)
 
3732
    if (error == 0)
3718
3733
    {
3719
3734
      write_bin_log(session, true, session->query, session->query_length);
3720
3735
      session->my_ok();
3721
 
  }
 
3736
    }
3722
3737
    else if (error > 0)
3723
 
  {
 
3738
    {
3724
3739
      table->file->print_error(error, MYF(0));
3725
3740
      error= -1;
3726
3741
    }
 
3742
 
3727
3743
    if (name_lock)
3728
3744
      session->unlink_open_table(name_lock);
 
3745
 
3729
3746
    pthread_mutex_unlock(&LOCK_open);
3730
 
    table_list->table= NULL;                    // For query cache
3731
 
    return(error);
 
3747
    table_list->table= NULL;
 
3748
    return error;
3732
3749
  }
3733
3750
 
3734
3751
  /* We have to do full alter table. */
3735
3752
 
3736
 
    /*
 
3753
  /*
3737
3754
    If the old table had partitions and we are doing ALTER Table ...
3738
3755
    engine= <new_engine>, the new table must preserve the original
3739
3756
    partitioning. That means that the new engine is still the
3747
3764
  new_db_type= create_info->db_type;
3748
3765
 
3749
3766
  if (mysql_prepare_alter_table(session, table, create_info, alter_info))
3750
 
      goto err;
 
3767
    goto err;
3751
3768
 
3752
3769
  set_table_default_charset(create_info, db);
3753
3770
 
3754
3771
  alter_info->build_method= HA_BUILD_OFFLINE;
3755
3772
 
3756
 
  snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%"PRIx64, TMP_FILE_PREFIX,
3757
 
           (unsigned long)current_pid, session->thread_id);
 
3773
  snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%"PRIx64, TMP_FILE_PREFIX, (unsigned long) current_pid, session->thread_id);
 
3774
  
3758
3775
  /* Safety fix for innodb */
3759
3776
  my_casedn_str(files_charset_info, tmp_name);
3760
3777
 
3761
 
 
3762
3778
  /* Create a temporary table with the new format */
3763
 
  if ((error= create_temporary_table(session, table, new_db, tmp_name,
3764
 
                                     create_info, alter_info,
3765
 
                                     !strcmp(db, new_db))))
3766
 
  {
 
3779
  error= create_temporary_table(session, table, new_db, tmp_name, create_info, alter_info, ! strcmp(db, new_db));
 
3780
 
 
3781
  if (error != 0)
3767
3782
    goto err;
3768
 
  }
3769
3783
 
3770
3784
  /* Open the table so we need to copy the data to it. */
3771
3785
  if (table->s->tmp_table)
3776
3790
    tbl.table_name= tmp_name;
3777
3791
 
3778
3792
    /* Table is in session->temporary_tables */
3779
 
    new_table= session->open_table(&tbl, (bool*) 0, DRIZZLE_LOCK_IGNORE_FLUSH);
 
3793
    new_table= session->openTable(&tbl, (bool*) 0, DRIZZLE_LOCK_IGNORE_FLUSH);
3780
3794
  }
3781
3795
  else
3782
3796
  {
3784
3798
    /* table is a normal table: Create temporary table in same directory */
3785
3799
    build_table_filename(tmp_path, sizeof(tmp_path), new_db, tmp_name, true);
3786
3800
    /* Open our intermediate table */
3787
 
    new_table= open_temporary_table(session, tmp_path, new_db, tmp_name, 0, OTM_OPEN);
 
3801
    new_table= session->open_temporary_table(tmp_path, new_db, tmp_name, 0, OTM_OPEN);
3788
3802
  }
3789
3803
 
3790
3804
  if (new_table == NULL)
3792
3806
 
3793
3807
  /* Copy the data if necessary. */
3794
3808
  session->count_cuted_fields= CHECK_FIELD_WARN;        // calc cuted fields
3795
 
  session->cuted_fields=0L;
 
3809
  session->cuted_fields= 0L;
3796
3810
  session->set_proc_info("copy to tmp table");
3797
3811
  copied= deleted= 0;
3798
3812
 
3800
3814
 
3801
3815
  /* We don't want update TIMESTAMP fields during ALTER Table. */
3802
3816
  new_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
3803
 
  new_table->next_number_field=new_table->found_next_number_field;
3804
 
  error= copy_data_between_tables(table, new_table,
3805
 
                                  alter_info->create_list, ignore,
3806
 
                                  order_num, order, &copied, &deleted,
 
3817
  new_table->next_number_field= new_table->found_next_number_field;
 
3818
  error= copy_data_between_tables(table, 
 
3819
                                  new_table,
 
3820
                                  alter_info->create_list, 
 
3821
                                  ignore,
 
3822
                                  order_num, 
 
3823
                                  order, 
 
3824
                                  &copied, 
 
3825
                                  &deleted,
3807
3826
                                  alter_info->keys_onoff,
3808
3827
                                  alter_info->error_if_not_empty);
3809
3828
 
3810
 
  /* We must not ignore bad input! */;
 
3829
  /* We must not ignore bad input! */
3811
3830
  session->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL;
3812
3831
 
3813
3832
  if (table->s->tmp_table != NO_TMP_TABLE)
3815
3834
    /* We changed a temporary table */
3816
3835
    if (error)
3817
3836
      goto err1;
 
3837
 
3818
3838
    /* Close lock if this is a transactional table */
3819
3839
    if (session->lock)
3820
3840
    {
3821
3841
      mysql_unlock_tables(session, session->lock);
3822
 
      session->lock=0;
 
3842
      session->lock= 0;
3823
3843
    }
 
3844
 
3824
3845
    /* Remove link to old table and rename the new one */
3825
3846
    session->close_temporary_table(table, true, true);
 
3847
 
3826
3848
    /* Should pass the 'new_name' as we store table name in the cache */
3827
 
    if (rename_temporary_table(new_table, new_db, new_name))
 
3849
    if (new_table->rename_temporary_table(new_db, new_name))
3828
3850
      goto err1;
 
3851
    
3829
3852
    goto end_temporary;
3830
3853
  }
3831
3854
 
3835
3858
      Close the intermediate table that will be the new table.
3836
3859
      Note that MERGE tables do not have their children attached here.
3837
3860
    */
3838
 
    intern_close_table(new_table);
 
3861
    new_table->intern_close_table();
3839
3862
    free(new_table);
3840
3863
  }
 
3864
 
3841
3865
  pthread_mutex_lock(&LOCK_open); /* ALTER TABLE */
 
3866
  
3842
3867
  if (error)
3843
3868
  {
3844
3869
    quick_rm_table(new_db_type, new_db, tmp_name, true);
3863
3888
  */
3864
3889
 
3865
3890
  session->set_proc_info("rename result table");
3866
 
  snprintf(old_name, sizeof(old_name), "%s2-%lx-%"PRIx64, TMP_FILE_PREFIX,
3867
 
           (unsigned long)current_pid, session->thread_id);
 
3891
 
 
3892
  snprintf(old_name, sizeof(old_name), "%s2-%lx-%"PRIx64, TMP_FILE_PREFIX, (unsigned long) current_pid, session->thread_id);
 
3893
 
3868
3894
  my_casedn_str(files_charset_info, old_name);
3869
3895
 
3870
3896
  wait_while_table_is_used(session, table, HA_EXTRA_PREPARE_FOR_RENAME);
3871
3897
  session->close_data_files_and_morph_locks(db, table_name);
3872
3898
 
3873
 
  error=0;
 
3899
  error= 0;
3874
3900
  save_old_db_type= old_db_type;
3875
3901
 
3876
3902
  /*
3886
3912
    table is renamed and the SE is also changed, then an intermediate table
3887
3913
    is created and the additional call will not take place.
3888
3914
  */
3889
 
  if (mysql_rename_table(old_db_type, db, table_name, db, old_name,
3890
 
                         FN_TO_IS_TMP))
3891
 
  {
3892
 
    error=1;
3893
 
    quick_rm_table(new_db_type, new_db, tmp_name, true);
3894
 
  }
3895
 
  else if (mysql_rename_table(new_db_type, new_db, tmp_name, new_db,
3896
 
                              new_alias, FN_FROM_IS_TMP) || ((new_name != table_name || new_db != db) && 0))
3897
 
  {
3898
 
    /* Try to get everything back. */
 
3915
  if (mysql_rename_table(old_db_type, db, table_name, db, old_name, FN_TO_IS_TMP))
 
3916
  {
3899
3917
    error= 1;
3900
 
    quick_rm_table(new_db_type, new_db, new_alias, false);
3901
3918
    quick_rm_table(new_db_type, new_db, tmp_name, true);
3902
 
    mysql_rename_table(old_db_type, db, old_name, db, table_name,
3903
 
                       FN_FROM_IS_TMP);
 
3919
  }
 
3920
  else
 
3921
  {
 
3922
    if (mysql_rename_table(new_db_type, new_db, tmp_name, new_db, new_alias, FN_FROM_IS_TMP) != 0)
 
3923
    {
 
3924
      /* Try to get everything back. */
 
3925
      error= 1;
 
3926
      quick_rm_table(new_db_type, new_db, new_alias, false);
 
3927
      quick_rm_table(new_db_type, new_db, tmp_name, true);
 
3928
      mysql_rename_table(old_db_type, db, old_name, db, table_name, FN_FROM_IS_TMP);
 
3929
    }
3904
3930
  }
3905
3931
 
3906
3932
  if (error)
3927
3953
    char table_path[FN_REFLEN];
3928
3954
    Table *t_table;
3929
3955
    build_table_filename(table_path, sizeof(table_path), new_db, table_name, false);
3930
 
    t_table= open_temporary_table(session, table_path, new_db, tmp_name, false, OTM_OPEN);
 
3956
    t_table= session->open_temporary_table(table_path, new_db, tmp_name, false, OTM_OPEN);
3931
3957
    if (t_table)
3932
3958
    {
3933
 
      intern_close_table(t_table);
 
3959
      t_table->intern_close_table();
3934
3960
      free(t_table);
3935
3961
    }
3936
3962
    else
3937
 
      errmsg_printf(ERRMSG_LVL_WARN,
3938
 
                    _("Could not open table %s.%s after rename\n"),
3939
 
                    new_db,table_name);
 
3963
      errmsg_printf(ERRMSG_LVL_WARN, _("Could not open table %s.%s after rename\n"), new_db, table_name);
 
3964
 
3940
3965
    ha_flush_logs(old_db_type);
3941
3966
  }
3942
 
  table_list->table=0;                          // For query cache
 
3967
  table_list->table= NULL;
3943
3968
 
3944
3969
end_temporary:
3945
3970
  /*
4021
4046
  if (name_lock)
4022
4047
    session->unlink_open_table(name_lock);
4023
4048
  pthread_mutex_unlock(&LOCK_open);
4024
 
  return(true);
 
4049
  return true;
4025
4050
}
4026
4051
/* mysql_alter_table */
4027
4052
 
4197
4222
      found_count++;
4198
4223
  }
4199
4224
  end_read_record(&info);
4200
 
  free_io_cache(from);
 
4225
  from->free_io_cache();
4201
4226
  delete [] copy;                               // This is never 0
4202
4227
 
4203
4228
  if (to->file->ha_end_bulk_insert() && error <= 0)
4225
4250
 err:
4226
4251
  session->variables.sql_mode= save_sql_mode;
4227
4252
  session->abort_on_warning= 0;
4228
 
  free_io_cache(from);
 
4253
  from->free_io_cache();
4229
4254
  *copied= found_count;
4230
4255
  *deleted=delete_count;
4231
4256
  to->file->ha_release_auto_increment();
4295
4320
 
4296
4321
    sprintf(table_name,"%s.%s",table->db,table->table_name);
4297
4322
 
4298
 
    t= table->table= session->open_ltable(table, TL_READ);
 
4323
    t= table->table= session->openTableLock(table, TL_READ);
4299
4324
    session->clear_error();                     // these errors shouldn't get client
4300
4325
 
4301
4326
    protocol->prepareForResend();