From e8a3a141c50aaa0f697aaa89c349764bbbbfbd13 Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Sat, 22 Dec 2001 21:08:25 +0200 Subject: [PATCH 01/14] data0type.ic, rem0cmp.c: Allow foreign keys refer between fixed and var length strings --- innobase/include/data0type.ic | 11 +++++++---- innobase/rem/rem0cmp.c | 10 +++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/innobase/include/data0type.ic b/innobase/include/data0type.ic index 4a62902eb1b..d82d976d076 100644 --- a/innobase/include/data0type.ic +++ b/innobase/include/data0type.ic @@ -107,14 +107,17 @@ dtype_get_pad_char( ULINT_UNDEFINED if no padding specified */ dtype_t* type) /* in: type */ { - if (type->mtype == DATA_CHAR) { - /* space is the padding character for all char strings */ + if (type->mtype == DATA_CHAR + || type->mtype == DATA_VARCHAR + || type->mtype == DATA_BINARY + || type->mtype == DATA_FIXBINARY) { + + /* Space is the padding character for all char and binary + strings */ return((ulint)' '); } - ut_ad((type->mtype == DATA_BINARY) || (type->mtype == DATA_VARCHAR)); - /* No padding specified */ return(ULINT_UNDEFINED); diff --git a/innobase/rem/rem0cmp.c b/innobase/rem/rem0cmp.c index f3d9d579aa0..363bb013ac9 100644 --- a/innobase/rem/rem0cmp.c +++ b/innobase/rem/rem0cmp.c @@ -100,7 +100,15 @@ cmp_types_are_equal( dtype_t* type1, /* in: type 1 */ dtype_t* type2) /* in: type 2 */ { - if (type1->mtype != type2->mtype) { + if ((type1->mtype == DATA_VARCHAR && type2->mtype == DATA_CHAR) + || (type1->mtype == DATA_CHAR && type2->mtype == DATA_VARCHAR) + || (type1->mtype == DATA_FIXBINARY && type2->mtype == DATA_BINARY) + || (type1->mtype == DATA_BINARY && type2->mtype == DATA_FIXBINARY)) { + + return(TRUE); + } + + if (type1->mtype != type2->mtype) { return(FALSE); } From 954920c874a82fdba6c6a7ad28041635c622b21b Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Sun, 23 Dec 2001 13:06:48 +0200 Subject: [PATCH 02/14] ha_innobase.cc: Increase table comment print size to 500 bytes to be able to print more foreign key constraint infos ha_innobase.h: Change max key len back to 500 bytes because MySQL interpreter cannot handle more --- sql/ha_innobase.cc | 4 ++-- sql/ha_innobase.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index dc030dde39a..62c721de13f 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -3220,7 +3220,7 @@ ha_innobase::update_table_comment( { row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt; uint length = strlen(comment); - char* str = my_malloc(length + 200, MYF(0)); + char* str = my_malloc(length + 550, MYF(0)); char* pos; if (!str) { @@ -3239,7 +3239,7 @@ ha_innobase::update_table_comment( /* We assume 150 bytes of space to print info */ - dict_print_info_on_foreign_keys(pos, 150, prebuilt->table); + dict_print_info_on_foreign_keys(pos, 500, prebuilt->table); return(str); } diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h index 84698a9114b..3f4bd5144eb 100644 --- a/sql/ha_innobase.h +++ b/sql/ha_innobase.h @@ -100,8 +100,11 @@ class ha_innobase: public handler a secondary key record must also contain the primary key value: max key length is therefore set to slightly - less than 1 / 4 of page size which is 16 kB */ - uint max_key_length() const { return 3500; } + less than 1 / 4 of page size which is 16 kB; + but currently MySQL does not work with keys + whose size is > MAX_KEY_LENGTH */ + uint max_key_length() const { return((MAX_KEY_LENGTH <= 3500) ? + MAX_KEY_LENGTH : 3500);} bool fast_key_read() { return 1;} key_map keys_to_use_for_scanning() { return ~(key_map) 0; } bool has_transactions() { return 1;} From 7f44419d423a16aca7628ade8dcad2e99771e03f Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Mon, 24 Dec 2001 22:27:11 +0200 Subject: [PATCH 03/14] log0recv.c: Print progress info of the applying log records to the database phase in recovery srv0srv.c: Do buffer pool flush and checkpoints more often to make recovery faster --- innobase/log/log0recv.c | 18 +++++++++++++++++- innobase/srv/srv0srv.c | 14 +++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/innobase/log/log0recv.c b/innobase/log/log0recv.c index f83a49d01a6..5cd5850d1a1 100644 --- a/innobase/log/log0recv.c +++ b/innobase/log/log0recv.c @@ -1019,7 +1019,8 @@ loop: if (recv_addr->state == RECV_NOT_PROCESSED) { if (!has_printed) { fprintf(stderr, -"InnoDB: Starting an apply batch of log records to the database...\n"); +"InnoDB: Starting an apply batch of log records to the database...\n" +"InnoDB: Progress in percents:"); has_printed = TRUE; } @@ -1046,6 +1047,16 @@ loop: recv_addr = HASH_GET_NEXT(addr_hash, recv_addr); } + + if (has_printed + && (i * 100) / hash_get_n_cells(recv_sys->addr_hash) + != ((i + 1) * 100) + / hash_get_n_cells(recv_sys->addr_hash)) { + + fprintf(stderr, "%lu ", + (i * 100) / hash_get_n_cells(recv_sys->addr_hash)); + + } } /* Wait until all the pages have been processed */ @@ -1059,6 +1070,11 @@ loop: mutex_enter(&(recv_sys->mutex)); } + if (has_printed) { + + fprintf(stderr, "\n"); + } + if (!allow_ibuf) { /* Flush all the file pages to disk and invalidate them in the buffer pool */ diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 37bf59b6b9a..d77db335366 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -2417,7 +2417,19 @@ loop: background_loop: /* In this loop we run background operations when the server - is quiet */ + is quiet and we also come here about once in 10 seconds */ + + srv_main_thread_op_info = "flushing buffer pool pages"; + + /* Flush a few oldest pages to make the checkpoint younger */ + + n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10, ut_dulint_max); + + srv_main_thread_op_info = "making checkpoint"; + + /* Make a new checkpoint about once in 10 seconds */ + + log_checkpoint(TRUE, FALSE); srv_main_thread_op_info = "reserving kernel mutex"; From 3fef3c7e5bdc5012fb0f611abf3932f3879bea56 Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Tue, 25 Dec 2001 23:44:41 +0200 Subject: [PATCH 04/14] mysqld.cc: Changed default of file_io_threads to 4 and lock_wait_timeout to 50 seconds Added a missing break: if not specified, innodb_fast_shutdown got the same value as ..flush_log_at_trx commit --- sql/mysqld.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c34f18da1ec..ac1bb3f04be 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2830,9 +2830,9 @@ CHANGEABLE_VAR changeable_vars[] = { (long*) &innobase_additional_mem_pool_size, 1*1024*1024L, 512*1024L, ~0L, 0, 1024}, {"innodb_file_io_threads", - (long*) &innobase_file_io_threads, 9, 4, 64, 0, 1}, + (long*) &innobase_file_io_threads, 4, 4, 64, 0, 1}, {"innodb_lock_wait_timeout", - (long*) &innobase_lock_wait_timeout, 1024 * 1024 * 1024, 1, + (long*) &innobase_lock_wait_timeout, 50, 1, 1024 * 1024 * 1024, 0, 1}, {"innodb_thread_concurrency", (long*) &innobase_thread_concurrency, 8, 1, 1000, 0, 1}, @@ -3935,6 +3935,7 @@ static void get_options(int argc,char **argv) break; case OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT: innobase_flush_log_at_trx_commit= optarg ? test(atoi(optarg)) : 1; + break; case OPT_INNODB_FAST_SHUTDOWN: innobase_fast_shutdown= optarg ? test(atoi(optarg)) : 1; break; From 116ced2f2967a06c520726cfac069afeb2dba14a Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Thu, 27 Dec 2001 00:56:40 +0200 Subject: [PATCH 05/14] os0file.c: Make os_file_flush to ignore the error we get from a raw device in fsync --- innobase/os/os0file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 9fecf2c04fd..363ed587c4e 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -582,6 +582,13 @@ os_file_flush( return(TRUE); } + /* Since Linux returns EINVAL if the 'file' is actually a raw device, + we choose to ignore that error */ + + if (errno == EINVAL) { + return(TRUE); + } + fprintf(stderr, "InnoDB: Error: the OS said file flush did not succeed\n"); From 2bd8bf31bdc4a0822780bc5a982044dcac4838b3 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Thu, 27 Dec 2001 02:04:27 +0200 Subject: [PATCH 06/14] Bugfix for WHERE key=@a OR key=@b --- Docs/manual.texi | 5 +++++ mysql-test/r/variables.result | 11 ++++++++++ mysql-test/t/variables.test | 13 ++++++++++++ sql/item_func.cc | 38 +++++++++++++++++++++++++++++++++++ sql/item_func.h | 4 ++++ sql/sql_select.cc | 2 +- 6 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index f3f3cdec961..101aa22a883 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46888,6 +46888,11 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.47 @itemize @bullet @item +Fixed in when using the following construct: +@code{SELECT ... WHERE key=@@var_name OR $key=@@var_name2} +@item +Restrict InnoDB keys to 500 bytes. +@item InnoDB now supports @code{NULL} in keys. @item Fixed shutdown problem on HPUX. (Introduced in 3.23.46) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index f852378e6a1..ab60d5042b0 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -12,3 +12,14 @@ NULL NULL NULL NULL 5 5 1 4 @t5 1.23456 +@min_cid:=min(c_id) @max_cid:=max(c_id) +1 4 +c_id c_name c_country +1 Bozo USA +4 Mr. Floppy GB +c_id c_name c_country +1 Bozo USA +4 Mr. Floppy GB +c_id c_name c_country +1 Bozo USA +4 Mr. Floppy GB diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index d5ff64d199b..0499263467c 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1,6 +1,7 @@ # # test variables # +drop table if exists t1; set @`test`=1,@TEST=3,@select=2,@t5=1.23456; select @test,@`select`,@TEST,@not_used; set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL; @@ -14,3 +15,15 @@ select @test_int,@test_double,@test_string,@test_string2; select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3; select @t5; +# +# Test problem with WHERE and variables +# + +CREATE TABLE t1 (c_id INT(4) NOT NULL, c_name CHAR(20), c_country CHAR(3), PRIMARY KEY(c_id)); +INSERT INTO t1 VALUES (1,'Bozo','USA'),(2,'Ronald','USA'),(3,'Kinko','IRE'),(4,'Mr. Floppy','GB'); +SELECT @min_cid:=min(c_id), @max_cid:=max(c_id) from t1; +SELECT * FROM t1 WHERE c_id=@min_cid OR c_id=@max_cid; +SELECT * FROM t1 WHERE c_id=@min_cid OR c_id=@max_cid OR c_id=666; +ALTER TABLE t1 DROP PRIMARY KEY; +select * from t1 where c_id=@min_cid OR c_id=@max_cid; +drop table t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index 94464bdc594..e7e8964b07a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1772,6 +1772,16 @@ Item_func_set_user_var::val_str(String *str) } +void Item_func_set_user_var::print(String *str) +{ + str->append('('); + str->append(name.str,name.length); + str->append(":=",2); + args[0]->print(str); + str->append(')'); +} + + user_var_entry *Item_func_get_user_var::get_entry() { if (!entry || ! entry->value) @@ -1864,6 +1874,34 @@ enum Item_result Item_func_get_user_var::result_type() const return entry->type; } + +void Item_func_get_user_var::print(String *str) +{ + str->append('@'); + str->append(name.str,name.length); + str->append(')'); +} + +bool Item_func_get_user_var::eq(const Item *item) const +{ + /* Assume we don't have rtti */ + if (this == item) + return 1; // Same item is same. + /* Check if other type is also a get_user_var() object */ +#ifdef FIX_THIS + if (item->eq == &Item_func_get_user_var::eq) + return 0; +#else + if (item->type() != FUNC_ITEM || + ((Item_func*) item)->func_name() != func_name()) + return 0; +#endif + Item_func_get_user_var *other=(Item_func_get_user_var*) item; + return (name.length == other->name.length && + !memcmp(name.str, other->name.str, name.length)); +} + + longlong Item_func_inet_aton::val_int() { uint byte_result = 0; diff --git a/sql/item_func.h b/sql/item_func.h index ac4c230f312..4a8f808de57 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -817,6 +817,7 @@ public: enum Item_result result_type () const { return cached_result_type; } bool fix_fields(THD *thd,struct st_table_list *tables); void fix_length_and_dec(); + void print(String *str); const char *func_name() const { return "set_user_var"; } }; @@ -835,13 +836,16 @@ public: longlong val_int(); String *val_str(String* str); void fix_length_and_dec(); + void print(String *str); enum Item_result result_type() const; const char *func_name() const { return "get_user_var"; } bool const_item() const { return const_var_flag; } table_map used_tables() const { return const_var_flag ? 0 : RAND_TABLE_BIT; } + bool eq(const Item *item) const; }; + class Item_func_inet_aton : public Item_int_func { public: diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 330df610b46..9ff64780bdd 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -35,7 +35,7 @@ const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", "MAYBE_REF","ALL","range","index","fulltext" }; static bool make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, - DYNAMIC_ARRAY *keyuse); + DYNAMIC_ARRAY *keyuse); static bool update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse, JOIN_TAB *join_tab, uint tables,COND *conds,table_map table_map); From ac8155cce1e015494773bf9e4da469233dddb7f2 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Thu, 27 Dec 2001 13:31:10 +0200 Subject: [PATCH 07/14] Portability fixes --- include/global.h | 5 +++++ sql/mysqld.cc | 1 + 2 files changed, 6 insertions(+) diff --git a/include/global.h b/include/global.h index c7d6952f1c6..857c66d3640 100644 --- a/include/global.h +++ b/include/global.h @@ -211,6 +211,11 @@ #ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */ #undef HAVE_FINITE #endif +#if defined(HPUX) && defined(_LARGEFILE64_SOURCE) && defined(THREAD) +/* Fix bug in setrlimit */ +#undef setrlimit +#define setrlimit cma_setrlimit64 +#endif /* We can not live without these */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ac1bb3f04be..be20c5fa964 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -377,6 +377,7 @@ static void get_options(int argc,char **argv); static char *get_relative_path(const char *path); static void fix_paths(void); static pthread_handler_decl(handle_connections_sockets,arg); +static pthread_handler_decl(kill_server_thread,arg); static int bootstrap(FILE *file); static bool read_init_file(char *file_name); #ifdef __NT__ From 43f2238c725ddc37100a24f4ae911656c7628929 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Thu, 27 Dec 2001 15:16:08 +0200 Subject: [PATCH 08/14] Portability fix for SCO --- extra/resolveip.c | 49 ++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/extra/resolveip.c b/extra/resolveip.c index 4856bead200..2d21d5c672c 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -1,30 +1,28 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ + 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 */ /* Resolves IP's to hostname and hostnames to IP's */ #define RESOLVE_VERSION "2.0" - -#include + +#include #include +#include #include -#ifndef SCO #include -#endif #include #include #ifndef HAVE_BROKEN_NETINET_INCLUDES @@ -34,10 +32,16 @@ #include #include +#ifdef SCO +#undef h_errno +#define h_errno errno +#endif + #if !defined(_AIX) && !defined(HAVE_UNIXWARE7_THREADS) && !defined(HAVE_UNIXWARE7_POSIX) && !defined(h_errno) extern int h_errno; #endif + static int silent=0; static struct option long_options[] = @@ -54,7 +58,7 @@ static void print_version(void) { printf("%s Ver %s, for %s (%s)\n",my_progname,RESOLVE_VERSION, SYSTEM_TYPE,MACHINE_TYPE); -} +} static void usage(void) @@ -140,7 +144,7 @@ int main(int argc, char **argv) puts("Old-Bcast"); continue; } - + hpaddr = gethostbyaddr((char*) &(taddr), sizeof(struct in_addr),AF_INET); if (hpaddr) { @@ -202,6 +206,3 @@ int main(int argc, char **argv) } exit(error); } - - - From 8c8d5c06aacdbb67fea59e329fc1cd5a7e5c05fb Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Thu, 27 Dec 2001 18:43:49 +0200 Subject: [PATCH 09/14] btr0sea.c: Eliminate a gcc compiler bug in inlining --- innobase/btr/btr0sea.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c index 31ef8ce573b..ca8589813ca 100644 --- a/innobase/btr/btr0sea.c +++ b/innobase/btr/btr0sea.c @@ -452,7 +452,7 @@ btr_search_info_update_slow( Checks if a guessed position for a tree cursor is right. Note that if mode is PAGE_CUR_LE, which is used in inserts, and the function returns TRUE, then cursor->up_match and cursor->low_match both have sensible values. */ -UNIV_INLINE +static ibool btr_search_check_guess( /*===================*/ From e4a3e38101aebf5bc64a25877196b7e4abb9b7aa Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Thu, 27 Dec 2001 20:17:49 +0200 Subject: [PATCH 10/14] manual.texi: Make InnoDB startup option samples easier to understand, recommend not setting log files too big, because recovery slow --- Docs/manual.texi | 80 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 21 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index f3f3cdec961..16dc3e9a87f 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -36313,23 +36313,37 @@ the configuration file @file{my.cnf}. @xref{Option files}. The only required parameter to use InnoDB is @code{innodb_data_file_path}, but you should set others if you want to get a better performance. -Suppose you have a Windows NT machine with 128 MB RAM and a single 10 GB +Suppose you have a Windows NT computer with 128 MB RAM and a single 10 GB hard disk. Below is an example of possible configuration parameters in @file{my.cnf} for InnoDB: @example -innodb_data_file_path = ibdata1:2000M;ibdata2:2000M +[mysqld] +# You can write your other MySQL server options here +# ... +# innodb_data_home_dir = c:\ibdata -set-variable = innodb_mirrored_log_groups=1 +# Data files must be able to +# hold your data and indexes +innodb_data_file_path = ibdata1:2000M;ibdata2:2000M +# Set buffer pool size to 50 - 80 % +# of your computer's memory +set-variable = innodb_buffer_pool_size=70M +set-variable = innodb_additional_mem_pool_size=10M innodb_log_group_home_dir = c:\iblogs -set-variable = innodb_log_files_in_group=3 -set-variable = innodb_log_file_size=30M -set-variable = innodb_log_buffer_size=8M -innodb_flush_log_at_trx_commit=1 +# .._log_arch_dir must be the same +# as .._log_group_home_dir innodb_log_arch_dir = c:\iblogs innodb_log_archive=0 -set-variable = innodb_buffer_pool_size=80M -set-variable = innodb_additional_mem_pool_size=10M +set-variable = innodb_log_files_in_group=3 +# Set the log file size to about +# 15 % of the buffer pool size +set-variable = innodb_log_file_size=10M +set-variable = innodb_log_buffer_size=8M +# Set ..flush_log_at_trx_commit to +# 0 if you can afford losing +# a few last transactions +innodb_flush_log_at_trx_commit=1 set-variable = innodb_file_io_threads=4 set-variable = innodb_lock_wait_timeout=50 @end example @@ -36340,27 +36354,44 @@ to be >= 10 MB. InnoDB does not create directories: you have to create them yourself. -Suppose you have a Linux machine with 512 MB RAM and +Suppose you have a Linux computer with 512 MB RAM and three 20 GB hard disks (at directory paths @file{/}, @file{/dr2} and @file{/dr3}). Below is an example of possible configuration parameters in @file{my.cnf} for InnoDB: @example -innodb_data_file_path = ibdata/ibdata1:2000M;dr2/ibdata/ibdata2:2000M +[mysqld] +# You can write your other MySQL server options here +# ... +# innodb_data_home_dir = / -set-variable = innodb_mirrored_log_groups=1 -innodb_log_group_home_dir = /dr3 -set-variable = innodb_log_files_in_group=3 -set-variable = innodb_log_file_size=50M -set-variable = innodb_log_buffer_size=8M -innodb_flush_log_at_trx_commit=1 +# Data files must be able to +# hold your data and indexes +innodb_data_file_path = ibdata/ibdata1:2000M;dr2/ibdata/ibdata2:2000M +# Set buffer pool size to 50 - 80 % +# of your computer's memory +set-variable = innodb_buffer_pool_size=350M +set-variable = innodb_additional_mem_pool_size=20M +innodb_log_group_home_dir = /dr3/iblogs +# .._log_arch_dir must be the same +# as .._log_group_home_dir innodb_log_arch_dir = /dr3/iblogs innodb_log_archive=0 -set-variable = innodb_buffer_pool_size=400M -set-variable = innodb_additional_mem_pool_size=20M +set-variable = innodb_log_files_in_group=3 +# Set the log file size to about +# 15 % of the buffer pool size +set-variable = innodb_log_file_size=50M +set-variable = innodb_log_buffer_size=8M +# Set ..flush_log_at_trx_commit to +# 0 if you can afford losing +# a few last transactions +innodb_flush_log_at_trx_commit=1 set-variable = innodb_file_io_threads=4 set-variable = innodb_lock_wait_timeout=50 +#innodb_flush_method=fdatasync +#innodb_fast_shutdown=1 +#set-variable = innodb_thread_concurrency=5 @end example Note that we have placed the two data files on different disks. @@ -36374,6 +36405,10 @@ improve the performance of the database if all data is not placed on the same physical disk. Putting log files on a different disk from data is very often beneficial for performance. +The combined size of the log files MUST be < 4G in a 32-bit computer, +and to make recovery reasonably fast you should keep the combined size +smaller than the buffer pool size. + The meanings of the configuration parameters are the following: @multitable @columnfractions .30 .70 @@ -36397,7 +36432,9 @@ Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here. @item @code{innodb_log_file_size} @tab Size of each log file in a log group in megabytes. Sensible values range -from 1M to the size of the buffer pool specified below. The bigger the +from 1M to 1/nth of the size of the buffer pool specified below, where +n is the number of log files in the log group. +The bigger the value, the less checkpoint flush activity is needed in the buffer pool, saving disk i/o. But bigger log files also mean that recovery will be slower in case of a crash. File size restriction as for a data file. @@ -37100,7 +37137,8 @@ to zero. InnoDB tries to flush the log anyway once in a second, though the flush is not guaranteed. @strong{4.} -Make your log files big, even as big as the buffer pool. When InnoDB +Make your log files big, the combined size +even as big as the buffer pool. When InnoDB has written the log files full, it has to write the modified contents of the buffer pool to disk in a checkpoint. Small log files will cause many unnecessary disk writes. The drawback in big log files is that recovery From d4a8e8d61ebaff11b5ffb02571763e98d91f3e67 Mon Sep 17 00:00:00 2001 From: "miguel@light.local" <> Date: Sun, 30 Dec 2001 00:22:01 -0200 Subject: [PATCH 11/14] Minors changes for the Windows 3.23.47 release --- mysys/my_bitmap.c | 1 + sql/sql_do.cc | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index 6bab35eabb1..a18fcba0b60 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -27,6 +27,7 @@ #include #include #include +#include inline void bitmap_lock(MY_BITMAP* map) { diff --git a/sql/sql_do.cc b/sql/sql_do.cc index 8e197b47fd5..57a6f88ed63 100644 --- a/sql/sql_do.cc +++ b/sql/sql_do.cc @@ -22,7 +22,6 @@ int mysql_do(THD *thd, List &values) { - int error; List_iterator li(values); Item *value; DBUG_ENTER("mysql_do"); From 410847fac6c1413d744895055168358cbd963474 Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Mon, 31 Dec 2001 14:41:58 +0200 Subject: [PATCH 12/14] row0mysql.c: Remove erroneous warning of a duplicate key when the key in a UNIQUE secondary index contains a NULL --- innobase/row/row0mysql.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 58bddcfd24a..9622a7cee32 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1678,6 +1678,8 @@ row_scan_and_check_index( rec_t* rec; ibool is_ok = TRUE; int cmp; + ibool contains_null; + ulint i; char err_buf[1000]; *n_rows = 0; @@ -1723,6 +1725,21 @@ loop: cmp = cmp_dtuple_rec_with_match(prev_entry, rec, &matched_fields, &matched_bytes); + contains_null = FALSE; + + /* In a unique secondary index we allow equal key values if + they contain SQL NULLs */ + + for (i = 0; + i < dict_index_get_n_ordering_defined_by_user(index); + i++) { + if (UNIV_SQL_NULL == dfield_get_len( + dtuple_get_nth_field(prev_entry, i))) { + + contains_null = TRUE; + } + } + if (cmp > 0) { fprintf(stderr, "Error: index records in a wrong order in index %s\n", @@ -1736,6 +1753,7 @@ loop: is_ok = FALSE; } else if ((index->type & DICT_UNIQUE) + && !contains_null && matched_fields >= dict_index_get_n_ordering_defined_by_user(index)) { From cb8bb9a84c17ed91b9b26719a6984606d55a35c0 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Wed, 2 Jan 2002 13:50:31 +0200 Subject: [PATCH 13/14] Backport of mysqldump from 4.0 --- Docs/manual.texi | 4 +- client/client_priv.h | 3 +- client/mysqldump.c | 367 +++++++++++++++++++++++++++++-------------- include/global.h | 4 +- 4 files changed, 254 insertions(+), 124 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 101aa22a883..479eeb7dc69 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46897,11 +46897,9 @@ InnoDB now supports @code{NULL} in keys. @item Fixed shutdown problem on HPUX. (Introduced in 3.23.46) @item -Added 'DO expression' command. -@item Fixed core-dump bug in replication when using SELECT RELEASE_LOCK(); @item -Added new statement DO expression,[expression]. +Added new command: @code{DO expression,[expression]} @item Added @code{slave-skip-errors} option @item diff --git a/client/client_priv.h b/client/client_priv.h index 377d42763a2..261367f7176 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -29,4 +29,5 @@ enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, OPT_PAGER, OPT_NOPAGER, OPT_TEE, OPT_NOTEE, OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS, OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE, - OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES}; + OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES, + OPT_MASTER_DATA, OPT_AUTOCOMMIT}; diff --git a/client/mysqldump.c b/client/mysqldump.c index 12e08669864..ed5749c88a6 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +/* Copyright (C) 2000 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 @@ -18,28 +18,26 @@ ** ** 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 * -** * * -** ****************************************************** +** 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 +** master/autocommit code by Brian Aker +** SSL by +** Andrei Errapart +** Tõnu Samuel +** XML by Gary Huntress 10/10/01, cleaned up +** and adapted to mysqldump 05/11/01 by Jani Tolonen */ -/* SSL by -** Andrei Errapart -** Tõnu Samuel -**/ -#define DUMP_VERSION "8.16" +#define DUMP_VERSION "8.20" -#include +#include #include #include #include @@ -74,7 +72,8 @@ 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,opt_disable_keys=0,opt_xml=0; 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, @@ -91,52 +90,56 @@ FILE *md_result_file; static struct option long_options[] = { {"all-databases", no_argument, 0, 'A'}, - {"all", no_argument, 0, 'a'}, - {"add-drop-table", no_argument, 0, OPT_DROP}, - {"add-locks", no_argument, 0, OPT_LOCKS}, - {"allow-keywords", no_argument, 0, OPT_KEYWORDS}, + {"all", no_argument, 0, 'a'}, + {"add-drop-table", no_argument, 0, OPT_DROP}, + {"add-locks", no_argument, 0, OPT_LOCKS}, + {"allow-keywords", no_argument, 0, OPT_KEYWORDS}, {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR}, - {"complete-insert", no_argument, 0, 'c'}, - {"compress", no_argument, 0, 'C'}, + {"complete-insert", no_argument, 0, 'c'}, + {"compress", no_argument, 0, 'C'}, {"databases", no_argument, 0, 'B'}, - {"debug", optional_argument, 0, '#'}, + {"debug", optional_argument, 0, '#'}, {"default-character-set", required_argument, 0, OPT_DEFAULT_CHARSET}, - {"delayed-insert", no_argument, 0, OPT_DELAYED}, - {"extended-insert", no_argument, 0, 'e'}, + {"delayed-insert", no_argument, 0, OPT_DELAYED}, + {"disable-keys", no_argument, 0, 'K'}, + {"extended-insert", no_argument, 0, 'e'}, {"fields-terminated-by", required_argument, 0, (int) OPT_FTB}, {"fields-enclosed-by", required_argument, 0, (int) OPT_ENC}, {"fields-optionally-enclosed-by", required_argument, 0, (int) OPT_O_ENC}, {"fields-escaped-by", required_argument, 0, (int) OPT_ESC}, {"first-slave", no_argument, 0, 'x'}, {"flush-logs", no_argument, 0, 'F'}, - {"force", no_argument, 0, 'f'}, - {"help", no_argument, 0, '?'}, - {"host", required_argument, 0, 'h'}, + {"force", no_argument, 0, 'f'}, + {"help", no_argument, 0, '?'}, + {"host", required_argument, 0, 'h'}, {"lines-terminated-by", required_argument, 0, (int) OPT_LTB}, - {"lock-tables", no_argument, 0, 'l'}, + {"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'}, - {"opt", no_argument, 0, OPT_OPTIMIZE}, - {"password", optional_argument, 0, 'p'}, + {"no-create-info", no_argument, 0, 't'}, + {"no-data", no_argument, 0, 'd'}, + {"opt", no_argument, 0, OPT_OPTIMIZE}, + {"password", optional_argument, 0, 'p'}, #ifdef __WIN__ - {"pipe", no_argument, 0, 'W'}, + {"pipe", no_argument, 0, 'W'}, #endif - {"port", required_argument, 0, 'P'}, - {"quick", no_argument, 0, 'q'}, + {"port", required_argument, 0, 'P'}, + {"quick", no_argument, 0, 'q'}, {"quote-names", no_argument, 0, 'Q'}, {"result-file", required_argument, 0, 'r'}, {"set-variable", required_argument, 0, 'O'}, - {"socket", required_argument, 0, 'S'}, + {"socket", required_argument, 0, 'S'}, #include "sslopt-longopts.h" - {"tab", required_argument, 0, 'T'}, + {"tab", required_argument, 0, 'T'}, {"tables", no_argument, 0, OPT_TABLES}, #ifndef DONT_ALLOW_USER_CHANGE - {"user", required_argument, 0, 'u'}, + {"user", required_argument, 0, 'u'}, #endif - {"verbose", no_argument, 0, 'v'}, - {"version", no_argument, 0, 'V'}, - {"where", required_argument, 0, 'w'}, + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"where", required_argument, 0, 'w'}, + {"xml", no_argument, 0, 'X'}, {0, 0, 0, 0} }; @@ -151,7 +154,7 @@ CHANGEABLE_VAR md_changeable_vars[] = { }; static void safe_exit(int error); -static void write_heder(FILE *sql_file, char *db_name); +static void write_header(FILE *sql_file, char *db_name); static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row, const char *prefix,const char *name, int string_value); @@ -161,6 +164,7 @@ static int init_dumping(char *); static int dump_databases(char **); static int dump_all_databases(); static char *quote_name(char *name, char *buff); +static void print_quoted_xml(FILE *output, char *fname, char *str, uint len); static void print_version(void) { @@ -202,11 +206,18 @@ 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\ + -K, --disable-keys '/*!40000 ALTER TABLE tb_name DISABLE KEYS */;\n\ + and '/*!40000 ALTER TABLE tb_name ENABLE KEYS */;\n\ + will be put in the output.\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\ @@ -215,12 +226,12 @@ puts("\ -d, --no-data No row information.\n\ -O, --set-variable var=option\n\ give a variable a value. --help lists variables\n\ - --opt Same as --add-drop-table --add-locks --all\n\ - --extended-insert --quick --lock-tables\n\ + --opt Same as --add-drop-table --add-locks --all --quick\n\ + --extended-insert --lock-tables --disable-keys\n\ -p, --password[=...] Password to use when connecting to server.\n\ If password is not given it's solicited on the tty.\n"); #ifdef __WIN__ - puts("-W, --pipe Use named pipes to connect to server"); + puts("-W, --pipe Use named pipes to connect to server"); #endif printf("\ -P, --port=... Port number to use for connection.\n\ @@ -246,6 +257,8 @@ 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, --xml dump a database as well formed XML\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\ @@ -269,17 +282,22 @@ puts("\ } /* usage */ -static void write_heder(FILE *sql_file, char *db_name) +static void write_header(FILE *sql_file, char *db_name) { - 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", - sql_file); - fprintf(sql_file, "# Server version\t%s\n", - mysql_get_server_info(&mysql_connection)); + if (opt_xml) + fprintf(sql_file,"\n"); + else + { + 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", + sql_file); + fprintf(sql_file, "-- Server version\t%s\n", + mysql_get_server_info(&mysql_connection)); + } return; -} /* write_heder */ +} /* write_header */ static int get_options(int *argc,char ***argv) @@ -291,10 +309,17 @@ static int get_options(int *argc,char ***argv) load_defaults("my",load_default_groups,argc,argv); set_all_changeable_vars(md_changeable_vars); while ((c=getopt_long(*argc,*argv, - "#::p::h:u:O:P:r:S:T:EBaAcCdefFlnqtvVw:?Ix", + "#::p::h:u:O:P:r:S:T:EBaAcCdefFKlnqtvVw:?IxX", 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; @@ -320,6 +345,9 @@ static int get_options(int *argc,char ***argv) my_free(current_host,MYF(MY_ALLOW_ZERO_PTR)); current_host=my_strdup(optarg,MYF(MY_WME)); break; + case 'K': + opt_disable_keys=1; + break; case 'n': opt_create_db = 1; break; @@ -366,6 +394,7 @@ static int get_options(int *argc,char ***argv) break; case 'T': path= optarg; + opt_disable_keys=0; break; case 'B': opt_databases = 1; @@ -387,6 +416,10 @@ static int get_options(int *argc,char ***argv) case 'w': where=optarg; break; + case 'X': + opt_xml = 1; + opt_disable_keys=0; + break; case 'x': opt_first_slave=1; break; @@ -422,7 +455,8 @@ static int get_options(int *argc,char ***argv) opt_lock=1; break; case (int) OPT_OPTIMIZE: - extended_insert=opt_drop=opt_lock=lock_tables=quick=create_options=1; + extended_insert=opt_drop=opt_lock=lock_tables=quick=create_options= + opt_disable_keys=1; break; case (int) OPT_DELAYED: opt_delayed=1; @@ -512,7 +546,7 @@ static int dbConnect(char *host, char *user,char *passwd) DBUG_ENTER("dbConnect"); if (verbose) { - fprintf(stderr, "# Connecting to %s...\n", host ? host : "localhost"); + fprintf(stderr, "-- Connecting to %s...\n", host ? host : "localhost"); } mysql_init(&mysql_connection); if (opt_compress) @@ -520,7 +554,7 @@ static int dbConnect(char *host, char *user,char *passwd) #ifdef HAVE_OPENSSL if (opt_use_ssl) mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, - opt_ssl_capath); + opt_ssl_capath, opt_ssl_cipher); #endif if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd, NULL,opt_mysql_port,opt_mysql_unix_port, @@ -539,7 +573,7 @@ static int dbConnect(char *host, char *user,char *passwd) static void dbDisconnect(char *host) { if (verbose) - fprintf(stderr, "# Disconnecting from %s...\n", host ? host : "localhost"); + fprintf(stderr, "-- Disconnecting from %s...\n", host ? host : "localhost"); mysql_close(sock); } /* dbDisconnect */ @@ -553,7 +587,7 @@ static void unescape(FILE *file,char *pos,uint length) ignore_errors=0; /* Fatal error */ safe_exit(EX_MYSQLERR); /* Force exit */ } - mysql_real_escape_string(&mysql_connection,tmp, pos, length); + mysql_real_escape_string(&mysql_connection, tmp, pos, length); fputc('\'', file); fputs(tmp, file); fputc('\'', file); @@ -596,16 +630,16 @@ static uint getTableStructure(char *table, char* db) MYSQL_ROW row; my_bool init=0; uint numFields; - char *strpos, *table_name; + char *strpos, *table_name; const char *delayed; - char name_buff[NAME_LEN+3],table_buff[NAME_LEN+3]; + char name_buff[NAME_LEN+3],table_buff[NAME_LEN+3]; FILE *sql_file = md_result_file; DBUG_ENTER("getTableStructure"); delayed= opt_delayed ? " DELAYED " : ""; if (verbose) - fprintf(stderr, "# Retrieving table structure for table %s...\n", table); + fprintf(stderr, "-- Retrieving table structure for table %s...\n", table); sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", opt_quoted); table_name=quote_name(table,table_buff); @@ -621,7 +655,7 @@ static uint getTableStructure(char *table, char* db) if (mysql_query(sock, buff)) { fprintf(stderr, "%s: Can't get CREATE TABLE for table '%s' (%s)\n", - my_progname, table, mysql_error(sock)); + my_progname, table, mysql_error(sock)); safe_exit(EX_MYSQLERR); DBUG_RETURN(0); } @@ -629,31 +663,36 @@ static uint getTableStructure(char *table, char* db) if (path) { char filename[FN_REFLEN], tmp_path[FN_REFLEN]; - strmov(tmp_path,path); + strmov(tmp_path,path); convert_dirname(tmp_path); sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4), - O_WRONLY, MYF(MY_WME)); + O_WRONLY, MYF(MY_WME)); if (!sql_file) /* If file couldn't be opened */ { safe_exit(EX_MYSQLERR); DBUG_RETURN(0); } - write_heder(sql_file, db); + write_header(sql_file, db); } - fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table); + if (!opt_xml) + 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); tableRes=mysql_store_result(sock); row=mysql_fetch_row(tableRes); - fprintf(sql_file, "%s;\n", row[1]); + if (!opt_xml) + fprintf(sql_file, "%s;\n", row[1]); mysql_free_result(tableRes); } sprintf(insert_pat,"show fields from %s",table_name); if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) { fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", - my_progname, table, mysql_error(sock)); + my_progname, table, mysql_error(sock)); + if (path) + my_fclose(sql_file, MYF(MY_WME)); safe_exit(EX_MYSQLERR); DBUG_RETURN(0); } @@ -702,18 +741,20 @@ static uint getTableStructure(char *table, char* db) if (path) { char filename[FN_REFLEN], tmp_path[FN_REFLEN]; - strmov(tmp_path,path); + strmov(tmp_path,path); convert_dirname(tmp_path); sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4), O_WRONLY, MYF(MY_WME)); if (!sql_file) /* If file couldn't be opened */ { - safe_exit(EX_MYSQLERR); - DBUG_RETURN(0); + safe_exit(EX_MYSQLERR); + DBUG_RETURN(0); } - write_heder(sql_file, db); + write_header(sql_file, db); } - fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table); + if (!opt_xml) + 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); @@ -752,7 +793,7 @@ static uint getTableStructure(char *table, char* db) if (row[SHOW_DEFAULT]) { fputs(" DEFAULT ", sql_file); - unescape(sql_file,row[SHOW_DEFAULT],lengths[SHOW_DEFAULT]); + unescape(sql_file, row[SHOW_DEFAULT], lengths[SHOW_DEFAULT]); } if (!row[SHOW_NULL][0]) fputs(" NOT NULL", sql_file); @@ -772,7 +813,7 @@ static uint getTableStructure(char *table, char* db) { fprintf(stderr, "%s: Can't get keys for table '%s' (%s)\n", my_progname, table, mysql_error(sock)); - if (sql_file != stdout) + if (path) my_fclose(sql_file, MYF(MY_WME)); safe_exit(EX_MYSQLERR); DBUG_RETURN(0); @@ -834,7 +875,7 @@ static uint getTableStructure(char *table, char* db) { /* If old MySQL version */ if (verbose) fprintf(stderr, - "# Warning: Couldn't get status information for table '%s' (%s)\n", + "-- Warning: Couldn't get status information for table '%s' (%s)\n", table,mysql_error(sock)); } } @@ -858,12 +899,16 @@ static uint getTableStructure(char *table, char* db) fputs(";\n", sql_file); } } + if (opt_disable_keys) + fprintf(sql_file,"\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n",table_name); if (cFlag) { strpos=strmov(strpos,") VALUES "); if (!extended_insert) strpos=strmov(strpos,"("); } + if (sql_file != md_result_file) + my_fclose(sql_file, MYF(MY_WME)); DBUG_RETURN(numFields); } /* getTableStructure */ @@ -931,11 +976,11 @@ static void dumpTable(uint numFields, char *table) ulong rownr, row_break, total_length, init_length; if (verbose) - fprintf(stderr, "# Sending SELECT query...\n"); + fprintf(stderr, "-- Sending SELECT query...\n"); if (path) { char filename[FN_REFLEN], tmp_path[FN_REFLEN]; - strmov(tmp_path, path); + strmov(tmp_path,path); convert_dirname(tmp_path); my_load_path(tmp_path, tmp_path, NULL); fn_format(filename, table, tmp_path, ".txt", 4); @@ -958,7 +1003,7 @@ static void dumpTable(uint numFields, char *table) end= add_load_option(end, lines_terminated, " LINES TERMINATED BY"); *end= '\0'; - sprintf(buff," FROM %s",table); + sprintf(buff," FROM %s",quote_name(table,table_buff)); end= strmov(end,buff); if (where) end= strxmov(end, " WHERE ",where,NullS); @@ -970,15 +1015,18 @@ static void dumpTable(uint numFields, char *table) } else { - fprintf(md_result_file,"\n#\n# Dumping data for table '%s'\n", table); + if (!opt_xml) + 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) { - fprintf(md_result_file,"# WHERE: %s\n",where); + if (!opt_xml) + fprintf(md_result_file,"-- WHERE: %s\n",where); strxmov(strend(query), " WHERE ",where,NullS); } - fputs("#\n\n", md_result_file); - + if (!opt_xml) + fputs("\n\n", md_result_file); if (mysql_query(sock, query)) { DBerror(sock, "when retrieving data from server"); @@ -994,7 +1042,7 @@ static void dumpTable(uint numFields, char *table) return; } if (verbose) - fprintf(stderr, "# Retrieving rows...\n"); + fprintf(stderr, "-- Retrieving rows...\n"); if (mysql_num_fields(res) != numFields) { fprintf(stderr,"%s: Error in field count for table: '%s' ! Aborting.\n", @@ -1011,13 +1059,18 @@ static void dumpTable(uint numFields, char *table) row_break=0; rownr=0; init_length=(uint) strlen(insert_pat)+4; + if (opt_xml) + fprintf(md_result_file, "\t<%s>\n", table); + + if (opt_autocommit) + fprintf(md_result_file, "set autocommit=0;\n"); while ((row=mysql_fetch_row(res))) { uint i; ulong *lengths=mysql_fetch_lengths(res); rownr++; - if (!extended_insert) + if (!extended_insert && !opt_xml) fputs(insert_pat,md_result_file); mysql_field_seek(res,0); @@ -1076,22 +1129,36 @@ static void dumpTable(uint numFields, char *table) } else { - if (i) - fputc(',',md_result_file); + if (i && !opt_xml) + fputc(',', md_result_file); if (row[i]) { if (!IS_NUM_FIELD(field)) - unescape(md_result_file, row[i], lengths[i]); + { + if (opt_xml) + print_quoted_xml(md_result_file, field->name, row[i], + lengths[i]); + else + unescape(md_result_file, row[i], lengths[i]); + } else { /* change any strings ("inf","nan",..) into NULL */ char *ptr = row[i]; - fputs((!isalpha(*ptr)) ? ptr : "NULL", md_result_file); + if (opt_xml) + fprintf(md_result_file, "\t\t<%s>%s\n", + field->name,!isalpha(*ptr) ?ptr: "NULL",field->name); + else + fputs((!isalpha(*ptr)) ? ptr : "NULL", md_result_file); } } else { - fputs("NULL",md_result_file); + if (opt_xml) + fprintf(md_result_file, "\t\t<%s>%s\n", + field->name, "NULL", field->name); + else + fputs("NULL", md_result_file); } } } @@ -1109,18 +1176,26 @@ static void dumpTable(uint numFields, char *table) } else { - if (row_break) + if (row_break && !opt_xml) fputs(";\n", md_result_file); row_break=1; /* This is first row */ - fputs(insert_pat,md_result_file); - fputs(extended_row.str,md_result_file); + + if (!opt_xml) + { + fputs(insert_pat,md_result_file); + fputs(extended_row.str,md_result_file); + } total_length = row_length+init_length; } } - else + else if (!opt_xml) fputs(");\n", md_result_file); } - if (extended_insert && row_break) + + //XML - close table tag and supress regular output + if (opt_xml) + fprintf(md_result_file, "\t\n", table); + else if (extended_insert && row_break) fputs(";\n", md_result_file); /* If not empty table */ fflush(md_result_file); if (mysql_errno(sock)) @@ -1135,13 +1210,39 @@ static void dumpTable(uint numFields, char *table) safe_exit(EX_CONSCHECK); return; } + if (opt_disable_keys) + fprintf(md_result_file,"\n/*!40000 ALTER TABLE %s ENABLE KEYS */;\n", + quote_name(table,table_buff)); if (opt_lock) fputs("UNLOCK TABLES;\n", md_result_file); + if (opt_autocommit) + fprintf(md_result_file, "commit;\n"); mysql_free_result(res); } } /* dumpTable */ +static void print_quoted_xml(FILE *output, char *fname, char *str, uint len) +{ + const char *end; + + fprintf(output, "\t\t<%s>", fname); + for (end = str + len; str != end; str++) + { + if (*str == '<') + fputs("<", output); + else if (*str == '>') + fputs(">", output); + else if (*str == '&') + fputs("&", output); + else if (*str == '\"') + fputs(""", output); + else + fputc(*str, output); + } + fprintf(output, "<%s>\n", fname); +} + static char *getTableName(int reset) { static MYSQL_RES *res = NULL; @@ -1194,8 +1295,13 @@ static int dump_databases(char **db_names) int result=0; for ( ; *db_names ; db_names++) { + //XML edit - add database element + if (opt_xml) + fprintf(md_result_file, "<%s>\n", *db_names); if (dump_all_tables_in_db(*db_names)) result=1; + if (opt_xml) + fprintf(md_result_file, "\n", *db_names); } return result; } /* dump_databases */ @@ -1212,7 +1318,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); @@ -1240,7 +1346,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)) @@ -1282,7 +1388,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)) @@ -1338,6 +1444,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 @@ -1350,19 +1459,19 @@ int main(int argc, char **argv) if (dbConnect(current_host, current_user, opt_password)) exit(EX_MYSQLERR); if (!path) - write_heder(md_result_file, *argv); + write_header(md_result_file, *argv); - if (opt_first_slave) - { - lock_tables=0; /* No other locks needed */ - if (mysql_query(sock, "FLUSH TABLES WITH READ LOCK")) - { - my_printf_error(0, "Error: Couldn't execute 'FLUSH TABLES WITH READ LOCK': %s", - MYF(0), mysql_error(sock)); - my_end(0); - return(first_error); - } - } + if (opt_first_slave) + { + lock_tables=0; /* No other locks needed */ + if (mysql_query(sock, "FLUSH TABLES WITH READ LOCK")) + { + my_printf_error(0, "Error: Couldn't execute 'FLUSH TABLES WITH READ LOCK': %s", + MYF(0), mysql_error(sock)); + my_end(0); + return(first_error); + } + } if (opt_alldbs) dump_all_databases(); /* Only one database and selected table(s) */ @@ -1374,6 +1483,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/include/global.h b/include/global.h index 857c66d3640..b8b118cd855 100644 --- a/include/global.h +++ b/include/global.h @@ -616,8 +616,8 @@ typedef unsigned long ulong; /* Short for unsigned long */ #endif #ifndef longlong_defined #if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8 -typedef unsigned long long ulonglong; /* ulong or unsigned long long */ -typedef long long longlong; +typedef unsigned long long int ulonglong; /* ulong or unsigned long long */ +typedef long long int longlong; #else typedef unsigned long ulonglong; /* ulong or unsigned long long */ typedef long longlong; From 89f8ca058e3c548fa23b7a4aeb5662425d3d83b0 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Wed, 2 Jan 2002 14:12:37 +0200 Subject: [PATCH 14/14] Removed Heikki's changes to the manual that was meant for 4.0 --- Docs/manual.texi | 76 ++++++++++++------------------------------------ configure.in | 2 +- 2 files changed, 20 insertions(+), 58 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index c657a75a992..479eeb7dc69 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -36313,37 +36313,23 @@ the configuration file @file{my.cnf}. @xref{Option files}. The only required parameter to use InnoDB is @code{innodb_data_file_path}, but you should set others if you want to get a better performance. -Suppose you have a Windows NT computer with 128 MB RAM and a single 10 GB +Suppose you have a Windows NT machine with 128 MB RAM and a single 10 GB hard disk. Below is an example of possible configuration parameters in @file{my.cnf} for InnoDB: @example -[mysqld] -# You can write your other MySQL server options here -# ... -# -innodb_data_home_dir = c:\ibdata -# Data files must be able to -# hold your data and indexes innodb_data_file_path = ibdata1:2000M;ibdata2:2000M -# Set buffer pool size to 50 - 80 % -# of your computer's memory -set-variable = innodb_buffer_pool_size=70M -set-variable = innodb_additional_mem_pool_size=10M +innodb_data_home_dir = c:\ibdata +set-variable = innodb_mirrored_log_groups=1 innodb_log_group_home_dir = c:\iblogs -# .._log_arch_dir must be the same -# as .._log_group_home_dir +set-variable = innodb_log_files_in_group=3 +set-variable = innodb_log_file_size=30M +set-variable = innodb_log_buffer_size=8M +innodb_flush_log_at_trx_commit=1 innodb_log_arch_dir = c:\iblogs innodb_log_archive=0 -set-variable = innodb_log_files_in_group=3 -# Set the log file size to about -# 15 % of the buffer pool size -set-variable = innodb_log_file_size=10M -set-variable = innodb_log_buffer_size=8M -# Set ..flush_log_at_trx_commit to -# 0 if you can afford losing -# a few last transactions -innodb_flush_log_at_trx_commit=1 +set-variable = innodb_buffer_pool_size=80M +set-variable = innodb_additional_mem_pool_size=10M set-variable = innodb_file_io_threads=4 set-variable = innodb_lock_wait_timeout=50 @end example @@ -36354,44 +36340,27 @@ to be >= 10 MB. InnoDB does not create directories: you have to create them yourself. -Suppose you have a Linux computer with 512 MB RAM and +Suppose you have a Linux machine with 512 MB RAM and three 20 GB hard disks (at directory paths @file{/}, @file{/dr2} and @file{/dr3}). Below is an example of possible configuration parameters in @file{my.cnf} for InnoDB: @example -[mysqld] -# You can write your other MySQL server options here -# ... -# -innodb_data_home_dir = / -# Data files must be able to -# hold your data and indexes innodb_data_file_path = ibdata/ibdata1:2000M;dr2/ibdata/ibdata2:2000M -# Set buffer pool size to 50 - 80 % -# of your computer's memory -set-variable = innodb_buffer_pool_size=350M -set-variable = innodb_additional_mem_pool_size=20M -innodb_log_group_home_dir = /dr3/iblogs -# .._log_arch_dir must be the same -# as .._log_group_home_dir -innodb_log_arch_dir = /dr3/iblogs -innodb_log_archive=0 +innodb_data_home_dir = / +set-variable = innodb_mirrored_log_groups=1 +innodb_log_group_home_dir = /dr3 set-variable = innodb_log_files_in_group=3 -# Set the log file size to about -# 15 % of the buffer pool size set-variable = innodb_log_file_size=50M set-variable = innodb_log_buffer_size=8M -# Set ..flush_log_at_trx_commit to -# 0 if you can afford losing -# a few last transactions innodb_flush_log_at_trx_commit=1 +innodb_log_arch_dir = /dr3/iblogs +innodb_log_archive=0 +set-variable = innodb_buffer_pool_size=400M +set-variable = innodb_additional_mem_pool_size=20M set-variable = innodb_file_io_threads=4 set-variable = innodb_lock_wait_timeout=50 -#innodb_flush_method=fdatasync -#innodb_fast_shutdown=1 -#set-variable = innodb_thread_concurrency=5 @end example Note that we have placed the two data files on different disks. @@ -36405,10 +36374,6 @@ improve the performance of the database if all data is not placed on the same physical disk. Putting log files on a different disk from data is very often beneficial for performance. -The combined size of the log files MUST be < 4G in a 32-bit computer, -and to make recovery reasonably fast you should keep the combined size -smaller than the buffer pool size. - The meanings of the configuration parameters are the following: @multitable @columnfractions .30 .70 @@ -36432,9 +36397,7 @@ Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here. @item @code{innodb_log_file_size} @tab Size of each log file in a log group in megabytes. Sensible values range -from 1M to 1/nth of the size of the buffer pool specified below, where -n is the number of log files in the log group. -The bigger the +from 1M to the size of the buffer pool specified below. The bigger the value, the less checkpoint flush activity is needed in the buffer pool, saving disk i/o. But bigger log files also mean that recovery will be slower in case of a crash. File size restriction as for a data file. @@ -37137,8 +37100,7 @@ to zero. InnoDB tries to flush the log anyway once in a second, though the flush is not guaranteed. @strong{4.} -Make your log files big, the combined size -even as big as the buffer pool. When InnoDB +Make your log files big, even as big as the buffer pool. When InnoDB has written the log files full, it has to write the modified contents of the buffer pool to disk in a checkpoint. Small log files will cause many unnecessary disk writes. The drawback in big log files is that recovery diff --git a/configure.in b/configure.in index 562790e3b1e..7b0c604d2be 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 3.23.47) +AM_INIT_AUTOMAKE(mysql, 3.23.48) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10