summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc18
-rw-r--r--sql/filesort.cc2
-rw-r--r--sql/gen_lex_hash.cc2
-rw-r--r--sql/ha_innodb.cc12
-rw-r--r--sql/ha_isammrg.cc12
-rw-r--r--sql/ha_myisam.cc36
-rw-r--r--sql/ha_myisammrg.cc30
-rw-r--r--sql/hash_filo.h4
-rw-r--r--sql/hostname.cc2
-rw-r--r--sql/item_cmpfunc.h6
-rw-r--r--sql/item_func.cc63
-rw-r--r--sql/item_func.h2
-rw-r--r--sql/log.cc20
-rw-r--r--sql/log_event.cc32
-rw-r--r--sql/mysql_priv.h9
-rw-r--r--sql/mysqld.cc38
-rw-r--r--sql/opt_range.cc55
-rw-r--r--sql/repl_failsafe.cc9
-rw-r--r--sql/slave.cc6
-rw-r--r--sql/slave.h4
-rw-r--r--sql/sql_acl.cc2
-rw-r--r--sql/sql_base.cc6
-rw-r--r--sql/sql_cache.cc126
-rw-r--r--sql/sql_cache.h2
-rw-r--r--sql/sql_class.cc27
-rw-r--r--sql/sql_delete.cc26
-rw-r--r--sql/sql_insert.cc4
-rw-r--r--sql/sql_manager.cc2
-rw-r--r--sql/sql_parse.cc10
-rw-r--r--sql/sql_udf.cc2
-rw-r--r--sql/sql_update.cc59
31 files changed, 327 insertions, 301 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 42ddcc3b9d2..14cdc2dba95 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -3703,12 +3703,12 @@ int Field_string::pack_cmp(const char *b, uint length)
}
-uint Field_string::packed_col_length(const char *ptr, uint length)
+uint Field_string::packed_col_length(const char *data_ptr, uint length)
{
if (length > 255)
- return uint2korr(ptr)+2;
+ return uint2korr(data_ptr)+2;
else
- return (uint) ((uchar) *ptr)+1;
+ return (uint) ((uchar) *data_ptr)+1;
}
uint Field_string::max_packed_col_length(uint max_length)
@@ -3922,12 +3922,12 @@ int Field_varstring::pack_cmp(const char *b, uint key_length)
return my_sortncmp(a,a_length, b,b_length);
}
-uint Field_varstring::packed_col_length(const char *ptr, uint length)
+uint Field_varstring::packed_col_length(const char *data_ptr, uint length)
{
if (length > 255)
- return uint2korr(ptr)+2;
+ return uint2korr(data_ptr)+2;
else
- return (uint) ((uchar) *ptr)+1;
+ return (uint) ((uchar) *data_ptr)+1;
}
uint Field_varstring::max_packed_col_length(uint max_length)
@@ -4408,12 +4408,12 @@ char *Field_blob::pack_key_from_key_image(char *to, const char *from,
return to+length;
}
-uint Field_blob::packed_col_length(const char *ptr, uint length)
+uint Field_blob::packed_col_length(const char *data_ptr, uint length)
{
if (length > 255)
- return uint2korr(ptr)+2;
+ return uint2korr(data_ptr)+2;
else
- return (uint) ((uchar) *ptr)+1;
+ return (uint) ((uchar) *data_ptr)+1;
}
uint Field_blob::max_packed_col_length(uint max_length)
diff --git a/sql/filesort.cc b/sql/filesort.cc
index d8fcb0292ff..e42baf333a5 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -732,7 +732,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
org_max_rows=max_rows=param->max_rows;
if (init_queue(&queue,(uint) (Tb-Fb)+1,offsetof(BUFFPEK,key),0,
- (int (*) (void *, byte *,byte*))
+ (queue_compare)
(cmp=get_ptr_compare(sort_length)),(void*) &sort_length))
DBUG_RETURN(1); /* purecov: inspected */
for (buffpek= Fb ; buffpek <= Tb ; buffpek++)
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index c24e7b6d124..bd3d5e1bf7a 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -360,7 +360,7 @@ static void usage(int version)
}
-static my_bool
+extern "C" static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
{
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index b849bbb76b2..d06e0ab7b57 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -3344,7 +3344,7 @@ ha_innobase::estimate_number_of_rows(void)
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
dict_index_t* index;
ulonglong estimate;
- ulonglong data_file_length;
+ ulonglong local_data_file_length;
/* Warning: since it is not sure that MySQL calls external_lock
before calling this function, the trx field in prebuilt can be
@@ -3354,7 +3354,7 @@ ha_innobase::estimate_number_of_rows(void)
index = dict_table_get_first_index_noninline(prebuilt->table);
- data_file_length = ((ulonglong) index->stat_n_leaf_pages)
+ local_data_file_length = ((ulonglong) index->stat_n_leaf_pages)
* UNIV_PAGE_SIZE;
/* Calculate a minimum length for a clustered index record and from
@@ -3363,7 +3363,7 @@ ha_innobase::estimate_number_of_rows(void)
by a threshold factor, we must add a safety factor 2 in front
of the formula below. */
- estimate = 2 * data_file_length / dict_index_calc_min_rec_len(index);
+ estimate = 2 * local_data_file_length / dict_index_calc_min_rec_len(index);
DBUG_RETURN((ha_rows) estimate);
}
@@ -3847,9 +3847,9 @@ innodb_show_status(
DBUG_ENTER("innodb_show_status");
if (innodb_skip) {
- fprintf(stderr,
- "Cannot call SHOW INNODB STATUS because skip-innodb is defined\n");
-
+ my_message(ER_NOT_SUPPORTED_YET,
+ "Cannot call SHOW INNODB STATUS because skip-innodb is defined",
+ MYF(0));
DBUG_RETURN(-1);
}
diff --git a/sql/ha_isammrg.cc b/sql/ha_isammrg.cc
index b110ffba2f9..94e394e7665 100644
--- a/sql/ha_isammrg.cc
+++ b/sql/ha_isammrg.cc
@@ -190,13 +190,15 @@ THR_LOCK_DATA **ha_isammrg::store_lock(THD *thd,
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
{
- MRG_TABLE *table;
+ MRG_TABLE *open_table;
- for (table=file->open_tables ; table != file->end_table ; table++)
+ for (open_table=file->open_tables ;
+ open_table != file->end_table ;
+ open_table++)
{
- *(to++)= &table->table->lock;
- if (lock_type != TL_IGNORE && table->table->lock.type == TL_UNLOCK)
- table->table->lock.type=lock_type;
+ *(to++)= &open_table->table->lock;
+ if (lock_type != TL_IGNORE && open_table->table->lock.type == TL_UNLOCK)
+ open_table->table->lock.type=lock_type;
}
return to;
}
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index f96ef7210ac..a92c4f64668 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -1004,7 +1004,7 @@ void ha_myisam::update_create_info(HA_CREATE_INFO *create_info)
}
-int ha_myisam::create(const char *name, register TABLE *table,
+int ha_myisam::create(const char *name, register TABLE *table_arg,
HA_CREATE_INFO *info)
{
int error;
@@ -1016,20 +1016,20 @@ int ha_myisam::create(const char *name, register TABLE *table,
MI_KEYDEF *keydef;
MI_COLUMNDEF *recinfo,*recinfo_pos;
MI_KEYSEG *keyseg;
- uint options=table->db_options_in_use;
+ uint options=table_arg->db_options_in_use;
DBUG_ENTER("ha_myisam::create");
type=HA_KEYTYPE_BINARY; // Keep compiler happy
if (!(my_multi_malloc(MYF(MY_WME),
- &recinfo,(table->fields*2+2)*sizeof(MI_COLUMNDEF),
- &keydef, table->keys*sizeof(MI_KEYDEF),
+ &recinfo,(table_arg->fields*2+2)*sizeof(MI_COLUMNDEF),
+ &keydef, table_arg->keys*sizeof(MI_KEYDEF),
&keyseg,
- ((table->key_parts + table->keys) * sizeof(MI_KEYSEG)),
+ ((table_arg->key_parts + table_arg->keys) * sizeof(MI_KEYSEG)),
0)))
DBUG_RETURN(1);
- pos=table->key_info;
- for (i=0; i < table->keys ; i++, pos++)
+ pos=table_arg->key_info;
+ for (i=0; i < table_arg->keys ; i++, pos++)
{
keydef[i].flag= (pos->flags & (HA_NOSAME | HA_FULLTEXT));
keydef[i].seg=keyseg;
@@ -1072,7 +1072,7 @@ int ha_myisam::create(const char *name, register TABLE *table,
{
keydef[i].seg[j].null_bit=field->null_bit;
keydef[i].seg[j].null_pos= (uint) (field->null_ptr-
- (uchar*) table->record[0]);
+ (uchar*) table_arg->record[0]);
}
else
{
@@ -1090,19 +1090,19 @@ int ha_myisam::create(const char *name, register TABLE *table,
keydef[i].seg[j].flag|=HA_BLOB_PART;
/* save number of bytes used to pack length */
keydef[i].seg[j].bit_start= (uint) (field->pack_length() -
- table->blob_ptr_size);
+ table_arg->blob_ptr_size);
}
}
keyseg+=pos->key_parts;
}
recpos=0; recinfo_pos=recinfo;
- while (recpos < (uint) table->reclength)
+ while (recpos < (uint) table_arg->reclength)
{
Field **field,*found=0;
- minpos=table->reclength; length=0;
+ minpos=table_arg->reclength; length=0;
- for (field=table->field ; *field ; field++)
+ for (field=table_arg->field ; *field ; field++)
{
if ((fieldpos=(*field)->offset()) >= recpos &&
fieldpos <= minpos)
@@ -1148,7 +1148,7 @@ int ha_myisam::create(const char *name, register TABLE *table,
{
recinfo_pos->null_bit=found->null_bit;
recinfo_pos->null_pos= (uint) (found->null_ptr-
- (uchar*) table->record[0]);
+ (uchar*) table_arg->record[0]);
}
else
{
@@ -1163,13 +1163,13 @@ int ha_myisam::create(const char *name, register TABLE *table,
}
MI_CREATE_INFO create_info;
bzero((char*) &create_info,sizeof(create_info));
- create_info.max_rows=table->max_rows;
- create_info.reloc_rows=table->min_rows;
+ create_info.max_rows=table_arg->max_rows;
+ create_info.reloc_rows=table_arg->min_rows;
create_info.auto_increment=(info->auto_increment_value ?
info->auto_increment_value -1 :
(ulonglong) 0);
- create_info.data_file_length= ((ulonglong) table->max_rows *
- table->avg_row_length);
+ create_info.data_file_length= ((ulonglong) table_arg->max_rows *
+ table_arg->avg_row_length);
create_info.raid_type=info->raid_type;
create_info.raid_chunks= (info->raid_chunks ? info->raid_chunks :
RAID_DEFAULT_CHUNKS);
@@ -1179,7 +1179,7 @@ int ha_myisam::create(const char *name, register TABLE *table,
create_info.index_file_name=info->index_file_name;
error=mi_create(fn_format(buff,name,"","",2+4),
- table->keys,keydef,
+ table_arg->keys,keydef,
(uint) (recinfo_pos-recinfo), recinfo,
0, (MI_UNIQUEDEF*) 0,
&create_info,
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index c35bf657445..281a4431045 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -262,13 +262,15 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd,
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
{
- MYRG_TABLE *table;
+ MYRG_TABLE *open_table;
- for (table=file->open_tables ; table != file->end_table ; table++)
+ for (open_table=file->open_tables ;
+ open_table != file->end_table ;
+ open_table++)
{
- *(to++)= &table->table->lock;
- if (lock_type != TL_IGNORE && table->table->lock.type == TL_UNLOCK)
- table->table->lock.type=lock_type;
+ *(to++)= &open_table->table->lock;
+ if (lock_type != TL_IGNORE && open_table->table->lock.type == TL_UNLOCK)
+ open_table->table->lock.type=lock_type;
}
return to;
}
@@ -279,14 +281,16 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info)
DBUG_ENTER("ha_myisammrg::update_create_info");
if (!(create_info->used_fields & HA_CREATE_USED_UNION))
{
- MYRG_TABLE *table;
+ MYRG_TABLE *open_table;
THD *thd=current_thd;
create_info->merge_list.next= &create_info->merge_list.first;
create_info->merge_list.elements=0;
- for (table=file->open_tables ; table != file->end_table ; table++)
+ for (open_table=file->open_tables ;
+ open_table != file->end_table ;
+ open_table++)
{
- char *name=table->table->filename;
+ char *name=open_table->table->filename;
char buff[FN_REFLEN];
TABLE_LIST *ptr;
if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
@@ -340,13 +344,15 @@ void ha_myisammrg::append_create_info(String *packet)
packet->append(get_type(&merge_insert_method,file->merge_insert_method-1));
}
packet->append(" UNION=(",8);
- MYRG_TABLE *table,*first;
+ MYRG_TABLE *open_table,*first;
- for (first=table=file->open_tables ; table != file->end_table ; table++)
+ for (first=open_table=file->open_tables ;
+ open_table != file->end_table ;
+ open_table++)
{
- char *name=table->table->filename;
+ char *name= open_table->table->filename;
fn_format(buff,name,"","",3);
- if (table != first)
+ if (open_table != first)
packet->append(',');
packet->append(buff,(uint) strlen(buff));
}
diff --git a/sql/hash_filo.h b/sql/hash_filo.h
index b8d45f0d3be..34584b45d8c 100644
--- a/sql/hash_filo.h
+++ b/sql/hash_filo.h
@@ -40,7 +40,7 @@ class hash_filo
{
const uint size, key_offset, key_length;
const hash_get_key get_key;
- void (*free_element)(void*);
+ hash_free_key free_element;
bool init;
hash_filo_element *first_link,*last_link;
@@ -49,7 +49,7 @@ public:
HASH cache;
hash_filo(uint size_arg, uint key_offset_arg , uint key_length_arg,
- hash_get_key get_key_arg,void (*free_element_arg)(void*))
+ hash_get_key get_key_arg, hash_free_key free_element_arg)
:size(size_arg), key_offset(key_offset_arg), key_length(key_length_arg),
get_key(get_key_arg), free_element(free_element_arg),init(0)
{
diff --git a/sql/hostname.cc b/sql/hostname.cc
index abccc466a22..be035e52ac1 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -63,7 +63,7 @@ bool hostname_cache_init()
if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE, offset,
sizeof(struct in_addr),NULL,
- (void (*)(void*)) free)))
+ (hash_free_key) free)))
return 1;
hostname_cache->clear();
return 0;
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 9d83a8a9673..214abff4b77 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -292,9 +292,9 @@ public:
virtual void set(uint pos,Item *item)=0;
virtual byte *get_value(Item *item)=0;
void sort()
- {
- qsort(base,used_count,size,compare);
- }
+ {
+ qsort(base,used_count,size,compare);
+ }
int find(Item *item);
};
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 7da5435276d..48b11efcace 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -711,13 +711,14 @@ double Item_func_rand::val()
}
else if (!thd->rand_used)
{
- // no need to send a Rand log event if seed was given eg: RAND(seed),
- // as it will be replicated in the query as such.
-
- // save the seed only the first time RAND() is used in the query
-
- // once events are forwarded rather than recreated,
- // the following can be skipped if inside the slave thread
+ /*
+ No need to send a Rand log event if seed was given eg: RAND(seed),
+ as it will be replicated in the query as such.
+
+ Save the seed only the first time RAND() is used in the query
+ Once events are forwarded rather than recreated,
+ the following can be skipped if inside the slave thread
+ */
thd->rand_used=1;
thd->rand_saved_seed1=thd->rand.seed1;
thd->rand_saved_seed2=thd->rand.seed2;
@@ -1957,13 +1958,13 @@ void Item_func_set_user_var::print(String *str)
user_var_entry *Item_func_get_user_var::get_entry()
{
- if (!entry || ! entry->value)
+ if (!var_entry || ! var_entry->value)
{
null_value=1;
return 0;
}
null_value=0;
- return entry;
+ return var_entry;
}
@@ -2032,8 +2033,8 @@ void Item_func_get_user_var::fix_length_and_dec()
maybe_null=1;
decimals=NOT_FIXED_DEC;
max_length=MAX_BLOB_WIDTH;
- if ((entry= get_variable(&thd->user_vars, name, 0)))
- const_var_flag= thd->query_id != entry->update_query_id;
+ if ((var_entry= get_variable(&thd->user_vars, name, 0)))
+ const_var_flag= thd->query_id != var_entry->update_query_id;
}
@@ -2208,18 +2209,18 @@ bool Item_func_match::fix_index()
{
List_iterator_fast<Item> li(fields);
Item_field *item;
- uint ft_to_key[MAX_KEY], ft_cnt[MAX_KEY], fts=0, key;
+ uint ft_to_key[MAX_KEY], ft_cnt[MAX_KEY], fts=0, keynr;
uint max_cnt=0, mkeys=0;
- if (this->key == NO_SUCH_KEY)
+ if (key == NO_SUCH_KEY)
return 0;
- for (key=0 ; key<table->keys ; key++)
+ for (keynr=0 ; keynr < table->keys ; keynr++)
{
- if ((table->key_info[key].flags & HA_FULLTEXT) &&
- (table->keys_in_use_for_query & (((key_map)1) << key)))
+ if ((table->key_info[keynr].flags & HA_FULLTEXT) &&
+ (table->keys_in_use_for_query & (((key_map)1) << keynr)))
{
- ft_to_key[fts]=key;
+ ft_to_key[fts]=keynr;
ft_cnt[fts]=0;
fts++;
}
@@ -2230,45 +2231,45 @@ bool Item_func_match::fix_index()
while ((item=(Item_field*)(li++)))
{
- for (key=0 ; key<fts ; key++)
+ for (keynr=0 ; keynr < fts ; keynr++)
{
- KEY *ft_key=&table->key_info[ft_to_key[key]];
+ KEY *ft_key=&table->key_info[ft_to_key[keynr]];
uint key_parts=ft_key->key_parts;
for (uint part=0 ; part < key_parts ; part++)
{
if (item->field->eq(ft_key->key_part[part].field))
- ft_cnt[key]++;
+ ft_cnt[keynr]++;
}
}
}
- for (key=0 ; key<fts ; key++)
+ for (keynr=0 ; keynr < fts ; keynr++)
{
- if (ft_cnt[key] > max_cnt)
+ if (ft_cnt[keynr] > max_cnt)
{
mkeys=0;
- max_cnt=ft_cnt[mkeys]=ft_cnt[key];
- ft_to_key[mkeys]=ft_to_key[key];
+ max_cnt=ft_cnt[mkeys]=ft_cnt[keynr];
+ ft_to_key[mkeys]=ft_to_key[keynr];
continue;
}
- if (max_cnt && ft_cnt[key] == max_cnt)
+ if (max_cnt && ft_cnt[keynr] == max_cnt)
{
mkeys++;
- ft_cnt[mkeys]=ft_cnt[key];
- ft_to_key[mkeys]=ft_to_key[key];
+ ft_cnt[mkeys]=ft_cnt[keynr];
+ ft_to_key[mkeys]=ft_to_key[keynr];
continue;
}
}
- for (key=0 ; key<=mkeys ; key++)
+ for (keynr=0 ; keynr <= mkeys ; keynr++)
{
// for now, partial keys won't work. SerG
if (max_cnt < fields.elements ||
- max_cnt < table->key_info[ft_to_key[key]].key_parts)
+ max_cnt < table->key_info[ft_to_key[keynr]].key_parts)
continue;
- this->key=ft_to_key[key];
+ key=ft_to_key[keynr];
return 0;
}
@@ -2276,7 +2277,7 @@ bool Item_func_match::fix_index()
err:
if (mode == FT_BOOL)
{
- this->key=NO_SUCH_KEY;
+ key=NO_SUCH_KEY;
return 0;
}
my_printf_error(ER_FT_MATCHING_KEY_NOT_FOUND,
diff --git a/sql/item_func.h b/sql/item_func.h
index 736616b016a..2e02d7cfd28 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -901,7 +901,7 @@ public:
class Item_func_get_user_var :public Item_func
{
LEX_STRING name;
- user_var_entry *entry;
+ user_var_entry *var_entry;
bool const_var_flag;
public:
diff --git a/sql/log.cc b/sql/log.cc
index 32c0f4417f1..28acdb71ef8 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1027,7 +1027,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
{
bool should_rotate = 0;
THD *thd=event_info->thd;
- const char* db = event_info->get_db();
+ const char *local_db = event_info->get_db();
#ifdef USING_TRANSACTIONS
IO_CACHE *file = ((event_info->get_cache_stmt()) ?
&thd->transaction.trans_log :
@@ -1037,7 +1037,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
#endif
if ((thd && !(thd->options & OPTION_BIN_LOG) &&
(thd->master_access & SUPER_ACL)) ||
- (db && !db_ok(db, binlog_do_db, binlog_ignore_db)))
+ (local_db && !db_ok(local_db, binlog_do_db, binlog_ignore_db)))
{
VOID(pthread_mutex_unlock(&LOCK_log));
return 0;
@@ -1237,7 +1237,7 @@ err:
*/
bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
- time_t query_start)
+ time_t query_start_arg)
{
bool error=0;
if (is_open())
@@ -1255,7 +1255,7 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
VOID(pthread_mutex_unlock(&LOCK_log));
return 0;
}
- if ((specialflag & SPECIAL_LONG_LOG_FORMAT) || query_start)
+ if ((specialflag & SPECIAL_LONG_LOG_FORMAT) || query_start_arg)
{
current_time=time(NULL);
if (current_time != last_time)
@@ -1283,13 +1283,13 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
thd->ip ? thd->ip : "") == (uint) -1)
tmp_errno=errno;
}
- if (query_start)
+ if (query_start_arg)
{
/* For slow query log */
if (my_b_printf(&log_file,
"# Query_time: %lu Lock_time: %lu Rows_sent: %lu Rows_examined: %lu\n",
- (ulong) (current_time - query_start),
- (ulong) (thd->time_after_lock - query_start),
+ (ulong) (current_time - query_start_arg),
+ (ulong) (thd->time_after_lock - query_start_arg),
(ulong) thd->sent_row_count,
(ulong) thd->examined_row_count) == (uint) -1)
tmp_errno=errno;
@@ -1316,11 +1316,11 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
}
if (thd->query_start_used)
{
- if (query_start != thd->query_start())
+ if (query_start_arg != thd->query_start())
{
- query_start=thd->query_start();
+ query_start_arg=thd->query_start();
end=strmov(end,",timestamp=");
- end=int10_to_str((long) query_start,end,10);
+ end=int10_to_str((long) query_start_arg,end,10);
}
}
if (end != buff)
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 871f72acbae..9d0c365505a 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -391,9 +391,9 @@ void Log_event::init_show_field_list(List<Item>* field_list)
/*
* only called by SHOW BINLOG EVENTS
*/
-int Log_event::net_send(THD* thd, const char* log_name, my_off_t pos)
+int Log_event::net_send(THD* thd_arg, const char* log_name, my_off_t pos)
{
- String* packet = &thd->packet;
+ String* packet = &thd_arg->packet;
const char* p = strrchr(log_name, FN_LIBCHAR);
const char* event_type;
if (p)
@@ -407,7 +407,7 @@ int Log_event::net_send(THD* thd, const char* log_name, my_off_t pos)
net_store_data(packet, server_id);
net_store_data(packet, (longlong) log_pos);
pack_info(packet);
- return my_net_write(&thd->net, (char*) packet->ptr(), packet->length());
+ return my_net_write(&thd_arg->net, (char*) packet->ptr(), packet->length());
}
#endif /* MYSQL_CLIENT */
@@ -1090,18 +1090,18 @@ char* sql_ex_info::init(char* buf,char* buf_end,bool use_new_format)
#ifndef MYSQL_CLIENT
-Load_log_event::Load_log_event(THD* thd, sql_exchange* ex,
+Load_log_event::Load_log_event(THD* thd_arg, sql_exchange* ex,
const char* db_arg, const char* table_name_arg,
List<Item>& fields_arg,
enum enum_duplicates handle_dup)
- :Log_event(thd),thread_id(thd->thread_id), num_fields(0),fields(0),
+ :Log_event(thd_arg),thread_id(thd_arg->thread_id), num_fields(0),fields(0),
field_lens(0),field_block_len(0),
table_name(table_name_arg ? table_name_arg : ""),
db(db_arg), fname(ex->file_name)
{
time_t end_time;
time(&end_time);
- exec_time = (ulong) (end_time - thd->start_time);
+ exec_time = (ulong) (end_time - thd_arg->start_time);
/* db can never be a zero pointer in 4.0 */
db_len = (uint32) strlen(db);
table_name_len = (uint32) strlen(table_name);
@@ -1170,8 +1170,8 @@ Load_log_event::Load_log_event(THD* thd, sql_exchange* ex,
*/
Load_log_event::Load_log_event(const char* buf, int event_len,
- bool old_format):
- Log_event(buf, old_format),num_fields(0),fields(0),
+ bool old_format)
+ :Log_event(buf, old_format),num_fields(0),fields(0),
field_lens(0),field_block_len(0),
table_name(0),db(0),fname(0)
{
@@ -1318,14 +1318,14 @@ void Log_event::set_log_pos(MYSQL_LOG* log)
}
-void Load_log_event::set_fields(List<Item> &fields)
+void Load_log_event::set_fields(List<Item> &field_list)
{
uint i;
- const char* field = this->fields;
- for (i = 0; i < num_fields; i++)
+ const char *field= fields;
+ for (i= 0; i < num_fields; i++)
{
- fields.push_back(new Item_field(db, table_name, field));
- field += field_lens[i] + 1;
+ field_list.push_back(new Item_field(db, table_name, field));
+ field+= field_lens[i] + 1;
}
}
@@ -1799,8 +1799,8 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
ex.field_term->length(0);
ex.skip_lines = skip_lines;
- List<Item> fields;
- set_fields(fields);
+ List<Item> field_list;
+ set_fields(field_list);
thd->slave_proxy_id = thd->thread_id;
if (net)
{
@@ -1811,7 +1811,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
*/
thd->net.pkt_nr = net->pkt_nr;
}
- if (mysql_load(thd, &ex, &tables, fields, handle_dup, net != 0,
+ if (mysql_load(thd, &ex, &tables, field_list, handle_dup, net != 0,
TL_WRITE))
thd->query_error = 1;
if (thd->cuted_fields)
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 05157cbd9b8..a763bdd35ad 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -311,9 +311,8 @@ void mysql_init_multi_delete(LEX *lex);
void init_max_user_conn(void);
void init_update_queries(void);
void free_max_user_conn(void);
-pthread_handler_decl(handle_one_connection,arg);
-pthread_handler_decl(handle_bootstrap,arg);
-sig_handler end_thread_signal(int sig);
+extern "C" pthread_handler_decl(handle_one_connection,arg);
+extern "C" pthread_handler_decl(handle_bootstrap,arg);
void end_thread(THD *thd,bool put_in_cache);
void flush_thread_cache();
void mysql_execute_command(void);
@@ -559,7 +558,7 @@ int write_record(TABLE *table,COPY_INFO *info);
extern ulong volatile manager_status;
extern bool volatile manager_thread_in_use, mqh_used;
extern pthread_t manager_thread;
-pthread_handler_decl(handle_manager, arg);
+extern "C" pthread_handler_decl(handle_manager, arg);
/* sql_test.cc */
#ifndef DBUG_OFF
@@ -736,7 +735,7 @@ timestamp_type str_to_TIME(const char *str, uint length, TIME *l_time,
int test_if_number(char *str,int *res,bool allow_wildcards);
void change_byte(byte *,uint,char,char);
-void unireg_abort(int exit_code);
+extern "C" void unireg_abort(int exit_code);
void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
SQL_SELECT *select,
int use_record_cache, bool print_errors);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 9e0dfe17f1b..ef097809cf3 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -444,20 +444,20 @@ pthread_cond_t eventShutdown;
#endif
static void start_signal_handler(void);
-static void *signal_hand(void *arg);
+extern "C" static pthread_handler_decl(signal_hand, arg);
static void set_options(void);
static void get_options(int argc,char **argv);
static char *get_relative_path(const char *path);
static void fix_paths(void);
-static pthread_handler_decl(handle_connections_sockets,arg);
-static pthread_handler_decl(kill_server_thread,arg);
+extern "C" static pthread_handler_decl(handle_connections_sockets,arg);
+extern "C" static pthread_handler_decl(kill_server_thread,arg);
static int bootstrap(FILE *file);
static void close_server_sock();
static bool read_init_file(char *file_name);
#ifdef __NT__
-static pthread_handler_decl(handle_connections_namedpipes,arg);
+extern "C" static pthread_handler_decl(handle_connections_namedpipes,arg);
#endif
-extern pthread_handler_decl(handle_slave,arg);
+extern "C" extern pthread_handler_decl(handle_slave,arg);
#ifdef SET_RLIMIT_NOFILE
static uint set_maximum_open_files(uint max_file_limit);
#endif
@@ -771,7 +771,7 @@ static void __cdecl kill_server(int sig_ptr)
#ifdef USE_ONE_SIGNAL_HAND
-static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
+extern "C" static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
{
SHUTDOWN_THD;
my_thread_init(); // Initialize new thread
@@ -786,7 +786,7 @@ static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
#define sigset signal
#endif
-static sig_handler print_signal_warning(int sig)
+extern "C" static sig_handler print_signal_warning(int sig)
{
if (!DBUG_IN_USE)
{
@@ -812,7 +812,7 @@ void unireg_end(int signal_number __attribute__((unused)))
}
-void unireg_abort(int exit_code)
+extern "C" void unireg_abort(int exit_code)
{
DBUG_ENTER("unireg_abort");
if (exit_code)
@@ -1162,7 +1162,7 @@ void close_connection(NET *net,uint errcode,bool lock)
/* Called when a thread is aborted */
/* ARGSUSED */
-sig_handler end_thread_signal(int sig __attribute__((unused)))
+extern "C" static sig_handler end_thread_signal(int sig __attribute__((unused)))
{
THD *thd=current_thd;
DBUG_ENTER("end_thread_signal");
@@ -1253,7 +1253,7 @@ void flush_thread_cache()
*/
#ifdef THREAD_SPECIFIC_SIGPIPE
-static sig_handler abort_thread(int sig __attribute__((unused)))
+extern "C" static sig_handler abort_thread(int sig __attribute__((unused)))
{
THD *thd=current_thd;
DBUG_ENTER("abort_thread");
@@ -1327,7 +1327,7 @@ static void start_signal_handler(void)
#define UNSAFE_DEFAULT_LINUX_THREADS 200
#endif
-static sig_handler handle_segfault(int sig)
+extern "C" static sig_handler handle_segfault(int sig)
{
THD *thd=current_thd;
/*
@@ -1512,7 +1512,7 @@ static void start_signal_handler(void)
/* This threads handles all signals and alarms */
/* ARGSUSED */
-static void *signal_hand(void *arg __attribute__((unused)))
+extern "C" static void *signal_hand(void *arg __attribute__((unused)))
{
sigset_t set;
int sig;
@@ -1640,7 +1640,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
/* ARGSUSED */
-static int my_message_sql(uint error, const char *str,
+extern "C" static int my_message_sql(uint error, const char *str,
myf MyFlags __attribute__((unused)))
{
NET *net;
@@ -1674,7 +1674,7 @@ int uname(struct utsname *a)
#ifdef __WIN__
-pthread_handler_decl(handle_shutdown,arg)
+extern "C" pthread_handler_decl(handle_shutdown,arg)
{
MSG msg;
SHUTDOWN_THD;
@@ -1702,7 +1702,7 @@ int __stdcall handle_kill(ulong ctrl_type)
#endif
#ifdef OS2
-pthread_handler_decl(handle_shutdown,arg)
+extern "C" pthread_handler_decl(handle_shutdown,arg)
{
SHUTDOWN_THD;
my_thread_init();
@@ -2500,7 +2500,7 @@ inline void kill_broken_server()
/* Handle new connections and spawn new process to handle them */
-pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
+extern "C" pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
{
my_socket sock,new_sock;
uint error_count=0;
@@ -2707,7 +2707,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
#ifdef __NT__
-pthread_handler_decl(handle_connections_namedpipes,arg)
+extern "C" pthread_handler_decl(handle_connections_namedpipes,arg)
{
HANDLE hConnectedPipe;
BOOL fConnected;
@@ -3218,7 +3218,7 @@ struct my_option my_long_options[] =
(gptr*) &report_port, (gptr*) &report_port, 0, GET_UINT, REQUIRED_ARG,
MYSQL_PORT, 0, 0, 0, 0, 0},
{"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented",
- (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_UINT,
+ (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"relay-log", OPT_RELAY_LOG, "Undocumented",
(gptr*) &opt_relay_logname, (gptr*) &opt_relay_logname, 0,
@@ -3910,7 +3910,7 @@ static void set_options(void)
}
-static my_bool
+extern "C" static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 181d97ceacc..38fc8928eaf 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2461,9 +2461,9 @@ int QUICK_SELECT::get_next()
DBUG_RETURN(HA_ERR_END_OF_FILE); // All ranges used
if (range->flag & NO_MIN_RANGE) // Read first record
{
- int error;
- if ((error=file->index_first(record)))
- DBUG_RETURN(error); // Empty table
+ int local_error;
+ if ((local_error=file->index_first(record)))
+ DBUG_RETURN(local_error); // Empty table
if (cmp_next(range) == 0)
DBUG_RETURN(0);
range=0; // No matching records; go to next range
@@ -2496,13 +2496,13 @@ int QUICK_SELECT::get_next()
/* compare if found key is over max-value */
/* Returns 0 if key <= range->max_key */
-int QUICK_SELECT::cmp_next(QUICK_RANGE *range)
+int QUICK_SELECT::cmp_next(QUICK_RANGE *range_arg)
{
- if (range->flag & NO_MAX_RANGE)
+ if (range_arg->flag & NO_MAX_RANGE)
return (0); /* key can't be to large */
KEY_PART *key_part=key_parts;
- for (char *key=range->max_key, *end=key+range->max_length;
+ for (char *key=range_arg->max_key, *end=key+range_arg->max_length;
key < end;
key+= key_part++->part_length)
{
@@ -2523,7 +2523,7 @@ int QUICK_SELECT::cmp_next(QUICK_RANGE *range)
if (cmp > 0)
return 1;
}
- return (range->flag & NEAR_MAX) ? 1 : 0; // Exact match
+ return (range_arg->flag & NEAR_MAX) ? 1 : 0; // Exact match
}
@@ -2607,9 +2607,9 @@ int QUICK_SELECT_DESC::get_next()
if (range->flag & NO_MAX_RANGE) // Read last record
{
- int error;
- if ((error=file->index_last(record)))
- DBUG_RETURN(error); // Empty table
+ int local_error;
+ if ((local_error=file->index_last(record)))
+ DBUG_RETURN(local_error); // Empty table
if (cmp_prev(range) == 0)
DBUG_RETURN(0);
range=0; // No matching records; go to next range
@@ -2655,16 +2655,18 @@ int QUICK_SELECT_DESC::get_next()
}
}
+
/*
- * Returns 0 if found key is inside range (found key >= range->min_key).
- */
-int QUICK_SELECT_DESC::cmp_prev(QUICK_RANGE *range)
+ Returns 0 if found key is inside range (found key >= range->min_key).
+*/
+
+int QUICK_SELECT_DESC::cmp_prev(QUICK_RANGE *range_arg)
{
- if (range->flag & NO_MIN_RANGE)
+ if (range_arg->flag & NO_MIN_RANGE)
return (0); /* key can't be to small */
KEY_PART *key_part = key_parts;
- for (char *key = range->min_key, *end = key + range->min_length;
+ for (char *key = range_arg->min_key, *end = key + range_arg->min_length;
key < end;
key += key_part++->part_length)
{
@@ -2688,42 +2690,45 @@ int QUICK_SELECT_DESC::cmp_prev(QUICK_RANGE *range)
if (cmp < 0)
return 1;
}
- return (range->flag & NEAR_MIN) ? 1 : 0; // Exact match
+ return (range_arg->flag & NEAR_MIN) ? 1 : 0; // Exact match
}
+
/*
* True if this range will require using HA_READ_AFTER_KEY
See comment in get_next() about this
*/
-bool QUICK_SELECT_DESC::range_reads_after_key(QUICK_RANGE *range)
+bool QUICK_SELECT_DESC::range_reads_after_key(QUICK_RANGE *range_arg)
{
- return ((range->flag & (NO_MAX_RANGE | NEAR_MAX)) ||
- !(range->flag & EQ_RANGE) ||
- head->key_info[index].key_length != range->max_length) ? 1 : 0;
+ return ((range_arg->flag & (NO_MAX_RANGE | NEAR_MAX)) ||
+ !(range_arg->flag & EQ_RANGE) ||
+ head->key_info[index].key_length != range_arg->max_length) ? 1 : 0;
}
+
/* True if we are reading over a key that may have a NULL value */
-bool QUICK_SELECT_DESC::test_if_null_range(QUICK_RANGE *range,
+bool QUICK_SELECT_DESC::test_if_null_range(QUICK_RANGE *range_arg,
uint used_key_parts)
{
uint offset,end;
KEY_PART *key_part = key_parts,
*key_part_end= key_part+used_key_parts;
- for (offset= 0, end = min(range->min_length, range->max_length) ;
+ for (offset= 0, end = min(range_arg->min_length, range_arg->max_length) ;
offset < end && key_part != key_part_end ;
offset += key_part++->part_length)
{
uint null_length=test(key_part->null_bit);
- if (!memcmp((char*) range->min_key+offset, (char*) range->max_key+offset,
+ if (!memcmp((char*) range_arg->min_key+offset,
+ (char*) range_arg->max_key+offset,
key_part->part_length + null_length))
{
offset+=null_length;
continue;
}
- if (null_length && range->min_key[offset])
+ if (null_length && range_arg->min_key[offset])
return 1; // min_key is null and max_key isn't
// Range doesn't cover NULL. This is ok if there is no more null parts
break;
@@ -2736,7 +2741,7 @@ bool QUICK_SELECT_DESC::test_if_null_range(QUICK_RANGE *range,
*/
if (key_part != key_part_end && key_part->null_bit)
{
- if (offset >= range->min_length || range->min_key[offset])
+ if (offset >= range_arg->min_length || range_arg->min_key[offset])
return 1; // Could be null
key_part++;
}
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 81627dceb0e..78b22a61b66 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -188,14 +188,15 @@ err2:
return 1;
}
-static uint32* slave_list_key(SLAVE_INFO* si, uint* len,
- my_bool not_used __attribute__((unused)))
+extern "C" static uint32
+*slave_list_key(SLAVE_INFO* si, uint* len,
+ my_bool not_used __attribute__((unused)))
{
*len = 4;
return &si->server_id;
}
-static void slave_info_free(void *s)
+extern "C" static void slave_info_free(void *s)
{
my_free((gptr) s, MYF(MY_WME));
}
@@ -203,7 +204,7 @@ static void slave_info_free(void *s)
void init_slave_list()
{
hash_init(&slave_list, SLAVE_LIST_CHUNK, 0, 0,
- (hash_get_key) slave_list_key, slave_info_free, 0);
+ (hash_get_key) slave_list_key, (hash_free_key) slave_info_free, 0);
pthread_mutex_init(&LOCK_slave_list, MY_MUTEX_INIT_FAST);
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 620523dd47f..bccfe89f8c9 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -556,7 +556,7 @@ void init_table_rule_hash(HASH* h, bool* h_inited)
{
hash_init(h, TABLE_RULE_HASH_SIZE,0,0,
(hash_get_key) get_table_key,
- (void (*)(void*)) free_table_ent, 0);
+ (hash_free_key) free_table_ent, 0);
*h_inited = 1;
}
@@ -1809,7 +1809,7 @@ This may also be a network problem, or just a bug in the master or slave code.\
/* slave I/O thread */
-pthread_handler_decl(handle_slave_io,arg)
+extern "C" pthread_handler_decl(handle_slave_io,arg)
{
THD *thd; // needs to be first for thread_stack
MYSQL *mysql;
@@ -2080,7 +2080,7 @@ err:
/* slave SQL logic thread */
-pthread_handler_decl(handle_slave_sql,arg)
+extern "C" pthread_handler_decl(handle_slave_sql,arg)
{
THD *thd; /* needs to be first for thread_stack */
char llbuff[22],llbuff1[22];
diff --git a/sql/slave.h b/sql/slave.h
index cbcd2957476..721fd8534a0 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -414,8 +414,8 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,ulonglong pos,
int purge_relay_logs(RELAY_LOG_INFO* rli, THD *thd, bool just_reset,
const char** errmsg);
-pthread_handler_decl(handle_slave_io,arg);
-pthread_handler_decl(handle_slave_sql,arg);
+extern "C" pthread_handler_decl(handle_slave_io,arg);
+extern "C" pthread_handler_decl(handle_slave_sql,arg);
extern bool volatile abort_loop;
extern MASTER_INFO main_mi, *active_mi; /* active_mi for multi-master */
extern volatile int active_mi_in_use;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 1694e662b52..4a9fcefbda5 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -141,7 +141,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
if (!acl_cache)
acl_cache=new hash_filo(ACL_CACHE_SIZE,0,0,
(hash_get_key) acl_entry_get_key,
- (void (*)(void*)) free);
+ (hash_free_key) free);
if (dont_read_acl_tables)
DBUG_RETURN(0); /* purecov: tested */
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 3b46c53f75c..a318f846a02 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -39,8 +39,8 @@ static key_map get_key_map_from_key_list(TABLE *table,
List<String> *index_list);
-static byte *cache_key(const byte *record,uint *length,
- my_bool not_used __attribute__((unused)))
+extern "C" static byte *cache_key(const byte *record,uint *length,
+ my_bool not_used __attribute__((unused)))
{
TABLE *entry=(TABLE*) record;
*length=entry->key_length;
@@ -50,7 +50,7 @@ static byte *cache_key(const byte *record,uint *length,
void table_cache_init(void)
{
VOID(hash_init(&open_cache,table_cache_size+16,0,0,cache_key,
- (void (*)(void*)) free_cache_entry,0));
+ (hash_free_key) free_cache_entry,0));
mysql_rm_tmp_tables();
}
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 0b9caf4e6c3..db601cd8a00 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -458,33 +458,6 @@ byte *query_cache_table_get_key(const byte *record, uint *length,
Query_cache_query methods
*****************************************************************************/
-void Query_cache_query::init_n_lock()
-{
- DBUG_ENTER("Query_cache_query::init_n_lock");
- res=0; wri = 0; len = 0;
- my_rwlock_init(&lock, NULL);
- lock_writing();
- DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx",
- ((byte*) this)-ALIGN_SIZE(sizeof(Query_cache_block))));
- DBUG_VOID_RETURN;
-}
-
-
-void Query_cache_query::unlock_n_destroy()
-{
- DBUG_ENTER("Query_cache_query::unlock_n_destroy");
- DBUG_PRINT("qcache", ("destroyed & unlocked query for block 0x%lx",
- ((byte*)this)-ALIGN_SIZE(sizeof(Query_cache_block))));
- /*
- The following call is not needed on system where one can destroy an
- active semaphore
- */
- this->unlock_writing();
- rwlock_destroy(&lock);
- DBUG_VOID_RETURN;
-}
-
-
/*
Following methods work for block read/write locking only in this
particular case and in interaction with structure_guard_mutex.
@@ -536,6 +509,34 @@ inline void Query_cache_query::unlock_reading()
RW_UNLOCK(&lock);
}
+
+void Query_cache_query::init_n_lock()
+{
+ DBUG_ENTER("Query_cache_query::init_n_lock");
+ res=0; wri = 0; len = 0;
+ my_rwlock_init(&lock, NULL);
+ lock_writing();
+ DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx",
+ ((byte*) this)-ALIGN_SIZE(sizeof(Query_cache_block))));
+ DBUG_VOID_RETURN;
+}
+
+
+void Query_cache_query::unlock_n_destroy()
+{
+ DBUG_ENTER("Query_cache_query::unlock_n_destroy");
+ DBUG_PRINT("qcache", ("destroyed & unlocked query for block 0x%lx",
+ ((byte*)this)-ALIGN_SIZE(sizeof(Query_cache_block))));
+ /*
+ The following call is not needed on system where one can destroy an
+ active semaphore
+ */
+ this->unlock_writing();
+ rwlock_destroy(&lock);
+ DBUG_VOID_RETURN;
+}
+
+
extern "C"
{
byte *query_cache_query_get_key(const byte *record, uint *length,
@@ -699,19 +700,19 @@ void query_cache_invalidate_by_MyISAM_filename(const char *filename)
Query_cache methods
*****************************************************************************/
-Query_cache::Query_cache(ulong query_cache_limit,
- ulong min_allocation_unit,
- ulong min_result_data_size,
- uint def_query_hash_size ,
- uint def_table_hash_size)
+Query_cache::Query_cache(ulong query_cache_limit_arg,
+ ulong min_allocation_unit_arg,
+ ulong min_result_data_size_arg,
+ uint def_query_hash_size_arg,
+ uint def_table_hash_size_arg)
:query_cache_size(0),
- query_cache_limit(query_cache_limit),
+ query_cache_limit(query_cache_limit_arg),
queries_in_cache(0), hits(0), inserts(0), refused(0),
total_blocks(0),
- min_allocation_unit(ALIGN_SIZE(min_allocation_unit)),
- min_result_data_size(ALIGN_SIZE(min_result_data_size)),
- def_query_hash_size(ALIGN_SIZE(def_query_hash_size)),
- def_table_hash_size(ALIGN_SIZE(def_table_hash_size)),
+ min_allocation_unit(ALIGN_SIZE(min_allocation_unit_arg)),
+ min_result_data_size(ALIGN_SIZE(min_result_data_size_arg)),
+ def_query_hash_size(ALIGN_SIZE(def_query_hash_size_arg)),
+ def_table_hash_size(ALIGN_SIZE(def_table_hash_size_arg)),
initialized(0)
{
ulong min_needed= (ALIGN_SIZE(sizeof(Query_cache_block)) +
@@ -736,13 +737,13 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
{
- TABLE_COUNTER_TYPE tables;
+ TABLE_COUNTER_TYPE local_tables;
ulong tot_length;
DBUG_ENTER("Query_cache::store_query");
if (query_cache_size == 0)
DBUG_VOID_RETURN;
- if ((tables = is_cacheable(thd, thd->query_length,
+ if ((local_tables = is_cacheable(thd, thd->query_length,
thd->query, &thd->lex, tables_used)))
{
NET *net = &thd->net;
@@ -788,7 +789,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
Query_cache_block *query_block;
query_block= write_block_data(tot_length, (gptr) thd->query,
ALIGN_SIZE(sizeof(Query_cache_query)),
- Query_cache_block::QUERY, tables, 1);
+ Query_cache_block::QUERY, local_tables, 1);
if (query_block != 0)
{
DBUG_PRINT("qcache", ("query block 0x%lx allocated, %lu",
@@ -805,7 +806,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
STRUCT_UNLOCK(&structure_guard_mutex);
goto end;
}
- if (!register_all_tables(query_block, tables_used, tables))
+ if (!register_all_tables(query_block, tables_used, local_tables))
{
refused++;
DBUG_PRINT("warning", ("tables list including failed"));
@@ -1780,7 +1781,7 @@ inline ulong Query_cache::get_min_append_result_data_size()
my_bool Query_cache::allocate_data_chain(Query_cache_block **result_block,
ulong data_len,
Query_cache_block *query_block,
- my_bool first_block)
+ my_bool first_block_arg)
{
ulong all_headers_len = (ALIGN_SIZE(sizeof(Query_cache_block)) +
ALIGN_SIZE(sizeof(Query_cache_result)));
@@ -1790,7 +1791,7 @@ my_bool Query_cache::allocate_data_chain(Query_cache_block **result_block,
DBUG_PRINT("qcache", ("data_len %lu, all_headers_len %lu",
data_len, all_headers_len));
- ulong min_size = (first_block ?
+ ulong min_size = (first_block_arg ?
get_min_first_result_data_size():
get_min_append_result_data_size());
*result_block = allocate_block(max(min_size, align_len),
@@ -1817,7 +1818,7 @@ my_bool Query_cache::allocate_data_chain(Query_cache_block **result_block,
Query_cache_block *next_block;
if ((success = allocate_data_chain(&next_block,
len - new_block->length,
- query_block, first_block)))
+ query_block, first_block_arg)))
double_linked_list_join(new_block, next_block);
}
if (success)
@@ -1886,14 +1887,23 @@ void Query_cache::invalidate_table(Query_cache_block *table_block)
}
}
+/*
+ Store all used tables
+
+ SYNOPSIS
+ register_all_tables()
+ block Store tables in this block
+ tables_used List if used tables
+ tables_arg Not used ?
+*/
my_bool Query_cache::register_all_tables(Query_cache_block *block,
TABLE_LIST *tables_used,
- TABLE_COUNTER_TYPE tables)
+ TABLE_COUNTER_TYPE tables_arg)
{
TABLE_COUNTER_TYPE n;
DBUG_PRINT("qcache", ("register tables block 0x%lx, n %d, header %x",
- (ulong) block, (int) tables,
+ (ulong) block, (int) tables_arg,
(int) ALIGN_SIZE(sizeof(Query_cache_block))));
Query_cache_block_table *block_table = block->table(0);
@@ -2185,28 +2195,28 @@ void Query_cache::split_block(Query_cache_block *block, ulong len)
Query_cache_block *
-Query_cache::join_free_blocks(Query_cache_block *first_block,
+Query_cache::join_free_blocks(Query_cache_block *first_block_arg,
Query_cache_block *block_in_list)
{
Query_cache_block *second_block;
DBUG_ENTER("Query_cache::join_free_blocks");
DBUG_PRINT("qcache",
("join first 0x%lx, pnext 0x%lx, in list 0x%lx",
- (ulong) first_block, (ulong) first_block->pnext,
+ (ulong) first_block_arg, (ulong) first_block_arg->pnext,
(ulong) block_in_list));
exclude_from_free_memory_list(block_in_list);
- second_block = first_block->pnext;
+ second_block = first_block_arg->pnext;
// May be was not free block
second_block->used=0;
second_block->destroy();
total_blocks--;
- first_block->length += second_block->length;
- first_block->pnext = second_block->pnext;
- second_block->pnext->pprev = first_block;
+ first_block_arg->length += second_block->length;
+ first_block_arg->pnext = second_block->pnext;
+ second_block->pnext->pprev = first_block_arg;
- DBUG_RETURN(first_block);
+ DBUG_RETURN(first_block_arg);
}
@@ -2423,7 +2433,7 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
char *query,
LEX *lex, TABLE_LIST *tables_used)
{
- TABLE_COUNTER_TYPE tables = 0;
+ TABLE_COUNTER_TYPE table_count = 0;
DBUG_ENTER("Query_cache::is_cacheable");
if (lex->sql_command == SQLCOM_SELECT &&
@@ -2440,7 +2450,7 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
for (; tables_used; tables_used= tables_used->next)
{
- tables++;
+ table_count++;
DBUG_PRINT("qcache", ("table %s, db %s, type %u",
tables_used->real_name,
tables_used->db, tables_used->table->db_type));
@@ -2464,7 +2474,7 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
{
ha_myisammrg *handler = (ha_myisammrg *)tables_used->table->file;
MYRG_INFO *file = handler->myrg_info();
- tables+= (file->end_table - file->open_tables);
+ table_count+= (file->end_table - file->open_tables);
}
}
@@ -2474,8 +2484,8 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
DBUG_PRINT("qcache", ("not in autocommin mode"));
DBUG_RETURN(0);
}
- DBUG_PRINT("qcache", ("select is using %d tables", tables));
- DBUG_RETURN(tables);
+ DBUG_PRINT("qcache", ("select is using %d tables", table_count));
+ DBUG_RETURN(table_count);
}
DBUG_PRINT("qcache",
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index f19e6630da5..0c73c46652e 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -178,7 +178,7 @@ extern "C"
my_bool not_used);
}
void query_cache_insert(NET *thd, const char *packet, ulong length);
-void query_cache_invalidate_by_MyISAM_filename(const char* filename);
+extern "C" void query_cache_invalidate_by_MyISAM_filename(const char* filename);
struct Query_cache_memory_bin
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 11b2bb93430..0066bccbd73 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -59,14 +59,14 @@ template class List_iterator<Alter_column>;
** User variables
****************************************************************************/
-static byte* get_var_key(user_var_entry *entry, uint *length,
- my_bool not_used __attribute__((unused)))
+extern "C" static byte *get_var_key(user_var_entry *entry, uint *length,
+ my_bool not_used __attribute__((unused)))
{
*length=(uint) entry->name.length;
return (byte*) entry->name.str;
}
-static void free_var(user_var_entry *entry)
+extern "C" static void free_var(user_var_entry *entry)
{
char *pos= (char*) entry+ALIGN_SIZE(sizeof(*entry));
if (entry->value && entry->value != pos)
@@ -148,7 +148,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
user_connect=(USER_CONN *)0;
hash_init(&user_vars, USER_VARS_HASH_SIZE, 0, 0,
(hash_get_key) get_var_key,
- (void (*)(void*)) free_var,0);
+ (hash_free_key) free_var,0);
#ifdef USING_TRANSACTIONS
bzero((char*) &transaction,sizeof(transaction));
if (opt_using_transactions)
@@ -320,20 +320,21 @@ void THD::add_changed_table(TABLE *table)
DBUG_VOID_RETURN;
}
+
void THD::add_changed_table(const char *key, long key_length)
{
DBUG_ENTER("THD::add_changed_table(key)");
- CHANGED_TABLE_LIST** prev = &transaction.changed_tables;
- CHANGED_TABLE_LIST* curr = transaction.changed_tables;
+ CHANGED_TABLE_LIST **prev_changed = &transaction.changed_tables;
+ CHANGED_TABLE_LIST *curr = transaction.changed_tables;
- for (; curr; prev = &(curr->next), curr = curr->next)
+ for (; curr; prev_changed = &(curr->next), curr = curr->next)
{
int cmp = (long)curr->key_length - (long)key_length;
if (cmp < 0)
{
- list_include(prev, curr, changed_table_dup(key, key_length));
+ list_include(prev_changed, curr, changed_table_dup(key, key_length));
DBUG_PRINT("info",
- ("key_length %u %u", key_length, (*prev)->key_length));
+ ("key_length %u %u", key_length, (*prev_changed)->key_length));
DBUG_VOID_RETURN;
}
else if (cmp == 0)
@@ -341,10 +342,10 @@ void THD::add_changed_table(const char *key, long key_length)
cmp = memcmp(curr->key, key, curr->key_length);
if (cmp < 0)
{
- list_include(prev, curr, changed_table_dup(key, key_length));
+ list_include(prev_changed, curr, changed_table_dup(key, key_length));
DBUG_PRINT("info",
("key_length %u %u", key_length,
- (*prev)->key_length));
+ (*prev_changed)->key_length));
DBUG_VOID_RETURN;
}
else if (cmp == 0)
@@ -354,9 +355,9 @@ void THD::add_changed_table(const char *key, long key_length)
}
}
}
- *prev = changed_table_dup(key, key_length);
+ *prev_changed = changed_table_dup(key, key_length);
DBUG_PRINT("info", ("key_length %u %u", key_length,
- (*prev)->key_length));
+ (*prev_changed)->key_length));
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index b40e0b7b093..b69d4cf1e44 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -204,7 +204,7 @@ cleanup:
#define MEM_STRIP_BUF_SIZE current_thd->variables.sortbuff_size
-int refposcmp2(void* arg, const void *a,const void *b)
+extern "C" static int refposcmp2(void* arg, const void *a,const void *b)
{
return memcmp(a,b, *(int*) arg);
}
@@ -392,7 +392,7 @@ void multi_delete::send_error(uint errcode,const char *err)
int multi_delete::do_deletes(bool from_send_error)
{
- int error = 0, counter = 0;
+ int local_error= 0, counter= 0;
if (from_send_error)
{
@@ -413,27 +413,27 @@ int multi_delete::do_deletes(bool from_send_error)
TABLE *table = table_being_deleted->table;
if (tempfiles[counter]->get(table))
{
- error=1;
+ local_error=1;
break;
}
READ_RECORD info;
init_read_record(&info,thd,table,NULL,0,0);
- while (!(error=info.read_record(&info)) &&
+ while (!(local_error=info.read_record(&info)) &&
(!thd->killed || from_send_error || not_trans_safe))
{
- if ((error=table->file->delete_row(table->record[0])))
+ if ((local_error=table->file->delete_row(table->record[0])))
{
- table->file->print_error(error,MYF(0));
+ table->file->print_error(local_error,MYF(0));
break;
}
deleted++;
}
end_read_record(&info);
- if (error == -1) // End of file
- error = 0;
+ if (local_error == -1) // End of file
+ local_error = 0;
}
- return error;
+ return local_error;
}
@@ -449,11 +449,11 @@ bool multi_delete::send_eof()
thd->proc_info="deleting from reference tables";
/* Does deletes for the last n - 1 tables, returns 0 if ok */
- int error = do_deletes(0); // returns 0 if success
+ int local_error= do_deletes(0); // returns 0 if success
/* reset used flags */
thd->proc_info="end";
- if (error)
+ if (local_error)
{
::send_error(&thd->net);
return 1;
@@ -473,10 +473,10 @@ bool multi_delete::send_eof()
Query_log_event qinfo(thd, thd->query, thd->query_length);
if (mysql_bin_log.write(&qinfo) &&
!not_trans_safe)
- error=1; // Log write failed: roll back the SQL statement
+ local_error=1; // Log write failed: roll back the SQL statement
}
/* Commit or rollback the current SQL statement */
- VOID(ha_autocommit_or_rollback(thd,error > 0));
+ VOID(ha_autocommit_or_rollback(thd,local_error > 0));
}
if (deleted)
{
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index bd379bf688d..c14672fd4b3 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -25,7 +25,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list);
static int write_delayed(THD *thd,TABLE *table, enum_duplicates dup,
char *query, uint query_length, bool log_on);
static void end_delayed_insert(THD *thd);
-static pthread_handler_decl(handle_delayed_insert,arg);
+extern "C" static pthread_handler_decl(handle_delayed_insert,arg);
static void unlink_blobs(register TABLE *table);
/* Define to force use of my_malloc() if the allocated memory block is big */
@@ -913,7 +913,7 @@ void kill_delayed_threads(void)
* Create a new delayed insert thread
*/
-static pthread_handler_decl(handle_delayed_insert,arg)
+extern "C" static pthread_handler_decl(handle_delayed_insert,arg)
{
delayed_insert *di=(delayed_insert*) arg;
THD *thd= &di->thd;
diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc
index 13cac83fc3f..0af6a80d4c2 100644
--- a/sql/sql_manager.cc
+++ b/sql/sql_manager.cc
@@ -32,7 +32,7 @@ pthread_t manager_thread;
pthread_mutex_t LOCK_manager;
pthread_cond_t COND_manager;
-pthread_handler_decl(handle_manager,arg __attribute__((unused)))
+extern "C" pthread_handler_decl(handle_manager,arg __attribute__((unused)))
{
int error = 0;
ulong status;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 7416506fd02..23274c90367 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -259,14 +259,14 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
started with corresponding variable that is greater then 0.
*/
-static byte* get_key_conn(user_conn *buff, uint *length,
- my_bool not_used __attribute__((unused)))
+extern "C" static byte *get_key_conn(user_conn *buff, uint *length,
+ my_bool not_used __attribute__((unused)))
{
*length=buff->len;
return (byte*) buff->user;
}
-static void free_user(struct user_conn *uc)
+extern "C" static void free_user(struct user_conn *uc)
{
my_free((char*) uc,MYF(0));
}
@@ -274,7 +274,7 @@ static void free_user(struct user_conn *uc)
void init_max_user_conn(void)
{
(void) hash_init(&hash_user_connections,max_connections,0,0,
- (hash_get_key) get_key_conn, (void (*)(void*)) free_user,
+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
0);
}
@@ -713,7 +713,7 @@ end_thread:
Used when creating the initial grant tables
*/
-pthread_handler_decl(handle_bootstrap,arg)
+extern "C" pthread_handler_decl(handle_bootstrap,arg)
{
THD *thd=(THD*) arg;
FILE *file=bootstrap_file;
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index daf02b1c6d6..fe1fa3332cf 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -98,7 +98,7 @@ static void init_syms(udf_func *tmp)
}
}
-static byte* get_hash_key(const byte *buff,uint *length,
+extern "C" static byte* get_hash_key(const byte *buff,uint *length,
my_bool not_used __attribute__((unused)))
{
udf_func *udf=(udf_func*) buff;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 92decc63b6b..838554fde6d 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -688,7 +688,7 @@ void multi_update::send_error(uint errcode,const char *err)
int multi_update::do_updates (bool from_send_error)
{
- int error = 0, counter = 0;
+ int local_error= 0, counter= 0;
if (from_send_error)
{
@@ -713,7 +713,7 @@ int multi_update::do_updates (bool from_send_error)
TABLE *tmp_table=tmp_tables[counter];
if (tmp_table->file->extra(HA_EXTRA_NO_CACHE))
{
- error=1;
+ local_error=1;
break;
}
List<Item> list;
@@ -729,35 +729,36 @@ int multi_update::do_updates (bool from_send_error)
tmp_table->used_keys&=field->part_of_key;
}
tmp_table->used_fields=tmp_table->fields;
- error=0; list.pop(); // we get position some other way ...
- error = tmp_table->file->rnd_init(1);
- if (error)
- return error;
- while (!(error=tmp_table->file->rnd_next(tmp_table->record[0])) &&
+ local_error=0;
+ list.pop(); // we get position some other way ...
+ local_error = tmp_table->file->rnd_init(1);
+ if (local_error)
+ return local_error;
+ while (!(local_error=tmp_table->file->rnd_next(tmp_table->record[0])) &&
(!thd->killed || from_send_error || not_trans_safe))
{
found++;
- error= table->file->rnd_pos(table->record[0],
- (byte*) (*(tmp_table->field))->ptr);
- if (error)
- return error;
+ local_error= table->file->rnd_pos(table->record[0],
+ (byte*) (*(tmp_table->field))->ptr);
+ if (local_error)
+ return local_error;
table->status|= STATUS_UPDATED;
store_record(table,1);
- error= fill_record(*fields_by_tables[counter + 1],list) ||
- /* compare_record(table, query_id) || */
- table->file->update_row(table->record[1],table->record[0]);
- if (error)
+ local_error= (fill_record(*fields_by_tables[counter + 1],list) ||
+ /* compare_record(table, query_id) || */
+ table->file->update_row(table->record[1],table->record[0]));
+ if (local_error)
{
- table->file->print_error(error,MYF(0));
+ table->file->print_error(local_error,MYF(0));
break;
}
else
updated++;
}
- if (error == HA_ERR_END_OF_FILE)
- error = 0;
+ if (local_error == HA_ERR_END_OF_FILE)
+ local_error = 0;
}
- return error;
+ return local_error;
}
@@ -768,17 +769,17 @@ bool multi_update::send_eof()
thd->proc_info="updating the reference tables";
/* Does updates for the last n - 1 tables, returns 0 if ok */
- int error = (num_updated) ? do_updates(false) : 0; /* do_updates returns 0 if success */
+ int local_error = (num_updated) ? do_updates(false) : 0;
/* reset used flags */
#ifndef NOT_USED
update_tables->table->no_keyread=0;
#endif
- if (error == -1)
- error = 0;
- thd->proc_info="end";
- if (error)
- send_error(error,"An error occured in multi-table update");
+ if (local_error == -1)
+ local_error= 0;
+ thd->proc_info= "end";
+ if (local_error)
+ send_error(local_error, "An error occured in multi-table update");
/*
Write the SQL statement to the binlog if we updated
@@ -799,14 +800,14 @@ bool multi_update::send_eof()
if (mysql_bin_log.is_open() && mysql_bin_log.write(&qinfo) &&
!not_trans_safe)
- error=1; /* Log write failed: roll back the SQL statement */
+ local_error=1; /* Log write failed: roll back the SQL statement */
/* Commit or rollback the current SQL statement */
- VOID(ha_autocommit_or_rollback(thd,error > 0));
+ VOID(ha_autocommit_or_rollback(thd, local_error > 0));
}
else
- error=0; // this can happen only if it is end of file error
- if (!error) // if the above log write did not fail ...
+ local_error= 0; // this can happen only if it is end of file error
+ if (!local_error) // if the above log write did not fail ...
{
char buff[80];
sprintf(buff,ER(ER_UPDATE_INFO), (long) found, (long) updated,