~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Monty Taylor
  • Date: 2008-09-23 14:19:48 UTC
  • mto: This revision was merged to the branch mainline in revision 419.
  • Revision ID: monty@inaugust.com-20080923141948-ktph2kg13addaxq1
Actually removed VOID() this time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
  if (flags & FN_IS_TMP) // FN_FROM_IS_TMP | FN_TO_IS_TMP
163
163
    stpncpy(tbbuff, table_name, sizeof(tbbuff));
164
164
  else
165
 
    VOID(tablename_to_filename(table_name, tbbuff, sizeof(tbbuff)));
 
165
    tablename_to_filename(table_name, tbbuff, sizeof(tbbuff));
166
166
 
167
 
  VOID(tablename_to_filename(db, dbbuff, sizeof(dbbuff)));
 
167
  tablename_to_filename(db, dbbuff, sizeof(dbbuff));
168
168
 
169
169
  char *end = buff + bufflen;
170
170
  /* Don't add FN_ROOTDIR if mysql_data_home already includes it */
1788
1788
    goto err;
1789
1789
  }
1790
1790
 
1791
 
  VOID(pthread_mutex_lock(&LOCK_open));
 
1791
  pthread_mutex_lock(&LOCK_open);
1792
1792
  if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
1793
1793
  {
1794
1794
    if (!access(path,F_OK))
1904
1904
    write_bin_log(thd, true, thd->query, thd->query_length);
1905
1905
  error= false;
1906
1906
unlock_and_end:
1907
 
  VOID(pthread_mutex_unlock(&LOCK_open));
 
1907
  pthread_mutex_unlock(&LOCK_open);
1908
1908
 
1909
1909
err:
1910
1910
  thd_proc_info(thd, "After create");
2146
2146
 
2147
2147
  safe_mutex_assert_owner(&LOCK_open);
2148
2148
 
2149
 
  VOID(table->file->extra(function));
 
2149
  table->file->extra(function);
2150
2150
  /* Mark all tables that are in use as 'old' */
2151
2151
  mysql_lock_abort(thd, table, true);   /* end threads waiting on lock */
2152
2152
 
2972
2972
    Also some engines (e.g. NDB cluster) require that LOCK_open should be held
2973
2973
    during the call to ha_create_table(). See bug #28614 for more info.
2974
2974
  */
2975
 
  VOID(pthread_mutex_lock(&LOCK_open));
 
2975
  pthread_mutex_lock(&LOCK_open);
2976
2976
  if (src_table->schema_table)
2977
2977
  {
2978
2978
    if (mysql_create_like_schema_frm(thd, src_table, dst_path, create_info))
2979
2979
    {
2980
 
      VOID(pthread_mutex_unlock(&LOCK_open));
 
2980
      pthread_mutex_unlock(&LOCK_open);
2981
2981
      goto err;
2982
2982
    }
2983
2983
  }
2987
2987
      my_error(ER_BAD_DB_ERROR,MYF(0),db);
2988
2988
    else
2989
2989
      my_error(ER_CANT_CREATE_FILE,MYF(0),dst_path,my_errno);
2990
 
    VOID(pthread_mutex_unlock(&LOCK_open));
 
2990
    pthread_mutex_unlock(&LOCK_open);
2991
2991
    goto err;
2992
2992
  }
2993
2993
 
3000
3000
  if (thd->variables.keep_files_on_create)
3001
3001
    create_info->options|= HA_CREATE_KEEP_FILES;
3002
3002
  err= ha_create_table(thd, dst_path, db, table_name, create_info, 1);
3003
 
  VOID(pthread_mutex_unlock(&LOCK_open));
 
3003
  pthread_mutex_unlock(&LOCK_open);
3004
3004
 
3005
3005
  if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
3006
3006
  {
3055
3055
          of this function.
3056
3056
        */
3057
3057
        table->table= name_lock;
3058
 
        VOID(pthread_mutex_lock(&LOCK_open));
 
3058
        pthread_mutex_lock(&LOCK_open);
3059
3059
        if (reopen_name_locked_table(thd, table, false))
3060
3060
        {
3061
 
          VOID(pthread_mutex_unlock(&LOCK_open));
 
3061
          pthread_mutex_unlock(&LOCK_open);
3062
3062
          goto err;
3063
3063
        }
3064
 
        VOID(pthread_mutex_unlock(&LOCK_open));
 
3064
        pthread_mutex_unlock(&LOCK_open);
3065
3065
 
3066
3066
        int result= store_create_info(thd, table, &query,
3067
3067
                                               create_info);
3845
3845
    The final .frm file is already created as a temporary file
3846
3846
    and will be renamed to the original table name.
3847
3847
  */
3848
 
  VOID(pthread_mutex_lock(&LOCK_open));
 
3848
  pthread_mutex_lock(&LOCK_open);
3849
3849
  wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
3850
3850
  alter_table_manage_keys(table, table->file->indexes_are_disabled(),
3851
3851
                          keys_onoff);
3859
3859
                         table->s->table_name.str, FN_FROM_IS_TMP))
3860
3860
  {
3861
3861
    error= 1;
3862
 
    VOID(pthread_mutex_unlock(&LOCK_open));
 
3862
    pthread_mutex_unlock(&LOCK_open);
3863
3863
    goto err;
3864
3864
  }
3865
3865
  broadcast_refresh();
3866
 
  VOID(pthread_mutex_unlock(&LOCK_open));
 
3866
  pthread_mutex_unlock(&LOCK_open);
3867
3867
 
3868
3868
  /*
3869
3869
    The ALTER Table is always in its own transaction.
3879
3879
    goto err;
3880
3880
  if (online)
3881
3881
  {
3882
 
    VOID(pthread_mutex_lock(&LOCK_open));
 
3882
    pthread_mutex_lock(&LOCK_open);
3883
3883
    if (reopen_table(table))
3884
3884
    {
3885
3885
      error= -1;
3886
3886
      goto err;
3887
3887
    }
3888
 
    VOID(pthread_mutex_unlock(&LOCK_open));
 
3888
    pthread_mutex_unlock(&LOCK_open);
3889
3889
    t_table= table;
3890
3890
 
3891
3891
   /*
3904
3904
    */
3905
3905
    assert(t_table == table);
3906
3906
    table->open_placeholder= 1;
3907
 
    VOID(pthread_mutex_lock(&LOCK_open));
 
3907
    pthread_mutex_lock(&LOCK_open);
3908
3908
    close_handle_and_leave_table_as_lock(table);
3909
 
    VOID(pthread_mutex_unlock(&LOCK_open));
 
3909
    pthread_mutex_unlock(&LOCK_open);
3910
3910
  }
3911
3911
 
3912
3912
 err:
4528
4528
        while the fact that the table is still open gives us protection
4529
4529
        from concurrent DDL statements.
4530
4530
      */
4531
 
      VOID(pthread_mutex_lock(&LOCK_open));
 
4531
      pthread_mutex_lock(&LOCK_open);
4532
4532
      wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
4533
 
      VOID(pthread_mutex_unlock(&LOCK_open));
 
4533
      pthread_mutex_unlock(&LOCK_open);
4534
4534
      error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
4535
4535
      /* COND_refresh will be signaled in close_thread_tables() */
4536
4536
      break;
4537
4537
    case DISABLE:
4538
 
      VOID(pthread_mutex_lock(&LOCK_open));
 
4538
      pthread_mutex_lock(&LOCK_open);
4539
4539
      wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
4540
 
      VOID(pthread_mutex_unlock(&LOCK_open));
 
4540
      pthread_mutex_unlock(&LOCK_open);
4541
4541
      error=table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
4542
4542
      /* COND_refresh will be signaled in close_thread_tables() */
4543
4543
      break;
4554
4554
                          table->alias);
4555
4555
    }
4556
4556
 
4557
 
    VOID(pthread_mutex_lock(&LOCK_open));
 
4557
    pthread_mutex_lock(&LOCK_open);
4558
4558
    /*
4559
4559
      Unlike to the above case close_cached_table() below will remove ALL
4560
4560
      instances of Table from table cache (it will also remove table lock
4592
4592
          error= -1;
4593
4593
        else if (0)
4594
4594
      {
4595
 
          VOID(mysql_rename_table(old_db_type, new_db, new_alias, db,
4596
 
                                  table_name, 0));
 
4595
          mysql_rename_table(old_db_type, new_db, new_alias, db,
 
4596
                             table_name, 0);
4597
4597
          error= -1;
4598
4598
      }
4599
4599
    }
4619
4619
    }
4620
4620
    if (name_lock)
4621
4621
      unlink_open_table(thd, name_lock, false);
4622
 
    VOID(pthread_mutex_unlock(&LOCK_open));
 
4622
    pthread_mutex_unlock(&LOCK_open);
4623
4623
    table_list->table= NULL;                    // For query cache
4624
4624
    return(error);
4625
4625
  }
4834
4834
  }
4835
4835
  else
4836
4836
  {
4837
 
    VOID(pthread_mutex_lock(&LOCK_open));
 
4837
    pthread_mutex_lock(&LOCK_open);
4838
4838
    wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
4839
 
    VOID(pthread_mutex_unlock(&LOCK_open));
 
4839
    pthread_mutex_unlock(&LOCK_open);
4840
4840
    alter_table_manage_keys(table, table->file->indexes_are_disabled(),
4841
4841
                            alter_info->keys_onoff);
4842
4842
    error= ha_autocommit_or_rollback(thd, 0);
4876
4876
    intern_close_table(new_table);
4877
4877
    my_free(new_table,MYF(0));
4878
4878
  }
4879
 
  VOID(pthread_mutex_lock(&LOCK_open));
 
4879
  pthread_mutex_lock(&LOCK_open);
4880
4880
  if (error)
4881
4881
  {
4882
 
    VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP));
4883
 
    VOID(pthread_mutex_unlock(&LOCK_open));
 
4882
    quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP);
 
4883
    pthread_mutex_unlock(&LOCK_open);
4884
4884
    goto err;
4885
4885
  }
4886
4886
 
4929
4929
                         FN_TO_IS_TMP))
4930
4930
  {
4931
4931
    error=1;
4932
 
    VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP));
 
4932
    quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP);
4933
4933
  }
4934
4934
  else if (mysql_rename_table(new_db_type, new_db, tmp_name, new_db,
4935
4935
                              new_alias, FN_FROM_IS_TMP) || ((new_name != table_name || new_db != db) && 0))
4936
4936
  {
4937
4937
    /* Try to get everything back. */
4938
4938
    error=1;
4939
 
    VOID(quick_rm_table(new_db_type,new_db,new_alias, 0));
4940
 
    VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP));
4941
 
    VOID(mysql_rename_table(old_db_type, db, old_name, db, alias,
4942
 
                            FN_FROM_IS_TMP));
 
4939
    quick_rm_table(new_db_type,new_db,new_alias, 0);
 
4940
    quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP);
 
4941
    mysql_rename_table(old_db_type, db, old_name, db, alias,
 
4942
                       FN_FROM_IS_TMP);
4943
4943
  }
4944
4944
 
4945
4945
  if (error)
4948
4948
    goto err_with_placeholders;
4949
4949
  }
4950
4950
 
4951
 
  VOID(quick_rm_table(old_db_type, db, old_name, FN_IS_TMP));
 
4951
  quick_rm_table(old_db_type, db, old_name, FN_IS_TMP);
4952
4952
 
4953
4953
end_online:
4954
4954
  if (thd->locked_tables && new_name == table_name && new_db == db)
4959
4959
    if (error)
4960
4960
      goto err_with_placeholders;
4961
4961
  }
4962
 
  VOID(pthread_mutex_unlock(&LOCK_open));
 
4962
  pthread_mutex_unlock(&LOCK_open);
4963
4963
 
4964
4964
  thd_proc_info(thd, "end");
4965
4965
 
5024
5024
    close_temporary_table(thd, new_table, 1, 1);
5025
5025
  }
5026
5026
  else
5027
 
    VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP));
 
5027
    quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP);
5028
5028
 
5029
5029
err:
5030
5030
  /*
5075
5075
  unlink_open_table(thd, table, false);
5076
5076
  if (name_lock)
5077
5077
    unlink_open_table(thd, name_lock, false);
5078
 
  VOID(pthread_mutex_unlock(&LOCK_open));
 
5078
  pthread_mutex_unlock(&LOCK_open);
5079
5079
  return(true);
5080
5080
}
5081
5081
/* mysql_alter_table */