diff options
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 530 |
1 files changed, 235 insertions, 295 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6006c818725..4f962de0a12 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "sp_head.h" #include "sql_trigger.h" #include "sql_show.h" +#include "keycaches.h" #ifdef __WIN__ #include <io.h> @@ -498,9 +499,9 @@ uint build_table_filename(char *buff, size_t bufflen, const char *db, if (flags & FN_IS_TMP) // FN_FROM_IS_TMP | FN_TO_IS_TMP strnmov(tbbuff, table_name, sizeof(tbbuff)); else - VOID(tablename_to_filename(table_name, tbbuff, sizeof(tbbuff))); + (void) tablename_to_filename(table_name, tbbuff, sizeof(tbbuff)); - VOID(tablename_to_filename(db, dbbuff, sizeof(dbbuff))); + (void) tablename_to_filename(db, dbbuff, sizeof(dbbuff)); char *end = buff + bufflen; /* Don't add FN_ROOTDIR if mysql_data_home already includes it */ @@ -611,7 +612,7 @@ struct st_global_ddl_log st_global_ddl_log global_ddl_log; -pthread_mutex_t LOCK_gdl; +mysql_mutex_t LOCK_gdl; #define DDL_LOG_ENTRY_TYPE_POS 0 #define DDL_LOG_ACTION_TYPE_POS 1 @@ -641,8 +642,8 @@ static bool read_ddl_log_file_entry(uint entry_no) uint io_size= global_ddl_log.io_size; DBUG_ENTER("read_ddl_log_file_entry"); - if (my_pread(file_id, file_entry_buf, io_size, io_size * entry_no, - MYF(MY_WME)) != io_size) + if (mysql_file_pread(file_id, file_entry_buf, io_size, io_size * entry_no, + MYF(MY_WME)) != io_size) error= TRUE; DBUG_RETURN(error); } @@ -665,8 +666,8 @@ static bool write_ddl_log_file_entry(uint entry_no) char *file_entry_buf= (char*)global_ddl_log.file_entry_buf; DBUG_ENTER("write_ddl_log_file_entry"); - if (my_pwrite(file_id, (uchar*)file_entry_buf, - IO_SIZE, IO_SIZE * entry_no, MYF(MY_WME)) != IO_SIZE) + if (mysql_file_pwrite(file_id, (uchar*)file_entry_buf, + IO_SIZE, IO_SIZE * entry_no, MYF(MY_WME)) != IO_SIZE) error= TRUE; DBUG_RETURN(error); } @@ -700,7 +701,7 @@ static bool write_ddl_log_header() sql_print_error("Error writing ddl log header"); DBUG_RETURN(TRUE); } - VOID(sync_ddl_log()); + (void) sync_ddl_log(); DBUG_RETURN(error); } @@ -742,8 +743,9 @@ static uint read_ddl_log_header() DBUG_ENTER("read_ddl_log_header"); create_ddl_log_file_name(file_name); - if ((global_ddl_log.file_id= my_open(file_name, - O_RDWR | O_BINARY, MYF(0))) >= 0) + if ((global_ddl_log.file_id= mysql_file_open(key_file_global_ddl_log, + file_name, + O_RDWR | O_BINARY, MYF(0))) >= 0) { if (read_ddl_log_file_entry(0UL)) { @@ -768,7 +770,7 @@ static uint read_ddl_log_header() global_ddl_log.first_free= NULL; global_ddl_log.first_used= NULL; global_ddl_log.num_entries= 0; - VOID(pthread_mutex_init(&LOCK_gdl, MY_MUTEX_INIT_FAST)); + mysql_mutex_init(key_LOCK_gdl, &LOCK_gdl, MY_MUTEX_INIT_FAST); global_ddl_log.do_release= true; DBUG_RETURN(entry_no); } @@ -839,10 +841,10 @@ static bool init_ddl_log() global_ddl_log.io_size= IO_SIZE; global_ddl_log.name_len= FN_LEN; create_ddl_log_file_name(file_name); - if ((global_ddl_log.file_id= my_create(file_name, - CREATE_MODE, - O_RDWR | O_TRUNC | O_BINARY, - MYF(MY_WME))) < 0) + if ((global_ddl_log.file_id= mysql_file_create(key_file_global_ddl_log, + file_name, CREATE_MODE, + O_RDWR | O_TRUNC | O_BINARY, + MYF(MY_WME))) < 0) { /* Couldn't create ddl log file, this is serious error */ sql_print_error("Failed to open ddl log file"); @@ -851,7 +853,7 @@ static bool init_ddl_log() global_ddl_log.inited= TRUE; if (write_ddl_log_header()) { - VOID(my_close(global_ddl_log.file_id, MYF(MY_WME))); + (void) mysql_file_close(global_ddl_log.file_id, MYF(MY_WME)); global_ddl_log.inited= FALSE; DBUG_RETURN(TRUE); } @@ -928,14 +930,14 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry) if (frm_action) { strxmov(to_path, ddl_log_entry->name, reg_ext, NullS); - if ((error= my_delete(to_path, MYF(MY_WME)))) + if ((error= mysql_file_delete(key_file_frm, to_path, MYF(MY_WME)))) { if (my_errno != ENOENT) break; } #ifdef WITH_PARTITION_STORAGE_ENGINE strxmov(to_path, ddl_log_entry->name, par_ext, NullS); - VOID(my_delete(to_path, MYF(MY_WME))); + (void) mysql_file_delete(key_file_partition, to_path, MYF(MY_WME)); #endif } else @@ -948,7 +950,7 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry) } if ((deactivate_ddl_log_entry(ddl_log_entry->entry_pos))) break; - VOID(sync_ddl_log()); + (void) sync_ddl_log(); error= FALSE; if (ddl_log_entry->action_type == DDL_LOG_DELETE_ACTION) break; @@ -967,12 +969,12 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry) { strxmov(to_path, ddl_log_entry->name, reg_ext, NullS); strxmov(from_path, ddl_log_entry->from_name, reg_ext, NullS); - if (my_rename(from_path, to_path, MYF(MY_WME))) + if (mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME))) break; #ifdef WITH_PARTITION_STORAGE_ENGINE strxmov(to_path, ddl_log_entry->name, par_ext, NullS); strxmov(from_path, ddl_log_entry->from_name, par_ext, NullS); - VOID(my_rename(from_path, to_path, MYF(MY_WME))); + (void) mysql_file_rename(key_file_partition, from_path, to_path, MYF(MY_WME)); #endif } else @@ -983,7 +985,7 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry) } if ((deactivate_ddl_log_entry(ddl_log_entry->entry_pos))) break; - VOID(sync_ddl_log()); + (void) sync_ddl_log(); error= FALSE; break; } @@ -1121,7 +1123,7 @@ bool write_ddl_log_entry(DDL_LOG_ENTRY *ddl_log_entry, } if (write_header && !error) { - VOID(sync_ddl_log()); + (void) sync_ddl_log(); if (write_ddl_log_header()) error= TRUE; } @@ -1178,7 +1180,7 @@ bool write_execute_ddl_log_entry(uint first_entry, any log entries before, we are only here to write the execute entry to indicate it is done. */ - VOID(sync_ddl_log()); + (void) sync_ddl_log(); file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]= (char)DDL_LOG_EXECUTE_CODE; } else @@ -1202,7 +1204,7 @@ bool write_execute_ddl_log_entry(uint first_entry, release_ddl_log_memory_entry(*active_entry); DBUG_RETURN(TRUE); } - VOID(sync_ddl_log()); + (void) sync_ddl_log(); if (write_header) { if (write_ddl_log_header()) @@ -1298,7 +1300,7 @@ bool sync_ddl_log() { DBUG_RETURN(TRUE); } - if (my_sync(global_ddl_log.file_id, MYF(0))) + if (mysql_file_sync(global_ddl_log.file_id, MYF(0))) { /* Write to error log */ sql_print_error("Failed to sync ddl log"); @@ -1354,7 +1356,7 @@ bool execute_ddl_log_entry(THD *thd, uint first_entry) uint read_entry= first_entry; DBUG_ENTER("execute_ddl_log_entry"); - pthread_mutex_lock(&LOCK_gdl); + mysql_mutex_lock(&LOCK_gdl); do { if (read_ddl_log_entry(read_entry, &ddl_log_entry)) @@ -1376,7 +1378,7 @@ bool execute_ddl_log_entry(THD *thd, uint first_entry) } read_entry= ddl_log_entry.next_entry; } while (read_entry); - pthread_mutex_unlock(&LOCK_gdl); + mysql_mutex_unlock(&LOCK_gdl); DBUG_RETURN(FALSE); } @@ -1394,7 +1396,7 @@ static void close_ddl_log() DBUG_ENTER("close_ddl_log"); if (global_ddl_log.file_id >= 0) { - VOID(my_close(global_ddl_log.file_id, MYF(MY_WME))); + (void) mysql_file_close(global_ddl_log.file_id, MYF(MY_WME)); global_ddl_log.file_id= (File) -1; } DBUG_VOID_RETURN; @@ -1454,7 +1456,7 @@ void execute_ddl_log_recovery() } close_ddl_log(); create_ddl_log_file_name(file_name); - VOID(my_delete(file_name, MYF(0))); + (void) mysql_file_delete(key_file_global_ddl_log, file_name, MYF(0)); global_ddl_log.recovery_phase= FALSE; delete thd; /* Remember that we don't have a THD */ @@ -1480,7 +1482,7 @@ void release_ddl_log() if (!global_ddl_log.do_release) DBUG_VOID_RETURN; - pthread_mutex_lock(&LOCK_gdl); + mysql_mutex_lock(&LOCK_gdl); while (used_list) { DDL_LOG_MEMORY_ENTRY *tmp= used_list->next_log_entry; @@ -1495,8 +1497,8 @@ void release_ddl_log() } close_ddl_log(); global_ddl_log.inited= 0; - pthread_mutex_unlock(&LOCK_gdl); - VOID(pthread_mutex_destroy(&LOCK_gdl)); + mysql_mutex_unlock(&LOCK_gdl); + mysql_mutex_destroy(&LOCK_gdl); global_ddl_log.do_release= false; DBUG_VOID_RETURN; } @@ -1628,7 +1630,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) CHF_CREATE_FLAG, lpt->create_info)) { - my_delete(shadow_frm_name, MYF(0)); + mysql_file_delete(key_file_frm, shadow_frm_name, MYF(0)); error= 1; goto end; } @@ -1652,7 +1654,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) error= 1; goto end; } - error= my_delete(shadow_frm_name, MYF(MY_WME)); + error= mysql_file_delete(key_file_frm, shadow_frm_name, MYF(MY_WME)); } if (flags & WFRM_INSTALL_SHADOW) { @@ -1675,8 +1677,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) completing this we write a new phase to the log entry that will deactivate it. */ - VOID(pthread_mutex_lock(&LOCK_open)); - if (my_delete(frm_name, MYF(MY_WME)) || + mysql_mutex_lock(&LOCK_open); + if (mysql_file_delete(key_file_frm, frm_name, MYF(MY_WME)) || #ifdef WITH_PARTITION_STORAGE_ENGINE lpt->table->file->ha_create_handler_files(path, shadow_path, CHF_DELETE_FLAG, NULL) || @@ -1684,11 +1686,13 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) (sync_ddl_log(), FALSE) || #endif #ifdef WITH_PARTITION_STORAGE_ENGINE - my_rename(shadow_frm_name, frm_name, MYF(MY_WME)) || + mysql_file_rename(key_file_frm, + shadow_frm_name, frm_name, MYF(MY_WME)) || lpt->table->file->ha_create_handler_files(path, shadow_path, CHF_RENAME_FLAG, NULL)) #else - my_rename(shadow_frm_name, frm_name, MYF(MY_WME))) + mysql_file_rename(key_file_frm, + shadow_frm_name, frm_name, MYF(MY_WME))) #endif { error= 1; @@ -1728,11 +1732,11 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) #endif err: - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); #ifdef WITH_PARTITION_STORAGE_ENGINE deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos); part_info->frm_log_entry= NULL; - VOID(sync_ddl_log()); + (void) sync_ddl_log(); #endif } @@ -1758,7 +1762,7 @@ end: */ int write_bin_log(THD *thd, bool clear_error, - char const *query, ulong query_length) + char const *query, ulong query_length, bool is_trans) { int error= 0; if (mysql_bin_log.is_open()) @@ -1769,7 +1773,8 @@ int write_bin_log(THD *thd, bool clear_error, else errcode= query_error_code(thd, TRUE); error= thd->binlog_query(THD::STMT_QUERY_TYPE, - query, query_length, FALSE, FALSE, errcode); + query, query_length, is_trans, FALSE, FALSE, + errcode); } return error; } @@ -1790,7 +1795,8 @@ int write_bin_log(THD *thd, bool clear_error, If a table is in use, we will wait for all users to free the table before dropping it - Wait if global_read_lock (FLUSH TABLES WITH READ LOCK) is set. + Wait if global_read_lock (FLUSH TABLES WITH READ LOCK) is set, but + not if under LOCK TABLES. RETURN FALSE OK. In this case ok packet is sent to user @@ -1801,7 +1807,7 @@ int write_bin_log(THD *thd, bool clear_error, bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, my_bool drop_temporary) { - bool error= FALSE, need_start_waiters= FALSE; + bool error= FALSE, need_start_waiting= FALSE; Drop_table_error_handler err_handler(thd->get_internal_handler()); DBUG_ENTER("mysql_rm_table"); @@ -1809,13 +1815,9 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, if (!drop_temporary) { - if ((error= wait_if_global_read_lock(thd, 0, 1))) - { - my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, MYF(0), tables->table_name); + if (!thd->locked_tables && + !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) DBUG_RETURN(TRUE); - } - else - need_start_waiters= TRUE; } /* @@ -1828,7 +1830,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, thd->pop_internal_handler(); - if (need_start_waiters) + if (need_start_waiting) start_waiting_global_read_lock(thd); if (error) @@ -1885,7 +1887,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, LINT_INIT(alias); LINT_INIT(path_length); - if (thd->current_stmt_binlog_row_based && !dont_log_query) + if (thd->is_current_stmt_binlog_format_row() && !dont_log_query) { built_query.set_charset(system_charset_info); if (if_exists) @@ -1896,7 +1898,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, mysql_ha_rm_tables(thd, tables, FALSE); - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); /* If we have the table in the definition cache, we don't have to check the @@ -1912,19 +1914,19 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, table->db_type= share->db_type(); /* Disable drop of enabled log tables */ - if (share && (share->table_category == TABLE_CATEGORY_PERFORMANCE) && + if (share && (share->table_category == TABLE_CATEGORY_LOG) && check_if_log_table(table->db_length, table->db, table->table_name_length, table->table_name, 1)) { my_error(ER_BAD_LOG_STATEMENT, MYF(0), "DROP"); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(1); } } if (!drop_temporary && lock_table_names_exclusively(thd, tables)) { - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(1); } @@ -1945,7 +1947,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, // removed temporary table tmp_table_deleted= 1; if (thd->variables.binlog_format == BINLOG_FORMAT_MIXED && - thd->current_stmt_binlog_row_based) + thd->is_current_stmt_binlog_format_row()) { if (built_tmp_query.is_empty()) { @@ -1979,7 +1981,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, being built. The string always end in a comma and the comma will be chopped off before being written to the binary log. */ - if (!drop_temporary && thd->current_stmt_binlog_row_based && !dont_log_query) + if (!drop_temporary && thd->is_current_stmt_binlog_format_row() && !dont_log_query) { non_temp_tables_count++; /* @@ -2067,7 +2069,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, int new_error; /* Delete the table definition file */ strmov(end,reg_ext); - if (!(new_error=my_delete(path,MYF(MY_WME)))) + if (!(new_error= mysql_file_delete(key_file_frm, path, MYF(MY_WME)))) { some_tables_deleted=1; new_error= Table_triggers_list::drop_all_triggers(thd, db, @@ -2095,7 +2097,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, It's safe to unlock LOCK_open: we have an exclusive lock on the table name. */ - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); thd->thread_specific_used|= tmp_table_deleted; error= 0; if (wrong_tables.length()) @@ -2113,7 +2115,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, query_cache_invalidate3(thd, tables, 0); if (!dont_log_query) { - if (!thd->current_stmt_binlog_row_based || + if (!thd->is_current_stmt_binlog_format_row() || (non_temp_tables_count > 0 && !tmp_table_deleted)) { /* @@ -2125,7 +2127,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, */ error |= write_bin_log(thd, !error, thd->query(), thd->query_length()); } - else if (thd->current_stmt_binlog_row_based && + else if (thd->is_current_stmt_binlog_format_row() && tmp_table_deleted) { if (non_temp_tables_count > 0) @@ -2164,7 +2166,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, */ built_tmp_query.chop(); // Chop of the last comma built_tmp_query.append(" /* generated by server */"); - error|= write_bin_log(thd, !error, built_tmp_query.ptr(), built_tmp_query.length()); + error|= write_bin_log(thd, !error, built_tmp_query.ptr(), built_tmp_query.length(), + thd->in_multi_stmt_transaction()); } } @@ -2178,10 +2181,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, */ } } - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); err_with_placeholders: unlock_table_names(thd, tables, (TABLE_LIST*) 0); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(error); } @@ -2210,7 +2213,7 @@ bool quick_rm_table(handlerton *base,const char *db, uint path_length= build_table_filename(path, sizeof(path) - 1, db, table_name, reg_ext, flags); - if (my_delete(path,MYF(0))) + if (mysql_file_delete(key_file_frm, path, MYF(0))) error= 1; /* purecov: inspected */ path[path_length - reg_ext_length]= '\0'; // Remove reg_ext if (!(flags & FRM_ONLY)) @@ -2239,10 +2242,10 @@ static int sort_keys(KEY *a, KEY *b) { if (!(b_flags & HA_NOSAME)) return -1; - if ((a_flags ^ b_flags) & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) + if ((a_flags ^ b_flags) & HA_NULL_PART_KEY) { /* Sort NOT NULL keys before other keys */ - return (a_flags & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) ? 1 : -1; + return (a_flags & HA_NULL_PART_KEY) ? 1 : -1; } if (a->name == primary_key_name) return -1; @@ -3617,8 +3620,8 @@ static inline int write_create_table_bin_log(THD *thd, Otherwise, the statement shall be binlogged. */ if (!internal_tmp_table && - (!thd->current_stmt_binlog_row_based || - (thd->current_stmt_binlog_row_based && + (!thd->is_current_stmt_binlog_format_row() || + (thd->is_current_stmt_binlog_format_row() && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)))) return write_bin_log(thd, TRUE, thd->query(), thd->query_length()); return 0; @@ -3897,7 +3900,7 @@ bool mysql_create_table_no_lock(THD *thd, goto err; } - VOID(pthread_mutex_lock(&LOCK_open)); + mysql_mutex_lock(&LOCK_open); if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) { if (!access(path,F_OK)) @@ -3961,15 +3964,43 @@ bool mysql_create_table_no_lock(THD *thd, create_info->table_existed= 0; // Mark that table is created #ifdef HAVE_READLINK - if (test_if_data_home_dir(create_info->data_file_name)) - { - my_error(ER_WRONG_ARGUMENTS, MYF(0), "DATA DIRECTORY"); - goto unlock_and_end; - } - if (test_if_data_home_dir(create_info->index_file_name)) { - my_error(ER_WRONG_ARGUMENTS, MYF(0), "INDEX DIRECTORY"); - goto unlock_and_end; + size_t dirlen; + char dirpath[FN_REFLEN]; + + /* + data_file_name and index_file_name include the table name without + extension. Mostly this does not refer to an existing file. When + comparing data_file_name or index_file_name against the data + directory, we try to resolve all symbolic links. On some systems, + we use realpath(3) for the resolution. This returns ENOENT if the + resolved path does not refer to an existing file. my_realpath() + does then copy the requested path verbatim, without symlink + resolution. Thereafter the comparison can fail even if the + requested path is within the data directory. E.g. if symlinks to + another file system are used. To make realpath(3) return the + resolved path, we strip the table name and compare the directory + path only. If the directory doesn't exist either, table creation + will fail anyway. + */ + if (create_info->data_file_name) + { + dirname_part(dirpath, create_info->data_file_name, &dirlen); + if (test_if_data_home_dir(dirpath)) + { + my_error(ER_WRONG_ARGUMENTS, MYF(0), "DATA DIRECTORY"); + goto unlock_and_end; + } + } + if (create_info->index_file_name) + { + dirname_part(dirpath, create_info->index_file_name, &dirlen); + if (test_if_data_home_dir(dirpath)) + { + my_error(ER_WRONG_ARGUMENTS, MYF(0), "INDEX DIRECTORY"); + goto unlock_and_end; + } + } } #ifdef WITH_PARTITION_STORAGE_ENGINE @@ -4013,7 +4044,7 @@ bool mysql_create_table_no_lock(THD *thd, error= write_create_table_bin_log(thd, create_info, internal_tmp_table); unlock_and_end: - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); err: thd_proc_info(thd, "After create"); @@ -4046,21 +4077,21 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, DBUG_ENTER("mysql_create_table"); /* Wait for any database locks */ - pthread_mutex_lock(&LOCK_lock_db); + mysql_mutex_lock(&LOCK_lock_db); while (!thd->killed && my_hash_search(&lock_db_cache,(uchar*) db, strlen(db))) { wait_for_condition(thd, &LOCK_lock_db, &COND_refresh); - pthread_mutex_lock(&LOCK_lock_db); + mysql_mutex_lock(&LOCK_lock_db); } if (thd->killed) { - pthread_mutex_unlock(&LOCK_lock_db); + mysql_mutex_unlock(&LOCK_lock_db); DBUG_RETURN(TRUE); } creating_table++; - pthread_mutex_unlock(&LOCK_lock_db); + mysql_mutex_unlock(&LOCK_lock_db); if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE)) { @@ -4097,14 +4128,14 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, unlock: if (name_lock) { - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); unlink_open_table(thd, name_lock, FALSE); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); } - pthread_mutex_lock(&LOCK_lock_db); + mysql_mutex_lock(&LOCK_lock_db); if (!--creating_table && creating_database) - pthread_cond_signal(&COND_refresh); - pthread_mutex_unlock(&LOCK_lock_db); + mysql_cond_signal(&COND_refresh); + mysql_mutex_unlock(&LOCK_lock_db); DBUG_RETURN(result); } @@ -4265,9 +4296,9 @@ void wait_while_table_is_used(THD *thd, TABLE *table, table->s->table_name.str, (ulong) table->s, table->db_stat, table->s->version)); - safe_mutex_assert_owner(&LOCK_open); + mysql_mutex_assert_owner(&LOCK_open); - VOID(table->file->extra(function)); + (void) table->file->extra(function); /* Mark all tables that are in use as 'old' */ mysql_lock_abort(thd, table, TRUE); /* end threads waiting on lock */ @@ -4330,73 +4361,6 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table, return 1; } - -static int prepare_for_restore(THD* thd, TABLE_LIST* table, - HA_CHECK_OPT *check_opt) -{ - DBUG_ENTER("prepare_for_restore"); - - if (table->table) // do not overwrite existing tables on restore - { - DBUG_RETURN(send_check_errmsg(thd, table, "restore", - "table exists, will not overwrite on restore" - )); - } - else - { - char* backup_dir= thd->lex->backup_dir; - char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1], uname[FN_REFLEN]; - char* table_name= table->table_name; - char* db= table->db; - - VOID(tablename_to_filename(table->table_name, uname, sizeof(uname) - 1)); - - if (fn_format_relative_to_data_home(src_path, uname, backup_dir, reg_ext)) - DBUG_RETURN(-1); // protect buffer overflow - - build_table_filename(dst_path, sizeof(dst_path) - 1, - db, table_name, reg_ext, 0); - - if (lock_and_wait_for_table_name(thd,table)) - DBUG_RETURN(-1); - - if (my_copy(src_path, dst_path, MYF(MY_WME))) - { - pthread_mutex_lock(&LOCK_open); - unlock_table_name(thd, table); - pthread_mutex_unlock(&LOCK_open); - DBUG_RETURN(send_check_errmsg(thd, table, "restore", - "Failed copying .frm file")); - } - if (mysql_truncate(thd, table, 1)) - { - pthread_mutex_lock(&LOCK_open); - unlock_table_name(thd, table); - pthread_mutex_unlock(&LOCK_open); - DBUG_RETURN(send_check_errmsg(thd, table, "restore", - "Failed generating table from .frm file")); - } - } - - /* - Now we should be able to open the partially restored table - to finish the restore in the handler later on - */ - pthread_mutex_lock(&LOCK_open); - if (reopen_name_locked_table(thd, table, TRUE)) - { - unlock_table_name(thd, table); - pthread_mutex_unlock(&LOCK_open); - DBUG_RETURN(send_check_errmsg(thd, table, "restore", - "Failed to open partially restored table")); - } - /* A MERGE table must not come here. */ - DBUG_ASSERT(!table->table || !table->table->child_l); - pthread_mutex_unlock(&LOCK_open); - DBUG_RETURN(0); -} - - static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, HA_CHECK_OPT *check_opt) { @@ -4417,22 +4381,22 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, uint key_length; key_length= create_table_def_key(thd, key, table_list, 0); - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); if (!(share= (get_table_share(thd, table_list, key, key_length, 0, &error)))) { - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(0); // Can't open frm file } if (open_table_from_share(thd, share, "", 0, 0, 0, &tmp_table, FALSE)) { release_table_share(share, RELEASE_NORMAL); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(0); // Out of memory } table= &tmp_table; - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); } /* A MERGE table must not come here. */ @@ -4477,7 +4441,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, // Name of data file strxmov(from, table->s->normalized_path.str, ext[1], NullS); - if (!my_stat(from, &stat_info, MYF(0))) + if (!mysql_file_stat(key_file_misc, from, &stat_info, MYF(0))) goto end; // Can't use USE_FRM flag my_snprintf(tmp, sizeof(tmp), "%s-%lx_%lx", @@ -4486,38 +4450,38 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, /* If we could open the table, close it */ if (table_list->table) { - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); close_cached_table(thd, table); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); } if (lock_and_wait_for_table_name(thd,table_list)) { error= -1; goto end; } - if (my_rename(from, tmp, MYF(MY_WME))) + if (mysql_file_rename(key_file_misc, from, tmp, MYF(MY_WME))) { - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); unlock_table_name(thd, table_list); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); error= send_check_errmsg(thd, table_list, "repair", "Failed renaming data file"); goto end; } if (mysql_truncate(thd, table_list, 1)) { - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); unlock_table_name(thd, table_list); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); error= send_check_errmsg(thd, table_list, "repair", "Failed generating table from .frm file"); goto end; } - if (my_rename(tmp, from, MYF(MY_WME))) + if (mysql_file_rename(key_file_misc, tmp, from, MYF(MY_WME))) { - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); unlock_table_name(thd, table_list); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); error= send_check_errmsg(thd, table_list, "repair", "Failed restoring .MYD file"); goto end; @@ -4527,23 +4491,23 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, Now we should be able to open the partially repaired table to finish the repair in the handler later on. */ - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); if (reopen_name_locked_table(thd, table_list, TRUE)) { unlock_table_name(thd, table_list); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); error= send_check_errmsg(thd, table_list, "repair", "Failed to open partially repaired table"); goto end; } - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); end: if (table == &tmp_table) { - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); closefrm(table, 1); // Free allocated memory - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); } DBUG_RETURN(error); } @@ -4770,7 +4734,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if (lock_type == TL_WRITE && table->table->s->version) { DBUG_PRINT("admin", ("removing table from cache")); - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open, "Waiting to get writelock"); mysql_lock_abort(thd,table->table, TRUE); @@ -5033,10 +4997,10 @@ send_result_message: table->table->file->info(HA_STATUS_CONST); else { - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); remove_table_from_cache(thd, table->table->s->db.str, table->table->s->table_name.str, RTFC_NO_FLAG); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); } /* May be something modified consequently we have to invalidate cache */ query_cache_invalidate3(thd, table->table, 0); @@ -5063,29 +5027,6 @@ err: } -bool mysql_backup_table(THD* thd, TABLE_LIST* table_list) -{ - DBUG_ENTER("mysql_backup_table"); - WARN_DEPRECATED(thd, "6.0", "BACKUP TABLE", - "MySQL Administrator (mysqldump, mysql)"); - DBUG_RETURN(mysql_admin_table(thd, table_list, 0, - "backup", TL_READ, 0, 0, 0, 0, - &handler::ha_backup, 0)); -} - - -bool mysql_restore_table(THD* thd, TABLE_LIST* table_list) -{ - DBUG_ENTER("mysql_restore_table"); - WARN_DEPRECATED(thd, "6.0", "RESTORE TABLE", - "MySQL Administrator (mysqldump, mysql)"); - DBUG_RETURN(mysql_admin_table(thd, table_list, 0, - "restore", TL_WRITE, 1, 1, 0, - &prepare_for_restore, - &handler::ha_restore, 0)); -} - - bool mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) { DBUG_ENTER("mysql_repair_table"); @@ -5128,14 +5069,14 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, DBUG_ENTER("mysql_assign_to_keycache"); check_opt.init(); - pthread_mutex_lock(&LOCK_global_system_variables); + mysql_mutex_lock(&LOCK_global_system_variables); if (!(key_cache= get_key_cache(key_cache_name))) { - pthread_mutex_unlock(&LOCK_global_system_variables); + mysql_mutex_unlock(&LOCK_global_system_variables); my_error(ER_UNKNOWN_KEY_CACHE, MYF(0), key_cache_name->str); DBUG_RETURN(TRUE); } - pthread_mutex_unlock(&LOCK_global_system_variables); + mysql_mutex_unlock(&LOCK_global_system_variables); check_opt.key_cache= key_cache; DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt, "assign_to_keycache", TL_READ_NO_INSERT, 0, 0, @@ -5144,45 +5085,6 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, /* - Reassign all tables assigned to a key cache to another key cache - - SYNOPSIS - reassign_keycache_tables() - thd Thread object - src_cache Reference to the key cache to clean up - dest_cache New key cache - - NOTES - This is called when one sets a key cache size to zero, in which - case we have to move the tables associated to this key cache to - the "default" one. - - One has to ensure that one never calls this function while - some other thread is changing the key cache. This is assured by - the caller setting src_cache->in_init before calling this function. - - We don't delete the old key cache as there may still be pointers pointing - to it for a while after this function returns. - - RETURN VALUES - 0 ok -*/ - -int reassign_keycache_tables(THD *thd, KEY_CACHE *src_cache, - KEY_CACHE *dst_cache) -{ - DBUG_ENTER("reassign_keycache_tables"); - - DBUG_ASSERT(src_cache != dst_cache); - DBUG_ASSERT(src_cache->in_init); - src_cache->param_buff_size= 0; // Free key cache - ha_resize_key_cache(src_cache); - ha_change_key_cache(src_cache, dst_cache); - DBUG_RETURN(0); -} - - -/* Preload specified indexes for a table into key cache SYNOPSIS @@ -5362,12 +5264,12 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, Also some engines (e.g. NDB cluster) require that LOCK_open should be held during the call to ha_create_table(). See bug #28614 for more info. */ - VOID(pthread_mutex_lock(&LOCK_open)); + mysql_mutex_lock(&LOCK_open); if (src_table->schema_table) { if (mysql_create_like_schema_frm(thd, src_table, dst_path, create_info)) { - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); goto err; } } @@ -5377,7 +5279,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, my_error(ER_BAD_DB_ERROR,MYF(0),db); else my_error(ER_CANT_CREATE_FILE,MYF(0),dst_path,my_errno); - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); goto err; } @@ -5406,7 +5308,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, if (thd->variables.keep_files_on_create) create_info->options|= HA_CREATE_KEEP_FILES; err= ha_create_table(thd, dst_path, db, table_name, create_info, 1); - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); if (create_info->options & HA_LEX_CREATE_TMP_TABLE) { @@ -5448,7 +5350,7 @@ binlog: /* We have to write the query before we unlock the tables. */ - if (thd->current_stmt_binlog_row_based) + if (thd->is_current_stmt_binlog_format_row()) { /* Since temporary tables are not replicated under row-based @@ -5480,13 +5382,13 @@ binlog: of this function. */ table->table= name_lock; - VOID(pthread_mutex_lock(&LOCK_open)); + mysql_mutex_lock(&LOCK_open); if (reopen_name_locked_table(thd, table, FALSE)) { - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); goto err; } - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); /* The condition avoids a crash as described in BUG#48506. Other @@ -5520,9 +5422,9 @@ binlog: err: if (name_lock) { - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); unlink_open_table(thd, name_lock, FALSE); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); } DBUG_RETURN(res); } @@ -6009,6 +5911,35 @@ bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled, /** + maximum possible length for certain blob types. + + @param[in] type Blob type (e.g. MYSQL_TYPE_TINY_BLOB) + + @return + length +*/ + +static uint +blob_length_by_type(enum_field_types type) +{ + switch (type) + { + case MYSQL_TYPE_TINY_BLOB: + return 255; + case MYSQL_TYPE_BLOB: + return 65535; + case MYSQL_TYPE_MEDIUM_BLOB: + return 16777215; + case MYSQL_TYPE_LONG_BLOB: + return 4294967295U; + default: + DBUG_ASSERT(0); // we should never go here + return 0; + } +} + + +/** Prepare column and key definitions for CREATE TABLE in ALTER TABLE. This function transforms parse output of ALTER TABLE - lists of @@ -6303,6 +6234,14 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, BLOBs may have cfield->length == 0, which is why we test it before checking whether cfield->length < key_part_length (in chars). + + In case of TEXTs we check the data type maximum length *in bytes* + to key part length measured *in characters* (i.e. key_part_length + devided to mbmaxlen). This is because it's OK to have: + CREATE TABLE t1 (a tinytext, key(a(254)) character set utf8); + In case of this example: + - data type maximum length is 255. + - key_part_length is 1016 (=254*4, where 4 is mbmaxlen) */ if (!Field::type_can_have_key_part(cfield->field->type()) || !Field::type_can_have_key_part(cfield->sql_type) || @@ -6310,8 +6249,11 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, (key_info->flags & HA_SPATIAL) || (cfield->field->field_length == key_part_length && !f_is_blob(key_part->key_type)) || - (cfield->length && (cfield->length < key_part_length / - key_part->field->charset()->mbmaxlen))) + (cfield->length && (((cfield->sql_type >= MYSQL_TYPE_TINY_BLOB && + cfield->sql_type <= MYSQL_TYPE_BLOB) ? + blob_length_by_type(cfield->sql_type) : + cfield->length) < + key_part_length / key_part->field->charset()->mbmaxlen))) key_part_length= 0; // Use whole field } key_part_length /= key_part->field->charset()->mbmaxlen; @@ -6599,7 +6541,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (wait_if_global_read_lock(thd,0,1)) DBUG_RETURN(TRUE); - VOID(pthread_mutex_lock(&LOCK_open)); + mysql_mutex_lock(&LOCK_open); if (lock_table_names(thd, table_list)) { error= 1; @@ -6612,7 +6554,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, { thd->clear_error(); Query_log_event qinfo(thd, thd->query(), thd->query_length(), - 0, FALSE, 0); + FALSE, TRUE, FALSE, 0); if ((error= mysql_bin_log.write(&qinfo))) goto view_err_unlock; } @@ -6623,7 +6565,7 @@ view_err_unlock: unlock_table_names(thd, table_list, (TABLE_LIST*) 0); view_err: - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); start_waiting_global_read_lock(thd); DBUG_RETURN(error); } @@ -6784,17 +6726,17 @@ view_err: while the fact that the table is still open gives us protection from concurrent DDL statements. */ - VOID(pthread_mutex_lock(&LOCK_open)); + mysql_mutex_lock(&LOCK_open); wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); DBUG_EXECUTE_IF("sleep_alter_enable_indexes", my_sleep(6000000);); error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); /* COND_refresh will be signaled in close_thread_tables() */ break; case DISABLE: - VOID(pthread_mutex_lock(&LOCK_open)); + mysql_mutex_lock(&LOCK_open); wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); error=table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); /* COND_refresh will be signaled in close_thread_tables() */ break; @@ -6811,7 +6753,7 @@ view_err: table->alias); } - VOID(pthread_mutex_lock(&LOCK_open)); + mysql_mutex_lock(&LOCK_open); /* Unlike to the above case close_cached_table() below will remove ALL instances of TABLE from table cache (it will also remove table lock @@ -6850,8 +6792,8 @@ view_err: else if (Table_triggers_list::change_table_name(thd, db, table_name, new_db, new_alias)) { - VOID(mysql_rename_table(old_db_type, new_db, new_alias, db, - table_name, 0)); + (void) mysql_rename_table(old_db_type, new_db, new_alias, db, + table_name, 0); error= -1; } } @@ -6878,7 +6820,7 @@ view_err: } if (name_lock) unlink_open_table(thd, name_lock, FALSE); - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); table_list->table= NULL; // For query cache query_cache_invalidate3(thd, table_list, 0); DBUG_RETURN(error); @@ -7239,9 +7181,9 @@ view_err: } else { - VOID(pthread_mutex_lock(&LOCK_open)); + mysql_mutex_lock(&LOCK_open); wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); thd_proc_info(thd, "manage keys"); alter_table_manage_keys(table, table->file->indexes_are_disabled(), alter_info->keys_onoff); @@ -7356,8 +7298,8 @@ view_err: /* Should pass the 'new_name' as we store table name in the cache */ if (rename_temporary_table(thd, new_table, new_db, new_name)) goto err1; - /* We don't replicate alter table statement on temporary tables */ - if (!thd->current_stmt_binlog_row_based && + + if (!thd->is_current_stmt_binlog_format_row() && write_bin_log(thd, TRUE, thd->query(), thd->query_length())) DBUG_RETURN(TRUE); goto end_temporary; @@ -7372,11 +7314,11 @@ view_err: intern_close_table(new_table); my_free(new_table,MYF(0)); } - VOID(pthread_mutex_lock(&LOCK_open)); + mysql_mutex_lock(&LOCK_open); if (error) { - VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP)); - VOID(pthread_mutex_unlock(&LOCK_open)); + (void) quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP); + mysql_mutex_unlock(&LOCK_open); goto err; } @@ -7431,7 +7373,7 @@ view_err: FN_TO_IS_TMP)) { error=1; - VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP)); + (void) quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP); } else if (mysql_rename_table(new_db_type, new_db, tmp_name, new_db, new_alias, FN_FROM_IS_TMP) || @@ -7444,10 +7386,10 @@ view_err: { /* Try to get everything back. */ error=1; - VOID(quick_rm_table(new_db_type,new_db,new_alias, 0)); - VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP)); - VOID(mysql_rename_table(old_db_type, db, old_name, db, alias, - FN_FROM_IS_TMP)); + (void) quick_rm_table(new_db_type,new_db,new_alias, 0); + (void) quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP); + (void) mysql_rename_table(old_db_type, db, old_name, db, alias, + FN_FROM_IS_TMP); } if (error) @@ -7499,7 +7441,7 @@ view_err: } } - VOID(quick_rm_table(old_db_type, db, old_name, FN_IS_TMP)); + (void) quick_rm_table(old_db_type, db, old_name, FN_IS_TMP); if (thd->locked_tables && new_name == table_name && new_db == db) { @@ -7509,7 +7451,7 @@ view_err: if (error) goto err_with_placeholders; } - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); thd_proc_info(thd, "end"); @@ -7520,7 +7462,7 @@ view_err: db, table_name); DBUG_ASSERT(!(mysql_bin_log.is_open() && - thd->current_stmt_binlog_row_based && + thd->is_current_stmt_binlog_format_row() && (create_info->options & HA_LEX_CREATE_TMP_TABLE))); if (write_bin_log(thd, TRUE, thd->query(), thd->query_length())) DBUG_RETURN(TRUE); @@ -7557,10 +7499,10 @@ view_err: from the list of open tables and table cache. If we are not under LOCK TABLES we can rely on close_thread_tables() doing this job. */ - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); unlink_open_table(thd, table, FALSE); unlink_open_table(thd, name_lock, FALSE); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); } end_temporary: @@ -7578,10 +7520,8 @@ err1: close_temporary_table(thd, new_table, 1, 1); } else - VOID(quick_rm_table(new_db_type, new_db, tmp_name, - create_info->frm_only - ? FN_IS_TMP | FRM_ONLY - : FN_IS_TMP)); + (void) quick_rm_table(new_db_type, new_db, tmp_name, + create_info->frm_only ? FN_IS_TMP | FRM_ONLY : FN_IS_TMP); err: /* @@ -7619,9 +7559,9 @@ err: } if (name_lock) { - pthread_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); unlink_open_table(thd, name_lock, FALSE); - pthread_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); } DBUG_RETURN(TRUE); @@ -7634,7 +7574,7 @@ err_with_placeholders: unlink_open_table(thd, table, FALSE); if (name_lock) unlink_open_table(thd, name_lock, FALSE); - VOID(pthread_mutex_unlock(&LOCK_open)); + mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(TRUE); } /* mysql_alter_table */ |