Auto-merge from mysql-trunk.
This commit is contained in:
commit
0e7c10445f
@ -1139,6 +1139,7 @@ libmysqld/protocol_cursor.cc
|
||||
libmysqld/records.cc
|
||||
libmysqld/repl_failsafe.cc
|
||||
libmysqld/rpl_filter.cc
|
||||
libmysqld/rpl_handler.cc
|
||||
libmysqld/rpl_injector.cc
|
||||
libmysqld/rpl_record.cc
|
||||
libmysqld/rpl_record_old.cc
|
||||
@ -3064,4 +3065,8 @@ sql/share/spanish
|
||||
sql/share/swedish
|
||||
sql/share/ukrainian
|
||||
libmysqld/examples/mysqltest.cc
|
||||
libmysqld/sql_signal.cc
|
||||
libmysqld/rpl_handler.cc
|
||||
libmysqld/debug_sync.cc
|
||||
libmysqld/rpl_handler.cc
|
||||
dbug/tests
|
||||
|
@ -556,7 +556,7 @@ parse_package()
|
||||
package="pro"
|
||||
;;
|
||||
extended )
|
||||
package=""
|
||||
package="extended"
|
||||
;;
|
||||
cge )
|
||||
package="cge"
|
||||
@ -1274,7 +1274,7 @@ set_bsd_configs()
|
||||
if test "x$fast_flag" != "xno" ; then
|
||||
compiler_flags="$compiler_flags -O3"
|
||||
else
|
||||
compiler_flags="$compiler_flags -O"
|
||||
compiler_flags="$compiler_flags -O0"
|
||||
fi
|
||||
set_cc_and_cxx_for_gcc
|
||||
}
|
||||
@ -1305,7 +1305,7 @@ set_linux_configs()
|
||||
if test "x$fast_flag" != "xno" ; then
|
||||
compiler_flags="$compiler_flags -O2"
|
||||
else
|
||||
compiler_flags="$compiler_flags -O"
|
||||
compiler_flags="$compiler_flags -O0"
|
||||
fi
|
||||
# configure will set proper compiler flags for gcc on Linux
|
||||
elif test "x$compiler" = "xicc" ; then
|
||||
@ -1375,8 +1375,8 @@ set_solaris_configs()
|
||||
LDFLAGS="$LDFLAGS -O2"
|
||||
compiler_flags="$compiler_flags -O2"
|
||||
else
|
||||
LDFLAGS="$LDFLAGS -O"
|
||||
compiler_flags="$compiler_flags -O"
|
||||
LDFLAGS="$LDFLAGS -O0"
|
||||
compiler_flags="$compiler_flags -O0"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
@ -1407,7 +1407,7 @@ set_solaris_configs()
|
||||
elif test "x$fast_flag" = "xgeneric" ; then
|
||||
compiler_flags="$compiler_flags -xO2"
|
||||
else
|
||||
compiler_flags="$compiler_flags -xO"
|
||||
compiler_flags="$compiler_flags -xO0"
|
||||
fi
|
||||
else
|
||||
#Using SPARC cpu with SunStudio (Forte) compiler
|
||||
@ -1421,7 +1421,7 @@ set_solaris_configs()
|
||||
elif test "x$fast_flag" = "xgeneric" ; then
|
||||
compiler_flags="$compiler_flags -xO2"
|
||||
else
|
||||
compiler_flags="$compiler_flags -xO"
|
||||
compiler_flags="$compiler_flags -xO0"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@ -1452,7 +1452,7 @@ set_macosx_configs()
|
||||
if test "x$fast_flag" != "xno" ; then
|
||||
compiler_flags="$compiler_flags -Os"
|
||||
else
|
||||
compiler_flags="$compiler_flags -O"
|
||||
compiler_flags="$compiler_flags -O0"
|
||||
fi
|
||||
set_cc_and_cxx_for_gcc
|
||||
}
|
||||
|
@ -42,6 +42,13 @@ ADD_DEFINITIONS(-DSHAREDIR="share")
|
||||
# Set debug options
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS")
|
||||
|
||||
# Do not use SAFEMALLOC for Windows builds, as Debug CRT has the same functionality
|
||||
# Neither SAFE_MUTEX works on Windows and it has been explicitely undefined in
|
||||
# my_pthread.h
|
||||
IF(NOT WIN32)
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
ENDIF(NOT WIN32)
|
||||
|
||||
SET(localstatedir "C:\\mysql\\data")
|
||||
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-huge.cnf.sh
|
||||
@ -55,9 +62,6 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-medium.cnf.sh
|
||||
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-small.cnf.sh
|
||||
${CMAKE_SOURCE_DIR}/support-files/my-small.ini @ONLY)
|
||||
|
||||
|
||||
ADD_DEFINITIONS(-D__NT__)
|
||||
|
||||
IF(CYBOZU)
|
||||
ADD_DEFINITIONS(-DCYBOZU)
|
||||
ENDIF(CYBOZU)
|
||||
@ -287,6 +291,10 @@ FOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES})
|
||||
ADD_SUBDIRECTORY(${DIR})
|
||||
ENDFOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES})
|
||||
|
||||
# Add subdirectories for semisync plugin
|
||||
IF(NOT WITHOUT_DYNAMIC_PLUGINS)
|
||||
ADD_SUBDIRECTORY(plugin/semisync)
|
||||
ENDIF(NOT WITHOUT_DYNAMIC_PLUGINS)
|
||||
|
||||
# FIXME "debug" only needed if build type is "Debug", but
|
||||
# CMAKE_BUILD_TYPE is not set during configure time.
|
||||
@ -303,6 +311,7 @@ ADD_SUBDIRECTORY(extra)
|
||||
ADD_SUBDIRECTORY(client)
|
||||
ADD_SUBDIRECTORY(sql)
|
||||
ADD_SUBDIRECTORY(libmysql)
|
||||
ADD_SUBDIRECTORY(libservices)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
IF(WITH_EMBEDDED_SERVER)
|
||||
ADD_SUBDIRECTORY(libmysqld)
|
||||
|
13
Makefile.am
13
Makefile.am
@ -23,7 +23,7 @@ EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \
|
||||
|
||||
SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
|
||||
@readline_topdir@ sql-common scripts \
|
||||
@pstack_dir@ \
|
||||
@pstack_dir@ libservices \
|
||||
@sql_union_dirs@ unittest \
|
||||
@sql_server@ @man_dirs@ tests \
|
||||
netware @libmysqld_dirs@ \
|
||||
@ -32,7 +32,7 @@ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
|
||||
|
||||
DIST_SUBDIRS = . include Docs zlib \
|
||||
cmd-line-utils sql-common scripts \
|
||||
pstack \
|
||||
pstack libservices \
|
||||
strings mysys dbug extra regex libmysql libmysql_r client unittest storage plugin \
|
||||
vio sql man tests \
|
||||
netware libmysqld \
|
||||
@ -98,7 +98,8 @@ test-pr:
|
||||
|
||||
test-ns:
|
||||
cd mysql-test ; \
|
||||
@PERL@ ./mysql-test-run.pl $(force) $(mem) --mysqld=--binlog-format=mixed
|
||||
@PERL@ ./mysql-test-run.pl $(force) $(mem) --mysqld=--binlog-format=mixed ; \
|
||||
@PERL@ ./mysql-test-run.pl $(force) $(mem) --suite=funcs_1
|
||||
|
||||
test-binlog-statement:
|
||||
cd mysql-test ; \
|
||||
@ -198,6 +199,10 @@ test-bt-fast:
|
||||
-cd mysql-test ; MTR_BUILD_THREAD=auto \
|
||||
@PERL@ ./mysql-test-run.pl --force --comment=stress --suite=stress $(EXP)
|
||||
|
||||
test-bt-fast:
|
||||
-cd mysql-test ; MTR_BUILD_THREAD=auto \
|
||||
@PERL@ ./mysql-test-run.pl --force --comment=ps --ps-protocol --report-features
|
||||
|
||||
test-bt-debug:
|
||||
-cd mysql-test ; MTR_BUILD_THREAD=auto \
|
||||
@PERL@ ./mysql-test-run.pl --comment=debug --force --timer \
|
||||
@ -205,6 +210,8 @@ test-bt-debug:
|
||||
|
||||
test-bt-debug-fast:
|
||||
|
||||
test-bt-debug-fast:
|
||||
|
||||
# Keep these for a while
|
||||
test-pl: test
|
||||
test-full-pl: test-full
|
||||
|
@ -14,13 +14,6 @@
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
|
||||
|
||||
# We use the "mysqlclient_notls" library here just as safety, in case
|
||||
# any of the clients here would go beyond the client API and access the
|
||||
# Thread Local Storage directly.
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/zlib
|
||||
${CMAKE_SOURCE_DIR}/extra/yassl/include
|
||||
@ -30,27 +23,27 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/strings)
|
||||
|
||||
ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c)
|
||||
TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32)
|
||||
TARGET_LINK_LIBRARIES(mysql mysqlclient)
|
||||
|
||||
ADD_EXECUTABLE(mysqltest mysqltest.cc)
|
||||
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
|
||||
TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex wsock32 dbug)
|
||||
TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex dbug)
|
||||
|
||||
ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)
|
||||
TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient_notls wsock32)
|
||||
TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient)
|
||||
|
||||
ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c)
|
||||
TARGET_LINK_LIBRARIES(mysqldump mysqlclient_notls wsock32)
|
||||
TARGET_LINK_LIBRARIES(mysqldump mysqlclient)
|
||||
|
||||
ADD_EXECUTABLE(mysqlimport mysqlimport.c)
|
||||
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient_notls wsock32)
|
||||
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)
|
||||
|
||||
ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c)
|
||||
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient_notls wsock32)
|
||||
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient)
|
||||
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)
|
||||
|
||||
ADD_EXECUTABLE(mysqlshow mysqlshow.c)
|
||||
TARGET_LINK_LIBRARIES(mysqlshow mysqlclient_notls wsock32)
|
||||
TARGET_LINK_LIBRARIES(mysqlshow mysqlclient)
|
||||
|
||||
ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc
|
||||
../mysys/mf_tempdir.c
|
||||
@ -59,14 +52,14 @@ ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc
|
||||
../mysys/my_bitmap.c
|
||||
../mysys/my_vle.c
|
||||
../mysys/base64.c)
|
||||
TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient_notls wsock32)
|
||||
TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient)
|
||||
|
||||
ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
|
||||
TARGET_LINK_LIBRARIES(mysqladmin mysqlclient_notls wsock32)
|
||||
TARGET_LINK_LIBRARIES(mysqladmin mysqlclient)
|
||||
|
||||
ADD_EXECUTABLE(mysqlslap mysqlslap.c)
|
||||
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
|
||||
TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug)
|
||||
TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib dbug)
|
||||
|
||||
ADD_EXECUTABLE(echo echo.c)
|
||||
|
||||
|
@ -80,5 +80,6 @@ enum options_client
|
||||
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
|
||||
OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
|
||||
OPT_WRITE_BINLOG, OPT_DUMP_DATE,
|
||||
OPT_INIT_COMMAND,
|
||||
OPT_MAX_CLIENT_OPTION
|
||||
};
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef CLIENT_MY_READLINE_INCLUDED
|
||||
#define CLIENT_MY_READLINE_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -31,3 +34,5 @@ extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
|
||||
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
|
||||
extern char *batch_readline(LINE_BUFFER *buffer, bool *truncated);
|
||||
extern void batch_readline_end(LINE_BUFFER *buffer);
|
||||
|
||||
#endif /* CLIENT_MY_READLINE_INCLUDED */
|
||||
|
@ -141,7 +141,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
|
||||
vertical=0, line_numbers=1, column_names=1,opt_html=0,
|
||||
opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0,
|
||||
tty_password= 0, opt_nobeep=0, opt_reconnect=1,
|
||||
default_charset_used= 0, opt_secure_auth= 0,
|
||||
opt_secure_auth= 0,
|
||||
default_pager_set= 0, opt_sigint_ignore= 0,
|
||||
show_warnings= 0, executing_query= 0, interrupted_query= 0,
|
||||
ignore_spaces= 0;
|
||||
@ -155,7 +155,8 @@ static char * opt_mysql_unix_port=0;
|
||||
static int connect_flag=CLIENT_INTERACTIVE;
|
||||
static char *current_host,*current_db,*current_user=0,*opt_password=0,
|
||||
*current_prompt=0, *delimiter_str= 0,
|
||||
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
|
||||
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME,
|
||||
*opt_init_command= 0;
|
||||
static char *histfile;
|
||||
static char *histfile_tmp;
|
||||
static String glob_buffer,old_buffer;
|
||||
@ -1280,21 +1281,35 @@ sig_handler handle_sigint(int sig)
|
||||
MYSQL *kill_mysql= NULL;
|
||||
|
||||
/* terminate if no query being executed, or we already tried interrupting */
|
||||
if (!executing_query || interrupted_query)
|
||||
/* terminate if no query being executed, or we already tried interrupting */
|
||||
if (!executing_query || (interrupted_query == 2))
|
||||
{
|
||||
tee_fprintf(stdout, "Ctrl-C -- exit!\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
kill_mysql= mysql_init(kill_mysql);
|
||||
if (!mysql_real_connect(kill_mysql,current_host, current_user, opt_password,
|
||||
"", opt_mysql_port, opt_mysql_unix_port,0))
|
||||
{
|
||||
tee_fprintf(stdout, "Ctrl-C -- sorry, cannot connect to server to kill query, giving up ...\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
interrupted_query++;
|
||||
|
||||
/* mysqld < 5 does not understand KILL QUERY, skip to KILL CONNECTION */
|
||||
if ((interrupted_query == 1) && (mysql_get_server_version(&mysql) < 50000))
|
||||
interrupted_query= 2;
|
||||
|
||||
/* kill_buffer is always big enough because max length of %lu is 15 */
|
||||
sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql));
|
||||
mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
|
||||
sprintf(kill_buffer, "KILL %s%lu",
|
||||
(interrupted_query == 1) ? "QUERY " : "",
|
||||
mysql_thread_id(&mysql));
|
||||
tee_fprintf(stdout, "Ctrl-C -- sending \"%s\" to server ...\n", kill_buffer);
|
||||
mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer));
|
||||
mysql_close(kill_mysql);
|
||||
tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
|
||||
|
||||
interrupted_query= 1;
|
||||
tee_fprintf(stdout, "Ctrl-C -- query aborted.\n");
|
||||
|
||||
return;
|
||||
|
||||
@ -1384,6 +1399,10 @@ static struct my_option my_long_options[] =
|
||||
{"ignore-spaces", 'i', "Ignore space after function names.",
|
||||
(uchar**) &ignore_spaces, (uchar**) &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0,
|
||||
0, 0, 0, 0},
|
||||
{"init-command", OPT_INIT_COMMAND,
|
||||
"SQL Command to execute when connecting to MySQL server. Will automatically be re-executed when reconnecting.",
|
||||
(uchar**) &opt_init_command, (uchar**) &opt_init_command, 0,
|
||||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.",
|
||||
(uchar**) &opt_local_infile,
|
||||
(uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@ -1576,9 +1595,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir) - 1);
|
||||
charsets_dir = mysql_charsets_dir;
|
||||
break;
|
||||
case OPT_DEFAULT_CHARSET:
|
||||
default_charset_used= 1;
|
||||
break;
|
||||
case OPT_DELIMITER:
|
||||
if (argument == disabled_my_option)
|
||||
{
|
||||
@ -1783,10 +1799,6 @@ static int get_options(int argc, char **argv)
|
||||
connect_flag= 0; /* Not in interactive mode */
|
||||
}
|
||||
|
||||
if (strcmp(default_charset, charset_info->csname) &&
|
||||
!(charset_info= get_charset_by_csname(default_charset,
|
||||
MY_CS_PRIMARY, MYF(MY_WME))))
|
||||
exit(1);
|
||||
if (argc > 1)
|
||||
{
|
||||
usage(0);
|
||||
@ -2914,7 +2926,6 @@ com_charset(String *buffer __attribute__((unused)), char *line)
|
||||
charset_info= new_cs;
|
||||
mysql_set_character_set(&mysql, charset_info->csname);
|
||||
default_charset= (char *)charset_info->csname;
|
||||
default_charset_used= 1;
|
||||
put_info("Charset changed", INFO_INFO);
|
||||
}
|
||||
else put_info("Charset is not found", INFO_INFO);
|
||||
@ -4203,6 +4214,8 @@ sql_real_connect(char *host,char *database,char *user,char *password,
|
||||
mysql_close(&mysql);
|
||||
}
|
||||
mysql_init(&mysql);
|
||||
if (opt_init_command)
|
||||
mysql_options(&mysql, MYSQL_INIT_COMMAND, opt_init_command);
|
||||
if (opt_connect_timeout)
|
||||
{
|
||||
uint timeout=opt_connect_timeout;
|
||||
@ -4236,8 +4249,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
|
||||
select_limit,max_join_size);
|
||||
mysql_options(&mysql, MYSQL_INIT_COMMAND, init_command);
|
||||
}
|
||||
if (default_charset_used)
|
||||
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
|
||||
|
||||
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
|
||||
|
||||
if (!mysql_real_connect(&mysql, host, user, password,
|
||||
database, opt_mysql_port, opt_mysql_unix_port,
|
||||
connect_flag | CLIENT_MULTI_STATEMENTS))
|
||||
@ -4252,6 +4266,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
|
||||
}
|
||||
return -1; // Retryable
|
||||
}
|
||||
|
||||
charset_info= mysql.charset;
|
||||
|
||||
connected=1;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
mysql.reconnect= debug_info_flag; // We want to know if this happens
|
||||
|
@ -34,7 +34,8 @@
|
||||
static char mysql_path[FN_REFLEN];
|
||||
static char mysqlcheck_path[FN_REFLEN];
|
||||
|
||||
static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag;
|
||||
static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag,
|
||||
opt_systables_only;
|
||||
static uint my_end_arg= 0;
|
||||
static char *opt_user= (char*)"root";
|
||||
|
||||
@ -121,6 +122,10 @@ static struct my_option my_long_options[]=
|
||||
#include <sslopt-longopts.h>
|
||||
{"tmpdir", 't', "Directory for temporary files",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"upgrade-system-tables", 's', "Only upgrade the system tables "
|
||||
"do not try to upgrade the data.",
|
||||
(uchar**)&opt_systables_only, (uchar**)&opt_systables_only, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"user", 'u', "User for login if not current user.", (uchar**) &opt_user,
|
||||
(uchar**) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"verbose", 'v', "Display more output about the process",
|
||||
@ -838,8 +843,15 @@ int main(int argc, char **argv)
|
||||
/* Find mysql */
|
||||
find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"), self_name);
|
||||
|
||||
/* Find mysqlcheck */
|
||||
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
|
||||
if (!opt_systables_only)
|
||||
{
|
||||
/* Find mysqlcheck */
|
||||
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("The --upgrade-system-tables option was used, databases won't be touched.\n");
|
||||
}
|
||||
|
||||
/*
|
||||
Read the mysql_upgrade_info file to check if mysql_upgrade
|
||||
@ -856,8 +868,8 @@ int main(int argc, char **argv)
|
||||
/*
|
||||
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
|
||||
*/
|
||||
if (run_mysqlcheck_fixnames() ||
|
||||
run_mysqlcheck_upgrade() ||
|
||||
if ((!opt_systables_only &&
|
||||
(run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) ||
|
||||
run_sql_fix_privilege_tables())
|
||||
{
|
||||
/*
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define MAX_TRUNC_LENGTH 3
|
||||
|
||||
char *host= NULL, *user= 0, *opt_password= 0,
|
||||
*default_charset= NULL;
|
||||
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
|
||||
char truncated_var_names[MAX_MYSQL_VAR][MAX_TRUNC_LENGTH];
|
||||
char ex_var_names[MAX_MYSQL_VAR][FN_REFLEN];
|
||||
ulonglong last_values[MAX_MYSQL_VAR];
|
||||
@ -348,8 +348,7 @@ int main(int argc,char *argv[])
|
||||
if (shared_memory_base_name)
|
||||
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
|
||||
#endif
|
||||
if (default_charset)
|
||||
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
|
||||
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
|
||||
error_flags= (myf)(opt_nobeep ? 0 : ME_BELL);
|
||||
|
||||
if (sql_connect(&mysql, option_wait))
|
||||
|
@ -78,6 +78,9 @@ static const char* host = 0;
|
||||
static int port= 0;
|
||||
static uint my_end_arg;
|
||||
static const char* sock= 0;
|
||||
#ifdef HAVE_SMEM
|
||||
static char *shared_memory_base_name= 0;
|
||||
#endif
|
||||
static const char* user = 0;
|
||||
static char* pass = 0;
|
||||
static char *charset= 0;
|
||||
@ -992,13 +995,13 @@ static struct my_option my_long_options[] =
|
||||
/* 'unspec' is not mentioned because it is just a placeholder. */
|
||||
"Determine when the output statements should be base64-encoded BINLOG "
|
||||
"statements: 'never' disables it and works only for binlogs without "
|
||||
"row-based events; 'auto' is the default and prints base64 only when "
|
||||
"necessary (i.e., for row-based events and format description events); "
|
||||
"'decode-rows' suppresses BINLOG statements for row events, but does "
|
||||
"not exit as an error if a row event is found, unlike 'never'; "
|
||||
"'always' prints base64 whenever possible. 'always' is for debugging "
|
||||
"only and should not be used in a production system. The default is "
|
||||
"'auto'. --base64-output is a short form for --base64-output=always."
|
||||
"row-based events; 'decode-rows' decodes row events into commented SQL "
|
||||
"statements if the --verbose option is also given; 'auto' prints base64 "
|
||||
"only when necessary (i.e., for row-based events and format description "
|
||||
"events); 'always' prints base64 whenever possible. 'always' is for "
|
||||
"debugging only and should not be used in a production system. If this "
|
||||
"argument is not given, the default is 'auto'; if it is given with no "
|
||||
"argument, 'always' is used."
|
||||
,(uchar**) &opt_base64_output_mode_str,
|
||||
(uchar**) &opt_base64_output_mode_str,
|
||||
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@ -1077,6 +1080,12 @@ static struct my_option my_long_options[] =
|
||||
{"set-charset", OPT_SET_CHARSET,
|
||||
"Add 'SET NAMES character_set' to the output.", (uchar**) &charset,
|
||||
(uchar**) &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifdef HAVE_SMEM
|
||||
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
|
||||
"Base name of shared memory.", (uchar**) &shared_memory_base_name,
|
||||
(uchar**) &shared_memory_base_name,
|
||||
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"short-form", 's', "Just show regular queries: no extra info and no "
|
||||
"row-based events. This is for testing only, and should not be used in "
|
||||
"production systems. If you want to suppress base64-output, consider "
|
||||
@ -1349,7 +1358,6 @@ static int parse_args(int *argc, char*** argv)
|
||||
int ho_error;
|
||||
|
||||
result_file = stdout;
|
||||
load_defaults("my",load_default_groups,argc,argv);
|
||||
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
|
||||
exit(ho_error);
|
||||
if (debug_info_flag)
|
||||
@ -1379,6 +1387,11 @@ static Exit_status safe_connect()
|
||||
|
||||
if (opt_protocol)
|
||||
mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
|
||||
#ifdef HAVE_SMEM
|
||||
if (shared_memory_base_name)
|
||||
mysql_options(mysql, MYSQL_SHARED_MEMORY_BASE_NAME,
|
||||
shared_memory_base_name);
|
||||
#endif
|
||||
if (!mysql_real_connect(mysql, host, user, pass, 0, port, sock, 0))
|
||||
{
|
||||
error("Failed on connect: %s", mysql_error(mysql));
|
||||
@ -1912,7 +1925,7 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
|
||||
return ERROR_STOP;
|
||||
}
|
||||
#endif
|
||||
if (init_io_cache(file, fileno(stdin), 0, READ_CACHE, (my_off_t) 0,
|
||||
if (init_io_cache(file, my_fileno(stdin), 0, READ_CACHE, (my_off_t) 0,
|
||||
0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE)))
|
||||
{
|
||||
error("Failed to init IO cache.");
|
||||
@ -2001,8 +2014,9 @@ int main(int argc, char** argv)
|
||||
|
||||
my_init_time(); // for time functions
|
||||
|
||||
load_defaults("my", load_default_groups, &argc, &argv);
|
||||
defaults_argv= argv;
|
||||
parse_args(&argc, (char***)&argv);
|
||||
defaults_argv=argv;
|
||||
|
||||
if (!argc)
|
||||
{
|
||||
|
@ -369,12 +369,15 @@ static int get_options(int *argc, char ***argv)
|
||||
If there's no --default-character-set option given with
|
||||
--fix-table-name or --fix-db-name set the default character set to "utf8".
|
||||
*/
|
||||
if (!default_charset && (opt_fix_db_names || opt_fix_table_names))
|
||||
if (!default_charset)
|
||||
{
|
||||
default_charset= (char*) "utf8";
|
||||
if (opt_fix_db_names || opt_fix_table_names)
|
||||
default_charset= (char*) "utf8";
|
||||
else
|
||||
default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
|
||||
}
|
||||
if (default_charset && !get_charset_by_csname(default_charset, MY_CS_PRIMARY,
|
||||
MYF(MY_WME)))
|
||||
if (strcmp(default_charset, MYSQL_AUTODETECT_CHARSET_NAME) &&
|
||||
!get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME)))
|
||||
{
|
||||
printf("Unsupported character set: %s\n", default_charset);
|
||||
return 1;
|
||||
@ -798,8 +801,7 @@ static int dbConnect(char *host, char *user, char *passwd)
|
||||
if (shared_memory_base_name)
|
||||
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
|
||||
#endif
|
||||
if (default_charset)
|
||||
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
|
||||
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
|
||||
if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
|
||||
NULL, opt_mysql_port, opt_mysql_unix_port, 0)))
|
||||
{
|
||||
|
@ -861,9 +861,9 @@ static int get_options(int *argc, char ***argv)
|
||||
load_defaults("my",load_default_groups,argc,argv);
|
||||
defaults_argv= *argv;
|
||||
|
||||
if (hash_init(&ignore_table, charset_info, 16, 0, 0,
|
||||
(hash_get_key) get_table_key,
|
||||
(hash_free_key) free_table_ent, 0))
|
||||
if (my_hash_init(&ignore_table, charset_info, 16, 0, 0,
|
||||
(my_hash_get_key) get_table_key,
|
||||
(my_hash_free_key) free_table_ent, 0))
|
||||
return(EX_EOM);
|
||||
/* Don't copy internal log tables */
|
||||
if (my_hash_insert(&ignore_table,
|
||||
@ -1273,120 +1273,68 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name)
|
||||
}
|
||||
|
||||
/**
|
||||
Rewrite CREATE TRIGGER statement, enclosing DEFINER clause in
|
||||
version-specific comment.
|
||||
Rewrite statement, enclosing DEFINER clause in version-specific comment.
|
||||
|
||||
This function parses the CREATE TRIGGER statement and encloses
|
||||
DEFINER-clause in version-specific comment:
|
||||
input query: CREATE DEFINER=a@b TRIGGER ...
|
||||
rewritten query: CREATE * / / *!50017 DEFINER=a@b * / / *!50003 TRIGGER ...
|
||||
|
||||
@note This function will go away when WL#3995 is implemented.
|
||||
|
||||
@param[in] trigger_def_str CREATE TRIGGER statement string.
|
||||
@param[in] trigger_def_length length of the trigger_def_str.
|
||||
|
||||
@return pointer to the new allocated query string.
|
||||
*/
|
||||
|
||||
static char *cover_definer_clause_in_trigger(const char *trigger_def_str,
|
||||
uint trigger_def_length)
|
||||
{
|
||||
char *query_str= NULL;
|
||||
char *definer_begin= my_case_str(trigger_def_str, trigger_def_length,
|
||||
C_STRING_WITH_LEN(" DEFINER"));
|
||||
char *definer_end;
|
||||
|
||||
if (!definer_begin)
|
||||
return NULL;
|
||||
|
||||
definer_end= my_case_str(definer_begin, strlen(definer_begin),
|
||||
C_STRING_WITH_LEN(" TRIGGER"));
|
||||
|
||||
if (definer_end)
|
||||
{
|
||||
char *query_str_tail;
|
||||
|
||||
/*
|
||||
Allocate memory for new query string: original string
|
||||
from SHOW statement and version-specific comments.
|
||||
*/
|
||||
query_str= alloc_query_str(trigger_def_length + 23);
|
||||
|
||||
query_str_tail= strnmov(query_str,
|
||||
trigger_def_str,
|
||||
definer_begin - trigger_def_str);
|
||||
|
||||
query_str_tail= strmov(query_str_tail,
|
||||
"*/ /*!50017");
|
||||
|
||||
query_str_tail= strnmov(query_str_tail,
|
||||
definer_begin,
|
||||
definer_end - definer_begin);
|
||||
|
||||
query_str_tail= strxmov(query_str_tail,
|
||||
"*/ /*!50003",
|
||||
definer_end,
|
||||
NullS);
|
||||
}
|
||||
|
||||
return query_str;
|
||||
}
|
||||
|
||||
/**
|
||||
Rewrite CREATE FUNCTION or CREATE PROCEDURE statement, enclosing DEFINER
|
||||
clause in version-specific comment.
|
||||
|
||||
This function parses the CREATE FUNCTION | PROCEDURE statement and
|
||||
encloses DEFINER-clause in version-specific comment:
|
||||
This function parses any CREATE statement and encloses DEFINER-clause in
|
||||
version-specific comment:
|
||||
input query: CREATE DEFINER=a@b FUNCTION ...
|
||||
rewritten query: CREATE * / / *!50020 DEFINER=a@b * / / *!50003 FUNCTION ...
|
||||
|
||||
@note This function will go away when WL#3995 is implemented.
|
||||
|
||||
@param[in] def_str CREATE FUNCTION|PROCEDURE statement string.
|
||||
@param[in] def_str_length length of the def_str.
|
||||
@param[in] stmt_str CREATE statement string.
|
||||
@param[in] stmt_length Length of the stmt_str.
|
||||
@param[in] definer_version_str Minimal MySQL version number when
|
||||
DEFINER clause is supported in the
|
||||
given statement.
|
||||
@param[in] definer_version_length Length of definer_version_str.
|
||||
@param[in] stmt_version_str Minimal MySQL version number when the
|
||||
given statement is supported.
|
||||
@param[in] stmt_version_length Length of stmt_version_str.
|
||||
@param[in] keyword_str Keyword to look for after CREATE.
|
||||
@param[in] keyword_length Length of keyword_str.
|
||||
|
||||
@return pointer to the new allocated query string.
|
||||
*/
|
||||
|
||||
static char *cover_definer_clause_in_sp(const char *def_str,
|
||||
uint def_str_length)
|
||||
static char *cover_definer_clause(const char *stmt_str,
|
||||
uint stmt_length,
|
||||
const char *definer_version_str,
|
||||
uint definer_version_length,
|
||||
const char *stmt_version_str,
|
||||
uint stmt_version_length,
|
||||
const char *keyword_str,
|
||||
uint keyword_length)
|
||||
{
|
||||
char *query_str= NULL;
|
||||
char *definer_begin= my_case_str(def_str, def_str_length,
|
||||
char *definer_begin= my_case_str(stmt_str, stmt_length,
|
||||
C_STRING_WITH_LEN(" DEFINER"));
|
||||
char *definer_end;
|
||||
char *definer_end= NULL;
|
||||
|
||||
char *query_str= NULL;
|
||||
char *query_ptr;
|
||||
|
||||
if (!definer_begin)
|
||||
return NULL;
|
||||
|
||||
definer_end= my_case_str(definer_begin, strlen(definer_begin),
|
||||
C_STRING_WITH_LEN(" PROCEDURE"));
|
||||
keyword_str, keyword_length);
|
||||
|
||||
if (!definer_end)
|
||||
{
|
||||
definer_end= my_case_str(definer_begin, strlen(definer_begin),
|
||||
C_STRING_WITH_LEN(" FUNCTION"));
|
||||
}
|
||||
return NULL;
|
||||
|
||||
if (definer_end)
|
||||
{
|
||||
char *query_str_tail;
|
||||
/*
|
||||
Allocate memory for new query string: original string
|
||||
from SHOW statement and version-specific comments.
|
||||
*/
|
||||
query_str= alloc_query_str(stmt_length + 23);
|
||||
|
||||
/*
|
||||
Allocate memory for new query string: original string
|
||||
from SHOW statement and version-specific comments.
|
||||
*/
|
||||
query_str= alloc_query_str(def_str_length + 23);
|
||||
|
||||
query_str_tail= strnmov(query_str, def_str, definer_begin - def_str);
|
||||
query_str_tail= strmov(query_str_tail, "*/ /*!50020");
|
||||
query_str_tail= strnmov(query_str_tail, definer_begin,
|
||||
definer_end - definer_begin);
|
||||
query_str_tail= strxmov(query_str_tail, "*/ /*!50003",
|
||||
definer_end, NullS);
|
||||
}
|
||||
query_ptr= strnmov(query_str, stmt_str, definer_begin - stmt_str);
|
||||
query_ptr= strnmov(query_ptr, C_STRING_WITH_LEN("*/ /*!"));
|
||||
query_ptr= strnmov(query_ptr, definer_version_str, definer_version_length);
|
||||
query_ptr= strnmov(query_ptr, definer_begin, definer_end - definer_begin);
|
||||
query_ptr= strnmov(query_ptr, C_STRING_WITH_LEN("*/ /*!"));
|
||||
query_ptr= strnmov(query_ptr, stmt_version_str, stmt_version_length);
|
||||
query_ptr= strxmov(query_ptr, definer_end, NullS);
|
||||
|
||||
return query_str;
|
||||
}
|
||||
@ -1419,8 +1367,8 @@ static void free_resources()
|
||||
if (md_result_file && md_result_file != stdout)
|
||||
my_fclose(md_result_file, MYF(0));
|
||||
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
|
||||
if (hash_inited(&ignore_table))
|
||||
hash_free(&ignore_table);
|
||||
if (my_hash_inited(&ignore_table))
|
||||
my_hash_free(&ignore_table);
|
||||
if (extended_insert)
|
||||
dynstr_free(&extended_row);
|
||||
if (insert_pat_inited)
|
||||
@ -1922,6 +1870,8 @@ static uint dump_events_for_db(char *db)
|
||||
*/
|
||||
if (strlen(row[3]) != 0)
|
||||
{
|
||||
char *query_str;
|
||||
|
||||
if (opt_drop)
|
||||
fprintf(sql_file, "/*!50106 DROP EVENT IF EXISTS %s */%s\n",
|
||||
event_name, delimiter);
|
||||
@ -1948,31 +1898,36 @@ static uint dump_events_for_db(char *db)
|
||||
row[4], /* character_set_results */
|
||||
row[5]); /* collation_connection */
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
mysqldump is being run against the server, that does not
|
||||
provide character set information in SHOW CREATE
|
||||
statements.
|
||||
else
|
||||
{
|
||||
/*
|
||||
mysqldump is being run against the server, that does not
|
||||
provide character set information in SHOW CREATE
|
||||
statements.
|
||||
|
||||
NOTE: the dump may be incorrect, since character set
|
||||
information is required in order to restore event properly.
|
||||
*/
|
||||
NOTE: the dump may be incorrect, since character set
|
||||
information is required in order to restore event properly.
|
||||
*/
|
||||
|
||||
fprintf(sql_file,
|
||||
"--\n"
|
||||
"-- WARNING: old server version. "
|
||||
"The following dump may be incomplete.\n"
|
||||
"--\n");
|
||||
}
|
||||
fprintf(sql_file,
|
||||
"--\n"
|
||||
"-- WARNING: old server version. "
|
||||
"The following dump may be incomplete.\n"
|
||||
"--\n");
|
||||
}
|
||||
|
||||
switch_sql_mode(sql_file, delimiter, row[1]);
|
||||
|
||||
switch_time_zone(sql_file, delimiter, row[2]);
|
||||
|
||||
query_str= cover_definer_clause(row[3], strlen(row[3]),
|
||||
C_STRING_WITH_LEN("50117"),
|
||||
C_STRING_WITH_LEN("50106"),
|
||||
C_STRING_WITH_LEN(" EVENT"));
|
||||
|
||||
fprintf(sql_file,
|
||||
"/*!50106 %s */ %s\n",
|
||||
(const char *) row[3],
|
||||
(const char *) (query_str != NULL ? query_str : row[3]),
|
||||
(const char *) delimiter);
|
||||
|
||||
restore_time_zone(sql_file, delimiter);
|
||||
@ -2127,7 +2082,16 @@ static uint dump_routines_for_db(char *db)
|
||||
fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n",
|
||||
routine_type[i], routine_name);
|
||||
|
||||
query_str= cover_definer_clause_in_sp(row[2], strlen(row[2]));
|
||||
query_str= cover_definer_clause(row[2], strlen(row[2]),
|
||||
C_STRING_WITH_LEN("50020"),
|
||||
C_STRING_WITH_LEN("50003"),
|
||||
C_STRING_WITH_LEN(" FUNCTION"));
|
||||
|
||||
if (!query_str)
|
||||
query_str= cover_definer_clause(row[2], strlen(row[2]),
|
||||
C_STRING_WITH_LEN("50020"),
|
||||
C_STRING_WITH_LEN("50003"),
|
||||
C_STRING_WITH_LEN(" PROCEDURE"));
|
||||
|
||||
if (mysql_num_fields(routine_res) >= 6)
|
||||
{
|
||||
@ -2806,8 +2770,10 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
|
||||
|
||||
while ((row= mysql_fetch_row(show_create_trigger_rs)))
|
||||
{
|
||||
char *query_str= cover_definer_clause_in_trigger(row[2], strlen(row[2]));
|
||||
|
||||
char *query_str= cover_definer_clause(row[2], strlen(row[2]),
|
||||
C_STRING_WITH_LEN("50017"),
|
||||
C_STRING_WITH_LEN("50003"),
|
||||
C_STRING_WITH_LEN(" TRIGGER"));
|
||||
|
||||
if (switch_db_collation(sql_file, db_name, ";",
|
||||
db_cl_name, row[5], &db_cl_altered))
|
||||
@ -3316,7 +3282,7 @@ static void dump_table(char *table, char *db)
|
||||
{
|
||||
if (length)
|
||||
{
|
||||
if (!IS_NUM_FIELD(field))
|
||||
if (!(field->flags & NUM_FLAG))
|
||||
{
|
||||
/*
|
||||
"length * 2 + 2" is OK for both HEX and non-HEX modes:
|
||||
@ -3384,7 +3350,7 @@ static void dump_table(char *table, char *db)
|
||||
}
|
||||
if (row[i])
|
||||
{
|
||||
if (!IS_NUM_FIELD(field))
|
||||
if (!(field->flags & NUM_FLAG))
|
||||
{
|
||||
if (opt_xml)
|
||||
{
|
||||
@ -3992,7 +3958,7 @@ static int init_dumping(char *database, int init_func(char*))
|
||||
|
||||
my_bool include_table(const uchar *hash_key, size_t len)
|
||||
{
|
||||
return !hash_search(&ignore_table, hash_key, len);
|
||||
return ! my_hash_search(&ignore_table, hash_key, len);
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,11 +55,10 @@ static char *opt_password=0, *current_user=0,
|
||||
*current_host=0, *current_db=0, *fields_terminated=0,
|
||||
*lines_terminated=0, *enclosed=0, *opt_enclosed=0,
|
||||
*escaped=0, *opt_columns=0,
|
||||
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
|
||||
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
|
||||
static uint opt_mysql_port= 0, opt_protocol= 0;
|
||||
static char * opt_mysql_unix_port=0;
|
||||
static longlong opt_ignore_lines= -1;
|
||||
static CHARSET_INFO *charset_info= &my_charset_latin1;
|
||||
#include <sslopt-vars.h>
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
@ -282,10 +281,6 @@ static int get_options(int *argc, char ***argv)
|
||||
fprintf(stderr, "You can't use --ignore (-i) and --replace (-r) at the same time.\n");
|
||||
return(1);
|
||||
}
|
||||
if (strcmp(default_charset, charset_info->csname) &&
|
||||
!(charset_info= get_charset_by_csname(default_charset,
|
||||
MY_CS_PRIMARY, MYF(MY_WME))))
|
||||
exit(1);
|
||||
if (*argc < 2)
|
||||
{
|
||||
usage();
|
||||
@ -440,6 +435,7 @@ static MYSQL *db_connect(char *host, char *database,
|
||||
if (shared_memory_base_name)
|
||||
mysql_options(mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
|
||||
#endif
|
||||
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset);
|
||||
if (!(mysql_real_connect(mysql,host,user,passwd,
|
||||
database,opt_mysql_port,opt_mysql_unix_port,
|
||||
0)))
|
||||
|
@ -32,7 +32,7 @@ static my_bool tty_password= 0, opt_table_type= 0;
|
||||
static my_bool debug_info_flag= 0, debug_check_flag= 0;
|
||||
static uint my_end_arg= 0;
|
||||
static uint opt_verbose=0;
|
||||
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
|
||||
static char *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
static char *shared_memory_base_name=0;
|
||||
|
@ -1204,7 +1204,7 @@ get_options(int *argc,char ***argv)
|
||||
|
||||
if (opt_csv_str[0] == '-')
|
||||
{
|
||||
csv_file= fileno(stdout);
|
||||
csv_file= my_fileno(stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -81,6 +81,9 @@ enum {
|
||||
static int record= 0, opt_sleep= -1;
|
||||
static char *opt_db= 0, *opt_pass= 0;
|
||||
const char *opt_user= 0, *opt_host= 0, *unix_sock= 0, *opt_basedir= "./";
|
||||
#ifdef HAVE_SMEM
|
||||
static char *shared_memory_base_name=0;
|
||||
#endif
|
||||
const char *opt_logdir= "";
|
||||
const char *opt_include= 0, *opt_charsets_dir;
|
||||
static int opt_port= 0;
|
||||
@ -112,6 +115,8 @@ static uint my_end_arg= 0;
|
||||
/* Number of lines of the result to include in failure report */
|
||||
static uint opt_tail_lines= 0;
|
||||
|
||||
static uint opt_connect_timeout= 0;
|
||||
|
||||
static char delimiter[MAX_DELIMITER_LENGTH]= ";";
|
||||
static uint delimiter_length= 1;
|
||||
|
||||
@ -257,8 +262,7 @@ enum enum_commands {
|
||||
Q_SEND, Q_REAP,
|
||||
Q_DIRTY_CLOSE, Q_REPLACE, Q_REPLACE_COLUMN,
|
||||
Q_PING, Q_EVAL,
|
||||
Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
|
||||
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
|
||||
Q_EVAL_RESULT,
|
||||
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
|
||||
Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
|
||||
Q_WAIT_FOR_SLAVE_TO_STOP,
|
||||
@ -317,9 +321,6 @@ const char *command_names[]=
|
||||
"replace_column",
|
||||
"ping",
|
||||
"eval",
|
||||
"rpl_probe",
|
||||
"enable_rpl_parse",
|
||||
"disable_rpl_parse",
|
||||
"eval_result",
|
||||
/* Enable/disable that the _query_ is logged to result file */
|
||||
"enable_query_log",
|
||||
@ -659,14 +660,6 @@ public:
|
||||
LogFile log_file;
|
||||
LogFile progress_file;
|
||||
|
||||
|
||||
/* Disable functions that only exist in MySQL 4.0 */
|
||||
#if MYSQL_VERSION_ID < 40000
|
||||
void mysql_enable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
|
||||
void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
|
||||
int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
|
||||
my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
|
||||
#endif
|
||||
void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
|
||||
int len);
|
||||
void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
|
||||
@ -1135,7 +1128,7 @@ void free_used_memory()
|
||||
|
||||
close_connections();
|
||||
close_files();
|
||||
hash_free(&var_hash);
|
||||
my_hash_free(&var_hash);
|
||||
|
||||
for (i= 0 ; i < q_lines.elements ; i++)
|
||||
{
|
||||
@ -1168,7 +1161,6 @@ void free_used_memory()
|
||||
mysql_server_end();
|
||||
|
||||
/* Don't use DBUG after mysql_server_end() */
|
||||
DBUG_VIOLATION_HELPER_LEAVE;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1998,8 +1990,8 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw,
|
||||
if (length >= MAX_VAR_NAME_LENGTH)
|
||||
die("Too long variable name: %s", save_var_name);
|
||||
|
||||
if (!(v = (VAR*) hash_search(&var_hash, (const uchar*) save_var_name,
|
||||
length)))
|
||||
if (!(v = (VAR*) my_hash_search(&var_hash, (const uchar*) save_var_name,
|
||||
length)))
|
||||
{
|
||||
char buff[MAX_VAR_NAME_LENGTH+1];
|
||||
strmake(buff, save_var_name, length);
|
||||
@ -2030,7 +2022,7 @@ err:
|
||||
VAR *var_obtain(const char *name, int len)
|
||||
{
|
||||
VAR* v;
|
||||
if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len)))
|
||||
if ((v = (VAR*)my_hash_search(&var_hash, (const uchar *) name, len)))
|
||||
return v;
|
||||
v = var_init(0, name, len, "", 0);
|
||||
my_hash_insert(&var_hash, (uchar*)v);
|
||||
@ -2964,6 +2956,7 @@ void do_move_file(struct st_command *command)
|
||||
void do_chmod_file(struct st_command *command)
|
||||
{
|
||||
long mode= 0;
|
||||
int err_code;
|
||||
static DYNAMIC_STRING ds_mode;
|
||||
static DYNAMIC_STRING ds_file;
|
||||
const struct command_arg chmod_file_args[] = {
|
||||
@ -2983,7 +2976,10 @@ void do_chmod_file(struct st_command *command)
|
||||
die("You must write a 4 digit octal number for mode");
|
||||
|
||||
DBUG_PRINT("info", ("chmod %o %s", (uint)mode, ds_file.str));
|
||||
handle_command_error(command, chmod(ds_file.str, mode));
|
||||
err_code= chmod(ds_file.str, mode);
|
||||
if (err_code < 0)
|
||||
err_code= 1;
|
||||
handle_command_error(command, err_code);
|
||||
dynstr_free(&ds_mode);
|
||||
dynstr_free(&ds_file);
|
||||
DBUG_VOID_RETURN;
|
||||
@ -3844,12 +3840,8 @@ int do_save_master_pos()
|
||||
MYSQL_ROW row;
|
||||
MYSQL *mysql = &cur_con->mysql;
|
||||
const char *query;
|
||||
int rpl_parse;
|
||||
DBUG_ENTER("do_save_master_pos");
|
||||
|
||||
rpl_parse = mysql_rpl_parse_enabled(mysql);
|
||||
mysql_disable_rpl_parse(mysql);
|
||||
|
||||
#ifdef HAVE_NDB_BINLOG
|
||||
/*
|
||||
Wait for ndb binlog to be up-to-date with all changes
|
||||
@ -3999,10 +3991,6 @@ int do_save_master_pos()
|
||||
strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1);
|
||||
master_pos.pos = strtoul(row[1], (char**) 0, 10);
|
||||
mysql_free_result(res);
|
||||
|
||||
if (rpl_parse)
|
||||
mysql_enable_rpl_parse(mysql);
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@ -4065,29 +4053,6 @@ void do_let(struct st_command *command)
|
||||
}
|
||||
|
||||
|
||||
int do_rpl_probe(struct st_command *command __attribute__((unused)))
|
||||
{
|
||||
DBUG_ENTER("do_rpl_probe");
|
||||
if (mysql_rpl_probe(&cur_con->mysql))
|
||||
die("Failed in mysql_rpl_probe(): '%s'", mysql_error(&cur_con->mysql));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
int do_enable_rpl_parse(struct st_command *command __attribute__((unused)))
|
||||
{
|
||||
mysql_enable_rpl_parse(&cur_con->mysql);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int do_disable_rpl_parse(struct st_command *command __attribute__((unused)))
|
||||
{
|
||||
mysql_disable_rpl_parse(&cur_con->mysql);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Sleep the number of specified seconds
|
||||
|
||||
@ -4896,6 +4861,8 @@ do_handle_error:
|
||||
<opts> - options to use for the connection
|
||||
* SSL - use SSL if available
|
||||
* COMPRESS - use compression if available
|
||||
* SHM - use shared memory if available
|
||||
* PIPE - use named pipe if available
|
||||
|
||||
*/
|
||||
|
||||
@ -4904,6 +4871,7 @@ void do_connect(struct st_command *command)
|
||||
int con_port= opt_port;
|
||||
char *con_options;
|
||||
my_bool con_ssl= 0, con_compress= 0;
|
||||
my_bool con_pipe= 0, con_shm= 0;
|
||||
struct st_connection* con_slot;
|
||||
|
||||
static DYNAMIC_STRING ds_connection_name;
|
||||
@ -4914,6 +4882,9 @@ void do_connect(struct st_command *command)
|
||||
static DYNAMIC_STRING ds_port;
|
||||
static DYNAMIC_STRING ds_sock;
|
||||
static DYNAMIC_STRING ds_options;
|
||||
#ifdef HAVE_SMEM
|
||||
static DYNAMIC_STRING ds_shm;
|
||||
#endif
|
||||
const struct command_arg connect_args[] = {
|
||||
{ "connection name", ARG_STRING, TRUE, &ds_connection_name, "Name of the connection" },
|
||||
{ "host", ARG_STRING, TRUE, &ds_host, "Host to connect to" },
|
||||
@ -4941,6 +4912,11 @@ void do_connect(struct st_command *command)
|
||||
die("Illegal argument for port: '%s'", ds_port.str);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
/* Shared memory */
|
||||
init_dynamic_string(&ds_shm, ds_sock.str, 0, 0);
|
||||
#endif
|
||||
|
||||
/* Sock */
|
||||
if (ds_sock.length)
|
||||
{
|
||||
@ -4979,6 +4955,10 @@ void do_connect(struct st_command *command)
|
||||
con_ssl= 1;
|
||||
else if (!strncmp(con_options, "COMPRESS", 8))
|
||||
con_compress= 1;
|
||||
else if (!strncmp(con_options, "PIPE", 4))
|
||||
con_pipe= 1;
|
||||
else if (!strncmp(con_options, "SHM", 3))
|
||||
con_shm= 1;
|
||||
else
|
||||
die("Illegal option to connect: %.*s",
|
||||
(int) (end - con_options), con_options);
|
||||
@ -5003,6 +4983,11 @@ void do_connect(struct st_command *command)
|
||||
#endif
|
||||
if (!mysql_init(&con_slot->mysql))
|
||||
die("Failed on mysql_init()");
|
||||
|
||||
if (opt_connect_timeout)
|
||||
mysql_options(&con_slot->mysql, MYSQL_OPT_CONNECT_TIMEOUT,
|
||||
(void *) &opt_connect_timeout);
|
||||
|
||||
if (opt_compress || con_compress)
|
||||
mysql_options(&con_slot->mysql, MYSQL_OPT_COMPRESS, NullS);
|
||||
mysql_options(&con_slot->mysql, MYSQL_OPT_LOCAL_INFILE, 0);
|
||||
@ -5026,6 +5011,31 @@ void do_connect(struct st_command *command)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __WIN__
|
||||
if (con_pipe)
|
||||
{
|
||||
uint protocol= MYSQL_PROTOCOL_PIPE;
|
||||
mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, &protocol);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
if (con_shm)
|
||||
{
|
||||
uint protocol= MYSQL_PROTOCOL_MEMORY;
|
||||
if (!ds_shm.length)
|
||||
die("Missing shared memory base name");
|
||||
mysql_options(&con_slot->mysql, MYSQL_SHARED_MEMORY_BASE_NAME, ds_shm.str);
|
||||
mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, &protocol);
|
||||
}
|
||||
else if(shared_memory_base_name)
|
||||
{
|
||||
mysql_options(&con_slot->mysql, MYSQL_SHARED_MEMORY_BASE_NAME,
|
||||
shared_memory_base_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Use default db name */
|
||||
if (ds_database.length == 0)
|
||||
dynstr_set(&ds_database, opt_db);
|
||||
@ -5058,6 +5068,9 @@ void do_connect(struct st_command *command)
|
||||
dynstr_free(&ds_port);
|
||||
dynstr_free(&ds_sock);
|
||||
dynstr_free(&ds_options);
|
||||
#ifdef HAVE_SMEM
|
||||
dynstr_free(&ds_shm);
|
||||
#endif
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@ -5724,6 +5737,12 @@ static struct my_option my_long_options[] =
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"server-file", 'F', "Read embedded server arguments from file.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifdef HAVE_SMEM
|
||||
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
|
||||
"Base name of shared memory.", (uchar**) &shared_memory_base_name,
|
||||
(uchar**) &shared_memory_base_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
|
||||
0, 0, 0},
|
||||
#endif
|
||||
{"silent", 's', "Suppress all normal output. Synonym for --quiet.",
|
||||
(uchar**) &silent, (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"skip-safemalloc", OPT_SKIP_SAFEMALLOC,
|
||||
@ -5758,6 +5777,11 @@ static struct my_option my_long_options[] =
|
||||
{"view-protocol", OPT_VIEW_PROTOCOL, "Use views for select",
|
||||
(uchar**) &view_protocol, (uchar**) &view_protocol, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"connect_timeout", OPT_CONNECT_TIMEOUT,
|
||||
"Number of seconds before connection timeout.",
|
||||
(uchar**) &opt_connect_timeout,
|
||||
(uchar**) &opt_connect_timeout, 0, GET_UINT, REQUIRED_ARG,
|
||||
120, 0, 3600 * 12, 0, 0, 0},
|
||||
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@ -6496,8 +6520,6 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
|
||||
|
||||
if (!disable_result_log)
|
||||
{
|
||||
ulonglong UNINIT_VAR(affected_rows); /* Ok to be undef if 'disable_info' is set */
|
||||
|
||||
if (res)
|
||||
{
|
||||
MYSQL_FIELD *fields= mysql_fetch_fields(res);
|
||||
@ -6514,10 +6536,10 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
|
||||
|
||||
/*
|
||||
Need to call mysql_affected_rows() before the "new"
|
||||
query to find the warnings
|
||||
query to find the warnings.
|
||||
*/
|
||||
if (!disable_info)
|
||||
affected_rows= mysql_affected_rows(mysql);
|
||||
append_info(ds, mysql_affected_rows(mysql), mysql_info(mysql));
|
||||
|
||||
/*
|
||||
Add all warnings to the result. We can't do this if we are in
|
||||
@ -6532,9 +6554,6 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
|
||||
dynstr_append_mem(ds, ds_warnings->str, ds_warnings->length);
|
||||
}
|
||||
}
|
||||
|
||||
if (!disable_info)
|
||||
append_info(ds, affected_rows, mysql_info(mysql));
|
||||
}
|
||||
|
||||
if (res)
|
||||
@ -6775,10 +6794,8 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
|
||||
MYSQL_STMT *stmt;
|
||||
DYNAMIC_STRING ds_prepare_warnings;
|
||||
DYNAMIC_STRING ds_execute_warnings;
|
||||
ulonglong affected_rows;
|
||||
DBUG_ENTER("run_query_stmt");
|
||||
DBUG_PRINT("query", ("'%-.60s'", query));
|
||||
LINT_INIT(affected_rows);
|
||||
|
||||
/*
|
||||
Init a new stmt if it's not already one created for this connection
|
||||
@ -6910,11 +6927,12 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
|
||||
}
|
||||
|
||||
/*
|
||||
Need to grab affected rows information before getting
|
||||
warnings here
|
||||
Fetch info before fetching warnings, since it will be reset
|
||||
otherwise.
|
||||
*/
|
||||
|
||||
if (!disable_info)
|
||||
affected_rows= mysql_affected_rows(mysql);
|
||||
append_info(ds, mysql_stmt_affected_rows(stmt), mysql_info(mysql));
|
||||
|
||||
if (!disable_warnings)
|
||||
{
|
||||
@ -6927,21 +6945,17 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
|
||||
ds_warnings->length)
|
||||
{
|
||||
dynstr_append_mem(ds, "Warnings:\n", 10);
|
||||
if (ds_warnings->length)
|
||||
dynstr_append_mem(ds, ds_warnings->str,
|
||||
ds_warnings->length);
|
||||
if (ds_prepare_warnings.length)
|
||||
dynstr_append_mem(ds, ds_prepare_warnings.str,
|
||||
ds_prepare_warnings.length);
|
||||
if (ds_execute_warnings.length)
|
||||
dynstr_append_mem(ds, ds_execute_warnings.str,
|
||||
ds_execute_warnings.length);
|
||||
if (ds_warnings->length)
|
||||
dynstr_append_mem(ds, ds_warnings->str,
|
||||
ds_warnings->length);
|
||||
if (ds_prepare_warnings.length)
|
||||
dynstr_append_mem(ds, ds_prepare_warnings.str,
|
||||
ds_prepare_warnings.length);
|
||||
if (ds_execute_warnings.length)
|
||||
dynstr_append_mem(ds, ds_execute_warnings.str,
|
||||
ds_execute_warnings.length);
|
||||
}
|
||||
}
|
||||
|
||||
if (!disable_info)
|
||||
append_info(ds, affected_rows, mysql_info(mysql));
|
||||
|
||||
}
|
||||
|
||||
end:
|
||||
@ -6990,6 +7004,10 @@ int util_query(MYSQL* org_mysql, const char* query){
|
||||
if (!(mysql= mysql_init(mysql)))
|
||||
die("Failed in mysql_init()");
|
||||
|
||||
if (opt_connect_timeout)
|
||||
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT,
|
||||
(void *) &opt_connect_timeout);
|
||||
|
||||
/* enable local infile, in non-binary builds often disabled by default */
|
||||
mysql_options(mysql, MYSQL_OPT_LOCAL_INFILE, 0);
|
||||
safe_connect(mysql, "util", org_mysql->host, org_mysql->user,
|
||||
@ -7585,8 +7603,8 @@ int main(int argc, char **argv)
|
||||
|
||||
my_init_dynamic_array(&q_lines, sizeof(struct st_command*), 1024, 1024);
|
||||
|
||||
if (hash_init(&var_hash, charset_info,
|
||||
1024, 0, 0, get_var_key, var_free, MYF(0)))
|
||||
if (my_hash_init(&var_hash, charset_info,
|
||||
1024, 0, 0, get_var_key, var_free, MYF(0)))
|
||||
die("Variable hash initialization failed");
|
||||
|
||||
var_set_string("$MYSQL_SERVER_VERSION", MYSQL_SERVER_VERSION);
|
||||
@ -7649,6 +7667,9 @@ int main(int argc, char **argv)
|
||||
st_connection *con= connections;
|
||||
if (!( mysql_init(&con->mysql)))
|
||||
die("Failed in mysql_init()");
|
||||
if (opt_connect_timeout)
|
||||
mysql_options(&con->mysql, MYSQL_OPT_CONNECT_TIMEOUT,
|
||||
(void *) &opt_connect_timeout);
|
||||
if (opt_compress)
|
||||
mysql_options(&con->mysql,MYSQL_OPT_COMPRESS,NullS);
|
||||
mysql_options(&con->mysql, MYSQL_OPT_LOCAL_INFILE, 0);
|
||||
@ -7673,6 +7694,11 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
if (shared_memory_base_name)
|
||||
mysql_options(&con->mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
|
||||
#endif
|
||||
|
||||
if (!(con->name = my_strdup("default", MYF(MY_WME))))
|
||||
die("Out of memory");
|
||||
|
||||
@ -7748,9 +7774,6 @@ int main(int argc, char **argv)
|
||||
case Q_DISCONNECT:
|
||||
case Q_DIRTY_CLOSE:
|
||||
do_close_connection(command); break;
|
||||
case Q_RPL_PROBE: do_rpl_probe(command); break;
|
||||
case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(command); break;
|
||||
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(command); break;
|
||||
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
|
||||
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
|
||||
case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break;
|
||||
|
@ -33,7 +33,7 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
|
||||
if (!(line_buff=(LINE_BUFFER*)
|
||||
my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL))))
|
||||
return 0;
|
||||
if (init_line_buffer(line_buff,fileno(file),IO_SIZE,max_size))
|
||||
if (init_line_buffer(line_buff,my_fileno(file),IO_SIZE,max_size))
|
||||
{
|
||||
my_free(line_buff,MYF(0));
|
||||
return 0;
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef CLIENT_SQL_STRING_INCLUDED
|
||||
#define CLIENT_SQL_STRING_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -353,3 +356,5 @@ public:
|
||||
return (s->alloced && Ptr >= s->Ptr && Ptr < s->Ptr + s->str_length);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* CLIENT_SQL_STRING_INCLUDED */
|
||||
|
38
configure.in
38
configure.in
@ -617,24 +617,6 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(whether features provided by the user community should be included.)
|
||||
AC_ARG_ENABLE(community-features,
|
||||
AC_HELP_STRING(
|
||||
[--disable-community-features],
|
||||
[Disable additional features provided by the user community.]),
|
||||
[ ENABLE_COMMUNITY_FEATURES=$enableval ],
|
||||
[ ENABLE_COMMUNITY_FEATURES=yes ]
|
||||
)
|
||||
|
||||
if test "$ENABLE_COMMUNITY_FEATURES" = "yes"
|
||||
then
|
||||
AC_DEFINE([COMMUNITY_SERVER], [1],
|
||||
[Whether features provided by the user community should be included])
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(server-suffix,
|
||||
[ --with-server-suffix Append value to the version string.],
|
||||
[ MYSQL_SERVER_SUFFIX=`echo "$withval" | sed -e 's/^\(...................................\)..*$/\1/'` ],
|
||||
@ -700,21 +682,14 @@ fi
|
||||
# Add query profiler
|
||||
AC_MSG_CHECKING(if SHOW PROFILE should be enabled.)
|
||||
AC_ARG_ENABLE(profiling,
|
||||
AS_HELP_STRING([--enable-profiling], [Build a version with query profiling code (req. community-features)]),
|
||||
AS_HELP_STRING([--enable-profiling], [Enable profiling of query lifetime.]),
|
||||
[ ENABLED_PROFILING=$enableval ],
|
||||
[ ENABLED_PROFILING=$ENABLE_COMMUNITY_FEATURES ])
|
||||
[ ENABLED_PROFILING=no ])
|
||||
|
||||
AC_DEFINE([ENABLED_PROFILING], [1], [If SHOW PROFILE should be enabled])
|
||||
if test "$ENABLED_PROFILING" = "yes"
|
||||
then
|
||||
if test "$ENABLE_COMMUNITY_FEATURES" = "yes";
|
||||
then
|
||||
AC_DEFINE([ENABLED_PROFILING], [1],
|
||||
[If SHOW PROFILE should be enabled])
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
ENABLED_PROFILING="no"
|
||||
AC_MSG_RESULT([no, overridden by community-features disabled])
|
||||
fi
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
@ -2048,10 +2023,11 @@ AC_SUBST(MAKE_SHELL)
|
||||
AC_CHECK_HEADERS(varargs.h stdarg.h dirent.h locale.h ndir.h sys/dir.h \
|
||||
sys/file.h sys/ndir.h sys/ptem.h sys/pte.h sys/select.h sys/stream.h \
|
||||
sys/mman.h curses.h termcap.h termio.h termbits.h asm/termbits.h grp.h \
|
||||
paths.h semaphore.h)
|
||||
paths.h semaphore.h langinfo.h)
|
||||
|
||||
# Already-done: strcasecmp
|
||||
AC_CHECK_FUNCS(lstat putenv select setenv setlocale strcoll tcgetattr)
|
||||
AC_CHECK_FUNCS(nl_langinfo)
|
||||
|
||||
AC_STAT_MACROS_BROKEN
|
||||
MYSQL_SIGNAL_CHECK
|
||||
@ -2945,7 +2921,7 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl
|
||||
man/Makefile BUILD/Makefile vio/Makefile dnl
|
||||
libmysql/Makefile libmysql_r/Makefile client/Makefile dnl
|
||||
sql/Makefile sql/share/Makefile dnl
|
||||
sql/sql_builtin.cc sql-common/Makefile dnl
|
||||
sql/sql_builtin.cc sql-common/Makefile libservices/Makefile dnl
|
||||
dbug/Makefile scripts/Makefile include/Makefile dnl
|
||||
tests/Makefile Docs/Makefile support-files/Makefile dnl
|
||||
support-files/MacOSX/Makefile support-files/RHEL4-SElinux/Makefile dnl
|
||||
|
@ -1,3 +0,0 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
@ -18,7 +18,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbug)
|
||||
SET(DBUG_SOURCES dbug.c factorial.c sanity.c)
|
||||
|
||||
IF(NOT SOURCE_SUBLIBS)
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
|
||||
ADD_LIBRARY(dbug ${DBUG_SOURCES})
|
||||
ENDIF(NOT SOURCE_SUBLIBS)
|
||||
|
@ -23,19 +23,20 @@ libdbug_a_SOURCES = dbug.c sanity.c
|
||||
EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
|
||||
user.r monty.doc dbug_add_tags.pl \
|
||||
my_main.c main.c factorial.c dbug_analyze.c \
|
||||
CMakeLists.txt
|
||||
CMakeLists.txt tests.c tests-t.pl
|
||||
NROFF_INC = example1.r example2.r example3.r main.r \
|
||||
factorial.r output1.r output2.r output3.r \
|
||||
output4.r output5.r
|
||||
CLEANFILES = $(NROFF_INC) user.t user.ps
|
||||
CLEANFILES = $(NROFF_INC) user.t user.ps tests-t
|
||||
|
||||
|
||||
# Must be linked with libs that are not compiled yet
|
||||
noinst_PROGRAMS = factorial dbug_analyze
|
||||
noinst_PROGRAMS = factorial dbug_analyze tests
|
||||
factorial_SOURCES = my_main.c factorial.c
|
||||
tests_SOURCES = tests.c
|
||||
dbug_analyze_SOURCES = dbug_analyze.c
|
||||
|
||||
all: user.t user.ps
|
||||
all: user.t user.ps tests-t
|
||||
|
||||
user.t: user.r $(NROFF_INC)
|
||||
-nroff -mm user.r > $@
|
||||
@ -61,5 +62,7 @@ output5.r: factorial
|
||||
@RM@ -f $@
|
||||
@SED@ -e 's!\\!\\\\!g' $< > $@
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
||||
# a hack to have executable in builddir, not in srcdir
|
||||
tests-t: tests-t.pl
|
||||
cp -f $(srcdir)/tests-t.pl ./tests-t
|
||||
|
||||
|
872
dbug/dbug.c
872
dbug/dbug.c
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ $ctags="exctags -x -f - --c-types=f -u";
|
||||
sub get_tag {
|
||||
local $.; local $_=<TAGS>;
|
||||
($symbol, $line)= /^(.*\S)\s+function\s+(\d+)/;
|
||||
$symbol=$1 if /\s(\S+)\s*\(/;
|
||||
$symbol=$1 if /[\s*]([^\s*]+)\s*\(/;
|
||||
$line=1e50 unless $line;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ while($src=shift)
|
||||
$skip=!$semicolon;
|
||||
$semicolon= /;\s*$/;
|
||||
print && next if $skip ||
|
||||
(/^\s+\w+((::\w+)?|<\w+>)\s+\**\w+/ && !/^\s*return/);
|
||||
(/^\s+\w+((::\w+)?|<\w+>)\s+\**\w+/ && !/^\s*return\b/);
|
||||
last if /DBUG_ENTER/;
|
||||
print "$tab DBUG_ENTER(\"$symbol\");\n";
|
||||
print "\n" unless $_ eq "\n";
|
||||
|
@ -1,15 +0,0 @@
|
||||
|
||||
# Warning - first line left blank for sh/csh/ksh compatibility. Do not
|
||||
# remove it. fnf@Unisoft
|
||||
|
||||
# doinstall.sh --- figure out environment and do recursive make with
|
||||
# appropriate pathnames. Works under SV or BSD.
|
||||
|
||||
if [ -r /usr/include/search.h ]
|
||||
then
|
||||
# System V
|
||||
$* LLIB=/usr/lib
|
||||
else
|
||||
# 4.2 BSD
|
||||
$* LLIB=/usr/lib/lint
|
||||
fi
|
@ -1,64 +0,0 @@
|
||||
|
||||
# WARNING -- first line intentionally left blank for sh/csh/ksh
|
||||
# compatibility. Do not remove it! FNF, UniSoft Systems.
|
||||
#
|
||||
# Usage is:
|
||||
# install <from> <to>
|
||||
#
|
||||
# The file <to> is replaced with the file <from>, after first
|
||||
# moving <to> to a backup file. The backup file name is created
|
||||
# by prepending the filename (after removing any leading pathname
|
||||
# components) with "OLD".
|
||||
#
|
||||
# This script is currently not real robust in the face of signals
|
||||
# or permission problems. It also does not do (by intention) all
|
||||
# the things that the System V or BSD install scripts try to do
|
||||
#
|
||||
|
||||
if [ $# -ne 2 ]
|
||||
then
|
||||
echo "usage: $0 <from> <to>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Now extract the dirname and basename components. Unfortunately, BSD does
|
||||
# not have dirname, so we do it the hard way.
|
||||
|
||||
fd=`expr $1'/' : '\(/\)[^/]*/$' \| $1'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .`
|
||||
ff=`basename $1`
|
||||
td=`expr $2'/' : '\(/\)[^/]*/$' \| $2'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .`
|
||||
tf=`basename $2`
|
||||
|
||||
# Now test to make sure that they are not the same files.
|
||||
|
||||
if [ $fd/$ff = $td/$tf ]
|
||||
then
|
||||
echo "install: input and output are same files"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Save a copy of the "to" file as a backup.
|
||||
|
||||
if test -f $td/$tf
|
||||
then
|
||||
if test -f $td/OLD$tf
|
||||
then
|
||||
rm -f $td/OLD$tf
|
||||
fi
|
||||
mv $td/$tf $td/OLD$tf
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
|
||||
# Now do the copy and return appropriate status
|
||||
|
||||
cp $fd/$ff $td/$tf
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
exit 4
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
@ -1,30 +0,0 @@
|
||||
|
||||
# Warning - first line left blank for sh/csh/ksh compatibility. Do not
|
||||
# remove it. fnf@Unisoft
|
||||
|
||||
# mklintlib --- make a lint library, under either System V or 4.2 BSD
|
||||
#
|
||||
# usage: mklintlib <infile> <outfile>
|
||||
#
|
||||
|
||||
if test $# -ne 2
|
||||
then
|
||||
echo "usage: mklintlib <infile> <outfile>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep SIGTSTP /usr/include/signal.h >/dev/null
|
||||
then # BSD
|
||||
if test -r /usr/include/whoami.h # 4.1
|
||||
then
|
||||
/lib/cpp -C -Dlint $1 >hlint
|
||||
(/usr/lib/lint/lint1 <hlint >$2) 2>&1 | grep -v warning
|
||||
else # 4.2
|
||||
lint -Cxxxx $1
|
||||
mv llib-lxxxx.ln $2
|
||||
fi
|
||||
else # USG
|
||||
cc -E -C -Dlint $1 | /usr/lib/lint1 -vx -Hhlint >$2
|
||||
rm -f hlint
|
||||
fi
|
||||
exit 0 # don't kill make
|
@ -1,4 +0,0 @@
|
||||
CL -I\my\include -AL -Gsm2 -FPi -DDBUG_OFF *.c
|
||||
rm \my\lib\dbug.lib
|
||||
lib.exe \my\lib\dbug dbug.obj sanity.obj;
|
||||
link /NOD /STACK:8000 main factoria,factoria,,DBUG+STRINGS+LLIBCEP+DOSCALLS;
|
26
dbug/remove_function_from_trace.pl
Executable file
26
dbug/remove_function_from_trace.pl
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
|
||||
die <<EEE unless @ARGV;
|
||||
Usage: $0 func1 [func2 [ ...] ]
|
||||
|
||||
This filter (stdin->stdout) removes lines from dbug trace that were generated
|
||||
by specified functions and all functions down the call stack. Produces the
|
||||
same effect as if the original source had DBUG_PUSH(""); right after
|
||||
DBUG_ENTER() and DBUG_POP(); right before DBUG_RETURN in every such a function.
|
||||
EEE
|
||||
|
||||
$re=join('|', @ARGV);
|
||||
$skip='';
|
||||
|
||||
while(<STDIN>) {
|
||||
print unless $skip;
|
||||
next unless /^(?:.*: )*((?:\| )*)([<>])($re)\n/o;
|
||||
if ($2 eq '>') {
|
||||
$skip=$1.$3 unless $skip;
|
||||
next;
|
||||
}
|
||||
next if $skip ne $1.$3;
|
||||
$skip='';
|
||||
print;
|
||||
}
|
496
dbug/tests-t.pl
Executable file
496
dbug/tests-t.pl
Executable file
@ -0,0 +1,496 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
#
|
||||
# A driver program to test DBUG features - runs tests (shell commands)
|
||||
# from the end of file to invoke tests.c, which does the real dbug work.
|
||||
#
|
||||
|
||||
use Test::More;
|
||||
|
||||
$exe=$0;
|
||||
|
||||
die unless $exe =~ s/(tests)-t(\.exe)?$/$1$2 /;
|
||||
|
||||
# load tests
|
||||
@tests=();
|
||||
while (<DATA>) {
|
||||
if (/^% \.\/tests /) {
|
||||
push @tests, [ $' ]
|
||||
} elsif (/^#/) {
|
||||
next;
|
||||
} else {
|
||||
push @{$tests[$#tests]}, $_
|
||||
}
|
||||
}
|
||||
|
||||
plan skip_all => "because dbug is disabled" if system $exe;
|
||||
|
||||
plan tests => scalar(@tests);
|
||||
|
||||
for (@tests) {
|
||||
$t=$exe . shift @$_;
|
||||
chomp($t);
|
||||
open F, '-|', $t or die "open($t|): $!";
|
||||
local $";
|
||||
$out=join($", <F>); close(F);
|
||||
# special cases are handled here:
|
||||
$out =~ s/Memory: 0x[0-9A-Fa-f]+/Memory: 0x####/g if $t =~ /dump/;
|
||||
# compare ("\n" at the beginning makes better output in case of errors)
|
||||
is("\n$out","\n@$_", $t);
|
||||
}
|
||||
|
||||
__DATA__
|
||||
% ./tests -#d
|
||||
func2: info: s=ok
|
||||
=> execute
|
||||
=> evaluate: ON
|
||||
=> evaluate_if: OFF
|
||||
main: explain: dbug explained: d
|
||||
func2: info: s=ok
|
||||
% ./tests d,ret3
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
#
|
||||
## Testing negative lists
|
||||
#
|
||||
% ./tests d:-d,ret3
|
||||
func2: info: s=ko
|
||||
=> execute
|
||||
=> evaluate: ON
|
||||
=> evaluate_if: OFF
|
||||
main: explain: dbug explained: d:-d,ret3
|
||||
func2: info: s=ko
|
||||
% ./tests t:-d,ret3
|
||||
>main
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | <func2
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| <func2
|
||||
<main
|
||||
% ./tests t:d,info:-d,ret3
|
||||
>main
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | | info: s=ko
|
||||
| | <func2
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| | info: s=ko
|
||||
| <func2
|
||||
<main
|
||||
% ./tests t:d,info:-d,ret3:-f,func2
|
||||
>main
|
||||
| >func1
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| | >func3
|
||||
| | <func3
|
||||
<main
|
||||
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate
|
||||
=> evaluate: ON
|
||||
=> evaluate_if: OFF
|
||||
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate_if
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: ON
|
||||
% ./tests t:d:-d,ret3:-f,func2 d,evaluate_if
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: ON
|
||||
% ./tests t:d:-d,ret3:-f,func2
|
||||
>main
|
||||
| >func1
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| <func1
|
||||
=> execute
|
||||
=> evaluate: ON
|
||||
=> evaluate_if: OFF
|
||||
| explain: dbug explained: d:-d,ret3:f:-f,func2:t
|
||||
| | >func3
|
||||
| | <func3
|
||||
<main
|
||||
#
|
||||
## Adding incremental settings to the brew
|
||||
#
|
||||
% ./tests t:d:-d,ret3:-f,func2 +d,evaluate_if
|
||||
>main
|
||||
| >func1
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: ON
|
||||
| | >func3
|
||||
| | <func3
|
||||
<main
|
||||
#
|
||||
## DBUG_DUMP
|
||||
#
|
||||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump
|
||||
>main
|
||||
| >func1
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| <func1
|
||||
| dump: Memory: 0x#### Bytes: (27)
|
||||
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
|
||||
74
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| | >func3
|
||||
| | <func3
|
||||
<main
|
||||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump
|
||||
>main
|
||||
| >func1
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| <func1
|
||||
| dump: Memory: 0x#### Bytes: (27)
|
||||
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
|
||||
74
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| | >func3
|
||||
| | <func3
|
||||
<main
|
||||
% ./tests t:d:-d,ret3:f:-f,func2:+d,dump
|
||||
>main
|
||||
| >func1
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| <func1
|
||||
| dump: Memory: 0x#### Bytes: (27)
|
||||
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
|
||||
74
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| | >func3
|
||||
| | <func3
|
||||
<main
|
||||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain
|
||||
>main
|
||||
| >func1
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| <func1
|
||||
| dump: Memory: 0x#### Bytes: (35)
|
||||
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
|
||||
66 2C 66 75 6E 63 32 3A 74
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:t
|
||||
| | >func3
|
||||
| | <func3
|
||||
<main
|
||||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P
|
||||
dbug: >main
|
||||
dbug-tests: | >func1
|
||||
dbug-tests: | | | >func3
|
||||
dbug-tests: | | | <func3
|
||||
dbug-tests: | <func1
|
||||
dbug-tests: | dump: Memory: 0x#### Bytes: (37)
|
||||
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
|
||||
66 2C 66 75 6E 63 32 3A 50 3A 74
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
dbug-tests: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:P:t
|
||||
dbug-tests: | | >func3
|
||||
dbug-tests: | | <func3
|
||||
dbug-tests: <main
|
||||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P:F
|
||||
dbug: tests.c: >main
|
||||
dbug-tests: tests.c: | >func1
|
||||
dbug-tests: tests.c: | | | >func3
|
||||
dbug-tests: tests.c: | | | <func3
|
||||
dbug-tests: tests.c: | <func1
|
||||
dbug-tests: tests.c: | dump: Memory: 0x#### Bytes: (39)
|
||||
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
|
||||
66 2C 66 75 6E 63 32 3A 46 3A 50 3A 74
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
dbug-tests: tests.c: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:F:P:t
|
||||
dbug-tests: tests.c: | | >func3
|
||||
dbug-tests: tests.c: | | <func3
|
||||
dbug-tests: tests.c: <main
|
||||
#
|
||||
## DBUG_EXPLAIN, DBUG_PUSH, DBUG_POP, DBUG_SET
|
||||
#
|
||||
% ./tests t:d:-d,ret3:f:-f,func2
|
||||
>main
|
||||
| >func1
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| <func1
|
||||
=> execute
|
||||
=> evaluate: ON
|
||||
=> evaluate_if: OFF
|
||||
| explain: dbug explained: d:-d,ret3:f:-f,func2:t
|
||||
| | >func3
|
||||
| | <func3
|
||||
<main
|
||||
% ./tests t:d:-d,ret3
|
||||
>main
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | | info: s=ko
|
||||
| | <func2
|
||||
| <func1
|
||||
=> execute
|
||||
=> evaluate: ON
|
||||
=> evaluate_if: OFF
|
||||
| explain: dbug explained: d:-d,ret3:t
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| | info: s=ko
|
||||
| <func2
|
||||
<main
|
||||
% ./tests d,info:-d,ret3:d,push
|
||||
func2: info: s=ko
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| | info: s=ko
|
||||
| <func2
|
||||
<main
|
||||
% ./tests d,info:-d,ret3:d,push,explain
|
||||
func2: info: s=ko
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| explain: dbug explained: d,info,push,explain:-d,ret3:t
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| | info: s=ko
|
||||
| <func2
|
||||
<main
|
||||
% ./tests d,info:-d,ret3:d,explain
|
||||
func2: info: s=ko
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
main: explain: dbug explained: d,info,explain:-d,ret3
|
||||
func2: info: s=ko
|
||||
% ./tests d,info:-d,ret3:d,explain,pop
|
||||
func2: info: s=ko
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
% ./tests d,info:-d,ret3:d,explain t:d,pop
|
||||
>main
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | <func2
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
main: explain: dbug explained: d,info,explain:-d,ret3
|
||||
func2: info: s=ko
|
||||
% ./tests d,info:-d,ret3:d,explain,pop +t
|
||||
>main
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | | info: s=ko
|
||||
| | <func2
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
main: explain: dbug explained: d,info,explain,pop:-d,ret3
|
||||
func2: info: s=ko
|
||||
% ./tests d,info:-d,ret3:d,explain,set
|
||||
func2: info: s=ko
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
tests.c: main: explain: dbug explained: d,info,explain,set:-d,ret3:F
|
||||
tests.c: func2: info: s=ko
|
||||
% ./tests d,info:-d,ret3:d,explain,set:t
|
||||
>main
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | | info: s=ko
|
||||
| | <func2
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
|
||||
tests.c: | >func2
|
||||
tests.c: | | >func3
|
||||
tests.c: | | <func3
|
||||
tests.c: | | info: s=ko
|
||||
tests.c: | <func2
|
||||
tests.c: <main
|
||||
% ./tests t d,info:-d,ret3:d,explain,set:t
|
||||
>main
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | | info: s=ko
|
||||
| | <func2
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
|
||||
tests.c: | >func2
|
||||
tests.c: | | >func3
|
||||
tests.c: | | <func3
|
||||
tests.c: | | info: s=ko
|
||||
tests.c: | <func2
|
||||
tests.c: <main
|
||||
% ./tests t d,info:-d,ret3:d,explain,set,pop
|
||||
func2: info: s=ko
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| <func2
|
||||
<main
|
||||
% ./tests t:f,func2
|
||||
| | >func2
|
||||
| | <func2
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| >func2
|
||||
| <func2
|
||||
#
|
||||
## Testing SUBDIR rules
|
||||
#
|
||||
% ./tests t:-f,func2/:d
|
||||
>main
|
||||
| >func1
|
||||
| <func1
|
||||
=> execute
|
||||
=> evaluate: ON
|
||||
=> evaluate_if: OFF
|
||||
| explain: dbug explained: d:f:-f,func2/:t
|
||||
<main
|
||||
% ./tests t:f,func1/:d
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | | info: s=ok
|
||||
| | <func2
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
% ./tests t:f,main/:d,pop
|
||||
>main
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | <func2
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
% ./tests f,main/:d,push
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| <func2
|
||||
<main
|
||||
#
|
||||
## Testing FixTraceFlags() - when we need to traverse the call stack
|
||||
# (these tests fail with FixTraceFlags() disabled)
|
||||
#
|
||||
# delete the INCLUDE rule up the stack
|
||||
% ./tests t:f,func1/ --push1=t:f,func3/
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | <func2
|
||||
=> push1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| | >func3
|
||||
| | <func3
|
||||
# delete the EXCLUDE rule up the stack
|
||||
% ./tests t:-f,func1/ --push1=t
|
||||
>main
|
||||
=> push1
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| <func2
|
||||
<main
|
||||
# add the INCLUDE rule up the stack
|
||||
% ./tests t:f,func3 --push1=t:f,main/
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
=> push1
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| <func2
|
||||
<main
|
||||
# add the EXCLUDE rule up the stack
|
||||
% ./tests t --push1=t:-f,main/
|
||||
>main
|
||||
| >func1
|
||||
| | >func2
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
| | <func2
|
||||
=> push1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
# change the defaults
|
||||
% ./tests t:f,func3 --push1=t
|
||||
| | | >func3
|
||||
| | | <func3
|
||||
=> push1
|
||||
| <func1
|
||||
=> evaluate: OFF
|
||||
=> evaluate_if: OFF
|
||||
| >func2
|
||||
| | >func3
|
||||
| | <func3
|
||||
| <func2
|
||||
<main
|
||||
# repeated keyword
|
||||
% ./tests d:-d,info,info
|
||||
=> execute
|
||||
=> evaluate: ON
|
||||
=> evaluate_if: OFF
|
||||
main: explain: dbug explained: d:-d,info
|
||||
% ./tests d:-d,info/,info
|
||||
=> execute
|
||||
=> evaluate: ON
|
||||
=> evaluate_if: OFF
|
||||
main: explain: dbug explained: d:-d,info/
|
87
dbug/tests.c
Normal file
87
dbug/tests.c
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
A program to test DBUG features. Used by tests-t.pl
|
||||
*/
|
||||
|
||||
char *push1=0;
|
||||
|
||||
#include <my_global.h> /* This includes dbug.h */
|
||||
#include <my_pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
const char *func3()
|
||||
{
|
||||
DBUG_ENTER("func3");
|
||||
DBUG_RETURN(DBUG_EVALUATE("ret3", "ok", "ko"));
|
||||
}
|
||||
|
||||
void func2()
|
||||
{
|
||||
const char *s;
|
||||
DBUG_ENTER("func2");
|
||||
s=func3();
|
||||
DBUG_PRINT("info", ("s=%s", s));
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
int func1()
|
||||
{
|
||||
DBUG_ENTER("func1");
|
||||
func2();
|
||||
if (push1)
|
||||
{
|
||||
DBUG_PUSH(push1);
|
||||
fprintf(DBUG_FILE, "=> push1\n");
|
||||
}
|
||||
DBUG_RETURN(10);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
#ifdef DBUG_OFF
|
||||
return 1;
|
||||
#endif
|
||||
if (argc == 1)
|
||||
return 0;
|
||||
|
||||
#if defined(HAVE_PTHREAD_INIT) && defined(THREAD)
|
||||
pthread_init(); /* Must be called before DBUG_ENTER */
|
||||
#endif
|
||||
#ifdef THREAD
|
||||
my_thread_global_init();
|
||||
#endif
|
||||
dup2(1, 2);
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (strncmp(argv[i], "--push1=", 8) == 0)
|
||||
push1=argv[i]+8;
|
||||
else
|
||||
DBUG_PUSH (argv[i]);
|
||||
}
|
||||
{
|
||||
DBUG_ENTER ("main");
|
||||
DBUG_PROCESS ("dbug-tests");
|
||||
func1();
|
||||
DBUG_EXECUTE_IF("dump",
|
||||
{
|
||||
char s[1000];
|
||||
DBUG_EXPLAIN(s, sizeof(s)-1);
|
||||
DBUG_DUMP("dump", (uchar*)s, strlen(s));
|
||||
});
|
||||
DBUG_EXECUTE_IF("push", DBUG_PUSH("+t"); );
|
||||
DBUG_EXECUTE("execute", fprintf(DBUG_FILE, "=> execute\n"); );
|
||||
DBUG_EXECUTE_IF("set", DBUG_SET("+F"); );
|
||||
fprintf(DBUG_FILE, "=> evaluate: %s\n",
|
||||
DBUG_EVALUATE("evaluate", "ON", "OFF"));
|
||||
fprintf(DBUG_FILE, "=> evaluate_if: %s\n",
|
||||
DBUG_EVALUATE_IF("evaluate_if", "ON", "OFF"));
|
||||
DBUG_EXECUTE_IF("pop", DBUG_POP(); );
|
||||
{
|
||||
char s[1000] __attribute__((unused));
|
||||
DBUG_EXPLAIN(s, sizeof(s)-1);
|
||||
DBUG_PRINT("explain", ("dbug explained: %s", s));
|
||||
}
|
||||
func2();
|
||||
DBUG_RETURN (0);
|
||||
}
|
||||
}
|
54
dbug/user.r
54
dbug/user.r
@ -512,7 +512,7 @@ possible since all code preceding the first call to
|
||||
.B DBUG_PUSH
|
||||
is
|
||||
essentially invisible to
|
||||
.B dbug
|
||||
.I dbug
|
||||
(this can be worked around by
|
||||
inserting a temporary
|
||||
.B DBUG_PUSH(argv[1])
|
||||
@ -708,7 +708,7 @@ EX:\ \fCDBUG_PROCESS\ (argv[0]);\fR
|
||||
.SP 1
|
||||
.LI DBUG_PUSH\
|
||||
Sets a new debugger state by pushing the current
|
||||
.B dbug
|
||||
.I dbug
|
||||
state onto an internal stack and setting up the new state using the
|
||||
debug control string passed as the macro argument. The most common
|
||||
usage is to set the state specified by a debug control string
|
||||
@ -769,14 +769,14 @@ the 'd' flag. Used to conditionally execute "dangerous" actions, e.g
|
||||
to crash the program testing how recovery works, or to introduce an
|
||||
artificial delay checking for race conditions.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ abort\ ());\fR
|
||||
EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ DBUG_ABORT()\ ());\fR
|
||||
.SP 1
|
||||
.LI DBUG_EVALUATE\
|
||||
The DBUG_EVALUATE macro is similar to DBUG_EXECUTE, but it can be used in
|
||||
the expression context. The first argument is the debug keyword that is used to
|
||||
choose whether the second (keyword is enabled) or the third (keyword is not
|
||||
enabled) argument is evaluated. When
|
||||
.B dbug
|
||||
.I dbug
|
||||
is compiled off, the third argument is evaluated.
|
||||
.SP 1
|
||||
EX:\fC
|
||||
@ -796,7 +796,7 @@ EX:\fC
|
||||
.br
|
||||
if (prepare_transaction () ||
|
||||
.br
|
||||
DBUG_EVALUATE ("crashme", (abort (), 0), 0) ||
|
||||
DBUG_EVALUATE ("crashme", (DBUG_ABORT(), 0), 0) ||
|
||||
.br
|
||||
commit_transaction () )\fR
|
||||
.SP 1
|
||||
@ -875,6 +875,12 @@ library. So there will be no need to disable asserts separately with NDEBUG.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_ASSERT(\ a\ >\ 0\ );\fR
|
||||
.SP 1
|
||||
.LI DBUG_ABORT\
|
||||
This macro could be used instead of abort(). It flushes DBUG_FILE stream
|
||||
to ensure that no
|
||||
.I dbug
|
||||
output is lost and then calls abort().
|
||||
.SP 1
|
||||
.LI DBUG_EXPLAIN\
|
||||
Generates control string corresponding to the current debug state.
|
||||
The macro takes two arguments - a buffer to store the result string
|
||||
@ -910,17 +916,17 @@ via the
|
||||
.B DBUG_PUSH
|
||||
or
|
||||
.B DBUG_SET
|
||||
macros. Control string consists of colon separate flags. Colons
|
||||
macros. Control string consists of colon separated flags. Colons
|
||||
that are part of ':\\', ':/', or '::' are not considered flag
|
||||
separators. A flag may take an argument or a list of arguments.
|
||||
If a control string starts from a '+' sign it works
|
||||
.I incrementally,
|
||||
that is, it can modify existing state without overriding it. In such a
|
||||
string every flag may be preceded by a '+' or '-' to enable or disable
|
||||
a corresponding option in the debugger state. This section summarizes
|
||||
the currently available debugger options and the flag characters which
|
||||
enable or disable them. Argument lists enclosed in '[' and ']' are
|
||||
optional.
|
||||
that is, it can modify existing state without overriding it. Every
|
||||
flag may be preceded by a '+' or '-' to enable or disable a
|
||||
corresponding option in the debugger state or to add or remove
|
||||
arguments to the list. This section summarizes the currently available
|
||||
debugger options and the flag characters which enable or disable them.
|
||||
Argument lists enclosed in '[' and ']' are optional.
|
||||
.SP 2
|
||||
.BL 22
|
||||
.LI a[,file]
|
||||
@ -936,6 +942,9 @@ a complete log file in case of crashes. This mode is implicit in
|
||||
multi-threaded environment.
|
||||
.LI d[,keywords]
|
||||
Enable output from macros with specified keywords.
|
||||
Every keyword can be a
|
||||
.I glob(7)
|
||||
pattern.
|
||||
An empty list of keywords implies that all keywords are selected.
|
||||
.LI D[,time]
|
||||
Delay for specified time after each output line, to let output drain.
|
||||
@ -943,7 +952,19 @@ Time is given in tenths of a second (value of 10 is one second).
|
||||
Default is zero.
|
||||
.LI f[,functions]
|
||||
Limit debugger actions to the specified list of functions.
|
||||
Every function can be a
|
||||
.I glob(7)
|
||||
pattern.
|
||||
An empty list of functions implies that all functions are selected.
|
||||
Every function in the list may optionally be followed by a '/' -
|
||||
this will implicitly select all the functions down the call stack.
|
||||
.SP 1
|
||||
EX: \fCf,func1,func2/:-f,func3,func4/\fR
|
||||
.SP 1
|
||||
This would enable debugger in functions 'func1()', 'func2()' and all
|
||||
functions called from it (directly or indirectly). But not in
|
||||
functions 'func3()' or 'func4()' and all functions called from
|
||||
it.
|
||||
.LI F
|
||||
Mark each debugger output line with the name of the source file
|
||||
containing the macro causing the output.
|
||||
@ -952,6 +973,9 @@ Mark each debugger output line with the PID (or thread ID) of the
|
||||
current process.
|
||||
.LI g,[functions]
|
||||
Enable profiling for the specified list of functions.
|
||||
Every function can be a
|
||||
.I glob(7)
|
||||
pattern.
|
||||
An empty list of functions enables profiling for all functions.
|
||||
See
|
||||
.B PROFILING\ WITH\ DBUG
|
||||
@ -970,7 +994,11 @@ Like 'a[,file]' but overwrite old file, do not append.
|
||||
.LI O[,file]
|
||||
Like 'A[,file]' but overwrite old file, do not append.
|
||||
.LI p[,processes]
|
||||
Limit debugger actions to the specified processes. An empty list
|
||||
Limit debugger actions to the specified processes.
|
||||
Every name can be a
|
||||
.I glob(7)
|
||||
pattern.
|
||||
An empty list
|
||||
implies all processes. This is useful for processes which run child
|
||||
processes. Note that each debugger output line can be marked with the
|
||||
name of the current process via the 'P' flag. The process name must
|
||||
|
139
dbug/vargs.h
139
dbug/vargs.h
@ -1,139 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* N O T I C E *
|
||||
* *
|
||||
* Copyright Abandoned, 1987, Fred Fish *
|
||||
* *
|
||||
* *
|
||||
* This previously copyrighted work has been placed into the public *
|
||||
* domain by the author and may be freely used for any purpose, *
|
||||
* private or commercial. *
|
||||
* *
|
||||
* Because of the number of inquiries I was receiving about the use *
|
||||
* of this product in commercially developed works I have decided to *
|
||||
* simply make it public domain to further its unrestricted use. I *
|
||||
* specifically would be most happy to see this material become a *
|
||||
* part of the standard Unix distributions by AT&T and the Berkeley *
|
||||
* Computer Science Research Group, and a standard part of the GNU *
|
||||
* system from the Free Software Foundation. *
|
||||
* *
|
||||
* I would appreciate it, as a courtesy, if this notice is left in *
|
||||
* all copies and derivative works. Thank you. *
|
||||
* *
|
||||
* The author makes no warranty of any kind with respect to this *
|
||||
* product and explicitly disclaims any implied warranties of mer- *
|
||||
* chantability or fitness for any particular purpose. *
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* FILE
|
||||
*
|
||||
* vargs.h include file for environments without varargs.h
|
||||
*
|
||||
* SCCS
|
||||
*
|
||||
* @(#)vargs.h 1.2 5/8/88
|
||||
*
|
||||
* SYNOPSIS
|
||||
*
|
||||
* #include "vargs.h"
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* This file implements a varargs macro set for use in those
|
||||
* environments where there is no system supplied varargs. This
|
||||
* generally works because systems which don't supply a varargs
|
||||
* package are precisely those which don't strictly need a varargs
|
||||
* package. Using this one then allows us to minimize source
|
||||
* code changes. So in some sense, this is a "portable" varargs
|
||||
* since it is only used for convenience, when it is not strictly
|
||||
* needed.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* These macros allow us to rebuild an argument list on the stack
|
||||
* given only a va_list. We can use these to fake a function like
|
||||
* vfprintf, which gets a fixed number of arguments, the last of
|
||||
* which is a va_list, by rebuilding a stack and calling the variable
|
||||
* argument form fprintf. Of course this only works when vfprintf
|
||||
* is not available in the host environment, and thus is not available
|
||||
* for fprintf to call (which would give us an infinite loop).
|
||||
*
|
||||
* Note that ARGS_TYPE is a long, which lets us get several bytes
|
||||
* at a time while also preventing lots of "possible pointer alignment
|
||||
* problem" messages from lint. The messages are valid, because this
|
||||
* IS nonportable, but then we should only be using it in very
|
||||
* nonrestrictive environments, and using the real varargs where it
|
||||
* really counts.
|
||||
*
|
||||
*/
|
||||
|
||||
#define ARG0 a0
|
||||
#define ARG1 a1
|
||||
#define ARG2 a2
|
||||
#define ARG3 a3
|
||||
#define ARG4 a4
|
||||
#define ARG5 a5
|
||||
#define ARG6 a6
|
||||
#define ARG7 a7
|
||||
#define ARG8 a8
|
||||
#define ARG9 a9
|
||||
|
||||
#define ARGS_TYPE long
|
||||
#define ARGS_LIST ARG0,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8,ARG9
|
||||
#define ARGS_DCL auto ARGS_TYPE ARGS_LIST
|
||||
|
||||
/*
|
||||
* A pointer of type "va_list" points to a section of memory
|
||||
* containing an array of variable sized arguments of unknown
|
||||
* number. This pointer is initialized by the va_start
|
||||
* macro to point to the first byte of the first argument.
|
||||
* We can then use it to walk through the argument list by
|
||||
* incrementing it by the size of the argument being referenced.
|
||||
*/
|
||||
|
||||
typedef char *va_list;
|
||||
|
||||
/*
|
||||
* The first variable argument overlays va_alist, which is
|
||||
* nothing more than a "handle" which allows us to get the
|
||||
* address of the first argument on the stack. Note that
|
||||
* by definition, the va_dcl macro includes the terminating
|
||||
* semicolon, which makes use of va_dcl in the source code
|
||||
* appear to be missing a semicolon.
|
||||
*/
|
||||
|
||||
#define va_dcl ARGS_TYPE va_alist;
|
||||
|
||||
/*
|
||||
* The va_start macro takes a variable of type "va_list" and
|
||||
* initializes it. In our case, it initializes a local variable
|
||||
* of type "pointer to char" to point to the first argument on
|
||||
* the stack.
|
||||
*/
|
||||
|
||||
#define va_start(list) list = (char *) &va_alist
|
||||
|
||||
/*
|
||||
* The va_end macro is a null operation for our use.
|
||||
*/
|
||||
|
||||
#define va_end(list)
|
||||
|
||||
/*
|
||||
* The va_arg macro is the tricky one. This one takes
|
||||
* a va_list as the first argument, and a type as the second
|
||||
* argument, and returns a value of the appropriate type
|
||||
* while advancing the va_list to the following argument.
|
||||
* For our case, we first increment the va_list arg by the
|
||||
* size of the type being recovered, cast the result to
|
||||
* a pointer of the appropriate type, and then dereference
|
||||
* that pointer as an array to get the previous arg (which
|
||||
* is the one we wanted.
|
||||
*/
|
||||
|
||||
#define va_arg(list,type) ((type *) (list += sizeof (type)))[-1]
|
@ -14,13 +14,11 @@
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
ADD_EXECUTABLE(comp_err comp_err.c)
|
||||
TARGET_LINK_LIBRARIES(comp_err debug dbug mysys strings zlib wsock32)
|
||||
TARGET_LINK_LIBRARIES(comp_err dbug mysys strings zlib)
|
||||
|
||||
GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION)
|
||||
|
||||
@ -31,24 +29,24 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
|
||||
--header_file=${PROJECT_SOURCE_DIR}/include/mysqld_error.h
|
||||
--name_file=${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
|
||||
--state_file=${PROJECT_SOURCE_DIR}/include/sql_state.h
|
||||
--in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt
|
||||
DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt)
|
||||
--in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg-utf8.txt
|
||||
DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg-utf8.txt)
|
||||
|
||||
ADD_CUSTOM_TARGET(GenError
|
||||
ALL
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h)
|
||||
|
||||
ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
|
||||
TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32)
|
||||
TARGET_LINK_LIBRARIES(my_print_defaults strings mysys dbug taocrypt)
|
||||
|
||||
ADD_EXECUTABLE(perror perror.c)
|
||||
TARGET_LINK_LIBRARIES(perror strings mysys debug dbug wsock32)
|
||||
TARGET_LINK_LIBRARIES(perror strings mysys dbug)
|
||||
|
||||
ADD_EXECUTABLE(resolveip resolveip.c)
|
||||
TARGET_LINK_LIBRARIES(resolveip strings mysys debug dbug wsock32)
|
||||
TARGET_LINK_LIBRARIES(resolveip strings mysys dbug)
|
||||
|
||||
ADD_EXECUTABLE(replace replace.c)
|
||||
TARGET_LINK_LIBRARIES(replace strings mysys debug dbug wsock32)
|
||||
TARGET_LINK_LIBRARIES(replace strings mysys dbug)
|
||||
|
||||
IF(EMBED_MANIFESTS)
|
||||
MYSQL_EMBED_MANIFEST("myTest" "asInvoker")
|
||||
|
@ -30,7 +30,7 @@ DIST_SUBDIRS = yassl
|
||||
# NOTE Built files should depend on their sources to avoid
|
||||
# the built files being rebuilt in source dist
|
||||
$(top_builddir)/include/mysqld_error.h: comp_err.c \
|
||||
$(top_srcdir)/sql/share/errmsg.txt
|
||||
$(top_srcdir)/sql/share/errmsg-utf8.txt
|
||||
$(MAKE) $(AM_MAKEFLAGS) comp_err$(EXEEXT)
|
||||
$(top_builddir)/extra/comp_err$(EXEEXT) \
|
||||
--charset=$(top_srcdir)/sql/share/charsets \
|
||||
@ -38,7 +38,7 @@ $(top_builddir)/include/mysqld_error.h: comp_err.c \
|
||||
--header_file=$(top_builddir)/include/mysqld_error.h \
|
||||
--name_file=$(top_builddir)/include/mysqld_ername.h \
|
||||
--state_file=$(top_builddir)/include/sql_state.h \
|
||||
--in_file=$(top_srcdir)/sql/share/errmsg.txt
|
||||
--in_file=$(top_srcdir)/sql/share/errmsg-utf8.txt
|
||||
$(top_builddir)/include/mysqld_ername.h: $(top_builddir)/include/mysqld_error.h
|
||||
$(top_builddir)/include/sql_state.h: $(top_builddir)/include/mysqld_error.h
|
||||
|
||||
|
@ -39,7 +39,7 @@ static char *OUTFILE= (char*) "errmsg.sys";
|
||||
static char *HEADERFILE= (char*) "mysqld_error.h";
|
||||
static char *NAMEFILE= (char*) "mysqld_ername.h";
|
||||
static char *STATEFILE= (char*) "sql_state.h";
|
||||
static char *TXTFILE= (char*) "../sql/share/errmsg.txt";
|
||||
static char *TXTFILE= (char*) "../sql/share/errmsg-utf8.txt";
|
||||
static char *DATADIRECTORY= (char*) "../sql/share/";
|
||||
#ifndef DBUG_OFF
|
||||
static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace";
|
||||
|
@ -192,7 +192,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
for (argument= arguments+1 ; *argument ; argument++)
|
||||
puts(*argument);
|
||||
if (*argument != args_separator) /* skip arguments separator */
|
||||
puts(*argument);
|
||||
my_free((char*) load_default_groups,MYF(0));
|
||||
free_defaults(arguments);
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <time.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#else
|
||||
|
@ -21,7 +21,8 @@ HEADERS_GEN_MAKE = my_config.h
|
||||
HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \
|
||||
my_list.h my_alloc.h typelib.h mysql/plugin.h
|
||||
pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
|
||||
my_xml.h mysql_embed.h \
|
||||
my_xml.h mysql_embed.h mysql/services.h \
|
||||
mysql/service_my_snprintf.h mysql/service_thd_alloc.h \
|
||||
my_pthread.h my_no_pthread.h \
|
||||
decimal.h errmsg.h my_global.h my_net.h \
|
||||
my_getopt.h sslopt-longopts.h my_dir.h \
|
||||
@ -36,7 +37,7 @@ noinst_HEADERS = config-win.h config-netware.h my_bit.h \
|
||||
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
|
||||
my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
|
||||
thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
|
||||
my_handler.h my_time.h \
|
||||
my_handler.h my_time.h service_versions.h \
|
||||
my_vle.h my_user.h my_atomic.h atomic/nolock.h \
|
||||
atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \
|
||||
atomic/solaris.h \
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef ATOMIC_GCC_BUILTINS_INCLUDED
|
||||
#define ATOMIC_GCC_BUILTINS_INCLUDED
|
||||
|
||||
/* Copyright (C) 2008 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -31,3 +34,5 @@
|
||||
#define make_atomic_store_body(S) \
|
||||
(void) __sync_lock_test_and_set(a, v);
|
||||
#endif
|
||||
|
||||
#endif /* ATOMIC_GCC_BUILTINS_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef ATOMIC_NOLOCK_INCLUDED
|
||||
#define ATOMIC_NOLOCK_INCLUDED
|
||||
|
||||
/* Copyright (C) 2006 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -59,3 +62,4 @@ typedef struct { } my_atomic_rwlock_t;
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* ATOMIC_NOLOCK_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef ATOMIC_RWLOCK_INCLUDED
|
||||
#define ATOMIC_RWLOCK_INCLUDED
|
||||
|
||||
/* Copyright (C) 2006 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -46,3 +49,4 @@ typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t;
|
||||
#define make_atomic_load_body(S) ret= *a;
|
||||
#define make_atomic_store_body(S) *a= v;
|
||||
|
||||
#endif /* ATOMIC_RWLOCK_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef ATOMIC_X86_GCC_INCLUDED
|
||||
#define ATOMIC_X86_GCC_INCLUDED
|
||||
|
||||
/* Copyright (C) 2006 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -56,3 +59,4 @@
|
||||
asm volatile ("; xchg %0, %1;" : "+m" (*a) : "r" (v))
|
||||
#endif
|
||||
|
||||
#endif /* ATOMIC_X86_GCC_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef CONFIG_WIN_INCLUDED
|
||||
#define CONFIG_WIN_INCLUDED
|
||||
|
||||
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -27,6 +30,9 @@
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <malloc.h>
|
||||
#include <sys/stat.h>
|
||||
#include <process.h> /* getpid()*/
|
||||
|
||||
|
||||
#define HAVE_SMEM 1
|
||||
|
||||
@ -65,7 +71,6 @@
|
||||
#endif
|
||||
|
||||
/* File and lock constants */
|
||||
#define O_SHARE 0x1000 /* Open file in sharing mode */
|
||||
#ifdef __BORLANDC__
|
||||
#define F_RDLCK LK_NBLCK /* read lock */
|
||||
#define F_WRLCK LK_NBRLCK /* write lock */
|
||||
@ -175,7 +180,7 @@ typedef uint rf_SetTimer;
|
||||
#define SIZEOF_CHARP 4
|
||||
#endif
|
||||
#define HAVE_BROKEN_NETINET_INCLUDES
|
||||
#ifdef __NT__
|
||||
#ifdef _WIN32
|
||||
#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
|
||||
#endif
|
||||
|
||||
@ -288,11 +293,6 @@ inline ulonglong double2ulonglong(double d)
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
|
||||
#ifndef __NT__
|
||||
#undef FILE_SHARE_DELETE
|
||||
#define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */
|
||||
#endif
|
||||
|
||||
#ifdef NOT_USED
|
||||
#define HAVE_SNPRINTF /* Gave link error */
|
||||
#define _snprintf snprintf
|
||||
@ -336,13 +336,13 @@ inline ulonglong double2ulonglong(double d)
|
||||
#define FN_DEVCHAR ':'
|
||||
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
|
||||
#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
|
||||
#define OS_FILE_LIMIT 2048
|
||||
#define OS_FILE_LIMIT UINT_MAX /* No limit*/
|
||||
|
||||
#define DO_NOT_REMOVE_THREAD_WRAPPERS
|
||||
#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
|
||||
#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
|
||||
/* The following is only used for statistics, so it should be good enough */
|
||||
#ifdef __NT__ /* This should also work on Win98 but .. */
|
||||
#ifdef _WIN32
|
||||
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
|
||||
#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
|
||||
#endif
|
||||
@ -356,7 +356,6 @@ inline ulonglong double2ulonglong(double d)
|
||||
#define HAVE_OPENSSL 1
|
||||
#define HAVE_YASSL 1
|
||||
|
||||
#define COMMUNITY_SERVER 1
|
||||
#define ENABLED_PROFILING 1
|
||||
|
||||
/*
|
||||
@ -410,3 +409,5 @@ inline ulonglong double2ulonglong(double d)
|
||||
|
||||
#define HAVE_UCA_COLLATIONS 1
|
||||
#define HAVE_BOOL 1
|
||||
|
||||
#endif /* CONFIG_WIN_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef ERRMSG_INCLUDED
|
||||
#define ERRMSG_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -97,6 +100,8 @@ extern const char *client_errors[]; /* Error messages */
|
||||
#define CR_SERVER_LOST_EXTENDED 2055
|
||||
#define CR_STMT_CLOSED 2056
|
||||
#define CR_NEW_STMT_METADATA 2057
|
||||
#define CR_ERROR_LAST /*Copy last error nr:*/ 2057
|
||||
#define CR_ALREADY_CONNECTED 2058
|
||||
#define CR_ERROR_LAST /*Copy last error nr:*/ 2058
|
||||
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
|
||||
|
||||
#endif /* ERRMSG_INCLUDED */
|
||||
|
@ -21,40 +21,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
There was a problem on MacOSX with a shared object ha_example.so.
|
||||
It used hash_search(). During build of ha_example.so no libmysys
|
||||
was specified. Since MacOSX had a hash_search() in the system
|
||||
library, it built the shared object so that the dynamic linker
|
||||
linked hash_search() to the system library, which caused a crash
|
||||
when called. To come around this, we renamed hash_search() to
|
||||
my_hash_search(), as we did long ago with hash_insert() and
|
||||
hash_reset(). However, this time we made the move complete with
|
||||
all names. To keep compatibility, we redefine the old names.
|
||||
Since every C and C++ file, that uses HASH, needs to include
|
||||
this file, the change is complete. Both names could be used
|
||||
in the code, but the my_* versions are recommended now.
|
||||
*/
|
||||
#define hash_get_key my_hash_get_key
|
||||
#define hash_free_key my_hash_free_key
|
||||
#define hash_init my_hash_init
|
||||
#define hash_init2 my_hash_init2
|
||||
#define _hash_init _my_hash_init
|
||||
#define hash_free my_hash_free
|
||||
#define hash_reset my_hash_reset
|
||||
#define hash_element my_hash_element
|
||||
#define hash_search my_hash_search
|
||||
#define hash_first my_hash_first
|
||||
#define hash_next my_hash_next
|
||||
#define hash_insert my_hash_insert
|
||||
#define hash_delete my_hash_delete
|
||||
#define hash_update my_hash_update
|
||||
#define hash_replace my_hash_replace
|
||||
#define hash_check my_hash_check
|
||||
#define hash_clear my_hash_clear
|
||||
#define hash_inited my_hash_inited
|
||||
#define hash_init_opt my_hash_init_opt
|
||||
|
||||
/*
|
||||
Overhead to store an element in hash
|
||||
Can be used to approximate memory consumption for a hash
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef HELP_END_INCLUDED
|
||||
#define HELP_END_INCLUDED
|
||||
|
||||
/* Copyright (C) 2004-2005 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -20,3 +23,4 @@
|
||||
#undef fputc
|
||||
#undef putchar
|
||||
#endif
|
||||
#endif /* HELP_END_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef HELP_START_INCLUDED
|
||||
#define HELP_START_INCLUDED
|
||||
|
||||
/* Copyright (C) 2004-2005 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -22,3 +25,4 @@
|
||||
#define fputc(s,f) consoleprintf("%c", s)
|
||||
#define putchar(s) consoleprintf("%c", s)
|
||||
#endif
|
||||
#endif /* HELP_START_INCLUDED */
|
||||
|
@ -87,6 +87,7 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
|
||||
#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
|
||||
#define MY_CS_HIDDEN 2048 /* don't display in SHOW */
|
||||
#define MY_CS_PUREASCII 4096 /* if a charset is pure ascii */
|
||||
#define MY_CS_NONASCII 8192 /* if not ASCII-compatible */
|
||||
#define MY_CHARSET_UNDEFINED 0
|
||||
|
||||
/* Character repertoire flags */
|
||||
@ -474,6 +475,10 @@ my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
|
||||
my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
|
||||
uint my_charset_repertoire(CHARSET_INFO *cs);
|
||||
|
||||
my_bool my_charset_is_ascii_compatible(CHARSET_INFO *cs);
|
||||
|
||||
extern size_t my_vsnprintf_ex(CHARSET_INFO *cs, char *to, size_t n,
|
||||
const char* fmt, va_list ap);
|
||||
|
||||
#define _MY_U 01 /* Upper case */
|
||||
#define _MY_L 02 /* Lower case */
|
||||
|
@ -250,16 +250,10 @@ extern size_t my_snprintf(char *to, size_t n, const char *fmt, ...)
|
||||
|
||||
/*
|
||||
LEX_STRING -- a pair of a C-string and its length.
|
||||
(it's part of the plugin API as a MYSQL_LEX_STRING)
|
||||
*/
|
||||
|
||||
#ifndef _my_plugin_h
|
||||
/* This definition must match the one given in mysql/plugin.h */
|
||||
struct st_mysql_lex_string
|
||||
{
|
||||
char *str;
|
||||
size_t length;
|
||||
};
|
||||
#endif
|
||||
#include <mysql/plugin.h>
|
||||
typedef struct st_mysql_lex_string LEX_STRING;
|
||||
|
||||
#define STRING_WITH_LEN(X) (X), ((size_t) (sizeof(X) - 1))
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef MY_AES_INCLUDED
|
||||
#define MY_AES_INCLUDED
|
||||
|
||||
/* Copyright (C) 2002 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -63,3 +66,5 @@ int my_aes_decrypt(const char *source, int source_length, char *dest,
|
||||
int my_aes_get_size(int source_length);
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* MY_AES_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef MY_ATOMIC_INCLUDED
|
||||
#define MY_ATOMIC_INCLUDED
|
||||
|
||||
/* Copyright (C) 2006 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -150,3 +153,4 @@ extern int my_atomic_initialize();
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* MY_ATOMIC_INCLUDED */
|
||||
|
@ -255,7 +255,17 @@ enum ha_base_keytype {
|
||||
HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \
|
||||
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
|
||||
|
||||
#define HA_KEY_HAS_PART_KEY_SEG 65536 /* Key contains partial segments */
|
||||
/*
|
||||
Key contains partial segments.
|
||||
|
||||
This flag is internal to the MySQL server by design. It is not supposed
|
||||
neither to be saved in FRM-files, nor to be passed to storage engines.
|
||||
It is intended to pass information into internal static sort_keys(KEY *,
|
||||
KEY *) function.
|
||||
|
||||
This flag can be calculated -- it's based on key lengths comparison.
|
||||
*/
|
||||
#define HA_KEY_HAS_PART_KEY_SEG 65536
|
||||
|
||||
/* Automatic bits in key-flag */
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef MY_BIT_INCLUDED
|
||||
#define MY_BIT_INCLUDED
|
||||
|
||||
/*
|
||||
Some useful bit functions
|
||||
*/
|
||||
@ -107,3 +110,5 @@ extern uint my_count_bits(ulonglong v);
|
||||
extern uint my_count_bits_ushort(ushort v);
|
||||
#endif /* HAVE_INLINE */
|
||||
C_MODE_END
|
||||
|
||||
#endif /* MY_BIT_INCLUDED */
|
||||
|
@ -16,101 +16,64 @@
|
||||
#ifndef _dbug_h
|
||||
#define _dbug_h
|
||||
|
||||
#if defined(__cplusplus) && !defined(DBUG_OFF)
|
||||
class Dbug_violation_helper
|
||||
{
|
||||
public:
|
||||
inline Dbug_violation_helper() :
|
||||
_entered(TRUE)
|
||||
{ }
|
||||
|
||||
inline ~Dbug_violation_helper()
|
||||
{
|
||||
assert(!_entered);
|
||||
}
|
||||
|
||||
inline void leave()
|
||||
{
|
||||
_entered= FALSE;
|
||||
}
|
||||
|
||||
private:
|
||||
bool _entered;
|
||||
};
|
||||
#endif /* C++ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if !defined(DBUG_OFF) && !defined(_lint)
|
||||
struct _db_code_state_;
|
||||
extern int _db_keyword_(struct _db_code_state_ *cs, const char *keyword);
|
||||
extern int _db_strict_keyword_(const char *keyword);
|
||||
|
||||
struct _db_stack_frame_ {
|
||||
const char *func; /* function name of the previous stack frame */
|
||||
const char *file; /* filename of the function of previous frame */
|
||||
uint level; /* this nesting level, highest bit enables tracing */
|
||||
struct _db_stack_frame_ *prev; /* pointer to the previous frame */
|
||||
};
|
||||
|
||||
struct _db_code_state_;
|
||||
extern my_bool _dbug_on_;
|
||||
extern my_bool _db_keyword_(struct _db_code_state_ *, const char *, int);
|
||||
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
|
||||
extern int _db_explain_init_(char *buf, size_t len);
|
||||
extern void _db_setjmp_(void);
|
||||
extern void _db_longjmp_(void);
|
||||
extern int _db_is_pushed_(void);
|
||||
extern void _db_setjmp_(void);
|
||||
extern void _db_longjmp_(void);
|
||||
extern void _db_process_(const char *name);
|
||||
extern void _db_push_(const char *control);
|
||||
extern void _db_pop_(void);
|
||||
extern void _db_set_(struct _db_code_state_ *cs, const char *control);
|
||||
extern void _db_push_(const char *control);
|
||||
extern void _db_pop_(void);
|
||||
extern void _db_set_(const char *control);
|
||||
extern void _db_set_init_(const char *control);
|
||||
extern void _db_enter_(const char *_func_,const char *_file_,uint _line_,
|
||||
const char **_sfunc_,const char **_sfile_,
|
||||
uint *_slevel_, char ***);
|
||||
extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
|
||||
uint *_slevel_);
|
||||
extern void _db_pargs_(uint _line_,const char *keyword);
|
||||
extern void _db_doprnt_ _VARARGS((const char *format,...))
|
||||
extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
|
||||
struct _db_stack_frame_ *_stack_frame_);
|
||||
extern void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_);
|
||||
extern void _db_pargs_(uint _line_,const char *keyword);
|
||||
extern void _db_doprnt_ _VARARGS((const char *format,...))
|
||||
ATTRIBUTE_FORMAT(printf, 1, 2);
|
||||
extern void _db_dump_(uint _line_,const char *keyword,
|
||||
extern void _db_dump_(uint _line_,const char *keyword,
|
||||
const unsigned char *memory, size_t length);
|
||||
extern void _db_end_(void);
|
||||
extern void _db_lock_file_(void);
|
||||
extern void _db_unlock_file_(void);
|
||||
extern FILE *_db_fp_(void);
|
||||
extern void _db_end_(void);
|
||||
extern void _db_lock_file_(void);
|
||||
extern void _db_unlock_file_(void);
|
||||
extern FILE *_db_fp_(void);
|
||||
extern void _db_flush_();
|
||||
extern const char* _db_get_func_(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#define DBUG_ENTER(a) \
|
||||
const char *_db_func_, *_db_file_; \
|
||||
uint _db_level_; \
|
||||
char **_db_framep_; \
|
||||
Dbug_violation_helper dbug_violation_helper; \
|
||||
_db_enter_ (a, __FILE__, __LINE__, &_db_func_, &_db_file_, \
|
||||
&_db_level_, &_db_framep_)
|
||||
#define DBUG_VIOLATION_HELPER_LEAVE dbug_violation_helper.leave()
|
||||
|
||||
#else /* C */
|
||||
|
||||
#define DBUG_ENTER(a) \
|
||||
const char *_db_func_, *_db_file_; \
|
||||
uint _db_level_; \
|
||||
char **_db_framep_; \
|
||||
_db_enter_ (a, __FILE__, __LINE__, &_db_func_, &_db_file_, \
|
||||
&_db_level_, &_db_framep_)
|
||||
#define DBUG_VIOLATION_HELPER_LEAVE do { } while(0)
|
||||
|
||||
#endif /* C++ */
|
||||
|
||||
#define DBUG_LEAVE \
|
||||
DBUG_VIOLATION_HELPER_LEAVE; \
|
||||
_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)
|
||||
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
|
||||
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
|
||||
#define DBUG_LEAVE _db_return_ (__LINE__, &_db_stack_frame_)
|
||||
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
|
||||
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
|
||||
#define DBUG_EXECUTE(keyword,a1) \
|
||||
do {if (_db_keyword_(0, (keyword))) { a1 }} while(0)
|
||||
do {if (_db_keyword_(0, (keyword), 0)) { a1 }} while(0)
|
||||
#define DBUG_EXECUTE_IF(keyword,a1) \
|
||||
do {if (_db_strict_keyword_ (keyword)) { a1 } } while(0)
|
||||
do {if (_db_keyword_(0, (keyword), 1)) { a1 }} while(0)
|
||||
#define DBUG_EVALUATE(keyword,a1,a2) \
|
||||
(_db_keyword_(0,(keyword)) ? (a1) : (a2))
|
||||
(_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
|
||||
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
|
||||
(_db_strict_keyword_((keyword)) ? (a1) : (a2))
|
||||
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
|
||||
#define DBUG_PRINT(keyword,arglist) \
|
||||
do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
|
||||
#define DBUG_PUSH(a1) _db_push_ (a1)
|
||||
#define DBUG_POP() _db_pop_ ()
|
||||
#define DBUG_SET(a1) _db_set_ (0, (a1))
|
||||
#define DBUG_SET(a1) _db_set_ (a1)
|
||||
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
|
||||
#define DBUG_PROCESS(a1) _db_process_(a1)
|
||||
#define DBUG_FILE _db_fp_()
|
||||
@ -123,37 +86,66 @@ extern FILE *_db_fp_(void);
|
||||
#define DBUG_ASSERT(A) assert(A)
|
||||
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
|
||||
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
|
||||
#define IF_DBUG(A) A
|
||||
#else /* No debugger */
|
||||
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
|
||||
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
|
||||
#ifndef __WIN__
|
||||
#define DBUG_ABORT() (_db_flush_(), abort())
|
||||
#else
|
||||
/*
|
||||
Avoid popup with abort/retry/ignore buttons. When BUG#31745 is fixed we can
|
||||
call abort() instead of _exit(3) (now it would cause a "test signal" popup).
|
||||
*/
|
||||
#include <crtdbg.h>
|
||||
#define DBUG_ABORT() (_db_flush_(),\
|
||||
(void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE),\
|
||||
(void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR),\
|
||||
_exit(3))
|
||||
#endif
|
||||
#define DBUG_CHECK_CRASH(func, op) \
|
||||
do { char _dbuf_[255]; strxnmov(_dbuf_, sizeof(_dbuf_)-1, (func), (op)); \
|
||||
DBUG_EXECUTE_IF(_dbuf_, DBUG_ABORT()); } while(0)
|
||||
#define DBUG_CRASH_ENTER(func) \
|
||||
DBUG_ENTER(func); DBUG_CHECK_CRASH(func, "_crash_enter")
|
||||
#define DBUG_CRASH_RETURN(val) \
|
||||
DBUG_CHECK_CRASH(_db_get_func_(), "_crash_return")
|
||||
#define DBUG_CRASH_VOID_RETURN \
|
||||
DBUG_CHECK_CRASH (_db_get_func_(), "_crash_return")
|
||||
|
||||
#else /* No debugger */
|
||||
|
||||
#define DBUG_ENTER(a1)
|
||||
#define DBUG_LEAVE
|
||||
#define DBUG_VIOLATION_HELPER_LEAVE
|
||||
#define DBUG_RETURN(a1) do { return(a1); } while(0)
|
||||
#define DBUG_VOID_RETURN do { return; } while(0)
|
||||
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
|
||||
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
|
||||
#define DBUG_RETURN(a1) do { return(a1); } while(0)
|
||||
#define DBUG_VOID_RETURN do { return; } while(0)
|
||||
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
|
||||
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
|
||||
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
|
||||
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
|
||||
#define DBUG_PRINT(keyword,arglist) do { } while(0)
|
||||
#define DBUG_PUSH(a1)
|
||||
#define DBUG_SET(a1) do { } while(0)
|
||||
#define DBUG_SET_INITIAL(a1) do { } while(0)
|
||||
#define DBUG_POP()
|
||||
#define DBUG_PROCESS(a1)
|
||||
#define DBUG_PRINT(keyword,arglist) do { } while(0)
|
||||
#define DBUG_PUSH(a1) do { } while(0)
|
||||
#define DBUG_SET(a1) do { } while(0)
|
||||
#define DBUG_SET_INITIAL(a1) do { } while(0)
|
||||
#define DBUG_POP() do { } while(0)
|
||||
#define DBUG_PROCESS(a1) do { } while(0)
|
||||
#define DBUG_SETJMP(a1) setjmp(a1)
|
||||
#define DBUG_LONGJMP(a1) longjmp(a1)
|
||||
#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
|
||||
#define DBUG_END()
|
||||
#define DBUG_ASSERT(A) do { } while(0)
|
||||
#define DBUG_LOCK_FILE
|
||||
#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
|
||||
#define DBUG_END() do { } while(0)
|
||||
#define DBUG_ASSERT(A) do { } while(0)
|
||||
#define DBUG_LOCK_FILE do { } while(0)
|
||||
#define DBUG_FILE (stderr)
|
||||
#define DBUG_UNLOCK_FILE
|
||||
#define DBUG_UNLOCK_FILE do { } while(0)
|
||||
#define DBUG_EXPLAIN(buf,len)
|
||||
#define DBUG_EXPLAIN_INITIAL(buf,len)
|
||||
#define IF_DBUG(A)
|
||||
#define DEBUGGER_OFF do { } while(0)
|
||||
#define DEBUGGER_ON do { } while(0)
|
||||
#define DBUG_ABORT() abort()
|
||||
#define DBUG_CRASH_ENTER(func)
|
||||
#define DBUG_CRASH_RETURN(val) do { return(val); } while(0)
|
||||
#define DBUG_CRASH_VOID_RETURN do { return; } while(0)
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -69,7 +69,11 @@ typedef struct my_stat
|
||||
|
||||
#else
|
||||
|
||||
#if(_MSC_VER)
|
||||
#define MY_STAT struct _stati64 /* 64 bit file size */
|
||||
#else
|
||||
#define MY_STAT struct stat /* Orginal struct have what we need */
|
||||
#endif
|
||||
|
||||
#endif /* USE_MY_STAT_STRUCT */
|
||||
|
||||
|
@ -410,6 +410,7 @@ C_MODE_END
|
||||
#ifndef stdin
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
@ -648,8 +649,6 @@ C_MODE_END
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <my_dbug.h>
|
||||
|
||||
#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/
|
||||
#define ASCII_BITS_USED 8 /* Bit char used */
|
||||
#define NEAR_F /* No near function handling */
|
||||
@ -749,7 +748,41 @@ typedef SOCKET_SIZE_TYPE size_socket;
|
||||
#define FN_LIBCHAR '/'
|
||||
#define FN_ROOTDIR "/"
|
||||
#endif
|
||||
#define MY_NFILE 64 /* This is only used to save filenames */
|
||||
|
||||
/*
|
||||
MY_FILE_MIN is Windows speciality and is used to quickly detect
|
||||
the mismatch of CRT and mysys file IO usage on Windows at runtime.
|
||||
CRT file descriptors can be in the range 0-2047, whereas descriptors returned
|
||||
by my_open() will start with 2048. If a file descriptor with value less then
|
||||
MY_FILE_MIN is passed to mysys IO function, chances are it stemms from
|
||||
open()/fileno() and not my_open()/my_fileno.
|
||||
|
||||
For Posix, mysys functions are light wrappers around libc, and MY_FILE_MIN
|
||||
is logically 0.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MY_FILE_MIN 2048
|
||||
#else
|
||||
#define MY_FILE_MIN 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
MY_NFILE is the default size of my_file_info array.
|
||||
|
||||
It is larger on Windows, because it all file handles are stored in my_file_info
|
||||
Default size is 16384 and this should be enough for most cases.If it is not
|
||||
enough, --max-open-files with larger value can be used.
|
||||
|
||||
For Posix , my_file_info array is only used to store filenames for
|
||||
error reporting and its size is not a limitation for number of open files.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define MY_NFILE (16384 + MY_FILE_MIN)
|
||||
#else
|
||||
#define MY_NFILE 64
|
||||
#endif
|
||||
|
||||
#ifndef OS_FILE_LIMIT
|
||||
#define OS_FILE_LIMIT 65535
|
||||
#endif
|
||||
@ -786,9 +819,8 @@ typedef SOCKET_SIZE_TYPE size_socket;
|
||||
/* Some things that this system doesn't have */
|
||||
|
||||
#define NO_HASH /* Not needed anymore */
|
||||
#ifdef __WIN__
|
||||
#define NO_DIR_LIBRARY /* Not standar dir-library */
|
||||
#define USE_MY_STAT_STRUCT /* For my_lib */
|
||||
#ifdef _WIN32
|
||||
#define NO_DIR_LIBRARY /* Not standard dir-library */
|
||||
#endif
|
||||
|
||||
/* Some defines of functions for portability */
|
||||
@ -1143,6 +1175,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */
|
||||
#define reg16 register
|
||||
#endif
|
||||
|
||||
#include <my_dbug.h>
|
||||
|
||||
/*
|
||||
Sometimes we want to make sure that the variable is not put into
|
||||
a register in debugging mode so we can see its value in the core
|
||||
|
@ -53,8 +53,8 @@ typedef struct st_HA_KEYSEG /* Key-portion */
|
||||
uint16 bit_pos; /* Position to bit part */
|
||||
uint16 flag;
|
||||
uint16 length; /* Keylength */
|
||||
uint16 language;
|
||||
uint8 type; /* Type of key (for sort) */
|
||||
uint8 language;
|
||||
uint8 null_bit; /* bitmask to test for NULL */
|
||||
uint8 bit_start,bit_end; /* if bit field */
|
||||
uint8 bit_length; /* Length of bit part */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef MY_LIBWRAP_INCLUDED
|
||||
#define MY_LIBWRAP_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -25,3 +28,4 @@ extern int my_hosts_access(struct request_info *req);
|
||||
extern char *my_eval_client(struct request_info *req);
|
||||
|
||||
#endif /* HAVE_LIBWRAP */
|
||||
#endif /* MY_LIBWRAP_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef MY_MD5_INCLUDED
|
||||
#define MY_MD5_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -52,3 +55,5 @@ do { \
|
||||
my_MD5Update (&ctx, buf, len); \
|
||||
my_MD5Final (digest, &ctx); \
|
||||
} while (0)
|
||||
|
||||
#endif /* MY_MD__INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef MY_NO_PTHREAD_INCLUDED
|
||||
#define MY_NO_PTHREAD_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -14,9 +17,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
|
||||
#if !defined(_my_no_pthread_h) && !defined(THREAD)
|
||||
#define _my_no_pthread_h
|
||||
|
||||
#ifndef THREAD
|
||||
|
||||
/*
|
||||
This block is to access some thread-related type definitions
|
||||
@ -48,3 +49,4 @@
|
||||
#define rwlock_destroy(A)
|
||||
|
||||
#endif
|
||||
#endif /* MY_NO_PTHREAD_INCLUDED */
|
||||
|
@ -31,7 +31,7 @@ extern "C" {
|
||||
|
||||
#if defined(__WIN__)
|
||||
typedef CRITICAL_SECTION pthread_mutex_t;
|
||||
typedef HANDLE pthread_t;
|
||||
typedef DWORD pthread_t;
|
||||
typedef struct thread_attr {
|
||||
DWORD dwStackSize ;
|
||||
DWORD dwCreatingFlag ;
|
||||
@ -64,8 +64,7 @@ typedef struct {
|
||||
|
||||
|
||||
typedef int pthread_mutexattr_t;
|
||||
#define win_pthread_self my_thread_var->pthread_self
|
||||
#define pthread_self() win_pthread_self
|
||||
#define pthread_self() GetCurrentThreadId()
|
||||
#define pthread_handler_t EXTERNC void * __cdecl
|
||||
typedef void * (__cdecl *pthread_handler)(void *);
|
||||
|
||||
@ -99,8 +98,7 @@ struct timespec {
|
||||
(ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \
|
||||
}
|
||||
|
||||
void win_pthread_init(void);
|
||||
int win_pthread_setspecific(void *A,void *B,uint length);
|
||||
|
||||
int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
|
||||
int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
|
||||
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
|
||||
@ -117,42 +115,25 @@ int pthread_attr_destroy(pthread_attr_t *connect_att);
|
||||
struct tm *localtime_r(const time_t *timep,struct tm *tmp);
|
||||
struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
|
||||
|
||||
void pthread_exit(void *a);
|
||||
int pthread_join(pthread_t thread, void **value_ptr);
|
||||
|
||||
void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
|
||||
|
||||
#define ETIMEDOUT 145 /* Win32 doesn't have this */
|
||||
#define getpid() GetCurrentThreadId()
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define _REENTRANT 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
|
||||
|
||||
/*
|
||||
Windows has two ways to use thread local storage. The most efficient
|
||||
is using __declspec(thread), but that does not work properly when
|
||||
used in a .dll that is loaded at runtime, after program load. So for
|
||||
libmysql.dll and libmysqld.dll we define USE_TLS in order to use the
|
||||
TlsXxx() API instead, which works in all cases.
|
||||
*/
|
||||
#ifdef USE_TLS /* For LIBMYSQL.DLL */
|
||||
|
||||
#undef SAFE_MUTEX /* This will cause conflicts */
|
||||
#define pthread_key(T,V) DWORD V
|
||||
#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
|
||||
#define pthread_key_delete(A) TlsFree(A)
|
||||
#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
|
||||
#define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
|
||||
#define pthread_getspecific(A) (TlsGetValue(A))
|
||||
#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
|
||||
#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V))
|
||||
#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
|
||||
#define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
|
||||
#else
|
||||
#define pthread_key(T,V) __declspec(thread) T V
|
||||
#define pthread_key_create(A,B) pthread_dummy(0)
|
||||
#define pthread_key_delete(A) pthread_dummy(0)
|
||||
#define pthread_getspecific(A) (&(A))
|
||||
#define my_pthread_getspecific(T,A) (&(A))
|
||||
#define my_pthread_getspecific_ptr(T,V) (V)
|
||||
#define my_pthread_setspecific_ptr(T,V) ((T)=(V),0)
|
||||
#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A))
|
||||
#endif /* USE_TLS */
|
||||
|
||||
#define pthread_equal(A,B) ((A) == (B))
|
||||
#define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0)
|
||||
@ -163,7 +144,6 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
|
||||
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
|
||||
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
|
||||
|
||||
#define pthread_join(A,B) (WaitForSingleObject((A), INFINITE) != WAIT_OBJECT_0)
|
||||
|
||||
/* Dummy defines for easier code */
|
||||
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
|
||||
@ -690,6 +670,7 @@ struct st_my_thread_var
|
||||
};
|
||||
|
||||
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
|
||||
extern void **my_thread_var_dbug();
|
||||
extern uint my_thread_end_wait_time;
|
||||
#define my_thread_var (_my_thread_var())
|
||||
#define my_errno my_thread_var->thr_errno
|
||||
|
@ -39,6 +39,17 @@ extern int NEAR my_errno; /* Last error in mysys */
|
||||
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
|
||||
#define MY_INIT(name); { my_progname= name; my_init(); }
|
||||
|
||||
/**
|
||||
Max length of an error message generated by mysys utilities.
|
||||
Some mysys functions produce error messages. These mostly go
|
||||
to stderr.
|
||||
This constant defines the size of the buffer used to format
|
||||
the message. It should be kept in sync with MYSQL_ERRMSG_SIZE,
|
||||
since sometimes mysys errors are stored in the server diagnostics
|
||||
area, and we would like to avoid unexpected truncation.
|
||||
*/
|
||||
#define MYSYS_ERRMSG_SIZE (512)
|
||||
|
||||
#define MY_FILE_ERROR ((size_t) -1)
|
||||
|
||||
/* General bitmaps for my_func's */
|
||||
@ -90,8 +101,6 @@ extern int NEAR my_errno; /* Last error in mysys */
|
||||
#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
|
||||
#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
|
||||
#define ME_FATALERROR 1024 /* Fatal statement error */
|
||||
#define ME_NO_WARNING_FOR_ERROR 2048 /* Don't push a warning for error */
|
||||
#define ME_NO_SP_HANDLER 4096 /* Don't call stored routine error handlers */
|
||||
|
||||
/* Bits in last argument to fn_format */
|
||||
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
|
||||
@ -220,8 +229,8 @@ extern int errno; /* declare errno */
|
||||
extern char *home_dir; /* Home directory for user */
|
||||
extern const char *my_progname; /* program-name (printed in errors) */
|
||||
extern char NEAR curr_dir[]; /* Current directory for user */
|
||||
extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
|
||||
extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
|
||||
extern void (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
|
||||
extern void (*fatal_error_handler_hook)(uint my_err, const char *str,
|
||||
myf MyFlags);
|
||||
extern uint my_file_limit;
|
||||
extern ulong my_thread_stack_size;
|
||||
@ -232,8 +241,9 @@ extern uint my_large_page_size;
|
||||
#endif
|
||||
|
||||
/* charsets */
|
||||
#define MY_ALL_CHARSETS_SIZE 2048
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *default_charset_info;
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *all_charsets[256];
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *all_charsets[MY_ALL_CHARSETS_SIZE];
|
||||
extern CHARSET_INFO compiled_charsets[];
|
||||
|
||||
/* statistics */
|
||||
@ -321,9 +331,13 @@ enum file_type
|
||||
|
||||
struct st_my_file_info
|
||||
{
|
||||
char * name;
|
||||
enum file_type type;
|
||||
#if defined(THREAD) && !defined(HAVE_PREAD)
|
||||
char *name;
|
||||
#ifdef _WIN32
|
||||
HANDLE fhandle; /* win32 file handle */
|
||||
int oflag; /* open flags, e.g O_APPEND */
|
||||
#endif
|
||||
enum file_type type;
|
||||
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
|
||||
pthread_mutex_t mutex;
|
||||
#endif
|
||||
};
|
||||
@ -628,43 +642,55 @@ extern void *my_memmem(const void *haystack, size_t haystacklen,
|
||||
const void *needle, size_t needlelen);
|
||||
|
||||
|
||||
#ifdef __WIN__
|
||||
extern int my_access(const char *path, int amode);
|
||||
extern File my_sopen(const char *path, int oflag, int shflag, int pmode);
|
||||
#ifdef _WIN32
|
||||
extern int my_access(const char *path, int amode);
|
||||
#else
|
||||
#define my_access access
|
||||
#endif
|
||||
|
||||
extern int check_if_legal_filename(const char *path);
|
||||
extern int check_if_legal_tablename(const char *path);
|
||||
|
||||
#if defined(__WIN__) && defined(__NT__)
|
||||
#ifdef _WIN32
|
||||
extern int nt_share_delete(const char *name,myf MyFlags);
|
||||
#define my_delete_allow_opened(fname,flags) nt_share_delete((fname),(flags))
|
||||
#else
|
||||
#define my_delete_allow_opened(fname,flags) my_delete((fname),(flags))
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Windows-only functions (CRT equivalents)*/
|
||||
extern File my_sopen(const char *path, int oflag, int shflag, int pmode);
|
||||
extern HANDLE my_get_osfhandle(File fd);
|
||||
extern void my_osmaperr(unsigned long last_error);
|
||||
#endif
|
||||
|
||||
#ifndef TERMINATE
|
||||
extern void TERMINATE(FILE *file, uint flag);
|
||||
#endif
|
||||
extern void init_glob_errs(void);
|
||||
extern const char** get_global_errmsgs();
|
||||
extern void wait_for_free_space(const char *filename, int errors);
|
||||
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
|
||||
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
|
||||
extern int my_fclose(FILE *fd,myf MyFlags);
|
||||
extern File my_fileno(FILE *fd);
|
||||
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
|
||||
extern int my_sync(File fd, myf my_flags);
|
||||
extern int my_sync_dir(const char *dir_name, myf my_flags);
|
||||
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
|
||||
extern int my_error _VARARGS((int nr,myf MyFlags, ...));
|
||||
extern int my_printf_error _VARARGS((uint my_err, const char *format,
|
||||
myf MyFlags, ...))
|
||||
ATTRIBUTE_FORMAT(printf, 2, 4);
|
||||
extern int my_error_register(const char **errmsgs, int first, int last);
|
||||
extern void my_error _VARARGS((int nr,myf MyFlags, ...));
|
||||
extern void my_printf_error _VARARGS((uint my_err, const char *format,
|
||||
myf MyFlags, ...))
|
||||
ATTRIBUTE_FORMAT(printf, 2, 4);
|
||||
extern void my_printv_error(uint error, const char *format, myf MyFlags,
|
||||
va_list ap);
|
||||
extern int my_error_register(const char** (*get_errmsgs) (),
|
||||
int first, int last);
|
||||
extern const char **my_error_unregister(int first, int last);
|
||||
extern int my_message(uint my_err, const char *str,myf MyFlags);
|
||||
extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
|
||||
extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
|
||||
extern void my_message(uint my_err, const char *str,myf MyFlags);
|
||||
extern void my_message_no_curses(uint my_err, const char *str,myf MyFlags);
|
||||
extern void my_message_curses(uint my_err, const char *str,myf MyFlags);
|
||||
extern my_bool my_init(void);
|
||||
extern void my_end(int infoflag);
|
||||
extern int my_redel(const char *from, const char *to, int MyFlags);
|
||||
@ -853,6 +879,7 @@ extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
|
||||
extern int get_defaults_options(int argc, char **argv,
|
||||
char **defaults, char **extra_defaults,
|
||||
char **group_suffix);
|
||||
extern const char *args_separator;
|
||||
extern int my_load_defaults(const char *conf_file, const char **groups,
|
||||
int *argc, char ***argv, const char ***);
|
||||
extern int load_defaults(const char *conf_file, const char **groups,
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef MY_UCTYPE_INCLUDED
|
||||
#define MY_UCTYPE_INCLUDED
|
||||
|
||||
/* Copyright (C) 2006 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -1477,3 +1480,4 @@ MY_UNI_CTYPE my_uni_ctype[256]={
|
||||
};
|
||||
|
||||
|
||||
#endif /* MY_UCTYPE_INCLUDED */
|
||||
|
@ -162,7 +162,7 @@ typedef struct st_mi_create_info
|
||||
ulonglong data_file_length;
|
||||
ulonglong key_file_length;
|
||||
uint old_options;
|
||||
uint8 language;
|
||||
uint16 language;
|
||||
my_bool with_auto_increment;
|
||||
} MI_CREATE_INFO;
|
||||
|
||||
@ -410,7 +410,7 @@ typedef struct st_mi_check_param
|
||||
uint out_flag,warning_printed,error_printed,verbose;
|
||||
uint opt_sort_key,total_files,max_level;
|
||||
uint testflag, key_cache_block_size;
|
||||
uint8 language;
|
||||
uint16 language;
|
||||
my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
|
||||
my_bool retry_repair, force_sort;
|
||||
char temp_filename[FN_REFLEN],*isam_file_name;
|
||||
@ -432,6 +432,10 @@ typedef struct st_mi_check_param
|
||||
const char *db_name, *table_name;
|
||||
const char *op_name;
|
||||
enum_mi_stats_method stats_method;
|
||||
#ifdef THREAD
|
||||
pthread_mutex_t print_msg_mutex;
|
||||
my_bool need_print_msg_lock;
|
||||
#endif
|
||||
} MI_CHECK;
|
||||
|
||||
typedef struct st_sort_ft_buf
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef MYISAMPACK_INCLUDED
|
||||
#define MYISAMPACK_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -236,3 +239,4 @@
|
||||
mi_int4store(((T) + 4), A); }}
|
||||
#define mi_sizekorr(T) mi_uint4korr((uchar*) (T) + 4)
|
||||
#endif
|
||||
#endif /* MYISAMPACK_INCLUDED */
|
||||
|
146
include/mysql.h
146
include/mysql.h
@ -86,9 +86,11 @@ extern char *mysql_unix_port;
|
||||
#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
|
||||
#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
|
||||
#define IS_BLOB(n) ((n) & BLOB_FLAG)
|
||||
#define IS_NUM(t) ((t) <= MYSQL_TYPE_INT24 || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
|
||||
#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG)
|
||||
#define INTERNAL_NUM_FIELD(f) (((f)->type <= MYSQL_TYPE_INT24 && ((f)->type != MYSQL_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == MYSQL_TYPE_YEAR)
|
||||
/**
|
||||
Returns true if the value is a number which does not need quotes for
|
||||
the sql_lex.cc parser to parse correctly.
|
||||
*/
|
||||
#define IS_NUM(t) (((t) <= MYSQL_TYPE_INT24 && (t) != MYSQL_TYPE_TIMESTAMP) || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
|
||||
#define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING)
|
||||
|
||||
|
||||
@ -186,24 +188,10 @@ struct st_mysql_options {
|
||||
unsigned long max_allowed_packet;
|
||||
my_bool use_ssl; /* if to use SSL or not */
|
||||
my_bool compress,named_pipe;
|
||||
/*
|
||||
On connect, find out the replication role of the server, and
|
||||
establish connections to all the peers
|
||||
*/
|
||||
my_bool rpl_probe;
|
||||
/*
|
||||
Each call to mysql_real_query() will parse it to tell if it is a read
|
||||
or a write, and direct it to the slave or the master
|
||||
*/
|
||||
my_bool rpl_parse;
|
||||
/*
|
||||
If set, never read from a master, only from slave, when doing
|
||||
a read that is replication-aware
|
||||
*/
|
||||
my_bool no_master_reads;
|
||||
#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
|
||||
my_bool separate_thread;
|
||||
#endif
|
||||
my_bool unused1;
|
||||
my_bool unused2;
|
||||
my_bool unused3;
|
||||
my_bool unused4;
|
||||
enum mysql_option methods_to_use;
|
||||
char *client_ip;
|
||||
/* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */
|
||||
@ -230,15 +218,6 @@ enum mysql_protocol_type
|
||||
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
|
||||
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
|
||||
};
|
||||
/*
|
||||
There are three types of queries - the ones that have to go to
|
||||
the master, the ones that go to a slave, and the adminstrative
|
||||
type which must happen on the pivot connectioin
|
||||
*/
|
||||
enum mysql_rpl_type
|
||||
{
|
||||
MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
|
||||
};
|
||||
|
||||
typedef struct character_set
|
||||
{
|
||||
@ -283,21 +262,8 @@ typedef struct st_mysql
|
||||
|
||||
/* session-wide random string */
|
||||
char scramble[SCRAMBLE_LENGTH+1];
|
||||
|
||||
/*
|
||||
Set if this is the original connection, not a master or a slave we have
|
||||
added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave()
|
||||
*/
|
||||
my_bool rpl_pivot;
|
||||
/*
|
||||
Pointers to the master, and the next slave connections, points to
|
||||
itself if lone connection.
|
||||
*/
|
||||
struct st_mysql* master, *next_slave;
|
||||
|
||||
struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
|
||||
/* needed for send/read/store/use result to work correctly with replication */
|
||||
struct st_mysql* last_used_con;
|
||||
my_bool unused1;
|
||||
void *unused2, *unused3, *unused4, *unused5;
|
||||
|
||||
LIST *stmts; /* list of all statements */
|
||||
const struct st_mysql_methods *methods;
|
||||
@ -331,35 +297,12 @@ typedef struct st_mysql_res {
|
||||
void *extension;
|
||||
} MYSQL_RES;
|
||||
|
||||
#define MAX_MYSQL_MANAGER_ERR 256
|
||||
#define MAX_MYSQL_MANAGER_MSG 256
|
||||
|
||||
#define MANAGER_OK 200
|
||||
#define MANAGER_INFO 250
|
||||
#define MANAGER_ACCESS 401
|
||||
#define MANAGER_CLIENT_ERR 450
|
||||
#define MANAGER_INTERNAL_ERR 500
|
||||
|
||||
#if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT)
|
||||
#define MYSQL_CLIENT
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct st_mysql_manager
|
||||
{
|
||||
NET net;
|
||||
char *host, *user, *passwd;
|
||||
char *net_buf, *net_buf_pos, *net_data_end;
|
||||
unsigned int port;
|
||||
int cmd_status;
|
||||
int last_errno;
|
||||
int net_buf_size;
|
||||
my_bool free_me;
|
||||
my_bool eof;
|
||||
char last_error[MAX_MYSQL_MANAGER_ERR];
|
||||
void *extension;
|
||||
} MYSQL_MANAGER;
|
||||
|
||||
typedef struct st_mysql_parameters
|
||||
{
|
||||
unsigned long *p_max_allowed_packet;
|
||||
@ -452,16 +395,6 @@ int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
|
||||
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
|
||||
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
|
||||
|
||||
/* perform query on master */
|
||||
my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
my_bool STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
/* perform query on slave */
|
||||
my_bool STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
void STDCALL mysql_get_character_set_info(MYSQL *mysql,
|
||||
MY_CHARSET_INFO *charset);
|
||||
|
||||
@ -483,37 +416,6 @@ mysql_set_local_infile_handler(MYSQL *mysql,
|
||||
void
|
||||
mysql_set_local_infile_default(MYSQL *mysql);
|
||||
|
||||
|
||||
/*
|
||||
enable/disable parsing of all queries to decide if they go on master or
|
||||
slave
|
||||
*/
|
||||
void STDCALL mysql_enable_rpl_parse(MYSQL* mysql);
|
||||
void STDCALL mysql_disable_rpl_parse(MYSQL* mysql);
|
||||
/* get the value of the parse flag */
|
||||
int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql);
|
||||
|
||||
/* enable/disable reads from master */
|
||||
void STDCALL mysql_enable_reads_from_master(MYSQL* mysql);
|
||||
void STDCALL mysql_disable_reads_from_master(MYSQL* mysql);
|
||||
/* get the value of the master read flag */
|
||||
my_bool STDCALL mysql_reads_from_master_enabled(MYSQL* mysql);
|
||||
|
||||
enum mysql_rpl_type STDCALL mysql_rpl_query_type(const char* q, int len);
|
||||
|
||||
/* discover the master and its slaves */
|
||||
my_bool STDCALL mysql_rpl_probe(MYSQL* mysql);
|
||||
|
||||
/* set the master, close/free the old one, if it is not a pivot */
|
||||
int STDCALL mysql_set_master(MYSQL* mysql, const char* host,
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd);
|
||||
int STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd);
|
||||
|
||||
int STDCALL mysql_shutdown(MYSQL *mysql,
|
||||
enum mysql_enum_shutdown_level
|
||||
shutdown_level);
|
||||
@ -557,21 +459,19 @@ unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
|
||||
char *to,const char *from,
|
||||
unsigned long length);
|
||||
void STDCALL mysql_debug(const char *debug);
|
||||
char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
|
||||
char *to,
|
||||
unsigned long to_length,
|
||||
const char *from,
|
||||
unsigned long from_length,
|
||||
void *param,
|
||||
char *
|
||||
(*extend_buffer)
|
||||
(void *, char *to,
|
||||
unsigned long *length));
|
||||
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
|
||||
unsigned int STDCALL mysql_thread_safe(void);
|
||||
my_bool STDCALL mysql_embedded(void);
|
||||
MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con);
|
||||
MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
|
||||
const char* host,
|
||||
const char* user,
|
||||
const char* passwd,
|
||||
unsigned int port);
|
||||
void STDCALL mysql_manager_close(MYSQL_MANAGER* con);
|
||||
int STDCALL mysql_manager_command(MYSQL_MANAGER* con,
|
||||
const char* cmd, int cmd_len);
|
||||
int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
|
||||
char* res_buf,
|
||||
int res_buf_size);
|
||||
my_bool STDCALL mysql_read_query_result(MYSQL *mysql);
|
||||
|
||||
|
||||
@ -766,7 +666,7 @@ typedef struct st_mysql_methods
|
||||
MYSQL_RES * (*use_result)(MYSQL *mysql);
|
||||
void (*fetch_lengths)(unsigned long *to,
|
||||
MYSQL_ROW column, unsigned int field_count);
|
||||
void (*flush_use_result)(MYSQL *mysql);
|
||||
void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
|
||||
#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
|
||||
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
|
||||
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
|
||||
@ -826,6 +726,7 @@ my_bool STDCALL mysql_rollback(MYSQL * mysql);
|
||||
my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
|
||||
my_bool STDCALL mysql_more_results(MYSQL *mysql);
|
||||
int STDCALL mysql_next_result(MYSQL *mysql);
|
||||
int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt);
|
||||
void STDCALL mysql_close(MYSQL *sock);
|
||||
|
||||
|
||||
@ -840,7 +741,6 @@ MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
|
||||
const char *user, const char *passwd);
|
||||
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
|
||||
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
|
||||
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
|
||||
#endif
|
||||
#define HAVE_MYSQL_REAL_CONNECT
|
||||
|
||||
|
@ -28,15 +28,15 @@ typedef struct st_net {
|
||||
unsigned int *return_status;
|
||||
unsigned char reading_or_writing;
|
||||
char save_char;
|
||||
my_bool unused0;
|
||||
my_bool unused;
|
||||
my_bool compress;
|
||||
my_bool unused1;
|
||||
unsigned char *query_cache_query;
|
||||
my_bool unused2;
|
||||
my_bool compress;
|
||||
my_bool unused3;
|
||||
unsigned char *unused;
|
||||
unsigned int last_errno;
|
||||
unsigned char error;
|
||||
my_bool unused2;
|
||||
my_bool return_errno;
|
||||
my_bool unused4;
|
||||
my_bool unused5;
|
||||
char last_error[512];
|
||||
char sqlstate[5 +1];
|
||||
void *extension;
|
||||
@ -277,10 +277,10 @@ struct st_mysql_options {
|
||||
unsigned long max_allowed_packet;
|
||||
my_bool use_ssl;
|
||||
my_bool compress,named_pipe;
|
||||
my_bool rpl_probe;
|
||||
my_bool rpl_parse;
|
||||
my_bool no_master_reads;
|
||||
my_bool separate_thread;
|
||||
my_bool unused1;
|
||||
my_bool unused2;
|
||||
my_bool unused3;
|
||||
my_bool unused4;
|
||||
enum mysql_option methods_to_use;
|
||||
char *client_ip;
|
||||
my_bool secure_auth;
|
||||
@ -301,10 +301,6 @@ enum mysql_protocol_type
|
||||
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
|
||||
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
|
||||
};
|
||||
enum mysql_rpl_type
|
||||
{
|
||||
MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
|
||||
};
|
||||
typedef struct character_set
|
||||
{
|
||||
unsigned int number;
|
||||
@ -344,10 +340,8 @@ typedef struct st_mysql
|
||||
my_bool free_me;
|
||||
my_bool reconnect;
|
||||
char scramble[20 +1];
|
||||
my_bool rpl_pivot;
|
||||
struct st_mysql* master, *next_slave;
|
||||
struct st_mysql* last_used_slave;
|
||||
struct st_mysql* last_used_con;
|
||||
my_bool unused1;
|
||||
void *unused2, *unused3, *unused4, *unused5;
|
||||
LIST *stmts;
|
||||
const struct st_mysql_methods *methods;
|
||||
void *thd;
|
||||
@ -371,20 +365,6 @@ typedef struct st_mysql_res {
|
||||
my_bool unbuffered_fetch_cancelled;
|
||||
void *extension;
|
||||
} MYSQL_RES;
|
||||
typedef struct st_mysql_manager
|
||||
{
|
||||
NET net;
|
||||
char *host, *user, *passwd;
|
||||
char *net_buf, *net_buf_pos, *net_data_end;
|
||||
unsigned int port;
|
||||
int cmd_status;
|
||||
int last_errno;
|
||||
int net_buf_size;
|
||||
my_bool free_me;
|
||||
my_bool eof;
|
||||
char last_error[256];
|
||||
void *extension;
|
||||
} MYSQL_MANAGER;
|
||||
typedef struct st_mysql_parameters
|
||||
{
|
||||
unsigned long *p_max_allowed_packet;
|
||||
@ -437,14 +417,6 @@ int mysql_real_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
MYSQL_RES * mysql_store_result(MYSQL *mysql);
|
||||
MYSQL_RES * mysql_use_result(MYSQL *mysql);
|
||||
my_bool mysql_master_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
my_bool mysql_master_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
my_bool mysql_slave_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
my_bool mysql_slave_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
void mysql_get_character_set_info(MYSQL *mysql,
|
||||
MY_CHARSET_INFO *charset);
|
||||
void
|
||||
@ -459,22 +431,6 @@ mysql_set_local_infile_handler(MYSQL *mysql,
|
||||
void *);
|
||||
void
|
||||
mysql_set_local_infile_default(MYSQL *mysql);
|
||||
void mysql_enable_rpl_parse(MYSQL* mysql);
|
||||
void mysql_disable_rpl_parse(MYSQL* mysql);
|
||||
int mysql_rpl_parse_enabled(MYSQL* mysql);
|
||||
void mysql_enable_reads_from_master(MYSQL* mysql);
|
||||
void mysql_disable_reads_from_master(MYSQL* mysql);
|
||||
my_bool mysql_reads_from_master_enabled(MYSQL* mysql);
|
||||
enum mysql_rpl_type mysql_rpl_query_type(const char* q, int len);
|
||||
my_bool mysql_rpl_probe(MYSQL* mysql);
|
||||
int mysql_set_master(MYSQL* mysql, const char* host,
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd);
|
||||
int mysql_add_slave(MYSQL* mysql, const char* host,
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd);
|
||||
int mysql_shutdown(MYSQL *mysql,
|
||||
enum mysql_enum_shutdown_level
|
||||
shutdown_level);
|
||||
@ -518,21 +474,19 @@ unsigned long mysql_real_escape_string(MYSQL *mysql,
|
||||
char *to,const char *from,
|
||||
unsigned long length);
|
||||
void mysql_debug(const char *debug);
|
||||
char * mysql_odbc_escape_string(MYSQL *mysql,
|
||||
char *to,
|
||||
unsigned long to_length,
|
||||
const char *from,
|
||||
unsigned long from_length,
|
||||
void *param,
|
||||
char *
|
||||
(*extend_buffer)
|
||||
(void *, char *to,
|
||||
unsigned long *length));
|
||||
void myodbc_remove_escape(MYSQL *mysql,char *name);
|
||||
unsigned int mysql_thread_safe(void);
|
||||
my_bool mysql_embedded(void);
|
||||
MYSQL_MANAGER* mysql_manager_init(MYSQL_MANAGER* con);
|
||||
MYSQL_MANAGER* mysql_manager_connect(MYSQL_MANAGER* con,
|
||||
const char* host,
|
||||
const char* user,
|
||||
const char* passwd,
|
||||
unsigned int port);
|
||||
void mysql_manager_close(MYSQL_MANAGER* con);
|
||||
int mysql_manager_command(MYSQL_MANAGER* con,
|
||||
const char* cmd, int cmd_len);
|
||||
int mysql_manager_fetch_line(MYSQL_MANAGER* con,
|
||||
char* res_buf,
|
||||
int res_buf_size);
|
||||
my_bool mysql_read_query_result(MYSQL *mysql);
|
||||
enum enum_mysql_stmt_state
|
||||
{
|
||||
@ -616,7 +570,7 @@ typedef struct st_mysql_methods
|
||||
MYSQL_RES * (*use_result)(MYSQL *mysql);
|
||||
void (*fetch_lengths)(unsigned long *to,
|
||||
MYSQL_ROW column, unsigned int field_count);
|
||||
void (*flush_use_result)(MYSQL *mysql);
|
||||
void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
|
||||
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
|
||||
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
|
||||
int (*stmt_execute)(MYSQL_STMT *stmt);
|
||||
@ -671,4 +625,5 @@ my_bool mysql_rollback(MYSQL * mysql);
|
||||
my_bool mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
|
||||
my_bool mysql_more_results(MYSQL *mysql);
|
||||
int mysql_next_result(MYSQL *mysql);
|
||||
int mysql_stmt_next_result(MYSQL_STMT *stmt);
|
||||
void mysql_close(MYSQL *sock);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2005 MySQL AB
|
||||
/* Copyright (C) 2005 MySQL AB, 2009 Sun Microsystems, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -16,7 +16,6 @@
|
||||
#ifndef _my_plugin_h
|
||||
#define _my_plugin_h
|
||||
|
||||
|
||||
/*
|
||||
On Windows, exports from DLL need to be declared
|
||||
*/
|
||||
@ -34,15 +33,7 @@ class Item;
|
||||
#define MYSQL_THD void*
|
||||
#endif
|
||||
|
||||
#ifndef _m_string_h
|
||||
/* This definition must match the one given in m_string.h */
|
||||
struct st_mysql_lex_string
|
||||
{
|
||||
char *str;
|
||||
unsigned int length;
|
||||
};
|
||||
#endif /* _m_string_h */
|
||||
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
|
||||
#include <mysql/services.h>
|
||||
|
||||
#define MYSQL_XIDDATASIZE 128
|
||||
/**
|
||||
@ -65,7 +56,7 @@ typedef struct st_mysql_xid MYSQL_XID;
|
||||
Plugin API. Common for all plugin types.
|
||||
*/
|
||||
|
||||
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0100
|
||||
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0101
|
||||
|
||||
/*
|
||||
The allowable types of plugins
|
||||
@ -75,7 +66,8 @@ typedef struct st_mysql_xid MYSQL_XID;
|
||||
#define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */
|
||||
#define MYSQL_DAEMON_PLUGIN 3 /* The daemon/raw plugin type */
|
||||
#define MYSQL_INFORMATION_SCHEMA_PLUGIN 4 /* The I_S plugin type */
|
||||
#define MYSQL_MAX_PLUGIN_TYPE_NUM 5 /* The number of plugin types */
|
||||
#define MYSQL_REPLICATION_PLUGIN 5 /* The replication plugin type */
|
||||
#define MYSQL_MAX_PLUGIN_TYPE_NUM 6 /* The number of plugin types */
|
||||
|
||||
/* We use the following strings to define licenses for plugins */
|
||||
#define PLUGIN_LICENSE_PROPRIETARY 0
|
||||
@ -120,7 +112,8 @@ enum enum_mysql_show_type
|
||||
{
|
||||
SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
|
||||
SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
|
||||
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
|
||||
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
|
||||
SHOW_always_last
|
||||
};
|
||||
|
||||
struct st_mysql_show_var {
|
||||
@ -650,6 +643,17 @@ struct st_mysql_information_schema
|
||||
int interface_version;
|
||||
};
|
||||
|
||||
/*
|
||||
API for Replication plugin. (MYSQL_REPLICATION_PLUGIN)
|
||||
*/
|
||||
#define MYSQL_REPLICATION_INTERFACE_VERSION 0x0100
|
||||
|
||||
/**
|
||||
Replication plugin descriptor
|
||||
*/
|
||||
struct Mysql_replication {
|
||||
int interface_version;
|
||||
};
|
||||
|
||||
/*
|
||||
st_mysql_value struct for reading values from mysqld.
|
||||
@ -733,54 +737,6 @@ int thd_killed(const MYSQL_THD thd);
|
||||
*/
|
||||
unsigned long thd_get_thread_id(const MYSQL_THD thd);
|
||||
|
||||
|
||||
/**
|
||||
Allocate memory in the connection's local memory pool
|
||||
|
||||
@details
|
||||
When properly used in place of @c my_malloc(), this can significantly
|
||||
improve concurrency. Don't use this or related functions to allocate
|
||||
large chunks of memory. Use for temporary storage only. The memory
|
||||
will be freed automatically at the end of the statement; no explicit
|
||||
code is required to prevent memory leaks.
|
||||
|
||||
@see alloc_root()
|
||||
*/
|
||||
void *thd_alloc(MYSQL_THD thd, unsigned int size);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
void *thd_calloc(MYSQL_THD thd, unsigned int size);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
char *thd_strdup(MYSQL_THD thd, const char *str);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
|
||||
|
||||
/**
|
||||
Create a LEX_STRING in this connection's local memory pool
|
||||
|
||||
@param thd user thread connection handle
|
||||
@param lex_str pointer to LEX_STRING object to be initialized
|
||||
@param str initializer to be copied into lex_str
|
||||
@param size length of str, in bytes
|
||||
@param allocate_lex_string flag: if TRUE, allocate new LEX_STRING object,
|
||||
instead of using lex_str value
|
||||
@return NULL on failure, or pointer to the LEX_STRING object
|
||||
|
||||
@see thd_alloc()
|
||||
*/
|
||||
MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
|
||||
const char *str, unsigned int size,
|
||||
int allocate_lex_string);
|
||||
|
||||
/**
|
||||
Get the XID for this connection's transaction
|
||||
|
||||
|
@ -1,9 +1,38 @@
|
||||
#include <mysql/services.h>
|
||||
#include <mysql/service_my_snprintf.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
extern struct my_snprintf_service_st {
|
||||
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
|
||||
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
|
||||
} *my_snprintf_service;
|
||||
size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
|
||||
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
|
||||
#include <mysql/service_thd_alloc.h>
|
||||
#include <stdlib.h>
|
||||
struct st_mysql_lex_string
|
||||
{
|
||||
char *str;
|
||||
unsigned int length;
|
||||
size_t length;
|
||||
};
|
||||
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
|
||||
extern struct thd_alloc_service_st {
|
||||
void *(*thd_alloc_func)(void*, unsigned int);
|
||||
void *(*thd_calloc_func)(void*, unsigned int);
|
||||
char *(*thd_strdup_func)(void*, const char *);
|
||||
char *(*thd_strmake_func)(void*, const char *, unsigned int);
|
||||
void *(*thd_memdup_func)(void*, const void*, unsigned int);
|
||||
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
|
||||
const char *, unsigned int, int);
|
||||
} *thd_alloc_service;
|
||||
void *thd_alloc(void* thd, unsigned int size);
|
||||
void *thd_calloc(void* thd, unsigned int size);
|
||||
char *thd_strdup(void* thd, const char *str);
|
||||
char *thd_strmake(void* thd, const char *str, unsigned int size);
|
||||
void *thd_memdup(void* thd, const void* str, unsigned int size);
|
||||
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
|
||||
const char *str, unsigned int size,
|
||||
int allocate_lex_string);
|
||||
struct st_mysql_xid {
|
||||
long formatID;
|
||||
long gtrid_length;
|
||||
@ -15,7 +44,8 @@ enum enum_mysql_show_type
|
||||
{
|
||||
SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
|
||||
SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
|
||||
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
|
||||
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
|
||||
SHOW_always_last
|
||||
};
|
||||
struct st_mysql_show_var {
|
||||
const char *name;
|
||||
@ -105,6 +135,9 @@ struct st_mysql_information_schema
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct Mysql_replication {
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_value
|
||||
{
|
||||
int (*value_type)(struct st_mysql_value *);
|
||||
@ -125,14 +158,6 @@ void thd_inc_row_count(void* thd);
|
||||
int mysql_tmpfile(const char *prefix);
|
||||
int thd_killed(const void* thd);
|
||||
unsigned long thd_get_thread_id(const void* thd);
|
||||
void *thd_alloc(void* thd, unsigned int size);
|
||||
void *thd_calloc(void* thd, unsigned int size);
|
||||
char *thd_strdup(void* thd, const char *str);
|
||||
char *thd_strmake(void* thd, const char *str, unsigned int size);
|
||||
void *thd_memdup(void* thd, const void* str, unsigned int size);
|
||||
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
|
||||
const char *str, unsigned int size,
|
||||
int allocate_lex_string);
|
||||
void thd_get_xid(const void* thd, MYSQL_XID *xid);
|
||||
void mysql_query_cache_invalidate4(void* thd,
|
||||
const char *key, unsigned int key_length,
|
||||
|
98
include/mysql/service_my_snprintf.h
Normal file
98
include/mysql/service_my_snprintf.h
Normal file
@ -0,0 +1,98 @@
|
||||
#ifndef MYSQL_SERVICE_MY_SNPRINTF_INCLUDED
|
||||
/* Copyright (C) 2009 Sun Microsystems, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/**
|
||||
@file
|
||||
my_snprintf service
|
||||
|
||||
Portable and limited vsnprintf() implementation.
|
||||
|
||||
This is a portable, limited vsnprintf() implementation, with some
|
||||
extra features. "Portable" means that it'll produce identical result
|
||||
on all platforms (for example, on Windows and Linux system printf %e
|
||||
formats the exponent differently, on different systems %p either
|
||||
prints leading 0x or not, %s may accept null pointer or crash on
|
||||
it). "Limited" means that it does not support all the C89 features.
|
||||
But it supports few extensions, not in any standard.
|
||||
|
||||
my_vsnprintf(to, n, fmt, ap)
|
||||
|
||||
@param[out] to A buffer to store the result in
|
||||
@param[in] n Store up to n-1 characters, followed by an end 0
|
||||
@param[in] fmt printf-like format string
|
||||
@param[in] ap Arguments
|
||||
|
||||
@return a number of bytes written to a buffer *excluding* terminating '\0'
|
||||
|
||||
@post
|
||||
The syntax of a format string is generally the same:
|
||||
% <flag> <width> <precision> <length modifier> <format>
|
||||
where everithing but the format is optional.
|
||||
|
||||
Three one-character flags are recognized:
|
||||
'0' has the standard zero-padding semantics;
|
||||
'-' is parsed, but silently ignored;
|
||||
'`' (backtick) is only supported for strings (%s) and means that the
|
||||
string will be quoted according to MySQL identifier quoting rules.
|
||||
|
||||
Both <width> and <precision> can be specified as numbers or '*'.
|
||||
|
||||
<length modifier> can be 'l', 'll', or 'z'.
|
||||
|
||||
Supported formats are 's' (null pointer is accepted, printed as
|
||||
"(null)"), 'b' (extension, see below), 'c', 'd', 'u', 'x',
|
||||
'X', 'p' (works as 0x%x).
|
||||
|
||||
Standard syntax for positional arguments $n is supported.
|
||||
|
||||
Extensions:
|
||||
|
||||
Flag '`' (backtick): see above.
|
||||
|
||||
Format 'b': binary buffer, prints exactly <precision> bytes from the
|
||||
argument, without stopping at '\0'.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
extern struct my_snprintf_service_st {
|
||||
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
|
||||
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
|
||||
} *my_snprintf_service;
|
||||
|
||||
#ifdef MYSQL_DYNAMIC_PLUGIN
|
||||
|
||||
#define my_vsnprintf my_snprintf_service->my_vsnprintf_type
|
||||
#define my_snprintf my_snprintf_service->my_snprintf_type
|
||||
|
||||
#else
|
||||
|
||||
size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
|
||||
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED
|
||||
#endif
|
||||
|
128
include/mysql/service_thd_alloc.h
Normal file
128
include/mysql/service_thd_alloc.h
Normal file
@ -0,0 +1,128 @@
|
||||
#ifndef MYSQL_SERVICE_THD_ALLOC_INCLUDED
|
||||
/* Copyright (C) 2009 Sun Microsystems, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/**
|
||||
@file
|
||||
This service provdes functions to allocate memory in a connection local
|
||||
memory pool. The memory allocated there will be automatically freed at the
|
||||
end of the statement, don't use it for allocations that should live longer
|
||||
than that. For short living allocations this is more efficient than
|
||||
using my_malloc and friends, and automatic "garbage collection" allows not
|
||||
to think about memory leaks.
|
||||
|
||||
The pool is best for small to medium objects, don't use it for large
|
||||
allocations - they are better served with my_malloc.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct st_mysql_lex_string
|
||||
{
|
||||
char *str;
|
||||
size_t length;
|
||||
};
|
||||
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
|
||||
|
||||
extern struct thd_alloc_service_st {
|
||||
void *(*thd_alloc_func)(MYSQL_THD, unsigned int);
|
||||
void *(*thd_calloc_func)(MYSQL_THD, unsigned int);
|
||||
char *(*thd_strdup_func)(MYSQL_THD, const char *);
|
||||
char *(*thd_strmake_func)(MYSQL_THD, const char *, unsigned int);
|
||||
void *(*thd_memdup_func)(MYSQL_THD, const void*, unsigned int);
|
||||
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(MYSQL_THD, MYSQL_LEX_STRING *,
|
||||
const char *, unsigned int, int);
|
||||
} *thd_alloc_service;
|
||||
|
||||
#ifdef MYSQL_DYNAMIC_PLUGIN
|
||||
|
||||
#define thd_alloc(thd,size) (thd_alloc_service->thd_alloc_func((thd), (size)))
|
||||
|
||||
#define thd_calloc(thd,size) (thd_alloc_service->thd_calloc_func((thd), (size)))
|
||||
|
||||
#define thd_strdup(thd,str) (thd_alloc_service->thd_strdup_func((thd), (str)))
|
||||
|
||||
#define thd_strmake(thd,str,size) \
|
||||
(thd_alloc_service->thd_strmake_func((thd), (str), (size)))
|
||||
|
||||
#define thd_memdup(thd,str,size) \
|
||||
(thd_alloc_service->thd_memdup_func((thd), (str), (size)))
|
||||
|
||||
#define thd_make_lex_string(thd, lex_str, str, size, allocate_lex_string) \
|
||||
(thd_alloc_service->thd_make_lex_string_func((thd), (lex_str), (str), \
|
||||
(size), (allocate_lex_string)))
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
Allocate memory in the connection's local memory pool
|
||||
|
||||
@details
|
||||
When properly used in place of @c my_malloc(), this can significantly
|
||||
improve concurrency. Don't use this or related functions to allocate
|
||||
large chunks of memory. Use for temporary storage only. The memory
|
||||
will be freed automatically at the end of the statement; no explicit
|
||||
code is required to prevent memory leaks.
|
||||
|
||||
@see alloc_root()
|
||||
*/
|
||||
void *thd_alloc(MYSQL_THD thd, unsigned int size);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
void *thd_calloc(MYSQL_THD thd, unsigned int size);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
char *thd_strdup(MYSQL_THD thd, const char *str);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
|
||||
|
||||
/**
|
||||
Create a LEX_STRING in this connection's local memory pool
|
||||
|
||||
@param thd user thread connection handle
|
||||
@param lex_str pointer to LEX_STRING object to be initialized
|
||||
@param str initializer to be copied into lex_str
|
||||
@param size length of str, in bytes
|
||||
@param allocate_lex_string flag: if TRUE, allocate new LEX_STRING object,
|
||||
instead of using lex_str value
|
||||
@return NULL on failure, or pointer to the LEX_STRING object
|
||||
|
||||
@see thd_alloc()
|
||||
*/
|
||||
MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
|
||||
const char *str, unsigned int size,
|
||||
int allocate_lex_string);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MYSQL_SERVICE_THD_ALLOC_INCLUDED
|
||||
#endif
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 2004 MySQL AB
|
||||
#ifndef MYSQL_SERVICES_INCLUDED
|
||||
/* Copyright (C) 2009 Sun Microsystems, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -13,18 +14,17 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#if defined(__GNUC__) && defined(USE_PRAGMA_IMPLEMENTATION)
|
||||
#pragma implementation
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "manager.h"
|
||||
#include "command.h"
|
||||
#include <mysql/service_my_snprintf.h>
|
||||
#include <mysql/service_thd_alloc.h>
|
||||
|
||||
Command::Command()
|
||||
:guardian(Manager::get_guardian()),
|
||||
instance_map(Manager::get_instance_map())
|
||||
{}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Command::~Command()
|
||||
{}
|
||||
#define MYSQL_SERVICES_INCLUDED
|
||||
#endif
|
||||
|
@ -27,6 +27,8 @@
|
||||
#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
|
||||
#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
|
||||
|
||||
#define MYSQL_AUTODETECT_CHARSET_NAME "auto"
|
||||
|
||||
#define SERVER_VERSION_LENGTH 60
|
||||
#define SQLSTATE_LENGTH 5
|
||||
|
||||
@ -144,6 +146,7 @@ enum enum_server_command
|
||||
#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
|
||||
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
|
||||
#define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
|
||||
#define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */
|
||||
|
||||
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
|
||||
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
|
||||
@ -167,6 +170,7 @@ enum enum_server_command
|
||||
CLIENT_SECURE_CONNECTION | \
|
||||
CLIENT_MULTI_STATEMENTS | \
|
||||
CLIENT_MULTI_RESULTS | \
|
||||
CLIENT_PS_MULTI_RESULTS | \
|
||||
CLIENT_SSL_VERIFY_SERVER_CERT | \
|
||||
CLIENT_REMEMBER_OPTIONS)
|
||||
|
||||
@ -203,6 +207,12 @@ enum enum_server_command
|
||||
number of result set columns.
|
||||
*/
|
||||
#define SERVER_STATUS_METADATA_CHANGED 1024
|
||||
#define SERVER_QUERY_WAS_SLOW 2048
|
||||
|
||||
/**
|
||||
To mark ResultSet containing output parameter values.
|
||||
*/
|
||||
#define SERVER_PS_OUT_PARAMS 4096
|
||||
|
||||
/**
|
||||
Server status flags that must be cleared when starting
|
||||
@ -254,24 +264,23 @@ typedef struct st_net {
|
||||
unsigned int *return_status;
|
||||
unsigned char reading_or_writing;
|
||||
char save_char;
|
||||
my_bool unused0; /* Please remove with the next incompatible ABI change. */
|
||||
my_bool unused; /* Please remove with the next incompatible ABI change */
|
||||
my_bool compress;
|
||||
my_bool unused1; /* Please remove with the next incompatible ABI change. */
|
||||
my_bool unused2; /* Please remove with the next incompatible ABI change */
|
||||
my_bool compress;
|
||||
my_bool unused3; /* Please remove with the next incompatible ABI change. */
|
||||
/*
|
||||
Pointer to query object in query cache, do not equal NULL (0) for
|
||||
queries in cache that have not stored its results yet
|
||||
*/
|
||||
#endif
|
||||
/*
|
||||
'query_cache_query' should be accessed only via query cache
|
||||
functions and methods to maintain proper locking.
|
||||
Unused, please remove with the next incompatible ABI change.
|
||||
*/
|
||||
unsigned char *query_cache_query;
|
||||
unsigned char *unused;
|
||||
unsigned int last_errno;
|
||||
unsigned char error;
|
||||
my_bool unused2; /* Please remove with the next incompatible ABI change. */
|
||||
my_bool return_errno;
|
||||
my_bool unused4; /* Please remove with the next incompatible ABI change. */
|
||||
my_bool unused5; /* Please remove with the next incompatible ABI change. */
|
||||
/** Client library error message buffer. Actually belongs to struct MYSQL. */
|
||||
char last_error[MYSQL_ERRMSG_SIZE];
|
||||
/** Client library sqlstate buffer. Set along with the error message. */
|
||||
@ -409,10 +418,6 @@ void my_net_set_write_timeout(NET *net, uint timeout);
|
||||
void my_net_set_read_timeout(NET *net, uint timeout);
|
||||
#endif
|
||||
|
||||
/*
|
||||
The following function is not meant for normal usage
|
||||
Currently it's used internally by manager.c
|
||||
*/
|
||||
struct sockaddr;
|
||||
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
|
||||
unsigned int timeout);
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef MYSQL_EMBED_INCLUDED
|
||||
#define MYSQL_EMBED_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -28,3 +31,4 @@
|
||||
#define DONT_USE_RAID
|
||||
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
#endif /* MYSQL_EMBED_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef RIJNDAEL_INCLUDED
|
||||
#define RIJNDAEL_INCLUDED
|
||||
|
||||
/* Copyright (C) 2002 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -39,3 +42,5 @@ void rijndaelEncrypt(const uint32 rk[/*4*(Nr + 1)*/], int Nr,
|
||||
const uint8 pt[16], uint8 ct[16]);
|
||||
void rijndaelDecrypt(const uint32 rk[/*4*(Nr + 1)*/], int Nr,
|
||||
const uint8 ct[16], uint8 pt[16]);
|
||||
|
||||
#endif /* RIJNDAEL_INCLUDED */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2004-2006 MySQL AB
|
||||
/* Copyright (C) 2009 Sun Microsystems, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -13,11 +13,12 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_MESSAGES_H
|
||||
#define INCLUDES_MYSQL_INSTANCE_MANAGER_MESSAGES_H
|
||||
#ifdef _WIN32
|
||||
#define SERVICE_VERSION __declspec(dllexport) void *
|
||||
#else
|
||||
#define SERVICE_VERSION void *
|
||||
#endif
|
||||
|
||||
const char *message(unsigned sql_errno);
|
||||
#define VERSION_my_snprintf 0x0100
|
||||
#define VERSION_thd_alloc 0x0100
|
||||
|
||||
const char *errno_to_sqlstate(unsigned sql_errno);
|
||||
|
||||
#endif // INCLUDES_MYSQL_INSTANCE_MANAGER_MESSAGES_H
|
@ -1,3 +1,6 @@
|
||||
#ifndef SHA1_INCLUDED
|
||||
#define SHA1_INCLUDED
|
||||
|
||||
/* Copyright (C) 2002, 2006 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -64,3 +67,5 @@ int mysql_sha1_input(SHA1_CONTEXT*, const uint8 *, unsigned int);
|
||||
int mysql_sha1_result(SHA1_CONTEXT* , uint8 Message_Digest[SHA1_HASH_SIZE]);
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* SHA__INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef SQL_COMMON_INCLUDED
|
||||
#define SQL_COMMON_INCLUDED
|
||||
|
||||
/* Copyright (C) 2003-2004, 2006 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -48,3 +51,4 @@ void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
|
||||
|
||||
#define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41)
|
||||
|
||||
#endif /* SQL_COMMON_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef SSLOPT_CASE_INCLUDED
|
||||
#define SSLOPT_CASE_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -26,3 +29,4 @@
|
||||
opt_use_ssl= 1;
|
||||
break;
|
||||
#endif
|
||||
#endif /* SSLOPT_CASE_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef SSLOPT_LONGOPTS_INCLUDED
|
||||
#define SSLOPT_LONGOPTS_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -43,3 +46,4 @@
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
#endif /* HAVE_OPENSSL */
|
||||
#endif /* SSLOPT_LONGOPTS_INCLUDED */
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef SSLOPT_VARS_INCLUDED
|
||||
#define SSLOPT_VARS_INCLUDED
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -29,3 +32,4 @@ SSL_STATIC char *opt_ssl_key = 0;
|
||||
SSL_STATIC my_bool opt_ssl_verify_server_cert= 0;
|
||||
#endif
|
||||
#endif
|
||||
#endif /* SSLOPT_VARS_INCLUDED */
|
||||
|
@ -44,7 +44,7 @@ enum enum_vio_type
|
||||
Vio* vio_new(my_socket sd, enum enum_vio_type type, uint flags);
|
||||
#ifdef __WIN__
|
||||
Vio* vio_new_win32pipe(HANDLE hPipe);
|
||||
Vio* vio_new_win32shared_memory(NET *net,HANDLE handle_file_map,
|
||||
Vio* vio_new_win32shared_memory(HANDLE handle_file_map,
|
||||
HANDLE handle_map,
|
||||
HANDLE event_server_wrote,
|
||||
HANDLE event_server_read,
|
||||
@ -221,7 +221,11 @@ struct st_vio
|
||||
HANDLE event_conn_closed;
|
||||
size_t shared_memory_remain;
|
||||
char *shared_memory_pos;
|
||||
NET *net;
|
||||
#endif /* HAVE_SMEM */
|
||||
#ifdef _WIN32
|
||||
OVERLAPPED pipe_overlapped;
|
||||
DWORD read_timeout_millis;
|
||||
DWORD write_timeout_millis;
|
||||
#endif
|
||||
};
|
||||
#endif /* vio_violite_h_ */
|
||||
|
@ -14,8 +14,6 @@
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
|
||||
# Note that we don't link with the libraries "strings" or "mysys"
|
||||
# here, instead we recompile the files needed and include them
|
||||
@ -75,7 +73,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
|
||||
../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c
|
||||
get_password.c ../strings/int2str.c ../strings/is_prefix.c
|
||||
libmysql.c ../mysys/list.c ../strings/llstr.c
|
||||
../strings/longlong2str.c manager.c ../mysys/mf_arr_appstr.c ../mysys/mf_cache.c
|
||||
../strings/longlong2str.c ../mysys/mf_arr_appstr.c ../mysys/mf_cache.c
|
||||
../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c
|
||||
../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c
|
||||
../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c
|
||||
@ -98,33 +96,17 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
|
||||
../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c
|
||||
../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
|
||||
../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c ../mysys/mf_qsort.c
|
||||
../mysys/my_getsystime.c ../mysys/my_sync.c ${LIB_SOURCES})
|
||||
../mysys/my_getsystime.c ../mysys/my_sync.c ../mysys/my_winerr.c ../mysys/my_winfile.c ${LIB_SOURCES})
|
||||
|
||||
|
||||
# Need to set USE_TLS for building the DLL, since __declspec(thread)
|
||||
# approach to thread local storage does not work properly in DLLs.
|
||||
#
|
||||
# The static library might be used to form another DLL, as is the case
|
||||
# with the ODBC driver, so it has to be compiled with USE_TLS as well.
|
||||
#
|
||||
# We create a third library without USE_TLS for internal use. We can't
|
||||
# be sure that some client application part of this build doesn't go
|
||||
# beond the documented API, and try access the Thread Local Storage.
|
||||
# The "_notls" means no Tls*() functions used, i.e. "static" TLS.
|
||||
|
||||
ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES})
|
||||
ADD_DEPENDENCIES(mysqlclient GenError)
|
||||
TARGET_LINK_LIBRARIES(mysqlclient)
|
||||
|
||||
ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES})
|
||||
ADD_DEPENDENCIES(mysqlclient_notls GenError)
|
||||
TARGET_LINK_LIBRARIES(mysqlclient_notls)
|
||||
|
||||
ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} dll.c libmysql.def)
|
||||
IF(WIN32)
|
||||
SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS")
|
||||
ENDIF(WIN32)
|
||||
ADD_DEPENDENCIES(libmysql GenError)
|
||||
TARGET_LINK_LIBRARIES(libmysql wsock32)
|
||||
TARGET_LINK_LIBRARIES(libmysql)
|
||||
|
||||
IF(EMBED_MANIFESTS)
|
||||
MYSQL_EMBED_MANIFEST("myTest" "asInvoker")
|
||||
|
@ -31,7 +31,7 @@ pkglib_LTLIBRARIES = $(target)
|
||||
noinst_PROGRAMS = conf_to_src
|
||||
|
||||
|
||||
target_sources = libmysql.c password.c manager.c \
|
||||
target_sources = libmysql.c password.c \
|
||||
get_password.c errmsg.c
|
||||
|
||||
mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
|
||||
|
@ -13,12 +13,22 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifndef CLIENT_SETTINGS_INCLUDED
|
||||
#define CLIENT_SETTINGS_INCLUDED
|
||||
#else
|
||||
#error You have already included an client_settings.h and it should not be included twice
|
||||
#endif /* CLIENT_SETTINGS_INCLUDED */
|
||||
|
||||
extern uint mysql_port;
|
||||
extern char * mysql_unix_port;
|
||||
|
||||
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | \
|
||||
CLIENT_TRANSACTIONS | \
|
||||
CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
|
||||
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | \
|
||||
CLIENT_LONG_FLAG | \
|
||||
CLIENT_TRANSACTIONS | \
|
||||
CLIENT_PROTOCOL_41 | \
|
||||
CLIENT_SECURE_CONNECTION | \
|
||||
CLIENT_MULTI_RESULTS | \
|
||||
CLIENT_PS_MULTI_RESULTS)
|
||||
|
||||
sig_handler my_pipe_sig_handler(int sig);
|
||||
void read_user_name(char *name);
|
||||
|
@ -85,6 +85,7 @@ const char *client_errors[]=
|
||||
"Lost connection to MySQL server at '%s', system error: %d",
|
||||
"Statement closed indirectly because of a preceeding %s() call",
|
||||
"The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
|
||||
"This handle is already connected. Use a separate handle for each connection."
|
||||
""
|
||||
};
|
||||
|
||||
@ -151,6 +152,7 @@ const char *client_errors[]=
|
||||
"Lost connection to MySQL server at '%s', system error: %d",
|
||||
"Statement closed indirectly because of a preceeding %s() call",
|
||||
"The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
|
||||
"This handle is already connected. Use a separate handle for each connection."
|
||||
""
|
||||
};
|
||||
|
||||
@ -215,10 +217,15 @@ const char *client_errors[]=
|
||||
"Lost connection to MySQL server at '%s', system error: %d",
|
||||
"Statement closed indirectly because of a preceeding %s() call",
|
||||
"The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
|
||||
"This handle is already connected. Use a separate handle for each connection."
|
||||
""
|
||||
};
|
||||
#endif
|
||||
|
||||
const char** get_client_errmsgs()
|
||||
{
|
||||
return client_errors;
|
||||
}
|
||||
|
||||
/*
|
||||
Register client error messages for use with my_error().
|
||||
@ -232,7 +239,7 @@ const char *client_errors[]=
|
||||
|
||||
void init_client_errs(void)
|
||||
{
|
||||
(void) my_error_register(client_errors, CR_ERROR_FIRST, CR_ERROR_LAST);
|
||||
(void) my_error_register(get_client_errmsgs, CR_ERROR_FIRST, CR_ERROR_LAST);
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,7 +131,7 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)),
|
||||
mysql_port = MYSQL_PORT;
|
||||
#ifndef MSDOS
|
||||
{
|
||||
struct servent *serv_ptr;
|
||||
struct servent *serv_ptr __attribute__((unused));
|
||||
char *env;
|
||||
|
||||
/*
|
||||
@ -249,16 +249,6 @@ void STDCALL mysql_thread_end()
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Let the user specify that we don't want SIGPIPE; This doesn't however work
|
||||
with threaded applications as we can have multiple read in progress.
|
||||
*/
|
||||
static MYSQL* spawn_init(MYSQL* parent, const char* host,
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Expand wildcard to a sql string
|
||||
@ -320,7 +310,7 @@ mysql_debug(const char *debug __attribute__((unused)))
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
Close the server connection if we get a SIGPIPE
|
||||
Ignore SIGPIPE handler
|
||||
ARGSUSED
|
||||
**************************************************************************/
|
||||
|
||||
@ -333,305 +323,6 @@ my_pipe_sig_handler(int sig __attribute__((unused)))
|
||||
#endif
|
||||
}
|
||||
|
||||
/* perform query on master */
|
||||
my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length)
|
||||
{
|
||||
DBUG_ENTER("mysql_master_query");
|
||||
if (mysql_master_send_query(mysql, q, length))
|
||||
DBUG_RETURN(1);
|
||||
DBUG_RETURN((*mysql->methods->read_query_result)(mysql));
|
||||
}
|
||||
|
||||
my_bool STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length)
|
||||
{
|
||||
MYSQL *master = mysql->master;
|
||||
DBUG_ENTER("mysql_master_send_query");
|
||||
if (!master->net.vio && !mysql_real_connect(master,0,0,0,0,0,0,0))
|
||||
DBUG_RETURN(1);
|
||||
master->reconnect= 1;
|
||||
mysql->last_used_con = master;
|
||||
DBUG_RETURN(simple_command(master, COM_QUERY, (const uchar*) q, length, 1));
|
||||
}
|
||||
|
||||
|
||||
/* perform query on slave */
|
||||
my_bool STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length)
|
||||
{
|
||||
DBUG_ENTER("mysql_slave_query");
|
||||
if (mysql_slave_send_query(mysql, q, length))
|
||||
DBUG_RETURN(1);
|
||||
DBUG_RETURN((*mysql->methods->read_query_result)(mysql));
|
||||
}
|
||||
|
||||
|
||||
my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length)
|
||||
{
|
||||
MYSQL* last_used_slave, *slave_to_use = 0;
|
||||
DBUG_ENTER("mysql_slave_send_query");
|
||||
|
||||
if ((last_used_slave = mysql->last_used_slave))
|
||||
slave_to_use = last_used_slave->next_slave;
|
||||
else
|
||||
slave_to_use = mysql->next_slave;
|
||||
/*
|
||||
Next_slave is always safe to use - we have a circular list of slaves
|
||||
if there are no slaves, mysql->next_slave == mysql
|
||||
*/
|
||||
mysql->last_used_con = mysql->last_used_slave = slave_to_use;
|
||||
if (!slave_to_use->net.vio && !mysql_real_connect(slave_to_use, 0,0,0,
|
||||
0,0,0,0))
|
||||
DBUG_RETURN(1);
|
||||
slave_to_use->reconnect= 1;
|
||||
DBUG_RETURN(simple_command(slave_to_use, COM_QUERY, (const uchar*) q,
|
||||
length, 1));
|
||||
}
|
||||
|
||||
|
||||
/* enable/disable parsing of all queries to decide
|
||||
if they go on master or slave */
|
||||
void STDCALL mysql_enable_rpl_parse(MYSQL* mysql)
|
||||
{
|
||||
mysql->options.rpl_parse = 1;
|
||||
}
|
||||
|
||||
void STDCALL mysql_disable_rpl_parse(MYSQL* mysql)
|
||||
{
|
||||
mysql->options.rpl_parse = 0;
|
||||
}
|
||||
|
||||
/* get the value of the parse flag */
|
||||
int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql)
|
||||
{
|
||||
return mysql->options.rpl_parse;
|
||||
}
|
||||
|
||||
/* enable/disable reads from master */
|
||||
void STDCALL mysql_enable_reads_from_master(MYSQL* mysql)
|
||||
{
|
||||
mysql->options.no_master_reads = 0;
|
||||
}
|
||||
|
||||
void STDCALL mysql_disable_reads_from_master(MYSQL* mysql)
|
||||
{
|
||||
mysql->options.no_master_reads = 1;
|
||||
}
|
||||
|
||||
/* get the value of the master read flag */
|
||||
my_bool STDCALL mysql_reads_from_master_enabled(MYSQL* mysql)
|
||||
{
|
||||
return !(mysql->options.no_master_reads);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
We may get an error while doing replication internals.
|
||||
In this case, we add a special explanation to the original
|
||||
error
|
||||
*/
|
||||
|
||||
static void expand_error(MYSQL* mysql, int error)
|
||||
{
|
||||
char tmp[MYSQL_ERRMSG_SIZE];
|
||||
char *p;
|
||||
uint err_length;
|
||||
strmake(tmp, mysql->net.last_error, MYSQL_ERRMSG_SIZE-1);
|
||||
p = strmake(mysql->net.last_error, ER(error), MYSQL_ERRMSG_SIZE-1);
|
||||
err_length= (uint) (p - mysql->net.last_error);
|
||||
strmake(p, tmp, MYSQL_ERRMSG_SIZE-1 - err_length);
|
||||
mysql->net.last_errno = error;
|
||||
}
|
||||
|
||||
/*
|
||||
This function assumes we have just called SHOW SLAVE STATUS and have
|
||||
read the given result and row
|
||||
*/
|
||||
|
||||
static my_bool get_master(MYSQL* mysql, MYSQL_RES* res, MYSQL_ROW row)
|
||||
{
|
||||
MYSQL* master;
|
||||
DBUG_ENTER("get_master");
|
||||
if (mysql_num_fields(res) < 3)
|
||||
DBUG_RETURN(1); /* safety */
|
||||
|
||||
/* use the same username and password as the original connection */
|
||||
if (!(master = spawn_init(mysql, row[0], atoi(row[2]), 0, 0)))
|
||||
DBUG_RETURN(1);
|
||||
mysql->master = master;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Assuming we already know that mysql points to a master connection,
|
||||
retrieve all the slaves
|
||||
*/
|
||||
|
||||
static my_bool get_slaves_from_master(MYSQL* mysql)
|
||||
{
|
||||
MYSQL_RES* res = 0;
|
||||
MYSQL_ROW row;
|
||||
my_bool error = 1;
|
||||
int has_auth_info;
|
||||
int port_ind;
|
||||
DBUG_ENTER("get_slaves_from_master");
|
||||
|
||||
if (!mysql->net.vio && !mysql_real_connect(mysql,0,0,0,0,0,0,0))
|
||||
{
|
||||
expand_error(mysql, CR_PROBE_MASTER_CONNECT);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
mysql->reconnect= 1;
|
||||
|
||||
if (mysql_query(mysql, "SHOW SLAVE HOSTS") ||
|
||||
!(res = mysql_store_result(mysql)))
|
||||
{
|
||||
expand_error(mysql, CR_PROBE_SLAVE_HOSTS);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
switch (mysql_num_fields(res)) {
|
||||
case 5:
|
||||
has_auth_info = 0;
|
||||
port_ind=2;
|
||||
break;
|
||||
case 7:
|
||||
has_auth_info = 1;
|
||||
port_ind=4;
|
||||
break;
|
||||
default:
|
||||
goto err;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(res)))
|
||||
{
|
||||
MYSQL* slave;
|
||||
const char* tmp_user, *tmp_pass;
|
||||
|
||||
if (has_auth_info)
|
||||
{
|
||||
tmp_user = row[2];
|
||||
tmp_pass = row[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_user = mysql->user;
|
||||
tmp_pass = mysql->passwd;
|
||||
}
|
||||
|
||||
if (!(slave = spawn_init(mysql, row[1], atoi(row[port_ind]),
|
||||
tmp_user, tmp_pass)))
|
||||
goto err;
|
||||
|
||||
/* Now add slave into the circular linked list */
|
||||
slave->next_slave = mysql->next_slave;
|
||||
mysql->next_slave = slave;
|
||||
}
|
||||
error = 0;
|
||||
err:
|
||||
if (res)
|
||||
mysql_free_result(res);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
||||
my_bool STDCALL mysql_rpl_probe(MYSQL* mysql)
|
||||
{
|
||||
MYSQL_RES *res= 0;
|
||||
MYSQL_ROW row;
|
||||
my_bool error= 1;
|
||||
DBUG_ENTER("mysql_rpl_probe");
|
||||
|
||||
/*
|
||||
First determine the replication role of the server we connected to
|
||||
the most reliable way to do this is to run SHOW SLAVE STATUS and see
|
||||
if we have a non-empty master host. This is still not fool-proof -
|
||||
it is not a sin to have a master that has a dormant slave thread with
|
||||
a non-empty master host. However, it is more reliable to check
|
||||
for empty master than whether the slave thread is actually running
|
||||
*/
|
||||
if (mysql_query(mysql, "SHOW SLAVE STATUS") ||
|
||||
!(res = mysql_store_result(mysql)))
|
||||
{
|
||||
expand_error(mysql, CR_PROBE_SLAVE_STATUS);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
row= mysql_fetch_row(res);
|
||||
/*
|
||||
Check master host for emptiness/NULL
|
||||
For MySQL 4.0 it's enough to check for row[0]
|
||||
*/
|
||||
if (row && row[0] && *(row[0]))
|
||||
{
|
||||
/* this is a slave, ask it for the master */
|
||||
if (get_master(mysql, res, row) || get_slaves_from_master(mysql))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql->master = mysql;
|
||||
if (get_slaves_from_master(mysql))
|
||||
goto err;
|
||||
}
|
||||
|
||||
error = 0;
|
||||
err:
|
||||
if (res)
|
||||
mysql_free_result(res);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Make a not so fool-proof decision on where the query should go, to
|
||||
the master or the slave. Ideally the user should always make this
|
||||
decision himself with mysql_master_query() or mysql_slave_query().
|
||||
However, to be able to more easily port the old code, we support the
|
||||
option of an educated guess - this should work for most applications,
|
||||
however, it may make the wrong decision in some particular cases. If
|
||||
that happens, the user would have to change the code to call
|
||||
mysql_master_query() or mysql_slave_query() explicitly in the place
|
||||
where we have made the wrong decision
|
||||
*/
|
||||
|
||||
enum mysql_rpl_type
|
||||
STDCALL mysql_rpl_query_type(const char* q, int len)
|
||||
{
|
||||
const char *q_end= q + len;
|
||||
for (; q < q_end; ++q)
|
||||
{
|
||||
char c;
|
||||
if (my_isalpha(&my_charset_latin1, (c= *q)))
|
||||
{
|
||||
switch (my_tolower(&my_charset_latin1,c)) {
|
||||
case 'i': /* insert */
|
||||
case 'u': /* update or unlock tables */
|
||||
case 'l': /* lock tables or load data infile */
|
||||
case 'd': /* drop or delete */
|
||||
case 'a': /* alter */
|
||||
return MYSQL_RPL_MASTER;
|
||||
case 'c': /* create or check */
|
||||
return my_tolower(&my_charset_latin1,q[1]) == 'h' ? MYSQL_RPL_ADMIN :
|
||||
MYSQL_RPL_MASTER;
|
||||
case 's': /* select or show */
|
||||
return my_tolower(&my_charset_latin1,q[1]) == 'h' ? MYSQL_RPL_ADMIN :
|
||||
MYSQL_RPL_SLAVE;
|
||||
case 'f': /* flush */
|
||||
case 'r': /* repair */
|
||||
case 'g': /* grant */
|
||||
return MYSQL_RPL_ADMIN;
|
||||
default:
|
||||
return MYSQL_RPL_SLAVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return MYSQL_RPL_MASTER; /* By default, send to master */
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
Connect to sql server
|
||||
@ -1093,68 +784,6 @@ mysql_query(MYSQL *mysql, const char *query)
|
||||
}
|
||||
|
||||
|
||||
static MYSQL* spawn_init(MYSQL* parent, const char* host,
|
||||
unsigned int port, const char* user,
|
||||
const char* passwd)
|
||||
{
|
||||
MYSQL* child;
|
||||
DBUG_ENTER("spawn_init");
|
||||
if (!(child= mysql_init(0)))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
child->options.user= my_strdup((user) ? user :
|
||||
(parent->user ? parent->user :
|
||||
parent->options.user), MYF(0));
|
||||
child->options.password= my_strdup((passwd) ? passwd :
|
||||
(parent->passwd ?
|
||||
parent->passwd :
|
||||
parent->options.password), MYF(0));
|
||||
child->options.port= port;
|
||||
child->options.host= my_strdup((host) ? host :
|
||||
(parent->host ?
|
||||
parent->host :
|
||||
parent->options.host), MYF(0));
|
||||
if (parent->db)
|
||||
child->options.db= my_strdup(parent->db, MYF(0));
|
||||
else if (parent->options.db)
|
||||
child->options.db= my_strdup(parent->options.db, MYF(0));
|
||||
|
||||
/*
|
||||
rpl_pivot is set to 1 in mysql_init(); Reset it as we are not doing
|
||||
replication here
|
||||
*/
|
||||
child->rpl_pivot= 0;
|
||||
DBUG_RETURN(child);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
STDCALL mysql_set_master(MYSQL* mysql, const char* host,
|
||||
unsigned int port, const char* user,
|
||||
const char* passwd)
|
||||
{
|
||||
if (mysql->master != mysql && !mysql->master->rpl_pivot)
|
||||
mysql_close(mysql->master);
|
||||
if (!(mysql->master = spawn_init(mysql, host, port, user, passwd)))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd)
|
||||
{
|
||||
MYSQL* slave;
|
||||
if (!(slave = spawn_init(mysql, host, port, user, passwd)))
|
||||
return 1;
|
||||
slave->next_slave = mysql->next_slave;
|
||||
mysql->next_slave = slave;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Return next field of the query results
|
||||
**************************************************************************/
|
||||
@ -1483,17 +1112,17 @@ MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res)
|
||||
|
||||
unsigned int STDCALL mysql_field_count(MYSQL *mysql)
|
||||
{
|
||||
return mysql->last_used_con->field_count;
|
||||
return mysql->field_count;
|
||||
}
|
||||
|
||||
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql)
|
||||
{
|
||||
return mysql->last_used_con->affected_rows;
|
||||
return mysql->affected_rows;
|
||||
}
|
||||
|
||||
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
|
||||
{
|
||||
return mysql->last_used_con->insert_id;
|
||||
return mysql->insert_id;
|
||||
}
|
||||
|
||||
const char *STDCALL mysql_sqlstate(MYSQL *mysql)
|
||||
@ -1629,6 +1258,20 @@ mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
|
||||
return (uint) escape_string_for_mysql(mysql->charset, to, 0, from, length);
|
||||
}
|
||||
|
||||
|
||||
char * STDCALL
|
||||
mysql_odbc_escape_string(MYSQL *mysql __attribute__((unused)),
|
||||
char *to __attribute__((unused)),
|
||||
ulong to_length __attribute__((unused)),
|
||||
const char *from __attribute__((unused)),
|
||||
ulong from_length __attribute__((unused)),
|
||||
void *param __attribute__((unused)),
|
||||
char * (*extend_buffer)(void *, char *, ulong *)
|
||||
__attribute__((unused)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void STDCALL
|
||||
myodbc_remove_escape(MYSQL *mysql,char *name)
|
||||
{
|
||||
@ -1858,7 +1501,6 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
|
||||
MYSQL_DATA *fields_data;
|
||||
DBUG_ENTER("cli_read_prepare_result");
|
||||
|
||||
mysql= mysql->last_used_con;
|
||||
if ((packet_length= cli_safe_read(mysql)) == packet_error)
|
||||
DBUG_RETURN(1);
|
||||
mysql->warning_count= 0;
|
||||
@ -2092,7 +1734,9 @@ static void alloc_stmt_fields(MYSQL_STMT *stmt)
|
||||
{
|
||||
MYSQL_FIELD *fields, *field, *end;
|
||||
MEM_ROOT *alloc= &stmt->mem_root;
|
||||
MYSQL *mysql= stmt->mysql->last_used_con;
|
||||
MYSQL *mysql= stmt->mysql;
|
||||
|
||||
DBUG_ASSERT(mysql->field_count);
|
||||
|
||||
stmt->field_count= mysql->field_count;
|
||||
|
||||
@ -2115,18 +1759,21 @@ static void alloc_stmt_fields(MYSQL_STMT *stmt)
|
||||
field= stmt->fields;
|
||||
field && fields < end; fields++, field++)
|
||||
{
|
||||
field->db = strdup_root(alloc,fields->db);
|
||||
field->table = strdup_root(alloc,fields->table);
|
||||
field->org_table= strdup_root(alloc,fields->org_table);
|
||||
field->name = strdup_root(alloc,fields->name);
|
||||
field->org_name = strdup_root(alloc,fields->org_name);
|
||||
field->charsetnr= fields->charsetnr;
|
||||
field->length = fields->length;
|
||||
field->type = fields->type;
|
||||
field->flags = fields->flags;
|
||||
field->decimals = fields->decimals;
|
||||
field->def = fields->def ? strdup_root(alloc,fields->def): 0;
|
||||
field->max_length= 0;
|
||||
*field= *fields; /* To copy all numeric parts. */
|
||||
field->catalog= strmake_root(alloc, fields->catalog,
|
||||
fields->catalog_length);
|
||||
field->db= strmake_root(alloc, fields->db, fields->db_length);
|
||||
field->table= strmake_root(alloc, fields->table, fields->table_length);
|
||||
field->org_table= strmake_root(alloc, fields->org_table,
|
||||
fields->org_table_length);
|
||||
field->name= strmake_root(alloc, fields->name, fields->name_length);
|
||||
field->org_name= strmake_root(alloc, fields->org_name,
|
||||
fields->org_name_length);
|
||||
field->def= fields->def ? strmake_root(alloc, fields->def,
|
||||
fields->def_length) : 0;
|
||||
field->def_length= field->def ? fields->def_length : 0;
|
||||
field->extension= 0; /* Avoid dangling links. */
|
||||
field->max_length= 0; /* max_length is set in mysql_stmt_store_result() */
|
||||
}
|
||||
}
|
||||
|
||||
@ -2479,7 +2126,6 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
|
||||
DBUG_ENTER("execute");
|
||||
DBUG_DUMP("packet", (uchar *) packet, length);
|
||||
|
||||
mysql->last_used_con= mysql;
|
||||
int4store(buff, stmt->stmt_id); /* Send stmt id to server */
|
||||
buff[4]= (char) stmt->flags;
|
||||
int4store(buff+5, 1); /* iteration count */
|
||||
@ -2854,6 +2500,33 @@ static void reinit_result_set_metadata(MYSQL_STMT *stmt)
|
||||
}
|
||||
|
||||
|
||||
static void prepare_to_fetch_result(MYSQL_STMT *stmt)
|
||||
{
|
||||
if (stmt->server_status & SERVER_STATUS_CURSOR_EXISTS)
|
||||
{
|
||||
stmt->mysql->status= MYSQL_STATUS_READY;
|
||||
stmt->read_row_func= stmt_read_row_from_cursor;
|
||||
}
|
||||
else if (stmt->flags & CURSOR_TYPE_READ_ONLY)
|
||||
{
|
||||
/*
|
||||
This is a single-row result set, a result set with no rows, EXPLAIN,
|
||||
SHOW VARIABLES, or some other command which either a) bypasses the
|
||||
cursors framework in the server and writes rows directly to the
|
||||
network or b) is more efficient if all (few) result set rows are
|
||||
precached on client and server's resources are freed.
|
||||
*/
|
||||
mysql_stmt_store_result(stmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
stmt->mysql->unbuffered_fetch_owner= &stmt->unbuffered_fetch_cancelled;
|
||||
stmt->unbuffered_fetch_cancelled= FALSE;
|
||||
stmt->read_row_func= stmt_read_row_unbuffered;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Send placeholders data to server (if there are placeholders)
|
||||
and execute prepared statement.
|
||||
@ -2921,28 +2594,7 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
|
||||
if (mysql->field_count)
|
||||
{
|
||||
reinit_result_set_metadata(stmt);
|
||||
if (stmt->server_status & SERVER_STATUS_CURSOR_EXISTS)
|
||||
{
|
||||
mysql->status= MYSQL_STATUS_READY;
|
||||
stmt->read_row_func= stmt_read_row_from_cursor;
|
||||
}
|
||||
else if (stmt->flags & CURSOR_TYPE_READ_ONLY)
|
||||
{
|
||||
/*
|
||||
This is a single-row result set, a result set with no rows, EXPLAIN,
|
||||
SHOW VARIABLES, or some other command which either a) bypasses the
|
||||
cursors framework in the server and writes rows directly to the
|
||||
network or b) is more efficient if all (few) result set rows are
|
||||
precached on client and server's resources are freed.
|
||||
*/
|
||||
mysql_stmt_store_result(stmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
stmt->mysql->unbuffered_fetch_owner= &stmt->unbuffered_fetch_cancelled;
|
||||
stmt->unbuffered_fetch_cancelled= FALSE;
|
||||
stmt->read_row_func= stmt_read_row_unbuffered;
|
||||
}
|
||||
prepare_to_fetch_result(stmt);
|
||||
}
|
||||
DBUG_RETURN(test(stmt->last_errno));
|
||||
}
|
||||
@ -4407,7 +4059,6 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field)
|
||||
field->max_length= 10; /* 2003-11-11 */
|
||||
param->skip_result= skip_result_with_length;
|
||||
break;
|
||||
break;
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
param->skip_result= skip_result_with_length;
|
||||
@ -4689,7 +4340,6 @@ int cli_read_binary_rows(MYSQL_STMT *stmt)
|
||||
}
|
||||
|
||||
net = &mysql->net;
|
||||
mysql= mysql->last_used_con;
|
||||
|
||||
while ((pkt_len= cli_safe_read(mysql)) != packet_error)
|
||||
{
|
||||
@ -4787,8 +4437,6 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
mysql= mysql->last_used_con;
|
||||
|
||||
if (!stmt->field_count)
|
||||
DBUG_RETURN(0);
|
||||
|
||||
@ -4990,7 +4638,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
|
||||
if (stmt->field_count && mysql->status != MYSQL_STATUS_READY)
|
||||
{
|
||||
/* There is a result set and it belongs to this statement */
|
||||
(*mysql->methods->flush_use_result)(mysql);
|
||||
(*mysql->methods->flush_use_result)(mysql, FALSE);
|
||||
if (mysql->unbuffered_fetch_owner)
|
||||
*mysql->unbuffered_fetch_owner= TRUE;
|
||||
mysql->status= MYSQL_STATUS_READY;
|
||||
@ -5074,7 +4722,7 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
|
||||
Flush result set of the connection. If it does not belong
|
||||
to this statement, set a warning.
|
||||
*/
|
||||
(*mysql->methods->flush_use_result)(mysql);
|
||||
(*mysql->methods->flush_use_result)(mysql, TRUE);
|
||||
if (mysql->unbuffered_fetch_owner)
|
||||
*mysql->unbuffered_fetch_owner= TRUE;
|
||||
mysql->status= MYSQL_STATUS_READY;
|
||||
@ -5193,8 +4841,7 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql)
|
||||
my_bool res;
|
||||
DBUG_ENTER("mysql_more_results");
|
||||
|
||||
res= ((mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) ?
|
||||
1: 0);
|
||||
res= ((mysql->server_status & SERVER_MORE_RESULTS_EXISTS) ? 1: 0);
|
||||
DBUG_PRINT("exit",("More results exists ? %d", res));
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
@ -5216,13 +4863,56 @@ int STDCALL mysql_next_result(MYSQL *mysql)
|
||||
net_clear_error(&mysql->net);
|
||||
mysql->affected_rows= ~(my_ulonglong) 0;
|
||||
|
||||
if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS)
|
||||
if (mysql->server_status & SERVER_MORE_RESULTS_EXISTS)
|
||||
DBUG_RETURN((*mysql->methods->next_result)(mysql));
|
||||
|
||||
DBUG_RETURN(-1); /* No more results */
|
||||
}
|
||||
|
||||
|
||||
int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt)
|
||||
{
|
||||
MYSQL *mysql= stmt->mysql;
|
||||
int rc;
|
||||
DBUG_ENTER("mysql_stmt_next_result");
|
||||
|
||||
if (!mysql)
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (stmt->last_errno)
|
||||
DBUG_RETURN(stmt->last_errno);
|
||||
|
||||
if (mysql->server_status & SERVER_MORE_RESULTS_EXISTS)
|
||||
{
|
||||
if (reset_stmt_handle(stmt, RESET_STORE_RESULT))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
rc= mysql_next_result(mysql);
|
||||
|
||||
if (rc)
|
||||
{
|
||||
set_stmt_errmsg(stmt, &mysql->net);
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
stmt->state= MYSQL_STMT_EXECUTE_DONE;
|
||||
stmt->bind_result_done= FALSE;
|
||||
|
||||
if (mysql->field_count)
|
||||
{
|
||||
alloc_stmt_fields(stmt);
|
||||
prepare_to_fetch_result(stmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
stmt->field_count= mysql->field_count;
|
||||
}
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql)
|
||||
{
|
||||
return (*mysql->methods->use_result)(mysql);
|
||||
|
@ -78,6 +78,7 @@ EXPORTS
|
||||
mysql_next_result
|
||||
mysql_num_fields
|
||||
mysql_num_rows
|
||||
mysql_odbc_escape_string
|
||||
mysql_options
|
||||
mysql_stmt_param_count
|
||||
mysql_stmt_param_metadata
|
||||
@ -135,15 +136,6 @@ EXPORTS
|
||||
client_errors
|
||||
mysql_set_local_infile_default
|
||||
mysql_set_local_infile_handler
|
||||
mysql_disable_reads_from_master
|
||||
mysql_disable_rpl_parse
|
||||
mysql_enable_reads_from_master
|
||||
mysql_enable_rpl_parse
|
||||
mysql_master_query
|
||||
mysql_rpl_parse_enabled
|
||||
mysql_rpl_probe
|
||||
mysql_rpl_query_type
|
||||
mysql_slave_query
|
||||
mysql_embedded
|
||||
mysql_server_init
|
||||
mysql_server_end
|
||||
|
@ -1,269 +0,0 @@
|
||||
/* Copyright (C) 2000-2004 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation.
|
||||
|
||||
There are special exceptions to the terms and conditions of the GPL as it
|
||||
is applied to this software. View the full text of the exception in file
|
||||
EXCEPTIONS-CLIENT in the directory of this software distribution.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include <my_global.h>
|
||||
#if defined(THREAD)
|
||||
#include <my_pthread.h> /* because of signal() */
|
||||
#endif
|
||||
#include "mysql.h"
|
||||
#include "mysql_version.h"
|
||||
#include "mysqld_error.h"
|
||||
#include <my_sys.h>
|
||||
#include <mysys_err.h>
|
||||
#include <m_string.h>
|
||||
#include <m_ctype.h>
|
||||
#include <my_net.h>
|
||||
#include <errmsg.h>
|
||||
#include <violite.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(__NETWARE__)
|
||||
#include <netdb.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/utsname.h>
|
||||
#elif !defined( __WIN__)
|
||||
#include <sys/resource.h>
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
# include <sys/un.h>
|
||||
#endif
|
||||
#include <netdb.h>
|
||||
#ifdef HAVE_SELECT_H
|
||||
# include <select.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <sys/utsname.h>
|
||||
#endif /* __WIN__ */
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE -1
|
||||
#endif
|
||||
|
||||
#define RES_BUF_SHIFT 5
|
||||
#define NET_BUF_SIZE 2048
|
||||
|
||||
MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con)
|
||||
{
|
||||
int net_buf_size=NET_BUF_SIZE;
|
||||
if (!con)
|
||||
{
|
||||
if (!(con=(MYSQL_MANAGER*)my_malloc(sizeof(*con)+net_buf_size,
|
||||
MYF(MY_WME|MY_ZEROFILL))))
|
||||
return 0;
|
||||
con->free_me=1;
|
||||
con->net_buf=(char*)con+sizeof(*con);
|
||||
}
|
||||
else
|
||||
{
|
||||
bzero((char*)con,sizeof(*con));
|
||||
if (!(con->net_buf=my_malloc(net_buf_size,MYF(0))))
|
||||
return 0;
|
||||
}
|
||||
con->net_buf_pos=con->net_data_end=con->net_buf;
|
||||
con->net_buf_size=net_buf_size;
|
||||
return con;
|
||||
}
|
||||
|
||||
MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
|
||||
const char* host,
|
||||
const char* user,
|
||||
const char* passwd,
|
||||
unsigned int port)
|
||||
{
|
||||
my_socket sock;
|
||||
struct sockaddr_in sock_addr;
|
||||
in_addr_t ip_addr;
|
||||
char msg_buf[MAX_MYSQL_MANAGER_MSG];
|
||||
int msg_len;
|
||||
Vio* vio;
|
||||
my_bool not_used;
|
||||
|
||||
if (!host)
|
||||
host="localhost";
|
||||
if (!user)
|
||||
user="root";
|
||||
if (!passwd)
|
||||
passwd="";
|
||||
|
||||
if ((sock=(my_socket)socket(AF_INET,SOCK_STREAM,0)) == INVALID_SOCKET)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"Cannot create socket");
|
||||
goto err;
|
||||
}
|
||||
if (!(vio=vio_new(sock,VIO_TYPE_TCPIP,FALSE)))
|
||||
{
|
||||
con->last_errno=ENOMEM;
|
||||
strmov(con->last_error,"Cannot create network I/O object");
|
||||
goto err;
|
||||
}
|
||||
vio_blocking(vio, TRUE, ¬_used);
|
||||
my_net_init(&con->net,vio);
|
||||
bzero((char*) &sock_addr,sizeof(sock_addr));
|
||||
sock_addr.sin_family = AF_INET;
|
||||
if ((int) (ip_addr = inet_addr(host)) != (int) INADDR_NONE)
|
||||
{
|
||||
memcpy_fixed(&sock_addr.sin_addr,&ip_addr,sizeof(ip_addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
int tmp_errno;
|
||||
struct hostent tmp_hostent,*hp;
|
||||
char buff2[GETHOSTBYNAME_BUFF_SIZE];
|
||||
hp = my_gethostbyname_r(host,&tmp_hostent,buff2,sizeof(buff2),
|
||||
&tmp_errno);
|
||||
if (!hp)
|
||||
{
|
||||
con->last_errno=tmp_errno;
|
||||
sprintf(con->last_error,"Could not resolve host '%-.64s'",host);
|
||||
my_gethostbyname_r_free();
|
||||
goto err;
|
||||
}
|
||||
memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
|
||||
my_gethostbyname_r_free();
|
||||
}
|
||||
sock_addr.sin_port = (ushort) htons((ushort) port);
|
||||
if (my_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
|
||||
0))
|
||||
{
|
||||
con->last_errno=errno;
|
||||
sprintf(con->last_error ,"Could not connect to %-.64s", host);
|
||||
goto err;
|
||||
}
|
||||
/* read the greating */
|
||||
if (my_net_read(&con->net) == packet_error)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"Read error on socket");
|
||||
goto err;
|
||||
}
|
||||
sprintf(msg_buf,"%-.16s %-.16s\n",user,passwd);
|
||||
msg_len=strlen(msg_buf);
|
||||
if (my_net_write(&con->net,(uchar*) msg_buf,msg_len) || net_flush(&con->net))
|
||||
{
|
||||
con->last_errno=con->net.last_errno;
|
||||
strmov(con->last_error,"Write error on socket");
|
||||
goto err;
|
||||
}
|
||||
if (my_net_read(&con->net) == packet_error)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"Read error on socket");
|
||||
goto err;
|
||||
}
|
||||
if ((con->cmd_status=atoi((char*) con->net.read_pos)) != MANAGER_OK)
|
||||
{
|
||||
strmov(con->last_error,"Access denied");
|
||||
goto err;
|
||||
}
|
||||
if (!my_multi_malloc(MYF(0), &con->host, (uint)strlen(host)+1,
|
||||
&con->user, (uint)strlen(user)+1,
|
||||
&con->passwd, (uint)strlen(passwd)+1,
|
||||
NullS))
|
||||
{
|
||||
con->last_errno=ENOMEM;
|
||||
strmov(con->last_error,"Out of memory");
|
||||
goto err;
|
||||
}
|
||||
strmov(con->host,host);
|
||||
strmov(con->user,user);
|
||||
strmov(con->passwd,passwd);
|
||||
return con;
|
||||
|
||||
err:
|
||||
{
|
||||
my_bool free_me=con->free_me;
|
||||
con->free_me=0;
|
||||
mysql_manager_close(con);
|
||||
con->free_me=free_me;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void STDCALL mysql_manager_close(MYSQL_MANAGER* con)
|
||||
{
|
||||
/*
|
||||
No need to free con->user and con->passwd, because they were
|
||||
allocated in my_multimalloc() along with con->host, freeing
|
||||
con->hosts frees the whole block
|
||||
*/
|
||||
my_free((uchar*)con->host,MYF(MY_ALLOW_ZERO_PTR));
|
||||
net_end(&con->net);
|
||||
if (con->free_me)
|
||||
my_free((uchar*)con,MYF(0));
|
||||
}
|
||||
|
||||
|
||||
int STDCALL mysql_manager_command(MYSQL_MANAGER* con,const char* cmd,
|
||||
int cmd_len)
|
||||
{
|
||||
if (!cmd_len)
|
||||
cmd_len=strlen(cmd);
|
||||
if (my_net_write(&con->net,(const uchar*)cmd,cmd_len) || net_flush(&con->net))
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"Write error on socket");
|
||||
return 1;
|
||||
}
|
||||
con->eof=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con, char* res_buf,
|
||||
int res_buf_size)
|
||||
{
|
||||
char* res_buf_end=res_buf+res_buf_size;
|
||||
char* net_buf=(char*) con->net.read_pos, *net_buf_end;
|
||||
int res_buf_shift=RES_BUF_SHIFT;
|
||||
ulong num_bytes;
|
||||
|
||||
if (res_buf_size<RES_BUF_SHIFT)
|
||||
{
|
||||
con->last_errno=ENOMEM;
|
||||
strmov(con->last_error,"Result buffer too small");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((num_bytes=my_net_read(&con->net)) == packet_error)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"socket read failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
net_buf_end=net_buf+num_bytes;
|
||||
|
||||
if ((con->eof=(net_buf[3]==' ')))
|
||||
res_buf_shift--;
|
||||
net_buf+=res_buf_shift;
|
||||
res_buf_end[-1]=0;
|
||||
for (;net_buf<net_buf_end && res_buf < res_buf_end;res_buf++,net_buf++)
|
||||
{
|
||||
if ((*res_buf=*net_buf) == '\r')
|
||||
{
|
||||
*res_buf=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -13,15 +13,6 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
|
||||
# Need to set USE_TLS, since __declspec(thread) approach to thread local
|
||||
# storage does not work properly in DLLs.
|
||||
IF(WIN32)
|
||||
ADD_DEFINITIONS(-DUSE_TLS)
|
||||
ENDIF(WIN32)
|
||||
|
||||
ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY -DHAVE_DLOPEN)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
|
||||
@ -141,6 +132,7 @@ SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
|
||||
../sql/time.cc ../sql/tztime.cc ../sql/uniques.cc ../sql/unireg.cc
|
||||
../sql/partition_info.cc ../sql/sql_connect.cc
|
||||
../sql/scheduler.cc ../sql/event_parse_data.cc
|
||||
../sql/sql_signal.cc ../sql/rpl_handler.cc
|
||||
${GEN_SOURCES}
|
||||
${LIB_SOURCES})
|
||||
|
||||
|
@ -78,7 +78,8 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
|
||||
debug_sync.cc \
|
||||
sql_tablespace.cc \
|
||||
rpl_injector.cc my_user.c partition_info.cc \
|
||||
sql_servers.cc event_parse_data.cc
|
||||
sql_servers.cc event_parse_data.cc sql_signal.cc \
|
||||
rpl_handler.cc
|
||||
|
||||
libmysqld_int_a_SOURCES= $(libmysqld_sources)
|
||||
nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
|
||||
|
@ -483,7 +483,8 @@ int emb_load_querycache_result(THD *thd, Querycache_stream *src)
|
||||
*prev_row= NULL;
|
||||
data->embedded_info->prev_ptr= prev_row;
|
||||
return_ok:
|
||||
net_send_eof(thd, thd->server_status, thd->total_warn_count);
|
||||
net_send_eof(thd, thd->server_status,
|
||||
thd->warning_info->statement_warn_count());
|
||||
DBUG_RETURN(0);
|
||||
err:
|
||||
DBUG_RETURN(1);
|
||||
|
@ -20,9 +20,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/extra/yassl/include)
|
||||
|
||||
# Currently does not work with DBUG, there are missing symbols reported.
|
||||
IF(WIN32)
|
||||
ADD_DEFINITIONS(-DUSE_TLS)
|
||||
ENDIF(WIN32)
|
||||
|
||||
ADD_DEFINITIONS(-DEMBEDDED_LIBRARY)
|
||||
|
||||
|
@ -98,7 +98,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
|
||||
thd= (THD *) mysql->thd;
|
||||
}
|
||||
|
||||
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
|
||||
#if defined(ENABLED_PROFILING)
|
||||
thd->profiling.start_new_query();
|
||||
#endif
|
||||
|
||||
@ -112,7 +112,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
|
||||
|
||||
/* Clear result variables */
|
||||
thd->clear_error();
|
||||
thd->main_da.reset_diagnostics_area();
|
||||
thd->stmt_da->reset_diagnostics_area();
|
||||
mysql->affected_rows= ~(my_ulonglong) 0;
|
||||
mysql->field_count= 0;
|
||||
net_clear_error(net);
|
||||
@ -144,13 +144,13 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
|
||||
|
||||
thd->mysys_var= 0;
|
||||
|
||||
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
|
||||
#if defined(ENABLED_PROFILING)
|
||||
thd->profiling.finish_current_query();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
static void emb_flush_use_result(MYSQL *mysql)
|
||||
static void emb_flush_use_result(MYSQL *mysql, my_bool)
|
||||
{
|
||||
THD *thd= (THD*) mysql->thd;
|
||||
if (thd->cur_data)
|
||||
@ -219,7 +219,7 @@ static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
|
||||
stmt->stmt_id= thd->client_stmt_id;
|
||||
stmt->param_count= thd->client_param_count;
|
||||
stmt->field_count= 0;
|
||||
mysql->warning_count= thd->total_warn_count;
|
||||
mysql->warning_count= thd->warning_info->statement_warn_count();
|
||||
|
||||
if (thd->first_data)
|
||||
{
|
||||
@ -404,7 +404,7 @@ static void emb_free_embedded_thd(MYSQL *mysql)
|
||||
static const char * emb_read_statistics(MYSQL *mysql)
|
||||
{
|
||||
THD *thd= (THD*)mysql->thd;
|
||||
return thd->is_error() ? thd->main_da.message() : "";
|
||||
return thd->is_error() ? thd->stmt_da->message() : "";
|
||||
}
|
||||
|
||||
|
||||
@ -656,7 +656,7 @@ int check_embedded_connection(MYSQL *mysql, const char *db)
|
||||
strmake(sctx->priv_host, (char*) my_localhost, MAX_HOSTNAME-1);
|
||||
sctx->priv_user= sctx->user= my_strdup(mysql->user, MYF(0));
|
||||
result= check_user(thd, COM_CONNECT, NULL, 0, db, true);
|
||||
net_end_statement(thd);
|
||||
thd->protocol->end_statement();
|
||||
emb_read_query_result(mysql);
|
||||
return result;
|
||||
}
|
||||
@ -706,9 +706,10 @@ int check_embedded_connection(MYSQL *mysql, const char *db)
|
||||
err:
|
||||
{
|
||||
NET *net= &mysql->net;
|
||||
strmake(net->last_error, thd->main_da.message(), sizeof(net->last_error)-1);
|
||||
strmake(net->last_error, thd->stmt_da->message(),
|
||||
sizeof(net->last_error)-1);
|
||||
memcpy(net->sqlstate,
|
||||
mysql_errno_to_sqlstate(thd->main_da.sql_errno()),
|
||||
mysql_errno_to_sqlstate(thd->stmt_da->sql_errno()),
|
||||
sizeof(net->sqlstate)-1);
|
||||
}
|
||||
return result;
|
||||
@ -732,8 +733,8 @@ void THD::clear_data_list()
|
||||
|
||||
void THD::clear_error()
|
||||
{
|
||||
if (main_da.is_error())
|
||||
main_da.reset_diagnostics_area();
|
||||
if (stmt_da->is_error())
|
||||
stmt_da->reset_diagnostics_area();
|
||||
}
|
||||
|
||||
static char *dup_str_aux(MEM_ROOT *root, const char *from, uint length,
|
||||
@ -807,7 +808,7 @@ MYSQL_DATA *THD::alloc_new_dataset()
|
||||
|
||||
static
|
||||
bool
|
||||
write_eof_packet(THD *thd, uint server_status, uint total_warn_count)
|
||||
write_eof_packet(THD *thd, uint server_status, uint statement_warn_count)
|
||||
{
|
||||
if (!thd->mysql) // bootstrap file handling
|
||||
return FALSE;
|
||||
@ -824,7 +825,7 @@ write_eof_packet(THD *thd, uint server_status, uint total_warn_count)
|
||||
is cleared between substatements, and mysqltest gets confused
|
||||
*/
|
||||
thd->cur_data->embedded_info->warning_count=
|
||||
(thd->spcont ? 0 : min(total_warn_count, 65535));
|
||||
(thd->spcont ? 0 : min(statement_warn_count, 65535));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -881,7 +882,7 @@ void Protocol_text::remove_last_row()
|
||||
}
|
||||
|
||||
|
||||
bool Protocol::send_fields(List<Item> *list, uint flags)
|
||||
bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
|
||||
{
|
||||
List_iterator_fast<Item> it(*list);
|
||||
Item *item;
|
||||
@ -890,7 +891,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
|
||||
CHARSET_INFO *thd_cs= thd->variables.character_set_results;
|
||||
CHARSET_INFO *cs= system_charset_info;
|
||||
MYSQL_DATA *data;
|
||||
DBUG_ENTER("send_fields");
|
||||
DBUG_ENTER("send_result_set_metadata");
|
||||
|
||||
if (!thd->mysql) // bootstrap file handling
|
||||
DBUG_RETURN(0);
|
||||
@ -954,7 +955,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
|
||||
client_field->catalog= dup_str_aux(field_alloc, "def", 3, cs, thd_cs);
|
||||
client_field->catalog_length= 3;
|
||||
|
||||
if (INTERNAL_NUM_FIELD(client_field))
|
||||
if (IS_NUM(client_field->type))
|
||||
client_field->flags|= NUM_FLAG;
|
||||
|
||||
if (flags & (int) Protocol::SEND_DEFAULTS)
|
||||
@ -981,9 +982,10 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
|
||||
}
|
||||
|
||||
if (flags & SEND_EOF)
|
||||
write_eof_packet(thd, thd->server_status, thd->total_warn_count);
|
||||
write_eof_packet(thd, thd->server_status,
|
||||
thd->warning_info->statement_warn_count());
|
||||
|
||||
DBUG_RETURN(prepare_for_send(list));
|
||||
DBUG_RETURN(prepare_for_send(list->elements));
|
||||
err:
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0)); /* purecov: inspected */
|
||||
DBUG_RETURN(1); /* purecov: inspected */
|
||||
@ -1043,25 +1045,24 @@ bool Protocol_binary::write()
|
||||
|
||||
bool
|
||||
net_send_ok(THD *thd,
|
||||
uint server_status, uint total_warn_count,
|
||||
ha_rows affected_rows, ulonglong id, const char *message)
|
||||
uint server_status, uint statement_warn_count,
|
||||
ulonglong affected_rows, ulonglong id, const char *message)
|
||||
{
|
||||
DBUG_ENTER("emb_net_send_ok");
|
||||
MYSQL_DATA *data;
|
||||
bool error;
|
||||
MYSQL *mysql= thd->mysql;
|
||||
|
||||
if (!mysql) // bootstrap file handling
|
||||
DBUG_RETURN(FALSE);
|
||||
if (!(data= thd->alloc_new_dataset()))
|
||||
return TRUE;
|
||||
DBUG_RETURN(TRUE);
|
||||
data->embedded_info->affected_rows= affected_rows;
|
||||
data->embedded_info->insert_id= id;
|
||||
if (message)
|
||||
strmake(data->embedded_info->info, message,
|
||||
sizeof(data->embedded_info->info)-1);
|
||||
|
||||
error= write_eof_packet(thd, server_status, total_warn_count);
|
||||
bool error= write_eof_packet(thd, server_status, statement_warn_count);
|
||||
thd->cur_data= 0;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
@ -1078,16 +1079,20 @@ net_send_ok(THD *thd,
|
||||
*/
|
||||
|
||||
bool
|
||||
net_send_eof(THD *thd, uint server_status, uint total_warn_count)
|
||||
net_send_eof(THD *thd, uint server_status, uint statement_warn_count)
|
||||
{
|
||||
bool error= write_eof_packet(thd, server_status, total_warn_count);
|
||||
bool error= write_eof_packet(thd, server_status, statement_warn_count);
|
||||
thd->cur_data= 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
bool net_send_error_packet(THD *thd, uint sql_errno, const char *err)
|
||||
bool net_send_error_packet(THD *thd, uint sql_errno, const char *err,
|
||||
const char *sqlstate)
|
||||
{
|
||||
uint error;
|
||||
uchar converted_err[MYSQL_ERRMSG_SIZE];
|
||||
uint32 converted_err_len;
|
||||
MYSQL_DATA *data= thd->cur_data;
|
||||
struct embedded_query_result *ei;
|
||||
|
||||
@ -1102,8 +1107,13 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err)
|
||||
|
||||
ei= data->embedded_info;
|
||||
ei->last_errno= sql_errno;
|
||||
strmake(ei->info, err, sizeof(ei->info)-1);
|
||||
strmov(ei->sqlstate, mysql_errno_to_sqlstate(sql_errno));
|
||||
converted_err_len= convert_error_message((char*)converted_err,
|
||||
sizeof(converted_err),
|
||||
thd->variables.character_set_results,
|
||||
err, strlen(err),
|
||||
system_charset_info, &error);
|
||||
strmake(ei->info, (const char*) converted_err, sizeof(ei->info)-1);
|
||||
strmov(ei->sqlstate, sqlstate);
|
||||
ei->server_status= thd->server_status;
|
||||
thd->cur_data= 0;
|
||||
return FALSE;
|
||||
@ -1176,3 +1186,27 @@ int vprint_msg_to_log(enum loglevel level __attribute__((unused)),
|
||||
mysql_server_last_errno= CR_UNKNOWN_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool Protocol::net_store_data(const uchar *from, size_t length,
|
||||
CHARSET_INFO *from_cs, CHARSET_INFO *to_cs)
|
||||
{
|
||||
uint conv_length= to_cs->mbmaxlen * length / from_cs->mbminlen;
|
||||
uint dummy_error;
|
||||
char *field_buf;
|
||||
if (!thd->mysql) // bootstrap file handling
|
||||
return false;
|
||||
|
||||
if (!(field_buf= (char*) alloc_root(alloc, conv_length + sizeof(uint) + 1)))
|
||||
return true;
|
||||
*next_field= field_buf + sizeof(uint);
|
||||
length= copy_and_convert(*next_field, conv_length, to_cs,
|
||||
(const char*) from, length, from_cs, &dummy_error);
|
||||
*(uint *) field_buf= length;
|
||||
(*next_field)[length]= 0;
|
||||
if (next_mysql_field->max_length < length)
|
||||
next_mysql_field->max_length= length;
|
||||
++next_field;
|
||||
++next_mysql_field;
|
||||
return false;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sql_common.h>
|
||||
#include "client_settings.h"
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
@ -77,17 +78,6 @@ static my_bool is_NT(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************************************
|
||||
** Shut down connection
|
||||
**************************************************************************/
|
||||
|
||||
static void end_server(MYSQL *mysql)
|
||||
{
|
||||
DBUG_ENTER("end_server");
|
||||
free_old_query(mysql);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
int mysql_init_character_set(MYSQL *mysql);
|
||||
|
||||
@ -99,11 +89,18 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
char name_buff[USERNAME_LENGTH];
|
||||
|
||||
DBUG_ENTER("mysql_real_connect");
|
||||
DBUG_PRINT("enter",("host: %s db: %s user: %s",
|
||||
DBUG_PRINT("enter",("host: %s db: %s user: %s (libmysqld)",
|
||||
host ? host : "(Null)",
|
||||
db ? db : "(Null)",
|
||||
user ? user : "(Null)"));
|
||||
|
||||
/* Test whether we're already connected */
|
||||
if (mysql->server_version)
|
||||
{
|
||||
set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
if (!host || !host[0])
|
||||
host= mysql->options.host;
|
||||
|
||||
@ -216,7 +213,7 @@ error:
|
||||
{
|
||||
/* Free alloced memory */
|
||||
my_bool free_me=mysql->free_me;
|
||||
end_server(mysql);
|
||||
free_old_query(mysql);
|
||||
mysql->free_me=0;
|
||||
mysql_close(mysql);
|
||||
mysql->free_me=free_me;
|
||||
|
@ -13,9 +13,7 @@ EXPORTS
|
||||
mysql_commit
|
||||
mysql_data_seek
|
||||
mysql_debug
|
||||
mysql_disable_rpl_parse
|
||||
mysql_dump_debug_info
|
||||
mysql_enable_rpl_parse
|
||||
mysql_eof
|
||||
mysql_errno
|
||||
mysql_error
|
||||
@ -50,6 +48,7 @@ EXPORTS
|
||||
mysql_next_result
|
||||
mysql_num_fields
|
||||
mysql_num_rows
|
||||
mysql_odbc_escape_string
|
||||
mysql_options
|
||||
mysql_ping
|
||||
mysql_query
|
||||
@ -61,8 +60,6 @@ EXPORTS
|
||||
mysql_rollback
|
||||
mysql_row_seek
|
||||
mysql_row_tell
|
||||
mysql_rpl_parse_enabled
|
||||
mysql_rpl_probe
|
||||
mysql_select_db
|
||||
mysql_send_query
|
||||
mysql_shutdown
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2003, 2006 MySQL AB
|
||||
# Copyright (C) 2006 MySQL AB
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -13,8 +13,8 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
SUBDIRS = . instance-manager
|
||||
DIST_SUBDIRS = . instance-manager
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
||||
SET(MYSQLSERVICES_SOURCES my_snprintf_service.c thd_alloc_service.c)
|
||||
|
||||
ADD_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES})
|
100
libservices/HOWTO
Normal file
100
libservices/HOWTO
Normal file
@ -0,0 +1,100 @@
|
||||
How to create a new service
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
A "service" is a set of C functions in a structure that a
|
||||
service dynamic linker uses when a dynamic plugin is loaded.
|
||||
|
||||
If you want to export C++ class you need to provide an
|
||||
extern "C" function that will create a new instance of your class,
|
||||
and put it in a service.
|
||||
|
||||
Data structures are not part of the service structure, but they are part
|
||||
of the API you create and usually need to be declared in the same
|
||||
service_*.h file.
|
||||
|
||||
To turn a set of functions (foo_func1, foo_func2)
|
||||
into a service "foo" you need to
|
||||
|
||||
1. create a new file include/mysql/service_foo.h
|
||||
|
||||
2. the template is
|
||||
==================================================================
|
||||
#ifndef MYSQL_SERVICE_FOO_INCLUDED
|
||||
/* standard GPL header */
|
||||
|
||||
/**
|
||||
@file
|
||||
*exhaustive* description of the interface you provide.
|
||||
This file is the main user documentation of the new service
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct foo_service_st {
|
||||
int (*foo_func1_type)(...); /* fix the prototype as appropriate */
|
||||
void (*foo_func2_type)(...); /* fix the prototype as appropriate */
|
||||
} *foo_service;
|
||||
|
||||
#ifdef MYSQL_DYNAMIC_PLUGIN
|
||||
|
||||
#define foo_func1(...) foo_service->foo_func1_type(...)
|
||||
#define foo_func2(...) foo_service->foo_func2_type(...)
|
||||
|
||||
#else
|
||||
|
||||
int foo_func1_type(...); /* fix the prototype as appropriate */
|
||||
void foo_func2_type(...); /* fix the prototype as appropriate */
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MYSQL_SERVICE_FOO_INCLUDED
|
||||
#endif
|
||||
==================================================================
|
||||
|
||||
the service_foo.h file should be self-contained, if it needs system headers -
|
||||
include them in it, e.g. if you use size_t - #include <stdlib.h>
|
||||
|
||||
it should also declare all the accompanying data structures, as necessary
|
||||
(e.g. thd_alloc_service declares MYSQL_LEX_STRING).
|
||||
|
||||
3. add the new file to include/Makefile.am (pkginclude_HEADERS)
|
||||
4. add the new file to include/mysql/services.h
|
||||
5. increase the minor plugin ABI version in include/mysql/plugin.h
|
||||
(MYSQL_PLUGIN_INTERFACE_VERSION = MYSQL_PLUGIN_INTERFACE_VERSION+1)
|
||||
6. add the version of your service to include/service_versions.h:
|
||||
==================================================================
|
||||
#define VERSION_foo 0x0100
|
||||
==================================================================
|
||||
|
||||
7. create a new file libservices/foo_service.h using the following template:
|
||||
==================================================================
|
||||
/* GPL header */
|
||||
#include <service_versions.h>
|
||||
SERVICE_VERSION *foo_service= (void*)VERSION_foo;
|
||||
==================================================================
|
||||
|
||||
8. add the new file to libservices/CMakeLists.txt (MYSQLSERVICES_SOURCES)
|
||||
9. add the new file to libservices/Makefile.am (libmysqlservices_a_SOURCES)
|
||||
10. and finally, register your service for dynamic linking in
|
||||
sql/sql_plugin_services.h
|
||||
10.1 fill in the service structure:
|
||||
==================================================================
|
||||
static struct foo_service_st foo_handler = {
|
||||
foo_func1,
|
||||
foo_func2
|
||||
}
|
||||
==================================================================
|
||||
|
||||
10.2 and add it to the list of services
|
||||
|
||||
==================================================================
|
||||
{ "foo_service", VERSION_foo, &foo_handler }
|
||||
==================================================================
|
||||
|
||||
that's all.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user