summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorunknown <jani@a88-113-38-195.elisa-laajakaista.fi>2007-05-24 13:24:36 +0300
committerunknown <jani@a88-113-38-195.elisa-laajakaista.fi>2007-05-24 13:24:36 +0300
commit69ac4cde16515b451cd8ddd4f489c75d0f821299 (patch)
tree94027c861a0c3fd6ad62c4bee7ae5f7b1088f056 /sql/sql_base.cc
parent0b8ce7cd6ed48d69417b681023c36781abd54cfe (diff)
parent1629d809edeb96488e40c5753061d71676d9585b (diff)
downloadmariadb-git-69ac4cde16515b451cd8ddd4f489c75d0f821299.tar.gz
Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel BitKeeper/etc/ignore: auto-union client/mysql.cc: Auto merged client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged extra/comp_err.c: Auto merged include/decimal.h: Auto merged include/my_getopt.h: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged mysys/array.c: Auto merged mysys/hash.c: Auto merged mysys/typelib.c: Auto merged sql/derror.cc: Auto merged sql/event_data_objects.cc: Auto merged sql/event_queue.cc: Auto merged sql/field.cc: Auto merged sql/filesort.cc: Auto merged sql/ha_ndbcluster.h: Auto merged sql/ha_ndbcluster_binlog.cc: Auto merged sql/ha_partition.cc: Auto merged sql/ha_partition.h: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_subselect.cc: Auto merged sql/item_sum.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/my_decimal.cc: Auto merged sql/my_decimal.h: Auto merged sql/mysql_priv.h: Auto merged sql/opt_range.cc: Auto merged sql/opt_range.h: Auto merged sql/opt_sum.cc: Auto merged sql/protocol.cc: Auto merged sql/protocol.h: Auto merged sql/rpl_utility.h: Auto merged sql/slave.cc: Auto merged sql/sp.cc: Auto merged sql/sp_head.cc: Auto merged sql/sp_head.h: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_connect.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_partition.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_trigger.cc: Auto merged sql/sql_union.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_view.cc: Auto merged sql/structs.h: Auto merged sql/table.h: Auto merged sql/tztime.cc: Auto merged sql/unireg.cc: Auto merged storage/example/ha_example.cc: Auto merged storage/federated/ha_federated.cc: Auto merged storage/heap/ha_heap.cc: Auto merged storage/innobase/handler/ha_innodb.h: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisam/sort.c: Auto merged storage/myisammrg/ha_myisammrg.cc: Auto merged storage/ndb/tools/restore/consumer_restore.cpp: Auto merged strings/decimal.c: Auto merged strings/strtod.c: Auto merged include/hash.h: Manual merge with 5.1 main tree. mysys/my_getopt.c: Manual merge with 5.1 main tree. sql/field.h: Manual merge with 5.1 main tree. sql/ha_ndbcluster.cc: Manual merge with 5.1 main tree. sql/item_cmpfunc.h: Manual merge with 5.1 main tree. sql/item_create.cc: Manual merge with 5.1 main tree. sql/item_func.h: Manual merge with 5.1 main tree. sql/key.cc: Manual merge with 5.1 main tree. sql/lock.cc: Manual merge with 5.1 main tree. sql/mysqld.cc: Manual merge with 5.1 main tree. sql/set_var.cc: Manual merge with 5.1 main tree. sql/set_var.h: Manual merge with 5.1 main tree. sql/sql_base.cc: Manual merge with 5.1 main tree. sql/sql_handler.cc: Manual merge with 5.1 main tree. sql/sql_insert.cc: Manual merge with 5.1 main tree. sql/sql_plugin.cc: Manual merge with 5.1 main tree. sql/sql_table.cc: Manual merge with 5.1 main tree. sql/sql_yacc.yy: Manual merge with 5.1 main tree. sql/table.cc: Manual merge with 5.1 main tree. storage/innobase/handler/ha_innodb.cc: Manual merge with 5.1 main tree. storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Manual merge with 5.1 main tree. storage/ndb/tools/restore/restore_main.cpp: Manual merge with 5.1 main tree.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc105
1 files changed, 53 insertions, 52 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 14edd460bc4..3cf0432560d 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -104,19 +104,19 @@ static bool
has_two_write_locked_tables_with_auto_increment(TABLE_LIST *tables);
-extern "C" byte *table_cache_key(const byte *record,uint *length,
+extern "C" uchar *table_cache_key(const uchar *record, size_t *length,
my_bool not_used __attribute__((unused)))
{
TABLE *entry=(TABLE*) record;
*length= entry->s->table_cache_key.length;
- return (byte*) entry->s->table_cache_key.str;
+ return (uchar*) entry->s->table_cache_key.str;
}
bool table_cache_init(void)
{
return hash_init(&open_cache, &my_charset_bin, table_cache_size+16,
- 0, 0,table_cache_key,
+ 0, 0, table_cache_key,
(hash_free_key) free_cache_entry, 0) != 0;
}
@@ -243,12 +243,12 @@ uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
Functions to handle table definition cach (TABLE_SHARE)
*****************************************************************************/
-extern "C" byte *table_def_key(const byte *record, uint *length,
+extern "C" uchar *table_def_key(const uchar *record, size_t *length,
my_bool not_used __attribute__((unused)))
{
TABLE_SHARE *entry=(TABLE_SHARE*) record;
*length= entry->table_cache_key.length;
- return (byte*) entry->table_cache_key.str;
+ return (uchar*) entry->table_cache_key.str;
}
@@ -334,7 +334,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
*error= 0;
/* Read table definition from cache */
- if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(byte*) key,
+ if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key,
key_length)))
goto found;
@@ -351,7 +351,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
pthread_mutex_unlock(&LOCK_open);
pthread_mutex_lock(&LOCK_open);
/* Check that another thread didn't insert the same table in between */
- if ((old_share= hash_search(&table_def_cache, (byte*) key, key_length)))
+ if ((old_share= hash_search(&table_def_cache, (uchar*) key, key_length)))
{
(void) pthread_mutex_lock(&share->mutex);
free_table_share(share);
@@ -381,7 +381,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
*/
assign_new_table_id(share);
- if (my_hash_insert(&table_def_cache, (byte*) share))
+ if (my_hash_insert(&table_def_cache, (uchar*) share))
{
#ifdef WAITING_FOR_TABLE_DEF_CACHE_STAGE_3
pthread_mutex_unlock(&LOCK_open);
@@ -407,7 +407,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
(void) pthread_mutex_lock(&share->mutex);
#endif
*error= share->error;
- (void) hash_delete(&table_def_cache, (byte*) share);
+ (void) hash_delete(&table_def_cache, (uchar*) share);
DBUG_RETURN(0);
}
share->ref_count++; // Mark in use
@@ -462,7 +462,7 @@ found:
oldest_unused_share->next)
{
pthread_mutex_lock(&oldest_unused_share->mutex);
- VOID(hash_delete(&table_def_cache, (byte*) oldest_unused_share));
+ VOID(hash_delete(&table_def_cache, (uchar*) oldest_unused_share));
}
DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u",
@@ -585,7 +585,7 @@ void release_table_share(TABLE_SHARE *share, enum release_type type)
if (to_be_deleted)
{
DBUG_PRINT("info", ("Deleting share"));
- hash_delete(&table_def_cache, (byte*) share);
+ hash_delete(&table_def_cache, (uchar*) share);
DBUG_VOID_RETURN;
}
pthread_mutex_unlock(&share->mutex);
@@ -611,13 +611,13 @@ void release_table_share(TABLE_SHARE *share, enum release_type type)
This code is execured when someone does FLUSH TABLES while on has
locked tables.
*/
- (void) hash_search(&def_cache,(byte*) key,key_length);
- hash_replace(&def_cache, def_cache.current_record,(byte*) name_lock);
+ (void) hash_search(&def_cache,(uchar*) key,key_length);
+ hash_replace(&def_cache, def_cache.current_record,(uchar*) name_lock);
}
else
{
/* Remove table definition */
- hash_delete(&def_cache,(byte*) share);
+ hash_delete(&def_cache,(uchar*) share);
}
pthread_mutex_unlock(&LOCK_open);
free_table_share(share);
@@ -662,7 +662,7 @@ TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name)
table_list.db= (char*) db;
table_list.table_name= (char*) table_name;
key_length= create_table_def_key((THD*) 0, key, &table_list, 0);
- return (TABLE_SHARE*) hash_search(&table_def_cache,(byte*) key, key_length);
+ return (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, key_length);
}
@@ -842,7 +842,7 @@ static void free_cache_entry(TABLE *table)
}
check_unused(); // consisty check
}
- my_free((gptr) table,MYF(0));
+ my_free((uchar*) table,MYF(0));
DBUG_VOID_RETURN;
}
@@ -854,7 +854,7 @@ void free_io_cache(TABLE *table)
if (table->sort.io_cache)
{
close_cached_file(table->sort.io_cache);
- my_free((gptr) table->sort.io_cache,MYF(0));
+ my_free((uchar*) table->sort.io_cache,MYF(0));
table->sort.io_cache=0;
}
DBUG_VOID_RETURN;
@@ -883,17 +883,17 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
while (unused_tables)
{
#ifdef EXTRA_DEBUG
- if (hash_delete(&open_cache,(byte*) unused_tables))
+ if (hash_delete(&open_cache,(uchar*) unused_tables))
printf("Warning: Couldn't delete open table from hash\n");
#else
- VOID(hash_delete(&open_cache,(byte*) unused_tables));
+ VOID(hash_delete(&open_cache,(uchar*) unused_tables));
#endif
}
/* Free table shares */
while (oldest_unused_share->next)
{
pthread_mutex_lock(&oldest_unused_share->mutex);
- VOID(hash_delete(&table_def_cache, (byte*) oldest_unused_share));
+ VOID(hash_delete(&table_def_cache, (uchar*) oldest_unused_share));
}
}
else
@@ -1232,7 +1232,7 @@ void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived)
/* Free tables to hold down open files */
while (open_cache.records > table_cache_size && unused_tables)
- VOID(hash_delete(&open_cache,(byte*) unused_tables)); /* purecov: tested */
+ VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */
check_unused();
if (found_old_table)
{
@@ -1271,7 +1271,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(hash_delete(&open_cache,(byte*) table));
+ VOID(hash_delete(&open_cache,(uchar*) table));
found_old_table=1;
}
else
@@ -1835,7 +1835,7 @@ void unlink_open_table(THD *thd, TABLE *find, bool unlock)
{
if (unlock && thd->locked_tables)
mysql_lock_remove(thd, thd->locked_tables,list);
- VOID(hash_delete(&open_cache,(byte*) list)); // Close table
+ VOID(hash_delete(&open_cache,(uchar*) list)); // Close table
}
else
{
@@ -2058,7 +2058,7 @@ TABLE *table_cache_insert_placeholder(THD *thd, const char *key,
table->in_use= thd;
table->locked_by_name=1;
- if (my_hash_insert(&open_cache, (byte*)table))
+ if (my_hash_insert(&open_cache, (uchar*)table))
{
my_free((gptr) table, MYF(0));
DBUG_RETURN(NULL);
@@ -2100,7 +2100,7 @@ bool lock_table_name_if_not_cached(THD *thd, const char *db,
key_length= (uint)(strmov(strmov(key, db) + 1, table_name) - key) + 1;
VOID(pthread_mutex_lock(&LOCK_open));
- if (hash_search(&open_cache, (byte *)key, key_length))
+ if (hash_search(&open_cache, (uchar *)key, key_length))
{
VOID(pthread_mutex_unlock(&LOCK_open));
DBUG_PRINT("info", ("Table is cached, name-lock is not obtained"));
@@ -2232,7 +2232,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
*refresh=0;
/* an open table operation needs a lot of the stack space */
- if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (char *)&alias))
+ if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (uchar *)&alias))
DBUG_RETURN(0);
if (thd->killed)
@@ -2452,10 +2452,10 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
an implicit "pending locks queue" - see
wait_for_locked_table_names for details.
*/
- for (table= (TABLE*) hash_first(&open_cache, (byte*) key, key_length,
+ for (table= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length,
&state);
table && table->in_use ;
- table= (TABLE*) hash_next(&open_cache, (byte*) key, key_length,
+ table= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length,
&state))
{
/*
@@ -2560,7 +2560,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
int error;
/* Free cache if too big */
while (open_cache.records > table_cache_size && unused_tables)
- VOID(hash_delete(&open_cache,(byte*) unused_tables)); /* purecov: tested */
+ VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */
if (table_list->create)
{
@@ -2607,7 +2607,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
mem_root, (flags & OPEN_VIEW_NO_PARSE));
if (error > 0)
{
- my_free((gptr)table, MYF(0));
+ my_free((uchar*)table, MYF(0));
VOID(pthread_mutex_unlock(&LOCK_open));
DBUG_RETURN(NULL);
}
@@ -2620,12 +2620,12 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if (error < 0)
table_list->view= (st_lex*)1;
- my_free((gptr)table, MYF(0));
+ my_free((uchar*)table, MYF(0));
VOID(pthread_mutex_unlock(&LOCK_open));
DBUG_RETURN(0); // VIEW
}
DBUG_PRINT("info", ("inserting table 0x%lx into the cache", (long) table));
- VOID(my_hash_insert(&open_cache,(byte*) table));
+ VOID(my_hash_insert(&open_cache,(uchar*) table));
}
check_unused(); // Debugging call
@@ -2863,7 +2863,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh)
if (!tables || (!db_stat && reopen_table(table)))
{
my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias);
- VOID(hash_delete(&open_cache,(byte*) table));
+ VOID(hash_delete(&open_cache,(uchar*) table));
error=1;
}
else
@@ -2894,7 +2894,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh)
}
if (get_locks && tables)
{
- my_afree((gptr) tables);
+ my_afree((uchar*) tables);
}
broadcast_refresh();
*prev=0;
@@ -2991,10 +2991,10 @@ bool table_is_used(TABLE *table, bool wait_for_name_lock)
DBUG_PRINT("loop", ("table_name: %s", table->alias));
HASH_SEARCH_STATE state;
- for (TABLE *search= (TABLE*) hash_first(&open_cache, (byte*) key,
+ for (TABLE *search= (TABLE*) hash_first(&open_cache, (uchar*) key,
key_length, &state);
search ;
- search= (TABLE*) hash_next(&open_cache, (byte*) key,
+ search= (TABLE*) hash_next(&open_cache, (uchar*) key,
key_length, &state))
{
DBUG_PRINT("info", ("share: 0x%lx locked_by_logger: %d "
@@ -3108,7 +3108,7 @@ TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name)
else
{
/* We already have a name lock, remove copy */
- VOID(hash_delete(&open_cache,(byte*) table));
+ VOID(hash_delete(&open_cache,(uchar*) table));
}
}
else
@@ -3122,7 +3122,7 @@ TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name)
broadcast_refresh();
if (thd->locked_tables && thd->locked_tables->table_count == 0)
{
- my_free((gptr) thd->locked_tables,MYF(0));
+ my_free((uchar*) thd->locked_tables,MYF(0));
thd->locked_tables=0;
}
DBUG_RETURN(found);
@@ -4524,7 +4524,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
field_ptr= table->field + cached_field_index;
else if (table->s->name_hash.records)
{
- field_ptr= (Field**) hash_search(&table->s->name_hash, (byte*) name,
+ field_ptr= (Field**) hash_search(&table->s->name_hash, (uchar*) name,
length);
if (field_ptr)
{
@@ -4732,7 +4732,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
else
{
if (thd->mark_used_columns == MARK_COLUMNS_READ)
- it->walk(&Item::register_field_in_read_map, 1, (byte *) 0);
+ it->walk(&Item::register_field_in_read_map, 1, (uchar *) 0);
}
}
else
@@ -4771,7 +4771,7 @@ Field *find_field_in_table_sef(TABLE *table, const char *name)
Field **field_ptr;
if (table->s->name_hash.records)
{
- field_ptr= (Field**)hash_search(&table->s->name_hash,(byte*) name,
+ field_ptr= (Field**)hash_search(&table->s->name_hash,(uchar*) name,
strlen(name));
if (field_ptr)
{
@@ -6863,14 +6863,15 @@ my_bool mysql_rm_tmp_tables(void)
(file->name[1] == '.' && !file->name[2])))
continue;
- if (!bcmp(file->name,tmp_file_prefix,tmp_file_prefix_length))
+ if (!bcmp((uchar*) file->name, (uchar*) tmp_file_prefix,
+ tmp_file_prefix_length))
{
char *ext= fn_ext(file->name);
uint ext_len= strlen(ext);
uint filePath_len= my_snprintf(filePath, sizeof(filePath),
"%s%c%s", tmpdir, FN_LIBCHAR,
file->name);
- if (!bcmp(reg_ext, ext, ext_len))
+ if (!bcmp((uchar*) reg_ext, (uchar*) ext, ext_len))
{
handler *handler_file= 0;
/* We should cut file extention before deleting of table */
@@ -6933,7 +6934,7 @@ void remove_db_from_cache(const char *db)
}
}
while (unused_tables && !unused_tables->s->version)
- VOID(hash_delete(&open_cache,(byte*) unused_tables));
+ VOID(hash_delete(&open_cache,(uchar*) unused_tables));
}
@@ -6949,7 +6950,7 @@ void flush_tables()
{
(void) pthread_mutex_lock(&LOCK_open);
while (unused_tables)
- hash_delete(&open_cache,(byte*) unused_tables);
+ hash_delete(&open_cache,(uchar*) unused_tables);
(void) pthread_mutex_unlock(&LOCK_open);
}
@@ -6986,10 +6987,10 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
HASH_SEARCH_STATE state;
result= signalled= 0;
- for (table= (TABLE*) hash_first(&open_cache, (byte*) key, key_length,
+ for (table= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length,
&state);
table;
- table= (TABLE*) hash_next(&open_cache, (byte*) key, key_length,
+ table= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length,
&state))
{
THD *in_use;
@@ -7044,11 +7045,11 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
}
}
while (unused_tables && !unused_tables->s->version)
- VOID(hash_delete(&open_cache,(byte*) unused_tables));
+ VOID(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 */
- if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(byte*) key,
+ if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key,
key_length)))
{
DBUG_PRINT("info", ("share version: %lu ref_count: %u",
@@ -7057,7 +7058,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(hash_delete(&table_def_cache, (byte*) share));
+ VOID(hash_delete(&table_def_cache, (uchar*) share));
}
}
@@ -7299,10 +7300,10 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table
key_length=(uint) (strmov(strmov(key,lpt->db)+1,lpt->table_name)-key)+1;
VOID(pthread_mutex_lock(&LOCK_open));
HASH_SEARCH_STATE state;
- for (table= (TABLE*) hash_first(&open_cache,(byte*) key,key_length,
+ for (table= (TABLE*) hash_first(&open_cache,(uchar*) key,key_length,
&state) ;
table;
- table= (TABLE*) hash_next(&open_cache,(byte*) key,key_length,
+ table= (TABLE*) hash_next(&open_cache,(uchar*) key,key_length,
&state))
{
THD *in_use= table->in_use;