1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Manual merge/pull from mysql-next-mr.

Conflicts:
  - sql/sql_insert.cc
This commit is contained in:
Alexander Nozdrin
2009-11-25 18:03:05 +03:00
161 changed files with 1611 additions and 1362 deletions

View File

@ -438,7 +438,7 @@ found:
oldest_unused_share->next)
{
pthread_mutex_lock(&oldest_unused_share->mutex);
VOID(my_hash_delete(&table_def_cache, (uchar*) oldest_unused_share));
my_hash_delete(&table_def_cache, (uchar*) oldest_unused_share);
}
DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u",
@ -714,7 +714,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
TABLE_LIST table_list;
DBUG_ENTER("list_open_tables");
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
bzero((char*) &table_list,sizeof(table_list));
start_list= &open_list;
open_list=0;
@ -767,7 +767,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
start_list= &(*start_list)->next;
*start_list=0;
}
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(open_list);
}
@ -787,7 +787,7 @@ void intern_close_table(TABLE *table)
free_io_cache(table);
delete table->triggers;
if (table->file) // Not true if name lock
VOID(closefrm(table, 1)); // close file
(void) closefrm(table, 1); // close file
DBUG_VOID_RETURN;
}
@ -864,7 +864,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
DBUG_ASSERT(thd || (!wait_for_refresh && !tables));
if (!have_lock)
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
if (!tables)
{
refresh_version++; // Force close of open tables
@ -874,14 +874,14 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
if (my_hash_delete(&open_cache,(uchar*) unused_tables))
printf("Warning: Couldn't delete open table from hash\n");
#else
VOID(my_hash_delete(&open_cache,(uchar*) unused_tables));
(void) my_hash_delete(&open_cache,(uchar*) unused_tables);
#endif
}
/* Free table shares */
while (oldest_unused_share->next)
{
pthread_mutex_lock(&oldest_unused_share->mutex);
VOID(my_hash_delete(&table_def_cache, (uchar*) oldest_unused_share));
(void) my_hash_delete(&table_def_cache, (uchar*) oldest_unused_share);
}
DBUG_PRINT("tcache", ("incremented global refresh_version to: %lu",
refresh_version));
@ -1019,7 +1019,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
}
}
if (!have_lock)
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
if (wait_for_refresh)
{
pthread_mutex_lock(&thd->mysys_var->mutex);
@ -1049,7 +1049,7 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh,
bzero(&tmp, sizeof(TABLE_LIST));
if (!have_lock)
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
for (idx= 0; idx < table_def_cache.records; idx++)
{
@ -1082,7 +1082,7 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh,
result= close_cached_tables(thd, tables, TRUE, FALSE, FALSE);
if (!have_lock)
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
if (if_wait_for_refresh)
{
@ -1199,7 +1199,7 @@ static void close_open_tables(THD *thd)
safe_mutex_assert_not_owner(&LOCK_open);
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
DBUG_PRINT("info", ("thd->open_tables: 0x%lx", (long) thd->open_tables));
@ -1209,7 +1209,7 @@ static void close_open_tables(THD *thd)
/* Free tables to hold down open files */
while (open_cache.records > table_cache_size && unused_tables)
VOID(my_hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */
my_hash_delete(&open_cache,(uchar*) unused_tables); /* purecov: tested */
check_unused();
if (found_old_table)
{
@ -1217,7 +1217,7 @@ static void close_open_tables(THD *thd)
broadcast_refresh();
}
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
}
@ -1395,7 +1395,7 @@ bool close_thread_table(THD *thd, TABLE **table_ptr)
if (table->needs_reopen_or_name_lock() ||
thd->version != refresh_version || !table->db_stat)
{
VOID(my_hash_delete(&open_cache,(uchar*) table));
my_hash_delete(&open_cache,(uchar*) table);
found_old_table=1;
}
else
@ -1684,20 +1684,42 @@ TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name));
for (;;)
{
if (((! (res= find_table_in_global_list(table_list, d_name, t_name))) &&
(! (res= mysql_lock_have_duplicate(thd, table, table_list)))) ||
((!res->table || res->table != table->table) &&
(!check_alias || !(lower_case_table_names ?
my_strcasecmp(files_charset_info, t_alias, res->alias) :
strcmp(t_alias, res->alias))) &&
res->select_lex && !res->select_lex->exclude_from_table_unique_test &&
!res->prelocking_placeholder))
/*
Table is unique if it is present only once in the global list
of tables and once in the list of table locks.
*/
if (! (res= find_table_in_global_list(table_list, d_name, t_name)) &&
! (res= mysql_lock_have_duplicate(thd, table, table_list)))
break;
/* Skip if same underlying table. */
if (res->table && (res->table == table->table))
goto next;
/* Skip if table alias does not match. */
if (check_alias)
{
if (lower_case_table_names ?
my_strcasecmp(files_charset_info, t_alias, res->alias) :
strcmp(t_alias, res->alias))
goto next;
}
/*
Skip if marked to be excluded (could be a derived table) or if
entry is a prelocking placeholder.
*/
if (res->select_lex &&
!res->select_lex->exclude_from_table_unique_test &&
!res->prelocking_placeholder)
break;
/*
If we found entry of this table or table of SELECT which already
processed in derived table or top select of multi-update/multi-delete
(exclude_from_table_unique_test) or prelocking placeholder.
*/
next:
table_list= res->next_global;
DBUG_PRINT("info",
("found same copy of table or table which we should skip"));
@ -2103,7 +2125,7 @@ void unlink_open_table(THD *thd, TABLE *find, bool unlock)
/* Remove table from open_tables list. */
*prev= list->next;
/* Close table. */
VOID(my_hash_delete(&open_cache,(uchar*) list)); // Close table
my_hash_delete(&open_cache,(uchar*) list); // Close table
}
else
{
@ -2145,14 +2167,14 @@ void drop_open_table(THD *thd, TABLE *table, const char *db_name,
else
{
handlerton *table_type= table->s->db_type();
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
/*
unlink_open_table() also tells threads waiting for refresh or close
that something has happened.
*/
unlink_open_table(thd, table, FALSE);
quick_rm_table(table_type, db_name, table_name, 0);
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
}
}
@ -2407,24 +2429,24 @@ bool lock_table_name_if_not_cached(THD *thd, const char *db,
DBUG_ENTER("lock_table_name_if_not_cached");
key_length= (uint)(strmov(strmov(key, db) + 1, table_name) - key) + 1;
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
if (my_hash_search(&open_cache, (uchar *)key, key_length))
{
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_PRINT("info", ("Table is cached, name-lock is not obtained"));
*table= 0;
DBUG_RETURN(FALSE);
}
if (!(*table= table_cache_insert_placeholder(thd, key, key_length)))
{
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(TRUE);
}
(*table)->open_placeholder= 1;
(*table)->next= thd->open_tables;
thd->open_tables= *table;
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(FALSE);
}
@ -2678,15 +2700,15 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
*/
TABLE tab;
table= &tab;
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
if (!open_unireg_entry(thd, table, table_list, alias,
key, key_length, mem_root, 0))
{
DBUG_ASSERT(table_list->view != 0);
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(0); // VIEW
}
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
}
}
/*
@ -2719,7 +2741,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
on disk.
*/
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
/*
If it's the first table from a list of tables used in a query,
@ -2737,7 +2759,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
/* Someone did a refresh while thread was opening tables */
if (refresh)
*refresh=1;
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(0);
}
@ -2803,7 +2825,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
/* Avoid self-deadlocks by detecting self-dependencies. */
if (table->open_placeholder && table->in_use == thd)
{
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
my_error(ER_UPDATE_TABLE_USED, MYF(0), table->s->table_name.str);
DBUG_RETURN(0);
}
@ -2844,7 +2866,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
}
else
{
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
}
/*
There is a refresh in progress for this table.
@ -2877,7 +2899,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
DBUG_PRINT("tcache", ("opening new table"));
/* Free cache if too big */
while (open_cache.records > table_cache_size && unused_tables)
VOID(my_hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */
my_hash_delete(&open_cache,(uchar*) unused_tables); /* purecov: tested */
if (table_list->create)
{
@ -2885,7 +2907,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if (check_if_table_exists(thd, table_list, &exists))
{
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(NULL);
}
@ -2896,7 +2918,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
*/
if (!(table= table_cache_insert_placeholder(thd, key, key_length)))
{
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(NULL);
}
/*
@ -2907,7 +2929,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table->open_placeholder= 1;
table->next= thd->open_tables;
thd->open_tables= table;
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(table);
}
/* Table exists. Let us try to open it. */
@ -2916,7 +2938,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
/* make a new table */
if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))
{
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(NULL);
}
@ -2925,7 +2947,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if (error > 0)
{
my_free((uchar*)table, MYF(0));
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(NULL);
}
if (table_list->view || error < 0)
@ -2938,18 +2960,18 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table_list->view= (LEX*)1;
my_free((uchar*)table, MYF(0));
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(0); // VIEW
}
DBUG_PRINT("info", ("inserting table '%s'.'%s' 0x%lx into the cache",
table->s->db.str, table->s->table_name.str,
(long) table));
VOID(my_hash_insert(&open_cache,(uchar*) table));
(void) my_hash_insert(&open_cache,(uchar*) table);
}
check_unused(); // Debugging call
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
if (refresh)
{
table->next=thd->open_tables; /* Link into simple list */
@ -3088,13 +3110,13 @@ bool reopen_table(TABLE *table)
fix_merge_after_open(table->child_l, table->child_last_l,
tmp.child_l, tmp.child_last_l))
{
VOID(closefrm(&tmp, 1)); // close file, free everything
(void) closefrm(&tmp, 1); // close file, free everything
goto end;
}
delete table->triggers;
if (table->file)
VOID(closefrm(table, 1)); // close file, free everything
(void) closefrm(table, 1); // close file, free everything
*table= tmp;
table->default_column_bitmaps();
@ -3335,7 +3357,7 @@ bool reopen_tables(THD *thd, bool get_locks, bool mark_share_as_old)
*/
if (table->child_l || table->parent)
detach_merge_children(table, TRUE);
VOID(my_hash_delete(&open_cache,(uchar*) table));
my_hash_delete(&open_cache,(uchar*) table);
error=1;
}
else
@ -3364,7 +3386,7 @@ bool reopen_tables(THD *thd, bool get_locks, bool mark_share_as_old)
{
while (err_tables)
{
VOID(my_hash_delete(&open_cache, (uchar*) err_tables));
my_hash_delete(&open_cache, (uchar*) err_tables);
err_tables= err_tables->next;
}
}
@ -3646,7 +3668,7 @@ TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name)
else
{
/* We already have a name lock, remove copy */
VOID(my_hash_delete(&open_cache,(uchar*) table));
my_hash_delete(&open_cache,(uchar*) table);
}
}
else
@ -4257,7 +4279,7 @@ void detach_merge_children(TABLE *table, bool clear_refs)
*/
if ((first_detach= parent->children_attached))
{
VOID(parent->file->extra(HA_EXTRA_DETACH_CHILDREN));
(void) parent->file->extra(HA_EXTRA_DETACH_CHILDREN);
parent->children_attached= FALSE;
DBUG_PRINT("myrg", ("detached parent: '%s'.'%s' 0x%lx", parent->s->db.str,
parent->s->table_name.str, (long) parent));
@ -8359,7 +8381,7 @@ my_bool mysql_rm_tmp_tables(void)
So we hide error messages which happnes during deleting of these
files(MYF(0)).
*/
VOID(my_delete(filePath, MYF(0)));
(void) my_delete(filePath, MYF(0));
}
}
my_dirend(dirp);
@ -8401,7 +8423,7 @@ void remove_db_from_cache(const char *db)
}
}
while (unused_tables && !unused_tables->s->version)
VOID(my_hash_delete(&open_cache,(uchar*) unused_tables));
my_hash_delete(&open_cache,(uchar*) unused_tables);
}
@ -8525,7 +8547,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
}
}
while (unused_tables && !unused_tables->s->version)
VOID(my_hash_delete(&open_cache,(uchar*) unused_tables));
my_hash_delete(&open_cache,(uchar*) unused_tables);
DBUG_PRINT("info", ("Removing table from table_def_cache"));
/* Remove table from table definition cache if it's not in use */
@ -8538,7 +8560,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
if (share->ref_count == 0)
{
pthread_mutex_lock(&share->mutex);
VOID(my_hash_delete(&table_def_cache, (uchar*) share));
my_hash_delete(&table_def_cache, (uchar*) share);
}
}
@ -8715,12 +8737,12 @@ int abort_and_upgrade_lock(ALTER_PARTITION_PARAM_TYPE *lpt)
DBUG_ENTER("abort_and_upgrade_locks");
lpt->old_lock_type= lpt->table->reginfo.lock_type;
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
/* If MERGE child, forward lock handling to parent. */
mysql_lock_abort(lpt->thd, lpt->table->parent ? lpt->table->parent :
lpt->table, TRUE);
VOID(remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name, flags));
VOID(pthread_mutex_unlock(&LOCK_open));
(void) remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name, flags);
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(0);
}
@ -8742,10 +8764,10 @@ int abort_and_upgrade_lock(ALTER_PARTITION_PARAM_TYPE *lpt)
/* purecov: begin deadcode */
void close_open_tables_and_downgrade(ALTER_PARTITION_PARAM_TYPE *lpt)
{
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name,
RTFC_WAIT_OTHER_THREAD_FLAG);
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
/* If MERGE child, forward lock handling to parent. */
mysql_lock_downgrade_write(lpt->thd, lpt->table->parent ? lpt->table->parent :
lpt->table, lpt->old_lock_type);
@ -8784,7 +8806,7 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table
DBUG_ENTER("mysql_wait_completed_table");
key_length=(uint) (strmov(strmov(key,lpt->db)+1,lpt->table_name)-key)+1;
VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_lock(&LOCK_open);
HASH_SEARCH_STATE state;
for (table= (TABLE*) my_hash_first(&open_cache,(uchar*) key,key_length,
&state) ;
@ -8842,7 +8864,7 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table
*/
mysql_lock_abort(lpt->thd, my_table->parent ? my_table->parent : my_table,
FALSE);
VOID(pthread_mutex_unlock(&LOCK_open));
pthread_mutex_unlock(&LOCK_open);
DBUG_VOID_RETURN;
}