diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-10-04 15:46:04 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-10-04 15:46:04 -0600 |
commit | 89055361b9203be1d4e813b00aa5dfbc6e9b0caa (patch) | |
tree | f15f127921d230171bb0ac60a5a854a61af3b185 /client | |
parent | 5ee900d38a1d20247823ab23a441cbb78ac9942a (diff) | |
parent | 6bede5bed1add70fb5bb442ba70fe029c4c534f7 (diff) | |
download | mariadb-git-89055361b9203be1d4e813b00aa5dfbc6e9b0caa.tar.gz |
Merge
client/mysqltest.c:
Auto merged
include/mysql.h:
Auto merged
include/mysql_com.h:
Auto merged
libmysql/libmysql.c:
Auto merged
libmysqld/libmysqld.c:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
sql/item_func.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
acinclude.m4:
SCCS merged
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqlbinlog.cc | 9 | ||||
-rw-r--r-- | client/mysqldump.c | 95 | ||||
-rw-r--r-- | client/mysqltest.c | 27 |
3 files changed, 86 insertions, 45 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 58a22b74282..8cb1b82753e 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -23,15 +23,6 @@ #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES) -#ifndef OS2 -extern "C" -{ - int simple_command(MYSQL *mysql,enum enum_server_command command, - const char *arg, uint length, my_bool skipp_check); - uint net_safe_read(MYSQL* mysql); -} -#endif - char server_version[SERVER_VERSION_LENGTH]; uint32 server_id = 0; diff --git a/client/mysqldump.c b/client/mysqldump.c index 3c9e36e8a70..284ef3a0adf 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -18,26 +18,22 @@ ** ** The author's original notes follow :- ** -** ****************************************************** -** * * -** * AUTHOR: Igor Romanenko (igor@frog.kiev.ua) * -** * DATE: December 3, 1994 * -** * WARRANTY: None, expressed, impressed, implied * -** * or other * -** * STATUS: Public domain * -** * Adapted and optimized for MySQL by * -** * Michael Widenius, Sinisa Milivojevic, Jani Tolonen * -** * -w --where added 9/10/98 by Jim Faucette * -** * slave code by David Saez Padros <david@ols.es> * -** * * -** ****************************************************** -*/ -/* SSL by -** Andrei Errapart <andreie@no.spam.ee> -** Tõnu Samuel <tonu@please.do.not.remove.this.spam.ee> +** AUTHOR: Igor Romanenko (igor@frog.kiev.ua) +** DATE: December 3, 1994 +** WARRANTY: None, expressed, impressed, implied +** or other +** STATUS: Public domain +** Adapted and optimized for MySQL by +** Michael Widenius, Sinisa Milivojevic, Jani Tolonen +** -w --where added 9/10/98 by Jim Faucette +** slave code by David Saez Padros <david@ols.es> +** master/autocommit code by Brian Aker <brian@tangent.org> +** SSL by +** Andrei Errapart <andreie@no.spam.ee> +** Tõnu Samuel <tonu@please.do.not.remove.this.spam.ee> **/ -#define DUMP_VERSION "8.16" +#define DUMP_VERSION "8.17" #include <my_global.h> #include <my_sys.h> @@ -73,7 +69,7 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0, lock_tables=0,ignore_errors=0,flush_logs=0,replace=0, ignore=0,opt_drop=0,opt_keywords=0,opt_lock=0,opt_compress=0, opt_delayed=0,create_options=0,opt_quoted=0,opt_databases=0, - opt_alldbs=0,opt_create_db=0,opt_first_slave=0; + opt_alldbs=0,opt_create_db=0,opt_first_slave=0, opt_autocommit=0, opt_master_data; static MYSQL mysql_connection,*sock=0; static char insert_pat[12 * 1024],*opt_password=0,*current_user=0, *current_host=0,*path=0,*fields_terminated=0, @@ -89,7 +85,8 @@ FILE *md_result_file; enum md_options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_KEYWORDS, OPT_LOCKS, OPT_DROP, OPT_OPTIMIZE, OPT_DELAYED, - OPT_TABLES, MD_OPT_CHARSETS_DIR, MD_OPT_DEFAULT_CHARSET}; + OPT_TABLES, MD_OPT_CHARSETS_DIR, MD_OPT_DEFAULT_CHARSET, + OPT_AUTOCOMMIT, OPT_MASTER_DATA}; static struct option long_options[] = { @@ -117,6 +114,8 @@ static struct option long_options[] = {"host", required_argument, 0, 'h'}, {"lines-terminated-by", required_argument, 0, (int) OPT_LTB}, {"lock-tables", no_argument, 0, 'l'}, + {"master-data", no_argument, 0, OPT_MASTER_DATA}, + {"no-autocommit", no_argument, 0, OPT_AUTOCOMMIT}, {"no-create-db", no_argument, 0, 'n'}, {"no-create-info", no_argument, 0, 't'}, {"no-data", no_argument, 0, 'd'}, @@ -205,11 +204,15 @@ static void usage(void) --add-locks Add locks around insert statements.\n\ --allow-keywords Allow creation of column names that are keywords.\n\ --delayed-insert Insert rows with INSERT DELAYED.\n\ + --master-data This will cause the master position and filename to \n\ + be appended to your output. This will automagically \n\ + enable --first-slave.\n\ -F, --flush-logs Flush logs file in server before starting dump.\n\ -f, --force Continue even if we get an sql-error.\n\ -h, --host=... Connect to host.\n"); puts("\ -l, --lock-tables Lock all tables for read.\n\ + --no-autocommit Wrap tables with autocommit/commit statements.\n\ -n, --no-create-db 'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;'\n\ will not be put in the output. The above line will\n\ be added otherwise, if --databases or\n\ @@ -249,6 +252,7 @@ puts("\ -v, --verbose Print info about the various stages.\n\ -V, --version Output version information and exit.\n\ -w, --where= dump only selected records; QUOTES mandatory!\n\ + -x, --first-slave Locks all tables across all databases.\n\ EXAMPLES: \"--where=user=\'jimf\'\" \"-wuserid>1\" \"-wuserid<1\"\n\ Use -T (--tab=...) with --fields-...\n\ --fields-terminated-by=...\n\ @@ -274,7 +278,7 @@ puts("\ static void write_heder(FILE *sql_file, char *db_name) { - fprintf(sql_file, "-- MySQL dump %s\n#\n", DUMP_VERSION); + fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION); fprintf(sql_file, "-- Host: %s Database: %s\n", current_host ? current_host : "localhost", db_name ? db_name : ""); fputs("---------------------------------------------------------\n", @@ -298,6 +302,13 @@ static int get_options(int *argc,char ***argv) long_options, &option_index)) != EOF) { switch(c) { + case OPT_MASTER_DATA: + opt_master_data=1; + opt_first_slave=1; + break; + case OPT_AUTOCOMMIT: + opt_autocommit=1; + break; case 'a': create_options=1; break; @@ -643,7 +654,7 @@ static uint getTableStructure(char *table, char* db) } write_heder(sql_file, db); } - fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table); + fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n",table); if (opt_drop) fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name); @@ -716,7 +727,7 @@ static uint getTableStructure(char *table, char* db) } write_heder(sql_file, db); } - fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table); + fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n",table); if (opt_drop) fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name); fprintf(sql_file, "CREATE TABLE %s (\n", table_name); @@ -973,7 +984,7 @@ static void dumpTable(uint numFields, char *table) } else { - fprintf(md_result_file,"\n#\n# Dumping data for table '%s'\n", table); + fprintf(md_result_file,"\n--\n-- Dumping data for table '%s'\n--\n", table); sprintf(query, "SELECT * FROM %s", quote_name(table,table_buff)); if (where) { @@ -1014,6 +1025,9 @@ static void dumpTable(uint numFields, char *table) rownr=0; init_length=(uint) strlen(insert_pat)+4; + if (opt_autocommit) + fprintf(md_result_file, "set autocommit=0;\n"); + while ((row=mysql_fetch_row(res))) { uint i; @@ -1140,6 +1154,8 @@ static void dumpTable(uint numFields, char *table) if (opt_lock) fputs("UNLOCK TABLES;\n", md_result_file); mysql_free_result(res); + if (opt_autocommit) + fprintf(md_result_file, "commit;\n"); } } /* dumpTable */ @@ -1214,7 +1230,7 @@ static int init_dumping(char *database) { if (opt_databases || opt_alldbs) { - fprintf(md_result_file,"\n#\n# Current Database: %s\n#\n", database); + fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", database); if (!opt_create_db) fprintf(md_result_file,"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n", database); @@ -1242,7 +1258,7 @@ static int dump_all_tables_in_db(char *database) init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); for (numrows=0 ; (table = getTableName(1)) ; numrows++) { - dynstr_append(&query, quote_name(table,table_buff)); + dynstr_append(&query, quote_name(table, table_buff)); dynstr_append(&query, " READ /*!32311 LOCAL */,"); } if (numrows && mysql_real_query(sock, query.str, query.length-1)) @@ -1284,7 +1300,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); for (i=0 ; i < tables ; i++) { - dynstr_append(&query, quote_name(table_names[i],table_buff)); + dynstr_append(&query, quote_name(table_names[i], table_buff)); dynstr_append(&query, " READ /*!32311 LOCAL */,"); } if (mysql_real_query(sock, query.str, query.length-1)) @@ -1340,6 +1356,9 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row, int main(int argc, char **argv) { + MYSQL_ROW row; + MYSQL_RES *master; + MY_INIT(argv[0]); /* ** Check out the args @@ -1376,6 +1395,28 @@ int main(int argc, char **argv) if (opt_first_slave) { + if (opt_master_data) + { + if (mysql_query(sock, "SHOW MASTER STATUS") || + !(master = mysql_store_result(sock))) + { + my_printf_error(0, "Error: Couldn't execute 'SHOW MASTER STATUS': %s", + MYF(0), mysql_error(sock)); + } + else + { + row = mysql_fetch_row(master); + if(row[0] && row[1]) { + fprintf(md_result_file, + "\n--\n-- Position to start replication from\n--\n\n"); + fprintf(md_result_file, + "CHANGE MASTER TO MASTER_LOG_FILE='%s' ;\n", row[0]); + fprintf(md_result_file, "CHANGE MASTER TO MASTER_LOG_POS=%s ;\n", + row[1]); + } + mysql_free_result(master); + } + } if (mysql_query(sock, "FLUSH MASTER")) { my_printf_error(0, "Error: Couldn't execute 'FLUSH MASTER': %s", diff --git a/client/mysqltest.c b/client/mysqltest.c index b0a21a1cd5b..b95b9a44907 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -43,7 +43,7 @@ **********************************************************************/ -#define MTEST_VERSION "1.10" +#define MTEST_VERSION "1.11" #include <my_global.h> #include <mysql_embed.h> @@ -90,7 +90,7 @@ enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD, static int record = 0, verbose = 0, silent = 0, opt_sleep=0; static char *db = 0, *pass=0; const char* user = 0, *host = 0, *unix_sock = 0; -static int port = 0, opt_big_test=0; +static int port = 0, opt_big_test=0, opt_compress=0; static uint start_lineno, *lineno; const char* manager_user="root",*manager_host="localhost"; char *manager_pass=0; @@ -264,11 +264,11 @@ static uint out_length; static int eval_result = 0; /* Disable functions that only exist in MySQL 4.0 */ -#if MYSQL_VERSION_ID < 40000 -static void mysql_enable_rpl_parse(MYSQL* mysql __attribute__((unused))) {} -static void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {} -static int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; } -static int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; } +#if MYSQL_VERSION_ID < 40000 || defined(EMBEDDED_LIBRARY) +void mysql_enable_rpl_parse(MYSQL* mysql __attribute__((unused))) {} +void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {} +int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; } +int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; } #endif static void do_eval(DYNAMIC_STRING* query_eval, const char* query) @@ -1255,6 +1255,8 @@ int do_connect(struct st_query* q) if (!mysql_init(&next_con->mysql)) die("Failed on mysql_init()"); + if (opt_compress) + mysql_options(&next_con->mysql,MYSQL_OPT_COMPRESS,NullS); if (con_sock) con_sock=fn_format(buff, con_sock, TMPDIR, "",0); if (!con_db[0]) @@ -1594,6 +1596,7 @@ struct option long_options[] = {"debug", optional_argument, 0, '#'}, {"database", required_argument, 0, 'D'}, {"big-test", no_argument, 0, 'B'}, + {"compress", no_argument, 0, 'C'}, {"help", no_argument, 0, '?'}, {"host", required_argument, 0, 'h'}, {"manager-user",required_argument, 0, OPT_MANAGER_USER}, @@ -1643,6 +1646,7 @@ void usage() -p[password], --password[=...]\n\ Password to use when connecting to server.\n\ -B, --big-test Define BIG_TEST to 1\n\ + -C, --compress Use the compressed server/client protocol\n\ -D, --database=... Database to use.\n\ -P, --port=... Port number to use for connection.\n\ -S, --socket=... Socket file to use for connection.\n\ @@ -1665,8 +1669,8 @@ int parse_args(int argc, char **argv) load_defaults("my",load_default_groups,&argc,&argv); default_argv= argv; - while((c = getopt_long(argc, argv, "h:p::u:BP:D:S:R:x:t:T:#:?rvVq", - long_options, &option_index)) != EOF) + while ((c = getopt_long(argc, argv, "h:p::u:BCP:D:S:R:x:t:T:#:?rvVq", + long_options, &option_index)) != EOF) { switch(c) { case '#': @@ -1718,6 +1722,9 @@ int parse_args(int argc, char **argv) case 'B': opt_big_test=1; break; + case 'C': + opt_compress=1; + break; case 'P': port = atoi(optarg); break; @@ -2112,6 +2119,8 @@ int main(int argc, char** argv) #endif if (!( mysql_init(&cur_con->mysql))) die("Failed in mysql_init()"); + if (opt_compress) + mysql_options(&cur_con->mysql,MYSQL_OPT_COMPRESS,NullS); cur_con->name = my_strdup("default", MYF(MY_WME)); if (!cur_con->name) die("Out of memory"); |