diff options
58 files changed, 1238 insertions, 1044 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index addcf06aa5f..c9f82de08d3 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -98,6 +98,7 @@ sasha@mysql.sashanet.com serg@build.mysql2.com serg@serg.mylan serg@serg.mysql.com +serg@sergbook.mylan serg@sergbook.mysql.com sinisa@rhols221.adsl.netsonic.fi tfr@beta.frontier86.ee diff --git a/BitKeeper/triggers/post-incoming b/BitKeeper/triggers/post-incoming deleted file mode 100755 index f1ea2255de9..00000000000 --- a/BitKeeper/triggers/post-incoming +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -echo "Test: post-incoming works" diff --git a/BitKeeper/triggers/post-outgoing b/BitKeeper/triggers/post-outgoing deleted file mode 100755 index 3fc2cdbad67..00000000000 --- a/BitKeeper/triggers/post-outgoing +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -echo "Test: post-outgoing works" diff --git a/BitKeeper/triggers/pre-commit b/BitKeeper/triggers/pre-commit new file mode 100755 index 00000000000..2293dc55e2a --- /dev/null +++ b/BitKeeper/triggers/pre-commit @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ "$REAL_EMAIL" = "" ] +then + echo "Error: you must set REAL_EMAIL in your profile" + echo "e.g.: export REAL_EMAIL='Joe Dow <joe@foo.bar>'" + echo "" + echo "Commit FAILED!" + echo "Set REAL_EMAIL and retry." + exit 1 +fi + diff --git a/INSTALL-WIN-SOURCE b/INSTALL-WIN-SOURCE new file mode 100755 index 00000000000..ee3e35a91c8 --- /dev/null +++ b/INSTALL-WIN-SOURCE @@ -0,0 +1,211 @@ +######################################################### +# # +# HOWTO : INSTALL MySQL FROM SOURCE # +# WINDOWS PORT # +# # +# Copyright (C) MySQL AB 1995-2003 # +######################################################### + +This is a simple 'HOWTO' document describing how to +build MySQL binaries for versions 4.1 and above on +Windows. Instructions are provided for building binaries +from a standard source distribution or from the BitKeeper +tree that contains the latest developer source. + +--------------------------------------------------------- +NOTE +--------------------------------------------------------- + +Normally, it is best to use precompiled binary distributions +of MySQL that are built specifically for optimal performance +on Windows by MySQL AB. Binary distributions are available +from: + +http://www.mysql.com/downloads/ + +The instructions in this document are strictly for users +who want to test MySQL on Windows from the latest source or +from the BitKeeper tree, and for internal MySQL developers. + +-------------------------------------------------------- +TABLE OF CONTENTS +-------------------------------------------------------- +1. REQUIREMENTS +2. OBTAINING A WINDOWS SOURCE DISTRIBUTION +3. CREATING A SOURCE PACKAGE FROM THE 'BitKeeper' TREE +4. BUILDING 'mysql server and clients' FROM VC++ WORKSPACE +5. BUILDING FROM 'nmake' MAKEFILES +6. STARTING THE MYSQL SERVER FOR THE FIRST TIME +7. TESTING THE CONNECTION +8. SPECIAL NOTES AND CONSIDERATIONS + +------------------------------------------------------- +1. REQUIREMENTS +------------------------------------------------------- + +To build MySQL on Windows from source, you need the +following compiler and resources available on your Windows +system: + + - Microsoft Visual C++ 6.0 and above + - ~45 MB disk space + - 64 MB RAM + +You'll also need a MySQL source distribution. You can +get the source for released versions of MySQL from: + +http://www.mysql.com/downloads/ + +Alternatively, you can package a source distribution +yourself from the latest BitKeeper developer source +tree. If you plan to do this, you must create the +package on a Unix system and then transfer it to your +Windows system. (The reason for this is that the initial +configuration scripts and some of the build steps work +only on Unix.) The BitKeeper approach thus requires: + + - A system running Unix, or a Unix-like system such as Linux + - BitKeeper 3.0 installed on that system (you can obtain + BitKeeper from http://www.bitkeeper.com) + +------------------------------------------------------- +2. OBTAINING A WINDOWS SOURCE DISTRIBUTION +------------------------------------------------------- + +There are two ways you can get a Windows source distribution for +MySQL version 4.1 and above: + + I. Obtain a MySQL AB-distributed source distribution for the + particular version of MySQL in which you are interested. + Prepackaged source distributions are available for released + versions of MySQL and can be obtained from: + + http://www.mysql.com/downloads/ + + II. Create a source package yourself from the latest development + 'BitKeeper' source tree. + +If you are using the first option, you can skip the next +section and go directly to 'BUILDING FROM VC++ WORKSPACE'. + +------------------------------------------------------- +3. CREATING A SOURCE PACKAGE FROM THE 'BitKeeper' TREE +------------------------------------------------------- + +To build the latest Windows source package, Please follow the +following instructions from any of your '*UNIX*' operating +systems (preferably Linux): + +- Clone the BitKeeper source tree for MySQL (version 4.1 + or above, as desired). For more information how to clone + the BitKeeper source tree, follow the instructions at: + + http://www.mysql.com/doc/en/Installing_source_tree.html + +- Build the distribution so that you have a server binary to + work with. One way to do this is to run the following + command in the top-level directory of your source tree: + + ./BUILD/compile-pentium-max + +- After making sure that build process completed successfully, + run the following utility script from top-level directory + of your source tree: + + ./scripts/make_win_src_distribution + + This script creates the Windows source package. You can + supply different options to the script based on your needs. + It accepts: the following options: + + --debug Debug, without creating the package + --tmp Specify the temporary location + --suffix Suffix name for the package + --dirname Directory name to copy files (intermediate) + --silent Do not list verbosely files processed + --tar Create tar.gz package instead of .zip + --help Show this help message + + By default, make_win_src_distribution creates a zipped + archive with the name mysql-$version-win-src.zip, where + $version is the version of the MySQL source tree you + cloned. + + - Copy or upload to your Windows machine the Windows source + package that you have just created, and compile it using + the instructions in the next section. + +--------------------------------------------------------- +4. BUILDING 'mysql server & clients' FROM VC++ WORKSPACE +--------------------------------------------------------- + +NOTE: MySQL 4.1 and above VC++ workspace files are compatible + with Microsoft Visual Studio 6.0 and above(7.0/.NET) + editions and tested by MySQL folks before each + release. + +Unpack the Windows source zipped archive to a folder and open +mysql.dsw from your top-level directory. + +If you want to build both release and debug versions, then +select 'build' -> 'buildall' option. To build only 'release' +or 'debug' versions, then select all appropriate workspaces +from the 'build' -> 'batch build' option. + +The simplest solution to build basic clients and core +server is to set your current active workspace as 'mysqld' +release or debug version, and just hit 'build' or 'F7', which +creates necessary client binaries in the 'client_release' or +'client_debug' directories. The libraries are placed in the +'lib_release' and 'lib_debug' directories for release and +debug versions, respectively. + +Now you have built the distribution. If you get any compiler +errors, please cross check and send the compiler output to +win32@lists.mysql.com for further assistance. + +--------------------------------------------------------- +5. BUILDING FROM 'nmake' MAKEFILES +--------------------------------------------------------- +TODO from MySQL PIEFU team. + +--------------------------------------------------------- +6. STARTING THE MYSQL SERVER FOR THE FIRST TIME +--------------------------------------------------------- + +First ensure to set or copy my.ini or my.cnf file to your +'data' directory that exists in the top-level directory or +point to existing 'data' directory. + +Now, start your server from the 'client_release' or +'client_debug' directory (depending on which server you +want to use), by following the instructions from: + +http://www.mysql.com/doc/en/Windows_installation.html + +That's all!!! See, it's as simple to build MySQL on Windows +as on any other platform!!! + +--------------------------------------------------------- +7. TESTING THE CONNECTION +--------------------------------------------------------- + +Once the server is running in standalone fashion or as a +service based on your configuration, try to connect to it +from the 'mysql' command line SQL interactive utility that +exists in your 'client_release' or 'client_debug' directory. + +--------------------------------------------------------- +8. SPECIAL NOTES AND CONSIDERATIONS +--------------------------------------------------------- + +- For production use, MySQL AB does not advise using a MySQL + server built by yourself from source. Instead, stick to + binaries shipped by MySQL AB. + +- If you find something not working as expected, or you have + suggestions about ways to improve the current build process + on Windows, please email to 'win32@lists.mysql.com'. + +Thanks +MySQL Team diff --git a/client/mysql.cc b/client/mysql.cc index a957f804537..45b0e4bf2ea 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -563,12 +563,12 @@ static struct my_option my_long_options[] = {"prompt", OPT_PROMPT, "Set the mysql prompt to this value.", (gptr*) ¤t_prompt, (gptr*) ¤t_prompt, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"quick", 'q', - "Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file. ", + "Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file.", (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"raw", 'r', "Write fields without conversion. Used with --batch", + {"raw", 'r', "Write fields without conversion. Used with --batch.", (gptr*) &opt_raw_data, (gptr*) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default.", @@ -577,7 +577,7 @@ static struct my_option my_long_options[] = 0, 0}, #ifdef HAVE_SMEM {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"socket", 'S', "Socket file to use for connection.", @@ -601,7 +601,7 @@ static struct my_option my_long_options[] = {"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.", (gptr*) &safe_updates, (gptr*) &safe_updates, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Write more. (-v -v -v gives the table output format)", 0, + {"verbose", 'v', "Write more. (-v -v -v gives the table output format).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -1525,6 +1525,9 @@ static int com_server_help(String *buffer __attribute__((unused)), char last_char; int num_name, num_cat; + LINT_INIT(num_name); + LINT_INIT(num_cat); + if (num_fields == 2) { put_info("Many help items for your request exist", INFO_INFO); @@ -1841,7 +1844,7 @@ print_table_data(MYSQL_RES *result) separator.fill(separator.length()+length+2,'-'); separator.append('+'); } - tee_puts(separator.c_ptr(), PAGER); + tee_puts(separator.c_ptr_safe(), PAGER); if (column_names) { mysql_field_seek(result,0); diff --git a/client/mysqladmin.c b/client/mysqladmin.c index f5a9a70c820..018bcbc1963 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -113,16 +113,16 @@ static TYPELIB command_typelib= static struct my_option my_long_options[] = { {"count", 'c', - "Number of iterations to make. This works with -i (--sleep) only", + "Number of iterations to make. This works with -i (--sleep) only.", (gptr*) &nr_iterations, (gptr*) &nr_iterations, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'", + {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Don't ask for confirmation on drop database; with multiple commands, continue even if an error occurs.", (gptr*) &option_force, (gptr*) &option_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"compress", 'C', "Use compression in server/client protocol", + {"compress", 'C', "Use compression in server/client protocol.", (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, @@ -130,7 +130,7 @@ static struct my_option my_long_options[] = (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host", (gptr*) &host, (gptr*) &host, 0, GET_STR, + {"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", @@ -141,7 +141,7 @@ static struct my_option my_long_options[] = #endif {"port", 'P', "Port number to use for connection.", (gptr*) &tcp_port, (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"relative", 'r', "Show difference between current and previous values when used with -i. Currently works only with extended-status.", @@ -152,10 +152,10 @@ static struct my_option my_long_options[] = 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", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"silent", 's', "Silently exit if one can't connect to server", + {"silent", 's', "Silently exit if one can't connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", (gptr*) &unix_port, (gptr*) &unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, @@ -170,13 +170,13 @@ static struct my_option my_long_options[] = #endif {"verbose", 'v', "Write more information.", (gptr*) &opt_verbose, (gptr*) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"version", 'V', "Output version information and exit", 0, 0, 0, GET_NO_ARG, + {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"vertical", 'E', "Print output vertically. Is similar to --relative, but prints output vertically.", (gptr*) &opt_vertical, (gptr*) &opt_vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"wait", 'w', "Wait and retry if connection is down", 0, 0, 0, GET_UINT, + {"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_UINT, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"connect_timeout", OPT_CONNECT_TIMEOUT, "", (gptr*) &opt_connect_timeout, (gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 3600*12, 0, diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index ff86882bad3..0ef0cb9b8c1 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -199,38 +199,38 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log.", (gptr*) &default_dbug_option, (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"database", 'd', "List entries for just this database (local log only)", + {"database", 'd', "List entries for just this database (local log only).", (gptr*) &database, (gptr*) &database, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"force-read", 'f', "Force reading unknown binlog events", + {"force-read", 'f', "Force reading unknown binlog events.", (gptr*) &force_opt, (gptr*) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"help", '?', "Display this help and exit", + {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Get the binlog from server", (gptr*) &host, (gptr*) &host, + {"host", 'h', "Get the binlog from server.", (gptr*) &host, (gptr*) &host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"offset", 'o', "Skip the first N entries", (gptr*) &offset, (gptr*) &offset, + {"offset", 'o', "Skip the first N entries.", (gptr*) &offset, (gptr*) &offset, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"password", 'p', "Password to connect to remote server", + {"password", 'p', "Password to connect to remote server.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Use port to connect to the remote server", + {"port", 'P', "Use port to connect to the remote server.", (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"position", 'j', "Start reading the binlog at position N", + {"position", 'j', "Start reading the binlog at position N.", (gptr*) &position, (gptr*) &position, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"result-file", 'r', "Direct output to a given file", 0, 0, 0, GET_STR, + {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"short-form", 's', "Just show the queries, no extra info", + {"short-form", 's', "Just show the queries, no extra info.", (gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"table", 't', "Get raw table dump using COM_TABLE_DUMB", (gptr*) &table, + {"table", 't', "Get raw table dump using COM_TABLE_DUMB.", (gptr*) &table, (gptr*) &table, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"user", 'u', "Connect to the remote server as username", + {"user", 'u', "Connect to the remote server as username.", (gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"local-load", 'l', "Prepare files for local load in directory", - (gptr*) &dirname_for_local_load, (gptr*) &dirname_for_local_load, 0, + {"local-load", 'l', "Prepare files for local load in directory.", + (gptr*) &dirname_for_local_load, (gptr*) &dirname_for_local_load, 0, GET_STR_ALLOC, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index b21a73aae4f..00767ae98a7 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -67,9 +67,9 @@ static struct my_option my_long_options[] = (gptr*) &opt_auto_repair, (gptr*) &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are", (gptr*) &charsets_dir, + "Directory where character sets are.", (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"check", 'c', "Check table for errors", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, + {"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"check-only-changed", 'C', "Check only tables that have changed since last check or haven't been closed properly.", @@ -81,12 +81,12 @@ static struct my_option my_long_options[] = "To check several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames.", (gptr*) &opt_databases, (gptr*) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'", + {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, - "Set the default character set", (gptr*) &default_charset, + "Set the default character set.", (gptr*) &default_charset, (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"fast",'F', "Check only tables that haven't been closed properly", + {"fast",'F', "Check only tables that haven't been closed properly.", (gptr*) &opt_fast, (gptr*) &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Continue even if we get an sql-error.", @@ -115,7 +115,7 @@ static struct my_option my_long_options[] = {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"quick", 'q', "If you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table.", @@ -126,7 +126,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"silent", 's', "Print only error messages.", (gptr*) &opt_silent, diff --git a/client/mysqldump.c b/client/mysqldump.c index 67e83d58768..82737836485 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -132,7 +132,7 @@ static struct my_option my_long_options[] = "Allow creation of column names that are keywords.", (gptr*) &opt_keywords, (gptr*) &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are", (gptr*) &charsets_dir, + "Directory where character sets are.", (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compatible", OPT_COMPATIBLE, "Change the dump to be compatible with a given mode. By default tables are dumped without any restrictions. Legal modes are: mysql323, mysql40, postgresql, oracle, mssql, db2, sapdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires MySQL server version 4.1.0 or higher. This option does a no operation on earlier server versions.", @@ -204,9 +204,9 @@ static struct my_option my_long_options[] = {"single-transaction", OPT_TRANSACTION, "Dump all tables in single transaction to get consistent snapshot. Mutually exclusive with --lock-tables.", (gptr*) &opt_single_transaction, (gptr*) &opt_single_transaction, 0, - GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-create-db", 'n', - "'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be put in the output. The above line will be added otherwise, if --databases or --all-databases option was given.}", + "'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be put in the output. The above line will be added otherwise, if --databases or --all-databases option was given.}.", (gptr*) &opt_create_db, (gptr*) &opt_create_db, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-create-info", 't', "Don't write table creation info.", @@ -227,17 +227,17 @@ static struct my_option my_long_options[] = "Password to use when connecting to server. If password is not given it's solicited on the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __WIN__ - {"pipe", 'W', "Use named pipes to connect to server", 0, 0, 0, GET_NO_ARG, + {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"quick", 'q', "Don't buffer query, dump directly to stdout.", (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"quote-names",'Q', "Quote table and column names with a `", + {"quote-names",'Q', "Quote table and column names with backticks (`).", (gptr*) &opt_quoted, (gptr*) &opt_quoted, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"result-file", 'r', @@ -245,7 +245,7 @@ static struct my_option my_long_options[] = 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", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"skip-opt", OPT_SKIP_OPTIMIZATION, diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 8ee656f23b2..d049d69011b 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -59,7 +59,7 @@ static uint opt_protocol=0; static struct my_option my_long_options[] = { {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are", (gptr*) &charsets_dir, + "Directory where character sets are.", (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (gptr*) &default_charset, @@ -71,8 +71,8 @@ static struct my_option my_long_options[] = {"compress", 'C', "Use compression in server/client protocol.", (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"debug",'#', "Output debug log. Often this is 'd:t:o,filename'", 0, 0, 0, - GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug",'#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, + GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"delete", 'd', "First delete all rows from table.", (gptr*) &opt_delete, (gptr*) &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"fields-terminated-by", OPT_FTB, @@ -102,12 +102,12 @@ static struct my_option my_long_options[] = {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"local", 'L', "Read all files through the client", (gptr*) &opt_local_file, + {"local", 'L', "Read all files through the client.", (gptr*) &opt_local_file, (gptr*) &opt_local_file, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"lock-tables", 'l', "Lock all tables for write.", (gptr*) &lock_tables, (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"low-priority", OPT_LOW_PRIORITY, - "Use LOW_PRIORITY when updating the table", (gptr*) &opt_low_priority, + "Use LOW_PRIORITY when updating the table.", (gptr*) &opt_low_priority, (gptr*) &opt_low_priority, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", @@ -119,13 +119,13 @@ static struct my_option my_long_options[] = {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"replace", 'r', "If duplicate unique key was found, replace old row.", (gptr*) &replace, (gptr*) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent, 0, diff --git a/client/mysqlmanager-pwgen.c b/client/mysqlmanager-pwgen.c index 57d91b52f49..1d942e207ad 100644 --- a/client/mysqlmanager-pwgen.c +++ b/client/mysqlmanager-pwgen.c @@ -29,14 +29,14 @@ const char* outfile=0,*user="root"; static struct my_option my_long_options[] = { - {"output-file", 'o', "Write the output to the file with the given name", + {"output-file", 'o', "Write the output to the file with the given name.", (gptr*) &outfile, (gptr*) &outfile, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"user", 'u', "Put given user in the password file", (gptr*) &user, + {"user", 'u', "Put given user in the password file.", (gptr*) &user, (gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"help", '?', "Display this message and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, + {"help", '?', "Display this message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"version", 'V', "Display version info", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, + {"version", 'V', "Display version info.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 5bb611b713f..9dc5c0a30f4 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -155,16 +155,16 @@ int main(int argc, char **argv) static struct my_option my_long_options[] = { - {"character-sets-dir", 'c', "Directory where character sets are", + {"character-sets-dir", 'c', "Directory where character sets are.", (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (gptr*) &default_charset, (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"compress", 'C', "Use compression in server/client protocol", + {"compress", 'C', "Use compression in server/client protocol.", (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'", + {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -173,10 +173,10 @@ static struct my_option my_long_options[] = {"status", 'i', "Shows a lot of extra information about each table.", (gptr*) &opt_status, (gptr*) &opt_status, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"keys", 'k', "Show keys for table", (gptr*) &opt_show_keys, + {"keys", 'k', "Show keys for table.", (gptr*) &opt_show_keys, (gptr*) &opt_show_keys, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', - "Password to use when connecting to server. If password is not given it's asked from the tty.", + "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, @@ -185,11 +185,11 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 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", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"socket", 'S', "Socket file to use for connection.", @@ -207,7 +207,7 @@ static struct my_option my_long_options[] = NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; - + static void print_version(void) { diff --git a/client/mysqltest.c b/client/mysqltest.c index 517c41c2b18..03a8206276f 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1808,34 +1808,34 @@ int read_query(struct st_query** q_ptr) static struct my_option my_long_options[] = { - {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'", + {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"database", 'D', "Database to use.", (gptr*) &db, (gptr*) &db, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"basedir", 'b', "Basedir for tests", (gptr*) &opt_basedir, + {"basedir", 'b', "Basedir for tests.", (gptr*) &opt_basedir, (gptr*) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"big-test", 'B', "Define BIG_TEST to 1", (gptr*) &opt_big_test, + {"big-test", 'B', "Define BIG_TEST to 1.", (gptr*) &opt_big_test, (gptr*) &opt_big_test, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"compress", 'C', "Use the compressed server/client protocol", + {"compress", 'C', "Use the compressed server/client protocol.", (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"manager-user", OPT_MANAGER_USER, "Undocumented: Used for debugging", + {"manager-user", OPT_MANAGER_USER, "Undocumented: Used for debugging.", (gptr*) &manager_user, (gptr*) &manager_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"manager-host", OPT_MANAGER_HOST, "Undocumented: Used for debugging", + {"manager-host", OPT_MANAGER_HOST, "Undocumented: Used for debugging.", (gptr*) &manager_host, (gptr*) &manager_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"manager-password", OPT_MANAGER_PASSWD, "Undocumented: Used for debugging", + {"manager-password", OPT_MANAGER_PASSWD, "Undocumented: Used for debugging.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"manager-port", OPT_MANAGER_PORT, "Undocumented: Used for debugging", + {"manager-port", OPT_MANAGER_PORT, "Undocumented: Used for debugging.", (gptr*) &manager_port, (gptr*) &manager_port, 0, GET_INT, REQUIRED_ARG, MYSQL_MANAGER_PORT, 0, 0, 0, 0, 0}, {"manager-wait-timeout", OPT_MANAGER_WAIT_TIMEOUT, - "Undocumented: Used for debugging", (gptr*) &manager_wait_timeout, + "Undocumented: Used for debugging.", (gptr*) &manager_wait_timeout, (gptr*) &manager_wait_timeout, 0, GET_INT, REQUIRED_ARG, 3, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -1848,16 +1848,16 @@ static struct my_option my_long_options[] = {"result-file", 'R', "Read/Store result from/in this file.", (gptr*) &result_file, (gptr*) &result_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"server-arg", 'A', "Send enbedded server this as a paramenter", + {"server-arg", 'A', "Send enbedded server this as a paramenter.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"server-file", 'F', "Read embedded server arguments from file", + {"server-file", 'F', "Read embedded server arguments from file.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"silent", 's', "Suppress all normal output. Synonym for --quiet.", (gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-safemalloc", OPT_SKIP_SAFEMALLOC, - "Don't use the memory allocation checking", 0, 0, 0, GET_NO_ARG, NO_ARG, + "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"sleep", 'T', "Sleep always this many seconds on sleep commands", + {"sleep", 'T', "Sleep always this many seconds on sleep commands.", (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", @@ -1866,7 +1866,7 @@ static struct my_option my_long_options[] = #include "sslopt-longopts.h" {"test-file", 'x', "Read test from/in this file (default stdin).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"tmpdir", 't', "Temporary directory where sockets are put", + {"tmpdir", 't', "Temporary directory where sockets are put.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"user", 'u', "User for login.", (gptr*) &user, (gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -1877,7 +1877,6 @@ static struct my_option my_long_options[] = { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; - static void print_version(void) { printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,MTEST_VERSION, diff --git a/client/sql_string.h b/client/sql_string.h index 33f34a43b7f..aec40466d2b 100644 --- a/client/sql_string.h +++ b/client/sql_string.h @@ -92,6 +92,14 @@ public: Ptr[str_length]=0; return Ptr; } + inline char *c_ptr_safe() + { + if (Ptr && str_length < Alloced_length) + Ptr[str_length]=0; + else + (void) realloc(str_length); + return Ptr; + } void set(String &str,uint32 offset,uint32 arg_length) { diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index c0f8a54f432..a5ce489c0fd 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -29,21 +29,21 @@ const char *config_file="my"; /* Default config file */ static struct my_option my_long_options[] = { - {"config-file", 'c', "The config file to be used", + {"config-file", 'c', "The config file to be used.", (gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"defaults-file", 'c', "Synonym for --config-file", + {"defaults-file", 'c', "Synonym for --config-file.", (gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"defaults-extra-file", 'e', + {"defaults-extra-file", 'e', "Read this file after the global /etc config file and before the config file in the users home directory.", (gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"extra-file", 'e', - "Synonym for --defaults-extra-file", + {"extra-file", 'e', + "Synonym for --defaults-extra-file.", (gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"no-defaults", 'n', "Return an empty string (useful for scripts)", + {"no-defaults", 'n', "Return an empty string (useful for scripts).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -52,7 +52,6 @@ static struct my_option my_long_options[] = {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; - static void usage(my_bool version) { printf("%s Ver 1.5 for %s at %s\n",my_progname,SYSTEM_TYPE, diff --git a/extra/perror.c b/extra/perror.c index a2951bff66a..1e47364bc5e 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -30,14 +30,14 @@ static struct my_option my_long_options[] = { {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"info", 'I', "Synonym for --help", 0, 0, 0, GET_NO_ARG, + {"info", 'I', "Synonym for --help.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SYS_ERRLIST {"all", 'a', "Print all the error messages and the number.", (gptr*) &print_all_codes, (gptr*) &print_all_codes, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"silent", 's', "Only print the error message", 0, 0, 0, GET_NO_ARG, NO_ARG, + {"silent", 's', "Only print the error message.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Print error code and message (default).", (gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, diff --git a/extra/resolveip.c b/extra/resolveip.c index 95861bca2bc..cef79180720 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -43,7 +43,7 @@ static struct my_option my_long_options[] = { {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"info", 'I', "Synonym for --help", + {"info", 'I', "Synonym for --help.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/include/mysql.h b/include/mysql.h index 374ac9b8959..337e080e4cc 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -135,9 +135,9 @@ typedef struct st_mysql_data { } MYSQL_DATA; struct st_mysql_options { - unsigned int connect_timeout; + unsigned int connect_timeout, read_timeout, write_timeout; + unsigned int port, protocol; unsigned long client_flag; - unsigned int port; char *host,*user,*password,*unix_socket,*db; struct st_dynamic_array *init_commands; char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name; @@ -146,6 +146,7 @@ struct st_mysql_options { char *ssl_ca; /* PEM CA file */ char *ssl_capath; /* PEM directory of CA-s? */ char *ssl_cipher; /* cipher to use */ + char *shared_memory_base_name; unsigned long max_allowed_packet; my_bool use_ssl; /* if to use SSL or not */ my_bool compress,named_pipe; @@ -167,18 +168,15 @@ struct st_mysql_options { #ifdef EMBEDDED_LIBRARY my_bool separate_thread; #endif - char *shared_memory_base_name; - unsigned int protocol; }; enum mysql_option { - MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND, - MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, - MYSQL_OPT_LOCAL_INFILE, MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME -#ifdef EMBEDDED_LIBRARY - , MYSQL_OPT_USE_RESULT -#endif + MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, + MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, + MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE, + MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT, + MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT }; enum mysql_status @@ -188,8 +186,8 @@ enum mysql_status enum mysql_protocol_type { - MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET, MYSQL_PROTOCOL_PIPE, - MYSQL_PROTOCOL_MEMORY + 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 diff --git a/include/mysql_com.h b/include/mysql_com.h index faa025c934e..e87001ff27d 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -25,7 +25,7 @@ #define HOSTNAME_LENGTH 60 #define USERNAME_LENGTH 16 #define SERVER_VERSION_LENGTH 60 -#define SQLSTATE_LENGTH 6 +#define SQLSTATE_LENGTH 5 #define LOCAL_HOST "localhost" #define LOCAL_HOST_NAMEDPIPE "." @@ -110,6 +110,7 @@ enum enum_server_command #define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ #define CLIENT_MULTI_QUERIES 65536 /* Enable/disable multiquery support */ #define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */ +#define CLIENT_REMEMBER_OPTIONS (1L << 31) #define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ diff --git a/include/sql_common.h b/include/sql_common.h index 65283486fb4..f3300281f29 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -42,9 +42,5 @@ my_bool mysql_reconnect(MYSQL *mysql); } #endif -#ifdef MYSQL_SERVER -#define protocol_41(A) FALSE -#else #define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41) -#endif diff --git a/include/sql_state.h b/include/sql_state.h index cc0fab7bfce..c998beaf578 100644 --- a/include/sql_state.h +++ b/include/sql_state.h @@ -86,7 +86,6 @@ ER_UNSUPPORTED_EXTENSION, "42000", "", ER_TABLE_MUST_HAVE_COLUMNS, "42000", "", ER_UNKNOWN_CHARACTER_SET, "42000", "", ER_TOO_BIG_ROWSIZE, "42000", "", -ER_STACK_OVERRUN, "HY000", "", ER_WRONG_OUTER_JOIN, "42000", "", ER_NULL_COLUMN_IN_INDEX, "42000", "", ER_PASSWORD_ANONYMOUS_USER, "42000", "", @@ -128,8 +127,6 @@ ER_REQUIRES_PRIMARY_KEY, "42000", "", ER_CHECK_NO_SUCH_TABLE, "42000", "", ER_CHECK_NOT_IMPLEMENTED, "42000", "", ER_CANT_DO_THIS_DURING_AN_TRANSACTION, "25000", "", -ER_ERROR_DURING_COMMIT, "HY000", "", -ER_ERROR_DURING_ROLLBACK, "HY000", "", ER_NEW_ABORTING_CONNECTION, "08S01", "", ER_MASTER_NET_READ, "08S01", "", ER_MASTER_NET_WRITE, "08S01", "", diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index 397d8baa9d6..dc3b0922327 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -17,24 +17,24 @@ #ifdef HAVE_OPENSSL {"ssl", OPT_SSL_SSL, - "Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl", + "Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl.", (gptr*) &opt_use_ssl, (gptr*) &opt_use_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl)", + {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl).", (gptr*) &opt_ssl_key, (gptr*) &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl)", + {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl).", (gptr*) &opt_ssl_cert, (gptr*) &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ssl-ca", OPT_SSL_CA, - "CA file in PEM format (check OpenSSL docs, implies --ssl)", + "CA file in PEM format (check OpenSSL docs, implies --ssl).", (gptr*) &opt_ssl_ca, (gptr*) &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ssl-capath", OPT_SSL_CAPATH, - "CA directory (check OpenSSL docs, implies --ssl)", + "CA directory (check OpenSSL docs, implies --ssl).", (gptr*) &opt_ssl_capath, (gptr*) &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use (implies --ssl)", + {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use (implies --ssl).", (gptr*) &opt_ssl_cipher, (gptr*) &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index 47d5185b6ca..17e992be5b0 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -15,27 +15,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -static my_bool mysql_client_init=0; -extern uint mysql_port; -extern my_string mysql_unix_port; +#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | \ + CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS | \ + CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) -#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \ - | CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS \ - | CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) - - -#ifdef __WIN__ -#define CONNECT_TIMEOUT 20 -#else -#define CONNECT_TIMEOUT 0 -#endif - -#ifdef HAVE_SMEM -char *shared_memory_base_name=0; -const char *def_shared_memory_base_name=default_shared_memory_base_name; -#endif - -static my_bool org_my_init_done=0; sig_handler pipe_sig_handler(int sig __attribute__((unused))); my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 7e379ab63ba..771278c1dbb 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -59,24 +59,11 @@ #include <sql_common.h> -uint mysql_port=0; -my_string mysql_unix_port=0; ulong net_buffer_length=8192; ulong max_allowed_packet= 1024L*1024L*1024L; ulong net_read_timeout= NET_READ_TIMEOUT; ulong net_write_timeout= NET_WRITE_TIMEOUT; -#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \ - | CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS \ - | CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) - - -#ifdef __WIN__ -#define CONNECT_TIMEOUT 20 -#else -#define CONNECT_TIMEOUT 0 -#endif - #if defined(MSDOS) || defined(__WIN__) /* socket_errno is defined in my_global.h for all platforms */ #define perror(A) @@ -85,10 +72,6 @@ ulong net_write_timeout= NET_WRITE_TIMEOUT; #define SOCKET_ERROR -1 #endif /* __WIN__ */ -const char *sql_protocol_names_lib[] = -{ "TCP", "SOCKET", "PIPE", "MEMORY", NullS }; -TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"", - sql_protocol_names_lib}; /* If allowed through some configuration, then this needs to be changed @@ -101,7 +84,67 @@ sig_handler pipe_sig_handler(int sig); static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, const char *from, ulong length); my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list); -static my_bool org_my_init_done=0; + +/* + Initialize the MySQL library + + SYNOPSIS + mysql_once_init() + + NOTES + Can't be static on NetWare + This function is called by mysql_init() and indirectly called + by mysql_real_query(), so one should never have to call this from an + outside program. +*/ + +static my_bool mysql_client_init= 0; +static my_bool org_my_init_done= 0; + +void mysql_once_init(void) +{ + if (!mysql_client_init) + { + mysql_client_init=1; + org_my_init_done=my_init_done; + my_init(); /* Will init threads */ + init_client_errs(); + if (!mysql_port) + { + mysql_port = MYSQL_PORT; +#ifndef MSDOS + { + struct servent *serv_ptr; + char *env; + if ((serv_ptr = getservbyname("mysql", "tcp"))) + mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); + if ((env = getenv("MYSQL_TCP_PORT"))) + mysql_port =(uint) atoi(env); + } +#endif + } + if (!mysql_unix_port) + { + char *env; +#ifdef __WIN__ + mysql_unix_port = (char*) MYSQL_NAMEDPIPE; +#else + mysql_unix_port = (char*) MYSQL_UNIX_ADDR; +#endif + if ((env = getenv("MYSQL_UNIX_PORT"))) + mysql_unix_port = env; + } + mysql_debug(NullS); +#if defined(SIGPIPE) && !defined(THREAD) && !defined(__WIN__) + (void) signal(SIGPIPE,SIG_IGN); +#endif + } +#ifdef THREAD + else + my_thread_init(); /* Init if new thread */ +#endif +} + int STDCALL mysql_server_init(int argc __attribute__((unused)), char **argv __attribute__((unused)), @@ -529,30 +572,6 @@ STDCALL mysql_rpl_query_type(const char* q, int len) return MYSQL_RPL_MASTER; /* By default, send to master */ } -/* - Fill in SSL part of MYSQL structure and set 'use_ssl' flag. - NB! Errors are not reported until you do mysql_real_connect. -*/ - -#define strdup_if_not_null(A) (A) == 0 ? 0 : my_strdup((A),MYF(MY_WME)) - -my_bool STDCALL -mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , - const char *key __attribute__((unused)), - const char *cert __attribute__((unused)), - const char *ca __attribute__((unused)), - const char *capath __attribute__((unused)), - const char *cipher __attribute__((unused))) -{ -#ifdef HAVE_OPENSSL - mysql->options.ssl_key= strdup_if_not_null(key); - mysql->options.ssl_cert= strdup_if_not_null(cert); - mysql->options.ssl_ca= strdup_if_not_null(ca); - mysql->options.ssl_capath= strdup_if_not_null(capath); - mysql->options.ssl_cipher= strdup_if_not_null(cipher); -#endif /* HAVE_OPENSSL */ - return 0; -} /************************************************************************** Connect to sql server @@ -578,6 +597,7 @@ mysql_connect(MYSQL *mysql,const char *host, } #endif + /************************************************************************** Change user and database **************************************************************************/ @@ -836,56 +856,6 @@ STDCALL mysql_add_slave(MYSQL* mysql, const char* host, return 0; } -/************************************************************************** - Alloc struct for use with unbuffered reads. Data is fetched by domand - when calling to mysql_fetch_row. - mysql_data_seek is a noop. - - No other queries may be specified with the same MYSQL handle. - There shouldn't be much processing per row because mysql server shouldn't - have to wait for the client (and will not wait more than 30 sec/packet). -**************************************************************************/ - -MYSQL_RES * STDCALL -mysql_use_result(MYSQL *mysql) -{ - MYSQL_RES *result; - DBUG_ENTER("mysql_use_result"); - - mysql = mysql->last_used_con; - - if (!mysql->fields) - DBUG_RETURN(0); - if (mysql->status != MYSQL_STATUS_GET_RESULT) - { - strmov(mysql->net.sqlstate, unknown_sqlstate); - strmov(mysql->net.last_error, - ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); - DBUG_RETURN(0); - } - if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result)+ - sizeof(ulong)*mysql->field_count, - MYF(MY_WME | MY_ZEROFILL)))) - DBUG_RETURN(0); - result->lengths=(ulong*) (result+1); - if (!(result->row=(MYSQL_ROW) - my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME)))) - { /* Ptrs: to one row */ - my_free((gptr) result,MYF(0)); - DBUG_RETURN(0); - } - result->fields= mysql->fields; - result->field_alloc= mysql->field_alloc; - result->field_count= mysql->field_count; - result->current_field=0; - result->handle= mysql; - result->current_row= 0; - mysql->fields=0; /* fields is now in result */ - mysql->status=MYSQL_STATUS_USE_RESULT; - DBUG_RETURN(result); /* Data is read to be fetched */ -} - - /************************************************************************** Return next field of the query results @@ -899,6 +869,13 @@ mysql_fetch_field(MYSQL_RES *result) return &result->fields[result->current_field++]; } + +/************************************************************************** + Get column lengths of the current row + If one uses mysql_use_result, res->lengths contains the length information, + else the lengths are calculated from the offset between pointers. +**************************************************************************/ + ulong * STDCALL mysql_fetch_lengths(MYSQL_RES *res) { @@ -911,6 +888,23 @@ mysql_fetch_lengths(MYSQL_RES *res) return res->lengths; } + +/************************************************************************** + Move to a specific row and column +**************************************************************************/ + +void STDCALL +mysql_data_seek(MYSQL_RES *result, my_ulonglong row) +{ + MYSQL_ROWS *tmp=0; + DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row)); + if (result->data) + for (tmp=result->data->data; row-- && tmp ; tmp = tmp->next) ; + result->current_row=0; + result->data_cursor = tmp; +} + + /************************************************************************* put the row or field cursor one a position one got from mysql_row_tell() This doesn't restore any data. The next mysql_fetch_row or @@ -935,6 +929,7 @@ mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET field_offset) return return_value; } + /***************************************************************************** List all databases *****************************************************************************/ @@ -2444,7 +2439,7 @@ static void send_data_long(MYSQL_BIND *param, longlong value) } default: { - char tmp[12]; + char tmp[22]; /* Enough for longlong */ uint length= (uint)(longlong10_to_str(value,(char *)tmp,10)-tmp); ulong copy_length= min((ulong)length-param->offset, param->buffer_length); memcpy(buffer, (char *)tmp+param->offset, copy_length); @@ -2492,7 +2487,7 @@ static void send_data_double(MYSQL_BIND *param, double value) } default: { - char tmp[12]; + char tmp[128]; uint length= my_sprintf(tmp,(tmp,"%g",value)); ulong copy_length= min((ulong)length-param->offset, param->buffer_length); memcpy(buffer, (char *)tmp+param->offset, copy_length); diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c index 67a99468645..57ae67c7a02 100644 --- a/myisam/ft_dump.c +++ b/myisam/ft_dump.c @@ -34,21 +34,23 @@ static uint lengths[256]; static struct my_option my_long_options[] = { - {"dump", 'd', "Dump index (incl. data offsets and word weights)", + {"dump", 'd', "Dump index (incl. data offsets and word weights).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"stats", 's', "Report global stats", + {"stats", 's', "Report global stats.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Be verbose", + {"verbose", 'v', "Be verbose.", (gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"count", 'c', "Calculate per-word stats (counts and global weights)", + {"count", 'c', "Calculate per-word stats (counts and global weights).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"length", 'l', "Report length distribution", + {"length", 'l', "Report length distribution.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"execute", 'e', "Execute given query", (gptr*) &query, (gptr*) &query, 0, +#ifdef DISABLED + {"execute", 'e', "Execute given query.", (gptr*) &query, (gptr*) &query, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"help", 'h', "Display help and exit", +#endif + {"help", 'h', "Display help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"help", '?', "Synonym for -h", + {"help", '?', "Synonym for -h.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 834ad818972..72b2567278e 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -163,7 +163,7 @@ static struct my_option my_long_options[] = "No help available.", 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"backup", 'B', - "Make a backup of the .MYD file as 'filename-time.BAK'", + "Make a backup of the .MYD file as 'filename-time.BAK'.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, "Directory where character sets are.", @@ -209,7 +209,7 @@ static struct my_option my_long_options[] = "Print statistics information about table that is checked.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"keys-used", 'k', - "Tell MyISAM to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts!", + "Tell MyISAM to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts.", (gptr*) &check_param.keys_in_use, (gptr*) &check_param.keys_in_use, 0, GET_ULL, REQUIRED_ARG, -1, 0, 0, 0, 0, 0}, @@ -225,7 +225,7 @@ static struct my_option my_long_options[] = "Can fix almost anything except unique keys that aren't unique.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"parallel-recover", 'p', - "Same as '-r' but creates all the keys in parallel", + "Same as '-r' but creates all the keys in parallel.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"safe-recover", 'o', "Uses old recovery method; Slower than '-r' but can handle a couple of cases where '-r' reports that it can't fix the data file.", @@ -337,9 +337,9 @@ static void usage(void) puts("Used without options all tables on the command will be checked for errors"); printf("Usage: %s [OPTIONS] tables[.MYI]\n", my_progname_short); puts("\nGlobal options:\n\ - -#, --debug=... Output debug log. Often this is 'd:t:o,filename'\n\ + -#, --debug=... Output debug log. Often this is 'd:t:o,filename'.\n\ -?, --help Display this help and exit.\n\ - -O, --set-variable var=option\n\ + -O, --set-variable var=option.\n\ Change the value of a variable. Please note that\n\ this option is deprecated; you can set variables\n\ directly with '--variable-name=value'.\n\ @@ -353,9 +353,9 @@ static void usage(void) ", they will be used\n\ in a round-robin fashion.\n\ -s, --silent Only print errors. One can use two -s to make\n\ - myisamchk very silent\n\ + myisamchk very silent.\n\ -v, --verbose Print more information. This can be used with\n\ - --description and --check. Use many -v for more verbosity!\n\ + --description and --check. Use many -v for more verbosity.\n\ -V, --version Print version and exit.\n\ -w, --wait Wait if table is locked.\n"); #ifdef DEBUG @@ -363,33 +363,33 @@ static void usage(void) #endif puts("Check options (check is the default action for myisamchk):\n\ - -c, --check Check table for errors\n\ + -c, --check Check table for errors.\n\ -e, --extend-check Check the table VERY throughly. Only use this in\n\ extreme cases as myisamchk should normally be able to\n\ - find out if the table is ok even without this switch\n\ - -F, --fast Check only tables that haven't been closed properly\n\ + find out if the table is ok even without this switch.\n\ + -F, --fast Check only tables that haven't been closed properly.\n\ -C, --check-only-changed\n\ - Check only tables that have changed since last check\n\ + Check only tables that have changed since last check.\n\ -f, --force Restart with '-r' if there are any errors in the table.\n\ - States will be updated as with '--update-state'\n\ - -i, --information Print statistics information about table that is checked\n\ + States will be updated as with '--update-state'.\n\ + -i, --information Print statistics information about table that is checked.\n\ -m, --medium-check Faster than extend-check, but only finds 99.99% of\n\ - all errors. Should be good enough for most cases\n\ - -U --update-state Mark tables as crashed if you find any errors\n\ - -T, --read-only Don't mark table as checked\n"); + all errors. Should be good enough for most cases.\n\ + -U --update-state Mark tables as crashed if you find any errors.\n\ + -T, --read-only Don't mark table as checked.\n"); - puts("Repair options (When using '-r' or '-o') \n\ - -B, --backup Make a backup of the .MYD file as 'filename-time.BAK'\n\ + puts("Repair options (When using '-r' or '-o'):\n\ + -B, --backup Make a backup of the .MYD file as 'filename-time.BAK'.\n\ --correct-checksum Correct checksum information for table.\n\ -D, --data-file-length=# Max length of data file (when recreating data\n\ - file when it's full)\n\ + file when it's full).\n\ -e, --extend-check Try to recover every possible row from the data file\n\ Normally this will also find a lot of garbage rows;\n\ Don't use this option if you are not totally desperate.\n\ -f, --force Overwrite old temporary files.\n\ -k, --keys-used=# Tell MyISAM to update only some specific keys. # is a\n\ bit mask of which keys to use. This can be used to\n\ - get faster inserts!\n\ + get faster inserts.\n\ -r, --recover Can fix almost anything except unique keys that aren't\n\ unique.\n\ -n, --sort-recover Forces recovering with sorting even if the temporary\n\ @@ -397,17 +397,16 @@ static void usage(void) -p, --parallel-recover\n\ Uses the same technique as '-r' and '-n', but creates\n\ all the keys in parallel, in different threads.\n\ - THIS IS ALPHA CODE. USE AT YOUR OWN RISK!\n\ -o, --safe-recover Uses old recovery method; Slower than '-r' but can\n\ handle a couple of cases where '-r' reports that it\n\ can't fix the data file.\n\ --character-sets-dir=...\n\ - Directory where character sets are\n\ + Directory where character sets are.\n\ --set-character-set=name\n\ - Change the character set used by the index\n\ + Change the character set used by the index.\n\ -q, --quick Faster repair by not modifying the data file.\n\ One can give a second '-q' to force myisamchk to\n\ - modify the original datafile in case of duplicate keys\n\ + modify the original datafile in case of duplicate keys.\n\ -u, --unpack Unpack file packed with myisampack.\n\ "); @@ -421,11 +420,11 @@ static void usage(void) If no value is given, then sets the next auto_increment\n\ value to the highest used value for the auto key + 1.\n\ -S, --sort-index Sort index blocks. This speeds up 'read-next' in\n\ - applications\n\ + applications.\n\ -R, --sort-records=#\n\ Sort records according to an index. This makes your\n\ data much more localized and may speed up things\n\ - (It may be VERY slow to do a sort the first time!)\n\ + (It may be VERY slow to do a sort the first time!).\n\ -b, --block-search=#\n\ Find a record, a block at given offset belongs to."); diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 3eded3b52f2..21b73ce244d 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -235,12 +235,12 @@ enum options_mp {OPT_CHARSETS_DIR_MP=256}; static struct my_option my_long_options[] = { - {"backup", 'b', "Make a backup of the table as table_name.OLD", + {"backup", 'b', "Make a backup of the table as table_name.OLD.", (gptr*) &backup, (gptr*) &backup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR_MP, "Directory where character sets are.", (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'", + {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Force packing of table even if it gets bigger or if tempfile exists.", diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index bd15c913d2e..5553f718799 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -143,5 +143,5 @@ insert into t1 values (NULL, 10); ERROR 23000: Duplicate entry '10' for key 2 select last_insert_id(); last_insert_id() -3 +0 drop table t1; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index caf93e7e973..157beec2c01 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -172,9 +172,9 @@ CREATE TABLE t1 ( id int(11) auto_increment, title varchar(100) default '', PRIMARY KEY (id), -KEY ind5 (title), -FULLTEXT KEY FT1 (title) +KEY ind5 (title) ) TYPE=MyISAM; +CREATE FULLTEXT INDEX ft1 ON t1(title); insert into t1 (title) values ('this is a test'); select * from t1 where match title against ('test' in boolean mode); id title diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 40ac7f905c7..d06e2dce0a1 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -135,10 +135,10 @@ CREATE TABLE t1 ( id int(11) auto_increment, title varchar(100) default '', PRIMARY KEY (id), - KEY ind5 (title), - FULLTEXT KEY FT1 (title) + KEY ind5 (title) ) TYPE=MyISAM; +CREATE FULLTEXT INDEX ft1 ON t1(title); insert into t1 (title) values ('this is a test'); select * from t1 where match title against ('test' in boolean mode); update t1 set title='this is A test' where id=1; diff --git a/mysys/charset.c b/mysys/charset.c index ad0468a5087..7dab1a38325 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -368,6 +368,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags) char *get_charsets_dir(char *buf) { const char *sharedir= SHAREDIR; + char *res; DBUG_ENTER("get_charsets_dir"); if (charsets_dir != NULL) @@ -381,9 +382,9 @@ char *get_charsets_dir(char *buf) strxmov(buf, DEFAULT_CHARSET_HOME, "/", sharedir, "/", CHARSET_DIR, NullS); } - convert_dirname(buf,buf,NullS); + res= convert_dirname(buf,buf,NullS); DBUG_PRINT("info",("charsets dir: '%s'", buf)); - DBUG_RETURN(strend(buf)); + DBUG_RETURN(res); } CHARSET_INFO *all_charsets[256]; @@ -613,6 +614,9 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name, { CHARSET_INFO *cs=NULL; CHARSET_INFO **css; + DBUG_ENTER("get_charset_by_csname"); + DBUG_PRINT("enter",("name: '%s'", cs_name)); + (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ for (css= all_charsets; css < all_charsets+255; ++css) @@ -624,7 +628,7 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name, cs= css[0]->number ? get_internal_charset(css[0]->number,flags) : NULL; break; } - } + } if (!cs && (flags & MY_WME)) { @@ -633,5 +637,5 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name, my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_name, index_file); } - return cs; + DBUG_RETURN(cs); } diff --git a/mysys/errors.c b/mysys/errors.c index 8a120e0e869..a2226fc12c5 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -82,7 +82,7 @@ void init_glob_errs() EE(EE_OPEN_WARNING) = "%d files and %d streams is left open\n"; EE(EE_DISK_FULL) = "Disk is full writing '%s'. Waiting for someone to free space..."; EE(EE_CANT_MKDIR) ="Can't create directory '%s' (Errcode: %d)"; - EE(EE_UNKNOWN_CHARSET)= "Character set is not a compiled character set and is not specified in the %s file"; + EE(EE_UNKNOWN_CHARSET)= "Character set '%s' is not a compiled character set and is not specified in the %s file"; EE(EE_OUT_OF_FILERESOURCES)="Out of resources when opening file '%s' (Errcode: %d)"; EE(EE_CANT_READLINK)="Can't read value for symlink '%s' (Error %d)"; EE(EE_CANT_SYMLINK)="Can't create symlink '%s' pointing at '%s' (Error %d)"; diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index a6312193221..1be301ee92a 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -12,6 +12,7 @@ CP="cp -p" DEBUG=0 SILENT=0 SUFFIX="" +DIRNAME="" OUTTAR=0 # @@ -58,6 +59,8 @@ show_usage() echo "" echo " --debug Debug, without creating the package" echo " --tmp Specify the temporary location" + echo " --suffix Suffix name for the package" + echo " --dirname Directory name to copy files (intermediate)" echo " --silent Do not list verbosely files processed" echo " --tar Create tar.gz package instead of .zip" echo " --help Show this help message" @@ -75,6 +78,7 @@ parse_arguments() { --debug) DEBUG=1;; --tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;; --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;; + --dirname=*) DIRNAME=`echo "$arg" | sed -e "s;--dirname=;;"` ;; --silent) SILENT=1 ;; --tar) OUTTAR=1 ;; --help) show_usage ;; @@ -155,11 +159,15 @@ mkdir $BASE/Docs $BASE/extra $BASE/include # Copy directory files # -copy_dir_files() { - +copy_dir_files() +{ for arg do print_debug "Copying files from directory '$arg'" - cd $SOURCE/$arg/ + cd $SOURCE/$arg + if [ ! -d $BASE/$arg ]; then + print_debug "Creating directory '$arg'" + mkdir $BASE/$arg + fi for i in *.c *.cpp *.h *.ih *.i *.ic *.asm *.def \ README INSTALL* LICENSE do @@ -199,9 +207,6 @@ copy_dir_dirs() { for i in * do if [ -d $SOURCE/$basedir/$i ] && [ "$i" != "SCCS" ]; then - if [ ! -d $BASE/$basedir/$i ]; then - mkdir $BASE/$basedir/$i - fi copy_dir_files $basedir/$i fi done @@ -214,7 +219,7 @@ copy_dir_dirs() { for i in client dbug extra heap include isam \ libmysql libmysqld merge myisam \ - myisammrg mysys regex sql strings \ + myisammrg mysys regex sql strings sql-common \ vio zlib do copy_dir_files $i @@ -246,7 +251,7 @@ touch $BASE/innobase/ib_config.h cd $SOURCE for i in COPYING ChangeLog README \ INSTALL-SOURCE INSTALL-WIN \ - INSTALL-SOURCE-WIN \ + INSTALL-WIN-SOURCE Docs/manual_toc.html Docs/manual.html \ Docs/mysqld_error.txt Docs/INSTALL-BINARY @@ -270,15 +275,19 @@ done if [ -f scripts/mysql_install_db ]; then print_debug "Initializing the 'data' directory" - scripts/mysql_install_db --windows --datadir=$BASE/data + scripts/mysql_install_db --no-defaults --windows --datadir=$BASE/data fi - # # Specify the distribution package name and copy it # -NEW_DIR_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version$SUFFIX +if test -z $DIRNAME +then + NEW_DIR_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version$SUFFIX +else + NEW_DIR_NAME=$DIRNAME +fi NEW_NAME=$NEW_DIR_NAME-win-src BASE2=$TMP/$NEW_DIR_NAME @@ -345,7 +354,7 @@ set_tarzip_options() EXT=".zip" NEED_COMPRESS=0 if [ "$SILENT" = "1" ] ; then - OPT="-r" + OPT="$OPT -q" fi fi done @@ -386,9 +395,7 @@ fi print_debug "Removing temporary directory" rm -r -f $BASE -echo "$NEW_NAME$EXT created successfully !!" - +if [ "$SILENT" = "0" ] ; then + echo "$NEW_NAME$EXT created successfully !!" +fi # End of script - - - diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index c54394305cd..51fbb8a8097 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -1,6 +1,5 @@ #!/bin/sh - -# Copyright (C) 1997-2002 MySQL AB +# Copyright (C) 1997-2003 MySQL AB # For a more info consult the file COPYRIGHT distributed with this file # This script writes on stdout SQL commands to generate all not @@ -12,7 +11,7 @@ # $3 - hostname # $4 - windows option -if test x$1 = x"" ; +if test "$1" = "" then echo " This script writes on stdout SQL commands to generate all not @@ -20,9 +19,9 @@ existing MySQL system tables. It also replaces the help tables with new context from the manual (from fill_help_tables.sql). Usage: - mysql_create_system_tables {help|real|verbose} <path to mysql-database directory> <hostname> <windows option> -"; - exit; + mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option> +" + exit fi mdata=$2 @@ -44,7 +43,7 @@ i_ht="" # Check for old tables if test ! -f $mdata/db.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing db table" 1>&2; fi @@ -76,7 +75,7 @@ fi if test ! -f $mdata/host.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing host table" 1>&2; fi @@ -102,7 +101,7 @@ fi if test ! -f $mdata/user.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing user table" 1>&2; fi @@ -142,7 +141,7 @@ then c_u="$c_u )" c_u="$c_u comment='Users and global privileges';" - if test x$1 = x"test" + if test "$1" = "test" then i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); @@ -165,7 +164,7 @@ fi if test ! -f $mdata/func.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing func table" 1>&2; fi @@ -181,7 +180,7 @@ fi if test ! -f $mdata/tables_priv.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing tables_priv table" 1>&2; fi @@ -202,7 +201,7 @@ fi if test ! -f $mdata/columns_priv.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing columns_priv table" 1>&2; fi @@ -221,7 +220,7 @@ fi if test ! -f $mdata/help_topic.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing help_topic table" 1>&2; fi @@ -242,7 +241,7 @@ old_categories="yes" if test ! -f $mdata/help_category.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing help_category table" 1>&2; fi @@ -259,7 +258,7 @@ fi if test ! -f $mdata/help_keyword.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing help_keyword table" 1>&2; fi @@ -274,7 +273,7 @@ fi if test ! -f $mdata/help_relation.frm then - if test x$1 = x"verbose" ; then + if test "$1" = "verbose" ; then echo "Preparing help_relation table" 1>&2; fi diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 96e33d3e7c5..9e4f35dd5e1 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -8,18 +8,8 @@ # All unrecognized arguments to this script are passed to mysqld. in_rpm=0 -case "$1" in - --rpm) - in_rpm="1"; shift - ;; -esac windows=0 -case "$1" in - --windows) - windows="1"; shift - ;; -esac -defaults= +defaults="" case "$1" in --no-defaults|--defaults-file=*|--defaults-extra-file=*) defaults="$1"; shift @@ -44,6 +34,8 @@ parse_arguments() { --ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --verbose) verbose=1 ;; + --rpm) in_rpm=1 ;; + --windows) windows=1 ;; *) if test -n "$pick_args" then @@ -61,6 +53,9 @@ parse_arguments() { if test -x ./bin/my_print_defaults then print_defaults="./bin/my_print_defaults" +elif test -x ./extra/my_print_defaults +then + print_defaults="./extra/my_print_defaults" elif test -x @bindir@/my_print_defaults then print_defaults="@bindir@/my_print_defaults" @@ -79,6 +74,7 @@ basedir= force=0 verbose=0 fill_help_tables="" + parse_arguments `$print_defaults $defaults mysqld mysql_install_db` parse_arguments PICK-ARGS-FROM-ARGV "$@" @@ -103,7 +99,7 @@ else fi # find fill_help_tables.sh -for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` @pkgdatadir@ +for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@ do if test -f $i/fill_help_tables.sql then @@ -115,22 +111,28 @@ if test -f $pkgdatadir/fill_help_tables.sql then fill_help_tables=$pkgdatadir/fill_help_tables.sql else - if test $verbose -eq 1 - then - echo "Could not find help file 'fill_help_tables.sql' ;$pkgdatadir; ;$basedir;". - fi + echo "Could not find help file 'fill_help_tables.sql' in @pkgdatadir@ or inside $basedir". + exit 1; fi mdata=$ldata/mysql +mysqld=$execdir/mysqld +mysqld_opt="" -if test "$windows" -eq 0 -a ! -x $execdir/mysqld +if test "$windows" = 1 +then + mysqld="./sql/mysqld" + mysqld_opt="--language=./sql/share/english" +fi + +if test ! -x $mysqld then if test "$in_rpm" -eq 1 then - echo "FATAL ERROR $execdir/mysqld not found!" + echo "FATAL ERROR $mysqld not found!" exit 1 else - echo "Didn't find $execdir/mysqld" + echo "Didn't find $mysqld" echo "You should do a 'make install' before executing this script" exit 1 fi @@ -184,23 +186,28 @@ else create_option="real" fi -echo "Installing all prepared tables" +if test "$in_rpm" -eq 0 -a "$windows" -eq 0 +then + echo "Installing all prepared tables" +fi if ( - mysql_create_system_tables $create_option $mdata $hostname $windows + $pkgdatadir/mysql_create_system_tables $create_option $mdata $hostname $windows if test -n "$fill_help_tables" then cat $fill_help_tables fi -) | eval "$execdir/mysqld $defaults --bootstrap --skip-grant-tables \ +) | eval "$mysqld $defaults $mysqld_opt --bootstrap --skip-grant-tables \ --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb $args" then - echo "" - if test "$in_rpm" -eq 0 || "$windows" -eq 0 + if test "$in_rpm" -eq 0 -a "$windows" -eq 0 then + echo "" echo "To start mysqld at boot time you have to copy support-files/mysql.server" echo "to the right place for your system" echo fi + if test "$windows" -eq 0 + then echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !" echo "This is done with:" echo "$bindir/mysqladmin -u root password 'new-password'" @@ -216,7 +223,7 @@ then echo "able to use the new GRANT command!" fi echo - if test "$in_rpm" -eq 0 -a "$windows" -eq 0 + if test "$in_rpm" -eq 0 then echo "You can start the MySQL daemon with:" echo "cd @prefix@ ; $bindir/mysqld_safe &" @@ -230,13 +237,14 @@ then echo "The latest information about MySQL is available on the web at" echo "http://www.mysql.com" echo "Support MySQL by buying support/licenses at https://order.mysql.com" + fi exit 0 else echo "Installation of grant tables failed!" echo echo "Examine the logs in $ldata for more information." echo "You can also try to start the mysqld daemon with:" - echo "$execdir/mysqld --skip-grant &" + echo "$mysqld --skip-grant &" echo "You can use the command line tool" echo "$bindir/mysql to connect to the mysql" echo "database and look at the grant tables:" diff --git a/sql-common/client.c b/sql-common/client.c index 3c025d18bd6..33f2b996971 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +/* Copyright (C) 2000-2003 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 @@ -37,13 +37,11 @@ #include <my_global.h> -#if defined(MYSQL_SERVER) || defined(HAVE_EXTERNAL_CLIENT) - #include "mysql.h" -#if !defined(MYSQL_SERVER) && defined(__WIN__) || defined(_WIN32) || defined(_WIN64) +#if !defined(MYSQL_SERVER) && (defined(__WIN__) || defined(_WIN32) || defined(_WIN64)) #include <winsock.h> #include <odbcinst.h> -#endif +#endif /* !defined(MYSQL_SERVER) && (defined(__WIN__) ... */ #include <my_sys.h> #include <mysys_err.h> #include <m_string.h> @@ -55,21 +53,19 @@ #include <assert.h> #if defined(THREAD) && !defined(__WIN__) #include <my_pthread.h> /* because of signal() */ -#endif +#endif /* defined(THREAD) && !defined(__WIN__) */ -#if defined( OS2) && defined(MYSQL_SERVER) +#if defined(OS2) && defined(MYSQL_SERVER) #undef ER #define ER CER -#endif +#endif /* defined( OS2) && defined(MYSQL_SERVER) */ #include <sys/stat.h> #include <signal.h> #include <time.h> - #ifdef HAVE_PWD_H #include <pwd.h> #endif - #if !defined(MSDOS) && !defined(__WIN__) #include <sys/socket.h> #include <netinet/in.h> @@ -96,16 +92,27 @@ #define SOCKET_ERROR -1 #endif +#ifdef __WIN__ +#define CONNECT_TIMEOUT 20 +#else +#define CONNECT_TIMEOUT 0 +#endif + #include "client_settings.h" #include <sql_common.h> -const char *unknown_sqlstate= "HY0000"; +uint mysql_port=0; +char *mysql_unix_port= 0; +const char *unknown_sqlstate= "HY000"; const char *not_error_sqlstate= "00000"; - -#ifdef MYSQL_CLIENT -extern my_bool stmt_close(MYSQL_STMT *stmt,my_bool skip_list); +#ifdef HAVE_SMEM +char *shared_memory_base_name= 0; +const char *def_shared_memory_base_name= default_shared_memory_base_name; #endif +static void mysql_close_free_options(MYSQL *mysql); +static void mysql_close_free(MYSQL *mysql); + /**************************************************************************** A modified version of connect(). my_connect() allows you to specify a timeout value, in seconds, that we should wait until we @@ -293,6 +300,7 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, } #endif + /* Create new shared memory connection, return handler of connection @@ -310,7 +318,8 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) /* event_connect_request is event object for start connection actions event_connect_answer is event object for confirm, that server put data - handle_connect_file_map is file-mapping object, use for create shared memory + handle_connect_file_map is file-mapping object, use for create shared + memory handle_connect_map is pointer on shared memory handle_map is pointer on shared memory for client event_server_wrote, @@ -505,7 +514,7 @@ net_safe_read(MYSQL *mysql) { NET *net= &mysql->net; ulong len=0; - init_sigpipe_variables; + init_sigpipe_variables /* Don't give sigpipe errors if the client doesn't want them */ set_sigpipe(mysql); @@ -570,7 +579,7 @@ advanced_command(MYSQL *mysql, enum enum_server_command command, { NET *net= &mysql->net; my_bool result= 1; - init_sigpipe_variables; + init_sigpipe_variables /* Don't give sigpipe errors if the client doesn't want them */ set_sigpipe(mysql); @@ -594,8 +603,6 @@ advanced_command(MYSQL *mysql, enum enum_server_command command, mysql->info=0; mysql->affected_rows= ~(my_ulonglong) 0; net_clear(&mysql->net); /* Clear receive buffer */ - if (!arg) - arg=""; if (net_write_command(net,(uchar) command, header, header_length, arg, arg_length)) @@ -640,8 +647,7 @@ void free_old_query(MYSQL *mysql) DBUG_ENTER("free_old_query"); if (mysql->fields) free_root(&mysql->field_alloc,MYF(0)); - else - init_alloc_root(&mysql->field_alloc,8192,0); /* Assume rowlength < 8192 */ + init_alloc_root(&mysql->field_alloc,8192,0); /* Assume rowlength < 8192 */ mysql->fields=0; mysql->field_count=0; /* For API */ DBUG_VOID_RETURN; @@ -664,7 +670,7 @@ void end_server(MYSQL *mysql) DBUG_ENTER("end_server"); if (mysql->net.vio != 0) { - init_sigpipe_variables; + init_sigpipe_variables DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio))); set_sigpipe(mysql); vio_delete(mysql->net.vio); @@ -676,6 +682,7 @@ void end_server(MYSQL *mysql) DBUG_VOID_RETURN; } + void STDCALL mysql_free_result(MYSQL_RES *result) { @@ -726,6 +733,11 @@ static const char *default_options[]= static TYPELIB option_types={array_elements(default_options)-1, "options",default_options}; +const char *sql_protocol_names_lib[] = +{ "TCP", "SOCKET", "PIPE", "MEMORY", NullS }; +TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"", + sql_protocol_names_lib}; + static int add_init_command(struct st_mysql_options *options, const char *cmd) { char *tmp; @@ -832,8 +844,8 @@ static void mysql_read_default_options(struct st_mysql_options *options, options->db=my_strdup(opt_arg,MYF(MY_WME)); } break; -#ifdef MYSQL_CLIENT case 11: /* debug */ +#ifdef MYSQL_CLIENT mysql_debug(opt_arg ? opt_arg : "d:t:o,/tmp/client.trace"); break; #endif @@ -885,26 +897,30 @@ static void mysql_read_default_options(struct st_mysql_options *options, options->client_flag&= CLIENT_LOCAL_FILES; break; case 23: /* replication probe */ +#ifndef TO_BE_DELETED options->rpl_probe= 1; +#endif break; case 24: /* enable-reads-from-master */ options->no_master_reads= 0; break; case 25: /* repl-parse-query */ +#ifndef TO_BE_DELETED options->rpl_parse= 1; +#endif break; case 27: options->max_allowed_packet= atoi(opt_arg); break; -#ifdef MYSQL_CLIENT case 28: /* protocol */ - if ((options->protocol = find_type(opt_arg, &sql_protocol_typelib,0)) == ~(ulong) 0) + if ((options->protocol = find_type(opt_arg, + &sql_protocol_typelib,0)) + == ~(ulong) 0) { fprintf(stderr, "Unknown option to protocol: %s\n", opt_arg); exit(1); } break; -#endif case 29: /* shared_memory_base_name */ #ifdef HAVE_SMEM if (options->shared_memory_base_name != def_shared_memory_base_name) @@ -928,6 +944,7 @@ static void mysql_read_default_options(struct st_mysql_options *options, DBUG_VOID_RETURN; } + /************************************************************************** Get column lengths of the current row If one uses mysql_use_result, res->lengths contains the length information, @@ -956,51 +973,6 @@ void fetch_lengths(ulong *to, MYSQL_ROW column, uint field_count) } -static inline void -unpack_fields_40(MYSQL_ROWS *row, MYSQL_FIELD *field, MEM_ROOT *alloc, - ulong *lengths, uint n_lengths, - my_bool default_value, my_bool long_flag_protocol) -{ - DBUG_ENTER("unpack_fields_40"); - - for (; row ; row = row->next,field++) - { - fetch_lengths(lengths, row->data, n_lengths); - field->org_table= field->table= strdup_root(alloc,(char*) row->data[0]); - field->name= strdup_root(alloc,(char*) row->data[1]); - field->length= (uint) uint3korr(row->data[2]); - field->type= (enum enum_field_types) (uchar) row->data[3][0]; - - field->catalog=(char*) ""; - field->db= (char*) ""; - field->catalog_length= 0; - field->db_length= 0; - field->org_table_length= field->table_length= lengths[0]; - field->name_length= lengths[1]; - - if (long_flag_protocol) - { - field->flags= uint2korr(row->data[4]); - field->decimals=(uint) (uchar) row->data[4][2]; - } - else - { - field->flags= (uint) (uchar) row->data[4][0]; - field->decimals=(uint) (uchar) row->data[4][1]; - } - if (INTERNAL_NUM_FIELD(field)) - field->flags|= NUM_FLAG; - if (default_value && row->data[5]) - { - field->def=strdup_root(alloc,(char*) row->data[5]); - field->def_length= lengths[5]; - } - else - field->def=0; - field->max_length= 0; - } -} - /*************************************************************************** Change field rows to field structs ***************************************************************************/ @@ -1009,25 +981,19 @@ MYSQL_FIELD * unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, my_bool default_value, uint server_capabilities) { -#ifdef MYSQL_CLIENT MYSQL_ROWS *row; -#endif MYSQL_FIELD *field,*result; ulong lengths[9]; /* Max of fields */ DBUG_ENTER("unpack_fields"); - field=result=(MYSQL_FIELD*) alloc_root(alloc, - (uint) sizeof(MYSQL_FIELD)*fields); + field= result= (MYSQL_FIELD*) alloc_root(alloc, + (uint) sizeof(*field)*fields); if (!result) { free_rows(data); /* Free old data */ DBUG_RETURN(0); } bzero((char*) field, (uint) sizeof(MYSQL_FIELD)*fields); -#ifdef MYSQL_SERVER - unpack_fields_40(data->data, field, alloc, lengths, default_value ? 6 : 5, - default_value, (my_bool)(server_capabilities & CLIENT_LONG_FLAG)); -#else if (server_capabilities & CLIENT_PROTOCOL_41) { /* server is 4.1, and returns the new field result format */ @@ -1071,10 +1037,46 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, } #ifndef DELETE_SUPPORT_OF_4_0_PROTOCOL else - unpack_fields_40(data->data, field, alloc, lengths, default_value ? 6 : 5, - default_value, (my_bool)(server_capabilities & CLIENT_LONG_FLAG)); + { + /* old protocol, for backward compatibility */ + for (row=data->data; row ; row = row->next,field++) + { + fetch_lengths(&lengths[0], row->data, default_value ? 6 : 5); + field->org_table= field->table= strdup_root(alloc,(char*) row->data[0]); + field->name= strdup_root(alloc,(char*) row->data[1]); + field->length= (uint) uint3korr(row->data[2]); + field->type= (enum enum_field_types) (uchar) row->data[3][0]; + + field->catalog=(char*) ""; + field->db= (char*) ""; + field->catalog_length= 0; + field->db_length= 0; + field->org_table_length= field->table_length= lengths[0]; + field->name_length= lengths[1]; + + if (server_capabilities & CLIENT_LONG_FLAG) + { + field->flags= uint2korr(row->data[4]); + field->decimals=(uint) (uchar) row->data[4][2]; + } + else + { + field->flags= (uint) (uchar) row->data[4][0]; + field->decimals=(uint) (uchar) row->data[4][1]; + } + if (INTERNAL_NUM_FIELD(field)) + field->flags|= NUM_FLAG; + if (default_value && row->data[5]) + { + field->def=strdup_root(alloc,(char*) row->data[5]); + field->def_length= lengths[5]; + } + else + field->def=0; + field->max_length= 0; + } + } #endif /* DELETE_SUPPORT_OF_4_0_PROTOCOL */ -#endif /*MYSQL_SERVER*/ free_rows(data); /* Free old data */ DBUG_RETURN(result); } @@ -1172,13 +1174,11 @@ MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, } } *prev_ptr=0; /* last pointer is null */ -#ifndef MYSQL_SERVER if (pkt_len > 1) /* MySQL 4.1 protocol */ { mysql->warning_count= uint2korr(cp+1); DBUG_PRINT("info",("warning_count: %ld", mysql->warning_count)); } -#endif DBUG_PRINT("exit",("Got %d rows",result->rows)); DBUG_RETURN(result); } @@ -1201,10 +1201,8 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) return -1; if (pkt_len <= 8 && net->read_pos[0] == 254) { -#ifndef MYSQL_SERVER if (pkt_len > 1) /* MySQL 4.1 protocol */ mysql->warning_count= uint2korr(net->read_pos+1); -#endif return 1; /* End of data */ } prev_pos= 0; /* allowed to write at packet[-1] */ @@ -1256,102 +1254,84 @@ mysql_init(MYSQL *mysql) } else bzero((char*) (mysql),sizeof(*(mysql))); -#ifndef MYSQL_SERVER - mysql->options.connect_timeout=CONNECT_TIMEOUT; - mysql->last_used_con = mysql->next_slave = mysql->master = mysql; + mysql->options.connect_timeout= CONNECT_TIMEOUT; + mysql->last_used_con= mysql->next_slave= mysql->master = mysql; /* By default, we are a replication pivot. The caller must reset it after we return if this is not the case. */ +#ifndef TO_BE_DELETED mysql->rpl_pivot = 1; -#if defined(SIGPIPE) && defined(THREAD) && !defined(__WIN__) +#endif +#if defined(SIGPIPE) && defined(THREAD) && !defined(__WIN__) && !defined(MYSQL_SERVER) if (!((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE)) (void) signal(SIGPIPE,pipe_sig_handler); #endif -/* - Only enable LOAD DATA INFILE by default if configured with - --enable-local-infile -*/ -#ifdef ENABLED_LOCAL_INFILE + /* + Only enable LOAD DATA INFILE by default if configured with + --enable-local-infile + */ +#if defined(ENABLED_LOCAL_INFILE) && !defined(MYSQL_SERVER) mysql->options.client_flag|= CLIENT_LOCAL_FILES; #endif #ifdef HAVE_SMEM - mysql->options.shared_memory_base_name=(char*)def_shared_memory_base_name; -#endif - -#else /*MYSQL_SERVER*/ - -#ifdef __WIN__ - mysql->options.connect_timeout=20; + mysql->options.shared_memory_base_name= (char*) def_shared_memory_base_name; #endif -#endif /*MYSQL_SERVER*/ return mysql; } /* - Initialize the MySQL library - - SYNOPSIS - mysql_once_init() - - NOTES - Can't be static on NetWare - This function is called by mysql_init() and indirectly called - by mysql_query(), so one should never have to call this from an - outside program. + Fill in SSL part of MYSQL structure and set 'use_ssl' flag. + NB! Errors are not reported until you do mysql_real_connect. */ -void mysql_once_init(void) +#define strdup_if_not_null(A) (A) == 0 ? 0 : my_strdup((A),MYF(MY_WME)) + +my_bool STDCALL +mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , + const char *key __attribute__((unused)), + const char *cert __attribute__((unused)), + const char *ca __attribute__((unused)), + const char *capath __attribute__((unused)), + const char *cipher __attribute__((unused))) { -#ifndef MYSQL_SERVER +#ifdef HAVE_OPENSSL + mysql->options.ssl_key= strdup_if_not_null(key); + mysql->options.ssl_cert= strdup_if_not_null(cert); + mysql->options.ssl_ca= strdup_if_not_null(ca); + mysql->options.ssl_capath= strdup_if_not_null(capath); + mysql->options.ssl_cipher= strdup_if_not_null(cipher); +#endif /* HAVE_OPENSSL */ + return 0; +} - if (!mysql_client_init) - { - mysql_client_init=1; - org_my_init_done=my_init_done; - my_init(); /* Will init threads */ - init_client_errs(); - if (!mysql_port) - { - mysql_port = MYSQL_PORT; -#ifndef MSDOS - { - struct servent *serv_ptr; - char *env; - if ((serv_ptr = getservbyname("mysql", "tcp"))) - mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); - if ((env = getenv("MYSQL_TCP_PORT"))) - mysql_port =(uint) atoi(env); - } -#endif - } - if (!mysql_unix_port) - { - char *env; -#ifdef __WIN__ - mysql_unix_port = (char*) MYSQL_NAMEDPIPE; -#else - mysql_unix_port = (char*) MYSQL_UNIX_ADDR; -#endif - if ((env = getenv("MYSQL_UNIX_PORT"))) - mysql_unix_port = env; - } - mysql_debug(NullS); -#if defined(SIGPIPE) && !defined(THREAD) && !defined(__WIN__) - (void) signal(SIGPIPE,SIG_IGN); -#endif - } -#ifdef THREAD - else - my_thread_init(); /* Init if new thread */ -#endif -#else /*MYSQL_SERVER*/ - init_client_errs(); -#endif /*MYSQL_SERVER*/ +/* + Free strings in the SSL structure and clear 'use_ssl' flag. + NB! Errors are not reported until you do mysql_real_connect. +*/ + +#ifdef HAVE_OPENSSL +static void +mysql_ssl_free(MYSQL *mysql __attribute__((unused))) +{ + my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR)); + mysql->options.ssl_key = 0; + mysql->options.ssl_cert = 0; + mysql->options.ssl_ca = 0; + mysql->options.ssl_capath = 0; + mysql->options.ssl_cipher= 0; + mysql->options.use_ssl = FALSE; + mysql->connector_fd = 0; } +#endif /* HAVE_OPENSSL */ /* @@ -1423,6 +1403,7 @@ error: return 1; } + /* Note that the mysql argument must be initialized with mysql_init() before calling mysql_real_connect ! @@ -1433,12 +1414,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, const char *passwd, const char *db, uint port, const char *unix_socket,ulong client_flag) { -#ifdef MYSQL_CLIENT - char *charset_name; - char charset_name_buff[16]; -#endif - char buff[NAME_LEN+USERNAME_LENGTH+100]; - char *end,*host_info; + char buff[NAME_LEN+USERNAME_LENGTH+100],charset_name_buff[16]; + char *end,*host_info,*charset_name; my_socket sock; uint32 ip_addr; struct sockaddr_in sock_addr; @@ -1447,9 +1424,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, #ifdef MYSQL_SERVER thr_alarm_t alarmed; ALARM alarm_buff; - ulong max_allowed_packet; #endif - #ifdef __WIN__ HANDLE hPipe=INVALID_HANDLE_VALUE; #endif @@ -1469,9 +1444,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, set_sigpipe(mysql); net->vio = 0; /* If something goes wrong */ mysql->client_flag=0; /* For handshake */ -#ifdef MYSQL_SERVER - mysql->charset=default_charset_info; /* Set character set */ -#endif /* use default options */ if (mysql->options.my_cnf_file || mysql->options.my_cnf_group) @@ -1493,7 +1465,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (!passwd) { passwd=mysql->options.password; -#ifndef DONT_USE_MYSQL_PWD +#if !defined(DONT_USE_MYSQL_PWD) && !defined(MYSQL_SERVER) if (!passwd) passwd=getenv("MYSQL_PWD"); /* get it from environment */ #endif @@ -1511,7 +1483,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, /* Grab a socket and connect it to the server */ -#ifdef HAVE_SMEM +#if defined(HAVE_SMEM) if ((!mysql->options.protocol || mysql->options.protocol == MYSQL_PROTOCOL_MEMORY) && (!host || !strcmp(host,LOCAL_HOST))) @@ -1537,86 +1509,76 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, host=mysql->options.shared_memory_base_name; host_info=(char*) ER(CR_SHARED_MEMORY_CONNECTION); } - } else + } #endif /* HAVE_SMEM */ #if defined(HAVE_SYS_UN_H) - if ((!mysql->options.protocol || - mysql->options.protocol == MYSQL_PROTOCOL_SOCKET)&& - (unix_socket || mysql_unix_port) && - (!host || !strcmp(host,LOCAL_HOST))) + if (!net->vio && + (!mysql->options.protocol || + mysql->options.protocol == MYSQL_PROTOCOL_SOCKET) && + (unix_socket || mysql_unix_port) && + (!host || !strcmp(host,LOCAL_HOST))) + { + host=LOCAL_HOST; + if (!unix_socket) + unix_socket=mysql_unix_port; + host_info=(char*) ER(CR_LOCALHOST_CONNECTION); + DBUG_PRINT("info",("Using UNIX sock '%s'",unix_socket)); + if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR) { - host=LOCAL_HOST; - if (!unix_socket) - unix_socket=mysql_unix_port; - host_info=(char*) ER(CR_LOCALHOST_CONNECTION); - DBUG_PRINT("info",("Using UNIX sock '%s'",unix_socket)); - if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR) - { - net->last_errno=CR_SOCKET_CREATE_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - sprintf(net->last_error,ER(net->last_errno),socket_errno); - goto error; - } - net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE); - bzero((char*) &UNIXaddr,sizeof(UNIXaddr)); - UNIXaddr.sun_family = AF_UNIX; - strmake(UNIXaddr.sun_path, unix_socket, sizeof(UNIXaddr.sun_path)-1); - if (my_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr), - mysql->options.connect_timeout)) - { - DBUG_PRINT("error",("Got error %d on connect to local server", - socket_errno)); - net->last_errno=CR_CONNECTION_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno); + net->last_errno=CR_SOCKET_CREATE_ERROR; + strmov(net->sqlstate, unknown_sqlstate); + sprintf(net->last_error,ER(net->last_errno),socket_errno); + goto error; + } + net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE); + bzero((char*) &UNIXaddr,sizeof(UNIXaddr)); + UNIXaddr.sun_family = AF_UNIX; + strmake(UNIXaddr.sun_path, unix_socket, sizeof(UNIXaddr.sun_path)-1); + if (my_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr), + mysql->options.connect_timeout)) + { + DBUG_PRINT("error",("Got error %d on connect to local server", + socket_errno)); + net->last_errno=CR_CONNECTION_ERROR; + strmov(net->sqlstate, unknown_sqlstate); + sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno); + goto error; + } + mysql->options.protocol=MYSQL_PROTOCOL_SOCKET; + } +#elif defined(__WIN__) + if (!net->vio && + (mysql->options.protocol == MYSQL_PROTOCOL_PIPE || + (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) || + (! have_tcpip && (unix_socket || !host && is_NT())))) + { + sock=0; + if ((hPipe=create_named_pipe(net, mysql->options.connect_timeout, + (char**) &host, (char**) &unix_socket)) == + INVALID_HANDLE_VALUE) + { + DBUG_PRINT("error", + ("host: '%s' socket: '%s' have_tcpip: %d", + host ? host : "<null>", + unix_socket ? unix_socket : "<null>", + (int) have_tcpip)); + if (mysql->options.protocol == MYSQL_PROTOCOL_PIPE || + (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) || + (unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE))) goto error; - } -#ifdef MYSQL_CLIENT - else - mysql->options.protocol=MYSQL_PROTOCOL_SOCKET; -#endif + /* Try also with TCP/IP */ } else -#elif defined(__WIN__) { - if ((!mysql->options.protocol || - mysql->options.protocol == MYSQL_PROTOCOL_PIPE)&& - ((unix_socket || !host && is_NT() || - host && !strcmp(host,LOCAL_HOST_NAMEDPIPE) ||! have_tcpip))&& - (!net->vio)) - { - sock=0; - if ((hPipe=create_named_pipe(net, mysql->options.connect_timeout, - (char**) &host, (char**) &unix_socket)) == - INVALID_HANDLE_VALUE) - { - DBUG_PRINT("error", - ("host: '%s' socket: '%s' have_tcpip: %d", - host ? host : "<null>", - unix_socket ? unix_socket : "<null>", - (int) have_tcpip)); - if (mysql->options.protocol == MYSQL_PROTOCOL_PIPE || - (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) || - (unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE))) - goto error; - /* Try also with TCP/IP */ - } - else - { - net->vio=vio_new_win32pipe(hPipe); - sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), host, - unix_socket); - } - } + net->vio=vio_new_win32pipe(hPipe); + sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), host, + unix_socket); } -#ifdef MYSQL_SERVER - if (hPipe == INVALID_HANDLE_VALUE) -#endif -#endif -#ifdef MYSQL_CLIENT - if ((!mysql->options.protocol || - mysql->options.protocol == MYSQL_PROTOCOL_TCP)&&(!net->vio)) + } #endif + if (!net->vio && + (!mysql->options.protocol || + mysql->options.protocol == MYSQL_PROTOCOL_TCP)) { unix_socket=0; /* This is not used */ if (!port) @@ -1629,11 +1591,11 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, thr_alarm_init(&alarmed); thr_alarm(&alarmed, mysql->options.connect_timeout, &alarm_buff); #endif + /* _WIN64 ; Assume that the (int) range is enough for socket() */ sock = (my_socket) socket(AF_INET,SOCK_STREAM,0); #ifdef MYSQL_SERVER thr_end_alarm(&alarmed); #endif - /* _WIN64 ; Assume that the (int) range is enough for socket() */ if (sock == SOCKET_ERROR) { net->last_errno=CR_IPSOCK_ERROR; @@ -1683,17 +1645,16 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, goto error; } } -#ifdef MYSQL_CLIENT - else if (!net->vio) + if (!net->vio) { DBUG_PRINT("error",("Unknow protocol %d ",mysql->options.protocol)); - net->last_errno= CR_CONN_UNKNOW_PROTOCOL; strmov(net->sqlstate, unknown_sqlstate); - sprintf(net->last_error ,ER(CR_CONN_UNKNOW_PROTOCOL)); + net->last_errno= CR_CONN_UNKNOW_PROTOCOL; + strmov(net->last_error, ER(CR_CONN_UNKNOW_PROTOCOL)); goto error; } -#endif /*MYSQL_CLIENT*/ - if (!net->vio || my_net_init(net, net->vio)) + + if (my_net_init(net, net->vio)) { vio_delete(net->vio); net->vio = 0; @@ -1703,9 +1664,14 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, goto error; } vio_keepalive(net->vio,TRUE); -#ifdef MYSQL_SERVER - net->read_timeout=slave_net_timeout; -#endif + /* Override local client variables */ + if (mysql->options.read_timeout) + net->read_timeout= mysql->options.read_timeout; + if (mysql->options.write_timeout) + net->write_timeout= mysql->options.write_timeout; + if (mysql->options.max_allowed_packet) + net->max_packet_size= mysql->options.max_allowed_packet; + /* Get version info */ mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */ if (mysql->options.connect_timeout && @@ -1725,9 +1691,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, DBUG_DUMP("packet",(char*) net->read_pos,10); DBUG_PRINT("info",("mysql protocol version %d, server=%d", PROTOCOL_VERSION, mysql->protocol_version)); - if (mysql->protocol_version != PROTOCOL_VERSION - && mysql->protocol_version != PROTOCOL_VERSION-1) + if (mysql->protocol_version != PROTOCOL_VERSION) { + strmov(net->sqlstate, unknown_sqlstate); net->last_errno= CR_VERSION_ERROR; sprintf(net->last_error, ER(CR_VERSION_ERROR), mysql->protocol_version, PROTOCOL_VERSION); @@ -1747,7 +1713,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, mysql->server_status=uint2korr(end+3); } -#ifdef MYSQL_CLIENT /* Set character set */ if ((charset_name=mysql->options.charset_name)) { @@ -1755,14 +1720,15 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (mysql->options.charset_dir) charsets_dir=mysql->options.charset_dir; mysql->charset=get_charset_by_csname(mysql->options.charset_name, - MY_CS_PRIMARY, - MYF(MY_WME)); + MY_CS_PRIMARY, + MYF(MY_WME)); charsets_dir=save; } else if (mysql->server_language) { charset_name=charset_name_buff; - sprintf(charset_name,"%d",mysql->server_language); /* In case of errors */ + /* Save name in case of errors */ + int10_to_str(mysql->server_language, charset_name, 10); if (!(mysql->charset = get_charset((uint8) mysql->server_language, MYF(0)))) mysql->charset = default_charset_info; /* shouldn't be fatal */ @@ -1775,20 +1741,21 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, net->last_errno=CR_CANT_READ_CHARSET; strmov(net->sqlstate, unknown_sqlstate); if (mysql->options.charset_dir) - sprintf(net->last_error,ER(net->last_errno), - charset_name ? charset_name : "unknown", - mysql->options.charset_dir); + my_snprintf(net->last_error, sizeof(net->last_error)-1, + ER(net->last_errno), + charset_name ? charset_name : "unknown", + mysql->options.charset_dir); else { char cs_dir_name[FN_REFLEN]; get_charsets_dir(cs_dir_name); - sprintf(net->last_error,ER(net->last_errno), - charset_name ? charset_name : "unknown", - cs_dir_name); + my_snprintf(net->last_error, sizeof(net->last_error)-1, + ER(net->last_errno), + charset_name ? charset_name : "unknown", + cs_dir_name); } goto error; } -#endif /*MYSQL_CLIENT*/ /* Save connection information */ if (!user) user=""; @@ -1834,7 +1801,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (db) client_flag|=CLIENT_CONNECT_WITH_DB; -#ifdef MYSQL_CLIENT /* Remove options that server doesn't support */ client_flag= ((client_flag & ~(CLIENT_COMPRESS | CLIENT_SSL | CLIENT_PROTOCOL_41)) | @@ -1842,11 +1808,12 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, #ifndef HAVE_COMPRESS client_flag&= ~CLIENT_COMPRESS; #endif + if (client_flag & CLIENT_PROTOCOL_41) { /* 4.1 server and 4.1 client has a 32 byte option flag */ int4store(buff,client_flag); - int4store(buff+4,max_allowed_packet); + int4store(buff+4, net->max_packet_size); buff[8]= mysql->charset->number; bzero(buff+9, 32-9); end= buff+32; @@ -1854,46 +1821,10 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, else { int2store(buff,client_flag); - int3store(buff+2,max_allowed_packet); + int3store(buff+2,net->max_packet_size); end= buff+5; } mysql->client_flag=client_flag; -#endif /*MYSQL_CLIENT*/ - -#ifdef MYSQL_SERVER -#ifdef HAVE_COMPRESS - if ((mysql->server_capabilities & CLIENT_COMPRESS) && - (mysql->options.compress || (client_flag & CLIENT_COMPRESS))) - client_flag|=CLIENT_COMPRESS; /* We will use compression */ - else -#endif - client_flag&= ~CLIENT_COMPRESS; -#endif /*MYSQL_SERVER*/ - -#ifdef MYSQL_SERVER -#ifdef HAVE_OPENSSL - if ((mysql->server_capabilities & CLIENT_SSL) && - (mysql->options.use_ssl || (client_flag & CLIENT_SSL))) - { - DBUG_PRINT("info", ("Changing IO layer to SSL")); - client_flag |= CLIENT_SSL; - } - else - { - if (client_flag & CLIENT_SSL) - { - DBUG_PRINT("info", ("Leaving IO layer intact because server doesn't support SSL")); - } - client_flag &= ~CLIENT_SSL; - } -#endif /* HAVE_OPENSSL */ - - max_allowed_packet=mysql->net.max_packet_size; - int2store(buff,client_flag); - int3store(buff+2,max_allowed_packet); - end= buff+5; - mysql->client_flag=client_flag; -#endif /*MYSQL_SERVER*/ #ifdef HAVE_OPENSSL /* @@ -1902,9 +1833,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, */ if (client_flag & CLIENT_SSL) { -#ifdef MYSQL_CLIENT struct st_mysql_options *options= &mysql->options; -#endif if (my_net_write(net,buff,(uint) (end-buff)) || net_flush(net)) { strmov(net->sqlstate, unknown_sqlstate); @@ -1913,7 +1842,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, goto error; } /* Do the SSL layering. */ -#ifdef MYSQL_CLIENT if (!(mysql->connector_fd= (gptr) new_VioSSLConnectorFd(options->ssl_key, options->ssl_cert, @@ -1926,7 +1854,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, strmov(net->last_error,ER(net->last_errno)); goto error; } -#endif /*MYSQL_CLIENT*/ DBUG_PRINT("info", ("IO layer change in progress...")); if (sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd), mysql->net.vio, (long) (mysql->options.connect_timeout))) @@ -1947,18 +1874,11 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (user && user[0]) strmake(end,user,32); /* Max user name */ else -#ifdef MYSQL_SERVER - { - user = getenv("USER"); - if (!user) user = "mysql"; - strmov((char*) end, user ); - } -#else read_user_name((char*) end); -#endif /*MYSQL_SERVER*/ + /* We have to handle different version of handshake here */ -#if defined(_CUSTOMCONFIG_) && defined(MYSQL_CLIENT) -#include "_cust_libmysql.h"; +#ifdef _CUSTOMCONFIG_ +#include "_cust_libmysql.h" #endif DBUG_PRINT("info",("user: %s",end)); /* @@ -2012,9 +1932,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (client_flag & CLIENT_COMPRESS) /* We will use compression */ net->compress=1; -#ifdef MYSQL_CLIENT - if (mysql->options.max_allowed_packet) - net->max_packet_size= mysql->options.max_allowed_packet; if (db && mysql_select_db(mysql,db)) goto error; @@ -2030,7 +1947,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, for (; ptr<end; ptr++) { MYSQL_RES *res; - if (mysql_query(mysql,*ptr)) + if (mysql_real_query(mysql,*ptr, strlen(*ptr))) goto error; if (mysql->fields) { @@ -2039,13 +1956,13 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, mysql_free_result(res); } } - mysql->reconnect=reconnect; } +#ifndef TO_BE_DELETED if (mysql->options.rpl_probe && mysql_rpl_probe(mysql)) goto error; -#endif /*MYSQL_CLIENT*/ +#endif DBUG_PRINT("exit",("Mysql handler: %lx",mysql)); reset_sigpipe(mysql); @@ -2057,37 +1974,35 @@ error: net->last_errno, net->sqlstate, net->last_error)); { /* Free alloced memory */ - my_bool free_me=mysql->free_me; end_server(mysql); - mysql->free_me=0; - mysql_close(mysql); - mysql->free_me=free_me; + mysql_close_free(mysql); + if (!(client_flag & CLIENT_REMEMBER_OPTIONS)) + mysql_close_free_options(mysql); } DBUG_RETURN(0); } + /* needed when we move MYSQL structure to a different address */ +#ifndef TO_BE_DELETED static void mysql_fix_pointers(MYSQL* mysql, MYSQL* old_mysql) { + MYSQL *tmp, *tmp_prev; if (mysql->master == old_mysql) - mysql->master = mysql; + mysql->master= mysql; if (mysql->last_used_con == old_mysql) - mysql->last_used_con = mysql; + mysql->last_used_con= mysql; if (mysql->last_used_slave == old_mysql) - mysql->last_used_slave = mysql; -#ifdef MYSQL_CLIENT /*should work in MYSQL_SERVER also, but doesn't */ + mysql->last_used_slave= mysql; + for (tmp_prev = mysql, tmp = mysql->next_slave; + tmp != old_mysql;tmp = tmp->next_slave) { - MYSQL *tmp, *tmp_prev; - for (tmp_prev = mysql, tmp = mysql->next_slave; - tmp != old_mysql;tmp = tmp->next_slave) - { - tmp_prev = tmp; - } - tmp_prev->next_slave = mysql; + tmp_prev= tmp; } -#endif /*MYSQL_CLIENT*/ + tmp_prev->next_slave= mysql; } +#endif my_bool mysql_reconnect(MYSQL *mysql) @@ -2111,11 +2026,11 @@ my_bool mysql_reconnect(MYSQL *mysql) tmp_mysql.rpl_pivot = mysql->rpl_pivot; if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, mysql->db, mysql->port, mysql->unix_socket, - mysql->client_flag)) + mysql->client_flag | CLIENT_REMEMBER_OPTIONS)) { mysql->net.last_errno= tmp_mysql.net.last_errno; strmov(mysql->net.last_error, tmp_mysql.net.last_error); - strmov(mysql->net.sqlstate, unknown_sqlstate); + strmov(mysql->net.sqlstate, tmp_mysql.net.sqlstate); DBUG_RETURN(1); } tmp_mysql.free_me=mysql->free_me; @@ -2128,6 +2043,7 @@ my_bool mysql_reconnect(MYSQL *mysql) DBUG_RETURN(0); } + /************************************************************************** Set current database **************************************************************************/ @@ -2146,42 +2062,62 @@ mysql_select_db(MYSQL *mysql, const char *db) DBUG_RETURN(0); } -/* - Free strings in the SSL structure and clear 'use_ssl' flag. - NB! Errors are not reported until you do mysql_real_connect. -*/ - -#ifdef HAVE_OPENSSL -static void -mysql_ssl_free(MYSQL *mysql __attribute__((unused))) -{ - my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR)); - mysql->options.ssl_key = 0; - mysql->options.ssl_cert = 0; - mysql->options.ssl_ca = 0; - mysql->options.ssl_capath = 0; - mysql->options.ssl_cipher= 0; - mysql->options.use_ssl = FALSE; - mysql->connector_fd = 0; -} -#endif /* HAVE_OPENSSL */ /************************************************************************* Send a QUIT to the server and close the connection If handle is alloced by mysql connect free it. *************************************************************************/ +static void mysql_close_free_options(MYSQL *mysql) +{ + my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.user,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.host,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.password,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.unix_socket,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.db,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR)); + my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR)); + if (mysql->options.init_commands) + { + DYNAMIC_ARRAY *init_commands= mysql->options.init_commands; + char **ptr= (char**)init_commands->buffer; + char **end= ptr + init_commands->elements; + for (; ptr<end; ptr++) + my_free(*ptr,MYF(MY_WME)); + delete_dynamic(init_commands); + my_free((char*)init_commands,MYF(MY_WME)); + } +#ifdef HAVE_OPENSSL + mysql_ssl_free(mysql); +#endif /* HAVE_OPENSSL */ +#ifdef HAVE_SMEM + if (mysql->options.shared_memory_base_name != def_shared_memory_base_name) + my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); +#endif /* HAVE_SMEM */ + bzero((char*) &mysql->options,sizeof(mysql->options)); +} + + +static void mysql_close_free(MYSQL *mysql) +{ + /* Clear pointers for better safety */ + my_free((gptr) mysql->host_info,MYF(MY_ALLOW_ZERO_PTR)); + mysql->host_info=mysql->user=mysql->passwd=mysql->db=0; +} + + void STDCALL mysql_close(MYSQL *mysql) { DBUG_ENTER("mysql_close"); if (mysql) /* Some simple safety */ { + /* If connection is still up, send a QUIT message */ if (mysql->net.vio != 0) { free_old_query(mysql); @@ -2190,34 +2126,22 @@ mysql_close(MYSQL *mysql) simple_command(mysql,COM_QUIT,NullS,0,1); end_server(mysql); /* Sets mysql->net.vio= 0 */ } - my_free((gptr) mysql->host_info,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.user,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.host,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.password,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.unix_socket,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.db,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR)); - if (mysql->options.init_commands) + mysql_close_free_options(mysql); + mysql_close_free(mysql); +#ifdef MYSQL_CLIENT + if (mysql->stmts) { - DYNAMIC_ARRAY *init_commands= mysql->options.init_commands; - char **ptr= (char**)init_commands->buffer; - char **end= ptr + init_commands->elements; - for (; ptr<end; ptr++) - my_free(*ptr,MYF(MY_WME)); - delete_dynamic(init_commands); - my_free((char*)init_commands,MYF(MY_WME)); + /* Free any open prepared statements */ + LIST *element, *next_element; + for (element= mysql->stmts; element; element= next_element) + { + next_element= element->next; + stmt_close((MYSQL_STMT *)element->data, 0); + } + mysql->stmts= 0; } -#ifdef HAVE_SMEM - if (mysql->options.shared_memory_base_name != def_shared_memory_base_name) - my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); -#endif /* HAVE_SMEM */ - +#endif /*MYSQL_CLIENT*/ +#ifndef TO_BE_DELETED /* free/close slave list */ if (mysql->rpl_pivot) { @@ -2231,34 +2155,16 @@ mysql_close(MYSQL *mysql) } mysql->rpl_pivot=0; } -#ifdef MYSQL_CLIENT - if (mysql->stmts) - { - /* Free any open prepared statements */ - LIST *element, *next_element; - for (element= mysql->stmts; element; element= next_element) - { - next_element= element->next; - stmt_close((MYSQL_STMT *)element->data, 0); - } - } +#endif if (mysql != mysql->master) mysql_close(mysql->master); -#endif /*MYSQL_CLIENT*/ - -#ifdef HAVE_OPENSSL - mysql_ssl_free(mysql); -#endif /* HAVE_OPENSSL */ - /* Clear pointers for better safety */ - - mysql->host_info=mysql->user=mysql->passwd=mysql->db=0; - bzero((char*) &mysql->options,sizeof(mysql->options)); if (mysql->free_me) my_free((gptr) mysql,MYF(0)); } DBUG_VOID_RETURN; } + my_bool STDCALL mysql_read_query_result(MYSQL *mysql) { uchar *pos; @@ -2267,18 +2173,16 @@ my_bool STDCALL mysql_read_query_result(MYSQL *mysql) ulong length; DBUG_ENTER("mysql_read_query_result"); -#ifdef MYSQL_CLIENT /* Read from the connection which we actually used, which could differ from the original connection if we have slaves */ mysql = mysql->last_used_con; -#endif if ((length = net_safe_read(mysql)) == packet_error) DBUG_RETURN(1); - free_old_query(mysql); /* Free old result */ -#ifdef MYSQL_CLIENT /*or else gcc will warn of unused labels*/ + free_old_query(mysql); /* Free old result */ +#ifdef MYSQL_CLIENT /* Avoid warn of unused labels*/ get_info: #endif pos=(uchar*) mysql->net.read_pos; @@ -2341,7 +2245,7 @@ mysql_send_query(MYSQL* mysql, const char* query, ulong length) DBUG_ENTER("mysql_send_query"); DBUG_PRINT("enter",("rpl_parse: %d rpl_pivot: %d", mysql->options.rpl_parse, mysql->rpl_pivot)); -#ifdef MYSQL_CLIENT +#ifndef TO_BE_DELETED if (mysql->options.rpl_parse && mysql->rpl_pivot) { switch (mysql_rpl_query_type(query, length)) { @@ -2353,9 +2257,8 @@ mysql_send_query(MYSQL* mysql, const char* query, ulong length) break; /* fall through */ } } - mysql->last_used_con = mysql; -#endif /*MYSQL_CLIENT*/ +#endif DBUG_RETURN(simple_command(mysql, COM_QUERY, query, length, 1)); } @@ -2373,6 +2276,7 @@ mysql_real_query(MYSQL *mysql, const char *query, ulong length) DBUG_RETURN((int) mysql_read_query_result(mysql)); } + /************************************************************************** Alloc result struct for buffered results. All rows are read to buffer. mysql_data_seek may be used. @@ -2383,11 +2287,8 @@ mysql_store_result(MYSQL *mysql) { MYSQL_RES *result; DBUG_ENTER("mysql_store_result"); - -#ifdef MYSQL_CLIENT /* read from the actually used connection */ mysql = mysql->last_used_con; -#endif if (!mysql->fields) DBUG_RETURN(0); if (mysql->status != MYSQL_STATUS_GET_RESULT) @@ -2426,8 +2327,59 @@ mysql_store_result(MYSQL *mysql) DBUG_RETURN(result); /* Data fetched */ } + +/************************************************************************** + Alloc struct for use with unbuffered reads. Data is fetched by domand + when calling to mysql_fetch_row. + mysql_data_seek is a noop. + + No other queries may be specified with the same MYSQL handle. + There shouldn't be much processing per row because mysql server shouldn't + have to wait for the client (and will not wait more than 30 sec/packet). +**************************************************************************/ + +MYSQL_RES * STDCALL +mysql_use_result(MYSQL *mysql) +{ + MYSQL_RES *result; + DBUG_ENTER("mysql_use_result"); + + mysql = mysql->last_used_con; + + if (!mysql->fields) + DBUG_RETURN(0); + if (mysql->status != MYSQL_STATUS_GET_RESULT) + { + strmov(mysql->net.sqlstate, unknown_sqlstate); + strmov(mysql->net.last_error, + ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); + DBUG_RETURN(0); + } + if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result)+ + sizeof(ulong)*mysql->field_count, + MYF(MY_WME | MY_ZEROFILL)))) + DBUG_RETURN(0); + result->lengths=(ulong*) (result+1); + if (!(result->row=(MYSQL_ROW) + my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME)))) + { /* Ptrs: to one row */ + my_free((gptr) result,MYF(0)); + DBUG_RETURN(0); + } + result->fields= mysql->fields; + result->field_alloc= mysql->field_alloc; + result->field_count= mysql->field_count; + result->current_field=0; + result->handle= mysql; + result->current_row= 0; + mysql->fields=0; /* fields is now in result */ + mysql->status=MYSQL_STATUS_USE_RESULT; + DBUG_RETURN(result); /* Data is read to be fetched */ +} + + /************************************************************************** - Return next row of the query results + Return next row of the query results **************************************************************************/ MYSQL_ROW STDCALL @@ -2467,20 +2419,6 @@ mysql_fetch_row(MYSQL_RES *res) } } -/************************************************************************** - Move to a specific row and column -**************************************************************************/ - -void STDCALL -mysql_data_seek(MYSQL_RES *result, my_ulonglong row) -{ - MYSQL_ROWS *tmp=0; - DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row)); - if (result->data) - for (tmp=result->data->data; row-- && tmp ; tmp = tmp->next) ; - result->current_row=0; - result->data_cursor = tmp; -} int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) @@ -2491,11 +2429,17 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) case MYSQL_OPT_CONNECT_TIMEOUT: mysql->options.connect_timeout= *(uint*) arg; break; + case MYSQL_OPT_READ_TIMEOUT: + mysql->options.read_timeout= *(uint*) arg; + break; + case MYSQL_OPT_WRITE_TIMEOUT: + mysql->options.write_timeout= *(uint*) arg; + break; case MYSQL_OPT_COMPRESS: mysql->options.compress= 1; /* Remember for connect */ mysql->options.client_flag|= CLIENT_COMPRESS; break; - case MYSQL_OPT_NAMED_PIPE: + case MYSQL_OPT_NAMED_PIPE: /* This option is depricated */ mysql->options.protocol=MYSQL_PROTOCOL_PIPE; /* Force named pipe */ break; case MYSQL_OPT_LOCAL_INFILE: /* Allow LOAD DATA LOCAL ?*/ @@ -2504,11 +2448,9 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) else mysql->options.client_flag&= ~CLIENT_LOCAL_FILES; break; -#ifdef MYSQL_CLIENT case MYSQL_INIT_COMMAND: add_init_command(&mysql->options,arg); break; -#endif case MYSQL_READ_DEFAULT_FILE: my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR)); mysql->options.my_cnf_file=my_strdup(arg,MYF(MY_WME)); @@ -2567,6 +2509,3 @@ const char * STDCALL mysql_error(MYSQL *mysql) { return mysql->net.last_error; } - -#endif /* defined(MYSQL_SERVER) || defined(HAVE_EXTERNAL_CLIENT) */ - diff --git a/sql/Makefile.am b/sql/Makefile.am index 7c98f1a9315..fd02cc906d7 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -84,7 +84,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \ sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \ slave.cc sql_repl.cc sql_union.cc sql_derived.cc \ - client.c mini_client_errors.c pack.c\ + client.c sql_client.cc mini_client_errors.c pack.c\ stacktrace.c repl_failsafe.h repl_failsafe.cc sql_olap.cc\ gstream.cc spatial.cc sql_help.cc protocol_cursor.cc gen_lex_hash_SOURCES = gen_lex_hash.cc diff --git a/sql/client_settings.h b/sql/client_settings.h index 1963281d980..efae3f18a8b 100644 --- a/sql/client_settings.h +++ b/sql/client_settings.h @@ -17,18 +17,17 @@ #include <thr_alarm.h> -extern char *mysql_unix_port; - -#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \ - | CLIENT_LOCAL_FILES | CLIENT_SECURE_CONNECTION) - +#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | \ + CLIENT_SECURE_CONNECTION | CLIENT_TRANSACTIONS | \ + CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) #define init_sigpipe_variables #define set_sigpipe(mysql) #define reset_sigpipe(mysql) - -extern ulong slave_net_timeout; - -#ifdef HAVE_SMEM +#define read_user_name(A) {} +#define mysql_rpl_query_type(A,B) MYSQL_RPL_ADMIN +#define mysql_master_send_query(A, B, C) 1 +#define mysql_slave_send_query(A, B, C) 1 +#define mysql_rpl_probe(mysql) 0 #undef HAVE_SMEM -#endif +#undef _CUSTOMCONFIG_ diff --git a/sql/field.h b/sql/field.h index a1f19638658..a72ccfa8354 100644 --- a/sql/field.h +++ b/sql/field.h @@ -50,7 +50,7 @@ public: LEX_STRING comment; ulong query_id; // For quick test of used fields /* Field is part of the following keys */ - key_map key_start,part_of_key,part_of_sortkey; + key_map key_start,part_of_key,part_of_sortkey; enum utype { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL, CHECK,EMPTY,UNKNOWN_FIELD,CASEDN,NEXT_NUMBER,INTERVAL_FIELD, BIT_FIELD, TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD}; @@ -134,6 +134,7 @@ public: virtual void sort_string(char *buff,uint length)=0; virtual bool optimize_range(uint idx); virtual bool store_for_compare() { return 0; } + virtual void free() {} Field *new_field(MEM_ROOT *root, struct st_table *new_table) { Field *tmp= (Field*) memdup_root(root,(char*) this,size_of()); @@ -937,11 +938,11 @@ public: int pack_cmp(const char *b, uint key_length); uint packed_col_length(const char *col_ptr, uint length); uint max_packed_col_length(uint max_length); - inline void free() { value.free(); } + void free() { value.free(); } inline void clear_temporary() { bzero((char*) &value,sizeof(value)); } friend void field_conv(Field *to,Field *from); uint size_of() const { return sizeof(*this); } - bool has_charset(void) const + bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } }; @@ -949,7 +950,7 @@ public: class Field_geom :public Field_blob { public: enum geometry_type geom_type; - + Field_geom(char *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, struct st_table *table_arg,uint blob_pack_length, diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 74036edf605..d4997f78a9e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1652,7 +1652,9 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { List_iterator<Item> li(list); Item *item; +#ifndef EMBEDDED_LIBRARY char buff[sizeof(char*)]; // Max local vars in function +#endif used_tables_cache=0; const_item_cache=0; diff --git a/sql/log.cc b/sql/log.cc index 223df51d07f..dd544dcac93 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -209,9 +209,9 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, #ifdef EMBEDDED_LIBRARY sprintf(buff, "%s, Version: %s, embedded library\n", my_progname, server_version); #elif __NT__ - sprintf(buff, "%s, Version: %s, started with:\nTCP Port: %d, Named Pipe: %s\n", my_progname, server_version, mysql_port, mysql_unix_port); + sprintf(buff, "%s, Version: %s, started with:\nTCP Port: %d, Named Pipe: %s\n", my_progname, server_version, mysqld_port, mysqld_unix_port); #else - sprintf(buff, "%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysql_port,mysql_unix_port); + sprintf(buff, "%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysqld_port,mysqld_unix_port); #endif end=strmov(strend(buff),"Time Id Command Argument\n"); if (my_b_write(&log_file, (byte*) buff,(uint) (end-buff)) || diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 345f44492bc..aca84f1bcb3 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -737,7 +737,7 @@ extern ulong specialflag, current_pid; extern ulong expire_logs_days; extern my_bool relay_log_purge; extern uint test_flags,select_errors,ha_open_options; -extern uint protocol_version,dropping_tables; +extern uint protocol_version, mysqld_port, dropping_tables; extern uint delay_key_write_options; extern bool opt_endinfo, using_udf_functions, locked_in_memory; extern bool opt_using_transactions, mysql_embedded; @@ -752,7 +752,7 @@ extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern my_bool opt_readonly; extern my_bool opt_enable_named_pipe; extern my_bool opt_old_passwords, use_old_passwords; -extern char *shared_memory_base_name; +extern char *shared_memory_base_name, *mysqld_unix_port; extern bool opt_enable_shared_memory; extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7c36a02f751..68fa0cca2d5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -35,6 +35,7 @@ #include <nisam.h> #include <thr_alarm.h> #include <ft_global.h> +#include <errmsg.h> #define mysqld_charset &my_charset_latin1 @@ -254,7 +255,7 @@ my_bool opt_console= 0, opt_bdb, opt_innodb, opt_isam; my_bool opt_readonly, use_temp_pool, relay_log_purge; volatile bool mqh_used = 0; -uint mysql_port, test_flags, select_errors, dropping_tables, ha_open_options; +uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options; uint delay_key_write_options, protocol_version; uint volatile thread_count, thread_running, kill_cached_threads, wake_thread; @@ -303,7 +304,7 @@ char mysql_real_data_home[FN_REFLEN], char *language_ptr, *default_collation_name, *default_character_set_name; char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home; char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION; -char *mysql_unix_port, *opt_mysql_tmpdir; +char *mysqld_unix_port, *opt_mysql_tmpdir; char *my_bind_addr_str; const char **errmesg; /* Error messages */ const char *myisam_recover_options_str="OFF"; @@ -561,7 +562,7 @@ static void close_connections(void) { (void) shutdown(unix_sock,2); (void) closesocket(unix_sock); - (void) unlink(mysql_unix_port); + (void) unlink(mysqld_unix_port); unix_sock= INVALID_SOCKET; } #endif @@ -670,7 +671,7 @@ static void close_server_sock() DBUG_PRINT("info",("calling closesocket on unix/IP socket")); VOID(closesocket(tmp_sock)); #endif - VOID(unlink(mysql_unix_port)); + VOID(unlink(mysqld_unix_port)); } DBUG_VOID_RETURN; #endif @@ -961,24 +962,24 @@ static void clean_up_mutexes() static void set_ports() { char *env; - if (!mysql_port && !opt_disable_networking) + if (!mysqld_port && !opt_disable_networking) { // Get port if not from commandline struct servent *serv_ptr; - mysql_port = MYSQL_PORT; - if ((serv_ptr = getservbyname("mysql", "tcp"))) - mysql_port = ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */ + mysqld_port= MYSQL_PORT; + if ((serv_ptr= getservbyname("mysql", "tcp"))) + mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */ if ((env = getenv("MYSQL_TCP_PORT"))) - mysql_port = (uint) atoi(env); /* purecov: inspected */ + mysqld_port= (uint) atoi(env); /* purecov: inspected */ } - if (!mysql_unix_port) + if (!mysqld_unix_port) { #ifdef __WIN__ - mysql_unix_port = (char*) MYSQL_NAMEDPIPE; + mysqld_unix_port= (char*) MYSQL_NAMEDPIPE; #else - mysql_unix_port = (char*) MYSQL_UNIX_ADDR; + mysqld_unix_port= (char*) MYSQL_UNIX_ADDR; #endif if ((env = getenv("MYSQL_UNIX_PORT"))) - mysql_unix_port = env; /* purecov: inspected */ + mysqld_unix_port= env; /* purecov: inspected */ } } @@ -1088,9 +1089,9 @@ static void server_init(void) set_ports(); - if (mysql_port != 0 && !opt_disable_networking && !opt_bootstrap) + if (mysqld_port != 0 && !opt_disable_networking && !opt_bootstrap) { - DBUG_PRINT("general",("IP Socket is %d",mysql_port)); + DBUG_PRINT("general",("IP Socket is %d",mysqld_port)); ip_sock = socket(AF_INET, SOCK_STREAM, 0); if (ip_sock == INVALID_SOCKET) { @@ -1101,14 +1102,14 @@ static void server_init(void) bzero((char*) &IPaddr, sizeof(IPaddr)); IPaddr.sin_family = AF_INET; IPaddr.sin_addr.s_addr = my_bind_addr; - IPaddr.sin_port = (unsigned short) htons((unsigned short) mysql_port); + IPaddr.sin_port = (unsigned short) htons((unsigned short) mysqld_port); (void) setsockopt(ip_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,sizeof(arg)); if (bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr), sizeof(IPaddr)) < 0) { DBUG_PRINT("error",("Got error: %d from bind",socket_errno)); sql_perror("Can't start server: Bind on TCP/IP port"); - sql_print_error("Do you already have another mysqld server running on port: %d ?",mysql_port); + sql_print_error("Do you already have another mysqld server running on port: %d ?",mysqld_port); unireg_abort(1); } if (listen(ip_sock,(int) back_log) < 0) @@ -1123,10 +1124,10 @@ static void server_init(void) #ifdef __NT__ /* create named pipe */ - if (Service.IsNT() && mysql_unix_port[0] && !opt_bootstrap && + if (Service.IsNT() && mysqld_unix_port[0] && !opt_bootstrap && opt_enable_named_pipe) { - sprintf(szPipeName, "\\\\.\\pipe\\%s", mysql_unix_port ); + sprintf(szPipeName, "\\\\.\\pipe\\%s", mysqld_unix_port ); ZeroMemory( &saPipeSecurity, sizeof(saPipeSecurity) ); ZeroMemory( &sdPipeDescriptor, sizeof(sdPipeDescriptor) ); if ( !InitializeSecurityDescriptor(&sdPipeDescriptor, @@ -1172,9 +1173,9 @@ static void server_init(void) /* ** Create the UNIX socket */ - if (mysql_unix_port[0] && !opt_bootstrap) + if (mysqld_unix_port[0] && !opt_bootstrap) { - DBUG_PRINT("general",("UNIX Socket is %s",mysql_unix_port)); + DBUG_PRINT("general",("UNIX Socket is %s",mysqld_unix_port)); if ((unix_sock= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { @@ -1183,8 +1184,8 @@ static void server_init(void) } bzero((char*) &UNIXaddr, sizeof(UNIXaddr)); UNIXaddr.sun_family = AF_UNIX; - strmov(UNIXaddr.sun_path, mysql_unix_port); - (void) unlink(mysql_unix_port); + strmov(UNIXaddr.sun_path, mysqld_unix_port); + (void) unlink(mysqld_unix_port); (void) setsockopt(unix_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg, sizeof(arg)); umask(0); @@ -1192,12 +1193,12 @@ static void server_init(void) sizeof(UNIXaddr)) < 0) { sql_perror("Can't start server : Bind on unix socket"); /* purecov: tested */ - sql_print_error("Do you already have another mysqld server running on socket: %s ?",mysql_unix_port); + sql_print_error("Do you already have another mysqld server running on socket: %s ?",mysqld_unix_port); unireg_abort(1); /* purecov: tested */ } umask(((~my_umask) & 0666)); #if defined(S_IFSOCK) && defined(SECURE_SOCKETS) - (void) chmod(mysql_unix_port,S_IFSOCK); /* Fix solaris 2.6 bug */ + (void) chmod(mysqld_unix_port,S_IFSOCK); /* Fix solaris 2.6 bug */ #endif if (listen(unix_sock,(int) back_log) < 0) sql_print_error("Warning: listen() on Unix socket failed with error %d", @@ -2024,6 +2025,7 @@ static int init_common_variables(const char *conf_file_name, int argc, #endif unireg_init(opt_specialflag); /* Set up extern variabels */ init_errmessage(); /* Read error messages from file */ + init_client_errs(); lex_init(); item_init(); set_var_init(); @@ -2426,7 +2428,7 @@ The server will not act as a slave."); (void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore #endif if (unix_sock != INVALID_SOCKET) - unlink(mysql_unix_port); + unlink(mysqld_unix_port); exit(1); } if (!opt_noacl) @@ -2458,8 +2460,8 @@ The server will not act as a slave."); create_maintenance_thread(); printf(ER(ER_READY),my_progname,server_version, - ((unix_sock == INVALID_SOCKET) ? (char*) "" : mysql_unix_port), - mysql_port); + ((unix_sock == INVALID_SOCKET) ? (char*) "" : mysqld_unix_port), + mysqld_port); fflush(stdout); #if defined(__NT__) || defined(HAVE_SMEM) @@ -3464,108 +3466,108 @@ enum options struct my_option my_long_options[] = { - {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax", 0, 0, 0, + {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"basedir", 'b', "Path to installation directory. All paths are usually resolved relative to this.", (gptr*) &mysql_home_ptr, (gptr*) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_BERKELEY_DB - {"bdb-home", OPT_BDB_HOME, "Berkeley home directory", (gptr*) &berkeley_home, + {"bdb-home", OPT_BDB_HOME, "Berkeley home directory.", (gptr*) &berkeley_home, (gptr*) &berkeley_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"bdb-lock-detect", OPT_BDB_LOCK, - "Berkeley lock detect (DEFAULT, OLDEST, RANDOM or YOUNGEST, # sec)", + "Berkeley lock detect (DEFAULT, OLDEST, RANDOM or YOUNGEST, # sec).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"bdb-logdir", OPT_BDB_LOG, "Berkeley DB log file directory", + {"bdb-logdir", OPT_BDB_LOG, "Berkeley DB log file directory.", (gptr*) &berkeley_logdir, (gptr*) &berkeley_logdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"bdb-no-recover", OPT_BDB_NO_RECOVER, - "Don't try to recover Berkeley DB tables on start", 0, 0, 0, GET_NO_ARG, + "Don't try to recover Berkeley DB tables on start.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"bdb-no-sync", OPT_BDB_NOSYNC, "Don't synchronously flush logs", 0, 0, 0, + {"bdb-no-sync", OPT_BDB_NOSYNC, "Don't synchronously flush logs.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"bdb-shared-data", OPT_BDB_SHARED, - "Start Berkeley DB in multi-process mode", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, + "Start Berkeley DB in multi-process mode.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"bdb-tmpdir", OPT_BDB_TMP, "Berkeley DB tempfile name", + {"bdb-tmpdir", OPT_BDB_TMP, "Berkeley DB tempfile name.", (gptr*) &berkeley_tmpdir, (gptr*) &berkeley_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_BERKELEY_DB */ {"bdb", OPT_BDB, "Enable Berkeley DB (if this version of MySQL supports it). \ -Disable with --skip-bdb (will save memory)", +Disable with --skip-bdb (will save memory).", (gptr*) &opt_bdb, (gptr*) &opt_bdb, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"big-tables", OPT_BIG_TABLES, - "Allow big result sets by saving all temporary sets on file (Solves most 'table full' errors)", + "Allow big result sets by saving all temporary sets on file (Solves most 'table full' errors).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"binlog-do-db", OPT_BINLOG_DO_DB, "Tells the master it should log updates for the specified database, and exclude all others not explicitly mentioned.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"binlog-ignore-db", OPT_BINLOG_IGNORE_DB, - "Tells the master that updates to the given database should not be logged tothe binary log", + "Tells the master that updates to the given database should not be logged tothe binary log.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to", + {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.", (gptr*) &my_bind_addr_str, (gptr*) &my_bind_addr_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts", 0, 0, 0, + {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows", + {"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows.", (gptr*) &opt_console, (gptr*) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __WIN__ {"standalone", OPT_STANDALONE, - "Dummy option to start as a standalone program (NT)", 0, 0, 0, GET_NO_ARG, + "Dummy option to start as a standalone program (NT).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"core-file", OPT_WANT_CORE, "Write core on errors", 0, 0, 0, GET_NO_ARG, + {"core-file", OPT_WANT_CORE, "Write core on errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"chroot", 'r', "Chroot mysqld daemon during startup.", (gptr*) &mysqld_chroot, (gptr*) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are", (gptr*) &charsets_dir, + "Directory where character sets are.", (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"datadir", 'h', "Path to the database root", (gptr*) &mysql_data_home, + {"datadir", 'h', "Path to the database root.", (gptr*) &mysql_data_home, (gptr*) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DBUG_OFF {"debug", '#', "Debug log.", (gptr*) &default_dbug_option, (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef SAFEMALLOC {"skip-safemalloc", OPT_SKIP_SAFEMALLOC, - "Don't use the memory allocation checking", 0, 0, 0, GET_NO_ARG, NO_ARG, + "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif #endif #ifdef HAVE_OPENSSL {"des-key-file", OPT_DES_KEY_FILE, - "Load keys for des_encrypt() and des_encrypt from given file", + "Load keys for des_encrypt() and des_encrypt from given file.", (gptr*) &des_key_file, (gptr*) &des_key_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_OPENSSL */ - {"default-character-set", 'C', "Set the default character set", - (gptr*) &default_character_set_name, (gptr*) &default_character_set_name, + {"default-character-set", 'C', "Set the default character set.", + (gptr*) &default_character_set_name, (gptr*) &default_character_set_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, - {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation", + {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation.", (gptr*) &default_collation_name, (gptr*) &default_collation_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"default-table-type", OPT_TABLE_TYPE, - "Set the default table type for tables", 0, 0, + "Set the default table type for tables.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE", + {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE.", 0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL, - "Don't flush key buffers between writes for any MyISAM table (Deprecated option, use --delay-key-write=all instead)", + "Don't flush key buffers between writes for any MyISAM table (Deprecated option, use --delay-key-write=all instead).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"enable-locking", OPT_ENABLE_LOCK, - "Deprecated option, use --external-locking instead", + "Deprecated option, use --external-locking instead.", (gptr*) &opt_external_locking, (gptr*) &opt_external_locking, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NT__ - {"enable-named-pipe", OPT_HAVE_NAMED_PIPE, "Enable the named pipe (NT)", + {"enable-named-pipe", OPT_HAVE_NAMED_PIPE, "Enable the named pipe (NT).", (gptr*) &opt_enable_named_pipe, (gptr*) &opt_enable_named_pipe, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"enable-pstack", OPT_DO_PSTACK, "Print a symbolic stack trace on failure", + {"enable-pstack", OPT_DO_PSTACK, "Print a symbolic stack trace on failure.", (gptr*) &opt_do_pstack, (gptr*) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM @@ -3575,23 +3577,23 @@ Disable with --skip-bdb (will save memory)", #endif {"exit-info", 'T', "Used for debugging; Use at your own risk!", 0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"flush", OPT_FLUSH, "Flush tables to disk between SQL commands", 0, 0, 0, + {"flush", OPT_FLUSH, "Flush tables to disk between SQL commands.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN, "The maximum length of the result of function group_concat.", - (gptr*) &global_system_variables.group_concat_max_len, + (gptr*) &global_system_variables.group_concat_max_len, (gptr*) &max_system_variables.group_concat_max_len, 0, GET_ULONG, REQUIRED_ARG, 1024, 4, (long) ~0, 0, 1, 0}, /* We must always support the next option to make scripts like mysqltest easier to do */ - {"init-rpl-role", OPT_INIT_RPL_ROLE, "Set the replication role", 0, 0, 0, + {"init-rpl-role", OPT_INIT_RPL_ROLE, "Set the replication role.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_data_file_path", OPT_INNODB_DATA_FILE_PATH, - "Path to individual files and their sizes", + "Path to individual files and their sizes.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_INNOBASE_DB {"innodb_data_home_dir", OPT_INNODB_DATA_HOME_DIR, - "The common part for Innodb table spaces", (gptr*) &innobase_data_home_dir, + "The common part for Innodb table spaces.", (gptr*) &innobase_data_home_dir, (gptr*) &innobase_data_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_log_group_home_dir", OPT_INNODB_LOG_GROUP_HOME_DIR, @@ -3599,53 +3601,52 @@ Disable with --skip-bdb (will save memory)", (gptr*) &innobase_log_group_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_log_arch_dir", OPT_INNODB_LOG_ARCH_DIR, - "Where full logs should be archived", (gptr*) &innobase_log_arch_dir, + "Where full logs should be archived.", (gptr*) &innobase_log_arch_dir, (gptr*) &innobase_log_arch_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_log_archive", OPT_INNODB_LOG_ARCHIVE, - "Set to 1 if you want to have logs archived", 0, 0, 0, GET_LONG, OPT_ARG, + "Set to 1 if you want to have logs archived.", 0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_flush_log_at_trx_commit", OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT, - "Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2 (write at commit, flush once per second)", + "Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2 (write at commit, flush once per second).", (gptr*) &innobase_flush_log_at_trx_commit, (gptr*) &innobase_flush_log_at_trx_commit, 0, GET_UINT, OPT_ARG, 1, 0, 2, 0, 0, 0}, {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD, - "With which method to flush data", (gptr*) &innobase_unix_file_flush_method, + "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method, (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN, - "Speeds up server shutdown process", (gptr*) &innobase_fast_shutdown, + "Speeds up server shutdown process.", (gptr*) &innobase_fast_shutdown, (gptr*) &innobase_fast_shutdown, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT, - "Percentage of dirty pages allowed in bufferpool", (gptr*) &srv_max_buf_pool_modified_pct, + "Percentage of dirty pages allowed in bufferpool.", (gptr*) &srv_max_buf_pool_modified_pct, (gptr*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0}, - #endif /* End HAVE_INNOBASE_DB */ - {"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, + {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"init-file", OPT_INIT_FILE, "Read SQL commands from this file at startup", + {"init-file", OPT_INIT_FILE, "Read SQL commands from this file at startup.", (gptr*) &opt_init_file, (gptr*) &opt_init_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"log", 'l', "Log connections and queries to file", (gptr*) &opt_logname, + {"log", 'l', "Log connections and queries to file.", (gptr*) &opt_logname, (gptr*) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"language", 'L', - "Client error messages in given language. May be given as a full path", + "Client error messages in given language. May be given as a full path.", (gptr*) &language_ptr, (gptr*) &language_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"local-infile", OPT_LOCAL_INFILE, - "Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0)", + "Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0).", (gptr*) &opt_local_infile, (gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"log-bin", OPT_BIN_LOG, - "Log update queries in binary format", + "Log update queries in binary format.", (gptr*) &opt_bin_logname, (gptr*) &opt_bin_logname, 0, GET_STR_ALLOC, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-bin-index", OPT_BIN_LOG_INDEX, - "File that holds the names for last binary log files", + "File that holds the names for last binary log files.", (gptr*) &opt_binlog_index_name, (gptr*) &opt_binlog_index_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file", + {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.", (gptr*) &myisam_log_filename, (gptr*) &myisam_log_filename, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-update", OPT_UPDATE_LOG, @@ -3653,18 +3654,18 @@ Disable with --skip-bdb (will save memory)", (gptr*) &opt_update_logname, (gptr*) &opt_update_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-slow-queries", OPT_SLOW_QUERY_LOG, - "Log slow queries to this log file. Defaults logging to hostname-slow.log", + "Log slow queries to this log file. Defaults logging to hostname-slow.log file.", (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-long-format", OPT_LONG_FORMAT, - "Log some extra information to update log", 0, 0, 0, GET_NO_ARG, NO_ARG, + "Log some extra information to update log.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"log-slave-updates", OPT_LOG_SLAVE_UPDATES, "Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.", (gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"low-priority-updates", OPT_LOW_PRIORITY_UPDATES, - "INSERT/DELETE/UPDATE has lower priority than selects", + "INSERT/DELETE/UPDATE has lower priority than selects.", (gptr*) &global_system_variables.low_priority_updates, (gptr*) &max_system_variables.low_priority_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -3680,7 +3681,7 @@ Disable with --skip-bdb (will save memory)", "The password the slave thread will authenticate with when connecting to the master. If not set, an empty password is assumed.The value in master.info will take precedence if it can be read.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-port", OPT_MASTER_PORT, - "The port the master is listening on. If not set, the compiled setting of MYSQL_PORT is assumed. If you have not tinkered with configure options, this should be 3306. The value in master.info will take precedence if it can be read", + "The port the master is listening on. If not set, the compiled setting of MYSQL_PORT is assumed. If you have not tinkered with configure options, this should be 3306. The value in master.info will take precedence if it can be read.", (gptr*) &master_port, (gptr*) &master_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, {"master-connect-retry", OPT_MASTER_CONNECT_RETRY, @@ -3724,61 +3725,61 @@ Does nothing yet.", "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP or FORCE.", (gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"memlock", OPT_MEMLOCK, "Lock mysqld in memory", (gptr*) &locked_in_memory, + {"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (gptr*) &locked_in_memory, (gptr*) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_REPLICATION {"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT, - "Option used by mysql-test for debugging and testing of replication", + "Option used by mysql-test for debugging and testing of replication.", (gptr*) &disconnect_slave_event_count, (gptr*) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"abort-slave-event-count", OPT_ABORT_SLAVE_EVENT_COUNT, - "Option used by mysql-test for debugging and testing of replication", + "Option used by mysql-test for debugging and testing of replication.", (gptr*) &abort_slave_event_count, (gptr*) &abort_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"max-binlog-dump-events", OPT_MAX_BINLOG_DUMP_EVENTS, - "Option used by mysql-test for debugging and testing of replication", + "Option used by mysql-test for debugging and testing of replication.", (gptr*) &max_binlog_dump_events, (gptr*) &max_binlog_dump_events, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"sporadic-binlog-dump-fail", OPT_SPORADIC_BINLOG_DUMP_FAIL, - "Option used by mysql-test for debugging and testing of replication", + "Option used by mysql-test for debugging and testing of replication.", (gptr*) &opt_sporadic_binlog_dump_fail, (gptr*) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ {"safemalloc-mem-limit", OPT_SAFEMALLOC_MEM_LIMIT, - "Simulate memory shortage when compiled with the --with-debug=full option", + "Simulate memory shortage when compiled with the --with-debug=full option.", 0, 0, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"new", 'n', "Use very new possible 'unsafe' functions", + {"new", 'n', "Use very new possible 'unsafe' functions.", (gptr*) &global_system_variables.new_mode, (gptr*) &max_system_variables.new_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef NOT_YET - {"no-mix-table-types", OPT_NO_MIX_TYPE, "Don't allow commands with uses two different table types", + {"no-mix-table-types", OPT_NO_MIX_TYPE, "Don't allow commands with uses two different table types.", (gptr*) &opt_no_mix_types, (gptr*) &opt_no_mix_types, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"old-protocol", 'o', "Use the old (3.20) protocol client/server protocol", + {"old-protocol", 'o', "Use the old (3.20) protocol client/server protocol.", (gptr*) &protocol_version, (gptr*) &protocol_version, 0, GET_UINT, NO_ARG, PROTOCOL_VERSION, 0, 0, 0, 0, 0}, {"old-rpl-compat", OPT_OLD_RPL_COMPAT, - "Use old LOAD DATA format in the binary log (don't save data in file)", + "Use old LOAD DATA format in the binary log (don't save data in file).", (gptr*) &opt_old_rpl_compat, (gptr*) &opt_old_rpl_compat, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef ONE_THREAD {"one-thread", OPT_ONE_THREAD, - "Only use one thread (for debugging under Linux)", 0, 0, 0, GET_NO_ARG, + "Only use one thread (for debugging under Linux).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld", + {"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld.", (gptr*) &pidfile_name_ptr, (gptr*) &pidfile_name_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"log-error", OPT_ERROR_LOG_FILE, "Log error file", + {"log-error", OPT_ERROR_LOG_FILE, "Log error file.", (gptr*) &log_error_file_ptr, (gptr*) &log_error_file_ptr, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &mysql_port, - (gptr*) &mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"reckless-slave", OPT_RECKLESS_SLAVE, "For debugging", 0, 0, 0, GET_NO_ARG, + {"port", 'P', "Port number to use for connection.", (gptr*) &mysqld_port, + (gptr*) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"reckless-slave", OPT_RECKLESS_SLAVE, "Used for debugging.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"replicate-do-db", OPT_REPLICATE_DO_DB, "Tells the slave thread to restrict replication to the specified database. To specify more than one database, use the directive multiple times, once for each database. Note that this will only work if you do not use cross-database queries such as UPDATE some_db.some_table SET foo='bar' while having selected a different or no database. If you need cross database updates to work, make sure you have 3.23.28 or later, and use replicate-wild-do-table=db_name.%.", @@ -3787,7 +3788,7 @@ Does nothing yet.", "Tells the slave thread to restrict replication to the specified table. To specify more than one table, use the directive multiple times, once for each table. This will work for cross-database updates, in contrast to replicate-do-db.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE, - "Tells the slave thread to restrict replication to the tables that match the specified wildcard pattern. To specify more than one table, use the directive multiple times, once for each table. This will work for cross-database updates. Example: replicate-wild-do-table=foo%.bar% will replicate only updates to tables in all databases that start with foo and whose table names start with bar", + "Tells the slave thread to restrict replication to the tables that match the specified wildcard pattern. To specify more than one table, use the directive multiple times, once for each table. This will work for cross-database updates. Example: replicate-wild-do-table=foo%.bar% will replicate only updates to tables in all databases that start with foo and whose table names start with bar.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"replicate-ignore-db", OPT_REPLICATE_IGNORE_DB, "Tells the slave thread to not replicate to the specified database. To specify more than one database to ignore, use the directive multiple times, once for each database. This option will not work if you use cross database updates. If you need cross database updates to work, make sure you have 3.23.28 or later, and use replicate-wild-ignore-table=db_name.%. ", @@ -3799,37 +3800,37 @@ Does nothing yet.", "Tells the slave thread to not replicate to the tables that match the given wildcard pattern. To specify more than one table to ignore, use the directive multiple times, once for each table. This will work for cross-database updates. Example: replicate-wild-ignore-table=foo%.bar% will not do updates to tables in databases that start with foo and whose table names start with bar.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"replicate-rewrite-db", OPT_REPLICATE_REWRITE_DB, - "Updates to a database with a different name than the original. Example: replicate-rewrite-db=master_db_name->slave_db_name", + "Updates to a database with a different name than the original. Example: replicate-rewrite-db=master_db_name->slave_db_name.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, // In replication, we may need to tell the other servers how to connect {"report-host", OPT_REPORT_HOST, "Hostname or IP of the slave to be reported to to the master during slave registration. Will appear in the output of SHOW SLAVE HOSTS. Leave unset if you do not want the slave to register itself with the master. Note that it is not sufficient for the master to simply read the IP of the slave off the socket once the slave connects. Due to NAT and other routing issues, that IP may not be valid for connecting to the slave from the master or other hosts.", (gptr*) &report_host, (gptr*) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"report-user", OPT_REPORT_USER, "Undocumented", (gptr*) &report_user, + {"report-user", OPT_REPORT_USER, "Undocumented.", (gptr*) &report_user, (gptr*) &report_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"report-password", OPT_REPORT_PASSWORD, "Undocumented", + {"report-password", OPT_REPORT_PASSWORD, "Undocumented.", (gptr*) &report_password, (gptr*) &report_password, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"report-port", OPT_REPORT_PORT, "Port for connecting to slave reported to the master during slave registration. Set it only if the slave is listening on a non-default port or if you have a special tunnel from the master or other clients to the slave. If not sure, leave this option unset.", (gptr*) &report_port, (gptr*) &report_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented", + {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.", (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"relay-log", OPT_RELAY_LOG, - "The location and name to use for relay logs", + {"relay-log", OPT_RELAY_LOG, + "The location and name to use for relay logs.", (gptr*) &opt_relay_logname, (gptr*) &opt_relay_logname, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"relay-log-index", OPT_RELAY_LOG_INDEX, + {"relay-log-index", OPT_RELAY_LOG_INDEX, "The location and name to use for the file that keeps a list of the last \ -relay logs", +relay logs.", (gptr*) &opt_relaylog_index_name, (gptr*) &opt_relaylog_index_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"old-passwords", OPT_OLD_PASSWORDS, "Use old password encryption method (needed for 4.0 and older clients)", + {"old-passwords", OPT_OLD_PASSWORDS, "Use old password encryption method (needed for 4.0 and older clients).", (gptr*) &opt_old_passwords, (gptr*) &opt_old_passwords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef TO_BE_DELETED {"safe-show-database", OPT_SAFE_SHOW_DB, @@ -3837,11 +3838,11 @@ relay logs", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"safe-user-create", OPT_SAFE_USER_CREATE, - "Don't allow new user creation by the user who has no write privileges to the mysql.user table", + "Don't allow new user creation by the user who has no write privileges to the mysql.user table.", (gptr*) &opt_safe_user_create, (gptr*) &opt_safe_user_create, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"server-id", OPT_SERVER_ID, - "Uniquely identifies the server instance in the community of replication partners", + "Uniquely identifies the server instance in the community of replication partners.", (gptr*) &server_id, (gptr*) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"set-variable", 'O', @@ -3849,15 +3850,15 @@ relay logs", 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", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"show-slave-auth-info", OPT_SHOW_SLAVE_AUTH_INFO, - "Show user and password in SHOW SLAVE STATUS", + "Show user and password in SHOW SLAVE STATUS.", (gptr*) &opt_show_slave_auth_info, (gptr*) &opt_show_slave_auth_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"concurrent-insert", OPT_CONCURRENT_INSERT, - "Use concurrent insert with MyISAM. Disable with prefix --skip-", + "Use concurrent insert with MyISAM. Disable with --skip-concurrent-insert.", (gptr*) &myisam_concurrent_insert, (gptr*) &myisam_concurrent_insert, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-grant-tables", OPT_SKIP_GRANT, @@ -3865,20 +3866,20 @@ relay logs", (gptr*) &opt_noacl, (gptr*) &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"innodb", OPT_INNODB, "Enable InnoDB (if this version of MySQL supports it). \ -Disable with --skip-innodb (will save memory)", +Disable with --skip-innodb (will save memory).", (gptr*) &opt_innodb, (gptr*) &opt_innodb, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"isam", OPT_ISAM, "Enable isam (if this version of MySQL supports it). \ -Disable with --skip-isam", +Disable with --skip-isam.", (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-locking", OPT_SKIP_LOCK, - "Deprecated option, use --skip-external-locking instead", + "Deprecated option, use --skip-external-locking instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names", 0, 0, 0, + {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-name-resolve", OPT_SKIP_RESOLVE, - "Don't resolve hostnames. All hostnames are IP's or 'localhost'", + "Don't resolve hostnames. All hostnames are IP's or 'localhost'.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-networking", OPT_SKIP_NETWORKING, "Don't allow connection with TCP/IP.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, @@ -3886,36 +3887,36 @@ Disable with --skip-isam", {"skip-new", OPT_SKIP_NEW, "Don't use new, possible wrong routines.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-show-database", OPT_SKIP_SHOW_DB, - "Don't allow 'SHOW DATABASE' commands", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, + "Don't allow 'SHOW DATABASE' commands.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-slave-start", OPT_SKIP_SLAVE_START, "If set, slave is not autostarted.", (gptr*) &opt_skip_slave_start, (gptr*) &opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-stack-trace", OPT_SKIP_STACK_TRACE, - "Don't print a stack trace on failure", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, + "Don't print a stack trace on failure.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables. Depricated option. Use --skip-symbolic-links instead", + {"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables. Depricated option. Use --skip-symbolic-links instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-thread-priority", OPT_SKIP_PRIOR, "Don't give threads different priorities.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE, + {"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE, "The location and name of the file that remembers where the SQL replication \ -thread is in the relay logs", +thread is in the relay logs.", (gptr*) &relay_log_info_file, (gptr*) &relay_log_info_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_REPLICATION - {"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR, + {"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR, "The location where the slave should put its temporary files when \ -replicating a LOAD DATA INFILE command", +replicating a LOAD DATA INFILE command.", (gptr*) &slave_load_tmpdir, (gptr*) &slave_load_tmpdir, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"slave-skip-errors", OPT_SLAVE_SKIP_ERRORS, - "Tells the slave thread to continue replication when a query returns an error from the provided list", + "Tells the slave thread to continue replication when a query returns an error from the provided list.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"socket", OPT_SOCKET, "Socket file to use for connection", - (gptr*) &mysql_unix_port, (gptr*) &mysql_unix_port, 0, GET_STR, + {"socket", OPT_SOCKET, "Socket file to use for connection.", + (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME, "If set, setting SQL_LOG_BIN to a value will automatically set SQL_LOG_UPDATE to the same value and vice versa.", @@ -3943,28 +3944,28 @@ replicating a LOAD DATA INFILE command", (gptr*) &opt_mysql_tmpdir, (gptr*) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"transaction-isolation", OPT_TX_ISOLATION, - "Default transaction isolation level", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, + "Default transaction isolation level.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"external-locking", OPT_USE_LOCKING, "Use system (external) locking. With this option enabled you can run myisamchk to test (not repair) tables while the MySQL server is running", + {"external-locking", OPT_USE_LOCKING, "Use system (external) locking. With this option enabled you can run myisamchk to test (not repair) tables while the MySQL server is running.", (gptr*) &opt_external_locking, (gptr*) &opt_external_locking, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"use-symbolic-links", 's', "Enable symbolic link support. Depricated option; Use --symbolic-links instead", + {"use-symbolic-links", 's', "Enable symbolic link support. Depricated option; Use --symbolic-links instead.", (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG, IF_PURIFY(0,1), 0, 0, 0, 0, 0}, - {"--symbolic-links", 's', "Enable symbolic link support", + {"--symbolic-links", 's', "Enable symbolic link support.", (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG, IF_PURIFY(0,1), 0, 0, 0, 0, 0}, - {"user", 'u', "Run mysqld daemon as user", 0, 0, 0, GET_STR, REQUIRED_ARG, + {"user", 'u', "Run mysqld daemon as user.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"version", 'V', "Output version information and exit", 0, 0, 0, GET_NO_ARG, + {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"version", 'v', "Synonym for option -v", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, + {"version", 'v', "Synonym for option -V.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"log-warnings", 'W', "Log some not critical warnings to the log file", + {"log-warnings", 'W', "Log some not critical warnings to the log file.", (gptr*) &global_system_variables.log_warnings, (gptr*) &max_system_variables.log_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"warnings", 'W', "Deprecated ; Use --log-warnings instead", + {"warnings", 'W', "Deprecated ; Use --log-warnings instead.", (gptr*) &global_system_variables.log_warnings, (gptr*) &max_system_variables.log_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -3986,7 +3987,7 @@ replicating a LOAD DATA INFILE command", (gptr*) &berkeley_max_lock, (gptr*) &berkeley_max_lock, 0, GET_ULONG, REQUIRED_ARG, 10000, 0, (long) ~0, 0, 1, 0}, /* QQ: The following should be removed soon! */ - {"bdb_lock_max", OPT_BDB_MAX_LOCK, "Synonym for bdb_max_lock", + {"bdb_lock_max", OPT_BDB_MAX_LOCK, "Synonym for bdb_max_lock.", (gptr*) &berkeley_max_lock, (gptr*) &berkeley_max_lock, 0, GET_ULONG, REQUIRED_ARG, 10000, 0, (long) ~0, 0, 1, 0}, #endif /* HAVE_BERKELEY_DB */ @@ -3995,7 +3996,7 @@ replicating a LOAD DATA INFILE command", (gptr*) &binlog_cache_size, (gptr*) &binlog_cache_size, 0, GET_ULONG, REQUIRED_ARG, 32*1024L, IO_SIZE, ~0L, 0, IO_SIZE, 0}, {"connect_timeout", OPT_CONNECT_TIMEOUT, - "The number of seconds the mysqld server is waiting for a connect packet before responding with Bad handshake", + "The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake'.", (gptr*) &connect_timeout, (gptr*) &connect_timeout, 0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 }, {"delayed_insert_timeout", OPT_DELAYED_INSERT_TIMEOUT, @@ -4135,7 +4136,7 @@ replicating a LOAD DATA INFILE command", (gptr*) &max_insert_delayed_threads, (gptr*) &max_insert_delayed_threads, 0, GET_ULONG, REQUIRED_ARG, 20, 0, 16384, 0, 1, 0}, {"max_error_count", OPT_MAX_ERROR_COUNT, - "Max number of errors/warnings to store for a statement", + "Max number of errors/warnings to store for a statement.", (gptr*) &global_system_variables.max_error_count, (gptr*) &max_system_variables.max_error_count, 0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 1, 65535, 0, 1, 0}, @@ -4150,12 +4151,12 @@ replicating a LOAD DATA INFILE command", (gptr*) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0}, {"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA, - "Max number of bytes in sorted records", + "Max number of bytes in sorted records.", (gptr*) &global_system_variables.max_length_for_sort_data, (gptr*) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG, REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0}, {"max_prepared_statements", OPT_MAX_PREP_STMT, - "Max number of prepared_statements for a thread", + "Max number of prepared_statements for a thread.", (gptr*) &global_system_variables.max_prep_stmt_count, (gptr*) &max_system_variables.max_prep_stmt_count, 0, GET_ULONG, REQUIRED_ARG, DEFAULT_PREP_STMT_COUNT, 0, ~0L, 0, 1, 0}, @@ -4183,19 +4184,19 @@ replicating a LOAD DATA INFILE command", (gptr*) &max_system_variables.bulk_insert_buff_size, 0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ~0L, 0, 1, 0}, {"myisam_block_size", OPT_MYISAM_BLOCK_SIZE, - "Block size to be used for MyISAM index pages", + "Block size to be used for MyISAM index pages.", (gptr*) &opt_myisam_block_size, (gptr*) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG, MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, 0, MI_MIN_KEY_BLOCK_LENGTH, 0}, {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE, - "Used to help MySQL to decide when to use the slow but safe key cache index create method", + "Used to help MySQL to decide when to use the slow but safe key cache index create method.", (gptr*) &global_system_variables.myisam_max_extra_sort_file_size, (gptr*) &max_system_variables.myisam_max_extra_sort_file_size, 0, GET_ULL, REQUIRED_ARG, (ulonglong) MI_MAX_TEMP_LENGTH, 0, (ulonglong) MAX_FILE_SIZE, 0, 1, 0}, {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE, - "Don't use the fast sort index method to created index if the temporary file would get bigger than this!", + "Don't use the fast sort index method to created index if the temporary file would get bigger than this.", (gptr*) &global_system_variables.myisam_max_sort_file_size, (gptr*) &max_system_variables.myisam_max_sort_file_size, 0, GET_ULL, REQUIRED_ARG, (longlong) LONG_MAX, 0, (ulonglong) MAX_FILE_SIZE, @@ -4284,12 +4285,12 @@ replicating a LOAD DATA INFILE command", (gptr*) &relay_log_purge, 0, GET_BOOL, NO_ARG, 1, 0, 1, 0, 1, 0}, {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT, - "Maximum space to use for all relay logs", + "Maximum space to use for all relay logs.", (gptr*) &relay_log_space_limit, (gptr*) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L, (longlong) ULONG_MAX, 0, 1, 0}, {"slave_compressed_protocol", OPT_SLAVE_COMPRESSED_PROTOCOL, - "Use compression on master/slave protocol", + "Use compression on master/slave protocol.", (gptr*) &opt_slave_compressed_protocol, (gptr*) &opt_slave_compressed_protocol, 0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0}, @@ -4299,7 +4300,7 @@ replicating a LOAD DATA INFILE command", GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, #endif /* HAVE_REPLICATION */ {"read-only", OPT_READONLY, - "Make all tables readonly, with the expections for replications (slave) threads and users with the SUPER privilege", + "Make all tables readonly, with the expections for replications (slave) threads and users with the SUPER privilege.", (gptr*) &opt_readonly, (gptr*) &opt_readonly, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, @@ -4335,7 +4336,7 @@ replicating a LOAD DATA INFILE command", (gptr*) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK, 1024*32, ~0L, 0, 1024, 0}, {"wait_timeout", OPT_WAIT_TIMEOUT, - "The number of seconds the server waits for activity on a connection before closing it", + "The number of seconds the server waits for activity on a connection before closing it.", (gptr*) &global_system_variables.net_wait_timeout, (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, @@ -4346,13 +4347,12 @@ replicating a LOAD DATA INFILE command", REQUIRED_ARG, 0, 0, 99, 0, 1, 0}, { "default-week-format", OPT_DEFAULT_WEEK_FORMAT, "The default week format used by WEEK() functions.", - (gptr*) &global_system_variables.default_week_format, - (gptr*) &max_system_variables.default_week_format, + (gptr*) &global_system_variables.default_week_format, + (gptr*) &max_system_variables.default_week_format, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3L, 0, 1, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; - struct show_var_st status_vars[]= { {"Aborted_clients", (char*) &aborted_threads, SHOW_LONG}, {"Aborted_connects", (char*) &aborted_connects, SHOW_LONG}, @@ -4636,7 +4636,7 @@ static void mysql_init_variables(void) max_sort_char= 0; mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0; errmesg= 0; - mysql_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS; + mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS; bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); bzero((gptr) &com_stat, sizeof(com_stat)); @@ -5043,7 +5043,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case (int) OPT_SKIP_NETWORKING: opt_disable_networking=1; - mysql_port=0; + mysqld_port=0; break; case (int) OPT_SKIP_SHOW_DB: opt_skip_show_db=1; diff --git a/sql/protocol.cc b/sql/protocol.cc index 10fe2c1725e..1d730836d6e 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -103,8 +103,7 @@ void send_error(THD *thd, uint sql_errno, const char *err) { /* The first # is to make the protocol backward compatible */ buff[2]= '#'; - strmov(buff+3, mysql_errno_to_sqlstate(sql_errno)); - pos= buff + 2 + SQLSTATE_LENGTH +1; + pos= strmov(buff+3, mysql_errno_to_sqlstate(sql_errno)); } length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff); err=buff; @@ -236,28 +235,6 @@ net_printf(THD *thd, uint errcode, ...) DBUG_VOID_RETURN; } -/* - Function called by my_net_init() to set some check variables -*/ - -#ifndef EMBEDDED_LIBRARY -extern "C" { -void my_net_local_init(NET *net) -{ - net->max_packet= (uint) global_system_variables.net_buffer_length; - net->read_timeout= (uint) global_system_variables.net_read_timeout; - net->write_timeout=(uint) global_system_variables.net_write_timeout; - net->retry_count= (uint) global_system_variables.net_retry_count; - net->max_packet_size= max(global_system_variables.net_buffer_length, - global_system_variables.max_allowed_packet); -} -} - -#else /* EMBEDDED_LIBRARY */ -void my_net_local_init(NET *net __attribute__(unused)) -{ -} -#endif /* EMBEDDED_LIBRARY */ /* Return ok to the client. diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index bbfd7866aa2..60af9a92c76 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -450,11 +450,11 @@ int show_new_master(THD* thd) /* Asks the master for the list of its other connected slaves. - This is for failsafe replication : - in order for failsafe replication to work, the servers involved in replication - must know of each other. We accomplish this by having each slave report to the - master how to reach it, and on connection, each slave receives information - about where the other slaves are. + This is for failsafe replication: + in order for failsafe replication to work, the servers involved in + replication must know of each other. We accomplish this by having each + slave report to the master how to reach it, and on connection, each + slave receives information about where the other slaves are. SYNOPSIS update_slave_list() @@ -466,8 +466,8 @@ int show_new_master(THD* thd) hostname/port of the master, the username used by the slave to connect to the master. If the user used by the slave to connect to the master does not have the - REPLICATION SLAVE privilege, it will pop in this function because SHOW SLAVE - HOSTS will fail on the master. + REPLICATION SLAVE privilege, it will pop in this function because + SHOW SLAVE HOSTS will fail on the master. RETURN VALUES 1 error @@ -483,7 +483,6 @@ int update_slave_list(MYSQL* mysql, MASTER_INFO* mi) int port_ind; DBUG_ENTER("update_slave_list"); - if (mysql_real_query(mysql,"SHOW SLAVE HOSTS",16) || !(res = mysql_store_result(mysql))) { @@ -668,8 +667,10 @@ int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi) strmov(mysql->net.last_error, "Master is not configured"); DBUG_RETURN(1); } - mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&slave_net_timeout); - mysql_options(mysql, MYSQL_SET_CHARSET_NAME, (char *)default_charset_info); + mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout); + mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout); + mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname); + mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir); if (!mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0, mi->port, 0, 0)) DBUG_RETURN(1); diff --git a/sql/set_var.cc b/sql/set_var.cc index f71390d500d..a281fac530a 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -603,7 +603,7 @@ struct show_var_st init_vars[]= { {"open_files_limit", (char*) &open_files_limit, SHOW_LONG}, {"pid_file", (char*) pidfile_name, SHOW_CHAR}, {"log_error", (char*) log_error_file, SHOW_CHAR}, - {"port", (char*) &mysql_port, SHOW_INT}, + {"port", (char*) &mysqld_port, SHOW_INT}, {"protocol_version", (char*) &protocol_version, SHOW_INT}, {sys_preload_buff_size.name, (char*) &sys_preload_buff_size, SHOW_SYS}, {sys_pseudo_thread_id.name, (char*) &sys_pseudo_thread_id, SHOW_SYS}, @@ -635,7 +635,7 @@ struct show_var_st init_vars[]= { {"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL}, {sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS}, #ifdef HAVE_SYS_UN_H - {"socket", (char*) &mysql_unix_port, SHOW_CHAR_PTR}, + {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR}, #endif {sys_sort_buffer.name, (char*) &sys_sort_buffer, SHOW_SYS}, {sys_sql_mode.name, (char*) &sys_sql_mode, SHOW_SYS}, diff --git a/sql/share/charsets/Index.xml b/sql/share/charsets/Index.xml index 6e091066654..c5a2ae5dfb6 100644 --- a/sql/share/charsets/Index.xml +++ b/sql/share/charsets/Index.xml @@ -208,7 +208,7 @@ To make maintaining easier please: <alias>windows-1251</alias> <alias>ms-cyr</alias> <alias>ms-cyrillic</alias> - <collation name="cp1251_bulgarian_ci" id="14" flag="primary"> + <collation name="cp1251_bulgarian_ci" id="14"> <order>Belarusian</order> <order>Bulgarian</order> <order>Macedonian</order> @@ -219,7 +219,7 @@ To make maintaining easier please: </collation> <collation name="cp1251_ukrainian_ci" id="23" order="Ukrainian"/> <collation name="cp1251_bin" id="50" order="Binary" flag="binary"/> - <collation name="cp1251_general_ci" id="51"> + <collation name="cp1251_general_ci" id="51" flag="primary"> <order>Belarusian</order> <order>Bulgarian</order> <order>Macedonian</order> diff --git a/sql/slave.cc b/sql/slave.cc index 504bb0309cc..ccce8077cb8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -71,7 +71,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, MASTER_INFO* mi, static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed, void* thread_killed_arg); static int request_table_dump(MYSQL* mysql, const char* db, const char* table); -static int create_table_from_dump(THD* thd, NET* net, const char* db, +static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, const char* table_name); static int check_master_version(MYSQL* mysql, MASTER_INFO* mi); char* rewrite_db(char* db); @@ -1049,10 +1049,10 @@ static int check_master_version(MYSQL* mysql, MASTER_INFO* mi) } -static int create_table_from_dump(THD* thd, NET* net, const char* db, +static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, const char* table_name) { - ulong packet_len = my_net_read(net); // read create table statement + ulong packet_len; char *query; Vio* save_vio; HA_CHECK_OPT check_opt; @@ -1060,7 +1060,9 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db, int error= 1; handler *file; ulong save_options; + NET *net= &mysql->net; + packet_len= my_net_read(net); // read create table statement if (packet_len == packet_error) { send_error(thd, ER_MASTER_NET_READ); @@ -1068,32 +1070,27 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db, } if (net->read_pos[0] == 255) // error from master { - net->read_pos[packet_len] = 0; - net_printf(thd, ER_MASTER, net->read_pos + 3); + char *err_msg; + err_msg= (char*) net->read_pos + ((mysql->server_capabilities & + CLIENT_PROTOCOL_41) ? + 3+SQLSTATE_LENGTH+1 : 3); + net_printf(thd, ER_MASTER, err_msg); return 1; } thd->command = COM_TABLE_DUMP; + thd->query_length= packet_len; /* Note that we should not set thd->query until the area is initalized */ - if (!(query = sql_alloc(packet_len + 1))) + if (!(query = thd->strmake((char*) net->read_pos, packet_len))) { sql_print_error("create_table_from_dump: out of memory"); net_printf(thd, ER_GET_ERRNO, "Out of memory"); return 1; } - memcpy(query, net->read_pos, packet_len); - query[packet_len]= 0; - thd->query_length= packet_len; - /* - We make the following lock in an attempt to ensure that the compiler will - not rearrange the code so that thd->query is set too soon - */ - VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query= query; - VOID(pthread_mutex_unlock(&LOCK_thread_count)); thd->current_tablenr = 0; thd->query_error = 0; thd->net.no_send_ok = 1; - + /* we do not want to log create table statement */ save_options = thd->options; thd->options &= ~(ulong) (OPTION_BIN_LOG); @@ -1185,8 +1182,7 @@ int fetch_master_table(THD *thd, const char *db_name, const char *table_name, errmsg= "Failed on table dump request"; goto err; } - if (create_table_from_dump(thd, &mysql->net, db_name, - table_name)) + if (create_table_from_dump(thd, mysql, db_name, table_name)) goto err; // create_table_from_dump will have sent the error already error = 0; @@ -2996,17 +2992,20 @@ static int connect_to_master(THD* thd, MYSQL* mysql, MASTER_INFO* mi, #ifndef DBUG_OFF events_till_disconnect = disconnect_slave_event_count; #endif - uint client_flag=0; + ulong client_flag= CLIENT_REMEMBER_OPTIONS; if (opt_slave_compressed_protocol) client_flag=CLIENT_COMPRESS; /* We will use compression */ + mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout); + mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout); + mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname); + /* This one is not strictly needed but we have it here for completeness */ + mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir); + while (!(slave_was_killed = io_slave_killed(thd,mi)) && - (reconnect ? mysql_reconnect(mysql) != 0: - !(mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, - (char *)&thd->variables.net_read_timeout), - mysql_options(mysql, MYSQL_SET_CHARSET_NAME, (char *)default_charset_info), - mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0, - mi->port, 0, client_flag)))) + (reconnect ? mysql_reconnect(mysql) != 0 : + mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0, + mi->port, 0, client_flag) == 0)) { /* Don't repeat last error */ if ((int)mysql_errno(mysql) != last_errno) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 49aad321702..1bdca7167e8 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3337,15 +3337,19 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) } tables[0].table->field[0]->store(user_name->host.str,(uint) - user_name->host.length, system_charset_info); + user_name->host.length, + system_charset_info); tables[0].table->field[1]->store(user_name->user.str,(uint) - user_name->user.length, system_charset_info); + user_name->user.length, + system_charset_info); if (!tables[0].table->file->index_read_idx(tables[0].table->record[0],0, - (byte*) tables[0].table->field[0]->ptr,0, + (byte*) tables[0].table-> + field[0]->ptr,0, HA_READ_KEY_EXACT)) { int error; - if ((error = tables[0].table->file->delete_row(tables[0].table->record[0]))) + if ((error = tables[0].table->file->delete_row(tables[0].table-> + record[0]))) { tables[0].table->file->print_error(error, MYF(0)); tables[0].table->file->index_end(); @@ -3355,7 +3359,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) } tables[0].table->file->index_end(); } -err: + VOID(pthread_mutex_unlock(&acl_cache->lock)); rw_unlock(&LOCK_grant); close_thread_tables(thd); diff --git a/sql/sql_client.cc b/sql/sql_client.cc new file mode 100644 index 00000000000..464596f0734 --- /dev/null +++ b/sql/sql_client.cc @@ -0,0 +1,45 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or + (at your option) any later version. + + 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 */ + +/* + This files defines some MySQL C API functions that are server specific +*/ + +#include <mysql_priv.h> + +/* + Function called by my_net_init() to set some check variables +*/ + +extern "C" { +void my_net_local_init(NET *net) +{ +#ifndef EMBEDDED_LIBRARY + net->max_packet= (uint) global_system_variables.net_buffer_length; + net->read_timeout= (uint) global_system_variables.net_read_timeout; + net->write_timeout=(uint) global_system_variables.net_write_timeout; + net->retry_count= (uint) global_system_variables.net_retry_count; + net->max_packet_size= max(global_system_variables.net_buffer_length, + global_system_variables.max_allowed_packet); +#endif +} +} + +extern "C" { +void mysql_once_init(void) +{ +} +} diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index f65ef4b968a..091de9d406f 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -308,6 +308,11 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, } thd->row_count++; } + + /* + Now all rows are inserted. Time to update logs and sends response to + user + */ if (lock_type == TL_WRITE_DELAYED) { if (!error) @@ -341,7 +346,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, } if (id && values_list.elements != 1) thd->insert_id(id); // For update log - else if (table->next_number_field) + else if (table->next_number_field && info.copied) id=table->next_number_field->val_int(); // Return auto_increment value /* @@ -383,9 +388,15 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, thd->next_insert_id=0; // Reset this if wrongly used if (duplic != DUP_ERROR) table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); + + /* Reset value of LAST_INSERT_ID if no rows where inserted */ + if (!info.copied && thd->insert_id_used) + { + thd->insert_id(0); + id=0; + } if (error) goto abort; - if (values_list.elements == 1 && (!(thd->options & OPTION_WARNINGS) || !thd->cuted_fields)) send_ok(thd,info.copied+info.deleted,id); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index cffdd19b08d..4f54b0fc3ba 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2317,7 +2317,6 @@ mysql_execute_command(THD *thd) break; } case SQLCOM_UPDATE: - TABLE_LIST *table; if (check_db_used(thd,tables)) goto error; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 61a64573eaa..248496d6b43 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4791,7 +4791,7 @@ free_tmp_table(THD *thd, TABLE *entry) (void) ha_delete_table(entry->db_type,entry->real_name); /* free blobs */ for (Field **ptr=entry->field ; *ptr ; ptr++) - delete *ptr; + (*ptr)->free(); my_free((gptr) entry->record[0],MYF(0)); free_io_cache(entry); @@ -8061,7 +8061,6 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select) bool JOIN::rollup_init() { uint i,j; - ORDER *group; Item **ref_array; tmp_table_param.quick_group= 0; // Can't create groups in tmp table @@ -8145,7 +8144,7 @@ bool JOIN::rollup_make_fields(List<Item> &all_fields, List<Item> &fields, ... */ - for (level=0 ; level < send_group_parts > 0 ; level++) + for (level=0 ; level < send_group_parts ; level++) { uint i; uint pos= send_group_parts - level -1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0b18b7ffdc5..2eb65eab288 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1502,7 +1502,9 @@ keys_or_index: opt_unique_or_fulltext: /* empty */ { $$= Key::MULTIPLE; } | UNIQUE_SYM { $$= Key::UNIQUE; } - | SPATIAL_SYM { $$= Key::SPATIAL; }; + | FULLTEXT_SYM { $$= Key::FULLTEXT;} + | SPATIAL_SYM { $$= Key::SPATIAL; } + ; key_alg: /* empty */ { $$= HA_KEY_ALG_UNDEF; } @@ -3903,7 +3905,7 @@ purge_option: } Item *tmp= new Item_func_unix_timestamp($2); Lex->sql_command = SQLCOM_PURGE_BEFORE; - Lex->purge_time= tmp->val_int(); + Lex->purge_time= (ulong) tmp->val_int(); } ; diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 4d9c735de21..f5da95571c4 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1723,13 +1723,13 @@ static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) , switch (count) { /* Fall through all cases!!! */ #ifdef UNICODE_32BIT - case 6: r[5] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x4000000; - case 5: r[4] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x200000; - case 4: r[3] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x10000; + case 6: r[5] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x4000000; + case 5: r[4] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x200000; + case 4: r[3] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x10000; #endif - case 3: r[2] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x800; - case 2: r[1] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0xc0; - case 1: r[0] = wc; + case 3: r[2] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x800; + case 2: r[1] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0xc0; + case 1: r[0] = (uchar) wc; } return count; } diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 694e6fa8ebb..ed973b61e57 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -129,7 +129,7 @@ then extra_args="-e $datadir/my.cnf" fi -parse_arguments `$print_defaults $extra_args mysqld mysql_server mysql.server` +parse_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` # Safeguard (relative paths, core dumps..) cd $basedir diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index 20fe2178005..70382c29735 100644 --- a/tools/mysqlmanager.c +++ b/tools/mysqlmanager.c @@ -283,7 +283,7 @@ struct manager_cmd commands[] = static struct my_option my_long_options[] = { #ifndef DBUG_OFF - {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'", + {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"help", '?', "Display this help and exit.", @@ -299,20 +299,20 @@ static struct my_option my_long_options[] = {"tcp-backlog", 'B', "Size of TCP/IP listen queue.", (gptr*) &manager_back_log, (gptr*) &manager_back_log, 0, GET_INT, REQUIRED_ARG, MANAGER_BACK_LOG, 0, 0, 0, 0, 0}, - {"greeting", 'g', "Set greeting on connect", (gptr*) &manager_greeting, + {"greeting", 'g', "Set greeting on connect.", (gptr*) &manager_greeting, (gptr*) &manager_greeting, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"max-command-len", 'm', "Maximum command length", + {"max-command-len", 'm', "Maximum command length.", (gptr*) &manager_max_cmd_len, (gptr*) &manager_max_cmd_len, 0, GET_UINT, REQUIRED_ARG, MANAGER_MAX_CMD_LEN, 0, 0, 0, 0, 0}, - {"one-thread", 'd', "Use one thread ( for debugging)", (gptr*) &one_thread, + {"one-thread", 'd', "Use one thread ( for debugging).", (gptr*) &one_thread, (gptr*) &one_thread, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"connect-retries", 'C', "Number of attempts to establish MySQL connection", + {"connect-retries", 'C', "Number of attempts to establish MySQL connection.", (gptr*) &manager_connect_retries, (gptr*) &manager_connect_retries, 0, GET_INT, REQUIRED_ARG, MANAGER_CONNECT_RETRIES, 0, 0, 0, 0, 0}, - {"password-file", 'p', "Password file for manager", + {"password-file", 'p', "Password file for manager.", (gptr*) &manager_pw_file, (gptr*) &manager_pw_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"pid-file", 'f', "Pid file to use", (gptr*) &pid_file, (gptr*) &pid_file, + {"pid-file", 'f', "Pid file to use.", (gptr*) &pid_file, (gptr*) &pid_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, |