From aa8ab68fea734374521aacf696fe970a7f8334ac Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Mon, 17 Apr 2006 12:33:45 +0500 Subject: [PATCH 001/119] Bug#17939: Wrong table format when using UTF8 strings Lines with column names consisting of national letters were wrongly formatted in "mysql --table" results: mysql> SELECT 'xxx xxx xxx' as 'xxx xxx xxx'; +-------------------+ | xxx xxx xxx | +-------------------+ | xxx xxx xxx | +-------------------+ 1 row in set (0.00 sec) It happened because in UTF-8 (and other multibyte charsets) the number of display cells is not always equal to the number of bytes of the string. Data lines (unlike column name lines) were formatted correctly, because data lines were displayed taking in account number of display cells. This patch takes in account number of cells when displaying column names, the same way like displaying data lines does. Note: The patch is going to be applied to 4.1. Test case will be added after merge to 5.0, into "mysql.test", which appeared in 5.0. mysql.cc: Adding column name allignment using numcells(), the same to data alignment, which was implemented earlier. --- client/mysql.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 2f9031b84b8..22fe6e81b25 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2145,9 +2145,14 @@ print_table_data(MYSQL_RES *result) (void) tee_fputs("|", PAGER); for (uint off=0; (field = mysql_fetch_field(result)) ; off++) { - tee_fprintf(PAGER, " %-*s|",(int) min(field->max_length, + uint name_length= (uint) strlen(field->name); + uint numcells= charset_info->cset->numcells(charset_info, + field->name, + field->name + name_length); + uint display_length= field->max_length + name_length - numcells; + tee_fprintf(PAGER, " %-*s|",(int) min(display_length, MAX_COLUMN_LENGTH), - field->name); + field->name); num_flag[off]= IS_NUM(field->type); } (void) tee_fputs("\n", PAGER); From 093792c6c24439bc81afb30899cd260674cb6f87 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Thu, 20 Apr 2006 15:09:01 +0500 Subject: [PATCH 002/119] Bug#9509: Optimizer: wrong result after AND with latin1_german2_ci comparisons Fixing part2 of this problem: AND didn't work well with utf8_czech_ci and utf8_lithianian_ci in some cases. The problem was because when during condition optimization field was replaced with a constant, the constant's collation and collation derivation was used later for comparison instead of the field collation and derivation, which led to non-equal new condition in some cases. This patch copies collation and derivation from the field being removed to the new constant, which makes comparison work using the same collation with the one which would be used if no condition optimization were done. In other words: where s1 < 'K' and s1 = 'Y'; was rewritten to: where 'Y' < 'K' and s1 = 'Y'; Now it's rewritten to: where 'Y' collate collation_of_s1 < 'K' and s1 = 'Y' (using derivation of s1) Note, the first problem of this bug (with latin1_german2_ci) was fixed earlier in 5.0 tree, in a separate changeset. --- mysql-test/r/ctype_utf8.result | 31 +++++++++++++++++++++++++++++++ mysql-test/t/ctype_utf8.test | 18 ++++++++++++++++++ sql/sql_select.cc | 4 ++++ 3 files changed, 53 insertions(+) diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 69d7577ee77..615b0ae2d52 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -924,6 +924,37 @@ NULL select ifnull(NULL, _utf8'string'); ifnull(NULL, _utf8'string') string +set names utf8; +create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci); +insert into t1 values ('I'),('K'),('Y'); +select * from t1 where s1 < 'K' and s1 = 'Y'; +s1 +I +Y +select * from t1 where 'K' > s1 and s1 = 'Y'; +s1 +I +Y +drop table t1; +create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci); +insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i'); +select * from t1 where s1 > 'd' and s1 = 'CH'; +s1 +ch +CH +Ch +select * from t1 where 'd' < s1 and s1 = 'CH'; +s1 +ch +CH +Ch +select * from t1 where s1 = 'cH' and s1 <> 'ch'; +s1 +cH +select * from t1 where 'cH' = s1 and s1 <> 'ch'; +s1 +cH +drop table t1; create table t1 (a varchar(255)) default character set utf8; insert into t1 values (1.0); drop table t1; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 5044f7979f1..159e8490f12 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -727,6 +727,24 @@ drop table t1; select repeat(_utf8'+',3) as h union select NULL; select ifnull(NULL, _utf8'string'); +# +# Bug#9509 Optimizer: wrong result after AND with comparisons +# +set names utf8; +create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci); +insert into t1 values ('I'),('K'),('Y'); +select * from t1 where s1 < 'K' and s1 = 'Y'; +select * from t1 where 'K' > s1 and s1 = 'Y'; +drop table t1; + +create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci); +insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i'); +select * from t1 where s1 > 'd' and s1 = 'CH'; +select * from t1 where 'd' < s1 and s1 = 'CH'; +select * from t1 where s1 = 'cH' and s1 <> 'ch'; +select * from t1 where 'cH' = s1 and s1 <> 'ch'; +drop table t1; + # # Bug#10714: Inserting double value into utf8 column crashes server # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 91fc808058f..caaace13c6f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4456,6 +4456,8 @@ change_cond_ref_to_const(THD *thd, I_List *save_list, left_item->collation.collation == value->collation.collation)) { Item *tmp=value->new_item(); + tmp->collation.set(right_item->collation); + if (tmp) { thd->change_item_tree(args + 1, tmp); @@ -4477,6 +4479,8 @@ change_cond_ref_to_const(THD *thd, I_List *save_list, right_item->collation.collation == value->collation.collation)) { Item *tmp=value->new_item(); + tmp->collation.set(left_item->collation); + if (tmp) { thd->change_item_tree(args, tmp); From 1252cec249fc1b92d837b488fed162fd04d9fdd2 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/deer.(none)" <> Date: Tue, 25 Jul 2006 18:02:42 +0500 Subject: [PATCH 003/119] Bug #15440 (handler.test hangs in embedded mode) the old problem - mysqltest can't handle multiple connections in the embedded server properly. So i disabled the test for the embedded mode until mysqltest is fixed --- mysql-test/t/handler.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test index a78800d3d5a..55936e44b32 100644 --- a/mysql-test/t/handler.test +++ b/mysql-test/t/handler.test @@ -1,3 +1,4 @@ +-- source include/not_embedded.inc # # test of HANDLER ... # From 21f721c6f533e9dd5c01c706e967f6d1dbd1ad4f Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/deer.(none)" <> Date: Tue, 1 Aug 2006 15:18:21 +0500 Subject: [PATCH 004/119] bug #13717 embedded library dumps warnings on STDERR directly Here i just disabled STDERR warnings in embedded server Later we should get more defined about logs in the embedded server --- sql/log.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sql/log.cc b/sql/log.cc index c530f15a84f..78605de3141 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2321,6 +2321,12 @@ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, void */ +#ifdef EMBEDDED_LIBRARY +void vprint_msg_to_log(enum loglevel level __attribute__((unused)), + const char *format __attribute__((unused)), + va_list argsi __attribute__((unused))) +{} +#else /*!EMBEDDED_LIBRARY*/ void vprint_msg_to_log(enum loglevel level, const char *format, va_list args) { char buff[1024]; @@ -2336,6 +2342,7 @@ void vprint_msg_to_log(enum loglevel level, const char *format, va_list args) DBUG_VOID_RETURN; } +#endif /*EMBEDDED_LIBRARY*/ void sql_print_error(const char *format, ...) From b76f0d31d8a5dd05e6411725703bfbfb2334e7b8 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com/c-4b4072d5.010-2112-6f72651.cust.bredbandsbolaget.se" <> Date: Wed, 2 Aug 2006 00:04:58 +0200 Subject: [PATCH 005/119] mysql.sln: Use separate ID for mysqlimport and mysql_upgrade --- VC++Files/mysql.sln | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/VC++Files/mysql.sln b/VC++Files/mysql.sln index bd0cae1d5d8..1e3a33b8eb4 100644 --- a/VC++Files/mysql.sln +++ b/VC++Files/mysql.sln @@ -174,7 +174,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysqlimport", "client\mysql {44D9C7DC-6636-4B82-BD01-6876C64017DF} = {44D9C7DC-6636-4B82-BD01-6876C64017DF} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_upgrade", "client\mysql_upgrade.vcproj", "{AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3D}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_upgrade", "client\mysql_upgrade.vcproj", "{AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}" ProjectSection(ProjectDependencies) = postProject {BA86AE72-0CF5-423D-BBA2-E12B0D72EBFB} = {BA86AE72-0CF5-423D-BBA2-E12B0D72EBFB} {26383276-4843-494B-8BE0-8936ED3EBAAB} = {26383276-4843-494B-8BE0-8936ED3EBAAB} @@ -990,6 +990,33 @@ Global {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3D}.pro nt.Build.0 = Release|Win32 {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3D}.Release.ActiveCfg = Release|Win32 {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3D}.Release.Build.0 = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.classic.ActiveCfg = classic|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.classic.Build.0 = classic|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.classic nt.ActiveCfg = classic|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.classic nt.Build.0 = classic|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Debug.ActiveCfg = Debug|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Debug.Build.0 = Debug|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Embedded_Classic.ActiveCfg = classic|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Embedded_Debug.ActiveCfg = Debug|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Embedded_Pro.ActiveCfg = classic|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Embedded_ProGPL.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Embedded_Release.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Max.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Max.Build.0 = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Max nt.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Max nt.Build.0 = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.nt.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.nt.Build.0 = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.pro.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.pro.Build.0 = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.pro gpl.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.pro gpl.Build.0 = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.pro gpl nt.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.pro gpl nt.Build.0 = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.pro nt.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.pro nt.Build.0 = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Release.ActiveCfg = Release|Win32 + {AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Release.Build.0 = Release|Win32 {94B86159-C581-42CD-825D-C69CBC237E5C}.classic.ActiveCfg = Release|Win32 {94B86159-C581-42CD-825D-C69CBC237E5C}.classic.Build.0 = Release|Win32 {94B86159-C581-42CD-825D-C69CBC237E5C}.classic nt.ActiveCfg = Release|Win32 From 8a4c19d915c1a45d85947a71915f98fc66b694a4 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com/bar.intranet.mysql.r18.ru" <> Date: Fri, 11 Aug 2006 13:14:26 +0500 Subject: [PATCH 006/119] Bug#7192 Specify --with-collation doesn't work for connections? --with-collation worked only on the server side. Client side ignored this argument, so collation_connection was not properly set (remained latin1_swedish_ci). --- sql-common/client.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/sql-common/client.c b/sql-common/client.c index e5bab51ca8a..ff5f1ef150a 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1544,11 +1544,18 @@ C_MODE_START int mysql_init_character_set(MYSQL *mysql) { NET *net= &mysql->net; + const char *default_collation_name; + /* Set character set */ - if (!mysql->options.charset_name && - !(mysql->options.charset_name= + if (!mysql->options.charset_name) + { + default_collation_name= MYSQL_DEFAULT_COLLATION_NAME; + if (!(mysql->options.charset_name= my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME)))) return 1; + } + else + default_collation_name= NULL; { const char *save= charsets_dir; @@ -1556,6 +1563,28 @@ int mysql_init_character_set(MYSQL *mysql) charsets_dir=mysql->options.charset_dir; mysql->charset=get_charset_by_csname(mysql->options.charset_name, MY_CS_PRIMARY, MYF(MY_WME)); + if (mysql->charset && default_collation_name) + { + CHARSET_INFO *collation; + if ((collation= + get_charset_by_name(default_collation_name, MYF(MY_WME)))) + { + if (!my_charset_same(mysql->charset, collation)) + { + my_printf_error(ER_UNKNOWN_ERROR, + "COLLATION %s is not valid for CHARACTER SET %s", + MYF(0), + default_collation_name, mysql->options.charset_name); + mysql->charset= NULL; + } + else + { + mysql->charset= collation; + } + } + else + mysql->charset= NULL; + } charsets_dir= save; } From 4a63a64f1eda1872e9ad0ebcc193be6947271fb3 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com/bar.intranet.mysql.r18.ru" <> Date: Fri, 11 Aug 2006 13:19:44 +0500 Subject: [PATCH 007/119] mysqld --collation-server=xxx --character-set-server=yyy didn't work as expected: collation_server was set not to xxx, but to the default collation of character set "yyy". With different argument order it worked as expected: mysqld --character-set-server=yyy --collation-server=yyy Fix: initializate default_collation_name to 0 when processing --character-set-server only if --collation-server has not been specified in command line. --- mysql-test/r/ctype_ucs2_def.result | 3 +++ mysql-test/t/ctype_ucs2_def-master.opt | 2 +- mysql-test/t/ctype_ucs2_def.test | 5 +++++ sql/mysqld.cc | 6 ++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ctype_ucs2_def.result b/mysql-test/r/ctype_ucs2_def.result index 897dbac251c..2f9dc4ae616 100644 --- a/mysql-test/r/ctype_ucs2_def.result +++ b/mysql-test/r/ctype_ucs2_def.result @@ -1,3 +1,6 @@ +show variables like 'collation_server'; +Variable_name Value +collation_server ucs2_unicode_ci show variables like "%character_set_ser%"; Variable_name Value character_set_server ucs2 diff --git a/mysql-test/t/ctype_ucs2_def-master.opt b/mysql-test/t/ctype_ucs2_def-master.opt index 1f884ff1d67..a0b5b061860 100644 --- a/mysql-test/t/ctype_ucs2_def-master.opt +++ b/mysql-test/t/ctype_ucs2_def-master.opt @@ -1 +1 @@ ---default-character-set=ucs2 --default-collation=ucs2_unicode_ci +--default-collation=ucs2_unicode_ci --default-character-set=ucs2 diff --git a/mysql-test/t/ctype_ucs2_def.test b/mysql-test/t/ctype_ucs2_def.test index fb174d551cf..00f636d79dc 100644 --- a/mysql-test/t/ctype_ucs2_def.test +++ b/mysql-test/t/ctype_ucs2_def.test @@ -1,3 +1,8 @@ +# +# MySQL Bug#15276: MySQL ignores collation-server +# +show variables like 'collation_server'; + # # Bug#18004 Connecting crashes server when default charset is UCS2 # diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 74c7b1a4e4c..bf83772a8d8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -378,6 +378,7 @@ key_map key_map_full(0); // Will be initialized later const char *opt_date_time_formats[3]; +char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME; char *language_ptr, *default_collation_name, *default_character_set_name; char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home; struct passwd *user_info; @@ -5936,7 +5937,7 @@ static void mysql_init_variables(void) /* Variables in libraries */ charsets_dir= 0; default_character_set_name= (char*) MYSQL_DEFAULT_CHARSET_NAME; - default_collation_name= (char*) MYSQL_DEFAULT_COLLATION_NAME; + default_collation_name= compiled_default_collation_name; sys_charset_system.value= (char*) system_charset_info->csname; @@ -6091,7 +6092,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), strmake(mysql_home,argument,sizeof(mysql_home)-1); break; case 'C': - default_collation_name= 0; + if (default_collation_name == compiled_default_collation_name) + default_collation_name= 0; break; case 'l': opt_log=1; From 6e2c8bac4c339dd7f9c059f0f71d2ab3e2303b01 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Fri, 11 Aug 2006 09:49:01 -0400 Subject: [PATCH 008/119] Bug#18875: Default value of tmp_table_size is meaningless It makes no sense to have a default tmp_table_size larger than the max_heap_table_size . In usage, the tmp is ever limited to the max value, so I lowered the default tmp to the default max value. A great idea would be to emit a warning when the tmp_table_size is set to greater than max_heap_table_size . --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 087613c6b7c..4c6e5c5326b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6310,7 +6310,7 @@ The minimum value for this variable is 4096.", "If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.", (gptr*) &global_system_variables.tmp_table_size, (gptr*) &max_system_variables.tmp_table_size, 0, GET_ULONG, - REQUIRED_ARG, 32*1024*1024L, 1024, ~0L, 0, 1, 0}, + REQUIRED_ARG, 16*1024*1024L, 1024, ~0L, 0, 1, 0}, /* See max_heap_table_size . */ {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE, "Allocation block size for transactions to be stored in binary log", (gptr*) &global_system_variables.trans_alloc_block_size, From d6b00b72eb43559cb4857bc9d11ca8c8bb2af02b Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Fri, 11 Aug 2006 15:31:06 -0400 Subject: [PATCH 009/119] Bug#21224: mysql_upgrade uses possibly insecure temporary files We open for writing a known location, which is exploitable with a symlink attack. Now, use the EXCLusive flag, so that the presence of anything at that location causes a failure. Try once to open safely, and if failure then remove that location and try again to open safely. If both fail, then raise an error. --- client/mysql_upgrade.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 3288b627554..053eb86b051 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -149,17 +149,29 @@ static int create_defaults_file(const char *path, const char *our_defaults_path) File our_defaults_file, defaults_file; char buffer[512]; char *buffer_end; + int failed_to_open_count= 0; int error; /* check if the defaults file is needed at all */ if (!opt_password) return 0; - defaults_file= my_open(path, O_BINARY | O_CREAT | O_WRONLY, +retry_open: + defaults_file= my_open(path, O_BINARY | O_CREAT | O_WRONLY | O_EXCL, MYF(MY_FAE | MY_WME)); if (defaults_file < 0) - return 1; + { + if (failed_to_open_count == 0) + { + remove(path); + failed_to_open_count+= 1; + goto retry_open; + } + else + return 1; + } + upgrade_defaults_created= 1; if (our_defaults_path) { From 72d55f38789334e71a9c1de97c9a611e25c6bd66 Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Fri, 11 Aug 2006 17:09:19 -0600 Subject: [PATCH 010/119] Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb Make the encryption functions MD5(), SHA1() and ENCRYPT() return binary results. Make MAKE_SET() and EXPORT_SET() use the correct character set for their default separator strings. --- mysql-test/r/ctype_ucs.result | 43 +++++++++++++++++++++++++++++++++++ mysql-test/t/ctype_ucs.test | 41 ++++++++++++++++++++++++++++++++- sql/item_strfunc.cc | 14 ++++++++---- sql/item_strfunc.h | 26 +++++++++++++++++---- 4 files changed, 115 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index bcf9cc77519..3a65287ffc5 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -722,3 +722,46 @@ id MIN(s) 1 ZZZ 2 ZZZ DROP TABLE t1; +drop table if exists bug20536; +set names latin1; +create table bug20536 (id bigint not null auto_increment primary key, name +varchar(255) character set ucs2 not null); +insert into `bug20536` (`id`,`name`) values (1, _latin1 x'74657374311a'), (2, "'test\\_2'"); +select md5(name) from bug20536; +md5(name) +3417d830fe24ffb2f81a28e54df2d1b3 +48d95db0d8305c2fe11548a3635c9385 +select sha1(name) from bug20536; +sha1(name) +72228a6d56efb7a89a09543068d5d8fa4c330881 +677d4d505355eb5b0549b865fcae4b7f0c28aef5 +select make_set(3, name, upper(name)) from bug20536; +make_set(3, name, upper(name)) +test1,TEST1 +'test\_2','TEST\_2' +select export_set(5, name, upper(name)) from bug20536; +export_set(5, name, upper(name)) +test1,TEST1,test1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1 +'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2' +select export_set(5, name, upper(name), ",", 5) from bug20536; +export_set(5, name, upper(name), ",", 5) +test1,TEST1,test1,TEST1,TEST1 +'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2' +select password(name) from bug20536; +password(name) +???????????????????? +???????????????????? +select old_password(name) from bug20536; +old_password(name) +???????? +???????? +select encrypt(name, 'SALT') from bug20536; +encrypt(name, 'SALT') +SA5pDi1UPZdys +SA5pDi1UPZdys +select quote(name) from bug20536; +quote(name) +?????????? +???????????????? +drop table bug20536; +End of 4.1 tests diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index a4d4d1846a7..0ad38d98403 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -463,4 +463,43 @@ INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ'); SELECT id, MIN(s) FROM t1 GROUP BY id; DROP TABLE t1; -# End of 4.1 tests + +# +# Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb +# + +--disable_warnings +drop table if exists bug20536; +--enable_warnings + +set names latin1; +create table bug20536 (id bigint not null auto_increment primary key, name +varchar(255) character set ucs2 not null); +insert into `bug20536` (`id`,`name`) values (1, _latin1 x'74657374311a'), (2, "'test\\_2'"); +select md5(name) from bug20536; +select sha1(name) from bug20536; +select make_set(3, name, upper(name)) from bug20536; +select export_set(5, name, upper(name)) from bug20536; +select export_set(5, name, upper(name), ",", 5) from bug20536; + +# Some broken functions: add these tests just to document current behavior. + +# PASSWORD and OLD_PASSWORD don't work with UCS2 strings, but to fix it would +# not be backwards compatible in all cases, so it's best to leave it alone +select password(name) from bug20536; +select old_password(name) from bug20536; + +# ENCRYPT relies on OS function crypt() which takes a NUL-terminated string; it +# doesn't return good results for strings with embedded 0 bytes. It won't be +# fixed unless we choose to re-implement the crypt() function ourselves to take +# an extra size_t string_length argument. +select encrypt(name, 'SALT') from bug20536; + +# QUOTE doesn't work with UCS2 data. It would require a total rewrite +# of Item_func_quote::val_str(), which isn't worthwhile until UCS2 is +# supported fully as a client character set. +select quote(name) from bug20536; + +drop table bug20536; + +--echo End of 4.1 tests diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 7bc7956283b..56a31d074ac 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -88,6 +88,7 @@ String *Item_func_md5::val_str(String *str) { DBUG_ASSERT(fixed == 1); String * sptr= args[0]->val_str(str); + str->set_charset(&my_charset_bin); if (sptr) { my_MD5_CTX context; @@ -134,6 +135,7 @@ String *Item_func_sha::val_str(String *str) { DBUG_ASSERT(fixed == 1); String * sptr= args[0]->val_str(str); + str->set_charset(&my_charset_bin); if (sptr) /* If we got value different from NULL */ { SHA1_CONTEXT context; /* Context used to generate SHA1 hash */ @@ -1529,7 +1531,7 @@ String *Item_func_encrypt::val_str(String *str) null_value= 1; return 0; } - str->set(tmp,(uint) strlen(tmp),res->charset()); + str->set(tmp, (uint) strlen(tmp), &my_charset_bin); str->copy(); pthread_mutex_unlock(&LOCK_crypt); return str; @@ -1926,7 +1928,7 @@ String *Item_func_make_set::val_str(String *str) return &my_empty_string; result= &tmp_str; } - if (tmp_str.append(',') || tmp_str.append(*res)) + if (tmp_str.append(",", 1, &my_charset_bin) || tmp_str.append(*res)) return &my_empty_string; } } @@ -2592,8 +2594,12 @@ String* Item_func_export_set::val_str(String* str) } break; case 3: - sep_buf.set(",", 1, default_charset()); - sep = &sep_buf; + { + /* errors is not checked - assume "," can always be converted */ + uint errors; + sep_buf.copy(",", 1, &my_charset_bin, collation.collation, &errors); + sep = &sep_buf; + } break; default: DBUG_ASSERT(0); // cannot happen diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index f800c17182b..d3e2d24099b 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -41,7 +41,10 @@ class Item_func_md5 :public Item_str_func { String tmp_value; public: - Item_func_md5(Item *a) :Item_str_func(a) {} + Item_func_md5(Item *a) :Item_str_func(a) + { + collation.set(&my_charset_bin); + } String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "md5"; } @@ -51,7 +54,10 @@ public: class Item_func_sha :public Item_str_func { public: - Item_func_sha(Item *a) :Item_str_func(a) {} + Item_func_sha(Item *a) :Item_str_func(a) + { + collation.set(&my_charset_bin); + } String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "sha"; } @@ -306,9 +312,21 @@ public: class Item_func_encrypt :public Item_str_func { String tmp_value; + + /* Encapsulate common constructor actions */ + void constructor_helper() + { + collation.set(&my_charset_bin); + } public: - Item_func_encrypt(Item *a) :Item_str_func(a) {} - Item_func_encrypt(Item *a, Item *b): Item_str_func(a,b) {} + Item_func_encrypt(Item *a) :Item_str_func(a) + { + constructor_helper(); + } + Item_func_encrypt(Item *a, Item *b): Item_str_func(a,b) + { + constructor_helper(); + } String *val_str(String *); void fix_length_and_dec() { maybe_null=1; max_length = 13; } const char *func_name() const { return "ecrypt"; } From bc1e69d4530c093267a39180aefeba855c607674 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Mon, 14 Aug 2006 10:54:24 +0500 Subject: [PATCH 011/119] Restore alphabetical order of the system variables. --- sql/set_var.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index 1d994f1c98f..4acedc7bcbd 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -738,8 +738,8 @@ struct show_var_st init_vars[]= { {"have_geometry", (char*) &have_geometry, SHOW_HAVE}, {"have_innodb", (char*) &have_innodb, SHOW_HAVE}, {"have_isam", (char*) &have_isam, SHOW_HAVE}, - {"have_ndbcluster", (char*) &have_ndbcluster, SHOW_HAVE}, {"have_merge_engine", (char*) &have_merge_db, SHOW_HAVE}, + {"have_ndbcluster", (char*) &have_ndbcluster, SHOW_HAVE}, {"have_openssl", (char*) &have_openssl, SHOW_HAVE}, {"have_query_cache", (char*) &have_query_cache, SHOW_HAVE}, {"have_raid", (char*) &have_raid, SHOW_HAVE}, From dc4b2a4f1dc6ea2533e75f3eb8397c5c1ad9fbf8 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Mon, 14 Aug 2006 12:59:54 +0500 Subject: [PATCH 012/119] Make the heap_btree test repeatable. --- mysql-test/r/heap_btree.result | 14 +++++++------- mysql-test/t/heap_btree.test | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 91c3ec65a13..e6492e90b80 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -255,27 +255,27 @@ a 3 3 delete from t1 where a < 4; -select a from t1; +select a from t1 order by a; a insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); select a from t1 where a > 4; a delete from t1 where a > 4; -select a from t1; +select a from t1 order by a; a -3 -3 1 -3 -3 1 2 2 2 +3 +3 +3 +3 select a from t1 where a > 3; a delete from t1 where a >= 2; -select a from t1; +select a from t1 order by a; a 1 1 diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index f510f97fe9b..9aa820becd9 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -172,14 +172,14 @@ create table t1(a int not null, key using btree(a)) engine=heap; insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); select a from t1 where a > 2; delete from t1 where a < 4; -select a from t1; +select a from t1 order by a; insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); select a from t1 where a > 4; delete from t1 where a > 4; -select a from t1; +select a from t1 order by a; select a from t1 where a > 3; delete from t1 where a >= 2; -select a from t1; +select a from t1 order by a; drop table t1; --echo End of 4.1 tests From c746c08af9287e43b8517307e32be258e0c6f1f1 Mon Sep 17 00:00:00 2001 From: "kroki/tomash@moonlight.intranet" <> Date: Mon, 14 Aug 2006 20:01:19 +0400 Subject: [PATCH 013/119] BUG#9678: Client library hangs after network communication failure Socket timeouts in client library were used only on Windows. The solution is to use socket timeouts in client library on all systems were they are supported. No test case is provided because it is impossible to simulate network failure in current test suit. --- sql/net_serv.cc | 2 +- vio/viosocket.c | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 93fa7ac938c..08184537896 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -747,7 +747,7 @@ my_real_read(NET *net, ulong *complen) #endif /* EXTRA_DEBUG */ } #if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) - if (vio_should_retry(net->vio)) + if (vio_errno(net->vio) == SOCKET_EINTR) { DBUG_PRINT("warning",("Interrupted read. Retrying...")); continue; diff --git a/vio/viosocket.c b/vio/viosocket.c index 8d4c2387632..847e036d3b2 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -333,16 +333,30 @@ my_bool vio_poll_read(Vio *vio,uint timeout) } -void vio_timeout(Vio *vio __attribute__((unused)), - uint which __attribute__((unused)), - uint timeout __attribute__((unused))) +void vio_timeout(Vio *vio, uint which, uint timeout) { +/* TODO: some action should be taken if socket timeouts are not supported. */ +#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) + #ifdef __WIN__ - ulong wait_timeout= (ulong) timeout * 1000; - (void) setsockopt(vio->sd, SOL_SOCKET, - which ? SO_SNDTIMEO : SO_RCVTIMEO, (char*) &wait_timeout, - sizeof(wait_timeout)); -#endif /* __WIN__ */ + + /* Windows expects time in milliseconds as int. */ + int wait_timeout= (int) timeout * 1000; + +#else /* ! __WIN__ */ + + /* POSIX specifies time as struct timeval. */ + struct timeval wait_timeout; + wait_timeout.tv_sec= timeout; + wait_timeout.tv_usec= 0; + +#endif /* ! __WIN__ */ + + /* TODO: return value should be checked. */ + (void) setsockopt(vio->sd, SOL_SOCKET, which ? SO_SNDTIMEO : SO_RCVTIMEO, + (char*) &wait_timeout, sizeof(wait_timeout)); + +#endif /* defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) */ } From df5e20e75d18d705700480d777d6e0b2fed45d2c Mon Sep 17 00:00:00 2001 From: "tsmith@production.mysql.com" <> Date: Tue, 15 Aug 2006 01:42:57 +0200 Subject: [PATCH 014/119] Applied innodb-5.1-ss677, -ss680, -ss713, and -ss720 snapshots. All but ss677 are against the mysql-5.1 tree only. Fixes the following bugs: - Bug #19834: Using cursors when running in READ-COMMITTED can cause InnoDB to crash - Bug #20213: DBT2 testing cause mysqld to core using Innodb - Bug #20493: on partition tables, select and show command casue server crash - Bug #21113: Duplicate printout in SHOW INNODB STATUS - Bug #21313: rsql_..._recover_innodb_tmp_table is redundant and broken - Bug #21467: Manual URL wrong in InnoDB "page corrupted" error report --- mysql-test/r/innodb.result | 16 +--- mysql-test/t/innodb.test | 8 -- sql/ha_innodb.cc | 129 +++++++++++++------------ storage/innobase/Makefile.am | 3 +- storage/innobase/btr/btr0btr.c | 2 +- storage/innobase/buf/buf0buf.c | 5 +- storage/innobase/dict/dict0dict.c | 11 +-- storage/innobase/fil/fil0fil.c | 26 ++--- storage/innobase/fsp/fsp0fsp.c | 2 +- storage/innobase/ibuf/ibuf0ibuf.c | 17 +--- storage/innobase/include/btr0cur.ic | 5 +- storage/innobase/include/buf0buf.ic | 8 +- storage/innobase/include/ibuf0ibuf.ic | 11 +-- storage/innobase/log/log0log.c | 2 +- storage/innobase/log/log0recv.c | 4 +- storage/innobase/os/os0file.c | 12 +-- storage/innobase/row/row0mysql.c | 133 ++++---------------------- storage/innobase/row/row0sel.c | 2 +- storage/innobase/row/row0vers.c | 2 +- storage/innobase/srv/srv0start.c | 2 +- storage/innobase/ut/ut0dbg.c | 4 +- 21 files changed, 138 insertions(+), 266 deletions(-) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 3034fc2035e..e26e6fb271a 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1295,24 +1295,16 @@ insert into t2 (a) select b from t1; insert into t1 (a) select b from t2; insert into t2 (a) select b from t1; insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; select count(*) from t1; count(*) -29267 +623 explain select * from t1 where c between 1 and 2500; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range c c 5 NULL # Using where update t1 set c=a; explain select * from t1 where c between 1 and 2500; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL # Using where +1 SIMPLE t1 ALL c NULL NULL NULL # Using where drop table t1,t2; create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb; insert into t1 (id) values (null),(null),(null),(null),(null); @@ -1786,10 +1778,10 @@ Variable_name Value Innodb_rows_deleted 2070 show status like "Innodb_rows_inserted"; Variable_name Value -Innodb_rows_inserted 31727 +Innodb_rows_inserted 3083 show status like "Innodb_rows_updated"; Variable_name Value -Innodb_rows_updated 29530 +Innodb_rows_updated 886 show status like "Innodb_row_lock_waits"; Variable_name Value Innodb_row_lock_waits 0 diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index d00c5499ef9..1a2afad3b44 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -904,14 +904,6 @@ insert into t2 (a) select b from t1; insert into t1 (a) select b from t2; insert into t2 (a) select b from t1; insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; select count(*) from t1; --replace_column 9 # explain select * from t1 where c between 1 and 2500; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 00a92e05ffb..6b19ea228e5 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -208,6 +208,7 @@ static handler *innobase_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root); static const char innobase_hton_name[]= "InnoDB"; + handlerton innobase_hton; static handler *innobase_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) @@ -2364,8 +2365,7 @@ ha_innobase::open( "have forgotten\nto delete the corresponding " ".frm files of InnoDB tables, or you\n" "have moved .frm files to another database?\n" - "Look from section 15.1 of " - "http://www.innodb.com/ibman.html\n" + "See http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "how you can resolve the problem.\n", norm_name); free_share(share); @@ -2382,8 +2382,7 @@ ha_innobase::open( "Have you deleted the .ibd file from the " "database directory under\nthe MySQL datadir, " "or have you used DISCARD TABLESPACE?\n" - "Look from section 15.1 of " - "http://www.innodb.com/ibman.html\n" + "See http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "how you can resolve the problem.\n", norm_name); free_share(share); @@ -3664,7 +3663,7 @@ ha_innobase::update_row( DBUG_ENTER("ha_innobase::update_row"); - ut_ad(prebuilt->trx == + ut_a(prebuilt->trx == (trx_t*) current_thd->ha_data[innobase_hton.slot]); if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) @@ -3725,7 +3724,7 @@ ha_innobase::delete_row( DBUG_ENTER("ha_innobase::delete_row"); - ut_ad(prebuilt->trx == + ut_a(prebuilt->trx == (trx_t*) current_thd->ha_data[innobase_hton.slot]); if (last_query_id != user_thd->query_id) { @@ -3823,6 +3822,9 @@ ha_innobase::try_semi_consistent_read(bool yes) { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; + ut_a(prebuilt->trx == + (trx_t*) current_thd->ha_data[innobase_hton.slot]); + /* Row read type is set to semi consistent read if this was requested by the MySQL and either innodb_locks_unsafe_for_binlog option is used or this session is using READ COMMITTED isolation @@ -3987,7 +3989,7 @@ ha_innobase::index_read( DBUG_ENTER("index_read"); - ut_ad(prebuilt->trx == + ut_a(prebuilt->trx == (trx_t*) current_thd->ha_data[innobase_hton.slot]); statistic_increment(current_thd->status_var.ha_read_key_count, @@ -4102,7 +4104,7 @@ ha_innobase::change_active_index( DBUG_ENTER("change_active_index"); ut_ad(user_thd == current_thd); - ut_ad(prebuilt->trx == + ut_a(prebuilt->trx == (trx_t*) current_thd->ha_data[innobase_hton.slot]); active_index = keynr; @@ -4192,7 +4194,7 @@ ha_innobase::general_fetch( DBUG_ENTER("general_fetch"); - ut_ad(prebuilt->trx == + ut_a(prebuilt->trx == (trx_t*) current_thd->ha_data[innobase_hton.slot]); innodb_srv_conc_enter_innodb(prebuilt->trx); @@ -4428,7 +4430,7 @@ ha_innobase::rnd_pos( statistic_increment(current_thd->status_var.ha_read_rnd_count, &LOCK_status); - ut_ad(prebuilt->trx == + ut_a(prebuilt->trx == (trx_t*) current_thd->ha_data[innobase_hton.slot]); if (prebuilt->clust_index_was_generated) { @@ -4478,7 +4480,7 @@ ha_innobase::position( row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; uint len; - ut_ad(prebuilt->trx == + ut_a(prebuilt->trx == (trx_t*) current_thd->ha_data[innobase_hton.slot]); if (prebuilt->clust_index_was_generated) { @@ -5006,7 +5008,6 @@ ha_innobase::delete_all_rows(void) { row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt; int error; - trx_t* trx; THD* thd = current_thd; DBUG_ENTER("ha_innobase::delete_all_rows"); @@ -5019,13 +5020,13 @@ ha_innobase::delete_all_rows(void) } /* Get the transaction associated with the current thd, or create one - if not yet created */ + if not yet created, and update prebuilt->trx */ - trx = check_trx_exists(thd); + update_thd(thd); /* Truncate the table in InnoDB */ - error = row_truncate_table_for_mysql(prebuilt->table, trx); + error = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx); if (error == DB_ERROR) { /* Cannot truncate; resort to ha_innobase::delete_row() */ goto fallback; @@ -5308,6 +5309,9 @@ ha_innobase::records_in_range( DBUG_ENTER("records_in_range"); + ut_a(prebuilt->trx == + (trx_t*) current_thd->ha_data[innobase_hton.slot]); + prebuilt->trx->op_info = (char*)"estimating records in index range"; /* In case MySQL calls this in the middle of a SELECT query, release @@ -5604,13 +5608,14 @@ ha_innobase::info( for (i = 0; i < table->s->keys; i++) { if (index == NULL) { ut_print_timestamp(stderr); - sql_print_error("Table %s contains less " + sql_print_error("Table %s contains fewer " "indexes inside InnoDB than " "are defined in the MySQL " ".frm file. Have you mixed up " ".frm files from different " - "installations? See section " - "15.1 at http://www.innodb.com/ibman.html", + "installations? See " +"http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", + ib_table->name); break; } @@ -5619,17 +5624,11 @@ ha_innobase::info( if (j + 1 > index->n_uniq) { ut_print_timestamp(stderr); - sql_print_error("Index %s of %s has " - "%lu columns unique " - "inside InnoDB, but " - "MySQL is asking " - "statistics for %lu " - "columns. Have you " - "mixed up .frm files " - "from different " - "installations? See " - "section 15.1 at " - "http://www.innodb.com/ibman.html", + sql_print_error( +"Index %s of %s has %lu columns unique inside InnoDB, but MySQL is asking " +"statistics for %lu columns. Have you mixed up .frm files from different " +"installations? " +"See http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", index->name, ib_table->name, (unsigned long) @@ -6035,6 +6034,10 @@ ha_innobase::can_switch_engines(void) bool can_switch; DBUG_ENTER("ha_innobase::can_switch_engines"); + + ut_a(prebuilt->trx == + (trx_t*) current_thd->ha_data[innobase_hton.slot]); + prebuilt->trx->op_info = "determining if there are foreign key constraints"; row_mysql_lock_data_dictionary(prebuilt->trx); @@ -6172,14 +6175,6 @@ ha_innobase::start_stmt( innobase_release_stat_resources(trx); - if (trx->isolation_level <= TRX_ISO_READ_COMMITTED - && trx->global_read_view) { - /* At low transaction isolation levels we let - each consistent read set its own snapshot */ - - read_view_close_for_mysql(trx); - } - prebuilt->sql_stat_start = TRUE; prebuilt->hint_need_to_fetch_extra_cols = 0; prebuilt->read_just_key = 0; @@ -6438,7 +6433,7 @@ ha_innobase::transactional_table_lock( "table %s does not exist.\n" "Have you deleted the .ibd file from the database directory under\n" "the MySQL datadir?" -"Look from section 15.1 of http://www.innodb.com/ibman.html\n" +"See http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "how you can resolve the problem.\n", prebuilt->table->name); DBUG_RETURN(HA_ERR_CRASHED); @@ -6792,7 +6787,15 @@ ha_innobase::store_lock( TL_IGNORE */ { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; - trx_t* trx = prebuilt->trx; + trx_t* trx; + + /* Call update_thd() to update prebuilt->trx to point to the trx + object of thd! Failure to do this caused a serious memory + corruption bug in 5.1.11. */ + + update_thd(thd); + + trx = prebuilt->trx; /* NOTE: MySQL can call this function with lock 'type' TL_IGNORE! Be careful to ignore TL_IGNORE if we are going to do something with @@ -6909,28 +6912,28 @@ ha_innobase::store_lock( stored function call (MySQL does have thd->in_lock_tables TRUE there). */ - if ((lock_type >= TL_WRITE_CONCURRENT_INSERT - && lock_type <= TL_WRITE) - && !(thd->in_lock_tables - && thd->lex->sql_command == SQLCOM_LOCK_TABLES) - && !thd->tablespace_op - && thd->lex->sql_command != SQLCOM_TRUNCATE - && thd->lex->sql_command != SQLCOM_OPTIMIZE + if ((lock_type >= TL_WRITE_CONCURRENT_INSERT + && lock_type <= TL_WRITE) + && !(thd->in_lock_tables + && thd->lex->sql_command == SQLCOM_LOCK_TABLES) + && !thd->tablespace_op + && thd->lex->sql_command != SQLCOM_TRUNCATE + && thd->lex->sql_command != SQLCOM_OPTIMIZE + #ifdef __WIN__ - /* - for alter table on win32 for succesfull operation - completion it is used TL_WRITE(=10) lock instead of - TL_WRITE_ALLOW_READ(=6), however here in innodb handler - TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes - race condition when several clients do alter table - simultaneously (bug #17264). This fix avoids the problem. - */ - && thd->lex->sql_command != SQLCOM_ALTER_TABLE + /* For alter table on win32 for succesful operation + completion it is used TL_WRITE(=10) lock instead of + TL_WRITE_ALLOW_READ(=6), however here in innodb handler + TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes + race condition when several clients do alter table + simultaneously (bug #17264). This fix avoids the problem. */ + && thd->lex->sql_command != SQLCOM_ALTER_TABLE #endif - && thd->lex->sql_command != SQLCOM_CREATE_TABLE) { + + && thd->lex->sql_command != SQLCOM_CREATE_TABLE) { lock_type = TL_WRITE_ALLOW_WRITE; - } + } /* In queries of type INSERT INTO t1 SELECT ... FROM t2 ... MySQL would use the lock TL_READ_NO_INSERT on t2, and that @@ -6977,10 +6980,11 @@ ha_innobase::innobase_read_and_init_auto_inc( int error; ut_a(prebuilt); - ut_a(prebuilt->trx == - (trx_t*) current_thd->ha_data[innobase_hton.slot]); ut_a(prebuilt->table); + /* Prepare prebuilt->trx in the table handle */ + update_thd(current_thd); + if (prebuilt->trx->conc_state == TRX_NOT_STARTED) { trx_was_not_started = TRUE; } @@ -7115,6 +7119,9 @@ void ha_innobase::get_auto_increment( longlong nr; int error; + /* Prepare prebuilt->trx in the table handle */ + update_thd(current_thd); + error = innobase_read_and_init_auto_inc(&nr); if (error) { @@ -7143,6 +7150,8 @@ ha_innobase::reset_auto_increment(ulonglong value) row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; int error; + update_thd(current_thd); + error = row_lock_table_autoinc_for_mysql(prebuilt); if (error != DB_SUCCESS) { @@ -7183,7 +7192,7 @@ ha_innobase::cmp_ref( const mysql_byte* ref2) /* in: an (internal) primary key value in the MySQL key value format */ { - row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; + row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; enum_field_types mysql_type; Field* field; KEY_PART_INFO* key_part; diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am index 7884715d839..3f46f059fc0 100644 --- a/storage/innobase/Makefile.am +++ b/storage/innobase/Makefile.am @@ -77,8 +77,7 @@ EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr include/ut0byte.h include/ut0byte.ic include/ut0dbg.h include/ut0lst.h \ include/ut0mem.h include/ut0mem.ic include/ut0rnd.h include/ut0rnd.ic \ include/ut0sort.h include/ut0ut.h include/ut0ut.ic include/ut0vec.h include/ut0vec.ic include/ha_prototypes.h \ - include/ut0list.h include/ut0list.ic \ - include/ut0wqueue.h \ + include/ut0list.h include/ut0list.ic include/ut0wqueue.h \ CMakeLists.txt noinst_LIBRARIES = libinnobase.a diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c index ae3e722b513..57c6289e5f7 100644 --- a/storage/innobase/btr/btr0btr.c +++ b/storage/innobase/btr/btr0btr.c @@ -624,7 +624,7 @@ btr_page_get_father_for_rec( fputs( "InnoDB: You should dump + drop + reimport the table to fix the\n" "InnoDB: corruption. If the crash happens at the database startup, see\n" -"InnoDB: http://dev.mysql.com/doc/mysql/en/Forcing_recovery.html about\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html about\n" "InnoDB: forcing recovery. Then dump + drop + reimport.\n", stderr); } diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index 5f3e4a9ea50..ad23da4af93 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -323,7 +323,8 @@ buf_page_is_corrupted( "InnoDB: is in the future! Current system log sequence number %lu %lu.\n" "InnoDB: Your database may be corrupt or you may have copied the InnoDB\n" "InnoDB: tablespace but not the InnoDB log files. See\n" -"http://dev.mysql.com/doc/mysql/en/backing-up.html for more information.\n", +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" +"InnoDB: for more information.\n", (ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET), (ulong) ut_dulint_get_high( mach_read_from_8(read_buf + FIL_PAGE_LSN)), @@ -1923,7 +1924,7 @@ buf_page_io_complete( "InnoDB: the corrupt table. You can use CHECK\n" "InnoDB: TABLE to scan your table for corruption.\n" "InnoDB: See also " - "http://dev.mysql.com/doc/mysql/en/Forcing_recovery.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" "InnoDB: about forcing recovery.\n", stderr); if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) { diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index ce075138cb1..3470b19ed71 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -2215,8 +2215,8 @@ dict_foreign_error_report( if (fk->foreign_index) { fputs("The index in the foreign key in table is ", file); ut_print_name(file, NULL, FALSE, fk->foreign_index->name); - fputs( -"\nSee http://dev.mysql.com/doc/mysql/en/InnoDB_foreign_key_constraints.html\n" + fputs("\n" +"See http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html\n" "for correct foreign key definition.\n", file); } @@ -3119,7 +3119,7 @@ col_loop1: ut_print_name(ef, NULL, TRUE, name); fprintf(ef, " where the columns appear\n" "as the first columns. Constraint:\n%s\n" -"See http://dev.mysql.com/doc/mysql/en/InnoDB_foreign_key_constraints.html\n" +"See http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html\n" "for correct foreign key definition.\n", start_of_latest_foreign); mutex_exit(&dict_foreign_err_mutex); @@ -3387,7 +3387,7 @@ try_find_index: "Note that the internal storage type of ENUM and SET changed in\n" "tables created with >= InnoDB-4.1.12, and such columns in old tables\n" "cannot be referenced by such columns in new tables.\n" -"See http://dev.mysql.com/doc/mysql/en/InnoDB_foreign_key_constraints.html\n" +"See http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html\n" "for correct foreign key definition.\n", start_of_latest_foreign); mutex_exit(&dict_foreign_err_mutex); @@ -3941,8 +3941,7 @@ dict_update_statistics_low( fprintf(stderr, " InnoDB: cannot calculate statistics for table %s\n" "InnoDB: because the .ibd file is missing. For help, please refer to\n" -"InnoDB: " -"http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n", +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", table->name); return; diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c index b2935a119a5..722ffc12743 100644 --- a/storage/innobase/fil/fil0fil.c +++ b/storage/innobase/fil/fil0fil.c @@ -251,9 +251,6 @@ struct fil_system_struct { initialized. */ fil_system_t* fil_system = NULL; -/* The tablespace memory cache hash table size */ -#define FIL_SYSTEM_HASH_SIZE 50 /* TODO: make bigger! */ - /************************************************************************ NOTE: you must call fil_mutex_enter_and_prepare_for_io() first! @@ -1323,11 +1320,17 @@ fil_init( /*=====*/ ulint max_n_open) /* in: max number of open files */ { + ulint hash_size; + ut_a(fil_system == NULL); - /*printf("Initializing the tablespace cache with max %lu open files\n", - max_n_open); */ - fil_system = fil_system_create(FIL_SYSTEM_HASH_SIZE, max_n_open); + if (srv_file_per_table) { + hash_size = 50000; + } else { + hash_size = 5000; + } + + fil_system = fil_system_create(hash_size, max_n_open); } /*********************************************************************** @@ -2560,7 +2563,7 @@ fil_reset_too_high_lsns( ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Flush lsn in the tablespace file %lu to be imported\n" +" InnoDB: Flush lsn in the tablespace file %lu to be imported\n" "InnoDB: is %lu %lu, which exceeds current system lsn %lu %lu.\n" "InnoDB: We reset the lsn's in the file ", (ulong) space_id, @@ -2685,8 +2688,7 @@ fil_open_single_table_tablespace( "InnoDB: It is also possible that this is a temporary table #sql...,\n" "InnoDB: and MySQL removed the .ibd file for this.\n" "InnoDB: Please refer to\n" -"InnoDB:" -" http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "InnoDB: for how to resolve the issue.\n", stderr); mem_free(filepath); @@ -2725,8 +2727,7 @@ fil_open_single_table_tablespace( "InnoDB: Have you moved InnoDB .ibd files around without using the\n" "InnoDB: commands DISCARD TABLESPACE and IMPORT TABLESPACE?\n" "InnoDB: Please refer to\n" -"InnoDB:" -" http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "InnoDB: for how to resolve the issue.\n", (ulong) space_id, (ulong) id); ret = FALSE; @@ -3373,8 +3374,7 @@ fil_space_for_table_exists_in_mem( error_exit: fputs( "InnoDB: Please refer to\n" -"InnoDB:" -" http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "InnoDB: for how to resolve the issue.\n", stderr); mem_free(path); diff --git a/storage/innobase/fsp/fsp0fsp.c b/storage/innobase/fsp/fsp0fsp.c index 43c7ba005cb..9b0406a1c26 100644 --- a/storage/innobase/fsp/fsp0fsp.c +++ b/storage/innobase/fsp/fsp0fsp.c @@ -2988,7 +2988,7 @@ fseg_free_page_low( crash: fputs( "InnoDB: Please refer to\n" -"InnoDB: http://dev.mysql.com/doc/mysql/en/Forcing_recovery.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" "InnoDB: about forcing recovery.\n", stderr); ut_error; } diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c index f1ae43033bd..4e38e1f0353 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.c +++ b/storage/innobase/ibuf/ibuf0ibuf.c @@ -373,7 +373,6 @@ ibuf_init_at_db_start(void) ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE / IBUF_POOL_SIZE_PER_MAX_SIZE; - ibuf->meter = IBUF_THRESHOLD + 1; UT_LIST_INIT(ibuf->data_list); @@ -3517,21 +3516,9 @@ ibuf_print( data = UT_LIST_GET_FIRST(ibuf->data_list); while (data) { - fprintf(file, - "Ibuf for space %lu: size %lu, free list len %lu, seg size %lu,", - (ulong) data->space, (ulong) data->size, - (ulong) data->free_list_len, - (ulong) data->seg_size); - - if (data->empty) { - fputs(" is empty\n", file); - } else { - fputs(" is not empty\n", file); - } fprintf(file, - "Ibuf for space %lu: size %lu, free list len %lu, seg size %lu,\n" - "%lu inserts, %lu merged recs, %lu merges\n", - (ulong) data->space, + "Ibuf: size %lu, free list len %lu, seg size %lu,\n" + "%lu inserts, %lu merged recs, %lu merges\n", (ulong) data->size, (ulong) data->free_list_len, (ulong) data->seg_size, diff --git a/storage/innobase/include/btr0cur.ic b/storage/innobase/include/btr0cur.ic index a199c3d4d32..7fbdf6035b0 100644 --- a/storage/innobase/include/btr0cur.ic +++ b/storage/innobase/include/btr0cur.ic @@ -52,10 +52,7 @@ btr_cur_get_page( /* out: pointer to page */ btr_cur_t* cursor) /* in: tree cursor */ { - page_t* page = buf_frame_align(page_cur_get_rec(&(cursor->page_cur))); - ut_ad(!!page_is_comp(page) - == dict_table_is_comp(cursor->index->table)); - return(page); + return(buf_frame_align(page_cur_get_rec(&(cursor->page_cur)))); } /************************************************************* diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index 15187c03636..3c7a64cbcb0 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -216,8 +216,8 @@ buf_block_align( "InnoDB: Error: trying to access a stray pointer %p\n" "InnoDB: buf pool start is at %p, end at %p\n" "InnoDB: Probable reason is database corruption or memory\n" -"InnoDB: corruption. If this happens in an InnoDB database recovery,\n" -"InnoDB: you can look from section 6.1 at http://www.innodb.com/ibman.html\n" +"InnoDB: corruption. If this happens in an InnoDB database recovery, see\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" "InnoDB: how to force recovery.\n", ptr, frame_zero, buf_pool->high_end); @@ -252,8 +252,8 @@ buf_frame_align( "InnoDB: Error: trying to access a stray pointer %p\n" "InnoDB: buf pool start is at %p, end at %p\n" "InnoDB: Probable reason is database corruption or memory\n" -"InnoDB: corruption. If this happens in an InnoDB database recovery,\n" -"InnoDB: you can look from section 6.1 at http://www.innodb.com/ibman.html\n" +"InnoDB: corruption. If this happens in an InnoDB database recovery, see\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" "InnoDB: how to force recovery.\n", ptr, buf_pool->frame_zero, buf_pool->high_end); diff --git a/storage/innobase/include/ibuf0ibuf.ic b/storage/innobase/include/ibuf0ibuf.ic index 4eea8f41e32..7e75fccc160 100644 --- a/storage/innobase/include/ibuf0ibuf.ic +++ b/storage/innobase/include/ibuf0ibuf.ic @@ -39,19 +39,11 @@ struct ibuf_data_struct{ ulint n_merged_recs;/* number of records merged */ }; -/* If the ibuf meter exceeds this value, then the suitable inserts are made to -the insert buffer instead of directly to the disk page */ -#define IBUF_THRESHOLD 50 - struct ibuf_struct{ ulint size; /* current size of the ibuf index trees in pages */ ulint max_size; /* recommended maximum size in pages for the ibuf index tree */ - ulint meter; /* heuristic meter which measures - desirability of doing inserts to the - insert buffer instead of directly to - the disk page */ UT_LIST_BASE_NODE_T(ibuf_data_t) data_list; /* list of ibuf data structs for each tablespace */ @@ -88,8 +80,7 @@ ibuf_should_try( decide */ { if (!(index->type & DICT_CLUSTERED) - && (ignore_sec_unique || !(index->type & DICT_UNIQUE)) - && ibuf->meter > IBUF_THRESHOLD) { + && (ignore_sec_unique || !(index->type & DICT_UNIQUE))) { ibuf_flush_count++; diff --git a/storage/innobase/log/log0log.c b/storage/innobase/log/log0log.c index db6b8fabf6f..2351c6055de 100644 --- a/storage/innobase/log/log0log.c +++ b/storage/innobase/log/log0log.c @@ -720,7 +720,7 @@ failure: "InnoDB: To get mysqld to start up, set innodb_thread_concurrency in my.cnf\n" "InnoDB: to a lower value, for example, to 8. After an ERROR-FREE shutdown\n" "InnoDB: of mysqld you can adjust the size of ib_logfiles, as explained in\n" -"InnoDB: http://dev.mysql.com/doc/mysql/en/Adding_and_removing.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/adding-and-removing.html\n" "InnoDB: Cannot continue operation. Calling exit(1).\n", (ulong)srv_thread_concurrency); diff --git a/storage/innobase/log/log0recv.c b/storage/innobase/log/log0recv.c index 63a90f05212..8150dba165c 100644 --- a/storage/innobase/log/log0recv.c +++ b/storage/innobase/log/log0recv.c @@ -542,7 +542,7 @@ recv_find_max_checkpoint( "InnoDB: the problem may be that during an earlier attempt you managed\n" "InnoDB: to create the InnoDB data files, but log file creation failed.\n" "InnoDB: If that is the case, please refer to\n" -"InnoDB: http://dev.mysql.com/doc/mysql/en/Error_creating_InnoDB.html\n"); +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/error-creating-innodb.html\n"); return(DB_ERROR); } @@ -1962,7 +1962,7 @@ recv_report_corrupt_log( "InnoDB: far enough in recovery! Please run CHECK TABLE\n" "InnoDB: on your InnoDB tables to check that they are ok!\n" "InnoDB: If mysqld crashes after this recovery, look at\n" - "InnoDB: http://dev.mysql.com/doc/mysql/en/Forcing_recovery.html\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" "InnoDB: about forcing recovery.\n", stderr); fflush(stderr); diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 74905ce06dd..6cd44a5ad08 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -248,7 +248,7 @@ os_file_get_last_error( fprintf(stderr, "InnoDB: Some operating system error numbers are described at\n" "InnoDB: " - "http://dev.mysql.com/doc/mysql/en/Operating_System_error_codes.html\n"); + "http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n"); } } @@ -295,7 +295,7 @@ os_file_get_last_error( fprintf(stderr, "InnoDB: Some operating system error numbers are described at\n" "InnoDB: " - "http://dev.mysql.com/doc/mysql/en/Operating_System_error_codes.html\n"); + "http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n"); } } @@ -688,7 +688,7 @@ next_file: /* TODO: test Windows symlinks */ /* TODO: MySQL has apparently its own symlink implementation in Windows, dbname.sym can redirect a database directory: -http://www.mysql.com/doc/en/Windows_symbolic_links.html */ +http://dev.mysql.com/doc/refman/5.1/en/windows-symbolic-links.html */ info->type = OS_FILE_TYPE_LINK; } else if (lpFindFileData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { @@ -2343,7 +2343,7 @@ retry: "InnoDB: offset %lu %lu. Operating system error number %lu.\n" "InnoDB: Some operating system error numbers are described at\n" "InnoDB: " -"http://dev.mysql.com/doc/mysql/en/Operating_System_error_codes.html\n", +"http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n", name, (ulong) offset_high, (ulong) offset, (ulong) GetLastError()); @@ -2408,7 +2408,7 @@ retry: fprintf(stderr, "InnoDB: Some operating system error numbers are described at\n" "InnoDB: " -"http://dev.mysql.com/doc/mysql/en/Operating_System_error_codes.html\n"); +"http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n"); os_has_said_disk_full = TRUE; } @@ -2444,7 +2444,7 @@ retry: fprintf(stderr, "InnoDB: Some operating system error numbers are described at\n" "InnoDB: " -"http://dev.mysql.com/doc/mysql/en/Operating_System_error_codes.html\n"); +"http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n"); os_has_said_disk_full = TRUE; } diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 5f4a882f4a8..f2d501e0ba7 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -54,27 +54,6 @@ static const char S_innodb_tablespace_monitor[] = "innodb_tablespace_monitor"; static const char S_innodb_table_monitor[] = "innodb_table_monitor"; static const char S_innodb_mem_validate[] = "innodb_mem_validate"; -/* Name suffix for recovered orphaned temporary tables */ -static const char S_recover_innodb_tmp_table[] = "_recover_innodb_tmp_table"; -/*********************************************************************** -Determine if the given name ends in the suffix reserved for recovered -orphaned temporary tables. */ -static -ibool -row_mysql_is_recovered_tmp_table( -/*=============================*/ - /* out: TRUE if table name ends in - the reserved suffix */ - const char* name) -{ - ulint namelen = strlen(name) + 1; - return(namelen >= sizeof S_recover_innodb_tmp_table - && !memcmp(name + namelen - - sizeof S_recover_innodb_tmp_table, - S_recover_innodb_tmp_table, - sizeof S_recover_innodb_tmp_table)); -} - /*********************************************************************** Determine if the given name is a name reserved for MySQL system tables. */ static @@ -550,7 +529,7 @@ handle_new_error: "InnoDB: tables and recreate the whole InnoDB tablespace.\n" "InnoDB: If the mysqld server crashes after the startup or when\n" "InnoDB: you dump the tables, look at\n" - "InnoDB: http://dev.mysql.com/doc/mysql/en/Forcing_recovery.html" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html" " for help.\n", stderr); } else { @@ -1083,7 +1062,7 @@ row_insert_for_mysql( "InnoDB: Have you deleted the .ibd file from the database directory under\n" "InnoDB: the MySQL datadir, or have you used DISCARD TABLESPACE?\n" "InnoDB: Look from\n" -"http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "InnoDB: how you can resolve the problem.\n", prebuilt->table->name); return(DB_ERROR); @@ -1319,7 +1298,7 @@ row_update_for_mysql( "InnoDB: Have you deleted the .ibd file from the database directory under\n" "InnoDB: the MySQL datadir, or have you used DISCARD TABLESPACE?\n" "InnoDB: Look from\n" -"http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "InnoDB: how you can resolve the problem.\n", prebuilt->table->name); return(DB_ERROR); @@ -1659,48 +1638,6 @@ row_get_mysql_key_number_for_index( return(i); } -/************************************************************************* -Recovers an orphaned tmp table inside InnoDB by renaming it. In the table -name #sql becomes rsql, and "_recover_innodb_tmp_table" is catenated to -the end of name. table->name should be of the form -"dbname/rsql..._recover_innodb_tmp_table". This renames a table whose -name is "#sql..." */ -static -int -row_mysql_recover_tmp_table( -/*========================*/ - /* out: error code or DB_SUCCESS */ - dict_table_t* table, /* in: table definition */ - trx_t* trx) /* in: transaction handle */ -{ - const char* ptr = strstr(table->name, "/rsql"); - - if (!ptr) { - /* table name does not begin with "/rsql" */ - dict_mem_table_free(table); - trx_commit_for_mysql(trx); - - return(DB_ERROR); - } - else { - int status; - int namelen = (int) strlen(table->name); - char* old_name = mem_strdupl(table->name, namelen); - /* replace "rsql" with "#sql" */ - old_name[ptr - table->name + 1] = '#'; - /* remove "_recover_innodb_tmp_table" suffix */ - ut_ad(namelen > (int) sizeof S_recover_innodb_tmp_table); - ut_ad(!strcmp(old_name + namelen + 1 - - sizeof S_recover_innodb_tmp_table, - S_recover_innodb_tmp_table)); - old_name[namelen + 1 - sizeof S_recover_innodb_tmp_table] = 0; - status = row_rename_table_for_mysql(old_name, - table->name, trx); - mem_free(old_name); - return(status); - } -} - /************************************************************************* Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL. */ @@ -1845,18 +1782,6 @@ row_create_table_for_mysql( trx_start_if_not_started(trx); - if (row_mysql_is_recovered_tmp_table(table->name)) { - - /* MySQL prevents accessing of tables whose name begins - with #sql, that is temporary tables. If mysqld crashes in - the middle of an ALTER TABLE, we may get an orphaned - #sql-table in the tablespace. We have here a special - mechanism to recover such tables by renaming them to - rsql... */ - - return(row_mysql_recover_tmp_table(table, trx)); - } - /* The table name is prefixed with the database name and a '/'. Certain table names starting with 'innodb_' have their special meaning regardless of the database name. Thus, we need to @@ -1968,8 +1893,8 @@ row_create_table_for_mysql( "InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n" "InnoDB: succeed.\n" "InnoDB: You can look for further help from\n" - "InnoDB: http://dev.mysql.com/doc/mysql/en/" - "InnoDB_troubleshooting_datadict.html\n", stderr); +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", + stderr); } /* We may also get err == DB_ERROR if the .ibd file for the @@ -2063,11 +1988,6 @@ row_create_index_for_mysql( } } - if (row_mysql_is_recovered_tmp_table(index->table_name)) { - - return(DB_SUCCESS); - } - heap = mem_heap_create(512); trx->dict_operation = TRUE; @@ -2142,11 +2062,6 @@ row_table_add_foreign_constraints( trx_start_if_not_started(trx); - if (row_mysql_is_recovered_tmp_table(name)) { - - return(DB_SUCCESS); - } - trx->dict_operation = TRUE; err = dict_create_foreign_constraints(trx, sql_string, name, @@ -3054,8 +2969,8 @@ row_drop_table_for_mysql( "InnoDB: Have you copied the .frm file of the table to the\n" "InnoDB: MySQL database directory from another database?\n" "InnoDB: You can look for further help from\n" - "InnoDB: http://dev.mysql.com/doc/mysql/en/" - "InnoDB_troubleshooting_datadict.html\n", stderr); +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", + stderr); goto funct_exit; } @@ -3495,7 +3410,6 @@ row_rename_table_for_mysql( mem_heap_t* heap = NULL; const char** constraints_to_drop = NULL; ulint n_constraints_to_drop = 0; - ibool recovering_temp_table = FALSE; ibool old_is_tmp, new_is_tmp; pars_info_t* info = NULL; @@ -3533,15 +3447,10 @@ row_rename_table_for_mysql( old_is_tmp = row_is_mysql_tmp_table_name(old_name); new_is_tmp = row_is_mysql_tmp_table_name(new_name); - if (row_mysql_is_recovered_tmp_table(new_name)) { + /* Serialize data dictionary operations with dictionary mutex: + no deadlocks can occur then in these operations */ - recovering_temp_table = TRUE; - } else { - /* Serialize data dictionary operations with dictionary mutex: - no deadlocks can occur then in these operations */ - - row_mysql_lock_data_dictionary(trx); - } + row_mysql_lock_data_dictionary(trx); table = dict_table_get_low(old_name); @@ -3556,8 +3465,8 @@ row_rename_table_for_mysql( "InnoDB: Have you copied the .frm file of the table to the\n" "InnoDB: MySQL database directory from another database?\n" "InnoDB: You can look for further help from\n" - "InnoDB: http://dev.mysql.com/doc/mysql/en/" - "InnoDB_troubleshooting_datadict.html\n", stderr); +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", + stderr); goto funct_exit; } @@ -3570,8 +3479,8 @@ row_rename_table_for_mysql( fputs( " does not have an .ibd file in the database directory.\n" "InnoDB: You can look for further help from\n" - "InnoDB: http://dev.mysql.com/doc/mysql/en/" - "InnoDB_troubleshooting_datadict.html\n", stderr); +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", + stderr); goto funct_exit; } @@ -3719,8 +3628,7 @@ end: fputs(" to it.\n" "InnoDB: Have you deleted the .frm file and not used DROP TABLE?\n" "InnoDB: You can look for further help from\n" - "InnoDB: http://dev.mysql.com/doc/mysql/en/" - "InnoDB_troubleshooting_datadict.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "InnoDB: If table ", stderr); ut_print_name(stderr, trx, TRUE, new_name); fputs( @@ -3748,8 +3656,8 @@ end: trx_general_rollback_for_mysql(trx, FALSE, NULL); trx->error_state = DB_SUCCESS; ut_print_timestamp(stderr); - fputs(" InnoDB: Error in table rename, cannot rename ", - stderr); + fputs( +" InnoDB: Error in table rename, cannot rename ", stderr); ut_print_name(stderr, trx, TRUE, old_name); fputs(" to ", stderr); ut_print_name(stderr, trx, TRUE, new_name); @@ -3797,10 +3705,7 @@ end: funct_exit: trx_commit_for_mysql(trx); - - if (!recovering_temp_table) { - row_mysql_unlock_data_dictionary(trx); - } + row_mysql_unlock_data_dictionary(trx); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -3968,7 +3873,7 @@ row_check_table_for_mysql( "InnoDB: Have you deleted the .ibd file from the database directory under\n" "InnoDB: the MySQL datadir, or have you used DISCARD TABLESPACE?\n" "InnoDB: Look from\n" -"http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "InnoDB: how you can resolve the problem.\n", prebuilt->table->name); return(DB_ERROR); diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index f79bda5d6d8..251ee95886f 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -3245,7 +3245,7 @@ row_search_for_mysql( "InnoDB: Have you deleted the .ibd file from the database directory under\n" "InnoDB: the MySQL datadir, or have you used DISCARD TABLESPACE?\n" "InnoDB: Look from\n" -"http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" "InnoDB: how you can resolve the problem.\n", prebuilt->table->name); diff --git a/storage/innobase/row/row0vers.c b/storage/innobase/row/row0vers.c index ab3b6385146..07b75a34347 100644 --- a/storage/innobase/row/row0vers.c +++ b/storage/innobase/row/row0vers.c @@ -553,7 +553,7 @@ row_vers_build_for_semi_consistent_read( mem_heap_t* heap = NULL; byte* buf; ulint err; - dulint rec_trx_id; + dulint rec_trx_id = ut_dulint_create(0, 0); ut_ad(index->type & DICT_CLUSTERED); ut_ad(mtr_memo_contains(mtr, buf_block_align(rec), MTR_MEMO_PAGE_X_FIX) diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c index 205b54004ce..8346203f3f7 100644 --- a/storage/innobase/srv/srv0start.c +++ b/storage/innobase/srv/srv0start.c @@ -1691,7 +1691,7 @@ NetWare. */ "InnoDB: You have now successfully upgraded to the multiple tablespaces\n" "InnoDB: format. You should NOT DOWNGRADE to an earlier version of\n" "InnoDB: InnoDB! But if you absolutely need to downgrade, see\n" -"InnoDB: http://dev.mysql.com/doc/mysql/en/Multiple_tablespaces.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/multiple-tablespaces.html\n" "InnoDB: for instructions.\n"); } diff --git a/storage/innobase/ut/ut0dbg.c b/storage/innobase/ut/ut0dbg.c index a9391cd3adc..87960b98556 100644 --- a/storage/innobase/ut/ut0dbg.c +++ b/storage/innobase/ut/ut0dbg.c @@ -42,7 +42,7 @@ ut_dbg_assertion_failed( { ut_print_timestamp(stderr); fprintf(stderr, - "InnoDB: Assertion failure in thread %lu" + " InnoDB: Assertion failure in thread %lu" " in file %s line %lu\n", os_thread_pf(os_thread_get_curr_id()), file, line); if (expr) { @@ -56,7 +56,7 @@ ut_dbg_assertion_failed( "InnoDB: If you get repeated assertion failures or crashes, even\n" "InnoDB: immediately after the mysqld startup, there may be\n" "InnoDB: corruption in the InnoDB tablespace. Please refer to\n" -"InnoDB: http://dev.mysql.com/doc/mysql/en/Forcing_recovery.html\n" +"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" "InnoDB: about forcing recovery.\n", stderr); #if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT) ut_dbg_stop_threads = TRUE; From 6660f98b6422fa949036bded702fd1a9da80352e Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Tue, 15 Aug 2006 15:24:07 +0500 Subject: [PATCH 015/119] Fix for bug #20695: Charset introducer overrides charset definition for column. - if there are two character set definitions in the column declaration, we replace the first one with the second one as we store both in the LEX->charset slot. Add a separate slot to the LEX structure to store underscore charset. - convert default values to the column charset of STRING, VARSTRING fields if necessary as well. --- mysql-test/r/ctype_recoding.result | 11 ++++++ mysql-test/t/ctype_recoding.test | 12 ++++++ sql/sql_lex.cc | 5 ++- sql/sql_lex.h | 2 +- sql/sql_table.cc | 63 ++++++++++++++++-------------- sql/sql_yacc.yy | 4 +- 6 files changed, 63 insertions(+), 34 deletions(-) diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index 0b5c6f8974c..2daa2d5ba0b 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -247,3 +247,14 @@ lpad(c1,3,' select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1; rpad(c1,3,'ö') rpad('ö',3,c1) ßöö ößß +drop table t1; +set names koi8r; +create table t1(a char character set cp1251 default _koi8r 0xFF); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) character set cp1251 default 'ÿ' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1(a char character set latin1 default _cp1251 0xFF); +ERROR 42000: Invalid default value for 'a' diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index 5648cea7fd3..ddaaa7b9e4f 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -186,5 +186,17 @@ select rpad(c1,3,' # TODO #select case c1 when 'ß' then 'ß' when 'ö' then 'ö' else 'c' end from t1; #select export_set(5,c1,'ö'), export_set(5,'ö',c1) from t1; +drop table t1; + +# +# Bug 20695: problem with field default value's character set +# + +set names koi8r; +create table t1(a char character set cp1251 default _koi8r 0xFF); +show create table t1; +drop table t1; +--error 1067 +create table t1(a char character set latin1 default _cp1251 0xFF); # End of 4.1 tests diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index fb9a765f12c..dfe406c351e 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -643,8 +643,9 @@ int yylex(void *arg, void *yythd) */ if ((yylval->lex_str.str[0]=='_') && - (lex->charset=get_charset_by_csname(yylval->lex_str.str+1, - MY_CS_PRIMARY,MYF(0)))) + (lex->underscore_charset= + get_charset_by_csname(yylval->lex_str.str + 1, + MY_CS_PRIMARY,MYF(0)))) return(UNDERSCORE_CHARSET); return(result_state); // IDENT or IDENT_QUOTED diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 35f02db6cf9..12f89202e2d 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -613,7 +613,7 @@ typedef struct st_lex LEX_USER *grant_user; gptr yacc_yyss,yacc_yyvs; THD *thd; - CHARSET_INFO *charset; + CHARSET_INFO *charset, *underscore_charset; List col_list; List ref_list; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 631d2d89bbb..a5cb0d45664 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -516,6 +516,40 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(-1); } + /* + Convert the default value character + set into the column character set if necessary. + */ + if (sql_field->def && + savecs != sql_field->def->collation.collation && + (sql_field->sql_type == FIELD_TYPE_VAR_STRING || + sql_field->sql_type == FIELD_TYPE_STRING || + sql_field->sql_type == FIELD_TYPE_SET || + sql_field->sql_type == FIELD_TYPE_ENUM)) + { + Item_arena backup_arena; + bool need_to_change_arena= + !thd->current_arena->is_conventional_execution(); + if (need_to_change_arena) + { + /* Assert that we don't do that at every PS execute */ + DBUG_ASSERT(thd->current_arena->is_first_stmt_execute()); + thd->set_n_backup_item_arena(thd->current_arena, &backup_arena); + } + + sql_field->def= sql_field->def->safe_charset_converter(savecs); + + if (need_to_change_arena) + thd->restore_backup_item_arena(thd->current_arena, &backup_arena); + + if (sql_field->def == NULL) + { + /* Could not convert */ + my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name); + DBUG_RETURN(-1); + } + } + if (sql_field->sql_type == FIELD_TYPE_SET || sql_field->sql_type == FIELD_TYPE_ENUM) { @@ -580,35 +614,6 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->interval_list.empty(); // Don't need interval_list anymore } - /* - Convert the default value from client character - set into the column character set if necessary. - */ - if (sql_field->def && cs != sql_field->def->collation.collation) - { - Item_arena backup_arena; - bool need_to_change_arena= - !thd->current_arena->is_conventional_execution(); - if (need_to_change_arena) - { - /* Asser that we don't do that at every PS execute */ - DBUG_ASSERT(thd->current_arena->is_first_stmt_execute()); - thd->set_n_backup_item_arena(thd->current_arena, &backup_arena); - } - - sql_field->def= sql_field->def->safe_charset_converter(cs); - - if (need_to_change_arena) - thd->restore_backup_item_arena(thd->current_arena, &backup_arena); - - if (sql_field->def == NULL) - { - /* Could not convert */ - my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name); - DBUG_RETURN(-1); - } - } - if (sql_field->sql_type == FIELD_TYPE_SET) { if (sql_field->def != NULL) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 162b4183c84..efd83549312 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4896,7 +4896,7 @@ text_literal: | NCHAR_STRING { $$= new Item_string($1.str,$1.length,national_charset_info); } | UNDERSCORE_CHARSET TEXT_STRING - { $$ = new Item_string($2.str,$2.length,Lex->charset); } + { $$ = new Item_string($2.str,$2.length,Lex->underscore_charset); } | text_literal TEXT_STRING_literal { ((Item_string*) $1)->append($2.str,$2.length); } ; @@ -4963,7 +4963,7 @@ literal: (String*) 0; $$= new Item_string(str ? str->ptr() : "", str ? str->length() : 0, - Lex->charset); + Lex->underscore_charset); } | DATE_SYM text_literal { $$ = $2; } | TIME_SYM text_literal { $$ = $2; } From 53bb6a47cd67fb988c5cf6f1fff48b5a5023bcd1 Mon Sep 17 00:00:00 2001 From: "cmiller@maint1.mysql.com" <> Date: Tue, 15 Aug 2006 18:41:21 +0200 Subject: [PATCH 016/119] Bug #20908: Crash if select @@"" Zero-length variables caused failures when using the length to look up the name in a hash. Instead, signal that no zero-length name can ever be found and that to encounter one is a syntax error. --- mysql-test/r/variables.result | 6 ++++++ mysql-test/t/variables.test | 11 +++++++++++ sql/gen_lex_hash.cc | 13 +++++++++++-- sql/sql_lex.cc | 2 ++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index a0e516d2397..cd834a789bd 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -689,6 +689,12 @@ select @@log_queries_not_using_indexes; show variables like 'log_queries_not_using_indexes'; Variable_name Value log_queries_not_using_indexes OFF +select @@""; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '""' at line 1 +select @@&; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '&' at line 1 +select @@@; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@' at line 1 End of 5.0 tests set global binlog_cache_size =@my_binlog_cache_size; set global connect_timeout =@my_connect_timeout; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 68efcafd1e0..d855b4d8266 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -585,6 +585,16 @@ show variables like 'ssl%'; select @@log_queries_not_using_indexes; show variables like 'log_queries_not_using_indexes'; +# +# Bug#20908: Crash if select @@"" +# +--error ER_PARSE_ERROR +select @@""; +--error ER_PARSE_ERROR +select @@&; +--error ER_PARSE_ERROR +select @@@; + --echo End of 5.0 tests # This is at the very after the versioned tests, since it involves doing @@ -620,3 +630,4 @@ set global server_id =@my_server_id; set global slow_launch_time =@my_slow_launch_time; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; + diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 7e0b178f7af..e59986092e4 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -442,13 +442,16 @@ int main(int argc,char **argv) if (get_options(argc,(char **) argv)) exit(1); + /* Broken up to indicate that it's not advice to you, gentle reader. */ + printf("/*\n\n Do " "not " "edit " "this " "file " "directly!\n\n*/\n"); + printf("/* Copyright (C) 2001-2004 MySQL AB\n\ This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\ and you are welcome to modify and redistribute it under the GPL license\n\ \n*/\n\n"); - printf("/* This code is generated by gen_lex_hash.cc that seeks for\ - a perfect\nhash function */\n\n"); + printf("/* Do " "not " "edit " "this " "file! This is generated by " + "gen_lex_hash.cc\nthat seeks for a perfect hash function */\n\n"); printf("#include \"lex.h\"\n\n"); calc_length(); @@ -468,6 +471,12 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\ {\n\ register uchar *hash_map;\n\ register const char *cur_str= s;\n\ +\n\ + if (len == 0) {\n\ + DBUG_PRINT(\"warning\", (\"get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.\"));\ + return(NULL);\n\ + }\ +\n\ if (function){\n\ if (len>sql_functions_max_len) return 0;\n\ hash_map= sql_functions_map;\n\ diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 7d4dca15608..479db7b5b99 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1042,6 +1042,8 @@ int MYSQLlex(void *arg, void *yythd) if (c == '.') lex->next_state=MY_LEX_IDENT_SEP; length= (uint) (lex->ptr - lex->tok_start)-1; + if (length == 0) + return(ABORT_SYM); // Names must be nonempty. if ((tokval= find_keyword(lex,length,0))) { yyUnget(); // Put back 'c' From 0c41fd3abbe6e479d5e1e92bdb7f5bcb649f682a Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Wed, 16 Aug 2006 10:30:22 +0200 Subject: [PATCH 017/119] Move initializations of environment variables that are constant during the whole testrun to 'environment_setup' Split out functions that detects if we need master or slave restarts --- mysql-test/lib/mtr_process.pl | 5 +- mysql-test/mysql-test-run.pl | 531 ++++++++++++++++++++-------------- 2 files changed, 311 insertions(+), 225 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index e47b0e4287c..a71a1e7d2e4 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -633,7 +633,7 @@ sub mtr_check_stop_servers ($) { } else { - mtr_verbose("All ports where free, continuing"); + mtr_verbose("All ports were free, continuing"); } } } @@ -896,6 +896,7 @@ sub check_expected_crash_and_restart($) sub mtr_record_dead_children () { + my $process_died= 0; my $ret_pid; # Wait without blockinng to see if any processes had died @@ -904,7 +905,9 @@ sub mtr_record_dead_children () { { mtr_warning("mtr_record_dead_children: $ret_pid"); mark_process_dead($ret_pid); + $process_died= 1; } + return $process_died; } sub start_reap_all { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 5d6f39bc882..be1c72e9582 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -357,7 +357,7 @@ sub initialize_servers (); sub mysql_install_db (); sub install_db ($$); sub run_testcase ($); -sub run_testcase_stop_servers ($); +sub run_testcase_stop_servers ($$$); sub run_testcase_start_servers ($); sub report_failure_and_restart ($); sub do_before_start_master ($$); @@ -1296,9 +1296,19 @@ sub executable_setup () { } +sub generate_cmdline_mysqldump ($) { + my($mysqld) = @_; + return + "$exe_mysqldump --no-defaults -uroot " . + "--port=$mysqld->{'port'} " . + "--socket=$mysqld->{'path_sock'} --password="; +} + + ############################################################################## # -# Set environment to be used by childs of this process +# Set environment to be used by childs of this process for +# things that are constant duting the whole lifetime of mysql-test-run.pl # ############################################################################## @@ -1323,18 +1333,11 @@ sub environment_setup () { ($ENV{'DYLD_LIBRARY_PATH'} ? ":$ENV{'DYLD_LIBRARY_PATH'}" : ""); } - # -------------------------------------------------------------------------- - # Add the path where mysqld will find udf_example.so - # -------------------------------------------------------------------------- - $ENV{'LD_LIBRARY_PATH'}= - ($lib_udf_example ? dirname($lib_udf_example) : "") . - ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : ""); - - # -------------------------------------------------------------------------- # Also command lines in .opt files may contain env vars # -------------------------------------------------------------------------- + $ENV{'CHARSETSDIR'}= $path_charsetsdir; $ENV{'UMASK'}= "0660"; # The octal *string* $ENV{'UMASK_DIR'}= "0770"; # The octal *string* $ENV{'LC_COLLATE'}= "C"; @@ -1352,10 +1355,30 @@ sub environment_setup () { # $ENV{'MYSQL_TCP_PORT'}= '@MYSQL_TCP_PORT@'; # FIXME $ENV{'MYSQL_TCP_PORT'}= 3306; - $ENV{'NDBCLUSTER_PORT'}= $opt_ndbcluster_port; - $ENV{'NDBCLUSTER_PORT_SLAVE'}=$opt_ndbcluster_port_slave; - $ENV{'NDB_STATUS_OK'}= "YES"; + $ENV{MTR_BUILD_THREAD}= 0 unless $ENV{MTR_BUILD_THREAD}; # Set if not set + # ---------------------------------------------------- + # Setup env for NDB + # ---------------------------------------------------- + $ENV{'NDB_MGM'}= $exe_ndb_mgm; + + $ENV{'NDBCLUSTER_PORT'}= $opt_ndbcluster_port; + $ENV{'NDBCLUSTER_PORT_SLAVE'}= $opt_ndbcluster_port_slave; + + $ENV{'NDB_STATUS_OK'}= $clusters->[0]->{'installed_ok'}; + $ENV{'NDB_SLAVE_STATUS_OK'}= $clusters->[0]->{'installed_ok'};; + $ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test; + + $ENV{'NDB_BACKUP_DIR'}= $clusters->[0]->{'data_dir'}; + $ENV{'NDB_DATA_DIR'}= $clusters->[0]->{'data_dir'}; + $ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir; + $ENV{'NDB_TOOLS_OUTPUT'}= $file_ndb_testrun_log; + $ENV{'NDB_CONNECTSTRING'}= $opt_ndbconnectstring; + + + # ---------------------------------------------------- + # Setup env for IM + # ---------------------------------------------------- $ENV{'IM_EXE'}= $exe_im; $ENV{'IM_PATH_PID'}= $instance_manager->{path_pid}; $ENV{'IM_PATH_ANGEL_PID'}= $instance_manager->{path_angel_pid}; @@ -1370,9 +1393,168 @@ sub environment_setup () { $ENV{'IM_MYSQLD2_PORT'}= $instance_manager->{instances}->[1]->{port}; $ENV{'IM_MYSQLD2_PATH_PID'}=$instance_manager->{instances}->[1]->{path_pid}; - $ENV{MTR_BUILD_THREAD}= 0 unless $ENV{MTR_BUILD_THREAD}; # Set if not set + # ---------------------------------------------------- + # Setup env so childs can execute mysqlcheck + # ---------------------------------------------------- + my $cmdline_mysqlcheck= + "$exe_mysqlcheck --no-defaults -uroot " . + "--port=$master->[0]->{'port'} " . + "--socket=$master->[0]->{'path_sock'} --password="; + if ( $opt_debug ) + { + $cmdline_mysqlcheck .= + " --debug=d:t:A,$opt_vardir_trace/log/mysqlcheck.trace"; + } + $ENV{'MYSQL_CHECK'}= $cmdline_mysqlcheck; + + # ---------------------------------------------------- + # Setup env to childs can execute myqldump + # ---------------------------------------------------- + my $cmdline_mysqldump= generate_cmdline_mysqldump($master->[0]); + my $cmdline_mysqldumpslave= generate_cmdline_mysqldump($slave->[0]); + + if ( $opt_debug ) + { + $cmdline_mysqldump .= + " --debug=d:t:A,$opt_vardir_trace/log/mysqldump-master.trace"; + $cmdline_mysqldumpslave .= + " --debug=d:t:A,$opt_vardir_trace/log/mysqldump-slave.trace"; + } + $ENV{'MYSQL_DUMP'}= $cmdline_mysqldump; + $ENV{'MYSQL_DUMP_SLAVE'}= $cmdline_mysqldumpslave; + + + # ---------------------------------------------------- + # Setup env so childs can execute mysqlslap + # ---------------------------------------------------- + unless ( $glob_win32 ) + { + my $cmdline_mysqlslap= + "$exe_mysqlslap -uroot " . + "--port=$master->[0]->{'port'} " . + "--socket=$master->[0]->{'path_sock'} --password= " . + "--lock-directory=$opt_tmpdir"; + + if ( $opt_debug ) + { + $cmdline_mysqlslap .= + " --debug=d:t:A,$opt_vardir_trace/log/mysqlslap.trace"; + } + $ENV{'MYSQL_SLAP'}= $cmdline_mysqlslap; + } + + # ---------------------------------------------------- + # Setup env so childs can execute mysqlimport + # ---------------------------------------------------- + my $cmdline_mysqlimport= + "$exe_mysqlimport -uroot " . + "--port=$master->[0]->{'port'} " . + "--socket=$master->[0]->{'path_sock'} --password="; + + if ( $opt_debug ) + { + $cmdline_mysqlimport .= + " --debug=d:t:A,$opt_vardir_trace/log/mysqlimport.trace"; + } + $ENV{'MYSQL_IMPORT'}= $cmdline_mysqlimport; + + + # ---------------------------------------------------- + # Setup env so childs can execute mysqlshow + # ---------------------------------------------------- + my $cmdline_mysqlshow= + "$exe_mysqlshow -uroot " . + "--port=$master->[0]->{'port'} " . + "--socket=$master->[0]->{'path_sock'} --password="; + + if ( $opt_debug ) + { + $cmdline_mysqlshow .= + " --debug=d:t:A,$opt_vardir_trace/log/mysqlshow.trace"; + } + $ENV{'MYSQL_SHOW'}= $cmdline_mysqlshow; + + # ---------------------------------------------------- + # Setup env so childs can execute mysqlbinlog + # ---------------------------------------------------- + my $cmdline_mysqlbinlog= + "$exe_mysqlbinlog" . + " --no-defaults --local-load=$opt_tmpdir" . + " --character-sets-dir=$path_charsetsdir"; + + if ( $opt_debug ) + { + $cmdline_mysqlbinlog .= + " --debug=d:t:A,$opt_vardir_trace/log/mysqlbinlog.trace"; + } + $ENV{'MYSQL_BINLOG'}= $cmdline_mysqlbinlog; + + # ---------------------------------------------------- + # Setup env so childs can execute mysql + # ---------------------------------------------------- + my $cmdline_mysql= + "$exe_mysql --no-defaults --host=localhost --user=root --password= " . + "--port=$master->[0]->{'port'} " . + "--socket=$master->[0]->{'path_sock'}"; + + $ENV{'MYSQL'}= $cmdline_mysql; + + # ---------------------------------------------------- + # Setup env so childs can execute mysql_client_test + # ---------------------------------------------------- + my $cmdline_mysql_client_test= + "$exe_mysql_client_test --no-defaults --testcase --user=root --silent " . + "--port=$master->[0]->{'port'} " . + "--vardir=$opt_vardir " . + "--socket=$master->[0]->{'path_sock'}"; + + if ( $opt_debug ) + { + $cmdline_mysql_client_test .= + " --debug=d:t:A,$opt_vardir_trace/log/mysql_client_test.trace"; + } + + if ( $glob_use_embedded_server ) + { + $cmdline_mysql_client_test.= + " -A --language=$path_language" . + " -A --datadir=$slave->[0]->{'path_myddir'}" . + " -A --character-sets-dir=$path_charsetsdir"; + } + $ENV{'MYSQL_CLIENT_TEST'}= $cmdline_mysql_client_test; + + + # ---------------------------------------------------- + # Setup env so childs can execute mysql_fix_system_tables + # ---------------------------------------------------- + my $cmdline_mysql_fix_system_tables= + "$exe_mysql_fix_system_tables --no-defaults --host=localhost --user=root --password= " . + "--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " . + "--port=$master->[0]->{'port'} " . + "--socket=$master->[0]->{'path_sock'}"; + + $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; + + # ---------------------------------------------------- + # Setup env so childs can execute my_print_defaults + # ---------------------------------------------------- + $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults; + + # ---------------------------------------------------- + # Add the path where mysqld will find udf_example.so + # ---------------------------------------------------- + $ENV{'UDF_EXAMPLE_LIB'}= + ($lib_udf_example ? basename($lib_udf_example) : ""); + + $ENV{'LD_LIBRARY_PATH'}= + ($lib_udf_example ? dirname($lib_udf_example) : "") . + ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : ""); + + + # ---------------------------------------------------- # We are nice and report a bit about our settings + # ---------------------------------------------------- if (!$opt_extern) { print "Using MTR_BUILD_THREAD = $ENV{MTR_BUILD_THREAD}\n"; @@ -2284,15 +2466,19 @@ sub run_testcase ($) { return; } - run_testcase_stop_servers($tinfo); + my $master_restart= run_testcase_need_master_restart($tinfo); + my $slave_restart= run_testcase_need_slave_restart($tinfo); + + if ($master_restart or $slave_restart) + { + run_testcase_stop_servers($tinfo, $master_restart, $slave_restart); + } # ---------------------------------------------------------------------- # Prepare to start masters. Even if we use embedded, we want to run # the preparation. # ---------------------------------------------------------------------- - $ENV{'TZ'}= $tinfo->{'timezone'}; - mtr_tofile($master->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n"); if ( $master->[1]->{'pid'} ) { @@ -2303,12 +2489,15 @@ sub run_testcase ($) { # If any mysqld servers running died, we have to know # ---------------------------------------------------------------------- - mtr_record_dead_children(); + my $died= mtr_record_dead_children(); # ---------------------------------------------------------------------- # Start masters needed by the testcase # ---------------------------------------------------------------------- - run_testcase_start_servers($tinfo); + if ($died or $master_restart or $slave_restart) + { + run_testcase_start_servers($tinfo); + } # ---------------------------------------------------------------------- # If --start-and-exit or --start-dirty given, stop here to let user manually @@ -2325,8 +2514,6 @@ sub run_testcase ($) { # Run the test case # ---------------------------------------------------------------------- - mtr_report_test_name($tinfo); - { # remove the old reject file if ( $opt_suite eq "main" ) @@ -2340,6 +2527,7 @@ sub run_testcase ($) { unlink($path_timefile); my $res= run_mysqltest($tinfo); + mtr_report_test_name($tinfo); if ( $res == 0 ) { mtr_report_test_passed($tinfo); @@ -2993,24 +3181,9 @@ sub stop_all_servers () { } -# ---------------------------------------------------------------------- -# If not using a running servers we may need to stop and restart. -# We restart in the case we have initiation scripts, server options -# etc to run. But we also restart again after the test first restart -# and test is run, to get back to normal server settings. -# -# To make the code a bit more clean, we actually only stop servers -# here, and mark this to be done. Then a generic "start" part will -# start up the needed servers again. -# ---------------------------------------------------------------------- - -sub run_testcase_stop_servers($) { - my $tinfo= shift; - - if ( $glob_use_running_server || $glob_use_embedded_server ) - { - return; - } +sub run_testcase_need_master_restart($) +{ + my ($tinfo)= @_; # We try to find out if we are to restart the master(s) my $do_restart= 0; # Assumes we don't have to @@ -3067,6 +3240,91 @@ sub run_testcase_stop_servers($) { join(" ", @{$master->[0]->{'start_opts'}}) . "'" ); } + return $do_restart; +} + +sub run_testcase_need_slave_restart($) +{ + my ($tinfo)= @_; + + # We try to find out if we are to restart the slaves + my $do_slave_restart= 0; # Assumes we don't have to + + # FIXME only restart slave when necessary + $do_slave_restart= 1; + +# if ( ! $slave->[0]->{'pid'} ) +# { +# # mtr_verbose("Slave not started, no need to check slave restart"); +# } +# elsif ( $do_restart ) +# { +# $do_slave_restart= 1; # Always restart if master restart +# mtr_verbose("Restart slave because: Master restart"); +# } +# elsif ( $tinfo->{'slave_sh'} ) +# { +# $do_slave_restart= 1; # Always restart if script to run +# mtr_verbose("Restart slave because: Always restart if script to run"); +# } +# elsif ( ! $opt_skip_ndbcluster_slave and +# $tinfo->{'ndb_test'} == 0 and +# $clusters->[1]->{'pid'} != 0 ) +# { +# $do_slave_restart= 1; # Restart without slave cluster +# mtr_verbose("Restart slave because: Test does not need slave cluster"); +# } +# elsif ( ! $opt_with_ndbcluster_slave and +# $tinfo->{'ndb_test'} == 1 and +# $clusters->[1]->{'pid'} == 0 ) +# { +# $do_slave_restart= 1; # Restart with slave cluster +# mtr_verbose("Restart slave because: Test need slave cluster"); +# } +# elsif ( $tinfo->{'slave_restart'} ) +# { +# $do_slave_restart= 1; +# mtr_verbose("Restart slave because: slave_restart"); +# } +# elsif ( $slave->[0]->{'running_slave_is_special'} ) +# { +# $do_slave_restart= 1; +# mtr_verbose("Restart slave because: running_slave_is_special"); +# } +# # Check that running slave was started with same options +# # as the current test requires +# elsif (! mtr_same_opts($slave->[0]->{'start_opts'}, +# $tinfo->{'slave_opt'}) ) +# { +# $do_slave_restart= 1; +# mtr_verbose("Restart slave because: running with different options '" . +# join(" ", @{$tinfo->{'slave_opt'}}) . "' != '" . +# join(" ", @{$slave->[0]->{'start_opts'}}) . "'" ); +# } + + return $do_slave_restart; + +} + +# ---------------------------------------------------------------------- +# If not using a running servers we may need to stop and restart. +# We restart in the case we have initiation scripts, server options +# etc to run. But we also restart again after the test first restart +# and test is run, to get back to normal server settings. +# +# To make the code a bit more clean, we actually only stop servers +# here, and mark this to be done. Then a generic "start" part will +# start up the needed servers again. +# ---------------------------------------------------------------------- + +sub run_testcase_stop_servers($$$) { + my ($tinfo, $do_restart, $do_slave_restart)= @_; + + if ( $glob_use_running_server || $glob_use_embedded_server ) + { + return; + } + my $pid; my %admin_pids; # hash of admin processes that requests shutdown my @kill_pids; # list of processes to shutdown/kill @@ -3124,62 +3382,7 @@ sub run_testcase_stop_servers($) { } } - # We try to find out if we are to restart the slaves - my $do_slave_restart= 0; # Assumes we don't have to - - # FIXME only restaret when necessary - $do_slave_restart= 1; - -# if ( ! $slave->[0]->{'pid'} ) -# { -# # mtr_verbose("Slave not started, no need to check slave restart"); -# } -# elsif ( $do_restart ) -# { -# $do_slave_restart= 1; # Always restart if master restart -# mtr_verbose("Restart slave because: Master restart"); -# } -# elsif ( $tinfo->{'slave_sh'} ) -# { -# $do_slave_restart= 1; # Always restart if script to run -# mtr_verbose("Restart slave because: Always restart if script to run"); -# } -# elsif ( ! $opt_skip_ndbcluster_slave and -# $tinfo->{'ndb_test'} == 0 and -# $clusters->[1]->{'pid'} != 0 ) -# { -# $do_slave_restart= 1; # Restart without slave cluster -# mtr_verbose("Restart slave because: Test does not need slave cluster"); -# } -# elsif ( ! $opt_with_ndbcluster_slave and -# $tinfo->{'ndb_test'} == 1 and -# $clusters->[1]->{'pid'} == 0 ) -# { -# $do_slave_restart= 1; # Restart with slave cluster -# mtr_verbose("Restart slave because: Test need slave cluster"); -# } -# elsif ( $tinfo->{'slave_restart'} ) -# { -# $do_slave_restart= 1; -# mtr_verbose("Restart slave because: slave_restart"); -# } -# elsif ( $slave->[0]->{'running_slave_is_special'} ) -# { -# $do_slave_restart= 1; -# mtr_verbose("Restart slave because: running_slave_is_special"); -# } -# # Check that running slave was started with same options -# # as the current test requires -# elsif (! mtr_same_opts($slave->[0]->{'start_opts'}, -# $tinfo->{'slave_opt'}) ) -# { -# $do_slave_restart= 1; -# mtr_verbose("Restart slave because: running with different options '" . -# join(" ", @{$tinfo->{'slave_opt'}}) . "' != '" . -# join(" ", @{$slave->[0]->{'start_opts'}}) . "'" ); -# } - - if ( $do_slave_restart ) + if ( $do_restart || $do_slave_restart ) { delete $slave->[0]->{'running_slave_is_special'}; # Forget history @@ -3627,135 +3830,9 @@ sub run_check_testcase ($$) { } -sub generate_cmdline_mysqldump ($) { - my($info) = @_; - return - "$exe_mysqldump --no-defaults -uroot " . - "--port=$info->[0]->{'port'} " . - "--socket=$info->[0]->{'path_sock'} --password="; -} sub run_mysqltest ($) { - my $tinfo= shift; - my $cmdline_mysqlcheck= "$exe_mysqlcheck --no-defaults -uroot " . - "--port=$master->[0]->{'port'} " . - "--socket=$master->[0]->{'path_sock'} --password="; - if ( $opt_debug ) - { - $cmdline_mysqlcheck .= - " --debug=d:t:A,$opt_vardir_trace/log/mysqlcheck.trace"; - } - - my $cmdline_mysqldump= generate_cmdline_mysqldump $master; - my $cmdline_mysqldumpslave= generate_cmdline_mysqldump $slave; - - if ( $opt_debug ) - { - $cmdline_mysqldump .= - " --debug=d:t:A,$opt_vardir_trace/log/mysqldump-master.trace"; - $cmdline_mysqldumpslave .= - " --debug=d:t:A,$opt_vardir_trace/log/mysqldump-slave.trace"; - } - - my $cmdline_mysqlslap; - - unless ( $glob_win32 ) - { - $cmdline_mysqlslap= "$exe_mysqlslap -uroot " . - "--port=$master->[0]->{'port'} " . - "--socket=$master->[0]->{'path_sock'} --password= " . - "--lock-directory=$opt_tmpdir"; - if ( $opt_debug ) - { - $cmdline_mysqlslap .= - " --debug=d:t:A,$opt_vardir_trace/log/mysqlslap.trace"; - } - } - - my $cmdline_mysqlimport= "$exe_mysqlimport -uroot " . - "--port=$master->[0]->{'port'} " . - "--socket=$master->[0]->{'path_sock'} --password="; - if ( $opt_debug ) - { - $cmdline_mysqlimport .= - " --debug=d:t:A,$opt_vardir_trace/log/mysqlimport.trace"; - } - - my $cmdline_mysqlshow= "$exe_mysqlshow -uroot " . - "--port=$master->[0]->{'port'} " . - "--socket=$master->[0]->{'path_sock'} --password="; - if ( $opt_debug ) - { - $cmdline_mysqlshow .= - " --debug=d:t:A,$opt_vardir_trace/log/mysqlshow.trace"; - } - - my $cmdline_mysqlbinlog= - "$exe_mysqlbinlog" . - " --no-defaults --local-load=$opt_tmpdir" . - " --character-sets-dir=$path_charsetsdir"; - - if ( $opt_debug ) - { - $cmdline_mysqlbinlog .= - " --debug=d:t:A,$opt_vardir_trace/log/mysqlbinlog.trace"; - } - - my $cmdline_mysql= - "$exe_mysql --no-defaults --host=localhost --user=root --password= " . - "--port=$master->[0]->{'port'} " . - "--socket=$master->[0]->{'path_sock'}"; - - my $cmdline_mysql_client_test= - "$exe_mysql_client_test --no-defaults --testcase --user=root --silent " . - "--port=$master->[0]->{'port'} " . - "--vardir=$opt_vardir " . - "--socket=$master->[0]->{'path_sock'}"; - - if ( $opt_debug ) - { - $cmdline_mysql_client_test .= - " --debug=d:t:A,$opt_vardir_trace/log/mysql_client_test.trace"; - } - - if ( $glob_use_embedded_server ) - { - $cmdline_mysql_client_test.= - " -A --language=$path_language" . - " -A --datadir=$slave->[0]->{'path_myddir'}" . - " -A --character-sets-dir=$path_charsetsdir"; - } - - my $cmdline_mysql_fix_system_tables= - "$exe_mysql_fix_system_tables --no-defaults --host=localhost --user=root --password= " . - "--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " . - "--port=$master->[0]->{'port'} " . - "--socket=$master->[0]->{'path_sock'}"; - - $ENV{'MYSQL'}= $cmdline_mysql; - $ENV{'MYSQL_CHECK'}= $cmdline_mysqlcheck; - $ENV{'MYSQL_DUMP'}= $cmdline_mysqldump; - $ENV{'MYSQL_SLAP'}= $cmdline_mysqlslap unless $glob_win32; - $ENV{'MYSQL_IMPORT'}= $cmdline_mysqlimport; - $ENV{'MYSQL_DUMP_SLAVE'}= $cmdline_mysqldumpslave; - $ENV{'MYSQL_SHOW'}= $cmdline_mysqlshow; - $ENV{'MYSQL_BINLOG'}= $cmdline_mysqlbinlog; - $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; - $ENV{'MYSQL_CLIENT_TEST'}= $cmdline_mysql_client_test; - $ENV{'CHARSETSDIR'}= $path_charsetsdir; - $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults; - $ENV{'UDF_EXAMPLE_LIB'}= - ($lib_udf_example ? basename($lib_udf_example) : ""); - - $ENV{'NDB_STATUS_OK'}= $clusters->[0]->{'installed_ok'}; - $ENV{'NDB_SLAVE_STATUS_OK'}= $clusters->[0]->{'installed_ok'};; - $ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test; - $ENV{'NDB_MGM'}= $exe_ndb_mgm; - $ENV{'NDB_BACKUP_DIR'}= $clusters->[0]->{'data_dir'}; - $ENV{'NDB_DATA_DIR'}= $clusters->[0]->{'data_dir'}; - $ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir; - $ENV{'NDB_TOOLS_OUTPUT'}= $file_ndb_testrun_log; - $ENV{'NDB_CONNECTSTRING'}= $opt_ndbconnectstring; + my ($tinfo)= @_; my $exe= $exe_mysqltest; my $args; @@ -3834,7 +3911,8 @@ sub run_mysqltest ($) { if ( $opt_debug ) { - mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", $opt_vardir_trace); + mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", + $opt_vardir_trace); } if ( $opt_ssl_supported ) @@ -3847,9 +3925,9 @@ sub run_mysqltest ($) { $glob_mysql_test_dir); } - # Turn on SSL for all test cases if ( $opt_ssl ) { + # Turn on SSL for _all_ test cases if option --ssl was used mtr_add_arg($args, "--ssl", $glob_mysql_test_dir); } @@ -3931,6 +4009,11 @@ sub run_mysqltest ($) { } } + # ------------------------------------------------------- + # Init variables that change for each testcase + # ------------------------------------------------------- + $ENV{'TZ'}= $tinfo->{'timezone'}; + my $res = mtr_run_test($exe,$args,"","",$path_timefile,""); if ( $opt_check_testcases ) From f03e672c4efc844a256ab63318b213a2f61ba27e Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Wed, 16 Aug 2006 13:47:01 +0200 Subject: [PATCH 018/119] Fix indentation --- mysql-test/mysql-test-run.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 890ac3fe407..afac82a2213 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2557,7 +2557,8 @@ sub run_testcase ($) { # Try to get reason from mysqltest.log my $last_line= mtr_lastlinefromfile($path_timefile) if -f $path_timefile; my $reason= mtr_match_prefix($last_line, "reason: "); - $tinfo->{'comment'}= defined $reason ? $reason : "Detected by testcase(reason unknown) "; + $tinfo->{'comment'}= + defined $reason ? $reason : "Detected by testcase(reason unknown) "; mtr_report_test_skipped($tinfo); } elsif ( $res == 63 ) From 4550b9d044d47280e558502ed4268bb9d16c7e5f Mon Sep 17 00:00:00 2001 From: "tnurnberg@salvation.intern.azundris.com" <> Date: Wed, 16 Aug 2006 23:45:01 +0200 Subject: [PATCH 019/119] manual merge --- mysql-test/r/partition.result | 8 ++++---- mysql-test/r/partition_mgm.result | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index e95489864f7..25dc4295d87 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1083,12 +1083,12 @@ partition by range (a) subpartition by hash (a) (partition p0 VALUES LESS THAN (1) DATA DIRECTORY = 'hello/master-data/tmpdata' INDEX DIRECTORY = 'hello/master-data/tmpinx' (SUBPARTITION subpart00, SUBPARTITION subpart01)); +hello/master-data/test/t1.frm +hello/master-data/test/t1.par hello/master-data/test/t1#P#p0#SP#subpart00.MYD hello/master-data/test/t1#P#p0#SP#subpart00.MYI hello/master-data/test/t1#P#p0#SP#subpart01.MYD hello/master-data/test/t1#P#p0#SP#subpart01.MYI -hello/master-data/test/t1.frm -hello/master-data/test/t1.par hello/master-data/tmpdata/t1#P#p0#SP#subpart00.MYD hello/master-data/tmpdata/t1#P#p0#SP#subpart01.MYD hello/master-data/tmpinx/t1#P#p0#SP#subpart00.MYI @@ -1098,6 +1098,8 @@ ALTER TABLE t1 REORGANIZE PARTITION p0 INTO (SUBPARTITION subpart10, SUBPARTITION subpart11), partition p2 VALUES LESS THAN (2) DATA DIRECTORY = 'hello/master-data/tmpdata' INDEX DIRECTORY = 'hello/master-data/tmpinx' (SUBPARTITION subpart20, SUBPARTITION subpart21)); +hello/master-data/test/t1.frm +hello/master-data/test/t1.par hello/master-data/test/t1#P#p1#SP#subpart10.MYD hello/master-data/test/t1#P#p1#SP#subpart10.MYI hello/master-data/test/t1#P#p1#SP#subpart11.MYD @@ -1106,8 +1108,6 @@ hello/master-data/test/t1#P#p2#SP#subpart20.MYD hello/master-data/test/t1#P#p2#SP#subpart20.MYI hello/master-data/test/t1#P#p2#SP#subpart21.MYD hello/master-data/test/t1#P#p2#SP#subpart21.MYI -hello/master-data/test/t1.frm -hello/master-data/test/t1.par hello/master-data/tmpdata/t1#P#p1#SP#subpart10.MYD hello/master-data/tmpdata/t1#P#p1#SP#subpart11.MYD hello/master-data/tmpdata/t1#P#p2#SP#subpart20.MYD diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index f64ffaff495..5ee12259312 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -7,12 +7,12 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2 */ +hello/master-data/test/t1.frm +hello/master-data/test/t1.par hello/master-data/test/t1#P#p0.MYD hello/master-data/test/t1#P#p0.MYI hello/master-data/test/t1#P#p1.MYD hello/master-data/test/t1#P#p1.MYI -hello/master-data/test/t1.frm -hello/master-data/test/t1.par ALTER TABLE t1 COALESCE PARTITION 1; SHOW CREATE TABLE t1; Table Create Table @@ -20,10 +20,10 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 1 */ -hello/master-data/test/t1#P#p0.MYD -hello/master-data/test/t1#P#p0.MYI hello/master-data/test/t1.frm hello/master-data/test/t1.par +hello/master-data/test/t1#P#p0.MYD +hello/master-data/test/t1#P#p0.MYI drop table t1; create table t1 (a int) partition by list (a) From d1e1ea2c27688b6a3c1dae292264b88dfac70916 Mon Sep 17 00:00:00 2001 From: "tnurnberg@salvation.intern.azundris.com" <> Date: Thu, 17 Aug 2006 16:01:33 +0200 Subject: [PATCH 020/119] temporarily disabled partition test, fails w/ PS protocol, filed as Bug#21658 --- mysql-test/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 359092b43b3..efbe1f5b32d 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -45,3 +45,4 @@ rpl_truncate_7ndb : BUG#21298 2006-07-27 msvensson crash_commit_before : 2006-08-02 msvensson rpl_ndb_dd_advance : BUG#18679 2006-07-28 jimw (Test fails randomly) federated_transactions : Need to be re-enabled once Patrick's merge is complete +partition : BUG#21658 2006-08-17 azundris fails w/ --ps-protocol From abc148000dabc6e726adf162dcbc3ef37779d6ef Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Thu, 17 Aug 2006 14:09:24 -0700 Subject: [PATCH 021/119] Bug #21288: mysqldump segmentation fault when using --where The problem was that the error handling was using a too-small buffer to print the error message generated. We fix this by not using a buffer at all, but by using fprintf() directly. There were also some problems with the error handling in table dumping that was exposed by this fix that were also corrected. --- client/mysqldump.c | 16 +++++++++++----- mysql-test/r/mysqldump.result | 27 +++++++++++++++++++++++++++ mysql-test/t/mysqldump.test | 8 ++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 58e51b9b955..7f495ccdafb 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -783,8 +783,8 @@ static int get_options(int *argc, char ***argv) static void DBerror(MYSQL *mysql, const char *when) { DBUG_ENTER("DBerror"); - my_printf_error(0,"Got error: %d: %s %s", MYF(0), - mysql_errno(mysql), mysql_error(mysql), when); + fprintf(stderr, "%s: Got error: %d: %s %s\n", my_progname, + mysql_errno(mysql), mysql_error(mysql), when); safe_exit(EX_MYSQLERR); DBUG_VOID_RETURN; } /* DBerror */ @@ -811,9 +811,9 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res, if (mysql_query(mysql_con, query) || (res && !((*res)= mysql_store_result(mysql_con)))) { - my_printf_error(0, "%s: Couldn't execute '%s': %s (%d)", - MYF(0), my_progname, query, - mysql_error(mysql_con), mysql_errno(mysql_con)); + fprintf(stderr, "%s: Couldn't execute '%s': %s (%d)\n", + my_progname, query, + mysql_error(mysql_con), mysql_errno(mysql_con)); return 1; } return 0; @@ -1705,13 +1705,19 @@ static void dumpTable(uint numFields, char *table) check_io(md_result_file); } if (mysql_query_with_error_report(sock, 0, query)) + { DBerror(sock, "when retrieving data from server"); + goto err; + } if (quick) res=mysql_use_result(sock); else res=mysql_store_result(sock); if (!res) + { DBerror(sock, "when retrieving data from server"); + goto err; + } if (verbose) fprintf(stderr, "-- Retrieving rows...\n"); if (mysql_num_fields(res) != numFields) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 6c5c757061d..721982e11e3 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1557,4 +1557,31 @@ CREATE TABLE `t2` ( /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; drop table t1, t2, t3; +create table t1 (a int); +mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064) +mysqldump: Got error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 when retrieving data from server + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +drop table t1; End of 4.1 tests diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index e86635e24d0..b0df2bb9db2 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -694,4 +694,12 @@ create table t3(a int); --exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2 drop table t1, t2, t3; +# +# Bug #21288: mysqldump segmentation fault when using --where +# +create table t1 (a int); +--error 2 +--exec $MYSQL_DUMP --skip-comments --force test t1 --where='xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 2>&1 +drop table t1; + --echo End of 4.1 tests From 9335cba3e43759512478237d2ace53d2a2b994e0 Mon Sep 17 00:00:00 2001 From: "tnurnberg@salvation.intern.azundris.com" <> Date: Fri, 18 Aug 2006 19:29:54 +0200 Subject: [PATCH 022/119] 17926 duplicates Bug#1989 in bug db on up-merging 17926 from 5.0 tree it collides with near-identical fix 1989 in 5.1 tree. backing 17926 out of 5.1 tree. --- client/mysql.cc | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 3872968ca3f..2f1efc3b02a 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -338,7 +338,7 @@ static void end_timer(ulong start_time,char *buff); static void mysql_end_timer(ulong start_time,char *buff); static void nice_time(double sec,char *buff,bool part_second); static sig_handler mysql_end(int sig); -static sig_handler mysql_sigint(int sig); +static sig_handler handle_sigint(int sig); int main(int argc,char *argv[]) { @@ -421,7 +421,6 @@ int main(int argc,char *argv[]) signal(SIGINT, SIG_IGN); else signal(SIGINT, handle_sigint); // Catch SIGINT to clean up - signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up /* @@ -489,28 +488,6 @@ int main(int argc,char *argv[]) #endif } -sig_handler mysql_sigint(int sig) -{ - char kill_buffer[40]; - MYSQL *kill_mysql= NULL; - - signal(SIGINT, mysql_sigint); - - /* terminate if no query being executed, or we already tried interrupting */ - if (!executing_query || interrupted_query++) - mysql_end(sig); - - kill_mysql= mysql_init(kill_mysql); - if (!mysql_real_connect(kill_mysql,current_host, current_user, opt_password, - "", opt_mysql_port, opt_mysql_unix_port,0)) - mysql_end(sig); - /* kill_buffer is always big enough because max length of %lu is 15 */ - sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql)); - mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer)); - mysql_close(kill_mysql); - tee_fprintf(stdout, "Query aborted by Ctrl+C\n"); -} - sig_handler mysql_end(int sig) { mysql_close(&mysql); @@ -1058,8 +1035,6 @@ static int read_and_execute(bool interactive) if (opt_outfile && glob_buffer.is_empty()) fflush(OUTFILE); - interrupted_query= 0; - #if defined( __WIN__) || defined(__NETWARE__) tee_fputs(prompt, stdout); #if defined(__NETWARE__) @@ -2041,9 +2016,7 @@ com_go(String *buffer,char *line __attribute__((unused))) } timer=start_timer(); - executing_query= 1; - error= mysql_real_query_for_lazy(buffer->ptr(),buffer->length()); #ifdef HAVE_READLINE @@ -2059,7 +2032,6 @@ com_go(String *buffer,char *line __attribute__((unused))) { executing_query= 0; buffer->length(0); // Remove query on error - executing_query= 0; return error; } error=0; @@ -2143,9 +2115,6 @@ com_go(String *buffer,char *line __attribute__((unused))) fflush(stdout); mysql_free_result(result); } while (!(err= mysql_next_result(&mysql))); - - executing_query= 0; - if (err >= 1) error= put_error(&mysql); From 4d8e38a6932c76f0ed809273db66d59b6bd6607e Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/deer.(none)" <> Date: Sat, 19 Aug 2006 15:15:36 +0500 Subject: [PATCH 023/119] bug #16513 (no mysql_set_server_option in libmysqld.dll export) --- libmysqld/libmysqld.def | 1 + 1 file changed, 1 insertion(+) diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def index 3895588e02c..0e80681700f 100644 --- a/libmysqld/libmysqld.def +++ b/libmysqld/libmysqld.def @@ -163,3 +163,4 @@ EXPORTS my_charset_bin my_charset_same modify_defaults_file + mysql_set_server_option From 0f54eccbb09aa302e5b59846e1cc3a815ac8ab8c Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Sun, 20 Aug 2006 20:46:50 +0200 Subject: [PATCH 024/119] Move the initialisation of "NDB_STATUS_OK" env variable to after cluster has been intalled --- mysql-test/mysql-test-run.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 9907bb3a181..af59c39cda7 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1392,8 +1392,6 @@ sub environment_setup () { $ENV{'NDBCLUSTER_PORT'}= $opt_ndbcluster_port; $ENV{'NDBCLUSTER_PORT_SLAVE'}= $opt_ndbcluster_port_slave; - $ENV{'NDB_STATUS_OK'}= $clusters->[0]->{'installed_ok'}; - $ENV{'NDB_SLAVE_STATUS_OK'}= $clusters->[0]->{'installed_ok'};; $ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test; $ENV{'NDB_BACKUP_DIR'}= $clusters->[0]->{'data_dir'}; @@ -2260,6 +2258,9 @@ sub mysql_install_db () { } } + $ENV{'NDB_STATUS_OK'}= $clusters->[0]->{'installed_ok'}; + $ENV{'NDB_SLAVE_STATUS_OK'}= $clusters->[1]->{'installed_ok'};; + if ( ! $cluster_started_ok ) { if ( $opt_force) From 447d2fefdfaacf3fa76f60c776e3732fc5acdca0 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Mon, 21 Aug 2006 09:53:04 +0200 Subject: [PATCH 025/119] Break out and create new function 'run_testcase_check_skip_test' --- mysql-test/mysql-test-run.pl | 73 +++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index af59c39cda7..507258c5d65 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -360,6 +360,7 @@ sub install_db ($$); sub run_testcase ($); sub run_testcase_stop_servers ($$$); sub run_testcase_start_servers ($); +sub run_testcase_check_skip_test($); sub report_failure_and_restart ($); sub do_before_start_master ($$); sub do_before_start_slave ($$); @@ -2156,6 +2157,8 @@ sub run_suite () { foreach my $tinfo ( @$tests ) { + next if run_testcase_check_skip_test($tinfo); + mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout); run_testcase($tinfo); mtr_timer_stop($glob_timers,"testcase"); @@ -2440,6 +2443,45 @@ sub im_prepare_data_dir($) { } } +sub run_testcase_check_skip_test($) +{ + my ($tinfo)= @_; + + # ---------------------------------------------------------------------- + # If marked to skip, just print out and return. + # Note that a test case not marked as 'skip' can still be + # skipped later, because of the test case itself in cooperation + # with the mysqltest program tells us so. + # ---------------------------------------------------------------------- + + if ( $tinfo->{'skip'} ) + { + mtr_report_test_name($tinfo); + mtr_report_test_skipped($tinfo); + return 1; + } + + # If test needs cluster, check that master installed ok + if ( $tinfo->{'ndb_test'} and $clusters->[0]->{'installed_ok'} eq "NO" ) + { + mtr_report_test_name($tinfo); + mtr_report_test_failed($tinfo); + return 1; + } + + # If test needs slave cluster, check that it installed ok + if ( $tinfo->{'ndb_test'} and $tinfo->{'slave_num'} and + $clusters->[1]->{'installed_ok'} eq "NO" ) + { + mtr_report_test_name($tinfo); + mtr_report_test_failed($tinfo); + return 1; + } + + return 0; +} + + ############################################################################## # @@ -2467,37 +2509,6 @@ sub run_testcase ($) { # output current test to ndbcluster log file to enable diagnostics mtr_tofile($file_ndb_testrun_log,"CURRENT TEST $tname\n"); - # ---------------------------------------------------------------------- - # If marked to skip, just print out and return. - # Note that a test case not marked as 'skip' can still be - # skipped later, because of the test case itself in cooperation - # with the mysqltest program tells us so. - # ---------------------------------------------------------------------- - - if ( $tinfo->{'skip'} ) - { - mtr_report_test_name($tinfo); - mtr_report_test_skipped($tinfo); - return; - } - - # If test needs cluster, check that master installed ok - if ( $tinfo->{'ndb_test'} and $clusters->[0]->{'installed_ok'} eq "NO" ) - { - mtr_report_test_name($tinfo); - mtr_report_test_failed($tinfo); - return; - } - - # If test needs slave cluster, check that it installed ok - if ( $tinfo->{'ndb_test'} and $tinfo->{'slave_num'} and - $clusters->[1]->{'installed_ok'} eq "NO" ) - { - mtr_report_test_name($tinfo); - mtr_report_test_failed($tinfo); - return; - } - my $master_restart= run_testcase_need_master_restart($tinfo); my $slave_restart= run_testcase_need_slave_restart($tinfo); From 457a7702f6bef8e9430c062d15ec2c4c7588815b Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Mon, 21 Aug 2006 09:53:49 +0200 Subject: [PATCH 026/119] Turn on reorder by default --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 507258c5d65..26f9bcda889 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -216,7 +216,7 @@ our $opt_embedded_server; our $opt_extern; our $opt_fast; our $opt_force; -our $opt_reorder; +our $opt_reorder= 1; our $opt_enable_disabled; our $opt_gcov; From 8a55763f286c48a8030d697a509f9b5372fcab06 Mon Sep 17 00:00:00 2001 From: "aelkin@dl145j.mysql.com" <> Date: Mon, 21 Aug 2006 11:44:30 +0200 Subject: [PATCH 027/119] BUG#21582 mysql server crashes in close_temporary_tables the problem is described and resolved by 20919 which fix happened not to have got to the release tree. Applying the patch of the parent bug. --- sql/sql_base.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 5904e13d710..ffd40df2fdc 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -624,8 +624,10 @@ void close_temporary_tables(THD *thd) if (!mysql_bin_log.is_open()) { - for (table= thd->temporary_tables; table; table= table->next) + TABLE *next; + for (table= thd->temporary_tables; table; table= next) { + next= table->next; close_temporary(table, 1); } thd->temporary_tables= 0; From 2f0b080aeaa1afb8f58a730ba8ad4e586b8d4eb9 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 21 Aug 2006 14:51:59 +0200 Subject: [PATCH 028/119] Bug#19810 Bundled YASSL in libmysqlclient conflicts with OpenSSL - Rename yaSSL version of 'SSL_peek' to 'yaSSL_peek' by using a macro --- extra/yassl/include/openssl/prefix_ssl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/yassl/include/openssl/prefix_ssl.h b/extra/yassl/include/openssl/prefix_ssl.h index 7f815156f47..0d740b6b97e 100644 --- a/extra/yassl/include/openssl/prefix_ssl.h +++ b/extra/yassl/include/openssl/prefix_ssl.h @@ -150,3 +150,4 @@ #define MD5_Init yaMD5_Init #define MD5_Update yaMD5_Update #define MD5_Final yaMD5_Final +#define SSL_peek yaSSL_peek From df063e0c939fef2f488e9114c9fb75ecdd7444ec Mon Sep 17 00:00:00 2001 From: "rburnett@production.mysql.com" <> Date: Mon, 21 Aug 2006 16:36:03 +0200 Subject: [PATCH 029/119] mysqld.cc: var was already defined so had to remove extra one --- sql/mysqld.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d8d8f27ce5e..5ef98eded95 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -438,7 +438,6 @@ key_map key_map_full(0); // Will be initialized later const char *opt_date_time_formats[3]; -char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME; char *mysql_data_home= mysql_real_data_home; char server_version[SERVER_VERSION_LENGTH]; char *mysqld_unix_port, *opt_mysql_tmpdir; From aa944afbe7497d6b991355326732c05ebe546607 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 22 Aug 2006 08:30:33 +0200 Subject: [PATCH 030/119] Remove debug printout from mysql_client_test --- tests/mysql_client_test.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 88c1a5737d3..f8c091e37f7 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -14975,8 +14975,6 @@ static void test_bug17667() DIE("Read error"); } } - /* Print the line */ - printf("%s", line_buffer); } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2, statement_cursor->buffer, statement_cursor->length) == NULL); From 442c111b72561a514412c6bec31ad4dd6f7cd190 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com/g4-2.local" <> Date: Tue, 22 Aug 2006 11:48:58 +0200 Subject: [PATCH 031/119] mysql.spec.sh: Added ndb_size.{pl,tmpl} to the RPM install (bug#20426) --- support-files/mysql.spec.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 454ec522f0e..befd9f48fed 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -647,6 +647,8 @@ fi %attr(755, root, root) %{_bindir}/ndb_show_tables %attr(755, root, root) %{_bindir}/ndb_test_platform %attr(755, root, root) %{_bindir}/ndb_config +%attr(755, root, root) %{_bindir}/ndb_size.pl +%attr(-, root, root) %{_datadir}/mysql/ndb_size.tmpl %files ndb-extra %defattr(-,root,root,0755) From c8b6563dfc0bf677d34aed18426800d5d77de270 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com/g4-2.local" <> Date: Tue, 22 Aug 2006 11:55:08 +0200 Subject: [PATCH 032/119] mysql.spec.sh: Added ndb_error_reporter to the RPM install (bug#20426) --- support-files/mysql.spec.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 89cf998f8fd..f5db4e8ae18 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -675,6 +675,7 @@ fi %attr(755, root, root) %{_bindir}/ndb_show_tables %attr(755, root, root) %{_bindir}/ndb_test_platform %attr(755, root, root) %{_bindir}/ndb_config +%attr(755, root, root) %{_bindir}/ndb_error_reporter %attr(755, root, root) %{_bindir}/ndb_size.pl %attr(-, root, root) %{_datadir}/mysql/ndb_size.tmpl From 75c0f2fba672abeea6250df7804fa6ee8465446e Mon Sep 17 00:00:00 2001 From: "joerg@trift2." <> Date: Wed, 23 Aug 2006 12:08:08 +0200 Subject: [PATCH 033/119] Fix for bug#21537, "Error at startup" These variables must be defined for Netware, or it fails to recognize hard paths starting from the device. (Packport of: 2006/08/16 19:30:46+03:00 jani@ua141d10.elisa.omakaista.fi ) --- include/config-netware.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/config-netware.h b/include/config-netware.h index 5a8b926a669..a3cd6635bae 100644 --- a/include/config-netware.h +++ b/include/config-netware.h @@ -101,6 +101,10 @@ extern "C" { /* On NetWare, to fix the problem with the deletion of open files */ #define CANT_DELETE_OPEN_FILES 1 +#define FN_LIBCHAR '\\' +#define FN_ROOTDIR "\\" +#define FN_DEVCHAR ':' + /* default directory information */ #define DEFAULT_MYSQL_HOME "sys:/mysql" #define PACKAGE "mysql" From 01412f2bd93d799d47d3b6446e991f512678335b Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Wed, 23 Aug 2006 15:35:24 +0200 Subject: [PATCH 034/119] Break out functions do_before_run_mysqltest and do_after_run_mysqltest --- mysql-test/mysql-test-run.pl | 94 ++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 26f9bcda889..6865cd55398 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2157,7 +2157,10 @@ sub run_suite () { foreach my $tinfo ( @$tests ) { - next if run_testcase_check_skip_test($tinfo); + if (run_testcase_check_skip_test($tinfo)) + { + next; + } mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout); run_testcase($tinfo); @@ -2482,6 +2485,47 @@ sub run_testcase_check_skip_test($) } +sub do_before_run_mysqltest($) +{ + my $tinfo= shift; + my $tname= $tinfo->{'name'}; + + # Remove old reject file + if ( $opt_suite eq "main" ) + { + unlink("r/$tname.reject"); + } + else + { + unlink("suite/$opt_suite/r/$tname.reject"); + } + + +# MASV cleanup... + mtr_tonewfile($path_current_test_log,"$tname\n"); # Always tell where we are + + # output current test to ndbcluster log file to enable diagnostics + mtr_tofile($file_ndb_testrun_log,"CURRENT TEST $tname\n"); + + mtr_tofile($master->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n"); + if ( $master->[1]->{'pid'} ) + { + mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n"); + } +} + +sub do_after_run_mysqltest($) +{ + my $tinfo= shift; + my $tname= $tinfo->{'name'}; + + #MASV cleanup + # Save info from this testcase run to mysqltest.log + my $testcase_log= mtr_fromfile($path_timefile) if -f $path_timefile; + mtr_tofile($path_mysqltest_log,"CURRENT TEST $tname\n"); + mtr_tofile($path_mysqltest_log, $testcase_log); + } + ############################################################################## # @@ -2502,13 +2546,6 @@ sub run_testcase_check_skip_test($) sub run_testcase ($) { my $tinfo= shift; - my $tname= $tinfo->{'name'}; - - mtr_tonewfile($path_current_test_log,"$tname\n"); # Always tell where we are - - # output current test to ndbcluster log file to enable diagnostics - mtr_tofile($file_ndb_testrun_log,"CURRENT TEST $tname\n"); - my $master_restart= run_testcase_need_master_restart($tinfo); my $slave_restart= run_testcase_need_slave_restart($tinfo); @@ -2517,26 +2554,7 @@ sub run_testcase ($) { run_testcase_stop_servers($tinfo, $master_restart, $slave_restart); } - # ---------------------------------------------------------------------- - # Prepare to start masters. Even if we use embedded, we want to run - # the preparation. - # ---------------------------------------------------------------------- - - mtr_tofile($master->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - if ( $master->[1]->{'pid'} ) - { - mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - } - - # ---------------------------------------------------------------------- - # If any mysqld servers running died, we have to know - # ---------------------------------------------------------------------- - my $died= mtr_record_dead_children(); - - # ---------------------------------------------------------------------- - # Start masters needed by the testcase - # ---------------------------------------------------------------------- if ($died or $master_restart or $slave_restart) { run_testcase_start_servers($tinfo); @@ -2546,28 +2564,14 @@ sub run_testcase ($) { # If --start-and-exit or --start-dirty given, stop here to let user manually # run tests # ---------------------------------------------------------------------- - if ( $opt_start_and_exit or $opt_start_dirty ) { mtr_report("\nServers started, exiting"); exit(0); } - # ---------------------------------------------------------------------- - # Run the test case - # ---------------------------------------------------------------------- - { - # remove the old reject file - if ( $opt_suite eq "main" ) - { - unlink("r/$tname.reject"); - } - else - { - unlink("suite/$opt_suite/r/$tname.reject"); - } - unlink($path_timefile); + do_before_run_mysqltest($tinfo); my $res= run_mysqltest($tinfo); mtr_report_test_name($tinfo); @@ -2603,10 +2607,8 @@ sub run_testcase ($) { report_failure_and_restart($tinfo); } - # Save info from this testcase run to mysqltest.log - my $testcase_log= mtr_fromfile($path_timefile) if -f $path_timefile; - mtr_tofile($path_mysqltest_log,"CURRENT TEST $tname\n"); - mtr_tofile($path_mysqltest_log, $testcase_log); + + do_after_run_mysqltest($tinfo); } # ---------------------------------------------------------------------- From 92f908dcaea285186abffb1ecdd386bd48cc1c32 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Wed, 23 Aug 2006 15:41:52 +0200 Subject: [PATCH 035/119] Fix VC 2005 compile problem --- sql/handler.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index d67acf69d14..c92f7dcb16d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3513,10 +3513,10 @@ int handler::ha_external_lock(THD *thd, int lock_type) int handler::ha_reset() { DBUG_ENTER("ha_reset"); - /* Check that we have called all proper delallocation functions */ + /* Check that we have called all proper deallocation functions */ DBUG_ASSERT((byte*) table->def_read_set.bitmap + table->s->column_bitmap_size == - (char*) table->def_write_set.bitmap); + (byte*) table->def_write_set.bitmap); DBUG_ASSERT(bitmap_is_set_all(&table->s->all_set)); DBUG_ASSERT(table->key_read == 0); /* ensure that ha_index_end / ha_rnd_end has been called */ From 6d62914044ce04cc4ebf749d110e4963428bb312 Mon Sep 17 00:00:00 2001 From: "joerg@trift2." <> Date: Wed, 23 Aug 2006 17:40:05 +0200 Subject: [PATCH 036/119] configure.in : Set the version for 5.0.24a. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 48454a11309..46664866822 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.24) +AM_INIT_AUTOMAKE(mysql, 5.0.24a) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 977e6966779db2177927a1662e198ec11faa5678 Mon Sep 17 00:00:00 2001 From: "cmiller@maint1.mysql.com" <> Date: Wed, 23 Aug 2006 19:14:58 +0200 Subject: [PATCH 037/119] Bug #20908: Crash if select @@"" Zero-length variables caused failures when using the length to look up the name in a hash. Instead, signal that no zero-length name can ever be found and that to encounter one is a syntax error. --- mysql-test/r/variables.result | 6 ++++++ mysql-test/t/variables.test | 11 +++++++++++ sql/gen_lex_hash.cc | 11 +++++++++-- sql/sql_lex.cc | 2 ++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index a0e516d2397..cd834a789bd 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -689,6 +689,12 @@ select @@log_queries_not_using_indexes; show variables like 'log_queries_not_using_indexes'; Variable_name Value log_queries_not_using_indexes OFF +select @@""; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '""' at line 1 +select @@&; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '&' at line 1 +select @@@; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@' at line 1 End of 5.0 tests set global binlog_cache_size =@my_binlog_cache_size; set global connect_timeout =@my_connect_timeout; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 68efcafd1e0..d855b4d8266 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -585,6 +585,16 @@ show variables like 'ssl%'; select @@log_queries_not_using_indexes; show variables like 'log_queries_not_using_indexes'; +# +# Bug#20908: Crash if select @@"" +# +--error ER_PARSE_ERROR +select @@""; +--error ER_PARSE_ERROR +select @@&; +--error ER_PARSE_ERROR +select @@@; + --echo End of 5.0 tests # This is at the very after the versioned tests, since it involves doing @@ -620,3 +630,4 @@ set global server_id =@my_server_id; set global slow_launch_time =@my_slow_launch_time; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; + diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 7e0b178f7af..89af0d30076 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -447,8 +447,9 @@ int main(int argc,char **argv) and you are welcome to modify and redistribute it under the GPL license\n\ \n*/\n\n"); - printf("/* This code is generated by gen_lex_hash.cc that seeks for\ - a perfect\nhash function */\n\n"); + /* Broken up to indicate that it's not advice to you, gentle reader. */ + printf("/* Do " "not " "edit " "this " "file! This is generated by " + "gen_lex_hash.cc\nthat seeks for a perfect hash function */\n\n"); printf("#include \"lex.h\"\n\n"); calc_length(); @@ -468,6 +469,12 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\ {\n\ register uchar *hash_map;\n\ register const char *cur_str= s;\n\ +\n\ + if (len == 0) {\n\ + DBUG_PRINT(\"warning\", (\"get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.\"));\ + return(NULL);\n\ + }\ +\n\ if (function){\n\ if (len>sql_functions_max_len) return 0;\n\ hash_map= sql_functions_map;\n\ diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 7d4dca15608..479db7b5b99 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1042,6 +1042,8 @@ int MYSQLlex(void *arg, void *yythd) if (c == '.') lex->next_state=MY_LEX_IDENT_SEP; length= (uint) (lex->ptr - lex->tok_start)-1; + if (length == 0) + return(ABORT_SYM); // Names must be nonempty. if ((tokval= find_keyword(lex,length,0))) { yyUnget(); // Put back 'c' From dba7b8e81c462e81256c95986d0b5daec9ba36ac Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Wed, 23 Aug 2006 15:37:54 -0600 Subject: [PATCH 038/119] Bug #20402: DROP USER failure logged as ERROR rather than WARNING Remove some sql_print_error() calls which were triggered by user error (i.e., not server-level events at all). Also, convert an sql_print_error -> sql_print_information for a non-error server event. --- sql/slave.cc | 2 +- sql/sql_acl.cc | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index b2862a437bb..bceeca1055c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2946,7 +2946,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) rli->is_until_satisfied()) { char buf[22]; - sql_print_error("Slave SQL thread stopped because it reached its" + sql_print_information("Slave SQL thread stopped because it reached its" " UNTIL position %s", llstr(rli->until_pos(), buf)); /* Setting abort_slave flag because we do not want additional message about diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 204a38dfb64..5b3e2619d21 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3669,17 +3669,11 @@ int mysql_drop_user(THD *thd, List &list) { if (!(acl_user= check_acl_user(user_name, &counter))) { - sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; No such user", - user_name->user.str, - user_name->host.str); result= -1; continue; } if ((acl_user->access & ~0)) { - sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Global privileges exists", - user_name->user.str, - user_name->host.str); result= -1; continue; } @@ -3700,9 +3694,6 @@ int mysql_drop_user(THD *thd, List &list) } if (counter != acl_dbs.elements) { - sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Database privileges exists", - user_name->user.str, - user_name->host.str); result= -1; continue; } @@ -3723,9 +3714,6 @@ int mysql_drop_user(THD *thd, List &list) } if (counter != column_priv_hash.records) { - sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Table privileges exists", - user_name->user.str, - user_name->host.str); result= -1; continue; } @@ -3791,9 +3779,6 @@ int mysql_revoke_all(THD *thd, List &list) { if (!check_acl_user(lex_user, &counter)) { - sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' not exists", - lex_user->user.str, - lex_user->host.str); result= -1; continue; } From a4f32ff2e85294f93cfe5513839fb75e0150facd Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 23 Aug 2006 18:29:05 -0400 Subject: [PATCH 039/119] String broken up to avoid silly MICROS~1 string-size limit. --- .bzrignore | 1 + sql/gen_lex_hash.cc | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.bzrignore b/.bzrignore index 68e8120fae0..68365ad40c2 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1296,3 +1296,4 @@ vio/viotest-sslconnect.cpp vio/viotest.cpp zlib/*.ds? zlib/*.vcproj +sql/f.c diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 89af0d30076..1a7710dba0d 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -473,8 +473,10 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\ if (len == 0) {\n\ DBUG_PRINT(\"warning\", (\"get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.\"));\ return(NULL);\n\ - }\ -\n\ + }\n" +); + + printf("\ if (function){\n\ if (len>sql_functions_max_len) return 0;\n\ hash_map= sql_functions_map;\n\ @@ -505,7 +507,10 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\ cur_struct= uint4korr(hash_map+\n\ (((uint16)cur_struct + cur_char - first_char)*4));\n\ cur_str++;\n\ - }\n\ + }\n" +); + + printf("\ }else{\n\ if (len>symbols_max_len) return 0;\n\ hash_map= symbols_map;\n\ From 45460bd0afbf5f31111ee44f352622cd79402a0d Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Wed, 23 Aug 2006 18:02:31 -0600 Subject: [PATCH 040/119] Bug #21531: EXPORT_SET() doesn't accept args with coercible character sets - Fix typo in Item_func_export_set::fix_length_and_dec() which caused character set aggregation to fail - Remove default argument from last arg of agg_arg_charsets() function, to reduce potential errors --- mysql-test/r/func_misc.result | 4 ++++ mysql-test/t/func_misc.test | 7 ++++++- sql/item_func.h | 3 +-- sql/item_strfunc.cc | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 8bcdd8b7cbc..adf2035173f 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -93,3 +93,7 @@ SELECT IS_USED_LOCK('bug16501'); IS_USED_LOCK('bug16501') NULL DROP TABLE t1; +select export_set(3, _latin1'foo', _utf8'bar', ',', 4); +export_set(3, _latin1'foo', _utf8'bar', ',', 4) +foo,foo,bar,bar +End of 4.1 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index e2641f8d6cd..a7dc9e7c966 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -83,4 +83,9 @@ connection default; DROP TABLE t1; -# End of 4.1 tests +# +# Bug #21531: EXPORT_SET() doesn't accept args with coercible character sets +# +select export_set(3, _latin1'foo', _utf8'bar', ',', 4); + +--echo End of 4.1 tests diff --git a/sql/item_func.h b/sql/item_func.h index 51f9d3fb36f..aaf74e4f7af 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -156,8 +156,7 @@ public: return agg_item_collations_for_comparison(c, func_name(), items, nitems, flags); } - bool agg_arg_charsets(DTCollation &c, Item **items, uint nitems, - uint flags= 0) + bool agg_arg_charsets(DTCollation &c, Item **items, uint nitems, uint flags) { return agg_item_charsets(c, func_name(), items, nitems, flags); } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 56a31d074ac..a43f8b5a22a 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2624,8 +2624,8 @@ void Item_func_export_set::fix_length_and_dec() uint sep_length=(arg_count > 3 ? args[3]->max_length : 1); max_length=length*64+sep_length*63; - if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1), - MY_COLL_ALLOW_CONV) + if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1, + MY_COLL_ALLOW_CONV)) return; } From b25b49a05a5b981ee90ec827a559fc509e78e01c Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 24 Aug 2006 11:39:52 +0200 Subject: [PATCH 041/119] Cset exclude: msvensson@neptunus.(none)|ChangeSet|20060612110740|13873 --- configure.in | 15 ++++++--------- dbug/dbug.c | 5 +---- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/configure.in b/configure.in index 3430bd8a5b5..b49dffcb59f 100644 --- a/configure.in +++ b/configure.in @@ -1655,20 +1655,17 @@ AC_ARG_WITH(debug, if test "$with_debug" = "yes" then # Medium debug. - AC_DEFINE([DBUG_ON], [1], [Use libdbug]) - CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DSAFE_MUTEX $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS" + CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DDBUG_ON -DSAFE_MUTEX $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DDBUG_ON -DSAFE_MUTEX $CXXFLAGS" elif test "$with_debug" = "full" then # Full debug. Very slow in some cases - AC_DEFINE([DBUG_ON], [1], [Use libdbug]) - CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" + CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" else # Optimized version. No debug - AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug]) - CFLAGS="$OPTIMIZE_CFLAGS $CFLAGS" - CXXFLAGS="$OPTIMIZE_CXXFLAGS $CXXFLAGS" + CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS" + CXXFLAGS="$OPTIMIZE_CXXFLAGS -DDBUG_OFF $CXXFLAGS" fi # Force static compilation to avoid linking problems/get more speed diff --git a/dbug/dbug.c b/dbug/dbug.c index 575481305e7..c991daf3617 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -66,13 +66,10 @@ * Check of malloc on entry/exit (option "S") */ -#include - -/* This file won't compile unless DBUG_OFF is undefined locally */ #ifdef DBUG_OFF #undef DBUG_OFF #endif - +#include #include #include #if defined(MSDOS) || defined(__WIN__) From 81a0090333a6efffba3f6063438a36a8f7754e55 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 24 Aug 2006 14:27:57 +0200 Subject: [PATCH 042/119] Bug#20841 mysqldump fails to store right info with --compatible=mysql40 option - Add "not in version before" commensta around new syntax "WITH PARSER" and "TABLESPACE xxx STORAGE DISK" --- mysql-test/r/ndb_dd_advance.result | 14 +++++++------- mysql-test/r/ndb_dd_advance2.result | 8 ++++---- mysql-test/r/ndb_dd_backuprestore.result | 12 ++++++------ mysql-test/r/ndb_dd_basic.result | 2 +- mysql-test/r/ndb_dd_disk2memory.result | 4 ++-- sql/sql_show.cc | 9 +++++---- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/ndb_dd_advance.result b/mysql-test/r/ndb_dd_advance.result index 09fe75805d5..64c30aab9ab 100644 --- a/mysql-test/r/ndb_dd_advance.result +++ b/mysql-test/r/ndb_dd_advance.result @@ -226,7 +226,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) NOT NULL, `c` int(11) NOT NULL, PRIMARY KEY (`pk1`) -) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; SHOW CREATE TABLE test.t2; @@ -236,7 +236,7 @@ t2 CREATE TABLE `t2` ( `b2` int(11) NOT NULL, `c2` int(11) NOT NULL, PRIMARY KEY (`pk2`) -) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t1 ENGINE=NDBCLUSTER; SHOW CREATE TABLE test.t1; Table Create Table @@ -331,7 +331,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL, `b` int(11) DEFAULT NULL, PRIMARY KEY (`a`) -) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -931,7 +931,7 @@ t1 CREATE TABLE `t1` ( `a1` int(11) DEFAULT NULL, `a2` blob, `a3` text -) TABLESPACE ts STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 DROP TABLE test.t1; CREATE TABLE test.t1 (a1 INT, a2 BLOB, a3 TEXT) ENGINE=MyISAM; SHOW CREATE TABLE test.t1; @@ -950,7 +950,7 @@ t1 CREATE TABLE `t1` ( `a1` int(11) DEFAULT NULL, `a2` blob, `a3` text -) TABLESPACE ts STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 DROP TABLE test.t1; CREATE TABLE test.t1 (a1 INT PRIMARY KEY, a2 BLOB, a3 TEXT) TABLESPACE ts STORAGE DISK ENGINE=NDB; SHOW CREATE TABLE test.t1; @@ -960,7 +960,7 @@ t1 CREATE TABLE `t1` ( `a2` blob, `a3` text, PRIMARY KEY (`a1`) -) TABLESPACE ts STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t1 ENGINE=InnoDB; SHOW CREATE TABLE test.t1; Table Create Table @@ -980,7 +980,7 @@ t1 CREATE TABLE `t1` ( `a1` int(11) DEFAULT NULL, `a2` blob, `a3` text -) TABLESPACE ts STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t1 ENGINE=MyISAM; SHOW CREATE TABLE test.t1; Table Create Table diff --git a/mysql-test/r/ndb_dd_advance2.result b/mysql-test/r/ndb_dd_advance2.result index c7fcda650e6..86dc8df3b15 100644 --- a/mysql-test/r/ndb_dd_advance2.result +++ b/mysql-test/r/ndb_dd_advance2.result @@ -30,7 +30,7 @@ t1 CREATE TABLE `t1` ( `a2` varchar(256) DEFAULT NULL, `a3` blob, PRIMARY KEY (`a1`) -) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 SHOW CREATE TABLE test.t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -38,7 +38,7 @@ t2 CREATE TABLE `t2` ( `a2` varchar(256) DEFAULT NULL, `a3` blob, PRIMARY KEY (`a1`) -) TABLESPACE ts2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 INSERT INTO test.t1 VALUES (1,'111111','aaaaaaaa'); INSERT INTO test.t1 VALUES (2,'222222','bbbbbbbb'); SELECT * FROM test.t1 ORDER BY a1; @@ -93,7 +93,7 @@ t1 CREATE TABLE `t1` ( `a2` varchar(5000) DEFAULT NULL, `a3` blob, PRIMARY KEY (`a1`) -) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 SHOW CREATE TABLE test.t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -101,7 +101,7 @@ t2 CREATE TABLE `t2` ( `a2` varchar(5000) DEFAULT NULL, `a3` blob, PRIMARY KEY (`a1`) -) TABLESPACE ts2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 INSERT INTO test.t1 VALUES (1,@vc1,@d1); INSERT INTO test.t1 VALUES (2,@vc2,@b1); INSERT INTO test.t1 VALUES (3,@vc3,@d2); diff --git a/mysql-test/r/ndb_dd_backuprestore.result b/mysql-test/r/ndb_dd_backuprestore.result index cb6c62b16da..1e03172b255 100644 --- a/mysql-test/r/ndb_dd_backuprestore.result +++ b/mysql-test/r/ndb_dd_backuprestore.result @@ -175,7 +175,7 @@ t1 CREATE TABLE `t1` ( `c3` int(11) NOT NULL, `c4` bit(1) NOT NULL, PRIMARY KEY (`pk1`,`c3`) -) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */ +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */ SHOW CREATE TABLE test.t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -184,7 +184,7 @@ t2 CREATE TABLE `t2` ( `c3` int(11) NOT NULL, `c4` bit(1) NOT NULL, PRIMARY KEY (`pk1`,`c3`) -) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ SHOW CREATE TABLE test.t3; Table Create Table t3 CREATE TABLE `t3` ( @@ -193,7 +193,7 @@ t3 CREATE TABLE `t3` ( `c3` int(11) NOT NULL, `c4` bit(1) NOT NULL, PRIMARY KEY (`pk1`,`c3`) -) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */ +) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */ SHOW CREATE TABLE test.t4; Table Create Table t4 CREATE TABLE `t4` ( @@ -341,7 +341,7 @@ t1 CREATE TABLE `t1` ( `c3` int(11) NOT NULL, `c4` bit(1) NOT NULL, PRIMARY KEY (`pk1`,`c3`) -) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */ +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */ SHOW CREATE TABLE test.t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -350,7 +350,7 @@ t2 CREATE TABLE `t2` ( `c3` int(11) NOT NULL, `c4` bit(1) NOT NULL, PRIMARY KEY (`pk1`,`c3`) -) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ SHOW CREATE TABLE test.t3; Table Create Table t3 CREATE TABLE `t3` ( @@ -359,7 +359,7 @@ t3 CREATE TABLE `t3` ( `c3` int(11) NOT NULL, `c4` bit(1) NOT NULL, PRIMARY KEY (`pk1`,`c3`) -) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */ +) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */ SHOW CREATE TABLE test.t4; Table Create Table t4 CREATE TABLE `t4` ( diff --git a/mysql-test/r/ndb_dd_basic.result b/mysql-test/r/ndb_dd_basic.result index 6c10fbe63b3..5a7e70e796d 100644 --- a/mysql-test/r/ndb_dd_basic.result +++ b/mysql-test/r/ndb_dd_basic.result @@ -49,7 +49,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) NOT NULL, `c` int(11) NOT NULL, PRIMARY KEY (`pk1`) -) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES (0, 0, 0); SELECT * FROM t1; pk1 b c diff --git a/mysql-test/r/ndb_dd_disk2memory.result b/mysql-test/r/ndb_dd_disk2memory.result index bd5bbda42f3..9084ddc3e16 100644 --- a/mysql-test/r/ndb_dd_disk2memory.result +++ b/mysql-test/r/ndb_dd_disk2memory.result @@ -226,7 +226,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) NOT NULL, `c` int(11) NOT NULL, PRIMARY KEY (`pk1`) -) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; SHOW CREATE TABLE test.t2; @@ -236,7 +236,7 @@ t2 CREATE TABLE `t2` ( `b2` int(11) NOT NULL, `c2` int(11) NOT NULL, PRIMARY KEY (`pk2`) -) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t1 ENGINE=NDBCLUSTER; SHOW CREATE TABLE test.t1; Table Create Table diff --git a/sql/sql_show.cc b/sql/sql_show.cc index cb3027e32fa..8d4a2c6c4b4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1215,9 +1215,10 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, store_key_options(thd, packet, table, key_info); if (key_info->parser) { - packet->append(" WITH PARSER ", 13); + packet->append(STRING_WITH_LEN(" /*!50100 WITH PARSER ")); append_identifier(thd, packet, key_info->parser->name.str, key_info->parser->name.length); + packet->append(STRING_WITH_LEN(" */ ")); } } @@ -1243,9 +1244,9 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, if ((for_str= file->get_tablespace_name(thd))) { - packet->append(" TABLESPACE "); + packet->append(STRING_WITH_LEN(" /*!50100 TABLESPACE ")); packet->append(for_str, strlen(for_str)); - packet->append(" STORAGE DISK"); + packet->append(STRING_WITH_LEN(" STORAGE DISK */")); my_free(for_str, MYF(0)); } @@ -1284,7 +1285,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, if(create_info.auto_increment_value > 1) { - packet->append(" AUTO_INCREMENT=", 16); + packet->append(STRING_WITH_LEN(" AUTO_INCREMENT=")); end= longlong10_to_str(create_info.auto_increment_value, buff,10); packet->append(buff, (uint) (end - buff)); } From df28e14b3a9935d2a4ba4a69453e8e8c2aed7ca1 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@alik." <> Date: Thu, 24 Aug 2006 16:29:24 +0400 Subject: [PATCH 043/119] Fix for BUG#16899: Possible buffer overflow in handling of DEFINER-clause User name (host name) has limit on length. The server code relies on these limits when storing the names. The problem was that sometimes these limits were not checked properly, so that could lead to buffer overflow. The fix is to check length of user/host name in parser and if string is too long, throw an error. --- mysql-test/r/grant.result | 24 ++++++++++++++++++ mysql-test/r/sp.result | 13 ++++++++++ mysql-test/r/trigger.result | 13 ++++++++++ mysql-test/r/view.result | 11 +++++++++ mysql-test/t/grant.test | 49 +++++++++++++++++++++++++++++++++++++ mysql-test/t/sp.test | 26 ++++++++++++++++++++ mysql-test/t/trigger.test | 30 +++++++++++++++++++++++ mysql-test/t/view.test | 27 ++++++++++++++++++++ sql/mysql_priv.h | 1 + sql/share/errmsg.txt | 6 +++++ sql/sql_acl.cc | 35 ++------------------------ sql/sql_parse.cc | 26 ++++++++++++++++++++ sql/sql_yacc.yy | 18 ++++++++------ 13 files changed, 238 insertions(+), 41 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 3f3325354ee..e755822c490 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -867,3 +867,27 @@ insert into mysql.user select * from t2; flush privileges; drop table t2; drop table t1; +GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +GRANT CREATE ON mysqltest.* TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) +REVOKE CREATE ON mysqltest.* FROM 1234567890abcdefGHIKL@localhost; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +REVOKE CREATE ON mysqltest.* FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) +GRANT CREATE ON t1 TO 1234567890abcdefGHIKL@localhost; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +GRANT CREATE ON t1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) +REVOKE CREATE ON t1 FROM 1234567890abcdefGHIKL@localhost; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +REVOKE CREATE ON t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) +GRANT EXECUTE ON PROCEDURE p1 TO 1234567890abcdefGHIKL@localhost; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +GRANT EXECUTE ON PROCEDURE p1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) +REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 229dab72422..80ddc1301f0 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5072,4 +5072,17 @@ a 1 use test| drop table t3| +DROP PROCEDURE IF EXISTS bug16899_p1| +DROP FUNCTION IF EXISTS bug16899_f1| +CREATE DEFINER=1234567890abcdefGHIKL@localhost PROCEDURE bug16899_p1() +BEGIN +SET @a = 1; +END| +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY +FUNCTION bug16899_f1() RETURNS INT +BEGIN +RETURN 1; +END| +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) drop table t1,t2; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 4fa7a9ca8bd..6f20c4987e1 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1089,4 +1089,17 @@ begin set @a:= 1; end| ERROR HY000: Triggers can not be created on system tables +use test| +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1(c INT); +CREATE TABLE t2(c INT); +CREATE DEFINER=1234567890abcdefGHIKL@localhost +TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY +TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW SET @a = 2; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) +DROP TABLE t1; +DROP TABLE t2; End of 5.0 tests diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 72cffb9531c..b5097ccba11 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2736,3 +2736,14 @@ m e 1 b DROP VIEW v1; DROP TABLE IF EXISTS t1,t2; +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +CREATE TABLE t1(a INT, b INT); +CREATE DEFINER=1234567890abcdefGHIKL@localhost +VIEW v1 AS SELECT a FROM t1; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY +VIEW v2 AS SELECT b FROM t1; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) +DROP TABLE t1; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index a9d52f559ca..94b63389771 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -681,3 +681,52 @@ drop table t2; drop table t1; +# +# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause. +# +# These checks are intended to ensure that appropriate errors are risen when +# illegal user name or hostname is specified in user-clause of GRANT/REVOKE +# statements. +# + +# Working with database-level privileges. + +--error ER_WRONG_STRING_LENGTH +GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost; + +--error ER_WRONG_STRING_LENGTH +GRANT CREATE ON mysqltest.* TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; + +--error ER_WRONG_STRING_LENGTH +REVOKE CREATE ON mysqltest.* FROM 1234567890abcdefGHIKL@localhost; + +--error ER_WRONG_STRING_LENGTH +REVOKE CREATE ON mysqltest.* FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; + +# Working with table-level privileges. + +--error ER_WRONG_STRING_LENGTH +GRANT CREATE ON t1 TO 1234567890abcdefGHIKL@localhost; + +--error ER_WRONG_STRING_LENGTH +GRANT CREATE ON t1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; + +--error ER_WRONG_STRING_LENGTH +REVOKE CREATE ON t1 FROM 1234567890abcdefGHIKL@localhost; + +--error ER_WRONG_STRING_LENGTH +REVOKE CREATE ON t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; + +# Working with routine-level privileges. + +--error ER_WRONG_STRING_LENGTH +GRANT EXECUTE ON PROCEDURE p1 TO 1234567890abcdefGHIKL@localhost; + +--error ER_WRONG_STRING_LENGTH +GRANT EXECUTE ON PROCEDURE p1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; + +--error ER_WRONG_STRING_LENGTH +REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost; + +--error ER_WRONG_STRING_LENGTH +REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 9a0003bab9c..8b002218175 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -5987,6 +5987,32 @@ select * from (select 1 as a) as t1 natural join (select * from test.t3) as t2| use test| drop table t3| + +# +# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause. +# + +# Prepare. + +--disable_warnings +DROP PROCEDURE IF EXISTS bug16899_p1| +DROP FUNCTION IF EXISTS bug16899_f1| +--enable_warnings + +--error ER_WRONG_STRING_LENGTH +CREATE DEFINER=1234567890abcdefGHIKL@localhost PROCEDURE bug16899_p1() +BEGIN + SET @a = 1; +END| + +--error ER_WRONG_STRING_LENGTH +CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY + FUNCTION bug16899_f1() RETURNS INT +BEGIN + RETURN 1; +END| + + # # BUG#NNNN: New bug synopsis # diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 6c9b5063f32..7845a4f7730 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1301,6 +1301,36 @@ create trigger wont_work after update on event for each row begin set @a:= 1; end| +use test| delimiter ;| + +# +# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause. +# + +# Prepare. + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings + +CREATE TABLE t1(c INT); +CREATE TABLE t2(c INT); + +--error ER_WRONG_STRING_LENGTH +CREATE DEFINER=1234567890abcdefGHIKL@localhost + TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1; + +--error ER_WRONG_STRING_LENGTH +CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY + TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW SET @a = 2; + +# Cleanup. + +DROP TABLE t1; +DROP TABLE t2; + + --echo End of 5.0 tests diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index a1c1e9b2ad1..c381b0d445a 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2596,3 +2596,30 @@ SELECT * FROM t2; DROP VIEW v1; DROP TABLE IF EXISTS t1,t2; + + +# +# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause. +# + +# Prepare. + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +--enable_warnings + +CREATE TABLE t1(a INT, b INT); + +--error ER_WRONG_STRING_LENGTH +CREATE DEFINER=1234567890abcdefGHIKL@localhost + VIEW v1 AS SELECT a FROM t1; + +--error ER_WRONG_STRING_LENGTH +CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY + VIEW v2 AS SELECT b FROM t1; + +# Cleanup. + +DROP TABLE t1; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index dffd2677d0d..c1b1633d241 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -537,6 +537,7 @@ int append_query_string(CHARSET_INFO *csinfo, void get_default_definer(THD *thd, LEX_USER *definer); LEX_USER *create_default_definer(THD *thd); LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name); +bool check_string_length(LEX_STRING *str, const char *err_msg, uint max_length); enum enum_mysql_completiontype { ROLLBACK_RELEASE=-2, ROLLBACK=1, ROLLBACK_AND_CHAIN=7, diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 9b20c37ece2..208ac72e4e4 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5621,3 +5621,9 @@ ER_TABLE_CANT_HANDLE_SPKEYS eng "The used table type doesn't support SPATIAL indexes" ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA eng "Triggers can not be created on system tables" +ER_USERNAME + eng "user name" +ER_HOSTNAME + eng "host name" +ER_WRONG_STRING_LENGTH + eng "String '%-.70s' is too long for %s (should be no longer than %d)" diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 124d3566b19..f86800fcbea 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2895,14 +2895,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, { int error; GRANT_TABLE *grant_table; - if (Str->host.length > HOSTNAME_LENGTH || - Str->user.length > USERNAME_LENGTH) - { - my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER), - MYF(0)); - result= TRUE; - continue; - } + /* Create user if needed */ error=replace_user_table(thd, tables[0].table, *Str, 0, revoke_grant, create_new_users, @@ -3102,15 +3095,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, { int error; GRANT_NAME *grant_name; - if (Str->host.length > HOSTNAME_LENGTH || - Str->user.length > USERNAME_LENGTH) - { - if (!no_error) - my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER), - MYF(0)); - result= TRUE; - continue; - } + /* Create user if needed */ error=replace_user_table(thd, tables[0].table, *Str, 0, revoke_grant, create_new_users, @@ -3231,14 +3216,6 @@ bool mysql_grant(THD *thd, const char *db, List &list, int result=0; while ((Str = str_list++)) { - if (Str->host.length > HOSTNAME_LENGTH || - Str->user.length > USERNAME_LENGTH) - { - my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER), - MYF(0)); - result= -1; - continue; - } if (replace_user_table(thd, tables[0].table, *Str, (!db ? rights : 0), revoke_grant, create_new_users, test(thd->variables.sql_mode & @@ -4129,14 +4106,6 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) DBUG_RETURN(TRUE); } - if (lex_user->host.length > HOSTNAME_LENGTH || - lex_user->user.length > USERNAME_LENGTH) - { - my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER), - MYF(0)); - DBUG_RETURN(TRUE); - } - rw_rdlock(&LOCK_grant); VOID(pthread_mutex_lock(&acl_cache->lock)); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4c542234d4f..a41da2fb4cc 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7499,3 +7499,29 @@ LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name) return definer; } + + +/* + Check that length of a string does not exceed some limit. + + SYNOPSIS + check_string_length() + str string to be checked + err_msg error message to be displayed if the string is too long + max_length max length + + RETURN + FALSE the passed string is not longer than max_length + TRUE the passed string is longer than max_length +*/ + +bool check_string_length(LEX_STRING *str, const char *err_msg, + uint max_length) +{ + if (str->length <= max_length) + return FALSE; + + my_error(ER_WRONG_STRING_LENGTH, MYF(0), str->str, err_msg, max_length); + + return TRUE; +} diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 952a8eb44ea..616b142a478 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7479,6 +7479,9 @@ user: $$->user = $1; $$->host.str= (char *) "%"; $$->host.length= 1; + + if (check_string_length(&$$->user, ER(ER_USERNAME), USERNAME_LENGTH)) + YYABORT; } | ident_or_text '@' ident_or_text { @@ -7486,6 +7489,11 @@ user: if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user)))) YYABORT; $$->user = $1; $$->host=$3; + + if (check_string_length(&$$->user, ER(ER_USERNAME), USERNAME_LENGTH) || + check_string_length(&$$->host, ER(ER_HOSTNAME), + HOSTNAME_LENGTH)) + YYABORT; } | CURRENT_USER optional_braces { @@ -8966,15 +8974,9 @@ definer: */ YYTHD->lex->definer= 0; } - | DEFINER_SYM EQ CURRENT_USER optional_braces + | DEFINER_SYM EQ user { - if (! (YYTHD->lex->definer= create_default_definer(YYTHD))) - YYABORT; - } - | DEFINER_SYM EQ ident_or_text '@' ident_or_text - { - if (!(YYTHD->lex->definer= create_definer(YYTHD, &$3, &$5))) - YYABORT; + YYTHD->lex->definer= $3; } ; From 8bc745456f2ebcce9ebde0137aeb918f3b9af383 Mon Sep 17 00:00:00 2001 From: "iggy@rolltop.ignatz42.dyndns.org" <> Date: Thu, 24 Aug 2006 11:15:08 -0400 Subject: [PATCH 044/119] Bug #11972: client uses wrong character set after reconnect. The mysql client uses the default character set on reconnect. The default character set is now controled by the client charset command while the client is running. The charset command now also issues a SET NAMES command to the server to make sure that the client's charset settings are in sync with the server's. --- client/mysql.cc | 3 +++ mysql-test/r/mysql.result | 14 +++++++------- mysql-test/t/mysql.test | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 6af9be965bb..b39a05bc61c 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1974,6 +1974,9 @@ com_charset(String *buffer __attribute__((unused)), char *line) if (new_cs) { charset_info= new_cs; + mysql_set_character_set(&mysql, charset_info->csname); + default_charset= (char *)charset_info->csname; + default_charset_used= 1; put_info("Charset changed", INFO_INFO); } else put_info("Charset is not found", INFO_INFO); diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index ba4e9daf7cb..99633f5e12a 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -59,16 +59,16 @@ database() test unlock tables; drop table t1; -ソ -ソ +ƒ\ +ƒ\ c_cp932 +ƒ\ +ƒ\ +ƒ\ ソ ソ -ソ -ソ -ソ -ソ -ソ +ƒ\ +ƒ\ +----------------------+------------+--------+ | concat('>',col1,'<') | col2 | col3 | +----------------------+------------+--------+ diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 385c59d1503..cf4e6f4047c 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -52,8 +52,8 @@ drop table t1; --exec $MYSQL --default-character-set=cp932 test -e "charset utf8;" # its usage to switch internally in mysql to requested charset ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; set @@session.character_set_client= cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;" ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; set character_set_client= cp932; select 'ƒ\'" +--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;" +--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'" --exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'" --exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'" From 17a3c45122b701de22925fbbf09a5ff864ecd29e Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Fri, 25 Aug 2006 17:59:47 +0400 Subject: [PATCH 045/119] Added stacktrace dumps for x86_64 (bug #21250) Fixed stacktrace dumps for i386/NPTL --- sql/stacktrace.c | 51 ++++++++++++++++++++++++++++++++++-------------- sql/stacktrace.h | 8 ++++++-- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/sql/stacktrace.c b/sql/stacktrace.c index 838f547dc02..d82c7c2a384 100644 --- a/sql/stacktrace.c +++ b/sql/stacktrace.c @@ -21,6 +21,7 @@ #ifdef HAVE_STACKTRACE #include +#include #define PTR_SANE(p) ((p) && (char*)(p) >= heap_start && (char*)(p) <= heap_end) @@ -44,7 +45,25 @@ void safe_print_str(const char* name, const char* val, int max_len) } #ifdef TARGET_OS_LINUX -#define SIGRETURN_FRAME_COUNT 2 + +#ifdef __i386__ +#define SIGRETURN_FRAME_OFFSET 17 +#endif + +#ifdef __x86_64__ +#define SIGRETURN_FRAME_OFFSET 23 +#endif + +static my_bool is_nptl; + +/* Check if we are using NPTL or LinuxThreads on Linux */ +void check_thread_lib(void) +{ + char buf[5]; + + confstr(_CS_GNU_LIBPTHREAD_VERSION, buf, sizeof(buf)); + is_nptl = !strncasecmp(buf, "NPTL", sizeof(buf)); +} #if defined(__alpha__) && defined(__GNUC__) /* @@ -90,7 +109,7 @@ inline uint32* find_prev_pc(uint32* pc, uchar** fp) void print_stacktrace(gptr stack_bottom, ulong thread_stack) { uchar** fp; - uint frame_count = 0; + uint frame_count = 0, sigreturn_frame_count; #if defined(__alpha__) && defined(__GNUC__) uint32* pc; #endif @@ -100,28 +119,27 @@ void print_stacktrace(gptr stack_bottom, ulong thread_stack) Attempting backtrace. You can use the following information to find out\n\ where mysqld died. If you see no messages after this, something went\n\ terribly wrong...\n"); -#ifdef __i386__ +#ifdef __i386__ __asm __volatile__ ("movl %%ebp,%0" :"=r"(fp) :"r"(fp)); - if (!fp) - { - fprintf(stderr, "frame pointer (ebp) is NULL, did you compile with\n\ --fomit-frame-pointer? Aborting backtrace!\n"); - return; - } +#endif +#ifdef __x86_64__ + __asm __volatile__ ("movq %%rbp,%0" + :"=r"(fp) + :"r"(fp)); #endif #if defined(__alpha__) && defined(__GNUC__) __asm __volatile__ ("mov $30,%0" :"=r"(fp) :"r"(fp)); +#endif if (!fp) { - fprintf(stderr, "frame pointer (fp) is NULL, did you compile with\n\ + fprintf(stderr, "frame pointer is NULL, did you compile with\n\ -fomit-frame-pointer? Aborting backtrace!\n"); return; } -#endif /* __alpha__ */ if (!stack_bottom || (gptr) stack_bottom > (gptr) &fp) { @@ -151,13 +169,16 @@ terribly wrong...\n"); :"r"(pc)); #endif /* __alpha__ */ + /* We are 1 frame above signal frame with NPTL and 2 frames above with LT */ + sigreturn_frame_count = is_nptl ? 1 : 2; + while (fp < (uchar**) stack_bottom) { -#ifdef __i386__ +#if defined(__i386__) || defined(__x86_64__) uchar** new_fp = (uchar**)*fp; - fprintf(stderr, "%p\n", frame_count == SIGRETURN_FRAME_COUNT ? - *(fp+17) : *(fp+1)); -#endif /* __386__ */ + fprintf(stderr, "%p\n", frame_count == sigreturn_frame_count ? + *(fp + SIGRETURN_FRAME_OFFSET) : *(fp + 1)); +#endif /* defined(__386__) || defined(__x86_64__) */ #if defined(__alpha__) && defined(__GNUC__) uchar** new_fp = find_prev_fp(pc, fp); diff --git a/sql/stacktrace.h b/sql/stacktrace.h index d5d1e05ef0e..527d10d70a2 100644 --- a/sql/stacktrace.h +++ b/sql/stacktrace.h @@ -19,16 +19,20 @@ extern "C" { #endif #ifdef TARGET_OS_LINUX -#if defined(HAVE_STACKTRACE) || (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) +#if defined(HAVE_STACKTRACE) || (defined (__x86_64__) || defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) #undef HAVE_STACKTRACE #define HAVE_STACKTRACE extern char* __bss_start; extern char* heap_start; -#define init_stacktrace() { heap_start = (char*) &__bss_start; } +#define init_stacktrace() do { \ + heap_start = (char*) &__bss_start; \ + check_thread_lib(); \ + } while(0); void print_stacktrace(gptr stack_bottom, ulong thread_stack); void safe_print_str(const char* name, const char* val, int max_len); +void check_thread_lib(void); #endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */ #endif /* TARGET_OS_LINUX */ From 89d759b93e3975e5d5e1c5cf9b901c01b9e80ff7 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Fri, 25 Aug 2006 11:54:33 -0400 Subject: [PATCH 046/119] Bug#21543: 5.0.24 breaks ABI compatibility for python bindings: \ InterfaceError on connect Removed the bool flag from the st_mysql_options struct, since it adds another word in size to the memory size and shifts member memory locations down, both of which break binary-interface compatibility. Instead, use a flag, 2**30, in the client_options bit-field to represent that the client should check the SSL certificate of the server. --- include/mysql.h | 1 - include/mysql_com.h | 6 ++++-- sql-common/client.c | 8 +++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index 3a71e47f414..b2efa2ffd3b 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -165,7 +165,6 @@ struct st_mysql_options { char *ssl_ca; /* PEM CA file */ char *ssl_capath; /* PEM directory of CA-s? */ char *ssl_cipher; /* cipher to use */ - my_bool ssl_verify_server_cert; /* if to verify server cert */ char *shared_memory_base_name; unsigned long max_allowed_packet; my_bool use_ssl; /* if to use SSL or not */ diff --git a/include/mysql_com.h b/include/mysql_com.h index ec1c133799f..d60cfd8d8d8 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -134,8 +134,10 @@ enum enum_server_command #define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ #define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */ #define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ -#define CLIENT_MULTI_STATEMENTS 65536 /* Enable/disable multi-stmt support */ -#define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */ +#define CLIENT_MULTI_STATEMENTS (((ulong) 1) << 16) /* Enable/disable multi-stmt support */ +#define CLIENT_MULTI_RESULTS (((ulong) 1) << 17) /* Enable/disable multi-results */ + +#define CLIENT_SSL_VERIFY_SERVER_CERT (((ulong) 1) << 30) #define CLIENT_REMEMBER_OPTIONS (((ulong) 1) << 31) #define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ diff --git a/sql-common/client.c b/sql-common/client.c index 31e85475f08..a8e87ff4d2e 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1502,7 +1502,6 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , 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); - mysql->options.ssl_verify_server_cert= FALSE; /* Off by default */ #endif /* HAVE_OPENSSL */ DBUG_RETURN(0); } @@ -2162,7 +2161,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, DBUG_PRINT("info", ("IO layer change done!")); /* Verify server cert */ - if (mysql->options.ssl_verify_server_cert && + if ((client_flag & CLIENT_SSL_VERIFY_SERVER_CERT) && ssl_verify_server_cert(mysql->net.vio, mysql->host)) { set_mysql_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate); @@ -2909,7 +2908,10 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) mysql->reconnect= *(my_bool *) arg; break; case MYSQL_OPT_SSL_VERIFY_SERVER_CERT: - mysql->options.ssl_verify_server_cert= *(my_bool *) arg; + if (!arg || test(*(uint*) arg)) + mysql->options.client_flag|= CLIENT_SSL_VERIFY_SERVER_CERT; + else + mysql->options.client_flag&= ~CLIENT_SSL_VERIFY_SERVER_CERT; break; default: DBUG_RETURN(1); From b0619ace21bd8ae74e0f8d6c8a7f898fb39bf2ef Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Sat, 26 Aug 2006 10:21:26 +0400 Subject: [PATCH 047/119] Post-review fix (bug #21250) --- sql/stacktrace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/stacktrace.c b/sql/stacktrace.c index d82c7c2a384..43f35c452f7 100644 --- a/sql/stacktrace.c +++ b/sql/stacktrace.c @@ -61,8 +61,12 @@ void check_thread_lib(void) { char buf[5]; +#ifdef _CS_GNU_LIBPTHREAD_VERSION confstr(_CS_GNU_LIBPTHREAD_VERSION, buf, sizeof(buf)); is_nptl = !strncasecmp(buf, "NPTL", sizeof(buf)); +#else + is_nptl = 0; +#endif } #if defined(__alpha__) && defined(__GNUC__) From bfe86ca4484fc0c9cabfc34d3ff027f3487e8d4a Mon Sep 17 00:00:00 2001 From: "iggy@rolltop.ignatz42.dyndns.org" <> Date: Mon, 28 Aug 2006 17:48:06 -0400 Subject: [PATCH 048/119] Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the information_schema database. init_dumping now accepts a function pointer to the table or view specific init_dumping function. This allows both tables and views to use the init_dumping function. --- client/mysqldump.c | 130 ++++++++++++++++++++-------------- mysql-test/r/mysqldump.result | 14 ++++ mysql-test/t/mysqldump.test | 30 ++++++++ 3 files changed, 122 insertions(+), 52 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 5ecf334c9f7..45aa2146d0f 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -417,7 +417,9 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row, int string_value); static int dump_selected_tables(char *db, char **table_names, int tables); static int dump_all_tables_in_db(char *db); -static int init_dumping(char *); +static int init_dumping_views(char *); +static int init_dumping_tables(char *); +static int init_dumping(char *, int init_func(char*)); static int dump_databases(char **); static int dump_all_databases(); static char *quote_name(const char *name, char *buff, my_bool force); @@ -2635,7 +2637,76 @@ static int dump_databases(char **db_names) } /* dump_databases */ -static int init_dumping(char *database) +/* +View Specific database initalization. + +SYNOPSIS + init_dumping_views + qdatabase quoted name of the database + +RETURN VALUES + 0 Success. + 1 Failure. +*/ +int init_dumping_views(char *qdatabase) +{ + return 0; +} /* init_dumping_views */ + + +/* +Table Specific database initalization. + +SYNOPSIS + init_dumping_tables + qdatabase quoted name of the database + +RETURN VALUES + 0 Success. + 1 Failure. +*/ +int init_dumping_tables(char *qdatabase) +{ + if (!opt_create_db) + { + char qbuf[256]; + MYSQL_ROW row; + MYSQL_RES *dbinfo; + + my_snprintf(qbuf, sizeof(qbuf), + "SHOW CREATE DATABASE IF NOT EXISTS %s", + qdatabase); + + if (mysql_query(mysql, qbuf) || !(dbinfo = mysql_store_result(mysql))) + { + /* Old server version, dump generic CREATE DATABASE */ + if (opt_drop_database) + fprintf(md_result_file, + "\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n", + qdatabase); + fprintf(md_result_file, + "\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n", + qdatabase); + } + else + { + if (opt_drop_database) + fprintf(md_result_file, + "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n", + qdatabase); + row = mysql_fetch_row(dbinfo); + if (row[1]) + { + fprintf(md_result_file,"\n%s;\n",row[1]); + } + } + } + + return 0; +} /* init_dumping_tables */ + + +static int init_dumping(char *database, int init_func(char*)) { if (mysql_get_server_version(mysql) >= 50003 && !my_strcasecmp(&my_charset_latin1, database, "information_schema")) @@ -2660,40 +2731,10 @@ static int init_dumping(char *database) fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase); check_io(md_result_file); } - if (!opt_create_db) - { - char qbuf[256]; - MYSQL_ROW row; - MYSQL_RES *dbinfo; - my_snprintf(qbuf, sizeof(qbuf), - "SHOW CREATE DATABASE IF NOT EXISTS %s", - qdatabase); + /* Call the view or table specific function */ + init_func(qdatabase); - if (mysql_query(mysql, qbuf) || !(dbinfo = mysql_store_result(mysql))) - { - /* Old server version, dump generic CREATE DATABASE */ - if (opt_drop_database) - fprintf(md_result_file, - "\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n", - qdatabase); - fprintf(md_result_file, - "\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n", - qdatabase); - } - else - { - if (opt_drop_database) - fprintf(md_result_file, - "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n", - qdatabase); - row = mysql_fetch_row(dbinfo); - if (row[1]) - { - fprintf(md_result_file,"\n%s;\n",row[1]); - } - } - } fprintf(md_result_file,"\nUSE %s;\n", qdatabase); check_io(md_result_file); } @@ -2725,7 +2766,7 @@ static int dump_all_tables_in_db(char *database) afterdot= strmov(hash_key, database); *afterdot++= '.'; - if (init_dumping(database)) + if (init_dumping(database, init_dumping_tables)) return 1; if (opt_xml) print_xml_tag1(md_result_file, "", "database name=", database, "\n"); @@ -2797,23 +2838,8 @@ static my_bool dump_all_views_in_db(char *database) uint numrows; char table_buff[NAME_LEN*2+3]; - if (mysql_select_db(mysql, database)) - { - DB_error(mysql, "when selecting the database"); + if (init_dumping(database, init_dumping_views)) return 1; - } - if (opt_databases || opt_alldbs) - { - char quoted_database_buf[NAME_LEN*2+3]; - char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted); - if (opt_comments) - { - fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase); - check_io(md_result_file); - } - fprintf(md_result_file,"\nUSE %s;\n", qdatabase); - check_io(md_result_file); - } if (opt_xml) print_xml_tag1(md_result_file, "", "database name=", database, "\n"); if (lock_tables) @@ -2908,7 +2934,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) char **dump_tables, **pos, **end; DBUG_ENTER("dump_selected_tables"); - if (init_dumping(db)) + if (init_dumping(db, init_dumping_tables)) return 1; init_alloc_root(&root, 8192, 0); diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 6669b33e1bb..d62d780d3dd 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -2892,3 +2892,17 @@ CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1; drop table t1; drop user mysqltest_1@localhost; +create database mysqldump_myDB; +use mysqldump_myDB; +create user myDB_User; +grant create view, select on mysqldump_myDB.* to myDB_User@localhost; +create table t1 (c1 int); +insert into t1 values (3); +use mysqldump_myDB; +create view v1 (c1) as select * from t1; +use mysqldump_myDB; +drop view v1; +drop table t1; +revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; +drop user myDB_User; +drop database mysqldump_myDB; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 848c5360db7..2c3bc2a157b 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1309,3 +1309,33 @@ grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; # Clean up drop table t1; drop user mysqltest_1@localhost; + +# +# Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the +# information_schema database. +# +connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +connection root; +create database mysqldump_myDB; +use mysqldump_myDB; +create user myDB_User; +grant create view, select on mysqldump_myDB.* to myDB_User@localhost; +create table t1 (c1 int); +insert into t1 values (3); + +connect (user1,localhost,myDB_User,,mysqldump_myDB,$MASTER_MYPORT,$MASTER_MYSOCK); +connection user1; +use mysqldump_myDB; +create view v1 (c1) as select * from t1; + +# Backup should not fail. +--exec $MYSQL_DUMP --all-databases --add-drop-table > $MYSQLTEST_VARDIR/tmp/bug21527.sql + +# Clean up +connection root; +use mysqldump_myDB; +drop view v1; +drop table t1; +revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; +drop user myDB_User; +drop database mysqldump_myDB; From 54e73e93d7b6f355e3faace09940b62ef53cfdf5 Mon Sep 17 00:00:00 2001 From: "tsmith@maint1.mysql.com" <> Date: Tue, 29 Aug 2006 01:13:06 +0200 Subject: [PATCH 049/119] minor portability fix in SETUP.sh --- BUILD/SETUP.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 150f9e28b41..2b47f0daacd 100644 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -1,4 +1,4 @@ -if ! test -f sql/mysqld.cc +if test ! -f sql/mysqld.cc then echo "You must run this script from the MySQL top-level directory" exit 1 @@ -81,12 +81,6 @@ fi # (returns 0 if finds lines) if ccache -V > /dev/null 2>&1 then - if ! (echo "$CC" | grep "ccache" > /dev/null) - then - CC="ccache $CC" - fi - if ! (echo "$CXX" | grep "ccache" > /dev/null) - then - CXX="ccache $CXX" - fi + echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC" + echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX" fi From 5de6240a93803400cda6622164acdb6ca60a4f62 Mon Sep 17 00:00:00 2001 From: "iggy@rolltop.ignatz42.dyndns.org" <> Date: Mon, 28 Aug 2006 21:13:55 -0400 Subject: [PATCH 050/119] Post merge changes. --- mysql-test/r/mysqldump.result | 10 +++++----- mysql-test/t/mysqldump.test | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index d5f243905c4..eb26b0324e7 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -434,7 +434,7 @@ USE `mysqldump_test_db`; drop database mysqldump_test_db; CREATE TABLE t1 (a CHAR(10)); -INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); +INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -479,7 +479,7 @@ CREATE TABLE `t1` ( LOCK TABLES `t1` WRITE; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT INTO `t1` VALUES ('Ž™šá'); +INSERT INTO `t1` VALUES ('Ž™šá'); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -502,7 +502,7 @@ CREATE TABLE `t1` ( LOCK TABLES `t1` WRITE; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT INTO `t1` VALUES ('Ž™šá'); +INSERT INTO `t1` VALUES ('Ž™šá'); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -1676,11 +1676,11 @@ create table t1 (a text character set utf8, b text character set latin1); insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E); select * from t1; a b -Osnabrück Köln +Osnabrück Köln test.t1: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0 select * from t1; a b -Osnabrück Köln +Osnabrück Köln drop table t1; create table `t1` ( t1_name varchar(255) default null, diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 9f22ad0b23d..545edcac315 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -153,7 +153,7 @@ drop database mysqldump_test_db; # if it is explicitely set. CREATE TABLE t1 (a CHAR(10)); -INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); +INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); --exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments test t1 # # Bug#8063: make test mysqldump [ fail ] From 6233d8c6968e64d5f09d650bb2ca4269f0aa283c Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Tue, 29 Aug 2006 09:30:58 -0400 Subject: [PATCH 051/119] Correcting bad merge. --- mysql-test/r/partition_mgm.result | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index 5ee12259312..f64ffaff495 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -7,12 +7,12 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2 */ -hello/master-data/test/t1.frm -hello/master-data/test/t1.par hello/master-data/test/t1#P#p0.MYD hello/master-data/test/t1#P#p0.MYI hello/master-data/test/t1#P#p1.MYD hello/master-data/test/t1#P#p1.MYI +hello/master-data/test/t1.frm +hello/master-data/test/t1.par ALTER TABLE t1 COALESCE PARTITION 1; SHOW CREATE TABLE t1; Table Create Table @@ -20,10 +20,10 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 1 */ -hello/master-data/test/t1.frm -hello/master-data/test/t1.par hello/master-data/test/t1#P#p0.MYD hello/master-data/test/t1#P#p0.MYI +hello/master-data/test/t1.frm +hello/master-data/test/t1.par drop table t1; create table t1 (a int) partition by list (a) From 73625c3a11c34efeefb33aa9611776a4dcb85d81 Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Tue, 29 Aug 2006 17:37:48 +0200 Subject: [PATCH 052/119] Fix for BUG#20866 "show table status on innodb raises assertion" and its duplicate BUG#19057 "Test 'rpl_row_func003' fails on SuSE SLES9 x86". It was an assertion failure, only in debug builds, not present in released versions (nothing to document). It happened when doing SHOW TABLE STATUS on an InnoDB table having an auto_increment column, right after creating the table. The test which would have caught this problem was disabled in mid-April for another reason (how much I like tests disabled for months...). --- mysql-test/t/disabled.def | 1 - sql/ha_innodb.cc | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 644c379d746..9e6c3e3d5cc 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -34,7 +34,6 @@ rpl_ndb_innodb2ndb : Bug #19710 Cluster replication to partition table fa #rpl_ndb_log : BUG#18947 2006-03-21 tomas CRBR: order in binlog of create table and insert (on different table) not determ rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly -rpl_row_func003 : BUG#19074 2006-13-04 andrei test failed rpl_sp : BUG#16456 2006-02-16 jmiller rpl_sp_effects : BUG#19862 2006-06-15 mkindahl diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index fc7dff3a41e..6145b6518a8 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -7067,10 +7067,16 @@ ha_innobase::innobase_read_and_init_auto_inc( 'found_next_number_field' below because MySQL in SHOW TABLE STATUS does not seem to set 'next_number_field'. The comment in table.h says that 'next_number_field' is set when it is - 'active'. */ + 'active'. + Since 5.1 MySQL enforces that we announce fields which we will + read; as we only do a val_*() call, dbug_tmp_use_all_columns() + with read_set is sufficient. */ + my_bitmap_map *old_map; + old_map= dbug_tmp_use_all_columns(table, table->read_set); auto_inc = (longlong) table->found_next_number_field-> val_int_offset(table->s->rec_buff_length) + 1; + dbug_tmp_restore_column_map(table->read_set, old_map); } dict_table_autoinc_initialize(prebuilt->table, auto_inc); From 5c3ac45ca49bb9d8df3ef1be928c5d20b9bb2f0d Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Tue, 29 Aug 2006 11:58:12 -0700 Subject: [PATCH 053/119] Re'ordering of startup. Fixed Execution path issues. Added function for de'initing everything. This includes Antony's suggestions (bk collapse uber alles!) --- sql/handler.cc | 6 -- sql/mysqld.cc | 7 +- sql/sql_plugin.cc | 196 +++++++++++++++++++++++++--------------------- sql/sql_plugin.h | 7 +- 4 files changed, 112 insertions(+), 104 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index dd1be47e3c2..465919d49a8 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -430,12 +430,6 @@ int ha_initialize_handlerton(st_plugin_int *plugin) savepoint_alloc_size+= tmp; hton->slot= total_ha++; hton2plugin[hton->slot]=plugin; - /* This is just a temp need until plugin/engine startup is fixed */ - if (plugin->plugin->status_vars) - { - add_status_vars(plugin->plugin->status_vars); - } - if (hton->prepare) total_ha_2pc++; break; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 46f5e0ae4e9..9b2f61ee2cf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1186,7 +1186,7 @@ void clean_up(bool print_message) udf_free(); #endif } - plugin_free(); + plugin_shutdown(); if (tc_log) tc_log->close(); xid_cache_free(); @@ -2629,7 +2629,7 @@ static int init_common_variables(const char *conf_file_name, int argc, /* Add server status variables to the dynamic list of status variables that is shown by SHOW STATUS. - Later, in plugin_init, plugin_load, and mysql_install_plugin + Later, in plugin_init, and mysql_install_plugin new entries could be added to that list. */ if (add_status_vars(status_vars)) @@ -3178,7 +3178,7 @@ server."); using_update_log=1; } - if (plugin_init()) + if (plugin_init(0)) { sql_print_error("Failed to init plugins."); return 1; @@ -3610,7 +3610,6 @@ we force server id to 2, but this MySQL server will not act as a slave."); if (!opt_noacl) { - plugin_load(); #ifdef HAVE_DLOPEN udf_init(); #endif diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 074999a52cf..9db7c743a40 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -63,6 +63,10 @@ static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM]; static rw_lock_t THR_LOCK_plugin; static bool initialized= 0; +/* prototypes */ +my_bool plugin_register_builtin(struct st_mysql_plugin *plugin); +void plugin_load(void); + static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *dl) { uint i; @@ -442,15 +446,6 @@ static my_bool plugin_add(const LEX_STRING *name, const LEX_STRING *dl, int repo tmp.name.length= name_len; tmp.ref_count= 0; tmp.state= PLUGIN_IS_UNINITIALIZED; - if (plugin->status_vars) - { - SHOW_VAR array[2]= { - {plugin->name, (char*)plugin->status_vars, SHOW_ARRAY}, - {0, 0, SHOW_UNDEF} - }; - if (add_status_vars(array)) // add_status_vars makes a copy - goto err; - } if (! (tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) goto err; if (my_hash_insert(&plugin_hash[plugin->type], (byte*)tmp_plugin_ptr)) @@ -466,19 +461,38 @@ static my_bool plugin_add(const LEX_STRING *name, const LEX_STRING *dl, int repo if (report & REPORT_TO_LOG) sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), name->str); err: - if (plugin->status_vars) - { - SHOW_VAR array[2]= { - {plugin->name, (char*)plugin->status_vars, SHOW_ARRAY}, - {0, 0, SHOW_UNDEF} - }; - remove_status_vars(array); - } plugin_dl_del(dl); DBUG_RETURN(TRUE); } +void plugin_deinitializer(struct st_plugin_int *plugin) +{ + if (plugin->plugin->status_vars) + { + SHOW_VAR array[2]= { + {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, + {0, 0, SHOW_UNDEF} + }; + remove_status_vars(array); + } + + if (plugin->state == PLUGIN_IS_READY) + { + if (plugin->plugin->deinit) + { + DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str)); + if (plugin->plugin->deinit()) + { + DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.", + plugin->name.str)); + } + } + plugin->state= PLUGIN_IS_UNINITIALIZED; + } +} + + static void plugin_del(const LEX_STRING *name) { uint i; @@ -486,14 +500,7 @@ static void plugin_del(const LEX_STRING *name) DBUG_ENTER("plugin_del"); if ((plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN))) { - if (plugin->plugin->status_vars) - { - SHOW_VAR array[2]= { - {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, - {0, 0, SHOW_UNDEF} - }; - remove_status_vars(array); - } + plugin_deinitializer(plugin); hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin); plugin_dl_del(&plugin->plugin_dl->dl); plugin->state= PLUGIN_IS_FREED; @@ -523,6 +530,26 @@ static int plugin_initialize(struct st_plugin_int *plugin) { DBUG_ENTER("plugin_initialize"); + if (plugin->plugin->status_vars) + { +#ifdef FIX_LATER + /* + We have a problem right now where we can not prepend without + breaking backwards compatibility. We will fix this shortly so + that engines have "use names" and we wil use those for + CREATE TABLE, and use the plugin name then for adding automatic + variable names. + */ + SHOW_VAR array[2]= { + {plugin->name, (char*)plugin->status_vars, SHOW_ARRAY}, + {0, 0, SHOW_UNDEF} + }; + if (add_status_vars(array)) // add_status_vars makes a copy + goto err; +#else + add_status_vars(plugin->plugin->status_vars); // add_status_vars makes a copy +#endif /* FIX_LATER */ + } if (plugin->plugin->init) { if (plugin->plugin->init()) @@ -540,6 +567,8 @@ static int plugin_initialize(struct st_plugin_int *plugin) goto err; } + plugin->state= PLUGIN_IS_READY; + DBUG_RETURN(0); err: DBUG_RETURN(1); @@ -592,52 +621,6 @@ err: DBUG_RETURN(1); } -static void plugin_call_initializer(void) -{ - uint i; - DBUG_ENTER("plugin_call_initializer"); - for (i= 0; i < plugin_array.elements; i++) - { - struct st_plugin_int *tmp= dynamic_element(&plugin_array, i, - struct st_plugin_int *); - if (tmp->state == PLUGIN_IS_UNINITIALIZED) - { - if (plugin_initialize(tmp)) - plugin_del(&tmp->name); - else - tmp->state= PLUGIN_IS_READY; - } - } - DBUG_VOID_RETURN; -} - - -static void plugin_call_deinitializer(void) -{ - uint i; - DBUG_ENTER("plugin_call_deinitializer"); - for (i= 0; i < plugin_array.elements; i++) - { - struct st_plugin_int *tmp= dynamic_element(&plugin_array, i, - struct st_plugin_int *); - if (tmp->state == PLUGIN_IS_READY) - { - if (tmp->plugin->deinit) - { - DBUG_PRINT("info", ("Deinitializing plugin: '%s'", tmp->name.str)); - if (tmp->plugin->deinit()) - { - DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.", - tmp->name.str)); - } - } - tmp->state= PLUGIN_IS_UNINITIALIZED; - } - } - DBUG_VOID_RETURN; -} - - static byte *get_hash_key(const byte *buff, uint *length, my_bool not_used __attribute__((unused))) { @@ -647,7 +630,14 @@ static byte *get_hash_key(const byte *buff, uint *length, } -int plugin_init(void) +/* + The logic is that we first load and initialize all compiled in plugins. + From there we load up the dynamic types (assuming we have not been told to + skip this part). + + Finally we inializie everything, aka the dynamic that have yet to initialize. +*/ +int plugin_init(int skip_dynamic_loading) { int i; struct st_mysql_plugin **builtins; @@ -672,24 +662,46 @@ int plugin_init(void) goto err; } - /* Register all the built-in plugins */ + /* + First we register builtin plugins + */ for (builtins= mysqld_builtins; *builtins; builtins++) { for (plugin= *builtins; plugin->info; plugin++) { - if (plugin_register_builtin(plugin)) - goto err; - struct st_plugin_int *tmp=dynamic_element(&plugin_array, - plugin_array.elements-1, - struct st_plugin_int *); - if (plugin_initialize(tmp)) - goto err; - tmp->state= PLUGIN_IS_READY; +// if (!(strcmp(plugin->name, "MyISAM"))) + { + if (plugin_register_builtin(plugin)) + goto err; + struct st_plugin_int *tmp= dynamic_element(&plugin_array, + plugin_array.elements-1, + struct st_plugin_int *); + if (plugin_initialize(tmp)) + goto err; + } } } + /* Register all dynamic plugins */ + if (!skip_dynamic_loading) + plugin_load(); + initialized= 1; + /* + Now we initialize all remaining plugins + */ + for (i= 0; i < plugin_array.elements; i++) + { + struct st_plugin_int *tmp= dynamic_element(&plugin_array, i, + struct st_plugin_int *); + if (tmp->state == PLUGIN_IS_UNINITIALIZED) + { + if (plugin_initialize(tmp)) + plugin_del(&tmp->name); + } + } + DBUG_RETURN(0); err: @@ -734,8 +746,6 @@ void plugin_load(void) THD *new_thd; DBUG_ENTER("plugin_load"); - DBUG_ASSERT(initialized); - if (!(new_thd= new THD)) { sql_print_error("Can't allocate memory for plugin structures"); @@ -772,7 +782,6 @@ void plugin_load(void) DBUG_PRINT("warning", ("Couldn't load plugin named '%s' with soname '%s'.", name.str, dl.str)); } - plugin_call_initializer(); if (error > 0) sql_print_error(ER(ER_GET_ERRNO), my_errno); end_read_record(&read_record_info); @@ -787,11 +796,22 @@ end: } -void plugin_free(void) +void plugin_shutdown(void) { uint i; - DBUG_ENTER("plugin_free"); - plugin_call_deinitializer(); + DBUG_ENTER("plugin_shutdown"); + + /* + We loop through all plugins and call deinit() if they have one. + */ + for (i= 0; i < plugin_array.elements; i++) + { + struct st_plugin_int *tmp= dynamic_element(&plugin_array, i, + struct st_plugin_int *); + plugin_deinitializer(tmp); + + } + for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) hash_free(&plugin_hash[i]); delete_dynamic(&plugin_array); @@ -841,8 +861,6 @@ my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING goto err; } - tmp->state= PLUGIN_IS_READY; - table->use_all_columns(); restore_record(table, s->default_values); table->field[0]->store(name->str, name->length, system_charset_info); diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index df7c9a39495..ed7ba36ac84 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -67,17 +67,14 @@ typedef int (*plugin_type_init)(struct st_plugin_int *); extern char *opt_plugin_dir_ptr; extern char opt_plugin_dir[FN_REFLEN]; extern const LEX_STRING plugin_type_names[]; -extern int plugin_init(void); -extern void plugin_load(void); -extern void plugin_free(void); +extern int plugin_init(int); +extern void plugin_shutdown(void); extern my_bool plugin_is_ready(const LEX_STRING *name, int type); extern st_plugin_int *plugin_lock(const LEX_STRING *name, int type); extern void plugin_unlock(struct st_plugin_int *plugin); extern my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl); extern my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name); -extern my_bool plugin_register_builtin(struct st_mysql_plugin *plugin); - typedef my_bool (plugin_foreach_func)(THD *thd, st_plugin_int *plugin, void *arg); From 8566db3fc738a6f2046af5307a6fe704d4cc782b Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.local" <> Date: Wed, 30 Aug 2006 01:48:15 +0400 Subject: [PATCH 054/119] Remove the fix for Bug#10668 "CREATE USER does not enforce username length limit", it's superseded by the fix for Bug#16899 "Possible buffer overflow in handling of DEFINER-clause". Update test results. --- mysql-test/r/grant.result | 3 ++- mysql-test/t/grant.test | 5 +++-- sql/sql_acl.cc | 8 -------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index b6803a49c76..2f417a41652 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -943,8 +943,9 @@ DROP TABLE mysqltest3.t_nn; DROP DATABASE mysqltest3; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost'; DROP USER 'mysqltest_1'@'localhost'; +use test; create user mysqltest1_thisisreallytoolong; -ERROR HY000: Operation CREATE USER failed for 'mysqltest1_thisisreallytoolong'@'%' +ERROR HY000: String 'mysqltest1_thisisreallytoolong' is too long for user name (should be no longer than 16) GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost; ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) GRANT CREATE ON mysqltest.* TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 0f63bc300d0..a938a8a64a7 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -805,12 +805,13 @@ DROP DATABASE mysqltest3; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost'; DROP USER 'mysqltest_1'@'localhost'; - +# eestore the original database +use test; # # Bug #10668: CREATE USER does not enforce username length limit # ---error ER_CANNOT_USER +--error ER_WRONG_STRING_LENGTH create user mysqltest1_thisisreallytoolong; # diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 6f2b464ef08..cb0a9576378 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5232,14 +5232,6 @@ bool mysql_create_user(THD *thd, List &list) continue; } - if (user_name->host.length > HOSTNAME_LENGTH || - user_name->user.length > USERNAME_LENGTH) - { - append_user(&wrong_users, user_name); - result= TRUE; - continue; - } - /* Search all in-memory structures and grant tables for a mention of the new user name. From cb26d4757076fa9402b433110f855fdc9e55e067 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.local" <> Date: Wed, 30 Aug 2006 03:22:59 +0400 Subject: [PATCH 055/119] Post-merge fixes. --- mysql-test/r/view.result | 22 +++++------ mysql-test/t/grant.test | 2 +- mysql-test/t/view.test | 83 +++++++++++++++++++++------------------- 3 files changed, 55 insertions(+), 52 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index dba9a9e229e..f70547cd4a8 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2849,17 +2849,6 @@ SHOW TABLES; Tables_in_test t1 DROP TABLE t1; -DROP TABLE IF EXISTS t1; -DROP VIEW IF EXISTS v1; -DROP VIEW IF EXISTS v2; -CREATE TABLE t1(a INT, b INT); -CREATE DEFINER=1234567890abcdefGHIKL@localhost -VIEW v1 AS SELECT a FROM t1; -ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) -CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY -VIEW v2 AS SELECT b FROM t1; -ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) -DROP TABLE t1; DROP VIEW IF EXISTS v1; CREATE DATABASE bug21261DB; USE bug21261DB; @@ -2890,6 +2879,17 @@ View Create View v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` where (`t1`.`f1` between now() and (now() + interval 1 minute)) drop view v1; drop table t1; +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +CREATE TABLE t1(a INT, b INT); +CREATE DEFINER=1234567890abcdefGHIKL@localhost +VIEW v1 AS SELECT a FROM t1; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY +VIEW v2 AS SELECT b FROM t1; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) +DROP TABLE t1; DROP FUNCTION IF EXISTS f1; DROP FUNCTION IF EXISTS f2; DROP VIEW IF EXISTS v1, v2; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index a938a8a64a7..d3781d58780 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -805,7 +805,7 @@ DROP DATABASE mysqltest3; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost'; DROP USER 'mysqltest_1'@'localhost'; -# eestore the original database +# restore the original database use test; # diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 5ae4ec8bbfa..edff38274c4 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2715,8 +2715,51 @@ DROP VIEW t1,v1; SHOW TABLES; DROP TABLE t1; +--disable_warnings +DROP VIEW IF EXISTS v1; +--enable_warnings +# +# Bug #21261: Wrong access rights was required for an insert to a view +# +CREATE DATABASE bug21261DB; +USE bug21261DB; +CONNECT (root,localhost,root,,bug21261DB); +CONNECTION root; +CREATE TABLE t1 (x INT); +CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1; +GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost'; +GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost'; +CREATE TABLE t2 (y INT); +GRANT SELECT ON t2 TO 'user21261'@'localhost'; + +CONNECT (user21261, localhost, user21261,, bug21261DB); +CONNECTION user21261; +INSERT INTO v1 (x) VALUES (5); +UPDATE v1 SET x=1; +CONNECTION root; +GRANT SELECT ON v1 TO 'user21261'@'localhost'; +GRANT SELECT ON t1 TO 'user21261'@'localhost'; +CONNECTION user21261; +UPDATE v1,t2 SET x=1 WHERE x=y; +CONNECTION root; +SELECT * FROM t1; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost'; +DROP USER 'user21261'@'localhost'; +DROP VIEW v1; +DROP TABLE t1; +DROP DATABASE bug21261DB; +USE test; + +# +# Bug #15950: NOW() optimized away in VIEWs +# +create table t1 (f1 datetime); +create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute; +show create view v1; +drop view v1; +drop table t1; # # Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause. # @@ -2790,45 +2833,5 @@ DROP FUNCTION f2; DROP VIEW v1, v2; DROP TABLE t1; -# -# Bug #21261: Wrong access rights was required for an insert to a view -# -CREATE DATABASE bug21261DB; -USE bug21261DB; -CONNECT (root,localhost,root,,bug21261DB); -CONNECTION root; -CREATE TABLE t1 (x INT); -CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1; -GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost'; -GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost'; -CREATE TABLE t2 (y INT); -GRANT SELECT ON t2 TO 'user21261'@'localhost'; - -CONNECT (user21261, localhost, user21261,, bug21261DB); -CONNECTION user21261; -INSERT INTO v1 (x) VALUES (5); -UPDATE v1 SET x=1; -CONNECTION root; -GRANT SELECT ON v1 TO 'user21261'@'localhost'; -GRANT SELECT ON t1 TO 'user21261'@'localhost'; -CONNECTION user21261; -UPDATE v1,t2 SET x=1 WHERE x=y; -CONNECTION root; -SELECT * FROM t1; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost'; -DROP USER 'user21261'@'localhost'; -DROP VIEW v1; -DROP TABLE t1; -DROP DATABASE bug21261DB; -USE test; - -# -# Bug #15950: NOW() optimized away in VIEWs -# -create table t1 (f1 datetime); -create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute; -show create view v1; -drop view v1; -drop table t1; --echo End of 5.0 tests. From 9d87db7767f4286b116ddadc85f6dcafb5658c0d Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 30 Aug 2006 17:11:00 +0200 Subject: [PATCH 056/119] Bug#21813 An attacker has the opportunity to bypass query logging, part2 - Use the "%.*b" format when printing prepared and exeuted prepared statements to the log. - Add test case to check that also prepared statements end up in the query log Bug#14346 Prepared statements corrupting general log/server memory - Use "stmt->query" when logging the newly prepared query instead of "packet" --- sql/sql_prepare.cc | 6 ++- tests/mysql_client_test.c | 91 ++++++++++++++++++++++++++++----------- 2 files changed, 71 insertions(+), 26 deletions(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 6d35c441368..32f0ca6859d 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1877,7 +1877,8 @@ void mysql_stmt_prepare(THD *thd, const char *packet, uint packet_length) thd->stmt_map.erase(stmt); } else - mysql_log.write(thd, COM_STMT_PREPARE, "[%lu] %s", stmt->id, packet); + mysql_log.write(thd, COM_STMT_PREPARE, "[%lu] %.*b", stmt->id, + stmt->query_length, stmt->query); /* check_prepared_statemnt sends the metadata packet in case of success */ DBUG_VOID_RETURN; @@ -2252,7 +2253,8 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(), WAIT_PRIOR); if (error == 0) - mysql_log.write(thd, COM_STMT_EXECUTE, "[%lu] %s", stmt->id, thd->query); + mysql_log.write(thd, COM_STMT_EXECUTE, "[%lu] %.*b", stmt->id, + thd->query_length, thd->query); DBUG_VOID_RETURN; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 427994f832f..8377c757138 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -14912,22 +14912,31 @@ static void test_bug15613() /* Bug#17667: An attacker has the opportunity to bypass query logging. + + Note! Also tests Bug#21813, where prepared statements are used to + run queries */ static void test_bug17667() { int rc; + MYSQL_STMT *stmt; + enum query_type { QT_NORMAL, QT_PREPARED}; struct buffer_and_length { + enum query_type qt; const char *buffer; const uint length; } statements[]= { - { "drop table if exists bug17667", 29 }, - { "create table bug17667 (c varchar(20))", 37 }, - { "insert into bug17667 (c) values ('regular') /* NUL=\0 with comment */", 68 }, - { "insert into bug17667 (c) values ('NUL=\0 in value')", 50 }, - { "insert into bug17667 (c) values ('5 NULs=\0\0\0\0\0')", 48 }, - { "/* NUL=\0 with comment */ insert into bug17667 (c) values ('encore')", 67 }, - { "drop table bug17667", 19 }, - { NULL, 0 } }; + { QT_NORMAL, "drop table if exists bug17667", 29 }, + { QT_NORMAL, "create table bug17667 (c varchar(20))", 37 }, + { QT_NORMAL, "insert into bug17667 (c) values ('regular') /* NUL=\0 with comment */", 68 }, + { QT_PREPARED, + "insert into bug17667 (c) values ('prepared') /* NUL=\0 with comment */", 69, }, + { QT_NORMAL, "insert into bug17667 (c) values ('NUL=\0 in value')", 50 }, + { QT_NORMAL, "insert into bug17667 (c) values ('5 NULs=\0\0\0\0\0')", 48 }, + { QT_PREPARED, "insert into bug17667 (c) values ('6 NULs=\0\0\0\0\0\0')", 50 }, + { QT_NORMAL, "/* NUL=\0 with comment */ insert into bug17667 (c) values ('encore')", 67 }, + { QT_NORMAL, "drop table bug17667", 19 }, + { QT_NORMAL, NULL, 0 } }; struct buffer_and_length *statement_cursor; FILE *log_file; @@ -14937,9 +14946,36 @@ static void test_bug17667() for (statement_cursor= statements; statement_cursor->buffer != NULL; statement_cursor++) { - rc= mysql_real_query(mysql, statement_cursor->buffer, - statement_cursor->length); - myquery(rc); + if (statement_cursor->qt == QT_NORMAL) + { + /* Run statement as normal query */ + rc= mysql_real_query(mysql, statement_cursor->buffer, + statement_cursor->length); + myquery(rc); + } + else if (statement_cursor->qt == QT_PREPARED) + { + /* + Run as prepared statement + + NOTE! All these queries should be in the log twice, + one time for prepare and one time for execute + */ + stmt= mysql_stmt_init(mysql); + + rc= mysql_stmt_prepare(stmt, statement_cursor->buffer, + statement_cursor->length); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + mysql_stmt_close(stmt); + } + else + { + assert(0==1); + } } /* Make sure the server has written the logs to disk before reading it */ @@ -14957,29 +14993,36 @@ static void test_bug17667() for (statement_cursor= statements; statement_cursor->buffer != NULL; statement_cursor++) { + int expected_hits= 1, hits= 0; char line_buffer[MAX_TEST_QUERY_LENGTH*2]; /* more than enough room for the query and some marginalia. */ - do { - memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); + /* Prepared statments always occurs twice in log */ + if (statement_cursor->qt == QT_PREPARED) + expected_hits++; - if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL) - { - /* If fgets returned NULL, it indicates either error or EOF */ - if (feof(log_file)) - DIE("Found EOF before all statements where found"); - else + /* Loop until we found expected number of log entries */ + do { + /* Loop until statement is found in log */ + do { + memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); + + if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL) { + /* If fgets returned NULL, it indicates either error or EOF */ + if (feof(log_file)) + DIE("Found EOF before all statements where found"); + fprintf(stderr, "Got error %d while reading from file\n", ferror(log_file)); DIE("Read error"); } - } - /* Print the line */ - printf("%s", line_buffer); - } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2, - statement_cursor->buffer, statement_cursor->length) == NULL); + } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2, + statement_cursor->buffer, + statement_cursor->length) == NULL); + hits++; + } while (hits < expected_hits); printf("Found statement starting with \"%s\"\n", statement_cursor->buffer); From e3d56d2cd32464e565a1daf9d338ad909aa60959 Mon Sep 17 00:00:00 2001 From: "hartmut@mysql.com/linux.site" <> Date: Wed, 30 Aug 2006 20:45:43 +0200 Subject: [PATCH 057/119] make DNS based hostname queries work (bug #17582) --- ndb/tools/ndb_config.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndb/tools/ndb_config.cpp b/ndb/tools/ndb_config.cpp index 27ab6a182bb..135bec7ef72 100644 --- a/ndb/tools/ndb_config.cpp +++ b/ndb/tools/ndb_config.cpp @@ -145,7 +145,7 @@ struct Match struct HostMatch : public Match { - virtual int eval(NdbMgmHandle, const Iter&); + virtual int eval(const Iter&); }; struct Apply @@ -402,7 +402,7 @@ Match::eval(const Iter& iter) } int -HostMatch::eval(NdbMgmHandle h, const Iter& iter) +HostMatch::eval(const Iter& iter) { const char* valc; From 843135ae1f785475266d173d020dd363803d719e Mon Sep 17 00:00:00 2001 From: "tsmith@maint2.mysql.com" <> Date: Wed, 30 Aug 2006 21:24:09 +0200 Subject: [PATCH 058/119] portability fix in BUILD/* for solaris --- BUILD/check-cpu | 363 ++++++++++++++++++++++++------------------------ 1 file changed, 183 insertions(+), 180 deletions(-) diff --git a/BUILD/check-cpu b/BUILD/check-cpu index b970a4b9a5b..e207d12d972 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -3,203 +3,206 @@ # Check cpu of current machine and find the # best compiler optimization flags for gcc # -# -if test -r /proc/cpuinfo ; then - # on Linux (and others?) we can get detailed CPU information out of /proc - cpuinfo="cat /proc/cpuinfo" +check_cpu () { + if test -r /proc/cpuinfo ; then + # on Linux (and others?) we can get detailed CPU information out of /proc + cpuinfo="cat /proc/cpuinfo" - # detect CPU family - cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` - if test -z "$cpu_family" ; then - cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` + # detect CPU family + cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` + if test -z "$cpu_family" ; then + cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` + fi + + # detect CPU vendor and model + cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` + model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1` + if test -z "$model_name" ; then + model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1` + fi + + # fallback: get CPU model from uname output + if test -z "$model_name" ; then + model_name=`uname -m` + fi + + # parse CPU flags + for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //'`; do + eval cpu_flag_$flag=yes + done + else + # Fallback when there is no /proc/cpuinfo + case "`uname -s`" in + FreeBSD|OpenBSD) + cpu_family=`uname -m`; + model_name=`sysctl -n hw.model` + ;; + Darwin) + cpu_family=`uname -p` + model_name=`machine` + ;; + *) + cpu_family=`uname -m`; + model_name=`uname -p`; + ;; + esac fi - # detect CPU vendor and model - cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` - model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1` - if test -z "$model_name" ; then - model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1` - fi - - # fallback: get CPU model from uname output - if test -z "$model_name" ; then - model_name=`uname -m` - fi - - # parse CPU flags - for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //'`; do - eval cpu_flag_$flag=yes - done -else - # Fallback when there is no /proc/cpuinfo - case "`uname -s`" in - FreeBSD|OpenBSD) - cpu_family=`uname -m`; - model_name=`sysctl -n hw.model` + # detect CPU shortname as used by gcc options + # this list is not complete, feel free to add further entries + cpu_arg="" + case "$cpu_family--$model_name" in + # DEC Alpha + Alpha*EV6*) + cpu_arg="ev6"; ;; - Darwin) - cpu_family=`uname -p` - model_name=`machine` + + # Intel ia32 + *Xeon*) + # a Xeon is just another pentium4 ... + # ... unless it has the "lm" (long-mode) flag set, + # in that case it's a Xeon with EM64T support + if [ -z "$cpu_flag_lm" ]; then + cpu_arg="pentium4"; + else + cpu_arg="nocona"; + fi ;; + *Pentium*4*Mobile*) + cpu_arg="pentium4m"; + ;; + *Pentium*4*) + cpu_arg="pentium4"; + ;; + *Pentium*III*Mobile*) + cpu_arg="pentium3m"; + ;; + *Pentium*III*) + cpu_arg="pentium3"; + ;; + *Pentium*M*pro*) + cpu_arg="pentium-m"; + ;; + *Athlon*64*) + cpu_arg="athlon64"; + ;; + *Athlon*) + cpu_arg="athlon"; + ;; + + # Intel ia64 + *Itanium*) + # Don't need to set any flags for itanium(at the moment) + cpu_arg=""; + ;; + + # + *ppc*) + cpu_arg='powerpc' + ;; + + *powerpc*) + cpu_arg='powerpc' + ;; + + # unknown *) - cpu_family=`uname -m`; - model_name=`uname -p`; + cpu_arg=""; ;; esac -fi - -# detect CPU shortname as used by gcc options -# this list is not complete, feel free to add further entries -cpu_arg="" -case "$cpu_family--$model_name" in - # DEC Alpha - Alpha*EV6*) - cpu_arg="ev6"; - ;; - - # Intel ia32 - *Xeon*) - # a Xeon is just another pentium4 ... - # ... unless it has the "lm" (long-mode) flag set, - # in that case it's a Xeon with EM64T support - if [ -z "$cpu_flag_lm" ]; then - cpu_arg="pentium4"; - else - cpu_arg="nocona"; - fi - ;; - *Pentium*4*Mobile*) - cpu_arg="pentium4m"; - ;; - *Pentium*4*) - cpu_arg="pentium4"; - ;; - *Pentium*III*Mobile*) - cpu_arg="pentium3m"; - ;; - *Pentium*III*) - cpu_arg="pentium3"; - ;; - *Pentium*M*pro*) - cpu_arg="pentium-m"; - ;; - *Athlon*64*) - cpu_arg="athlon64"; - ;; - *Athlon*) - cpu_arg="athlon"; - ;; - - # Intel ia64 - *Itanium*) - # Don't need to set any flags for itanium(at the moment) - cpu_arg=""; - ;; - - # - *ppc*) - cpu_arg='powerpc' - ;; - - *powerpc*) - cpu_arg='powerpc' - ;; - - # unknown - *) - cpu_arg=""; - ;; -esac -if test -z "$cpu_arg"; then - echo "BUILD/check-cpu: Oops, could not find out what kind of cpu this machine is using." - check_cpu_cflags="" - return -fi - -# different compiler versions have different option names -# for CPU specific command line options -if test -z "$CC" ; then - cc="gcc"; -else - cc=$CC -fi - -cc_ver=`$cc --version | sed 1q` -cc_verno=`echo $cc_ver | sed -e 's/[^0-9. ]//g; s/^ *//g; s/ .*//g'` - -case "$cc_ver--$cc_verno" in - *GCC*) - # different gcc backends (and versions) have different CPU flags - case `gcc -dumpmachine` in - i?86-*) - case "$cc_verno" in - 3.4*|3.5*|4.*) - check_cpu_args='-mtune=$cpu_arg -march=$cpu_arg' - ;; - *) - check_cpu_args='-mcpu=$cpu_arg -march=$cpu_arg' - ;; - esac - ;; - ppc-*) - check_cpu_args='-mcpu=$cpu_arg -mtune=$cpu_arg' - ;; - *) - check_cpu_cflags="" - return - ;; - esac - ;; - 2.95.*) - # GCC 2.95 doesn't expose its name in --version output - check_cpu_args='-m$cpu_arg' - ;; - *) + if test -z "$cpu_arg"; then + echo "BUILD/check-cpu: Oops, could not find out what kind of cpu this machine is using." >&2 check_cpu_cflags="" return - ;; -esac - -# now we check whether the compiler really understands the cpu type -touch __test.c - -while [ "$cpu_arg" ] ; do - echo -n testing $cpu_arg "... " - - # compile check - check_cpu_cflags=`eval echo $check_cpu_args` - if $cc -c $check_cpu_cflags __test.c 2>/dev/null; then - echo ok - break; fi - echo failed - check_cpu_cflags="" + # different compiler versions have different option names + # for CPU specific command line options + if test -z "$CC" ; then + cc="gcc"; + else + cc=$CC + fi - # if compile failed: check whether it supports a predecessor of this CPU - # this list is not complete, feel free to add further entries - case "$cpu_arg" in - # Intel ia32 - nocona) cpu_arg=pentium4 ;; - prescott) cpu_arg=pentium4 ;; - pentium4m) cpu_arg=pentium4 ;; - pentium4) cpu_arg=pentium3 ;; - pentium3m) cpu_arg=pentium3 ;; - pentium3) cpu_arg=pentium2 ;; - pentium2) cpu_arg=pentiumpro ;; - pentiumpro) cpu_arg=pentium ;; - pentium) cpu_arg=i486 ;; - i486) cpu_arg=i386 ;; + cc_ver=`$cc --version | sed 1q` + cc_verno=`echo $cc_ver | sed -e 's/[^0-9. ]//g; s/^ *//g; s/ .*//g'` - # power / powerPC - 7450) cpu_arg=7400 ;; - - *) cpu_arg="" ;; + case "$cc_ver--$cc_verno" in + *GCC*) + # different gcc backends (and versions) have different CPU flags + case `gcc -dumpmachine` in + i?86-*) + case "$cc_verno" in + 3.4*|3.5*|4.*) + check_cpu_args='-mtune=$cpu_arg -march=$cpu_arg' + ;; + *) + check_cpu_args='-mcpu=$cpu_arg -march=$cpu_arg' + ;; + esac + ;; + ppc-*) + check_cpu_args='-mcpu=$cpu_arg -mtune=$cpu_arg' + ;; + *) + check_cpu_cflags="" + return + ;; + esac + ;; + 2.95.*) + # GCC 2.95 doesn't expose its name in --version output + check_cpu_args='-m$cpu_arg' + ;; + *) + check_cpu_cflags="" + return + ;; esac -done -rm __test.* + # now we check whether the compiler really understands the cpu type + touch __test.c + while [ "$cpu_arg" ] ; do + # FIXME: echo -n isn't portable - see contortions autoconf goes through + echo -n testing $cpu_arg "... " >&2 + + # compile check + check_cpu_cflags=`eval echo $check_cpu_args` + if $cc -c $check_cpu_cflags __test.c 2>/dev/null; then + echo ok >&2 + break; + fi + + echo failed >&2 + check_cpu_cflags="" + + # if compile failed: check whether it supports a predecessor of this CPU + # this list is not complete, feel free to add further entries + case "$cpu_arg" in + # Intel ia32 + nocona) cpu_arg=pentium4 ;; + prescott) cpu_arg=pentium4 ;; + pentium4m) cpu_arg=pentium4 ;; + pentium4) cpu_arg=pentium3 ;; + pentium3m) cpu_arg=pentium3 ;; + pentium3) cpu_arg=pentium2 ;; + pentium2) cpu_arg=pentiumpro ;; + pentiumpro) cpu_arg=pentium ;; + pentium) cpu_arg=i486 ;; + i486) cpu_arg=i386 ;; + + # power / powerPC + 7450) cpu_arg=7400 ;; + + *) cpu_arg="" ;; + esac + done + + rm __test.* +} + +check_cpu From 7ae3682dc8e67cc6398c6bb2c1b1aa3a4732b979 Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Wed, 30 Aug 2006 12:28:25 -0700 Subject: [PATCH 059/119] This pulls two function calls which should have been handlerton calls out of handler.cc. --- sql/ha_ndbcluster.cc | 2 ++ sql/handler.cc | 64 +++++++++++++++++++++++++++++++++++--------- sql/handler.h | 6 ++++- 3 files changed, 58 insertions(+), 14 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c7b0ce95214..486bbd35fc0 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6388,6 +6388,8 @@ static int ndbcluster_init() #endif h.flags= HTON_CAN_RECREATE | HTON_TEMPORARY_NOT_SUPPORTED; h.discover= ndbcluster_discover; + h.find_files= ndbcluster_find_files; + h.table_exists_in_engine= ndbcluster_table_exists_in_engine; } if (have_ndbcluster != SHOW_OPTION_YES) diff --git a/sql/handler.cc b/sql/handler.cc index 465919d49a8..9aaad7b3914 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -28,11 +28,6 @@ #include #include -#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE -#define NDB_MAX_ATTRIBUTES_IN_TABLE 128 -#include "ha_ndbcluster.h" -#endif - #ifdef WITH_PARTITION_STORAGE_ENGINE #include "ha_partition.h" #endif @@ -2745,6 +2740,29 @@ int ha_discover(THD *thd, const char *db, const char *name, to ask engine if there are any new tables that should be written to disk or any dropped tables that need to be removed from disk */ +typedef struct st_find_files_args +{ + const char *db; + const char *path; + const char *wild; + bool dir; + List *files; +}; + +static my_bool find_files_handlerton(THD *thd, st_plugin_int *plugin, + void *arg) +{ + st_find_files_args *vargs= (st_find_files_args *)arg; + handlerton *hton= (handlerton *)plugin->data; + + + if (hton->state == SHOW_OPTION_YES && hton->find_files) + if (hton->find_files(thd, vargs->db, vargs->path, vargs->wild, + vargs->dir, vargs->files)) + return TRUE; + + return FALSE; +} int ha_find_files(THD *thd,const char *db,const char *path, @@ -2754,10 +2772,11 @@ ha_find_files(THD *thd,const char *db,const char *path, DBUG_ENTER("ha_find_files"); DBUG_PRINT("enter", ("db: %s, path: %s, wild: %s, dir: %d", db, path, wild, dir)); -#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE - if (have_ndbcluster == SHOW_OPTION_YES) - error= ndbcluster_find_files(thd, db, path, wild, dir, files); -#endif + st_find_files_args args= {db, path, wild, dir, files}; + + plugin_foreach(thd, find_files_handlerton, + MYSQL_STORAGE_ENGINE_PLUGIN, &args); + /* The return value is not currently used */ DBUG_RETURN(error); } @@ -2771,15 +2790,34 @@ ha_find_files(THD *thd,const char *db,const char *path, # Error code */ + +typedef struct st_table_exists_in_engine_args +{ + const char *db; + const char *name; +}; + +static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin, + void *arg) +{ + st_table_exists_in_engine_args *vargs= (st_table_exists_in_engine_args *)arg; + handlerton *hton= (handlerton *)plugin->data; + + if (hton->state == SHOW_OPTION_YES && hton->table_exists_in_engine) + if ((hton->table_exists_in_engine(thd, vargs->db, vargs->name)) == 1) + return TRUE; + + return FALSE; +} + int ha_table_exists_in_engine(THD* thd, const char* db, const char* name) { int error= 0; DBUG_ENTER("ha_table_exists_in_engine"); DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); -#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE - if (have_ndbcluster == SHOW_OPTION_YES) - error= ndbcluster_table_exists_in_engine(thd, db, name); -#endif + st_table_exists_in_engine_args args= {db, name}; + error= plugin_foreach(thd, table_exists_in_engine_handlerton, + MYSQL_STORAGE_ENGINE_PLUGIN, &args); DBUG_PRINT("exit", ("error: %d", error)); DBUG_RETURN(error); } diff --git a/sql/handler.h b/sql/handler.h index bfc502b0658..f41cf1d6727 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -668,7 +668,11 @@ struct handlerton (*create_iterator)(enum handler_iterator_type type, struct handler_iterator *fill_this_in); int (*discover)(THD* thd, const char *db, const char *name, - const void** frmblob, uint* frmlen); + const void** frmblob, uint* frmlen); + int (*find_files)(THD *thd,const char *db,const char *path, + const char *wild, bool dir, List *files); + int (*table_exists_in_engine)(THD* thd, const char *db, + const char *name); }; From e80741b3a55798854b10e9c0dbd36cc1f6d6eb74 Mon Sep 17 00:00:00 2001 From: "tsmith@maint2.mysql.com" <> Date: Wed, 30 Aug 2006 22:39:23 +0200 Subject: [PATCH 060/119] Remove ^Z from ctype_ucs.test data, to avoid problems testing on Windows --- mysql-test/r/ctype_ucs.result | 14 +++++++------- mysql-test/t/ctype_ucs.test | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 3a65287ffc5..05866ea4966 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -726,26 +726,26 @@ drop table if exists bug20536; set names latin1; create table bug20536 (id bigint not null auto_increment primary key, name varchar(255) character set ucs2 not null); -insert into `bug20536` (`id`,`name`) values (1, _latin1 x'74657374311a'), (2, "'test\\_2'"); +insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'"); select md5(name) from bug20536; md5(name) -3417d830fe24ffb2f81a28e54df2d1b3 +f4b7ce8b45a20e3c4e84bef515d1525c 48d95db0d8305c2fe11548a3635c9385 select sha1(name) from bug20536; sha1(name) -72228a6d56efb7a89a09543068d5d8fa4c330881 +e0b52f38deddb9f9e8d5336b153592794cb49baf 677d4d505355eb5b0549b865fcae4b7f0c28aef5 select make_set(3, name, upper(name)) from bug20536; make_set(3, name, upper(name)) -test1,TEST1 +test1,TEST1 'test\_2','TEST\_2' select export_set(5, name, upper(name)) from bug20536; export_set(5, name, upper(name)) -test1,TEST1,test1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1 +test1,TEST1,test1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1 'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2' select export_set(5, name, upper(name), ",", 5) from bug20536; export_set(5, name, upper(name), ",", 5) -test1,TEST1,test1,TEST1,TEST1 +test1,TEST1,test1,TEST1,TEST1 'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2' select password(name) from bug20536; password(name) @@ -761,7 +761,7 @@ SA5pDi1UPZdys SA5pDi1UPZdys select quote(name) from bug20536; quote(name) -?????????? +???????? ???????????????? drop table bug20536; End of 4.1 tests diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 0ad38d98403..62244b3d8f5 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -475,7 +475,7 @@ drop table if exists bug20536; set names latin1; create table bug20536 (id bigint not null auto_increment primary key, name varchar(255) character set ucs2 not null); -insert into `bug20536` (`id`,`name`) values (1, _latin1 x'74657374311a'), (2, "'test\\_2'"); +insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'"); select md5(name) from bug20536; select sha1(name) from bug20536; select make_set(3, name, upper(name)) from bug20536; From 38a59efbc9828afcead6389f6abab8a5e35eb314 Mon Sep 17 00:00:00 2001 From: "acurtis/antony@xiphis.org/ltantony.xiphis.org" <> Date: Wed, 30 Aug 2006 14:27:29 -0700 Subject: [PATCH 061/119] add 2 placeholder values for config and system variables. --- include/mysql/plugin.h | 4 +++- plugin/fulltext/plugin_example.c | 4 +++- sql/ha_innodb.cc | 4 +++- sql/ha_ndbcluster.cc | 4 +++- sql/ha_partition.cc | 4 +++- sql/log.cc | 4 +++- storage/archive/ha_archive.cc | 4 +++- storage/blackhole/ha_blackhole.cc | 4 +++- storage/csv/ha_tina.cc | 4 +++- storage/example/ha_example.cc | 4 +++- storage/federated/ha_federated.cc | 4 +++- storage/heap/ha_heap.cc | 4 +++- storage/myisam/ha_myisam.cc | 4 +++- storage/myisammrg/ha_myisammrg.cc | 4 +++- 14 files changed, 42 insertions(+), 14 deletions(-) diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 156c3312c53..739f7bc5fc6 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -60,7 +60,7 @@ __MYSQL_DECLARE_PLUGIN(NAME, \ builtin_ ## NAME ## _sizeof_struct_st_plugin, \ builtin_ ## NAME ## _plugin) -#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0}} +#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}} /* declarations for SHOW STATUS support in plugins @@ -96,6 +96,8 @@ struct st_mysql_plugin int (*deinit)(void); /* the function to invoke when plugin is unloaded */ unsigned int version; /* plugin version (for SHOW PLUGINS) */ struct st_mysql_show_var *status_vars; + void * __reserved1; /* placeholder for system variables */ + void * __reserved2; /* placeholder for config options */ }; /************************************************************************* diff --git a/plugin/fulltext/plugin_example.c b/plugin/fulltext/plugin_example.c index beb02128774..34350e317ba 100644 --- a/plugin/fulltext/plugin_example.c +++ b/plugin/fulltext/plugin_example.c @@ -225,7 +225,9 @@ mysql_declare_plugin(ftexample) simple_parser_plugin_init, /* init function (when loaded) */ simple_parser_plugin_deinit,/* deinit function (when unloaded) */ 0x0001, /* version */ - simple_status /* status variables */ + simple_status, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 7f4d6abd4b7..9f7965ffb3a 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -7623,7 +7623,9 @@ mysql_declare_plugin(innobase) innobase_init, /* Plugin Init */ NULL, /* Plugin Deinit */ 0x0100 /* 1.0 */, - innodb_status_variables_export + innodb_status_variables_export,/* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 486bbd35fc0..cc5e5b5040a 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -10598,7 +10598,9 @@ mysql_declare_plugin(ndbcluster) ndbcluster_init, /* Plugin Init */ NULL, /* Plugin Deinit */ 0x0100 /* 1.0 */, - ndb_status_variables_export + ndb_status_variables_export,/* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index ee0667b92bd..43303bb1a03 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5598,7 +5598,9 @@ mysql_declare_plugin(partition) partition_initialize, /* Plugin Init */ NULL, /* Plugin Deinit */ 0x0100, /* 1.0 */ - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/sql/log.cc b/sql/log.cc index b93d36cf630..50b9119f7e6 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -4678,6 +4678,8 @@ mysql_declare_plugin(binlog) binlog_init, /* Plugin Init */ NULL, /* Plugin Deinit */ 0x0100 /* 1.0 */, - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index de8b50fd2f3..3029b1db53e 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1583,7 +1583,9 @@ mysql_declare_plugin(archive) archive_db_init, /* Plugin Init */ archive_db_done, /* Plugin Deinit */ 0x0100 /* 1.0 */, - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index d22d9372e0d..c1141cce5ae 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -223,6 +223,8 @@ mysql_declare_plugin(blackhole) blackhole_init, /* Plugin Init */ NULL, /* Plugin Deinit */ 0x0100 /* 1.0 */, - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 2fe2afeb470..ce19202d745 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -1529,7 +1529,9 @@ mysql_declare_plugin(csv) tina_init_func, /* Plugin Init */ tina_done_func, /* Plugin Deinit */ 0x0100 /* 1.0 */, - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 704ea757749..6986796cb2e 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -715,7 +715,9 @@ mysql_declare_plugin(example) example_init_func, /* Plugin Init */ example_done_func, /* Plugin Deinit */ 0x0001 /* 0.1 */, - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 98f48b09ba6..456b6c73f3c 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -2896,7 +2896,9 @@ mysql_declare_plugin(federated) federated_db_init, /* Plugin Init */ NULL, /* Plugin Deinit */ 0x0100 /* 1.0 */, - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 317f85d26f2..57777410bea 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -708,6 +708,8 @@ mysql_declare_plugin(heap) heap_init, NULL, 0x0100, /* 1.0 */ - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 209478ee9a5..6a32ba95eee 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1800,7 +1800,9 @@ mysql_declare_plugin(myisam) myisam_init, /* Plugin Init */ NULL, /* Plugin Deinit */ 0x0100, /* 1.0 */ - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 8c767e32b83..2d1628e5e4f 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -573,6 +573,8 @@ mysql_declare_plugin(myisammrg) myisammrg_init, /* Plugin Init */ NULL, /* Plugin Deinit */ 0x0100, /* 1.0 */ - 0 + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ } mysql_declare_plugin_end; From 2c356ec7db475c942d804256add35b15b9ab9dac Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 30 Aug 2006 17:28:34 -0400 Subject: [PATCH 062/119] Bug#4053: too many of "error 1236: 'binlog truncated in the middle of \ event' from master" Since there is no repeatable test case, and this is obviously wrong, this is the most conservative change that might possibly work. The syscall read() wasn't checked for a negative return value for an interrupted read. The kernel sys_read() returns -EINTR, and the "library" layer maps that to return value of -1 and sets errno to EINTR. It's impossible (on Linux) for read() to set errno EINTR without the return value being -1 . So, if we're checking for EINTR behavior, we should not require that the return value be zero. --- mysys/my_read.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/mysys/my_read.c b/mysys/my_read.c index b7621ac99eb..bca28694295 100644 --- a/mysys/my_read.c +++ b/mysys/my_read.c @@ -36,48 +36,51 @@ uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags) { - uint readbytes,save_count; + uint readbytes, save_count; DBUG_ENTER("my_read"); DBUG_PRINT("my",("Fd: %d Buffer: %lx Count: %u MyFlags: %d", - Filedes, Buffer, Count, MyFlags)); - save_count=Count; + Filedes, Buffer, Count, MyFlags)); + save_count= Count; for (;;) { - errno=0; /* Linux doesn't reset this */ - if ((readbytes = (uint) read(Filedes, Buffer, Count)) != Count) + errno= 0; /* Linux doesn't reset this */ + if ((readbytes= (uint) read(Filedes, Buffer, Count)) != Count) { - my_errno=errno ? errno : -1; + my_errno= errno ? errno : -1; DBUG_PRINT("warning",("Read only %ld bytes off %ld from %d, errno: %d", - readbytes,Count,Filedes,my_errno)); + readbytes, Count, Filedes, my_errno)); #ifdef THREAD - if (readbytes == 0 && errno == EINTR) - continue; /* Interrupted */ + if ((int) readbytes <= 0 && errno == EINTR) + { + DBUG_PRINT("debug", ("my_read() was interrupted and returned %d", (int) readbytes)); + continue; /* Interrupted */ + } #endif if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { - if ((int) readbytes == -1) - my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), - my_filename(Filedes),my_errno); - else if (MyFlags & (MY_NABP | MY_FNABP)) - my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), - my_filename(Filedes),my_errno); + if ((int) readbytes == -1) + my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), + my_filename(Filedes),my_errno); + else if (MyFlags & (MY_NABP | MY_FNABP)) + my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), + my_filename(Filedes),my_errno); } if ((int) readbytes == -1 || - ((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO))) - DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ + ((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO))) + DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ if (readbytes > 0 && (MyFlags & MY_FULL_IO)) { - Buffer+=readbytes; - Count-=readbytes; - continue; + Buffer+= readbytes; + Count-= readbytes; + continue; } } if (MyFlags & (MY_NABP | MY_FNABP)) - readbytes=0; /* Ok on read */ + readbytes= 0; /* Ok on read */ else if (MyFlags & MY_FULL_IO) - readbytes=save_count; + readbytes= save_count; break; } DBUG_RETURN(readbytes); From f19bdd996fe1fab98cd918509c1ab672cf6da302 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Thu, 31 Aug 2006 10:18:55 +0200 Subject: [PATCH 063/119] Add check in 'spawn_impl' that we are not trying to span when the path to the executable is empty or undefined --- mysql-test/lib/mtr_process.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index a71a1e7d2e4..f74665d1646 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -94,6 +94,8 @@ sub spawn_impl ($$$$$$$$) { my $pid_file= shift; # FIXME my $spawn_opts= shift; + mtr_error("Can't spawn with empty \"path\"") unless defined $path; + if ( $::opt_script_debug ) { print STDERR "\n"; From 71450a865f91803a77e600e9fb82afb6963f8a75 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Thu, 31 Aug 2006 10:28:48 +0200 Subject: [PATCH 064/119] Bug#21721 Test suite does not start with NDB, hangs forever; problem around "ndb_mgmd" - Wait for ndb_mgmd with timeout --- mysql-test/mysql-test-run.pl | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 6865cd55398..c949c2e1966 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1955,6 +1955,23 @@ sub mysqld_wait_started($){ } +sub ndb_mgmd_wait_started($) { + my ($cluster)= @_; + + my $retries= 100; + while (ndbcluster_wait_started($cluster, "--no-contact") and + $retries) + { + # Millisceond sleep emulated with select + select(undef, undef, undef, (0.1)); + + $retries--; + } + + return $retries == 0; + +} + sub ndb_mgmd_start ($) { my $cluster= shift; @@ -1975,13 +1992,12 @@ sub ndb_mgmd_start ($) { "", { append_log_file => 1 }); - # FIXME Should not be needed # Unfortunately the cluster nodes will fail to start # if ndb_mgmd has not started properly - while (ndbcluster_wait_started($cluster, "--no-contact")) + if (ndb_mgmd_wait_started($cluster)) { - select(undef, undef, undef, 0.1); + mtr_error("Failed to wait for start of ndb_mgmd"); } # Remember pid of ndb_mgmd @@ -2046,7 +2062,7 @@ sub ndbcluster_start ($$) { mtr_error("Cluster '$cluster->{'name'}' already started"); } - my $pid= ndb_mgmd_start($cluster); + ndb_mgmd_start($cluster); for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ ) { From b0754b3d021be88b20e3cf935f56b65a14279f05 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Thu, 31 Aug 2006 11:53:08 +0200 Subject: [PATCH 065/119] Disable testing of "encrypt" in ctype_ucs.test --- mysql-test/r/ctype_ucs.result | 4 ---- mysql-test/t/ctype_ucs.test | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 441dbbaf4ec..3b6bfa6d776 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -763,10 +763,6 @@ select old_password(name) from bug20536; old_password(name) ???????? ???????? -select encrypt(name, 'SALT') from bug20536; -encrypt(name, 'SALT') -SA5pDi1UPZdys -SA5pDi1UPZdys select quote(name) from bug20536; quote(name) ???????? diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 3690ac958a2..8116d39e3db 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -491,11 +491,16 @@ select export_set(5, name, upper(name), ",", 5) from bug20536; select password(name) from bug20536; select old_password(name) from bug20536; +# Disable test case as encrypt relies on 'crypt' function. +# "decrypt" is noramlly tested in func_crypt.test which have a +# "have_crypt.inc" test +--disable_parsing # ENCRYPT relies on OS function crypt() which takes a NUL-terminated string; it # doesn't return good results for strings with embedded 0 bytes. It won't be # fixed unless we choose to re-implement the crypt() function ourselves to take # an extra size_t string_length argument. select encrypt(name, 'SALT') from bug20536; +--enable_parsing # QUOTE doesn't work with UCS2 data. It would require a total rewrite # of Item_func_quote::val_str(), which isn't worthwhile until UCS2 is From f368e0753e771a2890a3eae2d18bc50808626e32 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Thu, 31 Aug 2006 14:26:12 +0200 Subject: [PATCH 066/119] Bug #21930 libmysqlclient defines BN_bin2bn which belongs to OpenSSL! Breaks other apps! - Correct bug in perl script that faild to add rename macros for some functions. --- extra/yassl/include/openssl/prefix_ssl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extra/yassl/include/openssl/prefix_ssl.h b/extra/yassl/include/openssl/prefix_ssl.h index 0d740b6b97e..aa3f799cf80 100644 --- a/extra/yassl/include/openssl/prefix_ssl.h +++ b/extra/yassl/include/openssl/prefix_ssl.h @@ -1,5 +1,6 @@ #define Copyright yaCopyright #define yaSSL_CleanUp yayaSSL_CleanUp +#define BN_bin2bn yaBN_bin2bn #define DH_new yaDH_new #define DH_free yaDH_free #define RSA_free yaRSA_free @@ -92,6 +93,12 @@ #define SSL_want_read yaSSL_want_read #define SSL_want_write yaSSL_want_write #define SSL_pending yaSSL_pending +#define SSLv3_method yaSSLv3_method +#define SSLv3_server_method yaSSLv3_server_method +#define SSLv3_client_method yaSSLv3_client_method +#define TLSv1_server_method yaTLSv1_server_method +#define TLSv1_client_method yaTLSv1_client_method +#define SSLv23_server_method yaSSLv23_server_method #define SSL_CTX_use_certificate_file yaSSL_CTX_use_certificate_file #define SSL_CTX_use_PrivateKey_file yaSSL_CTX_use_PrivateKey_file #define SSL_CTX_set_cipher_list yaSSL_CTX_set_cipher_list @@ -115,11 +122,13 @@ #define RAND_write_file yaRAND_write_file #define RAND_load_file yaRAND_load_file #define RAND_status yaRAND_status +#define RAND_bytes yaRAND_bytes #define DES_set_key yaDES_set_key #define DES_set_odd_parity yaDES_set_odd_parity #define DES_ecb_encrypt yaDES_ecb_encrypt #define SSL_CTX_set_default_passwd_cb_userdata yaSSL_CTX_set_default_passwd_cb_userdata #define SSL_SESSION_free yaSSL_SESSION_free +#define SSL_peek yaSSL_peek #define SSL_get_certificate yaSSL_get_certificate #define SSL_get_privatekey yaSSL_get_privatekey #define X509_get_pubkey yaX509_get_pubkey @@ -150,4 +159,3 @@ #define MD5_Init yaMD5_Init #define MD5_Update yaMD5_Update #define MD5_Final yaMD5_Final -#define SSL_peek yaSSL_peek From 086fea980928d7fc6016823fc8e7d573663f802f Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Thu, 31 Aug 2006 15:16:44 +0200 Subject: [PATCH 067/119] Bug#21930 libmysqlclient defines BN_bin2bn which belongs to OpenSSL! Breaks other apps! - Don't add the signatures for CRYPTO_* when compiling yaSSL for MySQL --- extra/yassl/taocrypt/src/misc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index b8095334789..a33ca4fa432 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -29,7 +29,7 @@ #include "runtime.hpp" #include "misc.hpp" - +#if !defined(YASSL_MYSQL_COMPATIBLE) extern "C" { // for libcurl configure test, these are the signatures they use @@ -37,6 +37,7 @@ extern "C" { char CRYPTO_lock() { return 0;} char CRYPTO_add_lock() { return 0;} } // extern "C" +#endif #ifdef YASSL_PURE_C From 9af6450e30714030472d2eb798ba7dbdbe13e377 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Thu, 31 Aug 2006 15:17:35 +0200 Subject: [PATCH 068/119] Update the generate_prefix_files.pl --- extra/yassl/include/openssl/generate_prefix_files.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/yassl/include/openssl/generate_prefix_files.pl b/extra/yassl/include/openssl/generate_prefix_files.pl index b921ee11e9a..da591b31332 100755 --- a/extra/yassl/include/openssl/generate_prefix_files.pl +++ b/extra/yassl/include/openssl/generate_prefix_files.pl @@ -30,7 +30,7 @@ sub generate_prefix($$) next; } - if ( /^\s*[a-zA-Z0-9*_ ]+\s+([_a-zA-Z0-9]+)\s*\(/ ) + if ( /^\s*[a-zA-Z0-9*_ ]+\s+\*?([_a-zA-Z0-9]+)\s*\(/ ) { print OUT "#define $1 ya$1\n"; } From 436d3a37985e363b3be07f2c3a1a510f05f3dbed Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Thu, 31 Aug 2006 11:14:04 -0400 Subject: [PATCH 069/119] Bitkeeper's Tk interface uses UTF8 by default, so mixing charsets in a single file is a bad practice. --- tests/mysql_client_test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 94034141d81..bb4fb649a44 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -9952,8 +9952,9 @@ static void test_ps_i18n() const char *stmt_text; MYSQL_BIND bind_array[2]; - const char *koi8= "îÕ, ÚÁ ÒÙÂÁÌËÕ"; - const char *cp1251= "Íó, çà ðûáàëêó"; + /* Represented as numbers to keep UTF8 tools from clobbering them. */ + const char *koi8= "\xee\xd5\x2c\x20\xda\xc1\x20\xd2\xd9\xc2\xc1\xcc\xcb\xd5"; + const char *cp1251= "\xcd\xf3\x2c\x20\xe7\xe0\x20\xf0\xfb\xe1\xe0\xeb\xea\xf3"; char buf1[16], buf2[16]; ulong buf1_len, buf2_len; From 27636d93037a72fb77d0c711cb1630057c733ca4 Mon Sep 17 00:00:00 2001 From: "georg@lmy002.wdf.sap.corp" <> Date: Thu, 31 Aug 2006 19:52:42 +0200 Subject: [PATCH 070/119] Additional files for cmake support --- CMakeLists.txt | 132 +++++++++++++++ bdb/CMakeLists.txt | 44 +++++ client/CMakeLists.txt | 79 +++++++++ dbug/CMakeLists.txt | 5 + extra/CMakeLists.txt | 32 ++++ extra/yassl/CMakeLists.txt | 6 + extra/yassl/taocrypt/CMakeLists.txt | 10 ++ heap/CMakeLists.txt | 8 + innobase/CMakeLists.txt | 35 ++++ libmysql/CMakeLists.txt | 54 ++++++ myisam/CMakeLists.txt | 26 +++ myisammrg/CMakeLists.txt | 9 + mysys/CMakeLists.txt | 29 ++++ regex/CMakeLists.txt | 5 + server-tools/CMakeLists.txt | 18 ++ server-tools/instance-manager/CMakeLists.txt | 17 ++ sql/CMakeLists.txt | 114 +++++++++++++ sql/examples/CMakeLists.txt | 11 ++ strings/CMakeLists.txt | 12 ++ tests/CMakeLists.txt | 9 + vio/CMakeLists.txt | 6 + win/Makefile.am | 21 +++ win/README | 82 +++++++++ win/build-vs71.bat | 7 + win/build-vs8.bat | 6 + win/build-vs8_x64.bat | 6 + win/configure.js | 166 +++++++++++++++++++ zlib/CMakeLists.txt | 8 + 28 files changed, 957 insertions(+) create mode 100755 CMakeLists.txt create mode 100755 bdb/CMakeLists.txt create mode 100755 client/CMakeLists.txt create mode 100755 dbug/CMakeLists.txt create mode 100755 extra/CMakeLists.txt create mode 100755 extra/yassl/CMakeLists.txt create mode 100755 extra/yassl/taocrypt/CMakeLists.txt create mode 100755 heap/CMakeLists.txt create mode 100755 innobase/CMakeLists.txt create mode 100755 libmysql/CMakeLists.txt create mode 100755 myisam/CMakeLists.txt create mode 100755 myisammrg/CMakeLists.txt create mode 100755 mysys/CMakeLists.txt create mode 100755 regex/CMakeLists.txt create mode 100755 server-tools/CMakeLists.txt create mode 100755 server-tools/instance-manager/CMakeLists.txt create mode 100755 sql/CMakeLists.txt create mode 100755 sql/examples/CMakeLists.txt create mode 100755 strings/CMakeLists.txt create mode 100755 tests/CMakeLists.txt create mode 100755 vio/CMakeLists.txt create mode 100755 win/Makefile.am create mode 100644 win/README create mode 100755 win/build-vs71.bat create mode 100755 win/build-vs8.bat create mode 100755 win/build-vs8_x64.bat create mode 100755 win/configure.js create mode 100755 zlib/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 00000000000..fd780ec6a13 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,132 @@ +PROJECT(MySql) + +# This reads user configuration, generated by configure.js. +INCLUDE(win/configure.data) + +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in + ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY) + +# Set standard options +ADD_DEFINITIONS(-D WITH_MYISAM_STORAGE_ENGINE) +ADD_DEFINITIONS(-D CMAKE_BUILD) +ADD_DEFINITIONS(-D HAVE_YASSL) + +SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisam_plugin") + + +IF(WITH_ARCHIVE_STORAGE_ENGINE) + ADD_DEFINITIONS(-D HAVE_ARCHIVE_DB) +ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) + +IF (WITH_HEAP_STORAGE_ENGINE) + ADD_DEFINITIONS(-D WITH_HEAP_STORAGE_ENGINE) + SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_heap_plugin") +ENDIF (WITH_HEAP_STORAGE_ENGINE) + +IF (WITH_MYISAMMRG_STORAGE_ENGINE) + ADD_DEFINITIONS(-D WITH_MYISAMMRG_STORAGE_ENGINE) + SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisammrg_plugin") +ENDIF (WITH_MYISAMMRG_STORAGE_ENGINE) + +IF(WITH_INNOBASE_STORAGE_ENGINE) + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/innobase/ib_config.h.in + ${CMAKE_SOURCE_DIR}/innobase/ib_config.h @ONLY) + ADD_DEFINITIONS(-D HAVE_INNOBASE_DB) + ADD_DEFINITIONS(-D WITH_INNOBASE_STORAGE_ENGINE) + SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_innobase_plugin") +ENDIF(WITH_INNOBASE_STORAGE_ENGINE) + +IF(WITH_FEDERATED_STORAGE_ENGINE) + ADD_DEFINITIONS(-D HAVE_FEDERATED_DB) + ADD_DEFINITIONS(-D WITH_FEDERATED_STORAGE_ENGINE) + SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_federated_plugin") +ENDIF(WITH_FEDERATED_STORAGE_ENGINE) + +IF(WITH_BERKELEY_STORAGE_ENGINE) + ADD_DEFINITIONS(-D HAVE_BERKELEY_DB) + ADD_DEFINITIONS(-D WITH_BERKELEY_STORAGE_ENGINE) + SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_berkeley_plugin") +ENDIF(WITH_BERKELEY_STORAGE_ENGINE) + +IF (WITH_BLACKHOLE_STORAGE_ENGINE) + ADD_DEFINITIONS(-D HAVE_BLACKHOLE_DB) +ENDIF (WITH_BLACKHOLE_STORAGE_ENGINE) + +SET(localstatedir "C:\\mysql\\data") +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-huge.cnf.sh + ${CMAKE_SOURCE_DIR}/support-files/my-huge.ini @ONLY) +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-innodb-heavy-4G.cnf.sh + ${CMAKE_SOURCE_DIR}/support-files/my-innodb-heavy-4G.ini @ONLY) +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-large.cnf.sh + ${CMAKE_SOURCE_DIR}/support-files/my-large.ini @ONLY) +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-medium.cnf.sh + ${CMAKE_SOURCE_DIR}/support-files/my-medium.ini @ONLY) +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-small.cnf.sh + ${CMAKE_SOURCE_DIR}/support-files/my-small.ini @ONLY) + +IF(__NT__) + ADD_DEFINITIONS(-D __NT__) +ENDIF(__NT__) +IF(CYBOZU) + ADD_DEFINITIONS(-D CYBOZU) +ENDIF(CYBOZU) + +# in some places we use DBUG_OFF +SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D DBUG_OFF") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D DBUG_OFF") + +IF(CMAKE_GENERATOR MATCHES "Visual Studio 8") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /wd4996") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /wd4996") +ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8") + +IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR + CMAKE_GENERATOR MATCHES "Visual Studio 8") + # replace /MDd with /MTd + STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT + ${CMAKE_CXX_FLAGS_DEBUG_INIT}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT + ${CMAKE_C_FLAGS_DEBUG_INIT}) + STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE + ${CMAKE_C_FLAGS_RELEASE}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG + ${CMAKE_C_FLAGS_DEBUG}) + STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE + ${CMAKE_CXX_FLAGS_RELEASE}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG + ${CMAKE_CXX_FLAGS_DEBUG}) + + # remove support for Exception handling + STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT + ${CMAKE_CXX_FLAGS_INIT}) + STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT + ${CMAKE_CXX_FLAGS_DEBUG_INIT}) +ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR + CMAKE_GENERATOR MATCHES "Visual Studio 8") + +ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D _CRT_SECURE_NO_DEPRECATE") + +ADD_SUBDIRECTORY(vio) +ADD_SUBDIRECTORY(dbug) +ADD_SUBDIRECTORY(strings) +ADD_SUBDIRECTORY(regex) +ADD_SUBDIRECTORY(mysys) +ADD_SUBDIRECTORY(extra/yassl) +ADD_SUBDIRECTORY(extra/yassl/taocrypt) +ADD_SUBDIRECTORY(extra) +ADD_SUBDIRECTORY(zlib) +ADD_SUBDIRECTORY(heap) +ADD_SUBDIRECTORY(myisam) +ADD_SUBDIRECTORY(myisammrg) +ADD_SUBDIRECTORY(client) +ADD_SUBDIRECTORY(bdb) +ADD_SUBDIRECTORY(innobase) +ADD_SUBDIRECTORY(sql) +ADD_SUBDIRECTORY(sql/examples) +ADD_SUBDIRECTORY(server-tools/instance-manager) +ADD_SUBDIRECTORY(libmysql) +ADD_SUBDIRECTORY(tests) diff --git a/bdb/CMakeLists.txt b/bdb/CMakeLists.txt new file mode 100755 index 00000000000..c5dd60852d4 --- /dev/null +++ b/bdb/CMakeLists.txt @@ -0,0 +1,44 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/bdb/build_win32 + ${CMAKE_SOURCE_DIR}/bdb/dbinc + ${CMAKE_SOURCE_DIR}/bdb) + +# BDB needs a number of source files that are auto-generated by the unix +# configure. So to build BDB, it is necessary to copy these over to the Windows +# bitkeeper tree, or to use a source .tar.gz package which already has these +# files. +ADD_LIBRARY(bdb btree/bt_compare.c btree/bt_conv.c btree/bt_curadj.c btree/bt_cursor.c + btree/bt_delete.c btree/bt_method.c btree/bt_open.c btree/bt_put.c btree/bt_rec.c + btree/bt_reclaim.c btree/bt_recno.c btree/bt_rsearch.c btree/bt_search.c + btree/bt_split.c btree/bt_stat.c btree/bt_upgrade.c btree/bt_verify.c btree/btree_auto.c + db/crdel_auto.c db/crdel_rec.c db/db.c db/db_am.c db/db_auto.c common/db_byteorder.c + db/db_cam.c db/db_conv.c db/db_dispatch.c db/db_dup.c common/db_err.c common/db_getlong.c + common/db_idspace.c db/db_iface.c db/db_join.c common/db_log2.c db/db_meta.c + db/db_method.c db/db_open.c db/db_overflow.c db/db_pr.c db/db_rec.c db/db_reclaim.c + db/db_remove.c db/db_rename.c db/db_ret.c env/db_salloc.c env/db_shash.c db/db_truncate.c + db/db_upg.c db/db_upg_opd.c db/db_vrfy.c db/db_vrfyutil.c dbm/dbm.c dbreg/dbreg.c + dbreg/dbreg_auto.c dbreg/dbreg_rec.c dbreg/dbreg_util.c env/env_file.c env/env_method.c + env/env_open.c env/env_recover.c env/env_region.c fileops/fileops_auto.c fileops/fop_basic.c + fileops/fop_rec.c fileops/fop_util.c hash/hash.c hash/hash_auto.c hash/hash_conv.c + hash/hash_dup.c hash/hash_func.c hash/hash_meta.c hash/hash_method.c hash/hash_open.c + hash/hash_page.c hash/hash_rec.c hash/hash_reclaim.c hash/hash_stat.c hash/hash_upgrade.c + hash/hash_verify.c hmac/hmac.c hsearch/hsearch.c lock/lock.c lock/lock_deadlock.c + lock/lock_method.c lock/lock_region.c lock/lock_stat.c lock/lock_util.c log/log.c + log/log_archive.c log/log_compare.c log/log_get.c log/log_method.c log/log_put.c + mp/mp_alloc.c mp/mp_bh.c mp/mp_fget.c mp/mp_fopen.c mp/mp_fput.c + mp/mp_fset.c mp/mp_method.c mp/mp_region.c mp/mp_register.c mp/mp_stat.c mp/mp_sync.c + mp/mp_trickle.c mutex/mut_tas.c mutex/mut_win32.c mutex/mutex.c os_win32/os_abs.c + os/os_alloc.c os_win32/os_clock.c os_win32/os_config.c os_win32/os_dir.c os_win32/os_errno.c + os_win32/os_fid.c os_win32/os_fsync.c os_win32/os_handle.c os/os_id.c os_win32/os_map.c + os/os_method.c os/os_oflags.c os_win32/os_open.c os/os_region.c os_win32/os_rename.c + os/os_root.c os/os_rpath.c os_win32/os_rw.c os_win32/os_seek.c os_win32/os_sleep.c + os_win32/os_spin.c os_win32/os_stat.c os/os_tmpdir.c os_win32/os_type.c os/os_unlink.c + qam/qam.c qam/qam_auto.c qam/qam_conv.c qam/qam_files.c qam/qam_method.c qam/qam_open.c + qam/qam_rec.c qam/qam_stat.c qam/qam_upgrade.c qam/qam_verify.c rep/rep_method.c + rep/rep_record.c rep/rep_region.c rep/rep_util.c hmac/sha1.c + clib/strcasecmp.c txn/txn.c txn/txn_auto.c txn/txn_method.c txn/txn_rec.c + txn/txn_recover.c txn/txn_region.c txn/txn_stat.c txn/txn_util.c common/util_log.c + common/util_sig.c xa/xa.c xa/xa_db.c xa/xa_map.c) + diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt new file mode 100755 index 00000000000..3e7f1a48c70 --- /dev/null +++ b/client/CMakeLists.txt @@ -0,0 +1,79 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +# The old Windows build method used renamed (.cc -> .cpp) source files, fails +# in #include in mysqlbinlog.cc. So disable that using the USING_CMAKE define. +ADD_DEFINITIONS(-DUSING_CMAKE) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/zlib + ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/libmysql + ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/mysys + ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/strings) + +ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c + ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c + ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c + ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c + ../strings/ctype-eucjpms.c ../strings/ctype-extra.c ../strings/ctype-gb2312.c + ../strings/ctype-gbk.c ../strings/ctype-latin1.c ../strings/ctype-mb.c + ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c + ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c + ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c + ../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c + ../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c + ../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c + ../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.c + ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c + ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c + ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c + ../mysys/mf_wcomp.c ../mysys/mulalloc.c ../mysys/my_access.c ../mysys/my_alloc.c + ../mysys/my_chsize.c ../mysys/my_compress.c ../mysys/my_create.c + ../mysys/my_delete.c ../mysys/my_div.c ../mysys/my_error.c ../mysys/my_file.c + ../mysys/my_fopen.c ../mysys/my_fstream.c ../mysys/my_gethostbyname.c + ../mysys/my_getopt.c ../mysys/my_getwd.c ../mysys/my_init.c ../mysys/my_lib.c + ../mysys/my_malloc.c ../mysys/my_messnc.c ../mysys/my_net.c ../mysys/my_once.c + ../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c + ../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c + ../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c + ../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c + ../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c + ../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c + ../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c + ../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c + ../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c + ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c + ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c + ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c + ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) + +ADD_DEPENDENCIES(mysqlclient GenError) +ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) +LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) +TARGET_LINK_LIBRARIES(mysql mysqlclient mysys yassl taocrypt zlib dbug wsock32) + +ADD_EXECUTABLE(mysqltest mysqltest.c) +TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys yassl taocrypt zlib dbug regex wsock32) + +ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) +TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug yassl taocrypt zlib wsock32) + +ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) +TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug yassl taocrypt zlib wsock32) + +ADD_EXECUTABLE(mysqlimport mysqlimport.c) +TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug yassl taocrypt zlib wsock32) + +ADD_EXECUTABLE(mysqlshow mysqlshow.c) +TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug yassl taocrypt zlib wsock32) + +ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc + ../mysys/my_bit.c ../mysys/my_bitmap.c + ../mysys/base64.c) +TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug yassl taocrypt zlib wsock32) + +ADD_EXECUTABLE(mysqladmin mysqladmin.cc) +TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug yassl taocrypt zlib wsock32) + diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt new file mode 100755 index 00000000000..fe20fdd3db6 --- /dev/null +++ b/dbug/CMakeLists.txt @@ -0,0 +1,5 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -D__WIN32__") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +ADD_LIBRARY(dbug dbug.c factorial.c sanity.c) diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt new file mode 100755 index 00000000000..50e0f04eb14 --- /dev/null +++ b/extra/CMakeLists.txt @@ -0,0 +1,32 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) + +ADD_EXECUTABLE(comp_err comp_err.c) +TARGET_LINK_LIBRARIES(comp_err dbug mysys strings wsock32) + +GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION) + +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/include/mysqld_error.h + COMMAND ${COMP_ERR_EXE} + --charset=${PROJECT_SOURCE_DIR}/sql/share/charsets + --out-dir=${PROJECT_SOURCE_DIR}/sql/share/ + --header_file=${PROJECT_SOURCE_DIR}/include/mysqld_error.h + --name_file=${PROJECT_SOURCE_DIR}/include/mysqld_ername.h + --state_file=${PROJECT_SOURCE_DIR}/include/sql_state.h + --in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt + DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt) + +ADD_CUSTOM_TARGET(GenError + ALL + DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h) + +ADD_EXECUTABLE(my_print_defaults my_print_defaults.c) +TARGET_LINK_LIBRARIES(my_print_defaults strings mysys dbug taocrypt odbc32 odbccp32 wsock32) + +ADD_EXECUTABLE(perror perror.c) +TARGET_LINK_LIBRARIES(perror strings mysys dbug wsock32) + +ADD_EXECUTABLE(replace replace.c) +TARGET_LINK_LIBRARIES(replace strings mysys dbug wsock32) diff --git a/extra/yassl/CMakeLists.txt b/extra/yassl/CMakeLists.txt new file mode 100755 index 00000000000..e5429876072 --- /dev/null +++ b/extra/yassl/CMakeLists.txt @@ -0,0 +1,6 @@ +ADD_DEFINITIONS("-DWIN32 -D_LIB -DYASSL_PREFIX") + +INCLUDE_DIRECTORIES(include taocrypt/include mySTL) +ADD_LIBRARY(yassl src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp + src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp + src/yassl_imp.cpp src/yassl_int.cpp) diff --git a/extra/yassl/taocrypt/CMakeLists.txt b/extra/yassl/taocrypt/CMakeLists.txt new file mode 100755 index 00000000000..0af0a242e5d --- /dev/null +++ b/extra/yassl/taocrypt/CMakeLists.txt @@ -0,0 +1,10 @@ +INCLUDE_DIRECTORIES(../mySTL include) + +ADD_LIBRARY(taocrypt src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp + src/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp + src/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp + include/aes.hpp include/algebra.hpp include/arc4.hpp include/asn.hpp include/block.hpp + include/coding.hpp include/des.hpp include/dh.hpp include/dsa.hpp include/dsa.hpp + include/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp + include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp + include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp) diff --git a/heap/CMakeLists.txt b/heap/CMakeLists.txt new file mode 100755 index 00000000000..db5fb8b2981 --- /dev/null +++ b/heap/CMakeLists.txt @@ -0,0 +1,8 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +ADD_LIBRARY(heap _check.c _rectest.c hp_block.c hp_clear.c hp_close.c hp_create.c + hp_delete.c hp_extra.c hp_hash.c hp_info.c hp_open.c hp_panic.c + hp_rename.c hp_rfirst.c hp_rkey.c hp_rlast.c hp_rnext.c hp_rprev.c + hp_rrnd.c hp_rsame.c hp_scan.c hp_static.c hp_update.c hp_write.c) diff --git a/innobase/CMakeLists.txt b/innobase/CMakeLists.txt new file mode 100755 index 00000000000..f9661963d56 --- /dev/null +++ b/innobase/CMakeLists.txt @@ -0,0 +1,35 @@ +#SET(CMAKE_CXX_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") +#SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") +ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include include) +ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c + buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c + data/data0data.c data/data0type.c + dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c dict/dict0load.c dict/dict0mem.c + dyn/dyn0dyn.c + eval/eval0eval.c eval/eval0proc.c + fil/fil0fil.c + fsp/fsp0fsp.c + fut/fut0fut.c fut/fut0lst.c + ha/ha0ha.c ha/hash0hash.c + ibuf/ibuf0ibuf.c + pars/lexyy.c pars/pars0grm.c pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c + lock/lock0lock.c + log/log0log.c log/log0recv.c + mach/mach0data.c + mem/mem0mem.c mem/mem0pool.c + mtr/mtr0log.c mtr/mtr0mtr.c + os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c + page/page0cur.c page/page0page.c + que/que0que.c + read/read0read.c + rem/rem0cmp.c rem/rem0rec.c + row/row0ins.c row/row0mysql.c row/row0purge.c row/row0row.c row/row0sel.c row/row0uins.c + row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c + srv/srv0que.c srv/srv0srv.c srv/srv0start.c + sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c + thr/thr0loc.c + trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c + usr/usr0sess.c + ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c ) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt new file mode 100755 index 00000000000..d12b6ca6c10 --- /dev/null +++ b/libmysql/CMakeLists.txt @@ -0,0 +1,54 @@ +# Need to set USE_TLS, since __declspec(thread) approach to thread local +# storage does not work properly in DLLs. +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/zlib + ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/libmysql + ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/strings) + +ADD_LIBRARY(libmysql SHARED dll.c libmysql.def + ../mysys/array.c ../strings/bchange.c ../strings/bmove.c + ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c + ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c + ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c + ../strings/ctype-eucjpms.c ../strings/ctype-extra.c ../strings/ctype-gb2312.c + ../strings/ctype-gbk.c ../strings/ctype-latin1.c ../strings/ctype-mb.c + ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c + ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c + ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c + ../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c + ../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c + ../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c + ../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.c + ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c + ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c + ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c + ../mysys/mf_wcomp.c ../mysys/mulalloc.c ../mysys/my_access.c ../mysys/my_alloc.c + ../mysys/my_chsize.c ../mysys/my_compress.c ../mysys/my_create.c + ../mysys/my_delete.c ../mysys/my_div.c ../mysys/my_error.c ../mysys/my_file.c + ../mysys/my_fopen.c ../mysys/my_fstream.c ../mysys/my_gethostbyname.c + ../mysys/my_getopt.c ../mysys/my_getwd.c ../mysys/my_init.c ../mysys/my_lib.c + ../mysys/my_malloc.c ../mysys/my_messnc.c ../mysys/my_net.c ../mysys/my_once.c + ../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c + ../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c + ../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c + ../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c + ../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c + ../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c + ../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c + ../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c + ../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c + ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c + ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c + ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c + ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) +ADD_DEPENDENCIES(libmysql dbug vio mysys strings GenError zlib yassl taocrypt) +TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32) + +ADD_EXECUTABLE(myTest mytest.c) +TARGET_LINK_LIBRARIES(myTest libmysql) diff --git a/myisam/CMakeLists.txt b/myisam/CMakeLists.txt new file mode 100755 index 00000000000..3ba7aba4555 --- /dev/null +++ b/myisam/CMakeLists.txt @@ -0,0 +1,26 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +ADD_LIBRARY(myisam ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c ft_stem.c + ft_stopwords.c ft_update.c mi_cache.c mi_changed.c mi_check.c + mi_checksum.c mi_close.c mi_create.c mi_dbug.c mi_delete.c + mi_delete_all.c mi_delete_table.c mi_dynrec.c mi_extra.c mi_info.c + mi_key.c mi_keycache.c mi_locking.c mi_log.c mi_open.c + mi_packrec.c mi_page.c mi_panic.c mi_preload.c mi_range.c mi_rename.c + mi_rfirst.c mi_rlast.c mi_rnext.c mi_rnext_same.c mi_rprev.c mi_rrnd.c + mi_rsame.c mi_rsamepos.c mi_scan.c mi_search.c mi_static.c mi_statrec.c + mi_unique.c mi_update.c mi_write.c rt_index.c rt_key.c rt_mbr.c + rt_split.c sort.c sp_key.c ft_eval.h myisamdef.h rt_index.h mi_rkey.c) + +ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c) +TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys dbug strings zlib wsock32) + +ADD_EXECUTABLE(myisamchk myisamchk.c) +TARGET_LINK_LIBRARIES(myisamchk myisam mysys dbug strings zlib wsock32) + +ADD_EXECUTABLE(myisamlog myisamlog.c) +TARGET_LINK_LIBRARIES(myisamlog myisam mysys dbug strings zlib wsock32) + +ADD_EXECUTABLE(myisampack myisampack.c) +TARGET_LINK_LIBRARIES(myisampack myisam mysys dbug strings zlib wsock32) diff --git a/myisammrg/CMakeLists.txt b/myisammrg/CMakeLists.txt new file mode 100755 index 00000000000..83168f6c60c --- /dev/null +++ b/myisammrg/CMakeLists.txt @@ -0,0 +1,9 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +ADD_LIBRARY(myisammrg myrg_close.c myrg_create.c myrg_delete.c myrg_extra.c myrg_info.c + myrg_locking.c myrg_open.c myrg_panic.c myrg_queue.c myrg_range.c + myrg_rfirst.c myrg_rkey.c myrg_rlast.c myrg_rnext.c myrg_rnext_same.c + myrg_rprev.c myrg_rrnd.c myrg_rsame.c myrg_static.c myrg_update.c + myrg_write.c) diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt new file mode 100755 index 00000000000..7926cb916c1 --- /dev/null +++ b/mysys/CMakeLists.txt @@ -0,0 +1,29 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +# Need to set USE_TLS, since mysys is linked into libmysql.dll and +# libmysqld.dll, and __declspec(thread) approach to thread local storage does +# not work properly in DLLs. +# Currently, USE_TLS crashes in Debug builds, so until that is fixed Debug +# .dlls cannot be loaded at runtime. +SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DUSE_TLS") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DUSE_TLS") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys ) +ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_modify.c + errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c + mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c + mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c + mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_strip.c mf_tempdir.c + mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c + my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c + my_clock.c my_compress.c my_conio.c my_copy.c my_crc32.c my_create.c my_delete.c + my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c + my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c + my_lib.c my_lock.c my_lockmem.c my_lread.c my_lwrite.c my_malloc.c my_messnc.c + my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c + my_quick.c my_read.c my_realloc.c my_redel.c my_rename.c my_seek.c my_sleep.c + my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c + my_windac.c my_winsem.c my_winthread.c my_write.c ptr_cmp.c queues.c + rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c + thr_rwlock.c tree.c typelib.c base64.c my_memmem.c) diff --git a/regex/CMakeLists.txt b/regex/CMakeLists.txt new file mode 100755 index 00000000000..796481a62d5 --- /dev/null +++ b/regex/CMakeLists.txt @@ -0,0 +1,5 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys}) +ADD_LIBRARY(regex debug.c regcomp.c regerror.c regexec.c regfree.c reginit.c split.c) diff --git a/server-tools/CMakeLists.txt b/server-tools/CMakeLists.txt new file mode 100755 index 00000000000..1983d459ce2 --- /dev/null +++ b/server-tools/CMakeLists.txt @@ -0,0 +1,18 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +ADD_DEFINITIONS(-DMYSQL_SERVER -DMYSQL_INSTANCE_MANAGER) +INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/sql + ${PROJECT_SOURCE_DIR}/extra/yassl/include) + +ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instance.cc instance_map.cc + instance_options.cc listener.cc log.cc manager.cc messages.cc mysql_connection.cc + mysqlmanager.cc options.cc parse.cc parse_output.cc priv.cc protocol.cc + thread_registry.cc user_map.cc imservice.cpp windowsservice.cpp + user_management_commands.cc + ../../sql/net_serv.cc ../../sql-common/pack.c ../../sql/password.c + ../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c + ../../libmysql/errmsg.c) + +ADD_DEPENDENCIES(mysqlmanager GenError) +TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32) diff --git a/server-tools/instance-manager/CMakeLists.txt b/server-tools/instance-manager/CMakeLists.txt new file mode 100755 index 00000000000..fafc3df4108 --- /dev/null +++ b/server-tools/instance-manager/CMakeLists.txt @@ -0,0 +1,17 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +ADD_DEFINITIONS(-DMYSQL_SERVER -DMYSQL_INSTANCE_MANAGER) +INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/sql + ${PROJECT_SOURCE_DIR}/extra/yassl/include) + +ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instance.cc instance_map.cc + instance_options.cc listener.cc log.cc manager.cc messages.cc mysql_connection.cc + mysqlmanager.cc options.cc parse.cc parse_output.cc priv.cc protocol.cc + thread_registry.cc user_map.cc IMService.cpp WindowsService.cpp + ../../sql/net_serv.cc ../../sql-common/pack.c ../../sql/password.c + ../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c + ../../libmysql/errmsg.c) + +ADD_DEPENDENCIES(mysqlmanager GenError) +TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt new file mode 100755 index 00000000000..b01871872ce --- /dev/null +++ b/sql/CMakeLists.txt @@ -0,0 +1,114 @@ +SET(CMAKE_CXX_FLAGS_DEBUG + "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi") +SET(CMAKE_C_FLAGS_DEBUG + "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi") +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MAP /MAPINFO:EXPORTS") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/zlib + ${CMAKE_SOURCE_DIR}/bdb/build_win32 + ${CMAKE_SOURCE_DIR}/bdb/dbinc) + +SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/sql/message.rc + ${CMAKE_SOURCE_DIR}/sql/message.h + ${CMAKE_SOURCE_DIR}/sql/sql_yacc.h + ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc + ${CMAKE_SOURCE_DIR}/include/mysql_version.h + ${CMAKE_SOURCE_DIR}/sql/lex_hash.h + ${PROJECT_SOURCE_DIR}/include/mysqld_error.h + ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h + ${PROJECT_SOURCE_DIR}/include/sql_state.h + PROPERTIES GENERATED 1) + +ADD_DEFINITIONS(-DHAVE_INNOBASE -DMYSQL_SERVER + -D_CONSOLE -DHAVE_DLOPEN) + +ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc + discover.cc ../libmysql/errmsg.c field.cc field_conv.cc + filesort.cc gstream.cc ha_blackhole.cc + ha_archive.cc ha_heap.cc ha_myisam.cc ha_myisammrg.cc + ha_innodb.cc ha_federated.cc ha_berkeley.cc ha_blackhole.cc + handler.cc hash_filo.cc hash_filo.h + hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc + item_create.cc item_func.cc item_geofunc.cc item_row.cc + item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.cc + item_uniq.cc key.cc log.cc lock.cc log_event.cc message.rc + message.h mf_iocache.cc my_decimal.cc ../sql-common/my_time.c + ../myisammrg/myrg_rnext_same.c mysqld.cc net_serv.cc + nt_servc.cc nt_servc.h opt_range.cc opt_range.h opt_sum.cc + ../sql-common/pack.c parse_file.cc password.c procedure.cc + protocol.cc records.cc repl_failsafe.cc set_var.cc + slave.cc sp.cc sp_cache.cc sp_head.cc sp_pcontext.cc + sp_rcontext.cc spatial.cc sql_acl.cc sql_analyse.cc sql_base.cc + sql_cache.cc sql_class.cc sql_client.cc sql_crypt.cc sql_crypt.h + sql_cursor.cc sql_db.cc sql_delete.cc sql_derived.cc sql_do.cc + sql_error.cc sql_handler.cc sql_help.cc sql_insert.cc sql_lex.cc + sql_list.cc sql_load.cc sql_manager.cc sql_map.cc sql_parse.cc + sql_prepare.cc sql_rename.cc + sql_repl.cc sql_select.cc sql_show.cc sql_state.c sql_string.cc + sql_table.cc sql_test.cc sql_trigger.cc sql_udf.cc sql_union.cc + sql_update.cc sql_view.cc strfunc.cc table.cc thr_malloc.cc + time.cc tztime.cc uniques.cc unireg.cc + ../sql-common/my_user.c + sql_locale.cc + ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc + ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h + ${PROJECT_SOURCE_DIR}/include/mysqld_error.h + ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h + ${PROJECT_SOURCE_DIR}/include/sql_state.h + ${PROJECT_SOURCE_DIR}/include/mysql_version.h + ${PROJECT_SOURCE_DIR}/sql/lex_hash.h) + +TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg mysys yassl zlib dbug yassl + taocrypt strings vio regex wsock32) + +IF(WITH_EXAMPLE_STORAGE_ENGINE) + TARGET_LINK_LIBRARIES(mysqld example) +ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) + +IF(WITH_INNOBASE_STORAGE_ENGINE) + TARGET_LINK_LIBRARIES(mysqld innobase) +ENDIF(WITH_INNOBASE_STORAGE_ENGINE) + +IF(WITH_BERKELEY_STORAGE_ENGINE) + TARGET_LINK_LIBRARIES(mysqld bdb) +ENDIF(WITH_BERKELEY_STORAGE_ENGINE) + + +ADD_DEPENDENCIES(mysqld GenError) + +# Sql Parser custom command +ADD_CUSTOM_COMMAND( + SOURCE ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy + OUTPUT ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc + COMMAND bison.exe ARGS -y -p MYSQL --defines=sql_yacc.h + --output=sql_yacc.cc sql_yacc.yy + DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy) + +ADD_CUSTOM_COMMAND( + OUTPUT ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h + COMMAND echo + DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc +) + +# Windows message file +ADD_CUSTOM_COMMAND( + SOURCE ${PROJECT_SOURCE_DIR}/sql/message.mc + OUTPUT message.rc message.h + COMMAND mc ARGS ${PROJECT_SOURCE_DIR}/sql/message.mc + DEPENDS ${PROJECT_SOURCE_DIR}/sql/message.mc) + +# Gen_lex_hash +ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc) +TARGET_LINK_LIBRARIES(gen_lex_hash dbug mysqlclient wsock32) +GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION) +ADD_CUSTOM_COMMAND( + OUTPUT ${PROJECT_SOURCE_DIR}/sql/lex_hash.h + COMMAND ${GEN_LEX_HASH_EXE} ARGS > lex_hash.h + DEPENDS ${GEN_LEX_HASH_EXE} +) + +ADD_DEPENDENCIES(mysqld gen_lex_hash) diff --git a/sql/examples/CMakeLists.txt b/sql/examples/CMakeLists.txt new file mode 100755 index 00000000000..d3cc430ef40 --- /dev/null +++ b/sql/examples/CMakeLists.txt @@ -0,0 +1,11 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/regex) + +IF(WITH_EXAMPLE_STORAGE_ENGINE) +ADD_LIBRARY(example ha_example.cc) +ADD_DEPENDENCIES(example GenError) +ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt new file mode 100755 index 00000000000..0c65ce390b2 --- /dev/null +++ b/strings/CMakeLists.txt @@ -0,0 +1,12 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +ADD_LIBRARY(strings bchange.c bcmp.c bfill.c bmove512.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c + ctype-czech.c ctype-euc_kr.c ctype-eucjpms.c ctype-extra.c ctype-gb2312.c ctype-gbk.c + ctype-latin1.c ctype-mb.c ctype-simple.c ctype-sjis.c ctype-tis620.c ctype-uca.c + ctype-ucs2.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype.c decimal.c int2str.c + is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c r_strinstr.c + str2int.c str_alloc.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c + strtod.c strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c xml.c + strcont.c strinstr.c) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100755 index 00000000000..46c42d461f3 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,9 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +ADD_DEFINITIONS("-DMYSQL_CLIENT") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) + +ADD_EXECUTABLE(mysql_client_test mysql_client_test.c) +TARGET_LINK_LIBRARIES(mysql_client_test dbug mysys mysqlclient yassl taocrypt zlib wsock32) diff --git a/vio/CMakeLists.txt b/vio/CMakeLists.txt new file mode 100755 index 00000000000..a3cbb304289 --- /dev/null +++ b/vio/CMakeLists.txt @@ -0,0 +1,6 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") + +ADD_DEFINITIONS(-DUSE_SYMDIR) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/extra/yassl/include) +ADD_LIBRARY(vio vio.c viosocket.c viossl.c viosslfactories.c) diff --git a/win/Makefile.am b/win/Makefile.am new file mode 100755 index 00000000000..05c01b61360 --- /dev/null +++ b/win/Makefile.am @@ -0,0 +1,21 @@ +# Copyright (C) 2006 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 + +## Process this file with automake to create Makefile.in +EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/win/README b/win/README new file mode 100644 index 00000000000..cbda33e1184 --- /dev/null +++ b/win/README @@ -0,0 +1,82 @@ +Windows building readme +====================================== + +----------------IMPORTANT---------------------------- +This readme outlines the instructions for building +MySQL for Windows staring from version 5.0. +This readme does not apply to MySQL versions 5.1 +or ealier. +----------------------------------------------------- + +The Windows build system uses a tool named CMake to generate build files for +a variety of project systems. This tool is combined with a set of jscript +files to enable building of MySQL for Windows directly out of a bk clone. +The steps required are below. + +Step 1 +------ +Download and install CMake. It can be downloaded from http://www.cmake.org. +Once it is installed, modify your path to make sure you can execute +the cmake binary. + +Step 2 +------ +Download and install bison for Windows. It can be downloaded from +http://gnuwin32.sourceforge.net/packages/bison.htm. Please download using +the link named "Complete package, excluding sources". This includes an +installer that will install bison. After the installer finishes, modify +your path so that you can execute bison. + +Step 3 +------ +Clone your bk tree to any location you like. + +Step 4 +------ +From the root of your bk clone, execute the command: win\configure . +The options right now are + + WITH_INNOBASE_STORAGE_ENGINE Enable particular storage engines + WITH_PARTITION_STORAGE_ENGINE + WITH_ARCHIVE_STORAGE_ENGINE + WITH_BERKELEY_STORAGE_ENGINE + WITH_BLACKHOLE_STORAGE_ENGINE + WITH_EXAMPLE_STORAGE_ENGINE + WITH_FEDERATED_STORAGE_ENGINE + WITH_INNOBASE_STORAGE_ENGINE + __NT__ Enable named pipe support + MYSQL_SERVER_SUFFIX= Server suffix, default none + COMPILATION_COMMENT= Server comment, default "Source distribution" + MYSQL_TCP_PORT= Server port, default 3306 + CYBOZU + +So the command line could look like: + +win\configure WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro + +Step 5 +------ +From the root of your bk clone, execute one of the batch files to generate the type +of project files you desire. + +For Visual Studio 8, do win\build-vs8. +For Visual Studio 7.1, do win\build-vs71. + +We will support building with nmake in the near future. + +Step 6 +------ +From the root of your bk clone, start your build. + +For Visual Studio, simply execute mysql.sln. This will start the IDE and you can +click the build solution menu option. + +Current issues +-------------- +1. After changing configuration (eg. adding or removing a storage engine), it +may be necessary to clean the build tree to remove any stale objects. + +2. To use Visual C++ Express Edition you also need to install the Platform SDK. +Please see this link: http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ +At step 4 you only need to add the libraries advapi32.lib and user32.lib to +the file "corewin_express.vsprops" in order to avoid link errors. diff --git a/win/build-vs71.bat b/win/build-vs71.bat new file mode 100755 index 00000000000..959067695c5 --- /dev/null +++ b/win/build-vs71.bat @@ -0,0 +1,7 @@ +@echo off + +if exist cmakecache.txt del cmakecache.txt +copy win\vs71cache.txt cmakecache.txt +cmake -G "Visual Studio 7 .NET 2003" +copy cmakecache.txt win\vs71cache.txt + diff --git a/win/build-vs8.bat b/win/build-vs8.bat new file mode 100755 index 00000000000..d9c06241a9b --- /dev/null +++ b/win/build-vs8.bat @@ -0,0 +1,6 @@ +@echo off + +if exist cmakecache.txt del cmakecache.txt +copy win\vs8cache.txt cmakecache.txt +cmake -G "Visual Studio 8 2005" +copy cmakecache.txt win\vs8cache.txt diff --git a/win/build-vs8_x64.bat b/win/build-vs8_x64.bat new file mode 100755 index 00000000000..f1d96116390 --- /dev/null +++ b/win/build-vs8_x64.bat @@ -0,0 +1,6 @@ +@echo off + +if exist cmakecache.txt del cmakecache.txt +copy win\vs8cache.txt cmakecache.txt +cmake -G "Visual Studio 8 2005 Win64" +copy cmakecache.txt win\vs8cache.txt diff --git a/win/configure.js b/win/configure.js new file mode 100755 index 00000000000..ef90ce982a6 --- /dev/null +++ b/win/configure.js @@ -0,0 +1,166 @@ +// Configure.js + +ForReading = 1; +ForWriting = 2; +ForAppending = 8; + +try +{ + var fso = new ActiveXObject("Scripting.FileSystemObject"); + + var args = WScript.Arguments + + // read in the Unix configure.in file + var configureInTS = fso.OpenTextFile("configure.in", ForReading); + var configureIn = configureInTS.ReadAll(); + configureInTS.Close(); + var default_comment = "Source distribution"; + var default_port = GetValue(configureIn, "MYSQL_TCP_PORT_DEFAULT"); + + var configfile = fso.CreateTextFile("win\\configure.data", true); + for (i=0; i < args.Count(); i++) + { + var parts = args.Item(i).split('='); + switch (parts[0]) + { + case "WITH_ARCHIVE_STORAGE_ENGINE": + case "WITH_BERKELEY_STORAGE_ENGINE": + case "WITH_BLACKHOLE_STORAGE_ENGINE": + case "WITH_EXAMPLE_STORAGE_ENGINE": + case "WITH_FEDERATED_STORAGE_ENGINE": + case "WITH_INNOBASE_STORAGE_ENGINE": + case "WITH_PARTITION_STORAGE_ENGINE": + case "__NT__": + case "CYBOZU": + configfile.WriteLine("SET (" + args.Item(i) + " TRUE)"); + break; + case "MYSQL_SERVER_SUFFIX": + configfile.WriteLine("SET (" + parts[0] + " \"" + + parts[1] + "\")"); + break; + case "COMPILATION_COMMENT": + default_comment = parts[1]; + break; + case "MYSQL_TCP_PORT": + default_port = parts[1]; + break; + } + } + + configfile.WriteLine("SET (COMPILATION_COMMENT \"" + + default_comment + "\")"); + + configfile.WriteLine("SET (PROTOCOL_VERSION \"" + + GetValue(configureIn, "PROTOCOL_VERSION") + "\")"); + configfile.WriteLine("SET (DOT_FRM_VERSION \"" + + GetValue(configureIn, "DOT_FRM_VERSION") + "\")"); + configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + default_port + "\")"); + configfile.WriteLine("SET (MYSQL_UNIX_ADDR \"" + + GetValue(configureIn, "MYSQL_UNIX_ADDR_DEFAULT") + "\")"); + var version = GetVersion(configureIn); + configfile.WriteLine("SET (VERSION \"" + version + "\")"); + configfile.WriteLine("SET (MYSQL_BASE_VERSION \"" + + GetBaseVersion(version) + "\")"); + configfile.WriteLine("SET (MYSQL_VERSION_ID \"" + + GetVersionId(version) + "\")"); + + configfile.Close(); + + //ConfigureBDB(); + + fso = null; + + WScript.Echo("done!"); +} +catch (e) +{ + WScript.Echo("Error: " + e.description); +} + +function GetValue(str, key) +{ + var pos = str.indexOf(key+'='); + if (pos == -1) return null; + pos += key.length + 1; + var end = str.indexOf("\n", pos); + if (str.charAt(pos) == "\"") + pos++; + if (str.charAt(end-1) == "\"") + end--; + return str.substring(pos, end); +} + +function GetVersion(str) +{ + var key = "AM_INIT_AUTOMAKE(mysql, "; + var pos = str.indexOf(key); //5.0.6-beta) + if (pos == -1) return null; + pos += key.length; + var end = str.indexOf(")", pos); + if (end == -1) return null; + return str.substring(pos, end); +} + +function GetBaseVersion(version) +{ + var dot = version.indexOf("."); + if (dot == -1) return null; + dot = version.indexOf(".", dot+1); + if (dot == -1) dot = version.length; + return version.substring(0, dot); +} + +function GetVersionId(version) +{ + var dot = version.indexOf("."); + if (dot == -1) return null; + var major = parseInt(version.substring(0, dot), 10); + + dot++; + var nextdot = version.indexOf(".", dot); + if (nextdot == -1) return null; + var minor = parseInt(version.substring(dot, nextdot), 10); + dot = nextdot+1; + + var stop = version.indexOf("-", dot); + if (stop == -1) stop = version.length; + var build = parseInt(version.substring(dot, stop), 10); + + var id = major; + if (minor < 10) + id += '0'; + id += minor; + if (build < 10) + id += '0'; + id += build; + return id; +} + +function ConfigureBDB() +{ + // read in the Unix configure.in file + var dbIncTS = fso.OpenTextFile("..\\bdb\\dbinc\\db.in", ForReading); + var dbIn = dbIncTS.ReadAll(); + dbIncTS.Close(); + + dbIn = dbIn.replace("@DB_VERSION_MAJOR@", "$DB_VERSION_MAJOR"); + dbIn = dbIn.replace("@DB_VERSION_MINOR@", "$DB_VERSION_MINOR"); + dbIn = dbIn.replace("@DB_VERSION_PATCH@", "$DB_VERSION_PATCH"); + dbIn = dbIn.replace("@DB_VERSION_STRING@", "$DB_VERSION_STRING"); + + dbIn = dbIn.replace("@u_int8_decl@", "typedef unsigned char u_int8_t;"); + dbIn = dbIn.replace("@int16_decl@", "typedef short int16_t;"); + dbIn = dbIn.replace("@u_int16_decl@", "typedef unsigned short u_int16_t;"); + dbIn = dbIn.replace("@int32_decl@", "typedef int int32_t;"); + dbIn = dbIn.replace("@u_int32_decl@", "typedef unsigned int u_int32_t;"); + + dbIn = dbIn.replace("@u_char_decl@", "{\r\n#if !defined(_WINSOCKAPI_)\r\n" + + "typedef unsigned char u_char;"); + dbIn = dbIn.replace("@u_short_decl@", "typedef unsigned short u_short;"); + dbIn = dbIn.replace("@u_int_decl@", "typedef unsigned int u_int;"); + dbIn = dbIn.replace("@u_long_decl@", "typedef unsigned long u_long;"); + + dbIn = dbIn.replace("@ssize_t_decl@", "#endif\r\n#if defined(_WIN64)\r\n" + + "typedef __int64 ssize_t;\r\n#else\r\n" + + "typedef int ssize_t;\r\n#endif"); +} diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt new file mode 100755 index 00000000000..53560adf6d1 --- /dev/null +++ b/zlib/CMakeLists.txt @@ -0,0 +1,8 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") + +ADD_DEFINITIONS(-DUSE_TLS -DMYSQL_CLIENT -D__WIN32__) +ADD_LIBRARY(zlib adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h + inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h zlib.h + zutil.c zutil.h) + \ No newline at end of file From 7f243b8d198f41cd7e1381cd682a78cb4ad82f0f Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Thu, 31 Aug 2006 20:58:00 +0200 Subject: [PATCH 071/119] Only install the first masters db and copy it for the other Gives slightly faster startup --- mysql-test/lib/mtr_misc.pl | 2 ++ mysql-test/mysql-test-run.pl | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index 0ab09a40b37..dd9d24ebc8e 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -139,6 +139,8 @@ sub mtr_copy_dir($$) { my $from_dir= shift; my $to_dir= shift; +# mtr_verbose("Copying from $from_dir to $to_dir"); + mkpath("$to_dir"); opendir(DIR, "$from_dir") or mtr_error("Can't find $from_dir$!"); diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3c4e10c9363..b3dd5a26085 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -357,6 +357,7 @@ sub run_benchmarks ($); sub initialize_servers (); sub mysql_install_db (); sub install_db ($$); +sub copy_install_db ($$); sub run_testcase ($); sub run_testcase_stop_servers ($$$); sub run_testcase_start_servers ($); @@ -2237,7 +2238,7 @@ sub mysql_install_db () { # FIXME not exactly true I think, needs improvements install_db('master', $master->[0]->{'path_myddir'}); - install_db('master', $master->[1]->{'path_myddir'}); + copy_install_db('master', $master->[1]->{'path_myddir'}); if ( $use_slaves ) { @@ -2302,6 +2303,18 @@ sub mysql_install_db () { } +sub copy_install_db ($$) { + my $type= shift; + my $data_dir= shift; + + mtr_report("Installing \u$type Database"); + + # Just copy the installed db from first master + mtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir); + +} + + sub install_db ($$) { my $type= shift; my $data_dir= shift; @@ -2456,7 +2469,7 @@ sub im_prepare_data_dir($) { foreach my $instance (@{$instance_manager->{'instances'}}) { - install_db( + copy_install_db( 'im_mysqld_' . $instance->{'server_id'}, $instance->{'path_datadir'}); } From 39a139193f43987df0d4875a79b94596c7354d5d Mon Sep 17 00:00:00 2001 From: "tsmith@maint2.mysql.com" <> Date: Fri, 1 Sep 2006 05:00:32 +0200 Subject: [PATCH 072/119] post-merge fix --- mysql-test/r/heap_btree.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index c9d3db5e8e8..5b9c7f2244f 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -294,3 +294,4 @@ DROP TABLE t1; CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY; INSERT INTO t1 VALUES(NULL),(NULL); DROP TABLE t1; +End of 5.0 tests From bd2825f5bb7ab06a2f0b73afc8e58f1367687d51 Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Thu, 31 Aug 2006 20:53:34 -0700 Subject: [PATCH 073/119] Restore bug fix lost in merge of client/mysqldump.c, and clean up mysqldump.test so that 4.1 and 5.0 tests are all in the right place and no tests are duplicated. --- client/mysqldump.c | 1 + mysql-test/r/mysqldump.result | 574 ++++++++++------------------------ mysql-test/t/mysqldump.test | 219 ++++++------- 3 files changed, 249 insertions(+), 545 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 990253aa48c..d6f89022e32 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -882,6 +882,7 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res, fprintf(stderr, "%s: Couldn't execute '%s': %s (%d)\n", my_progname, query, mysql_error(mysql_con), mysql_errno(mysql_con)); + safe_exit(EX_MYSQLERR); return 1; } return 0; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index bdbaa870a42..1d131c67c73 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -640,298 +640,6 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -drop table t1; -CREATE TABLE t1 (a int); -INSERT INTO t1 VALUES (1),(2),(3); - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - -/*!40000 DROP DATABASE IF EXISTS `test`*/; - -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */; - -USE `test`; -DROP TABLE IF EXISTS `t1`; -CREATE TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -LOCK TABLES `t1` WRITE; -/*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT INTO `t1` VALUES (1),(2),(3); -/*!40000 ALTER TABLE `t1` ENABLE KEYS */; -UNLOCK TABLES; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -DROP TABLE t1; -CREATE DATABASE mysqldump_test_db; -USE mysqldump_test_db; -CREATE TABLE t1 ( a INT ); -CREATE TABLE t2 ( a INT ); -INSERT INTO t1 VALUES (1), (2); -INSERT INTO t2 VALUES (1), (2); - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `t1`; -CREATE TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -DROP TABLE IF EXISTS `t2`; -CREATE TABLE `t2` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `t1`; -CREATE TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -DROP TABLE IF EXISTS `t2`; -CREATE TABLE `t2` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -DROP TABLE t1, t2; -DROP DATABASE mysqldump_test_db; -create database mysqldump_test_db; -use mysqldump_test_db; -create table t1(a varchar(30) primary key, b int not null); -create table t2(a varchar(30) primary key, b int not null); -create table t3(a varchar(30) primary key, b int not null); -test_sequence ------- Testing with illegal table names ------ -mysqldump: Couldn't find table: "\d-2-1.sql" - -mysqldump: Couldn't find table: "\t1" - -mysqldump: Couldn't find table: "\t1" - -mysqldump: Couldn't find table: "\\t1" - -mysqldump: Couldn't find table: "t\1" - -mysqldump: Couldn't find table: "t\1" - -mysqldump: Couldn't find table: "t/1" - -test_sequence ------- Testing with illegal database names ------ -mysqldump: Got error: 1049: Unknown database 'mysqldump_test_d' when selecting the database -mysqldump: Got error: 1102: Incorrect database name 'mysqld\ump_test_db' when selecting the database -drop table t1, t2, t3; -drop database mysqldump_test_db; -use test; -create table t1 (a int(10)); -create table t2 (pk int primary key auto_increment, -a int(10), b varchar(30), c datetime, d blob, e text); -insert into t1 values (NULL), (10), (20); -insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thirty"); - - - - - - - - - 10 - - - 20 - - - - - 1 - - - - - - - - 2 - 10 - - - - - - - 3 - - twenty - - - - - - 4 - 30 - thirty - - - - - - - -drop table t1, t2; -create table t1 (a text character set utf8, b text character set latin1); -insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E); -select * from t1; -a b -Osnabrück Köln -test.t1: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0 -select * from t1; -a b -Osnabrück Köln -drop table t1; ---fields-optionally-enclosed-by=" -create table `t1` ( -t1_name varchar(255) default null, -t1_id int(10) unsigned not null auto_increment, -key (t1_name), -primary key (t1_id) -) auto_increment = 1000 default charset=latin1; -insert into t1 (t1_name) values('bla'); -insert into t1 (t1_name) values('bla'); -insert into t1 (t1_name) values('bla'); -select * from t1; -t1_name t1_id -bla 1000 -bla 1001 -bla 1002 -show create table `t1`; -Table Create Table -t1 CREATE TABLE `t1` ( - `t1_name` varchar(255) default NULL, - `t1_id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`t1_id`), - KEY `t1_name` (`t1_name`) -) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1 -DROP TABLE `t1`; -select * from t1; -t1_name t1_id -bla 1000 -bla 1001 -bla 1002 -show create table `t1`; -Table Create Table -t1 CREATE TABLE `t1` ( - `t1_name` varchar(255) default NULL, - `t1_id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`t1_id`), - KEY `t1_name` (`t1_name`) -) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1 -drop table `t1`; -create table t1(a int); -create table t2(a int); -create table t3(a int); - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `t3`; -CREATE TABLE `t3` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -DROP TABLE IF EXISTS `t1`; -CREATE TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -DROP TABLE IF EXISTS `t2`; -CREATE TABLE `t2` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -drop table t1, t2, t3; -create table t1 (a int); -mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064) -mysqldump: Got error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 when retrieving data from server - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `t1`; -CREATE TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -drop table t1; -End of 4.1 tests /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1695,92 +1403,6 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; -create database db1; -use db1; -CREATE TABLE t2 ( -a varchar(30) default NULL, -KEY a (a(5)) -); -INSERT INTO t2 VALUES ('alfred'); -INSERT INTO t2 VALUES ('angie'); -INSERT INTO t2 VALUES ('bingo'); -INSERT INTO t2 VALUES ('waffle'); -INSERT INTO t2 VALUES ('lemon'); -create view v2 as select * from t2 where a like 'a%' with check option; - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `t2`; -CREATE TABLE `t2` ( - `a` varchar(30) default NULL, - KEY `a` (`a`(5)) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -LOCK TABLES `t2` WRITE; -/*!40000 ALTER TABLE `t2` DISABLE KEYS */; -INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon'); -/*!40000 ALTER TABLE `t2` ENABLE KEYS */; -UNLOCK TABLES; -DROP TABLE IF EXISTS `v2`; -/*!50001 DROP VIEW IF EXISTS `v2`*/; -/*!50001 CREATE TABLE `v2` ( - `a` varchar(30) -) */; -/*!50001 DROP TABLE IF EXISTS `v2`*/; -/*!50001 DROP VIEW IF EXISTS `v2`*/; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */ -/*!50002 WITH CASCADED CHECK OPTION */; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -drop table t2; -drop view v2; -drop database db1; -create database db2; -use db2; -create table t1 (a int); -create table t2 (a int, b varchar(10), primary key(a)); -insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg"); -insert into t1 values (289), (298), (234), (456), (789); -create view v1 as select * from t2; -create view v2 as select * from t1; -drop table t1, t2; -drop view v1, v2; -drop database db2; -create database db1; -use db1; -show tables; -Tables_in_db1 -t1 -t2 -v1 -v2 -select * from t2 order by a; -a b -1 on -2 off -10 pol -12 meg -drop table t1, t2; -drop database db1; ---fields-optionally-enclosed-by=" CREATE DATABASE mysqldump_test_db; USE mysqldump_test_db; CREATE TABLE t1 ( a INT ); @@ -1973,6 +1595,7 @@ select * from t1; a b Osnabrück Köln drop table t1; +--fields-optionally-enclosed-by=" create table `t1` ( t1_name varchar(255) default null, t1_id int(10) unsigned not null auto_increment, @@ -2010,7 +1633,162 @@ t1 CREATE TABLE `t1` ( KEY `t1_name` (`t1_name`) ) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1 drop table `t1`; +create table t1(a int); +create table t2(a int); +create table t3(a int); + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t3`; +CREATE TABLE `t3` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +DROP TABLE IF EXISTS `t2`; +CREATE TABLE `t2` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +drop table t1, t2, t3; +create table t1 (a int); +mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064) +mysqldump: Got error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 when retrieving data from server + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +drop table t1; End of 4.1 tests +create database db1; +use db1; +CREATE TABLE t2 ( +a varchar(30) default NULL, +KEY a (a(5)) +); +INSERT INTO t2 VALUES ('alfred'); +INSERT INTO t2 VALUES ('angie'); +INSERT INTO t2 VALUES ('bingo'); +INSERT INTO t2 VALUES ('waffle'); +INSERT INTO t2 VALUES ('lemon'); +create view v2 as select * from t2 where a like 'a%' with check option; + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t2`; +CREATE TABLE `t2` ( + `a` varchar(30) default NULL, + KEY `a` (`a`(5)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +LOCK TABLES `t2` WRITE; +/*!40000 ALTER TABLE `t2` DISABLE KEYS */; +INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon'); +/*!40000 ALTER TABLE `t2` ENABLE KEYS */; +UNLOCK TABLES; +DROP TABLE IF EXISTS `v2`; +/*!50001 DROP VIEW IF EXISTS `v2`*/; +/*!50001 CREATE TABLE `v2` ( + `a` varchar(30) +) */; +/*!50001 DROP TABLE IF EXISTS `v2`*/; +/*!50001 DROP VIEW IF EXISTS `v2`*/; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */ +/*!50002 WITH CASCADED CHECK OPTION */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +drop table t2; +drop view v2; +drop database db1; +use test; +create database db2; +use db2; +create table t1 (a int); +create table t2 (a int, b varchar(10), primary key(a)); +insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg"); +insert into t1 values (289), (298), (234), (456), (789); +create view v1 as select * from t2; +create view v2 as select * from t1; +drop table t1, t2; +drop view v1, v2; +drop database db2; +use test; +create database db1; +use db1; +show tables; +Tables_in_db1 +t1 +t2 +v1 +v2 +select * from t2 order by a; +a b +1 on +2 off +10 pol +12 meg +drop table t1, t2; +drop database db1; +use test; create table t1(a int); create view v1 as select * from t1; @@ -2915,44 +2693,6 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; drop table t1; -create table t1(a int); -create table t2(a int); -create table t3(a int); - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `t3`; -CREATE TABLE `t3` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -DROP TABLE IF EXISTS `t1`; -CREATE TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -DROP TABLE IF EXISTS `t2`; -CREATE TABLE `t2` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -drop table t1, t2, t3; -End of 4.1 tests create table t1 (a int); insert into t1 values (289), (298), (234), (456), (789); create definer = CURRENT_USER view v1 as select * from t1; @@ -3198,3 +2938,5 @@ drop table t1; revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; drop user myDB_User; drop database mysqldump_myDB; +use test; +End of 5.0 tests diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index a8521b7e1eb..9766ee8d9c8 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -548,121 +548,6 @@ INSERT INTO t1 VALUES (1),(2),(3); --exec $MYSQL_DUMP --add-drop-database --skip-comments --databases test DROP TABLE t1; - -# -# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X) -# - -create database db1; -use db1; - -CREATE TABLE t2 ( - a varchar(30) default NULL, - KEY a (a(5)) -); - -INSERT INTO t2 VALUES ('alfred'); -INSERT INTO t2 VALUES ('angie'); -INSERT INTO t2 VALUES ('bingo'); -INSERT INTO t2 VALUES ('waffle'); -INSERT INTO t2 VALUES ('lemon'); -create view v2 as select * from t2 where a like 'a%' with check option; ---exec $MYSQL_DUMP --skip-comments db1 -drop table t2; -drop view v2; -drop database db1; - -# -# Bug 10713 mysqldump includes database in create view and referenced tables -# - -# create table and views in db2 -create database db2; -use db2; -create table t1 (a int); -create table t2 (a int, b varchar(10), primary key(a)); -insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg"); -insert into t1 values (289), (298), (234), (456), (789); -create view v1 as select * from t2; -create view v2 as select * from t1; - -# dump tables and view from db2 ---exec $MYSQL_DUMP db2 > $MYSQLTEST_VARDIR/tmp/bug10713.sql - -# drop the db, tables and views -drop table t1, t2; -drop view v1, v2; -drop database db2; - -# create db1 and reload dump -create database db1; -use db1; ---exec $MYSQL db1 < $MYSQLTEST_VARDIR/tmp/bug10713.sql - -# check that all tables and views could be created -show tables; -select * from t2 order by a; - -drop table t1, t2; -drop database db1; - -# -# BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence -# - ---exec $MYSQL_MY_PRINT_DEFAULTS --config-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump - - -# -# BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]" -# -create table `t1` ( - t1_name varchar(255) default null, - t1_id int(10) unsigned not null auto_increment, - key (t1_name), - primary key (t1_id) -) auto_increment = 1000 default charset=latin1; - -insert into t1 (t1_name) values('bla'); -insert into t1 (t1_name) values('bla'); -insert into t1 (t1_name) values('bla'); - -select * from t1; - -show create table `t1`; - ---exec $MYSQL_DUMP --skip-comments test t1 > $MYSQLTEST_VARDIR/tmp/bug19025.sql -DROP TABLE `t1`; - ---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug19025.sql - -select * from t1; - -show create table `t1`; - -drop table `t1`; - -# -# Bug #18536: wrong table order -# - -create table t1(a int); -create table t2(a int); -create table t3(a int); ---error 6 ---exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2 -drop table t1, t2, t3; - -# -# Bug #21288: mysqldump segmentation fault when using --where -# -create table t1 (a int); ---error 2 ---exec $MYSQL_DUMP --skip-comments --force test t1 --where='xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 2>&1 -drop table t1; - ---echo End of 4.1 tests - # # Bug #9558 mysqldump --no-data db t1 t2 format still dumps data # @@ -769,6 +654,12 @@ select * from t1; drop table t1; +# +# BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence +# + +--exec $MYSQL_MY_PRINT_DEFAULTS --config-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump + # # BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]" # @@ -798,8 +689,87 @@ show create table `t1`; drop table `t1`; +# +# Bug #18536: wrong table order +# + +create table t1(a int); +create table t2(a int); +create table t3(a int); +--error 6 +--exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2 +drop table t1, t2, t3; + +# +# Bug #21288: mysqldump segmentation fault when using --where +# +create table t1 (a int); +--error 2 +--exec $MYSQL_DUMP --skip-comments --force test t1 --where='xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 2>&1 +drop table t1; + --echo End of 4.1 tests +# +# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X) +# + +create database db1; +use db1; + +CREATE TABLE t2 ( + a varchar(30) default NULL, + KEY a (a(5)) +); + +INSERT INTO t2 VALUES ('alfred'); +INSERT INTO t2 VALUES ('angie'); +INSERT INTO t2 VALUES ('bingo'); +INSERT INTO t2 VALUES ('waffle'); +INSERT INTO t2 VALUES ('lemon'); +create view v2 as select * from t2 where a like 'a%' with check option; +--exec $MYSQL_DUMP --skip-comments db1 +drop table t2; +drop view v2; +drop database db1; +use test; + +# +# Bug 10713 mysqldump includes database in create view and referenced tables +# + +# create table and views in db2 +create database db2; +use db2; +create table t1 (a int); +create table t2 (a int, b varchar(10), primary key(a)); +insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg"); +insert into t1 values (289), (298), (234), (456), (789); +create view v1 as select * from t2; +create view v2 as select * from t1; + +# dump tables and view from db2 +--exec $MYSQL_DUMP db2 > $MYSQLTEST_VARDIR/tmp/bug10713.sql + +# drop the db, tables and views +drop table t1, t2; +drop view v1, v2; +drop database db2; +use test; + +# create db1 and reload dump +create database db1; +use db1; +--exec $MYSQL db1 < $MYSQLTEST_VARDIR/tmp/bug10713.sql + +# check that all tables and views could be created +show tables; +select * from t2 order by a; + +drop table t1, t2; +drop database db1; +use test; + # # dump of view # @@ -863,6 +833,7 @@ select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1; drop view v1, v2, v3; drop table t1; + # # Test for dumping triggers # @@ -1122,19 +1093,6 @@ insert into t1 values ('',''); --exec $MYSQL_DUMP --skip-comments --hex-blob test t1 drop table t1; -# -# Bug #18536: wrong table order -# - -create table t1(a int); -create table t2(a int); -create table t3(a int); ---error 6 ---exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2 -drop table t1, t2, t3; - ---echo End of 4.1 tests - # # Bug 14871 Invalid view dump output # @@ -1316,11 +1274,11 @@ use mysqldump_dbb; drop view v1; drop table t1; drop database mysqldump_dbb; +use test; # # Bug#21215 mysqldump creating incomplete backups without warning # -use test; # Create user without sufficient privs to perform the requested operation create user mysqltest_1@localhost; @@ -1389,3 +1347,6 @@ drop table t1; revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; drop user myDB_User; drop database mysqldump_myDB; +use test; + +--echo End of 5.0 tests From ebf482c4474b8e7ce7c33a9d0db79a05cc7678d4 Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Thu, 31 Aug 2006 21:21:23 -0700 Subject: [PATCH 074/119] Fix results of mysqldump test after messy merge --- mysql-test/r/mysqldump.result | 366 ++++++++++++++++++---------------- 1 file changed, 199 insertions(+), 167 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 07f3ffa89e4..1e1456bd81a 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1404,92 +1404,6 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; -create database db1; -use db1; -CREATE TABLE t2 ( -a varchar(30) default NULL, -KEY a (a(5)) -); -INSERT INTO t2 VALUES ('alfred'); -INSERT INTO t2 VALUES ('angie'); -INSERT INTO t2 VALUES ('bingo'); -INSERT INTO t2 VALUES ('waffle'); -INSERT INTO t2 VALUES ('lemon'); -create view v2 as select * from t2 where a like 'a%' with check option; - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `t2`; -CREATE TABLE `t2` ( - `a` varchar(30) DEFAULT NULL, - KEY `a` (`a`(5)) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -LOCK TABLES `t2` WRITE; -/*!40000 ALTER TABLE `t2` DISABLE KEYS */; -INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon'); -/*!40000 ALTER TABLE `t2` ENABLE KEYS */; -UNLOCK TABLES; -DROP TABLE IF EXISTS `v2`; -/*!50001 DROP VIEW IF EXISTS `v2`*/; -/*!50001 CREATE TABLE `v2` ( - `a` varchar(30) -) */; -/*!50001 DROP TABLE IF EXISTS `v2`*/; -/*!50001 DROP VIEW IF EXISTS `v2`*/; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */ -/*!50002 WITH CASCADED CHECK OPTION */; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -drop table t2; -drop view v2; -drop database db1; -create database db2; -use db2; -create table t1 (a int); -create table t2 (a int, b varchar(10), primary key(a)); -insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg"); -insert into t1 values (289), (298), (234), (456), (789); -create view v1 as select * from t2; -create view v2 as select * from t1; -drop table t1, t2; -drop view v1, v2; -drop database db2; -create database db1; -use db1; -show tables; -Tables_in_db1 -t1 -t2 -v1 -v2 -select * from t2 order by a; -a b -1 on -2 off -10 pol -12 meg -drop table t1, t2; -drop database db1; ---fields-optionally-enclosed-by=" CREATE DATABASE mysqldump_test_db; USE mysqldump_test_db; CREATE TABLE t1 ( a INT ); @@ -1757,8 +1671,9 @@ CREATE TABLE `t2` ( /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; drop table t1, t2, t3; -create table t1 (a binary(1), b blob); -insert into t1 values ('',''); +create table t1 (a int); +mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064) +mysqldump: Got error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 when retrieving data from server /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1772,47 +1687,9 @@ insert into t1 values ('',''); /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( - `a` binary(1) DEFAULT NULL, - `b` blob + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -LOCK TABLES `t1` WRITE; -/*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT INTO `t1` VALUES (0x00,''); -/*!40000 ALTER TABLE `t1` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `t1`; -CREATE TABLE `t1` ( - `a` binary(1) DEFAULT NULL, - `b` blob -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -LOCK TABLES `t1` WRITE; -/*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT INTO `t1` VALUES (0x00,''); -/*!40000 ALTER TABLE `t1` ENABLE KEYS */; -UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -1824,6 +1701,95 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; drop table t1; +End of 4.1 tests +create database db1; +use db1; +CREATE TABLE t2 ( +a varchar(30) default NULL, +KEY a (a(5)) +); +INSERT INTO t2 VALUES ('alfred'); +INSERT INTO t2 VALUES ('angie'); +INSERT INTO t2 VALUES ('bingo'); +INSERT INTO t2 VALUES ('waffle'); +INSERT INTO t2 VALUES ('lemon'); +create view v2 as select * from t2 where a like 'a%' with check option; + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t2`; +CREATE TABLE `t2` ( + `a` varchar(30) DEFAULT NULL, + KEY `a` (`a`(5)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +LOCK TABLES `t2` WRITE; +/*!40000 ALTER TABLE `t2` DISABLE KEYS */; +INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon'); +/*!40000 ALTER TABLE `t2` ENABLE KEYS */; +UNLOCK TABLES; +DROP TABLE IF EXISTS `v2`; +/*!50001 DROP VIEW IF EXISTS `v2`*/; +/*!50001 CREATE TABLE `v2` ( + `a` varchar(30) +) */; +/*!50001 DROP TABLE IF EXISTS `v2`*/; +/*!50001 DROP VIEW IF EXISTS `v2`*/; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */ +/*!50002 WITH CASCADED CHECK OPTION */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +drop table t2; +drop view v2; +drop database db1; +use test; +create database db2; +use db2; +create table t1 (a int); +create table t2 (a int, b varchar(10), primary key(a)); +insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg"); +insert into t1 values (289), (298), (234), (456), (789); +create view v1 as select * from t2; +create view v2 as select * from t1; +drop table t1, t2; +drop view v1, v2; +drop database db2; +use test; +create database db1; +use db1; +show tables; +Tables_in_db1 +t1 +t2 +v1 +v2 +select * from t2 order by a; +a b +1 on +2 off +10 pol +12 meg +drop table t1, t2; +drop database db1; +use test; create table t1(a int); create view v1 as select * from t1; @@ -2606,44 +2572,6 @@ drop view v2; drop view v0; drop view v1; drop table t1; -drop table if exists t1; -CREATE TABLE t1(a int, b int); -INSERT INTO t1 VALUES (1,1); -INSERT INTO t1 VALUES (2,3); -INSERT INTO t1 VALUES (3,4), (4,5); - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `t1`; -CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -LOCK TABLES `t1` WRITE; -/*!40000 ALTER TABLE `t1` DISABLE KEYS */; -REPLACE INTO `t1` VALUES (1,1),(2,3),(3,4),(4,5); -/*!40000 ALTER TABLE `t1` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -DROP TABLE t1; SET @old_sql_mode = @@SQL_MODE; SET SQL_MODE = IGNORE_SPACE; CREATE TABLE t1 (a INT); @@ -2699,7 +2627,73 @@ DELIMITER ; DROP TRIGGER tr1; DROP TABLE t1; -End of 4.1 tests +create table t1 (a binary(1), b blob); +insert into t1 values ('',''); + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` binary(1) DEFAULT NULL, + `b` blob +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +LOCK TABLES `t1` WRITE; +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +INSERT INTO `t1` VALUES (0x00,''); +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` binary(1) DEFAULT NULL, + `b` blob +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +LOCK TABLES `t1` WRITE; +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +INSERT INTO `t1` VALUES (0x00,''); +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +drop table t1; create table t1 (a int); insert into t1 values (289), (298), (234), (456), (789); create definer = CURRENT_USER view v1 as select * from t1; @@ -2940,8 +2934,46 @@ drop table t1; revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; drop user myDB_User; drop database mysqldump_myDB; -End of 5.0 tests use test; +End of 5.0 tests +drop table if exists t1; +CREATE TABLE t1(a int, b int); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t1 VALUES (2,3); +INSERT INTO t1 VALUES (3,4), (4,5); + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +LOCK TABLES `t1` WRITE; +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +REPLACE INTO `t1` VALUES (1,1),(2,3),(3,4),(4,5); +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +DROP TABLE t1; create table t1 (a text , b text); create table t2 (a text , b text); insert t1 values ("Duck, Duck", "goose"); From 9bdc99f1300c47848a8035f025339033ee00117d Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 1 Sep 2006 10:01:47 +0200 Subject: [PATCH 075/119] Use "--skip-innodb" if running with testcases that does not need innodb Decreases test time when running a selected number of tests --- mysql-test/lib/mtr_cases.pl | 8 -------- mysql-test/mysql-test-run.pl | 10 +++++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index b0ba27e6736..daed111dfce 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -469,14 +469,6 @@ sub collect_one_test_case($$$$$$$) { { mtr_options_from_test_file($tinfo,"$testdir/${tname}.test"); - if ( ! $tinfo->{'innodb_test'} ) - { - # mtr_verbose("Adding '--skip-innodb' to $tinfo->{'name'}"); - # FIXME activate the --skip-innodb only when running with - # selected test cases - # push(@{$tinfo->{'master_opt'}}, "--skip-innodb"); - } - if ( $tinfo->{'big_test'} and ! $::opt_big_test ) { $tinfo->{'skip'}= 1; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b3dd5a26085..cb7d8a16b90 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -258,6 +258,7 @@ our $opt_result_ext; our $opt_skip; our $opt_skip_rpl; our $use_slaves; +our $use_innodb; our $opt_skip_test; our $opt_skip_im; @@ -428,6 +429,7 @@ sub main () { $need_ndbcluster||= $test->{ndb_test}; $need_im||= $test->{component_id} eq 'im'; $use_slaves||= $test->{slave_num}; + $use_innodb||= $test->{'innodb_test'}; } $opt_skip_ndbcluster= $opt_skip_ndbcluster_slave= 1 unless $need_ndbcluster; @@ -2236,8 +2238,9 @@ sub initialize_servers () { sub mysql_install_db () { - # FIXME not exactly true I think, needs improvements install_db('master', $master->[0]->{'path_myddir'}); + + # FIXME check if testcase really is using second master copy_install_db('master', $master->[1]->{'path_myddir'}); if ( $use_slaves ) @@ -2252,10 +2255,8 @@ sub mysql_install_db () { im_prepare_env($instance_manager); } - my $cluster_started_ok= 1; # Assume it can be started - if (ndbcluster_start_install($clusters->[0]) || $use_slaves && ndbcluster_start_install($clusters->[1])) { @@ -2263,7 +2264,6 @@ sub mysql_install_db () { $cluster_started_ok= 0; } - foreach my $cluster (@{$clusters}) { @@ -2903,7 +2903,7 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--datadir=%s", $prefix, $master->[$idx]->{'path_myddir'}); - if ( $idx > 0 ) + if ( $idx > 0 or !$use_innodb) { mtr_add_arg($args, "%s--skip-innodb", $prefix); } From 324cf4ccb3251627bf19a8fc8dd27a7fd8b98ff4 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 1 Sep 2006 10:21:08 +0200 Subject: [PATCH 076/119] Add target to make "mtr", shortcut for running test suite --- .bzrignore | 1 + mysql-test/Makefile.am | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index 6dd06504096..4325a9177fa 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1059,3 +1059,4 @@ vio/test-sslserver vio/viotest-ssl libmysql/libmysql.ver libmysqld/sql_locale.cc +mysql-test/mtr diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index cd939417e64..1e6eb12f7b2 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -34,7 +34,7 @@ benchdir_root= $(prefix) testdir = $(benchdir_root)/mysql-test EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh $(PRESCRIPTS) EXTRA_DIST = $(EXTRA_SCRIPTS) -GENSCRIPTS = mysql-test-run install_test_db +GENSCRIPTS = mysql-test-run install_test_db mtr PRESCRIPTS = mysql-test-run.pl test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS) test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem \ @@ -105,6 +105,11 @@ std_data/server-cert.pem: std_data/server-key.pem: @CP@ $(top_srcdir)/SSL/$(@F) $(srcdir)/std_data +# mtr - a shortcut for executing mysql-test-run.pl +mtr: + $(RM) -f mtr + $(LN_S) mysql-test-run.pl mtr + SUFFIXES = .sh .sh: From 4d359b80c6fa23902f5e0f65b8773076d6bc85c7 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 1 Sep 2006 12:27:28 +0200 Subject: [PATCH 077/119] Turn off reorder as default --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index cb7d8a16b90..3d1bb2dce25 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -216,7 +216,7 @@ our $opt_embedded_server; our $opt_extern; our $opt_fast; our $opt_force; -our $opt_reorder= 1; +our $opt_reorder= 0; our $opt_enable_disabled; our $opt_gcov; From 8f378e0f3a80a6e6d81e2c2d2926a2cfe6e6ad0e Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 1 Sep 2006 13:53:43 +0200 Subject: [PATCH 078/119] Fix problem with windows where stderr is not flushed until end of program. --- client/mysqldump.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/mysqldump.c b/client/mysqldump.c index d6f89022e32..e774a07295b 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -852,6 +852,7 @@ static void DB_error(MYSQL *mysql, const char *when) DBUG_ENTER("DB_error"); fprintf(stderr, "%s: Got error: %d: %s %s\n", my_progname, mysql_errno(mysql), mysql_error(mysql), when); + fflush(stderr); safe_exit(EX_MYSQLERR); DBUG_VOID_RETURN; } /* DB_error */ From 2036bdc88e506d455acd96b600774ce3aec1bda6 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 1 Sep 2006 16:51:37 +0200 Subject: [PATCH 079/119] Move test that requires innodb to "mysql_innodb" --- mysql-test/r/auto_increment.result | 46 ------------------------------ mysql-test/r/innodb_mysql.result | 46 ++++++++++++++++++++++++++++++ mysql-test/t/auto_increment.test | 36 ----------------------- mysql-test/t/innodb_mysql.test | 37 ++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 82 deletions(-) diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 1f13264ee55..54c2df34a7f 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -446,52 +446,6 @@ INSERT INTO t1 VALUES(1, 1); ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment; ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY' DROP TABLE t1; -CREATE TABLE `t2` ( -`k` int(11) NOT NULL auto_increment, -`a` int(11) default NULL, -`c` int(11) default NULL, -PRIMARY KEY (`k`), -UNIQUE KEY `idx_1` (`a`) -) ENGINE=InnoDB; -insert into t2 ( a ) values ( 6 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -insert into t2 ( a ) values ( 7 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -select last_insert_id(); -last_insert_id() -2 -select * from t2; -k a c -1 6 NULL -2 7 NULL -insert into t2 ( a ) values ( 6 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -select last_insert_id(); -last_insert_id() -1 -select * from t2; -k a c -1 6 1 -2 7 NULL -insert ignore into t2 values (null,6,1),(10,8,1); -select last_insert_id(); -last_insert_id() -1 -insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); -select last_insert_id(); -last_insert_id() -11 -select * from t2; -k a c -1 6 1 -2 7 NULL -10 8 1 -11 15 1 -12 20 1 -drop table t2; create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c)); insert into t1 values(null,1,1,now()); insert into t1 values(null,0,0,null); diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 9f177e99a17..c5f3ed296e2 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -367,3 +367,49 @@ Warnings: Warning 1071 Specified key was too long; max key length is 765 bytes insert into t1 values('aaa'); drop table t1; +CREATE TABLE `t2` ( +`k` int(11) NOT NULL auto_increment, +`a` int(11) default NULL, +`c` int(11) default NULL, +PRIMARY KEY (`k`), +UNIQUE KEY `idx_1` (`a`) +) ENGINE=InnoDB; +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +insert into t2 ( a ) values ( 7 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +2 +select * from t2; +k a c +1 6 NULL +2 7 NULL +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +1 +select * from t2; +k a c +1 6 1 +2 7 NULL +insert ignore into t2 values (null,6,1),(10,8,1); +select last_insert_id(); +last_insert_id() +1 +insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); +select last_insert_id(); +last_insert_id() +11 +select * from t2; +k a c +1 6 1 +2 7 NULL +10 8 1 +11 15 1 +12 20 1 +drop table t2; diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index 7cef1bad784..f869dc06187 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -304,42 +304,6 @@ INSERT INTO t1 VALUES(1, 1); ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment; DROP TABLE t1; -# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY -# UPDATE": now LAST_INSERT_ID() will return the id of the updated -# row. -CREATE TABLE `t2` ( - `k` int(11) NOT NULL auto_increment, - `a` int(11) default NULL, - `c` int(11) default NULL, - PRIMARY KEY (`k`), - UNIQUE KEY `idx_1` (`a`) -) ENGINE=InnoDB; - insert into t2 ( a ) values ( 6 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -insert into t2 ( a ) values ( 7 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -select last_insert_id(); -select * from t2; -insert into t2 ( a ) values ( 6 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -select last_insert_id(); -select * from t2; - -# Test of LAST_INSERT_ID() when autogenerated will fail: -# last_insert_id() should not change -insert ignore into t2 values (null,6,1),(10,8,1); -select last_insert_id(); -# First and second autogenerated will fail, last_insert_id() should -# point to third -insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); -select last_insert_id(); -select * from t2; - -drop table t2; - # Test of REPLACE when it does INSERT+DELETE and not UPDATE: # see if it sets LAST_INSERT_ID() ok create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c)); diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index 2be53b58a39..4c84dc2faee 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -320,3 +320,40 @@ create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb character set utf8 collate utf8_general_ci; insert into t1 values('aaa'); drop table t1; + +# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY +# UPDATE": now LAST_INSERT_ID() will return the id of the updated +# row. +CREATE TABLE `t2` ( + `k` int(11) NOT NULL auto_increment, + `a` int(11) default NULL, + `c` int(11) default NULL, + PRIMARY KEY (`k`), + UNIQUE KEY `idx_1` (`a`) +) ENGINE=InnoDB; + insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +insert into t2 ( a ) values ( 7 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +select * from t2; +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +select * from t2; + +# Test of LAST_INSERT_ID() when autogenerated will fail: +# last_insert_id() should not change +insert ignore into t2 values (null,6,1),(10,8,1); +select last_insert_id(); +# First and second autogenerated will fail, last_insert_id() should +# point to third +insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); +select last_insert_id(); +select * from t2; + +drop table t2; + From 906d17779b4db4aae6620bd5548702b823c6d9f9 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 1 Sep 2006 16:56:46 +0200 Subject: [PATCH 080/119] Turn on reorder as default. --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3d1bb2dce25..cb7d8a16b90 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -216,7 +216,7 @@ our $opt_embedded_server; our $opt_extern; our $opt_fast; our $opt_force; -our $opt_reorder= 0; +our $opt_reorder= 1; our $opt_enable_disabled; our $opt_gcov; From bfb06f15fd119772f79939dd2624d513b402f693 Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Fri, 1 Sep 2006 10:39:48 -0700 Subject: [PATCH 081/119] Bug #19874: SHOW COLUMNS and SHOW KEYS handle identifiers containing \ incorrectly Identifiers with embedded escape characters were not handled correctly by some SHOW statements due to some old code that was doing some extra unescaping. --- mysql-test/r/show_check.result | 15 ++++++++++++++ mysql-test/t/show_check.test | 13 ++++++++++++ sql/sql_parse.cc | 36 ---------------------------------- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 7759a6f1f7f..b473bbac923 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -695,4 +695,19 @@ Level Code Message Warning 1541 The syntax 'SHOW PLUGIN' is deprecated and will be removed in MySQL 5.2. Please use 'SHOW PLUGINS' instead show plugin; show plugins; +create database `mysqlttest\1`; +create table `mysqlttest\1`.`a\b` (a int); +show tables from `mysqlttest\1`; +Tables_in_mysqlttest\1 +a\b +show fields from `mysqlttest\1`.`a\b`; +Field Type Null Key Default Extra +a int(11) YES NULL +show columns from `a\b` from `mysqlttest\1`; +Field Type Null Key Default Extra +a int(11) YES NULL +show keys from `mysqlttest\1`.`a\b`; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +drop table `mysqlttest\1`.`a\b`; +drop database `mysqlttest\1`; End of 5.1 tests diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index e99387bf695..553b3d9059b 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -539,4 +539,17 @@ show plugin; show plugins; --enable_result_log +# +# Bug #19874: SHOW COLUMNS and SHOW KEYS handle identifiers containing +# \ incorrectly +# +create database `mysqlttest\1`; +create table `mysqlttest\1`.`a\b` (a int); +show tables from `mysqlttest\1`; +show fields from `mysqlttest\1`.`a\b`; +show columns from `a\b` from `mysqlttest\1`; +show keys from `mysqlttest\1`.`a\b`; +drop table `mysqlttest\1`.`a\b`; +drop database `mysqlttest\1`; + --echo End of 5.1 tests diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 63de7bb1930..70e2051cab8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -67,7 +67,6 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc); static void decrease_user_connections(USER_CONN *uc); #endif /* NO_EMBEDDED_ACCESS_CHECKS */ static bool check_multi_update_lock(THD *thd); -static void remove_escape(char *name); static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables); const char *any_db="*any*"; // Special symbol for check_access @@ -1442,7 +1441,6 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name) } if (lower_case_table_names) my_casedn_str(files_charset_info, tbl_name); - remove_escape(table_list->table_name); if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT))) DBUG_RETURN(1); @@ -1909,7 +1907,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, general_log_print(thd, command, "%s %s", table_list.table_name, fields); if (lower_case_table_names) my_casedn_str(files_charset_info, table_list.table_name); - remove_escape(table_list.table_name); // This can't have wildcards if (check_access(thd,SELECT_ACL,table_list.db,&table_list.grant.privilege, 0, 0, test(table_list.schema_table))) @@ -2299,7 +2296,6 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, DBUG_RETURN(1); } db= lex->select_lex.db; - remove_escape(db); // Fix escaped '_' if (check_db_name(db)) { my_error(ER_WRONG_DB_NAME, MYF(0), db); @@ -2338,8 +2334,6 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, lex->query_tables_last= query_tables_last; TABLE_LIST *table_list= (TABLE_LIST*) sel->table_list.first; char *db= table_list->db; - remove_escape(db); // Fix escaped '_' - remove_escape(table_list->table_name); if (check_access(thd,SELECT_ACL | EXTRA_ACL,db, &table_list->grant.privilege, 0, 0, test(table_list->schema_table))) @@ -6274,36 +6268,6 @@ add_proc_to_list(THD* thd, Item *item) } -/* Fix escaping of _, % and \ in database and table names (for ODBC) */ - -static void remove_escape(char *name) -{ - if (!*name) // For empty DB names - return; - char *to; -#ifdef USE_MB - char *strend=name+(uint) strlen(name); -#endif - for (to=name; *name ; name++) - { -#ifdef USE_MB - int l; - if (use_mb(system_charset_info) && - (l = my_ismbchar(system_charset_info, name, strend))) - { - while (l--) - *to++ = *name++; - name--; - continue; - } -#endif - if (*name == '\\' && name[1]) - name++; // Skip '\\' - *to++= *name; - } - *to=0; -} - /**************************************************************************** ** save order by and tables in own lists ****************************************************************************/ From 46b3997c514fac4b991209d8679b12698bf5103f Mon Sep 17 00:00:00 2001 From: "cmiller@maint1.mysql.com" <> Date: Fri, 1 Sep 2006 21:53:23 +0200 Subject: [PATCH 082/119] mtr_cases.pl: Provide a more extensible, easier-to-change way of reordering test cases. --- mysql-test/lib/mtr_cases.pl | 58 ++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index ed0395abd9d..009269f382e 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -82,7 +82,7 @@ sub collect_test_cases ($) { if ( $mysqld_test_exists and $im_test_exists ) { - mtr_error("Ambiguos test case name ($tname)"); + mtr_error("Ambiguous test case name ($tname)"); } elsif ( ! $mysqld_test_exists and ! $im_test_exists ) { @@ -154,34 +154,38 @@ sub collect_test_cases ($) { if ( $::opt_reorder ) { - @$cases = sort { - if ( ! $a->{'master_restart'} and ! $b->{'master_restart'} ) - { - return $a->{'name'} cmp $b->{'name'}; - } - if ( $a->{'master_restart'} and $b->{'master_restart'} ) - { - my $cmp= mtr_cmp_opts($a->{'master_opt'}, $b->{'master_opt'}); - if ( $cmp == 0 ) - { - return $a->{'name'} cmp $b->{'name'}; - } - else - { - return $cmp; - } - } + my %sort_criteria; + my $tinfo; - if ( $a->{'master_restart'} ) - { - return 1; # Is greater - } - else - { - return -1; # Is less - } - } @$cases; + # Make a mapping of test name to a string that represents how that test + # should be sorted among the other tests. Put the most important criterion + # first, then a sub-criterion, then sub-sub-criterion, et c. + foreach $tinfo (@$cases) + { + my @this_criteria = (); + + # Append the criteria for sorting, in order of importance. + push(@this_criteria, join("!", sort @{$tinfo->{'master_opt'}}) . "~"); # Ending with "~" makes empty sort later than filled + push(@this_criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "1" : "0")); + push(@this_criteria, "restart=" . ($tinfo->{'master_restart'} ? "1" : "0")); + push(@this_criteria, "big_test=" . ($tinfo->{'big_test'} ? "1" : "0")); + push(@this_criteria, join("|", sort keys %{$tinfo})); # Group similar things together. The values may differ substantially. FIXME? + push(@this_criteria, $tinfo->{'name'}); # Finally, order by the name + + $sort_criteria{$tinfo->{"name"}} = join(" ", @this_criteria); + } + + @$cases = sort { $sort_criteria{$a->{"name"}} cmp $sort_criteria{$b->{"name"}}; } @$cases; + +### For debugging the sort-order +# foreach $tinfo (@$cases) +# { +# print $sort_criteria{$tinfo->{"name"}}; +# print " -> \t"; +# print $tinfo->{"name"}; +# print "\n"; +# } } return $cases; From 51e4432b79b7fd26668d4f8da2c6a4ffa03d0b4f Mon Sep 17 00:00:00 2001 From: "cmiller@maint1.mysql.com" <> Date: Sat, 2 Sep 2006 13:30:37 +0200 Subject: [PATCH 083/119] mysql-test-run.pl: 'reorder' default off until test cases fixed. --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index cb7d8a16b90..3d1bb2dce25 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -216,7 +216,7 @@ our $opt_embedded_server; our $opt_extern; our $opt_fast; our $opt_force; -our $opt_reorder= 1; +our $opt_reorder= 0; our $opt_enable_disabled; our $opt_gcov; From 41f19324886d62935728a033e6135b77b0b21e77 Mon Sep 17 00:00:00 2001 From: "tnurnberg@salvation.intern.azundris.com" <> Date: Mon, 4 Sep 2006 06:16:34 +0200 Subject: [PATCH 084/119] Bug#21913: DATE_FORMAT() Crashes mysql server if I use it through mysql-connector-j driver. Variable character_set_results can legally be NULL (for "no conversion.") This could result in a NULL deref that crashed the server. Fixed. (Although ran some additional precursory tests to see whether I could break anything else, but no breakage so far.) --- mysql-test/r/func_time.result | 12 ++++++++++++ mysql-test/t/func_time.test | 18 ++++++++++++++++++ sql/sql_string.cc | 7 ++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index fab0bf01f58..07a46f92469 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -688,3 +688,15 @@ t1 CREATE TABLE `t1` ( `from_unixtime(1) + 0` double(23,6) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +SET NAMES latin1; +SET character_set_results = NULL; +SHOW VARIABLES LIKE 'character_set_results'; +Variable_name Value +character_set_results +CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY); +INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd'); +SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868; +fmtddate field2 +Sep-4 12:00AM abcd +DROP TABLE testBug8868; +SET NAMES DEFAULT; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index b232fb14e1e..8a7f8792081 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -358,4 +358,22 @@ create table t1 select now() - now(), curtime() - curtime(), show create table t1; drop table t1; +# +# 21913: DATE_FORMAT() Crashes mysql server if I use it through +# mysql-connector-j driver. +# + +SET NAMES latin1; +SET character_set_results = NULL; +SHOW VARIABLES LIKE 'character_set_results'; + +CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY); +INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd'); + +SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868; + +DROP TABLE testBug8868; + +SET NAMES DEFAULT; + # End of 4.1 tests diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 939ffe8d9d2..aaa85b0d96c 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -248,6 +248,10 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs) 0 No conversion needed 1 Either character set conversion or adding leading zeros (e.g. for UCS-2) must be done + + NOTE + to_cs may be NULL for "no conversion" if the system variable + character_set_results is NULL. */ bool String::needs_conversion(uint32 arg_length, @@ -256,7 +260,8 @@ bool String::needs_conversion(uint32 arg_length, uint32 *offset) { *offset= 0; - if ((to_cs == &my_charset_bin) || + if (!to_cs || + (to_cs == &my_charset_bin) || (to_cs == from_cs) || my_charset_same(from_cs, to_cs) || ((from_cs == &my_charset_bin) && From c488e4b928a87993c5aa83ba1cb0183ac0d85046 Mon Sep 17 00:00:00 2001 From: "tsmith@maint1.mysql.com" <> Date: Tue, 5 Sep 2006 03:52:15 +0200 Subject: [PATCH 085/119] Applied InnoDB 5.1 snapshot ss787. Bugs fixed: - Bug #20791 valgrind errors in InnoDB Remove Valgrind warning of Bug #20791 : in new database creation, we read the doublewrite buffer magic number from uninitialized memory; the code worked because it was extremely unlikely that the memory would contain the magic number - Bug #21784 DROP TABLE crashes 5.1.12-pre if concurrent queries on the table remove update_thd() in ::store_lock() Also includes numerous coding style fixes, etc. See file-level comments for details. --- sql/ha_innodb.cc | 39 +- storage/innobase/Makefile.am | 3 +- storage/innobase/btr/btr0btr.c | 548 +++++------ storage/innobase/btr/btr0cur.c | 675 +++++++------- storage/innobase/btr/btr0pcur.c | 92 +- storage/innobase/btr/btr0sea.c | 215 +++-- storage/innobase/buf/buf0buf.c | 458 +++++----- storage/innobase/buf/buf0flu.c | 211 +++-- storage/innobase/buf/buf0lru.c | 153 ++-- storage/innobase/buf/buf0rea.c | 169 ++-- storage/innobase/data/data0data.c | 70 +- storage/innobase/data/data0type.c | 26 +- storage/innobase/dict/dict0boot.c | 84 +- storage/innobase/dict/dict0crea.c | 191 ++-- storage/innobase/dict/dict0dict.c | 590 ++++++------ storage/innobase/dict/dict0load.c | 213 ++--- storage/innobase/dict/dict0mem.c | 8 +- storage/innobase/eval/eval0eval.c | 31 +- storage/innobase/eval/eval0proc.c | 9 +- storage/innobase/fil/fil0fil.c | 797 +++++++++------- storage/innobase/fsp/fsp0fsp.c | 663 +++++++------- storage/innobase/fut/fut0lst.c | 52 +- storage/innobase/ha/ha0ha.c | 8 +- storage/innobase/ibuf/ibuf0ibuf.c | 557 ++++++------ storage/innobase/include/btr0btr.ic | 19 +- storage/innobase/include/btr0cur.h | 8 +- storage/innobase/include/btr0cur.ic | 14 +- storage/innobase/include/btr0pcur.ic | 16 +- storage/innobase/include/buf0buf.h | 4 +- storage/innobase/include/buf0buf.ic | 56 +- storage/innobase/include/buf0flu.ic | 4 +- storage/innobase/include/buf0rea.h | 3 +- storage/innobase/include/data0data.h | 8 - storage/innobase/include/data0data.ic | 14 +- storage/innobase/include/data0type.ic | 191 ++-- storage/innobase/include/dict0boot.h | 3 +- storage/innobase/include/dict0dict.ic | 18 +- storage/innobase/include/dict0mem.h | 2 - storage/innobase/include/eval0eval.ic | 4 +- storage/innobase/include/fut0lst.ic | 8 +- storage/innobase/include/ibuf0ibuf.ic | 8 +- storage/innobase/include/lock0lock.ic | 2 +- storage/innobase/include/log0log.ic | 20 +- storage/innobase/include/log0recv.h | 26 - storage/innobase/include/mach0data.ic | 36 +- storage/innobase/include/mem0mem.ic | 31 +- storage/innobase/include/mtr0log.ic | 8 +- storage/innobase/include/mtr0mtr.h | 3 +- storage/innobase/include/os0file.h | 6 +- storage/innobase/include/page0cur.ic | 12 +- storage/innobase/include/page0page.ic | 95 +- storage/innobase/include/que0que.ic | 8 +- storage/innobase/include/read0read.ic | 5 +- storage/innobase/include/rem0cmp.ic | 9 +- storage/innobase/include/rem0rec.ic | 102 ++- storage/innobase/include/row0mysql.h | 7 +- storage/innobase/include/row0purge.h | 3 +- storage/innobase/include/row0row.h | 8 +- storage/innobase/include/row0row.ic | 10 +- storage/innobase/include/row0sel.h | 20 +- storage/innobase/include/row0sel.ic | 8 +- storage/innobase/include/row0undo.h | 3 +- storage/innobase/include/row0upd.ic | 6 +- storage/innobase/include/sync0rw.h | 4 +- storage/innobase/include/sync0rw.ic | 16 +- storage/innobase/include/sync0sync.h | 5 +- storage/innobase/include/sync0sync.ic | 65 +- storage/innobase/include/trx0rec.ic | 2 +- storage/innobase/include/trx0rseg.ic | 12 +- storage/innobase/include/trx0sys.ic | 32 +- storage/innobase/include/trx0trx.h | 8 +- storage/innobase/include/trx0trx.ic | 2 +- storage/innobase/include/trx0undo.h | 8 +- storage/innobase/include/trx0undo.ic | 8 +- storage/innobase/include/trx0xa.h | 3 +- storage/innobase/include/univ.i | 2 - storage/innobase/include/ut0byte.ic | 2 +- storage/innobase/include/ut0rnd.ic | 7 +- storage/innobase/lock/lock0lock.c | 558 ++++++------ storage/innobase/log/log0log.c | 498 +++++----- storage/innobase/log/log0recv.c | 1162 +++++++++++------------ storage/innobase/mem/mem0dbg.c | 151 +-- storage/innobase/mem/mem0mem.c | 4 +- storage/innobase/mem/mem0pool.c | 60 +- storage/innobase/mtr/mtr0log.c | 48 +- storage/innobase/mtr/mtr0mtr.c | 28 +- storage/innobase/os/os0file.c | 629 +++++++------ storage/innobase/os/os0proc.c | 227 +++-- storage/innobase/os/os0sync.c | 51 +- storage/innobase/os/os0thread.c | 36 +- storage/innobase/page/page0cur.c | 222 ++--- storage/innobase/page/page0page.c | 264 +++--- storage/innobase/pars/pars0opt.c | 116 +-- storage/innobase/pars/pars0pars.c | 163 ++-- storage/innobase/que/que0que.c | 43 +- storage/innobase/read/read0read.c | 53 +- storage/innobase/rem/rem0cmp.c | 140 +-- storage/innobase/rem/rem0rec.c | 153 ++-- storage/innobase/row/row0ins.c | 428 ++++----- storage/innobase/row/row0mysql.c | 1215 ++++++++++++++----------- storage/innobase/row/row0purge.c | 64 +- storage/innobase/row/row0row.c | 82 +- storage/innobase/row/row0sel.c | 861 +++++++++--------- storage/innobase/row/row0uins.c | 18 +- storage/innobase/row/row0umod.c | 112 ++- storage/innobase/row/row0undo.c | 24 +- storage/innobase/row/row0upd.c | 258 +++--- storage/innobase/row/row0vers.c | 73 +- storage/innobase/srv/srv0srv.c | 408 +++++---- storage/innobase/srv/srv0start.c | 642 +++++++------ storage/innobase/sync/sync0arr.c | 79 +- storage/innobase/sync/sync0rw.c | 87 +- storage/innobase/sync/sync0sync.c | 132 +-- storage/innobase/thr/thr0loc.c | 10 +- storage/innobase/trx/trx0purge.c | 158 ++-- storage/innobase/trx/trx0rec.c | 155 ++-- storage/innobase/trx/trx0roll.c | 78 +- storage/innobase/trx/trx0rseg.c | 27 +- storage/innobase/trx/trx0sys.c | 380 ++++---- storage/innobase/trx/trx0trx.c | 212 +++-- storage/innobase/trx/trx0undo.c | 198 ++-- storage/innobase/ut/ut0byte.c | 2 +- storage/innobase/ut/ut0dbg.c | 18 +- storage/innobase/ut/ut0mem.c | 92 +- storage/innobase/ut/ut0ut.c | 81 +- storage/innobase/ut/ut0vec.c | 2 +- storage/innobase/ut/ut0wqueue.c | 2 +- 127 files changed, 9165 insertions(+), 8185 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 6145b6518a8..a75fae4caf0 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -6787,19 +6787,17 @@ ha_innobase::store_lock( row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; trx_t* trx; - /* Call update_thd() to update prebuilt->trx to point to the trx - object of thd! Failure to do this caused a serious memory - corruption bug in 5.1.11. */ + /* Note that trx in this function is NOT necessarily prebuilt->trx + because we call update_thd() later, in ::external_lock()! Failure to + understand this caused a serious memory corruption bug in 5.1.11. */ - update_thd(thd); + trx = check_trx_exists(thd); - trx = prebuilt->trx; - - /* NOTE: MySQL can call this function with lock 'type' TL_IGNORE! + /* NOTE: MySQL can call this function with lock 'type' TL_IGNORE! Be careful to ignore TL_IGNORE if we are going to do something with only 'real' locks! */ - /* If no MySQL tables is use we need to set isolation level + /* If no MySQL table is in use, we need to set the isolation level of the transaction. */ if (lock_type != TL_IGNORE @@ -6809,7 +6807,13 @@ ha_innobase::store_lock( thd->variables.tx_isolation); } - if ((lock_type == TL_READ && thd->in_lock_tables) || + if (thd->lex->sql_command == SQLCOM_DROP_TABLE) { + + /* MySQL calls this function in DROP TABLE though this table + handle may belong to another thd that is running a query. Let + us in that case skip any changes to the prebuilt struct. */ + + } else if ((lock_type == TL_READ && thd->in_lock_tables) || (lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) || lock_type == TL_READ_WITH_SHARED_LOCKS || lock_type == TL_READ_NO_INSERT || @@ -7400,7 +7404,9 @@ innobase_xa_prepare( int error = 0; trx_t* trx = check_trx_exists(thd); - if (thd->lex->sql_command != SQLCOM_XA_PREPARE) { + if (thd->lex->sql_command != SQLCOM_XA_PREPARE && + (all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) + { /* For ibbackup to work the order of transactions in binlog and InnoDB must be the same. Consider the situation @@ -7625,6 +7631,19 @@ SHOW_VAR innodb_status_variables_export[]= { {NullS, NullS, SHOW_LONG} }; +static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff) +{ + innodb_export_status(); + var->type= SHOW_ARRAY; + var->value= (char *) &innodb_status_variables; + return 0; +} + +SHOW_VAR innodb_status_variables_export[]= { + {"Innodb", (char*) &show_innodb_vars, SHOW_FUNC}, + {NullS, NullS, SHOW_LONG} +}; + struct st_mysql_storage_engine innobase_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION, &innobase_hton}; diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am index a5b84e0a908..a68dbbcc2e6 100644 --- a/storage/innobase/Makefile.am +++ b/storage/innobase/Makefile.am @@ -87,7 +87,8 @@ EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr include/ut0byte.h include/ut0byte.ic include/ut0dbg.h include/ut0lst.h \ include/ut0mem.h include/ut0mem.ic include/ut0rnd.h include/ut0rnd.ic \ include/ut0sort.h include/ut0ut.h include/ut0ut.ic include/ut0vec.h include/ut0vec.ic include/ha_prototypes.h \ - include/ut0list.h include/ut0list.ic include/ut0wqueue.h \ + include/ut0list.h include/ut0list.ic \ + include/ut0wqueue.h \ CMakeLists.txt noinst_LIBRARIES = libinnobase.a diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c index 57c6289e5f7..095ef6f02df 100644 --- a/storage/innobase/btr/btr0btr.c +++ b/storage/innobase/btr/btr0btr.c @@ -143,8 +143,8 @@ btr_root_get( root_page_no = dict_tree_get_page(tree); root = btr_page_get(space, root_page_no, RW_X_LATCH, mtr); - ut_a((ibool)!!page_is_comp(root) == - dict_table_is_comp(tree->tree_index->table)); + ut_a((ibool)!!page_is_comp(root) + == dict_table_is_comp(tree->tree_index->table)); return(root); } @@ -183,16 +183,16 @@ btr_get_prev_user_rec( if (prev_page_no != FIL_NULL) { prev_page = buf_page_get_with_no_latch(space, prev_page_no, - mtr); + mtr); /* The caller must already have a latch to the brother */ ut_ad((mtr_memo_contains(mtr, buf_block_align(prev_page), - MTR_MEMO_PAGE_S_FIX)) - || (mtr_memo_contains(mtr, buf_block_align(prev_page), - MTR_MEMO_PAGE_X_FIX))); + MTR_MEMO_PAGE_S_FIX)) + || (mtr_memo_contains(mtr, buf_block_align(prev_page), + MTR_MEMO_PAGE_X_FIX))); ut_a(page_is_comp(prev_page) == page_is_comp(page)); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(prev_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ return(page_rec_get_prev(page_get_supremum_rec(prev_page))); @@ -235,15 +235,15 @@ btr_get_next_user_rec( if (next_page_no != FIL_NULL) { next_page = buf_page_get_with_no_latch(space, next_page_no, - mtr); + mtr); /* The caller must already have a latch to the brother */ ut_ad((mtr_memo_contains(mtr, buf_block_align(next_page), - MTR_MEMO_PAGE_S_FIX)) - || (mtr_memo_contains(mtr, buf_block_align(next_page), - MTR_MEMO_PAGE_X_FIX))); + MTR_MEMO_PAGE_S_FIX)) + || (mtr_memo_contains(mtr, buf_block_align(next_page), + MTR_MEMO_PAGE_X_FIX))); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_prev(next_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ ut_a(page_is_comp(next_page) == page_is_comp(page)); @@ -265,9 +265,9 @@ btr_page_create( mtr_t* mtr) /* in: mtr */ { ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); page_create(page, mtr, - dict_table_is_comp(tree->tree_index->table)); + dict_table_is_comp(tree->tree_index->table)); buf_block_align(page)->check_index_page_at_flush = TRUE; btr_page_set_index_id(page, tree->id, mtr); @@ -291,19 +291,20 @@ btr_page_alloc_for_ibuf( root = btr_root_get(tree, mtr); node_addr = flst_get_first(root + PAGE_HEADER - + PAGE_BTR_IBUF_FREE_LIST, mtr); + + PAGE_BTR_IBUF_FREE_LIST, mtr); ut_a(node_addr.page != FIL_NULL); new_page = buf_page_get(dict_tree_get_space(tree), node_addr.page, - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(new_page, SYNC_TREE_NODE_NEW); #endif /* UNIV_SYNC_DEBUG */ flst_remove(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - new_page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, - mtr); - ut_ad(flst_validate(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, mtr)); + new_page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, + mtr); + ut_ad(flst_validate(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, + mtr)); return(new_page); } @@ -348,14 +349,14 @@ btr_page_alloc( be allocated: */ new_page_no = fseg_alloc_free_page_general(seg_header, hint_page_no, - file_direction, TRUE, mtr); + file_direction, TRUE, mtr); if (new_page_no == FIL_NULL) { return(NULL); } new_page = buf_page_get(dict_tree_get_space(tree), new_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(new_page, SYNC_TREE_NODE_NEW); #endif /* UNIV_SYNC_DEBUG */ @@ -421,14 +422,14 @@ btr_page_free_for_ibuf( page_t* root; ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); root = btr_root_get(tree, mtr); flst_add_first(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, mtr); + page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, mtr); ut_ad(flst_validate(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - mtr)); + mtr)); } /****************************************************************** @@ -450,7 +451,7 @@ btr_page_free_low( ulint page_no; ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); /* The page gets invalid for optimistic searches: increment the frame modify clock */ @@ -491,7 +492,7 @@ btr_page_free( ulint level; ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); level = btr_page_get_level(page, mtr); btr_page_free_low(tree, page, level, mtr); @@ -517,7 +518,7 @@ btr_node_ptr_set_child_page_no( /* The child address is in the last field */ field = rec_get_nth_field(rec, offsets, - rec_offs_n_fields(offsets) - 1, &len); + rec_offs_n_fields(offsets) - 1, &len); ut_ad(len == 4); @@ -573,7 +574,7 @@ btr_page_get_father_for_rec( *offsets_ = (sizeof offsets_) / sizeof *offsets_; ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_a(page_rec_is_user_rec(user_rec)); ut_ad(dict_tree_get_page(tree) != buf_frame_get_page_no(page)); @@ -588,16 +589,16 @@ btr_page_get_father_for_rec( first parameter for btr_cur_search_to_nth_level. */ btr_cur_search_to_nth_level(index, - btr_page_get_level(page, mtr) + 1, - tuple, PAGE_CUR_LE, - BTR_CONT_MODIFY_TREE, &cursor, 0, mtr); + btr_page_get_level(page, mtr) + 1, + tuple, PAGE_CUR_LE, + BTR_CONT_MODIFY_TREE, &cursor, 0, mtr); node_ptr = btr_cur_get_rec(&cursor); offsets = rec_get_offsets(node_ptr, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); - if (btr_node_ptr_get_child_page_no(node_ptr, offsets) != - buf_frame_get_page_no(page)) { + if (UNIV_UNLIKELY(btr_node_ptr_get_child_page_no(node_ptr, offsets) + != buf_frame_get_page_no(page))) { rec_t* print_rec; fputs("InnoDB: Dump of the child page:\n", stderr); buf_page_print(buf_frame_align(page)); @@ -609,27 +610,30 @@ btr_page_get_father_for_rec( fputs(", index ", stderr); ut_print_name(stderr, NULL, FALSE, index->name); fprintf(stderr, ",\n" -"InnoDB: father ptr page no %lu, child page no %lu\n", + "InnoDB: father ptr page no %lu, child page no %lu\n", (ulong) btr_node_ptr_get_child_page_no(node_ptr, offsets), (ulong) buf_frame_get_page_no(page)); print_rec = page_rec_get_next(page_get_infimum_rec(page)); offsets = rec_get_offsets(print_rec, index, - offsets, ULINT_UNDEFINED, &heap); + offsets, ULINT_UNDEFINED, &heap); page_rec_print(print_rec, offsets); offsets = rec_get_offsets(node_ptr, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); page_rec_print(node_ptr, offsets); - fputs( -"InnoDB: You should dump + drop + reimport the table to fix the\n" -"InnoDB: corruption. If the crash happens at the database startup, see\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html about\n" -"InnoDB: forcing recovery. Then dump + drop + reimport.\n", stderr); + fputs("InnoDB: You should dump + drop + reimport the table" + " to fix the\n" + "InnoDB: corruption. If the crash happens at " + "the database startup, see\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "forcing-recovery.html about\n" + "InnoDB: forcing recovery. " + "Then dump + drop + reimport.\n", stderr); } - ut_a(btr_node_ptr_get_child_page_no(node_ptr, offsets) == - buf_frame_get_page_no(page)); + ut_a(btr_node_ptr_get_child_page_no(node_ptr, offsets) + == buf_frame_get_page_no(page)); mem_heap_free(heap); return(node_ptr); @@ -648,7 +652,8 @@ btr_page_get_father_node_ptr( user record */ mtr_t* mtr) /* in: mtr */ { - return(btr_page_get_father_for_rec(tree, page, + return(btr_page_get_father_for_rec + (tree, page, page_rec_get_next(page_get_infimum_rec(page)), mtr)); } @@ -678,27 +683,27 @@ btr_create( if (type & DICT_IBUF) { /* Allocate first the ibuf header page */ - ibuf_hdr_frame = fseg_create(space, 0, - IBUF_HEADER + IBUF_TREE_SEG_HEADER, mtr); + ibuf_hdr_frame = fseg_create + (space, 0, IBUF_HEADER + IBUF_TREE_SEG_HEADER, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(ibuf_hdr_frame, SYNC_TREE_NODE_NEW); #endif /* UNIV_SYNC_DEBUG */ ut_ad(buf_frame_get_page_no(ibuf_hdr_frame) - == IBUF_HEADER_PAGE_NO); + == IBUF_HEADER_PAGE_NO); /* Allocate then the next page to the segment: it will be the tree root page */ - page_no = fseg_alloc_free_page( - ibuf_hdr_frame + IBUF_HEADER - + IBUF_TREE_SEG_HEADER, IBUF_TREE_ROOT_PAGE_NO, - FSP_UP, mtr); + page_no = fseg_alloc_free_page(ibuf_hdr_frame + IBUF_HEADER + + IBUF_TREE_SEG_HEADER, + IBUF_TREE_ROOT_PAGE_NO, + FSP_UP, mtr); ut_ad(page_no == IBUF_TREE_ROOT_PAGE_NO); frame = buf_page_get(space, page_no, RW_X_LATCH, mtr); } else { frame = fseg_create(space, 0, PAGE_HEADER + PAGE_BTR_SEG_TOP, - mtr); + mtr); } if (frame == NULL) { @@ -722,7 +727,7 @@ btr_create( /* It is a non-ibuf tree: create a file segment for leaf pages */ fseg_create(space, page_no, PAGE_HEADER + PAGE_BTR_SEG_LEAF, - mtr); + mtr); /* The fseg create acquires a second latch on the page, therefore we must declare it: */ #ifdef UNIV_SYNC_DEBUG @@ -781,8 +786,8 @@ leaf_loop: /* NOTE: page hash indexes are dropped when a page is freed inside fsp0fsp. */ - finished = fseg_free_step( - root + PAGE_HEADER + PAGE_BTR_SEG_LEAF, &mtr); + finished = fseg_free_step + (root + PAGE_HEADER + PAGE_BTR_SEG_LEAF, &mtr); mtr_commit(&mtr); if (!finished) { @@ -794,8 +799,8 @@ top_loop: root = btr_page_get(space, root_page_no, RW_X_LATCH, &mtr); - finished = fseg_free_step_not_header( - root + PAGE_HEADER + PAGE_BTR_SEG_TOP, &mtr); + finished = fseg_free_step_not_header + (root + PAGE_HEADER + PAGE_BTR_SEG_TOP, &mtr); mtr_commit(&mtr); if (!finished) { @@ -822,8 +827,8 @@ btr_free_root( btr_search_drop_page_hash_index(root); top_loop: - finished = fseg_free_step( - root + PAGE_HEADER + PAGE_BTR_SEG_TOP, mtr); + finished = fseg_free_step + (root + PAGE_HEADER + PAGE_BTR_SEG_TOP, mtr); if (!finished) { goto top_loop; @@ -853,15 +858,15 @@ btr_page_reorganize_low( ulint max_ins_size2; ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table)); data_size1 = page_get_data_size(page); max_ins_size1 = page_get_max_insert_size_after_reorganize(page, 1); /* Write the log record */ mlog_open_and_write_index(mtr, page, index, page_is_comp(page) - ? MLOG_COMP_PAGE_REORGANIZE - : MLOG_PAGE_REORGANIZE, 0); + ? MLOG_COMP_PAGE_REORGANIZE + : MLOG_PAGE_REORGANIZE, 0); /* Turn logging off */ log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); @@ -885,7 +890,8 @@ btr_page_reorganize_low( do not copy the lock bits yet */ page_copy_rec_list_end_no_locks(page, new_page, - page_get_infimum_rec(new_page), index, mtr); + page_get_infimum_rec(new_page), + index, mtr); /* Copy max trx id to recreated page */ page_set_max_trx_id(page, page_get_max_trx_id(new_page)); @@ -901,9 +907,12 @@ btr_page_reorganize_low( buf_page_print(page); buf_page_print(new_page); fprintf(stderr, -"InnoDB: Error: page old data size %lu new data size %lu\n" -"InnoDB: Error: page old max ins size %lu new max ins size %lu\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", + "InnoDB: Error: page old data size %lu" + " new data size %lu\n" + "InnoDB: Error: page old max ins size %lu" + " new max ins size %lu\n" + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n", (unsigned long) data_size1, (unsigned long) data_size2, (unsigned long) max_ins_size1, (unsigned long) max_ins_size2); @@ -963,7 +972,7 @@ btr_page_empty( mtr_t* mtr) /* in: mtr */ { ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); btr_search_drop_page_hash_index(page); /* Recreate the page: note that global data on page (possible @@ -1007,9 +1016,9 @@ btr_root_raise_and_insert( ut_ad(dict_tree_get_page(tree) == buf_frame_get_page_no(root)); ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, buf_block_align(root), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); btr_search_drop_page_hash_index(root); /* Allocate a new page to the tree. Root splitting is done by first @@ -1034,7 +1043,7 @@ btr_root_raise_and_insert( /* Move the records from root to the new page */ page_move_rec_list_end(new_page, root, page_get_infimum_rec(root), - cursor->index, mtr); + cursor->index, mtr); /* If this is a pessimistic insert which is actually done to perform a pessimistic update then we have stored the lock information of the record to be inserted on the infimum of the @@ -1052,7 +1061,7 @@ btr_root_raise_and_insert( child */ node_ptr = dict_tree_build_node_ptr(tree, rec, new_page_no, heap, - level); + level); /* Reorganize the root to get free space */ btr_page_reorganize(root, cursor->index, mtr); @@ -1063,7 +1072,7 @@ btr_root_raise_and_insert( page_cur_set_before_first(root, page_cursor); node_ptr_rec = page_cur_tuple_insert(page_cursor, node_ptr, - cursor->index, mtr); + cursor->index, mtr); ut_ad(node_ptr_rec); @@ -1078,13 +1087,15 @@ btr_root_raise_and_insert( /* We play safe and reset the free bits for the new page */ -/* fprintf(stderr, "Root raise new page no %lu\n", - buf_frame_get_page_no(new_page)); */ +#if 0 + fprintf(stderr, "Root raise new page no %lu\n", + buf_frame_get_page_no(new_page)); +#endif ibuf_reset_free_bits(tree->tree_index, new_page); /* Reposition the cursor to the child node */ page_cur_search(new_page, cursor->index, tuple, - PAGE_CUR_LE, page_cursor); + PAGE_CUR_LE, page_cursor); /* Split the child and insert tuple */ return(btr_page_split_and_insert(cursor, tuple, mtr)); @@ -1112,7 +1123,7 @@ btr_page_get_split_rec_to_left( insert_point = btr_cur_get_rec(cursor); if (page_header_get_ptr(page, PAGE_LAST_INSERT) - == page_rec_get_next(insert_point)) { + == page_rec_get_next(insert_point)) { infimum = page_get_infimum_rec(page); @@ -1122,7 +1133,7 @@ btr_page_get_split_rec_to_left( lots of records smaller than the convergence point. */ if (infimum != insert_point - && page_rec_get_next(infimum) != insert_point) { + && page_rec_get_next(infimum) != insert_point) { *split_rec = insert_point; } else { @@ -1160,7 +1171,7 @@ btr_page_get_split_rec_to_right( pattern of sequential inserts here. */ if (UNIV_LIKELY(page_header_get_ptr(page, PAGE_LAST_INSERT) - == insert_point)) { + == insert_point)) { rec_t* next_rec; @@ -1265,17 +1276,18 @@ btr_page_get_sure_split_rec( incl_data += insert_size; } else { offsets = rec_get_offsets(rec, cursor->index, - offsets, ULINT_UNDEFINED, &heap); + offsets, ULINT_UNDEFINED, + &heap); incl_data += rec_offs_size(offsets); } n++; if (incl_data + page_dir_calc_reserved_space(n) - >= total_space / 2) { + >= total_space / 2) { if (incl_data + page_dir_calc_reserved_space(n) - <= free_space) { + <= free_space) { /* The next record will be the first on the right half page if it is not the supremum record of page */ @@ -1335,9 +1347,9 @@ btr_page_insert_fits( ut_ad(!split_rec == !offsets); ut_ad(!offsets - || !page_is_comp(page) == !rec_offs_comp(offsets)); + || !page_is_comp(page) == !rec_offs_comp(offsets)); ut_ad(!offsets - || rec_offs_validate(split_rec, cursor->index, offsets)); + || rec_offs_validate(split_rec, cursor->index, offsets)); insert_size = rec_get_converted_size(cursor->index, tuple); free_space = page_get_free_space_of_empty(page_is_comp(page)); @@ -1365,7 +1377,7 @@ btr_page_insert_fits( } if (total_data + page_dir_calc_reserved_space(total_n_recs) - <= free_space) { + <= free_space) { /* Ok, there will be enough available space on the half page where the tuple is inserted */ @@ -1380,13 +1392,13 @@ btr_page_insert_fits( space after rec is removed from page. */ offs = rec_get_offsets(rec, cursor->index, offs, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); total_data -= rec_offs_size(offs); total_n_recs--; if (total_data + page_dir_calc_reserved_space(total_n_recs) - <= free_space) { + <= free_space) { /* Ok, there will be enough available space on the half page where the tuple is inserted */ @@ -1423,12 +1435,15 @@ btr_insert_on_non_leaf_level( first parameter for btr_cur_search_to_nth_level. */ btr_cur_search_to_nth_level(tree->tree_index, - level, tuple, PAGE_CUR_LE, BTR_CONT_MODIFY_TREE, - &cursor, 0, mtr); + level, tuple, PAGE_CUR_LE, + BTR_CONT_MODIFY_TREE, + &cursor, 0, mtr); err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG - | BTR_KEEP_SYS_FLAG | BTR_NO_UNDO_LOG_FLAG, - &cursor, tuple, &rec, &dummy_big_rec, NULL, mtr); + | BTR_KEEP_SYS_FLAG + | BTR_NO_UNDO_LOG_FLAG, + &cursor, tuple, &rec, + &dummy_big_rec, NULL, mtr); ut_a(err == DB_SUCCESS); } @@ -1462,9 +1477,9 @@ btr_attach_half_pages( mem_heap_t* heap; ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(new_page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_a(page_is_comp(page) == page_is_comp(new_page)); /* Create a memory heap where the data tuple is stored */ @@ -1484,11 +1499,10 @@ btr_attach_half_pages( /* Replace the address of the old child node (= page) with the address of the new lower half */ - btr_node_ptr_set_child_page_no(node_ptr, - rec_get_offsets(node_ptr, - tree->tree_index, - NULL, ULINT_UNDEFINED, &heap), - lower_page_no, mtr); + btr_node_ptr_set_child_page_no(node_ptr, rec_get_offsets + (node_ptr, tree->tree_index, + NULL, ULINT_UNDEFINED, &heap), + lower_page_no, mtr); mem_heap_empty(heap); } else { lower_page_no = buf_frame_get_page_no(page); @@ -1504,7 +1518,7 @@ btr_attach_half_pages( half */ node_ptr_upper = dict_tree_build_node_ptr(tree, split_rec, - upper_page_no, heap, level); + upper_page_no, heap, level); /* Insert it next to the pointer to the lower half. Note that this may generate recursion leading to a split on the higher level. */ @@ -1528,7 +1542,7 @@ btr_attach_half_pages( ut_a(page_is_comp(prev_page) == page_is_comp(page)); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(prev_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ btr_page_set_next(prev_page, lower_page_no, mtr); @@ -1600,7 +1614,7 @@ func_start: tree = btr_cur_get_tree(cursor); ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(dict_tree_get_lock(tree), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ @@ -1608,7 +1622,7 @@ func_start: page = btr_cur_get_page(cursor); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(page_get_n_recs(page) >= 2); page_no = buf_frame_get_page_no(page); @@ -1637,7 +1651,7 @@ func_start: /* 2. Allocate a new page to the tree */ new_page = btr_page_alloc(tree, hint_page_no, direction, - btr_page_get_level(page, mtr), mtr); + btr_page_get_level(page, mtr), mtr); btr_page_create(new_page, tree, mtr); /* 3. Calculate the first record on the upper half-page, and the @@ -1651,7 +1665,7 @@ func_start: buf = mem_alloc(rec_get_converted_size(cursor->index, tuple)); first_rec = rec_convert_dtuple_to_rec(buf, - cursor->index, tuple); + cursor->index, tuple); move_limit = page_rec_get_next(btr_cur_get_rec(cursor)); } @@ -1670,36 +1684,38 @@ func_start: if (split_rec) { offsets = rec_get_offsets(split_rec, cursor->index, offsets, - n_uniq, &heap); + n_uniq, &heap); insert_will_fit = btr_page_insert_fits(cursor, - split_rec, offsets, tuple, heap); + split_rec, offsets, + tuple, heap); } else { insert_will_fit = btr_page_insert_fits(cursor, - NULL, NULL, tuple, heap); + NULL, NULL, + tuple, heap); } if (insert_will_fit && (btr_page_get_level(page, mtr) == 0)) { mtr_memo_release(mtr, dict_tree_get_lock(tree), - MTR_MEMO_X_LOCK); + MTR_MEMO_X_LOCK); } /* 5. Move then the records to the new page */ if (direction == FSP_DOWN) { -/* fputs("Split left\n", stderr); */ + /* fputs("Split left\n", stderr); */ page_move_rec_list_start(new_page, page, move_limit, - cursor->index, mtr); + cursor->index, mtr); left_page = new_page; right_page = page; lock_update_split_left(right_page, left_page); } else { -/* fputs("Split right\n", stderr); */ + /* fputs("Split right\n", stderr); */ page_move_rec_list_end(new_page, page, move_limit, - cursor->index, mtr); + cursor->index, mtr); left_page = page; right_page = new_page; @@ -1714,7 +1730,7 @@ func_start: } else { offsets = rec_get_offsets(first_rec, cursor->index, - offsets, n_uniq, &heap); + offsets, n_uniq, &heap); if (cmp_dtuple_rec(tuple, first_rec, offsets) >= 0) { @@ -1728,7 +1744,7 @@ func_start: page_cursor = btr_cur_get_page_cur(cursor); page_cur_search(insert_page, cursor->index, tuple, - PAGE_CUR_LE, page_cursor); + PAGE_CUR_LE, page_cursor); rec = page_cur_tuple_insert(page_cursor, tuple, cursor->index, mtr); @@ -1740,8 +1756,8 @@ func_start: left_page, right_page, mtr); /* fprintf(stderr, "Split and insert done %lu %lu\n", - buf_frame_get_page_no(left_page), - buf_frame_get_page_no(right_page)); */ + buf_frame_get_page_no(left_page), + buf_frame_get_page_no(right_page)); */ mem_heap_free(heap); return(rec); } @@ -1751,7 +1767,7 @@ func_start: btr_page_reorganize(insert_page, cursor->index, mtr); page_cur_search(insert_page, cursor->index, tuple, - PAGE_CUR_LE, page_cursor); + PAGE_CUR_LE, page_cursor); rec = page_cur_tuple_insert(page_cursor, tuple, cursor->index, mtr); if (rec == NULL) { @@ -1762,7 +1778,7 @@ func_start: ibuf_reset_free_bits(cursor->index, new_page); /* fprintf(stderr, "Split second round %lu\n", - buf_frame_get_page_no(page)); */ + buf_frame_get_page_no(page)); */ n_iterations++; ut_ad(n_iterations < 2); ut_ad(!insert_will_fit); @@ -1774,10 +1790,12 @@ func_start: left and right pages in the same mtr */ ibuf_update_free_bits_for_two_pages_low(cursor->index, left_page, - right_page, mtr); - /* fprintf(stderr, "Split and insert done %lu %lu\n", - buf_frame_get_page_no(left_page), - buf_frame_get_page_no(right_page)); */ + right_page, mtr); +#if 0 + fprintf(stderr, "Split and insert done %lu %lu\n", + buf_frame_get_page_no(left_page), + buf_frame_get_page_no(right_page)); +#endif ut_ad(page_validate(left_page, tree->tree_index)); ut_ad(page_validate(right_page, tree->tree_index)); @@ -1804,7 +1822,7 @@ btr_level_list_remove( ut_ad(tree && page && mtr); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); /* Get the previous and next page numbers of page */ prev_page_no = btr_page_get_prev(page, mtr); @@ -1819,7 +1837,7 @@ btr_level_list_remove( ut_a(page_is_comp(prev_page) == page_is_comp(page)); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(prev_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ btr_page_set_next(prev_page, next_page_no, mtr); @@ -1831,7 +1849,7 @@ btr_level_list_remove( ut_a(page_is_comp(next_page) == page_is_comp(page)); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_prev(next_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ btr_page_set_prev(next_page, prev_page_no, mtr); @@ -1849,12 +1867,12 @@ btr_set_min_rec_mark_log( ulint comp, /* nonzero=compact record format */ mtr_t* mtr) /* in: mtr */ { - mlog_write_initial_log_record(rec, - comp ? MLOG_COMP_REC_MIN_MARK : MLOG_REC_MIN_MARK, mtr); + mlog_write_initial_log_record + (rec, comp ? MLOG_COMP_REC_MIN_MARK : MLOG_REC_MIN_MARK, mtr); /* Write rec offset as a 2-byte ulint */ mlog_catenate_ulint(mtr, ut_align_offset(rec, UNIV_PAGE_SIZE), - MLOG_2BYTES); + MLOG_2BYTES); } /******************************************************************** @@ -1924,14 +1942,14 @@ btr_node_ptr_delete( ulint err; ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); /* Delete node pointer on father page */ node_ptr = btr_page_get_father_node_ptr(tree, page, mtr); btr_cur_position(tree->tree_index, node_ptr, &cursor); compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, FALSE, - mtr); + mtr); ut_a(err == DB_SUCCESS); if (!compressed) { @@ -1960,9 +1978,9 @@ btr_lift_page_up( ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL); ut_ad(btr_page_get_next(page, mtr) == FIL_NULL); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); - father_page = buf_frame_align( - btr_page_get_father_node_ptr(tree, page, mtr)); + MTR_MEMO_PAGE_X_FIX)); + father_page = buf_frame_align + (btr_page_get_father_node_ptr(tree, page, mtr)); page_level = btr_page_get_level(page, mtr); index = tree->tree_index; @@ -1974,7 +1992,7 @@ btr_lift_page_up( /* Move records to the father */ page_copy_rec_list_end(father_page, page, page_get_infimum_rec(page), - index, mtr); + index, mtr); lock_update_copy_and_discard(father_page, page); btr_page_set_level(father_page, page_level, mtr); @@ -2032,17 +2050,19 @@ btr_compress( ut_a((ibool)!!comp == dict_table_is_comp(cursor->index->table)); ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); level = btr_page_get_level(page, mtr); space = dict_tree_get_space(tree); left_page_no = btr_page_get_prev(page, mtr); right_page_no = btr_page_get_next(page, mtr); -/* fprintf(stderr, "Merge left page %lu right %lu \n", left_page_no, - right_page_no); */ +#if 0 + fprintf(stderr, "Merge left page %lu right %lu \n", + left_page_no, right_page_no); +#endif node_ptr = btr_page_get_father_node_ptr(tree, page, mtr); ut_ad(!comp || rec_get_status(node_ptr) == REC_STATUS_NODE_PTR); @@ -2057,18 +2077,18 @@ btr_compress( if (is_left) { merge_page = btr_page_get(space, left_page_no, RW_X_LATCH, - mtr); + mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(merge_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ } else if (right_page_no != FIL_NULL) { merge_page = btr_page_get(space, right_page_no, RW_X_LATCH, - mtr); + mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_prev(merge_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ } else { /* The page is the only one on the level, lift the records @@ -2082,8 +2102,8 @@ btr_compress( data_size = page_get_data_size(page); ut_a(page_is_comp(merge_page) == comp); - max_ins_size_reorg = page_get_max_insert_size_after_reorganize( - merge_page, n_recs); + max_ins_size_reorg = page_get_max_insert_size_after_reorganize + (merge_page, n_recs); if (data_size > max_ins_size_reorg) { /* No space for merge */ @@ -2105,7 +2125,7 @@ btr_compress( ut_ad(page_validate(merge_page, cursor->index)); ut_ad(page_get_max_insert_size(merge_page, n_recs) - == max_ins_size_reorg); + == max_ins_size_reorg); } if (data_size > max_ins_size) { @@ -2129,10 +2149,11 @@ btr_compress( /* Replace the address of the old child node (= page) with the address of the merge page to the right */ - btr_node_ptr_set_child_page_no(node_ptr, - rec_get_offsets(node_ptr, cursor->index, - offsets_, ULINT_UNDEFINED, &heap), - right_page_no, mtr); + btr_node_ptr_set_child_page_no(node_ptr, rec_get_offsets + (node_ptr, cursor->index, + offsets_, ULINT_UNDEFINED, + &heap), + right_page_no, mtr); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -2141,24 +2162,26 @@ btr_compress( /* Move records to the merge page */ if (is_left) { - orig_pred = page_rec_get_prev( - page_get_supremum_rec(merge_page)); + orig_pred = page_rec_get_prev + (page_get_supremum_rec(merge_page)); page_copy_rec_list_start(merge_page, page, - page_get_supremum_rec(page), cursor->index, mtr); + page_get_supremum_rec(page), + cursor->index, mtr); lock_update_merge_left(merge_page, orig_pred, page); } else { - orig_succ = page_rec_get_next( - page_get_infimum_rec(merge_page)); + orig_succ = page_rec_get_next + (page_get_infimum_rec(merge_page)); page_copy_rec_list_end(merge_page, page, - page_get_infimum_rec(page), cursor->index, mtr); + page_get_infimum_rec(page), + cursor->index, mtr); lock_update_merge_right(orig_succ, page); } /* We have added new records to merge_page: update its free bits */ ibuf_update_free_bits_if_full(cursor->index, merge_page, - UNIV_PAGE_SIZE, ULINT_UNDEFINED); + UNIV_PAGE_SIZE, ULINT_UNDEFINED); ut_ad(page_validate(merge_page, cursor->index)); @@ -2185,7 +2208,7 @@ btr_discard_only_page_on_level( ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL); ut_ad(btr_page_get_next(page, mtr) == FIL_NULL); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); btr_search_drop_page_hash_index(page); node_ptr = btr_page_get_father_node_ptr(tree, page, mtr); @@ -2239,9 +2262,9 @@ btr_discard_page( ut_ad(dict_tree_get_page(tree) != buf_frame_get_page_no(page)); ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); space = dict_tree_get_space(tree); /* Decide the page which will inherit the locks */ @@ -2251,17 +2274,17 @@ btr_discard_page( if (left_page_no != FIL_NULL) { merge_page = btr_page_get(space, left_page_no, RW_X_LATCH, - mtr); + mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(merge_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ } else if (right_page_no != FIL_NULL) { merge_page = btr_page_get(space, right_page_no, RW_X_LATCH, - mtr); + mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_prev(merge_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ } else { btr_discard_only_page_on_level(tree, page, mtr); @@ -2292,8 +2315,8 @@ btr_discard_page( if (left_page_no != FIL_NULL) { lock_update_discard(page_get_supremum_rec(merge_page), page); } else { - lock_update_discard(page_rec_get_next( - page_get_infimum_rec(merge_page)), page); + lock_update_discard(page_rec_get_next + (page_get_infimum_rec(merge_page)), page); } /* Free the file page */ @@ -2316,9 +2339,8 @@ btr_print_size( mtr_t mtr; if (tree->type & DICT_IBUF) { - fputs( - "Sorry, cannot print info of an ibuf tree: use ibuf functions\n", - stderr); + fputs("Sorry, cannot print info of an ibuf tree:" + " use ibuf functions\n", stderr); return; } @@ -2366,7 +2388,7 @@ btr_print_recursive( dict_index_t* index; ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); fprintf(stderr, "NODE ON LEVEL %lu page number %lu\n", (ulong) btr_page_get_level(page, mtr), (ulong) buf_frame_get_page_no(page)); @@ -2392,11 +2414,11 @@ btr_print_recursive( node_ptr = page_cur_get_rec(&cursor); *offsets = rec_get_offsets(node_ptr, index, *offsets, - ULINT_UNDEFINED, heap); + ULINT_UNDEFINED, heap); child = btr_node_ptr_get_child(node_ptr, - *offsets, &mtr2); + *offsets, &mtr2); btr_print_recursive(tree, child, width, - heap, offsets, &mtr2); + heap, offsets, &mtr2); mtr_commit(&mtr2); } @@ -2423,7 +2445,7 @@ btr_print_tree( *offsets_ = (sizeof offsets_) / sizeof *offsets_; fputs("--------------------------\n" - "INDEX TREE PRINT\n", stderr); + "INDEX TREE PRINT\n", stderr); mtr_start(&mtr); @@ -2457,7 +2479,7 @@ btr_check_node_ptr( dtuple_t* node_ptr_tuple; ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); if (dict_tree_get_page(tree) == buf_frame_get_page_no(page)) { return(TRUE); @@ -2472,15 +2494,13 @@ btr_check_node_ptr( heap = mem_heap_create(256); - node_ptr_tuple = dict_tree_build_node_ptr( - tree, - page_rec_get_next(page_get_infimum_rec(page)), - 0, heap, btr_page_get_level(page, mtr)); + node_ptr_tuple = dict_tree_build_node_ptr + (tree, page_rec_get_next(page_get_infimum_rec(page)), + 0, heap, btr_page_get_level(page, mtr)); - ut_a(cmp_dtuple_rec(node_ptr_tuple, node_ptr, - rec_get_offsets(node_ptr, - tree->tree_index, - NULL, ULINT_UNDEFINED, &heap)) == 0); + ut_a(!cmp_dtuple_rec(node_ptr_tuple, node_ptr, + rec_get_offsets(node_ptr, tree->tree_index, + NULL, ULINT_UNDEFINED, &heap))); mem_heap_free(heap); @@ -2538,7 +2558,7 @@ btr_index_rec_validate( } if (UNIV_UNLIKELY((ibool)!!page_is_comp(page) - != dict_table_is_comp(index->table))) { + != dict_table_is_comp(index->table))) { btr_index_rec_validate_report(page, rec, index); fprintf(stderr, "InnoDB: compact flag=%lu, should be %lu\n", (ulong) !!page_is_comp(page), @@ -2550,7 +2570,7 @@ btr_index_rec_validate( n = dict_index_get_n_fields(index); if (!page_is_comp(page) - && UNIV_UNLIKELY(rec_get_n_fields_old(rec) != n)) { + && UNIV_UNLIKELY(rec_get_n_fields_old(rec) != n)) { btr_index_rec_validate_report(page, rec, index); fprintf(stderr, "InnoDB: has %lu fields, should have %lu\n", (ulong) rec_get_n_fields_old(rec), (ulong) n); @@ -2577,18 +2597,19 @@ btr_index_rec_validate( their type is CHAR. */ if ((dict_index_get_nth_field(index, i)->prefix_len == 0 - && len != UNIV_SQL_NULL && fixed_size - && len != fixed_size) - || - (dict_index_get_nth_field(index, i)->prefix_len > 0 - && len != UNIV_SQL_NULL - && len > - dict_index_get_nth_field(index, i)->prefix_len)) { + && len != UNIV_SQL_NULL && fixed_size + && len != fixed_size) + || (dict_index_get_nth_field(index, i)->prefix_len > 0 + && len != UNIV_SQL_NULL + && len + > dict_index_get_nth_field(index, i)->prefix_len)) { btr_index_rec_validate_report(page, rec, index); fprintf(stderr, -"InnoDB: field %lu len is %lu, should be %lu\n", - (ulong) i, (ulong) len, (ulong) dtype_get_fixed_size(type)); + "InnoDB: field %lu len is %lu," + " should be %lu\n", + (ulong) i, (ulong) len, + (ulong) dtype_get_fixed_size(type)); if (dump_on_error) { buf_page_print(page); @@ -2733,7 +2754,7 @@ btr_validate_level( node_ptr = page_cur_get_rec(&cursor); offsets = rec_get_offsets(node_ptr, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); page = btr_node_ptr_get_child(node_ptr, offsets, &mtr); } @@ -2771,18 +2792,19 @@ loop: left_page_no = btr_page_get_prev(page, &mtr); ut_a((page_get_n_recs(page) > 0) - || ((level == 0) && - (buf_frame_get_page_no(page) == dict_tree_get_page(tree)))); + || ((level == 0) + && (buf_frame_get_page_no(page) + == dict_tree_get_page(tree)))); if (right_page_no != FIL_NULL) { rec_t* right_rec; right_page = btr_page_get(space, right_page_no, RW_X_LATCH, - &mtr); + &mtr); if (UNIV_UNLIKELY(btr_page_get_prev(right_page, &mtr) - != buf_frame_get_page_no(page))) { + != buf_frame_get_page_no(page))) { btr_validate_report2(index, level, page, right_page); fputs("InnoDB: broken FIL_PAGE_NEXT" - " or FIL_PAGE_PREV links\n", stderr); + " or FIL_PAGE_PREV links\n", stderr); buf_page_print(page); buf_page_print(right_page); @@ -2790,7 +2812,7 @@ loop: } if (UNIV_UNLIKELY(page_is_comp(right_page) - != page_is_comp(page))) { + != page_is_comp(page))) { btr_validate_report2(index, level, page, right_page); fputs("InnoDB: 'compact' flag mismatch\n", stderr); buf_page_print(page); @@ -2802,19 +2824,20 @@ loop: } rec = page_rec_get_prev(page_get_supremum_rec(page)); - right_rec = page_rec_get_next( - page_get_infimum_rec(right_page)); + right_rec = page_rec_get_next(page_get_infimum_rec + (right_page)); offsets = rec_get_offsets(rec, index, - offsets, ULINT_UNDEFINED, &heap); + offsets, ULINT_UNDEFINED, &heap); offsets2 = rec_get_offsets(right_rec, index, - offsets2, ULINT_UNDEFINED, &heap); + offsets2, ULINT_UNDEFINED, &heap); if (UNIV_UNLIKELY(cmp_rec_rec(rec, right_rec, - offsets, offsets2, index) >= 0)) { + offsets, offsets2, + index) >= 0)) { btr_validate_report2(index, level, page, right_page); fputs("InnoDB: records in wrong order" - " on adjacent pages\n", stderr); + " on adjacent pages\n", stderr); buf_page_print(page); buf_page_print(right_page); @@ -2824,8 +2847,8 @@ loop: rec_print(stderr, rec, index); putc('\n', stderr); fputs("InnoDB: record ", stderr); - rec = page_rec_get_next(page_get_infimum_rec( - right_page)); + rec = page_rec_get_next + (page_get_infimum_rec(right_page)); rec_print(stderr, rec, index); putc('\n', stderr); @@ -2834,9 +2857,9 @@ loop: } if (level > 0 && left_page_no == FIL_NULL) { - ut_a(REC_INFO_MIN_REC_FLAG & rec_get_info_bits( - page_rec_get_next(page_get_infimum_rec(page)), - page_is_comp(page))); + ut_a(REC_INFO_MIN_REC_FLAG & rec_get_info_bits + (page_rec_get_next(page_get_infimum_rec(page)), + page_is_comp(page))); } if (buf_frame_get_page_no(page) != dict_tree_get_page(tree)) { @@ -2846,17 +2869,17 @@ loop: node_ptr = btr_page_get_father_node_ptr(tree, page, &mtr); father_page = buf_frame_align(node_ptr); offsets = rec_get_offsets(node_ptr, index, - offsets, ULINT_UNDEFINED, &heap); + offsets, ULINT_UNDEFINED, &heap); - if (btr_node_ptr_get_child_page_no(node_ptr, offsets) != - buf_frame_get_page_no(page) - || node_ptr != btr_page_get_father_for_rec(tree, page, - page_rec_get_prev(page_get_supremum_rec(page)), - &mtr)) { + if (btr_node_ptr_get_child_page_no(node_ptr, offsets) + != buf_frame_get_page_no(page) + || node_ptr != btr_page_get_father_for_rec + (tree, page, + page_rec_get_prev(page_get_supremum_rec(page)), &mtr)) { btr_validate_report1(index, level, page); fputs("InnoDB: node pointer to the page is wrong\n", - stderr); + stderr); buf_page_print(father_page); buf_page_print(page); @@ -2866,13 +2889,13 @@ loop: fprintf(stderr, "\n" "InnoDB: node ptr child page n:o %lu\n", - (unsigned long) btr_node_ptr_get_child_page_no( - node_ptr, offsets)); + (unsigned long) btr_node_ptr_get_child_page_no + (node_ptr, offsets)); fputs("InnoDB: record on page ", stderr); - rec = btr_page_get_father_for_rec(tree, page, - page_rec_get_prev(page_get_supremum_rec(page)), - &mtr); + rec = btr_page_get_father_for_rec + (tree, page, page_rec_get_prev + (page_get_supremum_rec(page)), &mtr); rec_print(stderr, rec, index); putc('\n', stderr); ret = FALSE; @@ -2882,19 +2905,18 @@ loop: if (btr_page_get_level(page, &mtr) > 0) { offsets = rec_get_offsets(node_ptr, index, - offsets, ULINT_UNDEFINED, &heap); + offsets, ULINT_UNDEFINED, + &heap); - node_ptr_tuple = dict_tree_build_node_ptr( - tree, - page_rec_get_next( - page_get_infimum_rec(page)), - 0, heap, - btr_page_get_level(page, &mtr)); + node_ptr_tuple = dict_tree_build_node_ptr + (tree, + page_rec_get_next(page_get_infimum_rec(page)), + 0, heap, btr_page_get_level(page, &mtr)); if (cmp_dtuple_rec(node_ptr_tuple, node_ptr, - offsets)) { - rec_t* first_rec = page_rec_get_next( - page_get_infimum_rec(page)); + offsets)) { + rec_t* first_rec = page_rec_get_next + (page_get_infimum_rec(page)); btr_validate_report1(index, level, page); @@ -2902,8 +2924,8 @@ loop: buf_page_print(page); fputs("InnoDB: Error: node ptrs differ" - " on levels > 0\n" - "InnoDB: node ptr ", stderr); + " on levels > 0\n" + "InnoDB: node ptr ", stderr); rec_print_new(stderr, node_ptr, offsets); fputs("InnoDB: first rec ", stderr); rec_print(stderr, first_rec, index); @@ -2915,49 +2937,49 @@ loop: } if (left_page_no == FIL_NULL) { - ut_a(node_ptr == page_rec_get_next( - page_get_infimum_rec(father_page))); + ut_a(node_ptr == page_rec_get_next + (page_get_infimum_rec(father_page))); ut_a(btr_page_get_prev(father_page, &mtr) == FIL_NULL); } if (right_page_no == FIL_NULL) { - ut_a(node_ptr == page_rec_get_prev( - page_get_supremum_rec(father_page))); + ut_a(node_ptr == page_rec_get_prev + (page_get_supremum_rec(father_page))); ut_a(btr_page_get_next(father_page, &mtr) == FIL_NULL); } else { - right_node_ptr = btr_page_get_father_node_ptr(tree, - right_page, &mtr); - if (page_rec_get_next(node_ptr) != - page_get_supremum_rec(father_page)) { + right_node_ptr = btr_page_get_father_node_ptr + (tree, right_page, &mtr); + if (page_rec_get_next(node_ptr) + != page_get_supremum_rec(father_page)) { - if (right_node_ptr != - page_rec_get_next(node_ptr)) { + if (right_node_ptr + != page_rec_get_next(node_ptr)) { ret = FALSE; - fputs( - "InnoDB: node pointer to the right page is wrong\n", - stderr); + fputs("InnoDB: node pointer to" + " the right page is wrong\n", + stderr); btr_validate_report1(index, level, - page); + page); buf_page_print(father_page); buf_page_print(page); buf_page_print(right_page); } } else { - right_father_page = buf_frame_align( - right_node_ptr); + right_father_page = buf_frame_align + (right_node_ptr); - if (right_node_ptr != page_rec_get_next( - page_get_infimum_rec( - right_father_page))) { + if (right_node_ptr != page_rec_get_next + (page_get_infimum_rec + (right_father_page))) { ret = FALSE; - fputs( - "InnoDB: node pointer 2 to the right page is wrong\n", - stderr); + fputs("InnoDB: node pointer 2 to" + " the right page is wrong\n", + stderr); btr_validate_report1(index, level, - page); + page); buf_page_print(father_page); buf_page_print(right_father_page); @@ -2966,15 +2988,15 @@ loop: } if (buf_frame_get_page_no(right_father_page) - != btr_page_get_next(father_page, &mtr)) { + != btr_page_get_next(father_page, &mtr)) { ret = FALSE; - fputs( - "InnoDB: node pointer 3 to the right page is wrong\n", - stderr); + fputs("InnoDB: node pointer 3 to" + " the right page is wrong\n", + stderr); btr_validate_report1(index, level, - page); + page); buf_page_print(father_page); buf_page_print(right_father_page); diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c index 7d62571284f..8fbc25c9e79 100644 --- a/storage/innobase/btr/btr0cur.c +++ b/storage/innobase/btr/btr0cur.c @@ -156,14 +156,14 @@ btr_cur_latch_leaves( if (left_page_no != FIL_NULL) { get_page = btr_page_get(space, left_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(get_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ ut_a(page_is_comp(get_page) == page_is_comp(page)); - buf_block_align(get_page)->check_index_page_at_flush = - TRUE; + buf_block_align(get_page)->check_index_page_at_flush + = TRUE; } get_page = btr_page_get(space, page_no, RW_X_LATCH, mtr); @@ -174,13 +174,13 @@ btr_cur_latch_leaves( if (right_page_no != FIL_NULL) { get_page = btr_page_get(space, right_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_prev(get_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ - buf_block_align(get_page)->check_index_page_at_flush = - TRUE; + buf_block_align(get_page)->check_index_page_at_flush + = TRUE; } } else if (latch_mode == BTR_SEARCH_PREV) { @@ -190,15 +190,15 @@ btr_cur_latch_leaves( if (left_page_no != FIL_NULL) { cursor->left_page = btr_page_get(space, left_page_no, - RW_S_LATCH, mtr); + RW_S_LATCH, mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(cursor->left_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ - ut_a(page_is_comp(cursor->left_page) == - page_is_comp(page)); - buf_block_align( - cursor->left_page)->check_index_page_at_flush = TRUE; + ut_a(page_is_comp(cursor->left_page) + == page_is_comp(page)); + buf_block_align(cursor->left_page) + ->check_index_page_at_flush = TRUE; } get_page = btr_page_get(space, page_no, RW_S_LATCH, mtr); @@ -212,15 +212,15 @@ btr_cur_latch_leaves( if (left_page_no != FIL_NULL) { cursor->left_page = btr_page_get(space, left_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(cursor->left_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ - ut_a(page_is_comp(cursor->left_page) == - page_is_comp(page)); - buf_block_align( - cursor->left_page)->check_index_page_at_flush = TRUE; + ut_a(page_is_comp(cursor->left_page) + == page_is_comp(page)); + buf_block_align(cursor->left_page) + ->check_index_page_at_flush = TRUE; } get_page = btr_page_get(space, page_no, RW_X_LATCH, mtr); @@ -237,7 +237,12 @@ NOTE: n_fields_cmp in tuple must be set so that it cannot be compared to node pointer page number fields on the upper levels of the tree! Note that if mode is PAGE_CUR_LE, which is used in inserts, then cursor->up_match and cursor->low_match both will have sensible values. -If mode is PAGE_CUR_GE, then up_match will a have a sensible value. */ +If mode is PAGE_CUR_GE, then up_match will a have a sensible value. + +If mode is PAGE_CUR_LE , cursor is left at the place where an insert of the +search tuple should be performed in the B-tree. InnoDB does an insert +immediately after the cursor. Thus, the cursor may end up on a user record, +or on a page infimum record. */ void btr_cur_search_to_nth_level( @@ -310,7 +315,7 @@ btr_cur_search_to_nth_level( estimate = latch_mode & BTR_ESTIMATE; ignore_sec_unique = latch_mode & BTR_IGNORE_SEC_UNIQUE; latch_mode = latch_mode & ~(BTR_INSERT | BTR_ESTIMATE - | BTR_IGNORE_SEC_UNIQUE); + | BTR_IGNORE_SEC_UNIQUE); ut_ad(!insert_planned || (mode == PAGE_CUR_LE)); @@ -330,24 +335,24 @@ btr_cur_search_to_nth_level( info->n_searches++; #endif if (btr_search_latch.writer == RW_LOCK_NOT_LOCKED - && latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ - && !estimate + && latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ + && !estimate #ifdef PAGE_CUR_LE_OR_EXTENDS - && mode != PAGE_CUR_LE_OR_EXTENDS + && mode != PAGE_CUR_LE_OR_EXTENDS #endif /* PAGE_CUR_LE_OR_EXTENDS */ - && srv_use_adaptive_hash_indexes - && btr_search_guess_on_hash(index, info, tuple, mode, - latch_mode, cursor, - has_search_latch, mtr)) { + && srv_use_adaptive_hash_indexes + && btr_search_guess_on_hash(index, info, tuple, mode, + latch_mode, cursor, + has_search_latch, mtr)) { /* Search using the hash index succeeded */ ut_ad(cursor->up_match != ULINT_UNDEFINED - || mode != PAGE_CUR_GE); + || mode != PAGE_CUR_GE); ut_ad(cursor->up_match != ULINT_UNDEFINED - || mode != PAGE_CUR_LE); + || mode != PAGE_CUR_LE); ut_ad(cursor->low_match != ULINT_UNDEFINED - || mode != PAGE_CUR_LE); + || mode != PAGE_CUR_LE); btr_cur_n_sea++; return; @@ -377,7 +382,7 @@ btr_cur_search_to_nth_level( } else if (latch_mode == BTR_CONT_MODIFY_TREE) { /* Do nothing */ ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); } else { mtr_s_lock(dict_tree_get_lock(tree), mtr); } @@ -410,7 +415,7 @@ btr_cur_search_to_nth_level( default: #ifdef PAGE_CUR_LE_OR_EXTENDS ut_ad(mode == PAGE_CUR_L || mode == PAGE_CUR_LE - || mode == PAGE_CUR_LE_OR_EXTENDS); + || mode == PAGE_CUR_LE_OR_EXTENDS); #else /* PAGE_CUR_LE_OR_EXTENDS */ ut_ad(mode == PAGE_CUR_L || mode == PAGE_CUR_LE); #endif /* PAGE_CUR_LE_OR_EXTENDS */ @@ -425,8 +430,8 @@ btr_cur_search_to_nth_level( rw_latch = latch_mode; - if (insert_planned && ibuf_should_try(index, - ignore_sec_unique)) { + if (insert_planned + && ibuf_should_try(index, ignore_sec_unique)) { /* Try insert to the insert buffer if the page is not in the buffer pool */ @@ -447,9 +452,9 @@ retry_page_get: ut_ad(insert_planned); ut_ad(cursor->thr); - if (ibuf_should_try(index, ignore_sec_unique) && - ibuf_insert(tuple, index, space, page_no, - cursor->thr)) { + if (ibuf_should_try(index, ignore_sec_unique) + && ibuf_insert(tuple, index, space, page_no, + cursor->thr)) { /* Insertion to the insert buffer succeeded */ cursor->flag = BTR_CUR_INSERT_TO_IBUF; if (UNIV_LIKELY_NULL(heap)) { @@ -474,7 +479,7 @@ retry_page_get: } #endif ut_ad(0 == ut_dulint_cmp(tree->id, - btr_page_get_index_id(page))); + btr_page_get_index_id(page))); if (height == ULINT_UNDEFINED) { /* We are in the root node */ @@ -493,43 +498,44 @@ retry_page_get: if (rw_latch == RW_NO_LATCH) { btr_cur_latch_leaves(page, space, - page_no, latch_mode, cursor, - mtr); + page_no, latch_mode, + cursor, mtr); } if ((latch_mode != BTR_MODIFY_TREE) - && (latch_mode != BTR_CONT_MODIFY_TREE)) { + && (latch_mode != BTR_CONT_MODIFY_TREE)) { /* Release the tree s-latch */ - mtr_release_s_latch_at_savepoint( - mtr, savepoint, - dict_tree_get_lock(tree)); + mtr_release_s_latch_at_savepoint + (mtr, savepoint, + dict_tree_get_lock(tree)); } page_mode = mode; } page_cur_search_with_match(page, index, tuple, page_mode, - &up_match, &up_bytes, - &low_match, &low_bytes, page_cursor); + &up_match, &up_bytes, + &low_match, &low_bytes, + page_cursor); if (estimate) { btr_cur_add_path_info(cursor, height, root_height); } /* If this is the desired level, leave the loop */ - ut_ad(height - == btr_page_get_level(page_cur_get_page(page_cursor), mtr)); + ut_ad(height == btr_page_get_level + (page_cur_get_page(page_cursor), mtr)); if (level == height) { if (level > 0) { /* x-latch the page */ page = btr_page_get(space, - page_no, RW_X_LATCH, mtr); + page_no, RW_X_LATCH, mtr); ut_a((ibool)!!page_is_comp(page) - == dict_table_is_comp(index->table)); + == dict_table_is_comp(index->table)); } break; @@ -542,7 +548,7 @@ retry_page_get: node_ptr = page_cur_get_rec(page_cursor); offsets = rec_get_offsets(node_ptr, cursor->index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); /* Go to the child node */ page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); } @@ -564,11 +570,11 @@ retry_page_get: } #endif ut_ad(cursor->up_match != ULINT_UNDEFINED - || mode != PAGE_CUR_GE); + || mode != PAGE_CUR_GE); ut_ad(cursor->up_match != ULINT_UNDEFINED - || mode != PAGE_CUR_LE); + || mode != PAGE_CUR_LE); ut_ad(cursor->low_match != ULINT_UNDEFINED - || mode != PAGE_CUR_LE); + || mode != PAGE_CUR_LE); } func_exit: @@ -636,7 +642,7 @@ btr_cur_open_at_index_side( __FILE__, __LINE__, mtr); ut_ad(0 == ut_dulint_cmp(tree->id, - btr_page_get_index_id(page))); + btr_page_get_index_id(page))); buf_block_align(page)->check_index_page_at_flush = TRUE; @@ -649,7 +655,7 @@ btr_cur_open_at_index_side( if (height == 0) { btr_cur_latch_leaves(page, space, page_no, - latch_mode, cursor, mtr); + latch_mode, cursor, mtr); /* In versions <= 3.23.52 we had forgotten to release the tree latch here. If in an index scan @@ -658,13 +664,13 @@ btr_cur_open_at_index_side( waiting for the tree latch. */ if ((latch_mode != BTR_MODIFY_TREE) - && (latch_mode != BTR_CONT_MODIFY_TREE)) { + && (latch_mode != BTR_CONT_MODIFY_TREE)) { /* Release the tree s-latch */ - mtr_release_s_latch_at_savepoint( - mtr, savepoint, - dict_tree_get_lock(tree)); + mtr_release_s_latch_at_savepoint + (mtr, savepoint, + dict_tree_get_lock(tree)); } } @@ -677,7 +683,7 @@ btr_cur_open_at_index_side( if (height == 0) { if (estimate) { btr_cur_add_path_info(cursor, height, - root_height); + root_height); } break; @@ -699,7 +705,7 @@ btr_cur_open_at_index_side( node_ptr = page_cur_get_rec(page_cursor); offsets = rec_get_offsets(node_ptr, cursor->index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); /* Go to the child node */ page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); } @@ -754,7 +760,7 @@ btr_cur_open_at_rnd_pos( __FILE__, __LINE__, mtr); ut_ad(0 == ut_dulint_cmp(tree->id, - btr_page_get_index_id(page))); + btr_page_get_index_id(page))); if (height == ULINT_UNDEFINED) { /* We are in the root node */ @@ -764,7 +770,7 @@ btr_cur_open_at_rnd_pos( if (height == 0) { btr_cur_latch_leaves(page, space, page_no, - latch_mode, cursor, mtr); + latch_mode, cursor, mtr); } page_cur_open_on_rnd_user_rec(page, page_cursor); @@ -780,7 +786,7 @@ btr_cur_open_at_rnd_pos( node_ptr = page_cur_get_rec(page_cursor); offsets = rec_get_offsets(node_ptr, cursor->index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); /* Go to the child node */ page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); } @@ -821,7 +827,7 @@ btr_cur_insert_if_possible( page = btr_cur_get_page(cursor); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); page_cursor = btr_cur_get_page_cur(cursor); /* Now, try the insert */ @@ -835,10 +841,10 @@ btr_cur_insert_if_possible( *reorg = TRUE; page_cur_search(page, cursor->index, tuple, - PAGE_CUR_LE, page_cursor); + PAGE_CUR_LE, page_cursor); rec = page_cur_tuple_insert(page_cursor, tuple, - cursor->index, mtr); + cursor->index, mtr); } return(rec); @@ -883,8 +889,9 @@ btr_cur_ins_lock_and_undo( if ((index->type & DICT_CLUSTERED) && !(index->type & DICT_IBUF)) { err = trx_undo_report_row_operation(flags, TRX_UNDO_INSERT_OP, - thr, index, entry, NULL, 0, NULL, - &roll_ptr); + thr, index, entry, + NULL, 0, NULL, + &roll_ptr); if (err != DB_SUCCESS) { return(err); @@ -895,7 +902,7 @@ btr_cur_ins_lock_and_undo( if (!(flags & BTR_KEEP_SYS_FLAG)) { row_upd_index_entry_sys_field(entry, index, - DATA_ROLL_PTR, roll_ptr); + DATA_ROLL_PTR, roll_ptr); } } @@ -978,7 +985,7 @@ btr_cur_optimistic_insert( #endif /* UNIV_DEBUG */ ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); max_size = page_get_max_insert_size_after_reorganize(page, 1); level = btr_page_get_level(page, mtr); @@ -986,9 +993,9 @@ calculate_sizes_again: /* Calculate the record size when entry is converted to a record */ rec_size = rec_get_converted_size(index, entry); - if (rec_size >= - ut_min(page_get_free_space_of_empty(page_is_comp(page)) / 2, - REC_MAX_DATA_SIZE)) { + if (rec_size + >= ut_min(page_get_free_space_of_empty(page_is_comp(page)) / 2, + REC_MAX_DATA_SIZE)) { /* The record is so big that we have to store some fields externally on separate database pages */ @@ -1010,11 +1017,11 @@ calculate_sizes_again: type = index->type; if ((type & DICT_CLUSTERED) - && (dict_tree_get_space_reserve(index->tree) + rec_size > max_size) - && (page_get_n_recs(page) >= 2) - && (0 == level) - && (btr_page_get_split_rec_to_right(cursor, &dummy_rec) - || btr_page_get_split_rec_to_left(cursor, &dummy_rec))) { + && (dict_tree_get_space_reserve(index->tree) + rec_size > max_size) + && (page_get_n_recs(page) >= 2) + && (0 == level) + && (btr_page_get_split_rec_to_right(cursor, &dummy_rec) + || btr_page_get_split_rec_to_left(cursor, &dummy_rec))) { if (big_rec_vec) { dtuple_convert_back_big_rec(index, entry, big_rec_vec); @@ -1024,9 +1031,9 @@ calculate_sizes_again: } if (!(((max_size >= rec_size) - && (max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)) - || (page_get_max_insert_size(page, 1) >= rec_size) - || (page_get_n_recs(page) <= 1))) { + && (max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)) + || (page_get_max_insert_size(page, 1) >= rec_size) + || (page_get_n_recs(page) <= 1))) { if (big_rec_vec) { dtuple_convert_back_big_rec(index, entry, big_rec_vec); @@ -1052,7 +1059,7 @@ calculate_sizes_again: /* Now, try the insert */ *rec = page_cur_insert_rec_low(page_cursor, entry, index, - NULL, NULL, mtr); + NULL, NULL, mtr); if (UNIV_UNLIKELY(!(*rec))) { /* If the record did not fit, reorganize */ btr_page_reorganize(page, index, mtr); @@ -1089,15 +1096,16 @@ calculate_sizes_again: lock_update_insert(*rec); } -/* fprintf(stderr, "Insert into page %lu, max ins size %lu," +#if 0 + fprintf(stderr, "Insert into page %lu, max ins size %lu," " rec %lu ind type %lu\n", - buf_frame_get_page_no(page), max_size, - rec_size + PAGE_DIR_SLOT_SIZE, type); -*/ + buf_frame_get_page_no(page), max_size, + rec_size + PAGE_DIR_SLOT_SIZE, type); +#endif if (!(type & DICT_CLUSTERED)) { /* We have added a record to page: update its free bits */ ibuf_update_free_bits_if_full(cursor->index, page, max_size, - rec_size + PAGE_DIR_SLOT_SIZE); + rec_size + PAGE_DIR_SLOT_SIZE); } *big_rec = big_rec_vec; @@ -1149,9 +1157,9 @@ btr_cur_pessimistic_insert( ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(btr_cur_get_tree(cursor)), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); /* Try first an optimistic insert; reset the cursor flag: we do not assume anything of how it was positioned */ @@ -1159,7 +1167,7 @@ btr_cur_pessimistic_insert( cursor->flag = BTR_CUR_BINARY; err = btr_cur_optimistic_insert(flags, cursor, entry, rec, big_rec, - thr, mtr); + thr, mtr); if (err != DB_FAIL) { return(err); @@ -1183,7 +1191,7 @@ btr_cur_pessimistic_insert( n_extents = cursor->tree_height / 16 + 3; success = fsp_reserve_free_extents(&n_reserved, index->space, - n_extents, FSP_NORMAL, mtr); + n_extents, FSP_NORMAL, mtr); if (!success) { err = DB_OUT_OF_FILE_SPACE; @@ -1191,9 +1199,9 @@ btr_cur_pessimistic_insert( } } - if (rec_get_converted_size(index, entry) >= - ut_min(page_get_free_space_of_empty(page_is_comp(page)) / 2, - REC_MAX_DATA_SIZE)) { + if (rec_get_converted_size(index, entry) + >= ut_min(page_get_free_space_of_empty(page_is_comp(page)) / 2, + REC_MAX_DATA_SIZE)) { /* The record is so big that we have to store some fields externally on separate database pages */ @@ -1204,14 +1212,14 @@ btr_cur_pessimistic_insert( if (n_extents > 0) { fil_space_release_free_extents(index->space, - n_reserved); + n_reserved); } return(DB_TOO_BIG_RECORD); } } if (dict_tree_get_page(index->tree) - == buf_frame_get_page_no(page)) { + == buf_frame_get_page_no(page)) { /* The page is the root page */ *rec = btr_root_raise_and_insert(cursor, entry, mtr); @@ -1271,7 +1279,7 @@ btr_cur_upd_lock_and_undo( /* We do undo logging only when we update a clustered index record */ return(lock_sec_rec_modify_check_and_lock(flags, rec, index, - thr)); + thr)); } /* Check if we have to wait for a lock: enqueue an explicit lock @@ -1284,9 +1292,10 @@ btr_cur_upd_lock_and_undo( ulint offsets_[REC_OFFS_NORMAL_SIZE]; *offsets_ = (sizeof offsets_) / sizeof *offsets_; - err = lock_clust_rec_modify_check_and_lock(flags, rec, index, - rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &heap), thr); + err = lock_clust_rec_modify_check_and_lock + (flags, rec, index, + rec_get_offsets(rec, index, offsets_, + ULINT_UNDEFINED, &heap), thr); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1299,8 +1308,8 @@ btr_cur_upd_lock_and_undo( /* Append the info about the update in the undo log */ err = trx_undo_report_row_operation(flags, TRX_UNDO_MODIFY_OP, thr, - index, NULL, update, - cmpl_info, rec, roll_ptr); + index, NULL, update, + cmpl_info, rec, roll_ptr); return(err); } @@ -1324,9 +1333,10 @@ btr_cur_update_in_place_log( ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table)); log_ptr = mlog_open_and_write_index(mtr, rec, index, page_is_comp(page) - ? MLOG_COMP_REC_UPDATE_IN_PLACE - : MLOG_REC_UPDATE_IN_PLACE, - 1 + DATA_ROLL_PTR_LEN + 14 + 2 + MLOG_BUF_MARGIN); + ? MLOG_COMP_REC_UPDATE_IN_PLACE + : MLOG_REC_UPDATE_IN_PLACE, + 1 + DATA_ROLL_PTR_LEN + 14 + 2 + + MLOG_BUF_MARGIN); if (!log_ptr) { /* Logging in mtr is switched off during crash recovery */ @@ -1344,7 +1354,7 @@ btr_cur_update_in_place_log( log_ptr++; log_ptr = row_upd_write_sys_vals_to_log(index, trx, roll_ptr, log_ptr, - mtr); + mtr); mach_write_to_2(log_ptr, ut_align_offset(rec, UNIV_PAGE_SIZE)); log_ptr += 2; @@ -1417,7 +1427,7 @@ btr_cur_parse_update_in_place( if (!(flags & BTR_KEEP_SYS_FLAG)) { row_upd_rec_sys_fields_in_recovery(rec, offsets, - pos, trx_id, roll_ptr); + pos, trx_id, roll_ptr); } row_upd_rec_in_place(rec, offsets, update); @@ -1472,7 +1482,7 @@ btr_cur_update_in_place( /* Do lock checking and undo logging */ err = btr_cur_upd_lock_and_undo(flags, cursor, update, cmpl_info, - thr, &roll_ptr); + thr, &roll_ptr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { if (UNIV_LIKELY_NULL(heap)) { @@ -1483,7 +1493,7 @@ btr_cur_update_in_place( block = buf_block_align(rec); ut_ad(!!page_is_comp(buf_block_get_frame(block)) - == dict_table_is_comp(index->table)); + == dict_table_is_comp(index->table)); if (block->is_hashed) { /* The function row_upd_changes_ord_field_binary works only @@ -1491,7 +1501,7 @@ btr_cur_update_in_place( NOT call it if index is secondary */ if (!(index->type & DICT_CLUSTERED) - || row_upd_changes_ord_field_binary(NULL, index, update)) { + || row_upd_changes_ord_field_binary(NULL, index, update)) { /* Remove possible hash index pointer to this record */ btr_search_update_hash_on_delete(cursor); @@ -1507,8 +1517,8 @@ btr_cur_update_in_place( /* FIXME: in a mixed tree, all records may not have enough ordering fields for btr search: */ - was_delete_marked = rec_get_deleted_flag(rec, - page_is_comp(buf_block_get_frame(block))); + was_delete_marked = rec_get_deleted_flag + (rec, page_is_comp(buf_block_get_frame(block))); row_upd_rec_in_place(rec, offsets, update); @@ -1517,9 +1527,10 @@ btr_cur_update_in_place( } btr_cur_update_in_place_log(flags, rec, index, update, trx, roll_ptr, - mtr); - if (was_delete_marked && !rec_get_deleted_flag(rec, - page_is_comp(buf_block_get_frame(block)))) { + mtr); + if (was_delete_marked + && !rec_get_deleted_flag(rec, page_is_comp + (buf_block_get_frame(block)))) { /* The new updated record owns its possible externally stored fields */ @@ -1588,7 +1599,7 @@ btr_cur_optimistic_update( #endif /* UNIV_DEBUG */ ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); if (!row_upd_changes_field_size_or_external(index, offsets, update)) { /* The simplest and the most common case: the update does not @@ -1596,7 +1607,7 @@ btr_cur_optimistic_update( externally stored in rec or update */ mem_heap_free(heap); return(btr_cur_update_in_place(flags, cursor, update, - cmpl_info, thr, mtr)); + cmpl_info, thr, mtr)); } for (i = 0; i < upd_get_n_fields(update); i++) { @@ -1623,12 +1634,13 @@ btr_cur_optimistic_update( new_entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, heap); row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update, - FALSE, NULL); + FALSE, NULL); old_rec_size = rec_offs_size(offsets); new_rec_size = rec_get_converted_size(index, new_entry); - if (UNIV_UNLIKELY(new_rec_size >= page_get_free_space_of_empty( - page_is_comp(page)) / 2)) { + if (UNIV_UNLIKELY(new_rec_size + >= (page_get_free_space_of_empty(page_is_comp(page)) + / 2))) { mem_heap_free(heap); @@ -1636,11 +1648,11 @@ btr_cur_optimistic_update( } max_size = old_rec_size - + page_get_max_insert_size_after_reorganize(page, 1); + + page_get_max_insert_size_after_reorganize(page, 1); if (UNIV_UNLIKELY(page_get_data_size(page) - - old_rec_size + new_rec_size - < BTR_CUR_PAGE_COMPRESS_LIMIT)) { + - old_rec_size + new_rec_size + < BTR_CUR_PAGE_COMPRESS_LIMIT)) { /* The page would become too empty */ @@ -1650,8 +1662,8 @@ btr_cur_optimistic_update( } if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT) - && (max_size >= new_rec_size)) - || (page_get_n_recs(page) <= 1))) { + && (max_size >= new_rec_size)) + || (page_get_n_recs(page) <= 1))) { /* There was not enough space, or it did not pay to reorganize: for simplicity, we decide what to do assuming a @@ -1664,7 +1676,7 @@ btr_cur_optimistic_update( /* Do lock checking and undo logging */ err = btr_cur_upd_lock_and_undo(flags, cursor, update, cmpl_info, thr, - &roll_ptr); + &roll_ptr); if (err != DB_SUCCESS) { mem_heap_free(heap); @@ -1688,9 +1700,9 @@ btr_cur_optimistic_update( if (!(flags & BTR_KEEP_SYS_FLAG)) { row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR, - roll_ptr); + roll_ptr); row_upd_index_entry_sys_field(new_entry, index, DATA_TRX_ID, - trx->id); + trx->id); } rec = btr_cur_insert_if_possible(cursor, new_entry, &reorganized, mtr); @@ -1702,7 +1714,7 @@ btr_cur_optimistic_update( stored fields */ offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); btr_cur_unmark_extern_fields(rec, mtr, offsets); } @@ -1750,15 +1762,15 @@ btr_cur_pess_upd_restore_supremum( prev_page = buf_page_get_with_no_latch(space, prev_page_no, mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(prev_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ /* We must already have an x-latch to prev_page! */ ut_ad(mtr_memo_contains(mtr, buf_block_align(prev_page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); lock_rec_reset_and_inherit_gap_locks(page_get_supremum_rec(prev_page), - rec); + rec); } /***************************************************************** @@ -1816,12 +1828,12 @@ btr_cur_pessimistic_update( tree = index->tree; ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); optim_err = btr_cur_optimistic_update(flags, cursor, update, - cmpl_info, thr, mtr); + cmpl_info, thr, mtr); if (optim_err != DB_UNDERFLOW && optim_err != DB_OVERFLOW) { @@ -1830,7 +1842,7 @@ btr_cur_pessimistic_update( /* Do lock checking and undo logging */ err = btr_cur_upd_lock_and_undo(flags, cursor, update, cmpl_info, - thr, &roll_ptr); + thr, &roll_ptr); if (err != DB_SUCCESS) { return(err); @@ -1849,9 +1861,9 @@ btr_cur_pessimistic_update( reserve_flag = FSP_NORMAL; } - success = fsp_reserve_free_extents(&n_reserved, - index->space, - n_extents, reserve_flag, mtr); + success = fsp_reserve_free_extents(&n_reserved, index->space, + n_extents, + reserve_flag, mtr); if (!success) { err = DB_OUT_OF_FILE_SPACE; @@ -1867,12 +1879,12 @@ btr_cur_pessimistic_update( new_entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, heap); row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update, - FALSE, heap); + FALSE, heap); if (!(flags & BTR_KEEP_SYS_FLAG)) { row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR, - roll_ptr); + roll_ptr); row_upd_index_entry_sys_field(new_entry, index, DATA_TRX_ID, - trx->id); + trx->id); } if (flags & BTR_NO_UNDO_LOG_FLAG) { @@ -1886,25 +1898,26 @@ btr_cur_pessimistic_update( ut_a(big_rec_vec == NULL); btr_rec_free_updated_extern_fields(index, rec, offsets, - update, TRUE, mtr); + update, TRUE, mtr); } /* We have to set appropriate extern storage bits in the new record to be inserted: we have to remember which fields were such */ ext_vect = mem_heap_alloc(heap, sizeof(ulint) - * dict_index_get_n_fields(index)); + * dict_index_get_n_fields(index)); ut_ad(!page_is_comp(page) || !rec_get_node_ptr_flag(rec)); offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); n_ext_vect = btr_push_update_extern_fields(ext_vect, offsets, update); - if (UNIV_UNLIKELY(rec_get_converted_size(index, new_entry) >= - ut_min(page_get_free_space_of_empty(page_is_comp(page)) / 2, - REC_MAX_DATA_SIZE))) { + if (UNIV_UNLIKELY(rec_get_converted_size(index, new_entry) + >= ut_min(page_get_free_space_of_empty + (page_is_comp(page)) / 2, + REC_MAX_DATA_SIZE))) { big_rec_vec = dtuple_convert_big_rec(index, new_entry, - ext_vect, n_ext_vect); + ext_vect, n_ext_vect); if (big_rec_vec == NULL) { err = DB_TOO_BIG_RECORD; @@ -1932,16 +1945,16 @@ btr_cur_pessimistic_update( page_cur_move_to_prev(page_cursor); rec = btr_cur_insert_if_possible(cursor, new_entry, - &dummy_reorganized, mtr); + &dummy_reorganized, mtr); ut_a(rec || optim_err != DB_UNDERFLOW); if (rec) { lock_rec_restore_from_page_infimum(rec, page); rec_set_field_extern_bits(rec, index, - ext_vect, n_ext_vect, mtr); + ext_vect, n_ext_vect, mtr); offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (!rec_get_deleted_flag(rec, rec_offs_comp(offsets))) { /* The new inserted record owns its possible externally @@ -1968,10 +1981,10 @@ btr_cur_pessimistic_update( is made in the insert */ err = btr_cur_pessimistic_insert(BTR_NO_UNDO_LOG_FLAG - | BTR_NO_LOCKING_FLAG - | BTR_KEEP_SYS_FLAG, - cursor, new_entry, &rec, - &dummy_big_rec, NULL, mtr); + | BTR_NO_LOCKING_FLAG + | BTR_KEEP_SYS_FLAG, + cursor, new_entry, &rec, + &dummy_big_rec, NULL, mtr); ut_a(rec); ut_a(err == DB_SUCCESS); ut_a(dummy_big_rec == NULL); @@ -2033,10 +2046,11 @@ btr_cur_del_mark_set_clust_rec_log( ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); log_ptr = mlog_open_and_write_index(mtr, rec, index, - page_rec_is_comp(rec) - ? MLOG_COMP_REC_CLUST_DELETE_MARK - : MLOG_REC_CLUST_DELETE_MARK, - 1 + 1 + DATA_ROLL_PTR_LEN + 14 + 2); + page_rec_is_comp(rec) + ? MLOG_COMP_REC_CLUST_DELETE_MARK + : MLOG_REC_CLUST_DELETE_MARK, + 1 + 1 + DATA_ROLL_PTR_LEN + + 14 + 2); if (!log_ptr) { /* Logging in mtr is switched off during crash recovery */ @@ -2049,7 +2063,7 @@ btr_cur_del_mark_set_clust_rec_log( log_ptr++; log_ptr = row_upd_write_sys_vals_to_log(index, trx, roll_ptr, log_ptr, - mtr); + mtr); mach_write_to_2(log_ptr, ut_align_offset(rec, UNIV_PAGE_SIZE)); log_ptr += 2; @@ -2078,7 +2092,7 @@ btr_cur_parse_del_mark_set_clust_rec( rec_t* rec; ut_ad(!page - || !!page_is_comp(page) == dict_table_is_comp(index->table)); + || !!page_is_comp(page) == dict_table_is_comp(index->table)); if (end_ptr < ptr + 2) { @@ -2115,10 +2129,10 @@ btr_cur_parse_del_mark_set_clust_rec( ulint offsets_[REC_OFFS_NORMAL_SIZE]; *offsets_ = (sizeof offsets_) / sizeof *offsets_; - row_upd_rec_sys_fields_in_recovery(rec, - rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &heap), - pos, trx_id, roll_ptr); + row_upd_rec_sys_fields_in_recovery + (rec, rec_get_offsets(rec, index, offsets_, + ULINT_UNDEFINED, &heap), + pos, trx_id, roll_ptr); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -2178,7 +2192,7 @@ btr_cur_del_mark_set_clust_rec( ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets))); err = lock_clust_rec_modify_check_and_lock(flags, - rec, index, offsets, thr); + rec, index, offsets, thr); if (err != DB_SUCCESS) { @@ -2189,8 +2203,8 @@ btr_cur_del_mark_set_clust_rec( } err = trx_undo_report_row_operation(flags, TRX_UNDO_MODIFY_OP, thr, - index, NULL, NULL, 0, rec, - &roll_ptr); + index, NULL, NULL, 0, rec, + &roll_ptr); if (err != DB_SUCCESS) { if (UNIV_LIKELY_NULL(heap)) { @@ -2218,7 +2232,7 @@ btr_cur_del_mark_set_clust_rec( } btr_cur_del_mark_set_clust_rec_log(flags, rec, index, val, trx, - roll_ptr, mtr); + roll_ptr, mtr); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -2247,8 +2261,8 @@ btr_cur_del_mark_set_sec_rec_log( return; } - log_ptr = mlog_write_initial_log_record_fast( - rec, MLOG_REC_SEC_DELETE_MARK, log_ptr, mtr); + log_ptr = mlog_write_initial_log_record_fast + (rec, MLOG_REC_SEC_DELETE_MARK, log_ptr, mtr); mach_write_to_1(log_ptr, val); log_ptr++; @@ -2323,13 +2337,13 @@ btr_cur_del_mark_set_sec_rec( #ifdef UNIV_DEBUG if (btr_cur_print_record_ops && thr) { btr_cur_trx_report(thr_get_trx(thr), cursor->index, - "del mark "); + "del mark "); rec_print(stderr, rec, cursor->index); } #endif /* UNIV_DEBUG */ err = lock_sec_rec_modify_check_and_lock(flags, rec, cursor->index, - thr); + thr); if (err != DB_SUCCESS) { return(err); @@ -2337,14 +2351,14 @@ btr_cur_del_mark_set_sec_rec( block = buf_block_align(rec); ut_ad(!!page_is_comp(buf_block_get_frame(block)) - == dict_table_is_comp(cursor->index->table)); + == dict_table_is_comp(cursor->index->table)); if (block->is_hashed) { rw_lock_x_lock(&btr_search_latch); } rec_set_deleted_flag(rec, page_is_comp(buf_block_get_frame(block)), - val); + val); if (block->is_hashed) { rw_lock_x_unlock(&btr_search_latch); @@ -2391,7 +2405,7 @@ btr_cur_compress( { ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(btr_cur_get_tree(cursor)), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)), MTR_MEMO_PAGE_X_FIX)); ut_ad(btr_page_get_level(btr_cur_get_page(cursor), mtr) == 0); @@ -2417,7 +2431,7 @@ btr_cur_compress_if_useful( { ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(btr_cur_get_tree(cursor)), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)), MTR_MEMO_PAGE_X_FIX)); @@ -2457,7 +2471,7 @@ btr_cur_optimistic_delete( *offsets_ = (sizeof offsets_) / sizeof *offsets_; ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); /* This is intended only for leaf page deletions */ page = btr_cur_get_page(cursor); @@ -2466,11 +2480,11 @@ btr_cur_optimistic_delete( rec = btr_cur_get_rec(cursor); offsets = rec_get_offsets(rec, cursor->index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); no_compress_needed = !rec_offs_any_extern(offsets) - && btr_cur_can_delete_without_compress( - cursor, rec_offs_size(offsets), mtr); + && btr_cur_can_delete_without_compress + (cursor, rec_offs_size(offsets), mtr); if (no_compress_needed) { @@ -2478,13 +2492,13 @@ btr_cur_optimistic_delete( btr_search_update_hash_on_delete(cursor); - max_ins_size = page_get_max_insert_size_after_reorganize(page, - 1); + max_ins_size = page_get_max_insert_size_after_reorganize + (page, 1); page_cur_delete_rec(btr_cur_get_page_cur(cursor), - cursor->index, offsets, mtr); + cursor->index, offsets, mtr); ibuf_update_free_bits_low(cursor->index, page, max_ins_size, - mtr); + mtr); } if (UNIV_LIKELY_NULL(heap)) { @@ -2538,9 +2552,9 @@ btr_cur_pessimistic_delete( tree = btr_cur_get_tree(cursor); ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); if (!has_reserved_extents) { /* First reserve enough free space for the file segments of the index tree, so that the node pointer updates will @@ -2549,8 +2563,9 @@ btr_cur_pessimistic_delete( n_extents = cursor->tree_height / 32 + 1; success = fsp_reserve_free_extents(&n_reserved, - cursor->index->space, - n_extents, FSP_CLEANING, mtr); + cursor->index->space, + n_extents, + FSP_CLEANING, mtr); if (!success) { *err = DB_OUT_OF_FILE_SPACE; @@ -2562,21 +2577,22 @@ btr_cur_pessimistic_delete( rec = btr_cur_get_rec(cursor); offsets = rec_get_offsets(rec, cursor->index, - NULL, ULINT_UNDEFINED, &heap); + NULL, ULINT_UNDEFINED, &heap); /* Free externally stored fields if the record is neither a node pointer nor in two-byte format. This avoids an unnecessary loop. */ if (page_is_comp(page) - ? !rec_get_node_ptr_flag(rec) - : !rec_get_1byte_offs_flag(rec)) { + ? !rec_get_node_ptr_flag(rec) + : !rec_get_1byte_offs_flag(rec)) { btr_rec_free_externally_stored_fields(cursor->index, - rec, offsets, in_rollback, mtr); + rec, offsets, + in_rollback, mtr); } if (UNIV_UNLIKELY(page_get_n_recs(page) < 2) - && UNIV_UNLIKELY(dict_tree_get_page(btr_cur_get_tree(cursor)) - != buf_frame_get_page_no(page))) { + && UNIV_UNLIKELY(dict_tree_get_page(btr_cur_get_tree(cursor)) + != buf_frame_get_page_no(page))) { /* If there is only one record, drop the whole page in btr_discard_page, if this is not the root page */ @@ -2593,8 +2609,8 @@ btr_cur_pessimistic_delete( level = btr_page_get_level(page, mtr); if (level > 0 - && UNIV_UNLIKELY(rec == page_rec_get_next( - page_get_infimum_rec(page)))) { + && UNIV_UNLIKELY(rec == page_rec_get_next + (page_get_infimum_rec(page)))) { rec_t* next_rec = page_rec_get_next(rec); @@ -2605,7 +2621,7 @@ btr_cur_pessimistic_delete( pointer as the predefined minimum record */ btr_set_min_rec_mark(next_rec, page_is_comp(page), - mtr); + mtr); } else { /* Otherwise, if we delete the leftmost node pointer on a page, we have to change the father node pointer @@ -2614,20 +2630,19 @@ btr_cur_pessimistic_delete( btr_node_ptr_delete(tree, page, mtr); - node_ptr = dict_tree_build_node_ptr( - tree, next_rec, - buf_frame_get_page_no(page), - heap, level); + node_ptr = dict_tree_build_node_ptr + (tree, next_rec, buf_frame_get_page_no(page), + heap, level); btr_insert_on_non_leaf_level(tree, - level + 1, node_ptr, mtr); + level + 1, node_ptr, mtr); } } btr_search_update_hash_on_delete(cursor); page_cur_delete_rec(btr_cur_get_page_cur(cursor), cursor->index, - offsets, mtr); + offsets, mtr); ut_ad(btr_check_node_ptr(tree, page, mtr)); @@ -2642,7 +2657,7 @@ return_after_reservations: if (n_extents > 0) { fil_space_release_free_extents(cursor->index->space, - n_reserved); + n_reserved); } return(ret); @@ -2720,12 +2735,12 @@ btr_estimate_n_rows_in_range( if (dtuple_get_n_fields(tuple1) > 0) { btr_cur_search_to_nth_level(index, 0, tuple1, mode1, - BTR_SEARCH_LEAF | BTR_ESTIMATE, - &cursor, 0, &mtr); + BTR_SEARCH_LEAF | BTR_ESTIMATE, + &cursor, 0, &mtr); } else { btr_cur_open_at_index_side(TRUE, index, - BTR_SEARCH_LEAF | BTR_ESTIMATE, - &cursor, &mtr); + BTR_SEARCH_LEAF | BTR_ESTIMATE, + &cursor, &mtr); } mtr_commit(&mtr); @@ -2737,12 +2752,12 @@ btr_estimate_n_rows_in_range( if (dtuple_get_n_fields(tuple2) > 0) { btr_cur_search_to_nth_level(index, 0, tuple2, mode2, - BTR_SEARCH_LEAF | BTR_ESTIMATE, - &cursor, 0, &mtr); + BTR_SEARCH_LEAF | BTR_ESTIMATE, + &cursor, 0, &mtr); } else { btr_cur_open_at_index_side(FALSE, index, - BTR_SEARCH_LEAF | BTR_ESTIMATE, - &cursor, &mtr); + BTR_SEARCH_LEAF | BTR_ESTIMATE, + &cursor, &mtr); } mtr_commit(&mtr); @@ -2751,11 +2766,11 @@ btr_estimate_n_rows_in_range( n_rows = 1; diverged = FALSE; /* This becomes true when the path is not - the same any more */ + the same any more */ diverged_lot = FALSE; /* This becomes true when the paths are - not the same or adjacent any more */ + not the same or adjacent any more */ divergence_level = 1000000; /* This is the level where paths diverged - a lot */ + a lot */ for (i = 0; ; i++) { ut_ad(i < BTR_PATH_ARRAY_N_SLOTS); @@ -2763,7 +2778,7 @@ btr_estimate_n_rows_in_range( slot2 = path2 + i; if (slot1->nth_rec == ULINT_UNDEFINED - || slot2->nth_rec == ULINT_UNDEFINED) { + || slot2->nth_rec == ULINT_UNDEFINED) { if (i > divergence_level + 1) { /* In trees whose height is > 1 our algorithm @@ -2799,8 +2814,8 @@ btr_estimate_n_rows_in_range( n_rows = slot2->nth_rec - slot1->nth_rec; if (n_rows > 1) { - diverged_lot = TRUE; - divergence_level = i; + diverged_lot = TRUE; + divergence_level = i; } } else { /* Maybe the tree has changed between @@ -2812,7 +2827,7 @@ btr_estimate_n_rows_in_range( } else if (diverged && !diverged_lot) { if (slot1->nth_rec < slot1->n_recs - || slot2->nth_rec > 1) { + || slot2->nth_rec > 1) { diverged_lot = TRUE; divergence_level = i; @@ -2831,7 +2846,7 @@ btr_estimate_n_rows_in_range( } else if (diverged_lot) { n_rows = (n_rows * (slot1->n_recs + slot2->n_recs)) - / 2; + / 2; } } } @@ -2865,8 +2880,8 @@ btr_estimate_number_of_different_key_vals( ulint* offsets_rec = offsets_rec_; ulint* offsets_next_rec= offsets_next_rec_; *offsets_rec_ = (sizeof offsets_rec_) / sizeof *offsets_rec_; - *offsets_next_rec_ = - (sizeof offsets_next_rec_) / sizeof *offsets_next_rec_; + *offsets_next_rec_ + = (sizeof offsets_next_rec_) / sizeof *offsets_next_rec_; n_cols = dict_index_get_n_unique(index); @@ -2896,7 +2911,7 @@ btr_estimate_number_of_different_key_vals( if (rec != supremum) { not_empty_flag = 1; offsets_rec = rec_get_offsets(rec, index, offsets_rec, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); } while (rec != supremum) { @@ -2908,13 +2923,13 @@ btr_estimate_number_of_different_key_vals( matched_fields = 0; matched_bytes = 0; offsets_next_rec = rec_get_offsets(next_rec, index, - offsets_next_rec, - n_cols, &heap); + offsets_next_rec, + n_cols, &heap); cmp_rec_rec_with_match(rec, next_rec, - offsets_rec, offsets_next_rec, - index, &matched_fields, - &matched_bytes); + offsets_rec, offsets_next_rec, + index, &matched_fields, + &matched_bytes); for (j = matched_fields + 1; j <= n_cols; j++) { /* We add one if this index record has @@ -2923,9 +2938,9 @@ btr_estimate_number_of_different_key_vals( n_diff[j]++; } - total_external_size += - btr_rec_get_externally_stored_len( - rec, offsets_rec); + total_external_size + += btr_rec_get_externally_stored_len + (rec, offsets_rec); rec = next_rec; /* Initialize offsets_rec for the next round @@ -2951,17 +2966,16 @@ btr_estimate_number_of_different_key_vals( in the table. */ if (btr_page_get_prev(page, &mtr) != FIL_NULL - || btr_page_get_next(page, &mtr) != FIL_NULL) { + || btr_page_get_next(page, &mtr) != FIL_NULL) { n_diff[n_cols]++; } } offsets_rec = rec_get_offsets(rec, index, offsets_rec, - ULINT_UNDEFINED, &heap); - total_external_size += - btr_rec_get_externally_stored_len(rec, - offsets_rec); + ULINT_UNDEFINED, &heap); + total_external_size += btr_rec_get_externally_stored_len + (rec, offsets_rec); mtr_commit(&mtr); } @@ -2974,16 +2988,16 @@ btr_estimate_number_of_different_key_vals( included in index->stat_n_leaf_pages) */ for (j = 0; j <= n_cols; j++) { - index->stat_n_diff_key_vals[j] = - (n_diff[j] - * (ib_longlong)index->stat_n_leaf_pages - + BTR_KEY_VAL_ESTIMATE_N_PAGES - 1 - + total_external_size - + not_empty_flag) - / (BTR_KEY_VAL_ESTIMATE_N_PAGES - + total_external_size); + index->stat_n_diff_key_vals[j] + = ((n_diff[j] + * (ib_longlong)index->stat_n_leaf_pages + + BTR_KEY_VAL_ESTIMATE_N_PAGES - 1 + + total_external_size + + not_empty_flag) + / (BTR_KEY_VAL_ESTIMATE_N_PAGES + + total_external_size)); - /* If the tree is small, smaller than < + /* If the tree is small, smaller than 10 * BTR_KEY_VAL_ESTIMATE_N_PAGES + total_external_size, then the above estimate is ok. For bigger trees it is common that we do not see any borders between key values in the few pages @@ -2991,8 +3005,9 @@ btr_estimate_number_of_different_key_vals( different key values, or even more. Let us try to approximate that: */ - add_on = index->stat_n_leaf_pages / - (10 * (BTR_KEY_VAL_ESTIMATE_N_PAGES + total_external_size)); + add_on = index->stat_n_leaf_pages + / (10 * (BTR_KEY_VAL_ESTIMATE_N_PAGES + + total_external_size)); if (add_on > BTR_KEY_VAL_ESTIMATE_N_PAGES) { add_on = BTR_KEY_VAL_ESTIMATE_N_PAGES; @@ -3038,10 +3053,10 @@ btr_rec_get_externally_stored_len( local_len -= BTR_EXTERN_FIELD_REF_SIZE; extern_len = mach_read_from_4(data + local_len - + BTR_EXTERN_LEN + 4); + + BTR_EXTERN_LEN + 4); total_extern_len += ut_calc_align(extern_len, - UNIV_PAGE_SIZE); + UNIV_PAGE_SIZE); } } @@ -3079,7 +3094,7 @@ btr_cur_set_ownership_of_extern_field( } mlog_write_ulint(data + local_len + BTR_EXTERN_LEN, byte_val, - MLOG_1BYTE, mtr); + MLOG_1BYTE, mtr); } /*********************************************************************** @@ -3113,17 +3128,17 @@ btr_cur_mark_extern_inherited_fields( if (update) { for (j = 0; j < upd_get_n_fields(update); - j++) { + j++) { if (upd_get_nth_field(update, j) - ->field_no == i) { + ->field_no == i) { is_updated = TRUE; } } } if (!is_updated) { - btr_cur_set_ownership_of_extern_field(rec, - offsets, i, FALSE, mtr); + btr_cur_set_ownership_of_extern_field + (rec, offsets, i, FALSE, mtr); } } } @@ -3164,7 +3179,7 @@ btr_cur_mark_dtuple_inherited_extern( for (j = 0; j < upd_get_n_fields(update); j++) { if (upd_get_nth_field(update, j)->field_no - == ext_vec[i]) { + == ext_vec[i]) { is_updated = TRUE; } } @@ -3178,7 +3193,7 @@ btr_cur_mark_dtuple_inherited_extern( len -= BTR_EXTERN_FIELD_REF_SIZE; byte_val = mach_read_from_1(data + len - + BTR_EXTERN_LEN); + + BTR_EXTERN_LEN); byte_val = byte_val | BTR_EXTERN_INHERITED_FLAG; @@ -3209,7 +3224,7 @@ btr_cur_unmark_extern_fields( if (rec_offs_nth_extern(offsets, i)) { btr_cur_set_ownership_of_extern_field(rec, offsets, i, - TRUE, mtr); + TRUE, mtr); } } } @@ -3276,8 +3291,8 @@ btr_push_update_extern_fields( if (upd_get_nth_field(update, i)->extern_storage) { - ext_vect[n_pushed] = - upd_get_nth_field(update, i)->field_no; + ext_vect[n_pushed] = upd_get_nth_field + (update, i)->field_no; n_pushed++; } @@ -3294,9 +3309,9 @@ btr_push_update_extern_fields( if (update) { for (j = 0; j < upd_get_n_fields(update); - j++) { + j++) { if (upd_get_nth_field(update, j) - ->field_no == i) { + ->field_no == i) { is_updated = TRUE; } } @@ -3375,9 +3390,9 @@ btr_store_big_rec_extern_fields( ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(mtr_memo_contains(local_mtr, dict_tree_get_lock(index->tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(local_mtr, buf_block_align(rec), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_a(index->type & DICT_CLUSTERED); space_id = buf_frame_get_space_id(rec); @@ -3388,7 +3403,8 @@ btr_store_big_rec_extern_fields( for (i = 0; i < big_rec_vec->n_fields; i++) { data = rec_get_nth_field(rec, offsets, - big_rec_vec->fields[i].field_no, &local_len); + big_rec_vec->fields[i].field_no, + &local_len); ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); local_len -= BTR_EXTERN_FIELD_REF_SIZE; extern_len = big_rec_vec->fields[i].len; @@ -3407,7 +3423,7 @@ btr_store_big_rec_extern_fields( } page = btr_page_alloc(index->tree, hint_page_no, - FSP_NO_DIR, 0, &mtr); + FSP_NO_DIR, 0, &mtr); if (page == NULL) { mtr_commit(&mtr); @@ -3416,85 +3432,87 @@ btr_store_big_rec_extern_fields( } mlog_write_ulint(page + FIL_PAGE_TYPE, - FIL_PAGE_TYPE_BLOB, MLOG_2BYTES, &mtr); + FIL_PAGE_TYPE_BLOB, + MLOG_2BYTES, &mtr); page_no = buf_frame_get_page_no(page); if (prev_page_no != FIL_NULL) { prev_page = buf_page_get(space_id, - prev_page_no, - RW_X_LATCH, &mtr); + prev_page_no, + RW_X_LATCH, &mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(prev_page, - SYNC_EXTERN_STORAGE); + SYNC_EXTERN_STORAGE); #endif /* UNIV_SYNC_DEBUG */ mlog_write_ulint(prev_page + FIL_PAGE_DATA - + BTR_BLOB_HDR_NEXT_PAGE_NO, - page_no, MLOG_4BYTES, &mtr); + + BTR_BLOB_HDR_NEXT_PAGE_NO, + page_no, MLOG_4BYTES, &mtr); } if (extern_len > (UNIV_PAGE_SIZE - FIL_PAGE_DATA - - BTR_BLOB_HDR_SIZE - - FIL_PAGE_DATA_END)) { + - BTR_BLOB_HDR_SIZE + - FIL_PAGE_DATA_END)) { store_len = UNIV_PAGE_SIZE - FIL_PAGE_DATA - - BTR_BLOB_HDR_SIZE - - FIL_PAGE_DATA_END; + - BTR_BLOB_HDR_SIZE + - FIL_PAGE_DATA_END; } else { store_len = extern_len; } mlog_write_string(page + FIL_PAGE_DATA - + BTR_BLOB_HDR_SIZE, - big_rec_vec->fields[i].data - + big_rec_vec->fields[i].len - - extern_len, - store_len, &mtr); + + BTR_BLOB_HDR_SIZE, + big_rec_vec->fields[i].data + + big_rec_vec->fields[i].len + - extern_len, + store_len, &mtr); mlog_write_ulint(page + FIL_PAGE_DATA - + BTR_BLOB_HDR_PART_LEN, - store_len, MLOG_4BYTES, &mtr); + + BTR_BLOB_HDR_PART_LEN, + store_len, MLOG_4BYTES, &mtr); mlog_write_ulint(page + FIL_PAGE_DATA - + BTR_BLOB_HDR_NEXT_PAGE_NO, - FIL_NULL, MLOG_4BYTES, &mtr); + + BTR_BLOB_HDR_NEXT_PAGE_NO, + FIL_NULL, MLOG_4BYTES, &mtr); extern_len -= store_len; rec_page = buf_page_get(space_id, buf_frame_get_page_no(data), - RW_X_LATCH, &mtr); + RW_X_LATCH, &mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(rec_page, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ mlog_write_ulint(data + local_len + BTR_EXTERN_LEN, 0, - MLOG_4BYTES, &mtr); + MLOG_4BYTES, &mtr); mlog_write_ulint(data + local_len + BTR_EXTERN_LEN + 4, - big_rec_vec->fields[i].len - - extern_len, - MLOG_4BYTES, &mtr); + big_rec_vec->fields[i].len + - extern_len, + MLOG_4BYTES, &mtr); if (prev_page_no == FIL_NULL) { mlog_write_ulint(data + local_len - + BTR_EXTERN_SPACE_ID, - space_id, - MLOG_4BYTES, &mtr); + + BTR_EXTERN_SPACE_ID, + space_id, + MLOG_4BYTES, &mtr); mlog_write_ulint(data + local_len - + BTR_EXTERN_PAGE_NO, - page_no, - MLOG_4BYTES, &mtr); + + BTR_EXTERN_PAGE_NO, + page_no, + MLOG_4BYTES, &mtr); mlog_write_ulint(data + local_len - + BTR_EXTERN_OFFSET, - FIL_PAGE_DATA, - MLOG_4BYTES, &mtr); + + BTR_EXTERN_OFFSET, + FIL_PAGE_DATA, + MLOG_4BYTES, &mtr); /* Set the bit denoting that this field in rec is stored externally */ - rec_set_nth_field_extern_bit(rec, index, - big_rec_vec->fields[i].field_no, - TRUE, &mtr); + rec_set_nth_field_extern_bit + (rec, index, + big_rec_vec->fields[i].field_no, + TRUE, &mtr); } prev_page_no = page_no; @@ -3546,9 +3564,9 @@ btr_free_externally_stored_field( ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); ut_ad(mtr_memo_contains(local_mtr, dict_tree_get_lock(index->tree), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(local_mtr, buf_block_align(data), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); local_len -= BTR_EXTERN_FIELD_REF_SIZE; @@ -3556,20 +3574,21 @@ btr_free_externally_stored_field( mtr_start(&mtr); rec_page = buf_page_get(buf_frame_get_space_id(data), - buf_frame_get_page_no(data), RW_X_LATCH, &mtr); + buf_frame_get_page_no(data), + RW_X_LATCH, &mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(rec_page, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ space_id = mach_read_from_4(data + local_len - + BTR_EXTERN_SPACE_ID); + + BTR_EXTERN_SPACE_ID); page_no = mach_read_from_4(data + local_len - + BTR_EXTERN_PAGE_NO); + + BTR_EXTERN_PAGE_NO); offset = mach_read_from_4(data + local_len - + BTR_EXTERN_OFFSET); + + BTR_EXTERN_OFFSET); extern_len = mach_read_from_4(data + local_len - + BTR_EXTERN_LEN + 4); + + BTR_EXTERN_LEN + 4); /* If extern len is 0, then there is no external storage data at all */ @@ -3582,7 +3601,7 @@ btr_free_externally_stored_field( } if (mach_read_from_1(data + local_len + BTR_EXTERN_LEN) - & BTR_EXTERN_OWNER_FLAG) { + & BTR_EXTERN_OWNER_FLAG) { /* This field does not own the externally stored field: do not free! */ @@ -3592,8 +3611,8 @@ btr_free_externally_stored_field( } if (do_not_free_inherited - && mach_read_from_1(data + local_len + BTR_EXTERN_LEN) - & BTR_EXTERN_INHERITED_FLAG) { + && mach_read_from_1(data + local_len + BTR_EXTERN_LEN) + & BTR_EXTERN_INHERITED_FLAG) { /* Rollback and inherited field: do not free! */ mtr_commit(&mtr); @@ -3619,11 +3638,11 @@ btr_free_externally_stored_field( btr_page_free_low(index->tree, page, 0, &mtr); mlog_write_ulint(data + local_len + BTR_EXTERN_PAGE_NO, - next_page_no, - MLOG_4BYTES, &mtr); + next_page_no, + MLOG_4BYTES, &mtr); mlog_write_ulint(data + local_len + BTR_EXTERN_LEN + 4, - extern_len - part_len, - MLOG_4BYTES, &mtr); + extern_len - part_len, + MLOG_4BYTES, &mtr); if (next_page_no == FIL_NULL) { ut_a(extern_len - part_len == 0); } @@ -3660,7 +3679,7 @@ btr_rec_free_externally_stored_fields( ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(mtr_memo_contains(mtr, buf_block_align(rec), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); /* Free possible externally stored fields in the record */ ut_ad(dict_table_is_comp(index->table) == !!rec_offs_comp(offsets)); @@ -3671,7 +3690,8 @@ btr_rec_free_externally_stored_fields( data = rec_get_nth_field(rec, offsets, i, &len); btr_free_externally_stored_field(index, data, len, - do_not_free_inherited, mtr); + do_not_free_inherited, + mtr); } } } @@ -3702,7 +3722,7 @@ btr_rec_free_updated_extern_fields( ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(mtr_memo_contains(mtr, buf_block_align(rec), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); /* Free possible externally stored fields in the record */ @@ -3714,9 +3734,10 @@ btr_rec_free_updated_extern_fields( if (rec_offs_nth_extern(offsets, ufield->field_no)) { data = rec_get_nth_field(rec, offsets, - ufield->field_no, &len); + ufield->field_no, &len); btr_free_externally_stored_field(index, data, len, - do_not_free_inherited, mtr); + do_not_free_inherited, + mtr); } } } @@ -3787,7 +3808,7 @@ btr_copy_externally_stored_field( part_len = btr_blob_get_part_len(blob_header); ut_memcpy(buf + copied_len, blob_header + BTR_BLOB_HDR_SIZE, - part_len); + part_len); copied_len += part_len; page_no = btr_blob_get_next_page_no(blob_header); diff --git a/storage/innobase/btr/btr0pcur.c b/storage/innobase/btr/btr0pcur.c index c739930ce04..a8d8b2f072a 100644 --- a/storage/innobase/btr/btr0pcur.c +++ b/storage/innobase/btr/btr0pcur.c @@ -92,9 +92,9 @@ btr_pcur_store_position( offs = ut_align_offset(rec, UNIV_PAGE_SIZE); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_S_FIX) - || mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_S_FIX) + || mtr_memo_contains(mtr, buf_block_align(page), + MTR_MEMO_PAGE_X_FIX)); ut_a(cursor->latch_mode != BTR_NO_LATCHES); if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) { @@ -133,14 +133,13 @@ btr_pcur_store_position( } cursor->old_stored = BTR_PCUR_OLD_STORED; - cursor->old_rec = dict_tree_copy_rec_order_prefix(tree, rec, - &cursor->old_n_fields, - &cursor->old_rec_buf, - &cursor->buf_size); + cursor->old_rec = dict_tree_copy_rec_order_prefix + (tree, rec, &cursor->old_n_fields, + &cursor->old_rec_buf, &cursor->buf_size); cursor->block_when_stored = buf_block_align(page); - cursor->modify_clock = buf_block_get_modify_clock( - cursor->block_when_stored); + cursor->modify_clock = buf_block_get_modify_clock + (cursor->block_when_stored); } /****************************************************************** @@ -165,7 +164,7 @@ btr_pcur_copy_stored_position( pcur_receive->old_rec_buf = mem_alloc(pcur_donate->buf_size); ut_memcpy(pcur_receive->old_rec_buf, pcur_donate->old_rec_buf, - pcur_donate->buf_size); + pcur_donate->buf_size); pcur_receive->old_rec = pcur_receive->old_rec_buf + (pcur_donate->old_rec - pcur_donate->old_rec_buf); } @@ -206,8 +205,8 @@ btr_pcur_restore_position( mem_heap_t* heap; if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED) - || UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED - && cursor->pos_state != BTR_PCUR_IS_POSITIONED)) { + || UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED + && cursor->pos_state != BTR_PCUR_IS_POSITIONED)) { ut_print_buf(stderr, cursor, sizeof(btr_pcur_t)); if (cursor->trx_if_known) { trx_print(stderr, cursor->trx_if_known, 0); @@ -216,19 +215,20 @@ btr_pcur_restore_position( ut_error; } - if (UNIV_UNLIKELY(cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE - || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) { + if (UNIV_UNLIKELY + (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE + || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) { /* In these cases we do not try an optimistic restoration, but always do a search */ - btr_cur_open_at_index_side( - cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE, - btr_pcur_get_btr_cur(cursor)->index, latch_mode, - btr_pcur_get_btr_cur(cursor), mtr); + btr_cur_open_at_index_side + (cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE, + btr_pcur_get_btr_cur(cursor)->index, latch_mode, + btr_pcur_get_btr_cur(cursor), mtr); - cursor->block_when_stored = - buf_block_align(btr_pcur_get_page(cursor)); + cursor->block_when_stored + = buf_block_align(btr_pcur_get_page(cursor)); return(FALSE); } @@ -239,12 +239,13 @@ btr_pcur_restore_position( page = btr_cur_get_page(btr_pcur_get_btr_cur(cursor)); if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF) - || UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) { + || UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) { /* Try optimistic restoration */ - if (UNIV_LIKELY(buf_page_optimistic_get(latch_mode, - cursor->block_when_stored, page, - cursor->modify_clock, mtr))) { + if (UNIV_LIKELY + (buf_page_optimistic_get(latch_mode, + cursor->block_when_stored, page, + cursor->modify_clock, mtr))) { cursor->pos_state = BTR_PCUR_IS_POSITIONED; #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_TREE_NODE); @@ -262,14 +263,16 @@ btr_pcur_restore_position( index = btr_pcur_get_btr_cur(cursor)->index; heap = mem_heap_create(256); - offsets1 = rec_get_offsets(cursor->old_rec, - index, NULL, - cursor->old_n_fields, &heap); - offsets2 = rec_get_offsets(rec, index, NULL, - cursor->old_n_fields, &heap); + offsets1 = rec_get_offsets + (cursor->old_rec, index, NULL, + cursor->old_n_fields, &heap); + offsets2 = rec_get_offsets + (rec, index, NULL, + cursor->old_n_fields, &heap); - ut_ad(cmp_rec_rec(cursor->old_rec, - rec, offsets1, offsets2, index) == 0); + ut_ad(!cmp_rec_rec(cursor->old_rec, + rec, offsets1, offsets2, + index)); mem_heap_free(heap); #endif /* UNIV_DEBUG */ return(TRUE); @@ -285,7 +288,7 @@ btr_pcur_restore_position( tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor)); tuple = dict_tree_build_data_tuple(tree, cursor->old_rec, - cursor->old_n_fields, heap); + cursor->old_n_fields, heap); /* Save the old search mode of the cursor */ old_mode = cursor->search_mode; @@ -300,26 +303,27 @@ btr_pcur_restore_position( } btr_pcur_open_with_no_init(btr_pcur_get_btr_cur(cursor)->index, tuple, - mode, latch_mode, cursor, 0, mtr); + mode, latch_mode, cursor, 0, mtr); /* Restore the old search mode */ cursor->search_mode = old_mode; if (cursor->rel_pos == BTR_PCUR_ON - && btr_pcur_is_on_user_rec(cursor, mtr) - && 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor), - rec_get_offsets(btr_pcur_get_rec(cursor), - btr_pcur_get_btr_cur(cursor)->index, - NULL, ULINT_UNDEFINED, &heap))) { + && btr_pcur_is_on_user_rec(cursor, mtr) + && 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor), + rec_get_offsets + (btr_pcur_get_rec(cursor), + btr_pcur_get_btr_cur(cursor)->index, + NULL, ULINT_UNDEFINED, &heap))) { /* We have to store the NEW value for the modify clock, since the cursor can now be on a different page! But we can retain the value of old_rec */ - cursor->block_when_stored = - buf_block_align(btr_pcur_get_page(cursor)); - cursor->modify_clock = - buf_block_get_modify_clock(cursor->block_when_stored); + cursor->block_when_stored = buf_block_align + (btr_pcur_get_page(cursor)); + cursor->modify_clock = buf_block_get_modify_clock + (cursor->block_when_stored); cursor->old_stored = BTR_PCUR_OLD_STORED; mem_heap_free(heap); @@ -467,14 +471,14 @@ btr_pcur_move_backward_from_page( space = buf_frame_get_space_id(page); if (btr_pcur_is_before_first_on_page(cursor, mtr) - && (prev_page_no != FIL_NULL)) { + && (prev_page_no != FIL_NULL)) { prev_page = btr_pcur_get_btr_cur(cursor)->left_page; btr_leaf_page_release(page, latch_mode, mtr); page_cur_set_after_last(prev_page, - btr_pcur_get_page_cur(cursor)); + btr_pcur_get_page_cur(cursor)); } else if (prev_page_no != FIL_NULL) { /* The repositioned cursor did not end on an infimum record on diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index 2f2102379ab..bb089c4c417 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -231,19 +231,19 @@ btr_search_info_update_hash( } cmp = ut_pair_cmp(info->n_fields, info->n_bytes, - cursor->low_match, cursor->low_bytes); + cursor->low_match, cursor->low_bytes); if ((info->side == BTR_SEARCH_LEFT_SIDE && cmp <= 0) - || (info->side == BTR_SEARCH_RIGHT_SIDE && cmp > 0)) { + || (info->side == BTR_SEARCH_RIGHT_SIDE && cmp > 0)) { goto set_new_recomm; } cmp = ut_pair_cmp(info->n_fields, info->n_bytes, - cursor->up_match, cursor->up_bytes); + cursor->up_match, cursor->up_bytes); if ((info->side == BTR_SEARCH_LEFT_SIDE && cmp > 0) - || (info->side == BTR_SEARCH_RIGHT_SIDE && cmp <= 0)) { + || (info->side == BTR_SEARCH_RIGHT_SIDE && cmp <= 0)) { goto set_new_recomm; } @@ -260,7 +260,7 @@ set_new_recomm: info->hash_analysis = 0; cmp = ut_pair_cmp(cursor->up_match, cursor->up_bytes, - cursor->low_match, cursor->low_bytes); + cursor->low_match, cursor->low_bytes); if (cmp == 0) { info->n_hash_potential = 0; @@ -328,7 +328,7 @@ btr_search_update_block_hash_info( ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); ut_ad(rw_lock_own(&((buf_block_t*) block)->lock, RW_LOCK_SHARED) - || rw_lock_own(&((buf_block_t*) block)->lock, RW_LOCK_EX)); + || rw_lock_own(&((buf_block_t*) block)->lock, RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ ut_ad(cursor); @@ -338,15 +338,15 @@ btr_search_update_block_hash_info( ut_a(info->magic_n == BTR_SEARCH_MAGIC_N); if ((block->n_hash_helps > 0) - && (info->n_hash_potential > 0) - && (block->n_fields == info->n_fields) - && (block->n_bytes == info->n_bytes) - && (block->side == info->side)) { + && (info->n_hash_potential > 0) + && (block->n_fields == info->n_fields) + && (block->n_bytes == info->n_bytes) + && (block->side == info->side)) { if ((block->is_hashed) - && (block->curr_n_fields == info->n_fields) - && (block->curr_n_bytes == info->n_bytes) - && (block->curr_side == info->side)) { + && (block->curr_n_fields == info->n_fields) + && (block->curr_n_bytes == info->n_bytes) + && (block->curr_side == info->side)) { /* The search would presumably have succeeded using the hash index */ @@ -367,15 +367,15 @@ btr_search_update_block_hash_info( } if ((block->n_hash_helps > page_get_n_recs(block->frame) - / BTR_SEARCH_PAGE_BUILD_LIMIT) - && (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) { + / BTR_SEARCH_PAGE_BUILD_LIMIT) + && (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) { if ((!block->is_hashed) - || (block->n_hash_helps - > 2 * page_get_n_recs(block->frame)) - || (block->n_fields != block->curr_n_fields) - || (block->n_bytes != block->curr_n_bytes) - || (block->side != block->curr_side)) { + || (block->n_hash_helps + > 2 * page_get_n_recs(block->frame)) + || (block->n_fields != block->curr_n_fields) + || (block->n_bytes != block->curr_n_bytes) + || (block->side != block->curr_side)) { /* Build a new hash index on the page */ @@ -410,16 +410,16 @@ btr_search_update_hash_ref( #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) - || rw_lock_own(&(block->lock), RW_LOCK_EX)); + || rw_lock_own(&(block->lock), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ ut_ad(buf_block_align(btr_cur_get_rec(cursor)) == block); ut_a(!block->is_hashed || block->index == cursor->index); if (block->is_hashed - && (info->n_hash_potential > 0) - && (block->curr_n_fields == info->n_fields) - && (block->curr_n_bytes == info->n_bytes) - && (block->curr_side == info->side)) { + && (info->n_hash_potential > 0) + && (block->curr_n_fields == info->n_fields) + && (block->curr_n_bytes == info->n_bytes) + && (block->curr_side == info->side)) { mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; *offsets_ = (sizeof offsets_) / sizeof *offsets_; @@ -432,8 +432,9 @@ btr_search_update_hash_ref( } tree_id = ((cursor->index)->tree)->id; - fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, - offsets_, ULINT_UNDEFINED, &heap), + fold = rec_fold(rec, + rec_get_offsets(rec, cursor->index, offsets_, + ULINT_UNDEFINED, &heap), block->curr_n_fields, block->curr_n_bytes, tree_id); if (UNIV_LIKELY_NULL(heap)) { @@ -516,10 +517,10 @@ btr_search_info_update_slow( params2 = params + btr_search_this_is_zero; btr_search_build_page_hash_index(cursor->index, - block->frame, - params2[0], - params2[1], - params2[2]); + block->frame, + params2[0], + params2[1], + params2[2]); mem_free(params); } } @@ -568,9 +569,9 @@ btr_search_check_guess( bytes = 0; offsets = rec_get_offsets(rec, cursor->index, offsets, - n_unique, &heap); + n_unique, &heap); cmp = page_cmp_dtuple_rec_with_match(tuple, rec, - offsets, &match, &bytes); + offsets, &match, &bytes); if (mode == PAGE_CUR_GE) { if (cmp == 1) { @@ -617,16 +618,16 @@ btr_search_check_guess( prev_rec = page_rec_get_prev(rec); if (page_rec_is_infimum(prev_rec)) { - success = btr_page_get_prev( - buf_frame_align(prev_rec), mtr) == FIL_NULL; + success = btr_page_get_prev + (buf_frame_align(prev_rec), mtr) == FIL_NULL; goto exit_func; } offsets = rec_get_offsets(prev_rec, cursor->index, offsets, - n_unique, &heap); + n_unique, &heap); cmp = page_cmp_dtuple_rec_with_match(tuple, prev_rec, - offsets, &match, &bytes); + offsets, &match, &bytes); if (mode == PAGE_CUR_GE) { success = cmp == 1; } else { @@ -642,8 +643,8 @@ btr_search_check_guess( next_rec = page_rec_get_next(rec); if (page_rec_is_supremum(next_rec)) { - if (btr_page_get_next( - buf_frame_align(next_rec), mtr) == FIL_NULL) { + if (btr_page_get_next + (buf_frame_align(next_rec), mtr) == FIL_NULL) { cursor->up_match = 0; success = TRUE; @@ -653,9 +654,9 @@ btr_search_check_guess( } offsets = rec_get_offsets(next_rec, cursor->index, offsets, - n_unique, &heap); + n_unique, &heap); cmp = page_cmp_dtuple_rec_with_match(tuple, next_rec, - offsets, &match, &bytes); + offsets, &match, &bytes); if (mode == PAGE_CUR_LE) { success = cmp == -1; cursor->up_match = match; @@ -709,7 +710,7 @@ btr_search_guess_on_hash( #endif ut_ad(index && info && tuple && cursor && mtr); ut_ad((latch_mode == BTR_SEARCH_LEAF) - || (latch_mode == BTR_MODIFY_LEAF)); + || (latch_mode == BTR_MODIFY_LEAF)); /* Note that, for efficiency, the struct info may not be protected by any latch here! */ @@ -730,7 +731,7 @@ btr_search_guess_on_hash( } if (UNIV_UNLIKELY(tuple_n_fields == cursor->n_fields) - && (cursor->n_bytes > 0)) { + && (cursor->n_bytes > 0)) { return(FALSE); } @@ -762,10 +763,10 @@ btr_search_guess_on_hash( if (UNIV_LIKELY(!has_search_latch)) { - if (UNIV_UNLIKELY(!buf_page_get_known_nowait(latch_mode, page, + if (UNIV_UNLIKELY + (!buf_page_get_known_nowait(latch_mode, page, BUF_MAKE_YOUNG, - __FILE__, __LINE__, - mtr))) { + __FILE__, __LINE__, mtr))) { goto failure_unlock; } @@ -801,10 +802,11 @@ btr_search_guess_on_hash( record to determine if our guess for the cursor position is right. */ if (UNIV_EXPECT(ut_dulint_cmp(tree_id, btr_page_get_index_id(page)), 0) - || !btr_search_check_guess(cursor, - can_only_compare_to_cursor_rec, tuple, mode, mtr)) { + || !btr_search_check_guess(cursor, + can_only_compare_to_cursor_rec, + tuple, mode, mtr)) { if (UNIV_LIKELY(!has_search_latch)) { - btr_leaf_page_release(page, latch_mode, mtr); + btr_leaf_page_release(page, latch_mode, mtr); } goto failure; @@ -827,9 +829,9 @@ btr_search_guess_on_hash( btr_leaf_page_release(page, latch_mode, mtr); btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, - &cursor2, 0, mtr); + &cursor2, 0, mtr); if (mode == PAGE_CUR_GE - && page_rec_is_supremum(btr_cur_get_rec(&cursor2))) { + && page_rec_is_supremum(btr_cur_get_rec(&cursor2))) { /* If mode is PAGE_CUR_GE, then the binary search in the index tree may actually take us to the supremum @@ -838,7 +840,7 @@ btr_search_guess_on_hash( info->last_hash_succ = FALSE; btr_pcur_open_on_user_rec(index, tuple, mode, latch_mode, - &pcur, mtr); + &pcur, mtr); ut_ad(btr_pcur_get_rec(&pcur) == btr_cur_get_rec(cursor)); } else { ut_ad(btr_cur_get_rec(&cursor2) == btr_cur_get_rec(cursor)); @@ -854,7 +856,7 @@ btr_search_guess_on_hash( btr_search_n_succ++; #endif if (UNIV_LIKELY(!has_search_latch) - && buf_block_peek_if_too_old(block)) { + && buf_block_peek_if_too_old(block)) { buf_page_make_young(page); } @@ -931,8 +933,8 @@ retry: #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) - || rw_lock_own(&(block->lock), RW_LOCK_EX) - || (block->buf_fix_count == 0)); + || rw_lock_own(&(block->lock), RW_LOCK_EX) + || (block->buf_fix_count == 0)); #endif /* UNIV_SYNC_DEBUG */ n_fields = block->curr_n_fields; @@ -972,7 +974,7 @@ retry: /* FIXME: in a mixed tree, not all records may have enough ordering fields: */ offsets = rec_get_offsets(rec, index, offsets, - n_fields + (n_bytes > 0), &heap); + n_fields + (n_bytes > 0), &heap); ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0)); fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id); @@ -1006,7 +1008,7 @@ next_rec: ut_a(block->index == index); if (UNIV_UNLIKELY(block->curr_n_fields != n_fields) - || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) { + || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) { /* Someone else has meanwhile built a new hash index on the page, with different parameters */ @@ -1029,8 +1031,10 @@ cleanup: /* Corruption */ ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Corruption of adaptive hash index. After dropping\n" -"InnoDB: the hash index to a page of %s, still %lu hash nodes remain.\n", + " InnoDB: Corruption of adaptive hash index." + " After dropping\n" + "InnoDB: the hash index to a page of %s," + " still %lu hash nodes remain.\n", index->name, (ulong) block->n_pointers); rw_lock_x_unlock(&btr_search_latch); @@ -1124,14 +1128,14 @@ btr_search_build_page_hash_index( #ifdef UNIV_SYNC_DEBUG ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) - || rw_lock_own(&(block->lock), RW_LOCK_EX)); + || rw_lock_own(&(block->lock), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ rw_lock_s_lock(&btr_search_latch); if (block->is_hashed && ((block->curr_n_fields != n_fields) - || (block->curr_n_bytes != n_bytes) - || (block->curr_side != side))) { + || (block->curr_n_bytes != n_bytes) + || (block->curr_side != side))) { rw_lock_s_unlock(&btr_search_latch); @@ -1155,8 +1159,8 @@ btr_search_build_page_hash_index( } if (dict_index_get_n_unique_in_tree(index) < n_fields - || (dict_index_get_n_unique_in_tree(index) == n_fields - && n_bytes > 0)) { + || (dict_index_get_n_unique_in_tree(index) == n_fields + && n_bytes > 0)) { return; } @@ -1174,7 +1178,7 @@ btr_search_build_page_hash_index( rec = page_rec_get_next(rec); offsets = rec_get_offsets(rec, index, offsets, - n_fields + (n_bytes > 0), &heap); + n_fields + (n_bytes > 0), &heap); if (!page_rec_is_supremum(rec)) { ut_a(n_fields <= rec_offs_n_fields(offsets)); @@ -1211,9 +1215,9 @@ btr_search_build_page_hash_index( } offsets = rec_get_offsets(next_rec, index, offsets, - n_fields + (n_bytes > 0), &heap); + n_fields + (n_bytes > 0), &heap); next_fold = rec_fold(next_rec, offsets, n_fields, - n_bytes, tree_id); + n_bytes, tree_id); if (fold != next_fold) { /* Insert an entry into the hash index */ @@ -1239,8 +1243,8 @@ btr_search_build_page_hash_index( rw_lock_x_lock(&btr_search_latch); if (block->is_hashed && ((block->curr_n_fields != n_fields) - || (block->curr_n_bytes != n_bytes) - || (block->curr_side != side))) { + || (block->curr_n_bytes != n_bytes) + || (block->curr_side != side))) { goto exit_func; } @@ -1327,7 +1331,7 @@ btr_search_move_or_delete_hash_entries( ut_a(n_fields + n_bytes > 0); btr_search_build_page_hash_index(index, new_page, n_fields, - n_bytes, side); + n_bytes, side); ut_a(n_fields == block->curr_n_fields); ut_a(n_bytes == block->curr_n_bytes); ut_a(side == block->curr_side); @@ -1378,8 +1382,8 @@ btr_search_update_hash_on_delete( tree_id = cursor->index->tree->id; fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_, - ULINT_UNDEFINED, &heap), block->curr_n_fields, - block->curr_n_bytes, tree_id); + ULINT_UNDEFINED, &heap), + block->curr_n_fields, block->curr_n_bytes, tree_id); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1423,14 +1427,14 @@ btr_search_update_hash_node_on_insert( rw_lock_x_lock(&btr_search_latch); if ((cursor->flag == BTR_CUR_HASH) - && (cursor->n_fields == block->curr_n_fields) - && (cursor->n_bytes == block->curr_n_bytes) - && (block->curr_side == BTR_SEARCH_RIGHT_SIDE)) { + && (cursor->n_fields == block->curr_n_fields) + && (cursor->n_bytes == block->curr_n_bytes) + && (block->curr_side == BTR_SEARCH_RIGHT_SIDE)) { table = btr_search_sys->hash_index; ha_search_and_update_if_found(table, cursor->fold, rec, - page_rec_get_next(rec)); + page_rec_get_next(rec)); rw_lock_x_unlock(&btr_search_latch); } else { @@ -1498,19 +1502,19 @@ btr_search_update_hash_on_insert( next_rec = page_rec_get_next(ins_rec); offsets = rec_get_offsets(ins_rec, cursor->index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, tree_id); if (!page_rec_is_supremum(next_rec)) { offsets = rec_get_offsets(next_rec, cursor->index, offsets, - n_fields + (n_bytes > 0), &heap); + n_fields + (n_bytes > 0), &heap); next_fold = rec_fold(next_rec, offsets, n_fields, - n_bytes, tree_id); + n_bytes, tree_id); } if (!page_rec_is_infimum(rec)) { offsets = rec_get_offsets(rec, cursor->index, offsets, - n_fields + (n_bytes > 0), &heap); + n_fields + (n_bytes > 0), &heap); fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id); } else { if (side == BTR_SEARCH_LEFT_SIDE) { @@ -1570,11 +1574,11 @@ check_next_rec: if (side == BTR_SEARCH_RIGHT_SIDE) { ha_insert_for_fold(table, ins_fold, ins_rec); -/* + /* fputs("Hash insert for ", stderr); dict_index_name_print(stderr, cursor->index); fprintf(stderr, " fold %lu\n", ins_fold); -*/ + */ } else { ha_insert_for_fold(table, next_fold, next_rec); } @@ -1633,12 +1637,13 @@ btr_search_validate(void) block = buf_block_align(node->data); page = buf_frame_align(node->data); offsets = rec_get_offsets((rec_t*) node->data, - block->index, offsets, - block->curr_n_fields - + (block->curr_n_bytes > 0), &heap); + block->index, offsets, + block->curr_n_fields + + (block->curr_n_bytes > 0), + &heap); - if (!block->is_hashed - || node->fold != rec_fold((rec_t*)(node->data), + if (!block->is_hashed || node->fold + != rec_fold((rec_t*)(node->data), offsets, block->curr_n_fields, block->curr_n_bytes, @@ -1647,28 +1652,36 @@ btr_search_validate(void) ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error in an adaptive hash index pointer to page %lu\n" -"ptr mem address %p index id %lu %lu, node fold %lu, rec fold %lu\n", + " InnoDB: Error in an adaptive hash" + " index pointer to page %lu\n" + "InnoDB: ptr mem address %p" + " index id %lu %lu," + " node fold %lu, rec fold %lu\n", (ulong) buf_frame_get_page_no(page), node->data, - (ulong) ut_dulint_get_high(btr_page_get_index_id(page)), - (ulong) ut_dulint_get_low(btr_page_get_index_id(page)), + (ulong) ut_dulint_get_high + (btr_page_get_index_id(page)), + (ulong) ut_dulint_get_low + (btr_page_get_index_id(page)), (ulong) node->fold, (ulong) rec_fold((rec_t*)(node->data), - offsets, - block->curr_n_fields, - block->curr_n_bytes, - btr_page_get_index_id(page))); + offsets, + block->curr_n_fields, + block->curr_n_bytes, + btr_page_get_index_id + (page))); fputs("InnoDB: Record ", stderr); rec_print_new(stderr, (rec_t*)node->data, - offsets); + offsets); fprintf(stderr, "\nInnoDB: on that page." -"Page mem address %p, is hashed %lu, n fields %lu, n bytes %lu\n" -"side %lu\n", - page, (ulong) block->is_hashed, - (ulong) block->curr_n_fields, - (ulong) block->curr_n_bytes, (ulong) block->curr_side); + " Page mem address %p, is hashed %lu," + " n fields %lu, n bytes %lu\n" + "InnoDB: side %lu\n", + (void*) page, (ulong) block->is_hashed, + (ulong) block->curr_n_fields, + (ulong) block->curr_n_bytes, + (ulong) block->curr_side); if (n_page_dumps < 20) { buf_page_print(page); diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index ad23da4af93..4e8cd97c9a8 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -160,8 +160,8 @@ and the io-operation for loading the page is queued. The io-handler thread releases the X-lock on the frame and resets the io_fix field when the io operation completes. -A thread may request the above operation using the buf_page_get- -function. It may then continue to request a lock on the frame. +A thread may request the above operation using the function +buf_page_get(). It may then continue to request a lock on the frame. The lock is granted when the io-handler releases the x-lock. Read-ahead @@ -253,10 +253,10 @@ buf_calc_page_new_checksum( there we store the old formula checksum. */ checksum = ut_fold_binary(page + FIL_PAGE_OFFSET, - FIL_PAGE_FILE_FLUSH_LSN - FIL_PAGE_OFFSET) - + ut_fold_binary(page + FIL_PAGE_DATA, - UNIV_PAGE_SIZE - FIL_PAGE_DATA - - FIL_PAGE_END_LSN_OLD_CHKSUM); + FIL_PAGE_FILE_FLUSH_LSN - FIL_PAGE_OFFSET) + + ut_fold_binary(page + FIL_PAGE_DATA, + UNIV_PAGE_SIZE - FIL_PAGE_DATA + - FIL_PAGE_END_LSN_OLD_CHKSUM); checksum = checksum & 0xFFFFFFFFUL; return(checksum); @@ -302,11 +302,11 @@ buf_page_is_corrupted( dulint current_lsn; #endif if (mach_read_from_4(read_buf + FIL_PAGE_LSN + 4) - != mach_read_from_4(read_buf + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + != mach_read_from_4(read_buf + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { /* Stored log sequence numbers at the start and the end - of page do not match */ + of page do not match */ return(TRUE); } @@ -314,22 +314,28 @@ buf_page_is_corrupted( #ifndef UNIV_HOTBACKUP if (recv_lsn_checks_on && log_peek_lsn(¤t_lsn)) { if (ut_dulint_cmp(current_lsn, - mach_read_from_8(read_buf + FIL_PAGE_LSN)) - < 0) { + mach_read_from_8(read_buf + FIL_PAGE_LSN)) + < 0) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: page %lu log sequence number %lu %lu\n" -"InnoDB: is in the future! Current system log sequence number %lu %lu.\n" -"InnoDB: Your database may be corrupt or you may have copied the InnoDB\n" -"InnoDB: tablespace but not the InnoDB log files. See\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" -"InnoDB: for more information.\n", - (ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET), - (ulong) ut_dulint_get_high( - mach_read_from_8(read_buf + FIL_PAGE_LSN)), - (ulong) ut_dulint_get_low( - mach_read_from_8(read_buf + FIL_PAGE_LSN)), + " InnoDB: Error: page %lu log sequence number" + " %lu %lu\n" + "InnoDB: is in the future! Current system " + "log sequence number %lu %lu.\n" + "InnoDB: Your database may be corrupt or " + "you may have copied the InnoDB\n" + "InnoDB: tablespace but not the InnoDB " + "log files. See\n" + "InnoDB: http://dev.mysql.com/doc/refman/" + "5.1/en/forcing-recovery.html\n" + "InnoDB: for more information.\n", + (ulong) mach_read_from_4(read_buf + + FIL_PAGE_OFFSET), + (ulong) ut_dulint_get_high + (mach_read_from_8(read_buf + FIL_PAGE_LSN)), + (ulong) ut_dulint_get_low + (mach_read_from_8(read_buf + FIL_PAGE_LSN)), (ulong) ut_dulint_get_high(current_lsn), (ulong) ut_dulint_get_low(current_lsn)); } @@ -344,8 +350,9 @@ buf_page_is_corrupted( if (srv_use_checksums) { old_checksum = buf_calc_page_old_checksum(read_buf); - old_checksum_field = mach_read_from_4(read_buf + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM); + old_checksum_field = mach_read_from_4 + (read_buf + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM); /* There are 2 valid formulas for old_checksum_field: @@ -356,22 +363,22 @@ buf_page_is_corrupted( there. */ if (old_checksum_field != mach_read_from_4(read_buf - + FIL_PAGE_LSN) - && old_checksum_field != old_checksum - && old_checksum_field != BUF_NO_CHECKSUM_MAGIC) { + + FIL_PAGE_LSN) + && old_checksum_field != old_checksum + && old_checksum_field != BUF_NO_CHECKSUM_MAGIC) { return(TRUE); } checksum = buf_calc_page_new_checksum(read_buf); - checksum_field = mach_read_from_4(read_buf + - FIL_PAGE_SPACE_OR_CHKSUM); + checksum_field = mach_read_from_4(read_buf + + FIL_PAGE_SPACE_OR_CHKSUM); /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id (always equal to 0), to FIL_PAGE_SPACE_SPACE_OR_CHKSUM */ if (checksum_field != 0 && checksum_field != checksum - && checksum_field != BUF_NO_CHECKSUM_MAGIC) { + && checksum_field != BUF_NO_CHECKSUM_MAGIC) { return(TRUE); } @@ -398,37 +405,41 @@ buf_page_print( ut_print_buf(stderr, read_buf, UNIV_PAGE_SIZE); fputs("InnoDB: End of page dump\n", stderr); - checksum = srv_use_checksums ? - buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC; - old_checksum = srv_use_checksums ? - buf_calc_page_old_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC; + checksum = srv_use_checksums + ? buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC; + old_checksum = srv_use_checksums + ? buf_calc_page_old_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC; ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Page checksum %lu, prior-to-4.0.14-form checksum %lu\n" -"InnoDB: stored checksum %lu, prior-to-4.0.14-form stored checksum %lu\n", - (ulong) checksum, (ulong) old_checksum, - (ulong) mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM), - (ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM)); - fprintf(stderr, -"InnoDB: Page lsn %lu %lu, low 4 bytes of lsn at page end %lu\n" -"InnoDB: Page number (if stored to page already) %lu,\n" -"InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) %lu\n", + " InnoDB: Page checksum %lu, prior-to-4.0.14-form" + " checksum %lu\n" + "InnoDB: stored checksum %lu, prior-to-4.0.14-form" + " stored checksum %lu\n" + "InnoDB: Page lsn %lu %lu, low 4 bytes of lsn" + " at page end %lu\n" + "InnoDB: Page number (if stored to page already) %lu,\n" + "InnoDB: space id (if created with >= MySQL-4.1.1" + " and stored already) %lu\n", + (ulong) checksum, (ulong) old_checksum, + (ulong) mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM), + (ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM), (ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN), (ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN + 4), (ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM + 4), + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4), (ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET), - (ulong) mach_read_from_4(read_buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID)); + (ulong) mach_read_from_4(read_buf + + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID)); if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE) - == TRX_UNDO_INSERT) { + == TRX_UNDO_INSERT) { fprintf(stderr, "InnoDB: Page may be an insert undo log page\n"); } else if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_TYPE) - == TRX_UNDO_UPDATE) { + + TRX_UNDO_PAGE_TYPE) + == TRX_UNDO_UPDATE) { fprintf(stderr, "InnoDB: Page may be an update undo log page\n"); } @@ -436,17 +447,20 @@ buf_page_print( switch (fil_page_get_type(read_buf)) { case FIL_PAGE_INDEX: fprintf(stderr, -"InnoDB: Page may be an index page where index id is %lu %lu\n", - (ulong) ut_dulint_get_high(btr_page_get_index_id(read_buf)), - (ulong) ut_dulint_get_low(btr_page_get_index_id(read_buf))); + "InnoDB: Page may be an index page where" + " index id is %lu %lu\n", + (ulong) ut_dulint_get_high + (btr_page_get_index_id(read_buf)), + (ulong) ut_dulint_get_low + (btr_page_get_index_id(read_buf))); /* If the code is in ibbackup, dict_sys may be uninitialized, i.e., NULL */ if (dict_sys != NULL) { - index = dict_index_find_on_id_low( - btr_page_get_index_id(read_buf)); + index = dict_index_find_on_id_low + (btr_page_get_index_id(read_buf)); if (index) { fputs("InnoDB: (", stderr); dict_index_name_print(stderr, NULL, index); @@ -459,35 +473,35 @@ buf_page_print( break; case FIL_PAGE_IBUF_FREE_LIST: fputs("InnoDB: Page may be an insert buffer free list page\n", - stderr); + stderr); break; case FIL_PAGE_TYPE_ALLOCATED: fputs("InnoDB: Page may be a freshly allocated page\n", - stderr); + stderr); break; case FIL_PAGE_IBUF_BITMAP: fputs("InnoDB: Page may be an insert buffer bitmap page\n", - stderr); + stderr); break; case FIL_PAGE_TYPE_SYS: fputs("InnoDB: Page may be a system page\n", - stderr); + stderr); break; case FIL_PAGE_TYPE_TRX_SYS: fputs("InnoDB: Page may be a transaction system page\n", - stderr); + stderr); break; case FIL_PAGE_TYPE_FSP_HDR: fputs("InnoDB: Page may be a file space header page\n", - stderr); + stderr); break; case FIL_PAGE_TYPE_XDES: fputs("InnoDB: Page may be an extent descriptor page\n", - stderr); + stderr); break; case FIL_PAGE_TYPE_BLOB: fputs("InnoDB: Page may be a BLOB page\n", - stderr); + stderr); break; } } @@ -561,9 +575,12 @@ buf_pool_init( if (n_frames > curr_size) { fprintf(stderr, -"InnoDB: AWE: Error: you must specify in my.cnf .._awe_mem_mb larger\n" -"InnoDB: than .._buffer_pool_size. Now the former is %lu pages,\n" -"InnoDB: the latter %lu pages.\n", (ulong) curr_size, (ulong) n_frames); + "InnoDB: AWE: Error: you must specify in my.cnf" + " .._awe_mem_mb larger\n" + "InnoDB: than .._buffer_pool_size. Now the former" + " is %lu pages,\n" + "InnoDB: the latter %lu pages.\n", + (ulong) curr_size, (ulong) n_frames); return(NULL); } @@ -571,7 +588,7 @@ buf_pool_init( buf_pool = mem_alloc(sizeof(buf_pool_t)); /* 1. Initialize general fields - ---------------------------- */ + ---------------------------- */ mutex_create(&buf_pool->mutex, SYNC_BUF_POOL); mutex_enter(&(buf_pool->mutex)); @@ -581,8 +598,8 @@ buf_pool_init( /* Allocate the virtual address space window, i.e., the buffer pool frames */ - buf_pool->frame_mem = os_awe_allocate_virtual_mem_window( - UNIV_PAGE_SIZE * (n_frames + 1)); + buf_pool->frame_mem = os_awe_allocate_virtual_mem_window + (UNIV_PAGE_SIZE * (n_frames + 1)); /* Allocate the physical memory for AWE and the AWE info array for buf_pool */ @@ -590,23 +607,26 @@ buf_pool_init( if ((curr_size % ((1024 * 1024) / UNIV_PAGE_SIZE)) != 0) { fprintf(stderr, -"InnoDB: AWE: Error: physical memory must be allocated in full megabytes.\n" -"InnoDB: Trying to allocate %lu database pages.\n", - (ulong) curr_size); + "InnoDB: AWE: Error: physical memory must be" + " allocated in full megabytes.\n" + "InnoDB: Trying to allocate %lu" + " database pages.\n", + (ulong) curr_size); return(NULL); } if (!os_awe_allocate_physical_mem(&(buf_pool->awe_info), - curr_size / ((1024 * 1024) / UNIV_PAGE_SIZE))) { + curr_size + / ((1024 * 1024) + / UNIV_PAGE_SIZE))) { return(NULL); } /*----------------------------------------*/ } else { - buf_pool->frame_mem = os_mem_alloc_large( - UNIV_PAGE_SIZE * (n_frames + 1), - TRUE, FALSE); + buf_pool->frame_mem = os_mem_alloc_large + (UNIV_PAGE_SIZE * (n_frames + 1), TRUE, FALSE); } if (buf_pool->frame_mem == NULL) { @@ -639,9 +659,10 @@ buf_pool_init( the window */ os_awe_map_physical_mem_to_window(buf_pool->frame_zero, - n_frames * - (UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE), - buf_pool->awe_info); + n_frames + * (UNIV_PAGE_SIZE + / OS_AWE_X86_PAGE_SIZE), + buf_pool->awe_info); /*----------------------------------------*/ } @@ -697,7 +718,7 @@ buf_pool_init( buf_pool->n_pages_awe_remapped_old = 0; /* 2. Initialize flushing fields - ---------------------------- */ + ---------------------------- */ UT_LIST_INIT(buf_pool->flush_list); for (i = BUF_FLUSH_LRU; i <= BUF_FLUSH_LIST; i++) { @@ -712,7 +733,7 @@ buf_pool_init( buf_pool->freed_page_clock = 0; /* 3. Initialize LRU fields - ---------------------------- */ + ---------------------------- */ UT_LIST_INIT(buf_pool->LRU); buf_pool->LRU_old = NULL; @@ -738,7 +759,8 @@ buf_pool_init( frames */ UT_LIST_ADD_LAST(awe_LRU_free_mapped, - buf_pool->awe_LRU_free_mapped, block); + buf_pool->awe_LRU_free_mapped, + block); } } @@ -749,8 +771,8 @@ buf_pool_init( mutex_exit(&(buf_pool->mutex)); if (srv_use_adaptive_hash_indexes) { - btr_search_sys_create( - curr_size * UNIV_PAGE_SIZE / sizeof(void*) / 64); + btr_search_sys_create(curr_size * UNIV_PAGE_SIZE + / sizeof(void*) / 64); } else { /* Create only a small dummy system */ btr_search_sys_create(1000); @@ -792,35 +814,36 @@ buf_awe_map_page_to_frame( while (bck) { if (bck->state == BUF_BLOCK_FILE_PAGE - && (bck->buf_fix_count != 0 || bck->io_fix != 0)) { + && (bck->buf_fix_count != 0 || bck->io_fix != 0)) { /* We have to skip this */ bck = UT_LIST_GET_PREV(awe_LRU_free_mapped, bck); } else { /* We can map block to the frame of bck */ - os_awe_map_physical_mem_to_window( - bck->frame, - UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE, - block->awe_info); + os_awe_map_physical_mem_to_window + (bck->frame, + UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE, + block->awe_info); block->frame = bck->frame; *(buf_pool->blocks_of_frames - + (((ulint)(block->frame - - buf_pool->frame_zero)) - >> UNIV_PAGE_SIZE_SHIFT)) + + (((ulint)(block->frame + - buf_pool->frame_zero)) + >> UNIV_PAGE_SIZE_SHIFT)) = block; bck->frame = NULL; UT_LIST_REMOVE(awe_LRU_free_mapped, - buf_pool->awe_LRU_free_mapped, - bck); + buf_pool->awe_LRU_free_mapped, + bck); if (add_to_mapped_list) { - UT_LIST_ADD_FIRST(awe_LRU_free_mapped, - buf_pool->awe_LRU_free_mapped, - block); + UT_LIST_ADD_FIRST + (awe_LRU_free_mapped, + buf_pool->awe_LRU_free_mapped, + block); } buf_pool->n_pages_awe_remapped++; @@ -830,8 +853,8 @@ buf_awe_map_page_to_frame( } fprintf(stderr, -"InnoDB: AWE: Fatal error: cannot find a page to unmap\n" -"InnoDB: awe_LRU_free_mapped list length %lu\n", + "InnoDB: AWE: Fatal error: cannot find a page to unmap\n" + "InnoDB: awe_LRU_free_mapped list length %lu\n", (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped)); ut_a(0); @@ -864,7 +887,7 @@ buf_block_make_young( buf_block_t* block) /* in: block to make younger */ { if (buf_pool->freed_page_clock >= block->freed_page_clock - + 1 + (buf_pool->curr_size / 1024)) { + + 1 + (buf_pool->curr_size / 1024)) { /* There has been freeing activity in the LRU list: best to move to the head of the LRU list */ @@ -1118,11 +1141,11 @@ buf_page_get_gen( ut_ad(mtr); ut_ad((rw_latch == RW_S_LATCH) - || (rw_latch == RW_X_LATCH) - || (rw_latch == RW_NO_LATCH)); + || (rw_latch == RW_X_LATCH) + || (rw_latch == RW_NO_LATCH)); ut_ad((mode != BUF_GET_NO_LATCH) || (rw_latch == RW_NO_LATCH)); ut_ad((mode == BUF_GET) || (mode == BUF_GET_IF_IN_POOL) - || (mode == BUF_GET_NO_LATCH) || (mode == BUF_GET_NOWAIT)); + || (mode == BUF_GET_NO_LATCH) || (mode == BUF_GET_NOWAIT)); #ifndef UNIV_LOG_DEBUG ut_ad(!ibuf_inside() || ibuf_page(space, offset)); #endif @@ -1136,7 +1159,7 @@ loop: block = buf_block_align(guess); if ((offset != block->offset) || (space != block->space) - || (block->state != BUF_BLOCK_FILE_PAGE)) { + || (block->state != BUF_BLOCK_FILE_PAGE)) { block = NULL; } @@ -1229,12 +1252,12 @@ loop: if (mode == BUF_GET_NOWAIT) { if (rw_latch == RW_S_LATCH) { success = rw_lock_s_lock_func_nowait(&(block->lock), - file, line); + file, line); fix_type = MTR_MEMO_PAGE_S_FIX; } else { ut_ad(rw_latch == RW_X_LATCH); success = rw_lock_x_lock_func_nowait(&(block->lock), - file, line); + file, line); fix_type = MTR_MEMO_PAGE_X_FIX; } @@ -1331,8 +1354,8 @@ buf_page_optimistic_get_func( /* If AWE is used, block may have a different frame now, e.g., NULL */ if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE) - || UNIV_UNLIKELY(block->frame != guess)) { - exit_func: + || UNIV_UNLIKELY(block->frame != guess)) { +exit_func: mutex_exit(&(buf_pool->mutex)); return(FALSE); @@ -1357,11 +1380,11 @@ buf_page_optimistic_get_func( if (rw_latch == RW_S_LATCH) { success = rw_lock_s_lock_func_nowait(&(block->lock), - file, line); + file, line); fix_type = MTR_MEMO_PAGE_S_FIX; } else { success = rw_lock_x_lock_func_nowait(&(block->lock), - file, line); + file, line); fix_type = MTR_MEMO_PAGE_X_FIX; } @@ -1414,7 +1437,7 @@ buf_page_optimistic_get_func( read-ahead */ buf_read_ahead_linear(buf_frame_get_space_id(guess), - buf_frame_get_page_no(guess)); + buf_frame_get_page_no(guess)); } #ifdef UNIV_IBUF_DEBUG @@ -1482,11 +1505,11 @@ buf_page_get_known_nowait( if (rw_latch == RW_S_LATCH) { success = rw_lock_s_lock_func_nowait(&(block->lock), - file, line); + file, line); fix_type = MTR_MEMO_PAGE_S_FIX; } else { success = rw_lock_x_lock_func_nowait(&(block->lock), - file, line); + file, line); fix_type = MTR_MEMO_PAGE_X_FIX; } @@ -1519,7 +1542,7 @@ buf_page_get_known_nowait( #ifdef UNIV_IBUF_DEBUG ut_a((mode == BUF_KEEP_OLD) - || (ibuf_count_get(block->space, block->offset) == 0)); + || (ibuf_count_get(block->space, block->offset) == 0)); #endif buf_pool->n_page_gets++; @@ -1598,7 +1621,8 @@ buf_page_init( if (buf_page_hash_get(space, offset)) { fprintf(stderr, -"InnoDB: Error: page %lu %lu already found from the hash table\n", + "InnoDB: Error: page %lu %lu already found" + " in the hash table\n", (ulong) space, (ulong) offset); #ifdef UNIV_DEBUG @@ -1611,7 +1635,7 @@ buf_page_init( } HASH_INSERT(buf_block_t, hash, buf_pool->page_hash, - buf_page_address_fold(space, offset), block); + buf_page_address_fold(space, offset), block); block->freed_page_clock = 0; @@ -1686,27 +1710,28 @@ buf_page_init_for_read( mutex_enter(&(buf_pool->mutex)); - if (fil_tablespace_deleted_or_being_deleted_in_mem(space, - tablespace_version)) { + if (fil_tablespace_deleted_or_being_deleted_in_mem + (space, tablespace_version)) { *err = DB_TABLESPACE_DELETED; } if (*err == DB_TABLESPACE_DELETED - || NULL != buf_page_hash_get(space, offset)) { + || NULL != buf_page_hash_get(space, offset)) { - /* The page belongs to a space which has been deleted or is - being deleted, or the page is already in buf_pool, return */ + /* The page belongs to a space which has been + deleted or is being deleted, or the page is + already in buf_pool, return */ - mutex_exit(&(buf_pool->mutex)); - buf_block_free(block); + mutex_exit(&(buf_pool->mutex)); + buf_block_free(block); - if (mode == BUF_READ_IBUF_PAGES_ONLY) { + if (mode == BUF_READ_IBUF_PAGES_ONLY) { - mtr_commit(&mtr); - } + mtr_commit(&mtr); + } - return(NULL); - } + return(NULL); + } ut_ad(block); @@ -1866,23 +1891,24 @@ buf_page_io_complete( /* If this page is not uninitialized and not in the doublewrite buffer, then the page number and space id should be the same as in block. */ - ulint read_page_no = mach_read_from_4((block->frame) - + FIL_PAGE_OFFSET); - ulint read_space_id = mach_read_from_4((block->frame) - + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); + ulint read_page_no = mach_read_from_4 + (block->frame + FIL_PAGE_OFFSET); + ulint read_space_id = mach_read_from_4 + (block->frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - if (!block->space && trx_doublewrite_page_inside( - block->offset)) { + if (!block->space + && trx_doublewrite_page_inside(block->offset)) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: reading page %lu\n" -"InnoDB: which is in the doublewrite buffer!\n", + " InnoDB: Error: reading page %lu\n" + "InnoDB: which is in the" + " doublewrite buffer!\n", (ulong) block->offset); } else if (!read_space_id && !read_page_no) { /* This is likely an uninitialized page. */ } else if ((block->space && block->space != read_space_id) - || block->offset != read_page_no) { + || block->offset != read_page_no) { /* We did not compare space_id to read_space_id if block->space == 0, because the field on the page may contain garbage in MySQL < 4.1.1, @@ -1890,59 +1916,73 @@ buf_page_io_complete( ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: space id and page n:o stored in the page\n" -"InnoDB: read in are %lu:%lu, should be %lu:%lu!\n", + " InnoDB: Error: space id and page n:o" + " stored in the page\n" + "InnoDB: read in are %lu:%lu," + " should be %lu:%lu!\n", (ulong) read_space_id, (ulong) read_page_no, (ulong) block->space, (ulong) block->offset); } /* From version 3.23.38 up we store the page checksum - to the 4 first bytes of the page end lsn field */ + to the 4 first bytes of the page end lsn field */ if (buf_page_is_corrupted(block->frame)) { fprintf(stderr, - "InnoDB: Database page corruption on disk or a failed\n" - "InnoDB: file read of page %lu.\n", (ulong) block->offset); + "InnoDB: Database page corruption on disk" + " or a failed\n" + "InnoDB: file read of page %lu.\n", + (ulong) block->offset); - fputs( - "InnoDB: You may have to recover from a backup.\n", stderr); + fputs("InnoDB: You may have to recover" + " from a backup.\n", stderr); buf_page_print(block->frame); fprintf(stderr, - "InnoDB: Database page corruption on disk or a failed\n" - "InnoDB: file read of page %lu.\n", (ulong) block->offset); - fputs( - "InnoDB: You may have to recover from a backup.\n", stderr); - fputs( - "InnoDB: It is also possible that your operating\n" - "InnoDB: system has corrupted its own file cache\n" - "InnoDB: and rebooting your computer removes the\n" - "InnoDB: error.\n" - "InnoDB: If the corrupt page is an index page\n" - "InnoDB: you can also try to fix the corruption\n" - "InnoDB: by dumping, dropping, and reimporting\n" - "InnoDB: the corrupt table. You can use CHECK\n" - "InnoDB: TABLE to scan your table for corruption.\n" - "InnoDB: See also " -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" - "InnoDB: about forcing recovery.\n", stderr); + "InnoDB: Database page corruption on disk" + " or a failed\n" + "InnoDB: file read of page %lu.\n", + (ulong) block->offset); + fputs("InnoDB: You may have to recover" + " from a backup.\n", stderr); + fputs("InnoDB: It is also possible that" + " your operating\n" + "InnoDB: system has corrupted its" + " own file cache\n" + "InnoDB: and rebooting your computer" + " removes the\n" + "InnoDB: error.\n" + "InnoDB: If the corrupt page is an index page\n" + "InnoDB: you can also try to" + " fix the corruption\n" + "InnoDB: by dumping, dropping," + " and reimporting\n" + "InnoDB: the corrupt table." + " You can use CHECK\n" + "InnoDB: TABLE to scan your" + " table for corruption.\n" + "InnoDB: See also" + " http://dev.mysql.com/doc/refman/5.1/en/" + "forcing-recovery.html\n" + "InnoDB: about forcing recovery.\n", stderr); if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) { - fputs( - "InnoDB: Ending processing because of a corrupt database page.\n", - stderr); + fputs("InnoDB: Ending processing because of" + " a corrupt database page.\n", + stderr); exit(1); } } if (recv_recovery_is_on()) { recv_recover_page(FALSE, TRUE, block->frame, - block->space, block->offset); + block->space, block->offset); } if (!recv_no_ibuf_operations) { - ibuf_merge_or_delete_for_page(block->frame, - block->space, block->offset, TRUE); + ibuf_merge_or_delete_for_page + (block->frame, block->space, + block->offset, TRUE); } } @@ -2058,25 +2098,25 @@ buf_validate(void) if (block->state == BUF_BLOCK_FILE_PAGE) { ut_a(buf_page_hash_get(block->space, - block->offset) == block); + block->offset) == block); n_page++; #ifdef UNIV_IBUF_DEBUG ut_a((block->io_fix == BUF_IO_READ) - || ibuf_count_get(block->space, block->offset) - == 0); + || ibuf_count_get(block->space, block->offset) + == 0); #endif if (block->io_fix == BUF_IO_WRITE) { if (block->flush_type == BUF_FLUSH_LRU) { n_lru_flush++; - ut_a(rw_lock_is_locked(&(block->lock), - RW_LOCK_SHARED)); - } else if (block->flush_type == - BUF_FLUSH_LIST) { + ut_a(rw_lock_is_locked + (&block->lock, RW_LOCK_SHARED)); + } else if (block->flush_type + == BUF_FLUSH_LIST) { n_list_flush++; - } else if (block->flush_type == - BUF_FLUSH_SINGLE_PAGE) { + } else if (block->flush_type + == BUF_FLUSH_SINGLE_PAGE) { n_single_flush++; } else { ut_error; @@ -2085,14 +2125,14 @@ buf_validate(void) } else if (block->io_fix == BUF_IO_READ) { ut_a(rw_lock_is_locked(&(block->lock), - RW_LOCK_EX)); + RW_LOCK_EX)); } n_lru++; if (ut_dulint_cmp(block->oldest_modification, - ut_dulint_zero) > 0) { - n_flush++; + ut_dulint_zero) > 0) { + n_flush++; } } else if (block->state == BUF_BLOCK_NOT_USED) { @@ -2101,14 +2141,16 @@ buf_validate(void) } if (n_lru + n_free > buf_pool->curr_size) { - fprintf(stderr, "n LRU %lu, n free %lu\n", (ulong) n_lru, (ulong) n_free); + fprintf(stderr, "n LRU %lu, n free %lu\n", + (ulong) n_lru, (ulong) n_free); ut_error; } ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru); if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { fprintf(stderr, "Free list len %lu, free blocks %lu\n", - (ulong) UT_LIST_GET_LEN(buf_pool->free), (ulong) n_free); + (ulong) UT_LIST_GET_LEN(buf_pool->free), + (ulong) n_free); ut_error; } ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush); @@ -2233,9 +2275,9 @@ Returns the number of latched pages in the buffer pool. */ ulint buf_get_latched_pages_number(void) { - buf_block_t* block; - ulint i; - ulint fixed_pages_number = 0; + buf_block_t* block; + ulint i; + ulint fixed_pages_number = 0; mutex_enter(&(buf_pool->mutex)); @@ -2243,9 +2285,10 @@ buf_get_latched_pages_number(void) block = buf_pool_get_nth_block(buf_pool, i); - if (((block->buf_fix_count != 0) || (block->io_fix != 0)) && - block->magic_n == BUF_BLOCK_MAGIC_N ) + if (((block->buf_fix_count != 0) || (block->io_fix != 0)) + && block->magic_n == BUF_BLOCK_MAGIC_N) { fixed_pages_number++; + } } mutex_exit(&(buf_pool->mutex)); @@ -2261,9 +2304,9 @@ buf_get_n_pending_ios(void) /*=======================*/ { return(buf_pool->n_pend_reads - + buf_pool->n_flush[BUF_FLUSH_LRU] - + buf_pool->n_flush[BUF_FLUSH_LIST] - + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); + + buf_pool->n_flush[BUF_FLUSH_LRU] + + buf_pool->n_flush[BUF_FLUSH_LIST] + + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); } /************************************************************************* @@ -2280,7 +2323,7 @@ buf_get_modified_ratio_pct(void) ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list)) / (1 + UT_LIST_GET_LEN(buf_pool->LRU) - + UT_LIST_GET_LEN(buf_pool->free)); + + UT_LIST_GET_LEN(buf_pool->free)); /* 1 + is there to avoid division by zero */ @@ -2308,12 +2351,14 @@ buf_print_io( if (srv_use_awe) { fprintf(stderr, - "AWE: Buffer pool memory frames %lu\n", - (ulong) buf_pool->n_frames); + "AWE: Buffer pool memory frames %lu\n", + (ulong) buf_pool->n_frames); fprintf(stderr, - "AWE: Database pages and free buffers mapped in frames %lu\n", - (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped)); + "AWE: Database pages and free buffers" + " mapped in frames %lu\n", + (ulong) + UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped)); } fprintf(file, "Buffer pool size %lu\n" @@ -2328,14 +2373,14 @@ buf_print_io( (ulong) UT_LIST_GET_LEN(buf_pool->flush_list), (ulong) buf_pool->n_pend_reads, (ulong) buf_pool->n_flush[BUF_FLUSH_LRU] - + buf_pool->init_flush[BUF_FLUSH_LRU], + + buf_pool->init_flush[BUF_FLUSH_LRU], (ulong) buf_pool->n_flush[BUF_FLUSH_LIST] - + buf_pool->init_flush[BUF_FLUSH_LIST], + + buf_pool->init_flush[BUF_FLUSH_LIST], (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); current_time = time(NULL); time_elapsed = 0.001 + difftime(current_time, - buf_pool->last_printout_time); + buf_pool->last_printout_time); buf_pool->last_printout_time = current_time; fprintf(file, @@ -2353,19 +2398,21 @@ buf_print_io( if (srv_use_awe) { fprintf(file, "AWE: %.2f page remaps/s\n", - (buf_pool->n_pages_awe_remapped - - buf_pool->n_pages_awe_remapped_old) + (buf_pool->n_pages_awe_remapped + - buf_pool->n_pages_awe_remapped_old) / time_elapsed); } if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) { fprintf(file, "Buffer pool hit rate %lu / 1000\n", - (ulong) (1000 - - ((1000 * (buf_pool->n_pages_read - buf_pool->n_pages_read_old)) - / (buf_pool->n_page_gets - buf_pool->n_page_gets_old)))); + (ulong) + (1000 - ((1000 * (buf_pool->n_pages_read + - buf_pool->n_pages_read_old)) + / (buf_pool->n_page_gets + - buf_pool->n_page_gets_old)))); } else { fputs("No buffer pool page gets since the last printout\n", - file); + file); } buf_pool->n_page_gets_old = buf_pool->n_page_gets; @@ -2416,7 +2463,8 @@ buf_all_freed(void) fprintf(stderr, "Page %lu %lu still fixed or dirty\n", - (ulong) block->space, (ulong) block->offset); + (ulong) block->space, + (ulong) block->offset); ut_error; } } @@ -2441,8 +2489,8 @@ buf_pool_check_no_pending_io(void) mutex_enter(&(buf_pool->mutex)); if (buf_pool->n_pend_reads + buf_pool->n_flush[BUF_FLUSH_LRU] - + buf_pool->n_flush[BUF_FLUSH_LIST] - + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]) { + + buf_pool->n_flush[BUF_FLUSH_LIST] + + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]) { ret = FALSE; } else { ret = TRUE; diff --git a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c index 9bfbeb1b456..9274b67a555 100644 --- a/storage/innobase/buf/buf0flu.c +++ b/storage/innobase/buf/buf0flu.c @@ -55,10 +55,9 @@ buf_flush_insert_into_flush_list( ut_a(block->state == BUF_BLOCK_FILE_PAGE); ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL) - || (ut_dulint_cmp( - (UT_LIST_GET_FIRST(buf_pool->flush_list)) - ->oldest_modification, - block->oldest_modification) <= 0)); + || (ut_dulint_cmp((UT_LIST_GET_FIRST(buf_pool->flush_list)) + ->oldest_modification, + block->oldest_modification) <= 0)); UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block); @@ -86,7 +85,7 @@ buf_flush_insert_sorted_into_flush_list( b = UT_LIST_GET_FIRST(buf_pool->flush_list); while (b && (ut_dulint_cmp(b->oldest_modification, - block->oldest_modification) > 0)) { + block->oldest_modification) > 0)) { prev_b = b; b = UT_LIST_GET_NEXT(flush_list, b); } @@ -95,7 +94,7 @@ buf_flush_insert_sorted_into_flush_list( UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block); } else { UT_LIST_INSERT_AFTER(flush_list, buf_pool->flush_list, prev_b, - block); + block); } ut_ad(buf_flush_validate_low()); @@ -118,7 +117,8 @@ buf_flush_ready_for_replace( if (block->state != BUF_BLOCK_FILE_PAGE) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: buffer block state %lu in the LRU list!\n", + " InnoDB: Error: buffer block state %lu" + " in the LRU list!\n", (ulong)block->state); ut_print_buf(stderr, block, sizeof(buf_block_t)); @@ -126,8 +126,8 @@ buf_flush_ready_for_replace( } if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0) - || (block->buf_fix_count != 0) - || (block->io_fix != 0)) { + || (block->buf_fix_count != 0) + || (block->io_fix != 0)) { return(FALSE); } @@ -152,7 +152,7 @@ buf_flush_ready_for_flush( ut_a(block->state == BUF_BLOCK_FILE_PAGE); if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0) - && (block->io_fix == 0)) { + && (block->io_fix == 0)) { if (flush_type != BUF_FLUSH_LRU) { return(TRUE); @@ -202,10 +202,10 @@ buf_flush_write_complete( } /* fprintf(stderr, "n pending flush %lu\n", - buf_pool->n_flush[block->flush_type]); */ + buf_pool->n_flush[block->flush_type]); */ if ((buf_pool->n_flush[block->flush_type] == 0) - && (buf_pool->init_flush[block->flush_type] == FALSE)) { + && (buf_pool->init_flush[block->flush_type] == FALSE)) { /* The running flush batch has ended */ @@ -255,27 +255,33 @@ buf_flush_buffered_writes(void) ut_a(block->state == BUF_BLOCK_FILE_PAGE); if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4) - != mach_read_from_4(block->frame + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { - ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: ERROR: The page to be written seems corrupt!\n" -"InnoDB: The lsn fields do not match! Noticed in the buffer pool\n" -"InnoDB: before posting to the doublewrite buffer.\n"); + != mach_read_from_4(block->frame + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: ERROR: The page to be written" + " seems corrupt!\n" + "InnoDB: The lsn fields do not match!" + " Noticed in the buffer pool\n" + "InnoDB: before posting to the" + " doublewrite buffer.\n"); } if (block->check_index_page_at_flush - && !page_simple_validate(block->frame)) { + && !page_simple_validate(block->frame)) { buf_page_print(block->frame); ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Apparent corruption of an index page n:o %lu in space %lu\n" - "InnoDB: to be written to data file. We intentionally crash server\n" - "InnoDB: to prevent corrupt data from ending up in data\n" - "InnoDB: files.\n", - (ulong) block->offset, (ulong) block->space); + " InnoDB: Apparent corruption of an" + " index page n:o %lu in space %lu\n" + "InnoDB: to be written to data file." + " We intentionally crash server\n" + "InnoDB: to prevent corrupt data" + " from ending up in data\n" + "InnoDB: files.\n", + (ulong) block->offset, (ulong) block->space); ut_error; } @@ -292,47 +298,54 @@ buf_flush_buffered_writes(void) } fil_io(OS_FILE_WRITE, - TRUE, TRX_SYS_SPACE, - trx_doublewrite->block1, 0, len, - (void*)trx_doublewrite->write_buf, NULL); + TRUE, TRX_SYS_SPACE, + trx_doublewrite->block1, 0, len, + (void*)trx_doublewrite->write_buf, NULL); write_buf = trx_doublewrite->write_buf; for (len2 = 0; len2 + UNIV_PAGE_SIZE <= len; len2 += UNIV_PAGE_SIZE) { if (mach_read_from_4(write_buf + len2 + FIL_PAGE_LSN + 4) - != mach_read_from_4(write_buf + len2 + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + != mach_read_from_4(write_buf + len2 + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: ERROR: The page to be written seems corrupt!\n" -"InnoDB: The lsn fields do not match! Noticed in the doublewrite block1.\n"); + " InnoDB: ERROR: The page to be written" + " seems corrupt!\n" + "InnoDB: The lsn fields do not match!" + " Noticed in the doublewrite block1.\n"); } } if (trx_doublewrite->first_free > TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { len = (trx_doublewrite->first_free - - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) * UNIV_PAGE_SIZE; + - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) * UNIV_PAGE_SIZE; fil_io(OS_FILE_WRITE, - TRUE, TRX_SYS_SPACE, - trx_doublewrite->block2, 0, len, - (void*)(trx_doublewrite->write_buf - + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE), - NULL); + TRUE, TRX_SYS_SPACE, + trx_doublewrite->block2, 0, len, + (void*)(trx_doublewrite->write_buf + + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE + * UNIV_PAGE_SIZE), + NULL); write_buf = trx_doublewrite->write_buf - + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE; + + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE; for (len2 = 0; len2 + UNIV_PAGE_SIZE <= len; - len2 += UNIV_PAGE_SIZE) { + len2 += UNIV_PAGE_SIZE) { if (mach_read_from_4(write_buf + len2 - + FIL_PAGE_LSN + 4) - != mach_read_from_4(write_buf + len2 - + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + + FIL_PAGE_LSN + 4) + != mach_read_from_4(write_buf + len2 + + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + + 4)) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: ERROR: The page to be written seems corrupt!\n" -"InnoDB: The lsn fields do not match! Noticed in the doublewrite block2.\n"); + " InnoDB: ERROR: The page to be" + " written seems corrupt!\n" + "InnoDB: The lsn fields do not match!" + " Noticed in" + " the doublewrite block2.\n"); } } } @@ -349,14 +362,18 @@ buf_flush_buffered_writes(void) block = trx_doublewrite->buf_block_arr[i]; if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4) - != mach_read_from_4(block->frame + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + != mach_read_from_4(block->frame + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: ERROR: The page to be written seems corrupt!\n" -"InnoDB: The lsn fields do not match! Noticed in the buffer pool\n" -"InnoDB: after posting and flushing the doublewrite buffer.\n" -"InnoDB: Page buf fix count %lu, io fix %lu, state %lu\n", + " InnoDB: ERROR: The page to be written" + " seems corrupt!\n" + "InnoDB: The lsn fields do not match!" + " Noticed in the buffer pool\n" + "InnoDB: after posting and flushing" + " the doublewrite buffer.\n" + "InnoDB: Page buf fix count %lu," + " io fix %lu, state %lu\n", (ulong)block->buf_fix_count, (ulong)block->io_fix, (ulong)block->state); @@ -364,8 +381,8 @@ buf_flush_buffered_writes(void) ut_a(block->state == BUF_BLOCK_FILE_PAGE); fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, - FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE, - (void*)block->frame, (void*)block); + FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE, + (void*)block->frame, (void*)block); } /* Wake possible simulated aio thread to actually post the @@ -405,7 +422,7 @@ try_again: ut_a(block->state == BUF_BLOCK_FILE_PAGE); if (trx_doublewrite->first_free - >= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { + >= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { mutex_exit(&(trx_doublewrite->mutex)); buf_flush_buffered_writes(); @@ -414,15 +431,15 @@ try_again: } ut_memcpy(trx_doublewrite->write_buf - + UNIV_PAGE_SIZE * trx_doublewrite->first_free, - block->frame, UNIV_PAGE_SIZE); + + UNIV_PAGE_SIZE * trx_doublewrite->first_free, + block->frame, UNIV_PAGE_SIZE); trx_doublewrite->buf_block_arr[trx_doublewrite->first_free] = block; trx_doublewrite->first_free++; if (trx_doublewrite->first_free - >= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { + >= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { mutex_exit(&(trx_doublewrite->mutex)); buf_flush_buffered_writes(); @@ -448,7 +465,7 @@ buf_flush_init_for_writing( mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn); mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, - newest_lsn); + newest_lsn); /* Write the page number and the space id */ mach_write_to_4(page + FIL_PAGE_OFFSET, page_no); @@ -457,8 +474,9 @@ buf_flush_init_for_writing( /* Store the new formula checksum */ mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, - srv_use_checksums ? - buf_calc_page_new_checksum(page) : BUF_NO_CHECKSUM_MAGIC); + srv_use_checksums + ? buf_calc_page_new_checksum(page) + : BUF_NO_CHECKSUM_MAGIC); /* We overwrite the first 4 bytes of the end lsn field to store the old formula checksum. Since it depends also on the field @@ -466,8 +484,9 @@ buf_flush_init_for_writing( new formula checksum. */ mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, - srv_use_checksums ? - buf_calc_page_old_checksum(page) : BUF_NO_CHECKSUM_MAGIC); + srv_use_checksums + ? buf_calc_page_old_checksum(page) + : BUF_NO_CHECKSUM_MAGIC); } /************************************************************************ @@ -493,21 +512,21 @@ buf_flush_write_block_low( #ifdef UNIV_LOG_DEBUG if (!univ_log_debug_warned) { univ_log_debug_warned = TRUE; - fputs( - "Warning: cannot force log to disk if UNIV_LOG_DEBUG is defined!\n" - "Crash recovery will not work!\n", - stderr); + fputs("Warning: cannot force log to disk if" + " UNIV_LOG_DEBUG is defined!\n" + "Crash recovery will not work!\n", + stderr); } #else /* Force the log to the disk before writing the modified block */ log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE); #endif buf_flush_init_for_writing(block->frame, block->newest_modification, - block->space, block->offset); + block->space, block->offset); if (!srv_use_doublewrite_buf || !trx_doublewrite) { fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, - FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE, - (void*)block->frame, (void*)block); + FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE, + (void*)block->frame, (void*)block); } else { buf_flush_post_to_doublewrite_buf(block); } @@ -532,7 +551,7 @@ buf_flush_try_page( ibool locked; ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST - || flush_type == BUF_FLUSH_SINGLE_PAGE); + || flush_type == BUF_FLUSH_SINGLE_PAGE); mutex_enter(&(buf_pool->mutex)); @@ -541,7 +560,7 @@ buf_flush_try_page( ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE); if (flush_type == BUF_FLUSH_LIST - && block && buf_flush_ready_for_flush(block, flush_type)) { + && block && buf_flush_ready_for_flush(block, flush_type)) { block->io_fix = BUF_IO_WRITE; @@ -600,7 +619,7 @@ buf_flush_try_page( return(1); } else if (flush_type == BUF_FLUSH_LRU && block - && buf_flush_ready_for_flush(block, flush_type)) { + && buf_flush_ready_for_flush(block, flush_type)) { /* VERY IMPORTANT: Because any thread may call the LRU flush, even when owning @@ -647,7 +666,7 @@ buf_flush_try_page( return(1); } else if (flush_type == BUF_FLUSH_SINGLE_PAGE && block - && buf_flush_ready_for_flush(block, flush_type)) { + && buf_flush_ready_for_flush(block, flush_type)) { block->io_fix = BUF_IO_WRITE; @@ -680,9 +699,10 @@ buf_flush_try_page( #ifdef UNIV_DEBUG if (buf_debug_prints) { fprintf(stderr, - "Flushing single page space %lu, page no %lu \n", - (ulong) block->space, - (ulong) block->offset); + "Flushing single page space %lu," + " page no %lu \n", + (ulong) block->space, + (ulong) block->offset); } #endif /* UNIV_DEBUG */ @@ -739,7 +759,7 @@ buf_flush_try_neighbors( ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE); if (block && flush_type == BUF_FLUSH_LRU && i != offset - && !block->old) { + && !block->old) { /* We avoid flushing 'non-old' blocks in an LRU flush, because the flushed blocks are soon freed */ @@ -748,7 +768,7 @@ buf_flush_try_neighbors( } if (block && buf_flush_ready_for_flush(block, flush_type) - && (i == offset || block->buf_fix_count == 0)) { + && (i == offset || block->buf_fix_count == 0)) { /* We only try to flush those neighbors != offset where the buf fix count is zero, as we then know that we probably can latch the page without a semaphore @@ -806,13 +826,13 @@ buf_flush_batch( ibool found; ut_ad((flush_type == BUF_FLUSH_LRU) - || (flush_type == BUF_FLUSH_LIST)); + || (flush_type == BUF_FLUSH_LIST)); ut_ad((flush_type != BUF_FLUSH_LIST) - || sync_thread_levels_empty_gen(TRUE)); + || sync_thread_levels_empty_gen(TRUE)); mutex_enter(&(buf_pool->mutex)); if ((buf_pool->n_flush[flush_type] > 0) - || (buf_pool->init_flush[flush_type] == TRUE)) { + || (buf_pool->init_flush[flush_type] == TRUE)) { /* There is already a flush batch of the same type running */ @@ -840,8 +860,8 @@ buf_flush_batch( block = UT_LIST_GET_LAST(buf_pool->flush_list); if (!block - || (ut_dulint_cmp(block->oldest_modification, - lsn_limit) >= 0)) { + || (ut_dulint_cmp(block->oldest_modification, + lsn_limit) >= 0)) { /* We have flushed enough */ break; @@ -870,9 +890,8 @@ buf_flush_batch( old_page_count = page_count; /* Try to flush also all the neighbors */ - page_count += - buf_flush_try_neighbors(space, offset, - flush_type); + page_count += buf_flush_try_neighbors + (space, offset, flush_type); /* fprintf(stderr, "Flush type %lu, page no %lu, neighb %lu\n", flush_type, offset, @@ -900,7 +919,7 @@ buf_flush_batch( (buf_pool->init_flush)[flush_type] = FALSE; if ((buf_pool->n_flush[flush_type] == 0) - && (buf_pool->init_flush[flush_type] == FALSE)) { + && (buf_pool->init_flush[flush_type] == FALSE)) { /* The running flush batch has ended */ @@ -914,7 +933,7 @@ buf_flush_batch( #ifdef UNIV_DEBUG if (buf_debug_prints && page_count > 0) { ut_a(flush_type == BUF_FLUSH_LRU - || flush_type == BUF_FLUSH_LIST); + || flush_type == BUF_FLUSH_LIST); fprintf(stderr, flush_type == BUF_FLUSH_LRU ? "Flushed %lu pages in LRU flush\n" : "Flushed %lu pages in flush list flush\n", @@ -923,7 +942,7 @@ buf_flush_batch( #endif /* UNIV_DEBUG */ if (page_count != ULINT_UNDEFINED) - srv_buf_pool_flushed+= page_count; + srv_buf_pool_flushed+= page_count; return(page_count); } @@ -963,9 +982,9 @@ buf_flush_LRU_recommendation(void) block = UT_LIST_GET_LAST(buf_pool->LRU); while ((block != NULL) - && (n_replaceable < BUF_FLUSH_FREE_BLOCK_MARGIN - + BUF_FLUSH_EXTRA_MARGIN) - && (distance < BUF_LRU_FREE_SEARCH_LEN)) { + && (n_replaceable < BUF_FLUSH_FREE_BLOCK_MARGIN + + BUF_FLUSH_EXTRA_MARGIN) + && (distance < BUF_LRU_FREE_SEARCH_LEN)) { if (buf_flush_ready_for_replace(block)) { n_replaceable++; @@ -984,7 +1003,7 @@ buf_flush_LRU_recommendation(void) } return(BUF_FLUSH_FREE_BLOCK_MARGIN + BUF_FLUSH_EXTRA_MARGIN - - n_replaceable); + - n_replaceable); } /************************************************************************* @@ -1005,7 +1024,7 @@ buf_flush_free_margin(void) if (n_to_flush > 0) { n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush, - ut_dulint_zero); + ut_dulint_zero); if (n_flushed == ULINT_UNDEFINED) { /* There was an LRU type flush batch already running; let us wait for it to end */ @@ -1039,7 +1058,7 @@ buf_flush_validate_low(void) if (block) { ut_a(ut_dulint_cmp(om, block->oldest_modification) - >= 0); + >= 0); } } diff --git a/storage/innobase/buf/buf0lru.c b/storage/innobase/buf/buf0lru.c index 08be5811a4b..f0264f2e323 100644 --- a/storage/innobase/buf/buf0lru.c +++ b/storage/innobase/buf/buf0lru.c @@ -89,7 +89,7 @@ scan_again: ut_a(block->state == BUF_BLOCK_FILE_PAGE); if (block->space == id - && (block->buf_fix_count > 0 || block->io_fix != 0)) { + && (block->buf_fix_count > 0 || block->io_fix != 0)) { /* We cannot remove this page during this scan yet; maybe the system is currently reading it in, or @@ -103,8 +103,8 @@ scan_again: if (block->space == id) { #ifdef UNIV_DEBUG if (buf_debug_prints) { - printf( - "Dropping space %lu page %lu\n", + fprintf(stderr, + "Dropping space %lu page %lu\n", (ulong) block->space, (ulong) block->offset); } @@ -118,19 +118,19 @@ scan_again: an S-latch on the page */ btr_search_drop_page_hash_when_freed(id, - page_no); + page_no); goto scan_again; } if (0 != ut_dulint_cmp(block->oldest_modification, - ut_dulint_zero)) { + ut_dulint_zero)) { /* Remove from the flush list of modified blocks */ block->oldest_modification = ut_dulint_zero; UT_LIST_REMOVE(flush_list, - buf_pool->flush_list, block); + buf_pool->flush_list, block); } /* Remove from the LRU list */ @@ -216,7 +216,8 @@ buf_LRU_search_and_free_block( #ifdef UNIV_DEBUG if (buf_debug_prints) { fprintf(stderr, - "Putting space %lu page %lu to free list\n", + "Putting space %lu page %lu" + " to free list\n", (ulong) block->space, (ulong) block->offset); } @@ -246,8 +247,8 @@ buf_LRU_search_and_free_block( distance++; if (!freed && n_iterations <= 10 - && distance > 100 + (n_iterations * buf_pool->curr_size) - / 10) { + && distance > 100 + (n_iterations * buf_pool->curr_size) + / 10) { buf_pool->LRU_flush_ended = 0; mutex_exit(&(buf_pool->mutex)); @@ -309,7 +310,7 @@ buf_LRU_buf_pool_running_out(void) mutex_enter(&(buf_pool->mutex)); if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) - + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) { + + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) { ret = TRUE; } @@ -340,23 +341,28 @@ loop: mutex_enter(&(buf_pool->mutex)); if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) - + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) { + + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: ERROR: over 95 percent of the buffer pool is occupied by\n" -"InnoDB: lock heaps or the adaptive hash index! Check that your\n" -"InnoDB: transactions do not set too many row locks.\n" -"InnoDB: Your buffer pool size is %lu MB. Maybe you should make\n" -"InnoDB: the buffer pool bigger?\n" -"InnoDB: We intentionally generate a seg fault to print a stack trace\n" -"InnoDB: on Linux!\n", - (ulong)(buf_pool->curr_size / (1024 * 1024 / UNIV_PAGE_SIZE))); + " InnoDB: ERROR: over 95 percent of the buffer pool" + " is occupied by\n" + "InnoDB: lock heaps or the adaptive hash index!" + " Check that your\n" + "InnoDB: transactions do not set too many row locks.\n" + "InnoDB: Your buffer pool size is %lu MB." + " Maybe you should make\n" + "InnoDB: the buffer pool bigger?\n" + "InnoDB: We intentionally generate a seg fault" + " to print a stack trace\n" + "InnoDB: on Linux!\n", + (ulong) (buf_pool->curr_size + / (1024 * 1024 / UNIV_PAGE_SIZE))); ut_error; } else if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) - + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 3) { + + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 3) { if (!buf_lru_switched_on_innodb_mon) { @@ -366,14 +372,20 @@ loop: ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: WARNING: over 67 percent of the buffer pool is occupied by\n" -"InnoDB: lock heaps or the adaptive hash index! Check that your\n" -"InnoDB: transactions do not set too many row locks.\n" -"InnoDB: Your buffer pool size is %lu MB. Maybe you should make\n" -"InnoDB: the buffer pool bigger?\n" -"InnoDB: Starting the InnoDB Monitor to print diagnostics, including\n" -"InnoDB: lock heap and hash index sizes.\n", - (ulong) (buf_pool->curr_size / (1024 * 1024 / UNIV_PAGE_SIZE))); + " InnoDB: WARNING: over 67 percent of" + " the buffer pool is occupied by\n" + "InnoDB: lock heaps or the adaptive" + " hash index! Check that your\n" + "InnoDB: transactions do not set too many" + " row locks.\n" + "InnoDB: Your buffer pool size is %lu MB." + " Maybe you should make\n" + "InnoDB: the buffer pool bigger?\n" + "InnoDB: Starting the InnoDB Monitor to print" + " diagnostics, including\n" + "InnoDB: lock heap and hash index sizes.\n", + (ulong) (buf_pool->curr_size + / (1024 * 1024 / UNIV_PAGE_SIZE))); buf_lru_switched_on_innodb_mon = TRUE; srv_print_innodb_monitor = TRUE; @@ -405,7 +417,8 @@ loop: /* Remove from the list of mapped pages */ UT_LIST_REMOVE(awe_LRU_free_mapped, - buf_pool->awe_LRU_free_mapped, block); + buf_pool->awe_LRU_free_mapped, + block); } else { /* We map the page to a frame; second param FALSE below because we do not want it to be @@ -440,18 +453,25 @@ loop: if (n_iterations > 30) { ut_print_timestamp(stderr); fprintf(stderr, - "InnoDB: Warning: difficult to find free blocks from\n" - "InnoDB: the buffer pool (%lu search iterations)! Consider\n" - "InnoDB: increasing the buffer pool size.\n" - "InnoDB: It is also possible that in your Unix version\n" - "InnoDB: fsync is very slow, or completely frozen inside\n" - "InnoDB: the OS kernel. Then upgrading to a newer version\n" - "InnoDB: of your operating system may help. Look at the\n" - "InnoDB: number of fsyncs in diagnostic info below.\n" - "InnoDB: Pending flushes (fsync) log: %lu; buffer pool: %lu\n" - "InnoDB: %lu OS file reads, %lu OS file writes, %lu OS fsyncs\n" - "InnoDB: Starting InnoDB Monitor to print further\n" - "InnoDB: diagnostics to the standard output.\n", + "InnoDB: Warning: difficult to find free blocks from\n" + "InnoDB: the buffer pool (%lu search iterations)!" + " Consider\n" + "InnoDB: increasing the buffer pool size.\n" + "InnoDB: It is also possible that" + " in your Unix version\n" + "InnoDB: fsync is very slow, or" + " completely frozen inside\n" + "InnoDB: the OS kernel. Then upgrading to" + " a newer version\n" + "InnoDB: of your operating system may help." + " Look at the\n" + "InnoDB: number of fsyncs in diagnostic info below.\n" + "InnoDB: Pending flushes (fsync) log: %lu;" + " buffer pool: %lu\n" + "InnoDB: %lu OS file reads, %lu OS file writes," + " %lu OS fsyncs\n" + "InnoDB: Starting InnoDB Monitor to print further\n" + "InnoDB: diagnostics to the standard output.\n", (ulong) n_iterations, (ulong) fil_n_pending_log_flushes, (ulong) fil_n_pending_tablespace_flushes, @@ -522,20 +542,20 @@ buf_LRU_old_adjust_len(void) if (old_len < new_len - BUF_LRU_OLD_TOLERANCE) { - buf_pool->LRU_old = UT_LIST_GET_PREV(LRU, - buf_pool->LRU_old); + buf_pool->LRU_old = UT_LIST_GET_PREV + (LRU, buf_pool->LRU_old); (buf_pool->LRU_old)->old = TRUE; buf_pool->LRU_old_len++; } else if (old_len > new_len + BUF_LRU_OLD_TOLERANCE) { (buf_pool->LRU_old)->old = FALSE; - buf_pool->LRU_old = UT_LIST_GET_NEXT(LRU, - buf_pool->LRU_old); + buf_pool->LRU_old = UT_LIST_GET_NEXT + (LRU, buf_pool->LRU_old); buf_pool->LRU_old_len--; } else { ut_a(buf_pool->LRU_old); /* Check that we did not - fall out of the LRU list */ + fall out of the LRU list */ return; } } @@ -613,7 +633,7 @@ buf_LRU_remove_block( /* Remove from the list of mapped pages */ UT_LIST_REMOVE(awe_LRU_free_mapped, - buf_pool->awe_LRU_free_mapped, block); + buf_pool->awe_LRU_free_mapped, block); } /* If the LRU list is so short that LRU_old not defined, return */ @@ -672,7 +692,7 @@ buf_LRU_add_block_to_end_low( /* Add to the list of mapped pages */ UT_LIST_ADD_LAST(awe_LRU_free_mapped, - buf_pool->awe_LRU_free_mapped, block); + buf_pool->awe_LRU_free_mapped, block); } if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) { @@ -729,7 +749,7 @@ buf_LRU_add_block_low( TRUE */ UT_LIST_ADD_FIRST(awe_LRU_free_mapped, - buf_pool->awe_LRU_free_mapped, block); + buf_pool->awe_LRU_free_mapped, block); } if (!old || (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN)) { @@ -740,7 +760,7 @@ buf_LRU_add_block_low( block->freed_page_clock = buf_pool->freed_page_clock; } else { UT_LIST_INSERT_AFTER(LRU, buf_pool->LRU, buf_pool->LRU_old, - block); + block); buf_pool->LRU_old_len++; /* We copy the LRU position field of the previous block @@ -822,7 +842,7 @@ buf_LRU_block_free_non_file_page( ut_ad(block); ut_a((block->state == BUF_BLOCK_MEMORY) - || (block->state == BUF_BLOCK_READY_FOR_USE)); + || (block->state == BUF_BLOCK_READY_FOR_USE)); ut_a(block->n_pointers == 0); ut_a(!block->in_free_list); @@ -840,7 +860,7 @@ buf_LRU_block_free_non_file_page( /* Add to the list of mapped pages */ UT_LIST_ADD_FIRST(awe_LRU_free_mapped, - buf_pool->awe_LRU_free_mapped, block); + buf_pool->awe_LRU_free_mapped, block); } } @@ -875,16 +895,21 @@ buf_LRU_block_remove_hashed_page( if (block != buf_page_hash_get(block->space, block->offset)) { fprintf(stderr, -"InnoDB: Error: page %lu %lu not found from the hash table\n", + "InnoDB: Error: page %lu %lu not found" + " in the hash table\n", (ulong) block->space, (ulong) block->offset); if (buf_page_hash_get(block->space, block->offset)) { fprintf(stderr, -"InnoDB: From hash table we find block %p of %lu %lu which is not %p\n", - (void*) buf_page_hash_get(block->space, block->offset), - (ulong) buf_page_hash_get(block->space, block->offset)->space, - (ulong) buf_page_hash_get(block->space, block->offset)->offset, - (void*) block); + "InnoDB: In hash table we find block" + " %p of %lu %lu which is not %p\n", + (void*) buf_page_hash_get + (block->space, block->offset), + (ulong) buf_page_hash_get + (block->space, block->offset)->space, + (ulong) buf_page_hash_get + (block->space, block->offset)->offset, + (void*) block); } #ifdef UNIV_DEBUG @@ -897,8 +922,8 @@ buf_LRU_block_remove_hashed_page( } HASH_DELETE(buf_block_t, hash, buf_pool->page_hash, - buf_page_address_fold(block->space, block->offset), - block); + buf_page_address_fold(block->space, block->offset), + block); block->state = BUF_BLOCK_REMOVE_HASH; } @@ -1009,7 +1034,8 @@ buf_LRU_print(void) ut_ad(buf_pool); mutex_enter(&(buf_pool->mutex)); - fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock); + fprintf(stderr, "Pool ulint clock %lu\n", + (ulong) buf_pool->ulint_clock); block = UT_LIST_GET_FIRST(buf_pool->LRU); @@ -1033,7 +1059,7 @@ buf_LRU_print(void) } if (ut_dulint_cmp(block->oldest_modification, - ut_dulint_zero) > 0) { + ut_dulint_zero) > 0) { fputs("modif. ", stderr); } @@ -1042,7 +1068,8 @@ buf_LRU_print(void) fprintf(stderr, "LRU pos %lu type %lu index id %lu ", (ulong) block->LRU_position, (ulong) fil_page_get_type(frame), - (ulong) ut_dulint_get_low(btr_page_get_index_id(frame))); + (ulong) ut_dulint_get_low + (btr_page_get_index_id(frame))); block = UT_LIST_GET_NEXT(LRU, block); if (++len == 10) { diff --git a/storage/innobase/buf/buf0rea.c b/storage/innobase/buf/buf0rea.c index d9864aae360..cf7aa97191f 100644 --- a/storage/innobase/buf/buf0rea.c +++ b/storage/innobase/buf/buf0rea.c @@ -81,32 +81,21 @@ buf_read_page_low( mode = mode & ~OS_AIO_SIMULATED_WAKE_LATER; if (trx_doublewrite && space == TRX_SYS_SPACE - && ( (offset >= trx_doublewrite->block1 - && offset < trx_doublewrite->block1 - + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) - || (offset >= trx_doublewrite->block2 - && offset < trx_doublewrite->block2 - + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE))) { + && ( (offset >= trx_doublewrite->block1 + && offset < trx_doublewrite->block1 + + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) + || (offset >= trx_doublewrite->block2 + && offset < trx_doublewrite->block2 + + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE))) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Warning: trying to read doublewrite buffer page %lu\n", + " InnoDB: Warning: trying to read" + " doublewrite buffer page %lu\n", (ulong) offset); return(0); } -#ifdef UNIV_LOG_DEBUG - if (space % 2 == 1) { - /* We are updating a replicate space while holding the - log mutex: the read must be handled before other reads - which might incur ibuf operations and thus write to the log */ - - fputs("Log debug: reading replicate page in sync mode\n", - stderr); - - sync = TRUE; - } -#endif if (ibuf_bitmap_page(offset) || trx_sys_hdr_page(space, offset)) { /* Trx sys header is so low in the latching order that we play @@ -123,7 +112,7 @@ buf_read_page_low( pool for read, then DISCARD cannot proceed until the read has completed */ block = buf_page_init_for_read(err, mode, space, tablespace_version, - offset); + offset); if (block == NULL) { return(0); @@ -133,17 +122,17 @@ buf_read_page_low( if (buf_debug_prints) { fprintf(stderr, "Posting read request for page %lu, sync %lu\n", - (ulong) offset, - (ulong) sync); + (ulong) offset, + (ulong) sync); } #endif ut_a(block->state == BUF_BLOCK_FILE_PAGE); *err = fil_io(OS_FILE_READ | wake_later, - sync, space, - offset, 0, UNIV_PAGE_SIZE, - (void*)block->frame, (void*)block); + sync, space, + offset, 0, UNIV_PAGE_SIZE, + (void*)block->frame, (void*)block); ut_a(*err == DB_SUCCESS); if (sync) { @@ -208,9 +197,9 @@ buf_read_ahead_random( tablespace_version = fil_space_get_version(space); low = (offset / BUF_READ_AHEAD_RANDOM_AREA) - * BUF_READ_AHEAD_RANDOM_AREA; + * BUF_READ_AHEAD_RANDOM_AREA; high = (offset / BUF_READ_AHEAD_RANDOM_AREA + 1) - * BUF_READ_AHEAD_RANDOM_AREA; + * BUF_READ_AHEAD_RANDOM_AREA; if (high > fil_space_get_size(space)) { high = fil_space_get_size(space); @@ -224,8 +213,8 @@ buf_read_ahead_random( mutex_enter(&(buf_pool->mutex)); - if (buf_pool->n_pend_reads > - buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { + if (buf_pool->n_pend_reads + > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { mutex_exit(&(buf_pool->mutex)); return(0); @@ -238,8 +227,8 @@ buf_read_ahead_random( block = buf_page_hash_get(space, i); if ((block) - && (block->LRU_position > LRU_recent_limit) - && block->accessed) { + && (block->LRU_position > LRU_recent_limit) + && block->accessed) { recent_blocks++; } @@ -268,15 +257,18 @@ buf_read_ahead_random( mode: hence FALSE as the first parameter */ if (!ibuf_bitmap_page(i)) { - count += buf_read_page_low(&err, FALSE, ibuf_mode - | OS_AIO_SIMULATED_WAKE_LATER, - space, tablespace_version, i); + count += buf_read_page_low + (&err, FALSE, + ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER, + space, tablespace_version, i); if (err == DB_TABLESPACE_DELETED) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Warning: in random readahead trying to access tablespace\n" -"InnoDB: %lu page no. %lu,\n" -"InnoDB: but the tablespace does not exist or is just being dropped.\n", + " InnoDB: Warning: in random" + " readahead trying to access\n" + "InnoDB: tablespace %lu page %lu,\n" + "InnoDB: but the tablespace does not" + " exist or is just being dropped.\n", (ulong) space, (ulong) i); } } @@ -292,8 +284,8 @@ buf_read_ahead_random( if (buf_debug_prints && (count > 0)) { fprintf(stderr, "Random read-ahead space %lu offset %lu pages %lu\n", - (ulong) space, (ulong) offset, - (ulong) count); + (ulong) space, (ulong) offset, + (ulong) count); } #endif /* UNIV_DEBUG */ @@ -329,14 +321,16 @@ buf_read_page( switches: hence TRUE */ count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space, - tablespace_version, offset); + tablespace_version, offset); srv_buf_pool_reads+= count2; if (err == DB_TABLESPACE_DELETED) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: trying to access tablespace %lu page no. %lu,\n" -"InnoDB: but the tablespace does not exist or is just being dropped.\n", - (ulong) space, (ulong) offset); + " InnoDB: Error: trying to access" + " tablespace %lu page no. %lu,\n" + "InnoDB: but the tablespace does not exist" + " or is just being dropped.\n", + (ulong) space, (ulong) offset); } /* Flush pages from the end of the LRU list if necessary */ @@ -407,9 +401,9 @@ buf_read_ahead_linear( } low = (offset / BUF_READ_AHEAD_LINEAR_AREA) - * BUF_READ_AHEAD_LINEAR_AREA; + * BUF_READ_AHEAD_LINEAR_AREA; high = (offset / BUF_READ_AHEAD_LINEAR_AREA + 1) - * BUF_READ_AHEAD_LINEAR_AREA; + * BUF_READ_AHEAD_LINEAR_AREA; if ((offset != low) && (offset != high - 1)) { /* This is not a border page of the area: return */ @@ -432,8 +426,8 @@ buf_read_ahead_linear( return(0); } - if (buf_pool->n_pend_reads > - buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { + if (buf_pool->n_pend_reads + > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { mutex_exit(&(buf_pool->mutex)); return(0); @@ -459,9 +453,9 @@ buf_read_ahead_linear( fail_count++; } else if (pred_block - && (ut_ulint_cmp(block->LRU_position, - pred_block->LRU_position) - != asc_or_desc)) { + && (ut_ulint_cmp(block->LRU_position, + pred_block->LRU_position) + != asc_or_desc)) { /* Accesses not in the right order */ fail_count++; @@ -469,8 +463,8 @@ buf_read_ahead_linear( } } - if (fail_count > BUF_READ_AHEAD_LINEAR_AREA - - BUF_READ_AHEAD_LINEAR_THRESHOLD) { + if (fail_count > BUF_READ_AHEAD_LINEAR_AREA + - BUF_READ_AHEAD_LINEAR_THRESHOLD) { /* Too many failures: return */ mutex_exit(&(buf_pool->mutex)); @@ -518,9 +512,9 @@ buf_read_ahead_linear( } low = (new_offset / BUF_READ_AHEAD_LINEAR_AREA) - * BUF_READ_AHEAD_LINEAR_AREA; + * BUF_READ_AHEAD_LINEAR_AREA; high = (new_offset / BUF_READ_AHEAD_LINEAR_AREA + 1) - * BUF_READ_AHEAD_LINEAR_AREA; + * BUF_READ_AHEAD_LINEAR_AREA; if ((new_offset != low) && (new_offset != high - 1)) { /* This is not a border page of the area: return */ @@ -555,16 +549,19 @@ buf_read_ahead_linear( aio mode: hence FALSE as the first parameter */ if (!ibuf_bitmap_page(i)) { - count += buf_read_page_low(&err, FALSE, ibuf_mode - | OS_AIO_SIMULATED_WAKE_LATER, - space, tablespace_version, i); + count += buf_read_page_low + (&err, FALSE, + ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER, + space, tablespace_version, i); if (err == DB_TABLESPACE_DELETED) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Warning: in linear readahead trying to access tablespace\n" -"InnoDB: %lu page no. %lu,\n" -"InnoDB: but the tablespace does not exist or is just being dropped.\n", - (ulong) space, (ulong) i); + " InnoDB: Warning: in" + " linear readahead trying to access\n" + "InnoDB: tablespace %lu page %lu,\n" + "InnoDB: but the tablespace does not" + " exist or is just being dropped.\n", + (ulong) space, (ulong) i); } } } @@ -581,8 +578,8 @@ buf_read_ahead_linear( #ifdef UNIV_DEBUG if (buf_debug_prints && (count > 0)) { fprintf(stderr, - "LINEAR read-ahead space %lu offset %lu pages %lu\n", - (ulong) space, (ulong) offset, (ulong) count); + "LINEAR read-ahead space %lu offset %lu pages %lu\n", + (ulong) space, (ulong) offset, (ulong) count); } #endif /* UNIV_DEBUG */ @@ -618,26 +615,24 @@ buf_read_ibuf_merge_pages( #ifdef UNIV_IBUF_DEBUG ut_a(n_stored < UNIV_PAGE_SIZE); #endif - while (buf_pool->n_pend_reads > - buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { + while (buf_pool->n_pend_reads + > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { os_thread_sleep(500000); } for (i = 0; i < n_stored; i++) { - if ((i + 1 == n_stored) && sync) { - buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, - space_ids[i], space_versions[i], page_nos[i]); - } else { - buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE, - space_ids[i], space_versions[i], page_nos[i]); - } + buf_read_page_low(&err, + (i + 1 == n_stored) && sync, + BUF_READ_ANY_PAGE, + space_ids[i], space_versions[i], + page_nos[i]); if (err == DB_TABLESPACE_DELETED) { /* We have deleted or are deleting the single-table tablespace: remove the entries for that page */ ibuf_merge_or_delete_for_page(NULL, space_ids[i], - page_nos[i], FALSE); + page_nos[i], FALSE); } } @@ -650,7 +645,7 @@ buf_read_ibuf_merge_pages( if (buf_debug_prints) { fprintf(stderr, "Ibuf merge read-ahead space %lu pages %lu\n", - (ulong) space_ids[0], (ulong) n_stored); + (ulong) space_ids[0], (ulong) n_stored); } #endif /* UNIV_DEBUG */ } @@ -691,11 +686,14 @@ buf_read_recv_pages( if (count > 100) { fprintf(stderr, -"InnoDB: Error: InnoDB has waited for 50 seconds for pending\n" -"InnoDB: reads to the buffer pool to be finished.\n" -"InnoDB: Number of pending reads %lu, pending pread calls %lu\n", - (ulong) buf_pool->n_pend_reads, - (ulong)os_file_n_pending_preads); + "InnoDB: Error: InnoDB has waited for" + " 50 seconds for pending\n" + "InnoDB: reads to the buffer pool to" + " be finished.\n" + "InnoDB: Number of pending reads %lu," + " pending pread calls %lu\n", + (ulong) buf_pool->n_pend_reads, + (ulong)os_file_n_pending_preads); os_aio_print_debug = TRUE; } @@ -704,12 +702,14 @@ buf_read_recv_pages( os_aio_print_debug = FALSE; if ((i + 1 == n_stored) && sync) { - buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space, - tablespace_version, page_nos[i]); + buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, + space, tablespace_version, + page_nos[i]); } else { buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE - | OS_AIO_SIMULATED_WAKE_LATER, - space, tablespace_version, page_nos[i]); + | OS_AIO_SIMULATED_WAKE_LATER, + space, tablespace_version, + page_nos[i]); } } @@ -721,7 +721,8 @@ buf_read_recv_pages( #ifdef UNIV_DEBUG if (buf_debug_prints) { fprintf(stderr, - "Recovery applies read-ahead pages %lu\n", (ulong) n_stored); + "Recovery applies read-ahead pages %lu\n", + (ulong) n_stored); } #endif /* UNIV_DEBUG */ } diff --git a/storage/innobase/data/data0data.c b/storage/innobase/data/data0data.c index b2c8408e901..804d02e8f59 100644 --- a/storage/innobase/data/data0data.c +++ b/storage/innobase/data/data0data.c @@ -189,10 +189,10 @@ dfield_check_typed_no_assert( dfield_t* field) /* in: data field */ { if (dfield_get_type(field)->mtype > DATA_MYSQL - || dfield_get_type(field)->mtype < DATA_VARCHAR) { + || dfield_get_type(field)->mtype < DATA_VARCHAR) { fprintf(stderr, -"InnoDB: Error: data field type %lu, len %lu\n", + "InnoDB: Error: data field type %lu, len %lu\n", (ulong) dfield_get_type(field)->mtype, (ulong) dfield_get_len(field)); return(FALSE); @@ -215,9 +215,9 @@ dtuple_check_typed_no_assert( if (dtuple_get_n_fields(tuple) > REC_MAX_N_FIELDS) { fprintf(stderr, -"InnoDB: Error: index entry has %lu fields\n", + "InnoDB: Error: index entry has %lu fields\n", (ulong) dtuple_get_n_fields(tuple)); - dump: +dump: fputs("InnoDB: Tuple contents: ", stderr); dtuple_print(stderr, tuple); putc('\n', stderr); @@ -247,10 +247,10 @@ dfield_check_typed( dfield_t* field) /* in: data field */ { if (dfield_get_type(field)->mtype > DATA_MYSQL - || dfield_get_type(field)->mtype < DATA_VARCHAR) { + || dfield_get_type(field)->mtype < DATA_VARCHAR) { fprintf(stderr, -"InnoDB: Error: data field type %lu, len %lu\n", + "InnoDB: Error: data field type %lu, len %lu\n", (ulong) dfield_get_type(field)->mtype, (ulong) dfield_get_len(field)); @@ -319,8 +319,8 @@ dtuple_validate( for (j = 0; j < len; j++) { data_dummy += *data; /* fool the compiler not - to optimize out this - code */ + to optimize out this + code */ data++; } } @@ -433,15 +433,20 @@ dfield_print_also_hex( /***************************************************************** Print a dfield value using ut_print_buf. */ - +static void dfield_print_raw( /*=============*/ FILE* f, /* in: output stream */ dfield_t* dfield) /* in: dfield */ { - if (dfield->len != UNIV_SQL_NULL) { - ut_print_buf(f, dfield->data, dfield->len); + ulint len = dfield->len; + if (len != UNIV_SQL_NULL) { + ulint print_len = ut_min(len, 1000); + ut_print_buf(f, dfield->data, print_len); + if (len != print_len) { + fprintf(f, "(total %lu bytes)", (ulong) len); + } } else { fputs(" SQL NULL", f); } @@ -513,14 +518,15 @@ dtuple_convert_big_rec( if (UNIV_UNLIKELY(size > 1000000000)) { fprintf(stderr, -"InnoDB: Warning: tuple size very big: %lu\n", (ulong) size); + "InnoDB: Warning: tuple size very big: %lu\n", + (ulong) size); fputs("InnoDB: Tuple contents: ", stderr); dtuple_print(stderr, entry); putc('\n', stderr); } heap = mem_heap_create(size + dtuple_get_n_fields(entry) - * sizeof(big_rec_field_t) + 1000); + * sizeof(big_rec_field_t) + 1000); vector = mem_heap_alloc(heap, sizeof(big_rec_t)); @@ -534,13 +540,13 @@ dtuple_convert_big_rec( n_fields = 0; while (rec_get_converted_size(index, entry) - >= ut_min(page_get_free_space_of_empty( - dict_table_is_comp(index->table)) / 2, - REC_MAX_DATA_SIZE)) { + >= ut_min(page_get_free_space_of_empty + (dict_table_is_comp(index->table)) / 2, + REC_MAX_DATA_SIZE)) { longest = 0; for (i = dict_index_get_n_unique_in_tree(index); - i < dtuple_get_n_fields(entry); i++) { + i < dtuple_get_n_fields(entry); i++) { /* Skip over fields which already are externally stored */ @@ -559,8 +565,8 @@ dtuple_convert_big_rec( dfield = dtuple_get_nth_field(entry, i); - if (dfield->len != UNIV_SQL_NULL && - dfield->len > longest) { + if (dfield->len != UNIV_SQL_NULL + && dfield->len > longest) { longest = dfield->len; @@ -577,7 +583,7 @@ dtuple_convert_big_rec( #endif if (longest < BTR_EXTERN_FIELD_REF_SIZE + 10 - + DICT_MAX_INDEX_COL_LEN) { + + DICT_MAX_INDEX_COL_LEN) { /* Cannot shorten more */ mem_heap_free(heap); @@ -602,24 +608,24 @@ dtuple_convert_big_rec( ut_a(dfield->len > DICT_MAX_INDEX_COL_LEN); vector->fields[n_fields].len = dfield->len - - DICT_MAX_INDEX_COL_LEN; + - DICT_MAX_INDEX_COL_LEN; - vector->fields[n_fields].data = mem_heap_alloc(heap, - vector->fields[n_fields].len); + vector->fields[n_fields].data = mem_heap_alloc + (heap, vector->fields[n_fields].len); /* Copy data (from the end of field) to big rec vector */ ut_memcpy(vector->fields[n_fields].data, - ((byte*)dfield->data) + dfield->len - - vector->fields[n_fields].len, - vector->fields[n_fields].len); + ((byte*)dfield->data) + dfield->len + - vector->fields[n_fields].len, + vector->fields[n_fields].len); dfield->len = dfield->len - vector->fields[n_fields].len - + BTR_EXTERN_FIELD_REF_SIZE; + + BTR_EXTERN_FIELD_REF_SIZE; /* Set the extern field reference in dfield to zero */ memset(((byte*)dfield->data) - + dfield->len - BTR_EXTERN_FIELD_REF_SIZE, - 0, BTR_EXTERN_FIELD_REF_SIZE); + + dfield->len - BTR_EXTERN_FIELD_REF_SIZE, + 0, BTR_EXTERN_FIELD_REF_SIZE); n_fields++; } @@ -646,15 +652,15 @@ dtuple_convert_back_big_rec( for (i = 0; i < vector->n_fields; i++) { dfield = dtuple_get_nth_field(entry, - vector->fields[i].field_no); + vector->fields[i].field_no); /* Copy data from big rec vector */ ut_memcpy(((byte*)dfield->data) - + dfield->len - BTR_EXTERN_FIELD_REF_SIZE, + + dfield->len - BTR_EXTERN_FIELD_REF_SIZE, vector->fields[i].data, vector->fields[i].len); dfield->len = dfield->len + vector->fields[i].len - - BTR_EXTERN_FIELD_REF_SIZE; + - BTR_EXTERN_FIELD_REF_SIZE; } mem_heap_free(vector->heap); diff --git a/storage/innobase/data/data0type.c b/storage/innobase/data/data0type.c index 5b7b9c9aefb..43fc8c55e35 100644 --- a/storage/innobase/data/data0type.c +++ b/storage/innobase/data/data0type.c @@ -67,9 +67,9 @@ dtype_get_at_most_n_mbchars( if (dtype->mbminlen != dtype->mbmaxlen) { ut_a(!(prefix_len % dtype->mbmaxlen)); - return(innobase_get_at_most_n_mbchars( - dtype_get_charset_coll(dtype->prtype), - prefix_len, data_len, str)); + return(innobase_get_at_most_n_mbchars + (dtype_get_charset_coll(dtype->prtype), + prefix_len, data_len, str)); } if (prefix_len < data_len) { @@ -98,8 +98,8 @@ dtype_is_string_type( ulint mtype) /* in: InnoDB main data type code: DATA_CHAR, ... */ { if (mtype <= DATA_BLOB - || mtype == DATA_MYSQL - || mtype == DATA_VARMYSQL) { + || mtype == DATA_MYSQL + || mtype == DATA_VARMYSQL) { return(TRUE); } @@ -120,8 +120,8 @@ dtype_is_binary_string_type( ulint prtype) /* in: precise type */ { if ((mtype == DATA_FIXBINARY) - || (mtype == DATA_BINARY) - || (mtype == DATA_BLOB && (prtype & DATA_BINARY_TYPE))) { + || (mtype == DATA_BINARY) + || (mtype == DATA_BLOB && (prtype & DATA_BINARY_TYPE))) { return(TRUE); } @@ -143,7 +143,7 @@ dtype_is_non_binary_string_type( ulint prtype) /* in: precise type */ { if (dtype_is_string_type(mtype) == TRUE - && dtype_is_binary_string_type(mtype, prtype) == FALSE) { + && dtype_is_binary_string_type(mtype, prtype) == FALSE) { return(TRUE); } @@ -258,9 +258,9 @@ dtype_print( len = type->len; if ((type->mtype == DATA_SYS) - || (type->mtype == DATA_VARCHAR) - || (type->mtype == DATA_CHAR)) { - putc(' ', stderr); + || (type->mtype == DATA_VARCHAR) + || (type->mtype == DATA_CHAR)) { + putc(' ', stderr); if (prtype == DATA_ROW_ID) { fputs("DATA_ROW_ID", stderr); len = DATA_ROW_ID_LEN; @@ -317,9 +317,9 @@ dtype_get_max_size( case DATA_BINARY: case DATA_DECIMAL: case DATA_VARMYSQL: - return(type->len); + return(type->len); case DATA_BLOB: - return(ULINT_MAX); + return(ULINT_MAX); default: ut_error; } diff --git a/storage/innobase/dict/dict0boot.c b/storage/innobase/dict/dict0boot.c index 9c98338e603..0515adb9a8f 100644 --- a/storage/innobase/dict/dict0boot.c +++ b/storage/innobase/dict/dict0boot.c @@ -38,7 +38,7 @@ dict_hdr_get( ut_ad(mtr); header = DICT_HDR + buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO, - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(header, SYNC_DICT_HEADER); #endif /* UNIV_SYNC_DEBUG */ @@ -59,7 +59,7 @@ dict_hdr_get_new_id( mtr_t mtr; ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID) - || (type == DICT_HDR_MIX_ID)); + || (type == DICT_HDR_MIX_ID)); mtr_start(&mtr); @@ -122,7 +122,7 @@ dict_hdr_create( /* Create the dictionary header file block in a new, allocated file segment in the system tablespace */ page = fseg_create(DICT_HDR_SPACE, 0, - DICT_HDR + DICT_HDR_FSEG_HEADER, mtr); + DICT_HDR + DICT_HDR_FSEG_HEADER, mtr); hdr_page_no = buf_frame_get_page_no(page); @@ -133,70 +133,70 @@ dict_hdr_create( /* Start counting row, table, index, and tree ids from DICT_HDR_FIRST_ID */ mlog_write_dulint(dict_header + DICT_HDR_ROW_ID, - ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); + ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID, - ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); + ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID, - ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); + ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); mlog_write_dulint(dict_header + DICT_HDR_MIX_ID, - ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); + ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); /* Create the B-tree roots for the clustered indexes of the basic system tables */ /*--------------------------*/ root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, - DICT_HDR_SPACE, DICT_TABLES_ID, FALSE, mtr); + DICT_HDR_SPACE, DICT_TABLES_ID, FALSE, mtr); if (root_page_no == FIL_NULL) { return(FALSE); } mlog_write_ulint(dict_header + DICT_HDR_TABLES, root_page_no, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); /*--------------------------*/ root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE, - DICT_TABLE_IDS_ID, FALSE, mtr); + DICT_TABLE_IDS_ID, FALSE, mtr); if (root_page_no == FIL_NULL) { return(FALSE); } mlog_write_ulint(dict_header + DICT_HDR_TABLE_IDS, root_page_no, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); /*--------------------------*/ root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, - DICT_HDR_SPACE, DICT_COLUMNS_ID, FALSE, mtr); + DICT_HDR_SPACE, DICT_COLUMNS_ID, FALSE, mtr); if (root_page_no == FIL_NULL) { return(FALSE); } mlog_write_ulint(dict_header + DICT_HDR_COLUMNS, root_page_no, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); /*--------------------------*/ root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, - DICT_HDR_SPACE, DICT_INDEXES_ID, FALSE, mtr); + DICT_HDR_SPACE, DICT_INDEXES_ID, FALSE, mtr); if (root_page_no == FIL_NULL) { return(FALSE); } mlog_write_ulint(dict_header + DICT_HDR_INDEXES, root_page_no, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); /*--------------------------*/ root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, - DICT_HDR_SPACE, DICT_FIELDS_ID, FALSE, mtr); + DICT_HDR_SPACE, DICT_FIELDS_ID, FALSE, mtr); if (root_page_no == FIL_NULL) { return(FALSE); } mlog_write_ulint(dict_header + DICT_HDR_FIELDS, root_page_no, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); /*--------------------------*/ return(TRUE); @@ -236,11 +236,11 @@ dict_boot(void) ..._MARGIN, it will immediately be updated to the disk-based header. */ - dict_sys->row_id = ut_dulint_add( - ut_dulint_align_up( - mtr_read_dulint(dict_hdr + DICT_HDR_ROW_ID, &mtr), - DICT_HDR_ROW_ID_WRITE_MARGIN), - DICT_HDR_ROW_ID_WRITE_MARGIN); + dict_sys->row_id = ut_dulint_add + (ut_dulint_align_up(mtr_read_dulint + (dict_hdr + DICT_HDR_ROW_ID, &mtr), + DICT_HDR_ROW_ID_WRITE_MARGIN), + DICT_HDR_ROW_ID_WRITE_MARGIN); /* Insert into the dictionary cache the descriptions of the basic system tables */ @@ -262,23 +262,27 @@ dict_boot(void) dict_sys->sys_tables = table; index = dict_mem_index_create("SYS_TABLES", "CLUST_IND", - DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 1); + DICT_HDR_SPACE, + DICT_UNIQUE | DICT_CLUSTERED, 1); dict_mem_index_add_field(index, "NAME", 0); index->id = DICT_TABLES_ID; - success = dict_index_add_to_cache(table, index, mtr_read_ulint( - dict_hdr + DICT_HDR_TABLES, MLOG_4BYTES, &mtr)); + success = dict_index_add_to_cache(table, index, mtr_read_ulint + (dict_hdr + DICT_HDR_TABLES, + MLOG_4BYTES, &mtr)); ut_a(success); /*-------------------------*/ index = dict_mem_index_create("SYS_TABLES", "ID_IND", - DICT_HDR_SPACE, DICT_UNIQUE, 1); + DICT_HDR_SPACE, DICT_UNIQUE, 1); dict_mem_index_add_field(index, "ID", 0); index->id = DICT_TABLE_IDS_ID; - success = dict_index_add_to_cache(table, index, mtr_read_ulint( - dict_hdr + DICT_HDR_TABLE_IDS, MLOG_4BYTES, &mtr)); + success = dict_index_add_to_cache(table, index, + mtr_read_ulint + (dict_hdr + DICT_HDR_TABLE_IDS, + MLOG_4BYTES, &mtr)); ut_a(success); /*-------------------------*/ table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0); @@ -297,14 +301,16 @@ dict_boot(void) dict_sys->sys_columns = table; index = dict_mem_index_create("SYS_COLUMNS", "CLUST_IND", - DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2); + DICT_HDR_SPACE, + DICT_UNIQUE | DICT_CLUSTERED, 2); dict_mem_index_add_field(index, "TABLE_ID", 0); dict_mem_index_add_field(index, "POS", 0); index->id = DICT_COLUMNS_ID; - success = dict_index_add_to_cache(table, index, mtr_read_ulint( - dict_hdr + DICT_HDR_COLUMNS, MLOG_4BYTES, &mtr)); + success = dict_index_add_to_cache(table, index, mtr_read_ulint + (dict_hdr + DICT_HDR_COLUMNS, + MLOG_4BYTES, &mtr)); ut_a(success); /*-------------------------*/ table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0); @@ -333,14 +339,16 @@ dict_boot(void) dict_sys->sys_indexes = table; index = dict_mem_index_create("SYS_INDEXES", "CLUST_IND", - DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2); + DICT_HDR_SPACE, + DICT_UNIQUE | DICT_CLUSTERED, 2); dict_mem_index_add_field(index, "TABLE_ID", 0); dict_mem_index_add_field(index, "ID", 0); index->id = DICT_INDEXES_ID; - success = dict_index_add_to_cache(table, index, mtr_read_ulint( - dict_hdr + DICT_HDR_INDEXES, MLOG_4BYTES, &mtr)); + success = dict_index_add_to_cache(table, index, mtr_read_ulint + (dict_hdr + DICT_HDR_INDEXES, + MLOG_4BYTES, &mtr)); ut_a(success); /*-------------------------*/ table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0); @@ -354,14 +362,16 @@ dict_boot(void) dict_sys->sys_fields = table; index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND", - DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2); + DICT_HDR_SPACE, + DICT_UNIQUE | DICT_CLUSTERED, 2); dict_mem_index_add_field(index, "INDEX_ID", 0); dict_mem_index_add_field(index, "POS", 0); index->id = DICT_FIELDS_ID; - success = dict_index_add_to_cache(table, index, mtr_read_ulint( - dict_hdr + DICT_HDR_FIELDS, MLOG_4BYTES, &mtr)); + success = dict_index_add_to_cache(table, index, mtr_read_ulint + (dict_hdr + DICT_HDR_FIELDS, + MLOG_4BYTES, &mtr)); ut_a(success); mtr_commit(&mtr); diff --git a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c index dd2e205a735..c912ea0fd1a 100644 --- a/storage/innobase/dict/dict0crea.c +++ b/storage/innobase/dict/dict0crea.c @@ -69,7 +69,7 @@ dict_create_sys_tables_tuple( ptr = mem_heap_alloc(heap, 4); mach_write_to_4(ptr, table->n_def - | ((table->flags & DICT_TF_COMPACT) << 31)); + | ((table->flags & DICT_TF_COMPACT) << 31)); dfield_set_data(dfield, ptr, 4); /* 5: TYPE -----------------------------*/ dfield = dtuple_get_nth_field(entry, 3); @@ -222,8 +222,8 @@ dict_build_table_def_step( row_len = 0; for (i = 0; i < table->n_def; i++) { - row_len += dtype_get_min_size(dict_col_get_type( - &table->cols[i])); + row_len += dtype_get_min_size(dict_col_get_type + (&table->cols[i])); } if (row_len > BTR_PAGE_MAX_REC_SIZE) { return(DB_TOO_BIG_RECORD); @@ -236,7 +236,7 @@ dict_build_table_def_step( - page 1 is an ibuf bitmap page, - page 2 is the first inode page, - page 3 will contain the root of the clustered index of the - table we create here. */ + table we create here. */ table->space = 0; /* reset to zero for the call below */ @@ -251,9 +251,9 @@ dict_build_table_def_step( is_path = FALSE; } - error = fil_create_new_single_table_tablespace( - &(table->space), path_or_name, is_path, - FIL_IBD_FILE_INITIAL_SIZE); + error = fil_create_new_single_table_tablespace + (&table->space, path_or_name, is_path, + FIL_IBD_FILE_INITIAL_SIZE); if (error != DB_SUCCESS) { return(error); @@ -285,7 +285,7 @@ dict_build_col_def_step( dtuple_t* row; row = dict_create_sys_columns_tuple(node->table, node->col_no, - node->heap); + node->heap); ins_node_set_new_row(node->col_def, row); return(DB_SUCCESS); @@ -450,7 +450,7 @@ dict_create_sys_fields_tuple( dfield = dtuple_get_nth_field(entry, 2); dfield_set_data(dfield, field->name, - ut_strlen(field->name)); + ut_strlen(field->name)); /*---------------------------------*/ dict_table_copy_types(entry, sys_fields); @@ -528,7 +528,7 @@ dict_build_index_def_step( node->table = table; ut_ad((UT_LIST_GET_LEN(table->indexes) > 0) - || (index->type & DICT_CLUSTERED)); + || (index->type & DICT_CLUSTERED)); index->id = dict_hdr_get_new_id(DICT_HDR_INDEX_ID); @@ -600,19 +600,19 @@ dict_create_index_tree_step( search_tuple = dict_create_search_tuple(node->ind_row, node->heap); btr_pcur_open(UT_LIST_GET_FIRST(sys_indexes->indexes), - search_tuple, PAGE_CUR_L, BTR_MODIFY_LEAF, - &pcur, &mtr); + search_tuple, PAGE_CUR_L, BTR_MODIFY_LEAF, + &pcur, &mtr); btr_pcur_move_to_next_user_rec(&pcur, &mtr); node->page_no = btr_create(index->type, index->space, index->id, - dict_table_is_comp(table), &mtr); + dict_table_is_comp(table), &mtr); /* printf("Created a new index tree in space %lu root page %lu\n", - index->space, index->page_no); */ + index->space, index->page_no); */ page_rec_write_index_page_no(btr_pcur_get_rec(&pcur), - DICT_SYS_INDEXES_PAGE_NO_FIELD, - node->page_no, &mtr); + DICT_SYS_INDEXES_PAGE_NO_FIELD, + node->page_no, &mtr); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -657,7 +657,7 @@ dict_drop_index_tree( } ptr = rec_get_nth_field_old(rec, - DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); + DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); ut_ad(len == 4); @@ -680,11 +680,12 @@ dict_drop_index_tree( record: this mini-transaction marks the B-tree totally freed */ /* printf("Dropping index tree in space %lu root page %lu\n", space, - root_page_no); */ + root_page_no); */ btr_free_root(space, root_page_no, mtr); page_rec_write_index_page_no(rec, - DICT_SYS_INDEXES_PAGE_NO_FIELD, FIL_NULL, mtr); + DICT_SYS_INDEXES_PAGE_NO_FIELD, + FIL_NULL, mtr); } /*********************************************************************** @@ -732,7 +733,7 @@ dict_truncate_index_tree( } ptr = rec_get_nth_field_old(rec, - DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); + DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); ut_ad(len == 4); @@ -749,7 +750,7 @@ dict_truncate_index_tree( } ptr = rec_get_nth_field_old(rec, - DICT_SYS_INDEXES_TYPE_FIELD, &len); + DICT_SYS_INDEXES_TYPE_FIELD, &len); ut_ad(len == 4); type = mach_read_from_4(ptr); @@ -767,8 +768,8 @@ dict_truncate_index_tree( appropriate field in the SYS_INDEXES record: this mini-transaction marks the B-tree totally truncated */ - comp = page_is_comp(btr_page_get( - space, root_page_no, RW_X_LATCH, mtr)); + comp = page_is_comp(btr_page_get + (space, root_page_no, RW_X_LATCH, mtr)); btr_free_root(space, root_page_no, mtr); /* We will temporarily write FIL_NULL to the PAGE_NO field @@ -776,7 +777,7 @@ dict_truncate_index_tree( inconsistent state in case it crashes between the mtr_commit() below and the following mtr_commit() call. */ page_rec_write_index_page_no(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, - FIL_NULL, mtr); + FIL_NULL, mtr); /* We will need to commit the mini-transaction in order to avoid deadlocks in the btr_create() call, because otherwise we would @@ -788,8 +789,8 @@ dict_truncate_index_tree( /* Find the index corresponding to this SYS_INDEXES record. */ for (index = UT_LIST_GET_FIRST(table->indexes); - index; - index = UT_LIST_GET_NEXT(indexes, index)) { + index; + index = UT_LIST_GET_NEXT(indexes, index)) { if (!ut_dulint_cmp(index->id, index_id)) { break; } @@ -834,11 +835,11 @@ tab_create_graph_create( node->heap = mem_heap_create(256); node->tab_def = ins_node_create(INS_DIRECT, dict_sys->sys_tables, - heap); + heap); node->tab_def->common.parent = node; node->col_def = ins_node_create(INS_DIRECT, dict_sys->sys_columns, - heap); + heap); node->col_def->common.parent = node; node->commit_node = commit_node_create(heap); @@ -871,11 +872,11 @@ ind_create_graph_create( node->heap = mem_heap_create(256); node->ind_def = ins_node_create(INS_DIRECT, - dict_sys->sys_indexes, heap); + dict_sys->sys_indexes, heap); node->ind_def->common.parent = node; node->field_def = ins_node_create(INS_DIRECT, - dict_sys->sys_fields, heap); + dict_sys->sys_fields, heap); node->field_def->common.parent = node; node->commit_node = commit_node_create(heap); @@ -1088,7 +1089,7 @@ dict_create_index_step( if (node->state == INDEX_ADD_TO_CACHE) { success = dict_index_add_to_cache(node->table, node->index, - node->page_no); + node->page_no); ut_a(success); @@ -1136,8 +1137,8 @@ dict_create_or_check_foreign_constraint_tables(void) table2 = dict_table_get_low("SYS_FOREIGN_COLS"); if (table1 && table2 - && UT_LIST_GET_LEN(table1->indexes) == 3 - && UT_LIST_GET_LEN(table2->indexes) == 1) { + && UT_LIST_GET_LEN(table1->indexes) == 3 + && UT_LIST_GET_LEN(table2->indexes) == 1) { /* Foreign constraint system tables have already been created, and they are ok */ @@ -1157,13 +1158,15 @@ dict_create_or_check_foreign_constraint_tables(void) if (table1) { fprintf(stderr, - "InnoDB: dropping incompletely created SYS_FOREIGN table\n"); + "InnoDB: dropping incompletely created" + " SYS_FOREIGN table\n"); row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE); } if (table2) { fprintf(stderr, - "InnoDB: dropping incompletely created SYS_FOREIGN_COLS table\n"); + "InnoDB: dropping incompletely created" + " SYS_FOREIGN_COLS table\n"); row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE); } @@ -1181,19 +1184,25 @@ dict_create_or_check_foreign_constraint_tables(void) design. */ error = que_eval_sql(NULL, - "PROCEDURE CREATE_FOREIGN_SYS_TABLES_PROC () IS\n" - "BEGIN\n" - "CREATE TABLE\n" - "SYS_FOREIGN(ID CHAR, FOR_NAME CHAR, REF_NAME CHAR, N_COLS INT);\n" - "CREATE UNIQUE CLUSTERED INDEX ID_IND ON SYS_FOREIGN (ID);\n" - "CREATE INDEX FOR_IND ON SYS_FOREIGN (FOR_NAME);\n" - "CREATE INDEX REF_IND ON SYS_FOREIGN (REF_NAME);\n" - "CREATE TABLE\n" - "SYS_FOREIGN_COLS(ID CHAR, POS INT, FOR_COL_NAME CHAR, REF_COL_NAME CHAR);\n" - "CREATE UNIQUE CLUSTERED INDEX ID_IND ON SYS_FOREIGN_COLS (ID, POS);\n" - "COMMIT WORK;\n" - "END;\n" - , FALSE, trx); + "PROCEDURE CREATE_FOREIGN_SYS_TABLES_PROC () IS\n" + "BEGIN\n" + "CREATE TABLE\n" + "SYS_FOREIGN(ID CHAR, FOR_NAME CHAR," + " REF_NAME CHAR, N_COLS INT);\n" + "CREATE UNIQUE CLUSTERED INDEX ID_IND" + " ON SYS_FOREIGN (ID);\n" + "CREATE INDEX FOR_IND" + " ON SYS_FOREIGN (FOR_NAME);\n" + "CREATE INDEX REF_IND" + " ON SYS_FOREIGN (REF_NAME);\n" + "CREATE TABLE\n" + "SYS_FOREIGN_COLS(ID CHAR, POS INT," + " FOR_COL_NAME CHAR, REF_COL_NAME CHAR);\n" + "CREATE UNIQUE CLUSTERED INDEX ID_IND" + " ON SYS_FOREIGN_COLS (ID, POS);\n" + "COMMIT WORK;\n" + "END;\n" + , FALSE, trx); if (error != DB_SUCCESS) { fprintf(stderr, "InnoDB: error %lu in creation\n", @@ -1201,10 +1210,11 @@ dict_create_or_check_foreign_constraint_tables(void) ut_a(error == DB_OUT_OF_FILE_SPACE); - fprintf(stderr, "InnoDB: creation failed\n"); - fprintf(stderr, "InnoDB: tablespace is full\n"); fprintf(stderr, - "InnoDB: dropping incompletely created SYS_FOREIGN tables\n"); + "InnoDB: creation failed\n" + "InnoDB: tablespace is full\n" + "InnoDB: dropping incompletely created" + " SYS_FOREIGN tables\n"); row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE); row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE); @@ -1220,7 +1230,8 @@ dict_create_or_check_foreign_constraint_tables(void) if (error == DB_SUCCESS) { fprintf(stderr, - "InnoDB: Foreign key constraint system tables created\n"); + "InnoDB: Foreign key constraint system tables" + " created\n"); } return(error); @@ -1249,22 +1260,22 @@ dict_foreign_eval_sql( rewind(ef); ut_print_timestamp(ef); fputs(" Error in foreign key constraint creation for table ", - ef); + ef); ut_print_name(ef, trx, TRUE, table->name); fputs(".\nA foreign key constraint of name ", ef); ut_print_name(ef, trx, FALSE, foreign->id); fputs("\nalready exists." - " (Note that internally InnoDB adds 'databasename/'\n" - "in front of the user-defined constraint name).\n", - ef); + " (Note that internally InnoDB adds 'databasename/'\n" + "in front of the user-defined constraint name).\n", + ef); fputs("Note that InnoDB's FOREIGN KEY system tables store\n" - "constraint names as case-insensitive, with the\n" - "MySQL standard latin1_swedish_ci collation. If you\n" - "create tables or databases whose names differ only in\n" - "the character case, then collisions in constraint\n" - "names can occur. Workaround: name your constraints\n" - "explicitly with unique names.\n", - ef); + "constraint names as case-insensitive, with the\n" + "MySQL standard latin1_swedish_ci collation. If you\n" + "create tables or databases whose names differ only in\n" + "the character case, then collisions in constraint\n" + "names can occur. Workaround: name your constraints\n" + "explicitly with unique names.\n", + ef); mutex_exit(&dict_foreign_err_mutex); @@ -1279,10 +1290,11 @@ dict_foreign_eval_sql( mutex_enter(&dict_foreign_err_mutex); ut_print_timestamp(ef); fputs(" Internal error in foreign key constraint creation" - " for table ", ef); + " for table ", ef); ut_print_name(ef, trx, TRUE, table->name); fputs(".\n" - "See the MySQL .err log in the datadir for more information.\n", ef); + "See the MySQL .err log in the datadir" + " for more information.\n", ef); mutex_exit(&dict_foreign_err_mutex); return(error); @@ -1311,18 +1323,18 @@ dict_create_add_foreign_field_to_dictionary( pars_info_add_int4_literal(info, "pos", field_nr); pars_info_add_str_literal(info, "for_col_name", - foreign->foreign_col_names[field_nr]); + foreign->foreign_col_names[field_nr]); pars_info_add_str_literal(info, "ref_col_name", - foreign->referenced_col_names[field_nr]); + foreign->referenced_col_names[field_nr]); - return dict_foreign_eval_sql(info, - "PROCEDURE P () IS\n" + return(dict_foreign_eval_sql + (info, "PROCEDURE P () IS\n" "BEGIN\n" "INSERT INTO SYS_FOREIGN_COLS VALUES" "(:id, :pos, :for_col_name, :ref_col_name);\n" - "END;\n" - , table, foreign, trx); + "END;\n", + table, foreign, trx)); } /************************************************************************ @@ -1362,18 +1374,18 @@ dict_create_add_foreign_to_dictionary( pars_info_add_str_literal(info, "for_name", table->name); pars_info_add_str_literal(info, "ref_name", - foreign->referenced_table_name); + foreign->referenced_table_name); pars_info_add_int4_literal(info, "n_cols", - foreign->n_fields + (foreign->type << 24)); + foreign->n_fields + (foreign->type << 24)); error = dict_foreign_eval_sql(info, - "PROCEDURE P () IS\n" - "BEGIN\n" - "INSERT INTO SYS_FOREIGN VALUES" - "(:id, :for_name, :ref_name, :n_cols);\n" - "END;\n" - , table, foreign, trx); + "PROCEDURE P () IS\n" + "BEGIN\n" + "INSERT INTO SYS_FOREIGN VALUES" + "(:id, :for_name, :ref_name, :n_cols);\n" + "END;\n" + , table, foreign, trx); if (error != DB_SUCCESS) { @@ -1381,8 +1393,8 @@ dict_create_add_foreign_to_dictionary( } for (i = 0; i < foreign->n_fields; i++) { - error = dict_create_add_foreign_field_to_dictionary(i, - table, foreign, trx); + error = dict_create_add_foreign_field_to_dictionary + (i, table, foreign, trx); if (error != DB_SUCCESS) { @@ -1391,11 +1403,11 @@ dict_create_add_foreign_to_dictionary( } error = dict_foreign_eval_sql(NULL, - "PROCEDURE P () IS\n" - "BEGIN\n" - "COMMIT WORK;\n" - "END;\n" - , table, foreign, trx); + "PROCEDURE P () IS\n" + "BEGIN\n" + "COMMIT WORK;\n" + "END;\n" + , table, foreign, trx); return(error); } @@ -1428,7 +1440,8 @@ dict_create_add_foreigns_to_dictionary( if (NULL == dict_table_get_low("SYS_FOREIGN")) { fprintf(stderr, -"InnoDB: table SYS_FOREIGN not found from internal data dictionary\n"); + "InnoDB: table SYS_FOREIGN not found" + " in internal data dictionary\n"); return(DB_ERROR); } @@ -1437,8 +1450,8 @@ dict_create_add_foreigns_to_dictionary( foreign; foreign = UT_LIST_GET_NEXT(foreign_list, foreign)) { - error = dict_create_add_foreign_to_dictionary(&number, - table, foreign, trx); + error = dict_create_add_foreign_to_dictionary + (&number, table, foreign, trx); if (error != DB_SUCCESS) { diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index 3470b19ed71..f98898a44a0 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -645,9 +645,9 @@ dict_index_get_nth_field_pos( field = dict_index_get_nth_field(index, pos); if (field->col == field2->col - && (field->prefix_len == 0 + && (field->prefix_len == 0 || (field->prefix_len >= field2->prefix_len - && field2->prefix_len != 0))) { + && field2->prefix_len != 0))) { return(pos); } @@ -669,7 +669,7 @@ dict_table_get_on_id( dict_table_t* table; if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0 - || trx->dict_operation_lock_mode == RW_X_LATCH) { + || trx->dict_operation_lock_mode == RW_X_LATCH) { /* It is a system table which will always exist in the table cache: we avoid acquiring the dictionary mutex, because if we are doing a rollback to handle an error in TABLE @@ -703,7 +703,7 @@ dict_table_get_nth_col_pos( ulint n) /* in: column number */ { return(dict_index_get_nth_col_pos(dict_table_get_first_index(table), - n)); + n)); } /************************************************************************ @@ -768,15 +768,15 @@ dict_init(void) mutex_create(&dict_sys->mutex, SYNC_DICT); - dict_sys->table_hash = hash_create(buf_pool_get_max_size() / - (DICT_POOL_PER_TABLE_HASH * - UNIV_WORD_SIZE)); - dict_sys->table_id_hash = hash_create(buf_pool_get_max_size() / - (DICT_POOL_PER_TABLE_HASH * - UNIV_WORD_SIZE)); - dict_sys->col_hash = hash_create(buf_pool_get_max_size() / - (DICT_POOL_PER_COL_HASH * - UNIV_WORD_SIZE)); + dict_sys->table_hash = hash_create(buf_pool_get_max_size() + / (DICT_POOL_PER_TABLE_HASH + * UNIV_WORD_SIZE)); + dict_sys->table_id_hash = hash_create(buf_pool_get_max_size() + / (DICT_POOL_PER_TABLE_HASH + * UNIV_WORD_SIZE)); + dict_sys->col_hash = hash_create(buf_pool_get_max_size() + / (DICT_POOL_PER_COL_HASH + * UNIV_WORD_SIZE)); dict_sys->size = 0; UT_LIST_INIT(dict_sys->table_LRU); @@ -883,22 +883,26 @@ dict_table_add_to_cache( system columns. */ dict_mem_table_add_col(table, "DB_ROW_ID", DATA_SYS, - DATA_ROW_ID | DATA_NOT_NULL, DATA_ROW_ID_LEN, 0); + DATA_ROW_ID | DATA_NOT_NULL, + DATA_ROW_ID_LEN, 0); #if DATA_ROW_ID != 0 #error "DATA_ROW_ID != 0" #endif dict_mem_table_add_col(table, "DB_TRX_ID", DATA_SYS, - DATA_TRX_ID | DATA_NOT_NULL, DATA_TRX_ID_LEN, 0); + DATA_TRX_ID | DATA_NOT_NULL, + DATA_TRX_ID_LEN, 0); #if DATA_TRX_ID != 1 #error "DATA_TRX_ID != 1" #endif dict_mem_table_add_col(table, "DB_ROLL_PTR", DATA_SYS, - DATA_ROLL_PTR | DATA_NOT_NULL, DATA_ROLL_PTR_LEN, 0); + DATA_ROLL_PTR | DATA_NOT_NULL, + DATA_ROLL_PTR_LEN, 0); #if DATA_ROLL_PTR != 2 #error "DATA_ROLL_PTR != 2" #endif dict_mem_table_add_col(table, "DB_MIX_ID", DATA_SYS, - DATA_MIX_ID | DATA_NOT_NULL, DATA_MIX_ID_LEN, 0); + DATA_MIX_ID | DATA_NOT_NULL, + DATA_MIX_ID_LEN, 0); #if DATA_MIX_ID != 3 #error "DATA_MIX_ID != 3" #endif @@ -911,8 +915,8 @@ dict_table_add_to_cache( row_len = 0; for (i = 0; i < table->n_def; i++) { - ulint col_len = dtype_get_max_size( - dict_col_get_type(dict_table_get_nth_col(table, i))); + ulint col_len = dtype_get_max_size + (dict_col_get_type(dict_table_get_nth_col(table, i))); /* If we have a single unbounded field, or several gigantic fields, mark the maximum row size as ULINT_MAX. */ @@ -931,7 +935,7 @@ dict_table_add_to_cache( { dict_table_t* table2; HASH_SEARCH(name_hash, dict_sys->table_hash, fold, table2, - (ut_strcmp(table2->name, table->name) == 0)); + (ut_strcmp(table2->name, table->name) == 0)); ut_a(table2 == NULL); } @@ -939,7 +943,7 @@ dict_table_add_to_cache( { dict_table_t* table2; HASH_SEARCH(id_hash, dict_sys->table_id_hash, id_fold, table2, - (ut_dulint_cmp(table2->id, table->id) == 0)); + (ut_dulint_cmp(table2->id, table->id) == 0)); ut_a(table2 == NULL); } @@ -950,11 +954,11 @@ dict_table_add_to_cache( /* Add table to hash table of tables */ HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold, - table); + table); /* Add table to hash table of tables based on table id */ HASH_INSERT(dict_table_t, id_hash, dict_sys->table_id_hash, id_fold, - table); + table); /* Add table to LRU list of tables */ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table); @@ -1030,10 +1034,11 @@ dict_table_rename_in_cache( { dict_table_t* table2; HASH_SEARCH(name_hash, dict_sys->table_hash, fold, table2, - (ut_strcmp(table2->name, new_name) == 0)); + (ut_strcmp(table2->name, new_name) == 0)); if (table2) { fprintf(stderr, -"InnoDB: Error: dictionary cache already contains a table of name %s\n", + "InnoDB: Error: dictionary cache" + " already contains a table of name %s\n", new_name); return(FALSE); } @@ -1045,12 +1050,14 @@ dict_table_rename_in_cache( if (table->space != 0) { if (table->dir_path_of_temp_table != NULL) { fprintf(stderr, -"InnoDB: Error: trying to rename a table %s (%s) created with CREATE\n" -"InnoDB: TEMPORARY TABLE\n", table->name, table->dir_path_of_temp_table); + "InnoDB: Error: trying to rename a table" + " %s (%s) created with CREATE\n" + "InnoDB: TEMPORARY TABLE\n", + table->name, table->dir_path_of_temp_table); success = FALSE; } else { - success = fil_rename_tablespace(table->name, - table->space, new_name); + success = fil_rename_tablespace + (table->name, table->space, new_name); } if (!success) { @@ -1064,18 +1071,19 @@ dict_table_rename_in_cache( for (i = 0; i < table->n_cols; i++) { dict_col_reposition_in_cache(table, - dict_table_get_nth_col(table, i), new_name); + dict_table_get_nth_col(table, i), + new_name); } /* Remove table from the hash tables of tables */ HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash, - ut_fold_string(table->name), table); + ut_fold_string(table->name), table); old_name = mem_heap_strdup(table->heap, table->name); table->name = mem_heap_strdup(table->heap, new_name); /* Add table to hash table of tables */ HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold, - table); + table); dict_sys->size += (mem_heap_get_size(table->heap) - old_size); /* Update the table_name field in indexes */ @@ -1129,14 +1137,14 @@ dict_table_rename_in_cache( foreign = UT_LIST_GET_FIRST(table->foreign_list); while (foreign != NULL) { - if (ut_strlen(foreign->foreign_table_name) < - ut_strlen(table->name)) { + if (ut_strlen(foreign->foreign_table_name) + < ut_strlen(table->name)) { /* Allocate a longer name buffer; TODO: store buf len to save memory */ - foreign->foreign_table_name = mem_heap_alloc( - foreign->heap, - ut_strlen(table->name) + 1); + foreign->foreign_table_name + = mem_heap_alloc(foreign->heap, + ut_strlen(table->name) + 1); } strcpy(foreign->foreign_table_name, table->name); @@ -1150,38 +1158,37 @@ dict_table_rename_in_cache( old_id = mem_strdup(foreign->id); if (ut_strlen(foreign->id) > ut_strlen(old_name) - + ((sizeof dict_ibfk) - 1) - && 0 == ut_memcmp(foreign->id, old_name, - ut_strlen(old_name)) - && 0 == ut_memcmp( - foreign->id + ut_strlen(old_name), - dict_ibfk, (sizeof dict_ibfk) - 1)) { + + ((sizeof dict_ibfk) - 1) + && !memcmp(foreign->id, old_name, + ut_strlen(old_name)) + && !memcmp(foreign->id + ut_strlen(old_name), + dict_ibfk, (sizeof dict_ibfk) - 1)) { /* This is a generated >= 4.0.18 format id */ - if (ut_strlen(table->name) > ut_strlen(old_name)) { - foreign->id = mem_heap_alloc( - foreign->heap, - ut_strlen(table->name) - + ut_strlen(old_id) + 1); + if (strlen(table->name) > strlen(old_name)) { + foreign->id = mem_heap_alloc + (foreign->heap, + strlen(table->name) + + strlen(old_id) + 1); } /* Replace the prefix 'databasename/tablename' with the new names */ strcpy(foreign->id, table->name); strcat(foreign->id, - old_id + ut_strlen(old_name)); + old_id + ut_strlen(old_name)); } else { /* This is a >= 4.0.18 format id where the user gave the id name */ db_len = dict_get_db_name_len(table->name) + 1; if (dict_get_db_name_len(table->name) - > dict_get_db_name_len(foreign->id)) { + > dict_get_db_name_len(foreign->id)) { - foreign->id = mem_heap_alloc( - foreign->heap, - db_len + ut_strlen(old_id) + 1); + foreign->id = mem_heap_alloc + (foreign->heap, + db_len + strlen(old_id) + 1); } /* Replace the database prefix in id with the @@ -1190,7 +1197,7 @@ dict_table_rename_in_cache( ut_memcpy(foreign->id, table->name, db_len); strcpy(foreign->id + db_len, - dict_remove_db_name(old_id)); + dict_remove_db_name(old_id)); } mem_free(old_id); @@ -1202,14 +1209,13 @@ dict_table_rename_in_cache( foreign = UT_LIST_GET_FIRST(table->referenced_list); while (foreign != NULL) { - if (ut_strlen(foreign->referenced_table_name) < - ut_strlen(table->name)) { + if (ut_strlen(foreign->referenced_table_name) + < ut_strlen(table->name)) { /* Allocate a longer name buffer; TODO: store buf len to save memory */ - foreign->referenced_table_name = mem_heap_alloc( - foreign->heap, - ut_strlen(table->name) + 1); + foreign->referenced_table_name = mem_heap_alloc + (foreign->heap, strlen(table->name) + 1); } strcpy(foreign->referenced_table_name, table->name); @@ -1239,12 +1245,12 @@ dict_table_change_id_in_cache( /* Remove the table from the hash table of id's */ HASH_DELETE(dict_table_t, id_hash, dict_sys->table_id_hash, - ut_fold_dulint(table->id), table); + ut_fold_dulint(table->id), table); table->id = new_id; /* Add the table back to the hash table */ HASH_INSERT(dict_table_t, id_hash, dict_sys->table_id_hash, - ut_fold_dulint(table->id), table); + ut_fold_dulint(table->id), table); } /************************************************************************** @@ -1307,9 +1313,9 @@ dict_table_remove_from_cache( /* Remove table from the hash tables of tables */ HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash, - ut_fold_string(table->name), table); + ut_fold_string(table->name), table); HASH_DELETE(dict_table_t, id_hash, dict_sys->table_id_hash, - ut_fold_dulint(table->id), table); + ut_fold_dulint(table->id), table); /* Remove table from LRU list of tables */ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table); @@ -1347,9 +1353,9 @@ dict_col_add_to_cache( { dict_col_t* col2; HASH_SEARCH(hash, dict_sys->col_hash, fold, col2, - (ut_strcmp(col->name, col2->name) == 0) - && (ut_strcmp((col2->table)->name, table->name) - == 0)); + (ut_strcmp(col->name, col2->name) == 0) + && (ut_strcmp((col2->table)->name, table->name) + == 0)); ut_a(col2 == NULL); } @@ -1483,7 +1489,7 @@ dict_index_add_to_cache( #endif /* UNIV_DEBUG */ ut_a(!(index->type & DICT_CLUSTERED) - || UT_LIST_GET_LEN(table->indexes) == 0); + || UT_LIST_GET_LEN(table->indexes) == 0); success = dict_index_find_cols(table, index); @@ -1538,10 +1544,10 @@ dict_index_add_to_cache( if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) { - new_index->stat_n_diff_key_vals = - mem_heap_alloc(new_index->heap, - (1 + dict_index_get_n_unique(new_index)) - * sizeof(ib_longlong)); + new_index->stat_n_diff_key_vals = mem_heap_alloc + (new_index->heap, + (1 + dict_index_get_n_unique(new_index)) + * sizeof(ib_longlong)); /* Give some sensible values to stat_n_... in case we do not calculate statistics quickly enough */ @@ -1631,12 +1637,12 @@ dict_index_find_cols( field = dict_index_get_nth_field(index, i); fold = ut_fold_ulint_pair(ut_fold_string(table->name), - ut_fold_string(field->name)); + ut_fold_string(field->name)); HASH_SEARCH(hash, dict_sys->col_hash, fold, col, - (ut_strcmp(col->name, field->name) == 0) - && (ut_strcmp((col->table)->name, table->name) - == 0)); + (ut_strcmp(col->name, field->name) == 0) + && (ut_strcmp((col->table)->name, table->name) + == 0)); if (col == NULL) { return(FALSE); @@ -1729,8 +1735,8 @@ dict_index_copy_types( for (i = 0; i < n_fields; i++) { dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i)); - type = dict_col_get_type(dict_field_get_col( - dict_index_get_nth_field(index, i))); + type = dict_col_get_type(dict_field_get_col + (dict_index_get_nth_field(index, i))); *dfield_type = *type; } } @@ -1776,6 +1782,7 @@ dict_index_build_internal_clust( ulint fixed_size; ulint trx_id_pos; ulint i; + ibool* indexed; ut_ad(table && index); ut_ad(index->type & DICT_CLUSTERED); @@ -1786,8 +1793,9 @@ dict_index_build_internal_clust( /* Create a new index object with certainly enough fields */ new_index = dict_mem_index_create(table->name, - index->name, table->space, index->type, - index->n_fields + table->n_cols); + index->name, table->space, + index->type, + index->n_fields + table->n_cols); /* Copy other relevant data from the old index struct to the new struct: it inherits the values */ @@ -1833,20 +1841,23 @@ dict_index_build_internal_clust( if (!(index->type & DICT_UNIQUE)) { dict_index_add_col(new_index, - dict_table_get_sys_col(table, DATA_ROW_ID), 0); + dict_table_get_sys_col + (table, DATA_ROW_ID), 0); trx_id_pos++; } dict_index_add_col(new_index, - dict_table_get_sys_col(table, DATA_TRX_ID), 0); + dict_table_get_sys_col + (table, DATA_TRX_ID), 0); dict_index_add_col(new_index, - dict_table_get_sys_col(table, DATA_ROLL_PTR), 0); + dict_table_get_sys_col + (table, DATA_ROLL_PTR), 0); for (i = 0; i < trx_id_pos; i++) { - fixed_size = dtype_get_fixed_size( - dict_index_get_nth_type(new_index, i)); + fixed_size = dtype_get_fixed_size + (dict_index_get_nth_type(new_index, i)); if (fixed_size == 0) { new_index->trx_id_offset = 0; @@ -1855,7 +1866,7 @@ dict_index_build_internal_clust( } if (dict_index_get_nth_field(new_index, i)->prefix_len - > 0) { + > 0) { new_index->trx_id_offset = 0; break; @@ -1866,12 +1877,9 @@ dict_index_build_internal_clust( } - /* Set auxiliary variables in table columns as undefined */ - for (i = 0; i < table->n_cols; i++) { - - col = dict_table_get_nth_col(table, i); - col->aux = ULINT_UNDEFINED; - } + /* Remember the table columns already contained in new_index */ + indexed = mem_alloc(table->n_cols * sizeof *indexed); + memset(indexed, 0, table->n_cols * sizeof *indexed); /* Mark with 0 the table columns already contained in new_index */ for (i = 0; i < new_index->n_def; i++) { @@ -1883,7 +1891,7 @@ dict_index_build_internal_clust( if (field->prefix_len == 0) { - field->col->aux = 0; + indexed[field->col->ind] = TRUE; } } @@ -1894,13 +1902,15 @@ dict_index_build_internal_clust( col = dict_table_get_nth_col(table, i); ut_ad(col->type.mtype != DATA_SYS); - if (col->aux == ULINT_UNDEFINED) { + if (!indexed[col->ind]) { dict_index_add_col(new_index, col, 0); } } + mem_free(indexed); + ut_ad((index->type & DICT_IBUF) - || (UT_LIST_GET_LEN(table->indexes) == 0)); + || (UT_LIST_GET_LEN(table->indexes) == 0)); /* Store to the column structs the position of the table columns in the clustered index */ @@ -1936,6 +1946,7 @@ dict_index_build_internal_non_clust( dict_index_t* new_index; dict_index_t* clust_index; ulint i; + ibool* indexed; ut_ad(table && index); ut_ad(0 == (index->type & DICT_CLUSTERED)); @@ -1952,9 +1963,9 @@ dict_index_build_internal_non_clust( ut_ad(!(clust_index->type & DICT_UNIVERSAL)); /* Create a new index */ - new_index = dict_mem_index_create(table->name, - index->name, index->space, index->type, - index->n_fields + 1 + clust_index->n_uniq); + new_index = dict_mem_index_create + (table->name, index->name, index->space, index->type, + index->n_fields + 1 + clust_index->n_uniq); /* Copy other relevant data from the old index struct to the new struct: it inherits the values */ @@ -1966,13 +1977,9 @@ dict_index_build_internal_non_clust( /* Copy fields from index to new_index */ dict_index_copy(new_index, index, 0, index->n_fields); - /* Set the auxiliary variables in the clust_index unique columns - as undefined */ - for (i = 0; i < clust_index->n_uniq; i++) { - - field = dict_index_get_nth_field(clust_index, i); - field->col->aux = ULINT_UNDEFINED; - } + /* Remember the table columns already contained in new_index */ + indexed = mem_alloc(table->n_cols * sizeof *indexed); + memset(indexed, 0, table->n_cols * sizeof *indexed); /* Mark with 0 table columns already contained in new_index */ for (i = 0; i < new_index->n_def; i++) { @@ -1984,7 +1991,7 @@ dict_index_build_internal_non_clust( if (field->prefix_len == 0) { - field->col->aux = 0; + indexed[field->col->ind] = TRUE; } } @@ -1995,12 +2002,14 @@ dict_index_build_internal_non_clust( field = dict_index_get_nth_field(clust_index, i); - if (field->col->aux == ULINT_UNDEFINED) { + if (!indexed[field->col->ind]) { dict_index_add_col(new_index, field->col, - field->prefix_len); + field->prefix_len); } } + mem_free(indexed); + if ((index->type) & DICT_UNIQUE) { new_index->n_uniq = index->n_fields; } else { @@ -2063,12 +2072,14 @@ dict_foreign_remove_from_cache( if (foreign->referenced_table) { UT_LIST_REMOVE(referenced_list, - foreign->referenced_table->referenced_list, foreign); + foreign->referenced_table->referenced_list, + foreign); } if (foreign->foreign_table) { UT_LIST_REMOVE(foreign_list, - foreign->foreign_table->foreign_list, foreign); + foreign->foreign_table->foreign_list, + foreign); } dict_foreign_free(foreign); @@ -2130,9 +2141,9 @@ dict_foreign_find_index( ulint n_cols, /* in: number of columns */ dict_index_t* types_idx, /* in: NULL or an index to whose types the column types must match */ - ibool check_charsets) /* in: whether to check charsets. - only has an effect if types_idx != - NULL. */ + ibool check_charsets) + /* in: whether to check charsets. + only has an effect if types_idx != NULL */ { dict_index_t* index; const char* col_name; @@ -2145,9 +2156,9 @@ dict_foreign_find_index( for (i = 0; i < n_cols; i++) { col_name = dict_index_get_nth_field(index, i) - ->col->name; + ->col->name; if (dict_index_get_nth_field(index, i) - ->prefix_len != 0) { + ->prefix_len != 0) { /* We do not accept column prefix indexes here */ @@ -2155,14 +2166,14 @@ dict_foreign_find_index( } if (0 != innobase_strcasecmp(columns[i], - col_name)) { + col_name)) { break; } - if (types_idx && !cmp_types_are_equal( - dict_index_get_nth_type(index, i), - dict_index_get_nth_type(types_idx, i), - check_charsets)) { + if (types_idx && !cmp_types_are_equal + (dict_index_get_nth_type(index, i), + dict_index_get_nth_type(types_idx, i), + check_charsets)) { break; } @@ -2216,9 +2227,10 @@ dict_foreign_error_report( fputs("The index in the foreign key in table is ", file); ut_print_name(file, NULL, FALSE, fk->foreign_index->name); fputs("\n" -"See http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html\n" -"for correct foreign key definition.\n", - file); + "See http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-foreign-key-constraints.html\n" + "for correct foreign key definition.\n", + file); } mutex_exit(&dict_foreign_err_mutex); } @@ -2248,11 +2260,11 @@ dict_foreign_add_to_cache( ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ - for_table = dict_table_check_if_in_cache_low( - foreign->foreign_table_name); + for_table = dict_table_check_if_in_cache_low + (foreign->foreign_table_name); - ref_table = dict_table_check_if_in_cache_low( - foreign->referenced_table_name); + ref_table = dict_table_check_if_in_cache_low + (foreign->referenced_table_name); ut_a(for_table || ref_table); if (for_table) { @@ -2271,16 +2283,21 @@ dict_foreign_add_to_cache( } if (for_in_cache->referenced_table == NULL && ref_table) { - index = dict_foreign_find_index(ref_table, - (const char**) for_in_cache->referenced_col_names, - for_in_cache->n_fields, - for_in_cache->foreign_index, check_charsets); + index = dict_foreign_find_index + (ref_table, + (const char**) for_in_cache->referenced_col_names, + for_in_cache->n_fields, + for_in_cache->foreign_index, check_charsets); if (index == NULL) { - dict_foreign_error_report(ef, for_in_cache, -"there is no index in referenced table which would contain\n" -"the columns as the first columns, or the data types in the\n" -"referenced table do not match to the ones in table."); + dict_foreign_error_report + (ef, for_in_cache, + "there is no index in referenced table" + " which would contain\n" + "the columns as the first columns," + " or the data types in the\n" + "referenced table do not match" + " the ones in table."); if (for_in_cache == foreign) { mem_heap_free(foreign->heap); @@ -2292,28 +2309,34 @@ dict_foreign_add_to_cache( for_in_cache->referenced_table = ref_table; for_in_cache->referenced_index = index; UT_LIST_ADD_LAST(referenced_list, - ref_table->referenced_list, - for_in_cache); + ref_table->referenced_list, + for_in_cache); added_to_referenced_list = TRUE; } if (for_in_cache->foreign_table == NULL && for_table) { - index = dict_foreign_find_index(for_table, - (const char**) for_in_cache->foreign_col_names, - for_in_cache->n_fields, - for_in_cache->referenced_index, check_charsets); + index = dict_foreign_find_index + (for_table, + (const char**) for_in_cache->foreign_col_names, + for_in_cache->n_fields, + for_in_cache->referenced_index, check_charsets); if (index == NULL) { - dict_foreign_error_report(ef, for_in_cache, -"there is no index in the table which would contain\n" -"the columns as the first columns, or the data types in the\n" -"table do not match to the ones in the referenced table."); + dict_foreign_error_report + (ef, for_in_cache, + "there is no index in the table" + " which would contain\n" + "the columns as the first columns," + " or the data types in the\n" + "table do not match" + " the ones in the referenced table."); if (for_in_cache == foreign) { if (added_to_referenced_list) { - UT_LIST_REMOVE(referenced_list, - ref_table->referenced_list, - for_in_cache); + UT_LIST_REMOVE + (referenced_list, + ref_table->referenced_list, + for_in_cache); } mem_heap_free(foreign->heap); @@ -2325,8 +2348,8 @@ dict_foreign_add_to_cache( for_in_cache->foreign_table = for_table; for_in_cache->foreign_index = index; UT_LIST_ADD_LAST(foreign_list, - for_table->foreign_list, - for_in_cache); + for_table->foreign_list, + for_in_cache); } return(DB_SUCCESS); @@ -2361,13 +2384,13 @@ dict_scan_to( ulint i; for (i = 0; string[i]; i++) { if (toupper((int)(unsigned char)(ptr[i])) - != toupper((int)(unsigned char) - (string[i]))) { + != toupper((int)(unsigned char) + (string[i]))) { goto nomatch; } } break; - nomatch: +nomatch: ; } } @@ -2473,8 +2496,8 @@ dict_scan_id( } } else { while (!my_isspace(cs, *ptr) && *ptr != '(' && *ptr != ')' - && (accept_also_dot || *ptr != '.') - && *ptr != ',' && *ptr != '\0') { + && (accept_also_dot || *ptr != '.') + && *ptr != ',' && *ptr != '\0') { ptr++; } @@ -2513,7 +2536,7 @@ convert_id: innobase_convert_from_id(dst, str, len); } else if (!strncmp(str, srv_mysql50_table_name_prefix, - sizeof srv_mysql50_table_name_prefix)) { + sizeof srv_mysql50_table_name_prefix)) { /* This is a pre-5.1 table name containing chars other than [A-Za-z0-9]. Discard the prefix and use raw UTF-8 encoding. */ @@ -2634,9 +2657,9 @@ dict_scan_table_name( earlier, we must allow the dot separator between the database name and the table name also to appear within a quoted identifier! InnoDB used to print a constraint as: - ... REFERENCES `databasename.tablename` ... + ... REFERENCES `databasename.tablename` ... starting from 4.0.18 it is - ... REFERENCES `databasename`.`tablename` ... */ + ... REFERENCES `databasename`.`tablename` ... */ const char* s; for (s = scan_name; *s; s++) { @@ -2753,15 +2776,15 @@ scan_more: /* Starting quote: remember the quote character. */ quote = *sptr; } else if (*sptr == '#' - || (sptr[0] == '-' && sptr[1] == '-' && - sptr[2] == ' ')) { + || (sptr[0] == '-' && sptr[1] == '-' + && sptr[2] == ' ')) { for (;;) { /* In Unix a newline is 0x0A while in Windows it is 0x0D followed by 0x0A */ if (*sptr == (char)0x0A - || *sptr == (char)0x0D - || *sptr == '\0') { + || *sptr == (char)0x0D + || *sptr == '\0') { goto scan_more; } @@ -2818,14 +2841,15 @@ dict_table_get_highest_foreign_id( while (foreign) { if (ut_strlen(foreign->id) > ((sizeof dict_ibfk) - 1) + len - && 0 == ut_memcmp(foreign->id, table->name, len) - && 0 == ut_memcmp(foreign->id + len, - dict_ibfk, (sizeof dict_ibfk) - 1) - && foreign->id[len + ((sizeof dict_ibfk) - 1)] != '0') { + && 0 == ut_memcmp(foreign->id, table->name, len) + && 0 == ut_memcmp(foreign->id + len, + dict_ibfk, (sizeof dict_ibfk) - 1) + && foreign->id[len + ((sizeof dict_ibfk) - 1)] != '0') { /* It is of the >= 4.0.18 format */ - id = strtoul(foreign->id + len + ((sizeof dict_ibfk) - 1), - &endp, 10); + id = strtoul(foreign->id + len + + ((sizeof dict_ibfk) - 1), + &endp, 10); if (*endp == '\0') { ut_a(id != biggest_id); @@ -2923,8 +2947,9 @@ dict_create_foreign_constraints_low( mutex_enter(&dict_foreign_err_mutex); dict_foreign_error_report_low(ef, name); fprintf(ef, -"Cannot find the table in the internal data dictionary of InnoDB.\n" -"Create table statement:\n%s\n", sql_string); + "Cannot find the table in the internal" + " data dictionary of InnoDB.\n" + "Create table statement:\n%s\n", sql_string); mutex_exit(&dict_foreign_err_mutex); return(DB_ERROR); @@ -2950,10 +2975,12 @@ dict_create_foreign_constraints_low( /* We are doing an ALTER TABLE: scan the table name we are altering */ ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name, - &success, heap, &referenced_table_name); + &success, heap, &referenced_table_name); if (!success) { fprintf(stderr, -"InnoDB: Error: could not find the table being ALTERED in:\n%s\n", sql_string); + "InnoDB: Error: could not find" + " the table being ALTERED in:\n%s\n", + sql_string); return(DB_ERROR); } @@ -2970,8 +2997,8 @@ dict_create_foreign_constraints_low( if (table_to_alter == NULL) { highest_id_so_far = 0; } else { - highest_id_so_far = dict_table_get_highest_foreign_id( - table_to_alter); + highest_id_so_far = dict_table_get_highest_foreign_id + (table_to_alter); } /* Scan for foreign key declarations in a loop */ @@ -3004,7 +3031,7 @@ loop: /* read constraint name unless got "CONSTRAINT FOREIGN" */ if (ptr != ptr2) { ptr = dict_scan_id(cs, ptr, heap, - &constraint_name, FALSE, FALSE); + &constraint_name, FALSE, FALSE); } } else { ptr = ptr2; @@ -3012,12 +3039,12 @@ loop: if (*ptr == '\0') { /* The proper way to reject foreign keys for temporary - tables would be to split the lexing and syntactical - analysis of foreign key clauses from the actual adding - of them, so that ha_innodb.cc could first parse the SQL - command, determine if there are any foreign keys, and - if so, immediately reject the command if the table is a - temporary one. For now, this kludge will work. */ + tables would be to split the lexing and syntactical + analysis of foreign key clauses from the actual adding + of them, so that ha_innodb.cc could first parse the SQL + command, determine if there are any foreign keys, and + if so, immediately reject the command if the table is a + temporary one. For now, this kludge will work. */ if (reject_fks && (UT_LIST_GET_LEN(table->foreign_list) > 0)) { return(DB_CANNOT_ADD_CONSTRAINT); @@ -3027,8 +3054,8 @@ loop: /* The following call adds the foreign key constraints to the data dictionary system tables on disk */ - error = dict_create_add_foreigns_to_dictionary( - highest_id_so_far, table, trx); + error = dict_create_add_foreigns_to_dictionary + (highest_id_so_far, table, trx); return(error); } @@ -3058,8 +3085,8 @@ loop: ptr = dict_skip_word(cs, ptr, &success); if (!success) { - dict_foreign_report_syntax_err(name, - start_of_latest_foreign, ptr); + dict_foreign_report_syntax_err + (name, start_of_latest_foreign, ptr); return(DB_CANNOT_ADD_CONSTRAINT); } @@ -3080,12 +3107,12 @@ loop: col_loop1: ut_a(i < (sizeof column_names) / sizeof *column_names); ptr = dict_scan_col(cs, ptr, &success, table, columns + i, - heap, column_names + i); + heap, column_names + i); if (!success) { mutex_enter(&dict_foreign_err_mutex); dict_foreign_error_report_low(ef, name); fprintf(ef, "%s:\nCannot resolve column name close to:\n%s\n", - start_of_latest_foreign, ptr); + start_of_latest_foreign, ptr); mutex_exit(&dict_foreign_err_mutex); return(DB_CANNOT_ADD_CONSTRAINT); @@ -3102,8 +3129,8 @@ col_loop1: ptr = dict_accept(cs, ptr, ")", &success); if (!success) { - dict_foreign_report_syntax_err(name, start_of_latest_foreign, - ptr); + dict_foreign_report_syntax_err + (name, start_of_latest_foreign, ptr); return(DB_CANNOT_ADD_CONSTRAINT); } @@ -3118,9 +3145,10 @@ col_loop1: fputs("There is no index in table ", ef); ut_print_name(ef, NULL, TRUE, name); fprintf(ef, " where the columns appear\n" -"as the first columns. Constraint:\n%s\n" -"See http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html\n" -"for correct foreign key definition.\n", + "as the first columns. Constraint:\n%s\n" + "See http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-foreign-key-constraints.html\n" + "for correct foreign key definition.\n", start_of_latest_foreign); mutex_exit(&dict_foreign_err_mutex); @@ -3129,8 +3157,8 @@ col_loop1: ptr = dict_accept(cs, ptr, "REFERENCES", &success); if (!success || !my_isspace(cs, *ptr)) { - dict_foreign_report_syntax_err(name, start_of_latest_foreign, - ptr); + dict_foreign_report_syntax_err + (name, start_of_latest_foreign, ptr); return(DB_CANNOT_ADD_CONSTRAINT); } @@ -3148,8 +3176,8 @@ col_loop1: db_len = dict_get_db_name_len(table->name); - foreign->id = mem_heap_alloc(foreign->heap, - db_len + strlen(constraint_name) + 2); + foreign->id = mem_heap_alloc + (foreign->heap, db_len + strlen(constraint_name) + 2); ut_memcpy(foreign->id, table->name, db_len); foreign->id[db_len] = '/'; @@ -3158,18 +3186,18 @@ col_loop1: foreign->foreign_table = table; foreign->foreign_table_name = mem_heap_strdup(foreign->heap, - table->name); + table->name); foreign->foreign_index = index; foreign->n_fields = i; foreign->foreign_col_names = mem_heap_alloc(foreign->heap, - i * sizeof(void*)); + i * sizeof(void*)); for (i = 0; i < foreign->n_fields; i++) { - foreign->foreign_col_names[i] = - mem_heap_strdup(foreign->heap, columns[i]->name); + foreign->foreign_col_names[i] = mem_heap_strdup + (foreign->heap, columns[i]->name); } ptr = dict_scan_table_name(cs, ptr, &referenced_table, name, - &success, heap, &referenced_table_name); + &success, heap, &referenced_table_name); /* Note that referenced_table can be NULL if the user has suppressed checking of foreign key constraints! */ @@ -3192,7 +3220,7 @@ col_loop1: if (!success) { dict_foreign_free(foreign); dict_foreign_report_syntax_err(name, start_of_latest_foreign, - ptr); + ptr); return(DB_CANNOT_ADD_CONSTRAINT); } @@ -3201,7 +3229,7 @@ col_loop1: col_loop2: ptr = dict_scan_col(cs, ptr, &success, referenced_table, columns + i, - heap, column_names + i); + heap, column_names + i); i++; if (!success) { @@ -3229,7 +3257,7 @@ col_loop2: dict_foreign_free(foreign); dict_foreign_report_syntax_err(name, start_of_latest_foreign, - ptr); + ptr); return(DB_CANNOT_ADD_CONSTRAINT); } @@ -3254,8 +3282,8 @@ scan_on_conditions: if (!success) { dict_foreign_free(foreign); - dict_foreign_report_syntax_err(name, - start_of_latest_foreign, ptr); + dict_foreign_report_syntax_err + (name, start_of_latest_foreign, ptr); return(DB_CANNOT_ADD_CONSTRAINT); } @@ -3291,8 +3319,8 @@ scan_on_conditions: if (!success) { dict_foreign_free(foreign); - dict_foreign_report_syntax_err(name, - start_of_latest_foreign, ptr); + dict_foreign_report_syntax_err + (name, start_of_latest_foreign, ptr); return(DB_CANNOT_ADD_CONSTRAINT); } @@ -3311,7 +3339,7 @@ scan_on_conditions: if (!success) { dict_foreign_free(foreign); dict_foreign_report_syntax_err(name, start_of_latest_foreign, - ptr); + ptr); return(DB_CANNOT_ADD_CONSTRAINT); } @@ -3320,14 +3348,14 @@ scan_on_conditions: if (!success) { dict_foreign_free(foreign); dict_foreign_report_syntax_err(name, start_of_latest_foreign, - ptr); + ptr); return(DB_CANNOT_ADD_CONSTRAINT); } for (j = 0; j < foreign->n_fields; j++) { - if ((dict_index_get_nth_type( - foreign->foreign_index, j)->prtype) - & DATA_NOT_NULL) { + if ((dict_index_get_nth_type + (foreign->foreign_index, j)->prtype) + & DATA_NOT_NULL) { /* It is not sensible to define SET NULL if the column is not allowed to be NULL! */ @@ -3337,8 +3365,10 @@ scan_on_conditions: mutex_enter(&dict_foreign_err_mutex); dict_foreign_error_report_low(ef, name); fprintf(ef, "%s:\n" - "You have defined a SET NULL condition though some of the\n" - "columns are defined as NOT NULL.\n", start_of_latest_foreign); + "You have defined a SET NULL condition" + " though some of the\n" + "columns are defined as NOT NULL.\n", + start_of_latest_foreign); mutex_exit(&dict_foreign_err_mutex); return(DB_CANNOT_ADD_CONSTRAINT); @@ -3362,7 +3392,8 @@ try_find_index: mutex_enter(&dict_foreign_err_mutex); dict_foreign_error_report_low(ef, name); fprintf(ef, "%s:\n" -"You have twice an ON DELETE clause or twice an ON UPDATE clause.\n", + "You have twice an ON DELETE clause" + " or twice an ON UPDATE clause.\n", start_of_latest_foreign); mutex_exit(&dict_foreign_err_mutex); @@ -3375,20 +3406,28 @@ try_find_index: if (referenced_table) { index = dict_foreign_find_index(referenced_table, - column_names, i, foreign->foreign_index, TRUE); + column_names, i, + foreign->foreign_index, TRUE); if (!index) { dict_foreign_free(foreign); mutex_enter(&dict_foreign_err_mutex); dict_foreign_error_report_low(ef, name); fprintf(ef, "%s:\n" -"Cannot find an index in the referenced table where the\n" -"referenced columns appear as the first columns, or column types\n" -"in the table and the referenced table do not match for constraint.\n" -"Note that the internal storage type of ENUM and SET changed in\n" -"tables created with >= InnoDB-4.1.12, and such columns in old tables\n" -"cannot be referenced by such columns in new tables.\n" -"See http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html\n" -"for correct foreign key definition.\n", + "Cannot find an index in the" + " referenced table where the\n" + "referenced columns appear as the" + " first columns, or column types\n" + "in the table and the referenced table" + " do not match for constraint.\n" + "Note that the internal storage type of" + " ENUM and SET changed in\n" + "tables created with >= InnoDB-4.1.12," + " and such columns in old tables\n" + "cannot be referenced by such columns" + " in new tables.\n" + "See http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-foreign-key-constraints.html\n" + "for correct foreign key definition.\n", start_of_latest_foreign); mutex_exit(&dict_foreign_err_mutex); @@ -3402,11 +3441,11 @@ try_find_index: foreign->referenced_index = index; foreign->referenced_table = referenced_table; - foreign->referenced_table_name = mem_heap_strdup(foreign->heap, - referenced_table_name); + foreign->referenced_table_name + = mem_heap_strdup(foreign->heap, referenced_table_name); foreign->referenced_col_names = mem_heap_alloc(foreign->heap, - i * sizeof(void*)); + i * sizeof(void*)); for (i = 0; i < foreign->n_fields; i++) { foreign->referenced_col_names[i] = mem_heap_strdup(foreign->heap, column_names[i]); @@ -3418,8 +3457,8 @@ try_find_index: if (referenced_table) { UT_LIST_ADD_LAST(referenced_list, - referenced_table->referenced_list, - foreign); + referenced_table->referenced_list, + foreign); } goto loop; @@ -3480,9 +3519,9 @@ dict_create_foreign_constraints( str = dict_strip_comments(sql_string); heap = mem_heap_create(10000); - err = dict_create_foreign_constraints_low(trx, heap, - innobase_get_charset(trx->mysql_thd), - str, name, reject_fks); + err = dict_create_foreign_constraints_low + (trx, heap, innobase_get_charset(trx->mysql_thd), + str, name, reject_fks); mem_heap_free(heap); mem_free(str); @@ -3578,9 +3617,9 @@ loop: while (foreign != NULL) { if (0 == strcmp(foreign->id, id) - || (strchr(foreign->id, '/') - && 0 == strcmp(id, - dict_remove_db_name(foreign->id)))) { + || (strchr(foreign->id, '/') + && 0 == strcmp(id, + dict_remove_db_name(foreign->id)))) { /* Found */ break; } @@ -3592,11 +3631,11 @@ loop: mutex_enter(&dict_foreign_err_mutex); rewind(ef); ut_print_timestamp(ef); - fputs( - " Error in dropping of a foreign key constraint of table ", ef); + fputs(" Error in dropping of a foreign key constraint" + " of table ", ef); ut_print_name(ef, NULL, TRUE, table->name); fputs(",\n" - "in SQL command\n", ef); + "in SQL command\n", ef); fputs(str, ef); fputs("\nCannot find a constraint with the given id ", ef); ut_print_name(ef, NULL, FALSE, id); @@ -3614,8 +3653,8 @@ syntax_error: mutex_enter(&dict_foreign_err_mutex); rewind(ef); ut_print_timestamp(ef); - fputs( - " Syntax error in dropping of a foreign key constraint of table ", ef); + fputs(" Syntax error in dropping of a" + " foreign key constraint of table ", ef); ut_print_name(ef, NULL, TRUE, table->name); fprintf(ef, ",\n" "close to:\n%s\n in SQL command\n%s\n", ptr, str); @@ -3735,7 +3774,7 @@ dict_tree_check_search_tuple( ut_a(index); ut_a(dtuple_get_n_fields_cmp(tuple) - <= dict_index_get_n_unique_in_tree(index)); + <= dict_index_get_n_unique_in_tree(index)); return(TRUE); } #endif /* UNIV_DEBUG */ @@ -3802,8 +3841,8 @@ dict_tree_build_node_ptr( dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4, 0); rec_copy_prefix_to_dtuple(tuple, rec, ind, n_unique, heap); - dtuple_set_info_bits(tuple, dtuple_get_info_bits(tuple) | - REC_STATUS_NODE_PTR); + dtuple_set_info_bits(tuple, dtuple_get_info_bits(tuple) + | REC_STATUS_NODE_PTR); ut_ad(dtuple_check_typed(tuple)); @@ -3860,7 +3899,7 @@ dict_tree_build_data_tuple( ind = tree->tree_index; ut_ad(dict_table_is_comp(ind->table) - || n_fields <= rec_get_n_fields_old(rec)); + || n_fields <= rec_get_n_fields_old(rec)); tuple = dtuple_create(heap, n_fields); @@ -3940,8 +3979,10 @@ dict_update_statistics_low( ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: cannot calculate statistics for table %s\n" -"InnoDB: because the .ibd file is missing. For help, please refer to\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", + "InnoDB: because the .ibd file is missing. For help," + " please refer to\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n", table->name); return; @@ -3989,13 +4030,13 @@ dict_update_statistics_low( index = dict_table_get_first_index(table); - table->stat_n_rows = index->stat_n_diff_key_vals[ - dict_index_get_n_unique(index)]; + table->stat_n_rows = index->stat_n_diff_key_vals + [dict_index_get_n_unique(index)]; table->stat_clustered_index_size = index->stat_index_size; table->stat_sum_of_other_index_sizes = sum_of_index_sizes - - index->stat_index_size; + - index->stat_index_size; table->stat_initialized = TRUE; @@ -4110,15 +4151,16 @@ dict_table_print_low( dict_update_statistics_low(table, TRUE); fprintf(stderr, -"--------------------------------------\n" -"TABLE: name %s, id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n" -" COLUMNS: ", - table->name, - (ulong) ut_dulint_get_high(table->id), - (ulong) ut_dulint_get_low(table->id), - (ulong) table->n_cols, - (ulong) UT_LIST_GET_LEN(table->indexes), - (ulong) table->stat_n_rows); + "--------------------------------------\n" + "TABLE: name %s, id %lu %lu, columns %lu, indexes %lu," + " appr.rows %lu\n" + " COLUMNS: ", + table->name, + (ulong) ut_dulint_get_high(table->id), + (ulong) ut_dulint_get_low(table->id), + (ulong) table->n_cols, + (ulong) UT_LIST_GET_LEN(table->indexes), + (ulong) table->stat_n_rows); for (i = 0; i < table->n_cols - 1; i++) { dict_col_print_low(dict_table_get_nth_col(table, i)); @@ -4188,14 +4230,15 @@ dict_index_print_low( tree = index->tree; if (index->n_user_defined_cols > 0) { - n_vals = index->stat_n_diff_key_vals[ - index->n_user_defined_cols]; + n_vals = index->stat_n_diff_key_vals + [index->n_user_defined_cols]; } else { n_vals = index->stat_n_diff_key_vals[1]; } fprintf(stderr, - " INDEX: name %s, id %lu %lu, fields %lu/%lu, uniq %lu, type %lu\n" + " INDEX: name %s, id %lu %lu, fields %lu/%lu," + " uniq %lu, type %lu\n" " root page %lu, appr.key vals %lu," " leaf pages %lu, size pages %lu\n" " FIELDS: ", @@ -4260,7 +4303,7 @@ dict_print_info_on_foreign_key_in_create_format( if (strchr(foreign->id, '/')) { /* Strip the preceding database name from the constraint id */ stripped_id = foreign->id + 1 - + dict_get_db_name_len(foreign->id); + + dict_get_db_name_len(foreign->id); } else { stripped_id = foreign->id; } @@ -4290,10 +4333,10 @@ dict_print_info_on_foreign_key_in_create_format( fputs(") REFERENCES ", file); if (dict_tables_have_same_db(foreign->foreign_table_name, - foreign->referenced_table_name)) { + foreign->referenced_table_name)) { /* Do not print the database name of the referenced table */ - ut_print_name(file, trx, TRUE, dict_remove_db_name( - foreign->referenced_table_name)); + ut_print_name(file, trx, TRUE, dict_remove_db_name + (foreign->referenced_table_name)); } else { /* Look for the '/' in the table name */ @@ -4303,10 +4346,10 @@ dict_print_info_on_foreign_key_in_create_format( } ut_print_namel(file, trx, TRUE, - foreign->referenced_table_name, i); + foreign->referenced_table_name, i); putc('.', file); ut_print_name(file, trx, TRUE, - foreign->referenced_table_name + i + 1); + foreign->referenced_table_name + i + 1); } putc(' ', file); @@ -4314,7 +4357,7 @@ dict_print_info_on_foreign_key_in_create_format( for (i = 0;;) { ut_print_name(file, trx, FALSE, - foreign->referenced_col_names[i]); + foreign->referenced_col_names[i]); if (++i < foreign->n_fields) { fputs(", ", file); } else { @@ -4377,8 +4420,8 @@ dict_print_info_on_foreign_keys( while (foreign != NULL) { if (create_table_format) { - dict_print_info_on_foreign_key_in_create_format( - file, trx, foreign, TRUE); + dict_print_info_on_foreign_key_in_create_format + (file, trx, foreign, TRUE); } else { ulint i; fputs("; (", file); @@ -4389,12 +4432,12 @@ dict_print_info_on_foreign_keys( } ut_print_name(file, trx, FALSE, - foreign->foreign_col_names[i]); + foreign->foreign_col_names[i]); } fputs(") REFER ", file); ut_print_name(file, trx, TRUE, - foreign->referenced_table_name); + foreign->referenced_table_name); putc('(', file); for (i = 0; i < foreign->n_fields; i++) { @@ -4402,7 +4445,8 @@ dict_print_info_on_foreign_keys( putc(' ', file); } ut_print_name(file, trx, FALSE, - foreign->referenced_col_names[i]); + foreign->referenced_col_names + [i]); } putc(')', file); diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c index 58900d85f67..bc393140a6f 100644 --- a/storage/innobase/dict/dict0load.c +++ b/storage/innobase/dict/dict0load.c @@ -67,7 +67,7 @@ dict_get_first_table_name_in_db( dict_index_copy_types(tuple, sys_index, 1); btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); loop: rec = btr_pcur_get_rec(&pcur); @@ -84,7 +84,7 @@ loop: field = rec_get_nth_field_old(rec, 0, &len); if (len < strlen(name) - || ut_memcmp(name, field, strlen(name)) != 0) { + || ut_memcmp(name, field, strlen(name)) != 0) { /* Not found */ btr_pcur_close(&pcur); @@ -144,7 +144,7 @@ dict_print(void) sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur, - TRUE, &mtr); + TRUE, &mtr); loop: btr_pcur_move_to_next_user_rec(&pcur, &mtr); @@ -238,7 +238,7 @@ dict_check_tablespaces_and_store_max_id( ut_a(!dict_table_is_comp(sys_tables)); btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur, - TRUE, &mtr); + TRUE, &mtr); loop: btr_pcur_move_to_next_user_rec(&pcur, &mtr); @@ -254,7 +254,7 @@ loop: known space id */ /* printf("Biggest space id in data dictionary %lu\n", - max_space_id); */ + max_space_id); */ fil_set_max_space_id_if_bigger(max_space_id); mutex_exit(&(dict_sys->mutex)); @@ -284,7 +284,7 @@ loop: exists; print a warning to the .err log if not */ fil_space_for_table_exists_in_mem(space_id, name, - FALSE, TRUE, TRUE); + FALSE, TRUE, TRUE); } if (space_id != 0 && !in_crash_recovery) { @@ -292,7 +292,7 @@ loop: object and check that the .ibd file exists. */ fil_open_single_table_tablespace(FALSE, space_id, - name); + name); } mem_free(name); @@ -355,7 +355,7 @@ dict_load_columns( dict_index_copy_types(tuple, sys_index, 1); btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); for (i = 0; i < table->n_cols - DATA_N_SYS_COLS; i++) { rec = btr_pcur_get_rec(&pcur); @@ -372,9 +372,8 @@ dict_load_columns( ut_ad(len == 4); ut_a(i == mach_read_from_4(field)); - ut_a(0 == ut_strcmp("NAME", - dict_field_get_col( - dict_index_get_nth_field(sys_index, 4))->name)); + ut_a(!strcmp("NAME", dict_field_get_col + (dict_index_get_nth_field(sys_index, 4))->name)); field = rec_get_nth_field_old(rec, 4, &len); name = mem_heap_strdupl(heap, (char*) field, len); @@ -386,36 +385,37 @@ dict_load_columns( prtype = mach_read_from_4(field); if (dtype_get_charset_coll(prtype) == 0 - && dtype_is_string_type(mtype)) { + && dtype_is_string_type(mtype)) { /* The table was created with < 4.1.2. */ if (dtype_is_binary_string_type(mtype, prtype)) { /* Use the binary collation for string columns of binary type. */ - prtype = dtype_form_prtype(prtype, - DATA_MYSQL_BINARY_CHARSET_COLL); + prtype = dtype_form_prtype + (prtype, + DATA_MYSQL_BINARY_CHARSET_COLL); } else { /* Use the default charset for other than binary columns. */ - prtype = dtype_form_prtype(prtype, - data_mysql_default_charset_coll); + prtype = dtype_form_prtype + (prtype, + data_mysql_default_charset_coll); } } field = rec_get_nth_field_old(rec, 7, &len); col_len = mach_read_from_4(field); - ut_a(0 == ut_strcmp("PREC", - dict_field_get_col( - dict_index_get_nth_field(sys_index, 8))->name)); + ut_a(!strcmp("PREC", dict_field_get_col + (dict_index_get_nth_field(sys_index, 8))->name)); field = rec_get_nth_field_old(rec, 8, &len); prec = mach_read_from_4(field); dict_mem_table_add_col(table, name, mtype, prtype, col_len, - prec); + prec); btr_pcur_move_to_next_user_rec(&pcur, &mtr); } @@ -488,7 +488,7 @@ dict_load_fields( dict_index_copy_types(tuple, sys_index, 1); btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); for (i = 0; i < index->n_fields; i++) { rec = btr_pcur_get_rec(&pcur); @@ -516,24 +516,24 @@ dict_load_fields( pos_and_prefix_len = mach_read_from_4(field); ut_a((pos_and_prefix_len & 0xFFFFUL) == i - || (pos_and_prefix_len & 0xFFFF0000UL) == (i << 16)); + || (pos_and_prefix_len & 0xFFFF0000UL) == (i << 16)); if ((i == 0 && pos_and_prefix_len > 0) - || (pos_and_prefix_len & 0xFFFF0000UL) > 0) { + || (pos_and_prefix_len & 0xFFFF0000UL) > 0) { prefix_len = pos_and_prefix_len & 0xFFFFUL; } else { prefix_len = 0; } - ut_a(0 == ut_strcmp("COL_NAME", - dict_field_get_col( - dict_index_get_nth_field(sys_index, 4))->name)); + ut_a(!strcmp("COL_NAME", dict_field_get_col + (dict_index_get_nth_field(sys_index, 4))->name)); field = rec_get_nth_field_old(rec, 4, &len); - dict_mem_index_add_field(index, - mem_heap_strdupl(heap, (char*) field, len), prefix_len); + dict_mem_index_add_field(index, mem_heap_strdupl + (heap, (char*) field, len), + prefix_len); btr_pcur_move_to_next_user_rec(&pcur, &mtr); } @@ -579,7 +579,7 @@ dict_load_indexes( #endif /* UNIV_SYNC_DEBUG */ if ((ut_dulint_get_high(table->id) == 0) - && (ut_dulint_get_low(table->id) < DICT_HDR_FIRST_ID)) { + && (ut_dulint_get_low(table->id) < DICT_HDR_FIRST_ID)) { is_sys_table = TRUE; } else { is_sys_table = FALSE; @@ -601,7 +601,7 @@ dict_load_indexes( dict_index_copy_types(tuple, sys_index, 1); btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); for (;;) { if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { @@ -619,7 +619,7 @@ dict_load_indexes( if (rec_get_deleted_flag(rec, 0)) { dict_load_report_deleted_index(table->name, - ULINT_UNDEFINED); + ULINT_UNDEFINED); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -631,9 +631,8 @@ dict_load_indexes( ut_ad(len == 8); id = mach_read_from_8(field); - ut_a(0 == ut_strcmp("NAME", - dict_field_get_col( - dict_index_get_nth_field(sys_index, 4))->name)); + ut_a(!strcmp("NAME", dict_field_get_col + (dict_index_get_nth_field(sys_index, 4))->name)); field = rec_get_nth_field_old(rec, 4, &name_len); name_buf = mem_heap_strdupl(heap, (char*) field, name_len); @@ -647,9 +646,8 @@ dict_load_indexes( field = rec_get_nth_field_old(rec, 7, &len); space = mach_read_from_4(field); - ut_a(0 == ut_strcmp("PAGE_NO", - dict_field_get_col( - dict_index_get_nth_field(sys_index, 8))->name)); + ut_a(!strcmp("PAGE_NO", dict_field_get_col + (dict_index_get_nth_field(sys_index, 8))->name)); field = rec_get_nth_field_old(rec, 8, &len); page_no = mach_read_from_4(field); @@ -657,8 +655,9 @@ dict_load_indexes( if (page_no == FIL_NULL) { fprintf(stderr, - "InnoDB: Error: trying to load index %s for table %s\n" - "InnoDB: but the index tree has been freed!\n", + "InnoDB: Error: trying to load index %s" + " for table %s\n" + "InnoDB: but the index tree has been freed!\n", name_buf, table->name); btr_pcur_close(&pcur); @@ -668,11 +667,13 @@ dict_load_indexes( } if ((type & DICT_CLUSTERED) == 0 - && NULL == dict_table_get_first_index(table)) { + && NULL == dict_table_get_first_index(table)) { fprintf(stderr, - "InnoDB: Error: trying to load index %s for table %s\n" - "InnoDB: but the first index is not clustered!\n", + "InnoDB: Error: trying to load index %s" + " for table %s\n" + "InnoDB: but the first index" + " is not clustered!\n", name_buf, table->name); btr_pcur_close(&pcur); @@ -682,17 +683,17 @@ dict_load_indexes( } if (is_sys_table - && ((type & DICT_CLUSTERED) + && ((type & DICT_CLUSTERED) || ((table == dict_sys->sys_tables) - && (name_len == (sizeof "ID_IND") - 1) - && (0 == ut_memcmp(name_buf, "ID_IND", - name_len))))) { + && (name_len == (sizeof "ID_IND") - 1) + && (0 == ut_memcmp(name_buf, "ID_IND", + name_len))))) { /* The index was created in memory already at booting of the database server */ } else { index = dict_mem_index_create(table->name, name_buf, - space, type, n_fields); + space, type, n_fields); index->id = id; dict_load_fields(table, index, heap); @@ -762,13 +763,13 @@ dict_load_table( dict_index_copy_types(tuple, sys_index, 1); btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); rec = btr_pcur_get_rec(&pcur); if (!btr_pcur_is_on_user_rec(&pcur, &mtr) - || rec_get_deleted_flag(rec, 0)) { + || rec_get_deleted_flag(rec, 0)) { /* Not found */ - err_exit: +err_exit: btr_pcur_close(&pcur); mtr_commit(&mtr); mem_heap_free(heap); @@ -784,9 +785,8 @@ dict_load_table( goto err_exit; } - ut_a(0 == ut_strcmp("SPACE", - dict_field_get_col( - dict_index_get_nth_field(sys_index, 9))->name)); + ut_a(!strcmp("SPACE", dict_field_get_col + (dict_index_get_nth_field(sys_index, 9))->name)); field = rec_get_nth_field_old(rec, 9, &len); space = mach_read_from_4(field); @@ -794,7 +794,7 @@ dict_load_table( /* Check if the tablespace exists and has the right name */ if (space != 0) { if (fil_space_for_table_exists_in_mem(space, name, FALSE, - FALSE, FALSE)) { + FALSE, FALSE)) { /* Ok; (if we did a crash recovery then the tablespace can already be in the memory cache) */ } else { @@ -804,12 +804,13 @@ dict_load_table( ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: error: space object of table %s,\n" -"InnoDB: space id %lu did not exist in memory. Retrying an open.\n", - name, (ulong)space); + " InnoDB: error: space object of table %s,\n" + "InnoDB: space id %lu did not exist in memory." + " Retrying an open.\n", + name, (ulong)space); /* Try to open the tablespace */ if (!fil_open_single_table_tablespace(TRUE, - space, name)) { + space, name)) { /* We failed to find a sensible tablespace file */ @@ -818,9 +819,8 @@ dict_load_table( } } - ut_a(0 == ut_strcmp("N_COLS", - dict_field_get_col( - dict_index_get_nth_field(sys_index, 4))->name)); + ut_a(!strcmp("N_COLS", dict_field_get_col + (dict_index_get_nth_field(sys_index, 4))->name)); field = rec_get_nth_field_old(rec, 4, &len); n_cols = mach_read_from_4(field); @@ -833,13 +833,12 @@ dict_load_table( } table = dict_mem_table_create(name, space, n_cols & ~0x80000000UL, - flags); + flags); table->ibd_file_missing = ibd_file_missing; - ut_a(0 == ut_strcmp("ID", - dict_field_get_col( - dict_index_get_nth_field(sys_index, 3))->name)); + ut_a(!strcmp("ID", dict_field_get_col + (dict_index_get_nth_field(sys_index, 3))->name)); field = rec_get_nth_field_old(rec, 3, &len); table->id = mach_read_from_8(field); @@ -863,7 +862,7 @@ dict_load_table( dict_load_indexes(table, heap); err = dict_load_foreigns(table->name, TRUE); -/* +#if 0 if (err != DB_SUCCESS) { mutex_enter(&dict_foreign_err_mutex); @@ -871,16 +870,22 @@ dict_load_table( ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: could not make a foreign key definition to match\n" -"InnoDB: the foreign key table or the referenced table!\n" -"InnoDB: The data dictionary of InnoDB is corrupt. You may need to drop\n" -"InnoDB: and recreate the foreign key table or the referenced table.\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n" -"InnoDB: Latest foreign key error printout:\n%s\n", dict_foreign_err_buf); + " InnoDB: Error: could not make a foreign key" + " definition to match\n" + "InnoDB: the foreign key table" + " or the referenced table!\n" + "InnoDB: The data dictionary of InnoDB is corrupt." + " You may need to drop\n" + "InnoDB: and recreate the foreign key table" + " or the referenced table.\n" + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n" + "InnoDB: Latest foreign key error printout:\n%s\n", + dict_foreign_err_buf); mutex_exit(&dict_foreign_err_mutex); } -*/ +#endif /* 0 */ mem_heap_free(heap); return(table); @@ -920,8 +925,8 @@ dict_load_table_on_id( /*---------------------------------------------------*/ /* Get the secondary index based on ID for table SYS_TABLES */ sys_tables = dict_sys->sys_tables; - sys_table_ids = dict_table_get_next_index( - dict_table_get_first_index(sys_tables)); + sys_table_ids = dict_table_get_next_index + (dict_table_get_first_index(sys_tables)); ut_a(!dict_table_is_comp(sys_tables)); heap = mem_heap_create(256); @@ -935,11 +940,11 @@ dict_load_table_on_id( dict_index_copy_types(tuple, sys_table_ids, 1); btr_pcur_open_on_user_rec(sys_table_ids, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); rec = btr_pcur_get_rec(&pcur); if (!btr_pcur_is_on_user_rec(&pcur, &mtr) - || rec_get_deleted_flag(rec, 0)) { + || rec_get_deleted_flag(rec, 0)) { /* Not found */ btr_pcur_close(&pcur); @@ -1008,8 +1013,8 @@ static void dict_load_foreign_cols( /*===================*/ - const char* id, /* in: foreign constraint id as a null- - terminated string */ + const char* id, /* in: foreign constraint id as a + null-terminated string */ dict_foreign_t* foreign)/* in: foreign constraint object */ { dict_table_t* sys_foreign_cols; @@ -1027,11 +1032,11 @@ dict_load_foreign_cols( ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ - foreign->foreign_col_names = mem_heap_alloc(foreign->heap, - foreign->n_fields * sizeof(void*)); + foreign->foreign_col_names = mem_heap_alloc + (foreign->heap, foreign->n_fields * sizeof(void*)); - foreign->referenced_col_names = mem_heap_alloc(foreign->heap, - foreign->n_fields * sizeof(void*)); + foreign->referenced_col_names = mem_heap_alloc + (foreign->heap, foreign->n_fields * sizeof(void*)); mtr_start(&mtr); sys_foreign_cols = dict_table_get_low("SYS_FOREIGN_COLS"); @@ -1045,7 +1050,7 @@ dict_load_foreign_cols( dict_index_copy_types(tuple, sys_index, 1); btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); for (i = 0; i < foreign->n_fields; i++) { rec = btr_pcur_get_rec(&pcur); @@ -1062,12 +1067,12 @@ dict_load_foreign_cols( ut_a(i == mach_read_from_4(field)); field = rec_get_nth_field_old(rec, 4, &len); - foreign->foreign_col_names[i] = - mem_heap_strdupl(foreign->heap, (char*) field, len); + foreign->foreign_col_names[i] = mem_heap_strdupl + (foreign->heap, (char*) field, len); field = rec_get_nth_field_old(rec, 5, &len); - foreign->referenced_col_names[i] = - mem_heap_strdupl(foreign->heap, (char*) field, len); + foreign->referenced_col_names[i] = mem_heap_strdupl + (foreign->heap, (char*) field, len); btr_pcur_move_to_next_user_rec(&pcur, &mtr); } @@ -1085,7 +1090,8 @@ dict_load_foreign( /* out: DB_SUCCESS or error code */ const char* id, /* in: foreign constraint id as a null-terminated string */ - ibool check_charsets)/* in: TRUE=check charset compatibility */ + ibool check_charsets) + /* in: TRUE=check charset compatibility */ { dict_foreign_t* foreign; dict_table_t* sys_foreign; @@ -1118,11 +1124,11 @@ dict_load_foreign( dict_index_copy_types(tuple, sys_index, 1); btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); rec = btr_pcur_get_rec(&pcur); if (!btr_pcur_is_on_user_rec(&pcur, &mtr) - || rec_get_deleted_flag(rec, 0)) { + || rec_get_deleted_flag(rec, 0)) { /* Not found */ fprintf(stderr, @@ -1159,8 +1165,8 @@ dict_load_foreign( foreign = dict_mem_foreign_create(); - foreign->n_fields = - mach_read_from_4(rec_get_nth_field_old(rec, 5, &len)); + foreign->n_fields = mach_read_from_4 + (rec_get_nth_field_old(rec, 5, &len)); ut_a(len == 4); @@ -1172,12 +1178,12 @@ dict_load_foreign( foreign->id = mem_heap_strdup(foreign->heap, id); field = rec_get_nth_field_old(rec, 3, &len); - foreign->foreign_table_name = - mem_heap_strdupl(foreign->heap, (char*) field, len); + foreign->foreign_table_name = mem_heap_strdupl + (foreign->heap, (char*) field, len); field = rec_get_nth_field_old(rec, 4, &len); - foreign->referenced_table_name = - mem_heap_strdupl(foreign->heap, (char*) field, len); + foreign->referenced_table_name = mem_heap_strdupl + (foreign->heap, (char*) field, len); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -1239,7 +1245,8 @@ dict_load_foreigns( /* No foreign keys defined yet in this database */ fprintf(stderr, - "InnoDB: Error: no foreign key system tables in the database\n"); + "InnoDB: Error: no foreign key system tables" + " in the database\n"); return(DB_ERROR); } @@ -1250,8 +1257,8 @@ dict_load_foreigns( /* Get the secondary index based on FOR_NAME from table SYS_FOREIGN */ - sec_index = dict_table_get_next_index( - dict_table_get_first_index(sys_foreign)); + sec_index = dict_table_get_next_index + (dict_table_get_first_index(sys_foreign)); start_load: heap = mem_heap_create(256); @@ -1262,7 +1269,7 @@ start_load: dict_index_copy_types(tuple, sec_index, 1); btr_pcur_open_on_user_rec(sec_index, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); loop: rec = btr_pcur_get_rec(&pcur); @@ -1283,8 +1290,8 @@ loop: charset-collation, in a case-insensitive way. */ if (0 != cmp_data_data(dfield_get_type(dfield), - dfield_get_data(dfield), dfield_get_len(dfield), - field, len)) { + dfield_get_data(dfield), dfield_get_len(dfield), + field, len)) { goto load_next_index; } diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c index 42bf39078d1..a6a42dd0411 100644 --- a/storage/innobase/dict/dict0mem.c +++ b/storage/innobase/dict/dict0mem.c @@ -65,7 +65,7 @@ dict_mem_table_create( table->cached = FALSE; table->cols = mem_heap_alloc(heap, (n_cols + DATA_N_SYS_COLS) - * sizeof(dict_col_t)); + * sizeof(dict_col_t)); UT_LIST_INIT(table->indexes); table->auto_inc_lock = mem_heap_alloc(heap, lock_get_size()); @@ -177,9 +177,9 @@ dict_mem_index_create( index->n_def = index->n_nullable = 0; index->n_fields = n_fields; index->fields = mem_heap_alloc(heap, 1 + n_fields - * sizeof(dict_field_t)); - /* The '1 +' above prevents allocation - of an empty mem block */ + * sizeof(dict_field_t)); + /* The '1 +' above prevents allocation + of an empty mem block */ index->stat_n_diff_key_vals = NULL; index->cached = FALSE; diff --git a/storage/innobase/eval/eval0eval.c b/storage/innobase/eval/eval0eval.c index 79f889a39ee..18408832e91 100644 --- a/storage/innobase/eval/eval0eval.c +++ b/storage/innobase/eval/eval0eval.c @@ -44,7 +44,7 @@ eval_node_alloc_val_buf( byte* data; ut_ad(que_node_get_type(node) == QUE_NODE_SYMBOL - || que_node_get_type(node) == QUE_NODE_FUNC); + || que_node_get_type(node) == QUE_NODE_FUNC); dfield = que_node_get_val(node); @@ -81,7 +81,7 @@ eval_node_free_val_buf( byte* data; ut_ad(que_node_get_type(node) == QUE_NODE_SYMBOL - || que_node_get_type(node) == QUE_NODE_FUNC); + || que_node_get_type(node) == QUE_NODE_FUNC); dfield = que_node_get_val(node); @@ -115,7 +115,7 @@ eval_cmp( arg2 = que_node_get_next(arg1); res = cmp_dfield_dfield(que_node_get_val(arg1), - que_node_get_val(arg2)); + que_node_get_val(arg2)); val = TRUE; func = cmp_node->func; @@ -317,7 +317,7 @@ eval_predefined_2( if (!eval_node_get_ibool_val(arg1)) { fputs("SQL assertion fails in a stored procedure!\n", - stderr); + stderr); } ut_a(eval_node_get_ibool_val(arg1)); @@ -333,10 +333,10 @@ eval_predefined_2( ut_ad(len2 >= len1); if (len2 > len1) { - int_val = (lint)(len1 + - (eval_rnd % (len2 - len1 + 1))); + int_val = (lint) (len1 + + (eval_rnd % (len2 - len1 + 1))); } else { - int_val = (lint)len1; + int_val = (lint) len1; } eval_rnd = ut_rnd_gen_next_ulint(eval_rnd); @@ -385,7 +385,7 @@ eval_notfound( if (cursor->token_type == SYM_LIT) { ut_ad(ut_memcmp(dfield_get_data(que_node_get_val(cursor)), - "SQL", 3) == 0); + "SQL", 3) == 0); sel_node = cursor->sym_table->query_graph->last_sel_node; } else { @@ -466,7 +466,7 @@ eval_replstr( len2 = (ulint)eval_node_get_int_val(arg4); if ((dfield_get_len(que_node_get_val(arg1)) < len1 + len2) - || (dfield_get_len(que_node_get_val(arg2)) < len2)) { + || (dfield_get_len(que_node_get_val(arg2)) < len2)) { ut_error; } @@ -741,19 +741,20 @@ eval_predefined( uint_val = (ulint) int_val; } for (tmp = int_len; uint_val > 0; uint_val /= 10) { - data[--tmp] = (byte) ('0' + (byte)(uint_val % 10)); + data[--tmp] = (byte) + ('0' + (byte)(uint_val % 10)); } } dfield_set_len((dfield_t*) que_node_get_val(func_node), - int_len); + int_len); return; } else if (func == PARS_TO_NUMBER_TOKEN) { int_val = atoi((char*) - dfield_get_data(que_node_get_val(arg1))); + dfield_get_data(que_node_get_val(arg1))); } else if (func == PARS_SYSDATE_TOKEN) { int_val = (lint)ut_time(); @@ -793,9 +794,9 @@ eval_func( values, except for eval_cmp and notfound */ if ((dfield_get_len(que_node_get_val(arg)) == UNIV_SQL_NULL) - && (class != PARS_FUNC_CMP) - && (func != PARS_NOTFOUND_TOKEN) - && (func != PARS_PRINTF_TOKEN)) { + && (class != PARS_FUNC_CMP) + && (func != PARS_NOTFOUND_TOKEN) + && (func != PARS_PRINTF_TOKEN)) { ut_error; } diff --git a/storage/innobase/eval/eval0proc.c b/storage/innobase/eval/eval0proc.c index 96b8ef75955..3b3a42d56ef 100644 --- a/storage/innobase/eval/eval0proc.c +++ b/storage/innobase/eval/eval0proc.c @@ -51,7 +51,8 @@ if_step( for (;;) { eval_exp(elsif_node->cond); - if (eval_node_get_ibool_val(elsif_node->cond)) { + if (eval_node_get_ibool_val + (elsif_node->cond)) { /* The condition evaluated to TRUE: start execution from the first @@ -104,7 +105,7 @@ while_step( ut_ad(que_node_get_type(node) == QUE_NODE_WHILE); ut_ad((thr->prev_node == que_node_get_parent(node)) - || (que_node_get_next(thr->prev_node) == NULL)); + || (que_node_get_next(thr->prev_node) == NULL)); /* Evaluate the condition */ @@ -192,8 +193,8 @@ for_step( loop_var_value = eval_node_get_int_val(node->loop_start_limit); - node->loop_end_value = eval_node_get_int_val( - node->loop_end_limit); + node->loop_end_value + = eval_node_get_int_val(node->loop_end_limit); } /* Check if we should do another loop */ diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c index 722ffc12743..e0a9955f8fb 100644 --- a/storage/innobase/fil/fil0fil.c +++ b/storage/innobase/fil/fil0fil.c @@ -470,8 +470,8 @@ fil_node_create( if (!space) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: Could not find tablespace %lu for\n" -"InnoDB: file ", (ulong) id); + " InnoDB: Error: Could not find tablespace %lu for\n" + "InnoDB: file ", (ulong) id); ut_print_filename(stderr, name); fputs(" in the tablespace memory cache.\n", stderr); mem_free(node->name); @@ -529,9 +529,9 @@ fil_node_open_file( os_file_read() in Windows to read from a file opened for async I/O! */ - node->handle = os_file_create_simple_no_error_handling( - node->name, OS_FILE_OPEN, - OS_FILE_READ_ONLY, &success); + node->handle = os_file_create_simple_no_error_handling + (node->name, + OS_FILE_OPEN, OS_FILE_READ_ONLY, &success); if (!success) { /* The following call prints an error message */ os_file_get_last_error(TRUE); @@ -539,8 +539,9 @@ fil_node_open_file( ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Fatal error: cannot open %s\n." -"InnoDB: Have you deleted .ibd files under a running mysqld server?\n", + " InnoDB: Fatal error: cannot open %s\n." + "InnoDB: Have you deleted .ibd files" + " under a running mysqld server?\n", node->name); ut_a(0); } @@ -548,7 +549,7 @@ fil_node_open_file( os_file_get_size(node->handle, &size_low, &size_high); size_bytes = (((ib_longlong)size_high) << 32) - + (ib_longlong)size_low; + + (ib_longlong)size_low; #ifdef UNIV_HOTBACKUP node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE); @@ -558,10 +559,15 @@ fil_node_open_file( if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) { fprintf(stderr, -"InnoDB: Error: the size of single-table tablespace file %s\n" -"InnoDB: is only %lu %lu, should be at least %lu!\n", node->name, - (ulong) size_high, - (ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE)); + "InnoDB: Error: the size of single-table" + " tablespace file %s\n" + "InnoDB: is only %lu %lu," + " should be at least %lu!\n", + node->name, + (ulong) size_high, + (ulong) size_low, + (ulong) (FIL_IBD_FILE_INITIAL_SIZE + * UNIV_PAGE_SIZE)); ut_a(0); } @@ -574,7 +580,7 @@ fil_node_open_file( page = ut_align(buf2, UNIV_PAGE_SIZE); success = os_file_read(node->handle, page, 0, 0, - UNIV_PAGE_SIZE); + UNIV_PAGE_SIZE); space_id = fsp_header_get_space_id(page); ut_free(buf2); @@ -585,24 +591,27 @@ fil_node_open_file( if (space_id == ULINT_UNDEFINED || space_id == 0) { fprintf(stderr, -"InnoDB: Error: tablespace id %lu in file %s is not sensible\n", - (ulong) space_id, - node->name); + "InnoDB: Error: tablespace id %lu" + " in file %s is not sensible\n", + (ulong) space_id, node->name); ut_a(0); } if (space_id != space->id) { fprintf(stderr, -"InnoDB: Error: tablespace id is %lu in the data dictionary\n" -"InnoDB: but in file %s it is %lu!\n", space->id, node->name, space_id); + "InnoDB: Error: tablespace id is %lu" + " in the data dictionary\n" + "InnoDB: but in file %s it is %lu!\n", + space->id, node->name, space_id); ut_a(0); } if (size_bytes >= FSP_EXTENT_SIZE * UNIV_PAGE_SIZE) { - node->size = (ulint) ((size_bytes / (1024 * 1024)) - * ((1024 * 1024) / UNIV_PAGE_SIZE)); + node->size = (ulint) + ((size_bytes / (1024 * 1024)) + * ((1024 * 1024) / UNIV_PAGE_SIZE)); } else { node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE); } @@ -618,14 +627,14 @@ fil_node_open_file( if (space->purpose == FIL_LOG) { node->handle = os_file_create(node->name, OS_FILE_OPEN, - OS_FILE_AIO, OS_LOG_FILE, &ret); + OS_FILE_AIO, OS_LOG_FILE, &ret); } else if (node->is_raw_disk) { node->handle = os_file_create(node->name, - OS_FILE_OPEN_RAW, - OS_FILE_AIO, OS_DATA_FILE, &ret); + OS_FILE_OPEN_RAW, + OS_FILE_AIO, OS_DATA_FILE, &ret); } else { node->handle = os_file_create(node->name, OS_FILE_OPEN, - OS_FILE_AIO, OS_DATA_FILE, &ret); + OS_FILE_AIO, OS_DATA_FILE, &ret); } ut_a(ret); @@ -704,12 +713,13 @@ fil_try_to_close_file_in_LRU( if (print_info) { fprintf(stderr, -"InnoDB: fil_sys open file LRU len %lu\n", (ulong) UT_LIST_GET_LEN(system->LRU)); + "InnoDB: fil_sys open file LRU len %lu\n", + (ulong) UT_LIST_GET_LEN(system->LRU)); } while (node != NULL) { if (node->modification_counter == node->flush_counter - && node->n_pending_flushes == 0) { + && node->n_pending_flushes == 0) { fil_node_close_file(node, system); @@ -724,7 +734,7 @@ fil_try_to_close_file_in_LRU( } if (print_info - && node->modification_counter != node->flush_counter) { + && node->modification_counter != node->flush_counter) { fputs("InnoDB: cannot close file ", stderr); ut_print_filename(stderr, node->name); fprintf(stderr, @@ -778,7 +788,7 @@ retry: } HASH_SEARCH(hash, system->spaces, space_id, space, - space->id == space_id); + space->id == space_id); if (space != NULL && space->stop_ios) { /* We are going to do a rename file and want to stop new i/o's for a while */ @@ -831,10 +841,13 @@ close_more: if (count >= 2) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Warning: too many (%lu) files stay open while the maximum\n" -"InnoDB: allowed value would be %lu.\n" -"InnoDB: You may need to raise the value of innodb_max_files_open in\n" -"InnoDB: my.cnf.\n", (ulong) system->n_open, (ulong) system->max_n_open); + " InnoDB: Warning: too many (%lu) files stay open" + " while the maximum\n" + "InnoDB: allowed value would be %lu.\n" + "InnoDB: You may need to raise the value of" + " innodb_max_files_open in\n" + "InnoDB: my.cnf.\n", + (ulong) system->n_open, (ulong) system->max_n_open); return; } @@ -882,13 +895,13 @@ fil_node_free( node->modification_counter = node->flush_counter; if (space->is_in_unflushed_spaces - && fil_space_is_flushed(space)) { + && fil_space_is_flushed(space)) { space->is_in_unflushed_spaces = FALSE; UT_LIST_REMOVE(unflushed_spaces, - system->unflushed_spaces, - space); + system->unflushed_spaces, + space); } fil_node_close_file(node, system); @@ -955,7 +968,7 @@ fil_space_create( try_again: /*printf( "InnoDB: Adding tablespace %lu of name %s, purpose %lu\n", id, name, - purpose);*/ + purpose);*/ ut_a(system); ut_a(name); @@ -963,16 +976,18 @@ try_again: mutex_enter(&(system->mutex)); HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(name), space, - 0 == strcmp(name, space->name)); + 0 == strcmp(name, space->name)); if (space != NULL) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Warning: trying to init to the tablespace memory cache\n" -"InnoDB: a tablespace %lu of name ", (ulong) id); + " InnoDB: Warning: trying to init to the" + " tablespace memory cache\n" + "InnoDB: a tablespace %lu of name ", (ulong) id); ut_print_filename(stderr, name); fprintf(stderr, ",\n" -"InnoDB: but a tablespace %lu of the same name\n" -"InnoDB: already exists in the tablespace memory cache!\n", + "InnoDB: but a tablespace %lu of the same name\n" + "InnoDB: already exists in the" + " tablespace memory cache!\n", (ulong) space->id); if (id == 0 || purpose != FIL_TABLESPACE) { @@ -983,13 +998,19 @@ try_again: } fprintf(stderr, -"InnoDB: We assume that InnoDB did a crash recovery, and you had\n" -"InnoDB: an .ibd file for which the table did not exist in the\n" -"InnoDB: InnoDB internal data dictionary in the ibdata files.\n" -"InnoDB: We assume that you later removed the .ibd and .frm files,\n" -"InnoDB: and are now trying to recreate the table. We now remove the\n" -"InnoDB: conflicting tablespace object from the memory cache and try\n" -"InnoDB: the init again.\n"); + "InnoDB: We assume that InnoDB did a crash recovery," + " and you had\n" + "InnoDB: an .ibd file for which the table" + " did not exist in the\n" + "InnoDB: InnoDB internal data dictionary in the" + " ibdata files.\n" + "InnoDB: We assume that you later removed the" + " .ibd and .frm files,\n" + "InnoDB: and are now trying to recreate the table." + " We now remove the\n" + "InnoDB: conflicting tablespace object" + " from the memory cache and try\n" + "InnoDB: the init again.\n"); namesake_id = space->id; @@ -1004,14 +1025,16 @@ try_again: if (space != NULL) { fprintf(stderr, -"InnoDB: Error: trying to add tablespace %lu of name ", (ulong) id); + "InnoDB: Error: trying to add tablespace %lu" + " of name ", (ulong) id); ut_print_filename(stderr, name); fprintf(stderr, "\n" -"InnoDB: to the tablespace memory cache, but tablespace\n" -"InnoDB: %lu of name ", (ulong) space->id); + "InnoDB: to the tablespace memory cache," + " but tablespace\n" + "InnoDB: %lu of name ", (ulong) space->id); ut_print_filename(stderr, space->name); fputs(" already exists in the tablespace\n" -"InnoDB: memory cache!\n", stderr); + "InnoDB: memory cache!\n", stderr); mutex_exit(&(system->mutex)); @@ -1052,7 +1075,7 @@ try_again: HASH_INSERT(fil_space_t, hash, system->spaces, id, space); HASH_INSERT(fil_space_t, name_hash, system->name_hash, - ut_fold_string(name), space); + ut_fold_string(name), space); space->is_in_unflushed_spaces = FALSE; UT_LIST_ADD_LAST(space_list, system->space_list, space); @@ -1085,20 +1108,27 @@ fil_assign_new_space_id(void) if (id > (SRV_LOG_SPACE_FIRST_ID / 2) && (id % 1000000UL == 0)) { ut_print_timestamp(stderr); fprintf(stderr, -"InnoDB: Warning: you are running out of new single-table tablespace id's.\n" -"InnoDB: Current counter is %lu and it must not exceed %lu!\n" -"InnoDB: To reset the counter to zero you have to dump all your tables and\n" -"InnoDB: recreate the whole InnoDB installation.\n", (ulong) id, - (ulong) SRV_LOG_SPACE_FIRST_ID); + "InnoDB: Warning: you are running out of new" + " single-table tablespace id's.\n" + "InnoDB: Current counter is %lu and it" + " must not exceed %lu!\n" + "InnoDB: To reset the counter to zero" + " you have to dump all your tables and\n" + "InnoDB: recreate the whole InnoDB installation.\n", + (ulong) id, + (ulong) SRV_LOG_SPACE_FIRST_ID); } if (id >= SRV_LOG_SPACE_FIRST_ID) { ut_print_timestamp(stderr); fprintf(stderr, -"InnoDB: You have run out of single-table tablespace id's!\n" -"InnoDB: Current counter is %lu.\n" -"InnoDB: To reset the counter to zero you have to dump all your tables and\n" -"InnoDB: recreate the whole InnoDB installation.\n", (ulong) id); + "InnoDB: You have run out of single-table" + " tablespace id's!\n" + "InnoDB: Current counter is %lu.\n" + "InnoDB: To reset the counter to zero you" + " have to dump all your tables and\n" + "InnoDB: recreate the whole InnoDB installation.\n", + (ulong) id); system->max_assigned_id--; id = ULINT_UNDEFINED; @@ -1132,8 +1162,9 @@ fil_space_free( if (!space) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: trying to remove tablespace %lu from the cache but\n" -"InnoDB: it is not there.\n", (ulong) id); + " InnoDB: Error: trying to remove tablespace %lu" + " from the cache but\n" + "InnoDB: it is not there.\n", (ulong) id); mutex_exit(&(system->mutex)); @@ -1143,18 +1174,18 @@ fil_space_free( HASH_DELETE(fil_space_t, hash, system->spaces, id, space); HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(space->name), - namespace, 0 == strcmp(space->name, namespace->name)); + namespace, 0 == strcmp(space->name, namespace->name)); ut_a(namespace); ut_a(space == namespace); HASH_DELETE(fil_space_t, name_hash, system->name_hash, - ut_fold_string(space->name), space); + ut_fold_string(space->name), space); if (space->is_in_unflushed_spaces) { space->is_in_unflushed_spaces = FALSE; UT_LIST_REMOVE(unflushed_spaces, system->unflushed_spaces, - space); + space); } UT_LIST_REMOVE(space_list, system->space_list, space); @@ -1359,15 +1390,26 @@ fil_open_log_and_system_tablespace_files(void) while (node != NULL) { if (!node->open) { fil_node_open_file(node, system, - space); + space); } if (system->max_n_open < 10 + system->n_open) { fprintf(stderr, -"InnoDB: Warning: you must raise the value of innodb_max_open_files in\n" -"InnoDB: my.cnf! Remember that InnoDB keeps all log files and all system\n" -"InnoDB: tablespace files open for the whole time mysqld is running, and\n" -"InnoDB: needs to open also some .ibd files if the file-per-table storage\n" -"InnoDB: model is used. Current open files %lu, max allowed open files %lu.\n", + "InnoDB: Warning: you must" + " raise the value of" + " innodb_max_open_files in\n" + "InnoDB: my.cnf! Remember that" + " InnoDB keeps all log files" + " and all system\n" + "InnoDB: tablespace files open" + " for the whole time mysqld is" + " running, and\n" + "InnoDB: needs to open also" + " some .ibd files if the" + " file-per-table storage\n" + "InnoDB: model is used." + " Current open files %lu," + " max allowed" + " open files %lu.\n", (ulong) system->n_open, (ulong) system->max_n_open); } @@ -1424,7 +1466,8 @@ fil_set_max_space_id_if_bigger( if (max_id >= SRV_LOG_SPACE_FIRST_ID) { fprintf(stderr, -"InnoDB: Fatal error: max tablespace id is too high, %lu\n", (ulong) max_id); + "InnoDB: Fatal error: max tablespace id" + " is too high, %lu\n", (ulong) max_id); ut_a(0); } @@ -1514,16 +1557,16 @@ fil_write_flushed_lsn_to_data_files( always open. */ if (space->purpose == FIL_TABLESPACE - && space->id == 0) { + && space->id == 0) { sum_of_sizes = 0; node = UT_LIST_GET_FIRST(space->chain); while (node) { mutex_exit(&(fil_system->mutex)); - err = fil_write_lsn_and_arch_no_to_file( - space->id, sum_of_sizes, - lsn, arch_log_no); + err = fil_write_lsn_and_arch_no_to_file + (space->id, sum_of_sizes, + lsn, arch_log_no); if (err != DB_SUCCESS) { return(err); @@ -1622,7 +1665,8 @@ fil_inc_pending_ibuf_merges( if (space == NULL) { fprintf(stderr, -"InnoDB: Error: trying to do ibuf merge to a dropped tablespace %lu\n", + "InnoDB: Error: trying to do ibuf merge to a" + " dropped tablespace %lu\n", (ulong) id); } @@ -1656,7 +1700,8 @@ fil_decr_pending_ibuf_merges( if (space == NULL) { fprintf(stderr, -"InnoDB: Error: decrementing ibuf merge of a dropped tablespace %lu\n", + "InnoDB: Error: decrementing ibuf merge of a" + " dropped tablespace %lu\n", (ulong) id); } @@ -1728,7 +1773,7 @@ fil_op_write_log( } log_ptr = mlog_write_initial_log_record_for_file_op(type, space_id, 0, - log_ptr, mtr); + log_ptr, mtr); /* Let us store the strings as null-terminated for easier readability and handling */ @@ -1827,14 +1872,14 @@ fil_op_log_parse_or_replay( } /* We managed to parse a full log record body */ -/* + /* printf("Parsed log rec of type %lu space %lu\n" - "name %s\n", type, space_id, name); + "name %s\n", type, space_id, name); if (type == MLOG_FILE_RENAME) { - printf("new name %s\n", new_name); + printf("new name %s\n", new_name); } -*/ + */ if (do_replay == FALSE) { return(ptr); @@ -1867,11 +1912,13 @@ fil_op_log_parse_or_replay( with the same name */ if (fil_get_space_id_for_table(new_name) - == ULINT_UNDEFINED) { + == ULINT_UNDEFINED) { /* We do not care of the old name, that is why we pass NULL as the first argument */ - ut_a(fil_rename_tablespace(NULL, space_id, - new_name)); + if (!fil_rename_tablespace(NULL, space_id, + new_name)) { + ut_error; + } } } } else { @@ -1879,8 +1926,8 @@ fil_op_log_parse_or_replay( if (fil_tablespace_exists_in_mem(space_id)) { /* Do nothing */ - } else if (fil_get_space_id_for_table(name) != - ULINT_UNDEFINED) { + } else if (fil_get_space_id_for_table(name) + != ULINT_UNDEFINED) { /* Do nothing */ } else { /* Create the database directory for name, if it does @@ -1889,10 +1936,11 @@ fil_op_log_parse_or_replay( ut_a(space_id != 0); - ut_a(DB_SUCCESS == - fil_create_new_single_table_tablespace( - &space_id, name, FALSE, - FIL_IBD_FILE_INITIAL_SIZE)); + if (fil_create_new_single_table_tablespace + (&space_id, name, FALSE, + FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) { + ut_error; + } } } @@ -1933,14 +1981,16 @@ stop_ibuf_merges: goto try_again; } else { if (count > 5000) { - ut_print_timestamp(stderr); - fputs( -" InnoDB: Warning: trying to delete tablespace ", stderr); - ut_print_filename(stderr, space->name); - fprintf(stderr, ",\n" -"InnoDB: but there are %lu pending ibuf merges on it.\n" -"InnoDB: Loop %lu.\n", (ulong) space->n_pending_ibuf_merges, - (ulong) count); + ut_print_timestamp(stderr); + fputs(" InnoDB: Warning: trying to" + " delete tablespace ", stderr); + ut_print_filename(stderr, space->name); + fprintf(stderr, ",\n" + "InnoDB: but there are %lu pending" + " ibuf merges on it.\n" + "InnoDB: Loop %lu.\n", + (ulong) space->n_pending_ibuf_merges, + (ulong) count); } mutex_exit(&(system->mutex)); @@ -1963,8 +2013,9 @@ try_again: if (space == NULL) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: cannot delete tablespace %lu\n" -"InnoDB: because it is not found in the tablespace memory cache.\n", + " InnoDB: Error: cannot delete tablespace %lu\n" + "InnoDB: because it is not found in the" + " tablespace memory cache.\n", (ulong) id); mutex_exit(&(system->mutex)); @@ -1983,12 +2034,14 @@ try_again: if (space->n_pending_flushes > 0 || node->n_pending > 0) { if (count > 1000) { ut_print_timestamp(stderr); - fputs( -" InnoDB: Warning: trying to delete tablespace ", stderr); + fputs(" InnoDB: Warning: trying to" + " delete tablespace ", stderr); ut_print_filename(stderr, space->name); fprintf(stderr, ",\n" -"InnoDB: but there are %lu flushes and %lu pending i/o's on it\n" -"InnoDB: Loop %lu.\n", (ulong) space->n_pending_flushes, + "InnoDB: but there are %lu flushes" + " and %lu pending i/o's on it\n" + "InnoDB: Loop %lu.\n", + (ulong) space->n_pending_flushes, (ulong) node->n_pending, (ulong) count); } @@ -2071,8 +2124,10 @@ fil_discard_tablespace( if (!success) { fprintf(stderr, -"InnoDB: Warning: cannot delete tablespace %lu in DISCARD TABLESPACE.\n" -"InnoDB: But let us remove the insert buffer entries for this tablespace.\n", + "InnoDB: Warning: cannot delete tablespace %lu" + " in DISCARD TABLESPACE.\n" + "InnoDB: But let us remove the" + " insert buffer entries for this tablespace.\n", (ulong) id); } @@ -2099,7 +2154,7 @@ fil_rename_tablespace_in_mem( const char* old_name = space->name; HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(old_name), - space2, 0 == strcmp(old_name, space2->name)); + space2, 0 == strcmp(old_name, space2->name)); if (space != space2) { fputs("InnoDB: Error: cannot find ", stderr); ut_print_filename(stderr, old_name); @@ -2109,7 +2164,7 @@ fil_rename_tablespace_in_mem( } HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(path), - space2, 0 == strcmp(path, space2->name)); + space2, 0 == strcmp(path, space2->name)); if (space2 != NULL) { fputs("InnoDB: Error: ", stderr); ut_print_filename(stderr, path); @@ -2119,7 +2174,7 @@ fil_rename_tablespace_in_mem( } HASH_DELETE(fil_space_t, name_hash, system->name_hash, - ut_fold_string(space->name), space); + ut_fold_string(space->name), space); mem_free(space->name); mem_free(node->name); @@ -2127,7 +2182,7 @@ fil_rename_tablespace_in_mem( node->name = mem_strdup(path); HASH_INSERT(fil_space_t, name_hash, system->name_hash, - ut_fold_string(path), space); + ut_fold_string(path), space); return(TRUE); } @@ -2213,8 +2268,9 @@ retry: if (space == NULL) { fprintf(stderr, -"InnoDB: Error: cannot find space id %lu from the tablespace memory cache\n" -"InnoDB: though the table ", (ulong) id); + "InnoDB: Error: cannot find space id %lu" + " in the tablespace memory cache\n" + "InnoDB: though the table ", (ulong) id); ut_print_filename(stderr, old_name); fputs(" in a rename operation should have that id\n", stderr); mutex_exit(&(system->mutex)); @@ -2288,7 +2344,7 @@ retry: to the tablespace memory cache */ ut_a(fil_rename_tablespace_in_mem(space, node, - old_path)); + old_path)); } } @@ -2306,7 +2362,7 @@ retry: mtr_start(&mtr); fil_op_write_log(MLOG_FILE_RENAME, id, old_name, new_name, - &mtr); + &mtr); mtr_commit(&mtr); } #endif @@ -2350,7 +2406,7 @@ fil_create_new_single_table_tablespace( path = fil_make_ibd_name(tablename, is_temp); file = os_file_create(path, OS_FILE_CREATE, OS_FILE_NORMAL, - OS_DATA_FILE, &ret); + OS_DATA_FILE, &ret); if (ret == FALSE) { ut_print_timestamp(stderr); fputs(" InnoDB: Error creating file ", stderr); @@ -2362,16 +2418,22 @@ fil_create_new_single_table_tablespace( err = os_file_get_last_error(TRUE); if (err == OS_FILE_ALREADY_EXISTS) { - fputs( -"InnoDB: The file already exists though the corresponding table did not\n" -"InnoDB: exist in the InnoDB data dictionary. Have you moved InnoDB\n" -"InnoDB: .ibd files around without using the SQL commands\n" -"InnoDB: DISCARD TABLESPACE and IMPORT TABLESPACE, or did\n" -"InnoDB: mysqld crash in the middle of CREATE TABLE? You can\n" -"InnoDB: resolve the problem by removing the file ", stderr); + fputs("InnoDB: The file already exists though" + " the corresponding table did not\n" + "InnoDB: exist in the InnoDB data dictionary." + " Have you moved InnoDB\n" + "InnoDB: .ibd files around without using the" + " SQL commands\n" + "InnoDB: DISCARD TABLESPACE and" + " IMPORT TABLESPACE, or did\n" + "InnoDB: mysqld crash in the middle of" + " CREATE TABLE? You can\n" + "InnoDB: resolve the problem by" + " removing the file ", stderr); ut_print_filename(stderr, path); fputs("\n" -"InnoDB: under the 'datadir' of MySQL.\n", stderr); + "InnoDB: under the 'datadir' of MySQL.\n", + stderr); mem_free(path); return(DB_TABLESPACE_ALREADY_EXISTS); @@ -2410,9 +2472,9 @@ fil_create_new_single_table_tablespace( if (*space_id == ULINT_UNDEFINED) { ut_free(buf2); - error_exit: +error_exit: os_file_close(file); - error_exit2: +error_exit2: os_file_delete(path); mem_free(path); @@ -2439,8 +2501,8 @@ fil_create_new_single_table_tablespace( ut_free(buf2); if (!ret) { - fputs( -"InnoDB: Error: could not write the first page to tablespace ", stderr); + fputs("InnoDB: Error: could not write the first page" + " to tablespace ", stderr); ut_print_filename(stderr, path); putc('\n', stderr); goto error_exit; @@ -2449,8 +2511,7 @@ fil_create_new_single_table_tablespace( ret = os_file_flush(file); if (!ret) { - fputs( -"InnoDB: Error: file flush of tablespace ", stderr); + fputs("InnoDB: Error: file flush of tablespace ", stderr); ut_print_filename(stderr, path); fputs(" failed\n", stderr); goto error_exit; @@ -2472,13 +2533,14 @@ fil_create_new_single_table_tablespace( #ifndef UNIV_HOTBACKUP { - mtr_t mtr; + mtr_t mtr; - mtr_start(&mtr); + mtr_start(&mtr); - fil_op_write_log(MLOG_FILE_CREATE, *space_id, tablename, NULL, &mtr); + fil_op_write_log(MLOG_FILE_CREATE, *space_id, tablename, + NULL, &mtr); - mtr_commit(&mtr); + mtr_commit(&mtr); } #endif mem_free(path); @@ -2518,17 +2580,17 @@ fil_reset_too_high_lsns( filepath = fil_make_ibd_name(name, FALSE); - file = os_file_create_simple_no_error_handling(filepath, OS_FILE_OPEN, - OS_FILE_READ_WRITE, &success); + file = os_file_create_simple_no_error_handling + (filepath, OS_FILE_OPEN, OS_FILE_READ_WRITE, &success); if (!success) { /* The following call prints an error message */ os_file_get_last_error(TRUE); ut_print_timestamp(stderr); - fputs( -" InnoDB: Error: trying to open a table, but could not\n" -"InnoDB: open the tablespace file ", stderr); + fputs(" InnoDB: Error: trying to open a table," + " but could not\n" + "InnoDB: open the tablespace file ", stderr); ut_print_filename(stderr, filepath); fputs("!\n", stderr); mem_free(filepath); @@ -2563,9 +2625,11 @@ fil_reset_too_high_lsns( ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Flush lsn in the tablespace file %lu to be imported\n" -"InnoDB: is %lu %lu, which exceeds current system lsn %lu %lu.\n" -"InnoDB: We reset the lsn's in the file ", + " InnoDB: Flush lsn in the tablespace file %lu" + " to be imported\n" + "InnoDB: is %lu %lu, which exceeds current" + " system lsn %lu %lu.\n" + "InnoDB: We reset the lsn's in the file ", (ulong) space_id, (ulong) ut_dulint_get_high(flush_lsn), (ulong) ut_dulint_get_low(flush_lsn), @@ -2581,8 +2645,8 @@ fil_reset_too_high_lsns( for (offset = 0; offset < file_size; offset += UNIV_PAGE_SIZE) { success = os_file_read(file, page, - (ulint)(offset & 0xFFFFFFFFUL), - (ulint)(offset >> 32), UNIV_PAGE_SIZE); + (ulint)(offset & 0xFFFFFFFFUL), + (ulint)(offset >> 32), UNIV_PAGE_SIZE); if (!success) { goto func_exit; @@ -2590,15 +2654,16 @@ fil_reset_too_high_lsns( if (ut_dulint_cmp(mach_read_from_8(page + FIL_PAGE_LSN), current_lsn) > 0) { /* We have to reset the lsn */ - space_id = mach_read_from_4(page - + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); + space_id = mach_read_from_4 + (page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); page_no = mach_read_from_4(page + FIL_PAGE_OFFSET); buf_flush_init_for_writing(page, current_lsn, space_id, - page_no); + page_no); success = os_file_write(filepath, file, page, - (ulint)(offset & 0xFFFFFFFFUL), - (ulint)(offset >> 32), UNIV_PAGE_SIZE); + (ulint)(offset & 0xFFFFFFFFUL), + (ulint)(offset >> 32), + UNIV_PAGE_SIZE); if (!success) { goto func_exit; @@ -2670,26 +2735,30 @@ fil_open_single_table_tablespace( filepath = fil_make_ibd_name(name, FALSE); - file = os_file_create_simple_no_error_handling(filepath, OS_FILE_OPEN, - OS_FILE_READ_ONLY, &success); + file = os_file_create_simple_no_error_handling + (filepath, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success); if (!success) { /* The following call prints an error message */ os_file_get_last_error(TRUE); ut_print_timestamp(stderr); - fputs( -" InnoDB: Error: trying to open a table, but could not\n" -"InnoDB: open the tablespace file ", stderr); + fputs(" InnoDB: Error: trying to open a table," + " but could not\n" + "InnoDB: open the tablespace file ", stderr); ut_print_filename(stderr, filepath); fputs("!\n" -"InnoDB: Have you moved InnoDB .ibd files around without using the\n" -"InnoDB: commands DISCARD TABLESPACE and IMPORT TABLESPACE?\n" -"InnoDB: It is also possible that this is a temporary table #sql...,\n" -"InnoDB: and MySQL removed the .ibd file for this.\n" -"InnoDB: Please refer to\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" -"InnoDB: for how to resolve the issue.\n", stderr); + "InnoDB: Have you moved InnoDB .ibd files around" + " without using the\n" + "InnoDB: commands DISCARD TABLESPACE and" + " IMPORT TABLESPACE?\n" + "InnoDB: It is also possible that this is" + " a temporary table #sql...,\n" + "InnoDB: and MySQL removed the .ibd file for this.\n" + "InnoDB: Please refer to\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n" + "InnoDB: for how to resolve the issue.\n", stderr); mem_free(filepath); @@ -2719,16 +2788,19 @@ fil_open_single_table_tablespace( if (space_id != id) { ut_print_timestamp(stderr); - fputs( -" InnoDB: Error: tablespace id in file ", stderr); + fputs(" InnoDB: Error: tablespace id in file ", stderr); ut_print_filename(stderr, filepath); fprintf(stderr, " is %lu, but in the InnoDB\n" -"InnoDB: data dictionary it is %lu.\n" -"InnoDB: Have you moved InnoDB .ibd files around without using the\n" -"InnoDB: commands DISCARD TABLESPACE and IMPORT TABLESPACE?\n" -"InnoDB: Please refer to\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" -"InnoDB: for how to resolve the issue.\n", (ulong) space_id, (ulong) id); + "InnoDB: data dictionary it is %lu.\n" + "InnoDB: Have you moved InnoDB .ibd files" + " around without using the\n" + "InnoDB: commands DISCARD TABLESPACE and" + " IMPORT TABLESPACE?\n" + "InnoDB: Please refer to\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n" + "InnoDB: for how to resolve the issue.\n", + (ulong) space_id, (ulong) id); ret = FALSE; @@ -2799,10 +2871,10 @@ fil_load_single_table_tablespace( fil_space_t* space; #endif filepath = mem_alloc(strlen(dbname) + strlen(filename) - + strlen(fil_path_to_mysql_datadir) + 3); + + strlen(fil_path_to_mysql_datadir) + 3); sprintf(filepath, "%s/%s/%s", fil_path_to_mysql_datadir, dbname, - filename); + filename); srv_normalize_path_for_win(filepath); #ifdef __WIN__ # ifndef UNIV_HOTBACKUP @@ -2815,34 +2887,46 @@ fil_load_single_table_tablespace( dict_casedn_str(filepath); # endif /* !UNIV_HOTBACKUP */ #endif - file = os_file_create_simple_no_error_handling(filepath, OS_FILE_OPEN, - OS_FILE_READ_ONLY, &success); + file = os_file_create_simple_no_error_handling + (filepath, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success); if (!success) { /* The following call prints an error message */ os_file_get_last_error(TRUE); fprintf(stderr, -"InnoDB: Error: could not open single-table tablespace file\n" -"InnoDB: %s!\n" -"InnoDB: We do not continue the crash recovery, because the table may become\n" -"InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.\n" -"InnoDB: To fix the problem and start mysqld:\n" -"InnoDB: 1) If there is a permission problem in the file and mysqld cannot\n" -"InnoDB: open the file, you should modify the permissions.\n" -"InnoDB: 2) If the table is not needed, or you can restore it from a backup,\n" -"InnoDB: then you can remove the .ibd file, and InnoDB will do a normal\n" -"InnoDB: crash recovery and ignore that table.\n" -"InnoDB: 3) If the file system or the disk is broken, and you cannot remove\n" -"InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf\n" -"InnoDB: and force InnoDB to continue crash recovery here.\n", filepath); + "InnoDB: Error: could not open single-table tablespace" + " file\n" + "InnoDB: %s!\n" + "InnoDB: We do not continue the crash recovery," + " because the table may become\n" + "InnoDB: corrupt if we cannot apply the log records" + " in the InnoDB log to it.\n" + "InnoDB: To fix the problem and start mysqld:\n" + "InnoDB: 1) If there is a permission problem" + " in the file and mysqld cannot\n" + "InnoDB: open the file, you should" + " modify the permissions.\n" + "InnoDB: 2) If the table is not needed, or you can" + " restore it from a backup,\n" + "InnoDB: then you can remove the .ibd file," + " and InnoDB will do a normal\n" + "InnoDB: crash recovery and ignore that table.\n" + "InnoDB: 3) If the file system or the" + " disk is broken, and you cannot remove\n" + "InnoDB: the .ibd file, you can set" + " innodb_force_recovery > 0 in my.cnf\n" + "InnoDB: and force InnoDB to continue crash" + " recovery here.\n", filepath); mem_free(filepath); if (srv_force_recovery > 0) { fprintf(stderr, -"InnoDB: innodb_force_recovery was set to %lu. Continuing crash recovery\n" -"InnoDB: even though we cannot access the .ibd file of this table.\n", - srv_force_recovery); + "InnoDB: innodb_force_recovery" + " was set to %lu. Continuing crash recovery\n" + "InnoDB: even though we cannot access" + " the .ibd file of this table.\n", + srv_force_recovery); return; } @@ -2856,28 +2940,40 @@ fil_load_single_table_tablespace( os_file_get_last_error(TRUE); fprintf(stderr, -"InnoDB: Error: could not measure the size of single-table tablespace file\n" -"InnoDB: %s!\n" -"InnoDB: We do not continue crash recovery, because the table will become\n" -"InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.\n" -"InnoDB: To fix the problem and start mysqld:\n" -"InnoDB: 1) If there is a permission problem in the file and mysqld cannot\n" -"InnoDB: access the file, you should modify the permissions.\n" -"InnoDB: 2) If the table is not needed, or you can restore it from a backup,\n" -"InnoDB: then you can remove the .ibd file, and InnoDB will do a normal\n" -"InnoDB: crash recovery and ignore that table.\n" -"InnoDB: 3) If the file system or the disk is broken, and you cannot remove\n" -"InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf\n" -"InnoDB: and force InnoDB to continue crash recovery here.\n", filepath); + "InnoDB: Error: could not measure the size" + " of single-table tablespace file\n" + "InnoDB: %s!\n" + "InnoDB: We do not continue crash recovery," + " because the table will become\n" + "InnoDB: corrupt if we cannot apply the log records" + " in the InnoDB log to it.\n" + "InnoDB: To fix the problem and start mysqld:\n" + "InnoDB: 1) If there is a permission problem" + " in the file and mysqld cannot\n" + "InnoDB: access the file, you should" + " modify the permissions.\n" + "InnoDB: 2) If the table is not needed," + " or you can restore it from a backup,\n" + "InnoDB: then you can remove the .ibd file," + " and InnoDB will do a normal\n" + "InnoDB: crash recovery and ignore that table.\n" + "InnoDB: 3) If the file system or the disk is broken," + " and you cannot remove\n" + "InnoDB: the .ibd file, you can set" + " innodb_force_recovery > 0 in my.cnf\n" + "InnoDB: and force InnoDB to continue" + " crash recovery here.\n", filepath); os_file_close(file); mem_free(filepath); if (srv_force_recovery > 0) { fprintf(stderr, -"InnoDB: innodb_force_recovery was set to %lu. Continuing crash recovery\n" -"InnoDB: even though we cannot access the .ibd file of this table.\n", - srv_force_recovery); + "InnoDB: innodb_force_recovery" + " was set to %lu. Continuing crash recovery\n" + "InnoDB: even though we cannot access" + " the .ibd file of this table.\n", + srv_force_recovery); return; } @@ -2894,8 +2990,10 @@ fil_load_single_table_tablespace( #ifndef UNIV_HOTBACKUP if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) { fprintf(stderr, -"InnoDB: Error: the size of single-table tablespace file %s\n" -"InnoDB: is only %lu %lu, should be at least %lu!", filepath, + "InnoDB: Error: the size of single-table tablespace" + " file %s\n" + "InnoDB: is only %lu %lu, should be at least %lu!", + filepath, (ulong) size_high, (ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE)); os_file_close(file); @@ -2923,7 +3021,8 @@ fil_load_single_table_tablespace( #ifndef UNIV_HOTBACKUP if (space_id == ULINT_UNDEFINED || space_id == 0) { fprintf(stderr, -"InnoDB: Error: tablespace id %lu in file %s is not sensible\n", + "InnoDB: Error: tablespace id %lu in file %s" + " is not sensible\n", (ulong) space_id, filepath); goto func_exit; @@ -2933,12 +3032,15 @@ fil_load_single_table_tablespace( char* new_path; fprintf(stderr, -"InnoDB: Renaming tablespace %s of id %lu,\n" -"InnoDB: to %s_ibbackup_old_vers_\n" -"InnoDB: because its size %lld is too small (< 4 pages 16 kB each),\n" -"InnoDB: or the space id in the file header is not sensible.\n" -"InnoDB: This can happen in an ibbackup run, and is not dangerous.\n", - filepath, space_id, filepath, size); + "InnoDB: Renaming tablespace %s of id %lu,\n" + "InnoDB: to %s_ibbackup_old_vers_\n" + "InnoDB: because its size %lld is too small" + " (< 4 pages 16 kB each),\n" + "InnoDB: or the space id in the file header" + " is not sensible.\n" + "InnoDB: This can happen in an ibbackup run," + " and is not dangerous.\n", + filepath, space_id, filepath, size); os_file_close(file); new_path = fil_make_ibbackup_old_name(filepath); @@ -2966,12 +3068,14 @@ fil_load_single_table_tablespace( char* new_path; fprintf(stderr, -"InnoDB: Renaming tablespace %s of id %lu,\n" -"InnoDB: to %s_ibbackup_old_vers_\n" -"InnoDB: because space %s with the same id\n" -"InnoDB: was scanned earlier. This can happen if you have renamed tables\n" -"InnoDB: during an ibbackup run.\n", filepath, space_id, filepath, - space->name); + "InnoDB: Renaming tablespace %s of id %lu,\n" + "InnoDB: to %s_ibbackup_old_vers_\n" + "InnoDB: because space %s with the same id\n" + "InnoDB: was scanned earlier. This can happen" + " if you have renamed tables\n" + "InnoDB: during an ibbackup run.\n", + filepath, space_id, filepath, + space->name); os_file_close(file); new_path = fil_make_ibbackup_old_name(filepath); @@ -3034,9 +3138,11 @@ fil_file_readdir_next_file( } fprintf(stderr, -"InnoDB: Error: os_file_readdir_next_file() returned -1 in\n" -"InnoDB: directory %s\n" -"InnoDB: Crash recovery may have failed for some .ibd files!\n", dirname); + "InnoDB: Error: os_file_readdir_next_file()" + " returned -1 in\n" + "InnoDB: directory %s\n" + "InnoDB: Crash recovery may have failed" + " for some .ibd files!\n", dirname); *err = DB_ERROR; } @@ -3081,13 +3187,13 @@ fil_load_single_table_tablespaces(void) directories of MySQL. */ ret = fil_file_readdir_next_file(&err, fil_path_to_mysql_datadir, dir, - &dbinfo); + &dbinfo); while (ret == 0) { ulint len; /* printf("Looking at %s in datadir\n", dbinfo.name); */ if (dbinfo.type == OS_FILE_TYPE_FILE - || dbinfo.type == OS_FILE_TYPE_UNKNOWN) { + || dbinfo.type == OS_FILE_TYPE_UNKNOWN) { goto next_datadir_item; } @@ -3096,7 +3202,7 @@ fil_load_single_table_tablespaces(void) if a symlink is a directory */ len = strlen(fil_path_to_mysql_datadir) - + strlen (dbinfo.name) + 2; + + strlen (dbinfo.name) + 2; if (len > dbpath_len) { dbpath_len = len; @@ -3107,7 +3213,7 @@ fil_load_single_table_tablespaces(void) dbpath = mem_alloc(dbpath_len); } sprintf(dbpath, "%s/%s", fil_path_to_mysql_datadir, - dbinfo.name); + dbinfo.name); srv_normalize_path_for_win(dbpath); dbdir = os_file_opendir(dbpath, FALSE); @@ -3119,10 +3225,10 @@ fil_load_single_table_tablespaces(void) looking for possible .ibd files in it */ ret = fil_file_readdir_next_file(&err, dbpath, dbdir, - &fileinfo); + &fileinfo); while (ret == 0) { /* printf( - " Looking at file %s\n", fileinfo.name); */ + " Looking at file %s\n", fileinfo.name); */ if (fileinfo.type == OS_FILE_TYPE_DIR) { @@ -3131,23 +3237,23 @@ fil_load_single_table_tablespaces(void) /* We found a symlink or a file */ if (strlen(fileinfo.name) > 4 - && 0 == strcmp(fileinfo.name + - strlen(fileinfo.name) - 4, - ".ibd")) { + && 0 == strcmp(fileinfo.name + + strlen(fileinfo.name) - 4, + ".ibd")) { /* The name ends in .ibd; try opening the file */ - fil_load_single_table_tablespace( - dbinfo.name, fileinfo.name); + fil_load_single_table_tablespace + (dbinfo.name, fileinfo.name); } next_file_item: ret = fil_file_readdir_next_file(&err, - dbpath, dbdir, - &fileinfo); + dbpath, dbdir, + &fileinfo); } if (0 != os_file_closedir(dbdir)) { - fputs( -"InnoDB: Warning: could not close database directory ", stderr); + fputs("InnoDB: Warning: could not" + " close database directory ", stderr); ut_print_filename(stderr, dbpath); putc('\n', stderr); @@ -3157,15 +3263,15 @@ next_file_item: next_datadir_item: ret = fil_file_readdir_next_file(&err, - fil_path_to_mysql_datadir, - dir, &dbinfo); + fil_path_to_mysql_datadir, + dir, &dbinfo); } mem_free(dbpath); if (0 != os_file_closedir(dir)) { fprintf(stderr, -"InnoDB: Error: could not close MySQL datadir\n"); + "InnoDB: Error: could not close MySQL datadir\n"); return(DB_ERROR); } @@ -3193,11 +3299,12 @@ fil_print_orphaned_tablespaces(void) while (space) { if (space->purpose == FIL_TABLESPACE && space->id != 0 - && !space->mark) { + && !space->mark) { fputs("InnoDB: Warning: tablespace ", stderr); ut_print_filename(stderr, space->name); fprintf(stderr, " of id %lu has no matching table in\n" -"InnoDB: the InnoDB data dictionary.\n", (ulong) space->id); + "InnoDB: the InnoDB data dictionary.\n", + (ulong) space->id); } space = UT_LIST_GET_NEXT(space_list, space); @@ -3236,7 +3343,7 @@ fil_tablespace_deleted_or_being_deleted_in_mem( } if (version != ((ib_longlong)-1) - && space->tablespace_version != version) { + && space->tablespace_version != version) { mutex_exit(&(system->mutex)); return(TRUE); @@ -3323,8 +3430,8 @@ fil_space_for_table_exists_in_mem( directory path from the datadir to the file */ HASH_SEARCH(name_hash, system->name_hash, - ut_fold_string(path), namespace, - 0 == strcmp(namespace->name, path)); + ut_fold_string(path), namespace, + 0 == strcmp(namespace->name, path)); if (space && space == namespace) { /* Found */ @@ -3352,30 +3459,38 @@ fil_space_for_table_exists_in_mem( fputs(" InnoDB: Error: table ", stderr); ut_print_filename(stderr, name); fprintf(stderr, "\n" -"InnoDB: in InnoDB data dictionary has tablespace id %lu,\n" -"InnoDB: but tablespace with that id or name does not exist. Have\n" -"InnoDB: you deleted or moved .ibd files?\n" -"InnoDB: This may also be a table created with CREATE TEMPORARY TABLE\n" -"InnoDB: whose .ibd and .frm files MySQL automatically removed, but the\n" -"InnoDB: table still exists in the InnoDB internal data dictionary.\n", + "InnoDB: in InnoDB data dictionary" + " has tablespace id %lu,\n" + "InnoDB: but tablespace with that id" + " or name does not exist. Have\n" + "InnoDB: you deleted or moved .ibd files?\n" + "InnoDB: This may also be a table created with" + " CREATE TEMPORARY TABLE\n" + "InnoDB: whose .ibd and .frm files" + " MySQL automatically removed, but the\n" + "InnoDB: table still exists in the" + " InnoDB internal data dictionary.\n", (ulong) id); } else { ut_print_timestamp(stderr); fputs(" InnoDB: Error: table ", stderr); ut_print_filename(stderr, name); fprintf(stderr, "\n" -"InnoDB: in InnoDB data dictionary has tablespace id %lu,\n" -"InnoDB: but a tablespace with that id does not exist. There is\n" -"InnoDB: a tablespace of name %s and id %lu, though. Have\n" -"InnoDB: you deleted or moved .ibd files?\n", + "InnoDB: in InnoDB data dictionary has" + " tablespace id %lu,\n" + "InnoDB: but a tablespace with that id" + " does not exist. There is\n" + "InnoDB: a tablespace of name %s and id %lu," + " though. Have\n" + "InnoDB: you deleted or moved .ibd files?\n", (ulong) id, namespace->name, (ulong) namespace->id); } - error_exit: - fputs( -"InnoDB: Please refer to\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" -"InnoDB: for how to resolve the issue.\n", stderr); +error_exit: + fputs("InnoDB: Please refer to\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n" + "InnoDB: for how to resolve the issue.\n", stderr); mem_free(path); mutex_exit(&(system->mutex)); @@ -3388,14 +3503,17 @@ fil_space_for_table_exists_in_mem( fputs(" InnoDB: Error: table ", stderr); ut_print_filename(stderr, name); fprintf(stderr, "\n" -"InnoDB: in InnoDB data dictionary has tablespace id %lu,\n" -"InnoDB: but the tablespace with that id has name %s.\n" -"InnoDB: Have you deleted or moved .ibd files?\n", (ulong) id, space->name); + "InnoDB: in InnoDB data dictionary has" + " tablespace id %lu,\n" + "InnoDB: but the tablespace with that id" + " has name %s.\n" + "InnoDB: Have you deleted or moved .ibd files?\n", + (ulong) id, space->name); if (namespace != NULL) { - fputs( -"InnoDB: There is a tablespace with the right name\n" -"InnoDB: ", stderr); + fputs("InnoDB: There is a tablespace" + " with the right name\n" + "InnoDB: ", stderr); ut_print_filename(stderr, namespace->name); fprintf(stderr, ", but its id is %lu.\n", (ulong) namespace->id); @@ -3437,8 +3555,8 @@ fil_get_space_id_for_table( directory path to the file */ HASH_SEARCH(name_hash, system->name_hash, - ut_fold_string(path), namespace, - 0 == strcmp(namespace->name, path)); + ut_fold_string(path), namespace, + 0 == strcmp(namespace->name, path)); if (namespace) { id = namespace->id; } @@ -3482,7 +3600,7 @@ fil_extend_space_to_desired_size( fil_mutex_enter_and_prepare_for_io(space_id); HASH_SEARCH(hash, system->spaces, space_id, space, - space->id == space_id); + space->id == space_id); ut_a(space); if (space->size >= size_after_extend) { @@ -3504,7 +3622,7 @@ fil_extend_space_to_desired_size( /* Extend at most 64 pages at a time */ buf_size = ut_min(64, size_after_extend - start_page_no) - * UNIV_PAGE_SIZE; + * UNIV_PAGE_SIZE; buf2 = mem_alloc(buf_size + UNIV_PAGE_SIZE); buf = ut_align(buf2, UNIV_PAGE_SIZE); @@ -3512,12 +3630,12 @@ fil_extend_space_to_desired_size( while (start_page_no < size_after_extend) { ulint n_pages = ut_min(buf_size / UNIV_PAGE_SIZE, - size_after_extend - start_page_no); + size_after_extend - start_page_no); offset_high = (start_page_no - file_start_page_no) - / (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE)); + / (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE)); offset_low = ((start_page_no - file_start_page_no) - % (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE))) + % (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE))) * UNIV_PAGE_SIZE; #ifdef UNIV_HOTBACKUP success = os_file_write(node->name, node->handle, buf, @@ -3525,10 +3643,10 @@ fil_extend_space_to_desired_size( UNIV_PAGE_SIZE * n_pages); #else success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC, - node->name, node->handle, buf, - offset_low, offset_high, - UNIV_PAGE_SIZE * n_pages, - NULL, NULL); + node->name, node->handle, buf, + offset_low, offset_high, + UNIV_PAGE_SIZE * n_pages, + NULL, NULL); #endif if (success) { node->size += n_pages; @@ -3540,8 +3658,9 @@ fil_extend_space_to_desired_size( how much we were able to extend it */ n_pages = ((ulint) - (os_file_get_size_as_iblonglong(node->handle) - / UNIV_PAGE_SIZE)) - node->size; + (os_file_get_size_as_iblonglong + (node->handle) + / UNIV_PAGE_SIZE)) - node->size; node->size += n_pages; space->size += n_pages; @@ -3565,14 +3684,14 @@ fil_extend_space_to_desired_size( /* Keep the last data file size info up to date, rounded to full megabytes */ - srv_data_file_sizes[srv_n_data_files - 1] = - (node->size / pages_per_mb) * pages_per_mb; + srv_data_file_sizes[srv_n_data_files - 1] + = (node->size / pages_per_mb) * pages_per_mb; } #endif /* !UNIV_HOTBACKUP */ /* printf("Extended %s to %lu, actual size %lu pages\n", space->name, - size_after_extend, *actual_size); */ + size_after_extend, *actual_size); */ mutex_exit(&(system->mutex)); fil_flush(space_id); @@ -3612,20 +3731,23 @@ fil_extend_tablespaces_to_stored_len(void) mutex, because this is a single-threaded operation */ error = fil_read(TRUE, space->id, 0, 0, UNIV_PAGE_SIZE, buf, - NULL); + NULL); ut_a(error == DB_SUCCESS); size_in_header = fsp_get_size_low(buf); - success = fil_extend_space_to_desired_size(&actual_size, - space->id, size_in_header); + success = fil_extend_space_to_desired_size + (&actual_size, space->id, size_in_header); if (!success) { fprintf(stderr, -"InnoDB: Error: could not extend the tablespace of %s\n" -"InnoDB: to the size stored in header, %lu pages;\n" -"InnoDB: size after extension %lu pages\n" -"InnoDB: Check that you have free disk space and retry!\n", space->name, - size_in_header, actual_size); + "InnoDB: Error: could not extend the" + " tablespace of %s\n" + "InnoDB: to the size stored in header," + " %lu pages;\n" + "InnoDB: size after extension %lu pages\n" + "InnoDB: Check that you have free disk space" + " and retry!\n", + space->name, size_in_header, actual_size); exit(1); } @@ -3756,7 +3878,8 @@ fil_node_prepare_for_io( if (system->n_open > system->max_n_open + 5) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Warning: open files %lu exceeds the limit %lu\n", + " InnoDB: Warning: open files %lu" + " exceeds the limit %lu\n", (ulong) system->n_open, (ulong) system->max_n_open); } @@ -3769,7 +3892,7 @@ fil_node_prepare_for_io( } if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE - && space->id != 0) { + && space->id != 0) { /* The node is in the LRU list, remove it */ ut_a(UT_LIST_GET_LEN(system->LRU) > 0); @@ -3811,13 +3934,13 @@ fil_node_complete_io( node->space->is_in_unflushed_spaces = TRUE; UT_LIST_ADD_FIRST(unflushed_spaces, - system->unflushed_spaces, - node->space); + system->unflushed_spaces, + node->space); } } if (node->n_pending == 0 && node->space->purpose == FIL_TABLESPACE - && node->space->id != 0) { + && node->space->id != 0) { /* The node must be put back to the LRU list */ UT_LIST_ADD_FIRST(LRU, system->LRU, node); } @@ -3837,13 +3960,16 @@ fil_report_invalid_page_access( ulint type) /* in: I/O type */ { fprintf(stderr, - "InnoDB: Error: trying to access page number %lu in space %lu,\n" - "InnoDB: space name %s,\n" - "InnoDB: which is outside the tablespace bounds.\n" - "InnoDB: Byte offset %lu, len %lu, i/o type %lu.\n" - "InnoDB: If you get this error at mysqld startup, please check that\n" - "InnoDB: your my.cnf matches the ibdata files that you have in the\n" - "InnoDB: MySQL server.\n", + "InnoDB: Error: trying to access page number %lu" + " in space %lu,\n" + "InnoDB: space name %s,\n" + "InnoDB: which is outside the tablespace bounds.\n" + "InnoDB: Byte offset %lu, len %lu, i/o type %lu.\n" + "InnoDB: If you get this error at mysqld startup," + " please check that\n" + "InnoDB: your my.cnf matches the ibdata files" + " that you have in the\n" + "InnoDB: MySQL server.\n", (ulong) block_offset, (ulong) space_id, space_name, (ulong) byte_offset, (ulong) len, (ulong) type); } @@ -3905,16 +4031,16 @@ fil_io( #ifndef UNIV_LOG_DEBUG /* ibuf bitmap pages must be read in the sync aio mode: */ ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE) - || !ibuf_bitmap_page(block_offset) || sync || is_log); + || !ibuf_bitmap_page(block_offset) || sync || is_log); #ifdef UNIV_SYNC_DEBUG ut_ad(!ibuf_inside() || is_log || (type == OS_FILE_WRITE) - || ibuf_page(space_id, block_offset)); + || ibuf_page(space_id, block_offset)); #endif #endif if (sync) { mode = OS_AIO_SYNC; } else if (type == OS_FILE_READ && !is_log - && ibuf_page(space_id, block_offset)) { + && ibuf_page(space_id, block_offset)) { mode = OS_AIO_IBUF; } else if (is_log) { mode = OS_AIO_LOG; @@ -3934,14 +4060,16 @@ fil_io( fil_mutex_enter_and_prepare_for_io(space_id); HASH_SEARCH(hash, system->spaces, space_id, space, - space->id == space_id); + space->id == space_id); if (!space) { mutex_exit(&(system->mutex)); ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: trying to do i/o to a tablespace which does not exist.\n" -"InnoDB: i/o type %lu, space id %lu, page no. %lu, i/o length %lu bytes\n", + " InnoDB: Error: trying to do i/o" + " to a tablespace which does not exist.\n" + "InnoDB: i/o type %lu, space id %lu," + " page no. %lu, i/o length %lu bytes\n", (ulong) type, (ulong) space_id, (ulong) block_offset, (ulong) len); @@ -3954,8 +4082,9 @@ fil_io( for (;;) { if (node == NULL) { - fil_report_invalid_page_access(block_offset, space_id, - space->name, byte_offset, len, type); + fil_report_invalid_page_access + (block_offset, space_id, + space->name, byte_offset, len, type); ut_error; } @@ -3982,10 +4111,11 @@ fil_io( /* Check that at least the start offset is within the bounds of a single-table tablespace */ if (space->purpose == FIL_TABLESPACE && space->id != 0 - && node->size <= block_offset) { + && node->size <= block_offset) { - fil_report_invalid_page_access(block_offset, space_id, - space->name, byte_offset, len, type); + fil_report_invalid_page_access + (block_offset, space_id, + space->name, byte_offset, len, type); ut_error; } @@ -3997,10 +4127,10 @@ fil_io( offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT)); offset_low = ((block_offset << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL) - + byte_offset; + + byte_offset; - ut_a(node->size - block_offset >= - (byte_offset + len + (UNIV_PAGE_SIZE - 1)) / UNIV_PAGE_SIZE); + ut_a(node->size - block_offset + >= (byte_offset + len + (UNIV_PAGE_SIZE - 1)) / UNIV_PAGE_SIZE); /* Do aio */ @@ -4011,15 +4141,15 @@ fil_io( /* In ibbackup do normal i/o, not aio */ if (type == OS_FILE_READ) { ret = os_file_read(node->handle, buf, offset_low, offset_high, - len); + len); } else { ret = os_file_write(node->name, node->handle, buf, - offset_low, offset_high, len); + offset_low, offset_high, len); } #else /* Queue the aio request */ ret = os_aio(type, mode | wake_later, node->name, node->handle, buf, - offset_low, offset_high, len, node, message); + offset_low, offset_high, len, node, message); #endif ut_a(ret); @@ -4064,7 +4194,7 @@ fil_read( aio used, else ignored */ { return(fil_io(OS_FILE_READ, sync, space_id, block_offset, - byte_offset, len, buf, message)); + byte_offset, len, buf, message)); } /************************************************************************ @@ -4092,7 +4222,7 @@ fil_write( aio used, else ignored */ { return(fil_io(OS_FILE_WRITE, sync, space_id, block_offset, - byte_offset, len, buf, message)); + byte_offset, len, buf, message)); } /************************************************************************** @@ -4119,7 +4249,7 @@ fil_aio_wait( srv_set_io_thread_op_info(segment, "native aio handle"); #ifdef WIN_ASYNC_IO ret = os_aio_windows_handle(segment, 0, &fil_node, - &message, &type); + &message, &type); #elif defined(POSIX_ASYNC_IO) ret = os_aio_posix_handle(segment, &fil_node, &message); #else @@ -4130,7 +4260,7 @@ fil_aio_wait( srv_set_io_thread_op_info(segment, "simulated aio handle"); ret = os_aio_simulated_handle(segment, &fil_node, - &message, &type); + &message, &type); } ut_a(ret); @@ -4179,7 +4309,7 @@ fil_flush( mutex_enter(&(system->mutex)); HASH_SEARCH(hash, system->spaces, space_id, space, - space->id == space_id); + space->id == space_id); if (!space || space->is_being_deleted) { mutex_exit(&(system->mutex)); @@ -4238,7 +4368,7 @@ retry: mutex_exit(&(system->mutex)); /* fprintf(stderr, "Flushing to file %s\n", - node->name); */ + node->name); */ os_file_flush(file); @@ -4250,13 +4380,14 @@ skip_flush: node->flush_counter = old_mod_counter; if (space->is_in_unflushed_spaces - && fil_space_is_flushed(space)) { + && fil_space_is_flushed(space)) { space->is_in_unflushed_spaces = FALSE; - UT_LIST_REMOVE(unflushed_spaces, - system->unflushed_spaces, - space); + UT_LIST_REMOVE + (unflushed_spaces, + system->unflushed_spaces, + space); } } diff --git a/storage/innobase/fsp/fsp0fsp.c b/storage/innobase/fsp/fsp0fsp.c index 9b0406a1c26..4da25f4d479 100644 --- a/storage/innobase/fsp/fsp0fsp.c +++ b/storage/innobase/fsp/fsp0fsp.c @@ -135,9 +135,12 @@ typedef byte fseg_inode_t; page number within space, FIL_NULL means that the slot is not in use */ /*-------------------------------------*/ -#define FSEG_INODE_SIZE (16 + 3 * FLST_BASE_NODE_SIZE + FSEG_FRAG_ARR_N_SLOTS * FSEG_FRAG_SLOT_SIZE) +#define FSEG_INODE_SIZE \ + (16 + 3 * FLST_BASE_NODE_SIZE \ + + FSEG_FRAG_ARR_N_SLOTS * FSEG_FRAG_SLOT_SIZE) -#define FSP_SEG_INODES_PER_PAGE ((UNIV_PAGE_SIZE - FSEG_ARR_OFFSET - 10) / FSEG_INODE_SIZE) +#define FSP_SEG_INODES_PER_PAGE \ + ((UNIV_PAGE_SIZE - FSEG_ARR_OFFSET - 10) / FSEG_INODE_SIZE) /* Number of segment inodes which fit on a single page */ @@ -204,7 +207,8 @@ the extent are free and which contain old tuple version to clean. */ /* File extent data structure size in bytes. The "+ 7 ) / 8" part in the definition rounds the number of bytes upward. */ -#define XDES_SIZE (XDES_BITMAP + (FSP_EXTENT_SIZE * XDES_BITS_PER_PAGE + 7) / 8) +#define XDES_SIZE \ + (XDES_BITMAP + (FSP_EXTENT_SIZE * XDES_BITS_PER_PAGE + 7) / 8) /* Offset of the descriptor array on a descriptor page */ #define XDES_ARR_OFFSET (FSP_HEADER_OFFSET + FSP_HEADER_SIZE) @@ -351,7 +355,7 @@ xdes_get_bit( ulint bit_index; ut_ad(mtr_memo_contains(mtr, buf_block_align(descr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad((bit == XDES_FREE_BIT) || (bit == XDES_CLEAN_BIT)); ut_ad(offset < FSP_EXTENT_SIZE); @@ -360,10 +364,9 @@ xdes_get_bit( byte_index = index / 8; bit_index = index % 8; - return(ut_bit_get_nth( - mtr_read_ulint(descr + XDES_BITMAP + byte_index, - MLOG_1BYTE, mtr), - bit_index)); + return(ut_bit_get_nth(mtr_read_ulint(descr + XDES_BITMAP + byte_index, + MLOG_1BYTE, mtr), + bit_index)); } /************************************************************************** @@ -385,7 +388,7 @@ xdes_set_bit( ulint descr_byte; ut_ad(mtr_memo_contains(mtr, buf_block_align(descr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad((bit == XDES_FREE_BIT) || (bit == XDES_CLEAN_BIT)); ut_ad(offset < FSP_EXTENT_SIZE); @@ -395,11 +398,11 @@ xdes_set_bit( bit_index = index % 8; descr_byte = mtr_read_ulint(descr + XDES_BITMAP + byte_index, - MLOG_1BYTE, mtr); + MLOG_1BYTE, mtr); descr_byte = ut_bit_set_nth(descr_byte, bit_index, val); mlog_write_ulint(descr + XDES_BITMAP + byte_index, descr_byte, - MLOG_1BYTE, mtr); + MLOG_1BYTE, mtr); } /************************************************************************** @@ -424,7 +427,7 @@ xdes_find_bit( ut_ad(val <= TRUE); ut_ad(hint < FSP_EXTENT_SIZE); ut_ad(mtr_memo_contains(mtr, buf_block_align(descr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); for (i = hint; i < FSP_EXTENT_SIZE; i++) { if (val == xdes_get_bit(descr, bit, i, mtr)) { @@ -463,7 +466,7 @@ xdes_find_bit_downward( ut_ad(val <= TRUE); ut_ad(hint < FSP_EXTENT_SIZE); ut_ad(mtr_memo_contains(mtr, buf_block_align(descr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); for (i = hint + 1; i > 0; i--) { if (val == xdes_get_bit(descr, bit, i - 1, mtr)) { @@ -496,7 +499,7 @@ xdes_get_n_used( ut_ad(descr && mtr); ut_ad(mtr_memo_contains(mtr, buf_block_align(descr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); for (i = 0; i < FSP_EXTENT_SIZE; i++) { if (FALSE == xdes_get_bit(descr, XDES_FREE_BIT, i, mtr)) { count++; @@ -556,7 +559,7 @@ xdes_set_state( ut_ad(state >= XDES_FREE); ut_ad(state <= XDES_FSEG); ut_ad(mtr_memo_contains(mtr, buf_block_align(descr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); mlog_write_ulint(descr + XDES_STATE, state, MLOG_4BYTES, mtr); } @@ -573,7 +576,7 @@ xdes_get_state( { ut_ad(descr && mtr); ut_ad(mtr_memo_contains(mtr, buf_block_align(descr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); return(mtr_read_ulint(descr + XDES_STATE, MLOG_4BYTES, mtr)); } @@ -591,7 +594,7 @@ xdes_init( ut_ad(descr && mtr); ut_ad(mtr_memo_contains(mtr, buf_block_align(descr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad((XDES_SIZE - XDES_BITMAP) % 4 == 0); for (i = XDES_BITMAP; i < XDES_SIZE; i += 4) { @@ -627,8 +630,8 @@ xdes_calc_descriptor_index( /* out: descriptor index */ ulint offset) /* in: page offset */ { - return(ut_2pow_remainder(offset, XDES_DESCRIBED_PER_PAGE) / - FSP_EXTENT_SIZE); + return(ut_2pow_remainder(offset, XDES_DESCRIBED_PER_PAGE) + / FSP_EXTENT_SIZE); } /************************************************************************ @@ -659,7 +662,7 @@ xdes_get_descriptor_with_space_hdr( ut_ad(mtr); ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); /* Read free limit and space size */ limit = mtr_read_ulint(sp_header + FSP_FREE_LIMIT, MLOG_4BYTES, mtr); size = mtr_read_ulint(sp_header + FSP_SIZE, MLOG_4BYTES, mtr); @@ -685,14 +688,14 @@ xdes_get_descriptor_with_space_hdr( descr_page = buf_frame_align(sp_header); } else { descr_page = buf_page_get(space, descr_page_no, RW_X_LATCH, - mtr); + mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(descr_page, SYNC_FSP_PAGE); #endif /* UNIV_SYNC_DEBUG */ } return(descr_page + XDES_ARR_OFFSET - + XDES_SIZE * xdes_calc_descriptor_index(offset)); + + XDES_SIZE * xdes_calc_descriptor_index(offset)); } /************************************************************************ @@ -717,12 +720,12 @@ xdes_get_descriptor( fsp_header_t* sp_header; sp_header = FSP_HEADER_OFFSET - + buf_page_get(space, 0, RW_X_LATCH, mtr); + + buf_page_get(space, 0, RW_X_LATCH, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(sp_header, SYNC_FSP_PAGE); #endif /* UNIV_SYNC_DEBUG */ return(xdes_get_descriptor_with_space_hdr(sp_header, space, offset, - mtr)); + mtr)); } /************************************************************************ @@ -743,7 +746,7 @@ xdes_lst_get_descriptor( ut_ad(mtr); ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); descr = fut_get_ptr(space, lst_node, RW_X_LATCH, mtr) - XDES_FLST_NODE; return(descr); @@ -765,8 +768,8 @@ xdes_lst_get_next( space = buf_frame_get_space_id(descr); - return(xdes_lst_get_descriptor(space, - flst_get_next_addr(descr + XDES_FLST_NODE, mtr), mtr)); + return(xdes_lst_get_descriptor + (space, flst_get_next_addr(descr + XDES_FLST_NODE, mtr), mtr)); } /************************************************************************ @@ -781,9 +784,9 @@ xdes_get_offset( ut_ad(descr); return(buf_frame_get_page_no(descr) - + ((descr - buf_frame_align(descr) - XDES_ARR_OFFSET) - / XDES_SIZE) - * FSP_EXTENT_SIZE); + + ((descr - buf_frame_align(descr) - XDES_ARR_OFFSET) + / XDES_SIZE) + * FSP_EXTENT_SIZE); } /*************************************************************** @@ -803,7 +806,7 @@ fsp_init_file_page_low( memset(page, 0xff, UNIV_PAGE_SIZE); #endif mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, - ut_dulint_zero); + ut_dulint_zero); mach_write_to_8(page + FIL_PAGE_LSN, ut_dulint_zero); } @@ -893,7 +896,7 @@ fsp_header_init( fsp_init_file_page(page, mtr); mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_TYPE_FSP_HDR, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); header = FSP_HEADER_OFFSET + page; @@ -915,7 +918,7 @@ fsp_header_init( if (space == 0) { fsp_fill_free_list(FALSE, space, header, mtr); btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF, space, - ut_dulint_add(DICT_IBUF_ID_MIN, space), FALSE, mtr); + ut_dulint_add(DICT_IBUF_ID_MIN, space), FALSE, mtr); } else { fsp_fill_free_list(TRUE, space, header, mtr); } @@ -939,7 +942,8 @@ fsp_header_get_space_id( if (id != fsp_id) { fprintf(stderr, -"InnoDB: Error: space id in fsp header %lu, but in the page header %lu\n", + "InnoDB: Error: space id in fsp header %lu," + " but in the page header %lu\n", (ulong) fsp_id, (ulong) id); return(ULINT_UNDEFINED); @@ -970,7 +974,7 @@ fsp_header_inc_size( size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr); mlog_write_ulint(header + FSP_SIZE, size + size_inc, MLOG_4BYTES, - mtr); + mtr); } /************************************************************************** @@ -1062,7 +1066,7 @@ fsp_try_extend_data_file_with_pages( ut_a(page_no >= size); success = fil_extend_space_to_desired_size(&actual_size, space, - page_no + 1); + page_no + 1); /* actual_size now has the space size in pages; it may be less than we wanted if we ran out of disk space */ @@ -1107,16 +1111,18 @@ fsp_try_extend_data_file( if (space == 0 && srv_last_file_size_max != 0) { if (srv_last_file_size_max - < srv_data_file_sizes[srv_n_data_files - 1]) { + < srv_data_file_sizes[srv_n_data_files - 1]) { fprintf(stderr, -"InnoDB: Error: Last data file size is %lu, max size allowed %lu\n", - (ulong) srv_data_file_sizes[srv_n_data_files - 1], + "InnoDB: Error: Last data file size is %lu," + " max size allowed %lu\n", + (ulong) srv_data_file_sizes + [srv_n_data_files - 1], (ulong) srv_last_file_size_max); } size_increase = srv_last_file_size_max - - srv_data_file_sizes[srv_n_data_files - 1]; + - srv_data_file_sizes[srv_n_data_files - 1]; if (size_increase > SRV_AUTO_EXTEND_INCREMENT) { size_increase = SRV_AUTO_EXTEND_INCREMENT; } @@ -1131,12 +1137,13 @@ fsp_try_extend_data_file( if (size < FSP_EXTENT_SIZE) { /* Let us first extend the file to 64 pages */ - success = fsp_try_extend_data_file_with_pages( - space, FSP_EXTENT_SIZE - 1, - header, mtr); + success = fsp_try_extend_data_file_with_pages + (space, FSP_EXTENT_SIZE - 1, + header, mtr); if (!success) { - new_size = mtr_read_ulint( - header + FSP_SIZE, MLOG_4BYTES, mtr); + new_size = mtr_read_ulint + (header + FSP_SIZE, + MLOG_4BYTES, mtr); *actual_increase = new_size - old_size; @@ -1163,13 +1170,14 @@ fsp_try_extend_data_file( } success = fil_extend_space_to_desired_size(&actual_size, space, - size + size_increase); + size + size_increase); /* We ignore any fragments of a full megabyte when storing the size to the space header */ mlog_write_ulint(header + FSP_SIZE, - ut_calc_align_down(actual_size, (1024 * 1024) / UNIV_PAGE_SIZE), - MLOG_4BYTES, mtr); + ut_calc_align_down(actual_size, + (1024 * 1024) / UNIV_PAGE_SIZE), + MLOG_4BYTES, mtr); new_size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr); *actual_increase = new_size - old_size; @@ -1212,7 +1220,7 @@ fsp_fill_free_list( limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES, mtr); if (space == 0 && srv_auto_extend_last_data_file - && size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) { + && size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) { /* Try to increase the last data file size */ fsp_try_extend_data_file(&actual_increase, space, header, mtr); @@ -1220,7 +1228,7 @@ fsp_fill_free_list( } if (space != 0 && !init_space - && size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) { + && size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) { /* Try to increase the .ibd file size */ fsp_try_extend_data_file(&actual_increase, space, header, mtr); @@ -1230,17 +1238,17 @@ fsp_fill_free_list( i = limit; while ((init_space && i < 1) - || ((i + FSP_EXTENT_SIZE <= size) && (count < FSP_FREE_ADD))) { + || ((i + FSP_EXTENT_SIZE <= size) && (count < FSP_FREE_ADD))) { mlog_write_ulint(header + FSP_FREE_LIMIT, i + FSP_EXTENT_SIZE, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); /* Update the free limit info in the log system and make a checkpoint */ if (space == 0) { - log_fsp_current_free_limit_set_and_checkpoint( - (i + FSP_EXTENT_SIZE) - / ((1024 * 1024) / UNIV_PAGE_SIZE)); + log_fsp_current_free_limit_set_and_checkpoint + ((i + FSP_EXTENT_SIZE) + / ((1024 * 1024) / UNIV_PAGE_SIZE)); } if (0 == i % XDES_DESCRIBED_PER_PAGE) { @@ -1254,11 +1262,12 @@ fsp_fill_free_list( buf_page_get(space, i, RW_X_LATCH, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(descr_page, - SYNC_FSP_PAGE); + SYNC_FSP_PAGE); #endif /* UNIV_SYNC_DEBUG */ fsp_init_file_page(descr_page, mtr); mlog_write_ulint(descr_page + FIL_PAGE_TYPE, - FIL_PAGE_TYPE_XDES, MLOG_2BYTES, mtr); + FIL_PAGE_TYPE_XDES, + MLOG_2BYTES, mtr); } /* Initialize the ibuf bitmap page in a separate @@ -1269,9 +1278,10 @@ fsp_fill_free_list( mtr_start(&ibuf_mtr); ibuf_page = buf_page_create(space, - i + FSP_IBUF_BITMAP_OFFSET, &ibuf_mtr); + i + FSP_IBUF_BITMAP_OFFSET, + &ibuf_mtr); buf_page_get(space, i + FSP_IBUF_BITMAP_OFFSET, - RW_X_LATCH, &ibuf_mtr); + RW_X_LATCH, &ibuf_mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(ibuf_page, SYNC_FSP_PAGE); #endif /* UNIV_SYNC_DEBUG */ @@ -1283,7 +1293,7 @@ fsp_fill_free_list( } descr = xdes_get_descriptor_with_space_hdr(header, space, i, - mtr); + mtr); xdes_init(descr, mtr); #if XDES_DESCRIBED_PER_PAGE % FSP_EXTENT_SIZE @@ -1298,18 +1308,18 @@ fsp_fill_free_list( xdes_set_bit(descr, XDES_FREE_BIT, 0, FALSE, mtr); xdes_set_bit(descr, XDES_FREE_BIT, - FSP_IBUF_BITMAP_OFFSET, FALSE, mtr); + FSP_IBUF_BITMAP_OFFSET, FALSE, mtr); xdes_set_state(descr, XDES_FREE_FRAG, mtr); flst_add_last(header + FSP_FREE_FRAG, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); mlog_write_ulint(header + FSP_FRAG_N_USED, - frag_n_used + 2, MLOG_4BYTES, mtr); + frag_n_used + 2, MLOG_4BYTES, mtr); } else { flst_add_last(header + FSP_FREE, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); count++; } @@ -1419,7 +1429,7 @@ fsp_alloc_free_page( xdes_set_state(descr, XDES_FREE_FRAG, mtr); flst_add_last(header + FSP_FREE_FRAG, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); } else { descr = xdes_lst_get_descriptor(space, first, mtr); } @@ -1432,7 +1442,7 @@ fsp_alloc_free_page( for a free page in the extent. */ free = xdes_find_bit(descr, XDES_FREE_BIT, TRUE, - hint % FSP_EXTENT_SIZE, mtr); + hint % FSP_EXTENT_SIZE, mtr); if (free == ULINT_UNDEFINED) { ut_print_buf(stderr, ((byte*)descr) - 500, 1000); @@ -1451,13 +1461,16 @@ fsp_alloc_free_page( ut_a(space != 0); if (page_no >= FSP_EXTENT_SIZE) { fprintf(stderr, -"InnoDB: Error: trying to extend a single-table tablespace %lu\n" -"InnoDB: by single page(s) though the space size %lu. Page no %lu.\n", - (ulong) space, (ulong) space_size, (ulong) page_no); + "InnoDB: Error: trying to extend a" + " single-table tablespace %lu\n" + "InnoDB: by single page(s) though the" + " space size %lu. Page no %lu.\n", + (ulong) space, (ulong) space_size, + (ulong) page_no); return(FIL_NULL); } success = fsp_try_extend_data_file_with_pages(space, page_no, - header, mtr); + header, mtr); if (!success) { /* No disk space left */ return(FIL_NULL); @@ -1468,21 +1481,21 @@ fsp_alloc_free_page( /* Update the FRAG_N_USED field */ frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES, - mtr); + mtr); frag_n_used++; mlog_write_ulint(header + FSP_FRAG_N_USED, frag_n_used, MLOG_4BYTES, - mtr); + mtr); if (xdes_is_full(descr, mtr)) { /* The fragment is full: move it to another list */ flst_remove(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE, - mtr); + mtr); xdes_set_state(descr, XDES_FULL_FRAG, mtr); flst_add_last(header + FSP_FULL_FRAG, descr + XDES_FLST_NODE, - mtr); + mtr); mlog_write_ulint(header + FSP_FRAG_N_USED, - frag_n_used - FSP_EXTENT_SIZE, MLOG_4BYTES, - mtr); + frag_n_used - FSP_EXTENT_SIZE, MLOG_4BYTES, + mtr); } /* Initialize the allocated page to the buffer pool, so that it can @@ -1519,7 +1532,7 @@ fsp_free_page( ut_ad(mtr); -/* fprintf(stderr, "Freeing page %lu in space %lu\n", page, space); */ + /* fprintf(stderr, "Freeing page %lu in space %lu\n", page, space); */ header = fsp_get_space_header(space, mtr); @@ -1529,9 +1542,10 @@ fsp_free_page( if (state != XDES_FREE_FRAG && state != XDES_FULL_FRAG) { fprintf(stderr, -"InnoDB: Error: File space extent descriptor of page %lu has state %lu\n", - (ulong) page, - (ulong) state); + "InnoDB: Error: File space extent descriptor" + " of page %lu has state %lu\n", + (ulong) page, + (ulong) state); fputs("InnoDB: Dump of descriptor: ", stderr); ut_print_buf(stderr, ((byte*)descr) - 50, 200); putc('\n', stderr); @@ -1548,8 +1562,9 @@ fsp_free_page( if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) { fprintf(stderr, -"InnoDB: Error: File space extent descriptor of page %lu says it is free\n" -"InnoDB: Dump of descriptor: ", (ulong) page); + "InnoDB: Error: File space extent descriptor" + " of page %lu says it is free\n" + "InnoDB: Dump of descriptor: ", (ulong) page); ut_print_buf(stderr, ((byte*)descr) - 50, 200); putc('\n', stderr); @@ -1563,27 +1578,27 @@ fsp_free_page( xdes_set_bit(descr, XDES_CLEAN_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr); frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES, - mtr); + mtr); if (state == XDES_FULL_FRAG) { /* The fragment was full: move it to another list */ flst_remove(header + FSP_FULL_FRAG, descr + XDES_FLST_NODE, - mtr); + mtr); xdes_set_state(descr, XDES_FREE_FRAG, mtr); flst_add_last(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE, - mtr); + mtr); mlog_write_ulint(header + FSP_FRAG_N_USED, - frag_n_used + FSP_EXTENT_SIZE - 1, - MLOG_4BYTES, mtr); + frag_n_used + FSP_EXTENT_SIZE - 1, + MLOG_4BYTES, mtr); } else { ut_a(frag_n_used > 0); mlog_write_ulint(header + FSP_FRAG_N_USED, frag_n_used - 1, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); } if (xdes_is_free(descr, mtr)) { /* The extent has become free: move it to another list */ flst_remove(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE, - mtr); + mtr); fsp_free_extent(space, page, mtr); } } @@ -1632,7 +1647,7 @@ fsp_seg_inode_page_get_nth_inode( { ut_ad(i < FSP_SEG_INODES_PER_PAGE); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); return(page + FSEG_ARR_OFFSET + FSEG_INODE_SIZE * i); } @@ -1656,7 +1671,7 @@ fsp_seg_inode_page_find_used( inode = fsp_seg_inode_page_get_nth_inode(page, i, mtr); if (ut_dulint_cmp(mach_read_from_8(inode + FSEG_ID), - ut_dulint_zero) != 0) { + ut_dulint_zero) != 0) { /* This is used */ return(i); @@ -1686,7 +1701,7 @@ fsp_seg_inode_page_find_free( inode = fsp_seg_inode_page_get_nth_inode(page, i, mtr); if (ut_dulint_cmp(mach_read_from_8(inode + FSEG_ID), - ut_dulint_zero) == 0) { + ut_dulint_zero) == 0) { /* This is unused */ return(i); @@ -1726,7 +1741,7 @@ fsp_alloc_seg_inode_page( buf_block_align(page)->check_index_page_at_flush = FALSE; mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_INODE, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_FSP_PAGE); #endif /* UNIV_SYNC_DEBUG */ @@ -1739,7 +1754,7 @@ fsp_alloc_seg_inode_page( } flst_add_last(space_header + FSP_SEG_INODES_FREE, - page + FSEG_INODE_PAGE_NODE, mtr); + page + FSEG_INODE_PAGE_NODE, mtr); return(TRUE); } @@ -1774,7 +1789,7 @@ fsp_alloc_seg_inode( page_no = flst_get_first(space_header + FSP_SEG_INODES_FREE, mtr).page; page = buf_page_get(buf_frame_get_space_id(space_header), page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_FSP_PAGE); #endif /* UNIV_SYNC_DEBUG */ @@ -1786,15 +1801,15 @@ fsp_alloc_seg_inode( inode = fsp_seg_inode_page_get_nth_inode(page, n, mtr); if (ULINT_UNDEFINED == fsp_seg_inode_page_find_free(page, n + 1, - mtr)) { + mtr)) { /* There are no other unused headers left on the page: move it to another list */ flst_remove(space_header + FSP_SEG_INODES_FREE, - page + FSEG_INODE_PAGE_NODE, mtr); + page + FSEG_INODE_PAGE_NODE, mtr); flst_add_last(space_header + FSP_SEG_INODES_FULL, - page + FSEG_INODE_PAGE_NODE, mtr); + page + FSEG_INODE_PAGE_NODE, mtr); } return(inode); @@ -1824,10 +1839,10 @@ fsp_free_seg_inode( /* Move the page to another list */ flst_remove(space_header + FSP_SEG_INODES_FULL, - page + FSEG_INODE_PAGE_NODE, mtr); + page + FSEG_INODE_PAGE_NODE, mtr); flst_add_last(space_header + FSP_SEG_INODES_FREE, - page + FSEG_INODE_PAGE_NODE, mtr); + page + FSEG_INODE_PAGE_NODE, mtr); } mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr); @@ -1838,7 +1853,7 @@ fsp_free_seg_inode( /* There are no other used headers left on the page: free it */ flst_remove(space_header + FSP_SEG_INODES_FREE, - page + FSEG_INODE_PAGE_NODE, mtr); + page + FSEG_INODE_PAGE_NODE, mtr); fsp_free_page(space, buf_frame_get_page_no(page), mtr); } @@ -1861,7 +1876,7 @@ fseg_inode_get( inode_addr.boffset = mach_read_from_2(header + FSEG_HDR_OFFSET); inode = fut_get_ptr(mach_read_from_4(header + FSEG_HDR_SPACE), - inode_addr, RW_X_LATCH, mtr); + inode_addr, RW_X_LATCH, mtr); ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); @@ -1882,9 +1897,9 @@ fseg_get_nth_frag_page_no( ut_ad(inode && mtr); ut_ad(n < FSEG_FRAG_ARR_N_SLOTS); ut_ad(mtr_memo_contains(mtr, buf_block_align(inode), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); return(mach_read_from_4(inode + FSEG_FRAG_ARR - + n * FSEG_FRAG_SLOT_SIZE)); + + n * FSEG_FRAG_SLOT_SIZE)); } /************************************************************************** @@ -1901,10 +1916,10 @@ fseg_set_nth_frag_page_no( ut_ad(inode && mtr); ut_ad(n < FSEG_FRAG_ARR_N_SLOTS); ut_ad(mtr_memo_contains(mtr, buf_block_align(inode), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); mlog_write_ulint(inode + FSEG_FRAG_ARR + n * FSEG_FRAG_SLOT_SIZE, - page_no, MLOG_4BYTES, mtr); + page_no, MLOG_4BYTES, mtr); } /************************************************************************** @@ -1952,8 +1967,8 @@ fseg_find_last_used_frag_page_slot( ut_ad(inode && mtr); for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) { - page_no = fseg_get_nth_frag_page_no(inode, - FSEG_FRAG_ARR_N_SLOTS - i - 1, mtr); + page_no = fseg_get_nth_frag_page_no + (inode, FSEG_FRAG_ARR_N_SLOTS - i - 1, mtr); if (page_no != FIL_NULL) { @@ -2026,13 +2041,13 @@ fseg_create_general( if (page != 0) { header = byte_offset + buf_page_get(space, page, RW_X_LATCH, - mtr); + mtr); } #ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex) - || mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + || mtr_memo_contains(mtr, fil_space_get_latch(space), + MTR_MEMO_X_LOCK)); #endif /* UNIV_SYNC_DEBUG */ latch = fil_space_get_latch(space); @@ -2049,7 +2064,7 @@ fseg_create_general( if (!has_done_reservation) { success = fsp_reserve_free_extents(&n_reserved, space, 2, - FSP_NORMAL, mtr); + FSP_NORMAL, mtr); if (!success) { return(NULL); } @@ -2070,7 +2085,7 @@ fseg_create_general( seg_id = mtr_read_dulint(space_header + FSP_SEG_ID, mtr); mlog_write_dulint(space_header + FSP_SEG_ID, ut_dulint_add(seg_id, 1), - mtr); + mtr); mlog_write_dulint(inode + FSEG_ID, seg_id, mtr); mlog_write_ulint(inode + FSEG_NOT_FULL_N_USED, 0, MLOG_4BYTES, mtr); @@ -2080,7 +2095,7 @@ fseg_create_general( flst_init(inode + FSEG_FULL, mtr); mlog_write_ulint(inode + FSEG_MAGIC_N, FSEG_MAGIC_N_VALUE, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) { fseg_set_nth_frag_page_no(inode, i, FIL_NULL, mtr); } @@ -2096,16 +2111,16 @@ fseg_create_general( } header = byte_offset - + buf_page_get(space, page, RW_X_LATCH, mtr); + + buf_page_get(space, page, RW_X_LATCH, mtr); mlog_write_ulint(header - byte_offset + FIL_PAGE_TYPE, - FIL_PAGE_TYPE_SYS, MLOG_2BYTES, mtr); + FIL_PAGE_TYPE_SYS, MLOG_2BYTES, mtr); } mlog_write_ulint(header + FSEG_HDR_OFFSET, - inode - buf_frame_align(inode), MLOG_2BYTES, mtr); + inode - buf_frame_align(inode), MLOG_2BYTES, mtr); mlog_write_ulint(header + FSEG_HDR_PAGE_NO, - buf_frame_get_page_no(inode), MLOG_4BYTES, mtr); + buf_frame_get_page_no(inode), MLOG_4BYTES, mtr); mlog_write_ulint(header + FSEG_HDR_SPACE, space, MLOG_4BYTES, mtr); @@ -2157,7 +2172,7 @@ fseg_n_reserved_pages_low( ut_ad(inode && used && mtr); ut_ad(mtr_memo_contains(mtr, buf_block_align(inode), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); *used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED, MLOG_4BYTES, mtr) + FSP_EXTENT_SIZE * flst_get_len(inode + FSEG_FULL, mtr) @@ -2191,8 +2206,8 @@ fseg_n_reserved_pages( #ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex) - || mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + || mtr_memo_contains(mtr, fil_space_get_latch(space), + MTR_MEMO_X_LOCK)); #endif /* UNIV_SYNC_DEBUG */ mtr_x_lock(fil_space_get_latch(space), mtr); @@ -2244,8 +2259,8 @@ fseg_fill_free_list( for (i = 0; i < FSEG_FREE_LIST_MAX_LEN; i++) { descr = xdes_get_descriptor(space, hint, mtr); - if ((descr == NULL) || - (XDES_FREE != xdes_get_state(descr, mtr))) { + if ((descr == NULL) + || (XDES_FREE != xdes_get_state(descr, mtr))) { /* We cannot allocate the desired extent: stop */ @@ -2306,7 +2321,8 @@ fseg_alloc_free_extent( /* Try to fill the segment free list */ fseg_fill_free_list(inode, space, - xdes_get_offset(descr) + FSP_EXTENT_SIZE, mtr); + xdes_get_offset(descr) + FSP_EXTENT_SIZE, + mtr); } return(descr); @@ -2348,8 +2364,8 @@ fseg_alloc_free_page_low( ut_ad(mtr); ut_ad((direction >= FSP_UP) && (direction <= FSP_NO_DIR)); - ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == - FSEG_MAGIC_N_VALUE); + ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) + == FSEG_MAGIC_N_VALUE); seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr); ut_ad(ut_dulint_cmp(seg_id, ut_dulint_zero) > 0); @@ -2359,7 +2375,7 @@ fseg_alloc_free_page_low( space_header = fsp_get_space_header(space, mtr); descr = xdes_get_descriptor_with_space_hdr(space_header, space, - hint, mtr); + hint, mtr); if (descr == NULL) { /* Hint outside space or too high above free limit: reset hint */ @@ -2370,16 +2386,16 @@ fseg_alloc_free_page_low( /* In the big if-else below we look for ret_page and ret_descr */ /*-------------------------------------------------------------*/ if ((xdes_get_state(descr, mtr) == XDES_FSEG) - && (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, - mtr), seg_id)) - && (xdes_get_bit(descr, XDES_FREE_BIT, - hint % FSP_EXTENT_SIZE, mtr) == TRUE)) { + && (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, + mtr), seg_id)) + && (xdes_get_bit(descr, XDES_FREE_BIT, + hint % FSP_EXTENT_SIZE, mtr) == TRUE)) { /* 1. We can take the hinted page =================================*/ ret_descr = descr; ret_page = hint; - /*-------------------------------------------------------------*/ + /*-----------------------------------------------------------*/ } else if ((xdes_get_state(descr, mtr) == XDES_FREE) && ((reserved - used) < reserved / FSEG_FILLFACTOR) && (used >= FSEG_FRAG_LIMIT)) { @@ -2395,18 +2411,18 @@ fseg_alloc_free_page_low( xdes_set_state(ret_descr, XDES_FSEG, mtr); mlog_write_dulint(ret_descr + XDES_ID, seg_id, mtr); flst_add_last(seg_inode + FSEG_FREE, - ret_descr + XDES_FLST_NODE, mtr); + ret_descr + XDES_FLST_NODE, mtr); /* Try to fill the segment free list */ fseg_fill_free_list(seg_inode, space, - hint + FSP_EXTENT_SIZE, mtr); + hint + FSP_EXTENT_SIZE, mtr); ret_page = hint; - /*-------------------------------------------------------------*/ + /*-----------------------------------------------------------*/ } else if ((direction != FSP_NO_DIR) && ((reserved - used) < reserved / FSEG_FILLFACTOR) && (used >= FSEG_FRAG_LIMIT) - && (NULL != (ret_descr = - fseg_alloc_free_extent(seg_inode, space, mtr)))) { + && (!!(ret_descr + = fseg_alloc_free_extent(seg_inode, space, mtr)))) { /* 3. We take any free extent (which was already assigned above =============================================================== @@ -2419,10 +2435,10 @@ fseg_alloc_free_page_low( if (direction == FSP_DOWN) { ret_page += FSP_EXTENT_SIZE - 1; } - /*-------------------------------------------------------------*/ + /*-----------------------------------------------------------*/ } else if ((xdes_get_state(descr, mtr) == XDES_FSEG) && (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, - mtr), seg_id)) + mtr), seg_id)) && (!xdes_is_full(descr, mtr))) { /* 4. We can take the page from the same extent as the @@ -2432,10 +2448,10 @@ fseg_alloc_free_page_low( segment) ========*/ ret_descr = descr; - ret_page = xdes_get_offset(ret_descr) + - xdes_find_bit(ret_descr, XDES_FREE_BIT, TRUE, + ret_page = xdes_get_offset(ret_descr) + + xdes_find_bit(ret_descr, XDES_FREE_BIT, TRUE, hint % FSP_EXTENT_SIZE, mtr); - /*-------------------------------------------------------------*/ + /*-----------------------------------------------------------*/ } else if (reserved - used > 0) { /* 5. We take any unused page from the segment ==============================================*/ @@ -2443,7 +2459,7 @@ fseg_alloc_free_page_low( if (flst_get_len(seg_inode + FSEG_NOT_FULL, mtr) > 0) { first = flst_get_first(seg_inode + FSEG_NOT_FULL, - mtr); + mtr); } else if (flst_get_len(seg_inode + FSEG_FREE, mtr) > 0) { first = flst_get_first(seg_inode + FSEG_FREE, mtr); } else { @@ -2452,10 +2468,10 @@ fseg_alloc_free_page_low( } ret_descr = xdes_lst_get_descriptor(space, first, mtr); - ret_page = xdes_get_offset(ret_descr) + - xdes_find_bit(ret_descr, XDES_FREE_BIT, TRUE, - 0, mtr); - /*-------------------------------------------------------------*/ + ret_page = xdes_get_offset(ret_descr) + + xdes_find_bit(ret_descr, XDES_FREE_BIT, TRUE, + 0, mtr); + /*-----------------------------------------------------------*/ } else if (used < FSEG_FRAG_LIMIT) { /* 6. We allocate an individual page from the space ===================================================*/ @@ -2471,9 +2487,9 @@ fseg_alloc_free_page_low( ut_a(n != FIL_NULL); fseg_set_nth_frag_page_no(seg_inode, n, ret_page, - mtr); + mtr); } - /*-------------------------------------------------------------*/ + /*-----------------------------------------------------------*/ } else { /* 7. We allocate a new extent and take its first page ======================================================*/ @@ -2501,15 +2517,17 @@ fseg_alloc_free_page_low( if (ret_page >= FSP_EXTENT_SIZE) { fprintf(stderr, -"InnoDB: Error (2): trying to extend a single-table tablespace %lu\n" -"InnoDB: by single page(s) though the space size %lu. Page no %lu.\n", + "InnoDB: Error (2): trying to extend" + " a single-table tablespace %lu\n" + "InnoDB: by single page(s) though" + " the space size %lu. Page no %lu.\n", (ulong) space, (ulong) space_size, (ulong) ret_page); return(FIL_NULL); } - success = fsp_try_extend_data_file_with_pages(space, - ret_page, space_header, mtr); + success = fsp_try_extend_data_file_with_pages + (space, ret_page, space_header, mtr); if (!success) { /* No disk space left */ return(FIL_NULL); @@ -2539,7 +2557,7 @@ fseg_alloc_free_page_low( ut_ad(xdes_get_descriptor(space, ret_page, mtr) == ret_descr); ut_ad(xdes_get_bit(ret_descr, XDES_FREE_BIT, - ret_page % FSP_EXTENT_SIZE, mtr) == TRUE); + ret_page % FSP_EXTENT_SIZE, mtr) == TRUE); fseg_mark_page_used(seg_inode, space, ret_page, mtr); } @@ -2584,8 +2602,8 @@ fseg_alloc_free_page_general( #ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex) - || mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + || mtr_memo_contains(mtr, fil_space_get_latch(space), + MTR_MEMO_X_LOCK)); #endif /* UNIV_SYNC_DEBUG */ latch = fil_space_get_latch(space); @@ -2604,14 +2622,14 @@ fseg_alloc_free_page_general( if (!has_done_reservation) { success = fsp_reserve_free_extents(&n_reserved, space, 2, - FSP_NORMAL, mtr); + FSP_NORMAL, mtr); if (!success) { return(FIL_NULL); } } page_no = fseg_alloc_free_page_low(buf_frame_get_space_id(inode), - inode, hint, direction, mtr); + inode, hint, direction, mtr); if (!has_done_reservation) { fil_space_release_free_extents(space, n_reserved); } @@ -2639,7 +2657,7 @@ fseg_alloc_free_page( mtr_t* mtr) /* in: mtr handle */ { return(fseg_alloc_free_page_general(seg_header, hint, direction, - FALSE, mtr)); + FALSE, mtr)); } /************************************************************************** @@ -2668,7 +2686,7 @@ fsp_reserve_free_pages( ut_a(size < FSP_EXTENT_SIZE / 2); descr = xdes_get_descriptor_with_space_hdr(space_header, space, 0, - mtr); + mtr); n_used = xdes_get_n_used(descr, mtr); ut_a(n_used <= size); @@ -2679,7 +2697,7 @@ fsp_reserve_free_pages( } return(fsp_try_extend_data_file_with_pages(space, n_used + 1, - space_header, mtr)); + space_header, mtr)); } /************************************************************************** @@ -2734,8 +2752,8 @@ fsp_reserve_free_extents( ut_ad(mtr); #ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex) - || mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + || mtr_memo_contains(mtr, fil_space_get_latch(space), + MTR_MEMO_X_LOCK)); #endif /* UNIV_SYNC_DEBUG */ *n_reserved = n_ext; @@ -2756,7 +2774,7 @@ try_again: n_free_list_ext = flst_get_len(space_header + FSP_FREE, mtr); free_limit = mtr_read_ulint(space_header + FSP_FREE_LIMIT, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); /* Below we play safe when counting free extents above the free limit: some of them will contain extent descriptor pages, and therefore @@ -2767,7 +2785,7 @@ try_again: if (n_free_up > 0) { n_free_up--; n_free_up = n_free_up - n_free_up - / (XDES_DESCRIBED_PER_PAGE / FSP_EXTENT_SIZE); + / (XDES_DESCRIBED_PER_PAGE / FSP_EXTENT_SIZE); } n_free = n_free_list_ext + n_free_up; @@ -2803,7 +2821,7 @@ try_again: } try_to_extend: success = fsp_try_extend_data_file(&n_pages_added, space, - space_header, mtr); + space_header, mtr); if (success && n_pages_added > 0) { goto try_again; @@ -2850,7 +2868,7 @@ fsp_get_available_space_in_free_extents( n_free_list_ext = flst_get_len(space_header + FSP_FREE, &mtr); free_limit = mtr_read_ulint(space_header + FSP_FREE_LIMIT, - MLOG_4BYTES, &mtr); + MLOG_4BYTES, &mtr); mtr_commit(&mtr); if (size < FSP_EXTENT_SIZE) { @@ -2870,7 +2888,7 @@ fsp_get_available_space_in_free_extents( if (n_free_up > 0) { n_free_up--; n_free_up = n_free_up - n_free_up - / (XDES_DESCRIBED_PER_PAGE / FSP_EXTENT_SIZE); + / (XDES_DESCRIBED_PER_PAGE / FSP_EXTENT_SIZE); } n_free = n_free_list_ext + n_free_up; @@ -2886,7 +2904,7 @@ fsp_get_available_space_in_free_extents( } return(((n_free - reserve) * FSP_EXTENT_SIZE) - * (UNIV_PAGE_SIZE / 1024)); + * (UNIV_PAGE_SIZE / 1024)); } /************************************************************************ @@ -2908,39 +2926,39 @@ fseg_mark_page_used( descr = xdes_get_descriptor(space, page, mtr); - ut_ad(mtr_read_ulint(seg_inode + FSEG_ID, MLOG_4BYTES, mtr) == - mtr_read_ulint(descr + XDES_ID, MLOG_4BYTES, mtr)); + ut_ad(mtr_read_ulint(seg_inode + FSEG_ID, MLOG_4BYTES, mtr) + == mtr_read_ulint(descr + XDES_ID, MLOG_4BYTES, mtr)); if (xdes_is_free(descr, mtr)) { /* We move the extent from the free list to the NOT_FULL list */ flst_remove(seg_inode + FSEG_FREE, descr + XDES_FLST_NODE, - mtr); + mtr); flst_add_last(seg_inode + FSEG_NOT_FULL, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); } ut_ad(xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr) - == TRUE); + == TRUE); /* We mark the page as used */ xdes_set_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, FALSE, mtr); not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); not_full_n_used++; mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED, not_full_n_used, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); if (xdes_is_full(descr, mtr)) { /* We move the extent from the NOT_FULL list to the FULL list */ flst_remove(seg_inode + FSEG_NOT_FULL, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); flst_add_last(seg_inode + FSEG_FULL, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED, - not_full_n_used - FSP_EXTENT_SIZE, - MLOG_4BYTES, mtr); + not_full_n_used - FSP_EXTENT_SIZE, + MLOG_4BYTES, mtr); } } @@ -2963,8 +2981,8 @@ fseg_free_page_low( ulint i; ut_ad(seg_inode && mtr); - ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == - FSEG_MAGIC_N_VALUE); + ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) + == FSEG_MAGIC_N_VALUE); /* Drop search system page hash index if the page is found in the pool and is hashed */ @@ -2976,20 +2994,23 @@ fseg_free_page_low( ut_a(descr); if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) { fputs("InnoDB: Dump of the tablespace extent descriptor: ", - stderr); + stderr); ut_print_buf(stderr, descr, 40); fprintf(stderr, "\n" -"InnoDB: Serious error! InnoDB is trying to free page %lu\n" -"InnoDB: though it is already marked as free in the tablespace!\n" -"InnoDB: The tablespace free space info is corrupt.\n" -"InnoDB: You may need to dump your InnoDB tables and recreate the whole\n" -"InnoDB: database!\n", (ulong) page); - crash: - fputs( -"InnoDB: Please refer to\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" -"InnoDB: about forcing recovery.\n", stderr); + "InnoDB: Serious error! InnoDB is trying to" + " free page %lu\n" + "InnoDB: though it is already marked as free" + " in the tablespace!\n" + "InnoDB: The tablespace free space info is corrupt.\n" + "InnoDB: You may need to dump your" + " InnoDB tables and recreate the whole\n" + "InnoDB: database!\n", (ulong) page); +crash: + fputs("InnoDB: Please refer to\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "forcing-recovery.html\n" + "InnoDB: about forcing recovery.\n", stderr); ut_error; } @@ -3000,10 +3021,10 @@ fseg_free_page_low( for (i = 0;; i++) { if (fseg_get_nth_frag_page_no(seg_inode, i, mtr) - == page) { + == page) { fseg_set_nth_frag_page_no(seg_inode, i, - FIL_NULL, mtr); + FIL_NULL, mtr); break; } } @@ -3017,52 +3038,54 @@ fseg_free_page_low( descr_id = mtr_read_dulint(descr + XDES_ID, mtr); seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr); -/* +#if 0 fprintf(stderr, -"InnoDB: InnoDB is freeing space %lu page %lu,\n" -"InnoDB: which belongs to descr seg %lu %lu\n" -"InnoDB: segment %lu %lu.\n", - space, page, - ut_dulint_get_high(descr_id), - ut_dulint_get_low(descr_id), - ut_dulint_get_high(seg_id), - ut_dulint_get_low(seg_id)); -*/ + "InnoDB: InnoDB is freeing space %lu page %lu,\n" + "InnoDB: which belongs to descr seg %lu %lu\n" + "InnoDB: segment %lu %lu.\n", + (ulong) space, (ulong) page, + (ulong) ut_dulint_get_high(descr_id), + (ulong) ut_dulint_get_low(descr_id), + (ulong) ut_dulint_get_high(seg_id), + (ulong) ut_dulint_get_low(seg_id)); +#endif /* 0 */ if (0 != ut_dulint_cmp(descr_id, seg_id)) { fputs("InnoDB: Dump of the tablespace extent descriptor: ", - stderr); + stderr); ut_print_buf(stderr, descr, 40); fputs("\nInnoDB: Dump of the segment inode: ", stderr); ut_print_buf(stderr, seg_inode, 40); putc('\n', stderr); fprintf(stderr, -"InnoDB: Serious error: InnoDB is trying to free space %lu page %lu,\n" -"InnoDB: which does not belong to segment %lu %lu but belongs\n" -"InnoDB: to segment %lu %lu.\n", - (ulong) space, (ulong) page, - (ulong) ut_dulint_get_high(descr_id), - (ulong) ut_dulint_get_low(descr_id), - (ulong) ut_dulint_get_high(seg_id), - (ulong) ut_dulint_get_low(seg_id)); + "InnoDB: Serious error: InnoDB is trying to" + " free space %lu page %lu,\n" + "InnoDB: which does not belong to" + " segment %lu %lu but belongs\n" + "InnoDB: to segment %lu %lu.\n", + (ulong) space, (ulong) page, + (ulong) ut_dulint_get_high(descr_id), + (ulong) ut_dulint_get_low(descr_id), + (ulong) ut_dulint_get_high(seg_id), + (ulong) ut_dulint_get_low(seg_id)); goto crash; } not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); if (xdes_is_full(descr, mtr)) { /* The fragment is full: move it to another list */ flst_remove(seg_inode + FSEG_FULL, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); flst_add_last(seg_inode + FSEG_NOT_FULL, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED, - not_full_n_used + FSP_EXTENT_SIZE - 1, - MLOG_4BYTES, mtr); + not_full_n_used + FSP_EXTENT_SIZE - 1, + MLOG_4BYTES, mtr); } else { ut_a(not_full_n_used > 0); mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED, - not_full_n_used - 1, MLOG_4BYTES, mtr); + not_full_n_used - 1, MLOG_4BYTES, mtr); } xdes_set_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr); @@ -3071,7 +3094,7 @@ fseg_free_page_low( if (xdes_is_free(descr, mtr)) { /* The extent has become free: free it to space */ flst_remove(seg_inode + FSEG_NOT_FULL, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); fsp_free_extent(space, page, mtr); } } @@ -3091,8 +3114,8 @@ fseg_free_page( #ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex) - || mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + || mtr_memo_contains(mtr, fil_space_get_latch(space), + MTR_MEMO_X_LOCK)); #endif /* UNIV_SYNC_DEBUG */ mtr_x_lock(fil_space_get_latch(space), mtr); @@ -3127,9 +3150,8 @@ fseg_free_extent( descr = xdes_get_descriptor(space, page, mtr); ut_a(xdes_get_state(descr, mtr) == XDES_FSEG); - ut_a(0 == ut_dulint_cmp( - mtr_read_dulint(descr + XDES_ID, mtr), - mtr_read_dulint(seg_inode + FSEG_ID, mtr))); + ut_a(0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, mtr), + mtr_read_dulint(seg_inode + FSEG_ID, mtr))); first_page_in_extent = page - (page % FSP_EXTENT_SIZE); @@ -3139,30 +3161,29 @@ fseg_free_extent( /* Drop search system page hash index if the page is found in the pool and is hashed */ - btr_search_drop_page_hash_when_freed(space, - first_page_in_extent + i); + btr_search_drop_page_hash_when_freed + (space, first_page_in_extent + i); } } if (xdes_is_full(descr, mtr)) { flst_remove(seg_inode + FSEG_FULL, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); } else if (xdes_is_free(descr, mtr)) { flst_remove(seg_inode + FSEG_FREE, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); } else { flst_remove(seg_inode + FSEG_NOT_FULL, - descr + XDES_FLST_NODE, mtr); + descr + XDES_FLST_NODE, mtr); - not_full_n_used = mtr_read_ulint( - seg_inode + FSEG_NOT_FULL_N_USED, - MLOG_4BYTES, mtr); + not_full_n_used = mtr_read_ulint + (seg_inode + FSEG_NOT_FULL_N_USED, MLOG_4BYTES, mtr); descr_n_used = xdes_get_n_used(descr, mtr); ut_a(not_full_n_used >= descr_n_used); mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED, - not_full_n_used - descr_n_used, - MLOG_4BYTES, mtr); + not_full_n_used - descr_n_used, + MLOG_4BYTES, mtr); } fsp_free_extent(space, page, mtr); @@ -3171,7 +3192,7 @@ fseg_free_extent( for (i = 0; i < FSP_EXTENT_SIZE; i++) { buf_page_set_file_page_was_freed(space, - first_page_in_extent + i); + first_page_in_extent + i); } #endif } @@ -3202,8 +3223,8 @@ fseg_free_step( #ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex) - || mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + || mtr_memo_contains(mtr, fil_space_get_latch(space), + MTR_MEMO_X_LOCK)); #endif /* UNIV_SYNC_DEBUG */ mtr_x_lock(fil_space_get_latch(space), mtr); @@ -3214,7 +3235,7 @@ fseg_free_step( ut_a(descr); ut_a(xdes_get_bit(descr, XDES_FREE_BIT, buf_frame_get_page_no(header) - % FSP_EXTENT_SIZE, mtr) == FALSE); + % FSP_EXTENT_SIZE, mtr) == FALSE); inode = fseg_inode_get(header, mtr); descr = fseg_get_first_extent(inode, mtr); @@ -3239,7 +3260,7 @@ fseg_free_step( } fseg_free_page_low(inode, space, - fseg_get_nth_frag_page_no(inode, n, mtr), mtr); + fseg_get_nth_frag_page_no(inode, n, mtr), mtr); n = fseg_find_last_used_frag_page_slot(inode, mtr); @@ -3277,8 +3298,8 @@ fseg_free_step_not_header( #ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex) - || mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + || mtr_memo_contains(mtr, fil_space_get_latch(space), + MTR_MEMO_X_LOCK)); #endif /* UNIV_SYNC_DEBUG */ mtr_x_lock(fil_space_get_latch(space), mtr); @@ -3416,14 +3437,14 @@ fseg_validate_low( ulint n_used2 = 0; ut_ad(mtr_memo_contains(mtr2, buf_block_align(inode), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); space = buf_frame_get_space_id(inode); seg_id = mtr_read_dulint(inode + FSEG_ID, mtr2); n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED, - MLOG_4BYTES, mtr2); + MLOG_4BYTES, mtr2); flst_validate(inode + FSEG_FREE, mtr2); flst_validate(inode + FSEG_NOT_FULL, mtr2); flst_validate(inode + FSEG_FULL, mtr2); @@ -3439,8 +3460,8 @@ fseg_validate_low( ut_a(xdes_get_n_used(descr, &mtr) == 0); ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG); - ut_a(0 == ut_dulint_cmp( - mtr_read_dulint(descr + XDES_ID, &mtr), seg_id)); + ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr), + seg_id)); node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr); mtr_commit(&mtr); @@ -3459,8 +3480,8 @@ fseg_validate_low( ut_a(xdes_get_n_used(descr, &mtr) > 0); ut_a(xdes_get_n_used(descr, &mtr) < FSP_EXTENT_SIZE); ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG); - ut_a(0 == ut_dulint_cmp( - mtr_read_dulint(descr + XDES_ID, &mtr), seg_id)); + ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr), + seg_id)); n_used2 += xdes_get_n_used(descr, &mtr); @@ -3480,8 +3501,8 @@ fseg_validate_low( ut_a(xdes_get_n_used(descr, &mtr) == FSP_EXTENT_SIZE); ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG); - ut_a(0 == ut_dulint_cmp( - mtr_read_dulint(descr + XDES_ID, &mtr), seg_id)); + ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr), + seg_id)); node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr); mtr_commit(&mtr); @@ -3540,7 +3561,7 @@ fseg_print_low( dulint d_var; ut_ad(mtr_memo_contains(mtr, buf_block_align(inode), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); space = buf_frame_get_space_id(inode); page_no = buf_frame_get_page_no(inode); @@ -3552,16 +3573,19 @@ fseg_print_low( seg_id_high = ut_dulint_get_high(d_var); n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); n_frag = fseg_get_n_frag_pages(inode, mtr); n_free = flst_get_len(inode + FSEG_FREE, mtr); n_not_full = flst_get_len(inode + FSEG_NOT_FULL, mtr); n_full = flst_get_len(inode + FSEG_FULL, mtr); fprintf(stderr, -"SEGMENT id %lu %lu space %lu; page %lu; res %lu used %lu; full ext %lu\n" -"fragm pages %lu; free extents %lu; not full extents %lu: pages %lu\n", - (ulong) seg_id_high, (ulong) seg_id_low, (ulong) space, (ulong) page_no, + "SEGMENT id %lu %lu space %lu; page %lu;" + " res %lu used %lu; full ext %lu\n" + "fragm pages %lu; free extents %lu;" + " not full extents %lu: pages %lu\n", + (ulong) seg_id_high, (ulong) seg_id_low, + (ulong) space, (ulong) page_no, (ulong) reserved, (ulong) used, (ulong) n_full, (ulong) n_frag, (ulong) n_free, (ulong) n_not_full, (ulong) n_used); @@ -3628,12 +3652,12 @@ fsp_validate( size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr); free_limit = mtr_read_ulint(header + FSP_FREE_LIMIT, - MLOG_4BYTES, &mtr); + MLOG_4BYTES, &mtr); frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, - MLOG_4BYTES, &mtr); + MLOG_4BYTES, &mtr); - n_full_frag_pages = FSP_EXTENT_SIZE * - flst_get_len(header + FSP_FULL_FRAG, &mtr); + n_full_frag_pages = FSP_EXTENT_SIZE + * flst_get_len(header + FSP_FULL_FRAG, &mtr); ut_a(free_limit <= size || (space != 0 && size < FSP_EXTENT_SIZE)); @@ -3734,27 +3758,28 @@ fsp_validate( mtr_start(&mtr); mtr_x_lock(fil_space_get_latch(space), &mtr); - seg_inode_page = fut_get_ptr(space, node_addr, - RW_X_LATCH, &mtr) - FSEG_INODE_PAGE_NODE; + seg_inode_page = fut_get_ptr + (space, node_addr, RW_X_LATCH, &mtr) + - FSEG_INODE_PAGE_NODE; - seg_inode = fsp_seg_inode_page_get_nth_inode( - seg_inode_page, n, &mtr); - ut_a(ut_dulint_cmp( - mach_read_from_8(seg_inode + FSEG_ID), - ut_dulint_zero) != 0); + seg_inode = fsp_seg_inode_page_get_nth_inode + (seg_inode_page, n, &mtr); + ut_a(ut_dulint_cmp + (mach_read_from_8(seg_inode + FSEG_ID), + ut_dulint_zero) != 0); fseg_validate_low(seg_inode, &mtr); descr_count += flst_get_len(seg_inode + FSEG_FREE, - &mtr); + &mtr); descr_count += flst_get_len(seg_inode + FSEG_FULL, - &mtr); + &mtr); descr_count += flst_get_len(seg_inode + FSEG_NOT_FULL, - &mtr); + &mtr); n_used2 += fseg_get_n_frag_pages(seg_inode, &mtr); - next_node_addr = flst_get_next_addr(seg_inode_page - + FSEG_INODE_PAGE_NODE, &mtr); + next_node_addr = flst_get_next_addr + (seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr); mtr_commit(&mtr); } @@ -3779,28 +3804,29 @@ fsp_validate( mtr_start(&mtr); mtr_x_lock(fil_space_get_latch(space), &mtr); - seg_inode_page = fut_get_ptr(space, node_addr, - RW_X_LATCH, &mtr) - FSEG_INODE_PAGE_NODE; + seg_inode_page = fut_get_ptr + (space, node_addr, RW_X_LATCH, &mtr) + - FSEG_INODE_PAGE_NODE; - seg_inode = fsp_seg_inode_page_get_nth_inode( - seg_inode_page, n, &mtr); - if (ut_dulint_cmp(mach_read_from_8( - seg_inode + FSEG_ID), - ut_dulint_zero) != 0) { + seg_inode = fsp_seg_inode_page_get_nth_inode + (seg_inode_page, n, &mtr); + if (ut_dulint_cmp + (mach_read_from_8(seg_inode + FSEG_ID), + ut_dulint_zero) != 0) { fseg_validate_low(seg_inode, &mtr); - descr_count += flst_get_len( - seg_inode + FSEG_FREE, &mtr); - descr_count += flst_get_len( - seg_inode + FSEG_FULL, &mtr); - descr_count += flst_get_len( - seg_inode + FSEG_NOT_FULL, &mtr); - n_used2 += fseg_get_n_frag_pages( - seg_inode, &mtr); + descr_count += flst_get_len + (seg_inode + FSEG_FREE, &mtr); + descr_count += flst_get_len + (seg_inode + FSEG_FULL, &mtr); + descr_count += flst_get_len + (seg_inode + FSEG_NOT_FULL, &mtr); + n_used2 += fseg_get_n_frag_pages + (seg_inode, &mtr); } - next_node_addr = flst_get_next_addr(seg_inode_page - + FSEG_INODE_PAGE_NODE, &mtr); + next_node_addr = flst_get_next_addr + (seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr); mtr_commit(&mtr); } @@ -3809,9 +3835,9 @@ fsp_validate( ut_a(descr_count * FSP_EXTENT_SIZE == free_limit); ut_a(n_used + n_full_frag_pages - == n_used2 + 2* ((free_limit + XDES_DESCRIBED_PER_PAGE - 1) - / XDES_DESCRIBED_PER_PAGE) - + seg_inode_len_full + seg_inode_len_free); + == n_used2 + 2* ((free_limit + XDES_DESCRIBED_PER_PAGE - 1) + / XDES_DESCRIBED_PER_PAGE) + + seg_inode_len_full + seg_inode_len_free); ut_a(frag_n_used == n_used); mtr_commit(&mtr2); @@ -3862,9 +3888,9 @@ fsp_print( size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr); free_limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES, - &mtr); + &mtr); frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES, - &mtr); + &mtr); n_free = flst_get_len(header + FSP_FREE, &mtr); n_free_frag = flst_get_len(header + FSP_FREE_FRAG, &mtr); n_full_frag = flst_get_len(header + FSP_FULL_FRAG, &mtr); @@ -3875,10 +3901,11 @@ fsp_print( seg_id_high = ut_dulint_get_high(d_var); fprintf(stderr, -"FILE SPACE INFO: id %lu\n" -"size %lu, free limit %lu, free extents %lu\n" -"not full frag extents %lu: used pages %lu, full frag extents %lu\n" -"first seg id not used %lu %lu\n", + "FILE SPACE INFO: id %lu\n" + "size %lu, free limit %lu, free extents %lu\n" + "not full frag extents %lu: used pages %lu," + " full frag extents %lu\n" + "first seg id not used %lu %lu\n", (long) space, (ulong) size, (ulong) free_limit, (ulong) n_free, (ulong) n_free_frag, (ulong) frag_n_used, (ulong) n_full_frag, @@ -3904,20 +3931,21 @@ fsp_print( mtr_start(&mtr); mtr_x_lock(fil_space_get_latch(space), &mtr); - seg_inode_page = fut_get_ptr(space, node_addr, - RW_X_LATCH, &mtr) - FSEG_INODE_PAGE_NODE; + seg_inode_page = fut_get_ptr + (space, node_addr, RW_X_LATCH, &mtr) + - FSEG_INODE_PAGE_NODE; - seg_inode = fsp_seg_inode_page_get_nth_inode( - seg_inode_page, n, &mtr); - ut_a(ut_dulint_cmp(mach_read_from_8( - seg_inode + FSEG_ID), - ut_dulint_zero) != 0); + seg_inode = fsp_seg_inode_page_get_nth_inode + (seg_inode_page, n, &mtr); + ut_a(ut_dulint_cmp + (mach_read_from_8(seg_inode + FSEG_ID), + ut_dulint_zero) != 0); fseg_print_low(seg_inode, &mtr); n_segs++; - next_node_addr = flst_get_next_addr(seg_inode_page - + FSEG_INODE_PAGE_NODE, &mtr); + next_node_addr = flst_get_next_addr + (seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr); mtr_commit(&mtr); } @@ -3940,21 +3968,22 @@ fsp_print( mtr_start(&mtr); mtr_x_lock(fil_space_get_latch(space), &mtr); - seg_inode_page = fut_get_ptr(space, node_addr, - RW_X_LATCH, &mtr) - FSEG_INODE_PAGE_NODE; + seg_inode_page = fut_get_ptr + (space, node_addr, RW_X_LATCH, &mtr) + - FSEG_INODE_PAGE_NODE; - seg_inode = fsp_seg_inode_page_get_nth_inode( - seg_inode_page, n, &mtr); - if (ut_dulint_cmp(mach_read_from_8( - seg_inode + FSEG_ID), - ut_dulint_zero) != 0) { + seg_inode = fsp_seg_inode_page_get_nth_inode + (seg_inode_page, n, &mtr); + if (ut_dulint_cmp + (mach_read_from_8(seg_inode + FSEG_ID), + ut_dulint_zero) != 0) { fseg_print_low(seg_inode, &mtr); n_segs++; } - next_node_addr = flst_get_next_addr(seg_inode_page - + FSEG_INODE_PAGE_NODE, &mtr); + next_node_addr = flst_get_next_addr + (seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr); mtr_commit(&mtr); } diff --git a/storage/innobase/fut/fut0lst.c b/storage/innobase/fut/fut0lst.c index cdf7719dde0..75fa8bf5552 100644 --- a/storage/innobase/fut/fut0lst.c +++ b/storage/innobase/fut/fut0lst.c @@ -33,9 +33,9 @@ flst_add_to_empty( ut_ad(mtr && base && node); ut_ad(base != node); ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); len = flst_get_len(base, mtr); ut_a(len == 0); @@ -72,9 +72,9 @@ flst_add_last( ut_ad(mtr && base && node); ut_ad(base != node); ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); len = flst_get_len(base, mtr); last_addr = flst_get_last(base, mtr); @@ -86,7 +86,7 @@ flst_add_last( last_node = buf_frame_align(node) + last_addr.boffset; } else { last_node = fut_get_ptr(space, last_addr, RW_X_LATCH, - mtr); + mtr); } flst_insert_after(base, last_node, node, mtr); @@ -115,9 +115,9 @@ flst_add_first( ut_ad(mtr && base && node); ut_ad(base != node); ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); len = flst_get_len(base, mtr); first_addr = flst_get_first(base, mtr); @@ -127,10 +127,10 @@ flst_add_first( if (len != 0) { if (first_addr.page == node_addr.page) { first_node = buf_frame_align(node) - + first_addr.boffset; + + first_addr.boffset; } else { first_node = fut_get_ptr(space, first_addr, - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); } flst_insert_before(base, node, first_node, mtr); @@ -163,11 +163,11 @@ flst_insert_after( ut_ad(base != node2); ut_ad(node2 != node1); ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node1), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node2), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); buf_ptr_get_fsp_addr(node1, &space, &node1_addr); buf_ptr_get_fsp_addr(node2, &space, &node2_addr); @@ -218,11 +218,11 @@ flst_insert_before( ut_ad(base != node3); ut_ad(node2 != node3); ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node2), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node3), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); buf_ptr_get_fsp_addr(node2, &space, &node2_addr); buf_ptr_get_fsp_addr(node3, &space, &node3_addr); @@ -270,9 +270,9 @@ flst_remove( ut_ad(mtr && node2 && base); ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node2), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); buf_ptr_get_fsp_addr(node2, &space, &node2_addr); @@ -288,7 +288,7 @@ flst_remove( node1 = buf_frame_align(node2) + node1_addr.boffset; } else { node1 = fut_get_ptr(space, node1_addr, RW_X_LATCH, - mtr); + mtr); } ut_ad(node1 != node2); @@ -307,7 +307,7 @@ flst_remove( node3 = buf_frame_align(node2) + node3_addr.boffset; } else { node3 = fut_get_ptr(space, node3_addr, RW_X_LATCH, - mtr); + mtr); } ut_ad(node2 != node3); @@ -347,9 +347,9 @@ flst_cut_end( ut_ad(mtr && node2 && base); ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node2), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(n_nodes > 0); buf_ptr_get_fsp_addr(node2, &space, &node2_addr); @@ -365,7 +365,7 @@ flst_cut_end( node1 = buf_frame_align(node2) + node1_addr.boffset; } else { node1 = fut_get_ptr(space, node1_addr, RW_X_LATCH, - mtr); + mtr); } flst_write_addr(node1 + FLST_NEXT, fil_addr_null, mtr); @@ -402,9 +402,9 @@ flst_truncate_end( ut_ad(mtr && node2 && base); ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, buf_block_align(node2), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); if (n_nodes == 0) { ut_ad(fil_addr_is_null(flst_get_next_addr(node2, mtr))); @@ -446,7 +446,7 @@ flst_validate( ut_ad(base); ut_ad(mtr_memo_contains(mtr1, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); /* We use two mini-transaction handles: the first is used to lock the base node, and prevent other threads from modifying the @@ -504,7 +504,7 @@ flst_print( ut_ad(base && mtr); ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); frame = buf_frame_align(base); len = flst_get_len(base, mtr); diff --git a/storage/innobase/ha/ha0ha.c b/storage/innobase/ha/ha0ha.c index 6b03ea5f2fe..23ea2554f01 100644 --- a/storage/innobase/ha/ha0ha.c +++ b/storage/innobase/ha/ha0ha.c @@ -310,8 +310,9 @@ ha_validate( if (hash_calc_hash(node->fold, table) != i) { ut_print_timestamp(stderr); fprintf(stderr, -"InnoDB: Error: hash table node fold value %lu does not\n" -"InnoDB: match with the cell number %lu.\n", + "InnoDB: Error: hash table node" + " fold value %lu does not\n" + "InnoDB: match the cell number %lu.\n", (ulong) node->fold, (ulong) i); ok = FALSE; @@ -363,6 +364,7 @@ ha_print_info( n_bufs++; } - fprintf(file, ", node heap has %lu buffer(s)\n", (ulong) n_bufs); + fprintf(file, ", node heap has %lu buffer(s)\n", + (ulong) n_bufs); } } diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c index 4e38e1f0353..2f4d0ae1009 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.c +++ b/storage/innobase/ibuf/ibuf0ibuf.c @@ -308,7 +308,7 @@ ibuf_tree_root_get( mtr_x_lock(dict_tree_get_lock((data->index)->tree), mtr); page = buf_page_get(space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, - mtr); + mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_TREE_NODE); #endif /* UNIV_SYNC_DEBUG */ @@ -372,7 +372,7 @@ ibuf_init_at_db_start(void) change */ ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE - / IBUF_POOL_SIZE_PER_MAX_SIZE; + / IBUF_POOL_SIZE_PER_MAX_SIZE; UT_LIST_INIT(ibuf->data_list); @@ -385,7 +385,7 @@ ibuf_init_at_db_start(void) for (i = 0; i < IBUF_COUNT_N_SPACES; i++) { ibuf_counts[i] = mem_alloc(sizeof(ulint) - * IBUF_COUNT_N_PAGES); + * IBUF_COUNT_N_PAGES); for (j = 0; j < IBUF_COUNT_N_PAGES; j++) { ibuf_count_set(i, j, 0); } @@ -395,7 +395,7 @@ ibuf_init_at_db_start(void) } #endif mutex_create(&ibuf_pessimistic_insert_mutex, - SYNC_IBUF_PESS_INSERT_MUTEX); + SYNC_IBUF_PESS_INSERT_MUTEX); mutex_create(&ibuf_mutex, SYNC_IBUF_MUTEX); @@ -429,7 +429,7 @@ ibuf_data_sizes_update( data->height = 1 + btr_page_get_level(root, mtr); data->size = data->seg_size - (1 + data->free_list_len); - /* the '1 +' is the ibuf header page */ + /* the '1 +' is the ibuf header page */ ut_ad(data->size < data->seg_size); if (page_get_n_recs(root) == 0) { @@ -443,8 +443,10 @@ ibuf_data_sizes_update( ibuf->size = ibuf->size + data->size - old_size; -/* fprintf(stderr, "ibuf size %lu, space ibuf size %lu\n", ibuf->size, - data->size); */ +#if 0 + fprintf(stderr, "ibuf size %lu, space ibuf size %lu\n", + ibuf->size, data->size); +#endif } /********************************************************************** @@ -471,14 +473,6 @@ ibuf_data_init_for_space( ut_a(space == 0); -#ifdef UNIV_LOG_DEBUG - if (space % 2 == 1) { - - fputs("No ibuf op in replicate space\n", stderr); - - return(NULL); - } -#endif data = mem_alloc(sizeof(ibuf_data_t)); data->space = space; @@ -492,7 +486,7 @@ ibuf_data_init_for_space( header_page = ibuf_header_page_get(space, &mtr); fseg_n_reserved_pages(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER, - &n_used, &mtr); + &n_used, &mtr); ibuf_enter(); ut_ad(n_used >= 2); @@ -500,7 +494,7 @@ ibuf_data_init_for_space( data->seg_size = n_used; root = buf_page_get(space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, - &mtr); + &mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(root, SYNC_TREE_NODE); #endif /* UNIV_SYNC_DEBUG */ @@ -511,15 +505,15 @@ ibuf_data_init_for_space( data->n_merged_recs = 0; ibuf_data_sizes_update(data, root, &mtr); -/* + /* if (!data->empty) { - fprintf(stderr, -"InnoDB: index entries found in the insert buffer\n"); + fprintf(stderr, + "InnoDB: index entries found in the insert buffer\n"); } else { - fprintf(stderr, -"InnoDB: insert buffer empty\n"); + fprintf(stderr, + "InnoDB: insert buffer empty\n"); } -*/ + */ mutex_exit(&ibuf_mutex); mtr_commit(&mtr); @@ -537,8 +531,9 @@ ibuf_data_init_for_space( dict_table_add_to_cache(table); - index = dict_mem_index_create(buf, "CLUST_IND", space, - DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,2); + index = dict_mem_index_create + (buf, "CLUST_IND", space, + DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF, 2); dict_mem_index_add_field(index, "PAGE_NO", 0); dict_mem_index_add_field(index, "TYPES", 0); @@ -630,7 +625,7 @@ ibuf_bitmap_page_get_bits( # error "IBUF_BITS_PER_PAGE % 2 != 0" #endif ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); bit_offset = (page_no % XDES_DESCRIBED_PER_PAGE) * IBUF_BITS_PER_PAGE + bit; @@ -674,11 +669,11 @@ ibuf_bitmap_page_set_bits( # error "IBUF_BITS_PER_PAGE % 2 != 0" #endif ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); #ifdef UNIV_IBUF_DEBUG ut_a((bit != IBUF_BITMAP_BUFFERED) || (val != FALSE) - || (0 == ibuf_count_get(buf_frame_get_space_id(page), - page_no))); + || (0 == ibuf_count_get(buf_frame_get_space_id(page), + page_no))); #endif bit_offset = (page_no % XDES_DESCRIBED_PER_PAGE) * IBUF_BITS_PER_PAGE + bit; @@ -702,7 +697,7 @@ ibuf_bitmap_page_set_bits( } mlog_write_ulint(page + IBUF_BITMAP + byte_offset, map_byte, - MLOG_1BYTE, mtr); + MLOG_1BYTE, mtr); } /************************************************************************ @@ -716,8 +711,8 @@ ibuf_bitmap_page_no_calc( ulint page_no) /* in: tablespace page number */ { return(FSP_IBUF_BITMAP_OFFSET - + XDES_DESCRIBED_PER_PAGE - * (page_no / XDES_DESCRIBED_PER_PAGE)); + + XDES_DESCRIBED_PER_PAGE + * (page_no / XDES_DESCRIBED_PER_PAGE)); } /************************************************************************ @@ -738,7 +733,7 @@ ibuf_bitmap_get_map_page( page_t* page; page = buf_page_get(space, ibuf_bitmap_page_no_calc(page_no), - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_IBUF_BITMAP); #endif /* UNIV_SYNC_DEBUG */ @@ -773,18 +768,21 @@ ibuf_set_free_bits_low( return; } - bitmap_page = ibuf_bitmap_get_map_page(buf_frame_get_space_id(page), - buf_frame_get_page_no(page), mtr); + bitmap_page = ibuf_bitmap_get_map_page + (buf_frame_get_space_id(page), + buf_frame_get_page_no(page), mtr); #ifdef UNIV_IBUF_DEBUG - /* fprintf(stderr, +# if 0 + fprintf(stderr, "Setting page no %lu free bits to %lu should be %lu\n", - buf_frame_get_page_no(page), val, - ibuf_index_page_calc_free(page)); */ + buf_frame_get_page_no(page), val, + ibuf_index_page_calc_free(page)); +# endif ut_a(val <= ibuf_index_page_calc_free(page)); -#endif +#endif /* UNIV_IBUF_DEBUG */ ibuf_bitmap_page_set_bits(bitmap_page, buf_frame_get_page_no(page), - IBUF_BITMAP_FREE, val, mtr); + IBUF_BITMAP_FREE, val, mtr); } @@ -820,34 +818,40 @@ ibuf_set_free_bits( mtr_start(&mtr); - bitmap_page = ibuf_bitmap_get_map_page(buf_frame_get_space_id(page), - buf_frame_get_page_no(page), &mtr); + bitmap_page = ibuf_bitmap_get_map_page + (buf_frame_get_space_id(page), + buf_frame_get_page_no(page), &mtr); if (max_val != ULINT_UNDEFINED) { #ifdef UNIV_IBUF_DEBUG ulint old_val; - old_val = ibuf_bitmap_page_get_bits(bitmap_page, - buf_frame_get_page_no(page), - IBUF_BITMAP_FREE, &mtr); + old_val = ibuf_bitmap_page_get_bits + (bitmap_page, buf_frame_get_page_no(page), + IBUF_BITMAP_FREE, &mtr); +# if 0 if (old_val != max_val) { - /* fprintf(stderr, - "Ibuf: page %lu old val %lu max val %lu\n", - buf_frame_get_page_no(page), old_val, max_val); */ + fprintf(stderr, + "Ibuf: page %lu old val %lu max val %lu\n", + buf_frame_get_page_no(page), + old_val, max_val); } +# endif ut_a(old_val <= max_val); #endif } #ifdef UNIV_IBUF_DEBUG -/* fprintf(stderr, "Setting page no %lu free bits to %lu should be %lu\n", - buf_frame_get_page_no(page), val, - ibuf_index_page_calc_free(page)); */ +# if 0 + fprintf(stderr, "Setting page no %lu free bits to %lu should be %lu\n", + buf_frame_get_page_no(page), val, + ibuf_index_page_calc_free(page)); +# endif ut_a(val <= ibuf_index_page_calc_free(page)); #endif ibuf_bitmap_page_set_bits(bitmap_page, buf_frame_get_page_no(page), - IBUF_BITMAP_FREE, val, &mtr); + IBUF_BITMAP_FREE, val, &mtr); mtr_commit(&mtr); } @@ -955,7 +959,7 @@ ibuf_fixed_addr_page( ulint page_no)/* in: page number */ { return((space == 0 && page_no == IBUF_TREE_ROOT_PAGE_NO) - || ibuf_bitmap_page(page_no)); + || ibuf_bitmap_page(page_no)); } /*************************************************************************** @@ -997,7 +1001,7 @@ ibuf_page( bitmap_page = ibuf_bitmap_get_map_page(space, page_no, &mtr); ret = ibuf_bitmap_page_get_bits(bitmap_page, page_no, IBUF_BITMAP_IBUF, - &mtr); + &mtr); mtr_commit(&mtr); return(ret); @@ -1019,14 +1023,6 @@ ibuf_page_low( page_t* bitmap_page; ibool ret; -#ifdef UNIV_LOG_DEBUG - if (space % 2 != 0) { - - fputs("No ibuf in a replicate space\n", stderr); - - return(FALSE); - } -#endif if (ibuf_fixed_addr_page(space, page_no)) { return(TRUE); @@ -1035,7 +1031,7 @@ ibuf_page_low( bitmap_page = ibuf_bitmap_get_map_page(space, page_no, mtr); ret = ibuf_bitmap_page_get_bits(bitmap_page, page_no, IBUF_BITMAP_IBUF, - mtr); + mtr); return(ret); } @@ -1122,10 +1118,11 @@ ibuf_dummy_index_create( dict_index_t* index; table = dict_mem_table_create("IBUF_DUMMY", - DICT_HDR_SPACE, n, comp ? DICT_TF_COMPACT : 0); + DICT_HDR_SPACE, n, + comp ? DICT_TF_COMPACT : 0); index = dict_mem_index_create("IBUF_DUMMY", "IBUF_DUMMY", - DICT_HDR_SPACE, 0, n); + DICT_HDR_SPACE, 0, n); index->table = table; @@ -1146,12 +1143,12 @@ ibuf_dummy_index_add_col( { ulint i = index->table->n_def; dict_mem_table_add_col(index->table, "DUMMY", - dtype_get_mtype(type), - dtype_get_prtype(type), - dtype_get_len(type), - dtype_get_prec(type)); + dtype_get_mtype(type), + dtype_get_prtype(type), + dtype_get_len(type), + dtype_get_prec(type)); dict_index_add_col(index, - dict_table_get_nth_col(index->table, i), len); + dict_table_get_nth_col(index->table, i), len); } /************************************************************************ Deallocates a dummy index for inserting a record to a non-clustered index. @@ -1216,9 +1213,9 @@ ibuf_build_entry_from_ibuf_rec( dfield_set_data(field, data, len); - dtype_read_for_order_and_null_size( - dfield_get_type(field), - types + i * DATA_ORDER_NULL_TYPE_BUF_SIZE); + dtype_read_for_order_and_null_size + (dfield_get_type(field), + types + i * DATA_ORDER_NULL_TYPE_BUF_SIZE); } *pindex = ibuf_dummy_index_create(n_fields, FALSE); @@ -1238,8 +1235,8 @@ ibuf_build_entry_from_ibuf_rec( types = rec_get_nth_field_old(ibuf_rec, 3, &len); ut_a(len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE <= 1); - index = ibuf_dummy_index_create(n_fields, - len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); + index = ibuf_dummy_index_create + (n_fields, len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); if (len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE) { /* compact record format */ @@ -1257,9 +1254,9 @@ ibuf_build_entry_from_ibuf_rec( dfield_set_data(field, data, len); - dtype_new_read_for_order_and_null_size( - dfield_get_type(field), - types + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); + dtype_new_read_for_order_and_null_size + (dfield_get_type(field), + types + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); ibuf_dummy_index_add_col(index, dfield_get_type(field), len); } @@ -1318,9 +1315,8 @@ ibuf_rec_get_volume( ulint volume; dict_index_t* dummy_index; mem_heap_t* heap = mem_heap_create(500); - dtuple_t* entry = - ibuf_build_entry_from_ibuf_rec( - ibuf_rec, heap, &dummy_index); + dtuple_t* entry = ibuf_build_entry_from_ibuf_rec + (ibuf_rec, heap, &dummy_index); volume = rec_get_converted_size(dummy_index, entry); ibuf_dummy_index_free(dummy_index); mem_heap_free(heap); @@ -1336,13 +1332,15 @@ ibuf_rec_get_volume( if (new_format) { data = rec_get_nth_field_old(ibuf_rec, i + 4, &len); - dtype_new_read_for_order_and_null_size(&dtype, - types + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); + dtype_new_read_for_order_and_null_size + (&dtype, types + i + * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); } else { data = rec_get_nth_field_old(ibuf_rec, i + 2, &len); - dtype_read_for_order_and_null_size(&dtype, - types + i * DATA_ORDER_NULL_TYPE_BUF_SIZE); + dtype_read_for_order_and_null_size + (&dtype, types + i + * DATA_ORDER_NULL_TYPE_BUF_SIZE); } if (len == UNIV_SQL_NULL) { @@ -1353,7 +1351,7 @@ ibuf_rec_get_volume( } return(data_size + rec_get_converted_extra_size(data_size, n_fields) - + page_dir_calc_reserved_space(1)); + + page_dir_calc_reserved_space(1)); } /************************************************************************* @@ -1389,9 +1387,9 @@ ibuf_entry_build( (3) the third contains the page number, and (4) the fourth contains the relevent type information of each data field; the length of this field % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE is - (a) 0 for b-trees in the old format, and - (b) 1 for b-trees in the compact format, the first byte of the field - being the marker (0); + (a) 0 for b-trees in the old format, and + (b) 1 for b-trees in the compact format, the first byte of the field + being the marker (0); (5) and the rest of the fields are copied from entry. All fields in the tuple are ordered like the type binary in our insert buffer tree. */ @@ -1436,8 +1434,8 @@ ibuf_entry_build( /* Store the type info in buf2, and add the fields from entry to tuple */ buf2 = mem_heap_alloc(heap, n_fields - * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE - + comp); + * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE + + comp); if (comp) { *buf2++ = 0; /* write the compact format indicator */ } @@ -1449,9 +1447,9 @@ ibuf_entry_build( entry_field = dtuple_get_nth_field(entry, i); dfield_copy(field, entry_field); - dtype_new_store_for_order_and_null_size( - buf2 + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE, - dfield_get_type(entry_field)); + dtype_new_store_for_order_and_null_size + (buf2 + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE, + dfield_get_type(entry_field)); } /* Store the type info in buf2 to field 3 of tuple */ @@ -1463,8 +1461,8 @@ ibuf_entry_build( } dfield_set_data(field, buf2, n_fields - * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE - + comp); + * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE + + comp); /* Set all the types in the new tuple binary */ dtuple_set_types_binary(tuple, n_fields + 4); @@ -1654,8 +1652,8 @@ ibuf_add_free_page( header page apart from the ibuf tree. */ page_no = fseg_alloc_free_page(header_page + IBUF_HEADER - + IBUF_TREE_SEG_HEADER, 0, FSP_UP, - &mtr); + + IBUF_TREE_SEG_HEADER, 0, FSP_UP, + &mtr); if (page_no == FIL_NULL) { mtr_commit(&mtr); @@ -1677,10 +1675,10 @@ ibuf_add_free_page( /* Add the page to the free list and update the ibuf size data */ flst_add_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr); + page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr); mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST, - MLOG_2BYTES, &mtr); + MLOG_2BYTES, &mtr); ibuf_data->seg_size++; ibuf_data->free_list_len++; @@ -1691,7 +1689,7 @@ ibuf_add_free_page( bitmap_page = ibuf_bitmap_get_map_page(space, page_no, &mtr); ibuf_bitmap_page_set_bits(bitmap_page, page_no, IBUF_BITMAP_IBUF, - TRUE, &mtr); + TRUE, &mtr); mtr_commit(&mtr); mutex_exit(&ibuf_mutex); @@ -1753,8 +1751,8 @@ ibuf_remove_free_page( root = ibuf_tree_root_get(ibuf_data, space, &mtr2); page_no = flst_get_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - &mtr2) - .page; + &mtr2) + .page; /* NOTE that we must release the latch on the ibuf tree root because in fseg_free_page we access level 1 pages, and the root @@ -1772,7 +1770,7 @@ ibuf_remove_free_page( page from it. */ fseg_free_page(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER, - space, page_no, &mtr); + space, page_no, &mtr); #ifdef UNIV_DEBUG_FILE_ACCESSES buf_page_reset_file_page_was_freed(space, page_no); #endif @@ -1783,8 +1781,8 @@ ibuf_remove_free_page( root = ibuf_tree_root_get(ibuf_data, space, &mtr); ut_ad(page_no == flst_get_last(root + PAGE_HEADER - + PAGE_BTR_IBUF_FREE_LIST, &mtr) - .page); + + PAGE_BTR_IBUF_FREE_LIST, &mtr) + .page); page = buf_page_get(space, page_no, RW_X_LATCH, &mtr); @@ -1795,7 +1793,7 @@ ibuf_remove_free_page( /* Remove the page from the free list and update the ibuf size data */ flst_remove(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr); + page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr); ibuf_data->seg_size--; ibuf_data->free_list_len--; @@ -1808,7 +1806,7 @@ ibuf_remove_free_page( bitmap_page = ibuf_bitmap_get_map_page(space, page_no, &mtr); ibuf_bitmap_page_set_bits(bitmap_page, page_no, IBUF_BITMAP_IBUF, - FALSE, &mtr); + FALSE, &mtr); #ifdef UNIV_DEBUG_FILE_ACCESSES buf_page_set_file_page_was_freed(space, page_no); #endif @@ -1834,7 +1832,8 @@ ibuf_free_excess_pages( if (space != 0) { fprintf(stderr, -"InnoDB: Error: calling ibuf_free_excess_pages for space %lu\n", (ulong) space); + "InnoDB: Error: calling ibuf_free_excess_pages" + " for space %lu\n", (ulong) space); return; } @@ -1853,9 +1852,9 @@ ibuf_free_excess_pages( if (ibuf_data == NULL) { /* Not yet initialized */ -#ifdef UNIV_DEBUG - /*fprintf(stderr, - "Ibuf for space %lu not yet initialized\n", space); */ +#if 0 /* defined UNIV_DEBUG */ + fprintf(stderr, + "Ibuf for space %lu not yet initialized\n", space); #endif return; @@ -1952,14 +1951,14 @@ ibuf_get_merge_page_nos( rec_space_id = ibuf_rec_get_space(rec); if (rec_space_id != first_space_id - || rec_page_no / IBUF_MERGE_AREA - != first_page_no / IBUF_MERGE_AREA) { + || rec_page_no / IBUF_MERGE_AREA + != first_page_no / IBUF_MERGE_AREA) { break; } if (rec_page_no != prev_page_no - || rec_space_id != prev_space_id) { + || rec_space_id != prev_space_id) { n_pages++; } @@ -1996,22 +1995,21 @@ ibuf_get_merge_page_nos( ut_a(*n_stored < IBUF_MAX_N_PAGES_MERGED); #endif if ((rec_space_id != prev_space_id - || rec_page_no != prev_page_no) - && (prev_space_id != 0 || prev_page_no != 0)) { + || rec_page_no != prev_page_no) + && (prev_space_id != 0 || prev_page_no != 0)) { if ((prev_page_no == first_page_no - && prev_space_id == first_space_id) - || contract - || (volume_for_page > - ((IBUF_MERGE_THRESHOLD - 1) - * 4 * UNIV_PAGE_SIZE - / IBUF_PAGE_SIZE_PER_FREE_SPACE) - / IBUF_MERGE_THRESHOLD)) { + && prev_space_id == first_space_id) + || contract + || (volume_for_page + > ((IBUF_MERGE_THRESHOLD - 1) + * 4 * UNIV_PAGE_SIZE + / IBUF_PAGE_SIZE_PER_FREE_SPACE) + / IBUF_MERGE_THRESHOLD)) { space_ids[*n_stored] = prev_space_id; space_versions[*n_stored] - = fil_space_get_version( - prev_space_id); + = fil_space_get_version(prev_space_id); page_nos[*n_stored] = prev_page_no; (*n_stored)++; @@ -2020,8 +2018,8 @@ ibuf_get_merge_page_nos( } if (rec_space_id != first_space_id - || rec_page_no / IBUF_MERGE_AREA - != first_page_no / IBUF_MERGE_AREA) { + || rec_page_no / IBUF_MERGE_AREA + != first_page_no / IBUF_MERGE_AREA) { break; } @@ -2048,8 +2046,10 @@ ibuf_get_merge_page_nos( #ifdef UNIV_IBUF_DEBUG ut_a(*n_stored <= IBUF_MAX_N_PAGES_MERGED); #endif -/* fprintf(stderr, "Ibuf merge batch %lu pages %lu volume\n", *n_stored, - sum_volumes); */ +#if 0 + fprintf(stderr, "Ibuf merge batch %lu pages %lu volume\n", + *n_stored, sum_volumes); +#endif return(sum_volumes); } @@ -2156,10 +2156,11 @@ loop: mutex_exit(&ibuf_mutex); sum_sizes = ibuf_get_merge_page_nos(TRUE, btr_pcur_get_rec(&pcur), - space_ids, space_versions, page_nos, &n_stored); -#ifdef UNIV_IBUF_DEBUG - /* fprintf(stderr, "Ibuf contract sync %lu pages %lu volume %lu\n", - sync, n_stored, sum_sizes); */ + space_ids, space_versions, + page_nos, &n_stored); +#if 0 /* defined UNIV_IBUF_DEBUG */ + fprintf(stderr, "Ibuf contract sync %lu pages %lu volume %lu\n", + sync, n_stored, sum_sizes); #endif ibuf_exit(); @@ -2167,7 +2168,7 @@ loop: btr_pcur_close(&pcur); buf_read_ibuf_merge_pages(sync, space_ids, space_versions, page_nos, - n_stored); + n_stored); *n_pages = n_stored; return(sum_sizes + 1); @@ -2299,7 +2300,7 @@ ibuf_get_volume_buffered( ut_a(trx_sys_multiple_tablespace_format); ut_ad((pcur->latch_mode == BTR_MODIFY_PREV) - || (pcur->latch_mode == BTR_MODIFY_TREE)); + || (pcur->latch_mode == BTR_MODIFY_TREE)); /* Count the volume of records earlier in the alphabetical order than pcur */ @@ -2321,7 +2322,7 @@ ibuf_get_volume_buffered( } if (page_no != ibuf_rec_get_page_no(rec) - || space != ibuf_rec_get_space(rec)) { + || space != ibuf_rec_get_space(rec)) { goto count_later; } @@ -2343,7 +2344,7 @@ ibuf_get_volume_buffered( prev_page = buf_page_get(0, prev_page_no, RW_X_LATCH, mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(prev_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ #ifdef UNIV_SYNC_DEBUG @@ -2364,7 +2365,7 @@ ibuf_get_volume_buffered( } if (page_no != ibuf_rec_get_page_no(rec) - || space != ibuf_rec_get_space(rec)) { + || space != ibuf_rec_get_space(rec)) { goto count_later; } @@ -2388,7 +2389,7 @@ count_later: } if (page_no != ibuf_rec_get_page_no(rec) - || space != ibuf_rec_get_space(rec)) { + || space != ibuf_rec_get_space(rec)) { return(volume); } @@ -2410,7 +2411,7 @@ count_later: next_page = buf_page_get(0, next_page_no, RW_X_LATCH, mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_prev(next_page, mtr) - == buf_frame_get_page_no(page)); + == buf_frame_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ #ifdef UNIV_SYNC_DEBUG @@ -2429,7 +2430,7 @@ count_later: } if (page_no != ibuf_rec_get_page_no(rec) - || space != ibuf_rec_get_space(rec)) { + || space != ibuf_rec_get_space(rec)) { return(volume); } @@ -2467,7 +2468,7 @@ ibuf_update_max_tablespace_id(void) mtr_start(&mtr); btr_pcur_open_at_index_side(FALSE, ibuf_index, BTR_SEARCH_LEAF, - &pcur, TRUE, &mtr); + &pcur, TRUE, &mtr); btr_pcur_move_to_prev(&pcur, &mtr); if (btr_pcur_is_before_first_on_page(&pcur, &mtr)) { @@ -2605,7 +2606,7 @@ ibuf_insert_low( will be inserted to the insert buffer. */ ibuf_entry = ibuf_entry_build(entry, dict_table_is_comp(index->table), - space, page_no, heap); + space, page_no, heap); /* Open a cursor to the insert buffer tree to calculate if we can add the new entry to it without exceeding the free space limit for the @@ -2629,7 +2630,7 @@ ibuf_insert_low( /* We check if the index page is suitable for buffered entries */ if (buf_page_peek(space, page_no) - || lock_rec_expl_exist_on_page(space, page_no)) { + || lock_rec_expl_exist_on_page(space, page_no)) { err = DB_STRONG_FAIL; mtr_commit(&bitmap_mtr); @@ -2638,10 +2639,10 @@ ibuf_insert_low( } bits = ibuf_bitmap_page_get_bits(bitmap_page, page_no, - IBUF_BITMAP_FREE, &bitmap_mtr); + IBUF_BITMAP_FREE, &bitmap_mtr); if (buffered + entry_size + page_dir_calc_reserved_space(1) - > ibuf_index_page_calc_free_from_bits(bits)) { + > ibuf_index_page_calc_free_from_bits(bits)) { mtr_commit(&bitmap_mtr); /* It may not fit */ @@ -2659,10 +2660,12 @@ ibuf_insert_low( buffered entries for this index page, if the bit is not set yet */ old_bit_value = ibuf_bitmap_page_get_bits(bitmap_page, page_no, - IBUF_BITMAP_BUFFERED, &bitmap_mtr); + IBUF_BITMAP_BUFFERED, + &bitmap_mtr); if (!old_bit_value) { ibuf_bitmap_page_set_bits(bitmap_page, page_no, - IBUF_BITMAP_BUFFERED, TRUE, &bitmap_mtr); + IBUF_BITMAP_BUFFERED, TRUE, + &bitmap_mtr); } mtr_commit(&bitmap_mtr); @@ -2677,7 +2680,7 @@ ibuf_insert_low( if (err == DB_SUCCESS) { /* Update the page max trx id field */ page_update_max_trx_id(buf_frame_align(ins_rec), - thr_get_trx(thr)->id); + thr_get_trx(thr)->id); } } else { ut_ad(mode == BTR_MODIFY_TREE); @@ -2691,14 +2694,14 @@ ibuf_insert_low( err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG, - cursor, - ibuf_entry, &ins_rec, - &dummy_big_rec, thr, - &mtr); + cursor, + ibuf_entry, &ins_rec, + &dummy_big_rec, thr, + &mtr); if (err == DB_SUCCESS) { /* Update the page max trx id field */ page_update_max_trx_id(buf_frame_align(ins_rec), - thr_get_trx(thr)->id); + thr_get_trx(thr)->id); } ibuf_data_sizes_update(ibuf_data, root, &mtr); @@ -2707,12 +2710,13 @@ ibuf_insert_low( function_exit: #ifdef UNIV_IBUF_DEBUG if (err == DB_SUCCESS) { - printf( -"Incrementing ibuf count of space %lu page %lu\n" -"from %lu by 1\n", space, page_no, ibuf_count_get(space, page_no)); + fprintf(stderr, + "Incrementing ibuf count of space %lu page %lu\n" + "from %lu by 1\n", space, page_no, + ibuf_count_get(space, page_no)); ibuf_count_set(space, page_no, - ibuf_count_get(space, page_no) + 1); + ibuf_count_get(space, page_no) + 1); } #endif if (mode == BTR_MODIFY_TREE) { @@ -2746,7 +2750,7 @@ function_exit: ut_a(n_stored <= IBUF_MAX_N_PAGES_MERGED); #endif buf_read_ibuf_merge_pages(FALSE, space_ids, space_versions, - page_nos, n_stored); + page_nos, n_stored); } return(err); @@ -2775,22 +2779,22 @@ ibuf_insert( ut_a(!(index->type & DICT_CLUSTERED)); if (rec_get_converted_size(index, entry) - >= page_get_free_space_of_empty( - dict_table_is_comp(index->table)) / 2) { + >= (page_get_free_space_of_empty(dict_table_is_comp(index->table)) + / 2)) { return(FALSE); } err = ibuf_insert_low(BTR_MODIFY_PREV, entry, index, space, page_no, - thr); + thr); if (err == DB_FAIL) { err = ibuf_insert_low(BTR_MODIFY_TREE, entry, index, space, - page_no, thr); + page_no, thr); } if (err == DB_SUCCESS) { #ifdef UNIV_IBUF_DEBUG /* fprintf(stderr, "Ibuf insert for page no %lu of index %s\n", - page_no, index->name); */ + page_no, index->name); */ #endif return(TRUE); @@ -2824,36 +2828,40 @@ ibuf_insert_to_index_page( ut_ad(dtuple_check_typed(entry)); if (UNIV_UNLIKELY(dict_table_is_comp(index->table) - != (ibool)!!page_is_comp(page))) { - fputs( -"InnoDB: Trying to insert a record from the insert buffer to an index page\n" -"InnoDB: but the 'compact' flag does not match!\n", stderr); + != (ibool)!!page_is_comp(page))) { + fputs("InnoDB: Trying to insert a record from" + " the insert buffer to an index page\n" + "InnoDB: but the 'compact' flag does not match!\n", + stderr); goto dump; } rec = page_rec_get_next(page_get_infimum_rec(page)); if (UNIV_UNLIKELY(rec_get_n_fields(rec, index) - != dtuple_get_n_fields(entry))) { - fputs( -"InnoDB: Trying to insert a record from the insert buffer to an index page\n" -"InnoDB: but the number of fields does not match!\n", stderr); - dump: + != dtuple_get_n_fields(entry))) { + fputs("InnoDB: Trying to insert a record from" + " the insert buffer to an index page\n" + "InnoDB: but the number of fields does not match!\n", + stderr); +dump: buf_page_print(page); dtuple_print(stderr, entry); - fputs( -"InnoDB: The table where where this index record belongs\n" -"InnoDB: is now probably corrupt. Please run CHECK TABLE on\n" -"InnoDB: your tables.\n" -"InnoDB: Send a detailed bug report to mysql@lists.mysql.com!\n", stderr); + fputs("InnoDB: The table where where" + " this index record belongs\n" + "InnoDB: is now probably corrupt." + " Please run CHECK TABLE on\n" + "InnoDB: your tables.\n" + "InnoDB: Submit a detailed bug report to" + " http://bugs.mysql.com!\n", stderr); return; } low_match = page_cur_search(page, index, entry, - PAGE_CUR_LE, &page_cur); + PAGE_CUR_LE, &page_cur); if (low_match == dtuple_get_n_fields(entry)) { rec = page_cur_get_rec(&page_cur); @@ -2868,39 +2876,45 @@ ibuf_insert_to_index_page( btr_page_reorganize(page, index, mtr); page_cur_search(page, index, entry, - PAGE_CUR_LE, &page_cur); + PAGE_CUR_LE, &page_cur); /* This time the record must fit */ - if (UNIV_UNLIKELY(!page_cur_tuple_insert( - &page_cur, entry, index, mtr))) { + if (UNIV_UNLIKELY(!page_cur_tuple_insert + (&page_cur, entry, index, mtr))) { ut_print_timestamp(stderr); fprintf(stderr, -"InnoDB: Error: Insert buffer insert fails; page free %lu, dtuple size %lu\n", - (ulong) page_get_max_insert_size(page, 1), - (ulong) rec_get_converted_size(index, entry)); + "InnoDB: Error: Insert buffer insert" + " fails; page free %lu," + " dtuple size %lu\n", + (ulong) page_get_max_insert_size + (page, 1), + (ulong) rec_get_converted_size + (index, entry)); fputs("InnoDB: Cannot insert index record ", - stderr); + stderr); dtuple_print(stderr, entry); - fputs( -"\nInnoDB: The table where where this index record belongs\n" -"InnoDB: is now probably corrupt. Please run CHECK TABLE on\n" -"InnoDB: that table.\n", stderr); + fputs("\nInnoDB: The table where" + " this index record belongs\n" + "InnoDB: is now probably corrupt." + " Please run CHECK TABLE on\n" + "InnoDB: that table.\n", stderr); - bitmap_page = ibuf_bitmap_get_map_page( - buf_frame_get_space_id(page), - buf_frame_get_page_no(page), - mtr); - old_bits = ibuf_bitmap_page_get_bits( - bitmap_page, - buf_frame_get_page_no(page), - IBUF_BITMAP_FREE, mtr); + bitmap_page = ibuf_bitmap_get_map_page + (buf_frame_get_space_id(page), + buf_frame_get_page_no(page), + mtr); + old_bits = ibuf_bitmap_page_get_bits + (bitmap_page, + buf_frame_get_page_no(page), + IBUF_BITMAP_FREE, mtr); - fprintf(stderr, "Bitmap bits %lu\n", (ulong) old_bits); + fprintf(stderr, "Bitmap bits %lu\n", + (ulong) old_bits); - fputs( -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); + fputs("InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n", stderr); } } } @@ -2936,11 +2950,12 @@ ibuf_delete_rec( if (success) { #ifdef UNIV_IBUF_DEBUG - printf( -"Decrementing ibuf count of space %lu page %lu\n" -"from %lu by 1\n", space, page_no, ibuf_count_get(space, page_no)); + fprintf(stderr, + "Decrementing ibuf count of space %lu page %lu\n" + "from %lu by 1\n", space, page_no, + ibuf_count_get(space, page_no)); ibuf_count_set(space, page_no, - ibuf_count_get(space, page_no) - 1); + ibuf_count_get(space, page_no) - 1); #endif return(FALSE); } @@ -2963,9 +2978,11 @@ ibuf_delete_rec( if (!success) { fprintf(stderr, - "InnoDB: ERROR: Submit the output to http://bugs.mysql.com\n" - "InnoDB: ibuf cursor restoration fails!\n" - "InnoDB: ibuf record inserted to page %lu\n", (ulong) page_no); + "InnoDB: ERROR: Submit the output to" + " http://bugs.mysql.com\n" + "InnoDB: ibuf cursor restoration fails!\n" + "InnoDB: ibuf record inserted to page %lu\n", + (ulong) page_no); fflush(stderr); rec_print_old(stderr, btr_pcur_get_rec(pcur)); @@ -2973,7 +2990,7 @@ ibuf_delete_rec( dtuple_print(stderr, search_tuple); rec_print_old(stderr, - page_rec_get_next(btr_pcur_get_rec(pcur))); + page_rec_get_next(btr_pcur_get_rec(pcur))); fflush(stderr); btr_pcur_commit_specify_mtr(pcur, mtr); @@ -2996,7 +3013,7 @@ ibuf_delete_rec( root = ibuf_tree_root_get(ibuf_data, 0, mtr); btr_cur_pessimistic_delete(&err, TRUE, btr_pcur_get_btr_cur(pcur), - FALSE, mtr); + FALSE, mtr); ut_a(err == DB_SUCCESS); #ifdef UNIV_IBUF_DEBUG @@ -3058,16 +3075,8 @@ ibuf_merge_or_delete_for_page( return; } -#ifdef UNIV_LOG_DEBUG - if (space % 2 != 0) { - - fputs("No ibuf operation in a replicate space\n", stderr); - - return; - } -#endif if (ibuf_fixed_addr_page(space, page_no) || fsp_descr_page(page_no) - || trx_sys_hdr_page(space, page_no)) { + || trx_sys_hdr_page(space, page_no)) { return; } @@ -3093,7 +3102,7 @@ ibuf_merge_or_delete_for_page( bitmap_page = ibuf_bitmap_get_map_page(space, page_no, &mtr); if (!ibuf_bitmap_page_get_bits(bitmap_page, page_no, - IBUF_BITMAP_BUFFERED, &mtr)) { + IBUF_BITMAP_BUFFERED, &mtr)) { /* No inserts buffered for this page */ mtr_commit(&mtr); @@ -3120,7 +3129,7 @@ ibuf_merge_or_delete_for_page( search_tuple = ibuf_search_tuple_build(space, page_no, heap); } else { search_tuple = ibuf_new_search_tuple_build(space, page_no, - heap); + heap); } if (page) { @@ -3141,10 +3150,10 @@ ibuf_merge_or_delete_for_page( mtr_start(&mtr); fputs(" InnoDB: Dump of the ibuf bitmap page:\n", - stderr); + stderr); bitmap_page = ibuf_bitmap_get_map_page(space, page_no, - &mtr); + &mtr); buf_page_print(bitmap_page); mtr_commit(&mtr); @@ -3154,13 +3163,20 @@ ibuf_merge_or_delete_for_page( buf_page_print(page); fprintf(stderr, -"InnoDB: Error: corruption in the tablespace. Bitmap shows insert\n" -"InnoDB: buffer records to page n:o %lu though the page\n" -"InnoDB: type is %lu, which is not an index page!\n" -"InnoDB: We try to resolve the problem by skipping the insert buffer\n" -"InnoDB: merge for this page. Please run CHECK TABLE on your tables\n" -"InnoDB: to determine if they are corrupt after this.\n\n" -"InnoDB: Please submit a detailed bug report to http://bugs.mysql.com\n\n", + "InnoDB: Error: corruption in the tablespace." + " Bitmap shows insert\n" + "InnoDB: buffer records to page n:o %lu" + " though the page\n" + "InnoDB: type is %lu, which is" + " not an index page!\n" + "InnoDB: We try to resolve the problem" + " by skipping the insert buffer\n" + "InnoDB: merge for this page." + " Please run CHECK TABLE on your tables\n" + "InnoDB: to determine if they are corrupt" + " after this.\n\n" + "InnoDB: Please submit a detailed bug report" + " to http://bugs.mysql.com\n\n", (ulong) page_no, (ulong) fil_page_get_type(page)); } @@ -3175,9 +3191,9 @@ loop: if (page) { ibool success = buf_page_get_known_nowait(RW_X_LATCH, page, - BUF_KEEP_OLD, - __FILE__, __LINE__, - &mtr); + BUF_KEEP_OLD, + __FILE__, __LINE__, + &mtr); ut_a(success); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_TREE_NODE); @@ -3187,7 +3203,7 @@ loop: /* Position pcur in the insert buffer at the first entry for this index page */ btr_pcur_open_on_user_rec(ibuf_data->index, search_tuple, PAGE_CUR_GE, - BTR_MODIFY_LEAF, &pcur, &mtr); + BTR_MODIFY_LEAF, &pcur, &mtr); if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr)); @@ -3201,7 +3217,7 @@ loop: /* Check if the entry is for this index page */ if (ibuf_rec_get_page_no(ibuf_rec) != page_no - || ibuf_rec_get_space(ibuf_rec) != space) { + || ibuf_rec_get_space(ibuf_rec) != space) { if (page) { page_header_reset_last_insert(page, &mtr); } @@ -3219,20 +3235,20 @@ loop: keep the latch to the ibuf_rec page until the insertion is finished! */ dict_index_t* dummy_index; - dulint max_trx_id = page_get_max_trx_id( - buf_frame_align(ibuf_rec)); + dulint max_trx_id = page_get_max_trx_id + (buf_frame_align(ibuf_rec)); page_update_max_trx_id(page, max_trx_id); - entry = ibuf_build_entry_from_ibuf_rec(ibuf_rec, - heap, &dummy_index); + entry = ibuf_build_entry_from_ibuf_rec + (ibuf_rec, heap, &dummy_index); #ifdef UNIV_IBUF_DEBUG volume += rec_get_converted_size(dummy_index, entry) - + page_dir_calc_reserved_space(1); + + page_dir_calc_reserved_space(1); ut_a(volume <= 4 * UNIV_PAGE_SIZE - / IBUF_PAGE_SIZE_PER_FREE_SPACE); + / IBUF_PAGE_SIZE_PER_FREE_SPACE); #endif ibuf_insert_to_index_page(entry, page, - dummy_index, &mtr); + dummy_index, &mtr); ibuf_dummy_index_free(dummy_index); } @@ -3240,7 +3256,7 @@ loop: /* Delete the record from ibuf */ if (ibuf_delete_rec(space, page_no, &pcur, search_tuple, - &mtr)) { + &mtr)) { /* Deletion was pessimistic and mtr was committed: we start from the beginning again */ @@ -3265,27 +3281,29 @@ reset_bit: if (update_ibuf_bitmap) { bitmap_page = ibuf_bitmap_get_map_page(space, page_no, &mtr); ibuf_bitmap_page_set_bits(bitmap_page, page_no, - IBUF_BITMAP_BUFFERED, FALSE, &mtr); - if (page) { - ulint old_bits = ibuf_bitmap_page_get_bits(bitmap_page, - page_no, IBUF_BITMAP_FREE, &mtr); - ulint new_bits = ibuf_index_page_calc_free(page); -#ifdef UNIV_IBUF_DEBUG - /* fprintf(stderr, "Old bits %lu new bits %lu max size %lu\n", - old_bits, new_bits, - page_get_max_insert_size_after_reorganize(page, 1)); */ + IBUF_BITMAP_BUFFERED, FALSE, &mtr); + if (page) { + ulint old_bits = ibuf_bitmap_page_get_bits + (bitmap_page, page_no, IBUF_BITMAP_FREE, &mtr); + ulint new_bits = ibuf_index_page_calc_free(page); +#if 0 /* defined UNIV_IBUF_DEBUG */ + fprintf(stderr, "Old bits %lu new bits %lu" + " max size %lu\n", + old_bits, new_bits, + page_get_max_insert_size_after_reorganize + (page, 1)); #endif if (old_bits != new_bits) { ibuf_bitmap_page_set_bits(bitmap_page, page_no, - IBUF_BITMAP_FREE, - new_bits, &mtr); + IBUF_BITMAP_FREE, + new_bits, &mtr); } } } -#ifdef UNIV_IBUF_DEBUG - /* fprintf(stderr, +#if 0 /* defined UNIV_IBUF_DEBUG */ + fprintf(stderr, "Ibuf merge %lu records volume %lu to page no %lu\n", - n_inserts, volume, page_no); */ + n_inserts, volume, page_no); #endif mtr_commit(&mtr); btr_pcur_close(&pcur); @@ -3352,7 +3370,7 @@ loop: /* Position pcur in the insert buffer at the first entry for the space */ btr_pcur_open_on_user_rec(ibuf_data->index, search_tuple, PAGE_CUR_GE, - BTR_MODIFY_LEAF, &pcur, &mtr); + BTR_MODIFY_LEAF, &pcur, &mtr); if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr)); @@ -3376,7 +3394,7 @@ loop: /* Delete the record from ibuf */ closed = ibuf_delete_rec(space, page_no, &pcur, search_tuple, - &mtr); + &mtr); if (closed) { /* Deletion was pessimistic and mtr was committed: we start from the beginning again */ @@ -3409,8 +3427,8 @@ leave_loop: mutex_exit(&ibuf_mutex); /* fprintf(stderr, - "InnoDB: Discarded %lu ibuf entries for space %lu\n", - (ulong) n_inserts, (ulong) space); + "InnoDB: Discarded %lu ibuf entries for space %lu\n", + (ulong) n_inserts, (ulong) space); */ ibuf_exit(); @@ -3477,9 +3495,11 @@ ibuf_is_empty(void) if (data->empty == FALSE) { fprintf(stderr, -"InnoDB: Warning: insert buffer tree is empty but the data struct does not\n" -"InnoDB: know it. This condition is legal if the master thread has not yet\n" -"InnoDB: run to completion.\n"); + "InnoDB: Warning: insert buffer tree is empty" + " but the data struct does not\n" + "InnoDB: know it. This condition is legal" + " if the master thread has not yet\n" + "InnoDB: run to completion.\n"); } } else { ut_a(data->empty == FALSE); @@ -3517,8 +3537,8 @@ ibuf_print( while (data) { fprintf(file, - "Ibuf: size %lu, free list len %lu, seg size %lu,\n" - "%lu inserts, %lu merged recs, %lu merges\n", + "Ibuf: size %lu, free list len %lu, seg size %lu,\n" + "%lu inserts, %lu merged recs, %lu merges\n", (ulong) data->size, (ulong) data->free_list_len, (ulong) data->seg_size, @@ -3532,7 +3552,8 @@ ibuf_print( fprintf(stderr, "Ibuf count for page %lu is %lu\n", (ulong) i, - (ulong) ibuf_count_get(data->space, i)); + (ulong) + ibuf_count_get(data->space, i)); } } #endif diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index c24b1603bd2..1f39b52f3c8 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -109,7 +109,7 @@ btr_page_set_level( ut_ad(level <= BTR_MAX_NODE_LEVEL); mlog_write_ulint(page + PAGE_HEADER + PAGE_LEVEL, level, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); } /************************************************************ @@ -124,9 +124,9 @@ btr_page_get_next( { ut_ad(page && mtr); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX) - || mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_PAGE_S_FIX)); + MTR_MEMO_PAGE_X_FIX) + || mtr_memo_contains(mtr, buf_block_align(page), + MTR_MEMO_PAGE_S_FIX)); return(mach_read_from_4(page + FIL_PAGE_NEXT)); } @@ -194,7 +194,7 @@ btr_node_ptr_get_child_page_no( /* The child address is in the last field */ field = rec_get_nth_field(rec, offsets, - rec_offs_n_fields(offsets) - 1, &len); + rec_offs_n_fields(offsets) - 1, &len); ut_ad(len == 4); @@ -202,7 +202,8 @@ btr_node_ptr_get_child_page_no( if (UNIV_UNLIKELY(page_no == 0)) { fprintf(stderr, -"InnoDB: a nonsensical page number 0 in a node ptr record at offset %lu\n", + "InnoDB: a nonsensical page number 0" + " in a node ptr record at offset %lu\n", (ulong) ut_align_offset(rec, UNIV_PAGE_SIZE)); buf_page_print(buf_frame_align(rec)); } @@ -221,13 +222,13 @@ btr_leaf_page_release( mtr_t* mtr) /* in: mtr */ { ut_ad(!mtr_memo_contains(mtr, buf_block_align(page), - MTR_MEMO_MODIFY)); + MTR_MEMO_MODIFY)); if (latch_mode == BTR_SEARCH_LEAF) { mtr_memo_release(mtr, buf_block_align(page), - MTR_MEMO_PAGE_S_FIX); + MTR_MEMO_PAGE_S_FIX); } else { ut_ad(latch_mode == BTR_MODIFY_LEAF); mtr_memo_release(mtr, buf_block_align(page), - MTR_MEMO_PAGE_X_FIX); + MTR_MEMO_PAGE_X_FIX); } } diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index d5dd4f3010a..1d41a345699 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -583,9 +583,11 @@ to know struct size! */ struct btr_cur_struct { dict_index_t* index; /* index where positioned */ page_cur_t page_cur; /* page cursor */ - page_t* left_page; /* this field is used to store a pointer - to the left neighbor page, in the cases - BTR_SEARCH_PREV and BTR_MODIFY_PREV */ + page_t* left_page; /* this field is used to store + a pointer to the left neighbor + page, in the cases + BTR_SEARCH_PREV and + BTR_MODIFY_PREV */ /*------------------------------*/ que_thr_t* thr; /* this field is only used when btr_cur_search_... is called for an diff --git a/storage/innobase/include/btr0cur.ic b/storage/innobase/include/btr0cur.ic index 7fbdf6035b0..76a4ff938a2 100644 --- a/storage/innobase/include/btr0cur.ic +++ b/storage/innobase/include/btr0cur.ic @@ -101,8 +101,8 @@ btr_cur_compress_recommendation( page = btr_cur_get_page(cursor); if ((page_get_data_size(page) < BTR_CUR_PAGE_COMPRESS_LIMIT) - || ((btr_page_get_next(page, mtr) == FIL_NULL) - && (btr_page_get_prev(page, mtr) == FIL_NULL))) { + || ((btr_page_get_next(page, mtr) == FIL_NULL) + && (btr_page_get_prev(page, mtr) == FIL_NULL))) { /* The page fillfactor has dropped below a predefined minimum value OR the level in the B-tree contains just @@ -110,7 +110,7 @@ btr_cur_compress_recommendation( root page. */ if (dict_tree_get_page((cursor->index)->tree) - == buf_frame_get_page_no(page)) { + == buf_frame_get_page_no(page)) { /* It is the root page */ @@ -144,9 +144,9 @@ btr_cur_can_delete_without_compress( page = btr_cur_get_page(cursor); if ((page_get_data_size(page) - rec_size < BTR_CUR_PAGE_COMPRESS_LIMIT) - || ((btr_page_get_next(page, mtr) == FIL_NULL) - && (btr_page_get_prev(page, mtr) == FIL_NULL)) - || (page_get_n_recs(page) < 2)) { + || ((btr_page_get_next(page, mtr) == FIL_NULL) + && (btr_page_get_prev(page, mtr) == FIL_NULL)) + || (page_get_n_recs(page) < 2)) { /* The page fillfactor will drop below a predefined minimum value, OR the level in the B-tree contains just @@ -154,7 +154,7 @@ btr_cur_can_delete_without_compress( compression if this is not the root page. */ if (dict_tree_get_page((cursor->index)->tree) - == buf_frame_get_page_no(page)) { + == buf_frame_get_page_no(page)) { /* It is the root page */ diff --git a/storage/innobase/include/btr0pcur.ic b/storage/innobase/include/btr0pcur.ic index a8aa82cf203..66462530716 100644 --- a/storage/innobase/include/btr0pcur.ic +++ b/storage/innobase/include/btr0pcur.ic @@ -20,7 +20,7 @@ btr_pcur_get_rel_pos( ut_ad(cursor->old_rec); ut_ad(cursor->old_stored == BTR_PCUR_OLD_STORED); ut_ad(cursor->pos_state == BTR_PCUR_WAS_POSITIONED - || cursor->pos_state == BTR_PCUR_IS_POSITIONED); + || cursor->pos_state == BTR_PCUR_IS_POSITIONED); return(cursor->rel_pos); } @@ -120,7 +120,7 @@ btr_pcur_get_up_match( btr_cur_t* btr_cursor; ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED) - || (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); + || (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); btr_cursor = btr_pcur_get_btr_cur(cursor); @@ -143,7 +143,7 @@ btr_pcur_get_low_match( btr_cur_t* btr_cursor; ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED) - || (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); + || (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); btr_cursor = btr_pcur_get_btr_cur(cursor); ut_ad(btr_cursor->low_match != ULINT_UNDEFINED); @@ -198,7 +198,7 @@ btr_pcur_is_on_user_rec( ut_ad(cursor->latch_mode != BTR_NO_LATCHES); if ((btr_pcur_is_before_first_on_page(cursor, mtr)) - || (btr_pcur_is_after_last_on_page(cursor, mtr))) { + || (btr_pcur_is_after_last_on_page(cursor, mtr))) { return(FALSE); } @@ -491,7 +491,7 @@ btr_pcur_open( btr_cursor = btr_pcur_get_btr_cur(cursor); btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, - btr_cursor, 0, mtr); + btr_cursor, 0, mtr); cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->trx_if_known = NULL; @@ -533,7 +533,7 @@ btr_pcur_open_with_no_init( btr_cursor = btr_pcur_get_btr_cur(cursor); btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, - btr_cursor, has_search_latch, mtr); + btr_cursor, has_search_latch, mtr); cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; @@ -568,7 +568,7 @@ btr_pcur_open_at_index_side( } btr_cur_open_at_index_side(from_left, index, latch_mode, - btr_pcur_get_btr_cur(pcur), mtr); + btr_pcur_get_btr_cur(pcur), mtr); pcur->pos_state = BTR_PCUR_IS_POSITIONED; pcur->old_stored = BTR_PCUR_OLD_NOT_STORED; @@ -595,7 +595,7 @@ btr_pcur_open_at_rnd_pos( btr_pcur_init(cursor); btr_cur_open_at_rnd_pos(index, latch_mode, - btr_pcur_get_btr_cur(cursor), mtr); + btr_pcur_get_btr_cur(cursor), mtr); cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 12aac878614..110ef36a296 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -156,8 +156,8 @@ improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed as LA! */ NOTE! The following macros should be used instead of buf_page_optimistic_get_func, to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed as LA! */ -#define buf_page_optimistic_get(LA, BL, G, MC, MTR) buf_page_optimistic_get_func(\ - LA, BL, G, MC, __FILE__, __LINE__, MTR) +#define buf_page_optimistic_get(LA, BL, G, MC, MTR) \ + buf_page_optimistic_get_func(LA, BL, G, MC, __FILE__, __LINE__, MTR) /************************************************************************ This is the general function used to get optimistic access to a database page. */ diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index 3c7a64cbcb0..015de862705 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -28,7 +28,7 @@ buf_block_peek_if_too_old( buf_block_t* block) /* in: block to make younger */ { return(buf_pool->freed_page_clock >= block->freed_page_clock - + 1 + (buf_pool->curr_size / 1024)); + + 1 + (buf_pool->curr_size / 1024)); } /************************************************************************* @@ -82,8 +82,8 @@ buf_pool_is_block( void* ptr) /* in: pointer to memory */ { if ((buf_pool->blocks <= (buf_block_t*)ptr) - && ((buf_block_t*)ptr < buf_pool->blocks - + buf_pool->max_size)) { + && ((buf_block_t*)ptr < buf_pool->blocks + + buf_pool->max_size)) { return(TRUE); } @@ -151,7 +151,7 @@ buf_block_get_frame( ut_ad(block < buf_pool->blocks + buf_pool->max_size); ut_ad(block->state != BUF_BLOCK_NOT_USED); ut_ad((block->state != BUF_BLOCK_FILE_PAGE) - || (block->buf_fix_count > 0)); + || (block->buf_fix_count > 0)); return(block->frame); } @@ -209,16 +209,19 @@ buf_block_align( frame_zero = buf_pool->frame_zero; if (UNIV_UNLIKELY((ulint)ptr < (ulint)frame_zero) - || UNIV_UNLIKELY((ulint)ptr > (ulint)(buf_pool->high_end))) { + || UNIV_UNLIKELY((ulint)ptr > (ulint)(buf_pool->high_end))) { ut_print_timestamp(stderr); fprintf(stderr, -"InnoDB: Error: trying to access a stray pointer %p\n" -"InnoDB: buf pool start is at %p, end at %p\n" -"InnoDB: Probable reason is database corruption or memory\n" -"InnoDB: corruption. If this happens in an InnoDB database recovery, see\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" -"InnoDB: how to force recovery.\n", + "InnoDB: Error: trying to access a stray pointer %p\n" + "InnoDB: buf pool start is at %p, end at %p\n" + "InnoDB: Probable reason is database corruption" + " or memory\n" + "InnoDB: corruption. If this happens in an" + " InnoDB database recovery, see\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "forcing-recovery.html\n" + "InnoDB: how to force recovery.\n", ptr, frame_zero, buf_pool->high_end); ut_error; @@ -245,16 +248,19 @@ buf_frame_align( frame = ut_align_down(ptr, UNIV_PAGE_SIZE); if (UNIV_UNLIKELY((ulint)frame < (ulint)(buf_pool->frame_zero)) - || UNIV_UNLIKELY((ulint)frame >= (ulint)(buf_pool->high_end))) { + || UNIV_UNLIKELY((ulint)frame >= (ulint)(buf_pool->high_end))) { ut_print_timestamp(stderr); fprintf(stderr, -"InnoDB: Error: trying to access a stray pointer %p\n" -"InnoDB: buf pool start is at %p, end at %p\n" -"InnoDB: Probable reason is database corruption or memory\n" -"InnoDB: corruption. If this happens in an InnoDB database recovery, see\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" -"InnoDB: how to force recovery.\n", + "InnoDB: Error: trying to access a stray pointer %p\n" + "InnoDB: buf pool start is at %p, end at %p\n" + "InnoDB: Probable reason is database corruption" + " or memory\n" + "InnoDB: corruption. If this happens in an" + " InnoDB database recovery, see\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "forcing-recovery.html\n" + "InnoDB: how to force recovery.\n", ptr, buf_pool->frame_zero, buf_pool->high_end); ut_error; @@ -449,7 +455,7 @@ buf_frame_modify_clock_inc( #ifdef UNIV_SYNC_DEBUG ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0)) - || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); + || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); #endif /*UNIV_SYNC_DEBUG */ UT_DULINT_INC(block->modify_clock); @@ -470,7 +476,7 @@ buf_block_modify_clock_inc( { #ifdef UNIV_SYNC_DEBUG ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0)) - || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); + || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); #endif /* UNIV_SYNC_DEBUG */ UT_DULINT_INC(block->modify_clock); @@ -490,7 +496,7 @@ buf_block_get_modify_clock( { #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) - || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); + || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); #endif /* UNIV_SYNC_DEBUG */ return(block->modify_clock); @@ -551,7 +557,7 @@ buf_page_hash_get( fold = buf_page_address_fold(space, offset); HASH_SEARCH(hash, buf_pool->page_hash, fold, block, - (block->space == space) && (block->offset == offset)); + (block->space == space) && (block->offset == offset)); ut_a(block == NULL || block->state == BUF_BLOCK_FILE_PAGE); return(block); @@ -580,9 +586,9 @@ buf_page_get_release_on_io( buf_frame_t* frame; frame = buf_page_get_gen(space, offset, rw_latch, guess, - BUF_GET_IF_IN_POOL, - __FILE__, __LINE__, - mtr); + BUF_GET_IF_IN_POOL, + __FILE__, __LINE__, + mtr); if (frame != NULL) { return(frame); diff --git a/storage/innobase/include/buf0flu.ic b/storage/innobase/include/buf0flu.ic index ea619cd4063..b304673f8be 100644 --- a/storage/innobase/include/buf0flu.ic +++ b/storage/innobase/include/buf0flu.ic @@ -59,7 +59,7 @@ buf_flush_note_modification( buf_flush_insert_into_flush_list(block); } else { ut_ad(ut_dulint_cmp(block->oldest_modification, - mtr->start_lsn) <= 0); + mtr->start_lsn) <= 0); } ++srv_buf_pool_write_requests; @@ -99,7 +99,7 @@ buf_flush_recv_note_modification( buf_flush_insert_sorted_into_flush_list(block); } else { ut_ad(ut_dulint_cmp(block->oldest_modification, - start_lsn) <= 0); + start_lsn) <= 0); } mutex_exit(&(buf_pool->mutex)); diff --git a/storage/innobase/include/buf0rea.h b/storage/innobase/include/buf0rea.h index 380a42f4b80..e4620172860 100644 --- a/storage/innobase/include/buf0rea.h +++ b/storage/innobase/include/buf0rea.h @@ -94,7 +94,8 @@ buf_read_recv_pages( /* The size in pages of the area which the read-ahead algorithms read if invoked */ -#define BUF_READ_AHEAD_AREA ut_min(64, ut_2_power_up(buf_pool->curr_size / 32)) +#define BUF_READ_AHEAD_AREA \ + ut_min(64, ut_2_power_up(buf_pool->curr_size / 32)) /* Modes used in read-ahead */ #define BUF_READ_IBUF_PAGES_ONLY 131 diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h index 8e906fcb2e5..40592c3c0ce 100644 --- a/storage/innobase/include/data0data.h +++ b/storage/innobase/include/data0data.h @@ -320,14 +320,6 @@ void dfield_print_also_hex( /*==================*/ dfield_t* dfield); /* in: dfield */ -/***************************************************************** -Print a dfield value using ut_print_buf. */ - -void -dfield_print_raw( -/*=============*/ - FILE* f, /* in: output stream */ - dfield_t* dfield); /* in: dfield */ /************************************************************** The following function prints the contents of a tuple. */ diff --git a/storage/innobase/include/data0data.ic b/storage/innobase/include/data0data.ic index 6b07ade2934..77fce029851 100644 --- a/storage/innobase/include/data0data.ic +++ b/storage/innobase/include/data0data.ic @@ -52,7 +52,7 @@ dfield_get_data( { ut_ad(field); ut_ad((field->len == UNIV_SQL_NULL) - || (field->data != &data_error)); + || (field->data != &data_error)); return(field->data); } @@ -69,7 +69,7 @@ dfield_get_len( { ut_ad(field); ut_ad((field->len == UNIV_SQL_NULL) - || (field->data != &data_error)); + || (field->data != &data_error)); return(field->len); } @@ -146,9 +146,9 @@ dfield_datas_are_binary_equal( len = field1->len; if ((len != field2->len) - || ((len != UNIV_SQL_NULL) - && (0 != ut_memcmp(field1->data, field2->data, - len)))) { + || ((len != UNIV_SQL_NULL) + && (0 != ut_memcmp(field1->data, field2->data, + len)))) { return(FALSE); } @@ -262,7 +262,7 @@ dtuple_create( ut_ad(heap); tuple = (dtuple_t*) mem_heap_alloc(heap, sizeof(dtuple_t) - + n_fields * sizeof(dfield_t)); + + n_fields * sizeof(dfield_t)); tuple->info_bits = 0; tuple->n_fields = n_fields; tuple->n_fields_cmp = n_fields; @@ -426,7 +426,7 @@ dtuple_contains_null( for (i = 0; i < n; i++) { if (dfield_get_len(dtuple_get_nth_field(tuple, i)) - == UNIV_SQL_NULL) { + == UNIV_SQL_NULL) { return(TRUE); } diff --git a/storage/innobase/include/data0type.ic b/storage/innobase/include/data0type.ic index aabf471a70c..d2027592c09 100644 --- a/storage/innobase/include/data0type.ic +++ b/storage/innobase/include/data0type.ic @@ -59,12 +59,12 @@ dtype_set_mblen( if (dtype_is_string_type(type->mtype)) { #ifndef UNIV_HOTBACKUP innobase_get_cset_width(dtype_get_charset_coll(type->prtype), - &type->mbminlen, &type->mbmaxlen); + &type->mbminlen, &type->mbmaxlen); ut_ad(type->mbminlen <= type->mbmaxlen); #else /* !UNIV_HOTBACKUP */ #ifdef notdefined -printf("ibbackup: DEBUG: type->mtype=%lu, type->prtype=%lu\n", - type->mtype, type->prtype); + printf("ibbackup: DEBUG: type->mtype=%lu, type->prtype=%lu\n", + type->mtype, type->prtype); #endif ut_a(type->mtype <= DATA_BINARY); #ifdef notdefined @@ -208,7 +208,7 @@ dtype_get_pad_char( case DATA_FIXBINARY: case DATA_BINARY: if (UNIV_UNLIKELY(dtype_get_charset_coll(type->prtype) - == DATA_MYSQL_BINARY_CHARSET_COLL)) { + == DATA_MYSQL_BINARY_CHARSET_COLL)) { /* Starting from 5.0.18, do not pad VARBINARY or BINARY columns. */ return(ULINT_UNDEFINED); @@ -257,8 +257,8 @@ dtype_new_store_for_order_and_null_size( } /* In versions < 4.1.2 we had: if (type->prtype & DATA_NONLATIN1) { - buf[0] = buf[0] | 64; - } + buf[0] = buf[0] | 64; + } */ buf[1] = (byte)(type->prtype & 0xFFUL); @@ -296,7 +296,7 @@ dtype_read_for_order_and_null_size( type->len = mach_read_from_2(buf + 2); type->prtype = dtype_form_prtype(type->prtype, - data_mysql_default_charset_coll); + data_mysql_default_charset_coll); dtype_set_mblen(type); } @@ -368,80 +368,81 @@ dtype_get_fixed_size( switch (mtype) { case DATA_SYS: #ifdef UNIV_DEBUG - switch (type->prtype & DATA_MYSQL_TYPE_MASK) { - default: - ut_ad(0); - return(0); - case DATA_ROW_ID: - ut_ad(type->len == DATA_ROW_ID_LEN); - break; - case DATA_TRX_ID: - ut_ad(type->len == DATA_TRX_ID_LEN); - break; - case DATA_ROLL_PTR: - ut_ad(type->len == DATA_ROLL_PTR_LEN); - break; - case DATA_MIX_ID: - ut_ad(type->len == DATA_MIX_ID_LEN); - break; - } + switch (type->prtype & DATA_MYSQL_TYPE_MASK) { + default: + ut_ad(0); + return(0); + case DATA_ROW_ID: + ut_ad(type->len == DATA_ROW_ID_LEN); + break; + case DATA_TRX_ID: + ut_ad(type->len == DATA_TRX_ID_LEN); + break; + case DATA_ROLL_PTR: + ut_ad(type->len == DATA_ROLL_PTR_LEN); + break; + case DATA_MIX_ID: + ut_ad(type->len == DATA_MIX_ID_LEN); + break; + } #endif /* UNIV_DEBUG */ case DATA_CHAR: case DATA_FIXBINARY: case DATA_INT: case DATA_FLOAT: case DATA_DOUBLE: - return(dtype_get_len(type)); + return(dtype_get_len(type)); case DATA_MYSQL: - if (type->prtype & DATA_BINARY_TYPE) { - return(dtype_get_len(type)); - } else { + if (type->prtype & DATA_BINARY_TYPE) { + return(dtype_get_len(type)); + } else { #ifdef UNIV_HOTBACKUP - if (type->mbminlen == type->mbmaxlen) { - return(dtype_get_len(type)); - } -#else /* UNIV_HOTBACKUP */ - /* We play it safe here and ask MySQL for - mbminlen and mbmaxlen. Although - type->mbminlen and type->mbmaxlen are - initialized if and only if type->prtype - is (in one of the 3 functions in this file), - it could be that none of these functions - has been called. */ - - ulint mbminlen, mbmaxlen; - - innobase_get_cset_width( - dtype_get_charset_coll(type->prtype), - &mbminlen, &mbmaxlen); - - if (UNIV_UNLIKELY(type->mbminlen != mbminlen) - || UNIV_UNLIKELY(type->mbmaxlen != mbmaxlen)) { - - ut_print_timestamp(stderr); - fprintf(stderr, " InnoDB: " - "mbminlen=%lu, " - "mbmaxlen=%lu, " - "type->mbminlen=%lu, " - "type->mbmaxlen=%lu\n", - (ulong) mbminlen, - (ulong) mbmaxlen, - (ulong) type->mbminlen, - (ulong) type->mbmaxlen); - } - if (mbminlen == mbmaxlen) { - return(dtype_get_len(type)); - } -#endif /* !UNIV_HOTBACKUP */ + if (type->mbminlen == type->mbmaxlen) { + return(dtype_get_len(type)); } - /* fall through for variable-length charsets */ +#else /* UNIV_HOTBACKUP */ + /* We play it safe here and ask MySQL for + mbminlen and mbmaxlen. Although + type->mbminlen and type->mbmaxlen are + initialized if and only if type->prtype + is (in one of the 3 functions in this file), + it could be that none of these functions + has been called. */ + + ulint mbminlen, mbmaxlen; + + innobase_get_cset_width + (dtype_get_charset_coll(type->prtype), + &mbminlen, &mbmaxlen); + + if (UNIV_UNLIKELY(type->mbminlen != mbminlen) + || UNIV_UNLIKELY(type->mbmaxlen != mbmaxlen)) { + + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: " + "mbminlen=%lu, " + "mbmaxlen=%lu, " + "type->mbminlen=%lu, " + "type->mbmaxlen=%lu\n", + (ulong) mbminlen, + (ulong) mbmaxlen, + (ulong) type->mbminlen, + (ulong) type->mbmaxlen); + } + if (mbminlen == mbmaxlen) { + return(dtype_get_len(type)); + } +#endif /* !UNIV_HOTBACKUP */ + } + /* fall through for variable-length charsets */ case DATA_VARCHAR: case DATA_BINARY: case DATA_DECIMAL: case DATA_VARMYSQL: case DATA_BLOB: - return(0); - default: ut_error; + return(0); + default: + ut_error; } return(0); @@ -459,46 +460,46 @@ dtype_get_min_size( switch (type->mtype) { case DATA_SYS: #ifdef UNIV_DEBUG - switch (type->prtype & DATA_MYSQL_TYPE_MASK) { - default: - ut_ad(0); - return(0); - case DATA_ROW_ID: - ut_ad(type->len == DATA_ROW_ID_LEN); - break; - case DATA_TRX_ID: - ut_ad(type->len == DATA_TRX_ID_LEN); - break; - case DATA_ROLL_PTR: - ut_ad(type->len == DATA_ROLL_PTR_LEN); - break; - case DATA_MIX_ID: - ut_ad(type->len == DATA_MIX_ID_LEN); - break; - } + switch (type->prtype & DATA_MYSQL_TYPE_MASK) { + default: + ut_ad(0); + return(0); + case DATA_ROW_ID: + ut_ad(type->len == DATA_ROW_ID_LEN); + break; + case DATA_TRX_ID: + ut_ad(type->len == DATA_TRX_ID_LEN); + break; + case DATA_ROLL_PTR: + ut_ad(type->len == DATA_ROLL_PTR_LEN); + break; + case DATA_MIX_ID: + ut_ad(type->len == DATA_MIX_ID_LEN); + break; + } #endif /* UNIV_DEBUG */ case DATA_CHAR: case DATA_FIXBINARY: case DATA_INT: case DATA_FLOAT: case DATA_DOUBLE: - return(type->len); + return(type->len); case DATA_MYSQL: - if ((type->prtype & DATA_BINARY_TYPE) - || type->mbminlen == type->mbmaxlen) { - return(type->len); - } - /* this is a variable-length character set */ - ut_a(type->mbminlen > 0); - ut_a(type->mbmaxlen > type->mbminlen); - ut_a(type->len % type->mbmaxlen == 0); - return(type->len * type->mbminlen / type->mbmaxlen); + if ((type->prtype & DATA_BINARY_TYPE) + || type->mbminlen == type->mbmaxlen) { + return(type->len); + } + /* this is a variable-length character set */ + ut_a(type->mbminlen > 0); + ut_a(type->mbmaxlen > type->mbminlen); + ut_a(type->len % type->mbmaxlen == 0); + return(type->len * type->mbminlen / type->mbmaxlen); case DATA_VARCHAR: case DATA_BINARY: case DATA_DECIMAL: case DATA_VARMYSQL: case DATA_BLOB: - return(0); + return(0); default: ut_error; } diff --git a/storage/innobase/include/dict0boot.h b/storage/innobase/include/dict0boot.h index 39e3bdf72b0..41ce0ac059a 100644 --- a/storage/innobase/include/dict0boot.h +++ b/storage/innobase/include/dict0boot.h @@ -108,7 +108,8 @@ dict_create(void); #define DICT_HDR_TABLE_IDS 36 /* Root of the table index tree */ #define DICT_HDR_COLUMNS 40 /* Root of the column index tree */ #define DICT_HDR_INDEXES 44 /* Root of the index index tree */ -#define DICT_HDR_FIELDS 48 /* Root of the index field index tree */ +#define DICT_HDR_FIELDS 48 /* Root of the index field + index tree */ #define DICT_HDR_FSEG_HEADER 56 /* Segment header for the tablespace segment into which the dictionary diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index c65fdde81e9..de00148535f 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -163,7 +163,7 @@ dict_table_get_sys_col( ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); col = dict_table_get_nth_col(table, table->n_cols - - DATA_N_SYS_COLS + sys); + - DATA_N_SYS_COLS + sys); ut_ad(col->type.mtype == DATA_SYS); ut_ad(col->type.prtype == (sys | DATA_NOT_NULL)); @@ -324,8 +324,8 @@ dict_index_get_sys_col_pos( return(col->clust_pos); } - return(dict_index_get_nth_col_pos(index, - dict_table_get_sys_col_no(index->table, type))); + return(dict_index_get_nth_col_pos + (index, dict_table_get_sys_col_no(index->table, type))); } /************************************************************************* @@ -366,8 +366,8 @@ dict_index_get_nth_type( dict_index_t* index, /* in: index */ ulint pos) /* in: position of the field */ { - return(dict_col_get_type(dict_field_get_col( - dict_index_get_nth_field(index, pos)))); + return(dict_col_get_type(dict_field_get_col + (dict_index_get_nth_field(index, pos)))); } /************************************************************************ @@ -380,8 +380,8 @@ dict_index_get_nth_col_no( dict_index_t* index, /* in: index */ ulint pos) /* in: position of the field */ { - return(dict_col_get_no(dict_field_get_col( - dict_index_get_nth_field(index, pos)))); + return(dict_col_get_no(dict_field_get_col + (dict_index_get_nth_field(index, pos)))); } /************************************************************************* @@ -514,7 +514,7 @@ dict_table_check_if_in_cache_low( table_fold = ut_fold_string(table_name); HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, table, - ut_strcmp(table->name, table_name) == 0); + ut_strcmp(table->name, table_name) == 0); return(table); } @@ -564,7 +564,7 @@ dict_table_get_on_id_low( fold = ut_fold_dulint(table_id); HASH_SEARCH(id_hash, dict_sys->table_id_hash, fold, table, - ut_dulint_cmp(table->id, table_id) == 0); + ut_dulint_cmp(table->id, table_id) == 0); if (table == NULL) { table = dict_load_table_on_id(table_id); } diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 427991180f6..e8682b79387 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -132,8 +132,6 @@ struct dict_col_struct{ const char* name; /* name */ dtype_t type; /* data type */ dict_table_t* table; /* back pointer to table of this column */ - ulint aux; /* this is used as an auxiliary variable - in some of the functions below */ }; /* DICT_MAX_INDEX_COL_LEN is measured in bytes and is the max index column diff --git a/storage/innobase/include/eval0eval.ic b/storage/innobase/include/eval0eval.ic index 26e9b8e41fe..caffa2e0bfd 100644 --- a/storage/innobase/include/eval0eval.ic +++ b/storage/innobase/include/eval0eval.ic @@ -79,7 +79,7 @@ eval_sym( column */ dfield_copy_data(que_node_get_val(sym_node), - que_node_get_val(sym_node->indirection)); + que_node_get_val(sym_node->indirection)); } } @@ -230,5 +230,5 @@ eval_node_copy_val( dfield2 = que_node_get_val(node2); eval_node_copy_and_alloc_val(node1, dfield_get_data(dfield2), - dfield_get_len(dfield2)); + dfield_get_len(dfield2)); } diff --git a/storage/innobase/include/fut0lst.ic b/storage/innobase/include/fut0lst.ic index 4681a1ce509..6c7e863b078 100644 --- a/storage/innobase/include/fut0lst.ic +++ b/storage/innobase/include/fut0lst.ic @@ -38,11 +38,11 @@ flst_write_addr( { ut_ad(faddr && mtr); ut_ad(mtr_memo_contains(mtr, buf_block_align(faddr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); mlog_write_ulint(faddr + FIL_ADDR_PAGE, addr.page, MLOG_4BYTES, mtr); mlog_write_ulint(faddr + FIL_ADDR_BYTE, addr.boffset, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); } /************************************************************************ @@ -61,7 +61,7 @@ flst_read_addr( addr.page = mtr_read_ulint(faddr + FIL_ADDR_PAGE, MLOG_4BYTES, mtr); addr.boffset = mtr_read_ulint(faddr + FIL_ADDR_BYTE, MLOG_2BYTES, - mtr); + mtr); return(addr); } @@ -75,7 +75,7 @@ flst_init( mtr_t* mtr) /* in: mini-transaction handle */ { ut_ad(mtr_memo_contains(mtr, buf_block_align(base), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); mlog_write_ulint(base + FLST_LEN, 0, MLOG_4BYTES, mtr); flst_write_addr(base + FLST_FIRST, fil_addr_null, mtr); flst_write_addr(base + FLST_LAST, fil_addr_null, mtr); diff --git a/storage/innobase/include/ibuf0ibuf.ic b/storage/innobase/include/ibuf0ibuf.ic index 7e75fccc160..4c5f6dbf5e1 100644 --- a/storage/innobase/include/ibuf0ibuf.ic +++ b/storage/innobase/include/ibuf0ibuf.ic @@ -80,7 +80,7 @@ ibuf_should_try( decide */ { if (!(index->type & DICT_CLUSTERED) - && (ignore_sec_unique || !(index->type & DICT_UNIQUE))) { + && (ignore_sec_unique || !(index->type & DICT_UNIQUE))) { ibuf_flush_count++; @@ -165,8 +165,8 @@ ibuf_index_page_calc_free( /* out: value for ibuf bitmap bits */ page_t* page) /* in: non-unique secondary index page */ { - return(ibuf_index_page_calc_free_bits( - page_get_max_insert_size_after_reorganize(page, 1))); + return(ibuf_index_page_calc_free_bits + (page_get_max_insert_size_after_reorganize(page, 1))); } /**************************************************************************** @@ -201,7 +201,7 @@ ibuf_update_free_bits_if_full( # error "ULINT32_UNDEFINED <= UNIV_PAGE_SIZE" #endif after = ibuf_index_page_calc_free_bits(max_ins_size - - increase); + - increase); #ifdef UNIV_IBUF_DEBUG ut_a(after <= ibuf_index_page_calc_free(page)); #endif diff --git a/storage/innobase/include/lock0lock.ic b/storage/innobase/include/lock0lock.ic index c7a71bb45d8..feec460bec8 100644 --- a/storage/innobase/include/lock0lock.ic +++ b/storage/innobase/include/lock0lock.ic @@ -47,7 +47,7 @@ lock_rec_hash( ulint page_no)/* in: page number */ { return(hash_calc_hash(lock_rec_fold(space, page_no), - lock_sys->rec_hash)); + lock_sys->rec_hash)); } /************************************************************************* diff --git a/storage/innobase/include/log0log.ic b/storage/innobase/include/log0log.ic index 898a8f3b6e3..06deff196bc 100644 --- a/storage/innobase/include/log0log.ic +++ b/storage/innobase/include/log0log.ic @@ -33,7 +33,7 @@ log_block_get_flush_bit( byte* log_block) /* in: log block */ { if (LOG_BLOCK_FLUSH_BIT_MASK - & mach_read_from_4(log_block + LOG_BLOCK_HDR_NO)) { + & mach_read_from_4(log_block + LOG_BLOCK_HDR_NO)) { return(TRUE); } @@ -74,7 +74,7 @@ log_block_get_hdr_no( byte* log_block) /* in: log block */ { return(~LOG_BLOCK_FLUSH_BIT_MASK - & mach_read_from_4(log_block + LOG_BLOCK_HDR_NO)); + & mach_read_from_4(log_block + LOG_BLOCK_HDR_NO)); } /**************************************************************** @@ -166,7 +166,7 @@ log_block_set_checkpoint_no( dulint no) /* in: checkpoint no */ { mach_write_to_4(log_block + LOG_BLOCK_CHECKPOINT_NO, - ut_dulint_get_low(no)); + ut_dulint_get_low(no)); } /**************************************************************** @@ -227,7 +227,7 @@ log_block_get_checksum( byte* log_block) /* in: log block */ { return(mach_read_from_4(log_block + OS_FILE_LOG_BLOCK_SIZE - - LOG_BLOCK_CHECKSUM)); + - LOG_BLOCK_CHECKSUM)); } /**************************************************************** @@ -240,8 +240,8 @@ log_block_set_checksum( ulint checksum) /* in: checksum */ { mach_write_to_4(log_block + OS_FILE_LOG_BLOCK_SIZE - - LOG_BLOCK_CHECKSUM, - checksum); + - LOG_BLOCK_CHECKSUM, + checksum); } /**************************************************************** @@ -287,7 +287,7 @@ log_block_init_in_old_format( log_block_set_hdr_no(log_block, no); mach_write_to_4(log_block + OS_FILE_LOG_BLOCK_SIZE - - LOG_BLOCK_CHECKSUM, no); + - LOG_BLOCK_CHECKSUM, no); log_block_set_data_len(log_block, LOG_BLOCK_HDR_SIZE); log_block_set_first_rec_group(log_block, 0); } @@ -333,8 +333,8 @@ log_reserve_and_write_fast( ut_memcpy(log->buf + log->buf_free, str, len); log_block_set_data_len(ut_align_down(log->buf + log->buf_free, - OS_FILE_LOG_BLOCK_SIZE), - data_len); + OS_FILE_LOG_BLOCK_SIZE), + data_len); #ifdef UNIV_LOG_DEBUG log->old_buf_free = log->buf_free; log->old_lsn = log->lsn; @@ -349,7 +349,7 @@ log_reserve_and_write_fast( #ifdef UNIV_LOG_DEBUG log_check_log_recs(log->buf + log->old_buf_free, - log->buf_free - log->old_buf_free, log->old_lsn); + log->buf_free - log->old_buf_free, log->old_lsn); #endif return(lsn); } diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index 7bdf8bf6100..091bbe34562 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -214,27 +214,6 @@ void recv_recovery_from_archive_finish(void); /*===================================*/ #endif /* UNIV_LOG_ARCHIVE */ -/*********************************************************************** -Checks that a replica of a space is identical to the original space. */ - -void -recv_compare_spaces( -/*================*/ - ulint space1, /* in: space id */ - ulint space2, /* in: space id */ - ulint n_pages);/* in: number of pages */ -/*********************************************************************** -Checks that a replica of a space is identical to the original space. Disables -ibuf operations and flushes and invalidates the buffer pool pages after the -test. This function can be used to check the recovery before dict or trx -systems are initialized. */ - -void -recv_compare_spaces_low( -/*====================*/ - ulint space1, /* in: space id */ - ulint space2, /* in: space id */ - ulint n_pages);/* in: number of pages */ /* Block of log record data */ typedef struct recv_data_struct recv_data_t; @@ -361,11 +340,6 @@ roll-forward */ #define RECV_BEING_PROCESSED 73 #define RECV_PROCESSED 74 -/* The number which is added to a space id to obtain the replicate space -in the debug version: spaces with an odd number as the id are replicate -spaces */ -#define RECV_REPLICA_SPACE_ADD 1 - extern ulint recv_n_pool_free_frames; #ifndef UNIV_NONINL diff --git a/storage/innobase/include/mach0data.ic b/storage/innobase/include/mach0data.ic index 2199565aff4..03ece7529a8 100644 --- a/storage/innobase/include/mach0data.ic +++ b/storage/innobase/include/mach0data.ic @@ -65,7 +65,7 @@ mach_read_from_2( ut_ad(b); return( ((ulint)(b[0]) << 8) + (ulint)(b[1]) - ); + ); } /************************************************************ @@ -131,7 +131,7 @@ mach_read_from_3( return( ((ulint)(b[0]) << 16) + ((ulint)(b[1]) << 8) + (ulint)(b[2]) - ); + ); } /*********************************************************** @@ -146,22 +146,10 @@ mach_write_to_4( { ut_ad(b); -#if (0 == 1) && !defined(__STDC__) && defined(UNIV_INTEL) && (UNIV_WORD_SIZE == 4) && defined(UNIV_VISUALC) - - /* We do not use this even on Intel, because unaligned accesses may - be slow */ - - __asm MOV EAX, n - __asm BSWAP EAX /* Intel is little-endian, must swap bytes */ - __asm MOV n, EAX - - *((ulint*)b) = n; -#else b[0] = (byte)(n >> 24); b[1] = (byte)(n >> 16); b[2] = (byte)(n >> 8); b[3] = (byte)n; -#endif } /************************************************************ @@ -174,28 +162,12 @@ mach_read_from_4( /* out: ulint integer */ byte* b) /* in: pointer to four bytes */ { -#if (0 == 1) && !defined(__STDC__) && defined(UNIV_INTEL) && (UNIV_WORD_SIZE == 4) && defined(UNIV_VISUALC) - /* We do not use this even on Intel, because unaligned accesses may - be slow */ - - ulint res; - - ut_ad(b); - - __asm MOV EDX, b - __asm MOV ECX, DWORD PTR [EDX] - __asm BSWAP ECX /* Intel is little-endian, must swap bytes */ - __asm MOV res, ECX - - return(res); -#else ut_ad(b); return( ((ulint)(b[0]) << 24) + ((ulint)(b[1]) << 16) + ((ulint)(b[2]) << 8) + (ulint)(b[3]) - ); -#endif + ); } /************************************************************* @@ -492,7 +464,7 @@ mach_dulint_get_much_compressed_size( } return(1 + mach_get_compressed_size(ut_dulint_get_high(n)) - + mach_get_compressed_size(ut_dulint_get_low(n))); + + mach_get_compressed_size(ut_dulint_get_low(n))); } /************************************************************* diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic index db0ab7aba8c..069f8de36cb 100644 --- a/storage/innobase/include/mem0mem.ic +++ b/storage/innobase/include/mem0mem.ic @@ -77,7 +77,7 @@ void mem_block_set_type(mem_block_t* block, ulint type) { ut_ad((type == MEM_HEAP_DYNAMIC) || (type == MEM_HEAP_BUFFER) - || (type == MEM_HEAP_BUFFER + MEM_HEAP_BTR_SEARCH)); + || (type == MEM_HEAP_BUFFER + MEM_HEAP_BTR_SEARCH)); block->type = type; } @@ -150,7 +150,7 @@ mem_heap_alloc( block to the heap */ if (mem_block_get_len(block) - < mem_block_get_free(block) + MEM_SPACE_NEEDED(n)) { + < mem_block_get_free(block) + MEM_SPACE_NEEDED(n)) { block = mem_heap_add_block(heap, n); @@ -228,12 +228,12 @@ mem_heap_free_heap_top( /* Validate the heap and get its total allocated size */ mem_heap_validate_or_print(heap, NULL, FALSE, &error, &total_size, - NULL, NULL); + NULL, NULL); ut_a(!error); /* Get the size below top pointer */ mem_heap_validate_or_print(heap, old_top, FALSE, &error, &size, NULL, - NULL); + NULL); ut_a(!error); #endif @@ -242,7 +242,7 @@ mem_heap_free_heap_top( while (block != NULL) { if (((byte*)block + mem_block_get_free(block) >= old_top) - && ((byte*)block <= old_top)) { + && ((byte*)block <= old_top)) { /* Found the right block */ break; @@ -280,8 +280,8 @@ mem_heap_free_heap_top( /* If free == start, we may free the block if it is not the first one */ - if ((heap != block) && (mem_block_get_free(block) == - mem_block_get_start(block))) { + if ((heap != block) && (mem_block_get_free(block) + == mem_block_get_start(block))) { mem_heap_block_free(heap, block); } } @@ -354,7 +354,7 @@ mem_heap_free_top( /* Subtract the free field of block */ mem_block_set_free(block, mem_block_get_free(block) - - MEM_SPACE_NEEDED(n)); + - MEM_SPACE_NEEDED(n)); #ifdef UNIV_MEM_DEBUG ut_ad(mem_block_get_start(block) <= mem_block_get_free(block)); @@ -366,8 +366,8 @@ mem_heap_free_top( /* If free == start, we may free the block if it is not the first one */ - if ((heap != block) && (mem_block_get_free(block) == - mem_block_get_start(block))) { + if ((heap != block) && (mem_block_get_free(block) + == mem_block_get_start(block))) { mem_heap_block_free(heap, block); } } @@ -407,10 +407,11 @@ mem_heap_create_func( if (n > 0) { block = mem_heap_create_block(NULL, n, init_block, type, - file_name, line); + file_name, line); } else { block = mem_heap_create_block(NULL, MEM_BLOCK_START_SIZE, - init_block, type, file_name, line); + init_block, type, + file_name, line); } if (block == NULL) { @@ -496,7 +497,7 @@ mem_alloc_func( void* buf; heap = mem_heap_create_func(n, NULL, MEM_HEAP_DYNAMIC, file_name, - line); + line); /* Note that as we created the first block in the heap big enough for the buffer requested by the caller, the buffer will be in the @@ -506,7 +507,7 @@ mem_alloc_func( buf = mem_heap_alloc(heap, n); ut_a((byte*)heap == (byte*)buf - MEM_BLOCK_HEADER_SIZE - - MEM_FIELD_HEADER_SIZE); + - MEM_FIELD_HEADER_SIZE); return(buf); } @@ -526,7 +527,7 @@ mem_free_func( mem_heap_t* heap; heap = (mem_heap_t*)((byte*)ptr - MEM_BLOCK_HEADER_SIZE - - MEM_FIELD_HEADER_SIZE); + - MEM_FIELD_HEADER_SIZE); mem_heap_free_func(heap, file_name, line); } diff --git a/storage/innobase/include/mtr0log.ic b/storage/innobase/include/mtr0log.ic index 1a5ef033f87..5b1d1ed34d9 100644 --- a/storage/innobase/include/mtr0log.ic +++ b/storage/innobase/include/mtr0log.ic @@ -165,7 +165,7 @@ mlog_write_initial_log_record_fast( ulint offset; ut_ad(mtr_memo_contains(mtr, buf_block_align(ptr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_X_FIX)); ut_ad(type <= MLOG_BIGGEST_TYPE); ut_ad(ptr && log_ptr); @@ -182,9 +182,9 @@ mlog_write_initial_log_record_fast( mtr->n_log_recs++; #ifdef UNIV_LOG_DEBUG -/* fprintf(stderr, - "Adding to mtr log record type %lu space %lu page no %lu\n", - type, space, offset); */ + /* fprintf(stderr, + "Adding to mtr log record type %lu space %lu page no %lu\n", + type, space, offset); */ #endif #ifdef UNIV_DEBUG diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index 3167ea3bc03..9e8250cb545 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -70,7 +70,8 @@ flag value must give the length also! */ #define MLOG_PAGE_CREATE ((byte)19) /* create an index page */ #define MLOG_UNDO_INSERT ((byte)20) /* insert entry in an undo log */ -#define MLOG_UNDO_ERASE_END ((byte)21) /* erase an undo log page end */ +#define MLOG_UNDO_ERASE_END ((byte)21) /* erase an undo log + page end */ #define MLOG_UNDO_INIT ((byte)22) /* initialize a page in an undo log */ #define MLOG_UNDO_HDR_DISCARD ((byte)23) /* discard an update undo log diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index 4ab7fda7358..5ffcdf7e58c 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -723,8 +723,10 @@ This function returns information about the specified file */ ibool os_file_get_status( /*===============*/ - /* out: TRUE if stat information found */ + /* out: TRUE if stat + information found */ const char* path, /* in: pathname of the file */ - os_file_stat_t* stat_info); /* information of a file in a directory */ + os_file_stat_t* stat_info); /* information of a file in a + directory */ #endif diff --git a/storage/innobase/include/page0cur.ic b/storage/innobase/include/page0cur.ic index 243550c055f..b747874abc2 100644 --- a/storage/innobase/include/page0cur.ic +++ b/storage/innobase/include/page0cur.ic @@ -162,11 +162,11 @@ page_cur_search( ut_ad(dtuple_check_typed(tuple)); page_cur_search_with_match(page, index, tuple, mode, - &up_matched_fields, - &up_matched_bytes, - &low_matched_fields, - &low_matched_bytes, - cursor); + &up_matched_fields, + &up_matched_bytes, + &low_matched_fields, + &low_matched_bytes, + cursor); return(low_matched_fields); } @@ -205,6 +205,6 @@ page_cur_rec_insert( mtr_t* mtr) /* in: mini-transaction handle */ { return(page_cur_insert_rec_low(cursor, NULL, index, rec, - offsets, mtr)); + offsets, mtr)); } diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index b33eeaceb1c..9348acd5ffc 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -93,8 +93,8 @@ page_header_get_ptr( ut_ad(page); ut_ad((field == PAGE_FREE) - || (field == PAGE_LAST_INSERT) - || (field == PAGE_HEAP_TOP)); + || (field == PAGE_LAST_INSERT) + || (field == PAGE_HEAP_TOP)); offs = page_header_get_field(page, field); @@ -122,8 +122,8 @@ page_header_set_ptr( ut_ad(page); ut_ad((field == PAGE_FREE) - || (field == PAGE_LAST_INSERT) - || (field == PAGE_HEAP_TOP)); + || (field == PAGE_LAST_INSERT) + || (field == PAGE_HEAP_TOP)); if (ptr == NULL) { offs = 0; @@ -149,7 +149,7 @@ page_header_reset_last_insert( ut_ad(page && mtr); mlog_write_ulint(page + PAGE_HEADER + PAGE_LAST_INSERT, 0, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); } /**************************************************************** @@ -163,7 +163,7 @@ page_is_comp( page_t* page) /* in: index page */ { return(UNIV_EXPECT(page_header_get_field(page, PAGE_N_HEAP) & 0x8000, - 0x8000)); + 0x8000)); } /**************************************************************** @@ -245,9 +245,9 @@ page_rec_is_user_rec_low( ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); return(UNIV_LIKELY(offset != PAGE_NEW_SUPREMUM) - && UNIV_LIKELY(offset != PAGE_NEW_INFIMUM) - && UNIV_LIKELY(offset != PAGE_OLD_INFIMUM) - && UNIV_LIKELY(offset != PAGE_OLD_SUPREMUM)); + && UNIV_LIKELY(offset != PAGE_NEW_INFIMUM) + && UNIV_LIKELY(offset != PAGE_OLD_INFIMUM) + && UNIV_LIKELY(offset != PAGE_OLD_SUPREMUM)); } /**************************************************************** @@ -263,7 +263,7 @@ page_rec_is_supremum_low( ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); return(UNIV_UNLIKELY(offset == PAGE_NEW_SUPREMUM) - || UNIV_UNLIKELY(offset == PAGE_OLD_SUPREMUM)); + || UNIV_UNLIKELY(offset == PAGE_OLD_SUPREMUM)); } /**************************************************************** @@ -279,7 +279,7 @@ page_rec_is_infimum_low( ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); return(UNIV_UNLIKELY(offset == PAGE_NEW_INFIMUM) - || UNIV_UNLIKELY(offset == PAGE_OLD_INFIMUM)); + || UNIV_UNLIKELY(offset == PAGE_OLD_INFIMUM)); } /**************************************************************** @@ -291,8 +291,7 @@ page_rec_is_user_rec( /* out: TRUE if a user record */ const rec_t* rec) /* in: record */ { - return(page_rec_is_user_rec_low( - ut_align_offset(rec, UNIV_PAGE_SIZE))); + return(page_rec_is_user_rec_low(ut_align_offset(rec, UNIV_PAGE_SIZE))); } /**************************************************************** @@ -304,8 +303,7 @@ page_rec_is_supremum( /* out: TRUE if the supremum record */ const rec_t* rec) /* in: record */ { - return(page_rec_is_supremum_low( - ut_align_offset(rec, UNIV_PAGE_SIZE))); + return(page_rec_is_supremum_low(ut_align_offset(rec, UNIV_PAGE_SIZE))); } /**************************************************************** @@ -317,8 +315,7 @@ page_rec_is_infimum( /* out: TRUE if the infimum record */ const rec_t* rec) /* in: record */ { - return(page_rec_is_infimum_low( - ut_align_offset(rec, UNIV_PAGE_SIZE))); + return(page_rec_is_infimum_low(ut_align_offset(rec, UNIV_PAGE_SIZE))); } /***************************************************************** @@ -357,17 +354,17 @@ page_cmp_dtuple_rec_with_match( rec_offset = ut_align_offset(rec, UNIV_PAGE_SIZE); if (UNIV_UNLIKELY(rec_offset == PAGE_NEW_INFIMUM) - || UNIV_UNLIKELY(rec_offset == PAGE_OLD_INFIMUM)) { + || UNIV_UNLIKELY(rec_offset == PAGE_OLD_INFIMUM)) { return(1); } if (UNIV_UNLIKELY(rec_offset == PAGE_NEW_SUPREMUM) - || UNIV_UNLIKELY(rec_offset == PAGE_OLD_SUPREMUM)) { + || UNIV_UNLIKELY(rec_offset == PAGE_OLD_SUPREMUM)) { return(-1); } return(cmp_dtuple_rec_with_match(dtuple, rec, offsets, - matched_fields, - matched_bytes)); + matched_fields, + matched_bytes)); } /***************************************************************** @@ -430,8 +427,9 @@ page_dir_set_n_heap( { ut_ad(n_heap < 0x8000); - page_header_set_field(page, PAGE_N_HEAP, n_heap | (0x8000 & - page_header_get_field(page, PAGE_N_HEAP))); + page_header_set_field(page, PAGE_N_HEAP, n_heap + | (0x8000 + & page_header_get_field(page, PAGE_N_HEAP))); } /***************************************************************** @@ -447,7 +445,7 @@ page_dir_get_nth_slot( ut_ad(page_dir_get_n_slots(page) > n); return(page + UNIV_PAGE_SIZE - PAGE_DIR - - (n + 1) * PAGE_DIR_SLOT_SIZE); + - (n + 1) * PAGE_DIR_SLOT_SIZE); } /****************************************************************** @@ -535,7 +533,7 @@ page_dir_calc_reserved_space( ulint n_recs) /* in: number of records */ { return((PAGE_DIR_SLOT_SIZE * n_recs + PAGE_DIR_SLOT_MIN_N_OWNED - 1) - / PAGE_DIR_SLOT_MIN_N_OWNED); + / PAGE_DIR_SLOT_MIN_N_OWNED); } /**************************************************************** @@ -558,13 +556,14 @@ page_rec_get_next( if (UNIV_UNLIKELY(offs >= UNIV_PAGE_SIZE)) { fprintf(stderr, -"InnoDB: Next record offset is nonsensical %lu in record at offset %lu\n" -"InnoDB: rec address %p, first buffer frame %p\n" -"InnoDB: buffer pool high end %p, buf fix count %lu\n", - (ulong)offs, (ulong)(rec - page), - rec, buf_pool->frame_zero, - buf_pool->high_end, - (ulong)buf_block_align(rec)->buf_fix_count); + "InnoDB: Next record offset is nonsensical %lu" + " in record at offset %lu\n" + "InnoDB: rec address %p, first buffer frame %p\n" + "InnoDB: buffer pool high end %p, buf fix count %lu\n", + (ulong)offs, (ulong)(rec - page), + (void*) rec, (void*) buf_pool->frame_zero, + (void*) buf_pool->high_end, + (ulong) buf_block_align(rec)->buf_fix_count); buf_page_print(page); ut_error; @@ -683,10 +682,10 @@ page_get_data_size( ulint ret; ret = (ulint)(page_header_get_field(page, PAGE_HEAP_TOP) - - (page_is_comp(page) - ? PAGE_NEW_SUPREMUM_END - : PAGE_OLD_SUPREMUM_END) - - page_header_get_field(page, PAGE_GARBAGE)); + - (page_is_comp(page) + ? PAGE_NEW_SUPREMUM_END + : PAGE_OLD_SUPREMUM_END) + - page_header_get_field(page, PAGE_GARBAGE)); ut_ad(ret < UNIV_PAGE_SIZE); @@ -704,15 +703,15 @@ page_get_free_space_of_empty( { if (UNIV_LIKELY(comp)) { return((ulint)(UNIV_PAGE_SIZE - - PAGE_NEW_SUPREMUM_END - - PAGE_DIR - - 2 * PAGE_DIR_SLOT_SIZE)); + - PAGE_NEW_SUPREMUM_END + - PAGE_DIR + - 2 * PAGE_DIR_SLOT_SIZE)); } return((ulint)(UNIV_PAGE_SIZE - - PAGE_OLD_SUPREMUM_END - - PAGE_DIR - - 2 * PAGE_DIR_SLOT_SIZE)); + - PAGE_OLD_SUPREMUM_END + - PAGE_DIR + - 2 * PAGE_DIR_SLOT_SIZE)); } /**************************************************************** @@ -735,14 +734,16 @@ page_get_max_insert_size( if (page_is_comp(page)) { occupied = page_header_get_field(page, PAGE_HEAP_TOP) - - PAGE_NEW_SUPREMUM_END + page_dir_calc_reserved_space( - n_recs + page_dir_get_n_heap(page) - 2); + - PAGE_NEW_SUPREMUM_END + + page_dir_calc_reserved_space + (n_recs + page_dir_get_n_heap(page) - 2); free_space = page_get_free_space_of_empty(TRUE); } else { occupied = page_header_get_field(page, PAGE_HEAP_TOP) - - PAGE_OLD_SUPREMUM_END + page_dir_calc_reserved_space( - n_recs + page_dir_get_n_heap(page) - 2); + - PAGE_OLD_SUPREMUM_END + + page_dir_calc_reserved_space + (n_recs + page_dir_get_n_heap(page) - 2); free_space = page_get_free_space_of_empty(FALSE); } @@ -819,7 +820,7 @@ page_mem_free( garbage = page_header_get_field(page, PAGE_GARBAGE); page_header_set_field(page, PAGE_GARBAGE, - garbage + rec_offs_size(offsets)); + garbage + rec_offs_size(offsets)); } #ifdef UNIV_MATERIALIZE diff --git a/storage/innobase/include/que0que.ic b/storage/innobase/include/que0que.ic index 70be4068147..a20108a7820 100644 --- a/storage/innobase/include/que0que.ic +++ b/storage/innobase/include/que0que.ic @@ -230,9 +230,9 @@ que_thr_peek_stop( trx = graph->trx; if (graph->state != QUE_FORK_ACTIVE - || trx->que_state == TRX_QUE_LOCK_WAIT - || (UT_LIST_GET_LEN(trx->signals) > 0 - && trx->que_state == TRX_QUE_RUNNING)) { + || trx->que_state == TRX_QUE_LOCK_WAIT + || (UT_LIST_GET_LEN(trx->signals) > 0 + && trx->que_state == TRX_QUE_RUNNING)) { return(TRUE); } @@ -250,7 +250,7 @@ que_graph_is_select( que_t* graph) /* in: graph */ { if (graph->fork_type == QUE_FORK_SELECT_SCROLL - || graph->fork_type == QUE_FORK_SELECT_NON_SCROLL) { + || graph->fork_type == QUE_FORK_SELECT_NON_SCROLL) { return(TRUE); } diff --git a/storage/innobase/include/read0read.ic b/storage/innobase/include/read0read.ic index 276e01b9f4a..9785cf1b3ce 100644 --- a/storage/innobase/include/read0read.ic +++ b/storage/innobase/include/read0read.ic @@ -69,8 +69,9 @@ read_view_sees_trx_id( for (i = 0; i < n_ids; i++) { - cmp = ut_dulint_cmp(trx_id, - read_view_get_nth_trx_id(view, n_ids - i - 1)); + cmp = ut_dulint_cmp + (trx_id, + read_view_get_nth_trx_id(view, n_ids - i - 1)); if (cmp <= 0) { return(cmp < 0); } diff --git a/storage/innobase/include/rem0cmp.ic b/storage/innobase/include/rem0cmp.ic index 954634737bc..5653ec1ac44 100644 --- a/storage/innobase/include/rem0cmp.ic +++ b/storage/innobase/include/rem0cmp.ic @@ -40,9 +40,10 @@ cmp_dfield_dfield( { ut_ad(dfield_check_typed(dfield1)); - return(cmp_data_data(dfield_get_type(dfield1), - dfield_get_data(dfield1), dfield_get_len(dfield1), - dfield_get_data(dfield2), dfield_get_len(dfield2))); + return(cmp_data_data + (dfield_get_type(dfield1), + dfield_get_data(dfield1), dfield_get_len(dfield1), + dfield_get_data(dfield2), dfield_get_len(dfield2))); } /***************************************************************** @@ -65,5 +66,5 @@ cmp_rec_rec( ulint match_b = 0; return(cmp_rec_rec_with_match(rec1, rec2, offsets1, offsets2, index, - &match_f, &match_b)); + &match_f, &match_b)); } diff --git a/storage/innobase/include/rem0rec.ic b/storage/innobase/include/rem0rec.ic index e716241f26c..5e4c0ea0664 100644 --- a/storage/innobase/include/rem0rec.ic +++ b/storage/innobase/include/rem0rec.ic @@ -289,10 +289,10 @@ rec_get_next_offs( (int16_t) field_value + ut_align_offset(...) < UNIV_PAGE_SIZE */ ut_ad((field_value >= 32768 - ? field_value - 65536 - : field_value) - + ut_align_offset(rec, UNIV_PAGE_SIZE) - < UNIV_PAGE_SIZE); + ? field_value - 65536 + : field_value) + + ut_align_offset(rec, UNIV_PAGE_SIZE) + < UNIV_PAGE_SIZE); #endif if (field_value == 0) { @@ -336,7 +336,8 @@ rec_set_next_offs( as a non-negative number */ field_value = (ulint)((lint)next - - (lint)ut_align_offset(rec, UNIV_PAGE_SIZE)); + - (lint)ut_align_offset + (rec, UNIV_PAGE_SIZE)); field_value &= REC_NEXT_MASK; } else { field_value = 0; @@ -363,7 +364,8 @@ rec_get_n_fields_old( ut_ad(rec); ret = rec_get_bit_field_2(rec, REC_OLD_N_FIELDS, - REC_OLD_N_FIELDS_MASK, REC_OLD_N_FIELDS_SHIFT); + REC_OLD_N_FIELDS_MASK, + REC_OLD_N_FIELDS_SHIFT); ut_ad(ret <= REC_MAX_N_FIELDS); ut_ad(ret > 0); @@ -385,7 +387,7 @@ rec_set_n_fields_old( ut_ad(n_fields > 0); rec_set_bit_field_2(rec, n_fields, REC_OLD_N_FIELDS, - REC_OLD_N_FIELDS_MASK, REC_OLD_N_FIELDS_SHIFT); + REC_OLD_N_FIELDS_MASK, REC_OLD_N_FIELDS_SHIFT); } /********************************************************** @@ -402,7 +404,7 @@ rec_get_status( ut_ad(rec); ret = rec_get_bit_field_1(rec, REC_NEW_STATUS, - REC_NEW_STATUS_MASK, REC_NEW_STATUS_SHIFT); + REC_NEW_STATUS_MASK, REC_NEW_STATUS_SHIFT); ut_ad((ret & ~REC_NEW_STATUS_MASK) == 0); return(ret); @@ -456,8 +458,8 @@ rec_get_n_owned( ut_ad(rec); ret = rec_get_bit_field_1(rec, - comp ? REC_NEW_N_OWNED : REC_OLD_N_OWNED, - REC_N_OWNED_MASK, REC_N_OWNED_SHIFT); + comp ? REC_NEW_N_OWNED : REC_OLD_N_OWNED, + REC_N_OWNED_MASK, REC_N_OWNED_SHIFT); ut_ad(ret <= REC_MAX_N_OWNED); return(ret); @@ -477,8 +479,8 @@ rec_set_n_owned( ut_ad(n_owned <= REC_MAX_N_OWNED); rec_set_bit_field_1(rec, n_owned, - comp ? REC_NEW_N_OWNED : REC_OLD_N_OWNED, - REC_N_OWNED_MASK, REC_N_OWNED_SHIFT); + comp ? REC_NEW_N_OWNED : REC_OLD_N_OWNED, + REC_N_OWNED_MASK, REC_N_OWNED_SHIFT); } /********************************************************** @@ -496,8 +498,8 @@ rec_get_info_bits( ut_ad(rec); ret = rec_get_bit_field_1(rec, - comp ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS, - REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT); + comp ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS, + REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT); ut_ad((ret & ~REC_INFO_BITS_MASK) == 0); return(ret); @@ -517,8 +519,8 @@ rec_set_info_bits( ut_ad((bits & ~REC_INFO_BITS_MASK) == 0); rec_set_bit_field_1(rec, bits, - comp ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS, - REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT); + comp ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS, + REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT); } /********************************************************** @@ -534,7 +536,7 @@ rec_set_status( ut_ad((bits & ~REC_NEW_STATUS_MASK) == 0); rec_set_bit_field_1(rec, bits, REC_NEW_STATUS, - REC_NEW_STATUS_MASK, REC_NEW_STATUS_SHIFT); + REC_NEW_STATUS_MASK, REC_NEW_STATUS_SHIFT); } /********************************************************** @@ -595,13 +597,15 @@ rec_get_deleted_flag( ulint comp) /* in: nonzero=compact page format */ { if (UNIV_EXPECT(comp, REC_OFFS_COMPACT)) { - return(UNIV_UNLIKELY(rec_get_bit_field_1(rec, - REC_NEW_INFO_BITS, REC_INFO_DELETED_FLAG, - REC_INFO_BITS_SHIFT))); + return(UNIV_UNLIKELY + (rec_get_bit_field_1(rec, REC_NEW_INFO_BITS, + REC_INFO_DELETED_FLAG, + REC_INFO_BITS_SHIFT))); } else { - return(UNIV_UNLIKELY(rec_get_bit_field_1(rec, - REC_OLD_INFO_BITS, REC_INFO_DELETED_FLAG, - REC_INFO_BITS_SHIFT))); + return(UNIV_UNLIKELY + (rec_get_bit_field_1(rec, REC_OLD_INFO_BITS, + REC_INFO_DELETED_FLAG, + REC_INFO_BITS_SHIFT))); } } @@ -656,8 +660,8 @@ rec_get_heap_no( ut_ad(rec); ret = rec_get_bit_field_2(rec, - comp ? REC_NEW_HEAP_NO : REC_OLD_HEAP_NO, - REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT); + comp ? REC_NEW_HEAP_NO : REC_OLD_HEAP_NO, + REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT); ut_ad(ret <= REC_MAX_HEAP_NO); return(ret); @@ -676,8 +680,8 @@ rec_set_heap_no( ut_ad(heap_no <= REC_MAX_HEAP_NO); rec_set_bit_field_2(rec, heap_no, - comp ? REC_NEW_HEAP_NO : REC_OLD_HEAP_NO, - REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT); + comp ? REC_NEW_HEAP_NO : REC_OLD_HEAP_NO, + REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT); } /********************************************************** @@ -695,7 +699,7 @@ rec_get_1byte_offs_flag( #endif return(rec_get_bit_field_1(rec, REC_OLD_SHORT, REC_OLD_SHORT_MASK, - REC_OLD_SHORT_SHIFT)); + REC_OLD_SHORT_SHIFT)); } /********************************************************** @@ -713,7 +717,7 @@ rec_set_1byte_offs_flag( ut_ad(flag <= TRUE); rec_set_bit_field_1(rec, flag, REC_OLD_SHORT, REC_OLD_SHORT_MASK, - REC_OLD_SHORT_SHIFT); + REC_OLD_SHORT_SHIFT); } /********************************************************** @@ -814,7 +818,7 @@ rec_offs_n_fields( ut_ad(n_fields > 0); ut_ad(n_fields <= REC_MAX_N_FIELDS); ut_ad(n_fields + REC_OFFS_HEADER_SIZE - <= rec_offs_get_n_alloc(offsets)); + <= rec_offs_get_n_alloc(offsets)); return(n_fields); } @@ -842,16 +846,16 @@ rec_offs_validate( if (index) { ulint max_n_fields; ut_ad((ulint) index == offsets[3]); - max_n_fields = ut_max( - dict_index_get_n_fields(index), - dict_index_get_n_unique_in_tree(index) + 1); + max_n_fields = ut_max + (dict_index_get_n_fields(index), + dict_index_get_n_unique_in_tree(index) + 1); if (comp && rec) { switch (rec_get_status(rec)) { case REC_STATUS_ORDINARY: break; case REC_STATUS_NODE_PTR: - max_n_fields = - dict_index_get_n_unique_in_tree(index) + 1; + max_n_fields = dict_index_get_n_unique_in_tree + (index) + 1; break; case REC_STATUS_INFIMUM: case REC_STATUS_SUPREMUM: @@ -960,7 +964,7 @@ rec_offs_nth_extern( ut_ad(rec_offs_validate(NULL, NULL, offsets)); ut_ad(n < rec_offs_n_fields(offsets)); return(UNIV_UNLIKELY(rec_offs_base(offsets)[1 + n] - & REC_OFFS_EXTERNAL)); + & REC_OFFS_EXTERNAL)); } /********************************************************** @@ -976,7 +980,7 @@ rec_offs_nth_sql_null( ut_ad(rec_offs_validate(NULL, NULL, offsets)); ut_ad(n < rec_offs_n_fields(offsets)); return(UNIV_UNLIKELY(rec_offs_base(offsets)[1 + n] - & REC_OFFS_SQL_NULL)); + & REC_OFFS_SQL_NULL)); } /********************************************************** @@ -992,7 +996,7 @@ rec_offs_nth_size( ut_ad(rec_offs_validate(NULL, NULL, offsets)); ut_ad(n < rec_offs_n_fields(offsets)); return((rec_offs_base(offsets)[1 + n] - rec_offs_base(offsets)[n]) - & REC_OFFS_MASK); + & REC_OFFS_MASK); } /********************************************************** @@ -1129,7 +1133,7 @@ rec_1_get_field_start_offs( } return(rec_1_get_prev_field_end_info(rec, n) - & ~REC_1BYTE_SQL_NULL_MASK); + & ~REC_1BYTE_SQL_NULL_MASK); } /********************************************************** @@ -1152,7 +1156,7 @@ rec_2_get_field_start_offs( } return(rec_2_get_prev_field_end_info(rec, n) - & ~(REC_2BYTE_SQL_NULL_MASK | REC_2BYTE_EXTERN_MASK)); + & ~(REC_2BYTE_SQL_NULL_MASK | REC_2BYTE_EXTERN_MASK)); } /********************************************************** @@ -1282,7 +1286,7 @@ rec_offs_set_n_fields( ut_ad(n_fields > 0); ut_ad(n_fields <= REC_MAX_N_FIELDS); ut_ad(n_fields + REC_OFFS_HEADER_SIZE - <= rec_offs_get_n_alloc(offsets)); + <= rec_offs_get_n_alloc(offsets)); offsets[1] = n_fields; } @@ -1302,7 +1306,7 @@ rec_offs_data_size( ut_ad(rec_offs_validate(NULL, NULL, offsets)); size = rec_offs_base(offsets)[rec_offs_n_fields(offsets)] - & REC_OFFS_MASK; + & REC_OFFS_MASK; ut_ad(size < UNIV_PAGE_SIZE); return(size); } @@ -1437,11 +1441,11 @@ rec_get_converted_size( ut_ad(dtuple_check_typed(dtuple)); ut_ad(index->type & DICT_UNIVERSAL - || dtuple_get_n_fields(dtuple) == - (((dtuple_get_info_bits(dtuple) & REC_NEW_STATUS_MASK) - == REC_STATUS_NODE_PTR) - ? dict_index_get_n_unique_in_tree(index) + 1 - : dict_index_get_n_fields(index))); + || dtuple_get_n_fields(dtuple) + == (((dtuple_get_info_bits(dtuple) & REC_NEW_STATUS_MASK) + == REC_STATUS_NODE_PTR) + ? dict_index_get_n_unique_in_tree(index) + 1 + : dict_index_get_n_fields(index))); if (dict_table_is_comp(index->table)) { return(rec_get_converted_size_new(index, dtuple)); @@ -1449,8 +1453,8 @@ rec_get_converted_size( data_size = dtuple_get_data_size(dtuple); - extra_size = rec_get_converted_extra_size( - data_size, dtuple_get_n_fields(dtuple)); + extra_size = rec_get_converted_extra_size + (data_size, dtuple_get_n_fields(dtuple)); return(data_size + extra_size); } diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 48fb7432b54..be285037767 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -602,9 +602,10 @@ struct row_prebuilt_struct { selects */ dtuple_t* search_tuple; /* prebuilt dtuple used in selects */ byte row_id[DATA_ROW_ID_LEN]; - /* if the clustered index was generated, - the row id of the last row fetched is - stored here */ + /* if the clustered index was + generated, the row id of the + last row fetched is stored + here */ dtuple_t* clust_ref; /* prebuilt dtuple used in sel/upd/del */ ulint select_lock_type;/* LOCK_NONE, LOCK_S, or LOCK_X */ diff --git a/storage/innobase/include/row0purge.h b/storage/innobase/include/row0purge.h index 2653f8a354d..174dd239eb5 100644 --- a/storage/innobase/include/row0purge.h +++ b/storage/innobase/include/row0purge.h @@ -58,7 +58,8 @@ struct purge_node_struct{ it */ dict_table_t* table; /* table where purge is done */ ulint cmpl_info;/* compiler analysis info of an update */ - upd_t* update; /* update vector for a clustered index record */ + upd_t* update; /* update vector for a clustered index + record */ dtuple_t* ref; /* NULL, or row reference to the next row to handle */ dtuple_t* row; /* NULL, or a copy (also fields copied to diff --git a/storage/innobase/include/row0row.h b/storage/innobase/include/row0row.h index 22ad4cb4d6d..bea7627cd86 100644 --- a/storage/innobase/include/row0row.h +++ b/storage/innobase/include/row0row.h @@ -80,10 +80,9 @@ dtuple_t* row_build( /*======*/ /* out, own: row built; see the NOTE below! */ - ulint type, /* in: ROW_COPY_POINTERS, ROW_COPY_DATA, or - ROW_COPY_ALSO_EXTERNALS, - the two last copy also the data fields to - heap as the first only places pointers to + ulint type, /* in: ROW_COPY_POINTERS or ROW_COPY_DATA; + the latter copies also the data fields to + heap while the first only places pointers to data fields on the index page, and thus is more efficient */ dict_index_t* index, /* in: clustered index */ @@ -235,7 +234,6 @@ row_search_index_entry( #define ROW_COPY_DATA 1 #define ROW_COPY_POINTERS 2 -#define ROW_COPY_ALSO_EXTERNALS 3 /* The allowed latching order of index records is the following: (1) a secondary index record -> diff --git a/storage/innobase/include/row0row.ic b/storage/innobase/include/row0row.ic index 7cf09d25eed..de417f3d971 100644 --- a/storage/innobase/include/row0row.ic +++ b/storage/innobase/include/row0row.ic @@ -58,7 +58,7 @@ row_get_rec_trx_id( return(trx_read_trx_id(rec + offset)); } else { return(row_get_rec_sys_field(DATA_TRX_ID, - rec, index, offsets)); + rec, index, offsets)); } } @@ -84,7 +84,7 @@ row_get_rec_roll_ptr( return(trx_read_roll_ptr(rec + offset + DATA_TRX_ID_LEN)); } else { return(row_get_rec_sys_field(DATA_ROLL_PTR, - rec, index, offsets)); + rec, index, offsets)); } } @@ -110,7 +110,7 @@ row_set_rec_trx_id( trx_write_trx_id(rec + offset, trx_id); } else { row_set_rec_sys_field(DATA_TRX_ID, - rec, index, offsets, trx_id); + rec, index, offsets, trx_id); } } @@ -136,7 +136,7 @@ row_set_rec_roll_ptr( trx_write_roll_ptr(rec + offset + DATA_TRX_ID_LEN, roll_ptr); } else { row_set_rec_sys_field(DATA_ROLL_PTR, - rec, index, offsets, roll_ptr); + rec, index, offsets, roll_ptr); } } @@ -175,7 +175,7 @@ row_build_row_ref_fast( if (field_no != ULINT_UNDEFINED) { field = rec_get_nth_field(rec, offsets, - field_no, &len); + field_no, &len); dfield_set_data(dfield, field, len); } } diff --git a/storage/innobase/include/row0sel.h b/storage/innobase/include/row0sel.h index 70b08d82994..96273a18cd5 100644 --- a/storage/innobase/include/row0sel.h +++ b/storage/innobase/include/row0sel.h @@ -298,15 +298,17 @@ struct sel_node_struct{ /* TRUE if the aggregate row has already been fetched for the current cursor */ - ibool can_get_updated;/* this is TRUE if the select is in a - single-table explicit cursor which can - get updated within the stored procedure, - or in a searched update or delete; - NOTE that to determine of an explicit - cursor if it can get updated, the - parser checks from a stored procedure - if it contains positioned update or - delete statements */ + ibool can_get_updated;/* this is TRUE if the select + is in a single-table explicit + cursor which can get updated + within the stored procedure, + or in a searched update or + delete; NOTE that to determine + of an explicit cursor if it + can get updated, the parser + checks from a stored procedure + if it contains positioned + update or delete statements */ sym_node_t* explicit_cursor;/* not NULL if an explicit cursor */ UT_LIST_BASE_NODE_T(sym_node_t) copy_variables; /* variables whose values we have to diff --git a/storage/innobase/include/row0sel.ic b/storage/innobase/include/row0sel.ic index d58daf79969..1f92b99271e 100644 --- a/storage/innobase/include/row0sel.ic +++ b/storage/innobase/include/row0sel.ic @@ -60,11 +60,11 @@ open_step( if (node->op_type == ROW_SEL_OPEN_CURSOR) { -/* if (sel_node->state == SEL_NODE_CLOSED) { */ + /* if (sel_node->state == SEL_NODE_CLOSED) { */ - sel_node_reset_cursor(sel_node); -/* } else { - err = DB_ERROR; + sel_node_reset_cursor(sel_node); + /* } else { + err = DB_ERROR; } */ } else { if (sel_node->state != SEL_NODE_CLOSED) { diff --git a/storage/innobase/include/row0undo.h b/storage/innobase/include/row0undo.h index 29cfbc9ac20..0be09ed1822 100644 --- a/storage/innobase/include/row0undo.h +++ b/storage/innobase/include/row0undo.h @@ -86,7 +86,8 @@ struct undo_node_struct{ clustered index record */ dict_table_t* table; /* table where undo is done */ ulint cmpl_info;/* compiler analysis of an update */ - upd_t* update; /* update vector for a clustered index record */ + upd_t* update; /* update vector for a clustered index + record */ dtuple_t* ref; /* row reference to the next row to handle */ dtuple_t* row; /* a copy (also fields copied to heap) of the row to handle */ diff --git a/storage/innobase/include/row0upd.ic b/storage/innobase/include/row0upd.ic index d5a797df651..5e852559fe4 100644 --- a/storage/innobase/include/row0upd.ic +++ b/storage/innobase/include/row0upd.ic @@ -90,11 +90,11 @@ upd_field_set_field_no( dict_index_name_print(stderr, trx, index); fprintf(stderr, "\n" "InnoDB: but index only has %lu fields\n", - (ulong) dict_index_get_n_fields(index)); + (ulong) dict_index_get_n_fields(index)); } dtype_copy(dfield_get_type(&(upd_field->new_val)), - dict_index_get_nth_type(index, field_no)); + dict_index_get_nth_type(index, field_no)); } /************************************************************************* @@ -114,7 +114,7 @@ row_upd_rec_sys_fields( ut_ad(rec_offs_validate(rec, index, offsets)); #ifdef UNIV_SYNC_DEBUG ut_ad(!buf_block_align(rec)->is_hashed - || rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + || rw_lock_own(&btr_search_latch, RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ row_set_rec_trx_id(rec, index, offsets, trx->id); diff --git a/storage/innobase/include/sync0rw.h b/storage/innobase/include/sync0rw.h index 616d3eeb978..e5f3e1341c5 100644 --- a/storage/innobase/include/sync0rw.h +++ b/storage/innobase/include/sync0rw.h @@ -61,9 +61,9 @@ Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appropriately aligned). The rw-lock is initialized to the non-locked state. Explicit freeing of the rw-lock with rw_lock_free is necessary only if the memory block containing it is freed. */ -#define rw_lock_create(L, level) rw_lock_create_func((L), (level), __FILE__, __LINE__, #L) +#define rw_lock_create(L, level) \ + rw_lock_create_func((L), (level), __FILE__, __LINE__, #L) -/*=====================*/ /********************************************************************** Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appropriately aligned). The rw-lock is initialized diff --git a/storage/innobase/include/sync0rw.ic b/storage/innobase/include/sync0rw.ic index 02b12f40bc9..defe0692aa8 100644 --- a/storage/innobase/include/sync0rw.ic +++ b/storage/innobase/include/sync0rw.ic @@ -144,7 +144,7 @@ rw_lock_s_lock_low( #ifdef UNIV_SYNC_DEBUG rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name, - line); + line); #endif lock->last_s_file_name = file_name; lock->last_s_line = line; @@ -280,7 +280,7 @@ rw_lock_s_lock_func_nowait( #ifdef UNIV_SYNC_DEBUG rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name, - line); + line); #endif lock->last_s_file_name = file_name; @@ -313,11 +313,11 @@ rw_lock_x_lock_func_nowait( if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) { } else if (UNIV_LIKELY(rw_lock_get_writer(lock) - == RW_LOCK_NOT_LOCKED)) { + == RW_LOCK_NOT_LOCKED)) { rw_lock_set_writer(lock, RW_LOCK_EX); lock->writer_thread = curr_thread; lock->pass = 0; - relock: +relock: lock->writer_count++; #ifdef UNIV_SYNC_DEBUG @@ -329,8 +329,8 @@ rw_lock_x_lock_func_nowait( success = TRUE; } else if (rw_lock_get_writer(lock) == RW_LOCK_EX - && lock->pass == 0 - && os_thread_eq(lock->writer_thread, curr_thread)) { + && lock->pass == 0 + && os_thread_eq(lock->writer_thread, curr_thread)) { goto relock; } @@ -373,7 +373,7 @@ rw_lock_s_unlock_func( signal the object */ if (UNIV_UNLIKELY(lock->waiters) - && lock->reader_count == 0) { + && lock->reader_count == 0) { sg = TRUE; rw_lock_set_waiters(lock, 0); @@ -453,7 +453,7 @@ rw_lock_x_unlock_func( /* If there may be waiters, signal the lock */ if (UNIV_UNLIKELY(lock->waiters) - && lock->writer_count == 0) { + && lock->writer_count == 0) { sg = TRUE; rw_lock_set_waiters(lock, 0); diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h index 64b245246f8..7d795e60efd 100644 --- a/storage/innobase/include/sync0sync.h +++ b/storage/innobase/include/sync0sync.h @@ -39,8 +39,9 @@ location (which must be appropriately aligned). The mutex is initialized in the reset state. Explicit freeing of the mutex with mutex_free is necessary only if the memory block containing it is freed. */ -#define mutex_create(M, level) mutex_create_func((M), (level), __FILE__, __LINE__, #M) -/*===================*/ +#define mutex_create(M, level) \ + mutex_create_func((M), (level), __FILE__, __LINE__, #M) + /********************************************************************** Creates, or rather, initializes a mutex object in a specified memory location (which must be appropriately aligned). The mutex is initialized diff --git a/storage/innobase/include/sync0sync.ic b/storage/innobase/include/sync0sync.ic index f384e43779f..bcecc3478b3 100644 --- a/storage/innobase/include/sync0sync.ic +++ b/storage/innobase/include/sync0sync.ic @@ -66,25 +66,28 @@ mutex_test_and_set( lw = &(mutex->lock_word); __asm MOV ECX, lw - __asm MOV EDX, 1 - __asm XCHG EDX, DWORD PTR [ECX] - __asm MOV res, EDX + __asm MOV EDX, 1 + __asm XCHG EDX, DWORD PTR [ECX] + __asm MOV res, EDX - /* The fence below would prevent this thread from reading the data - structure protected by the mutex before the test-and-set operation is - committed, but the fence is apparently not needed: + /* The fence below would prevent this thread from + reading the data structure protected by the mutex + before the test-and-set operation is committed, but + the fence is apparently not needed: - In a posting to comp.arch newsgroup (August 10, 1997) Andy Glew said - that in P6 a LOCKed instruction like XCHG establishes a fence with - respect to memory reads and writes and thus an explicit fence is not - needed. In P5 he seemed to agree with a previous newsgroup poster that - LOCKed instructions serialize all instruction execution, and, - consequently, also memory operations. This is confirmed in Intel - Software Dev. Manual, Vol. 3. */ + In a posting to comp.arch newsgroup (August 10, 1997) + Andy Glew said that in P6 a LOCKed instruction like + XCHG establishes a fence with respect to memory reads + and writes and thus an explicit fence is not + needed. In P5 he seemed to agree with a previous + newsgroup poster that LOCKed instructions serialize + all instruction execution, and, consequently, also + memory operations. This is confirmed in Intel Software + Dev. Manual, Vol. 3. */ - /* mutex_fence(); */ + /* mutex_fence(); */ - return(res); + return(res); #elif defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86) ulint* lw; ulint res; @@ -98,8 +101,8 @@ mutex_test_and_set( code, and the second line tells the input to the asm code. */ asm volatile("movl $1, %%eax; xchgl (%%ecx), %%eax" : - "=eax" (res), "=m" (*lw) : - "ecx" (lw)); + "=eax" (res), "=m" (*lw) : + "ecx" (lw)); return(res); #else ibool ret; @@ -135,10 +138,10 @@ mutex_reset_lock_word( lw = &(mutex->lock_word); __asm MOV EDX, 0 - __asm MOV ECX, lw - __asm XCHG EDX, DWORD PTR [ECX] + __asm MOV ECX, lw + __asm XCHG EDX, DWORD PTR [ECX] #elif defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86) - ulint* lw; + ulint* lw; lw = &(mutex->lock_word); @@ -147,11 +150,11 @@ mutex_reset_lock_word( syntax. The 'l' after the mnemonics denotes a 32-bit operation. */ asm volatile("movl $0, %%eax; xchgl (%%ecx), %%eax" : - "=m" (*lw) : - "ecx" (lw) : - "eax"); /* gcc does not seem to understand that our asm code - resets eax: tell it explicitly that after the third - ':' */ + "=m" (*lw) : + "ecx" (lw) : + "eax"); /* gcc does not seem to understand + that our asm code resets eax: tell it + explicitly that after the third ':' */ #else mutex->lock_word = 0; @@ -167,8 +170,8 @@ mutex_get_lock_word( /*================*/ mutex_t* mutex) /* in: mutex */ { -volatile ulint* ptr; /* declared volatile to ensure that - lock_word is loaded from memory */ + volatile ulint* ptr; /* declared volatile to ensure that + lock_word is loaded from memory */ ut_ad(mutex); ptr = &(mutex->lock_word); @@ -185,8 +188,8 @@ mutex_get_waiters( /* out: value to set */ mutex_t* mutex) /* in: mutex */ { -volatile ulint* ptr; /* declared volatile to ensure that - the value is read from memory */ + volatile ulint* ptr; /* declared volatile to ensure that + the value is read from memory */ ut_ad(mutex); ptr = &(mutex->waiters); @@ -252,10 +255,10 @@ mutex_enter_func( the atomic test_and_set; we could peek, and possibly save time. */ #ifndef UNIV_HOTBACKUP - mutex->count_using++; + mutex->count_using++; #endif /* UNIV_HOTBACKUP */ - if (!mutex_test_and_set(mutex)) { + if (!mutex_test_and_set(mutex)) { #ifdef UNIV_SYNC_DEBUG mutex_set_debug_info(mutex, file_name, line); #endif diff --git a/storage/innobase/include/trx0rec.ic b/storage/innobase/include/trx0rec.ic index cd02ed9e04c..a1ddc127ec7 100644 --- a/storage/innobase/include/trx0rec.ic +++ b/storage/innobase/include/trx0rec.ic @@ -77,7 +77,7 @@ trx_undo_rec_copy( trx_undo_rec_t* rec_copy; len = mach_read_from_2(undo_rec) + buf_frame_align(undo_rec) - - undo_rec; + - undo_rec; rec_copy = mem_heap_alloc(heap, len); ut_memcpy(rec_copy, undo_rec, len); diff --git a/storage/innobase/include/trx0rseg.ic b/storage/innobase/include/trx0rseg.ic index 4de7a4ab144..eb1893587a6 100644 --- a/storage/innobase/include/trx0rseg.ic +++ b/storage/innobase/include/trx0rseg.ic @@ -67,12 +67,13 @@ trx_rsegf_get_nth_undo( { if (UNIV_UNLIKELY(n >= TRX_RSEG_N_SLOTS)) { fprintf(stderr, - "InnoDB: Error: trying to get slot %lu of rseg\n", (unsigned long) n); + "InnoDB: Error: trying to get slot %lu of rseg\n", + (ulong) n); ut_error; } - return(mtr_read_ulint(rsegf + TRX_RSEG_UNDO_SLOTS + - n * TRX_RSEG_SLOT_SIZE, MLOG_4BYTES, mtr)); + return(mtr_read_ulint(rsegf + TRX_RSEG_UNDO_SLOTS + + n * TRX_RSEG_SLOT_SIZE, MLOG_4BYTES, mtr)); } /******************************************************************* @@ -88,12 +89,13 @@ trx_rsegf_set_nth_undo( { if (UNIV_UNLIKELY(n >= TRX_RSEG_N_SLOTS)) { fprintf(stderr, - "InnoDB: Error: trying to set slot %lu of rseg\n", (unsigned long) n); + "InnoDB: Error: trying to set slot %lu of rseg\n", + (ulong) n); ut_error; } mlog_write_ulint(rsegf + TRX_RSEG_UNDO_SLOTS + n * TRX_RSEG_SLOT_SIZE, - page_no, MLOG_4BYTES, mtr); + page_no, MLOG_4BYTES, mtr); } /******************************************************************** diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic index e0653609b36..9c950be09f0 100644 --- a/storage/innobase/include/trx0sys.ic +++ b/storage/innobase/include/trx0sys.ic @@ -100,7 +100,7 @@ trx_sysf_get( ut_ad(mtr); header = TRX_SYS + buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, - RW_X_LATCH, mtr); + RW_X_LATCH, mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(header, SYNC_TRX_SYS_HEADER); @@ -128,8 +128,8 @@ trx_sysf_rseg_get_space( ut_ad(i < TRX_SYS_N_RSEGS); return(mtr_read_ulint(sys_header + TRX_SYS_RSEGS - + i * TRX_SYS_RSEG_SLOT_SIZE - + TRX_SYS_RSEG_SPACE, MLOG_4BYTES, mtr)); + + i * TRX_SYS_RSEG_SLOT_SIZE + + TRX_SYS_RSEG_SPACE, MLOG_4BYTES, mtr)); } /********************************************************************* @@ -152,8 +152,8 @@ trx_sysf_rseg_get_page_no( ut_ad(i < TRX_SYS_N_RSEGS); return(mtr_read_ulint(sys_header + TRX_SYS_RSEGS - + i * TRX_SYS_RSEG_SLOT_SIZE - + TRX_SYS_RSEG_PAGE_NO, MLOG_4BYTES, mtr)); + + i * TRX_SYS_RSEG_SLOT_SIZE + + TRX_SYS_RSEG_PAGE_NO, MLOG_4BYTES, mtr)); } /********************************************************************* @@ -175,10 +175,10 @@ trx_sysf_rseg_set_space( ut_ad(i < TRX_SYS_N_RSEGS); mlog_write_ulint(sys_header + TRX_SYS_RSEGS - + i * TRX_SYS_RSEG_SLOT_SIZE - + TRX_SYS_RSEG_SPACE, - space, - MLOG_4BYTES, mtr); + + i * TRX_SYS_RSEG_SLOT_SIZE + + TRX_SYS_RSEG_SPACE, + space, + MLOG_4BYTES, mtr); } /********************************************************************* @@ -201,10 +201,10 @@ trx_sysf_rseg_set_page_no( ut_ad(i < TRX_SYS_N_RSEGS); mlog_write_ulint(sys_header + TRX_SYS_RSEGS - + i * TRX_SYS_RSEG_SLOT_SIZE - + TRX_SYS_RSEG_PAGE_NO, - page_no, - MLOG_4BYTES, mtr); + + i * TRX_SYS_RSEG_SLOT_SIZE + + TRX_SYS_RSEG_PAGE_NO, + page_no, + MLOG_4BYTES, mtr); } /********************************************************************* @@ -327,8 +327,8 @@ trx_is_active( } trx = trx_get_on_id(trx_id); - if (trx && (trx->conc_state == TRX_ACTIVE || - trx->conc_state == TRX_PREPARED)) { + if (trx && (trx->conc_state == TRX_ACTIVE + || trx->conc_state == TRX_PREPARED)) { return(TRUE); } @@ -358,7 +358,7 @@ trx_sys_get_new_trx_id(void) repeatedly started! */ if (ut_dulint_get_low(trx_sys->max_trx_id) - % TRX_SYS_TRX_ID_WRITE_MARGIN == 0) { + % TRX_SYS_TRX_ID_WRITE_MARGIN == 0) { trx_sys_flush_max_trx_id(); } diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 94f85366d1e..8232699c7f9 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -670,9 +670,11 @@ struct trx_struct{ error, or empty. */ }; -#define TRX_MAX_N_THREADS 32 /* maximum number of concurrent - threads running a single operation of - a transaction, e.g., a parallel query */ +#define TRX_MAX_N_THREADS 32 /* maximum number of + concurrent threads running a + single operation of a + transaction, e.g., a parallel + query */ /* Transaction types */ #define TRX_USER 1 /* normal user transaction */ #define TRX_PURGE 2 /* purge transaction: this is not diff --git a/storage/innobase/include/trx0trx.ic b/storage/innobase/include/trx0trx.ic index 3992225ed8b..d562db233e9 100644 --- a/storage/innobase/include/trx0trx.ic +++ b/storage/innobase/include/trx0trx.ic @@ -94,5 +94,5 @@ trx_new_rec_locks_contain( dict_index_t* index) /* in: index */ { return(trx->new_rec_locks[0] == index - || trx->new_rec_locks[1] == index); + || trx->new_rec_locks[1] == index); } diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index 83f022cc2c5..87849ab42c3 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -26,7 +26,7 @@ trx_undo_build_roll_ptr( ibool is_insert, /* in: TRUE if insert undo log */ ulint rseg_id, /* in: rollback segment id */ ulint page_no, /* in: page number */ - ulint offset); /* in: offset of the undo entry within page */ + ulint offset); /* in: offset of the undo entry within page */ /*************************************************************************** Decodes a roll pointer dulint. */ UNIV_INLINE @@ -96,7 +96,7 @@ trx_undo_page_get_prev_rec( /* out: pointer to record, NULL if none */ trx_undo_rec_t* rec, /* in: undo log record */ ulint page_no,/* in: undo log header page number */ - ulint offset); /* in: undo log header offset on page */ + ulint offset);/* in: undo log header offset on page */ /********************************************************************** Returns the next undo log record on the page in the specified log, or NULL if none exists. */ @@ -107,7 +107,7 @@ trx_undo_page_get_next_rec( /* out: pointer to record, NULL if none */ trx_undo_rec_t* rec, /* in: undo log record */ ulint page_no,/* in: undo log header page number */ - ulint offset); /* in: undo log header offset on page */ + ulint offset);/* in: undo log header offset on page */ /********************************************************************** Returns the last undo record on the page in the specified undo log, or NULL if none exists. */ @@ -129,7 +129,7 @@ trx_undo_page_get_first_rec( /* out: pointer to record, NULL if none */ page_t* undo_page,/* in: undo log page */ ulint page_no,/* in: undo log header page number */ - ulint offset); /* in: undo log header offset on page */ + ulint offset);/* in: undo log header offset on page */ /*************************************************************************** Gets the previous record in an undo log. */ diff --git a/storage/innobase/include/trx0undo.ic b/storage/innobase/include/trx0undo.ic index 1678b292590..f28f36ade03 100644 --- a/storage/innobase/include/trx0undo.ic +++ b/storage/innobase/include/trx0undo.ic @@ -61,7 +61,7 @@ trx_undo_decode_roll_ptr( *rseg_id = (high / (256 * 256)) % 128; *page_no = (high % (256 * 256)) * 256 * 256 - + (low / 256) / 256; + + (low / 256) / 256; } /*************************************************************************** @@ -179,7 +179,7 @@ trx_undo_page_get_start( if (page_no == buf_frame_get_page_no(undo_page)) { start = mach_read_from_2(offset + undo_page - + TRX_UNDO_LOG_START); + + TRX_UNDO_LOG_START); } else { start = TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE; } @@ -210,11 +210,11 @@ trx_undo_page_get_end( if (end == 0) { end = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_FREE); + + TRX_UNDO_PAGE_FREE); } } else { end = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_FREE); + + TRX_UNDO_PAGE_FREE); } return(end); diff --git a/storage/innobase/include/trx0xa.h b/storage/innobase/include/trx0xa.h index e90ce47ffcf..df85cd663cb 100644 --- a/storage/innobase/include/trx0xa.h +++ b/storage/innobase/include/trx0xa.h @@ -144,7 +144,8 @@ struct xa_switch_t { on this list */ #define XA_RBPROTO XA_RBBASE+5 /* A protocol error occurred in the resource manager */ -#define XA_RBTIMEOUT XA_RBBASE+6 /* A transaction branch took too long */ +#define XA_RBTIMEOUT XA_RBBASE+6 /* A transaction branch took + too long */ #define XA_RBTRANSIENT XA_RBBASE+7 /* May retry the transaction branch */ #define XA_RBEND XA_RBTRANSIENT /* The inclusive upper bound of the rollback codes */ diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index c1f028ef4a3..e60241b0ff3 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -96,8 +96,6 @@ memory is read outside the allocated blocks. */ #define UNIV_BTR_DEBUG #define UNIV_LIGHT_MEM_DEBUG -#define YYDEBUG 1 - #ifdef HAVE_purify /* The following sets all new allocated memory to zero before use: this can be used to eliminate unnecessary Purify warnings, but note that diff --git a/storage/innobase/include/ut0byte.ic b/storage/innobase/include/ut0byte.ic index 9829b3a2c46..020cf9cedd9 100644 --- a/storage/innobase/include/ut0byte.ic +++ b/storage/innobase/include/ut0byte.ic @@ -62,7 +62,7 @@ ut_conv_dulint_to_longlong( dulint d) /* in: dulint */ { return((ib_longlong)d.low - + (((ib_longlong)d.high) << 32)); + + (((ib_longlong)d.high) << 32)); } /*********************************************************** diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic index 455007c7d9b..625c378489a 100644 --- a/storage/innobase/include/ut0rnd.ic +++ b/storage/innobase/include/ut0rnd.ic @@ -71,8 +71,7 @@ ut_rnd_gen_ulint(void) n_bits = 8 * sizeof(ulint); - ut_rnd_ulint_counter = - UT_RND1 * ut_rnd_ulint_counter + UT_RND2; + ut_rnd_ulint_counter = UT_RND1 * ut_rnd_ulint_counter + UT_RND2; rnd = ut_rnd_gen_next_ulint(ut_rnd_ulint_counter); @@ -151,7 +150,7 @@ ut_fold_ulint_pair( ulint n2) /* in: ulint */ { return(((((n1 ^ n2 ^ UT_HASH_RANDOM_MASK2) << 8) + n1) - ^ UT_HASH_RANDOM_MASK) + n2); + ^ UT_HASH_RANDOM_MASK) + n2); } /***************************************************************** @@ -164,7 +163,7 @@ ut_fold_dulint( dulint d) /* in: dulint */ { return(ut_fold_ulint_pair(ut_dulint_get_low(d), - ut_dulint_get_high(d))); + ut_dulint_get_high(d))); } /***************************************************************** diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index a73a78620f1..3a2f17f41e5 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -477,14 +477,16 @@ lock_check_trx_id_sanity( if (ut_dulint_cmp(trx_id, trx_sys->max_trx_id) >= 0) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: transaction id associated" - " with record\n", - stderr); + " with record\n", + stderr); rec_print_new(stderr, rec, offsets); fputs("InnoDB: in ", stderr); dict_index_name_print(stderr, NULL, index); fprintf(stderr, "\n" -"InnoDB: is %lu %lu which is higher than the global trx id counter %lu %lu!\n" -"InnoDB: The table is corrupt. You have to do dump + drop + reimport.\n", + "InnoDB: is %lu %lu which is higher than the" + " global trx id counter %lu %lu!\n" + "InnoDB: The table is corrupt. You have to do" + " dump + drop + reimport.\n", (ulong) ut_dulint_get_high(trx_id), (ulong) ut_dulint_get_low(trx_id), (ulong) ut_dulint_get_high(trx_sys->max_trx_id), @@ -674,8 +676,8 @@ lock_get_src_table( } else if (!src) { /* This presumably is the source table. */ src = tab_lock->table; - if (UT_LIST_GET_LEN(src->locks) != 1 || - UT_LIST_GET_FIRST(src->locks) != lock) { + if (UT_LIST_GET_LEN(src->locks) != 1 + || UT_LIST_GET_FIRST(src->locks) != lock) { /* We only support the case when there is only one lock on this table. */ return(NULL); @@ -863,9 +865,9 @@ lock_mode_stronger_or_eq( ulint mode2) /* in: lock mode */ { ut_ad(mode1 == LOCK_X || mode1 == LOCK_S || mode1 == LOCK_IX - || mode1 == LOCK_IS || mode1 == LOCK_AUTO_INC); + || mode1 == LOCK_IS || mode1 == LOCK_AUTO_INC); ut_ad(mode2 == LOCK_X || mode2 == LOCK_S || mode2 == LOCK_IX - || mode2 == LOCK_IS || mode2 == LOCK_AUTO_INC); + || mode2 == LOCK_IS || mode2 == LOCK_AUTO_INC); if (mode1 == LOCK_X) { return(TRUE); @@ -875,7 +877,7 @@ lock_mode_stronger_or_eq( return(TRUE); } else if (mode1 == LOCK_S - && (mode2 == LOCK_S || mode2 == LOCK_IS)) { + && (mode2 == LOCK_S || mode2 == LOCK_IS)) { return(TRUE); } else if (mode1 == LOCK_IS && mode2 == LOCK_IS) { @@ -883,7 +885,7 @@ lock_mode_stronger_or_eq( return(TRUE); } else if (mode1 == LOCK_IX && (mode2 == LOCK_IX - || mode2 == LOCK_IS)) { + || mode2 == LOCK_IS)) { return(TRUE); } @@ -901,9 +903,9 @@ lock_mode_compatible( ulint mode2) /* in: lock mode */ { ut_ad(mode1 == LOCK_X || mode1 == LOCK_S || mode1 == LOCK_IX - || mode1 == LOCK_IS || mode1 == LOCK_AUTO_INC); + || mode1 == LOCK_IS || mode1 == LOCK_AUTO_INC); ut_ad(mode2 == LOCK_X || mode2 == LOCK_S || mode2 == LOCK_IX - || mode2 == LOCK_IS || mode2 == LOCK_AUTO_INC); + || mode2 == LOCK_IS || mode2 == LOCK_AUTO_INC); if (mode1 == LOCK_S && (mode2 == LOCK_IS || mode2 == LOCK_S)) { @@ -914,18 +916,18 @@ lock_mode_compatible( return(FALSE); } else if (mode1 == LOCK_AUTO_INC && (mode2 == LOCK_IS - || mode2 == LOCK_IX)) { + || mode2 == LOCK_IX)) { return(TRUE); } else if (mode1 == LOCK_IS && (mode2 == LOCK_IS - || mode2 == LOCK_IX - || mode2 == LOCK_AUTO_INC - || mode2 == LOCK_S)) { + || mode2 == LOCK_IX + || mode2 == LOCK_AUTO_INC + || mode2 == LOCK_S)) { return(TRUE); } else if (mode1 == LOCK_IX && (mode2 == LOCK_IS - || mode2 == LOCK_AUTO_INC - || mode2 == LOCK_IX)) { + || mode2 == LOCK_AUTO_INC + || mode2 == LOCK_IX)) { return(TRUE); } @@ -956,14 +958,14 @@ lock_rec_has_to_wait( ut_ad(lock_get_type(lock2) == LOCK_REC); if (trx != lock2->trx - && !lock_mode_compatible(LOCK_MODE_MASK & type_mode, - lock_get_mode(lock2))) { + && !lock_mode_compatible(LOCK_MODE_MASK & type_mode, + lock_get_mode(lock2))) { /* We have somewhat complex rules when gap type record locks cause waits */ if ((lock_is_on_supremum || (type_mode & LOCK_GAP)) - && !(type_mode & LOCK_INSERT_INTENTION)) { + && !(type_mode & LOCK_INSERT_INTENTION)) { /* Gap type locks without LOCK_INSERT_INTENTION flag do not need to wait for anything. This is because @@ -974,7 +976,7 @@ lock_rec_has_to_wait( } if (!(type_mode & LOCK_INSERT_INTENTION) - && lock_rec_get_gap(lock2)) { + && lock_rec_get_gap(lock2)) { /* Record lock (LOCK_ORDINARY or LOCK_REC_NOT_GAP does not need to wait for a gap type lock */ @@ -983,7 +985,7 @@ lock_rec_has_to_wait( } if ((type_mode & LOCK_GAP) - && lock_rec_get_rec_not_gap(lock2)) { + && lock_rec_get_rec_not_gap(lock2)) { /* Lock on gap does not need to wait for a LOCK_REC_NOT_GAP type lock */ @@ -1029,8 +1031,8 @@ lock_has_to_wait( ut_ad(lock1 && lock2); if (lock1->trx != lock2->trx - && !lock_mode_compatible(lock_get_mode(lock1), - lock_get_mode(lock2))) { + && !lock_mode_compatible(lock_get_mode(lock1), + lock_get_mode(lock2))) { if (lock_get_type(lock1) == LOCK_REC) { ut_ad(lock_get_type(lock2) == LOCK_REC); @@ -1038,8 +1040,9 @@ lock_has_to_wait( then the second bit on the lock bitmap is set */ return(lock_rec_has_to_wait(lock1->trx, - lock1->type_mode, lock2, - lock_rec_get_nth_bit(lock1,1))); + lock1->type_mode, lock2, + lock_rec_get_nth_bit + (lock1, 1))); } return(TRUE); @@ -1176,7 +1179,7 @@ lock_rec_get_next_on_page( } if ((lock->un_member.rec_lock.space == space) - && (lock->un_member.rec_lock.page_no == page_no)) { + && (lock->un_member.rec_lock.page_no == page_no)) { break; } @@ -1203,10 +1206,10 @@ lock_rec_get_first_on_page_addr( #endif /* UNIV_SYNC_DEBUG */ lock = HASH_GET_FIRST(lock_sys->rec_hash, - lock_rec_hash(space, page_no)); + lock_rec_hash(space, page_no)); while (lock) { if ((lock->un_member.rec_lock.space == space) - && (lock->un_member.rec_lock.page_no == page_no)) { + && (lock->un_member.rec_lock.page_no == page_no)) { break; } @@ -1271,7 +1274,7 @@ lock_rec_get_first_on_page( page_no = buf_frame_get_page_no(ptr); if ((lock->un_member.rec_lock.space == space) - && (lock->un_member.rec_lock.page_no == page_no)) { + && (lock->un_member.rec_lock.page_no == page_no)) { break; } @@ -1300,13 +1303,13 @@ lock_rec_get_next( if (page_rec_is_comp(rec)) { do { lock = lock_rec_get_next_on_page(lock); - } while (lock && !lock_rec_get_nth_bit(lock, - rec_get_heap_no(rec, TRUE))); + } while (lock && !lock_rec_get_nth_bit + (lock, rec_get_heap_no(rec, TRUE))); } else { do { lock = lock_rec_get_next_on_page(lock); - } while (lock && !lock_rec_get_nth_bit(lock, - rec_get_heap_no(rec, FALSE))); + } while (lock && !lock_rec_get_nth_bit + (lock, rec_get_heap_no(rec, FALSE))); } return(lock); @@ -1464,7 +1467,7 @@ lock_table_has( while (lock != NULL) { if (lock->trx == trx - && lock_mode_stronger_or_eq(lock_get_mode(lock), mode)) { + && lock_mode_stronger_or_eq(lock_get_mode(lock), mode)) { /* The same trx already has locked the table in a mode stronger or equal to the mode given */ @@ -1503,23 +1506,23 @@ lock_rec_has_expl( ut_ad(mutex_own(&kernel_mutex)); #endif /* UNIV_SYNC_DEBUG */ ut_ad((precise_mode & LOCK_MODE_MASK) == LOCK_S - || (precise_mode & LOCK_MODE_MASK) == LOCK_X); + || (precise_mode & LOCK_MODE_MASK) == LOCK_X); ut_ad(!(precise_mode & LOCK_INSERT_INTENTION)); lock = lock_rec_get_first(rec); while (lock) { if (lock->trx == trx - && lock_mode_stronger_or_eq(lock_get_mode(lock), - precise_mode & LOCK_MODE_MASK) - && !lock_get_wait(lock) - && (!lock_rec_get_rec_not_gap(lock) - || (precise_mode & LOCK_REC_NOT_GAP) - || page_rec_is_supremum(rec)) - && (!lock_rec_get_gap(lock) - || (precise_mode & LOCK_GAP) - || page_rec_is_supremum(rec)) - && (!lock_rec_get_insert_intention(lock))) { + && lock_mode_stronger_or_eq(lock_get_mode(lock), + precise_mode & LOCK_MODE_MASK) + && !lock_get_wait(lock) + && (!lock_rec_get_rec_not_gap(lock) + || (precise_mode & LOCK_REC_NOT_GAP) + || page_rec_is_supremum(rec)) + && (!lock_rec_get_gap(lock) + || (precise_mode & LOCK_GAP) + || page_rec_is_supremum(rec)) + && (!lock_rec_get_insert_intention(lock))) { return(lock); } @@ -1560,10 +1563,11 @@ lock_rec_other_has_expl_req( while (lock) { if (lock->trx != trx - && (gap || - !(lock_rec_get_gap(lock) || page_rec_is_supremum(rec))) - && (wait || !lock_get_wait(lock)) - && lock_mode_stronger_or_eq(lock_get_mode(lock), mode)) { + && (gap + || !(lock_rec_get_gap(lock) + || page_rec_is_supremum(rec))) + && (wait || !lock_get_wait(lock)) + && lock_mode_stronger_or_eq(lock_get_mode(lock), mode)) { return(lock); } @@ -1598,7 +1602,7 @@ lock_rec_other_has_conflicting( while (lock) { if (lock_rec_has_to_wait(trx, mode, lock, - page_rec_is_supremum(rec))) { + page_rec_is_supremum(rec))) { return(lock); } @@ -1634,8 +1638,8 @@ lock_rec_find_similar_on_page( while (lock != NULL) { if (lock->trx == trx - && lock->type_mode == type_mode - && lock_rec_get_n_bits(lock) > heap_no) { + && lock->type_mode == type_mode + && lock_rec_get_n_bits(lock) > heap_no) { return(lock); } @@ -1677,8 +1681,8 @@ lock_sec_rec_some_has_impl_off_kernel( for a page may be incorrect. */ if (!(ut_dulint_cmp(page_get_max_trx_id(page), - trx_list_get_min_trx_id()) >= 0) - && !recv_recovery_is_on()) { + trx_list_get_min_trx_id()) >= 0) + && !recv_recovery_is_on()) { return(NULL); } @@ -1687,7 +1691,7 @@ lock_sec_rec_some_has_impl_off_kernel( implicit x-lock. We have to look in the clustered index. */ if (!lock_check_trx_id_sanity(page_get_max_trx_id(page), - rec, index, offsets, TRUE)) { + rec, index, offsets, TRUE)) { buf_page_print(page); /* The page is corrupt: try to avoid a crash by returning @@ -1803,7 +1807,7 @@ lock_rec_create( lock_rec_set_nth_bit(lock, heap_no); HASH_INSERT(lock_t, hash, lock_sys->rec_hash, - lock_rec_fold(space, page_no), lock); + lock_rec_fold(space, page_no), lock); if (type_mode & LOCK_WAIT) { lock_set_lock_and_trx_wait(lock, trx); @@ -1857,13 +1861,14 @@ lock_rec_enqueue_waiting( if (trx->dict_operation) { ut_print_timestamp(stderr); - fputs( -" InnoDB: Error: a record lock wait happens in a dictionary operation!\n" -"InnoDB: Table name ", stderr); + fputs(" InnoDB: Error: a record lock wait happens" + " in a dictionary operation!\n" + "InnoDB: Table name ", stderr); ut_print_name(stderr, trx, TRUE, index->table_name); fputs(".\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", - stderr); + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n", + stderr); } /* Enqueue the lock request that will wait to be granted */ @@ -1875,8 +1880,8 @@ lock_rec_enqueue_waiting( if (lock_deadlock_occurs(lock, trx)) { lock_reset_lock_and_trx_wait(lock); - lock_rec_reset_nth_bit(lock, rec_get_heap_no(rec, - page_rec_is_comp(rec))); + lock_rec_reset_nth_bit(lock, rec_get_heap_no + (rec, page_rec_is_comp(rec))); return(DB_DEADLOCK); } @@ -1933,13 +1938,13 @@ lock_rec_add_to_queue( ut_ad(mutex_own(&kernel_mutex)); #endif /* UNIV_SYNC_DEBUG */ ut_ad((type_mode & (LOCK_WAIT | LOCK_GAP)) - || ((type_mode & LOCK_MODE_MASK) != LOCK_S) - || !lock_rec_other_has_expl_req(LOCK_X, 0, LOCK_WAIT, - rec, trx)); + || ((type_mode & LOCK_MODE_MASK) != LOCK_S) + || !lock_rec_other_has_expl_req(LOCK_X, 0, LOCK_WAIT, + rec, trx)); ut_ad((type_mode & (LOCK_WAIT | LOCK_GAP)) - || ((type_mode & LOCK_MODE_MASK) != LOCK_X) - || !lock_rec_other_has_expl_req(LOCK_S, 0, LOCK_WAIT, - rec, trx)); + || ((type_mode & LOCK_MODE_MASK) != LOCK_X) + || !lock_rec_other_has_expl_req(LOCK_S, 0, LOCK_WAIT, + rec, trx)); type_mode = type_mode | LOCK_REC; @@ -1964,7 +1969,7 @@ lock_rec_add_to_queue( while (lock != NULL) { if (lock_get_wait(lock) - && (lock_rec_get_nth_bit(lock, heap_no))) { + && (lock_rec_get_nth_bit(lock, heap_no))) { somebody_waits = TRUE; } @@ -2016,14 +2021,14 @@ lock_rec_lock_fast( ut_ad(mutex_own(&kernel_mutex)); #endif /* UNIV_SYNC_DEBUG */ ut_ad((LOCK_MODE_MASK & mode) != LOCK_S - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); ut_ad((LOCK_MODE_MASK & mode) != LOCK_X - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); ut_ad((LOCK_MODE_MASK & mode) == LOCK_S - || (LOCK_MODE_MASK & mode) == LOCK_X); + || (LOCK_MODE_MASK & mode) == LOCK_X); ut_ad(mode - (LOCK_MODE_MASK & mode) == LOCK_GAP - || mode - (LOCK_MODE_MASK & mode) == 0 - || mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP); + || mode - (LOCK_MODE_MASK & mode) == 0 + || mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP); heap_no = rec_get_heap_no(rec, page_rec_is_comp(rec)); @@ -2036,7 +2041,8 @@ lock_rec_lock_fast( lock_rec_create(mode, rec, index, trx); if (srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) { + || trx->isolation_level + == TRX_ISO_READ_COMMITTED) { trx_register_new_rec_lock(trx, index); } } @@ -2050,8 +2056,8 @@ lock_rec_lock_fast( } if (lock->trx != trx - || lock->type_mode != (mode | LOCK_REC) - || lock_rec_get_n_bits(lock) <= heap_no) { + || lock->type_mode != (mode | LOCK_REC) + || lock_rec_get_n_bits(lock) <= heap_no) { return(FALSE); } @@ -2063,7 +2069,8 @@ lock_rec_lock_fast( if (!lock_rec_get_nth_bit(lock, heap_no)) { lock_rec_set_nth_bit(lock, heap_no); if (srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) { + || trx->isolation_level + == TRX_ISO_READ_COMMITTED) { trx_register_new_rec_lock(trx, index); } } @@ -2099,14 +2106,14 @@ lock_rec_lock_slow( ut_ad(mutex_own(&kernel_mutex)); #endif /* UNIV_SYNC_DEBUG */ ut_ad((LOCK_MODE_MASK & mode) != LOCK_S - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); ut_ad((LOCK_MODE_MASK & mode) != LOCK_X - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); ut_ad((LOCK_MODE_MASK & mode) == LOCK_S - || (LOCK_MODE_MASK & mode) == LOCK_X); + || (LOCK_MODE_MASK & mode) == LOCK_X); ut_ad(mode - (LOCK_MODE_MASK & mode) == LOCK_GAP - || mode - (LOCK_MODE_MASK & mode) == 0 - || mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP); + || mode - (LOCK_MODE_MASK & mode) == 0 + || mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP); trx = thr_get_trx(thr); @@ -2124,7 +2131,7 @@ lock_rec_lock_slow( err = lock_rec_enqueue_waiting(mode, rec, index, thr); if (srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) { + || trx->isolation_level == TRX_ISO_READ_COMMITTED) { trx_register_new_rec_lock(trx, index); } } else { @@ -2132,9 +2139,10 @@ lock_rec_lock_slow( /* Set the requested lock on the record */ lock_rec_add_to_queue(LOCK_REC | mode, rec, index, - trx); + trx); if (srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) { + || trx->isolation_level + == TRX_ISO_READ_COMMITTED) { trx_register_new_rec_lock(trx, index); } } @@ -2172,14 +2180,14 @@ lock_rec_lock( ut_ad(mutex_own(&kernel_mutex)); #endif /* UNIV_SYNC_DEBUG */ ut_ad((LOCK_MODE_MASK & mode) != LOCK_S - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); ut_ad((LOCK_MODE_MASK & mode) != LOCK_X - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); ut_ad((LOCK_MODE_MASK & mode) == LOCK_S - || (LOCK_MODE_MASK & mode) == LOCK_X); + || (LOCK_MODE_MASK & mode) == LOCK_X); ut_ad(mode - (LOCK_MODE_MASK & mode) == LOCK_GAP - || mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP - || mode - (LOCK_MODE_MASK & mode) == 0); + || mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP + || mode - (LOCK_MODE_MASK & mode) == 0); if (lock_rec_lock_fast(impl, mode, rec, index, thr)) { @@ -2223,7 +2231,7 @@ lock_rec_has_to_wait_in_queue( while (lock != wait_lock) { if (lock_rec_get_nth_bit(lock, heap_no) - && lock_has_to_wait(wait_lock, lock)) { + && lock_has_to_wait(wait_lock, lock)) { return(TRUE); } @@ -2253,7 +2261,8 @@ lock_grant( if (lock->trx->auto_inc_lock != NULL) { fprintf(stderr, - "InnoDB: Error: trx already had an AUTO-INC lock!\n"); + "InnoDB: Error: trx already had" + " an AUTO-INC lock!\n"); } /* Store pointer to lock to trx so that we know to @@ -2335,7 +2344,7 @@ lock_rec_dequeue_from_page( page_no = in_lock->un_member.rec_lock.page_no; HASH_DELETE(lock_t, hash, lock_sys->rec_hash, - lock_rec_fold(space, page_no), in_lock); + lock_rec_fold(space, page_no), in_lock); UT_LIST_REMOVE(trx_locks, trx->trx_locks, in_lock); @@ -2346,7 +2355,7 @@ lock_rec_dequeue_from_page( while (lock != NULL) { if (lock_get_wait(lock) - && !lock_rec_has_to_wait_in_queue(lock)) { + && !lock_rec_has_to_wait_in_queue(lock)) { /* Grant the lock */ lock_grant(lock); @@ -2380,7 +2389,7 @@ lock_rec_discard( page_no = in_lock->un_member.rec_lock.page_no; HASH_DELETE(lock_t, hash, lock_sys->rec_hash, - lock_rec_fold(space, page_no), in_lock); + lock_rec_fold(space, page_no), in_lock); UT_LIST_REMOVE(trx_locks, trx->trx_locks, in_lock); } @@ -2482,14 +2491,14 @@ lock_rec_inherit_to_gap( while (lock != NULL) { if (!lock_rec_get_insert_intention(lock) - && !((srv_locks_unsafe_for_binlog - || lock->trx->isolation_level == - TRX_ISO_READ_COMMITTED) - && lock_get_mode(lock) == LOCK_X)) { + && !((srv_locks_unsafe_for_binlog + || lock->trx->isolation_level + == TRX_ISO_READ_COMMITTED) + && lock_get_mode(lock) == LOCK_X)) { lock_rec_add_to_queue(LOCK_REC | lock_get_mode(lock) - | LOCK_GAP, - heir, lock->index, lock->trx); + | LOCK_GAP, + heir, lock->index, lock->trx); } lock = lock_rec_get_next(rec, lock); @@ -2517,12 +2526,12 @@ lock_rec_inherit_to_gap_if_gap_lock( while (lock != NULL) { if (!lock_rec_get_insert_intention(lock) - && (page_rec_is_supremum(rec) - || !lock_rec_get_rec_not_gap(lock))) { + && (page_rec_is_supremum(rec) + || !lock_rec_get_rec_not_gap(lock))) { lock_rec_add_to_queue(LOCK_REC | lock_get_mode(lock) - | LOCK_GAP, - heir, lock->index, lock->trx); + | LOCK_GAP, + heir, lock->index, lock->trx); } lock = lock_rec_get_next(rec, lock); @@ -2568,7 +2577,7 @@ lock_rec_move( the function works also if donator == receiver */ lock_rec_add_to_queue(type_mode, receiver, lock->index, - lock->trx); + lock->trx); lock = lock_rec_get_next(donator, lock); } @@ -2650,12 +2659,12 @@ lock_move_reorganize_page( /* Set locks according to old locks */ for (;;) { - ut_ad(comp || 0 == ut_memcmp(page_cur_get_rec(&cur1), - page_cur_get_rec(&cur2), - rec_get_data_size_old( - page_cur_get_rec(&cur2)))); + ut_ad(comp || !memcmp(page_cur_get_rec(&cur1), + page_cur_get_rec(&cur2), + rec_get_data_size_old + (page_cur_get_rec(&cur2)))); old_heap_no = rec_get_heap_no(page_cur_get_rec(&cur2), - comp); + comp); if (lock_rec_get_nth_bit(lock, old_heap_no)) { @@ -2663,14 +2672,14 @@ lock_move_reorganize_page( small for the new heap number! */ lock_rec_add_to_queue(lock->type_mode, - page_cur_get_rec(&cur1), - lock->index, lock->trx); + page_cur_get_rec(&cur1), + lock->index, lock->trx); /* if ((page_cur_get_rec(&cur1) == sup) - && lock_get_wait(lock)) { - fprintf(stderr, + && lock_get_wait(lock)) { + fprintf(stderr, "---\n--\n!!!Lock reorg: supr type %lu\n", - lock->type_mode); + lock->type_mode); } */ } @@ -2683,7 +2692,7 @@ lock_move_reorganize_page( page_cur_move_to_next(&cur2); } - /* Remember that we chained old locks on the trx_locks field: */ + /* Remember that we chained old locks on the trx_locks field */ lock = UT_LIST_GET_NEXT(trx_locks, lock); } @@ -2692,8 +2701,10 @@ lock_move_reorganize_page( mem_heap_free(heap); -/* ut_ad(lock_rec_validate_page(buf_frame_get_space_id(page), - buf_frame_get_page_no(page))); */ +#if 0 + ut_ad(lock_rec_validate_page(buf_frame_get_space_id(page), + buf_frame_get_page_no(page))); +#endif } /***************************************************************** @@ -2746,12 +2757,12 @@ lock_move_rec_list_end( reset the lock bits on the old */ while (page_cur_get_rec(&cur1) != sup) { - ut_ad(comp || 0 == ut_memcmp(page_cur_get_rec(&cur1), - page_cur_get_rec(&cur2), - rec_get_data_size_old( - page_cur_get_rec(&cur2)))); + ut_ad(comp || !memcmp(page_cur_get_rec(&cur1), + page_cur_get_rec(&cur2), + rec_get_data_size_old + (page_cur_get_rec(&cur2)))); heap_no = rec_get_heap_no(page_cur_get_rec(&cur1), - comp); + comp); if (lock_rec_get_nth_bit(lock, heap_no)) { type_mode = lock->type_mode; @@ -2763,8 +2774,8 @@ lock_move_rec_list_end( } lock_rec_add_to_queue(type_mode, - page_cur_get_rec(&cur2), - lock->index, lock->trx); + page_cur_get_rec(&cur2), + lock->index, lock->trx); } page_cur_move_to_next(&cur1); @@ -2776,10 +2787,12 @@ lock_move_rec_list_end( lock_mutex_exit_kernel(); -/* ut_ad(lock_rec_validate_page(buf_frame_get_space_id(page), - buf_frame_get_page_no(page))); +#if 0 + ut_ad(lock_rec_validate_page(buf_frame_get_space_id(page), + buf_frame_get_page_no(page))); ut_ad(lock_rec_validate_page(buf_frame_get_space_id(new_page), - buf_frame_get_page_no(new_page))); */ + buf_frame_get_page_no(new_page))); +#endif } /***************************************************************** @@ -2824,12 +2837,12 @@ lock_move_rec_list_start( reset the lock bits on the old */ while (page_cur_get_rec(&cur1) != rec) { - ut_ad(comp || 0 == ut_memcmp(page_cur_get_rec(&cur1), - page_cur_get_rec(&cur2), - rec_get_data_size_old( - page_cur_get_rec(&cur2)))); + ut_ad(comp || !memcmp(page_cur_get_rec(&cur1), + page_cur_get_rec(&cur2), + rec_get_data_size_old + (page_cur_get_rec(&cur2)))); heap_no = rec_get_heap_no(page_cur_get_rec(&cur1), - comp); + comp); if (lock_rec_get_nth_bit(lock, heap_no)) { type_mode = lock->type_mode; @@ -2841,8 +2854,8 @@ lock_move_rec_list_start( } lock_rec_add_to_queue(type_mode, - page_cur_get_rec(&cur2), - lock->index, lock->trx); + page_cur_get_rec(&cur2), + lock->index, lock->trx); } page_cur_move_to_next(&cur1); @@ -2853,11 +2866,12 @@ lock_move_rec_list_start( } lock_mutex_exit_kernel(); - -/* ut_ad(lock_rec_validate_page(buf_frame_get_space_id(page), - buf_frame_get_page_no(page))); +#if 0 + ut_ad(lock_rec_validate_page(buf_frame_get_space_id(page), + buf_frame_get_page_no(page))); ut_ad(lock_rec_validate_page(buf_frame_get_space_id(new_page), - buf_frame_get_page_no(new_page))); */ + buf_frame_get_page_no(new_page))); +#endif } /***************************************************************** @@ -2878,13 +2892,14 @@ lock_update_split_right( of the right page */ lock_rec_move(page_get_supremum_rec(right_page), - page_get_supremum_rec(left_page), comp); + page_get_supremum_rec(left_page), comp); /* Inherit the locks to the supremum of left page from the successor of the infimum on right page */ lock_rec_inherit_to_gap(page_get_supremum_rec(left_page), - page_rec_get_next(page_get_infimum_rec(right_page))); + page_rec_get_next + (page_get_infimum_rec(right_page))); lock_mutex_exit_kernel(); } @@ -2941,7 +2956,7 @@ lock_update_root_raise( of new_page */ lock_rec_move(page_get_supremum_rec(new_page), - page_get_supremum_rec(root), comp); + page_get_supremum_rec(root), comp); lock_mutex_exit_kernel(); } @@ -2964,7 +2979,7 @@ lock_update_copy_and_discard( of new_page */ lock_rec_move(page_get_supremum_rec(new_page), - page_get_supremum_rec(page), comp); + page_get_supremum_rec(page), comp); lock_rec_free_all_from_discard_page(page); lock_mutex_exit_kernel(); @@ -2985,7 +3000,8 @@ lock_update_split_left( successor of the infimum on the right page */ lock_rec_inherit_to_gap(page_get_supremum_rec(left_page), - page_rec_get_next(page_get_infimum_rec(right_page))); + page_rec_get_next + (page_get_infimum_rec(right_page))); lock_mutex_exit_kernel(); } @@ -3245,7 +3261,7 @@ retry: lock_deadlock_found = TRUE; fputs("*** WE ROLL BACK TRANSACTION (2)\n", - lock_latest_err_file); + lock_latest_err_file); return(TRUE); } @@ -3297,7 +3313,7 @@ lock_deadlock_recursive( *cost = *cost + 1; if ((depth > LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK) - || (*cost > LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK)) { + || (*cost > LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK)) { return(LOCK_VICTIM_IS_START); } @@ -3316,7 +3332,8 @@ lock_deadlock_recursive( for (;;) { if (lock_get_type(lock) & LOCK_TABLE) { - lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, lock); + lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, + lock); } else { ut_ad(lock_get_type(lock) == LOCK_REC); ut_a(bit_no != ULINT_UNDEFINED); @@ -3347,8 +3364,8 @@ lock_deadlock_recursive( trx_print(ef, wait_lock->trx, 3000); - fputs( - "*** (1) WAITING FOR THIS LOCK TO BE GRANTED:\n", ef); + fputs("*** (1) WAITING FOR THIS LOCK" + " TO BE GRANTED:\n", ef); if (lock_get_type(wait_lock) == LOCK_REC) { lock_rec_print(ef, wait_lock); @@ -3368,11 +3385,11 @@ lock_deadlock_recursive( lock_table_print(ef, lock); } - fputs( - "*** (2) WAITING FOR THIS LOCK TO BE GRANTED:\n", ef); + fputs("*** (2) WAITING FOR THIS LOCK" + " TO BE GRANTED:\n", ef); if (lock_get_type(start->wait_lock) - == LOCK_REC) { + == LOCK_REC) { lock_rec_print(ef, start->wait_lock); } else { lock_table_print(ef, start->wait_lock); @@ -3383,7 +3400,7 @@ lock_deadlock_recursive( } #endif /* UNIV_DEBUG */ if (ut_dulint_cmp(wait_lock->trx->undo_no, - start->undo_no) >= 0) { + start->undo_no) >= 0) { /* Our recursion starting point transaction is 'smaller', let us choose 'start' as the victim and roll @@ -3399,10 +3416,10 @@ lock_deadlock_recursive( recursion starting point transaction */ fputs("*** WE ROLL BACK TRANSACTION (1)\n", - ef); + ef); wait_lock->trx->was_chosen_as_deadlock_victim - = TRUE; + = TRUE; lock_cancel_waiting_and_release(wait_lock); @@ -3422,8 +3439,9 @@ lock_deadlock_recursive( incompatible mode, and is itself waiting for a lock */ - ret = lock_deadlock_recursive(start, lock_trx, - lock_trx->wait_lock, cost, depth + 1); + ret = lock_deadlock_recursive + (start, lock_trx, + lock_trx->wait_lock, cost, depth + 1); if (ret != 0) { return(ret); @@ -3552,13 +3570,14 @@ lock_table_enqueue_waiting( if (trx->dict_operation) { ut_print_timestamp(stderr); - fputs( -" InnoDB: Error: a table lock wait happens in a dictionary operation!\n" -"InnoDB: Table name ", stderr); + fputs(" InnoDB: Error: a table lock wait happens" + " in a dictionary operation!\n" + "InnoDB: Table name ", stderr); ut_print_name(stderr, trx, TRUE, table->name); fputs(".\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", - stderr); + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n", + stderr); } /* Enqueue the lock request that will wait to be granted */ @@ -3617,8 +3636,8 @@ lock_table_other_has_incompatible( while (lock != NULL) { if ((lock->trx != trx) - && (!lock_mode_compatible(lock_get_mode(lock), mode)) - && (wait || !(lock_get_wait(lock)))) { + && (!lock_mode_compatible(lock_get_mode(lock), mode)) + && (wait || !(lock_get_wait(lock)))) { return(TRUE); } @@ -3779,7 +3798,7 @@ lock_table_dequeue( while (lock != NULL) { if (lock_get_wait(lock) - && !lock_table_has_to_wait_in_queue(lock)) { + && !lock_table_has_to_wait_in_queue(lock)) { /* Grant the lock */ lock_grant(lock); @@ -3836,8 +3855,9 @@ lock_rec_unlock( mutex_exit(&kernel_mutex); ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: unlock row could not find a %lu mode lock on the record\n", - (ulong)lock_mode); + " InnoDB: Error: unlock row could not" + " find a %lu mode lock on the record\n", + (ulong) lock_mode); return; } @@ -3848,7 +3868,7 @@ lock_rec_unlock( while (lock != NULL) { if (lock_get_wait(lock) - && !lock_rec_has_to_wait_in_queue(lock)) { + && !lock_rec_has_to_wait_in_queue(lock)) { /* Grant the lock */ lock_grant(lock); @@ -3926,8 +3946,8 @@ lock_release_off_kernel( ut_ad(lock_get_type(lock) & LOCK_TABLE); if (lock_get_mode(lock) != LOCK_IS - && 0 != ut_dulint_cmp(trx->undo_no, - ut_dulint_zero)) { + && 0 != ut_dulint_cmp(trx->undo_no, + ut_dulint_zero)) { /* The trx may have modified the table. We block the use of the MySQL query cache for @@ -3935,8 +3955,8 @@ lock_release_off_kernel( table = lock->un_member.tab_lock.table; - table->query_cache_inv_trx_id = - trx_sys->max_trx_id; + table->query_cache_inv_trx_id + = trx_sys->max_trx_id; } lock_table_dequeue(lock); @@ -4015,12 +4035,12 @@ lock_reset_all_on_table_for_trx( prev_lock = UT_LIST_GET_PREV(trx_locks, lock); if (lock_get_type(lock) == LOCK_REC - && lock->index->table == table) { + && lock->index->table == table) { ut_a(!lock_get_wait(lock)); lock_rec_discard(lock); } else if (lock_get_type(lock) & LOCK_TABLE - && lock->un_member.tab_lock.table == table) { + && lock->un_member.tab_lock.table == table) { ut_a(!lock_get_wait(lock)); @@ -4075,7 +4095,7 @@ lock_table_print( fputs("TABLE LOCK table ", file); ut_print_name(file, lock->trx, TRUE, - lock->un_member.tab_lock.table->name); + lock->un_member.tab_lock.table->name); fprintf(file, " trx id %lu %lu", (ulong) (lock->trx)->id.high, (ulong) (lock->trx)->id.low); @@ -4090,7 +4110,8 @@ lock_table_print( } else if (lock_get_mode(lock) == LOCK_AUTO_INC) { fputs(" lock mode AUTO-INC", file); } else { - fprintf(file, " unknown lock mode %lu", (ulong) lock_get_mode(lock)); + fprintf(file, " unknown lock mode %lu", + (ulong) lock_get_mode(lock)); } if (lock_get_wait(lock)) { @@ -4168,8 +4189,8 @@ lock_rec_print( break the latching order */ page = buf_page_get_gen(space, page_no, RW_NO_LATCH, - NULL, BUF_GET_IF_IN_POOL, - __FILE__, __LINE__, &mtr); + NULL, BUF_GET_IF_IN_POOL, + __FILE__, __LINE__, &mtr); if (page) { page = buf_page_get_nowait(space, page_no, RW_S_LATCH, &mtr); @@ -4179,7 +4200,7 @@ lock_rec_print( S-latch. */ page = buf_page_get_nowait(space, page_no, RW_X_LATCH, - &mtr); + &mtr); } } @@ -4198,8 +4219,9 @@ lock_rec_print( if (page) { rec_t* rec = page_find_rec_with_heap_no(page, i); - offsets = rec_get_offsets(rec, lock->index, - offsets, ULINT_UNDEFINED, &heap); + offsets = rec_get_offsets + (rec, lock->index, offsets, + ULINT_UNDEFINED, &heap); rec_print_new(file, rec, offsets); } @@ -4259,36 +4281,35 @@ lock_print_info_summary( lock_mutex_enter_kernel(); if (lock_deadlock_found) { - fputs( -"------------------------\n" -"LATEST DETECTED DEADLOCK\n" -"------------------------\n", file); + fputs("------------------------\n" + "LATEST DETECTED DEADLOCK\n" + "------------------------\n", file); ut_copy_file(file, lock_latest_err_file); } - fputs( -"------------\n" -"TRANSACTIONS\n" -"------------\n", file); + fputs("------------\n" + "TRANSACTIONS\n" + "------------\n", file); fprintf(file, "Trx id counter %lu %lu\n", (ulong) ut_dulint_get_high(trx_sys->max_trx_id), (ulong) ut_dulint_get_low(trx_sys->max_trx_id)); fprintf(file, - "Purge done for trx's n:o < %lu %lu undo n:o < %lu %lu\n", + "Purge done for trx's n:o < %lu %lu undo n:o < %lu %lu\n", (ulong) ut_dulint_get_high(purge_sys->purge_trx_no), (ulong) ut_dulint_get_low(purge_sys->purge_trx_no), (ulong) ut_dulint_get_high(purge_sys->purge_undo_no), (ulong) ut_dulint_get_low(purge_sys->purge_undo_no)); fprintf(file, - "History list length %lu\n", (ulong) trx_sys->rseg_history_len); + "History list length %lu\n", + (ulong) trx_sys->rseg_history_len); fprintf(file, "Total number of lock structs in row lock hash table %lu\n", - (ulong) lock_get_n_rec_locks()); + (ulong) lock_get_n_rec_locks()); } /************************************************************************* @@ -4355,11 +4376,16 @@ loop: if (trx->read_view) { fprintf(file, -"Trx read view will not see trx with id >= %lu %lu, sees < %lu %lu\n", - (ulong) ut_dulint_get_high(trx->read_view->low_limit_id), - (ulong) ut_dulint_get_low(trx->read_view->low_limit_id), - (ulong) ut_dulint_get_high(trx->read_view->up_limit_id), - (ulong) ut_dulint_get_low(trx->read_view->up_limit_id)); + "Trx read view will not see trx with" + " id >= %lu %lu, sees < %lu %lu\n", + (ulong) ut_dulint_get_high + (trx->read_view->low_limit_id), + (ulong) ut_dulint_get_low + (trx->read_view->low_limit_id), + (ulong) ut_dulint_get_high + (trx->read_view->up_limit_id), + (ulong) ut_dulint_get_low + (trx->read_view->up_limit_id)); } fprintf(file, @@ -4368,8 +4394,10 @@ loop: if (trx->que_state == TRX_QUE_LOCK_WAIT) { fprintf(file, - "------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n", - (ulong)difftime(time(NULL), trx->wait_started)); + "------- TRX HAS BEEN WAITING %lu SEC" + " FOR THIS LOCK TO BE GRANTED:\n", + (ulong) difftime(time(NULL), + trx->wait_started)); if (lock_get_type(trx->wait_lock) == LOCK_REC) { lock_rec_print(file, trx->wait_lock); @@ -4415,7 +4443,8 @@ loop: mtr_start(&mtr); - page = buf_page_get_with_no_latch(space, page_no, &mtr); + page = buf_page_get_with_no_latch + (space, page_no, &mtr); mtr_commit(&mtr); @@ -4439,9 +4468,9 @@ loop: nth_lock++; if (nth_lock >= 10) { - fputs( - "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n", - file); + fputs("10 LOCKS PRINTED FOR THIS TRX:" + " SUPPRESSING FURTHER PRINTS\n", + file); nth_trx++; nth_lock = 0; @@ -4474,15 +4503,15 @@ lock_table_queue_validate( while (lock) { ut_a(((lock->trx)->conc_state == TRX_ACTIVE) - || ((lock->trx)->conc_state == TRX_PREPARED) - || ((lock->trx)->conc_state == TRX_COMMITTED_IN_MEMORY)); + || ((lock->trx)->conc_state == TRX_PREPARED) + || ((lock->trx)->conc_state == TRX_COMMITTED_IN_MEMORY)); if (!lock_get_wait(lock)) { ut_a(!is_waiting); - ut_a(!lock_table_other_has_incompatible(lock->trx, 0, - table, lock_get_mode(lock))); + ut_a(!lock_table_other_has_incompatible + (lock->trx, 0, table, lock_get_mode(lock))); } else { is_waiting = TRUE; @@ -4520,9 +4549,14 @@ lock_rec_queue_validate( lock = lock_rec_get_first(rec); while (lock) { - ut_a(lock->trx->conc_state == TRX_ACTIVE - || lock->trx->conc_state == TRX_PREPARED - || lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY); + switch(lock->trx->conc_state) { + case TRX_ACTIVE: + case TRX_PREPARED: + case TRX_COMMITTED_IN_MEMORY: + break; + default: + ut_error; + } ut_a(trx_in_trx_list(lock->trx)); @@ -4546,11 +4580,11 @@ lock_rec_queue_validate( impl_trx = lock_clust_rec_some_has_impl(rec, index, offsets); - if (impl_trx && lock_rec_other_has_expl_req(LOCK_S, 0, - LOCK_WAIT, rec, impl_trx)) { + if (impl_trx && lock_rec_other_has_expl_req + (LOCK_S, 0, LOCK_WAIT, rec, impl_trx)) { - ut_a(lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, rec, - impl_trx)); + ut_a(lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, + rec, impl_trx)); } } @@ -4560,14 +4594,14 @@ lock_rec_queue_validate( next function call: we have to release lock table mutex to obey the latching order */ - impl_trx = lock_sec_rec_some_has_impl_off_kernel( - rec, index, offsets); + impl_trx = lock_sec_rec_some_has_impl_off_kernel + (rec, index, offsets); - if (impl_trx && lock_rec_other_has_expl_req(LOCK_S, 0, - LOCK_WAIT, rec, impl_trx)) { + if (impl_trx && lock_rec_other_has_expl_req + (LOCK_S, 0, LOCK_WAIT, rec, impl_trx)) { ut_a(lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, - rec, impl_trx)); + rec, impl_trx)); } } @@ -4575,8 +4609,8 @@ lock_rec_queue_validate( while (lock) { ut_a(lock->trx->conc_state == TRX_ACTIVE - || lock->trx->conc_state == TRX_PREPARED - || lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY); + || lock->trx->conc_state == TRX_PREPARED + || lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY); ut_a(trx_in_trx_list(lock->trx)); if (index) { @@ -4592,8 +4626,8 @@ lock_rec_queue_validate( } else { mode = LOCK_S; } - ut_a(!lock_rec_other_has_expl_req(mode, - 0, 0, rec, lock->trx)); + ut_a(!lock_rec_other_has_expl_req + (mode, 0, 0, rec, lock->trx)); } else if (lock_get_wait(lock) && !lock_rec_get_gap(lock)) { @@ -4661,8 +4695,8 @@ loop: ut_a(trx_in_trx_list(lock->trx)); ut_a(lock->trx->conc_state == TRX_ACTIVE - || lock->trx->conc_state == TRX_PREPARED - || lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY); + || lock->trx->conc_state == TRX_PREPARED + || lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY); for (i = nth_bit; i < lock_rec_get_n_bits(lock); i++) { @@ -4671,10 +4705,11 @@ loop: index = lock->index; rec = page_find_rec_with_heap_no(page, i); offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); fprintf(stderr, - "Validating %lu %lu\n", (ulong) space, (ulong) page_no); + "Validating %lu %lu\n", + (ulong) space, (ulong) page_no); lock_mutex_exit_kernel(); @@ -4729,8 +4764,8 @@ lock_validate(void) while (lock) { if (lock_get_type(lock) & LOCK_TABLE) { - lock_table_queue_validate( - lock->un_member.tab_lock.table); + lock_table_queue_validate + (lock->un_member.tab_lock.table); } lock = UT_LIST_GET_NEXT(trx_locks, lock); @@ -4752,9 +4787,9 @@ lock_validate(void) space = lock->un_member.rec_lock.space; page_no = lock->un_member.rec_lock.page_no; - if (ut_dulint_cmp( - ut_dulint_create(space, page_no), - limit) >= 0) { + if (ut_dulint_cmp + (ut_dulint_create(space, page_no), + limit) >= 0) { break; } @@ -4836,7 +4871,7 @@ lock_rec_insert_check_and_lock( /* Update the page max trx id field */ page_update_max_trx_id(buf_frame_align(rec), - thr_get_trx(thr)->id); + thr_get_trx(thr)->id); } return(DB_SUCCESS); @@ -4854,13 +4889,13 @@ lock_rec_insert_check_and_lock( had to wait for their insert. Both had waiting gap type lock requests on the successor, which produced an unnecessary deadlock. */ - if (lock_rec_other_has_conflicting(LOCK_X | LOCK_GAP - | LOCK_INSERT_INTENTION, next_rec, trx)) { + if (lock_rec_other_has_conflicting + (LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION, next_rec, trx)) { /* Note that we may get DB_SUCCESS also here! */ err = lock_rec_enqueue_waiting(LOCK_X | LOCK_GAP - | LOCK_INSERT_INTENTION, - next_rec, index, thr); + | LOCK_INSERT_INTENTION, + next_rec, index, thr); } else { err = DB_SUCCESS; } @@ -4871,7 +4906,7 @@ lock_rec_insert_check_and_lock( /* Update the page max trx id field */ page_update_max_trx_id(buf_frame_align(rec), - thr_get_trx(thr)->id); + thr_get_trx(thr)->id); } #ifdef UNIV_DEBUG @@ -4882,7 +4917,7 @@ lock_rec_insert_check_and_lock( *offsets_ = (sizeof offsets_) / sizeof *offsets_; offsets = rec_get_offsets(next_rec, index, offsets_, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); ut_ad(lock_rec_queue_validate(next_rec, index, offsets)); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -4917,8 +4952,8 @@ lock_rec_convert_impl_to_expl( if (index->type & DICT_CLUSTERED) { impl_trx = lock_clust_rec_some_has_impl(rec, index, offsets); } else { - impl_trx = lock_sec_rec_some_has_impl_off_kernel( - rec, index, offsets); + impl_trx = lock_sec_rec_some_has_impl_off_kernel + (rec, index, offsets); } if (impl_trx) { @@ -4926,10 +4961,11 @@ lock_rec_convert_impl_to_expl( record, set one for it */ if (!lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, rec, - impl_trx)) { + impl_trx)) { - lock_rec_add_to_queue(LOCK_REC | LOCK_X - | LOCK_REC_NOT_GAP, rec, index, impl_trx); + lock_rec_add_to_queue + (LOCK_REC | LOCK_X | LOCK_REC_NOT_GAP, + rec, index, impl_trx); } } } @@ -5030,7 +5066,7 @@ lock_sec_rec_modify_check_and_lock( *offsets_ = (sizeof offsets_) / sizeof *offsets_; offsets = rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); ut_ad(lock_rec_queue_validate(rec, index, offsets)); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -5042,7 +5078,7 @@ lock_sec_rec_modify_check_and_lock( /* Update the page max trx id field */ page_update_max_trx_id(buf_frame_align(rec), - thr_get_trx(thr)->id); + thr_get_trx(thr)->id); } return(err); @@ -5085,18 +5121,18 @@ lock_sec_rec_read_check_and_lock( lock_mutex_enter_kernel(); ut_ad(mode != LOCK_X - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); ut_ad(mode != LOCK_S - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); /* Some transaction may have an implicit x-lock on the record only if the max trx id for the page >= min trx id for the trx list or a database recovery is running. */ if (((ut_dulint_cmp(page_get_max_trx_id(buf_frame_align(rec)), - trx_list_get_min_trx_id()) >= 0) - || recv_recovery_is_on()) - && !page_rec_is_supremum(rec)) { + trx_list_get_min_trx_id()) >= 0) + || recv_recovery_is_on()) + && !page_rec_is_supremum(rec)) { lock_rec_convert_impl_to_expl(rec, index, offsets); } @@ -5142,7 +5178,7 @@ lock_clust_rec_read_check_and_lock( ut_ad(index->type & DICT_CLUSTERED); ut_ad(page_rec_is_user_rec(rec) || page_rec_is_supremum(rec)); ut_ad(gap_mode == LOCK_ORDINARY || gap_mode == LOCK_GAP - || gap_mode == LOCK_REC_NOT_GAP); + || gap_mode == LOCK_REC_NOT_GAP); ut_ad(rec_offs_validate(rec, index, offsets)); if (flags & BTR_NO_LOCKING_FLAG) { @@ -5153,9 +5189,9 @@ lock_clust_rec_read_check_and_lock( lock_mutex_enter_kernel(); ut_ad(mode != LOCK_X - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX)); ut_ad(mode != LOCK_S - || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); + || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); if (!page_rec_is_supremum(rec)) { @@ -5205,9 +5241,9 @@ lock_clust_rec_read_check_and_lock_alt( *offsets_ = (sizeof offsets_) / sizeof *offsets_; offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &tmp_heap); + ULINT_UNDEFINED, &tmp_heap); ret = lock_clust_rec_read_check_and_lock(flags, rec, index, - offsets, mode, gap_mode, thr); + offsets, mode, gap_mode, thr); if (tmp_heap) { mem_heap_free(tmp_heap); } diff --git a/storage/innobase/log/log0log.c b/storage/innobase/log/log0log.c index 2351c6055de..9ac9e40466c 100644 --- a/storage/innobase/log/log0log.c +++ b/storage/innobase/log/log0log.c @@ -228,9 +228,9 @@ loop: if (log->archiving_state != LOG_ARCH_OFF) { archived_lsn_age = ut_dulint_minus(log->lsn, - log->archived_lsn); + log->archived_lsn); if (archived_lsn_age + len_upper_limit - > log->max_archived_lsn_age) { + > log->max_archived_lsn_age) { /* Not enough free archived space in log groups: do a synchronous archive write batch: */ @@ -296,14 +296,14 @@ part_loop: str = str + len; log_block = ut_align_down(log->buf + log->buf_free, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); log_block_set_data_len(log_block, data_len); if (data_len == OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE) { /* This block became full */ log_block_set_data_len(log_block, OS_FILE_LOG_BLOCK_SIZE); log_block_set_checkpoint_no(log_block, - log_sys->next_checkpoint_no); + log_sys->next_checkpoint_no); len += LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE; log->lsn = ut_dulint_add(log->lsn, len); @@ -347,7 +347,7 @@ log_close(void) lsn = log->lsn; log_block = ut_align_down(log->buf + log->buf_free, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); first_rec_group = log_block_get_first_rec_group(log_block); if (first_rec_group == 0) { @@ -355,8 +355,8 @@ log_close(void) full by the current mtr: the next mtr log record group will start within this block at the offset data_len */ - log_block_set_first_rec_group(log_block, - log_block_get_data_len(log_block)); + log_block_set_first_rec_group + (log_block, log_block_get_data_len(log_block)); } if (log->buf_free > log->max_buf_free) { @@ -374,18 +374,22 @@ log_close(void) big_rec operations, but other operations are smaller. */ if (!log_has_printed_chkp_warning - || difftime(time(NULL), log_last_warning_time) > 15) { + || difftime(time(NULL), log_last_warning_time) > 15) { log_has_printed_chkp_warning = TRUE; log_last_warning_time = time(NULL); ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: ERROR: the age of the last checkpoint is %lu,\n" -"InnoDB: which exceeds the log group capacity %lu.\n" -"InnoDB: If you are using big BLOB or TEXT rows, you must set the\n" -"InnoDB: combined size of log files at least 10 times bigger than the\n" -"InnoDB: largest such row.\n", + " InnoDB: ERROR: the age of the last" + " checkpoint is %lu,\n" + "InnoDB: which exceeds the log group" + " capacity %lu.\n" + "InnoDB: If you are using big" + " BLOB or TEXT rows, you must set the\n" + "InnoDB: combined size of log files" + " at least 10 times bigger than the\n" + "InnoDB: largest such row.\n", (ulong) checkpoint_age, (ulong) log->log_group_capacity); } @@ -399,9 +403,9 @@ log_close(void) oldest_lsn = buf_pool_get_oldest_modification(); if (ut_dulint_is_zero(oldest_lsn) - || (ut_dulint_minus(lsn, oldest_lsn) - > log->max_modified_age_async) - || checkpoint_age > log->max_checkpoint_age_async) { + || (ut_dulint_minus(lsn, oldest_lsn) + > log->max_modified_age_async) + || checkpoint_age > log->max_checkpoint_age_async) { log->check_flush_or_checkpoint = TRUE; } @@ -409,7 +413,7 @@ function_exit: #ifdef UNIV_LOG_DEBUG log_check_log_recs(log->buf + log->old_buf_free, - log->buf_free - log->old_buf_free, log->old_lsn); + log->buf_free - log->old_buf_free, log->old_lsn); #endif return(lsn); @@ -433,8 +437,8 @@ log_pad_current_log_block(void) lsn = log_reserve_and_open(OS_FILE_LOG_BLOCK_SIZE); pad_length = OS_FILE_LOG_BLOCK_SIZE - - (log_sys->buf_free % OS_FILE_LOG_BLOCK_SIZE) - - LOG_BLOCK_TRL_SIZE; + - (log_sys->buf_free % OS_FILE_LOG_BLOCK_SIZE) + - LOG_BLOCK_TRL_SIZE; for (i = 0; i < pad_length; i++) { log_write_low(&b, 1); @@ -446,7 +450,7 @@ log_pad_current_log_block(void) log_release(); ut_a((ut_dulint_get_low(lsn) % OS_FILE_LOG_BLOCK_SIZE) - == LOG_BLOCK_HDR_SIZE); + == LOG_BLOCK_HDR_SIZE); } #endif /* UNIV_LOG_ARCHIVE */ @@ -501,7 +505,7 @@ log_group_calc_real_offset( #endif /* UNIV_SYNC_DEBUG */ return(offset + LOG_FILE_HDR_SIZE - * (1 + offset / (group->file_size - LOG_FILE_HDR_SIZE))); + * (1 + offset / (group->file_size - LOG_FILE_HDR_SIZE))); } /********************************************************** @@ -551,8 +555,8 @@ log_group_calc_lsn_offset( ut_a(offset < (((ib_longlong) 1) << 32)); /* offset must be < 4 GB */ /* fprintf(stderr, - "Offset is %lu gr_lsn_offset is %lu difference is %lu\n", - (ulint)offset,(ulint)gr_lsn_size_offset, (ulint)difference); + "Offset is %lu gr_lsn_offset is %lu difference is %lu\n", + (ulint)offset,(ulint)gr_lsn_size_offset, (ulint)difference); */ return(log_group_calc_real_offset((ulint)offset, group)); @@ -587,15 +591,15 @@ log_calc_where_lsn_is( if (ib_lsn < ib_first_header_lsn) { add_this_many = 1 + (ib_first_header_lsn - ib_lsn) - / (capacity * (ib_longlong)n_log_files); + / (capacity * (ib_longlong)n_log_files); ib_lsn += add_this_many - * capacity * (ib_longlong)n_log_files; + * capacity * (ib_longlong)n_log_files; } ut_a(ib_lsn >= ib_first_header_lsn); file_no = ((ulint)((ib_lsn - ib_first_header_lsn) / capacity)) - % n_log_files; + % n_log_files; *log_file_offset = (ib_lsn - ib_first_header_lsn) % capacity; *log_file_offset = *log_file_offset + LOG_FILE_HDR_SIZE; @@ -658,8 +662,8 @@ log_calc_max_ages(void) } archive_margin = log_group_get_capacity(group) - - (group->file_size - LOG_FILE_HDR_SIZE) - - LOG_ARCHIVE_EXTRA_MARGIN; + - (group->file_size - LOG_FILE_HDR_SIZE) + - LOG_ARCHIVE_EXTRA_MARGIN; if (archive_margin < smallest_archive_margin) { @@ -678,7 +682,7 @@ log_calc_max_ages(void) system error which requires rebooting the database. */ free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency) - + LOG_CHECKPOINT_EXTRA_FREE; + + LOG_CHECKPOINT_EXTRA_FREE; if (free >= smallest_capacity / 2) { success = FALSE; @@ -694,34 +698,40 @@ log_calc_max_ages(void) log_sys->log_group_capacity = smallest_capacity; log_sys->max_modified_age_async = margin - - margin / LOG_POOL_PREFLUSH_RATIO_ASYNC; + - margin / LOG_POOL_PREFLUSH_RATIO_ASYNC; log_sys->max_modified_age_sync = margin - - margin / LOG_POOL_PREFLUSH_RATIO_SYNC; + - margin / LOG_POOL_PREFLUSH_RATIO_SYNC; log_sys->max_checkpoint_age_async = margin - margin - / LOG_POOL_CHECKPOINT_RATIO_ASYNC; + / LOG_POOL_CHECKPOINT_RATIO_ASYNC; log_sys->max_checkpoint_age = margin; #ifdef UNIV_LOG_ARCHIVE log_sys->max_archived_lsn_age = smallest_archive_margin; log_sys->max_archived_lsn_age_async = smallest_archive_margin - - smallest_archive_margin / - LOG_ARCHIVE_RATIO_ASYNC; + - smallest_archive_margin / LOG_ARCHIVE_RATIO_ASYNC; #endif /* UNIV_LOG_ARCHIVE */ failure: mutex_exit(&(log_sys->mutex)); if (!success) { fprintf(stderr, -"InnoDB: Error: ib_logfiles are too small for innodb_thread_concurrency %lu.\n" -"InnoDB: The combined size of ib_logfiles should be bigger than\n" -"InnoDB: 200 kB * innodb_thread_concurrency.\n" -"InnoDB: To get mysqld to start up, set innodb_thread_concurrency in my.cnf\n" -"InnoDB: to a lower value, for example, to 8. After an ERROR-FREE shutdown\n" -"InnoDB: of mysqld you can adjust the size of ib_logfiles, as explained in\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/adding-and-removing.html\n" -"InnoDB: Cannot continue operation. Calling exit(1).\n", + "InnoDB: Error: ib_logfiles are too small" + " for innodb_thread_concurrency %lu.\n" + "InnoDB: The combined size of ib_logfiles" + " should be bigger than\n" + "InnoDB: 200 kB * innodb_thread_concurrency.\n" + "InnoDB: To get mysqld to start up, set" + " innodb_thread_concurrency in my.cnf\n" + "InnoDB: to a lower value, for example, to 8." + " After an ERROR-FREE shutdown\n" + "InnoDB: of mysqld you can adjust the size of" + " ib_logfiles, as explained in\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "adding-and-removing.html\n" + "InnoDB: Cannot continue operation." + " Calling exit(1).\n", (ulong)srv_thread_concurrency); exit(1); @@ -761,7 +771,7 @@ log_init(void) memset(log_sys->buf, '\0', LOG_BUFFER_SIZE); log_sys->max_buf_free = log_sys->buf_size / LOG_BUF_FLUSH_RATIO - - LOG_BUF_FLUSH_MARGIN; + - LOG_BUF_FLUSH_MARGIN; log_sys->check_flush_or_checkpoint = TRUE; UT_LIST_INIT(log_sys->log_groups); @@ -799,9 +809,9 @@ log_init(void) rw_lock_create(&log_sys->checkpoint_lock, SYNC_NO_ORDER_CHECK); - log_sys->checkpoint_buf = ut_align( - mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE), - OS_FILE_LOG_BLOCK_SIZE); + log_sys->checkpoint_buf + = ut_align(mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE), + OS_FILE_LOG_BLOCK_SIZE); memset(log_sys->checkpoint_buf, '\0', OS_FILE_LOG_BLOCK_SIZE); /*----------------------------*/ @@ -817,10 +827,10 @@ log_init(void) log_sys->archive_buf = NULL; - /* ut_align( - ut_malloc(LOG_ARCHIVE_BUF_SIZE - + OS_FILE_LOG_BLOCK_SIZE), - OS_FILE_LOG_BLOCK_SIZE); */ + /* ut_align( + ut_malloc(LOG_ARCHIVE_BUF_SIZE + + OS_FILE_LOG_BLOCK_SIZE), + OS_FILE_LOG_BLOCK_SIZE); */ log_sys->archive_buf_size = 0; /* memset(log_sys->archive_buf, '\0', LOG_ARCHIVE_BUF_SIZE); */ @@ -890,19 +900,19 @@ log_group_init( #endif /* UNIV_LOG_ARCHIVE */ for (i = 0; i < n_files; i++) { - *(group->file_header_bufs + i) = ut_align( - mem_alloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE), - OS_FILE_LOG_BLOCK_SIZE); + *(group->file_header_bufs + i) = ut_align + (mem_alloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE), + OS_FILE_LOG_BLOCK_SIZE); memset(*(group->file_header_bufs + i), '\0', - LOG_FILE_HDR_SIZE); + LOG_FILE_HDR_SIZE); #ifdef UNIV_LOG_ARCHIVE - *(group->archive_file_header_bufs + i) = ut_align( - mem_alloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE), - OS_FILE_LOG_BLOCK_SIZE); + *(group->archive_file_header_bufs + i) = ut_align + (mem_alloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE), + OS_FILE_LOG_BLOCK_SIZE); memset(*(group->archive_file_header_bufs + i), '\0', - LOG_FILE_HDR_SIZE); + LOG_FILE_HDR_SIZE); #endif /* UNIV_LOG_ARCHIVE */ } @@ -913,9 +923,9 @@ log_group_init( group->archived_offset = 0; #endif /* UNIV_LOG_ARCHIVE */ - group->checkpoint_buf = ut_align( - mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE), - OS_FILE_LOG_BLOCK_SIZE); + group->checkpoint_buf = ut_align + (mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE), + OS_FILE_LOG_BLOCK_SIZE); memset(group->checkpoint_buf, '\0', OS_FILE_LOG_BLOCK_SIZE); @@ -944,7 +954,7 @@ log_flush_do_unlocks( calling this function might be preempted for a while, and when it resumed execution, it might be that a new flush had been started, and this function would erroneously signal the NEW flush as completed. - Thus, the changes in the state of these events are performed + Thus, the changes in the state of these events are performed atomically in conjunction with the changes in the state of log_sys->n_pending_writes etc. */ @@ -975,7 +985,8 @@ log_group_check_flush_completion( #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, - "Log flushed first to group %lu\n", (ulong) group->id); + "Log flushed first to group %lu\n", + (ulong) group->id); } #endif /* UNIV_DEBUG */ log_sys->written_to_some_lsn = log_sys->write_lsn; @@ -987,7 +998,8 @@ log_group_check_flush_completion( #ifdef UNIV_DEBUG if (log_debug_writes && (group->n_pending_writes == 0)) { - fprintf(stderr, "Log flushed to group %lu\n", (ulong) group->id); + fprintf(stderr, "Log flushed to group %lu\n", + (ulong) group->id); } #endif /* UNIV_DEBUG */ return(0); @@ -1017,14 +1029,14 @@ log_sys_check_flush_completion(void) /* Move the log buffer content to the start of the buffer */ - move_start = ut_calc_align_down( - log_sys->write_end_offset, - OS_FILE_LOG_BLOCK_SIZE); + move_start = ut_calc_align_down + (log_sys->write_end_offset, + OS_FILE_LOG_BLOCK_SIZE); move_end = ut_calc_align(log_sys->buf_free, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); ut_memmove(log_sys->buf, log_sys->buf + move_start, - move_end - move_start); + move_end - move_start); log_sys->buf_free -= move_start; log_sys->buf_next_to_write -= move_start; @@ -1061,7 +1073,7 @@ log_io_complete( group = (log_group_t*)((ulint)group - 1); if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC - && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) { + && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) { fil_flush(group->space_id); } @@ -1082,8 +1094,8 @@ log_io_complete( logs and cannot end up here! */ if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC - && srv_unix_file_flush_method != SRV_UNIX_NOSYNC - && srv_flush_log_at_trx_commit != 2) { + && srv_unix_file_flush_method != SRV_UNIX_NOSYNC + && srv_flush_log_at_trx_commit != 2) { fil_flush(group->space_id); } @@ -1147,10 +1159,10 @@ log_group_file_header_flush( srv_os_log_pending_writes++; fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id, - dest_offset / UNIV_PAGE_SIZE, - dest_offset % UNIV_PAGE_SIZE, - OS_FILE_LOG_BLOCK_SIZE, - buf, group); + dest_offset / UNIV_PAGE_SIZE, + dest_offset % UNIV_PAGE_SIZE, + OS_FILE_LOG_BLOCK_SIZE, + buf, group); srv_os_log_pending_writes--; } @@ -1212,11 +1224,12 @@ loop: next_offset = log_group_calc_lsn_offset(start_lsn, group); if ((next_offset % group->file_size == LOG_FILE_HDR_SIZE) - && write_header) { + && write_header) { /* We start to write a new log file instance in the group */ log_group_file_header_flush(group, - next_offset / group->file_size, start_lsn); + next_offset / group->file_size, + start_lsn); srv_os_log_written+= OS_FILE_LOG_BLOCK_SIZE; srv_log_writes++; } @@ -1224,7 +1237,7 @@ loop: if ((next_offset % group->file_size) + len > group->file_size) { write_len = group->file_size - - (next_offset % group->file_size); + - (next_offset % group->file_size); } else { write_len = len; } @@ -1233,24 +1246,25 @@ loop: if (log_debug_writes) { fprintf(stderr, - "Writing log file segment to group %lu offset %lu len %lu\n" - "start lsn %lu %lu\n" - "First block n:o %lu last block n:o %lu\n", + "Writing log file segment to group %lu" + " offset %lu len %lu\n" + "start lsn %lu %lu\n" + "First block n:o %lu last block n:o %lu\n", (ulong) group->id, (ulong) next_offset, (ulong) write_len, (ulong) ut_dulint_get_high(start_lsn), (ulong) ut_dulint_get_low(start_lsn), (ulong) log_block_get_hdr_no(buf), - (ulong) log_block_get_hdr_no( - buf + write_len - OS_FILE_LOG_BLOCK_SIZE)); + (ulong) log_block_get_hdr_no + (buf + write_len - OS_FILE_LOG_BLOCK_SIZE)); ut_a(log_block_get_hdr_no(buf) - == log_block_convert_lsn_to_no(start_lsn)); + == log_block_convert_lsn_to_no(start_lsn)); for (i = 0; i < write_len / OS_FILE_LOG_BLOCK_SIZE; i++) { ut_a(log_block_get_hdr_no(buf) + i - == log_block_get_hdr_no(buf - + i * OS_FILE_LOG_BLOCK_SIZE)); + == log_block_get_hdr_no + (buf + i * OS_FILE_LOG_BLOCK_SIZE)); } } #endif /* UNIV_DEBUG */ @@ -1267,8 +1281,8 @@ loop: srv_os_log_pending_writes++; fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id, - next_offset / UNIV_PAGE_SIZE, - next_offset % UNIV_PAGE_SIZE, write_len, buf, group); + next_offset / UNIV_PAGE_SIZE, + next_offset % UNIV_PAGE_SIZE, write_len, buf, group); srv_os_log_pending_writes--; @@ -1309,7 +1323,9 @@ log_write_up_to( ulint end_offset; ulint area_start; ulint area_end; - ulint loop_count; +#ifdef UNIV_DEBUG + ulint loop_count = 0; +#endif /* UNIV_DEBUG */ ulint unlock; if (recv_no_ibuf_operations) { @@ -1319,20 +1335,23 @@ log_write_up_to( return; } - loop_count = 0; loop: +#ifdef UNIV_DEBUG loop_count++; ut_ad(loop_count < 5); +# if 0 if (loop_count > 2) { -/* fprintf(stderr, "Log loop count %lu\n", loop_count); */ + fprintf(stderr, "Log loop count %lu\n", loop_count); } +# endif +#endif mutex_enter(&(log_sys->mutex)); if (flush_to_disk - && ut_dulint_cmp(log_sys->flushed_to_disk_lsn, lsn) >= 0) { + && ut_dulint_cmp(log_sys->flushed_to_disk_lsn, lsn) >= 0) { mutex_exit(&(log_sys->mutex)); @@ -1340,10 +1359,10 @@ loop: } if (!flush_to_disk - && (ut_dulint_cmp(log_sys->written_to_all_lsn, lsn) >= 0 - || (ut_dulint_cmp(log_sys->written_to_some_lsn, lsn) - >= 0 - && wait != LOG_WAIT_ALL_GROUPS))) { + && (ut_dulint_cmp(log_sys->written_to_all_lsn, lsn) >= 0 + || (ut_dulint_cmp(log_sys->written_to_some_lsn, lsn) + >= 0 + && wait != LOG_WAIT_ALL_GROUPS))) { mutex_exit(&(log_sys->mutex)); @@ -1354,8 +1373,8 @@ loop: /* A write (+ possibly flush to disk) is running */ if (flush_to_disk - && ut_dulint_cmp(log_sys->current_flush_lsn, lsn) - >= 0) { + && ut_dulint_cmp(log_sys->current_flush_lsn, lsn) + >= 0) { /* The write + flush will write enough: wait for it to complete */ @@ -1363,7 +1382,7 @@ loop: } if (!flush_to_disk - && ut_dulint_cmp(log_sys->write_lsn, lsn) >= 0) { + && ut_dulint_cmp(log_sys->write_lsn, lsn) >= 0) { /* The write will write enough: wait for it to complete */ @@ -1381,7 +1400,7 @@ loop: } if (!flush_to_disk - && log_sys->buf_free == log_sys->buf_next_to_write) { + && log_sys->buf_free == log_sys->buf_next_to_write) { /* Nothing to write and no flush to disk requested */ mutex_exit(&(log_sys->mutex)); @@ -1393,8 +1412,10 @@ loop: if (log_debug_writes) { fprintf(stderr, "Writing log from %lu %lu up to lsn %lu %lu\n", - (ulong) ut_dulint_get_high(log_sys->written_to_all_lsn), - (ulong) ut_dulint_get_low(log_sys->written_to_all_lsn), + (ulong) ut_dulint_get_high + (log_sys->written_to_all_lsn), + (ulong) ut_dulint_get_low + (log_sys->written_to_all_lsn), (ulong) ut_dulint_get_high(log_sys->lsn), (ulong) ut_dulint_get_low(log_sys->lsn)); } @@ -1425,17 +1446,17 @@ loop: log_sys->one_flushed = FALSE; log_block_set_flush_bit(log_sys->buf + area_start, TRUE); - log_block_set_checkpoint_no( - log_sys->buf + area_end - OS_FILE_LOG_BLOCK_SIZE, - log_sys->next_checkpoint_no); + log_block_set_checkpoint_no + (log_sys->buf + area_end - OS_FILE_LOG_BLOCK_SIZE, + log_sys->next_checkpoint_no); /* Copy the last, incompletely written, log block a log block length up, so that when the flush operation writes from the log buffer, the segment to write will not be changed by writers to the log */ ut_memcpy(log_sys->buf + area_end, - log_sys->buf + area_end - OS_FILE_LOG_BLOCK_SIZE, - OS_FILE_LOG_BLOCK_SIZE); + log_sys->buf + area_end - OS_FILE_LOG_BLOCK_SIZE, + OS_FILE_LOG_BLOCK_SIZE); log_sys->buf_free += OS_FILE_LOG_BLOCK_SIZE; log_sys->write_end_offset = log_sys->buf_free; @@ -1445,12 +1466,12 @@ loop: /* Do the write to the log files */ while (group) { - log_group_write_buf(group, - log_sys->buf + area_start, - area_end - area_start, - ut_dulint_align_down(log_sys->written_to_all_lsn, - OS_FILE_LOG_BLOCK_SIZE), - start_offset - area_start); + log_group_write_buf + (group, log_sys->buf + area_start, + area_end - area_start, + ut_dulint_align_down(log_sys->written_to_all_lsn, + OS_FILE_LOG_BLOCK_SIZE), + start_offset - area_start); log_group_set_fields(group, log_sys->write_lsn); @@ -1612,7 +1633,7 @@ log_complete_checkpoint(void) ut_ad(log_sys->n_pending_checkpoint_writes == 0); log_sys->next_checkpoint_no - = ut_dulint_add(log_sys->next_checkpoint_no, 1); + = ut_dulint_add(log_sys->next_checkpoint_no, 1); log_sys->last_checkpoint_lsn = log_sys->next_checkpoint_lsn; @@ -1672,9 +1693,9 @@ log_checkpoint_get_nth_group_info( ut_ad(n < LOG_MAX_N_GROUPS); *file_no = mach_read_from_4(buf + LOG_CHECKPOINT_GROUP_ARRAY - + 8 * n + LOG_CHECKPOINT_ARCHIVED_FILE_NO); + + 8 * n + LOG_CHECKPOINT_ARCHIVED_FILE_NO); *offset = mach_read_from_4(buf + LOG_CHECKPOINT_GROUP_ARRAY - + 8 * n + LOG_CHECKPOINT_ARCHIVED_OFFSET); + + 8 * n + LOG_CHECKPOINT_ARCHIVED_OFFSET); } /********************************************************** @@ -1706,11 +1727,11 @@ log_group_checkpoint( mach_write_to_8(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no); mach_write_to_8(buf + LOG_CHECKPOINT_LSN, - log_sys->next_checkpoint_lsn); + log_sys->next_checkpoint_lsn); mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET, - log_group_calc_lsn_offset( - log_sys->next_checkpoint_lsn, group)); + log_group_calc_lsn_offset + (log_sys->next_checkpoint_lsn, group)); mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, log_sys->buf_size); @@ -1721,7 +1742,7 @@ log_group_checkpoint( archived_lsn = log_sys->archived_lsn; if (0 != ut_dulint_cmp(archived_lsn, - log_sys->next_archived_lsn)) { + log_sys->next_archived_lsn)) { next_archived_lsn = log_sys->next_archived_lsn; /* For debugging only */ } @@ -1741,12 +1762,12 @@ log_group_checkpoint( while (group2) { log_checkpoint_set_nth_group_info(buf, group2->id, #ifdef UNIV_LOG_ARCHIVE - group2->archived_file_no, - group2->archived_offset + group2->archived_file_no, + group2->archived_offset #else /* UNIV_LOG_ARCHIVE */ - 0, 0 + 0, 0 #endif /* UNIV_LOG_ARCHIVE */ - ); + ); group2 = UT_LIST_GET_NEXT(log_groups, group2); } @@ -1755,17 +1776,17 @@ log_group_checkpoint( mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_1, fold); fold = ut_fold_binary(buf + LOG_CHECKPOINT_LSN, - LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN); + LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN); mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_2, fold); /* Starting from InnoDB-3.23.50, we also write info on allocated size in the tablespace */ mach_write_to_4(buf + LOG_CHECKPOINT_FSP_FREE_LIMIT, - log_fsp_current_free_limit); + log_fsp_current_free_limit); mach_write_to_4(buf + LOG_CHECKPOINT_FSP_MAGIC_N, - LOG_CHECKPOINT_FSP_MAGIC_N_VAL); + LOG_CHECKPOINT_FSP_MAGIC_N_VAL); /* We alternate the physical place of the checkpoint info in the first log file */ @@ -1780,7 +1801,7 @@ log_group_checkpoint( if (log_sys->n_pending_checkpoint_writes == 0) { rw_lock_x_lock_gen(&(log_sys->checkpoint_lock), - LOG_CHECKPOINT); + LOG_CHECKPOINT); } log_sys->n_pending_checkpoint_writes++; @@ -1792,10 +1813,10 @@ log_group_checkpoint( file write and a checkpoint field write */ fil_io(OS_FILE_WRITE | OS_FILE_LOG, FALSE, group->space_id, - write_offset / UNIV_PAGE_SIZE, - write_offset % UNIV_PAGE_SIZE, - OS_FILE_LOG_BLOCK_SIZE, - buf, ((byte*)group + 1)); + write_offset / UNIV_PAGE_SIZE, + write_offset % UNIV_PAGE_SIZE, + OS_FILE_LOG_BLOCK_SIZE, + buf, ((byte*)group + 1)); ut_ad(((ulint)group & 0x1UL) == 0); } @@ -1825,17 +1846,17 @@ log_reset_first_header_and_checkpoint( /* Write the label of ibbackup --restore */ strcpy((char*) hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, - "ibbackup "); - ut_sprintf_timestamp( - (char*) hdr_buf + (LOG_FILE_WAS_CREATED_BY_HOT_BACKUP - + (sizeof "ibbackup ") - 1)); + "ibbackup "); + ut_sprintf_timestamp((char*) hdr_buf + + (LOG_FILE_WAS_CREATED_BY_HOT_BACKUP + + (sizeof "ibbackup ") - 1)); buf = hdr_buf + LOG_CHECKPOINT_1; mach_write_to_8(buf + LOG_CHECKPOINT_NO, ut_dulint_zero); mach_write_to_8(buf + LOG_CHECKPOINT_LSN, lsn); mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET, - LOG_FILE_HDR_SIZE + LOG_BLOCK_HDR_SIZE); + LOG_FILE_HDR_SIZE + LOG_BLOCK_HDR_SIZE); mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, 2 * 1024 * 1024); @@ -1845,7 +1866,7 @@ log_reset_first_header_and_checkpoint( mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_1, fold); fold = ut_fold_binary(buf + LOG_CHECKPOINT_LSN, - LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN); + LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN); mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_2, fold); /* Starting from InnoDB-3.23.50, we should also write info on @@ -1869,8 +1890,8 @@ log_group_read_checkpoint_info( log_sys->n_log_ios++; fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, group->space_id, - field / UNIV_PAGE_SIZE, field % UNIV_PAGE_SIZE, - OS_FILE_LOG_BLOCK_SIZE, log_sys->checkpoint_buf, NULL); + field / UNIV_PAGE_SIZE, field % UNIV_PAGE_SIZE, + OS_FILE_LOG_BLOCK_SIZE, log_sys->checkpoint_buf, NULL); } /********************************************************** @@ -1943,8 +1964,8 @@ log_checkpoint( mutex_enter(&(log_sys->mutex)); - if (!write_always && ut_dulint_cmp( - log_sys->last_checkpoint_lsn, oldest_lsn) >= 0) { + if (!write_always + && ut_dulint_cmp(log_sys->last_checkpoint_lsn, oldest_lsn) >= 0) { mutex_exit(&(log_sys->mutex)); @@ -2173,8 +2194,8 @@ loop: log_sys->n_log_ios++; fil_io(OS_FILE_READ | OS_FILE_LOG, sync, group->space_id, - source_offset / UNIV_PAGE_SIZE, source_offset % UNIV_PAGE_SIZE, - len, buf, NULL); + source_offset / UNIV_PAGE_SIZE, source_offset % UNIV_PAGE_SIZE, + len, buf, NULL); start_lsn = ut_dulint_add(start_lsn, len); buf += len; @@ -2236,10 +2257,10 @@ log_group_archive_file_header_write( log_sys->n_log_ios++; fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->archive_space_id, - dest_offset / UNIV_PAGE_SIZE, - dest_offset % UNIV_PAGE_SIZE, - 2 * OS_FILE_LOG_BLOCK_SIZE, - buf, &log_archive_io); + dest_offset / UNIV_PAGE_SIZE, + dest_offset % UNIV_PAGE_SIZE, + 2 * OS_FILE_LOG_BLOCK_SIZE, + buf, &log_archive_io); } /********************************************************** @@ -2271,11 +2292,11 @@ log_group_archive_completed_header_write( log_sys->n_log_ios++; fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->archive_space_id, - dest_offset / UNIV_PAGE_SIZE, - dest_offset % UNIV_PAGE_SIZE, - OS_FILE_LOG_BLOCK_SIZE, - buf + LOG_FILE_ARCH_COMPLETED, - &log_archive_io); + dest_offset / UNIV_PAGE_SIZE, + dest_offset % UNIV_PAGE_SIZE, + OS_FILE_LOG_BLOCK_SIZE, + buf + LOG_FILE_ARCH_COMPLETED, + &log_archive_io); } /********************************************************** @@ -2316,7 +2337,7 @@ log_group_archive( next_offset = group->archived_offset; loop: if ((next_offset % group->file_size == 0) - || (fil_space_get_size(group->archive_space_id) == 0)) { + || (fil_space_get_size(group->archive_space_id) == 0)) { /* Add the file to the archive file space; create or open the file */ @@ -2328,23 +2349,26 @@ loop: } log_archived_file_name_gen(name, group->id, - group->archived_file_no + n_files); + group->archived_file_no + n_files); file_handle = os_file_create(name, open_mode, OS_FILE_AIO, - OS_DATA_FILE, &ret); + OS_DATA_FILE, &ret); if (!ret && (open_mode == OS_FILE_CREATE)) { - file_handle = os_file_create(name, OS_FILE_OPEN, - OS_FILE_AIO, OS_DATA_FILE, &ret); + file_handle = os_file_create + (name, OS_FILE_OPEN, OS_FILE_AIO, + OS_DATA_FILE, &ret); } if (!ret) { fprintf(stderr, - "InnoDB: Cannot create or open archive log file %s.\n" - "InnoDB: Cannot continue operation.\n" - "InnoDB: Check that the log archive directory exists,\n" - "InnoDB: you have access rights to it, and\n" - "InnoDB: there is space available.\n", name); + "InnoDB: Cannot create or open" + " archive log file %s.\n" + "InnoDB: Cannot continue operation.\n" + "InnoDB: Check that the log archive" + " directory exists,\n" + "InnoDB: you have access rights to it, and\n" + "InnoDB: there is space available.\n", name); exit(1); } @@ -2361,12 +2385,13 @@ loop: /* Add the archive file as a node to the space */ fil_node_create(name, group->file_size / UNIV_PAGE_SIZE, - group->archive_space_id, FALSE); + group->archive_space_id, FALSE); if (next_offset % group->file_size == 0) { - log_group_archive_file_header_write(group, n_files, - group->archived_file_no + n_files, - start_lsn); + log_group_archive_file_header_write + (group, n_files, + group->archived_file_no + n_files, + start_lsn); next_offset += LOG_FILE_HDR_SIZE; } @@ -2382,10 +2407,11 @@ loop: #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, - "Archiving starting at lsn %lu %lu, len %lu to group %lu\n", - (ulong) ut_dulint_get_high(start_lsn), - (ulong) ut_dulint_get_low(start_lsn), - (ulong) len, (ulong) group->id); + "Archiving starting at lsn %lu %lu, len %lu" + " to group %lu\n", + (ulong) ut_dulint_get_high(start_lsn), + (ulong) ut_dulint_get_low(start_lsn), + (ulong) len, (ulong) group->id); } #endif /* UNIV_DEBUG */ @@ -2394,9 +2420,9 @@ loop: log_sys->n_log_ios++; fil_io(OS_FILE_WRITE | OS_FILE_LOG, FALSE, group->archive_space_id, - next_offset / UNIV_PAGE_SIZE, next_offset % UNIV_PAGE_SIZE, - ut_calc_align(len, OS_FILE_LOG_BLOCK_SIZE), buf, - &log_archive_io); + next_offset / UNIV_PAGE_SIZE, next_offset % UNIV_PAGE_SIZE, + ut_calc_align(len, OS_FILE_LOG_BLOCK_SIZE), buf, + &log_archive_io); start_lsn = ut_dulint_add(start_lsn, len); next_offset += len; @@ -2465,7 +2491,7 @@ log_archive_write_complete_groups(void) file, or if it has been written full, all files */ n_files = (UNIV_PAGE_SIZE - * fil_space_get_size(group->archive_space_id)) + * fil_space_get_size(group->archive_space_id)) / group->file_size; ut_ad(n_files > 0); @@ -2482,15 +2508,15 @@ log_archive_write_complete_groups(void) if (log_debug_writes && trunc_files) { fprintf(stderr, "Complete file(s) archived to group %lu\n", - (ulong) group->id); + (ulong) group->id); } #endif /* UNIV_DEBUG */ /* Calculate the archive file space start lsn */ - start_lsn = ut_dulint_subtract(log_sys->next_archived_lsn, - end_offset - LOG_FILE_HDR_SIZE - + trunc_files - * (group->file_size - LOG_FILE_HDR_SIZE)); + start_lsn = ut_dulint_subtract + (log_sys->next_archived_lsn, + end_offset - LOG_FILE_HDR_SIZE + trunc_files + * (group->file_size - LOG_FILE_HDR_SIZE)); end_lsn = start_lsn; for (i = 0; i < trunc_files; i++) { @@ -2505,7 +2531,7 @@ log_archive_write_complete_groups(void) } fil_space_truncate_start(group->archive_space_id, - trunc_files * group->file_size); + trunc_files * group->file_size); #ifdef UNIV_DEBUG if (log_debug_writes) { @@ -2526,7 +2552,7 @@ log_archive_check_completion_low(void) #endif /* UNIV_SYNC_DEBUG */ if (log_sys->n_pending_archive_ios == 0 - && log_sys->archiving_phase == LOG_ARCHIVE_READ) { + && log_sys->archiving_phase == LOG_ARCHIVE_READ) { #ifdef UNIV_DEBUG if (log_debug_writes) { @@ -2542,7 +2568,7 @@ log_archive_check_completion_low(void) } if (log_sys->n_pending_archive_ios == 0 - && log_sys->archiving_phase == LOG_ARCHIVE_WRITE) { + && log_sys->archiving_phase == LOG_ARCHIVE_WRITE) { log_archive_write_complete_groups(); @@ -2624,14 +2650,14 @@ loop: if (calc_new_limit) { ut_a(log_sys->archive_buf_size % OS_FILE_LOG_BLOCK_SIZE == 0); limit_lsn = ut_dulint_add(start_lsn, - log_sys->archive_buf_size); + log_sys->archive_buf_size); *n_bytes = log_sys->archive_buf_size; if (ut_dulint_cmp(limit_lsn, log_sys->lsn) >= 0) { - limit_lsn = ut_dulint_align_down(log_sys->lsn, - OS_FILE_LOG_BLOCK_SIZE); + limit_lsn = ut_dulint_align_down + (log_sys->lsn, OS_FILE_LOG_BLOCK_SIZE); } } @@ -2690,8 +2716,8 @@ loop: /* Read the log segment to the archive buffer */ log_group_read_log_seg(LOG_ARCHIVE, log_sys->archive_buf, - UT_LIST_GET_FIRST(log_sys->log_groups), - start_lsn, limit_lsn); + UT_LIST_GET_FIRST(log_sys->log_groups), + start_lsn, limit_lsn); mutex_exit(&(log_sys->mutex)); @@ -2778,11 +2804,11 @@ log_archive_close_groups( /* Write a notice to the headers of archived log files that the file write has been completed */ - log_group_archive_completed_header_write(group, - 0, log_sys->archived_lsn); + log_group_archive_completed_header_write + (group, 0, log_sys->archived_lsn); fil_space_truncate_start(group->archive_space_id, - trunc_len); + trunc_len); if (increment_file_count) { group->archived_offset = 0; group->archived_file_no += 2; @@ -2791,7 +2817,8 @@ log_archive_close_groups( #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, - "Incrementing arch file no to %lu in log group %lu\n", + "Incrementing arch file no to %lu" + " in log group %lu\n", (ulong) group->archived_file_no + 2, (ulong) group->id); } @@ -2904,7 +2931,7 @@ loop: mutex_enter(&(log_sys->mutex)); if (log_sys->archiving_state == LOG_ARCH_STOPPED - || log_sys->archiving_state == LOG_ARCH_OFF) { + || log_sys->archiving_state == LOG_ARCH_OFF) { log_sys->archiving_state = LOG_ARCH_OFF; @@ -2938,8 +2965,9 @@ log_archive_archivelog(void) log_sys->archiving_state = LOG_ARCH_ON; - log_sys->archived_lsn = ut_dulint_align_down(log_sys->lsn, - OS_FILE_LOG_BLOCK_SIZE); + log_sys->archived_lsn + = ut_dulint_align_down(log_sys->lsn, + OS_FILE_LOG_BLOCK_SIZE); mutex_exit(&(log_sys->mutex)); return(DB_SUCCESS); @@ -3068,7 +3096,7 @@ loop: them. */ if (trx_n_mysql_transactions > 0 - || UT_LIST_GET_LEN(trx_sys->trx_list) > 0) { + || UT_LIST_GET_LEN(trx_sys->trx_list) > 0) { mutex_exit(&kernel_mutex); @@ -3102,12 +3130,11 @@ loop: mutex_enter(&(log_sys->mutex)); - if ( + if (log_sys->n_pending_checkpoint_writes #ifdef UNIV_LOG_ARCHIVE - log_sys->n_pending_archive_ios || + || log_sys->n_pending_archive_ios #endif /* UNIV_LOG_ARCHIVE */ - log_sys->n_pending_checkpoint_writes || - log_sys->n_pending_writes) { + || log_sys->n_pending_writes) { mutex_exit(&(log_sys->mutex)); @@ -3125,7 +3152,7 @@ loop: log_archive_all(); #endif /* UNIV_LOG_ARCHIVE */ - log_make_checkpoint_at(ut_dulint_max, TRUE); + log_make_checkpoint_at(ut_dulint_max, TRUE); mutex_enter(&(log_sys->mutex)); @@ -3133,13 +3160,13 @@ loop: if ((ut_dulint_cmp(lsn, log_sys->last_checkpoint_lsn) != 0) #ifdef UNIV_LOG_ARCHIVE - || (srv_log_archive_on - && ut_dulint_cmp(lsn, - ut_dulint_add(log_sys->archived_lsn, - LOG_BLOCK_HDR_SIZE)) - != 0) + || (srv_log_archive_on + && ut_dulint_cmp(lsn, + ut_dulint_add(log_sys->archived_lsn, + LOG_BLOCK_HDR_SIZE)) + != 0) #endif /* UNIV_LOG_ARCHIVE */ - ) { + ) { mutex_exit(&(log_sys->mutex)); @@ -3165,7 +3192,8 @@ loop: /* Check that the master thread has stayed suspended */ if (srv_n_threads_active[SRV_MASTER] != 0) { fprintf(stderr, -"InnoDB: Warning: the master thread woke up during shutdown\n"); + "InnoDB: Warning: the master thread woke up" + " during shutdown\n"); mutex_exit(&kernel_mutex); @@ -3209,17 +3237,18 @@ loop: if (ut_dulint_cmp(lsn, srv_start_lsn) < 0) { fprintf(stderr, -"InnoDB: Error: log sequence number at shutdown %lu %lu\n" -"InnoDB: is lower than at startup %lu %lu!\n", - (ulong) ut_dulint_get_high(lsn), - (ulong) ut_dulint_get_low(lsn), - (ulong) ut_dulint_get_high(srv_start_lsn), - (ulong) ut_dulint_get_low(srv_start_lsn)); + "InnoDB: Error: log sequence number" + " at shutdown %lu %lu\n" + "InnoDB: is lower than at startup %lu %lu!\n", + (ulong) ut_dulint_get_high(lsn), + (ulong) ut_dulint_get_low(lsn), + (ulong) ut_dulint_get_high(srv_start_lsn), + (ulong) ut_dulint_get_low(srv_start_lsn)); } srv_shutdown_lsn = lsn; - fil_write_flushed_lsn_to_data_files(lsn, arch_log_no); + fil_write_flushed_lsn_to_data_files(lsn, arch_log_no); fil_flush_file_spaces(FIL_TABLESPACE); @@ -3268,15 +3297,15 @@ log_check_log_recs( ut_memcpy(scan_buf, start, end - start); recv_scan_log_recs(TRUE, - (buf_pool->n_frames - - recv_n_pool_free_frames) * UNIV_PAGE_SIZE, - FALSE, scan_buf, end - start, - ut_dulint_align_down(buf_start_lsn, + (buf_pool->n_frames + - recv_n_pool_free_frames) * UNIV_PAGE_SIZE, + FALSE, scan_buf, end - start, + ut_dulint_align_down(buf_start_lsn, OS_FILE_LOG_BLOCK_SIZE), - &contiguous_lsn, &scanned_lsn); + &contiguous_lsn, &scanned_lsn); ut_a(ut_dulint_cmp(scanned_lsn, ut_dulint_add(buf_start_lsn, len)) - == 0); + == 0); ut_a(ut_dulint_cmp(recv_sys->recovered_lsn, scanned_lsn) == 0); mem_free(buf1); @@ -3322,24 +3351,25 @@ log_print( "Log sequence number %lu %lu\n" "Log flushed up to %lu %lu\n" "Last checkpoint at %lu %lu\n", - (ulong) ut_dulint_get_high(log_sys->lsn), - (ulong) ut_dulint_get_low(log_sys->lsn), - (ulong) ut_dulint_get_high(log_sys->flushed_to_disk_lsn), - (ulong) ut_dulint_get_low(log_sys->flushed_to_disk_lsn), - (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn), - (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn)); + (ulong) ut_dulint_get_high(log_sys->lsn), + (ulong) ut_dulint_get_low(log_sys->lsn), + (ulong) ut_dulint_get_high(log_sys->flushed_to_disk_lsn), + (ulong) ut_dulint_get_low(log_sys->flushed_to_disk_lsn), + (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn), + (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn)); current_time = time(NULL); time_elapsed = 0.001 + difftime(current_time, log_sys->last_printout_time); fprintf(file, - "%lu pending log writes, %lu pending chkp writes\n" - "%lu log i/o's done, %.2f log i/o's/second\n", - (ulong) log_sys->n_pending_writes, - (ulong) log_sys->n_pending_checkpoint_writes, - (ulong) log_sys->n_log_ios, - ((log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed)); + "%lu pending log writes, %lu pending chkp writes\n" + "%lu log i/o's done, %.2f log i/o's/second\n", + (ulong) log_sys->n_pending_writes, + (ulong) log_sys->n_pending_checkpoint_writes, + (ulong) log_sys->n_log_ios, + ((log_sys->n_log_ios - log_sys->n_log_ios_old) + / time_elapsed)); log_sys->n_log_ios_old = log_sys->n_log_ios; log_sys->last_printout_time = current_time; diff --git a/storage/innobase/log/log0recv.c b/storage/innobase/log/log0recv.c index 8150dba165c..3a53e0eb6e5 100644 --- a/storage/innobase/log/log0recv.c +++ b/storage/innobase/log/log0recv.c @@ -155,7 +155,7 @@ recv_sys_init( recv_sys->last_block_buf_start = mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE); recv_sys->last_block = ut_align(recv_sys->last_block_buf_start, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); recv_sys->found_corrupt_log = FALSE; recv_max_page_lsn = ut_dulint_zero; @@ -175,8 +175,10 @@ recv_sys_empty_hash(void) #endif /* UNIV_SYNC_DEBUG */ if (recv_sys->n_addrs != 0) { fprintf(stderr, -"InnoDB: Error: %lu pages with log records were left unprocessed!\n" -"InnoDB: Maximum page number with log records on it %lu\n", + "InnoDB: Error: %lu pages with log records" + " were left unprocessed!\n" + "InnoDB: Maximum page number with" + " log records on it %lu\n", (ulong) recv_sys->n_addrs, (ulong) recv_max_parsed_page_no); ut_error; @@ -237,13 +239,13 @@ recv_truncate_group( archived_lsn = checkpoint_lsn; } - finish_lsn1 = ut_dulint_add(ut_dulint_align_down(archived_lsn, - OS_FILE_LOG_BLOCK_SIZE), - log_group_get_capacity(group)); + finish_lsn1 = ut_dulint_add(ut_dulint_align_down + (archived_lsn, OS_FILE_LOG_BLOCK_SIZE), + log_group_get_capacity(group)); - finish_lsn2 = ut_dulint_add(ut_dulint_align_up(recovered_lsn, - OS_FILE_LOG_BLOCK_SIZE), - recv_sys->last_log_buf_size); + finish_lsn2 = ut_dulint_add(ut_dulint_align_up + (recovered_lsn, OS_FILE_LOG_BLOCK_SIZE), + recv_sys->last_log_buf_size); if (ut_dulint_cmp(limit_lsn, ut_dulint_max) != 0) { /* We do not know how far we should erase log records: erase @@ -264,16 +266,16 @@ recv_truncate_group( } start_lsn = ut_dulint_align_down(recovered_lsn, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); if (ut_dulint_cmp(start_lsn, recovered_lsn) != 0) { /* Copy the last incomplete log block to the log buffer and edit its data length: */ ut_memcpy(log_sys->buf, recv_sys->last_block, - OS_FILE_LOG_BLOCK_SIZE); - log_block_set_data_len(log_sys->buf, - ut_dulint_minus(recovered_lsn, start_lsn)); + OS_FILE_LOG_BLOCK_SIZE); + log_block_set_data_len(log_sys->buf, ut_dulint_minus + (recovered_lsn, start_lsn)); } if (ut_dulint_cmp(start_lsn, finish_lsn) >= 0) { @@ -333,17 +335,17 @@ recv_copy_group( ut_a(RECV_SCAN_SIZE <= log_sys->buf_size); start_lsn = ut_dulint_align_down(group->scanned_lsn, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); for (;;) { end_lsn = ut_dulint_add(start_lsn, RECV_SCAN_SIZE); if (ut_dulint_cmp(end_lsn, recovered_lsn) > 0) { end_lsn = ut_dulint_align_up(recovered_lsn, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); } log_group_read_log_seg(LOG_RECOVER, log_sys->buf, - up_to_date_group, start_lsn, end_lsn); + up_to_date_group, start_lsn, end_lsn); len = ut_dulint_minus(end_lsn, start_lsn); @@ -383,13 +385,13 @@ recv_synchronize_groups( the block is always incomplete */ start_lsn = ut_dulint_align_down(recovered_lsn, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); end_lsn = ut_dulint_align_up(recovered_lsn, OS_FILE_LOG_BLOCK_SIZE); ut_a(ut_dulint_cmp(start_lsn, end_lsn) != 0); log_group_read_log_seg(LOG_RECOVER, recv_sys->last_block, - up_to_date_group, start_lsn, end_lsn); + up_to_date_group, start_lsn, end_lsn); group = UT_LIST_GET_FIRST(log_sys->log_groups); @@ -399,7 +401,7 @@ recv_synchronize_groups( /* Copy log data if needed */ recv_copy_group(group, up_to_date_group, - recovered_lsn); + recovered_lsn); } /* Update the fields in the group struct to correspond to @@ -439,16 +441,16 @@ recv_check_cp_is_consistent( fold = ut_fold_binary(buf, LOG_CHECKPOINT_CHECKSUM_1); - if ((fold & 0xFFFFFFFFUL) != mach_read_from_4(buf - + LOG_CHECKPOINT_CHECKSUM_1)) { + if ((fold & 0xFFFFFFFFUL) != mach_read_from_4 + (buf + LOG_CHECKPOINT_CHECKSUM_1)) { return(FALSE); } fold = ut_fold_binary(buf + LOG_CHECKPOINT_LSN, - LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN); + LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN); - if ((fold & 0xFFFFFFFFUL) != mach_read_from_4(buf - + LOG_CHECKPOINT_CHECKSUM_2)) { + if ((fold & 0xFFFFFFFFUL) != mach_read_from_4 + (buf + LOG_CHECKPOINT_CHECKSUM_2)) { return(FALSE); } @@ -484,7 +486,7 @@ recv_find_max_checkpoint( group->state = LOG_GROUP_CORRUPTED; for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2; - field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) { + field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) { log_group_read_checkpoint_info(group, field); @@ -492,11 +494,13 @@ recv_find_max_checkpoint( #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, - "InnoDB: Checkpoint in group %lu at %lu invalid, %lu\n", - (ulong) group->id, - (ulong) field, - (ulong) mach_read_from_4(buf - + LOG_CHECKPOINT_CHECKSUM_1)); + "InnoDB: Checkpoint in group" + " %lu at %lu invalid, %lu\n", + (ulong) group->id, + (ulong) field, + (ulong) mach_read_from_4 + (buf + + LOG_CHECKPOINT_CHECKSUM_1)); } #endif /* UNIV_DEBUG */ @@ -505,19 +509,21 @@ recv_find_max_checkpoint( group->state = LOG_GROUP_OK; - group->lsn = mach_read_from_8(buf - + LOG_CHECKPOINT_LSN); - group->lsn_offset = mach_read_from_4(buf - + LOG_CHECKPOINT_OFFSET); - checkpoint_no = - mach_read_from_8(buf + LOG_CHECKPOINT_NO); + group->lsn = mach_read_from_8 + (buf + LOG_CHECKPOINT_LSN); + group->lsn_offset = mach_read_from_4 + (buf + LOG_CHECKPOINT_OFFSET); + checkpoint_no = mach_read_from_8 + (buf + LOG_CHECKPOINT_NO); #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, - "InnoDB: Checkpoint number %lu found in group %lu\n", - (ulong) ut_dulint_get_low(checkpoint_no), - (ulong) group->id); + "InnoDB: Checkpoint number %lu" + " found in group %lu\n", + (ulong) ut_dulint_get_low + (checkpoint_no), + (ulong) group->id); } #endif /* UNIV_DEBUG */ @@ -527,7 +533,7 @@ recv_find_max_checkpoint( max_no = checkpoint_no; } - not_consistent: +not_consistent: ; } @@ -537,12 +543,16 @@ recv_find_max_checkpoint( if (*max_group == NULL) { fprintf(stderr, -"InnoDB: No valid checkpoint found.\n" -"InnoDB: If this error appears when you are creating an InnoDB database,\n" -"InnoDB: the problem may be that during an earlier attempt you managed\n" -"InnoDB: to create the InnoDB data files, but log file creation failed.\n" -"InnoDB: If that is the case, please refer to\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/error-creating-innodb.html\n"); + "InnoDB: No valid checkpoint found.\n" + "InnoDB: If this error appears when you are" + " creating an InnoDB database,\n" + "InnoDB: the problem may be that during" + " an earlier attempt you managed\n" + "InnoDB: to create the InnoDB data files," + " but log file creation failed.\n" + "InnoDB: If that is the case, please refer to\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "error-creating-innodb.html\n"); return(DB_ERROR); } @@ -580,7 +590,7 @@ recv_read_cp_info_for_backup( if (recv_check_cp_is_consistent(cp_buf)) { if (ut_dulint_cmp(mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO), - max_cp_no) > 0) { + max_cp_no) > 0) { max_cp = LOG_CHECKPOINT_2; } } @@ -597,10 +607,10 @@ recv_read_cp_info_for_backup( /* If the user is running a pre-3.23.50 version of InnoDB, its checkpoint data does not contain the fsp limit info */ if (mach_read_from_4(cp_buf + LOG_CHECKPOINT_FSP_MAGIC_N) - == LOG_CHECKPOINT_FSP_MAGIC_N_VAL) { + == LOG_CHECKPOINT_FSP_MAGIC_N_VAL) { - *fsp_limit = mach_read_from_4( - cp_buf + LOG_CHECKPOINT_FSP_FREE_LIMIT); + *fsp_limit = mach_read_from_4 + (cp_buf + LOG_CHECKPOINT_FSP_FREE_LIMIT); if (*fsp_limit == 0) { *fsp_limit = 1000000000; @@ -609,7 +619,7 @@ recv_read_cp_info_for_backup( *fsp_limit = 1000000000; } -/* fprintf(stderr, "fsp limit %lu MB\n", *fsp_limit); */ + /* fprintf(stderr, "fsp limit %lu MB\n", *fsp_limit); */ *cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO); @@ -642,11 +652,12 @@ log_block_checksum_is_ok_or_old_format( /* We assume the log block is in the format of InnoDB version < 3.23.52 and the block is ok */ -/* +#if 0 fprintf(stderr, -"InnoDB: Scanned old format < InnoDB-3.23.52 log block number %lu\n", + "InnoDB: Scanned old format < InnoDB-3.23.52" + " log block number %lu\n", log_block_get_hdr_no(block)); -*/ +#endif return(TRUE); } @@ -679,52 +690,54 @@ recv_scan_log_seg_for_backup( *n_bytes_scanned = 0; for (log_block = buf; log_block < buf + buf_len; - log_block += OS_FILE_LOG_BLOCK_SIZE) { + log_block += OS_FILE_LOG_BLOCK_SIZE) { no = log_block_get_hdr_no(log_block); -/* fprintf(stderr, "Log block header no %lu\n", no); */ +#if 0 + fprintf(stderr, "Log block header no %lu\n", no); +#endif if (no != log_block_convert_lsn_to_no(*scanned_lsn) - || !log_block_checksum_is_ok_or_old_format(log_block)) { -/* + || !log_block_checksum_is_ok_or_old_format(log_block)) { +#if 0 fprintf(stderr, -"Log block n:o %lu, scanned lsn n:o %lu\n", - no, log_block_convert_lsn_to_no(*scanned_lsn)); -*/ + "Log block n:o %lu, scanned lsn n:o %lu\n", + no, log_block_convert_lsn_to_no(*scanned_lsn)); +#endif /* Garbage or an incompletely written log block */ log_block += OS_FILE_LOG_BLOCK_SIZE; -/* +#if 0 fprintf(stderr, -"Next log block n:o %lu\n", - log_block_get_hdr_no(log_block)); -*/ + "Next log block n:o %lu\n", + log_block_get_hdr_no(log_block)); +#endif break; } if (*scanned_checkpoint_no > 0 - && log_block_get_checkpoint_no(log_block) - < *scanned_checkpoint_no - && *scanned_checkpoint_no - - log_block_get_checkpoint_no(log_block) - > 0x80000000UL) { + && log_block_get_checkpoint_no(log_block) + < *scanned_checkpoint_no + && *scanned_checkpoint_no + - log_block_get_checkpoint_no(log_block) + > 0x80000000UL) { /* Garbage from a log buffer flush which was made before the most recent database recovery */ -/* +#if 0 fprintf(stderr, "Scanned cp n:o %lu, block cp n:o %lu\n", *scanned_checkpoint_no, log_block_get_checkpoint_no(log_block)); -*/ +#endif break; } data_len = log_block_get_data_len(log_block); *scanned_checkpoint_no - = log_block_get_checkpoint_no(log_block); + = log_block_get_checkpoint_no(log_block); *scanned_lsn = ut_dulint_add(*scanned_lsn, data_len); *n_bytes_scanned += data_len; @@ -732,9 +745,10 @@ recv_scan_log_seg_for_backup( if (data_len < OS_FILE_LOG_BLOCK_SIZE) { /* Log data ends here */ - /* fprintf(stderr, "Log block data len %lu\n", - data_len); */ - +#if 0 + fprintf(stderr, "Log block data len %lu\n", + data_len); +#endif break; } } @@ -765,23 +779,27 @@ recv_parse_or_apply_log_rec_body( ptr = mlog_parse_nbytes(type, ptr, end_ptr, page); break; case MLOG_REC_INSERT: case MLOG_COMP_REC_INSERT: - if (NULL != (ptr = mlog_parse_index(ptr, end_ptr, - type == MLOG_COMP_REC_INSERT, &index))) { + if (NULL != (ptr = mlog_parse_index + (ptr, end_ptr, + type == MLOG_COMP_REC_INSERT, + &index))) { ut_a(!page - || (ibool)!!page_is_comp(page) - == dict_table_is_comp(index->table)); + || (ibool)!!page_is_comp(page) + == dict_table_is_comp(index->table)); ptr = page_cur_parse_insert_rec(FALSE, ptr, end_ptr, index, page, mtr); } break; case MLOG_REC_CLUST_DELETE_MARK: case MLOG_COMP_REC_CLUST_DELETE_MARK: - if (NULL != (ptr = mlog_parse_index(ptr, end_ptr, - type == MLOG_COMP_REC_CLUST_DELETE_MARK, &index))) { + if (NULL != (ptr = mlog_parse_index + (ptr, end_ptr, + type == MLOG_COMP_REC_CLUST_DELETE_MARK, + &index))) { ut_a(!page - || (ibool)!!page_is_comp(page) - == dict_table_is_comp(index->table)); - ptr = btr_cur_parse_del_mark_set_clust_rec(ptr, - end_ptr, index, page); + || (ibool)!!page_is_comp(page) + == dict_table_is_comp(index->table)); + ptr = btr_cur_parse_del_mark_set_clust_rec + (ptr, end_ptr, index, page); } break; case MLOG_COMP_REC_SEC_DELETE_MARK: @@ -797,50 +815,59 @@ recv_parse_or_apply_log_rec_body( ptr = btr_cur_parse_del_mark_set_sec_rec(ptr, end_ptr, page); break; case MLOG_REC_UPDATE_IN_PLACE: case MLOG_COMP_REC_UPDATE_IN_PLACE: - if (NULL != (ptr = mlog_parse_index(ptr, end_ptr, - type == MLOG_COMP_REC_UPDATE_IN_PLACE, &index))) { + if (NULL != (ptr = mlog_parse_index + (ptr, end_ptr, + type == MLOG_COMP_REC_UPDATE_IN_PLACE, + &index))) { ut_a(!page - || (ibool)!!page_is_comp(page) - == dict_table_is_comp(index->table)); + || (ibool)!!page_is_comp(page) + == dict_table_is_comp(index->table)); ptr = btr_cur_parse_update_in_place(ptr, end_ptr, - page, index); + page, index); } break; case MLOG_LIST_END_DELETE: case MLOG_COMP_LIST_END_DELETE: case MLOG_LIST_START_DELETE: case MLOG_COMP_LIST_START_DELETE: - if (NULL != (ptr = mlog_parse_index(ptr, end_ptr, - type == MLOG_COMP_LIST_END_DELETE - || type == MLOG_COMP_LIST_START_DELETE, &index))) { + if (NULL != (ptr = mlog_parse_index + (ptr, end_ptr, + type == MLOG_COMP_LIST_END_DELETE + || type == MLOG_COMP_LIST_START_DELETE, + &index))) { ut_a(!page - || (ibool)!!page_is_comp(page) - == dict_table_is_comp(index->table)); + || (ibool)!!page_is_comp(page) + == dict_table_is_comp(index->table)); ptr = page_parse_delete_rec_list(type, ptr, end_ptr, - index, page, mtr); + index, page, mtr); } break; case MLOG_LIST_END_COPY_CREATED: case MLOG_COMP_LIST_END_COPY_CREATED: - if (NULL != (ptr = mlog_parse_index(ptr, end_ptr, - type == MLOG_COMP_LIST_END_COPY_CREATED, &index))) { + if (NULL != (ptr = mlog_parse_index + (ptr, end_ptr, + type == MLOG_COMP_LIST_END_COPY_CREATED, + &index))) { ut_a(!page - || (ibool)!!page_is_comp(page) - == dict_table_is_comp(index->table)); - ptr = page_parse_copy_rec_list_to_created_page(ptr, - end_ptr, index, page, mtr); + || (ibool)!!page_is_comp(page) + == dict_table_is_comp(index->table)); + ptr = page_parse_copy_rec_list_to_created_page + (ptr, end_ptr, index, page, mtr); } break; case MLOG_PAGE_REORGANIZE: case MLOG_COMP_PAGE_REORGANIZE: - if (NULL != (ptr = mlog_parse_index(ptr, end_ptr, - type == MLOG_COMP_PAGE_REORGANIZE, &index))) { + if (NULL != (ptr = mlog_parse_index + (ptr, end_ptr, + type == MLOG_COMP_PAGE_REORGANIZE, + &index))) { ut_a(!page - || (ibool)!!page_is_comp(page) - == dict_table_is_comp(index->table)); + || (ibool)!!page_is_comp(page) + == dict_table_is_comp(index->table)); ptr = btr_parse_page_reorganize(ptr, end_ptr, index, - page, mtr); + page, mtr); } break; case MLOG_PAGE_CREATE: case MLOG_COMP_PAGE_CREATE: ptr = page_parse_create(ptr, end_ptr, - type == MLOG_COMP_PAGE_CREATE, page, mtr); + type == MLOG_COMP_PAGE_CREATE, + page, mtr); break; case MLOG_UNDO_INSERT: ptr = trx_undo_parse_add_undo_rec(ptr, end_ptr, page); @@ -857,18 +884,21 @@ recv_parse_or_apply_log_rec_body( case MLOG_UNDO_HDR_CREATE: case MLOG_UNDO_HDR_REUSE: ptr = trx_undo_parse_page_header(type, ptr, end_ptr, - page, mtr); + page, mtr); break; case MLOG_REC_MIN_MARK: case MLOG_COMP_REC_MIN_MARK: - ptr = btr_parse_set_min_rec_mark(ptr, end_ptr, - type == MLOG_COMP_REC_MIN_MARK, page, mtr); + ptr = btr_parse_set_min_rec_mark + (ptr, end_ptr, type == MLOG_COMP_REC_MIN_MARK, + page, mtr); break; case MLOG_REC_DELETE: case MLOG_COMP_REC_DELETE: - if (NULL != (ptr = mlog_parse_index(ptr, end_ptr, - type == MLOG_COMP_REC_DELETE, &index))) { + if (NULL != (ptr = mlog_parse_index + (ptr, end_ptr, + type == MLOG_COMP_REC_DELETE, + &index))) { ut_a(!page - || (ibool)!!page_is_comp(page) - == dict_table_is_comp(index->table)); + || (ibool)!!page_is_comp(page) + == dict_table_is_comp(index->table)); ptr = page_cur_parse_delete_rec(ptr, end_ptr, index, page, mtr); } @@ -886,7 +916,7 @@ recv_parse_or_apply_log_rec_body( case MLOG_FILE_RENAME: case MLOG_FILE_DELETE: ptr = fil_op_log_parse_or_replay(ptr, end_ptr, type, FALSE, - ULINT_UNDEFINED); + ULINT_UNDEFINED); break; default: ptr = NULL; @@ -945,10 +975,10 @@ recv_get_fil_addr_struct( recv_addr_t* recv_addr; recv_addr = HASH_GET_FIRST(recv_sys->addr_hash, - recv_hash(space, page_no)); + recv_hash(space, page_no)); while (recv_addr) { if ((recv_addr->space == space) - && (recv_addr->page_no == page_no)) { + && (recv_addr->page_no == page_no)) { break; } @@ -998,7 +1028,7 @@ recv_add_to_hash_table( if (recv_addr == NULL) { recv_addr = mem_heap_alloc(recv_sys->heap, - sizeof(recv_addr_t)); + sizeof(recv_addr_t)); recv_addr->space = space; recv_addr->page_no = page_no; recv_addr->state = RECV_NOT_PROCESSED; @@ -1006,11 +1036,12 @@ recv_add_to_hash_table( UT_LIST_INIT(recv_addr->rec_list); HASH_INSERT(recv_addr_t, addr_hash, recv_sys->addr_hash, - recv_fold(space, page_no), recv_addr); + recv_fold(space, page_no), recv_addr); recv_sys->n_addrs++; - - /* fprintf(stderr, "Inserting log rec for space %lu, page %lu\n", - space, page_no); */ +#if 0 + fprintf(stderr, "Inserting log rec for space %lu, page %lu\n", + space, page_no); +#endif } UT_LIST_ADD_LAST(rec_list, recv_addr->rec_list, recv); @@ -1030,7 +1061,7 @@ recv_add_to_hash_table( } recv_data = mem_heap_alloc(recv_sys->heap, - sizeof(recv_data_t) + len); + sizeof(recv_data_t) + len); *prev_field = recv_data; ut_memcpy(((byte*)recv_data) + sizeof(recv_data_t), body, len); @@ -1067,7 +1098,7 @@ recv_data_copy_to_buf( } ut_memcpy(buf, ((byte*)recv_data) + sizeof(recv_data_t), - part_len); + part_len); buf += part_len; len -= part_len; @@ -1119,15 +1150,17 @@ recv_recover_page( recv_addr = recv_get_fil_addr_struct(space, page_no); if ((recv_addr == NULL) - || (recv_addr->state == RECV_BEING_PROCESSED) - || (recv_addr->state == RECV_PROCESSED)) { + || (recv_addr->state == RECV_BEING_PROCESSED) + || (recv_addr->state == RECV_PROCESSED)) { mutex_exit(&(recv_sys->mutex)); return; } - /* fprintf(stderr, "Recovering space %lu, page %lu\n", space, page_no); */ +#if 0 + fprintf(stderr, "Recovering space %lu, page %lu\n", space, page_no); +#endif recv_addr->state = RECV_BEING_PROCESSED; @@ -1140,18 +1173,19 @@ recv_recover_page( block = buf_block_align(page); if (just_read_in) { - /* Move the ownership of the x-latch on the page to this OS - thread, so that we can acquire a second x-latch on it. This - is needed for the operations to the page to pass the debug - checks. */ + /* Move the ownership of the x-latch on the + page to this OS thread, so that we can acquire + a second x-latch on it. This is needed for the + operations to the page to pass the debug + checks. */ rw_lock_x_lock_move_ownership(&(block->lock)); } success = buf_page_get_known_nowait(RW_X_LATCH, page, - BUF_KEEP_OLD, - __FILE__, __LINE__, - &mtr); + BUF_KEEP_OLD, + __FILE__, __LINE__, + &mtr); ut_a(success); #ifdef UNIV_SYNC_DEBUG @@ -1202,7 +1236,8 @@ recv_recover_page( page_lsn = page_newest_lsn; mach_write_to_8(page + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM, ut_dulint_zero); + - FIL_PAGE_END_LSN_OLD_CHKSUM, + ut_dulint_zero); mach_write_to_8(page + FIL_PAGE_LSN, ut_dulint_zero); } @@ -1217,7 +1252,9 @@ recv_recover_page( #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, - "InnoDB: Applying log rec type %lu len %lu to space %lu page no %lu\n", + "InnoDB: Applying log rec" + " type %lu len %lu" + " to space %lu page no %lu\n", (ulong) recv->type, (ulong) recv->len, (ulong) recv_addr->space, (ulong) recv_addr->page_no); @@ -1225,14 +1262,15 @@ recv_recover_page( #endif /* UNIV_DEBUG */ recv_parse_or_apply_log_rec_body(recv->type, buf, - buf + recv->len, page, &mtr); + buf + recv->len, + page, &mtr); mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, ut_dulint_add(recv->start_lsn, - recv->len)); + recv->len)); mach_write_to_8(page + FIL_PAGE_LSN, ut_dulint_add(recv->start_lsn, - recv->len)); + recv->len)); } if (recv->len > RECV_DATA_BLOCK_SIZE) { @@ -1290,7 +1328,7 @@ recv_read_in_area( n = 0; for (page_no = low_limit; page_no < low_limit + RECV_READ_AHEAD_AREA; - page_no++) { + page_no++) { recv_addr = recv_get_fil_addr_struct(space, page_no); if (recv_addr && !buf_page_peek(space, page_no)) { @@ -1374,9 +1412,11 @@ loop: if (recv_addr->state == RECV_NOT_PROCESSED) { if (!has_printed) { ut_print_timestamp(stderr); - fputs( -" InnoDB: Starting an apply batch of log records to the database...\n" -"InnoDB: Progress in percents: ",stderr); + fputs(" InnoDB: Starting an" + " apply batch of log records" + " to the database...\n" + "InnoDB: Progress in percents: ", + stderr); has_printed = TRUE; } @@ -1387,14 +1427,14 @@ loop: mtr_start(&mtr); page = buf_page_get(space, page_no, - RW_X_LATCH, &mtr); + RW_X_LATCH, &mtr); #ifdef UNIV_SYNC_DEBUG - buf_page_dbg_add_level(page, - SYNC_NO_ORDER_CHECK); + buf_page_dbg_add_level + (page, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ recv_recover_page(FALSE, FALSE, page, - space, page_no); + space, page_no); mtr_commit(&mtr); } else { recv_read_in_area(space, page_no); @@ -1407,12 +1447,13 @@ loop: } if (has_printed - && (i * 100) / hash_get_n_cells(recv_sys->addr_hash) - != ((i + 1) * 100) - / hash_get_n_cells(recv_sys->addr_hash)) { + && (i * 100) / hash_get_n_cells(recv_sys->addr_hash) + != ((i + 1) * 100) + / hash_get_n_cells(recv_sys->addr_hash)) { - fprintf(stderr, "%lu ", - (ulong) ((i * 100) / hash_get_n_cells(recv_sys->addr_hash))); + fprintf(stderr, "%lu ", (ulong) + ((i * 100) + / hash_get_n_cells(recv_sys->addr_hash))); } } @@ -1440,7 +1481,7 @@ loop: mutex_exit(&(log_sys->mutex)); n_pages = buf_flush_batch(BUF_FLUSH_LIST, ULINT_MAX, - ut_dulint_max); + ut_dulint_max); ut_a(n_pages != ULINT_UNDEFINED); buf_flush_wait_batch_end(BUF_FLUSH_LIST); @@ -1493,9 +1534,9 @@ recv_apply_log_recs_for_backup(void) page = recv_backup_application_page; - fputs( -"InnoDB: Starting an apply batch of log records to the database...\n" -"InnoDB: Progress in percents: ", stderr); + fputs("InnoDB: Starting an apply batch of log records" + " to the database...\n" + "InnoDB: Progress in percents: ", stderr); n_hash_cells = hash_get_n_cells(recv_sys->addr_hash); @@ -1506,12 +1547,15 @@ recv_apply_log_recs_for_backup(void) while (recv_addr != NULL) { if (!fil_tablespace_exists_in_mem(recv_addr->space)) { -/* +#if 0 fprintf(stderr, -"InnoDB: Warning: cannot apply log record to tablespace %lu page %lu,\n" -"InnoDB: because tablespace with that id does not exist.\n", -recv_addr->space, recv_addr->page_no); -*/ + "InnoDB: Warning: cannot apply" + " log record to" + " tablespace %lu page %lu,\n" + "InnoDB: because tablespace with" + " that id does not exist.\n", + recv_addr->space, recv_addr->page_no); +#endif recv_addr->state = RECV_PROCESSED; ut_a(recv_sys->n_addrs); @@ -1526,19 +1570,18 @@ recv_addr->space, recv_addr->page_no); the block corresponding to buf_pool->frame_zero (== page). */ - buf_page_init_for_backup_restore(recv_addr->space, - recv_addr->page_no, - buf_block_align(page)); + buf_page_init_for_backup_restore + (recv_addr->space, recv_addr->page_no, + buf_block_align(page)); /* Extend the tablespace's last file if the page_no does not fall inside its bounds; we assume the last file is auto-extending, and ibbackup copied the file when it still was smaller */ - success = fil_extend_space_to_desired_size( - &actual_size, - recv_addr->space, - recv_addr->page_no + 1); + success = fil_extend_space_to_desired_size + (&actual_size, + recv_addr->space, recv_addr->page_no + 1); if (!success) { fprintf(stderr, "InnoDB: Fatal error: cannot extend" @@ -1552,12 +1595,13 @@ recv_addr->space, recv_addr->page_no); fil0fil.c routines */ error = fil_io(OS_FILE_READ, TRUE, recv_addr->space, - recv_addr->page_no, 0, UNIV_PAGE_SIZE, - page, NULL); + recv_addr->page_no, 0, UNIV_PAGE_SIZE, + page, NULL); if (error != DB_SUCCESS) { fprintf(stderr, - "InnoDB: Fatal error: cannot read from tablespace" - " %lu page number %lu\n", + "InnoDB: Fatal error: cannot read" + " from tablespace" + " %lu page number %lu\n", (ulong) recv_addr->space, (ulong) recv_addr->page_no); @@ -1566,24 +1610,24 @@ recv_addr->space, recv_addr->page_no); /* Apply the log records to this page */ recv_recover_page(TRUE, FALSE, page, recv_addr->space, - recv_addr->page_no); + recv_addr->page_no); /* Write the page back to the tablespace file using the fil0fil.c routines */ - buf_flush_init_for_writing(page, - mach_read_from_8(page + FIL_PAGE_LSN), - recv_addr->space, recv_addr->page_no); + buf_flush_init_for_writing + (page, mach_read_from_8(page + FIL_PAGE_LSN), + recv_addr->space, recv_addr->page_no); error = fil_io(OS_FILE_WRITE, TRUE, recv_addr->space, - recv_addr->page_no, 0, UNIV_PAGE_SIZE, - page, NULL); + recv_addr->page_no, 0, UNIV_PAGE_SIZE, + page, NULL); skip_this_recv_addr: recv_addr = HASH_GET_NEXT(addr_hash, recv_addr); } if ((100 * i) / n_hash_cells - != (100 * (i + 1)) / n_hash_cells) { + != (100 * (i + 1)) / n_hash_cells) { fprintf(stderr, "%lu ", (ulong) ((100 * i) / n_hash_cells)); fflush(stderr); @@ -1593,208 +1637,6 @@ skip_this_recv_addr: recv_sys_empty_hash(); } -#ifdef notdefined -/*********************************************************************** -In the debug version, updates the replica of a file page, based on a log -record. */ -static -void -recv_update_replicate( -/*==================*/ - byte type, /* in: log record type */ - ulint space, /* in: space id */ - ulint page_no,/* in: page number */ - byte* body, /* in: log record body */ - byte* end_ptr)/* in: log record end */ -{ - page_t* replica; - mtr_t mtr; - byte* ptr; - - mtr_start(&mtr); - - mtr_set_log_mode(&mtr, MTR_LOG_NONE); - - replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no, - RW_X_LATCH, &mtr); -#ifdef UNIV_SYNC_DEBUG - buf_page_dbg_add_level(replica, SYNC_NO_ORDER_CHECK); -#endif /* UNIV_SYNC_DEBUG */ - - ptr = recv_parse_or_apply_log_rec_body(type, body, end_ptr, replica, - &mtr); - ut_a(ptr == end_ptr); - - /* Notify the buffer manager that the page has been updated */ - - buf_flush_recv_note_modification(buf_block_align(replica), - log_sys->old_lsn, log_sys->old_lsn); - - /* Make sure that committing mtr does not call log routines, as - we currently own the log mutex */ - - mtr.modifications = FALSE; - - mtr_commit(&mtr); -} - -/*********************************************************************** -Checks that two strings are identical. */ -static -void -recv_check_identical( -/*=================*/ - byte* str1, /* in: first string */ - byte* str2, /* in: second string */ - ulint len) /* in: length of strings */ -{ - ulint i; - - for (i = 0; i < len; i++) { - - if (str1[i] != str2[i]) { - fprintf(stderr, - "Strings do not match at offset %lu\n", i); - ut_print_buf(str1 + i, 16); - fprintf(stderr, "\n"); - ut_print_buf(str2 + i, 16); - - ut_error; - } - } -} - -/*********************************************************************** -In the debug version, checks that the replica of a file page is identical -to the original page. */ -static -void -recv_compare_replicate( -/*===================*/ - ulint space, /* in: space id */ - ulint page_no)/* in: page number */ -{ - page_t* replica; - page_t* page; - mtr_t mtr; - - mtr_start(&mtr); - - mutex_enter(&(buf_pool->mutex)); - - page = buf_page_hash_get(space, page_no)->frame; - - mutex_exit(&(buf_pool->mutex)); - - replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no, - RW_X_LATCH, &mtr); -#ifdef UNIV_SYNC_DEBUG - buf_page_dbg_add_level(replica, SYNC_NO_ORDER_CHECK); -#endif /* UNIV_SYNC_DEBUG */ - - recv_check_identical(page + FIL_PAGE_DATA, - replica + FIL_PAGE_DATA, - PAGE_HEADER + PAGE_MAX_TRX_ID - FIL_PAGE_DATA); - - recv_check_identical(page + PAGE_HEADER + PAGE_MAX_TRX_ID + 8, - replica + PAGE_HEADER + PAGE_MAX_TRX_ID + 8, - UNIV_PAGE_SIZE - FIL_PAGE_DATA_END - - PAGE_HEADER - PAGE_MAX_TRX_ID - 8); - mtr_commit(&mtr); -} - -/*********************************************************************** -Checks that a replica of a space is identical to the original space. */ - -void -recv_compare_spaces( -/*================*/ - ulint space1, /* in: space id */ - ulint space2, /* in: space id */ - ulint n_pages)/* in: number of pages */ -{ - page_t* replica; - page_t* page; - mtr_t mtr; - page_t* frame; - ulint page_no; - - replica = buf_frame_alloc(); - page = buf_frame_alloc(); - - for (page_no = 0; page_no < n_pages; page_no++) { - - mtr_start(&mtr); - - frame = buf_page_get_gen(space1, page_no, RW_S_LATCH, NULL, - BUF_GET_IF_IN_POOL, - __FILE__, __LINE__, - &mtr); - if (frame) { -#ifdef UNIV_SYNC_DEBUG - buf_page_dbg_add_level(frame, SYNC_NO_ORDER_CHECK); -#endif /* UNIV_SYNC_DEBUG */ - ut_memcpy(page, frame, UNIV_PAGE_SIZE); - } else { - /* Read it from file */ - fil_io(OS_FILE_READ, TRUE, space1, page_no, 0, - UNIV_PAGE_SIZE, page, NULL); - } - - frame = buf_page_get_gen(space2, page_no, RW_S_LATCH, NULL, - BUF_GET_IF_IN_POOL, - __FILE__, __LINE__, - &mtr); - if (frame) { -#ifdef UNIV_SYNC_DEBUG - buf_page_dbg_add_level(frame, SYNC_NO_ORDER_CHECK); -#endif /* UNIV_SYNC_DEBUG */ - ut_memcpy(replica, frame, UNIV_PAGE_SIZE); - } else { - /* Read it from file */ - fil_io(OS_FILE_READ, TRUE, space2, page_no, 0, - UNIV_PAGE_SIZE, replica, NULL); - } - - recv_check_identical(page + FIL_PAGE_DATA, - replica + FIL_PAGE_DATA, - PAGE_HEADER + PAGE_MAX_TRX_ID - FIL_PAGE_DATA); - - recv_check_identical(page + PAGE_HEADER + PAGE_MAX_TRX_ID + 8, - replica + PAGE_HEADER + PAGE_MAX_TRX_ID + 8, - UNIV_PAGE_SIZE - FIL_PAGE_DATA_END - - PAGE_HEADER - PAGE_MAX_TRX_ID - 8); - - mtr_commit(&mtr); - } - - buf_frame_free(replica); - buf_frame_free(page); -} - -/*********************************************************************** -Checks that a replica of a space is identical to the original space. Disables -ibuf operations and flushes and invalidates the buffer pool pages after the -test. This function can be used to check the recovery before dict or trx -systems are initialized. */ - -void -recv_compare_spaces_low( -/*====================*/ - ulint space1, /* in: space id */ - ulint space2, /* in: space id */ - ulint n_pages)/* in: number of pages */ -{ - mutex_enter(&(log_sys->mutex)); - - recv_apply_hashed_log_recs(FALSE); - - mutex_exit(&(log_sys->mutex)); - - recv_compare_spaces(space1, space2, n_pages); -} -#endif /* UNIV_LOG_REPLICATE */ - /*********************************************************************** Tries to parse a single log record and returns its length. */ static @@ -1835,7 +1677,7 @@ recv_parse_log_rec( } new_ptr = mlog_parse_initial_log_record(ptr, end_ptr, type, space, - page_no); + page_no); *body = new_ptr; if (UNIV_UNLIKELY(!new_ptr)) { @@ -1853,7 +1695,7 @@ recv_parse_log_rec( } new_ptr = recv_parse_or_apply_log_rec_body(*type, new_ptr, end_ptr, - NULL, NULL); + NULL, NULL); if (UNIV_UNLIKELY(new_ptr == NULL)) { return(0); @@ -1880,13 +1722,13 @@ recv_calc_lsn_on_data_add( ulint lsn_len; frag_len = (ut_dulint_get_low(lsn) % OS_FILE_LOG_BLOCK_SIZE) - - LOG_BLOCK_HDR_SIZE; + - LOG_BLOCK_HDR_SIZE; ut_ad(frag_len < OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - - LOG_BLOCK_TRL_SIZE); + - LOG_BLOCK_TRL_SIZE); lsn_len = len + ((len + frag_len) / (OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - - LOG_BLOCK_TRL_SIZE)) - * (LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE); + - LOG_BLOCK_TRL_SIZE)) + * (LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE); return(ut_dulint_add(lsn, lsn_len)); } @@ -1909,7 +1751,7 @@ recv_check_incomplete_log_recs( for (i = 0; i < len; i++) { ut_a(0 == recv_parse_log_rec(ptr, ptr + i, &type, &space, - &page_no, &body)); + &page_no, &body)); } } @@ -1925,11 +1767,11 @@ recv_report_corrupt_log( ulint page_no)/* in: page number, this may also be garbage */ { fprintf(stderr, -"InnoDB: ############### CORRUPT LOG RECORD FOUND\n" -"InnoDB: Log record type %lu, space id %lu, page number %lu\n" -"InnoDB: Log parsing proceeded successfully up to %lu %lu\n" -"InnoDB: Previous log record type %lu, is multi %lu\n" -"InnoDB: Recv offset %lu, prev %lu\n", + "InnoDB: ############### CORRUPT LOG RECORD FOUND\n" + "InnoDB: Log record type %lu, space id %lu, page number %lu\n" + "InnoDB: Log parsing proceeded successfully up to %lu %lu\n" + "InnoDB: Previous log record type %lu, is multi %lu\n" + "InnoDB: Recv offset %lu, prev %lu\n", (ulong) type, (ulong) space, (ulong) page_no, (ulong) ut_dulint_get_high(recv_sys->recovered_lsn), (ulong) ut_dulint_get_low(recv_sys->recovered_lsn), @@ -1939,31 +1781,33 @@ recv_report_corrupt_log( (ulong) recv_previous_parsed_rec_offset); if ((ulint)(ptr - recv_sys->buf + 100) - > recv_previous_parsed_rec_offset - && (ulint)(ptr - recv_sys->buf + 100 - - recv_previous_parsed_rec_offset) - < 200000) { - fputs( -"InnoDB: Hex dump of corrupt log starting 100 bytes before the start\n" -"InnoDB: of the previous log rec,\n" -"InnoDB: and ending 100 bytes after the start of the corrupt rec:\n", - stderr); + > recv_previous_parsed_rec_offset + && (ulint)(ptr - recv_sys->buf + 100 + - recv_previous_parsed_rec_offset) + < 200000) { + fputs("InnoDB: Hex dump of corrupt log starting" + " 100 bytes before the start\n" + "InnoDB: of the previous log rec,\n" + "InnoDB: and ending 100 bytes after the start" + " of the corrupt rec:\n", + stderr); ut_print_buf(stderr, - recv_sys->buf + recv_previous_parsed_rec_offset - 100, - ptr - recv_sys->buf + 200 - - recv_previous_parsed_rec_offset); + recv_sys->buf + + recv_previous_parsed_rec_offset - 100, + ptr - recv_sys->buf + 200 + - recv_previous_parsed_rec_offset); putc('\n', stderr); } - fputs( - "InnoDB: WARNING: the log file may have been corrupt and it\n" - "InnoDB: is possible that the log scan did not proceed\n" - "InnoDB: far enough in recovery! Please run CHECK TABLE\n" - "InnoDB: on your InnoDB tables to check that they are ok!\n" - "InnoDB: If mysqld crashes after this recovery, look at\n" - "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" - "InnoDB: about forcing recovery.\n", stderr); + fputs("InnoDB: WARNING: the log file may have been corrupt and it\n" + "InnoDB: is possible that the log scan did not proceed\n" + "InnoDB: far enough in recovery! Please run CHECK TABLE\n" + "InnoDB: on your InnoDB tables to check that they are ok!\n" + "InnoDB: If mysqld crashes after this recovery, look at\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "forcing-recovery.html\n" + "InnoDB: about forcing recovery.\n", stderr); fflush(stderr); } @@ -2018,13 +1862,13 @@ loop: page no, and a pointer to the body of the log record */ len = recv_parse_log_rec(ptr, end_ptr, &type, &space, - &page_no, &body); + &page_no, &body); if (len == 0 || recv_sys->found_corrupt_log) { if (recv_sys->found_corrupt_log) { recv_report_corrupt_log(ptr, - type, space, page_no); + type, space, page_no); } return(FALSE); @@ -2033,7 +1877,7 @@ loop: new_recovered_lsn = recv_calc_lsn_on_data_add(old_lsn, len); if (ut_dulint_cmp(new_recovered_lsn, recv_sys->scanned_lsn) - > 0) { + > 0) { /* The log record filled a log block, and we require that also the next log block should have been scanned in */ @@ -2051,7 +1895,8 @@ loop: #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, -"InnoDB: Parsed a single log rec type %lu len %lu space %lu page no %lu\n", + "InnoDB: Parsed a single log rec" + " type %lu len %lu space %lu page no %lu\n", (ulong) type, (ulong) len, (ulong) space, (ulong) page_no); } @@ -2061,8 +1906,8 @@ loop: /* Do nothing */ } else if (store_to_hash && (type == MLOG_FILE_CREATE - || type == MLOG_FILE_RENAME - || type == MLOG_FILE_DELETE)) { + || type == MLOG_FILE_RENAME + || type == MLOG_FILE_DELETE)) { #ifdef UNIV_HOTBACKUP if (recv_replay_file_ops) { @@ -2071,11 +1916,16 @@ loop: fil_path_to_mysql_datadir is set in ibbackup to point to the datadir we should use there */ - if (NULL == fil_op_log_parse_or_replay(body, - end_ptr, type, TRUE, space)) { + if (NULL == fil_op_log_parse_or_replay + (body, end_ptr, type, TRUE, space)) { fprintf(stderr, -"InnoDB: Error: file op log record of type %lu space %lu not complete in\n" -"InnoDB: the replay phase. Path %s\n", (ulint)type, space, (char*)(body + 2)); + "InnoDB: Error: file op" + " log record of type %lu" + " space %lu not complete in\n" + "InnoDB: the replay phase." + " Path %s\n", + (ulint)type, space, + (char*)(body + 2)); ut_a(0); } @@ -2085,21 +1935,12 @@ loop: replay file operations */ } else if (store_to_hash) { recv_add_to_hash_table(type, space, page_no, body, - ptr + len, old_lsn, - recv_sys->recovered_lsn); + ptr + len, old_lsn, + recv_sys->recovered_lsn); } else { - /* In debug checking, update a replicate page - according to the log record, and check that it - becomes identical with the original page */ #ifdef UNIV_LOG_DEBUG recv_check_incomplete_log_recs(ptr, len); #endif/* UNIV_LOG_DEBUG */ -#ifdef UNIV_LOG_REPLICATE - recv_update_replicate(type, space, page_no, body, - ptr + len); - recv_compare_replicate(space, page_no); -#endif /* UNIV_LOG_REPLICATE */ - } } else { /* Check that all the records associated with the single mtr @@ -2110,13 +1951,13 @@ loop: for (;;) { len = recv_parse_log_rec(ptr, end_ptr, &type, &space, - &page_no, &body); + &page_no, &body); if (len == 0 || recv_sys->found_corrupt_log) { if (recv_sys->found_corrupt_log) { - recv_report_corrupt_log(ptr, - type, space, page_no); + recv_report_corrupt_log + (ptr, type, space, page_no); } return(FALSE); @@ -2128,23 +1969,19 @@ loop: recv_previous_parsed_rec_is_multi = 1; if ((!store_to_hash) && (type != MLOG_MULTI_REC_END)) { - /* In debug checking, update a replicate page - according to the log record */ #ifdef UNIV_LOG_DEBUG recv_check_incomplete_log_recs(ptr, len); #endif /* UNIV_LOG_DEBUG */ -#ifdef UNIV_LOG_REPLICATE - recv_update_replicate(type, space, page_no, - body, ptr + len); -#endif /* UNIV_LOG_REPLICATE */ } #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, -"InnoDB: Parsed a multi log rec type %lu len %lu space %lu page no %lu\n", - (ulong) type, (ulong) len, (ulong) space, - (ulong) page_no); + "InnoDB: Parsed a multi log rec" + " type %lu len %lu" + " space %lu page no %lu\n", + (ulong) type, (ulong) len, + (ulong) space, (ulong) page_no); } #endif /* UNIV_DEBUG */ @@ -2161,11 +1998,11 @@ loop: } } - new_recovered_lsn = recv_calc_lsn_on_data_add( - recv_sys->recovered_lsn, total_len); + new_recovered_lsn = recv_calc_lsn_on_data_add + (recv_sys->recovered_lsn, total_len); if (ut_dulint_cmp(new_recovered_lsn, recv_sys->scanned_lsn) - > 0) { + > 0) { /* The log record filled a log block, and we require that also the next log block should have been scanned in */ @@ -2180,7 +2017,7 @@ loop: for (;;) { old_lsn = recv_sys->recovered_lsn; len = recv_parse_log_rec(ptr, end_ptr, &type, &space, - &page_no, &body); + &page_no, &body); if (recv_sys->found_corrupt_log) { recv_report_corrupt_log(ptr, @@ -2191,8 +2028,8 @@ loop: ut_a(0 == ((ulint)*ptr & MLOG_SINGLE_REC_FLAG)); recv_sys->recovered_offset += len; - recv_sys->recovered_lsn = recv_calc_lsn_on_data_add( - old_lsn, len); + recv_sys->recovered_lsn + = recv_calc_lsn_on_data_add(old_lsn, len); if (type == MLOG_MULTI_REC_END) { /* Found the end mark for the records */ @@ -2202,15 +2039,9 @@ loop: if (store_to_hash) { recv_add_to_hash_table(type, space, page_no, - body, ptr + len, old_lsn, - new_recovered_lsn); -#ifdef UNIV_LOG_REPLICATE - } else { - /* In debug checking, check that the replicate - page has become identical with the original - page */ - recv_compare_replicate(space, page_no); -#endif /* UNIV_LOG_REPLICATE */ + body, ptr + len, + old_lsn, + new_recovered_lsn); } ptr += len; @@ -2257,9 +2088,9 @@ recv_sys_add_to_parsing_buf( return(FALSE); } else if (ut_dulint_cmp(recv_sys->parse_start_lsn, - recv_sys->scanned_lsn) > 0) { + recv_sys->scanned_lsn) > 0) { more_len = ut_dulint_minus(scanned_lsn, - recv_sys->parse_start_lsn); + recv_sys->parse_start_lsn); } else { more_len = ut_dulint_minus(scanned_lsn, recv_sys->scanned_lsn); } @@ -2287,7 +2118,7 @@ recv_sys_add_to_parsing_buf( if (start_offset < end_offset) { ut_memcpy(recv_sys->buf + recv_sys->len, - log_block + start_offset, end_offset - start_offset); + log_block + start_offset, end_offset - start_offset); recv_sys->len += end_offset - start_offset; @@ -2305,7 +2136,7 @@ recv_sys_justify_left_parsing_buf(void) /*===================================*/ { ut_memmove(recv_sys->buf, recv_sys->buf + recv_sys->recovered_offset, - recv_sys->len - recv_sys->recovered_offset); + recv_sys->len - recv_sys->recovered_offset); recv_sys->len -= recv_sys->recovered_offset; @@ -2361,26 +2192,32 @@ recv_scan_log_recs( while (log_block < buf + len && !finished) { no = log_block_get_hdr_no(log_block); -/* + /* fprintf(stderr, "Log block header no %lu\n", no); fprintf(stderr, "Scanned lsn no %lu\n", - log_block_convert_lsn_to_no(scanned_lsn)); -*/ + log_block_convert_lsn_to_no(scanned_lsn)); + */ if (no != log_block_convert_lsn_to_no(scanned_lsn) - || !log_block_checksum_is_ok_or_old_format(log_block)) { + || !log_block_checksum_is_ok_or_old_format(log_block)) { if (no == log_block_convert_lsn_to_no(scanned_lsn) - && !log_block_checksum_is_ok_or_old_format( - log_block)) { + && !log_block_checksum_is_ok_or_old_format + (log_block)) { fprintf(stderr, -"InnoDB: Log block no %lu at lsn %lu %lu has\n" -"InnoDB: ok header, but checksum field contains %lu, should be %lu\n", - (ulong) no, - (ulong) ut_dulint_get_high(scanned_lsn), - (ulong) ut_dulint_get_low(scanned_lsn), - (ulong) log_block_get_checksum(log_block), - (ulong) log_block_calc_checksum(log_block)); + "InnoDB: Log block no %lu at" + " lsn %lu %lu has\n" + "InnoDB: ok header, but checksum field" + " contains %lu, should be %lu\n", + (ulong) no, + (ulong) ut_dulint_get_high + (scanned_lsn), + (ulong) ut_dulint_get_low + (scanned_lsn), + (ulong) log_block_get_checksum + (log_block), + (ulong) log_block_calc_checksum + (log_block)); } /* Garbage or an incompletely written log block */ @@ -2406,14 +2243,14 @@ recv_scan_log_recs( data_len = log_block_get_data_len(log_block); if ((store_to_hash || (data_len == OS_FILE_LOG_BLOCK_SIZE)) - && (ut_dulint_cmp(ut_dulint_add(scanned_lsn, data_len), - recv_sys->scanned_lsn) > 0) - && (recv_sys->scanned_checkpoint_no > 0) - && (log_block_get_checkpoint_no(log_block) - < recv_sys->scanned_checkpoint_no) - && (recv_sys->scanned_checkpoint_no - - log_block_get_checkpoint_no(log_block) - > 0x80000000UL)) { + && (ut_dulint_cmp(ut_dulint_add(scanned_lsn, data_len), + recv_sys->scanned_lsn) > 0) + && (recv_sys->scanned_checkpoint_no > 0) + && (log_block_get_checkpoint_no(log_block) + < recv_sys->scanned_checkpoint_no) + && (recv_sys->scanned_checkpoint_no + - log_block_get_checkpoint_no(log_block) + > 0x80000000UL)) { /* Garbage from a log buffer flush which was made before the most recent database recovery */ @@ -2429,14 +2266,15 @@ recv_scan_log_recs( } if (ut_dulint_is_zero(recv_sys->parse_start_lsn) - && (log_block_get_first_rec_group(log_block) > 0)) { + && (log_block_get_first_rec_group(log_block) > 0)) { /* We found a point from which to start the parsing of log records */ - recv_sys->parse_start_lsn = - ut_dulint_add(scanned_lsn, - log_block_get_first_rec_group(log_block)); + recv_sys->parse_start_lsn + = ut_dulint_add(scanned_lsn, + log_block_get_first_rec_group + (log_block)); recv_sys->scanned_lsn = recv_sys->parse_start_lsn; recv_sys->recovered_lsn = recv_sys->parse_start_lsn; } @@ -2450,20 +2288,22 @@ recv_scan_log_recs( non-zero */ if (recv_sys->len + 4 * OS_FILE_LOG_BLOCK_SIZE - >= RECV_PARSING_BUF_SIZE) { + >= RECV_PARSING_BUF_SIZE) { fprintf(stderr, -"InnoDB: Error: log parsing buffer overflow. Recovery may have failed!\n"); + "InnoDB: Error: log parsing" + " buffer overflow." + " Recovery may have failed!\n"); recv_sys->found_corrupt_log = TRUE; } else if (!recv_sys->found_corrupt_log) { - more_data = recv_sys_add_to_parsing_buf( - log_block, scanned_lsn); + more_data = recv_sys_add_to_parsing_buf + (log_block, scanned_lsn); } recv_sys->scanned_lsn = scanned_lsn; - recv_sys->scanned_checkpoint_no = - log_block_get_checkpoint_no(log_block); + recv_sys->scanned_checkpoint_no + = log_block_get_checkpoint_no(log_block); } if (data_len < OS_FILE_LOG_BLOCK_SIZE) { @@ -2478,13 +2318,14 @@ recv_scan_log_recs( *group_scanned_lsn = scanned_lsn; if (recv_needed_recovery - || (recv_is_from_backup && !recv_is_making_a_backup)) { + || (recv_is_from_backup && !recv_is_making_a_backup)) { recv_scan_print_counter++; if (finished || (recv_scan_print_counter % 80 == 0)) { fprintf(stderr, -"InnoDB: Doing recovery: scanned up to log sequence number %lu %lu\n", + "InnoDB: Doing recovery: scanned up to" + " log sequence number %lu %lu\n", (ulong) ut_dulint_get_high(*group_scanned_lsn), (ulong) ut_dulint_get_low(*group_scanned_lsn)); } @@ -2496,8 +2337,8 @@ recv_scan_log_recs( recv_parse_log_recs(store_to_hash); if (store_to_hash && mem_heap_get_size(recv_sys->heap) - > available_memory - && apply_automatically) { + > available_memory + && apply_automatically) { /* Hash table of log records has grown too big: empty it; FALSE means no ibuf operations @@ -2542,24 +2383,24 @@ recv_group_scan_log_recs( end_lsn = ut_dulint_add(start_lsn, RECV_SCAN_SIZE); log_group_read_log_seg(LOG_RECOVER, log_sys->buf, - group, start_lsn, end_lsn); + group, start_lsn, end_lsn); - finished = recv_scan_log_recs(TRUE, - (buf_pool->n_frames - - recv_n_pool_free_frames) * UNIV_PAGE_SIZE, - TRUE, log_sys->buf, - RECV_SCAN_SIZE, start_lsn, - contiguous_lsn, group_scanned_lsn); + finished = recv_scan_log_recs + (TRUE, (buf_pool->n_frames - recv_n_pool_free_frames) + * UNIV_PAGE_SIZE, TRUE, log_sys->buf, + RECV_SCAN_SIZE, start_lsn, + contiguous_lsn, group_scanned_lsn); start_lsn = end_lsn; } #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, - "InnoDB: Scanned group %lu up to log sequence number %lu %lu\n", - (ulong) group->id, - (ulong) ut_dulint_get_high(*group_scanned_lsn), - (ulong) ut_dulint_get_low(*group_scanned_lsn)); + "InnoDB: Scanned group %lu up to" + " log sequence number %lu %lu\n", + (ulong) group->id, + (ulong) ut_dulint_get_high(*group_scanned_lsn), + (ulong) ut_dulint_get_low(*group_scanned_lsn)); } #endif /* UNIV_DEBUG */ } @@ -2595,7 +2436,7 @@ recv_recovery_from_checkpoint_start( ulint err; ut_ad((type != LOG_CHECKPOINT) - || (ut_dulint_cmp(limit_lsn, ut_dulint_max) == 0)); + || (ut_dulint_cmp(limit_lsn, ut_dulint_max) == 0)); if (type == LOG_CHECKPOINT) { recv_sys_create(); @@ -2604,9 +2445,9 @@ recv_recovery_from_checkpoint_start( if (srv_force_recovery >= SRV_FORCE_NO_LOG_REDO) { fprintf(stderr, - "InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on\n"); + "InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on\n"); fprintf(stderr, - "InnoDB: Skipping log redo\n"); + "InnoDB: Skipping log redo\n"); return(DB_SUCCESS); } @@ -2640,29 +2481,32 @@ recv_recovery_from_checkpoint_start( a recovery from a restored InnoDB Hot Backup */ fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, max_cp_group->space_id, - 0, 0, LOG_FILE_HDR_SIZE, - log_hdr_buf, max_cp_group); + 0, 0, LOG_FILE_HDR_SIZE, + log_hdr_buf, max_cp_group); if (0 == ut_memcmp(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, - (byte*)"ibbackup", (sizeof "ibbackup") - 1)) { + (byte*)"ibbackup", (sizeof "ibbackup") - 1)) { /* This log file was created by ibbackup --restore: print a note to the user about it */ fprintf(stderr, - "InnoDB: The log file was created by ibbackup --apply-log at\n" - "InnoDB: %s\n", log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP); + "InnoDB: The log file was created by" + " ibbackup --apply-log at\n" + "InnoDB: %s\n", + log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP); fprintf(stderr, -"InnoDB: NOTE: the following crash recovery is part of a normal restore.\n"); + "InnoDB: NOTE: the following crash recovery" + " is part of a normal restore.\n"); /* Wipe over the label now */ memset(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, - ' ', 4); + ' ', 4); /* Write to the log file to wipe over the label */ fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, - max_cp_group->space_id, - 0, 0, OS_FILE_LOG_BLOCK_SIZE, - log_hdr_buf, max_cp_group); + max_cp_group->space_id, + 0, 0, OS_FILE_LOG_BLOCK_SIZE, + log_hdr_buf, max_cp_group); } #ifdef UNIV_LOG_ARCHIVE @@ -2670,8 +2514,8 @@ recv_recovery_from_checkpoint_start( while (group) { log_checkpoint_get_nth_group_info(buf, group->id, - &(group->archived_file_no), - &(group->archived_offset)); + &(group->archived_file_no), + &(group->archived_offset)); group = UT_LIST_GET_NEXT(log_groups, group); } @@ -2694,26 +2538,41 @@ recv_recovery_from_checkpoint_start( user about recovery: */ if (ut_dulint_cmp(checkpoint_lsn, max_flushed_lsn) != 0 - || ut_dulint_cmp(checkpoint_lsn, min_flushed_lsn) != 0) { + || ut_dulint_cmp(checkpoint_lsn, min_flushed_lsn) != 0) { if (ut_dulint_cmp(checkpoint_lsn, max_flushed_lsn) - < 0) { + < 0) { fprintf(stderr, -"InnoDB: ##########################################################\n" -"InnoDB: WARNING!\n" -"InnoDB: The log sequence number in ibdata files is higher\n" -"InnoDB: than the log sequence number in the ib_logfiles! Are you sure\n" -"InnoDB: you are using the right ib_logfiles to start up the database?\n" -"InnoDB: Log sequence number in ib_logfiles is %lu %lu, log\n" -"InnoDB: sequence numbers stamped to ibdata file headers are between\n" -"InnoDB: %lu %lu and %lu %lu.\n" -"InnoDB: ##########################################################\n", - (ulong) ut_dulint_get_high(checkpoint_lsn), - (ulong) ut_dulint_get_low(checkpoint_lsn), - (ulong) ut_dulint_get_high(min_flushed_lsn), - (ulong) ut_dulint_get_low(min_flushed_lsn), - (ulong) ut_dulint_get_high(max_flushed_lsn), - (ulong) ut_dulint_get_low(max_flushed_lsn)); + "InnoDB: #########################" + "#################################\n" + "InnoDB: " + "WARNING!\n" + "InnoDB: The log sequence number" + " in ibdata files is higher\n" + "InnoDB: than the log sequence number" + " in the ib_logfiles! Are you sure\n" + "InnoDB: you are using the right" + " ib_logfiles to start up" + " the database?\n" + "InnoDB: Log sequence number in" + " ib_logfiles is %lu %lu, log\n" + "InnoDB: sequence numbers stamped" + " to ibdata file headers are between\n" + "InnoDB: %lu %lu and %lu %lu.\n" + "InnoDB: #########################" + "#################################\n", + (ulong) ut_dulint_get_high + (checkpoint_lsn), + (ulong) ut_dulint_get_low + (checkpoint_lsn), + (ulong) ut_dulint_get_high + (min_flushed_lsn), + (ulong) ut_dulint_get_low + (min_flushed_lsn), + (ulong) ut_dulint_get_high + (max_flushed_lsn), + (ulong) ut_dulint_get_low + (max_flushed_lsn)); } recv_needed_recovery = TRUE; @@ -2721,11 +2580,13 @@ recv_recovery_from_checkpoint_start( ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Database was not shut down normally!\n" -"InnoDB: Starting crash recovery.\n"); + " InnoDB: Database was not" + " shut down normally!\n" + "InnoDB: Starting crash recovery.\n"); fprintf(stderr, -"InnoDB: Reading tablespace information from the .ibd files...\n"); + "InnoDB: Reading tablespace information" + " from the .ibd files...\n"); fil_load_single_table_tablespaces(); @@ -2737,19 +2598,22 @@ recv_recovery_from_checkpoint_start( if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) { fprintf(stderr, -"InnoDB: Restoring possible half-written data pages from the doublewrite\n" -"InnoDB: buffer...\n"); - trx_sys_doublewrite_init_or_restore_pages( - TRUE); + "InnoDB: Restoring possible" + " half-written data pages from" + " the doublewrite\n" + "InnoDB: buffer...\n"); + trx_sys_doublewrite_init_or_restore_pages + (TRUE); } ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Starting log scan based on checkpoint at\n" -"InnoDB: log sequence number %lu %lu.\n", - (ulong) ut_dulint_get_high(checkpoint_lsn), - (ulong) ut_dulint_get_low(checkpoint_lsn)); + " InnoDB: Starting log scan" + " based on checkpoint at\n" + "InnoDB: log sequence number %lu %lu.\n", + (ulong) ut_dulint_get_high(checkpoint_lsn), + (ulong) ut_dulint_get_low(checkpoint_lsn)); } else { /* Init the doublewrite buffer memory structure */ trx_sys_doublewrite_init_or_restore_pages(FALSE); @@ -2757,7 +2621,7 @@ recv_recovery_from_checkpoint_start( } contiguous_lsn = ut_dulint_align_down(recv_sys->scanned_lsn, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); if (type == LOG_ARCHIVE) { /* Try to recover the remaining part from logs: first from the logs of the archived group */ @@ -2765,10 +2629,11 @@ recv_recovery_from_checkpoint_start( group = recv_sys->archive_group; capacity = log_group_get_capacity(group); - if ((ut_dulint_cmp(recv_sys->scanned_lsn, - ut_dulint_add(checkpoint_lsn, capacity)) > 0) - || (ut_dulint_cmp(checkpoint_lsn, - ut_dulint_add(recv_sys->scanned_lsn, capacity)) > 0)) { + if ((ut_dulint_cmp(recv_sys->scanned_lsn, ut_dulint_add + (checkpoint_lsn, capacity)) > 0) + || (ut_dulint_cmp(checkpoint_lsn, ut_dulint_add + (recv_sys->scanned_lsn, capacity)) + > 0)) { mutex_exit(&(log_sys->mutex)); @@ -2779,7 +2644,7 @@ recv_recovery_from_checkpoint_start( } recv_group_scan_log_recs(group, &contiguous_lsn, - &group_scanned_lsn); + &group_scanned_lsn); if (ut_dulint_cmp(recv_sys->scanned_lsn, checkpoint_lsn) < 0) { mutex_exit(&(log_sys->mutex)); @@ -2809,7 +2674,7 @@ recv_recovery_from_checkpoint_start( old_scanned_lsn = recv_sys->scanned_lsn; recv_group_scan_log_recs(group, &contiguous_lsn, - &group_scanned_lsn); + &group_scanned_lsn); group->scanned_lsn = group_scanned_lsn; if (ut_dulint_cmp(old_scanned_lsn, group_scanned_lsn) < 0) { @@ -2819,7 +2684,7 @@ recv_recovery_from_checkpoint_start( } if ((type == LOG_ARCHIVE) - && (group == recv_sys->archive_group)) { + && (group == recv_sys->archive_group)) { group = UT_LIST_GET_NEXT(log_groups, group); } @@ -2830,25 +2695,29 @@ recv_recovery_from_checkpoint_start( if (ut_dulint_cmp(group_scanned_lsn, checkpoint_lsn) < 0) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: ERROR: We were only able to scan the log up to\n" -"InnoDB: %lu %lu, but a checkpoint was at %lu %lu.\n" -"InnoDB: It is possible that the database is now corrupt!\n", - (ulong) ut_dulint_get_high(group_scanned_lsn), - (ulong) ut_dulint_get_low(group_scanned_lsn), - (ulong) ut_dulint_get_high(checkpoint_lsn), - (ulong) ut_dulint_get_low(checkpoint_lsn)); + " InnoDB: ERROR: We were only able to scan the log" + " up to\n" + "InnoDB: %lu %lu, but a checkpoint was at %lu %lu.\n" + "InnoDB: It is possible that" + " the database is now corrupt!\n", + (ulong) ut_dulint_get_high(group_scanned_lsn), + (ulong) ut_dulint_get_low(group_scanned_lsn), + (ulong) ut_dulint_get_high(checkpoint_lsn), + (ulong) ut_dulint_get_low(checkpoint_lsn)); } if (ut_dulint_cmp(group_scanned_lsn, recv_max_page_lsn) < 0) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: ERROR: We were only able to scan the log up to %lu %lu\n" -"InnoDB: but a database page a had an lsn %lu %lu. It is possible that the\n" -"InnoDB: database is now corrupt!\n", - (ulong) ut_dulint_get_high(group_scanned_lsn), - (ulong) ut_dulint_get_low(group_scanned_lsn), - (ulong) ut_dulint_get_high(recv_max_page_lsn), - (ulong) ut_dulint_get_low(recv_max_page_lsn)); + " InnoDB: ERROR: We were only able to scan the log" + " up to %lu %lu\n" + "InnoDB: but a database page a had an lsn %lu %lu." + " It is possible that the\n" + "InnoDB: database is now corrupt!\n", + (ulong) ut_dulint_get_high(group_scanned_lsn), + (ulong) ut_dulint_get_low(group_scanned_lsn), + (ulong) ut_dulint_get_high(recv_max_page_lsn), + (ulong) ut_dulint_get_low(recv_max_page_lsn)); } if (ut_dulint_cmp(recv_sys->recovered_lsn, checkpoint_lsn) < 0) { @@ -2879,14 +2748,18 @@ recv_recovery_from_checkpoint_start( if (!recv_needed_recovery) { if (ut_dulint_cmp(checkpoint_lsn, recv_sys->recovered_lsn) - != 0) { + != 0) { fprintf(stderr, -"InnoDB: Warning: we did not need to do crash recovery, but log scan\n" -"InnoDB: progressed past the checkpoint lsn %lu %lu up to lsn %lu %lu\n", - (ulong) ut_dulint_get_high(checkpoint_lsn), - (ulong) ut_dulint_get_low(checkpoint_lsn), - (ulong) ut_dulint_get_high(recv_sys->recovered_lsn), - (ulong) ut_dulint_get_low(recv_sys->recovered_lsn)); + "InnoDB: Warning: we did not need to do" + " crash recovery, but log scan\n" + "InnoDB: progressed past the checkpoint" + " lsn %lu %lu up to lsn %lu %lu\n", + (ulong) ut_dulint_get_high(checkpoint_lsn), + (ulong) ut_dulint_get_low(checkpoint_lsn), + (ulong) ut_dulint_get_high + (recv_sys->recovered_lsn), + (ulong) ut_dulint_get_low + (recv_sys->recovered_lsn)); } } else { srv_start_lsn = recv_sys->recovered_lsn; @@ -2897,7 +2770,7 @@ recv_recovery_from_checkpoint_start( ut_memcpy(log_sys->buf, recv_sys->last_block, OS_FILE_LOG_BLOCK_SIZE); log_sys->buf_free = ut_dulint_get_low(log_sys->lsn) - % OS_FILE_LOG_BLOCK_SIZE; + % OS_FILE_LOG_BLOCK_SIZE; log_sys->buf_next_to_write = log_sys->buf_free; log_sys->written_to_some_lsn = log_sys->lsn; log_sys->written_to_all_lsn = log_sys->lsn; @@ -2949,7 +2822,7 @@ recv_recovery_from_checkpoint_finish(void) #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, - "InnoDB: Log records applied to the database\n"); + "InnoDB: Log records applied to the database\n"); } #endif /* UNIV_DEBUG */ @@ -2961,12 +2834,17 @@ recv_recovery_from_checkpoint_finish(void) if (recv_sys->found_corrupt_log) { fprintf(stderr, - "InnoDB: WARNING: the log file may have been corrupt and it\n" - "InnoDB: is possible that the log scan or parsing did not proceed\n" - "InnoDB: far enough in recovery. Please run CHECK TABLE\n" - "InnoDB: on your InnoDB tables to check that they are ok!\n" - "InnoDB: It may be safest to recover your InnoDB database from\n" - "InnoDB: a backup!\n"); + "InnoDB: WARNING: the log file may have been" + " corrupt and it\n" + "InnoDB: is possible that the log scan or parsing" + " did not proceed\n" + "InnoDB: far enough in recovery. Please run" + " CHECK TABLE\n" + "InnoDB: on your InnoDB tables to check that" + " they are ok!\n" + "InnoDB: It may be safest to recover your" + " InnoDB database from\n" + "InnoDB: a backup!\n"); } /* Free the resources of the recovery system */ @@ -2981,7 +2859,7 @@ recv_recovery_from_checkpoint_finish(void) session */ os_thread_create(trx_rollback_or_clean_all_without_sess, - (void *)&i, NULL); + (void *)&i, NULL); } } @@ -3020,7 +2898,7 @@ recv_reset_logs( if (!new_logs_created) { recv_truncate_group(group, group->lsn, group->lsn, - group->lsn, group->lsn); + group->lsn, group->lsn); } group = UT_LIST_GET_NEXT(log_groups, group); @@ -3076,7 +2954,7 @@ recv_reset_log_files_for_backup( log_dir_len = strlen(log_dir); /* full path name of ib_logfile consists of log dir path + basename - + number. This must fit in the name buffer. + + number. This must fit in the name buffer. */ ut_a(log_dir_len + strlen(ib_logfile_basename) + 11 < sizeof(name)); @@ -3089,10 +2967,11 @@ recv_reset_log_files_for_backup( ib_logfile_basename, (ulong)i); log_file = os_file_create_simple(name, OS_FILE_CREATE, - OS_FILE_READ_WRITE, &success); + OS_FILE_READ_WRITE, &success); if (!success) { fprintf(stderr, -"InnoDB: Cannot create %s. Check that the file does not exist yet.\n", name); + "InnoDB: Cannot create %s. Check that" + " the file does not exist yet.\n", name); exit(1); } @@ -3103,13 +2982,14 @@ recv_reset_log_files_for_backup( (ulong) log_file_size & 0xFFFFFFFFUL); success = os_file_set_size(name, log_file, - log_file_size & 0xFFFFFFFFUL, - ut_get_high32(log_file_size)); + log_file_size & 0xFFFFFFFFUL, + ut_get_high32(log_file_size)); if (!success) { fprintf(stderr, -"InnoDB: Cannot set %s size to %lu %lu\n", name, (ulong) ut_get_high32(log_file_size), - (ulong) (log_file_size & 0xFFFFFFFFUL)); + "InnoDB: Cannot set %s size to %lu %lu\n", + name, (ulong) ut_get_high32(log_file_size), + (ulong) (log_file_size & 0xFFFFFFFFUL)); exit(1); } @@ -3123,11 +3003,11 @@ recv_reset_log_files_for_backup( log_block_init_in_old_format(buf + LOG_FILE_HDR_SIZE, lsn); log_block_set_first_rec_group(buf + LOG_FILE_HDR_SIZE, - LOG_BLOCK_HDR_SIZE); + LOG_BLOCK_HDR_SIZE); sprintf(name, "%s%s%lu", log_dir, ib_logfile_basename, (ulong)0); log_file = os_file_create_simple(name, OS_FILE_OPEN, - OS_FILE_READ_WRITE, &success); + OS_FILE_READ_WRITE, &success); if (!success) { fprintf(stderr, "InnoDB: Cannot open %s.\n", name); @@ -3135,7 +3015,7 @@ recv_reset_log_files_for_backup( } os_file_write(name, log_file, buf, 0, 0, - LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE); + LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE); os_file_flush(log_file); os_file_close(log_file); @@ -3178,17 +3058,19 @@ try_open_again: log_archived_file_name_gen(name, group->id, group->archived_file_no); file_handle = os_file_create(name, OS_FILE_OPEN, - OS_FILE_LOG, OS_FILE_AIO, &ret); + OS_FILE_LOG, OS_FILE_AIO, &ret); if (ret == FALSE) { ask_again: fprintf(stderr, - "InnoDB: Do you want to copy additional archived log files\n" - "InnoDB: to the directory\n"); + "InnoDB: Do you want to copy additional" + " archived log files\n" + "InnoDB: to the directory\n"); fprintf(stderr, - "InnoDB: or were these all the files needed in recovery?\n"); + "InnoDB: or were these all the files needed" + " in recovery?\n"); fprintf(stderr, - "InnoDB: (Y == copy more files; N == this is all)?"); + "InnoDB: (Y == copy more files; N == this is all)?"); input_char = getchar(); @@ -3224,29 +3106,30 @@ ask_again: /* Add the archive file as a node to the space */ fil_node_create(name, 1 + file_size / UNIV_PAGE_SIZE, - group->archive_space_id, FALSE); + group->archive_space_id, FALSE); #if RECV_SCAN_SIZE < LOG_FILE_HDR_SIZE # error "RECV_SCAN_SIZE < LOG_FILE_HDR_SIZE" #endif /* Read the archive file header */ fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, group->archive_space_id, 0, 0, - LOG_FILE_HDR_SIZE, buf, NULL); + LOG_FILE_HDR_SIZE, buf, NULL); /* Check if the archive file header is consistent */ if (mach_read_from_4(buf + LOG_GROUP_ID) != group->id - || mach_read_from_4(buf + LOG_FILE_NO) - != group->archived_file_no) { + || mach_read_from_4(buf + LOG_FILE_NO) + != group->archived_file_no) { fprintf(stderr, - "InnoDB: Archive file header inconsistent %s\n", name); + "InnoDB: Archive file header inconsistent %s\n", name); return(TRUE); } if (!mach_read_from_4(buf + LOG_FILE_ARCH_COMPLETED)) { fprintf(stderr, - "InnoDB: Archive file not completely written %s\n", name); + "InnoDB: Archive file not completely written %s\n", + name); return(TRUE); } @@ -3258,7 +3141,8 @@ ask_again: if (ut_dulint_cmp(recv_sys->parse_start_lsn, start_lsn) < 0) { fprintf(stderr, - "InnoDB: Archive log file %s starts from too big a lsn\n", + "InnoDB: Archive log file %s" + " starts from too big a lsn\n", name); return(TRUE); } @@ -3269,8 +3153,9 @@ ask_again: if (ut_dulint_cmp(recv_sys->scanned_lsn, start_lsn) != 0) { fprintf(stderr, - "InnoDB: Archive log file %s starts from a wrong lsn\n", - name); + "InnoDB: Archive log file %s starts from" + " a wrong lsn\n", + name); return(TRUE); } @@ -3281,7 +3166,7 @@ ask_again: if (read_offset + len > file_size) { len = ut_calc_align_down(file_size - read_offset, - OS_FILE_LOG_BLOCK_SIZE); + OS_FILE_LOG_BLOCK_SIZE); } if (len == 0) { @@ -3292,22 +3177,22 @@ ask_again: #ifdef UNIV_DEBUG if (log_debug_writes) { fprintf(stderr, -"InnoDB: Archive read starting at lsn %lu %lu, len %lu from file %s\n", - (ulong) ut_dulint_get_high(start_lsn), - (ulong) ut_dulint_get_low(start_lsn), - (ulong) len, name); + "InnoDB: Archive read starting at" + " lsn %lu %lu, len %lu from file %s\n", + (ulong) ut_dulint_get_high(start_lsn), + (ulong) ut_dulint_get_low(start_lsn), + (ulong) len, name); } #endif /* UNIV_DEBUG */ fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, - group->archive_space_id, read_offset / UNIV_PAGE_SIZE, - read_offset % UNIV_PAGE_SIZE, len, buf, NULL); + group->archive_space_id, read_offset / UNIV_PAGE_SIZE, + read_offset % UNIV_PAGE_SIZE, len, buf, NULL); - ret = recv_scan_log_recs(TRUE, - (buf_pool->n_frames - - recv_n_pool_free_frames) * UNIV_PAGE_SIZE, - TRUE, buf, len, start_lsn, - &dummy_lsn, &scanned_lsn); + ret = recv_scan_log_recs + (TRUE, (buf_pool->n_frames - recv_n_pool_free_frames) + * UNIV_PAGE_SIZE, TRUE, buf, len, start_lsn, + &dummy_lsn, &scanned_lsn); if (ut_dulint_cmp(scanned_lsn, file_end_lsn) == 0) { @@ -3316,7 +3201,8 @@ ask_again: if (ret) { fprintf(stderr, - "InnoDB: Archive log file %s does not scan right\n", + "InnoDB: Archive log file %s" + " does not scan right\n", name); return(TRUE); } @@ -3376,8 +3262,8 @@ recv_recovery_from_archive_start( if (!group) { fprintf(stderr, - "InnoDB: There is no log group defined with id %lu!\n", - (ulong) group_id); + "InnoDB: There is no log group defined with id %lu!\n", + (ulong) group_id); return(DB_ERROR); } @@ -3405,7 +3291,7 @@ recv_recovery_from_archive_start( * fil_space_get_size(group->archive_space_id); if (trunc_len > 0) { fil_space_truncate_start(group->archive_space_id, - trunc_len); + trunc_len); } group->archived_file_no++; @@ -3421,9 +3307,9 @@ recv_recovery_from_archive_start( mutex_exit(&(log_sys->mutex)); err = recv_recovery_from_checkpoint_start(LOG_ARCHIVE, - limit_lsn, - ut_dulint_max, - ut_dulint_max); + limit_lsn, + ut_dulint_max, + ut_dulint_max); if (err != DB_SUCCESS) { return(err); diff --git a/storage/innobase/mem/mem0dbg.c b/storage/innobase/mem/mem0dbg.c index 1220c2c8e82..3cab454e3ac 100644 --- a/storage/innobase/mem/mem0dbg.c +++ b/storage/innobase/mem/mem0dbg.c @@ -103,8 +103,8 @@ mem_field_trailer_set_check(byte* field, ulint check) ulint mem_field_trailer_get_check(byte* field) { - return(mach_read_from_4(field + - mem_field_header_get_len(field))); + return(mach_read_from_4(field + + mem_field_header_get_len(field))); } /********************************************************************** @@ -337,7 +337,8 @@ mem_hash_remove( if (node == NULL) { fprintf(stderr, - "Memory heap or buffer freed in %s line %lu did not exist.\n", + "Memory heap or buffer freed in %s line %lu" + " did not exist.\n", file_name, (ulong) line); ut_error; } @@ -349,18 +350,20 @@ mem_hash_remove( /* Validate the heap which will be freed */ mem_heap_validate_or_print(node->heap, NULL, FALSE, &error, &size, - NULL, NULL); + NULL, NULL); if (error) { fprintf(stderr, - "Inconsistency in memory heap or buffer n:o %lu created\n" - "in %s line %lu and tried to free in %s line %lu.\n" - "Hex dump of 400 bytes around memory heap first block start:\n", + "Inconsistency in memory heap or" + " buffer n:o %lu created\n" + "in %s line %lu and tried to free in %s line %lu.\n" + "Hex dump of 400 bytes around memory heap" + " first block start:\n", node->nth_heap, node->file_name, (ulong) node->line, file_name, (ulong) line); ut_print_buf(stderr, (byte*)node->heap - 200, 400); fputs("\nDump of the mem heap:\n", stderr); mem_heap_validate_or_print(node->heap, NULL, TRUE, &error, - &size, NULL, NULL); + &size, NULL, NULL); ut_error; } @@ -441,10 +444,12 @@ mem_heap_validate_or_print( phys_len += mem_block_get_len(block); if ((block->type == MEM_HEAP_BUFFER) - && (mem_block_get_len(block) > UNIV_PAGE_SIZE)) { + && (mem_block_get_len(block) > UNIV_PAGE_SIZE)) { fprintf(stderr, -"InnoDB: Error: mem block %p length %lu > UNIV_PAGE_SIZE\n", (void*) block, + "InnoDB: Error: mem block %p" + " length %lu > UNIV_PAGE_SIZE\n", + (void*) block, (ulong) mem_block_get_len(block)); /* error */ @@ -481,15 +486,19 @@ mem_heap_validate_or_print( total_len += len; check_field = mem_field_header_get_check(user_field); - if (check_field != - mem_field_trailer_get_check(user_field)) { + if (check_field + != mem_field_trailer_get_check(user_field)) { /* error */ fprintf(stderr, -"InnoDB: Error: block %lx mem field %lx len %lu\n" -"InnoDB: header check field is %lx but trailer %lx\n", (ulint)block, - (ulint)field, len, check_field, - mem_field_trailer_get_check(user_field)); + "InnoDB: Error: block %lx mem" + " field %lx len %lu\n" + "InnoDB: header check field is" + " %lx but trailer %lx\n", + (ulint)block, + (ulint)field, len, check_field, + mem_field_trailer_get_check + (user_field)); return; } @@ -511,9 +520,12 @@ mem_heap_validate_or_print( /* error */ fprintf(stderr, -"InnoDB: Error: block %lx end of mem fields %lx\n" -"InnoDB: but block free at %lx\n", (ulint)block, (ulint)field, - (ulint)((byte*)block + mem_block_get_free(block))); + "InnoDB: Error: block %lx end of" + " mem fields %lx\n" + "InnoDB: but block free at %lx\n", + (ulint)block, (ulint)field, + (ulint)((byte*)block + + mem_block_get_free(block))); return; } @@ -554,11 +566,12 @@ mem_heap_print( ut_ad(mem_heap_check(heap)); mem_heap_validate_or_print(heap, NULL, TRUE, &error, - &us_size, &phys_size, &n_blocks); + &us_size, &phys_size, &n_blocks); fprintf(stderr, - "\nheap type: %lu; size: user size %lu; physical size %lu; blocks %lu.\n", - (ulong) heap->type, (ulong) us_size, - (ulong) phys_size, (ulong) n_blocks); + "\nheap type: %lu; size: user size %lu;" + " physical size %lu; blocks %lu.\n", + (ulong) heap->type, (ulong) us_size, + (ulong) phys_size, (ulong) n_blocks); ut_a(!error); } @@ -593,7 +606,7 @@ mem_heap_validate( ut_ad(mem_heap_check(heap)); mem_heap_validate_or_print(heap, NULL, FALSE, &error, &us_size, - &phys_size, &n_blocks); + &phys_size, &n_blocks); if (error) { mem_heap_print(heap); } @@ -670,14 +683,17 @@ mem_validate_no_assert(void) n_heaps++; mem_heap_validate_or_print(node->heap, NULL, - FALSE, &error, &allocated_mem, - &ph_size, &n_blocks); + FALSE, &error, + &allocated_mem, + &ph_size, &n_blocks); if (error) { fprintf(stderr, - "\nERROR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n" - "Inconsistency in memory heap or buffer created\n" - "in %s line %lu.\n", + "\nERROR!!!!!!!!!!!!!!!!!!!" + "!!!!!!!!!!!!!!!!!!!!!!!\n\n" + "Inconsistency in memory heap" + " or buffer created\n" + "in %s line %lu.\n", node->file_name, node->line); mutex_exit(&mem_hash_mutex); @@ -741,7 +757,8 @@ mem_analyze_corruption( fputs("InnoDB: Apparent memory corruption: mem dump ", stderr); ut_print_buf(stderr, (byte*)ptr - 250, 500); - fputs("\nInnoDB: Scanning backward trying to find previous allocated mem blocks\n", stderr); + fputs("\nInnoDB: Scanning backward trying to find" + " previous allocated mem blocks\n", stderr); p = (byte*)ptr; dist = 0; @@ -752,18 +769,26 @@ mem_analyze_corruption( if (*((ulint*)p) == MEM_BLOCK_MAGIC_N) { fprintf(stderr, - "Mem block at - %lu, file %s, line %lu\n", - (ulong) dist, (p + sizeof(ulint)), - (ulong) (*(ulint*)(p + 8 + sizeof(ulint)))); + "Mem block at - %lu," + " file %s, line %lu\n", + (ulong) dist, + (p + sizeof(ulint)), + (ulong) + (*(ulint*)(p + 8 + + sizeof(ulint)))); break; } if (*((ulint*)p) == MEM_FREED_BLOCK_MAGIC_N) { fprintf(stderr, - "Freed mem block at - %lu, file %s, line %lu\n", - (ulong) dist, (p + sizeof(ulint)), - (ulong) (*(ulint*)(p + 8 + sizeof(ulint)))); + "Freed mem block at - %lu," + " file %s, line %lu\n", + (ulong) dist, + (p + sizeof(ulint)), + (ulong) + (*(ulint*)(p + 8 + + sizeof(ulint)))); break; } @@ -778,7 +803,8 @@ mem_analyze_corruption( } fprintf(stderr, - "InnoDB: Scanning forward trying to find next allocated mem blocks\n"); + "InnoDB: Scanning forward trying to find next" + " allocated mem blocks\n"); p = (byte*)ptr; dist = 0; @@ -789,18 +815,26 @@ mem_analyze_corruption( if (*((ulint*)p) == MEM_BLOCK_MAGIC_N) { fprintf(stderr, - "Mem block at + %lu, file %s, line %lu\n", - (ulong) dist, (p + sizeof(ulint)), - (ulong) (*(ulint*)(p + 8 + sizeof(ulint)))); + "Mem block at + %lu, file %s," + " line %lu\n", + (ulong) dist, + (p + sizeof(ulint)), + (ulong) + (*(ulint*)(p + 8 + + sizeof(ulint)))); break; } if (*((ulint*)p) == MEM_FREED_BLOCK_MAGIC_N) { fprintf(stderr, - "Freed mem block at + %lu, file %s, line %lu\n", - (ulong) dist, (p + sizeof(ulint)), - (ulong) (*(ulint*)(p + 8 + sizeof(ulint)))); + "Freed mem block at + %lu," + " file %s, line %lu\n", + (ulong) dist, + (p + sizeof(ulint)), + (ulong) + (*(ulint*)(p + 8 + + sizeof(ulint)))); break; } @@ -878,33 +912,34 @@ mem_print_info_low( } mem_heap_validate_or_print(node->heap, NULL, - FALSE, &error, &allocated_mem, - &ph_size, &n_blocks); + FALSE, &error, &allocated_mem, + &ph_size, &n_blocks); total_allocated_mem += allocated_mem; fprintf(outfile, - "%lu: file %s line %lu of size %lu phys.size %lu with %lu blocks, type %lu\n", - node->nth_heap, node->file_name, node->line, - allocated_mem, ph_size, n_blocks, - (node->heap)->type); - next_heap: + "%lu: file %s line %lu of size %lu phys.size %lu" + " with %lu blocks, type %lu\n", + node->nth_heap, node->file_name, node->line, + allocated_mem, ph_size, n_blocks, + (node->heap)->type); +next_heap: node = UT_LIST_GET_NEXT(all_list, node); } fprintf(outfile, "\n"); fprintf(outfile, "Current allocated memory : %lu\n", - mem_current_allocated_memory); + mem_current_allocated_memory); fprintf(outfile, "Current allocated heaps and buffers : %lu\n", - n_heaps); + n_heaps); fprintf(outfile, "Cumulative allocated memory : %lu\n", - mem_total_allocated_memory); + mem_total_allocated_memory); fprintf(outfile, "Maximum allocated memory : %lu\n", - mem_max_allocated_memory); + mem_max_allocated_memory); fprintf(outfile, "Cumulative created heaps and buffers : %lu\n", - mem_n_created_heaps); + mem_n_created_heaps); fprintf(outfile, "Cumulative number of allocations : %lu\n", - mem_n_allocations); + mem_n_allocations); mem_last_print_info = mem_n_created_heaps; @@ -912,9 +947,9 @@ mem_print_info_low( mem_pool_print_info(outfile, mem_comm_pool); -/* mem_validate(); */ + /* mem_validate(); */ -/* fclose(outfile); */ + /* fclose(outfile); */ #endif } diff --git a/storage/innobase/mem/mem0mem.c b/storage/innobase/mem/mem0mem.c index b11b574d80d..10b359e8e67 100644 --- a/storage/innobase/mem/mem0mem.c +++ b/storage/innobase/mem/mem0mem.c @@ -342,7 +342,7 @@ mem_heap_create_block( ulint len; ut_ad((type == MEM_HEAP_DYNAMIC) || (type == MEM_HEAP_BUFFER) - || (type == MEM_HEAP_BUFFER + MEM_HEAP_BTR_SEARCH)); + || (type == MEM_HEAP_BUFFER + MEM_HEAP_BTR_SEARCH)); if (heap && heap->magic_n != MEM_BLOCK_MAGIC_N) { mem_analyze_corruption(heap); @@ -463,7 +463,7 @@ mem_heap_add_block( } new_block = mem_heap_create_block(heap, new_size, NULL, heap->type, - heap->file_name, heap->line); + heap->file_name, heap->line); if (new_block == NULL) { return(NULL); diff --git a/storage/innobase/mem/mem0pool.c b/storage/innobase/mem/mem0pool.c index 5606921758c..91e7532aba8 100644 --- a/storage/innobase/mem/mem0pool.c +++ b/storage/innobase/mem/mem0pool.c @@ -145,7 +145,7 @@ mem_area_set_size( ulint size) /* in: size */ { area->size_and_free = (area->size_and_free & MEM_AREA_FREE) - | size; + | size; } /************************************************************************ @@ -176,7 +176,7 @@ mem_area_set_free( # error "TRUE != MEM_AREA_FREE" #endif area->size_and_free = (area->size_and_free & ~MEM_AREA_FREE) - | free; + | free; } /************************************************************************ @@ -276,10 +276,12 @@ mem_pool_fill_free_list( ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: mem pool free list %lu length is %lu\n" -"InnoDB: though the list is empty!\n", - (ulong) i + 1, - (ulong) UT_LIST_GET_LEN(pool->free_list[i + 1])); + " InnoDB: Error: mem pool free list %lu" + " length is %lu\n" + "InnoDB: though the list is empty!\n", + (ulong) i + 1, + (ulong) + UT_LIST_GET_LEN(pool->free_list[i + 1])); } ret = mem_pool_fill_free_list(i + 1, pool); @@ -358,8 +360,9 @@ mem_area_alloc( if (!mem_area_get_free(area)) { fprintf(stderr, -"InnoDB: Error: Removing element from mem pool free list %lu though the\n" -"InnoDB: element is not marked free!\n", + "InnoDB: Error: Removing element from mem pool" + " free list %lu though the\n" + "InnoDB: element is not marked free!\n", (ulong) n); mem_analyze_corruption(area); @@ -370,7 +373,8 @@ mem_area_alloc( if (mem_area_get_free(area)) { fprintf(stderr, -"InnoDB: Probably a race condition because now the area is marked free!\n"); + "InnoDB: Probably a race condition" + " because now the area is marked free!\n"); } ut_error; @@ -378,8 +382,9 @@ mem_area_alloc( if (UT_LIST_GET_LEN(pool->free_list[n]) == 0) { fprintf(stderr, -"InnoDB: Error: Removing element from mem pool free list %lu\n" -"InnoDB: though the list length is 0!\n", + "InnoDB: Error: Removing element from mem pool" + " free list %lu\n" + "InnoDB: though the list length is 0!\n", (ulong) n); mem_analyze_corruption(area); @@ -471,8 +476,9 @@ mem_area_free( if (mem_area_get_free(area)) { fprintf(stderr, -"InnoDB: Error: Freeing element to mem pool free list though the\n" -"InnoDB: element is marked free!\n"); + "InnoDB: Error: Freeing element to mem pool" + " free list though the\n" + "InnoDB: element is marked free!\n"); mem_analyze_corruption(area); ut_error; @@ -482,8 +488,9 @@ mem_area_free( if (size == 0) { fprintf(stderr, -"InnoDB: Error: Mem area size is 0. Possibly a memory overrun of the\n" -"InnoDB: previous allocated area!\n"); + "InnoDB: Error: Mem area size is 0. Possibly a" + " memory overrun of the\n" + "InnoDB: previous allocated area!\n"); mem_analyze_corruption(area); ut_error; @@ -494,13 +501,15 @@ mem_area_free( ulint next_size; - next_size = mem_area_get_size( - (mem_area_t*)(((byte*)area) + size)); + next_size = mem_area_get_size + ((mem_area_t*)(((byte*)area) + size)); if (ut_2_power_up(next_size) != next_size) { fprintf(stderr, -"InnoDB: Error: Memory area size %lu, next area size %lu not a power of 2!\n" -"InnoDB: Possibly a memory overrun of the buffer being freed here.\n", - (ulong) size, (ulong) next_size); + "InnoDB: Error: Memory area size %lu," + " next area size %lu not a power of 2!\n" + "InnoDB: Possibly a memory overrun of" + " the buffer being freed here.\n", + (ulong) size, (ulong) next_size); mem_analyze_corruption(area); ut_error; @@ -517,7 +526,7 @@ mem_area_free( ut_a(mem_n_threads_inside == 1); if (buddy && mem_area_get_free(buddy) - && (size == mem_area_get_size(buddy))) { + && (size == mem_area_get_size(buddy))) { /* The buddy is in a free list */ @@ -591,7 +600,7 @@ mem_pool_validate( buddy = mem_area_get_buddy(area, ut_2_exp(i), pool); ut_a(!buddy || !mem_area_get_free(buddy) - || (ut_2_exp(i) != mem_area_get_size(buddy))); + || (ut_2_exp(i) != mem_area_get_size(buddy))); area = UT_LIST_GET_NEXT(free_list, area); @@ -627,9 +636,10 @@ mem_pool_print_info( if (UT_LIST_GET_LEN(pool->free_list[i]) > 0) { fprintf(outfile, - "Free list length %lu for blocks of size %lu\n", - (ulong) UT_LIST_GET_LEN(pool->free_list[i]), - (ulong) ut_2_exp(i)); + "Free list length %lu for" + " blocks of size %lu\n", + (ulong) UT_LIST_GET_LEN(pool->free_list[i]), + (ulong) ut_2_exp(i)); } } diff --git a/storage/innobase/mtr/mtr0log.c b/storage/innobase/mtr/mtr0log.c index c47c73e188b..ba5284d9169 100644 --- a/storage/innobase/mtr/mtr0log.c +++ b/storage/innobase/mtr/mtr0log.c @@ -59,7 +59,8 @@ mlog_write_initial_log_record( if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) { fprintf(stderr, - "InnoDB: Error: trying to write to a stray memory location %p\n", ptr); + "InnoDB: Error: trying to write to" + " a stray memory location %p\n", (void*) ptr); ut_error; } @@ -222,7 +223,8 @@ mlog_write_ulint( if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) { fprintf(stderr, - "InnoDB: Error: trying to write to a stray memory location %p\n", ptr); + "InnoDB: Error: trying to write to" + " a stray memory location %p\n", (void*) ptr); ut_error; } @@ -266,9 +268,11 @@ mlog_write_dulint( { byte* log_ptr; - if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) { + if (UNIV_UNLIKELY(ptr < buf_pool->frame_zero) + || UNIV_UNLIKELY(ptr >= buf_pool->high_end)) { fprintf(stderr, - "InnoDB: Error: trying to write to a stray memory location %p\n", ptr); + "InnoDB: Error: trying to write to" + " a stray memory location %p\n", (void*) ptr); ut_error; } @@ -285,7 +289,7 @@ mlog_write_dulint( } log_ptr = mlog_write_initial_log_record_fast(ptr, MLOG_8BYTES, - log_ptr, mtr); + log_ptr, mtr); mach_write_to_2(log_ptr, ptr - buf_frame_align(ptr)); log_ptr += 2; @@ -310,9 +314,10 @@ mlog_write_string( byte* log_ptr; if (UNIV_UNLIKELY(ptr < buf_pool->frame_zero) - || UNIV_UNLIKELY(ptr >= buf_pool->high_end)) { + || UNIV_UNLIKELY(ptr >= buf_pool->high_end)) { fprintf(stderr, - "InnoDB: Error: trying to write to a stray memory location %p\n", ptr); + "InnoDB: Error: trying to write to" + " a stray memory location %p\n", (void*) ptr); ut_error; } ut_ad(ptr && mtr); @@ -329,7 +334,7 @@ mlog_write_string( } log_ptr = mlog_write_initial_log_record_fast(ptr, MLOG_WRITE_STRING, - log_ptr, mtr); + log_ptr, mtr); mach_write_to_2(log_ptr, ptr - buf_frame_align(ptr)); log_ptr += 2; @@ -415,7 +420,7 @@ mlog_open_and_write_index( return(NULL); /* logging is disabled */ } log_ptr = mlog_write_initial_log_record_fast(rec, type, - log_ptr, mtr); + log_ptr, mtr); log_end = log_ptr + 11 + size; } else { ulint i; @@ -433,7 +438,7 @@ mlog_open_and_write_index( } log_end = log_ptr + alloc; log_ptr = mlog_write_initial_log_record_fast(rec, type, - log_ptr, mtr); + log_ptr, mtr); mach_write_to_2(log_ptr, n); log_ptr += 2; mach_write_to_2(log_ptr, @@ -447,7 +452,8 @@ mlog_open_and_write_index( type = dict_col_get_type(dict_field_get_col(field)); len = field->fixed_len; ut_ad(len < 0x7fff); - if (len == 0 && (dtype_get_len(type) > 255 + if (len == 0 + && (dtype_get_len(type) > 255 || dtype_get_mtype(type) == DATA_BLOB)) { /* variable-length field with maximum length > 255 */ @@ -519,9 +525,9 @@ mlog_parse_index( n = n_uniq = 1; } table = dict_mem_table_create("LOG_DUMMY", DICT_HDR_SPACE, n, - comp ? DICT_TF_COMPACT : 0); + comp ? DICT_TF_COMPACT : 0); ind = dict_mem_index_create("LOG_DUMMY", "LOG_DUMMY", - DICT_HDR_SPACE, 0, n); + DICT_HDR_SPACE, 0, n); ind->table = table; ind->n_uniq = n_uniq; if (n_uniq != n) { @@ -535,14 +541,14 @@ mlog_parse_index( /* The high-order bit of len is the NOT NULL flag; the rest is 0 or 0x7fff for variable-length fields, and 1..0x7ffe for fixed-length fields. */ - dict_mem_table_add_col(table, "DUMMY", - ((len + 1) & 0x7fff) <= 1 - ? DATA_BINARY - : DATA_FIXBINARY, - len & 0x8000 ? DATA_NOT_NULL : 0, - len & 0x7fff, 0); - dict_index_add_col(ind, - dict_table_get_nth_col(table, i), 0); + dict_mem_table_add_col + (table, "DUMMY", + ((len + 1) & 0x7fff) <= 1 + ? DATA_BINARY : DATA_FIXBINARY, + len & 0x8000 ? DATA_NOT_NULL : 0, + len & 0x7fff, 0); + dict_index_add_col + (ind, dict_table_get_nth_col(table, i), 0); } ptr += 2; } diff --git a/storage/innobase/mtr/mtr0mtr.c b/storage/innobase/mtr/mtr0mtr.c index c27a97f6028..13c579c646b 100644 --- a/storage/innobase/mtr/mtr0mtr.c +++ b/storage/innobase/mtr/mtr0mtr.c @@ -90,7 +90,7 @@ mtr_memo_pop_all( ut_ad(mtr); ut_ad(mtr->magic_n == MTR_MAGIC_N); ut_ad(mtr->state == MTR_COMMITTING); /* Currently only used in - commit */ + commit */ memo = &(mtr->memo); offset = dyn_array_get_data_size(memo); @@ -126,13 +126,14 @@ mtr_log_reserve_and_write( if (mtr->n_log_recs > 1) { mlog_catenate_ulint(mtr, MLOG_MULTI_REC_END, MLOG_1BYTE); } else { - *first_data = (byte)((ulint)*first_data | MLOG_SINGLE_REC_FLAG); + *first_data = (byte)((ulint)*first_data + | MLOG_SINGLE_REC_FLAG); } if (mlog->heap == NULL) { - mtr->end_lsn = log_reserve_and_write_fast(first_data, - dyn_block_get_used(mlog), - &(mtr->start_lsn), &success); + mtr->end_lsn = log_reserve_and_write_fast + (first_data, dyn_block_get_used(mlog), + &(mtr->start_lsn), &success); if (success) { return; @@ -150,7 +151,7 @@ mtr_log_reserve_and_write( while (block != NULL) { log_write_low(dyn_block_get_data(block), - dyn_block_get_used(block)); + dyn_block_get_used(block)); block = dyn_array_get_next_block(mlog, block); } } else { @@ -284,9 +285,9 @@ mtr_read_ulint( { ut_ad(mtr->state == MTR_ACTIVE); ut_ad(mtr_memo_contains(mtr, buf_block_align(ptr), - MTR_MEMO_PAGE_S_FIX) || - mtr_memo_contains(mtr, buf_block_align(ptr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_S_FIX) + || mtr_memo_contains(mtr, buf_block_align(ptr), + MTR_MEMO_PAGE_X_FIX)); if (type == MLOG_1BYTE) { return(mach_read_from_1(ptr)); } else if (type == MLOG_2BYTES) { @@ -311,9 +312,9 @@ mtr_read_dulint( ut_ad(mtr->state == MTR_ACTIVE); ut_ad(ptr && mtr); ut_ad(mtr_memo_contains(mtr, buf_block_align(ptr), - MTR_MEMO_PAGE_S_FIX) || - mtr_memo_contains(mtr, buf_block_align(ptr), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_S_FIX) + || mtr_memo_contains(mtr, buf_block_align(ptr), + MTR_MEMO_PAGE_X_FIX)); return(mach_read_from_8(ptr)); } @@ -326,7 +327,8 @@ mtr_print( mtr_t* mtr) /* in: mtr */ { fprintf(stderr, - "Mini-transaction handle: memo size %lu bytes log size %lu bytes\n", + "Mini-transaction handle: memo size %lu bytes" + " log size %lu bytes\n", (ulong) dyn_array_get_data_size(&(mtr->memo)), (ulong) dyn_array_get_data_size(&(mtr->log))); } diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 3aebf20ac41..65903717cfb 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -224,31 +224,39 @@ os_file_get_last_error( err = (ulint) GetLastError(); if (report_all_errors - || (err != ERROR_DISK_FULL && err != ERROR_FILE_EXISTS)) { + || (err != ERROR_DISK_FULL && err != ERROR_FILE_EXISTS)) { ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Operating system error number %lu in a file operation.\n", (ulong) err); + " InnoDB: Operating system error number %lu" + " in a file operation.\n", (ulong) err); if (err == ERROR_PATH_NOT_FOUND) { fprintf(stderr, - "InnoDB: The error means the system cannot find the path specified.\n"); + "InnoDB: The error means the system" + " cannot find the path specified.\n"); if (srv_is_being_started) { fprintf(stderr, - "InnoDB: If you are installing InnoDB, remember that you must create\n" - "InnoDB: directories yourself, InnoDB does not create them.\n"); + "InnoDB: If you are installing InnoDB," + " remember that you must create\n" + "InnoDB: directories yourself, InnoDB" + " does not create them.\n"); } } else if (err == ERROR_ACCESS_DENIED) { fprintf(stderr, - "InnoDB: The error means mysqld does not have the access rights to\n" - "InnoDB: the directory. It may also be you have created a subdirectory\n" - "InnoDB: of the same name as a data file.\n"); + "InnoDB: The error means mysqld does not have" + " the access rights to\n" + "InnoDB: the directory. It may also be" + " you have created a subdirectory\n" + "InnoDB: of the same name as a data file.\n"); } else { fprintf(stderr, - "InnoDB: Some operating system error numbers are described at\n" - "InnoDB: " - "http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n"); + "InnoDB: Some operating system error numbers" + " are described at\n" + "InnoDB: " + "http://dev.mysql.com/doc/refman/5.1/en/" + "operating-system-error-codes.html\n"); } } @@ -267,35 +275,44 @@ os_file_get_last_error( err = (ulint) errno; if (report_all_errors - || (err != ENOSPC && err != EEXIST)) { + || (err != ENOSPC && err != EEXIST)) { ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Operating system error number %lu in a file operation.\n", (ulong) err); + " InnoDB: Operating system error number %lu" + " in a file operation.\n", (ulong) err); if (err == ENOENT) { fprintf(stderr, - "InnoDB: The error means the system cannot find the path specified.\n"); + "InnoDB: The error means the system" + " cannot find the path specified.\n"); if (srv_is_being_started) { fprintf(stderr, - "InnoDB: If you are installing InnoDB, remember that you must create\n" - "InnoDB: directories yourself, InnoDB does not create them.\n"); + "InnoDB: If you are installing InnoDB," + " remember that you must create\n" + "InnoDB: directories yourself, InnoDB" + " does not create them.\n"); } } else if (err == EACCES) { fprintf(stderr, - "InnoDB: The error means mysqld does not have the access rights to\n" - "InnoDB: the directory.\n"); + "InnoDB: The error means mysqld does not have" + " the access rights to\n" + "InnoDB: the directory.\n"); } else { if (strerror((int)err) != NULL) { fprintf(stderr, - "InnoDB: Error number %lu means '%s'.\n", err, strerror((int)err)); + "InnoDB: Error number %lu" + " means '%s'.\n", + err, strerror((int)err)); } fprintf(stderr, - "InnoDB: Some operating system error numbers are described at\n" - "InnoDB: " - "http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n"); + "InnoDB: Some operating system" + " error numbers are described at\n" + "InnoDB: " + "http://dev.mysql.com/doc/refman/5.1/en/" + "operating-system-error-codes.html\n"); } } @@ -345,12 +362,14 @@ os_file_handle_error( if (name) { ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Encountered a problem with file %s\n", name); + " InnoDB: Encountered a problem with" + " file %s\n", name); } ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Disk is full. Try to clean the disk to free space.\n"); + " InnoDB: Disk is full. Try to clean the disk" + " to free space.\n"); os_has_said_disk_full = TRUE; @@ -363,7 +382,7 @@ os_file_handle_error( return(TRUE); } else if (err == OS_FILE_ALREADY_EXISTS - || err == OS_FILE_PATH_ERROR) { + || err == OS_FILE_PATH_ERROR) { return(FALSE); } else { @@ -413,8 +432,10 @@ os_file_lock( if (errno == EAGAIN || errno == EACCES) { fprintf(stderr, -"InnoDB: Check that you do not already have another mysqld process\n" -"InnoDB: using the same InnoDB data or log files.\n"); + "InnoDB: Check that you do not already have" + " another mysqld process\n" + "InnoDB: using the same InnoDB data" + " or log files.\n"); } return(-1); @@ -450,12 +471,14 @@ os_file_handle_error_no_exit( if (name) { ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Encountered a problem with file %s\n", name); + " InnoDB: Encountered a problem with" + " file %s\n", name); } ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Disk is full. Try to clean the disk to free space.\n"); + " InnoDB: Disk is full. Try to clean the disk" + " to free space.\n"); os_has_said_disk_full = TRUE; @@ -468,7 +491,7 @@ os_file_handle_error_no_exit( return(TRUE); } else if (err == OS_FILE_ALREADY_EXISTS - || err == OS_FILE_PATH_ERROR) { + || err == OS_FILE_PATH_ERROR) { return(FALSE); } else { @@ -670,10 +693,11 @@ next_file: ret = FindNextFile(dir, lpFindFileData); if (ret) { - ut_a(strlen((char *) lpFindFileData->cFileName) < OS_FILE_MAX_PATH); + ut_a(strlen((char *) lpFindFileData->cFileName) + < OS_FILE_MAX_PATH); if (strcmp((char *) lpFindFileData->cFileName, ".") == 0 - || strcmp((char *) lpFindFileData->cFileName, "..") == 0) { + || strcmp((char *) lpFindFileData->cFileName, "..") == 0) { goto next_file; } @@ -681,17 +705,20 @@ next_file: strcpy(info->name, (char *) lpFindFileData->cFileName); info->size = (ib_longlong)(lpFindFileData->nFileSizeLow) - + (((ib_longlong)(lpFindFileData->nFileSizeHigh)) << 32); + + (((ib_longlong)(lpFindFileData->nFileSizeHigh)) + << 32); if (lpFindFileData->dwFileAttributes - & FILE_ATTRIBUTE_REPARSE_POINT) { -/* TODO: test Windows symlinks */ -/* TODO: MySQL has apparently its own symlink implementation in Windows, -dbname.sym can redirect a database directory: -http://dev.mysql.com/doc/refman/5.1/en/windows-symbolic-links.html */ + & FILE_ATTRIBUTE_REPARSE_POINT) { + /* TODO: test Windows symlinks */ + /* TODO: MySQL has apparently its own symlink + implementation in Windows, dbname.sym can + redirect a database directory: + http://dev.mysql.com/doc/refman/5.1/en/ + windows-symbolic-links.html */ info->type = OS_FILE_TYPE_LINK; } else if (lpFindFileData->dwFileAttributes - & FILE_ATTRIBUTE_DIRECTORY) { + & FILE_ATTRIBUTE_DIRECTORY) { info->type = OS_FILE_TYPE_DIR; } else { /* It is probably safest to assume that all other @@ -711,7 +738,7 @@ http://dev.mysql.com/doc/refman/5.1/en/windows-symbolic-links.html */ return(1); } else { os_file_handle_error_no_exit(dirname, - "readdir_next_file"); + "readdir_next_file"); return(-1); } #else @@ -720,11 +747,11 @@ http://dev.mysql.com/doc/refman/5.1/en/windows-symbolic-links.html */ int ret; struct stat statinfo; #ifdef HAVE_READDIR_R - char dirent_buf[sizeof(struct dirent) + _POSIX_PATH_MAX + - 100]; - /* In /mysys/my_lib.c, _POSIX_PATH_MAX + 1 is used as - the max file name len; but in most standards, the - length is NAME_MAX; we add 100 to be even safer */ + char dirent_buf[sizeof(struct dirent) + + _POSIX_PATH_MAX + 100]; + /* In /mysys/my_lib.c, _POSIX_PATH_MAX + 1 is used as + the max file name len; but in most standards, the + length is NAME_MAX; we add 100 to be even safer */ #endif next_file: @@ -734,7 +761,8 @@ next_file: if (ret != 0) { fprintf(stderr, -"InnoDB: cannot read directory %s, error %lu\n", dirname, (ulong)ret); + "InnoDB: cannot read directory %s, error %lu\n", + dirname, (ulong)ret); return(-1); } @@ -815,8 +843,9 @@ os_file_create_directory( BOOL rcode; rcode = CreateDirectory((LPCTSTR) pathname, NULL); - if (!(rcode != 0 || - (GetLastError() == ERROR_ALREADY_EXISTS && !fail_if_exists))) { + if (!(rcode != 0 + || (GetLastError() == ERROR_ALREADY_EXISTS + && !fail_if_exists))) { /* failure */ os_file_handle_error(pathname, "CreateDirectory"); @@ -899,21 +928,21 @@ try_again: } file = CreateFile((LPCTSTR) name, - access, - FILE_SHARE_READ | FILE_SHARE_WRITE, - /* file can be read ansd written also - by other processes */ - NULL, /* default security attributes */ - create_flag, - attributes, - NULL); /* no template file */ + access, + FILE_SHARE_READ | FILE_SHARE_WRITE, + /* file can be read ansd written also + by other processes */ + NULL, /* default security attributes */ + create_flag, + attributes, + NULL); /* no template file */ if (file == INVALID_HANDLE_VALUE) { *success = FALSE; retry = os_file_handle_error(name, - create_mode == OS_FILE_OPEN ? - "open" : "create"); + create_mode == OS_FILE_OPEN ? + "open" : "create"); if (retry) { goto try_again; } @@ -953,7 +982,7 @@ try_again: if (create_mode == OS_FILE_CREATE) { file = open(name, create_flag, S_IRUSR | S_IWUSR - | S_IRGRP | S_IWGRP); + | S_IRGRP | S_IWGRP); } else { file = open(name, create_flag); } @@ -962,14 +991,14 @@ try_again: *success = FALSE; retry = os_file_handle_error(name, - create_mode == OS_FILE_OPEN ? - "open" : "create"); + create_mode == OS_FILE_OPEN ? + "open" : "create"); if (retry) { goto try_again; } #ifdef USE_FILE_LOCK } else if (access_type == OS_FILE_READ_WRITE - && os_file_lock(file, name)) { + && os_file_lock(file, name)) { *success = FALSE; close(file); file = -1; @@ -1028,7 +1057,7 @@ os_file_create_simple_no_error_handling( } else if (access_type == OS_FILE_READ_ALLOW_DELETE) { access = GENERIC_READ; share_mode = FILE_SHARE_DELETE | FILE_SHARE_READ - | FILE_SHARE_WRITE; /* A backup program has to give + | FILE_SHARE_WRITE; /* A backup program has to give mysqld the maximum freedom to do what it likes with the file */ @@ -1038,12 +1067,12 @@ os_file_create_simple_no_error_handling( } file = CreateFile((LPCTSTR) name, - access, - share_mode, - NULL, /* default security attributes */ - create_flag, - attributes, - NULL); /* no template file */ + access, + share_mode, + NULL, /* default security attributes */ + create_flag, + attributes, + NULL); /* no template file */ if (file == INVALID_HANDLE_VALUE) { *success = FALSE; @@ -1073,7 +1102,7 @@ os_file_create_simple_no_error_handling( if (create_mode == OS_FILE_CREATE) { file = open(name, create_flag, S_IRUSR | S_IWUSR - | S_IRGRP | S_IWGRP); + | S_IRGRP | S_IWGRP); } else { file = open(name, create_flag); } @@ -1082,7 +1111,7 @@ os_file_create_simple_no_error_handling( *success = FALSE; #ifdef USE_FILE_LOCK } else if (access_type == OS_FILE_READ_WRITE - && os_file_lock(file, name)) { + && os_file_lock(file, name)) { *success = FALSE; close(file); file = -1; @@ -1137,7 +1166,7 @@ try_again: create_flag = OPEN_EXISTING; share_mode = FILE_SHARE_WRITE; } else if (create_mode == OS_FILE_OPEN - || create_mode == OS_FILE_OPEN_RETRY) { + || create_mode == OS_FILE_OPEN_RETRY) { create_flag = OPEN_EXISTING; } else if (create_mode == OS_FILE_CREATE) { create_flag = CREATE_NEW; @@ -1162,8 +1191,8 @@ try_again: /* Do not use unbuffered i/o to log files because value 2 denotes that we do not flush the log at every commit, but only once per second */ - } else if (srv_win_file_flush_method == - SRV_WIN_IO_UNBUFFERED) { + } else if (srv_win_file_flush_method + == SRV_WIN_IO_UNBUFFERED) { attributes = attributes | FILE_FLAG_NO_BUFFERING; } #endif @@ -1174,8 +1203,8 @@ try_again: /* Do not use unbuffered i/o to log files because value 2 denotes that we do not flush the log at every commit, but only once per second */ - } else if (srv_win_file_flush_method == - SRV_WIN_IO_UNBUFFERED) { + } else if (srv_win_file_flush_method + == SRV_WIN_IO_UNBUFFERED) { attributes = attributes | FILE_FLAG_NO_BUFFERING; } #endif @@ -1185,9 +1214,9 @@ try_again: } file = CreateFile((LPCTSTR) name, - GENERIC_READ | GENERIC_WRITE, /* read and write + GENERIC_READ | GENERIC_WRITE, /* read and write access */ - share_mode, /* File can be read also by other + share_mode, /* File can be read also by other processes; we must give the read permission because of ibbackup. We do not give the write permission to @@ -1198,17 +1227,17 @@ try_again: raw disk partitions, Microsoft manuals say that we must give also the write permission. */ - NULL, /* default security attributes */ - create_flag, - attributes, - NULL); /* no template file */ + NULL, /* default security attributes */ + create_flag, + attributes, + NULL); /* no template file */ if (file == INVALID_HANDLE_VALUE) { *success = FALSE; retry = os_file_handle_error(name, - create_mode == OS_FILE_CREATE ? - "create" : "open"); + create_mode == OS_FILE_CREATE ? + "create" : "open"); if (retry) { goto try_again; } @@ -1229,7 +1258,7 @@ try_again: ut_a(name); if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW - || create_mode == OS_FILE_OPEN_RETRY) { + || create_mode == OS_FILE_OPEN_RETRY) { mode_str = "OPEN"; create_flag = O_RDWR; } else if (create_mode == OS_FILE_CREATE) { @@ -1259,30 +1288,34 @@ try_again: ut_error; } -/* fprintf(stderr, "Opening file %s, mode %s, type %s, purpose %s\n", - name, mode_str, type_str, purpose_str); */ +#if 0 + fprintf(stderr, "Opening file %s, mode %s, type %s, purpose %s\n", + name, mode_str, type_str, purpose_str); +#endif #ifdef O_SYNC /* We let O_SYNC only affect log files; note that we map O_DSYNC to O_SYNC because the datasync options seemed to corrupt files in 2001 in both Linux and Solaris */ if (type == OS_LOG_FILE - && srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) { + && srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) { -/* fprintf(stderr, "Using O_SYNC for file %s\n", name); */ +# if 0 + fprintf(stderr, "Using O_SYNC for file %s\n", name); +# endif create_flag = create_flag | O_SYNC; } -#endif +#endif /* O_SYNC */ #ifdef O_DIRECT /* We let O_DIRECT only affect data files */ if (type != OS_LOG_FILE - && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { - -/* fprintf(stderr, "Using O_DIRECT for file %s\n", name); */ - + && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { +# if 0 + fprintf(stderr, "Using O_DIRECT for file %s\n", name); +# endif create_flag = create_flag | O_DIRECT; } -#endif +#endif /* O_DIRECT */ if (create_mode == OS_FILE_CREATE) { file = open(name, create_flag, os_innodb_umask); } else { @@ -1293,20 +1326,21 @@ try_again: *success = FALSE; retry = os_file_handle_error(name, - create_mode == OS_FILE_CREATE ? - "create" : "open"); + create_mode == OS_FILE_CREATE ? + "create" : "open"); if (retry) { goto try_again; } #ifdef USE_FILE_LOCK } else if (create_mode != OS_FILE_OPEN_RAW - && os_file_lock(file, name)) { + && os_file_lock(file, name)) { *success = FALSE; if (create_mode == OS_FILE_OPEN_RETRY) { int i; ut_print_timestamp(stderr); - fputs(" InnoDB: Retrying to lock the first data file\n", - stderr); + fputs(" InnoDB: Retrying to lock" + " the first data file\n", + stderr); for (i = 0; i < 100; i++) { os_thread_sleep(1000000); if (!os_file_lock(file, name)) { @@ -1316,7 +1350,7 @@ try_again: } ut_print_timestamp(stderr); fputs(" InnoDB: Unable to open the first data file\n", - stderr); + stderr); } close(file); file = -1; @@ -1361,8 +1395,9 @@ loop: if (count > 100 && 0 == (count % 10)) { fprintf(stderr, -"InnoDB: Warning: cannot delete file %s\n" -"InnoDB: Are you running ibbackup to back up the file?\n", name); + "InnoDB: Warning: cannot delete file %s\n" + "InnoDB: Are you running ibbackup" + " to back up the file?\n", name); os_file_get_last_error(TRUE); /* print error information */ } @@ -1423,8 +1458,9 @@ loop: if (count > 100 && 0 == (count % 10)) { fprintf(stderr, -"InnoDB: Warning: cannot delete file %s\n" -"InnoDB: Are you running ibbackup to back up the file?\n", name); + "InnoDB: Warning: cannot delete file %s\n" + "InnoDB: Are you running ibbackup" + " to back up the file?\n", name); os_file_get_last_error(TRUE); /* print error information */ } @@ -1664,7 +1700,7 @@ os_file_set_size( /* Write up to 1 megabyte at a time. */ buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE)) - * UNIV_PAGE_SIZE; + * UNIV_PAGE_SIZE; buf2 = ut_malloc(buf_size + UNIV_PAGE_SIZE); /* Align the buffer for possible raw i/o */ @@ -1688,9 +1724,9 @@ os_file_set_size( } ret = os_file_write(name, file, buf, - (ulint)(current_size & 0xFFFFFFFF), - (ulint)(current_size >> 32), - n_bytes); + (ulint)(current_size & 0xFFFFFFFF), + (ulint)(current_size >> 32), + n_bytes); if (!ret) { ut_free(buf2); goto error_handling; @@ -1698,11 +1734,11 @@ os_file_set_size( /* Print about progress for each 100 MB written */ if ((current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024) - != current_size / (ib_longlong)(100 * 1024 * 1024)) { + != current_size / (ib_longlong)(100 * 1024 * 1024)) { fprintf(stderr, " %lu00", (ulong) ((current_size + n_bytes) - / (ib_longlong)(100 * 1024 * 1024))); + / (ib_longlong)(100 * 1024 * 1024))); } current_size += n_bytes; @@ -1769,7 +1805,7 @@ os_file_flush( raw disks */ if (srv_start_raw_disk_in_use && GetLastError() - == ERROR_INVALID_FUNCTION) { + == ERROR_INVALID_FUNCTION) { return(TRUE); } @@ -1812,7 +1848,7 @@ os_file_flush( #elif HAVE_FDATASYNC ret = fdatasync(file); #else -/* fprintf(stderr, "Flushing to file %p\n", file); */ + /* fprintf(stderr, "Flushing to file %p\n", file); */ ret = fsync(file); #endif os_n_fsyncs++; @@ -1876,7 +1912,7 @@ os_file_pread( if (offset_high > 0) { fprintf(stderr, - "InnoDB: Error: file read at offset > 4 GB\n"); + "InnoDB: Error: file read at offset > 4 GB\n"); } } @@ -1898,34 +1934,34 @@ os_file_pread( return(n_bytes); #else { - off_t ret_offset; - ssize_t ret; - ulint i; + off_t ret_offset; + ssize_t ret; + ulint i; - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads++; - os_mutex_exit(os_file_count_mutex); + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads++; + os_mutex_exit(os_file_count_mutex); - /* Protect the seek / read operation with a mutex */ - i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; + /* Protect the seek / read operation with a mutex */ + i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; - os_mutex_enter(os_file_seek_mutexes[i]); + os_mutex_enter(os_file_seek_mutexes[i]); - ret_offset = lseek(file, offs, SEEK_SET); + ret_offset = lseek(file, offs, SEEK_SET); - if (ret_offset < 0) { - ret = -1; - } else { - ret = read(file, buf, (ssize_t)n); - } + if (ret_offset < 0) { + ret = -1; + } else { + ret = read(file, buf, (ssize_t)n); + } - os_mutex_exit(os_file_seek_mutexes[i]); + os_mutex_exit(os_file_seek_mutexes[i]); - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads--; - os_mutex_exit(os_file_count_mutex); + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads--; + os_mutex_exit(os_file_count_mutex); - return(ret); + return(ret); } #endif } @@ -1960,7 +1996,8 @@ os_file_pwrite( if (offset_high > 0) { fprintf(stderr, - "InnoDB: Error: file write at offset > 4 GB\n"); + "InnoDB: Error: file write" + " at offset > 4 GB\n"); } } @@ -1981,8 +2018,8 @@ os_file_pwrite( # ifdef UNIV_DO_FLUSH if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC - && srv_unix_file_flush_method != SRV_UNIX_NOSYNC - && !os_do_not_call_flush_at_each_write) { + && srv_unix_file_flush_method != SRV_UNIX_NOSYNC + && !os_do_not_call_flush_at_each_write) { /* Always do fsync to reduce the probability that when the OS crashes, a database page is only partially @@ -1995,49 +2032,49 @@ os_file_pwrite( return(ret); #else { - off_t ret_offset; - ulint i; + off_t ret_offset; + ulint i; - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes++; - os_mutex_exit(os_file_count_mutex); + os_mutex_enter(os_file_count_mutex); + os_n_pending_writes++; + os_mutex_exit(os_file_count_mutex); - /* Protect the seek / write operation with a mutex */ - i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; + /* Protect the seek / write operation with a mutex */ + i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; - os_mutex_enter(os_file_seek_mutexes[i]); + os_mutex_enter(os_file_seek_mutexes[i]); - ret_offset = lseek(file, offs, SEEK_SET); + ret_offset = lseek(file, offs, SEEK_SET); - if (ret_offset < 0) { - ret = -1; + if (ret_offset < 0) { + ret = -1; - goto func_exit; - } + goto func_exit; + } - ret = write(file, buf, (ssize_t)n); + ret = write(file, buf, (ssize_t)n); # ifdef UNIV_DO_FLUSH - if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC - && srv_unix_file_flush_method != SRV_UNIX_NOSYNC - && !os_do_not_call_flush_at_each_write) { + if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC + && srv_unix_file_flush_method != SRV_UNIX_NOSYNC + && !os_do_not_call_flush_at_each_write) { - /* Always do fsync to reduce the probability that when - the OS crashes, a database page is only partially - physically written to disk. */ + /* Always do fsync to reduce the probability that when + the OS crashes, a database page is only partially + physically written to disk. */ - ut_a(TRUE == os_file_flush(file)); - } + ut_a(TRUE == os_file_flush(file)); + } # endif /* UNIV_DO_FLUSH */ func_exit: - os_mutex_exit(os_file_seek_mutexes[i]); + os_mutex_exit(os_file_seek_mutexes[i]); - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes--; - os_mutex_exit(os_file_count_mutex); + os_mutex_enter(os_file_count_mutex); + os_n_pending_writes--; + os_mutex_exit(os_file_count_mutex); - return(ret); + return(ret); } #endif } @@ -2129,9 +2166,10 @@ try_again: } fprintf(stderr, -"InnoDB: Error: tried to read %lu bytes at offset %lu %lu.\n" -"InnoDB: Was only able to read %ld.\n", (ulong)n, (ulong)offset_high, - (ulong)offset, (long)ret); + "InnoDB: Error: tried to read %lu bytes at offset %lu %lu.\n" + "InnoDB: Was only able to read %ld.\n", + (ulong)n, (ulong)offset_high, + (ulong)offset, (long)ret); #endif #ifdef __WIN__ error_handling: @@ -2143,7 +2181,8 @@ error_handling: } fprintf(stderr, -"InnoDB: Fatal error: cannot read from file. OS error number %lu.\n", + "InnoDB: Fatal error: cannot read from file." + " OS error number %lu.\n", #ifdef __WIN__ (ulong) GetLastError() #else @@ -2339,11 +2378,15 @@ retry: ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: File pointer positioning to file %s failed at\n" -"InnoDB: offset %lu %lu. Operating system error number %lu.\n" -"InnoDB: Some operating system error numbers are described at\n" -"InnoDB: " -"http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n", + " InnoDB: Error: File pointer positioning to" + " file %s failed at\n" + "InnoDB: offset %lu %lu. Operating system" + " error number %lu.\n" + "InnoDB: Some operating system error numbers" + " are described at\n" + "InnoDB: " + "http://dev.mysql.com/doc/refman/5.1/en/" + "operating-system-error-codes.html\n", name, (ulong) offset_high, (ulong) offset, (ulong) GetLastError()); @@ -2392,23 +2435,30 @@ retry: ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: Write to file %s failed at offset %lu %lu.\n" -"InnoDB: %lu bytes should have been written, only %lu were written.\n" -"InnoDB: Operating system error number %lu.\n" -"InnoDB: Check that your OS and file system support files of this size.\n" -"InnoDB: Check also that the disk is not full or a disk quota exceeded.\n", + " InnoDB: Error: Write to file %s failed" + " at offset %lu %lu.\n" + "InnoDB: %lu bytes should have been written," + " only %lu were written.\n" + "InnoDB: Operating system error number %lu.\n" + "InnoDB: Check that your OS and file system" + " support files of this size.\n" + "InnoDB: Check also that the disk is not full" + " or a disk quota exceeded.\n", name, (ulong) offset_high, (ulong) offset, (ulong) n, (ulong) len, (ulong) err); if (strerror((int)err) != NULL) { fprintf(stderr, -"InnoDB: Error number %lu means '%s'.\n", (ulong) err, strerror((int)err)); + "InnoDB: Error number %lu means '%s'.\n", + (ulong) err, strerror((int)err)); } fprintf(stderr, -"InnoDB: Some operating system error numbers are described at\n" -"InnoDB: " -"http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n"); + "InnoDB: Some operating system error numbers" + " are described at\n" + "InnoDB: " + "http://dev.mysql.com/doc/refman/5.1/en/" + "operating-system-error-codes.html\n"); os_has_said_disk_full = TRUE; } @@ -2429,22 +2479,29 @@ retry: ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: Write to file %s failed at offset %lu %lu.\n" -"InnoDB: %lu bytes should have been written, only %ld were written.\n" -"InnoDB: Operating system error number %lu.\n" -"InnoDB: Check that your OS and file system support files of this size.\n" -"InnoDB: Check also that the disk is not full or a disk quota exceeded.\n", + " InnoDB: Error: Write to file %s failed" + " at offset %lu %lu.\n" + "InnoDB: %lu bytes should have been written," + " only %ld were written.\n" + "InnoDB: Operating system error number %lu.\n" + "InnoDB: Check that your OS and file system" + " support files of this size.\n" + "InnoDB: Check also that the disk is not full" + " or a disk quota exceeded.\n", name, offset_high, offset, n, (long int)ret, - (ulint)errno); + (ulint)errno); if (strerror(errno) != NULL) { fprintf(stderr, -"InnoDB: Error number %lu means '%s'.\n", (ulint)errno, strerror(errno)); + "InnoDB: Error number %lu means '%s'.\n", + (ulint)errno, strerror(errno)); } fprintf(stderr, -"InnoDB: Some operating system error numbers are described at\n" -"InnoDB: " -"http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html\n"); + "InnoDB: Some operating system error numbers" + " are described at\n" + "InnoDB: " + "http://dev.mysql.com/doc/refman/5.1/en/" + "operating-system-error-codes.html\n"); os_has_said_disk_full = TRUE; } @@ -2531,9 +2588,11 @@ This function returns information about the specified file */ ibool os_file_get_status( /*===============*/ - /* out: TRUE if stat information found */ - const char* path, /* in: pathname of the file */ - os_file_stat_t* stat_info) /* information of a file in a directory */ + /* out: TRUE if stat + information found */ + const char* path, /* in: pathname of the file */ + os_file_stat_t* stat_info) /* information of a file in a + directory */ { #ifdef __WIN__ int ret; @@ -2613,7 +2672,7 @@ os_file_get_status( The function os_file_dirname returns a directory component of a null-terminated pathname string. In the usual case, dirname returns the string up to, but not including, the final '/', and basename -is the component following the final '/'. Trailing '/' charac­ +is the component following the final '/'. Trailing '/' charac­ ters are not counted as part of the pathname. If path does not contain a slash, dirname returns the string ".". @@ -2681,7 +2740,7 @@ os_file_create_subdirs_if_needed( subdir = os_file_dirname(path); if (strlen(subdir) == 1 - && (*subdir == OS_FILE_PATH_SEPARATOR || *subdir == '.')) { + && (*subdir == OS_FILE_PATH_SEPARATOR || *subdir == '.')) { /* subdir is root or cwd, nothing to do */ mem_free(subdir); @@ -2825,14 +2884,14 @@ os_aio_init( srv_io_thread_function[1] = "log thread"; os_aio_read_array = os_aio_array_create(n_read_segs * n_per_seg, - n_read_segs); + n_read_segs); for (i = 2; i < 2 + n_read_segs; i++) { ut_a(i < SRV_MAX_N_IO_THREADS); srv_io_thread_function[i] = "read thread"; } os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg, - n_write_segs); + n_write_segs); for (i = 2 + n_read_segs; i < n_segments; i++) { ut_a(i < SRV_MAX_N_IO_THREADS); srv_io_thread_function[i] = "write thread"; @@ -2868,7 +2927,7 @@ os_aio_init( pthread_sigmask(SIG_BLOCK, &sigset, NULL); */ #endif -} + } #ifdef WIN_ASYNC_IO /**************************************************************************** @@ -2946,17 +3005,17 @@ os_aio_get_segment_no_from_slot( segment = 1; } else if (array == os_aio_read_array) { - seg_len = os_aio_read_array->n_slots / - os_aio_read_array->n_segments; + seg_len = os_aio_read_array->n_slots + / os_aio_read_array->n_segments; segment = 2 + slot->pos / seg_len; } else { ut_a(array == os_aio_write_array); - seg_len = os_aio_write_array->n_slots / - os_aio_write_array->n_segments; + seg_len = os_aio_write_array->n_slots + / os_aio_write_array->n_segments; segment = os_aio_read_array->n_segments + 2 - + slot->pos / seg_len; + + slot->pos / seg_len; } return(segment); @@ -3161,13 +3220,13 @@ loop: control->aio_offset = offset; control->aio_reqprio = 0; control->aio_sigevent.sigev_notify = SIGEV_SIGNAL; - control->aio_sigevent.sigev_signo = - SIGRTMIN + 1 + os_aio_get_array_no(array); - /* TODO: How to choose the signal numbers? */ -/* + control->aio_sigevent.sigev_signo + = SIGRTMIN + 1 + os_aio_get_array_no(array); + /* TODO: How to choose the signal numbers? */ + /* fprintf(stderr, "AIO signal number %lu\n", - (ulint) control->aio_sigevent.sigev_signo); -*/ + (ulint) control->aio_sigevent.sigev_signo); + */ control->aio_sigevent.sigev_value.sival_ptr = slot; #endif os_mutex_exit(array->mutex); @@ -3362,9 +3421,9 @@ os_aio( if (mode == OS_AIO_SYNC #ifdef WIN_ASYNC_IO - && !os_aio_use_native_aio + && !os_aio_use_native_aio #endif - ) { + ) { /* This is actually an ordinary synchronous read or write: no need to use an i/o-handler thread. NOTE that if we use Windows async i/o, Windows does not allow us to use @@ -3374,7 +3433,7 @@ os_aio( if (type == OS_FILE_READ) { return(os_file_read(file, buf, offset, - offset_high, n)); + offset_high, n)); } ut_a(type == OS_FILE_WRITE); @@ -3408,7 +3467,7 @@ try_again: } slot = os_aio_array_reserve_slot(type, array, message1, message2, file, - name, buf, offset, offset_high, n); + name, buf, offset, offset_high, n); if (type == OS_FILE_READ) { if (os_aio_use_native_aio) { #ifdef WIN_ASYNC_IO @@ -3416,7 +3475,7 @@ try_again: os_bytes_read_since_printout += len; ret = ReadFile(file, buf, (DWORD)n, &len, - &(slot->control)); + &(slot->control)); #elif defined(POSIX_ASYNC_IO) slot->control.aio_lio_opcode = LIO_READ; err = (ulint) aio_read(&(slot->control)); @@ -3424,8 +3483,9 @@ try_again: #endif } else { if (!wake_later) { - os_aio_simulated_wake_handler_thread( - os_aio_get_segment_no_from_slot(array, slot)); + os_aio_simulated_wake_handler_thread + (os_aio_get_segment_no_from_slot + (array, slot)); } } } else if (type == OS_FILE_WRITE) { @@ -3433,7 +3493,7 @@ try_again: #ifdef WIN_ASYNC_IO os_n_file_writes++; ret = WriteFile(file, buf, (DWORD)n, &len, - &(slot->control)); + &(slot->control)); #elif defined(POSIX_ASYNC_IO) slot->control.aio_lio_opcode = LIO_WRITE; err = (ulint) aio_write(&(slot->control)); @@ -3441,8 +3501,9 @@ try_again: #endif } else { if (!wake_later) { - os_aio_simulated_wake_handler_thread( - os_aio_get_segment_no_from_slot(array, slot)); + os_aio_simulated_wake_handler_thread + (os_aio_get_segment_no_from_slot + (array, slot)); } } } else { @@ -3452,7 +3513,7 @@ try_again: #ifdef WIN_ASYNC_IO if (os_aio_use_native_aio) { if ((ret && len == n) - || (!ret && GetLastError() == ERROR_IO_PENDING)) { + || (!ret && GetLastError() == ERROR_IO_PENDING)) { /* aio was queued successfully! */ if (mode == OS_AIO_SYNC) { @@ -3462,9 +3523,10 @@ try_again: async i/o */ retval = os_aio_windows_handle(ULINT_UNDEFINED, - slot->pos, - &dummy_mess1, &dummy_mess2, - &dummy_type); + slot->pos, + &dummy_mess1, + &dummy_mess2, + &dummy_type); return(retval); } @@ -3484,7 +3546,8 @@ try_again: os_aio_array_free_slot(array, slot); retry = os_file_handle_error(name, - type == OS_FILE_READ ? "aio read" : "aio write"); + type == OS_FILE_READ + ? "aio read" : "aio write"); if (retry) { goto try_again; @@ -3554,7 +3617,8 @@ os_aio_windows_handle( } else { srv_set_io_thread_op_info(orig_seg, "wait Windows aio"); i = os_event_wait_multiple(n, - (array->native_events) + segment * n); + (array->native_events) + + segment * n); } os_mutex_enter(array->mutex); @@ -3565,7 +3629,7 @@ os_aio_windows_handle( if (orig_seg != ULINT_UNDEFINED) { srv_set_io_thread_op_info(orig_seg, - "get windows aio return value"); + "get windows aio return value"); } ret = GetOverlappedResult(slot->file, &(slot->control), &len, TRUE); @@ -3580,8 +3644,8 @@ os_aio_windows_handle( # ifdef UNIV_DO_FLUSH if (slot->type == OS_FILE_WRITE - && !os_do_not_call_flush_at_each_write) { - ut_a(TRUE == os_file_flush(slot->file)); + && !os_do_not_call_flush_at_each_write) { + ut_a(TRUE == os_file_flush(slot->file)); } # endif /* UNIV_DO_FLUSH */ } else { @@ -3631,16 +3695,16 @@ os_aio_posix_handle( pthread_sigmask(SIG_UNBLOCK, &sigset, NULL); - /* +#if 0 sigprocmask(0, NULL, &proc_sigset); pthread_sigmask(0, NULL, &thr_sigset); for (i = 32 ; i < 40; i++) { fprintf(stderr, "%lu : %lu %lu\n", (ulint)i, - (ulint)sigismember(&proc_sigset, i), - (ulint)sigismember(&thr_sigset, i)); + (ulint) sigismember(&proc_sigset, i), + (ulint) sigismember(&thr_sigset, i)); } - */ +#endif ret = sigwaitinfo(&sigset, &info); @@ -3666,7 +3730,7 @@ os_aio_posix_handle( # ifdef UNIV_DO_FLUSH if (slot->type == OS_FILE_WRITE - && !os_do_not_call_flush_at_each_write) { + && !os_do_not_call_flush_at_each_write) { ut_a(TRUE == os_file_flush(slot->file)); } # endif /* UNIV_DO_FLUSH */ @@ -3693,19 +3757,24 @@ os_file_check_page_trailers( ulint len; for (len = 0; len + UNIV_PAGE_SIZE <= total_len; - len += UNIV_PAGE_SIZE) { + len += UNIV_PAGE_SIZE) { byte* buf = combined_buf + len; - if (memcmp(buf + (FIL_PAGE_LSN + 4), buf + (UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM + 4), 4)) { + if (UNIV_UNLIKELY + (memcmp(buf + (FIL_PAGE_LSN + 4), + buf + (UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4), 4))) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: ERROR: The page to be written seems corrupt!\n" -"InnoDB: Writing a block of %lu bytes, currently at offset %lu\n", - (ulong)total_len, (ulong)len); + " InnoDB: ERROR: The page to be written" + " seems corrupt!\n" + "InnoDB: Writing a block of %lu bytes," + " currently at offset %lu\n", + (ulong)total_len, (ulong)len); buf_page_print(buf); fprintf(stderr, -"InnoDB: ERROR: The page to be written seems corrupt!\n"); + "InnoDB: ERROR: The page to be written" + " seems corrupt!\n"); } } } @@ -3755,7 +3824,7 @@ restart: we do not have to acquire the protecting mutex yet */ srv_set_io_thread_op_info(global_segment, - "looking for i/o requests (a)"); + "looking for i/o requests (a)"); ut_ad(os_aio_validate()); ut_ad(segment < array->n_segments); @@ -3764,7 +3833,7 @@ restart: /* Look through n slots after the segment * n'th slot */ if (array == os_aio_read_array - && os_aio_recommend_sleep_for_read_threads) { + && os_aio_recommend_sleep_for_read_threads) { /* Give other threads chance to add several i/os to the array at once. */ @@ -3775,7 +3844,7 @@ restart: os_mutex_enter(array->mutex); srv_set_io_thread_op_info(global_segment, - "looking for i/o requests (b)"); + "looking for i/o requests (b)"); /* Check if there is a slot for which the i/o has already been done */ @@ -3787,7 +3856,9 @@ restart: if (os_aio_print_debug) { fprintf(stderr, -"InnoDB: i/o for slot %lu already done, returning\n", (ulong) i); + "InnoDB: i/o for slot %lu" + " already done, returning\n", + (ulong) i); } ret = TRUE; @@ -3810,11 +3881,11 @@ restart: if (slot->reserved) { age = (ulint)difftime(time(NULL), - slot->reservation_time); + slot->reservation_time); if ((age >= 2 && age > biggest_age) - || (age >= 2 && age == biggest_age - && slot->offset < lowest_offset)) { + || (age >= 2 && age == biggest_age + && slot->offset < lowest_offset)) { /* Found an i/o request */ consecutive_ios[0] = slot; @@ -3836,7 +3907,7 @@ restart: for (i = 0; i < n; i++) { slot = os_aio_array_get_nth_slot(array, - i + segment * n); + i + segment * n); if (slot->reserved && slot->offset < lowest_offset) { @@ -3866,12 +3937,12 @@ consecutive_loop: slot2 = os_aio_array_get_nth_slot(array, i + segment * n); if (slot2->reserved && slot2 != slot - && slot2->offset == slot->offset + slot->len - /* check that sum does not wrap over */ - && slot->offset + slot->len > slot->offset - && slot2->offset_high == slot->offset_high - && slot2->type == slot->type - && slot2->file == slot->file) { + && slot2->offset == slot->offset + slot->len + /* check that sum does not wrap over */ + && slot->offset + slot->len > slot->offset + && slot2->offset_high == slot->offset_high + && slot2->type == slot->type + && slot2->file == slot->file) { /* Found a consecutive i/o request */ @@ -3927,7 +3998,7 @@ consecutive_loop: for (i = 0; i < n_consecutive; i++) { ut_memcpy(combined_buf + offs, consecutive_ios[i]->buf, - consecutive_ios[i]->len); + consecutive_ios[i]->len); offs += consecutive_ios[i]->len; } } @@ -3936,7 +4007,8 @@ consecutive_loop: if (os_aio_print_debug) { fprintf(stderr, -"InnoDB: doing i/o of type %lu at offset %lu %lu, length %lu\n", + "InnoDB: doing i/o of type %lu at offset %lu %lu," + " length %lu\n", (ulong) slot->type, (ulong) slot->offset_high, (ulong) slot->offset, (ulong) total_len); } @@ -3945,9 +4017,10 @@ consecutive_loop: if (slot->type == OS_FILE_WRITE) { if (array == os_aio_write_array) { if ((total_len % UNIV_PAGE_SIZE != 0) - || (slot->offset % UNIV_PAGE_SIZE != 0)) { + || (slot->offset % UNIV_PAGE_SIZE != 0)) { fprintf(stderr, -"InnoDB: Error: trying a displaced write to %s %lu %lu, len %lu\n", + "InnoDB: Error: trying a displaced" + " write to %s %lu %lu, len %lu\n", slot->name, (ulong) slot->offset_high, (ulong) slot->offset, (ulong) total_len); @@ -3958,22 +4031,25 @@ consecutive_loop: } ret = os_file_write(slot->name, slot->file, combined_buf, - slot->offset, slot->offset_high, total_len); + slot->offset, slot->offset_high, + total_len); if (array == os_aio_write_array) { os_file_check_page_trailers(combined_buf, total_len); } } else { ret = os_file_read(slot->file, combined_buf, - slot->offset, slot->offset_high, total_len); + slot->offset, slot->offset_high, total_len); } ut_a(ret); srv_set_io_thread_op_info(global_segment, "file i/o done"); -/* fprintf(stderr, - "aio: %lu consecutive %lu:th segment, first offs %lu blocks\n", - n_consecutive, global_segment, slot->offset / UNIV_PAGE_SIZE); */ +#if 0 + fprintf(stderr, + "aio: %lu consecutive %lu:th segment, first offs %lu blocks\n", + n_consecutive, global_segment, slot->offset / UNIV_PAGE_SIZE); +#endif if (slot->type == OS_FILE_READ && n_consecutive > 1) { /* Copy the combined buffer to individual buffers */ @@ -3982,7 +4058,7 @@ consecutive_loop: for (i = 0; i < n_consecutive; i++) { ut_memcpy(consecutive_ios[i]->buf, combined_buf + offs, - consecutive_ios[i]->len); + consecutive_ios[i]->len); offs += consecutive_ios[i]->len; } } @@ -4035,7 +4111,8 @@ recommended_sleep: if (os_aio_print_debug) { fprintf(stderr, -"InnoDB: i/o handler thread for i/o segment %lu wakes up\n", + "InnoDB: i/o handler thread for i/o" + " segment %lu wakes up\n", (ulong) global_segment); } @@ -4113,8 +4190,8 @@ os_aio_print( for (i = 0; i < srv_n_file_io_threads; i++) { fprintf(file, "I/O thread %lu state: %s (%s)", (ulong) i, - srv_io_thread_op_info[i], - srv_io_thread_function[i]); + srv_io_thread_op_info[i], + srv_io_thread_function[i]); #ifndef __WIN__ if (os_aio_segment_wait_events[i]->is_set) { @@ -4143,8 +4220,11 @@ loop: if (slot->reserved) { n_reserved++; - /* fprintf(stderr, "Reserved slot, messages %p %p\n", - slot->message1, slot->message2); */ +#if 0 + fprintf(stderr, "Reserved slot, messages %p %p\n", + (void*) slot->message1, + (void*) slot->message2); +#endif ut_a(slot->len > 0); } } @@ -4206,12 +4286,13 @@ loop: if (os_n_file_reads == os_n_file_reads_old) { avg_bytes_read = 0.0; } else { - avg_bytes_read = (double) os_bytes_read_since_printout / - (os_n_file_reads - os_n_file_reads_old); + avg_bytes_read = (double) os_bytes_read_since_printout + / (os_n_file_reads - os_n_file_reads_old); } fprintf(file, -"%.2f reads/s, %lu avg bytes/read, %.2f writes/s, %.2f fsyncs/s\n", + "%.2f reads/s, %lu avg bytes/read," + " %.2f writes/s, %.2f fsyncs/s\n", (os_n_file_reads - os_n_file_reads_old) / time_elapsed, (ulong)avg_bytes_read, diff --git a/storage/innobase/os/os0proc.c b/storage/innobase/os/os0proc.c index fc1b2d0d2dd..a99fe8b6a0e 100644 --- a/storage/innobase/os/os0proc.c +++ b/storage/innobase/os/os0proc.c @@ -90,8 +90,8 @@ os_awe_enable_lock_pages_in_mem(void) #elif defined(__WIN2000__) struct { - DWORD Count; - LUID_AND_ATTRIBUTES Privilege[1]; + DWORD Count; + LUID_AND_ATTRIBUTES Privilege[1]; } Info; HANDLE hProcess; HANDLE Token; @@ -102,7 +102,7 @@ os_awe_enable_lock_pages_in_mem(void) /* Open the token of the current process */ Result = OpenProcessToken(hProcess, - TOKEN_ADJUST_PRIVILEGES, &Token); + TOKEN_ADJUST_PRIVILEGES, &Token); if (Result != TRUE) { fprintf(stderr, "InnoDB: AWE: Cannot open process token, error %lu\n", @@ -118,10 +118,11 @@ os_awe_enable_lock_pages_in_mem(void) privilege */ Result = LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, - &(Info.Privilege[0].Luid)); + &(Info.Privilege[0].Luid)); if (Result != TRUE) { fprintf(stderr, - "InnoDB: AWE: Cannot get local privilege value for %s, error %lu.\n", + "InnoDB: AWE: Cannot get local privilege" + " value for %s, error %lu.\n", SE_LOCK_MEMORY_NAME, (ulint)GetLastError()); return(FALSE); @@ -130,23 +131,29 @@ os_awe_enable_lock_pages_in_mem(void) /* Try to adjust the privilege */ Result = AdjustTokenPrivileges(Token, FALSE, - (PTOKEN_PRIVILEGES)&Info, - 0, NULL, NULL); + (PTOKEN_PRIVILEGES)&Info, + 0, NULL, NULL); /* Check the result */ if (Result != TRUE) { fprintf(stderr, - "InnoDB: AWE: Cannot adjust process token privileges, error %u.\n", + "InnoDB: AWE: Cannot adjust process token privileges," + " error %u.\n", GetLastError()); return(FALSE); } else if (GetLastError() != ERROR_SUCCESS) { fprintf(stderr, -"InnoDB: AWE: Cannot enable SE_LOCK_MEMORY privilege, error %lu.\n" -"InnoDB: In Windows XP Home you cannot use AWE. In Windows 2000 and XP\n" -"InnoDB: Professional you must go to the Control Panel, to\n" -"InnoDB: Security Settings, to Local Policies, and enable\n" -"InnoDB: the 'lock pages in memory' privilege for the user who runs\n" -"InnoDB: the MySQL server.\n", GetLastError()); + "InnoDB: AWE: Cannot enable SE_LOCK_MEMORY privilege," + " error %lu.\n" + "InnoDB: In Windows XP Home you cannot use AWE." + " In Windows 2000 and XP\n" + "InnoDB: Professional you must go to the" + " Control Panel, to\n" + "InnoDB: Security Settings, to Local Policies," + " and enable\n" + "InnoDB: the 'lock pages in memory' privilege" + " for the user who runs\n" + "InnoDB: the MySQL server.\n", GetLastError()); return(FALSE); } @@ -157,7 +164,8 @@ os_awe_enable_lock_pages_in_mem(void) #else #ifdef __WIN__ fprintf(stderr, -"InnoDB: AWE: Error: to use AWE you must use a ...-nt MySQL executable.\n"); + "InnoDB: AWE: Error: to use AWE you must use" + " a ...-nt MySQL executable.\n"); #endif return(FALSE); #endif @@ -178,12 +186,12 @@ os_awe_allocate_physical_mem( ulint n_megabytes) /* in: number of megabytes to allocate */ { #ifdef UNIV_SIMULATE_AWE - os_awe_simulate_page_info = ut_malloc(sizeof(os_awe_t) * - n_megabytes * ((1024 * 1024) / OS_AWE_X86_PAGE_SIZE)); + os_awe_simulate_page_info = ut_malloc + (sizeof(os_awe_t) * n_megabytes + * ((1024 * 1024) / OS_AWE_X86_PAGE_SIZE)); - os_awe_simulate_mem = ut_align(ut_malloc( - 4096 + 1024 * 1024 * n_megabytes), - 4096); + os_awe_simulate_mem + = ut_align(ut_malloc(4096 + 1024 * 1024 * n_megabytes), 4096); os_awe_simulate_mem_size = n_megabytes * 1024 * 1024; *page_info = os_awe_simulate_page_info; @@ -204,8 +212,9 @@ os_awe_allocate_physical_mem( if (n_megabytes > 64 * 1024) { fprintf(stderr, -"InnoDB: AWE: Error: tried to allocate %lu MB.\n" -"InnoDB: AWE cannot allocate more than 64 GB in any computer.\n", n_megabytes); + "InnoDB: AWE: Error: tried to allocate %lu MB.\n" + "InnoDB: AWE cannot allocate more than" + " 64 GB in any computer.\n", n_megabytes); return(FALSE); } @@ -214,8 +223,10 @@ os_awe_allocate_physical_mem( if ((ulint)OS_AWE_X86_PAGE_SIZE != (ulint)sSysInfo.dwPageSize) { fprintf(stderr, -"InnoDB: AWE: Error: this computer has a page size of %lu.\n" -"InnoDB: Should be 4096 bytes for InnoDB AWE support to work.\n", + "InnoDB: AWE: Error: this computer has a page size" + " of %lu.\n" + "InnoDB: Should be 4096 bytes for" + " InnoDB AWE support to work.\n", (ulint)sSysInfo.dwPageSize); return(FALSE); @@ -233,7 +244,8 @@ os_awe_allocate_physical_mem( if (*page_info == NULL) { fprintf(stderr, -"InnoDB: AWE: Failed to allocate page info array from process heap, error %lu\n", + "InnoDB: AWE: Failed to allocate page info" + " array from process heap, error %lu\n", (ulint)GetLastError()); return(FALSE); @@ -259,10 +271,11 @@ os_awe_allocate_physical_mem( defined, see the note at the start of this file */ bResult = AllocateUserPhysicalPages(GetCurrentProcess(), - &NumberOfPages, *page_info); + &NumberOfPages, *page_info); if (bResult != TRUE) { fprintf(stderr, -"InnoDB: AWE: Cannot allocate physical pages, error %lu.\n", + "InnoDB: AWE: Cannot allocate physical pages," + " error %lu.\n", (ulint)GetLastError()); return(FALSE); @@ -270,14 +283,19 @@ os_awe_allocate_physical_mem( if (NumberOfPagesInitial != NumberOfPages) { fprintf(stderr, -"InnoDB: AWE: Error: allocated only %lu pages of %lu requested.\n" -"InnoDB: Check that you have enough free RAM.\n" -"InnoDB: In Windows XP Professional and 2000 Professional\n" -"InnoDB: Windows PAE size is max 4 GB. In 2000 and .NET\n" -"InnoDB: Advanced Servers and 2000 Datacenter Server it is 32 GB,\n" -"InnoDB: and in .NET Datacenter Server it is 64 GB.\n" -"InnoDB: A Microsoft web page said that the processor must be an Intel\n" -"InnoDB: processor.\n", + "InnoDB: AWE: Error: allocated only %lu pages" + " of %lu requested.\n" + "InnoDB: Check that you have enough free RAM.\n" + "InnoDB: In Windows XP Professional and" + " 2000 Professional\n" + "InnoDB: Windows PAE size is max 4 GB." + " In 2000 and .NET\n" + "InnoDB: Advanced Servers and 2000 Datacenter Server" + " it is 32 GB,\n" + "InnoDB: and in .NET Datacenter Server it is 64 GB.\n" + "InnoDB: A Microsoft web page said that" + " the processor must be an Intel\n" + "InnoDB: processor.\n", (ulint)NumberOfPages, (ulint)NumberOfPagesInitial); @@ -285,7 +303,8 @@ os_awe_allocate_physical_mem( } fprintf(stderr, -"InnoDB: Using Address Windowing Extensions (AWE); allocated %lu MB\n", + "InnoDB: Using Address Windowing Extensions (AWE);" + " allocated %lu MB\n", n_megabytes); return(TRUE); @@ -328,17 +347,19 @@ os_awe_allocate_virtual_mem_window( if (size > (ulint)0x7FFFFFFFUL) { fprintf(stderr, -"InnoDB: AWE: Cannot allocate %lu bytes of virtual memory\n", size); + "InnoDB: AWE: Cannot allocate %lu bytes" + " of virtual memory\n", size); return(NULL); } ptr = VirtualAlloc(NULL, (SIZE_T)size, MEM_RESERVE | MEM_PHYSICAL, - PAGE_READWRITE); + PAGE_READWRITE); if (ptr == NULL) { fprintf(stderr, -"InnoDB: AWE: Cannot allocate %lu bytes of virtual memory, error %lu\n", - size, (ulint)GetLastError()); + "InnoDB: AWE: Cannot allocate %lu bytes" + " of virtual memory, error %lu\n", + size, (ulint)GetLastError()); return(NULL); } @@ -390,14 +411,14 @@ os_awe_map_physical_mem_to_window( ut_a(ptr >= os_awe_simulate_window); ut_a(ptr < os_awe_simulate_window + os_awe_simulate_window_size); ut_a(page_info >= os_awe_simulate_page_info); - ut_a(page_info < os_awe_simulate_page_info + - (os_awe_simulate_mem_size / 4096)); + ut_a(page_info < os_awe_simulate_page_info + + (os_awe_simulate_mem_size / 4096)); /* First look if some other 'physical pages' are mapped at ptr, and copy them back to where they were if yes */ map = os_awe_simulate_map - + ((ulint)(ptr - os_awe_simulate_window)) / 4096; + + ((ulint)(ptr - os_awe_simulate_window)) / 4096; page = ptr; for (i = 0; i < n_mem_pages; i++) { @@ -412,15 +433,15 @@ os_awe_map_physical_mem_to_window( assume page_info is a segment of the array we created at the start */ phys_page = os_awe_simulate_mem - + (ulint)(page_info - os_awe_simulate_page_info) - * 4096; + + (ulint)(page_info - os_awe_simulate_page_info) + * 4096; ut_memcpy(ptr, phys_page, n_mem_pages * 4096); /* Update the map */ map = os_awe_simulate_map - + ((ulint)(ptr - os_awe_simulate_window)) / 4096; + + ((ulint)(ptr - os_awe_simulate_window)) / 4096; for (i = 0; i < n_mem_pages; i++) { *map = phys_page; @@ -439,29 +460,34 @@ os_awe_map_physical_mem_to_window( if (!(ptr >= os_awe_window)) { fprintf(stderr, -"InnoDB: AWE: Error: trying to map to address %lx but AWE window start %lx\n", - (ulint)ptr, (ulint)os_awe_window); + "InnoDB: AWE: Error: trying to map to address %lx" + " but AWE window start %lx\n", + (ulint)ptr, (ulint)os_awe_window); ut_a(0); } if (!(ptr <= os_awe_window + os_awe_window_size - UNIV_PAGE_SIZE)) { fprintf(stderr, -"InnoDB: AWE: Error: trying to map to address %lx but AWE window end %lx\n", - (ulint)ptr, (ulint)os_awe_window + os_awe_window_size); + "InnoDB: AWE: Error: trying to map to address %lx" + " but AWE window end %lx\n", + (ulint)ptr, (ulint)os_awe_window + os_awe_window_size); ut_a(0); } if (!(page_info >= os_awe_page_info)) { fprintf(stderr, -"InnoDB: AWE: Error: trying to map page info at %lx but array start %lx\n", - (ulint)page_info, (ulint)os_awe_page_info); + "InnoDB: AWE: Error: trying to map page info" + " at %lx but array start %lx\n", + (ulint)page_info, (ulint)os_awe_page_info); ut_a(0); } if (!(page_info <= os_awe_page_info + (os_awe_n_pages - 4))) { fprintf(stderr, -"InnoDB: AWE: Error: trying to map page info at %lx but array end %lx\n", - (ulint)page_info, (ulint)(os_awe_page_info + os_awe_n_pages)); + "InnoDB: AWE: Error: trying to map page info" + " at %lx but array end %lx\n", + (ulint)page_info, + (ulint)(os_awe_page_info + os_awe_n_pages)); ut_a(0); } @@ -470,9 +496,10 @@ os_awe_map_physical_mem_to_window( if (bResult != TRUE) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: AWE: Mapping of %lu physical pages to address %lx failed,\n" -"InnoDB: error %lu.\n" -"InnoDB: Cannot continue operation.\n", + " InnoDB: AWE: Mapping of %lu physical pages" + " to address %lx failed,\n" + "InnoDB: error %lu.\n" + "InnoDB: Cannot continue operation.\n", n_mem_pages, (ulint)ptr, (ulint)GetLastError()); exit(1); } @@ -517,7 +544,7 @@ os_mem_alloc_nocache( void* ptr; ptr = VirtualAlloc(NULL, n, MEM_COMMIT, - PAGE_READWRITE | PAGE_NOCACHE); + PAGE_READWRITE | PAGE_NOCACHE); ut_a(ptr); return(ptr); @@ -541,47 +568,50 @@ os_mem_alloc_large( the memory cannot be allocated */ { #ifdef HAVE_LARGE_PAGES - ulint size; - int shmid; - void *ptr = NULL; - struct shmid_ds buf; + ulint size; + int shmid; + void *ptr = NULL; + struct shmid_ds buf; - if (!os_use_large_pages || !os_large_page_size) { - goto skip; - } + if (!os_use_large_pages || !os_large_page_size) { + goto skip; + } #ifdef UNIV_LINUX - /* Align block size to os_large_page_size */ - size = ((n - 1) & ~(os_large_page_size - 1)) + os_large_page_size; + /* Align block size to os_large_page_size */ + size = ((n - 1) & ~(os_large_page_size - 1)) + os_large_page_size; - shmid = shmget(IPC_PRIVATE, (size_t)size, SHM_HUGETLB | SHM_R | SHM_W); - if (shmid < 0) { - fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to allocate" - " %lu bytes. errno %d\n", n, errno); - } else { - ptr = shmat(shmid, NULL, 0); - if (ptr == (void *)-1) { - fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to" - " attach shared memory segment, errno %d\n", errno); - } + shmid = shmget(IPC_PRIVATE, (size_t)size, SHM_HUGETLB | SHM_R | SHM_W); + if (shmid < 0) { + fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to allocate" + " %lu bytes. errno %d\n", n, errno); + } else { + ptr = shmat(shmid, NULL, 0); + if (ptr == (void *)-1) { + fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to" + " attach shared memory segment, errno %d\n", + errno); + } - /* Remove the shared memory segment so that it will be - automatically freed after memory is detached or process exits */ - shmctl(shmid, IPC_RMID, &buf); - } + /* Remove the shared memory segment so that it will be + automatically freed after memory is detached or + process exits */ + shmctl(shmid, IPC_RMID, &buf); + } #endif - if (ptr) { - if (set_to_zero) { + if (ptr) { + if (set_to_zero) { #ifdef UNIV_SET_MEM_TO_ZERO - memset(ptr, '\0', size); + memset(ptr, '\0', size); #endif - } + } - return(ptr); - } + return(ptr); + } - fprintf(stderr, "InnoDB HugeTLB: Warning: Using conventional memory pool\n"); + fprintf(stderr, "InnoDB HugeTLB: Warning: Using conventional" + " memory pool\n"); skip: #endif /* HAVE_LARGE_PAGES */ @@ -597,16 +627,16 @@ os_mem_free_large( void *ptr) /* in: number of bytes */ { #ifdef HAVE_LARGE_PAGES - if (os_use_large_pages && os_large_page_size + if (os_use_large_pages && os_large_page_size #ifdef UNIV_LINUX - && !shmdt(ptr) + && !shmdt(ptr) #endif - ) { - return; - } + ) { + return; + } #endif - ut_free(ptr); + ut_free(ptr); } /******************************************************************** @@ -632,11 +662,12 @@ os_process_set_priority_boost( # error "TRUE != 1" #endif -/* Does not do anything currently! + /* Does not do anything currently! SetProcessPriorityBoost(GetCurrentProcess(), no_boost); -*/ - fputs("Warning: process priority boost setting currently not functional!\n", - stderr); + */ + fputs("Warning: process priority boost setting" + " currently not functional!\n", + stderr); #else UT_NOT_USED(do_boost); #endif diff --git a/storage/innobase/os/os0sync.c b/storage/innobase/os/os0sync.c index eceedcb66b2..9c6b1134e12 100644 --- a/storage/innobase/os/os0sync.c +++ b/storage/innobase/os/os0sync.c @@ -90,8 +90,8 @@ os_sync_free(void) while (mutex) { if (mutex == os_sync_mutex) { /* Set the flag to FALSE so that we do not try to - reserve os_sync_mutex any more in remaining freeing - operations in shutdown */ + reserve os_sync_mutex any more in remaining freeing + operations in shutdown */ os_sync_mutex_inited = FALSE; } @@ -118,14 +118,15 @@ os_event_create( event = ut_malloc(sizeof(struct os_event_struct)); - event->handle = CreateEvent(NULL,/* No security attributes */ - TRUE, /* Manual reset */ - FALSE, /* Initial state nonsignaled */ - (LPCTSTR) name); + event->handle = CreateEvent(NULL, /* No security attributes */ + TRUE, /* Manual reset */ + FALSE, /* Initial state nonsignaled */ + (LPCTSTR) name); if (!event->handle) { fprintf(stderr, -"InnoDB: Could not create a Windows event semaphore; Windows error %lu\n", - (ulong) GetLastError()); + "InnoDB: Could not create a Windows event semaphore;" + " Windows error %lu\n", + (ulong) GetLastError()); } #else /* Unix */ os_event_t event; @@ -138,7 +139,7 @@ os_event_create( #if defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10) ut_a(0 == pthread_cond_init(&(event->cond_var), - pthread_condattr_default)); + pthread_condattr_default)); #else ut_a(0 == pthread_cond_init(&(event->cond_var), NULL)); #endif @@ -174,15 +175,16 @@ os_event_create_auto( event = ut_malloc(sizeof(struct os_event_struct)); - event->handle = CreateEvent(NULL,/* No security attributes */ - FALSE, /* Auto-reset */ - FALSE, /* Initial state nonsignaled */ - (LPCTSTR) name); + event->handle = CreateEvent(NULL, /* No security attributes */ + FALSE, /* Auto-reset */ + FALSE, /* Initial state nonsignaled */ + (LPCTSTR) name); if (!event->handle) { fprintf(stderr, -"InnoDB: Could not create a Windows auto event semaphore; Windows error %lu\n", - (ulong) GetLastError()); + "InnoDB: Could not create a Windows auto" + " event semaphore; Windows error %lu\n", + (ulong) GetLastError()); } /* Put to the list of events */ @@ -320,7 +322,7 @@ os_event_wait( for (;;) { if (event->is_set == TRUE - || event->signal_count != old_signal_count) { + || event->signal_count != old_signal_count) { os_fast_mutex_unlock(&(event->os_mutex)); @@ -409,9 +411,9 @@ os_event_wait_multiple( ut_a(n > 0); index = WaitForMultipleObjects((DWORD) n, native_event_array, - FALSE, /* Wait for any 1 event */ - INFINITE); /* Infinite wait time - limit */ + FALSE, /* Wait for any 1 event */ + INFINITE); /* Infinite wait time + limit */ ut_a(index >= WAIT_OBJECT_0); /* NOTE: Pointless comparision */ ut_a(index < WAIT_OBJECT_0 + n); @@ -439,8 +441,8 @@ os_mutex_create( os_mutex_t mutex_str; mutex = CreateMutex(NULL, /* No security attributes */ - FALSE, /* Initial state: no owner */ - (LPCTSTR) name); + FALSE, /* Initial state: no owner */ + (LPCTSTR) name); ut_a(mutex); #else os_fast_mutex_t* mutex; @@ -638,10 +640,11 @@ os_fast_mutex_free( if (ret != 0) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: error: return value %lu when calling\n" -"InnoDB: pthread_mutex_destroy().\n", (ulint)ret); + " InnoDB: error: return value %lu when calling\n" + "InnoDB: pthread_mutex_destroy().\n", (ulint)ret); fprintf(stderr, -"InnoDB: Byte contents of the pthread mutex at %p:\n", (void*) fast_mutex); + "InnoDB: Byte contents of the pthread mutex at %p:\n", + (void*) fast_mutex); ut_print_buf(stderr, fast_mutex, sizeof(os_fast_mutex_t)); fprintf(stderr, "\n"); } diff --git a/storage/innobase/os/os0thread.c b/storage/innobase/os/os0thread.c index 138db6426ea..0c9434ccc7f 100644 --- a/storage/innobase/os/os0thread.c +++ b/storage/innobase/os/os0thread.c @@ -107,11 +107,11 @@ os_thread_create( os_mutex_exit(os_sync_mutex); thread = CreateThread(NULL, /* no security attributes */ - 0, /* default size stack */ - (LPTHREAD_START_ROUTINE)start_f, - arg, - 0, /* thread runs immediately */ - &win_thread_id); + 0, /* default size stack */ + (LPTHREAD_START_ROUTINE)start_f, + arg, + 0, /* thread runs immediately */ + &win_thread_id); if (srv_set_thread_priorities) { @@ -142,21 +142,23 @@ os_thread_create( AIX is always big enough. An empirical test on AIX-4.3 suggested the size was 96 kB, though. */ - ret = pthread_attr_setstacksize(&attr, - (size_t)(PTHREAD_STACK_MIN + 32 * 1024)); + ret = pthread_attr_setstacksize + (&attr, (size_t)(PTHREAD_STACK_MIN + 32 * 1024)); if (ret) { - fprintf(stderr, - "InnoDB: Error: pthread_attr_setstacksize returned %d\n", ret); - exit(1); + fprintf(stderr, + "InnoDB: Error: pthread_attr_setstacksize" + " returned %d\n", ret); + exit(1); } #endif #ifdef __NETWARE__ ret = pthread_attr_setstacksize(&attr, (size_t) NW_THD_STACKSIZE); if (ret) { - fprintf(stderr, - "InnoDB: Error: pthread_attr_setstacksize returned %d\n", ret); - exit(1); + fprintf(stderr, + "InnoDB: Error: pthread_attr_setstacksize" + " returned %d\n", ret); + exit(1); } #endif os_mutex_enter(os_sync_mutex); @@ -169,9 +171,9 @@ os_thread_create( ret = pthread_create(&pthread, &attr, start_f, arg); #endif if (ret) { - fprintf(stderr, - "InnoDB: Error: pthread_create returned %d\n", ret); - exit(1); + fprintf(stderr, + "InnoDB: Error: pthread_create returned %d\n", ret); + exit(1); } #if !(defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10)) @@ -220,7 +222,7 @@ os_thread_join( /*===========*/ os_thread_id_t thread_id) /* in: id of the thread to join */ { - return(pthread_join(thread_id, NULL)); + return(pthread_join(thread_id, NULL)); } #endif /********************************************************************* diff --git a/storage/innobase/page/page0cur.c b/storage/innobase/page/page0cur.c index 70943ec3c8a..2a440c4f479 100644 --- a/storage/innobase/page/page0cur.c +++ b/storage/innobase/page/page0cur.c @@ -66,29 +66,29 @@ page_cur_try_search_shortcut( rec = page_header_get_ptr(page, PAGE_LAST_INSERT); offsets = rec_get_offsets(rec, index, offsets, - dtuple_get_n_fields(tuple), &heap); + dtuple_get_n_fields(tuple), &heap); ut_ad(rec); ut_ad(page_rec_is_user_rec(rec)); ut_pair_min(&low_match, &low_bytes, - *ilow_matched_fields, *ilow_matched_bytes, - *iup_matched_fields, *iup_matched_bytes); + *ilow_matched_fields, *ilow_matched_bytes, + *iup_matched_fields, *iup_matched_bytes); up_match = low_match; up_bytes = low_bytes; if (page_cmp_dtuple_rec_with_match(tuple, rec, offsets, - &low_match, &low_bytes) < 0) { + &low_match, &low_bytes) < 0) { goto exit_func; } next_rec = page_rec_get_next(rec); offsets = rec_get_offsets(next_rec, index, offsets, - dtuple_get_n_fields(tuple), &heap); + dtuple_get_n_fields(tuple), &heap); if (page_cmp_dtuple_rec_with_match(tuple, next_rec, offsets, - &up_match, &up_bytes) >= 0) { + &up_match, &up_bytes) >= 0) { goto exit_func; } @@ -96,11 +96,11 @@ page_cur_try_search_shortcut( #ifdef UNIV_SEARCH_DEBUG page_cur_search_with_match(page, index, tuple, PAGE_CUR_DBG, - iup_matched_fields, - iup_matched_bytes, - ilow_matched_fields, - ilow_matched_bytes, - &cursor2); + iup_matched_fields, + iup_matched_bytes, + ilow_matched_fields, + ilow_matched_bytes, + &cursor2); ut_a(cursor2.rec == cursor->rec); if (next_rec != page_get_supremum_rec(page)) { @@ -163,20 +163,20 @@ page_cur_rec_field_extends( rec_f = rec_get_nth_field(rec, offsets, n, &rec_f_len); if (type->mtype == DATA_VARCHAR - || type->mtype == DATA_CHAR - || type->mtype == DATA_FIXBINARY - || type->mtype == DATA_BINARY - || type->mtype == DATA_BLOB - || type->mtype == DATA_VARMYSQL - || type->mtype == DATA_MYSQL) { + || type->mtype == DATA_CHAR + || type->mtype == DATA_FIXBINARY + || type->mtype == DATA_BINARY + || type->mtype == DATA_BLOB + || type->mtype == DATA_VARMYSQL + || type->mtype == DATA_MYSQL) { if (dfield_get_len(dfield) != UNIV_SQL_NULL - && rec_f_len != UNIV_SQL_NULL - && rec_f_len >= dfield_get_len(dfield) - && 0 == cmp_data_data_slow(type, - dfield_get_data(dfield), - dfield_get_len(dfield), - rec_f, dfield_get_len(dfield))) { + && rec_f_len != UNIV_SQL_NULL + && rec_f_len >= dfield_get_len(dfield) + && !cmp_data_data_slow(type, + dfield_get_data(dfield), + dfield_get_len(dfield), + rec_f, dfield_get_len(dfield))) { return(TRUE); } @@ -236,7 +236,7 @@ page_cur_search_with_match( *offsets_ = (sizeof offsets_) / sizeof *offsets_; ut_ad(page && tuple && iup_matched_fields && iup_matched_bytes - && ilow_matched_fields && ilow_matched_bytes && cursor); + && ilow_matched_fields && ilow_matched_bytes && cursor); ut_ad(dtuple_validate(tuple)); ut_ad(dtuple_check_typed(tuple)); #ifdef UNIV_DEBUG @@ -246,23 +246,24 @@ page_cur_search_with_match( # ifdef PAGE_CUR_LE_OR_EXTENDS if (mode != PAGE_CUR_LE_OR_EXTENDS) # endif /* PAGE_CUR_LE_OR_EXTENDS */ - ut_ad((mode == PAGE_CUR_L) || (mode == PAGE_CUR_LE) - || (mode == PAGE_CUR_G) || (mode == PAGE_CUR_GE)); + ut_ad(mode == PAGE_CUR_L || mode == PAGE_CUR_LE + || mode == PAGE_CUR_G || mode == PAGE_CUR_GE); #endif /* UNIV_DEBUG */ page_check_dir(page); #ifdef PAGE_CUR_ADAPT if ((page_header_get_field(page, PAGE_LEVEL) == 0) - && (mode == PAGE_CUR_LE) - && (page_header_get_field(page, PAGE_N_DIRECTION) > 3) - && (page_header_get_ptr(page, PAGE_LAST_INSERT)) - && (page_header_get_field(page, PAGE_DIRECTION) == PAGE_RIGHT)) { + && (mode == PAGE_CUR_LE) + && (page_header_get_field(page, PAGE_N_DIRECTION) > 3) + && (page_header_get_ptr(page, PAGE_LAST_INSERT)) + && (page_header_get_field(page, PAGE_DIRECTION) == PAGE_RIGHT)) { - if (page_cur_try_search_shortcut(page, index, tuple, - iup_matched_fields, iup_matched_bytes, - ilow_matched_fields, ilow_matched_bytes, - cursor)) { + if (page_cur_try_search_shortcut + (page, index, tuple, + iup_matched_fields, iup_matched_bytes, + ilow_matched_fields, ilow_matched_bytes, + cursor)) { return; } } @@ -306,11 +307,12 @@ page_cur_search_with_match( mid_rec = page_dir_slot_get_rec(slot); ut_pair_min(&cur_matched_fields, &cur_matched_bytes, - low_matched_fields, low_matched_bytes, - up_matched_fields, up_matched_bytes); + low_matched_fields, low_matched_bytes, + up_matched_fields, up_matched_bytes); offsets = rec_get_offsets(mid_rec, index, offsets, - dtuple_get_n_fields_cmp(tuple), &heap); + dtuple_get_n_fields_cmp(tuple), + &heap); cmp = cmp_dtuple_rec_with_match(tuple, mid_rec, offsets, &cur_matched_fields, @@ -321,11 +323,11 @@ low_slot_match: low_matched_fields = cur_matched_fields; low_matched_bytes = cur_matched_bytes; - } else if (UNIV_LIKELY(cmp /* == -1 */)) { + } else if (UNIV_EXPECT(cmp, -1)) { #ifdef PAGE_CUR_LE_OR_EXTENDS if (mode == PAGE_CUR_LE_OR_EXTENDS - && page_cur_rec_field_extends(tuple, mid_rec, - offsets, cur_matched_fields)) { + && page_cur_rec_field_extends + (tuple, mid_rec, offsets, cur_matched_fields)) { goto low_slot_match; } @@ -339,7 +341,7 @@ up_slot_match: #ifdef PAGE_CUR_LE_OR_EXTENDS || mode == PAGE_CUR_LE_OR_EXTENDS #endif /* PAGE_CUR_LE_OR_EXTENDS */ - ) { + ) { goto low_slot_match; } else { @@ -361,11 +363,12 @@ up_slot_match: mid_rec = page_rec_get_next(low_rec); ut_pair_min(&cur_matched_fields, &cur_matched_bytes, - low_matched_fields, low_matched_bytes, - up_matched_fields, up_matched_bytes); + low_matched_fields, low_matched_bytes, + up_matched_fields, up_matched_bytes); offsets = rec_get_offsets(mid_rec, index, offsets, - dtuple_get_n_fields_cmp(tuple), &heap); + dtuple_get_n_fields_cmp(tuple), + &heap); cmp = cmp_dtuple_rec_with_match(tuple, mid_rec, offsets, &cur_matched_fields, @@ -376,11 +379,11 @@ low_rec_match: low_matched_fields = cur_matched_fields; low_matched_bytes = cur_matched_bytes; - } else if (UNIV_LIKELY(cmp /* == -1 */)) { + } else if (UNIV_EXPECT(cmp, -1)) { #ifdef PAGE_CUR_LE_OR_EXTENDS if (mode == PAGE_CUR_LE_OR_EXTENDS - && page_cur_rec_field_extends(tuple, mid_rec, - offsets, cur_matched_fields)) { + && page_cur_rec_field_extends + (tuple, mid_rec, offsets, cur_matched_fields)) { goto low_rec_match; } @@ -393,7 +396,7 @@ up_rec_match: #ifdef PAGE_CUR_LE_OR_EXTENDS || mode == PAGE_CUR_LE_OR_EXTENDS #endif /* PAGE_CUR_LE_OR_EXTENDS */ - ) { + ) { goto low_rec_match; } else { @@ -410,10 +413,10 @@ up_rec_match: dbg_matched_bytes = 0; offsets = rec_get_offsets(low_rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); dbg_cmp = page_cmp_dtuple_rec_with_match(tuple, low_rec, offsets, - &dbg_matched_fields, - &dbg_matched_bytes); + &dbg_matched_fields, + &dbg_matched_bytes); if (mode == PAGE_CUR_G) { ut_a(dbg_cmp >= 0); } else if (mode == PAGE_CUR_GE) { @@ -434,10 +437,10 @@ up_rec_match: dbg_matched_bytes = 0; offsets = rec_get_offsets(up_rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); dbg_cmp = page_cmp_dtuple_rec_with_match(tuple, up_rec, offsets, - &dbg_matched_fields, - &dbg_matched_bytes); + &dbg_matched_fields, + &dbg_matched_bytes); if (mode == PAGE_CUR_G) { ut_a(dbg_cmp == -1); } else if (mode == PAGE_CUR_GE) { @@ -533,7 +536,7 @@ page_cur_insert_rec_write_log( ut_a(rec_size < UNIV_PAGE_SIZE); ut_ad(buf_frame_align(insert_rec) == buf_frame_align(cursor_rec)); ut_ad(!page_rec_is_comp(insert_rec) - == !dict_table_is_comp(index->table)); + == !dict_table_is_comp(index->table)); comp = page_rec_is_comp(insert_rec); { @@ -548,9 +551,9 @@ page_cur_insert_rec_write_log( *ins_offs_ = (sizeof ins_offs_) / sizeof *ins_offs_; cur_offs = rec_get_offsets(cursor_rec, index, cur_offs_, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); ins_offs = rec_get_offsets(insert_rec, index, ins_offs_, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); extra_size = rec_offs_extra_size(ins_offs); cur_extra_size = rec_offs_extra_size(cur_offs); @@ -583,9 +586,10 @@ page_cur_insert_rec_write_log( ins_ptr++; cur_ptr++; } else if ((i < extra_size) - && (i >= extra_size - (comp - ? REC_N_NEW_EXTRA_BYTES - : REC_N_OLD_EXTRA_BYTES))) { + && (i >= extra_size + - (comp + ? REC_N_NEW_EXTRA_BYTES + : REC_N_OLD_EXTRA_BYTES))) { i = extra_size; ins_ptr = insert_rec; cur_ptr = cursor_rec; @@ -598,9 +602,11 @@ page_cur_insert_rec_write_log( if (mtr_get_log_mode(mtr) != MTR_LOG_SHORT_INSERTS) { log_ptr = mlog_open_and_write_index(mtr, insert_rec, index, - comp - ? MLOG_COMP_REC_INSERT : MLOG_REC_INSERT, - 2 + 5 + 1 + 5 + 5 + MLOG_BUF_MARGIN); + comp + ? MLOG_COMP_REC_INSERT + : MLOG_REC_INSERT, + 2 + 5 + 1 + 5 + 5 + + MLOG_BUF_MARGIN); if (!log_ptr) { /* Logging in mtr is switched off during crash @@ -611,7 +617,7 @@ page_cur_insert_rec_write_log( log_end = &log_ptr[2 + 5 + 1 + 5 + 5 + MLOG_BUF_MARGIN]; /* Write the cursor rec offset as a 2-byte ulint */ mach_write_to_2(log_ptr, cursor_rec - - buf_frame_align(cursor_rec)); + - buf_frame_align(cursor_rec)); log_ptr += 2; } else { log_ptr = mlog_open(mtr, 5 + 1 + 5 + 5 + MLOG_BUF_MARGIN); @@ -623,10 +629,10 @@ page_cur_insert_rec_write_log( log_end = &log_ptr[5 + 1 + 5 + 5 + MLOG_BUF_MARGIN]; } - if ((rec_get_info_and_status_bits(insert_rec, comp) != - rec_get_info_and_status_bits(cursor_rec, comp)) - || (extra_size != cur_extra_size) - || (rec_size != cur_rec_size)) { + if ((rec_get_info_and_status_bits(insert_rec, comp) + != rec_get_info_and_status_bits(cursor_rec, comp)) + || (extra_size != cur_extra_size) + || (rec_size != cur_rec_size)) { extra_info_yes = 1; } else { @@ -636,11 +642,12 @@ page_cur_insert_rec_write_log( /* Write the record end segment length and the extra info storage flag */ log_ptr += mach_write_compressed(log_ptr, 2 * (rec_size - i) - + extra_info_yes); + + extra_info_yes); if (extra_info_yes) { /* Write the info bits */ - mach_write_to_1(log_ptr, - rec_get_info_and_status_bits(insert_rec, comp)); + mach_write_to_1 + (log_ptr, + rec_get_info_and_status_bits(insert_rec, comp)); log_ptr++; /* Write the record origin offset */ @@ -786,11 +793,11 @@ page_cur_parse_insert_rec( } offsets = rec_get_offsets(cursor_rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (extra_info_yes == 0) { - info_and_status_bits = rec_get_info_and_status_bits( - cursor_rec, page_is_comp(page)); + info_and_status_bits = rec_get_info_and_status_bits + (cursor_rec, page_is_comp(page)); origin_offset = rec_offs_extra_size(offsets); mismatch_index = rec_offs_size(offsets) - end_seg_len; } @@ -827,12 +834,12 @@ page_cur_parse_insert_rec( ut_memcpy(buf + mismatch_index, ptr, end_seg_len); rec_set_info_and_status_bits(buf + origin_offset, page_is_comp(page), - info_and_status_bits); + info_and_status_bits); page_cur_position(cursor_rec, &cursor); offsets = rec_get_offsets(buf + origin_offset, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); page_cur_rec_insert(&cursor, buf + origin_offset, index, offsets, mtr); if (buf != buf1) { @@ -868,9 +875,11 @@ page_cur_insert_rec_low( byte* insert_buf = NULL; ulint rec_size; byte* page; /* the relevant page */ - rec_t* last_insert; /* cursor position at previous insert */ + rec_t* last_insert; /* cursor position at previous + insert */ rec_t* insert_rec; /* inserted record */ - ulint heap_no; /* heap number of the inserted record */ + ulint heap_no; /* heap number of the inserted + record */ rec_t* current_rec; /* current record after which the new record is inserted */ rec_t* next_rec; /* next record after current before @@ -899,7 +908,7 @@ page_cur_insert_rec_low( } else { if (!offsets) { offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); } ut_ad(rec_offs_validate(rec, index, offsets)); rec_size = rec_offs_size(offsets); @@ -918,9 +927,9 @@ page_cur_insert_rec_low( /* 3. Create the record */ if (tuple != NULL) { insert_rec = rec_convert_dtuple_to_rec(insert_buf, - index, tuple); + index, tuple); offsets = rec_get_offsets(insert_rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); } else { insert_rec = rec_copy(insert_buf, rec, offsets); ut_ad(rec_offs_validate(rec, index, offsets)); @@ -953,26 +962,30 @@ page_cur_insert_rec_low( last_insert = page_header_get_ptr(page, PAGE_LAST_INSERT); ut_ad(!last_insert || !comp - || rec_get_node_ptr_flag(last_insert) - == rec_get_node_ptr_flag(insert_rec)); + || rec_get_node_ptr_flag(last_insert) + == rec_get_node_ptr_flag(insert_rec)); if (last_insert == NULL) { page_header_set_field(page, PAGE_DIRECTION, PAGE_NO_DIRECTION); page_header_set_field(page, PAGE_N_DIRECTION, 0); } else if ((last_insert == current_rec) - && (page_header_get_field(page, PAGE_DIRECTION) != PAGE_LEFT)) { + && (page_header_get_field(page, PAGE_DIRECTION) + != PAGE_LEFT)) { page_header_set_field(page, PAGE_DIRECTION, PAGE_RIGHT); page_header_set_field(page, PAGE_N_DIRECTION, - page_header_get_field(page, PAGE_N_DIRECTION) + 1); + page_header_get_field + (page, PAGE_N_DIRECTION) + 1); } else if ((page_rec_get_next(insert_rec) == last_insert) - && (page_header_get_field(page, PAGE_DIRECTION) != PAGE_RIGHT)) { + && (page_header_get_field(page, PAGE_DIRECTION) + != PAGE_RIGHT)) { page_header_set_field(page, PAGE_DIRECTION, PAGE_LEFT); page_header_set_field(page, PAGE_N_DIRECTION, - page_header_get_field(page, PAGE_N_DIRECTION) + 1); + page_header_get_field + (page, PAGE_N_DIRECTION) + 1); } else { page_header_set_field(page, PAGE_DIRECTION, PAGE_NO_DIRECTION); page_header_set_field(page, PAGE_N_DIRECTION, 0); @@ -997,7 +1010,7 @@ page_cur_insert_rec_low( /* 9. Write log record of the insert */ page_cur_insert_rec_write_log(insert_rec, rec_size, current_rec, - index, mtr); + index, mtr); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -1022,9 +1035,9 @@ page_copy_rec_list_to_created_page_write_log( ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table)); log_ptr = mlog_open_and_write_index(mtr, page, index, - page_is_comp(page) - ? MLOG_COMP_LIST_END_COPY_CREATED - : MLOG_LIST_END_COPY_CREATED, 4); + page_is_comp(page) + ? MLOG_COMP_LIST_END_COPY_CREATED + : MLOG_LIST_END_COPY_CREATED, 4); ut_a(log_ptr); mlog_close(mtr, log_ptr + 4); @@ -1069,7 +1082,7 @@ page_parse_copy_rec_list_to_created_page( while (ptr < rec_end) { ptr = page_cur_parse_insert_rec(TRUE, ptr, end_ptr, - index, page, mtr); + index, page, mtr); } ut_a(ptr == rec_end); @@ -1130,11 +1143,11 @@ page_copy_rec_list_end_to_created_page( in the debug version */ page_dir_set_n_slots(new_page, UNIV_PAGE_SIZE / 2); page_header_set_ptr(new_page, PAGE_HEAP_TOP, - new_page + UNIV_PAGE_SIZE - 1); + new_page + UNIV_PAGE_SIZE - 1); #endif log_ptr = page_copy_rec_list_to_created_page_write_log(new_page, - index, mtr); + index, mtr); log_data_len = dyn_array_get_data_size(&(mtr->log)); @@ -1155,7 +1168,7 @@ page_copy_rec_list_end_to_created_page( /* should be do ... until, comment by Jani */ while (rec != page_get_supremum_rec(page)) { offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); insert_rec = rec_copy(heap_top, rec, offsets); rec_set_next_offs(prev_rec, comp, insert_rec - new_page); @@ -1185,13 +1198,13 @@ page_copy_rec_list_end_to_created_page( } page_cur_insert_rec_write_log(insert_rec, rec_size, prev_rec, - index, mtr); + index, mtr); prev_rec = insert_rec; rec = page_rec_get_next(rec); } if ((slot_index > 0) && (count + 1 - + (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2 + + (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2 <= PAGE_DIR_SLOT_MAX_N_OWNED)) { /* We can merge the two last dir slots. This operation is here to make this function imitate exactly the equivalent @@ -1218,7 +1231,7 @@ page_copy_rec_list_end_to_created_page( mach_write_to_4(log_ptr, log_data_len); rec_set_next_offs(insert_rec, comp, - comp ? PAGE_NEW_SUPREMUM : PAGE_OLD_SUPREMUM); + comp ? PAGE_NEW_SUPREMUM : PAGE_OLD_SUPREMUM); slot = page_dir_get_nth_slot(new_page, 1 + slot_index); @@ -1254,9 +1267,9 @@ page_cur_delete_rec_write_log( ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); log_ptr = mlog_open_and_write_index(mtr, rec, index, - page_rec_is_comp(rec) - ? MLOG_COMP_REC_DELETE - : MLOG_REC_DELETE, 2); + page_rec_is_comp(rec) + ? MLOG_COMP_REC_DELETE + : MLOG_REC_DELETE, 2); if (!log_ptr) { /* Logging in mtr is switched off during crash recovery: @@ -1306,8 +1319,9 @@ page_cur_parse_delete_rec( page_cur_position(rec, &cursor); page_cur_delete_rec(&cursor, index, - rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &heap), mtr); + rec_get_offsets(rec, index, offsets_, + ULINT_UNDEFINED, &heap), + mtr); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1390,7 +1404,7 @@ page_cur_delete_rec( page_rec_set_next(prev_rec, next_rec); page_header_set_field(page, PAGE_N_RECS, - (ulint)(page_get_n_recs(page) - 1)); + (ulint)(page_get_n_recs(page) - 1)); /* 4. If the deleted record is pointed to by a dir slot, update the record pointer in slot. In the following if-clause we assume that diff --git a/storage/innobase/page/page0page.c b/storage/innobase/page/page0page.c index a7a0dd4b788..0c869445546 100644 --- a/storage/innobase/page/page0page.c +++ b/storage/innobase/page/page0page.c @@ -104,9 +104,10 @@ page_dir_find_owner_slot( if (UNIV_UNLIKELY(slot == first_slot)) { fprintf(stderr, - "InnoDB: Probable data corruption on page %lu\n" - "InnoDB: Original record ", - (ulong) buf_frame_get_page_no(page)); + "InnoDB: Probable data corruption on" + " page %lu\n" + "InnoDB: Original record ", + (ulong) buf_frame_get_page_no(page)); if (page_is_comp(page)) { fputs("(compact record)", stderr); @@ -115,17 +116,17 @@ page_dir_find_owner_slot( } fputs("\n" - "InnoDB: on that page.\n" - "InnoDB: Cannot find the dir slot for record ", - stderr); + "InnoDB: on that page.\n" + "InnoDB: Cannot find the dir slot for record ", + stderr); if (page_is_comp(page)) { fputs("(compact record)", stderr); } else { rec_print_old(stderr, page - + mach_decode_2(rec_offs_bytes)); + + mach_decode_2(rec_offs_bytes)); } fputs("\n" - "InnoDB: on that page!\n", stderr); + "InnoDB: on that page!\n", stderr); buf_page_print(page); @@ -163,7 +164,7 @@ page_dir_slot_check( ut_a(page_rec_check(page_dir_slot_get_rec(slot))); n_owned = rec_get_n_owned(page_dir_slot_get_rec(slot), - page_is_comp(page)); + page_is_comp(page)); if (slot == page_dir_get_nth_slot(page, 0)) { ut_a(n_owned == 1); @@ -242,17 +243,17 @@ page_mem_alloc( *offsets_ = (sizeof offsets_) / sizeof *offsets_; offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (rec_offs_size(offsets) >= need) { page_header_set_ptr(page, PAGE_FREE, - page_rec_get_next(rec)); + page_rec_get_next(rec)); garbage = page_header_get_field(page, PAGE_GARBAGE); ut_ad(garbage >= need); page_header_set_field(page, PAGE_GARBAGE, - garbage - need); + garbage - need); *heap_no = rec_get_heap_no(rec, page_is_comp(page)); @@ -297,8 +298,9 @@ page_create_write_log( mtr_t* mtr, /* in: mini-transaction handle */ ulint comp) /* in: nonzero=compact page format */ { - mlog_write_initial_log_record(frame, - comp ? MLOG_COMP_PAGE_CREATE : MLOG_PAGE_CREATE, mtr); + mlog_write_initial_log_record(frame, comp + ? MLOG_COMP_PAGE_CREATE + : MLOG_PAGE_CREATE, mtr); } /*************************************************************** @@ -379,7 +381,7 @@ page_create( dfield_set_data(field, "infimum", 8); dtype_set(dfield_get_type(field), - DATA_VARCHAR, DATA_ENGLISH | DATA_NOT_NULL, 8, 0); + DATA_VARCHAR, DATA_ENGLISH | DATA_NOT_NULL, 8, 0); /* Set the corresponding physical record to its place in the page record heap */ @@ -387,13 +389,13 @@ page_create( infimum_rec = rec_convert_dtuple_to_rec(heap_top, index, tuple); - ut_a(infimum_rec == - page + (comp ? PAGE_NEW_INFIMUM : PAGE_OLD_INFIMUM)); + ut_a(infimum_rec == page + + (comp ? PAGE_NEW_INFIMUM : PAGE_OLD_INFIMUM)); rec_set_n_owned(infimum_rec, comp, 1); rec_set_heap_no(infimum_rec, comp, 0); offsets = rec_get_offsets(infimum_rec, index, NULL, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); heap_top = rec_get_end(infimum_rec, offsets); @@ -405,22 +407,22 @@ page_create( dfield_set_data(field, "supremum", comp ? 8 : 9); dtype_set(dfield_get_type(field), - DATA_VARCHAR, DATA_ENGLISH | DATA_NOT_NULL, comp ? 8 : 9, 0); + DATA_VARCHAR, DATA_ENGLISH | DATA_NOT_NULL, comp ? 8 : 9, 0); supremum_rec = rec_convert_dtuple_to_rec(heap_top, index, tuple); - ut_a(supremum_rec == - page + (comp ? PAGE_NEW_SUPREMUM : PAGE_OLD_SUPREMUM)); + ut_a(supremum_rec == page + + (comp ? PAGE_NEW_SUPREMUM : PAGE_OLD_SUPREMUM)); rec_set_n_owned(supremum_rec, comp, 1); rec_set_heap_no(supremum_rec, comp, 1); offsets = rec_get_offsets(supremum_rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); heap_top = rec_get_end(supremum_rec, offsets); - ut_ad(heap_top == - page + (comp ? PAGE_NEW_SUPREMUM_END : PAGE_OLD_SUPREMUM_END)); + ut_ad(heap_top == page + + (comp ? PAGE_NEW_SUPREMUM_END : PAGE_OLD_SUPREMUM_END)); mem_heap_free(heap); @@ -437,7 +439,7 @@ page_create( page_header_set_field(page, PAGE_N_RECS, 0); page_set_max_trx_id(page, ut_dulint_zero); memset(heap_top, 0, UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START - - (heap_top - page)); + - (heap_top - page)); /* 5. SET POINTERS IN RECORDS AND DIR SLOTS */ @@ -486,11 +488,11 @@ page_copy_rec_list_end_no_locks( } ut_a((ibool)!!page_is_comp(new_page) - == dict_table_is_comp(index->table)); + == dict_table_is_comp(index->table)); ut_a(page_is_comp(new_page) == page_is_comp(page)); ut_a(mach_read_from_2(new_page + UNIV_PAGE_SIZE - 10) == (ulint) - (page_is_comp(new_page) - ? PAGE_NEW_INFIMUM : PAGE_OLD_INFIMUM)); + (page_is_comp(new_page) + ? PAGE_NEW_INFIMUM : PAGE_OLD_INFIMUM)); page_cur_set_before_first(new_page, &cur2); @@ -504,9 +506,9 @@ page_copy_rec_list_end_no_locks( break; } offsets = rec_get_offsets(cur1_rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (UNIV_UNLIKELY(!page_cur_rec_insert(&cur2, cur1_rec, index, - offsets, mtr))) { + offsets, mtr))) { /* Track an assertion failure reported on the mailing list on June 18th, 2003 */ @@ -515,7 +517,8 @@ page_copy_rec_list_end_no_locks( ut_print_timestamp(stderr); fprintf(stderr, -"InnoDB: rec offset %lu, cur1 offset %lu, cur2 offset %lu\n", + "InnoDB: rec offset %lu, cur1 offset %lu," + " cur2 offset %lu\n", (ulong)(rec - page), (ulong)(page_cur_get_rec(&cur1) - page), (ulong)(page_cur_get_rec(&cur2) - new_page)); @@ -548,10 +551,10 @@ page_copy_rec_list_end( { if (page_dir_get_n_heap(new_page) == 2) { page_copy_rec_list_end_to_created_page(new_page, page, rec, - index, mtr); + index, mtr); } else { page_copy_rec_list_end_no_locks(new_page, page, rec, - index, mtr); + index, mtr); } /* Update the lock table, MAX_TRX_ID, and possible hash index */ @@ -604,9 +607,9 @@ page_copy_rec_list_start( rec_t* ins_rec; rec_t* cur1_rec = page_cur_get_rec(&cur1); offsets = rec_get_offsets(cur1_rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); ins_rec = page_cur_rec_insert(&cur2, cur1_rec, index, - offsets, mtr); + offsets, mtr); ut_a(ins_rec); page_cur_move_to_next(&cur1); @@ -640,9 +643,9 @@ page_delete_rec_list_write_log( { byte* log_ptr; ut_ad(type == MLOG_LIST_END_DELETE - || type == MLOG_LIST_START_DELETE - || type == MLOG_COMP_LIST_END_DELETE - || type == MLOG_COMP_LIST_START_DELETE); + || type == MLOG_LIST_START_DELETE + || type == MLOG_COMP_LIST_END_DELETE + || type == MLOG_COMP_LIST_START_DELETE); log_ptr = mlog_open_and_write_index(mtr, rec, index, type, 2); if (log_ptr) { @@ -672,9 +675,9 @@ page_parse_delete_rec_list( ulint offset; ut_ad(type == MLOG_LIST_END_DELETE - || type == MLOG_LIST_START_DELETE - || type == MLOG_COMP_LIST_END_DELETE - || type == MLOG_COMP_LIST_START_DELETE); + || type == MLOG_LIST_START_DELETE + || type == MLOG_COMP_LIST_END_DELETE + || type == MLOG_COMP_LIST_START_DELETE); /* Read the record offset as a 2-byte ulint */ @@ -694,9 +697,10 @@ page_parse_delete_rec_list( ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table)); if (type == MLOG_LIST_END_DELETE - || type == MLOG_COMP_LIST_END_DELETE) { + || type == MLOG_COMP_LIST_END_DELETE) { page_delete_rec_list_end(page, page + offset, index, - ULINT_UNDEFINED, ULINT_UNDEFINED, mtr); + ULINT_UNDEFINED, + ULINT_UNDEFINED, mtr); } else { page_delete_rec_list_start(page, page + offset, index, mtr); } @@ -750,8 +754,9 @@ page_delete_rec_list_end( rec = page_rec_get_next(rec); } - page_delete_rec_list_write_log(rec, index, - comp ? MLOG_COMP_LIST_END_DELETE : MLOG_LIST_END_DELETE, mtr); + page_delete_rec_list_write_log(rec, index, comp + ? MLOG_COMP_LIST_END_DELETE + : MLOG_LIST_END_DELETE, mtr); if (rec == sup) { @@ -775,10 +780,10 @@ page_delete_rec_list_end( while (rec2 != sup) { ulint s; offsets = rec_get_offsets(rec2, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); s = rec_offs_size(offsets); ut_ad(rec2 - page + s - rec_offs_extra_size(offsets) - < UNIV_PAGE_SIZE); + < UNIV_PAGE_SIZE); ut_ad(size + s < UNIV_PAGE_SIZE); size += s; n_recs++; @@ -828,11 +833,11 @@ page_delete_rec_list_end( page_rec_set_next(last_rec, free); page_header_set_ptr(page, PAGE_FREE, rec); - page_header_set_field(page, PAGE_GARBAGE, - size + page_header_get_field(page, PAGE_GARBAGE)); + page_header_set_field(page, PAGE_GARBAGE, size + + page_header_get_field(page, PAGE_GARBAGE)); page_header_set_field(page, PAGE_N_RECS, - (ulint)(page_get_n_recs(page) - n_recs)); + (ulint)(page_get_n_recs(page) - n_recs)); } /***************************************************************** @@ -880,7 +885,7 @@ page_delete_rec_list_start( while (page_cur_get_rec(&cur1) != rec) { offsets = rec_get_offsets(page_cur_get_rec(&cur1), index, - offsets, ULINT_UNDEFINED, &heap); + offsets, ULINT_UNDEFINED, &heap); page_cur_delete_rec(&cur1, index, offsets, mtr); } @@ -922,7 +927,8 @@ page_move_rec_list_end( ut_ad(new_data_size >= old_data_size); page_delete_rec_list_end(page, split_rec, index, - new_n_recs - old_n_recs, new_data_size - old_data_size, mtr); + new_n_recs - old_n_recs, + new_data_size - old_data_size, mtr); } /***************************************************************** @@ -1002,7 +1008,7 @@ page_dir_delete_slots( slot = page_dir_get_nth_slot(page, start + n); page_dir_slot_set_n_owned(slot, - sum_owned + page_dir_slot_get_n_owned(slot)); + sum_owned + page_dir_slot_get_n_owned(slot)); /* 3. Destroy start and other slots by copying slots */ for (i = start + n; i < n_slots; i++) { @@ -1314,7 +1320,8 @@ page_dir_print( "PAGE DIRECTORY\n" "Page address %p\n" "Directory stack top at offs: %lu; number of slots: %lu\n", - page, (ulong)(page_dir_get_nth_slot(page, n - 1) - page), (ulong) n); + page, (ulong)(page_dir_get_nth_slot(page, n - 1) - page), + (ulong) n); for (i = 0; i < n; i++) { slot = page_dir_get_nth_slot(page, i); if ((i == pr_n) && (i < n - pr_n)) { @@ -1322,9 +1329,11 @@ page_dir_print( } if ((i < pr_n) || (i >= n - pr_n)) { fprintf(stderr, - "Contents of slot: %lu: n_owned: %lu, rec offs: %lu\n", - (ulong) i, (ulong) page_dir_slot_get_n_owned(slot), - (ulong)(page_dir_slot_get_rec(slot) - page)); + "Contents of slot: %lu: n_owned: %lu," + " rec offs: %lu\n", + (ulong) i, + (ulong) page_dir_slot_get_n_owned(slot), + (ulong)(page_dir_slot_get_rec(slot) - page)); } } fprintf(stderr, "Total of %lu records\n" @@ -1364,7 +1373,7 @@ page_print_list( count = 0; for (;;) { offsets = rec_get_offsets(cur.rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); page_rec_print(cur.rec, offsets); if (count == pr_n) { @@ -1386,7 +1395,7 @@ page_print_list( if (count + pr_n >= n_recs) { offsets = rec_get_offsets(cur.rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); page_rec_print(cur.rec, offsets); } count++; @@ -1478,15 +1487,15 @@ page_rec_validate( if (!(n_owned <= PAGE_DIR_SLOT_MAX_N_OWNED)) { fprintf(stderr, "InnoDB: Dir slot of rec %lu, n owned too big %lu\n", - (ulong)(rec - page), (ulong) n_owned); + (ulong)(rec - page), (ulong) n_owned); return(FALSE); } if (!(heap_no < page_dir_get_n_heap(page))) { fprintf(stderr, - "InnoDB: Heap no of rec %lu too big %lu %lu\n", - (ulong)(rec - page), (ulong) heap_no, - (ulong) page_dir_get_n_heap(page)); + "InnoDB: Heap no of rec %lu too big %lu %lu\n", + (ulong)(rec - page), (ulong) heap_no, + (ulong) page_dir_get_n_heap(page)); return(FALSE); } @@ -1508,18 +1517,20 @@ page_check_dir( n_slots = page_dir_get_n_slots(page); if (page_dir_slot_get_rec(page_dir_get_nth_slot(page, 0)) - != page_get_infimum_rec(page)) { + != page_get_infimum_rec(page)) { fprintf(stderr, -"InnoDB: Page directory corruption: supremum not pointed to\n"); + "InnoDB: Page directory corruption:" + " infimum not pointed to\n"); buf_page_print(page); } if (page_dir_slot_get_rec(page_dir_get_nth_slot(page, n_slots - 1)) - != page_get_supremum_rec(page)) { + != page_get_supremum_rec(page)) { fprintf(stderr, -"InnoDB: Page directory corruption: supremum not pointed to\n"); + "InnoDB: Page directory corruption:" + " supremum not pointed to\n"); buf_page_print(page); } } @@ -1553,7 +1564,8 @@ page_simple_validate( if (n_slots > UNIV_PAGE_SIZE / 4) { fprintf(stderr, - "InnoDB: Nonsensical number %lu of page dir slots\n", (ulong) n_slots); + "InnoDB: Nonsensical number %lu of page dir slots\n", + (ulong) n_slots); goto func_exit; } @@ -1563,9 +1575,12 @@ page_simple_validate( if (rec_heap_top > page_dir_get_nth_slot(page, n_slots - 1)) { fprintf(stderr, - "InnoDB: Record heap and dir overlap on a page, heap top %lu, dir %lu\n", - (ulong)(page_header_get_ptr(page, PAGE_HEAP_TOP) - page), - (ulong)(page_dir_get_nth_slot(page, n_slots - 1) - page)); + "InnoDB: Record heap and dir overlap on a page," + " heap top %lu, dir %lu\n", + (ulong) + (page_header_get_ptr(page, PAGE_HEAP_TOP) - page), + (ulong) + (page_dir_get_nth_slot(page, n_slots - 1) - page)); goto func_exit; } @@ -1585,8 +1600,10 @@ page_simple_validate( if (rec > rec_heap_top) { fprintf(stderr, - "InnoDB: Record %lu is above rec heap top %lu\n", - (ulong)(rec - page), (ulong)(rec_heap_top - page)); + "InnoDB: Record %lu is above" + " rec heap top %lu\n", + (ulong)(rec - page), + (ulong)(rec_heap_top - page)); goto func_exit; } @@ -1596,17 +1613,19 @@ page_simple_validate( if (rec_get_n_owned(rec, comp) != own_count) { fprintf(stderr, - "InnoDB: Wrong owned count %lu, %lu, rec %lu\n", - (ulong) rec_get_n_owned(rec, comp), - (ulong) own_count, - (ulong)(rec - page)); + "InnoDB: Wrong owned count %lu, %lu," + " rec %lu\n", + (ulong) rec_get_n_owned(rec, comp), + (ulong) own_count, + (ulong)(rec - page)); goto func_exit; } if (page_dir_slot_get_rec(slot) != rec) { fprintf(stderr, - "InnoDB: Dir slot does not point to right rec %lu\n", + "InnoDB: Dir slot does not point" + " to right rec %lu\n", (ulong)(rec - page)); goto func_exit; @@ -1626,11 +1645,12 @@ page_simple_validate( } if (rec_get_next_offs(rec, comp) < FIL_PAGE_DATA - || rec_get_next_offs(rec, comp) >= UNIV_PAGE_SIZE) { + || rec_get_next_offs(rec, comp) >= UNIV_PAGE_SIZE) { fprintf(stderr, - "InnoDB: Next record offset nonsensical %lu for rec %lu\n", - (ulong) rec_get_next_offs(rec, comp), - (ulong)(rec - page)); + "InnoDB: Next record offset" + " nonsensical %lu for rec %lu\n", + (ulong) rec_get_next_offs(rec, comp), + (ulong)(rec - page)); goto func_exit; } @@ -1639,8 +1659,9 @@ page_simple_validate( if (count > UNIV_PAGE_SIZE) { fprintf(stderr, - "InnoDB: Page record list appears to be circular %lu\n", - (ulong) count); + "InnoDB: Page record list appears" + " to be circular %lu\n", + (ulong) count); goto func_exit; } @@ -1662,8 +1683,8 @@ page_simple_validate( if (page_header_get_field(page, PAGE_N_RECS) + 2 != count + 1) { fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n", - (ulong) page_header_get_field(page, PAGE_N_RECS) + 2, - (ulong) (count + 1)); + (ulong) page_header_get_field(page, PAGE_N_RECS) + 2, + (ulong) (count + 1)); goto func_exit; } @@ -1673,18 +1694,21 @@ page_simple_validate( while (rec != NULL) { if (rec < page + FIL_PAGE_DATA - || rec >= page + UNIV_PAGE_SIZE) { + || rec >= page + UNIV_PAGE_SIZE) { fprintf(stderr, - "InnoDB: Free list record has a nonsensical offset %lu\n", - (ulong)(rec - page)); + "InnoDB: Free list record has" + " a nonsensical offset %lu\n", + (ulong) (rec - page)); goto func_exit; } if (rec > rec_heap_top) { fprintf(stderr, - "InnoDB: Free list record %lu is above rec heap top %lu\n", - (ulong)(rec - page), (ulong)(rec_heap_top - page)); + "InnoDB: Free list record %lu" + " is above rec heap top %lu\n", + (ulong) (rec - page), + (ulong) (rec_heap_top - page)); goto func_exit; } @@ -1693,7 +1717,8 @@ page_simple_validate( if (count > UNIV_PAGE_SIZE) { fprintf(stderr, - "InnoDB: Page free list appears to be circular %lu\n", + "InnoDB: Page free list appears" + " to be circular %lu\n", (ulong) count); goto func_exit; } @@ -1704,8 +1729,8 @@ page_simple_validate( if (page_dir_get_n_heap(page) != count + 1) { fprintf(stderr, "InnoDB: N heap is wrong %lu, %lu\n", - (ulong) page_dir_get_n_heap(page), - (ulong) (count + 1)); + (ulong) page_dir_get_n_heap(page), + (ulong) (count + 1)); goto func_exit; } @@ -1766,14 +1791,14 @@ page_validate( n_slots = page_dir_get_n_slots(page); - if (!(page_header_get_ptr(page, PAGE_HEAP_TOP) <= - page_dir_get_nth_slot(page, n_slots - 1))) { + if (!(page_header_get_ptr(page, PAGE_HEAP_TOP) + <= page_dir_get_nth_slot(page, n_slots - 1))) { fputs("InnoDB: Record heap and dir overlap on a page ", - stderr); + stderr); dict_index_name_print(stderr, NULL, index); fprintf(stderr, ", %p, %p\n", - page_header_get_ptr(page, PAGE_HEAP_TOP), + page_header_get_ptr(page, PAGE_HEAP_TOP), page_dir_get_nth_slot(page, n_slots - 1)); goto func_exit; @@ -1792,12 +1817,12 @@ page_validate( for (;;) { rec = cur.rec; offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (comp && page_rec_is_user_rec(rec) - && rec_get_node_ptr_flag(rec) - != (ibool) - (btr_page_get_level_low(page) != 0)) { + && rec_get_node_ptr_flag(rec) + != (ibool) + (btr_page_get_level_low(page) != 0)) { fputs("InnoDB: node_ptr flag mismatch\n", stderr); goto func_exit; } @@ -1809,9 +1834,10 @@ page_validate( /* Check that the records are in the ascending order */ if ((count >= 2) && (!page_cur_is_after_last(&cur))) { if (!(1 == cmp_rec_rec(rec, old_rec, - offsets, old_offsets, index))) { + offsets, old_offsets, index))) { fprintf(stderr, - "InnoDB: Records in wrong order on page %lu", + "InnoDB: Records in wrong order" + " on page %lu ", (ulong) buf_frame_get_page_no(page)); dict_index_name_print(stderr, NULL, index); fputs("\nInnoDB: previous record ", stderr); @@ -1836,7 +1862,7 @@ page_validate( /* No other record may overlap this */ fputs("InnoDB: Record overlaps another\n", - stderr); + stderr); goto func_exit; } @@ -1847,16 +1873,16 @@ page_validate( /* This is a record pointed to by a dir slot */ if (rec_get_n_owned(rec, comp) != own_count) { fprintf(stderr, - "InnoDB: Wrong owned count %lu, %lu\n", - (ulong) rec_get_n_owned(rec, comp), - (ulong) own_count); + "InnoDB: Wrong owned count %lu, %lu\n", + (ulong) rec_get_n_owned(rec, comp), + (ulong) own_count); goto func_exit; } if (page_dir_slot_get_rec(slot) != rec) { - fputs( - "InnoDB: Dir slot does not point to right rec\n", - stderr); + fputs("InnoDB: Dir slot does not" + " point to right rec\n", + stderr); goto func_exit; } @@ -1874,7 +1900,7 @@ page_validate( } if (rec_get_next_offs(rec, comp) < FIL_PAGE_DATA - || rec_get_next_offs(rec, comp) >= UNIV_PAGE_SIZE) { + || rec_get_next_offs(rec, comp) >= UNIV_PAGE_SIZE) { fprintf(stderr, "InnoDB: Next record offset wrong %lu\n", (ulong) rec_get_next_offs(rec, comp)); @@ -1906,14 +1932,14 @@ page_validate( if (page_header_get_field(page, PAGE_N_RECS) + 2 != count + 1) { fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n", - (ulong) page_header_get_field(page, PAGE_N_RECS) + 2, - (ulong) (count + 1)); + (ulong) page_header_get_field(page, PAGE_N_RECS) + 2, + (ulong) (count + 1)); goto func_exit; } if (data_size != page_get_data_size(page)) { fprintf(stderr, - "InnoDB: Summed data size %lu, returned by func %lu\n", + "InnoDB: Summed data size %lu, returned by func %lu\n", (ulong) data_size, (ulong) page_get_data_size(page)); goto func_exit; } @@ -1923,7 +1949,7 @@ page_validate( while (rec != NULL) { offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (!page_rec_validate(rec, offsets)) { goto func_exit; @@ -1935,8 +1961,8 @@ page_validate( for (i = 0; i < rec_offs_size(offsets); i++) { if (buf[offs + i] != 0) { - fputs( - "InnoDB: Record overlaps another in free list\n", stderr); + fputs("InnoDB: Record overlaps another" + " in free list\n", stderr); goto func_exit; } @@ -1959,7 +1985,7 @@ func_exit: mem_heap_free(heap); if (ret == FALSE) { - func_exit2: +func_exit2: fprintf(stderr, "InnoDB: Apparent corruption in page %lu in ", (ulong) buf_frame_get_page_no(page)); dict_index_name_print(stderr, NULL, index); diff --git a/storage/innobase/pars/pars0opt.c b/storage/innobase/pars/pars0opt.c index 4037f50cb5c..7c564d3ee4c 100644 --- a/storage/innobase/pars/pars0opt.c +++ b/storage/innobase/pars/pars0opt.c @@ -86,7 +86,7 @@ opt_check_exp_determined_before( while (arg) { if (!opt_check_exp_determined_before(arg, sel_node, - nth_table)) { + nth_table)) { return(FALSE); } @@ -148,10 +148,10 @@ opt_look_for_col_in_comparison_before( ut_ad(search_cond); ut_a((search_cond->func == '<') - || (search_cond->func == '>') - || (search_cond->func == '=') - || (search_cond->func == PARS_GE_TOKEN) - || (search_cond->func == PARS_LE_TOKEN)); + || (search_cond->func == '>') + || (search_cond->func == '=') + || (search_cond->func == PARS_GE_TOKEN) + || (search_cond->func == PARS_LE_TOKEN)); table = sel_node_get_nth_plan(sel_node, nth_table)->table; @@ -160,10 +160,10 @@ opt_look_for_col_in_comparison_before( return(NULL); } else if ((cmp_type == OPT_COMPARISON) - && (search_cond->func != '<') - && (search_cond->func != '>') - && (search_cond->func != PARS_GE_TOKEN) - && (search_cond->func != PARS_LE_TOKEN)) { + && (search_cond->func != '<') + && (search_cond->func != '>') + && (search_cond->func != PARS_GE_TOKEN) + && (search_cond->func != PARS_LE_TOKEN)) { return(NULL); } @@ -174,8 +174,8 @@ opt_look_for_col_in_comparison_before( sym_node = arg; if ((sym_node->token_type == SYM_COLUMN) - && (sym_node->table == table) - && (sym_node->col_no == col_no)) { + && (sym_node->table == table) + && (sym_node->col_no == col_no)) { /* sym_node contains the desired column id */ @@ -185,7 +185,7 @@ opt_look_for_col_in_comparison_before( exp = que_node_get_next(arg); if (opt_check_exp_determined_before(exp, sel_node, - nth_table)) { + nth_table)) { *op = search_cond->func; return(exp); @@ -200,11 +200,11 @@ opt_look_for_col_in_comparison_before( sym_node = arg; if ((sym_node->token_type == SYM_COLUMN) - && (sym_node->table == table) - && (sym_node->col_no == col_no)) { + && (sym_node->table == table) + && (sym_node->col_no == col_no)) { if (opt_check_exp_determined_before(exp, sel_node, - nth_table)) { + nth_table)) { *op = opt_invert_cmp_op(search_cond->func); return(exp); @@ -253,7 +253,8 @@ opt_look_for_col_in_cond_before( new_cond = search_cond->args; exp = opt_look_for_col_in_cond_before(cmp_type, col_no, - new_cond, sel_node, nth_table, op); + new_cond, sel_node, + nth_table, op); if (exp) { return(exp); @@ -262,12 +263,14 @@ opt_look_for_col_in_cond_before( new_cond = que_node_get_next(new_cond); exp = opt_look_for_col_in_cond_before(cmp_type, col_no, - new_cond, sel_node, nth_table, op); + new_cond, sel_node, + nth_table, op); return(exp); } exp = opt_look_for_col_in_comparison_before(cmp_type, col_no, - search_cond, sel_node, nth_table, op); + search_cond, sel_node, + nth_table, op); if (exp == NULL) { return(NULL); @@ -281,7 +284,8 @@ opt_look_for_col_in_cond_before( return(NULL); - } else if (!sel_node->asc && ((*op == '>') || (*op == PARS_GE_TOKEN))) { + } else if (!sel_node->asc + && ((*op == '>') || (*op == PARS_GE_TOKEN))) { return(NULL); } @@ -329,9 +333,9 @@ opt_calc_index_goodness( col_no = dict_index_get_nth_col_no(index, j); - exp = opt_look_for_col_in_cond_before(OPT_EQUAL, col_no, - sel_node->search_cond, - sel_node, nth_table, &op); + exp = opt_look_for_col_in_cond_before + (OPT_EQUAL, col_no, sel_node->search_cond, + sel_node, nth_table, &op); if (exp) { /* The value for this column is exactly known already at this stage of the join */ @@ -342,9 +346,9 @@ opt_calc_index_goodness( } else { /* Look for non-equality comparisons */ - exp = opt_look_for_col_in_cond_before(OPT_COMPARISON, - col_no, sel_node->search_cond, - sel_node, nth_table, &op); + exp = opt_look_for_col_in_cond_before + (OPT_COMPARISON, col_no, sel_node->search_cond, + sel_node, nth_table, &op); if (exp) { index_plan[j] = exp; *last_op = op; @@ -488,15 +492,15 @@ opt_check_order_by( if (i < sel_node->n_tables - 1) { ut_a(dict_index_get_n_unique(plan->index) - <= plan->n_exact_match); + <= plan->n_exact_match); } else { ut_a(plan->table == order_table); ut_a((dict_index_get_n_unique(plan->index) - <= plan->n_exact_match) - || (dict_index_get_nth_col_no(plan->index, - plan->n_exact_match) - == order_col_no)); + <= plan->n_exact_match) + || (dict_index_get_nth_col_no(plan->index, + plan->n_exact_match) + == order_col_no)); } } } @@ -541,7 +545,7 @@ opt_search_plan_for_table( /* should be do ... until ? comment by Jani */ while (index) { goodness = opt_calc_index_goodness(index, sel_node, i, - index_plan, &last_op); + index_plan, &last_op); if (goodness > best_goodness) { best_index = index; @@ -549,7 +553,7 @@ opt_search_plan_for_table( n_fields = opt_calc_n_fields_from_goodness(goodness); ut_memcpy(best_index_plan, index_plan, - n_fields * sizeof(void*)); + n_fields * sizeof(void*)); best_last_op = last_op; } @@ -565,14 +569,14 @@ opt_search_plan_for_table( plan->n_exact_match = 0; } else { plan->tuple = dtuple_create(pars_sym_tab_global->heap, - n_fields); + n_fields); dict_index_copy_types(plan->tuple, plan->index, n_fields); plan->tuple_exps = mem_heap_alloc(pars_sym_tab_global->heap, - n_fields * sizeof(void*)); + n_fields * sizeof(void*)); ut_memcpy(plan->tuple_exps, best_index_plan, - n_fields * sizeof(void*)); + n_fields * sizeof(void*)); if (best_last_op == '=') { plan->n_exact_match = n_fields; } else { @@ -580,11 +584,11 @@ opt_search_plan_for_table( } plan->mode = opt_op_to_search_mode(sel_node->asc, - best_last_op); + best_last_op); } if ((best_index->type & DICT_CLUSTERED) - && (plan->n_exact_match >= dict_index_get_n_unique(best_index))) { + && (plan->n_exact_match >= dict_index_get_n_unique(best_index))) { plan->unique_search = TRUE; } else { @@ -660,7 +664,7 @@ opt_classify_comparison( the testing is necessary when the cursor is reversed. */ if ((n_fields > plan->n_exact_match) - && opt_is_arg(plan->tuple_exps[n_fields - 1], cond)) { + && opt_is_arg(plan->tuple_exps[n_fields - 1], cond)) { return(OPT_SCROLL_COND); } @@ -671,11 +675,10 @@ opt_classify_comparison( access the table, it is classified as OPT_END_COND */ if ((dict_index_get_n_fields(plan->index) > plan->n_exact_match) - && opt_look_for_col_in_comparison_before( - OPT_COMPARISON, - dict_index_get_nth_col_no(plan->index, - plan->n_exact_match), - cond, sel_node, i, &op)) { + && opt_look_for_col_in_comparison_before + (OPT_COMPARISON, + dict_index_get_nth_col_no(plan->index, plan->n_exact_match), + cond, sel_node, i, &op)) { if (sel_node->asc && ((op == '<') || (op == PARS_LE_TOKEN))) { @@ -763,7 +766,7 @@ opt_normalize_cmp_conds( sym_node = arg2; if ((sym_node->token_type == SYM_COLUMN) - && (sym_node->table == table)) { + && (sym_node->table == table)) { /* Switch the order of the arguments */ @@ -803,7 +806,7 @@ opt_determine_and_normalize_test_conds( opt_find_test_conds(sel_node, i, sel_node->search_cond); opt_normalize_cmp_conds(UT_LIST_GET_FIRST(plan->end_conds), - plan->table); + plan->table); ut_a(UT_LIST_GET_LEN(plan->end_conds) >= plan->n_exact_match); } @@ -846,7 +849,7 @@ opt_find_all_cols( while (arg) { opt_find_all_cols(copy_val, index, col_list, plan, - arg); + arg); arg = que_node_get_next(arg); } @@ -900,10 +903,8 @@ opt_find_all_cols( /* Fill in the field_no fields in sym_node */ - sym_node->field_nos[SYM_CLUST_FIELD_NO] - = dict_index_get_nth_col_pos( - dict_table_get_first_index(index->table), - sym_node->col_no); + sym_node->field_nos[SYM_CLUST_FIELD_NO] = dict_index_get_nth_col_pos + (dict_table_get_first_index(index->table), sym_node->col_no); if (!(index->type & DICT_CLUSTERED)) { ut_a(plan); @@ -963,7 +964,7 @@ opt_find_copy_cols( plan = sel_node_get_nth_plan(sel_node, i); opt_find_all_cols(TRUE, plan->index, &(plan->columns), plan, - search_cond); + search_cond); } } @@ -998,7 +999,7 @@ opt_classify_cols( while (exp) { opt_find_all_cols(TRUE, plan->index, &(plan->columns), plan, - exp); + exp); exp = que_node_get_next(exp); } @@ -1008,7 +1009,7 @@ opt_classify_cols( columns: therefore FALSE */ opt_find_all_cols(FALSE, plan->index, &(plan->columns), plan, - sel_node->search_cond); + sel_node->search_cond); } /*********************************************************************** @@ -1069,10 +1070,11 @@ opt_clust_access( tables, and they should not contain column prefix indexes. */ if (dict_index_get_nth_field(index, pos)->prefix_len != 0 - || dict_index_get_nth_field(clust_index, i) - ->prefix_len != 0) { + || dict_index_get_nth_field(clust_index, i) + ->prefix_len != 0) { fprintf(stderr, -"InnoDB: Error in pars0opt.c: table %s has prefix_len != 0\n", + "InnoDB: Error in pars0opt.c:" + " table %s has prefix_len != 0\n", index->table_name); } @@ -1098,7 +1100,7 @@ opt_search_plan( ulint i; sel_node->plans = mem_heap_alloc(pars_sym_tab_global->heap, - sel_node->n_tables * sizeof(plan_t)); + sel_node->n_tables * sizeof(plan_t)); /* Analyze the search condition to find out what we know at each join stage about the conditions that the columns of a table should diff --git a/storage/innobase/pars/pars0pars.c b/storage/innobase/pars/pars0pars.c index 1ba28fa4fe3..214fff68c55 100644 --- a/storage/innobase/pars/pars0pars.c +++ b/storage/innobase/pars/pars0pars.c @@ -156,7 +156,7 @@ pars_func_low( node->args = arg; UT_LIST_ADD_LAST(func_node_list, pars_sym_tab_global->func_node_list, - node); + node); return(node); } @@ -241,17 +241,17 @@ pars_resolve_func_data_type( func = node->func; if ((func == PARS_SUM_TOKEN) - || (func == '+') || (func == '-') || (func == '*') - || (func == '/') || (func == '+')) { + || (func == '+') || (func == '-') || (func == '*') + || (func == '/') || (func == '+')) { /* Inherit the data type from the first argument (which must not be the SQL null literal whose type is DATA_ERROR) */ dtype_copy(que_node_get_data_type(node), - que_node_get_data_type(arg)); + que_node_get_data_type(arg)); ut_a(dtype_get_mtype(que_node_get_data_type(node)) - == DATA_INT); + == DATA_INT); } else if (func == PARS_COUNT_TOKEN) { ut_a(arg); dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0); @@ -259,33 +259,33 @@ pars_resolve_func_data_type( } else if (func == PARS_TO_CHAR_TOKEN) { ut_a(dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT); dtype_set(que_node_get_data_type(node), DATA_VARCHAR, - DATA_ENGLISH, 0, 0); + DATA_ENGLISH, 0, 0); } else if (func == PARS_TO_BINARY_TOKEN) { if (dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT) { dtype_set(que_node_get_data_type(node), DATA_VARCHAR, - DATA_ENGLISH, 0, 0); + DATA_ENGLISH, 0, 0); } else { dtype_set(que_node_get_data_type(node), DATA_BINARY, - 0, 0, 0); + 0, 0, 0); } } else if (func == PARS_TO_NUMBER_TOKEN) { ut_a(dtype_get_mtype(que_node_get_data_type(arg)) - == DATA_VARCHAR); + == DATA_VARCHAR); dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0); } else if (func == PARS_BINARY_TO_NUMBER_TOKEN) { ut_a(dtype_get_mtype(que_node_get_data_type(arg)) - == DATA_VARCHAR); + == DATA_VARCHAR); dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0); } else if (func == PARS_LENGTH_TOKEN) { ut_a(dtype_get_mtype(que_node_get_data_type(arg)) - == DATA_VARCHAR); + == DATA_VARCHAR); dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0); } else if (func == PARS_INSTR_TOKEN) { ut_a(dtype_get_mtype(que_node_get_data_type(arg)) - == DATA_VARCHAR); + == DATA_VARCHAR); dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0); } else if (func == PARS_SYSDATE_TOKEN) { @@ -293,12 +293,12 @@ pars_resolve_func_data_type( dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4, 0); } else if ((func == PARS_SUBSTR_TOKEN) - || (func == PARS_CONCAT_TOKEN)) { + || (func == PARS_CONCAT_TOKEN)) { ut_a(dtype_get_mtype(que_node_get_data_type(arg)) - == DATA_VARCHAR); + == DATA_VARCHAR); dtype_set(que_node_get_data_type(node), DATA_VARCHAR, - DATA_ENGLISH, 0, 0); + DATA_ENGLISH, 0, 0); } else if ((func == '>') || (func == '<') || (func == '=') || (func == PARS_GE_TOKEN) @@ -321,7 +321,7 @@ pars_resolve_func_data_type( ut_a(dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT); dtype_set(que_node_get_data_type(node), DATA_VARCHAR, - DATA_ENGLISH, 0, 0); + DATA_ENGLISH, 0, 0); } else { ut_error; } @@ -379,18 +379,18 @@ pars_resolve_exp_variables_and_types( while (node) { if (node->resolved - && ((node->token_type == SYM_VAR) - || (node->token_type == SYM_CURSOR) - || (node->token_type == SYM_FUNCTION)) - && node->name - && (sym_node->name_len == node->name_len) - && (ut_memcmp(sym_node->name, node->name, - node->name_len) == 0)) { + && ((node->token_type == SYM_VAR) + || (node->token_type == SYM_CURSOR) + || (node->token_type == SYM_FUNCTION)) + && node->name + && (sym_node->name_len == node->name_len) + && (ut_memcmp(sym_node->name, node->name, + node->name_len) == 0)) { - /* Found a variable or a cursor declared with - the same name */ + /* Found a variable or a cursor declared with + the same name */ - break; + break; } node = UT_LIST_GET_NEXT(sym_list, node); @@ -398,7 +398,7 @@ pars_resolve_exp_variables_and_types( if (!node) { fprintf(stderr, "PARSER ERROR: Unresolved identifier %s\n", - sym_node->name); + sym_node->name); } ut_a(node); @@ -410,11 +410,11 @@ pars_resolve_exp_variables_and_types( if (select_node) { UT_LIST_ADD_LAST(col_var_list, select_node->copy_variables, - sym_node); + sym_node); } dfield_set_type(que_node_get_val(sym_node), - que_node_get_data_type(node)); + que_node_get_data_type(node)); } /************************************************************************* @@ -493,8 +493,8 @@ pars_resolve_exp_columns( col = dict_table_get_nth_col(table, i); if ((sym_node->name_len == ut_strlen(col->name)) - && (0 == ut_memcmp(sym_node->name, col->name, - sym_node->name_len))) { + && (0 == ut_memcmp(sym_node->name, col->name, + sym_node->name_len))) { /* Found */ sym_node->resolved = TRUE; sym_node->token_type = SYM_COLUMN; @@ -607,12 +607,11 @@ pars_select_all_columns( col = dict_table_get_nth_col(table, i); col_node = sym_tab_add_id(pars_sym_tab_global, - (byte*)col->name, - ut_strlen(col->name)); + (byte*)col->name, + ut_strlen(col->name)); select_node->select_list - = que_node_list_add_last( - select_node->select_list, - col_node); + = que_node_list_add_last + (select_node->select_list, col_node); } table_node = que_node_get_next(table_node); @@ -715,14 +714,14 @@ pars_select_statement( if (select_node->into_list) { ut_a(que_node_list_get_len(select_node->into_list) - == que_node_list_get_len(select_node->select_list)); + == que_node_list_get_len(select_node->select_list)); } UT_LIST_INIT(select_node->copy_variables); pars_resolve_exp_list_columns(table_list, select_node->select_list); pars_resolve_exp_list_variables_and_types(select_node, - select_node->select_list); + select_node->select_list); pars_check_aggregate(select_node); select_node->search_cond = search_cond; @@ -806,7 +805,7 @@ pars_function_declaration( /* Check that the function exists. */ ut_a(pars_info_get_user_func(pars_sym_tab_global->info, - sym_node->name)); + sym_node->name)); return(sym_node); } @@ -849,7 +848,7 @@ pars_column_assignment( col_assign_node_t* node; node = mem_heap_alloc(pars_sym_tab_global->heap, - sizeof(col_assign_node_t)); + sizeof(col_assign_node_t)); node->common.type = QUE_NODE_COL_ASSIGNMENT; node->col = column; @@ -888,17 +887,18 @@ pars_process_assign_list( pars_resolve_exp_columns(table_sym, assign_node->col); pars_resolve_exp_columns(table_sym, assign_node->val); pars_resolve_exp_variables_and_types(NULL, assign_node->val); - - /* ut_a(dtype_get_mtype(dfield_get_type( - que_node_get_val(assign_node->col))) - == dtype_get_mtype(dfield_get_type( - que_node_get_val(assign_node->val)))); */ +#if 0 + ut_a(dtype_get_mtype + (dfield_get_type(que_node_get_val(assign_node->col))) + == dtype_get_mtype + (dfield_get_type(que_node_get_val(assign_node->val)))); +#endif /* Add to the update node all the columns found in assignment values as columns to copy: therefore, TRUE */ opt_find_all_cols(TRUE, clust_index, &(node->columns), NULL, - assign_node->val); + assign_node->val); n_assigns++; assign_node = que_node_get_next(assign_node); @@ -915,15 +915,13 @@ pars_process_assign_list( col_sym = assign_node->col; - upd_field_set_field_no(upd_field, - dict_index_get_nth_col_pos(clust_index, - col_sym->col_no), - clust_index, NULL); + upd_field_set_field_no(upd_field, dict_index_get_nth_col_pos + (clust_index, col_sym->col_no), + clust_index, NULL); upd_field->exp = assign_node->val; - if (!dtype_is_fixed_size( - dict_index_get_nth_type(clust_index, - upd_field->field_no))) { + if (!dtype_is_fixed_size(dict_index_get_nth_type + (clust_index, upd_field->field_no))) { changes_field_size = 0; } @@ -980,7 +978,7 @@ pars_update_statement( sel_node = pars_select_list(NULL, NULL); pars_select_statement(sel_node, table_sym, search_cond, NULL, - &pars_share_token, NULL); + &pars_share_token, NULL); node->searched_update = TRUE; sel_node->common.parent = node; } @@ -1027,8 +1025,8 @@ pars_update_statement( } if (!node->is_delete && node->searched_update - && (node->cmpl_info & UPD_NODE_NO_SIZE_CHANGE) - && (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { + && (node->cmpl_info & UPD_NODE_NO_SIZE_CHANGE) + && (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { /* The select node can perform the update in-place */ @@ -1070,10 +1068,10 @@ pars_insert_statement( pars_retrieve_table_def(table_sym); node = ins_node_create(ins_type, table_sym->table, - pars_sym_tab_global->heap); + pars_sym_tab_global->heap); row = dtuple_create(pars_sym_tab_global->heap, - dict_table_get_n_cols(node->table)); + dict_table_get_n_cols(node->table)); dict_table_copy_types(row, table_sym->table); @@ -1085,7 +1083,7 @@ pars_insert_statement( select->common.parent = node; ut_a(que_node_list_get_len(select->select_list) - == dict_table_get_n_user_cols(table_sym->table)); + == dict_table_get_n_user_cols(table_sym->table)); } node->values_list = values_list; @@ -1094,7 +1092,7 @@ pars_insert_statement( pars_resolve_exp_list_variables_and_types(NULL, values_list); ut_a(que_node_list_get_len(values_list) - == dict_table_get_n_user_cols(table_sym->table)); + == dict_table_get_n_user_cols(table_sym->table)); } return(node); @@ -1134,17 +1132,17 @@ pars_set_dfield_type( ut_a(len == 0); dtype_set(dfield_get_type(dfield), DATA_VARCHAR, - DATA_ENGLISH | flags, 0, 0); + DATA_ENGLISH | flags, 0, 0); } else if (type == &pars_binary_token) { ut_a(len != 0); dtype_set(dfield_get_type(dfield), DATA_FIXBINARY, - DATA_BINARY_TYPE | flags, len, 0); + DATA_BINARY_TYPE | flags, len, 0); } else if (type == &pars_blob_token) { ut_a(len == 0); dtype_set(dfield_get_type(dfield), DATA_BLOB, - DATA_BINARY_TYPE | flags, 0, 0); + DATA_BINARY_TYPE | flags, 0, 0); } else { ut_error; } @@ -1382,7 +1380,7 @@ pars_return_statement(void) return_node_t* node; node = mem_heap_alloc(pars_sym_tab_global->heap, - sizeof(return_node_t)); + sizeof(return_node_t)); node->common.type = QUE_NODE_RETURN; return(node); @@ -1401,7 +1399,7 @@ pars_assignment_statement( assign_node_t* node; node = mem_heap_alloc(pars_sym_tab_global->heap, - sizeof(assign_node_t)); + sizeof(assign_node_t)); node->common.type = QUE_NODE_ASSIGNMENT; node->var = var; @@ -1411,7 +1409,7 @@ pars_assignment_statement( pars_resolve_exp_variables_and_types(NULL, val); ut_a(dtype_get_mtype(dfield_get_type(que_node_get_val(var))) - == dtype_get_mtype(dfield_get_type(que_node_get_val(val)))); + == dtype_get_mtype(dfield_get_type(que_node_get_val(val)))); return(node); } @@ -1467,7 +1465,7 @@ pars_fetch_statement( pars_resolve_exp_variables_and_types(NULL, user_func); node->func = pars_info_get_user_func(pars_sym_tab_global->info, - user_func->name); + user_func->name); ut_a(node->func); node->into_list = NULL; @@ -1481,8 +1479,7 @@ pars_fetch_statement( if (into_list) { ut_a(que_node_list_get_len(into_list) - == que_node_list_get_len( - node->cursor_def->select_list)); + == que_node_list_get_len(node->cursor_def->select_list)); } return(node); @@ -1530,7 +1527,7 @@ pars_row_printf_statement( row_printf_node_t* node; node = mem_heap_alloc(pars_sym_tab_global->heap, - sizeof(row_printf_node_t)); + sizeof(row_printf_node_t)); node->common.type = QUE_NODE_ROW_PRINTF; node->sel_node = sel_node; @@ -1587,7 +1584,7 @@ pars_column_def( } pars_set_dfield_type(que_node_get_val(sym_node), type, len2, - is_unsigned != NULL, is_not_null != NULL); + is_unsigned != NULL, is_not_null != NULL); return(sym_node); } @@ -1636,8 +1633,8 @@ pars_create_table( dtype = dfield_get_type(que_node_get_val(column)); dict_mem_table_add_col(table, column->name, dtype->mtype, - dtype->prtype, dtype->len, - dtype->prec); + dtype->prtype, dtype->len, + dtype->prec); column->resolved = TRUE; column->token_type = SYM_COLUMN; @@ -1686,7 +1683,7 @@ pars_create_index( } index = dict_mem_index_create(table_sym->name, index_sym->name, 0, - ind_type, n_fields); + ind_type, n_fields); column = column_list; while (column) { @@ -1787,7 +1784,7 @@ pars_get_lex_chars( int len; len = pars_sym_tab_global->string_len - - pars_sym_tab_global->next_char_pos; + - pars_sym_tab_global->next_char_pos; if (len == 0) { #ifdef YYDEBUG /* fputs("SQL string ends\n", stderr); */ @@ -1808,14 +1805,14 @@ pars_get_lex_chars( len = 5; } - fwrite(pars_sym_tab_global->sql_string + - pars_sym_tab_global->next_char_pos, - 1, len, stderr); + fwrite(pars_sym_tab_global->sql_string + + pars_sym_tab_global->next_char_pos, + 1, len, stderr); } #endif /* UNIV_SQL_DEBUG */ - ut_memcpy(buf, pars_sym_tab_global->sql_string + - pars_sym_tab_global->next_char_pos, len); + ut_memcpy(buf, pars_sym_tab_global->sql_string + + pars_sym_tab_global->next_char_pos, len); *result = len; pars_sym_tab_global->next_char_pos += len; @@ -1862,8 +1859,8 @@ pars_sql( pars_sym_tab_global = sym_tab_create(heap); pars_sym_tab_global->string_len = strlen(str); - pars_sym_tab_global->sql_string = mem_heap_dup(heap, str, - pars_sym_tab_global->string_len + 1); + pars_sym_tab_global->sql_string = mem_heap_dup + (heap, str, pars_sym_tab_global->string_len + 1); pars_sym_tab_global->next_char_pos = 0; pars_sym_tab_global->info = info; @@ -1998,7 +1995,7 @@ pars_info_add_str_literal( const char* str) /* in: string */ { pars_info_add_literal(info, name, str, strlen(str), - DATA_VARCHAR, DATA_ENGLISH); + DATA_VARCHAR, DATA_ENGLISH); } /******************************************************************** diff --git a/storage/innobase/que/que0que.c b/storage/innobase/que/que0que.c index 74f331c29f2..b2663e30879 100644 --- a/storage/innobase/que/que0que.c +++ b/storage/innobase/que/que0que.c @@ -209,7 +209,7 @@ que_thr_create( thr->run_node = NULL; thr->resource = 0; - thr->lock_state = QUE_THR_LOCK_NOLOCK; + thr->lock_state = QUE_THR_LOCK_NOLOCK; UT_LIST_ADD_LAST(thrs, parent->thrs, thr); @@ -243,8 +243,8 @@ que_thr_end_wait( #endif /* UNIV_SYNC_DEBUG */ ut_ad(thr); ut_ad((thr->state == QUE_THR_LOCK_WAIT) - || (thr->state == QUE_THR_PROCEDURE_WAIT) - || (thr->state == QUE_THR_SIG_REPLY_WAIT)); + || (thr->state == QUE_THR_PROCEDURE_WAIT) + || (thr->state == QUE_THR_SIG_REPLY_WAIT)); ut_ad(thr->run_node); thr->prev_node = thr->run_node; @@ -285,8 +285,8 @@ que_thr_end_wait_no_next_thr( #endif /* UNIV_SYNC_DEBUG */ ut_ad(thr); ut_ad((thr->state == QUE_THR_LOCK_WAIT) - || (thr->state == QUE_THR_PROCEDURE_WAIT) - || (thr->state == QUE_THR_SIG_REPLY_WAIT)); + || (thr->state == QUE_THR_PROCEDURE_WAIT) + || (thr->state == QUE_THR_SIG_REPLY_WAIT)); was_active = thr->is_active; @@ -345,7 +345,8 @@ que_fork_start_command( there may be several to choose from */ /*--------------------------------------------------------------- - First we try to find a query thread in the QUE_THR_COMMAND_WAIT state */ + First we try to find a query thread in the QUE_THR_COMMAND_WAIT state + */ thr = UT_LIST_GET_FIRST(fork->thrs); @@ -531,7 +532,8 @@ que_graph_free_recursive( if (thr->magic_n != QUE_THR_MAGIC_N) { fprintf(stderr, - "que_thr struct appears corrupt; magic n %lu\n", + "que_thr struct appears corrupt;" + " magic n %lu\n", (unsigned long) thr->magic_n); mem_analyze_corruption(thr); ut_error; @@ -644,7 +646,7 @@ que_graph_free_recursive( break; default: fprintf(stderr, - "que_node struct appears corrupt; type %lu\n", + "que_node struct appears corrupt; type %lu\n", (unsigned long) que_node_get_type(node)); mem_analyze_corruption(node); ut_error; @@ -702,7 +704,7 @@ que_graph_try_free( sess = (graph->trx)->sess; if ((graph->state == QUE_FORK_BEING_FREED) - && (graph->n_active_thrs == 0)) { + && (graph->n_active_thrs == 0)) { UT_LIST_REMOVE(graphs, sess->graphs, graph); que_graph_free(graph); @@ -831,7 +833,7 @@ que_thr_dec_refer_count( running the thread */ /* fputs("!!!!!!!! Wait already ended: continue thr\n", - stderr); */ + stderr); */ if (next_thr && *next_thr == NULL) { /* Normally srv_suspend_mysql_thread resets @@ -944,13 +946,13 @@ que_thr_stop( thr->state = QUE_THR_LOCK_WAIT; } else if (trx->error_state != DB_SUCCESS - && trx->error_state != DB_LOCK_WAIT) { + && trx->error_state != DB_LOCK_WAIT) { /* Error handling built for the MySQL interface */ thr->state = QUE_THR_COMPLETED; } else if (UT_LIST_GET_LEN(trx->signals) > 0 - && graph->fork_type != QUE_FORK_ROLLBACK) { + && graph->fork_type != QUE_FORK_ROLLBACK) { thr->state = QUE_THR_SUSPENDED; } else { @@ -982,7 +984,7 @@ que_thr_stop_for_mysql( if (thr->state == QUE_THR_RUNNING) { if (trx->error_state != DB_SUCCESS - && trx->error_state != DB_LOCK_WAIT) { + && trx->error_state != DB_LOCK_WAIT) { /* Error handling built for the MySQL interface */ thr->state = QUE_THR_COMPLETED; @@ -1022,7 +1024,7 @@ que_thr_move_to_run_state_for_mysql( { if (thr->magic_n != QUE_THR_MAGIC_N) { fprintf(stderr, - "que_thr struct appears corrupt; magic n %lu\n", + "que_thr struct appears corrupt; magic n %lu\n", (unsigned long) thr->magic_n); mem_analyze_corruption(thr); @@ -1059,7 +1061,7 @@ que_thr_stop_for_mysql_no_error( if (thr->magic_n != QUE_THR_MAGIC_N) { fprintf(stderr, - "que_thr struct appears corrupt; magic n %lu\n", + "que_thr struct appears corrupt; magic n %lu\n", (unsigned long) thr->magic_n); mem_analyze_corruption(thr); @@ -1165,7 +1167,8 @@ que_node_print_info( str = "UNKNOWN NODE TYPE"; } - fprintf(stderr, "Node type %lu: %s, address %p\n", (ulong) type, str, node); + fprintf(stderr, "Node type %lu: %s, address %p\n", + (ulong) type, str, (void*) node); } /************************************************************************** @@ -1204,7 +1207,7 @@ que_thr_step( #endif if (type & QUE_NODE_CONTROL_STAT) { if ((thr->prev_node != que_node_get_parent(node)) - && que_node_get_next(thr->prev_node)) { + && que_node_get_next(thr->prev_node)) { /* The control statements, like WHILE, always pass the control to the next child statement if there is any @@ -1224,7 +1227,7 @@ que_thr_step( if (thr->prev_node == que_node_get_parent(node)) { trx->last_sql_stat_start.least_undo_no - = trx->undo_no; + = trx->undo_no; } proc_step(thr); @@ -1251,9 +1254,9 @@ que_thr_step( } else if (type == QUE_NODE_LOCK) { ut_error; -/* + /* thr = que_lock_step(thr); -*/ + */ } else if (type == QUE_NODE_THR) { thr = que_thr_node_step(thr); } else if (type == QUE_NODE_COMMIT) { diff --git a/storage/innobase/read/read0read.c b/storage/innobase/read/read0read.c index 1d6809ae5b7..4b9a116c3c1 100644 --- a/storage/innobase/read/read0read.c +++ b/storage/innobase/read/read0read.c @@ -175,7 +175,7 @@ read_view_oldest_copy_or_open_new( n = old_view->n_trx_ids; if (ut_dulint_cmp(old_view->creator_trx_id, - ut_dulint_create(0,0)) != 0) { + ut_dulint_create(0,0)) != 0) { n++; } else { needs_insert = FALSE; @@ -189,19 +189,19 @@ read_view_oldest_copy_or_open_new( i = 0; while (i < n) { if (needs_insert - && (i >= old_view->n_trx_ids - || ut_dulint_cmp(old_view->creator_trx_id, - read_view_get_nth_trx_id(old_view, i)) - > 0)) { + && (i >= old_view->n_trx_ids + || ut_dulint_cmp(old_view->creator_trx_id, + read_view_get_nth_trx_id(old_view, i)) + > 0)) { read_view_set_nth_trx_id(view_copy, i, - old_view->creator_trx_id); + old_view->creator_trx_id); needs_insert = FALSE; insert_done = 1; } else { read_view_set_nth_trx_id(view_copy, i, - read_view_get_nth_trx_id(old_view, - i - insert_done)); + read_view_get_nth_trx_id + (old_view, i - insert_done)); } i++; @@ -216,8 +216,8 @@ read_view_oldest_copy_or_open_new( if (n > 0) { /* The last active transaction has the smallest id: */ - view_copy->up_limit_id = read_view_get_nth_trx_id( - view_copy, n - 1); + view_copy->up_limit_id = read_view_get_nth_trx_id + (view_copy, n - 1); } else { view_copy->up_limit_id = old_view->up_limit_id; } @@ -267,8 +267,8 @@ read_view_open_now( while (trx) { if (ut_dulint_cmp(trx->id, cr_trx_id) != 0 - && (trx->conc_state == TRX_ACTIVE - || trx->conc_state == TRX_PREPARED)) { + && (trx->conc_state == TRX_ACTIVE + || trx->conc_state == TRX_PREPARED)) { read_view_set_nth_trx_id(view, n, trx->id); @@ -362,16 +362,16 @@ read_view_print( } fprintf(stderr, "Read view low limit trx n:o %lu %lu\n", - (ulong) ut_dulint_get_high(view->low_limit_no), - (ulong) ut_dulint_get_low(view->low_limit_no)); + (ulong) ut_dulint_get_high(view->low_limit_no), + (ulong) ut_dulint_get_low(view->low_limit_no)); fprintf(stderr, "Read view up limit trx id %lu %lu\n", - (ulong) ut_dulint_get_high(view->up_limit_id), - (ulong) ut_dulint_get_low(view->up_limit_id)); + (ulong) ut_dulint_get_high(view->up_limit_id), + (ulong) ut_dulint_get_low(view->up_limit_id)); fprintf(stderr, "Read view low limit trx id %lu %lu\n", - (ulong) ut_dulint_get_high(view->low_limit_id), - (ulong) ut_dulint_get_low(view->low_limit_id)); + (ulong) ut_dulint_get_high(view->low_limit_id), + (ulong) ut_dulint_get_low(view->low_limit_id)); fprintf(stderr, "Read view individually stored trx ids:\n"); @@ -379,8 +379,10 @@ read_view_print( for (i = 0; i < n_ids; i++) { fprintf(stderr, "Read view trx id %lu %lu\n", - (ulong) ut_dulint_get_high(read_view_get_nth_trx_id(view, i)), - (ulong) ut_dulint_get_low(read_view_get_nth_trx_id(view, i))); + (ulong) ut_dulint_get_high + (read_view_get_nth_trx_id(view, i)), + (ulong) ut_dulint_get_low + (read_view_get_nth_trx_id(view, i))); } } @@ -412,15 +414,14 @@ read_cursor_view_create_for_mysql( curview->heap = heap; /* Drop cursor tables from consideration when evaluating the need of - auto-commit */ + auto-commit */ curview->n_mysql_tables_in_use = cr_trx->n_mysql_tables_in_use; cr_trx->n_mysql_tables_in_use = 0; mutex_enter(&kernel_mutex); - curview->read_view = read_view_create_low( - UT_LIST_GET_LEN(trx_sys->trx_list), - curview->heap); + curview->read_view = read_view_create_low + (UT_LIST_GET_LEN(trx_sys->trx_list), curview->heap); view = curview->read_view; view->creator_trx_id = cr_trx->id; @@ -442,7 +443,7 @@ read_cursor_view_create_for_mysql( while (trx) { if (trx->conc_state == TRX_ACTIVE - || trx->conc_state == TRX_PREPARED) { + || trx->conc_state == TRX_PREPARED) { read_view_set_nth_trx_id(view, n, trx->id); @@ -494,7 +495,7 @@ read_cursor_view_close_for_mysql( ut_a(curview->heap); /* Add cursor's tables to the global count of active tables that - belong to this transaction */ + belong to this transaction */ trx->n_mysql_tables_in_use += curview->n_mysql_tables_in_use; mutex_enter(&kernel_mutex); diff --git a/storage/innobase/rem/rem0cmp.c b/storage/innobase/rem/rem0cmp.c index 6c29ef58ea1..57a028352fc 100644 --- a/storage/innobase/rem/rem0cmp.c +++ b/storage/innobase/rem/rem0cmp.c @@ -104,21 +104,21 @@ cmp_types_are_equal( ibool check_charsets) /* in: whether to check charsets */ { if (dtype_is_non_binary_string_type(type1->mtype, type1->prtype) - && dtype_is_non_binary_string_type(type2->mtype, type2->prtype)) { + && dtype_is_non_binary_string_type(type2->mtype, type2->prtype)) { /* Both are non-binary string types: they can be compared if and only if the charset-collation is the same */ if (check_charsets) { return(dtype_get_charset_coll(type1->prtype) - == dtype_get_charset_coll(type2->prtype)); + == dtype_get_charset_coll(type2->prtype)); } else { return(TRUE); } } if (dtype_is_binary_string_type(type1->mtype, type1->prtype) - && dtype_is_binary_string_type(type2->mtype, type2->prtype)) { + && dtype_is_binary_string_type(type2->mtype, type2->prtype)) { /* Both are binary string types: they can be compared */ @@ -131,8 +131,8 @@ cmp_types_are_equal( } if (type1->mtype == DATA_INT - && (type1->prtype & DATA_UNSIGNED) - != (type2->prtype & DATA_UNSIGNED)) { + && (type1->prtype & DATA_UNSIGNED) + != (type2->prtype & DATA_UNSIGNED)) { /* The storage format of an unsigned integer is different from a signed integer: in a signed integer we OR @@ -257,18 +257,19 @@ cmp_whole_field( case DATA_MYSQL: case DATA_BLOB: if (data_type == DATA_BLOB - && 0 != (type->prtype & DATA_BINARY_TYPE)) { + && 0 != (type->prtype & DATA_BINARY_TYPE)) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: comparing a binary BLOB with a character set sensitive\n" -"InnoDB: comparison!\n"); + " InnoDB: Error: comparing a binary BLOB" + " with a character set sensitive\n" + "InnoDB: comparison!\n"); } - return(innobase_mysql_cmp( - (int)(type->prtype & DATA_MYSQL_TYPE_MASK), - (uint)dtype_get_charset_coll(type->prtype), - a, a_length, b, b_length)); + return(innobase_mysql_cmp + ((int)(type->prtype & DATA_MYSQL_TYPE_MASK), + (uint)dtype_get_charset_coll(type->prtype), + a, a_length, b, b_length)); default: fprintf(stderr, "InnoDB: unknown type number %lu\n", @@ -322,14 +323,14 @@ cmp_data_data_slow( } if (cur_type->mtype >= DATA_FLOAT - || (cur_type->mtype == DATA_BLOB - && 0 == (cur_type->prtype & DATA_BINARY_TYPE) - && dtype_get_charset_coll(cur_type->prtype) != - DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) { + || (cur_type->mtype == DATA_BLOB + && 0 == (cur_type->prtype & DATA_BINARY_TYPE) + && dtype_get_charset_coll(cur_type->prtype) + != DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) { return(cmp_whole_field(cur_type, - data1, (unsigned) len1, - data2, (unsigned) len2)); + data1, (unsigned) len1, + data2, (unsigned) len2)); } /* Compare then the fields */ @@ -372,8 +373,8 @@ cmp_data_data_slow( } if (cur_type->mtype <= DATA_CHAR - || (cur_type->mtype == DATA_BLOB - && 0 == (cur_type->prtype & DATA_BINARY_TYPE))) { + || (cur_type->mtype == DATA_BLOB + && 0 == (cur_type->prtype & DATA_BINARY_TYPE))) { data1_byte = cmp_collate(data1_byte); data2_byte = cmp_collate(data2_byte); @@ -381,12 +382,12 @@ cmp_data_data_slow( if (data1_byte > data2_byte) { - return(1); + return(1); } else if (data1_byte < data2_byte) { - return(-1); + return(-1); } - next_byte: +next_byte: /* Next byte */ cur_bytes++; data1++; @@ -465,7 +466,7 @@ cmp_dtuple_rec_with_match( if (cur_bytes == 0 && cur_field == 0) { ulint rec_info = rec_get_info_bits(rec, - rec_offs_comp(offsets)); + rec_offs_comp(offsets)); ulint tup_info = dtuple_get_info_bits(dtuple); if (rec_info & REC_INFO_MIN_REC_FLAG) { @@ -488,7 +489,7 @@ cmp_dtuple_rec_with_match( dtuple_f_len = dfield_get_len(dtuple_field); rec_b_ptr = rec_get_nth_field(rec, offsets, - cur_field, &rec_f_len); + cur_field, &rec_f_len); /* If we have matched yet 0 bytes, it may be that one or both the fields are SQL null, or the record or dtuple may be @@ -524,16 +525,15 @@ cmp_dtuple_rec_with_match( } if (cur_type->mtype >= DATA_FLOAT - || (cur_type->mtype == DATA_BLOB - && 0 == (cur_type->prtype & DATA_BINARY_TYPE) - && dtype_get_charset_coll(cur_type->prtype) != - DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) { + || (cur_type->mtype == DATA_BLOB + && 0 == (cur_type->prtype & DATA_BINARY_TYPE) + && dtype_get_charset_coll(cur_type->prtype) + != DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) { - ret = cmp_whole_field( - cur_type, - dfield_get_data(dtuple_field), - (unsigned) dtuple_f_len, - rec_b_ptr, (unsigned) rec_f_len); + ret = cmp_whole_field(cur_type, + dfield_get_data(dtuple_field), + (unsigned) dtuple_f_len, + rec_b_ptr, (unsigned) rec_f_len); if (ret != 0) { cur_bytes = 0; @@ -548,7 +548,7 @@ cmp_dtuple_rec_with_match( rec_b_ptr = rec_b_ptr + cur_bytes; dtuple_b_ptr = (byte*)dfield_get_data(dtuple_field) - + cur_bytes; + + cur_bytes; /* Compare then the fields */ for (;;) { @@ -590,9 +590,8 @@ cmp_dtuple_rec_with_match( } if (cur_type->mtype <= DATA_CHAR - || (cur_type->mtype == DATA_BLOB - && 0 == - (cur_type->prtype & DATA_BINARY_TYPE))) { + || (cur_type->mtype == DATA_BLOB + && !(cur_type->prtype & DATA_BINARY_TYPE))) { rec_byte = cmp_collate(rec_byte); dtuple_byte = cmp_collate(dtuple_byte); @@ -608,14 +607,14 @@ cmp_dtuple_rec_with_match( goto order_resolved; } } - next_byte: +next_byte: /* Next byte */ cur_bytes++; rec_b_ptr++; dtuple_b_ptr++; } - next_field: +next_field: cur_field++; cur_bytes = 0; } @@ -627,10 +626,10 @@ cmp_dtuple_rec_with_match( order_resolved: ut_ad((ret >= - 1) && (ret <= 1)); ut_ad(ret == cmp_debug_dtuple_rec_with_match(dtuple, rec, offsets, - matched_fields)); + matched_fields)); ut_ad(*matched_fields == cur_field); /* In the debug version, the - above cmp_debug_... sets - *matched_fields to a value */ + above cmp_debug_... sets + *matched_fields to a value */ *matched_fields = cur_field; *matched_bytes = cur_bytes; @@ -662,7 +661,7 @@ cmp_dtuple_rec( ut_ad(rec_offs_validate(rec, NULL, offsets)); return(cmp_dtuple_rec_with_match(dtuple, rec, offsets, - &matched_fields, &matched_bytes)); + &matched_fields, &matched_bytes)); } /****************************************************************** @@ -690,15 +689,15 @@ cmp_dtuple_is_prefix_of_rec( } cmp_dtuple_rec_with_match(dtuple, rec, offsets, - &matched_fields, &matched_bytes); + &matched_fields, &matched_bytes); if (matched_fields == n_fields) { return(TRUE); } if (matched_fields == n_fields - 1 - && matched_bytes == dfield_get_len( - dtuple_get_nth_field(dtuple, n_fields - 1))) { + && matched_bytes == dfield_get_len + (dtuple_get_nth_field(dtuple, n_fields - 1))) { return(TRUE); } @@ -768,25 +767,25 @@ cmp_rec_rec_with_match( if (index->type & DICT_UNIVERSAL) { cur_type = dtype_binary; } else { - cur_type = dict_col_get_type( - dict_field_get_col( - dict_index_get_nth_field(index, cur_field))); + cur_type = dict_col_get_type + (dict_field_get_col(dict_index_get_nth_field + (index, cur_field))); } rec1_b_ptr = rec_get_nth_field(rec1, offsets1, - cur_field, &rec1_f_len); + cur_field, &rec1_f_len); rec2_b_ptr = rec_get_nth_field(rec2, offsets2, - cur_field, &rec2_f_len); + cur_field, &rec2_f_len); if (cur_bytes == 0) { if (cur_field == 0) { /* Test if rec is the predefined minimum record */ if (rec_get_info_bits(rec1, comp) - & REC_INFO_MIN_REC_FLAG) { + & REC_INFO_MIN_REC_FLAG) { if (rec_get_info_bits(rec2, comp) - & REC_INFO_MIN_REC_FLAG) { + & REC_INFO_MIN_REC_FLAG) { ret = 0; } else { ret = -1; @@ -804,7 +803,7 @@ cmp_rec_rec_with_match( } if (rec_offs_nth_extern(offsets1, cur_field) - || rec_offs_nth_extern(offsets2, cur_field)) { + || rec_offs_nth_extern(offsets2, cur_field)) { /* We do not compare to an externally stored field */ @@ -814,7 +813,7 @@ cmp_rec_rec_with_match( } if (rec1_f_len == UNIV_SQL_NULL - || rec2_f_len == UNIV_SQL_NULL) { + || rec2_f_len == UNIV_SQL_NULL) { if (rec1_f_len == rec2_f_len) { @@ -836,14 +835,16 @@ cmp_rec_rec_with_match( } if (cur_type->mtype >= DATA_FLOAT - || (cur_type->mtype == DATA_BLOB - && 0 == (cur_type->prtype & DATA_BINARY_TYPE) - && dtype_get_charset_coll(cur_type->prtype) != - DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) { + || (cur_type->mtype == DATA_BLOB + && 0 == (cur_type->prtype & DATA_BINARY_TYPE) + && dtype_get_charset_coll(cur_type->prtype) + != DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL)) { ret = cmp_whole_field(cur_type, - rec1_b_ptr, (unsigned) rec1_f_len, - rec2_b_ptr, (unsigned) rec2_f_len); + rec1_b_ptr, + (unsigned) rec1_f_len, + rec2_b_ptr, + (unsigned) rec2_f_len); if (ret != 0) { cur_bytes = 0; @@ -898,9 +899,8 @@ cmp_rec_rec_with_match( } if (cur_type->mtype <= DATA_CHAR - || (cur_type->mtype == DATA_BLOB - && 0 == - (cur_type->prtype & DATA_BINARY_TYPE))) { + || (cur_type->mtype == DATA_BLOB + && !(cur_type->prtype & DATA_BINARY_TYPE))) { rec1_byte = cmp_collate(rec1_byte); rec2_byte = cmp_collate(rec2_byte); @@ -913,7 +913,7 @@ cmp_rec_rec_with_match( ret = 1; goto order_resolved; } - next_byte: +next_byte: /* Next byte */ cur_bytes++; @@ -921,7 +921,7 @@ cmp_rec_rec_with_match( rec2_b_ptr++; } - next_field: +next_field: cur_field++; cur_bytes = 0; } @@ -995,7 +995,7 @@ cmp_debug_dtuple_rec_with_match( if (cur_field == 0) { if (rec_get_info_bits(rec, rec_offs_comp(offsets)) - & REC_INFO_MIN_REC_FLAG) { + & REC_INFO_MIN_REC_FLAG) { ret = !(dtuple_get_info_bits(dtuple) & REC_INFO_MIN_REC_FLAG); @@ -1022,7 +1022,7 @@ cmp_debug_dtuple_rec_with_match( dtuple_f_len = dfield_get_len(dtuple_field); rec_f_data = rec_get_nth_field(rec, offsets, - cur_field, &rec_f_len); + cur_field, &rec_f_len); if (rec_offs_nth_extern(offsets, cur_field)) { /* We do not compare to an externally stored field */ @@ -1033,7 +1033,7 @@ cmp_debug_dtuple_rec_with_match( } ret = cmp_data_data(cur_type, dtuple_f_data, dtuple_f_len, - rec_f_data, rec_f_len); + rec_f_data, rec_f_len); if (ret != 0) { goto order_resolved; } diff --git a/storage/innobase/rem/rem0rec.c b/storage/innobase/rem/rem0rec.c index f7ee53aeda2..c57a19f0230 100644 --- a/storage/innobase/rem/rem0rec.c +++ b/storage/innobase/rem/rem0rec.c @@ -176,13 +176,13 @@ rec_init_offsets( case REC_STATUS_INFIMUM: case REC_STATUS_SUPREMUM: /* the field is 8 bytes long */ - rec_offs_base(offsets)[0] = - REC_N_NEW_EXTRA_BYTES | REC_OFFS_COMPACT; + rec_offs_base(offsets)[0] + = REC_N_NEW_EXTRA_BYTES | REC_OFFS_COMPACT; rec_offs_base(offsets)[1] = 8; return; case REC_STATUS_NODE_PTR: - n_node_ptr_field = - dict_index_get_n_unique_in_tree(index); + n_node_ptr_field + = dict_index_get_n_unique_in_tree(index); break; case REC_STATUS_ORDINARY: break; @@ -202,9 +202,9 @@ rec_init_offsets( } field = dict_index_get_nth_field(index, i); - if (!(dtype_get_prtype(dict_col_get_type( - dict_field_get_col(field))) - & DATA_NOT_NULL)) { + if (!(dtype_get_prtype(dict_col_get_type + (dict_field_get_col(field))) + & DATA_NOT_NULL)) { /* nullable field => read the null flag */ if (UNIV_UNLIKELY(!(byte) null_mask)) { @@ -226,12 +226,12 @@ rec_init_offsets( if (UNIV_UNLIKELY(!field->fixed_len)) { /* Variable-length field: read the length */ - dtype_t* type = dict_col_get_type( - dict_field_get_col(field)); + dtype_t* type = dict_col_get_type + (dict_field_get_col(field)); len = *lens--; if (UNIV_UNLIKELY(dtype_get_len(type) > 255) - || UNIV_UNLIKELY(dtype_get_mtype(type) - == DATA_BLOB)) { + || UNIV_UNLIKELY(dtype_get_mtype(type) + == DATA_BLOB)) { if (len & 0x80) { /* 1exxxxxxx xxxxxxxx */ len <<= 8; @@ -239,9 +239,9 @@ rec_init_offsets( offs += len & 0x3fff; if (UNIV_UNLIKELY(len - & 0x4000)) { + & 0x4000)) { len = offs - | REC_OFFS_EXTERNAL; + | REC_OFFS_EXTERNAL; } else { len = offs; } @@ -254,12 +254,12 @@ rec_init_offsets( } else { len = offs += field->fixed_len; } - resolved: +resolved: rec_offs_base(offsets)[i + 1] = len; } while (++i < rec_offs_n_fields(offsets)); - *rec_offs_base(offsets) = - (rec - (lens + 1)) | REC_OFFS_COMPACT; + *rec_offs_base(offsets) + = (rec - (lens + 1)) | REC_OFFS_COMPACT; } else { /* Old-style record: determine extra size and end offsets */ offs = REC_N_OLD_EXTRA_BYTES; @@ -323,7 +323,7 @@ rec_get_offsets_func( if (dict_table_is_comp(index->table)) { switch (UNIV_EXPECT(rec_get_status(rec), - REC_STATUS_ORDINARY)) { + REC_STATUS_ORDINARY)) { case REC_STATUS_ORDINARY: n = dict_index_get_n_fields(index); break; @@ -349,11 +349,12 @@ rec_get_offsets_func( size = n + (1 + REC_OFFS_HEADER_SIZE); - if (UNIV_UNLIKELY(!offsets) || - UNIV_UNLIKELY(rec_offs_get_n_alloc(offsets) < size)) { + if (UNIV_UNLIKELY(!offsets) + || UNIV_UNLIKELY(rec_offs_get_n_alloc(offsets) < size)) { if (!*heap) { *heap = mem_heap_create_func(size * sizeof(ulint), - NULL, MEM_HEAP_DYNAMIC, file, line); + NULL, MEM_HEAP_DYNAMIC, + file, line); } offsets = mem_heap_alloc(*heap, size * sizeof(ulint)); rec_offs_set_n_alloc(offsets, size); @@ -385,7 +386,7 @@ rec_get_nth_field_old( if (n > REC_MAX_N_FIELDS) { fprintf(stderr, "Error: trying to access field %lu in rec\n", - (ulong) n); + (ulong) n); ut_error; } @@ -418,7 +419,7 @@ rec_get_nth_field_old( } next_os = next_os & ~(REC_2BYTE_SQL_NULL_MASK - | REC_2BYTE_EXTERN_MASK); + | REC_2BYTE_EXTERN_MASK); } *len = next_os - os; @@ -440,7 +441,7 @@ rec_get_converted_size_new( dtuple_t* dtuple) /* in: data tuple */ { ulint size = REC_N_NEW_EXTRA_BYTES - + (index->n_nullable + 7) / 8; + + (index->n_nullable + 7) / 8; dict_field_t* field; dtype_t* type; ulint i; @@ -473,8 +474,8 @@ rec_get_converted_size_new( ulint len = dtuple_get_nth_field(dtuple, i)->len; field = dict_index_get_nth_field(index, i); type = dict_col_get_type(dict_field_get_col(field)); - ut_ad(len != UNIV_SQL_NULL || - !(dtype_get_prtype(type) & DATA_NOT_NULL)); + ut_ad(len != UNIV_SQL_NULL + || !(dtype_get_prtype(type) & DATA_NOT_NULL)); if (len == UNIV_SQL_NULL) { /* No length is stored for NULL fields. */ @@ -482,12 +483,13 @@ rec_get_converted_size_new( } ut_ad(len <= dtype_get_len(type) - || dtype_get_mtype(type) == DATA_BLOB); + || dtype_get_mtype(type) == DATA_BLOB); ut_ad(!field->fixed_len || len == field->fixed_len); if (field->fixed_len) { - } else if (len < 128 || (dtype_get_len(type) < 256 - && dtype_get_mtype(type) != DATA_BLOB)) { + } else if (len < 128 + || (dtype_get_len(type) < 256 + && dtype_get_mtype(type) != DATA_BLOB)) { size++; } else { size += 2; @@ -564,7 +566,7 @@ rec_set_nth_field_extern_bit_old( if (mtr) { mlog_write_ulint(rec - REC_N_OLD_EXTRA_BYTES - 2 * (i + 1), - info, MLOG_2BYTES, mtr); + info, MLOG_2BYTES, mtr); } else { rec_2_set_field_end_info(rec, i, info); } @@ -628,7 +630,7 @@ rec_set_nth_field_extern_bit_new( } lens--; if (dtype_get_len(type) > 255 - || dtype_get_mtype(type) == DATA_BLOB) { + || dtype_get_mtype(type) == DATA_BLOB) { ulint len = lens[1]; if (len & 0x80) { /* 1exxxxxx: 2-byte length */ if (i == ith) { @@ -638,8 +640,9 @@ rec_set_nth_field_extern_bit_new( /* toggle the extern bit */ len ^= 0x40; if (mtr) { - mlog_write_ulint(lens + 1, len, - MLOG_1BYTE, mtr); + mlog_write_ulint + (lens + 1, len, + MLOG_1BYTE, mtr); } else { lens[1] = (byte) len; } @@ -677,12 +680,12 @@ rec_set_field_extern_bits( if (dict_table_is_comp(index->table)) { for (i = 0; i < n_fields; i++) { rec_set_nth_field_extern_bit_new(rec, index, vec[i], - TRUE, mtr); + TRUE, mtr); } } else { for (i = 0; i < n_fields; i++) { rec_set_nth_field_extern_bit_old(rec, vec[i], - TRUE, mtr); + TRUE, mtr); } } } @@ -746,7 +749,7 @@ rec_convert_dtuple_to_rec_old( /* Set the info bits of the record */ rec_set_info_bits(rec, FALSE, - dtuple_get_info_bits(dtuple) & REC_INFO_BITS_MASK); + dtuple_get_info_bits(dtuple) & REC_INFO_BITS_MASK); /* Store the data and the offsets */ @@ -764,8 +767,8 @@ rec_convert_dtuple_to_rec_old( len = dfield_get_len(field); if (len == UNIV_SQL_NULL) { - len = dtype_get_sql_null_size( - dfield_get_type(field)); + len = dtype_get_sql_null_size + (dfield_get_type(field)); data_write_sql_null(rec + end_offset, len); end_offset += len; @@ -792,8 +795,8 @@ rec_convert_dtuple_to_rec_old( len = dfield_get_len(field); if (len == UNIV_SQL_NULL) { - len = dtype_get_sql_null_size( - dfield_get_type(field)); + len = dtype_get_sql_null_size + (dfield_get_type(field)); data_write_sql_null(rec + end_offset, len); end_offset += len; @@ -840,7 +843,7 @@ rec_convert_dtuple_to_rec_new( ulint null_mask = 1; const ulint n_fields = dtuple_get_n_fields(dtuple); const ulint status = dtuple_get_info_bits(dtuple) - & REC_NEW_STATUS_MASK; + & REC_NEW_STATUS_MASK; ut_ad(dict_table_is_comp(index->table)); ut_ad(n_fields > 0); @@ -898,9 +901,10 @@ rec_convert_dtuple_to_rec_new( ut_ad(len == fixed_len); } else { ut_ad(len <= dtype_get_len(type) - || dtype_get_mtype(type) == DATA_BLOB); + || dtype_get_mtype(type) == DATA_BLOB); rec++; - if (len >= 128 && (dtype_get_len(type) >= 256 + if (len >= 128 + && (dtype_get_len(type) >= 256 || dtype_get_mtype(type) == DATA_BLOB)) { rec++; } @@ -918,7 +922,7 @@ init: rec_set_status(rec, status); rec_set_info_bits(rec, TRUE, - dtuple_get_info_bits(dtuple) & REC_INFO_BITS_MASK); + dtuple_get_info_bits(dtuple) & REC_INFO_BITS_MASK); /* Store the data and the offsets */ @@ -961,12 +965,13 @@ init: ut_ad(len == fixed_len); } else { ut_ad(len <= dtype_get_len(type) - || dtype_get_mtype(type) == DATA_BLOB); - if (len < 128 || (dtype_get_len(type) < 256 + || dtype_get_mtype(type) == DATA_BLOB); + if (len < 128 + || (dtype_get_len(type) < 256 && dtype_get_mtype(type) != DATA_BLOB)) { + *lens-- = (byte) len; - } - else { + } else { /* the extern bits will be set later */ ut_ad(len < 16384); *lens-- = (byte) (len >> 8) | 0x80; @@ -1015,7 +1020,7 @@ rec_convert_dtuple_to_rec( *offsets_ = (sizeof offsets_) / sizeof *offsets_; offsets = rec_get_offsets(rec, index, - offsets_, ULINT_UNDEFINED, &heap); + offsets_, ULINT_UNDEFINED, &heap); ut_ad(rec_validate(rec, offsets)); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -1052,8 +1057,8 @@ rec_copy_prefix_to_dtuple( ut_ad(rec_validate(rec, offsets)); ut_ad(dtuple_check_typed(tuple)); - dtuple_set_info_bits(tuple, - rec_get_info_bits(rec, dict_table_is_comp(index->table))); + dtuple_set_info_bits(tuple, rec_get_info_bits + (rec, dict_table_is_comp(index->table))); for (i = 0; i < n_fields; i++) { @@ -1143,7 +1148,8 @@ rec_copy_prefix_to_buf( if (!dict_table_is_comp(index->table)) { ut_ad(rec_validate_old(rec)); - return(rec_copy_prefix_to_buf_old(rec, n_fields, + return(rec_copy_prefix_to_buf_old + (rec, n_fields, rec_get_field_start_offs(rec, n_fields), buf, buf_size)); } @@ -1196,7 +1202,7 @@ rec_copy_prefix_to_buf( } else { ulint len = *lens--; if (dtype_get_len(type) > 255 - || dtype_get_mtype(type) == DATA_BLOB) { + || dtype_get_mtype(type) == DATA_BLOB) { if (len & 0x80) { /* 1exxxxxx */ len &= 0x3f; @@ -1248,7 +1254,7 @@ rec_validate_old( if ((n_fields == 0) || (n_fields > REC_MAX_N_FIELDS)) { fprintf(stderr, "InnoDB: Error: record has %lu fields\n", - (ulong) n_fields); + (ulong) n_fields); return(FALSE); } @@ -1257,17 +1263,18 @@ rec_validate_old( if (!((len < UNIV_PAGE_SIZE) || (len == UNIV_SQL_NULL))) { fprintf(stderr, - "InnoDB: Error: record field %lu len %lu\n", (ulong) i, - (ulong) len); + "InnoDB: Error: record field %lu len %lu\n", + (ulong) i, + (ulong) len); return(FALSE); } if (len != UNIV_SQL_NULL) { len_sum += len; sum += *(data + len -1); /* dereference the - end of the field to - cause a memory trap - if possible */ + end of the field to + cause a memory trap + if possible */ } else { len_sum += rec_get_nth_field_size(rec, i); } @@ -1275,9 +1282,9 @@ rec_validate_old( if (len_sum != rec_get_data_size_old(rec)) { fprintf(stderr, - "InnoDB: Error: record len should be %lu, len %lu\n", - (ulong) len_sum, - rec_get_data_size_old(rec)); + "InnoDB: Error: record len should be %lu, len %lu\n", + (ulong) len_sum, + rec_get_data_size_old(rec)); return(FALSE); } @@ -1308,7 +1315,7 @@ rec_validate( if ((n_fields == 0) || (n_fields > REC_MAX_N_FIELDS)) { fprintf(stderr, "InnoDB: Error: record has %lu fields\n", - (ulong) n_fields); + (ulong) n_fields); return(FALSE); } @@ -1319,17 +1326,18 @@ rec_validate( if (!((len < UNIV_PAGE_SIZE) || (len == UNIV_SQL_NULL))) { fprintf(stderr, - "InnoDB: Error: record field %lu len %lu\n", (ulong) i, - (ulong) len); + "InnoDB: Error: record field %lu len %lu\n", + (ulong) i, + (ulong) len); return(FALSE); } if (len != UNIV_SQL_NULL) { len_sum += len; sum += *(data + len -1); /* dereference the - end of the field to - cause a memory trap - if possible */ + end of the field to + cause a memory trap + if possible */ } else if (!rec_offs_comp(offsets)) { len_sum += rec_get_nth_field_size(rec, i); } @@ -1337,9 +1345,9 @@ rec_validate( if (len_sum != (ulint)(rec_get_end(rec, offsets) - rec)) { fprintf(stderr, - "InnoDB: Error: record len should be %lu, len %lu\n", - (ulong) len_sum, - (ulong) (rec_get_end(rec, offsets) - rec)); + "InnoDB: Error: record len should be %lu, len %lu\n", + (ulong) len_sum, + (ulong) (rec_get_end(rec, offsets) - rec)); return(FALSE); } @@ -1477,8 +1485,9 @@ rec_print( ulint offsets_[REC_OFFS_NORMAL_SIZE]; *offsets_ = (sizeof offsets_) / sizeof *offsets_; - rec_print_new(file, rec, rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &heap)); + rec_print_new(file, rec, + rec_get_offsets(rec, index, offsets_, + ULINT_UNDEFINED, &heap)); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c index 414f4091403..352519f5d56 100644 --- a/storage/innobase/row/row0ins.c +++ b/storage/innobase/row/row0ins.c @@ -120,7 +120,7 @@ ins_node_create_entry_list( while (index != NULL) { entry = row_build_index_entry(node->row, index, - node->entry_sys_heap); + node->entry_sys_heap); UT_LIST_ADD_LAST(tuple_list, node->entry_list, entry); index = dict_table_get_next_index(index); @@ -242,7 +242,7 @@ row_ins_sec_index_entry_by_modify( ut_ad((cursor->index->type & DICT_CLUSTERED) == 0); ut_ad(rec_get_deleted_flag(rec, - dict_table_is_comp(cursor->index->table))); + dict_table_is_comp(cursor->index->table))); /* We know that in the alphabetical ordering, entry and rec are identified. But in their binary form there may be differences if @@ -251,8 +251,8 @@ row_ins_sec_index_entry_by_modify( heap = mem_heap_create(1024); - update = row_upd_build_sec_rec_difference_binary(cursor->index, - entry, rec, thr_get_trx(thr), heap); + update = row_upd_build_sec_rec_difference_binary + (cursor->index, entry, rec, thr_get_trx(thr), heap); if (mode == BTR_MODIFY_LEAF) { /* Try an optimistic updating of the record, keeping changes within the page */ @@ -272,7 +272,8 @@ row_ins_sec_index_entry_by_modify( } err = btr_cur_pessimistic_update(BTR_KEEP_SYS_FLAG, cursor, - &dummy_big_rec, update, 0, thr, mtr); + &dummy_big_rec, update, + 0, thr, mtr); } func_exit: mem_heap_free(heap); @@ -315,7 +316,7 @@ row_ins_clust_index_entry_by_modify( rec = btr_cur_get_rec(cursor); ut_ad(rec_get_deleted_flag(rec, - dict_table_is_comp(cursor->index->table))); + dict_table_is_comp(cursor->index->table))); heap = mem_heap_create(1024); @@ -324,13 +325,14 @@ row_ins_clust_index_entry_by_modify( roll_ptr */ update = row_upd_build_difference_binary(cursor->index, entry, ext_vec, - n_ext_vec, rec, thr_get_trx(thr), heap); + n_ext_vec, rec, + thr_get_trx(thr), heap); if (mode == BTR_MODIFY_LEAF) { /* Try optimistic updating of the record, keeping changes within the page */ err = btr_cur_optimistic_update(0, cursor, update, 0, thr, - mtr); + mtr); if (err == DB_OVERFLOW || err == DB_UNDERFLOW) { err = DB_FAIL; } @@ -343,7 +345,7 @@ row_ins_clust_index_entry_by_modify( goto func_exit; } err = btr_cur_pessimistic_update(0, cursor, big_rec, update, - 0, thr, mtr); + 0, thr, mtr); } func_exit: mem_heap_free(heap); @@ -468,10 +470,9 @@ row_ins_cascade_calc_update_vec( for (i = 0; i < foreign->n_fields; i++) { - parent_field_no = dict_table_get_nth_col_pos( - parent_table, - dict_index_get_nth_col_no( - parent_index, i)); + parent_field_no = dict_table_get_nth_col_pos + (parent_table, + dict_index_get_nth_col_no(parent_index, i)); for (j = 0; j < parent_update->n_fields; j++) { parent_ufield = parent_update->fields + j; @@ -486,9 +487,10 @@ row_ins_cascade_calc_update_vec( ufield = update->fields + n_fields_updated; - ufield->field_no = - dict_table_get_nth_col_pos(table, - dict_index_get_nth_col_no(index, i)); + ufield->field_no + = dict_table_get_nth_col_pos + (table, + dict_index_get_nth_col_no(index, i)); ufield->exp = NULL; ufield->new_val = parent_ufield->new_val; @@ -499,7 +501,7 @@ row_ins_cascade_calc_update_vec( updated as NULL */ if (ufield->new_val.len == UNIV_SQL_NULL - && (type->prtype & DATA_NOT_NULL)) { + && (type->prtype & DATA_NOT_NULL)) { return(ULINT_UNDEFINED); } @@ -508,11 +510,10 @@ row_ins_cascade_calc_update_vec( column, do not allow the update */ if (ufield->new_val.len != UNIV_SQL_NULL - && dtype_get_at_most_n_mbchars( - type, dtype_get_len(type), - ufield->new_val.len, - ufield->new_val.data) - < ufield->new_val.len) { + && dtype_get_at_most_n_mbchars + (type, dtype_get_len(type), + ufield->new_val.len, ufield->new_val.data) + < ufield->new_val.len) { return(ULINT_UNDEFINED); } @@ -525,34 +526,33 @@ row_ins_cascade_calc_update_vec( min_size = dtype_get_min_size(type); if (min_size - && ufield->new_val.len != UNIV_SQL_NULL - && ufield->new_val.len < min_size) { + && ufield->new_val.len != UNIV_SQL_NULL + && ufield->new_val.len < min_size) { char* pad_start; const char* pad_end; - ufield->new_val.data = - mem_heap_alloc(heap, - min_size); - pad_start = - ((char*) ufield->new_val.data) + ufield->new_val.data = mem_heap_alloc + (heap, min_size); + pad_start = ((char*) ufield + ->new_val.data) + ufield->new_val.len; - pad_end = - ((char*) ufield->new_val.data) + pad_end = ((char*) ufield + ->new_val.data) + min_size; ufield->new_val.len = min_size; ut_memcpy(ufield->new_val.data, - parent_ufield->new_val.data, - parent_ufield->new_val.len); + parent_ufield->new_val.data, + parent_ufield->new_val.len); - switch (UNIV_EXPECT( - dtype_get_mbminlen(type), 1)) { + switch (UNIV_EXPECT(dtype_get_mbminlen + (type), 1)) { default: ut_error; case 1: - if (UNIV_UNLIKELY( - dtype_get_charset_coll( - dtype_get_prtype(type)) - == DATA_MYSQL_BINARY_CHARSET_COLL)) { + if (UNIV_UNLIKELY + (dtype_get_charset_coll + (dtype_get_prtype(type)) + == DATA_MYSQL_BINARY_CHARSET_COLL)) { /* Do not pad BINARY columns. */ return(ULINT_UNDEFINED); @@ -560,12 +560,12 @@ row_ins_cascade_calc_update_vec( /* space=0x20 */ memset(pad_start, 0x20, - pad_end - pad_start); + pad_end - pad_start); break; case 2: /* space=0x0020 */ ut_a(!(ufield->new_val.len - % 2)); + % 2)); ut_a(!(min_size % 2)); do { *pad_start++ = 0x00; @@ -602,10 +602,9 @@ row_ins_set_detailed( if (os_file_set_eof(srv_misc_tmpfile)) { ut_print_name(srv_misc_tmpfile, trx, TRUE, - foreign->foreign_table_name); - dict_print_info_on_foreign_key_in_create_format( - srv_misc_tmpfile, - trx, foreign, FALSE); + foreign->foreign_table_name); + dict_print_info_on_foreign_key_in_create_format + (srv_misc_tmpfile, trx, foreign, FALSE); trx_set_detailed_error_from_file(trx, srv_misc_tmpfile); } else { trx_set_detailed_error(trx, "temp file operation failed"); @@ -646,7 +645,7 @@ row_ins_foreign_report_err( ut_print_name(ef, trx, TRUE, foreign->foreign_table_name); fputs(":\n", ef); dict_print_info_on_foreign_key_in_create_format(ef, trx, foreign, - TRUE); + TRUE); putc('\n', ef); fputs(errstr, ef); fputs(" in parent table, in index ", ef); @@ -671,7 +670,7 @@ row_ins_foreign_report_err( } /************************************************************************* -Reports a foreign key error to dict_foreign_err_buf when we are trying +Reports a foreign key error to dict_foreign_err_file when we are trying to add an index entry to a child table. Note that the adding may be the result of an update, too. */ static @@ -699,7 +698,7 @@ row_ins_foreign_report_add_err( ut_print_name(ef, trx, TRUE, foreign->foreign_table_name); fputs(":\n", ef); dict_print_info_on_foreign_key_in_create_format(ef, trx, foreign, - TRUE); + TRUE); fputs("\nTrying to add in child table, in index ", ef); ut_print_name(ef, trx, FALSE, foreign->foreign_index->name); if (entry) { @@ -805,26 +804,26 @@ row_ins_foreign_check_on_constraint( node = thr->run_node; - if (node->is_delete && 0 == (foreign->type & - (DICT_FOREIGN_ON_DELETE_CASCADE - | DICT_FOREIGN_ON_DELETE_SET_NULL))) { + if (node->is_delete && 0 == (foreign->type + & (DICT_FOREIGN_ON_DELETE_CASCADE + | DICT_FOREIGN_ON_DELETE_SET_NULL))) { row_ins_foreign_report_err("Trying to delete", - thr, foreign, - btr_pcur_get_rec(pcur), entry); + thr, foreign, + btr_pcur_get_rec(pcur), entry); return(DB_ROW_IS_REFERENCED); } - if (!node->is_delete && 0 == (foreign->type & - (DICT_FOREIGN_ON_UPDATE_CASCADE - | DICT_FOREIGN_ON_UPDATE_SET_NULL))) { + if (!node->is_delete && 0 == (foreign->type + & (DICT_FOREIGN_ON_UPDATE_CASCADE + | DICT_FOREIGN_ON_UPDATE_SET_NULL))) { /* This is an UPDATE */ row_ins_foreign_report_err("Trying to update", - thr, foreign, - btr_pcur_get_rec(pcur), entry); + thr, foreign, + btr_pcur_get_rec(pcur), entry); return(DB_ROW_IS_REFERENCED); } @@ -835,8 +834,8 @@ row_ins_foreign_check_on_constraint( operation. */ node->cascade_heap = mem_heap_create(128); - node->cascade_node = row_create_update_node_for_mysql( - table, node->cascade_heap); + node->cascade_node = row_create_update_node_for_mysql + (table, node->cascade_heap); que_node_set_parent(node->cascade_node, node); } @@ -852,7 +851,7 @@ row_ins_foreign_check_on_constraint( cascade->foreign = foreign; if (node->is_delete - && (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE)) { + && (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE)) { cascade->is_delete = TRUE; } else { cascade->is_delete = FALSE; @@ -861,7 +860,7 @@ row_ins_foreign_check_on_constraint( /* We have to make the update vector longer */ cascade->update = upd_create(foreign->n_fields, - node->cascade_heap); + node->cascade_heap); cascade->update_n_fields = foreign->n_fields; } } @@ -875,16 +874,18 @@ row_ins_foreign_check_on_constraint( of the parent table in an inconsistent state! */ if (!cascade->is_delete - && row_ins_cascade_ancestor_updates_table(cascade, table)) { + && row_ins_cascade_ancestor_updates_table(cascade, table)) { /* We do not know if this would break foreign key constraints, but play safe and return an error */ err = DB_ROW_IS_REFERENCED; - row_ins_foreign_report_err( -"Trying an update, possibly causing a cyclic cascaded update\n" -"in the child table,", thr, foreign, btr_pcur_get_rec(pcur), entry); + row_ins_foreign_report_err + ("Trying an update, possibly causing a cyclic" + " cascaded update\n" + "in the child table,", thr, foreign, + btr_pcur_get_rec(pcur), entry); goto nonstandard_exit_func; } @@ -892,9 +893,9 @@ row_ins_foreign_check_on_constraint( if (row_ins_cascade_n_ancestors(cascade) >= 15) { err = DB_ROW_IS_REFERENCED; - row_ins_foreign_report_err( -"Trying a too deep cascaded delete or update\n", - thr, foreign, btr_pcur_get_rec(pcur), entry); + row_ins_foreign_report_err + ("Trying a too deep cascaded delete or update\n", + thr, foreign, btr_pcur_get_rec(pcur), entry); goto nonstandard_exit_func; } @@ -920,30 +921,30 @@ row_ins_foreign_check_on_constraint( tmp_heap = mem_heap_create(256); ref = row_build_row_ref(ROW_COPY_POINTERS, index, rec, - tmp_heap); + tmp_heap); btr_pcur_open_with_no_init(clust_index, ref, - PAGE_CUR_LE, BTR_SEARCH_LEAF, - cascade->pcur, 0, mtr); + PAGE_CUR_LE, BTR_SEARCH_LEAF, + cascade->pcur, 0, mtr); clust_rec = btr_pcur_get_rec(cascade->pcur); if (!page_rec_is_user_rec(clust_rec) - || btr_pcur_get_low_match(cascade->pcur) - < dict_index_get_n_unique(clust_index)) { + || btr_pcur_get_low_match(cascade->pcur) + < dict_index_get_n_unique(clust_index)) { - fputs( - "InnoDB: error in cascade of a foreign key op\n" - "InnoDB: ", stderr); + fputs("InnoDB: error in cascade of a foreign key op\n" + "InnoDB: ", stderr); dict_index_name_print(stderr, trx, index); fputs("\n" - "InnoDB: record ", stderr); + "InnoDB: record ", stderr); rec_print(stderr, rec, index); fputs("\n" - "InnoDB: clustered record ", stderr); + "InnoDB: clustered record ", stderr); rec_print(stderr, clust_rec, clust_index); fputs("\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); + "InnoDB: Submit a detailed bug report to" + " http://bugs.mysql.com\n", stderr); err = DB_SUCCESS; @@ -960,8 +961,9 @@ row_ins_foreign_check_on_constraint( we already have a normal shared lock on the appropriate gap if the search criterion was not unique */ - err = lock_clust_rec_read_check_and_lock_alt(0, clust_rec, - clust_index, LOCK_X, LOCK_REC_NOT_GAP, thr); + err = lock_clust_rec_read_check_and_lock_alt + (0, clust_rec, clust_index, + LOCK_X, LOCK_REC_NOT_GAP, thr); } if (err != DB_SUCCESS) { @@ -979,9 +981,9 @@ row_ins_foreign_check_on_constraint( } if ((node->is_delete - && (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)) - || (!node->is_delete - && (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL))) { + && (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)) + || (!node->is_delete + && (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL))) { /* Build the appropriate update vector which sets foreign->n_fields first fields in rec to SQL NULL */ @@ -993,8 +995,8 @@ row_ins_foreign_check_on_constraint( for (i = 0; i < foreign->n_fields; i++) { (update->fields + i)->field_no - = dict_table_get_nth_col_pos(table, - dict_index_get_nth_col_no(index, i)); + = dict_table_get_nth_col_pos + (table, dict_index_get_nth_col_no(index, i)); (update->fields + i)->exp = NULL; (update->fields + i)->new_val.len = UNIV_SQL_NULL; (update->fields + i)->new_val.data = NULL; @@ -1003,7 +1005,7 @@ row_ins_foreign_check_on_constraint( } if (!node->is_delete - && (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE)) { + && (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE)) { /* Build the appropriate update vector which sets changing foreign->n_fields first fields in rec to new values */ @@ -1011,15 +1013,18 @@ row_ins_foreign_check_on_constraint( upd_vec_heap = mem_heap_create(256); n_to_update = row_ins_cascade_calc_update_vec(node, foreign, - upd_vec_heap); + upd_vec_heap); if (n_to_update == ULINT_UNDEFINED) { err = DB_ROW_IS_REFERENCED; - row_ins_foreign_report_err( -"Trying a cascaded update where the updated value in the child\n" -"table would not fit in the length of the column, or the value would\n" -"be NULL and the column is declared as not NULL in the child table,", - thr, foreign, btr_pcur_get_rec(pcur), entry); + row_ins_foreign_report_err + ("Trying a cascaded update where the" + " updated value in the child\n" + "table would not fit in the length" + " of the column, or the value would\n" + "be NULL and the column is" + " declared as not NULL in the child table,", + thr, foreign, btr_pcur_get_rec(pcur), entry); goto nonstandard_exit_func; } @@ -1054,12 +1059,13 @@ row_ins_foreign_check_on_constraint( cascade->state = UPD_NODE_UPDATE_CLUSTERED; err = row_update_cascade_for_mysql(thr, cascade, - foreign->foreign_table); + foreign->foreign_table); if (foreign->foreign_table->n_foreign_key_checks_running == 0) { fprintf(stderr, -"InnoDB: error: table %s has the counter 0 though there is\n" -"InnoDB: a FOREIGN KEY check running on it.\n", + "InnoDB: error: table %s has the counter 0" + " though there is\n" + "InnoDB: a FOREIGN KEY check running on it.\n", foreign->foreign_table->name); } @@ -1127,11 +1133,11 @@ row_ins_set_shared_rec_lock( ut_ad(rec_offs_validate(rec, index, offsets)); if (index->type & DICT_CLUSTERED) { - err = lock_clust_rec_read_check_and_lock(0, - rec, index, offsets, LOCK_S, type, thr); + err = lock_clust_rec_read_check_and_lock + (0, rec, index, offsets, LOCK_S, type, thr); } else { - err = lock_sec_rec_read_check_and_lock(0, - rec, index, offsets, LOCK_S, type, thr); + err = lock_sec_rec_read_check_and_lock + (0, rec, index, offsets, LOCK_S, type, thr); } return(err); @@ -1158,11 +1164,11 @@ row_ins_set_exclusive_rec_lock( ut_ad(rec_offs_validate(rec, index, offsets)); if (index->type & DICT_CLUSTERED) { - err = lock_clust_rec_read_check_and_lock(0, - rec, index, offsets, LOCK_X, type, thr); + err = lock_clust_rec_read_check_and_lock + (0, rec, index, offsets, LOCK_X, type, thr); } else { - err = lock_sec_rec_read_check_and_lock(0, - rec, index, offsets, LOCK_X, type, thr); + err = lock_sec_rec_read_check_and_lock + (0, rec, index, offsets, LOCK_X, type, thr); } return(err); @@ -1226,8 +1232,8 @@ run_again: for example */ for (i = 0; i < foreign->n_fields; i++) { - if (UNIV_SQL_NULL == dfield_get_len( - dtuple_get_nth_field(entry, i))) { + if (UNIV_SQL_NULL == dfield_get_len + (dtuple_get_nth_field(entry, i))) { goto exit_func; } @@ -1278,19 +1284,20 @@ run_again: trx_print(ef, trx, 600); fputs("Foreign key constraint fails for table ", ef); ut_print_name(ef, trx, TRUE, - foreign->foreign_table_name); + foreign->foreign_table_name); fputs(":\n", ef); - dict_print_info_on_foreign_key_in_create_format(ef, - trx, foreign, TRUE); + dict_print_info_on_foreign_key_in_create_format + (ef, trx, foreign, TRUE); fputs("\nTrying to add to index ", ef); ut_print_name(ef, trx, FALSE, - foreign->foreign_index->name); + foreign->foreign_index->name); fputs(" tuple:\n", ef); dtuple_print(ef, entry); fputs("\nBut the parent table ", ef); ut_print_name(ef, trx, TRUE, - foreign->referenced_table_name); - fputs("\nor its .ibd file does not currently exist!\n", ef); + foreign->referenced_table_name); + fputs("\nor its .ibd file does" + " not currently exist!\n", ef); mutex_exit(&dict_foreign_err_mutex); err = DB_NO_REFERENCED_ROW; @@ -1322,7 +1329,7 @@ run_again: dtuple_set_n_fields_cmp(entry, foreign->n_fields); btr_pcur_open(check_index, entry, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); + BTR_SEARCH_LEAF, &pcur, &mtr); /* Scan index records and check if there is a matching record */ @@ -1337,12 +1344,13 @@ run_again: } offsets = rec_get_offsets(rec, check_index, - offsets, ULINT_UNDEFINED, &heap); + offsets, ULINT_UNDEFINED, &heap); if (rec == page_get_supremum_rec(page)) { - err = row_ins_set_shared_rec_lock(LOCK_ORDINARY, rec, - check_index, offsets, thr); + err = row_ins_set_shared_rec_lock + (LOCK_ORDINARY, rec, + check_index, offsets, thr); if (err != DB_SUCCESS) { break; @@ -1355,10 +1363,10 @@ run_again: if (cmp == 0) { if (rec_get_deleted_flag(rec, - rec_offs_comp(offsets))) { - err = row_ins_set_shared_rec_lock( - LOCK_ORDINARY, rec, - check_index, offsets, thr); + rec_offs_comp(offsets))) { + err = row_ins_set_shared_rec_lock + (LOCK_ORDINARY, rec, + check_index, offsets, thr); if (err != DB_SUCCESS) { break; @@ -1368,9 +1376,9 @@ run_again: a record because we can allow inserts into gaps */ - err = row_ins_set_shared_rec_lock( - LOCK_REC_NOT_GAP, rec, - check_index, offsets, thr); + err = row_ins_set_shared_rec_lock + (LOCK_REC_NOT_GAP, rec, + check_index, offsets, thr); if (err != DB_SUCCESS) { @@ -1386,10 +1394,9 @@ run_again: condition: check them in a separate function */ - err = - row_ins_foreign_check_on_constraint( - thr, foreign, &pcur, entry, - &mtr); + err = row_ins_foreign_check_on_constraint + (thr, foreign, &pcur, + entry, &mtr); if (err != DB_SUCCESS) { /* Since reporting a plain "duplicate key" error @@ -1410,9 +1417,9 @@ run_again: break; } } else { - row_ins_foreign_report_err( - "Trying to delete or update", - thr, foreign, rec, entry); + row_ins_foreign_report_err + ("Trying to delete or update", + thr, foreign, rec, entry); err = DB_ROW_IS_REFERENCED; break; @@ -1421,8 +1428,8 @@ run_again: } if (cmp < 0) { - err = row_ins_set_shared_rec_lock(LOCK_GAP, - rec, check_index, offsets, thr); + err = row_ins_set_shared_rec_lock + (LOCK_GAP, rec, check_index, offsets, thr); if (err != DB_SUCCESS) { break; @@ -1430,8 +1437,8 @@ run_again: if (check_ref) { err = DB_NO_REFERENCED_ROW; - row_ins_foreign_report_add_err( - trx, foreign, rec, entry); + row_ins_foreign_report_add_err + (trx, foreign, rec, entry); } else { err = DB_SUCCESS; } @@ -1446,8 +1453,8 @@ next_rec: if (!moved) { if (check_ref) { rec = btr_pcur_get_rec(&pcur); - row_ins_foreign_report_add_err( - trx, foreign, rec, entry); + row_ins_foreign_report_add_err + (trx, foreign, rec, entry); err = DB_NO_REFERENCED_ROW; } else { err = DB_SUCCESS; @@ -1529,7 +1536,7 @@ row_ins_check_foreign_constraints( mutex_enter(&(dict_sys->mutex)); (foreign->referenced_table - ->n_foreign_key_checks_running)++; + ->n_foreign_key_checks_running)++; mutex_exit(&(dict_sys->mutex)); } @@ -1539,16 +1546,16 @@ row_ins_check_foreign_constraints( But the counter on the table protects the referenced table from being dropped while the check is running. */ - err = row_ins_check_foreign_constraint(TRUE, foreign, - table, entry, thr); + err = row_ins_check_foreign_constraint + (TRUE, foreign, table, entry, thr); if (foreign->referenced_table) { mutex_enter(&(dict_sys->mutex)); ut_a(foreign->referenced_table - ->n_foreign_key_checks_running > 0); + ->n_foreign_key_checks_running > 0); (foreign->referenced_table - ->n_foreign_key_checks_running)--; + ->n_foreign_key_checks_running)--; mutex_exit(&(dict_sys->mutex)); } @@ -1597,7 +1604,7 @@ row_ins_dupl_error_with_rec( matched_bytes = 0; cmp_dtuple_rec_with_match(entry, rec, offsets, - &matched_fields, &matched_bytes); + &matched_fields, &matched_bytes); if (matched_fields < n_unique) { @@ -1610,8 +1617,8 @@ row_ins_dupl_error_with_rec( if (!(index->type & DICT_CLUSTERED)) { for (i = 0; i < n_unique; i++) { - if (UNIV_SQL_NULL == dfield_get_len( - dtuple_get_nth_field(entry, i))) { + if (UNIV_SQL_NULL == dfield_get_len + (dtuple_get_nth_field(entry, i))) { return(FALSE); } @@ -1658,8 +1665,8 @@ row_ins_scan_sec_index_for_duplicate( since we define NULL != NULL in this case */ for (i = 0; i < n_unique; i++) { - if (UNIV_SQL_NULL == dfield_get_len( - dtuple_get_nth_field(entry, i))) { + if (UNIV_SQL_NULL == dfield_get_len + (dtuple_get_nth_field(entry, i))) { return(DB_SUCCESS); } @@ -1686,7 +1693,7 @@ row_ins_scan_sec_index_for_duplicate( } offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (innobase_query_is_update()) { @@ -1695,12 +1702,12 @@ row_ins_scan_sec_index_for_duplicate( duplicates ( REPLACE, LOAD DATAFILE REPLACE, INSERT ON DUPLICATE KEY UPDATE). */ - err = row_ins_set_exclusive_rec_lock(LOCK_ORDINARY, - rec, index, offsets, thr); + err = row_ins_set_exclusive_rec_lock + (LOCK_ORDINARY, rec, index, offsets, thr); } else { - err = row_ins_set_shared_rec_lock(LOCK_ORDINARY, - rec, index, offsets, thr); + err = row_ins_set_shared_rec_lock + (LOCK_ORDINARY, rec, index, offsets, thr); } if (err != DB_SUCCESS) { @@ -1810,7 +1817,7 @@ row_ins_duplicate_error_in_clust( if (!page_rec_is_infimum(rec)) { offsets = rec_get_offsets(rec, cursor->index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); /* We set a lock on the possible duplicate: this is needed in logical logging of MySQL to make @@ -1824,22 +1831,22 @@ row_ins_duplicate_error_in_clust( duplicates ( REPLACE, LOAD DATAFILE REPLACE, INSERT ON DUPLICATE KEY UPDATE). */ - err = row_ins_set_exclusive_rec_lock( - LOCK_REC_NOT_GAP,rec,cursor->index, - offsets, thr); + err = row_ins_set_exclusive_rec_lock + (LOCK_REC_NOT_GAP, rec, + cursor->index, offsets, thr); } else { - err = row_ins_set_shared_rec_lock( - LOCK_REC_NOT_GAP,rec, cursor->index, - offsets, thr); + err = row_ins_set_shared_rec_lock + (LOCK_REC_NOT_GAP, rec, + cursor->index, offsets, thr); } if (err != DB_SUCCESS) { goto func_exit; } - if (row_ins_dupl_error_with_rec(rec, entry, - cursor->index, offsets)) { + if (row_ins_dupl_error_with_rec + (rec, entry, cursor->index, offsets)) { trx->error_info = cursor->index; err = DB_DUPLICATE_KEY; goto func_exit; @@ -1853,7 +1860,7 @@ row_ins_duplicate_error_in_clust( if (!page_rec_is_supremum(rec)) { offsets = rec_get_offsets(rec, cursor->index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (innobase_query_is_update()) { @@ -1862,22 +1869,22 @@ row_ins_duplicate_error_in_clust( duplicates ( REPLACE, LOAD DATAFILE REPLACE, INSERT ON DUPLICATE KEY UPDATE). */ - err = row_ins_set_exclusive_rec_lock( - LOCK_REC_NOT_GAP, rec, - cursor->index, offsets, thr); + err = row_ins_set_exclusive_rec_lock + (LOCK_REC_NOT_GAP, rec, + cursor->index, offsets, thr); } else { - err = row_ins_set_shared_rec_lock( - LOCK_REC_NOT_GAP, rec, - cursor->index, offsets, thr); + err = row_ins_set_shared_rec_lock + (LOCK_REC_NOT_GAP, rec, + cursor->index, offsets, thr); } if (err != DB_SUCCESS) { goto func_exit; } - if (row_ins_dupl_error_with_rec(rec, entry, - cursor->index, offsets)) { + if (row_ins_dupl_error_with_rec + (rec, entry, cursor->index, offsets)) { trx->error_info = cursor->index; err = DB_DUPLICATE_KEY; goto func_exit; @@ -1885,7 +1892,7 @@ row_ins_duplicate_error_in_clust( } ut_a(!(cursor->index->type & DICT_CLUSTERED)); - /* This should never happen */ + /* This should never happen */ } err = DB_SUCCESS; @@ -1999,8 +2006,8 @@ row_ins_index_entry_low( } btr_cur_search_to_nth_level(index, 0, entry, PAGE_CUR_LE, - mode | BTR_INSERT | ignore_sec_unique, - &cursor, 0, &mtr); + mode | BTR_INSERT | ignore_sec_unique, + &cursor, 0, &mtr); if (cursor.flag == BTR_CUR_INSERT_TO_IBUF) { /* The insertion was made to the insert buffer already during @@ -2014,12 +2021,12 @@ row_ins_index_entry_low( #ifdef UNIV_DEBUG { page_t* page = btr_cur_get_page(&cursor); - rec_t* first_rec = page_rec_get_next( - page_get_infimum_rec(page)); + rec_t* first_rec = page_rec_get_next + (page_get_infimum_rec(page)); if (UNIV_LIKELY(first_rec != page_get_supremum_rec(page))) { ut_a(rec_get_n_fields(first_rec, index) - == dtuple_get_n_fields(entry)); + == dtuple_get_n_fields(entry)); } } #endif @@ -2027,22 +2034,22 @@ row_ins_index_entry_low( n_unique = dict_index_get_n_unique(index); if (index->type & DICT_UNIQUE && (cursor.up_match >= n_unique - || cursor.low_match >= n_unique)) { + || cursor.low_match >= n_unique)) { if (index->type & DICT_CLUSTERED) { /* Note that the following may return also DB_LOCK_WAIT */ - err = row_ins_duplicate_error_in_clust(&cursor, - entry, thr, &mtr); + err = row_ins_duplicate_error_in_clust + (&cursor, entry, thr, &mtr); if (err != DB_SUCCESS) { goto function_exit; } } else { mtr_commit(&mtr); - err = row_ins_scan_sec_index_for_duplicate(index, - entry, thr); + err = row_ins_scan_sec_index_for_duplicate + (index, entry, thr); mtr_start(&mtr); if (err != DB_SUCCESS) { @@ -2057,8 +2064,9 @@ row_ins_index_entry_low( continue the insertion. */ btr_cur_search_to_nth_level(index, 0, entry, - PAGE_CUR_LE, mode | BTR_INSERT, - &cursor, 0, &mtr); + PAGE_CUR_LE, + mode | BTR_INSERT, + &cursor, 0, &mtr); } } @@ -2076,21 +2084,19 @@ row_ins_index_entry_low( } if (index->type & DICT_CLUSTERED) { - err = row_ins_clust_index_entry_by_modify(mode, - &cursor, &big_rec, - entry, - ext_vec, n_ext_vec, - thr, &mtr); + err = row_ins_clust_index_entry_by_modify + (mode, &cursor, &big_rec, entry, + ext_vec, n_ext_vec, thr, &mtr); } else { - err = row_ins_sec_index_entry_by_modify(mode, &cursor, - entry, - thr, &mtr); + err = row_ins_sec_index_entry_by_modify + (mode, &cursor, entry, thr, &mtr); } } else { if (mode == BTR_MODIFY_LEAF) { - err = btr_cur_optimistic_insert(0, &cursor, entry, - &insert_rec, &big_rec, thr, &mtr); + err = btr_cur_optimistic_insert + (0, &cursor, entry, + &insert_rec, &big_rec, thr, &mtr); } else { ut_a(mode == BTR_MODIFY_TREE); if (buf_LRU_buf_pool_running_out()) { @@ -2099,14 +2105,16 @@ row_ins_index_entry_low( goto function_exit; } - err = btr_cur_pessimistic_insert(0, &cursor, entry, - &insert_rec, &big_rec, thr, &mtr); + err = btr_cur_pessimistic_insert + (0, &cursor, entry, + &insert_rec, &big_rec, thr, &mtr); } if (err == DB_SUCCESS) { if (ext_vec) { rec_set_field_extern_bits(insert_rec, index, - ext_vec, n_ext_vec, &mtr); + ext_vec, n_ext_vec, + &mtr); } } } @@ -2119,13 +2127,13 @@ function_exit: mtr_start(&mtr); btr_cur_search_to_nth_level(index, 0, entry, PAGE_CUR_LE, - BTR_MODIFY_TREE, &cursor, 0, &mtr); + BTR_MODIFY_TREE, &cursor, 0, &mtr); rec = btr_cur_get_rec(&cursor); offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); err = btr_store_big_rec_extern_fields(index, rec, - offsets, big_rec, &mtr); + offsets, big_rec, &mtr); if (modify) { dtuple_big_rec_free(big_rec); @@ -2164,7 +2172,7 @@ row_ins_index_entry( if (UT_LIST_GET_FIRST(index->table->foreign_list)) { err = row_ins_check_foreign_constraints(index->table, index, - entry, thr); + entry, thr); if (err != DB_SUCCESS) { return(err); @@ -2174,7 +2182,7 @@ row_ins_index_entry( /* Try first optimistic descent to the B-tree */ err = row_ins_index_entry_low(BTR_MODIFY_LEAF, index, entry, - ext_vec, n_ext_vec, thr); + ext_vec, n_ext_vec, thr); if (err != DB_FAIL) { return(err); @@ -2183,7 +2191,7 @@ row_ins_index_entry( /* Try then pessimistic descent to the B-tree */ err = row_ins_index_entry_low(BTR_MODIFY_TREE, index, entry, - ext_vec, n_ext_vec, thr); + ext_vec, n_ext_vec, thr); return(err); } @@ -2217,14 +2225,14 @@ row_ins_index_entry_set_vals( /* Check column prefix indexes */ if (ind_field->prefix_len > 0 - && dfield_get_len(row_field) != UNIV_SQL_NULL) { + && dfield_get_len(row_field) != UNIV_SQL_NULL) { - cur_type = dict_col_get_type( - dict_field_get_col(ind_field)); + cur_type = dict_col_get_type + (dict_field_get_col(ind_field)); - field->len = dtype_get_at_most_n_mbchars(cur_type, - ind_field->prefix_len, - dfield_get_len(row_field), row_field->data); + field->len = dtype_get_at_most_n_mbchars + (cur_type, ind_field->prefix_len, + dfield_get_len(row_field), row_field->data); } else { field->len = row_field->len; } @@ -2466,7 +2474,7 @@ row_ins_step( } node->trx_id = trx->id; - same_trx: +same_trx: node->state = INS_NODE_ALLOC_ROW_ID; if (node->ins_type == INS_SEARCHED) { @@ -2482,7 +2490,7 @@ row_ins_step( } if ((node->ins_type == INS_SEARCHED) - && (sel_node->state != SEL_NODE_FETCH)) { + && (sel_node->state != SEL_NODE_FETCH)) { ut_ad(sel_node->state == SEL_NODE_NO_MORE_ROWS); diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 0378a3f8c87..af3f80fa53b 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -70,8 +70,8 @@ row_mysql_is_system_table( } return(0 == strcmp(name + 6, "host") - || 0 == strcmp(name + 6, "user") - || 0 == strcmp(name + 6, "db")); + || 0 == strcmp(name + 6, "user") + || 0 == strcmp(name + 6, "db")); } /*********************************************************************** @@ -280,8 +280,8 @@ row_mysql_store_col_in_innobase_format( buf += col_len; } else if ((type == DATA_VARCHAR - || type == DATA_VARMYSQL - || type == DATA_BINARY)) { + || type == DATA_VARMYSQL + || type == DATA_BINARY)) { if (dtype_get_mysql_type(dtype) == DATA_MYSQL_TRUE_VARCHAR) { /* The length of the actual data is stored to 1 or 2 @@ -299,7 +299,7 @@ row_mysql_store_col_in_innobase_format( } ptr = row_mysql_read_true_varchar(&col_len, mysql_data, - lenlen); + lenlen); } else { /* Remove trailing spaces from old style VARCHAR columns. */ @@ -315,21 +315,21 @@ row_mysql_store_col_in_innobase_format( col_len &= ~1; while (col_len >= 2 && ptr[col_len - 2] == 0x00 - && ptr[col_len - 1] == 0x20) { + && ptr[col_len - 1] == 0x20) { col_len -= 2; } } else { ut_a(mbminlen == 1); /* space=0x20 */ while (col_len > 0 - && ptr[col_len - 1] == 0x20) { + && ptr[col_len - 1] == 0x20) { col_len--; } } } } else if (comp && type == DATA_MYSQL - && dtype_get_mbminlen(dtype) == 1 - && dtype_get_mbmaxlen(dtype) > 1) { + && dtype_get_mbminlen(dtype) == 1 + && dtype_get_mbmaxlen(dtype) > 1) { /* In some cases we strip trailing spaces from UTF-8 and other multibyte charsets, from FIXED-length CHAR columns, to save space. UTF-8 would otherwise normally use 3 * the string length @@ -406,8 +406,8 @@ row_mysql_convert_row_to_innobase( if (templ->mysql_null_bit_mask != 0) { /* Column may be SQL NULL */ - if (mysql_rec[templ->mysql_null_byte_offset] & - (byte) (templ->mysql_null_bit_mask)) { + if (mysql_rec[templ->mysql_null_byte_offset] + & (byte) (templ->mysql_null_bit_mask)) { /* It is SQL NULL */ @@ -417,13 +417,13 @@ row_mysql_convert_row_to_innobase( } } - row_mysql_store_col_in_innobase_format(dfield, - prebuilt->ins_upd_rec_buff - + templ->mysql_col_offset, - TRUE, /* MySQL row format data */ - mysql_rec + templ->mysql_col_offset, - templ->mysql_col_len, - dict_table_is_comp(prebuilt->table)); + row_mysql_store_col_in_innobase_format + (dfield, + prebuilt->ins_upd_rec_buff + templ->mysql_col_offset, + TRUE, /* MySQL row format data */ + mysql_rec + templ->mysql_col_offset, + templ->mysql_col_len, + dict_table_is_comp(prebuilt->table)); next_column: ; } @@ -456,7 +456,7 @@ handle_new_error: trx->error_state = DB_SUCCESS; if ((err == DB_DUPLICATE_KEY) - || (err == DB_FOREIGN_DUPLICATE_KEY)) { + || (err == DB_FOREIGN_DUPLICATE_KEY)) { if (savept) { /* Roll back the latest, possibly incomplete insertion or update */ @@ -514,23 +514,29 @@ handle_new_error: } else if (err == DB_MUST_GET_MORE_FILE_SPACE) { - fputs( - "InnoDB: The database cannot continue operation because of\n" - "InnoDB: lack of space. You must add a new data file to\n" - "InnoDB: my.cnf and restart the database.\n", stderr); + fputs("InnoDB: The database cannot continue" + " operation because of\n" + "InnoDB: lack of space. You must add" + " a new data file to\n" + "InnoDB: my.cnf and restart the database.\n", stderr); exit(1); } else if (err == DB_CORRUPTION) { - fputs( - "InnoDB: We detected index corruption in an InnoDB type table.\n" - "InnoDB: You have to dump + drop + reimport the table or, in\n" - "InnoDB: a case of widespread corruption, dump all InnoDB\n" - "InnoDB: tables and recreate the whole InnoDB tablespace.\n" - "InnoDB: If the mysqld server crashes after the startup or when\n" - "InnoDB: you dump the tables, look at\n" - "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html" - " for help.\n", stderr); + fputs("InnoDB: We detected index corruption" + " in an InnoDB type table.\n" + "InnoDB: You have to dump + drop + reimport" + " the table or, in\n" + "InnoDB: a case of widespread corruption," + " dump all InnoDB\n" + "InnoDB: tables and recreate the" + " whole InnoDB tablespace.\n" + "InnoDB: If the mysqld server crashes" + " after the startup or when\n" + "InnoDB: you dump the tables, look at\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "forcing-recovery.html" + " for help.\n", stderr); } else { fprintf(stderr, "InnoDB: unknown error code %lu\n", @@ -613,8 +619,8 @@ row_create_prebuilt( prebuilt->sel_graph = NULL; - prebuilt->search_tuple = dtuple_create(heap, - 2 * dict_table_get_n_cols(table)); + prebuilt->search_tuple = dtuple_create + (heap, 2 * dict_table_get_n_cols(table)); clust_index = dict_table_get_first_index(table); @@ -653,12 +659,13 @@ row_prebuilt_free( ulint i; if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED - || prebuilt->magic_n2 != ROW_PREBUILT_ALLOCATED) { + || prebuilt->magic_n2 != ROW_PREBUILT_ALLOCATED) { fprintf(stderr, -"InnoDB: Error: trying to free a corrupt\n" -"InnoDB: table handle. Magic n %lu, magic n2 %lu, table name", - (ulong) prebuilt->magic_n, - (ulong) prebuilt->magic_n2); + "InnoDB: Error: trying to free a corrupt\n" + "InnoDB: table handle. Magic n %lu," + " magic n2 %lu, table name", + (ulong) prebuilt->magic_n, + (ulong) prebuilt->magic_n2); ut_print_name(stderr, NULL, TRUE, prebuilt->table->name); putc('\n', stderr); @@ -700,17 +707,16 @@ row_prebuilt_free( for (i = 0; i < MYSQL_FETCH_CACHE_SIZE; i++) { if (prebuilt->fetch_cache[i] != NULL) { - if ((ROW_PREBUILT_FETCH_MAGIC_N != - mach_read_from_4((prebuilt->fetch_cache[i]) - 4)) - || (ROW_PREBUILT_FETCH_MAGIC_N != - mach_read_from_4((prebuilt->fetch_cache[i]) - + prebuilt->mysql_row_len))) { - fputs( - "InnoDB: Error: trying to free a corrupt\n" - "InnoDB: fetch buffer.\n", stderr); + if ((ROW_PREBUILT_FETCH_MAGIC_N != mach_read_from_4 + ((prebuilt->fetch_cache[i]) - 4)) + || (ROW_PREBUILT_FETCH_MAGIC_N != mach_read_from_4 + ((prebuilt->fetch_cache[i]) + + prebuilt->mysql_row_len))) { + fputs("InnoDB: Error: trying to free" + " a corrupt fetch buffer.\n", stderr); - mem_analyze_corruption( - prebuilt->fetch_cache[i]); + mem_analyze_corruption + (prebuilt->fetch_cache[i]); ut_error; } @@ -738,9 +744,9 @@ row_update_prebuilt_trx( { if (trx->magic_n != TRX_MAGIC_N) { fprintf(stderr, - "InnoDB: Error: trying to use a corrupt\n" - "InnoDB: trx handle. Magic n %lu\n", - (ulong) trx->magic_n); + "InnoDB: Error: trying to use a corrupt\n" + "InnoDB: trx handle. Magic n %lu\n", + (ulong) trx->magic_n); mem_analyze_corruption(trx); @@ -749,9 +755,9 @@ row_update_prebuilt_trx( if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) { fprintf(stderr, - "InnoDB: Error: trying to use a corrupt\n" - "InnoDB: table handle. Magic n %lu, table name", - (ulong) prebuilt->magic_n); + "InnoDB: Error: trying to use a corrupt\n" + "InnoDB: table handle. Magic n %lu, table name", + (ulong) prebuilt->magic_n); ut_print_name(stderr, NULL, TRUE, prebuilt->table->name); putc('\n', stderr); @@ -805,13 +811,12 @@ row_get_prebuilt_insert_row( prebuilt->ins_node = node; if (prebuilt->ins_upd_rec_buff == NULL) { - prebuilt->ins_upd_rec_buff = mem_heap_alloc( - prebuilt->heap, - prebuilt->mysql_row_len); + prebuilt->ins_upd_rec_buff = mem_heap_alloc + (prebuilt->heap, prebuilt->mysql_row_len); } row = dtuple_create(prebuilt->heap, - dict_table_get_n_cols(table)); + dict_table_get_n_cols(table)); dict_table_copy_types(row, table); @@ -825,11 +830,10 @@ row_get_prebuilt_insert_row( ins_node_set_new_row(node, row); - prebuilt->ins_graph = - que_node_get_parent( - pars_complete_graph_for_exec(node, - prebuilt->trx, - prebuilt->heap)); + prebuilt->ins_graph = que_node_get_parent + (pars_complete_graph_for_exec(node, + prebuilt->trx, + prebuilt->heap)); prebuilt->ins_graph->state = QUE_FORK_ACTIVE; } @@ -858,7 +862,7 @@ row_update_statistics_if_needed( a counter table which is very small and updated very often. */ if (counter > 2000000000 - || ((ib_longlong)counter > 16 + table->stat_n_rows / 16)) { + || ((ib_longlong)counter > 16 + table->stat_n_rows / 16)) { dict_update_statistics(table); } @@ -1007,7 +1011,7 @@ run_again: err = lock_table(0, table, mode, thr); } else { err = lock_table(0, prebuilt->table, - prebuilt->select_lock_type, thr); + prebuilt->select_lock_type, thr); } trx->error_state = err; @@ -1057,24 +1061,28 @@ row_insert_for_mysql( if (prebuilt->table->ibd_file_missing) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error:\n" -"InnoDB: MySQL is trying to use a table handle but the .ibd file for\n" -"InnoDB: table %s does not exist.\n" -"InnoDB: Have you deleted the .ibd file from the database directory under\n" -"InnoDB: the MySQL datadir, or have you used DISCARD TABLESPACE?\n" -"InnoDB: Look from\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" -"InnoDB: how you can resolve the problem.\n", - prebuilt->table->name); + "InnoDB: MySQL is trying to use a table handle" + " but the .ibd file for\n" + "InnoDB: table %s does not exist.\n" + "InnoDB: Have you deleted the .ibd file" + " from the database directory under\n" + "InnoDB: the MySQL datadir, or have you" + " used DISCARD TABLESPACE?\n" + "InnoDB: Look from\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n" + "InnoDB: how you can resolve the problem.\n", + prebuilt->table->name); return(DB_ERROR); } if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) { fprintf(stderr, - "InnoDB: Error: trying to free a corrupt\n" - "InnoDB: table handle. Magic n %lu, table name", - (ulong) prebuilt->magic_n); + "InnoDB: Error: trying to free a corrupt\n" + "InnoDB: table handle. Magic n %lu, table name", + (ulong) prebuilt->magic_n); ut_print_name(stderr, prebuilt->trx, TRUE, - prebuilt->table->name); + prebuilt->table->name); putc('\n', stderr); mem_analyze_corruption(prebuilt); @@ -1083,13 +1091,13 @@ row_insert_for_mysql( } if (srv_created_new_raw || srv_force_recovery) { - fputs( - "InnoDB: A new raw disk partition was initialized or\n" - "InnoDB: innodb_force_recovery is on: we do not allow\n" - "InnoDB: database modifications by the user. Shut down\n" - "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" - "InnoDB: with raw, and innodb_force_... is removed.\n", - stderr); + fputs("InnoDB: A new raw disk partition was initialized or\n" + "InnoDB: innodb_force_recovery is on: we do not allow\n" + "InnoDB: database modifications by the user. Shut down\n" + "InnoDB: mysqld and edit my.cnf so that" + " newraw is replaced\n" + "InnoDB: with raw, and innodb_force_... is removed.\n", + stderr); return(DB_ERROR); } @@ -1131,10 +1139,10 @@ run_again: if (err != DB_SUCCESS) { que_thr_stop_for_mysql(thr); -/* TODO: what is this? */ thr->lock_state= QUE_THR_LOCK_ROW; + /* TODO: what is this? */ thr->lock_state= QUE_THR_LOCK_ROW; was_lock_wait = row_mysql_handle_errors(&err, trx, thr, - &savept); + &savept); thr->lock_state= QUE_THR_LOCK_NOLOCK; if (was_lock_wait) { @@ -1180,11 +1188,10 @@ row_prebuild_sel_graph( node = sel_node_create(prebuilt->heap); - prebuilt->sel_graph = - que_node_get_parent( - pars_complete_graph_for_exec(node, - prebuilt->trx, - prebuilt->heap)); + prebuilt->sel_graph = que_node_get_parent + (pars_complete_graph_for_exec(node, + prebuilt->trx, + prebuilt->heap)); prebuilt->sel_graph->state = QUE_FORK_ACTIVE; } @@ -1253,11 +1260,10 @@ row_get_prebuilt_update_vector( prebuilt->upd_node = node; - prebuilt->upd_graph = - que_node_get_parent( - pars_complete_graph_for_exec(node, - prebuilt->trx, - prebuilt->heap)); + prebuilt->upd_graph = que_node_get_parent + (pars_complete_graph_for_exec(node, + prebuilt->trx, + prebuilt->heap)); prebuilt->upd_graph->state = QUE_FORK_ACTIVE; } @@ -1281,7 +1287,7 @@ row_update_for_mysql( que_thr_t* thr; ibool was_lock_wait; dict_index_t* clust_index; -/* ulint ref_len; */ + /* ulint ref_len; */ upd_node_t* node; dict_table_t* table = prebuilt->table; trx_t* trx = prebuilt->trx; @@ -1293,24 +1299,28 @@ row_update_for_mysql( if (prebuilt->table->ibd_file_missing) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error:\n" -"InnoDB: MySQL is trying to use a table handle but the .ibd file for\n" -"InnoDB: table %s does not exist.\n" -"InnoDB: Have you deleted the .ibd file from the database directory under\n" -"InnoDB: the MySQL datadir, or have you used DISCARD TABLESPACE?\n" -"InnoDB: Look from\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" -"InnoDB: how you can resolve the problem.\n", - prebuilt->table->name); + "InnoDB: MySQL is trying to use a table handle" + " but the .ibd file for\n" + "InnoDB: table %s does not exist.\n" + "InnoDB: Have you deleted the .ibd file" + " from the database directory under\n" + "InnoDB: the MySQL datadir, or have you" + " used DISCARD TABLESPACE?\n" + "InnoDB: Look from\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n" + "InnoDB: how you can resolve the problem.\n", + prebuilt->table->name); return(DB_ERROR); } if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) { fprintf(stderr, - "InnoDB: Error: trying to free a corrupt\n" - "InnoDB: table handle. Magic n %lu, table name", - (ulong) prebuilt->magic_n); + "InnoDB: Error: trying to free a corrupt\n" + "InnoDB: table handle. Magic n %lu, table name", + (ulong) prebuilt->magic_n); ut_print_name(stderr, prebuilt->trx, TRUE, - prebuilt->table->name); + prebuilt->table->name); putc('\n', stderr); mem_analyze_corruption(prebuilt); @@ -1319,13 +1329,13 @@ row_update_for_mysql( } if (srv_created_new_raw || srv_force_recovery) { - fputs( - "InnoDB: A new raw disk partition was initialized or\n" - "InnoDB: innodb_force_recovery is on: we do not allow\n" - "InnoDB: database modifications by the user. Shut down\n" - "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" - "InnoDB: with raw, and innodb_force_... is removed.\n", - stderr); + fputs("InnoDB: A new raw disk partition was initialized or\n" + "InnoDB: innodb_force_recovery is on: we do not allow\n" + "InnoDB: database modifications by the user. Shut down\n" + "InnoDB: mysqld and edit my.cnf so that newraw" + " is replaced\n" + "InnoDB: with raw, and innodb_force_... is removed.\n", + stderr); return(DB_ERROR); } @@ -1344,7 +1354,7 @@ row_update_for_mysql( btr_pcur_copy_stored_position(node->pcur, prebuilt->pcur); } else { btr_pcur_copy_stored_position(node->pcur, - prebuilt->clust_pcur); + prebuilt->clust_pcur); } ut_a(node->pcur->rel_pos == BTR_PCUR_ON); @@ -1386,7 +1396,7 @@ run_again: thr->lock_state= QUE_THR_LOCK_ROW; was_lock_wait = row_mysql_handle_errors(&err, trx, thr, - &savept); + &savept); thr->lock_state= QUE_THR_LOCK_NOLOCK; if (was_lock_wait) { @@ -1451,12 +1461,13 @@ row_unlock_for_mysql( ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); if (!(srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED)) { + || trx->isolation_level == TRX_ISO_READ_COMMITTED)) { fprintf(stderr, -"InnoDB: Error: calling row_unlock_for_mysql though\n" -"InnoDB: srv_locks_unsafe_for_binlog is FALSE and\n" -"InnoDB: this session is not using READ COMMITTED isolation level.\n"); + "InnoDB: Error: calling row_unlock_for_mysql though\n" + "InnoDB: srv_locks_unsafe_for_binlog is FALSE and\n" + "InnoDB: this session is not using" + " READ COMMITTED isolation level.\n"); return(DB_SUCCESS); } @@ -1502,7 +1513,7 @@ row_unlock_for_mysql( if (!has_latches_on_recs) { btr_pcur_restore_position(BTR_SEARCH_LEAF, clust_pcur, - &mtr); + &mtr); } rec = btr_pcur_get_rec(clust_pcur); @@ -1601,7 +1612,7 @@ row_table_got_default_clust_index( clust_index = dict_table_get_first_index(table); if (dtype_get_mtype(dict_index_get_nth_type(clust_index, 0)) - == DATA_SYS) { + == DATA_SYS) { return(TRUE); } @@ -1679,7 +1690,7 @@ row_mysql_lock_data_dictionary( trx_t* trx) /* in: transaction */ { ut_a(trx->dict_operation_lock_mode == 0 - || trx->dict_operation_lock_mode == RW_X_LATCH); + || trx->dict_operation_lock_mode == RW_X_LATCH); /* Serialize data dictionary operations with dictionary mutex: no deadlocks or lock waits can occur then in these operations */ @@ -1738,13 +1749,13 @@ row_create_table_for_mysql( ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH); if (srv_created_new_raw) { - fputs( - "InnoDB: A new raw disk partition was initialized or\n" - "InnoDB: innodb_force_recovery is on: we do not allow\n" - "InnoDB: database modifications by the user. Shut down\n" - "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" - "InnoDB: with raw, and innodb_force_... is removed.\n", - stderr); + fputs("InnoDB: A new raw disk partition was initialized or\n" + "InnoDB: innodb_force_recovery is on: we do not allow\n" + "InnoDB: database modifications by the user. Shut down\n" + "InnoDB: mysqld and edit my.cnf so that newraw" + " is replaced\n" + "InnoDB: with raw, and innodb_force_... is removed.\n", + stderr); dict_mem_table_free(table); trx_commit_for_mysql(trx); @@ -1757,9 +1768,11 @@ row_create_table_for_mysql( if (row_mysql_is_system_table(table->name)) { fprintf(stderr, - "InnoDB: Error: trying to create a MySQL system table %s of type InnoDB.\n" - "InnoDB: MySQL system tables must be of the MyISAM type!\n", - table->name); + "InnoDB: Error: trying to create a MySQL system" + " table %s of type InnoDB.\n" + "InnoDB: MySQL system tables must be" + " of the MyISAM type!\n", + table->name); dict_mem_table_free(table); trx_commit_for_mysql(trx); @@ -1792,8 +1805,8 @@ row_create_table_for_mysql( table_name_len = strlen(table_name) + 1; if (table_name_len == sizeof S_innodb_monitor - && !memcmp(table_name, S_innodb_monitor, - sizeof S_innodb_monitor)) { + && !memcmp(table_name, S_innodb_monitor, + sizeof S_innodb_monitor)) { /* Table equals "innodb_monitor": start monitor prints */ @@ -1805,41 +1818,43 @@ row_create_table_for_mysql( os_event_set(srv_lock_timeout_thread_event); } else if (table_name_len == sizeof S_innodb_lock_monitor - && !memcmp(table_name, S_innodb_lock_monitor, - sizeof S_innodb_lock_monitor)) { + && !memcmp(table_name, S_innodb_lock_monitor, + sizeof S_innodb_lock_monitor)) { srv_print_innodb_monitor = TRUE; srv_print_innodb_lock_monitor = TRUE; os_event_set(srv_lock_timeout_thread_event); } else if (table_name_len == sizeof S_innodb_tablespace_monitor - && !memcmp(table_name, S_innodb_tablespace_monitor, - sizeof S_innodb_tablespace_monitor)) { + && !memcmp(table_name, S_innodb_tablespace_monitor, + sizeof S_innodb_tablespace_monitor)) { srv_print_innodb_tablespace_monitor = TRUE; os_event_set(srv_lock_timeout_thread_event); } else if (table_name_len == sizeof S_innodb_table_monitor - && !memcmp(table_name, S_innodb_table_monitor, - sizeof S_innodb_table_monitor)) { + && !memcmp(table_name, S_innodb_table_monitor, + sizeof S_innodb_table_monitor)) { srv_print_innodb_table_monitor = TRUE; os_event_set(srv_lock_timeout_thread_event); } else if (table_name_len == sizeof S_innodb_mem_validate - && !memcmp(table_name, S_innodb_mem_validate, - sizeof S_innodb_mem_validate)) { + && !memcmp(table_name, S_innodb_mem_validate, + sizeof S_innodb_mem_validate)) { /* We define here a debugging feature intended for developers */ fputs("Validating InnoDB memory:\n" - "to use this feature you must compile InnoDB with\n" - "UNIV_MEM_DEBUG defined in univ.i and the server must be\n" - "quiet because allocation from a mem heap is not protected\n" - "by any semaphore.\n", stderr); + "to use this feature you must compile InnoDB with\n" + "UNIV_MEM_DEBUG defined in univ.i and" + " the server must be\n" + "quiet because allocation from a mem heap" + " is not protected\n" + "by any semaphore.\n", stderr); #ifdef UNIV_MEM_DEBUG ut_a(mem_validate()); fputs("Memory validated\n", stderr); #else /* UNIV_MEM_DEBUG */ fputs("Memory NOT validated (recompile with UNIV_MEM_DEBUG)\n", - stderr); + stderr); #endif /* UNIV_MEM_DEBUG */ } @@ -1867,14 +1882,14 @@ row_create_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Warning: cannot create table ", - stderr); + stderr); ut_print_name(stderr, trx, TRUE, table->name); fputs(" because tablespace full\n", stderr); if (dict_table_get_low(table->name)) { row_drop_table_for_mysql(table->name, trx, - FALSE); + FALSE); } } else if (err == DB_DUPLICATE_KEY) { @@ -1883,18 +1898,27 @@ row_create_table_for_mysql( fputs(" InnoDB: Error: table ", stderr); ut_print_name(stderr, trx, TRUE, table->name); fputs(" already exists in InnoDB internal\n" - "InnoDB: data dictionary. Have you deleted the .frm file\n" - "InnoDB: and not used DROP TABLE? Have you used DROP DATABASE\n" - "InnoDB: for InnoDB tables in MySQL version <= 3.23.43?\n" - "InnoDB: See the Restrictions section of the InnoDB manual.\n" - "InnoDB: You can drop the orphaned table inside InnoDB by\n" - "InnoDB: creating an InnoDB table with the same name in another\n" - "InnoDB: database and copying the .frm file to the current database.\n" - "InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n" - "InnoDB: succeed.\n" - "InnoDB: You can look for further help from\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", - stderr); + "InnoDB: data dictionary. Have you deleted" + " the .frm file\n" + "InnoDB: and not used DROP TABLE?" + " Have you used DROP DATABASE\n" + "InnoDB: for InnoDB tables in" + " MySQL version <= 3.23.43?\n" + "InnoDB: See the Restrictions section" + " of the InnoDB manual.\n" + "InnoDB: You can drop the orphaned table" + " inside InnoDB by\n" + "InnoDB: creating an InnoDB table with" + " the same name in another\n" + "InnoDB: database and copying the .frm file" + " to the current database.\n" + "InnoDB: Then MySQL thinks the table exists," + " and DROP TABLE will\n" + "InnoDB: succeed.\n" + "InnoDB: You can look for further help from\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n", + stderr); } /* We may also get err == DB_ERROR if the .ibd file for the @@ -1951,20 +1975,21 @@ row_create_index_for_mysql( for (i = 0; i < dict_index_get_n_fields(index); i++) { for (j = 0; j < i; j++) { - if (0 == ut_strcmp( - dict_index_get_nth_field(index, j)->name, - dict_index_get_nth_field(index, i)->name)) { + if (0 == ut_strcmp + (dict_index_get_nth_field(index, j)->name, + dict_index_get_nth_field(index, i)->name)) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: column ", stderr); ut_print_name(stderr, trx, FALSE, - dict_index_get_nth_field(index, i)->name); + dict_index_get_nth_field + (index, i)->name); fputs(" appears twice in ", stderr); dict_index_name_print(stderr, trx, index); fputs("\n" - "InnoDB: This is not allowed in InnoDB.\n", - stderr); + "InnoDB: This is not allowed" + " in InnoDB.\n", stderr); err = DB_COL_APPEARS_TWICE_IN_INDEX; @@ -2065,7 +2090,7 @@ row_table_add_foreign_constraints( trx->dict_operation = TRUE; err = dict_create_foreign_constraints(trx, sql_string, name, - reject_fks); + reject_fks); if (err == DB_SUCCESS) { /* Check that also referencing constraints are ok */ @@ -2112,7 +2137,7 @@ row_drop_table_for_mysql_in_background( trx->check_foreigns = FALSE; -/* fputs("InnoDB: Error: Dropping table ", stderr); + /* fputs("InnoDB: Error: Dropping table ", stderr); ut_print_name(stderr, trx, TRUE, name); fputs(" in background drop list\n", stderr); */ @@ -2180,8 +2205,8 @@ loop: goto already_dropped; } - if (DB_SUCCESS != row_drop_table_for_mysql_in_background( - drop->table_name)) { + if (DB_SUCCESS != row_drop_table_for_mysql_in_background + (drop->table_name)) { /* If the DROP fails for some table, we return, and let the main thread retry later */ @@ -2276,7 +2301,7 @@ row_add_table_to_background_drop_list( UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list, drop); -/* fputs("InnoDB: Adding table ", stderr); + /* fputs("InnoDB: Adding table ", stderr); ut_print_name(stderr, trx, TRUE, drop->table_name); fputs(" to background drop list\n", stderr); */ @@ -2305,25 +2330,34 @@ row_discard_tablespace_for_mysql( ulint err; pars_info_t* info = NULL; -/* How do we prevent crashes caused by ongoing operations on the table? Old -operations could try to access non-existent pages. + /* How do we prevent crashes caused by ongoing operations on + the table? Old operations could try to access non-existent + pages. -1) SQL queries, INSERT, SELECT, ...: we must get an exclusive MySQL table lock -on the table before we can do DISCARD TABLESPACE. Then there are no running -queries on the table. -2) Purge and rollback: we assign a new table id for the table. Since purge and -rollback look for the table based on the table id, they see the table as -'dropped' and discard their operations. -3) Insert buffer: we remove all entries for the tablespace in the insert -buffer tree; as long as the tablespace mem object does not exist, ongoing -insert buffer page merges are discarded in buf0rea.c. If we recreate the -tablespace mem object with IMPORT TABLESPACE later, then the tablespace will -have the same id, but the tablespace_version field in the mem object is -different, and ongoing old insert buffer page merges get discarded. -4) Linear readahead and random readahead: we use the same method as in 3) to -discard ongoing operations. -5) FOREIGN KEY operations: if table->n_foreign_key_checks_running > 0, we -do not allow the discard. We also reserve the data dictionary latch. */ + 1) SQL queries, INSERT, SELECT, ...: we must get an exclusive + MySQL table lock on the table before we can do DISCARD + TABLESPACE. Then there are no running queries on the table. + + 2) Purge and rollback: we assign a new table id for the + table. Since purge and rollback look for the table based on + the table id, they see the table as 'dropped' and discard + their operations. + + 3) Insert buffer: we remove all entries for the tablespace in + the insert buffer tree; as long as the tablespace mem object + does not exist, ongoing insert buffer page merges are + discarded in buf0rea.c. If we recreate the tablespace mem + object with IMPORT TABLESPACE later, then the tablespace will + have the same id, but the tablespace_version field in the mem + object is different, and ongoing old insert buffer page merges + get discarded. + + 4) Linear readahead and random readahead: we use the same + method as in 3) to discard ongoing operations. + + 5) FOREIGN KEY operations: if + table->n_foreign_key_checks_running > 0, we do not allow the + discard. We also reserve the data dictionary latch. */ ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); @@ -2348,7 +2382,8 @@ do not allow the discard. We also reserve the data dictionary latch. */ fputs(" InnoDB: Error: table ", stderr); ut_print_name(stderr, trx, TRUE, name); fputs("\n" -"InnoDB: is in the system tablespace 0 which cannot be discarded\n", stderr); + "InnoDB: is in the system tablespace 0" + " which cannot be discarded\n", stderr); err = DB_ERROR; goto funct_exit; @@ -2360,9 +2395,10 @@ do not allow the discard. We also reserve the data dictionary latch. */ fputs(" InnoDB: You are trying to DISCARD table ", stderr); ut_print_name(stderr, trx, TRUE, table->name); fputs("\n" - "InnoDB: though there is a foreign key check running on it.\n" - "InnoDB: Cannot discard the table.\n", - stderr); + "InnoDB: though there is a foreign key check" + " running on it.\n" + "InnoDB: Cannot discard the table.\n", + stderr); err = DB_ERROR; @@ -2394,7 +2430,7 @@ do not allow the discard. We also reserve the data dictionary latch. */ fputs(" Cannot DISCARD table ", ef); ut_print_name(ef, trx, TRUE, name); fputs("\n" - "because it is referenced by ", ef); + "because it is referenced by ", ef); ut_print_name(ef, trx, TRUE, foreign->foreign_table_name); putc('\n', ef); mutex_exit(&dict_foreign_err_mutex); @@ -2413,26 +2449,26 @@ do not allow the discard. We also reserve the data dictionary latch. */ pars_info_add_dulint_literal(info, "new_id", new_id); err = que_eval_sql(info, - "PROCEDURE DISCARD_TABLESPACE_PROC () IS\n" - "old_id CHAR;\n" - "BEGIN\n" - "SELECT ID INTO old_id\n" - "FROM SYS_TABLES\n" - "WHERE NAME = :table_name\n" - "LOCK IN SHARE MODE;\n" - "IF (SQL % NOTFOUND) THEN\n" - " COMMIT WORK;\n" - " RETURN;\n" - "END IF;\n" - "UPDATE SYS_TABLES SET ID = :new_id\n" - " WHERE ID = old_id;\n" - "UPDATE SYS_COLUMNS SET TABLE_ID = :new_id\n" - " WHERE TABLE_ID = old_id;\n" - "UPDATE SYS_INDEXES SET TABLE_ID = :new_id\n" - " WHERE TABLE_ID = old_id;\n" - "COMMIT WORK;\n" - "END;\n" - , FALSE, trx); + "PROCEDURE DISCARD_TABLESPACE_PROC () IS\n" + "old_id CHAR;\n" + "BEGIN\n" + "SELECT ID INTO old_id\n" + "FROM SYS_TABLES\n" + "WHERE NAME = :table_name\n" + "LOCK IN SHARE MODE;\n" + "IF (SQL % NOTFOUND) THEN\n" + " COMMIT WORK;\n" + " RETURN;\n" + "END IF;\n" + "UPDATE SYS_TABLES SET ID = :new_id\n" + " WHERE ID = old_id;\n" + "UPDATE SYS_COLUMNS SET TABLE_ID = :new_id\n" + " WHERE TABLE_ID = old_id;\n" + "UPDATE SYS_INDEXES SET TABLE_ID = :new_id\n" + " WHERE TABLE_ID = old_id;\n" + "COMMIT WORK;\n" + "END;\n" + , FALSE, trx); if (err != DB_SUCCESS) { trx->error_state = DB_SUCCESS; @@ -2510,7 +2546,8 @@ row_import_tablespace_for_mysql( fputs(" InnoDB: Error: cannot reset lsn's in table ", stderr); ut_print_name(stderr, trx, TRUE, name); fputs("\n" - "InnoDB: in ALTER TABLE ... IMPORT TABLESPACE\n", stderr); + "InnoDB: in ALTER TABLE ... IMPORT TABLESPACE\n", + stderr); err = DB_ERROR; @@ -2531,9 +2568,9 @@ row_import_tablespace_for_mysql( fputs(" InnoDB: table ", stderr); ut_print_name(stderr, trx, TRUE, name); fputs("\n" -"InnoDB: does not exist in the InnoDB data dictionary\n" -"InnoDB: in ALTER TABLE ... IMPORT TABLESPACE\n", - stderr); + "InnoDB: does not exist in the InnoDB data dictionary\n" + "InnoDB: in ALTER TABLE ... IMPORT TABLESPACE\n", + stderr); err = DB_TABLE_NOT_FOUND; @@ -2545,7 +2582,8 @@ row_import_tablespace_for_mysql( fputs(" InnoDB: Error: table ", stderr); ut_print_name(stderr, trx, TRUE, name); fputs("\n" -"InnoDB: is in the system tablespace 0 which cannot be imported\n", stderr); + "InnoDB: is in the system tablespace 0" + " which cannot be imported\n", stderr); err = DB_ERROR; goto funct_exit; @@ -2553,12 +2591,13 @@ row_import_tablespace_for_mysql( if (!table->tablespace_discarded) { ut_print_timestamp(stderr); - fputs( -" InnoDB: Error: you are trying to IMPORT a tablespace\n" -"InnoDB: ", stderr); + fputs(" InnoDB: Error: you are trying to" + " IMPORT a tablespace\n" + "InnoDB: ", stderr); ut_print_name(stderr, trx, TRUE, name); fputs(", though you have not called DISCARD on it yet\n" -"InnoDB: during the lifetime of the mysqld process!\n", stderr); + "InnoDB: during the lifetime of the mysqld process!\n", + stderr); err = DB_ERROR; @@ -2571,20 +2610,20 @@ row_import_tablespace_for_mysql( ibuf_delete_for_discarded_space(table->space); success = fil_open_single_table_tablespace(TRUE, table->space, - table->name); + table->name); if (success) { table->ibd_file_missing = FALSE; table->tablespace_discarded = FALSE; } else { if (table->ibd_file_missing) { ut_print_timestamp(stderr); - fputs( -" InnoDB: cannot find or open in the database directory the .ibd file of\n" -"InnoDB: table ", stderr); + fputs(" InnoDB: cannot find or open in the" + " database directory the .ibd file of\n" + "InnoDB: table ", stderr); ut_print_name(stderr, trx, TRUE, name); fputs("\n" -"InnoDB: in ALTER TABLE ... IMPORT TABLESPACE\n", - stderr); + "InnoDB: in ALTER TABLE ... IMPORT TABLESPACE\n", + stderr); } err = DB_ERROR; @@ -2622,43 +2661,51 @@ row_truncate_table_for_mysql( dulint new_id; pars_info_t* info = NULL; -/* How do we prevent crashes caused by ongoing operations on the table? Old -operations could try to access non-existent pages. + /* How do we prevent crashes caused by ongoing operations on + the table? Old operations could try to access non-existent + pages. -1) SQL queries, INSERT, SELECT, ...: we must get an exclusive MySQL table lock -on the table before we can do TRUNCATE TABLE. Then there are no running -queries on the table. This is guaranteed, because in -ha_innobase::store_lock(), we do not weaken the TL_WRITE lock requested -by MySQL when executing SQLCOM_TRUNCATE. -2) Purge and rollback: we assign a new table id for the table. Since purge and -rollback look for the table based on the table id, they see the table as -'dropped' and discard their operations. -3) Insert buffer: TRUNCATE TABLE is analogous to DROP TABLE, so we do not -have to remove insert buffer records, as the insert buffer works at a low -level. If a freed page is later reallocated, the allocator will remove -the ibuf entries for it. + 1) SQL queries, INSERT, SELECT, ...: we must get an exclusive + MySQL table lock on the table before we can do TRUNCATE + TABLE. Then there are no running queries on the table. This is + guaranteed, because in ha_innobase::store_lock(), we do not + weaken the TL_WRITE lock requested by MySQL when executing + SQLCOM_TRUNCATE. -TODO: when we truncate *.ibd files (analogous to DISCARD TABLESPACE), we -will have to remove we remove all entries for the table in the insert -buffer tree! + 2) Purge and rollback: we assign a new table id for the + table. Since purge and rollback look for the table based on + the table id, they see the table as 'dropped' and discard + their operations. -4) Linear readahead and random readahead: we use the same method as in 3) to -discard ongoing operations. (This will only be relevant for TRUNCATE TABLE -by DISCARD TABLESPACE.) -5) FOREIGN KEY operations: if table->n_foreign_key_checks_running > 0, we -do not allow the TRUNCATE. We also reserve the data dictionary latch. */ + 3) Insert buffer: TRUNCATE TABLE is analogous to DROP TABLE, + so we do not have to remove insert buffer records, as the + insert buffer works at a low level. If a freed page is later + reallocated, the allocator will remove the ibuf entries for + it. + + TODO: when we truncate *.ibd files (analogous to DISCARD + TABLESPACE), we will have to remove we remove all entries for + the table in the insert buffer tree! + + 4) Linear readahead and random readahead: we use the same + method as in 3) to discard ongoing operations. (This will only + be relevant for TRUNCATE TABLE by DISCARD TABLESPACE.) + + 5) FOREIGN KEY operations: if + table->n_foreign_key_checks_running > 0, we do not allow the + TRUNCATE. We also reserve the data dictionary latch. */ ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(table); if (srv_created_new_raw) { - fputs( - "InnoDB: A new raw disk partition was initialized or\n" - "InnoDB: innodb_force_recovery is on: we do not allow\n" - "InnoDB: database modifications by the user. Shut down\n" - "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" - "InnoDB: with raw, and innodb_force_... is removed.\n", - stderr); + fputs("InnoDB: A new raw disk partition was initialized or\n" + "InnoDB: innodb_force_recovery is on: we do not allow\n" + "InnoDB: database modifications by the user. Shut down\n" + "InnoDB: mysqld and edit my.cnf so that newraw" + " is replaced\n" + "InnoDB: with raw, and innodb_force_... is removed.\n", + stderr); return(DB_ERROR); } @@ -2703,7 +2750,7 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */ fputs(" Cannot truncate table ", ef); ut_print_name(ef, trx, TRUE, table->name); fputs(" by DROP+CREATE\n" - "InnoDB: because it is referenced by ", ef); + "InnoDB: because it is referenced by ", ef); ut_print_name(ef, trx, TRUE, foreign->foreign_table_name); putc('\n', ef); mutex_exit(&dict_foreign_err_mutex); @@ -2723,8 +2770,9 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */ fputs(" InnoDB: Cannot truncate table ", stderr); ut_print_name(stderr, trx, TRUE, table->name); fputs(" by DROP+CREATE\n" -"InnoDB: because there is a foreign key check running on it.\n", - stderr); + "InnoDB: because there is a foreign key check" + " running on it.\n", + stderr); err = DB_ERROR; goto funct_exit; @@ -2751,7 +2799,7 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */ mtr_start(&mtr); btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, - BTR_MODIFY_LEAF, &pcur, &mtr); + BTR_MODIFY_LEAF, &pcur, &mtr); for (;;) { rec_t* rec; const byte* field; @@ -2787,9 +2835,9 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */ rec = btr_pcur_get_rec(&pcur); if (root_page_no != FIL_NULL) { - page_rec_write_index_page_no(rec, - DICT_SYS_INDEXES_PAGE_NO_FIELD, - root_page_no, &mtr); + page_rec_write_index_page_no + (rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, + root_page_no, &mtr); /* We will need to commit and restart the mini-transaction in order to avoid deadlocks. The dict_truncate_index_tree() call has allocated @@ -2798,10 +2846,10 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */ mtr_commit(&mtr); mtr_start(&mtr); btr_pcur_restore_position(BTR_MODIFY_LEAF, - &pcur, &mtr); + &pcur, &mtr); } - next_rec: +next_rec: btr_pcur_move_to_next_user_rec(&pcur, &mtr); } @@ -2818,28 +2866,29 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */ pars_info_add_dulint_literal(info, "new_id", new_id); err = que_eval_sql(info, - "PROCEDURE RENUMBER_TABLESPACE_PROC () IS\n" - "BEGIN\n" - "UPDATE SYS_TABLES SET ID = :new_id\n" - " WHERE ID = :old_id;\n" - "UPDATE SYS_COLUMNS SET TABLE_ID = :new_id\n" - " WHERE TABLE_ID = :old_id;\n" - "UPDATE SYS_INDEXES SET TABLE_ID = :new_id\n" - " WHERE TABLE_ID = :old_id;\n" - "COMMIT WORK;\n" - "END;\n" - , FALSE, trx); + "PROCEDURE RENUMBER_TABLESPACE_PROC () IS\n" + "BEGIN\n" + "UPDATE SYS_TABLES SET ID = :new_id\n" + " WHERE ID = :old_id;\n" + "UPDATE SYS_COLUMNS SET TABLE_ID = :new_id\n" + " WHERE TABLE_ID = :old_id;\n" + "UPDATE SYS_INDEXES SET TABLE_ID = :new_id\n" + " WHERE TABLE_ID = :old_id;\n" + "COMMIT WORK;\n" + "END;\n" + , FALSE, trx); if (err != DB_SUCCESS) { trx->error_state = DB_SUCCESS; trx_general_rollback_for_mysql(trx, FALSE, NULL); trx->error_state = DB_SUCCESS; ut_print_timestamp(stderr); -fputs(" InnoDB: Unable to assign a new identifier to table ", stderr); + fputs(" InnoDB: Unable to assign a new identifier to table ", + stderr); ut_print_name(stderr, trx, TRUE, table->name); fputs("\n" -"InnoDB: after truncating it. Background processes may corrupt the table!\n", - stderr); + "InnoDB: after truncating it. Background processes" + " may corrupt the table!\n", stderr); err = DB_ERROR; } else { dict_table_change_id_in_cache(table, new_id); @@ -2889,13 +2938,13 @@ row_drop_table_for_mysql( ut_a(name != NULL); if (srv_created_new_raw) { - fputs( - "InnoDB: A new raw disk partition was initialized or\n" - "InnoDB: innodb_force_recovery is on: we do not allow\n" - "InnoDB: database modifications by the user. Shut down\n" - "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" - "InnoDB: with raw, and innodb_force_... is removed.\n", - stderr); + fputs("InnoDB: A new raw disk partition was initialized or\n" + "InnoDB: innodb_force_recovery is on: we do not allow\n" + "InnoDB: database modifications by the user. Shut down\n" + "InnoDB: mysqld and edit my.cnf so that newraw" + " is replaced\n" + "InnoDB: with raw, and innodb_force_... is removed.\n", + stderr); return(DB_ERROR); } @@ -2914,8 +2963,8 @@ row_drop_table_for_mysql( namelen = strlen(table_name) + 1; if (namelen == sizeof S_innodb_monitor - && !memcmp(table_name, S_innodb_monitor, - sizeof S_innodb_monitor)) { + && !memcmp(table_name, S_innodb_monitor, + sizeof S_innodb_monitor)) { /* Table name equals "innodb_monitor": stop monitor prints */ @@ -2923,18 +2972,18 @@ row_drop_table_for_mysql( srv_print_innodb_monitor = FALSE; srv_print_innodb_lock_monitor = FALSE; } else if (namelen == sizeof S_innodb_lock_monitor - && !memcmp(table_name, S_innodb_lock_monitor, - sizeof S_innodb_lock_monitor)) { + && !memcmp(table_name, S_innodb_lock_monitor, + sizeof S_innodb_lock_monitor)) { srv_print_innodb_monitor = FALSE; srv_print_innodb_lock_monitor = FALSE; } else if (namelen == sizeof S_innodb_tablespace_monitor - && !memcmp(table_name, S_innodb_tablespace_monitor, - sizeof S_innodb_tablespace_monitor)) { + && !memcmp(table_name, S_innodb_tablespace_monitor, + sizeof S_innodb_tablespace_monitor)) { srv_print_innodb_tablespace_monitor = FALSE; } else if (namelen == sizeof S_innodb_table_monitor - && !memcmp(table_name, S_innodb_table_monitor, - sizeof S_innodb_table_monitor)) { + && !memcmp(table_name, S_innodb_table_monitor, + sizeof S_innodb_table_monitor)) { srv_print_innodb_table_monitor = FALSE; } @@ -2965,12 +3014,16 @@ row_drop_table_for_mysql( fputs(" InnoDB: Error: table ", stderr); ut_print_name(stderr, trx, TRUE, name); fputs(" does not exist in the InnoDB internal\n" - "InnoDB: data dictionary though MySQL is trying to drop it.\n" - "InnoDB: Have you copied the .frm file of the table to the\n" - "InnoDB: MySQL database directory from another database?\n" - "InnoDB: You can look for further help from\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", - stderr); + "InnoDB: data dictionary though MySQL is" + " trying to drop it.\n" + "InnoDB: Have you copied the .frm file" + " of the table to the\n" + "InnoDB: MySQL database directory" + " from another database?\n" + "InnoDB: You can look for further help from\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n", + stderr); goto funct_exit; } @@ -2980,13 +3033,13 @@ row_drop_table_for_mysql( foreign = UT_LIST_GET_FIRST(table->referenced_list); while (foreign && foreign->foreign_table == table) { - check_next_foreign: +check_next_foreign: foreign = UT_LIST_GET_NEXT(referenced_list, foreign); } - if (foreign && trx->check_foreigns && - !(drop_db && dict_tables_have_same_db( - name, foreign->foreign_table_name))) { + if (foreign && trx->check_foreigns + && !(drop_db && dict_tables_have_same_db + (name, foreign->foreign_table_name))) { FILE* ef = dict_foreign_err_file; /* We only allow dropping a referenced table if @@ -3001,7 +3054,7 @@ row_drop_table_for_mysql( fputs(" Cannot drop table ", ef); ut_print_name(ef, trx, TRUE, name); fputs("\n" - "because it is referenced by ", ef); + "because it is referenced by ", ef); ut_print_name(ef, trx, TRUE, foreign->foreign_table_name); putc('\n', ef); mutex_exit(&dict_foreign_err_mutex); @@ -3020,12 +3073,15 @@ row_drop_table_for_mysql( if (added) { ut_print_timestamp(stderr); -fputs(" InnoDB: Warning: MySQL is trying to drop table ", stderr); + fputs(" InnoDB: Warning: MySQL is" + " trying to drop table ", stderr); ut_print_name(stderr, trx, TRUE, table->name); fputs("\n" -"InnoDB: though there are still open handles to it.\n" -"InnoDB: Adding the table to the background drop queue.\n", - stderr); + "InnoDB: though there are still" + " open handles to it.\n" + "InnoDB: Adding the table to the" + " background drop queue.\n", + stderr); /* We return DB_SUCCESS to MySQL though the drop will happen lazily later */ @@ -3053,12 +3109,15 @@ fputs(" InnoDB: Warning: MySQL is trying to drop table ", stderr); if (added) { ut_print_timestamp(stderr); -fputs(" InnoDB: You are trying to drop table ", stderr); + fputs(" InnoDB: You are trying to drop table ", + stderr); ut_print_name(stderr, trx, TRUE, table->name); fputs("\n" -"InnoDB: though there is a foreign key check running on it.\n" -"InnoDB: Adding the table to the background drop queue.\n", - stderr); + "InnoDB: though there is a" + " foreign key check running on it.\n" + "InnoDB: Adding the table to" + " the background drop queue.\n", + stderr); /* We return DB_SUCCESS to MySQL though the drop will happen lazily later */ @@ -3089,67 +3148,74 @@ fputs(" InnoDB: You are trying to drop table ", stderr); pars_info_add_str_literal(info, "table_name", name); err = que_eval_sql(info, - "PROCEDURE DROP_TABLE_PROC () IS\n" - "sys_foreign_id CHAR;\n" - "table_id CHAR;\n" - "index_id CHAR;\n" - "foreign_id CHAR;\n" - "found INT;\n" - "BEGIN\n" - "SELECT ID INTO table_id\n" - "FROM SYS_TABLES\n" - "WHERE NAME = :table_name\n" - "LOCK IN SHARE MODE;\n" - "IF (SQL % NOTFOUND) THEN\n" - " COMMIT WORK;\n" - " RETURN;\n" - "END IF;\n" - "found := 1;\n" - "SELECT ID INTO sys_foreign_id\n" - "FROM SYS_TABLES\n" - "WHERE NAME = 'SYS_FOREIGN'\n" - "LOCK IN SHARE MODE;\n" - "IF (SQL % NOTFOUND) THEN\n" - " found := 0;\n" - "END IF;\n" - "IF (:table_name = 'SYS_FOREIGN') THEN\n" - " found := 0;\n" - "END IF;\n" - "IF (:table_name = 'SYS_FOREIGN_COLS') THEN\n" - " found := 0;\n" - "END IF;\n" - "WHILE found = 1 LOOP\n" - " SELECT ID INTO foreign_id\n" - " FROM SYS_FOREIGN\n" - " WHERE FOR_NAME = :table_name\n" - " AND TO_BINARY(FOR_NAME) = TO_BINARY(:table_name)\n" - " LOCK IN SHARE MODE;\n" - " IF (SQL % NOTFOUND) THEN\n" - " found := 0;\n" - " ELSE" - " DELETE FROM SYS_FOREIGN_COLS WHERE ID = foreign_id;\n" - " DELETE FROM SYS_FOREIGN WHERE ID = foreign_id;\n" - " END IF;\n" - "END LOOP;\n" - "found := 1;\n" - "WHILE found = 1 LOOP\n" - " SELECT ID INTO index_id\n" - " FROM SYS_INDEXES\n" - " WHERE TABLE_ID = table_id\n" - " LOCK IN SHARE MODE;\n" - " IF (SQL % NOTFOUND) THEN\n" - " found := 0;\n" - " ELSE" - " DELETE FROM SYS_FIELDS WHERE INDEX_ID = index_id;\n" - " DELETE FROM SYS_INDEXES WHERE ID = index_id\n" - " AND TABLE_ID = table_id;\n" - " END IF;\n" - "END LOOP;\n" - "DELETE FROM SYS_COLUMNS WHERE TABLE_ID = table_id;\n" - "DELETE FROM SYS_TABLES WHERE ID = table_id;\n" - "COMMIT WORK;\n" - "END;\n" - , FALSE, trx); + "PROCEDURE DROP_TABLE_PROC () IS\n" + "sys_foreign_id CHAR;\n" + "table_id CHAR;\n" + "index_id CHAR;\n" + "foreign_id CHAR;\n" + "found INT;\n" + "BEGIN\n" + "SELECT ID INTO table_id\n" + "FROM SYS_TABLES\n" + "WHERE NAME = :table_name\n" + "LOCK IN SHARE MODE;\n" + "IF (SQL % NOTFOUND) THEN\n" + " COMMIT WORK;\n" + " RETURN;\n" + "END IF;\n" + "found := 1;\n" + "SELECT ID INTO sys_foreign_id\n" + "FROM SYS_TABLES\n" + "WHERE NAME = 'SYS_FOREIGN'\n" + "LOCK IN SHARE MODE;\n" + "IF (SQL % NOTFOUND) THEN\n" + " found := 0;\n" + "END IF;\n" + "IF (:table_name = 'SYS_FOREIGN') THEN\n" + " found := 0;\n" + "END IF;\n" + "IF (:table_name = 'SYS_FOREIGN_COLS') THEN\n" + " found := 0;\n" + "END IF;\n" + "WHILE found = 1 LOOP\n" + " SELECT ID INTO foreign_id\n" + " FROM SYS_FOREIGN\n" + " WHERE FOR_NAME = :table_name\n" + " AND TO_BINARY(FOR_NAME)\n" + " = TO_BINARY(:table_name)\n" + " LOCK IN SHARE MODE;\n" + " IF (SQL % NOTFOUND) THEN\n" + " found := 0;\n" + " ELSE\n" + " DELETE FROM SYS_FOREIGN_COLS\n" + " WHERE ID = foreign_id;\n" + " DELETE FROM SYS_FOREIGN\n" + " WHERE ID = foreign_id;\n" + " END IF;\n" + "END LOOP;\n" + "found := 1;\n" + "WHILE found = 1 LOOP\n" + " SELECT ID INTO index_id\n" + " FROM SYS_INDEXES\n" + " WHERE TABLE_ID = table_id\n" + " LOCK IN SHARE MODE;\n" + " IF (SQL % NOTFOUND) THEN\n" + " found := 0;\n" + " ELSE\n" + " DELETE FROM SYS_FIELDS\n" + " WHERE INDEX_ID = index_id;\n" + " DELETE FROM SYS_INDEXES\n" + " WHERE ID = index_id\n" + " AND TABLE_ID = table_id;\n" + " END IF;\n" + "END LOOP;\n" + "DELETE FROM SYS_COLUMNS\n" + "WHERE TABLE_ID = table_id;\n" + "DELETE FROM SYS_TABLES\n" + "WHERE ID = table_id;\n" + "COMMIT WORK;\n" + "END;\n" + , FALSE, trx); if (err != DB_SUCCESS) { ut_a(err == DB_OUT_OF_FILE_SPACE); @@ -3166,8 +3232,8 @@ fputs(" InnoDB: You are trying to drop table ", stderr); space_id = table->space; if (table->dir_path_of_temp_table != NULL) { - dir_path_of_temp_table = - mem_strdup(table->dir_path_of_temp_table); + dir_path_of_temp_table = mem_strdup + (table->dir_path_of_temp_table); is_path = TRUE; name_or_path = dir_path_of_temp_table; } else { @@ -3180,7 +3246,7 @@ fputs(" InnoDB: You are trying to drop table ", stderr); if (dict_load_table(name) != NULL) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: not able to remove table ", - stderr); + stderr); ut_print_name(stderr, trx, TRUE, name); fputs(" from the dictionary cache!\n", stderr); err = DB_ERROR; @@ -3191,14 +3257,15 @@ fputs(" InnoDB: You are trying to drop table ", stderr); if (err == DB_SUCCESS && space_id > 0) { if (!fil_space_for_table_exists_in_mem(space_id, - name_or_path, - is_path, - FALSE, TRUE)) { + name_or_path, + is_path, + FALSE, TRUE)) { err = DB_SUCCESS; fprintf(stderr, -"InnoDB: We removed now the InnoDB internal data dictionary entry\n" -"InnoDB: of table "); + "InnoDB: We removed now the InnoDB" + " internal data dictionary entry\n" + "InnoDB: of table "); ut_print_name(stderr, trx, TRUE, name); fprintf(stderr, ".\n"); @@ -3209,14 +3276,16 @@ fputs(" InnoDB: You are trying to drop table ", stderr); if (!success) { fprintf(stderr, -"InnoDB: We removed now the InnoDB internal data dictionary entry\n" -"InnoDB: of table "); + "InnoDB: We removed now the InnoDB" + " internal data dictionary entry\n" + "InnoDB: of table "); ut_print_name(stderr, trx, TRUE, name); fprintf(stderr, ".\n"); ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: not able to delete tablespace %lu of table ", + " InnoDB: Error: not able to" + " delete tablespace %lu of table ", (ulong) space_id); ut_print_name(stderr, trx, TRUE, name); fputs("!\n", stderr); @@ -3284,11 +3353,12 @@ loop: row_mysql_unlock_data_dictionary(trx); ut_print_timestamp(stderr); - fputs( - " InnoDB: Warning: MySQL is trying to drop database ", stderr); + fputs(" InnoDB: Warning: MySQL is trying to" + " drop database ", stderr); ut_print_name(stderr, trx, TRUE, name); fputs("\n" - "InnoDB: though there are still open handles to table ", stderr); + "InnoDB: though there are still" + " open handles to table ", stderr); ut_print_name(stderr, trx, TRUE, table_name); fputs(".\n", stderr); @@ -3353,12 +3423,12 @@ row_delete_constraint_low( pars_info_add_str_literal(info, "id", id); return(que_eval_sql(info, - "PROCEDURE DELETE_CONSTRAINT () IS\n" - "BEGIN\n" - "DELETE FROM SYS_FOREIGN_COLS WHERE ID = :id;\n" - "DELETE FROM SYS_FOREIGN WHERE ID = :id;\n" - "END;\n" - , FALSE, trx)); + "PROCEDURE DELETE_CONSTRAINT () IS\n" + "BEGIN\n" + "DELETE FROM SYS_FOREIGN_COLS WHERE ID = :id;\n" + "DELETE FROM SYS_FOREIGN WHERE ID = :id;\n" + "END;\n" + , FALSE, trx)); } /******************************************************************** @@ -3377,8 +3447,8 @@ row_delete_constraint( ulint err; /* New format constraints have ids /. */ - err = row_delete_constraint_low( - mem_heap_strcat(heap, database_name, id), trx); + err = row_delete_constraint_low + (mem_heap_strcat(heap, database_name, id), trx); if ((err == DB_SUCCESS) && !strchr(id, '/')) { /* Old format < 4.0.18 constraints have constraint ids @@ -3418,13 +3488,13 @@ row_rename_table_for_mysql( ut_a(new_name != NULL); if (srv_created_new_raw || srv_force_recovery) { - fputs( - "InnoDB: A new raw disk partition was initialized or\n" - "InnoDB: innodb_force_recovery is on: we do not allow\n" - "InnoDB: database modifications by the user. Shut down\n" - "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" - "InnoDB: with raw, and innodb_force_... is removed.\n", - stderr); + fputs("InnoDB: A new raw disk partition was initialized or\n" + "InnoDB: innodb_force_recovery is on: we do not allow\n" + "InnoDB: database modifications by the user. Shut down\n" + "InnoDB: mysqld and edit my.cnf so that newraw" + " is replaced\n" + "InnoDB: with raw, and innodb_force_... is removed.\n", + stderr); trx_commit_for_mysql(trx); return(DB_ERROR); @@ -3433,9 +3503,11 @@ row_rename_table_for_mysql( if (row_mysql_is_system_table(new_name)) { fprintf(stderr, - "InnoDB: Error: trying to create a MySQL system table %s of type InnoDB.\n" - "InnoDB: MySQL system tables must be of the MyISAM type!\n", - new_name); + "InnoDB: Error: trying to create a MySQL" + " system table %s of type InnoDB.\n" + "InnoDB: MySQL system tables must be" + " of the MyISAM type!\n", + new_name); trx_commit_for_mysql(trx); return(DB_ERROR); @@ -3461,12 +3533,16 @@ row_rename_table_for_mysql( fputs(" InnoDB: Error: table ", stderr); ut_print_name(stderr, trx, TRUE, old_name); fputs(" does not exist in the InnoDB internal\n" - "InnoDB: data dictionary though MySQL is trying to rename the table.\n" - "InnoDB: Have you copied the .frm file of the table to the\n" - "InnoDB: MySQL database directory from another database?\n" - "InnoDB: You can look for further help from\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", - stderr); + "InnoDB: data dictionary though MySQL is" + " trying to rename the table.\n" + "InnoDB: Have you copied the .frm file" + " of the table to the\n" + "InnoDB: MySQL database directory" + " from another database?\n" + "InnoDB: You can look for further help from\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n", + stderr); goto funct_exit; } @@ -3476,11 +3552,12 @@ row_rename_table_for_mysql( fputs(" InnoDB: Error: table ", stderr); ut_print_name(stderr, trx, TRUE, old_name); - fputs( - " does not have an .ibd file in the database directory.\n" - "InnoDB: You can look for further help from\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n", - stderr); + fputs(" does not have an .ibd file" + " in the database directory.\n" + "InnoDB: You can look for further help from\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n", + stderr); goto funct_exit; } @@ -3493,8 +3570,9 @@ row_rename_table_for_mysql( heap = mem_heap_create(100); - err = dict_foreign_parse_drop_constraints(heap, trx, - table, &n_constraints_to_drop, &constraints_to_drop); + err = dict_foreign_parse_drop_constraints + (heap, trx, table, + &n_constraints_to_drop, &constraints_to_drop); if (err != DB_SUCCESS) { @@ -3513,12 +3591,12 @@ row_rename_table_for_mysql( pars_info_add_str_literal(info, "old_table_name", old_name); err = que_eval_sql(info, - "PROCEDURE RENAME_TABLE () IS\n" - "BEGIN\n" - "UPDATE SYS_TABLES SET NAME = :new_table_name\n" - " WHERE NAME = :old_table_name;\n" - "END;\n" - , FALSE, trx); + "PROCEDURE RENAME_TABLE () IS\n" + "BEGIN\n" + "UPDATE SYS_TABLES SET NAME = :new_table_name\n" + " WHERE NAME = :old_table_name;\n" + "END;\n" + , FALSE, trx); if (err != DB_SUCCESS) { @@ -3533,78 +3611,83 @@ row_rename_table_for_mysql( pars_info_add_str_literal(info, "new_table_name", new_name); pars_info_add_str_literal(info, "old_table_name", old_name); - err = que_eval_sql(info, - "PROCEDURE RENAME_CONSTRAINT_IDS () IS\n" - "gen_constr_prefix CHAR;\n" - "new_db_name CHAR;\n" - "foreign_id CHAR;\n" - "new_foreign_id CHAR;\n" - "old_db_name_len INT;\n" - "old_t_name_len INT;\n" - "new_db_name_len INT;\n" - "id_len INT;\n" - "found INT;\n" - "BEGIN\n" - "found := 1;\n" - "old_db_name_len := INSTR(:old_table_name, '/') - 1;\n" - "new_db_name_len := INSTR(:new_table_name, '/') - 1;\n" - "new_db_name := SUBSTR(:new_table_name, 0, new_db_name_len);\n" - "old_t_name_len := LENGTH(:old_table_name);\n" - "gen_constr_prefix := CONCAT(:old_table_name, '_ibfk_');\n" - "WHILE found = 1 LOOP\n" - " SELECT ID INTO foreign_id\n" - " FROM SYS_FOREIGN\n" - " WHERE FOR_NAME = :old_table_name\n" - " AND TO_BINARY(FOR_NAME) = TO_BINARY(:old_table_name)\n" - " LOCK IN SHARE MODE;\n" - " IF (SQL % NOTFOUND) THEN\n" - " found := 0;\n" - " ELSE\n" - " UPDATE SYS_FOREIGN\n" - " SET FOR_NAME = :new_table_name\n" - " WHERE ID = foreign_id;\n" - " id_len := LENGTH(foreign_id);\n" - " IF (INSTR(foreign_id, '/') > 0) THEN\n" - " IF (INSTR(foreign_id,\n" - " gen_constr_prefix) > 0)\n" - " THEN\n" - " new_foreign_id :=\n" - " CONCAT(:new_table_name,\n" - " SUBSTR(foreign_id, old_t_name_len,\n" - " id_len - old_t_name_len));\n" - " ELSE\n" - " new_foreign_id :=\n" - " CONCAT(new_db_name,\n" - " SUBSTR(foreign_id,\n" - " old_db_name_len,\n" - " id_len - old_db_name_len));\n" - " END IF;\n" - " UPDATE SYS_FOREIGN\n" - " SET ID = new_foreign_id\n" - " WHERE ID = foreign_id;\n" - " UPDATE SYS_FOREIGN_COLS\n" - " SET ID = new_foreign_id\n" - " WHERE ID = foreign_id;\n" - " END IF;\n" - " END IF;\n" - "END LOOP;\n" - "UPDATE SYS_FOREIGN SET REF_NAME = :new_table_name\n" - "WHERE REF_NAME = :old_table_name\n" - " AND TO_BINARY(REF_NAME) = TO_BINARY(:old_table_name);\n" - "END;\n" - , FALSE, trx); + err = que_eval_sql + (info, + "PROCEDURE RENAME_CONSTRAINT_IDS () IS\n" + "gen_constr_prefix CHAR;\n" + "new_db_name CHAR;\n" + "foreign_id CHAR;\n" + "new_foreign_id CHAR;\n" + "old_db_name_len INT;\n" + "old_t_name_len INT;\n" + "new_db_name_len INT;\n" + "id_len INT;\n" + "found INT;\n" + "BEGIN\n" + "found := 1;\n" + "old_db_name_len := INSTR(:old_table_name, '/')-1;\n" + "new_db_name_len := INSTR(:new_table_name, '/')-1;\n" + "new_db_name := SUBSTR(:new_table_name, 0,\n" + " new_db_name_len);\n" + "old_t_name_len := LENGTH(:old_table_name);\n" + "gen_constr_prefix := CONCAT(:old_table_name,\n" + " '_ibfk_');\n" + "WHILE found = 1 LOOP\n" + " SELECT ID INTO foreign_id\n" + " FROM SYS_FOREIGN\n" + " WHERE FOR_NAME = :old_table_name\n" + " AND TO_BINARY(FOR_NAME)\n" + " = TO_BINARY(:old_table_name)\n" + " LOCK IN SHARE MODE;\n" + " IF (SQL % NOTFOUND) THEN\n" + " found := 0;\n" + " ELSE\n" + " UPDATE SYS_FOREIGN\n" + " SET FOR_NAME = :new_table_name\n" + " WHERE ID = foreign_id;\n" + " id_len := LENGTH(foreign_id);\n" + " IF (INSTR(foreign_id, '/') > 0) THEN\n" + " IF (INSTR(foreign_id,\n" + " gen_constr_prefix) > 0)\n" + " THEN\n" + " new_foreign_id :=\n" + " CONCAT(:new_table_name,\n" + " SUBSTR(foreign_id, old_t_name_len,\n" + " id_len - old_t_name_len));\n" + " ELSE\n" + " new_foreign_id :=\n" + " CONCAT(new_db_name,\n" + " SUBSTR(foreign_id,\n" + " old_db_name_len,\n" + " id_len - old_db_name_len));\n" + " END IF;\n" + " UPDATE SYS_FOREIGN\n" + " SET ID = new_foreign_id\n" + " WHERE ID = foreign_id;\n" + " UPDATE SYS_FOREIGN_COLS\n" + " SET ID = new_foreign_id\n" + " WHERE ID = foreign_id;\n" + " END IF;\n" + " END IF;\n" + "END LOOP;\n" + "UPDATE SYS_FOREIGN SET REF_NAME = :new_table_name\n" + "WHERE REF_NAME = :old_table_name\n" + " AND TO_BINARY(REF_NAME)\n" + " = TO_BINARY(:old_table_name);\n" + "END;\n" + , FALSE, trx); } else if (n_constraints_to_drop > 0) { /* Drop some constraints of tmp tables. */ ulint db_name_len = dict_get_db_name_len(old_name) + 1; char* db_name = mem_heap_strdupl(heap, old_name, - db_name_len); + db_name_len); ulint i; for (i = 0; i < n_constraints_to_drop; i++) { err = row_delete_constraint(constraints_to_drop[i], - db_name, heap, trx); + db_name, heap, trx); if (err != DB_SUCCESS) { break; @@ -3616,30 +3699,40 @@ end: if (err != DB_SUCCESS) { if (err == DB_DUPLICATE_KEY) { ut_print_timestamp(stderr); - fputs( - " InnoDB: Error; possible reasons:\n" - "InnoDB: 1) Table rename would cause two FOREIGN KEY constraints\n" - "InnoDB: to have the same internal name in case-insensitive comparison.\n" - "InnoDB: 2) table ", stderr); - ut_print_name(stderr, trx, TRUE, new_name); - fputs(" exists in the InnoDB internal data\n" - "InnoDB: dictionary though MySQL is trying rename table ", stderr); - ut_print_name(stderr, trx, TRUE, old_name); - fputs(" to it.\n" - "InnoDB: Have you deleted the .frm file and not used DROP TABLE?\n" - "InnoDB: You can look for further help from\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" - "InnoDB: If table ", stderr); + fputs(" InnoDB: Error; possible reasons:\n" + "InnoDB: 1) Table rename would cause" + " two FOREIGN KEY constraints\n" + "InnoDB: to have the same internal name" + " in case-insensitive comparison.\n" + "InnoDB: 2) table ", stderr); ut_print_name(stderr, trx, TRUE, new_name); - fputs( - " is a temporary table #sql..., then it can be that\n" - "InnoDB: there are still queries running on the table, and it will be\n" - "InnoDB: dropped automatically when the queries end.\n" - "InnoDB: You can drop the orphaned table inside InnoDB by\n" - "InnoDB: creating an InnoDB table with the same name in another\n" - "InnoDB: database and copying the .frm file to the current database.\n" - "InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n" - "InnoDB: succeed.\n", stderr); + fputs(" exists in the InnoDB internal data\n" + "InnoDB: dictionary though MySQL is" + " trying to rename table ", stderr); + ut_print_name(stderr, trx, TRUE, old_name); + fputs(" to it.\n" + "InnoDB: Have you deleted the .frm file" + " and not used DROP TABLE?\n" + "InnoDB: You can look for further help from\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n" + "InnoDB: If table ", stderr); + ut_print_name(stderr, trx, TRUE, new_name); + fputs(" is a temporary table #sql..., then" + " it can be that\n" + "InnoDB: there are still queries running" + " on the table, and it will be\n" + "InnoDB: dropped automatically when" + " the queries end.\n" + "InnoDB: You can drop the orphaned table" + " inside InnoDB by\n" + "InnoDB: creating an InnoDB table with" + " the same name in another\n" + "InnoDB: database and copying the .frm file" + " to the current database.\n" + "InnoDB: Then MySQL thinks the table exists," + " and DROP TABLE will\n" + "InnoDB: succeed.\n", stderr); } trx->error_state = DB_SUCCESS; trx_general_rollback_for_mysql(trx, FALSE, NULL); @@ -3649,15 +3742,15 @@ end: the table is stored in a single-table tablespace */ ibool success = dict_table_rename_in_cache(table, new_name, - !new_is_tmp); + !new_is_tmp); if (!success) { trx->error_state = DB_SUCCESS; trx_general_rollback_for_mysql(trx, FALSE, NULL); trx->error_state = DB_SUCCESS; ut_print_timestamp(stderr); - fputs( -" InnoDB: Error in table rename, cannot rename ", stderr); + fputs(" InnoDB: Error in table rename," + " cannot rename ", stderr); ut_print_name(stderr, trx, TRUE, old_name); fputs(" to ", stderr); ut_print_name(stderr, trx, TRUE, new_name); @@ -3670,33 +3763,37 @@ end: /* We only want to switch off some of the type checking in an ALTER, not in a RENAME. */ - err = dict_load_foreigns(new_name, - old_is_tmp ? trx->check_foreigns : TRUE); + err = dict_load_foreigns + (new_name, old_is_tmp ? trx->check_foreigns : TRUE); if (err != DB_SUCCESS) { ut_print_timestamp(stderr); if (old_is_tmp) { fputs(" InnoDB: Error: in ALTER TABLE ", - stderr); + stderr); ut_print_name(stderr, trx, TRUE, new_name); fputs("\n" - "InnoDB: has or is referenced in foreign key constraints\n" - "InnoDB: which are not compatible with the new table definition.\n", - stderr); + "InnoDB: has or is referenced" + " in foreign key constraints\n" + "InnoDB: which are not compatible" + " with the new table definition.\n", + stderr); } else { - fputs( - " InnoDB: Error: in RENAME TABLE table ", - stderr); + fputs(" InnoDB: Error: in RENAME TABLE" + " table ", + stderr); ut_print_name(stderr, trx, TRUE, new_name); fputs("\n" - "InnoDB: is referenced in foreign key constraints\n" - "InnoDB: which are not compatible with the new table definition.\n", - stderr); + "InnoDB: is referenced in" + " foreign key constraints\n" + "InnoDB: which are not compatible" + " with the new table definition.\n", + stderr); } ut_a(dict_table_rename_in_cache(table, - old_name, FALSE)); + old_name, FALSE)); trx->error_state = DB_SUCCESS; trx_general_rollback_for_mysql(trx, FALSE, NULL); trx->error_state = DB_SUCCESS; @@ -3775,7 +3872,7 @@ loop: cnt = 1000; } if (ret != DB_SUCCESS) { - func_exit: +func_exit: mem_free(buf); mem_heap_free(heap); @@ -3795,7 +3892,7 @@ loop: matched_bytes = 0; offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); cmp = cmp_dtuple_rec_with_match(prev_entry, rec, offsets, &matched_fields, &matched_bytes); @@ -3807,8 +3904,8 @@ loop: 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))) { + if (UNIV_SQL_NULL == dfield_get_len + (dtuple_get_nth_field(prev_entry, i))) { contains_null = TRUE; } @@ -3816,22 +3913,23 @@ loop: if (cmp > 0) { fputs("InnoDB: index records in a wrong order in ", - stderr); - not_ok: + stderr); +not_ok: dict_index_name_print(stderr, - prebuilt->trx, index); + prebuilt->trx, index); fputs("\n" - "InnoDB: prev record ", stderr); + "InnoDB: prev record ", stderr); dtuple_print(stderr, prev_entry); fputs("\n" - "InnoDB: record ", stderr); + "InnoDB: record ", stderr); rec_print_new(stderr, rec, offsets); putc('\n', stderr); is_ok = FALSE; } else if ((index->type & DICT_UNIQUE) && !contains_null - && matched_fields >= - dict_index_get_n_ordering_defined_by_user(index)) { + && matched_fields + >= dict_index_get_n_ordering_defined_by_user + (index)) { fputs("InnoDB: duplicate key in ", stderr); goto not_ok; @@ -3868,14 +3966,18 @@ row_check_table_for_mysql( if (prebuilt->table->ibd_file_missing) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error:\n" -"InnoDB: MySQL is trying to use a table handle but the .ibd file for\n" -"InnoDB: table %s does not exist.\n" -"InnoDB: Have you deleted the .ibd file from the database directory under\n" -"InnoDB: the MySQL datadir, or have you used DISCARD TABLESPACE?\n" -"InnoDB: Look from\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" -"InnoDB: how you can resolve the problem.\n", - prebuilt->table->name); + "InnoDB: MySQL is trying to use a table handle" + " but the .ibd file for\n" + "InnoDB: table %s does not exist.\n" + "InnoDB: Have you deleted the .ibd file" + " from the database directory under\n" + "InnoDB: the MySQL datadir, or have you" + " used DISCARD TABLESPACE?\n" + "InnoDB: Look from\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n" + "InnoDB: how you can resolve the problem.\n", + prebuilt->table->name); return(DB_ERROR); } @@ -3906,7 +4008,7 @@ row_check_table_for_mysql( ret = DB_ERROR; } else { if (!row_scan_and_check_index(prebuilt, - index, &n_rows)) { + index, &n_rows)) { ret = DB_ERROR; } @@ -3915,7 +4017,7 @@ row_check_table_for_mysql( } /* fprintf(stderr, "%lu entries in index %s\n", n_rows, - index->name); */ + index->name); */ if (index == dict_table_get_first_index(table)) { n_rows_in_table = n_rows; @@ -3925,9 +4027,10 @@ row_check_table_for_mysql( fputs("Error: ", stderr); dict_index_name_print(stderr, - prebuilt->trx, index); + prebuilt->trx, index); fprintf(stderr, - " contains %lu entries, should be %lu\n", + " contains %lu entries," + " should be %lu\n", (ulong) n_rows, (ulong) n_rows_in_table); } diff --git a/storage/innobase/row/row0purge.c b/storage/innobase/row/row0purge.c index 1ef24f8e957..1513b18666d 100644 --- a/storage/innobase/row/row0purge.c +++ b/storage/innobase/row/row0purge.c @@ -72,7 +72,7 @@ row_purge_reposition_pcur( } found = row_search_on_row_ref(&(node->pcur), mode, node->table, - node->ref, mtr); + node->ref, mtr); node->found_clust = found; if (found) { @@ -123,9 +123,10 @@ row_purge_remove_clust_if_poss_low( rec = btr_pcur_get_rec(pcur); - if (0 != ut_dulint_cmp(node->roll_ptr, - row_get_rec_roll_ptr(rec, index, rec_get_offsets( - rec, index, offsets_, ULINT_UNDEFINED, &heap)))) { + if (0 != ut_dulint_cmp(node->roll_ptr, row_get_rec_roll_ptr + (rec, index, rec_get_offsets + (rec, index, offsets_, + ULINT_UNDEFINED, &heap)))) { if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -171,7 +172,7 @@ row_purge_remove_clust_if_poss( ibool success; ulint n_tries = 0; -/* fputs("Purge: Removing clustered record\n", stderr); */ + /* fputs("Purge: Removing clustered record\n", stderr); */ success = row_purge_remove_clust_if_poss_low(node, BTR_MODIFY_LEAF); if (success) { @@ -247,9 +248,9 @@ row_purge_remove_sec_if_poss_low( success = row_purge_reposition_pcur(BTR_SEARCH_LEAF, node, mtr_vers); if (success) { - old_has = row_vers_old_has_index_entry(TRUE, - btr_pcur_get_rec(&(node->pcur)), - mtr_vers, index, entry); + old_has = row_vers_old_has_index_entry + (TRUE, btr_pcur_get_rec(&(node->pcur)), + mtr_vers, index, entry); } btr_pcur_commit_specify_mtr(&(node->pcur), mtr_vers); @@ -264,7 +265,7 @@ row_purge_remove_sec_if_poss_low( } else { ut_ad(mode == BTR_MODIFY_TREE); btr_cur_pessimistic_delete(&err, FALSE, btr_cur, - FALSE, &mtr); + FALSE, &mtr); if (err == DB_SUCCESS) { success = TRUE; } else if (err == DB_OUT_OF_FILE_SPACE) { @@ -294,17 +295,17 @@ row_purge_remove_sec_if_poss( ibool success; ulint n_tries = 0; -/* fputs("Purge: Removing secondary record\n", stderr); */ + /* fputs("Purge: Removing secondary record\n", stderr); */ success = row_purge_remove_sec_if_poss_low(node, index, entry, - BTR_MODIFY_LEAF); + BTR_MODIFY_LEAF); if (success) { return; } retry: success = row_purge_remove_sec_if_poss_low(node, index, entry, - BTR_MODIFY_TREE); + BTR_MODIFY_TREE); /* The delete operation may fail if we have little file space left: TODO: easiest to crash the database and restart with more file space */ @@ -389,7 +390,7 @@ row_purge_upd_exist_or_extern( index = node->index; if (row_upd_changes_ord_field_binary(NULL, node->index, - node->update)) { + node->update)) { /* Build the older version of the index entry */ entry = row_build_index_entry(node->row, index, heap); @@ -415,13 +416,13 @@ skip_secondaries: address of the new_val data */ internal_offset = ((byte*)ufield->new_val.data) - - node->undo_rec; + - node->undo_rec; ut_a(internal_offset < UNIV_PAGE_SIZE); trx_undo_decode_roll_ptr(node->roll_ptr, - &is_insert, &rseg_id, - &page_no, &offset); + &is_insert, &rseg_id, + &page_no, &offset); mtr_start(&mtr); /* We have to acquire an X-latch to the clustered @@ -450,13 +451,14 @@ skip_secondaries: #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(buf_frame_align(data_field), - SYNC_TRX_UNDO_PAGE); + SYNC_TRX_UNDO_PAGE); #endif /* UNIV_SYNC_DEBUG */ data_field_len = ufield->new_val.len; btr_free_externally_stored_field(index, data_field, - data_field_len, FALSE, &mtr); + data_field_len, + FALSE, &mtr); mtr_commit(&mtr); } } @@ -493,7 +495,7 @@ row_purge_parse_undo_rec( trx = thr_get_trx(thr); ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &cmpl_info, - updated_extern, &undo_no, &table_id); + updated_extern, &undo_no, &table_id); node->rec_type = type; if (type == TRX_UNDO_UPD_DEL_REC && !(*updated_extern)) { @@ -502,11 +504,11 @@ row_purge_parse_undo_rec( } ptr = trx_undo_update_rec_get_sys_cols(ptr, &trx_id, &roll_ptr, - &info_bits); + &info_bits); node->table = NULL; if (type == TRX_UNDO_UPD_EXIST_REC - && cmpl_info & UPD_NODE_NO_ORD_CHANGE && !(*updated_extern)) { + && cmpl_info & UPD_NODE_NO_ORD_CHANGE && !(*updated_extern)) { /* Purge requires no changes to indexes: we may return */ @@ -553,17 +555,17 @@ row_purge_parse_undo_rec( } ptr = trx_undo_rec_get_row_ref(ptr, clust_index, &(node->ref), - node->heap); + node->heap); ptr = trx_undo_update_rec_get_update(ptr, clust_index, type, trx_id, - roll_ptr, info_bits, trx, - node->heap, &(node->update)); + roll_ptr, info_bits, trx, + node->heap, &(node->update)); /* Read to the partial row the fields that occur in indexes */ if (!cmpl_info & UPD_NODE_NO_ORD_CHANGE) { ptr = trx_undo_rec_get_partial_row(ptr, clust_index, - &(node->row), node->heap); + &(node->row), node->heap); } return(TRUE); @@ -592,8 +594,8 @@ row_purge( trx = thr_get_trx(thr); node->undo_rec = trx_purge_fetch_next_rec(&roll_ptr, - &(node->reservation), - node->heap); + &(node->reservation), + node->heap); if (!node->undo_rec) { /* Purge completed for this query thread */ @@ -608,7 +610,7 @@ row_purge( purge_needed = FALSE; } else { purge_needed = row_purge_parse_undo_rec(node, &updated_extern, - thr); + thr); /* If purge_needed == TRUE, we must also remember to unfreeze data dictionary! */ } @@ -616,14 +618,14 @@ row_purge( if (purge_needed) { node->found_clust = FALSE; - node->index = dict_table_get_next_index( - dict_table_get_first_index(node->table)); + node->index = dict_table_get_next_index + (dict_table_get_first_index(node->table)); if (node->rec_type == TRX_UNDO_DEL_MARK_REC) { row_purge_del_mark(node); } else if (updated_extern - || node->rec_type == TRX_UNDO_UPD_EXIST_REC) { + || node->rec_type == TRX_UNDO_UPD_EXIST_REC) { row_purge_upd_exist_or_extern(node); } diff --git a/storage/innobase/row/row0row.c b/storage/innobase/row/row0row.c index 50ad462f4aa..b945954041e 100644 --- a/storage/innobase/row/row0row.c +++ b/storage/innobase/row/row0row.c @@ -128,8 +128,8 @@ row_build_index_entry( if (index->type & DICT_UNIVERSAL) { dtuple_set_n_fields_cmp(entry, entry_len); } else { - dtuple_set_n_fields_cmp(entry, - dict_index_get_n_unique_in_tree(index)); + dtuple_set_n_fields_cmp + (entry, dict_index_get_n_unique_in_tree(index)); } for (i = 0; i < entry_len; i++) { @@ -144,15 +144,14 @@ row_build_index_entry( /* If a column prefix index, take only the prefix */ if (ind_field->prefix_len > 0 - && dfield_get_len(dfield2) != UNIV_SQL_NULL) { + && dfield_get_len(dfield2) != UNIV_SQL_NULL) { - cur_type = dict_col_get_type( - dict_field_get_col(ind_field)); + cur_type = dict_col_get_type + (dict_field_get_col(ind_field)); - storage_len = dtype_get_at_most_n_mbchars( - cur_type, - ind_field->prefix_len, - dfield_get_len(dfield2), dfield2->data); + storage_len = dtype_get_at_most_n_mbchars + (cur_type, ind_field->prefix_len, + dfield_get_len(dfield2), dfield2->data); dfield_set_len(dfield, storage_len); } @@ -171,10 +170,9 @@ dtuple_t* row_build( /*======*/ /* out, own: row built; see the NOTE below! */ - ulint type, /* in: ROW_COPY_POINTERS, ROW_COPY_DATA, or - ROW_COPY_ALSO_EXTERNALS, - the two last copy also the data fields to - heap as the first only places pointers to + ulint type, /* in: ROW_COPY_POINTERS or ROW_COPY_DATA; + the latter copies also the data fields to + heap while the first only places pointers to data fields on the index page, and thus is more efficient */ dict_index_t* index, /* in: clustered index */ @@ -211,7 +209,7 @@ row_build( if (!offsets) { offsets = rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &tmp_heap); + ULINT_UNDEFINED, &tmp_heap); } else { ut_ad(rec_offs_validate(rec, index, offsets)); } @@ -229,8 +227,8 @@ row_build( row = dtuple_create(heap, row_len); - dtuple_set_info_bits(row, rec_get_info_bits(rec, - dict_table_is_comp(table))); + dtuple_set_info_bits(row, rec_get_info_bits + (rec, dict_table_is_comp(table))); n_fields = rec_offs_n_fields(offsets); @@ -243,16 +241,9 @@ row_build( col = dict_field_get_col(ind_field); dfield = dtuple_get_nth_field(row, - dict_col_get_no(col)); + dict_col_get_no(col)); field = rec_get_nth_field(rec, offsets, i, &len); - if (type == ROW_COPY_ALSO_EXTERNALS - && rec_offs_nth_extern(offsets, i)) { - - field = btr_rec_copy_externally_stored_field( - rec, offsets, i, &len, heap); - } - dfield_set_data(dfield, field, len); } } @@ -305,7 +296,7 @@ row_rec_to_index_entry( ut_ad(rec && heap && index); offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &tmp_heap); + ULINT_UNDEFINED, &tmp_heap); if (type == ROW_COPY_DATA) { /* Take a copy of rec to heap */ @@ -326,7 +317,7 @@ row_rec_to_index_entry( dict_index_copy_types(entry, index, rec_len); dtuple_set_info_bits(entry, - rec_get_info_bits(rec, rec_offs_comp(offsets))); + rec_get_info_bits(rec, rec_offs_comp(offsets))); for (i = 0; i < rec_len; i++) { @@ -387,7 +378,7 @@ row_build_row_ref( ut_ad(index && rec && heap); offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &tmp_heap); + ULINT_UNDEFINED, &tmp_heap); if (type == ROW_COPY_DATA) { /* Take a copy of rec to heap */ @@ -425,16 +416,17 @@ row_build_row_ref( column, or the full column, and we must adjust the length accordingly. */ - clust_col_prefix_len = - dict_index_get_nth_field(clust_index, i)->prefix_len; + clust_col_prefix_len = dict_index_get_nth_field + (clust_index, i)->prefix_len; if (clust_col_prefix_len > 0) { if (len != UNIV_SQL_NULL) { dfield_set_len(dfield, - dtype_get_at_most_n_mbchars( - dfield_get_type(dfield), - clust_col_prefix_len, len, (char*) field)); + dtype_get_at_most_n_mbchars + (dfield_get_type(dfield), + clust_col_prefix_len, len, + (char*) field)); } } } @@ -482,7 +474,7 @@ row_build_row_ref_in_tuple( if (UNIV_UNLIKELY(!index->table)) { fputs("InnoDB: table ", stderr); - notfound: +notfound: ut_print_name(stderr, trx, TRUE, index->table_name); fputs(" for index ", stderr); ut_print_name(stderr, trx, FALSE, index->name); @@ -521,16 +513,17 @@ row_build_row_ref_in_tuple( column, or the full column, and we must adjust the length accordingly. */ - clust_col_prefix_len = - dict_index_get_nth_field(clust_index, i)->prefix_len; + clust_col_prefix_len = dict_index_get_nth_field + (clust_index, i)->prefix_len; if (clust_col_prefix_len > 0) { if (len != UNIV_SQL_NULL) { dfield_set_len(dfield, - dtype_get_at_most_n_mbchars( - dfield_get_type(dfield), - clust_col_prefix_len, len, (char*) field)); + dtype_get_at_most_n_mbchars + (dfield_get_type(dfield), + clust_col_prefix_len, len, + (char*) field)); } } } @@ -585,15 +578,14 @@ row_build_row_ref_from_row( dfield_copy(dfield, dfield2); if (field->prefix_len > 0 - && dfield->len != UNIV_SQL_NULL) { + && dfield->len != UNIV_SQL_NULL) { - cur_type = dict_col_get_type( - dict_field_get_col(field)); + cur_type = dict_col_get_type + (dict_field_get_col(field)); - dfield->len = dtype_get_at_most_n_mbchars( - cur_type, - field->prefix_len, - dfield->len, dfield->data); + dfield->len = dtype_get_at_most_n_mbchars + (cur_type, field->prefix_len, + dfield->len, dfield->data); } } diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index 251ee95886f..06aeca509d3 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -92,9 +92,9 @@ row_sel_sec_rec_is_for_clust_rec( *sec_offsets_ = (sizeof sec_offsets_) / sizeof *sec_offsets_; clust_offs = rec_get_offsets(clust_rec, clust_index, clust_offs, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); sec_offs = rec_get_offsets(sec_rec, sec_index, sec_offs, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); n = dict_index_get_n_ordering_defined_by_user(sec_index); @@ -108,20 +108,19 @@ row_sel_sec_rec_is_for_clust_rec( sec_field = rec_get_nth_field(sec_rec, sec_offs, i, &sec_len); if (ifield->prefix_len > 0 - && clust_len != UNIV_SQL_NULL) { + && clust_len != UNIV_SQL_NULL) { - cur_type = dict_col_get_type( - dict_field_get_col(ifield)); + cur_type = dict_col_get_type + (dict_field_get_col(ifield)); - clust_len = dtype_get_at_most_n_mbchars( - cur_type, - ifield->prefix_len, - clust_len, (char*) clust_field); + clust_len = dtype_get_at_most_n_mbchars + (cur_type, ifield->prefix_len, + clust_len, (char*) clust_field); } if (0 != cmp_data_data(dict_col_get_type(col), - clust_field, clust_len, - sec_field, sec_len)) { + clust_field, clust_len, + sec_field, sec_len)) { is_equal = FALSE; goto func_exit; } @@ -313,29 +312,29 @@ row_sel_fetch_columns( if (field_no != ULINT_UNDEFINED) { if (UNIV_UNLIKELY(rec_offs_nth_extern(offsets, - field_no))) { + field_no))) { /* Copy an externally stored field to the temporary heap */ heap = mem_heap_create(1); - data = btr_rec_copy_externally_stored_field( - rec, offsets, field_no, &len, heap); + data = btr_rec_copy_externally_stored_field + (rec, offsets, field_no, &len, heap); ut_a(len != UNIV_SQL_NULL); needs_copy = TRUE; } else { data = rec_get_nth_field(rec, offsets, - field_no, &len); + field_no, &len); needs_copy = column->copy_val; } if (needs_copy) { eval_node_copy_and_alloc_val(column, data, - len); + len); } else { val = que_node_get_val(column); dfield_set_data(val, data, len); @@ -364,7 +363,7 @@ sel_col_prefetch_buf_alloc( ut_ad(que_node_get_type(column) == QUE_NODE_SYMBOL); column->prefetch_buf = mem_alloc(SEL_MAX_N_PREFETCH - * sizeof(sel_buf_t)); + * sizeof(sel_buf_t)); for (i = 0; i < SEL_MAX_N_PREFETCH; i++) { sel_buf = column->prefetch_buf + i; @@ -558,9 +557,9 @@ row_sel_build_prev_vers( plan->old_vers_heap = mem_heap_create(512); } - err = row_vers_build_for_consistent_read(rec, mtr, plan->index, - offsets, read_view, offset_heap, - plan->old_vers_heap, old_vers); + err = row_vers_build_for_consistent_read + (rec, mtr, plan->index, offsets, read_view, offset_heap, + plan->old_vers_heap, old_vers); return(err); } @@ -593,9 +592,9 @@ row_sel_build_committed_vers_for_mysql( prebuilt->old_vers_heap = mem_heap_create(200); } - err = row_vers_build_for_semi_consistent_read(rec, mtr, clust_index, - offsets, offset_heap, - prebuilt->old_vers_heap, old_vers); + err = row_vers_build_for_semi_consistent_read + (rec, mtr, clust_index, offsets, offset_heap, + prebuilt->old_vers_heap, old_vers); return(err); } @@ -697,16 +696,16 @@ row_sel_get_clust_rec( *out_rec = NULL; offsets = rec_get_offsets(rec, - btr_pcur_get_btr_cur(&plan->pcur)->index, - offsets, ULINT_UNDEFINED, &heap); + btr_pcur_get_btr_cur(&plan->pcur)->index, + offsets, ULINT_UNDEFINED, &heap); row_build_row_ref_fast(plan->clust_ref, plan->clust_map, rec, offsets); index = dict_table_get_first_index(plan->table); btr_pcur_open_with_no_init(index, plan->clust_ref, PAGE_CUR_LE, - node->latch_mode, &(plan->clust_pcur), - 0, mtr); + node->latch_mode, &(plan->clust_pcur), + 0, mtr); clust_rec = btr_pcur_get_rec(&(plan->clust_pcur)); @@ -714,11 +713,11 @@ row_sel_get_clust_rec( low_match value the real match to the search tuple */ if (!page_rec_is_user_rec(clust_rec) - || btr_pcur_get_low_match(&(plan->clust_pcur)) - < dict_index_get_n_unique(index)) { + || btr_pcur_get_low_match(&(plan->clust_pcur)) + < dict_index_get_n_unique(index)) { ut_a(rec_get_deleted_flag(rec, - dict_table_is_comp(plan->table))); + dict_table_is_comp(plan->table))); ut_a(node->read_view); /* In a rare case it is possible that no clust rec is found @@ -734,7 +733,7 @@ row_sel_get_clust_rec( } offsets = rec_get_offsets(clust_rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (!node->read_view) { /* Try to place a lock on the index record */ @@ -749,15 +748,15 @@ row_sel_get_clust_rec( trx = thr_get_trx(thr); if (srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) { + || trx->isolation_level == TRX_ISO_READ_COMMITTED) { lock_type = LOCK_REC_NOT_GAP; } else { lock_type = LOCK_ORDINARY; } - err = lock_clust_rec_read_check_and_lock(0, - clust_rec, index, offsets, - node->row_lock_mode, lock_type, thr); + err = lock_clust_rec_read_check_and_lock + (0, clust_rec, index, offsets, + node->row_lock_mode, lock_type, thr); if (err != DB_SUCCESS) { @@ -770,11 +769,11 @@ row_sel_get_clust_rec( old_vers = NULL; if (!lock_clust_rec_cons_read_sees(clust_rec, index, offsets, - node->read_view)) { + node->read_view)) { err = row_sel_build_prev_vers(node->read_view, plan, - clust_rec, &offsets, &heap, - &old_vers, mtr); + clust_rec, &offsets, + &heap, &old_vers, mtr); if (err != DB_SUCCESS) { goto err_exit; @@ -800,10 +799,11 @@ row_sel_get_clust_rec( visit through secondary index records that would not really exist in our snapshot. */ - if ((old_vers || rec_get_deleted_flag(rec, - dict_table_is_comp(plan->table))) - && !row_sel_sec_rec_is_for_clust_rec(rec, plan->index, - clust_rec, index)) { + if ((old_vers + || rec_get_deleted_flag(rec, dict_table_is_comp + (plan->table))) + && !row_sel_sec_rec_is_for_clust_rec(rec, plan->index, + clust_rec, index)) { goto func_exit; } } @@ -811,7 +811,7 @@ row_sel_get_clust_rec( /* Fetch the columns needed in test conditions */ row_sel_fetch_columns(index, clust_rec, offsets, - UT_LIST_GET_FIRST(plan->columns)); + UT_LIST_GET_FIRST(plan->columns)); *out_rec = clust_rec; func_exit: err = DB_SUCCESS; @@ -833,7 +833,8 @@ sel_set_rec_lock( dict_index_t* index, /* in: index */ const ulint* offsets,/* in: rec_get_offsets(rec, index) */ ulint mode, /* in: lock mode */ - ulint type, /* in: LOCK_ORDINARY, LOCK_GAP, or LOC_REC_NOT_GAP */ + ulint type, /* in: LOCK_ORDINARY, LOCK_GAP, or + LOC_REC_NOT_GAP */ que_thr_t* thr) /* in: query thread */ { trx_t* trx; @@ -849,11 +850,11 @@ sel_set_rec_lock( } if (index->type & DICT_CLUSTERED) { - err = lock_clust_rec_read_check_and_lock(0, - rec, index, offsets, mode, type, thr); + err = lock_clust_rec_read_check_and_lock + (0, rec, index, offsets, mode, type, thr); } else { - err = lock_sec_rec_read_check_and_lock(0, - rec, index, offsets, mode, type, thr); + err = lock_sec_rec_read_check_and_lock + (0, rec, index, offsets, mode, type, thr); } return(err); @@ -912,20 +913,20 @@ row_sel_open_pcur( exp = plan->tuple_exps[i]; dfield_copy_data(dtuple_get_nth_field(plan->tuple, i), - que_node_get_val(exp)); + que_node_get_val(exp)); } /* Open pcur to the index */ btr_pcur_open_with_no_init(index, plan->tuple, plan->mode, - node->latch_mode, &(plan->pcur), - has_search_latch, mtr); + node->latch_mode, &(plan->pcur), + has_search_latch, mtr); } else { /* Open the cursor to the start or the end of the index (FALSE: no init) */ btr_pcur_open_at_index_side(plan->asc, index, node->latch_mode, - &(plan->pcur), FALSE, mtr); + &(plan->pcur), FALSE, mtr); } ut_ad(plan->n_rows_prefetched == 0); @@ -958,7 +959,7 @@ row_sel_restore_pcur_pos( relative_position = btr_pcur_get_rel_pos(&(plan->pcur)); equal_position = btr_pcur_restore_position(node->latch_mode, - &(plan->pcur), mtr); + &(plan->pcur), mtr); /* If the cursor is traveling upwards, and relative_position is @@ -988,7 +989,7 @@ row_sel_restore_pcur_pos( } ut_ad(relative_position == BTR_PCUR_AFTER - || relative_position == BTR_PCUR_AFTER_LAST_IN_TREE); + || relative_position == BTR_PCUR_AFTER_LAST_IN_TREE); return(FALSE); } @@ -1011,7 +1012,7 @@ row_sel_restore_pcur_pos( record, else there is no need to move the cursor. */ if (relative_position == BTR_PCUR_BEFORE - || relative_position == BTR_PCUR_BEFORE_FIRST_IN_TREE) { + || relative_position == BTR_PCUR_BEFORE_FIRST_IN_TREE) { return(FALSE); } @@ -1027,7 +1028,7 @@ row_sel_restore_pcur_pos( } ut_ad(relative_position == BTR_PCUR_AFTER - || relative_position == BTR_PCUR_AFTER_LAST_IN_TREE); + || relative_position == BTR_PCUR_AFTER_LAST_IN_TREE); return(TRUE); } @@ -1103,7 +1104,7 @@ row_sel_try_search_shortcut( if (index->type & DICT_CLUSTERED) { if (!lock_clust_rec_cons_read_sees(rec, index, offsets, - node->read_view)) { + node->read_view)) { ret = SEL_RETRY; goto func_exit; } @@ -1116,7 +1117,7 @@ row_sel_try_search_shortcut( /* Test deleted flag. Fetch the columns needed in test conditions. */ row_sel_fetch_columns(index, rec, offsets, - UT_LIST_GET_FIRST(plan->columns)); + UT_LIST_GET_FIRST(plan->columns)); if (rec_get_deleted_flag(rec, dict_table_is_comp(plan->table))) { @@ -1163,29 +1164,29 @@ row_sel( ibool search_latch_locked; ibool consistent_read; - /* The following flag becomes TRUE when we are doing a - consistent read from a non-clustered index and we must look - at the clustered index to find out the previous delete mark - state of the non-clustered record: */ + /* The following flag becomes TRUE when we are doing a + consistent read from a non-clustered index and we must look + at the clustered index to find out the previous delete mark + state of the non-clustered record: */ ibool cons_read_requires_clust_rec = FALSE; ulint cost_counter = 0; ibool cursor_just_opened; ibool must_go_to_next; ibool leaf_contains_updates = FALSE; - /* TRUE if select_will_do_update is - TRUE and the current clustered index - leaf page has been updated during - the current mtr: mtr must be committed - at the same time as the leaf x-latch - is released */ + /* TRUE if select_will_do_update is + TRUE and the current clustered index + leaf page has been updated during + the current mtr: mtr must be committed + at the same time as the leaf x-latch + is released */ ibool mtr_has_extra_clust_latch = FALSE; - /* TRUE if the search was made using - a non-clustered index, and we had to - access the clustered record: now &mtr - contains a clustered index latch, and - &mtr must be committed before we move - to the next non-clustered record */ + /* TRUE if the search was made using + a non-clustered index, and we had to + access the clustered record: now &mtr + contains a clustered index latch, and + &mtr must be committed before we move + to the next non-clustered record */ ulint found_flag; ulint err; mem_heap_t* heap = NULL; @@ -1212,7 +1213,7 @@ row_sel( table_loop: /* TABLE LOOP - ---------- + ---------- This is the outer major loop in calculating a join. We come here when node->fetch_table changes, and after adding a row to aggregate totals and, of course, when this function is called. */ @@ -1244,8 +1245,8 @@ table_loop: mtr_start(&mtr); if (consistent_read && plan->unique_search && !plan->pcur_is_open - && !plan->must_get_clust - && (plan->table->max_row_size < BIG_ROW_SIZE)) { + && !plan->must_get_clust + && (plan->table->max_row_size < BIG_ROW_SIZE)) { if (!search_latch_locked) { rw_lock_s_lock(&btr_search_latch); @@ -1315,7 +1316,7 @@ table_loop: rec_loop: /* RECORD LOOP - ----------- + ----------- In this loop we use pcur and try to fetch a qualifying row, and also fill the prefetch buffer for this table if n_rows_fetched has exceeded a threshold. While we are inside this loop, the following @@ -1333,7 +1334,7 @@ rec_loop: /* PHASE 1: Set a lock if specified */ if (!node->asc && cursor_just_opened - && !page_rec_is_supremum(rec)) { + && !page_rec_is_supremum(rec)) { /* When we open a cursor for a descending search, we must set a next-key lock on the successor record: otherwise it would @@ -1355,10 +1356,11 @@ rec_loop: trx = thr_get_trx(thr); offsets = rec_get_offsets(next_rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) { + || trx->isolation_level + == TRX_ISO_READ_COMMITTED) { if (page_rec_is_supremum(next_rec)) { @@ -1371,7 +1373,8 @@ rec_loop: } err = sel_set_rec_lock(next_rec, index, offsets, - node->row_lock_mode, lock_type, thr); + node->row_lock_mode, + lock_type, thr); if (err != DB_SUCCESS) { /* Note that in this case we will store in pcur @@ -1408,12 +1411,12 @@ skip_lock: trx_t* trx; offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); trx = thr_get_trx(thr); if (srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) { + || trx->isolation_level == TRX_ISO_READ_COMMITTED) { if (page_rec_is_supremum(rec)) { @@ -1426,7 +1429,7 @@ skip_lock: } err = sel_set_rec_lock(rec, index, offsets, - node->row_lock_mode, lock_type, thr); + node->row_lock_mode, lock_type, thr); if (err != DB_SUCCESS) { @@ -1468,7 +1471,7 @@ skip_lock: tuple */ if (btr_pcur_get_up_match(&(plan->pcur)) - < plan->n_exact_match) { + < plan->n_exact_match) { goto table_exhausted; } @@ -1491,24 +1494,25 @@ skip_lock: if (index->type & DICT_CLUSTERED) { if (!lock_clust_rec_cons_read_sees(rec, index, offsets, - node->read_view)) { + node->read_view)) { err = row_sel_build_prev_vers(node->read_view, - plan, rec, - &offsets, &heap, - &old_vers, &mtr); + plan, rec, + &offsets, &heap, + &old_vers, &mtr); if (err != DB_SUCCESS) { goto lock_wait_or_error; } if (old_vers == NULL) { - offsets = rec_get_offsets( - rec, index, offsets, - ULINT_UNDEFINED, &heap); - row_sel_fetch_columns(index, rec, - offsets, - UT_LIST_GET_FIRST(plan->columns)); + offsets = rec_get_offsets + (rec, index, offsets, + ULINT_UNDEFINED, &heap); + row_sel_fetch_columns + (index, rec, offsets, + UT_LIST_GET_FIRST + (plan->columns)); if (!row_sel_test_end_conds(plan)) { @@ -1531,7 +1535,7 @@ skip_lock: /* Fetch the columns needed in test conditions */ row_sel_fetch_columns(index, rec, offsets, - UT_LIST_GET_FIRST(plan->columns)); + UT_LIST_GET_FIRST(plan->columns)); /* Test the selection end conditions: these can only contain columns which already are found in the index, even though the index might be @@ -1547,7 +1551,7 @@ skip_lock: } if (rec_get_deleted_flag(rec, dict_table_is_comp(plan->table)) - && !cons_read_requires_clust_rec) { + && !cons_read_requires_clust_rec) { /* The record is delete marked: we can skip it if this is not a consistent read which might see an earlier version @@ -1570,7 +1574,7 @@ skip_lock: clustered index record */ err = row_sel_get_clust_rec(node, plan, rec, thr, &clust_rec, - &mtr); + &mtr); mtr_has_extra_clust_latch = TRUE; if (err != DB_SUCCESS) { @@ -1591,7 +1595,7 @@ skip_lock: } if (rec_get_deleted_flag(clust_rec, - dict_table_is_comp(plan->table))) { + dict_table_is_comp(plan->table))) { /* The record is delete marked: we can skip it */ @@ -1646,8 +1650,8 @@ skip_lock: } if ((plan->n_rows_fetched <= SEL_PREFETCH_LIMIT) - || plan->unique_search || plan->no_prefetch - || (plan->table->max_row_size >= BIG_ROW_SIZE)) { + || plan->unique_search || plan->no_prefetch + || (plan->table->max_row_size >= BIG_ROW_SIZE)) { /* No prefetch in operation: go to the next table */ @@ -1679,7 +1683,7 @@ next_rec: } if (leaf_contains_updates - && btr_pcur_is_after_last_on_page(&(plan->pcur), &mtr)) { + && btr_pcur_is_after_last_on_page(&(plan->pcur), &mtr)) { /* We must commit &mtr if we are moving to a different page, because we have done updates to the x-latched leaf page, and @@ -1705,7 +1709,7 @@ next_rec: cursor_just_opened = FALSE; /* END OF RECORD LOOP - ------------------ */ + ------------------ */ goto rec_loop; next_table: @@ -1860,7 +1864,7 @@ lock_wait_or_error: /* See the note at stop_for_a_while: the same holds for this case */ ut_ad(!btr_pcur_is_before_first_on_page(&(plan->pcur), &mtr) - || !node->asc); + || !node->asc); ut_ad(!search_latch_locked); plan->stored_cursor_rec_processed = FALSE; @@ -1918,8 +1922,8 @@ row_sel_step( if (node->consistent_read) { /* Assign a read view for the query */ - node->read_view = trx_assign_read_view( - thr_get_trx(thr)); + node->read_view = trx_assign_read_view + (thr_get_trx(thr)); } else { if (node->set_x_locks) { i_lock_mode = LOCK_IX; @@ -1931,7 +1935,7 @@ row_sel_step( while (table_node) { err = lock_table(0, table_node->table, - i_lock_mode, thr); + i_lock_mode, thr); if (err != DB_SUCCESS) { thr_get_trx(thr)->error_state = err; @@ -1947,8 +1951,8 @@ row_sel_step( fetches (currently, we copy them also for non-explicit cursors) */ - if (node->explicit_cursor && - UT_LIST_GET_FIRST(node->copy_variables)) { + if (node->explicit_cursor + && UT_LIST_GET_FIRST(node->copy_variables)) { row_sel_copy_input_variable_vals(node); } @@ -2004,14 +2008,14 @@ fetch_step( if (node->into_list) { sel_assign_into_var_values(node->into_list, - sel_node); + sel_node); } else { - void* ret = (*node->func->func)(sel_node, - node->func->arg); + void* ret = (*node->func->func) + (sel_node, node->func->arg); if (!ret) { - sel_node->state = - SEL_NODE_NO_MORE_ROWS; + sel_node->state + = SEL_NODE_NO_MORE_ROWS; } } } @@ -2073,7 +2077,7 @@ row_fetch_print( if (dfield_get_len(dfield) != UNIV_SQL_NULL) { ut_print_buf(stderr, dfield_get_data(dfield), - dfield_get_len(dfield)); + dfield_get_len(dfield)); } else { fprintf(stderr, " ;"); } @@ -2246,7 +2250,7 @@ row_sel_convert_mysql_key_to_innobase( while (key_ptr < key_end) { ut_a(dict_col_get_type(field->col)->mtype - == dfield_get_type(dfield)->mtype); + == dfield_get_type(dfield)->mtype); data_offset = 0; is_null = FALSE; @@ -2284,7 +2288,7 @@ row_sel_convert_mysql_key_to_innobase( from the start. */ data_len = key_ptr[data_offset] - + 256 * key_ptr[data_offset + 1]; + + 256 * key_ptr[data_offset + 1]; data_field_len = data_offset + 2 + field->prefix_len; data_offset += 2; @@ -2312,8 +2316,8 @@ row_sel_convert_mysql_key_to_innobase( } if (dtype_get_mysql_type(dfield_get_type(dfield)) - == DATA_MYSQL_TRUE_VARCHAR - && dfield_get_type(dfield)->mtype != DATA_INT) { + == DATA_MYSQL_TRUE_VARCHAR + && dfield_get_type(dfield)->mtype != DATA_INT) { /* In a MySQL key value format, a true VARCHAR is always preceded by 2 bytes of a length field. dfield_get_type(dfield)->len returns the maximum @@ -2330,13 +2334,11 @@ row_sel_convert_mysql_key_to_innobase( /* Storing may use at most data_len bytes of buf */ if (!is_null) { - row_mysql_store_col_in_innobase_format( - dfield, - buf, - FALSE, /* MySQL key value format col */ - key_ptr + data_offset, - data_len, - dict_table_is_comp(index->table)); + row_mysql_store_col_in_innobase_format + (dfield, buf, + FALSE, /* MySQL key value format col */ + key_ptr + data_offset, data_len, + dict_table_is_comp(index->table)); buf += data_len; } @@ -2354,15 +2356,16 @@ row_sel_convert_mysql_key_to_innobase( ut_print_timestamp(stderr); - fputs( - " InnoDB: Warning: using a partial-field key prefix in search.\n" - "InnoDB: ", stderr); + fputs(" InnoDB: Warning: using a partial-field" + " key prefix in search.\n" + "InnoDB: ", stderr); dict_index_name_print(stderr, trx, index); fprintf(stderr, ". Last data field length %lu bytes,\n" - "InnoDB: key ptr now exceeds key end by %lu bytes.\n" - "InnoDB: Key value in the MySQL format:\n", - (ulong) data_field_len, - (ulong) (key_ptr - key_end)); + "InnoDB: key ptr now exceeds" + " key end by %lu bytes.\n" + "InnoDB: Key value in the MySQL format:\n", + (ulong) data_field_len, + (ulong) (key_ptr - key_end)); fflush(stderr); ut_print_buf(stderr, original_key_ptr, key_len); fprintf(stderr, "\n"); @@ -2402,17 +2405,19 @@ row_sel_store_row_id_to_prebuilt( ut_ad(rec_offs_validate(index_rec, index, offsets)); - data = rec_get_nth_field(index_rec, offsets, - dict_index_get_sys_col_pos(index, DATA_ROW_ID), &len); + data = rec_get_nth_field + (index_rec, offsets, + dict_index_get_sys_col_pos(index, DATA_ROW_ID), &len); if (len != DATA_ROW_ID_LEN) { fprintf(stderr, -"InnoDB: Error: Row id field is wrong length %lu in ", (ulong) len); + "InnoDB: Error: Row id field is" + " wrong length %lu in ", (ulong) len); dict_index_name_print(stderr, prebuilt->trx, index); fprintf(stderr, "\n" -"InnoDB: Field number %lu, record:\n", + "InnoDB: Field number %lu, record:\n", (ulong) dict_index_get_sys_col_pos(index, - DATA_ROW_ID)); + DATA_ROW_ID)); rec_print_new(stderr, index_rec, offsets); putc('\n', stderr); ut_error; @@ -2475,8 +2480,8 @@ row_sel_field_store_in_mysql_format( length of the data to the first byte or the first two bytes of dest. */ - dest = row_mysql_store_true_var_len(dest, len, - templ->mysql_length_bytes); + dest = row_mysql_store_true_var_len + (dest, len, templ->mysql_length_bytes); } /* Copy the actual data */ @@ -2523,7 +2528,7 @@ row_sel_field_store_in_mysql_format( already copied to the buffer in row_sel_store_mysql_rec */ row_mysql_store_blob_ref(dest, templ->mysql_col_len, data, - len); + len); } else if (templ->type == DATA_MYSQL) { memcpy(dest, data, len); @@ -2531,11 +2536,11 @@ row_sel_field_store_in_mysql_format( ut_ad(templ->mbmaxlen >= templ->mbminlen); ut_ad(templ->mbmaxlen > templ->mbminlen - || templ->mysql_col_len == len); + || templ->mysql_col_len == len); /* The following assertion would fail for old tables containing UTF-8 ENUM columns due to Bug #9526. */ ut_ad(!templ->mbmaxlen - || !(templ->mysql_col_len % templ->mbmaxlen)); + || !(templ->mysql_col_len % templ->mbmaxlen)); ut_ad(len * templ->mbmaxlen >= templ->mysql_col_len); if (templ->mbminlen != templ->mbmaxlen) { @@ -2547,12 +2552,12 @@ row_sel_field_store_in_mysql_format( } } else { ut_ad(templ->type == DATA_CHAR - || templ->type == DATA_FIXBINARY - /*|| templ->type == DATA_SYS_CHILD - || templ->type == DATA_SYS*/ - || templ->type == DATA_FLOAT - || templ->type == DATA_DOUBLE - || templ->type == DATA_DECIMAL); + || templ->type == DATA_FIXBINARY + /*|| templ->type == DATA_SYS_CHILD + || templ->type == DATA_SYS*/ + || templ->type == DATA_FLOAT + || templ->type == DATA_DOUBLE + || templ->type == DATA_DECIMAL); ut_ad(templ->mysql_col_len == len); memcpy(dest, data, len); @@ -2600,7 +2605,7 @@ row_sel_store_mysql_rec( templ = prebuilt->mysql_template + i; if (UNIV_UNLIKELY(rec_offs_nth_extern(offsets, - templ->rec_field_no))) { + templ->rec_field_no))) { /* Copy an externally stored field to the temporary heap */ @@ -2609,14 +2614,14 @@ row_sel_store_mysql_rec( if (UNIV_UNLIKELY(templ->type == DATA_BLOB)) { if (prebuilt->blob_heap == NULL) { - prebuilt->blob_heap = - mem_heap_create(UNIV_PAGE_SIZE); + prebuilt->blob_heap = mem_heap_create + (UNIV_PAGE_SIZE); } heap = prebuilt->blob_heap; } else { - extern_field_heap = - mem_heap_create(UNIV_PAGE_SIZE); + extern_field_heap + = mem_heap_create(UNIV_PAGE_SIZE); heap = extern_field_heap; } @@ -2625,22 +2630,22 @@ row_sel_store_mysql_rec( already run out of memory in the next call, which causes an assert */ - data = btr_rec_copy_externally_stored_field(rec, - offsets, templ->rec_field_no, &len, - heap); + data = btr_rec_copy_externally_stored_field + (rec, offsets, templ->rec_field_no, + &len, heap); ut_a(len != UNIV_SQL_NULL); } else { /* Field is stored in the row. */ data = rec_get_nth_field(rec, offsets, - templ->rec_field_no, &len); + templ->rec_field_no, &len); } if (len != UNIV_SQL_NULL) { - row_sel_field_store_in_mysql_format( - mysql_rec + templ->mysql_col_offset, - templ, data, len); + row_sel_field_store_in_mysql_format + (mysql_rec + templ->mysql_col_offset, + templ, data, len); /* Cleanup */ if (extern_field_heap) { @@ -2651,8 +2656,8 @@ row_sel_store_mysql_rec( if (templ->mysql_null_bit_mask) { /* It is a nullable column with a non-NULL value */ - mysql_rec[templ->mysql_null_byte_offset] &= - ~(byte) (templ->mysql_null_bit_mask); + mysql_rec[templ->mysql_null_byte_offset] + &= ~(byte) templ->mysql_null_bit_mask; } } else { /* MySQL seems to assume the field for an SQL NULL @@ -2662,14 +2667,14 @@ row_sel_store_mysql_rec( and DISTINCT could treat NULL values inequal. */ int pad_char; - mysql_rec[templ->mysql_null_byte_offset] |= - (byte) (templ->mysql_null_bit_mask); + mysql_rec[templ->mysql_null_byte_offset] + |= (byte) templ->mysql_null_bit_mask; switch (templ->type) { case DATA_VARCHAR: case DATA_BINARY: case DATA_VARMYSQL: if (templ->mysql_type - == DATA_MYSQL_TRUE_VARCHAR) { + == DATA_MYSQL_TRUE_VARCHAR) { /* This is a >= 5.0.3 type true VARCHAR. Zero the field. */ pad_char = 0x00; @@ -2706,7 +2711,7 @@ row_sel_store_mysql_rec( ut_ad(!pad_char || templ->mbminlen == 1); memset(mysql_rec + templ->mysql_col_offset, - pad_char, templ->mysql_col_len); + pad_char, templ->mysql_col_len); } } @@ -2742,9 +2747,9 @@ row_sel_build_prev_vers_for_mysql( prebuilt->old_vers_heap = mem_heap_create(200); } - err = row_vers_build_for_consistent_read(rec, mtr, clust_index, - offsets, read_view, offset_heap, - prebuilt->old_vers_heap, old_vers); + err = row_vers_build_for_consistent_read + (rec, mtr, clust_index, offsets, read_view, offset_heap, + prebuilt->old_vers_heap, old_vers); return(err); } @@ -2790,8 +2795,8 @@ row_sel_get_clust_rec_for_mysql( clust_index = dict_table_get_first_index(sec_index->table); btr_pcur_open_with_no_init(clust_index, prebuilt->clust_ref, - PAGE_CUR_LE, BTR_SEARCH_LEAF, - prebuilt->clust_pcur, 0, mtr); + PAGE_CUR_LE, BTR_SEARCH_LEAF, + prebuilt->clust_pcur, 0, mtr); clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur); @@ -2801,8 +2806,8 @@ row_sel_get_clust_rec_for_mysql( low_match value the real match to the search tuple */ if (!page_rec_is_user_rec(clust_rec) - || btr_pcur_get_low_match(prebuilt->clust_pcur) - < dict_index_get_n_unique(clust_index)) { + || btr_pcur_get_low_match(prebuilt->clust_pcur) + < dict_index_get_n_unique(clust_index)) { /* In a rare case it is possible that no clust rec is found for a delete-marked secondary index record: if in row0umod.c @@ -2814,24 +2819,25 @@ row_sel_get_clust_rec_for_mysql( trx. */ if (!rec_get_deleted_flag(rec, - dict_table_is_comp(sec_index->table)) - || prebuilt->select_lock_type != LOCK_NONE) { + dict_table_is_comp(sec_index->table)) + || prebuilt->select_lock_type != LOCK_NONE) { ut_print_timestamp(stderr); fputs(" InnoDB: error clustered record" - " for sec rec not found\n" - "InnoDB: ", stderr); + " for sec rec not found\n" + "InnoDB: ", stderr); dict_index_name_print(stderr, trx, sec_index); fputs("\n" - "InnoDB: sec index record ", stderr); + "InnoDB: sec index record ", stderr); rec_print(stderr, rec, sec_index); fputs("\n" - "InnoDB: clust index record ", stderr); + "InnoDB: clust index record ", stderr); rec_print(stderr, clust_rec, clust_index); putc('\n', stderr); trx_print(stderr, trx, 600); fputs("\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n", stderr); } clust_rec = NULL; @@ -2840,17 +2846,16 @@ row_sel_get_clust_rec_for_mysql( } *offsets = rec_get_offsets(clust_rec, clust_index, *offsets, - ULINT_UNDEFINED, offset_heap); + ULINT_UNDEFINED, offset_heap); if (prebuilt->select_lock_type != LOCK_NONE) { /* Try to place a lock on the index record; we are searching the clust rec with a unique condition, hence we set a LOCK_REC_NOT_GAP type lock */ - err = lock_clust_rec_read_check_and_lock(0, clust_rec, - clust_index, *offsets, - prebuilt->select_lock_type, - LOCK_REC_NOT_GAP, thr); + err = lock_clust_rec_read_check_and_lock + (0, clust_rec, clust_index, *offsets, + prebuilt->select_lock_type, LOCK_REC_NOT_GAP, thr); if (err != DB_SUCCESS) { goto err_exit; @@ -2865,16 +2870,15 @@ row_sel_get_clust_rec_for_mysql( then we never look for an earlier version */ if (trx->isolation_level > TRX_ISO_READ_UNCOMMITTED - && !lock_clust_rec_cons_read_sees(clust_rec, - clust_index, *offsets, trx->read_view)) { + && !lock_clust_rec_cons_read_sees + (clust_rec, clust_index, *offsets, trx->read_view)) { /* The following call returns 'offsets' associated with 'old_vers' */ - err = row_sel_build_prev_vers_for_mysql( - trx->read_view, clust_index, - prebuilt, clust_rec, - offsets, offset_heap, - &old_vers, mtr); + err = row_sel_build_prev_vers_for_mysql + (trx->read_view, clust_index, + prebuilt, clust_rec, offsets, offset_heap, + &old_vers, mtr); if (err != DB_SUCCESS) { @@ -2897,17 +2901,16 @@ row_sel_get_clust_rec_for_mysql( visit through secondary index records that would not really exist in our snapshot. */ - if (clust_rec && (old_vers - || rec_get_deleted_flag(rec, - dict_table_is_comp(sec_index->table))) - && !row_sel_sec_rec_is_for_clust_rec(rec, sec_index, - clust_rec, clust_index)) { + if (clust_rec && (old_vers || rec_get_deleted_flag + (rec, dict_table_is_comp(sec_index->table))) + && !row_sel_sec_rec_is_for_clust_rec + (rec, sec_index, clust_rec, clust_index)) { clust_rec = NULL; } else { #ifdef UNIV_SEARCH_DEBUG - ut_a(clust_rec == NULL || - row_sel_sec_rec_is_for_clust_rec(rec, - sec_index, clust_rec, clust_index)); + ut_a(clust_rec == NULL + || row_sel_sec_rec_is_for_clust_rec + (rec, sec_index, clust_rec, clust_index)); #endif } } @@ -2973,7 +2976,7 @@ sel_restore_position_for_mysql( } if (relative_position == BTR_PCUR_AFTER - || relative_position == BTR_PCUR_AFTER_LAST_IN_TREE) { + || relative_position == BTR_PCUR_AFTER_LAST_IN_TREE) { if (moves_up) { return(TRUE); @@ -2987,7 +2990,7 @@ sel_restore_position_for_mysql( } ut_ad(relative_position == BTR_PCUR_BEFORE - || relative_position == BTR_PCUR_BEFORE_FIRST_IN_TREE); + || relative_position == BTR_PCUR_BEFORE_FIRST_IN_TREE); if (moves_up && btr_pcur_is_on_user_rec(pcur, mtr)) { btr_pcur_move_to_next(pcur, mtr); @@ -3015,28 +3018,29 @@ row_sel_pop_cached_row_for_mysql( if (UNIV_UNLIKELY(prebuilt->keep_other_fields_on_keyread)) { /* Copy cache record field by field, don't touch fields that are not covered by current key */ - cached_rec = - prebuilt->fetch_cache[prebuilt->fetch_cache_first]; + cached_rec = prebuilt->fetch_cache + [prebuilt->fetch_cache_first]; for (i = 0; i < prebuilt->n_template; i++) { templ = prebuilt->mysql_template + i; - ut_memcpy( - buf + templ->mysql_col_offset, - cached_rec + templ->mysql_col_offset, - templ->mysql_col_len); + ut_memcpy(buf + templ->mysql_col_offset, + cached_rec + templ->mysql_col_offset, + templ->mysql_col_len); /* Copy NULL bit of the current field from cached_rec to buf */ if (templ->mysql_null_bit_mask) { - buf[templ->mysql_null_byte_offset] ^= - (buf[templ->mysql_null_byte_offset] ^ - cached_rec[templ->mysql_null_byte_offset]) & - (byte)templ->mysql_null_bit_mask; + buf[templ->mysql_null_byte_offset] + ^= (buf[templ->mysql_null_byte_offset] + ^ cached_rec + [templ->mysql_null_byte_offset]) + & (byte)templ->mysql_null_bit_mask; } } } else { - ut_memcpy(buf, prebuilt->fetch_cache[prebuilt->fetch_cache_first], - prebuilt->mysql_prefix_len); + ut_memcpy(buf, + prebuilt->fetch_cache[prebuilt->fetch_cache_first], + prebuilt->mysql_prefix_len); } prebuilt->n_fetch_cached--; prebuilt->fetch_cache_first++; @@ -3084,9 +3088,9 @@ row_sel_push_cache_row_for_mysql( ut_ad(prebuilt->fetch_cache_first == 0); - if (UNIV_UNLIKELY(!row_sel_store_mysql_rec( - prebuilt->fetch_cache[prebuilt->n_fetch_cached], - prebuilt, rec, offsets))) { + if (UNIV_UNLIKELY(!row_sel_store_mysql_rec + (prebuilt->fetch_cache[prebuilt->n_fetch_cached], + prebuilt, rec, offsets))) { ut_error; } @@ -3119,13 +3123,13 @@ row_sel_try_search_shortcut_for_mysql( ut_ad(!prebuilt->templ_contains_blob); btr_pcur_open_with_no_init(index, search_tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, pcur, + BTR_SEARCH_LEAF, pcur, #ifndef UNIV_SEARCH_DEBUG - RW_S_LATCH, + RW_S_LATCH, #else - 0, + 0, #endif - mtr); + mtr); rec = btr_pcur_get_rec(pcur); if (!page_rec_is_user_rec(rec)) { @@ -3146,10 +3150,10 @@ row_sel_try_search_shortcut_for_mysql( a previous version of the record */ *offsets = rec_get_offsets(rec, index, *offsets, - ULINT_UNDEFINED, heap); + ULINT_UNDEFINED, heap); if (!lock_clust_rec_cons_read_sees(rec, index, - *offsets, trx->read_view)) { + *offsets, trx->read_view)) { return(SEL_RETRY); } @@ -3213,15 +3217,15 @@ row_search_for_mysql( ibool mtr_has_extra_clust_latch = FALSE; ibool moves_up = FALSE; ibool set_also_gap_locks = TRUE; - /* if the query is a plain - locking SELECT, and the isolation - level is <= TRX_ISO_READ_COMMITTED, - then this is set to FALSE */ + /* if the query is a plain + locking SELECT, and the isolation + level is <= TRX_ISO_READ_COMMITTED, + then this is set to FALSE */ ibool did_semi_consistent_read = FALSE; - /* if the returned record was locked - and we did a semi-consistent read - (fetch the newest committed version), - then this is set to TRUE */ + /* if the returned record was locked + and we did a semi-consistent read + (fetch the newest committed version), + then this is set to TRUE */ #ifdef UNIV_SEARCH_DEBUG ulint cnt = 0; #endif /* UNIV_SEARCH_DEBUG */ @@ -3240,23 +3244,27 @@ row_search_for_mysql( if (UNIV_UNLIKELY(prebuilt->table->ibd_file_missing)) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error:\n" -"InnoDB: MySQL is trying to use a table handle but the .ibd file for\n" -"InnoDB: table %s does not exist.\n" -"InnoDB: Have you deleted the .ibd file from the database directory under\n" -"InnoDB: the MySQL datadir, or have you used DISCARD TABLESPACE?\n" -"InnoDB: Look from\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n" -"InnoDB: how you can resolve the problem.\n", - prebuilt->table->name); + "InnoDB: MySQL is trying to use a table handle" + " but the .ibd file for\n" + "InnoDB: table %s does not exist.\n" + "InnoDB: Have you deleted the .ibd file" + " from the database directory under\n" + "InnoDB: the MySQL datadir, or have you used" + " DISCARD TABLESPACE?\n" + "InnoDB: Look from\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "innodb-troubleshooting.html\n" + "InnoDB: how you can resolve the problem.\n", + prebuilt->table->name); return(DB_ERROR); } if (UNIV_UNLIKELY(prebuilt->magic_n != ROW_PREBUILT_ALLOCATED)) { fprintf(stderr, - "InnoDB: Error: trying to free a corrupt\n" - "InnoDB: table handle. Magic n %lu, table name ", - (ulong) prebuilt->magic_n); + "InnoDB: Error: trying to free a corrupt\n" + "InnoDB: table handle. Magic n %lu, table name ", + (ulong) prebuilt->magic_n); ut_print_name(stderr, trx, TRUE, prebuilt->table->name); putc('\n', stderr); @@ -3265,37 +3273,40 @@ row_search_for_mysql( ut_error; } +#if 0 + /* August 19, 2005 by Heikki: temporarily disable this error + print until the cursor lock count is done correctly. + See bugs #12263 and #12456!*/ + if (trx->n_mysql_tables_in_use == 0 - && UNIV_UNLIKELY(prebuilt->select_lock_type == LOCK_NONE)) { + && UNIV_UNLIKELY(prebuilt->select_lock_type == LOCK_NONE)) { /* Note that if MySQL uses an InnoDB temp table that it created inside LOCK TABLES, then n_mysql_tables_in_use can be zero; in that case select_lock_type is set to LOCK_X in ::start_stmt. */ -/* August 19, 2005 by Heikki: temporarily disable this error print until the -cursor lock count is done correctly. See bugs #12263 and #12456! - - fputs( -"InnoDB: Error: MySQL is trying to perform a SELECT\n" -"InnoDB: but it has not locked any tables in ::external_lock()!\n", -stderr); + fputs("InnoDB: Error: MySQL is trying to perform a SELECT\n" + "InnoDB: but it has not locked" + " any tables in ::external_lock()!\n", + stderr); trx_print(stderr, trx, 600); fputc('\n', stderr); -*/ - } +#endif -/* fprintf(stderr, "Match mode %lu\n search tuple ", (ulong) match_mode); +#if 0 + fprintf(stderr, "Match mode %lu\n search tuple ", + (ulong) match_mode); dtuple_print(search_tuple); - - fprintf(stderr, "N tables locked %lu\n", trx->mysql_n_tables_locked); -*/ + fprintf(stderr, "N tables locked %lu\n", + (ulong) trx->mysql_n_tables_locked); +#endif /*-------------------------------------------------------------*/ /* PHASE 0: Release a possible s-latch we are holding on the adaptive hash index latch if there is someone waiting behind */ if (UNIV_UNLIKELY(btr_search_latch.writer != RW_LOCK_NOT_LOCKED) - && trx->has_search_latch) { + && trx->has_search_latch) { /* There is an x-latch request on the adaptive hash index: release the s-latch to reduce starvation and wait for @@ -3314,8 +3325,8 @@ stderr); row. */ if ((srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE) { + || trx->isolation_level == TRX_ISO_READ_COMMITTED) + && prebuilt->select_lock_type != LOCK_NONE) { trx_reset_new_rec_lock_info(trx); } @@ -3365,7 +3376,7 @@ stderr); } if (prebuilt->fetch_cache_first > 0 - && prebuilt->fetch_cache_first < MYSQL_FETCH_CACHE_SIZE) { + && prebuilt->fetch_cache_first < MYSQL_FETCH_CACHE_SIZE) { /* The previous returned row was popped from the fetch cache, but the cache was not full at the time of the @@ -3386,20 +3397,20 @@ stderr); } /* In a search where at most one record in the index may match, we - can use a LOCK_REC_NOT_GAP type record lock when locking a non-delete- - marked matching record. + can use a LOCK_REC_NOT_GAP type record lock when locking a + non-delete-marked matching record. - Note that in a unique secondary index there may be different delete- - marked versions of a record where only the primary key values differ: - thus in a secondary index we must use next-key locks when locking - delete-marked records. */ + Note that in a unique secondary index there may be different + delete-marked versions of a record where only the primary key + values differ: thus in a secondary index we must use next-key + locks when locking delete-marked records. */ if (match_mode == ROW_SEL_EXACT - && index->type & DICT_UNIQUE - && dtuple_get_n_fields(search_tuple) - == dict_index_get_n_unique(index) - && (index->type & DICT_CLUSTERED - || !dtuple_contains_null(search_tuple))) { + && index->type & DICT_UNIQUE + && dtuple_get_n_fields(search_tuple) + == dict_index_get_n_unique(index) + && (index->type & DICT_CLUSTERED + || !dtuple_contains_null(search_tuple))) { /* Note above that a UNIQUE secondary index can contain many rows with the same key value if one of the columns is the SQL @@ -3414,8 +3425,8 @@ stderr); 1 column. Return immediately if this is not a HANDLER command. */ - if (UNIV_UNLIKELY(direction != 0 && - !prebuilt->used_in_HANDLER)) { + if (UNIV_UNLIKELY(direction != 0 + && !prebuilt->used_in_HANDLER)) { err = DB_RECORD_NOT_FOUND; goto func_exit; @@ -3434,20 +3445,20 @@ stderr); may be long and there may be externally stored fields */ if (UNIV_UNLIKELY(direction == 0) - && unique_search - && index->type & DICT_CLUSTERED - && !prebuilt->templ_contains_blob - && !prebuilt->used_in_HANDLER - && (prebuilt->mysql_row_len < UNIV_PAGE_SIZE / 8)) { + && unique_search + && index->type & DICT_CLUSTERED + && !prebuilt->templ_contains_blob + && !prebuilt->used_in_HANDLER + && (prebuilt->mysql_row_len < UNIV_PAGE_SIZE / 8)) { mode = PAGE_CUR_GE; unique_search_from_clust_index = TRUE; if (trx->mysql_n_tables_locked == 0 - && prebuilt->select_lock_type == LOCK_NONE - && trx->isolation_level > TRX_ISO_READ_UNCOMMITTED - && trx->read_view) { + && prebuilt->select_lock_type == LOCK_NONE + && trx->isolation_level > TRX_ISO_READ_UNCOMMITTED + && trx->read_view) { /* This is a SELECT query done as a consistent read, and the read view has already been allocated: @@ -3467,15 +3478,15 @@ stderr); trx->has_search_latch = TRUE; } #endif - switch (row_sel_try_search_shortcut_for_mysql(&rec, - prebuilt, &offsets, &heap, &mtr)) { + switch (row_sel_try_search_shortcut_for_mysql + (&rec, prebuilt, &offsets, &heap, &mtr)) { case SEL_FOUND: #ifdef UNIV_SEARCH_DEBUG ut_a(0 == cmp_dtuple_rec(search_tuple, - rec, offsets)); + rec, offsets)); #endif if (!row_sel_store_mysql_rec(buf, prebuilt, - rec, offsets)) { + rec, offsets)) { err = DB_TOO_BIG_RECORD; /* We let the main loop to do the @@ -3491,7 +3502,7 @@ stderr); srv_n_rows_read++; if (trx->search_latch_timeout > 0 - && trx->has_search_latch) { + && trx->has_search_latch) { trx->search_latch_timeout--; @@ -3511,7 +3522,7 @@ stderr); fputs(" record not found 2\n", stderr); */ if (trx->search_latch_timeout > 0 - && trx->has_search_latch) { + && trx->has_search_latch) { trx->search_latch_timeout--; @@ -3542,14 +3553,14 @@ shortcut_fails_too_big_rec: trx_start_if_not_started(trx); if (trx->isolation_level <= TRX_ISO_READ_COMMITTED - && prebuilt->select_lock_type != LOCK_NONE - && trx->mysql_query_str && trx->mysql_thd) { + && prebuilt->select_lock_type != LOCK_NONE + && trx->mysql_query_str && trx->mysql_thd) { /* Scan the MySQL query string; check if SELECT is the first word there */ - if (dict_str_starts_with_keyword(trx->mysql_thd, - *trx->mysql_query_str, "SELECT")) { + if (dict_str_starts_with_keyword + (trx->mysql_thd, *trx->mysql_query_str, "SELECT")) { /* It is a plain locking SELECT and the isolation level is low: do not lock gaps */ @@ -3576,13 +3587,13 @@ shortcut_fails_too_big_rec: clust_index = dict_table_get_first_index(index->table); if (UNIV_LIKELY(direction != 0)) { - ibool need_to_process = sel_restore_position_for_mysql( - &same_user_rec, BTR_SEARCH_LEAF, - pcur, moves_up, &mtr); + ibool need_to_process = sel_restore_position_for_mysql + (&same_user_rec, BTR_SEARCH_LEAF, + pcur, moves_up, &mtr); if (UNIV_UNLIKELY(need_to_process)) { if (UNIV_UNLIKELY(prebuilt->row_read_type - == ROW_READ_DID_SEMI_CONSISTENT)) { + == ROW_READ_DID_SEMI_CONSISTENT)) { /* We did a semi-consistent read, but the record was removed in the meantime. */ @@ -3590,7 +3601,7 @@ shortcut_fails_too_big_rec: = ROW_READ_TRY_SEMI_CONSISTENT; } } else if (UNIV_LIKELY(prebuilt->row_read_type - != ROW_READ_DID_SEMI_CONSISTENT)) { + != ROW_READ_DID_SEMI_CONSISTENT)) { /* The cursor was positioned on the record that we returned previously. If we need @@ -3604,17 +3615,19 @@ shortcut_fails_too_big_rec: } else if (dtuple_get_n_fields(search_tuple) > 0) { btr_pcur_open_with_no_init(index, search_tuple, mode, - BTR_SEARCH_LEAF, - pcur, 0, &mtr); + BTR_SEARCH_LEAF, + pcur, 0, &mtr); pcur->trx_if_known = trx; } else { if (mode == PAGE_CUR_G) { - btr_pcur_open_at_index_side(TRUE, index, - BTR_SEARCH_LEAF, pcur, FALSE, &mtr); + btr_pcur_open_at_index_side + (TRUE, index, + BTR_SEARCH_LEAF, pcur, FALSE, &mtr); } else if (mode == PAGE_CUR_L) { - btr_pcur_open_at_index_side(FALSE, index, - BTR_SEARCH_LEAF, pcur, FALSE, &mtr); + btr_pcur_open_at_index_side + (FALSE, index, + BTR_SEARCH_LEAF, pcur, FALSE, &mtr); } } @@ -3622,11 +3635,12 @@ shortcut_fails_too_big_rec: /* No need to set an intention lock or assign a read view */ if (trx->read_view == NULL - && prebuilt->select_lock_type == LOCK_NONE) { + && prebuilt->select_lock_type == LOCK_NONE) { - fputs( -"InnoDB: Error: MySQL is trying to perform a consistent read\n" -"InnoDB: but the read view is not assigned!\n", stderr); + fputs("InnoDB: Error: MySQL is trying to" + " perform a consistent read\n" + "InnoDB: but the read view is not assigned!\n", + stderr); trx_print(stderr, trx, 600); fputc('\n', stderr); ut_a(0); @@ -3660,13 +3674,13 @@ rec_loop: rec = btr_pcur_get_rec(pcur); ut_ad(!!page_rec_is_comp(rec) == comp); #ifdef UNIV_SEARCH_DEBUG -/* + /* fputs("Using ", stderr); dict_index_name_print(stderr, index); fprintf(stderr, " cnt %lu ; Page no %lu\n", cnt, - buf_frame_get_page_no(buf_frame_align(rec))); + buf_frame_get_page_no(buf_frame_align(rec))); rec_print(rec); -*/ + */ #endif /* UNIV_SEARCH_DEBUG */ if (page_rec_is_infimum(rec)) { @@ -3681,9 +3695,9 @@ rec_loop: if (page_rec_is_supremum(rec)) { if (set_also_gap_locks - && !(srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE) { + && !(srv_locks_unsafe_for_binlog + || trx->isolation_level == TRX_ISO_READ_COMMITTED) + && prebuilt->select_lock_type != LOCK_NONE) { /* Try to place a lock on the index record */ @@ -3693,10 +3707,10 @@ rec_loop: a gap and therefore we do not set locks there. */ offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); err = sel_set_rec_lock(rec, index, offsets, - prebuilt->select_lock_type, - LOCK_ORDINARY, thr); + prebuilt->select_lock_type, + LOCK_ORDINARY, thr); if (err != DB_SUCCESS) { @@ -3734,21 +3748,25 @@ wrong_offs: ut_print_timestamp(stderr); buf_page_print(buf_frame_align(rec)); fprintf(stderr, -"\nInnoDB: rec address %p, first buffer frame %p\n" -"InnoDB: buffer pool high end %p, buf block fix count %lu\n", - rec, buf_pool->frame_zero, - buf_pool->high_end, + "\nInnoDB: rec address %p, first" + " buffer frame %p\n" + "InnoDB: buffer pool high end %p," + " buf block fix count %lu\n", + (void*) rec, (void*) buf_pool->frame_zero, + (void*) buf_pool->high_end, (ulong)buf_block_align(rec)->buf_fix_count); fprintf(stderr, -"InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n" -"InnoDB: ", + "InnoDB: Index corruption: rec offs %lu" + " next offs %lu, page no %lu,\n" + "InnoDB: ", (ulong) ut_align_offset(rec, UNIV_PAGE_SIZE), (ulong) next_offs, (ulong) buf_frame_get_page_no(rec)); dict_index_name_print(stderr, trx, index); fputs(". Run CHECK TABLE. You may need to\n" -"InnoDB: restore from a backup, or dump + drop + reimport the table.\n", - stderr); + "InnoDB: restore from a backup, or" + " dump + drop + reimport the table.\n", + stderr); err = DB_CORRUPTION; @@ -3758,14 +3776,15 @@ wrong_offs: over the corruption to recover as much as possible. */ fprintf(stderr, -"InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n" -"InnoDB: ", - (ulong) ut_align_offset(rec, UNIV_PAGE_SIZE), - (ulong) next_offs, - (ulong) buf_frame_get_page_no(rec)); + "InnoDB: Index corruption: rec offs %lu" + " next offs %lu, page no %lu,\n" + "InnoDB: ", + (ulong) ut_align_offset(rec, UNIV_PAGE_SIZE), + (ulong) next_offs, + (ulong) buf_frame_get_page_no(rec)); dict_index_name_print(stderr, trx, index); fputs(". We try to skip the rest of the page.\n", - stderr); + stderr); btr_pcur_move_to_last_on_page(pcur, &mtr); @@ -3780,16 +3799,17 @@ wrong_offs: if (UNIV_UNLIKELY(srv_force_recovery > 0)) { if (!rec_validate(rec, offsets) - || !btr_index_rec_validate(rec, index, FALSE)) { + || !btr_index_rec_validate(rec, index, FALSE)) { fprintf(stderr, -"InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n" -"InnoDB: ", - (ulong) ut_align_offset(rec, UNIV_PAGE_SIZE), - (ulong) next_offs, - (ulong) buf_frame_get_page_no(rec)); + "InnoDB: Index corruption: rec offs %lu" + " next offs %lu, page no %lu,\n" + "InnoDB: ", + (ulong) ut_align_offset(rec, UNIV_PAGE_SIZE), + (ulong) next_offs, + (ulong) buf_frame_get_page_no(rec)); dict_index_name_print(stderr, trx, index); fputs(". We try to skip the record.\n", - stderr); + stderr); goto next_rec; } @@ -3809,18 +3829,20 @@ wrong_offs: if (0 != cmp_dtuple_rec(search_tuple, rec, offsets)) { if (set_also_gap_locks - && !(srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE) { + && !(srv_locks_unsafe_for_binlog + || trx->isolation_level + == TRX_ISO_READ_COMMITTED) + && prebuilt->select_lock_type != LOCK_NONE) { /* Try to place a gap lock on the index record only if innodb_locks_unsafe_for_binlog option is not set or this session is not using a READ COMMITTED isolation level. */ - err = sel_set_rec_lock(rec, index, offsets, - prebuilt->select_lock_type, - LOCK_GAP, thr); + err = sel_set_rec_lock + (rec, index, offsets, + prebuilt->select_lock_type, + LOCK_GAP, thr); if (err != DB_SUCCESS) { @@ -3842,18 +3864,20 @@ wrong_offs: if (!cmp_dtuple_is_prefix_of_rec(search_tuple, rec, offsets)) { if (set_also_gap_locks - && !(srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE) { + && !(srv_locks_unsafe_for_binlog + || trx->isolation_level + == TRX_ISO_READ_COMMITTED) + && prebuilt->select_lock_type != LOCK_NONE) { /* Try to place a gap lock on the index record only if innodb_locks_unsafe_for_binlog option is not set or this session is not using a READ COMMITTED isolation level. */ - err = sel_set_rec_lock(rec, index, offsets, - prebuilt->select_lock_type, - LOCK_GAP, thr); + err = sel_set_rec_lock + (rec, index, offsets, + prebuilt->select_lock_type, + LOCK_GAP, thr); if (err != DB_SUCCESS) { @@ -3888,9 +3912,9 @@ wrong_offs: ulint lock_type; if (!set_also_gap_locks - || srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED - || (unique_search + || srv_locks_unsafe_for_binlog + || trx->isolation_level == TRX_ISO_READ_COMMITTED + || (unique_search && !UNIV_UNLIKELY(rec_get_deleted_flag(rec, comp)))) { goto no_gap_lock; @@ -3910,18 +3934,18 @@ wrong_offs: need to lock the gap before that record. */ if (index == clust_index - && mode == PAGE_CUR_GE - && direction == 0 - && dtuple_get_n_fields_cmp(search_tuple) - == dict_index_get_n_unique(index) - && 0 == cmp_dtuple_rec(search_tuple, rec, offsets)) { + && mode == PAGE_CUR_GE + && direction == 0 + && dtuple_get_n_fields_cmp(search_tuple) + == dict_index_get_n_unique(index) + && 0 == cmp_dtuple_rec(search_tuple, rec, offsets)) { no_gap_lock: lock_type = LOCK_REC_NOT_GAP; } err = sel_set_rec_lock(rec, index, offsets, - prebuilt->select_lock_type, - lock_type, thr); + prebuilt->select_lock_type, + lock_type, thr); switch (err) { rec_t* old_vers; @@ -3930,17 +3954,16 @@ no_gap_lock: case DB_LOCK_WAIT: if (UNIV_LIKELY(prebuilt->row_read_type != ROW_READ_TRY_SEMI_CONSISTENT) - || index != clust_index) { + || index != clust_index) { goto lock_wait_or_error; } /* The following call returns 'offsets' associated with 'old_vers' */ - err = row_sel_build_committed_vers_for_mysql( - clust_index, prebuilt, rec, - &offsets, &heap, - &old_vers, &mtr); + err = row_sel_build_committed_vers_for_mysql + (clust_index, prebuilt, rec, + &offsets, &heap, &old_vers, &mtr); if (err != DB_SUCCESS) { @@ -3954,8 +3977,8 @@ no_gap_lock: goto lock_wait_or_error; } if (UNIV_LIKELY(trx->wait_lock != NULL)) { - lock_cancel_waiting_and_release( - trx->wait_lock); + lock_cancel_waiting_and_release + (trx->wait_lock); trx_reset_new_rec_lock_info(trx); } else { mutex_exit(&kernel_mutex); @@ -3965,7 +3988,8 @@ no_gap_lock: Do a normal locking read. */ offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, + &heap); err = DB_SUCCESS; break; } @@ -4001,17 +4025,16 @@ no_gap_lock: by skipping this lookup */ if (UNIV_LIKELY(srv_force_recovery < 5) - && !lock_clust_rec_cons_read_sees(rec, index, - offsets, trx->read_view)) { + && !lock_clust_rec_cons_read_sees + (rec, index, offsets, trx->read_view)) { rec_t* old_vers; /* The following call returns 'offsets' associated with 'old_vers' */ - err = row_sel_build_prev_vers_for_mysql( - trx->read_view, clust_index, - prebuilt, rec, - &offsets, &heap, - &old_vers, &mtr); + err = row_sel_build_prev_vers_for_mysql + (trx->read_view, clust_index, + prebuilt, rec, &offsets, &heap, + &old_vers, &mtr); if (err != DB_SUCCESS) { @@ -4051,9 +4074,9 @@ no_gap_lock: /* The record is delete-marked: we can skip it */ if ((srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE - && !did_semi_consistent_read) { + || trx->isolation_level == TRX_ISO_READ_COMMITTED) + && prebuilt->select_lock_type != LOCK_NONE + && !did_semi_consistent_read) { /* No need to keep a lock on a delete-marked record if we do not want to use next-key locking. */ @@ -4086,8 +4109,8 @@ requires_clust_rec: built for a consistent read. */ err = row_sel_get_clust_rec_for_mysql(prebuilt, index, rec, - thr, &clust_rec, - &offsets, &heap, &mtr); + thr, &clust_rec, + &offsets, &heap, &mtr); if (err != DB_SUCCESS) { goto lock_wait_or_error; @@ -4105,8 +4128,8 @@ requires_clust_rec: /* The record is delete marked: we can skip it */ if ((srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE) { + || trx->isolation_level == TRX_ISO_READ_COMMITTED) + && prebuilt->select_lock_type != LOCK_NONE) { /* No need to keep a lock on a delete-marked record if we do not want to use next-key @@ -4123,12 +4146,12 @@ requires_clust_rec: result_rec = clust_rec; ut_ad(rec_offs_validate(result_rec, clust_index, - offsets)); + offsets)); } else { /* We used 'offsets' for the clust rec, recalculate them for 'rec' */ offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); result_rec = rec; } } else { @@ -4143,13 +4166,13 @@ requires_clust_rec: offsets)); if ((match_mode == ROW_SEL_EXACT - || prebuilt->n_rows_fetched >= MYSQL_FETCH_CACHE_THRESHOLD) - && prebuilt->select_lock_type == LOCK_NONE - && !prebuilt->templ_contains_blob - && !prebuilt->clust_index_was_generated - && !prebuilt->used_in_HANDLER - && prebuilt->template_type - != ROW_MYSQL_DUMMY_TEMPLATE) { + || prebuilt->n_rows_fetched >= MYSQL_FETCH_CACHE_THRESHOLD) + && prebuilt->select_lock_type == LOCK_NONE + && !prebuilt->templ_contains_blob + && !prebuilt->clust_index_was_generated + && !prebuilt->used_in_HANDLER + && prebuilt->template_type + != ROW_MYSQL_DUMMY_TEMPLATE) { /* Inside an update, for example, we do not cache rows, since we may use the cursor position to do the actual @@ -4161,7 +4184,7 @@ requires_clust_rec: cursor. */ row_sel_push_cache_row_for_mysql(prebuilt, result_rec, - offsets); + offsets); if (prebuilt->n_fetch_cached == MYSQL_FETCH_CACHE_SIZE) { goto got_row; @@ -4171,13 +4194,13 @@ requires_clust_rec: } else { if (prebuilt->template_type == ROW_MYSQL_DUMMY_TEMPLATE) { memcpy(buf + 4, result_rec - - rec_offs_extra_size(offsets), - rec_offs_size(offsets)); + - rec_offs_extra_size(offsets), + rec_offs_size(offsets)); mach_write_to_4(buf, rec_offs_extra_size(offsets) + 4); } else { if (!row_sel_store_mysql_rec(buf, prebuilt, - result_rec, offsets)) { + result_rec, offsets)) { err = DB_TOO_BIG_RECORD; goto lock_wait_or_error; @@ -4186,12 +4209,12 @@ requires_clust_rec: if (prebuilt->clust_index_was_generated) { if (result_rec != rec) { - offsets = rec_get_offsets( - rec, index, offsets, - ULINT_UNDEFINED, &heap); + offsets = rec_get_offsets + (rec, index, offsets, + ULINT_UNDEFINED, &heap); } row_sel_store_row_id_to_prebuilt(prebuilt, rec, - index, offsets); + index, offsets); } } @@ -4206,8 +4229,8 @@ got_row: even after a unique search. */ if (!unique_search_from_clust_index - || prebuilt->select_lock_type != LOCK_NONE - || prebuilt->used_in_HANDLER) { + || prebuilt->select_lock_type != LOCK_NONE + || prebuilt->used_in_HANDLER) { /* Inside an update always store the cursor position */ @@ -4221,14 +4244,14 @@ got_row: next_rec: /* Reset the old and new "did semi-consistent read" flags. */ if (UNIV_UNLIKELY(prebuilt->row_read_type - == ROW_READ_DID_SEMI_CONSISTENT)) { + == ROW_READ_DID_SEMI_CONSISTENT)) { prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT; } did_semi_consistent_read = FALSE; if (UNIV_UNLIKELY(srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE) { + || trx->isolation_level == TRX_ISO_READ_COMMITTED) + && prebuilt->select_lock_type != LOCK_NONE) { trx_reset_new_rec_lock_info(trx); } @@ -4249,8 +4272,8 @@ next_rec: mtr_start(&mtr); if (sel_restore_position_for_mysql(&same_user_rec, - BTR_SEARCH_LEAF, - pcur, moves_up, &mtr)) { + BTR_SEARCH_LEAF, + pcur, moves_up, &mtr)) { #ifdef UNIV_SEARCH_DEBUG cnt++; #endif /* UNIV_SEARCH_DEBUG */ @@ -4287,7 +4310,7 @@ not_moved: lock_wait_or_error: /* Reset the old and new "did semi-consistent read" flags. */ if (UNIV_UNLIKELY(prebuilt->row_read_type - == ROW_READ_DID_SEMI_CONSISTENT)) { + == ROW_READ_DID_SEMI_CONSISTENT)) { prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT; } did_semi_consistent_read = FALSE; @@ -4314,12 +4337,12 @@ lock_wait_or_error: mtr_start(&mtr); sel_restore_position_for_mysql(&same_user_rec, - BTR_SEARCH_LEAF, pcur, - moves_up, &mtr); + BTR_SEARCH_LEAF, pcur, + moves_up, &mtr); if ((srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED) - && !same_user_rec) { + || trx->isolation_level == TRX_ISO_READ_COMMITTED) + && !same_user_rec) { /* Since we were not able to restore the cursor on the same user record, we cannot use @@ -4348,7 +4371,7 @@ lock_wait_or_error: thr->lock_state = QUE_THR_LOCK_NOLOCK; #ifdef UNIV_SEARCH_DEBUG -/* fputs("Using ", stderr); + /* fputs("Using ", stderr); dict_index_name_print(stderr, index); fprintf(stderr, " cnt %lu ret value %lu err\n", cnt, err); */ #endif /* UNIV_SEARCH_DEBUG */ @@ -4367,7 +4390,7 @@ normal_return: } #ifdef UNIV_SEARCH_DEBUG -/* fputs("Using ", stderr); + /* fputs("Using ", stderr); dict_index_name_print(stderr, index); fprintf(stderr, " cnt %lu ret value %lu err\n", cnt, err); */ #endif /* UNIV_SEARCH_DEBUG */ @@ -4385,7 +4408,7 @@ func_exit: The flag did_semi_consistent_read is set if and only if the record being returned was fetched with a semi-consistent read. */ ut_ad(prebuilt->row_read_type != ROW_READ_WITH_LOCKS - || !did_semi_consistent_read); + || !did_semi_consistent_read); if (UNIV_UNLIKELY(prebuilt->row_read_type != ROW_READ_WITH_LOCKS)) { if (UNIV_UNLIKELY(did_semi_consistent_read)) { @@ -4432,8 +4455,8 @@ row_search_check_if_query_cache_permitted( IX type locks actually would require ret = FALSE. */ if (UT_LIST_GET_LEN(table->locks) == 0 - && ut_dulint_cmp(trx->id, - table->query_cache_inv_trx_id) >= 0) { + && ut_dulint_cmp(trx->id, + table->query_cache_inv_trx_id) >= 0) { ret = TRUE; @@ -4441,10 +4464,10 @@ row_search_check_if_query_cache_permitted( transaction if it does not yet have one */ if (trx->isolation_level >= TRX_ISO_REPEATABLE_READ - && !trx->read_view) { + && !trx->read_view) { - trx->read_view = read_view_open_now(trx->id, - trx->global_read_view_heap); + trx->read_view = read_view_open_now + (trx->id, trx->global_read_view_heap); trx->global_read_view = trx->read_view; } } diff --git a/storage/innobase/row/row0uins.c b/storage/innobase/row/row0uins.c index 2bf4b0e5c65..822b7cfb9f2 100644 --- a/storage/innobase/row/row0uins.c +++ b/storage/innobase/row/row0uins.c @@ -48,7 +48,7 @@ row_undo_ins_remove_clust_rec( mtr_start(&mtr); success = btr_pcur_restore_position(BTR_MODIFY_LEAF, &(node->pcur), - &mtr); + &mtr); ut_a(success); if (ut_dulint_cmp(node->table->id, DICT_INDEXES_ID) == 0) { @@ -63,7 +63,7 @@ row_undo_ins_remove_clust_rec( mtr_start(&mtr); success = btr_pcur_restore_position(BTR_MODIFY_LEAF, - &(node->pcur), &mtr); + &(node->pcur), &mtr); ut_a(success); } @@ -83,7 +83,7 @@ retry: mtr_start(&mtr); success = btr_pcur_restore_position(BTR_MODIFY_TREE, - &(node->pcur), &mtr); + &(node->pcur), &mtr); ut_a(success); btr_cur_pessimistic_delete(&err, FALSE, btr_cur, TRUE, &mtr); @@ -93,7 +93,7 @@ retry: and restart with more file space */ if (err == DB_OUT_OF_FILE_SPACE - && n_tries < BTR_CUR_RETRY_DELETE_N_TIMES) { + && n_tries < BTR_CUR_RETRY_DELETE_N_TIMES) { btr_pcur_commit_specify_mtr(&(node->pcur), &mtr); @@ -230,7 +230,7 @@ row_undo_ins_parse_undo_rec( ut_ad(node); ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &dummy, - &dummy_extern, &undo_no, &table_id); + &dummy_extern, &undo_no, &table_id); ut_ad(type == TRX_UNDO_INSERT_REC); node->rec_type = type; @@ -251,7 +251,7 @@ row_undo_ins_parse_undo_rec( clust_index = dict_table_get_first_index(node->table); ptr = trx_undo_rec_get_row_ref(ptr, clust_index, &(node->ref), - node->heap); + node->heap); } /*************************************************************** @@ -286,12 +286,12 @@ row_undo_ins( return(DB_SUCCESS); } - node->index = dict_table_get_next_index( - dict_table_get_first_index(node->table)); + node->index = dict_table_get_next_index + (dict_table_get_first_index(node->table)); while (node->index != NULL) { entry = row_build_index_entry(node->row, node->index, - node->heap); + node->heap); err = row_undo_ins_remove_sec(node->index, entry); if (err != DB_SUCCESS) { diff --git a/storage/innobase/row/row0umod.c b/storage/innobase/row/row0umod.c index 9c871def661..778f240d18e 100644 --- a/storage/innobase/row/row0umod.c +++ b/storage/innobase/row/row0umod.c @@ -101,18 +101,19 @@ row_undo_mod_clust_low( if (mode == BTR_MODIFY_LEAF) { err = btr_cur_optimistic_update(BTR_NO_LOCKING_FLAG - | BTR_NO_UNDO_LOG_FLAG - | BTR_KEEP_SYS_FLAG, - btr_cur, node->update, - node->cmpl_info, thr, mtr); + | BTR_NO_UNDO_LOG_FLAG + | BTR_KEEP_SYS_FLAG, + btr_cur, node->update, + node->cmpl_info, thr, mtr); } else { ut_ad(mode == BTR_MODIFY_TREE); - err = btr_cur_pessimistic_update(BTR_NO_LOCKING_FLAG - | BTR_NO_UNDO_LOG_FLAG - | BTR_KEEP_SYS_FLAG, - btr_cur, &dummy_big_rec, node->update, - node->cmpl_info, thr, mtr); + err = btr_cur_pessimistic_update + (BTR_NO_LOCKING_FLAG + | BTR_NO_UNDO_LOG_FLAG + | BTR_KEEP_SYS_FLAG, + btr_cur, &dummy_big_rec, node->update, + node->cmpl_info, thr, mtr); } return(err); @@ -149,7 +150,7 @@ row_undo_mod_remove_clust_low( /* Find out if we can remove the whole clustered index record */ if (node->rec_type == TRX_UNDO_UPD_DEL_REC - && !row_vers_must_preserve_del_marked(node->new_trx_id, mtr)) { + && !row_vers_must_preserve_del_marked(node->new_trx_id, mtr)) { /* Ok, we can remove */ } else { @@ -234,7 +235,7 @@ row_undo_mod_clust( mtr_start(&mtr); err = row_undo_mod_remove_clust_low(node, thr, &mtr, - BTR_MODIFY_LEAF); + BTR_MODIFY_LEAF); if (err != DB_SUCCESS) { btr_pcur_commit_specify_mtr(pcur, &mtr); @@ -244,7 +245,7 @@ row_undo_mod_clust( mtr_start(&mtr); err = row_undo_mod_remove_clust_low(node, thr, &mtr, - BTR_MODIFY_TREE); + BTR_MODIFY_TREE); } btr_pcur_commit_specify_mtr(pcur, &mtr); @@ -318,15 +319,15 @@ row_undo_mod_del_mark_or_remove_sec_low( mtr_start(&mtr_vers); success = btr_pcur_restore_position(BTR_SEARCH_LEAF, &(node->pcur), - &mtr_vers); + &mtr_vers); ut_a(success); old_has = row_vers_old_has_index_entry(FALSE, - btr_pcur_get_rec(&(node->pcur)), - &mtr_vers, index, entry); + btr_pcur_get_rec(&(node->pcur)), + &mtr_vers, index, entry); if (old_has) { err = btr_cur_del_mark_set_sec_rec(BTR_NO_LOCKING_FLAG, - btr_cur, TRUE, thr, &mtr); + btr_cur, TRUE, thr, &mtr); ut_ad(err == DB_SUCCESS); } else { /* Remove the index record */ @@ -342,7 +343,7 @@ row_undo_mod_del_mark_or_remove_sec_low( ut_ad(mode == BTR_MODIFY_TREE); btr_cur_pessimistic_delete(&err, FALSE, btr_cur, - TRUE, &mtr); + TRUE, &mtr); /* The delete operation may fail if we have little file space left: TODO: easiest to crash the database @@ -378,14 +379,14 @@ row_undo_mod_del_mark_or_remove_sec( ulint err; err = row_undo_mod_del_mark_or_remove_sec_low(node, thr, index, - entry, BTR_MODIFY_LEAF); + entry, BTR_MODIFY_LEAF); if (err == DB_SUCCESS) { return(err); } err = row_undo_mod_del_mark_or_remove_sec_low(node, thr, index, - entry, BTR_MODIFY_TREE); + entry, BTR_MODIFY_TREE); return(err); } @@ -422,28 +423,29 @@ row_undo_mod_del_unmark_sec_and_undo_update( if (!found) { fputs("InnoDB: error in sec index entry del undo in\n" - "InnoDB: ", stderr); + "InnoDB: ", stderr); dict_index_name_print(stderr, trx, index); fputs("\n" - "InnoDB: tuple ", stderr); + "InnoDB: tuple ", stderr); dtuple_print(stderr, entry); fputs("\n" - "InnoDB: record ", stderr); + "InnoDB: record ", stderr); rec_print(stderr, btr_pcur_get_rec(&pcur), index); putc('\n', stderr); trx_print(stderr, trx, 0); fputs("\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n", stderr); } else { btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&pcur); err = btr_cur_del_mark_set_sec_rec(BTR_NO_LOCKING_FLAG, - btr_cur, FALSE, thr, &mtr); + btr_cur, FALSE, thr, &mtr); ut_a(err == DB_SUCCESS); heap = mem_heap_create(100); - update = row_upd_build_sec_rec_difference_binary(index, entry, - btr_cur_get_rec(btr_cur), trx, heap); + update = row_upd_build_sec_rec_difference_binary + (index, entry, btr_cur_get_rec(btr_cur), trx, heap); if (upd_get_n_fields(update) == 0) { /* Do nothing */ @@ -452,18 +454,18 @@ row_undo_mod_del_unmark_sec_and_undo_update( /* Try an optimistic updating of the record, keeping changes within the page */ - err = btr_cur_optimistic_update(BTR_KEEP_SYS_FLAG - | BTR_NO_LOCKING_FLAG, - btr_cur, update, 0, thr, &mtr); + err = btr_cur_optimistic_update + (BTR_KEEP_SYS_FLAG | BTR_NO_LOCKING_FLAG, + btr_cur, update, 0, thr, &mtr); if (err == DB_OVERFLOW || err == DB_UNDERFLOW) { err = DB_FAIL; } } else { ut_a(mode == BTR_MODIFY_TREE); - err = btr_cur_pessimistic_update(BTR_KEEP_SYS_FLAG - | BTR_NO_LOCKING_FLAG, - btr_cur, &dummy_big_rec, - update, 0, thr, &mtr); + err = btr_cur_pessimistic_update + (BTR_KEEP_SYS_FLAG | BTR_NO_LOCKING_FLAG, + btr_cur, &dummy_big_rec, + update, 0, thr, &mtr); } mem_heap_free(heap); @@ -498,7 +500,7 @@ row_undo_mod_upd_del_sec( entry = row_build_index_entry(node->row, index, heap); err = row_undo_mod_del_mark_or_remove_sec(node, thr, index, - entry); + entry); if (err != DB_SUCCESS) { mem_heap_free(heap); @@ -536,13 +538,11 @@ row_undo_mod_del_mark_sec( entry = row_build_index_entry(node->row, index, heap); - err = row_undo_mod_del_unmark_sec_and_undo_update( - BTR_MODIFY_LEAF, - thr, index, entry); + err = row_undo_mod_del_unmark_sec_and_undo_update + (BTR_MODIFY_LEAF, thr, index, entry); if (err == DB_FAIL) { - err = row_undo_mod_del_unmark_sec_and_undo_update( - BTR_MODIFY_TREE, - thr, index, entry); + err = row_undo_mod_del_unmark_sec_and_undo_update + (BTR_MODIFY_TREE, thr, index, entry); } if (err != DB_SUCCESS) { @@ -587,7 +587,7 @@ row_undo_mod_upd_exist_sec( index = node->index; if (row_upd_changes_ord_field_binary(node->row, node->index, - node->update)) { + node->update)) { /* Build the newest version of the index entry */ entry = row_build_index_entry(node->row, index, heap); @@ -603,7 +603,8 @@ row_undo_mod_upd_exist_sec( through which we do the search is delete-marked. */ err = row_undo_mod_del_mark_or_remove_sec(node, thr, - index, entry); + index, + entry); if (err != DB_SUCCESS) { mem_heap_free(heap); @@ -618,15 +619,12 @@ row_undo_mod_upd_exist_sec( 'abc' -> 'aBc'. */ row_upd_index_replace_new_col_vals(entry, index, - node->update, NULL); - err = row_undo_mod_del_unmark_sec_and_undo_update( - BTR_MODIFY_LEAF, - thr, index, entry); + node->update, NULL); + err = row_undo_mod_del_unmark_sec_and_undo_update + (BTR_MODIFY_LEAF, thr, index, entry); if (err == DB_FAIL) { - err = - row_undo_mod_del_unmark_sec_and_undo_update( - BTR_MODIFY_TREE, - thr, index, entry); + err = row_undo_mod_del_unmark_sec_and_undo_update + (BTR_MODIFY_TREE, thr, index, entry); } if (err != DB_SUCCESS) { @@ -668,7 +666,7 @@ row_undo_mod_parse_undo_rec( ut_ad(node && thr); trx = thr_get_trx(thr); ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &cmpl_info, - &dummy_extern, &undo_no, &table_id); + &dummy_extern, &undo_no, &table_id); node->rec_type = type; node->table = dict_table_get_on_id(table_id, trx); @@ -691,14 +689,14 @@ row_undo_mod_parse_undo_rec( clust_index = dict_table_get_first_index(node->table); ptr = trx_undo_update_rec_get_sys_cols(ptr, &trx_id, &roll_ptr, - &info_bits); + &info_bits); ptr = trx_undo_rec_get_row_ref(ptr, clust_index, &(node->ref), - node->heap); + node->heap); trx_undo_update_rec_get_update(ptr, clust_index, type, trx_id, - roll_ptr, info_bits, trx, - node->heap, &(node->update)); + roll_ptr, info_bits, trx, + node->heap, &(node->update)); node->new_roll_ptr = roll_ptr; node->new_trx_id = trx_id; node->cmpl_info = cmpl_info; @@ -738,8 +736,8 @@ row_undo_mod( return(DB_SUCCESS); } - node->index = dict_table_get_next_index( - dict_table_get_first_index(node->table)); + node->index = dict_table_get_next_index + (dict_table_get_first_index(node->table)); if (node->rec_type == TRX_UNDO_UPD_EXIST_REC) { diff --git a/storage/innobase/row/row0undo.c b/storage/innobase/row/row0undo.c index 3454f6e3274..2f04e65e8ee 100644 --- a/storage/innobase/row/row0undo.c +++ b/storage/innobase/row/row0undo.c @@ -161,15 +161,16 @@ row_undo_search_clust_to_pcur( clust_index = dict_table_get_first_index(node->table); found = row_search_on_row_ref(&(node->pcur), BTR_MODIFY_LEAF, - node->table, node->ref, &mtr); + node->table, node->ref, &mtr); rec = btr_pcur_get_rec(&(node->pcur)); offsets = rec_get_offsets(rec, clust_index, offsets, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (!found || 0 != ut_dulint_cmp(node->roll_ptr, - row_get_rec_roll_ptr(rec, clust_index, offsets))) { + row_get_rec_roll_ptr(rec, clust_index, + offsets))) { /* We must remove the reservation on the undo log record BEFORE releasing the latch on the clustered index page: this @@ -177,12 +178,12 @@ row_undo_search_clust_to_pcur( modification corresponding to node->roll_ptr. */ /* fputs("--------------------undoing a previous version\n", - stderr); */ + stderr); */ ret = FALSE; } else { node->row = row_build(ROW_COPY_DATA, clust_index, rec, - offsets, node->heap); + offsets, node->heap); btr_pcur_store_position(&(node->pcur), &mtr); ret = TRUE; @@ -221,9 +222,9 @@ row_undo( if (node->state == UNDO_NODE_FETCH_NEXT) { node->undo_rec = trx_roll_pop_top_rec_of_trx(trx, - trx->roll_limit, - &roll_ptr, - node->heap); + trx->roll_limit, + &roll_ptr, + node->heap); if (!node->undo_rec) { /* Rollback completed for this query thread */ @@ -250,7 +251,7 @@ row_undo( roll_ptr = node->new_roll_ptr; node->undo_rec = trx_undo_get_undo_rec_low(roll_ptr, - node->heap); + node->heap); node->roll_ptr = roll_ptr; node->undo_no = trx_undo_rec_get_undo_no(node->undo_rec); @@ -335,8 +336,9 @@ row_undo_step( if (err == DB_OUT_OF_FILE_SPACE) { fprintf(stderr, - "InnoDB: Error 13 means out of tablespace.\n" - "InnoDB: Consider increasing your tablespace.\n"); + "InnoDB: Error 13 means out of tablespace.\n" + "InnoDB: Consider increasing" + " your tablespace.\n"); exit(1); } diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c index 783a01bcaa0..84f5f2a1acf 100644 --- a/storage/innobase/row/row0upd.c +++ b/storage/innobase/row/row0upd.c @@ -196,10 +196,9 @@ row_upd_check_references_constraints( NOT break the constraint. */ if (foreign->referenced_index == index - && (node->is_delete - || row_upd_changes_first_fields_binary( - entry, index, node->update, - foreign->n_fields))) { + && (node->is_delete + || row_upd_changes_first_fields_binary + (entry, index, node->update, foreign->n_fields))) { if (foreign->foreign_table == NULL) { dict_table_get(foreign->foreign_table_name); @@ -209,7 +208,7 @@ row_upd_check_references_constraints( mutex_enter(&(dict_sys->mutex)); (foreign->foreign_table - ->n_foreign_key_checks_running)++; + ->n_foreign_key_checks_running)++; mutex_exit(&(dict_sys->mutex)); } @@ -219,25 +218,25 @@ row_upd_check_references_constraints( But the counter on the table protects 'foreign' from being dropped while the check is running. */ - err = row_ins_check_foreign_constraint(FALSE, foreign, - table, entry, thr); + err = row_ins_check_foreign_constraint + (FALSE, foreign, table, entry, thr); if (foreign->foreign_table) { mutex_enter(&(dict_sys->mutex)); ut_a(foreign->foreign_table - ->n_foreign_key_checks_running > 0); + ->n_foreign_key_checks_running > 0); (foreign->foreign_table - ->n_foreign_key_checks_running)--; + ->n_foreign_key_checks_running)--; mutex_exit(&(dict_sys->mutex)); } if (err != DB_SUCCESS) { if (got_s_lock) { - row_mysql_unfreeze_data_dictionary( - trx); + row_mysql_unfreeze_data_dictionary + (trx); } mem_heap_free(heap); @@ -389,16 +388,16 @@ row_upd_changes_field_size_or_external( this fix also to 4.0. The merge to 5.0 will be made manually immediately after we commit this to 4.1. */ - new_len = dtype_get_sql_null_size( - dict_index_get_nth_type(index, - upd_field->field_no)); + new_len = dtype_get_sql_null_size + (dict_index_get_nth_type(index, + upd_field->field_no)); } old_len = rec_offs_nth_size(offsets, upd_field->field_no); if (rec_offs_comp(offsets) - && rec_offs_nth_sql_null(offsets, - upd_field->field_no)) { + && rec_offs_nth_sql_null(offsets, + upd_field->field_no)) { /* Note that in the compact table format, for a variable length field, an SQL NULL will use zero bytes in the offset array at the start of the physical @@ -456,8 +455,8 @@ row_upd_rec_in_place( new_val = &(upd_field->new_val); rec_set_nth_field(rec, offsets, upd_field->field_no, - dfield_get_data(new_val), - dfield_get_len(new_val)); + dfield_get_data(new_val), + dfield_get_len(new_val)); } } @@ -480,7 +479,8 @@ row_upd_write_sys_vals_to_log( ut_ad(mtr); log_ptr += mach_write_compressed(log_ptr, - dict_index_get_sys_col_pos(index, DATA_TRX_ID)); + dict_index_get_sys_col_pos + (index, DATA_TRX_ID)); trx_write_roll_ptr(log_ptr, roll_ptr); log_ptr += DATA_ROLL_PTR_LEN; @@ -635,7 +635,7 @@ row_upd_index_parse( new_val = &(upd_field->new_val); ptr = mach_parse_compressed(ptr, end_ptr, - &(upd_field->field_no)); + &(upd_field->field_no)); if (ptr == NULL) { return(NULL); @@ -733,7 +733,7 @@ row_upd_build_sec_rec_difference_binary( n_diff = 0; offsets = rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); for (i = 0; i < dtuple_get_n_fields(entry); i++) { @@ -815,7 +815,7 @@ row_upd_build_difference_binary( trx_id_pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID); offsets = rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); for (i = 0; i < dtuple_get_n_fields(entry); i++) { @@ -833,9 +833,9 @@ row_upd_build_difference_binary( extern_bit = upd_ext_vec_contains(ext_vec, n_ext_vec, i); - if (UNIV_UNLIKELY(extern_bit == - (ibool)!rec_offs_nth_extern(offsets, i)) - || !dfield_data_is_binary_equal(dfield, len, data)) { + if (UNIV_UNLIKELY(extern_bit + == (ibool)!rec_offs_nth_extern(offsets, i)) + || !dfield_data_is_binary_equal(dfield, len, data)) { upd_field = upd_get_nth_field(update, n_diff); @@ -911,26 +911,24 @@ row_upd_index_replace_new_col_vals_index_pos( new_val = &(upd_field->new_val); dfield_set_data(dfield, new_val->data, - new_val->len); + new_val->len); if (heap && new_val->len != UNIV_SQL_NULL) { - dfield->data = mem_heap_alloc(heap, - new_val->len); + dfield->data = mem_heap_alloc + (heap, new_val->len); ut_memcpy(dfield->data, new_val->data, - new_val->len); + new_val->len); } if (field->prefix_len > 0 - && new_val->len != UNIV_SQL_NULL) { + && new_val->len != UNIV_SQL_NULL) { - cur_type = dict_col_get_type( - dict_field_get_col(field)); + cur_type = dict_col_get_type + (dict_field_get_col(field)); - dfield->len = - dtype_get_at_most_n_mbchars( - cur_type, - field->prefix_len, - new_val->len, - new_val->data); + dfield->len + = dtype_get_at_most_n_mbchars + (cur_type, field->prefix_len, + new_val->len, new_val->data); } } } @@ -981,26 +979,24 @@ row_upd_index_replace_new_col_vals( new_val = &(upd_field->new_val); dfield_set_data(dfield, new_val->data, - new_val->len); + new_val->len); if (heap && new_val->len != UNIV_SQL_NULL) { - dfield->data = mem_heap_alloc(heap, - new_val->len); + dfield->data = mem_heap_alloc + (heap, new_val->len); ut_memcpy(dfield->data, new_val->data, - new_val->len); + new_val->len); } if (field->prefix_len > 0 - && new_val->len != UNIV_SQL_NULL) { + && new_val->len != UNIV_SQL_NULL) { - cur_type = dict_col_get_type( - dict_field_get_col(field)); + cur_type = dict_col_get_type + (dict_field_get_col(field)); - dfield->len = - dtype_get_at_most_n_mbchars( - cur_type, - field->prefix_len, - new_val->len, - new_val->data); + dfield->len + = dtype_get_at_most_n_mbchars + (cur_type, field->prefix_len, + new_val->len, new_val->data); } } } @@ -1060,12 +1056,12 @@ row_upd_changes_ord_field_binary( the datas */ if (col_pos == upd_field->field_no - && (row == NULL - || ind_field->prefix_len > 0 - || !dfield_datas_are_binary_equal( - dtuple_get_nth_field(row, - col_no), - &(upd_field->new_val)))) { + && (row == NULL + || ind_field->prefix_len > 0 + || !dfield_datas_are_binary_equal + (dtuple_get_nth_field(row, col_no), + &(upd_field->new_val)))) { + return(TRUE); } } @@ -1096,9 +1092,9 @@ row_upd_changes_some_index_ord_field_binary( upd_field = upd_get_nth_field(update, i); - if (dict_field_get_col(dict_index_get_nth_field(index, - upd_field->field_no)) - ->ord_part) { + if (dict_field_get_col(dict_index_get_nth_field + (index, upd_field->field_no)) + ->ord_part) { return(TRUE); } @@ -1146,9 +1142,9 @@ row_upd_changes_first_fields_binary( upd_field = upd_get_nth_field(update, j); if (col_pos == upd_field->field_no - && !dfield_datas_are_binary_equal( - dtuple_get_nth_field(entry, i), - &(upd_field->new_val))) { + && !dfield_datas_are_binary_equal + (dtuple_get_nth_field(entry, i), + &(upd_field->new_val))) { return(TRUE); } @@ -1174,8 +1170,8 @@ row_upd_copy_columns( while (column) { data = rec_get_nth_field(rec, offsets, - column->field_nos[SYM_CLUST_FIELD_NO], - &len); + column->field_nos[SYM_CLUST_FIELD_NO], + &len); eval_node_copy_and_alloc_val(column, data, len); column = UT_LIST_GET_NEXT(col_var_list, column); @@ -1237,11 +1233,11 @@ row_upd_store_row( rec = btr_pcur_get_rec(node->pcur); offsets = rec_get_offsets(rec, clust_index, offsets_, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); node->row = row_build(ROW_COPY_DATA, clust_index, rec, offsets, - node->heap); + node->heap); node->ext_vec = mem_heap_alloc(node->heap, sizeof(ulint) - * rec_offs_n_fields(offsets)); + * rec_offs_n_fields(offsets)); if (node->is_delete) { update = NULL; } else { @@ -1249,7 +1245,7 @@ row_upd_store_row( } node->n_ext_vec = btr_push_update_extern_fields(node->ext_vec, - offsets, update); + offsets, update); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1291,44 +1287,44 @@ row_upd_sec_index_entry( mtr_start(&mtr); found = row_search_index_entry(index, entry, BTR_MODIFY_LEAF, &pcur, - &mtr); + &mtr); btr_cur = btr_pcur_get_btr_cur(&pcur); rec = btr_cur_get_rec(btr_cur); if (UNIV_UNLIKELY(!found)) { fputs("InnoDB: error in sec index entry update in\n" - "InnoDB: ", stderr); + "InnoDB: ", stderr); dict_index_name_print(stderr, trx, index); fputs("\n" - "InnoDB: tuple ", stderr); + "InnoDB: tuple ", stderr); dtuple_print(stderr, entry); fputs("\n" - "InnoDB: record ", stderr); + "InnoDB: record ", stderr); rec_print(stderr, rec, index); putc('\n', stderr); trx_print(stderr, trx, 0); fputs("\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n", stderr); } else { /* Delete mark the old index record; it can already be delete marked if we return after a lock wait in row_ins_index_entry below */ if (!rec_get_deleted_flag(rec, - dict_table_is_comp(index->table))) { + dict_table_is_comp(index->table))) { err = btr_cur_del_mark_set_sec_rec(0, btr_cur, TRUE, - thr, &mtr); + thr, &mtr); if (err == DB_SUCCESS && check_ref) { /* NOTE that the following call loses the position of pcur ! */ - err = row_upd_check_references_constraints( - node, - &pcur, index->table, - index, thr, &mtr); + err = row_upd_check_references_constraints + (node, &pcur, index->table, + index, thr, &mtr); if (err != DB_SUCCESS) { goto close_cur; @@ -1374,12 +1370,12 @@ row_upd_sec_step( ulint err; ut_ad((node->state == UPD_NODE_UPDATE_ALL_SEC) - || (node->state == UPD_NODE_UPDATE_SOME_SEC)); + || (node->state == UPD_NODE_UPDATE_SOME_SEC)); ut_ad(!(node->index->type & DICT_CLUSTERED)); if (node->state == UPD_NODE_UPDATE_ALL_SEC - || row_upd_changes_ord_field_binary(node->row, node->index, - node->update)) { + || row_upd_changes_ord_field_binary(node->row, node->index, + node->update)) { err = row_upd_sec_index_entry(node, thr); return(err); @@ -1427,7 +1423,7 @@ row_upd_clust_rec_by_insert( *offsets_ = (sizeof offsets_) / sizeof *offsets_; err = btr_cur_del_mark_set_clust_rec(BTR_NO_LOCKING_FLAG, - btr_cur, TRUE, thr, mtr); + btr_cur, TRUE, thr, mtr); if (err != DB_SUCCESS) { mtr_commit(mtr); return(err); @@ -1438,16 +1434,17 @@ row_upd_clust_rec_by_insert( free those externally stored fields even if the delete marked record is removed from the index tree, or updated. */ - btr_cur_mark_extern_inherited_fields(btr_cur_get_rec(btr_cur), - rec_get_offsets(btr_cur_get_rec(btr_cur), - dict_table_get_first_index(table), offsets_, - ULINT_UNDEFINED, &heap), node->update, mtr); + btr_cur_mark_extern_inherited_fields + (btr_cur_get_rec(btr_cur), + rec_get_offsets(btr_cur_get_rec(btr_cur), + dict_table_get_first_index(table), + offsets_, ULINT_UNDEFINED, &heap), + node->update, mtr); if (check_ref) { /* NOTE that the following call loses the position of pcur ! */ - err = row_upd_check_references_constraints(node, - pcur, table, - index, thr, mtr); + err = row_upd_check_references_constraints + (node, pcur, table, index, thr, mtr); if (err != DB_SUCCESS) { mtr_commit(mtr); if (UNIV_LIKELY_NULL(heap)) { @@ -1477,16 +1474,16 @@ row_upd_clust_rec_by_insert( if-branch above). We must unmark them. */ btr_cur_unmark_dtuple_extern_fields(entry, node->ext_vec, - node->n_ext_vec); + node->n_ext_vec); /* We must mark non-updated extern fields in entry as inherited, so that a possible rollback will not free them */ btr_cur_mark_dtuple_inherited_extern(entry, node->ext_vec, - node->n_ext_vec, - node->update); + node->n_ext_vec, + node->update); err = row_ins_index_entry(index, entry, node->ext_vec, - node->n_ext_vec, thr); + node->n_ext_vec, thr); mem_heap_free(heap); return(err); @@ -1518,7 +1515,7 @@ row_upd_clust_rec( btr_cur = btr_pcur_get_btr_cur(pcur); ut_ad(!rec_get_deleted_flag(btr_pcur_get_rec(pcur), - dict_table_is_comp(index->table))); + dict_table_is_comp(index->table))); /* Try optimistic updating of the record, keeping changes within the page; we do not check locks because we assume the x-lock on the @@ -1526,8 +1523,8 @@ row_upd_clust_rec( if (node->cmpl_info & UPD_NODE_NO_SIZE_CHANGE) { err = btr_cur_update_in_place(BTR_NO_LOCKING_FLAG, - btr_cur, node->update, - node->cmpl_info, thr, mtr); + btr_cur, node->update, + node->cmpl_info, thr, mtr); } else { err = btr_cur_optimistic_update(BTR_NO_LOCKING_FLAG, btr_cur, node->update, @@ -1559,11 +1556,11 @@ row_upd_clust_rec( ut_a(btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr)); ut_ad(!rec_get_deleted_flag(btr_pcur_get_rec(pcur), - dict_table_is_comp(index->table))); + dict_table_is_comp(index->table))); err = btr_cur_pessimistic_update(BTR_NO_LOCKING_FLAG, btr_cur, - &big_rec, node->update, - node->cmpl_info, thr, mtr); + &big_rec, node->update, + node->cmpl_info, thr, mtr); mtr_commit(mtr); if (err == DB_SUCCESS && big_rec) { @@ -1576,10 +1573,11 @@ row_upd_clust_rec( ut_a(btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr)); rec = btr_cur_get_rec(btr_cur); - err = btr_store_big_rec_extern_fields(index, rec, - rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &heap), - big_rec, mtr); + err = btr_store_big_rec_extern_fields + (index, rec, + rec_get_offsets(rec, index, offsets_, + ULINT_UNDEFINED, &heap), + big_rec, mtr); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1628,13 +1626,13 @@ row_upd_del_mark_clust_rec( locks, because we assume that we have an x-lock on the record */ err = btr_cur_del_mark_set_clust_rec(BTR_NO_LOCKING_FLAG, - btr_cur, TRUE, thr, mtr); + btr_cur, TRUE, thr, mtr); if (err == DB_SUCCESS && check_ref) { /* NOTE that the following call loses the position of pcur ! */ err = row_upd_check_references_constraints(node, - pcur, index->table, - index, thr, mtr); + pcur, index->table, + index, thr, mtr); if (err != DB_SUCCESS) { mtr_commit(mtr); @@ -1708,7 +1706,7 @@ row_upd_clust_step( with the index */ if (node->is_delete - && ut_dulint_cmp(node->table->id, DICT_INDEXES_ID) == 0) { + && ut_dulint_cmp(node->table->id, DICT_INDEXES_ID) == 0) { dict_drop_index_tree(btr_pcur_get_rec(pcur), mtr); @@ -1717,7 +1715,7 @@ row_upd_clust_step( mtr_start(mtr); success = btr_pcur_restore_position(BTR_MODIFY_LEAF, pcur, - mtr); + mtr); if (!success) { err = DB_ERROR; @@ -1729,11 +1727,11 @@ row_upd_clust_step( rec = btr_pcur_get_rec(pcur); offsets = rec_get_offsets(rec, index, offsets_, - ULINT_UNDEFINED, &heap); + ULINT_UNDEFINED, &heap); if (!node->has_clust_rec_x_lock) { - err = lock_clust_rec_modify_check_and_lock(0, - rec, index, offsets, thr); + err = lock_clust_rec_modify_check_and_lock + (0, rec, index, offsets, thr); if (err != DB_SUCCESS) { mtr_commit(mtr); goto exit_func; @@ -1744,12 +1742,12 @@ row_upd_clust_step( if (node->is_delete) { err = row_upd_del_mark_clust_rec(node, index, thr, check_ref, - mtr); + mtr); if (err == DB_SUCCESS) { node->state = UPD_NODE_UPDATE_ALL_SEC; node->index = dict_table_get_next_index(index); } - exit_func: +exit_func: if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1763,7 +1761,7 @@ row_upd_clust_step( /* Copy the necessary columns from clust_rec and calculate the new values to set */ row_upd_copy_columns(rec, offsets, - UT_LIST_GET_FIRST(node->columns)); + UT_LIST_GET_FIRST(node->columns)); row_upd_eval_new_vals(node->update); } @@ -1793,7 +1791,7 @@ row_upd_clust_step( externally! */ err = row_upd_clust_rec_by_insert(node, index, thr, check_ref, - mtr); + mtr); if (err != DB_SUCCESS) { return(err); @@ -1838,9 +1836,9 @@ row_upd( /* We do not get the cmpl_info value from the MySQL interpreter: we must calculate it on the fly: */ - if (node->is_delete || - row_upd_changes_some_index_ord_field_binary( - node->table, node->update)) { + if (node->is_delete + || row_upd_changes_some_index_ord_field_binary + (node->table, node->update)) { node->cmpl_info = 0; } else { node->cmpl_info = UPD_NODE_NO_ORD_CHANGE; @@ -1848,7 +1846,7 @@ row_upd( } if (node->state == UPD_NODE_UPDATE_CLUSTERED - || node->state == UPD_NODE_INSERT_CLUSTERED) { + || node->state == UPD_NODE_INSERT_CLUSTERED) { err = row_upd_clust_step(node, thr); @@ -2038,24 +2036,26 @@ row_upd_in_place_in_select( /* Copy the necessary columns from clust_rec and calculate the new values to set */ - row_upd_copy_columns(btr_pcur_get_rec(pcur), rec_get_offsets( - btr_pcur_get_rec(pcur), btr_cur->index, offsets_, - ULINT_UNDEFINED, &heap), - UT_LIST_GET_FIRST(node->columns)); + row_upd_copy_columns(btr_pcur_get_rec(pcur), + rec_get_offsets(btr_pcur_get_rec(pcur), + btr_cur->index, offsets_, + ULINT_UNDEFINED, &heap), + UT_LIST_GET_FIRST(node->columns)); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } row_upd_eval_new_vals(node->update); - ut_ad(!rec_get_deleted_flag(btr_pcur_get_rec(pcur), - dict_table_is_comp(btr_cur->index->table))); + ut_ad(!rec_get_deleted_flag + (btr_pcur_get_rec(pcur), + dict_table_is_comp(btr_cur->index->table))); ut_ad(node->cmpl_info & UPD_NODE_NO_SIZE_CHANGE); ut_ad(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE); ut_ad(node->select_will_do_update); err = btr_cur_update_in_place(BTR_NO_LOCKING_FLAG, btr_cur, - node->update, node->cmpl_info, - thr, mtr); + node->update, node->cmpl_info, + thr, mtr); ut_ad(err == DB_SUCCESS); } diff --git a/storage/innobase/row/row0vers.c b/storage/innobase/row/row0vers.c index 07b75a34347..9b51314df7b 100644 --- a/storage/innobase/row/row0vers.c +++ b/storage/innobase/row/row0vers.c @@ -79,7 +79,7 @@ row_vers_impl_x_locked_off_kernel( reserve purge_latch to lock the bottom of the version stack. */ clust_rec = row_get_clust_rec(BTR_SEARCH_LEAF, rec, index, - &clust_index, &mtr); + &clust_index, &mtr); if (!clust_rec) { /* In a rare case it is possible that no clust rec is found for a secondary index record: if in row0umod.c @@ -116,7 +116,7 @@ row_vers_impl_x_locked_off_kernel( } if (!lock_check_trx_id_sanity(trx_id, clust_rec, clust_index, - clust_offsets, TRUE)) { + clust_offsets, TRUE)) { /* Corruption noticed: try to avoid a crash by returning */ goto exit_func; } @@ -153,14 +153,14 @@ row_vers_impl_x_locked_off_kernel( heap2 = heap; heap = mem_heap_create(1024); err = trx_undo_prev_version_build(clust_rec, &mtr, version, - clust_index, clust_offsets, heap, - &prev_version); + clust_index, clust_offsets, + heap, &prev_version); mem_heap_free(heap2); /* free version and clust_offsets */ if (prev_version) { - clust_offsets = rec_get_offsets(prev_version, - clust_index, NULL, - ULINT_UNDEFINED, &heap); + clust_offsets = rec_get_offsets + (prev_version, clust_index, NULL, + ULINT_UNDEFINED, &heap); row = row_build(ROW_COPY_POINTERS, clust_index, prev_version, clust_offsets, heap); entry = row_build_index_entry(row, index, heap); @@ -232,7 +232,7 @@ row_vers_impl_x_locked_off_kernel( } prev_trx_id = row_get_rec_trx_id(prev_version, clust_index, - clust_offsets); + clust_offsets); if (0 != ut_dulint_cmp(trx_id, prev_trx_id)) { /* The versions modified by the trx_id transaction end @@ -313,8 +313,8 @@ row_vers_old_has_index_entry( ulint comp; ut_ad(mtr_memo_contains(mtr, buf_block_align(rec), MTR_MEMO_PAGE_X_FIX) - || mtr_memo_contains(mtr, buf_block_align(rec), - MTR_MEMO_PAGE_S_FIX)); + || mtr_memo_contains(mtr, buf_block_align(rec), + MTR_MEMO_PAGE_S_FIX)); #ifdef UNIV_SYNC_DEBUG ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED)); #endif /* UNIV_SYNC_DEBUG */ @@ -330,7 +330,7 @@ row_vers_old_has_index_entry( if (also_curr && !rec_get_deleted_flag(rec, comp)) { row = row_build(ROW_COPY_POINTERS, clust_index, - rec, clust_offsets, heap); + rec, clust_offsets, heap); entry = row_build_index_entry(row, index, heap); /* NOTE that we cannot do the comparison as binary @@ -353,8 +353,8 @@ row_vers_old_has_index_entry( heap2 = heap; heap = mem_heap_create(1024); err = trx_undo_prev_version_build(rec, mtr, version, - clust_index, clust_offsets, heap, - &prev_version); + clust_index, clust_offsets, + heap, &prev_version); mem_heap_free(heap2); /* free version and clust_offsets */ if (err != DB_SUCCESS || !prev_version) { @@ -428,8 +428,8 @@ row_vers_build_for_consistent_read( ut_ad(index->type & DICT_CLUSTERED); ut_ad(mtr_memo_contains(mtr, buf_block_align(rec), MTR_MEMO_PAGE_X_FIX) - || mtr_memo_contains(mtr, buf_block_align(rec), - MTR_MEMO_PAGE_S_FIX)); + || mtr_memo_contains(mtr, buf_block_align(rec), + MTR_MEMO_PAGE_S_FIX)); #ifdef UNIV_SYNC_DEBUG ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED)); #endif /* UNIV_SYNC_DEBUG */ @@ -455,23 +455,24 @@ row_vers_build_for_consistent_read( the record we see this record only in the case when undo_no of the record is < undo_no in the view. */ - if (view->type == VIEW_HIGH_GRANULARITY - && ut_dulint_cmp(view->creator_trx_id, trx_id) == 0) { + if (view->type == VIEW_HIGH_GRANULARITY + && ut_dulint_cmp(view->creator_trx_id, trx_id) == 0) { - roll_ptr = row_get_rec_roll_ptr(version, index, - *offsets); + roll_ptr = row_get_rec_roll_ptr(version, index, + *offsets); undo_rec = trx_undo_get_undo_rec_low(roll_ptr, heap); undo_no = trx_undo_rec_get_undo_no(undo_rec); mem_heap_empty(heap); if (ut_dulint_cmp(view->undo_no, undo_no) > 0) { - /* The view already sees this version: we can + /* The view already sees this version: we can copy it to in_heap and return */ - buf = mem_heap_alloc(in_heap, - rec_offs_size(*offsets)); + buf = mem_heap_alloc(in_heap, + rec_offs_size(*offsets)); *old_vers = rec_copy(buf, version, *offsets); - rec_offs_make_valid(*old_vers, index, *offsets); + rec_offs_make_valid(*old_vers, index, + *offsets); err = DB_SUCCESS; break; @@ -479,7 +480,8 @@ row_vers_build_for_consistent_read( } err = trx_undo_prev_version_build(rec, mtr, version, index, - *offsets, heap, &prev_version); + *offsets, heap, + &prev_version); if (heap2) { mem_heap_free(heap2); /* free version */ } @@ -497,7 +499,7 @@ row_vers_build_for_consistent_read( } *offsets = rec_get_offsets(prev_version, index, *offsets, - ULINT_UNDEFINED, offset_heap); + ULINT_UNDEFINED, offset_heap); trx_id = row_get_rec_trx_id(prev_version, index, *offsets); @@ -557,8 +559,8 @@ row_vers_build_for_semi_consistent_read( ut_ad(index->type & DICT_CLUSTERED); ut_ad(mtr_memo_contains(mtr, buf_block_align(rec), MTR_MEMO_PAGE_X_FIX) - || mtr_memo_contains(mtr, buf_block_align(rec), - MTR_MEMO_PAGE_S_FIX)); + || mtr_memo_contains(mtr, buf_block_align(rec), + MTR_MEMO_PAGE_S_FIX)); #ifdef UNIV_SYNC_DEBUG ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED)); #endif /* UNIV_SYNC_DEBUG */ @@ -579,8 +581,7 @@ row_vers_build_for_semi_consistent_read( rec_t* prev_version; dulint version_trx_id; - version_trx_id = row_get_rec_trx_id( - version, index, *offsets); + version_trx_id = row_get_rec_trx_id(version, index, *offsets); if (rec == version) { rec_trx_id = version_trx_id; } @@ -590,8 +591,8 @@ row_vers_build_for_semi_consistent_read( mutex_exit(&kernel_mutex); if (!version_trx - || version_trx->conc_state == TRX_NOT_STARTED - || version_trx->conc_state == TRX_COMMITTED_IN_MEMORY) { + || version_trx->conc_state == TRX_NOT_STARTED + || version_trx->conc_state == TRX_COMMITTED_IN_MEMORY) { /* We found a version that belongs to a committed transaction: return it. */ @@ -615,8 +616,9 @@ row_vers_build_for_semi_consistent_read( version = rec; *offsets = rec_get_offsets(version, - index, *offsets, - ULINT_UNDEFINED, offset_heap); + index, *offsets, + ULINT_UNDEFINED, + offset_heap); } buf = mem_heap_alloc(in_heap, rec_offs_size(*offsets)); @@ -631,7 +633,8 @@ row_vers_build_for_semi_consistent_read( heap = mem_heap_create(1024); err = trx_undo_prev_version_build(rec, mtr, version, index, - *offsets, heap, &prev_version); + *offsets, heap, + &prev_version); if (heap2) { mem_heap_free(heap2); /* free version */ } @@ -650,7 +653,7 @@ row_vers_build_for_semi_consistent_read( version = prev_version; *offsets = rec_get_offsets(version, index, *offsets, - ULINT_UNDEFINED, offset_heap); + ULINT_UNDEFINED, offset_heap); }/* for (;;) */ if (heap) { diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index a475db031a3..b781a601039 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -85,10 +85,13 @@ ibool srv_file_per_table = FALSE; /* store to its own file each table created by an user; data dictionary tables are in the system tablespace 0 */ -ibool srv_locks_unsafe_for_binlog = FALSE; /* Place locks to records only - i.e. do not use next-key locking - except on duplicate key checking and - foreign key checking */ +ibool srv_locks_unsafe_for_binlog = FALSE; /* Place locks to + records only i.e. do + not use next-key + locking except on + duplicate key checking + and foreign key + checking */ ulint srv_n_data_files = 0; char** srv_data_file_names = NULL; ulint* srv_data_file_sizes = NULL; /* size in database pages */ @@ -793,9 +796,11 @@ srv_release_threads( if (srv_print_thread_releases) { fprintf(stderr, - "Releasing thread %lu type %lu from slot %lu meter %lu\n", - (ulong) slot->id, (ulong) type, (ulong) i, - (ulong) srv_meter[SRV_RECOVERY]); + "Releasing thread %lu type %lu" + " from slot %lu meter %lu\n", + (ulong) slot->id, (ulong) type, + (ulong) i, + (ulong) srv_meter[SRV_RECOVERY]); } count++; @@ -892,24 +897,24 @@ srv_init(void) /* create dummy table and index for old-style infimum and supremum */ table = dict_mem_table_create("SYS_DUMMY1", - DICT_HDR_SPACE, 1, 0); + DICT_HDR_SPACE, 1, 0); dict_mem_table_add_col(table, "DUMMY", DATA_CHAR, - DATA_ENGLISH | DATA_NOT_NULL, 8, 0); + DATA_ENGLISH | DATA_NOT_NULL, 8, 0); - srv_sys->dummy_ind1 = dict_mem_index_create("SYS_DUMMY1", - "SYS_DUMMY1", DICT_HDR_SPACE, 0, 1); + srv_sys->dummy_ind1 = dict_mem_index_create + ("SYS_DUMMY1", "SYS_DUMMY1", DICT_HDR_SPACE, 0, 1); dict_index_add_col(srv_sys->dummy_ind1, - dict_table_get_nth_col(table, 0), 0); + dict_table_get_nth_col(table, 0), 0); srv_sys->dummy_ind1->table = table; /* create dummy table and index for new-style infimum and supremum */ table = dict_mem_table_create("SYS_DUMMY2", - DICT_HDR_SPACE, 1, DICT_TF_COMPACT); + DICT_HDR_SPACE, 1, DICT_TF_COMPACT); dict_mem_table_add_col(table, "DUMMY", DATA_CHAR, - DATA_ENGLISH | DATA_NOT_NULL, 8, 0); - srv_sys->dummy_ind2 = dict_mem_index_create("SYS_DUMMY2", - "SYS_DUMMY2", DICT_HDR_SPACE, 0, 1); + DATA_ENGLISH | DATA_NOT_NULL, 8, 0); + srv_sys->dummy_ind2 = dict_mem_index_create + ("SYS_DUMMY2", "SYS_DUMMY2", DICT_HDR_SPACE, 0, 1); dict_index_add_col(srv_sys->dummy_ind2, - dict_table_get_nth_col(table, 0), 0); + dict_table_get_nth_col(table, 0), 0); srv_sys->dummy_ind2->table = table; /* avoid ut_ad(index->cached) in dict_index_get_n_unique_in_tree */ @@ -987,9 +992,9 @@ srv_conc_enter_innodb( retry: if (trx->declared_to_be_inside_innodb) { ut_print_timestamp(stderr); - fputs( -" InnoDB: Error: trying to declare trx to enter InnoDB, but\n" -"InnoDB: it already is declared.\n", stderr); + fputs(" InnoDB: Error: trying to declare trx" + " to enter InnoDB, but\n" + "InnoDB: it already is declared.\n", stderr); trx_print(stderr, trx, 0); putc('\n', stderr); os_fast_mutex_unlock(&srv_conc_mutex); @@ -1008,11 +1013,11 @@ retry: return; } - /* If the transaction is not holding resources, - let it sleep for SRV_THREAD_SLEEP_DELAY microseconds, and try again then */ + /* If the transaction is not holding resources, let it sleep + for SRV_THREAD_SLEEP_DELAY microseconds, and try again then */ if (!has_slept && !trx->has_search_latch - && NULL == UT_LIST_GET_FIRST(trx->trx_locks)) { + && NULL == UT_LIST_GET_FIRST(trx->trx_locks)) { has_slept = TRUE; /* We let is sleep only once to avoid starvation */ @@ -1227,11 +1232,11 @@ srv_normalize_init_values(void) for (i = 0; i < n; i++) { srv_data_file_sizes[i] = srv_data_file_sizes[i] - * ((1024 * 1024) / UNIV_PAGE_SIZE); + * ((1024 * 1024) / UNIV_PAGE_SIZE); } srv_last_file_size_max = srv_last_file_size_max - * ((1024 * 1024) / UNIV_PAGE_SIZE); + * ((1024 * 1024) / UNIV_PAGE_SIZE); srv_log_file_size = srv_log_file_size / UNIV_PAGE_SIZE; @@ -1313,21 +1318,29 @@ srv_table_reserve_slot_for_mysql(void) ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: There appear to be %lu MySQL threads currently waiting\n" -"InnoDB: inside InnoDB, which is the upper limit. Cannot continue operation.\n" -"InnoDB: We intentionally generate a seg fault to print a stack trace\n" -"InnoDB: on Linux. But first we print a list of waiting threads.\n", (ulong) i); + " InnoDB: There appear to be %lu MySQL" + " threads currently waiting\n" + "InnoDB: inside InnoDB, which is the" + " upper limit. Cannot continue operation.\n" + "InnoDB: We intentionally generate" + " a seg fault to print a stack trace\n" + "InnoDB: on Linux. But first we print" + " a list of waiting threads.\n", (ulong) i); for (i = 0; i < OS_THREAD_MAX_N; i++) { slot = srv_mysql_table + i; fprintf(stderr, -"Slot %lu: thread id %lu, type %lu, in use %lu, susp %lu, time %lu\n", - (ulong) i, (ulong) os_thread_pf(slot->id), - (ulong) slot->type, (ulong) slot->in_use, - (ulong) slot->suspended, - (ulong) difftime(ut_time(), slot->suspend_time)); + "Slot %lu: thread id %lu, type %lu," + " in use %lu, susp %lu, time %lu\n", + (ulong) i, + (ulong) os_thread_pf(slot->id), + (ulong) slot->type, + (ulong) slot->in_use, + (ulong) slot->suspended, + (ulong) difftime(ut_time(), + slot->suspend_time)); } ut_error; @@ -1493,8 +1506,8 @@ srv_suspend_mysql_thread( mutex_exit(&kernel_mutex); - if (srv_lock_wait_timeout < 100000000 && - wait_time > (double)srv_lock_wait_timeout) { + if (srv_lock_wait_timeout < 100000000 + && wait_time > (double)srv_lock_wait_timeout) { trx->error_state = DB_LOCK_WAIT_TIMEOUT; } @@ -1600,7 +1613,7 @@ srv_printf_innodb_monitor( time */ time_elapsed = difftime(current_time, srv_last_monitor_time) - + 0.001; + + 0.001; srv_last_monitor_time = time(NULL); @@ -1614,8 +1627,8 @@ srv_printf_innodb_monitor( (ulong)time_elapsed); fputs("----------\n" - "SEMAPHORES\n" - "----------\n", file); + "SEMAPHORES\n" + "----------\n", file); sync_print(file); /* Conceptually, srv_innodb_monitor_mutex has a very high latching @@ -1627,8 +1640,8 @@ srv_printf_innodb_monitor( if (ftell(dict_foreign_err_file) != 0L) { fputs("------------------------\n" - "LATEST FOREIGN KEY ERROR\n" - "------------------------\n", file); + "LATEST FOREIGN KEY ERROR\n" + "------------------------\n", file); ut_copy_file(file, dict_foreign_err_file); } @@ -1653,64 +1666,66 @@ srv_printf_innodb_monitor( } } fputs("--------\n" - "FILE I/O\n" - "--------\n", file); + "FILE I/O\n" + "--------\n", file); os_aio_print(file); fputs("-------------------------------------\n" - "INSERT BUFFER AND ADAPTIVE HASH INDEX\n" - "-------------------------------------\n", file); + "INSERT BUFFER AND ADAPTIVE HASH INDEX\n" + "-------------------------------------\n", file); ibuf_print(file); ha_print_info(file, btr_search_sys->hash_index); fprintf(file, "%.2f hash searches/s, %.2f non-hash searches/s\n", - (btr_cur_n_sea - btr_cur_n_sea_old) - / time_elapsed, - (btr_cur_n_non_sea - btr_cur_n_non_sea_old) - / time_elapsed); + (btr_cur_n_sea - btr_cur_n_sea_old) + / time_elapsed, + (btr_cur_n_non_sea - btr_cur_n_non_sea_old) + / time_elapsed); btr_cur_n_sea_old = btr_cur_n_sea; btr_cur_n_non_sea_old = btr_cur_n_non_sea; fputs("---\n" - "LOG\n" - "---\n", file); + "LOG\n" + "---\n", file); log_print(file); fputs("----------------------\n" - "BUFFER POOL AND MEMORY\n" - "----------------------\n", file); + "BUFFER POOL AND MEMORY\n" + "----------------------\n", file); fprintf(file, - "Total memory allocated " ULINTPF - "; in additional pool allocated " ULINTPF "\n", - ut_total_allocated_memory, - mem_pool_get_reserved(mem_comm_pool)); + "Total memory allocated " ULINTPF + "; in additional pool allocated " ULINTPF "\n", + ut_total_allocated_memory, + mem_pool_get_reserved(mem_comm_pool)); fprintf(file, "Dictionary memory allocated " ULINTPF "\n", dict_sys->size); if (srv_use_awe) { fprintf(file, - "In addition to that %lu MB of AWE memory allocated\n", - (ulong) (srv_pool_size / ((1024 * 1024) / UNIV_PAGE_SIZE))); + "In addition to that %lu MB of AWE memory allocated\n", + (ulong) (srv_pool_size + / ((1024 * 1024) / UNIV_PAGE_SIZE))); } buf_print_io(file); fputs("--------------\n" - "ROW OPERATIONS\n" - "--------------\n", file); + "ROW OPERATIONS\n" + "--------------\n", file); fprintf(file, "%ld queries inside InnoDB, %lu queries in queue\n", (long) srv_conc_n_threads, (ulong) srv_conc_n_waiting_threads); fprintf(file, "%lu read views open inside InnoDB\n", - UT_LIST_GET_LEN(trx_sys->view_list)); + UT_LIST_GET_LEN(trx_sys->view_list)); n_reserved = fil_space_get_n_reserved_extents(0); if (n_reserved > 0) { fprintf(file, - "%lu tablespace extents now reserved for B-tree split operations\n", + "%lu tablespace extents now reserved for" + " B-tree split operations\n", (ulong) n_reserved); } @@ -1721,35 +1736,37 @@ srv_printf_innodb_monitor( srv_main_thread_op_info); #else fprintf(file, "Main thread id %lu, state: %s\n", - (ulong) srv_main_thread_id, - srv_main_thread_op_info); + (ulong) srv_main_thread_id, + srv_main_thread_op_info); #endif fprintf(file, - "Number of rows inserted " ULINTPF - ", updated " ULINTPF ", deleted " ULINTPF ", read " ULINTPF "\n", - srv_n_rows_inserted, - srv_n_rows_updated, - srv_n_rows_deleted, - srv_n_rows_read); + "Number of rows inserted " ULINTPF + ", updated " ULINTPF ", deleted " ULINTPF + ", read " ULINTPF "\n", + srv_n_rows_inserted, + srv_n_rows_updated, + srv_n_rows_deleted, + srv_n_rows_read); fprintf(file, - "%.2f inserts/s, %.2f updates/s, %.2f deletes/s, %.2f reads/s\n", - (srv_n_rows_inserted - srv_n_rows_inserted_old) - / time_elapsed, - (srv_n_rows_updated - srv_n_rows_updated_old) - / time_elapsed, - (srv_n_rows_deleted - srv_n_rows_deleted_old) - / time_elapsed, - (srv_n_rows_read - srv_n_rows_read_old) - / time_elapsed); + "%.2f inserts/s, %.2f updates/s," + " %.2f deletes/s, %.2f reads/s\n", + (srv_n_rows_inserted - srv_n_rows_inserted_old) + / time_elapsed, + (srv_n_rows_updated - srv_n_rows_updated_old) + / time_elapsed, + (srv_n_rows_deleted - srv_n_rows_deleted_old) + / time_elapsed, + (srv_n_rows_read - srv_n_rows_read_old) + / time_elapsed); - srv_n_rows_inserted_old = srv_n_rows_inserted; + srv_n_rows_inserted_old = srv_n_rows_inserted; srv_n_rows_updated_old = srv_n_rows_updated; srv_n_rows_deleted_old = srv_n_rows_deleted; srv_n_rows_read_old = srv_n_rows_read; - fputs("----------------------------\n" - "END OF INNODB MONITOR OUTPUT\n" - "============================\n", file); + fputs("----------------------------\n" + "END OF INNODB MONITOR OUTPUT\n" + "============================\n", file); mutex_exit(&srv_innodb_monitor_mutex); fflush(file); } @@ -1760,60 +1777,72 @@ Function to pass InnoDB status variables to MySQL */ void srv_export_innodb_status(void) { - mutex_enter(&srv_innodb_monitor_mutex); - export_vars.innodb_data_pending_reads= os_n_pending_reads; - export_vars.innodb_data_pending_writes= os_n_pending_writes; - export_vars.innodb_data_pending_fsyncs= - fil_n_pending_log_flushes + fil_n_pending_tablespace_flushes; - export_vars.innodb_data_fsyncs= os_n_fsyncs; - export_vars.innodb_data_read= srv_data_read; - export_vars.innodb_data_reads= os_n_file_reads; - export_vars.innodb_data_writes= os_n_file_writes; - export_vars.innodb_data_written= srv_data_written; - export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets; - export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests; - export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free; - export_vars.innodb_buffer_pool_pages_flushed= srv_buf_pool_flushed; - export_vars.innodb_buffer_pool_reads= srv_buf_pool_reads; - export_vars.innodb_buffer_pool_read_ahead_rnd= srv_read_ahead_rnd; - export_vars.innodb_buffer_pool_read_ahead_seq= srv_read_ahead_seq; - export_vars.innodb_buffer_pool_pages_data= UT_LIST_GET_LEN(buf_pool->LRU); - export_vars.innodb_buffer_pool_pages_dirty= UT_LIST_GET_LEN(buf_pool->flush_list); - export_vars.innodb_buffer_pool_pages_free= UT_LIST_GET_LEN(buf_pool->free); - export_vars.innodb_buffer_pool_pages_latched= buf_get_latched_pages_number(); - export_vars.innodb_buffer_pool_pages_total= buf_pool->curr_size; - export_vars.innodb_buffer_pool_pages_misc= buf_pool->max_size - - UT_LIST_GET_LEN(buf_pool->LRU) - UT_LIST_GET_LEN(buf_pool->free); - export_vars.innodb_page_size= UNIV_PAGE_SIZE; - export_vars.innodb_log_waits= srv_log_waits; - export_vars.innodb_os_log_written= srv_os_log_written; - export_vars.innodb_os_log_fsyncs= fil_n_log_flushes; - export_vars.innodb_os_log_pending_fsyncs= fil_n_pending_log_flushes; - export_vars.innodb_os_log_pending_writes= srv_os_log_pending_writes; - export_vars.innodb_log_write_requests= srv_log_write_requests; - export_vars.innodb_log_writes= srv_log_writes; - export_vars.innodb_dblwr_pages_written= srv_dblwr_pages_written; - export_vars.innodb_dblwr_writes= srv_dblwr_writes; - export_vars.innodb_pages_created= buf_pool->n_pages_created; - export_vars.innodb_pages_read= buf_pool->n_pages_read; - export_vars.innodb_pages_written= buf_pool->n_pages_written; - export_vars.innodb_row_lock_waits= srv_n_lock_wait_count; - export_vars.innodb_row_lock_current_waits= srv_n_lock_wait_current_count; - export_vars.innodb_row_lock_time= srv_n_lock_wait_time / 10000; + + export_vars.innodb_data_pending_reads + = os_n_pending_reads; + export_vars.innodb_data_pending_writes + = os_n_pending_writes; + export_vars.innodb_data_pending_fsyncs + = fil_n_pending_log_flushes + + fil_n_pending_tablespace_flushes; + export_vars.innodb_data_fsyncs = os_n_fsyncs; + export_vars.innodb_data_read = srv_data_read; + export_vars.innodb_data_reads = os_n_file_reads; + export_vars.innodb_data_writes = os_n_file_writes; + export_vars.innodb_data_written = srv_data_written; + export_vars.innodb_buffer_pool_read_requests = buf_pool->n_page_gets; + export_vars.innodb_buffer_pool_write_requests + = srv_buf_pool_write_requests; + export_vars.innodb_buffer_pool_wait_free = srv_buf_pool_wait_free; + export_vars.innodb_buffer_pool_pages_flushed = srv_buf_pool_flushed; + export_vars.innodb_buffer_pool_reads = srv_buf_pool_reads; + export_vars.innodb_buffer_pool_read_ahead_rnd = srv_read_ahead_rnd; + export_vars.innodb_buffer_pool_read_ahead_seq = srv_read_ahead_seq; + export_vars.innodb_buffer_pool_pages_data + = UT_LIST_GET_LEN(buf_pool->LRU); + export_vars.innodb_buffer_pool_pages_dirty + = UT_LIST_GET_LEN(buf_pool->flush_list); + export_vars.innodb_buffer_pool_pages_free + = UT_LIST_GET_LEN(buf_pool->free); + export_vars.innodb_buffer_pool_pages_latched + = buf_get_latched_pages_number(); + export_vars.innodb_buffer_pool_pages_total = buf_pool->curr_size; + + export_vars.innodb_buffer_pool_pages_misc = buf_pool->max_size + - UT_LIST_GET_LEN(buf_pool->LRU) + - UT_LIST_GET_LEN(buf_pool->free); + export_vars.innodb_page_size = UNIV_PAGE_SIZE; + export_vars.innodb_log_waits = srv_log_waits; + export_vars.innodb_os_log_written = srv_os_log_written; + export_vars.innodb_os_log_fsyncs = fil_n_log_flushes; + export_vars.innodb_os_log_pending_fsyncs = fil_n_pending_log_flushes; + export_vars.innodb_os_log_pending_writes = srv_os_log_pending_writes; + export_vars.innodb_log_write_requests = srv_log_write_requests; + export_vars.innodb_log_writes = srv_log_writes; + export_vars.innodb_dblwr_pages_written = srv_dblwr_pages_written; + export_vars.innodb_dblwr_writes = srv_dblwr_writes; + export_vars.innodb_pages_created = buf_pool->n_pages_created; + export_vars.innodb_pages_read = buf_pool->n_pages_read; + export_vars.innodb_pages_written = buf_pool->n_pages_written; + export_vars.innodb_row_lock_waits = srv_n_lock_wait_count; + export_vars.innodb_row_lock_current_waits + = srv_n_lock_wait_current_count; + export_vars.innodb_row_lock_time = srv_n_lock_wait_time / 10000; if (srv_n_lock_wait_count > 0) { export_vars.innodb_row_lock_time_avg = (ulint) (srv_n_lock_wait_time / 10000 / srv_n_lock_wait_count); } else { export_vars.innodb_row_lock_time_avg = 0; } - export_vars.innodb_row_lock_time_max= srv_n_lock_max_wait_time / 10000; - export_vars.innodb_rows_read= srv_n_rows_read; - export_vars.innodb_rows_inserted= srv_n_rows_inserted; - export_vars.innodb_rows_updated= srv_n_rows_updated; - export_vars.innodb_rows_deleted= srv_n_rows_deleted; - mutex_exit(&srv_innodb_monitor_mutex); + export_vars.innodb_row_lock_time_max + = srv_n_lock_max_wait_time / 10000; + export_vars.innodb_rows_read = srv_n_rows_read; + export_vars.innodb_rows_inserted = srv_n_rows_inserted; + export_vars.innodb_rows_updated = srv_n_rows_updated; + export_vars.innodb_rows_deleted = srv_n_rows_deleted; + mutex_exit(&srv_innodb_monitor_mutex); } /************************************************************************* @@ -1873,53 +1902,57 @@ loop: if (srv_innodb_status) { mutex_enter(&srv_monitor_file_mutex); rewind(srv_monitor_file); - srv_printf_innodb_monitor(srv_monitor_file, NULL, NULL); + srv_printf_innodb_monitor + (srv_monitor_file, NULL, NULL); os_file_set_eof(srv_monitor_file); mutex_exit(&srv_monitor_file_mutex); } if (srv_print_innodb_tablespace_monitor - && difftime(current_time, last_table_monitor_time) > 60) { + && difftime(current_time, last_table_monitor_time) > 60) { last_table_monitor_time = time(NULL); - fputs("================================================\n", - stderr); + fputs("========================" + "========================\n", + stderr); ut_print_timestamp(stderr); fputs(" INNODB TABLESPACE MONITOR OUTPUT\n" - "================================================\n", - stderr); + "========================" + "========================\n", + stderr); fsp_print(0); fputs("Validating tablespace\n", stderr); fsp_validate(0); fputs("Validation ok\n" - "---------------------------------------\n" - "END OF INNODB TABLESPACE MONITOR OUTPUT\n" - "=======================================\n", - stderr); + "---------------------------------------\n" + "END OF INNODB TABLESPACE MONITOR OUTPUT\n" + "=======================================\n", + stderr); } if (srv_print_innodb_table_monitor - && difftime(current_time, last_table_monitor_time) > 60) { + && difftime(current_time, last_table_monitor_time) > 60) { last_table_monitor_time = time(NULL); - fputs("===========================================\n", stderr); + fputs("===========================================\n", + stderr); ut_print_timestamp(stderr); fputs(" INNODB TABLE MONITOR OUTPUT\n" - "===========================================\n", - stderr); + "===========================================\n", + stderr); dict_print(); fputs("-----------------------------------\n" - "END OF INNODB TABLE MONITOR OUTPUT\n" - "==================================\n", - stderr); + "END OF INNODB TABLE MONITOR OUTPUT\n" + "==================================\n", + stderr); } } @@ -1939,9 +1972,9 @@ loop: wait_time = ut_difftime(ut_time(), slot->suspend_time); - if (srv_lock_wait_timeout < 100000000 && - (wait_time > (double) srv_lock_wait_timeout - || wait_time < 0)) { + if (srv_lock_wait_timeout < 100000000 + && (wait_time > (double) srv_lock_wait_timeout + || wait_time < 0)) { /* Timeout exceeded or a wrap-around in system time counter: cancel the lock request queued @@ -1951,8 +1984,9 @@ loop: granted: in that case do nothing */ if (thr_get_trx(slot->thr)->wait_lock) { - lock_cancel_waiting_and_release( - thr_get_trx(slot->thr)->wait_lock); + lock_cancel_waiting_and_release + (thr_get_trx(slot->thr) + ->wait_lock); } } } @@ -1967,9 +2001,9 @@ loop: } if (some_waits || srv_print_innodb_monitor - || srv_print_innodb_lock_monitor - || srv_print_innodb_tablespace_monitor - || srv_print_innodb_table_monitor) { + || srv_print_innodb_lock_monitor + || srv_print_innodb_tablespace_monitor + || srv_print_innodb_table_monitor) { goto loop; } @@ -2030,13 +2064,15 @@ loop: if (ut_dulint_cmp(new_lsn, old_lsn) < 0) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: old log sequence number %lu %lu was greater\n" -"InnoDB: than the new log sequence number %lu %lu!\n" -"InnoDB: Please send a bug report to mysql@lists.mysql.com\n", - (ulong) ut_dulint_get_high(old_lsn), - (ulong) ut_dulint_get_low(old_lsn), - (ulong) ut_dulint_get_high(new_lsn), - (ulong) ut_dulint_get_low(new_lsn)); + " InnoDB: Error: old log sequence number %lu %lu" + " was greater\n" + "InnoDB: than the new log sequence number %lu %lu!\n" + "InnoDB: Please submit a bug report" + " to http://bugs.mysql.com\n", + (ulong) ut_dulint_get_high(old_lsn), + (ulong) ut_dulint_get_low(old_lsn), + (ulong) ut_dulint_get_high(new_lsn), + (ulong) ut_dulint_get_low(new_lsn)); } old_lsn = new_lsn; @@ -2053,9 +2089,11 @@ loop: if (fatal_cnt > 5) { fprintf(stderr, -"InnoDB: Error: semaphore wait has lasted > %lu seconds\n" -"InnoDB: We intentionally crash the server, because it appears to be hung.\n", - srv_fatal_semaphore_wait_threshold); + "InnoDB: Error: semaphore wait has lasted" + " > %lu seconds\n" + "InnoDB: We intentionally crash the server," + " because it appears to be hung.\n", + (ulong) srv_fatal_semaphore_wait_threshold); ut_error; } @@ -2174,7 +2212,7 @@ loop: srv_main_thread_op_info = "reserving kernel mutex"; n_ios_very_old = log_sys->n_log_ios + buf_pool->n_pages_read - + buf_pool->n_pages_written; + + buf_pool->n_pages_written; mutex_enter(&kernel_mutex); /* Store the user activity counter at the start of this loop */ @@ -2194,7 +2232,7 @@ loop: for (i = 0; i < 10; i++) { n_ios_old = log_sys->n_log_ios + buf_pool->n_pages_read - + buf_pool->n_pages_written; + + buf_pool->n_pages_written; srv_main_thread_op_info = "sleeping"; if (!skip_sleep) { @@ -2235,9 +2273,9 @@ loop: do an insert buffer merge. */ n_pend_ios = buf_get_n_pending_ios() - + log_sys->n_pending_writes; + + log_sys->n_pending_writes; n_ios = log_sys->n_log_ios + buf_pool->n_pages_read - + buf_pool->n_pages_written; + + buf_pool->n_pages_written; if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) { srv_main_thread_op_info = "doing insert buffer merge"; ibuf_contract_for_n_pages(TRUE, 5); @@ -2247,8 +2285,8 @@ loop: log_buffer_flush_to_disk(); } - if (buf_get_modified_ratio_pct() > - srv_max_buf_pool_modified_pct) { + if (UNIV_UNLIKELY(buf_get_modified_ratio_pct() + > srv_max_buf_pool_modified_pct)) { /* Try to keep the number of modified pages in the buffer pool under the limit wished by the user */ @@ -2287,7 +2325,7 @@ loop: n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes; n_ios = log_sys->n_log_ios + buf_pool->n_pages_read - + buf_pool->n_pages_written; + + buf_pool->n_pages_written; if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) { srv_main_thread_op_info = "flushing buffer pool pages"; @@ -2344,14 +2382,14 @@ loop: the time it requires to flush 100 pages */ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, - ut_dulint_max); + ut_dulint_max); } else { /* Otherwise, we only flush a small number of pages so that we do not unnecessarily use much disk i/o capacity from other work */ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10, - ut_dulint_max); + ut_dulint_max); } srv_main_thread_op_info = "making checkpoint"; @@ -2455,8 +2493,8 @@ flush_loop: srv_main_thread_op_info = "flushing buffer pool pages"; if (srv_fast_shutdown < 2) { - n_pages_flushed = - buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max); + n_pages_flushed = buf_flush_batch + (BUF_FLUSH_LIST, 100, ut_dulint_max); } else { /* In the fastest shutdown we do not flush the buffer pool to data files: we set n_pages_flushed to 0 artificially. */ @@ -2500,18 +2538,18 @@ flush_loop: goto loop; } mutex_exit(&kernel_mutex); -/* + /* srv_main_thread_op_info = "archiving log (if log archive is on)"; log_archive_do(FALSE, &n_bytes_archived); -*/ + */ n_bytes_archived = 0; /* Keep looping in the background loop if still work to do */ if (srv_fast_shutdown && srv_shutdown_state > 0) { if (n_tables_to_drop + n_pages_flushed - + n_bytes_archived != 0) { + + n_bytes_archived != 0) { /* If we are doing a fast shutdown (= the default) we do not do purge or insert buffer merge. But we @@ -2522,9 +2560,9 @@ flush_loop: goto background_loop; } - } else if (n_tables_to_drop + - n_pages_purged + n_bytes_merged + n_pages_flushed - + n_bytes_archived != 0) { + } else if (n_tables_to_drop + + n_pages_purged + n_bytes_merged + n_pages_flushed + + n_bytes_archived != 0) { /* In a 'slow' shutdown we run purge and the insert buffer merge to completion */ @@ -2549,6 +2587,10 @@ suspend_thread: mutex_exit(&kernel_mutex); + /* DO NOT CHANGE THIS STRING. innobase_start_or_create_for_mysql() + waits for database activity to die down when converting < 4.1.x + databases, and relies on this string being exactly as it is. InnoDB + manual also mentions this string in several places. */ srv_main_thread_op_info = "waiting for server activity"; os_event_wait(event); @@ -2564,5 +2606,7 @@ suspend_thread: main thread goes back to loop. */ goto loop; + + OS_THREAD_DUMMY_RETURN; /* Not reached, avoid compiler warning */ } #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c index 8346203f3f7..2b9bd402bb7 100644 --- a/storage/innobase/srv/srv0start.c +++ b/storage/innobase/srv/srv0start.c @@ -188,9 +188,9 @@ srv_parse_data_file_paths_and_sizes( path = str; while ((*str != ':' && *str != '\0') - || (*str == ':' - && (*(str + 1) == '\\' || *(str + 1) == '/' - || *(str + 1) == ':'))) { + || (*str == ':' + && (*(str + 1) == '\\' || *(str + 1) == '/' + || *(str + 1) == ':'))) { str++; } @@ -202,11 +202,13 @@ srv_parse_data_file_paths_and_sizes( str = srv_parse_megabytes(str, &size); - if (0 == memcmp(str, ":autoextend", (sizeof ":autoextend") - 1)) { + if (0 == memcmp(str, ":autoextend", + (sizeof ":autoextend") - 1)) { str += (sizeof ":autoextend") - 1; - if (0 == memcmp(str, ":max:", (sizeof ":max:") - 1)) { + if (0 == memcmp(str, ":max:", + (sizeof ":max:") - 1)) { str += (sizeof ":max:") - 1; @@ -220,9 +222,9 @@ srv_parse_data_file_paths_and_sizes( } if (strlen(str) >= 6 - && *str == 'n' - && *(str + 1) == 'e' - && *(str + 2) == 'w') { + && *str == 'n' + && *(str + 1) == 'e' + && *(str + 2) == 'w') { str += 3; } @@ -271,9 +273,9 @@ srv_parse_data_file_paths_and_sizes( \\.\C::1Gnewraw or \\.\PHYSICALDRIVE2:1Gnewraw */ while ((*str != ':' && *str != '\0') - || (*str == ':' - && (*(str + 1) == '\\' || *(str + 1) == '/' - || *(str + 1) == ':'))) { + || (*str == ':' + && (*(str + 1) == '\\' || *(str + 1) == '/' + || *(str + 1) == ':'))) { str++; } @@ -288,7 +290,8 @@ srv_parse_data_file_paths_and_sizes( (*data_file_names)[i] = path; (*data_file_sizes)[i] = size; - if (0 == memcmp(str, ":autoextend", (sizeof ":autoextend") - 1)) { + if (0 == memcmp(str, ":autoextend", + (sizeof ":autoextend") - 1)) { *is_auto_extending = TRUE; @@ -298,8 +301,8 @@ srv_parse_data_file_paths_and_sizes( str += (sizeof ":max:") - 1; - str = srv_parse_megabytes(str, - max_auto_extend_size); + str = srv_parse_megabytes + (str, max_auto_extend_size); } if (*str != '\0') { @@ -311,9 +314,9 @@ srv_parse_data_file_paths_and_sizes( (*data_file_is_raw_partition)[i] = 0; if (strlen(str) >= 6 - && *str == 'n' - && *(str + 1) == 'e' - && *(str + 2) == 'w') { + && *str == 'n' + && *(str + 1) == 'e' + && *(str + 2) == 'w') { str += 3; (*data_file_is_raw_partition)[i] = SRV_NEW_RAW; } @@ -425,7 +428,7 @@ io_handler_thread( #ifdef UNIV_DEBUG_THREAD_CREATION fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment, - os_thread_pf(os_thread_get_curr_id())); + os_thread_pf(os_thread_get_curr_id())); #endif for (i = 0;; i++) { fil_aio_wait(segment); @@ -459,7 +462,7 @@ void srv_normalize_path_for_win( /*=======================*/ char* str __attribute__((unused))) /* in/out: null-terminated - character string */ + character string */ { #ifdef __WIN__ for (; *str; str++) { @@ -554,35 +557,37 @@ open_or_create_log_file( *log_file_created = FALSE; srv_normalize_path_for_win(srv_log_group_home_dirs[k]); - srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed( - srv_log_group_home_dirs[k]); + srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed + (srv_log_group_home_dirs[k]); - ut_a(strlen(srv_log_group_home_dirs[k]) < - (sizeof name) - 10 - sizeof "ib_logfile"); - sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k], "ib_logfile", (ulong) i); + ut_a(strlen(srv_log_group_home_dirs[k]) + < (sizeof name) - 10 - sizeof "ib_logfile"); + sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k], + "ib_logfile", (ulong) i); files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL, - OS_LOG_FILE, &ret); + OS_LOG_FILE, &ret); if (ret == FALSE) { if (os_file_get_last_error(FALSE) != OS_FILE_ALREADY_EXISTS #ifdef UNIV_AIX - /* AIX 5.1 after security patch ML7 may have errno set - to 0 here, which causes our function to return 100; - work around that AIX problem */ - && os_file_get_last_error(FALSE) != 100 + /* AIX 5.1 after security patch ML7 may have errno set + to 0 here, which causes our function to return 100; + work around that AIX problem */ + && os_file_get_last_error(FALSE) != 100 #endif - ) { + ) { fprintf(stderr, - "InnoDB: Error in creating or opening %s\n", name); + "InnoDB: Error in creating" + " or opening %s\n", name); return(DB_ERROR); } files[i] = os_file_create(name, OS_FILE_OPEN, OS_FILE_AIO, - OS_LOG_FILE, &ret); + OS_LOG_FILE, &ret); if (!ret) { fprintf(stderr, - "InnoDB: Error in opening %s\n", name); + "InnoDB: Error in opening %s\n", name); return(DB_ERROR); } @@ -591,11 +596,13 @@ open_or_create_log_file( ut_a(ret); if (size != srv_calc_low32(srv_log_file_size) - || size_high != srv_calc_high32(srv_log_file_size)) { + || size_high != srv_calc_high32(srv_log_file_size)) { fprintf(stderr, -"InnoDB: Error: log file %s is of different size %lu %lu bytes\n" -"InnoDB: than specified in the .cnf file %lu %lu bytes!\n", + "InnoDB: Error: log file %s is" + " of different size %lu %lu bytes\n" + "InnoDB: than specified in the .cnf" + " file %lu %lu bytes!\n", name, (ulong) size_high, (ulong) size, (ulong) srv_calc_high32(srv_log_file_size), (ulong) srv_calc_low32(srv_log_file_size)); @@ -608,8 +615,9 @@ open_or_create_log_file( ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Log file %s did not exist: new to be created\n", - name); + " InnoDB: Log file %s did not exist:" + " new to be created\n", + name); if (log_file_has_been_opened) { return(DB_ERROR); @@ -620,15 +628,17 @@ open_or_create_log_file( >> (20 - UNIV_PAGE_SIZE_SHIFT)); fprintf(stderr, - "InnoDB: Database physically writes the file full: wait...\n"); + "InnoDB: Database physically writes the file" + " full: wait...\n"); ret = os_file_set_size(name, files[i], - srv_calc_low32(srv_log_file_size), - srv_calc_high32(srv_log_file_size)); + srv_calc_low32(srv_log_file_size), + srv_calc_high32(srv_log_file_size)); if (!ret) { fprintf(stderr, - "InnoDB: Error in creating %s: probably out of disk space\n", - name); + "InnoDB: Error in creating %s:" + " probably out of disk space\n", + name); return(DB_ERROR); } @@ -642,13 +652,13 @@ open_or_create_log_file( which is for this log group */ fil_space_create(name, - 2 * k + SRV_LOG_SPACE_FIRST_ID, FIL_LOG); + 2 * k + SRV_LOG_SPACE_FIRST_ID, FIL_LOG); } ut_a(fil_validate()); fil_node_create(name, srv_log_file_size, - 2 * k + SRV_LOG_SPACE_FIRST_ID, FALSE); + 2 * k + SRV_LOG_SPACE_FIRST_ID, FALSE); #ifdef UNIV_LOG_ARCHIVE /* If this is the first log group, create the file space object for archived logs. @@ -664,10 +674,10 @@ open_or_create_log_file( #endif /* UNIV_LOG_ARCHIVE */ if (i == 0) { log_group_init(k, srv_n_log_files, - srv_log_file_size * UNIV_PAGE_SIZE, - 2 * k + SRV_LOG_SPACE_FIRST_ID, - SRV_LOG_SPACE_FIRST_ID + 1); /* dummy arch - space id */ + srv_log_file_size * UNIV_PAGE_SIZE, + 2 * k + SRV_LOG_SPACE_FIRST_ID, + SRV_LOG_SPACE_FIRST_ID + 1); /* dummy arch + space id */ } return(DB_SUCCESS); @@ -703,8 +713,8 @@ open_or_create_data_files( if (srv_n_data_files >= 1000) { fprintf(stderr, "InnoDB: can only have < 1000 data files\n" - "InnoDB: you have defined %lu\n", - (ulong) srv_n_data_files); + "InnoDB: you have defined %lu\n", + (ulong) srv_n_data_files); return(DB_ERROR); } @@ -719,7 +729,7 @@ open_or_create_data_files( srv_normalize_path_for_win(srv_data_file_names[i]); ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i]) - < (sizeof name) - 1); + < (sizeof name) - 1); sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]); if (srv_data_file_is_raw_partition[i] == 0) { @@ -728,20 +738,22 @@ open_or_create_data_files( exists, ret will get value FALSE */ files[i] = os_file_create(name, OS_FILE_CREATE, - OS_FILE_NORMAL, OS_DATA_FILE, &ret); + OS_FILE_NORMAL, + OS_DATA_FILE, &ret); - if (ret == FALSE && os_file_get_last_error(FALSE) != - OS_FILE_ALREADY_EXISTS + if (ret == FALSE && os_file_get_last_error(FALSE) + != OS_FILE_ALREADY_EXISTS #ifdef UNIV_AIX - /* AIX 5.1 after security patch ML7 may have - errno set to 0 here, which causes our function - to return 100; work around that AIX problem */ - && os_file_get_last_error(FALSE) != 100 + /* AIX 5.1 after security patch ML7 may have + errno set to 0 here, which causes our function + to return 100; work around that AIX problem */ + && os_file_get_last_error(FALSE) != 100 #endif - ) { + ) { fprintf(stderr, - "InnoDB: Error in creating or opening %s\n", - name); + "InnoDB: Error in creating" + " or opening %s\n", + name); return(DB_ERROR); } @@ -752,12 +764,12 @@ open_or_create_data_files( srv_start_raw_disk_in_use = TRUE; srv_created_new_raw = TRUE; - files[i] = os_file_create( - name, OS_FILE_OPEN_RAW, OS_FILE_NORMAL, - OS_DATA_FILE, &ret); + files[i] = os_file_create(name, OS_FILE_OPEN_RAW, + OS_FILE_NORMAL, + OS_DATA_FILE, &ret); if (!ret) { fprintf(stderr, - "InnoDB: Error in opening %s\n", name); + "InnoDB: Error in opening %s\n", name); return(DB_ERROR); } @@ -774,31 +786,32 @@ open_or_create_data_files( if (one_created) { fprintf(stderr, - "InnoDB: Error: data files can only be added at the end\n"); + "InnoDB: Error: data files can only" + " be added at the end\n"); fprintf(stderr, - "InnoDB: of a tablespace, but data file %s existed beforehand.\n", - name); + "InnoDB: of a tablespace, but" + " data file %s existed beforehand.\n", + name); return(DB_ERROR); } if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) { - files[i] = os_file_create( - name, OS_FILE_OPEN_RAW, OS_FILE_NORMAL, - OS_DATA_FILE, &ret); + files[i] = os_file_create + (name, OS_FILE_OPEN_RAW, + OS_FILE_NORMAL, OS_DATA_FILE, &ret); } else if (i == 0) { - files[i] = os_file_create( - name, OS_FILE_OPEN_RETRY, - OS_FILE_NORMAL, - OS_DATA_FILE, &ret); + files[i] = os_file_create + (name, OS_FILE_OPEN_RETRY, + OS_FILE_NORMAL, OS_DATA_FILE, &ret); } else { - files[i] = os_file_create( - name, OS_FILE_OPEN, OS_FILE_NORMAL, - OS_DATA_FILE, &ret); + files[i] = os_file_create + (name, OS_FILE_OPEN, + OS_FILE_NORMAL, OS_DATA_FILE, &ret); } if (!ret) { fprintf(stderr, - "InnoDB: Error in opening %s\n", name); + "InnoDB: Error in opening %s\n", name); os_file_get_last_error(TRUE); return(DB_ERROR); @@ -813,26 +826,33 @@ open_or_create_data_files( ut_a(ret); /* Round size downward to megabytes */ - rounded_size_pages = (size / (1024 * 1024) - + 4096 * size_high) - << (20 - UNIV_PAGE_SIZE_SHIFT); + rounded_size_pages + = (size / (1024 * 1024) + 4096 * size_high) + << (20 - UNIV_PAGE_SIZE_SHIFT); if (i == srv_n_data_files - 1 - && srv_auto_extend_last_data_file) { + && srv_auto_extend_last_data_file) { - if (srv_data_file_sizes[i] > - rounded_size_pages - || (srv_last_file_size_max > 0 - && srv_last_file_size_max < - rounded_size_pages)) { + if (srv_data_file_sizes[i] > rounded_size_pages + || (srv_last_file_size_max > 0 + && srv_last_file_size_max + < rounded_size_pages)) { fprintf(stderr, -"InnoDB: Error: auto-extending data file %s is of a different size\n" -"InnoDB: %lu pages (rounded down to MB) than specified in the .cnf file:\n" -"InnoDB: initial %lu pages, max %lu (relevant if non-zero) pages!\n", - name, (ulong) rounded_size_pages, - (ulong) srv_data_file_sizes[i], - (ulong) srv_last_file_size_max); + "InnoDB: Error: auto-extending" + " data file %s is" + " of a different size\n" + "InnoDB: %lu pages (rounded" + " down to MB) than specified" + " in the .cnf file:\n" + "InnoDB: initial %lu pages," + " max %lu (relevant if" + " non-zero) pages!\n", + name, + (ulong) rounded_size_pages, + (ulong) srv_data_file_sizes[i], + (ulong) + srv_last_file_size_max); return(DB_ERROR); } @@ -843,21 +863,25 @@ open_or_create_data_files( if (rounded_size_pages != srv_data_file_sizes[i]) { fprintf(stderr, -"InnoDB: Error: data file %s is of a different size\n" -"InnoDB: %lu pages (rounded down to MB)\n" -"InnoDB: than specified in the .cnf file %lu pages!\n", name, + "InnoDB: Error: data file %s" + " is of a different size\n" + "InnoDB: %lu pages" + " (rounded down to MB)\n" + "InnoDB: than specified" + " in the .cnf file %lu pages!\n", + name, (ulong) rounded_size_pages, (ulong) srv_data_file_sizes[i]); return(DB_ERROR); } skip_size_check: - fil_read_flushed_lsn_and_arch_log_no(files[i], - one_opened, + fil_read_flushed_lsn_and_arch_log_no + (files[i], one_opened, #ifdef UNIV_LOG_ARCHIVE - min_arch_log_no, max_arch_log_no, + min_arch_log_no, max_arch_log_no, #endif /* UNIV_LOG_ARCHIVE */ - min_flushed_lsn, max_flushed_lsn); + min_flushed_lsn, max_flushed_lsn); one_opened = TRUE; } else { /* We created the data file and now write it full of @@ -868,37 +892,44 @@ skip_size_check: if (i > 0) { ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Data file %s did not exist: new to be created\n", - name); + " InnoDB: Data file %s did not" + " exist: new to be created\n", + name); } else { fprintf(stderr, - "InnoDB: The first specified data file %s did not exist:\n" - "InnoDB: a new database to be created!\n", name); + "InnoDB: The first specified" + " data file %s did not exist:\n" + "InnoDB: a new database" + " to be created!\n", name); *create_new_db = TRUE; } ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Setting file %s size to %lu MB\n", - name, (ulong) (srv_data_file_sizes[i] - >> (20 - UNIV_PAGE_SIZE_SHIFT))); + name, + (ulong) (srv_data_file_sizes[i] + >> (20 - UNIV_PAGE_SIZE_SHIFT))); fprintf(stderr, - "InnoDB: Database physically writes the file full: wait...\n"); + "InnoDB: Database physically writes the" + " file full: wait...\n"); - ret = os_file_set_size(name, files[i], - srv_calc_low32(srv_data_file_sizes[i]), - srv_calc_high32(srv_data_file_sizes[i])); + ret = os_file_set_size + (name, files[i], + srv_calc_low32(srv_data_file_sizes[i]), + srv_calc_high32(srv_data_file_sizes[i])); if (!ret) { fprintf(stderr, - "InnoDB: Error in creating %s: probably out of disk space\n", name); + "InnoDB: Error in creating %s:" + " probably out of disk space\n", name); return(DB_ERROR); } *sum_of_new_sizes = *sum_of_new_sizes - + srv_data_file_sizes[i]; + + srv_data_file_sizes[i]; } ret = os_file_close(files[i]); @@ -915,7 +946,7 @@ skip_size_check: fil_node_create(name, srv_data_file_sizes[i], 0, TRUE); } else { fil_node_create(name, srv_data_file_sizes[i], 0, - FALSE); + FALSE); } } @@ -970,67 +1001,74 @@ innobase_start_or_create_for_mysql(void) srv_have_fullfsync = strcmp(utsname.release, "7.") >= 0; } if (!srv_have_fullfsync) { - fputs( -"InnoDB: On Mac OS X, fsync() may be broken on internal drives,\n" -"InnoDB: making transactions unsafe!\n", stderr); + fputs("InnoDB: On Mac OS X, fsync() may be" + " broken on internal drives,\n" + "InnoDB: making transactions unsafe!\n", stderr); } # endif /* F_FULLFSYNC */ #endif /* HAVE_DARWIN_THREADS */ if (sizeof(ulint) != sizeof(void*)) { fprintf(stderr, -"InnoDB: Error: size of InnoDB's ulint is %lu, but size of void* is %lu.\n" -"InnoDB: The sizes should be the same so that on a 64-bit platform you can\n" -"InnoDB: allocate more than 4 GB of memory.", + "InnoDB: Error: size of InnoDB's ulint is %lu," + " but size of void* is %lu.\n" + "InnoDB: The sizes should be the same" + " so that on a 64-bit platform you can\n" + "InnoDB: allocate more than 4 GB of memory.", (ulong)sizeof(ulint), (ulong)sizeof(void*)); } srv_file_per_table = FALSE; /* system tables are created in tablespace - 0 */ + 0 */ #ifdef UNIV_DEBUG fprintf(stderr, -"InnoDB: !!!!!!!!!!!!!! UNIV_DEBUG switched on !!!!!!!!!!!!!!!\n"); + "InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n"); #endif #ifdef UNIV_SYNC_DEBUG fprintf(stderr, -"InnoDB: !!!!!!!!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!!!!!!!\n"); + "InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n"); #endif #ifdef UNIV_SEARCH_DEBUG fprintf(stderr, -"InnoDB: !!!!!!!!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!!!!!!!\n"); + "InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n"); #endif #ifdef UNIV_MEM_DEBUG fprintf(stderr, -"InnoDB: !!!!!!!!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!!!!!!!\n"); + "InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n"); #endif #ifdef UNIV_SIMULATE_AWE fprintf(stderr, -"InnoDB: !!!!!!!!!!!!!! UNIV_SIMULATE_AWE switched on !!!!!!!!!!!!!!!!!\n"); + "InnoDB: !!!!!!!! UNIV_SIMULATE_AWE switched on !!!!!!!!!\n"); #endif if (srv_sizeof_trx_t_in_ha_innodb_cc != (ulint)sizeof(trx_t)) { fprintf(stderr, - "InnoDB: Error: trx_t size is %lu in ha_innodb.cc but %lu in srv0start.c\n" - "InnoDB: Check that pthread_mutex_t is defined in the same way in these\n" - "InnoDB: compilation modules. Cannot continue.\n", - (ulong) srv_sizeof_trx_t_in_ha_innodb_cc, - (ulong) sizeof(trx_t)); + "InnoDB: Error: trx_t size is %lu in ha_innodb.cc" + " but %lu in srv0start.c\n" + "InnoDB: Check that pthread_mutex_t is defined" + " in the same way in these\n" + "InnoDB: compilation modules. Cannot continue.\n", + (ulong) srv_sizeof_trx_t_in_ha_innodb_cc, + (ulong) sizeof(trx_t)); return(DB_ERROR); } /* Since InnoDB does not currently clean up all its internal data - structures in MySQL Embedded Server Library server_end(), we - print an error message if someone tries to start up InnoDB a - second time during the process lifetime. */ + structures in MySQL Embedded Server Library server_end(), we + print an error message if someone tries to start up InnoDB a + second time during the process lifetime. */ if (srv_start_has_been_called) { fprintf(stderr, -"InnoDB: Error:startup called second time during the process lifetime.\n" -"InnoDB: In the MySQL Embedded Server Library you cannot call server_init()\n" -"InnoDB: more than once during the process lifetime.\n"); + "InnoDB: Error:startup called second time" + " during the process lifetime.\n" + "InnoDB: In the MySQL Embedded Server Library" + " you cannot call server_init()\n" + "InnoDB: more than once during" + " the process lifetime.\n"); } srv_start_has_been_called = TRUE; @@ -1038,7 +1076,7 @@ innobase_start_or_create_for_mysql(void) #ifdef UNIV_DEBUG log_do_write = TRUE; #endif /* UNIV_DEBUG */ -/* yydebug = TRUE; */ + /* yydebug = TRUE; */ srv_is_being_started = TRUE; srv_startup_is_before_trx_rollback_phase = TRUE; @@ -1048,9 +1086,12 @@ innobase_start_or_create_for_mysql(void) if (srv_use_awe) { fprintf(stderr, -"InnoDB: Error: You have specified innodb_buffer_pool_awe_mem_mb\n" -"InnoDB: in my.cnf, but AWE can only be used in Windows 2000 and later.\n" -"InnoDB: To use AWE, InnoDB must be compiled with __WIN2000__ defined.\n"); + "InnoDB: Error: You have specified" + " innodb_buffer_pool_awe_mem_mb\n" + "InnoDB: in my.cnf, but AWE can only" + " be used in Windows 2000 and later.\n" + "InnoDB: To use AWE, InnoDB must" + " be compiled with __WIN2000__ defined.\n"); return(DB_ERROR); } @@ -1058,8 +1099,8 @@ innobase_start_or_create_for_mysql(void) #ifdef __WIN__ if (os_get_os_version() == OS_WIN95 - || os_get_os_version() == OS_WIN31 - || os_get_os_version() == OS_WINNT) { + || os_get_os_version() == OS_WIN31 + || os_get_os_version() == OS_WINNT) { /* On Win 95, 98, ME, Win32 subsystem for Windows 3.1, and NT use simulated aio. In NT Windows provides async i/o, @@ -1103,13 +1144,14 @@ innobase_start_or_create_for_mysql(void) os_aio_use_native_aio = FALSE; } else if (0 == ut_strcmp(srv_file_flush_method_str, - "async_unbuffered")) { + "async_unbuffered")) { srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; #endif } else { fprintf(stderr, - "InnoDB: Unrecognized value %s for innodb_flush_method\n", - srv_file_flush_method_str); + "InnoDB: Unrecognized value %s for" + " innodb_flush_method\n", + srv_file_flush_method_str); return(DB_ERROR); } @@ -1123,18 +1165,18 @@ innobase_start_or_create_for_mysql(void) #if defined(__WIN__) || defined(__NETWARE__) -/* Create less event semaphores because Win 98/ME had difficulty creating -40000 event semaphores. -Comment from Novell, Inc.: also, these just take a lot of memory on -NetWare. */ + /* Create less event semaphores because Win 98/ME had + difficulty creating 40000 event semaphores. Comment from + Novell, Inc.: also, these just take a lot of memory on + NetWare. */ srv_max_n_threads = 1000; #else if (srv_pool_size >= 1000 * 1024) { - /* Here we still have srv_pool_size counted - in kilobytes (in 4.0 this was in bytes) - srv_boot() converts the value to - pages; if buffer pool is less than 1000 MB, - assume fewer threads. */ + /* Here we still have srv_pool_size counted + in kilobytes (in 4.0 this was in bytes) + srv_boot() converts the value to + pages; if buffer pool is less than 1000 MB, + assume fewer threads. */ srv_max_n_threads = 50000; } else if (srv_pool_size >= 8 * 1024) { @@ -1156,9 +1198,9 @@ NetWare. */ mutex_create(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK); if (srv_innodb_status) { - srv_monitor_file_name = mem_alloc( - strlen(fil_path_to_mysql_datadir) + - 20 + sizeof "/innodb_status."); + srv_monitor_file_name = mem_alloc + (strlen(fil_path_to_mysql_datadir) + + 20 + sizeof "/innodb_status."); sprintf(srv_monitor_file_name, "%s/innodb_status.%lu", fil_path_to_mysql_datadir, os_proc_get_number()); srv_monitor_file = fopen(srv_monitor_file_name, "w+"); @@ -1200,38 +1242,42 @@ NetWare. */ srv_n_file_io_threads = 4; os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD - * srv_n_file_io_threads, - srv_n_file_io_threads, - SRV_MAX_N_PENDING_SYNC_IOS); + * srv_n_file_io_threads, + srv_n_file_io_threads, + SRV_MAX_N_PENDING_SYNC_IOS); } else { os_aio_init(SRV_N_PENDING_IOS_PER_THREAD - * srv_n_file_io_threads, - srv_n_file_io_threads, - SRV_MAX_N_PENDING_SYNC_IOS); + * srv_n_file_io_threads, + srv_n_file_io_threads, + SRV_MAX_N_PENDING_SYNC_IOS); } fil_init(srv_max_n_open_files); if (srv_use_awe) { fprintf(stderr, -"InnoDB: Using AWE: Memory window is %lu MB and AWE memory is %lu MB\n", - (ulong) (srv_awe_window_size / ((1024 * 1024) / UNIV_PAGE_SIZE)), - (ulong) (srv_pool_size / ((1024 * 1024) / UNIV_PAGE_SIZE))); + "InnoDB: Using AWE: Memory window is %lu MB" + " and AWE memory is %lu MB\n", + (ulong) (srv_awe_window_size / ((1024 * 1024) + / UNIV_PAGE_SIZE)), + (ulong) (srv_pool_size / ((1024 * 1024) + / UNIV_PAGE_SIZE))); /* We must disable adaptive hash indexes because they do not tolerate remapping of pages in AWE */ srv_use_adaptive_hash_indexes = FALSE; ret = buf_pool_init(srv_pool_size, srv_pool_size, - srv_awe_window_size); + srv_awe_window_size); } else { ret = buf_pool_init(srv_pool_size, srv_pool_size, - srv_pool_size); + srv_pool_size); } if (ret == NULL) { fprintf(stderr, -"InnoDB: Fatal error: cannot allocate the memory for the buffer pool\n"); + "InnoDB: Fatal error: cannot allocate the memory" + " for the buffer pool\n"); return(DB_ERROR); } @@ -1252,8 +1298,9 @@ NetWare. */ #ifdef UNIV_LOG_ARCHIVE if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) { fprintf(stderr, - "InnoDB: Error: you must set the log group home dir in my.cnf the\n" - "InnoDB: same as log arch dir.\n"); + "InnoDB: Error: you must set the log group" + " home dir in my.cnf the\n" + "InnoDB: same as log arch dir.\n"); return(DB_ERROR); } @@ -1261,7 +1308,8 @@ NetWare. */ if (srv_n_log_files * srv_log_file_size >= 262144) { fprintf(stderr, - "InnoDB: Error: combined size of log files must be < 4 GB\n"); + "InnoDB: Error: combined size of log files" + " must be < 4 GB\n"); return(DB_ERROR); } @@ -1272,8 +1320,10 @@ NetWare. */ #ifndef __WIN__ if (sizeof(off_t) < 5 && srv_data_file_sizes[i] >= 262144) { fprintf(stderr, - "InnoDB: Error: file size must be < 4 GB with this MySQL binary\n" - "InnoDB: and operating system combination, in some OS's < 2 GB\n"); + "InnoDB: Error: file size must be < 4 GB" + " with this MySQL binary\n" + "InnoDB: and operating system combination," + " in some OS's < 2 GB\n"); return(DB_ERROR); } @@ -1282,10 +1332,11 @@ NetWare. */ } if (sum_of_new_sizes < 640) { - fprintf(stderr, - "InnoDB: Error: tablespace size must be at least 10 MB\n"); + fprintf(stderr, + "InnoDB: Error: tablespace size must be" + " at least 10 MB\n"); - return(DB_ERROR); + return(DB_ERROR); } err = open_or_create_data_files(&create_new_db, @@ -1296,13 +1347,19 @@ NetWare. */ &sum_of_new_sizes); if (err != DB_SUCCESS) { fprintf(stderr, -"InnoDB: Could not open or create data files.\n" -"InnoDB: If you tried to add new data files, and it failed here,\n" -"InnoDB: you should now edit innodb_data_file_path in my.cnf back\n" -"InnoDB: to what it was, and remove the new ibdata files InnoDB created\n" -"InnoDB: in this failed attempt. InnoDB only wrote those files full of\n" -"InnoDB: zeros, but did not yet use them in any way. But be careful: do not\n" -"InnoDB: remove old data files which contain your precious data!\n"); + "InnoDB: Could not open or create data files.\n" + "InnoDB: If you tried to add new data files," + " and it failed here,\n" + "InnoDB: you should now edit innodb_data_file_path" + " in my.cnf back\n" + "InnoDB: to what it was, and remove the" + " new ibdata files InnoDB created\n" + "InnoDB: in this failed attempt. InnoDB only wrote" + " those files full of\n" + "InnoDB: zeros, but did not yet use them in any way." + " But be careful: do not\n" + "InnoDB: remove old data files" + " which contain your precious data!\n"); return((int) err); } @@ -1314,7 +1371,7 @@ NetWare. */ for (i = 0; i < srv_n_log_files; i++) { err = open_or_create_log_file(create_new_db, &log_file_created, - log_opened, 0, i); + log_opened, 0, i); if (err != DB_SUCCESS) { return((int) err); @@ -1326,14 +1383,19 @@ NetWare. */ log_opened = TRUE; } if ((log_opened && create_new_db) - || (log_opened && log_created)) { + || (log_opened && log_created)) { fprintf(stderr, - "InnoDB: Error: all log files must be created at the same time.\n" - "InnoDB: All log files must be created also in database creation.\n" - "InnoDB: If you want bigger or smaller log files, shut down the\n" - "InnoDB: database and make sure there were no errors in shutdown.\n" - "InnoDB: Then delete the existing log files. Edit the .cnf file\n" - "InnoDB: and start the database again.\n"); + "InnoDB: Error: all log files must be" + " created at the same time.\n" + "InnoDB: All log files must be" + " created also in database creation.\n" + "InnoDB: If you want bigger or smaller" + " log files, shut down the\n" + "InnoDB: database and make sure there" + " were no errors in shutdown.\n" + "InnoDB: Then delete the existing log files." + " Edit the .cnf file\n" + "InnoDB: and start the database again.\n"); return(DB_ERROR); } @@ -1346,30 +1408,36 @@ NetWare. */ if (log_created && !create_new_db #ifdef UNIV_LOG_ARCHIVE - && !srv_archive_recovery + && !srv_archive_recovery #endif /* UNIV_LOG_ARCHIVE */ - ) { + ) { if (ut_dulint_cmp(max_flushed_lsn, min_flushed_lsn) != 0 #ifdef UNIV_LOG_ARCHIVE - || max_arch_log_no != min_arch_log_no + || max_arch_log_no != min_arch_log_no #endif /* UNIV_LOG_ARCHIVE */ - ) { + ) { fprintf(stderr, - "InnoDB: Cannot initialize created log files because\n" - "InnoDB: data files were not in sync with each other\n" - "InnoDB: or the data files are corrupt.\n"); + "InnoDB: Cannot initialize created" + " log files because\n" + "InnoDB: data files were not in sync" + " with each other\n" + "InnoDB: or the data files are corrupt.\n"); return(DB_ERROR); } if (ut_dulint_cmp(max_flushed_lsn, ut_dulint_create(0, 1000)) - < 0) { + < 0) { fprintf(stderr, - "InnoDB: Cannot initialize created log files because\n" - "InnoDB: data files are corrupt, or new data files were\n" - "InnoDB: created when the database was started previous\n" - "InnoDB: time but the database was not shut down\n" - "InnoDB: normally after that.\n"); + "InnoDB: Cannot initialize created" + " log files because\n" + "InnoDB: data files are corrupt," + " or new data files were\n" + "InnoDB: created when the database" + " was started previous\n" + "InnoDB: time but the database" + " was not shut down\n" + "InnoDB: normally after that.\n"); return(DB_ERROR); } @@ -1401,11 +1469,12 @@ NetWare. */ #ifdef UNIV_LOG_ARCHIVE } else if (srv_archive_recovery) { fprintf(stderr, - "InnoDB: Starting archive recovery from a backup...\n"); - err = recv_recovery_from_archive_start( - min_flushed_lsn, - srv_archive_recovery_limit_lsn, - min_arch_log_no); + "InnoDB: Starting archive" + " recovery from a backup...\n"); + err = recv_recovery_from_archive_start + (min_flushed_lsn, + srv_archive_recovery_limit_lsn, + min_arch_log_no); if (err != DB_SUCCESS) { return(DB_ERROR); @@ -1428,9 +1497,9 @@ NetWare. */ been shut down normally: this is the normal startup path */ err = recv_recovery_from_checkpoint_start(LOG_CHECKPOINT, - ut_dulint_max, - min_flushed_lsn, - max_flushed_lsn); + ut_dulint_max, + min_flushed_lsn, + max_flushed_lsn); if (err != DB_SUCCESS) { return(DB_ERROR); @@ -1466,8 +1535,8 @@ NetWare. */ data dictionary tables. Does that harm the scanning of the data dictionary below? */ - dict_check_tablespaces_and_store_max_id( - recv_needed_recovery); + dict_check_tablespaces_and_store_max_id + (recv_needed_recovery); } srv_startup_is_before_trx_rollback_phase = FALSE; @@ -1519,17 +1588,17 @@ NetWare. */ #endif /* UNIV_LOG_ARCHIVE */ /* fprintf(stderr, "Max allowed record size %lu\n", - page_get_free_space_of_empty() / 2); */ + page_get_free_space_of_empty() / 2); */ /* Create the thread which watches the timeouts for lock waits and prints InnoDB monitor info */ os_thread_create(&srv_lock_timeout_and_monitor_thread, NULL, - thread_ids + 2 + SRV_MAX_N_IO_THREADS); + thread_ids + 2 + SRV_MAX_N_IO_THREADS); /* Create the thread which warns of long semaphore waits */ os_thread_create(&srv_error_monitor_thread, NULL, - thread_ids + 3 + SRV_MAX_N_IO_THREADS); + thread_ids + 3 + SRV_MAX_N_IO_THREADS); srv_was_started = TRUE; srv_is_being_started = FALSE; @@ -1559,8 +1628,8 @@ NetWare. */ /* Create the master thread which does purge and other utility operations */ - os_thread_create(&srv_master_thread, NULL, thread_ids + 1 + - SRV_MAX_N_IO_THREADS); + os_thread_create(&srv_master_thread, NULL, thread_ids + + (1 + SRV_MAX_N_IO_THREADS)); #ifdef UNIV_DEBUG /* buf_debug_prints = TRUE; */ #endif /* UNIV_DEBUG */ @@ -1573,47 +1642,60 @@ NetWare. */ tablespace_size_in_header = fsp_header_get_tablespace_size(0); if (!srv_auto_extend_last_data_file - && sum_of_data_file_sizes != tablespace_size_in_header) { + && sum_of_data_file_sizes != tablespace_size_in_header) { fprintf(stderr, -"InnoDB: Error: tablespace size stored in header is %lu pages, but\n" -"InnoDB: the sum of data file sizes is %lu pages\n", + "InnoDB: Error: tablespace size" + " stored in header is %lu pages, but\n" + "InnoDB: the sum of data file sizes is %lu pages\n", (ulong) tablespace_size_in_header, (ulong) sum_of_data_file_sizes); if (srv_force_recovery == 0 - && sum_of_data_file_sizes < tablespace_size_in_header) { + && sum_of_data_file_sizes < tablespace_size_in_header) { /* This is a fatal error, the tail of a tablespace is missing */ fprintf(stderr, -"InnoDB: Cannot start InnoDB. The tail of the system tablespace is\n" -"InnoDB: missing. Have you edited innodb_data_file_path in my.cnf in an\n" -"InnoDB: inappropriate way, removing ibdata files from there?\n" -"InnoDB: You can set innodb_force_recovery=1 in my.cnf to force\n" -"InnoDB: a startup if you are trying to recover a badly corrupt database.\n"); + "InnoDB: Cannot start InnoDB." + " The tail of the system tablespace is\n" + "InnoDB: missing. Have you edited" + " innodb_data_file_path in my.cnf in an\n" + "InnoDB: inappropriate way, removing" + " ibdata files from there?\n" + "InnoDB: You can set innodb_force_recovery=1" + " in my.cnf to force\n" + "InnoDB: a startup if you are trying" + " to recover a badly corrupt database.\n"); return(DB_ERROR); } } if (srv_auto_extend_last_data_file - && sum_of_data_file_sizes < tablespace_size_in_header) { + && sum_of_data_file_sizes < tablespace_size_in_header) { fprintf(stderr, -"InnoDB: Error: tablespace size stored in header is %lu pages, but\n" -"InnoDB: the sum of data file sizes is only %lu pages\n", + "InnoDB: Error: tablespace size stored in header" + " is %lu pages, but\n" + "InnoDB: the sum of data file sizes" + " is only %lu pages\n", (ulong) tablespace_size_in_header, (ulong) sum_of_data_file_sizes); if (srv_force_recovery == 0) { fprintf(stderr, -"InnoDB: Cannot start InnoDB. The tail of the system tablespace is\n" -"InnoDB: missing. Have you edited innodb_data_file_path in my.cnf in an\n" -"InnoDB: inappropriate way, removing ibdata files from there?\n" -"InnoDB: You can set innodb_force_recovery=1 in my.cnf to force\n" -"InnoDB: a startup if you are trying to recover a badly corrupt database.\n"); + "InnoDB: Cannot start InnoDB. The tail of" + " the system tablespace is\n" + "InnoDB: missing. Have you edited" + " innodb_data_file_path in my.cnf in an\n" + "InnoDB: inappropriate way, removing" + " ibdata files from there?\n" + "InnoDB: You can set innodb_force_recovery=1" + " in my.cnf to force\n" + "InnoDB: a startup if you are trying to" + " recover a badly corrupt database.\n"); return(DB_ERROR); } @@ -1624,8 +1706,9 @@ NetWare. */ if (0 != os_fast_mutex_trylock(&srv_os_test_mutex)) { fprintf(stderr, -"InnoDB: Error: pthread_mutex_trylock returns an unexpected value on\n" -"InnoDB: success! Cannot continue.\n"); + "InnoDB: Error: pthread_mutex_trylock returns" + " an unexpected value on\n" + "InnoDB: success! Cannot continue.\n"); exit(1); } @@ -1640,14 +1723,15 @@ NetWare. */ if (srv_print_verbose_log) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Started; log sequence number %lu %lu\n", + " InnoDB: Started; log sequence number %lu %lu\n", (ulong) ut_dulint_get_high(srv_start_lsn), (ulong) ut_dulint_get_low(srv_start_lsn)); } if (srv_force_recovery > 0) { fprintf(stderr, - "InnoDB: !!! innodb_force_recovery is set to %lu !!!\n", + "InnoDB: !!! innodb_force_recovery" + " is set to %lu !!!\n", (ulong) srv_force_recovery); } @@ -1668,9 +1752,11 @@ NetWare. */ here! */ fprintf(stderr, -"InnoDB: You are upgrading to an InnoDB version which allows multiple\n" -"InnoDB: tablespaces. Wait that purge and insert buffer merge run to\n" -"InnoDB: completion...\n"); + "InnoDB: You are upgrading to an" + " InnoDB version which allows multiple\n" + "InnoDB: tablespaces. Wait that purge" + " and insert buffer merge run to\n" + "InnoDB: completion...\n"); for (;;) { os_thread_sleep(1000000); @@ -1683,16 +1769,21 @@ NetWare. */ } } fprintf(stderr, -"InnoDB: Full purge and insert buffer merge completed.\n"); + "InnoDB: Full purge and insert buffer merge" + " completed.\n"); trx_sys_mark_upgraded_to_multiple_tablespaces(); fprintf(stderr, -"InnoDB: You have now successfully upgraded to the multiple tablespaces\n" -"InnoDB: format. You should NOT DOWNGRADE to an earlier version of\n" -"InnoDB: InnoDB! But if you absolutely need to downgrade, see\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/multiple-tablespaces.html\n" -"InnoDB: for instructions.\n"); + "InnoDB: You have now successfully upgraded" + " to the multiple tablespaces\n" + "InnoDB: format. You should NOT DOWNGRADE" + " to an earlier version of\n" + "InnoDB: InnoDB! But if you absolutely need to" + " downgrade, see\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "multiple-tablespaces.html\n" + "InnoDB: for instructions.\n"); } if (srv_force_recovery == 0) { @@ -1725,8 +1816,9 @@ innobase_shutdown_for_mysql(void) if (srv_is_being_started) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Warning: shutting down a not properly started\n" -" InnoDB: or created database!\n"); + " InnoDB: Warning: shutting down" + " a not properly started\n" + "InnoDB: or created database!\n"); } return(DB_SUCCESS); @@ -1741,21 +1833,24 @@ innobase_shutdown_for_mysql(void) if (srv_fast_shutdown == 2) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: MySQL has requested a very fast shutdown without flushing " -"the InnoDB buffer pool to data files. At the next mysqld startup " -"InnoDB will do a crash recovery!\n"); + " InnoDB: MySQL has requested a very fast shutdown" + " without flushing " + "the InnoDB buffer pool to data files." + " At the next mysqld startup " + "InnoDB will do a crash recovery!\n"); } #ifdef __NETWARE__ if(!panic_shutdown) #endif - logs_empty_and_mark_files_at_shutdown(); + logs_empty_and_mark_files_at_shutdown(); if (srv_conc_n_threads != 0) { fprintf(stderr, - "InnoDB: Warning: query counter shows %ld queries still\n" - "InnoDB: inside InnoDB at shutdown\n", - srv_conc_n_threads); + "InnoDB: Warning: query counter shows %ld queries" + " still\n" + "InnoDB: inside InnoDB at shutdown\n", + srv_conc_n_threads); } /* 2. Make all threads created by InnoDB to exit */ @@ -1814,7 +1909,8 @@ innobase_shutdown_for_mysql(void) if (i == 1000) { fprintf(stderr, -"InnoDB: Warning: %lu threads created by InnoDB had not exited at shutdown!\n", + "InnoDB: Warning: %lu threads created by InnoDB" + " had not exited at shutdown!\n", (ulong) os_thread_count); } @@ -1854,9 +1950,10 @@ innobase_shutdown_for_mysql(void) if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) { fprintf(stderr, -"InnoDB: Error: all read views were not closed before shutdown:\n" -"InnoDB: %lu read views open \n", - UT_LIST_GET_LEN(trx_sys->view_list) - 1); + "InnoDB: Error: all read views were not closed" + " before shutdown:\n" + "InnoDB: %lu read views open \n", + UT_LIST_GET_LEN(trx_sys->view_list) - 1); } /* 5. Free all allocated memory and the os_fast_mutex created in @@ -1865,12 +1962,14 @@ innobase_shutdown_for_mysql(void) ut_free_all_mem(); if (os_thread_count != 0 - || os_event_count != 0 - || os_mutex_count != 0 - || os_fast_mutex_count != 0) { + || os_event_count != 0 + || os_mutex_count != 0 + || os_fast_mutex_count != 0) { fprintf(stderr, -"InnoDB: Warning: some resources were not cleaned up in shutdown:\n" -"InnoDB: threads %lu, events %lu, os_mutexes %lu, os_fast_mutexes %lu\n", + "InnoDB: Warning: some resources were not" + " cleaned up in shutdown:\n" + "InnoDB: threads %lu, events %lu," + " os_mutexes %lu, os_fast_mutexes %lu\n", (ulong) os_thread_count, (ulong) os_event_count, (ulong) os_mutex_count, (ulong) os_fast_mutex_count); } @@ -1885,7 +1984,8 @@ innobase_shutdown_for_mysql(void) if (srv_print_verbose_log) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Shutdown completed; log sequence number %lu %lu\n", + " InnoDB: Shutdown completed;" + " log sequence number %lu %lu\n", (ulong) ut_dulint_get_high(srv_shutdown_lsn), (ulong) ut_dulint_get_low(srv_shutdown_lsn)); } diff --git a/storage/innobase/sync/sync0arr.c b/storage/innobase/sync/sync0arr.c index 81986cdfd33..278dd65bb1e 100644 --- a/storage/innobase/sync/sync0arr.c +++ b/storage/innobase/sync/sync0arr.c @@ -498,7 +498,8 @@ sync_array_cell_print( type = cell->request_type; fprintf(file, -"--Thread %lu has waited at %s line %lu for %.2f seconds the semaphore:\n", + "--Thread %lu has waited at %s line %lu" + " for %.2f seconds the semaphore:\n", (ulong) os_thread_pf(cell->thread), cell->file, (ulong) cell->line, difftime(time(NULL), cell->reservation_time)); @@ -542,7 +543,8 @@ sync_array_cell_print( (ulong) rwlock->cline); if (rwlock->writer != RW_LOCK_NOT_LOCKED) { fprintf(file, - "a writer (thread id %lu) has reserved it in mode %s", + "a writer (thread id %lu) has" + " reserved it in mode %s", (ulong) os_thread_pf(rwlock->writer_thread), rwlock->writer == RW_LOCK_EX ? " exclusive\n" @@ -588,7 +590,7 @@ sync_array_find_thread( cell = sync_array_get_nth_cell(arr, i); if ((cell->state == SC_RESERVED) - && os_thread_eq(cell->thread, thread)) { + && os_thread_eq(cell->thread, thread)) { return(cell); /* Found */ } @@ -634,7 +636,7 @@ sync_array_deadlock_step( /* Deadlock */ fputs("########################################\n" - "DEADLOCK of threads detected!\n", stderr); + "DEADLOCK of threads detected!\n", stderr); return(TRUE); @@ -697,10 +699,11 @@ sync_array_detect_deadlock( a thread with ID_UNDEFINED value. */ ret = sync_array_deadlock_step(arr, start, thread, 0, - depth); + depth); if (ret) { fprintf(stderr, - "Mutex %p owned by thread %lu file %s line %lu\n", + "Mutex %p owned by thread %lu" + " file %s line %lu\n", (void*) mutex, (ulong) os_thread_pf(mutex->thread_id), mutex->file_name, (ulong) mutex->line); @@ -723,10 +726,10 @@ sync_array_detect_deadlock( thread = debug->thread_id; if (((debug->lock_type == RW_LOCK_EX) - && !os_thread_eq(thread, cell->thread)) - || ((debug->lock_type == RW_LOCK_WAIT_EX) - && !os_thread_eq(thread, cell->thread)) - || (debug->lock_type == RW_LOCK_SHARED)) { + && !os_thread_eq(thread, cell->thread)) + || ((debug->lock_type == RW_LOCK_WAIT_EX) + && !os_thread_eq(thread, cell->thread)) + || (debug->lock_type == RW_LOCK_SHARED)) { /* The (wait) x-lock request can block infinitely only if someone (can be also cell @@ -734,10 +737,11 @@ sync_array_detect_deadlock( (cannot be cell thread) (wait) x-lock, and he is blocked by start thread */ - ret = sync_array_deadlock_step(arr, start, - thread, debug->pass, depth); + ret = sync_array_deadlock_step + (arr, start, thread, + debug->pass, depth); if (ret) { - print: +print: fprintf(stderr, "rw-lock %p ", (void*) lock); sync_array_cell_print(stderr, cell); @@ -761,15 +765,16 @@ sync_array_detect_deadlock( thread = debug->thread_id; if ((debug->lock_type == RW_LOCK_EX) - || (debug->lock_type == RW_LOCK_WAIT_EX)) { + || (debug->lock_type == RW_LOCK_WAIT_EX)) { /* The s-lock request can block infinitely only if someone (can also be cell thread) is holding (wait) x-lock, and he is blocked by start thread */ - ret = sync_array_deadlock_step(arr, start, - thread, debug->pass, depth); + ret = sync_array_deadlock_step + (arr, start, thread, + debug->pass, depth); if (ret) { goto print; } @@ -814,14 +819,14 @@ sync_arr_cell_can_wake_up( lock = cell->wait_object; if (rw_lock_get_reader_count(lock) == 0 - && rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) { + && rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) { return(TRUE); } if (rw_lock_get_reader_count(lock) == 0 - && rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX - && os_thread_eq(lock->writer_thread, cell->thread)) { + && rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX + && os_thread_eq(lock->writer_thread, cell->thread)) { return(TRUE); } @@ -897,16 +902,16 @@ sync_array_signal_object( sync_cell_t** old_cell_ptr = cell_ptr; size_t old_size, new_size; - old_size = cell_max_count * - sizeof(sync_cell_t*); + old_size = cell_max_count + * sizeof(sync_cell_t*); cell_max_count *= 2; - new_size = cell_max_count * - sizeof(sync_cell_t*); + new_size = cell_max_count + * sizeof(sync_cell_t*); cell_ptr = malloc(new_size); ut_a(cell_ptr); memcpy(cell_ptr, old_cell_ptr, - old_size); + old_size); if (old_cell_ptr != &cells[0]) { free(old_cell_ptr); @@ -1009,23 +1014,24 @@ sync_array_print_long_waits(void) cell = sync_array_get_nth_cell(sync_primary_wait_array, i); if ((cell->state != SC_FREE) - && difftime(time(NULL), cell->reservation_time) > 240) { + && difftime(time(NULL), cell->reservation_time) > 240) { fputs("InnoDB: Warning: a long semaphore wait:\n", - stderr); + stderr); sync_array_cell_print(stderr, cell); noticed = TRUE; } if ((cell->state != SC_FREE) - && difftime(time(NULL), cell->reservation_time) - > fatal_timeout) { + && difftime(time(NULL), cell->reservation_time) + > fatal_timeout) { fatal = TRUE; } } if (noticed) { fprintf(stderr, -"InnoDB: ###### Starts InnoDB Monitor for 30 secs to print diagnostic info:\n"); + "InnoDB: ###### Starts InnoDB Monitor" + " for 30 secs to print diagnostic info:\n"); old_val = srv_print_innodb_monitor; /* If some crucial semaphore is reserved, then also the InnoDB @@ -1035,8 +1041,9 @@ sync_array_print_long_waits(void) now the values of pending calls of these. */ fprintf(stderr, -"InnoDB: Pending preads %lu, pwrites %lu\n", (ulong)os_file_n_pending_preads, - (ulong)os_file_n_pending_pwrites); + "InnoDB: Pending preads %lu, pwrites %lu\n", + (ulong)os_file_n_pending_preads, + (ulong)os_file_n_pending_pwrites); srv_print_innodb_monitor = TRUE; os_event_set(srv_lock_timeout_thread_event); @@ -1045,7 +1052,8 @@ sync_array_print_long_waits(void) srv_print_innodb_monitor = old_val; fprintf(stderr, -"InnoDB: ###### Diagnostic info printed to the standard error stream\n"); + "InnoDB: ###### Diagnostic info printed" + " to the standard error stream\n"); } return(fatal); @@ -1065,9 +1073,10 @@ sync_array_output_info( ulint i; fprintf(file, - "OS WAIT ARRAY INFO: reservation count %ld, signal count %ld\n", - (long) arr->res_count, - (long) arr->sg_count); + "OS WAIT ARRAY INFO: reservation count %ld," + " signal count %ld\n", + (long) arr->res_count, + (long) arr->sg_count); for (i = 0; i < arr->n_cells; i++) { cell = sync_array_get_nth_cell(arr, i); diff --git a/storage/innobase/sync/sync0rw.c b/storage/innobase/sync/sync0rw.c index ffc2633b467..f22b0dc8d61 100644 --- a/storage/innobase/sync/sync0rw.c +++ b/storage/innobase/sync/sync0rw.c @@ -103,8 +103,8 @@ rw_lock_create_func( lock->mutex.cline = cline; #ifndef UNIV_HOTBACKUP - lock->mutex.cmutex_name = cmutex_name; - lock->mutex.mutex_type = 1; + lock->mutex.cmutex_name = cmutex_name; + lock->mutex.mutex_type = 1; #endif /* !UNIV_HOTBACKUP */ rw_lock_set_waiters(lock, 0); @@ -134,7 +134,7 @@ rw_lock_create_func( if (UT_LIST_GET_LEN(rw_lock_list) > 0) { ut_a(UT_LIST_GET_FIRST(rw_lock_list)->magic_n - == RW_LOCK_MAGIC_N); + == RW_LOCK_MAGIC_N); } UT_LIST_ADD_FIRST(list, rw_lock_list, lock); @@ -192,12 +192,12 @@ rw_lock_validate( ut_a(lock->magic_n == RW_LOCK_MAGIC_N); ut_a((rw_lock_get_reader_count(lock) == 0) - || (rw_lock_get_writer(lock) != RW_LOCK_EX)); + || (rw_lock_get_writer(lock) != RW_LOCK_EX)); ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX) - || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX) - || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)); + || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX) + || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)); ut_a((rw_lock_get_waiters(lock) == 0) - || (rw_lock_get_waiters(lock) == 1)); + || (rw_lock_get_waiters(lock) == 1)); ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0)); mutex_exit(rw_lock_get_mutex(lock)); @@ -232,7 +232,7 @@ lock_loop: i = 0; while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED - && i < SYNC_SPIN_ROUNDS) { + && i < SYNC_SPIN_ROUNDS) { if (srv_spin_wait_delay) { ut_delay(ut_rnd_interval(0, srv_spin_wait_delay)); } @@ -246,9 +246,11 @@ lock_loop: if (srv_print_latch_waits) { fprintf(stderr, - "Thread %lu spin wait rw-s-lock at %p cfile %s cline %lu rnds %lu\n", - (ulong) os_thread_pf(os_thread_get_curr_id()), (void*) lock, - lock->cfile_name, (ulong) lock->cline, (ulong) i); + "Thread %lu spin wait rw-s-lock at %p" + " cfile %s cline %lu rnds %lu\n", + (ulong) os_thread_pf(os_thread_get_curr_id()), + (void*) lock, + lock->cfile_name, (ulong) lock->cline, (ulong) i); } mutex_enter(rw_lock_get_mutex(lock)); @@ -266,9 +268,9 @@ lock_loop: rw_s_system_call_count++; sync_array_reserve_cell(sync_primary_wait_array, - lock, RW_LOCK_SHARED, - file_name, line, - &index); + lock, RW_LOCK_SHARED, + file_name, line, + &index); rw_lock_set_waiters(lock, 1); @@ -276,7 +278,8 @@ lock_loop: if (srv_print_latch_waits) { fprintf(stderr, - "Thread %lu OS wait rw-s-lock at %p cfile %s cline %lu\n", + "Thread %lu OS wait rw-s-lock at %p" + " cfile %s cline %lu\n", os_thread_pf(os_thread_get_curr_id()), (void*) lock, lock->cfile_name, (ulong) lock->cline); @@ -346,7 +349,7 @@ rw_lock_x_lock_low( #ifdef UNIV_SYNC_DEBUG rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, - file_name, line); + file_name, line); #endif lock->last_x_file_name = file_name; lock->last_x_line = line; @@ -362,7 +365,7 @@ rw_lock_x_lock_low( #ifdef UNIV_SYNC_DEBUG rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX, - file_name, line); + file_name, line); #endif return(RW_LOCK_WAIT_EX); @@ -370,7 +373,7 @@ rw_lock_x_lock_low( } else if ((rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX) && os_thread_eq(lock->writer_thread, - os_thread_get_curr_id())) { + os_thread_get_curr_id())) { if (rw_lock_get_reader_count(lock) == 0) { @@ -382,7 +385,7 @@ rw_lock_x_lock_low( #ifdef UNIV_SYNC_DEBUG rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX); rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, - file_name, line); + file_name, line); #endif lock->last_x_file_name = file_name; @@ -396,7 +399,7 @@ rw_lock_x_lock_low( } else if ((rw_lock_get_writer(lock) == RW_LOCK_EX) && os_thread_eq(lock->writer_thread, - os_thread_get_curr_id()) + os_thread_get_curr_id()) && (lock->pass == 0) && (pass == 0)) { @@ -404,7 +407,7 @@ rw_lock_x_lock_low( #ifdef UNIV_SYNC_DEBUG rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name, - line); + line); #endif lock->last_x_file_name = file_name; @@ -461,10 +464,10 @@ lock_loop: i = 0; while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED - && i < SYNC_SPIN_ROUNDS) { + && i < SYNC_SPIN_ROUNDS) { if (srv_spin_wait_delay) { ut_delay(ut_rnd_interval(0, - srv_spin_wait_delay)); + srv_spin_wait_delay)); } i++; @@ -478,10 +481,10 @@ lock_loop: i = 0; while (rw_lock_get_reader_count(lock) != 0 - && i < SYNC_SPIN_ROUNDS) { + && i < SYNC_SPIN_ROUNDS) { if (srv_spin_wait_delay) { ut_delay(ut_rnd_interval(0, - srv_spin_wait_delay)); + srv_spin_wait_delay)); } i++; @@ -496,7 +499,8 @@ lock_loop: if (srv_print_latch_waits) { fprintf(stderr, - "Thread %lu spin wait rw-x-lock at %p cfile %s cline %lu rnds %lu\n", + "Thread %lu spin wait rw-x-lock at %p" + " cfile %s cline %lu rnds %lu\n", os_thread_pf(os_thread_get_curr_id()), (void*) lock, lock->cfile_name, (ulong) lock->cline, (ulong) i); } @@ -529,7 +533,8 @@ lock_loop: if (srv_print_latch_waits) { fprintf(stderr, - "Thread %lu OS wait for rw-x-lock at %p cfile %s cline %lu\n", + "Thread %lu OS wait for rw-x-lock at %p" + " cfile %s cline %lu\n", os_thread_pf(os_thread_get_curr_id()), (void*) lock, lock->cfile_name, (ulong) lock->cline); } @@ -556,7 +561,7 @@ rw_lock_debug_mutex_enter(void) { loop: if (0 == mutex_enter_nowait(&rw_lock_debug_mutex, - __FILE__, __LINE__)) { + __FILE__, __LINE__)) { return; } @@ -565,7 +570,7 @@ loop: rw_lock_debug_waiters = TRUE; if (0 == mutex_enter_nowait(&rw_lock_debug_mutex, - __FILE__, __LINE__)) { + __FILE__, __LINE__)) { return; } @@ -649,10 +654,10 @@ rw_lock_remove_debug_info( while (info != NULL) { if ((pass == info->pass) - && ((pass != 0) - || os_thread_eq(info->thread_id, + && ((pass != 0) + || os_thread_eq(info->thread_id, os_thread_get_curr_id())) - && (info->lock_type == lock_type)) { + && (info->lock_type == lock_type)) { /* Found! */ UT_LIST_REMOVE(list, lock->debug_list, info); @@ -695,8 +700,8 @@ rw_lock_own( while (info != NULL) { if (os_thread_eq(info->thread_id, os_thread_get_curr_id()) - && (info->pass == 0) - && (info->lock_type == lock_type)) { + && (info->pass == 0) + && (info->lock_type == lock_type)) { mutex_exit(&(lock->mutex)); /* Found! */ @@ -762,8 +767,8 @@ rw_lock_list_print_info(void) mutex_enter(&rw_lock_list_mutex); fputs("-------------\n" - "RW-LATCH INFO\n" - "-------------\n", stderr); + "RW-LATCH INFO\n" + "-------------\n", stderr); lock = UT_LIST_GET_FIRST(rw_lock_list); @@ -774,8 +779,8 @@ rw_lock_list_print_info(void) mutex_enter(&(lock->mutex)); if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) - || (rw_lock_get_reader_count(lock) != 0) - || (rw_lock_get_waiters(lock) != 0)) { + || (rw_lock_get_reader_count(lock) != 0) + || (rw_lock_get_waiters(lock) != 0)) { fprintf(stderr, "RW-LOCK: %p ", (void*) lock); @@ -816,8 +821,8 @@ rw_lock_print( "RW-LATCH: %p ", (void*) lock); if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) - || (rw_lock_get_reader_count(lock) != 0) - || (rw_lock_get_waiters(lock) != 0)) { + || (rw_lock_get_reader_count(lock) != 0) + || (rw_lock_get_waiters(lock) != 0)) { if (rw_lock_get_waiters(lock)) { fputs(" Waiters for the lock exist\n", stderr); @@ -882,7 +887,7 @@ rw_lock_n_locked(void) mutex_enter(rw_lock_get_mutex(lock)); if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) - || (rw_lock_get_reader_count(lock) != 0)) { + || (rw_lock_get_reader_count(lock) != 0)) { count++; } diff --git a/storage/innobase/sync/sync0sync.c b/storage/innobase/sync/sync0sync.c index 04f03e89ec5..d74b2b09ccf 100644 --- a/storage/innobase/sync/sync0sync.c +++ b/storage/innobase/sync/sync0sync.c @@ -277,11 +277,11 @@ mutex_free( if (UT_LIST_GET_PREV(list, mutex)) { ut_a(UT_LIST_GET_PREV(list, mutex)->magic_n - == MUTEX_MAGIC_N); + == MUTEX_MAGIC_N); } if (UT_LIST_GET_NEXT(list, mutex)) { ut_a(UT_LIST_GET_NEXT(list, mutex)->magic_n - == MUTEX_MAGIC_N); + == MUTEX_MAGIC_N); } UT_LIST_REMOVE(list, mutex_list, mutex); @@ -351,8 +351,8 @@ mutex_set_waiters( mutex_t* mutex, /* in: mutex */ ulint n) /* in: value to set */ { -volatile ulint* ptr; /* declared volatile to ensure that - the value is stored to memory */ + volatile ulint* ptr; /* declared volatile to ensure that + the value is stored to memory */ ut_ad(mutex); ptr = &(mutex->waiters); @@ -423,7 +423,8 @@ spin_loop: #ifdef UNIV_SRV_PRINT_LATCH_WAITS fprintf(stderr, - "Thread %lu spin wait mutex at %p cfile %s cline %lu rnds %lu\n", + "Thread %lu spin wait mutex at %p" + " cfile %s cline %lu rnds %lu\n", (ulong) os_thread_pf(os_thread_get_curr_id()), (void*) mutex, mutex->cfile_name, (ulong) mutex->cline, (ulong) i); #endif @@ -458,7 +459,7 @@ spin_loop: } sync_array_reserve_cell(sync_primary_wait_array, mutex, - SYNC_MUTEX, file_name, line, &index); + SYNC_MUTEX, file_name, line, &index); mutex_system_call_count++; @@ -476,7 +477,7 @@ spin_loop: /* Succeeded! Free the reserved wait cell */ sync_array_free_cell_protected(sync_primary_wait_array, - index); + index); #ifdef UNIV_SYNC_DEBUG mutex_set_debug_info(mutex, file_name, line); @@ -639,8 +640,8 @@ mutex_list_print_info(void) ulint count = 0; fputs("----------\n" - "MUTEX INFO\n" - "----------\n", stderr); + "MUTEX INFO\n" + "----------\n", stderr); mutex_enter(&mutex_list_mutex); @@ -651,9 +652,10 @@ mutex_list_print_info(void) if (mutex_get_lock_word(mutex) != 0) { mutex_get_debug_info(mutex, &file_name, &line, - &thread_id); + &thread_id); fprintf(stderr, - "Locked mutex: addr %p thread %ld file %s line %ld\n", + "Locked mutex: addr %p thread %ld" + " file %s line %ld\n", (void*) mutex, os_thread_pf(thread_id), file_name, line); } @@ -820,8 +822,9 @@ sync_thread_levels_g( mutex = slot->latch; fprintf(stderr, - "InnoDB error: sync levels should be > %lu but a level is %lu\n", - (ulong) limit, (ulong) slot->level); + "InnoDB error: sync levels should be" + " > %lu but a level is %lu\n", + (ulong) limit, (ulong) slot->level); if (mutex->magic_n == MUTEX_MAGIC_N) { fprintf(stderr, @@ -835,15 +838,24 @@ sync_thread_levels_g( ulint line; os_thread_id_t thread_id; - mutex_get_debug_info(mutex, - &file_name, &line, &thread_id); + mutex_get_debug_info + (mutex, &file_name, + &line, &thread_id); fprintf(stderr, - "InnoDB: Locked mutex: addr %p thread %ld file %s line %ld\n", - (void*) mutex, os_thread_pf(thread_id), file_name, (ulong) line); + "InnoDB: Locked mutex:" + " addr %p thread %ld" + " file %s line %ld\n", + (void*) mutex, + os_thread_pf + (thread_id), + file_name, + (ulong) line); #else /* UNIV_SYNC_DEBUG */ fprintf(stderr, - "InnoDB: Locked mutex: addr %p\n", (void*) mutex); + "InnoDB: Locked mutex:" + " addr %p\n", + (void*) mutex); #endif /* UNIV_SYNC_DEBUG */ } else { fputs("Not locked\n", stderr); @@ -931,9 +943,10 @@ sync_thread_levels_empty_gen( slot = sync_thread_levels_get_nth(arr, i); - if (slot->latch != NULL && (!dict_mutex_allowed || - (slot->level != SYNC_DICT - && slot->level != SYNC_DICT_OPERATION))) { + if (slot->latch != NULL + && (!dict_mutex_allowed + || (slot->level != SYNC_DICT + && slot->level != SYNC_DICT_OPERATION))) { mutex_exit(&sync_thread_mutex); ut_error; @@ -981,11 +994,11 @@ sync_thread_add_level( } if ((latch == (void*)&sync_thread_mutex) - || (latch == (void*)&mutex_list_mutex) + || (latch == (void*)&mutex_list_mutex) #ifdef UNIV_SYNC_DEBUG - || (latch == (void*)&rw_lock_debug_mutex) + || (latch == (void*)&rw_lock_debug_mutex) #endif /* UNIV_SYNC_DEBUG */ - || (latch == (void*)&rw_lock_list_mutex)) { + || (latch == (void*)&rw_lock_list_mutex)) { return; } @@ -1058,8 +1071,8 @@ sync_thread_add_level( break; case SYNC_BUF_BLOCK: ut_a((sync_thread_levels_contain(array, SYNC_BUF_POOL) - && sync_thread_levels_g(array, SYNC_BUF_BLOCK - 1)) - || sync_thread_levels_g(array, SYNC_BUF_BLOCK)); + && sync_thread_levels_g(array, SYNC_BUF_BLOCK - 1)) + || sync_thread_levels_g(array, SYNC_BUF_BLOCK)); break; case SYNC_BUF_POOL: ut_a(sync_thread_levels_g(array, SYNC_BUF_POOL)); @@ -1072,16 +1085,16 @@ sync_thread_add_level( break; case SYNC_REC_LOCK: ut_a((sync_thread_levels_contain(array, SYNC_KERNEL) - && sync_thread_levels_g(array, SYNC_REC_LOCK - 1)) - || sync_thread_levels_g(array, SYNC_REC_LOCK)); + && sync_thread_levels_g(array, SYNC_REC_LOCK - 1)) + || sync_thread_levels_g(array, SYNC_REC_LOCK)); break; case SYNC_KERNEL: ut_a(sync_thread_levels_g(array, SYNC_KERNEL)); break; case SYNC_IBUF_BITMAP: ut_a((sync_thread_levels_contain(array, SYNC_IBUF_BITMAP_MUTEX) - && sync_thread_levels_g(array, SYNC_IBUF_BITMAP - 1)) - || sync_thread_levels_g(array, SYNC_IBUF_BITMAP)); + && sync_thread_levels_g(array, SYNC_IBUF_BITMAP - 1)) + || sync_thread_levels_g(array, SYNC_IBUF_BITMAP)); break; case SYNC_IBUF_BITMAP_MUTEX: ut_a(sync_thread_levels_g(array, SYNC_IBUF_BITMAP_MUTEX)); @@ -1091,20 +1104,20 @@ sync_thread_add_level( break; case SYNC_FSP: ut_a(sync_thread_levels_contain(array, SYNC_FSP) - || sync_thread_levels_g(array, SYNC_FSP)); + || sync_thread_levels_g(array, SYNC_FSP)); break; case SYNC_TRX_UNDO_PAGE: ut_a(sync_thread_levels_contain(array, SYNC_TRX_UNDO) - || sync_thread_levels_contain(array, SYNC_RSEG) - || sync_thread_levels_contain(array, SYNC_PURGE_SYS) - || sync_thread_levels_g(array, SYNC_TRX_UNDO_PAGE)); + || sync_thread_levels_contain(array, SYNC_RSEG) + || sync_thread_levels_contain(array, SYNC_PURGE_SYS) + || sync_thread_levels_g(array, SYNC_TRX_UNDO_PAGE)); break; case SYNC_RSEG_HEADER: ut_a(sync_thread_levels_contain(array, SYNC_RSEG)); break; case SYNC_RSEG_HEADER_NEW: ut_a(sync_thread_levels_contain(array, SYNC_KERNEL) - && sync_thread_levels_contain(array, SYNC_FSP_PAGE)); + && sync_thread_levels_contain(array, SYNC_FSP_PAGE)); break; case SYNC_RSEG: ut_a(sync_thread_levels_g(array, SYNC_RSEG)); @@ -1120,30 +1133,30 @@ sync_thread_add_level( break; case SYNC_TREE_NODE: ut_a(sync_thread_levels_contain(array, SYNC_INDEX_TREE) - || sync_thread_levels_g(array, SYNC_TREE_NODE - 1)); + || sync_thread_levels_g(array, SYNC_TREE_NODE - 1)); break; case SYNC_TREE_NODE_NEW: ut_a(sync_thread_levels_contain(array, SYNC_FSP_PAGE) - || sync_thread_levels_contain(array, SYNC_IBUF_MUTEX)); + || sync_thread_levels_contain(array, SYNC_IBUF_MUTEX)); break; case SYNC_INDEX_TREE: ut_a((sync_thread_levels_contain(array, SYNC_IBUF_MUTEX) - && sync_thread_levels_contain(array, SYNC_FSP) - && sync_thread_levels_g(array, SYNC_FSP_PAGE - 1)) - || sync_thread_levels_g(array, SYNC_TREE_NODE - 1)); + && sync_thread_levels_contain(array, SYNC_FSP) + && sync_thread_levels_g(array, SYNC_FSP_PAGE - 1)) + || sync_thread_levels_g(array, SYNC_TREE_NODE - 1)); break; case SYNC_IBUF_MUTEX: ut_a(sync_thread_levels_g(array, SYNC_FSP_PAGE - 1)); break; case SYNC_IBUF_PESS_INSERT_MUTEX: ut_a(sync_thread_levels_g(array, SYNC_FSP - 1) - && !sync_thread_levels_contain(array, SYNC_IBUF_MUTEX)); + && !sync_thread_levels_contain(array, SYNC_IBUF_MUTEX)); break; case SYNC_IBUF_HEADER: ut_a(sync_thread_levels_g(array, SYNC_FSP - 1) - && !sync_thread_levels_contain(array, SYNC_IBUF_MUTEX) - && !sync_thread_levels_contain(array, - SYNC_IBUF_PESS_INSERT_MUTEX)); + && !sync_thread_levels_contain(array, SYNC_IBUF_MUTEX) + && !sync_thread_levels_contain + (array, SYNC_IBUF_PESS_INSERT_MUTEX)); break; case SYNC_DICT_AUTOINC_MUTEX: ut_a(sync_thread_levels_g(array, SYNC_DICT_AUTOINC_MUTEX)); @@ -1157,7 +1170,7 @@ sync_thread_add_level( case SYNC_DICT: #ifdef UNIV_DEBUG ut_a(buf_debug_prints - || sync_thread_levels_g(array, SYNC_DICT)); + || sync_thread_levels_g(array, SYNC_DICT)); #else /* UNIV_DEBUG */ ut_a(sync_thread_levels_g(array, SYNC_DICT)); #endif /* UNIV_DEBUG */ @@ -1204,11 +1217,11 @@ sync_thread_reset_level( } if ((latch == (void*)&sync_thread_mutex) - || (latch == (void*)&mutex_list_mutex) + || (latch == (void*)&mutex_list_mutex) #ifdef UNIV_SYNC_DEBUG - || (latch == (void*)&rw_lock_debug_mutex) + || (latch == (void*)&rw_lock_debug_mutex) #endif /* UNIV_SYNC_DEBUG */ - || (latch == (void*)&rw_lock_list_mutex)) { + || (latch == (void*)&rw_lock_list_mutex)) { return(FALSE); } @@ -1265,13 +1278,13 @@ sync_init(void) mutex */ sync_primary_wait_array = sync_array_create(OS_THREAD_MAX_N, - SYNC_ARRAY_OS_MUTEX); + SYNC_ARRAY_OS_MUTEX); /* Create the thread latch level array where the latch levels are stored for each OS thread */ sync_thread_level_arrays = ut_malloc(OS_THREAD_MAX_N - * sizeof(sync_thread_t)); + * sizeof(sync_thread_t)); for (i = 0; i < OS_THREAD_MAX_N; i++) { thread_slot = sync_thread_level_arrays_get_nth(i); @@ -1335,15 +1348,16 @@ sync_print_wait_info( #endif fprintf(file, -"Mutex spin waits %lu, rounds %lu, OS waits %lu\n" -"RW-shared spins %lu, OS waits %lu; RW-excl spins %lu, OS waits %lu\n", - (ulong) mutex_spin_wait_count, - (ulong) mutex_spin_round_count, - (ulong) mutex_os_wait_count, - (ulong) rw_s_spin_wait_count, - (ulong) rw_s_os_wait_count, - (ulong) rw_x_spin_wait_count, - (ulong) rw_x_os_wait_count); + "Mutex spin waits %lu, rounds %lu, OS waits %lu\n" + "RW-shared spins %lu, OS waits %lu;" + " RW-excl spins %lu, OS waits %lu\n", + (ulong) mutex_spin_wait_count, + (ulong) mutex_spin_round_count, + (ulong) mutex_os_wait_count, + (ulong) rw_s_spin_wait_count, + (ulong) rw_s_os_wait_count, + (ulong) rw_x_spin_wait_count, + (ulong) rw_x_os_wait_count); } /*********************************************************************** diff --git a/storage/innobase/thr/thr0loc.c b/storage/innobase/thr/thr0loc.c index c63520e8a07..f22e909f392 100644 --- a/storage/innobase/thr/thr0loc.c +++ b/storage/innobase/thr/thr0loc.c @@ -73,7 +73,7 @@ try_again: local = NULL; HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id), - local, os_thread_eq(local->id, id)); + local, os_thread_eq(local->id, id)); if (local == NULL) { mutex_exit(&thr_local_mutex); @@ -176,8 +176,8 @@ thr_local_create(void) mutex_enter(&thr_local_mutex); HASH_INSERT(thr_local_t, hash, thr_local_hash, - os_thread_pf(os_thread_get_curr_id()), - local); + os_thread_pf(os_thread_get_curr_id()), + local); mutex_exit(&thr_local_mutex); } @@ -197,7 +197,7 @@ thr_local_free( /* Look for the local struct in the hash table */ HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id), - local, os_thread_eq(local->id, id)); + local, os_thread_eq(local->id, id)); if (local == NULL) { mutex_exit(&thr_local_mutex); @@ -205,7 +205,7 @@ thr_local_free( } HASH_DELETE(thr_local_t, hash, thr_local_hash, - os_thread_pf(id), local); + os_thread_pf(id), local); mutex_exit(&thr_local_mutex); diff --git a/storage/innobase/trx/trx0purge.c b/storage/innobase/trx/trx0purge.c index 79f38b1ee52..9689a9fb179 100644 --- a/storage/innobase/trx/trx0purge.c +++ b/storage/innobase/trx/trx0purge.c @@ -142,9 +142,9 @@ trx_purge_arr_get_biggest( trx_cmp = ut_dulint_cmp(cell->trx_no, pair_trx_no); if ((trx_cmp > 0) - || ((trx_cmp == 0) - && (ut_dulint_cmp(cell->undo_no, - pair_undo_no) >= 0))) { + || ((trx_cmp == 0) + && (ut_dulint_cmp(cell->undo_no, + pair_undo_no) >= 0))) { pair_trx_no = cell->trx_no; pair_undo_no = cell->undo_no; @@ -172,7 +172,7 @@ trx_purge_graph_build(void) mem_heap_t* heap; que_fork_t* fork; que_thr_t* thr; -/* que_thr_t* thr2; */ + /* que_thr_t* thr2; */ heap = mem_heap_create(512); fork = que_fork_create(NULL, NULL, QUE_FORK_PURGE, heap); @@ -182,7 +182,7 @@ trx_purge_graph_build(void) thr->child = row_purge_node_create(thr, heap); -/* thr2 = que_thr_create(fork, fork, heap); + /* thr2 = que_thr_create(fork, fork, heap); thr2->child = row_purge_node_create(fork, thr2, heap); */ @@ -229,8 +229,8 @@ trx_purge_sys_create(void) purge_sys->query = trx_purge_graph_build(); - purge_sys->view = read_view_oldest_copy_or_open_new( - ut_dulint_create(0,0), purge_sys->heap); + purge_sys->view = read_view_oldest_copy_or_open_new(ut_dulint_zero, + purge_sys->heap); } /*================ UNDO LOG HISTORY LIST =============================*/ @@ -275,24 +275,25 @@ trx_purge_add_update_undo_to_history( if (undo->id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, - "InnoDB: Error: undo->id is %lu\n", (ulong) undo->id); + "InnoDB: Error: undo->id is %lu\n", + (ulong) undo->id); ut_error; } trx_rsegf_set_nth_undo(rseg_header, undo->id, FIL_NULL, mtr); hist_size = mtr_read_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE, - MLOG_4BYTES, mtr); - ut_ad(undo->size == - flst_get_len(seg_header + TRX_UNDO_PAGE_LIST, mtr)); + MLOG_4BYTES, mtr); + ut_ad(undo->size == flst_get_len + (seg_header + TRX_UNDO_PAGE_LIST, mtr)); mlog_write_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE, - hist_size + undo->size, MLOG_4BYTES, mtr); + hist_size + undo->size, MLOG_4BYTES, mtr); } /* Add the log as the first in the history list */ flst_add_first(rseg_header + TRX_RSEG_HISTORY, - undo_header + TRX_UNDO_HISTORY_NODE, mtr); + undo_header + TRX_UNDO_HISTORY_NODE, mtr); mutex_enter(&kernel_mutex); trx_sys->rseg_history_len++; mutex_exit(&kernel_mutex); @@ -303,7 +304,7 @@ trx_purge_add_update_undo_to_history( if (!undo->del_marks) { mlog_write_ulint(undo_header + TRX_UNDO_DEL_MARKS, FALSE, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); } if (rseg->last_page_no == FIL_NULL) { @@ -338,7 +339,7 @@ trx_purge_free_segment( ibool marked = FALSE; mtr_t mtr; -/* fputs("Freeing an update undo log segment\n", stderr); */ + /* fputs("Freeing an update undo log segment\n", stderr); */ #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(purge_sys->mutex))); @@ -361,12 +362,12 @@ loop: if (!marked) { mlog_write_ulint(log_hdr + TRX_UNDO_DEL_MARKS, FALSE, - MLOG_2BYTES, &mtr); + MLOG_2BYTES, &mtr); marked = TRUE; } freed = fseg_free_step_not_header(seg_hdr + TRX_UNDO_FSEG_HEADER, - &mtr); + &mtr); if (!freed) { mutex_exit(&(rseg->mutex)); mtr_commit(&mtr); @@ -386,7 +387,7 @@ loop: could become inaccessible garbage in the file space. */ flst_cut_end(rseg_hdr + TRX_RSEG_HISTORY, - log_hdr + TRX_UNDO_HISTORY_NODE, n_removed_logs, &mtr); + log_hdr + TRX_UNDO_HISTORY_NODE, n_removed_logs, &mtr); mutex_enter(&kernel_mutex); ut_ad(trx_sys->rseg_history_len >= n_removed_logs); @@ -402,15 +403,15 @@ loop: fsp0fsp.c. */ freed = fseg_free_step(seg_hdr + TRX_UNDO_FSEG_HEADER, - &mtr); + &mtr); } hist_size = mtr_read_ulint(rseg_hdr + TRX_RSEG_HISTORY_SIZE, - MLOG_4BYTES, &mtr); + MLOG_4BYTES, &mtr); ut_ad(hist_size >= seg_size); mlog_write_ulint(rseg_hdr + TRX_RSEG_HISTORY_SIZE, - hist_size - seg_size, MLOG_4BYTES, &mtr); + hist_size - seg_size, MLOG_4BYTES, &mtr); ut_ad(rseg->curr_size >= seg_size); @@ -453,8 +454,8 @@ trx_purge_truncate_rseg_history( rseg_hdr = trx_rsegf_get(rseg->space, rseg->page_no, &mtr); - hdr_addr = trx_purge_get_log_from_hist( - flst_get_last(rseg_hdr + TRX_RSEG_HISTORY, &mtr)); + hdr_addr = trx_purge_get_log_from_hist + (flst_get_last(rseg_hdr + TRX_RSEG_HISTORY, &mtr)); loop: if (hdr_addr.page == FIL_NULL) { @@ -470,7 +471,7 @@ loop: log_hdr = undo_page + hdr_addr.boffset; cmp = ut_dulint_cmp(mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO), - limit_trx_no); + limit_trx_no); if (cmp == 0) { trx_undo_truncate_start(rseg, rseg->space, hdr_addr.page, hdr_addr.boffset, limit_undo_no); @@ -483,8 +484,8 @@ loop: mutex_exit(&kernel_mutex); flst_truncate_end(rseg_hdr + TRX_RSEG_HISTORY, - log_hdr + TRX_UNDO_HISTORY_NODE, - n_removed_logs, &mtr); + log_hdr + TRX_UNDO_HISTORY_NODE, + n_removed_logs, &mtr); mutex_exit(&(rseg->mutex)); mtr_commit(&mtr); @@ -492,15 +493,14 @@ loop: return; } - prev_hdr_addr = trx_purge_get_log_from_hist( - flst_get_prev_addr(log_hdr + TRX_UNDO_HISTORY_NODE, - &mtr)); + prev_hdr_addr = trx_purge_get_log_from_hist + (flst_get_prev_addr(log_hdr + TRX_UNDO_HISTORY_NODE, &mtr)); n_removed_logs++; seg_hdr = undo_page + TRX_UNDO_SEG_HDR; if ((mach_read_from_2(seg_hdr + TRX_UNDO_STATE) == TRX_UNDO_TO_PURGE) - && (mach_read_from_2(log_hdr + TRX_UNDO_NEXT_LOG) == 0)) { + && (mach_read_from_2(log_hdr + TRX_UNDO_NEXT_LOG) == 0)) { /* We can free the whole log segment */ @@ -542,7 +542,7 @@ trx_purge_truncate_history(void) #endif /* UNIV_SYNC_DEBUG */ trx_purge_arr_get_biggest(purge_sys->arr, &limit_trx_no, - &limit_undo_no); + &limit_undo_no); if (ut_dulint_cmp(limit_trx_no, ut_dulint_zero) == 0) { @@ -559,13 +559,13 @@ trx_purge_truncate_history(void) } ut_ad((ut_dulint_cmp(limit_trx_no, - purge_sys->view->low_limit_no) <= 0)); + purge_sys->view->low_limit_no) <= 0)); rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list); while (rseg) { trx_purge_truncate_rseg_history(rseg, limit_trx_no, - limit_undo_no); + limit_undo_no); rseg = UT_LIST_GET_NEXT(rseg_list, rseg); } } @@ -633,9 +633,8 @@ trx_purge_rseg_get_next_history_log( purge_sys->n_pages_handled++; - prev_log_addr = trx_purge_get_log_from_hist( - flst_get_prev_addr(log_hdr + TRX_UNDO_HISTORY_NODE, - &mtr)); + prev_log_addr = trx_purge_get_log_from_hist + (flst_get_prev_addr(log_hdr + TRX_UNDO_HISTORY_NODE, &mtr)); if (prev_log_addr.page == FIL_NULL) { /* No logs left in the history list */ @@ -657,10 +656,13 @@ trx_purge_rseg_get_next_history_log( if (trx_sys->rseg_history_len > 20000) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Warning: purge reached the head of the history list,\n" -"InnoDB: but its length is still reported as %lu! Make a detailed bug\n" -"InnoDB: report, and post it to bugs.mysql.com\n", - (ulong)trx_sys->rseg_history_len); + " InnoDB: Warning: purge reached the" + " head of the history list,\n" + "InnoDB: but its length is still" + " reported as %lu! Make a detailed bug\n" + "InnoDB: report, and submit it" + " to http://bugs.mysql.com\n", + (ulong) trx_sys->rseg_history_len); } mutex_exit(&kernel_mutex); @@ -675,8 +677,8 @@ trx_purge_rseg_get_next_history_log( mtr_start(&mtr); log_hdr = trx_undo_page_get_s_latched(rseg->space, - prev_log_addr.page, &mtr) - + prev_log_addr.boffset; + prev_log_addr.page, &mtr) + + prev_log_addr.boffset; trx_no = mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO); @@ -730,15 +732,15 @@ trx_purge_choose_next_log(void) if (rseg->last_page_no != FIL_NULL) { if ((min_rseg == NULL) - || (ut_dulint_cmp(min_trx_no, - rseg->last_trx_no) > 0)) { + || (ut_dulint_cmp(min_trx_no, + rseg->last_trx_no) > 0)) { min_rseg = rseg; min_trx_no = rseg->last_trx_no; space = rseg->space; ut_a(space == 0); /* We assume in purge of - externally stored fields - that space id == 0 */ + externally stored fields + that space id == 0 */ page_no = rseg->last_page_no; offset = rseg->last_offset; } @@ -762,7 +764,7 @@ trx_purge_choose_next_log(void) rec = &trx_purge_dummy_rec; } else { rec = trx_undo_get_first_rec(space, page_no, offset, - RW_S_LATCH, &mtr); + RW_S_LATCH, &mtr); if (rec == NULL) { /* Undo log empty */ @@ -850,12 +852,12 @@ trx_purge_get_next_rec( operation from the same page of the same undo log */ next_rec = trx_undo_page_get_next_rec(rec2, - purge_sys->hdr_page_no, - purge_sys->hdr_offset); + purge_sys->hdr_page_no, + purge_sys->hdr_offset); if (next_rec == NULL) { - rec2 = trx_undo_get_next_rec(rec2, - purge_sys->hdr_page_no, - purge_sys->hdr_offset, &mtr); + rec2 = trx_undo_get_next_rec + (rec2, purge_sys->hdr_page_no, + purge_sys->hdr_offset, &mtr); break; } @@ -875,7 +877,7 @@ trx_purge_get_next_rec( } if ((type == TRX_UNDO_UPD_EXIST_REC) - && !(cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { + && !(cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { break; } } @@ -952,7 +954,8 @@ trx_purge_fetch_next_rec( if (srv_print_thread_releases) { fprintf(stderr, - "Purge: No logs left in the history list; pages handled %lu\n", + "Purge: No logs left in the" + " history list; pages handled %lu\n", (ulong) purge_sys->n_pages_handled); } @@ -974,7 +977,7 @@ trx_purge_fetch_next_rec( } if (ut_dulint_cmp(purge_sys->purge_trx_no, - purge_sys->view->low_limit_no) >= 0) { + purge_sys->view->low_limit_no) >= 0) { purge_sys->state = TRX_STOP_PURGE; trx_purge_truncate_if_arr_empty(); @@ -984,20 +987,20 @@ trx_purge_fetch_next_rec( return(NULL); } -/* fprintf(stderr, "Thread %lu purging trx %lu undo record %lu\n", - os_thread_get_curr_id(), - ut_dulint_get_low(purge_sys->purge_trx_no), - ut_dulint_get_low(purge_sys->purge_undo_no)); */ + /* fprintf(stderr, "Thread %lu purging trx %lu undo record %lu\n", + os_thread_get_curr_id(), + ut_dulint_get_low(purge_sys->purge_trx_no), + ut_dulint_get_low(purge_sys->purge_undo_no)); */ *roll_ptr = trx_undo_build_roll_ptr(FALSE, (purge_sys->rseg)->id, - purge_sys->page_no, - purge_sys->offset); + purge_sys->page_no, + purge_sys->offset); *cell = trx_purge_arr_store_info(purge_sys->purge_trx_no, purge_sys->purge_undo_no); ut_ad(ut_dulint_cmp(purge_sys->purge_trx_no, - (purge_sys->view)->low_limit_no) < 0); + (purge_sys->view)->low_limit_no) < 0); /* The following call will advance the stored values of purge_trx_no and purge_undo_no, therefore we had to store them first */ @@ -1038,7 +1041,7 @@ trx_purge(void) the batch */ { que_thr_t* thr; -/* que_thr_t* thr2; */ + /* que_thr_t* thr2; */ ulint old_pages_handled; mutex_enter(&(purge_sys->mutex)); @@ -1073,9 +1076,9 @@ trx_purge(void) 'consistent read view', then the DML statements cannot be delayed. Also, srv_max_purge_lag <= 0 means 'infinity'. */ if (srv_max_purge_lag > 0 - && !UT_LIST_GET_LAST(trx_sys->view_list)) { + && !UT_LIST_GET_LAST(trx_sys->view_list)) { float ratio = (float) trx_sys->rseg_history_len - / srv_max_purge_lag; + / srv_max_purge_lag; if (ratio > ULINT_MAX / 10000) { /* Avoid overflow: maximum delay is 4295 seconds */ srv_dml_needed_delay = ULINT_MAX; @@ -1088,9 +1091,8 @@ trx_purge(void) } } - purge_sys->view = read_view_oldest_copy_or_open_new( - ut_dulint_create(0, 0), - purge_sys->heap); + purge_sys->view = read_view_oldest_copy_or_open_new(ut_dulint_zero, + purge_sys->heap); mutex_exit(&kernel_mutex); rw_lock_x_unlock(&(purge_sys->latch)); @@ -1111,14 +1113,14 @@ trx_purge(void) ut_ad(thr); -/* thr2 = que_fork_start_command(purge_sys->query); + /* thr2 = que_fork_start_command(purge_sys->query); ut_ad(thr2); */ mutex_exit(&kernel_mutex); -/* srv_que_task_enqueue(thr2); */ + /* srv_que_task_enqueue(thr2); */ if (srv_print_thread_releases) { @@ -1130,8 +1132,8 @@ trx_purge(void) if (srv_print_thread_releases) { fprintf(stderr, - "Purge ends; pages handled %lu\n", - (ulong) purge_sys->n_pages_handled); + "Purge ends; pages handled %lu\n", + (ulong) purge_sys->n_pages_handled); } return(purge_sys->n_pages_handled - old_pages_handled); @@ -1148,13 +1150,13 @@ trx_purge_sys_print(void) read_view_print(purge_sys->view); fprintf(stderr, "InnoDB: Purge trx n:o %lu %lu, undo n_o %lu %lu\n", - (ulong) ut_dulint_get_high(purge_sys->purge_trx_no), - (ulong) ut_dulint_get_low(purge_sys->purge_trx_no), - (ulong) ut_dulint_get_high(purge_sys->purge_undo_no), - (ulong) ut_dulint_get_low(purge_sys->purge_undo_no)); + (ulong) ut_dulint_get_high(purge_sys->purge_trx_no), + (ulong) ut_dulint_get_low(purge_sys->purge_trx_no), + (ulong) ut_dulint_get_high(purge_sys->purge_undo_no), + (ulong) ut_dulint_get_low(purge_sys->purge_undo_no)); fprintf(stderr, - "InnoDB: Purge next stored %lu, page_no %lu, offset %lu,\n" - "InnoDB: Purge hdr_page_no %lu, hdr_offset %lu\n", + "InnoDB: Purge next stored %lu, page_no %lu, offset %lu,\n" + "InnoDB: Purge hdr_page_no %lu, hdr_offset %lu\n", (ulong) purge_sys->next_stored, (ulong) purge_sys->page_no, (ulong) purge_sys->offset, diff --git a/storage/innobase/trx/trx0rec.c b/storage/innobase/trx/trx0rec.c index 55723df48c5..3a214d6ce38 100644 --- a/storage/innobase/trx/trx0rec.c +++ b/storage/innobase/trx/trx0rec.c @@ -50,8 +50,8 @@ trx_undof_page_add_undo_rec_log( } log_end = &log_ptr[11 + 13 + MLOG_BUF_MARGIN]; - log_ptr = mlog_write_initial_log_record_fast(undo_page, - MLOG_UNDO_INSERT, log_ptr, mtr); + log_ptr = mlog_write_initial_log_record_fast + (undo_page, MLOG_UNDO_INSERT, log_ptr, mtr); len = new_free - old_free - 4; mach_write_to_2(log_ptr, len); @@ -100,14 +100,14 @@ trx_undo_parse_add_undo_rec( } first_free = mach_read_from_2(page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_FREE); + + TRX_UNDO_PAGE_FREE); rec = page + first_free; mach_write_to_2(rec, first_free + 4 + len); mach_write_to_2(rec + 2 + len, first_free); mach_write_to_2(page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE, - first_free + 4 + len); + first_free + 4 + len); ut_memcpy(rec + 2, ptr, len); return(ptr + len); @@ -152,10 +152,10 @@ trx_undo_page_report_insert( ulint i; ut_ad(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_TYPE) == TRX_UNDO_INSERT); + + TRX_UNDO_PAGE_TYPE) == TRX_UNDO_INSERT); first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_FREE); + + TRX_UNDO_PAGE_FREE); ptr = undo_page + first_free; ut_ad(first_free <= UNIV_PAGE_SIZE); @@ -228,12 +228,12 @@ trx_undo_page_report_insert( mach_write_to_2(undo_page + first_free, ptr - undo_page); mach_write_to_2(undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE, - ptr - undo_page); + ptr - undo_page); /* Write the log entry to the REDO log of this change in the UNDO - log */ + log */ trx_undof_page_add_undo_rec_log(undo_page, first_free, - ptr - undo_page, mtr); + ptr - undo_page, mtr); return(first_free); } @@ -432,11 +432,11 @@ trx_undo_page_report_modify( ut_a(index->type & DICT_CLUSTERED); ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_TYPE) == TRX_UNDO_UPDATE); + + TRX_UNDO_PAGE_TYPE) == TRX_UNDO_UPDATE); table = index->table; first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_FREE); + + TRX_UNDO_PAGE_FREE); ptr = undo_page + first_free; ut_ad(first_free <= UNIV_PAGE_SIZE); @@ -486,11 +486,13 @@ trx_undo_page_report_modify( /* Store the values of the system columns */ field = rec_get_nth_field(rec, offsets, - dict_index_get_sys_col_pos(index, DATA_TRX_ID), &len); + dict_index_get_sys_col_pos + (index, DATA_TRX_ID), &len); ut_ad(len == DATA_TRX_ID_LEN); trx_id = trx_read_trx_id(field); field = rec_get_nth_field(rec, offsets, - dict_index_get_sys_col_pos(index, DATA_ROLL_PTR), &len); + dict_index_get_sys_col_pos + (index, DATA_ROLL_PTR), &len); ut_ad(len == DATA_ROLL_PTR_LEN); roll_ptr = trx_read_roll_ptr(field); @@ -565,8 +567,9 @@ trx_undo_page_report_modify( /* If a field has external storage, we add to flen the flag */ - len = mach_write_compressed(ptr, - UNIV_EXTERN_STORAGE_FIELD + flen); + len = mach_write_compressed + (ptr, + UNIV_EXTERN_STORAGE_FIELD + flen); /* Notify purge that it eventually has to free the old externally stored field */ @@ -629,7 +632,7 @@ trx_undo_page_report_modify( if (col->ord_part > 0) { pos = dict_index_get_nth_col_pos(index, - col_no); + col_no); /* Write field number to undo log */ if (trx_undo_left(undo_page, ptr) < 5) { @@ -642,7 +645,7 @@ trx_undo_page_report_modify( /* Save the old value of field */ field = rec_get_nth_field(rec, offsets, pos, - &flen); + &flen); if (trx_undo_left(undo_page, ptr) < 5) { @@ -654,7 +657,7 @@ trx_undo_page_report_modify( if (flen != UNIV_SQL_NULL) { if (trx_undo_left(undo_page, ptr) - < flen) { + < flen) { return(0); } @@ -680,12 +683,12 @@ trx_undo_page_report_modify( mach_write_to_2(undo_page + first_free, ptr - undo_page); mach_write_to_2(undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE, - ptr - undo_page); + ptr - undo_page); /* Write to the REDO log about this change in the UNDO log */ trx_undof_page_add_undo_rec_log(undo_page, first_free, - ptr - undo_page, mtr); + ptr - undo_page, mtr); return(first_free); } @@ -815,17 +818,17 @@ trx_undo_update_rec_get_update( trx_write_trx_id(buf, trx_id); upd_field_set_field_no(upd_field, - dict_index_get_sys_col_pos(index, DATA_TRX_ID), - index, trx); + dict_index_get_sys_col_pos(index, DATA_TRX_ID), + index, trx); dfield_set_data(&(upd_field->new_val), buf, DATA_TRX_ID_LEN); upd_field = upd_get_nth_field(update, n_fields + 1); buf = mem_heap_alloc(heap, DATA_ROLL_PTR_LEN); trx_write_roll_ptr(buf, roll_ptr); - upd_field_set_field_no(upd_field, - dict_index_get_sys_col_pos(index, DATA_ROLL_PTR), - index, trx); + upd_field_set_field_no + (upd_field, dict_index_get_sys_col_pos(index, DATA_ROLL_PTR), + index, trx); dfield_set_data(&(upd_field->new_val), buf, DATA_ROLL_PTR_LEN); /* Store then the updated ordinary columns to the update vector */ @@ -836,16 +839,19 @@ trx_undo_update_rec_get_update( if (field_no >= dict_index_get_n_fields(index)) { fprintf(stderr, -"InnoDB: Error: trying to access update undo rec field %lu in ", (ulong) field_no); + "InnoDB: Error: trying to access" + " update undo rec field %lu in ", + (ulong) field_no); dict_index_name_print(stderr, trx, index); fprintf(stderr, "\n" -"InnoDB: but index has only %lu fields\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n" -"InnoDB: Run also CHECK TABLE ", + "InnoDB: but index has only %lu fields\n" + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n" + "InnoDB: Run also CHECK TABLE ", (ulong) dict_index_get_n_fields(index)); ut_print_name(stderr, trx, TRUE, index->table_name); fprintf(stderr, "\n" -"InnoDB: n_fields = %lu, i = %lu, ptr %p\n", + "InnoDB: n_fields = %lu, i = %lu, ptr %p\n", (ulong) n_fields, (ulong) i, ptr); return(NULL); } @@ -948,9 +954,9 @@ trx_undo_erase_page_end( ulint first_free; first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_FREE); + + TRX_UNDO_PAGE_FREE); memset(undo_page + first_free, 0xff, - (UNIV_PAGE_SIZE - FIL_PAGE_DATA_END) - first_free); + (UNIV_PAGE_SIZE - FIL_PAGE_DATA_END) - first_free); mlog_write_initial_log_record(undo_page, MLOG_UNDO_ERASE_END, mtr); } @@ -1034,7 +1040,7 @@ trx_undo_report_row_operation( ut_ad(thr); ut_ad((op_type != TRX_UNDO_INSERT_OP) - || (clust_entry && !update && !rec)); + || (clust_entry && !update && !rec)); trx = thr_get_trx(thr); rseg = trx->rseg; @@ -1078,32 +1084,30 @@ trx_undo_report_row_operation( for (;;) { undo_page = buf_page_get_gen(undo->space, page_no, - RW_X_LATCH, undo->guess_page, - BUF_GET, - __FILE__, __LINE__, - &mtr); + RW_X_LATCH, undo->guess_page, + BUF_GET, + __FILE__, __LINE__, + &mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(undo_page, SYNC_TRX_UNDO_PAGE); #endif /* UNIV_SYNC_DEBUG */ if (op_type == TRX_UNDO_INSERT_OP) { - offset = trx_undo_page_report_insert(undo_page, trx, - index, clust_entry, - &mtr); + offset = trx_undo_page_report_insert + (undo_page, trx, index, clust_entry, &mtr); } else { offsets = rec_get_offsets(rec, index, offsets, - ULINT_UNDEFINED, &heap); - offset = trx_undo_page_report_modify(undo_page, trx, - index, rec, offsets, update, cmpl_info, &mtr); + ULINT_UNDEFINED, &heap); + offset = trx_undo_page_report_modify + (undo_page, trx, index, rec, offsets, + update, cmpl_info, &mtr); } if (offset == 0) { /* The record did not fit on the page. We erase the end segment of the undo log page and write a log - record of it: this is to ensure that in the debug - version the replicate page constructed using the log - records stays identical to the original page */ + record of it to to ensure deterministic contents. */ trx_undo_erase_page_end(undo_page, &mtr); } @@ -1155,7 +1159,7 @@ trx_undo_report_row_operation( mutex_exit(&(trx->undo_mutex)); *roll_ptr = trx_undo_build_roll_ptr(is_insert, rseg->id, page_no, - offset); + offset); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1185,7 +1189,7 @@ trx_undo_get_undo_rec_low( mtr_t mtr; trx_undo_decode_roll_ptr(roll_ptr, &is_insert, &rseg_id, &page_no, - &offset); + &offset); rseg = trx_rseg_get_on_id(rseg_id); mtr_start(&mtr); @@ -1282,9 +1286,9 @@ trx_undo_prev_version_build( ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED)); #endif /* UNIV_SYNC_DEBUG */ ut_ad(mtr_memo_contains(index_mtr, buf_block_align(index_rec), - MTR_MEMO_PAGE_S_FIX) || - mtr_memo_contains(index_mtr, buf_block_align(index_rec), - MTR_MEMO_PAGE_X_FIX)); + MTR_MEMO_PAGE_S_FIX) + || mtr_memo_contains(index_mtr, buf_block_align(index_rec), + MTR_MEMO_PAGE_X_FIX)); ut_ad(rec_offs_validate(rec, index, offsets)); if (!(index->type & DICT_CLUSTERED)) { @@ -1295,7 +1299,7 @@ trx_undo_prev_version_build( "InnoDB: index record ", index->name); rec_print(stderr, index_rec, index); fputs("\n" - "InnoDB: record version ", stderr); + "InnoDB: record version ", stderr); rec_print_new(stderr, rec, offsets); putc('\n', stderr); return(DB_ERROR); @@ -1323,23 +1327,27 @@ trx_undo_prev_version_build( } ptr = trx_undo_rec_get_pars(undo_rec, &type, &cmpl_info, - &dummy_extern, &undo_no, &table_id); + &dummy_extern, &undo_no, &table_id); ptr = trx_undo_update_rec_get_sys_cols(ptr, &trx_id, &roll_ptr, - &info_bits); + &info_bits); ptr = trx_undo_rec_skip_row_ref(ptr, index); ptr = trx_undo_update_rec_get_update(ptr, index, type, trx_id, - roll_ptr, info_bits, NULL, heap, &update); + roll_ptr, info_bits, + NULL, heap, &update); if (ut_dulint_cmp(table_id, index->table->id) != 0) { ptr = NULL; fprintf(stderr, -"InnoDB: Error: trying to access update undo rec for table %s\n" -"InnoDB: but the table id in the undo record is wrong\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n" -"InnoDB: Run also CHECK TABLE %s\n", + "InnoDB: Error: trying to access update undo rec" + " for table %s\n" + "InnoDB: but the table id in the" + " undo record is wrong\n" + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com\n" + "InnoDB: Run also CHECK TABLE %s\n", index->table_name, index->table_name); } @@ -1348,10 +1356,11 @@ trx_undo_prev_version_build( should catch an elusive bug in row_vers_old_has_index_entry */ fprintf(stderr, - "InnoDB: table %s, index %s, n_uniq %lu\n" - "InnoDB: undo rec address %p, type %lu cmpl_info %lu\n" - "InnoDB: undo rec table id %lu %lu, index table id %lu %lu\n" - "InnoDB: dump of 150 bytes in undo rec: ", + "InnoDB: table %s, index %s, n_uniq %lu\n" + "InnoDB: undo rec address %p, type %lu cmpl_info %lu\n" + "InnoDB: undo rec table id %lu %lu," + " index table id %lu %lu\n" + "InnoDB: dump of 150 bytes in undo rec: ", index->table_name, index->name, (ulong) dict_index_get_n_unique(index), undo_rec, (ulong) type, (ulong) cmpl_info, @@ -1361,14 +1370,16 @@ trx_undo_prev_version_build( (ulong) ut_dulint_get_low(index->table->id)); ut_print_buf(stderr, undo_rec, 150); fputs("\n" - "InnoDB: index record ", stderr); + "InnoDB: index record ", stderr); rec_print(stderr, index_rec, index); fputs("\n" - "InnoDB: record version ", stderr); + "InnoDB: record version ", stderr); rec_print_new(stderr, rec, offsets); fprintf(stderr, "\n" - "InnoDB: Record trx id %lu %lu, update rec trx id %lu %lu\n" - "InnoDB: Roll ptr in rec %lu %lu, in update rec %lu %lu\n", + "InnoDB: Record trx id %lu %lu, update rec" + " trx id %lu %lu\n" + "InnoDB: Roll ptr in rec %lu %lu, in update rec" + " %lu %lu\n", (ulong) ut_dulint_get_high(rec_trx_id), (ulong) ut_dulint_get_low(rec_trx_id), (ulong) ut_dulint_get_high(trx_id), @@ -1393,21 +1404,21 @@ trx_undo_prev_version_build( fields. Store the info to ext_vect: */ ext_vect = mem_alloc(sizeof(ulint) - * rec_offs_n_fields(offsets)); + * rec_offs_n_fields(offsets)); n_ext_vect = btr_push_update_extern_fields(ext_vect, offsets, - update); + update); entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, - heap); + heap); row_upd_index_replace_new_col_vals(entry, index, update, heap); buf = mem_heap_alloc(heap, - rec_get_converted_size(index, entry)); + rec_get_converted_size(index, entry)); *old_vers = rec_convert_dtuple_to_rec(buf, index, entry); /* Now set the extern bits in the old version of the record */ rec_set_field_extern_bits(*old_vers, index, - ext_vect, n_ext_vect, NULL); + ext_vect, n_ext_vect, NULL); mem_free(ext_vect); } else { buf = mem_heap_alloc(heap, rec_offs_size(offsets)); diff --git a/storage/innobase/trx/trx0roll.c b/storage/innobase/trx/trx0roll.c index c777510cd06..1b00ae63ecd 100644 --- a/storage/innobase/trx/trx0roll.c +++ b/storage/innobase/trx/trx0roll.c @@ -157,7 +157,7 @@ trx_rollback_last_sql_stat_for_mysql( trx->op_info = "rollback of SQL statement"; err = trx_general_rollback_for_mysql(trx, TRUE, - &(trx->last_sql_stat_start)); + &(trx->last_sql_stat_start)); /* The following call should not be needed, but we play safe: */ trx_mark_sql_stat_end(trx); @@ -422,7 +422,8 @@ trx_rollback_or_clean_all_without_sess( if (UT_LIST_GET_FIRST(trx_sys->trx_list)) { fprintf(stderr, -"InnoDB: Starting in background the rollback of uncommitted transactions\n"); + "InnoDB: Starting in background the rollback" + " of uncommitted transactions\n"); } else { goto leave_function; } @@ -450,7 +451,8 @@ loop: if (trx == NULL) { ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Rollback of non-prepared transactions completed\n"); + " InnoDB: Rollback of non-prepared transactions" + " completed\n"); mem_heap_free(heap); @@ -461,8 +463,8 @@ loop: if (trx->conc_state == TRX_COMMITTED_IN_MEMORY) { fprintf(stderr, "InnoDB: Cleaning up trx with id %lu %lu\n", - (ulong) ut_dulint_get_high(trx->id), - (ulong) ut_dulint_get_low(trx->id)); + (ulong) ut_dulint_get_high(trx->id), + (ulong) ut_dulint_get_low(trx->id)); trx_cleanup_at_db_startup(trx); @@ -499,10 +501,11 @@ loop: ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Rolling back trx with id %lu %lu, %lu%s rows to undo\n", - (ulong) ut_dulint_get_high(trx->id), - (ulong) ut_dulint_get_low(trx->id), - (ulong) rows_to_undo, unit); + " InnoDB: Rolling back trx with id %lu %lu, %lu%s" + " rows to undo\n", + (ulong) ut_dulint_get_high(trx->id), + (ulong) ut_dulint_get_low(trx->id), + (ulong) rows_to_undo, unit); mutex_exit(&kernel_mutex); trx->mysql_thread_id = os_thread_get_curr_id(); @@ -522,8 +525,8 @@ loop: mutex_exit(&kernel_mutex); fprintf(stderr, - "InnoDB: Waiting for rollback of trx id %lu to end\n", - (ulong) ut_dulint_get_low(trx->id)); + "InnoDB: Waiting for rollback of trx id %lu to end\n", + (ulong) ut_dulint_get_low(trx->id)); os_thread_sleep(100000); mutex_enter(&kernel_mutex); @@ -536,7 +539,8 @@ loop: drop the relevant table, if it still exists */ fprintf(stderr, -"InnoDB: Dropping table with id %lu %lu in recovery if it exists\n", + "InnoDB: Dropping table with id %lu %lu" + " in recovery if it exists\n", (ulong) ut_dulint_get_high(trx->table_id), (ulong) ut_dulint_get_low(trx->table_id)); @@ -558,8 +562,8 @@ loop: } fprintf(stderr, "\nInnoDB: Rolling back of trx id %lu %lu completed\n", - (ulong) ut_dulint_get_high(trx->id), - (ulong) ut_dulint_get_low(trx->id)); + (ulong) ut_dulint_get_high(trx->id), + (ulong) ut_dulint_get_low(trx->id)); mem_heap_free(heap); trx_roll_crash_recv_trx = NULL; @@ -591,7 +595,7 @@ trx_undo_arr_create(void) arr = mem_heap_alloc(heap, sizeof(trx_undo_arr_t)); arr->infos = mem_heap_alloc(heap, sizeof(trx_undo_inf_t) - * UNIV_MAX_PARALLELISM); + * UNIV_MAX_PARALLELISM); arr->n_cells = UNIV_MAX_PARALLELISM; arr->n_used = 0; @@ -701,7 +705,7 @@ trx_undo_arr_remove_info( cell = trx_undo_arr_get_nth_info(arr, i); if (cell->in_use - && 0 == ut_dulint_cmp(cell->undo_no, undo_no)) { + && 0 == ut_dulint_cmp(cell->undo_no, undo_no)) { cell->in_use = FALSE; @@ -817,13 +821,13 @@ trx_roll_pop_top_rec( undo->top_page_no, mtr); offset = undo->top_offset; -/* fprintf(stderr, "Thread %lu undoing trx %lu undo record %lu\n", - os_thread_get_curr_id(), ut_dulint_get_low(trx->id), - ut_dulint_get_low(undo->top_undo_no)); */ + /* fprintf(stderr, "Thread %lu undoing trx %lu undo record %lu\n", + os_thread_get_curr_id(), ut_dulint_get_low(trx->id), + ut_dulint_get_low(undo->top_undo_no)); */ prev_rec = trx_undo_get_prev_rec(undo_page + offset, - undo->hdr_page_no, undo->hdr_offset, - mtr); + undo->hdr_page_no, undo->hdr_offset, + mtr); if (prev_rec == NULL) { undo->empty = TRUE; @@ -899,7 +903,7 @@ try_again: } if (!undo || undo->empty - || (ut_dulint_cmp(limit, undo->top_undo_no) > 0)) { + || (ut_dulint_cmp(limit, undo->top_undo_no) > 0)) { if ((trx->undo_no_arr)->n_used == 0) { /* Rollback is ending */ @@ -923,7 +927,8 @@ try_again: } *roll_ptr = trx_undo_build_roll_ptr(is_insert, (undo->rseg)->id, - undo->top_page_no, undo->top_offset); + undo->top_page_no, + undo->top_offset); mtr_start(&mtr); undo_rec = trx_roll_pop_top_rec(trx, undo, &mtr); @@ -938,15 +943,16 @@ try_again: if (trx == trx_roll_crash_recv_trx && trx_roll_max_undo_no > 1000) { progress_pct = 100 - (ulint) - ((ut_conv_dulint_to_longlong(undo_no) * 100) - / trx_roll_max_undo_no); + ((ut_conv_dulint_to_longlong(undo_no) * 100) + / trx_roll_max_undo_no); if (progress_pct != trx_roll_progress_printed_pct) { if (trx_roll_progress_printed_pct == 0) { fprintf(stderr, -"\nInnoDB: Progress in percents: %lu", (ulong) progress_pct); + "\nInnoDB: Progress in percents:" + " %lu", (ulong) progress_pct); } else { fprintf(stderr, - " %lu", (ulong) progress_pct); + " %lu", (ulong) progress_pct); } fflush(stderr); trx_roll_progress_printed_pct = progress_pct; @@ -1034,7 +1040,7 @@ trx_rollback( { que_t* roll_graph; que_thr_t* thr; -/* que_thr_t* thr2; */ + /* que_thr_t* thr2; */ #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); @@ -1077,16 +1083,16 @@ trx_rollback( ut_ad(thr); -/* thr2 = que_fork_start_command(roll_graph); + /* thr2 = que_fork_start_command(roll_graph); ut_ad(thr2); */ if (next_thr && (*next_thr == NULL)) { *next_thr = thr; -/* srv_que_task_enqueue_low(thr2); */ + /* srv_que_task_enqueue_low(thr2); */ } else { srv_que_task_enqueue_low(thr); -/* srv_que_task_enqueue_low(thr2); */ + /* srv_que_task_enqueue_low(thr2); */ } } @@ -1105,7 +1111,7 @@ trx_roll_graph_build( mem_heap_t* heap; que_fork_t* fork; que_thr_t* thr; -/* que_thr_t* thr2; */ + /* que_thr_t* thr2; */ #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); @@ -1116,10 +1122,10 @@ trx_roll_graph_build( fork->trx = trx; thr = que_thr_create(fork, heap); -/* thr2 = que_thr_create(fork, heap); */ + /* thr2 = que_thr_create(fork, heap); */ thr->child = row_undo_node_create(trx, thr, heap); -/* thr2->child = row_undo_node_create(trx, thr2, heap); */ + /* thr2->child = row_undo_node_create(trx, thr2, heap); */ return(fork); } @@ -1231,7 +1237,7 @@ trx_finish_rollback_off_kernel( #ifdef UNIV_DEBUG if (lock_print_waits) { fprintf(stderr, "Trx %lu rollback finished\n", - (ulong) ut_dulint_get_low(trx->id)); + (ulong) ut_dulint_get_low(trx->id)); } #endif /* UNIV_DEBUG */ @@ -1313,7 +1319,7 @@ trx_rollback_step( /* Send a rollback signal to the transaction */ trx_sig_send(thr_get_trx(thr), sig_no, TRX_SIG_SELF, thr, - savept, NULL); + savept, NULL); thr->state = QUE_THR_SIG_REPLY_WAIT; diff --git a/storage/innobase/trx/trx0rseg.c b/storage/innobase/trx/trx0rseg.c index 5136174d110..745a29021ad 100644 --- a/storage/innobase/trx/trx0rseg.c +++ b/storage/innobase/trx/trx0rseg.c @@ -64,7 +64,7 @@ trx_rseg_header_create( ut_ad(mutex_own(&kernel_mutex)); #endif /* UNIV_SYNC_DEBUG */ ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space), - MTR_MEMO_X_LOCK)); + MTR_MEMO_X_LOCK)); sys_header = trx_sysf_get(mtr); *slot_no = trx_sysf_rseg_find_free(mtr); @@ -93,7 +93,8 @@ trx_rseg_header_create( rsegf = trx_rsegf_get_new(space, page_no, mtr); /* Initialize max size field */ - mlog_write_ulint(rsegf + TRX_RSEG_MAX_SIZE, max_size, MLOG_4BYTES, mtr); + mlog_write_ulint(rsegf + TRX_RSEG_MAX_SIZE, max_size, + MLOG_4BYTES, mtr); /* Initialize the history list */ @@ -156,34 +157,32 @@ trx_rseg_mem_create( rseg_header = trx_rsegf_get_new(space, page_no, mtr); rseg->max_size = mtr_read_ulint(rseg_header + TRX_RSEG_MAX_SIZE, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); /* Initialize the undo log lists according to the rseg header */ sum_of_undo_sizes = trx_undo_lists_init(rseg); rseg->curr_size = mtr_read_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE, - MLOG_4BYTES, mtr) - + 1 + sum_of_undo_sizes; + MLOG_4BYTES, mtr) + + 1 + sum_of_undo_sizes; len = flst_get_len(rseg_header + TRX_RSEG_HISTORY, mtr); if (len > 0) { trx_sys->rseg_history_len += len; - node_addr = trx_purge_get_log_from_hist( - flst_get_last(rseg_header + TRX_RSEG_HISTORY, - mtr)); + node_addr = trx_purge_get_log_from_hist + (flst_get_last(rseg_header + TRX_RSEG_HISTORY, mtr)); rseg->last_page_no = node_addr.page; rseg->last_offset = node_addr.boffset; undo_log_hdr = trx_undo_page_get(rseg->space, node_addr.page, - mtr) + node_addr.boffset; + mtr) + node_addr.boffset; - rseg->last_trx_no = mtr_read_dulint( - undo_log_hdr + TRX_UNDO_TRX_NO, mtr); - rseg->last_del_marks = mtr_read_ulint( - undo_log_hdr + TRX_UNDO_DEL_MARKS, - MLOG_2BYTES, mtr); + rseg->last_trx_no = mtr_read_dulint + (undo_log_hdr + TRX_UNDO_TRX_NO, mtr); + rseg->last_del_marks = mtr_read_ulint + (undo_log_hdr + TRX_UNDO_DEL_MARKS, MLOG_2BYTES, mtr); } else { rseg->last_page_no = FIL_NULL; } diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c index 8f24a54208a..ce68f994d44 100644 --- a/storage/innobase/trx/trx0sys.c +++ b/storage/innobase/trx/trx0sys.c @@ -70,14 +70,14 @@ trx_doublewrite_page_inside( } if (page_no >= trx_doublewrite->block1 - && page_no < trx_doublewrite->block1 - + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { + && page_no < trx_doublewrite->block1 + + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { return(TRUE); } if (page_no >= trx_doublewrite->block2 - && page_no < trx_doublewrite->block2 - + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { + && page_no < trx_doublewrite->block2 + + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { return(TRUE); } @@ -105,23 +105,17 @@ trx_doublewrite_init( trx_doublewrite->first_free = 0; - trx_doublewrite->block1 = mach_read_from_4( - doublewrite - + TRX_SYS_DOUBLEWRITE_BLOCK1); - trx_doublewrite->block2 = mach_read_from_4( - doublewrite - + TRX_SYS_DOUBLEWRITE_BLOCK2); - trx_doublewrite->write_buf_unaligned = - ut_malloc( - (1 + 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) - * UNIV_PAGE_SIZE); + trx_doublewrite->block1 = mach_read_from_4 + (doublewrite + TRX_SYS_DOUBLEWRITE_BLOCK1); + trx_doublewrite->block2 = mach_read_from_4 + (doublewrite + TRX_SYS_DOUBLEWRITE_BLOCK2); + trx_doublewrite->write_buf_unaligned = ut_malloc + ((1 + 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) * UNIV_PAGE_SIZE); - trx_doublewrite->write_buf = ut_align( - trx_doublewrite->write_buf_unaligned, - UNIV_PAGE_SIZE); - trx_doublewrite->buf_block_arr = mem_alloc( - 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE - * sizeof(void*)); + trx_doublewrite->write_buf = ut_align + (trx_doublewrite->write_buf_unaligned, UNIV_PAGE_SIZE); + trx_doublewrite->buf_block_arr = mem_alloc + (2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * sizeof(void*)); } /******************************************************************** @@ -150,8 +144,8 @@ trx_sys_mark_upgraded_to_multiple_tablespaces(void) doublewrite = page + TRX_SYS_DOUBLEWRITE; mlog_write_ulint(doublewrite + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED, - TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N, - MLOG_4BYTES, &mtr); + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N, + MLOG_4BYTES, &mtr); mtr_commit(&mtr); /* Flush the modified pages to disk and make a checkpoint */ @@ -195,7 +189,7 @@ start_again: doublewrite = page + TRX_SYS_DOUBLEWRITE; if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC) - == TRX_SYS_DOUBLEWRITE_MAGIC_N) { + == TRX_SYS_DOUBLEWRITE_MAGIC_N) { /* The doublewrite buffer has already been created: just read in some numbers */ @@ -204,22 +198,25 @@ start_again: mtr_commit(&mtr); } else { fprintf(stderr, - "InnoDB: Doublewrite buffer not found: creating new\n"); + "InnoDB: Doublewrite buffer not found:" + " creating new\n"); - if (buf_pool_get_curr_size() < - (2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE - + FSP_EXTENT_SIZE / 2 + 100) - * UNIV_PAGE_SIZE) { + if (buf_pool_get_curr_size() + < ((2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE + + FSP_EXTENT_SIZE / 2 + 100) + * UNIV_PAGE_SIZE)) { fprintf(stderr, - "InnoDB: Cannot create doublewrite buffer: you must\n" - "InnoDB: increase your buffer pool size.\n" - "InnoDB: Cannot continue operation.\n"); + "InnoDB: Cannot create doublewrite buffer:" + " you must\n" + "InnoDB: increase your buffer pool size.\n" + "InnoDB: Cannot continue operation.\n"); exit(1); } page2 = fseg_create(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, - TRX_SYS_DOUBLEWRITE + TRX_SYS_DOUBLEWRITE_FSEG, &mtr); + TRX_SYS_DOUBLEWRITE + + TRX_SYS_DOUBLEWRITE_FSEG, &mtr); /* fseg_create acquires a second latch on the page, therefore we must declare it: */ @@ -230,9 +227,10 @@ start_again: if (page2 == NULL) { fprintf(stderr, - "InnoDB: Cannot create doublewrite buffer: you must\n" - "InnoDB: increase your tablespace size.\n" - "InnoDB: Cannot continue operation.\n"); + "InnoDB: Cannot create doublewrite buffer:" + " you must\n" + "InnoDB: increase your tablespace size.\n" + "InnoDB: Cannot continue operation.\n"); /* We exit without committing the mtr to prevent its modifications to the database getting to disk */ @@ -241,19 +239,22 @@ start_again: } fseg_header = page + TRX_SYS_DOUBLEWRITE - + TRX_SYS_DOUBLEWRITE_FSEG; + + TRX_SYS_DOUBLEWRITE_FSEG; prev_page_no = 0; for (i = 0; i < 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE - + FSP_EXTENT_SIZE / 2; i++) { + + FSP_EXTENT_SIZE / 2; i++) { page_no = fseg_alloc_free_page(fseg_header, - prev_page_no + 1, - FSP_UP, &mtr); + prev_page_no + 1, + FSP_UP, &mtr); if (page_no == FIL_NULL) { fprintf(stderr, - "InnoDB: Cannot create doublewrite buffer: you must\n" - "InnoDB: increase your tablespace size.\n" - "InnoDB: Cannot continue operation.\n"); + "InnoDB: Cannot create doublewrite" + " buffer: you must\n" + "InnoDB: increase your" + " tablespace size.\n" + "InnoDB: Cannot continue operation.\n" + ); exit(1); } @@ -268,7 +269,7 @@ start_again: has not been written to in doublewrite. */ new_page = buf_page_get(TRX_SYS_SPACE, page_no, - RW_X_LATCH, &mtr); + RW_X_LATCH, &mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(new_page, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ @@ -277,26 +278,26 @@ start_again: be written to disk in a flush */ mlog_write_ulint(new_page + FIL_PAGE_DATA, - TRX_SYS_DOUBLEWRITE_MAGIC_N, - MLOG_4BYTES, &mtr); + TRX_SYS_DOUBLEWRITE_MAGIC_N, + MLOG_4BYTES, &mtr); if (i == FSP_EXTENT_SIZE / 2) { mlog_write_ulint(doublewrite - + TRX_SYS_DOUBLEWRITE_BLOCK1, - page_no, MLOG_4BYTES, &mtr); + + TRX_SYS_DOUBLEWRITE_BLOCK1, + page_no, MLOG_4BYTES, &mtr); mlog_write_ulint(doublewrite - + TRX_SYS_DOUBLEWRITE_REPEAT - + TRX_SYS_DOUBLEWRITE_BLOCK1, - page_no, MLOG_4BYTES, &mtr); + + TRX_SYS_DOUBLEWRITE_REPEAT + + TRX_SYS_DOUBLEWRITE_BLOCK1, + page_no, MLOG_4BYTES, &mtr); } else if (i == FSP_EXTENT_SIZE / 2 - + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { + + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { mlog_write_ulint(doublewrite - + TRX_SYS_DOUBLEWRITE_BLOCK2, - page_no, MLOG_4BYTES, &mtr); + + TRX_SYS_DOUBLEWRITE_BLOCK2, + page_no, MLOG_4BYTES, &mtr); mlog_write_ulint(doublewrite - + TRX_SYS_DOUBLEWRITE_REPEAT - + TRX_SYS_DOUBLEWRITE_BLOCK2, - page_no, MLOG_4BYTES, &mtr); + + TRX_SYS_DOUBLEWRITE_REPEAT + + TRX_SYS_DOUBLEWRITE_BLOCK2, + page_no, MLOG_4BYTES, &mtr); } else if (i > FSP_EXTENT_SIZE / 2) { ut_a(page_no == prev_page_no + 1); } @@ -305,15 +306,17 @@ start_again: } mlog_write_ulint(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC, - TRX_SYS_DOUBLEWRITE_MAGIC_N, MLOG_4BYTES, &mtr); + TRX_SYS_DOUBLEWRITE_MAGIC_N, + MLOG_4BYTES, &mtr); mlog_write_ulint(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC - + TRX_SYS_DOUBLEWRITE_REPEAT, - TRX_SYS_DOUBLEWRITE_MAGIC_N, MLOG_4BYTES, &mtr); + + TRX_SYS_DOUBLEWRITE_REPEAT, + TRX_SYS_DOUBLEWRITE_MAGIC_N, + MLOG_4BYTES, &mtr); mlog_write_ulint(doublewrite - + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED, - TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N, - MLOG_4BYTES, &mtr); + + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED, + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N, + MLOG_4BYTES, &mtr); mtr_commit(&mtr); /* Flush the modified pages to disk and make a checkpoint */ @@ -361,11 +364,11 @@ trx_sys_doublewrite_init_or_restore_pages( buffer */ fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, TRX_SYS_PAGE_NO, 0, - UNIV_PAGE_SIZE, read_buf, NULL); + UNIV_PAGE_SIZE, read_buf, NULL); doublewrite = read_buf + TRX_SYS_DOUBLEWRITE; if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC) - == TRX_SYS_DOUBLEWRITE_MAGIC_N) { + == TRX_SYS_DOUBLEWRITE_MAGIC_N) { /* The doublewrite buffer has been created */ trx_doublewrite_init(doublewrite); @@ -379,7 +382,7 @@ trx_sys_doublewrite_init_or_restore_pages( } if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED) - != TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N) { + != TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N) { /* We are upgrading from a version < 4.1.x to a version where multiple tablespaces are supported. We must reset the space id @@ -390,7 +393,8 @@ trx_sys_doublewrite_init_or_restore_pages( trx_doublewrite_must_reset_space_ids = TRUE; fprintf(stderr, -"InnoDB: Resetting space id's in the doublewrite buffer\n"); + "InnoDB: Resetting space id's in the" + " doublewrite buffer\n"); } else { trx_sys_multiple_tablespace_format = TRUE; } @@ -398,12 +402,12 @@ trx_sys_doublewrite_init_or_restore_pages( /* Read the pages from the doublewrite buffer to memory */ fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, block1, 0, - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, - buf, NULL); + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, + buf, NULL); fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, block2, 0, - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, - buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, - NULL); + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, + buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, + NULL); /* Check if any of these pages is half-written in data files, in the intended position */ @@ -430,12 +434,12 @@ trx_sys_doublewrite_init_or_restore_pages( } fil_io(OS_FILE_WRITE, TRUE, 0, source_page_no, 0, - UNIV_PAGE_SIZE, page, NULL); + UNIV_PAGE_SIZE, page, NULL); /* printf("Resetting space id in page %lu\n", - source_page_no); */ + source_page_no); */ } else { - space_id = mach_read_from_4( - page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); + space_id = mach_read_from_4 + (page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); } if (!restore_corrupt_pages) { @@ -447,19 +451,23 @@ trx_sys_doublewrite_init_or_restore_pages( and this page once belonged to it: do nothing */ } else if (!fil_check_adress_in_tablespace(space_id, - page_no)) { + page_no)) { fprintf(stderr, -"InnoDB: Warning: a page in the doublewrite buffer is not within space\n" -"InnoDB: bounds; space id %lu page number %lu, page %lu in doublewrite buf.\n", + "InnoDB: Warning: a page in the" + " doublewrite buffer is not within space\n" + "InnoDB: bounds; space id %lu" + " page number %lu, page %lu in" + " doublewrite buf.\n", (ulong) space_id, (ulong) page_no, (ulong) i); } else if (space_id == TRX_SYS_SPACE - && ((page_no >= block1 - && page_no - < block1 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) - || (page_no >= block2 - && page_no - < block2 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE))) { + && ((page_no >= block1 + && page_no + < block1 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) + || (page_no >= block2 + && page_no + < (block2 + + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE)))) { /* It is an unwritten doublewrite buffer page: do nothing */ @@ -467,31 +475,42 @@ trx_sys_doublewrite_init_or_restore_pages( /* Read in the actual page from the data files */ fil_io(OS_FILE_READ, TRUE, space_id, page_no, 0, - UNIV_PAGE_SIZE, read_buf, NULL); + UNIV_PAGE_SIZE, read_buf, NULL); /* Check if the page is corrupt */ if (buf_page_is_corrupted(read_buf)) { fprintf(stderr, - "InnoDB: Warning: database page corruption or a failed\n" - "InnoDB: file read of page %lu.\n", (ulong) page_no); + "InnoDB: Warning: database page" + " corruption or a failed\n" + "InnoDB: file read of page %lu.\n", + (ulong) page_no); fprintf(stderr, - "InnoDB: Trying to recover it from the doublewrite buffer.\n"); + "InnoDB: Trying to recover it from" + " the doublewrite buffer.\n"); if (buf_page_is_corrupted(page)) { fprintf(stderr, - "InnoDB: Dump of the page:\n"); + "InnoDB: Dump of the page:\n"); buf_page_print(read_buf); fprintf(stderr, - "InnoDB: Dump of corresponding page in doublewrite buffer:\n"); + "InnoDB: Dump of" + " corresponding page" + " in doublewrite buffer:\n"); buf_page_print(page); fprintf(stderr, - "InnoDB: Also the page in the doublewrite buffer is corrupt.\n" - "InnoDB: Cannot continue operation.\n" - "InnoDB: You can try to recover the database with the my.cnf\n" - "InnoDB: option:\n" - "InnoDB: set-variable=innodb_force_recovery=6\n"); + "InnoDB: Also the page in the" + " doublewrite buffer" + " is corrupt.\n" + "InnoDB: Cannot continue" + " operation.\n" + "InnoDB: You can try to" + " recover the database" + " with the my.cnf\n" + "InnoDB: option:\n" + "InnoDB: set-variable=" + "innodb_force_recovery=6\n"); exit(1); } @@ -500,10 +519,11 @@ trx_sys_doublewrite_init_or_restore_pages( position */ fil_io(OS_FILE_WRITE, TRUE, space_id, - page_no, 0, - UNIV_PAGE_SIZE, page, NULL); + page_no, 0, + UNIV_PAGE_SIZE, page, NULL); fprintf(stderr, - "InnoDB: Recovered the page from the doublewrite buffer.\n"); + "InnoDB: Recovered the page from" + " the doublewrite buffer.\n"); } } @@ -565,7 +585,7 @@ trx_sys_flush_max_trx_id(void) sys_header = trx_sysf_get(&mtr); mlog_write_dulint(sys_header + TRX_SYS_TRX_ID_STORE, - trx_sys->max_trx_id, &mtr); + trx_sys->max_trx_id, &mtr); mtr_commit(&mtr); } @@ -596,36 +616,38 @@ trx_sys_update_mysql_binlog_offset( sys_header = trx_sysf_get(mtr); if (mach_read_from_4(sys_header + field - + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) - != TRX_SYS_MYSQL_LOG_MAGIC_N) { + + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) + != TRX_SYS_MYSQL_LOG_MAGIC_N) { mlog_write_ulint(sys_header + field - + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD, - TRX_SYS_MYSQL_LOG_MAGIC_N, - MLOG_4BYTES, mtr); + + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD, + TRX_SYS_MYSQL_LOG_MAGIC_N, + MLOG_4BYTES, mtr); } - if (0 != strcmp((char*) (sys_header + field + TRX_SYS_MYSQL_LOG_NAME), file_name)) { + if (0 != strcmp((char*) (sys_header + field + TRX_SYS_MYSQL_LOG_NAME), + file_name)) { mlog_write_string(sys_header + field - + TRX_SYS_MYSQL_LOG_NAME, - (byte*) file_name, 1 + ut_strlen(file_name), mtr); + + TRX_SYS_MYSQL_LOG_NAME, + (byte*) file_name, 1 + ut_strlen(file_name), + mtr); } if (mach_read_from_4(sys_header + field - + TRX_SYS_MYSQL_LOG_OFFSET_HIGH) > 0 - || (offset >> 32) > 0) { + + TRX_SYS_MYSQL_LOG_OFFSET_HIGH) > 0 + || (offset >> 32) > 0) { mlog_write_ulint(sys_header + field - + TRX_SYS_MYSQL_LOG_OFFSET_HIGH, - (ulint)(offset >> 32), - MLOG_4BYTES, mtr); + + TRX_SYS_MYSQL_LOG_OFFSET_HIGH, + (ulint)(offset >> 32), + MLOG_4BYTES, mtr); } mlog_write_ulint(sys_header + field - + TRX_SYS_MYSQL_LOG_OFFSET_LOW, - (ulint)(offset & 0xFFFFFFFFUL), - MLOG_4BYTES, mtr); + + TRX_SYS_MYSQL_LOG_OFFSET_LOW, + (ulint)(offset & 0xFFFFFFFFUL), + MLOG_4BYTES, mtr); } /********************************************************************* @@ -643,16 +665,20 @@ trx_sys_print_mysql_binlog_offset_from_page( sys_header = page + TRX_SYS; if (mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO - + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) - == TRX_SYS_MYSQL_LOG_MAGIC_N) { + + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) + == TRX_SYS_MYSQL_LOG_MAGIC_N) { fprintf(stderr, - "ibbackup: Last MySQL binlog file position %lu %lu, file name %s\n", - (ulong) mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO - + TRX_SYS_MYSQL_LOG_OFFSET_HIGH), - (ulong) mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO - + TRX_SYS_MYSQL_LOG_OFFSET_LOW), - sys_header + TRX_SYS_MYSQL_LOG_INFO + TRX_SYS_MYSQL_LOG_NAME); + "ibbackup: Last MySQL binlog file position %lu %lu," + " file name %s\n", + (ulong) mach_read_from_4 + (sys_header + TRX_SYS_MYSQL_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_HIGH), + (ulong) mach_read_from_4 + (sys_header + TRX_SYS_MYSQL_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_LOW), + sys_header + TRX_SYS_MYSQL_LOG_INFO + + TRX_SYS_MYSQL_LOG_NAME); } } @@ -674,27 +700,32 @@ trx_sys_print_mysql_binlog_offset(void) sys_header = trx_sysf_get(&mtr); if (mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO - + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) - != TRX_SYS_MYSQL_LOG_MAGIC_N) { + + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) + != TRX_SYS_MYSQL_LOG_MAGIC_N) { mtr_commit(&mtr); return; } - trx_sys_mysql_bin_log_pos_high = mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO - + TRX_SYS_MYSQL_LOG_OFFSET_HIGH); - trx_sys_mysql_bin_log_pos_low = mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO - + TRX_SYS_MYSQL_LOG_OFFSET_LOW); + trx_sys_mysql_bin_log_pos_high = mach_read_from_4 + (sys_header + TRX_SYS_MYSQL_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_HIGH); + trx_sys_mysql_bin_log_pos_low = mach_read_from_4 + (sys_header + TRX_SYS_MYSQL_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_LOW); - trx_sys_mysql_bin_log_pos = (((ib_longlong)trx_sys_mysql_bin_log_pos_high) << 32) + - (ib_longlong)trx_sys_mysql_bin_log_pos_low; + trx_sys_mysql_bin_log_pos + = (((ib_longlong)trx_sys_mysql_bin_log_pos_high) << 32) + + (ib_longlong)trx_sys_mysql_bin_log_pos_low; - ut_memcpy(trx_sys_mysql_bin_log_name, sys_header + TRX_SYS_MYSQL_LOG_INFO + - TRX_SYS_MYSQL_LOG_NAME, TRX_SYS_MYSQL_LOG_NAME_LEN); + ut_memcpy(trx_sys_mysql_bin_log_name, + sys_header + TRX_SYS_MYSQL_LOG_INFO + + TRX_SYS_MYSQL_LOG_NAME, TRX_SYS_MYSQL_LOG_NAME_LEN); fprintf(stderr, - "InnoDB: Last MySQL binlog file position %lu %lu, file name %s\n", + "InnoDB: Last MySQL binlog file position %lu %lu," + " file name %s\n", trx_sys_mysql_bin_log_pos_high, trx_sys_mysql_bin_log_pos_low, trx_sys_mysql_bin_log_name); @@ -717,8 +748,8 @@ trx_sys_print_mysql_master_log_pos(void) sys_header = trx_sysf_get(&mtr); if (mach_read_from_4(sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO - + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) - != TRX_SYS_MYSQL_LOG_MAGIC_N) { + + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) + != TRX_SYS_MYSQL_LOG_MAGIC_N) { mtr_commit(&mtr); @@ -726,30 +757,32 @@ trx_sys_print_mysql_master_log_pos(void) } fprintf(stderr, -"InnoDB: In a MySQL replication slave the last master binlog file\n" -"InnoDB: position %lu %lu, file name %s\n", - (ulong) mach_read_from_4(sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO - + TRX_SYS_MYSQL_LOG_OFFSET_HIGH), - (ulong) mach_read_from_4(sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO - + TRX_SYS_MYSQL_LOG_OFFSET_LOW), + "InnoDB: In a MySQL replication slave the last" + " master binlog file\n" + "InnoDB: position %lu %lu, file name %s\n", + (ulong) mach_read_from_4(sys_header + + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_HIGH), + (ulong) mach_read_from_4(sys_header + + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_LOW), sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO - + TRX_SYS_MYSQL_LOG_NAME); + + TRX_SYS_MYSQL_LOG_NAME); /* Copy the master log position info to global variables we can use in ha_innobase.cc to initialize glob_mi to right values */ ut_memcpy(trx_sys_mysql_master_log_name, - sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO - + TRX_SYS_MYSQL_LOG_NAME, - TRX_SYS_MYSQL_LOG_NAME_LEN); + sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_NAME, + TRX_SYS_MYSQL_LOG_NAME_LEN); - trx_sys_mysql_master_log_pos = - (((ib_longlong)mach_read_from_4( - sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO - + TRX_SYS_MYSQL_LOG_OFFSET_HIGH)) - << 32) - + (ib_longlong) - mach_read_from_4(sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO - + TRX_SYS_MYSQL_LOG_OFFSET_LOW); + trx_sys_mysql_master_log_pos + = (((ib_longlong) mach_read_from_4 + (sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_HIGH)) << 32) + + ((ib_longlong) mach_read_from_4 + (sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_LOW)); mtr_commit(&mtr); } @@ -811,21 +844,27 @@ trx_sysf_create( /* Create the trx sys file block in a new allocated file segment */ page = fseg_create(TRX_SYS_SPACE, 0, TRX_SYS + TRX_SYS_FSEG_HEADER, - mtr); + mtr); ut_a(buf_frame_get_page_no(page) == TRX_SYS_PAGE_NO); + /* Reset the doublewrite buffer magic number to zero so that we + know that the doublewrite buffer has not yet been created (this + suppresses a Valgrind warning) */ + + mach_write_to_4(page + TRX_SYS_DOUBLEWRITE + TRX_SYS_DOUBLEWRITE_MAGIC, + 0); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_TRX_SYS_HEADER); #endif /* UNIV_SYNC_DEBUG */ mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_TYPE_TRX_SYS, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); sys_header = trx_sysf_get(mtr); /* Start counting transaction ids from number 1 up */ mlog_write_dulint(sys_header + TRX_SYS_TRX_ID_STORE, - ut_dulint_create(0, 1), mtr); + ut_dulint_create(0, 1), mtr); /* Reset the rollback segment slots */ for (i = 0; i < TRX_SYS_N_RSEGS; i++) { @@ -838,7 +877,7 @@ trx_sysf_create( /* Create the first rollback segment in the SYSTEM tablespace */ page_no = trx_rseg_header_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no, - mtr); + mtr); ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID); ut_a(page_no != FIL_NULL); @@ -880,12 +919,12 @@ trx_sys_init_at_db_start(void) to the disk-based header! Thus trx id values will not overlap when the database is repeatedly started! */ - trx_sys->max_trx_id = ut_dulint_add( - ut_dulint_align_up( - mtr_read_dulint(sys_header - + TRX_SYS_TRX_ID_STORE, &mtr), - TRX_SYS_TRX_ID_WRITE_MARGIN), - 2 * TRX_SYS_TRX_ID_WRITE_MARGIN); + trx_sys->max_trx_id = ut_dulint_add + (ut_dulint_align_up(mtr_read_dulint + (sys_header + + TRX_SYS_TRX_ID_STORE, &mtr), + TRX_SYS_TRX_ID_WRITE_MARGIN), + 2 * TRX_SYS_TRX_ID_WRITE_MARGIN); UT_LIST_INIT(trx_sys->mysql_trx_list); trx_lists_init_at_db_start(); @@ -896,8 +935,8 @@ trx_sys_init_at_db_start(void) for (;;) { if ( trx->conc_state != TRX_PREPARED) { - rows_to_undo += - ut_conv_dulint_to_longlong(trx->undo_no); + rows_to_undo += ut_conv_dulint_to_longlong + (trx->undo_no); } trx = UT_LIST_GET_NEXT(trx_list, trx); @@ -913,10 +952,11 @@ trx_sys_init_at_db_start(void) } fprintf(stderr, -"InnoDB: %lu transaction(s) which must be rolled back or cleaned up\n" -"InnoDB: in total %lu%s row operations to undo\n", - (ulong) UT_LIST_GET_LEN(trx_sys->trx_list), - (ulong) rows_to_undo, unit); + "InnoDB: %lu transaction(s) which must be" + " rolled back or cleaned up\n" + "InnoDB: in total %lu%s row operations to undo\n", + (ulong) UT_LIST_GET_LEN(trx_sys->trx_list), + (ulong) rows_to_undo, unit); fprintf(stderr, "InnoDB: Trx id counter is %lu %lu\n", (ulong) ut_dulint_get_high(trx_sys->max_trx_id), diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c index 50ede8a6ff1..78b9e2446cb 100644 --- a/storage/innobase/trx/trx0trx.c +++ b/storage/innobase/trx/trx0trx.c @@ -75,7 +75,7 @@ trx_set_detailed_error_from_file( FILE* file) /* in: file to read message from */ { os_file_read_string(file, trx->detailed_error, - sizeof(trx->detailed_error)); + sizeof(trx->detailed_error)); } /******************************************************************** @@ -286,21 +286,21 @@ trx_free( if (trx->declared_to_be_inside_innodb) { ut_print_timestamp(stderr); - fputs( -" InnoDB: Error: Freeing a trx which is declared to be processing\n" -"InnoDB: inside InnoDB.\n", stderr); + fputs(" InnoDB: Error: Freeing a trx which is declared" + " to be processing\n" + "InnoDB: inside InnoDB.\n", stderr); trx_print(stderr, trx, 600); putc('\n', stderr); } if (trx->n_mysql_tables_in_use != 0 - || trx->mysql_n_tables_locked != 0) { + || trx->mysql_n_tables_locked != 0) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Error: MySQL is freeing a thd\n" -"InnoDB: though trx->n_mysql_tables_in_use is %lu\n" -"InnoDB: and trx->mysql_n_tables_locked is %lu.\n", + " InnoDB: Error: MySQL is freeing a thd\n" + "InnoDB: though trx->n_mysql_tables_in_use is %lu\n" + "InnoDB: and trx->mysql_n_tables_locked is %lu.\n", (ulong)trx->n_mysql_tables_in_use, (ulong)trx->mysql_n_tables_locked); @@ -428,7 +428,7 @@ trx_list_insert_ordered( UT_LIST_ADD_FIRST(trx_list, trx_sys->trx_list, trx); } else { UT_LIST_INSERT_AFTER(trx_list, trx_sys->trx_list, - trx2, trx); + trx2, trx); } } else { UT_LIST_ADD_LAST(trx_list, trx_sys->trx_list, trx); @@ -478,22 +478,28 @@ trx_lists_init_at_db_start(void) if (undo->state == TRX_UNDO_PREPARED) { fprintf(stderr, -"InnoDB: Transaction %lu %lu was in the XA prepared state.\n", - ut_dulint_get_high(trx->id), - ut_dulint_get_low(trx->id)); + "InnoDB: Transaction %lu %lu" + " was in the" + " XA prepared state.\n", + ut_dulint_get_high(trx->id), + ut_dulint_get_low(trx->id)); if (srv_force_recovery == 0) { trx->conc_state = TRX_PREPARED; } else { fprintf(stderr, -"InnoDB: Since innodb_force_recovery > 0, we will rollback it anyway.\n"); + "InnoDB: Since" + " innodb_force_recovery" + " > 0, we will" + " rollback it" + " anyway.\n"); trx->conc_state = TRX_ACTIVE; } } else { - trx->conc_state = - TRX_COMMITTED_IN_MEMORY; + trx->conc_state + = TRX_COMMITTED_IN_MEMORY; } /* We give a dummy value for the trx no; @@ -520,7 +526,7 @@ trx_lists_init_at_db_start(void) if (!undo->empty) { trx->undo_no = ut_dulint_add(undo->top_undo_no, - 1); + 1); } trx_list_insert_ordered(trx); @@ -547,24 +553,32 @@ trx_lists_init_at_db_start(void) if (undo->state == TRX_UNDO_PREPARED) { fprintf(stderr, -"InnoDB: Transaction %lu %lu was in the XA prepared state.\n", - ut_dulint_get_high(trx->id), - ut_dulint_get_low(trx->id)); + "InnoDB: Transaction" + " %lu %lu was in the" + " XA prepared state.\n", + ut_dulint_get_high + (trx->id), + ut_dulint_get_low + (trx->id)); if (srv_force_recovery == 0) { - trx->conc_state = - TRX_PREPARED; + trx->conc_state + = TRX_PREPARED; } else { fprintf(stderr, -"InnoDB: Since innodb_force_recovery > 0, we will rollback it anyway.\n"); + "InnoDB: Since" + " innodb_force_recovery" + " > 0, we will" + " rollback it" + " anyway.\n"); - trx->conc_state = - TRX_ACTIVE; + trx->conc_state + = TRX_ACTIVE; } } else { - trx->conc_state = - TRX_COMMITTED_IN_MEMORY; + trx->conc_state + = TRX_COMMITTED_IN_MEMORY; } /* We give a dummy value for the trx @@ -585,8 +599,8 @@ trx_lists_init_at_db_start(void) trx_list_insert_ordered(trx); if (undo->dict_operation) { - trx->dict_operation = - undo->dict_operation; + trx->dict_operation + = undo->dict_operation; trx->table_id = undo->table_id; } } @@ -594,11 +608,11 @@ trx_lists_init_at_db_start(void) trx->update_undo = undo; if ((!undo->empty) - && (ut_dulint_cmp(undo->top_undo_no, - trx->undo_no) >= 0)) { + && (ut_dulint_cmp(undo->top_undo_no, + trx->undo_no) >= 0)) { trx->undo_no = ut_dulint_add(undo->top_undo_no, - 1); + 1); } undo = UT_LIST_GET_NEXT(undo_list, undo); @@ -635,7 +649,7 @@ loop: it */ if ((rseg->id == TRX_SYS_SYSTEM_RSEG_ID) - && (UT_LIST_GET_LEN(trx_sys->rseg_list) > 1)) { + && (UT_LIST_GET_LEN(trx_sys->rseg_list) > 1)) { goto loop; } @@ -761,7 +775,7 @@ trx_commit_off_kernel( if (trx->insert_undo != NULL) { trx_undo_set_state_at_finish(trx, trx->insert_undo, - &mtr); + &mtr); } undo = trx->update_undo; @@ -776,8 +790,8 @@ trx_commit_off_kernel( because only a single OS thread is allowed to do the transaction commit for this transaction. */ - update_hdr_page = trx_undo_set_state_at_finish(trx, - undo, &mtr); + update_hdr_page = trx_undo_set_state_at_finish + (trx, undo, &mtr); /* We have to do the cleanup for the update log while holding the rseg mutex because update log headers @@ -794,20 +808,20 @@ trx_commit_off_kernel( server is a MySQL replication slave */ if (trx->mysql_log_file_name - && trx->mysql_log_file_name[0] != '\0') { - trx_sys_update_mysql_binlog_offset( - trx->mysql_log_file_name, - trx->mysql_log_offset, - TRX_SYS_MYSQL_LOG_INFO, &mtr); + && trx->mysql_log_file_name[0] != '\0') { + trx_sys_update_mysql_binlog_offset + (trx->mysql_log_file_name, + trx->mysql_log_offset, + TRX_SYS_MYSQL_LOG_INFO, &mtr); trx->mysql_log_file_name = NULL; } if (trx->mysql_master_log_file_name[0] != '\0') { /* This database server is a MySQL replication slave */ - trx_sys_update_mysql_binlog_offset( - trx->mysql_master_log_file_name, - trx->mysql_master_log_pos, - TRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr); + trx_sys_update_mysql_binlog_offset + (trx->mysql_master_log_file_name, + trx->mysql_master_log_pos, + TRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr); } /* The following call commits the mini-transaction, making the @@ -836,7 +850,7 @@ trx_commit_off_kernel( } ut_ad(trx->conc_state == TRX_ACTIVE - || trx->conc_state == TRX_PREPARED); + || trx->conc_state == TRX_PREPARED); #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); #endif /* UNIV_SYNC_DEBUG */ @@ -916,7 +930,7 @@ trx_commit_off_kernel( /* Write the log but do not flush it to disk */ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, - FALSE); + FALSE); } else { /* Write the log to the log files AND flush them to disk */ @@ -996,8 +1010,8 @@ trx_assign_read_view( mutex_enter(&kernel_mutex); if (!trx->read_view) { - trx->read_view = read_view_open_now(trx->id, - trx->global_read_view_heap); + trx->read_view = read_view_open_now + (trx->id, trx->global_read_view_heap); trx->global_read_view = trx->read_view; } @@ -1286,7 +1300,7 @@ trx_sig_send( receiver_trx = thr_get_trx(receiver_thr); UT_LIST_ADD_LAST(reply_signals, receiver_trx->reply_signals, - sig); + sig); } if (trx->sess->state == SESS_ERROR) { @@ -1411,7 +1425,7 @@ loop: trx_handle_commit_sig_off_kernel(trx, next_thr); } else if ((type == TRX_SIG_TOTAL_ROLLBACK) - || (type == TRX_SIG_ROLLBACK_TO_SAVEPT)) { + || (type == TRX_SIG_ROLLBACK_TO_SAVEPT)) { trx_rollback(trx, sig, next_thr); @@ -1467,7 +1481,7 @@ trx_sig_reply( receiver_trx = thr_get_trx(sig->receiver); UT_LIST_REMOVE(reply_signals, receiver_trx->reply_signals, - sig); + sig); ut_ad(receiver_trx->sess->state != SESS_ERROR); que_thr_end_wait(sig->receiver, next_thr); @@ -1551,7 +1565,7 @@ trx_commit_step( /* Send the commit signal to the transaction */ trx_sig_send(thr_get_trx(thr), TRX_SIG_COMMIT, TRX_SIG_SELF, - thr, NULL, &next_thr); + thr, NULL, &next_thr); mutex_exit(&kernel_mutex); @@ -1679,25 +1693,25 @@ trx_print( fprintf(f, "TRANSACTION %lu %lu", (ulong) ut_dulint_get_high(trx->id), - (ulong) ut_dulint_get_low(trx->id)); + (ulong) ut_dulint_get_low(trx->id)); switch (trx->conc_state) { - case TRX_NOT_STARTED: - fputs(", not started", f); - break; - case TRX_ACTIVE: - fprintf(f, ", ACTIVE %lu sec", - (ulong)difftime(time(NULL), trx->start_time)); - break; - case TRX_PREPARED: - fprintf(f, ", ACTIVE (PREPARED) %lu sec", - (ulong)difftime(time(NULL), trx->start_time)); - break; - case TRX_COMMITTED_IN_MEMORY: - fputs(", COMMITTED IN MEMORY", f); - break; - default: - fprintf(f, " state %lu", (ulong) trx->conc_state); + case TRX_NOT_STARTED: + fputs(", not started", f); + break; + case TRX_ACTIVE: + fprintf(f, ", ACTIVE %lu sec", + (ulong)difftime(time(NULL), trx->start_time)); + break; + case TRX_PREPARED: + fprintf(f, ", ACTIVE (PREPARED) %lu sec", + (ulong)difftime(time(NULL), trx->start_time)); + break; + case TRX_COMMITTED_IN_MEMORY: + fputs(", COMMITTED IN MEMORY", f); + break; + default: + fprintf(f, " state %lu", (ulong) trx->conc_state); } #ifdef UNIV_LINUX @@ -1724,27 +1738,27 @@ trx_print( if (trx->n_mysql_tables_in_use > 0 || trx->mysql_n_tables_locked > 0) { fprintf(f, "mysql tables in use %lu, locked %lu\n", - (ulong) trx->n_mysql_tables_in_use, - (ulong) trx->mysql_n_tables_locked); + (ulong) trx->n_mysql_tables_in_use, + (ulong) trx->mysql_n_tables_locked); } newline = TRUE; switch (trx->que_state) { - case TRX_QUE_RUNNING: - newline = FALSE; break; - case TRX_QUE_LOCK_WAIT: - fputs("LOCK WAIT ", f); break; - case TRX_QUE_ROLLING_BACK: - fputs("ROLLING BACK ", f); break; - case TRX_QUE_COMMITTING: - fputs("COMMITTING ", f); break; - default: - fprintf(f, "que state %lu ", (ulong) trx->que_state); + case TRX_QUE_RUNNING: + newline = FALSE; break; + case TRX_QUE_LOCK_WAIT: + fputs("LOCK WAIT ", f); break; + case TRX_QUE_ROLLING_BACK: + fputs("ROLLING BACK ", f); break; + case TRX_QUE_COMMITTING: + fputs("COMMITTING ", f); break; + default: + fprintf(f, "que state %lu ", (ulong) trx->que_state); } - if (0 < UT_LIST_GET_LEN(trx->trx_locks) || - mem_heap_get_size(trx->lock_heap) > 400) { + if (0 < UT_LIST_GET_LEN(trx->trx_locks) + || mem_heap_get_size(trx->lock_heap) > 400) { newline = TRUE; fprintf(f, "%lu lock struct(s), heap size %lu", @@ -1817,12 +1831,12 @@ trx_prepare_off_kernel( transaction prepare for this transaction. */ trx_undo_set_state_at_prepare(trx, trx->insert_undo, - &mtr); + &mtr); } if (trx->update_undo) { - update_hdr_page = trx_undo_set_state_at_prepare(trx, - trx->update_undo, &mtr); + update_hdr_page = trx_undo_set_state_at_prepare + (trx, trx->update_undo, &mtr); } mutex_exit(&(rseg->mutex)); @@ -1872,7 +1886,7 @@ trx_prepare_off_kernel( /* Write the log but do not flush it to disk */ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, - FALSE); + FALSE); } else { /* Write the log to the log files AND flush them to disk */ @@ -1954,19 +1968,23 @@ trx_recover_for_mysql( if (count == 0) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Starting recovery for XA transactions...\n"); + " InnoDB: Starting recovery for" + " XA transactions...\n"); } ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Transaction %lu %lu in prepared state after recovery\n", + " InnoDB: Transaction %lu %lu in" + " prepared state after recovery\n", (ulong) ut_dulint_get_high(trx->id), (ulong) ut_dulint_get_low(trx->id)); ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: Transaction contains changes to %lu rows\n", - (ulong)ut_conv_dulint_to_longlong(trx->undo_no)); + " InnoDB: Transaction contains changes" + " to %lu rows\n", + (ulong) ut_conv_dulint_to_longlong + (trx->undo_no)); count++; @@ -1983,7 +2001,8 @@ trx_recover_for_mysql( if (count > 0){ ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: %lu transactions in prepared state after recovery\n", + " InnoDB: %lu transactions in prepared state" + " after recovery\n", (ulong) count); } @@ -2017,11 +2036,10 @@ trx_get_trx_by_xid( of gtrid_lenght+bqual_length bytes should be the same */ - if (xid->gtrid_length == trx->xid.gtrid_length && - xid->bqual_length == trx->xid.bqual_length && - memcmp(xid->data, trx->xid.data, - xid->gtrid_length + - xid->bqual_length) == 0) { + if (xid->gtrid_length == trx->xid.gtrid_length + && xid->bqual_length == trx->xid.bqual_length + && memcmp(xid->data, trx->xid.data, + xid->gtrid_length + xid->bqual_length) == 0) { break; } diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c index bba1a4d6996..db33c515c34 100644 --- a/storage/innobase/trx/trx0undo.c +++ b/storage/innobase/trx/trx0undo.c @@ -145,17 +145,16 @@ trx_undo_get_prev_rec_from_prev_page( undo_page = buf_frame_align(rec); prev_page_no = flst_get_prev_addr(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_NODE, mtr) - .page; + + TRX_UNDO_PAGE_NODE, mtr) + .page; if (prev_page_no == FIL_NULL) { return(NULL); } - prev_page = trx_undo_page_get_s_latched( - buf_frame_get_space_id(undo_page), - prev_page_no, mtr); + prev_page = trx_undo_page_get_s_latched + (buf_frame_get_space_id(undo_page), prev_page_no, mtr); return(trx_undo_page_get_last_rec(prev_page, page_no, offset)); } @@ -186,7 +185,7 @@ trx_undo_get_prev_rec( previous record */ return(trx_undo_get_prev_rec_from_prev_page(rec, page_no, offset, - mtr)); + mtr)); } /*************************************************************************** @@ -223,8 +222,8 @@ trx_undo_get_next_rec_from_next_page( space = buf_frame_get_space_id(undo_page); next_page_no = flst_get_next_addr(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_NODE, mtr) - .page; + + TRX_UNDO_PAGE_NODE, mtr) + .page; if (next_page_no == FIL_NULL) { return(NULL); @@ -232,7 +231,7 @@ trx_undo_get_next_rec_from_next_page( if (mode == RW_S_LATCH) { next_page = trx_undo_page_get_s_latched(space, next_page_no, - mtr); + mtr); } else { ut_ad(mode == RW_X_LATCH); next_page = trx_undo_page_get(space, next_page_no, mtr); @@ -263,8 +262,8 @@ trx_undo_get_next_rec( } return(trx_undo_get_next_rec_from_next_page(buf_frame_align(rec), - page_no, offset, - RW_S_LATCH, mtr)); + page_no, offset, + RW_S_LATCH, mtr)); } /*************************************************************************** @@ -297,7 +296,7 @@ trx_undo_get_first_rec( } return(trx_undo_get_next_rec_from_next_page(undo_page, page_no, offset, - mode, mtr)); + mode, mtr)); } /*============== UNDO LOG FILE COPY CREATION AND FREEING ==================*/ @@ -362,9 +361,9 @@ trx_undo_page_init( mach_write_to_2(page_hdr + TRX_UNDO_PAGE_TYPE, type); mach_write_to_2(page_hdr + TRX_UNDO_PAGE_START, - TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); mach_write_to_2(page_hdr + TRX_UNDO_PAGE_FREE, - TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); fil_page_set_type(undo_page, FIL_PAGE_UNDO_LOG); @@ -400,16 +399,18 @@ trx_undo_seg_create( ut_ad(mutex_own(&(rseg->mutex))); #endif /* UNIV_SYNC_DEBUG */ -/* fputs(type == TRX_UNDO_INSERT - ? "Creating insert undo log segment\n" - : "Creating update undo log segment\n", stderr); */ + /* fputs(type == TRX_UNDO_INSERT + ? "Creating insert undo log segment\n" + : "Creating update undo log segment\n", stderr); */ slot_no = trx_rsegf_undo_find_free(rseg_hdr, mtr); if (slot_no == ULINT_UNDEFINED) { ut_print_timestamp(stderr); fprintf(stderr, -"InnoDB: Warning: cannot find a free slot for an undo log. Do you have too\n" -"InnoDB: many active transactions running concurrently?\n"); + "InnoDB: Warning: cannot find a free slot for" + " an undo log. Do you have too\n" + "InnoDB: many active transactions" + " running concurrently?\n"); return(NULL); } @@ -417,7 +418,7 @@ trx_undo_seg_create( space = buf_frame_get_space_id(rseg_hdr); success = fsp_reserve_free_extents(&n_reserved, space, 2, FSP_UNDO, - mtr); + mtr); if (!success) { return(NULL); @@ -425,7 +426,8 @@ trx_undo_seg_create( /* Allocate a new file segment for the undo log */ undo_page = fseg_create_general(space, 0, - TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER, TRUE, mtr); + TRX_UNDO_SEG_HDR + + TRX_UNDO_FSEG_HEADER, TRUE, mtr); fil_space_release_free_extents(space, n_reserved); @@ -445,18 +447,18 @@ trx_undo_seg_create( trx_undo_page_init(undo_page, type, mtr); mlog_write_ulint(page_hdr + TRX_UNDO_PAGE_FREE, - TRX_UNDO_SEG_HDR + TRX_UNDO_SEG_HDR_SIZE, - MLOG_2BYTES, mtr); + TRX_UNDO_SEG_HDR + TRX_UNDO_SEG_HDR_SIZE, + MLOG_2BYTES, mtr); mlog_write_ulint(seg_hdr + TRX_UNDO_LAST_LOG, 0, MLOG_2BYTES, mtr); flst_init(seg_hdr + TRX_UNDO_PAGE_LIST, mtr); flst_add_last(seg_hdr + TRX_UNDO_PAGE_LIST, - page_hdr + TRX_UNDO_PAGE_NODE, mtr); + page_hdr + TRX_UNDO_PAGE_NODE, mtr); trx_rsegf_set_nth_undo(rseg_hdr, slot_no, - buf_frame_get_page_no(undo_page), mtr); + buf_frame_get_page_no(undo_page), mtr); *id = slot_no; return(undo_page); @@ -560,16 +562,16 @@ trx_undo_write_xid( mtr_t* mtr) /* in: mtr */ { mlog_write_ulint(log_hdr + TRX_UNDO_XA_FORMAT, - (ulint)xid->formatID, MLOG_4BYTES, mtr); + (ulint)xid->formatID, MLOG_4BYTES, mtr); mlog_write_ulint(log_hdr + TRX_UNDO_XA_TRID_LEN, - (ulint)xid->gtrid_length, MLOG_4BYTES, mtr); + (ulint)xid->gtrid_length, MLOG_4BYTES, mtr); mlog_write_ulint(log_hdr + TRX_UNDO_XA_BQUAL_LEN, - (ulint)xid->bqual_length, MLOG_4BYTES, mtr); + (ulint)xid->bqual_length, MLOG_4BYTES, mtr); mlog_write_string(log_hdr + TRX_UNDO_XA_XID, (const byte*) xid->data, - XIDDATASIZE, mtr); + XIDDATASIZE, mtr); } /************************************************************************ @@ -583,10 +585,10 @@ trx_undo_read_xid( { xid->formatID = (long)mach_read_from_4(log_hdr + TRX_UNDO_XA_FORMAT); - xid->gtrid_length = - (long)mach_read_from_4(log_hdr + TRX_UNDO_XA_TRID_LEN); - xid->bqual_length = - (long)mach_read_from_4(log_hdr + TRX_UNDO_XA_BQUAL_LEN); + xid->gtrid_length + = (long) mach_read_from_4(log_hdr + TRX_UNDO_XA_TRID_LEN); + xid->bqual_length + = (long) mach_read_from_4(log_hdr + TRX_UNDO_XA_BQUAL_LEN); memcpy(xid->data, log_hdr + TRX_UNDO_XA_XID, XIDDATASIZE); } @@ -614,19 +616,19 @@ trx_undo_header_add_space_for_xid( ut_a(free == (ulint)(log_hdr - undo_page) + TRX_UNDO_LOG_OLD_HDR_SIZE); new_free = free + (TRX_UNDO_LOG_XA_HDR_SIZE - - TRX_UNDO_LOG_OLD_HDR_SIZE); + - TRX_UNDO_LOG_OLD_HDR_SIZE); /* Add space for a XID after the header, update the free offset fields on the undo log page and in the undo log header */ mlog_write_ulint(page_hdr + TRX_UNDO_PAGE_START, new_free, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); mlog_write_ulint(page_hdr + TRX_UNDO_PAGE_FREE, new_free, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); mlog_write_ulint(log_hdr + TRX_UNDO_LOG_START, new_free, - MLOG_2BYTES, mtr); + MLOG_2BYTES, mtr); } /************************************************************************** @@ -715,8 +717,8 @@ trx_undo_insert_header_reuse( the space on the page */ ut_a(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_TYPE) - == TRX_UNDO_INSERT); + + TRX_UNDO_PAGE_TYPE) + == TRX_UNDO_INSERT); mach_write_to_2(page_hdr + TRX_UNDO_PAGE_START, new_free); @@ -800,7 +802,8 @@ trx_undo_discard_latest_update_undo( prev_log_hdr = undo_page + prev_hdr_offset; mach_write_to_2(page_hdr + TRX_UNDO_PAGE_START, - mach_read_from_2(prev_log_hdr + TRX_UNDO_LOG_START)); + mach_read_from_2(prev_log_hdr + + TRX_UNDO_LOG_START)); mach_write_to_2(prev_log_hdr + TRX_UNDO_NEXT_LOG, 0); } @@ -849,16 +852,16 @@ trx_undo_add_page( header_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); success = fsp_reserve_free_extents(&n_reserved, undo->space, 1, - FSP_UNDO, mtr); + FSP_UNDO, mtr); if (!success) { return(FIL_NULL); } page_no = fseg_alloc_free_page_general(header_page + TRX_UNDO_SEG_HDR - + TRX_UNDO_FSEG_HEADER, - undo->top_page_no + 1, FSP_UP, - TRUE, mtr); + + TRX_UNDO_FSEG_HEADER, + undo->top_page_no + 1, FSP_UP, + TRUE, mtr); fil_space_release_free_extents(undo->space, n_reserved); @@ -876,7 +879,7 @@ trx_undo_add_page( trx_undo_page_init(new_page, undo->type, mtr); flst_add_last(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST, - new_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, mtr); + new_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, mtr); undo->size++; rseg->curr_size++; @@ -918,23 +921,23 @@ trx_undo_free_page( header_page = trx_undo_page_get(space, hdr_page_no, mtr); flst_remove(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST, - undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, mtr); + undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, mtr); fseg_free_page(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER, - space, page_no, mtr); + space, page_no, mtr); last_addr = flst_get_last(header_page + TRX_UNDO_SEG_HDR - + TRX_UNDO_PAGE_LIST, mtr); + + TRX_UNDO_PAGE_LIST, mtr); rseg->curr_size--; if (in_history) { rseg_header = trx_rsegf_get(space, rseg->page_no, mtr); hist_size = mtr_read_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE, - MLOG_4BYTES, mtr); + MLOG_4BYTES, mtr); ut_ad(hist_size > 0); mlog_write_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE, - hist_size - 1, MLOG_4BYTES, mtr); + hist_size - 1, MLOG_4BYTES, mtr); } return(last_addr.page); @@ -963,7 +966,7 @@ trx_undo_free_page_in_rollback( #endif /* UNIV_SYNC_DEBUG */ last_page_no = trx_undo_free_page(undo->rseg, FALSE, undo->space, - undo->hdr_page_no, page_no, mtr); + undo->hdr_page_no, page_no, mtr); undo->last_page_no = last_page_no; undo->size--; @@ -1030,7 +1033,7 @@ trx_undo_truncate_end( undo_page = trx_undo_page_get(undo->space, last_page_no, &mtr); rec = trx_undo_page_get_last_rec(undo_page, undo->hdr_page_no, - undo->hdr_offset); + undo->hdr_offset); for (;;) { if (rec == NULL) { if (last_page_no == undo->hdr_page_no) { @@ -1038,13 +1041,13 @@ trx_undo_truncate_end( goto function_exit; } - trx_undo_free_page_in_rollback(trx, undo, - last_page_no, &mtr); + trx_undo_free_page_in_rollback + (trx, undo, last_page_no, &mtr); break; } if (ut_dulint_cmp(trx_undo_rec_get_undo_no(rec), limit) - >= 0) { + >= 0) { /* Truncate at least this record off, maybe more */ trunc_here = rec; @@ -1053,8 +1056,8 @@ trx_undo_truncate_end( } rec = trx_undo_page_get_prev_rec(rec, - undo->hdr_page_no, - undo->hdr_offset); + undo->hdr_page_no, + undo->hdr_offset); } mtr_commit(&mtr); @@ -1063,8 +1066,8 @@ trx_undo_truncate_end( function_exit: if (trunc_here) { mlog_write_ulint(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_FREE, - trunc_here - undo_page, MLOG_2BYTES, &mtr); + + TRX_UNDO_PAGE_FREE, + trunc_here - undo_page, MLOG_2BYTES, &mtr); } mtr_commit(&mtr); @@ -1105,7 +1108,7 @@ loop: mtr_start(&mtr); rec = trx_undo_get_first_rec(space, hdr_page_no, hdr_offset, - RW_X_LATCH, &mtr); + RW_X_LATCH, &mtr); if (rec == NULL) { /* Already empty */ @@ -1117,7 +1120,7 @@ loop: undo_page = buf_frame_align(rec); last_rec = trx_undo_page_get_last_rec(undo_page, hdr_page_no, - hdr_offset); + hdr_offset); if (ut_dulint_cmp(trx_undo_rec_get_undo_no(last_rec), limit) >= 0) { mtr_commit(&mtr); @@ -1129,10 +1132,10 @@ loop: if (page_no == hdr_page_no) { trx_undo_empty_header_page(space, hdr_page_no, hdr_offset, - &mtr); + &mtr); } else { trx_undo_free_page(rseg, TRUE, space, hdr_page_no, - page_no, &mtr); + page_no, &mtr); } mtr_commit(&mtr); @@ -1167,7 +1170,7 @@ trx_undo_seg_free( mutex_enter(&(rseg->mutex)); seg_header = trx_undo_page_get(undo->space, undo->hdr_page_no, - &mtr) + TRX_UNDO_SEG_HDR; + &mtr) + TRX_UNDO_SEG_HDR; file_seg = seg_header + TRX_UNDO_FSEG_HEADER; @@ -1176,9 +1179,9 @@ trx_undo_seg_free( if (finished) { /* Update the rseg header */ rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, - &mtr); + &mtr); trx_rsegf_set_nth_undo(rseg_header, undo->id, FIL_NULL, - &mtr); + &mtr); } mutex_exit(&(rseg->mutex)); @@ -1219,7 +1222,7 @@ trx_undo_mem_create_at_db_start( if (id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, - "InnoDB: Error: undo->id is %lu\n", (ulong) id); + "InnoDB: Error: undo->id is %lu\n", (ulong) id); ut_error; } @@ -1228,7 +1231,7 @@ trx_undo_mem_create_at_db_start( page_header = undo_page + TRX_UNDO_PAGE_HDR; type = mtr_read_ulint(page_header + TRX_UNDO_PAGE_TYPE, MLOG_2BYTES, - mtr); + mtr); seg_header = undo_page + TRX_UNDO_SEG_HDR; state = mach_read_from_2(seg_header + TRX_UNDO_STATE); @@ -1240,7 +1243,7 @@ trx_undo_mem_create_at_db_start( trx_id = mtr_read_dulint(undo_header + TRX_UNDO_TRX_ID, mtr); xid_exists = mtr_read_ulint(undo_header + TRX_UNDO_XID_EXISTS, - MLOG_1BYTE, mtr); + MLOG_1BYTE, mtr); /* Read X/Open XA transaction identification if it exists, or set it to NULL. */ @@ -1255,12 +1258,11 @@ trx_undo_mem_create_at_db_start( mutex_enter(&(rseg->mutex)); undo = trx_undo_mem_create(rseg, id, type, trx_id, &xid, - page_no, offset); + page_no, offset); mutex_exit(&(rseg->mutex)); - undo->dict_operation = mtr_read_ulint( - undo_header + TRX_UNDO_DICT_TRANS, - MLOG_1BYTE, mtr); + undo->dict_operation = mtr_read_ulint + (undo_header + TRX_UNDO_DICT_TRANS, MLOG_1BYTE, mtr); undo->table_id = mtr_read_dulint(undo_header + TRX_UNDO_TABLE_ID, mtr); undo->state = state; @@ -1292,19 +1294,19 @@ add_to_list: if (type == TRX_UNDO_INSERT) { if (state != TRX_UNDO_CACHED) { UT_LIST_ADD_LAST(undo_list, rseg->insert_undo_list, - undo); + undo); } else { UT_LIST_ADD_LAST(undo_list, rseg->insert_undo_cached, - undo); + undo); } } else { ut_ad(type == TRX_UNDO_UPDATE); if (state != TRX_UNDO_CACHED) { UT_LIST_ADD_LAST(undo_list, rseg->update_undo_list, - undo); + undo); } else { UT_LIST_ADD_LAST(undo_list, rseg->update_undo_cached, - undo); + undo); } } @@ -1348,10 +1350,10 @@ trx_undo_lists_init( high */ if (page_no != FIL_NULL - && srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN) { + && srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN) { undo = trx_undo_mem_create_at_db_start(rseg, i, - page_no, &mtr); + page_no, &mtr); size += undo->size; mtr_commit(&mtr); @@ -1359,7 +1361,7 @@ trx_undo_lists_init( mtr_start(&mtr); rseg_header = trx_rsegf_get(rseg->space, - rseg->page_no, &mtr); + rseg->page_no, &mtr); } } @@ -1393,7 +1395,7 @@ trx_undo_mem_create( if (id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, - "InnoDB: Error: undo->id is %lu\n", (ulong) id); + "InnoDB: Error: undo->id is %lu\n", (ulong) id); ut_error; } @@ -1468,7 +1470,7 @@ trx_undo_mem_free( { if (undo->id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, - "InnoDB: Error: undo->id is %lu\n", (ulong) undo->id); + "InnoDB: Error: undo->id is %lu\n", (ulong) undo->id); ut_error; } @@ -1528,11 +1530,11 @@ trx_undo_create( if (trx->support_xa) { trx_undo_header_add_space_for_xid(undo_page, - undo_page + offset, mtr); + undo_page + offset, mtr); } undo = trx_undo_mem_create(rseg, id, type, trx_id, xid, - page_no, offset); + page_no, offset); return(undo); } @@ -1599,19 +1601,19 @@ trx_undo_reuse_cached( offset = trx_undo_insert_header_reuse(undo_page, trx_id, mtr); if (trx->support_xa) { - trx_undo_header_add_space_for_xid(undo_page, - undo_page + offset, mtr); + trx_undo_header_add_space_for_xid + (undo_page, undo_page + offset, mtr); } } else { ut_a(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_TYPE) - == TRX_UNDO_UPDATE); + + TRX_UNDO_PAGE_TYPE) + == TRX_UNDO_UPDATE); offset = trx_undo_header_create(undo_page, trx_id, mtr); if (trx->support_xa) { - trx_undo_header_add_space_for_xid(undo_page, - undo_page + offset, mtr); + trx_undo_header_add_space_for_xid + (undo_page, undo_page + offset, mtr); } } @@ -1637,12 +1639,12 @@ trx_undo_mark_as_dict_operation( hdr_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); - mlog_write_ulint(hdr_page + undo->hdr_offset + - TRX_UNDO_DICT_TRANS, - trx->dict_operation, MLOG_1BYTE, mtr); + mlog_write_ulint(hdr_page + undo->hdr_offset + + TRX_UNDO_DICT_TRANS, + trx->dict_operation, MLOG_1BYTE, mtr); mlog_write_dulint(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID, - trx->table_id, mtr); + trx->table_id, mtr); undo->dict_operation = trx->dict_operation; undo->table_id = trx->table_id; @@ -1681,10 +1683,10 @@ trx_undo_assign_undo( mutex_enter(&(rseg->mutex)); undo = trx_undo_reuse_cached(trx, rseg, type, trx->id, &trx->xid, - &mtr); + &mtr); if (undo == NULL) { undo = trx_undo_create(trx, rseg, type, trx->id, &trx->xid, - &mtr); + &mtr); if (undo == NULL) { /* Did not succeed */ @@ -1747,7 +1749,7 @@ trx_undo_set_state_at_finish( page_hdr = undo_page + TRX_UNDO_PAGE_HDR; if (undo->size == 1 && mach_read_from_2(page_hdr + TRX_UNDO_PAGE_FREE) - < TRX_UNDO_PAGE_REUSE_LIMIT) { + < TRX_UNDO_PAGE_REUSE_LIMIT) { state = TRX_UNDO_CACHED; } else if (undo->type == TRX_UNDO_INSERT) { @@ -1808,7 +1810,7 @@ trx_undo_set_state_at_prepare( undo_header = undo_page + offset; mlog_write_ulint(undo_header + TRX_UNDO_XID_EXISTS, - TRUE, MLOG_1BYTE, mtr); + TRUE, MLOG_1BYTE, mtr); trx_undo_write_xid(undo_header, &undo->xid, mtr); diff --git a/storage/innobase/ut/ut0byte.c b/storage/innobase/ut/ut0byte.c index 18f57181827..b5467fde601 100644 --- a/storage/innobase/ut/ut0byte.c +++ b/storage/innobase/ut/ut0byte.c @@ -27,5 +27,5 @@ ut_dulint_sort(dulint* arr, dulint* aux_arr, ulint low, ulint high) /*===============================================================*/ { UT_SORT_FUNCTION_BODY(ut_dulint_sort, arr, aux_arr, low, high, - ut_dulint_cmp); + ut_dulint_cmp); } diff --git a/storage/innobase/ut/ut0dbg.c b/storage/innobase/ut/ut0dbg.c index 87960b98556..8c4be190d77 100644 --- a/storage/innobase/ut/ut0dbg.c +++ b/storage/innobase/ut/ut0dbg.c @@ -50,14 +50,16 @@ ut_dbg_assertion_failed( "InnoDB: Failing assertion: %s\n", expr); } - fputs( -"InnoDB: We intentionally generate a memory trap.\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com.\n" -"InnoDB: If you get repeated assertion failures or crashes, even\n" -"InnoDB: immediately after the mysqld startup, there may be\n" -"InnoDB: corruption in the InnoDB tablespace. Please refer to\n" -"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html\n" -"InnoDB: about forcing recovery.\n", stderr); + fputs("InnoDB: We intentionally generate a memory trap.\n" + "InnoDB: Submit a detailed bug report" + " to http://bugs.mysql.com.\n" + "InnoDB: If you get repeated assertion failures" + " or crashes, even\n" + "InnoDB: immediately after the mysqld startup, there may be\n" + "InnoDB: corruption in the InnoDB tablespace. Please refer to\n" + "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" + "forcing-recovery.html\n" + "InnoDB: about forcing recovery.\n", stderr); #if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT) ut_dbg_stop_threads = TRUE; #endif diff --git a/storage/innobase/ut/ut0mem.c b/storage/innobase/ut/ut0mem.c index 4358edba8c0..4fd515c35e6 100644 --- a/storage/innobase/ut/ut0mem.c +++ b/storage/innobase/ut/ut0mem.c @@ -86,23 +86,31 @@ retry: ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Error: cannot allocate %lu bytes of\n" - "InnoDB: memory with malloc! Total allocated memory\n" - "InnoDB: by InnoDB %lu bytes. Operating system errno: %lu\n" - "InnoDB: Check if you should increase the swap file or\n" - "InnoDB: ulimits of your operating system.\n" - "InnoDB: On FreeBSD check you have compiled the OS with\n" - "InnoDB: a big enough maximum process size.\n" - "InnoDB: Note that in most 32-bit computers the process\n" - "InnoDB: memory space is limited to 2 GB or 4 GB.\n" - "InnoDB: We keep retrying the allocation for 60 seconds...\n", - (ulong) n, (ulong) ut_total_allocated_memory, + " InnoDB: Error: cannot allocate" + " %lu bytes of\n" + "InnoDB: memory with malloc!" + " Total allocated memory\n" + "InnoDB: by InnoDB %lu bytes." + " Operating system errno: %lu\n" + "InnoDB: Check if you should" + " increase the swap file or\n" + "InnoDB: ulimits of your operating system.\n" + "InnoDB: On FreeBSD check you" + " have compiled the OS with\n" + "InnoDB: a big enough maximum process size.\n" + "InnoDB: Note that in most 32-bit" + " computers the process\n" + "InnoDB: memory space is limited" + " to 2 GB or 4 GB.\n" + "InnoDB: We keep retrying" + " the allocation for 60 seconds...\n", + (ulong) n, (ulong) ut_total_allocated_memory, #ifdef __WIN__ - (ulong) GetLastError() + (ulong) GetLastError() #else - (ulong) errno + (ulong) errno #endif - ); + ); } os_fast_mutex_unlock(&ut_list_mutex); @@ -135,8 +143,9 @@ retry: ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: We now intentionally generate a seg fault so that\n" - "InnoDB: on Linux we get a stack trace.\n"); + " InnoDB: We now intentionally" + " generate a seg fault so that\n" + "InnoDB: on Linux we get a stack trace.\n"); if (*ut_mem_null_ptr) ut_mem_null_ptr = 0; } else { @@ -159,7 +168,7 @@ retry: ut_total_allocated_memory += n + sizeof(ut_mem_block_t); UT_LIST_ADD_FIRST(mem_block_list, ut_mem_block_list, - ((ut_mem_block_t*)ret)); + ((ut_mem_block_t*)ret)); os_fast_mutex_unlock(&ut_list_mutex); return((void*)((byte*)ret + sizeof(ut_mem_block_t))); @@ -196,16 +205,20 @@ ut_test_malloc( if (ret == NULL) { ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Error: cannot allocate %lu bytes of memory for\n" - "InnoDB: a BLOB with malloc! Total allocated memory\n" - "InnoDB: by InnoDB %lu bytes. Operating system errno: %d\n" - "InnoDB: Check if you should increase the swap file or\n" - "InnoDB: ulimits of your operating system.\n" - "InnoDB: On FreeBSD check you have compiled the OS with\n" - "InnoDB: a big enough maximum process size.\n", - (ulong) n, - (ulong) ut_total_allocated_memory, - (int) errno); + " InnoDB: Error: cannot allocate" + " %lu bytes of memory for\n" + "InnoDB: a BLOB with malloc! Total allocated memory\n" + "InnoDB: by InnoDB %lu bytes." + " Operating system errno: %d\n" + "InnoDB: Check if you should increase" + " the swap file or\n" + "InnoDB: ulimits of your operating system.\n" + "InnoDB: On FreeBSD check you have" + " compiled the OS with\n" + "InnoDB: a big enough maximum process size.\n", + (ulong) n, + (ulong) ut_total_allocated_memory, + (int) errno); return(FALSE); } @@ -338,8 +351,9 @@ ut_free_all_mem(void) if (ut_total_allocated_memory != 0) { fprintf(stderr, -"InnoDB: Warning: after shutdown total allocated memory is %lu\n", - (ulong) ut_total_allocated_memory); + "InnoDB: Warning: after shutdown" + " total allocated memory is %lu\n", + (ulong) ut_total_allocated_memory); } } @@ -453,7 +467,7 @@ ut_strcount( ulint len = strlen(s2); if (len == 0) { - + return(0); } @@ -461,7 +475,7 @@ ut_strcount( s1 = strstr(s1, s2); if (!s1) { - + break; } @@ -495,19 +509,19 @@ ut_strreplace( int len_delta = (int)s2_len - (int)s1_len; str_end = str + str_len; - + if (len_delta <= 0) { - len_delta = 0; + len_delta = 0; } else { count = ut_strcount(str, s1); } - + new_str = mem_alloc(str_len + count * len_delta + 1); ptr = new_str; - + while (str) { const char* next = strstr(str, s1); - + if (!next) { next = str_end; } @@ -516,17 +530,17 @@ ut_strreplace( ptr += next - str; if (next == str_end) { - + break; } memcpy(ptr, s2, s2_len); ptr += s2_len; - + str = next + s1_len; } *ptr = '\0'; - + return(new_str); } diff --git a/storage/innobase/ut/ut0ut.c b/storage/innobase/ut/ut0ut.c index 703e75872f6..10641b88a17 100644 --- a/storage/innobase/ut/ut0ut.c +++ b/storage/innobase/ut/ut0ut.c @@ -125,12 +125,12 @@ ut_print_timestamp( GetLocalTime(&cal_tm); fprintf(file,"%02d%02d%02d %2d:%02d:%02d", - (int)cal_tm.wYear % 100, - (int)cal_tm.wMonth, - (int)cal_tm.wDay, - (int)cal_tm.wHour, - (int)cal_tm.wMinute, - (int)cal_tm.wSecond); + (int)cal_tm.wYear % 100, + (int)cal_tm.wMonth, + (int)cal_tm.wDay, + (int)cal_tm.wHour, + (int)cal_tm.wMinute, + (int)cal_tm.wSecond); #else struct tm cal_tm; struct tm* cal_tm_ptr; @@ -145,12 +145,12 @@ ut_print_timestamp( cal_tm_ptr = localtime(&tm); #endif fprintf(file,"%02d%02d%02d %2d:%02d:%02d", - cal_tm_ptr->tm_year % 100, - cal_tm_ptr->tm_mon + 1, - cal_tm_ptr->tm_mday, - cal_tm_ptr->tm_hour, - cal_tm_ptr->tm_min, - cal_tm_ptr->tm_sec); + cal_tm_ptr->tm_year % 100, + cal_tm_ptr->tm_mon + 1, + cal_tm_ptr->tm_mday, + cal_tm_ptr->tm_hour, + cal_tm_ptr->tm_min, + cal_tm_ptr->tm_sec); #endif } @@ -168,12 +168,12 @@ ut_sprintf_timestamp( GetLocalTime(&cal_tm); sprintf(buf, "%02d%02d%02d %2d:%02d:%02d", - (int)cal_tm.wYear % 100, - (int)cal_tm.wMonth, - (int)cal_tm.wDay, - (int)cal_tm.wHour, - (int)cal_tm.wMinute, - (int)cal_tm.wSecond); + (int)cal_tm.wYear % 100, + (int)cal_tm.wMonth, + (int)cal_tm.wDay, + (int)cal_tm.wHour, + (int)cal_tm.wMinute, + (int)cal_tm.wSecond); #else struct tm cal_tm; struct tm* cal_tm_ptr; @@ -188,12 +188,12 @@ ut_sprintf_timestamp( cal_tm_ptr = localtime(&tm); #endif sprintf(buf, "%02d%02d%02d %2d:%02d:%02d", - cal_tm_ptr->tm_year % 100, - cal_tm_ptr->tm_mon + 1, - cal_tm_ptr->tm_mday, - cal_tm_ptr->tm_hour, - cal_tm_ptr->tm_min, - cal_tm_ptr->tm_sec); + cal_tm_ptr->tm_year % 100, + cal_tm_ptr->tm_mon + 1, + cal_tm_ptr->tm_mday, + cal_tm_ptr->tm_hour, + cal_tm_ptr->tm_min, + cal_tm_ptr->tm_sec); #endif } @@ -212,12 +212,12 @@ ut_sprintf_timestamp_without_extra_chars( GetLocalTime(&cal_tm); sprintf(buf, "%02d%02d%02d_%2d_%02d_%02d", - (int)cal_tm.wYear % 100, - (int)cal_tm.wMonth, - (int)cal_tm.wDay, - (int)cal_tm.wHour, - (int)cal_tm.wMinute, - (int)cal_tm.wSecond); + (int)cal_tm.wYear % 100, + (int)cal_tm.wMonth, + (int)cal_tm.wDay, + (int)cal_tm.wHour, + (int)cal_tm.wMinute, + (int)cal_tm.wSecond); #else struct tm cal_tm; struct tm* cal_tm_ptr; @@ -232,12 +232,12 @@ ut_sprintf_timestamp_without_extra_chars( cal_tm_ptr = localtime(&tm); #endif sprintf(buf, "%02d%02d%02d_%2d_%02d_%02d", - cal_tm_ptr->tm_year % 100, - cal_tm_ptr->tm_mon + 1, - cal_tm_ptr->tm_mday, - cal_tm_ptr->tm_hour, - cal_tm_ptr->tm_min, - cal_tm_ptr->tm_sec); + cal_tm_ptr->tm_year % 100, + cal_tm_ptr->tm_mon + 1, + cal_tm_ptr->tm_mday, + cal_tm_ptr->tm_hour, + cal_tm_ptr->tm_min, + cal_tm_ptr->tm_sec); #endif } @@ -342,7 +342,7 @@ ut_ulint_sort(ulint* arr, ulint* aux_arr, ulint low, ulint high) /*============================================================*/ { UT_SORT_FUNCTION_BODY(ut_ulint_sort, arr, aux_arr, low, high, - ut_ulint_cmp); + ut_ulint_cmp); } /***************************************************************** @@ -433,7 +433,7 @@ ut_print_namel( innobase_print_identifier(f, trx, TRUE, name, slash - name); putc('.', f); innobase_print_identifier(f, trx, TRUE, slash + 1, - namelen - (slash - name) - 1); + namelen - (slash - name) - 1); } else { innobase_print_identifier(f, trx, table_id, name, namelen); } @@ -454,8 +454,9 @@ ut_copy_file( rewind(src); do { - size_t maxs = - len < (long) sizeof buf ? (size_t) len : sizeof buf; + size_t maxs = len < (long) sizeof buf + ? (size_t) len + : sizeof buf; size_t size = fread(buf, 1, maxs, src); fwrite(buf, 1, size, dest); len -= (long) size; diff --git a/storage/innobase/ut/ut0vec.c b/storage/innobase/ut/ut0vec.c index 3f61c8c8386..e0d3e84d4a2 100644 --- a/storage/innobase/ut/ut0vec.c +++ b/storage/innobase/ut/ut0vec.c @@ -42,7 +42,7 @@ ib_vector_push( ulint new_total = vec->total * 2; new_data = mem_heap_alloc(vec->heap, - sizeof(void*) * new_total); + sizeof(void*) * new_total); memcpy(new_data, vec->data, sizeof(void*) * vec->total); vec->data = new_data; diff --git a/storage/innobase/ut/ut0wqueue.c b/storage/innobase/ut/ut0wqueue.c index 2a6d8c19ef0..7e090e89a4f 100644 --- a/storage/innobase/ut/ut0wqueue.c +++ b/storage/innobase/ut/ut0wqueue.c @@ -76,7 +76,7 @@ ib_wqueue_wait( if (!ib_list_get_first(wq->items)) { /* We must reset the event when the list - gets emptied. */ + gets emptied. */ os_event_reset(wq->event); } From 8e2ca1564a320466d93d8f8d513512a4e5c967b9 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Tue, 5 Sep 2006 10:01:52 -0400 Subject: [PATCH 086/119] Removed duplicate code from bad merge. --- sql/ha_innodb.cc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index a75fae4caf0..f2e51d7a06b 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -7631,19 +7631,6 @@ SHOW_VAR innodb_status_variables_export[]= { {NullS, NullS, SHOW_LONG} }; -static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff) -{ - innodb_export_status(); - var->type= SHOW_ARRAY; - var->value= (char *) &innodb_status_variables; - return 0; -} - -SHOW_VAR innodb_status_variables_export[]= { - {"Innodb", (char*) &show_innodb_vars, SHOW_FUNC}, - {NullS, NullS, SHOW_LONG} -}; - struct st_mysql_storage_engine innobase_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION, &innobase_hton}; From 6752861d1bf9f0adaba1f73382666ab26c274217 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Tue, 5 Sep 2006 17:07:00 +0200 Subject: [PATCH 087/119] Bug #21056 ndb pushdown equal/setValue error on datetime: only pushdown like of string type fields --- mysql-test/r/ndb_condition_pushdown.result | 22 +++++++++++++++++ mysql-test/t/ndb_condition_pushdown.test | 10 ++++++++ sql/ha_ndbcluster.cc | 5 ++++ sql/ha_ndbcluster.h | 28 ++++++++++++++++++++-- 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ndb_condition_pushdown.result b/mysql-test/r/ndb_condition_pushdown.result index 4e5597a4851..96881bd321b 100644 --- a/mysql-test/r/ndb_condition_pushdown.result +++ b/mysql-test/r/ndb_condition_pushdown.result @@ -1782,6 +1782,28 @@ select * from t5 where b like '%jo%' order by a; a b 1 jonas 3 johan +set engine_condition_pushdown = off; +select auto from t1 where date_time like '1902-02-02 %'; +auto +2 +select auto from t1 where date_time not like '1902-02-02 %'; +auto +3 +4 +set engine_condition_pushdown = on; +explain select auto from t1 where date_time like '1902-02-02 %'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where +select auto from t1 where date_time like '1902-02-02 %'; +auto +2 +explain select auto from t1 where date_time not like '1902-02-02 %'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where +select auto from t1 where date_time not like '1902-02-02 %'; +auto +3 +4 drop table t1; create table t1 (a int, b varchar(3), primary key using hash(a)) engine=ndb; diff --git a/mysql-test/t/ndb_condition_pushdown.test b/mysql-test/t/ndb_condition_pushdown.test index cc138b32b7e..765c5d06bab 100644 --- a/mysql-test/t/ndb_condition_pushdown.test +++ b/mysql-test/t/ndb_condition_pushdown.test @@ -1649,6 +1649,16 @@ set engine_condition_pushdown = on; explain select * from t5 where b like '%jo%'; select * from t5 where b like '%jo%' order by a; +# bug#21056 ndb pushdown equal/setValue error on datetime +set engine_condition_pushdown = off; +select auto from t1 where date_time like '1902-02-02 %'; +select auto from t1 where date_time not like '1902-02-02 %'; +set engine_condition_pushdown = on; +explain select auto from t1 where date_time like '1902-02-02 %'; +select auto from t1 where date_time like '1902-02-02 %'; +explain select auto from t1 where date_time not like '1902-02-02 %'; +select auto from t1 where date_time not like '1902-02-02 %'; + # bug#17421 -1 drop table t1; create table t1 (a int, b varchar(3), primary key using hash(a)) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 5d6fe5f984f..440adec4841 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6880,11 +6880,13 @@ void ndb_serialize_cond(const Item *item, void *arg) DBUG_PRINT("info", ("FIELD_ITEM")); DBUG_PRINT("info", ("table %s", tab->getName())); DBUG_PRINT("info", ("column %s", field->field_name)); + DBUG_PRINT("info", ("type %d", field->type())); DBUG_PRINT("info", ("result type %d", field->result_type())); // Check that we are expecting a field and with the correct // result type if (context->expecting(Item::FIELD_ITEM) && + context->expecting_field_type(field->type()) && (context->expecting_field_result(field->result_type()) || // Date and year can be written as string or int ((type == MYSQL_TYPE_TIME || @@ -7104,6 +7106,9 @@ void ndb_serialize_cond(const Item *item, void *arg) func_item); context->expect(Item::STRING_ITEM); context->expect(Item::FIELD_ITEM); + context->expect_only_field_type(MYSQL_TYPE_STRING); + context->expect_field_type(MYSQL_TYPE_VAR_STRING); + context->expect_field_type(MYSQL_TYPE_VARCHAR); context->expect_field_result(STRING_RESULT); context->expect(Item::FUNC_ITEM); break; diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index cfb12981b98..1e08e04198c 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -362,8 +362,8 @@ class Ndb_cond_traverse_context Ndb_cond_traverse_context(TABLE *tab, void* ndb_tab, Ndb_cond_stack* stack) : table(tab), ndb_table(ndb_tab), supported(TRUE), stack_ptr(stack), cond_ptr(NULL), - expect_mask(0), expect_field_result_mask(0), skip(0), collation(NULL), - rewrite_stack(NULL) + expect_mask(0), expect_field_type_mask(0), expect_field_result_mask(0), + skip(0), collation(NULL), rewrite_stack(NULL) { if (stack) cond_ptr= stack->ndb_cond; @@ -375,6 +375,7 @@ class Ndb_cond_traverse_context void expect(Item::Type type) { expect_mask|= (1 << type); + if (type == Item::FIELD_ITEM) expect_all_field_types(); }; void dont_expect(Item::Type type) { @@ -394,6 +395,28 @@ class Ndb_cond_traverse_context expect(type); }; + void expect_field_type(enum_field_types result) + { + expect_field_type_mask|= (1 << result); + }; + void expect_all_field_types() + { + expect_field_type_mask= ~0; + }; + bool expecting_field_type(enum_field_types result) + { + return (expect_field_type_mask & (1 << result)); + }; + void expect_no_field_type() + { + expect_field_type_mask= 0; + }; + void expect_only_field_type(enum_field_types result) + { + expect_field_type_mask= 0; + expect_field_type(result); + }; + void expect_field_result(Item_result result) { expect_field_result_mask|= (1 << result); @@ -429,6 +452,7 @@ class Ndb_cond_traverse_context Ndb_cond_stack* stack_ptr; Ndb_cond* cond_ptr; uint expect_mask; + uint expect_field_type_mask; uint expect_field_result_mask; uint skip; CHARSET_INFO* collation; From 298917eb5bf62cf8d8537bf6e61382fbc6d6db52 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Tue, 5 Sep 2006 16:28:31 -0400 Subject: [PATCH 088/119] Fix bad manual merge. --- mysql-test/r/grant.result | 313 -------------------------------------- sql/mysqld.cc | 4 - 2 files changed, 317 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index ee6a96b64a5..5dbbfbd9ab8 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -910,319 +910,6 @@ SHOW CREATE TABLE mysqltest3.v_nn; ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v_nn' SHOW CREATE TABLE mysqltest2.t_nn; Table Create Table -t_nn CREATE TABLE `t_nn` ( - `c1` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -SHOW CREATE VIEW mysqltest2.t_nn; -ERROR HY000: 'mysqltest2.t_nn' is not VIEW -SHOW CREATE VIEW mysqltest2.v_yy; -View Create View -v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55) -SHOW CREATE TABLE mysqltest2.v_yy; -View Create View -v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55) -SHOW CREATE TABLE mysqltest2.v_nn; -View Create View -v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn` -SHOW CREATE VIEW mysqltest2.v_nn; -View Create View -v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn` -SHOW CREATE TABLE mysqltest2.t_nn; -Table Create Table -t_nn CREATE TABLE `t_nn` ( - `c1` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -SHOW CREATE VIEW mysqltest2.t_nn; -ERROR HY000: 'mysqltest2.t_nn' is not VIEW -DROP VIEW mysqltest2.v_nn; -DROP VIEW mysqltest2.v_yn; -DROP VIEW mysqltest2.v_ny; -DROP VIEW mysqltest2.v_yy; -DROP TABLE mysqltest2.t_nn; -DROP DATABASE mysqltest2; -DROP VIEW mysqltest3.v_nn; -DROP TABLE mysqltest3.t_nn; -DROP DATABASE mysqltest3; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost'; -DROP USER 'mysqltest_1'@'localhost'; -use test; -create user mysqltest1_thisisreallytoolong; -ERROR HY000: String 'mysqltest1_thisisreallytoolong' is too long for user name (should be no longer than 16) -GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost; -ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) -GRANT CREATE ON mysqltest.* TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; -ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) -REVOKE CREATE ON mysqltest.* FROM 1234567890abcdefGHIKL@localhost; -ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) -REVOKE CREATE ON mysqltest.* FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; -ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) -GRANT CREATE ON t1 TO 1234567890abcdefGHIKL@localhost; -ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) -GRANT CREATE ON t1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; -ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) -REVOKE CREATE ON t1 FROM 1234567890abcdefGHIKL@localhost; -ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) -REVOKE CREATE ON t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; -ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) -GRANT EXECUTE ON PROCEDURE p1 TO 1234567890abcdefGHIKL@localhost; -ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) -GRANT EXECUTE ON PROCEDURE p1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; -ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) -REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost; -ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) -REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; -ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) -use test; -create table t1 (a int); -create table t2 as select * from mysql.user where user=''; -delete from mysql.user where user=''; -flush privileges; -create user mysqltest_8@''; -create user mysqltest_8; -create user mysqltest_8@host8; -create user mysqltest_8@''; -ERROR HY000: Operation CREATE USER failed for 'mysqltest_8'@'' -create user mysqltest_8; -ERROR HY000: Operation CREATE USER failed for 'mysqltest_8'@'%' -create user mysqltest_8@host8; -ERROR HY000: Operation CREATE USER failed for 'mysqltest_8'@'host8' -select user, QUOTE(host) from mysql.user where user="mysqltest_8"; -user QUOTE(host) -mysqltest_8 '' -mysqltest_8 '%' -mysqltest_8 'host8' -Schema privileges -grant select on mysqltest.* to mysqltest_8@''; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -GRANT SELECT ON `mysqltest`.* TO 'mysqltest_8'@'' -grant select on mysqltest.* to mysqltest_8@; -show grants for mysqltest_8@; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -GRANT SELECT ON `mysqltest`.* TO 'mysqltest_8'@'' -grant select on mysqltest.* to mysqltest_8; -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -GRANT SELECT ON `mysqltest`.* TO 'mysqltest_8'@'%' -select * from information_schema.schema_privileges -where grantee like "'mysqltest_8'%"; -GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE -'mysqltest_8'@'%' NULL mysqltest SELECT NO -'mysqltest_8'@'' NULL mysqltest SELECT NO -select * from t1; -a -revoke select on mysqltest.* from mysqltest_8@''; -revoke select on mysqltest.* from mysqltest_8; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -select * from information_schema.schema_privileges -where grantee like "'mysqltest_8'%"; -GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE -flush privileges; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -show grants for mysqltest_8@; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -grant select on mysqltest.* to mysqltest_8@''; -flush privileges; -show grants for mysqltest_8@; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -GRANT SELECT ON `mysqltest`.* TO 'mysqltest_8'@'' -revoke select on mysqltest.* from mysqltest_8@''; -flush privileges; -Column privileges -grant update (a) on t1 to mysqltest_8@''; -grant update (a) on t1 to mysqltest_8; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'%' -flush privileges; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'%' -select * from information_schema.column_privileges; -GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE -'mysqltest_8'@'%' NULL test t1 a UPDATE NO -'mysqltest_8'@'' NULL test t1 a UPDATE NO -select * from t1; -a -revoke update (a) on t1 from mysqltest_8@''; -revoke update (a) on t1 from mysqltest_8; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -select * from information_schema.column_privileges; -GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE -flush privileges; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -Table privileges -grant update on t1 to mysqltest_8@''; -grant update on t1 to mysqltest_8; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'%' -flush privileges; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'%' -select * from information_schema.table_privileges; -GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE -'mysqltest_8'@'%' NULL test t1 UPDATE NO -'mysqltest_8'@'' NULL test t1 UPDATE NO -select * from t1; -a -revoke update on t1 from mysqltest_8@''; -revoke update on t1 from mysqltest_8; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -select * from information_schema.table_privileges; -GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE -flush privileges; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -"DROP USER" should clear privileges -grant all privileges on mysqltest.* to mysqltest_8@''; -grant select on mysqltest.* to mysqltest_8@''; -grant update on t1 to mysqltest_8@''; -grant update (a) on t1 to mysqltest_8@''; -grant all privileges on mysqltest.* to mysqltest_8; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'' -GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%' -select * from information_schema.user_privileges -where grantee like "'mysqltest_8'%"; -GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE -'mysqltest_8'@'host8' NULL USAGE NO -'mysqltest_8'@'%' NULL USAGE NO -'mysqltest_8'@'' NULL USAGE NO -select * from t1; -a -flush privileges; -show grants for mysqltest_8@''; -Grants for mysqltest_8@ -GRANT USAGE ON *.* TO 'mysqltest_8'@'' -GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'' -GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%' -drop user mysqltest_8@''; -show grants for mysqltest_8@''; -ERROR 42000: There is no such grant defined for user 'mysqltest_8' on host '' -show grants for mysqltest_8; -Grants for mysqltest_8@% -GRANT USAGE ON *.* TO 'mysqltest_8'@'%' -GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%' -select * from information_schema.user_privileges -where grantee like "'mysqltest_8'%"; -GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE -'mysqltest_8'@'host8' NULL USAGE NO -'mysqltest_8'@'%' NULL USAGE NO -drop user mysqltest_8; -connect(localhost,mysqltest_8,,test,MASTER_PORT,MASTER_SOCKET); -ERROR 28000: Access denied for user 'mysqltest_8'@'localhost' (using password: NO) -show grants for mysqltest_8; -ERROR 42000: There is no such grant defined for user 'mysqltest_8' on host '%' -drop user mysqltest_8@host8; -show grants for mysqltest_8@host8; -ERROR 42000: There is no such grant defined for user 'mysqltest_8' on host 'host8' -insert into mysql.user select * from t2; -flush privileges; -drop table t2; -drop table t1; -CREATE DATABASE mysqltest3; -use mysqltest3; -CREATE TABLE t_nn (c1 INT); -CREATE VIEW v_nn AS SELECT * FROM t_nn; -CREATE DATABASE mysqltest2; -use mysqltest2; -CREATE TABLE t_nn (c1 INT); -CREATE VIEW v_nn AS SELECT * FROM t_nn; -CREATE VIEW v_yn AS SELECT * FROM t_nn; -CREATE VIEW v_gy AS SELECT * FROM t_nn; -CREATE VIEW v_ny AS SELECT * FROM t_nn; -CREATE VIEW v_yy AS SELECT * FROM t_nn WHERE c1=55; -GRANT SHOW VIEW ON mysqltest2.v_ny TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1'; -GRANT SELECT ON mysqltest2.v_yn TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1'; -GRANT SELECT ON mysqltest2.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1'; -GRANT SHOW VIEW,SELECT ON mysqltest2.v_yy TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1'; -SHOW CREATE VIEW mysqltest2.v_nn; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_nn' -SHOW CREATE TABLE mysqltest2.v_nn; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_nn' -SHOW CREATE VIEW mysqltest2.v_yn; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_yn' -SHOW CREATE TABLE mysqltest2.v_yn; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_yn' -SHOW CREATE TABLE mysqltest2.v_ny; -View Create View -v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` -SHOW CREATE VIEW mysqltest2.v_ny; -View Create View -v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` -SHOW CREATE TABLE mysqltest3.t_nn; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't_nn' -SHOW CREATE VIEW mysqltest3.t_nn; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't_nn' -SHOW CREATE VIEW mysqltest3.v_nn; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v_nn' -SHOW CREATE TABLE mysqltest3.v_nn; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v_nn' -SHOW CREATE TABLE mysqltest2.t_nn; -Table Create Table t_nn CREATE TABLE `t_nn` ( `c1` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 447000770bf..5b2a07ab5e0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -326,8 +326,6 @@ static char *my_bind_addr_str; static char *default_collation_name; static char *default_storage_engine_str; static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME; -static char mysql_data_home_buff[2]; -static struct passwd *user_info; static I_List thread_cache; static pthread_cond_t COND_thread_cache, COND_flush_thread_cache; @@ -508,10 +506,8 @@ key_map key_map_full(0); // Will be initialized later const char *opt_date_time_formats[3]; -char *language_ptr, *default_collation_name, *default_character_set_name; char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home; struct passwd *user_info; -char *mysql_data_home= mysql_real_data_home; char server_version[SERVER_VERSION_LENGTH]; char *mysqld_unix_port, *opt_mysql_tmpdir; const char **errmesg; /* Error messages */ From 29acac81cf6361367d7a494821d7c6cc9d28cde1 Mon Sep 17 00:00:00 2001 From: "serg@janus.mylan" <> Date: Tue, 5 Sep 2006 23:59:16 +0200 Subject: [PATCH 089/119] plugin_foreach - don't hold the lock when calling the function --- sql/sql_plugin.cc | 58 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 9db7c743a40..8ed16d8af58 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -63,6 +63,8 @@ static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM]; static rw_lock_t THR_LOCK_plugin; static bool initialized= 0; +static int plugin_array_version=0; + /* prototypes */ my_bool plugin_register_builtin(struct st_mysql_plugin *plugin); void plugin_load(void); @@ -448,6 +450,7 @@ static my_bool plugin_add(const LEX_STRING *name, const LEX_STRING *dl, int repo tmp.state= PLUGIN_IS_UNINITIALIZED; if (! (tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) goto err; + plugin_array_version++; if (my_hash_insert(&plugin_hash[plugin->type], (byte*)tmp_plugin_ptr)) { tmp_plugin_ptr->state= PLUGIN_IS_FREED; @@ -504,6 +507,7 @@ static void plugin_del(const LEX_STRING *name) hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin); plugin_dl_del(&plugin->plugin_dl->dl); plugin->state= PLUGIN_IS_FREED; + plugin_array_version++; } DBUG_VOID_RETURN; } @@ -639,7 +643,7 @@ static byte *get_hash_key(const byte *buff, uint *length, */ int plugin_init(int skip_dynamic_loading) { - int i; + uint i; struct st_mysql_plugin **builtins; struct st_mysql_plugin *plugin; DBUG_ENTER("plugin_init"); @@ -939,43 +943,61 @@ err: DBUG_RETURN(TRUE); } - my_bool plugin_foreach(THD *thd, plugin_foreach_func *func, int type, void *arg) { - uint idx; - struct st_plugin_int *plugin; + uint idx, total; + struct st_plugin_int *plugin, **plugins; + int version=plugin_array_version; DBUG_ENTER("plugin_foreach"); - rw_rdlock(&THR_LOCK_plugin); + rw_rdlock(&THR_LOCK_plugin); if (type == MYSQL_ANY_PLUGIN) { - for (idx= 0; idx < plugin_array.elements; idx++) + total=plugin_array.elements; + plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins)); + for (idx= 0; idx < total; idx++) { plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *); - - /* FREED records may have garbage pointers */ - if ((plugin->state != PLUGIN_IS_FREED) && - func(thd, plugin, arg)) - goto err; + if (plugin->state == PLUGIN_IS_FREED) + continue; + plugins[idx]= plugin; } } else { HASH *hash= &plugin_hash[type]; - for (idx= 0; idx < hash->records; idx++) + total=hash->records; + plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins)); + for (idx= 0; idx < total; idx++) { plugin= (struct st_plugin_int *) hash_element(hash, idx); - if ((plugin->state != PLUGIN_IS_FREED) && - (plugin->state != PLUGIN_IS_DELETED) && - func(thd, plugin, arg)) - goto err; + if (plugin->state == PLUGIN_IS_FREED) + continue; + plugins[idx]= plugin; } } - rw_unlock(&THR_LOCK_plugin); + + for (idx= 0; idx < total; idx++) + { + plugin= plugins[idx]; + if (unlikely(version != plugin_array_version)) + { + rw_rdlock(&THR_LOCK_plugin); + for (uint i=idx; i < total; i++) + if (plugins[i]->state == PLUGIN_IS_FREED) + plugins[i]=0; + rw_unlock(&THR_LOCK_plugin); + } + if (plugin && func(thd, plugin, arg)) + goto err; + } + + my_afree(plugins); DBUG_RETURN(FALSE); err: - rw_unlock(&THR_LOCK_plugin); + my_afree(plugins); DBUG_RETURN(TRUE); } + From fa98e9c71808b704dedc360c7412a647c8444097 Mon Sep 17 00:00:00 2001 From: "serg@janus.mylan" <> Date: Wed, 6 Sep 2006 10:22:59 +0200 Subject: [PATCH 090/119] converting plugin states to bitmask to simplify testing. state_mask argument to plugin_foreach() --- sql/sql_plugin.cc | 16 +++++++++------- sql/sql_plugin.h | 25 +++++++++++++++---------- sql/sql_show.cc | 5 +++-- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 8ed16d8af58..b66d2d20925 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -372,7 +372,7 @@ struct st_plugin_int *plugin_lock(const LEX_STRING *name, int type) rw_wrlock(&THR_LOCK_plugin); if ((rc= plugin_find_internal(name, type))) { - if (rc->state == PLUGIN_IS_READY || rc->state == PLUGIN_IS_UNINITIALIZED) + if (rc->state & (PLUGIN_IS_READY | PLUGIN_IS_UNINITIALIZED)) rc->ref_count++; else rc= 0; @@ -943,13 +943,15 @@ err: DBUG_RETURN(TRUE); } -my_bool plugin_foreach(THD *thd, plugin_foreach_func *func, - int type, void *arg) +my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, + int type, uint state_mask, void *arg) { uint idx, total; struct st_plugin_int *plugin, **plugins; int version=plugin_array_version; - DBUG_ENTER("plugin_foreach"); + DBUG_ENTER("plugin_foreach_with_mask"); + + state_mask= ~state_mask; // do it only once rw_rdlock(&THR_LOCK_plugin); if (type == MYSQL_ANY_PLUGIN) @@ -959,7 +961,7 @@ my_bool plugin_foreach(THD *thd, plugin_foreach_func *func, for (idx= 0; idx < total; idx++) { plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *); - if (plugin->state == PLUGIN_IS_FREED) + if (plugin->state & state_mask) continue; plugins[idx]= plugin; } @@ -972,7 +974,7 @@ my_bool plugin_foreach(THD *thd, plugin_foreach_func *func, for (idx= 0; idx < total; idx++) { plugin= (struct st_plugin_int *) hash_element(hash, idx); - if (plugin->state == PLUGIN_IS_FREED) + if (plugin->state & state_mask) continue; plugins[idx]= plugin; } @@ -986,7 +988,7 @@ my_bool plugin_foreach(THD *thd, plugin_foreach_func *func, { rw_rdlock(&THR_LOCK_plugin); for (uint i=idx; i < total; i++) - if (plugins[i]->state == PLUGIN_IS_FREED) + if (plugins[i]->state & state_mask) plugins[i]=0; rw_unlock(&THR_LOCK_plugin); } diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index ed7ba36ac84..fa3440f7f68 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -31,13 +31,17 @@ typedef struct st_mysql_show_var SHOW_VAR; #define MYSQL_ANY_PLUGIN -1 -enum enum_plugin_state -{ - PLUGIN_IS_FREED= 0, - PLUGIN_IS_DELETED, - PLUGIN_IS_UNINITIALIZED, - PLUGIN_IS_READY -}; +/* + different values of st_plugin_int::state + though they look like a bitmap, plugin may only + be in one of those eigenstates, not in a superposition of them :) + It's a bitmap, because it makes it easier to test + "whether the state is one of those..." +*/ +#define PLUGIN_IS_FREED 1 +#define PLUGIN_IS_DELETED 2 +#define PLUGIN_IS_UNINITIALIZED 4 +#define PLUGIN_IS_READY 8 /* A handle for the dynamic library containing a plugin or plugins. */ @@ -57,7 +61,7 @@ struct st_plugin_int LEX_STRING name; struct st_mysql_plugin *plugin; struct st_plugin_dl *plugin_dl; - enum enum_plugin_state state; + uint state; uint ref_count; /* number of threads using the plugin */ void *data; /* plugin type specific, e.g. handlerton */ }; @@ -78,6 +82,7 @@ extern my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name); typedef my_bool (plugin_foreach_func)(THD *thd, st_plugin_int *plugin, void *arg); -extern my_bool plugin_foreach(THD *thd, plugin_foreach_func *func, - int type, void *arg); +#define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D) +extern my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, + int type, uint state_mask, void *arg); #endif diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a8bf2695ac4..3acc025b84f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -220,9 +220,10 @@ int fill_plugins(THD *thd, TABLE_LIST *tables, COND *cond) DBUG_ENTER("fill_plugins"); TABLE *table= tables->table; - if (plugin_foreach(thd, show_plugins, MYSQL_ANY_PLUGIN, table)) + if (plugin_foreach_with_mask(thd, show_plugins, MYSQL_ANY_PLUGIN, + ~PLUGIN_IS_FREED, table)) DBUG_RETURN(1); - + DBUG_RETURN(0); } From 70b19dd1c08420fa6c9ad9839ba3c30c0b5ea77f Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Wed, 6 Sep 2006 11:54:01 +0200 Subject: [PATCH 091/119] Bug #21056 ndb pushdown equal/setValue error on datetime: Added missing order by --- mysql-test/r/ndb_condition_pushdown.result | 8 ++++---- mysql-test/t/ndb_condition_pushdown.test | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/ndb_condition_pushdown.result b/mysql-test/r/ndb_condition_pushdown.result index 96881bd321b..723311e6448 100644 --- a/mysql-test/r/ndb_condition_pushdown.result +++ b/mysql-test/r/ndb_condition_pushdown.result @@ -1783,10 +1783,10 @@ a b 1 jonas 3 johan set engine_condition_pushdown = off; -select auto from t1 where date_time like '1902-02-02 %'; +select auto from t1 where date_time like '1902-02-02 %' order by auto; auto 2 -select auto from t1 where date_time not like '1902-02-02 %'; +select auto from t1 where date_time not like '1902-02-02 %' order by auto; auto 3 4 @@ -1794,13 +1794,13 @@ set engine_condition_pushdown = on; explain select auto from t1 where date_time like '1902-02-02 %'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where -select auto from t1 where date_time like '1902-02-02 %'; +select auto from t1 where date_time like '1902-02-02 %' order by auto; auto 2 explain select auto from t1 where date_time not like '1902-02-02 %'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where -select auto from t1 where date_time not like '1902-02-02 %'; +select auto from t1 where date_time not like '1902-02-02 %' order by auto; auto 3 4 diff --git a/mysql-test/t/ndb_condition_pushdown.test b/mysql-test/t/ndb_condition_pushdown.test index 765c5d06bab..748c26e2a9a 100644 --- a/mysql-test/t/ndb_condition_pushdown.test +++ b/mysql-test/t/ndb_condition_pushdown.test @@ -1651,13 +1651,13 @@ select * from t5 where b like '%jo%' order by a; # bug#21056 ndb pushdown equal/setValue error on datetime set engine_condition_pushdown = off; -select auto from t1 where date_time like '1902-02-02 %'; -select auto from t1 where date_time not like '1902-02-02 %'; +select auto from t1 where date_time like '1902-02-02 %' order by auto; +select auto from t1 where date_time not like '1902-02-02 %' order by auto; set engine_condition_pushdown = on; explain select auto from t1 where date_time like '1902-02-02 %'; -select auto from t1 where date_time like '1902-02-02 %'; +select auto from t1 where date_time like '1902-02-02 %' order by auto; explain select auto from t1 where date_time not like '1902-02-02 %'; -select auto from t1 where date_time not like '1902-02-02 %'; +select auto from t1 where date_time not like '1902-02-02 %' order by auto; # bug#17421 -1 drop table t1; From 04284f8c10b173e9d6871da8e08ef521328d5ab8 Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Wed, 6 Sep 2006 12:50:42 +0200 Subject: [PATCH 092/119] New way to fix BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY UPDATE". This bug report was two problems: 1) LAST_INSERT_ID() returns a value which does not exist in the table 2) the reporter would want it to return the autoinc id of the updated row. 1) is a real bug, 2) is a feature request. In July I implemented 2) in 5.1 (which automatically fixes 1). This has not yet been documented or released, so is changeable. Precisely, recently Paul and a user found an easy workaround to give 2), which works in 4.1-5.0-5.1. So I can revert my code for 2), because it's not needed, that's what I do here; we forget about 2) (we will document the workaround). But when I revert my code for 2), 1) comes back. We solve 1) by saying that if INSERT ON DUPLICATE KEY UPDATE updates a row, it's like a regular UPDATE: LAST_INSERT_ID() should not be affected (instead of returning a non-existent value). So note: no behaviour change compared to the last released 5.1; just a bugfix for 1). --- mysql-test/r/innodb_mysql.result | 30 ++++++++++++++++++++++++++---- mysql-test/t/innodb_mysql.test | 21 ++++++++++++++++++--- sql/sql_insert.cc | 15 +++++++-------- 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index a5b263b759d..98e03239567 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -432,22 +432,44 @@ ifnull( c, 0 ) + 1; select last_insert_id(); last_insert_id() -1 +2 +select last_insert_id(0); +last_insert_id(0) +0 +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +0 select * from t2; k a c -1 6 1 +1 6 2 2 7 NULL insert ignore into t2 values (null,6,1),(10,8,1); select last_insert_id(); last_insert_id() -1 +0 insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); select last_insert_id(); last_insert_id() 11 select * from t2; k a c -1 6 1 +1 6 2 +2 7 NULL +10 8 1 +11 15 1 +12 20 1 +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1, k=last_insert_id(k); +select last_insert_id(); +last_insert_id() +1 +select * from t2; +k a c +1 6 3 2 7 NULL 10 8 1 11 15 1 diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index d61509317ca..73c642cd334 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -369,8 +369,8 @@ insert into t1 values('aaa'); drop table t1; # Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY -# UPDATE": now LAST_INSERT_ID() will return the id of the updated -# row. +# UPDATE": if the row is updated, it's like a regular UPDATE: +# LAST_INSERT_ID() is not affected. CREATE TABLE `t2` ( `k` int(11) NOT NULL auto_increment, `a` int(11) default NULL, @@ -390,6 +390,12 @@ insert into t2 ( a ) values ( 6 ) on duplicate key update c = ifnull( c, 0 ) + 1; select last_insert_id(); +# test again when last_insert_id() is 0 initially +select last_insert_id(0); +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); select * from t2; # Test of LAST_INSERT_ID() when autogenerated will fail: @@ -402,5 +408,14 @@ insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); select last_insert_id(); select * from t2; -drop table t2; +# Test of the workaround which enables people to know the id of the +# updated row in INSERT ON DUPLICATE KEY UPDATE, by using +# LAST_INSERT_ID(autoinc_col) in the UPDATE clause. +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1, k=last_insert_id(k); +select last_insert_id(); +select * from t2; + +drop table t2; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 4ae368cc0e4..623dbe802e7 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1145,16 +1145,15 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) } info->updated++; /* - If ON DUP KEY UPDATE updates a row instead of inserting one, and - there is an auto_increment column, then SELECT LAST_INSERT_ID() - returns the id of the updated row: + If ON DUP KEY UPDATE updates a row instead of inserting one, it's + like a regular UPDATE statement: it should not affect the value of a + next SELECT LAST_INSERT_ID() or mysql_insert_id(). + Except if LAST_INSERT_ID(#) was in the INSERT query, which is + handled separately by THD::arg_of_last_insert_id_function. */ + insert_id_for_cur_row= table->file->insert_id_for_cur_row= 0; if (table->next_number_field) - { - longlong field_val= table->next_number_field->val_int(); - thd->record_first_successful_insert_id_in_cur_stmt(field_val); - table->file->adjust_next_insert_id_after_explicit_value(field_val); - } + table->file->adjust_next_insert_id_after_explicit_value(table->next_number_field->val_int()); trg_error= (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, TRG_ACTION_AFTER, TRUE)); From 21c915a0037a9ad11321995d631880bdfd2ebff5 Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Wed, 6 Sep 2006 15:05:19 +0200 Subject: [PATCH 093/119] mi_test_all.sh needs "./" before the executable names otherwise they are not found --- storage/myisam/mi_test_all.sh | 256 +++++++++++++++++----------------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/storage/myisam/mi_test_all.sh b/storage/myisam/mi_test_all.sh index 07e71d65675..62eaff2dab6 100755 --- a/storage/myisam/mi_test_all.sh +++ b/storage/myisam/mi_test_all.sh @@ -6,142 +6,142 @@ valgrind="valgrind --alignment=8 --leak-check=yes" silent="-s" -if test -f mi_test1$MACH ; then suffix=$MACH else suffix=""; fi -mi_test1$suffix $silent -myisamchk$suffix -se test1 -mi_test1$suffix $silent -N -S -myisamchk$suffix -se test1 -mi_test1$suffix $silent -P --checksum -myisamchk$suffix -se test1 -mi_test1$suffix $silent -P -N -S -myisamchk$suffix -se test1 -mi_test1$suffix $silent -B -N -R2 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -k 480 --unique -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -N -S -R1 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S -N --unique -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S -N --key_length=127 --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S -N --key_length=128 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -B -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -B --key_length=64 --unique -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -B -k 480 --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -B -k 480 -N --unique --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -m -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -m -P --unique --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -m -P --key_length=480 --key_cache -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -m -p -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -w -S --unique -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -w --key_length=64 --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -w -N --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -w -S --key_length=480 --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -b -N -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -b --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -B --key_length=480 -myisamchk$suffix -sm test1 +if test -f mi_test1$MACH ; then suffix=$MACH ; else suffix=""; fi +./mi_test1$suffix $silent +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent -N -S +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent -P --checksum +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent -P -N -S +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent -B -N -R2 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -k 480 --unique +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -N -S -R1 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S -N --unique +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S -N --key_length=127 --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S -N --key_length=128 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -B +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -B --key_length=64 --unique +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -B -k 480 --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -B -k 480 -N --unique --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -m +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -m -P --unique --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -m -P --key_length=480 --key_cache +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -m -p +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -w -S --unique +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -w --key_length=64 --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -w -N --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -w -S --key_length=480 --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -b -N +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -b --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -B --key_length=480 +./myisamchk$suffix -sm test1 -mi_test1$suffix $silent --checksum -myisamchk$suffix -se test1 -myisamchk$suffix -rs test1 -myisamchk$suffix -se test1 -myisamchk$suffix -rqs test1 -myisamchk$suffix -se test1 -myisamchk$suffix -rs --correct-checksum test1 -myisamchk$suffix -se test1 -myisamchk$suffix -rqs --correct-checksum test1 -myisamchk$suffix -se test1 -myisamchk$suffix -ros --correct-checksum test1 -myisamchk$suffix -se test1 -myisamchk$suffix -rqos --correct-checksum test1 -myisamchk$suffix -se test1 +./mi_test1$suffix $silent --checksum +./myisamchk$suffix -se test1 +./myisamchk$suffix -rs test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -rqs test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -rs --correct-checksum test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -rqs --correct-checksum test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -ros --correct-checksum test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -rqos --correct-checksum test1 +./myisamchk$suffix -se test1 # check of myisampack / myisamchk -myisampack$suffix --force -s test1 -myisamchk$suffix -es test1 -myisamchk$suffix -rqs test1 -myisamchk$suffix -es test1 -myisamchk$suffix -rs test1 -myisamchk$suffix -es test1 -myisamchk$suffix -rus test1 -myisamchk$suffix -es test1 +./myisampack$suffix --force -s test1 +./myisamchk$suffix -es test1 +./myisamchk$suffix -rqs test1 +./myisamchk$suffix -es test1 +./myisamchk$suffix -rs test1 +./myisamchk$suffix -es test1 +./myisamchk$suffix -rus test1 +./myisamchk$suffix -es test1 -mi_test1$suffix $silent --checksum -S -myisamchk$suffix -se test1 -myisamchk$suffix -ros test1 -myisamchk$suffix -rqs test1 -myisamchk$suffix -se test1 +./mi_test1$suffix $silent --checksum -S +./myisamchk$suffix -se test1 +./myisamchk$suffix -ros test1 +./myisamchk$suffix -rqs test1 +./myisamchk$suffix -se test1 -myisampack$suffix --force -s test1 -myisamchk$suffix -rqs test1 -myisamchk$suffix -es test1 -myisamchk$suffix -rus test1 -myisamchk$suffix -es test1 +./myisampack$suffix --force -s test1 +./myisamchk$suffix -rqs test1 +./myisamchk$suffix -es test1 +./myisamchk$suffix -rus test1 +./myisamchk$suffix -es test1 -mi_test1$suffix $silent --checksum --unique -myisamchk$suffix -se test1 -mi_test1$suffix $silent --unique -S -myisamchk$suffix -se test1 +./mi_test1$suffix $silent --checksum --unique +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent --unique -S +./myisamchk$suffix -se test1 -mi_test1$suffix $silent --key_multiple -N -S -myisamchk$suffix -sm test1 -mi_test1$suffix $silent --key_multiple -a -p --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent --key_multiple -a -B --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent --key_multiple -P -S -myisamchk$suffix -sm test1 +./mi_test1$suffix $silent --key_multiple -N -S +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent --key_multiple -a -p --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent --key_multiple -a -B --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent --key_multiple -P -S +./myisamchk$suffix -sm test1 -mi_test2$suffix $silent -L -K -W -P -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -W -P -A -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -W -P -S -R1 -m500 +./mi_test2$suffix $silent -L -K -W -P +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -K -W -P -A +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -K -W -P -S -R1 -m500 echo "mi_test2$suffix $silent -L -K -R1 -m2000 ; Should give error 135" -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -R1 -m2000 -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -P -S -R3 -m50 -b1000000 -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -B -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -D -B -c -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -m10000 -e8192 -K -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -m10000 -e16384 -E16384 -K -L -myisamchk$suffix -sm test2 +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -K -R1 -m2000 +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -K -P -S -R3 -m50 -b1000000 +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -B +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -D -B -c +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -m10000 -e8192 -K +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -m10000 -e16384 -E16384 -K -L +./myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -W -P -m50 -l -myisamlog$suffix -mi_test2$suffix $silent -L -K -W -P -m50 -l -b100 -myisamlog$suffix -time mi_test2$suffix $silent -time mi_test2$suffix $silent -K -B -time mi_test2$suffix $silent -L -B -time mi_test2$suffix $silent -L -K -B -time mi_test2$suffix $silent -L -K -W -B -time mi_test2$suffix $silent -L -K -W -S -B -time mi_test2$suffix $silent -D -K -W -S -B +./mi_test2$suffix $silent -L -K -W -P -m50 -l +./myisamlog$suffix +./mi_test2$suffix $silent -L -K -W -P -m50 -l -b100 +./myisamlog$suffix +time ./mi_test2$suffix $silent +time ./mi_test2$suffix $silent -K -B +time ./mi_test2$suffix $silent -L -B +time ./mi_test2$suffix $silent -L -K -B +time ./mi_test2$suffix $silent -L -K -W -B +time ./mi_test2$suffix $silent -L -K -W -S -B +time ./mi_test2$suffix $silent -D -K -W -S -B From 8fdffd1b75ca50c77790d3d5f198599892558a40 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 6 Sep 2006 14:23:39 -0400 Subject: [PATCH 094/119] Fix merge problems; work around disparate "ls" behaviors. --- mysql-test/r/ctype_recoding.result | 2 +- mysql-test/t/heap_btree.test | 12 ------------ mysql-test/t/partition.test | 16 ++++++++++------ 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index acb07d1aa5d..d0087b03c17 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -253,7 +253,7 @@ create table t1(a char character set cp1251 default _koi8r 0xFF); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` char(1) character set cp1251 default 'ÿ' + `a` char(1) CHARACTER SET cp1251 DEFAULT 'ÿ' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1(a char character set latin1 default _cp1251 0xFF); diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index 12c911aa9c9..03ba8661a3c 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -204,16 +204,4 @@ CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY; INSERT INTO t1 VALUES(NULL),(NULL); DROP TABLE t1; -select a from t1 where a > 2; -delete from t1 where a < 4; -select a from t1 order by a; -insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); -select a from t1 where a > 4; -delete from t1 where a > 4; -select a from t1 order by a; -select a from t1 where a > 3; -delete from t1 where a >= 2; -select a from t1 order by a; -drop table t1; - --echo End of 5.0 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 532a63b0d24..928d855f9f4 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1340,11 +1340,13 @@ subpartition by hash (a) (SUBPARTITION subpart00, SUBPARTITION subpart01)); --replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1* || true +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1.* || true --replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/tmpdata/t1* || true +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1#* || true --replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/tmpinx/t1* || true +--exec ls $MYSQLTEST_VARDIR/master-data/tmpdata/t1#* || true +--replace_result $MYSQLTEST_VARDIR "hello" +--exec ls $MYSQLTEST_VARDIR/master-data/tmpinx/t1#* || true --replace_result $MYSQLTEST_VARDIR "hello" eval ALTER TABLE t1 REORGANIZE PARTITION p0 INTO @@ -1354,11 +1356,13 @@ eval ALTER TABLE t1 REORGANIZE PARTITION p0 INTO (SUBPARTITION subpart20, SUBPARTITION subpart21)); --replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1* || true +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1.* || true --replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/tmpdata/t1* || true +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1#* || true --replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/tmpinx/t1* || true +--exec ls $MYSQLTEST_VARDIR/master-data/tmpdata/t1#* || true +--replace_result $MYSQLTEST_VARDIR "hello" +--exec ls $MYSQLTEST_VARDIR/master-data/tmpinx/t1#* || true drop table t1; --exec rmdir $MYSQLTEST_VARDIR/master-data/tmpdata || true From 461afda9bb889db0758ddba70d5fe414d6444d37 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 6 Sep 2006 17:10:58 -0400 Subject: [PATCH 095/119] Fix build problem for when not compiled with debugging. --- dbug/dbug.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dbug/dbug.c b/dbug/dbug.c index 831c69bcdfb..ce692552045 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -71,9 +71,7 @@ * */ -#ifdef DBUG_OFF -#undef DBUG_OFF -#endif + #include #include #include @@ -81,6 +79,10 @@ #include #endif + +#ifndef DBUG_OFF + + /* * Manifest constants which may be "tuned" if desired. */ @@ -313,6 +315,7 @@ static unsigned long Clock(void); #define ChangeOwner(cs,name) #endif + /* ** Macros to allow dbugging with threads */ @@ -2351,3 +2354,5 @@ va_list ap; } #endif /* NO_VARARGS */ + +#endif From f4265f7a5741517799b17b493cebffb6bbb86571 Mon Sep 17 00:00:00 2001 From: "tsmith@maint1.mysql.com" <> Date: Thu, 7 Sep 2006 00:01:00 +0200 Subject: [PATCH 096/119] Bug #21250: esolve stack traces on AMD64 (backport to mysql-4.1) --- sql/stacktrace.c | 55 +++++++++++++++++++++++++++++++++++------------- sql/stacktrace.h | 8 +++++-- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/sql/stacktrace.c b/sql/stacktrace.c index 838f547dc02..43f35c452f7 100644 --- a/sql/stacktrace.c +++ b/sql/stacktrace.c @@ -21,6 +21,7 @@ #ifdef HAVE_STACKTRACE #include +#include #define PTR_SANE(p) ((p) && (char*)(p) >= heap_start && (char*)(p) <= heap_end) @@ -44,7 +45,29 @@ void safe_print_str(const char* name, const char* val, int max_len) } #ifdef TARGET_OS_LINUX -#define SIGRETURN_FRAME_COUNT 2 + +#ifdef __i386__ +#define SIGRETURN_FRAME_OFFSET 17 +#endif + +#ifdef __x86_64__ +#define SIGRETURN_FRAME_OFFSET 23 +#endif + +static my_bool is_nptl; + +/* Check if we are using NPTL or LinuxThreads on Linux */ +void check_thread_lib(void) +{ + char buf[5]; + +#ifdef _CS_GNU_LIBPTHREAD_VERSION + confstr(_CS_GNU_LIBPTHREAD_VERSION, buf, sizeof(buf)); + is_nptl = !strncasecmp(buf, "NPTL", sizeof(buf)); +#else + is_nptl = 0; +#endif +} #if defined(__alpha__) && defined(__GNUC__) /* @@ -90,7 +113,7 @@ inline uint32* find_prev_pc(uint32* pc, uchar** fp) void print_stacktrace(gptr stack_bottom, ulong thread_stack) { uchar** fp; - uint frame_count = 0; + uint frame_count = 0, sigreturn_frame_count; #if defined(__alpha__) && defined(__GNUC__) uint32* pc; #endif @@ -100,28 +123,27 @@ void print_stacktrace(gptr stack_bottom, ulong thread_stack) Attempting backtrace. You can use the following information to find out\n\ where mysqld died. If you see no messages after this, something went\n\ terribly wrong...\n"); -#ifdef __i386__ +#ifdef __i386__ __asm __volatile__ ("movl %%ebp,%0" :"=r"(fp) :"r"(fp)); - if (!fp) - { - fprintf(stderr, "frame pointer (ebp) is NULL, did you compile with\n\ --fomit-frame-pointer? Aborting backtrace!\n"); - return; - } +#endif +#ifdef __x86_64__ + __asm __volatile__ ("movq %%rbp,%0" + :"=r"(fp) + :"r"(fp)); #endif #if defined(__alpha__) && defined(__GNUC__) __asm __volatile__ ("mov $30,%0" :"=r"(fp) :"r"(fp)); +#endif if (!fp) { - fprintf(stderr, "frame pointer (fp) is NULL, did you compile with\n\ + fprintf(stderr, "frame pointer is NULL, did you compile with\n\ -fomit-frame-pointer? Aborting backtrace!\n"); return; } -#endif /* __alpha__ */ if (!stack_bottom || (gptr) stack_bottom > (gptr) &fp) { @@ -151,13 +173,16 @@ terribly wrong...\n"); :"r"(pc)); #endif /* __alpha__ */ + /* We are 1 frame above signal frame with NPTL and 2 frames above with LT */ + sigreturn_frame_count = is_nptl ? 1 : 2; + while (fp < (uchar**) stack_bottom) { -#ifdef __i386__ +#if defined(__i386__) || defined(__x86_64__) uchar** new_fp = (uchar**)*fp; - fprintf(stderr, "%p\n", frame_count == SIGRETURN_FRAME_COUNT ? - *(fp+17) : *(fp+1)); -#endif /* __386__ */ + fprintf(stderr, "%p\n", frame_count == sigreturn_frame_count ? + *(fp + SIGRETURN_FRAME_OFFSET) : *(fp + 1)); +#endif /* defined(__386__) || defined(__x86_64__) */ #if defined(__alpha__) && defined(__GNUC__) uchar** new_fp = find_prev_fp(pc, fp); diff --git a/sql/stacktrace.h b/sql/stacktrace.h index d5d1e05ef0e..527d10d70a2 100644 --- a/sql/stacktrace.h +++ b/sql/stacktrace.h @@ -19,16 +19,20 @@ extern "C" { #endif #ifdef TARGET_OS_LINUX -#if defined(HAVE_STACKTRACE) || (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) +#if defined(HAVE_STACKTRACE) || (defined (__x86_64__) || defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) #undef HAVE_STACKTRACE #define HAVE_STACKTRACE extern char* __bss_start; extern char* heap_start; -#define init_stacktrace() { heap_start = (char*) &__bss_start; } +#define init_stacktrace() do { \ + heap_start = (char*) &__bss_start; \ + check_thread_lib(); \ + } while(0); void print_stacktrace(gptr stack_bottom, ulong thread_stack); void safe_print_str(const char* name, const char* val, int max_len); +void check_thread_lib(void); #endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */ #endif /* TARGET_OS_LINUX */ From b6cd727ed1f722ae37f9302196f6f20121bbbb4d Mon Sep 17 00:00:00 2001 From: "tsmith@maint1.mysql.com" <> Date: Thu, 7 Sep 2006 00:11:43 +0200 Subject: [PATCH 097/119] Bug #21054: myisam_stats_method ignored in my.cnf and cmdline Fix OPT_MYISAM_STATS_METHOD case, where the NULLS_EQUAL and NULLS_NOT_EQUAL methods were mixed up --- sql/mysqld.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index fc3ca5085cf..71a0e35925e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6537,10 +6537,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } switch (method-1) { case 0: - method_conv= MI_STATS_METHOD_NULLS_EQUAL; + method_conv= MI_STATS_METHOD_NULLS_NOT_EQUAL; break; case 1: - method_conv= MI_STATS_METHOD_NULLS_NOT_EQUAL; + method_conv= MI_STATS_METHOD_NULLS_EQUAL; break; case 2: method_conv= MI_STATS_METHOD_IGNORE_NULLS; From 2480ec8e3ef17fd86bd39c83301a125a1d956eab Mon Sep 17 00:00:00 2001 From: "tsmith@maint1.mysql.com" <> Date: Thu, 7 Sep 2006 00:54:48 +0200 Subject: [PATCH 098/119] Force conflict to avoid bk automerge behavior; will be undone during merge. --- sql/stacktrace.c | 1 + sql/stacktrace.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/stacktrace.c b/sql/stacktrace.c index 838f547dc02..3660ac845fe 100644 --- a/sql/stacktrace.c +++ b/sql/stacktrace.c @@ -44,6 +44,7 @@ void safe_print_str(const char* name, const char* val, int max_len) } #ifdef TARGET_OS_LINUX +/* Force merge conflict, to avoid bk automerge */ #define SIGRETURN_FRAME_COUNT 2 #if defined(__alpha__) && defined(__GNUC__) diff --git a/sql/stacktrace.h b/sql/stacktrace.h index d5d1e05ef0e..7676ee28a83 100644 --- a/sql/stacktrace.h +++ b/sql/stacktrace.h @@ -19,7 +19,7 @@ extern "C" { #endif #ifdef TARGET_OS_LINUX -#if defined(HAVE_STACKTRACE) || (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) +#if defined(HAVE_STACKTRACE) || (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) /* Force conflict to avoid bk automerge */ #undef HAVE_STACKTRACE #define HAVE_STACKTRACE From 330ae3e29d41dd0aaa648b7a0c6bf4aa893be572 Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/salvation.intern.azundris.com" <> Date: Thu, 7 Sep 2006 04:18:17 +0200 Subject: [PATCH 099/119] make partition_mgm test deterministic wrt results of ls --- mysql-test/t/partition_mgm.test | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index f1a89b28443..8458d47d634 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -24,11 +24,15 @@ PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2; SHOW CREATE TABLE t1; --replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1* +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1#* +--replace_result $MYSQLTEST_VARDIR "hello" +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1.* ALTER TABLE t1 COALESCE PARTITION 1; SHOW CREATE TABLE t1; --replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1* +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1#* +--replace_result $MYSQLTEST_VARDIR "hello" +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1.* drop table t1; # # Bug 20767: REORGANIZE partition crashes From f5cebbdfba9f0288be06002cf61e8799f51ed676 Mon Sep 17 00:00:00 2001 From: "arjen@mysql.com/albus.bitbike.com" <> Date: Thu, 7 Sep 2006 13:52:30 +1000 Subject: [PATCH 100/119] errmsg.txt: Update of Dutch errmsg translations (not complete yet) errmsg.h: Fixup of changed error message file path in comment authors.h: Ego add. --- include/errmsg.h | 2 +- sql/authors.h | 2 ++ sql/share/errmsg.txt | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/errmsg.h b/include/errmsg.h index 4018e3ee01d..dc7adb3b501 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Error messages for MySQL clients */ -/* (Error messages for the daemon are in share/language/errmsg.sys) */ +/* (Error messages for the daemon are in sql/share/errmsg.txt) */ #ifdef __cplusplus extern "C" { diff --git a/sql/authors.h b/sql/authors.h index 618c6305f6b..980ec7670de 100644 --- a/sql/authors.h +++ b/sql/authors.h @@ -85,6 +85,8 @@ struct show_table_authors_st show_table_authors[]= { { "Matthias Leich", "Berlin, Germany", "Testing - Server" }, { "Dmitri Lenev", "Moscow, Russia", "Time zones support (4.1), Triggers (5.0)" }, + { "Arjen Lentz", "Brisbane, Australia", + "Documentation (2001-2004), Dutch error messages, LOG2()" }, { "Marc Liyanage", "", "Created Mac OS X packages" }, { "Zarko Mocnik", "", "Sorting for Slovenian language" }, { "Per-Erik Martin", "Uppsala, Sweden", "Stored Procedures (5.0)" }, diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 2228ded870b..28d81447c66 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -4710,6 +4710,7 @@ ER_MASTER_FATAL_ERROR_READING_BINLOG ER_SLAVE_IGNORED_TABLE eng "Slave SQL thread ignored the query because of replicate-*-table rules" ger "Slave-SQL-Thread hat die Abfrage aufgrund von replicate-*-table-Regeln ignoriert" + nla "Slave SQL thread negeerde de query vanwege replicate-*-table opties" por "Slave SQL thread ignorado a consulta devido às normas de replicação-*-tabela" spa "Slave SQL thread ignorado el query debido a las reglas de replicación-*-tabla" swe "Slav SQL tråden ignorerade frågan pga en replicate-*-table regel" @@ -4717,29 +4718,34 @@ ER_INCORRECT_GLOBAL_LOCAL_VAR eng "Variable '%-.64s' is a %s variable" serbian "Incorrect foreign key definition for '%-.64s': %s" ger "Variable '%-.64s' ist eine %s-Variable" + nla "Variabele '%-.64s' is geen %s variabele" spa "Variable '%-.64s' es una %s variable" swe "Variabel '%-.64s' är av typ %s" ER_WRONG_FK_DEF 42000 eng "Incorrect foreign key definition for '%-.64s': %s" ger "Falsche Fremdschlüssel-Definition für '%-.64s': %s" + nla "Incorrecte foreign key definitie voor '%-.64s': %s" por "Definição errada da chave estrangeira para '%-.64s': %s" spa "Equivocada definición de llave extranjera para '%-.64s': %s" swe "Felaktig FOREIGN KEY-definition för '%-.64s': %s" ER_KEY_REF_DO_NOT_MATCH_TABLE_REF eng "Key reference and table reference don't match" ger "Schlüssel- und Tabellenverweis passen nicht zusammen" + nla "Sleutel- en tabelreferentie komen niet overeen" por "Referência da chave e referência da tabela não coincidem" spa "Referencia de llave y referencia de tabla no coinciden" swe "Nyckelreferensen och tabellreferensen stämmer inte överens" ER_OPERAND_COLUMNS 21000 eng "Operand should contain %d column(s)" ger "Operand sollte %d Spalte(n) enthalten" + nla "Operand behoort %d kolommen te bevatten" rus "ïÐÅÒÁÎÄ ÄÏÌÖÅÎ ÓÏÄÅÒÖÁÔØ %d ËÏÌÏÎÏË" spa "Operando debe tener %d columna(s)" ukr "ïÐÅÒÁÎÄ ÍÁ¤ ÓËÌÁÄÁÔÉÓÑ Ú %d ÓÔÏ×Âæ×" ER_SUBQUERY_NO_1_ROW 21000 eng "Subquery returns more than 1 row" ger "Unterabfrage lieferte mehr als einen Datensatz zurück" + nla "Subquery retourneert meer dan 1 rij" por "Subconsulta retorna mais que 1 registro" rus "ðÏÄÚÁÐÒÏÓ ×ÏÚ×ÒÁÝÁÅÔ ÂÏÌÅÅ ÏÄÎÏÊ ÚÁÐÉÓÉ" spa "Subconsulta retorna mas que 1 línea" @@ -4749,6 +4755,7 @@ ER_UNKNOWN_STMT_HANDLER dan "Unknown prepared statement handler (%.*s) given to %s" eng "Unknown prepared statement handler (%.*s) given to %s" ger "Unbekannter Prepared-Statement-Handler (%.*s) für %s angegeben" + nla "Onebekende prepared statement handler (%.*s) voor %s aangegeven" por "Desconhecido manipulador de declaração preparado (%.*s) determinado para %s" spa "Desconocido preparado comando handler (%.*s) dado para %s" swe "Okänd PREPARED STATEMENT id (%.*s) var given till %s" @@ -4756,12 +4763,14 @@ ER_UNKNOWN_STMT_HANDLER ER_CORRUPT_HELP_DB eng "Help database is corrupt or does not exist" ger "Die Hilfe-Datenbank ist beschädigt oder existiert nicht" + nla "Help database is beschadigd of bestaat niet" por "Banco de dado de ajuda corrupto ou não existente" spa "Base de datos Help está corrupto o no existe" swe "Hjälpdatabasen finns inte eller är skadad" ER_CYCLIC_REFERENCE eng "Cyclic reference on subqueries" ger "Zyklischer Verweis in Unterabfragen" + nla "Cyclische verwijzing in subqueries" por "Referência cíclica em subconsultas" rus "ãÉËÌÉÞÅÓËÁÑ ÓÓÙÌËÁ ÎÁ ÐÏÄÚÁÐÒÏÓ" spa "Cíclica referencia en subconsultas" @@ -4770,6 +4779,7 @@ ER_CYCLIC_REFERENCE ER_AUTO_CONVERT eng "Converting column '%s' from %s to %s" ger "Feld '%s' wird von %s nach %s umgewandelt" + nla "Veld '%s' wordt van %s naar %s geconverteerd" por "Convertendo coluna '%s' de %s para %s" rus "ðÒÅÏÂÒÁÚÏ×ÁÎÉÅ ÐÏÌÑ '%s' ÉÚ %s × %s" spa "Convirtiendo columna '%s' de %s para %s" @@ -4778,6 +4788,7 @@ ER_AUTO_CONVERT ER_ILLEGAL_REFERENCE 42S22 eng "Reference '%-.64s' not supported (%s)" ger "Verweis '%-.64s' wird nicht unterstützt (%s)" + nla "Verwijzing '%-.64s' niet ondersteund (%s)" por "Referência '%-.64s' não suportada (%s)" rus "óÓÙÌËÁ '%-.64s' ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔÓÑ (%s)" spa "Referencia '%-.64s' no soportada (%s)" @@ -4786,12 +4797,14 @@ ER_ILLEGAL_REFERENCE 42S22 ER_DERIVED_MUST_HAVE_ALIAS 42000 eng "Every derived table must have its own alias" ger "Für jede abgeleitete Tabelle muss ein eigener Alias angegeben werden" + nla "Voor elke afgeleide tabel moet een unieke alias worden gebruikt" por "Cada tabela derivada deve ter seu próprio alias" spa "Cada tabla derivada debe tener su propio alias" swe "Varje 'derived table' måste ha sitt eget alias" ER_SELECT_REDUCED 01000 eng "Select %u was reduced during optimization" ger "Select %u wurde während der Optimierung reduziert" + nla "Select %u werd geredureerd tijdens optimtalisatie" por "Select %u foi reduzido durante otimização" rus "Select %u ÂÙÌ ÕÐÒÁÚÄÎÅÎ × ÐÒÏÃÅÓÓÅ ÏÐÔÉÍÉÚÁÃÉÉ" spa "Select %u fué reducido durante optimización" @@ -4800,62 +4813,73 @@ ER_SELECT_REDUCED 01000 ER_TABLENAME_NOT_ALLOWED_HERE 42000 eng "Table '%-.64s' from one of the SELECTs cannot be used in %-.32s" ger "Tabelle '%-.64s', die in einem der SELECT-Befehle verwendet wurde, kann nicht in %-.32s verwendet werden" + nla "Tabel '%-.64s' uit een van de SELECTS kan niet in %-.32s gebruikt worden" por "Tabela '%-.64s' de um dos SELECTs não pode ser usada em %-.32s" spa "Tabla '%-.64s' de uno de los SELECT no puede ser usada en %-.32s" swe "Tabell '%-.64s' från en SELECT kan inte användas i %-.32s" ER_NOT_SUPPORTED_AUTH_MODE 08004 eng "Client does not support authentication protocol requested by server; consider upgrading MySQL client" ger "Client unterstützt das vom Server erwartete Authentifizierungsprotokoll nicht. Bitte aktualisieren Sie Ihren MySQL-Client" + nla "Client ondersteunt het door de server verwachtte authenticatieprotocol niet. Overweeg een nieuwere MySQL client te gebruiken" por "Cliente não suporta o protocolo de autenticação exigido pelo servidor; considere a atualização do cliente MySQL" spa "Cliente no soporta protocolo de autenticación solicitado por el servidor; considere actualizar el cliente MySQL" swe "Klienten stöder inte autentiseringsprotokollet som begärts av servern; överväg uppgradering av klientprogrammet." ER_SPATIAL_CANT_HAVE_NULL 42000 eng "All parts of a SPATIAL index must be NOT NULL" ger "Alle Teile eines SPATIAL-Index müssen als NOT NULL deklariert sein" + nla "Alle delete van een SPATIAL index dienen als NOT NULL gedeclareerd te worden" por "Todas as partes de uma SPATIAL index devem ser NOT NULL" spa "Todas las partes de una SPATIAL index deben ser NOT NULL" swe "Alla delar av en SPATIAL index måste vara NOT NULL" ER_COLLATION_CHARSET_MISMATCH 42000 eng "COLLATION '%s' is not valid for CHARACTER SET '%s'" ger "COLLATION '%s' ist für CHARACTER SET '%s' ungültig" + nla "COLLATION '%s' is niet geldig voor CHARACTER SET '%s'" por "COLLATION '%s' não é válida para CHARACTER SET '%s'" spa "COLLATION '%s' no es válido para CHARACTER SET '%s'" swe "COLLATION '%s' är inte tillåtet för CHARACTER SET '%s'" ER_SLAVE_WAS_RUNNING eng "Slave is already running" ger "Slave läuft bereits" + nla "Slave is reeds actief" por "O slave já está rodando" spa "Slave ya está funcionando" swe "Slaven har redan startat" ER_SLAVE_WAS_NOT_RUNNING eng "Slave already has been stopped" ger "Slave wurde bereits angehalten" + nla "Slave is reeds gestopt" por "O slave já está parado" spa "Slave ya fué parado" swe "Slaven har redan stoppat" ER_TOO_BIG_FOR_UNCOMPRESS eng "Uncompressed data size too large; the maximum size is %d (probably, length of uncompressed data was corrupted)" ger "Unkomprimierte Daten sind zu groß. Die maximale Größe beträgt %d (wahrscheinlich wurde die Länge der unkomprimierten Daten beschädigt)" + nla "Ongecomprimeerder data is te groot; de maximum lengte is %d (waarschijnlijk, de lengte van de gecomprimeerde data was beschadigd)" por "Tamanho muito grande dos dados des comprimidos. O máximo tamanho é %d. (provavelmente, o comprimento dos dados descomprimidos está corrupto)" spa "Tamaño demasiado grande para datos descomprimidos. El máximo tamaño es %d. (probablemente, extensión de datos descomprimidos fué corrompida)" ER_ZLIB_Z_MEM_ERROR eng "ZLIB: Not enough memory" ger "ZLIB: Nicht genug Speicher" + nla "ZLIB: Onvoldoende geheugen" por "ZLIB: Não suficiente memória disponível" spa "Z_MEM_ERROR: No suficiente memoria para zlib" ER_ZLIB_Z_BUF_ERROR eng "ZLIB: Not enough room in the output buffer (probably, length of uncompressed data was corrupted)" ger "ZLIB: Im Ausgabepuffer ist nicht genug Platz vorhanden (wahrscheinlich wurde die Länge der unkomprimierten Daten beschädigt)" + nla "ZLIB: Onvoldoende ruimte in uitgaande buffer (waarschijnlijk, de lengte van de ongecomprimeerde data was beschadigd)" por "ZLIB: Não suficiente espaço no buffer emissor (provavelmente, o comprimento dos dados descomprimidos está corrupto)" spa "Z_BUF_ERROR: No suficiente espacio en el búfer de salida para zlib (probablemente, extensión de datos descomprimidos fué corrompida)" ER_ZLIB_Z_DATA_ERROR eng "ZLIB: Input data corrupted" ger "ZLIB: Eingabedaten beschädigt" + nla "ZLIB: Invoer data beschadigd" por "ZLIB: Dados de entrada está corrupto" spa "ZLIB: Dato de entrada fué corrompido para zlib" ER_CUT_VALUE_GROUP_CONCAT eng "%d line(s) were cut by GROUP_CONCAT()" ger "%d Zeile(n) durch GROUP_CONCAT() abgeschnitten" + nla "%d regel(s) door GROUP_CONCAT() ingekort" por "%d linha(s) foram cortada(s) por GROUP_CONCAT()" spa "%d línea(s) fue(fueron) cortadas por group_concat()" swe "%d rad(er) kapades av group_concat()" @@ -4863,11 +4887,13 @@ ER_CUT_VALUE_GROUP_CONCAT ER_WARN_TOO_FEW_RECORDS 01000 eng "Row %ld doesn't contain data for all columns" ger "Zeile %ld enthält nicht für alle Felder Daten" + nla "Rij %ld bevat niet de data voor alle kolommen" por "Conta de registro é menor que a conta de coluna na linha %ld" spa "Línea %ld no contiene datos para todas las columnas" ER_WARN_TOO_MANY_RECORDS 01000 eng "Row %ld was truncated; it contained more data than there were input columns" ger "Zeile %ld gekürzt, die Zeile enthielt mehr Daten, als es Eingabefelder gibt" + nla "Regel %ld ingekort, bevatte meer data dan invoer kolommen" por "Conta de registro é maior que a conta de coluna na linha %ld" spa "Línea %ld fué truncada; La misma contine mas datos que las que existen en las columnas de entrada" ER_WARN_NULL_TO_NOTNULL 22004 From e1db08e1daf4bc6f7d40c3afd6056242a960a4b8 Mon Sep 17 00:00:00 2001 From: "serg@janus.mylan" <> Date: Thu, 7 Sep 2006 12:56:32 +0200 Subject: [PATCH 101/119] minor plugin api fixes: remove #define __attribute__(A) from plugin.h increase API version because placeholders were added more robust definition of min_plugin_interface_version --- include/mysql/plugin.h | 6 +----- plugin/fulltext/plugin_example.c | 4 ++++ sql/sql_plugin.cc | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 739f7bc5fc6..417e949e83f 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -21,7 +21,7 @@ Plugin API. Common for all plugin types. */ -#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0001 +#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0002 /* The allowable types of plugins @@ -31,10 +31,6 @@ #define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */ #define MYSQL_MAX_PLUGIN_TYPE_NUM 3 /* The number of plugin types */ -#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) -#define __attribute__(A) -#endif - /* Macros for beginning and ending plugin declarations. Between mysql_declare_plugin and mysql_declare_plugin_end there should diff --git a/plugin/fulltext/plugin_example.c b/plugin/fulltext/plugin_example.c index 34350e317ba..7da6672190c 100644 --- a/plugin/fulltext/plugin_example.c +++ b/plugin/fulltext/plugin_example.c @@ -17,6 +17,10 @@ #include #include +#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) +#define __attribute__(A) +#endif + static long number_of_calls= 0; /* for SHOW STATUS, see below */ /* diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index b66d2d20925..56f58d67259 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -40,7 +40,7 @@ static const char *plugin_interface_version_sym= static const char *sizeof_st_plugin_sym= "_mysql_sizeof_struct_st_plugin_"; static const char *plugin_declarations_sym= "_mysql_plugin_declarations_"; -static int min_plugin_interface_version= 0x0000; +static int min_plugin_interface_version= MYSQL_PLUGIN_INTERFACE_VERSION & ~0xFF; /* Note that 'int version' must be the first field of every plugin sub-structure (plugin->info). */ From a057d38514abca25e26e84f95dcfdd11a3072695 Mon Sep 17 00:00:00 2001 From: "serg@janus.mylan" <> Date: Thu, 7 Sep 2006 15:01:36 +0200 Subject: [PATCH 102/119] cleanup of pligin removal code fixed multiple and missing deinitializations, moved all deinit/del code in one place --- sql/sql_plugin.cc | 176 +++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 96 deletions(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 56f58d67259..cc20e22ab32 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -35,6 +35,11 @@ plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]= 0,ha_initialize_handlerton,0 }; +plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]= +{ + 0,ha_finalize_handlerton,0 +}; + static const char *plugin_interface_version_sym= "_mysql_plugin_interface_version_"; static const char *sizeof_st_plugin_sym= @@ -469,49 +474,67 @@ err: } -void plugin_deinitializer(struct st_plugin_int *plugin) +void plugin_deinitialize(struct st_plugin_int *plugin) { - if (plugin->plugin->status_vars) - { - SHOW_VAR array[2]= { - {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, - {0, 0, SHOW_UNDEF} - }; - remove_status_vars(array); - } - if (plugin->state == PLUGIN_IS_READY) + if (plugin_type_deinitialize[plugin->plugin->type] && + (*plugin_type_deinitialize[plugin->plugin->type])(plugin)) + { + sql_print_error("Plugin '%s' of type %s failed deinitialization", + plugin->name.str, plugin_type_names[plugin->plugin->type]); + } + + if (plugin->plugin->status_vars) + { +#ifdef FIX_LATER + /* + We have a problem right now where we can not prepend without + breaking backwards compatibility. We will fix this shortly so + that engines have "use names" and we wil use those for + CREATE TABLE, and use the plugin name then for adding automatic + variable names. + */ + SHOW_VAR array[2]= { + {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, + {0, 0, SHOW_UNDEF} + }; + remove_status_vars(array); +#else + remove_status_vars(plugin->plugin->status_vars); +#endif /* FIX_LATER */ + } + + if (plugin->plugin->deinit) + { + DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str)); + if (plugin->plugin->deinit()) { - if (plugin->plugin->deinit) - { - DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str)); - if (plugin->plugin->deinit()) - { - DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.", - plugin->name.str)); - } - } - plugin->state= PLUGIN_IS_UNINITIALIZED; + DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.", + plugin->name.str)); } + } + plugin->state= PLUGIN_IS_UNINITIALIZED; } -static void plugin_del(const LEX_STRING *name) +static void plugin_del(struct st_plugin_int *plugin) { - uint i; - struct st_plugin_int *plugin; - DBUG_ENTER("plugin_del"); - if ((plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN))) - { - plugin_deinitializer(plugin); - hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin); - plugin_dl_del(&plugin->plugin_dl->dl); - plugin->state= PLUGIN_IS_FREED; - plugin_array_version++; - } + DBUG_ENTER("plugin_del(plugin)"); + hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin); + plugin_dl_del(&plugin->plugin_dl->dl); + plugin->state= PLUGIN_IS_FREED; + plugin_array_version++; DBUG_VOID_RETURN; } +static void plugin_del(const LEX_STRING *name) +{ + struct st_plugin_int *plugin; + DBUG_ENTER("plugin_del(name)"); + if ((plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN))) + plugin_del(plugin); + DBUG_VOID_RETURN; +} void plugin_unlock(struct st_plugin_int *plugin) { @@ -521,9 +544,8 @@ void plugin_unlock(struct st_plugin_int *plugin) plugin->ref_count--; if (plugin->state == PLUGIN_IS_DELETED && ! plugin->ref_count) { - if (plugin->plugin->deinit) - plugin->plugin->deinit(); - plugin_del(&plugin->name); + plugin_deinitialize(plugin); + plugin_del(plugin); } rw_unlock(&THR_LOCK_plugin); DBUG_VOID_RETURN; @@ -537,15 +559,15 @@ static int plugin_initialize(struct st_plugin_int *plugin) if (plugin->plugin->status_vars) { #ifdef FIX_LATER - /* + /* We have a problem right now where we can not prepend without - breaking backwards compatibility. We will fix this shortly so + breaking backwards compatibility. We will fix this shortly so that engines have "use names" and we wil use those for CREATE TABLE, and use the plugin name then for adding automatic variable names. */ SHOW_VAR array[2]= { - {plugin->name, (char*)plugin->status_vars, SHOW_ARRAY}, + {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, {0, 0, SHOW_UNDEF} }; if (add_status_vars(array)) // add_status_vars makes a copy @@ -578,53 +600,6 @@ err: DBUG_RETURN(1); } -static int plugin_finalize(THD *thd, struct st_plugin_int *plugin) -{ - int rc; - DBUG_ENTER("plugin_finalize"); - - if (plugin->ref_count) - { - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "Plugin is busy and will be uninstalled on shutdown"); - goto err; - } - - switch (plugin->plugin->type) - { - case MYSQL_STORAGE_ENGINE_PLUGIN: - if (ha_finalize_handlerton(plugin)) - { - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "Storage engine shutdown failed. " - "It will be uninstalled on shutdown"); - sql_print_warning("Storage engine '%s' shutdown failed. " - "It will be uninstalled on shutdown", plugin->name.str); - goto err; - } - break; - default: - break; - } - - if (plugin->plugin->deinit) - { - if ((rc= plugin->plugin->deinit())) - { - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "Plugin deinit failed. " - "It will be uninstalled on shutdown"); - sql_print_warning("Plugin '%s' deinit failed. " - "It will be uninstalled on shutdown", plugin->name.str); - goto err; - } - } - - DBUG_RETURN(0); -err: - DBUG_RETURN(1); -} - static byte *get_hash_key(const byte *buff, uint *length, my_bool not_used __attribute__((unused))) { @@ -637,7 +612,7 @@ static byte *get_hash_key(const byte *buff, uint *length, /* The logic is that we first load and initialize all compiled in plugins. From there we load up the dynamic types (assuming we have not been told to - skip this part). + skip this part). Finally we inializie everything, aka the dynamic that have yet to initialize. */ @@ -666,7 +641,7 @@ int plugin_init(int skip_dynamic_loading) goto err; } - /* + /* First we register builtin plugins */ for (builtins= mysqld_builtins; *builtins; builtins++) @@ -702,7 +677,10 @@ int plugin_init(int skip_dynamic_loading) if (tmp->state == PLUGIN_IS_UNINITIALIZED) { if (plugin_initialize(tmp)) - plugin_del(&tmp->name); + { + plugin_deinitialize(tmp); + plugin_del(tmp); + } } } @@ -812,7 +790,7 @@ void plugin_shutdown(void) { struct st_plugin_int *tmp= dynamic_element(&plugin_array, i, struct st_plugin_int *); - plugin_deinitializer(tmp); + plugin_deinitialize(tmp); } @@ -862,7 +840,7 @@ my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING { my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str, "Plugin initialization function failed."); - goto err; + goto deinit; } table->use_all_columns(); @@ -879,10 +857,9 @@ my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING rw_unlock(&THR_LOCK_plugin); DBUG_RETURN(FALSE); deinit: - if (tmp->plugin->deinit) - tmp->plugin->deinit(); + plugin_deinitialize(tmp); err: - plugin_del(name); + plugin_del(tmp); rw_unlock(&THR_LOCK_plugin); DBUG_RETURN(TRUE); } @@ -917,10 +894,17 @@ my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) goto err; } - if (!plugin_finalize(thd, plugin)) - plugin_del(name); - else + if (plugin->ref_count) + { + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + "Plugin is busy and will be uninstalled on shutdown"); plugin->state= PLUGIN_IS_DELETED; + } + else + { + plugin_deinitialize(plugin); + plugin_del(plugin); + } table->use_all_columns(); table->field[0]->store(name->str, name->length, system_charset_info); From 5e46ea7f037f0c6dd22a7c7fcbe223ecf6cf8cc7 Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Thu, 7 Sep 2006 08:23:58 -0700 Subject: [PATCH 103/119] Moves Innodb handler to the Innodb storage directory. --- libmysqld/Makefile.am | 2 +- sql/Makefile.am | 3 +- storage/innobase/CMakeLists.txt | 3 +- storage/innobase/Makefile.am | 3 ++ storage/innobase/handler/Makefile.am | 29 +++++++++++++++++++ .../innobase/handler}/ha_innodb.cc | 5 ++-- {sql => storage/innobase/handler}/ha_innodb.h | 0 storage/innobase/plug.in | 1 + 8 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 storage/innobase/handler/Makefile.am rename {sql => storage/innobase/handler}/ha_innodb.cc (99%) rename {sql => storage/innobase/handler}/ha_innodb.h (100%) diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index e6d1c1acfca..08a8d68b2e5 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -44,7 +44,7 @@ libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \ noinst_HEADERS = embedded_priv.h emb_qcache.h sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \ - ha_innodb.cc ha_ndbcluster.cc \ + ha_ndbcluster.cc \ ha_ndbcluster_binlog.cc ha_partition.cc \ handler.cc sql_handler.cc \ hostname.cc init.cc password.c \ diff --git a/sql/Makefile.am b/sql/Makefile.am index dfb625d4747..d1ebea45d0c 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -50,7 +50,6 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ sql_map.h sql_string.h unireg.h \ sql_error.h field.h handler.h mysqld_suffix.h \ ha_partition.h \ - ha_innodb.h \ ha_ndbcluster.h ha_ndbcluster_binlog.h \ ha_ndbcluster_tables.h \ opt_range.h protocol.h rpl_tblmap.h \ @@ -87,7 +86,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ unireg.cc des_key_file.cc \ discover.cc time.cc opt_range.cc opt_sum.cc \ records.cc filesort.cc handler.cc \ - ha_partition.cc ha_innodb.cc \ + ha_partition.cc \ ha_ndbcluster.cc ha_ndbcluster_binlog.cc \ sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \ sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \ diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 8b8c3af6582..8e456993413 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -2,7 +2,7 @@ #SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/handler include) ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c data/data0data.c data/data0type.c @@ -23,6 +23,7 @@ ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c page/page0cur.c page/page0page.c que/que0que.c + handler/ha_innodb.cc read/read0read.c rem/rem0cmp.c rem/rem0rec.c row/row0ins.c row/row0mysql.c row/row0purge.c row/row0row.c row/row0sel.c row/row0uins.c diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am index a68dbbcc2e6..bdab35f1dc0 100644 --- a/storage/innobase/Makefile.am +++ b/storage/innobase/Makefile.am @@ -34,6 +34,7 @@ noinst_HEADERS = SUBDIRS = os ut btr buf data dict dyn eval fil fsp fut \ ha ibuf lock log mach mem mtr page \ + handler \ pars que read rem row srv sync thr trx usr EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr0cur.ic \ @@ -86,6 +87,7 @@ EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr include/univ.i include/usr0sess.h include/usr0sess.ic include/usr0types.h \ include/ut0byte.h include/ut0byte.ic include/ut0dbg.h include/ut0lst.h \ include/ut0mem.h include/ut0mem.ic include/ut0rnd.h include/ut0rnd.ic \ + handler/ha_innodb.h \ include/ut0sort.h include/ut0ut.h include/ut0ut.ic include/ut0vec.h include/ut0vec.ic include/ha_prototypes.h \ include/ut0list.h include/ut0list.ic \ include/ut0wqueue.h \ @@ -102,6 +104,7 @@ libinnobase_a_LIBADD = usr/libusr.a srv/libsrv.a dict/libdict.a \ page/libpage.a rem/librem.a thr/libthr.a \ sync/libsync.a data/libdata.a mach/libmach.a \ ha/libha.a dyn/libdyn.a mem/libmem.a \ + handler/libhandler.a \ ut/libut.a os/libos.a ut/libut.a libinnobase_a_SOURCES = diff --git a/storage/innobase/handler/Makefile.am b/storage/innobase/handler/Makefile.am new file mode 100644 index 00000000000..46909c8b7e1 --- /dev/null +++ b/storage/innobase/handler/Makefile.am @@ -0,0 +1,29 @@ +# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +# & Innobase Oy +# +# 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 + +include ../include/Makefile.i + +DEFS = -DMYSQL_SERVER @DEFS@ + +noinst_LIBRARIES = libhandler.a + +libhandler_a_SOURCES = ha_innodb.cc + +EXTRA_PROGRAMS = + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/sql/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc similarity index 99% rename from sql/ha_innodb.cc rename to storage/innobase/handler/ha_innodb.cc index 1665c7c011a..9bf347a1f29 100644 --- a/sql/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -31,8 +31,7 @@ have disables the InnoDB inlining in this file. */ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" -#include "slave.h" +#include #include #include @@ -1689,7 +1688,7 @@ innobase_commit_low( return; } -#ifdef HAVE_REPLICATION +#ifdef DISABLED_HAVE_REPLICATION THD *thd=current_thd; if (thd && thd->slave_thread) { diff --git a/sql/ha_innodb.h b/storage/innobase/handler/ha_innodb.h similarity index 100% rename from sql/ha_innodb.h rename to storage/innobase/handler/ha_innodb.h diff --git a/storage/innobase/plug.in b/storage/innobase/plug.in index fc1d758fd87..028937882b2 100644 --- a/storage/innobase/plug.in +++ b/storage/innobase/plug.in @@ -65,6 +65,7 @@ MYSQL_PLUGIN_ACTIONS(innobase, [ storage/innobase/sync/Makefile storage/innobase/thr/Makefile storage/innobase/trx/Makefile + storage/innobase/handler/Makefile storage/innobase/usr/Makefile) ]) From 80a8f2c12b23d9215bb94357b1a418e82a3b19eb Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Thu, 7 Sep 2006 12:12:52 -0700 Subject: [PATCH 104/119] Adding in a few more engines to the now defunct (but still used) handler enum's since its the only way to enable for partitioning. --- sql/handler.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/handler.h b/sql/handler.h index b331c47a370..a132ec46b4c 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -255,7 +255,11 @@ enum legacy_db_type DB_TYPE_BLACKHOLE_DB, DB_TYPE_PARTITION_DB, DB_TYPE_BINLOG, - DB_TYPE_FIRST_DYNAMIC=32, + DB_TYPE_SOLID, + DB_TYPE_PBXT, + DB_TYPE_TABLE_FUNCTION, + DB_TYPE_MEMCACHE, + DB_TYPE_FIRST_DYNAMIC=42, DB_TYPE_DEFAULT=127 // Must be last }; From 7cc71499dbeabfacdabd06e76e5cc7bf96f12aa4 Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Thu, 7 Sep 2006 12:34:12 -0700 Subject: [PATCH 105/119] Fix for a compile problem in Windows. --- sql/CMakeLists.txt | 2 +- storage/innobase/handler/ha_innodb.cc | 28 --------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 132362c43d1..a089278448c 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -28,7 +28,7 @@ ADD_DEFINITIONS(-DHAVE_ROW_BASED_REPLICATION -DMYSQL_SERVER ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc discover.cc ../libmysql/errmsg.c field.cc field_conv.cc filesort.cc gstream.cc - ha_innodb.cc ha_partition.cc + ha_partition.cc handler.cc hash_filo.cc hash_filo.h hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc item_create.cc item_func.cc item_geofunc.cc item_row.cc diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 9bf347a1f29..405b5f14bb8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1599,21 +1599,6 @@ innobase_init(void) pthread_cond_init(&commit_cond, NULL); innodb_inited= 1; - /* If this is a replication slave and we needed to do a crash recovery, - set the master binlog position to what InnoDB internally knew about - how far we got transactions durable inside InnoDB. There is a - problem here: if the user used also MyISAM tables, InnoDB might not - know the right position for them. - - THIS DOES NOT WORK CURRENTLY because replication seems to initialize - glob_mi also after innobase_init. */ - -/* if (trx_sys_mysql_master_log_pos != -1) { - ut_memcpy(glob_mi.log_file_name, trx_sys_mysql_master_log_name, - 1 + ut_strlen(trx_sys_mysql_master_log_name)); - glob_mi.pos = trx_sys_mysql_master_log_pos; - } -*/ DBUG_RETURN(FALSE); error: have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler @@ -1688,19 +1673,6 @@ innobase_commit_low( return; } -#ifdef DISABLED_HAVE_REPLICATION - THD *thd=current_thd; - - if (thd && thd->slave_thread) { - /* Update the replication position info inside InnoDB */ - - trx->mysql_master_log_file_name - = active_mi->rli.group_master_log_name; - trx->mysql_master_log_pos = ((ib_longlong) - active_mi->rli.future_group_master_log_pos); - } -#endif /* HAVE_REPLICATION */ - trx_commit_for_mysql(trx); } From 0668eee26125edbd87ac6c5ed0026fcfc93ca44b Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Thu, 7 Sep 2006 12:35:52 -0700 Subject: [PATCH 106/119] Add support for Falcon, so that partitioning can be tested. --- sql/handler.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/handler.h b/sql/handler.h index a132ec46b4c..abc3e18d7a0 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -259,6 +259,7 @@ enum legacy_db_type DB_TYPE_PBXT, DB_TYPE_TABLE_FUNCTION, DB_TYPE_MEMCACHE, + DB_TYPE_FALCON, DB_TYPE_FIRST_DYNAMIC=42, DB_TYPE_DEFAULT=127 // Must be last }; From aa52207c11e96b561315872a897a7d6618830dc9 Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Thu, 7 Sep 2006 16:17:16 -0700 Subject: [PATCH 107/119] Warning fixes for Windows, and an include fix for Windows for Innodb. --- storage/archive/azio.c | 4 ++-- storage/federated/ha_federated.cc | 8 +++----- storage/innobase/CMakeLists.txt | 7 ++++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/storage/archive/azio.c b/storage/archive/azio.c index 45bad474d95..7cbe6a2a17d 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -125,7 +125,7 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd) buffer[8] = 0 /*xflags*/; buffer[9] = 0x03; s->start = 10L; - my_write(s->file, buffer, s->start, MYF(0)); + my_write(s->file, buffer, (uint)s->start, MYF(0)); /* We use 10L instead of ftell(s->file) to because ftell causes an * fflush on some systems. This version of the library doesn't use * start anyway in write mode, so this initialization is not @@ -503,7 +503,7 @@ int azrewind (s) if (!s->transparent) (void)inflateReset(&s->stream); s->in = 0; s->out = 0; - return my_seek(s->file, s->start, MY_SEEK_SET, MYF(0)); + return my_seek(s->file, (int)s->start, MY_SEEK_SET, MYF(0)); } /* =========================================================================== diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 456b6c73f3c..3e9759136bf 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -1263,7 +1263,6 @@ bool ha_federated::create_where_from_key(String *to, if (tmp.append(STRING_WITH_LEN(") "))) goto err; -next_loop: if (store_length >= length) break; DBUG_PRINT("info", ("remainder %d", remainder)); @@ -2016,8 +2015,8 @@ int ha_federated::delete_row(const byte *buf) { DBUG_RETURN(stash_remote_error()); } - stats.deleted+= mysql->affected_rows; - stats.records-= mysql->affected_rows; + stats.deleted+= (ha_rows)mysql->affected_rows; + stats.records-= (ha_rows)mysql->affected_rows; DBUG_PRINT("info", ("rows deleted %d rows deleted for all time %d", int(mysql->affected_rows), stats.deleted)); @@ -2373,7 +2372,6 @@ int ha_federated::rnd_next(byte *buf) int ha_federated::read_next(byte *buf, MYSQL_RES *result) { int retval; - my_ulonglong num_rows; MYSQL_ROW row; DBUG_ENTER("ha_federated::read_next"); @@ -2867,7 +2865,7 @@ int ha_federated::connection_autocommit(bool state) { const char *text; DBUG_ENTER("ha_federated::connection_autocommit"); - text= (state == true) ? "SET AUTOCOMMIT=1" : "SET AUTOCOMMIT=0"; + text= (state == TRUE) ? "SET AUTOCOMMIT=1" : "SET AUTOCOMMIT=0"; DBUG_RETURN(execute_simple_query(text, 16)); } diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 8e456993413..8a6260ecc7b 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -2,7 +2,12 @@ #SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/handler include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib + include + handler + ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/extra/yassl/include) ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c data/data0data.c data/data0type.c From 5ac62fd1d60bb7c425942d5b140b4085c9049378 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 8 Sep 2006 15:42:49 +0200 Subject: [PATCH 108/119] Bug#21855 Compilation error in ha_innodb.cc - Add ifdefs in ha_innodb.cc so it's only compiled if we have selected to build mysqld with innodb. This is inline with how it's done in other handlers. --- sql/ha_innodb.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 1665c7c011a..1b050d2ceed 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -32,6 +32,8 @@ have disables the InnoDB inlining in this file. */ #endif #include "mysql_priv.h" +#ifdef WITH_INNOBASE_STORAGE_ENGINE + #include "slave.h" #include @@ -7622,3 +7624,4 @@ mysql_declare_plugin(innobase) } mysql_declare_plugin_end; +#endif From 8ce37febef0180abfa9a07186d92d48ce9f5328c Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 8 Sep 2006 15:55:11 +0200 Subject: [PATCH 109/119] Fix problem running mysql-test-run.pl when running in a clone not compiled with ndb support --- mysql-test/mysql-test-run.pl | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 90f7c258c91..82753c1bd2e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1333,7 +1333,8 @@ sub environment_setup () { # -------------------------------------------------------------------------- if ( $opt_source_dist ) { - $extra_ld_library_paths= "$glob_basedir/libmysql/.libs/"; + $extra_ld_library_paths= "$glob_basedir/libmysql/.libs/" . + ":$glob_basedir/libmysql_r/.libs/"; } else { @@ -1346,26 +1347,20 @@ sub environment_setup () { $extra_ld_library_paths .= ":" . ($lib_udf_example ? dirname($lib_udf_example) : ""); + # -------------------------------------------------------------------------- + # Add the path where libndbclient can be found + # -------------------------------------------------------------------------- + if ( $opt_ndbcluster_supported ) + { + $extra_ld_library_paths .= ":$glob_basedir/storage/ndb/src/.libs"; + } + $ENV{'LD_LIBRARY_PATH'}= "$extra_ld_library_paths" . ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : ""); $ENV{'DYLD_LIBRARY_PATH'}= "$extra_ld_library_paths" . ($ENV{'DYLD_LIBRARY_PATH'} ? ":$ENV{'DYLD_LIBRARY_PATH'}" : ""); - # -------------------------------------------------------------------------- - # Add the path where libndbclient can be found - # -------------------------------------------------------------------------- - $ENV{'LD_LIBRARY_PATH'}= - (mtr_path_exists("$glob_basedir/storage/ndb/src/.libs") ? "$glob_basedir/storage/ndb/src/.libs" : "") . - ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : ""); - - # -------------------------------------------------------------------------- - # Add the path where libmysqlclient can be found - # -------------------------------------------------------------------------- - $ENV{'LD_LIBRARY_PATH'}= - (mtr_path_exists("$glob_basedir/libmysql_r/.libs") ? "$glob_basedir/libmysql_r/.libs" : "") . - ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : ""); - # -------------------------------------------------------------------------- # Also command lines in .opt files may contain env vars From d54cbe91205a50d9caedb3b6822e330f0ff683c1 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 8 Sep 2006 16:26:35 +0200 Subject: [PATCH 110/119] "crash_commit_before" need innodb --- mysql-test/t/crash_commit_before.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/crash_commit_before.test b/mysql-test/t/crash_commit_before.test index 4a0453901bc..c46340d44dc 100644 --- a/mysql-test/t/crash_commit_before.test +++ b/mysql-test/t/crash_commit_before.test @@ -1,4 +1,5 @@ --source include/have_debug.inc +--source include/have_innodb.inc CREATE TABLE t1(a int) engine=innodb; START TRANSACTION; From 28b90bfab5104efa3c1a4a80fb9e85b64880dabb Mon Sep 17 00:00:00 2001 From: "serg@janus.mylan" <> Date: Sat, 9 Sep 2006 10:39:12 +0200 Subject: [PATCH 111/119] bugfix --- sql/sql_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index cc20e22ab32..84810fb3324 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -967,7 +967,6 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, for (idx= 0; idx < total; idx++) { - plugin= plugins[idx]; if (unlikely(version != plugin_array_version)) { rw_rdlock(&THR_LOCK_plugin); @@ -976,6 +975,7 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, plugins[i]=0; rw_unlock(&THR_LOCK_plugin); } + plugin= plugins[idx]; if (plugin && func(thd, plugin, arg)) goto err; } From a1810201f666e5579c361c3336fdc825bd4f287b Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Mon, 11 Sep 2006 12:15:04 +0200 Subject: [PATCH 112/119] Use the mtr_file_exists function to detect if ndbapi_example is available --- mysql-test/mysql-test-run.pl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 7a58ba3af1c..bbf2a9e2cca 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1238,8 +1238,7 @@ sub executable_setup () { "/usr/bin/false"); $path_ndb_tools_dir= mtr_path_exists("$glob_basedir/storage/ndb/tools"); $path_ndb_examples_dir= mtr_path_exists("$glob_basedir/storage/ndb/ndbapi-examples"); - $exe_ndb_example= mtr_exe_exists("$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple", - $exe_mysqld); + $exe_ndb_example= mtr_file_exists("$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple"); $exe_ndb_mgm= "$glob_basedir/storage/ndb/src/mgmclient/ndb_mgm"; $exe_ndb_waiter= "$glob_basedir/storage/ndb/tools/ndb_waiter"; $exe_ndbd= "$glob_basedir/storage/ndb/src/kernel/ndbd"; @@ -1419,7 +1418,7 @@ sub environment_setup () { $ENV{'NDB_CONNECTSTRING'}= $opt_ndbconnectstring; $ENV{'NDB_EXAMPLES_DIR'}= $path_ndb_examples_dir; - $ENV{'MY_NDB_EXAMPLES_BINARY'}= ($exe_ndb_example eq "$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple")?$exe_ndb_example:""; + $ENV{'MY_NDB_EXAMPLES_BINARY'}= $exe_ndb_example; $ENV{'NDB_EXAMPLES_OUTPUT'}= $file_ndb_testrun_log; # ---------------------------------------------------- From 9b18cae31bc9c56fc3852e8f61d34b83a6583e7d Mon Sep 17 00:00:00 2001 From: "cmiller@maint1.mysql.com" <> Date: Tue, 12 Sep 2006 03:39:58 +0200 Subject: [PATCH 113/119] Change stolen from the -win tree. More specifically, the scripts/Makefile isn't created and it doesn't translate mysql_fix_privilege_tables ".sh" . So, mysql-test/mysql-test-run.pl doesn't find the binary and substitutes /bin/false instead. That obviously doesn't "fix" anything and the test fails because of it. --- mysql-test/t/system_mysql_db_fix.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test index 14132f5af11..daba3b6ff86 100644 --- a/mysql-test/t/system_mysql_db_fix.test +++ b/mysql-test/t/system_mysql_db_fix.test @@ -1,6 +1,9 @@ # Embedded server doesn't support external clients --source include/not_embedded.inc +# Windows doesn't support execution of shell scripts (to fix!!) +--source include/not_windows.inc + # check that CSV engine was compiled in, as the test relies on the presence # of the log tables (which are CSV-based) --source include/have_csv.inc From db89fb33aa26ed68d2e17b732fe2d0e208798bdc Mon Sep 17 00:00:00 2001 From: "rburnett@production.mysql.com" <> Date: Tue, 12 Sep 2006 04:46:41 +0200 Subject: [PATCH 114/119] log.cc: Fixing failed merge --- sql/log.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 9ffa1653909..8a8262c174d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3969,12 +3969,15 @@ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, */ #ifdef EMBEDDED_LIBRARY -void vprint_msg_to_log(enum loglevel level __attribute__((unused)), +int vprint_msg_to_log(enum loglevel level __attribute__((unused)), const char *format __attribute__((unused)), va_list argsi __attribute__((unused))) -{} +{ + DBUG_ENTER("vprint_msg_to_log"); + DBUG_RETURN(0); +} #else /*!EMBEDDED_LIBRARY*/ -void vprint_msg_to_log(enum loglevel level, const char *format, va_list args) +int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) { char buff[1024]; uint length; From 323efcc0c185e69b1dc35fa6f637aae5905d8080 Mon Sep 17 00:00:00 2001 From: "Kristofer.Pettersson@naruto." <> Date: Tue, 12 Sep 2006 14:23:41 +0200 Subject: [PATCH 115/119] Bug#20789 Merge Subtable Rename Causes Crash - When an ALTER TABLE RENAME is performed on windows, the files are closed and their cached file descriptors are marked invalid. Performing INSERT, UPDATE or SELECT on the associated merge table causes a server crash on windows. This patch adds a test for bad file descriptors when a table attempts a lock. If a bad descriptor is found an error is thrown. An additional FLUSH TABLES will be necessary to further operate on the associated merge table. --- myisam/mi_locking.c | 11 +++++++++++ mysql-test/r/windows.result | 28 ++++++++++++++++++++++++++ mysql-test/t/windows.test | 39 +++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 8d48c5242e5..4f8420d4b12 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -223,7 +223,18 @@ int mi_lock_database(MI_INFO *info, int lock_type) default: break; /* Impossible */ } + } +#ifdef __WIN__ + else + { + /* + The file has been closed and kfile is -1. + See mi_extra.c about implementation of + HA_EXTRA_PREPARE_FOR_DELETE. + */ + error=HA_ERR_NO_SUCH_TABLE; } +#endif pthread_mutex_unlock(&share->intern_lock); #if defined(FULL_LOG) || defined(_lint) lock_type|=(int) (flag << 8); /* Set bit to set if real lock */ diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index 039c5b1476e..e3241daf719 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -6,3 +6,31 @@ use prn; ERROR 42000: Unknown database 'prn' create table nu (a int); drop table nu; +CREATE TABLE `t1` ( +`TIM` datetime NOT NULL, +`VAL` double default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +CREATE TABLE `t2` ( +`TIM` datetime NOT NULL, +`VAL` double default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +CREATE TABLE `mt` ( +`TIM` datetime NOT NULL, +`VAL` double default NULL +) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST +UNION=(`t1`,`t2`); +INSERT INTO mt VALUES ('2006-01-01',0); +ALTER TABLE `t2` RENAME TO `t`; +INSERT INTO mt VALUES ('2006-01-01',0); +ERROR HY000: Can't lock file (errno: 155) +select * from mt; +ERROR HY000: Can't lock file (errno: 155) +FLUSH TABLES; +select * from mt; +ERROR HY000: Can't find file: 'mt' (errno: 2) +ALTER TABLE `t` RENAME TO `t2`; +INSERT INTO mt VALUES ('2006-01-01',0); +select * from mt; +TIM VAL +2006-01-01 00:00:00 0 +2006-01-01 00:00:00 0 diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test index d6bcfeb8cb3..79517df6517 100644 --- a/mysql-test/t/windows.test +++ b/mysql-test/t/windows.test @@ -18,3 +18,42 @@ create table nu (a int); drop table nu; # End of 4.1 tests + +# +# Bug #20789: Merge Subtable Rename Causes Crash +# +CREATE TABLE `t1` ( + `TIM` datetime NOT NULL, + `VAL` double default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +CREATE TABLE `t2` ( + `TIM` datetime NOT NULL, + `VAL` double default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +CREATE TABLE `mt` ( + `TIM` datetime NOT NULL, + `VAL` double default NULL +) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST +UNION=(`t1`,`t2`); + +# insert into the merge table and thus open it. +INSERT INTO mt VALUES ('2006-01-01',0); + +# Alter one of the tables that are part of the merge table +ALTER TABLE `t2` RENAME TO `t`; + +# Insert into the merge table that has just been altered +--error 1015 +INSERT INTO mt VALUES ('2006-01-01',0); +--error 1015 +select * from mt; + +FLUSH TABLES; +--error 1017 +select * from mt; + +# Alter one of the tables that are part of the merge table +ALTER TABLE `t` RENAME TO `t2`; +INSERT INTO mt VALUES ('2006-01-01',0); +select * from mt; + From 4f30db1f26cacd41c2923d18f8145d776bdbbe54 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Tue, 12 Sep 2006 16:34:12 +0200 Subject: [PATCH 116/119] Bug #21378 Alter table from X storage engine to NDB could cause data loss: don't overwrite local tables when pushing out schema changes --- sql/ha_ndbcluster_binlog.cc | 56 ++++++++++++++++++++++++++++++++----- sql/ha_ndbcluster_binlog.h | 2 ++ 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 4e59e0ef22a..a22bc392fca 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -1579,10 +1579,12 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, dbname, tabname)); build_table_filename(key, FN_LEN-1, dbname, tabname, NullS, 0); /* - If the frm of the altered table is different than the one on - disk then overwrite it with the new table definition + If the there is no local table shadowing the altered table and + it has an frm that is different than the one on disk then + overwrite it with the new table definition */ - if (readfrm(key, &data, &length) == 0 && + if (!ndbcluster_check_if_local_table(dbname, tabname) && + readfrm(key, &data, &length) == 0 && packfrm(data, length, &pack_data, &pack_length) == 0 && cmp_frm(altered_table, pack_data, pack_length)) { @@ -1799,7 +1801,16 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, // fall through case SOT_CREATE_TABLE: pthread_mutex_lock(&LOCK_open); - if (ndb_create_table_from_engine(thd, schema->db, schema->name)) + if (ndbcluster_check_if_local_table(schema->db, schema->name)) + { + DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'", + schema->db, schema->name, schema->query)); + sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from " + "binlog schema event '%s' from node %d. ", + schema->db, schema->name, schema->query, + schema->node_id); + } + else if (ndb_create_table_from_engine(thd, schema->db, schema->name)) { sql_print_error("NDB binlog: Could not discover table '%s.%s' from " "binlog schema event '%s' from node %d. " @@ -2050,9 +2061,18 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, share= 0; } pthread_mutex_lock(&LOCK_open); - if (ndb_create_table_from_engine(thd, schema->db, schema->name)) - { - sql_print_error("NDB binlog: Could not discover table '%s.%s' from " + if (ndbcluster_check_if_local_table(schema->db, schema->name)) + { + DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'", + schema->db, schema->name, schema->query)); + sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from " + "binlog schema event '%s' from node %d. ", + schema->db, schema->name, schema->query, + schema->node_id); + } + else if (ndb_create_table_from_engine(thd, schema->db, schema->name)) + { + sql_print_error("NDB binlog: Could not discover table '%s.%s' from " "binlog schema event '%s' from node %d. my_errno: %d", schema->db, schema->name, schema->query, schema->node_id, my_errno); @@ -2290,6 +2310,28 @@ ndb_rep_event_name(String *event_name,const char *db, const char *tbl) } } +bool +ndbcluster_check_if_local_table(const char *dbname, const char *tabname) +{ + char key[FN_REFLEN]; + char ndb_file[FN_REFLEN]; + + DBUG_ENTER("ndbcluster_check_if_local_table"); + build_table_filename(key, FN_LEN-1, dbname, tabname, reg_ext, 0); + build_table_filename(ndb_file, FN_LEN-1, dbname, tabname, ha_ndb_ext, 0); + /* Check that any defined table is an ndb table */ + DBUG_PRINT("info", ("Looking for file %s and %s", key, ndb_file)); + if ((! my_access(key, F_OK)) && my_access(ndb_file, F_OK)) + { + DBUG_PRINT("info", ("table file %s not on disk, local table", ndb_file)); + + + DBUG_RETURN(true); + } + + DBUG_RETURN(false); +} + /* Common function for setting up everything for logging a table at create/discover. diff --git a/sql/ha_ndbcluster_binlog.h b/sql/ha_ndbcluster_binlog.h index 4c3cd105d1d..774efb5984c 100644 --- a/sql/ha_ndbcluster_binlog.h +++ b/sql/ha_ndbcluster_binlog.h @@ -122,6 +122,8 @@ void ndbcluster_binlog_init_handlerton(); */ void ndbcluster_binlog_init_share(NDB_SHARE *share, TABLE *table); +bool ndbcluster_check_if_local_table(const char *dbname, const char *tabname); + int ndbcluster_create_binlog_setup(Ndb *ndb, const char *key, uint key_len, const char *db, From 7b7e66763cf1e34c76b8fe8c53d5f07dda909faf Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 12 Sep 2006 16:43:57 +0200 Subject: [PATCH 117/119] Correct faulty merge, "mysql_priv.h" must be included for the ifdef WITH_INNOBASE_STORAGE_ENGINE to work --- storage/innobase/handler/ha_innodb.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e5d1159a96a..754afa89378 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -31,10 +31,10 @@ have disables the InnoDB inlining in this file. */ #pragma implementation // gcc: Class implementation #endif -#ifdef WITH_INNOBASE_STORAGE_ENGINE - #include +#ifdef WITH_INNOBASE_STORAGE_ENGINE + #include #include #include From 38a450b44a64176effcc94a26f65f3d049fd2b73 Mon Sep 17 00:00:00 2001 From: "timour/timka@lamia.home" <> Date: Tue, 12 Sep 2006 17:50:24 +0300 Subject: [PATCH 118/119] Fix for BUG#21774: Column count doesn't match value count at row x The cause of the bug was an incomplete fix for bug 18080. The problem was that setup_tables() unconditionally reset the name resolution context to its 'tables' argument, which pointed to the first table of an SQL statement. The bug fix limits resetting of the name resolution context in setup_tables() only in the cases when the context was not set by earlier parser/optimizer phases. --- mysql-test/r/insert_select.result | 10 ++++++++++ mysql-test/t/insert_select.test | 18 ++++++++++++++++++ sql/sql_base.cc | 15 ++++++++++++++- sql/sql_insert.cc | 9 +++++++++ sql/sql_parse.cc | 2 -- 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 89ac863b8d2..0af48d27cd5 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -695,6 +695,16 @@ CREATE TABLE t2 (z int, y int); CREATE TABLE t3 (a int, b int); INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1); DROP TABLE IF EXISTS t1,t2,t3; +CREATE DATABASE bug21774_1; +CREATE DATABASE bug21774_2; +CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255)); +CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255)); +CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255)); +INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1; +use bug21774_1; +INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1; +DROP DATABASE bug21774_1; +DROP DATABASE bug21774_2; CREATE DATABASE meow; CREATE TABLE table_target ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id)); CREATE TABLE table_target2 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id)); diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index b6b94d07e87..6f86ed897ac 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -248,6 +248,24 @@ CREATE TABLE t3 (a int, b int); INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1); DROP TABLE IF EXISTS t1,t2,t3; +# +# Bug #21774: Column count doesn't match value count at row x +# +CREATE DATABASE bug21774_1; +CREATE DATABASE bug21774_2; + +CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255)); +CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255)); +CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255)); + +INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1; + +use bug21774_1; +INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1; + +DROP DATABASE bug21774_1; +DROP DATABASE bug21774_2; + # # Bug #20989: View '(null).(null)' references invalid table(s)... on # SQL SECURITY INVOKER diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3a12477bc15..c29c610b200 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4453,7 +4453,20 @@ bool setup_tables(THD *thd, Name_resolution_context *context, uint tablenr= 0; DBUG_ENTER("setup_tables"); - context->table_list= context->first_name_resolution_table= tables; + /* + Due to the various call paths that lead to setup_tables() it may happen + that context->table_list and context->first_name_resolution_table can be + NULL (this is typically done when creating TABLE_LISTs internally). + TODO: + Investigate all cases when this my happen, initialize the name resolution + context correctly in all those places, and remove the context reset below. + */ + if (!context->table_list || !context->first_name_resolution_table) + { + /* Test whether the context is in a consistent state. */ + DBUG_ASSERT(!context->first_name_resolution_table && !context->table_list); + context->table_list= context->first_name_resolution_table= tables; + } /* this is used for INSERT ... SELECT. diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c08deedea72..b70d11e4b26 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -411,6 +411,15 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, table= table_list->table; context= &thd->lex->select_lex.context; + /* + These three asserts test the hypothesis that the resetting of the name + resolution context below is not necessary at all since the list of local + tables for INSERT always consists of one table. + */ + DBUG_ASSERT(!table_list->next_local); + DBUG_ASSERT(!context->table_list->next_local); + DBUG_ASSERT(!context->first_name_resolution_table->next_name_resolution_table); + /* Save the state of the current name resolution context. */ ctx_state.save_state(context, table_list); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0e3bd7934eb..905e8cdc71a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3344,8 +3344,6 @@ end_with_restore_list: DBUG_ASSERT(first_table == all_tables && first_table != 0); if ((res= insert_precheck(thd, all_tables))) break; - /* Skip first table, which is the table we are inserting in */ - select_lex->context.table_list= first_table->next_local; if (!thd->locked_tables && !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) From 6c472b9a9d85e94c04bb10de07fe81c1f442a0a1 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Wed, 13 Sep 2006 13:41:05 +0200 Subject: [PATCH 119/119] Bug #21378 Alter table from X storage engine to NDB could cause data loss: post review fix --- sql/ha_ndbcluster_binlog.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index a22bc392fca..2d70e953f91 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -1804,7 +1804,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, if (ndbcluster_check_if_local_table(schema->db, schema->name)) { DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'", - schema->db, schema->name, schema->query)); + schema->db, schema->name)); sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from " "binlog schema event '%s' from node %d. ", schema->db, schema->name, schema->query, @@ -2064,7 +2064,7 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, if (ndbcluster_check_if_local_table(schema->db, schema->name)) { DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'", - schema->db, schema->name, schema->query)); + schema->db, schema->name)); sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from " "binlog schema event '%s' from node %d. ", schema->db, schema->name, schema->query,