From a88f4ea30f378234716e06d64dbc437babe79506 Mon Sep 17 00:00:00 2001 From: "hf@deer.(none)" <> Date: Sat, 8 Nov 2003 16:43:16 +0400 Subject: [PATCH 01/89] Fix for bug #1727 ( Crash in EXPLAIN & UNION & derived) another version of the fix. Here i removed a loop that seems to be superfluous --- mysql-test/r/derived.result | 17 +++++++++++++++++ mysql-test/t/derived.test | 6 ++++++ sql/sql_lex.cc | 31 ++----------------------------- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 37742893c2b..c59b68e4c4d 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -228,3 +228,20 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using where 3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where drop table t1; +create table t1 (a int); +insert into t1 values (1),(2); +select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +a a +1 1 +2 1 +1 2 +2 2 +explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 +1 PRIMARY ALL NULL NULL NULL NULL 2 +4 DERIVED t1 ALL NULL NULL NULL NULL 2 +5 UNION t1 ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 +3 UNION t1 ALL NULL NULL NULL NULL 2 +drop table t1; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 80b131ac6fe..ca881f73a4f 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -132,3 +132,9 @@ insert into t1 VALUES(1,1,1), (2,2,1); select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2; explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2; drop table t1; + +create table t1 (a int); +insert into t1 values (1),(2); +select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +drop table t1; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index a55b801a0fc..5fa6c088a16 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1269,28 +1269,6 @@ bool st_select_lex::test_limit() return(0); } - - - - - - - - - - - - - - - - - - - - - - /* Interface method of table list creation for query @@ -1315,13 +1293,8 @@ bool st_select_lex_unit::create_total_list(THD *thd, st_lex *lex, bool check_derived) { *result= 0; - for (SELECT_LEX_UNIT *unit= this; unit; unit= unit->next_unit()) - { - if ((res= unit->create_total_list_n_last_return(thd, lex, &result, - check_derived))) - return res; - } - return 0; + res= create_total_list_n_last_return(thd, lex, &result, check_derived); + return res; } /* From 05b3ff393ffed1d69e6ef7e5258d33280587c064 Mon Sep 17 00:00:00 2001 From: "serg@sergbook.mylan" <> Date: Sat, 8 Nov 2003 15:39:10 +0100 Subject: [PATCH 02/89] fulltext.test, fulltext.result: one simple trunc* test --- mysql-test/r/fulltext.result | 14 ++++++++++++++ mysql-test/t/fulltext.test | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 737390865f1..8f1f90e9f76 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -134,6 +134,20 @@ Only MyISAM tables support collections Function MATCH ... AGAINST() is used to do a search some test foobar implements vector space model drop table t1; +create table t1 (a varchar(200) not null, fulltext (a)); +insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); +select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); +a +aaa10 bbb20 +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); +a +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +a +drop table t1; CREATE TABLE t1 ( id int(11), ticket int(11), diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 387a36f1f52..e2293094258 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -70,6 +70,16 @@ delete from t1 where MATCH(a,b) AGAINST ("indexes"); select * from t1; drop table t1; +# +# why to scan strings for trunc* +# +create table t1 (a varchar(200) not null, fulltext (a)); +insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); +select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); +select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); +select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +drop table t1; + # # Check bug reported by Matthias Urlichs # From 9837748e5fa7baaeaa3f5d084571df5c05a7057e Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 14 Nov 2003 22:08:45 +0100 Subject: [PATCH 03/89] obligatory update checksum on repair, if it is obligatory verified on check. --- myisam/mi_check.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index a4ae7b25dbb..466defe8fbc 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1153,6 +1153,9 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + if (!param->using_global_keycache) VOID(init_key_cache(param->use_buffers)); @@ -1820,6 +1823,9 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); bzero((char *)&sort_param, sizeof(sort_param)); if (!(sort_info.key_block= @@ -2189,6 +2195,9 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); if (!(sort_info.key_block= alloc_key_blocks(param, From 60d60a299e9b8a4b99d83b99b1cde4634f95e20c Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sun, 16 Nov 2003 17:37:15 +0100 Subject: [PATCH 04/89] Item_uint::save_in_field() added to take into account bigint->decimal case --- .bzrignore | 1 + mysql-test/r/bigint.result | 8 ++++++++ mysql-test/t/bigint.test | 12 ++++++++++++ sql/item.cc | 13 +++++++++++++ sql/item.h | 3 ++- 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index 3dcf46841d9..12cdf99cbc9 100644 --- a/.bzrignore +++ b/.bzrignore @@ -540,3 +540,4 @@ libmysql/vio_priv.h libmysql_r/vio_priv.h hardcopy.0 scripts/make_sharedlib_distribution +sql/udf_example.so diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index d7d811dc5f3..2b595c2b83d 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -67,3 +67,11 @@ select * from t1 limit 9999999999; id a 9999999999 1 drop table t1; +CREATE TABLE t1 ( quantity decimal(60,0)); +insert into t1 values (10000000000000000000); +insert into t1 values ('10000000000000000000'); +select * from t1; +quantity +10000000000000000000 +10000000000000000000 +drop table t1; diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index c5691a760c7..a7cc068ec46 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -46,3 +46,15 @@ insert into t1 values (null,1); select * from t1; select * from t1 limit 9999999999; drop table t1; + +# +# Item_uint::save_to_field() +# BUG#1845 +# + +CREATE TABLE t1 ( quantity decimal(60,0)); +insert into t1 values (10000000000000000000); +insert into t1 values ('10000000000000000000'); +select * from t1; +drop table t1; + diff --git a/sql/item.cc b/sql/item.cc index 0e9085180cd..65eb7f1befd 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -548,6 +548,19 @@ bool Item_string::save_in_field(Field *field, bool no_conversions) return 0; } +bool Item_uint::save_in_field(Field *field, bool no_conversions) +{ + longlong nr=val_int(); + if (null_value) + return set_field_to_null(field); + field->set_notnull(); + if (nr < 0) + field->store(ulonglong2double(nr)); + else + field->store(nr); + return 0; +} + bool Item_int::save_in_field(Field *field, bool no_conversions) { longlong nr=val_int(); diff --git a/sql/item.h b/sql/item.h index 25650e85434..d23a061eedb 100644 --- a/sql/item.h +++ b/sql/item.h @@ -232,13 +232,14 @@ public: String *val_str(String*); void make_field(Send_field *field); Item *new_item() { return new Item_uint(name,max_length); } + bool save_in_field(Field *field, bool no_conversions); bool fix_fields(THD *thd,struct st_table_list *table_list) { unsigned_flag= 1; return 0; } void print(String *str); - unsigned int size_of() { return sizeof(*this);} + unsigned int size_of() { return sizeof(*this);} }; From 8377acc7d1baa928300c8061f9c4e5af5c88d5b2 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Tue, 18 Nov 2003 17:31:17 +0100 Subject: [PATCH 05/89] Fix for BUG#1870 "CHANGE MASTER makes SQL thread restart from coordinates of I/O thread". So, in CHANGE MASTER: when it seems reasonable that the user did not want to discontinue its replication (i.e. when he is not specifying host or port or master_log_file or master_log_pos; this will be documented), set the coordinates of the I/O thread to those of the SQL thread. This way, the SQL thread will see no discontinuity in the relay log (i.e. will skip no events), because the I/O thread will fill the brand new relay log with the events which are just after the position where the SQL thread had stopped (before CHANGE MASTER was issued). And a new test for this bug. --- mysql-test/r/rpl_change_master.result | 32 +++++++++++++++++ mysql-test/r/rpl_loaddata.result | 2 +- mysql-test/t/rpl_change_master.test | 26 ++++++++++++++ sql/sql_repl.cc | 49 ++++++++++++++++++++++++--- 4 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 mysql-test/r/rpl_change_master.result create mode 100644 mysql-test/t/rpl_change_master.test diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result new file mode 100644 index 00000000000..be2aec616b0 --- /dev/null +++ b/mysql-test/r/rpl_change_master.result @@ -0,0 +1,32 @@ +slave stop; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +slave start; +select get_lock("a",5); +get_lock("a",5) +1 +create table t1(n int); +insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(2); +stop slave; +select * from t1; +n +1 +show slave status; +Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space +127.0.0.1 root 9306 1 master-bin.001 273 slave-relay-bin.002 255 master-bin.001 No No 0 0 214 314 +change master to master_user='root'; +show slave status; +Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space +127.0.0.1 root 9306 1 master-bin.001 214 slave-relay-bin.001 4 master-bin.001 No No 0 0 214 4 +select release_lock("a"); +release_lock("a") +1 +start slave; +select * from t1; +n +1 +2 +drop table t1; diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 8b910d0d183..268e383ce69 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -43,7 +43,7 @@ change master to master_user='test'; change master to master_user='root'; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.001 1442 slave-relay-bin.001 4 master-bin.001 No No 0 0 1442 4 +127.0.0.1 root MASTER_PORT 1 master-bin.001 1419 slave-relay-bin.001 4 master-bin.001 No No 0 0 1419 4 set global sql_slave_skip_counter=1; start slave; set sql_log_bin=0; diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test new file mode 100644 index 00000000000..61de22fe57b --- /dev/null +++ b/mysql-test/t/rpl_change_master.test @@ -0,0 +1,26 @@ +source include/master-slave.inc; + +connection slave; +select get_lock("a",5); +connection master; +create table t1(n int); +insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(2); +save_master_pos; +connection slave; +sleep 3; # can't sync_with_master as we should be blocked +stop slave; +select * from t1; +show slave status; +change master to master_user='root'; +show slave status; +# Will restart from after the values(2), which is bug +select release_lock("a"); +start slave; +sync_with_master; +select * from t1; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 10581431c72..c95cdc1b04e 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -853,8 +853,8 @@ void kill_zombie_dump_threads(uint32 slave_server_id) int change_master(THD* thd, MASTER_INFO* mi) { int thread_mask; - const char* errmsg=0; - bool need_relay_log_purge=1; + const char* errmsg= 0; + bool need_relay_log_purge= 1; DBUG_ENTER("change_master"); lock_slave_threads(mi); @@ -928,6 +928,36 @@ int change_master(THD* thd, MASTER_INFO* mi) mi->rli.relay_log_pos=lex_mi->relay_log_pos; } + /* + If user did specify neither host nor port nor any log name nor any log + pos, i.e. he specified only user/password/master_connect_retry, he probably + wants replication to resume from where it had left, i.e. from the + coordinates of the **SQL** thread (imagine the case where the I/O is ahead + of the SQL; restarting from the coordinates of the I/O would lose some + events which is probably unwanted when you are just doing minor changes + like changing master_connect_retry). + A side-effect is that if only the I/O thread was started, this thread may + restart from ''/4 after the CHANGE MASTER. That's a minor problem (it is a + much more unlikely situation than the one we are fixing here). + Note: coordinates of the SQL thread must be read here, before the + 'if (need_relay_log_purge)' block which resets them. + */ + if (!lex_mi->host && !lex_mi->port && + !lex_mi->log_file_name && !lex_mi->pos && + need_relay_log_purge) + { + /* + Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is + not initialized), so we use a max(). + What happens to mi->rli.master_log_pos during the initialization stages + of replication is not 100% clear, so we guard against problems using + max(). + */ + mi->master_log_pos = max(BIN_LOG_HEADER_SIZE, mi->rli.master_log_pos); + strmake(mi->master_log_name,mi->rli.master_log_name, + sizeof(mi->master_log_name)-1); + } + flush_master_info(mi); if (need_relay_log_purge) { @@ -959,10 +989,21 @@ int change_master(THD* thd, MASTER_INFO* mi) } } DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); - /* If changing RELAY_LOG_FILE or RELAY_LOG_POS, this will be nonsense: */ + + /* + Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block, + so restore them to good values. If we left them to ''/0, that would work; + but that would fail in the case of 2 successive CHANGE MASTER (without a + START SLAVE in between): because first one would set the coords in mi to + the good values of those in rli, the set those in rli to ''/0, then + second CHANGE MASTER would set the coords in mi to those of rli, i.e. to + ''/0: we have lost all copies of the original good coordinates. + That's why we always save good coords in rli. + */ mi->rli.master_log_pos = mi->master_log_pos; strmake(mi->rli.master_log_name,mi->master_log_name, - sizeof(mi->rli.master_log_name)-1); + sizeof(mi->rli.master_log_name)-1); + if (!mi->rli.master_log_name[0]) // uninitialized case mi->rli.master_log_pos=0; From 11f70bdfc41561e36d2eee288ce4dc5715ab622a Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 18 Nov 2003 22:06:47 +0100 Subject: [PATCH 06/89] Bug#1826, HANDLER+ALTER TABLE=crash (unfortunately, it cannot be tested in mysql-test suite) more user variable tests --- mysql-test/r/user_var.result | 19 +++++++++++++++++++ mysql-test/t/user_var.test | 11 +++++++++++ sql/sql_handler.cc | 13 +++++++++++++ 3 files changed, 43 insertions(+) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index d7c41d5dbc4..3e83438b273 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -97,3 +97,22 @@ drop table t1; select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b 10 2 1 10 2 1 10 2 1 10 2 1 +create table t1 (i int not null); +insert t1 values (1),(2),(2),(3),(3),(3); +select @a:=0; +@a:=0 +0 +select @a, @a:=@a+count(*), count(*), @a from t1 group by i; +@a @a:=@a+count(*) count(*) @a +0 1 1 0 +0 2 2 0 +0 3 3 0 +select @a:=0; +@a:=0 +0 +select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; +@a+0 @a:=@a+0+count(*) count(*) @a+0 +0 1 1 0 +1 3 2 0 +3 6 3 0 +drop table t1; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 56528405a2a..9cb5d5e1eb0 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -53,3 +53,14 @@ drop table t1; # just for fun :) select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; + +# +# bug#1739 +# Item_func_set_user_var sets update_query_id, Item_func_get_user_var checks it +# +create table t1 (i int not null); +insert t1 values (1),(2),(2),(3),(3),(3); +select @a:=0; select @a, @a:=@a+count(*), count(*), @a from t1 group by i; +select @a:=0; select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; +drop table t1; + diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index dd8dfb31163..208545a435b 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -285,7 +285,20 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db, { if (!memcmp(table->table_cache_key, db, dblen) && !my_strcasecmp((is_alias ? table->table_name : table->real_name),table_name)) + { + if (table->version != refresh_version) + { + VOID(pthread_mutex_lock(&LOCK_open)); + if (close_thread_table(thd, ptr)) + { + /* Tell threads waiting for refresh that something has happened */ + VOID(pthread_cond_broadcast(&COND_refresh)); + } + VOID(pthread_mutex_unlock(&LOCK_open)); + continue; + } break; + } ptr=&(table->next); } return ptr; From 0bd17351ca478557f2888bf70ad7e0e088e8011d Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Wed, 19 Nov 2003 17:31:57 +0200 Subject: [PATCH 07/89] Changed mysql_next_result() to return int instead of bool Changed ~Item_func_in() to call cleanup() (to fix memory leak) Fixed test_multi_statements() test in client_test --- include/mysql.h | 2 +- libmysql/libmysql.c | 15 +- sql/item_cmpfunc.cc | 62 ++-- sql/item_cmpfunc.h | 19 +- tests/client_test.c | 843 +++++++++++++++++++++++--------------------- 5 files changed, 507 insertions(+), 434 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index 2098ed0516a..b31c04c755b 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -604,7 +604,7 @@ MYSQL_RES *STDCALL mysql_param_result(MYSQL_STMT *stmt); my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt); int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt); my_bool STDCALL mysql_more_results(MYSQL *mysql); -my_bool STDCALL mysql_next_result(MYSQL *mysql); +int STDCALL mysql_next_result(MYSQL *mysql); MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset); MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 9c388f71314..eb57e433c44 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3317,7 +3317,7 @@ my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt) my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt) { MYSQL *mysql; - DBUG_ENTER("mysql_stmt_close"); + DBUG_ENTER("mysql_stmt_free_result"); DBUG_ASSERT(stmt != 0); @@ -3498,10 +3498,18 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql) Reads and returns the next query results */ -my_bool STDCALL mysql_next_result(MYSQL *mysql) +int STDCALL mysql_next_result(MYSQL *mysql) { DBUG_ENTER("mysql_next_result"); + if (mysql->status != MYSQL_STATUS_READY) + { + strmov(mysql->net.sqlstate, unknown_sqlstate); + strmov(mysql->net.last_error, + ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); + DBUG_RETURN(1); + } + mysql->net.last_error[0]= 0; mysql->net.last_errno= 0; strmov(mysql->net.sqlstate, not_error_sqlstate); @@ -3510,9 +3518,10 @@ my_bool STDCALL mysql_next_result(MYSQL *mysql) if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) DBUG_RETURN((*mysql->methods->read_query_result)(mysql)); - DBUG_RETURN(0); + DBUG_RETURN(-1); /* No more results */ } + MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql) { return (*mysql->methods->use_result)(mysql); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 8731e8fbe21..709b20e5a54 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1375,6 +1375,7 @@ cmp_item* cmp_item::get_comparator(Item *item) return 0; // to satisfy compiler :) } + cmp_item* cmp_item_sort_string::make_same() { return new cmp_item_sort_string_in_static(cmp_charset); @@ -1395,6 +1396,23 @@ cmp_item* cmp_item_row::make_same() return new cmp_item_row(); } + +cmp_item_row::~cmp_item_row() +{ + DBUG_ENTER("~cmp_item_row"); + DBUG_PRINT("enter",("this: %lx", this)); + if (comparators) + { + for (uint i= 0; i < n; i++) + { + if (comparators[i]) + delete comparators[i]; + } + } + DBUG_VOID_RETURN; +} + + void cmp_item_row::store_value(Item *item) { THD *thd= current_thd; @@ -1404,18 +1422,16 @@ void cmp_item_row::store_value(Item *item) item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= cmp_item::get_comparator(item->el(i)))) - { - comparators[i]->store_value(item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!(comparators[i]= cmp_item::get_comparator(item->el(i)))) + break; // new failed + comparators[i]->store_value(item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; } + void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) { cmp_item_row *tmpl= (cmp_item_row*) t; @@ -1430,19 +1446,17 @@ void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= tmpl->comparators[i]->make_same())) - { - comparators[i]->store_value_by_template(tmpl->comparators[i], - item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!(comparators[i]= tmpl->comparators[i]->make_same())) + break; // new failed + comparators[i]->store_value_by_template(tmpl->comparators[i], + item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; } + int cmp_item_row::cmp(Item *arg) { arg->null_value= 0; @@ -1454,25 +1468,31 @@ int cmp_item_row::cmp(Item *arg) bool was_null= 0; arg->bring_value(); for (uint i=0; i < n; i++) + { if (comparators[i]->cmp(arg->el(i))) { if (!arg->el(i)->null_value) return 1; was_null= 1; } + } return (arg->null_value= was_null); } + int cmp_item_row::compare(cmp_item *c) { - int res; cmp_item_row *cmp= (cmp_item_row *) c; for (uint i=0; i < n; i++) + { + int res; if ((res= comparators[i]->compare(cmp->comparators[i]))) return res; + } return 0; } + bool Item_func_in::nulls_in_row() { Item **arg,**arg_end; @@ -1484,6 +1504,7 @@ bool Item_func_in::nulls_in_row() return 0; } + static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) { return cs->coll->strnncollsp(cs, @@ -1491,6 +1512,7 @@ static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) (unsigned char *) y->ptr(),y->length()); } + void Item_func_in::fix_length_and_dec() { Item **arg, **arg_end; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index dac7a2d43eb..51c53e6c136 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -638,17 +638,7 @@ class cmp_item_row :public cmp_item uint n; public: cmp_item_row(): comparators(0), n(0) {} - ~cmp_item_row() - { - if (comparators) - { - for (uint i= 0; i < n; i++) - { - if (comparators[i]) - delete comparators[i]; - } - } - } + ~cmp_item_row(); void store_value(Item *item); int cmp(Item *arg); int compare(cmp_item *arg); @@ -694,7 +684,7 @@ public: cmp_item_string *cmp= (cmp_item_string *)c; return sortcmp(value_res, cmp->value_res, cmp_charset); } - cmp_item * make_same() + cmp_item *make_same() { return new cmp_item_sort_string_in_static(cmp_charset); } @@ -715,7 +705,10 @@ class Item_func_in :public Item_int_func } longlong val_int(); void fix_length_and_dec(); - ~Item_func_in() {} + ~Item_func_in() + { + cleanup(); /* This is not called by Item::~Item() */ + } void cleanup() { delete array; diff --git a/tests/client_test.c b/tests/client_test.c index 03c9c1ff3ae..517cac39d1b 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -72,60 +72,55 @@ static double total_time; static void print_error(const char *msg); static void print_st_error(MYSQL_STMT *stmt, const char *msg); -static void check_errcode(const unsigned int err); static void client_disconnect(); #define myerror(msg) print_error(msg) #define mysterror(stmt, msg) print_st_error(stmt, msg) -#define myerrno(n) check_errcode(n) - -#define myassert(exp) assert(exp) -#define myassert_r(exp) assert(!(exp)) #define myquery(r) \ { \ if (r) \ myerror(NULL); \ - myassert(r == 0); \ + assert(r == 0); \ } #define myquery_r(r) \ { \ if (r) \ myerror(NULL); \ -myassert_r(r == 0); \ +assert(r != 0); \ } #define mystmt(stmt,r) \ { \ if (r) \ mysterror(stmt,NULL); \ -myassert(r == 0);\ +assert(r == 0);\ } #define mystmt_r(stmt,r) \ { \ if (r) \ mysterror(stmt,NULL); \ -myassert_r(r == 0);\ +assert(r != 0);\ } #define mystmt_init(stmt) \ { \ if ( stmt == 0) \ myerror(NULL); \ -myassert(stmt != 0); \ +assert(stmt != 0); \ } #define mystmt_init_r(stmt) \ { \ if (stmt == 0) \ myerror(NULL);\ -myassert(stmt == 0);\ +assert(stmt == 0);\ } -#define mytest(x) if (!x) {myerror(NULL);myassert(TRUE);} -#define mytest_r(x) if (x) {myerror(NULL);myassert(TRUE);} +#define mytest(x) if (!x) {myerror(NULL);assert(TRUE);} +#define mytest_r(x) if (x) {myerror(NULL);assert(TRUE);} /******************************************************** * print the error message * @@ -143,16 +138,6 @@ static void print_error(const char *msg) else if (msg) fprintf(stderr, " [MySQL] %s\n", msg); } -static void check_errcode(const unsigned int err) -{ - if (mysql->server_version) - fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); - else - fprintf(stdout,"\n [MySQL]"); - fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); - myassert(mysql_errno(mysql) == err); -} - static void print_st_error(MYSQL_STMT *stmt, const char *msg) { if (stmt && mysql_stmt_errno(stmt)) @@ -523,7 +508,7 @@ static void verify_col_data(const char *table, const char *col, } fprintf(stdout,"\n obtained: `%s` (expected: `%s`)", row[field], exp_data); - myassert(strcmp(row[field],exp_data) == 0); + assert(strcmp(row[field],exp_data) == 0); mysql_free_result(result); } @@ -556,15 +541,15 @@ static void verify_prepare_field(MYSQL_RES *result, fprintf(stdout,"\n charsetnr:`%d`", field->charsetnr); fprintf(stdout,"\n default :`%s`\t(expected: `%s`)", field->def ? field->def : "(null)", def ? def: "(null)"); fprintf(stdout,"\n"); - myassert(strcmp(field->name,name) == 0); - myassert(strcmp(field->org_name,org_name) == 0); - myassert(field->type == type); - myassert(strcmp(field->table,table) == 0); - myassert(strcmp(field->org_table,org_table) == 0); - myassert(strcmp(field->db,db) == 0); - myassert(field->length == length); + assert(strcmp(field->name,name) == 0); + assert(strcmp(field->org_name,org_name) == 0); + assert(field->type == type); + assert(strcmp(field->table,table) == 0); + assert(strcmp(field->org_table,org_table) == 0); + assert(strcmp(field->db,db) == 0); + assert(field->length == length); if (def) - myassert(strcmp(field->def,def) == 0); + assert(strcmp(field->def,def) == 0); } /* @@ -575,7 +560,7 @@ static void verify_param_count(MYSQL_STMT *stmt, long exp_count) long param_count= mysql_param_count(stmt); fprintf(stdout,"\n total parameters in stmt: `%ld` (expected: `%ld`)", param_count, exp_count); - myassert(param_count == exp_count); + assert(param_count == exp_count); } /* @@ -586,7 +571,7 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) ulonglong affected_rows= mysql_stmt_affected_rows(stmt); fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); } /* @@ -597,7 +582,7 @@ static void verify_affected_rows(ulonglong exp_count) ulonglong affected_rows= mysql_affected_rows(mysql); fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); } /* @@ -608,7 +593,7 @@ static void verify_field_count(MYSQL_RES *result, uint exp_count) uint field_count= mysql_num_fields(result); fprintf(stdout,"\n total fields in the result set: `%d` (expected: `%d`)", field_count, exp_count); - myassert(field_count == exp_count); + assert(field_count == exp_count); } /* @@ -630,7 +615,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count) fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); mysql_stmt_close(stmt); } @@ -1174,7 +1159,7 @@ static void test_prepare() myquery(rc); /* test the results now, only one row should exists */ - myassert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare",50)); + assert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare",50)); stmt = mysql_prepare(mysql,"SELECT * FROM my_prepare",50); mystmt_init(stmt); @@ -1212,27 +1197,27 @@ static void test_prepare() fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); - myassert(tiny_data == o_tiny_data); - myassert(is_null[0] == 0); - myassert(length[0] == 1); + assert(tiny_data == o_tiny_data); + assert(is_null[0] == 0); + assert(length[0] == 1); - myassert(int_data == o_int_data); - myassert(length[2] == 4); + assert(int_data == o_int_data); + assert(length[2] == 4); - myassert(small_data == o_small_data); - myassert(length[3] == 2); + assert(small_data == o_small_data); + assert(length[3] == 2); - myassert(big_data == o_big_data); - myassert(length[4] == 8); + assert(big_data == o_big_data); + assert(length[4] == 8); - myassert(real_data == o_real_data); - myassert(length[5] == 4); + assert(real_data == o_real_data); + assert(length[5] == 4); - myassert(double_data == o_double_data); - myassert(length[6] == 8); + assert(double_data == o_double_data); + assert(length[6] == 8); - myassert(strcmp(data,str_data) == 0); - myassert(length[1] == len); + assert(strcmp(data,str_data) == 0); + assert(length[1] == len); o_int_data += 25; o_small_data += 10; @@ -1242,7 +1227,7 @@ static void test_prepare() } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -1333,7 +1318,7 @@ static void test_double_compare() result = mysql_store_result(mysql); mytest(result); - myassert((int)tiny_data == my_process_result_set(result)); + assert((int)tiny_data == my_process_result_set(result)); mysql_free_result(result); } @@ -1408,7 +1393,7 @@ static void test_null() myquery(rc); nData*= 2; - myassert(nData == my_stmt_result("SELECT * FROM test_null", 30)); + assert(nData == my_stmt_result("SELECT * FROM test_null", 30)); /* Fetch results */ bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -1431,12 +1416,12 @@ static void test_null() is_null[0]= is_null[1]= 0; while (mysql_fetch(stmt) != MYSQL_NO_DATA) { - myassert(is_null[0]); - myassert(is_null[1]); + assert(is_null[0]); + assert(is_null[1]); rc++; is_null[0]= is_null[1]= 0; } - myassert(rc == (int)nData); + assert(rc == (int)nData); mysql_stmt_close(stmt); } @@ -1490,7 +1475,7 @@ static void test_fetch_null() strmov((char *)query , "SELECT * FROM test_fetch_null"); - myassert(3 == my_stmt_result(query,50)); + assert(3 == my_stmt_result(query,50)); stmt = mysql_prepare(mysql, query, 50); mystmt_init(stmt); @@ -1509,14 +1494,14 @@ static void test_fetch_null() { fprintf(stdout, "\n data[%d] : %s", i, is_null[i] ? "NULL" : "NOT NULL"); - myassert(is_null[i]); + assert(is_null[i]); } fprintf(stdout, "\n data[%d]: %d", i, nData); - myassert(nData == 1000 || nData == 88 || nData == 389789); - myassert(is_null[i] == 0); - myassert(length[i] == 4); + assert(nData == 1000 || nData == 88 || nData == 389789); + assert(is_null[i] == 0); + assert(length[i] == 4); } - myassert(rc == 3); + assert(rc == 3); mysql_stmt_close(stmt); } @@ -1651,7 +1636,7 @@ static void test_select_prepare() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); rc = mysql_query(mysql,"DROP TABLE test_select"); @@ -1681,7 +1666,7 @@ static void test_select_prepare() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -1757,7 +1742,7 @@ static void test_select() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); mysql_stmt_close(stmt); } @@ -1808,7 +1793,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); strmov(szData,(char *)"venu"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1824,7 +1809,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); strmov(szData,(char *)"abc"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1840,7 +1825,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); mysql_stmt_close(stmt); } @@ -1886,7 +1871,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); strmov(szData,(char *)"1111"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1902,7 +1887,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); strmov(szData,(char *)"abc"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1918,7 +1903,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); mysql_stmt_close(stmt); } @@ -1998,7 +1983,7 @@ static void test_bug1644() result= mysql_store_result(mysql); mytest(result); - myassert(3 == my_process_result_set(result)); + assert(3 == my_process_result_set(result)); mysql_data_seek(result, 0); @@ -2006,19 +1991,19 @@ static void test_bug1644() mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(strcmp(row[i], "22") == 0); + assert(strcmp(row[i], "22") == 0); } row= mysql_fetch_row(result); mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(row[i] == 0); + assert(row[i] == 0); } row= mysql_fetch_row(result); mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(strcmp(row[i], "88") == 0); + assert(strcmp(row[i], "88") == 0); } row= mysql_fetch_row(result); mytest_r(row); @@ -2084,7 +2069,7 @@ static void test_select_show() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -2170,7 +2155,7 @@ static void test_simple_update() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2256,7 +2241,7 @@ static void test_long_data() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); verify_col_data("test_long_data","col1","999"); @@ -2346,7 +2331,7 @@ static void test_long_data_str() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); my_sprintf(data,(data,"%d", i*5)); @@ -2435,7 +2420,7 @@ static void test_long_data_str1() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); my_sprintf(data,(data,"%ld",(long)i*length)); @@ -2526,7 +2511,7 @@ static void test_long_data_bin() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2614,7 +2599,7 @@ static void test_simple_delete() result = mysql_store_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); } @@ -2720,7 +2705,7 @@ static void test_update() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2770,7 +2755,7 @@ static void test_prepare_noparam() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2840,17 +2825,17 @@ static void test_bind_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d,%s(%lu)",nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %d,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"MySQL")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"MySQL")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -2858,12 +2843,12 @@ static void test_bind_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -2972,19 +2957,19 @@ static void test_bind_result_ext() fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); - myassert(t_data == 19); - myassert(s_data == 2999); - myassert(i_data == 3999); - myassert(b_data == 4999999); - /*myassert(f_data == 2345.60);*/ - /*myassert(d_data == 5678.89563);*/ - myassert(strcmp(szData,"venu")==0); - myassert(strncmp(bData,"mysql",5)==0); - myassert(szLength == 4); - myassert(bLength == 5); + assert(t_data == 19); + assert(s_data == 2999); + assert(i_data == 3999); + assert(b_data == 4999999); + /*assert(f_data == 2345.60);*/ + /*assert(d_data == 5678.89563);*/ + assert(strcmp(szData,"venu")==0); + assert(strncmp(bData,"mysql",5)==0); + assert(szLength == 4); + assert(bLength == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3096,23 +3081,23 @@ static void test_bind_result_ext1() fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); - myassert(strcmp(t_data,"120")==0); - myassert(i_data == 3999); - myassert(f_data == 2); - myassert(strcmp(d_data,"58.89")==0); - myassert(b_data == 54); + assert(strcmp(t_data,"120")==0); + assert(i_data == 3999); + assert(f_data == 2); + assert(strcmp(d_data,"58.89")==0); + assert(b_data == 54); - myassert(length[0] == 3); - myassert(length[1] == 4); - myassert(length[2] == 2); - myassert(length[3] == 1); - myassert(length[4] == 4); - myassert(length[5] == 5); - myassert(length[6] == 4); - myassert(length[7] == 8); + assert(length[0] == 3); + assert(length[1] == 4); + assert(length[2] == 2); + assert(length[3] == 1); + assert(length[4] == 4); + assert(length[5] == 5); + assert(length[6] == 4); + assert(length[7] == 8); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3165,7 +3150,7 @@ static void bind_fetch(int row_count) mysql_stmt_close(stmt); - myassert(row_count == (int) + assert(row_count == (int) my_stmt_result("SELECT * FROM test_bind_fetch",50)); stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_fetch",50); @@ -3220,33 +3205,33 @@ static void bind_fetch(int row_count) rc= 10+row_count; for (i=0; i < 4; i++) { - myassert(data[i] == rc+i); - myassert(length[i] == bit); + assert(data[i] == rc+i); + assert(length[i] == bit); bit<<= 1; rc+= 12; } /* FLOAT */ rc+= i; - myassert((int)f_data == rc); - myassert(length[4] == 4); + assert((int)f_data == rc); + assert(length[4] == 4); /* DOUBLE */ rc+= 13; - myassert((int)d_data == rc); - myassert(length[5] == 8); + assert((int)d_data == rc); + assert(length[5] == 8); /* CHAR */ rc+= 13; { char buff[20]; long len= my_sprintf(buff, (buff, "%d", rc)); - myassert(strcmp(s_data,buff)==0); - myassert(length[6] == (ulong) len); + assert(strcmp(s_data,buff)==0); + assert(length[6] == (ulong) len); } } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3336,7 +3321,7 @@ static void test_fetch_date() bind[6].buffer_length= sizeof(ts_6); bind[6].length= &ts6_length; - myassert(1 == my_stmt_result("SELECT * FROM test_bind_result",50)); + assert(1 == my_stmt_result("SELECT * FROM test_bind_result",50)); stmt = mysql_prepare(mysql, "SELECT * FROM test_bind_result", 50); mystmt_init(stmt); @@ -3359,29 +3344,29 @@ static void test_fetch_date() fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); - myassert(strcmp(date,"2002-01-02")==0); - myassert(d_length == 10); + assert(strcmp(date,"2002-01-02")==0); + assert(d_length == 10); - myassert(strcmp(time,"12:49:00")==0); - myassert(t_length == 8); + assert(strcmp(time,"12:49:00")==0); + assert(t_length == 8); - myassert(strcmp(ts,"2002-01-02 17:46:59")==0); - myassert(ts_length == 19); + assert(strcmp(ts,"2002-01-02 17:46:59")==0); + assert(ts_length == 19); - myassert(year == 2010); - myassert(y_length == 4); + assert(year == 2010); + assert(y_length == 4); - myassert(strcmp(dt,"2010-07-10 00:00:00")==0); - myassert(dt_length == 19); + assert(strcmp(dt,"2010-07-10 00:00:00")==0); + assert(dt_length == 19); - myassert(ts_4[0] == '\0'); - myassert(ts4_length == 0); + assert(ts_4[0] == '\0'); + assert(ts4_length == 0); - myassert(strcmp(ts_6,"1999-12-29 00:00:00")==0); - myassert(ts6_length == 19); + assert(strcmp(ts_6,"1999-12-29 00:00:00")==0); + assert(ts6_length == 19); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3726,7 +3711,7 @@ static void test_prepare_ext() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(nData == (int)my_process_stmt_result(stmt)); + assert(nData == (int)my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -3769,7 +3754,7 @@ static void test_field_names() result = mysql_use_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); /* with table name included with TRUE column name */ @@ -3779,7 +3764,7 @@ static void test_field_names() result = mysql_use_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); } @@ -3805,7 +3790,7 @@ static void test_warnings() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -3908,7 +3893,7 @@ static void test_insert() result = mysql_store_result(mysql); mytest(result); - myassert((int)tiny_data == my_process_result_set(result)); + assert((int)tiny_data == my_process_result_set(result)); mysql_free_result(result); } @@ -4074,18 +4059,18 @@ static void test_stmt_close() rc= mysql_stmt_close(stmt1); fprintf(stdout,"\n mysql_close_stmt(1) returned: %d", rc); - myassert(rc == 0); + assert(rc == 0); mysql_close(lmysql); /* it should free all open stmts(stmt3, 2 and 1) */ #if NOT_VALID rc= mysql_stmt_close(stmt3); fprintf(stdout,"\n mysql_close_stmt(3) returned: %d", rc); - myassert( rc == 1); + assert( rc == 1); rc= mysql_stmt_close(stmt2); fprintf(stdout,"\n mysql_close_stmt(2) returned: %d", rc); - myassert( rc == 1); + assert( rc == 1); #endif count= 100; @@ -4105,7 +4090,7 @@ static void test_stmt_close() rc= mysql_stmt_close(stmt_x); fprintf(stdout,"\n mysql_close_stmt(x) returned: %d", rc); - myassert( rc == 0); + assert( rc == 0); rc = mysql_query(mysql,"SELECT id FROM test_stmt_close"); myquery(rc); @@ -4113,7 +4098,7 @@ static void test_stmt_close() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -4161,9 +4146,9 @@ static void test_set_variable() fprintf(stdout, "\n max_error_count(default): %d", get_count); def_count= get_count; - myassert(strcmp(var,"max_error_count") == 0); + assert(strcmp(var,"max_error_count") == 0); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); stmt = mysql_prepare(mysql, "set max_error_count=?", 50); mystmt_init(stmt); @@ -4189,10 +4174,10 @@ static void test_set_variable() mystmt(stmt1, rc); fprintf(stdout, "\n max_error_count : %d", get_count); - myassert(get_count == set_count); + assert(get_count == set_count); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); /* restore back to default */ set_count= def_count; @@ -4206,10 +4191,10 @@ static void test_set_variable() mystmt(stmt1, rc); fprintf(stdout, "\n max_error_count(default): %d", get_count); - myassert(get_count == set_count); + assert(get_count == set_count); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); mysql_stmt_close(stmt1); @@ -4265,12 +4250,12 @@ static void test_insert_meta() field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); - myassert(strcmp(field->name,"col1")==0); + assert(strcmp(field->name,"col1")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); - myassert(strcmp(field->name,"col3")==0); + assert(strcmp(field->name,"col3")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4329,15 +4314,15 @@ static void test_update_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - myassert(strcmp(field->name,"col1")==0); - myassert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name,"col1")==0); + assert(strcmp(field->table,"test_prep_update")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - myassert(strcmp(field->name,"col3")==0); - myassert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name,"col3")==0); + assert(strcmp(field->table,"test_prep_update")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4394,15 +4379,15 @@ static void test_select_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - myassert(strcmp(field->name,"col1")==0); - myassert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name,"col1")==0); + assert(strcmp(field->table,"test_prep_select")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - myassert(strcmp(field->name,"col2")==0); - myassert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name,"col2")==0); + assert(strcmp(field->table,"test_prep_select")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4448,7 +4433,7 @@ static void test_func_fields() mytest(field); fprintf(stdout,"\n table name: `%s` (expected: `%s`)", field->table, "test_dateformat"); - myassert(strcmp(field->table, "test_dateformat")==0); + assert(strcmp(field->table, "test_dateformat")==0); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4465,7 +4450,7 @@ static void test_func_fields() field = mysql_fetch_field(result); mytest(field); fprintf(stdout,"\n table name: `%s` (expected: `%s`)", field->table, ""); - myassert(field->table[0] == '\0'); + assert(field->table[0] == '\0'); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4483,8 +4468,8 @@ static void test_func_fields() mytest(field); fprintf(stdout,"\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); fprintf(stdout,"\n field org name: `%s` (expected: `%s`)",field->org_name,""); - myassert(strcmp(field->name, "YEAR")==0); - myassert(field->org_name[0] == '\0'); + assert(strcmp(field->name, "YEAR")==0); + assert(field->org_name[0] == '\0'); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4552,11 +4537,11 @@ static void test_multi_stmt() fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); - myassert(id == 10); - myassert(strcmp(name,"mysql")==0); + assert(id == 10); + assert(strcmp(name,"mysql")==0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); /* alter the table schema now */ stmt1 = mysql_prepare(mysql,"DELETE FROM test_multi_table WHERE id = ? AND name=?",100); @@ -4580,11 +4565,11 @@ static void test_multi_stmt() fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); - myassert(id == 10); - myassert(strcmp(name,"updated")==0); + assert(id == 10); + assert(strcmp(name,"updated")==0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_execute(stmt1); mystmt(stmt1, rc); @@ -4597,9 +4582,9 @@ static void test_multi_stmt() mystmt(stmt, rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); - myassert(0 == my_stmt_result("SELECT * FROM test_multi_table",50)); + assert(0 == my_stmt_result("SELECT * FROM test_multi_table",50)); mysql_stmt_close(stmt); mysql_stmt_close(stmt2); @@ -4750,7 +4735,7 @@ static void test_manual_sample() fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } - myassert(2 == my_stmt_result("SELECT * FROM test_table",50)); + assert(2 == my_stmt_result("SELECT * FROM test_table",50)); /* DROP THE TABLE */ if (mysql_query(mysql,"DROP TABLE test_table")) @@ -4811,87 +4796,135 @@ static void test_prepare_alter() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(4 == my_stmt_result("SELECT * FROM test_prep_alter",50)); + assert(4 == my_stmt_result("SELECT * FROM test_prep_alter",50)); mysql_stmt_close(stmt); } /******************************************************** -* to test the support of multi-query executions * +* to test the support of multi-statement executions * *********************************************************/ -static void test_multi_query() + +static void test_multi_statements() { - MYSQL *l_mysql, *org_mysql; + MYSQL *mysql_local; MYSQL_RES *result; int rc; - const char *query= "DROP TABLE IF EXISTS test_multi_tab;\ - CREATE TABLE test_multi_tab(id int,name char(20));\ - INSERT INTO test_multi_tab(xxxx) VALUES(10);\ - UPDATE test_multi_tab SET id=10 WHERE unkown_col=10;\ - CREATE TABLE test_multi_tab(id int,name char(20));\ - INSERT INTO test_multi_tab(id) VALUES(10),(20);\ - INSERT INTO test_multi_tab VALUES(20,'insert;comma');\ - SELECT * FROM test_multi_tab;\ - UPDATE test_multi_tab SET unknown_col=100 WHERE id=100;\ - UPDATE test_multi_tab SET name='new;name' WHERE id=20;\ - DELETE FROM test_multi_tab WHERE name='new;name';\ - SELECT * FROM test_multi_tab;\ - DELETE FROM test_multi_tab WHERE id=10;\ - SELECT * FROM test_multi_tab;\ - DROP TABLE test_multi_tab;\ - DROP TABLE test_multi_tab;\ - DROP TABLE IF EXISTS test_multi_tab"; - uint count, rows[16]={0,1054,1054,1050,2,1,3,1054,2,2,1,1,0,0,1051,0}, exp_value; - - myheader("test_multi_query"); + const char *query="\ +DROP TABLE IF EXISTS test_multi_tab;\ +CREATE TABLE test_multi_tab(id int,name char(20));\ +INSERT INTO test_multi_tab(id) VALUES(10),(20);\ +INSERT INTO test_multi_tab VALUES(20,'insert;comma');\ +SELECT * FROM test_multi_tab;\ +UPDATE test_multi_tab SET name='new;name' WHERE id=20;\ +DELETE FROM test_multi_tab WHERE name='new;name';\ +SELECT * FROM test_multi_tab;\ +DELETE FROM test_multi_tab WHERE id=10;\ +SELECT * FROM test_multi_tab;\ +DROP TABLE test_multi_tab;\ +select 1;\ +DROP TABLE IF EXISTS test_multi_tab"; + uint count, exp_value; + uint rows[]= {0, 0, 2, 1, 3, 2, 2, 1, 1, 0, 0, 1, 0}; + myheader("test_multi_statements"); + + /* + First test that we get an error for multi statements + (Becasue default connection is not opened with CLIENT_MULTI_STATEMENTS) + */ rc = mysql_query(mysql, query); /* syntax error */ myquery_r(rc); - myassert(0 == mysql_next_result(mysql)); - myassert(0 == mysql_more_results(mysql)); + assert(-1 == mysql_next_result(mysql)); + assert(0 == mysql_more_results(mysql)); - if (!(l_mysql = mysql_init(NULL))) + if (!(mysql_local = mysql_init(NULL))) { fprintf(stdout,"\n mysql_init() failed"); exit(1); } - if (!(mysql_real_connect(l_mysql,opt_host,opt_user, - opt_password, current_db, opt_port, - opt_unix_socket, CLIENT_MULTI_STATEMENTS))) /* enable multi queries */ - { - fprintf(stdout,"\n connection failed(%s)", mysql_error(l_mysql)); - exit(1); - } - org_mysql= mysql; - mysql= l_mysql; - rc = mysql_query(mysql, query); + /* Create connection that supprot multi statements */ + if (!(mysql_real_connect(mysql_local,opt_host,opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, CLIENT_MULTI_STATEMENTS))) + { + fprintf(stdout,"\n connection failed(%s)", mysql_error(mysql_local)); + exit(1); + } + + rc = mysql_query(mysql_local, query); myquery(rc); - count= exp_value= 0; - while (mysql_more_results(mysql) && count < array_elements(rows)) + for (count=0 ; count < array_elements(rows) ; count++) { fprintf(stdout,"\n Query %d: ", count); - if ((rc= mysql_next_result(mysql))) + if ((result= mysql_store_result(mysql_local))) + my_process_result_set(result); + else + fprintf(stdout,"OK, %lld row(s) affected, %d warning(s)\n", + mysql_affected_rows(mysql_local), + mysql_warning_count(mysql_local)); + + exp_value= (uint) mysql_affected_rows(mysql_local); + if (rows[count] != exp_value) { - exp_value= mysql_errno(mysql); - fprintf(stdout, "ERROR %d: %s", exp_value, mysql_error(mysql)); + fprintf(stdout, "row %d had affected rows: %d, should be %d\n", + count, exp_value, rows[count]); + exit(1); + } + if (count != array_elements(rows) -1) + { + if (!(rc= mysql_more_results(mysql_local))) + { + fprintf(stdout, + "mysql_more_result returned wrong value: %d for row %d\n", + rc, count); + exit(1); + } + if ((rc= mysql_next_result(mysql_local))) + { + exp_value= mysql_errno(mysql_local); + + exit(1); + } } else { - if ((result= mysql_store_result(mysql))) - my_process_result_set(result); - else - fprintf(stdout,"OK, %lld row(s) affected, %d warning(s)", - mysql_affected_rows(mysql), - mysql_warning_count(mysql)); - exp_value= (uint) mysql_affected_rows(mysql); + assert(mysql_more_results(mysql_local) == 0); + assert(mysql_next_result(mysql_local) == -1); } - myassert(rows[count++] == exp_value); } - mysql= org_mysql; + + /* check that errors abort multi statements */ + + rc= mysql_query(mysql_local, "select 1+1+a;select 1+1"); + myquery_r(rc); + assert(mysql_more_results(mysql_local) == 0); + assert(mysql_next_result(mysql_local) == -1); + + rc= mysql_query(mysql_local, "select 1+1;select 1+1+a;select 1"); + myquery(rc); + result= mysql_store_result(mysql_local); + mytest(result); + mysql_free_result(result); + assert(mysql_more_results(mysql_local) == 1); + assert(mysql_next_result(mysql_local) > 0); + + /* + Ensure that we can now do a simple query (this checks that the server is + not trying to send us the results for the last 'select 1' + */ + rc= mysql_query(mysql_local, "select 1+1+1"); + myquery(rc); + result= mysql_store_result(mysql_local); + mytest(result); + my_process_result_set(result); + mysql_free_result(result); + + mysql_close(mysql_local); } @@ -4961,17 +4994,17 @@ static void test_store_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %ld,%s(%lu)", nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"mysql")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"mysql")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -4979,12 +5012,12 @@ static void test_store_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -4996,17 +5029,17 @@ static void test_store_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"mysql")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"mysql")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -5014,12 +5047,12 @@ static void test_store_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5069,7 +5102,7 @@ static void test_store_result1() while (mysql_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); - myassert(rc == 3); + assert(rc == 3); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5081,7 +5114,7 @@ static void test_store_result1() while (mysql_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); - myassert(rc == 3); + assert(rc == 3); mysql_stmt_close(stmt); } @@ -5148,10 +5181,10 @@ static void test_store_result2() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",nData); - myassert(nData == 10); + assert(nData == 10); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); nData = 20; rc = mysql_execute(stmt); @@ -5165,10 +5198,10 @@ static void test_store_result2() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",nData); - myassert(nData == 20); + assert(nData == 20); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5242,11 +5275,11 @@ static void test_subselect() mysql_stmt_close(stmt); - myassert(3 == my_stmt_result("SELECT * FROM test_sub2",50)); + assert(3 == my_stmt_result("SELECT * FROM test_sub2",50)); strmov((char *)query , "SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=?)"); - myassert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=8)",100)); - myassert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=7)",100)); + assert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=8)",100)); + assert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=7)",100)); stmt = mysql_prepare(mysql, query, 150); mystmt_init(stmt); @@ -5265,10 +5298,10 @@ static void test_subselect() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",id); - myassert(id == 1); + assert(id == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); id= 8; rc = mysql_execute(stmt); @@ -5278,10 +5311,10 @@ static void test_subselect() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",id); - myassert(id == 0); + assert(id == 0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); #endif @@ -5356,7 +5389,7 @@ static void test_bind_date_conv(uint row_count) mysql_stmt_close(stmt); - myassert(row_count == my_stmt_result("SELECT * FROM test_date",50)); + assert(row_count == my_stmt_result("SELECT * FROM test_date",50)); stmt = mysql_prepare(mysql,"SELECT * FROM test_date",50); myquery(rc); @@ -5384,23 +5417,23 @@ static void test_bind_date_conv(uint row_count) tm[i].hour, tm[i].minute, tm[i].second, tm[i].second_part); - myassert(tm[i].year == 0 || tm[i].year == year+count); - myassert(tm[i].month == 0 || tm[i].month == month+count); - myassert(tm[i].day == 0 || tm[i].day == day+count); + assert(tm[i].year == 0 || tm[i].year == year+count); + assert(tm[i].month == 0 || tm[i].month == month+count); + assert(tm[i].day == 0 || tm[i].day == day+count); - myassert(tm[i].hour == 0 || tm[i].hour == hour+count); + assert(tm[i].hour == 0 || tm[i].hour == hour+count); /* minute causes problems from date<->time, don't assert, instead validate separatly in another routine */ - /*myassert(tm[i].minute == 0 || tm[i].minute == minute+count); - myassert(tm[i].second == 0 || tm[i].second == sec+count);*/ + /*assert(tm[i].minute == 0 || tm[i].minute == minute+count); + assert(tm[i].second == 0 || tm[i].second == sec+count);*/ - myassert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); + assert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); } } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5673,9 +5706,9 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(buffer[0] == 'M'); - myassert(buffer[1] == 'X'); - myassert(length == 5); + assert(buffer[0] == 'M'); + assert(buffer[1] == 'X'); + assert(length == 5); bind[0].buffer_length=8; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5684,8 +5717,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strncmp(buffer,"Database",8) == 0); - myassert(length == 8); + assert(strncmp(buffer,"Database",8) == 0); + assert(length == 8); bind[0].buffer_length=12; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5694,8 +5727,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strcmp(buffer,"Open-Source") == 0); - myassert(length == 11); + assert(strcmp(buffer,"Open-Source") == 0); + assert(length == 11); bind[0].buffer_length=6; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5704,8 +5737,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strncmp(buffer,"Popula",6) == 0); - myassert(length == 7); + assert(strncmp(buffer,"Popula",6) == 0); + assert(length == 7); mysql_stmt_close(stmt); } @@ -5736,7 +5769,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5749,7 +5782,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5762,7 +5795,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_stmt_close(stmt); /* run a direct query in the middle of a fetch */ @@ -5828,7 +5861,7 @@ static void test_fetch_nobuffs() rc++; fprintf(stdout, "\n total rows : %d", rc); - myassert(rc == 1); + assert(rc == 1); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *)str[0]; @@ -5856,7 +5889,7 @@ static void test_fetch_nobuffs() fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]); } fprintf(stdout, "\n total rows : %d", rc); - myassert(rc == 1); + assert(rc == 1); mysql_stmt_close(stmt); } @@ -5927,20 +5960,20 @@ static void test_ushort_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == 35999); - myassert(s_length == 2); + assert(short_value == 35999); + assert(s_length == 2); - myassert(long_value == 35999); - myassert(l_length == 4); + assert(long_value == 35999); + assert(l_length == 4); - myassert(longlong_value == 35999); - myassert(ll_length == 8); + assert(longlong_value == 35999); + assert(ll_length == 8); - myassert(tiny_value == 200); - myassert(t_length == 1); + assert(tiny_value == 200); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6011,20 +6044,20 @@ static void test_sshort_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == -5999); - myassert(s_length == 2); + assert(short_value == -5999); + assert(s_length == 2); - myassert(long_value == -5999); - myassert(l_length == 4); + assert(long_value == -5999); + assert(l_length == 4); - myassert(longlong_value == 35999); - myassert(ll_length == 8); + assert(longlong_value == 35999); + assert(ll_length == 8); - myassert(tiny_value == 200); - myassert(t_length == 1); + assert(tiny_value == 200); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6095,20 +6128,20 @@ static void test_stiny_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == -128); - myassert(s_length == 2); + assert(short_value == -128); + assert(s_length == 2); - myassert(long_value == -127); - myassert(l_length == 4); + assert(long_value == -127); + assert(l_length == 4); - myassert(longlong_value == 255); - myassert(ll_length == 8); + assert(longlong_value == 255); + assert(ll_length == 8); - myassert(tiny_value == 0); - myassert(t_length == 1); + assert(tiny_value == 0); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6133,7 +6166,7 @@ static void test_field_misc() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); verify_prepare_field(result,0, "@@autocommit","", /* field and its org name */ @@ -6152,7 +6185,7 @@ static void test_field_misc() result = mysql_get_metadata(stmt); mytest(result); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@autocommit","", /* field and its org name */ @@ -6183,7 +6216,7 @@ static void test_field_misc() fprintf(stdout,"\n default table type: %s(%ld)", table_type, type_length); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -6196,7 +6229,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@table_type","", /* field and its org name */ @@ -6216,7 +6249,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@max_error_count","", /* field and its org name */ @@ -6236,7 +6269,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@max_allowed_packet","", /* field and its org name */ @@ -6256,7 +6289,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@sql_warnings","", /* field and its org name */ @@ -6303,7 +6336,7 @@ static void test_set_option() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); @@ -6314,7 +6347,7 @@ static void test_set_option() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(2 == my_process_stmt_result(stmt)); + assert(2 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); @@ -6329,7 +6362,7 @@ static void test_set_option() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(4 == my_process_stmt_result(stmt)); + assert(4 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -6400,7 +6433,7 @@ static void test_prepare_grant() execute_prepare_query("INSERT INTO test_grant(a) VALUES(NULL)",1); execute_prepare_query("INSERT INTO test_grant VALUES(NULL)",1); execute_prepare_query("UPDATE test_grant SET a=9 WHERE a=1",1); - myassert(4 == my_stmt_result("SELECT a FROM test_grant",50)); + assert(4 == my_stmt_result("SELECT a FROM test_grant",50)); rc = mysql_query(mysql,"DELETE FROM test_grant"); myquery_r(rc); @@ -6411,18 +6444,18 @@ static void test_prepare_grant() rc = mysql_execute(stmt); myquery_r(rc); - myassert(4 == my_stmt_result("SELECT * FROM test_grant",50)); + assert(4 == my_stmt_result("SELECT * FROM test_grant",50)); mysql_close(lmysql); mysql= org_mysql; rc = mysql_query(mysql,"delete from mysql.user where User='test_grant'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.tables_priv where User='test_grant'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); } } @@ -6476,7 +6509,7 @@ static void test_frm_bug() fprintf(stdout,"\n data directory: %s", data_dir); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); strxmov(test_frm,data_dir,"/",current_db,"/","test_frm_bug.frm",NullS); @@ -6496,7 +6529,7 @@ static void test_frm_bug() result = mysql_store_result(mysql); mytest(result);/* It can't be NULL */ - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_data_seek(result,0); @@ -6504,7 +6537,7 @@ static void test_frm_bug() mytest(row); fprintf(stdout,"\n Comment: %s", row[16]); - myassert(row[16] != 0); + assert(row[16] != 0); mysql_free_result(result); mysql_stmt_close(stmt); @@ -6562,10 +6595,10 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 8.0); + assert(data == 8.0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); data= 5.61; rc = mysql_execute(stmt); @@ -6579,17 +6612,17 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 5.61); + assert(data == 5.61); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); is_null= 1; rc = mysql_execute(stmt); mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); data= 10.22; is_null= 0; rc = mysql_execute(stmt); @@ -6603,10 +6636,10 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 10.22); + assert(data == 10.22); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6639,14 +6672,14 @@ static void test_explain_bug() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert( 2 == my_process_stmt_result(stmt)); + assert( 2 == my_process_stmt_result(stmt)); result = mysql_get_metadata(stmt); mytest(result); fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); - myassert(6 == mysql_num_fields(result)); + assert(6 == mysql_num_fields(result)); verify_prepare_field(result,0,"Field","",MYSQL_TYPE_VAR_STRING, "","","",NAME_LEN,0); @@ -6675,14 +6708,14 @@ static void test_explain_bug() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert( 1 == my_process_stmt_result(stmt)); + assert( 1 == my_process_stmt_result(stmt)); result = mysql_get_metadata(stmt); mytest(result); fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); - myassert(10 == mysql_num_fields(result)); + assert(10 == mysql_num_fields(result)); verify_prepare_field(result,0,"id","",MYSQL_TYPE_LONGLONG, "","","",3,0); @@ -6718,10 +6751,25 @@ static void test_explain_bug() mysql_stmt_close(stmt); } +#ifdef NOT_YET_WORKING + /* To test math functions bug #148 (reported by salle@mysql.com). */ + +#define myerrno(n) check_errcode(n) + +static void check_errcode(const unsigned int err) +{ + if (mysql->server_version) + fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); + else + fprintf(stdout,"\n [MySQL]"); + fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); + assert(mysql_errno(mysql) == err); +} + static void test_drop_temp() { int rc; @@ -6814,18 +6862,19 @@ static void test_drop_temp() rc = mysql_query(mysql,"drop database test_drop_temp_db"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.user where User='test_temp'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.tables_priv where User='test_temp'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); } } +#endif /* To test warnings for cuted rows @@ -6851,14 +6900,14 @@ static void test_cuted_rows() count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 0); + assert(count == 0); rc = mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1"); myquery(rc); count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 2); + assert(count == 2); rc = mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -6866,7 +6915,7 @@ static void test_cuted_rows() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); rc = mysql_query(mysql, "INSERT INTO t1 VALUES('junk'),(876789)"); @@ -6874,7 +6923,7 @@ static void test_cuted_rows() count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 2); + assert(count == 2); rc = mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -6882,7 +6931,7 @@ static void test_cuted_rows() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); } @@ -6985,44 +7034,44 @@ static void test_logs() fprintf(stdout, "\n id : %d", id); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(id == 9876); - myassert(length == 19); /* Due to VARCHAR(20) */ - myassert(strcmp(data,"MySQL - Open Source")==0); + assert(id == 9876); + assert(length == 19); /* Due to VARCHAR(20) */ + assert(strcmp(data,"MySQL - Open Source")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 1); - myassert(strcmp(data,"'")==0); + assert(length == 1); + assert(strcmp(data,"'")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 1); - myassert(strcmp(data,"\"")==0); + assert(length == 1); + assert(strcmp(data,"\"")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 7); - myassert(strcmp(data,"my\'sql\'")==0); + assert(length == 7); + assert(strcmp(data,"my\'sql\'")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 7); - /*myassert(strcmp(data,"my\"sql\"")==0); */ + assert(length == 7); + /*assert(strcmp(data,"my\"sql\"")==0); */ rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -7089,10 +7138,10 @@ static void test_nstmts() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n total rows: %d", i); - myassert( i == total_stmts); + assert( i == total_stmts); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -7189,7 +7238,7 @@ static void test_fetch_seek() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -7249,17 +7298,17 @@ static void test_fetch_offset() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - myassert(strncmp(data,"abcd",4) == 0 && length == 10); + assert(strncmp(data,"abcd",4) == 0 && length == 10); rc = mysql_fetch_column(stmt,bind,0,5); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - myassert(strncmp(data,"fg",2) == 0 && length == 10); + assert(strncmp(data,"fg",2) == 0 && length == 10); rc = mysql_fetch_column(stmt,bind,0,9); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %s (%ld)", data, length); - myassert(strncmp(data,"j",1) == 0 && length == 10); + assert(strncmp(data,"j",1) == 0 && length == 10); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7269,10 +7318,10 @@ static void test_fetch_offset() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); - myassert(is_null == 1); + assert(is_null == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_fetch_column(stmt,bind,1,0); mystmt_r(stmt,rc); @@ -7342,13 +7391,13 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"venu",4)==0 && l2 == 4); + assert(strncmp(c2,"venu",4)==0 && l2 == 4); c2[0]= '\0'; l2= 0; rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strcmp(c2,"venu")==0 && l2 == 4); + assert(strcmp(c2,"venu")==0 && l2 == 4); c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7360,7 +7409,7 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); - myassert(c1 == 1 && l1 == 4); + assert(c1 == 1 && l1 == 4); rc = mysql_fetch_column(stmt,bind,10,0); mystmt_r(stmt,rc); @@ -7380,13 +7429,13 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"mysq",4)==0 && l2 == 5); + assert(strncmp(c2,"mysq",4)==0 && l2 == 5); c2[0]= '\0'; l2= 0; rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); - myassert(strcmp(c2,"mysql")==0 && l2 == 5); + assert(strcmp(c2,"mysql")==0 && l2 == 5); c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7398,10 +7447,10 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); - myassert(c1 == 2 && l1 == 4); + assert(c1 == 2 && l1 == 4); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_fetch_column(stmt,bind,1,0); mystmt_r(stmt,rc); @@ -7427,7 +7476,7 @@ static void test_list_fields() result = mysql_list_fields(mysql, "test_list_fields",NULL); mytest(result); - myassert( 0 == my_process_result_set(result)); + assert( 0 == my_process_result_set(result)); verify_prepare_field(result,0,"c1","c1",MYSQL_TYPE_LONG, "test_list_fields","test_list_fields",current_db,11,"0"); @@ -7486,7 +7535,7 @@ static void test_mem_overun() rc = mysql_query(mysql,"select * from t_mem_overun"); myquery(rc); - myassert(1 == my_process_result(mysql)); + assert(1 == my_process_result(mysql)); stmt = mysql_prepare(mysql, "select * from t_mem_overun",30); mystmt_init(stmt); @@ -7498,7 +7547,7 @@ static void test_mem_overun() mytest(field_res); fprintf(stdout,"\n total fields : %d", mysql_num_fields(field_res)); - myassert( 1000 == mysql_num_fields(field_res)); + assert( 1000 == mysql_num_fields(field_res)); rc = mysql_stmt_store_result(stmt); mystmt(stmt,rc); @@ -7507,7 +7556,7 @@ static void test_mem_overun() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -7562,7 +7611,7 @@ static void test_free_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); - myassert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2,"1",1)==0 && l2 == 1); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7577,7 +7626,7 @@ static void test_free_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); - myassert(c1 == 2 && l2 == 4); + assert(c1 == 2 && l2 == 4); rc = mysql_query(mysql,"drop table test_free_result"); myquery_r(rc); /* error should be, COMMANDS OUT OF SYNC */ @@ -7644,7 +7693,7 @@ static void test_free_store_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2,"1",1)==0 && l2 == 1); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7659,7 +7708,7 @@ static void test_free_store_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); - myassert(c1 == 2 && l2 == 4); + assert(c1 == 2 && l2 == 4); rc = mysql_stmt_free_result(stmt); mystmt(stmt,rc); @@ -7770,7 +7819,7 @@ static void test_sqlmode() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); fprintf(stdout,"\n returned 1 row\n"); mysql_stmt_close(stmt); @@ -7793,7 +7842,7 @@ static void test_sqlmode() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); fprintf(stdout,"\n returned 1 row"); mysql_stmt_close(stmt); @@ -7872,7 +7921,7 @@ static void test_ts() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert( 2== my_process_stmt_result(stmt)); + assert( 2== my_process_stmt_result(stmt)); field_count= mysql_num_fields(prep_res); mysql_free_result(prep_res); @@ -7899,7 +7948,7 @@ static void test_ts() row_count++; fprintf(stdout, "\n returned '%d' rows", row_count); - myassert(row_count == 2); + assert(row_count == 2); mysql_stmt_close(stmt); } } @@ -8108,7 +8157,7 @@ int main(int argc, char **argv) test_stmt_close(); /* mysql_stmt_close() test -- hangs */ test_prepare_field_result(); /* prepare meta info */ test_multi_stmt(); /* multi stmt test */ - test_multi_query(); /* test multi query execution */ + test_multi_statements(); /* test multi statement execution */ test_store_result(); /* test the store_result */ test_store_result1(); /* test store result without buffers */ test_store_result2(); /* test store result for misc case */ From ad309d5e0d2f1b155e37f60a2e625d2fc92f79c5 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 19 Nov 2003 16:38:01 +0100 Subject: [PATCH 08/89] - removed some undefined non-weak symbols in libmysqlclient_r by setting LIBS to include @openss_libs@ (BUG#1652) --- libmysql_r/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index e01fc7634a1..ae091d86a88 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -19,7 +19,7 @@ target = libmysqlclient_r.la target_defs = -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -## LIBS = @LIBS@ +LIBS = @LIBS@ @openssl_libs@ INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include \ -I$(srcdir)/.. -I$(top_srcdir) -I.. $(openssl_includes) From a1272bbfd272cd37344ead6fe3407c6432c2dc08 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Wed, 19 Nov 2003 19:31:19 +0200 Subject: [PATCH 09/89] fixed memory allocation problem in IN with const rows --- sql/item_cmpfunc.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 709b20e5a54..64d6b5fa7cf 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1415,9 +1415,12 @@ cmp_item_row::~cmp_item_row() void cmp_item_row::store_value(Item *item) { + DBUG_ENTER("cmp_item_row::store_value"); THD *thd= current_thd; n= item->cols(); - if ((comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *)*n))) + if (!comparators) + comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *)*n); + if (comparators) { item->bring_value(); item->null_value= 0; @@ -1429,6 +1432,7 @@ void cmp_item_row::store_value(Item *item) item->null_value|= item->el(i)->null_value; } } + DBUG_VOID_RETURN; } From 0c2107c6b4b532065813487c0ce4170fe89299e7 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Wed, 19 Nov 2003 23:07:31 +0100 Subject: [PATCH 10/89] minor fixups: more verbose on "no memory" errors - report requested size, avoid flushing rec buffer to a file that is closed and deleted already (on got_error=1) --- myisam/mi_check.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 466defe8fbc..7108fdcba9e 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1368,6 +1368,7 @@ err: VOID(my_close(new_file,MYF(0))); VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks, MYF(MY_WME))); + info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */ } mi_mark_crashed_on_repair(info); } @@ -2852,8 +2853,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if (!(to=mi_alloc_rec_buff(info,block_info.rec_len, &(sort_param->rec_buff)))) { - mi_check_print_error(param,"Not enough memory for blob at %s", - llstr(sort_param->start_recpos,llbuff)); + mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)", + llstr(sort_param->start_recpos,llbuff), block_info.rec_len); DBUG_RETURN(1); } } From 4bd3b096a0db31e64e6a97b03ab44a1ddf91aa50 Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot2" <> Date: Wed, 19 Nov 2003 23:39:08 +0100 Subject: [PATCH 11/89] Official builds are tested with mysql-test-run --sleep=10, and the slave has (in mysql-test-run) a slave-net-timeout=10. So the 'sleep 1' below was converted in 'sleep 10', so slave thought that connection was down, so reconnected, so got an additional (fake) Rotate event, which shifted the positions displayed by SHOW SLAVE STATUS. --- mysql-test/t/rpl_rotate_logs.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 78213c6a750..7560d56af1c 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -101,7 +101,8 @@ show master logs; # we just tests if synonyms are accepted purge binary logs to 'master-bin.000002'; show binary logs; ---sleep 1; +# sleeping 10 seconds or more would make the slave believe connection is down +--real_sleep 1; purge master logs before now(); show binary logs; insert into t2 values (65); From ac7619833001936d481f845a5552835591f5009f Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Thu, 20 Nov 2003 02:48:09 +0200 Subject: [PATCH 12/89] Portability fixes for AIX43 --- include/my_base.h | 2 +- include/my_global.h | 3 ++- include/my_sys.h | 2 +- include/mysql.h | 24 ++++++++++++------------ innobase/fil/fil0fil.c | 8 ++++---- libmysql/libmysql.c | 3 ++- strings/my_strtoll10.c | 1 + 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/my_base.h b/include/my_base.h index a1744f37bc6..1bd0f47afa4 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -133,7 +133,7 @@ enum ha_extra_function { HA_EXTRA_RETRIEVE_ALL_COLS, HA_EXTRA_PREPARE_FOR_DELETE, HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */ - HA_EXTRA_PRELOAD_BUFFER_SIZE, /* Set buffer size for preloading */ + HA_EXTRA_PRELOAD_BUFFER_SIZE /* Set buffer size for preloading */ }; /* The following is parameter to ha_panic() */ diff --git a/include/my_global.h b/include/my_global.h index 43cacf8fa65..b5b78774e91 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -688,7 +688,8 @@ typedef long long my_ptrdiff_t; #endif #endif #if defined(__IBMC__) || defined(__IBMCPP__) -#define STDCALL _System _Export +/* This was _System _Export but caused a lot of warnings on _AIX43 */ +#define STDCALL #elif !defined( STDCALL) #define STDCALL #endif diff --git a/include/my_sys.h b/include/my_sys.h index 25c450e5d2b..bc43a59172e 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -160,7 +160,7 @@ extern char *my_strdup_with_length(const byte *from, uint length, #endif #ifdef HAVE_ALLOCA -#if defined(_AIX) && !defined(__GNUC__) +#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) #pragma alloca #endif /* _AIX */ #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) diff --git a/include/mysql.h b/include/mysql.h index b31c04c755b..7df42460c6d 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -552,27 +552,27 @@ typedef struct st_mysql_stmt typedef struct st_mysql_methods { - my_bool (STDCALL *read_query_result)(MYSQL *mysql); - my_bool (STDCALL *advanced_command)(MYSQL *mysql, + my_bool (* STDCALL read_query_result)(MYSQL *mysql); + my_bool (* STDCALL advanced_command)(MYSQL *mysql, enum enum_server_command command, const char *header, unsigned long header_length, const char *arg, unsigned long arg_length, my_bool skip_check); - MYSQL_DATA *(STDCALL *read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, + MYSQL_DATA *(* STDCALL read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, unsigned int fields); - MYSQL_RES * (STDCALL *use_result)(MYSQL *mysql); - void (STDCALL *fetch_lengths)(unsigned long *to, + MYSQL_RES * (* STDCALL use_result)(MYSQL *mysql); + void (* STDCALL fetch_lengths)(unsigned long *to, MYSQL_ROW column, unsigned int field_count); #if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) - MYSQL_FIELD * (STDCALL *list_fields)(MYSQL *mysql); - my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); - int (STDCALL *stmt_execute)(MYSQL_STMT *stmt); - MYSQL_DATA *(STDCALL *read_binary_rows)(MYSQL_STMT *stmt); - int (STDCALL *unbuffered_fetch)(MYSQL *mysql, char **row); - void (STDCALL *free_embedded_thd)(MYSQL *mysql); - const char *(STDCALL *read_statistic)(MYSQL *mysql); + MYSQL_FIELD * (* STDCALL list_fields)(MYSQL *mysql); + my_bool (* STDCALL read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); + int (* STDCALL stmt_execute)(MYSQL_STMT *stmt); + MYSQL_DATA *(* STDCALL read_binary_rows)(MYSQL_STMT *stmt); + int (* STDCALL unbuffered_fetch)(MYSQL *mysql, char **row); + void (* STDCALL free_embedded_thd)(MYSQL *mysql); + const char *(* STDCALL read_statistic)(MYSQL *mysql); #endif } MYSQL_METHODS; diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index a9ae59fbd50..7cf3cc409b3 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -1567,7 +1567,7 @@ fil_op_write_log( mlog_close(mtr, log_ptr); - mlog_catenate_string(mtr, name, ut_strlen(name) + 1); + mlog_catenate_string(mtr, (byte*) name, ut_strlen(name) + 1); if (type == MLOG_FILE_RENAME) { log_ptr = mlog_open(mtr, 30); @@ -1576,7 +1576,7 @@ fil_op_write_log( mlog_close(mtr, log_ptr); - mlog_catenate_string(mtr, new_name, ut_strlen(new_name) + 1); + mlog_catenate_string(mtr, (byte*) new_name, ut_strlen(new_name) + 1); } } #endif @@ -1630,7 +1630,7 @@ fil_op_log_parse_or_replay( return(NULL); } - name = ptr; + name = (char*) ptr; ptr += name_len; @@ -1649,7 +1649,7 @@ fil_op_log_parse_or_replay( return(NULL); } - new_name = ptr; + new_name = (char*) ptr; ptr += new_name_len; } diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index eb57e433c44..4f0a6aef11b 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2990,7 +2990,8 @@ int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row) if (packet_error == net_safe_read(mysql)) return 1; - *row= (mysql->net.read_pos[0] == 254) ? NULL : (mysql->net.read_pos+1); + *row= ((mysql->net.read_pos[0] == 254) ? NULL : + (char*) (mysql->net.read_pos+1)); return 0; } diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index f795ef64728..117b9d16a65 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -18,6 +18,7 @@ #include #include +#undef ULONGLONG_MAX #define ULONGLONG_MAX (~(ulonglong) 0) #define MAX_NEGATIVE_NUMBER ((ulonglong) LL(0x8000000000000000)) #define INIT_CNT 9 From f382adcfca0d63216405b2514d4235a30334e8f6 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Thu, 20 Nov 2003 03:11:33 +0200 Subject: [PATCH 13/89] Portability fixes (AIX43) Add missing file to VC++ project --- VC++Files/mysys/mysys.dsp | 4 ++++ include/my_sys.h | 3 +-- sql/set_var.h | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index 533d4212e2b..54345816884 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -190,6 +190,10 @@ SOURCE=.\mf_keycache.c # End Source File # Begin Source File +SOURCE=.\mf_keycaches.c +# End Source File +# Begin Source File + SOURCE=.\mf_loadpath.c # End Source File # Begin Source File diff --git a/include/my_sys.h b/include/my_sys.h index bc43a59172e..d1c7b658665 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -226,9 +226,8 @@ extern void add_compiled_collation(CHARSET_INFO *cs); extern ulong my_cache_w_requests, my_cache_write, my_cache_r_requests, my_cache_read; extern ulong my_blocks_used, my_blocks_changed; -extern uint key_cache_block_size; extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; -extern my_bool key_cache_inited, my_init_done; +extern my_bool my_init_done; /* Point to current my_message() */ extern void (*my_sigtstp_cleanup)(void), diff --git a/sql/set_var.h b/sql/set_var.h index a4c3b546fe0..666575a75e4 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -791,3 +791,6 @@ gptr find_named(I_List *list, const char *name, uint length, KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name); KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length); void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache); +bool process_key_caches(int (* func) (const char *name, KEY_CACHE_VAR *)); +void delete_elements(I_List *list, + void (*free_element)(const char*, gptr)); From 72566c794eab8141b0d63e15b64577ba2725e07a Mon Sep 17 00:00:00 2001 From: "hf@deer.(none)" <> Date: Thu, 20 Nov 2003 12:55:48 +0400 Subject: [PATCH 14/89] SCRUM WL#1284 (warnings about --skip-name-resolve) Now MySQL will issue warnings during startup about entries in grant tables with hostnames that require resolve, and after GRANT commands with that kind of hostnames. --- include/mysqld_error.h | 3 +- sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/serbian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/share/ukrainian/errmsg.txt | 1 + sql/sql_acl.cc | 66 ++++++++++++++++++++++++++++++- sql/sql_acl.h | 1 + sql/sql_parse.cc | 13 ++++++ 27 files changed, 103 insertions(+), 3 deletions(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index a6e23fbff3a..6b37b95cc45 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -300,4 +300,5 @@ #define ER_WARN_QC_RESIZE 1281 #define ER_BAD_FT_COLUMN 1282 #define ER_UNKNOWN_KEY_CACHE 1283 -#define ER_ERROR_MESSAGES 284 +#define ER_WARN_HOSTNAME_WONT_WORK 1284 +#define ER_ERROR_MESSAGES 285 diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index c40765ebf94..02dd0b18940 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -296,3 +296,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 98540e1bd0a..f4dc64282e6 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -290,3 +290,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 44c9399b821..c034e18e055 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -298,3 +298,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index e4f7c27610b..5e2c6844507 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -287,3 +287,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index dec488567ff..43204a3979b 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -292,3 +292,4 @@ character-set=latin7 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index c41c927d539..b7b03250341 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -287,3 +287,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 0425a709950..bb8aa296d58 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -299,3 +299,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 3cf5bbf592d..70913d58ff7 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -287,3 +287,4 @@ character-set=greek "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index f1b719ba716..a79bf7b184c 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -289,3 +289,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index ed39950e9f1..c8fc5079c75 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -287,3 +287,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 9760cd3f9e8..b8ece1ecf4c 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -289,3 +289,4 @@ character-set=ujis "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 10eed3bb2de..d57c3e13efe 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -287,3 +287,4 @@ character-set=euckr "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 7149eea8b10..01f50789449 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -289,3 +289,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index dc96d39f8dc..806729ccced 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -289,3 +289,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index b2b2e52ad75..30c77b41ed0 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -291,3 +291,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index c4a150d79bf..d4232007aed 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -288,3 +288,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index dce141da20a..f4712f75180 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -291,3 +291,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 27c1b49f4f0..30b0b8b4931 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -289,3 +289,4 @@ character-set=koi8r "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu, ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index 5311fa016dc..4d2ce07e369 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -282,3 +282,4 @@ character-set=cp1250 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 9355e8fc0c4..fb062bc29e8 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -295,3 +295,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 3cdcc3967d7..c4d4e1c9e93 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -289,3 +289,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 17dcdb89ae6..143aa6af9eb 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -287,3 +287,4 @@ character-set=latin1 "Storleken av "Query cache" kunde inte sättas till %lu, ny storlek är %lu", "Kolumn '%-.64s' kan inte vara del av ett FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 99a09afde6c..416d6fac572 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -292,3 +292,4 @@ character-set=koi8u "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu, ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b54e6a95bc5..0ce544edda5 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -139,6 +139,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) READ_RECORD read_record_info; MYSQL_LOCK *lock; my_bool return_val=1; + bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; + DBUG_ENTER("acl_init"); if (!acl_cache) @@ -198,6 +200,13 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) host.access= get_access(table,2); host.access= fix_rights_for_db(host.access); host.sort= get_sort(2,host.host.hostname,host.db); + if (check_no_resolve && hostname_requires_resolving(host.host.hostname)) + { + sql_print_error("Error in table 'host' entry '%s|%s'. " + "Can't resolve '%s' if --skip-name-resolve active. Skipped", + host.host.hostname, host.db, host.host.hostname); + continue; + } #ifndef TO_BE_REMOVED if (table->fields == 8) { // Without grant @@ -259,6 +268,14 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) ACL_USER user; update_hostname(&user.host, get_field(&mem, table->field[0])); user.user= get_field(&mem, table->field[1]); + if (check_no_resolve && hostname_requires_resolving(user.host.hostname)) + { + sql_print_error("Error in table 'user' entry '%s@%s'. " + "Can't resolve '%s' if --skip-name-resolve active. Skipped", + user.user, user.host.hostname, user.host.hostname); + continue; + } + const char *password= get_field(&mem, table->field[2]); uint password_len= password ? strlen(password) : 0; set_user_salt(&user, password, password_len); @@ -353,6 +370,13 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) continue; } db.user=get_field(&mem, table->field[2]); + if (check_no_resolve && hostname_requires_resolving(db.host.hostname)) + { + sql_print_error("Error in table 'db' entry '%s %s@%s'. " + "Can't resolve '%s' if --skip-name-resolve active. Skipped", + db.db, db.user, db.host.hostname, db.host.hostname); + continue; + } db.access=get_access(table,3); db.access=fix_rights_for_db(db.access); db.sort=get_sort(3,db.host.hostname,db.db,db.user); @@ -1257,6 +1281,25 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname, (ip && !wild_compare(ip,host->hostname,0))); } +bool hostname_requires_resolving(const char *hostname) +{ + char cur; + if (!hostname) + return false; + int namelen= strlen(hostname); + int lhlen= strlen(my_localhost); + if ((namelen == lhlen) && + !my_strnncoll(&my_charset_latin1, (const uchar *)hostname, namelen, + (const uchar *)my_localhost, strlen(my_localhost))) + return false; + for (; (cur=*hostname); hostname++) + { + if ((cur != '%') && (cur != '_') && (cur != '.') && + ((cur < '0') || (cur > '9'))) + return true; + } + return false; +} /* Update grants in the user and database privilege tables @@ -2444,6 +2487,7 @@ my_bool grant_init(THD *org_thd) MYSQL_LOCK *lock; my_bool return_val= 1; TABLE *t_table, *c_table; + bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; DBUG_ENTER("grant_init"); grant_option = FALSE; @@ -2493,13 +2537,31 @@ my_bool grant_init(THD *org_thd) do { GRANT_TABLE *mem_check; - if (!(mem_check=new GRANT_TABLE(t_table,c_table)) || - mem_check->ok() && my_hash_insert(&column_priv_hash,(byte*) mem_check)) + if (!(mem_check=new GRANT_TABLE(t_table,c_table)) || mem_check->ok()) { /* This could only happen if we are out memory */ grant_option= FALSE; /* purecov: deadcode */ goto end_unlock; } + + if (check_no_resolve) + { + if (hostname_requires_resolving(mem_check->host)) + { + char buff[MAX_FIELD_WIDTH]; + sql_print_error("Error in table 'tables_priv' entry '%s %s@%s'. " + "Can't resolve '%s' if --skip-name-resolve active. Skipped", + mem_check->tname, mem_check->user, + mem_check->host, mem_check->host); + continue; + } + } + + if (my_hash_insert(&column_priv_hash,(byte*) mem_check)) + { + grant_option= FALSE; + goto end_unlock; + } } while (!t_table->file->index_next(t_table->record[0])); diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 7e96f2eaff1..8b8115b10db 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -131,6 +131,7 @@ public: /* prototypes */ +bool hostname_requires_resolving(const char *hostname); my_bool acl_init(THD *thd, bool dont_read_acl_tables); void acl_reload(THD *thd); void acl_free(bool end=0); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 017ef065012..a73b2767995 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3183,6 +3183,19 @@ mysql_execute_command(THD *thd) } } } + if (specialflag & SPECIAL_NO_RESOLVE) + { + LEX_USER *user; + List_iterator user_list(lex->users_list); + while ((user=user_list++)) + { + if (hostname_requires_resolving(user->host.str)) + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_HOSTNAME_WONT_WORK, + ER(ER_WARN_HOSTNAME_WONT_WORK), + user->host.str); + } + } if (tables) { if (grant_option && check_grant(thd, From 1d84fa4d4e973678e45995cd4e0075dfa879f89f Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Thu, 20 Nov 2003 14:31:10 +0200 Subject: [PATCH 15/89] fixed memory allocation --- sql/item_cmpfunc.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 64d6b5fa7cf..8f3a1b78cd3 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1416,18 +1416,18 @@ cmp_item_row::~cmp_item_row() void cmp_item_row::store_value(Item *item) { DBUG_ENTER("cmp_item_row::store_value"); - THD *thd= current_thd; n= item->cols(); if (!comparators) - comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *)*n); + comparators= (cmp_item **) current_thd->calloc(sizeof(cmp_item *)*n); if (comparators) { item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) { - if (!(comparators[i]= cmp_item::get_comparator(item->el(i)))) - break; // new failed + if (!comparators[i]) + if (!(comparators[i]= cmp_item::get_comparator(item->el(i)))) + break; // new failed comparators[i]->store_value(item->el(i)); item->null_value|= item->el(i)->null_value; } From cc2916c4591d3801e9706dab2f967f0334bb0b7d Mon Sep 17 00:00:00 2001 From: "jani@rhols221.adsl.netsonic.fi" <> Date: Thu, 20 Nov 2003 14:33:07 +0200 Subject: [PATCH 16/89] Added multi command support for mysql client. --- client/mysql.cc | 130 +++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 63 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index af807d9fb60..f1921fbbe82 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -44,7 +44,7 @@ #include #endif -const char *VER= "14.2"; +const char *VER= "14.3"; /* Don't try to make a nice table if the data is too big */ #define MAX_COLUMN_LENGTH 1024 @@ -1665,79 +1665,82 @@ com_go(String *buffer,char *line __attribute__((unused))) buffer->length(0); // Remove query on error return error; } - error=0; buffer->length(0); - if (quick) + do { - if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql)) - return put_error(&mysql); - } - else - { - error= mysql_store_result_for_lazy(&result); - if (error) - return error; - } - - if (verbose >= 3 || !opt_silent) - mysql_end_timer(timer,time_buff); - else - time_buff[0]=0; - if (result) - { - if (!mysql_num_rows(result) && ! quick) + if (quick) { - strmov(buff, "Empty set"); + if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql)) + return put_error(&mysql); } else { - init_pager(); - if (opt_html) - print_table_data_html(result); - else if (opt_xml) - print_table_data_xml(result); - else if (vertical) - print_table_data_vertically(result); - else if (opt_silent && verbose <= 2 && !output_tables) - print_tab_data(result); - else - print_table_data(result); - sprintf(buff,"%ld %s in set", - (long) mysql_num_rows(result), - (long) mysql_num_rows(result) == 1 ? "row" : "rows"); - end_pager(); + error= mysql_store_result_for_lazy(&result); + if (error) + return error; } - } - else if (mysql_affected_rows(&mysql) == ~(ulonglong) 0) - strmov(buff,"Query OK"); - else - sprintf(buff,"Query OK, %ld %s affected", - (long) mysql_affected_rows(&mysql), - (long) mysql_affected_rows(&mysql) == 1 ? "row" : "rows"); - pos=strend(buff); - if ((warnings= mysql_warning_count(&mysql))) - { - *pos++= ','; - *pos++= ' '; - pos=int2str(warnings, pos, 10); - pos=strmov(pos, " warning"); - if (warnings != 1) - *pos++= 's'; - } - strmov(pos, time_buff); - put_info(buff,INFO_RESULT); - if (mysql_info(&mysql)) - put_info(mysql_info(&mysql),INFO_RESULT); - put_info("",INFO_RESULT); // Empty row + if (verbose >= 3 || !opt_silent) + mysql_end_timer(timer,time_buff); + else + time_buff[0]=0; + if (result) + { + if (!mysql_num_rows(result) && ! quick) + { + strmov(buff, "Empty set"); + } + else + { + init_pager(); + if (opt_html) + print_table_data_html(result); + else if (opt_xml) + print_table_data_xml(result); + else if (vertical) + print_table_data_vertically(result); + else if (opt_silent && verbose <= 2 && !output_tables) + print_tab_data(result); + else + print_table_data(result); + sprintf(buff,"%ld %s in set", + (long) mysql_num_rows(result), + (long) mysql_num_rows(result) == 1 ? "row" : "rows"); + end_pager(); + } + } + else if (mysql_affected_rows(&mysql) == ~(ulonglong) 0) + strmov(buff,"Query OK"); + else + sprintf(buff,"Query OK, %ld %s affected", + (long) mysql_affected_rows(&mysql), + (long) mysql_affected_rows(&mysql) == 1 ? "row" : "rows"); + + pos=strend(buff); + if ((warnings= mysql_warning_count(&mysql))) + { + *pos++= ','; + *pos++= ' '; + pos=int2str(warnings, pos, 10); + pos=strmov(pos, " warning"); + if (warnings != 1) + *pos++= 's'; + } + strmov(pos, time_buff); + put_info(buff,INFO_RESULT); + if (mysql_info(&mysql)) + put_info(mysql_info(&mysql),INFO_RESULT); + put_info("",INFO_RESULT); // Empty row + + if (result && !mysql_eof(result)) /* Something wrong when using quick */ + error= put_error(&mysql); + else if (unbuffered) + fflush(stdout); + mysql_free_result(result); + } while (!mysql_next_result(&mysql)); - if (result && !mysql_eof(result)) /* Something wrong when using quick */ - error= put_error(&mysql); - else if (unbuffered) - fflush(stdout); - mysql_free_result(result); return error; /* New command follows */ } @@ -2416,6 +2419,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line) } strmake(delimiter, tmp, sizeof(delimiter) - 1); delimiter_length= strlen(delimiter); + delimiter_str= delimiter; return 0; } From 0b1bae4677704ce2f34ea813aef3f56aa862a9e2 Mon Sep 17 00:00:00 2001 From: "jani@ua167d18.elisa.omakaista.fi" <> Date: Thu, 20 Nov 2003 20:06:51 +0200 Subject: [PATCH 17/89] Added error reporting if one of the multi queries failed. --- BitKeeper/etc/logging_ok | 1 + client/mysql.cc | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 86fcc8687d7..9fecdc743db 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -50,6 +50,7 @@ jani@janikt.pp.saunalahti.fi jani@rhols221.adsl.netsonic.fi jani@rhols221.arenanet.fi jani@ua126d19.elisa.omakaista.fi +jani@ua167d18.elisa.omakaista.fi jcole@abel.spaceapes.com jcole@main.burghcom.com jcole@mugatu.spaceapes.com diff --git a/client/mysql.cc b/client/mysql.cc index f1921fbbe82..059a1ad36f5 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1621,7 +1621,8 @@ com_go(String *buffer,char *line __attribute__((unused))) char buff[200], time_buff[32], *pos; MYSQL_RES *result; ulong timer, warnings; - uint error=0; + uint error= 0; + int err= 0; if (!status.batch) { @@ -1739,7 +1740,9 @@ com_go(String *buffer,char *line __attribute__((unused))) else if (unbuffered) fflush(stdout); mysql_free_result(result); - } while (!mysql_next_result(&mysql)); + } while (!(err= mysql_next_result(&mysql))); + if (err >= 1) + error= put_error(&mysql); return error; /* New command follows */ } From dd287a4cdf4b8937ce428678fa096134a5ae8a88 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Thu, 20 Nov 2003 21:21:56 +0300 Subject: [PATCH 18/89] added comments to simple_order, simple_group, no_order, skip_sort_order --- sql/sql_select.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 740b0470fdc..7f8dfd219d0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -208,8 +208,21 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, { TABLE *tmp_table; int error, tmp_error; - bool need_tmp,hidden_group_fields; - bool simple_order,simple_group,no_order, skip_sort_order; + bool need_tmp; + bool hidden_group_fields; + /* + simple_xxxxx is set if ORDER/GROUP BY doesn't include any references + to other tables than the first non-constant table in the JOIN. + It's also set if ORDER/GROUP BY is empty. + */ + bool simple_order, simple_group; + /* + Is set only in case if we have a GROUP BY clause + and no ORDER BY after constant elimination of 'order'. + */ + bool no_order; + /* Is set if we have a GROUP BY and we have ORDER BY on a constant. */ + bool skip_sort_order; ha_rows select_limit; Item::cond_result cond_value; SQL_SELECT *select; From ee46b6909c9452a8c5f6ba3f50f5e71a69986dcd Mon Sep 17 00:00:00 2001 From: "paul@ice.snake.net" <> Date: Thu, 20 Nov 2003 12:55:07 -0600 Subject: [PATCH 19/89] Typo. --- mysql-test/mysql-test-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 02d97d646a4..c343f313d47 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -1,7 +1,7 @@ #! /bin/sh # mysql-test-run - originally written by Matt Wagner # modified by Sasha Pachev -# Sligtly updated by Monty +# Slightly updated by Monty # Cleaned up again by Matt # Fixed by Sergei # :-) From 53c93091f236454365aed445fd6a376d3a23930c Mon Sep 17 00:00:00 2001 From: "paul@ice.snake.net" <> Date: Thu, 20 Nov 2003 13:07:25 -0600 Subject: [PATCH 20/89] Write slave status field names using consistent style. (Initial caps for each word.) For example, instead of writing Until_condition, Until_Log_File, and Until_log_pos, write Until_Condition, Until_Log_File, and Until_Log_pos. --- mysql-test/r/rpl000015.result | 8 +++--- mysql-test/r/rpl_empty_master_crash.result | 2 +- mysql-test/r/rpl_error_ignored_table.result | 2 +- mysql-test/r/rpl_flush_log_loop.result | 2 +- mysql-test/r/rpl_loaddata.result | 6 ++-- mysql-test/r/rpl_log.result | 2 +- mysql-test/r/rpl_log_pos.result | 8 +++--- mysql-test/r/rpl_max_relay_size.result | 12 ++++---- mysql-test/r/rpl_openssl.result | 4 +-- mysql-test/r/rpl_redirect.result | 2 +- mysql-test/r/rpl_replicate_do.result | 2 +- mysql-test/r/rpl_reset_slave.result | 8 +++--- mysql-test/r/rpl_rotate_logs.result | 6 ++-- mysql-test/r/rpl_trunc_binlog.result | 2 +- mysql-test/r/rpl_until.result | 8 +++--- mysql-test/t/mix_innodb_myisam_binlog.test | 2 +- mysql-test/t/rpl_max_relay_size.test | 2 +- sql/slave.cc | 32 ++++++++++----------- 18 files changed, 55 insertions(+), 55 deletions(-) diff --git a/mysql-test/r/rpl000015.result b/mysql-test/r/rpl000015.result index 98ad998f2ed..d048346481c 100644 --- a/mysql-test/r/rpl000015.result +++ b/mysql-test/r/rpl000015.result @@ -4,19 +4,19 @@ File Position Binlog_do_db Binlog_ignore_db master-bin.000001 79 reset slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master change master to master_host='127.0.0.1'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=MASTER_PORT; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 7 master-bin.000001 79 slave-relay-bin.000001 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # drop table if exists t1; create table t1 (n int); diff --git a/mysql-test/r/rpl_empty_master_crash.result b/mysql-test/r/rpl_empty_master_crash.result index 41c5ebe47e1..3e234d4ef59 100644 --- a/mysql-test/r/rpl_empty_master_crash.result +++ b/mysql-test/r/rpl_empty_master_crash.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master load table t1 from master; ERROR 08S01: Error connecting to master: Master is not configured load table t1 from master; diff --git a/mysql-test/r/rpl_error_ignored_table.result b/mysql-test/r/rpl_error_ignored_table.result index 2baa69d4aad..8d5bbf91561 100644 --- a/mysql-test/r/rpl_error_ignored_table.result +++ b/mysql-test/r/rpl_error_ignored_table.result @@ -8,7 +8,7 @@ create table t1 (a int primary key); insert into t1 values (1),(1); ERROR 23000: Duplicate entry '1' for key 1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 213 slave-relay-bin.000002 257 master-bin.000001 Yes Yes test.t1 0 0 213 257 None 0 No # show tables like 't1'; Tables_in_test (t1) diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result index e0f85210616..6992b635672 100644 --- a/mysql-test/r/rpl_flush_log_loop.result +++ b/mysql-test/r/rpl_flush_log_loop.result @@ -13,5 +13,5 @@ master_password='',master_port=SLAVE_PORT; start slave; flush logs; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 79 relay-log.000002 4 slave-bin.000001 Yes Yes 0 0 79 4 None 0 No # diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 092b14cacfb..d11dc6ee04c 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -32,7 +32,7 @@ load data infile '../../std_data/rpl_loaddata.dat' into table t1; set global sql_slave_skip_counter=1; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1311 slave-relay-bin.000002 1355 master-bin.000001 Yes Yes 0 0 1311 1355 None 0 No # set sql_log_bin=0; delete from t1; @@ -42,7 +42,7 @@ stop slave; change master to master_user='test'; change master to master_user='root'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1442 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 1442 4 None 0 No # set global sql_slave_skip_counter=1; start slave; @@ -53,7 +53,7 @@ load data infile '../../std_data/rpl_loaddata.dat' into table t1; stop slave; reset slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # reset master; create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 6860067a2d4..2f8a54369c9 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -95,7 +95,7 @@ slave-bin.000002 4 Query 1 4 use `test`; create table t1 (n int) slave-bin.000002 62 Query 1 62 use `test`; insert into t1 values (1) slave-bin.000002 122 Query 1 122 use `test`; drop table t1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000002 276 slave-relay-bin.000003 214 master-bin.000002 Yes Yes 0 0 276 214 None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index 098fb056cc6..581ea43ba13 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -8,7 +8,7 @@ show master status; File Position Binlog_do_db Binlog_ignore_db master-bin.000001 79 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # stop slave; change master to master_log_pos=73; @@ -16,17 +16,17 @@ start slave; stop slave; change master to master_log_pos=73; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 73 4 None 0 No # start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 48 master-bin.000001 No Yes 0 0 73 48 None 0 No # stop slave; change master to master_log_pos=173; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 173 4 None 0 No # show master status; File Position Binlog_do_db Binlog_ignore_db diff --git a/mysql-test/r/rpl_max_relay_size.result b/mysql-test/r/rpl_max_relay_size.result index 2d08ca6e3a3..8507e10ad10 100644 --- a/mysql-test/r/rpl_max_relay_size.result +++ b/mysql-test/r/rpl_max_relay_size.result @@ -15,7 +15,7 @@ select @@global.max_relay_log_size; 4096 start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000014 1221 master-bin.000001 Yes Yes 0 0 50477 1221 None 0 No # stop slave; reset slave; @@ -25,7 +25,7 @@ select @@global.max_relay_log_size; 20480 start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000004 9457 master-bin.000001 Yes Yes 0 0 50477 9457 None 0 No # stop slave; reset slave; @@ -35,25 +35,25 @@ select @@global.max_relay_log_size; 0 start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000008 1283 master-bin.000001 Yes Yes 0 0 50477 1283 None 0 No # stop slave; reset slave; flush logs; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # reset slave; start slave; flush logs; create table t1 (a int); show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50535 slave-relay-bin.000009 62 master-bin.000001 Yes Yes 0 0 50535 62 None 0 No # flush logs; drop table t1; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50583 slave-relay-bin.000010 52 master-bin.000001 Yes Yes 0 0 50583 52 None 0 No # flush logs; show master status; diff --git a/mysql-test/r/rpl_openssl.result b/mysql-test/r/rpl_openssl.result index 32760f2c870..ad7251fd631 100644 --- a/mysql-test/r/rpl_openssl.result +++ b/mysql-test/r/rpl_openssl.result @@ -19,12 +19,12 @@ select * from t1; t 1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 replssl MASTER_MYPORT 1 master-bin.000001 289 slave-relay-bin.000001 108 master-bin.000001 Yes Yes 0 0 289 108 None 0 Yes MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem # stop slave; change master to master_user='root',master_password='', master_ssl=0; start slave; drop table t1; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 337 slave-relay-bin.000001 96 master-bin.000001 Yes Yes 0 0 337 96 None 0 No MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem # diff --git a/mysql-test/r/rpl_redirect.result b/mysql-test/r/rpl_redirect.result index 24a0b1af541..9dd51eaba4d 100644 --- a/mysql-test/r/rpl_redirect.result +++ b/mysql-test/r/rpl_redirect.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; SHOW SLAVE STATUS; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master SHOW SLAVE HOSTS; Server_id Host Port Rpl_recovery_rank Master_id 2 127.0.0.1 SLAVE_PORT 2 1 diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result index 271ee9cefa1..43de4a67ce9 100644 --- a/mysql-test/r/rpl_replicate_do.result +++ b/mysql-test/r/rpl_replicate_do.result @@ -27,5 +27,5 @@ select * from t11; ERROR 42S02: Table 'test.t11' doesn't exist drop table if exists t1,t2,t11; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1281 slave-relay-bin.000002 1325 master-bin.000001 Yes Yes test.t1 0 0 1281 1325 None 0 No # diff --git a/mysql-test/r/rpl_reset_slave.result b/mysql-test/r/rpl_reset_slave.result index e1fbf12786d..42d41533cb0 100644 --- a/mysql-test/r/rpl_reset_slave.result +++ b/mysql-test/r/rpl_reset_slave.result @@ -5,20 +5,20 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # stop slave; change master to master_user='test'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 test MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 79 4 None 0 No # reset slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # stop slave; reset slave; diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 4e31164f2ec..54864e922fd 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -15,7 +15,7 @@ insert into temp_table values ("testing temporary tables"); create table t1 (s text); insert into t1 values('Could not break slave'),('Tried hard'); show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 60 master-bin.000001 417 slave-relay-bin.000001 461 master-bin.000001 Yes Yes 0 0 417 461 None 0 No # select * from t1; s @@ -56,7 +56,7 @@ Log_name master-bin.000003 insert into t2 values (65); show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 60 master-bin.000003 290 slave-relay-bin.000001 1088 master-bin.000003 Yes Yes 0 0 290 1088 None 0 No # select * from t2; m @@ -80,7 +80,7 @@ select * from t4; a testing temporary tables part 2 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 60 master-bin.000004 2886 slave-relay-bin.000001 7891 master-bin.000004 Yes Yes 0 0 2886 7891 None 0 No # lock tables t3 read; select count(*) from t3 where n >= 4; diff --git a/mysql-test/r/rpl_trunc_binlog.result b/mysql-test/r/rpl_trunc_binlog.result index caca15ab4ef..39b754dec47 100644 --- a/mysql-test/r/rpl_trunc_binlog.result +++ b/mysql-test/r/rpl_trunc_binlog.result @@ -9,5 +9,5 @@ flush logs; reset slave; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000002 4 slave-relay-bin.000002 123 master-bin.000001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 326 None 0 No # diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result index 3ee902cfc09..854a8605abb 100644 --- a/mysql-test/r/rpl_until.result +++ b/mysql-test/r/rpl_until.result @@ -30,7 +30,7 @@ n 3 4 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 332 master-bin.000001 Yes No 0 0 244 649 Master master-bin.000001 244 No # start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; select * from t1; @@ -40,7 +40,7 @@ n 3 4 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 332 master-bin.000001 Yes No 0 0 244 649 Master master-no-such-bin.000001 291 No # start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537; select * from t2; @@ -48,13 +48,13 @@ n 1 2 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 537 master-bin.000001 Yes No 0 0 449 649 Relay slave-relay-bin.000002 537 No # start slave; stop slave; start slave until master_log_file='master-bin.000001', master_log_pos=561; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 649 master-bin.000001 Yes No 0 0 561 693 Master master-bin.000001 561 No # start slave until master_log_file='master-bin', master_log_pos=561; ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index 314587feda6..26f7cbf22a0 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -3,7 +3,7 @@ # It would be nice to make this a replication test, but in 4.0 the # slave is always with --skip-innodb in the testsuite. I (Guilhem) however # did some tests manually on a slave; tables are replicated fine and -# Exec_master_log_pos advances as expected. +# Exec_Master_Log_Pos advances as expected. -- source include/have_innodb.inc diff --git a/mysql-test/t/rpl_max_relay_size.test b/mysql-test/t/rpl_max_relay_size.test index 99f0a9fdde6..a28aed52ec8 100644 --- a/mysql-test/t/rpl_max_relay_size.test +++ b/mysql-test/t/rpl_max_relay_size.test @@ -76,7 +76,7 @@ sync_with_master; --replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT --replace_column 1 # 33 # show slave status; -# one more rotation, to be sure Relay_log_space is correctly updated +# one more rotation, to be sure Relay_Log_Space is correctly updated flush logs; connection master; drop table t1; diff --git a/sql/slave.cc b/sql/slave.cc index 561b32b668c..329324efa3d 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1965,7 +1965,7 @@ int show_master_info(THD* thd, MASTER_INFO* mi) sizeof(mi->user))); field_list.push_back(new Item_return_int("Master_Port", 7, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Connect_retry", 10, + field_list.push_back(new Item_return_int("Connect_Retry", 10, MYSQL_TYPE_LONG)); field_list.push_back(new Item_empty_string("Master_Log_File", FN_REFLEN)); @@ -1979,24 +1979,24 @@ int show_master_info(THD* thd, MASTER_INFO* mi) FN_REFLEN)); field_list.push_back(new Item_empty_string("Slave_IO_Running", 3)); field_list.push_back(new Item_empty_string("Slave_SQL_Running", 3)); - field_list.push_back(new Item_empty_string("Replicate_do_db", 20)); - field_list.push_back(new Item_empty_string("Replicate_ignore_db", 20)); - field_list.push_back(new Item_empty_string("Replicate_do_table", 20)); - field_list.push_back(new Item_empty_string("Replicate_ignore_table", 23)); - field_list.push_back(new Item_empty_string("Replicate_wild_do_table", 24)); - field_list.push_back(new Item_empty_string("Replicate_wild_ignore_table", + field_list.push_back(new Item_empty_string("Replicate_Do_DB", 20)); + field_list.push_back(new Item_empty_string("Replicate_Ignore_DB", 20)); + field_list.push_back(new Item_empty_string("Replicate_Do_Table", 20)); + field_list.push_back(new Item_empty_string("Replicate_Ignore_Table", 23)); + field_list.push_back(new Item_empty_string("Replicate_Wild_Do_Table", 24)); + field_list.push_back(new Item_empty_string("Replicate_Wild_Ignore_Table", 28)); - field_list.push_back(new Item_return_int("Last_errno", 4, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Last_error", 20)); - field_list.push_back(new Item_return_int("Skip_counter", 10, + field_list.push_back(new Item_return_int("Last_Errno", 4, MYSQL_TYPE_LONG)); + field_list.push_back(new Item_empty_string("Last_Error", 20)); + field_list.push_back(new Item_return_int("Skip_Counter", 10, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Exec_master_log_pos", 10, + field_list.push_back(new Item_return_int("Exec_Master_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_return_int("Relay_log_space", 10, + field_list.push_back(new Item_return_int("Relay_Log_Space", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Until_condition", 6)); + field_list.push_back(new Item_empty_string("Until_Condition", 6)); field_list.push_back(new Item_empty_string("Until_Log_File", FN_REFLEN)); - field_list.push_back(new Item_return_int("Until_Log_pos", 10, + field_list.push_back(new Item_return_int("Until_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); field_list.push_back(new Item_empty_string("Master_SSL_Allowed", 7)); field_list.push_back(new Item_empty_string("Master_SSL_CA_File", @@ -2009,7 +2009,7 @@ int show_master_info(THD* thd, MASTER_INFO* mi) sizeof(mi->ssl_cipher))); field_list.push_back(new Item_empty_string("Master_SSL_Key", sizeof(mi->ssl_key))); - field_list.push_back(new Item_return_int("Seconds_behind_master", 10, + field_list.push_back(new Item_return_int("Seconds_Behind_Master", 10, MYSQL_TYPE_LONGLONG)); if (protocol->send_fields(&field_list, 1)) @@ -2362,7 +2362,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->options = ((opt_log_slave_updates) ? OPTION_BIN_LOG:0) | OPTION_AUTO_IS_NULL; /* - It's nonsense to constraint the slave threads with max_join_size; if a + It's nonsense to constrain the slave threads with max_join_size; if a query succeeded on master, we HAVE to execute it. */ thd->variables.max_join_size= HA_POS_ERROR; From 4909a37eac9f11efc71cbdd563cb29012e2cb88c Mon Sep 17 00:00:00 2001 From: "paul@ice.snake.net" <> Date: Thu, 20 Nov 2003 13:49:05 -0600 Subject: [PATCH 21/89] Use same style for SHOW MASTER STATUS fields as for SHOW SLAVE STATUS. --- mysql-test/r/rpl000015.result | 2 +- mysql-test/r/rpl_loaddata.result | 4 ++-- mysql-test/r/rpl_log_pos.result | 4 ++-- mysql-test/r/rpl_max_relay_size.result | 2 +- mysql-test/r/rpl_rotate_logs.result | 2 +- sql/repl_failsafe.cc | 2 +- sql/sql_repl.cc | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/rpl000015.result b/mysql-test/r/rpl000015.result index d048346481c..8cbbe3ab0e8 100644 --- a/mysql-test/r/rpl000015.result +++ b/mysql-test/r/rpl000015.result @@ -1,6 +1,6 @@ reset master; show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 79 reset slave; show slave status; diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index d11dc6ee04c..80e40924a55 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -21,7 +21,7 @@ day id category name 2003-03-22 2161 c asdf 2003-03-22 2416 a bbbbb show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB slave-bin.000001 964 drop table t1; drop table t2; @@ -63,6 +63,6 @@ terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; ERROR 23000: Duplicate entry '2003-03-22' for key 1 show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 491 drop table t2; diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index 581ea43ba13..10c78272de6 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 79 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master @@ -29,7 +29,7 @@ show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 173 4 None 0 No # show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 79 create table if not exists t1 (n int); drop table if exists t1; diff --git a/mysql-test/r/rpl_max_relay_size.result b/mysql-test/r/rpl_max_relay_size.result index 8507e10ad10..5c3360b0f66 100644 --- a/mysql-test/r/rpl_max_relay_size.result +++ b/mysql-test/r/rpl_max_relay_size.result @@ -57,5 +57,5 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50583 slave-relay-bin.000010 52 master-bin.000001 Yes Yes 0 0 50583 52 None 0 No # flush logs; show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000002 4 diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 54864e922fd..87ebf870f38 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -74,7 +74,7 @@ Log_name master-bin.000003 master-bin.000004 show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000004 2886 select * from t4; a diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index aba887be070..4ff08fd1d14 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -254,7 +254,7 @@ static int find_target_pos(LEX_MASTER_INFO *mi, IO_CACHE *log, char *errmsg) it is reworked. Event's log_pos used to be preserved through log-slave-updates to make code in repl_failsafe.cc work (this function, SHOW NEW MASTER); but on the other side it caused unexpected - values in Exec_master_log_pos in A->B->C replication setup, + values in Exec_Master_Log_Pos in A->B->C replication setup, synchronization problems in master_pos_wait(), ... So we (Dmitri & Guilhem) removed it. diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ecad84ba0cb..16996107c65 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1251,8 +1251,8 @@ int show_binlog_info(THD* thd) field_list.push_back(new Item_empty_string("File", FN_REFLEN)); field_list.push_back(new Item_return_int("Position",20, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Binlog_do_db",255)); - field_list.push_back(new Item_empty_string("Binlog_ignore_db",255)); + field_list.push_back(new Item_empty_string("Binlog_Do_DB",255)); + field_list.push_back(new Item_empty_string("Binlog_Ignore_DB",255)); if (protocol->send_fields(&field_list, 1)) DBUG_RETURN(-1); From 7c6113a39f56832da982cfb4ff191e9db49ca798 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Thu, 20 Nov 2003 22:06:25 +0200 Subject: [PATCH 22/89] Merge key cache structures to one Fixed compiler warnings (IRIX C compiler and VC++) --- VC++Files/client/mysqlclient.dsp | 4 + VC++Files/libmysql/libmysql.dsp | 4 + VC++Files/myisam/myisam.dsp | 10 +- VC++Files/mysys/mysys.dsp | 4 + heap/hp_test1.c | 4 +- heap/hp_test2.c | 11 +- include/hash.h | 11 +- include/keycache.h | 134 +++++++++ include/my_pthread.h | 4 +- include/my_sys.h | 65 ----- include/myisam.h | 9 +- include/mysql.h | 44 +-- include/sql_common.h | 2 +- include/violite.h | 2 +- isam/_locking.c | 4 +- isam/_page.c | 8 +- isam/close.c | 2 +- isam/extra.c | 2 +- isam/isamchk.c | 14 +- isam/isamdef.h | 1 + isam/isamlog.c | 8 +- isam/panic.c | 2 +- isam/test2.c | 4 +- isam/test3.c | 3 +- libmysql/client_settings.h | 18 +- libmysql/libmysql.c | 17 +- myisam/ft_boolean_search.c | 3 +- myisam/ft_dump.c | 10 +- myisam/ft_update.c | 6 +- myisam/mi_check.c | 33 +-- myisam/mi_close.c | 2 +- myisam/mi_delete_all.c | 2 +- myisam/mi_extra.c | 4 +- myisam/mi_keycache.c | 20 +- myisam/mi_locking.c | 4 +- myisam/mi_page.c | 8 +- myisam/mi_panic.c | 2 +- myisam/mi_preload.c | 6 +- myisam/mi_test1.c | 2 +- myisam/mi_test2.c | 6 +- myisam/mi_test3.c | 2 +- myisam/myisamchk.c | 14 +- myisam/myisamdef.h | 4 +- myisam/myisamlog.c | 13 +- myisam/sort.c | 22 +- myisam/sp_test.c | 7 +- mysql-test/r/case.result | 20 +- mysql-test/r/date_formats.result | 8 +- mysql-test/r/symlink.result | 4 +- mysql-test/t/case.test | 3 +- mysql-test/t/symlink.test | 4 +- mysys/hash.c | 5 + mysys/mf_keycache.c | 456 +++++++++++++------------------ mysys/mf_keycaches.c | 15 +- mysys/thr_mutex.c | 23 +- sql-common/client.c | 17 +- sql/derror.cc | 1 + sql/field.cc | 3 +- sql/ha_innodb.cc | 4 +- sql/ha_myisam.cc | 3 +- sql/ha_myisammrg.cc | 5 +- sql/handler.cc | 53 ++-- sql/handler.h | 16 +- sql/item.cc | 2 +- sql/item_cmpfunc.cc | 13 +- sql/item_func.cc | 3 - sql/item_strfunc.cc | 5 +- sql/item_sum.cc | 6 +- sql/item_timefunc.cc | 7 +- sql/mysql_priv.h | 9 +- sql/mysqld.cc | 43 ++- sql/opt_sum.cc | 1 - sql/protocol.cc | 2 + sql/protocol_cursor.cc | 6 +- sql/repl_failsafe.cc | 1 - sql/set_var.cc | 59 ++-- sql/set_var.h | 12 +- sql/sql_acl.cc | 6 +- sql/sql_base.cc | 1 - sql/sql_db.cc | 1 - sql/sql_handler.cc | 1 - sql/sql_insert.cc | 24 +- sql/sql_lex.cc | 6 +- sql/sql_parse.cc | 3 +- sql/sql_prepare.cc | 2 +- sql/sql_repl.cc | 2 - sql/sql_select.cc | 4 +- sql/sql_show.cc | 2 - sql/sql_table.cc | 10 +- sql/sql_test.cc | 14 +- sql/strfunc.cc | 2 +- sql/time.cc | 1 - strings/my_strtoll10.c | 2 +- 93 files changed, 739 insertions(+), 712 deletions(-) create mode 100644 include/keycache.h diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp index 685c9ae1a15..4a9d52232ca 100644 --- a/VC++Files/client/mysqlclient.dsp +++ b/VC++Files/client/mysqlclient.dsp @@ -100,6 +100,10 @@ SOURCE=..\strings\bmove_upp.c # End Source File # Begin Source File +SOURCE="..\mysys\charset-def.c" +# End Source File +# Begin Source File + SOURCE=..\mysys\charset.c # End Source File # Begin Source File diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index 8ab15a03110..6b76a6147ff 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -119,6 +119,10 @@ SOURCE=..\strings\bmove_upp.c # End Source File # Begin Source File +SOURCE="..\mysys\charset-def.c" +# End Source File +# Begin Source File + SOURCE=..\mysys\charset.c # End Source File # Begin Source File diff --git a/VC++Files/myisam/myisam.dsp b/VC++Files/myisam/myisam.dsp index 38cac3a0aba..0b386997e5e 100644 --- a/VC++Files/myisam/myisam.dsp +++ b/VC++Files/myisam/myisam.dsp @@ -25,7 +25,7 @@ CFG=myisam - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "myisam - Win32 Release" @@ -47,7 +47,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_release\myisam.lib" @@ -70,7 +70,7 @@ LIB32=link.exe -lib BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_Debug\myisam.lib" @@ -169,6 +169,10 @@ SOURCE=.\mi_key.c # End Source File # Begin Source File +SOURCE=.\mi_keycache.c +# End Source File +# Begin Source File + SOURCE=.\mi_locking.c # End Source File # Begin Source File diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index 54345816884..1867a3d02d4 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -126,6 +126,10 @@ SOURCE=.\array.c # End Source File # Begin Source File +SOURCE=".\charset-def.c" +# End Source File +# Begin Source File + SOURCE=.\charset.c # End Source File # Begin Source File diff --git a/heap/hp_test1.c b/heap/hp_test1.c index 96399fe4f2e..dd696528eb8 100644 --- a/heap/hp_test1.c +++ b/heap/hp_test1.c @@ -91,7 +91,7 @@ int main(int argc, char **argv) { if (i == remove_ant) { VOID(heap_close(file)) ; return (0) ; } sprintf(key,"%6d",(j=(int) ((rand() & 32767)/32767.*25))); - if ((error = heap_rkey(file,record,0,key,0,6))) + if ((error = heap_rkey(file,record,0,key,6,HA_READ_KEY_EXACT))) { if (verbose || (flags[j] == 1 || (error && my_errno != HA_ERR_KEY_NOT_FOUND))) @@ -119,7 +119,7 @@ int main(int argc, char **argv) sprintf(key,"%6d",i); bmove(record+1,key,6); my_errno=0; - error=heap_rkey(file,record,0,key,0,6); + error=heap_rkey(file,record,0,key,6,HA_READ_KEY_EXACT); if (verbose || (error == 0 && flags[i] != 1) || (error && (flags[i] != 0 || my_errno != HA_ERR_KEY_NOT_FOUND))) diff --git a/heap/hp_test2.c b/heap/hp_test2.c index 97fe1471ca1..2de49bcb66b 100644 --- a/heap/hp_test2.c +++ b/heap/hp_test2.c @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) if (j != 0) { sprintf(key,"%6d",j); - if (heap_rkey(file,record,0,key,6,0)) + if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) { printf("can't find key1: \"%s\"\n",key); goto err; @@ -239,7 +239,7 @@ int main(int argc, char *argv[]) if (!key1[j]) continue; sprintf(key,"%6d",j); - if (heap_rkey(file,record,0,key,6,0)) + if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) { printf("can't find key1: \"%s\"\n",key); goto err; @@ -289,7 +289,7 @@ int main(int argc, char *argv[]) printf("- Read first key - next - delete - next -> last\n"); DBUG_PRINT("progpos",("first - next - delete - next -> last")); - if (heap_rkey(file,record,0,key,6,0)) + if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) goto err; if (heap_rnext(file,record3)) goto err; if (heap_delete(file,record3)) goto err; @@ -513,7 +513,7 @@ int main(int argc, char *argv[]) } printf("- Read through all keys with first-next-last-prev\n"); ant=0; - for (error=heap_rkey(file,record,0,key,6,0); + for (error=heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT); ! error ; error=heap_rnext(file,record)) ant++; @@ -550,7 +550,8 @@ int main(int argc, char *argv[]) { if (error == 0) { - if (heap_rkey(file2,record2,2,record+keyinfo[2].seg[0].start,8,0)) + if (heap_rkey(file2,record2,2,record+keyinfo[2].seg[0].start,8, + HA_READ_KEY_EXACT)) { printf("can't find key3: \"%.8s\"\n", record+keyinfo[2].seg[0].start); diff --git a/include/hash.h b/include/hash.h index 3c2ae32c70e..c7cc118b7bd 100644 --- a/include/hash.h +++ b/include/hash.h @@ -22,14 +22,15 @@ extern "C" { #endif +/* + Overhead to store an element in hash + Can be used to approximate memory consumption for a hash + */ +#define HASH_OVERHEAD (sizeof(char*)*2) + typedef byte *(*hash_get_key)(const byte *,uint*,my_bool); typedef void (*hash_free_key)(void *); -typedef struct st_hash_info { - uint next; /* index to next key */ - byte *data; /* data for current entry */ -} HASH_LINK; - typedef struct st_hash { uint key_offset,key_length; /* Length of key if const length */ uint records,blength,current_record; diff --git a/include/keycache.h b/include/keycache.h new file mode 100644 index 00000000000..824c5874ffc --- /dev/null +++ b/include/keycache.h @@ -0,0 +1,134 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + 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 */ + +/* Key cache variable structures */ + +#ifndef _keycache_h +#define _keycache_h +C_MODE_START + +/* declare structures that is used by st_key_cache */ + +struct st_block_link; +typedef struct st_block_link BLOCK_LINK; +struct st_keycache_page; +typedef struct st_keycache_page KEYCACHE_PAGE; +struct st_hash_link; +typedef struct st_hash_link HASH_LINK; + +/* info about requests in a waiting queue */ +typedef struct st_keycache_wqueue +{ + struct st_my_thread_var *last_thread; /* circular list of waiting threads */ +} KEYCACHE_WQUEUE; + +#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ + +/* + The key cache structure + It also contains read-only statistics parameters. +*/ + +typedef struct st_key_cache +{ + my_bool key_cache_inited; + uint key_cache_shift; + ulong key_cache_mem_size; /* specified size of the cache memory */ + uint key_cache_block_size; /* size of the page buffer of a cache block */ + ulong min_warm_blocks; /* min number of warm blocks; */ + ulong age_threshold; /* age threshold for hot blocks */ + ulonglong keycache_time; /* total number of block link operations */ + uint hash_entries; /* max number of entries in the hash table */ + int hash_links; /* max number of hash links */ + int hash_links_used; /* number of hash links currently used */ + int disk_blocks; /* max number of blocks in the cache */ + ulong blocks_used; /* number of currently used blocks */ + ulong blocks_changed; /* number of currently dirty blocks */ + ulong warm_blocks; /* number of blocks in warm sub-chain */ + long blocks_available; /* number of blocks available in the LRU chain */ + HASH_LINK **hash_root; /* arr. of entries into hash table buckets */ + HASH_LINK *hash_link_root; /* memory for hash table links */ + HASH_LINK *free_hash_list; /* list of free hash links */ + BLOCK_LINK *block_root; /* memory for block links */ + byte HUGE_PTR *block_mem; /* memory for block buffers */ + BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */ + BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */ + pthread_mutex_t cache_lock; /* to lock access to the cache structure */ + KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */ + KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ + BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/ + BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/ + + /* + The following variables are and variables used to hold parameters for + initializing the key cache. + */ + + ulonglong param_buff_size; /* size the memory allocated for the cache */ + ulong param_block_size; /* size of the blocks in the key cache */ + ulong param_division_limit; /* min. percentage of warm blocks */ + ulong param_age_threshold; /* determines when hot block is downgraded */ + + /* Statistics variables */ + ulong global_blocks_used; /* number of currently used blocks */ + ulong global_blocks_changed; /* number of currently dirty blocks */ + ulong global_cache_w_requests;/* number of write requests (write hits) */ + ulong global_cache_write; /* number of writes from the cache to files */ + ulong global_cache_r_requests;/* number of read requests (read hits) */ + ulong global_cache_read; /* number of reads from files to the cache */ + int blocks; /* max number of blocks in the cache */ + my_bool in_init; /* Set to 1 in MySQL during init/resize */ + + /* optional call back function */ + void (*action)(struct st_key_cache *); +} KEY_CACHE; + +/* The default key cache */ +extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache; + +extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold); +extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold); +extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, + uint age_threshold); +extern byte *key_cache_read(KEY_CACHE *keycache, + File file, my_off_t filepos, int level, + byte *buff, uint length, + uint block_length,int return_buffer); +extern int key_cache_insert(KEY_CACHE *keycache, + File file, my_off_t filepos, int level, + byte *buff, uint length); +extern int key_cache_write(KEY_CACHE *keycache, + File file, my_off_t filepos, int level, + byte *buff, uint length, + uint block_length,int force_write); +extern int flush_key_blocks(KEY_CACHE *keycache, + int file, enum flush_type type); +extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup); + +/* Functions to handle multiple key caches */ +extern my_bool multi_keycache_init(void); +extern void multi_keycache_free(void); +extern KEY_CACHE *multi_key_cache_search(byte *key, uint length); +extern my_bool multi_key_cache_set(const byte *key, uint length, + KEY_CACHE *key_cache); +extern void multi_key_cache_change(KEY_CACHE *old_data, + KEY_CACHE *new_data); +C_MODE_END +#endif /* _keycache_h */ diff --git a/include/my_pthread.h b/include/my_pthread.h index a4ea88b20f0..44e6edcddec 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -468,7 +468,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); typedef struct st_safe_mutex_t { pthread_mutex_t global,mutex; - char *file; + const char *file; uint line,count; pthread_t thread; #ifdef SAFE_MUTEX_DETECT_DESTROY @@ -487,7 +487,7 @@ typedef struct st_safe_mutex_info_t { struct st_safe_mutex_info_t *next; struct st_safe_mutex_info_t *prev; - char *init_file; + const char *init_file; uint32 init_line; } safe_mutex_info_t; #endif /* SAFE_MUTEX_DETECT_DESTROY */ diff --git a/include/my_sys.h b/include/my_sys.h index d1c7b658665..604eaf34fb7 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -505,44 +505,6 @@ my_off_t my_b_append_tell(IO_CACHE* info); typedef uint32 ha_checksum; -/* Pointer to a key cache data structure (see the key cache module) */ -typedef struct st_key_cache* KEY_CACHE_HANDLE; - -/* Key cache variable structure */ -/* - The structure contains the parameters of a key cache that can - be set and undated by regular set global statements. - It also contains read-only statistics parameters. - If the corresponding key cache data structure has been already - created the variable contains the key cache handle. - The variables are put into a named list called key_caches. - At present the variables are only added to this list. -*/ -typedef struct st_key_cache_var -{ - ulonglong buff_size; /* size the memory allocated for the cache */ - ulong block_size; /* size of the blocks in the key cache */ - ulong division_limit; /* min. percentage of warm blocks */ - ulong age_threshold; /* determines when hot block is downgraded */ - KEY_CACHE_HANDLE cache; /* handles for the current and registered */ - ulong blocks_used; /* number of currently used blocks */ - ulong blocks_changed; /* number of currently dirty blocks */ - ulong cache_w_requests; /* number of write requests (write hits) */ - ulong cache_write; /* number of writes from the cache to files */ - ulong cache_r_requests; /* number of read requests (read hits) */ - ulong cache_read; /* number of reads from files to the cache */ - int blocks; /* max number of blocks in the cache */ - my_bool in_init; /* Set to 1 in MySQL during init/resize */ - struct st_key_cache_asmt *assign_list; /* list of assignments to the cache */ - int assignments; /* number of not completed assignments */ - void (*action)(void *); /* optional call back function */ - void *extra_info; /* ptr to extra info */ -} KEY_CACHE_VAR; - - -extern KEY_CACHE_HANDLE *dflt_keycache; -extern KEY_CACHE_VAR dflt_key_cache_var; - #include /* Prototypes for mysys and my_func functions */ @@ -682,33 +644,6 @@ extern int flush_write_cache(RECORD_CACHE *info); extern long my_clock(void); extern sig_handler sigtstp_handler(int signal_number); extern void handle_recived_signals(void); -extern int init_key_cache(KEY_CACHE_HANDLE *pkeycache, - uint key_cache_block_size, - ulong use_mem, KEY_CACHE_VAR* env); -extern int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, - uint key_cache_block_size, ulong use_mem); -extern void change_key_cache_param(KEY_CACHE_HANDLE keycache); -extern byte *key_cache_read(KEY_CACHE_HANDLE keycache, - File file, my_off_t filepos, int level, - byte* buff, uint length, - uint block_length,int return_buffer); -extern int key_cache_insert(KEY_CACHE_HANDLE keycache, - File file, my_off_t filepos, int level, - byte *buff, uint length); -extern int key_cache_write(KEY_CACHE_HANDLE keycache, - File file, my_off_t filepos, int level, - byte* buff, uint length, - uint block_length,int force_write); -extern int flush_key_blocks(KEY_CACHE_HANDLE keycache, - int file, enum flush_type type); -extern void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup); -extern my_bool multi_keycache_init(void); -extern void multi_keycache_free(void); -extern KEY_CACHE_HANDLE *multi_key_cache_search(byte *key, uint length); -extern my_bool multi_key_cache_set(const byte *key, uint length, - KEY_CACHE_HANDLE *key_cache); -extern void multi_key_cache_change(KEY_CACHE_HANDLE *old_data, - KEY_CACHE_HANDLE *new_data); extern sig_handler my_set_alarm_variable(int signo); extern void my_string_ptr_sort(void *base,uint items,size_s size); diff --git a/include/myisam.h b/include/myisam.h index 52f2948aaef..613a9965832 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -28,6 +28,9 @@ extern "C" { #ifndef _m_ctype_h #include #endif +#ifndef _keycache_h +#include "keycache.h" +#endif #include "my_handler.h" /* defines used by myisam-funktions */ @@ -408,9 +411,9 @@ int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows); void mi_flush_bulk_insert(MI_INFO *info, uint inx); void mi_end_bulk_insert(MI_INFO *info); int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map, - KEY_CACHE_VAR *key_cache); -void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache); + KEY_CACHE *key_cache); +void mi_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache); int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves); #ifdef __cplusplus diff --git a/include/mysql.h b/include/mysql.h index 7df42460c6d..23d89fd531f 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -535,10 +535,10 @@ typedef struct st_mysql_stmt char *query; /* query buffer */ MEM_ROOT mem_root; /* root allocations */ my_ulonglong last_fetched_column; /* last fetched column */ - unsigned long param_count; /* parameters count */ - unsigned long field_count; /* fields count */ unsigned long stmt_id; /* Id for prepared statement */ unsigned int last_errno; /* error code */ + unsigned int param_count; /* parameters count */ + unsigned int field_count; /* fields count */ enum PREP_STMT_STATE state; /* statement state */ char last_error[MYSQL_ERRMSG_SIZE]; /* error message */ char sqlstate[SQLSTATE_LENGTH+1]; @@ -552,27 +552,27 @@ typedef struct st_mysql_stmt typedef struct st_mysql_methods { - my_bool (* STDCALL read_query_result)(MYSQL *mysql); - my_bool (* STDCALL advanced_command)(MYSQL *mysql, - enum enum_server_command command, - const char *header, - unsigned long header_length, - const char *arg, - unsigned long arg_length, - my_bool skip_check); - MYSQL_DATA *(* STDCALL read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - unsigned int fields); - MYSQL_RES * (* STDCALL use_result)(MYSQL *mysql); - void (* STDCALL fetch_lengths)(unsigned long *to, - MYSQL_ROW column, unsigned int field_count); + my_bool (*read_query_result)(MYSQL *mysql); + my_bool (*advanced_command)(MYSQL *mysql, + enum enum_server_command command, + const char *header, + unsigned long header_length, + const char *arg, + unsigned long arg_length, + my_bool skip_check); + MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, + unsigned int fields); + MYSQL_RES * (*use_result)(MYSQL *mysql); + void (*fetch_lengths)(unsigned long *to, + MYSQL_ROW column, unsigned int field_count); #if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) - MYSQL_FIELD * (* STDCALL list_fields)(MYSQL *mysql); - my_bool (* STDCALL read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); - int (* STDCALL stmt_execute)(MYSQL_STMT *stmt); - MYSQL_DATA *(* STDCALL read_binary_rows)(MYSQL_STMT *stmt); - int (* STDCALL unbuffered_fetch)(MYSQL *mysql, char **row); - void (* STDCALL free_embedded_thd)(MYSQL *mysql); - const char *(* STDCALL read_statistic)(MYSQL *mysql); + MYSQL_FIELD * (*list_fields)(MYSQL *mysql); + my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); + int (*stmt_execute)(MYSQL_STMT *stmt); + MYSQL_DATA *(*read_binary_rows)(MYSQL_STMT *stmt); + int (*unbuffered_fetch)(MYSQL *mysql, char **row); + void (*free_embedded_thd)(MYSQL *mysql); + const char *(*read_statistic)(MYSQL *mysql); #endif } MYSQL_METHODS; diff --git a/include/sql_common.h b/include/sql_common.h index 1f442339c4f..1c374030a55 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -34,7 +34,7 @@ void end_server(MYSQL *mysql); my_bool mysql_reconnect(MYSQL *mysql); void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group); -my_bool STDCALL +my_bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command, const char *header, ulong header_length, const char *arg, ulong arg_length, my_bool skip_check); diff --git a/include/violite.h b/include/violite.h index 37c5abbbe67..e8f30288d34 100644 --- a/include/violite.h +++ b/include/violite.h @@ -177,7 +177,7 @@ struct st_vio void (*viodelete)(Vio*); int (*vioerrno)(Vio*); int (*read)(Vio*, gptr, int); - int (*write)(Vio*, gptr, int); + int (*write)(Vio*, const gptr, int); int (*vioblocking)(Vio*, my_bool, my_bool *); my_bool (*is_blocking)(Vio*); int (*viokeepalive)(Vio*, my_bool); diff --git a/isam/_locking.c b/isam/_locking.c index 0ffb46a81f8..e19804549e5 100644 --- a/isam/_locking.c +++ b/isam/_locking.c @@ -50,7 +50,7 @@ int nisam_lock_database(N_INFO *info, int lock_type) else count= --share->w_locks; if (info->lock_type == F_WRLCK && !share->w_locks && - flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_KEEP)) + flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_KEEP)) error=my_errno; if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) if (end_io_cache(&info->rec_cache)) @@ -329,7 +329,7 @@ int _nisam_test_if_changed(register N_INFO *info) share->state.uniq != info->last_uniq) { /* Keyfile has changed */ if (share->state.process != share->this_process) - VOID(flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_RELEASE)); + VOID(flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_RELEASE)); share->last_process=share->state.process; info->last_loop= share->state.loop; info->last_uniq= share->state.uniq; diff --git a/isam/_page.c b/isam/_page.c index 60f1dfb0ce6..e31115e624f 100644 --- a/isam/_page.c +++ b/isam/_page.c @@ -27,7 +27,7 @@ uchar *_nisam_fetch_keypage(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t page, uchar *buff, int return_buffer) { uchar *tmp; - tmp=(uchar*) key_cache_read(*dflt_keycache, + tmp=(uchar*) key_cache_read(dflt_key_cache, info->s->kfile,page,DFLT_INIT_HITS,(byte*) buff, (uint) keyinfo->base.block_length, (uint) keyinfo->base.block_length, @@ -84,7 +84,7 @@ int _nisam_write_keypage(register N_INFO *info, register N_KEYDEF *keyinfo, length=keyinfo->base.block_length; } #endif - return (key_cache_write(*dflt_keycache, + return (key_cache_write(dflt_key_cache, info->s->kfile,page,DFLT_INIT_HITS, (byte*) buff,length, (uint) keyinfo->base.block_length, @@ -102,7 +102,7 @@ int _nisam_dispose(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t pos) old_link=info->s->state.key_del[keynr]; info->s->state.key_del[keynr]=(ulong) pos; - DBUG_RETURN(key_cache_write(*dflt_keycache, + DBUG_RETURN(key_cache_write(dflt_key_cache, info->s->kfile,pos,DFLT_INIT_HITS, (byte*) &old_link, sizeof(long), @@ -131,7 +131,7 @@ ulong _nisam_new(register N_INFO *info, N_KEYDEF *keyinfo) } else { - if (!key_cache_read(*dflt_keycache, + if (!key_cache_read(dflt_key_cache, info->s->kfile,pos,DFLT_INIT_HITS, (byte*) &info->s->state.key_del[keynr], (uint) sizeof(long), diff --git a/isam/close.c b/isam/close.c index 37b35e450ae..37425653a5d 100644 --- a/isam/close.c +++ b/isam/close.c @@ -57,7 +57,7 @@ int nisam_close(register N_INFO *info) if (flag) { if (share->kfile >= 0 && - flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_RELEASE)) + flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_RELEASE)) error=my_errno; if (share->kfile >= 0 && my_close(share->kfile,MYF(0))) error = my_errno; diff --git a/isam/extra.c b/isam/extra.c index 3bf1dd012ed..421404311c8 100644 --- a/isam/extra.c +++ b/isam/extra.c @@ -215,7 +215,7 @@ int nisam_extra(N_INFO *info, enum ha_extra_function function) info->s->last_version= 0L; /* Impossible version */ #ifdef __WIN__ /* Close the isam and data files as Win32 can't drop an open table */ - if (flush_key_blocks(info->s->kfile,FLUSH_RELEASE)) + if (flush_key_blocks(dflt_key_cache, info->s->kfile, FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) { diff --git a/isam/isamchk.c b/isam/isamchk.c index e59da07e85b..0c0df603da0 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -516,8 +516,8 @@ static int nisamchk(my_string filename) if (!rep_quick) { if (testflag & T_EXTEND) - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE, - use_buffers,&dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE, + use_buffers,0,0)); VOID(init_io_cache(&read_cache,datafile,(uint) read_buffer_length, READ_CACHE,share->pack.header_length,1, MYF(MY_WME))); @@ -1460,8 +1460,7 @@ my_string name; printf("Data records: %lu\n",(ulong) share->state.records); } - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,use_buffers, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,use_buffers,0,0)); if (init_io_cache(&read_cache,info->dfile,(uint) read_buffer_length, READ_CACHE,share->pack.header_length,1,MYF(MY_WME))) goto err; @@ -1889,12 +1888,12 @@ static void lock_memory(void) static int flush_blocks(file) File file; { - if (flush_key_blocks(dflt_keycache,file,FLUSH_RELEASE)) + if (flush_key_blocks(dflt_key_cache,file,FLUSH_RELEASE)) { print_error("%d when trying to write bufferts",my_errno); return(1); } - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); return 0; } /* flush_blocks */ @@ -1938,8 +1937,7 @@ int write_info; if (share->state.key_root[sort_key] == NI_POS_ERROR) DBUG_RETURN(0); /* Nothing to do */ - init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,use_buffers, - &dflt_key_cache_var); + init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,use_buffers, 0, 0); if (init_io_cache(&info->rec_cache,-1,(uint) write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) diff --git a/isam/isamdef.h b/isam/isamdef.h index 54656b6842e..7d89730fe32 100644 --- a/isam/isamdef.h +++ b/isam/isamdef.h @@ -24,6 +24,7 @@ #else #include #endif +#include #ifdef my_write #undef my_write /* We want test if disk full */ diff --git a/isam/isamlog.c b/isam/isamlog.c index d8ea9d4ed80..75a35ef9704 100644 --- a/isam/isamlog.c +++ b/isam/isamlog.c @@ -329,8 +329,8 @@ static int examine_log(my_string file_name, char **table_names) bzero((gptr) com_count,sizeof(com_count)); init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (tree_element_free) file_info_free, NULL); - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, + 0,0)); files_open=0; access_time=0; while (access_time++ != number_of_commands && !my_b_read(&cache,(byte*) head,9)) @@ -622,7 +622,7 @@ static int examine_log(my_string file_name, char **table_names) goto end; } } - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); @@ -642,7 +642,7 @@ static int examine_log(my_string file_name, char **table_names) llstr(isamlog_filepos,llbuff))); fflush(stderr); end: - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); diff --git a/isam/panic.c b/isam/panic.c index de765f50e62..7af979a5104 100644 --- a/isam/panic.c +++ b/isam/panic.c @@ -48,7 +48,7 @@ int nisam_panic(enum ha_panic_function flag) if (info->s->base.options & HA_OPTION_READ_ONLY_DATA) break; #endif - if (flush_key_blocks(*dflt_keycache,info->s->kfile,FLUSH_RELEASE)) + if (flush_key_blocks(dflt_key_cache,info->s->kfile,FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & WRITE_CACHE_USED) if (flush_io_cache(&info->rec_cache)) diff --git a/isam/test2.c b/isam/test2.c index 67b411d1bbf..14a40f39865 100644 --- a/isam/test2.c +++ b/isam/test2.c @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) goto err; printf("- Writing key:s\n"); if (key_cacheing) - init_key_cache(dflt_keycache,512,IO_SIZE*16,0); /* Use a small cache */ + init_key_cache(dflt_key_cache,512,IO_SIZE*16,0,0); /* Use a small cache */ if (locking) nisam_lock_database(file,F_WRLCK); if (write_cacheing) @@ -674,7 +674,7 @@ end: puts("Locking used"); if (use_blob) puts("blobs used"); - end_key_cache(&dflt_keycache,1); + end_key_cache(dflt_key_cache,1); if (blob_buffer) my_free(blob_buffer,MYF(0)); my_end(MY_CHECK_ERROR | MY_GIVE_INFO); diff --git a/isam/test3.c b/isam/test3.c index 1b867ba0348..9195fcbf1b6 100644 --- a/isam/test3.c +++ b/isam/test3.c @@ -20,6 +20,7 @@ #include "nisam.h" #include +#include #ifdef HAVE_SYS_WAIT_H # include #endif @@ -173,7 +174,7 @@ void start_test(int id) exit(1); } if (key_cacheing && rnd(2) == 0) - init_key_cache(dflt_keycache,512,65536L,0); + init_key_cache(dflt_key_cache,512,65536L,0,0); printf("Process %d, pid: %d\n",id,(int) getpid()); fflush(stdout); for (error=i=0 ; i < tests && !error; i++) diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index 582f9613ee0..3798eaa3544 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -43,18 +43,18 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename); void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group); -MYSQL * STDCALL +MYSQL * cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user, const char *passwd, const char *db, uint port, const char *unix_socket,ulong client_flag); -void STDCALL cli_mysql_close(MYSQL *mysql); +void cli_mysql_close(MYSQL *mysql); -MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql); -my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt); -MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, +MYSQL_FIELD * cli_list_fields(MYSQL *mysql); +my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt); +MYSQL_DATA * cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, uint fields); -int STDCALL cli_stmt_execute(MYSQL_STMT *stmt); -MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt); -int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row); -const char * STDCALL cli_read_statistic(MYSQL *mysql); +int cli_stmt_execute(MYSQL_STMT *stmt); +MYSQL_DATA * cli_read_binary_rows(MYSQL_STMT *stmt); +int cli_unbuffered_fetch(MYSQL *mysql, char **row); +const char * cli_read_statistic(MYSQL *mysql); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4f0a6aef11b..980cc2bef4c 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -973,16 +973,16 @@ mysql_list_tables(MYSQL *mysql, const char *wild) DBUG_RETURN (mysql_store_result(mysql)); } -MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql) +MYSQL_FIELD *cli_list_fields(MYSQL *mysql) { MYSQL_DATA *query; if (!(query= cli_read_rows(mysql,(MYSQL_FIELD*) 0, protocol_41(mysql) ? 8 : 6))) return NULL; - mysql->field_count= query->rows; + mysql->field_count= (uint) query->rows; return unpack_fields(query,&mysql->field_alloc, - query->rows, 1, mysql->server_capabilities); + mysql->field_count, 1, mysql->server_capabilities); } @@ -1112,7 +1112,7 @@ mysql_dump_debug_info(MYSQL *mysql) DBUG_RETURN(simple_command(mysql,COM_DEBUG,0,0,0)); } -const char * STDCALL cli_read_statistic(MYSQL *mysql) +const char *cli_read_statistic(MYSQL *mysql) { mysql->net.read_pos[mysql->packet_length]=0; /* End of stat string */ if (!mysql->net.read_pos[0]) @@ -1589,7 +1589,7 @@ static my_bool my_realloc_str(NET *net, ulong length) 1 error */ -my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) +my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) { uchar *pos; uint field_count; @@ -2010,7 +2010,8 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length) DBUG_RETURN(0); } -int STDCALL cli_stmt_execute(MYSQL_STMT *stmt) + +int cli_stmt_execute(MYSQL_STMT *stmt) { DBUG_ENTER("cli_stmt_execute"); @@ -2985,7 +2986,7 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row) return 0; } -int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row) +int cli_unbuffered_fetch(MYSQL *mysql, char **row) { if (packet_error == net_safe_read(mysql)) return 1; @@ -3109,7 +3110,7 @@ no_data: Read all rows of data from server (binary format) */ -MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt) +MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt) { ulong pkt_len; uchar *cp; diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index f3b593f7341..e44516c16d6 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -251,7 +251,8 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) } /* going up to the first-level tree to continue search there */ - _mi_dpointer(info, ftbw->word+ftbw->off+HA_FT_WLEN, ftbw->key_root); + _mi_dpointer(info, (uchar*) (ftbw->word+ftbw->off+HA_FT_WLEN), + ftbw->key_root); ftbw->key_root=info->s->state.key_root[ftb->keynr]; ftbw->keyinfo=info->s->keyinfo+ftb->keynr; ftbw->off=0; diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c index 5591a6ddb3e..8c40878cf00 100644 --- a/myisam/ft_dump.c +++ b/myisam/ft_dump.c @@ -80,7 +80,7 @@ int main(int argc,char *argv[]) if (argc < 2) usage(); - init_key_cache(dflt_keycache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT,0); + init_key_cache(dflt_key_cache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0); if (!(info=mi_open(argv[0],2,HA_OPEN_ABORT_IF_LOCKED))) goto err; @@ -172,9 +172,9 @@ int main(int argc,char *argv[]) if (dump) { if (subkeys>=0) - printf("%9qx %20.7f %s\n",info->lastpos,weight,buf); + printf("%9lx %20.7f %s\n", (long) info->lastpos,weight,buf); else - printf("%9qx => %17d %s\n",info->lastpos,-subkeys,buf); + printf("%9lx => %17d %s\n",(long) info->lastpos,-subkeys,buf); } if (verbose && (total%HOW_OFTEN_TO_WRITE)==0) printf("%10ld\r",total); @@ -189,12 +189,12 @@ int main(int argc,char *argv[]) if ((ulong) count >= total/2) break; } - printf("Total rows: %qu\nTotal words: %lu\n" + printf("Total rows: %lu\nTotal words: %lu\n" "Unique words: %lu\nLongest word: %lu chars (%s)\n" "Median length: %u\n" "Average global weight: %f\n" "Most common word: %lu times, weight: %f (%s)\n", - (ulonglong)info->state->records, total, uniq, maxlen, buf_maxlen, + (long) info->state->records, total, uniq, maxlen, buf_maxlen, inx, avg_gws/uniq, max_doc_cnt, min_gws, buf_min_gws); } if (lstats) diff --git a/myisam/ft_update.c b/myisam/ft_update.c index a87f239b8f8..b94a174b292 100644 --- a/myisam/ft_update.c +++ b/myisam/ft_update.c @@ -304,7 +304,7 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key) my_off_t root; DYNAMIC_ARRAY *da=info->ft1_to_ft2; MI_KEYDEF *keyinfo=&info->s->ft2_keyinfo; - uchar *key_ptr=dynamic_array_ptr(da, 0), *end; + uchar *key_ptr= (uchar*) dynamic_array_ptr(da, 0), *end; uint length, key_length; DBUG_ENTER("_mi_ft_convert_to_ft2"); @@ -329,13 +329,13 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key) DBUG_RETURN(-1); /* inserting the rest of key values */ - end=dynamic_array_ptr(da, da->elements); + end= (uchar*) dynamic_array_ptr(da, da->elements); for (key_ptr+=length; key_ptr < end; key_ptr+=keyinfo->keylength) if(_mi_ck_real_write_btree(info, keyinfo, key_ptr, 0, &root, SEARCH_SAME)) DBUG_RETURN(-1); /* now, writing the word key entry */ - ft_intXstore(key+key_length, -da->elements); + ft_intXstore(key+key_length, - (int) da->elements); _mi_dpointer(info, key+key_length+HA_FT_WLEN, root); DBUG_RETURN(_mi_ck_real_write_btree(info, diff --git a/myisam/mi_check.c b/myisam/mi_check.c index cfdb696b60b..448e847f6e1 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -242,7 +242,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) if (next_link > info->state->key_file_length || next_link & (info->s->blocksize-1)) DBUG_RETURN(1); - if (!(buff=key_cache_read(*info->s->key_cache, + if (!(buff=key_cache_read(info->s->key_cache, info->s->kfile, next_link, DFLT_INIT_HITS, (byte*) info->buff, myisam_block_size, block_size, 1))) @@ -262,7 +262,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) } /* check_k_link */ - /* Kontrollerar storleken p} filerna */ + /* Check sizes of files */ int chk_size(MI_CHECK *param, register MI_INFO *info) { @@ -273,8 +273,9 @@ int chk_size(MI_CHECK *param, register MI_INFO *info) if (!(param->testflag & T_SILENT)) puts("- check file-size"); - flush_key_blocks(*info->s->key_cache, - info->s->kfile, FLUSH_FORCE_WRITE); /* If called externally */ + /* The following is needed if called externally (not from myisamchk) */ + flush_key_blocks(info->s->key_cache, + info->s->kfile, FLUSH_FORCE_WRITE); size=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0)); if ((skr=(my_off_t) info->state->key_file_length) != size) @@ -502,7 +503,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) param->record_checksum=old_record_checksum-init_checksum; /* Remove delete links */ else param->record_checksum=0; - DBUG_RETURN(0); + DBUG_RETURN(result); } /* chk_key */ @@ -1143,8 +1144,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, param->testflag|=T_REP; /* for easy checking */ if (!param->using_global_keycache) - VOID(init_key_cache(dflt_keycache, param->key_cache_block_size, - param->use_buffers, &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache, param->key_cache_block_size, + param->use_buffers, 0, 0)); if (init_io_cache(¶m->read_cache,info->dfile, (uint) param->read_buffer_length, @@ -1365,7 +1366,7 @@ err: VOID(end_io_cache(¶m->read_cache)); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); VOID(end_io_cache(&info->rec_cache)); - got_error|=flush_blocks(param, *share->key_cache, share->kfile); + got_error|=flush_blocks(param, share->key_cache, share->kfile); if (!got_error && param->testflag & T_UNPACK) { share->state.header.options[0]&= (uchar) ~HA_OPTION_COMPRESS_RECORD; @@ -1501,7 +1502,7 @@ void lock_memory(MI_CHECK *param __attribute__((unused))) /* Flush all changed blocks to disk */ -int flush_blocks(MI_CHECK *param, KEY_CACHE_HANDLE key_cache, File file) +int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file) { if (flush_key_blocks(key_cache, file, FLUSH_RELEASE)) { @@ -1564,7 +1565,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) } /* Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); share->state.version=(ulong) time((time_t*) 0); old_state= share->state; /* save state if not stored */ @@ -1874,7 +1875,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); /* Clear the pointers to the given rows */ for (i=0 ; i < share->base.keys ; i++) share->state.key_root[i]= HA_OFFSET_ERROR; @@ -1884,7 +1885,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } else { - if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) goto err; key_map= ~key_map; /* Create the missing keys */ } @@ -2076,7 +2077,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, memcpy( &share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param, *share->key_cache, share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(&info->rec_cache)); if (!got_error) { @@ -2237,7 +2238,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); /* Clear the pointers to the given rows */ for (i=0 ; i < share->base.keys ; i++) share->state.key_root[i]= HA_OFFSET_ERROR; @@ -2247,7 +2248,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } else { - if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) goto err; key_map= ~key_map; /* Create the missing keys */ } @@ -2483,7 +2484,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, memcpy(&share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param, *share->key_cache, share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(&info->rec_cache)); if (!got_error) { diff --git a/myisam/mi_close.c b/myisam/mi_close.c index 66d5b08bbc4..deb0ccee8f3 100644 --- a/myisam/mi_close.c +++ b/myisam/mi_close.c @@ -64,7 +64,7 @@ int mi_close(register MI_INFO *info) if (flag) { if (share->kfile >= 0 && - flush_key_blocks(*share->key_cache, share->kfile, + flush_key_blocks(share->key_cache, share->kfile, share->temporary ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE)) error=my_errno; diff --git a/myisam/mi_delete_all.c b/myisam/mi_delete_all.c index 357df9ebe3e..3033249886f 100644 --- a/myisam/mi_delete_all.c +++ b/myisam/mi_delete_all.c @@ -53,7 +53,7 @@ int mi_delete_all_rows(MI_INFO *info) If we are using delayed keys or if the user has done changes to the tables since it was locked then there may be key blocks in the key cache */ - flush_key_blocks(*share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED); if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) || my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) ) goto err; diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index 327d795d17b..fcc753b62e5 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -283,7 +283,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) #ifdef __WIN__ /* Close the isam and data files as Win32 can't drop an open table */ pthread_mutex_lock(&share->intern_lock); - if (flush_key_blocks(*share->keycache, share->kfile, + if (flush_key_blocks(share->key_cache, share->kfile, (function == HA_EXTRA_FORCE_REOPEN ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED))) { @@ -329,7 +329,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) break; case HA_EXTRA_FLUSH: if (!share->temporary) - flush_key_blocks(*share->key_cache, share->kfile, FLUSH_KEEP); + flush_key_blocks(share->key_cache, share->kfile, FLUSH_KEEP); #ifdef HAVE_PWRITE _mi_decrement_open_count(info); #endif diff --git a/myisam/mi_keycache.c b/myisam/mi_keycache.c index c6fd1801740..2c808c68c98 100644 --- a/myisam/mi_keycache.c +++ b/myisam/mi_keycache.c @@ -49,19 +49,19 @@ int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map __attribute__((unused)), - KEY_CACHE_VAR *key_cache) + KEY_CACHE *key_cache) { int error= 0; MYISAM_SHARE* share= info->s; DBUG_ENTER("mi_assign_to_key_cache"); DBUG_PRINT("enter",("old_key_cache_handle: %lx new_key_cache_handle: %lx", - share->key_cache, &key_cache->cache)); + share->key_cache, key_cache)); /* Skip operation if we didn't change key cache. This can happen if we call this for all open instances of the same table */ - if (*share->key_cache == key_cache->cache) + if (share->key_cache == key_cache) DBUG_RETURN(0); /* @@ -76,7 +76,7 @@ int mi_assign_to_key_cache(MI_INFO *info, in the old key cache. */ - if (flush_key_blocks(*share->key_cache, share->kfile, FLUSH_REMOVE)) + if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_REMOVE)) { error= my_errno; mi_mark_crashed(info); /* Mark that table must be checked */ @@ -90,13 +90,13 @@ int mi_assign_to_key_cache(MI_INFO *info, (This can never fail as there is never any not written data in the new key cache) */ - (void) flush_key_blocks(key_cache->cache, share->kfile, FLUSH_REMOVE); + (void) flush_key_blocks(key_cache, share->kfile, FLUSH_REMOVE); /* Tell all threads to use the new key cache This should be seen at the lastes for the next call to an myisam function. */ - share->key_cache= &key_cache->cache; + share->key_cache= key_cache; /* store the key cache in the global hash structure for future opens */ if (multi_key_cache_set(share->unique_file_name, share->unique_name_length, @@ -127,8 +127,8 @@ int mi_assign_to_key_cache(MI_INFO *info, */ -void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache) +void mi_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache) { LIST *pos; DBUG_ENTER("mi_change_key_cache"); @@ -141,7 +141,7 @@ void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, { MI_INFO *info= (MI_INFO*) pos->data; MYISAM_SHARE *share= info->s; - if (share->key_cache == &old_key_cache->cache) + if (share->key_cache == old_key_cache) mi_assign_to_key_cache(info, (ulonglong) ~0, new_key_cache); } @@ -150,6 +150,6 @@ void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, MyISAM list structure to ensure that another thread is not trying to open a new table that will be associted with the old key cache */ - multi_key_cache_change(&old_key_cache->cache, &new_key_cache->cache); + multi_key_cache_change(old_key_cache, new_key_cache); pthread_mutex_unlock(&THR_LOCK_myisam); } diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 2056b018a16..67ccca52d08 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -61,7 +61,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) count= --share->w_locks; --share->tot_locks; if (info->lock_type == F_WRLCK && !share->w_locks && - !share->delay_key_write && flush_key_blocks(*share->key_cache, + !share->delay_key_write && flush_key_blocks(share->key_cache, share->kfile,FLUSH_KEEP)) { error=my_errno; @@ -389,7 +389,7 @@ int _mi_test_if_changed(register MI_INFO *info) { /* Keyfile has changed */ DBUG_PRINT("info",("index file changed")); if (share->state.process != share->this_process) - VOID(flush_key_blocks(*share->key_cache, share->kfile, FLUSH_RELEASE)); + VOID(flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)); share->last_process=share->state.process; info->last_unique= share->state.unique; info->last_loop= share->state.update_count; diff --git a/myisam/mi_page.c b/myisam/mi_page.c index 0aae267e05e..8c6981afa00 100644 --- a/myisam/mi_page.c +++ b/myisam/mi_page.c @@ -32,7 +32,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_ENTER("_mi_fetch_keypage"); DBUG_PRINT("enter",("page: %ld",page)); - tmp=(uchar*) key_cache_read(*info->s->key_cache, + tmp=(uchar*) key_cache_read(info->s->key_cache, info->s->kfile, page, level, (byte*) buff, (uint) keyinfo->block_length, (uint) keyinfo->block_length, @@ -95,7 +95,7 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, length=keyinfo->block_length; } #endif - DBUG_RETURN((key_cache_write(*info->s->key_cache, + DBUG_RETURN((key_cache_write(info->s->key_cache, info->s->kfile,page, level, (byte*) buff,length, (uint) keyinfo->block_length, (int) ((info->lock_type != F_UNLCK) || @@ -117,7 +117,7 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos, info->s->state.key_del[keyinfo->block_size]=pos; mi_sizestore(buff,old_link); info->s->state.changed|= STATE_NOT_SORTED_PAGES; - DBUG_RETURN(key_cache_write(*info->s->key_cache, + DBUG_RETURN(key_cache_write(info->s->key_cache, info->s->kfile, pos , level, buff, sizeof(buff), (uint) keyinfo->block_length, @@ -146,7 +146,7 @@ my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level) } else { - if (!key_cache_read(*info->s->key_cache, + if (!key_cache_read(info->s->key_cache, info->s->kfile, pos, level, buff, (uint) sizeof(buff), diff --git a/myisam/mi_panic.c b/myisam/mi_panic.c index cefb3423ccc..78698d88c54 100644 --- a/myisam/mi_panic.c +++ b/myisam/mi_panic.c @@ -48,7 +48,7 @@ int mi_panic(enum ha_panic_function flag) if (info->s->options & HA_OPTION_READ_ONLY_DATA) break; #endif - if (flush_key_blocks(*info->s->key_cache, info->s->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(info->s->key_cache, info->s->kfile, FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & WRITE_CACHE_USED) if (flush_io_cache(&info->rec_cache)) diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index 3219c00b0e2..80489cbcd13 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -69,7 +69,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME)))) DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM); - if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE)) goto err; do @@ -87,7 +87,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) { if (mi_test_if_nod(buff)) { - if (key_cache_insert(*share->key_cache, + if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, block_length)) goto err; @@ -99,7 +99,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) } else { - if (key_cache_insert(*share->key_cache, + if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, length)) goto err; diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c index c1b76408a7c..64ffbe2db1d 100644 --- a/myisam/mi_test1.c +++ b/myisam/mi_test1.c @@ -50,7 +50,7 @@ int main(int argc,char *argv[]) MY_INIT(argv[0]); my_init(); if (key_cacheing) - init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0); + init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0,0); get_options(argc,argv); exit(run_test("test1")); diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c index 5918a2485b0..d3c3cc2c492 100644 --- a/myisam/mi_test2.c +++ b/myisam/mi_test2.c @@ -215,7 +215,7 @@ int main(int argc, char *argv[]) if (!silent) printf("- Writing key:s\n"); if (key_cacheing) - init_key_cache(dflt_keycache,key_cache_block_size,key_cache_size,0); /* Use a small cache */ + init_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size,0,0); if (locking) mi_lock_database(file,F_WRLCK); if (write_cacheing) @@ -276,7 +276,7 @@ int main(int argc, char *argv[]) } } if (key_cacheing) - resize_key_cache(dflt_keycache,key_cache_block_size,key_cache_size*2); + resize_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size*2,0,0); if (!silent) printf("- Delete\n"); @@ -829,7 +829,7 @@ reads: %10lu\n", my_cache_r_requests, my_cache_read); #endif } - end_key_cache(*dflt_keycache,1); + end_key_cache(dflt_key_cache,1); if (blob_buffer) my_free(blob_buffer,MYF(0)); my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO); diff --git a/myisam/mi_test3.c b/myisam/mi_test3.c index baeaba7bf24..dca04a9a64b 100644 --- a/myisam/mi_test3.c +++ b/myisam/mi_test3.c @@ -177,7 +177,7 @@ void start_test(int id) exit(1); } if (key_cacheing && rnd(2) == 0) - init_key_cache(dflt_keycache, KEY_CACHE_BLOCK_SIZE, 65536L,0); + init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE, 65536L, 0, 0); printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout); for (error=i=0 ; i < tests && !error; i++) diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 605baa14582..f034d6ae406 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -321,7 +321,7 @@ static struct my_option my_long_options[] = { "ft_max_word_len", OPT_FT_MAX_WORD_LEN, "", (gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_ULONG, REQUIRED_ARG, HA_FT_MAXLEN, 10, HA_FT_MAXLEN, 0, 1, 0}, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -1032,8 +1032,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) !(param->testflag & (T_FAST | T_FORCE_CREATE))) { if (param->testflag & (T_EXTEND | T_MEDIUM)) - VOID(init_key_cache(dflt_keycache,opt_key_cache_block_size, - param->use_buffers,&dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,opt_key_cache_block_size, + param->use_buffers, 0, 0)); VOID(init_io_cache(¶m->read_cache,datafile, (uint) param->read_buffer_length, READ_CACHE, @@ -1047,7 +1047,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) HA_OPTION_COMPRESS_RECORD)) || (param->testflag & (T_EXTEND | T_MEDIUM))) error|=chk_data_link(param, info, param->testflag & T_EXTEND); - error|=flush_blocks(param, *share->key_cache, share->kfile); + error|=flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(¶m->read_cache)); } if (!error) @@ -1456,8 +1456,8 @@ static int mi_sort_records(MI_CHECK *param, if (share->state.key_root[sort_key] == HA_OFFSET_ERROR) DBUG_RETURN(0); /* Nothing to do */ - init_key_cache(dflt_keycache, opt_key_cache_block_size, param->use_buffers, - &dflt_key_cache_var); + init_key_cache(dflt_key_cache, opt_key_cache_block_size, param->use_buffers, + 0, 0); if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) @@ -1571,7 +1571,7 @@ err: my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR)); sort_info.buff=0; share->state.sortkey=sort_key; - DBUG_RETURN(flush_blocks(param, *share->key_cache, share->kfile) | + DBUG_RETURN(flush_blocks(param, share->key_cache, share->kfile) | got_error); } /* sort_records */ diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 4f1bed5d50a..c92d5a76815 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -166,7 +166,7 @@ typedef struct st_mi_isam_share { /* Shared between opens */ char *data_file_name, /* Resolved path names from symlinks */ *index_file_name; byte *file_map; /* mem-map of file if possible */ - KEY_CACHE_HANDLE *key_cache; /* ref to the current key cache */ + KEY_CACHE *key_cache; /* ref to the current key cache */ MI_DECODE_TREE *decode_trees; uint16 *decode_tables; int (*read_record)(struct st_myisam_info*, my_off_t, byte*); @@ -713,7 +713,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param); #ifdef THREAD pthread_handler_decl(thr_find_all_keys,arg); #endif -int flush_blocks(MI_CHECK *param, KEY_CACHE_HANDLE key_cache, File file); +int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file); int sort_write_record(MI_SORT_PARAM *sort_param); int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong); diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index fbe8b675821..c9b00be7d9e 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -71,7 +71,7 @@ static void printf_log(const char *str,...); static bool cmp_filename(struct file_info *file_info,my_string name); static uint verbose=0,update=0,test_info=0,max_files=0,re_open_count=0, - recover=0,prefix_remove=0,opt_processes=0,opt_myisam_with_debug=0; + recover=0,prefix_remove=0,opt_processes=0; static my_string log_filename=0,filepath=0,write_filename=0,record_pos_file=0; static ulong com_count[10][3],number_of_commands=(ulong) ~0L, isamlog_process; @@ -201,9 +201,6 @@ static void get_options(register int *argc, register char ***argv) update=1; recover++; break; - case 'D': - opt_myisam_with_debug=1; - break; case 'P': opt_processes=1; break; @@ -333,8 +330,8 @@ static int examine_log(my_string file_name, char **table_names) bzero((gptr) com_count,sizeof(com_count)); init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (tree_element_free) file_info_free, NULL); - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, + 0, 0)); files_open=0; access_time=0; while (access_time++ != number_of_commands && @@ -648,7 +645,7 @@ static int examine_log(my_string file_name, char **table_names) goto end; } } - end_key_cache(*dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); @@ -668,7 +665,7 @@ static int examine_log(my_string file_name, char **table_names) llstr(isamlog_filepos,llbuff))); fflush(stderr); end: - end_key_cache(*dflt_keycache, 1); + end_key_cache(dflt_key_cache, 1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); diff --git a/myisam/sort.c b/myisam/sort.c index a41713f750f..651b2331cd1 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -84,7 +84,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, IO_CACHE *to_file, char* key, uint sort_length, uint count); -inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs); +inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file, byte *bufs); /* Creates a index of sorted keys @@ -622,21 +622,25 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys, DBUG_RETURN(0); } /* write_keys */ -inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs) + +inline int my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, byte *bufs) { int err; - uint16 len = _mi_keylength(info->keyinfo,bufs); + uint16 len = _mi_keylength(info->keyinfo, (uchar*) bufs); - if ((err= my_b_write(to_file,(byte*)&len,sizeof(len)))) + /* The following is safe as this is a local file */ + if ((err= my_b_write(to_file, (byte*)&len, sizeof(len)))) return (err); - if ((err= my_b_write(to_file,(byte*)bufs,(uint) len))) + if ((err= my_b_write(to_file,bufs, (uint) len))) return (err); return (0); } -static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_keys, - uint count, BUFFPEK *buffpek, IO_CACHE *tempfile) +static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, + register uchar **sort_keys, + uint count, BUFFPEK *buffpek, + IO_CACHE *tempfile) { uchar **end; int err; @@ -653,7 +657,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k buffpek->count=count; for (end=sort_keys+count ; sort_keys != end ; sort_keys++) { - if ((err= my_var_write(info,tempfile,*sort_keys))) + if ((err= my_var_write(info,tempfile, (byte*) *sort_keys))) DBUG_RETURN(err); } DBUG_RETURN(0); @@ -816,7 +820,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, for (idx=1;idx<=count;idx++) { int err; - if ((err= my_var_write(info,to_file,bufs))) + if ((err= my_var_write(info,to_file, (byte*) bufs))) return (err); bufs=bufs+sort_length; } diff --git a/myisam/sp_test.c b/myisam/sp_test.c index c4847217efd..16a97771887 100644 --- a/myisam/sp_test.c +++ b/myisam/sp_test.c @@ -271,7 +271,8 @@ int run_test(const char *filename) create_key(key, nrecords*upd); print_key(key," INTERSECT\n"); - hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0,0); + hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0, + HA_READ_KEY_EXACT); printf(" %ld rows\n", (long) hrows); @@ -351,7 +352,7 @@ static void print_record(char * record, my_off_t offs,const char * tail) printf(" len=%d ",len); memcpy_fixed(&ptr,pos,sizeof(char*)); if(ptr) - rtree_PrintWKB(ptr,SPDIMS); + rtree_PrintWKB((uchar*) ptr,SPDIMS); else printf(" "); printf(" offs=%ld ",(long int)offs); @@ -406,7 +407,7 @@ static void create_linestring(char *record,uint rownr) pos++; memset(blob_key,0,sizeof(blob_key)); - tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints,blob_key); + tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints, (uchar*) blob_key); int4store(pos,tmp); pos+=4; diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 9b03422f54c..e9d432de077 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -90,19 +90,21 @@ CASE WHEN 1 THEN 1 ELSE 'a' END AS c4, CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5, CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6, CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7, -CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8 +CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8, +CASE WHEN 1 THEN 1.0 END AS c9 ; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` char(1) character set latin1 collate latin1_danish_ci default NULL, - `c2` char(1) character set latin1 collate latin1_danish_ci default NULL, - `c3` char(1) default NULL, - `c4` char(1) default NULL, - `c5` char(3) default NULL, - `c6` char(3) default NULL, - `c7` double(3,1) default NULL, - `c8` double(3,1) default NULL + `c1` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '', + `c2` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '', + `c3` char(1) NOT NULL default '', + `c4` char(1) NOT NULL default '', + `c5` char(3) NOT NULL default '', + `c6` char(3) NOT NULL default '', + `c7` double(3,1) NOT NULL default '0.0', + `c8` double(3,1) NOT NULL default '0.0', + `c9` double(3,1) default NULL ) TYPE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; SELECT CASE diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 346d086f34c..5eb21c40a3e 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -120,7 +120,7 @@ date format str_to_date 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 @@ -144,7 +144,7 @@ date format con 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 @@ -168,7 +168,7 @@ date format datetime 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 @@ -192,7 +192,7 @@ date format date2 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 15 September 2001 %d %M %Y 2001-09-15 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 15 MAY 2001 %d %b %Y 2001-05-15 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index c31d1019d89..a56fe3e1462 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -40,7 +40,7 @@ t9 CREATE TABLE `t9` ( `b` char(16) NOT NULL default '', `c` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' +) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' alter table t9 rename t8, add column d int not null; alter table t8 rename t7; rename table t7 to t9; @@ -62,5 +62,5 @@ t9 CREATE TABLE `t9` ( `c` int(11) NOT NULL default '0', `d` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' +) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' drop database mysqltest; diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index 9a1b6b6bbfe..9377c6c4aef 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -57,7 +57,8 @@ CREATE TABLE t1 SELECT CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5, CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6, CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7, - CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8 + CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8, + CASE WHEN 1 THEN 1.0 END AS c9 ; SHOW CREATE TABLE t1; DROP TABLE t1; diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index 4be0cd0c6a2..f618c342936 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -65,7 +65,7 @@ drop table t1; # disable_query_log; ---error 1279,1279 +--error 1103,1103 create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam data directory="tmp"; # Check that we cannot link over a table from another database. @@ -75,7 +75,7 @@ create database mysqltest; --error 1,1 create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam index directory="/this-dir-does-not-exist"; ---error 1279,1279 +--error 1103,1103 create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam index directory="not-hard-path"; --error 1,1 diff --git a/mysys/hash.c b/mysys/hash.c index 516fa171d7c..665e3d11e8d 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -29,6 +29,11 @@ #define HIGHFIND 4 #define HIGHUSED 8 +typedef struct st_hash_info { + uint next; /* index to next key */ + byte *data; /* data for current entry */ +} HASH_LINK; + static uint hash_mask(uint hashnr,uint buffmax,uint maxlength); static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink); static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length); diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index a45d967665a..10ec72c220e 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -23,6 +23,7 @@ */ #include "mysys_priv.h" +#include #include "my_static.h" #include #include @@ -85,28 +86,22 @@ typedef pthread_cond_t KEYCACHE_CONDVAR; -/* info about requests in a waiting queue */ -typedef struct st_keycache_wqueue -{ - struct st_my_thread_var *last_thread; /* circular list of waiting threads */ -} KEYCACHE_WQUEUE; - /* descriptor of the page in the key cache block buffer */ -typedef struct st_keycache_page +struct st_keycache_page { int file; /* file to which the page belongs to */ my_off_t filepos; /* position of the page in the file */ -} KEYCACHE_PAGE; +}; /* element in the chain of a hash table bucket */ -typedef struct st_hash_link +struct st_hash_link { struct st_hash_link *next, **prev; /* to connect links in the same bucket */ struct st_block_link *block; /* reference to the block for the page: */ File file; /* from such a file */ my_off_t diskpos; /* with such an offset */ uint requests; /* number of requests for the page */ -} HASH_LINK; /* offset is always alighed for key_cache_block_size */ +}; /* simple states of a block */ #define BLOCK_ERROR 1 /* an error occured when performing disk i/o */ @@ -122,7 +117,7 @@ typedef struct st_hash_link #define PAGE_WAIT_TO_BE_READ 2 /* key cache block */ -typedef struct st_block_link +struct st_block_link { struct st_block_link *next_used, **prev_used; /* to connect links in the LRU chain (ring) */ @@ -138,52 +133,14 @@ typedef struct st_block_link uint hits_left; /* number of hits left until promotion */ ulonglong last_hit_time; /* timestamp of the last hit */ KEYCACHE_CONDVAR *condvar; /* condition variable for 'no readers' event */ -} BLOCK_LINK; - -KEY_CACHE_VAR dflt_key_cache_var= -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -KEY_CACHE_HANDLE *dflt_keycache= &dflt_key_cache_var.cache; -#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ +KEY_CACHE dflt_key_cache_var; +KEY_CACHE *dflt_key_cache= &dflt_key_cache_var; + #define FLUSH_CACHE 2000 /* sort this many blocks at once */ -typedef struct st_key_cache -{ - KEY_CACHE_VAR *env; /* pointer to key cache variables (if any) */ - my_bool key_cache_inited; - uint key_cache_shift; - ulong key_cache_mem_size; /* specified size of the cache memory */ - uint key_cache_block_size; /* size of the page buffer of a cache block */ - ulong min_warm_blocks; /* min number of warm blocks; */ - ulong age_threshold; /* age threshold for hot blocks */ - ulonglong keycache_time; /* total number of block link operations */ - uint hash_entries; /* max number of entries in the hash table */ - int hash_links; /* max number of hash links */ - int hash_links_used; /* number of hash links currently used */ - int disk_blocks; /* max number of blocks in the cache */ - ulong blocks_used; /* number of currently used blocks */ - ulong blocks_changed; /* number of currently dirty blocks */ - ulong warm_blocks; /* number of blocks in warm sub-chain */ -#if defined(KEYCACHE_DEBUG) - long blocks_available; /* number of blocks available in the LRU chain */ -#endif - HASH_LINK **hash_root; /* arr. of entries into hash table buckets */ - HASH_LINK *hash_link_root; /* memory for hash table links */ - HASH_LINK *free_hash_list; /* list of free hash links */ - BLOCK_LINK *block_root; /* memory for block links */ - byte HUGE_PTR *block_mem; /* memory for block buffers */ - BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */ - BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */ - pthread_mutex_t cache_lock; /* to lock access to the cache structure */ - KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */ - KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ - BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/ - BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/ -} KEY_CACHE; - -static int flush_all_key_blocks(KEY_CACHE_HANDLE keycache); +static int flush_all_key_blocks(KEY_CACHE *keycache); static void test_key_cache(KEY_CACHE *keycache, const char *where, my_bool lock); @@ -202,10 +159,10 @@ static void test_key_cache(KEY_CACHE *keycache, static FILE *keycache_debug_log=NULL; static void keycache_debug_print _VARARGS((const char *fmt,...)); #define KEYCACHE_DEBUG_OPEN \ - keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w") + if (!keycache_debug_log) keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w") #define KEYCACHE_DEBUG_CLOSE \ - if (keycache_debug_log) fclose(keycache_debug_log) + if (keycache_debug_log) { fclose(keycache_debug_log); keycache_debug_log=0; } #else #define KEYCACHE_DEBUG_OPEN #define KEYCACHE_DEBUG_CLOSE @@ -283,76 +240,56 @@ static uint next_power(uint value) SYNOPSIS init_ky_cache() - pkeycache in/out pointer to the key cache handle - key_cache_block_size size of blocks to keep cached data - use_mem total memory to use for the key cache - env ref to other parameters of the key cache, if any + keycache pointer to the key cache handle to initialize + key_cache_block_size size of blocks to keep cached data + use_mem total memory to use for the key cache + division_limit division limit (may be zero) + age_threshold age threshold (may be zero) RETURN VALUE number of blocks in the key cache, if successful, 0 - otherwise. NOTES. - If pkeycache points to an undefined handle (NULL), a new KEY_CACHE - data structure is created and a pointer to it is returned as a new - key cache handle, otherwise *pkeycache is considered as a reused - handle for a key cache with new blocks. + if keycache->key_cache_inited != 0 we assume that the key cache + is already initialized. This is for now used by myisamchk, but shouldn't + be something that a program should rely on! + It's assumed that no two threads call this function simultaneously referring to the same key cache handle. */ -int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, - ulong use_mem, KEY_CACHE_VAR *env) +int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold) { uint blocks, hash_links, length; int error; - KEY_CACHE *keycache; DBUG_ENTER("init_key_cache"); DBUG_ASSERT(key_cache_block_size >= 512); - if (!(keycache= (KEY_CACHE *) *pkeycache) && - !(keycache= (KEY_CACHE *) my_malloc(sizeof(KEY_CACHE), - MYF(MY_ZEROFILL)))) - DBUG_RETURN(0); - - keycache->env= env; - KEYCACHE_DEBUG_OPEN; if (keycache->key_cache_inited && keycache->disk_blocks > 0) { DBUG_PRINT("warning",("key cache already in use")); DBUG_RETURN(0); } - if (env && ! keycache->key_cache_inited) - { - env->cache_w_requests= env->cache_r_requests= 0; - env->cache_read= env->cache_write=0; - } + keycache->global_cache_w_requests= keycache->global_cache_r_requests= 0; + keycache->global_cache_read= keycache->global_cache_write= 0; + keycache->disk_blocks= -1; if (! keycache->key_cache_inited) { keycache->key_cache_inited= 1; - keycache->disk_blocks= -1; pthread_mutex_init(&keycache->cache_lock, MY_MUTEX_INIT_FAST); - keycache->key_cache_shift= my_bit_log2(key_cache_block_size); - keycache->key_cache_mem_size= use_mem; - keycache->key_cache_block_size= key_cache_block_size; - DBUG_PRINT("info", ("key_cache_block_size: %u", - key_cache_block_size)); } - /* - These are safety deallocations: actually we always call the - function after having called end_key_cache that deallocates - these memory itself. - */ - if (keycache->block_mem) - my_free_lock((gptr) keycache->block_mem, MYF(0)); - keycache->block_mem= NULL; - if (keycache->block_root) - my_free((gptr) keycache->block_root, MYF(0)); - keycache->block_root= NULL; + keycache->key_cache_mem_size= use_mem; + keycache->key_cache_block_size= key_cache_block_size; + keycache->key_cache_shift= my_bit_log2(key_cache_block_size); + DBUG_PRINT("info", ("key_cache_block_size: %u", + key_cache_block_size)); blocks= (uint) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); @@ -412,21 +349,20 @@ int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, keycache->hash_links_used= 0; keycache->free_hash_list= NULL; keycache->blocks_used= keycache->blocks_changed= 0; - if (env) - env->blocks_used= env->blocks_changed= 0; -#if defined(KEYCACHE_DEBUG) - keycache->blocks_available=0; -#endif + + keycache->global_blocks_used= keycache->global_blocks_changed= 0; + keycache->blocks_available=0; /* For debugging */ + /* The LRU chain is empty after initialization */ keycache->used_last= NULL; keycache->used_ins= NULL; keycache->keycache_time= 0; keycache->warm_blocks= 0; - keycache->min_warm_blocks= (env && env->division_limit ? - blocks * env->division_limit / 100 + 1 : + keycache->min_warm_blocks= (division_limit ? + blocks * division_limit / 100 + 1 : blocks); - keycache->age_threshold= (env && env->age_threshold ? - blocks * env->age_threshold / 100 : + keycache->age_threshold= (age_threshold ? + blocks * age_threshold / 100 : blocks); keycache->waiting_for_hash_link.last_thread= NULL; @@ -437,23 +373,19 @@ int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, keycache->disk_blocks, keycache->block_root, keycache->hash_entries, keycache->hash_root, keycache->hash_links, keycache->hash_link_root)); + bzero((gptr) keycache->changed_blocks, + sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH); + bzero((gptr) keycache->file_blocks, + sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH); } - bzero((gptr) keycache->changed_blocks, - sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH); - bzero((gptr) keycache->file_blocks, - sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH); - if (env) - env->blocks= keycache->disk_blocks > 0 ? keycache->disk_blocks : 0; - *pkeycache= keycache; - DBUG_PRINT("exit", ("key_cache: %lx", keycache)); + keycache->blocks= keycache->disk_blocks > 0 ? keycache->disk_blocks : 0; DBUG_RETURN((int) blocks); err: error= my_errno; keycache->disk_blocks= 0; - if (env) - env->blocks= 0; + keycache->blocks= 0; if (keycache->block_mem) { my_free_lock((gptr) keycache->block_mem, MYF(0)); @@ -474,9 +406,11 @@ err: SYNOPSIS resize_key_cache() - pkeycache in/out pointer to the key cache handle - key_cache_block_size size of blocks to keep cached data - use_mem total memory to use for the new key cache + keycache in/out key cache handle + key_cache_block_size size of blocks to keep cached data + use_mem total memory to use for the new key cache + division_limit new division limit (if not zero) + age_threshold new age threshold (if not zero) RETURN VALUE number of blocks in the key cache, if successful, @@ -484,35 +418,38 @@ err: NOTES. The function first compares the memory size and the block size parameters - with the corresponding parameters of the key cache referred by - *pkeycache. If they differ the function free the the memory allocated - for the old key cache blocks by calling the end_key_cache function - and then rebuilds the key cache with new blocks by calling init_key_cache. + with the key cache values. + + If they differ the function free the the memory allocated for the + old key cache blocks by calling the end_key_cache function and + then rebuilds the key cache with new blocks by calling + init_key_cache. */ -int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, - ulong use_mem) +int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold) { int blocks; - KEY_CACHE *keycache= *pkeycache; DBUG_ENTER("resize_key_cache"); - if (key_cache_block_size == keycache->key_cache_block_size && - use_mem == keycache->key_cache_mem_size) - return keycache->disk_blocks; + if (!keycache->key_cache_inited || + (key_cache_block_size == keycache->key_cache_block_size && + use_mem == keycache->key_cache_mem_size)) + DBUG_RETURN(keycache->disk_blocks); keycache_pthread_mutex_lock(&keycache->cache_lock); if (flush_all_key_blocks(keycache)) { /* TODO: if this happens, we should write a warning in the log file ! */ keycache_pthread_mutex_unlock(&keycache->cache_lock); - return 0; + DBUG_RETURN(0); } + end_key_cache(keycache, 0); /* Don't free mutex */ + /* the following will work even if use_mem is 0 */ + blocks= init_key_cache(keycache, key_cache_block_size, use_mem, + division_limit, age_threshold); keycache_pthread_mutex_unlock(&keycache->cache_lock); - end_key_cache(keycache, 0); - /* the following will work even if memory is 0 */ - blocks= init_key_cache(pkeycache, key_cache_block_size, use_mem, - keycache->env); return blocks; } @@ -522,7 +459,9 @@ int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, SYNOPSIS change_key_cache_param() - keycache the key cache handle + keycache key cache handle + division_limit new division limit (if not zero) + age_threshold new age threshold (if not zero) RETURN VALUE none @@ -530,24 +469,20 @@ int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, NOTES. Presently the function resets the key cache parameters concerning midpoint insertion strategy - division_limit and - age_threshold. It corresponding values are passed through - the keycache->env structure. + age_threshold. */ -void change_key_cache_param(KEY_CACHE_HANDLE keycache) +void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, + uint age_threshold) { - KEY_CACHE_VAR *env= keycache->env; DBUG_ENTER("change_key_cache_param"); - if (env) - { - if (env->division_limit) - keycache->min_warm_blocks= (keycache->disk_blocks * - env->division_limit / 100 + 1); - if (env->age_threshold) - keycache->age_threshold= (keycache->disk_blocks * - env->age_threshold / 100); - } + if (division_limit) + keycache->min_warm_blocks= (keycache->disk_blocks * + division_limit / 100 + 1); + if (age_threshold) + keycache->age_threshold= (keycache->disk_blocks * + age_threshold / 100); DBUG_VOID_RETURN; } @@ -557,26 +492,21 @@ void change_key_cache_param(KEY_CACHE_HANDLE keycache) SYNOPSIS end_key_cache() - pkeycache in/out pointer to the key cache handle - cleanup <-> the key cache data structure is freed as well + keycache key cache handle + cleanup Complete free (Free also mutex for key cache) RETURN VALUE none - - NOTES. - If the cleanup parameter is TRUE the data structure with all associated - elements are freed completely - Otherwise only memory used by the key cache blocks is freed. */ -void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup) +void end_key_cache(KEY_CACHE *keycache, my_bool cleanup) { - KEY_CACHE_VAR *env; DBUG_ENTER("end_key_cache"); DBUG_PRINT("enter", ("key_cache: %lx", keycache)); - if (!keycache) + if (!keycache->key_cache_inited) DBUG_VOID_RETURN; + if (keycache->disk_blocks > 0) { if (keycache->block_mem) @@ -587,22 +517,22 @@ void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup) keycache->block_root= NULL; } keycache->disk_blocks= -1; + /* Reset blocks_changed to be safe if flush_all_key_blocks is called */ + keycache->blocks_changed= 0; } - KEYCACHE_DEBUG_CLOSE; - keycache->key_cache_inited= 0; - if ((env= keycache->env)) - { - DBUG_PRINT("status", - ("used: %d changed: %d w_requests: %ld \ - writes: %ld r_requests: %ld reads: %ld", - env->blocks_used, env->blocks_changed, - env->cache_w_requests, env->cache_write, - env->cache_r_requests, env->cache_read)); - } + + DBUG_PRINT("status", + ("used: %d changed: %d w_requests: %ld \ +writes: %ld r_requests: %ld reads: %ld", + keycache->global_blocks_used, keycache->global_blocks_changed, + keycache->global_cache_w_requests, keycache->global_cache_write, + keycache->global_cache_r_requests, keycache->global_cache_read)); + if (cleanup) { pthread_mutex_destroy(&keycache->cache_lock); - my_free((gptr) keycache, MYF(0)); + keycache->key_cache_inited= 0; + KEYCACHE_DEBUG_CLOSE; } DBUG_VOID_RETURN; } /* end_key_cache */ @@ -786,8 +716,7 @@ static void link_to_file_list(KEY_CACHE *keycache, { block->status&= ~BLOCK_CHANGED; keycache->blocks_changed--; - if (keycache->env) - keycache->env->blocks_changed--; + keycache->global_blocks_changed--; } } @@ -805,8 +734,7 @@ static inline void link_to_changed_list(KEY_CACHE *keycache, &keycache->changed_blocks[FILE_HASH(block->hash_link->file)]); block->status|=BLOCK_CHANGED; keycache->blocks_changed++; - if (keycache->env) - keycache->env->blocks_changed++; + keycache->global_blocks_changed++; } @@ -1328,8 +1256,7 @@ restart: block->offset= keycache->key_cache_block_size; block->requests= 1; keycache->blocks_used++; - if (keycache->env) - keycache->env->blocks_used++; + keycache->global_blocks_used++; keycache->warm_blocks++; block->hits_left= init_hits_left; block->last_hit_time= 0; @@ -1401,8 +1328,7 @@ restart: block->hash_link->diskpos+ block->offset, MYF(MY_NABP | MY_WAIT_IF_FULL)); keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_write++; + keycache->global_cache_write++; } block->status|= BLOCK_REASSIGNED; @@ -1441,8 +1367,7 @@ restart: PAGE_READ : PAGE_WAIT_TO_BE_READ; } } - if (keycache->env) - keycache->env->cache_read++; + keycache->global_cache_read++; } else { @@ -1582,42 +1507,47 @@ static void read_block(KEY_CACHE *keycache, have to be a multiple of key_cache_block_size; */ -byte *key_cache_read(KEY_CACHE_HANDLE keycache, +byte *key_cache_read(KEY_CACHE *keycache, File file, my_off_t filepos, int level, byte *buff, uint length, uint block_length __attribute__((unused)), int return_buffer __attribute__((unused))) { int error=0; + uint offset= 0; + byte *start= buff; DBUG_ENTER("key_cache_read"); DBUG_PRINT("enter", ("file %u, filepos %lu, length %u", (uint) file, (ulong) filepos, length)); - if (keycache && keycache->disk_blocks > 0) + if (keycache->disk_blocks > 0) { /* Key cache is used */ reg1 BLOCK_LINK *block; - uint offset= (uint) (filepos & (keycache->key_cache_block_size-1)); - byte *start= buff; uint read_length; uint status; int page_st; -#ifndef THREAD - if (block_length > keycache->key_cache_block_size || offset) - return_buffer=0; -#endif - /* Read data in key_cache_block_size increments */ - filepos-= offset; do { + keycache_pthread_mutex_lock(&keycache->cache_lock); + if (keycache->disk_blocks <= 0) /* Resize failed */ + { + keycache_pthread_mutex_unlock(&keycache->cache_lock); + goto no_key_cache; + } read_length= length > keycache->key_cache_block_size ? keycache->key_cache_block_size : length; KEYCACHE_DBUG_ASSERT(read_length > 0); - keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_r_requests++; + offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + filepos-= offset; +#ifndef THREAD + if (block_length > keycache->key_cache_block_size || offset) + return_buffer=0; +#endif + + keycache->global_cache_r_requests++; block=find_key_block(keycache, file, filepos, level, 0, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ) { @@ -1673,29 +1603,25 @@ byte *key_cache_read(KEY_CACHE_HANDLE keycache, DBUG_RETURN((byte *) 0); #ifndef THREAD + /* This is only true if we where able to read everything in one block */ if (return_buffer) - return (block->buffer); + return (block->buffer); #endif - buff+= read_length; filepos+= read_length; - offset= 0; } while ((length-= read_length)); DBUG_RETURN(start); } - /* Key cache is not used */ - if (keycache && keycache->env) - { - statistic_increment(keycache->env->cache_r_requests, - &keycache->cache_lock); - statistic_increment(keycache->env->cache_read, - &keycache->cache_lock); - } - if (my_pread(file, (byte*) buff, length, filepos, MYF(MY_NABP))) +no_key_cache: /* Key cache is not used */ + + /* We can't use mutex here as the key cache may not be initialized */ + keycache->global_cache_r_requests++; + keycache->global_cache_read++; + if (my_pread(file, (byte*) buff, length, filepos+offset, MYF(MY_NABP))) error= 1; - DBUG_RETURN(error? (byte*) 0 : buff); + DBUG_RETURN(error ? (byte*) 0 : start); } @@ -1703,20 +1629,23 @@ byte *key_cache_read(KEY_CACHE_HANDLE keycache, Insert a block of file data from a buffer into key cache SYNOPSIS - key_cache_insert() - keycache pointer to a key cache data structure - file handler for the file to insert data from - filepos position of the block of data in the file to insert - level determines the weight of the data - buff buffer to read data from - length length of the data in the buffer + keycache pointer to a key cache data structure + file handler for the file to insert data from + filepos position of the block of data in the file to insert + level determines the weight of the data + buff buffer to read data from + length length of the data in the buffer + + NOTES + This is used by MyISAM to move all blocks from a index file to the key + cache RETURN VALUE 0 if a success, 1 - otherwise. */ -int key_cache_insert(KEY_CACHE_HANDLE keycache, +int key_cache_insert(KEY_CACHE *keycache, File file, my_off_t filepos, int level, byte *buff, uint length) { @@ -1728,20 +1657,27 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, { /* Key cache is used */ reg1 BLOCK_LINK *block; - uint offset= (uint) (filepos & (keycache->key_cache_block_size-1)); uint read_length; int page_st; + int error; - /* Read data into key cache from buff in key_cache_block_size increments */ - filepos-= offset; do { + uint offset; + keycache_pthread_mutex_lock(&keycache->cache_lock); + if (keycache->disk_blocks <= 0) /* Resize failed */ + { + keycache_pthread_mutex_unlock(&keycache->cache_lock); + DBUG_RETURN(0); + } read_length= length > keycache->key_cache_block_size ? keycache->key_cache_block_size : length; KEYCACHE_DBUG_ASSERT(read_length > 0); - keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_r_requests++; + offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + /* Read data into key cache from buff in key_cache_block_size incr. */ + filepos-= offset; + + keycache->global_cache_r_requests++; block= find_key_block(keycache, file, filepos, level, 0, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ) { @@ -1770,14 +1706,14 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, */ unreg_request(keycache, block, 1); + error= (block->status & BLOCK_ERROR); keycache_pthread_mutex_unlock(&keycache->cache_lock); - if (block->status & BLOCK_ERROR) + if (error) DBUG_RETURN(1); buff+= read_length; filepos+= read_length; - offset=0; } while ((length-= read_length)); } @@ -1812,7 +1748,7 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, have to be a multiple of key_cache_block_size; */ -int key_cache_write(KEY_CACHE_HANDLE keycache, +int key_cache_write(KEY_CACHE *keycache, File file, my_off_t filepos, int level, byte *buff, uint length, uint block_length __attribute__((unused)), @@ -1829,9 +1765,7 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, if (!dont_write) { /* Force writing from buff into disk */ - if (keycache && keycache->env) - statistic_increment(keycache->env->cache_write, - &keycache->cache_lock); + keycache->global_cache_write++; if (my_pwrite(file, buff, length, filepos, MYF(MY_NABP | MY_WAIT_IF_FULL))) DBUG_RETURN(1); } @@ -1841,23 +1775,29 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, test_key_cache(keycache, "start of key_cache_write", 1);); #endif - if (keycache && keycache->disk_blocks > 0) + if (keycache->disk_blocks > 0) { /* Key cache is used */ uint read_length; - uint offset= (uint) (filepos & (keycache->key_cache_block_size-1)); int page_st; - /* Write data in key_cache_block_size increments */ - filepos-= offset; do { - read_length= length > keycache->key_cache_block_size ? - keycache->key_cache_block_size : length; - KEYCACHE_DBUG_ASSERT(read_length > 0); + uint offset; keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_w_requests++; + if (keycache->disk_blocks <= 0) /* Resize failed */ + { + keycache_pthread_mutex_unlock(&keycache->cache_lock); + goto no_key_cache; + } + read_length= length > keycache->key_cache_block_size ? + keycache->key_cache_block_size : length; + KEYCACHE_DBUG_ASSERT(read_length > 0); + offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + /* Write data in key_cache_block_size increments */ + filepos-= offset; + + keycache->global_cache_w_requests++; block= find_key_block(keycache, file, filepos, level, 1, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ && (offset || read_length < keycache->key_cache_block_size)) @@ -1907,25 +1847,21 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, offset= 0; } while ((length-= read_length)); - } - else - { - /* Key cache is not used */ - if (dont_write) - { - if (keycache && keycache->env) - { - statistic_increment(keycache->env->cache_w_requests, - &keycache->cache_lock); - statistic_increment(keycache->env->cache_write, - &keycache->cache_lock); - } - if (my_pwrite(file, (byte*) buff, length, filepos, - MYF(MY_NABP | MY_WAIT_IF_FULL))) - error=1; - } + goto end; } +no_key_cache: + /* Key cache is not used */ + if (dont_write) + { + keycache->global_cache_w_requests++; + keycache->global_cache_write++; + if (my_pwrite(file, (byte*) buff, length, filepos, + MYF(MY_NABP | MY_WAIT_IF_FULL))) + error=1; + } + +end: #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("exec", test_key_cache(keycache, "end of key_cache_write", 1);); @@ -2007,8 +1943,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache, block->hash_link->diskpos+ block->offset, MYF(MY_NABP | MY_WAIT_IF_FULL)); keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_write++; + keycache->global_cache_write++; if (error) { block->status|= BLOCK_ERROR; @@ -2019,8 +1954,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache, if (! (type == FLUSH_KEEP || type == FLUSH_FORCE_WRITE)) { keycache->blocks_changed--; - if (keycache->env) - keycache->env->blocks_changed--; + keycache->global_blocks_changed--; free_block(keycache, block); } else @@ -2053,10 +1987,9 @@ static int flush_cached_blocks(KEY_CACHE *keycache, 1 error */ -static int flush_key_blocks_int(KEY_CACHE_HANDLE keycache, +static int flush_key_blocks_int(KEY_CACHE *keycache, File file, enum flush_type type) { - KEY_CACHE_VAR *env; BLOCK_LINK *cache_buff[FLUSH_CACHE],**cache; int last_errno= 0; DBUG_ENTER("flush_key_blocks_int"); @@ -2161,8 +2094,7 @@ restart: { /* It's a temporary file */ keycache->blocks_changed--; - if (keycache->env) - keycache->env->blocks_changed--; + keycache->global_blocks_changed--; free_block(keycache, block); } } @@ -2227,8 +2159,8 @@ restart: } } - if (type == FLUSH_REMOVE && (env= keycache->env) && (env->action)) - (*env->action)((void *) env); + if (type == FLUSH_REMOVE && keycache->action) + (*keycache->action)(keycache); #ifndef DBUG_OFF DBUG_EXECUTE("check_keycache", @@ -2257,14 +2189,14 @@ restart: 1 error */ -int flush_key_blocks(KEY_CACHE_HANDLE key_cache, +int flush_key_blocks(KEY_CACHE *key_cache, File file, enum flush_type type) { int res; DBUG_ENTER("flush_key_blocks"); DBUG_PRINT("enter", ("key_cache: %lx", key_cache)); - if (!key_cache || !key_cache->disk_blocks) + if (key_cache->disk_blocks <= 0) DBUG_RETURN(0); keycache_pthread_mutex_lock(&key_cache->cache_lock); res= flush_key_blocks_int(key_cache, file, type); diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c index 1d770e17719..806f83dc7d8 100644 --- a/mysys/mf_keycaches.c +++ b/mysys/mf_keycaches.c @@ -23,6 +23,7 @@ */ #include "mysys_priv.h" +#include #include #include @@ -295,7 +296,7 @@ static SAFE_HASH key_cache_hash; my_bool multi_keycache_init(void) { - return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_keycache); + return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_key_cache); } @@ -321,11 +322,11 @@ void multi_keycache_free(void) key cache to use */ -KEY_CACHE_HANDLE *multi_key_cache_search(byte *key, uint length) +KEY_CACHE *multi_key_cache_search(byte *key, uint length) { if (!key_cache_hash.hash.records) - return dflt_keycache; - return (KEY_CACHE_HANDLE*) safe_hash_search(&key_cache_hash, key, length); + return dflt_key_cache; + return (KEY_CACHE*) safe_hash_search(&key_cache_hash, key, length); } @@ -346,14 +347,14 @@ KEY_CACHE_HANDLE *multi_key_cache_search(byte *key, uint length) my_bool multi_key_cache_set(const byte *key, uint length, - KEY_CACHE_HANDLE *key_cache) + KEY_CACHE *key_cache) { return safe_hash_set(&key_cache_hash, key, length, (byte*) key_cache); } -void multi_key_cache_change(KEY_CACHE_HANDLE *old_data, - KEY_CACHE_HANDLE *new_data) +void multi_key_cache_change(KEY_CACHE *old_data, + KEY_CACHE *new_data) { safe_hash_change(&key_cache_hash, (byte*) old_data, (byte*) new_data); } diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 3abac2dc737..474334efcc0 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -54,12 +54,15 @@ void safe_mutex_global_init(void) int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr __attribute__((unused)), - const char *file __attribute__((unused)), - uint line __attribute__((unused))) + const char *file, + uint line) { bzero((char*) mp,sizeof(*mp)); pthread_mutex_init(&mp->global,MY_MUTEX_INIT_ERRCHK); pthread_mutex_init(&mp->mutex,attr); + /* Mark that mutex is initialized */ + mp->file= file; + mp->line= line; #ifdef SAFE_MUTEX_DETECT_DESTROY /* @@ -70,7 +73,7 @@ int safe_mutex_init(safe_mutex_t *mp, { struct st_safe_mutex_info_t *info =mp->info; - info->init_file= (char *) file; + info->init_file= file; info->init_line= line; info->prev= NULL; info->next= NULL; @@ -92,6 +95,13 @@ int safe_mutex_init(safe_mutex_t *mp, int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line) { int error; + if (!mp->file) + { + fprintf(stderr,"safe_mutex: Trying to lock unitialized mutex at %s, line %d", file, line); + fflush(stderr); + abort(); + } + pthread_mutex_lock(&mp->global); if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread)) { @@ -117,7 +127,7 @@ line %d more than 1 time\n", file,line); abort(); } mp->thread=pthread_self(); - mp->file= (char*) file; + mp->file= file; mp->line=line; pthread_mutex_unlock(&mp->global); return error; @@ -204,7 +214,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file, abort(); } mp->thread=pthread_self(); - mp->file= (char*) file; + mp->file= file; mp->line=line; pthread_mutex_unlock(&mp->global); return error; @@ -242,7 +252,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, abort(); } mp->thread=pthread_self(); - mp->file= (char*) file; + mp->file= file; mp->line=line; pthread_mutex_unlock(&mp->global); return error; @@ -268,6 +278,7 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) if (pthread_mutex_destroy(&mp->mutex)) error=1; #endif + mp->file= 0; /* Mark destroyed */ #ifdef SAFE_MUTEX_DETECT_DESTROY if (mp->info) diff --git a/sql-common/client.c b/sql-common/client.c index c6abfb0ba91..cb0d8230eb8 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -634,7 +634,7 @@ void free_rows(MYSQL_DATA *cur) } } -my_bool STDCALL +my_bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command, const char *header, ulong header_length, const char *arg, ulong arg_length, my_bool skip_check) @@ -1014,7 +1014,8 @@ void mysql_read_default_options(struct st_mysql_options *options, else the lengths are calculated from the offset between pointers. **************************************************************************/ -static void STDCALL cli_fetch_lengths(ulong *to, MYSQL_ROW column, unsigned int field_count) +static void cli_fetch_lengths(ulong *to, MYSQL_ROW column, + unsigned int field_count) { ulong *prev_length; byte *start=0; @@ -1145,8 +1146,8 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, /* Read all rows (fields or data) from server */ -MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - unsigned int fields) +MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, + unsigned int fields) { uint field; ulong pkt_len; @@ -1402,8 +1403,8 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused))) before calling mysql_real_connect ! */ -static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql); -static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql); +static my_bool cli_mysql_read_query_result(MYSQL *mysql); +static MYSQL_RES *cli_mysql_use_result(MYSQL *mysql); static MYSQL_METHODS client_methods= { @@ -2227,7 +2228,7 @@ void STDCALL mysql_close(MYSQL *mysql) DBUG_VOID_RETURN; } -static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql) +static my_bool cli_mysql_read_query_result(MYSQL *mysql) { uchar *pos; ulong field_count; @@ -2402,7 +2403,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql) have to wait for the client (and will not wait more than 30 sec/packet). **************************************************************************/ -static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql) +static MYSQL_RES * cli_mysql_use_result(MYSQL *mysql) { MYSQL_RES *result; DBUG_ENTER("cli_mysql_use_result"); diff --git a/sql/derror.cc b/sql/derror.cc index ad7432f7675..53d0dc5b7e5 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -75,6 +75,7 @@ Please install the latest version of this file.",name); goto err1; } + /* TODO: Convert the character set to server system character set */ if (!(cset= get_charset(head[30],MYF(MY_WME)))) { sql_print_error("Character set #%d is not supported for messagefile '%s'", diff --git a/sql/field.cc b/sql/field.cc index befa9993b05..70b8ce6c080 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2850,7 +2850,7 @@ String *Field_timestamp::val_str(String *val_buffer, struct tm tm_tmp; val_buffer->alloc(field_length+1); - char *to=(char*) val_buffer->ptr(),*end=to+field_length; + char *to= (char*) val_buffer->ptr(); val_buffer->length(field_length); #ifdef WORDS_BIGENDIAN @@ -3987,7 +3987,6 @@ longlong Field_string::val_int(void) String *Field_string::val_str(String *val_buffer __attribute__((unused)), String *val_ptr) { - char *end=ptr+field_length; uint length= field_charset->cset->lengthsp(field_charset, ptr, field_length); val_ptr->set((const char*) ptr, length, field_charset); return val_ptr; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 7f8c99f7c15..f79c5b55927 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -546,7 +546,6 @@ innobase_query_caching_of_table_permitted( { ibool is_autocommit; trx_t* trx; - char* ptr; char norm_name[1000]; ut_a(full_name_len < 999); @@ -606,7 +605,7 @@ innobase_query_caching_of_table_permitted( #ifdef __WIN__ /* Put to lower case */ - ptr = norm_name; + char* ptr = norm_name; while (*ptr != '\0') { *ptr = tolower(*ptr); @@ -1391,7 +1390,6 @@ ha_innobase::open( uint test_if_locked) /* in: not used */ { dict_table_t* ib_table; - int error = 0; char norm_name[1000]; DBUG_ENTER("ha_innobase::open"); diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 0f22a83a2b4..3cdd923d085 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -226,7 +226,6 @@ err: int ha_myisam::open(const char *name, int mode, uint test_if_locked) { - KEY_CACHE_VAR *key_cache; if (!(file=mi_open(name, mode, test_if_locked))) return (my_errno ? my_errno : -1); @@ -698,7 +697,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) { - KEY_CACHE_VAR *new_key_cache= check_opt->key_cache; + KEY_CACHE *new_key_cache= check_opt->key_cache; const char *errmsg= 0; int error= HA_ADMIN_OK; ulonglong map= ~(ulonglong) 0; diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index a834ace7032..3cd5d96d5f3 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -39,7 +39,6 @@ const char **ha_myisammrg::bas_ext() const int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) { char name_buff[FN_REFLEN]; - KEY_CACHE_VAR *key_cache; DBUG_PRINT("info", ("ha_myisammrg::open")); if (!(file=myrg_open(fn_format(name_buff,name,"","",2 | 4), mode, @@ -312,11 +311,11 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd, static void split_file_name(const char *file_name, LEX_STRING *db, LEX_STRING *name) { - uint name_length, dir_length, prefix_length; + uint dir_length, prefix_length; char buff[FN_REFLEN]; db->length= 0; - name_length= (uint) (strmake(buff, file_name, sizeof(buff)-1) - buff); + strmake(buff, file_name, sizeof(buff)-1); dir_length= dirname_length(buff); if (dir_length > 1) { diff --git a/sql/handler.cc b/sql/handler.cc index 56db355f45e..5267ddc8986 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1132,20 +1132,22 @@ void st_ha_check_opt::init() /* Init a key cache if it has not been initied before */ -int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache) +int ha_init_key_cache(const char *name, KEY_CACHE *key_cache) { DBUG_ENTER("ha_init_key_cache"); - if (!key_cache->cache) + if (!key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp_buff_size= (long) key_cache->buff_size; - long tmp_block_size= (long) key_cache->block_size; + long tmp_buff_size= (long) key_cache->param_buff_size; + long tmp_block_size= (long) key_cache->param_block_size; + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; pthread_mutex_unlock(&LOCK_global_system_variables); - DBUG_RETURN(!init_key_cache(&key_cache->cache, + DBUG_RETURN(!init_key_cache(key_cache, tmp_block_size, tmp_buff_size, - key_cache)); + division_limit, age_threshold)); } DBUG_RETURN(0); } @@ -1153,18 +1155,21 @@ int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache) /* Resize key cache */ -int ha_resize_key_cache(KEY_CACHE_VAR *key_cache) +int ha_resize_key_cache(KEY_CACHE *key_cache) { DBUG_ENTER("ha_resize_key_cache"); - if (key_cache->cache) + if (key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp_buff_size= (long) key_cache->buff_size; - long tmp_block_size= (long) key_cache->block_size; + long tmp_buff_size= (long) key_cache->param_buff_size; + long tmp_block_size= (long) key_cache->param_block_size; + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; pthread_mutex_unlock(&LOCK_global_system_variables); - DBUG_RETURN(!resize_key_cache(&key_cache->cache, tmp_block_size, - tmp_buff_size)); + DBUG_RETURN(!resize_key_cache(key_cache, tmp_block_size, + tmp_buff_size, + division_limit, age_threshold)); } DBUG_RETURN(0); } @@ -1172,29 +1177,31 @@ int ha_resize_key_cache(KEY_CACHE_VAR *key_cache) /* Change parameters for key cache (like size) */ -int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache) +int ha_change_key_cache_param(KEY_CACHE *key_cache) { - if (key_cache->cache) - change_key_cache_param(key_cache->cache); + if (key_cache->key_cache_inited) + { + pthread_mutex_lock(&LOCK_global_system_variables); + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; + pthread_mutex_unlock(&LOCK_global_system_variables); + change_key_cache_param(key_cache, division_limit, age_threshold); + } return 0; } /* Free memory allocated by a key cache */ -int ha_end_key_cache(KEY_CACHE_VAR *key_cache) +int ha_end_key_cache(KEY_CACHE *key_cache) { - if (key_cache->cache) - { - end_key_cache(key_cache->cache, 1); // Can never fail - key_cache->cache= 0; - } + end_key_cache(key_cache, 1); // Can never fail return 0; } /* Move all tables from one key cache to another one */ -int ha_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache) +int ha_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache) { mi_change_key_cache(old_key_cache, new_key_cache); return 0; diff --git a/sql/handler.h b/sql/handler.h index 40773c67605..9089db60d77 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -22,6 +22,7 @@ #endif #include +#include #ifndef NO_HASH #define NO_HASH /* Not yet implemented */ @@ -181,14 +182,13 @@ typedef struct st_ha_create_information struct st_table; typedef struct st_table TABLE; -typedef struct st_key_cache_asmt KEY_CACHE_ASMT; typedef struct st_ha_check_opt { ulong sort_buffer_size; uint flags; /* isam layer flags (e.g. for myisamchk) */ uint sql_flags; /* sql layer flags - for something myisamchk cannot do */ - KEY_CACHE_VAR *key_cache; /* new key cache when changing key cache */ + KEY_CACHE *key_cache; /* new key cache when changing key cache */ void init(); } HA_CHECK_OPT; @@ -394,10 +394,10 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, bool update_create_info); int ha_delete_table(enum db_type db_type, const char *path); void ha_drop_database(char* path); -int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache); -int ha_resize_key_cache(KEY_CACHE_VAR *key_cache); -int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache); -int ha_end_key_cache(KEY_CACHE_VAR *key_cache); +int ha_init_key_cache(const char *name, KEY_CACHE *key_cache); +int ha_resize_key_cache(KEY_CACHE *key_cache); +int ha_change_key_cache_param(KEY_CACHE *key_cache); +int ha_end_key_cache(KEY_CACHE *key_cache); int ha_start_stmt(THD *thd); int ha_report_binlog_offset_and_commit(THD *thd, char *log_file_name, my_off_t end_offset); @@ -411,5 +411,5 @@ int ha_autocommit_or_rollback(THD *thd, int error); void ha_set_spin_retries(uint retries); bool ha_flush_logs(void); int ha_recovery_logging(THD *thd, bool on); -int ha_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache); +int ha_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache); diff --git a/sql/item.cc b/sql/item.cc index d76ab529db5..f41cb720f12 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1347,7 +1347,7 @@ bool Item::send(Protocol *protocol, String *buffer) case MYSQL_TYPE_FLOAT: { float nr; - nr= val(); + nr= (float) val(); if (!null_value) result= protocol->store(nr, decimals, buffer); break; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 64d6b5fa7cf..792f99a686b 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -397,13 +397,12 @@ int Arg_comparator::compare_row() int Arg_comparator::compare_e_row() { - int res= 0; (*a)->bring_value(); (*b)->bring_value(); uint n= (*a)->cols(); for (uint i= 0; imaybe_null) + if (else_expr_num == -1 || args[else_expr_num]->maybe_null) maybe_null=1; max_length=0; @@ -1127,6 +1128,7 @@ void Item_func_case::fix_length_and_dec() } } + /* TODO: Fix this so that it prints the whole CASE expression */ void Item_func_case::print(String *str) @@ -1538,7 +1540,6 @@ void Item_func_in::fix_length_and_dec() { switch (cmp_type) { case STRING_RESULT: - uint i; array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in, cmp_collation.collation); break; diff --git a/sql/item_func.cc b/sql/item_func.cc index c42019a9fbb..2a07341d97a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2321,9 +2321,7 @@ String *user_var_entry::val_str(my_bool *null_value, String *str, bool Item_func_set_user_var::check() { - bool res; DBUG_ENTER("Item_func_set_user_var::check"); - LINT_INIT(res); switch (cached_result_type) { case REAL_RESULT: @@ -3013,7 +3011,6 @@ longlong Item_func_is_free_lock::val_int() String *res=args[0]->val_str(&value); THD *thd=current_thd; ULL *ull; - int error=0; null_value=0; if (!res || !res->length()) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index dfaf3001a19..f40d38dd4a8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -324,7 +324,6 @@ null: void Item_func_concat::fix_length_and_dec() { - bool first_coll= 1; max_length=0; if (agg_arg_collations(collation, args, arg_count)) @@ -2018,7 +2017,7 @@ void Item_func_lpad::fix_length_and_dec() String *Item_func_lpad::val_str(String *str) { - uint32 res_byte_length,res_char_length,pad_byte_length,pad_char_length; + uint32 res_char_length,pad_char_length; ulong count= (long) args[1]->val_int(), byte_count; String a1,a3; String *res= args[0]->val_str(&a1); @@ -2028,7 +2027,6 @@ String *Item_func_lpad::val_str(String *str) goto err; null_value=0; - res_byte_length= res->length(); res_char_length= res->numchars(); if (count <= res_char_length) @@ -2037,7 +2035,6 @@ String *Item_func_lpad::val_str(String *str) return res; } - pad_byte_length= pad->length(); pad_char_length= pad->numchars(); byte_count= count * collation.collation->mbmaxlen; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 74dd95bf0ab..a3d67e9f7fa 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1642,10 +1642,8 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct, original= 0; quick_group= 0; mark_as_sum_func(); - item_thd= current_thd; - SELECT_LEX *select_lex= item_thd->lex.current_select; order= 0; - group_concat_max_len= item_thd->variables.group_concat_max_len; + group_concat_max_len= current_thd->variables.group_concat_max_len; arg_show_fields= arg_count_field= is_select->elements; @@ -1791,6 +1789,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) thd->allow_sum_func= 0; maybe_null= 0; + item_thd= thd; for (i= 0 ; i < arg_count ; i++) { if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1)) @@ -1969,6 +1968,7 @@ String* Item_func_group_concat::val_str(String* str) return &result; } + void Item_func_group_concat::print(String *str) { str->append("group_concat(", 13); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index bcb7ddb1054..e73ecc99ffe 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -137,14 +137,12 @@ static bool make_datetime(date_time_format_types format, TIME *ltime, static bool extract_date_time(DATE_TIME_FORMAT *format, const char *val, uint length, TIME *l_time) { - int weekday= 0, yearday= 0, daypart= 0, len; + int weekday= 0, yearday= 0, daypart= 0; int week_number= -1; CHARSET_INFO *cs= &my_charset_bin; int error= 0; bool usa_time= 0; bool sunday_first= 0; - uint part_len= 0; - const char *val_ptr= val; const char *val_end= val + length; const char *ptr= format->format.str; const char *end= ptr+ format->format.length; @@ -1385,7 +1383,6 @@ String *Item_func_from_unixtime::val_str(String *str) { struct tm tm_tmp,*start; time_t tmp=(time_t) args[0]->val_int(); - CHARSET_INFO *cs= &my_charset_bin; TIME ltime; if ((null_value=args[0]->null_value)) @@ -1759,6 +1756,7 @@ bool Item_extract::eq(const Item *item, bool binary_cmp) const return 1; } + void Item_typecast::print(String *str) { str->append("cast(", 5); @@ -1768,6 +1766,7 @@ void Item_typecast::print(String *str) str->append(')'); } + void Item_char_typecast::print(String *str) { str->append("cast(", 5); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 9bc32581f32..b9032381c45 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -432,8 +432,6 @@ bool check_stack_overrun(THD *thd,char *dummy); void table_cache_init(void); void table_cache_free(void); uint cached_tables(void); -void reassign_key_cache(KEY_CACHE_ASMT *key_cache_asmt, - KEY_CACHE_VAR *new_key_cache); void kill_mysql(void); void close_connection(THD *thd, uint errcode, bool lock); bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, @@ -466,8 +464,8 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* table_list, int mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list, LEX_STRING *key_cache_name); int mysql_preload_keys(THD* thd, TABLE_LIST* table_list); -int reassign_keycache_tables(THD* thd, KEY_CACHE_VAR *src_cache, - KEY_CACHE_VAR *dst_cache); +int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, + KEY_CACHE *dst_cache); bool check_simple_select(); @@ -870,8 +868,7 @@ extern SHOW_COMP_OPTION have_berkeley_db; extern struct system_variables global_system_variables; extern struct system_variables max_system_variables; extern struct rand_struct sql_rand; -extern KEY_CACHE_VAR *sql_key_cache; -extern KEY_CACHE_HANDLE sql_key_cache_handle; +extern KEY_CACHE *sql_key_cache; extern const char *opt_date_time_formats[]; extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[]; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f26f18418a8..a0b5d910986 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -355,7 +355,7 @@ struct system_variables max_system_variables; MY_TMPDIR mysql_tmpdir_list; MY_BITMAP temp_pool; -KEY_CACHE_VAR *sql_key_cache; +KEY_CACHE *sql_key_cache; CHARSET_INFO *system_charset_info, *files_charset_info ; CHARSET_INFO *national_charset_info, *table_alias_charset; @@ -1565,14 +1565,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\ the problem, but since we have already crashed, something is definitely wrong\n\ and this may fail.\n\n"); fprintf(stderr, "key_buffer_size=%lu\n", - (ulong) sql_key_cache->buff_size); + (ulong) sql_key_cache->key_cache_mem_size); fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size); fprintf(stderr, "max_used_connections=%ld\n", max_used_connections); fprintf(stderr, "max_connections=%ld\n", max_connections); fprintf(stderr, "threads_connected=%d\n", thread_count); fprintf(stderr, "It is possible that mysqld could use up to \n\ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\ -bytes of memory\n", ((ulong) sql_key_cache->buff_size + +bytes of memory\n", ((ulong) sql_key_cache->key_cache_mem_size + (global_system_variables.read_buff_size + global_system_variables.sortbuff_size) * max_connections)/ 1024); @@ -2037,7 +2037,6 @@ bool init_global_datetime_format(timestamp_type format_type, { /* Get command line option */ const char *str= opt_date_time_formats[format_type]; - DATE_TIME_FORMAT *format; if (!str) // No specified format { @@ -2068,6 +2067,8 @@ static int init_common_variables(const char *conf_file_name, int argc, max_system_variables.pseudo_thread_id= (ulong)~0; start_time=time((time_t*) 0); + if (init_thread_environment()) + return 1; mysql_init_variables(); #ifdef OS2 @@ -2111,8 +2112,6 @@ static int init_common_variables(const char *conf_file_name, int argc, load_defaults(conf_file_name, groups, &argc, &argv); defaults_argv=argv; get_options(argc,argv); - if (init_thread_environment()) - return 1; if (opt_log || opt_update_log || opt_slow_log || opt_bin_log) strcat(server_version,"-log"); DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, @@ -2326,7 +2325,7 @@ Now disabling --log-slave-updates."); /* call ha_init_key_cache() on all key caches to init them */ process_key_caches(&ha_init_key_cache); /* We must set dflt_key_cache in case we are using ISAM tables */ - dflt_keycache= &sql_key_cache->cache; + dflt_key_cache= sql_key_cache; #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) if (locked_in_memory && !geteuid()) @@ -4316,26 +4315,26 @@ replicating a LOAD DATA INFILE command.", IO_SIZE, 0}, {"key_buffer_size", OPT_KEY_BUFFER_SIZE, "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", - (gptr*) &dflt_key_cache_var.buff_size, + (gptr*) &dflt_key_cache_var.param_buff_size, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "The default size of key cache blocks", - (gptr*) &dflt_key_cache_var.block_size, + (gptr*) &dflt_key_cache_var.param_block_size, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0}, {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, "The minimum percentage of warm blocks in key cache", - (gptr*) &dflt_key_cache_var.division_limit, + (gptr*) &dflt_key_cache_var.param_division_limit, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, 1, 100, 0, 1, 0}, {"key_cache_division_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", - (gptr*) &dflt_key_cache_var.age_threshold, + (gptr*) &dflt_key_cache_var.param_age_threshold, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 300, 100, ~0L, 0, 100, 0}, @@ -4757,17 +4756,17 @@ struct show_var_st status_vars[]= { {"Handler_rollback", (char*) &ha_rollback_count, SHOW_LONG}, {"Handler_update", (char*) &ha_update_count, SHOW_LONG}, {"Handler_write", (char*) &ha_write_count, SHOW_LONG}, - {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.blocks_changed, + {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG}, - {"Key_blocks_used", (char*) &dflt_key_cache_var.blocks_used, + {"Key_blocks_used", (char*) &dflt_key_cache_var.global_blocks_used, SHOW_KEY_CACHE_LONG}, - {"Key_read_requests", (char*) &dflt_key_cache_var.cache_r_requests, + {"Key_read_requests", (char*) &dflt_key_cache_var.global_cache_r_requests, SHOW_KEY_CACHE_LONG}, - {"Key_reads", (char*) &dflt_key_cache_var.cache_read, + {"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, SHOW_KEY_CACHE_LONG}, - {"Key_write_requests", (char*) &dflt_key_cache_var.cache_w_requests, + {"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, SHOW_KEY_CACHE_LONG}, - {"Key_writes", (char*) &dflt_key_cache_var.cache_write, + {"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, SHOW_KEY_CACHE_LONG}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_CONST}, @@ -5608,18 +5607,18 @@ mysql_getopt_value(const char *keyname, uint key_length, case OPT_KEY_CACHE_DIVISION_LIMIT: case OPT_KEY_CACHE_AGE_THRESHOLD: { - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; if (!(key_cache= get_or_create_key_cache(keyname, key_length))) exit(1); switch (option->id) { case OPT_KEY_BUFFER_SIZE: - return (gptr*) &key_cache->buff_size; + return (gptr*) &key_cache->param_buff_size; case OPT_KEY_CACHE_BLOCK_SIZE: - return (gptr*) &key_cache->block_size; + return (gptr*) &key_cache->param_block_size; case OPT_KEY_CACHE_DIVISION_LIMIT: - return (gptr*) &key_cache->division_limit; + return (gptr*) &key_cache->param_division_limit; case OPT_KEY_CACHE_AGE_THRESHOLD: - return (gptr*) &key_cache->age_threshold; + return (gptr*) &key_cache->param_age_threshold; } } } diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 932aceebdbb..4fdcd093132 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -83,7 +83,6 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) table_map removed_tables= 0, outer_tables= 0, used_tables= 0; table_map where_tables= 0; Item *item; - COND *org_conds= conds; int error; if (conds) diff --git a/sql/protocol.cc b/sql/protocol.cc index 884569d334a..e1347ff3c6f 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -302,6 +302,8 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) pos=net_store_data((char*) pos, message, strlen(message)); VOID(my_net_write(net,buff,(uint) (pos-buff))); VOID(net_flush(net)); + /* We can't anymore send an error to the client */ + thd->net.report_error= 0; DBUG_VOID_RETURN; } diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 19e3bb06d74..563a2d41019 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -30,7 +30,7 @@ bool Protocol_cursor::send_fields(List *list, uint flag) { List_iterator_fast it(*list); Item *item; - MYSQL_FIELD *field, *client_field; + MYSQL_FIELD *client_field; DBUG_ENTER("send_fields"); if (prepare_for_send(list)) @@ -71,9 +71,9 @@ bool Protocol_cursor::send_fields(List *list, uint flag) String tmp(buff, sizeof(buff), default_charset_info), *res; if (!(res=item->val_str(&tmp))) - client_field->def= strdup_root(alloc, ""); + client_field->def= (char*) ""; else - client_field->def= strdup_root(alloc, tmp.ptr()); + client_field->def= strmake_root(alloc, res->ptr(), res->length()); } else client_field->def=0; diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index aba887be070..776262be500 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -623,7 +623,6 @@ err: int show_slave_hosts(THD* thd) { List field_list; - NET* net = &thd->net; Protocol *protocol= thd->protocol; DBUG_ENTER("show_slave_hosts"); diff --git a/sql/set_var.cc b/sql/set_var.cc index 9a4543ada00..a7d077d8fc2 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -92,7 +92,7 @@ static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type); static void fix_max_binlog_size(THD *thd, enum_var_type type); static void fix_max_relay_log_size(THD *thd, enum_var_type type); static void fix_max_connections(THD *thd, enum_var_type type); -static KEY_CACHE_VAR *create_key_cache(const char *name, uint length); +static KEY_CACHE *create_key_cache(const char *name, uint length); void fix_sql_mode_var(THD *thd, enum_var_type type); static byte *get_error_count(THD *thd); static byte *get_warning_count(THD *thd); @@ -144,14 +144,14 @@ sys_var_thd_ulong sys_join_buffer_size("join_buffer_size", &SV::join_buff_size); sys_var_key_buffer_size sys_key_buffer_size("key_buffer_size"); sys_var_key_cache_long sys_key_cache_block_size("key_cache_block_size", - offsetof(KEY_CACHE_VAR, - block_size)); + offsetof(KEY_CACHE, + param_block_size)); sys_var_key_cache_long sys_key_cache_division_limit("key_cache_division_limit", - offsetof(KEY_CACHE_VAR, - division_limit)); + offsetof(KEY_CACHE, + param_division_limit)); sys_var_key_cache_long sys_key_cache_age_threshold("key_cache_age_threshold", - offsetof(KEY_CACHE_VAR, - age_threshold)); + offsetof(KEY_CACHE, + param_age_threshold)); sys_var_bool_ptr sys_local_infile("local_infile", &opt_local_infile); sys_var_thd_bool sys_log_warnings("log_warnings", &SV::log_warnings); @@ -1778,15 +1778,14 @@ void sys_var_collation_server::set_default(THD *thd, enum_var_type type) LEX_STRING default_key_cache_base= {(char *) "default", 7 }; -static KEY_CACHE_VAR zero_key_cache= - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static KEY_CACHE zero_key_cache; -KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name) +KEY_CACHE *get_key_cache(LEX_STRING *cache_name) { safe_mutex_assert_owner(&LOCK_global_system_variables); if (!cache_name || ! cache_name->length) cache_name= &default_key_cache_base; - return ((KEY_CACHE_VAR*) find_named(&key_caches, + return ((KEY_CACHE*) find_named(&key_caches, cache_name->str, cache_name->length, 0)); } @@ -1794,7 +1793,7 @@ KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name) byte *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - KEY_CACHE_VAR *key_cache= get_key_cache(base); + KEY_CACHE *key_cache= get_key_cache(base); if (!key_cache) key_cache= &zero_key_cache; return (byte*) key_cache + offset ; @@ -1805,7 +1804,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) { ulonglong tmp= var->save_result.ulonglong_value; LEX_STRING *base_name= &var->base; - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; bool error= 0; /* If no basename, assume it's for the key cache named 'default' */ @@ -1840,14 +1839,14 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) if (key_cache == sql_key_cache) goto end; // Ignore default key cache - if (key_cache->cache) // If initied + if (key_cache->key_cache_inited) // If initied { /* Move tables using this key cache to the default key cache and clear the old key cache. */ NAMED_LIST *list; - key_cache= (KEY_CACHE_VAR *) find_named(&key_caches, base_name->str, + key_cache= (KEY_CACHE *) find_named(&key_caches, base_name->str, base_name->length, &list); key_cache->in_init= 1; pthread_mutex_unlock(&LOCK_global_system_variables); @@ -1862,13 +1861,14 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) goto end; } - key_cache->buff_size= (ulonglong) getopt_ull_limit_value(tmp, option_limits); + key_cache->param_buff_size= + (ulonglong) getopt_ull_limit_value(tmp, option_limits); /* If key cache didn't existed initialize it, else resize it */ key_cache->in_init= 1; pthread_mutex_unlock(&LOCK_global_system_variables); - if (!key_cache->cache) + if (!key_cache->key_cache_inited) error= (bool) (ha_init_key_cache("", key_cache)); else error= (bool)(ha_resize_key_cache(key_cache)); @@ -1892,7 +1892,7 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var) base_name= &default_key_cache_base; pthread_mutex_lock(&LOCK_global_system_variables); - KEY_CACHE_VAR *key_cache= get_key_cache(base_name); + KEY_CACHE *key_cache= get_key_cache(base_name); if (!key_cache && !(key_cache= create_key_cache(base_name->str, base_name->length))) @@ -2413,7 +2413,6 @@ byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type, ulong val; char buff[256]; String tmp(buff, sizeof(buff), &my_charset_latin1); - my_bool found= 0; tmp.length(0); val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : @@ -2543,13 +2542,13 @@ void delete_elements(I_List *list, /* Key cache functions */ -static KEY_CACHE_VAR *create_key_cache(const char *name, uint length) +static KEY_CACHE *create_key_cache(const char *name, uint length) { - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; DBUG_ENTER("create_key_cache"); DBUG_PRINT("enter",("name: %.*s", length, name)); - if ((key_cache= (KEY_CACHE_VAR*) my_malloc(sizeof(KEY_CACHE_VAR), + if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE), MYF(MY_ZEROFILL | MY_WME)))) { if (!new NAMED_LIST(&key_caches, name, length, (gptr) key_cache)) @@ -2565,19 +2564,19 @@ static KEY_CACHE_VAR *create_key_cache(const char *name, uint length) We don't set 'buff_size' as this is used to enable the key cache */ - key_cache->block_size= dflt_key_cache_var.block_size; - key_cache->division_limit= dflt_key_cache_var.division_limit; - key_cache->age_threshold= dflt_key_cache_var.age_threshold; + key_cache->param_block_size= dflt_key_cache_var.param_block_size; + key_cache->param_division_limit= dflt_key_cache_var.param_division_limit; + key_cache->param_age_threshold= dflt_key_cache_var.param_age_threshold; } } DBUG_RETURN(key_cache); } -KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length) +KEY_CACHE *get_or_create_key_cache(const char *name, uint length) { LEX_STRING key_cache_name; - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; key_cache_name.str= (char *) name; key_cache_name.length= length; @@ -2589,21 +2588,21 @@ KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length) } -void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache) +void free_key_cache(const char *name, KEY_CACHE *key_cache) { ha_end_key_cache(key_cache); my_free((char*) key_cache, MYF(0)); } -bool process_key_caches(int (* func) (const char *name, KEY_CACHE_VAR *)) +bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)) { I_List_iterator it(key_caches); NAMED_LIST *element; while ((element= it++)) { - KEY_CACHE_VAR *key_cache= (KEY_CACHE_VAR *) element->data; + KEY_CACHE *key_cache= (KEY_CACHE *) element->data; func(element->name, key_cache); } return 0; diff --git a/sql/set_var.h b/sql/set_var.h index 666575a75e4..58ae53190e0 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -560,7 +560,7 @@ class sys_var_key_buffer_size :public sys_var_key_cache_param { public: sys_var_key_buffer_size(const char *name_arg) - :sys_var_key_cache_param(name_arg, offsetof(KEY_CACHE_VAR, buff_size)) + :sys_var_key_cache_param(name_arg, offsetof(KEY_CACHE, param_buff_size)) {} bool update(THD *thd, set_var *var); SHOW_TYPE type() { return SHOW_LONGLONG; } @@ -755,7 +755,7 @@ public: my_free((char*) name, MYF(0)); } friend bool process_key_caches(int (* func) (const char *name, - KEY_CACHE_VAR *)); + KEY_CACHE *)); friend void delete_elements(I_List *list, void (*free_element)(const char*, gptr)); }; @@ -788,9 +788,9 @@ gptr find_named(I_List *list, const char *name, uint length, NAMED_LIST **found); /* key_cache functions */ -KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name); -KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length); -void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache); -bool process_key_caches(int (* func) (const char *name, KEY_CACHE_VAR *)); +KEY_CACHE *get_key_cache(LEX_STRING *cache_name); +KEY_CACHE *get_or_create_key_cache(const char *name, uint length); +void free_key_cache(const char *name, KEY_CACHE *key_cache); +bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)); void delete_elements(I_List *list, void (*free_element)(const char*, gptr)); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b54e6a95bc5..bcfa9c6dec5 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -632,8 +632,8 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, if (acl_user) { /* OK. User found and password checked continue validation */ - Vio *vio=thd->net.vio; #ifdef HAVE_OPENSSL + Vio *vio=thd->net.vio; SSL *ssl= (SSL*) vio->ssl_arg; #endif @@ -3457,7 +3457,7 @@ int mysql_revoke_all(THD *thd, List &list) { uint counter; int result; - ACL_USER *acl_user; ACL_DB *acl_db; + ACL_DB *acl_db; TABLE_LIST tables[4]; DBUG_ENTER("mysql_revoke_all"); @@ -3471,7 +3471,7 @@ int mysql_revoke_all(THD *thd, List &list) List_iterator user_list(list); while ((lex_user=user_list++)) { - if (!(acl_user= check_acl_user(lex_user, &counter))) + if (!check_acl_user(lex_user, &counter)) { sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' not exists", lex_user->user.str, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9fe61ae19e1..7a657841845 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -35,7 +35,6 @@ HASH assign_cache; static int open_unireg_entry(THD *thd,TABLE *entry,const char *db, const char *name, const char *alias); static void free_cache_entry(TABLE *entry); -static void free_assign_entry(KEY_CACHE_ASMT *key_cache_asmt); static void mysql_rm_tmp_tables(void); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 63bf5f061e9..5481b1b266f 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -265,7 +265,6 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) char path[FN_REFLEN+16]; long result=1; int error = 0; - uint create_options = create_info ? create_info->options : 0; DBUG_ENTER("mysql_alter_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 78e8c877c45..88fedaad380 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -253,7 +253,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, continue; if (num_rows >= offset_limit) { - String *packet = &thd->packet; Item *item; protocol->prepare_for_resend(); it.rewind(); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9077d4c6a2d..4484cdbe248 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1488,6 +1488,8 @@ void select_insert::send_error(uint errcode,const char *err) bool select_insert::send_eof() { int error,error2; + DBUG_ENTER("select_insert::send_eof"); + if (!(error=table->file->extra(HA_EXTRA_NO_CACHE))) error=table->file->activate_all_index(thd); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); @@ -1521,20 +1523,18 @@ bool select_insert::send_eof() table->file->print_error(error,MYF(0)); //TODO error should be sent at the query processing end ::send_error(thd); - return 1; + DBUG_RETURN(1); } + + char buff[160]; + if (info.handle_duplicates == DUP_IGNORE) + sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, + (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); else - { - char buff[160]; - if (info.handle_duplicates == DUP_IGNORE) - sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); - else - sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) info.deleted, (ulong) thd->cuted_fields); - ::send_ok(thd,info.copied+info.deleted,last_insert_id,buff); - return 0; - } + sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, + (ulong) info.deleted, (ulong) thd->cuted_fields); + ::send_ok(thd,info.copied+info.deleted,last_insert_id,buff); + DBUG_RETURN(0); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index bc87f6aaabc..981e5e1e026 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -432,7 +432,7 @@ int yylex(void *arg, void *yythd) reg1 uchar c; int tokval, result_state; uint length; - enum my_lex_states state,prev_state; + enum my_lex_states state; LEX *lex= &(((THD *)yythd)->lex); YYSTYPE *yylval=(YYSTYPE*) arg; CHARSET_INFO *cs= ((THD *) yythd)->charset(); @@ -441,7 +441,7 @@ int yylex(void *arg, void *yythd) lex->yylval=yylval; // The global state lex->tok_start=lex->tok_end=lex->ptr; - prev_state=state=lex->next_state; + state=lex->next_state; lex->next_state=MY_LEX_OPERATOR_OR_IDENT; LINT_INIT(c); for (;;) @@ -1175,7 +1175,7 @@ void st_select_lex_unit::exclude_level() */ void st_select_lex_unit::exclude_tree() { - SELECT_LEX_UNIT *units= 0, **units_last= &units; + SELECT_LEX_UNIT *units= 0; for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) { // unlink current level from global SELECTs list diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 017ef065012..9f4b10682ba 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -128,7 +128,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, USER_RESOURCES *mqh) { int return_val=0; - uint temp_len, user_len, host_len; + uint temp_len, user_len; char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2]; struct user_conn *uc; @@ -136,7 +136,6 @@ static int get_or_create_user_conn(THD *thd, const char *user, DBUG_ASSERT(host != 0); user_len=strlen(user); - host_len=strlen(host); temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1; (void) pthread_mutex_lock(&LOCK_user_conn); if (!(uc = (struct user_conn *) hash_search(&hash_user_connections, diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2fa08e2d649..85b82d3b488 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1059,7 +1059,7 @@ void mysql_stmt_free(THD *thd, char *packet) PREP_STMT *stmt; DBUG_ENTER("mysql_stmt_free"); - if (!(stmt=find_prepared_statement(thd, stmt_id, "close"))) + if (!find_prepared_statement(thd, stmt_id, "close")) { send_error(thd); // Not seen by the client DBUG_VOID_RETURN; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ecad84ba0cb..80bcb7d569c 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1291,9 +1291,7 @@ int show_binlogs(THD* thd) { IO_CACHE *index_file; char fname[FN_REFLEN]; - NET* net = &thd->net; List field_list; - String *packet = &thd->packet; uint length; Protocol *protocol= thd->protocol; DBUG_ENTER("show_binlogs"); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 745f19d0bcf..44b403c0bb1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7228,7 +7228,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List &fields, Item *having) entry->file->info(HA_STATUS_VARIABLE); if (entry->db_type == DB_TYPE_HEAP || (!entry->blob_fields && - ((ALIGN_SIZE(reclength) +sizeof(HASH_LINK)) * entry->file->records < + ((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->file->records < thd->variables.sortbuff_size))) error=remove_dup_with_hash_index(join->thd, entry, field_count, first_field, @@ -7738,8 +7738,6 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, Item *itemptr=*order->item; if (itemptr->type() == Item::INT_ITEM) { /* Order by position */ - Item *item=0; - uint count= (uint) ((Item_int*)itemptr)->value; if (!count || count > fields.elements) { diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c2ebdeab5c2..e24102a5094 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -702,7 +702,6 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, restore_record(table,default_values); // Get empty record Field **ptr,*field; - String *packet= &thd->packet; for (ptr=table->field; (field= *ptr) ; ptr++) { if (!wild || !wild[0] || @@ -892,7 +891,6 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) if (protocol->send_fields(&field_list,1)) DBUG_RETURN(1); - String *packet= &thd->packet; KEY *key_info=table->key_info; table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); for (uint i=0 ; i < table->keys ; i++,key_info++) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b1d23de06b0..ea14249e907 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1637,7 +1637,7 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, LEX_STRING *key_cache_name) { HA_CHECK_OPT check_opt; - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; DBUG_ENTER("mysql_assign_to_keycache"); check_opt.init(); @@ -1682,14 +1682,14 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, 0 ok */ -int reassign_keycache_tables(THD *thd, KEY_CACHE_VAR *src_cache, - KEY_CACHE_VAR *dst_cache) +int reassign_keycache_tables(THD *thd, KEY_CACHE *src_cache, + KEY_CACHE *dst_cache) { DBUG_ENTER("reassign_keycache_tables"); DBUG_ASSERT(src_cache != dst_cache); DBUG_ASSERT(src_cache->in_init); - src_cache->buff_size= 0; // Free key cache + src_cache->param_buff_size= 0; // Free key cache ha_resize_key_cache(src_cache); ha_change_key_cache(src_cache, dst_cache); DBUG_RETURN(0); @@ -1955,7 +1955,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ulonglong next_insert_id; uint save_time_stamp,db_create_options, used_fields; enum db_type old_db_type,new_db_type; - thr_lock_type lock_type; DBUG_ENTER("mysql_alter_table"); thd->proc_info="init"; @@ -2798,7 +2797,6 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) for (table= tables; table; table= table->next) { char table_name[NAME_LEN*2+2]; - bool fatal_error= 0; TABLE *t; strxmov(table_name, table->db ,".", table->real_name, NullS); diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 449c43c24d1..6763181ce4a 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -303,9 +303,9 @@ end: } -static int print_key_cache_status(const char *name, KEY_CACHE_VAR *key_cache) +static int print_key_cache_status(const char *name, KEY_CACHE *key_cache) { - if (!key_cache->cache) + if (!key_cache->key_cache_inited) { printf("%s: Not in use\n", name); } @@ -323,11 +323,11 @@ writes: %10lu\n\ r_requests: %10lu\n\ reads: %10lu\n\n", name, - (ulong) key_cache->buff_size, key_cache->block_size, - key_cache->division_limit, key_cache->age_threshold, - key_cache->blocks_used,key_cache->blocks_changed, - key_cache->cache_w_requests,key_cache->cache_write, - key_cache->cache_r_requests,key_cache->cache_read); + (ulong) key_cache->param_buff_size, key_cache->param_block_size, + key_cache->param_division_limit, key_cache->param_age_threshold, + key_cache->global_blocks_used,key_cache->global_blocks_changed, + key_cache->global_cache_w_requests,key_cache->global_cache_write, + key_cache->global_cache_r_requests,key_cache->global_cache_read); } return 0; } diff --git a/sql/strfunc.cc b/sql/strfunc.cc index 1db2124bcee..d00e57df5a1 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -112,7 +112,7 @@ uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match) found_pos= pos; } } - return(found_count == 1 && part_match ? found_count : 0); + return(found_count == 1 && part_match ? found_pos : 0); } diff --git a/sql/time.cc b/sql/time.cc index e696918dee3..fe22b80d59d 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -357,7 +357,6 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags) const char *end=str+length; const uchar *format_position; bool found_delimitier= 0, found_space= 0; - DATE_TIME_FORMAT *format; DBUG_ENTER("str_to_TIME"); DBUG_PRINT("ENTER",("str: %.*s",length,str)); diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index 117b9d16a65..6319fbb4d9f 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -82,7 +82,7 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error) unsigned long i, j, k; ulonglong li; int negative; - long cutoff, cutoff2, cutoff3; + ulong cutoff, cutoff2, cutoff3; s= nptr; /* If fixed length string */ From 55182340ba00401540f9c4843a29e390e0cf40b6 Mon Sep 17 00:00:00 2001 From: "serg@sergbook.mylan" <> Date: Thu, 20 Nov 2003 22:20:54 +0100 Subject: [PATCH 23/89] more left join tests --- mysql-test/r/fulltext_left_join.result | 8 ++++++++ mysql-test/t/fulltext_left_join.test | 2 ++ 2 files changed, 10 insertions(+) diff --git a/mysql-test/r/fulltext_left_join.result b/mysql-test/r/fulltext_left_join.result index 6875a517718..d215ea0cea8 100644 --- a/mysql-test/r/fulltext_left_join.result +++ b/mysql-test/r/fulltext_left_join.result @@ -41,4 +41,12 @@ venue_id venue_text dt name entity_id select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen') and dt = '2003-05-23 19:30:00'; venue_id venue_text dt name entity_id 1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen' in boolean mode)) where dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +NULL a2 2003-05-23 19:30:00 NULL NULL +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +NULL a2 2003-05-23 19:30:00 NULL NULL drop table t1,t2; diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test index da4df13bc0c..a785cc6a61c 100644 --- a/mysql-test/t/fulltext_left_join.test +++ b/mysql-test/t/fulltext_left_join.test @@ -38,5 +38,7 @@ create table t2 (name varchar(255) not null default '', entity_id int(11) not nu insert into t2 (name, entity_id) values ('aberdeen town hall', 1), ('glasgow royal concert hall', 2), ('queen\'s hall, edinburgh', 3); select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen' in boolean mode) and dt = '2003-05-23 19:30:00'; select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen') and dt = '2003-05-23 19:30:00'; +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen' in boolean mode)) where dt = '2003-05-23 19:30:00'; +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00'; drop table t1,t2; From 41eda1c949671be87631255df355530da4efb745 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 21 Nov 2003 00:11:50 +0200 Subject: [PATCH 24/89] Revert patch for bigint handling in double context as it broke normal bigint handling The right way to fix this is to change the Field::store(longlong) method to be Field::store(longlong, bool unsigned_flag), but this is better to do in 4.1 than in 4.0 --- mysql-test/r/bigint.result | 8 +++++++- mysql-test/t/bigint.test | 4 +++- sql/item.cc | 12 ------------ sql/item.h | 1 - 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 2b595c2b83d..308adc881f2 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -15,9 +15,11 @@ select 9223372036854775808+1; 9223372036854775809 drop table if exists t1; create table t1 (a bigint unsigned not null, primary key(a)); -insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); +insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t1; a +18446744073709551612 +18446744073709551613 18446744073709551614 18446744073709551615 select * from t1 where a=18446744073709551615; @@ -26,6 +28,8 @@ a delete from t1 where a=18446744073709551615; select * from t1; a +18446744073709551612 +18446744073709551613 18446744073709551614 drop table t1; create table t1 ( a int not null default 1, big bigint ); @@ -69,9 +73,11 @@ id a drop table t1; CREATE TABLE t1 ( quantity decimal(60,0)); insert into t1 values (10000000000000000000); +insert into t1 values (10000000000000000000.0); insert into t1 values ('10000000000000000000'); select * from t1; quantity +-8446744073709551616 10000000000000000000 10000000000000000000 drop table t1; diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index a7cc068ec46..f21f821e45c 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -14,7 +14,7 @@ select 9223372036854775808+1; drop table if exists t1; create table t1 (a bigint unsigned not null, primary key(a)); -insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); +insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t1; select * from t1 where a=18446744073709551615; # select * from t1 where a='18446744073709551615'; @@ -50,10 +50,12 @@ drop table t1; # # Item_uint::save_to_field() # BUG#1845 +# This can't be fixed in MySQL 4.0 without loosing precisions for bigints # CREATE TABLE t1 ( quantity decimal(60,0)); insert into t1 values (10000000000000000000); +insert into t1 values (10000000000000000000.0); insert into t1 values ('10000000000000000000'); select * from t1; drop table t1; diff --git a/sql/item.cc b/sql/item.cc index 65eb7f1befd..fc6256d4fed 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -548,18 +548,6 @@ bool Item_string::save_in_field(Field *field, bool no_conversions) return 0; } -bool Item_uint::save_in_field(Field *field, bool no_conversions) -{ - longlong nr=val_int(); - if (null_value) - return set_field_to_null(field); - field->set_notnull(); - if (nr < 0) - field->store(ulonglong2double(nr)); - else - field->store(nr); - return 0; -} bool Item_int::save_in_field(Field *field, bool no_conversions) { diff --git a/sql/item.h b/sql/item.h index d23a061eedb..e8a6313b6a0 100644 --- a/sql/item.h +++ b/sql/item.h @@ -232,7 +232,6 @@ public: String *val_str(String*); void make_field(Send_field *field); Item *new_item() { return new Item_uint(name,max_length); } - bool save_in_field(Field *field, bool no_conversions); bool fix_fields(THD *thd,struct st_table_list *table_list) { unsigned_flag= 1; From 8ca18362071bf519426b589a806b7ba85255a111 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Thu, 20 Nov 2003 23:15:07 +0100 Subject: [PATCH 25/89] yet another trunc* bug --- myisam/ft_boolean_search.c | 53 ++++++++++++++++++++++-------------- mysql-test/r/fulltext.result | 3 ++ mysql-test/t/fulltext.test | 1 + 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 72c54bd0c5b..30b52a20060 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -62,11 +62,12 @@ typedef struct st_ftb_expr FTB_EXPR; struct st_ftb_expr { FTB_EXPR *up; - byte *quot, *qend; float weight; uint flags; - my_off_t docid[2]; /* for index search and for scan */ + my_off_t docid[2]; +/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */ float cur_weight; + byte *quot, *qend; int yesses; /* number of "yes" words matched */ int nos; /* number of "no" words matched */ int ythresh; /* number of "yes" words in expr */ @@ -78,7 +79,8 @@ typedef struct st_ftb_word FTB_EXPR *up; float weight; uint flags; - my_off_t docid[2]; /* for index search and for scan */ + my_off_t docid[2]; +/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */ uint ndepth; int len; /* ... docid cache can be added here. SerG */ @@ -217,13 +219,15 @@ static void _ftb_init_index_search(FT_INFO *ftb) if (ftbw->flags & FTB_FLAG_TRUNC) { /* - special treatment for truncation operator :(( - 1. +trunc* and there're other (not +trunc*) words + special treatment for truncation operator + 1. there are some (besides this) +words | no need to search in the index, it can never ADD new rows | to the result, and to remove half-matched rows we do scan anyway 2. -trunc* | same as 1. - 3. trunc* + 3. in 1 and 2, +/- need not be on the same expr. level, + but can be on any upper level, as in +word +(trunc1* trunc2*) + 4. otherwise | We have to index-search for this prefix. | It may cause duplicates, as in the index (sorted by ) | @@ -231,22 +235,31 @@ static void _ftb_init_index_search(FT_INFO *ftb) | | Searching for "aa*" will find row1 twice... */ - if ( test(ftbw->flags&FTB_FLAG_NO) || /* 2 */ - (test(ftbw->flags&FTB_FLAG_YES) && /* 1 */ - ftbw->up->ythresh - ftbw->up->yweaks >1)) /* 1 */ + FTB_EXPR *ftbe; + for (ftbe=(FTB_EXPR*)ftbw; + ftbe->up && !(ftbe->up->flags & FTB_FLAG_TRUNC); + ftbe->up->flags|= FTB_FLAG_TRUNC, ftbe=ftbe->up) { - ftbw->docid[0]=HA_POS_ERROR; - ftbw->up->yweaks++; + if (ftbe->flags & FTB_FLAG_NO || /* 2 */ + ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */ + { + FTB_EXPR *top_ftbe=ftbe->up->up; + ftbw->docid[0]=HA_POS_ERROR; + for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up) + if (ftbe->flags & FTB_FLAG_YES) + ftbe->yweaks++; + ftbe=0; + break; + } + } + if (!ftbe) continue; - } - else /* 3 */ - { - if (!is_tree_inited(& ftb->no_dupes)) - init_tree(& ftb->no_dupes,0,0,sizeof(my_off_t), - _ftb_no_dupes_cmp,0,0,0); - else - reset_tree(& ftb->no_dupes); - } + /* 3 */ + if (!is_tree_inited(& ftb->no_dupes)) + init_tree(& ftb->no_dupes,0,0,sizeof(my_off_t), + _ftb_no_dupes_cmp,0,0,0); + else + reset_tree(& ftb->no_dupes); } r=_mi_search(info, keyinfo, (uchar*) ftbw->word, ftbw->len, SEARCH_FIND | SEARCH_BIGGER, keyroot); diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index bd5d7c2a6ac..e8ae9d3063f 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -147,6 +147,9 @@ aaa20 bbb15 aaa30 bbb10 select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); a +select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); +a +aaa10 bbb20 drop table t1; CREATE TABLE t1 ( id int(11), diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 567fae069a1..e8f5d497692 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -78,6 +78,7 @@ insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); drop table t1; # From 8aeb63dd3bc0a7c7ec1cda701f721591929c41e3 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 21 Nov 2003 01:53:01 +0200 Subject: [PATCH 26/89] Update VC++ files Portability fixes After merge fixes --- VC++Files/mysql.dsw | 9 ++++++++ VC++Files/mysys/mysys.dsp | 4 ++++ client/mysqlcheck.c | 2 ++ client/mysqltest.c | 13 ++++-------- include/keycache.h | 3 --- include/m_ctype.h | 8 +++++++ include/my_base.h | 1 - myisam/mi_keycache.c | 6 ++++++ mysql-test/r/count_distinct3.result | 1 + mysql-test/r/rpl_change_master.result | 12 +++++------ mysql-test/t/count_distinct3.test | 3 +++ mysql-test/t/rpl_change_master.test | 2 ++ mysys/default.c | 1 + mysys/mf_keycache.c | 8 +++---- mysys/my_getopt.c | 4 +--- sql/ha_myisam.cc | 11 ++++------ sql/item.cc | 2 +- sql/item_timefunc.cc | 30 +++++++++++++-------------- sql/set_var.cc | 2 +- sql/sql_prepare.cc | 1 - sql/sql_repl.cc | 5 +++-- sql/sql_select.h | 22 +++++++++++++++----- sql/sql_table.cc | 3 +-- strings/ctype-tis620.c | 8 +++---- 24 files changed, 96 insertions(+), 65 deletions(-) diff --git a/VC++Files/mysql.dsw b/VC++Files/mysql.dsw index 4ff8c1df3fc..ea391362b84 100644 --- a/VC++Files/mysql.dsw +++ b/VC++Files/mysql.dsw @@ -251,6 +251,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name strings End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### @@ -275,6 +278,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name strings End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### @@ -311,6 +317,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name strings End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index 1867a3d02d4..3f9d37b395f 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -298,6 +298,10 @@ SOURCE=.\my_copy.c # End Source File # Begin Source File +SOURCE=.\my_crc32.c +# End Source File +# Begin Source File + SOURCE=.\my_create.c # End Source File # Begin Source File diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 00767ae98a7..1768d948373 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -309,6 +309,8 @@ static int get_options(int *argc, char ***argv) else what_to_do = DO_CHECK; } + + /* TODO: This variable is not yet used */ if (!(charset_info= get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME)))) exit(1); diff --git a/client/mysqltest.c b/client/mysqltest.c index 6a7f4ab7cac..e3e3d19984a 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -118,7 +118,6 @@ static FILE** cur_file; static FILE** file_stack_end; static uint lineno_stack[MAX_INCLUDE_DEPTH]; static char TMPDIR[FN_REFLEN]; -static int *block_ok_stack_end; static int *cur_block, *block_stack_end; static int block_stack[BLOCK_STACK_DEPTH]; @@ -1495,7 +1494,6 @@ int do_connect(struct st_query* q) char* p=q->first_argument; char buff[FN_REFLEN]; int con_port; - int con_error; int free_con_sock = 0; DBUG_ENTER("do_connect"); @@ -1560,9 +1558,9 @@ int do_connect(struct st_query* q) /* Special database to allow one to connect without a database name */ if (con_db && !strcmp(con_db,"*NO-ONE*")) con_db=0; - if ((con_error = safe_connect(&next_con->mysql, con_host, - con_user, con_pass, - con_db, con_port, con_sock ? con_sock: 0))) + if ((safe_connect(&next_con->mysql, con_host, + con_user, con_pass, + con_db, con_port, con_sock ? con_sock: 0))) die("Could not open connection '%s': %s", con_name, mysql_error(&next_con->mysql)); @@ -2018,12 +2016,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), int parse_args(int argc, char **argv) { - int ho_error; - load_defaults("my",load_default_groups,&argc,&argv); default_argv= argv; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + if ((handle_options(&argc, &argv, my_long_options, get_one_option))) exit(1); if (argc > 1) @@ -2454,7 +2450,6 @@ int main(int argc, char **argv) memset(block_stack, 0, sizeof(block_stack)); block_stack_end = block_stack + BLOCK_STACK_DEPTH; memset(block_ok_stack, 0, sizeof(block_stack)); - block_ok_stack_end = block_ok_stack + BLOCK_STACK_DEPTH; cur_block = block_stack; block_ok = block_ok_stack; *block_ok = 1; diff --git a/include/keycache.h b/include/keycache.h index 824c5874ffc..340ab881fee 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -91,9 +91,6 @@ typedef struct st_key_cache ulong global_cache_read; /* number of reads from files to the cache */ int blocks; /* max number of blocks in the cache */ my_bool in_init; /* Set to 1 in MySQL during init/resize */ - - /* optional call back function */ - void (*action)(struct st_key_cache *); } KEY_CACHE; /* The default key cache */ diff --git a/include/m_ctype.h b/include/m_ctype.h index e2b2f7f1668..0228b359111 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -335,6 +335,14 @@ uint my_instr_mb(struct charset_info_st *, extern my_bool my_parse_charset_xml(const char *bug, uint len, int (*add)(CHARSET_INFO *cs)); +#undef _U +#undef _L +#undef _NMR +#undef _SPC +#undef _PNT +#undef _CTR +#undef _B +#undef _X #define _U 01 /* Upper case */ #define _L 02 /* Lower case */ diff --git a/include/my_base.h b/include/my_base.h index 1bd0f47afa4..25521d7b13d 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -46,7 +46,6 @@ #define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */ #define HA_OPEN_ABORT_IF_CRASHED 16 #define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */ -#define HA_OPEN_TO_ASSIGN 64 /* Open for key cache assignment */ /* The following is parameter to ha_rkey() how to use key */ diff --git a/myisam/mi_keycache.c b/myisam/mi_keycache.c index 2c808c68c98..fc51f331d76 100644 --- a/myisam/mi_keycache.c +++ b/myisam/mi_keycache.c @@ -92,6 +92,11 @@ int mi_assign_to_key_cache(MI_INFO *info, */ (void) flush_key_blocks(key_cache, share->kfile, FLUSH_REMOVE); + /* + ensure that setting the key cache and changing the multi_key_cache + is done atomicly + */ + pthread_mutex_lock(&share->intern_lock); /* Tell all threads to use the new key cache This should be seen at the lastes for the next call to an myisam function. @@ -102,6 +107,7 @@ int mi_assign_to_key_cache(MI_INFO *info, if (multi_key_cache_set(share->unique_file_name, share->unique_name_length, share->key_cache)) error= my_errno; + pthread_mutex_unlock(&share->intern_lock); DBUG_RETURN(error); } diff --git a/mysql-test/r/count_distinct3.result b/mysql-test/r/count_distinct3.result index 633bb2fa252..086e1360b0c 100644 --- a/mysql-test/r/count_distinct3.result +++ b/mysql-test/r/count_distinct3.result @@ -5,3 +5,4 @@ COUNT(*) 4181000 SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp; DROP TABLE t1; +set @@read_buffer_size=default; diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result index be2aec616b0..883cb65171c 100644 --- a/mysql-test/r/rpl_change_master.result +++ b/mysql-test/r/rpl_change_master.result @@ -1,9 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; select get_lock("a",5); get_lock("a",5) 1 @@ -15,12 +15,12 @@ select * from t1; n 1 show slave status; -Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root 9306 1 master-bin.001 273 slave-relay-bin.002 255 master-bin.001 No No 0 0 214 314 +Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +# 127.0.0.1 root 9306 1 master-bin.000001 273 slave-relay-bin.000002 258 master-bin.000001 No No 0 0 214 317 None 0 No # change master to master_user='root'; show slave status; -Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root 9306 1 master-bin.001 214 slave-relay-bin.001 4 master-bin.001 No No 0 0 214 4 +Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +# 127.0.0.1 root 9306 1 master-bin.000001 214 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 214 4 None 0 No # select release_lock("a"); release_lock("a") 1 diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test index e6cc98d47df..9d2bb0d139a 100644 --- a/mysql-test/t/count_distinct3.test +++ b/mysql-test/t/count_distinct3.test @@ -21,6 +21,7 @@ while ($1) INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); dec $1; } +set @@read_buffer_size=2*1024*1024; CREATE TABLE t2 SELECT * FROM t1; INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; @@ -53,3 +54,5 @@ SELECT COUNT(*) FROM t1; SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp; --enable_result_log DROP TABLE t1; + +set @@read_buffer_size=default; diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test index 61de22fe57b..33fc2d75dd3 100644 --- a/mysql-test/t/rpl_change_master.test +++ b/mysql-test/t/rpl_change_master.test @@ -11,8 +11,10 @@ connection slave; sleep 3; # can't sync_with_master as we should be blocked stop slave; select * from t1; +--replace_column 1 # 33 # show slave status; change master to master_user='root'; +--replace_column 1 # 33 # show slave status; # Will restart from after the values(2), which is bug select release_lock("a"); diff --git a/mysys/default.c b/mysys/default.c index b1d9e40a1c2..3a751eb4e29 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -251,6 +251,7 @@ int load_defaults(const char *conf_file, const char **groups, err: fprintf(stderr,"Fatal error in defaults handling. Program aborted\n"); exit(1); + return 0; /* Keep compiler happy */ } diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 10ec72c220e..b1ef03fdcd2 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -15,8 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - These functions are to handle keyblock cacheing - for NISAM, MISAM and PISAM databases. + These functions handle keyblock cacheing for ISAM and MyISAM tables. + One cache can handle many files. It must contain buffers of the same blocksize. init_key_cache() should be used to init cache handler. @@ -282,6 +282,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, if (! keycache->key_cache_inited) { keycache->key_cache_inited= 1; + keycache->in_init= 0; pthread_mutex_init(&keycache->cache_lock, MY_MUTEX_INIT_FAST); } @@ -2159,9 +2160,6 @@ restart: } } - if (type == FLUSH_REMOVE && keycache->action) - (*keycache->action)(keycache); - #ifndef DBUG_OFF DBUG_EXECUTE("check_keycache", test_key_cache(keycache, "end of flush_key_blocks", 0);); diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 7fa8c9d4fa1..830c62b349b 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -83,7 +83,7 @@ int handle_options(int *argc, char ***argv, char *)) { uint opt_found, argvpos= 0, length, i; - my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used, + my_bool end_of_options= 0, must_be_var, set_maximum_value, option_is_loose; char **pos, **pos_end, *optend, *prev_found, *opt_str, key_name[FN_REFLEN]; @@ -104,7 +104,6 @@ int handle_options(int *argc, char ***argv, char *argument= 0; must_be_var= 0; set_maximum_value= 0; - special_used= 0; option_is_loose= 0; cur_arg++; /* skip '-' */ @@ -202,7 +201,6 @@ int handle_options(int *argc, char ***argv, /* We were called with a special prefix, we can reuse opt_found */ - special_used= 1; opt_str+= (special_opt_prefix_lengths[i] + 1); if (i == OPT_LOOSE) option_is_loose= 1; diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 3cdd923d085..a10eeb3c934 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -720,13 +720,10 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) if ((error= mi_assign_to_key_cache(file, map, new_key_cache))) { - switch (error) { - default: - char buf[80]; - my_snprintf(buf, sizeof(buf), - "Failed to flush to index file (errno: %d)", error); - errmsg= buf; - } + char buf[80]; + my_snprintf(buf, sizeof(buf), + "Failed to flush to index file (errno: %d)", error); + errmsg= buf; error= HA_ADMIN_CORRUPT; } diff --git a/sql/item.cc b/sql/item.cc index 4cd52c54097..9684fd3e518 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1196,7 +1196,7 @@ int Item_uint::save_in_field(Field *field, bool no_conversions) TODO: To be fixed when wen have a field->store(longlong, unsigned_flag) method */ - Item_int::save_in_field(field, no_conversions); + return Item_int::save_in_field(field, no_conversions); } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index e73ecc99ffe..496ea0ed5c8 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -235,7 +235,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, /* Second part */ case 'f': tmp= (char*) val_end; - l_time->second_part= my_strtoll10(val, &tmp, &error); + l_time->second_part= (int) my_strtoll10(val, &tmp, &error); val= tmp; break; @@ -1219,7 +1219,7 @@ String *Item_func_sec_to_time::val_str(String *str) sec= (uint) ((ulonglong) seconds % 3600); ltime.day= 0; - ltime.hour= seconds/3600; + ltime.hour= (uint) (seconds/3600); ltime.minute= sec/60; ltime.second= sec % 60; @@ -1850,9 +1850,8 @@ String *Item_datetime_typecast::val_str(String *str) if (!get_arg0_date(<ime,1) && !make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME, <ime, str)) - return str; + return str; -null_date: null_value=1; return 0; } @@ -1911,8 +1910,8 @@ String *Item_date_typecast::val_str(String *str) String *Item_func_makedate::val_str(String *str) { TIME l_time; - long daynr= args[1]->val_int(); - long yearnr= args[0]->val_int(); + long daynr= (long) args[1]->val_int(); + long yearnr= (long) args[0]->val_int(); long days; if (args[0]->null_value || args[1]->null_value || @@ -1920,7 +1919,7 @@ String *Item_func_makedate::val_str(String *str) goto err; days= calc_daynr(yearnr,1,1) + daynr - 1; - // Day number from year 0 to 9999-12-31 + /* Day number from year 0 to 9999-12-31 */ if (days >= 0 && days < MAX_DAY_NUMBER) { null_value=0; @@ -2124,7 +2123,8 @@ String *Item_func_timediff::val_str(String *str) microseconds= l_time1.second_part - l_sign*l_time2.second_part; seconds= ((longlong) days*86400L + l_time1.hour*3600L + l_time1.minute*60L + l_time1.second + microseconds/1000000L - - (longlong)l_sign*(l_time2.hour*3600L+l_time2.minute*60L+l_time2.second)); + (longlong)l_sign*(l_time2.hour*3600L+l_time2.minute*60L+ + l_time2.second)); l_time3.neg= 0; if (seconds < 0) @@ -2145,7 +2145,7 @@ String *Item_func_timediff::val_str(String *str) if ((l_time2.neg == l_time1.neg) && l_time1.neg) l_time3.neg= l_time3.neg ? 0 : 1; - calc_time_from_sec(&l_time3, seconds, microseconds); + calc_time_from_sec(&l_time3, (long) seconds, microseconds); if (!make_datetime(l_time1.second_part || l_time2.second_part ? TIME_MICROSECOND : TIME_ONLY, @@ -2167,9 +2167,9 @@ String *Item_func_maketime::val_str(String *str) { TIME ltime; - long hour= args[0]->val_int(); - long minute= args[1]->val_int(); - long second= args[2]->val_int(); + long hour= (long) args[0]->val_int(); + long minute= (long) args[1]->val_int(); + long second= (long) args[2]->val_int(); if ((null_value=(args[0]->null_value || args[1]->null_value || @@ -2185,9 +2185,9 @@ String *Item_func_maketime::val_str(String *str) ltime.neg= 1; hour= -hour; } - ltime.hour= (ulong)hour; - ltime.minute= (ulong)minute; - ltime.second= (ulong)second; + ltime.hour= (ulong) hour; + ltime.minute= (ulong) minute; + ltime.second= (ulong) second; make_time((DATE_TIME_FORMAT *) 0, <ime, str); return str; } diff --git a/sql/set_var.cc b/sql/set_var.cc index a7d077d8fc2..9b7be4afacc 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1884,7 +1884,7 @@ end: bool sys_var_key_cache_long::update(THD *thd, set_var *var) { - ulong tmp= var->value->val_int(); + ulong tmp= (ulong) var->value->val_int(); LEX_STRING *base_name= &var->base; bool error= 0; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 85b82d3b488..354214a4da5 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1056,7 +1056,6 @@ void mysql_stmt_reset(THD *thd, char *packet) void mysql_stmt_free(THD *thd, char *packet) { ulong stmt_id= uint4korr(packet); - PREP_STMT *stmt; DBUG_ENTER("mysql_stmt_free"); if (!find_prepared_statement(thd, stmt_id, "close")) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 49ca1ed1c8c..a3c9396db11 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1080,8 +1080,9 @@ int change_master(THD* thd, MASTER_INFO* mi) of replication is not 100% clear, so we guard against problems using max(). */ - mi->master_log_pos = max(BIN_LOG_HEADER_SIZE, mi->rli.master_log_pos); - strmake(mi->master_log_name,mi->rli.master_log_name, + mi->master_log_pos = max(BIN_LOG_HEADER_SIZE, + mi->rli.group_master_log_pos); + strmake(mi->master_log_name, mi->rli.group_master_log_name, sizeof(mi->master_log_name)-1); } diff --git a/sql/sql_select.h b/sql/sql_select.h index 24854713a0e..5f0370a5a32 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -166,11 +166,23 @@ class JOIN :public Sql_alloc JOIN *tmp_join; // copy of this JOIN to be used with temporary tables ROLLUP rollup; // Used with rollup - bool select_distinct, //Is select distinct? - no_order, simple_order, simple_group, - skip_sort_order, need_tmp, - hidden_group_fields, - buffer_result; + bool select_distinct; // Set if SELECT DISTINCT + + /* + simple_xxxxx is set if ORDER/GROUP BY doesn't include any references + to other tables than the first non-constant table in the JOIN. + It's also set if ORDER/GROUP BY is empty. + */ + bool simple_order, simple_group; + /* + Is set only in case if we have a GROUP BY clause + and no ORDER BY after constant elimination of 'order'. + */ + bool no_order; + /* Is set if we have a GROUP BY and we have ORDER BY on a constant. */ + bool skip_sort_order; + + bool need_tmp, hidden_group_fields, buffer_result; DYNAMIC_ARRAY keyuse; Item::cond_result cond_value; List all_fields; // to store all fields that used in query diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ea14249e907..8504a408605 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1652,8 +1652,7 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, check_opt.key_cache= key_cache; DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt, "assign_to_keycache", TL_READ_NO_INSERT, 0, - HA_OPEN_TO_ASSIGN, 0, - &handler::assign_to_keycache)); + 0, 0, &handler::assign_to_keycache)); } diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index fd5e58ad8a7..a2edc33b3d2 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -472,13 +472,13 @@ static uchar *thai2sortable(const uchar *tstr, uint len, uint *out_length) const uchar *p= tstr; uchar *outBuf; uchar *pRight1, *pRight2, *pRight3; - uchar *pLeft1, *pLeft2, *pLeft3; + uchar *pLeft2, *pLeft3; uint bufSize; uint RightSize; bufSize= (uint) (len + 1) * BUFFER_MULTIPLY; RightSize= sizeof(uchar) * (len + 1); - if (!(outBuf= pLeft1= pRight1= + if (!(outBuf= pRight1= (uchar *)malloc(sizeof(uchar) * bufSize + RightSize*2))) { /* @@ -608,8 +608,8 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), int my_strcoll_tis620(const uchar * s1, const uchar * s2) { - return my_strnncoll_tis620((CHARSET_INFO *) 0, s1, strlen(s1), s2, - strlen(s1)); + return my_strnncoll_tis620((CHARSET_INFO *) 0, s1, strlen((char*) s1), + s2, strlen((char*) s1)); } From 19b5da3247c844b52de2706fc3dd19fe0099dc84 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 21 Nov 2003 12:22:51 +0200 Subject: [PATCH 27/89] Added missing file keycache.h --- BUILD/compile-pentium-debug-max | 2 +- include/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD/compile-pentium-debug-max b/BUILD/compile-pentium-debug-max index b23648e4d91..f8cf19b2132 100755 --- a/BUILD/compile-pentium-debug-max +++ b/BUILD/compile-pentium-debug-max @@ -8,6 +8,6 @@ c_warnings="$c_warnings $debug_extra_warnings" cxx_warnings="$cxx_warnings $debug_extra_warnings" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-berkeley-db --with-innodb --without-isam --with-embedded-server --with-openssl" +extra_configs="$extra_configs --with-berkeley-db --with-innodb --without-isam --with-embedded-server --with-openssl --with-raid" . "$path/FINISH.sh" diff --git a/include/Makefile.am b/include/Makefile.am index 2ec06d71fbe..3adbb31f235 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -21,7 +21,7 @@ pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \ my_semaphore.h my_pthread.h my_no_pthread.h raid.h \ errmsg.h my_global.h my_net.h my_alloc.h \ my_getopt.h sslopt-longopts.h my_dir.h typelib.h \ - sslopt-vars.h sslopt-case.h sql_common.h \ + sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ sql_state.h $(BUILT_SOURCES) noinst_HEADERS = config-win.h config-os2.h config-netware.h \ nisam.h heap.h merge.h my_bitmap.h\ From 35af929935e891061144b82b1953930654ccc639 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 21 Nov 2003 13:22:49 +0100 Subject: [PATCH 28/89] - removed dependency on MySQL-client from the MySQL-devel RPM subpackage as it is not really required. (BUG 1610) Thanks to Scott Harrison for the suggestion. --- support-files/mysql.spec.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index ffc74c7559d..974a3bde36a 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -120,7 +120,6 @@ Este pacote cont %package devel Release: %{release} -Requires: %{name}-client Summary: MySQL - Development header files and libraries Group: Applications/Databases Summary(pt_BR): MySQL - Medições de desempenho @@ -568,6 +567,11 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Fri Nov 21 2003 Lenz Grimmer + +- removed dependency on MySQL-client from the MySQL-devel subpackage + as it is not really required. (BUG 1610) + * Fri Aug 29 2003 Lenz Grimmer - Fixed BUG 1162 (removed macro names from the changelog) From d08945498e44acb968d1aab6d269d9b1874246e6 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 21 Nov 2003 14:41:57 +0200 Subject: [PATCH 29/89] Fixed memory leak with RAID tables Fixed tests for RAID tables Detect uninitialized mutexes on lock and destroy --- mysql-test/r/raid.result | 8 ++-- mysql-test/r/rpl_change_master.result | 4 +- mysql-test/t/raid.test | 3 +- mysys/mf_iocache.c | 62 +++++++++++++++++++++++---- mysys/thr_mutex.c | 14 +++++- sql/sql_db.cc | 12 ++++-- 6 files changed, 82 insertions(+), 21 deletions(-) diff --git a/mysql-test/r/raid.result b/mysql-test/r/raid.result index fd47a9451f6..6e16757a43d 100644 --- a/mysql-test/r/raid.result +++ b/mysql-test/r/raid.result @@ -1,7 +1,8 @@ -create database test_raid; -create table test_raid.r1 (i int) raid_type=1; -drop database test_raid; DROP TABLE IF EXISTS t1,t2; +DROP DATABASE IF EXISTS test_$1; +create database test_$1; +create table test_$1.r1 (i int) raid_type=1; +drop database test_$1; CREATE TABLE t1 ( id int unsigned not null auto_increment primary key, c char(255) not null @@ -99,7 +100,6 @@ count(*) 450 DROP TABLE t2; /* variable rows */ -DROP TABLE IF EXISTS t2; CREATE TABLE t1 ( id int unsigned not null auto_increment primary key, c varchar(255) not null diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result index 883cb65171c..a886ad9c304 100644 --- a/mysql-test/r/rpl_change_master.result +++ b/mysql-test/r/rpl_change_master.result @@ -15,11 +15,11 @@ select * from t1; n 1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root 9306 1 master-bin.000001 273 slave-relay-bin.000002 258 master-bin.000001 No No 0 0 214 317 None 0 No # change master to master_user='root'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root 9306 1 master-bin.000001 214 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 214 4 None 0 No # select release_lock("a"); release_lock("a") diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test index 395a04615cb..0d6e851a153 100644 --- a/mysql-test/t/raid.test +++ b/mysql-test/t/raid.test @@ -9,6 +9,7 @@ enable_query_log; --disable_warnings DROP TABLE IF EXISTS t1,t2; +DROP DATABASE IF EXISTS test_$1; --enable_warnings # @@ -111,8 +112,8 @@ ALTER TABLE t1 DROP COLUMN x; ALTER TABLE t1 RENAME t2; select count(*) from t2; DROP TABLE t2; + /* variable rows */ -DROP TABLE IF EXISTS t2; CREATE TABLE t1 ( id int unsigned not null auto_increment primary key, c varchar(255) not null diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index d96d4c0db3c..b5c80d9482f 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -110,11 +110,29 @@ init_functions(IO_CACHE* info, enum cache_type type) } } - /* - ** if cachesize == 0 then use default cachesize (from s-file) - ** if file == -1 then real_open_cached_file() will be called. - ** returns 0 if ok - */ + +/* + Initialize an IO_CACHE object + + SYNOPSOS + init_io_cache() + info cache handler to initialize + file File that should be associated to to the handler + If == -1 then real_open_cached_file() + will be called when it's time to open file. + cachesize Size of buffer to allocate for read/write + If == 0 then use my_default_record_cache_size + type Type of cache + seek_offset Where cache should start reading/writing + use_async_io Set to 1 of we should use async_io (if avaiable) + cache_myflags Bitmap of differnt flags + MY_WME | MY_FAE | MY_NABP | MY_FNABP | + MY_DONT_CHECK_FILESIZE + + RETURN + 0 ok + # error +*/ int init_io_cache(IO_CACHE *info, File file, uint cachesize, enum cache_type type, my_off_t seek_offset, @@ -127,7 +145,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, (ulong) info, (int) type, (ulong) seek_offset)); info->file= file; - info->type=type; + info->type= 0; /* Don't set it until mutex are created */ info->pos_in_file= seek_offset; info->pre_close = info->pre_read = info->post_read = 0; info->arg = 0; @@ -138,9 +156,8 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, info->share=0; #endif - if (!cachesize) - if (! (cachesize= my_default_record_cache_size)) - DBUG_RETURN(1); /* No cache requested */ + if (!cachesize && !(cachesize= my_default_record_cache_size)) + DBUG_RETURN(1); /* No cache requested */ min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2; if (type == READ_CACHE || type == SEQ_READ_APPEND) { /* Assume file isn't growing */ @@ -201,6 +218,13 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, pthread_mutex_init(&info->append_buffer_lock,MY_MUTEX_INIT_FAST); #endif } +#if defined(SAFE_MUTEX) && defined(THREAD) + else + { + /* Clear mutex so that safe_mutex will notice that it's not initialized */ + bzero((char*) &info->append_buffer_lock, sizeof(info)); + } +#endif if (type == WRITE_CACHE) info->write_end= @@ -211,6 +235,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, /* End_of_file may be changed by user later */ info->end_of_file= end_of_file; info->error=0; + info->type= type; init_functions(info,type); #ifdef HAVE_AIOWAIT if (use_async_io && ! my_disable_async_io) @@ -1142,6 +1167,22 @@ int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) DBUG_RETURN(0); } +/* + Free an IO_CACHE object + + SYNOPSOS + end_io_cache() + info IO_CACHE Handle to free + + NOTES + It's currently safe to call this if one has called io_cache_init() + on the 'info' object, even if io_cache_init() failed. + This function is also safe to call twice with the same handle. + + RETURN + 0 ok + # Error +*/ int end_io_cache(IO_CACHE *info) { @@ -1164,7 +1205,10 @@ int end_io_cache(IO_CACHE *info) #endif if ((pre_close=info->pre_close)) + { (*pre_close)(info); + info->pre_close= 0; + } if (info->alloced_buffer) { info->alloced_buffer=0; diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 474334efcc0..8ebe5be22e8 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -97,10 +97,12 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line) int error; if (!mp->file) { - fprintf(stderr,"safe_mutex: Trying to lock unitialized mutex at %s, line %d", file, line); + fprintf(stderr, + "safe_mutex: Trying to lock unitialized mutex at %s, line %d\n", + file, line); fflush(stderr); abort(); - } + } pthread_mutex_lock(&mp->global); if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread)) @@ -262,6 +264,14 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) { int error=0; + if (!mp->file) + { + fprintf(stderr, + "safe_mutex: Trying to destroy unitialized mutex at %s, line %d\n", + file, line); + fflush(stderr); + abort(); + } if (mp->count != 0) { fprintf(stderr,"safe_mutex: Trying to destroy a mutex that was locked at %s, line %d at %s, line %d\n", diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 5481b1b266f..c61e6800cfa 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -440,7 +440,6 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, char filePath[FN_REFLEN]; TABLE_LIST *tot_list=0, **tot_list_next; List raid_dirs; - DBUG_ENTER("mysql_rm_known_files"); DBUG_PRINT("enter",("path: %s", org_path)); @@ -516,17 +515,24 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, deleted++; } } + List_iterator it(raid_dirs); + String *dir; + if (thd->killed || (tot_list && mysql_rm_table_part2_with_lock(thd, tot_list, 1, 0, 1))) { + /* Free memory for allocated raid dirs */ + while ((dir= it++)) + delete dir; my_dirend(dirp); DBUG_RETURN(-1); } - List_iterator it(raid_dirs); - String *dir; while ((dir= it++)) + { if (rmdir(dir->c_ptr()) < 0) found_other_files++; + delete dir; + } my_dirend(dirp); /* From f8e9f31e933c9fb36fb6be55a5984d7fb23d836f Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 21 Nov 2003 17:01:35 +0200 Subject: [PATCH 30/89] os0file.c: Fix the OS error 2 reported by Miguel and Mark in Windows crash recovery: a * had been forgotten from the path in directory scanning ha_innodb.cc: Set default directory in fil0fil.c right if we are running the Embedded Server Library, where the default dir of the process is not necessarily the MySQL datadir --- innobase/os/os0file.c | 2 +- sql/ha_innodb.cc | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index b6d4eba9f9b..e5dd8679163 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -409,7 +409,7 @@ os_file_opendir( ut_a(strlen(dirname) < OS_FILE_MAX_PATH); strcpy(path, dirname); - strcpy(path + strlen(path), "\\"); + strcpy(path + strlen(path), "\\*"); /* Note that in Windows opening the 'directory stream' also retrieves the first entry in the directory. Since it is '.', that is no problem, diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index f79c5b55927..8a3b1b7f4b6 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -75,6 +75,7 @@ extern "C" { #include "../innobase/include/btr0cur.h" #include "../innobase/include/btr0btr.h" #include "../innobase/include/fsp0fsp.h" +#include "../innobase/include/fil0fil.h" } #define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */ @@ -738,6 +739,7 @@ innobase_init(void) if (mysql_embedded) { default_path = mysql_real_data_home; + fil_path_to_mysql_datadir = mysql_real_data_home; } else { /* It's better to use current lib, to keep paths short */ current_dir[0] = FN_CURLIB; From 47812674a56379626f45e144b094f34d57bbcd9b Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Fri, 21 Nov 2003 19:16:19 +0300 Subject: [PATCH 31/89] added 'explicit' keyword to Bitmap constructor --- sql/ha_isammrg.cc | 2 +- sql/sql_bitmap.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/ha_isammrg.cc b/sql/ha_isammrg.cc index 94e394e7665..9915c182e26 100644 --- a/sql/ha_isammrg.cc +++ b/sql/ha_isammrg.cc @@ -157,7 +157,7 @@ void ha_isammrg::info(uint flag) deleted = (ha_rows) info.deleted; data_file_length=info.data_file_length; errkey = info.errkey; - table->keys_in_use=0; // No keys yet + table->keys_in_use.clear_all(); // No keys yet table->db_options_in_use = info.options; mean_rec_length=info.reclength; block_size=0; diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index e5e50c180bf..0274cd700da 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -29,7 +29,7 @@ template class Bitmap public: Bitmap() { init(); } Bitmap(Bitmap& from) { *this=from; } - Bitmap(uint prefix_to_set) { init(prefix_to_set); } + explicit Bitmap(uint prefix_to_set) { init(prefix_to_set); } void init() { bitmap_init(&map, buffer, default_width, 0); } void init(uint prefix_to_set) { init(); set_prefix(prefix_to_set); } uint length() const { return default_width; } @@ -91,7 +91,7 @@ template <> class Bitmap<64> ulonglong map; public: Bitmap<64>() { } - Bitmap<64>(uint prefix_to_set) { set_prefix(prefix_to_set); } + explicit Bitmap<64>(uint prefix_to_set) { set_prefix(prefix_to_set); } void init() { } void init(uint prefix_to_set) { set_prefix(prefix_to_set); } uint length() const { return 64; } From 7a1bb450a67233933884f6a6818f915b747723e3 Mon Sep 17 00:00:00 2001 From: "paul@teton.kitebird.com" <> Date: Fri, 21 Nov 2003 12:35:33 -0600 Subject: [PATCH 32/89] Change word order of a few PROCESSLIST messages to correspond to order used in START SLAVE syntax. --- sql/log.cc | 2 +- sql/slave.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 27c7c64f9c8..c32e37cd86a 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1692,7 +1692,7 @@ void MYSQL_LOG:: wait_for_update(THD* thd, bool master_or_slave) const char* old_msg = thd->enter_cond(&update_cond, &LOCK_log, master_or_slave ? "Has read all relay log; waiting for \ -the I/O slave thread to update it" : +the slave I/O thread to update it" : "Has sent all binlog to slave; \ waiting for binlog to be updated"); pthread_cond_wait(&update_cond, &LOCK_log); diff --git a/sql/slave.cc b/sql/slave.cc index 329324efa3d..ec58e5215d8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1579,7 +1579,7 @@ static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli) save_proc_info= thd->enter_cond(&rli->log_space_cond, &rli->log_space_lock, "\ -Waiting for the SQL slave thread to free enough relay log space"); +Waiting for the slave SQL thread to free enough relay log space"); while (rli->log_space_limit < rli->log_space_total && !(slave_killed=io_slave_killed(thd,mi)) && !rli->ignore_log_space_limit) @@ -2291,7 +2291,7 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, DBUG_PRINT("info",("Waiting for master update")); const char* msg = thd->enter_cond(&data_cond, &data_lock, - "Waiting for the SQL slave thread to \ + "Waiting for the slave SQL thread to \ advance position"); /* We are going to pthread_cond_(timed)wait(); if the SQL thread stops it From d87494c5acf1b0e03cb3848b3e588c1d0259b44f Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Sat, 22 Nov 2003 03:21:40 +0200 Subject: [PATCH 33/89] Don't flush cur_log (relay log) on flush_relay_log_info becasue this crashes the server if cur_log is 'hot' and the io_thread has changed log file. Updated project files for windows Made rpl_change_master.test portable Ensure that mutex are not freed if not initilized --- VC++Files/client/mysql.dsp | 6 ++--- VC++Files/comp_err/comp_err.dsp | 3 ++- VC++Files/innobase/innobase.dsp | 6 ++--- .../libmysqld/examples/test_libmysqld.dsp | 19 ++++++++-------- VC++Files/libmysqld/libmysqld.dsp | 5 +++-- VC++Files/myisamchk/myisamchk.dsp | 10 ++++----- VC++Files/myisamlog/myisamlog.dsp | 3 ++- VC++Files/myisampack/myisampack.dsp | 9 ++++---- VC++Files/mysqlmanager/MySqlManager.dsp | 4 ++-- VC++Files/mysqlshutdown/mysqlshutdown.dsp | 6 ++--- VC++Files/mysys/mysys.dsp | 4 ++-- libmysql/libmysql.c | 4 ---- mysql-test/r/rpl_change_master.result | 4 ++-- mysql-test/t/rpl_change_master.test | 2 ++ sql-common/client.c | 6 ----- sql/ha_innodb.cc | 22 ++++++++++--------- sql/hostname.cc | 12 ++++++---- sql/slave.cc | 9 ++++---- 18 files changed, 68 insertions(+), 66 deletions(-) diff --git a/VC++Files/client/mysql.dsp b/VC++Files/client/mysql.dsp index 2e9e1729bed..4f2cbbb5614 100644 --- a/VC++Files/client/mysql.dsp +++ b/VC++Files/client/mysql.dsp @@ -42,8 +42,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /WX /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -69,7 +69,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX +# SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/VC++Files/comp_err/comp_err.dsp b/VC++Files/comp_err/comp_err.dsp index deaf0627262..d9fc740ced8 100644 --- a/VC++Files/comp_err/comp_err.dsp +++ b/VC++Files/comp_err/comp_err.dsp @@ -38,7 +38,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCSN" /D "DBUG_OFF" /D "_WINDOWS" /D "__WIN__" /D "_MT" /FR /YX /FD /c +# ADD CPP /nologo /G6 /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCSN" /D "DBUG_OFF" /D "_WINDOWS" /D "__WIN__" /D "_MT" /YX /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE RSC /l 0x416 /d "NDEBUG" # ADD RSC /l 0x416 /d "NDEBUG" BSC32=bscmake.exe diff --git a/VC++Files/innobase/innobase.dsp b/VC++Files/innobase/innobase.dsp index 9985ec7e454..42d7001bdd4 100644 --- a/VC++Files/innobase/innobase.dsp +++ b/VC++Files/innobase/innobase.dsp @@ -43,8 +43,8 @@ RSC=rc.exe # PROP Intermediate_Dir "debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "__NT__" /D "WIN32" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /GX /Z7 /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /FD /c -# SUBTRACT CPP /YX +# ADD CPP /nologo /G6 /MTd /W3 /GX /Z7 /Od /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /FD /c +# SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x416 /d "NDEBUG" # ADD RSC /l 0x416 /d "NDEBUG" BSC32=bscmake.exe @@ -68,7 +68,7 @@ LIB32=xilink6.exe -lib # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /YX /FD /c # ADD CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /FD /c -# SUBTRACT CPP /YX +# SUBTRACT CPP /WX /Fr /YX # ADD BASE RSC /l 0x416 /d "NDEBUG" # ADD RSC /l 0x416 /d "NDEBUG" BSC32=bscmake.exe diff --git a/VC++Files/libmysqld/examples/test_libmysqld.dsp b/VC++Files/libmysqld/examples/test_libmysqld.dsp index 0f4b09d963e..6707b8cd8ee 100644 --- a/VC++Files/libmysqld/examples/test_libmysqld.dsp +++ b/VC++Files/libmysqld/examples/test_libmysqld.dsp @@ -7,24 +7,24 @@ CFG=test_libmysqld - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "test_libmysqld.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "test_libmysqld.mak" CFG="test_libmysqld - Win32 Release" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE !MESSAGE "test_libmysqld - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE +!MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 @@ -38,13 +38,14 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /I "../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "DBUG_OFF" /FR /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /I "../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "DBUG_OFF" /YX /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE RSC /l 0x416 /d "NDEBUG" # ADD RSC /l 0x416 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBCMTD" /out:"Release/mysql-server.exe" # Begin Target diff --git a/VC++Files/libmysqld/libmysqld.dsp b/VC++Files/libmysqld/libmysqld.dsp index 953761be297..c753b0d8fe7 100644 --- a/VC++Files/libmysqld/libmysqld.dsp +++ b/VC++Files/libmysqld/libmysqld.dsp @@ -43,7 +43,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBMYSQLD_EXPORTS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../sql" /I "../regex" /I "../bdb/build_win32" /I "../zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "DBUG_OFF" /D "USE_TLS" /D "__WIN__" /FR /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../sql" /I "../regex" /I "../bdb/build_win32" /I "../zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "DBUG_OFF" /D "USE_TLS" /D "__WIN__" /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x416 /d "NDEBUG" @@ -70,6 +71,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBMYSQLD_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MT /W3 /Z7 /Od /I "../include" /I "../sql" /I "../regex" /I "../bdb/build_win32" /I "../zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_BERKELEY_DB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "USE_TLS" /D "__WIN__" /FD /GZ /c +# SUBTRACT CPP /Fr # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x416 /d "_DEBUG" @@ -186,7 +188,6 @@ SOURCE=..\sql\item_create.cpp # Begin Source File SOURCE=..\sql\item_func.cpp -# ADD CPP /I "../zlib" # End Source File # Begin Source File diff --git a/VC++Files/myisamchk/myisamchk.dsp b/VC++Files/myisamchk/myisamchk.dsp index 0c8e7c00f1a..000e1c11215 100644 --- a/VC++Files/myisamchk/myisamchk.dsp +++ b/VC++Files/myisamchk/myisamchk.dsp @@ -25,7 +25,7 @@ CFG=myisamchk - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "myisamchk - Win32 Release" @@ -42,14 +42,14 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FR /FD /c -# SUBTRACT CPP /YX +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib setargv.obj /nologo /subsystem:console /machine:I386 /out:"../client_release/myisamchk.exe" @@ -74,7 +74,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/myisamchk.exe" /pdbtype:sept diff --git a/VC++Files/myisamlog/myisamlog.dsp b/VC++Files/myisamlog/myisamlog.dsp index 6df65add63c..f251712127b 100644 --- a/VC++Files/myisamlog/myisamlog.dsp +++ b/VC++Files/myisamlog/myisamlog.dsp @@ -42,7 +42,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FR /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe diff --git a/VC++Files/myisampack/myisampack.dsp b/VC++Files/myisampack/myisampack.dsp index cdfc44331ea..d4d05ec4591 100644 --- a/VC++Files/myisampack/myisampack.dsp +++ b/VC++Files/myisampack/myisampack.dsp @@ -25,7 +25,7 @@ CFG=myisampack - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "myisampack - Win32 Release" @@ -42,13 +42,14 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FR /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib setargv.obj /nologo /subsystem:console /machine:I386 @@ -73,7 +74,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept diff --git a/VC++Files/mysqlmanager/MySqlManager.dsp b/VC++Files/mysqlmanager/MySqlManager.dsp index c6108acfc8f..7f92e091904 100644 --- a/VC++Files/mysqlmanager/MySqlManager.dsp +++ b/VC++Files/mysqlmanager/MySqlManager.dsp @@ -43,8 +43,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /G6 /MT /W3 /GX /O1 /I "../include" /D "NDEBUG" /D "DBUG_OFF" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX /Yc /Yu +# ADD CPP /nologo /G6 /MT /W3 /GX /O2 /I "../include" /D "NDEBUG" /D "DBUG_OFF" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr /YX /Yc /Yu # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" diff --git a/VC++Files/mysqlshutdown/mysqlshutdown.dsp b/VC++Files/mysqlshutdown/mysqlshutdown.dsp index d4dd389e99d..f1ea7c7d934 100644 --- a/VC++Files/mysqlshutdown/mysqlshutdown.dsp +++ b/VC++Files/mysqlshutdown/mysqlshutdown.dsp @@ -44,7 +44,7 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /G6 /W3 /O2 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX +# SUBTRACT CPP /WX /Fr /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -72,8 +72,8 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /W3 /Z7 /O2 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX +# ADD CPP /nologo /G6 /W3 /Z7 /Od /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# SUBTRACT CPP /Fr /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index 3f9d37b395f..1ec566b5216 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../zlib" /D "NDEBUG" /D "DBUG_OFF" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX +# SUBTRACT CPP /WX /Fr /YX # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -117,7 +117,7 @@ SOURCE=.\array.c !ELSEIF "$(CFG)" == "mysys - Win32 Debug" -# ADD CPP /FR +# SUBTRACT CPP /Fr !ELSEIF "$(CFG)" == "mysys - Win32 Max" diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 980cc2bef4c..a8027742a0f 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -15,10 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64) -#include -#include -#endif #include #include #include diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result index a886ad9c304..546a0ee2710 100644 --- a/mysql-test/r/rpl_change_master.result +++ b/mysql-test/r/rpl_change_master.result @@ -16,11 +16,11 @@ n 1 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root 9306 1 master-bin.000001 273 slave-relay-bin.000002 258 master-bin.000001 No No 0 0 214 317 None 0 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 273 slave-relay-bin.000002 258 master-bin.000001 No No 0 0 214 317 None 0 No # change master to master_user='root'; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root 9306 1 master-bin.000001 214 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 214 4 None 0 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 214 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 214 4 None 0 No # select release_lock("a"); release_lock("a") 1 diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test index 33fc2d75dd3..94f044d5413 100644 --- a/mysql-test/t/rpl_change_master.test +++ b/mysql-test/t/rpl_change_master.test @@ -11,9 +11,11 @@ connection slave; sleep 3; # can't sync_with_master as we should be blocked stop slave; select * from t1; +--replace_result $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 33 # show slave status; change master to master_user='root'; +--replace_result $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 33 # show slave status; # Will restart from after the values(2), which is bug diff --git a/sql-common/client.c b/sql-common/client.c index cb0d8230eb8..878a8beacba 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -55,12 +55,6 @@ my_bool net_flush(NET *net); #else /*EMBEDDED_LIBRARY*/ #define CLI_MYSQL_REAL_CONNECT mysql_real_connect #endif /*EMBEDDED_LIBRARY*/ - -#if !defined(MYSQL_SERVER) && (defined(__WIN__) || defined(_WIN32) || defined(_WIN64)) - -#include -#include -#endif /* !defined(MYSQL_SERVER) && (defined(__WIN__) ... */ #include #include #include diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index f79c5b55927..671c62d5cf8 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -46,6 +46,7 @@ InnoDB */ #include "ha_innodb.h" pthread_mutex_t innobase_mutex; +bool innodb_inited= 0; /* Store MySQL definition of 'byte': in Linux it is char while InnoDB uses unsigned char; the header univ.i which we include next defines @@ -898,6 +899,7 @@ innobase_init(void) (void) hash_init(&innobase_open_tables,system_charset_info, 32, 0, 0, (hash_get_key) innobase_get_key, 0, 0); pthread_mutex_init(&innobase_mutex, MY_MUTEX_INIT_FAST); + 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 @@ -925,21 +927,21 @@ innobase_end(void) /*==============*/ /* out: TRUE if error */ { - int err; + int err= 0; DBUG_ENTER("innobase_end"); - err = innobase_shutdown_for_mysql(); - hash_free(&innobase_open_tables); - my_free(internal_innobase_data_file_path,MYF(MY_ALLOW_ZERO_PTR)); - pthread_mutex_destroy(&innobase_mutex); - - if (err != DB_SUCCESS) { - - DBUG_RETURN(1); + if (innodb_inited) + { + innodb_inited= 0; + if (innobase_shutdown_for_mysql() != DB_SUCCESS) + err= 1; + hash_free(&innobase_open_tables); + my_free(internal_innobase_data_file_path,MYF(MY_ALLOW_ZERO_PTR)); + pthread_mutex_destroy(&innobase_mutex); } - DBUG_RETURN(0); + DBUG_RETURN(err); } /******************************************************************** diff --git a/sql/hostname.cc b/sql/hostname.cc index 5c4bde99256..c9cb2a43963 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -61,23 +61,27 @@ bool hostname_cache_init() { host_entry tmp; uint offset= (uint) ((char*) (&tmp.ip) - (char*) &tmp); - (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW); - if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE, offset, sizeof(struct in_addr),NULL, (hash_free_key) free, &my_charset_latin1))) return 1; hostname_cache->clear(); + (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW); return 0; } void hostname_cache_free() { - (void) pthread_mutex_destroy(&LOCK_hostname); - delete hostname_cache; + if (hostname_cache) + { + (void) pthread_mutex_destroy(&LOCK_hostname); + delete hostname_cache; + hostname_cache= 0; + } } + static void add_hostname(struct in_addr *in,const char *name) { if (!(specialflag & SPECIAL_NO_HOST_CACHE)) diff --git a/sql/slave.cc b/sql/slave.cc index 329324efa3d..6d261a97dcd 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3122,9 +3122,10 @@ slave_begin: Reset errors for a clean start (otherwise, if the master is idle, the SQL thread may execute no Query_log_event, so the error will remain even though there's no problem anymore). Do not reset the master timestamp - (imagine the slave has caught everything, the STOP SLAVE and START SLAVE: as - we are not sure that we are going to receive a query, we want to remember - the last master timestamp (to say how many seconds behind we are now. + (imagine the slave has caught everything, the STOP SLAVE and START SLAVE: + as we are not sure that we are going to receive a query, we want to + remember the last master timestamp (to say how many seconds behind we are + now. But the master timestamp is reset by RESET SLAVE & CHANGE MASTER. */ clear_slave_error(rli); @@ -3797,8 +3798,6 @@ bool flush_relay_log_info(RELAY_LOG_INFO* rli) error=1; if (flush_io_cache(file)) error=1; - if (flush_io_cache(rli->cur_log)) // QQ Why this call ? - error=1; return error; } From 625371f306fbbf87d6e2aad247c912d232d39665 Mon Sep 17 00:00:00 2001 From: "dlenev@dlenev.mshome" <> Date: Sun, 23 Nov 2003 00:48:18 +0300 Subject: [PATCH 34/89] Fix for bug #1500 "Server crash with mysql_prepare" We treat Item_param whose value is not set as non-const. This allows us to avoid use of Item_param's value (not yet existing) in those fix_fields and fix_length_and_dec that do calculations if their Items arguments are const. So we can call fix_fields for such items from mysql_prepare safely. --- sql/item.cc | 7 ++- sql/item.h | 19 ++++++++ sql/item_func.cc | 13 +++-- tests/client_test.c | 112 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 5 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index d76ab529db5..2172b0f5c29 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -512,7 +512,7 @@ String *Item_null::val_str(String *str) void Item_param::set_null() { DBUG_ENTER("Item_param::set_null"); - maybe_null= null_value= 1; + maybe_null= null_value= value_is_set= 1; DBUG_VOID_RETURN; } @@ -521,6 +521,7 @@ void Item_param::set_int(longlong i) DBUG_ENTER("Item_param::set_int"); int_value= (longlong)i; item_type= INT_ITEM; + value_is_set= 1; DBUG_PRINT("info", ("integer: %lld", int_value)); DBUG_VOID_RETURN; } @@ -530,6 +531,7 @@ void Item_param::set_double(double value) DBUG_ENTER("Item_param::set_double"); real_value=value; item_type= REAL_ITEM; + value_is_set= 1; DBUG_PRINT("info", ("double: %lg", real_value)); DBUG_VOID_RETURN; } @@ -540,6 +542,7 @@ void Item_param::set_value(const char *str, uint length) DBUG_ENTER("Item_param::set_value"); str_value.copy(str,length,default_charset()); item_type= STRING_ITEM; + value_is_set= 1; DBUG_PRINT("info", ("string: %s", str_value.ptr())); DBUG_VOID_RETURN; } @@ -561,6 +564,7 @@ void Item_param::set_time(TIME *tm, timestamp_type type) item_is_time= true; item_type= STRING_ITEM; + value_is_set= 1; } @@ -568,6 +572,7 @@ void Item_param::set_longdata(const char *str, ulong length) { str_value.append(str,length); long_data_supplied= 1; + value_is_set= 1; } diff --git a/sql/item.h b/sql/item.h index 8b35705f191..1e62e863ab7 100644 --- a/sql/item.h +++ b/sql/item.h @@ -173,7 +173,17 @@ public: virtual cond_result eq_cmp_result() const { return COND_OK; } inline uint float_length(uint decimals_par) const { return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;} + /* + Returns true if this is constant (during query execution, i.e. its value + will not change until next fix_fields) and its value is known. + */ virtual bool const_item() const { return used_tables() == 0; } + /* + Returns true if this is constant but its value may be not known yet. + (Can be used for parameters of prep. stmts or of stored procedures.) + */ + virtual bool const_during_execution() const + { return (used_tables() & ~PARAM_TABLE_BIT) == 0; } virtual void print(String *str_arg) { str_arg->append(full_name()); } void print_item_w_name(String *); virtual void update_used_tables() {} @@ -318,6 +328,7 @@ public: class Item_param :public Item { public: + bool value_is_set; longlong int_value; double real_value; TIME ltime; @@ -336,6 +347,7 @@ public: item_result_type = STRING_RESULT; item_is_time= false; long_data_supplied= false; + value_is_set= 0; } enum Type type() const { return item_type; } double val(); @@ -363,6 +375,13 @@ public: String *query_val_str(String *str); enum_field_types field_type() const { return MYSQL_TYPE_STRING; } Item *new_item() { return new Item_param(pos_in_query); } + /* + If value for parameter was not set we treat it as non-const + so noone will use parameters value in fix_fields still + parameter is constant during execution. + */ + virtual table_map used_tables() const + { return value_is_set ? (table_map)0 : PARAM_TABLE_BIT; } void print(String *str) { str->append('?'); } }; diff --git a/sql/item_func.cc b/sql/item_func.cc index c42019a9fbb..0bcbe742eee 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2713,7 +2713,8 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) modifications to find_best and auto_close as complement to auto_init code above. */ - if (Item_func::fix_fields(thd, tlist, ref) || !args[0]->const_item()) + if (Item_func::fix_fields(thd, tlist, ref) || + !args[0]->const_during_execution()) { my_error(ER_WRONG_ARGUMENTS,MYF(0),"AGAINST"); return 1; @@ -2727,11 +2728,15 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) args[i]= item= *((Item_ref *)item)->ref; if (item->type() != Item::FIELD_ITEM) key=NO_SUCH_KEY; - used_tables_cache|=item->used_tables(); } - /* check that all columns come from the same table */ - if (my_count_bits(used_tables_cache) != 1) + /* + Check that all columns come from the same table. + We've already checked that columns in MATCH are fields so + PARAM_TABLE_BIT can only appear from AGAINST argument. + */ + if ((used_tables_cache & ~PARAM_TABLE_BIT) != item->used_tables()) key=NO_SUCH_KEY; + if (key == NO_SUCH_KEY && !(flags & FT_BOOL)) { my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH"); diff --git a/tests/client_test.c b/tests/client_test.c index 517cac39d1b..637f6c4ede1 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -7953,6 +7953,117 @@ static void test_ts() } } +/* + Test for bug #1500. +*/ +static void test_bug1500() +{ + MYSQL_STMT *stmt; + MYSQL_BIND bind[3]; + int rc; + long int_data[3]= {2,3,4}; + char *data; + + myheader("test_bug1500"); + + rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_bg1500"); + myquery(rc); + + rc= mysql_query(mysql,"CREATE TABLE test_bg1500 (i INT)"); + myquery(rc); + + rc= mysql_query(mysql,"INSERT INTO test_bg1500 VALUES (1),(2)"); + myquery(rc); + + rc= mysql_commit(mysql); + myquery(rc); + + stmt= mysql_prepare(mysql,"SELECT i FROM test_bg1500 WHERE i IN (?,?,?)",44); + mystmt_init(stmt); + verify_param_count(stmt,3); + + bind[0].buffer= (char *)int_data; + bind[0].buffer_type= FIELD_TYPE_LONG; + bind[0].is_null= 0; + bind[2]= bind[1]= bind[0]; + bind[1].buffer= (char *)(int_data + 1); + bind[2].buffer= (char *)(int_data + 2); + + rc= mysql_bind_param(stmt, bind); + mystmt(stmt,rc); + + rc= mysql_execute(stmt); + mystmt(stmt,rc); + + assert(1 == my_process_stmt_result(stmt)); + + /* FIXME If we comment out next string server will crash :( */ + mysql_stmt_close(stmt); + + rc= mysql_query(mysql,"DROP TABLE test_bg1500"); + myquery(rc); + + rc= mysql_query(mysql,"CREATE TABLE test_bg1500 (s VARCHAR(25), FULLTEXT(s))"); + myquery(rc); + + rc= mysql_query(mysql, + "INSERT INTO test_bg1500 VALUES ('Gravedigger'), ('Greed'),('Hollow Dogs')"); + myquery(rc); + + rc= mysql_commit(mysql); + myquery(rc); + + stmt= mysql_prepare(mysql, + "SELECT s FROM test_bg1500 WHERE MATCH (s) AGAINST (?)",53); + mystmt_init(stmt); + + verify_param_count(stmt,1); + + data= "Dogs"; + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= data; + bind[0].buffer_length= strlen(data); + bind[0].is_null= 0; + bind[0].length= 0; + + rc= mysql_bind_param(stmt, bind); + mystmt(stmt,rc); + + rc= mysql_execute(stmt); + mystmt(stmt,rc); + + assert(1 == my_process_stmt_result(stmt)); + + /* + FIXME If we comment out next string server will crash too :( + This is another manifestation of bug #1663 + */ + mysql_stmt_close(stmt); + + /* This should work too */ + stmt= mysql_prepare(mysql, + "SELECT s FROM test_bg1500 WHERE MATCH (s) AGAINST (CONCAT(?,'digger'))", 70); + mystmt_init(stmt); + + verify_param_count(stmt,1); + + data= "Grave"; + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= data; + bind[0].buffer_length= strlen(data); + bind[0].is_null= 0; + bind[0].length= 0; + + rc= mysql_bind_param(stmt, bind); + mystmt(stmt,rc); + + rc= mysql_execute(stmt); + mystmt(stmt,rc); + + assert(1 == my_process_stmt_result(stmt)); + + mysql_stmt_close(stmt); +} /* Read and parse arguments and MySQL options from my.cnf @@ -8194,6 +8305,7 @@ int main(int argc, char **argv) test_ts(); /* test for timestamp BR#819 */ test_bug1115(); /* BUG#1115 */ test_bug1180(); /* BUG#1180 */ + test_bug1500(); /* BUG#1500 */ test_bug1644(); /* BUG#1644 */ end_time= time((time_t *)0); From 7191ea0ae3281d75c50ba6e5d4c5cc86dd1f906c Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Sun, 23 Nov 2003 02:01:15 +0200 Subject: [PATCH 35/89] Fixed UNION fields type/length detecting --- mysql-test/r/union.result | 209 ++++++++++++++++++++++++++++++++++- mysql-test/t/union.test | 82 ++++++++++++++ sql/field.h | 48 +++++++++ sql/item.cc | 121 ++++++++++++++++++++- sql/item.h | 32 +++++- sql/item_subselect.cc | 49 ++------- sql/mysql_priv.h | 5 +- sql/sql_base.cc | 14 --- sql/sql_class.h | 1 + sql/sql_derived.cc | 152 ++++++++++++-------------- sql/sql_lex.h | 11 +- sql/sql_parse.cc | 2 +- sql/sql_prepare.cc | 2 +- sql/sql_select.cc | 222 +++++++++++++++++++++++++------------- sql/sql_select.h | 2 +- sql/sql_union.cc | 162 ++++++++++++++-------------- sql/sql_update.cc | 2 +- 17 files changed, 799 insertions(+), 317 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 00eddd596cf..cf5920481b2 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -53,7 +53,7 @@ select 0,'#' union select a,b from t1 union all select a,b from t2 union select 4 d 5 f 6 e -7 g +7 gg select a,b from t1 union select a,b from t1; a b 1 a @@ -449,10 +449,10 @@ INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1", SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master; id_master id text1 text2 1 1 NULL ABCDE -1 1 bar1 -1 2 bar2 +1 1 foo1 bar1 +1 2 foo2 bar2 1 3 NULL bar3 -1 4 bar4 +1 4 foo4 bar4 SELECT 1 AS id_master, 1 AS id, 'ABCDE' AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master; id_master id text1 text2 1 1 ABCDE ABCDE @@ -523,3 +523,204 @@ pla_id matintnum 105 c 0 0 drop table t1, t2; +create table t1 SELECT "a" as a UNION select "aa" as a; +select * from t1; +a +a +aa +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(2) NOT NULL default '' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT 12 as a UNION select "aa" as a; +select * from t1; +a +12 +aa +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(2) NOT NULL default '' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT 12 as a UNION select 12.2 as a; +select * from t1; +a +12.0 +12.2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double(4,1) NOT NULL default '0.0' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t2 (it1 tinyint, it2 tinyint not null, i int not null, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob); +insert into t2 values (NULL, 1, 3, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest'); +create table t1 SELECT it2 from t2 UNION select it1 from t2; +select * from t1; +it2 +1 +NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `it2` tinyint(4) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT it2 from t2 UNION select i from t2; +select * from t1; +it2 +1 +3 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `it2` int(11) NOT NULL default '0' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT i from t2 UNION select f from t2; +select * from t1; +i +3 +1.5 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` float default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT f from t2 UNION select d from t2; +select * from t1; +f +1.5 +2.5 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` double default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT f from t2 UNION select y from t2; +select * from t1; +f +1.5 +1972 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` double default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT f from t2 UNION select da from t2; +select * from t1; +f +1.5 +1972-10-22 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` char(12) binary default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT y from t2 UNION select da from t2; +select * from t1; +y +1972 +1972-10-22 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `y` char(10) binary default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT y from t2 UNION select dt from t2; +select * from t1; +y +1972 +1972-10-22 11:50:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `y` char(19) binary default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT da from t2 UNION select dt from t2; +select * from t1; +da +1972-10-22 00:00:00 +1972-10-22 11:50:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `da` datetime default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT dt from t2 UNION select sc from t2; +select * from t1; +dt +1972-10-22 11:50:00 +testc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dt` char(19) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT dt from t2 UNION select sv from t2; +select * from t1; +dt +1972-10-22 11:50:00 +testv +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dt` char(19) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT sc from t2 UNION select sv from t2; +select * from t1; +sc +testc +testv +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `sc` varchar(10) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT dt from t2 UNION select b from t2; +select * from t1; +dt +1972-10-22 11:50:00 +tetetetetest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dt` blob +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT sv from t2 UNION select b from t2; +select * from t1; +sv +testv +tetetetetest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `sv` blob +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2; +select * from t1; +i +3 +2.5 +tetetetetest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` blob +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1,t2; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 3cfdc14b0b8..af511d18ecc 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -302,3 +302,85 @@ insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd' insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105); SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id union SELECT 0, 0; drop table t1, t2; + +# +# types conversions +# + + +create table t1 SELECT "a" as a UNION select "aa" as a; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT 12 as a UNION select "aa" as a; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT 12 as a UNION select 12.2 as a; +select * from t1; +show create table t1; +drop table t1; + +create table t2 (it1 tinyint, it2 tinyint not null, i int not null, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob); +insert into t2 values (NULL, 1, 3, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest'); + +create table t1 SELECT it2 from t2 UNION select it1 from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT it2 from t2 UNION select i from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT i from t2 UNION select f from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT f from t2 UNION select d from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT f from t2 UNION select y from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT f from t2 UNION select da from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT y from t2 UNION select da from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT y from t2 UNION select dt from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT da from t2 UNION select dt from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT dt from t2 UNION select sc from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT dt from t2 UNION select sv from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT sc from t2 UNION select sv from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT dt from t2 UNION select b from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT sv from t2 UNION select b from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2; +select * from t1; +show create table t1; +drop table t1,t2; diff --git a/sql/field.h b/sql/field.h index 692e64d1146..ef6920f4d89 100644 --- a/sql/field.h +++ b/sql/field.h @@ -230,6 +230,24 @@ public: virtual bool has_charset(void) const { return FALSE; } virtual void set_charset(CHARSET_INFO *charset) { } void set_warning(const unsigned int level, const unsigned int code); + /* + number which describe preferences of field type converion, + for example, if we have int and float, float is prefered as more general + + ennumiration begins from: + 100 for int types + 300 for float point + 500 time/date + 700 string + */ + virtual uint convert_order()= 0; + /* + Is this type is compatible with given + (given can be stored in it) + Should take care only of types 'less' then current + */ + virtual bool convert_order_compatible(uint order) { return 0; } + friend bool reopen_table(THD *,struct st_table *,bool); friend int cre_myisam(my_string name, register TABLE *form, uint options, ulonglong auto_increment_value); @@ -334,6 +352,7 @@ public: void overflow(bool negative); bool zero_pack() const { return 0; } void sql_type(String &str) const; + uint convert_order() { return 130; } }; @@ -369,6 +388,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 1; } void sql_type(String &str) const; + uint convert_order() { return 100; } }; @@ -404,6 +424,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 2; } void sql_type(String &str) const; + uint convert_order() { return 101; } }; @@ -434,6 +455,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 3; } void sql_type(String &str) const; + uint convert_order() { return 102; } }; @@ -469,6 +491,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 4; } void sql_type(String &str) const; + uint convert_order() { return 103; } }; @@ -507,6 +530,7 @@ public: uint32 pack_length() const { return 8; } void sql_type(String &str) const; bool store_for_compare() { return 1; } + uint convert_order() { return 104; } }; #endif @@ -540,6 +564,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return sizeof(float); } void sql_type(String &str) const; + uint convert_order() { return 300; } }; @@ -573,6 +598,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return sizeof(double); } void sql_type(String &str) const; + uint convert_order() { return 301; } }; @@ -606,6 +632,7 @@ public: uint32 pack_length() const { return 0; } void sql_type(String &str) const; uint size_of() const { return sizeof(*this); } + uint convert_order() { return 0; } }; @@ -649,6 +676,8 @@ public: } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); + uint convert_order() { return 520; } + bool convert_order_compatible(uint ord) { return ord<520; } }; @@ -674,6 +703,8 @@ public: String *val_str(String*,String *); bool send_binary(Protocol *protocol); void sql_type(String &str) const; + uint convert_order() { return 501; } + bool convert_order_compatible(uint ord) { return ord<520; } }; @@ -706,6 +737,8 @@ public: void sql_type(String &str) const; bool store_for_compare() { return 1; } bool zero_pack() const { return 1; } + uint convert_order() { return 502; } + bool convert_order_compatible(uint ord) { return ord<520; } }; class Field_newdate :public Field_str { @@ -737,6 +770,8 @@ public: bool zero_pack() const { return 1; } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); + uint convert_order() { return 503; } + bool convert_order_compatible(uint ord) { return ord<520; } }; @@ -770,6 +805,8 @@ public: void sql_type(String &str) const; bool store_for_compare() { return 1; } bool zero_pack() const { return 1; } + uint convert_order() { return 504; } + bool convert_order_compatible(uint ord) { return ord<520; } }; @@ -807,6 +844,8 @@ public: bool zero_pack() const { return 1; } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); + uint convert_order() { return 530; } + bool convert_order_compatible(uint ord) { return ord<=501; } }; @@ -851,6 +890,7 @@ public: uint size_of() const { return sizeof(*this); } enum_field_types real_type() const { return FIELD_TYPE_STRING; } bool has_charset(void) const { return TRUE; } + uint convert_order() { return 700; } }; @@ -894,6 +934,7 @@ public: uint size_of() const { return sizeof(*this); } enum_field_types real_type() const { return FIELD_TYPE_VAR_STRING; } bool has_charset(void) const { return TRUE; } + uint convert_order() { return 701; } }; @@ -983,6 +1024,7 @@ public: uint size_of() const { return sizeof(*this); } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } + uint convert_order() { return 701; } }; @@ -1011,6 +1053,8 @@ public: void get_key_image(char *buff,uint length, CHARSET_INFO *cs,imagetype type); void set_key_image(char *buff,uint length, CHARSET_INFO *cs); + uint convert_order() { return 750; } + bool convert_order_compatible(uint ord) { return ord < 750; }; }; @@ -1052,6 +1096,8 @@ public: bool optimize_range(uint idx) { return 0; } bool eq_def(Field *field); bool has_charset(void) const { return TRUE; } + uint convert_order() { return 30; } + bool convert_order_compatible(uint ord) { return ord < 30; }; }; @@ -1077,6 +1123,8 @@ public: void sql_type(String &str) const; enum_field_types real_type() const { return FIELD_TYPE_SET; } bool has_charset(void) const { return TRUE; } + uint convert_order() { return 40; } + bool convert_order_compatible(uint ord) { return ord < 40; }; }; diff --git a/sql/item.cc b/sql/item.cc index 9684fd3e518..4e88dad5a06 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -312,7 +312,7 @@ void Item_field::set_field(Field *field_par) const char *Item_ident::full_name() const { char *tmp; - if (!table_name) + if (!table_name || !field_name) return field_name ? field_name : name ? name : "tmp_field"; if (db_name && db_name[0]) { @@ -1876,6 +1876,8 @@ void Item_cache_str::store(Item *item) } collation.set(item->collation); } + + double Item_cache_str::val() { int err; @@ -1885,6 +1887,8 @@ double Item_cache_str::val() else return (double)0; } + + longlong Item_cache_str::val_int() { int err; @@ -1895,6 +1899,7 @@ longlong Item_cache_str::val_int() return (longlong)0; } + bool Item_cache_row::allocate(uint num) { item_count= num; @@ -1903,6 +1908,7 @@ bool Item_cache_row::allocate(uint num) (Item_cache **) thd->calloc(sizeof(Item_cache *)*item_count))); } + bool Item_cache_row::setup(Item * item) { example= item; @@ -1919,6 +1925,7 @@ bool Item_cache_row::setup(Item * item) return 0; } + void Item_cache_row::store(Item * item) { null_value= 0; @@ -1930,6 +1937,7 @@ void Item_cache_row::store(Item * item) } } + void Item_cache_row::illegal_method_call(const char *method) { DBUG_ENTER("Item_cache_row::illegal_method_call"); @@ -1939,6 +1947,7 @@ void Item_cache_row::illegal_method_call(const char *method) DBUG_VOID_RETURN; } + bool Item_cache_row::check_cols(uint c) { if (c != item_count) @@ -1949,6 +1958,7 @@ bool Item_cache_row::check_cols(uint c) return 0; } + bool Item_cache_row::null_inside() { for (uint i= 0; i < item_count; i++) @@ -1968,6 +1978,7 @@ bool Item_cache_row::null_inside() return 0; } + void Item_cache_row::bring_value() { for (uint i= 0; i < item_count; i++) @@ -1975,6 +1986,114 @@ void Item_cache_row::bring_value() return; } + +Item_type_holder::Item_type_holder(THD *thd, Item *item) + :Item(thd, *item), item_type(item->result_type()) +{ + DBUG_ASSERT(item->fixed); + if (item->type() == Item::FIELD_ITEM) + { + Item_field *fitem= (Item_field*) item; + field_example= (Field*) thd->memdup((const char*)fitem->field, + fitem->field->size_of()); + } + else + field_example= 0; +} + + +// STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT +static Item_result type_convertor[4][4]= +{{STRING_RESULT, STRING_RESULT, STRING_RESULT, ROW_RESULT}, + {STRING_RESULT, REAL_RESULT, REAL_RESULT, ROW_RESULT}, + {STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT}, + {ROW_RESULT, ROW_RESULT, ROW_RESULT, ROW_RESULT}}; + +void Item_type_holder::join_types(THD *thd, Item *item) +{ + bool change_field= 0, skip_store_field= 0; + Item_result new_type= type_convertor[item_type][item->result_type()]; + + // we have both fields + if (field_example && item->type() == Item::FIELD_ITEM) + { + Field *field= ((Item_field *)item)->field; + + // is new field better + if ((change_field= + field_example->convert_order() < field->convert_order())) + { + // is it compatible? + if (field->convert_order_compatible(field_example->convert_order())) + skip_store_field= 1; + } + else + { + /* + if old field can't store value of 'worse' new field we will make + decision about result field tipe based only on Item result type + */ + if (field_example->convert_order_compatible(field->convert_order())) + skip_store_field= 1; + } + } + + // size/type should be changed + if (change_field || + (new_type != item_type) || + (max_length < item->max_length) || + ((new_type == INT_RESULT) && + (decimals < item->decimals)) || + (!maybe_null && item->maybe_null)) + { + // new field has some parameters worse then current + skip_store_field|= (change_field && + (max_length > item->max_length) || + ((new_type == INT_RESULT) && + (decimals > item->decimals)) || + (maybe_null && !item->maybe_null)); + if (skip_store_field || item->type() != Item::FIELD_ITEM) + field_example= 0; + else + { + /* + we do not need following, because we use mem_root + if (field_example) + thd->free(field_example) + */ + Item_field *fitem= (Item_field*) item; + field_example= (Field*) thd->memdup((const char*)fitem->field, + fitem->field->size_of()); + } + max_length= max(max_length, item->max_length); + decimals= max(decimals, item->decimals); + maybe_null|= item->maybe_null; + item_type= new_type; + } + DBUG_ASSERT(item_type != ROW_RESULT); +} + + +double Item_type_holder::val() +{ + DBUG_ASSERT(0); // should never be called + return 0.0; +} + + +longlong Item_type_holder::val_int() +{ + DBUG_ASSERT(0); // should never be called + return 0; +} + + +String *Item_type_holder::val_str(String*) +{ + DBUG_ASSERT(0); // should never be called + return 0; +} + /***************************************************************************** ** Instantiate templates *****************************************************************************/ diff --git a/sql/item.h b/sql/item.h index 907b9ea5ad4..ceeb2158155 100644 --- a/sql/item.h +++ b/sql/item.h @@ -98,7 +98,7 @@ public: COPY_STR_ITEM, FIELD_AVG_ITEM, DEFAULT_VALUE_ITEM, PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM, FIELD_VARIANCE_ITEM, INSERT_VALUE_ITEM, - SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM}; + SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER}; enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; @@ -371,17 +371,17 @@ class Item_int :public Item public: const longlong value; Item_int(int32 i,uint length=11) :value((longlong) i) - { max_length=length;} + { max_length=length; fixed= 1; } #ifdef HAVE_LONG_LONG Item_int(longlong i,uint length=21) :value(i) - { max_length=length;} + { max_length=length; fixed= 1;} #endif Item_int(const char *str_arg,longlong i,uint length) :value(i) - { max_length=length; name=(char*) str_arg;} + { max_length=length; name=(char*) str_arg; fixed= 1; } Item_int(const char *str_arg) : value(str_arg[0] == '-' ? strtoll(str_arg,(char**) 0,10) : (longlong) strtoull(str_arg,(char**) 0,10)) - { max_length= (uint) strlen(str_arg); name=(char*) str_arg;} + { max_length= (uint) strlen(str_arg); name=(char*) str_arg; fixed= 1; } enum Type type() const { return INT_ITEM; } enum Item_result result_type () const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } @@ -969,6 +969,28 @@ public: void bring_value(); }; + +/* + Used to store type. name, length of Item for UNIONS & derived table +*/ +class Item_type_holder: public Item +{ +protected: + Item_result item_type; + Field *field_example; +public: + Item_type_holder(THD*, Item*); + + Item_result result_type () const { return item_type; } + enum Type type() const { return TYPE_HOLDER; } + double val(); + longlong val_int(); + String *val_str(String*); + void join_types(THD *thd, Item *); + Field *example() { return field_example; } +}; + + extern Item_buff *new_Item_buff(Item *item); extern Item_result item_cmp_type(Item_result a,Item_result b); extern Item *resolve_const_item(Item *item,Item *cmp_item); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index a60a35aac6b..367400d6b0b 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -924,7 +924,7 @@ int subselect_single_select_engine::prepare() (ORDER*) select_lex->group_list.first, select_lex->having, (ORDER*) 0, select_lex, - select_lex->master_unit(), 0)) + select_lex->master_unit())) return 1; thd->lex.current_select= save_select; return 0; @@ -932,7 +932,7 @@ int subselect_single_select_engine::prepare() int subselect_union_engine::prepare() { - return unit->prepare(thd, result, 0); + return unit->prepare(thd, result); } int subselect_uniquesubquery_engine::prepare() @@ -942,12 +942,12 @@ int subselect_uniquesubquery_engine::prepare() return 1; } -static Item_result set_row(SELECT_LEX *select_lex, Item * item, +static Item_result set_row(List &item_list, Item *item, Item_cache **row, bool *maybe_null) { Item_result res_type= STRING_RESULT; Item *sel_item; - List_iterator_fast li(select_lex->item_list); + List_iterator_fast li(item_list); for (uint i= 0; (sel_item= li++); i++) { item->max_length= sel_item->max_length; @@ -962,7 +962,7 @@ static Item_result set_row(SELECT_LEX *select_lex, Item * item, row[i]->collation.set(sel_item->collation); } } - if (select_lex->item_list.elements > 1) + if (item_list.elements > 1) res_type= ROW_RESULT; return res_type; } @@ -970,7 +970,7 @@ static Item_result set_row(SELECT_LEX *select_lex, Item * item, void subselect_single_select_engine::fix_length_and_dec(Item_cache **row) { DBUG_ASSERT(row || select_lex->item_list.elements==1); - res_type= set_row(select_lex, item, row, &maybe_null); + res_type= set_row(select_lex->item_list, item, row, &maybe_null); item->collation.set(row[0]->collation); if (cols() != 1) maybe_null= 0; @@ -981,44 +981,11 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row) DBUG_ASSERT(row || unit->first_select()->item_list.elements==1); if (unit->first_select()->item_list.elements == 1) - { - uint32 mlen= 0, len; - Item *sel_item= 0; - for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select()) - { - List_iterator_fast li(sl->item_list); - Item *s_item= li++; - if ((len= s_item->max_length) > mlen) - mlen= len; - if (!sel_item) - sel_item= s_item; - maybe_null= s_item->maybe_null; - } - item->max_length= mlen; - res_type= sel_item->result_type(); - item->decimals= sel_item->decimals; - if (row) - { - if (!(row[0]= Item_cache::get_cache(res_type))) - return; - row[0]->set_len_n_dec(mlen, sel_item->decimals); - } - } + res_type= set_row(unit->types, item, row, &maybe_null); else { - SELECT_LEX *sl= unit->first_select(); bool fake= 0; - res_type= set_row(sl, item, row, &fake); - for (sl= sl->next_select(); sl; sl= sl->next_select()) - { - List_iterator_fast li(sl->item_list); - Item *sel_item; - for (uint i= 0; (sel_item= li++); i++) - { - if (sel_item->max_length > row[i]->max_length) - row[i]->max_length= sel_item->max_length; - } - } + res_type= set_row(unit->types, item, row, &fake); } } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index b9032381c45..5cf352aff99 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -482,7 +482,7 @@ int mysql_select(THD *thd, Item ***rref_pointer_array, COND *conds, uint og_num, ORDER *order, ORDER *group, Item *having, ORDER *proc_param, ulong select_type, select_result *result, SELECT_LEX_UNIT *unit, - SELECT_LEX *select_lex, bool tables_and_fields_initied); + SELECT_LEX *select_lex); void free_underlaid_joins(THD *thd, SELECT_LEX *select); void fix_tables_pointers(SELECT_LEX *select_lex); void fix_tables_pointers(SELECT_LEX_UNIT *select_lex); @@ -491,7 +491,7 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type, select_result *result); int mysql_union(THD *thd, LEX *lex, select_result *result, - SELECT_LEX_UNIT *unit, bool tables_and_fields_initied); + SELECT_LEX_UNIT *unit); int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *s, TABLE_LIST *t); Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, Item ***copy_func, Field **from_field, @@ -675,7 +675,6 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, int setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables, List &item, bool set_query_id, List *sum_func_list, bool allow_sum_func); -void unfix_item_list(List item_list); int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds); int setup_ftfuncs(SELECT_LEX* select); int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7a657841845..775aa1cd43f 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2023,20 +2023,6 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, DBUG_RETURN(test(thd->net.report_error)); } -/* - Mark all items in list as not fixed (0 assigned to 'fixed' field) - - SYNOPSYS - unfix_item_list() - item_list - list of items -*/ -void unfix_item_list(List item_list) -{ - Item *item; - List_iterator_fast it(item_list); - while ((item= it++)) - item->walk(&Item::remove_fixed, 0); -} /* Remap table numbers if INSERT ... SELECT diff --git a/sql/sql_class.h b/sql/sql_class.h index b19caf057e6..36faeae8f57 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -946,6 +946,7 @@ class select_union :public select_result { bool send_data(List &items); bool send_eof(); bool flush(); + void set_table(TABLE *tbl) { table= tbl; } }; /* Base subselect interface class */ diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 719686a56c3..591c6579a46 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -62,16 +62,15 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *org_table_list) { - SELECT_LEX *select_cursor= unit->first_select(); - List item_list; + SELECT_LEX *first_select= unit->first_select(); TABLE *table; int res; select_union *derived_result; - TABLE_LIST *tables= (TABLE_LIST *)select_cursor->table_list.first; + TABLE_LIST *tables= (TABLE_LIST *)first_select->table_list.first; TMP_TABLE_PARAM tmp_table_param; - bool is_union= select_cursor->next_select() && - select_cursor->next_select()->linkage == UNION_TYPE; - bool is_subsel= select_cursor->first_inner_unit() ? 1: 0; + bool is_union= first_select->next_select() && + first_select->next_select()->linkage == UNION_TYPE; + bool is_subsel= first_select->first_inner_unit() ? 1: 0; SELECT_LEX *save_current_select= lex->current_select; DBUG_ENTER("mysql_derived"); @@ -112,16 +111,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, fix_tables_pointers(unit); } - lex->current_select= select_cursor; - TABLE_LIST *first_table= (TABLE_LIST*) select_cursor->table_list.first; - /* Setting up. A must if a join or IGNORE, USE or similar are utilised */ - if (setup_tables(first_table) || - setup_wild(thd, first_table, select_cursor->item_list, 0, - select_cursor->with_wild)) - { - res= -1; + if(!(derived_result= new select_union(0))) + DBUG_RETURN(1); // out of memory + + // st_select_lex_unit::prepare coppectly work for single select + if ((res= unit->prepare(thd, derived_result))) goto exit; - } /* This is done in order to redo all field optimisations when any of the @@ -133,30 +128,16 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - item_list= select_cursor->item_list; - select_cursor->with_wild= 0; - if (select_cursor->setup_ref_array(thd, - select_cursor->order_list.elements + - select_cursor->group_list.elements) || - setup_fields(thd, select_cursor->ref_pointer_array, first_table, - item_list, 0, 0, 1)) - { - res= -1; - goto exit; - } - // Item list should be fix_fielded yet another time in JOIN::prepare - unfix_item_list(item_list); - bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); - tmp_table_param.field_count= item_list.elements; + tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be processed */ - if (!(table= create_tmp_table(thd, &tmp_table_param, item_list, + if (!(table= create_tmp_table(thd, &tmp_table_param, unit->types, (ORDER*) 0, is_union && !unit->union_option, 1, - (select_cursor->options | thd->options | + (first_select->options | thd->options | TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, org_table_list->alias))) @@ -164,70 +145,69 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, res= -1; goto exit; } - - if ((derived_result=new select_union(table))) + derived_result->set_table(table); + derived_result->tmp_table_param=tmp_table_param; + + unit->offset_limit_cnt= first_select->offset_limit; + unit->select_limit_cnt= first_select->select_limit+ + first_select->offset_limit; + if (unit->select_limit_cnt < first_select->select_limit) + unit->select_limit_cnt= HA_POS_ERROR; + if (unit->select_limit_cnt == HA_POS_ERROR) + first_select->options&= ~OPTION_FOUND_ROWS; + + if (is_union) + res= mysql_union(thd, lex, derived_result, unit); + else + res= mysql_select(thd, &first_select->ref_pointer_array, + (TABLE_LIST*) first_select->table_list.first, + first_select->with_wild, + first_select->item_list, first_select->where, + (first_select->order_list.elements+ + first_select->group_list.elements), + (ORDER *) first_select->order_list.first, + (ORDER *) first_select->group_list.first, + first_select->having, (ORDER*) NULL, + (first_select->options | thd->options | + SELECT_NO_UNLOCK), + derived_result, unit, first_select); + + if (!res) { - derived_result->tmp_table_param=tmp_table_param; - unit->offset_limit_cnt= select_cursor->offset_limit; - unit->select_limit_cnt= select_cursor->select_limit+ - select_cursor->offset_limit; - if (unit->select_limit_cnt < select_cursor->select_limit) - unit->select_limit_cnt= HA_POS_ERROR; - if (unit->select_limit_cnt == HA_POS_ERROR) - select_cursor->options&= ~OPTION_FOUND_ROWS; - - if (is_union) - res= mysql_union(thd, lex, derived_result, unit, 1); + /* + Here we entirely fix both TABLE_LIST and list of SELECT's as + there were no derived tables + */ + if (derived_result->flush()) + res= 1; else - res= mysql_select(thd, &select_cursor->ref_pointer_array, - (TABLE_LIST*) select_cursor->table_list.first, - select_cursor->with_wild, - select_cursor->item_list, select_cursor->where, - (select_cursor->order_list.elements+ - select_cursor->group_list.elements), - (ORDER *) select_cursor->order_list.first, - (ORDER *) select_cursor->group_list.first, - select_cursor->having, (ORDER*) NULL, - (select_cursor->options | thd->options | - SELECT_NO_UNLOCK), - derived_result, unit, select_cursor, 1); - - if (!res) { - /* - Here we entirely fix both TABLE_LIST and list of SELECT's as - there were no derived tables - */ - if (derived_result->flush()) - res= 1; - else - { - org_table_list->real_name=table->real_name; - org_table_list->table=table; - table->derived_select_number= select_cursor->select_number; - table->tmp_table= TMP_TABLE; + org_table_list->real_name=table->real_name; + org_table_list->table=table; + table->derived_select_number= first_select->select_number; + table->tmp_table= TMP_TABLE; #ifndef NO_EMBEDDED_ACCESS_CHECKS - org_table_list->grant.privilege= SELECT_ACL; + org_table_list->grant.privilege= SELECT_ACL; #endif - if (lex->describe) + if (lex->describe) + { + // to fix a problem in EXPLAIN + if (tables) { - // to fix a problem in EXPLAIN - if (tables) - { - for (TABLE_LIST *cursor= tables; cursor; cursor= cursor->next) - if (cursor->table_list) - cursor->table_list->table=cursor->table; - } + for (TABLE_LIST *cursor= tables; cursor; cursor= cursor->next) + if (cursor->table_list) + cursor->table_list->table=cursor->table; } - else - unit->exclude_tree(); - org_table_list->db= (char *)""; - // Force read of table stats in the optimizer - table->file->info(HA_STATUS_VARIABLE); } + else + unit->exclude_tree(); + org_table_list->db= (char *)""; + // Force read of table stats in the optimizer + table->file->info(HA_STATUS_VARIABLE); } - delete derived_result; } + delete derived_result; + if (res) free_tmp_table(thd, table); else diff --git a/sql/sql_lex.h b/sql/sql_lex.h index d2345165eb9..29301053c59 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -295,7 +295,6 @@ class JOIN; class select_union; class st_select_lex_unit: public st_select_lex_node { protected: - List item_list; TABLE_LIST result_table_list; select_union *union_result; TABLE *table; /* temporary table using for appending UNION results */ @@ -305,9 +304,13 @@ protected: ulong found_rows_for_union; bool prepared, // prepare phase already performed for UNION (unit) optimized, // optimize phase already performed for UNION (unit) - executed, // already executed - t_and_f; // used for transferring tables_and_fields_initied UNIT:: methods + executed; // already executed + public: + // list of fields which points to temporary table for union + List item_list; + // list of types of items inside union (used for union & derived tables) + List types; /* Pointer to 'last' select or pointer to unit where stored global parameters for union @@ -342,7 +345,7 @@ public: void exclude_tree(); /* UNION methods */ - int prepare(THD *thd, select_result *result, bool tables_and_fields_initied); + int prepare(THD *thd, select_result *result); int exec(); int cleanup(); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9f4b10682ba..d5a15de422d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2716,7 +2716,7 @@ mysql_execute_command(THD *thd) (ORDER *)NULL, select_lex->options | thd->options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK, - result, unit, select_lex, 0); + result, unit, select_lex); if (thd->net.report_error) res= -1; delete result; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 354214a4da5..69517b171cb 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -682,7 +682,7 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables, if (join->prepare(&select_lex->ref_pointer_array, tables, wild_num, conds, og_num, order, group, having, proc, - select_lex, unit, 0)) + select_lex, unit)) DBUG_RETURN(1); if (send_prep_stmt(stmt, fields.elements) || thd->protocol_simple.send_fields(&fields, 0) || diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 44b403c0bb1..ba4dd9f856e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -177,7 +177,7 @@ int handle_select(THD *thd, LEX *lex, select_result *result) fix_tables_pointers(lex->all_selects_list); if (select_lex->next_select()) - res=mysql_union(thd, lex, result, &lex->unit, 0); + res=mysql_union(thd, lex, result, &lex->unit); else res= mysql_select(thd, &select_lex->ref_pointer_array, (TABLE_LIST*) select_lex->table_list.first, @@ -190,7 +190,7 @@ int handle_select(THD *thd, LEX *lex, select_result *result) select_lex->having, (ORDER*) lex->proc_list.first, select_lex->options | thd->options, - result, &(lex->unit), &(lex->select_lex), 0); + result, &(lex->unit), &(lex->select_lex)); /* Don't set res if it's -1 as we may want this later */ DBUG_PRINT("info",("res: %d report_error: %d", res, @@ -285,8 +285,7 @@ JOIN::prepare(Item ***rref_pointer_array, ORDER *order_init, ORDER *group_init, Item *having_init, ORDER *proc_param_init, SELECT_LEX *select, - SELECT_LEX_UNIT *unit, - bool tables_and_fields_initied) + SELECT_LEX_UNIT *unit) { DBUG_ENTER("JOIN::prepare"); @@ -302,10 +301,8 @@ JOIN::prepare(Item ***rref_pointer_array, /* Check that all tables, fields, conds and order are ok */ - if ((tables_and_fields_initied ? 0 : (setup_tables(tables_list) || - setup_wild(thd, tables_list, - fields_list, - &all_fields, wild_num))) || + if (setup_tables(tables_list) || + setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) || select_lex->setup_ref_array(thd, og_num) || setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1, &all_fields, 1) || @@ -1536,7 +1533,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, COND *conds, uint og_num, ORDER *order, ORDER *group, Item *having, ORDER *proc_param, ulong select_options, select_result *result, SELECT_LEX_UNIT *unit, - SELECT_LEX *select_lex, bool tables_and_fields_initied) + SELECT_LEX *select_lex) { int err; bool free_join= 1; @@ -1546,26 +1543,31 @@ mysql_select(THD *thd, Item ***rref_pointer_array, if (select_lex->join != 0) { join= select_lex->join; - if (select_lex->linkage != GLOBAL_OPTIONS_TYPE) + // is it single SELECT in derived table, called in derived table creation + if (select_lex->linkage != DERIVED_TABLE_TYPE || + (select_options & SELECT_DESCRIBE)) { - //here is EXPLAIN of subselect or derived table - join->result= result; - if (!join->procedure && result->prepare(join->fields_list, unit)) + if (select_lex->linkage != GLOBAL_OPTIONS_TYPE) { - DBUG_RETURN(-1); + //here is EXPLAIN of subselect or derived table + join->result= result; + if (!join->procedure && result->prepare(join->fields_list, unit)) + { + DBUG_RETURN(-1); + } } - } - else - { - if (join->prepare(rref_pointer_array, tables, wild_num, - conds, og_num, order, group, having, proc_param, - select_lex, unit, tables_and_fields_initied)) + else { - goto err; + if (join->prepare(rref_pointer_array, tables, wild_num, + conds, og_num, order, group, having, proc_param, + select_lex, unit)) + { + goto err; + } } + free_join= 0; } join->select_options= select_options; - free_join= 0; } else { @@ -1574,7 +1576,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, thd->used_tables=0; // Updated by setup_fields if (join->prepare(rref_pointer_array, tables, wild_num, conds, og_num, order, group, having, proc_param, - select_lex, unit, tables_and_fields_initied)) + select_lex, unit)) { goto err; } @@ -4545,6 +4547,115 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) Create internal temporary table ****************************************************************************/ +/* + Create field for temporary table from given field + + SYNOPSIS + create_tmp_field_from_field() + thd Thread handler + org_field field from which new field will be created + item Item to create a field for + table Temporary table + modify_item 1 if item->result_field should point to new item. + This is relevent for how fill_record() is going to + work: + If modify_item is 1 then fill_record() will update + the record in the original table. + If modify_item is 0 then fill_record() will update + the temporary table + + RETURN + 0 on error + new_created field +*/ +static Field* create_tmp_field_from_field(THD *thd, + Field* org_field, + Item *item, + TABLE *table, + bool modify_item) +{ + Field *new_field; + + // The following should always be true + if ((new_field= org_field->new_field(&thd->mem_root,table))) + { + if (modify_item) + ((Item_field *)item)->result_field= new_field; + else + new_field->field_name= item->name; + if (org_field->maybe_null()) + new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join + if (org_field->type() == FIELD_TYPE_VAR_STRING) + table->db_create_options|= HA_OPTION_PACK_RECORD; + } + return new_field; +} + +/* + Create field for temporary table using type of given item + + SYNOPSIS + create_tmp_field_from_item() + thd Thread handler + item Item to create a field for + table Temporary table + copy_func If set and item is a function, store copy of item + in this array + modify_item 1 if item->result_field should point to new item. + This is relevent for how fill_record() is going to + work: + If modify_item is 1 then fill_record() will update + the record in the original table. + If modify_item is 0 then fill_record() will update + the temporary table + + RETURN + 0 on error + new_created field +*/ +static Field* create_tmp_field_from_item(THD *thd, + Item *item, + TABLE *table, + Item ***copy_func, + bool modify_item) +{ + bool maybe_null=item->maybe_null; + Field *new_field; + LINT_INIT(new_field); + + switch (item->result_type()) { + case REAL_RESULT: + new_field=new Field_double(item->max_length, maybe_null, + item->name, table, item->decimals); + break; + case INT_RESULT: + new_field=new Field_longlong(item->max_length, maybe_null, + item->name, table, item->unsigned_flag); + break; + case STRING_RESULT: + if (item->max_length > 255) + new_field= new Field_blob(item->max_length, maybe_null, + item->name, table, + item->collation.collation); + else + new_field= new Field_string(item->max_length, maybe_null, + item->name, table, + item->collation.collation); + break; + case ROW_RESULT: + default: + // This case should never be choosen + DBUG_ASSERT(0); + new_field= 0; // to satisfy compiler (uninitialized variable) + break; + } + if (copy_func && item->is_result_field()) + *((*copy_func)++) = item; // Save for copy_funcs + if (modify_item) + item->set_result_field(new_field); + return new_field; +} + /* Create field for temporary table @@ -4556,6 +4667,8 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) type Type of item (normally item->type) copy_func If set and item is a function, store copy of item in this array + from_field if field will be created using other field as example, + pointer example field will be written here group 1 if we are going to do a relative group by on result modify_item 1 if item->result_field should point to new item. This is relevent for how fill_record() is going to @@ -4622,24 +4735,9 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, return 0; // Error } case Item::FIELD_ITEM: - { - Field *org_field=((Item_field*) item)->field,*new_field; - - *from_field=org_field; - // The following should always be true - if ((new_field= org_field->new_field(&thd->mem_root,table))) - { - if (modify_item) - ((Item_field*) item)->result_field= new_field; - else - new_field->field_name=item->name; - if (org_field->maybe_null()) - new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join - if (org_field->type()==FIELD_TYPE_VAR_STRING) - table->db_create_options|= HA_OPTION_PACK_RECORD; - } - return new_field; - } + return create_tmp_field_from_field(thd, (*from_field= + ((Item_field*) item)->field), + item, table, modify_item); case Item::FUNC_ITEM: case Item::COND_ITEM: case Item::FIELD_AVG_ITEM: @@ -4653,40 +4751,14 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case Item::REF_ITEM: case Item::NULL_ITEM: case Item::VARBIN_ITEM: + return create_tmp_field_from_item(thd, item, table, + copy_func, modify_item); + case Item::TYPE_HOLDER: { - bool maybe_null=item->maybe_null; - Field *new_field; - LINT_INIT(new_field); - - switch (item->result_type()) { - case REAL_RESULT: - new_field=new Field_double(item->max_length,maybe_null, - item->name,table,item->decimals); - break; - case INT_RESULT: - new_field=new Field_longlong(item->max_length,maybe_null, - item->name,table, item->unsigned_flag); - break; - case STRING_RESULT: - if (item->max_length > 255) - new_field= new Field_blob(item->max_length,maybe_null, - item->name,table,item->collation.collation); - else - new_field= new Field_string(item->max_length,maybe_null, - item->name,table,item->collation.collation); - break; - case ROW_RESULT: - default: - // This case should never be choosen - DBUG_ASSERT(0); - new_field= 0; // to satisfy compiler (uninitialized variable) - break; - } - if (copy_func && item->is_result_field()) - *((*copy_func)++) = item; // Save for copy_funcs - if (modify_item) - item->set_result_field(new_field); - return new_field; + Field *example= ((Item_type_holder *)item)->example(); + if (example) + return create_tmp_field_from_field(thd, example, item, table, 0); + return create_tmp_field_from_item(thd, item, table, copy_func, 0); } default: // Dosen't have to be stored return 0; @@ -9077,7 +9149,7 @@ int mysql_explain_select(THD *thd, SELECT_LEX *select_lex, char const *type, select_lex->having, (ORDER*) thd->lex.proc_list.first, select_lex->options | thd->options | SELECT_DESCRIBE, - result, unit, select_lex, 0); + result, unit, select_lex); DBUG_RETURN(res); } diff --git a/sql/sql_select.h b/sql/sql_select.h index 5f0370a5a32..2e101c78613 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -266,7 +266,7 @@ class JOIN :public Sql_alloc int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num, COND *conds, uint og_num, ORDER *order, ORDER *group, Item *having, ORDER *proc_param, SELECT_LEX *select, - SELECT_LEX_UNIT *unit, bool tables_and_fields_initied); + SELECT_LEX_UNIT *unit); int optimize(); int reinit(); void exec(); diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 5292299f928..e2c90e4ff4c 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -25,11 +25,11 @@ #include "sql_select.h" int mysql_union(THD *thd, LEX *lex, select_result *result, - SELECT_LEX_UNIT *unit, bool tables_and_fields_initied) + SELECT_LEX_UNIT *unit) { DBUG_ENTER("mysql_union"); int res= 0; - if (!(res= unit->prepare(thd, result, tables_and_fields_initied))) + if (!(res= unit->prepare(thd, result))) res= unit->exec(); res|= unit->cleanup(); DBUG_RETURN(res); @@ -59,12 +59,6 @@ select_union::~select_union() int select_union::prepare(List &list, SELECT_LEX_UNIT *u) { unit= u; - if (not_describe && list.elements != table->fields) - { - my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, - ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),MYF(0)); - return -1; - } return 0; } @@ -112,11 +106,11 @@ bool select_union::flush() } -int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, - bool tables_and_fields_initied) +int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) { SELECT_LEX *lex_select_save= thd->lex.current_select; - SELECT_LEX *select_cursor,*sl; + SELECT_LEX *sl, *first_select; + select_result *tmp_result; DBUG_ENTER("st_select_lex_unit::prepare"); /* @@ -129,74 +123,33 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, DBUG_RETURN(0); prepared= 1; res= 0; - found_rows_for_union= first_select_in_union()->options & OPTION_FOUND_ROWS; TMP_TABLE_PARAM tmp_table_param; - t_and_f= tables_and_fields_initied; bzero((char *)&tmp_table_param,sizeof(TMP_TABLE_PARAM)); - thd->lex.current_select= sl= select_cursor= first_select_in_union(); + thd->lex.current_select= sl= first_select= first_select_in_union(); + found_rows_for_union= first_select->options & OPTION_FOUND_ROWS; + /* Global option */ - if (t_and_f) + + if (first_select->next_select()) { - // Item list and tables will be initialized by mysql_derived - item_list= select_cursor->item_list; + if (!(tmp_result= union_result= new select_union(0))) + goto err; + union_result->not_describe= 1; + union_result->tmp_table_param= tmp_table_param; } else { - item_list.empty(); - TABLE_LIST *first_table= (TABLE_LIST*) select_cursor->table_list.first; - - if (setup_tables(first_table) || - setup_wild(thd, first_table, select_cursor->item_list, 0, - select_cursor->with_wild)) - goto err; - List_iterator it(select_cursor->item_list); - Item *item; - item_list= select_cursor->item_list; - select_cursor->with_wild= 0; - if (select_cursor->setup_ref_array(thd, - select_cursor->order_list.elements + - select_cursor->group_list.elements) || - setup_fields(thd, select_cursor->ref_pointer_array, first_table, - item_list, 0, 0, 1)) - goto err; - // Item list should be fix_fielded yet another time in JOIN::prepare - unfix_item_list(item_list); - - t_and_f= 1; - while((item=it++)) - { - item->maybe_null=1; - if (item->type() == Item::FIELD_ITEM) - ((class Item_field *)item)->field->table->maybe_null=1; - } + tmp_result= sel_result; + // single select should be processed like select in p[arantses + first_select->braces= 1; } - tmp_table_param.field_count=item_list.elements; - if (!(table= create_tmp_table(thd, &tmp_table_param, item_list, - (ORDER*) 0, !union_option, - 1, (select_cursor->options | thd->options | - TMP_TABLE_ALL_COLUMNS), - HA_POS_ERROR, (char*) ""))) - goto err; - table->file->extra(HA_EXTRA_WRITE_CACHE); - table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); - bzero((char*) &result_table_list,sizeof(result_table_list)); - result_table_list.db= (char*) ""; - result_table_list.real_name=result_table_list.alias= (char*) "union"; - result_table_list.table=table; - - if (!(union_result=new select_union(table))) - goto err; - - union_result->not_describe=1; - union_result->tmp_table_param=tmp_table_param; - for (;sl; sl= sl->next_select()) { JOIN *join= new JOIN(thd, sl->item_list, sl->options | thd->options | SELECT_NO_UNLOCK, - union_result); + tmp_result); thd->lex.current_select= sl; offset_limit_cnt= sl->offset_limit; select_limit_cnt= sl->select_limit+sl->offset_limit; @@ -215,27 +168,76 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, (ORDER*) sl->group_list.first, sl->having, (ORDER*) NULL, - sl, this, t_and_f); - t_and_f= 0; + sl, this); if (res || thd->is_fatal_error) goto err; - } - - item_list.empty(); - thd->lex.current_select= lex_select_save; - { - List_iterator it(select_cursor->item_list); - Field **field; - - for (field= table->field; *field; field++) + if (sl == first_select) { - (void) it++; - if (item_list.push_back(new Item_field(*field))) - DBUG_RETURN(-1); + types.empty(); + List_iterator_fast it(sl->item_list); + Item *item; + while((item= it++)) + { + types.push_back(new Item_type_holder(thd, item)); + } + + if (thd->is_fatal_error) + goto err; // out of memory + } + else + { + if (types.elements != sl->item_list.elements) + { + my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, + ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),MYF(0)); + goto err; + } + List_iterator_fast it(sl->item_list); + List_iterator_fast tp(types); + Item *type, *item; + while((type= tp++, item= it++)) + { + ((Item_type_holder*)type)->join_types(thd, item); + } } } + if (first_select->next_select()) + { + tmp_table_param.field_count= types.elements; + if (!(table= create_tmp_table(thd, &tmp_table_param, types, + (ORDER*) 0, !union_option, 1, + (first_select_in_union()->options | + thd->options | + TMP_TABLE_ALL_COLUMNS), + HA_POS_ERROR, (char*) ""))) + goto err; + table->file->extra(HA_EXTRA_WRITE_CACHE); + table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); + bzero((char*) &result_table_list, sizeof(result_table_list)); + result_table_list.db= (char*) ""; + result_table_list.real_name= result_table_list.alias= (char*) "union"; + result_table_list.table= table; + union_result->set_table(table); + + item_list.empty(); + thd->lex.current_select= lex_select_save; + { + Field **field; + for (field= table->field; *field; field++) + { + if (item_list.push_back(new Item_field(*field))) + DBUG_RETURN(-1); + } + } + } + else + first_select->braces= 0; // remove our changes + + thd->lex.current_select= lex_select_save; + DBUG_RETURN(res || thd->is_fatal_error ? 1 : 0); + err: thd->lex.current_select= lex_select_save; DBUG_RETURN(-1); @@ -419,7 +421,7 @@ int st_select_lex_unit::exec() (ORDER*)global_parameters->order_list.first, (ORDER*) NULL, NULL, (ORDER*) NULL, options | SELECT_NO_UNLOCK, - result, this, fake_select_lex, 0); + result, this, fake_select_lex); if (!res) thd->limit_found_rows = (ulonglong)table->file->records + add_rows; /* diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 9214894e214..8b77f6958d0 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -461,7 +461,7 @@ int mysql_multi_update(THD *thd, conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, (ORDER *)NULL, options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK, - result, unit, select_lex, 0); + result, unit, select_lex); delete result; DBUG_RETURN(res); } From 7c725b2486de1f48f4e4e16a87b4b3cb542ab19b Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Sun, 23 Nov 2003 14:36:41 +0200 Subject: [PATCH 36/89] Fixed compiler warnings from Intel compiler in Win64 Added option --max-record-length=# to myisamchk Don't try repair twice if doing myisamchk --repair --force Shared memory handler didn't clean up things on errors or shutdown --- VC++Files/libmysqltest/mytest.c | 48 ++++--- include/myisam.h | 1 + include/mysql_com.h | 2 +- innobase/btr/btr0btr.c | 34 +++-- innobase/btr/btr0cur.c | 27 ++-- innobase/include/btr0btr.ic | 2 +- innobase/include/buf0buf.ic | 8 +- innobase/include/row0sel.ic | 2 +- innobase/include/row0upd.ic | 4 +- innobase/include/trx0rseg.ic | 4 +- innobase/pars/pars0opt.c | 5 +- innobase/que/que0que.c | 13 +- myisam/mi_check.c | 91 ++++++++----- myisam/myisamchk.c | 15 ++- mysql-test/r/create.result | 5 +- mysql-test/t/create.test | 6 +- sql/ha_innodb.cc | 7 +- sql/item_func.cc | 1 + sql/mysqld.cc | 228 +++++++++++++++----------------- strings/bmove512.c | 2 +- 20 files changed, 267 insertions(+), 238 deletions(-) diff --git a/VC++Files/libmysqltest/mytest.c b/VC++Files/libmysqltest/mytest.c index ceecbb19902..9af8c486e40 100644 --- a/VC++Files/libmysqltest/mytest.c +++ b/VC++Files/libmysqltest/mytest.c @@ -40,7 +40,7 @@ main( int argc, char * argv[] ) MYSQL_ROW row ; //....just curious.... - printf( "sizeof( MYSQL ) == %d\n", sizeof( MYSQL ) ) ; + printf( "sizeof( MYSQL ) == %d\n", (int) sizeof( MYSQL ) ) ; if ( argc == 2 ) { strcpy( szDB, argv[ 1 ] ) ; @@ -49,27 +49,31 @@ main( int argc, char * argv[] ) { strcpy( szDB, "mysql" ) ; printf("Some mysql struct information (size and offset):\n"); - printf("net:\t%3d %3d\n",sizeof(myData->net),offsetof(MYSQL,net)); - printf("host:\t%3d %3d\n",sizeof(myData->host),offsetof(MYSQL,host)); - printf("port:\t%3d %3d\n",sizeof(myData->port),offsetof(MYSQL,port)); - printf("protocol_version:\t%3d %3d\n",sizeof(myData->protocol_version), - offsetof(MYSQL,protocol_version)); - printf("thread_id:\t%3d %3d\n",sizeof(myData->thread_id), - offsetof(MYSQL,thread_id)); - printf("affected_rows:\t%3d %3d\n",sizeof(myData->affected_rows), - offsetof(MYSQL,affected_rows)); - printf("packet_length:\t%3d %3d\n",sizeof(myData->packet_length), - offsetof(MYSQL,packet_length)); - printf("status:\t%3d %3d\n",sizeof(myData->status), - offsetof(MYSQL,status)); - printf("fields:\t%3d %3d\n",sizeof(myData->fields), - offsetof(MYSQL,fields)); - printf("field_alloc:\t%3d %3d\n",sizeof(myData->field_alloc), - offsetof(MYSQL,field_alloc)); - printf("free_me:\t%3d %3d\n",sizeof(myData->free_me), - offsetof(MYSQL,free_me)); - printf("options:\t%3d %3d\n",sizeof(myData->options), - offsetof(MYSQL,options)); + printf("net:\t%3d %3d\n",(int) sizeof(myData->net), + (int) offsetof(MYSQL,net)); + printf("host:\t%3d %3d\n",(int) sizeof(myData->host), + (int) offsetof(MYSQL,host)); + printf("port:\t%3d %3d\n", (int) sizeof(myData->port), + (int) offsetof(MYSQL,port)); + printf("protocol_version:\t%3d %3d\n", + (int) sizeof(myData->protocol_version), + (int) offsetof(MYSQL,protocol_version)); + printf("thread_id:\t%3d %3d\n",(int) sizeof(myData->thread_id), + (int) offsetof(MYSQL,thread_id)); + printf("affected_rows:\t%3d %3d\n",(int) sizeof(myData->affected_rows), + (int) offsetof(MYSQL,affected_rows)); + printf("packet_length:\t%3d %3d\n",(int) sizeof(myData->packet_length), + (int) offsetof(MYSQL,packet_length)); + printf("status:\t%3d %3d\n",(int) sizeof(myData->status), + (int) offsetof(MYSQL,status)); + printf("fields:\t%3d %3d\n",(int) sizeof(myData->fields), + (int) offsetof(MYSQL,fields)); + printf("field_alloc:\t%3d %3d\n",(int) sizeof(myData->field_alloc), + (int) offsetof(MYSQL,field_alloc)); + printf("free_me:\t%3d %3d\n",(int) sizeof(myData->free_me), + (int) offsetof(MYSQL,free_me)); + printf("options:\t%3d %3d\n",(int) sizeof(myData->options), + (int) offsetof(MYSQL,options)); puts(""); } } diff --git a/include/myisam.h b/include/myisam.h index 613a9965832..2285f996464 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -318,6 +318,7 @@ typedef struct st_mi_check_param ulonglong auto_increment_value; ulonglong max_data_file_length; ulonglong keys_in_use; + ulonglong max_record_length; my_off_t search_after_block; my_off_t new_file_pos,key_file_blocks; my_off_t keydata,totaldata,key_blocks,start_check_pos; diff --git a/include/mysql_com.h b/include/mysql_com.h index 3031b883e98..39e9c48146d 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -118,7 +118,7 @@ enum enum_server_command #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_REMEMBER_OPTIONS (1L << 31) +#define CLIENT_REMEMBER_OPTIONS ((ulong) (1L << 31)) #define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c index 3d11cbe1748..686c35d1300 100644 --- a/innobase/btr/btr0btr.c +++ b/innobase/btr/btr0btr.c @@ -600,8 +600,8 @@ btr_page_get_father_for_rec( "InnoDB: father ptr page no %lu, child page no %lu\n", (UT_LIST_GET_FIRST(tree->tree_indexes))->table_name, (UT_LIST_GET_FIRST(tree->tree_indexes))->name, - btr_node_ptr_get_child_page_no(node_ptr), - buf_frame_get_page_no(page)); + (unsigned long) btr_node_ptr_get_child_page_no(node_ptr), + (unsigned long) buf_frame_get_page_no(page)); page_rec_print(page_rec_get_next(page_get_infimum_rec(page))); page_rec_print(node_ptr); @@ -877,7 +877,9 @@ btr_page_reorganize_low( "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: Make a detailed bug report and send it to mysql@lists.mysql.com\n", - data_size1, data_size2, max_ins_size1, max_ins_size2); + (unsigned long) data_size1, (unsigned long) data_size2, + (unsigned long) max_ins_size1, + (unsigned long) max_ins_size2); } buf_frame_free(new_page); @@ -2356,8 +2358,10 @@ btr_index_rec_validate( "InnoDB: Record in index %s in table %s, page %lu, at offset %lu\n" "InnoDB: has %lu fields, should have %lu\n", index->name, index->table_name, - buf_frame_get_page_no(page), (ulint)(rec - page), - rec_get_n_fields(rec), n); + (unsigned long) buf_frame_get_page_no(page), + (unsigned long) (rec - page), + (unsigned long) rec_get_n_fields(rec), + (unsigned long) n); if (!dump_on_error) { @@ -2390,9 +2394,11 @@ btr_index_rec_validate( "InnoDB: Record in index %s in table %s, page %lu, at offset %lu\n" "InnoDB: field %lu len is %lu, should be %lu\n", index->name, index->table_name, - buf_frame_get_page_no(page), - (ulint)(rec - page), - i, len, dtype_get_fixed_size(type)); + (unsigned long) buf_frame_get_page_no(page), + (unsigned long) (rec - page), + (unsigned long) i, + (unsigned long) len, + (unsigned long) dtype_get_fixed_size(type)); if (!dump_on_error) { @@ -2541,7 +2547,7 @@ loop: fprintf(stderr, "InnoDB: Error on pages %lu and %lu in index %s table %s\n", buf_frame_get_page_no(page), - right_page_no, + (unsigned long) right_page_no, index->name, index->table_name); fprintf(stderr, @@ -2581,7 +2587,7 @@ loop: &mtr)) { fprintf(stderr, "InnoDB: Error on page %lu in index %s table %s\n", - buf_frame_get_page_no(page), + (unsigned long) buf_frame_get_page_no(page), index->name, index->table_name); fprintf(stderr, @@ -2596,7 +2602,7 @@ loop: fprintf(stderr, "InnoDB: node ptr child page n:o %lu\n", - btr_node_ptr_get_child_page_no(node_ptr)); + (unsigned long) btr_node_ptr_get_child_page_no(node_ptr)); rec_sprintf(err_buf, 900, btr_page_get_father_for_rec(tree, page, @@ -2679,7 +2685,7 @@ loop: fprintf(stderr, "InnoDB: Error on page %lu in index %s table %s\n", - buf_frame_get_page_no(page), + (unsigned long) buf_frame_get_page_no(page), index->name, index->table_name); buf_page_print(father_page); @@ -2699,7 +2705,7 @@ loop: fprintf(stderr, "InnoDB: Error on page %lu in index %s table %s\n", - buf_frame_get_page_no(page), + (unsigned long) buf_frame_get_page_no(page), index->name, index->table_name); buf_page_print(father_page); @@ -2717,7 +2723,7 @@ loop: fprintf(stderr, "InnoDB: Error on page %lu in index %s table %s\n", - buf_frame_get_page_no(page), + (unsigned long) buf_frame_get_page_no(page), index->name, index->table_name); buf_page_print(father_page); diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c index 5743ba54544..93e9e815c99 100644 --- a/innobase/btr/btr0cur.c +++ b/innobase/btr/btr0cur.c @@ -874,8 +874,8 @@ btr_cur_optimistic_insert( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to insert to table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); dtuple_print(entry); } @@ -978,7 +978,8 @@ calculate_sizes_again: fprintf(stderr, "InnoDB: Error: cannot insert tuple %s to index %s of table %s\n" "InnoDB: max insert size %lu\n", - err_buf, index->name, index->table->name, max_size); + err_buf, index->name, index->table->name, + (unsigned long) max_size); mem_free(err_buf); } @@ -1343,8 +1344,8 @@ btr_cur_update_sec_rec_in_place( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to update table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); rec_print(rec); } @@ -1407,8 +1408,8 @@ btr_cur_update_in_place( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to update table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); rec_print(rec); } @@ -1509,8 +1510,8 @@ btr_cur_optimistic_update( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to update table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); rec_print(rec); } @@ -2059,8 +2060,8 @@ btr_cur_del_mark_set_clust_rec( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to del mark table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); rec_print(rec); } @@ -2199,8 +2200,8 @@ btr_cur_del_mark_set_sec_rec( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to del mark table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), cursor->index->table_name, cursor->index->name); rec_print(rec); } diff --git a/innobase/include/btr0btr.ic b/innobase/include/btr0btr.ic index 16057d2c8a6..301a73b3444 100644 --- a/innobase/include/btr0btr.ic +++ b/innobase/include/btr0btr.ic @@ -203,7 +203,7 @@ btr_node_ptr_get_child_page_no( if (page_no == 0) { fprintf(stderr, "InnoDB: a nonsensical page number 0 in a node ptr record at offset %lu\n", - (ulint)(rec - buf_frame_align(rec))); + (unsigned long)(rec - buf_frame_align(rec))); buf_page_print(buf_frame_align(rec)); } diff --git a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic index 281bb1ea527..eb22bae7ff0 100644 --- a/innobase/include/buf0buf.ic +++ b/innobase/include/buf0buf.ic @@ -219,8 +219,8 @@ buf_block_align( "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: how to force recovery.\n", - (ulint)ptr, (ulint)frame_zero, - (ulint)(buf_pool->high_end)); + (long)ptr, (long)frame_zero, + (long)(buf_pool->high_end)); ut_a(0); } @@ -255,8 +255,8 @@ buf_frame_align( "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: how to force recovery.\n", - (ulint)ptr, (ulint)(buf_pool->frame_zero), - (ulint)(buf_pool->high_end)); + (long)ptr, (long)(buf_pool->frame_zero), + (long)(buf_pool->high_end)); ut_a(0); } diff --git a/innobase/include/row0sel.ic b/innobase/include/row0sel.ic index 9005624b6ca..994638790c0 100644 --- a/innobase/include/row0sel.ic +++ b/innobase/include/row0sel.ic @@ -77,7 +77,7 @@ open_step( if (err != DB_SUCCESS) { /* SQL error detected */ - printf("SQL error %lu\n", err); + printf("SQL error %lu\n", (unsigned long) err); ut_error; que_thr_handle_error(thr, err, NULL, 0); diff --git a/innobase/include/row0upd.ic b/innobase/include/row0upd.ic index 7015b2eda13..1878431d1a4 100644 --- a/innobase/include/row0upd.ic +++ b/innobase/include/row0upd.ic @@ -86,8 +86,8 @@ upd_field_set_field_no( fprintf(stderr, "InnoDB: Error: trying to access field %lu in table %s\n" "InnoDB: index %s, but index has only %lu fields\n", - field_no, index->table_name, index->name, - dict_index_get_n_fields(index)); + (unsigned long) field_no, index->table_name, index->name, + (unsigned long) dict_index_get_n_fields(index)); } dtype_copy(dfield_get_type(&(upd_field->new_val)), diff --git a/innobase/include/trx0rseg.ic b/innobase/include/trx0rseg.ic index 423447d5566..6b242b66c09 100644 --- a/innobase/include/trx0rseg.ic +++ b/innobase/include/trx0rseg.ic @@ -63,7 +63,7 @@ trx_rsegf_get_nth_undo( { if (n >= TRX_RSEG_N_SLOTS) { fprintf(stderr, - "InnoDB: Error: trying to get slot %lu of rseg\n", n); + "InnoDB: Error: trying to get slot %lu of rseg\n", (unsigned long) n); ut_a(0); } @@ -84,7 +84,7 @@ trx_rsegf_set_nth_undo( { if (n >= TRX_RSEG_N_SLOTS) { fprintf(stderr, - "InnoDB: Error: trying to set slot %lu of rseg\n", n); + "InnoDB: Error: trying to set slot %lu of rseg\n", (unsigned long) n); ut_a(0); } diff --git a/innobase/pars/pars0opt.c b/innobase/pars/pars0opt.c index 4faf83b47a3..9b0495a01cd 100644 --- a/innobase/pars/pars0opt.c +++ b/innobase/pars/pars0opt.c @@ -1235,7 +1235,8 @@ opt_print_query_plan( printf( "Table %s index %s; exact m. %lu, match %lu, end conds %lu\n", plan->table->name, plan->index->name, - plan->n_exact_match, n_fields, - UT_LIST_GET_LEN(plan->end_conds)); + (unsigned long) plan->n_exact_match, + (unsigned long) n_fields, + (unsigned long) UT_LIST_GET_LEN(plan->end_conds)); } } diff --git a/innobase/que/que0que.c b/innobase/que/que0que.c index 3f28a4b40a5..7e4babd43ef 100644 --- a/innobase/que/que0que.c +++ b/innobase/que/que0que.c @@ -513,7 +513,7 @@ que_graph_free_recursive( if (thr->magic_n != QUE_THR_MAGIC_N) { fprintf(stderr, "que_thr struct appears corrupt; magic n %lu\n", - thr->magic_n); + (unsigned long) thr->magic_n); mem_analyze_corruption((byte*)thr); ut_a(0); } @@ -625,7 +625,7 @@ que_graph_free_recursive( default: fprintf(stderr, "que_node struct appears corrupt; type %lu\n", - que_node_get_type(node)); + (unsigned long) que_node_get_type(node)); mem_analyze_corruption((byte*)node); ut_a(0); } @@ -1105,7 +1105,8 @@ 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", thr->magic_n); + "que_thr struct appears corrupt; magic n %lu\n", + (unsigned long) thr->magic_n); mem_analyze_corruption((byte*)thr); @@ -1141,7 +1142,8 @@ 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", thr->magic_n); + "que_thr struct appears corrupt; magic n %lu\n", + (unsigned long) thr->magic_n); mem_analyze_corruption((byte*)thr); @@ -1216,7 +1218,8 @@ que_node_print_info( str = (char *) "UNKNOWN NODE TYPE"; } - printf("Node type %lu: %s, address %lx\n", type, str, addr); + printf("Node type %lu: %s, address %lx\n", (unsigned long) type, str, + (unsigned long) addr); } /************************************************************************** diff --git a/myisam/mi_check.c b/myisam/mi_check.c index fd4c897983f..bd8c8c60e33 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -77,6 +77,7 @@ void myisamchk_init(MI_CHECK *param) param->tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL; param->myf_rw=MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL); param->start_check_pos=0; + param->max_record_length= LONGLONG_MAX; param->key_cache_block_size= KEY_CACHE_BLOCK_SIZE; } @@ -523,7 +524,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, if (!(temp_buff=(uchar*) my_alloca((uint) keyinfo->block_length))) { - mi_check_print_error(param,"Not Enough memory"); + mi_check_print_error(param,"Not enough memory for keyblock"); DBUG_RETURN(-1); } @@ -712,7 +713,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) if (!(record= (byte*) my_malloc(info->s->base.pack_reclength,MYF(0)))) { - mi_check_print_error(param,"Not Enough memory"); + mi_check_print_error(param,"Not enough memory for record"); DBUG_RETURN(-1); } records=del_blocks=0; @@ -815,16 +816,17 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) goto next; } mi_check_print_error(param,"Wrong bytesec: %d-%d-%d at linkstart: %s", - block_info.header[0],block_info.header[1], - block_info.header[2], - llstr(start_block,llbuff)); + block_info.header[0],block_info.header[1], + block_info.header[2], + llstr(start_block,llbuff)); goto err2; } if (info->state->data_file_length < block_info.filepos+ block_info.block_len) { - mi_check_print_error(param,"Recordlink that points outside datafile at %s", - llstr(pos,llbuff)); + mi_check_print_error(param, + "Recordlink that points outside datafile at %s", + llstr(pos,llbuff)); got_error=1; break; } @@ -835,9 +837,9 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) pos=block_info.filepos+block_info.block_len; if (block_info.rec_len > (uint) info->s->base.max_pack_length) { - mi_check_print_error(param,"Found too long record (%d) at %s", - block_info.rec_len, - llstr(start_recpos,llbuff)); + mi_check_print_error(param,"Found too long record (%lu) at %s", + (ulong) block_info.rec_len, + llstr(start_recpos,llbuff)); got_error=1; break; } @@ -846,8 +848,10 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) if (!(to= mi_alloc_rec_buff(info, block_info.rec_len, &info->rec_buff))) { - mi_check_print_error(param,"Not enough memory for blob at %s", - llstr(start_recpos,llbuff)); + mi_check_print_error(param, + "Not enough memory (%lu) for blob at %s", + (ulong) block_info.rec_len, + llstr(start_recpos,llbuff)); got_error=1; break; } @@ -858,9 +862,11 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) } if (left_length < block_info.data_len) { - mi_check_print_error(param,"Found too long record at %s", - llstr(start_recpos,llbuff)); - got_error=1; break; + mi_check_print_error(param,"Found too long record (%lu) at %s", + (ulong) block_info.data_len, + llstr(start_recpos,llbuff)); + got_error=1; + break; } if (_mi_read_cache(¶m->read_cache,(byte*) to,block_info.filepos, (uint) block_info.data_len, @@ -1167,7 +1173,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, MYF(0))) || !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff)) { - mi_check_print_error(param,"Not enough memory for extra record"); + mi_check_print_error(param, "Not enough memory for extra record"); goto err; } @@ -1630,7 +1636,7 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, if (!(buff=(uchar*) my_alloca((uint) keyinfo->block_length))) { - mi_check_print_error(param,"Not Enough memory"); + mi_check_print_error(param,"Not enough memory for key block"); DBUG_RETURN(-1); } if (!_mi_fetch_keypage(info,keyinfo,pagepos,DFLT_INIT_HITS,buff,0)) @@ -1842,7 +1848,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, MYF(0))) || !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff)) { - mi_check_print_error(param,"Not enough memory for extra record"); + mi_check_print_error(param, "Not enough memory for extra record"); goto err; } if (!rep_quick) @@ -2278,17 +2284,19 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, rec_length=share->base.min_block_length; else rec_length=share->base.pack_reclength; + /* + +1 below is required hack for parallel repair mode. + The info->state->records value, that is compared later + to sort_info.max_records and cannot exceed it, is + increased in sort_key_write. In mi_repair_by_sort, sort_key_write + is called after sort_key_read, where the comparison is performed, + but in parallel mode master thread can call sort_key_write + before some other repair thread calls sort_key_read. + Furthermore I'm not even sure +1 would be enough. + May be sort_info.max_records shold be always set to max value in + parallel mode. + */ sort_info.max_records= - /* +1 below is required hack for parallel repair mode. - The info->state->records value, that is compared later - to sort_info.max_records and cannot exceed it, is - increased in sort_key_write. In mi_repair_by_sort, sort_key_write - is called after sort_key_read, where the comparison is performed, - but in parallel mode master thread can call sort_key_write - before some other repair thread calls sort_key_read. - Furthermore I'm not even sure +1 would be enough. - May be sort_info.max_records shold be always set to max value in - parallel mode. */ ((param->testflag & T_CREATE_MISSING_KEYS) ? info->state->records + 1: (ha_rows) (sort_info.filelength/rec_length+1)); @@ -2302,7 +2310,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, (sizeof(MI_SORT_PARAM) + share->base.pack_reclength), MYF(MY_ZEROFILL)))) { - mi_check_print_error(param,"Not enough memory!"); + mi_check_print_error(param,"Not enough memory for key!"); goto err; } total_key_length=0; @@ -2858,9 +2866,20 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if (!(to=mi_alloc_rec_buff(info,block_info.rec_len, &(sort_param->rec_buff)))) { - mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)", - llstr(sort_param->start_recpos,llbuff), block_info.rec_len); - DBUG_RETURN(1); + if (param->max_record_length >= block_info.rec_len) + { + mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)", + llstr(sort_param->start_recpos,llbuff), + (ulong) block_info.rec_len); + DBUG_RETURN(1); + } + else + { + mi_check_print_info(param,"Not enough memory for blob at %s (need %lu); Row skipped", + llstr(sort_param->start_recpos,llbuff), + (ulong) block_info.rec_len); + goto try_next; + } } } else @@ -2868,14 +2887,16 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) } if (left_length < block_info.data_len || ! block_info.data_len) { - mi_check_print_info(param,"Found block with too small length at %s; Skipped", + mi_check_print_info(param, + "Found block with too small length at %s; Skipped", llstr(sort_param->start_recpos,llbuff)); goto try_next; } if (block_info.filepos + block_info.data_len > sort_param->read_cache.end_of_file) { - mi_check_print_info(param,"Found block that points outside data file at %s", + mi_check_print_info(param, + "Found block that points outside data file at %s", llstr(sort_param->start_recpos,llbuff)); goto try_next; } @@ -3510,7 +3531,7 @@ static SORT_KEY_BLOCKS *alloc_key_blocks(MI_CHECK *param, uint blocks, buffer_length+IO_SIZE)*blocks, MYF(0)))) { - mi_check_print_error(param,"Not Enough memory for sort-key-blocks"); + mi_check_print_error(param,"Not enough memory for sort-key-blocks"); return(0); } for (i=0 ; i < blocks ; i++) diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index f034d6ae406..61a1736c521 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -110,7 +110,8 @@ int main(int argc, char **argv) VOID(fflush(stderr)); if ((check_param.error_printed | check_param.warning_printed) && (check_param.testflag & T_FORCE_CREATE) && - (!(check_param.testflag & (T_REP | T_SORT_RECORDS | T_SORT_INDEX)))) + (!(check_param.testflag & (T_REP | T_REP_BY_SORT | T_SORT_RECORDS | + T_SORT_INDEX)))) { uint old_testflag=check_param.testflag; if (!(check_param.testflag & T_REP)) @@ -153,7 +154,7 @@ enum options_mc { OPT_KEY_CACHE_BLOCK_SIZE, OPT_MYISAM_BLOCK_SIZE, OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE, OPT_SORT_KEY_BLOCKS, OPT_DECODE_BITS, OPT_FT_MIN_WORD_LEN, - OPT_FT_MAX_WORD_LEN, OPT_FT_MAX_WORD_LEN_FOR_SORT + OPT_FT_MAX_WORD_LEN, OPT_FT_MAX_WORD_LEN_FOR_SORT, OPT_MAX_RECORD_LENGTH }; static struct my_option my_long_options[] = @@ -215,6 +216,11 @@ static struct my_option my_long_options[] = (gptr*) &check_param.keys_in_use, (gptr*) &check_param.keys_in_use, 0, GET_ULL, REQUIRED_ARG, -1, 0, 0, 0, 0, 0}, + {"max-record-length", OPT_MAX_RECORD_LENGTH, + "Skip rows bigger than this if myisamchk can't allocate memory to hold it", + (gptr*) &check_param.max_record_length, + (gptr*) &check_param.max_record_length, + 0, GET_ULL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0}, {"medium-check", 'm', "Faster than extend-check, but only finds 99.99% of all errors. Should be good enough for most cases.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -327,7 +333,7 @@ static struct my_option my_long_options[] = static void print_version(void) { - printf("%s Ver 2.6 for %s at %s\n", my_progname, SYSTEM_TYPE, + printf("%s Ver 2.7 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); } @@ -394,6 +400,9 @@ static void usage(void) -k, --keys-used=# Tell MyISAM to update only some specific keys. # is a\n\ bit mask of which keys to use. This can be used to\n\ get faster inserts.\n\ + --max-record-length=#\n\ + Skip rows bigger than this if myisamchk can't allocate\n\ + memory to hold it.\n\ -r, --recover Can fix almost anything except unique keys that aren't\n\ unique.\n\ -n, --sort-recover Forces recovering with sorting even if the temporary\n\ diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 28f06f0bf47..a3a47ea6952 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1,4 +1,5 @@ drop table if exists t1,t2,t3; +drop database if exists test_$1; create table t1 (b char(0)); insert into t1 values (""),(null); select * from t1; @@ -302,9 +303,6 @@ t3 CREATE TABLE `t3` ( select * from t3; id name drop table t2, t3; -drop database if exists test_$1; -Warnings: -Note 1008 Can't drop database 'test_$1'; database doesn't exist create database test_$1; create table test_$1.t3 like t1; create temporary table t3 like test_$1.t3; @@ -411,7 +409,6 @@ a b c d e f g h dd 1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00 2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00 drop table t1, t2; -drop database if exists test_$1; create database test_$1; use test_$1; select database(); diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 0c1280751bc..dc4d2701bee 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -4,6 +4,7 @@ --disable_warnings drop table if exists t1,t2,t3; +drop database if exists test_$1; --enable_warnings create table t1 (b char(0)); @@ -57,6 +58,7 @@ select 1ea10.1a20,1e+ 1e+10 from 1ea10; drop table 1ea10; create table t1 (t1.index int); drop table t1; +# Test that we get warning for this drop database if exists test_$1; create database test_$1; create table test_$1.$test1 (a$1 int, $b int, c$ int); @@ -245,7 +247,6 @@ drop table t3; show create table t3; select * from t3; drop table t2, t3; -drop database if exists test_$1; create database test_$1; create table test_$1.t3 like t1; create temporary table t3 like test_$1.t3; @@ -326,9 +327,6 @@ drop table t1, t2; # Bug #1209 # ---disable_warnings -drop database if exists test_$1; ---enable_warnings create database test_$1; use test_$1; select database(); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 31ef4f7b7d7..11870e4cc29 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1536,7 +1536,7 @@ ha_innobase::open( fprintf(stderr, "InnoDB: Warning: table %s key_used_on_scan is %lu even though there is no\n" "InnoDB: primary key inside InnoDB.\n", - name, (ulint)key_used_on_scan); + name, (ulong)key_used_on_scan); } } @@ -3216,7 +3216,7 @@ ha_innobase::position( if (len != ref_length) { fprintf(stderr, "InnoDB: Error: stored ref len is %lu, but table ref len is %lu\n", - (ulint)len, (ulint)ref_length); + (ulong)len, (ulong)ref_length); } } @@ -4187,7 +4187,8 @@ ha_innobase::info( "InnoDB: .frm files from different installations? See section\n" "InnoDB: 15.1 at http://www.innodb.com/ibman.html\n", index->name, - ib_table->name, index->n_uniq, + ib_table->name, + (unsigned long) index->n_uniq, j + 1); break; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 2a07341d97a..54bdfb9dab3 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2701,6 +2701,7 @@ void Item_func_match::init_search(bool no_order) bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) { Item *item; + LINT_INIT(item); // Safe as arg_count is > 1 maybe_null=1; join_key=0; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a0b5d910986..b811c4a4b67 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3320,35 +3320,22 @@ extern "C" pthread_handler_decl(handle_connections_namedpipes,arg) #ifdef HAVE_SMEM pthread_handler_decl(handle_connections_shared_memory,arg) { -/* - event_connect_request is event object for start connection actions - event_connect_answer is event object for confirm, that server put data - handle_connect_file_map is file-mapping object, use for create shared memory - handle_connect_map is pointer on shared memory - handle_map is pointer on shared memory for client - event_server_wrote, - event_server_read, - event_client_wrote, - event_client_read are events for transfer data between server and client - handle_file_map is file-mapping object, use for create shared memory -*/ - HANDLE handle_connect_file_map = NULL; - char *handle_connect_map = NULL; - HANDLE event_connect_request = NULL; - HANDLE event_connect_answer = NULL; - ulong smem_buffer_length = shared_memory_buffer_length + 4; - ulong connect_number = 1; + /* file-mapping object, use for create shared memory */ + HANDLE handle_connect_file_map= 0; + char *handle_connect_map= 0; // pointer on shared memory + HANDLE event_connect_request= 0; // for start connection actions + HANDLE event_connect_answer= 0; + ulong smem_buffer_length= shared_memory_buffer_length + 4; + ulong connect_number= 1; my_bool error_allow; - THD *thd; char tmp[63]; char *suffix_pos; char connect_number_char[22], *p; - + const char *errmsg= 0; my_thread_init(); DBUG_ENTER("handle_connections_shared_memorys"); DBUG_PRINT("general",("Waiting for allocated shared memory.")); - /* The name of event and file-mapping events create agree next rule: shared_memory_base_name+unique_part @@ -3356,166 +3343,165 @@ pthread_handler_decl(handle_connections_shared_memory,arg) shared_memory_base_name is unique value for each server unique_part is unique value for each object (events and file-mapping) */ - suffix_pos = strxmov(tmp,shared_memory_base_name,"_",NullS); + suffix_pos= strxmov(tmp,shared_memory_base_name,"_",NullS); strmov(suffix_pos, "CONNECT_REQUEST"); - if ((event_connect_request = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_connect_request= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create shared memory service ! The request event don't create."); + errmsg= "Could not create request event"; goto error; } strmov(suffix_pos, "CONNECT_ANSWER"); - if ((event_connect_answer = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_connect_answer= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create shared memory service ! The answer event don't create."); + errmsg="Could not create answer event"; goto error; } strmov(suffix_pos, "CONNECT_DATA"); - if ((handle_connect_file_map = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE, - 0,sizeof(connect_number),tmp)) == 0) + if ((handle_connect_file_map= CreateFileMapping(INVALID_HANDLE_VALUE,0, + PAGE_READWRITE, + 0,sizeof(connect_number), + tmp)) == 0) { - sql_perror("Can't create shared memory service ! File mapping don't create."); + errmsg= "Could not create file mapping"; goto error; } - if ((handle_connect_map = (char *)MapViewOfFile(handle_connect_file_map,FILE_MAP_WRITE,0,0, - sizeof(DWORD))) == 0) + if ((handle_connect_map= (char *)MapViewOfFile(handle_connect_file_map, + FILE_MAP_WRITE,0,0, + sizeof(DWORD))) == 0) { - sql_perror("Can't create shared memory service ! Map of memory don't create."); + errmsg= "Could not create shared memory service"; goto error; } - while (!abort_loop) { -/* - Wait a request from client -*/ + /* Wait a request from client */ WaitForSingleObject(event_connect_request,INFINITE); - error_allow = FALSE; - HANDLE handle_client_file_map = NULL; - char *handle_client_map = NULL; - HANDLE event_client_wrote = NULL; - HANDLE event_client_read = NULL; - HANDLE event_server_wrote = NULL; - HANDLE event_server_read = NULL; + HANDLE handle_client_file_map= 0; + char *handle_client_map= 0; + HANDLE event_client_wrote= 0; + HANDLE event_client_read= 0; // for transfer data server <-> client + HANDLE event_server_wrote= 0; + HANDLE event_server_read= 0; + THD *thd= 0; - p = int2str(connect_number, connect_number_char, 10); -/* - The name of event and file-mapping events create agree next rule: - shared_memory_base_name+unique_part+number_of_connection - Where: - shared_memory_base_name is uniquel value for each server - unique_part is unique value for each object (events and file-mapping) - number_of_connection is number of connection between server and client -*/ - suffix_pos = strxmov(tmp,shared_memory_base_name,"_",connect_number_char,"_",NullS); + p= int2str(connect_number, connect_number_char, 10); + /* + The name of event and file-mapping events create agree next rule: + shared_memory_base_name+unique_part+number_of_connection + Where: + shared_memory_base_name is uniquel value for each server + unique_part is unique value for each object (events and file-mapping) + number_of_connection is connection-number between server and client + */ + suffix_pos= strxmov(tmp,shared_memory_base_name,"_",connect_number_char, + "_",NullS); strmov(suffix_pos, "DATA"); - if ((handle_client_file_map = CreateFileMapping(INVALID_HANDLE_VALUE,NULL, - PAGE_READWRITE,0,smem_buffer_length,tmp)) == 0) + if ((handle_client_file_map= CreateFileMapping(INVALID_HANDLE_VALUE,0, + PAGE_READWRITE,0, + smem_buffer_length, + tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! File mapping don't create."); - error_allow = TRUE; + errmsg= "Could not create file mapping"; goto errorconn; } - if ((handle_client_map = (char*)MapViewOfFile(handle_client_file_map,FILE_MAP_WRITE,0,0,smem_buffer_length)) == 0) + if ((handle_client_map= (char*)MapViewOfFile(handle_client_file_map, + FILE_MAP_WRITE,0,0, + smem_buffer_length)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! Map of memory don't create."); - error_allow = TRUE; + errmsg= "Could not create memory map"; goto errorconn; } - strmov(suffix_pos, "CLIENT_WROTE"); - if ((event_client_wrote = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_client_wrote= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! CW event don't create."); - error_allow = TRUE; + errmsg= "Could not create client write event"; goto errorconn; } - strmov(suffix_pos, "CLIENT_READ"); - if ((event_client_read = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_client_read= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! CR event don't create."); - error_allow = TRUE; + errmsg= "Could not create client read event"; goto errorconn; } - strmov(suffix_pos, "SERVER_READ"); - if ((event_server_read = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_server_read= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! SR event don't create."); - error_allow = TRUE; + errmsg= "Could not create server read event"; goto errorconn; } - strmov(suffix_pos, "SERVER_WROTE"); - if ((event_server_wrote = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_server_wrote= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! SW event don't create."); - error_allow = TRUE; + errmsg= "Could not create server write event"; goto errorconn; } - - if (abort_loop) break; - if ( !(thd = new THD)) - { - error_allow = TRUE; + if (abort_loop) goto errorconn; - } - -/* -Send number of connection to client -*/ + if (!(thd= new THD)) + goto errorconn; + /* Send number of connection to client */ int4store(handle_connect_map, connect_number); - -/* - Send number of connection to client -*/ if (!SetEvent(event_connect_answer)) { - sql_perror("Can't create connection with client in shared memory service ! Can't send answer event."); - error_allow = TRUE; + errmsg= "Could not send answer event"; goto errorconn; } - -/* - Set event that client should receive data -*/ + /* Set event that client should receive data */ if (!SetEvent(event_client_read)) { - sql_perror("Can't create connection with client in shared memory service ! Can't set client to read's mode."); - error_allow = TRUE; + errmsg= "Could not set client to read mode"; goto errorconn; } - if (!(thd->net.vio = vio_new_win32shared_memory(&thd->net,handle_client_file_map,handle_client_map,event_client_wrote, - event_client_read,event_server_wrote,event_server_read)) || - my_net_init(&thd->net, thd->net.vio)) + if (!(thd->net.vio= vio_new_win32shared_memory(&thd->net, + handle_client_file_map, + handle_client_map, + event_client_wrote, + event_client_read, + event_server_wrote, + event_server_read)) || + my_net_init(&thd->net, thd->net.vio)) { close_connection(thd, ER_OUT_OF_RESOURCES, 1); - delete thd; - error_allow = TRUE; + errmsg= 0; + goto errorconn; } - /* host name is unknown */ -errorconn: - if (error_allow) - { - if (!handle_client_map) UnmapViewOfFile(handle_client_map); - if (!handle_client_file_map) CloseHandle(handle_client_file_map); - if (!event_server_wrote) CloseHandle(event_server_wrote); - if (!event_server_read) CloseHandle(event_server_read); - if (!event_client_wrote) CloseHandle(event_client_wrote); - if (!event_client_read) CloseHandle(event_client_read); - continue; - } - thd->host = my_strdup(my_localhost,MYF(0)); /* Host is unknown */ + thd->host= my_strdup(my_localhost,MYF(0)); /* Host is unknown */ create_new_thread(thd); - uint4korr(connect_number++); + connect_number++; + continue; + +errorconn: + /* Could not form connection; Free used handlers/memort and retry */ + if (errmsg) + { + char buff[180]; + strxmov(buff, "Can't create shared memory connection: ", errmsg, ".", + NullS); + sql_perror(buff); + } + if (handle_client_file_map) CloseHandle(handle_client_file_map); + if (handle_client_map) UnmapViewOfFile(handle_client_map); + if (event_server_wrote) CloseHandle(event_server_wrote); + if (event_server_read) CloseHandle(event_server_read); + if (event_client_wrote) CloseHandle(event_client_wrote); + if (event_client_read) CloseHandle(event_client_read); + delete thd; } + + /* End shared memory handling */ error: - if (!handle_connect_map) UnmapViewOfFile(handle_connect_map); - if (!handle_connect_file_map) CloseHandle(handle_connect_file_map); - if (!event_connect_answer) CloseHandle(event_connect_answer); - if (!event_connect_request) CloseHandle(event_connect_request); + if (errmsg) + { + char buff[180]; + strxmov(buff, "Can't create shared memory service: ", errmsg, ".", NullS); + sql_perror(buff); + } + if (handle_connect_map) UnmapViewOfFile(handle_connect_map); + if (handle_connect_file_map) CloseHandle(handle_connect_file_map); + if (event_connect_answer) CloseHandle(event_connect_answer); + if (event_connect_request) CloseHandle(event_connect_request); decrement_handler_count(); DBUG_RETURN(0); diff --git a/strings/bmove512.c b/strings/bmove512.c index 30ac4b744b6..d4c748fe0ff 100644 --- a/strings/bmove512.c +++ b/strings/bmove512.c @@ -37,7 +37,7 @@ #define LONG ulonglong #endif -void bmove512(register gptr to, register const gptr from, register uint length) +void bmove512(gptr to, const gptr from, register uint length) { reg1 LONG *f,*t,*end= (LONG*) ((char*) from+length); From 05e5a35bf2db80d8c880618ad9424a8a52b31f13 Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot2" <> Date: Sun, 23 Nov 2003 17:02:59 +0100 Subject: [PATCH 37/89] Replication: Now the I/O thread (in flush_master_info()) flushes the relay log to disk after reading every event. Slower but provides additionnal safety in case of brutal crash. I had to make the flush optional (i.e. add a if(some_bool_argument) in the function) because sometimes flush_master_info() is called when there is no usable relay log (the relay log's IO_CACHE is not initialized so can't be flushed). --- mysql-test/r/rpl_loaddata_rule_m.result | 2 +- mysql-test/t/rpl_loaddata_rule_m.test | 2 +- sql/repl_failsafe.cc | 7 +++- sql/slave.cc | 51 ++++++++++--------------- sql/slave.h | 2 +- sql/sql_repl.cc | 7 +++- 6 files changed, 35 insertions(+), 36 deletions(-) diff --git a/mysql-test/r/rpl_loaddata_rule_m.result b/mysql-test/r/rpl_loaddata_rule_m.result index ed0c96bbfe1..a34453b0a2b 100644 --- a/mysql-test/r/rpl_loaddata_rule_m.result +++ b/mysql-test/r/rpl_loaddata_rule_m.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; drop database if exists mysqltest; -reset master; +stop slave; create database mysqltest; create table t1(a int, b int, unique(b)); use mysqltest; diff --git a/mysql-test/t/rpl_loaddata_rule_m.test b/mysql-test/t/rpl_loaddata_rule_m.test index ec3a9259e32..678dae13889 100644 --- a/mysql-test/t/rpl_loaddata_rule_m.test +++ b/mysql-test/t/rpl_loaddata_rule_m.test @@ -9,7 +9,7 @@ drop database if exists mysqltest; --enable_warnings connection slave; -reset master; +stop slave; # don't need slave for this test # Test logging on master diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 0d2da91e015..084f7386b7b 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -908,7 +908,12 @@ int load_master_data(THD* thd) // don't hit the magic number if (active_mi->master_log_pos < BIN_LOG_HEADER_SIZE) active_mi->master_log_pos = BIN_LOG_HEADER_SIZE; - flush_master_info(active_mi); + /* + Relay log's IO_CACHE may not be inited (even if we are sure that some + host was specified; there could have been a problem when replication + started, which led to relay log's IO_CACHE to not be inited. + */ + flush_master_info(active_mi, 0); } mysql_free_result(master_status_res); } diff --git a/sql/slave.cc b/sql/slave.cc index ae524db5511..5fab217762c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1107,7 +1107,7 @@ static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi) break; default: /* 5.0 is not supported */ - errmsg = "Master reported an unrecognized MySQL version. Note that 4.0 \ + errmsg = "Master reported an unrecognized MySQL version. Note that 4.1 \ slaves can't replicate a 5.0 or newer master."; break; } @@ -1368,32 +1368,9 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) } /* - The relay log will now be opened, as a SEQ_READ_APPEND IO_CACHE. It is - notable that the last kilobytes of it (8 kB for example) may live in - memory, not on disk (depending on what the thread using it does). While - this is efficient, it has a side-effect one must know: - The size of the relay log on disk (displayed by 'ls -l' on Unix) can be a - few kilobytes less than one would expect by doing SHOW SLAVE STATUS; this - happens when only the IO thread is started (not the SQL thread). The - "missing" kilobytes are in memory, are preserved during 'STOP SLAVE; START - SLAVE IO_THREAD', and are flushed to disk when the slave's mysqld stops. So - this does not cause any bug. Example of how disk size grows by leaps: - - Read_Master_Log_Pos: 7811 -rw-rw---- 1 guilhem qq 4 Jun 5 16:19 gbichot2-relay-bin.002 - ...later... - Read_Master_Log_Pos: 9744 -rw-rw---- 1 guilhem qq 8192 Jun 5 16:27 gbichot2-relay-bin.002 - - See how 4 is less than 7811 and 8192 is less than 9744. - - WARNING: this is risky because the slave can stay like this for a long - time; then if it has a power failure, master.info says the I/O thread has - read until 9744 while the relay-log contains only until 8192 (the - in-memory part from 8192 to 9744 has been lost), so the SQL slave thread - will miss some events, silently breaking replication. - Ideally we would like to flush master.info only when we know that the relay - log has no in-memory tail. - Note that the above problem may arise only when only the IO thread is - started, which is unlikely. + The relay log will now be opened, as a SEQ_READ_APPEND IO_CACHE. + Note that the I/O thread flushes it to disk after writing every event, in + flush_master_info(mi, 1). */ /* @@ -1850,7 +1827,7 @@ file '%s')", fname); mi->inited = 1; // now change cache READ -> WRITE - must do this before flush_master_info reinit_io_cache(&mi->file, WRITE_CACHE,0L,0,1); - if ((error=test(flush_master_info(mi)))) + if ((error=test(flush_master_info(mi, 1)))) sql_print_error("Failed to flush master info file"); pthread_mutex_unlock(&mi->data_lock); DBUG_RETURN(error); @@ -2100,7 +2077,7 @@ int show_master_info(THD* thd, MASTER_INFO* mi) } -bool flush_master_info(MASTER_INFO* mi) +bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache) { IO_CACHE* file = &mi->file; char lbuf[22]; @@ -2124,6 +2101,20 @@ bool flush_master_info(MASTER_INFO* mi) (int)(mi->ssl), mi->ssl_ca, mi->ssl_capath, mi->ssl_cert, mi->ssl_cipher, mi->ssl_key); flush_io_cache(file); + /* + Flush the relay log to disk. If we don't do it, then the relay log while + have some part (its last kilobytes) in memory only, so if the slave server + dies now, with, say, from master's position 100 to 150 in memory only (not + on disk), and with position 150 in master.info, then when the slave + restarts, the I/O thread will fetch binlogs from 150, so in the relay log + we will have "[0, 100] U [150, infinity[" and nobody will notice it, so the + SQL thread will jump from 100 to 150, and replication will silently break. + + When we come to this place in code, relay log may or not be initialized; + the caller is responsible for setting 'flush_relay_log_cache' accordingly. + */ + if (flush_relay_log_cache) + flush_io_cache(mi->rli.relay_log.get_log_file()); DBUG_RETURN(0); } @@ -2982,7 +2973,7 @@ reconnect done to recover from failed read"); sql_print_error("Slave I/O thread could not queue event from master"); goto err; } - flush_master_info(mi); + flush_master_info(mi, 1); /* sure that we can flush the relay log */ /* See if the relay logs take too much space. We don't lock mi->rli.log_space_lock here; this dirty read saves time diff --git a/sql/slave.h b/sql/slave.h index f8093826f58..e42b93a47ef 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -461,7 +461,7 @@ typedef struct st_table_rule_ent int init_slave(); void init_slave_skip_errors(const char* arg); -bool flush_master_info(MASTER_INFO* mi); +bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache); bool flush_relay_log_info(RELAY_LOG_INFO* rli); int register_slave_on_master(MYSQL* mysql); int terminate_slave_threads(MASTER_INFO* mi, int thread_mask, diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index c30409fd0cb..3c477afa300 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1085,8 +1085,11 @@ int change_master(THD* thd, MASTER_INFO* mi) strmake(mi->master_log_name, mi->rli.group_master_log_name, sizeof(mi->master_log_name)-1); } - - flush_master_info(mi); + /* + Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never + a slave before). + */ + flush_master_info(mi, 0); if (need_relay_log_purge) { relay_log_purge= 1; From 5dca5c7d53da389c740971780d1410a19471c1f9 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Sun, 23 Nov 2003 21:03:10 +0200 Subject: [PATCH 38/89] Fix test for binary builds --- mysql-test/r/rpl_change_master.result | 6 +++--- mysql-test/t/rpl_change_master.test | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result index be2aec616b0..966f07af9d5 100644 --- a/mysql-test/r/rpl_change_master.result +++ b/mysql-test/r/rpl_change_master.result @@ -8,7 +8,7 @@ select get_lock("a",5); get_lock("a",5) 1 create table t1(n int); -insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(1+get_lock("a",15)*0); insert into t1 values(2); stop slave; select * from t1; @@ -16,11 +16,11 @@ n 1 show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root 9306 1 master-bin.001 273 slave-relay-bin.002 255 master-bin.001 No No 0 0 214 314 +127.0.0.1 root MASTER_MYPORT 1 master-bin.001 273 slave-relay-bin.002 255 master-bin.001 No No 0 0 214 314 change master to master_user='root'; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root 9306 1 master-bin.001 214 slave-relay-bin.001 4 master-bin.001 No No 0 0 214 4 +127.0.0.1 root MASTER_MYPORT 1 master-bin.001 214 slave-relay-bin.001 4 master-bin.001 No No 0 0 214 4 select release_lock("a"); release_lock("a") 1 diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test index 61de22fe57b..a13e045cf48 100644 --- a/mysql-test/t/rpl_change_master.test +++ b/mysql-test/t/rpl_change_master.test @@ -4,15 +4,17 @@ connection slave; select get_lock("a",5); connection master; create table t1(n int); -insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(1+get_lock("a",15)*0); insert into t1 values(2); save_master_pos; connection slave; -sleep 3; # can't sync_with_master as we should be blocked +--real_sleep 3; # can't sync_with_master as we should be blocked stop slave; select * from t1; +--replace_result $MASTER_MYPORT MASTER_MYPORT show slave status; change master to master_user='root'; +--replace_result $MASTER_MYPORT MASTER_MYPORT show slave status; # Will restart from after the values(2), which is bug select release_lock("a"); From afe48d3ce4c649ec69dc2068339183791a33cc9c Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Sun, 23 Nov 2003 21:26:43 +0200 Subject: [PATCH 39/89] after review fixes --- mysql-test/r/union.result | 30 ++++++++-- mysql-test/t/union.test | 12 +++- sql/field.cc | 122 ++++++++++++++++++++++++++++++++++++++ sql/field.h | 82 +++++++++++-------------- sql/item.cc | 54 +++++++---------- sql/sql_derived.cc | 2 +- sql/sql_lex.h | 8 ++- 7 files changed, 223 insertions(+), 87 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index cf5920481b2..16640c78cb8 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -556,8 +556,8 @@ t1 CREATE TABLE `t1` ( `a` double(4,1) NOT NULL default '0.0' ) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; -create table t2 (it1 tinyint, it2 tinyint not null, i int not null, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob); -insert into t2 values (NULL, 1, 3, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest'); +create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob); +insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest'); create table t1 SELECT it2 from t2 UNION select it1 from t2; select * from t1; it2 @@ -588,7 +588,7 @@ i show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `i` float default NULL + `i` double default NULL ) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT f from t2 UNION select d from t2; @@ -602,6 +602,28 @@ t1 CREATE TABLE `t1` ( `f` double default NULL ) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +create table t1 SELECT ib from t2 UNION select f from t2; +select * from t1; +ib +4 +1.5 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ib` double default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT ib from t2 UNION select d from t2; +select * from t1; +ib +4 +2.5 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ib` double default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; create table t1 SELECT f from t2 UNION select y from t2; select * from t1; f @@ -610,7 +632,7 @@ f show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `f` double default NULL + `f` float default NULL ) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT f from t2 UNION select da from t2; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index af511d18ecc..9e02daf22fa 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -321,8 +321,8 @@ select * from t1; show create table t1; drop table t1; -create table t2 (it1 tinyint, it2 tinyint not null, i int not null, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob); -insert into t2 values (NULL, 1, 3, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest'); +create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob); +insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest'); create table t1 SELECT it2 from t2 UNION select it1 from t2; select * from t1; @@ -340,6 +340,14 @@ create table t1 SELECT f from t2 UNION select d from t2; select * from t1; show create table t1; drop table t1; +create table t1 SELECT ib from t2 UNION select f from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT ib from t2 UNION select d from t2; +select * from t1; +show create table t1; +drop table t1; create table t1 SELECT f from t2 UNION select y from t2; select * from t1; show create table t1; diff --git a/sql/field.cc b/sql/field.cc index 70b8ce6c080..9b8e386fdc5 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -169,6 +169,128 @@ static inline uint field_length_without_space(const char *ptr, uint length) return (uint) (end-ptr); } +/* + Tables of filed type compatibility. + + There are tables for every type, table consist of list of types in which + given type can be converted without data lost, list should be ended with + FIELD_CAST_STOP +*/ +static Field::field_cast_enum field_cast_decimal[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_tiny[]= +{Field::FIELD_CAST_SHORT, Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, + Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_short[]= +{Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_medium[]= +{Field::FIELD_CAST_LONG, Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_long[]= +{Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_longlong[]= +{Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_float[]= +{Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_double[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_null[]= +{Field::FIELD_CAST_DECIMAL, Field::FIELD_CAST_TINY, Field::FIELD_CAST_SHORT, + Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_TIMESTAMP, Field::FIELD_CAST_YEAR, + Field::FIELD_CAST_DATE, Field::FIELD_CAST_NEWDATE, + Field::FIELD_CAST_TIME, Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, + Field::FIELD_CAST_GEOM, Field::FIELD_CAST_ENUM, Field::FIELD_CAST_SET, + Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_timestamp[]= +{Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_year[]= +{Field::FIELD_CAST_SHORT, Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, + Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_date[]= +{Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_newdate[]= +{Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_time[]= +{Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_datetime[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_string[]= +{Field::FIELD_CAST_VARSTRING, Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_varstring[]= +{Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_blob[]= +{Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_geom[]= +{Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_enum[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_set[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +// Array of pointers on conversion table for all fields types casting +static Field::field_cast_enum *field_cast_array[]= +{0, //FIELD_CAST_STOP + field_cast_decimal, field_cast_tiny, field_cast_short, + field_cast_medium, field_cast_long, field_cast_longlong, + field_cast_float, field_cast_double, + field_cast_null, + field_cast_timestamp, field_cast_year, field_cast_date, field_cast_newdate, + field_cast_time, field_cast_datetime, + field_cast_string, field_cast_varstring, field_cast_blob, + field_cast_geom, field_cast_enum, field_cast_set +}; + + +bool Field::field_cast_compatible(Field::field_cast_enum type) +{ + DBUG_ASSERT(type != FIELD_CAST_STOP); + Field::field_cast_enum *array= field_cast_array[field_cast_type()]; + uint i= 0; + Field::field_cast_enum tp; + do + { + tp= array[i++]; + if (tp == type) + return 1; + } while (tp != FIELD_CAST_STOP); + return 0; +} + + /**************************************************************************** ** Functions for the base classes ** This is an unpacked number. diff --git a/sql/field.h b/sql/field.h index ef6920f4d89..cb44ab76439 100644 --- a/sql/field.h +++ b/sql/field.h @@ -61,6 +61,17 @@ public: GEOM_GEOMETRYCOLLECTION = 7 }; enum imagetype { itRAW, itMBR}; + enum field_cast_enum + { + FIELD_CAST_STOP, FIELD_CAST_DECIMAL, FIELD_CAST_TINY, FIELD_CAST_SHORT, + FIELD_CAST_MEDIUM, FIELD_CAST_LONG, FIELD_CAST_LONGLONG, + FIELD_CAST_FLOAT, FIELD_CAST_DOUBLE, + FIELD_CAST_NULL, + FIELD_CAST_TIMESTAMP, FIELD_CAST_YEAR, FIELD_CAST_DATE, FIELD_CAST_NEWDATE, + FIELD_CAST_TIME, FIELD_CAST_DATETIME, + FIELD_CAST_STRING, FIELD_CAST_VARSTRING, FIELD_CAST_BLOB, + FIELD_CAST_GEOM, FIELD_CAST_ENUM, FIELD_CAST_SET + }; utype unireg_check; uint32 field_length; // Length of field @@ -230,24 +241,8 @@ public: virtual bool has_charset(void) const { return FALSE; } virtual void set_charset(CHARSET_INFO *charset) { } void set_warning(const unsigned int level, const unsigned int code); - /* - number which describe preferences of field type converion, - for example, if we have int and float, float is prefered as more general - - ennumiration begins from: - 100 for int types - 300 for float point - 500 time/date - 700 string - */ - virtual uint convert_order()= 0; - /* - Is this type is compatible with given - (given can be stored in it) - Should take care only of types 'less' then current - */ - virtual bool convert_order_compatible(uint order) { return 0; } - + virtual field_cast_enum field_cast_type()= 0; + bool field_cast_compatible(field_cast_enum type); friend bool reopen_table(THD *,struct st_table *,bool); friend int cre_myisam(my_string name, register TABLE *form, uint options, ulonglong auto_increment_value); @@ -352,7 +347,7 @@ public: void overflow(bool negative); bool zero_pack() const { return 0; } void sql_type(String &str) const; - uint convert_order() { return 130; } + field_cast_enum field_cast_type() { return FIELD_CAST_DECIMAL; } }; @@ -388,7 +383,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 1; } void sql_type(String &str) const; - uint convert_order() { return 100; } + field_cast_enum field_cast_type() { return FIELD_CAST_TINY; } }; @@ -424,7 +419,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 2; } void sql_type(String &str) const; - uint convert_order() { return 101; } + field_cast_enum field_cast_type() { return FIELD_CAST_SHORT; } }; @@ -455,7 +450,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 3; } void sql_type(String &str) const; - uint convert_order() { return 102; } + field_cast_enum field_cast_type() { return FIELD_CAST_MEDIUM; } }; @@ -491,7 +486,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 4; } void sql_type(String &str) const; - uint convert_order() { return 103; } + field_cast_enum field_cast_type() { return FIELD_CAST_LONG; } }; @@ -530,7 +525,7 @@ public: uint32 pack_length() const { return 8; } void sql_type(String &str) const; bool store_for_compare() { return 1; } - uint convert_order() { return 104; } + field_cast_enum field_cast_type() { return FIELD_CAST_LONGLONG; } }; #endif @@ -564,7 +559,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return sizeof(float); } void sql_type(String &str) const; - uint convert_order() { return 300; } + field_cast_enum field_cast_type() { return FIELD_CAST_FLOAT; } }; @@ -598,7 +593,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return sizeof(double); } void sql_type(String &str) const; - uint convert_order() { return 301; } + field_cast_enum field_cast_type() { return FIELD_CAST_DOUBLE; } }; @@ -632,7 +627,7 @@ public: uint32 pack_length() const { return 0; } void sql_type(String &str) const; uint size_of() const { return sizeof(*this); } - uint convert_order() { return 0; } + field_cast_enum field_cast_type() { return FIELD_CAST_NULL; } }; @@ -676,8 +671,7 @@ public: } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); - uint convert_order() { return 520; } - bool convert_order_compatible(uint ord) { return ord<520; } + field_cast_enum field_cast_type() { return FIELD_CAST_TIMESTAMP; } }; @@ -703,8 +697,7 @@ public: String *val_str(String*,String *); bool send_binary(Protocol *protocol); void sql_type(String &str) const; - uint convert_order() { return 501; } - bool convert_order_compatible(uint ord) { return ord<520; } + field_cast_enum field_cast_type() { return FIELD_CAST_YEAR; } }; @@ -737,8 +730,7 @@ public: void sql_type(String &str) const; bool store_for_compare() { return 1; } bool zero_pack() const { return 1; } - uint convert_order() { return 502; } - bool convert_order_compatible(uint ord) { return ord<520; } + field_cast_enum field_cast_type() { return FIELD_CAST_DATE; } }; class Field_newdate :public Field_str { @@ -770,8 +762,7 @@ public: bool zero_pack() const { return 1; } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); - uint convert_order() { return 503; } - bool convert_order_compatible(uint ord) { return ord<520; } + field_cast_enum field_cast_type() { return FIELD_CAST_NEWDATE; } }; @@ -805,8 +796,7 @@ public: void sql_type(String &str) const; bool store_for_compare() { return 1; } bool zero_pack() const { return 1; } - uint convert_order() { return 504; } - bool convert_order_compatible(uint ord) { return ord<520; } + field_cast_enum field_cast_type() { return FIELD_CAST_TIME; } }; @@ -844,8 +834,7 @@ public: bool zero_pack() const { return 1; } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); - uint convert_order() { return 530; } - bool convert_order_compatible(uint ord) { return ord<=501; } + field_cast_enum field_cast_type() { return FIELD_CAST_DATETIME; } }; @@ -890,7 +879,7 @@ public: uint size_of() const { return sizeof(*this); } enum_field_types real_type() const { return FIELD_TYPE_STRING; } bool has_charset(void) const { return TRUE; } - uint convert_order() { return 700; } + field_cast_enum field_cast_type() { return FIELD_CAST_STRING; } }; @@ -934,7 +923,7 @@ public: uint size_of() const { return sizeof(*this); } enum_field_types real_type() const { return FIELD_TYPE_VAR_STRING; } bool has_charset(void) const { return TRUE; } - uint convert_order() { return 701; } + field_cast_enum field_cast_type() { return FIELD_CAST_VARSTRING; } }; @@ -1024,7 +1013,7 @@ public: uint size_of() const { return sizeof(*this); } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } - uint convert_order() { return 701; } + field_cast_enum field_cast_type() { return FIELD_CAST_BLOB; } }; @@ -1053,8 +1042,7 @@ public: void get_key_image(char *buff,uint length, CHARSET_INFO *cs,imagetype type); void set_key_image(char *buff,uint length, CHARSET_INFO *cs); - uint convert_order() { return 750; } - bool convert_order_compatible(uint ord) { return ord < 750; }; + field_cast_enum field_cast_type() { return FIELD_CAST_GEOM; } }; @@ -1096,8 +1084,7 @@ public: bool optimize_range(uint idx) { return 0; } bool eq_def(Field *field); bool has_charset(void) const { return TRUE; } - uint convert_order() { return 30; } - bool convert_order_compatible(uint ord) { return ord < 30; }; + field_cast_enum field_cast_type() { return FIELD_CAST_ENUM; } }; @@ -1123,8 +1110,7 @@ public: void sql_type(String &str) const; enum_field_types real_type() const { return FIELD_TYPE_SET; } bool has_charset(void) const { return TRUE; } - uint convert_order() { return 40; } - bool convert_order_compatible(uint ord) { return ord < 40; }; + field_cast_enum field_cast_type() { return FIELD_CAST_SET; } }; diff --git a/sql/item.cc b/sql/item.cc index e5a9f9db740..c26e00456b7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1996,12 +1996,13 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item) :Item(thd, *item), item_type(item->result_type()) { DBUG_ASSERT(item->fixed); + + /* + It is safe assign pointer on field, because it will be used just after + all JOIN::prepare calls and before any SELECT execution + */ if (item->type() == Item::FIELD_ITEM) - { - Item_field *fitem= (Item_field*) item; - field_example= (Field*) thd->memdup((const char*)fitem->field, - fitem->field->size_of()); - } + field_example= ((Item_field*) item)->field; else field_example= 0; } @@ -2023,23 +2024,18 @@ void Item_type_holder::join_types(THD *thd, Item *item) if (field_example && item->type() == Item::FIELD_ITEM) { Field *field= ((Item_field *)item)->field; - - // is new field better - if ((change_field= - field_example->convert_order() < field->convert_order())) + if (field_example->field_cast_type() != field->field_cast_type()) { - // is it compatible? - if (field->convert_order_compatible(field_example->convert_order())) - skip_store_field= 1; - } - else - { - /* - if old field can't store value of 'worse' new field we will make - decision about result field tipe based only on Item result type - */ - if (field_example->convert_order_compatible(field->convert_order())) - skip_store_field= 1; + if (!(change_field= + field_example->field_cast_compatible(field->field_cast_type()))) + { + /* + if old field can't store value of 'worse' new field we will make + decision about result field type based only on Item result type + */ + if (!field->field_cast_compatible(field_example->field_cast_type())) + skip_store_field= 1; + } } } @@ -2057,19 +2053,15 @@ void Item_type_holder::join_types(THD *thd, Item *item) ((new_type == INT_RESULT) && (decimals > item->decimals)) || (maybe_null && !item->maybe_null)); + /* + It is safe assign pointer on field, because it will be used just after + all JOIN::prepare calls and before any SELECT execution + */ if (skip_store_field || item->type() != Item::FIELD_ITEM) field_example= 0; else - { - /* - we do not need following, because we use mem_root - if (field_example) - thd->free(field_example) - */ - Item_field *fitem= (Item_field*) item; - field_example= (Field*) thd->memdup((const char*)fitem->field, - fitem->field->size_of()); - } + field_example= ((Item_field*) item)->field; + max_length= max(max_length, item->max_length); decimals= max(decimals, item->decimals); maybe_null|= item->maybe_null; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 591c6579a46..20a1f7f0124 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -114,7 +114,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, if(!(derived_result= new select_union(0))) DBUG_RETURN(1); // out of memory - // st_select_lex_unit::prepare coppectly work for single select + // st_select_lex_unit::prepare correctly work for single select if ((res= unit->prepare(thd, derived_result))) goto exit; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 29301053c59..15da6ca57a3 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -309,7 +309,13 @@ protected: public: // list of fields which points to temporary table for union List item_list; - // list of types of items inside union (used for union & derived tables) + /* + list of types of items inside union (used for union & derived tables) + + Item_type_holders from which this list consist may have pointers to Field, + pointers is valid only after preparing SELECTS of this unit and before + any SELECT of this unit execution + */ List types; /* Pointer to 'last' select or pointer to unit where stored From b137384a38c938fd92416050d478187668aa38b1 Mon Sep 17 00:00:00 2001 From: "jani@rhols221.adsl.netsonic.fi" <> Date: Mon, 24 Nov 2003 13:25:08 +0200 Subject: [PATCH 40/89] Fixed Bug#1907, option of type GET_BOOL with arg type OPT_ARG did not call get_one_option(). --- mysys/my_getopt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 5644d81837d..662e33a3a5a 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -316,8 +316,6 @@ int handle_options(int *argc, char ***argv, else /* If argument differs from 0, enable option, else disable */ *((my_bool*) optp->value)= (my_bool) atoi(optend) != 0; } - (*argc)--; - continue; } else if (optp->arg_type == REQUIRED_ARG && !optend) { From 6c1c262dc1cfca1e5d6f0caf4756f9693a778ba2 Mon Sep 17 00:00:00 2001 From: "jani@rhols221.adsl.netsonic.fi" <> Date: Mon, 24 Nov 2003 13:25:23 +0200 Subject: [PATCH 41/89] Fixed Bug#1907, option of type GET_BOOL with arg type OPT_ARG did not call get_one_option(). --- mysys/my_getopt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 830c62b349b..76f8f6bf852 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -330,8 +330,6 @@ int handle_options(int *argc, char ***argv, else /* If argument differs from 0, enable option, else disable */ *((my_bool*) value)= (my_bool) atoi(optend) != 0; } - (*argc)--; - continue; } else if (optp->arg_type == REQUIRED_ARG && !optend) { From 19845c6b1f510c306c938f4c45f14762d1882857 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Mon, 24 Nov 2003 14:49:03 +0100 Subject: [PATCH 42/89] WL#1172 optimization reverted (see fulltext.test) --- myisam/ft_boolean_search.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index aa41bc11513..f48a12b6f28 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -168,11 +168,7 @@ static void _ftb_parse_query(FTB *ftb, byte **start, byte *end, ftbw->word[0]=w.len; if (param.yesno > 0) up->ythresh++; queue_insert(& ftb->queue, (byte *)ftbw); -#ifdef TO_BE_REMOVED - /* after removing the following line, - ftb->with_scan handling can be simplified (no longer a bitmap) */ ftb->with_scan|=(param.trunc & FTB_FLAG_TRUNC); -#endif break; case 2: /* left bracket */ ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR)); From 12fb40460b356b445f5d0f76795fccdd3f96576e Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Mon, 24 Nov 2003 17:05:24 +0100 Subject: [PATCH 43/89] - Rephrased two option help texts to not start with "use the ..." as this confuses RPM's Perl module dependency checking (it adds a bogus requirement to "Perl(the)", as "use" is a Perl keyword). (BUG#1931) --- scripts/mysqlaccess.sh | 2 +- sql-bench/bench-init.pl.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index 699e74834e3..75ef63ecdd0 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -286,7 +286,7 @@ Release Notes: * --old_server: mysqlaccess will now use a full where clause when retrieving information from the MySQL-server. If you are connecting to an old server (before v3.21) - use the option --old_server. + then use the option --old_server. 2.03 : (1998-02-27) - bugfix: * in Host::MatchTemplate: incorrect match if host-field was left empty. diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh index 1ac5f29723b..d61551ffb3b 100644 --- a/sql-bench/bench-init.pl.sh +++ b/sql-bench/bench-init.pl.sh @@ -509,7 +509,7 @@ All benchmarks takes the following options: --socket='socket' If the database supports connecting through a Unix socket, - use this socket to connect + then use this socket to connect --regions This is a test specific option that is only used when debugging a test. From 5e6f94f422100f3cbf0852bd55f784d7f574624c Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Tue, 25 Nov 2003 15:11:01 +0200 Subject: [PATCH 44/89] dict0boot.c: Marko's patch: check the position of some system table columns already at C compile time --- innobase/dict/dict0boot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/innobase/dict/dict0boot.c b/innobase/dict/dict0boot.c index f0d41018948..76c94d1a918 100644 --- a/innobase/dict/dict0boot.c +++ b/innobase/dict/dict0boot.c @@ -332,8 +332,12 @@ dict_boot(void) dict_mem_table_add_col(table, (char *) "PAGE_NO", DATA_INT, 0, 4, 0); /* The '+ 2' below comes from the 2 system fields */ - ut_ad(DICT_SYS_INDEXES_PAGE_NO_FIELD == 6 + 2); - ut_ad(DICT_SYS_INDEXES_SPACE_NO_FIELD == 5 + 2); +#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2 +#error "DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2" +#endif +#if DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2 +#error "DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2" +#endif table->id = DICT_INDEXES_ID; dict_table_add_to_cache(table); From e26716361275447c5ab4412cf7e5f1dd3a05d134 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 25 Nov 2003 14:43:15 +0100 Subject: [PATCH 45/89] mysql-test-run fixes: libexec support in install_test_db --start-from in mysql-test-run --- mysql-test/install_test_db.sh | 11 +++++++++-- mysql-test/mysql-test-run.sh | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mysql-test/install_test_db.sh b/mysql-test/install_test_db.sh index ca6d393e3b4..d8bdd91c59f 100644 --- a/mysql-test/install_test_db.sh +++ b/mysql-test/install_test_db.sh @@ -12,11 +12,13 @@ if [ x$1 = x"-bin" ]; then BINARY_DIST=1 fix_bin=mysql-test scriptdir=../bin + libexecdir=../libexec else execdir=../sql bindir=../client fix_bin=. scriptdir=../scripts + libexecdir=../libexec fi vardir=var @@ -36,8 +38,13 @@ EXTRA_ARG="" if test ! -x $execdir/mysqld then - echo "mysqld is missing - looked in $execdir" - exit 1 + if test ! -x $libexecdir/mysqld + then + echo "mysqld is missing - looked in $execdir and in $libexecdir" + exit 1 + else + execdir=$libexecdir + fi fi # On IRIX hostname is in /usr/bsd so add this to the path diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index c343f313d47..f896f7fa9cc 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -229,6 +229,7 @@ while test $# -gt 0; do --local) USE_RUNNING_SERVER="" ;; --extern) USE_RUNNING_SERVER="1" ;; --tmpdir=*) MYSQL_TMP_DIR=`$ECHO "$1" | $SED -e "s;--tmpdir=;;"` ;; + --start-from=*) START_FROM=`$ECHO "$1" | $SED -e "s;--start-from=;;"` ;; --local-master) MASTER_MYPORT=3306; EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT --host=127.0.0.1 \ @@ -1185,6 +1186,11 @@ run_testcase () fi fi + if [ "$tname" '<' "$START_FROM" ] ; then +# skip_test $tname; + return; + fi + if [ -n "$DO_TEST" ] ; then DO_THIS_TEST=`$EXPR \( $tname : "$DO_TEST" \) != 0` if [ x$DO_THIS_TEST = x0 ] ; From 7c2d0eea456ba7ac58037e60d7a8feb705eb7458 Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Tue, 25 Nov 2003 17:41:12 +0300 Subject: [PATCH 46/89] fix for bug #1946: "You can always mysql_real_query a query with placeholders after mysql_prepare()" --- sql/sql_class.cc | 4 ++-- sql/sql_class.h | 1 - sql/sql_prepare.cc | 1 - sql/sql_yacc.yy | 2 +- tests/client_test.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4fcd6504a2f..1041c21ef30 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -90,8 +90,8 @@ THD::THD():user_time(0), is_fatal_error(0), { host=user=priv_user=db=query=ip=0; host_or_ip= "connecting host"; - locked=killed=some_tables_deleted=no_errors=password= - query_start_used=prepare_command=0; + locked=killed=some_tables_deleted=no_errors=password= 0; + query_start_used= 0; count_cuted_fields= CHECK_FIELD_IGNORE; db_length=query_length=col_access=0; query_error= tmp_table_used= 0; diff --git a/sql/sql_class.h b/sql/sql_class.h index 36faeae8f57..6be517d42d0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -606,7 +606,6 @@ public: bool system_thread,in_lock_tables,global_read_lock; bool query_error, bootstrap, cleanup_done; bool volatile killed; - bool prepare_command; bool tmp_table_used; bool charset_is_system_charset, charset_is_collation_connection; bool slow_command; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 69517b171cb..e76ff833e20 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -785,7 +785,6 @@ static bool parse_prepare_query(PREP_STMT *stmt, mysql_init_query(thd); LEX *lex=lex_start(thd, (uchar*) packet, length); lex->safe_to_cache_query= 0; - thd->prepare_command= TRUE; thd->lex.param_count= 0; if (!yyparse((void *)thd) && !thd->is_fatal_error) error= send_prepare_results(stmt); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0dbe14fd2ab..b944dc3955c 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4355,7 +4355,7 @@ param_marker: '?' { LEX *lex=Lex; - if (YYTHD->prepare_command) + if (YYTHD->command == COM_PREPARE) { lex->param_list.push_back($$=new Item_param((uint)(lex->tok_start-(uchar *)YYTHD->query))); lex->param_count++; diff --git a/tests/client_test.c b/tests/client_test.c index 637f6c4ede1..d2d77c9965c 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -8065,6 +8065,32 @@ static void test_bug1500() mysql_stmt_close(stmt); } +static void test_bug1946() +{ + MYSQL_STMT *stmt; + int rc; + + myheader("test_bug1946"); + const char *query= "INSERT INTO prepare_command VALUES (?)"; + + rc = mysql_query(mysql, "DROP TABLE IF EXISTS prepare_command"); + myquery(rc); + + rc= mysql_query(mysql,"CREATE TABLE prepare_command(ID INT)"); + myquery(rc); + + stmt = mysql_prepare(mysql, query, strlen(query)); + mystmt_init(stmt); + rc= mysql_real_query(mysql, query, strlen(query)); + assert(rc != 0); + fprintf(stdout, "Got error (as expected):\n"); + myerror(NULL); + + mysql_stmt_close(stmt); + rc= mysql_query(mysql,"DROP TABLE prepare_command"); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -8208,6 +8234,8 @@ int main(int argc, char **argv) /* Used for internal new development debugging */ test_drop_temp(); /* to test DROP TEMPORARY TABLE Access checks */ #endif + test_bug1946(); /* test that placeholders are allowed only in + prepared queries */ test_fetch_seek(); /* to test stmt seek() functions */ test_fetch_nobuffs(); /* to fecth without prior bound buffers */ test_open_direct(); /* direct execution in the middle of open stmts */ From f8d52f7cf148420b0d18e2db2db739cf596b28e7 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 25 Nov 2003 16:08:55 +0100 Subject: [PATCH 47/89] a script that fixes anti-GRANT'ness of privilege tables. It can appear as a result of manual modifications with INSERT/UPDATE/DELETE This script converts privilege table to the state that could be created with GRANT commands only (with the exception of the short password) This is necessary for 5.0 --- .../mysql_prepare_privilege_tables_for_5.sql | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 scripts/mysql_prepare_privilege_tables_for_5.sql diff --git a/scripts/mysql_prepare_privilege_tables_for_5.sql b/scripts/mysql_prepare_privilege_tables_for_5.sql new file mode 100644 index 00000000000..a9b6d43aee0 --- /dev/null +++ b/scripts/mysql_prepare_privilege_tables_for_5.sql @@ -0,0 +1,53 @@ + +use mysql; + +-- +-- merging `host` table and `db` +-- + +UPDATE IGNORE host SET Host='%' WHERE Host=''; +DELETE FROM host WHERE Host=''; + +INSERT IGNORE INTO db (User, Host, Select_priv, Insert_priv, Update_priv, + Delete_priv, Create_priv, Drop_priv, Grant_priv, References_priv, + Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv) + SELECT d.User, h.Host, + (d.Select_priv = 'Y' || h.Select_priv = 'Y') + 1, + (d.Insert_priv = 'Y' || h.Select_priv = 'Y') + 1, + (d.Update_priv = 'Y' || h.Update_priv = 'Y') + 1, + (d.Delete_priv = 'Y' || h.Delete_priv = 'Y') + 1, + (d.Create_priv = 'Y' || h.Create_priv = 'Y') + 1, + (d.Drop_priv = 'Y' || h.Drop_priv = 'Y') + 1, + (d.Grant_priv = 'Y' || h.Grant_priv = 'Y') + 1, + (d.References_priv = 'Y' || h.References_priv = 'Y') + 1, + (d.Index_priv = 'Y' || h.Index_priv = 'Y') + 1, + (d.Alter_priv = 'Y' || h.Alter_priv = 'Y') + 1, + (d.Create_tmp_table_priv = 'Y' || h.Create_tmp_table_priv = 'Y') + 1, + (d.Lock_tables_priv = 'Y' || h.Lock_tables_priv = 'Y') + 1 + FROM db d, host h WHERE d.Host = ''; + +UPDATE IGNORE db SET Host='%' WHERE Host = ''; +DELETE FROM db WHERE Host=''; + +TRUNCATE TABLE host; + +-- +-- Adding missing users to `user` table +-- +-- note that invalid password causes the user to be skipped during the +-- load of grand tables (at mysqld startup) thus three following inserts +-- do not affect anything + +INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM db; +INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM tables_priv; +INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM columns_priv; + +SELECT DISTINCT +"There are user accounts with the username 'PUBLIC'. In the SQL-1999 +(or later) standard this name is reserved for PUBLIC role and can +not be used as a valid user name. Consider renaming these accounts before +upgrading to MySQL-5.0. +These accounts are:" x +FROM user WHERE user='PUBLIC'; +SELECT CONCAT(user,'@',host) FROM user WHERE user='PUBLIC'; + From 531eb44301e559cc10a6c5905b6a87787ae17be6 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 25 Nov 2003 17:52:12 +0100 Subject: [PATCH 48/89] - Removed COPYING.LIB from all source and binary distributions after it was removed from manual.texi (where it was automatically generated from). --- Docs/Makefile.am | 3 --- Makefile.am | 3 +-- scripts/make_binary_distribution.sh | 2 +- scripts/make_win_src_distribution.sh | 2 +- support-files/mysql.spec.sh | 2 +- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Docs/Makefile.am b/Docs/Makefile.am index 07dac2d9df1..bf7aaa747e3 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -204,9 +204,6 @@ INSTALL-BINARY: mysql.info $(GT) ../COPYING: mysql.info $(GT) perl -w $(GT) mysql.info "GPL license" "LGPL license" > $@ -../COPYING.LIB: mysql.info $(GT) - perl -w $(GT) mysql.info "LGPL license" "Function Index" > $@ - ../support-files/MacOSX/ReadMe.txt: mysql.info $(GT) perl -w $(GT) mysql.info "Mac OS X installation" "NetWare installation" > $@ diff --git a/Makefile.am b/Makefile.am index b9e0e88ff77..8aef19d0920 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,8 +19,7 @@ AUTOMAKE_OPTIONS = foreign # These are built from source in the Docs directory -EXTRA_DIST = INSTALL-SOURCE README \ - COPYING COPYING.LIB +EXTRA_DIST = INSTALL-SOURCE README COPYING SUBDIRS = . include @docs_dirs@ @readline_dir@ \ @thread_dirs@ pstack @sql_client_dirs@ \ @sql_server_dirs@ scripts man tests \ diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 8735fc800ce..300fc4a7020 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -85,7 +85,7 @@ do fi done -for i in COPYING COPYING.LIB README Docs/INSTALL-BINARY \ +for i in COPYING README Docs/INSTALL-BINARY \ MySQLEULA.txt LICENSE.doc README.NW do if [ -f $i ] diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index c521c4cfdcb..3556b00cbc7 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -282,7 +282,7 @@ touch $BASE/innobase/ib_config.h # cd $SOURCE -for i in COPYING COPYING.LIB ChangeLog README \ +for i in COPYING ChangeLog README \ INSTALL-SOURCE INSTALL-WIN \ INSTALL-WIN-SOURCE \ Docs/manual_toc.html Docs/manual.html \ diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 974a3bde36a..658b90d1a3f 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -444,7 +444,7 @@ fi %files server %defattr(755 root, root) -%doc %attr(644, root, root) COPYING COPYING.LIB README +%doc %attr(644, root, root) COPYING README %doc %attr(644, root, root) Docs/manual.{html,ps,texi,txt} Docs/manual_toc.html %doc %attr(644, root, root) support-files/my-*.cnf From ba76560dca39d8ff12283bf6b10bdda562012975 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 25 Nov 2003 19:11:59 +0100 Subject: [PATCH 49/89] - Removed COPYING.LIB from txt_files target in Docs/Makefile.am --- Docs/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/Makefile.am b/Docs/Makefile.am index bf7aaa747e3..ff2b4fa4530 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) $(BUILT_SOURCES) mysqld_error.txt \ all: $(targets) txt_files -txt_files: ../INSTALL-SOURCE ../COPYING ../COPYING.LIB \ +txt_files: ../INSTALL-SOURCE ../COPYING \ INSTALL-BINARY ../support-files/MacOSX/ReadMe.txt CLEAN_FILES: $(BUILD_SOURCES) From 8ff4b768ed0d23cb5ba5f048642c105f02eae1af Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 25 Nov 2003 19:19:20 +0100 Subject: [PATCH 50/89] - Fixed missing node name --- Docs/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/Makefile.am b/Docs/Makefile.am index ff2b4fa4530..9a77202a91b 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -202,7 +202,7 @@ INSTALL-BINARY: mysql.info $(GT) perl -w $(GT) mysql.info "Installing binary" "Installing source" > $@ ../COPYING: mysql.info $(GT) - perl -w $(GT) mysql.info "GPL license" "LGPL license" > $@ + perl -w $(GT) mysql.info "GPL license" "Function Index" > $@ ../support-files/MacOSX/ReadMe.txt: mysql.info $(GT) perl -w $(GT) mysql.info "Mac OS X installation" "NetWare installation" > $@ From e82a7e2fd2d2426905b8160a294776fc9542d31b Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Tue, 25 Nov 2003 20:39:06 +0200 Subject: [PATCH 51/89] os0file.h, os0file.c: Changes needed for ibbackup directory scanning fault tolerance --- innobase/include/os0file.h | 26 +++++ innobase/os/os0file.c | 220 ++++++++++++++++++++++++++++++++++++- 2 files changed, 241 insertions(+), 5 deletions(-) diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 4a9fae90f07..5f2d6e3ed21 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -282,6 +282,15 @@ os_file_delete( /*===========*/ /* out: TRUE if success */ char* name); /* in: file path as a null-terminated string */ + +/*************************************************************************** +Deletes a file if it exists. The file has to be closed before calling this. */ + +ibool +os_file_delete_if_exists( +/*=====================*/ + /* out: TRUE if success */ + char* name); /* in: file path as a null-terminated string */ /*************************************************************************** Renames a file (can also move it to another directory). It is safest that the file is closed before calling this function. */ @@ -379,6 +388,23 @@ os_file_read( offset */ ulint n); /* in: number of bytes to read */ /*********************************************************************** +Requests a synchronous positioned read operation. This function does not do +any error handling. In case of error it returns FALSE. */ + +ibool +os_file_read_no_error_handling( +/*===========================*/ + /* out: TRUE if request was + successful, FALSE if fail */ + os_file_t file, /* in: handle to a file */ + void* buf, /* in: buffer where to read */ + ulint offset, /* in: least significant 32 bits of file + offset where to read */ + ulint offset_high,/* in: most significant 32 bits of + offset */ + ulint n); /* in: number of bytes to read */ + +/*********************************************************************** Requests a synchronous write operation. */ ibool diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index e5dd8679163..be57868e574 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -346,6 +346,7 @@ os_file_handle_error( return(FALSE); } else if (err == OS_FILE_AIO_RESOURCES_RESERVED) { + return(TRUE); } else if (err == OS_FILE_ALREADY_EXISTS) { @@ -368,6 +369,68 @@ os_file_handle_error( return(FALSE); } +/******************************************************************** +Does error handling when a file operation fails. */ +static +ibool +os_file_handle_error_no_exit( +/*=========================*/ + /* out: TRUE if we should retry the + operation */ + os_file_t file, /* in: file pointer */ + char* name, /* in: name of a file or NULL */ + const char* operation)/* in: operation */ +{ + ulint err; + + UT_NOT_USED(file); + + err = os_file_get_last_error(FALSE); + + if (err == OS_FILE_DISK_FULL) { + /* We only print a warning about disk full once */ + + if (os_has_said_disk_full) { + + return(FALSE); + } + + if (name) { + ut_print_timestamp(stderr); + fprintf(stderr, + " 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"); + + os_has_said_disk_full = TRUE; + + fflush(stderr); + + return(FALSE); + + } else if (err == OS_FILE_AIO_RESOURCES_RESERVED) { + + return(TRUE); + + } else if (err == OS_FILE_ALREADY_EXISTS) { + + return(FALSE); + } else { + if (name) { + fprintf(stderr, "InnoDB: File name %s\n", name); + } + + fprintf(stderr, "InnoDB: File operation call: '%s'.\n", + operation); + return (FALSE); + } + + return(FALSE); +} + /******************************************************************** Creates the seek mutexes used in positioned reads and writes. */ @@ -457,7 +520,7 @@ os_file_closedir( ret = FindClose(dir); if (!ret) { - os_file_handle_error(NULL, NULL, "closedir"); + os_file_handle_error_no_exit(NULL, NULL, "closedir"); return(-1); } @@ -469,7 +532,7 @@ os_file_closedir( ret = closedir(dir); if (ret) { - os_file_handle_error(0, NULL, "closedir"); + os_file_handle_error_no_exit(0, NULL, "closedir"); } return(ret); @@ -538,8 +601,8 @@ http://www.mysql.com/doc/en/Windows_symbolic_links.html */ return(1); } else { - os_file_handle_error(NULL, dirname, "readdir_next_file"); - + os_file_handle_error_no_exit(NULL, dirname, + "readdir_next_file"); return(-1); } #else @@ -570,7 +633,7 @@ next_file: ret = stat(full_path, &statinfo); if (ret) { - os_file_handle_error(0, full_path, "stat"); + os_file_handle_error_no_exit(0, full_path, "stat"); ut_free(full_path); @@ -1063,6 +1126,67 @@ try_again: #endif } +/*************************************************************************** +Deletes a file if it exists. The file has to be closed before calling this. */ + +ibool +os_file_delete_if_exists( +/*=====================*/ + /* out: TRUE if success */ + char* name) /* in: file path as a null-terminated string */ +{ +#ifdef __WIN__ + BOOL ret; + ulint count = 0; +loop: + /* In Windows, deleting an .ibd file may fail if ibbackup is copying + it */ + + ret = DeleteFile((LPCTSTR)name); + + if (ret) { + return(TRUE); + } + + if (GetLastError() == ERROR_PATH_NOT_FOUND) { + /* the file does not exist, this not an error */ + + return(TRUE); + } + + count++; + + 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); + + os_file_get_last_error(TRUE); /* print error information */ + } + + os_thread_sleep(1000000); /* sleep for a second */ + + if (count > 2000) { + + return(FALSE); + } + + goto loop; +#else + int ret; + + ret = unlink((const char*)name); + + if (ret != 0 && errno != ENOENT) { + os_file_handle_error(0, name, "delete"); + + return(FALSE); + } + + return(TRUE); +#endif +} + /*************************************************************************** Deletes a file. The file has to be closed before calling this. */ @@ -1746,6 +1870,92 @@ error_handling: return(FALSE); } +/*********************************************************************** +Requests a synchronous positioned read operation. This function does not do +any error handling. In case of error it returns FALSE. */ + +ibool +os_file_read_no_error_handling( +/*===========================*/ + /* out: TRUE if request was + successful, FALSE if fail */ + os_file_t file, /* in: handle to a file */ + void* buf, /* in: buffer where to read */ + ulint offset, /* in: least significant 32 bits of file + offset where to read */ + ulint offset_high, /* in: most significant 32 bits of + offset */ + ulint n) /* in: number of bytes to read */ +{ +#ifdef __WIN__ + BOOL ret; + DWORD len; + DWORD ret2; + DWORD low; + DWORD high; + ibool retry; + ulint i; + + ut_a((offset & 0xFFFFFFFFUL) == offset); + + os_n_file_reads++; + os_bytes_read_since_printout += n; + +try_again: + ut_ad(file); + ut_ad(buf); + ut_ad(n > 0); + + low = offset; + high = offset_high; + + /* Protect the seek / read operation with a mutex */ + i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; + + os_mutex_enter(os_file_seek_mutexes[i]); + + ret2 = SetFilePointer(file, low, &high, FILE_BEGIN); + + if (ret2 == 0xFFFFFFFF && GetLastError() != NO_ERROR) { + + os_mutex_exit(os_file_seek_mutexes[i]); + + goto error_handling; + } + + ret = ReadFile(file, buf, n, &len, NULL); + + os_mutex_exit(os_file_seek_mutexes[i]); + + if (ret && len == n) { + return(TRUE); + } +#else + ibool retry; + ssize_t ret; + + os_bytes_read_since_printout += n; + +try_again: + ret = os_file_pread(file, buf, n, offset, offset_high); + + if ((ulint)ret == n) { + + return(TRUE); + } +#endif +#ifdef __WIN__ +error_handling: +#endif + retry = os_file_handle_error_no_exit(file, NULL, "read"); + + if (retry) { + goto try_again; + } + + return(FALSE); +} + /*********************************************************************** Requests a synchronous write operation. */ From f6ca51feffeddb7af80ee2084c16731ae8efde89 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 25 Nov 2003 10:40:14 -0800 Subject: [PATCH 52/89] mf_keycache.c, keycache.h: Fix for the resize key cache operation. --- include/keycache.h | 4 + mysys/mf_keycache.c | 222 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 193 insertions(+), 33 deletions(-) diff --git a/include/keycache.h b/include/keycache.h index 340ab881fee..b882f3127f5 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -45,6 +45,8 @@ typedef struct st_keycache_wqueue typedef struct st_key_cache { my_bool key_cache_inited; + my_bool resize_in_flush; /* true during flush of resize operation */ + my_bool can_be_used; /* usage of cache for read/write is allowed */ uint key_cache_shift; ulong key_cache_mem_size; /* specified size of the cache memory */ uint key_cache_block_size; /* size of the page buffer of a cache block */ @@ -58,6 +60,7 @@ typedef struct st_key_cache ulong blocks_used; /* number of currently used blocks */ ulong blocks_changed; /* number of currently dirty blocks */ ulong warm_blocks; /* number of blocks in warm sub-chain */ + ulong cnt_for_resize_op; /* counter to block resize operation */ long blocks_available; /* number of blocks available in the LRU chain */ HASH_LINK **hash_root; /* arr. of entries into hash table buckets */ HASH_LINK *hash_link_root; /* memory for hash table links */ @@ -67,6 +70,7 @@ typedef struct st_key_cache BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */ BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */ pthread_mutex_t cache_lock; /* to lock access to the cache structure */ + KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */ KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */ KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/ diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index b1ef03fdcd2..6b1535e1a65 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -141,6 +141,11 @@ KEY_CACHE *dflt_key_cache= &dflt_key_cache_var; #define FLUSH_CACHE 2000 /* sort this many blocks at once */ static int flush_all_key_blocks(KEY_CACHE *keycache); +static inline void link_into_queue(KEYCACHE_WQUEUE *wqueue, + struct st_my_thread_var *thread); +static inline void unlink_from_queue(KEYCACHE_WQUEUE *wqueue, + struct st_my_thread_var *thread); +static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block); static void test_key_cache(KEY_CACHE *keycache, const char *where, my_bool lock); @@ -225,10 +230,10 @@ static int keycache_pthread_cond_broadcast(pthread_cond_t *cond); static uint next_power(uint value) { - uint old_value=1; + uint old_value= 1; while (value) { - old_value=value; + old_value= value; value&= value-1; } return (old_value << 1); @@ -239,8 +244,8 @@ static uint next_power(uint value) Initialize a key cache SYNOPSIS - init_ky_cache() - keycache pointer to the key cache handle to initialize + init_key_cache() + keycache pointer to a key cache data structure key_cache_block_size size of blocks to keep cached data use_mem total memory to use for the key cache division_limit division limit (may be zero) @@ -366,11 +371,16 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, blocks * age_threshold / 100 : blocks); + keycache->cnt_for_resize_op= 0; + keycache->resize_in_flush= 0; + keycache->can_be_used= 1; + keycache->resize_queue.last_thread= NULL; + keycache->waiting_for_hash_link.last_thread= NULL; keycache->waiting_for_block.last_thread= NULL; DBUG_PRINT("exit", - ("disk_blocks: %d block_root: %lx hash_entries: %d hash_root: %lx \ - hash_links: %d hash_link_root %lx", + ("disk_blocks: %d block_root: %lx hash_entries: %d\ + hash_root: %lx hash_links: %d hash_link_root %lx", keycache->disk_blocks, keycache->block_root, keycache->hash_entries, keycache->hash_root, keycache->hash_links, keycache->hash_link_root)); @@ -398,6 +408,7 @@ err: keycache->block_root= NULL; } my_errno= error; + keycache->can_be_used= 0; DBUG_RETURN(0); } @@ -407,8 +418,8 @@ err: SYNOPSIS resize_key_cache() - keycache in/out key cache handle - key_cache_block_size size of blocks to keep cached data + keycache pointer to a key cache data structure + key_cache_block_size size of blocks to keep cached data use_mem total memory to use for the new key cache division_limit new division limit (if not zero) age_threshold new age threshold (if not zero) @@ -425,6 +436,10 @@ err: old key cache blocks by calling the end_key_cache function and then rebuilds the key cache with new blocks by calling init_key_cache. + + The function starts the operation only when all other threads + performing operations with the key cache let her to proceed + (when cnt_for_resize=0). */ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, @@ -432,35 +447,90 @@ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, uint age_threshold) { int blocks; + struct st_my_thread_var *thread; + KEYCACHE_WQUEUE *wqueue; DBUG_ENTER("resize_key_cache"); - if (!keycache->key_cache_inited || - (key_cache_block_size == keycache->key_cache_block_size && - use_mem == keycache->key_cache_mem_size)) + if (!keycache->key_cache_inited) DBUG_RETURN(keycache->disk_blocks); + + if(key_cache_block_size == keycache->key_cache_block_size && + use_mem == keycache->key_cache_mem_size) + { + change_key_cache_param(keycache, division_limit, age_threshold); + DBUG_RETURN(keycache->disk_blocks); + } keycache_pthread_mutex_lock(&keycache->cache_lock); + + wqueue= &keycache->resize_queue; + thread=my_thread_var; + link_into_queue(wqueue, thread); + + while (wqueue->last_thread->next != thread) + { + keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); + } + + keycache->resize_in_flush= 1; if (flush_all_key_blocks(keycache)) { /* TODO: if this happens, we should write a warning in the log file ! */ - keycache_pthread_mutex_unlock(&keycache->cache_lock); - DBUG_RETURN(0); + keycache->resize_in_flush= 0; + blocks= 0; + goto finish; } + keycache->resize_in_flush= 0; + keycache->can_be_used= 0; + while (keycache->cnt_for_resize_op) + { + keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); + } + end_key_cache(keycache, 0); /* Don't free mutex */ - /* the following will work even if use_mem is 0 */ + /* The following will work even if use_mem is 0 */ blocks= init_key_cache(keycache, key_cache_block_size, use_mem, division_limit, age_threshold); + +finish: + unlink_from_queue(wqueue, thread); + /* Signal for the next resize request to proceeed if any */ + if (wqueue->last_thread) + keycache_pthread_cond_signal(&wqueue->last_thread->next->suspend); + + keycache->can_be_used= blocks <= 0; keycache_pthread_mutex_unlock(&keycache->cache_lock); return blocks; } +/* + Increment counter blocking resize key cache operation +*/ +static inline void inc_counter_for_resize_op(KEY_CACHE *keycache) +{ + keycache->cnt_for_resize_op++; +} + + +/* + Decrement counter blocking resize key cache operation; + Signal the operation to proceed when counter becomes equal zero +*/ +static inline void dec_counter_for_resize_op(KEY_CACHE *keycache) +{ + struct st_my_thread_var *last_thread; + if (!--keycache->cnt_for_resize_op && + (last_thread= keycache->resize_queue.last_thread)) + keycache_pthread_cond_signal(&last_thread->next->suspend); +} + /* Change the key cache parameters SYNOPSIS change_key_cache_param() - keycache key cache handle + keycache pointer to a key cache data structure division_limit new division limit (if not zero) age_threshold new age threshold (if not zero) @@ -478,12 +548,14 @@ void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, { DBUG_ENTER("change_key_cache_param"); + keycache_pthread_mutex_lock(&keycache->cache_lock); if (division_limit) keycache->min_warm_blocks= (keycache->disk_blocks * division_limit / 100 + 1); if (age_threshold) keycache->age_threshold= (keycache->disk_blocks * age_threshold / 100); + keycache_pthread_mutex_unlock(&keycache->cache_lock); DBUG_VOID_RETURN; } @@ -1018,7 +1090,7 @@ static void unlink_hash(KEY_CACHE *keycache, HASH_LINK *hash_link) hash_link->block= NULL; if (keycache->waiting_for_hash_link.last_thread) { - /* Signal that A free hash link appeared */ + /* Signal that a free hash link has appeared */ struct st_my_thread_var *last_thread= keycache->waiting_for_hash_link.last_thread; struct st_my_thread_var *first_thread= last_thread->next; @@ -1204,9 +1276,57 @@ restart: block->hash_link == hash_link && (block->status & BLOCK_READ)) page_status= PAGE_READ; - if (page_status == PAGE_READ && (block->status & BLOCK_IN_SWITCH)) + if (wrmode && keycache->resize_in_flush) + { + /* This is a write request during the flush phase of a resize operation */ + + if (page_status != PAGE_READ) + { + /* We don't need the page in the cache: we are going to write on disk */ + hash_link->requests--; + unlink_hash(keycache, hash_link); + return 0; + } + if (!(block->status & BLOCK_IN_FLUSH)) + { + hash_link->requests--; + /* + Remove block to invalidate the page in the block buffer + as we are going to write directly on disk. + Although we have an exlusive lock for the updated key part + the control can be yieded by the current thread as we might + have unfinished readers of other key parts in the block + buffer. Still we are guaranteed not to have any readers + of the key part we are writing into until the block is + removed from the cache as we set the BLOCL_REASSIGNED + flag (see the code below that handles reading requests). + */ + free_block(keycache, block); + return 0; + } + /* Wait intil the page is flushed on disk */ + hash_link->requests--; + { + struct st_my_thread_var *thread= my_thread_var; + add_to_queue(&block->wqueue[COND_FOR_SAVED], thread); + do + { + keycache_pthread_cond_wait(&thread->suspend, + &keycache->cache_lock); + } + while(thread->next); + } + /* Invalidate page in the block if it has not been done yet */ + if (block->status) + free_block(keycache, block); + return 0; + } + + if (page_status == PAGE_READ && + (block->status & (BLOCK_IN_SWITCH | BLOCK_REASSIGNED))) { /* This is a request for a page to be removed from cache */ + KEYCACHE_DBUG_PRINT("find_key_block", ("request for old page in block %u",BLOCK_NUMBER(block))); /* @@ -1270,10 +1390,11 @@ restart: else { /* There are no never used blocks, use a block from the LRU chain */ + /* - Wait until a new block is added to the LRU chain; - several threads might wait here for the same page, - all of them must get the same block + Wait until a new block is added to the LRU chain; + several threads might wait here for the same page, + all of them must get the same block */ if (! keycache->used_last) @@ -1521,7 +1642,7 @@ byte *key_cache_read(KEY_CACHE *keycache, DBUG_PRINT("enter", ("file %u, filepos %lu, length %u", (uint) file, (ulong) filepos, length)); - if (keycache->disk_blocks > 0) + if (keycache->can_be_used) { /* Key cache is used */ reg1 BLOCK_LINK *block; @@ -1533,7 +1654,7 @@ byte *key_cache_read(KEY_CACHE *keycache, do { keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->disk_blocks <= 0) /* Resize failed */ + if (!keycache->can_be_used) { keycache_pthread_mutex_unlock(&keycache->cache_lock); goto no_key_cache; @@ -1548,6 +1669,7 @@ byte *key_cache_read(KEY_CACHE *keycache, return_buffer=0; #endif + inc_counter_for_resize_op(keycache); keycache->global_cache_r_requests++; block=find_key_block(keycache, file, filepos, level, 0, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ) @@ -1598,6 +1720,8 @@ byte *key_cache_read(KEY_CACHE *keycache, */ unreg_request(keycache, block, 1); + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); if (status & BLOCK_ERROR) @@ -1654,7 +1778,7 @@ int key_cache_insert(KEY_CACHE *keycache, DBUG_PRINT("enter", ("file %u, filepos %lu, length %u", (uint) file,(ulong) filepos, length)); - if (keycache->disk_blocks > 0) + if (keycache->can_be_used) { /* Key cache is used */ reg1 BLOCK_LINK *block; @@ -1666,7 +1790,7 @@ int key_cache_insert(KEY_CACHE *keycache, { uint offset; keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->disk_blocks <= 0) /* Resize failed */ + if (!keycache->can_be_used) { keycache_pthread_mutex_unlock(&keycache->cache_lock); DBUG_RETURN(0); @@ -1678,6 +1802,7 @@ int key_cache_insert(KEY_CACHE *keycache, /* Read data into key cache from buff in key_cache_block_size incr. */ filepos-= offset; + inc_counter_for_resize_op(keycache); keycache->global_cache_r_requests++; block= find_key_block(keycache, file, filepos, level, 0, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ) @@ -1708,6 +1833,9 @@ int key_cache_insert(KEY_CACHE *keycache, unreg_request(keycache, block, 1); error= (block->status & BLOCK_ERROR); + + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); if (error) @@ -1776,7 +1904,7 @@ int key_cache_write(KEY_CACHE *keycache, test_key_cache(keycache, "start of key_cache_write", 1);); #endif - if (keycache->disk_blocks > 0) + if (keycache->can_be_used) { /* Key cache is used */ uint read_length; @@ -1786,7 +1914,7 @@ int key_cache_write(KEY_CACHE *keycache, { uint offset; keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->disk_blocks <= 0) /* Resize failed */ + if (!keycache->can_be_used) { keycache_pthread_mutex_unlock(&keycache->cache_lock); goto no_key_cache; @@ -1798,8 +1926,25 @@ int key_cache_write(KEY_CACHE *keycache, /* Write data in key_cache_block_size increments */ filepos-= offset; + inc_counter_for_resize_op(keycache); keycache->global_cache_w_requests++; block= find_key_block(keycache, file, filepos, level, 1, &page_st); + if (!block) + { + /* It happens only for requests submitted during resize operation */ + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); + if (dont_write) + { + keycache->global_cache_w_requests++; + keycache->global_cache_write++; + if (my_pwrite(file, (byte*) buff, length, filepos, + MYF(MY_NABP | MY_WAIT_IF_FULL))) + error=1; + } + goto next_block; + } + if (block->status != BLOCK_ERROR && page_st != PAGE_READ && (offset || read_length < keycache->key_cache_block_size)) read_block(keycache, block, @@ -1841,8 +1986,11 @@ int key_cache_write(KEY_CACHE *keycache, break; } - keycache_pthread_mutex_unlock(&keycache->cache_lock); + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); + + next_block: buff+= read_length; filepos+= read_length; offset= 0; @@ -1951,6 +2099,12 @@ static int flush_cached_blocks(KEY_CACHE *keycache, if (!last_errno) last_errno= errno ? errno : -1; } + /* + Let to proceed for possible waiting requests to write to the block page. + It might happen only during an operation to resize the key cache. + */ + if (block->wqueue[COND_FOR_SAVED].last_thread) + release_queue(&block->wqueue[COND_FOR_SAVED]); /* type will never be FLUSH_IGNORE_CHANGED here */ if (! (type == FLUSH_KEEP || type == FLUSH_FORCE_WRITE)) { @@ -2187,18 +2341,20 @@ restart: 1 error */ -int flush_key_blocks(KEY_CACHE *key_cache, +int flush_key_blocks(KEY_CACHE *keycache, File file, enum flush_type type) { int res; DBUG_ENTER("flush_key_blocks"); - DBUG_PRINT("enter", ("key_cache: %lx", key_cache)); + DBUG_PRINT("enter", ("keycache: %lx", keycache)); - if (key_cache->disk_blocks <= 0) + if (keycache->disk_blocks <= 0) DBUG_RETURN(0); - keycache_pthread_mutex_lock(&key_cache->cache_lock); - res= flush_key_blocks_int(key_cache, file, type); - keycache_pthread_mutex_unlock(&key_cache->cache_lock); + keycache_pthread_mutex_lock(&keycache->cache_lock); + inc_counter_for_resize_op(keycache); + res= flush_key_blocks_int(keycache, file, type); + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); DBUG_RETURN(res); } From 34fdd54e073c6ac6f8308f642bf16697b2a1bdc5 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 25 Nov 2003 20:06:41 +0100 Subject: [PATCH 53/89] post-merge fixes --- Makefile.am | 2 +- mysql-test/r/rpl_change_master.result | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index c330471169d..6afbce11dfa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,7 +20,7 @@ AUTOMAKE_OPTIONS = foreign # These are built from source in the Docs directory EXTRA_DIST = INSTALL-SOURCE README COPYING zlib -SUBDIRS = . include @docs_dirs@ \ +SUBDIRS = . include @docs_dirs@ \ @readline_topdir@ sql-common \ @thread_dirs@ pstack @sql_client_dirs@ \ @sql_server_dirs@ scripts man tests \ diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result index 546a0ee2710..a6342d47b49 100644 --- a/mysql-test/r/rpl_change_master.result +++ b/mysql-test/r/rpl_change_master.result @@ -8,7 +8,7 @@ select get_lock("a",5); get_lock("a",5) 1 create table t1(n int); -insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(1+get_lock("a",15)*0); insert into t1 values(2); stop slave; select * from t1; From dc95a025d64842d6b8c5074e695ce58629287158 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Tue, 25 Nov 2003 21:52:22 +0200 Subject: [PATCH 54/89] fil0fil.h, fil0fil.c: ibbackup --apply-log must be able to rename a table based only on the space id --- innobase/fil/fil0fil.c | 41 +++++++++++++++++++++++++------------- innobase/include/fil0fil.h | 4 +++- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index 7cf3cc409b3..b45eec8e4cf 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -84,7 +84,8 @@ completes, we decrement the count and return the file node to the LRU-list if the count drops to zero. */ /* When mysqld is run, the default directory "." is the mysqld datadir, -but in ibbackup we must set it explicitly */ +but in the MySQL Embedded Server Library and ibbackup it is not the default +directory, and we must set the base file path explicitly */ char* fil_path_to_mysql_datadir = (char*)"."; ulint fil_n_pending_log_flushes = 0; @@ -1576,7 +1577,8 @@ fil_op_write_log( mlog_close(mtr, log_ptr); - mlog_catenate_string(mtr, (byte*) new_name, ut_strlen(new_name) + 1); + mlog_catenate_string(mtr, (byte*) new_name, + ut_strlen(new_name) + 1); } } #endif @@ -1696,7 +1698,9 @@ fil_op_log_parse_or_replay( if (fil_get_space_id_for_table(new_name) == ULINT_UNDEFINED) { - ut_a(fil_rename_tablespace(name, space_id, + /* 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)); } } @@ -1956,7 +1960,9 @@ fil_rename_tablespace( /*==================*/ /* out: TRUE if success */ char* old_name, /* in: old table name in the standard - databasename/tablename format of InnoDB */ + databasename/tablename format of InnoDB, or + NULL if we do the rename based on the space + id only */ ulint id, /* in: space id */ char* new_name) /* in: new table name in the standard databasename/tablename format of InnoDB */ @@ -1967,9 +1973,15 @@ fil_rename_tablespace( fil_node_t* node; ulint count = 0; char* path = NULL; + ibool old_name_was_specified = TRUE; char old_path[OS_FILE_MAX_PATH]; ut_a(id != 0); + + if (old_name == NULL) { + old_name = (char*)"(name not specified)"; + old_name_was_specified = FALSE; + } retry: count++; @@ -2038,16 +2050,19 @@ retry: } /* Check that the old name in the space is right */ - - ut_a(strlen(old_name) + strlen(fil_path_to_mysql_datadir) + + if (old_name_was_specified) { + ut_a(strlen(old_name) + strlen(fil_path_to_mysql_datadir) < OS_FILE_MAX_PATH - 10); + sprintf(old_path, "%s/%s.ibd", fil_path_to_mysql_datadir, + old_name); + srv_normalize_path_for_win(old_path); - sprintf(old_path, "%s/%s.ibd", fil_path_to_mysql_datadir, old_name); - - srv_normalize_path_for_win(old_path); - - ut_a(strcmp(space->name, old_path) == 0); - ut_a(strcmp(node->name, old_path) == 0); + ut_a(strcmp(space->name, old_path) == 0); + ut_a(strcmp(node->name, old_path) == 0); + } else { + sprintf(old_path, "%s", space->name); + } /* Rename the tablespace and the node in the memory cache */ @@ -2066,8 +2081,6 @@ retry: goto func_exit; } - /* printf("Renaming tablespace %s to %s id %lu\n", path, old_path, id); - */ success = os_file_rename(old_path, path); if (!success) { diff --git a/innobase/include/fil0fil.h b/innobase/include/fil0fil.h index 0ed012c489a..310336af38e 100644 --- a/innobase/include/fil0fil.h +++ b/innobase/include/fil0fil.h @@ -329,7 +329,9 @@ fil_rename_tablespace( /*==================*/ /* out: TRUE if success */ char* old_name, /* in: old table name in the standard - databasename/tablename format of InnoDB */ + databasename/tablename format of InnoDB, or + NULL if we do the rename based on the space + id only */ ulint id, /* in: space id */ char* new_name); /* in: new table name in the standard databasename/tablename format of InnoDB */ From 5eb3763b2f5da446c815687355e5d9b6bcfbc460 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 25 Nov 2003 13:06:46 -0800 Subject: [PATCH 55/89] fork_big2.pl: Added resize key cache test. --- tests/fork_big2.pl | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/fork_big2.pl b/tests/fork_big2.pl index b552b95ba6b..a1c55ac4c11 100644 --- a/tests/fork_big2.pl +++ b/tests/fork_big2.pl @@ -23,14 +23,15 @@ $opt_select_count=$opt_join_count=0; $opt_update=1;$opt_delete=0; $opt_flush=$opt_check=$opt_repair=$opt_alter=0; $opt_join_range=100; +$opt_resize_interval=0; $opt_time=0; $opt_host=$opt_user=$opt_password=""; $opt_db="test"; +$opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$opt_force=undef; # Ignore warnings from these GetOptions("host=s","db=s","user=s","password=s","loop-count=i","skip-create","skip-in","skip-drop", "verbose","fast-insert","lock-tables","debug","fast","force","thread-factor=i", "insert=i", "select=i", "join=i", "select-count=i", "join-count=i", "update=i", "delete=i", - "flush=i", "check=i", "repair=i", "alter=i", "max-join_range=i", "time=i") || die "Aborted"; -$opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$opt_force=undef; # Ignore warnings from these + "flush=i", "check=i", "repair=i", "alter=i", "resize-interval=i", "max-join_range=i", "time=i") || die "Aborted"; print "Test of multiple connections that test the following things:\n"; print "insert, select, delete, update, alter, check, repair and flush\n"; @@ -158,6 +159,11 @@ for ($i=0 ; $i < $opt_alter ; $i ++) test_alter() if (($pid=fork()) == 0); $work{$pid}="alter"; } $threads+=$i; +if ($opt_resize_interval != 0) +{ + test_resize() if (($pid=fork()) == 0); $work{$pid}="resize"; + $threads+=1; +} print "Started $threads threads\n"; @@ -590,6 +596,32 @@ sub test_flush exit(0); } +# +# Do a resize key cache every periodically +# + +sub test_resize +{ + my ($dbh, $key_buffer_size); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + $count=0; + $key_buffer_size=1024*64; + while (!test_if_abort($dbh)) + { + sleep($opt_resize_interval); + $dbh->do("set global key_buffer_size=$key_buffer_size") || + die "Got error on resize key cache $DBI::errstr\n"; + $key_buffer_size+=1024*16; + $count++; + } + $dbh->disconnect; $dbh=0; + print "Test_resize: Executed $count times resize key cache\n"; + exit(0); +} # # Test all tables in a database From b7de8a0bc6f928bd24c9ae516d66ffa4a17eb442 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Tue, 25 Nov 2003 23:14:49 +0200 Subject: [PATCH 56/89] Change to use real_sleep to make test work in build environment --- myisam/mi_extra.c | 10 +++------- mysql-test/r/rpl_change_master.result | 2 +- mysql-test/t/rpl_change_master.test | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index fcc753b62e5..10f52f1e39a 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -33,15 +33,11 @@ Used when function is one of: HA_EXTRA_WRITE_CACHE HA_EXTRA_CACHE - HA_EXTRA_BULK_INSERT_BEGIN - If extra_arg is 0, then the default cache size is used. - HA_EXTRA_BULK_INSERT_FLUSH - extra_arg is a a pointer to which index to flush (uint*) - RETURN VALUES - 0 ok + RETURN VALUES + 0 ok + # error */ - int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) { int error=0; diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result index 546a0ee2710..a6342d47b49 100644 --- a/mysql-test/r/rpl_change_master.result +++ b/mysql-test/r/rpl_change_master.result @@ -8,7 +8,7 @@ select get_lock("a",5); get_lock("a",5) 1 create table t1(n int); -insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(1+get_lock("a",15)*0); insert into t1 values(2); stop slave; select * from t1; diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test index 94f044d5413..e6452b5b619 100644 --- a/mysql-test/t/rpl_change_master.test +++ b/mysql-test/t/rpl_change_master.test @@ -4,11 +4,11 @@ connection slave; select get_lock("a",5); connection master; create table t1(n int); -insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(1+get_lock("a",15)*0); insert into t1 values(2); save_master_pos; connection slave; -sleep 3; # can't sync_with_master as we should be blocked +--real_sleep 3; # can't sync_with_master as we should be blocked stop slave; select * from t1; --replace_result $MASTER_MYPORT MASTER_MYPORT From 5474ada47a285582cbed6df9ce5a0cd2fdbaa14c Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Tue, 25 Nov 2003 23:52:10 +0200 Subject: [PATCH 57/89] added collation processing in UNION merging temporary table BLOB now is longblob --- mysql-test/r/create.result | 2 +- mysql-test/r/type_blob.result | 2 +- mysql-test/r/type_ranges.result | 4 +- mysql-test/r/union.result | 65 +++++++++++++++++++++++++++++++-- mysql-test/t/union.test | 29 ++++++++++++++- sql/field.h | 2 +- sql/item.cc | 34 +++++++++++++++-- sql/item.h | 2 +- sql/sql_union.cc | 3 +- 9 files changed, 126 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 28f06f0bf47..fe613e3c7fe 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -404,7 +404,7 @@ d date 0000-00-00 e char(1) f datetime 0000-00-00 00:00:00 g time 00:00:00 -h mediumblob +h longblob dd time 00:00:00 select * from t2; a b c d e f g h dd diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index d1147e55119..c521aa0296c 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -508,5 +508,5 @@ drop table t1; create table t1 select load_file('../../std_data/words.dat'); show full fields from t1; Field Type Collation Null Key Default Extra Privileges Comment -load_file('../../std_data/words.dat') mediumblob NULL YES NULL select,insert,update,references +load_file('../../std_data/words.dat') longblob NULL YES NULL select,insert,update,references drop table t1; diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index b665f78bbce..512df8fbaa9 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -271,8 +271,8 @@ Field Type Collation Null Key Default Extra Privileges Comment auto bigint(17) unsigned NULL PRI 0 select,insert,update,references t1 bigint(1) NULL 0 select,insert,update,references t2 char(1) latin1_swedish_ci select,insert,update,references -t3 mediumtext latin1_swedish_ci select,insert,update,references -t4 mediumtext latin1_bin select,insert,update,references +t3 longtext latin1_swedish_ci select,insert,update,references +t4 longtext latin1_bin select,insert,update,references select * from t2; auto t1 t2 t3 t4 11 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 16640c78cb8..d01ecbc39b7 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -556,8 +556,8 @@ t1 CREATE TABLE `t1` ( `a` double(4,1) NOT NULL default '0.0' ) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; -create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob); -insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest'); +create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text); +insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest'); create table t1 SELECT it2 from t2 UNION select it1 from t2; select * from t1; it2 @@ -720,7 +720,7 @@ tetetetetest show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `dt` blob + `dt` longblob ) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT sv from t2 UNION select b from t2; @@ -731,7 +731,7 @@ tetetetetest show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `sv` blob + `sv` longblob ) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2; @@ -745,4 +745,61 @@ Table Create Table t1 CREATE TABLE `t1` ( `i` blob ) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT sv from t2 UNION select tx from t2; +select * from t1; +sv +testv +teeeeeeeeeeeest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `sv` text +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT b from t2 UNION select tx from t2; +select * from t1; +b +tetetetetest +teeeeeeeeeeeest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` longblob +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1,t2; +create table t1 (d decimal(10,1)); +create table t2 (d decimal(10,9)); +insert into t1 values ("100000000.0"); +insert into t2 values ("1.23456780"); +create table t3 select * from t2 union select * from t1; +select * from t3; +d +1.234567800 +100000000.0 +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `d` decimal(10,9) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1,t2,t3; +create table t1 select 1 union select -1; +select * from t1; +1 +1 +-1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `1` bigint(1) NOT NULL default '0' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 select _latin1"test" union select _latin2"testt" ; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'UNION' +create table t1 select _latin2"test" union select _latin2"testt" ; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `test` char(5) character set latin2 NOT NULL default '' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 9e02daf22fa..b758d57fa39 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -321,8 +321,8 @@ select * from t1; show create table t1; drop table t1; -create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob); -insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest'); +create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text); +insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest'); create table t1 SELECT it2 from t2 UNION select it1 from t2; select * from t1; @@ -391,4 +391,29 @@ drop table t1; create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2; select * from t1; show create table t1; +drop table t1; +create table t1 SELECT sv from t2 UNION select tx from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT b from t2 UNION select tx from t2; +select * from t1; +show create table t1; drop table t1,t2; +create table t1 (d decimal(10,1)); +create table t2 (d decimal(10,9)); +insert into t1 values ("100000000.0"); +insert into t2 values ("1.23456780"); +create table t3 select * from t2 union select * from t1; +select * from t3; +show create table t3; +drop table t1,t2,t3; +create table t1 select 1 union select -1; +select * from t1; +show create table t1; +drop table t1; +-- error 1266 +create table t1 select _latin1"test" union select _latin2"testt" ; +create table t1 select _latin2"test" union select _latin2"testt" ; +show create table t1; +drop table t1; \ No newline at end of file diff --git a/sql/field.h b/sql/field.h index cb44ab76439..0b6ba7dde09 100644 --- a/sql/field.h +++ b/sql/field.h @@ -941,7 +941,7 @@ public: struct st_table *table_arg, CHARSET_INFO *cs) :Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0, NONE, field_name_arg, table_arg, cs), - geom_flag(true), packlength(3) + geom_flag(true), packlength(4) { flags|= BLOB_FLAG; } diff --git a/sql/item.cc b/sql/item.cc index c26e00456b7..97ef19d089b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2005,17 +2005,24 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item) field_example= ((Item_field*) item)->field; else field_example= 0; + collation.set(item->collation); } -// STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT +/* + STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT + + ROW_RESULT should never appear in Item_type_holder::join_types, + but it is included in following table just to make table full + (there DBUG_ASSERT in function to catch ROW_RESULT) +*/ static Item_result type_convertor[4][4]= {{STRING_RESULT, STRING_RESULT, STRING_RESULT, ROW_RESULT}, {STRING_RESULT, REAL_RESULT, REAL_RESULT, ROW_RESULT}, {STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT}, {ROW_RESULT, ROW_RESULT, ROW_RESULT, ROW_RESULT}}; -void Item_type_holder::join_types(THD *thd, Item *item) +bool Item_type_holder::join_types(THD *thd, Item *item) { bool change_field= 0, skip_store_field= 0; Item_result new_type= type_convertor[item_type][item->result_type()]; @@ -2045,14 +2052,20 @@ void Item_type_holder::join_types(THD *thd, Item *item) (max_length < item->max_length) || ((new_type == INT_RESULT) && (decimals < item->decimals)) || - (!maybe_null && item->maybe_null)) + (!maybe_null && item->maybe_null) || + (item_type == STRING_RESULT && new_type == STRING_RESULT && + !my_charset_same(collation.collation, item->collation.collation))) { // new field has some parameters worse then current skip_store_field|= (change_field && (max_length > item->max_length) || ((new_type == INT_RESULT) && (decimals > item->decimals)) || - (maybe_null && !item->maybe_null)); + (maybe_null && !item->maybe_null) || + (item_type == STRING_RESULT && + new_type == STRING_RESULT && + !my_charset_same(collation.collation, + item->collation.collation))); /* It is safe assign pointer on field, because it will be used just after all JOIN::prepare calls and before any SELECT execution @@ -2062,12 +2075,25 @@ void Item_type_holder::join_types(THD *thd, Item *item) else field_example= ((Item_field*) item)->field; + const char *old_cs= collation.collation->name, + *old_derivation= collation.derivation_name(); + if (item_type == STRING_RESULT && collation.aggregate(item->collation)) + { + my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0), + old_cs, old_derivation, + item->collation.collation->name, + item->collation.derivation_name(), + "UNION"); + return 1; + } + max_length= max(max_length, item->max_length); decimals= max(decimals, item->decimals); maybe_null|= item->maybe_null; item_type= new_type; } DBUG_ASSERT(item_type != ROW_RESULT); + return 0; } diff --git a/sql/item.h b/sql/item.h index c79964f5811..23b0cf018e1 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1005,7 +1005,7 @@ public: double val(); longlong val_int(); String *val_str(String*); - void join_types(THD *thd, Item *); + bool join_types(THD *thd, Item *); Field *example() { return field_example; } }; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index e2c90e4ff4c..44a30082c0a 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -197,7 +197,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) Item *type, *item; while((type= tp++, item= it++)) { - ((Item_type_holder*)type)->join_types(thd, item); + if (((Item_type_holder*)type)->join_types(thd, item)) + DBUG_RETURN(-1) } } } From 413f6b2f83e333099343597127e0374becb0d06a Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 25 Nov 2003 15:00:31 -0800 Subject: [PATCH 58/89] sql_union.cc: Fixed a bug: missing semicolon. --- sql/sql_union.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 44a30082c0a..56713e42244 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -198,7 +198,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) while((type= tp++, item= it++)) { if (((Item_type_holder*)type)->join_types(thd, item)) - DBUG_RETURN(-1) + DBUG_RETURN(-1); } } } From e54f7400ab05dd87e99c2488a8e86f3e4aa21022 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 25 Nov 2003 17:21:43 -0800 Subject: [PATCH 59/89] mf_keycache.c: Fixed typo that caused blocking key cache usage after resize. Removed wrong re-initialization of resize queue in init_key_cache. --- mysys/mf_keycache.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 6b1535e1a65..f9b11e97f47 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -141,9 +141,9 @@ KEY_CACHE *dflt_key_cache= &dflt_key_cache_var; #define FLUSH_CACHE 2000 /* sort this many blocks at once */ static int flush_all_key_blocks(KEY_CACHE *keycache); -static inline void link_into_queue(KEYCACHE_WQUEUE *wqueue, +static void link_into_queue(KEYCACHE_WQUEUE *wqueue, struct st_my_thread_var *thread); -static inline void unlink_from_queue(KEYCACHE_WQUEUE *wqueue, +static void unlink_from_queue(KEYCACHE_WQUEUE *wqueue, struct st_my_thread_var *thread); static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block); static void test_key_cache(KEY_CACHE *keycache, @@ -192,8 +192,8 @@ static long keycache_thread_id; KEYCACHE_DBUG_PRINT(l,("|thread %ld",keycache_thread_id)) #define KEYCACHE_THREAD_TRACE_BEGIN(l) \ - { struct st_my_thread_var *thread_var =my_thread_var; \ - keycache_thread_id=my_thread_var->id; \ + { struct st_my_thread_var *thread_var= my_thread_var; \ + keycache_thread_id= my_thread_var->id; \ KEYCACHE_DBUG_PRINT(l,("[thread %ld",keycache_thread_id)) } #define KEYCACHE_THREAD_TRACE_END(l) \ @@ -289,6 +289,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, keycache->key_cache_inited= 1; keycache->in_init= 0; pthread_mutex_init(&keycache->cache_lock, MY_MUTEX_INIT_FAST); + keycache->resize_queue.last_thread= NULL; } keycache->key_cache_mem_size= use_mem; @@ -374,7 +375,6 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, keycache->cnt_for_resize_op= 0; keycache->resize_in_flush= 0; keycache->can_be_used= 1; - keycache->resize_queue.last_thread= NULL; keycache->waiting_for_hash_link.last_thread= NULL; keycache->waiting_for_block.last_thread= NULL; @@ -464,7 +464,7 @@ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, keycache_pthread_mutex_lock(&keycache->cache_lock); wqueue= &keycache->resize_queue; - thread=my_thread_var; + thread= my_thread_var; link_into_queue(wqueue, thread); while (wqueue->last_thread->next != thread) @@ -478,6 +478,7 @@ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, /* TODO: if this happens, we should write a warning in the log file ! */ keycache->resize_in_flush= 0; blocks= 0; + keycache->can_be_used= 0; goto finish; } keycache->resize_in_flush= 0; @@ -497,8 +498,6 @@ finish: /* Signal for the next resize request to proceeed if any */ if (wqueue->last_thread) keycache_pthread_cond_signal(&wqueue->last_thread->next->suspend); - - keycache->can_be_used= blocks <= 0; keycache_pthread_mutex_unlock(&keycache->cache_lock); return blocks; } @@ -733,8 +732,8 @@ static inline void add_to_queue(KEYCACHE_WQUEUE *wqueue, static void release_queue(KEYCACHE_WQUEUE *wqueue) { - struct st_my_thread_var *last=wqueue->last_thread; - struct st_my_thread_var *next=last->next; + struct st_my_thread_var *last= wqueue->last_thread; + struct st_my_thread_var *next= last->next; struct st_my_thread_var *thread; do { @@ -1052,7 +1051,7 @@ static inline void remove_reader(BLOCK_LINK *block) static inline void wait_for_readers(KEY_CACHE *keycache, BLOCK_LINK *block) { - struct st_my_thread_var *thread=my_thread_var; + struct st_my_thread_var *thread= my_thread_var; while (block->hash_link->requests) { block->condvar= &thread->suspend; From ed6e446225a8ee942f8acfdc6074158425c370a1 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Wed, 26 Nov 2003 03:30:00 +0200 Subject: [PATCH 60/89] Added compilation comment to 'show variables' This makes it possible to check origin of binary from the output of 'show variables' --- include/mysql_version.h.in | 1 + sql/mysqld.cc | 4 ++-- sql/set_var.cc | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in index da184665f6e..41d4ce081fb 100644 --- a/include/mysql_version.h.in +++ b/include/mysql_version.h.in @@ -19,6 +19,7 @@ #define MYSQL_PORT @MYSQL_TCP_PORT@ #define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@" #define MYSQL_CONFIG_NAME "my" +#define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@" /* mysqld compile time options */ #ifndef MYSQL_CHARSET diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e5ddbfe7a33..4c6cf1d5039 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4278,8 +4278,8 @@ struct show_var_st status_vars[]= { static void print_version(void) { - printf("%s Ver %s for %s on %s\n",my_progname, - server_version,SYSTEM_TYPE,MACHINE_TYPE); + printf("%s Ver %s for %s on %s (%s)\n",my_progname, + server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT); } static void use_help(void) diff --git a/sql/set_var.cc b/sql/set_var.cc index 03651967a7a..4aea611e401 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -593,6 +593,7 @@ struct show_var_st init_vars[]= { SHOW_SYS}, {sys_trans_prealloc_size.name, (char*) &sys_trans_prealloc_size, SHOW_SYS}, {"version", server_version, SHOW_CHAR}, + {"version_comment", (char*) MYSQL_COMPILATION_COMMENT, SHOW_CHAR}, {sys_net_wait_timeout.name, (char*) &sys_net_wait_timeout, SHOW_SYS}, {NullS, NullS, SHOW_LONG} }; From b99377f3d2966d4861ac7ea39a22f09a257f6287 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 25 Nov 2003 22:20:31 -0800 Subject: [PATCH 61/89] mi_keycache.c: Removed FLUSH_REMOVE flag (replaced it by FLUSH_RELEASE). my_sys.h: Removed FLUSH_REMOVE flag. --- include/my_sys.h | 3 +-- myisam/mi_keycache.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 604eaf34fb7..59d5767d204 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -265,8 +265,7 @@ enum cache_type enum flush_type { - FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE, - FLUSH_REMOVE + FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE }; typedef struct st_record_cache /* Used when cacheing records */ diff --git a/myisam/mi_keycache.c b/myisam/mi_keycache.c index fc51f331d76..99a2fd6db15 100644 --- a/myisam/mi_keycache.c +++ b/myisam/mi_keycache.c @@ -76,7 +76,7 @@ int mi_assign_to_key_cache(MI_INFO *info, in the old key cache. */ - if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_REMOVE)) + if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)) { error= my_errno; mi_mark_crashed(info); /* Mark that table must be checked */ @@ -90,7 +90,7 @@ int mi_assign_to_key_cache(MI_INFO *info, (This can never fail as there is never any not written data in the new key cache) */ - (void) flush_key_blocks(key_cache, share->kfile, FLUSH_REMOVE); + (void) flush_key_blocks(key_cache, share->kfile, FLUSH_RELEASE); /* ensure that setting the key cache and changing the multi_key_cache From 611096a709bf7e5d7f6a507009c41ea7f4ac32cb Mon Sep 17 00:00:00 2001 From: "hf@deer.(none)" <> Date: Wed, 26 Nov 2003 13:38:32 +0400 Subject: [PATCH 62/89] SCRUM WL#1284 (warnings about --skip-name-resolve) Messages corrected --- sql/share/czech/errmsg.txt | 2 +- sql/share/danish/errmsg.txt | 2 +- sql/share/dutch/errmsg.txt | 2 +- sql/share/english/errmsg.txt | 2 +- sql/share/estonian/errmsg.txt | 2 +- sql/share/french/errmsg.txt | 2 +- sql/share/german/errmsg.txt | 2 +- sql/share/greek/errmsg.txt | 2 +- sql/share/hungarian/errmsg.txt | 2 +- sql/share/italian/errmsg.txt | 2 +- sql/share/japanese/errmsg.txt | 2 +- sql/share/korean/errmsg.txt | 2 +- sql/share/norwegian-ny/errmsg.txt | 2 +- sql/share/norwegian/errmsg.txt | 2 +- sql/share/polish/errmsg.txt | 2 +- sql/share/portuguese/errmsg.txt | 2 +- sql/share/romanian/errmsg.txt | 2 +- sql/share/russian/errmsg.txt | 2 +- sql/share/serbian/errmsg.txt | 2 +- sql/share/slovak/errmsg.txt | 2 +- sql/share/spanish/errmsg.txt | 2 +- sql/share/swedish/errmsg.txt | 2 +- sql/share/ukrainian/errmsg.txt | 2 +- sql/sql_acl.cc | 16 ++++++++-------- 24 files changed, 31 insertions(+), 31 deletions(-) diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 02dd0b18940..50fd122b2ba 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -296,4 +296,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index f4dc64282e6..48fc3127f73 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -290,4 +290,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index c034e18e055..473eb897778 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -298,4 +298,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 5e2c6844507..d1873bdb568 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -287,4 +287,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 43204a3979b..0212550639d 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -292,4 +292,4 @@ character-set=latin7 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index b7b03250341..cc30a9ebbd3 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -287,4 +287,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index bb8aa296d58..bea0f2521d0 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -299,4 +299,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 70913d58ff7..83c9a894109 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -287,4 +287,4 @@ character-set=greek "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index a79bf7b184c..be940c399b0 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -289,4 +289,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index c8fc5079c75..c549a54b008 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -287,4 +287,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index b8ece1ecf4c..8414849ebe8 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -289,4 +289,4 @@ character-set=ujis "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index d57c3e13efe..e8a644796e2 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -287,4 +287,4 @@ character-set=euckr "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 01f50789449..89bd4392164 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -289,4 +289,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 806729ccced..26feccbb894 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -289,4 +289,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 30c77b41ed0..8696b15b889 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -291,4 +291,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index d4232007aed..21e79b8deba 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -288,4 +288,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index f4712f75180..da898445605 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -291,4 +291,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 30b0b8b4931..249e58b802a 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -289,4 +289,4 @@ character-set=koi8r "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu, ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index 4d2ce07e369..c631a171e05 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -282,4 +282,4 @@ character-set=cp1250 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index fb062bc29e8..344a41f742c 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -295,4 +295,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index c4d4e1c9e93..dec8735801f 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -289,4 +289,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 143aa6af9eb..ed8ad548fe2 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -287,4 +287,4 @@ character-set=latin1 "Storleken av "Query cache" kunde inte sättas till %lu, ny storlek är %lu", "Kolumn '%-.64s' kan inte vara del av ett FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 416d6fac572..8e9d336cf17 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -292,4 +292,4 @@ character-set=koi8u "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu, ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", -"Can't resolve '%s' if --skip-name-resolve active", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 0ce544edda5..038fac3d275 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -202,8 +202,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) host.sort= get_sort(2,host.host.hostname,host.db); if (check_no_resolve && hostname_requires_resolving(host.host.hostname)) { - sql_print_error("Error in table 'host' entry '%s|%s'. " - "Can't resolve '%s' if --skip-name-resolve active. Skipped", + sql_print_error("Warning: 'host' entry '%s|%s' " + "ignored in --skip-name-resolve mode.", host.host.hostname, host.db, host.host.hostname); continue; } @@ -270,8 +270,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) user.user= get_field(&mem, table->field[1]); if (check_no_resolve && hostname_requires_resolving(user.host.hostname)) { - sql_print_error("Error in table 'user' entry '%s@%s'. " - "Can't resolve '%s' if --skip-name-resolve active. Skipped", + sql_print_error("Warning: 'user' entry '%s@%s' " + "ignored in --skip-name-resolve mode.", user.user, user.host.hostname, user.host.hostname); continue; } @@ -372,8 +372,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) db.user=get_field(&mem, table->field[2]); if (check_no_resolve && hostname_requires_resolving(db.host.hostname)) { - sql_print_error("Error in table 'db' entry '%s %s@%s'. " - "Can't resolve '%s' if --skip-name-resolve active. Skipped", + sql_print_error("Warning: 'db' entry '%s %s@%s' " + "ignored in --skip-name-resolve mode.", db.db, db.user, db.host.hostname, db.host.hostname); continue; } @@ -2549,8 +2549,8 @@ my_bool grant_init(THD *org_thd) if (hostname_requires_resolving(mem_check->host)) { char buff[MAX_FIELD_WIDTH]; - sql_print_error("Error in table 'tables_priv' entry '%s %s@%s'. " - "Can't resolve '%s' if --skip-name-resolve active. Skipped", + sql_print_error("Warning: 'tables_priv' entry '%s %s@%s' " + "ignored in --skip-name-resolve mode.", mem_check->tname, mem_check->user, mem_check->host, mem_check->host); continue; From 6549791f2151c3bee95eee030c64d1817098fe72 Mon Sep 17 00:00:00 2001 From: "lenz@kallisto.local" <> Date: Wed, 26 Nov 2003 15:22:30 +0100 Subject: [PATCH 63/89] - fixed compile error in tests/client_test.c (declarations should be on top of a block) --- tests/client_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/client_test.c b/tests/client_test.c index d2d77c9965c..e074d46a788 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -8069,9 +8069,9 @@ static void test_bug1946() { MYSQL_STMT *stmt; int rc; + const char *query= "INSERT INTO prepare_command VALUES (?)"; myheader("test_bug1946"); - const char *query= "INSERT INTO prepare_command VALUES (?)"; rc = mysql_query(mysql, "DROP TABLE IF EXISTS prepare_command"); myquery(rc); From 292b0a1892d07b171dd3d77320f1e61c3efc716e Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Wed, 26 Nov 2003 17:06:24 +0100 Subject: [PATCH 64/89] Fix for BUG#1960 "date_format() returns spurious '-' for valid dates". It was a forgotten ltime->neg=0 (neg was the only forgotten variable). I scanned field.cc for other places where we would forget to set neg, found none. A test for the bug. --- mysql-test/r/date_formats.result | 7 +++++++ mysql-test/t/date_formats.test | 9 +++++++++ sql/field.cc | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 5eb21c40a3e..ee4fa074477 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -330,3 +330,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 select high_priority makedate(1997,1) AS `makedate(1997,1)`,addtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff(_latin1'01.01.97 11:59:59.000001 PM',_latin1'31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date(_latin1'15-01-2001 12:59:59',_latin1'%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond(_latin1'1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")` +create table t1 (d date); +insert into t1 values ('2004-07-14'),('2005-07-14'); +select date_format(d,"%d") from t1 order by 1; +date_format(d,"%d") +14 +14 +drop table t1; diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index d9219d3ac2e..7b88c0ecf72 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -200,3 +200,12 @@ select get_format(DATE, 'TEST') as a; select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA')); explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001"); + +# +# Test of date_format() +# + +create table t1 (d date); +insert into t1 values ('2004-07-14'),('2005-07-14'); +select date_format(d,"%d") from t1 order by 1; +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index 9b8e386fdc5..23f6e1232b6 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3757,7 +3757,7 @@ bool Field_newdate::get_date(TIME *ltime,uint fuzzydate) ltime->month= (tmp >> 5) & 15; ltime->year= (tmp >> 9); ltime->time_type=TIMESTAMP_DATE; - ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; + ltime->hour= ltime->minute= ltime->second= ltime->second_part= ltime->neg= 0; return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0; } From b633c0ffeffe1913189574bdbd9456545cc3a164 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Wed, 26 Nov 2003 19:10:30 +0200 Subject: [PATCH 65/89] avoiding coping tmp_table_param --- sql/sql_union.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 44a30082c0a..79e1cdef098 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -123,9 +123,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) DBUG_RETURN(0); prepared= 1; res= 0; - TMP_TABLE_PARAM tmp_table_param; + TMP_TABLE_PARAM *tmp_table_param, tmp_table_param_storage; - bzero((char *)&tmp_table_param,sizeof(TMP_TABLE_PARAM)); thd->lex.current_select= sl= first_select= first_select_in_union(); found_rows_for_union= first_select->options & OPTION_FOUND_ROWS; @@ -136,14 +135,17 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) if (!(tmp_result= union_result= new select_union(0))) goto err; union_result->not_describe= 1; - union_result->tmp_table_param= tmp_table_param; + tmp_table_param= &union_result->tmp_table_param; } else { tmp_result= sel_result; // single select should be processed like select in p[arantses first_select->braces= 1; + tmp_table_param= &tmp_table_param_storage; } + bzero((char *)tmp_table_param,sizeof(TMP_TABLE_PARAM)); + for (;sl; sl= sl->next_select()) { @@ -205,8 +207,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) if (first_select->next_select()) { - tmp_table_param.field_count= types.elements; - if (!(table= create_tmp_table(thd, &tmp_table_param, types, + tmp_table_param->field_count= types.elements; + if (!(table= create_tmp_table(thd, tmp_table_param, types, (ORDER*) 0, !union_option, 1, (first_select_in_union()->options | thd->options | From 2556abd912ffca3d2327b149f26ba1862b1f39c7 Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Wed, 26 Nov 2003 20:18:55 +0300 Subject: [PATCH 66/89] cleanup --- tests/client_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/client_test.c b/tests/client_test.c index e074d46a788..1575a3120ab 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -8234,8 +8234,6 @@ int main(int argc, char **argv) /* Used for internal new development debugging */ test_drop_temp(); /* to test DROP TEMPORARY TABLE Access checks */ #endif - test_bug1946(); /* test that placeholders are allowed only in - prepared queries */ test_fetch_seek(); /* to test stmt seek() functions */ test_fetch_nobuffs(); /* to fecth without prior bound buffers */ test_open_direct(); /* direct execution in the middle of open stmts */ @@ -8335,6 +8333,8 @@ int main(int argc, char **argv) test_bug1180(); /* BUG#1180 */ test_bug1500(); /* BUG#1500 */ test_bug1644(); /* BUG#1644 */ + test_bug1946(); /* test that placeholders are allowed only in + prepared queries */ end_time= time((time_t *)0); total_time+= difftime(end_time, start_time); From 9be8ea49e16f77304f2d604f52c133222aaeb3b5 Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Wed, 26 Nov 2003 20:23:28 +0300 Subject: [PATCH 67/89] cleanup --- tests/client_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/client_test.c b/tests/client_test.c index 1575a3120ab..048935d2efb 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -7962,7 +7962,7 @@ static void test_bug1500() MYSQL_BIND bind[3]; int rc; long int_data[3]= {2,3,4}; - char *data; + const char *data; myheader("test_bug1500"); @@ -8021,7 +8021,7 @@ static void test_bug1500() data= "Dogs"; bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= data; + bind[0].buffer= (char *) data; bind[0].buffer_length= strlen(data); bind[0].is_null= 0; bind[0].length= 0; @@ -8049,7 +8049,7 @@ static void test_bug1500() data= "Grave"; bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= data; + bind[0].buffer= (char *) data; bind[0].buffer_length= strlen(data); bind[0].is_null= 0; bind[0].length= 0; From 908bc2221796d37b93cd77af3cce95677fd97e5a Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Wed, 26 Nov 2003 20:12:26 +0200 Subject: [PATCH 68/89] avoiding coping tmptable_param --- sql/sql_derived.cc | 9 ++++----- sql/sql_union.cc | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 20a1f7f0124..2de56d715ea 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -128,14 +128,14 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); - tmp_table_param.field_count= unit->types.elements; + bzero((char*) &derived_result->tmp_table_param, sizeof(tmp_table_param)); + derived_result->tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be processed */ - if (!(table= create_tmp_table(thd, &tmp_table_param, unit->types, - (ORDER*) 0, + if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param, + unit->types, (ORDER*) 0, is_union && !unit->union_option, 1, (first_select->options | thd->options | TMP_TABLE_ALL_COLUMNS), @@ -146,7 +146,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, goto exit; } derived_result->set_table(table); - derived_result->tmp_table_param=tmp_table_param; unit->offset_limit_cnt= first_select->offset_limit; unit->select_limit_cnt= first_select->select_limit+ diff --git a/sql/sql_union.cc b/sql/sql_union.cc index c4ef382cf32..7657065edb4 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -144,7 +144,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) first_select->braces= 1; tmp_table_param= &tmp_table_param_storage; } - bzero((char *)tmp_table_param,sizeof(TMP_TABLE_PARAM)); + bzero((char *)tmp_table_param, sizeof(TMP_TABLE_PARAM)); for (;sl; sl= sl->next_select()) From 9702a4027dc00ba44a8e8927821e15fabbbae2c0 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Thu, 27 Nov 2003 09:34:41 +0200 Subject: [PATCH 69/89] removed unused variable --- sql/sql_derived.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 2de56d715ea..efc15ffcb18 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -67,7 +67,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, int res; select_union *derived_result; TABLE_LIST *tables= (TABLE_LIST *)first_select->table_list.first; - TMP_TABLE_PARAM tmp_table_param; bool is_union= first_select->next_select() && first_select->next_select()->linkage == UNION_TYPE; bool is_subsel= first_select->first_inner_unit() ? 1: 0; @@ -128,7 +127,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - bzero((char*) &derived_result->tmp_table_param, sizeof(tmp_table_param)); + bzero((char*) &derived_result->tmp_table_param, sizeof(TMP_TABLE_PARAM)); derived_result->tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be From d7b021a308a4e78d01111deefff137693fcf305d Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Thu, 27 Nov 2003 19:14:16 +0300 Subject: [PATCH 70/89] memory leak (no delete for query= new String) fixed --- sql/sql_prepare.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index e76ff833e20..9f7c0bc0b0c 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -426,8 +426,10 @@ static bool insert_params_withlog(PREP_STMT *stmt, uchar *pos, uchar *read_pos) Item_param *param; DBUG_ENTER("insert_params_withlog"); - String str, *res, *query= new String(stmt->query->alloced_length()); - query->copy(*stmt->query); + String str, query, *res; + + if (query.copy(*stmt->query)) + DBUG_RETURN(1); ulong param_no= 0; uint32 length= 0; @@ -451,16 +453,14 @@ static bool insert_params_withlog(PREP_STMT *stmt, uchar *pos, uchar *read_pos) res= param->query_val_str(&str); } } - if (query->replace(param->pos_in_query+length, 1, *res)) + if (query.replace(param->pos_in_query+length, 1, *res)) DBUG_RETURN(1); length+= res->length()-1; param_no++; } - if (alloc_query(stmt->thd, (char *)query->ptr(), query->length()+1)) + if (alloc_query(thd, (char *)query.ptr(), query.length()+1)) DBUG_RETURN(1); - - query->free(); DBUG_RETURN(0); } From bd0aef2df375a567128672cf1184d6e856065106 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Thu, 27 Nov 2003 19:45:28 +0200 Subject: [PATCH 71/89] code coverage for UNIONs --- mysql-test/r/subselect.result | 8 ++++---- mysql-test/r/union.result | 20 ++++++++++++++++++++ mysql-test/t/subselect.test | 2 +- mysql-test/t/union.test | 25 ++++++++++++++++++++++--- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 95638cbee41..71755aac52d 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -149,10 +149,10 @@ select (select a from t1 where t1.a=t2.b), a from t2; (select a from t1 where t1.a=t2.b) a NULL 1 NULL 2 -select (select a from t1), a from t2; -(select a from t1) a -2 1 -2 2 +select (select a from t1), a, (select 1 union select 2 limit 1) from t2; +(select a from t1) a (select 1 union select 2 limit 1) +2 1 1 +2 2 1 select (select a from t3), a from t2; (select a from t3) a NULL 1 diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index d01ecbc39b7..241b9847c02 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -803,3 +803,23 @@ t1 CREATE TABLE `t1` ( `test` char(5) character set latin2 NOT NULL default '' ) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +create table t1 (s char(200)); +insert into t1 values (repeat("1",200)); +create table t2 select * from t1; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +set local tmp_table_size=1024; +select count(*) from (select * from t1 union all select * from t2 order by 1) b; +count(*) +21 +select count(*) from t1; +count(*) +8 +select count(*) from t2; +count(*) +13 +drop table t1,t2; +set local tmp_table_size=default; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 75ca521d24e..e53679b444e 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -67,7 +67,7 @@ insert into t4 values (4,8),(3,8),(5,9); select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1; select (select a from t1 where t1.a=t2.a), a from t2; select (select a from t1 where t1.a=t2.b), a from t2; -select (select a from t1), a from t2; +select (select a from t1), a, (select 1 union select 2 limit 1) from t2; select (select a from t3), a from t2; select * from t2 where t2.a=(select a from t1); insert into t3 values (6),(7),(3); diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index b758d57fa39..e302378e117 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -306,8 +306,6 @@ drop table t1, t2; # # types conversions # - - create table t1 SELECT "a" as a UNION select "aa" as a; select * from t1; show create table t1; @@ -416,4 +414,25 @@ drop table t1; create table t1 select _latin1"test" union select _latin2"testt" ; create table t1 select _latin2"test" union select _latin2"testt" ; show create table t1; -drop table t1; \ No newline at end of file +drop table t1; + +# +# conversion memory->disk table +# +# +# conversion memory->disk table +# +create table t1 (s char(200)); +insert into t1 values (repeat("1",200)); +create table t2 select * from t1; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +set local tmp_table_size=1024; +select count(*) from (select * from t1 union all select * from t2 order by 1) b; +select count(*) from t1; +select count(*) from t2; +drop table t1,t2; +set local tmp_table_size=default; From 48ef39ee65d871f5df0417fe0b9ceee536f36d4b Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Fri, 28 Nov 2003 01:54:34 +0300 Subject: [PATCH 72/89] cleanup: no need to set rpl_parse, rpl_probe and rpl_pivot to zero as whole mysql structure is bzeroed in mysql_init(0) few lines before --- libmysql/libmysql.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 5d809adf36a..d5fe2cddc48 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2276,8 +2276,6 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host, else if (parent->options.db) child->options.db = my_strdup(parent->options.db, MYF(0)); - child->options.rpl_parse = child->options.rpl_probe = child->rpl_pivot = 0; - return child; } From 3b9eb09276eba4542f13175a16e6d9a528cd5439 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Fri, 28 Nov 2003 01:57:05 +0300 Subject: [PATCH 73/89] no need to zero-initialize mysql->master->{rpl_pivot, options.rpl_parse, options.rpl_probe} as they are zero-initialized in spawn_init() --- libmysql/libmysql.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index d5fe2cddc48..0c9c68f4505 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2289,9 +2289,6 @@ STDCALL mysql_set_master(MYSQL* mysql, const char* host, mysql_close(mysql->master); if (!(mysql->master = spawn_init(mysql, host, port, user, passwd))) return 1; - mysql->master->rpl_pivot = 0; - mysql->master->options.rpl_parse = 0; - mysql->master->options.rpl_probe = 0; return 0; } From 38b140fb0976872876cc883c894b95540304a7ec Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Fri, 28 Nov 2003 02:50:58 +0300 Subject: [PATCH 74/89] fix: 2 forgotten 'break;' statements added --- sql-common/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql-common/client.c b/sql-common/client.c index 878a8beacba..6261df944d6 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2535,6 +2535,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); mysql->options.shared_memory_base_name=my_strdup(arg,MYF(MY_WME)); #endif + break; case MYSQL_OPT_USE_REMOTE_CONNECTION: case MYSQL_OPT_USE_EMBEDDED_CONNECTION: case MYSQL_OPT_GUESS_CONNECTION: @@ -2542,6 +2543,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) break; case MYSQL_SET_CLIENT_IP: mysql->options.client_ip= my_strdup(arg, MYF(MY_WME)); + break; default: DBUG_RETURN(1); } From 2e8cf31abc7bb1bb00eb9dbf93e3b8b253889fed Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Fri, 28 Nov 2003 13:11:44 +0300 Subject: [PATCH 75/89] Second part of WL #519: Client option secure-auth deployed on all possible layers: - mysql client command-line and config file option - mysql_options option MYSQL_SECURE_AUTH - mysql_real_connect will automatically take into account that option if mysql->options.my_cnf_file/my_cnf_group is set --- client/client_priv.h | 2 +- client/mysql.cc | 7 ++++++- include/errmsg.h | 1 + include/mysql.h | 4 +++- libmysql/errmsg.c | 9 ++++++--- sql-common/client.c | 24 +++++++++++++++++++++--- 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index d655619516d..f6d766b7ef9 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -40,4 +40,4 @@ enum options_client { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, OPT_DELETE_MASTER_LOGS, OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL, OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION, - OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER }; + OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH }; diff --git a/client/mysql.cc b/client/mysql.cc index 059a1ad36f5..9062b58d09b 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -134,7 +134,7 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, vertical=0, line_numbers=1, column_names=1,opt_html=0, opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0, tty_password= 0, opt_nobeep=0, opt_reconnect=1, - default_charset_used= 0; + default_charset_used= 0, opt_secure_auth= 0; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; static my_string opt_mysql_unix_port=0; static int connect_flag=CLIENT_INTERACTIVE; @@ -623,6 +623,9 @@ static struct my_option my_long_options[] = {"max_join_size", OPT_MAX_JOIN_SIZE, "", (gptr*) &max_join_size, (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1, 0}, + {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it" + " uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth, + (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -2553,6 +2556,8 @@ sql_real_connect(char *host,char *database,char *user,char *password, } if (opt_compress) mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS); + if (opt_secure_auth) + mysql_options(&mysql, MYSQL_SECURE_AUTH, (char *) &opt_secure_auth); if (using_opt_local_infile) mysql_options(&mysql,MYSQL_OPT_LOCAL_INFILE, (char*) &opt_local_infile); #ifdef HAVE_OPENSSL diff --git a/include/errmsg.h b/include/errmsg.h index a354c125e36..24326b1efef 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -87,3 +87,4 @@ extern const char *client_errors[]; /* Error messages */ #define CR_CONN_UNKNOW_PROTOCOL 2046 #define CR_INVALID_CONN_HANDLE 2047 #define CR_MYSQL_SERVER_INIT_MISSED 2048 +#define CR_SECURE_AUTH 2049 diff --git a/include/mysql.h b/include/mysql.h index 23d89fd531f..fd0330b35da 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -145,7 +145,7 @@ enum mysql_option MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT, MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT, MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, - MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP + MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH }; struct st_mysql_options { @@ -184,6 +184,8 @@ struct st_mysql_options { #endif enum mysql_option methods_to_use; char *client_ip; + /* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */ + my_bool secure_auth; }; enum mysql_status diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 148625129b5..4dfcfe6a1d3 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -72,7 +72,8 @@ const char *client_errors[]= "Can't open shared memory. Can't send the request event to server (%lu)", "Wrong or unknown protocol", "Invalid connection handle", - "mysql_server_init wasn't called" + "mysql_server_init wasn't called", + "Connection using old (pre 4.1.1) authentication protocol refused (client option 'secure_auth' enabled)" }; /* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */ @@ -128,7 +129,8 @@ const char *client_errors[]= "Can't open shared memory. Can't send the request event to server (%lu)", "Wrong or unknown protocol", "Invalid connection handle", - "mysql_server_init wasn't called" + "mysql_server_init wasn't called", + "Connection using old (pre 4.1.1) authentication protocol refused (client option 'secure_auth' enabled)" }; #else /* ENGLISH */ @@ -182,7 +184,8 @@ const char *client_errors[]= "Can't open shared memory. Can't send the request event to server (%lu)", "Wrong or unknown protocol", "Invalid connection handle", - "mysql_server_init wasn't called" + "mysql_server_init wasn't called", + "Connection using old (pre 4.1.1) authentication protocol refused (client option 'secure_auth' enabled)" }; #endif diff --git a/sql-common/client.c b/sql-common/client.c index 878a8beacba..055aa5210b7 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -783,7 +783,7 @@ static const char *default_options[]= "connect-timeout", "local-infile", "disable-local-infile", "replication-probe", "enable-reads-from-master", "repl-parse-query", "ssl-cipher", "max-allowed-packet", "protocol", "shared-memory-base-name", - "multi-results", "multi-queries", + "multi-results", "multi-queries", "secure-auth", NullS }; @@ -991,6 +991,9 @@ void mysql_read_default_options(struct st_mysql_options *options, case 31: options->client_flag|= CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS; break; + case 32: /* secure-auth */ + options->secure_auth= TRUE; + break; default: DBUG_PRINT("warning",("unknown option: %s",option[0])); } @@ -1473,7 +1476,11 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, if (!host || !host[0]) host=mysql->options.host; if (!user || !user[0]) + { user=mysql->options.user; + if (!user) + user= ""; + } if (!passwd) { passwd=mysql->options.password; @@ -1481,6 +1488,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, if (!passwd) passwd=getenv("MYSQL_PWD"); /* get it from environment */ #endif + if (!passwd) + passwd= ""; } if (!db || !db[0]) db=mysql->options.db; @@ -1742,6 +1751,14 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, else mysql->server_capabilities&= ~CLIENT_SECURE_CONNECTION; + if (mysql->options.secure_auth && passwd[0] && + !(mysql->server_capabilities & CLIENT_SECURE_CONNECTION)) + { + strmov(net->sqlstate, unknown_sqlstate); + strmov(net->last_error, ER(net->last_errno=CR_SECURE_AUTH)); + goto error; + } + charset_number= mysql->server_language; /* Set character set */ @@ -1793,8 +1810,6 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, } /* Save connection information */ - if (!user) user=""; - if (!passwd) passwd=""; if (!my_multi_malloc(MYF(0), &mysql->host_info, (uint) strlen(host_info)+1, &mysql->host, (uint) strlen(host)+1, @@ -2542,6 +2557,9 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) break; case MYSQL_SET_CLIENT_IP: mysql->options.client_ip= my_strdup(arg, MYF(MY_WME)); + case MYSQL_SECURE_AUTH: + mysql->options.secure_auth= *(my_bool *) arg; + break; default: DBUG_RETURN(1); } From 3f6ef8d1ae9665eeec5a5116933b96978756bbf1 Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Fri, 28 Nov 2003 13:14:10 +0300 Subject: [PATCH 76/89] BK automerge tends to eat break; statements --- sql-common/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sql-common/client.c b/sql-common/client.c index 7877a2ffb2d..6b99b3424ea 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2558,6 +2558,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) break; case MYSQL_SET_CLIENT_IP: mysql->options.client_ip= my_strdup(arg, MYF(MY_WME)); + break; case MYSQL_SECURE_AUTH: mysql->options.secure_auth= *(my_bool *) arg; break; From ede8169d24c56a4e264034b3a098477072532ca5 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 Nov 2003 12:18:13 +0200 Subject: [PATCH 77/89] Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log --- Docs/mysqld_error.txt | 168 +++++++++++++++++++++++++++-------- Makefile.am | 3 +- SSL/Makefile.am | 24 +++++ configure.in | 2 +- include/sql_common.h | 3 - innobase/os/os0file.c | 2 +- innobase/srv/srv0srv.c | 4 +- innobase/srv/srv0start.c | 2 +- innobase/trx/trx0sys.c | 2 +- isam/isamchk.c | 4 +- libmysql/conf_to_src.c | 4 +- myisam/mi_check.c | 38 ++++---- myisam/mi_delete.c | 2 +- myisam/mi_page.c | 2 +- myisam/mi_preload.c | 4 +- myisam/mi_write.c | 2 +- myisam/myisampack.c | 14 +-- mysql-test/mysql-test-run.sh | 10 +-- mysys/hash.c | 5 +- mysys/mf_wcomp.c | 4 +- mysys/my_append.c | 6 +- mysys/my_copy.c | 6 +- mysys/my_redel.c | 6 +- sql-common/client.c | 9 +- sql-common/pack.c | 23 ++++- sql/ha_heap.cc | 29 +++--- sql/ha_innodb.cc | 8 +- sql/item.cc | 10 ++- sql/item.h | 10 +-- sql/item_cmpfunc.h | 16 ++-- sql/item_func.cc | 8 +- sql/item_subselect.cc | 81 ++++++++--------- sql/item_subselect.h | 6 +- sql/item_sum.cc | 6 +- sql/item_timefunc.cc | 6 +- sql/log.cc | 4 +- sql/protocol.cc | 18 ++-- sql/protocol.h | 11 ++- sql/protocol_cursor.cc | 10 +-- sql/set_var.cc | 6 +- sql/sql_class.cc | 15 +++- sql/sql_class.h | 8 +- sql/sql_derived.cc | 13 ++- sql/sql_error.cc | 3 +- sql/sql_help.cc | 2 +- sql/sql_lex.cc | 31 ++++--- sql/sql_list.h | 4 +- sql/sql_parse.cc | 16 ++-- sql/sql_select.cc | 157 ++++++++++++++++---------------- sql/sql_select.h | 14 +-- sql/sql_union.cc | 55 ++++++------ sql/sql_update.cc | 3 +- sql/sql_yacc.yy | 2 +- strings/conf_to_src.c | 10 +-- 54 files changed, 537 insertions(+), 374 deletions(-) create mode 100644 SSL/Makefile.am diff --git a/Docs/mysqld_error.txt b/Docs/mysqld_error.txt index aeb3a12c263..e567d5676aa 100644 --- a/Docs/mysqld_error.txt +++ b/Docs/mysqld_error.txt @@ -1,6 +1,8 @@ /* Copyright Abandoned 1997 TCX DataKonsult AB & Monty Program KB & Detron HB This file is public domain and comes with NO WARRANTY of any kind */ +character-set=latin1 + #define ER_HASHCHK 1000 "hashchk", #define ER_NISAMCHK 1001 @@ -14,11 +16,11 @@ #define ER_CANT_CREATE_TABLE 1005 "Can't create table '%-.64s' (errno: %d)", #define ER_CANT_CREATE_DB 1006 -"Can't create database '%-.64s'. (errno: %d)", +"Can't create database '%-.64s' (errno: %d)", #define ER_DB_CREATE_EXISTS 1007 -"Can't create database '%-.64s'. Database exists", +"Can't create database '%-.64s'; database exists", #define ER_DB_DROP_EXISTS 1008 -"Can't drop database '%-.64s'. Database doesn't exist", +"Can't drop database '%-.64s'; database doesn't exist", #define ER_DB_DROP_DELETE 1009 "Error dropping database (can't delete '%-.64s', errno: %d)", #define ER_DB_DROP_RMDIR 1010 @@ -34,7 +36,7 @@ #define ER_CANT_LOCK 1015 "Can't lock file (errno: %d)", #define ER_CANT_OPEN_FILE 1016 -"Can't open file: '%-.64s'. (errno: %d)", +"Can't open file: '%-.64s' (errno: %d)", #define ER_FILE_NOT_FOUND 1017 "Can't find file: '%-.64s' (errno: %d)", #define ER_CANT_READ_DIR 1018 @@ -44,7 +46,7 @@ #define ER_CHECKREAD 1020 "Record has changed since last read in table '%-.64s'", #define ER_DISK_FULL 1021 -"Disk full (%s). Waiting for someone to free some space....", +"Disk full (%s). Waiting for someone to free some space...", #define ER_DUP_KEY 1022 "Can't write, duplicate key in table '%-.64s'", #define ER_ERROR_ON_CLOSE 1023 @@ -62,17 +64,17 @@ #define ER_FORM_NOT_FOUND 1029 "View '%-.64s' doesn't exist for '%-.64s'", #define ER_GET_ERRNO 1030 -"Got error %d from table handler", +"Got error %d from storage engine", #define ER_ILLEGAL_HA 1031 -"Table handler for '%-.64s' doesn't have this option", +"Table storage engine for '%-.64s' doesn't have this option", #define ER_KEY_NOT_FOUND 1032 "Can't find record in '%-.64s'", #define ER_NOT_FORM_FILE 1033 "Incorrect information in file: '%-.64s'", #define ER_NOT_KEYFILE 1034 -"Incorrect key file for table: '%-.64s'. Try to repair it", +"Incorrect key file for table: '%-.64s'; try to repair it", #define ER_OLD_KEYFILE 1035 -"Old key file for table '%-.64s'; Repair it!", +"Old key file for table '%-.64s'; repair it!", #define ER_OPEN_AS_READONLY 1036 "Table '%-.64s' is read only", #define ER_OUTOFMEMORY 1037 @@ -90,9 +92,9 @@ #define ER_HANDSHAKE_ERROR 1043 "Bad handshake", #define ER_DBACCESS_DENIED_ERROR 1044 -"Access denied for user: '%-.32s@%-.64s' to database '%-.64s'", +"Access denied for user: '%-.32s'@'%-.64s' to database '%-.64s'", #define ER_ACCESS_DENIED_ERROR 1045 -"Access denied for user: '%-.32s@%-.64s' (Using password: %s)", +"Access denied for user: '%-.32s'@'%-.64s' (Using password: %s)", #define ER_NO_DB_ERROR 1046 "No Database Selected", #define ER_UNKNOWN_COM_ERROR 1047 @@ -154,7 +156,7 @@ #define ER_WRONG_AUTO_KEY 1075 "Incorrect table definition; There can only be one auto column and it must be defined as a key", #define ER_READY 1076 -"%s: ready for connections\n", +"%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d\n", #define ER_NORMAL_SHUTDOWN 1077 "%s: Normal shutdown\n", #define ER_GOT_SIGNAL 1078 @@ -170,7 +172,7 @@ #define ER_WRONG_FIELD_TERMINATORS 1083 "Field separator argument is not what is expected. Check the manual", #define ER_BLOBS_AND_NO_TERMINATED 1084 -"You can't use fixed rowlength with BLOBs. Please use 'fields terminated by'.", +"You can't use fixed rowlength with BLOBs. Please use 'fields terminated by'", #define ER_TEXTFILE_NOT_READABLE 1085 "The file '%-.64s' must be in the database directory or be readable by all", #define ER_FILE_EXISTS_ERROR 1086 @@ -180,15 +182,15 @@ #define ER_ALTER_INFO 1088 "Records: %ld Duplicates: %ld", #define ER_WRONG_SUB_KEY 1089 -"Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the table handler doesn't support unique sub keys", +"Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the storage engine doesn't support unique sub keys", #define ER_CANT_REMOVE_ALL_FIELDS 1090 "You can't delete all columns with ALTER TABLE. Use DROP TABLE instead", #define ER_CANT_DROP_FIELD_OR_KEY 1091 "Can't DROP '%-.64s'. Check that column/key exists", #define ER_INSERT_INFO 1092 "Records: %ld Duplicates: %ld Warnings: %ld", -#define ER_INSERT_TABLE_USED 1093 -"INSERT TABLE '%-.64s' isn't allowed in FROM table list", +#define ER_UPDATE_TABLE_USED 1093 +"You can't specify target table '%-.64s' for update in FROM clause", #define ER_NO_SUCH_THREAD 1094 "Unknown thread id: %lu", #define ER_KILL_DENIED_ERROR 1095 @@ -204,13 +206,13 @@ #define ER_TABLE_NOT_LOCKED 1100 "Table '%-.64s' was not locked with LOCK TABLES", #define ER_BLOB_CANT_HAVE_DEFAULT 1101 -"BLOB column '%-.64s' can't have a default value", +"BLOB/TEXT column '%-.64s' can't have a default value", #define ER_WRONG_DB_NAME 1102 "Incorrect database name '%-.100s'", #define ER_WRONG_TABLE_NAME 1103 "Incorrect table name '%-.100s'", #define ER_TOO_BIG_SELECT 1104 -"The SELECT would examine too many records and probably take a very long time. Check your WHERE and use SET OPTION SQL_BIG_SELECTS=1 if the SELECT is ok", +"The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok", #define ER_UNKNOWN_ERROR 1105 "Unknown error", #define ER_UNKNOWN_PROCEDURE 1106 @@ -238,7 +240,7 @@ #define ER_TOO_MANY_FIELDS 1117 "Too many columns", #define ER_TOO_BIG_ROWSIZE 1118 -"Too big row size. The maximum row size, not counting BLOBs, is %d. You have to change some fields to BLOBs", +"Too big row size. The maximum row size for the used table type, not counting BLOBs, is %ld. You have to change some fields to TEXT or BLOBs", #define ER_STACK_OVERRUN 1119 "Thread stack overrun: Used: %ld of a %ld stack. Use 'mysqld -O thread_stack=#' to specify a bigger stack if needed", #define ER_WRONG_OUTER_JOIN 1120 @@ -286,11 +288,11 @@ #define ER_NONEXISTING_GRANT 1141 "There is no such grant defined for user '%-.32s' on host '%-.64s'", #define ER_TABLEACCESS_DENIED_ERROR 1142 -"%-.16s command denied to user: '%-.32s@%-.64s' for table '%-.64s'", +"%-.16s command denied to user: '%-.32s'@'%-.64s' for table '%-.64s'", #define ER_COLUMNACCESS_DENIED_ERROR 1143 -"%-.16s command denied to user: '%-.32s@%-.64s' for column '%-.64s' in table '%-.64s'", +"%-.16s command denied to user: '%-.32s'@'%-.64s' for column '%-.64s' in table '%-.64s'", #define ER_ILLEGAL_GRANT_FOR_TABLE 1144 -"Illegal GRANT/REVOKE command. Please consult the manual which privileges can be used.", +"Illegal GRANT/REVOKE command. Please consult the manual which privileges can be used", #define ER_GRANT_WRONG_HOST_OR_USER 1145 "The host or user argument to GRANT is too long", #define ER_NO_SUCH_TABLE 1146 @@ -332,17 +334,17 @@ #define ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164 "The used table type doesn't support AUTO_INCREMENT columns", #define ER_DELAYED_INSERT_TABLE_LOCKED 1165 -"INSERT DELAYED can't be used with table '%-.64s', because it is locked with LOCK TABLES", +"INSERT DELAYED can't be used with table '%-.64s' because it is locked with LOCK TABLES", #define ER_WRONG_COLUMN_NAME 1166 "Incorrect column name '%-.100s'", #define ER_WRONG_KEY_COLUMN 1167 -"The used table handler can't index column '%-.64s'", +"The used storage engine can't index column '%-.64s'", #define ER_WRONG_MRG_TABLE 1168 "All tables in the MERGE table are not identically defined", #define ER_DUP_UNIQUE 1169 "Can't write, because of unique constraint, to table '%-.64s'", #define ER_BLOB_KEY_WITHOUT_LENGTH 1170 -"BLOB column '%-.64s' used in key specification without a key length", +"BLOB/TEXT column '%-.64s' used in key specification without a key length", #define ER_PRIMARY_CANT_HAVE_NULL 1171 "All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead", #define ER_TOO_MANY_ROWS 1172 @@ -358,7 +360,7 @@ #define ER_CHECK_NO_SUCH_TABLE 1177 "Can't open table", #define ER_CHECK_NOT_IMPLEMENTED 1178 -"The handler for the table doesn't support %s", +"The storage engine for the table doesn't support %s", #define ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179 "You are not allowed to execute this command in a transaction", #define ER_ERROR_DURING_COMMIT 1180 @@ -372,7 +374,7 @@ #define ER_NEW_ABORTING_CONNECTION 1184 "Aborted connection %ld to db: '%-.64s' user: '%-.32s' host: `%-.64s' (%-.64s)", #define ER_DUMP_NOT_IMPLEMENTED 1185 -"The handler for the table does not support binary table dump", +"The storage engine for the table does not support binary table dump", #define ER_FLUSH_MASTER_BINLOG_CLOSED 1186 "Binlog closed, cannot RESET MASTER", #define ER_INDEX_REBUILD 1187 @@ -394,13 +396,13 @@ #define ER_CRASHED_ON_REPAIR 1195 "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", #define ER_WARNING_NOT_COMPLETE_ROLLBACK 1196 -"Warning: Some non-transactional changed tables couldn't be rolled back", +"Some non-transactional changed tables couldn't be rolled back", #define ER_TRANS_CACHE_FULL 1197 -"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again", #define ER_SLAVE_MUST_STOP 1198 -"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation cannot be performed with a running slave, run STOP SLAVE first", #define ER_SLAVE_NOT_RUNNING 1199 -"This operation requires a running slave, configure slave and do SLAVE START", +"This operation requires a running slave, configure slave and do START SLAVE", #define ER_BAD_SLAVE 1200 "The server is not configured as slave, fix in config file or with CHANGE MASTER TO", #define ER_MASTER_INFO 1201 @@ -424,19 +426,19 @@ #define ER_WRONG_ARGUMENTS 1210 "Wrong arguments to %s", #define ER_NO_PERMISSION_TO_CREATE_USER 1211 -"%-.32s@%-.64s is not allowed to create new users", +"'%-.32s'@'%-.64s' is not allowed to create new users", #define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 -"Incorrect table definition; All MERGE tables must be in the same database", +"Incorrect table definition; all MERGE tables must be in the same database", #define ER_LOCK_DEADLOCK 1213 "Deadlock found when trying to get lock; Try restarting transaction", -#define ER_TABLE_CANT_HANDLE_FULLTEXT 1214 +#define ER_TABLE_CANT_HANDLE_FT 1214 "The used table type doesn't support FULLTEXT indexes", #define ER_CANNOT_ADD_FOREIGN 1215 "Cannot add foreign key constraint", #define ER_NO_REFERENCED_ROW 1216 -"Cannot add a child row: a foreign key constraint fails", +"Cannot add or update a child row: a foreign key constraint fails", #define ER_ROW_IS_REFERENCED 1217 -"Cannot delete a parent row: a foreign key constraint fails", +"Cannot delete or update a parent row: a foreign key constraint fails", #define ER_CONNECT_TO_MASTER 1218 "Error connecting to master: %-.128s", #define ER_QUERY_ON_MASTER 1219 @@ -475,3 +477,97 @@ "This version of MySQL doesn't yet support '%s'", #define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236 "Got fatal error %d: '%-.128s' from master when reading data from binary log", +#define ER_SLAVE_IGNORED_TABLE 1237 +"Slave SQL thread ignored the query because of replicate-*-table rules", +#define ER_WRONG_FK_DEF 1238 +"Wrong foreign key definition for '%-.64s': %s", +#define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1239 +"Key reference and table reference doesn't match", +#define ER_OPERAND_COLUMNS 1240 +"Operand should contain %d column(s)", +#define ER_SUBQUERY_NO_1_ROW 1241 +"Subquery returns more than 1 row", +#define ER_UNKNOWN_STMT_HANDLER 1242 +"Unknown prepared statement handler (%ld) given to %s", +#define ER_CORRUPT_HELP_DB 1243 +"Help database is corrupt or does not exist", +#define ER_CYCLIC_REFERENCE 1244 +"Cyclic reference on subqueries", +#define ER_AUTO_CONVERT 1245 +"Converting column '%s' from %s to %s", +#define ER_ILLEGAL_REFERENCE 1246 +"Reference '%-.64s' not supported (%s)", +#define ER_DERIVED_MUST_HAVE_ALIAS 1247 +"Every derived table must have it's own alias", +#define ER_SELECT_REDUCED 1248 +"Select %u was reduced during optimisation", +#define ER_TABLENAME_NOT_ALLOWED_HERE 1249 +"Table '%-.64s' from one of SELECT's can not be used in %-.32s", +#define ER_NOT_SUPPORTED_AUTH_MODE 1250 +"Client does not support authentication protocol requested by server; consider upgrading MySQL client", +#define ER_SPATIAL_CANT_HAVE_NULL 1251 +"All parts of a SPATIAL KEY must be NOT NULL", +#define ER_COLLATION_CHARSET_MISMATCH 1252 +"COLLATION '%s' is not valid for CHARACTER SET '%s'", +#define ER_SLAVE_WAS_RUNNING 1253 +"Slave is already running", +#define ER_SLAVE_WAS_NOT_RUNNING 1254 +"Slave has already been stopped", +#define ER_TOO_BIG_FOR_UNCOMPRESS 1255 +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)", +#define ER_ZLIB_Z_MEM_ERROR 1256 +"ZLIB: Not enough memory available for zlib", +#define ER_ZLIB_Z_BUF_ERROR 1257 +"ZLIB: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", +#define ER_ZLIB_Z_DATA_ERROR 1258 +"ZLIB: Input data was corrupted for zlib", +#define ER_CUT_VALUE_GROUP_CONCAT 1259 +"%d line(s) was(were) cut by group_concat()", +#define ER_WARN_TOO_FEW_RECORDS 1260 +"Record count is fewer than the column count at row %ld"; +#define ER_WARN_TOO_MANY_RECORDS 1261 +"Record count is more than the column count at row %ld"; +#define ER_WARN_NULL_TO_NOTNULL 1262 +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; +#define ER_WARN_DATA_OUT_OF_RANGE 1263 +"Data truncated, out of range for column '%s' at row %ld"; +#define ER_WARN_DATA_TRUNCATED 1264 +"Data truncated for column '%s' at row %ld", +#define ER_WARN_USING_OTHER_HANDLER 1265 +"Using storage engine %s for table '%s'", +#define ER_CANT_AGGREGATE_2COLLATIONS 1266 +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", +#define ER_DROP_USER 1267 +"Can't drop one or more of the requested users", +#define ER_REVOKE_GRANTS 1268 +"Can't revoke all privileges, grant for one or more of the requested users", +#define ER_CANT_AGGREGATE_3COLLATIONS 1269 +"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", +#define ER_CANT_AGGREGATE_NCOLLATIONS 1270 +"Illegal mix of collations for operation '%s'", +#define ER_VARIABLE_IS_NOT_STRUCT 1271 +"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +#define ER_UNKNOWN_COLLATION 1272 +"Unknown collation: '%-.64s'", +#define ER_SLAVE_IGNORED_SSL_PARAMS 1273 +"SSL parameters in CHANGE MASTER are ignored because this MySQL slave was compiled without SSL support. They can be used later when MySQL slave with SSL will be started.", +#define ER_SERVER_IS_IN_SECURE_AUTH_MODE 1274 +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format", +#define ER_WARN_FIELD_RESOLVED 1275 +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", +#define ER_BAD_SLAVE_UNTIL_COND 1276 +"Wrong parameter or combination of parameters for START SLAVE UNTIL", +#define ER_MISSING_SKIP_SLAVE 1277 +"It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL. Otherwise you will get problems if you get an unexpected slave's mysqld restart", +#define ER_UNTIL_COND_IGNORED 1278 +"SQL thread is not to be started so UNTIL options are ignored", +#define ER_WRONG_NAME_FOR_INDEX 1279 +"Incorrect index name '%-.100s'", +#define ER_WRONG_NAME_FOR_CATALOG 1280 +"Incorrect catalog name '%-.100s'", +#define ER_WARN_QC_RESIZE 1281 +"Query cache failed to set size %lu, new query cache size is %lu", +#define ER_BAD_FT_COLUMN 1282 +"Column '%-.64s' cannot be part of FULLTEXT index", +#define ER_UNKNOWN_KEY_CACHE 1283 +"Unknown key cache '%-.100s'", diff --git a/Makefile.am b/Makefile.am index 6afbce11dfa..4e4c2da8082 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,10 +23,9 @@ EXTRA_DIST = INSTALL-SOURCE README COPYING zlib SUBDIRS = . include @docs_dirs@ \ @readline_topdir@ sql-common \ @thread_dirs@ pstack @sql_client_dirs@ \ - @sql_server_dirs@ scripts man tests \ + @sql_server_dirs@ scripts man tests SSL\ BUILD @netware_dir@ os2 @libmysqld_dirs@ \ @bench_dirs@ support-files @fs_dirs@ @tools_dirs@ - # Relink after clean linked_sources = linked_client_sources linked_server_sources \ diff --git a/SSL/Makefile.am b/SSL/Makefile.am new file mode 100644 index 00000000000..bd3aad1e3b2 --- /dev/null +++ b/SSL/Makefile.am @@ -0,0 +1,24 @@ +# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +## Process this file with automake to create Makefile.in + +EXTRA_DIST= NOTES cacert.pem client-cert.pem client-key.pem \ + client-req.pem run-client run-server server-cert.pem \ + server-key.pem server-req.pem + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/configure.in b/configure.in index 4b930b45f04..88622ececab 100644 --- a/configure.in +++ b/configure.in @@ -2818,7 +2818,7 @@ AC_OUTPUT(Makefile extra/Makefile mysys/Makefile isam/Makefile dnl libmysql_r/Makefile libmysqld/Makefile libmysqld/examples/Makefile dnl libmysql/Makefile client/Makefile dnl pstack/Makefile pstack/aout/Makefile sql/Makefile sql/share/Makefile dnl - sql-common/Makefile dnl + sql-common/Makefile SSL/Makefile dnl merge/Makefile dbug/Makefile scripts/Makefile dnl include/Makefile sql-bench/Makefile tools/Makefile dnl tests/Makefile Docs/Makefile support-files/Makefile dnl diff --git a/include/sql_common.h b/include/sql_common.h index 1c374030a55..fef573f7450 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -22,9 +22,6 @@ extern const char *not_error_sqlstate; extern "C" { #endif -ulong STDCALL net_field_length(uchar **packet); -my_ulonglong net_field_length_ll(uchar **packet); - MYSQL_FIELD *unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, my_bool default_value, uint server_capabilities); void free_rows(MYSQL_DATA *cur); diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index be57868e574..fe5b4f9c096 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -428,7 +428,7 @@ os_file_handle_error_no_exit( return (FALSE); } - return(FALSE); + return(FALSE); /* not reached */ } /******************************************************************** diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 9987804f03e..1f709025759 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -995,7 +995,7 @@ srv_console( srv_dec_thread_count(SRV_CONSOLE); } - return(0); + return(0); /* Not reached */ } /************************************************************************* @@ -3286,7 +3286,7 @@ suspend_thread: os_thread_exit(NULL); #ifndef __WIN__ - return(NULL); + return(NULL); /* Not reached */ #else return(0); #endif diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 3f375b66c4f..69ddaec0619 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -441,7 +441,7 @@ io_handler_thread( os_thread_exit(NULL); #ifndef __WIN__ - return(NULL); + return(NULL); /* Not reached */ #else return(0); #endif diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c index 89412003485..177c5db7413 100644 --- a/innobase/trx/trx0sys.c +++ b/innobase/trx/trx0sys.c @@ -589,7 +589,7 @@ trx_sys_update_mysql_binlog_offset( mlog_write_string(sys_header + field + TRX_SYS_MYSQL_LOG_NAME, - file_name, 1 + ut_strlen(file_name), mtr); + (byte*) file_name, 1 + ut_strlen(file_name), mtr); } if (mach_read_from_4(sys_header + field diff --git a/isam/isamchk.c b/isam/isamchk.c index 0c0df603da0..4e7ab7ec854 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -286,8 +286,8 @@ static struct my_option my_long_options[] = "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"block-search", 'b', "For debugging.", (gptr*) &search_after_block, - (gptr*) &search_after_block, 0, GET_ULONG, REQUIRED_ARG, NI_POS_ERROR, 0, - 0, 0, 0, 0}, + (gptr*) &search_after_block, 0, GET_ULONG, REQUIRED_ARG, + (longlong) NI_POS_ERROR, 0, 0, 0, 0, 0}, {"silent", 's', "Only print errors. One can use two -s to make isamchk very silent.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/libmysql/conf_to_src.c b/libmysql/conf_to_src.c index 95ffcf1cb2b..8d931309abb 100644 --- a/libmysql/conf_to_src.c +++ b/libmysql/conf_to_src.c @@ -16,9 +16,9 @@ /* can't use -lmysys because this prog is used to create -lstrings */ + +#include #include -#include -#include #include #include diff --git a/myisam/mi_check.c b/myisam/mi_check.c index bd8c8c60e33..6f794ad2ea8 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -3301,30 +3301,28 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) ft_buf->buf=0; return error; } - else - { - /* flushing buffer */ - if ((error=sort_ft_buf_flush(sort_param))) - return error; + + /* flushing buffer */ + if ((error=sort_ft_buf_flush(sort_param))) + return error; word_init_ft_buf: - a_len+=val_len; - memcpy(ft_buf->lastkey, a, a_len); - ft_buf->buf=ft_buf->lastkey+a_len; - ft_buf->end=ft_buf->lastkey+ (sort_param->keyinfo->block_length-32); - /* 32 is just a safety margin here - (at least max(val_len, sizeof(nod_flag)) should be there). - May be better performance could be achieved if we'd put - (sort_info->keyinfo->block_length-32)/XXX - instead. - TODO: benchmark the best value for XXX. - */ - - return 0; - } - return -1; /* impossible */ + a_len+=val_len; + memcpy(ft_buf->lastkey, a, a_len); + ft_buf->buf=ft_buf->lastkey+a_len; + /* + 32 is just a safety margin here + (at least max(val_len, sizeof(nod_flag)) should be there). + May be better performance could be achieved if we'd put + (sort_info->keyinfo->block_length-32)/XXX + instead. + TODO: benchmark the best value for XXX. + */ + ft_buf->end=ft_buf->lastkey+ (sort_param->keyinfo->block_length-32); + return 0; } /* sort_ft_key_write */ + /* get pointer to record from a key */ static my_off_t get_record_for_key(MI_INFO *info, MI_KEYDEF *keyinfo, diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index f21b0e928b6..a55d5b2a5ca 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -241,7 +241,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (info->ft1_to_ft2) { /* we're in ft1->ft2 conversion mode. Saving key data */ - insert_dynamic(info->ft1_to_ft2, lastkey+off); + insert_dynamic(info->ft1_to_ft2, (char*) (lastkey+off)); } else { diff --git a/myisam/mi_page.c b/myisam/mi_page.c index 8c6981afa00..c70209c2da6 100644 --- a/myisam/mi_page.c +++ b/myisam/mi_page.c @@ -52,7 +52,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, { DBUG_PRINT("error",("page %lu had wrong page length: %u", (ulong) page, page_size)); - DBUG_DUMP("page", tmp, keyinfo->block_length); + DBUG_DUMP("page", (char*) tmp, keyinfo->block_length); info->last_keypage = HA_OFFSET_ERROR; my_errno = HA_ERR_CRASHED; tmp = 0; diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index 80489cbcd13..5e03d489efe 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -108,11 +108,11 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) } while (pos != key_file_length); - my_free(buff, MYF(0)); + my_free((char*) buff, MYF(0)); DBUG_RETURN(0); err: - my_free(buff, MYF(MY_ALLOW_ZERO_PTR)); + my_free((char*) buff, MYF(MY_ALLOW_ZERO_PTR)); DBUG_RETURN(my_errno= errno); } diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 86c45e0692f..d13ba6c2c4e 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -521,7 +521,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, we cannot easily dispatch an empty page here */ b+=blen+ft2len+2; for (a=anc_buff+a_length ; b < a ; b+=ft2len+2) - insert_dynamic(info->ft1_to_ft2, b); + insert_dynamic(info->ft1_to_ft2, (char*) b); /* fixing the page's length - it contains only one key now */ mi_putint(anc_buff,2+blen+ft2len+2,0); diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 5ca57248204..93edde33bdb 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -51,7 +51,7 @@ struct st_file_buffer { char *buffer,*pos,*end; my_off_t pos_in_file; int bits; - uint byte; + uint current_byte; }; struct st_huff_tree; @@ -1912,7 +1912,7 @@ static void init_file_buffer(File file, pbool read_buffer) file_buffer.pos=file_buffer.buffer; file_buffer.bits=BITS_SAVED; } - file_buffer.byte=0; + file_buffer.current_byte=0; } @@ -1961,13 +1961,13 @@ static void write_bits (register ulong value, register uint bits) { if ((file_buffer.bits-=(int) bits) >= 0) { - file_buffer.byte|=value << file_buffer.bits; + file_buffer.current_byte|=value << file_buffer.bits; } else { reg3 uint byte_buff; bits= (uint) -file_buffer.bits; - byte_buff=file_buffer.byte | (uint) (value >> bits); + byte_buff=file_buffer.current_byte | (uint) (value >> bits); #if BITS_SAVED == 32 *file_buffer.pos++= (byte) (byte_buff >> 24) ; *file_buffer.pos++= (byte) (byte_buff >> 16) ; @@ -1993,7 +1993,7 @@ static void write_bits (register ulong value, register uint bits) if (file_buffer.pos >= file_buffer.end) VOID(flush_buffer((uint) ~0)); file_buffer.bits=(int) (BITS_SAVED - bits); - file_buffer.byte=(uint) (value << (BITS_SAVED - bits)); + file_buffer.current_byte=(uint) (value << (BITS_SAVED - bits)); } return; } @@ -2005,7 +2005,7 @@ static void flush_bits (void) uint bits,byte_buff; bits=(file_buffer.bits) & ~7; - byte_buff = file_buffer.byte >> bits; + byte_buff = file_buffer.current_byte >> bits; bits=BITS_SAVED - bits; while (bits > 0) { @@ -2013,7 +2013,7 @@ static void flush_bits (void) *file_buffer.pos++= (byte) (uchar) (byte_buff >> bits) ; } file_buffer.bits=BITS_SAVED; - file_buffer.byte=0; + file_buffer.current_byte=0; return; } diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index f896f7fa9cc..29cd7a05f7d 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # mysql-test-run - originally written by Matt Wagner # modified by Sasha Pachev # Slightly updated by Monty @@ -229,7 +229,6 @@ while test $# -gt 0; do --local) USE_RUNNING_SERVER="" ;; --extern) USE_RUNNING_SERVER="1" ;; --tmpdir=*) MYSQL_TMP_DIR=`$ECHO "$1" | $SED -e "s;--tmpdir=;;"` ;; - --start-from=*) START_FROM=`$ECHO "$1" | $SED -e "s;--start-from=;;"` ;; --local-master) MASTER_MYPORT=3306; EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT --host=127.0.0.1 \ @@ -1173,7 +1172,7 @@ run_testcase () slave_master_info_file=$TESTDIR/$tname.slave-mi echo $tname > $CURRENT_TEST SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0` - if [ $USE_MANAGER = 1 ] ; then + if [ "$USE_MANAGER" = 1 ] ; then many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)` fi @@ -1186,11 +1185,6 @@ run_testcase () fi fi - if [ "$tname" '<' "$START_FROM" ] ; then -# skip_test $tname; - return; - fi - if [ -n "$DO_TEST" ] ; then DO_THIS_TEST=`$EXPR \( $tname : "$DO_TEST" \) != 0` if [ x$DO_THIS_TEST = x0 ] ; diff --git a/mysys/hash.c b/mysys/hash.c index 665e3d11e8d..4ef8847363f 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -41,7 +41,7 @@ static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length); static uint calc_hash(HASH *hash,const byte *key,uint length) { ulong nr1=1, nr2=4; - hash->charset->coll->hash_sort(hash->charset,key,length,&nr1,&nr2); + hash->charset->coll->hash_sort(hash->charset,(uchar*) key,length,&nr1,&nr2); return nr1; } @@ -216,7 +216,8 @@ static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length) uint rec_keylength; byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1); return (length && length != rec_keylength) || - my_strnncoll(hash->charset, rec_key, rec_keylength, key, length); + my_strnncoll(hash->charset, (uchar*) rec_key, rec_keylength, + (uchar*) key, length); } diff --git a/mysys/mf_wcomp.c b/mysys/mf_wcomp.c index 62a5a02eaea..c2a103688f2 100644 --- a/mysys/mf_wcomp.c +++ b/mysys/mf_wcomp.c @@ -74,7 +74,7 @@ int wild_compare(register const char *str, register const char *wildstr, DBUG_RETURN(0); /* '*' as last char: OK */ if ((cmp= *wildstr) == wild_prefix && wildstr[1] && !str_is_pattern) cmp=wildstr[1]; - for(;;str++) + for (;;str++) { while (*str && *str != cmp) str++; @@ -83,7 +83,7 @@ int wild_compare(register const char *str, register const char *wildstr, if (wild_compare(str,wildstr,str_is_pattern) == 0) DBUG_RETURN (0); } - DBUG_RETURN(1); + /* We will never come here */ } } DBUG_RETURN (*str != 0); diff --git a/mysys/my_append.c b/mysys/my_append.c index dc5ed084bb3..c3549c670c3 100644 --- a/mysys/my_append.c +++ b/mysys/my_append.c @@ -18,10 +18,10 @@ #include "mysys_priv.h" #include #include -#if defined(HAVE_SYS_UTIME_H) -#include -#elif defined(HAVE_UTIME_H) +#if defined(HAVE_UTIME_H) #include +#elif defined(HAVE_SYS_UTIME_H) +#include #elif !defined(HPUX10) struct utimbuf { time_t actime; diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 84eda781a09..03f3feb54d3 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -18,10 +18,10 @@ #include "mysys_priv.h" #include #include -#if defined(HAVE_SYS_UTIME_H) -#include -#elif defined(HAVE_UTIME_H) +#if defined(HAVE_UTIME_H) #include +#elif defined(HAVE_SYS_UTIME_H) +#include #elif !defined(HPUX10) #include struct utimbuf { diff --git a/mysys/my_redel.c b/mysys/my_redel.c index 9ba03cd9526..9af360424b0 100644 --- a/mysys/my_redel.c +++ b/mysys/my_redel.c @@ -19,10 +19,10 @@ #include #include #include "mysys_err.h" -#if defined(HAVE_SYS_UTIME_H) -#include -#elif defined(HAVE_UTIME_H) +#if defined(HAVE_UTIME_H) #include +#elif defined(HAVE_SYS_UTIME_H) +#include #elif !defined(HPUX10) struct utimbuf { time_t actime; diff --git a/sql-common/client.c b/sql-common/client.c index 878a8beacba..dd6a5339454 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1235,7 +1235,8 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, { mysql->warning_count= uint2korr(cp+1); mysql->server_status= uint2korr(cp+3); - DBUG_PRINT("info",("warning_count: %ld", mysql->warning_count)); + DBUG_PRINT("info",("status: %u warning_count: %u", + mysql->server_status, mysql->warning_count)); } DBUG_PRINT("exit",("Got %d rows",result->rows)); DBUG_RETURN(result); @@ -2247,6 +2248,9 @@ get_info: { mysql->affected_rows= net_field_length_ll(&pos); mysql->insert_id= net_field_length_ll(&pos); + DBUG_PRINT("info",("affected_rows: %lu insert_id: %lu", + (ulong) mysql->affected_rows, + (ulong) mysql->insert_id)); if (protocol_41(mysql)) { mysql->server_status=uint2korr(pos); pos+=2; @@ -2254,10 +2258,11 @@ get_info: } else if (mysql->server_capabilities & CLIENT_TRANSACTIONS) { + /* MySQL 4.0 protocol */ mysql->server_status=uint2korr(pos); pos+=2; mysql->warning_count= 0; } - DBUG_PRINT("info",("status: %ld warning_count: %ld", + DBUG_PRINT("info",("status: %u warning_count: %u", mysql->server_status, mysql->warning_count)); if (pos < mysql->net.read_pos+length && net_field_length(&pos)) mysql->info=(char*) pos; diff --git a/sql-common/pack.c b/sql-common/pack.c index e31e596ae7a..ed79143a04b 100644 --- a/sql-common/pack.c +++ b/sql-common/pack.c @@ -78,23 +78,40 @@ my_ulonglong net_field_length_ll(uchar **packet) #endif } +/* + Store an integer with simple packing into a output package + + SYNOPSIS + net_store_length() + pkg Store the packed integer here + length integers to store + + NOTES + This is mostly used to store lengths of strings. + We have to cast the result for the LL() becasue of a bug in Forte CC + compiler. + + RETURN + Position in 'pkg' after the packed length +*/ + char * net_store_length(char *pkg, ulonglong length) { uchar *packet=(uchar*) pkg; - if (length < LL(251)) + if (length < (ulonglong) LL(251)) { *packet=(uchar) length; return (char*) packet+1; } /* 251 is reserved for NULL */ - if (length < LL(65536)) + if (length < (ulonglong) LL(65536)) { *packet++=252; int2store(packet,(uint) length); return (char*) packet+2; } - if (length < LL(16777216)) + if (length < (ulonglong) LL(16777216)) { *packet++=253; int3store(packet,(ulong) length); diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index fb4061b31e0..ae0267b98f3 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -248,7 +248,8 @@ ha_rows ha_heap::records_in_range(int inx, } } -int ha_heap::create(const char *name, TABLE *table, + +int ha_heap::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { uint key, parts, mem_per_row= 0; @@ -259,17 +260,17 @@ int ha_heap::create(const char *name, TABLE *table, char buff[FN_REFLEN]; int error; - for (key= parts= 0; key < table->keys; key++) - parts+= table->key_info[key].key_parts; + for (key= parts= 0; key < table_arg->keys; key++) + parts+= table_arg->key_info[key].key_parts; - if (!(keydef= (HP_KEYDEF*) my_malloc(table->keys * sizeof(HP_KEYDEF) + + if (!(keydef= (HP_KEYDEF*) my_malloc(table_arg->keys * sizeof(HP_KEYDEF) + parts * sizeof(HA_KEYSEG), MYF(MY_WME)))) return my_errno; - seg= my_reinterpret_cast(HA_KEYSEG*) (keydef + table->keys); - for (key= 0; key < table->keys; key++) + seg= my_reinterpret_cast(HA_KEYSEG*) (keydef + table_arg->keys); + for (key= 0; key < table_arg->keys; key++) { - KEY *pos= table->key_info+key; + KEY *pos= table_arg->key_info+key; KEY_PART_INFO *key_part= pos->key_part; KEY_PART_INFO *key_part_end= key_part + pos->key_parts; @@ -303,7 +304,7 @@ int ha_heap::create(const char *name, TABLE *table, if (field->null_ptr) { seg->null_bit= field->null_bit; - seg->null_pos= (uint) (field->null_ptr - (uchar*) table->record[0]); + seg->null_pos= (uint) (field->null_ptr - (uchar*) table_arg->record[0]); } else { @@ -317,7 +318,7 @@ int ha_heap::create(const char *name, TABLE *table, } } } - mem_per_row+= MY_ALIGN(table->reclength + 1, sizeof(char*)); + mem_per_row+= MY_ALIGN(table_arg->reclength + 1, sizeof(char*)); max_rows = (ha_rows) (current_thd->variables.max_heap_table_size / mem_per_row); HP_CREATE_INFO hp_create_info; @@ -326,10 +327,11 @@ int ha_heap::create(const char *name, TABLE *table, hp_create_info.auto_increment= (create_info->auto_increment_value ? create_info->auto_increment_value - 1 : 0); error= heap_create(fn_format(buff,name,"","",4+2), - table->keys,keydef, table->reclength, - (ulong) ((table->max_rows < max_rows && table->max_rows) ? - table->max_rows : max_rows), - (ulong) table->min_rows, &hp_create_info); + table_arg->keys,keydef, table_arg->reclength, + (ulong) ((table_arg->max_rows < max_rows && + table_arg->max_rows) ? + table_arg->max_rows : max_rows), + (ulong) table_arg->min_rows, &hp_create_info); my_free((gptr) keydef, MYF(0)); if (file) info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE); @@ -337,6 +339,7 @@ int ha_heap::create(const char *name, TABLE *table, return (error); } + void ha_heap::update_create_info(HA_CREATE_INFO *create_info) { table->file->info(HA_STATUS_AUTO); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 11870e4cc29..7fc0664445d 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -3640,7 +3640,7 @@ ha_innobase::discard_or_import_tablespace( my_bool discard) /* in: TRUE if discard, else import */ { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; - dict_table_t* table; + dict_table_t* dict_table; trx_t* trx; int err; @@ -3650,13 +3650,13 @@ ha_innobase::discard_or_import_tablespace( ut_a(prebuilt->trx == (trx_t*) current_thd->transaction.all.innobase_tid); - table = prebuilt->table; + dict_table = prebuilt->table; trx = prebuilt->trx; if (discard) { - err = row_discard_tablespace_for_mysql(table->name, trx); + err = row_discard_tablespace_for_mysql(dict_table->name, trx); } else { - err = row_import_tablespace_for_mysql(table->name, trx); + err = row_import_tablespace_for_mysql(dict_table->name, trx); } if (err == DB_SUCCESS) { diff --git a/sql/item.cc b/sql/item.cc index 97ef19d089b..1d49671ff4c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1667,7 +1667,9 @@ bool Item_insert_value::eq(const Item *item, bool binary_cmp) const } -bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, Item **items) +bool Item_insert_value::fix_fields(THD *thd, + struct st_table_list *table_list, + Item **items) { bool res= arg->fix_fields(thd, table_list, items); if (res) @@ -1698,10 +1700,10 @@ bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, I } else { - Field *field=field_arg->field; + Field *tmp_field= field_arg->field; /* charset doesn't matter here, it's to avoid sigsegv only */ - set_field(new Field_null(0,0,Field::NONE,field->field_name,field->table, - &my_charset_bin)); + set_field(new Field_null(0, 0, Field::NONE, tmp_field->field_name, + tmp_field->table, &my_charset_bin)); } return 0; } diff --git a/sql/item.h b/sql/item.h index 23b0cf018e1..a94a7a77597 100644 --- a/sql/item.h +++ b/sql/item.h @@ -830,14 +830,14 @@ public: bool fix_fields(THD *, struct st_table_list *, Item **); void print(String *str); virtual bool basic_const_item() const { return true; } - int save_in_field(Field *field, bool no_conversions) + int save_in_field(Field *field_arg, bool no_conversions) { if (!arg) { - field->set_default(); + field_arg->set_default(); return 0; } - return Item_field::save_in_field(field, no_conversions); + return Item_field::save_in_field(field_arg, no_conversions); } table_map used_tables() const { return (table_map)0L; } @@ -858,9 +858,9 @@ public: bool fix_fields(THD *, struct st_table_list *, Item **); void print(String *str); virtual bool basic_const_item() const { return true; } - int save_in_field(Field *field, bool no_conversions) + int save_in_field(Field *field_arg, bool no_conversions) { - return Item_field::save_in_field(field, no_conversions); + return Item_field::save_in_field(field_arg, no_conversions); } table_map used_tables() const { return (table_map)0L; } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 51c53e6c136..dc017cef73c 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -41,24 +41,24 @@ public: Arg_comparator(Item **a1, Item **a2): a(a1), b(a2) {}; int set_compare_func(Item_bool_func2 *owner, Item_result type); - inline int set_compare_func(Item_bool_func2 *owner) + inline int set_compare_func(Item_bool_func2 *owner_arg) { - return set_compare_func(owner, item_cmp_type((*a)->result_type(), - (*b)->result_type())); + return set_compare_func(owner_arg, item_cmp_type((*a)->result_type(), + (*b)->result_type())); } - inline int set_cmp_func(Item_bool_func2 *owner, + inline int set_cmp_func(Item_bool_func2 *owner_arg, Item **a1, Item **a2, Item_result type) { a= a1; b= a2; - return set_compare_func(owner, type); + return set_compare_func(owner_arg, type); } - inline int set_cmp_func(Item_bool_func2 *owner, + inline int set_cmp_func(Item_bool_func2 *owner_arg, Item **a1, Item **a2) { - return set_cmp_func(owner, a1, a2, item_cmp_type((*a1)->result_type(), - (*a2)->result_type())); + return set_cmp_func(owner_arg, a1, a2, item_cmp_type((*a1)->result_type(), + (*a2)->result_type())); } inline int compare() { return (this->*func)(); } diff --git a/sql/item_func.cc b/sql/item_func.cc index 97454a6fce7..0ccc7febd0a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1624,7 +1624,7 @@ bool udf_handler::get_arguments() String *udf_handler::val_str(String *str,String *save_str) { - uchar is_null=0; + uchar is_null_tmp=0; ulong res_length; if (get_arguments()) @@ -1641,9 +1641,9 @@ String *udf_handler::val_str(String *str,String *save_str) return 0; } } - char *res=func(&initid, &f_args, (char*) str->ptr(), &res_length, &is_null, - &error); - if (is_null || !res || error) // The !res is for safety + char *res=func(&initid, &f_args, (char*) str->ptr(), &res_length, + &is_null_tmp, &error); + if (is_null_tmp || !res || error) // The !res is for safety { return 0; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 367400d6b0b..7b401b50d4c 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -306,8 +306,7 @@ void Item_singlerow_subselect::fix_length_and_dec() } else { - THD *thd= current_thd; - if (!(row= (Item_cache**)thd->alloc(sizeof(Item_cache*)*max_columns))) + if (!(row= (Item_cache**) sql_alloc(sizeof(Item_cache*)*max_columns))) return; engine->fix_length_and_dec(row); value= *row; @@ -550,8 +549,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, SELECT_LEX *select_lex= join->select_lex; - THD *thd= join->thd; - thd->where= "scalar IN/ALL/ANY subquery"; + THD *thd_tmp= join->thd; + thd_tmp->where= "scalar IN/ALL/ANY subquery"; if (select_lex->item_list.elements > 1) { @@ -595,7 +594,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, select_lex->item_list.empty(); select_lex->item_list.push_back(item); - if (item->fix_fields(thd, join->tables_list, &item)) + if (item->fix_fields(thd_tmp, join->tables_list, &item)) { DBUG_RETURN(RES_ERROR); } @@ -609,14 +608,14 @@ Item_in_subselect::single_value_transformer(JOIN *join, subs= new Item_maxmin_subselect(this, select_lex, func->l_op()); } // left expression belong to outer select - SELECT_LEX *current= thd->lex.current_select, *up; - thd->lex.current_select= up= current->return_after_parsing(); - if (left_expr->fix_fields(thd, up->get_table_list(), &left_expr)) + SELECT_LEX *current= thd_tmp->lex.current_select, *up; + thd_tmp->lex.current_select= up= current->return_after_parsing(); + if (left_expr->fix_fields(thd_tmp, up->get_table_list(), &left_expr)) { - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; DBUG_RETURN(RES_ERROR); } - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; substitution= func->create(left_expr, subs); DBUG_RETURN(RES_OK); } @@ -627,16 +626,16 @@ Item_in_subselect::single_value_transformer(JOIN *join, SELECT_LEX_UNIT *unit= select_lex->master_unit(); substitution= optimizer= new Item_in_optimizer(left_expr, this); - SELECT_LEX *current= thd->lex.current_select, *up; + SELECT_LEX *current= thd_tmp->lex.current_select, *up; - thd->lex.current_select= up= current->return_after_parsing(); + thd_tmp->lex.current_select= up= current->return_after_parsing(); //optimizer never use Item **ref => we can pass 0 as parameter - if (!optimizer || optimizer->fix_left(thd, up->get_table_list(), 0)) + if (!optimizer || optimizer->fix_left(thd_tmp, up->get_table_list(), 0)) { - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; DBUG_RETURN(RES_ERROR); } - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; /* As far as Item_ref_in_optimizer do not substitude itself on fix_fields @@ -664,7 +663,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, this->full_name())); join->having= and_items(join->having, item); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -688,7 +687,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, new Item_cond_and(having, join->having) : having); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, + &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -699,7 +699,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, } item->name= (char *)in_additional_cond; join->conds= and_items(join->conds, item); - if (join->conds->fix_fields(thd, join->tables_list, &join->conds)) + if (join->conds->fix_fields(thd_tmp, join->tables_list, &join->conds)) DBUG_RETURN(RES_ERROR); } else @@ -711,7 +711,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, (char *)"", (char *)"")); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, + &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -725,11 +726,11 @@ Item_in_subselect::single_value_transformer(JOIN *join, // fix_field of item will be done in time of substituting substitution= item; have_to_be_excluded= 1; - if (thd->lex.describe) + if (thd_tmp->lex.describe) { char warn_buff[MYSQL_ERRMSG_SIZE]; sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + push_warning(thd_tmp, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SELECT_REDUCED, warn_buff); } DBUG_RETURN(RES_REDUCE); @@ -739,13 +740,14 @@ Item_in_subselect::single_value_transformer(JOIN *join, DBUG_RETURN(RES_OK); } + Item_subselect::trans_res Item_in_subselect::row_value_transformer(JOIN *join) { DBUG_ENTER("Item_in_subselect::row_value_transformer"); - THD *thd= join->thd; - thd->where= "row IN/ALL/ANY subquery"; + THD *thd_tmp= join->thd; + thd_tmp->where= "row IN/ALL/ANY subquery"; SELECT_LEX *select_lex= join->select_lex; @@ -761,22 +763,22 @@ Item_in_subselect::row_value_transformer(JOIN *join) SELECT_LEX_UNIT *unit= select_lex->master_unit(); substitution= optimizer= new Item_in_optimizer(left_expr, this); - SELECT_LEX *current= thd->lex.current_select, *up; - thd->lex.current_select= up= current->return_after_parsing(); + SELECT_LEX *current= thd_tmp->lex.current_select, *up; + thd_tmp->lex.current_select= up= current->return_after_parsing(); //optimizer never use Item **ref => we can pass 0 as parameter - if (!optimizer || optimizer->fix_left(thd, up->get_table_list(), 0)) + if (!optimizer || optimizer->fix_left(thd_tmp, up->get_table_list(), 0)) { - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; DBUG_RETURN(RES_ERROR); } - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; unit->uncacheable|= UNCACHEABLE_DEPENDENT; } uint n= left_expr->cols(); select_lex->uncacheable|= UNCACHEABLE_DEPENDENT; - select_lex->setup_ref_array(thd, + select_lex->setup_ref_array(thd_tmp, select_lex->order_list.elements + select_lex->group_list.elements); Item *item= 0; @@ -802,7 +804,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) { join->having= and_items(join->having, item); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -812,7 +814,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) else { join->conds= and_items(join->conds, item); - if (join->conds->fix_fields(thd, join->tables_list, &join->having)) + if (join->conds->fix_fields(thd_tmp, join->tables_list, &join->having)) DBUG_RETURN(RES_ERROR); } DBUG_RETURN(RES_OK); @@ -880,7 +882,7 @@ subselect_single_select_engine(st_select_lex *select, unit->select_limit_cnt= unit->global_parameters->select_limit+ unit->global_parameters ->offset_limit; if (unit->select_limit_cnt < unit->global_parameters->select_limit) - unit->select_limit_cnt= HA_POS_ERROR; // no limit + unit->select_limit_cnt= HA_POS_ERROR; // no limit if (unit->select_limit_cnt == HA_POS_ERROR) select_lex->options&= ~OPTION_FOUND_ROWS; unit->item= item; @@ -889,17 +891,17 @@ subselect_single_select_engine(st_select_lex *select, subselect_union_engine::subselect_union_engine(st_select_lex_unit *u, - select_subselect *result, - Item_subselect *item) - :subselect_engine(item, result) + select_subselect *result_arg, + Item_subselect *item_arg) + :subselect_engine(item_arg, result_arg) { unit= u; - if (!result) - //out of memory + if (!result_arg) //out of memory current_thd->fatal_error(); - unit->item= item; + unit->item= item_arg; } + int subselect_single_select_engine::prepare() { if (prepared) @@ -907,8 +909,7 @@ int subselect_single_select_engine::prepare() join= new JOIN(thd, select_lex->item_list, select_lex->options, result); if (!join || !result) { - //out of memory - thd->fatal_error(); + thd->fatal_error(); //out of memory return 1; } prepared= 1; diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 3637e025d3c..8444dc7bf66 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -263,7 +263,7 @@ public: virtual ~subselect_engine() {}; // to satisfy compiler // set_thd should be called before prepare() - void set_thd(THD *thd) { this->thd= thd; } + void set_thd(THD *thd_arg) { thd= thd_arg; } THD * get_thd() { return thd; } virtual int prepare()= 0; virtual void fix_length_and_dec(Item_cache** row)= 0; @@ -328,11 +328,11 @@ protected: public: // constructor can assign THD because it will be called after JOIN::prepare - subselect_uniquesubquery_engine(THD *thd, st_join_table *tab_arg, + subselect_uniquesubquery_engine(THD *thd_arg, st_join_table *tab_arg, Item_subselect *subs, Item *where) :subselect_engine(subs, 0), tab(tab_arg), cond(where) { - set_thd(thd); + set_thd(thd_arg); } ~subselect_uniquesubquery_engine(); int prepare(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index a3d67e9f7fa..62782e1f710 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -104,16 +104,16 @@ Item *Item_sum::get_tmp_table_item(THD *thd) Item_sum* sum_item= (Item_sum *) copy_or_same(thd); if (sum_item && sum_item->result_field) // If not a const sum func { - Field *result_field= sum_item->result_field; + Field *result_field_tmp= sum_item->result_field; for (uint i=0 ; i < sum_item->arg_count ; i++) { Item *arg= sum_item->args[i]; if (!arg->const_item()) { if (arg->type() == Item::FIELD_ITEM) - ((Item_field*) arg)->field= result_field++; + ((Item_field*) arg)->field= result_field_tmp++; else - sum_item->args[i]= new Item_field(result_field++); + sum_item->args[i]= new Item_field(result_field_tmp++); } } } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 496ea0ed5c8..a5372a4ae60 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -671,7 +671,7 @@ longlong Item_func_month::val_int() String* Item_func_monthname::val_str(String* str) { - const char *name; + const char *month_name; uint month=(uint) Item_func_month::val_int(); if (!month) // This is also true for NULL @@ -680,8 +680,8 @@ String* Item_func_monthname::val_str(String* str) return (String*) 0; } null_value=0; - name= month_names[month-1]; - str->set(name, strlen(name), system_charset_info); + month_name= month_names[month-1]; + str->set(month_name, strlen(month_name), system_charset_info); return str; } diff --git a/sql/log.cc b/sql/log.cc index c32e37cd86a..936373daf03 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -179,7 +179,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, const char *new_name, const char *index_file_name_arg, enum cache_type io_cache_type_arg, bool no_auto_events_arg, - ulong max_size) + ulong max_size_arg) { char buff[512]; File file= -1, index_file_nr= -1; @@ -190,7 +190,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, last_time=query_start=0; write_error=0; - init(log_type_arg,io_cache_type_arg,no_auto_events_arg,max_size); + init(log_type_arg,io_cache_type_arg,no_auto_events_arg,max_size_arg); if (!(name=my_strdup(log_name,MYF(MY_WME)))) goto err; diff --git a/sql/protocol.cc b/sql/protocol.cc index e1347ff3c6f..0c9fed629b4 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -285,6 +285,12 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) pos=net_store_length(pos, (ulonglong) id); if (thd->client_capabilities & CLIENT_PROTOCOL_41) { + DBUG_PRINT("info", + ("affected_rows: %lu id: %lu status: %u warning_count: %u", + (ulong) affected_rows, + (ulong) id, + (uint) (thd->server_status & 0xffff), + (uint) thd->total_warn_count)); int2store(pos,thd->server_status); pos+=2; @@ -483,7 +489,7 @@ bool Protocol::send_fields(List *list, uint flag) char buff[80]; String tmp((char*) buff,sizeof(buff),&my_charset_bin); Protocol_simple prot(thd); - String *packet= prot.storage_packet(); + String *local_packet= prot.storage_packet(); CHARSET_INFO *thd_charset= thd->variables.character_set_results; DBUG_ENTER("send_fields"); @@ -520,10 +526,10 @@ bool Protocol::send_fields(List *list, uint flag) cs, thd_charset) || prot.store(field.org_col_name, (uint) strlen(field.org_col_name), cs, thd_charset) || - packet->realloc(packet->length()+12)) + local_packet->realloc(local_packet->length()+12)) goto err; /* Store fixed length fields */ - pos= (char*) packet->ptr()+packet->length(); + pos= (char*) local_packet->ptr()+local_packet->length(); *pos++= 12; // Length of packed fields int2store(pos, field.charsetnr); int4store(pos+2, field.length); @@ -540,9 +546,9 @@ bool Protocol::send_fields(List *list, uint flag) cs, thd_charset) || prot.store(field.col_name, (uint) strlen(field.col_name), cs, thd_charset) || - packet->realloc(packet->length()+10)) + local_packet->realloc(local_packet->length()+10)) goto err; - pos= (char*) packet->ptr()+packet->length(); + pos= (char*) local_packet->ptr()+local_packet->length(); #ifdef TO_BE_DELETED_IN_6 if (!(thd->client_capabilities & CLIENT_LONG_FLAG)) @@ -569,7 +575,7 @@ bool Protocol::send_fields(List *list, uint flag) pos+= 10; } } - packet->length((uint) (pos - packet->ptr())); + local_packet->length((uint) (pos - local_packet->ptr())); if (flag & 2) item->send(&prot, &tmp); // Send default value if (prot.write()) diff --git a/sql/protocol.h b/sql/protocol.h index 94fd303e259..67ae4ed01b4 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -44,9 +44,9 @@ protected: #endif public: Protocol() {} - Protocol(THD *thd) { init(thd); } + Protocol(THD *thd_arg) { init(thd_arg); } virtual ~Protocol() {} - void init(THD* thd); + void init(THD* thd_arg); bool send_fields(List *list, uint flag); bool send_records_num(List *list, ulonglong records); bool store(I_List *str_list); @@ -97,7 +97,7 @@ class Protocol_simple :public Protocol { public: Protocol_simple() {} - Protocol_simple(THD *thd) :Protocol(thd) {} + Protocol_simple(THD *thd_arg) :Protocol(thd_arg) {} virtual void prepare_for_resend(); virtual bool store_null(); virtual bool store_tiny(longlong from); @@ -122,7 +122,7 @@ private: uint bit_fields; public: Protocol_prep() {} - Protocol_prep(THD *thd) :Protocol(thd) {} + Protocol_prep(THD *thd_arg) :Protocol(thd_arg) {} virtual bool prepare_for_send(List *item_list); virtual void prepare_for_resend(); #ifdef EMBEDDED_LIBRARY @@ -155,7 +155,7 @@ public: ulong row_count; Protocol_cursor() {} - Protocol_cursor(THD *thd, MEM_ROOT *ini_alloc) :Protocol_simple(thd), alloc(ini_alloc) {} + Protocol_cursor(THD *thd_arg, MEM_ROOT *ini_alloc) :Protocol_simple(thd_arg), alloc(ini_alloc) {} bool prepare_for_send(List *item_list) { fields= NULL; @@ -173,7 +173,6 @@ void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, const char *info=0); void send_eof(THD *thd, bool no_flush=0); bool send_old_password_request(THD *thd); -char *net_store_length(char *packet,ulonglong length); char *net_store_length(char *packet,uint length); char *net_store_data(char *to,const char *from, uint length); char *net_store_data(char *to,int32 from); diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 563a2d41019..5f35552c562 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -96,23 +96,23 @@ bool Protocol_cursor::write() MYSQL_FIELD *cur_field= fields; MYSQL_FIELD *fields_end= fields + field_count; MYSQL_ROWS *new_record; - byte **data; + byte **data_tmp; byte *to; new_record= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS) + (field_count + 1)*sizeof(char *) + packet->length()); if (!new_record) goto err; - data= (byte **)(new_record + 1); - new_record->data= (char **)data; + data_tmp= (byte **)(new_record + 1); + new_record->data= (char **)data_tmp; to= (byte *)(fields + field_count + 1); - for (; cur_field < fields_end; ++cur_field, ++data) + for (; cur_field < fields_end; ++cur_field, ++data_tmp) { if ((len=net_field_length((uchar **)&cp))) { - *data= 0; + *data_tmp= 0; } else { diff --git a/sql/set_var.cc b/sql/set_var.cc index 39dc92c5d33..7e576b5a755 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -549,7 +549,6 @@ struct show_var_st init_vars[]= { {"bdb_logdir", (char*) &berkeley_logdir, SHOW_CHAR_PTR}, {"bdb_shared_data", (char*) &berkeley_shared_data, SHOW_BOOL}, {"bdb_tmpdir", (char*) &berkeley_tmpdir, SHOW_CHAR_PTR}, - {"bdb_version", (char*) DB_VERSION_STRING, SHOW_CHAR}, #endif {sys_binlog_cache_size.name,(char*) &sys_binlog_cache_size, SHOW_SYS}, {sys_bulk_insert_buff_size.name,(char*) &sys_bulk_insert_buff_size,SHOW_SYS}, @@ -740,7 +739,12 @@ struct show_var_st init_vars[]= { SHOW_SYS}, {sys_trans_prealloc_size.name, (char*) &sys_trans_prealloc_size, SHOW_SYS}, {"version", server_version, SHOW_CHAR}, +#ifdef HAVE_BERKELEY_DB + {"version_bdb", (char*) DB_VERSION_STRING, SHOW_CHAR}, +#endif {"version_comment", (char*) MYSQL_COMPILATION_COMMENT, SHOW_CHAR}, + {"version_compile_machine", (char*) MACHINE_TYPE, SHOW_CHAR}, + {"version_compile_os", (char*) SYSTEM_TYPE, SHOW_CHAR}, {sys_net_wait_timeout.name, (char*) &sys_net_wait_timeout, SHOW_SYS}, {NullS, NullS, SHOW_LONG} }; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 1041c21ef30..5dee75a5670 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1036,9 +1036,9 @@ bool select_dump::send_eof() return error; } -select_subselect::select_subselect(Item_subselect *item) +select_subselect::select_subselect(Item_subselect *item_arg) { - this->item=item; + item= item_arg; } bool select_singlerow_subselect::send_data(List &items) @@ -1229,3 +1229,14 @@ bool select_dumpvar::send_eof() return 1; } } + +/**************************************************************************** + TMP_TABLE_PARAM +****************************************************************************/ + +void TMP_TABLE_PARAM::init() +{ + field_count= sum_func_count= func_count= hidden_field_count= 0; + group_parts= group_length= group_null_parts= 0; + quick_group= 1; +} diff --git a/sql/sql_class.h b/sql/sql_class.h index 6be517d42d0..beb2de9c0a9 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -895,7 +895,12 @@ public: class TMP_TABLE_PARAM :public Sql_alloc { - public: +private: + /* Prevent use of these (not safe because of lists and copy_field) */ + TMP_TABLE_PARAM(const TMP_TABLE_PARAM &); + void operator=(TMP_TABLE_PARAM &); + +public: List copy_funcs; List save_copy_funcs; List_iterator_fast copy_funcs_it; @@ -920,6 +925,7 @@ class TMP_TABLE_PARAM :public Sql_alloc { cleanup(); } + void init(void); inline void cleanup(void) { if (copy_field) /* Fix for Intel compiler */ diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 20a1f7f0124..8e6f5b27ab0 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -67,7 +67,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, int res; select_union *derived_result; TABLE_LIST *tables= (TABLE_LIST *)first_select->table_list.first; - TMP_TABLE_PARAM tmp_table_param; bool is_union= first_select->next_select() && first_select->next_select()->linkage == UNION_TYPE; bool is_subsel= first_select->first_inner_unit() ? 1: 0; @@ -111,7 +110,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, fix_tables_pointers(unit); } - if(!(derived_result= new select_union(0))) + if (!(derived_result= new select_union(0))) DBUG_RETURN(1); // out of memory // st_select_lex_unit::prepare correctly work for single select @@ -128,13 +127,14 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); - tmp_table_param.field_count= unit->types.elements; + derived_result->tmp_table_param.init(); + derived_result->tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be processed */ - if (!(table= create_tmp_table(thd, &tmp_table_param, unit->types, + if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param, + unit->types, (ORDER*) 0, is_union && !unit->union_option, 1, (first_select->options | thd->options | @@ -146,7 +146,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, goto exit; } derived_result->set_table(table); - derived_result->tmp_table_param=tmp_table_param; unit->offset_limit_cnt= first_select->offset_limit; unit->select_limit_cnt= first_select->select_limit+ @@ -206,7 +205,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, table->file->info(HA_STATUS_VARIABLE); } } - delete derived_result; if (res) free_tmp_table(thd, table); @@ -218,6 +216,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, } exit: + delete derived_result; lex->current_select= save_current_select; close_thread_tables(thd, 0, 1); } diff --git a/sql/sql_error.cc b/sql/sql_error.cc index db0dbe0dedc..81b98358486 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -102,6 +102,7 @@ void mysql_reset_errors(THD *thd) MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code, const char *msg) { + DBUG_ENTER("push_warning"); if (thd->query_id != thd->warn_id) mysql_reset_errors(thd); @@ -122,7 +123,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, } thd->warn_count[(uint) level]++; thd->total_warn_count++; - return err; + DBUG_RETURN(err); } /* diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 6af4ffde0e1..c40133c04a8 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -524,7 +524,7 @@ int send_header_2(Protocol *protocol, bool for_category) same as strcmp */ -int string_ptr_cmp(const void* ptr1, const void* ptr2) +extern "C" int string_ptr_cmp(const void* ptr1, const void* ptr2) { String *str1= *(String**)ptr1; String *str2= *(String**)ptr2; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 9b74073b64e..4257df494bc 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1289,12 +1289,13 @@ bool st_select_lex::test_limit() 0 - OK !0 - error */ -bool st_select_lex_unit::create_total_list(THD *thd, st_lex *lex, - TABLE_LIST **result, +bool st_select_lex_unit::create_total_list(THD *thd_arg, st_lex *lex, + TABLE_LIST **result_arg, bool check_derived) { - *result= 0; - res= create_total_list_n_last_return(thd, lex, &result, check_derived); + *result_arg= 0; + res= create_total_list_n_last_return(thd_arg, lex, &result_arg, + check_derived); return res; } @@ -1318,12 +1319,14 @@ bool st_select_lex_unit::create_total_list(THD *thd, st_lex *lex, 0 - OK !0 - error */ -bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, - TABLE_LIST ***result, - bool check_derived) +bool st_select_lex_unit:: +create_total_list_n_last_return(THD *thd_arg, + st_lex *lex, + TABLE_LIST ***result_arg, + bool check_derived) { TABLE_LIST *slave_list_first=0, **slave_list_last= &slave_list_first; - TABLE_LIST **new_table_list= *result, *aux; + TABLE_LIST **new_table_list= *result_arg, *aux; SELECT_LEX *sl= (SELECT_LEX*)slave; /* @@ -1342,7 +1345,7 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, if (sl->order_list.first && sl->next_select() && !sl->braces && sl->linkage != GLOBAL_OPTIONS_TYPE) { - net_printf(thd,ER_WRONG_USAGE,"UNION","ORDER BY"); + net_printf(thd_arg,ER_WRONG_USAGE,"UNION","ORDER BY"); return 1; } @@ -1360,12 +1363,12 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, if ((aux= (TABLE_LIST*) sl->table_list.first)) { - TABLE_LIST *next; - for (; aux; aux= next) + TABLE_LIST *next_table; + for (; aux; aux= next_table) { TABLE_LIST *cursor; - next= aux->next; - for (cursor= **result; cursor; cursor= cursor->next) + next_table= aux->next; + for (cursor= **result_arg; cursor; cursor= cursor->next) if (!strcmp(cursor->db, aux->db) && !strcmp(cursor->real_name, aux->real_name) && !strcmp(cursor->alias, aux->alias)) @@ -1397,7 +1400,7 @@ end: *new_table_list= slave_list_first; new_table_list= slave_list_last; } - *result= new_table_list; + *result_arg= new_table_list; return 0; } diff --git a/sql/sql_list.h b/sql/sql_list.h index 7200046e6c5..0972d0341f6 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -283,9 +283,9 @@ public: List_iterator_fast(List &a) : base_list_iterator(a) {} inline T* operator++(int) { return (T*) base_list_iterator::next_fast(); } inline void rewind(void) { base_list_iterator::rewind(); } - void sublist(List &list, uint el) + void sublist(List &list_arg, uint el_arg) { - base_list_iterator::sublist(list, el); + base_list_iterator::sublist(list_arg, el_arg); } }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d5a15de422d..d74d06f9439 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4320,8 +4320,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, LEX_STRING *alias, ulong table_options, thr_lock_type lock_type, - List *use_index, - List *ignore_index, + List *use_index_arg, + List *ignore_index_arg, LEX_STRING *option) { register TABLE_LIST *ptr; @@ -4377,12 +4377,12 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX); ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES); ptr->derived= table->sel; - if (use_index) - ptr->use_index=(List *) thd->memdup((gptr) use_index, - sizeof(*use_index)); - if (ignore_index) - ptr->ignore_index=(List *) thd->memdup((gptr) ignore_index, - sizeof(*ignore_index)); + if (use_index_arg) + ptr->use_index=(List *) thd->memdup((gptr) use_index_arg, + sizeof(*use_index_arg)); + if (ignore_index_arg) + ptr->ignore_index=(List *) thd->memdup((gptr) ignore_index_arg, + sizeof(*ignore_index_arg)); ptr->option= option ? option->str : 0; /* check that used name is unique */ if (lock_type != TL_IGNORE) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ba4dd9f856e..3594b53436e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -284,8 +284,8 @@ JOIN::prepare(Item ***rref_pointer_array, uint wild_num, COND *conds_init, uint og_num, ORDER *order_init, ORDER *group_init, Item *having_init, - ORDER *proc_param_init, SELECT_LEX *select, - SELECT_LEX_UNIT *unit) + ORDER *proc_param_init, SELECT_LEX *select_lex_arg, + SELECT_LEX_UNIT *unit_arg) { DBUG_ENTER("JOIN::prepare"); @@ -295,9 +295,9 @@ JOIN::prepare(Item ***rref_pointer_array, having= having_init; proc_param= proc_param_init; tables_list= tables_init; - select_lex= select; + select_lex= select_lex_arg; select_lex->join= this; - union_part= (unit->first_select()->next_select() != 0); + union_part= (unit_arg->first_select()->next_select() != 0); /* Check that all tables, fields, conds and order are ok */ @@ -369,14 +369,14 @@ JOIN::prepare(Item ***rref_pointer_array, DBUG_RETURN(-1); } } - TABLE_LIST *table; - for (table=tables_list ; table ; table=table->next) + TABLE_LIST *table_ptr; + for (table_ptr= tables_list ; table_ptr ; table_ptr= table_ptr->next) tables++; } { /* Caclulate the number of groups */ send_group_parts= 0; - for (ORDER *group= group_list ; group ; group= group->next) + for (ORDER *group_tmp= group_list ; group_tmp ; group_tmp= group_tmp->next) send_group_parts++; } @@ -416,13 +416,13 @@ JOIN::prepare(Item ***rref_pointer_array, ref_pointer_array_size= all_fields.elements*sizeof(Item*); this->group= group_list != 0; row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR : - unit->select_limit_cnt); + unit_arg->select_limit_cnt); /* select_limit is used to decide if we are likely to scan the whole table */ - select_limit= unit->select_limit_cnt; + select_limit= unit_arg->select_limit_cnt; if (having || (select_options & OPTION_FOUND_ROWS)) select_limit= HA_POS_ERROR; - do_send_rows = (unit->select_limit_cnt) ? 1 : 0; - this->unit= unit; + do_send_rows = (unit_arg->select_limit_cnt) ? 1 : 0; + unit= unit_arg; #ifdef RESTRICTED_GROUP if (sum_func_count && !group_list && (func_count || field_count)) @@ -431,7 +431,7 @@ JOIN::prepare(Item ***rref_pointer_array, goto err; } #endif - if (!procedure && result->prepare(fields_list, unit)) + if (!procedure && result->prepare(fields_list, unit_arg)) goto err; /* purecov: inspected */ if (select_lex->olap == ROLLUP_TYPE && rollup_init()) @@ -607,20 +607,20 @@ JOIN::optimize() if (const_tables && !thd->locked_tables && !(select_options & SELECT_NO_UNLOCK)) { - TABLE **table, **end; - for (table=this->table, end=table + const_tables ; - table != end; - table++) + TABLE **curr_table, **end; + for (curr_table= table, end=cur_table + const_tables ; + curr_table != end; + curr_table++) { /* BDB tables require that we call index_end() before doing an unlock */ - if ((*table)->key_read) + if ((*curr_table)->key_read) { - (*table)->key_read=0; - (*table)->file->extra(HA_EXTRA_NO_KEYREAD); + (*curr_table)->key_read=0; + (*curr_table)->file->extra(HA_EXTRA_NO_KEYREAD); } - (*table)->file->index_end(); + (*curr_table)->file->index_end(); } - mysql_unlock_some_tables(thd, this->table, const_tables); + mysql_unlock_some_tables(thd, table, const_tables); } if (!conds && outer_join) { @@ -963,18 +963,18 @@ JOIN::optimize() if (exec_tmp_table1->distinct) { table_map used_tables= thd->used_tables; - JOIN_TAB *join_tab= this->join_tab+tables-1; + JOIN_TAB *last_join_tab= join_tab+tables-1; do { - if (used_tables & join_tab->table->map) + if (used_tables & last_join_tab->table->map) break; - join_tab->not_used_in_distinct=1; - } while (join_tab-- != this->join_tab); + last_join_tab->not_used_in_distinct=1; + } while (last_join_tab-- != join_tab); /* Optimize "select distinct b from t1 order by key_part_1 limit #" */ if (order && skip_sort_order) { /* Should always succeed */ - if (test_if_skip_sort_order(&this->join_tab[const_tables], + if (test_if_skip_sort_order(&join_tab[const_tables], order, unit->select_limit_cnt, 0)) order=0; } @@ -1393,26 +1393,27 @@ JOIN::exec() { // Some tables may have been const curr_join->tmp_having->update_used_tables(); - JOIN_TAB *table= &curr_join->join_tab[curr_join->const_tables]; - table_map used_tables= curr_join->const_table_map | table->table->map; + JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables]; + table_map used_tables= (curr_join->const_table_map | + curr_table->table->map); Item* sort_table_cond= make_cond_for_table(curr_join->tmp_having, used_tables, used_tables); if (sort_table_cond) { - if (!table->select) - if (!(table->select= new SQL_SELECT)) + if (!curr_table->select) + if (!(curr_table->select= new SQL_SELECT)) DBUG_VOID_RETURN; - if (!table->select->cond) - table->select->cond= sort_table_cond; + if (!curr_table->select->cond) + curr_table->select->cond= sort_table_cond; else // This should never happen - if (!(table->select->cond= new Item_cond_and(table->select->cond, - sort_table_cond))) + if (!(curr_table->select->cond= + new Item_cond_and(curr_table->select->cond, sort_table_cond))) DBUG_VOID_RETURN; - table->select_cond=table->select->cond; - table->select_cond->top_level_item(); - DBUG_EXECUTE("where",print_where(table->select->cond, + curr_table->select_cond= cur_table->select->cond; + curr_table->select_cond->top_level_item(); + DBUG_EXECUTE("where",print_where(curr_table->select->cond, "select and having");); curr_join->tmp_having= make_cond_for_table(curr_join->tmp_having, ~ (table_map) 0, @@ -1429,9 +1430,9 @@ JOIN::exec() We can abort sorting after thd->select_limit rows if we there is no WHERE clause for any tables after the sorted one. */ - JOIN_TAB *table= &curr_join->join_tab[curr_join->const_tables+1]; + JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables+1]; JOIN_TAB *end_table= &curr_join->join_tab[tables]; - for (; table < end_table ; table++) + for (; curr_table < end_table ; curr_table++) { /* table->keyuse is set in the case there was an original WHERE clause @@ -1439,7 +1440,8 @@ JOIN::exec() table->on_expr tells us that it was a LEFT JOIN and there will be at least one row generated from the table. */ - if (table->select_cond || (table->keyuse && !table->on_expr)) + if (curr_table->select_cond || + (curr_table->keyuse && !curr_table->on_expr)) { /* We have to sort all rows */ curr_join->select_limit= HA_POS_ERROR; @@ -1517,11 +1519,11 @@ JOIN::cleanup() delete select; delete_dynamic(&keyuse); delete procedure; - for (SELECT_LEX_UNIT *unit= select_lex->first_inner_unit(); - unit != 0; - unit= unit->next_unit()) + for (SELECT_LEX_UNIT *lex_unit= select_lex->first_inner_unit(); + lex_unit != 0; + lex_unit= lex_unit->next_unit()) { - error|= unit->cleanup(); + error|= lex_unit->cleanup(); } DBUG_RETURN(error); } @@ -4313,10 +4315,11 @@ COND *eliminate_not_funcs(COND *cond) static COND * optimize_cond(COND *conds,Item::cond_result *cond_value) { + DBUG_ENTER("optimize_cond"); if (!conds) { *cond_value= Item::COND_TRUE; - return conds; + DBUG_RETURN(conds); } DBUG_EXECUTE("where",print_where(conds,"original");); /* eliminate NOT operators */ @@ -4331,7 +4334,7 @@ optimize_cond(COND *conds,Item::cond_result *cond_value) DBUG_EXECUTE("where",print_where(conds,"after const change");); conds=remove_eq_conds(conds,cond_value) ; DBUG_EXECUTE("info",print_where(conds,"after remove");); - return conds; + DBUG_RETURN(conds); } @@ -8382,10 +8385,10 @@ bool JOIN::alloc_func_list() } -bool JOIN::make_sum_func_list(List &all_fields, List &send_fields, +bool JOIN::make_sum_func_list(List &field_list, List &send_fields, bool before_group_by) { - List_iterator_fast it(all_fields); + List_iterator_fast it(field_list); Item_sum **func; Item *item; DBUG_ENTER("make_sum_func_list"); @@ -8404,7 +8407,7 @@ bool JOIN::make_sum_func_list(List &all_fields, List &send_fields, if (before_group_by && rollup.state == ROLLUP::STATE_INITED) { rollup.state= ROLLUP::STATE_READY; - if (rollup_make_fields(all_fields, send_fields, &func)) + if (rollup_make_fields(field_list, send_fields, &func)) DBUG_RETURN(TRUE); // Should never happen } else if (rollup.state == ROLLUP::STATE_NONE) @@ -8707,12 +8710,12 @@ bool JOIN::rollup_init() */ for (i= 0 ; i < send_group_parts ; i++) { - List *fields= &rollup.fields[i]; - fields->empty(); + List *rollup_fields= &rollup.fields[i]; + rollup_fields->empty(); rollup.ref_pointer_arrays[i]= ref_array; ref_array+= all_fields.elements; for (j=0 ; j < fields_list.elements ; j++) - fields->push_back(rollup.item_null); + rollup_fields->push_back(rollup.item_null); } return 0; } @@ -8723,8 +8726,8 @@ bool JOIN::rollup_init() SYNOPSIS rollup_make_fields() - all_fields List of all fields (hidden and real ones) - fields Pointer to selected fields + fields_arg List of all fields (hidden and real ones) + sel_fields Pointer to selected fields func Store here a pointer to all fields IMPLEMENTATION: @@ -8736,11 +8739,11 @@ bool JOIN::rollup_init() 1 on error */ -bool JOIN::rollup_make_fields(List &all_fields, List &fields, +bool JOIN::rollup_make_fields(List &fields_arg, List &sel_fields, Item_sum ***func) { - List_iterator_fast it(all_fields); - Item *first_field= fields.head(); + List_iterator_fast it(fields_arg); + Item *first_field= sel_fields.head(); uint level; /* @@ -8775,7 +8778,7 @@ bool JOIN::rollup_make_fields(List &all_fields, List &fields, ORDER *start_group; /* Point to first hidden field */ - Item **ref_array= ref_array_start + all_fields.elements-1; + Item **ref_array= ref_array_start + fields_arg.elements-1; /* Remember where the sum functions ends for the previous level */ sum_funcs_end[pos+1]= *func; @@ -8815,10 +8818,10 @@ bool JOIN::rollup_make_fields(List &all_fields, List &fields, else if (real_fields) { /* Check if this is something that is part of this group by */ - ORDER *group; - for (group= start_group ; group ; group= group->next) + ORDER *group_tmp; + for (group_tmp= start_group ; group_tmp ; group_tmp= group_tmp->next) { - if (*group->item == item) + if (*group_tmp->item == item) { /* This is an element that is used by the GROUP BY and should be @@ -8925,7 +8928,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, DBUG_ENTER("select_describe"); DBUG_PRINT("info", ("Select 0x%lx, type %s, message %s", (ulong)join->select_lex, join->select_lex->type, - message)); + message ? message : "NULL")); /* Don't log this into the slow query log */ select_lex->options&= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED); join->unit->offset_limit_cnt= 0; @@ -9238,8 +9241,8 @@ void st_select_lex::print(THD *thd, String *str) next_on= 0; } - TABLE_LIST *next; - if ((next= table->next)) + TABLE_LIST *next_table; + if ((next_table= table->next)) { if (table->outer_join & JOIN_TYPE_RIGHT) { @@ -9248,9 +9251,9 @@ void st_select_lex::print(THD *thd, String *str) table->on_expr) next_on= table->on_expr; } - else if (next->straight) + else if (next_table->straight) str->append(" straight_join ", 15); - else if (next->outer_join & JOIN_TYPE_LEFT) + else if (next_table->outer_join & JOIN_TYPE_LEFT) str->append(" left join ", 11); else str->append(" join ", 6); @@ -9258,17 +9261,17 @@ void st_select_lex::print(THD *thd, String *str) } } - //where - Item *where= this->where; + // Where + Item *cur_where= where; if (join) - where= join->conds; - if (where) + cur_where= join->conds; + if (cur_where) { str->append(" where ", 7); - where->print(str); + cur_where->print(str); } - //group by & olap + // group by & olap if (group_list.elements) { str->append(" group by ", 10); @@ -9286,15 +9289,15 @@ void st_select_lex::print(THD *thd, String *str) } } - //having - Item *having= this->having; + // having + Item *cur_having= having; if (join) - having= join->having; + cur_having= join->having; - if (having) + if (cur_having) { str->append(" having ", 8); - having->print(str); + cur_having->print(str); } if (order_list.elements) diff --git a/sql/sql_select.h b/sql/sql_select.h index 2e101c78613..7cc71117914 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -207,14 +207,14 @@ class JOIN :public Sql_alloc bool union_part; // this subselect is part of union bool optimized; // flag to avoid double optimization in EXPLAIN - JOIN(THD *thd_arg, List &fields, ulong select_options_arg, + JOIN(THD *thd_arg, List &fields_arg, ulong select_options_arg, select_result *result_arg) - :fields_list(fields) + :fields_list(fields_arg) { - init(thd_arg, fields, select_options_arg, result_arg); + init(thd_arg, fields_arg, select_options_arg, result_arg); } - void init(THD *thd_arg, List &fields, ulong select_options_arg, + void init(THD *thd_arg, List &fields_arg, ulong select_options_arg, select_result *result_arg) { join_tab= join_tab_save= 0; @@ -247,8 +247,8 @@ class JOIN :public Sql_alloc hidden_group_fields= 0; /*safety*/ buffer_result= test(select_options & OPTION_BUFFER_RESULT) && !test(select_options & OPTION_FOUND_ROWS); - all_fields= fields; - fields_list= fields; + all_fields= fields_arg; + fields_list= fields_arg; error= 0; select= 0; ref_pointer_array= items0= items1= items2= items3= 0; @@ -256,7 +256,7 @@ class JOIN :public Sql_alloc zero_result_cause= 0; optimized= 0; - fields_list= fields; + fields_list= fields_arg; bzero((char*) &keyuse,sizeof(keyuse)); tmp_table_param.copy_field=0; tmp_table_param.end_write_records= HA_POS_ERROR; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 56713e42244..f2470a59944 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -106,9 +106,9 @@ bool select_union::flush() } -int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) +int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result) { - SELECT_LEX *lex_select_save= thd->lex.current_select; + SELECT_LEX *lex_select_save= thd_arg->lex.current_select; SELECT_LEX *sl, *first_select; select_result *tmp_result; DBUG_ENTER("st_select_lex_unit::prepare"); @@ -123,10 +123,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) DBUG_RETURN(0); prepared= 1; res= 0; - TMP_TABLE_PARAM tmp_table_param; - bzero((char *)&tmp_table_param,sizeof(TMP_TABLE_PARAM)); - thd->lex.current_select= sl= first_select= first_select_in_union(); + thd_arg->lex.current_select= sl= first_select= first_select_in_union(); found_rows_for_union= first_select->options & OPTION_FOUND_ROWS; /* Global option */ @@ -136,7 +134,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) if (!(tmp_result= union_result= new select_union(0))) goto err; union_result->not_describe= 1; - union_result->tmp_table_param= tmp_table_param; + union_result->tmp_table_param.init(); } else { @@ -147,10 +145,10 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) for (;sl; sl= sl->next_select()) { - JOIN *join= new JOIN(thd, sl->item_list, - sl->options | thd->options | SELECT_NO_UNLOCK, + JOIN *join= new JOIN(thd_arg, sl->item_list, + sl->options | thd_arg->options | SELECT_NO_UNLOCK, tmp_result); - thd->lex.current_select= sl; + thd_arg->lex.current_select= sl; offset_limit_cnt= sl->offset_limit; select_limit_cnt= sl->select_limit+sl->offset_limit; if (select_limit_cnt < sl->select_limit) @@ -169,19 +167,19 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) sl->having, (ORDER*) NULL, sl, this); - if (res || thd->is_fatal_error) + if (res || thd_arg->is_fatal_error) goto err; if (sl == first_select) { types.empty(); List_iterator_fast it(sl->item_list); - Item *item; - while((item= it++)) + Item *item_tmp; + while ((item_tmp= it++)) { - types.push_back(new Item_type_holder(thd, item)); + types.push_back(new Item_type_holder(thd_arg, item_tmp)); } - if (thd->is_fatal_error) + if (thd_arg->is_fatal_error) goto err; // out of memory } else @@ -194,10 +192,10 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) } List_iterator_fast it(sl->item_list); List_iterator_fast tp(types); - Item *type, *item; - while((type= tp++, item= it++)) + Item *type, *item_tmp; + while ((type= tp++, item_tmp= it++)) { - if (((Item_type_holder*)type)->join_types(thd, item)) + if (((Item_type_holder*)type)->join_types(thd_arg, item_tmp)) DBUG_RETURN(-1); } } @@ -205,11 +203,12 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) if (first_select->next_select()) { - tmp_table_param.field_count= types.elements; - if (!(table= create_tmp_table(thd, &tmp_table_param, types, + union_result->tmp_table_param.field_count= types.elements; + if (!(table= create_tmp_table(thd_arg, + &union_result->tmp_table_param, types, (ORDER*) 0, !union_option, 1, (first_select_in_union()->options | - thd->options | + thd_arg->options | TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, (char*) ""))) goto err; @@ -222,7 +221,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) union_result->set_table(table); item_list.empty(); - thd->lex.current_select= lex_select_save; + thd_arg->lex.current_select= lex_select_save; { Field **field; for (field= table->field; *field; field++) @@ -235,12 +234,12 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) else first_select->braces= 0; // remove our changes - thd->lex.current_select= lex_select_save; + thd_arg->lex.current_select= lex_select_save; - DBUG_RETURN(res || thd->is_fatal_error ? 1 : 0); + DBUG_RETURN(res || thd_arg->is_fatal_error ? 1 : 0); err: - thd->lex.current_select= lex_select_save; + thd_arg->lex.current_select= lex_select_save; DBUG_RETURN(-1); } @@ -375,7 +374,7 @@ int st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { - ulong options= thd->options; + ulong options_tmp= thd->options; thd->lex.current_select= fake_select_lex; offset_limit_cnt= global_parameters->offset_limit; select_limit_cnt= global_parameters->select_limit + @@ -384,9 +383,9 @@ int st_select_lex_unit::exec() if (select_limit_cnt < global_parameters->select_limit) select_limit_cnt= HA_POS_ERROR; // no limit if (select_limit_cnt == HA_POS_ERROR) - options&= ~OPTION_FOUND_ROWS; + options_tmp&= ~OPTION_FOUND_ROWS; else if (found_rows_for_union && !thd->lex.describe) - options|= OPTION_FOUND_ROWS; + options_tmp|= OPTION_FOUND_ROWS; fake_select_lex->ftfunc_list= &empty_list; fake_select_lex->table_list.link_in_list((byte *)&result_table_list, (byte **) @@ -421,7 +420,7 @@ int st_select_lex_unit::exec() global_parameters->order_list.elements, (ORDER*)global_parameters->order_list.first, (ORDER*) NULL, NULL, (ORDER*) NULL, - options | SELECT_NO_UNLOCK, + options_tmp | SELECT_NO_UNLOCK, result, this, fake_select_lex); if (!res) thd->limit_found_rows = (ulonglong)table->file->records + add_rows; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 8b77f6958d0..d623ea66dfb 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -481,7 +481,8 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list, Connect fields with tables and create list of tables that are updated */ -int multi_update::prepare(List ¬_used_values, SELECT_LEX_UNIT *unit) +int multi_update::prepare(List ¬_used_values, + SELECT_LEX_UNIT *lex_unit) { TABLE_LIST *table_ref; SQL_LIST update; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b944dc3955c..805dc9f1932 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -688,7 +688,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); insert_values update delete truncate rename show describe load alter optimize keycache preload flush reset purge begin commit rollback savepoint - slave master_def master_defs master_file_def + slave master_def master_defs master_file_def slave_until_opts repair restore backup analyze check start checksum field_list field_list_item field_spec kill column_def key_def keycache_list assign_to_keycache preload_list preload_keys diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c index b21740f9dbb..d5ffa15ee0c 100644 --- a/strings/conf_to_src.c +++ b/strings/conf_to_src.c @@ -14,18 +14,12 @@ 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 -#include -#include -#include -#include - #include +#include #include +#include #include - #define ROW_LEN 16 #define ROW16_LEN 8 #define MAX_BUF 16*1024 From 6a3e29c8652b3fa44c7128b860097f07885189f2 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 Nov 2003 13:15:42 +0200 Subject: [PATCH 78/89] Fix wrong last edit for last commit --- sql/sql_select.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3594b53436e..82ce688495a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -608,7 +608,7 @@ JOIN::optimize() !(select_options & SELECT_NO_UNLOCK)) { TABLE **curr_table, **end; - for (curr_table= table, end=cur_table + const_tables ; + for (curr_table= table, end=curr_table + const_tables ; curr_table != end; curr_table++) { @@ -1411,7 +1411,7 @@ JOIN::exec() if (!(curr_table->select->cond= new Item_cond_and(curr_table->select->cond, sort_table_cond))) DBUG_VOID_RETURN; - curr_table->select_cond= cur_table->select->cond; + curr_table->select_cond= curr_table->select->cond; curr_table->select_cond->top_level_item(); DBUG_EXECUTE("where",print_where(curr_table->select->cond, "select and having");); From 16e5b4f0ba9db861585a0667fdee1dae1cc1e267 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 28 Nov 2003 12:36:45 +0100 Subject: [PATCH 79/89] bug #1945. item(expression)->name=0, crash in find_item_in_list --- mysql-test/r/order_by.result | 4 ++++ mysql-test/t/order_by.test | 8 ++++++++ sql/sql_base.cc | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 076c80035b2..093633d5f5a 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -542,3 +542,7 @@ a b 1 2 5 NULL DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +SET @id=0; +UPDATE t1 SET a=0 ORDER BY (a=@id), b; +DROP TABLE t1; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 1fb83509ebb..8215ec84ae3 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -345,3 +345,11 @@ SELECT * FROM t1 ORDER BY (a + b); SELECT * FROM t1 ORDER BY (a + b) DESC; DROP TABLE t1; +# +# Bug #1945 - Crashing bug with bad User Variables in UPDATE ... ORDER BY ... +# +CREATE TABLE t1 (a INT, b INT); +SET @id=0; +UPDATE t1 SET a=0 ORDER BY (a=@id), b; +DROP TABLE t1; + diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 47529b90b67..e4694adb9a2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1837,7 +1837,7 @@ find_item_in_list(Item *find,List &items) } } else if (!table_name && (item->eq(find,0) || - find->name && + find->name && item->name && !my_strcasecmp(item->name,find->name))) { found=li.ref(); From 4f42a47408c316edbae8965fc1aef9979ead2026 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 Nov 2003 15:45:34 +0200 Subject: [PATCH 80/89] Fixed range optimzier bug (Bug #1828) --- mysql-test/r/range.result | 10 ++++++++++ mysql-test/t/range.test | 13 ++++++++++++- sql/opt_range.cc | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 68987009598..e87df9a6c24 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -290,3 +290,13 @@ t1 range a,b a 5 NULL 2 Using where SELECT * FROM t1 WHERE a IN(1,2) AND b=5; a b DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index e09fa73256b..364ea2d4195 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -231,9 +231,20 @@ INSERT INTO t1 VALUES (21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), (33,5),(33,5),(33,5),(33,5),(34,5),(35,5); +# we expect that optimizer will choose index on A EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; SELECT * FROM t1 WHERE a IN(1,2) AND b=5; DROP TABLE t1; -# we expect that optimizer will choose index on A +# +# Test error with +# + +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +# -- First reports 3; second reports 6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +DROP TABLE t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e932b2c46d6..63850709285 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -70,7 +70,7 @@ public: {} inline bool is_same(SEL_ARG *arg) { - if (type != arg->type) + if (type != arg->type || part != arg->part) return 0; if (type != KEY_RANGE) return 1; From e149e63334b42cb80ed3e8a2f85bb31d5ac949d1 Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Fri, 28 Nov 2003 17:28:04 +0300 Subject: [PATCH 81/89] cleanup: comment moved to proper place --- sql-common/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-common/client.c b/sql-common/client.c index 6b99b3424ea..52e5f84deae 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1455,8 +1455,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, user ? user : "(Null)")); /* Don't give sigpipe errors if the client doesn't want them */ - mysql->methods= &client_methods; set_sigpipe(mysql); + mysql->methods= &client_methods; net->vio = 0; /* If something goes wrong */ mysql->client_flag=0; /* For handshake */ From c9fd311aacbe0bf00dd61c4f42238aa0437513c4 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Fri, 28 Nov 2003 16:15:21 +0100 Subject: [PATCH 82/89] In the slave I/O thread (in master.info), it seems less worse to flush the relay log before flushing master.info. Doing 'before' leads to duplicate event, doing after leads to missing event. Both can be as destructive, but 'duplicate' enables us to later add detection code to catch it. Whereas 'missing' can't be caught (it can't, because the I/O thread can produce legal position jumps, for example if it has ignored an event coming from this slave (rememember that starting from 4.1.1, the I/O thread filters the server id). --- sql/slave.cc | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index 5fab217762c..5ace523be73 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2084,6 +2084,30 @@ bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache) DBUG_ENTER("flush_master_info"); DBUG_PRINT("enter",("master_pos: %ld", (long) mi->master_log_pos)); + /* + Flush the relay log to disk. If we don't do it, then the relay log while + have some part (its last kilobytes) in memory only, so if the slave server + dies now, with, say, from master's position 100 to 150 in memory only (not + on disk), and with position 150 in master.info, then when the slave + restarts, the I/O thread will fetch binlogs from 150, so in the relay log + we will have "[0, 100] U [150, infinity[" and nobody will notice it, so the + SQL thread will jump from 100 to 150, and replication will silently break. + + When we come to this place in code, relay log may or not be initialized; + the caller is responsible for setting 'flush_relay_log_cache' accordingly. + */ + if (flush_relay_log_cache) + flush_io_cache(mi->rli.relay_log.get_log_file()); + + /* + We flushed the relay log BEFORE the master.info file, because if we crash + now, we will get a duplicate event in the relay log at restart. If we + flushed in the other order, we would get a hole in the relay log. + And duplicate is better than hole (with a duplicate, in later versions we + can add detection and scrap one event; with a hole there's nothing we can + do). + */ + /* In certain cases this code may create master.info files that seems corrupted, because of extra lines filled with garbage in the end @@ -2101,20 +2125,6 @@ bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache) (int)(mi->ssl), mi->ssl_ca, mi->ssl_capath, mi->ssl_cert, mi->ssl_cipher, mi->ssl_key); flush_io_cache(file); - /* - Flush the relay log to disk. If we don't do it, then the relay log while - have some part (its last kilobytes) in memory only, so if the slave server - dies now, with, say, from master's position 100 to 150 in memory only (not - on disk), and with position 150 in master.info, then when the slave - restarts, the I/O thread will fetch binlogs from 150, so in the relay log - we will have "[0, 100] U [150, infinity[" and nobody will notice it, so the - SQL thread will jump from 100 to 150, and replication will silently break. - - When we come to this place in code, relay log may or not be initialized; - the caller is responsible for setting 'flush_relay_log_cache' accordingly. - */ - if (flush_relay_log_cache) - flush_io_cache(mi->rli.relay_log.get_log_file()); DBUG_RETURN(0); } From d2e065022f8afdd116a811b2ec8812f672d24989 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 28 Nov 2003 18:15:58 +0100 Subject: [PATCH 83/89] "optimization cleanup" reverted - problems on rpl_redirect test. It happens that mysql->client_next->client_next=mysql and mysql_close() goes into infinite loop. Results vary from simple sigsegv (FreeBSD), to hard system lockup (Linux) :) --- libmysql/libmysql.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 0c9c68f4505..763288a5e83 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2276,6 +2276,8 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host, else if (parent->options.db) child->options.db = my_strdup(parent->options.db, MYF(0)); + child->options.rpl_parse = child->options.rpl_probe = child->rpl_pivot = 0; + return child; } From cad6b7c8be513390ff345e2e7c2e997446419acf Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 Nov 2003 20:41:33 +0200 Subject: [PATCH 84/89] rpl_parse and rpl_probe don't have to be reset as they are already 0 --- libmysql/libmysql.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 763288a5e83..6abc29d29f4 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2256,29 +2256,33 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host, const char* passwd) { MYSQL* child; - if (!(child = mysql_init(0))) - return 0; + DBUG_ENTER("spawn_init"); + if (!(child= mysql_init(0))) + DBUG_RETURN(0); - child->options.user = my_strdup((user) ? user : - (parent->user ? parent->user : - parent->options.user), MYF(0)); - child->options.password = my_strdup((passwd) ? passwd : - (parent->passwd ? - parent->passwd : - parent->options.password), MYF(0)); - child->options.port = port; - child->options.host = my_strdup((host) ? host : - (parent->host ? - parent->host : - parent->options.host), MYF(0)); + child->options.user= my_strdup((user) ? user : + (parent->user ? parent->user : + parent->options.user), MYF(0)); + child->options.password= my_strdup((passwd) ? passwd : + (parent->passwd ? + parent->passwd : + parent->options.password), MYF(0)); + child->options.port= port; + child->options.host= my_strdup((host) ? host : + (parent->host ? + parent->host : + parent->options.host), MYF(0)); if (parent->db) - child->options.db = my_strdup(parent->db, MYF(0)); + child->options.db= my_strdup(parent->db, MYF(0)); else if (parent->options.db) - child->options.db = my_strdup(parent->options.db, MYF(0)); + child->options.db= my_strdup(parent->options.db, MYF(0)); - child->options.rpl_parse = child->options.rpl_probe = child->rpl_pivot = 0; - - return child; + /* + rpl_pivot is set to 1 in mysql_init(); Reset it as we are not doing + replication here + */ + child->rpl_pivot= 0; + DBUG_RETURN(child); } From 3ee758497f28359ab6fbccbfd32c1565b21dc571 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 Nov 2003 21:05:53 +0200 Subject: [PATCH 85/89] Mark position as # to make test portable --- mysql-test/r/rpl_until.result | 6 +++--- mysql-test/t/rpl_until.test | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result index 854a8605abb..4e03b47fe57 100644 --- a/mysql-test/r/rpl_until.result +++ b/mysql-test/r/rpl_until.result @@ -41,7 +41,7 @@ n 4 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 332 master-bin.000001 Yes No 0 0 244 649 Master master-no-such-bin.000001 291 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 244 649 Master master-no-such-bin.000001 291 No # start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537; select * from t2; n @@ -49,13 +49,13 @@ n 2 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 537 master-bin.000001 Yes No 0 0 449 649 Relay slave-relay-bin.000002 537 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 449 649 Relay slave-relay-bin.000002 537 No # start slave; stop slave; start slave until master_log_file='master-bin.000001', master_log_pos=561; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 649 master-bin.000001 Yes No 0 0 561 693 Master master-bin.000001 561 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 561 693 Master master-bin.000001 561 No # start slave until master_log_file='master-bin', master_log_pos=561; ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test index 8b20a493826..18c1162ed8d 100644 --- a/mysql-test/t/rpl_until.test +++ b/mysql-test/t/rpl_until.test @@ -38,7 +38,7 @@ start slave until master_log_file='master-no-such-bin.000001', master_log_pos=29 select * from t1; sleep 2; --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 33 # +--replace_column 1 # 9 # 33 # show slave status; # try replicate all until second insert to t2; @@ -46,7 +46,7 @@ start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537; sleep 2; select * from t2; --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 33 # +--replace_column 1 # 9 # 33 # show slave status; # clean up @@ -62,7 +62,7 @@ start slave until master_log_file='master-bin.000001', master_log_pos=561; sleep 2; # here the sql slave thread should be stopped --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 33 # +--replace_column 1 # 9 # 33 # show slave status; #testing various error conditions From f266cdabab538eeb87682af70d5e76652ee6387b Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Mon, 1 Dec 2003 13:13:16 +0200 Subject: [PATCH 86/89] Portability fixes (for binary build) Added --protocol to mysqlbinlog --- client/mysql.cc | 2 +- client/mysqlbinlog.cc | 22 ++++++++++- mysql-test/r/rpl_until.result | 6 +-- mysql-test/t/rpl_until.test | 6 +-- sql/mysqld.cc | 71 ++++++++++++++++++++++------------- vio/viosocket.c | 4 +- 6 files changed, 73 insertions(+), 38 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 9062b58d09b..42088d107ed 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -709,7 +709,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } break; } - break; + break; case 'A': rehash= 0; break; diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index f870c92cb6d..35f0db76ad6 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -34,6 +34,7 @@ ulong server_id = 0; ulong bytes_sent = 0L, bytes_received = 0L; ulong mysqld_net_retry_count = 10L; uint test_flags = 0; +static uint opt_protocol= 0; static FILE *result_file; @@ -233,6 +234,10 @@ static struct my_option my_long_options[] = {"position", 'j', "Start reading the binlog at position N.", (gptr*) &position, (gptr*) &position, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"protocol", OPT_MYSQL_PROTOCOL, + "The protocol of connection (tcp,socket,pipe,memory).", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"read-from-remote-server", 'R', "Read binary logs from a MySQL server", @@ -285,7 +290,7 @@ static void die(const char* fmt, ...) static void print_version() { - printf("%s Ver 2.4 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + printf("%s Ver 2.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); } @@ -369,6 +374,17 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'R': remote_opt= 1; break; + case OPT_MYSQL_PROTOCOL: + { + if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) == + ~(ulong) 0) + { + fprintf(stderr, "Unknown option to protocol: %s\n", argument); + exit(1); + } + break; + } + break; case 'V': print_version(); exit(0); @@ -398,9 +414,11 @@ static int parse_args(int *argc, char*** argv) static MYSQL* safe_connect() { MYSQL *local_mysql = mysql_init(NULL); - if(!local_mysql) + if (!local_mysql) die("Failed on mysql_init"); + if (opt_protocol) + mysql_options(local_mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol); if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0)) die("failed on connect: %s", mysql_error(local_mysql)); diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result index 4e03b47fe57..c179351551d 100644 --- a/mysql-test/r/rpl_until.result +++ b/mysql-test/r/rpl_until.result @@ -41,7 +41,7 @@ n 4 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 244 649 Master master-no-such-bin.000001 291 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 244 # Master master-no-such-bin.000001 291 No # start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537; select * from t2; n @@ -49,13 +49,13 @@ n 2 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 449 649 Relay slave-relay-bin.000002 537 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 449 # Relay slave-relay-bin.000002 537 No # start slave; stop slave; start slave until master_log_file='master-bin.000001', master_log_pos=561; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 561 693 Master master-bin.000001 561 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 561 # Master master-bin.000001 561 No # start slave until master_log_file='master-bin', master_log_pos=561; ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test index 18c1162ed8d..9bc4ea4e7b1 100644 --- a/mysql-test/t/rpl_until.test +++ b/mysql-test/t/rpl_until.test @@ -38,7 +38,7 @@ start slave until master_log_file='master-no-such-bin.000001', master_log_pos=29 select * from t1; sleep 2; --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 9 # 33 # +--replace_column 1 # 9 # 23 # 33 # show slave status; # try replicate all until second insert to t2; @@ -46,7 +46,7 @@ start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537; sleep 2; select * from t2; --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 9 # 33 # +--replace_column 1 # 9 # 23 # 33 # show slave status; # clean up @@ -62,7 +62,7 @@ start slave until master_log_file='master-bin.000001', master_log_pos=561; sleep 2; # here the sql slave thread should be stopped --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 9 # 33 # +--replace_column 1 # 9 # 23 # 33 # show slave status; #testing various error conditions diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9b31e35f90c..99ab926c479 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5785,63 +5785,80 @@ static void fix_paths(void) */ #ifdef SET_RLIMIT_NOFILE + +#ifndef RLIM_INFINITY +#define RLIM_INFINITY ((uint) 0xffffffff) +#endif + static uint set_maximum_open_files(uint max_file_limit) { struct rlimit rlimit; - ulong old_cur; + uint old_cur; + DBUG_ENTER("set_maximum_open_files"); + DBUG_PRINT("enter",("files: %u", max_file_limit)); if (!getrlimit(RLIMIT_NOFILE,&rlimit)) { - old_cur=rlimit.rlim_cur; - if (rlimit.rlim_cur >= max_file_limit) // Nothing to do - return rlimit.rlim_cur; /* purecov: inspected */ - rlimit.rlim_cur=rlimit.rlim_max=max_file_limit; + old_cur= (uint) rlimit.rlim_cur; + DBUG_PRINT("info", ("rlim_cur: %u rlim_max: %u", + (uint) rlimit.rlim_cur, + (uint) rlimit.rlim_max)); + if (rlimit.rlim_cur >= max_file_limit || + rlimit.rlim_cur == RLIM_INFINITY) + DBUG_RETURN(rlimit.rlim_cur); /* purecov: inspected */ + rlimit.rlim_cur= rlimit.rlim_max= max_file_limit; if (setrlimit(RLIMIT_NOFILE,&rlimit)) { if (global_system_variables.log_warnings) - sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %lu (request: %u)", + sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %u (request: %u)", old_cur, max_file_limit); /* purecov: inspected */ - max_file_limit=old_cur; + max_file_limit= old_cur; } else { + rlimit.rlim_cur= 0; // Safety if next call fails (void) getrlimit(RLIMIT_NOFILE,&rlimit); - if ((uint) rlimit.rlim_cur != max_file_limit && + DBUG_PRINT("info", ("rlim_cur: %u", (uint) rlimit.rlim_cur)); + if ((uint) rlimit.rlim_cur < max_file_limit && global_system_variables.log_warnings) - sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %ld (request: %u)", - (ulong) rlimit.rlim_cur, + sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %u (request: %u)", + (uint) rlimit.rlim_cur, max_file_limit); /* purecov: inspected */ - max_file_limit=rlimit.rlim_cur; + max_file_limit= (uint) rlimit.rlim_cur; } } - return max_file_limit; + DBUG_PRINT("exit",("max_file_limit: %u", max_file_limit)); + DBUG_RETURN(max_file_limit); } #endif + #ifdef OS2 static uint set_maximum_open_files(uint max_file_limit) { - LONG cbReqCount; - ULONG cbCurMaxFH, cbCurMaxFH0; - APIRET ulrc; + LONG cbReqCount; + ULONG cbCurMaxFH, cbCurMaxFH0; + APIRET ulrc; + DBUG_ENTER("set_maximum_open_files"); - // get current limit - cbReqCount = 0; - DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0); + // get current limit + cbReqCount = 0; + DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0); - // set new limit - cbReqCount = max_file_limit - cbCurMaxFH0; - ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH); - if (ulrc) { - sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d", - cbCurMaxFH0); - cbCurMaxFH = cbCurMaxFH0; - } + // set new limit + cbReqCount = max_file_limit - cbCurMaxFH0; + ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH); + if (ulrc) { + sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d", + cbCurMaxFH0); + cbCurMaxFH = cbCurMaxFH0; + } - return cbCurMaxFH; + DBUG_RETURN(cbCurMaxFH); } #endif + /* Return a bitfield from a string of substrings separated by ',' returns ~(ulong) 0 on error. diff --git a/vio/viosocket.c b/vio/viosocket.c index 31941a64102..9d5c7c0d890 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -249,8 +249,8 @@ my_bool vio_peer_addr(Vio * vio, char *buf, uint16 *port) } else { - size_socket addrLen = sizeof(struct sockaddr); - if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)), + size_socket addrLen = sizeof(vio->remote); + if (getpeername(vio->sd, (struct sockaddr *) (&vio->remote), &addrLen) != 0) { DBUG_PRINT("exit", ("getpeername gave error: %d", socket_errno)); From 3ed561d3cf3572b18ec201736aa2988dabc499b9 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Mon, 1 Dec 2003 18:24:09 +0100 Subject: [PATCH 87/89] Post-merge fixes. --- include/mysqld_error.h | 2 +- mysql-test/r/sp-error.result | 4 +- mysql-test/r/sp.result | 6 +-- mysql-test/r/variables.result | 2 +- mysql-test/t/sp-error.test | 82 +++++++++++++++++------------------ mysql-test/t/sp.test | 6 +-- sql/protocol_cursor.cc | 6 +-- sql/sql_union.cc | 4 +- sql/sql_yacc.yy | 2 +- 9 files changed, 57 insertions(+), 57 deletions(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 93f5e982736..6b2e5115a4e 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -302,7 +302,7 @@ #define ER_UNKNOWN_KEY_CACHE 1283 #define ER_WARN_HOSTNAME_WONT_WORK 1284 #define ER_SP_NO_RECURSIVE_CREATE 1285 -#define ER_SP_ALREADY_EXISTS 1285 +#define ER_SP_ALREADY_EXISTS 1286 #define ER_SP_DOES_NOT_EXIST 1287 #define ER_SP_DROP_FAILED 1288 #define ER_SP_STORE_FAILED 1289 diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 5f755592452..a1ac2a85b6e 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -35,7 +35,7 @@ call foo(); ERROR 42000: PROCEDURE foo does not exist drop procedure if exists foo; Warnings: -Warning 1286 PROCEDURE foo does not exist +Warning 1287 PROCEDURE foo does not exist show create procedure foo; ERROR 42000: PROCEDURE foo does not exist create procedure foo() @@ -71,7 +71,7 @@ declare y int; set x = y; end; Warnings: -Warning 1292 Referring to uninitialized variable y +Warning 1293 Referring to uninitialized variable y drop procedure foo; create procedure foo() begin diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index e8bc7b85e98..a419f4a0565 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -618,7 +618,7 @@ create procedure hndlr4() begin declare x int default 0; declare val int; # No default -declare continue handler for 1310 set x=1; +declare continue handler for sqlstate '02000' set x=1; select data into val from test.t3 where id='z' limit 1; # No hits insert into test.t3 values ('z', val); end; @@ -631,7 +631,7 @@ drop procedure hndlr4; create procedure cur1() begin declare done int default 0; -declare continue handler for 1310 set done = 1; +declare continue handler for sqlstate '02000' set done = 1; declare c cursor for select * from test.t2; declare a char(16); declare b int; @@ -658,7 +658,7 @@ create table t3 ( s char(16), i int ); create procedure cur2() begin declare done int default 0; -declare continue handler for 1310 set done = 1; +declare continue handler for sqlstate '02000' set done = 1; declare c1 cursor for select id,data from test.t1; declare c2 cursor for select i from test.t2; open c1; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 88f796f8c4e..3e7e6af7408 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -360,7 +360,7 @@ set sql_log_bin=1; set sql_log_off=1; set sql_log_update=1; Warnings: -Note 1296 The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored. +Note 1297 The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored. set sql_low_priority_updates=1; set sql_max_join_size=200; select @@sql_max_join_size,@@max_join_size; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 132a6b086c6..50a8b8c8768 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -32,18 +32,18 @@ create function func1() returns int return 42| # Can't create recursively ---error 1284 +--error 1285 create procedure foo() create procedure bar() set @x=3| ---error 1284 +--error 1285 create procedure foo() create function bar() returns double return 2.3| # Already exists ---error 1285 +--error 1286 create procedure proc1() set @x = 42| ---error 1285 +--error 1286 create function func1() returns int return 42| @@ -51,39 +51,39 @@ drop procedure proc1| drop function func1| # Does not exist ---error 1286 +--error 1287 alter procedure foo| ---error 1286 +--error 1287 alter function foo| ---error 1286 +--error 1287 drop procedure foo| ---error 1286 +--error 1287 drop function foo| ---error 1286 +--error 1287 call foo()| drop procedure if exists foo| ---error 1286 +--error 1287 show create procedure foo| # LEAVE/ITERATE with no match ---error 1289 +--error 1290 create procedure foo() foo: loop leave bar; end loop| ---error 1289 +--error 1290 create procedure foo() foo: loop iterate bar; end loop| ---error 1289 +--error 1290 create procedure foo() foo: begin iterate foo; end| # Redefining label ---error 1290 +--error 1291 create procedure foo() foo: loop foo: loop @@ -92,7 +92,7 @@ foo: loop end loop foo| # End label mismatch ---error 1291 +--error 1292 create procedure foo() foo: loop set @x=2; @@ -113,17 +113,17 @@ begin select name from mysql.proc; select type from mysql.proc; end| ---error 1293 +--error 1294 call foo()| drop procedure foo| # RETURN in FUNCTION only ---error 1294 +--error 1295 create procedure foo() return 42| # Doesn't allow queries in FUNCTIONs (for now :-( ) ---error 1295 +--error 1296 create function foo() returns int begin declare x int; @@ -137,19 +137,19 @@ create procedure p(x int) create function f(x int) returns int return x+42| ---error 1299 +--error 1300 call p()| ---error 1299 +--error 1300 call p(1, 2)| ---error 1299 +--error 1300 select f()| ---error 1299 +--error 1300 select f(1, 2)| drop procedure p| drop function f| ---error 1300 +--error 1301 create procedure p(val int, out res int) begin declare x int default 0; @@ -163,7 +163,7 @@ begin end if; end| ---error 1300 +--error 1301 create procedure p(val int, out res int) begin declare x int default 0; @@ -178,7 +178,7 @@ begin end if; end| ---error 1301 +--error 1302 create function f(val int) returns int begin declare x int; @@ -196,12 +196,12 @@ begin end if; end| ---error 1302 +--error 1303 select f(10)| drop function f| ---error 1303 +--error 1304 create procedure p() begin declare c cursor for insert into test.t1 values ("foo", 42); @@ -210,7 +210,7 @@ begin close c; end| ---error 1304 +--error 1305 create procedure p() begin declare x int; @@ -220,7 +220,7 @@ begin close c; end| ---error 1305 +--error 1306 create procedure p() begin declare c cursor for select * from test.t; @@ -242,7 +242,7 @@ begin open c; close c; end| ---error 1306 +--error 1307 call p()| drop procedure p| @@ -254,11 +254,11 @@ begin close c; close c; end| ---error 1307 +--error 1308 call p()| drop procedure p| ---error 1286 +--error 1287 alter procedure bar3 sql security invoker| --error 1059 alter procedure bar3 name @@ -272,7 +272,7 @@ drop table if exists t1| create table t1 (val int, x float)| insert into t1 values (42, 3.1), (19, 1.2)| ---error 1308 +--error 1309 create procedure p() begin declare c cursor for select * from t1; @@ -292,7 +292,7 @@ begin fetch c into x; close c; end| ---error 1309 +--error 1310 call p()| drop procedure p| @@ -307,34 +307,34 @@ begin fetch c into x, y, z; close c; end| ---error 1309 +--error 1310 call p()| drop procedure p| ---error 1311 +--error 1312 create procedure p(in x int, x char(10)) begin end| ---error 1311 +--error 1312 create function p(x int, x char(10)) begin end| ---error 1312 +--error 1313 create procedure p() begin declare x float; declare x int; end| ---error 1313 +--error 1314 create procedure p() begin declare c condition for 1064; declare c condition for 1065; end| ---error 1314 +--error 1315 create procedure p() begin declare c cursor for select * from t1; @@ -358,7 +358,7 @@ drop procedure bug1965| # # BUG#1966 # ---error 1308 +--error 1309 select 1 into a| diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index d8530b5130b..25657bd79e2 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -734,7 +734,7 @@ create procedure hndlr4() begin declare x int default 0; declare val int; # No default - declare continue handler for 1310 set x=1; + declare continue handler for sqlstate '02000' set x=1; select data into val from test.t3 where id='z' limit 1; # No hits @@ -753,7 +753,7 @@ drop procedure hndlr4| create procedure cur1() begin declare done int default 0; - declare continue handler for 1310 set done = 1; + declare continue handler for sqlstate '02000' set done = 1; declare c cursor for select * from test.t2; declare a char(16); declare b int; @@ -782,7 +782,7 @@ create table t3 ( s char(16), i int )| create procedure cur2() begin declare done int default 0; - declare continue handler for 1310 set done = 1; + declare continue handler for sqlstate '02000' set done = 1; declare c1 cursor for select id,data from test.t1; declare c2 cursor for select i from test.t2; diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index b9e9c14f361..749b66785d4 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -108,7 +108,7 @@ bool Protocol_cursor::write() data_tmp= (byte **)(new_record + 1); new_record->data= (char **)data_tmp; - to= (byte *)data + (field_count + 1)*sizeof(char *); + to= (byte *)data_tmp + (field_count + 1)*sizeof(char *); for (; cur_field < fields_end; ++cur_field, ++data_tmp) { @@ -123,7 +123,7 @@ bool Protocol_cursor::write() // TODO error signal send_error(thd, CR_MALFORMED_PACKET); return TRUE; } - *data= to; + *data_tmp= to; memcpy(to,(char*) cp,len); to[len]=0; to+=len+1; @@ -132,7 +132,7 @@ bool Protocol_cursor::write() cur_field->max_length=len; } } - *data= 0; + *data_tmp= 0; *prev_record= new_record; prev_record= &new_record->next; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 33204608fb1..25620229844 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -221,7 +221,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result) union_result->set_table(table); item_list.empty(); - thd_arg->lex.current_select= lex_select_save; + thd_arg->lex->current_select= lex_select_save; { Field **field; for (field= table->field; *field; field++) @@ -234,7 +234,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result) else first_select->braces= 0; // remove our changes - thd_arg->lex.current_select= lex_select_save; + thd_arg->lex->current_select= lex_select_save; DBUG_RETURN(res || thd_arg->is_fatal_error ? 1 : 0); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a4972231c29..cd08e702cd5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1777,7 +1777,7 @@ sp_case: { /* Simple case: = */ LEX_STRING ivar; - ivar.str= "_tmp_"; + ivar.str= (char *)"_tmp_"; ivar.length= 5; Item *var= (Item*) new Item_splocal(ivar, ctx->current_framesize()-1); From 441ad81b48475e57860a80daeaacddfd4e12dedb Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Mon, 1 Dec 2003 16:12:05 -0800 Subject: [PATCH 88/89] join_outer.result, null.result, null.test: Fixed inconsistency of values of used_tables_cache and const_item_cache for Item_func_isnull objects (bug #1990). item_cmpfunc.h: Fixed inconsistency of values of used_tables_cache and const_item_cache for Item_func_isnull objects (bug #1990). --- mysql-test/r/join_outer.result | 2 +- mysql-test/r/null.result | 11 +++++++++++ mysql-test/t/null.test | 11 +++++++++++ sql/item_cmpfunc.h | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 3a1f68fb6c1..165f1522378 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -91,7 +91,7 @@ grp a c id a c d NULL NULL NULL NULL NULL NULL explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index 9de9fdce2db..f4decd3b79e 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -142,3 +142,14 @@ a b c d 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 drop table t1; +create table t1 (a int not null, b int not null, index idx(a)); +insert into t1 values +(1,1), (2,2), (3,3), (4,4), (5,5), (6,6), +(7,7), (8,8), (9,9), (10,10), (11,11), (12,12); +explain select * from t1 where a between 2 and 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx idx 4 NULL 2 Using where +explain select * from t1 where a between 2 and 3 or b is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx idx 4 NULL 2 Using where +drop table t1; diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 0be755ba7ad..5fa8f8a7651 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -86,3 +86,14 @@ INSERT INTO t1 (d) values (null),(null); select * from t1; drop table t1; +# +# Test to check elimination of IS NULL predicate for a non-nullable attribute +# (bug #1990) +# +create table t1 (a int not null, b int not null, index idx(a)); +insert into t1 values + (1,1), (2,2), (3,3), (4,4), (5,5), (6,6), + (7,7), (8,8), (9,9), (10,10), (11,11), (12,12); +explain select * from t1 where a between 2 and 3; +explain select * from t1 where a between 2 and 3 or b is null; +drop table t1; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index dac7a2d43eb..3f7e77160a7 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -753,6 +753,7 @@ public: if (!args[0]->maybe_null) { used_tables_cache= 0; /* is always false */ + const_item_cache= 1; cached_value= (longlong) 0; } else From 37ad3d2f2d12ea011217bbbc753bcb151c0b8b7b Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Mon, 1 Dec 2003 16:15:25 -0800 Subject: [PATCH 89/89] index_merge.result: Fixed inconsistency of values of used_tables_cache and const_item_cache for Item_func_isnull objects (bug #1990). --- mysql-test/r/index_merge.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/index_merge.result b/mysql-test/r/index_merge.result index 63a0ebc4086..7de111549bb 100644 --- a/mysql-test/r/index_merge.result +++ b/mysql-test/r/index_merge.result @@ -76,13 +76,13 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 ALL i1,i2 NULL NULL NULL 1024 Using where explain select * from t0 where key2 = 45 or key1 is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 ALL i1,i2 NULL NULL NULL 1024 Using where +1 SIMPLE t0 range i1,i2 i2 4 NULL 1 Using where explain select * from t0 where key2=10 or key3=3 or key4 <=> null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 index_merge i2,i3,i4 i2,i3 4,4 NULL 2 Using where explain select * from t0 where key2=10 or key3=3 or key4 is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 ALL i2,i3,i4 NULL NULL NULL 1024 Using where +1 SIMPLE t0 index_merge i2,i3,i4 i2,i3 4,4 NULL 2 Using where explain select key1 from t0 where (key1 <=> null) or (key2 < 5) or (key3=10) or (key4 <=> null); id select_type table type possible_keys key key_len ref rows Extra