diff options
33 files changed, 245 insertions, 123 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 4a7a8f0e58c..45fabe9cf8c 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2316,8 +2316,10 @@ static bool add_line(String &buffer,char *line,char *in_string, #ifdef HAVE_READLINE +C_MODE_START static char *new_command_generator(const char *text, int); -extern "C" char **new_mysql_completion (const char *text, int start, int end); +static char **new_mysql_completion(const char *text, int start, int end); +C_MODE_END /* Tell the GNU Readline library how to complete. We want to try to complete @@ -2449,9 +2451,9 @@ static void initialize_readline (char *name) array of matches, or NULL if there aren't any. */ -char **new_mysql_completion (const char *text, - int start __attribute__((unused)), - int end __attribute__((unused))) +static char **new_mysql_completion(const char *text, + int start __attribute__((unused)), + int end __attribute__((unused))) { if (!status.batch && !quick) #if defined(USE_NEW_READLINE_INTERFACE) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 24d520ff97f..d0c948e67bb 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -77,6 +77,12 @@ static int setenv(const char *name, const char *value, int overwrite); #endif +C_MODE_START +static sig_handler signal_handler(int sig); +static my_bool get_one_option(int optid, const struct my_option *, + char *argument); +C_MODE_END + enum { OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION, OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, @@ -462,7 +468,6 @@ void log_msg(const char *fmt, ...) VAR* var_from_env(const char *, const char *); VAR* var_init(VAR* v, const char *name, int name_len, const char *val, int val_len); -void var_free(void* v); VAR* var_get(const char *var_name, const char** var_name_end, my_bool raw, my_bool ignore_not_existing); void eval_expr(VAR* v, const char *p, const char** p_end); @@ -1914,6 +1919,8 @@ static void strip_parentheses(struct st_command *command) } +C_MODE_START + static uchar *get_var_key(const uchar* var, size_t *len, my_bool __attribute__((unused)) t) { @@ -1924,6 +1931,16 @@ static uchar *get_var_key(const uchar* var, size_t *len, } +static void var_free(void *v) +{ + my_free(((VAR*) v)->str_val, MYF(MY_WME)); + if (((VAR*)v)->alloced) + my_free(v, MYF(MY_WME)); +} + +C_MODE_END + + VAR *var_init(VAR *v, const char *name, int name_len, const char *val, int val_len) { @@ -1966,14 +1983,6 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, } -void var_free(void *v) -{ - my_free(((VAR*) v)->str_val, MYF(MY_WME)); - if (((VAR*)v)->alloced) - my_free(v, MYF(MY_WME)); -} - - VAR* var_from_env(const char *name, const char *def_val) { const char *tmp; @@ -6070,8 +6079,7 @@ void read_embedded_server_arguments(const char *name) static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument) +get_one_option(int optid, const struct my_option *, char *argument) { switch(optid) { case '#': diff --git a/cmd-line-utils/readline/input.c b/cmd-line-utils/readline/input.c index 84c0422059a..af81d9cd3b0 100644 --- a/cmd-line-utils/readline/input.c +++ b/cmd-line-utils/readline/input.c @@ -318,7 +318,9 @@ _rl_input_available () return (_kbhit ()); #endif +#if !defined (HAVE_SELECT) return 0; +#endif } int diff --git a/include/my_alloc.h b/include/my_alloc.h index 93b7438a1df..dbf104bda9a 100644 --- a/include/my_alloc.h +++ b/include/my_alloc.h @@ -23,6 +23,8 @@ #define ALLOC_MAX_BLOCK_TO_DROP 4096 #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 +C_MODE_START + typedef struct st_used_mem { /* struct for once_alloc (block) */ struct st_used_mem *next; /* Next block in use */ @@ -48,4 +50,7 @@ typedef struct st_mem_root void (*error_handler)(void); } MEM_ROOT; + +C_MODE_END + #endif diff --git a/include/my_base.h b/include/my_base.h index 7766d4165a2..28dc55b1b84 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -562,6 +562,8 @@ typedef ulong ha_rows; #define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2) /* invalidator function reference for Query Cache */ +C_MODE_START typedef void (* invalidator_by_filename)(const char * filename); +C_MODE_END #endif /* _my_base_h */ diff --git a/include/my_global.h b/include/my_global.h index 41735f4e4f5..c21a8a1f9ea 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -73,6 +73,11 @@ #define C_MODE_END #endif +#ifdef __cplusplus +#define CPP_UNNAMED_NS_START namespace { +#define CPP_UNNAMED_NS_END } +#endif + #if defined(_WIN32) #include <my_config.h> #elif defined(__NETWARE__) diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 4fef9e9ec0b..9c1d8adcd2f 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -202,6 +202,7 @@ typedef unsigned int MYSQL_FIELD_OFFSET; typedef unsigned long long my_ulonglong; #include "typelib.h" #include "my_alloc.h" +C_MODE_START typedef struct st_used_mem { struct st_used_mem *next; @@ -219,6 +220,7 @@ typedef struct st_mem_root unsigned int first_block_usage; void (*error_handler)(void); } MEM_ROOT; +C_MODE_END typedef struct st_typelib { unsigned int count; const char *name; diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c index 38fa0313c5d..c6a7af58f57 100644 --- a/mysys/my_gethwaddr.c +++ b/mysys/my_gethwaddr.c @@ -102,47 +102,49 @@ err: } #elif defined(__WIN__) -
-/* Workaround for BUG#32082 (Definition of VOID in my_global.h conflicts with
-windows headers) */
-#ifdef VOID
-#undef VOID
-#define VOID void
-#endif
+ +/* + Workaround for BUG#32082 (Definition of VOID in my_global.h conflicts with + windows headers) +*/ +#ifdef VOID +#undef VOID +#define VOID void +#endif #include <iphlpapi.h> -/* - The following typedef is for dynamically loading - iphlpapi.dll / GetAdaptersAddresses. Dynamic loading is - used because GetAdaptersAddresses is not available on Windows 2000 - which MySQL still supports. Static linking would cause an unresolved export. +/* + The following typedef is for dynamically loading iphlpapi.dll / + GetAdaptersAddresses. Dynamic loading is used because + GetAdaptersAddresses is not available on Windows 2000 which MySQL + still supports. Static linking would cause an unresolved export. */ typedef DWORD (WINAPI *pfnGetAdaptersAddresses)(IN ULONG Family, IN DWORD Flags,IN PVOID Reserved, - OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses, + OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses, IN OUT PULONG pOutBufLen); /* - my_gethwaddr - Windows version + my_gethwaddr - Windows version @brief Retrieve MAC address from network hardware - + @param[out] to MAC address exactly six bytes - + @return Operation status @retval 0 OK - @retval <>0 FAILED + @retval <>0 FAILED */ my_bool my_gethwaddr(uchar *to) -{ +{ PIP_ADAPTER_ADDRESSES pAdapterAddresses; PIP_ADAPTER_ADDRESSES pCurrAddresses; IP_ADAPTER_ADDRESSES adapterAddresses; ULONG address_len; - my_bool return_val= 1; - static pfnGetAdaptersAddresses fnGetAdaptersAddresses= - (pfnGetAdaptersAddresses)-1; + my_bool return_val= 1; + static pfnGetAdaptersAddresses fnGetAdaptersAddresses= + (pfnGetAdaptersAddresses)-1; if(fnGetAdaptersAddresses == (pfnGetAdaptersAddresses)-1) { @@ -156,7 +158,7 @@ my_bool my_gethwaddr(uchar *to) address_len= sizeof (IP_ADAPTER_ADDRESSES); /* Get the required size for the address data. */ - if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, &adapterAddresses, &address_len) + if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, &adapterAddresses, &address_len) == ERROR_BUFFER_OVERFLOW) { pAdapterAddresses= my_malloc(address_len, 0); @@ -167,29 +169,29 @@ my_bool my_gethwaddr(uchar *to) pAdapterAddresses= &adapterAddresses; /* one is enough don't alloc */ /* Get the hardware info. */ - if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &address_len) + if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &address_len) == NO_ERROR) { pCurrAddresses= pAdapterAddresses; - while (pCurrAddresses) + while (pCurrAddresses) { /* Look for ethernet cards. */ if (pCurrAddresses->IfType == IF_TYPE_ETHERNET_CSMACD) { /* check for a good address */ if (pCurrAddresses->PhysicalAddressLength < 6) - continue; /* bad address */ + continue; /* bad address */ /* save 6 bytes of the address in the 'to' parameter */ memcpy(to, pCurrAddresses->PhysicalAddress, 6); /* Network card found, we're done. */ return_val= 0; - break; + break; } pCurrAddresses= pCurrAddresses->Next; - } + } } /* Clean up memory allocation. */ diff --git a/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc index d6cc23a43b7..a55ba184a17 100644 --- a/plugin/semisync/semisync_master_plugin.cc +++ b/plugin/semisync/semisync_master_plugin.cc @@ -20,6 +20,8 @@ ReplSemiSyncMaster repl_semisync; +C_MODE_START + int repl_semi_report_binlog_update(Binlog_storage_param *param, const char *log_file, my_off_t log_pos, uint32 flags) @@ -145,6 +147,8 @@ int repl_semi_reset_master(Binlog_transmit_param *param) return 0; } +C_MODE_END + /* semisync system variables */ diff --git a/plugin/semisync/semisync_slave_plugin.cc b/plugin/semisync/semisync_slave_plugin.cc index 66073f8a5e6..5aa32cdfd5f 100644 --- a/plugin/semisync/semisync_slave_plugin.cc +++ b/plugin/semisync/semisync_slave_plugin.cc @@ -29,6 +29,8 @@ ReplSemiSyncSlave repl_semisync; */ bool semi_sync_need_reply= false; +C_MODE_START + int repl_semi_reset_slave(Binlog_relay_IO_param *param) { // TODO: reset semi-sync slave status here @@ -124,6 +126,7 @@ int repl_semi_slave_io_end(Binlog_relay_IO_param *param) return repl_semisync.slaveStop(param); } +C_MODE_END static void fix_rpl_semi_sync_slave_enabled(MYSQL_THD thd, SYS_VAR *var, 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); diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 6b7e60b126c..9fc868a2ebe 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -221,8 +221,10 @@ const char *ha_myisammrg::index_type(uint key_number) children_last_l -----------------------------------------+ */ -static int myisammrg_parent_open_callback(void *callback_param, - const char *filename) +CPP_UNNAMED_NS_START + +extern "C" int myisammrg_parent_open_callback(void *callback_param, + const char *filename) { ha_myisammrg *ha_myrg= (ha_myisammrg*) callback_param; TABLE *parent= ha_myrg->table_ptr(); @@ -320,6 +322,8 @@ static int myisammrg_parent_open_callback(void *callback_param, DBUG_RETURN(0); } +CPP_UNNAMED_NS_END + /** Open a MERGE parent table, but not its children. @@ -575,7 +579,9 @@ public: next child table. It is called for each child table. */ -static MI_INFO *myisammrg_attach_children_callback(void *callback_param) +CPP_UNNAMED_NS_START + +extern "C" MI_INFO *myisammrg_attach_children_callback(void *callback_param) { Mrg_attach_children_callback_param *param= (Mrg_attach_children_callback_param*) callback_param; @@ -643,6 +649,8 @@ static MI_INFO *myisammrg_attach_children_callback(void *callback_param) DBUG_RETURN(myisam); } +CPP_UNNAMED_NS_END + /** Returns a cloned instance of the current handler. diff --git a/storage/perfschema/pfs.cc b/storage/perfschema/pfs.cc index 380801c8677..f5901540ab0 100644 --- a/storage/perfschema/pfs.cc +++ b/storage/perfschema/pfs.cc @@ -806,6 +806,10 @@ static int build_prefix(const LEX_STRING *prefix, const char *category, } \ return; +/* Use C linkage for the interface functions. */ + +C_MODE_START + static void register_mutex_v1(const char *category, PSI_mutex_info_v1 *info, int count) @@ -2054,8 +2058,9 @@ static void* get_interface(int version) } } +C_MODE_END + struct PSI_bootstrap PFS_bootstrap= { get_interface }; - diff --git a/storage/perfschema/pfs_instr.cc b/storage/perfschema/pfs_instr.cc index fb40db02ca3..9507e2d2582 100644 --- a/storage/perfschema/pfs_instr.cc +++ b/storage/perfschema/pfs_instr.cc @@ -134,6 +134,10 @@ static PFS_events_waits *thread_history_array= NULL; static LF_HASH filename_hash; /** True if filename_hash is initialized. */ static bool filename_hash_inited= false; +C_MODE_START +/** Get hash table key for instrumented files. */ +static uchar *filename_hash_get_key(const uchar *, size_t *, my_bool); +C_MODE_END /** Initialize all the instruments instance buffers. diff --git a/storage/perfschema/pfs_instr_class.cc b/storage/perfschema/pfs_instr_class.cc index ac8aa64b0c5..d1535aa851b 100644 --- a/storage/perfschema/pfs_instr_class.cc +++ b/storage/perfschema/pfs_instr_class.cc @@ -118,6 +118,10 @@ PFS_instr_class global_table_class= static LF_HASH table_share_hash; /** True if table_share_hash is initialized. */ static bool table_share_hash_inited= false; +C_MODE_START +/** Get hash table key for instrumented tables. */ +static uchar *table_share_hash_get_key(const uchar *, size_t *, my_bool); +C_MODE_END static volatile uint32 file_class_dirty_count= 0; static volatile uint32 file_class_allocated_count= 0; diff --git a/storage/perfschema/pfs_server.cc b/storage/perfschema/pfs_server.cc index a1216c6ac30..f852a9fe732 100644 --- a/storage/perfschema/pfs_server.cc +++ b/storage/perfschema/pfs_server.cc @@ -32,8 +32,11 @@ PFS_global_param pfs_param; +C_MODE_START static void destroy_pfs_thread(void *key); -void cleanup_performance_schema(void); +C_MODE_END + +static void cleanup_performance_schema(void); struct PSI_bootstrap* initialize_performance_schema(const PFS_global_param *param) @@ -100,7 +103,7 @@ static void destroy_pfs_thread(void *key) destroy_thread(pfs); } -void cleanup_performance_schema(void) +static void cleanup_performance_schema(void) { cleanup_instruments(); cleanup_sync_class(); |