Bug#53445: Build with -Wall and fix warnings that it generates

Fix various mismatches between function's language linkage. Any
particular function that is declared in C++ but should be callable
from C must have C linkage. Note that function types with different
linkages are also distinct. Thus, if a function type is declared in
C code, it will have C linkage (same if declared in a extern "C"
block).

client/mysql.cc:
  Mismatch between prototype and declaration.
client/mysqltest.cc:
  mysqltest used to be C code. Use C linkage where appropriate.
cmd-line-utils/readline/input.c:
  Isolate unreachable code.
include/my_alloc.h:
  Function type must have C linkage.
include/my_base.h:
  Function type must have C linkage.
include/my_global.h:
  Add helper macros to avoid spurious namespace indentation.
include/mysql.h.pp:
  Update ABI file.
mysys/my_gethwaddr.c:
  Remove stray carriage return and fix coding style.
plugin/semisync/semisync_master_plugin.cc:
  Callback function types have C linkage.
plugin/semisync/semisync_slave_plugin.cc:
  Callback function types have C linkage.
sql/derror.cc:
  Expected function type has C linkage.
sql/field.cc:
  Use helper macro and fix indentation.
sql/handler.cc:
  Expected function type has C linkage.
sql/item_sum.cc:
  Correct function linkages. Remove now unnecessary cast.
sql/item_sum.h:
  Add prototypes with the appropriate linkage as otherwise they
  are distinct.
sql/mysqld.cc:
  Wrap functions in C linkage mode.
sql/opt_range.cc:
  C language linkage is ignored for class member functions.
sql/partition_info.cc:
  Add wrapper functions with C linkage for class member functions.
sql/rpl_utility.h:
  Use helper macro and fix indentation.
sql/sql_class.cc:
  Change type of thd argument -- THD is a class.
  Use helper macro and fix indentation.
sql/sql_class.h:
  Change type of thd argument -- THD is a class.
sql/sql_select.cc:
  Expected function type has C linkage.
sql/sql_select.h:
  Move prototype to sql_test.h
sql/sql_show.cc:
  Expected function type has C linkage.
sql/sql_test.cc:
  Fix required function prototype and fix coding style.
sql/sql_test.h:
  Removed unnecessary export and add another.
storage/myisammrg/ha_myisammrg.cc:
  Expected function type has C linkage.
storage/perfschema/pfs.cc:
  PSI headers are declared with C language linkage, which also
  applies to function types.
This commit is contained in:
Davi Arnaut 2010-05-31 12:29:54 -03:00
parent e5bcb6f36a
commit a8c288054e
33 changed files with 245 additions and 123 deletions

View File

@ -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)

View File

@ -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 '#':

View File

@ -318,7 +318,9 @@ _rl_input_available ()
return (_kbhit ());
#endif
#if !defined (HAVE_SELECT)
return 0;
#endif
}
int

View File

@ -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

View File

@ -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 */

View File

@ -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__)

View File

@ -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;

View File

@ -103,8 +103,10 @@ err:
#elif defined(__WIN__)
/* Workaround for BUG#32082 (Definition of VOID in my_global.h conflicts with
windows headers) */
/*
Workaround for BUG#32082 (Definition of VOID in my_global.h conflicts with
windows headers)
*/
#ifdef VOID
#undef VOID
#define VOID void
@ -113,10 +115,10 @@ windows headers) */
#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,

View File

@ -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
*/

View File

@ -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,

View File

@ -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.

View File

@ -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.

View File

@ -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
/**

View File

@ -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;
}

View File

@ -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,

View File

@ -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);

View File

@ -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,

View File

@ -1538,6 +1538,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
@ -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));
@ -1566,25 +1589,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

View File

@ -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;
};

View File

@ -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;
/*

View File

@ -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

View File

@ -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,

View File

@ -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);

View File

@ -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.

View File

@ -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);

View File

@ -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

View File

@ -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)
@ -404,6 +414,7 @@ static void push_locks_into_array(DYNAMIC_ARRAY *ar, THR_LOCK_DATA *data,
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,9 +435,13 @@ 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");

View File

@ -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);

View File

@ -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.

View File

@ -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
};

View File

@ -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.

View File

@ -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;

View File

@ -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();