diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/derror.cc | 5 | ||||
-rw-r--r-- | sql/field.cc | 21 | ||||
-rw-r--r-- | sql/handler.cc | 7 | ||||
-rw-r--r-- | sql/item_sum.cc | 12 | ||||
-rw-r--r-- | sql/item_sum.h | 14 | ||||
-rw-r--r-- | sql/mdl.h | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 21 | ||||
-rw-r--r-- | sql/opt_range.cc | 44 | ||||
-rw-r--r-- | sql/opt_range.h | 1 | ||||
-rw-r--r-- | sql/partition_info.cc | 31 | ||||
-rw-r--r-- | sql/rpl_utility.h | 4 | ||||
-rw-r--r-- | sql/sql_class.cc | 10 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 | ||||
-rw-r--r-- | sql/sql_select.h | 1 | ||||
-rw-r--r-- | sql/sql_show.cc | 3 | ||||
-rw-r--r-- | sql/sql_test.cc | 29 | ||||
-rw-r--r-- | sql/sql_test.h | 2 |
18 files changed, 138 insertions, 75 deletions
diff --git a/sql/derror.cc b/sql/derror.cc index 04a82860d45..7f1435e89c1 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -32,11 +32,12 @@ static void init_myfunc_errs(void); -const char **get_server_errmsgs() +C_MODE_START +static const char **get_server_errmsgs() { return CURRENT_THD_ERRMSGS; } - +C_MODE_END /** Read messages from errorfile. diff --git a/sql/field.cc b/sql/field.cc index ac40ae53d7c..88a7f43819d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1009,17 +1009,20 @@ test_if_important_data(CHARSET_INFO *cs, const char *str, const char *strend) Used below. In an anonymous namespace to not clash with definitions in other files. */ -namespace { - int compare(unsigned int a, unsigned int b) - { - if (a < b) - return -1; - if (b < a) - return 1; - return 0; -} + +CPP_UNNAMED_NS_START + +int compare(unsigned int a, unsigned int b) +{ + if (a < b) + return -1; + if (b < a) + return 1; + return 0; } +CPP_UNNAMED_NS_END + /** Detect Item_result by given field type of UNION merge result. diff --git a/sql/handler.cc b/sql/handler.cc index 844c7305825..11f684a8010 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -299,13 +299,14 @@ handler *get_ha_partition(partition_info *part_info) #endif -const char **handler_errmsgs; +static const char **handler_errmsgs; - -const char **get_handler_errmsgs() +C_MODE_START +static const char **get_handler_errmsgs() { return handler_errmsgs; } +C_MODE_END /** diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 917acb0e908..15927c4b11e 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2827,6 +2827,7 @@ String *Item_sum_udf_str::val_str(String *str) @retval 1 : key1 > key2 */ +extern "C" int group_concat_key_cmp_with_distinct(void* arg, const void* key1, const void* key2) { @@ -2861,6 +2862,7 @@ int group_concat_key_cmp_with_distinct(void* arg, const void* key1, function of sort for syntax: GROUP_CONCAT(expr,... ORDER BY col,... ) */ +extern "C" int group_concat_key_cmp_with_order(void* arg, const void* key1, const void* key2) { @@ -2905,13 +2907,16 @@ int group_concat_key_cmp_with_order(void* arg, const void* key1, Append data from current leaf to item->result. */ -int dump_leaf_key(uchar* key, element_count count __attribute__((unused)), - Item_func_group_concat *item) +extern "C" +int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)), + void* item_arg) { + Item_func_group_concat *item= (Item_func_group_concat *) item_arg; TABLE *table= item->table; String tmp((char *)table->record[1], table->s->reclength, default_charset_info); String tmp2; + uchar *key= (uchar *) key_arg; String *result= &item->result; Item **arg= item->args, **arg_end= item->args + item->arg_count_field; uint old_length= result->length(); @@ -3385,8 +3390,7 @@ String* Item_func_group_concat::val_str(String* str) return 0; if (no_appended && tree) /* Tree is used for sorting as in ORDER BY */ - tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this, - left_root_right); + tree_walk(tree, &dump_leaf_key, this, left_root_right); return &result; } diff --git a/sql/item_sum.h b/sql/item_sum.h index c76f3102003..99fcb14d160 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1319,6 +1319,16 @@ public: #endif /* HAVE_DLOPEN */ +C_MODE_START +int group_concat_key_cmp_with_distinct(void* arg, const void* key1, + const void* key2); +int group_concat_key_cmp_with_order(void* arg, const void* key1, + const void* key2); +int dump_leaf_key(void* key_arg, + element_count count __attribute__((unused)), + void* item_arg); +C_MODE_END + class Item_func_group_concat : public Item_sum { TMP_TABLE_PARAM *tmp_table_param; @@ -1358,9 +1368,9 @@ class Item_func_group_concat : public Item_sum const void* key2); friend int group_concat_key_cmp_with_order(void* arg, const void* key1, const void* key2); - friend int dump_leaf_key(uchar* key, + friend int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)), - Item_func_group_concat *group_concat_item); + void* item_arg); public: Item_func_group_concat(Name_resolution_context *context_arg, diff --git a/sql/mdl.h b/sql/mdl.h index 2fb21a5aa18..89a679be264 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -718,7 +718,7 @@ void mdl_destroy(); extern bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use, bool needs_thr_lock_abort); extern void mysql_ha_flush(THD *thd); -extern "C" const char *set_thd_proc_info(THD *thd, const char *info, +extern "C" const char *set_thd_proc_info(void *thd_arg, const char *info, const char *calling_function, const char *calling_file, const unsigned int calling_line); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index eb76132c080..db0080451f2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -857,12 +857,15 @@ void Buffered_logs::print() /** Logs reported before a logger is available. */ static Buffered_logs buffered_logs; +#ifndef EMBEDDED_LIBRARY /** Error reporter that buffer log messages. @param level log message level @param format log message format string */ -void buffered_option_error_reporter(enum loglevel level, const char *format, ...) +C_MODE_START +static void buffered_option_error_reporter(enum loglevel level, + const char *format, ...) { va_list args; char buffer[1024]; @@ -872,6 +875,8 @@ void buffered_option_error_reporter(enum loglevel level, const char *format, ... va_end(args); buffered_logs.buffer(level, buffer); } +C_MODE_END +#endif /* !EMBEDDED_LIBRARY */ #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ static my_socket unix_sock,ip_sock; @@ -973,7 +978,6 @@ uint connection_count= 0; pthread_handler_t signal_hand(void *arg); static int mysql_init_variables(void); -extern "C" void option_error_reporter(enum loglevel level, const char *format, ...); static int get_options(int *argc_ptr, char ***argv_ptr); static bool add_terminator(DYNAMIC_ARRAY *options); extern "C" my_bool mysqld_get_one_option(int, const struct my_option *, char *); @@ -4020,9 +4024,8 @@ static int init_server_components() } } - proc_info_hook= (const char *(*)(void *, const char *, const char *, - const char *, const unsigned int)) - set_thd_proc_info; + proc_info_hook= set_thd_proc_info; + #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE /* Parsing the performance schema command line option may have reported @@ -7420,10 +7423,7 @@ mysqld_get_one_option(int optid, /** Handle arguments for multiple key caches. */ -extern "C" int mysql_getopt_value(uchar **value, - const char *keyname, uint key_length, - const struct my_option *option, - int *error); +C_MODE_START static uchar* * mysql_getopt_value(const char *keyname, uint key_length, @@ -7459,7 +7459,7 @@ mysql_getopt_value(const char *keyname, uint key_length, return option->value; } -void option_error_reporter(enum loglevel level, const char *format, ...) +static void option_error_reporter(enum loglevel level, const char *format, ...) { va_list args; va_start(args, format); @@ -7473,6 +7473,7 @@ void option_error_reporter(enum loglevel level, const char *format, ...) va_end(args); } +C_MODE_END /** Get server options from the command line, diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 5e985625c78..9363b637862 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1539,6 +1539,29 @@ QUICK_ROR_UNION_SELECT::QUICK_ROR_UNION_SELECT(THD *thd_param, /* + Comparison function to be used QUICK_ROR_UNION_SELECT::queue priority + queue. + + SYNPOSIS + QUICK_ROR_UNION_SELECT_queue_cmp() + arg Pointer to QUICK_ROR_UNION_SELECT + val1 First merged select + val2 Second merged select +*/ + +C_MODE_START + +static int QUICK_ROR_UNION_SELECT_queue_cmp(void *arg, uchar *val1, uchar *val2) +{ + QUICK_ROR_UNION_SELECT *self= (QUICK_ROR_UNION_SELECT*)arg; + return self->head->file->cmp_ref(((QUICK_SELECT_I*)val1)->last_rowid, + ((QUICK_SELECT_I*)val2)->last_rowid); +} + +C_MODE_END + + +/* Do post-constructor initialization. SYNOPSIS QUICK_ROR_UNION_SELECT::init() @@ -1552,7 +1575,7 @@ int QUICK_ROR_UNION_SELECT::init() { DBUG_ENTER("QUICK_ROR_UNION_SELECT::init"); if (init_queue(&queue, quick_selects.elements, 0, - FALSE , QUICK_ROR_UNION_SELECT::queue_cmp, + FALSE , QUICK_ROR_UNION_SELECT_queue_cmp, (void*) this)) { bzero(&queue, sizeof(QUEUE)); @@ -1567,25 +1590,6 @@ int QUICK_ROR_UNION_SELECT::init() /* - Comparison function to be used QUICK_ROR_UNION_SELECT::queue priority - queue. - - SYNPOSIS - QUICK_ROR_UNION_SELECT::queue_cmp() - arg Pointer to QUICK_ROR_UNION_SELECT - val1 First merged select - val2 Second merged select -*/ - -int QUICK_ROR_UNION_SELECT::queue_cmp(void *arg, uchar *val1, uchar *val2) -{ - QUICK_ROR_UNION_SELECT *self= (QUICK_ROR_UNION_SELECT*)arg; - return self->head->file->cmp_ref(((QUICK_SELECT_I*)val1)->last_rowid, - ((QUICK_SELECT_I*)val2)->last_rowid); -} - - -/* Initialize quick select for row retrieval. SYNOPSIS reset() diff --git a/sql/opt_range.h b/sql/opt_range.h index 85d59671b42..72f2eb4b51d 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -657,7 +657,6 @@ public: bool have_prev_rowid; /* true if prev_rowid has valid data */ uint rowid_length; /* table rowid length */ private: - static int queue_cmp(void *arg, uchar *val1, uchar *val2); bool scans_inited; }; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index a689d53d953..5b0b681c3a6 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -802,7 +802,8 @@ range_not_increasing_error: -1 a < b */ -int partition_info::list_part_cmp(const void* a, const void* b) +extern "C" +int partition_info_list_part_cmp(const void* a, const void* b) { longlong a1= ((LIST_PART_ENTRY*)a)->list_value; longlong b1= ((LIST_PART_ENTRY*)b)->list_value; @@ -814,7 +815,14 @@ int partition_info::list_part_cmp(const void* a, const void* b) return 0; } - /* + +int partition_info::list_part_cmp(const void* a, const void* b) +{ + return partition_info_list_part_cmp(a, b); +} + + +/* Compare two lists of column values in RANGE/LIST partitioning SYNOPSIS compare_column_values() @@ -826,8 +834,9 @@ int partition_info::list_part_cmp(const void* a, const void* b) +1 First argument is larger */ -int partition_info::compare_column_values(const void *first_arg, - const void *second_arg) +extern "C" +int partition_info_compare_column_values(const void *first_arg, + const void *second_arg) { const part_column_list_val *first= (part_column_list_val*)first_arg; const part_column_list_val *second= (part_column_list_val*)second_arg; @@ -863,6 +872,14 @@ int partition_info::compare_column_values(const void *first_arg, return 0; } + +int partition_info::compare_column_values(const void *first_arg, + const void *second_arg) +{ + return partition_info_compare_column_values(first_arg, second_arg); +} + + /* This routine allocates an array for all list constants to achieve a fast check what partition a certain value belongs to. At the same time it does @@ -895,7 +912,7 @@ bool partition_info::check_list_constants(THD *thd) void *UNINIT_VAR(prev_value); partition_element* part_def; bool found_null= FALSE; - int (*compare_func)(const void *, const void*); + qsort_cmp compare_func; void *ptr; List_iterator<partition_element> list_func_it(partitions); DBUG_ENTER("partition_info::check_list_constants"); @@ -952,7 +969,7 @@ bool partition_info::check_list_constants(THD *thd) part_column_list_val *loc_list_col_array; loc_list_col_array= (part_column_list_val*)ptr; list_col_array= (part_column_list_val*)ptr; - compare_func= compare_column_values; + compare_func= partition_info_compare_column_values; i= 0; do { @@ -972,7 +989,7 @@ bool partition_info::check_list_constants(THD *thd) } else { - compare_func= list_part_cmp; + compare_func= partition_info_list_part_cmp; list_array= (LIST_PART_ENTRY*)ptr; i= 0; /* diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h index cf28d2c8e29..25f2a60bece 100644 --- a/sql/rpl_utility.h +++ b/sql/rpl_utility.h @@ -233,7 +233,7 @@ struct RPL_TABLE_LIST /* Anonymous namespace for template functions/classes */ -namespace { +CPP_UNNAMED_NS_START /* Smart pointer that will automatically call my_afree (a macro) when @@ -260,7 +260,7 @@ namespace { Obj* get() { return m_ptr; } }; -} +CPP_UNNAMED_NS_END #endif // NB. number of printed bit values is limited to sizeof(buf) - 1 diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b090f35a607..ac092756a74 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -261,11 +261,13 @@ int thd_tablespace_op(const THD *thd) extern "C" -const char *set_thd_proc_info(THD *thd, const char *info, +const char *set_thd_proc_info(void *thd_arg, const char *info, const char *calling_function, const char *calling_file, const unsigned int calling_line) { + THD *thd= (THD *) thd_arg; + if (!thd) thd= current_thd; @@ -4207,7 +4209,9 @@ field_type_name(enum_field_types type) #endif -namespace { +/* Declare in unnamed namespace. */ +CPP_UNNAMED_NS_START + /** Class to handle temporary allocation of memory for row data. @@ -4326,8 +4330,8 @@ namespace { uchar *m_memory; uchar *m_ptr[2]; }; -} +CPP_UNNAMED_NS_END int THD::binlog_write_row(TABLE* table, bool is_trans, MY_BITMAP const* cols, size_t colcnt, diff --git a/sql/sql_class.h b/sql/sql_class.h index 015a87cb5cc..f1fce5ef472 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3685,7 +3685,7 @@ inline bool add_group_to_list(THD *thd, Item *item, bool asc) three calling-info parameters. */ extern "C" -const char *set_thd_proc_info(THD *thd, const char *info, +const char *set_thd_proc_info(void *thd_arg, const char *info, const char *calling_func, const char *calling_file, const unsigned int calling_line); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 8112bbba267..10884a95b74 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -44,7 +44,7 @@ #include "sql_partition.h" // make_used_partitions_str #include "sql_acl.h" // *_ACL #include "sql_test.h" // print_where, print_keyuse_array, - // print_sjm, print_plan + // print_sjm, print_plan, TEST_join #include "records.h" // init_read_record, end_read_record #include "filesort.h" // filesort_free_buffers #include "sql_union.h" // mysql_union @@ -90,8 +90,10 @@ static bool best_extension_by_limited_search(JOIN *join, double read_time, uint depth, uint prune_level); static uint determine_search_depth(JOIN* join); +C_MODE_START static int join_tab_cmp(const void* ptr1, const void* ptr2); static int join_tab_cmp_straight(const void* ptr1, const void* ptr2); +C_MODE_END /* TODO: 'find_best' is here only temporarily until 'greedy_search' is tested and approved. diff --git a/sql/sql_select.h b/sql/sql_select.h index ccf88c2cc5c..2c44dba74c3 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -597,7 +597,6 @@ typedef struct st_select_check { } SELECT_CHECK; extern const char *join_type_str[]; -void TEST_join(JOIN *join); /* Extern functions in sql_select.cc */ bool store_val_in_field(Field *field, Item *val, enum_check_fields check_flag); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index dda434a557a..16a17744279 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1945,10 +1945,13 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) static DYNAMIC_ARRAY all_status_vars; static bool status_vars_inited= 0; + +C_MODE_START static int show_var_cmp(const void *var1, const void *var2) { return strcmp(((SHOW_VAR*)var1)->name, ((SHOW_VAR*)var2)->name); } +C_MODE_END /* deletes all the SHOW_UNDEF elements from the array and calls diff --git a/sql/sql_test.cc b/sql/sql_test.cc index d34aee854d0..43d203e6498 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -76,7 +76,7 @@ print_where(COND *cond,const char *info, enum_query_type query_type) /* This is for debugging purposes */ -void print_cached_tables(void) +static void print_cached_tables(void) { uint idx,count,unused; TABLE_SHARE *share; @@ -341,6 +341,11 @@ print_plan(JOIN* join, uint idx, double record_count, double read_time, #endif +C_MODE_START +static int dl_compare(const void *p1, const void *p2); +static int print_key_cache_status(const char *name, KEY_CACHE *key_cache); +C_MODE_END + typedef struct st_debug_lock { ulong thread_id; @@ -350,8 +355,13 @@ typedef struct st_debug_lock enum thr_lock_type type; } TABLE_LOCK_INFO; -static int dl_compare(TABLE_LOCK_INFO *a,TABLE_LOCK_INFO *b) +static int dl_compare(const void *p1, const void *p2) { + TABLE_LOCK_INFO *a, *b; + + a= (TABLE_LOCK_INFO *) p1; + b= (TABLE_LOCK_INFO *) p2; + if (a->thread_id > b->thread_id) return 1; if (a->thread_id < b->thread_id) @@ -401,9 +411,10 @@ static void push_locks_into_array(DYNAMIC_ARRAY *ar, THR_LOCK_DATA *data, function so that we can easily add this if we ever need this. */ -static void display_table_locks(void) +static void display_table_locks(void) { LIST *list; + void *saved_base; DYNAMIC_ARRAY saved_table_locks; (void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO), table_cache_count + 20,50); @@ -424,13 +435,17 @@ static void display_table_locks(void) mysql_mutex_unlock(&lock->mutex); } mysql_mutex_unlock(&THR_LOCK_lock); - if (!saved_table_locks.elements) goto end; - - qsort((uchar*) dynamic_element(&saved_table_locks,0,TABLE_LOCK_INFO *),saved_table_locks.elements,sizeof(TABLE_LOCK_INFO),(qsort_cmp) dl_compare); + + if (!saved_table_locks.elements) + goto end; + + saved_base= dynamic_element(&saved_table_locks, 0, TABLE_LOCK_INFO *); + my_qsort(saved_base, saved_table_locks.elements, sizeof(TABLE_LOCK_INFO), + dl_compare); freeze_size(&saved_table_locks); puts("\nThread database.table_name Locked/Waiting Lock_type\n"); - + unsigned int i; for (i=0 ; i < saved_table_locks.elements ; i++) { diff --git a/sql/sql_test.h b/sql/sql_test.h index 539e89ec949..d7fcc126cb2 100644 --- a/sql/sql_test.h +++ b/sql/sql_test.h @@ -26,8 +26,8 @@ typedef struct st_sort_field SORT_FIELD; #ifndef DBUG_OFF void print_where(COND *cond,const char *info, enum_query_type query_type); -void print_cached_tables(void); void TEST_filesort(SORT_FIELD *sortorder,uint s_length); +void TEST_join(JOIN *join); void print_plan(JOIN* join,uint idx, double record_count, double read_time, double current_read_time, const char *info); void dump_TABLE_LIST_graph(SELECT_LEX *select_lex, TABLE_LIST* tl); |