From 302c85cbb3cb282c50b424f6913b2a441035930a Mon Sep 17 00:00:00 2001 From: "sasha@asksasha.com" <> Date: Tue, 2 Aug 2005 15:13:56 -0600 Subject: [PATCH 01/20] Added a test case for BUG#10456 --- mysql-test/r/rpl_insert_select.result | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 mysql-test/r/rpl_insert_select.result diff --git a/mysql-test/r/rpl_insert_select.result b/mysql-test/r/rpl_insert_select.result new file mode 100644 index 00000000000..1aff39e0026 --- /dev/null +++ b/mysql-test/r/rpl_insert_select.result @@ -0,0 +1,17 @@ +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; +start slave; +create table t1 (n int not null primary key); +insert into t1 values (1); +create table t2 (n int); +insert into t2 values (1); +insert ignore into t1 select * from t2; +insert into t1 values (2); +select * from t1; +n +1 +2 +drop table t1,t2; From bb76e143a3b151572a55ef702b1c72a45a0b73f4 Mon Sep 17 00:00:00 2001 From: "sasha@asksasha.com" <> Date: Tue, 2 Aug 2005 15:15:28 -0600 Subject: [PATCH 02/20] The earlier commit for BUG#10456 did not add the test file --- mysql-test/t/rpl_insert_select.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 mysql-test/t/rpl_insert_select.test diff --git a/mysql-test/t/rpl_insert_select.test b/mysql-test/t/rpl_insert_select.test new file mode 100644 index 00000000000..677be526982 --- /dev/null +++ b/mysql-test/t/rpl_insert_select.test @@ -0,0 +1,19 @@ +# Testcase for BUG#10456 - INSERT INTO ... SELECT violating a primary key +# breaks replication + +-- source include/master-slave.inc +connection master; + +create table t1 (n int not null primary key); +insert into t1 values (1); +create table t2 (n int); +insert into t2 values (1); +insert ignore into t1 select * from t2; +insert into t1 values (2); +sync_slave_with_master; +connection slave; +select * from t1; + +connection master; +drop table t1,t2; +sync_slave_with_master; From c44fe70d02163125ecc2a16e798fcea7cb073651 Mon Sep 17 00:00:00 2001 From: "sasha@asksasha.com" <> Date: Wed, 3 Aug 2005 18:08:20 -0600 Subject: [PATCH 03/20] patch for BUG#4680 - drop database breaking replication if there were extra files in the database directory on the master --- mysql-test/r/rpl_drop_db.result | 30 ++++++++++++++++++++++ mysql-test/t/rpl_drop_db.test | 39 ++++++++++++++++++++++++++++ sql/mysql_priv.h | 2 +- sql/sql_db.cc | 45 +++++++++++++++++++++++++++++---- sql/sql_table.cc | 20 ++++++++++++++- 5 files changed, 129 insertions(+), 7 deletions(-) create mode 100644 mysql-test/r/rpl_drop_db.result create mode 100644 mysql-test/t/rpl_drop_db.test diff --git a/mysql-test/r/rpl_drop_db.result b/mysql-test/r/rpl_drop_db.result new file mode 100644 index 00000000000..bafbfe3a1ed --- /dev/null +++ b/mysql-test/r/rpl_drop_db.result @@ -0,0 +1,30 @@ +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; +start slave; +drop database if exists d1; +create database d1; +create table d1.t1 (n int); +insert into d1.t1 values (1); +select * from d1.t1 into outfile 'd1/f1.txt'; +create table d1.t2 (n int); +create table d1.t3 (n int); +drop database d1; +ERROR HY000: Error dropping database (can't rmdir './d1/', errno: 17) +use d1; +show tables; +Tables_in_d1 +use test; +create table t1 (n int); +insert into t1 values (1234); +use d1; +show tables; +Tables_in_d1 +use test; +select * from t1; +n +1234 +drop table t1; +stop slave; diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test new file mode 100644 index 00000000000..ef0ab4be6fd --- /dev/null +++ b/mysql-test/t/rpl_drop_db.test @@ -0,0 +1,39 @@ +# test case for BUG#4680 -- if there are extra files in the db directory +# dropping the db on the master causes replication problems + +-- source include/master-slave.inc +connection master; + +--disable_warnings +drop database if exists d1; +--enable_warnings +create database d1; +create table d1.t1 (n int); +insert into d1.t1 values (1); +select * from d1.t1 into outfile 'd1/f1.txt'; +create table d1.t2 (n int); +create table d1.t3 (n int); +--error 1010 +drop database d1; +use d1; +show tables; +use test; +create table t1 (n int); +insert into t1 values (1234); +sync_slave_with_master; + +connection slave; +use d1; +show tables; +use test; +select * from t1; + +connection master; +drop table t1; +sync_slave_with_master; + +#cleanup +connection slave; +stop slave; +system rm -rf var/master-data/d1; + diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6969433649f..9d46cc507df 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -441,7 +441,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, bool drop_temporary, bool log_query); int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables, bool if_exists, bool drop_temporary, - bool log_query); + bool log_query, List *dropped_tables); int quick_rm_table(enum db_type base,const char *db, const char *table_name); bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index ad6845572e1..0155fca0466 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -31,7 +31,7 @@ static TYPELIB deletable_extentions= static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, const char *path, - uint level); + uint level, List *dropped_tables); /* Database options hash */ static HASH dboptions; @@ -584,6 +584,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) int error= 0; char path[FN_REFLEN+16], tmp_db[NAME_LEN+1]; MY_DIR *dirp; + List dropped_tables; uint length; DBUG_ENTER("mysql_rm_db"); @@ -621,8 +622,10 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) remove_db_from_cache(db); pthread_mutex_unlock(&LOCK_open); + error= -1; - if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0)) >= 0) + if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0, + &dropped_tables)) >= 0) { ha_drop_database(path); query_cache_invalidate1(db); @@ -672,6 +675,37 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) send_ok(thd, (ulong) deleted); thd->server_status&= ~SERVER_STATUS_DB_DROPPED; } + else if (!dropped_tables.is_empty() && mysql_bin_log.is_open()) + { + List_iterator it(dropped_tables); + String* dropped_table; + int q_len= 11; /* drop table */ + int db_len= strlen(db); + + for (;(dropped_table= it++);) + { + q_len += dropped_table->length() + 2 + db_len; + } + q_len--; /* no last comma */ + + char* query= thd->alloc(q_len); + if (!query) + goto exit; /* not much else we can do */ + char* p= strmov(query,"drop table "); + it.rewind(); + + for (;(dropped_table= it++);) + { + p= strmov(p,db); + *p++ = '.'; + p= strnmov(p,dropped_table->ptr(),dropped_table->length()); + *p++ = ','; + } + *--p= 0; + Query_log_event qinfo(thd, query, q_len, 0, 0); + qinfo.error_code= 0; + mysql_bin_log.write(&qinfo); + } exit: start_waiting_global_read_lock(thd); @@ -716,7 +750,7 @@ exit2: */ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, - const char *org_path, uint level) + const char *org_path, uint level, List *dropped_tables) { long deleted=0; ulong found_other_files=0; @@ -758,7 +792,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, if ((new_dirp = my_dir(newpath,MYF(MY_DONT_SORT)))) { DBUG_PRINT("my",("New subdir found: %s", newpath)); - if ((mysql_rm_known_files(thd, new_dirp, NullS, newpath,1)) < 0) + if ((mysql_rm_known_files(thd, new_dirp, NullS, newpath,1,0)) < 0) goto err; if (!(copy_of_path= thd->memdup(newpath, length+1)) || !(dir= new (thd->mem_root) String(copy_of_path, length, @@ -805,7 +839,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, } } if (thd->killed || - (tot_list && mysql_rm_table_part2_with_lock(thd, tot_list, 1, 0, 1))) + (tot_list && mysql_rm_table_part2_with_lock(thd, tot_list, 1, 0, + 1,dropped_tables))) goto err; /* Remove RAID directories */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 87b864c73fa..e948a65f301 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -156,7 +156,8 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables, bool if_exists, - bool drop_temporary, bool dont_log_query) + bool drop_temporary, bool dont_log_query, + List* dropped_tables) { int error; thd->mysys_var->current_mutex= &LOCK_open; @@ -165,6 +166,23 @@ int mysql_rm_table_part2_with_lock(THD *thd, error=mysql_rm_table_part2(thd,tables, if_exists, drop_temporary, dont_log_query); + /* + For now we assume that if we got success all the tables in the list + were actually dropped, otherwise, assume none were dropped. + TODO: fix it to work with a partial drop - extremely rare case, but + can happen. + */ + if (!error && dropped_tables) + { + TABLE_LIST* tbl; + + for (tbl= tables; tbl; tbl= tbl->next) + { + String *dropped_table= new (thd->mem_root) + String(tbl->real_name,&my_charset_latin1); + dropped_tables->push_back(dropped_table); + } + } pthread_mutex_unlock(&LOCK_open); From ecf4068fff22203cf82932569bcd7298ac9a53c3 Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Wed, 17 Aug 2005 15:11:29 +0200 Subject: [PATCH 04/20] No C++ style comments in C source! --- mysys/charset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/charset.c b/mysys/charset.c index df3f1cfa279..5aaac7a178f 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -679,5 +679,5 @@ char *bare_str_to_hex(char *to, const char *from, uint len) p[1]= _dig_vec_upper[tmp & 15]; } *p= 0; - return p; // pointer to end 0 of 'to' + return p; /* pointer to end 0 of 'to' */ } From 6d8bd17c3a8d11ad5404c4d80723fc0cb8a8496b Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Wed, 17 Aug 2005 23:53:12 +0400 Subject: [PATCH 05/20] Fix bug #11718 query with function, join and order by returns wrong type. create_tmp_field_from_item() was creating tmp field without regard to original field type of Item. This results in wrong type being reported to client. To create_tmp_field_from_item() added special handling for Items with DATE/TIME field types to preserve their type. --- sql/sql_select.cc | 10 +++++++++- tests/mysql_client_test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9984cb4138f..73cfe153b9b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4899,7 +4899,15 @@ static Field* create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, item->name, table, item->unsigned_flag); break; case STRING_RESULT: - if (item->max_length > 255) + enum enum_field_types type; + /* + DATE/TIME fields have STRING_RESULT result type. To preserve + type they needed to be handled separately. + */ + if ((type= item->field_type()) == MYSQL_TYPE_DATETIME || + type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE) + new_field= item->tmp_table_field_from_field_type(table); + else if (item->max_length > 255) { if (convert_blob_length) new_field= new Field_varstring(convert_blob_length, maybe_null, diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 37d6d951f96..64c5e7edaf9 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -11796,6 +11796,40 @@ static void test_bug12001() DIE_UNLESS(res==1); } +/* + Bug#11718: query with function, join and order by returns wrong type +*/ + +static void test_bug11718() +{ + MYSQL_RES *res; + int rc; + const char *query= "select str_to_date(concat(f3),'%Y%m%d') from t1,t2 " + "where f1=f2 order by f1"; + + myheader("test_bug11718"); + + rc= mysql_query(mysql, "drop table if exists t1, t2"); + myquery(rc); + rc= mysql_query(mysql, "create table t1 (f1 int)"); + myquery(rc); + rc= mysql_query(mysql, "create table t2 (f2 int, f3 numeric(8))"); + myquery(rc); + rc= mysql_query(mysql, "insert into t1 values (1), (2)"); + myquery(rc); + rc= mysql_query(mysql, "insert into t2 values (1,20050101), (2,20050202)"); + myquery(rc); + rc= mysql_query(mysql, query); + myquery(rc); + res = mysql_store_result(mysql); + + if (!opt_silent) + printf("return type: %s", (res->fields[0].type == MYSQL_TYPE_DATE)?"DATE": + "not DATE"); + DIE_UNLESS(res->fields[0].type == MYSQL_TYPE_DATE); + rc= mysql_query(mysql, "drop table t1, t2"); + myquery(rc); +} /* Read and parse arguments and MySQL options from my.cnf */ @@ -12013,6 +12047,7 @@ static struct my_tests_st my_tests[]= { { "test_bug9735", test_bug9735 }, { "test_bug11183", test_bug11183 }, { "test_bug12001", test_bug12001 }, + { "test_bug11718", test_bug11718 }, { 0, 0 } }; From 1dddccb8e9f38a498d5ed586aab49d5cba952f16 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Wed, 17 Aug 2005 23:47:03 +0200 Subject: [PATCH 06/20] mtr_process.pl: Longer shutdown timeout, slave may be in reconnect HUP seem to disturb exit(), added sleep to make sure output is flushed --- mysql-test/lib/mtr_process.pl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 1f18968031c..fb37296971e 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -331,7 +331,7 @@ sub mtr_kill_leftovers () { }); } - mtr_mysqladmin_shutdown(\@args); + mtr_mysqladmin_shutdown(\@args, 20); # We now have tried to terminate nice. We have waited for the listen # port to be free, but can't really tell if the mysqld process died @@ -441,7 +441,8 @@ sub mtr_stop_mysqld_servers ($) { # First try nice normal shutdown using 'mysqladmin' # ---------------------------------------------------------------------- - mtr_mysqladmin_shutdown($spec); + # Shutdown time must be high as slave may be in reconnect + mtr_mysqladmin_shutdown($spec, 70); # ---------------------------------------------------------------------- # We loop with waitpid() nonblocking to see how many of the ones we @@ -591,8 +592,9 @@ sub mtr_stop_mysqld_servers ($) { # ############################################################################## -sub mtr_mysqladmin_shutdown () { +sub mtr_mysqladmin_shutdown { my $spec= shift; + my $adm_shutdown_tmo= shift; my %mysql_admin_pids; my @to_kill_specs; @@ -631,7 +633,7 @@ sub mtr_mysqladmin_shutdown () { mtr_add_arg($args, "--protocol=tcp"); # Needed if no --socket } mtr_add_arg($args, "--connect_timeout=5"); - mtr_add_arg($args, "--shutdown_timeout=20"); + mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo"); mtr_add_arg($args, "shutdown"); # We don't wait for termination of mysqladmin my $pid= mtr_spawn($::exe_mysqladmin, $args, @@ -808,11 +810,15 @@ sub sleep_until_file_created ($$$) { # FIXME something is wrong, we sometimes terminate with "Hangup" written # to tty, and no STDERR output telling us why. +# FIXME for some readon, setting HUP to 'IGNORE' will cause exit() to +# write out "Hangup", and maybe loose some output. We insert a sleep... + sub mtr_exit ($) { my $code= shift; # cluck("Called mtr_exit()"); local $SIG{HUP} = 'IGNORE'; kill('HUP', -$$); + sleep 2; exit($code); } From adb94df2962a05d0b04dc5a2919244e89b4195f8 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Thu, 18 Aug 2005 00:07:17 +0200 Subject: [PATCH 07/20] mtr_process.pl: Bug#11792: Create a shell like 'mysqltest' exit status --- mysql-test/lib/mtr_process.pl | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index fb37296971e..ec12bc3907c 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -185,10 +185,6 @@ sub spawn_parent_impl { if ( $mode eq 'run' or $mode eq 'test' ) { - my $exit_value= -1; -# my $signal_num= 0; -# my $dumped_core= 0; - if ( $mode eq 'run' ) { # Simple run of command, we wait for it to return @@ -199,12 +195,7 @@ sub spawn_parent_impl { mtr_error("$path ($pid) got lost somehow"); } - $exit_value= $?; -# $exit_value= $? >> 8; -# $signal_num= $? & 127; -# $dumped_core= $? & 128; - - return $exit_value; + return mtr_process_exit_status($?); } else { @@ -218,6 +209,7 @@ sub spawn_parent_impl { # FIXME is this as it should be? Can't mysqld terminate # normally from running a test case? + my $exit_value= -1; my $ret_pid; # What waitpid() returns while ( ($ret_pid= waitpid(-1,0)) != -1 ) @@ -230,10 +222,7 @@ sub spawn_parent_impl { if ( $ret_pid == $pid ) { # We got termination of mysqltest, we are done - $exit_value= $?; -# $exit_value= $? >> 8; -# $signal_num= $? & 127; -# $dumped_core= $? & 128; + $exit_value= mtr_process_exit_status($?); last; } @@ -292,6 +281,23 @@ sub spawn_parent_impl { } +# ---------------------------------------------------------------------- +# We try to emulate how an Unix shell calculates the exit code +# ---------------------------------------------------------------------- + +sub mtr_process_exit_status { + my $raw_status= shift; + + if ( $raw_status & 127 ) + { + return ($raw_status & 127) + 128; # Signal num + 128 + } + else + { + return $raw_status >> 8; # Exit code + } +} + ############################################################################## # From 1476a524332334e5634a1af4aaabc67a4231aecf Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Thu, 18 Aug 2005 00:16:44 +0200 Subject: [PATCH 08/20] mtr_timer.pl, mysql-test-run.pl, mtr_report.pl, mtr_process.pl: Added suite and test case timeout mtr_timer.pl: new file --- mysql-test/lib/mtr_process.pl | 21 +++++- mysql-test/lib/mtr_report.pl | 9 ++- mysql-test/lib/mtr_timer.pl | 127 ++++++++++++++++++++++++++++++++++ mysql-test/mysql-test-run.pl | 28 +++++++- 4 files changed, 180 insertions(+), 5 deletions(-) create mode 100644 mysql-test/lib/mtr_timer.pl diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index ec12bc3907c..c9ae92305c2 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -210,6 +210,7 @@ sub spawn_parent_impl { # normally from running a test case? my $exit_value= -1; + my $saved_exit_value; my $ret_pid; # What waitpid() returns while ( ($ret_pid= waitpid(-1,0)) != -1 ) @@ -219,6 +220,24 @@ sub spawn_parent_impl { # but not $exit_value, this is flagged from # + my $timer_name= mtr_timer_timeout($::glob_timers, $ret_pid); + if ( $timer_name ) + { + if ( $timer_name eq "suite" ) + { + # We give up here + # FIXME we should only give up the suite, not all of the run? + print STDERR "\n"; + mtr_error("Test suite timeout"); + } + elsif ( $timer_name eq "testcase" ) + { + $saved_exit_value= 63; # Mark as timeout + kill(9, $pid); # Kill mysqltest + next; # Go on and catch the termination + } + } + if ( $ret_pid == $pid ) { # We got termination of mysqltest, we are done @@ -270,7 +289,7 @@ sub spawn_parent_impl { } } - return $exit_value; + return $saved_exit_value || $exit_value; } } else diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index b9dab6b8d32..5e1a8308505 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -109,7 +109,14 @@ sub mtr_report_test_failed ($) { my $tinfo= shift; $tinfo->{'result'}= 'MTR_RES_FAILED'; - print "[ fail ]\n"; + if ( $tinfo->{'timeout'} ) + { + print "[ fail ] timeout\n"; + } + else + { + print "[ fail ]\n"; + } # FIXME Instead of this test, and meaningless error message in 'else' # we should write out into $::path_timefile when the error occurs. diff --git a/mysql-test/lib/mtr_timer.pl b/mysql-test/lib/mtr_timer.pl new file mode 100644 index 00000000000..aab57d1bc52 --- /dev/null +++ b/mysql-test/lib/mtr_timer.pl @@ -0,0 +1,127 @@ +# -*- cperl -*- + +# This is a library file used by the Perl version of mysql-test-run, +# and is part of the translation of the Bourne shell script with the +# same name. + +use Carp qw(cluck); +use Socket; +use Errno; +use strict; + +#use POSIX ":sys_wait_h"; +use POSIX 'WNOHANG'; + +sub mtr_init_timers (); +sub mtr_timer_start($$$); +sub mtr_timer_stop($$); +sub mtr_timer_waitpid($$$); + +############################################################################## +# +# Initiate a structure shared by all timers +# +############################################################################## + +sub mtr_init_timers () { + my $timers = { timers => {}, pids => {}}; + return $timers; +} + + +############################################################################## +# +# Start, stop and poll a timer +# +# As alarm() isn't portable to Windows, we use separate processes to +# implement timers. That is why there is a mtr_timer_waitpid(), as this +# is where we catch a timeout. +# +############################################################################## + +sub mtr_timer_start($$$) { + my ($timers,$name,$duration)= @_; + + if ( exists $timers->{'timers'}->{$name} ) + { + # We have an old running timer, kill it + mtr_timer_stop($timers,$name); + } + + FORK: + { + my $tpid= fork(); + + if ( ! defined $tpid ) + { + if ( $! == $!{EAGAIN} ) # See "perldoc Errno" + { + mtr_debug("Got EAGAIN from fork(), sleep 1 second and redo"); + sleep(1); + redo FORK; + } + else + { + mtr_error("can't fork"); + } + } + + if ( $tpid ) + { + # Parent, record the information + $timers->{'timers'}->{$name}->{'pid'}= $tpid; + $timers->{'timers'}->{$name}->{'duration'}= $duration; + $timers->{'pids'}->{$tpid}= $name; + } + else + { + # Child, redirect output and exec + # FIXME do we need to redirect streams? + $0= "mtr_timer(timers,$name,$duration)"; + sleep($duration); + exit(0); + } + } +} + + +sub mtr_timer_stop ($$) { + my ($timers,$name)= @_; + + if ( exists $timers->{'timers'}->{$name} ) + { + my $tpid= $timers->{'timers'}->{$name}->{'pid'}; + + # FIXME as Cygwin reuses pids fast, maybe check that is + # the expected process somehow?! + kill(9, $tpid); + + # As the timers are so simple programs, we trust them to terminate, + # and use blocking wait for it. We wait just to avoid a zombie. + waitpid($tpid,0); + + delete $timers->{'timers'}->{$name}; # Remove the timer information + delete $timers->{'pids'}->{$tpid}; # and PID reference + + return 1; + } + else + { + mtr_debug("Asked to stop timer \"$name\" not started"); + return 0; + } +} + + +sub mtr_timer_timeout ($$) { + my ($timers,$pid)= @_; + + return "" unless exists $timers->{'pids'}->{$pid}; + + # We got a timeout + my $name= $timers->{'pids'}->{$pid}; + mtr_timer_stop($timers, $timers->{'timers'}->{$name}); + return $name; +} + +1; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index f3e42ecf755..456f481ce86 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -90,6 +90,7 @@ use strict; require "lib/mtr_cases.pl"; require "lib/mtr_process.pl"; +require "lib/mtr_timer.pl"; require "lib/mtr_io.pl"; require "lib/mtr_gcov.pl"; require "lib/mtr_gprof.pl"; @@ -137,6 +138,7 @@ our $glob_mysql_test_dir= undef; our $glob_mysql_bench_dir= undef; our $glob_hostname= undef; our $glob_scriptname= undef; +our $glob_timers= undef; our $glob_use_running_server= 0; our $glob_use_running_ndbcluster= 0; our $glob_use_embedded_server= 0; @@ -232,8 +234,10 @@ our $opt_skip_test; our $opt_sleep; our $opt_ps_protocol; -our $opt_sleep_time_after_restart= 1; +our $opt_sleep_time_after_restart= 1; our $opt_sleep_time_for_delete= 10; +our $opt_testcase_timeout= 5; # 5 min max +our $opt_suite_timeout= 120; # 2 hours max our $opt_socket; @@ -435,6 +439,8 @@ sub initial_setup () { $path_my_basedir= $opt_source_dist ? $glob_mysql_test_dir : $glob_basedir; + + $glob_timers= mtr_init_timers(); } @@ -530,6 +536,8 @@ sub command_line_setup () { 'vardir=s' => \$opt_vardir, 'verbose' => \$opt_verbose, 'wait-timeout=i' => \$opt_wait_timeout, + 'testcase-timeout=i' => \$opt_testcase_timeout, + 'suite-timeout=i' => \$opt_suite_timeout, 'warnings|log-warnings' => \$opt_warnings, 'with-openssl' => \$opt_with_openssl, @@ -1197,6 +1205,8 @@ sub run_suite () { mtr_report("Finding Tests in the '$suite' suite"); + mtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout); + my $tests= collect_test_cases($suite); mtr_report("Starting Tests in the '$suite' suite"); @@ -1205,7 +1215,9 @@ sub run_suite () { foreach my $tinfo ( @$tests ) { + mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout); run_testcase($tinfo); + mtr_timer_stop($glob_timers,"testcase"); } mtr_print_line(); @@ -1226,6 +1238,8 @@ sub run_suite () { } mtr_report_stats($tests); + + mtr_timer_stop($glob_timers,"suite"); } @@ -1523,6 +1537,11 @@ sub run_testcase ($) { # Testcase itself tell us to skip this one mtr_report_test_skipped($tinfo); } + elsif ( $res == 63 ) + { + $tinfo->{'timeout'}= 1; # Mark as timeout + report_failure_and_restart($tinfo); + } else { # Test case failed, if in control mysqltest returns 1 @@ -1657,8 +1676,6 @@ sub mysqld_arguments ($$$$$) { my $extra_opt= shift; my $slave_master_info= shift; -# print STDERR Dumper($extra_opt); - my $sidx= ""; # Index as string, 0 is empty string if ( $idx > 0 ) { @@ -2262,6 +2279,10 @@ Misc options help Get this help text unified-diff | udiff When presenting differences, use unified diff + testcase-timeout=MINUTES Max test case run time (default 5) + suite-timeout=MINUTES Max test suite run time (default 120) + + Options not yet described, or that I want to look into more big-test @@ -2281,4 +2302,5 @@ Options not yet described, or that I want to look into more HERE mtr_exit(1); + } From 79339063254e2166bc1ed6470e0851fe5c3011a8 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Thu, 18 Aug 2005 17:29:24 +0200 Subject: [PATCH 09/20] mysqld.dsp: Added archive and example storage engine to Windows build ha_example.cc, ha_archive.cc: Windows fix, use relative include path to "mysql_priv.h" ha_archive.h: Windows VC6 compile needed (char*) cast of byte var mysqltest.dsp, mysql_test_run_new.dsp: Added /FD flag, to avoid include file warnings --- VC++Files/client/mysqltest.dsp | 12 +++++------ VC++Files/mysql-test/mysql_test_run_new.dsp | 8 ++++---- VC++Files/sql/mysqld.dsp | 22 ++++++++++++++------- sql/examples/ha_archive.cc | 2 +- sql/examples/ha_archive.h | 2 +- sql/examples/ha_example.cc | 2 +- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/VC++Files/client/mysqltest.dsp b/VC++Files/client/mysqltest.dsp index e705b17b0f0..1c636c4d078 100644 --- a/VC++Files/client/mysqltest.dsp +++ b/VC++Files/client/mysqltest.dsp @@ -42,8 +42,8 @@ RSC=rc.exe # PROP Output_Dir ".\debug" # PROP Intermediate_Dir ".\debug" # PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /I "../include" /I "../regex" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_WINDOWS" /D "_MBCS" /Fp".\debug/mysqltest.pch" /Fo".\debug/" /Fd".\debug/" /GZ /c /GX -# ADD CPP /nologo /MTd /I "../include" /I "../regex" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_WINDOWS" /D "_MBCS" /Fp".\debug/mysqltest.pch" /Fo".\debug/" /Fd".\debug/" /GZ /c /GX +# ADD BASE CPP /nologo /MTd /I "../include" /I "../regex" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_WINDOWS" /D "_MBCS" /Fp".\debug/mysqltest.pch" /Fo".\debug/" /Fd".\debug/" /GZ /FD /c /GX +# ADD CPP /nologo /MTd /I "../include" /I "../regex" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_WINDOWS" /D "_MBCS" /Fp".\debug/mysqltest.pch" /Fo".\debug/" /Fd".\debug/" /GZ /FD /c /GX # ADD BASE MTL /nologo /tlb".\debug\mysqltest.tlb" /win32 # ADD MTL /nologo /tlb".\debug\mysqltest.tlb" /win32 # ADD BASE RSC /l 1033 /d "_DEBUG" @@ -67,8 +67,8 @@ LINK32=link.exe # PROP Output_Dir ".\classic" # PROP Intermediate_Dir ".\classic" # PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "_CONSOLE" /D "_WINDOWS" /D "LICENSE=Commercial" /D "DBUG_OFF" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\classic/mysqltest.pch" /Fo".\classic/" /Fd".\classic/" /c /GX -# ADD CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "_CONSOLE" /D "_WINDOWS" /D "LICENSE=Commercial" /D "DBUG_OFF" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\classic/mysqltest.pch" /Fo".\classic/" /Fd".\classic/" /c /GX +# ADD BASE CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "_CONSOLE" /D "_WINDOWS" /D "LICENSE=Commercial" /D "DBUG_OFF" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\classic/mysqltest.pch" /Fo".\classic/" /Fd".\classic/" /FD /c /GX +# ADD CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "_CONSOLE" /D "_WINDOWS" /D "LICENSE=Commercial" /D "DBUG_OFF" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\classic/mysqltest.pch" /Fo".\classic/" /Fd".\classic/" /FD /c /GX # ADD BASE MTL /nologo /tlb".\classic\mysqltest.tlb" /win32 # ADD MTL /nologo /tlb".\classic\mysqltest.tlb" /win32 # ADD BASE RSC /l 1033 /d "NDEBUG" @@ -92,8 +92,8 @@ LINK32=link.exe # PROP Output_Dir ".\release" # PROP Intermediate_Dir ".\release" # PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_CONSOLE" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\release/mysqltest.pch" /Fo".\release/" /Fd".\release/" /c /GX -# ADD CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_CONSOLE" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\release/mysqltest.pch" /Fo".\release/" /Fd".\release/" /c /GX +# ADD BASE CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_CONSOLE" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\release/mysqltest.pch" /Fo".\release/" /Fd".\release/" /FD /c /GX +# ADD CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_CONSOLE" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\release/mysqltest.pch" /Fo".\release/" /Fd".\release/" /FD /c /GX # ADD BASE MTL /nologo /tlb".\release\mysqltest.tlb" /win32 # ADD MTL /nologo /tlb".\release\mysqltest.tlb" /win32 # ADD BASE RSC /l 1033 /d "NDEBUG" diff --git a/VC++Files/mysql-test/mysql_test_run_new.dsp b/VC++Files/mysql-test/mysql_test_run_new.dsp index 467ff939502..5ff07f0994d 100644 --- a/VC++Files/mysql-test/mysql_test_run_new.dsp +++ b/VC++Files/mysql-test/mysql_test_run_new.dsp @@ -41,8 +41,8 @@ RSC=rc.exe # PROP Output_Dir ".\Debug" # PROP Intermediate_Dir ".\Debug" # PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /I "../include" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /Fp".\Debug/mysql_test_run_new.pch" /Fo".\Debug/" /Fd".\Debug/" /GZ /c /GX -# ADD CPP /nologo /MTd /I "../include" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /Fp".\Debug/mysql_test_run_new.pch" /Fo".\Debug/" /Fd".\Debug/" /GZ /c /GX +# ADD BASE CPP /nologo /MTd /I "../include" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /Fp".\Debug/mysql_test_run_new.pch" /Fo".\Debug/" /Fd".\Debug/" /GZ /FD /c /GX +# ADD CPP /nologo /MTd /I "../include" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /Fp".\Debug/mysql_test_run_new.pch" /Fo".\Debug/" /Fd".\Debug/" /GZ /FD /c /GX # ADD BASE MTL /nologo /tlb".\Debug\mysql_test_run_new.tlb" /win32 # ADD MTL /nologo /tlb".\Debug\mysql_test_run_new.tlb" /win32 # ADD BASE RSC /l 1033 @@ -66,8 +66,8 @@ LINK32=link.exe # PROP Output_Dir ".\Release" # PROP Intermediate_Dir ".\Release" # PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/mysql_test_run_new.pch" /Fo".\Release/" /Fd".\Release/" /c /GX -# ADD CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/mysql_test_run_new.pch" /Fo".\Release/" /Fd".\Release/" /c /GX +# ADD BASE CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/mysql_test_run_new.pch" /Fo".\Release/" /Fd".\Release/" /FD /c /GX +# ADD CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/mysql_test_run_new.pch" /Fo".\Release/" /Fd".\Release/" /FD /c /GX # ADD BASE MTL /nologo /tlb".\Release\mysql_test_run_new.tlb" /win32 # ADD MTL /nologo /tlb".\Release\mysql_test_run_new.tlb" /win32 # ADD BASE RSC /l 1033 diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index 6a33889da53..4034ac9f5d0 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -49,7 +49,7 @@ 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 "../zlib" /I "../include" /I "../regex" /D "NDEBUG" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../zlib" /I "../include" /I "../regex" /D "NDEBUG" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "HAVE_ARCHIVE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -75,7 +75,7 @@ LINK32=xilink6.exe # PROP Ignore_Export_Lib 0 # 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 "../bdb/build_win32" /I "../include" /I "../regex" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "HAVE_ARCHIVE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_EXAMPLE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c # SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" @@ -102,7 +102,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G5 /MT /W3 /O2 /I "../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__WIN32__" /D "DBUG_OFF" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "HAVE_INNOBASE_DB" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-nt /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "HAVE_INNOBASE_DB" /D "HAVE_ARCHIVE_DB" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-nt /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -130,7 +130,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../zlib" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-nt-max /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../zlib" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "HAVE_ARCHIVE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_EXAMPLE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-nt-max /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -159,7 +159,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /D "NDEBUG" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../zlib" /D "NDEBUG" /D "DBUG_OFF" /D "USE_SYMDIR" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-max /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../zlib" /D "NDEBUG" /D "DBUG_OFF" /D "USE_SYMDIR" /D "HAVE_INNOBASE_DB" /D "HAVE_ARCHIVE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_EXAMPLE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-max /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -215,7 +215,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "USE_SYMDIR" /D "HAVE_DLOPEN" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "MYSQL_SERVER" /D LICENSE=Commercial /D "_MBCS" /D "HAVE_DLOPEN" /D "HAVE_INNOBASE_DB" /D "DBUG_OFF" /D "NDEBUG" /D "_WINDOWS" /D "_CONSOLE" /D MYSQL_SERVER_SUFFIX=-pro /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "MYSQL_SERVER" /D LICENSE=Commercial /D "_MBCS" /D "HAVE_DLOPEN" /D "HAVE_INNOBASE_DB" /D "HAVE_ARCHIVE_DB" /D "DBUG_OFF" /D "NDEBUG" /D "_WINDOWS" /D "_CONSOLE" /D MYSQL_SERVER_SUFFIX=-pro /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -272,7 +272,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "USE_SYMDIR" /D "HAVE_DLOPEN" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D LICENSE=Commercial /D "NDEBUG" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-pro-nt /FD +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "HAVE_ARCHIVE_DB" /D LICENSE=Commercial /D "NDEBUG" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-pro-nt /FD # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -451,6 +451,14 @@ SOURCE=.\gstream.cpp # End Source File # Begin Source File +SOURCE=.\examples\ha_archive.cpp +# End Source File +# Begin Source File + +SOURCE=.\examples\ha_example.cpp +# End Source File +# Begin Source File + SOURCE=.\ha_blackhole.cpp # End Source File # Begin Source File diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index 10712c2e3be..b125f435cfa 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -18,7 +18,7 @@ #pragma implementation // gcc: Class implementation #endif -#include +#include "../mysql_priv.h" #ifdef HAVE_ARCHIVE_DB #include "ha_archive.h" diff --git a/sql/examples/ha_archive.h b/sql/examples/ha_archive.h index 7ab463b6661..52300fda8a2 100644 --- a/sql/examples/ha_archive.h +++ b/sql/examples/ha_archive.h @@ -58,7 +58,7 @@ public: ha_archive(TABLE *table): handler(table) { /* Set our original buffer from pre-allocated memory */ - buffer.set(byte_buffer, IO_SIZE, system_charset_info); + buffer.set((char*)byte_buffer, IO_SIZE, system_charset_info); /* The size of the offset value we will use for position() */ ref_length = sizeof(z_off_t); diff --git a/sql/examples/ha_example.cc b/sql/examples/ha_example.cc index 31e4e97c5c7..b3edce5ba4a 100644 --- a/sql/examples/ha_example.cc +++ b/sql/examples/ha_example.cc @@ -67,7 +67,7 @@ #pragma implementation // gcc: Class implementation #endif -#include +#include "../mysql_priv.h" #ifdef HAVE_EXAMPLE_DB #include "ha_example.h" From 86e5ddeb520f1963cc390425873f1fec61bf83a4 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Thu, 18 Aug 2005 22:27:12 +0200 Subject: [PATCH 10/20] ps_conv.inc: Adjustment of float results for Windows mysql-test-run.pl: Added --port to make MYSQL_DUMP and MYSQL_SHOW work on windows have_lowercase0.inc: new file --- mysql-test/include/have_lowercase0.inc | 4 ++++ mysql-test/include/ps_conv.inc | 16 ++++++++++++++++ mysql-test/mysql-test-run.pl | 2 ++ 3 files changed, 22 insertions(+) create mode 100644 mysql-test/include/have_lowercase0.inc diff --git a/mysql-test/include/have_lowercase0.inc b/mysql-test/include/have_lowercase0.inc new file mode 100644 index 00000000000..f967c18928b --- /dev/null +++ b/mysql-test/include/have_lowercase0.inc @@ -0,0 +1,4 @@ +--require r/lowercase0.require +--disable_query_log; +show variables like "lower_case_%"; +--enable_query_log; diff --git a/mysql-test/include/ps_conv.inc b/mysql-test/include/ps_conv.inc index 0a5bec26fe7..348526202ec 100644 --- a/mysql-test/include/ps_conv.inc +++ b/mysql-test/include/ps_conv.inc @@ -576,15 +576,19 @@ set @arg00= 9223372036854775807 ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; --vertical_results +--replace_result e+0 e+ execute my_select ; --horizontal_results +--replace_result e+0 e+ execute my_delete ; set @arg00= '9223372036854775807' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; --vertical_results +--replace_result e+0 e+ execute my_select ; --horizontal_results +--replace_result e+0 e+ execute my_delete ; # Use the minimum BIGINT from the manual # @@ -592,15 +596,19 @@ set @arg00= -9223372036854775808 ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; --vertical_results +--replace_result e+0 e+ execute my_select ; --horizontal_results +--replace_result e+0 e+ execute my_delete ; set @arg00= '-9223372036854775808' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; --vertical_results +--replace_result e+0 e+ execute my_select ; --horizontal_results +--replace_result e+0 e+ execute my_delete ; # Numeric overflow of columns(c1, c2, c3, c4, c5, c12) with type not in @@ -610,8 +618,10 @@ set @arg00= 1.11111111111111111111e+50 ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; --vertical_results +--replace_result e+0 e+ execute my_select ; --horizontal_results +--replace_result e+0 e+ execute my_delete ; # Attention: The columns(c1,c2,c3,c4,c5,c6) do not get the overflow, # because the string is treated as written integer and @@ -620,15 +630,19 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; --vertical_results +--replace_result e+0 e+ execute my_select ; --horizontal_results +--replace_result e+0 e+ execute my_delete ; set @arg00= -1.11111111111111111111e+50 ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; --vertical_results +--replace_result e+0 e+ execute my_select ; --horizontal_results +--replace_result e+0 e+ execute my_delete ; # Attention: The columns(c1,c2,c3,c4,c5,c6) do not get the overflow, # because the string is treated as written integer and @@ -637,8 +651,10 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; --vertical_results +--replace_result e+0 e+ execute my_select ; --horizontal_results +--replace_result e+0 e+ execute my_delete ; ########################## test of string types ########################## diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 456f481ce86..e72d8f5f683 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2043,6 +2043,7 @@ sub run_mysqltest ($) { my $tinfo= shift; my $cmdline_mysqldump= "$exe_mysqldump --no-defaults -uroot " . + "--port=$master->[0]->{'path_myport'} " . "--socket=$master->[0]->{'path_mysock'} --password="; if ( $opt_debug ) { @@ -2051,6 +2052,7 @@ sub run_mysqltest ($) { } my $cmdline_mysqlshow= "$exe_mysqlshow -uroot " . + "--port=$master->[0]->{'path_myport'} " . "--socket=$master->[0]->{'path_mysock'} --password="; if ( $opt_debug ) { From c594ab792179ced153d4b3073382b3ed1967c658 Mon Sep 17 00:00:00 2001 From: "sasha@asksasha.com" <> Date: Thu, 18 Aug 2005 21:40:14 -0600 Subject: [PATCH 11/20] updated patch for BUG#4680 (incomplete DROP DATABASE breaking replication). We binlog the DROP TABLE for each table that was actually dropped. Per Sergei's suggestion a fixed buffer for the DROP TABLE query is pre-allocated from THD pool, and logging now is done in batches - new batch is started if the buffer becomes full. Reduced memory usage by reusing the table list instead of accumulating a list of dropped table names. Also fixed the problem if the table was not actually dropped, eg due to permissions. Extended the test case to make sure batched query logging does work. --- .bzrignore | 2 + mysql-test/r/rpl_drop_db.result | 1005 +++++++++++++++++++++++++++++++ mysql-test/t/rpl_drop_db.test | 13 + sql/mysql_priv.h | 2 +- sql/sql_db.cc | 85 ++- sql/sql_table.cc | 23 +- sql/table.h | 3 + 7 files changed, 1085 insertions(+), 48 deletions(-) diff --git a/.bzrignore b/.bzrignore index 7a10ce9db69..f9f9c146692 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1054,3 +1054,5 @@ vio/test-sslclient vio/test-sslserver vio/viotest-ssl ndb/tools/ndb_config +support-files/MacOSX/postflight +support-files/MacOSX/preflight diff --git a/mysql-test/r/rpl_drop_db.result b/mysql-test/r/rpl_drop_db.result index bafbfe3a1ed..01a2af5341b 100644 --- a/mysql-test/r/rpl_drop_db.result +++ b/mysql-test/r/rpl_drop_db.result @@ -16,6 +16,1011 @@ ERROR HY000: Error dropping database (can't rmdir './d1/', errno: 17) use d1; show tables; Tables_in_d1 +create table d1.t1000(n int); +create table d1.t999(n int); +create table d1.t998(n int); +create table d1.t997(n int); +create table d1.t996(n int); +create table d1.t995(n int); +create table d1.t994(n int); +create table d1.t993(n int); +create table d1.t992(n int); +create table d1.t991(n int); +create table d1.t990(n int); +create table d1.t989(n int); +create table d1.t988(n int); +create table d1.t987(n int); +create table d1.t986(n int); +create table d1.t985(n int); +create table d1.t984(n int); +create table d1.t983(n int); +create table d1.t982(n int); +create table d1.t981(n int); +create table d1.t980(n int); +create table d1.t979(n int); +create table d1.t978(n int); +create table d1.t977(n int); +create table d1.t976(n int); +create table d1.t975(n int); +create table d1.t974(n int); +create table d1.t973(n int); +create table d1.t972(n int); +create table d1.t971(n int); +create table d1.t970(n int); +create table d1.t969(n int); +create table d1.t968(n int); +create table d1.t967(n int); +create table d1.t966(n int); +create table d1.t965(n int); +create table d1.t964(n int); +create table d1.t963(n int); +create table d1.t962(n int); +create table d1.t961(n int); +create table d1.t960(n int); +create table d1.t959(n int); +create table d1.t958(n int); +create table d1.t957(n int); +create table d1.t956(n int); +create table d1.t955(n int); +create table d1.t954(n int); +create table d1.t953(n int); +create table d1.t952(n int); +create table d1.t951(n int); +create table d1.t950(n int); +create table d1.t949(n int); +create table d1.t948(n int); +create table d1.t947(n int); +create table d1.t946(n int); +create table d1.t945(n int); +create table d1.t944(n int); +create table d1.t943(n int); +create table d1.t942(n int); +create table d1.t941(n int); +create table d1.t940(n int); +create table d1.t939(n int); +create table d1.t938(n int); +create table d1.t937(n int); +create table d1.t936(n int); +create table d1.t935(n int); +create table d1.t934(n int); +create table d1.t933(n int); +create table d1.t932(n int); +create table d1.t931(n int); +create table d1.t930(n int); +create table d1.t929(n int); +create table d1.t928(n int); +create table d1.t927(n int); +create table d1.t926(n int); +create table d1.t925(n int); +create table d1.t924(n int); +create table d1.t923(n int); +create table d1.t922(n int); +create table d1.t921(n int); +create table d1.t920(n int); +create table d1.t919(n int); +create table d1.t918(n int); +create table d1.t917(n int); +create table d1.t916(n int); +create table d1.t915(n int); +create table d1.t914(n int); +create table d1.t913(n int); +create table d1.t912(n int); +create table d1.t911(n int); +create table d1.t910(n int); +create table d1.t909(n int); +create table d1.t908(n int); +create table d1.t907(n int); +create table d1.t906(n int); +create table d1.t905(n int); +create table d1.t904(n int); +create table d1.t903(n int); +create table d1.t902(n int); +create table d1.t901(n int); +create table d1.t900(n int); +create table d1.t899(n int); +create table d1.t898(n int); +create table d1.t897(n int); +create table d1.t896(n int); +create table d1.t895(n int); +create table d1.t894(n int); +create table d1.t893(n int); +create table d1.t892(n int); +create table d1.t891(n int); +create table d1.t890(n int); +create table d1.t889(n int); +create table d1.t888(n int); +create table d1.t887(n int); +create table d1.t886(n int); +create table d1.t885(n int); +create table d1.t884(n int); +create table d1.t883(n int); +create table d1.t882(n int); +create table d1.t881(n int); +create table d1.t880(n int); +create table d1.t879(n int); +create table d1.t878(n int); +create table d1.t877(n int); +create table d1.t876(n int); +create table d1.t875(n int); +create table d1.t874(n int); +create table d1.t873(n int); +create table d1.t872(n int); +create table d1.t871(n int); +create table d1.t870(n int); +create table d1.t869(n int); +create table d1.t868(n int); +create table d1.t867(n int); +create table d1.t866(n int); +create table d1.t865(n int); +create table d1.t864(n int); +create table d1.t863(n int); +create table d1.t862(n int); +create table d1.t861(n int); +create table d1.t860(n int); +create table d1.t859(n int); +create table d1.t858(n int); +create table d1.t857(n int); +create table d1.t856(n int); +create table d1.t855(n int); +create table d1.t854(n int); +create table d1.t853(n int); +create table d1.t852(n int); +create table d1.t851(n int); +create table d1.t850(n int); +create table d1.t849(n int); +create table d1.t848(n int); +create table d1.t847(n int); +create table d1.t846(n int); +create table d1.t845(n int); +create table d1.t844(n int); +create table d1.t843(n int); +create table d1.t842(n int); +create table d1.t841(n int); +create table d1.t840(n int); +create table d1.t839(n int); +create table d1.t838(n int); +create table d1.t837(n int); +create table d1.t836(n int); +create table d1.t835(n int); +create table d1.t834(n int); +create table d1.t833(n int); +create table d1.t832(n int); +create table d1.t831(n int); +create table d1.t830(n int); +create table d1.t829(n int); +create table d1.t828(n int); +create table d1.t827(n int); +create table d1.t826(n int); +create table d1.t825(n int); +create table d1.t824(n int); +create table d1.t823(n int); +create table d1.t822(n int); +create table d1.t821(n int); +create table d1.t820(n int); +create table d1.t819(n int); +create table d1.t818(n int); +create table d1.t817(n int); +create table d1.t816(n int); +create table d1.t815(n int); +create table d1.t814(n int); +create table d1.t813(n int); +create table d1.t812(n int); +create table d1.t811(n int); +create table d1.t810(n int); +create table d1.t809(n int); +create table d1.t808(n int); +create table d1.t807(n int); +create table d1.t806(n int); +create table d1.t805(n int); +create table d1.t804(n int); +create table d1.t803(n int); +create table d1.t802(n int); +create table d1.t801(n int); +create table d1.t800(n int); +create table d1.t799(n int); +create table d1.t798(n int); +create table d1.t797(n int); +create table d1.t796(n int); +create table d1.t795(n int); +create table d1.t794(n int); +create table d1.t793(n int); +create table d1.t792(n int); +create table d1.t791(n int); +create table d1.t790(n int); +create table d1.t789(n int); +create table d1.t788(n int); +create table d1.t787(n int); +create table d1.t786(n int); +create table d1.t785(n int); +create table d1.t784(n int); +create table d1.t783(n int); +create table d1.t782(n int); +create table d1.t781(n int); +create table d1.t780(n int); +create table d1.t779(n int); +create table d1.t778(n int); +create table d1.t777(n int); +create table d1.t776(n int); +create table d1.t775(n int); +create table d1.t774(n int); +create table d1.t773(n int); +create table d1.t772(n int); +create table d1.t771(n int); +create table d1.t770(n int); +create table d1.t769(n int); +create table d1.t768(n int); +create table d1.t767(n int); +create table d1.t766(n int); +create table d1.t765(n int); +create table d1.t764(n int); +create table d1.t763(n int); +create table d1.t762(n int); +create table d1.t761(n int); +create table d1.t760(n int); +create table d1.t759(n int); +create table d1.t758(n int); +create table d1.t757(n int); +create table d1.t756(n int); +create table d1.t755(n int); +create table d1.t754(n int); +create table d1.t753(n int); +create table d1.t752(n int); +create table d1.t751(n int); +create table d1.t750(n int); +create table d1.t749(n int); +create table d1.t748(n int); +create table d1.t747(n int); +create table d1.t746(n int); +create table d1.t745(n int); +create table d1.t744(n int); +create table d1.t743(n int); +create table d1.t742(n int); +create table d1.t741(n int); +create table d1.t740(n int); +create table d1.t739(n int); +create table d1.t738(n int); +create table d1.t737(n int); +create table d1.t736(n int); +create table d1.t735(n int); +create table d1.t734(n int); +create table d1.t733(n int); +create table d1.t732(n int); +create table d1.t731(n int); +create table d1.t730(n int); +create table d1.t729(n int); +create table d1.t728(n int); +create table d1.t727(n int); +create table d1.t726(n int); +create table d1.t725(n int); +create table d1.t724(n int); +create table d1.t723(n int); +create table d1.t722(n int); +create table d1.t721(n int); +create table d1.t720(n int); +create table d1.t719(n int); +create table d1.t718(n int); +create table d1.t717(n int); +create table d1.t716(n int); +create table d1.t715(n int); +create table d1.t714(n int); +create table d1.t713(n int); +create table d1.t712(n int); +create table d1.t711(n int); +create table d1.t710(n int); +create table d1.t709(n int); +create table d1.t708(n int); +create table d1.t707(n int); +create table d1.t706(n int); +create table d1.t705(n int); +create table d1.t704(n int); +create table d1.t703(n int); +create table d1.t702(n int); +create table d1.t701(n int); +create table d1.t700(n int); +create table d1.t699(n int); +create table d1.t698(n int); +create table d1.t697(n int); +create table d1.t696(n int); +create table d1.t695(n int); +create table d1.t694(n int); +create table d1.t693(n int); +create table d1.t692(n int); +create table d1.t691(n int); +create table d1.t690(n int); +create table d1.t689(n int); +create table d1.t688(n int); +create table d1.t687(n int); +create table d1.t686(n int); +create table d1.t685(n int); +create table d1.t684(n int); +create table d1.t683(n int); +create table d1.t682(n int); +create table d1.t681(n int); +create table d1.t680(n int); +create table d1.t679(n int); +create table d1.t678(n int); +create table d1.t677(n int); +create table d1.t676(n int); +create table d1.t675(n int); +create table d1.t674(n int); +create table d1.t673(n int); +create table d1.t672(n int); +create table d1.t671(n int); +create table d1.t670(n int); +create table d1.t669(n int); +create table d1.t668(n int); +create table d1.t667(n int); +create table d1.t666(n int); +create table d1.t665(n int); +create table d1.t664(n int); +create table d1.t663(n int); +create table d1.t662(n int); +create table d1.t661(n int); +create table d1.t660(n int); +create table d1.t659(n int); +create table d1.t658(n int); +create table d1.t657(n int); +create table d1.t656(n int); +create table d1.t655(n int); +create table d1.t654(n int); +create table d1.t653(n int); +create table d1.t652(n int); +create table d1.t651(n int); +create table d1.t650(n int); +create table d1.t649(n int); +create table d1.t648(n int); +create table d1.t647(n int); +create table d1.t646(n int); +create table d1.t645(n int); +create table d1.t644(n int); +create table d1.t643(n int); +create table d1.t642(n int); +create table d1.t641(n int); +create table d1.t640(n int); +create table d1.t639(n int); +create table d1.t638(n int); +create table d1.t637(n int); +create table d1.t636(n int); +create table d1.t635(n int); +create table d1.t634(n int); +create table d1.t633(n int); +create table d1.t632(n int); +create table d1.t631(n int); +create table d1.t630(n int); +create table d1.t629(n int); +create table d1.t628(n int); +create table d1.t627(n int); +create table d1.t626(n int); +create table d1.t625(n int); +create table d1.t624(n int); +create table d1.t623(n int); +create table d1.t622(n int); +create table d1.t621(n int); +create table d1.t620(n int); +create table d1.t619(n int); +create table d1.t618(n int); +create table d1.t617(n int); +create table d1.t616(n int); +create table d1.t615(n int); +create table d1.t614(n int); +create table d1.t613(n int); +create table d1.t612(n int); +create table d1.t611(n int); +create table d1.t610(n int); +create table d1.t609(n int); +create table d1.t608(n int); +create table d1.t607(n int); +create table d1.t606(n int); +create table d1.t605(n int); +create table d1.t604(n int); +create table d1.t603(n int); +create table d1.t602(n int); +create table d1.t601(n int); +create table d1.t600(n int); +create table d1.t599(n int); +create table d1.t598(n int); +create table d1.t597(n int); +create table d1.t596(n int); +create table d1.t595(n int); +create table d1.t594(n int); +create table d1.t593(n int); +create table d1.t592(n int); +create table d1.t591(n int); +create table d1.t590(n int); +create table d1.t589(n int); +create table d1.t588(n int); +create table d1.t587(n int); +create table d1.t586(n int); +create table d1.t585(n int); +create table d1.t584(n int); +create table d1.t583(n int); +create table d1.t582(n int); +create table d1.t581(n int); +create table d1.t580(n int); +create table d1.t579(n int); +create table d1.t578(n int); +create table d1.t577(n int); +create table d1.t576(n int); +create table d1.t575(n int); +create table d1.t574(n int); +create table d1.t573(n int); +create table d1.t572(n int); +create table d1.t571(n int); +create table d1.t570(n int); +create table d1.t569(n int); +create table d1.t568(n int); +create table d1.t567(n int); +create table d1.t566(n int); +create table d1.t565(n int); +create table d1.t564(n int); +create table d1.t563(n int); +create table d1.t562(n int); +create table d1.t561(n int); +create table d1.t560(n int); +create table d1.t559(n int); +create table d1.t558(n int); +create table d1.t557(n int); +create table d1.t556(n int); +create table d1.t555(n int); +create table d1.t554(n int); +create table d1.t553(n int); +create table d1.t552(n int); +create table d1.t551(n int); +create table d1.t550(n int); +create table d1.t549(n int); +create table d1.t548(n int); +create table d1.t547(n int); +create table d1.t546(n int); +create table d1.t545(n int); +create table d1.t544(n int); +create table d1.t543(n int); +create table d1.t542(n int); +create table d1.t541(n int); +create table d1.t540(n int); +create table d1.t539(n int); +create table d1.t538(n int); +create table d1.t537(n int); +create table d1.t536(n int); +create table d1.t535(n int); +create table d1.t534(n int); +create table d1.t533(n int); +create table d1.t532(n int); +create table d1.t531(n int); +create table d1.t530(n int); +create table d1.t529(n int); +create table d1.t528(n int); +create table d1.t527(n int); +create table d1.t526(n int); +create table d1.t525(n int); +create table d1.t524(n int); +create table d1.t523(n int); +create table d1.t522(n int); +create table d1.t521(n int); +create table d1.t520(n int); +create table d1.t519(n int); +create table d1.t518(n int); +create table d1.t517(n int); +create table d1.t516(n int); +create table d1.t515(n int); +create table d1.t514(n int); +create table d1.t513(n int); +create table d1.t512(n int); +create table d1.t511(n int); +create table d1.t510(n int); +create table d1.t509(n int); +create table d1.t508(n int); +create table d1.t507(n int); +create table d1.t506(n int); +create table d1.t505(n int); +create table d1.t504(n int); +create table d1.t503(n int); +create table d1.t502(n int); +create table d1.t501(n int); +create table d1.t500(n int); +create table d1.t499(n int); +create table d1.t498(n int); +create table d1.t497(n int); +create table d1.t496(n int); +create table d1.t495(n int); +create table d1.t494(n int); +create table d1.t493(n int); +create table d1.t492(n int); +create table d1.t491(n int); +create table d1.t490(n int); +create table d1.t489(n int); +create table d1.t488(n int); +create table d1.t487(n int); +create table d1.t486(n int); +create table d1.t485(n int); +create table d1.t484(n int); +create table d1.t483(n int); +create table d1.t482(n int); +create table d1.t481(n int); +create table d1.t480(n int); +create table d1.t479(n int); +create table d1.t478(n int); +create table d1.t477(n int); +create table d1.t476(n int); +create table d1.t475(n int); +create table d1.t474(n int); +create table d1.t473(n int); +create table d1.t472(n int); +create table d1.t471(n int); +create table d1.t470(n int); +create table d1.t469(n int); +create table d1.t468(n int); +create table d1.t467(n int); +create table d1.t466(n int); +create table d1.t465(n int); +create table d1.t464(n int); +create table d1.t463(n int); +create table d1.t462(n int); +create table d1.t461(n int); +create table d1.t460(n int); +create table d1.t459(n int); +create table d1.t458(n int); +create table d1.t457(n int); +create table d1.t456(n int); +create table d1.t455(n int); +create table d1.t454(n int); +create table d1.t453(n int); +create table d1.t452(n int); +create table d1.t451(n int); +create table d1.t450(n int); +create table d1.t449(n int); +create table d1.t448(n int); +create table d1.t447(n int); +create table d1.t446(n int); +create table d1.t445(n int); +create table d1.t444(n int); +create table d1.t443(n int); +create table d1.t442(n int); +create table d1.t441(n int); +create table d1.t440(n int); +create table d1.t439(n int); +create table d1.t438(n int); +create table d1.t437(n int); +create table d1.t436(n int); +create table d1.t435(n int); +create table d1.t434(n int); +create table d1.t433(n int); +create table d1.t432(n int); +create table d1.t431(n int); +create table d1.t430(n int); +create table d1.t429(n int); +create table d1.t428(n int); +create table d1.t427(n int); +create table d1.t426(n int); +create table d1.t425(n int); +create table d1.t424(n int); +create table d1.t423(n int); +create table d1.t422(n int); +create table d1.t421(n int); +create table d1.t420(n int); +create table d1.t419(n int); +create table d1.t418(n int); +create table d1.t417(n int); +create table d1.t416(n int); +create table d1.t415(n int); +create table d1.t414(n int); +create table d1.t413(n int); +create table d1.t412(n int); +create table d1.t411(n int); +create table d1.t410(n int); +create table d1.t409(n int); +create table d1.t408(n int); +create table d1.t407(n int); +create table d1.t406(n int); +create table d1.t405(n int); +create table d1.t404(n int); +create table d1.t403(n int); +create table d1.t402(n int); +create table d1.t401(n int); +create table d1.t400(n int); +create table d1.t399(n int); +create table d1.t398(n int); +create table d1.t397(n int); +create table d1.t396(n int); +create table d1.t395(n int); +create table d1.t394(n int); +create table d1.t393(n int); +create table d1.t392(n int); +create table d1.t391(n int); +create table d1.t390(n int); +create table d1.t389(n int); +create table d1.t388(n int); +create table d1.t387(n int); +create table d1.t386(n int); +create table d1.t385(n int); +create table d1.t384(n int); +create table d1.t383(n int); +create table d1.t382(n int); +create table d1.t381(n int); +create table d1.t380(n int); +create table d1.t379(n int); +create table d1.t378(n int); +create table d1.t377(n int); +create table d1.t376(n int); +create table d1.t375(n int); +create table d1.t374(n int); +create table d1.t373(n int); +create table d1.t372(n int); +create table d1.t371(n int); +create table d1.t370(n int); +create table d1.t369(n int); +create table d1.t368(n int); +create table d1.t367(n int); +create table d1.t366(n int); +create table d1.t365(n int); +create table d1.t364(n int); +create table d1.t363(n int); +create table d1.t362(n int); +create table d1.t361(n int); +create table d1.t360(n int); +create table d1.t359(n int); +create table d1.t358(n int); +create table d1.t357(n int); +create table d1.t356(n int); +create table d1.t355(n int); +create table d1.t354(n int); +create table d1.t353(n int); +create table d1.t352(n int); +create table d1.t351(n int); +create table d1.t350(n int); +create table d1.t349(n int); +create table d1.t348(n int); +create table d1.t347(n int); +create table d1.t346(n int); +create table d1.t345(n int); +create table d1.t344(n int); +create table d1.t343(n int); +create table d1.t342(n int); +create table d1.t341(n int); +create table d1.t340(n int); +create table d1.t339(n int); +create table d1.t338(n int); +create table d1.t337(n int); +create table d1.t336(n int); +create table d1.t335(n int); +create table d1.t334(n int); +create table d1.t333(n int); +create table d1.t332(n int); +create table d1.t331(n int); +create table d1.t330(n int); +create table d1.t329(n int); +create table d1.t328(n int); +create table d1.t327(n int); +create table d1.t326(n int); +create table d1.t325(n int); +create table d1.t324(n int); +create table d1.t323(n int); +create table d1.t322(n int); +create table d1.t321(n int); +create table d1.t320(n int); +create table d1.t319(n int); +create table d1.t318(n int); +create table d1.t317(n int); +create table d1.t316(n int); +create table d1.t315(n int); +create table d1.t314(n int); +create table d1.t313(n int); +create table d1.t312(n int); +create table d1.t311(n int); +create table d1.t310(n int); +create table d1.t309(n int); +create table d1.t308(n int); +create table d1.t307(n int); +create table d1.t306(n int); +create table d1.t305(n int); +create table d1.t304(n int); +create table d1.t303(n int); +create table d1.t302(n int); +create table d1.t301(n int); +create table d1.t300(n int); +create table d1.t299(n int); +create table d1.t298(n int); +create table d1.t297(n int); +create table d1.t296(n int); +create table d1.t295(n int); +create table d1.t294(n int); +create table d1.t293(n int); +create table d1.t292(n int); +create table d1.t291(n int); +create table d1.t290(n int); +create table d1.t289(n int); +create table d1.t288(n int); +create table d1.t287(n int); +create table d1.t286(n int); +create table d1.t285(n int); +create table d1.t284(n int); +create table d1.t283(n int); +create table d1.t282(n int); +create table d1.t281(n int); +create table d1.t280(n int); +create table d1.t279(n int); +create table d1.t278(n int); +create table d1.t277(n int); +create table d1.t276(n int); +create table d1.t275(n int); +create table d1.t274(n int); +create table d1.t273(n int); +create table d1.t272(n int); +create table d1.t271(n int); +create table d1.t270(n int); +create table d1.t269(n int); +create table d1.t268(n int); +create table d1.t267(n int); +create table d1.t266(n int); +create table d1.t265(n int); +create table d1.t264(n int); +create table d1.t263(n int); +create table d1.t262(n int); +create table d1.t261(n int); +create table d1.t260(n int); +create table d1.t259(n int); +create table d1.t258(n int); +create table d1.t257(n int); +create table d1.t256(n int); +create table d1.t255(n int); +create table d1.t254(n int); +create table d1.t253(n int); +create table d1.t252(n int); +create table d1.t251(n int); +create table d1.t250(n int); +create table d1.t249(n int); +create table d1.t248(n int); +create table d1.t247(n int); +create table d1.t246(n int); +create table d1.t245(n int); +create table d1.t244(n int); +create table d1.t243(n int); +create table d1.t242(n int); +create table d1.t241(n int); +create table d1.t240(n int); +create table d1.t239(n int); +create table d1.t238(n int); +create table d1.t237(n int); +create table d1.t236(n int); +create table d1.t235(n int); +create table d1.t234(n int); +create table d1.t233(n int); +create table d1.t232(n int); +create table d1.t231(n int); +create table d1.t230(n int); +create table d1.t229(n int); +create table d1.t228(n int); +create table d1.t227(n int); +create table d1.t226(n int); +create table d1.t225(n int); +create table d1.t224(n int); +create table d1.t223(n int); +create table d1.t222(n int); +create table d1.t221(n int); +create table d1.t220(n int); +create table d1.t219(n int); +create table d1.t218(n int); +create table d1.t217(n int); +create table d1.t216(n int); +create table d1.t215(n int); +create table d1.t214(n int); +create table d1.t213(n int); +create table d1.t212(n int); +create table d1.t211(n int); +create table d1.t210(n int); +create table d1.t209(n int); +create table d1.t208(n int); +create table d1.t207(n int); +create table d1.t206(n int); +create table d1.t205(n int); +create table d1.t204(n int); +create table d1.t203(n int); +create table d1.t202(n int); +create table d1.t201(n int); +create table d1.t200(n int); +create table d1.t199(n int); +create table d1.t198(n int); +create table d1.t197(n int); +create table d1.t196(n int); +create table d1.t195(n int); +create table d1.t194(n int); +create table d1.t193(n int); +create table d1.t192(n int); +create table d1.t191(n int); +create table d1.t190(n int); +create table d1.t189(n int); +create table d1.t188(n int); +create table d1.t187(n int); +create table d1.t186(n int); +create table d1.t185(n int); +create table d1.t184(n int); +create table d1.t183(n int); +create table d1.t182(n int); +create table d1.t181(n int); +create table d1.t180(n int); +create table d1.t179(n int); +create table d1.t178(n int); +create table d1.t177(n int); +create table d1.t176(n int); +create table d1.t175(n int); +create table d1.t174(n int); +create table d1.t173(n int); +create table d1.t172(n int); +create table d1.t171(n int); +create table d1.t170(n int); +create table d1.t169(n int); +create table d1.t168(n int); +create table d1.t167(n int); +create table d1.t166(n int); +create table d1.t165(n int); +create table d1.t164(n int); +create table d1.t163(n int); +create table d1.t162(n int); +create table d1.t161(n int); +create table d1.t160(n int); +create table d1.t159(n int); +create table d1.t158(n int); +create table d1.t157(n int); +create table d1.t156(n int); +create table d1.t155(n int); +create table d1.t154(n int); +create table d1.t153(n int); +create table d1.t152(n int); +create table d1.t151(n int); +create table d1.t150(n int); +create table d1.t149(n int); +create table d1.t148(n int); +create table d1.t147(n int); +create table d1.t146(n int); +create table d1.t145(n int); +create table d1.t144(n int); +create table d1.t143(n int); +create table d1.t142(n int); +create table d1.t141(n int); +create table d1.t140(n int); +create table d1.t139(n int); +create table d1.t138(n int); +create table d1.t137(n int); +create table d1.t136(n int); +create table d1.t135(n int); +create table d1.t134(n int); +create table d1.t133(n int); +create table d1.t132(n int); +create table d1.t131(n int); +create table d1.t130(n int); +create table d1.t129(n int); +create table d1.t128(n int); +create table d1.t127(n int); +create table d1.t126(n int); +create table d1.t125(n int); +create table d1.t124(n int); +create table d1.t123(n int); +create table d1.t122(n int); +create table d1.t121(n int); +create table d1.t120(n int); +create table d1.t119(n int); +create table d1.t118(n int); +create table d1.t117(n int); +create table d1.t116(n int); +create table d1.t115(n int); +create table d1.t114(n int); +create table d1.t113(n int); +create table d1.t112(n int); +create table d1.t111(n int); +create table d1.t110(n int); +create table d1.t109(n int); +create table d1.t108(n int); +create table d1.t107(n int); +create table d1.t106(n int); +create table d1.t105(n int); +create table d1.t104(n int); +create table d1.t103(n int); +create table d1.t102(n int); +create table d1.t101(n int); +create table d1.t100(n int); +create table d1.t99(n int); +create table d1.t98(n int); +create table d1.t97(n int); +create table d1.t96(n int); +create table d1.t95(n int); +create table d1.t94(n int); +create table d1.t93(n int); +create table d1.t92(n int); +create table d1.t91(n int); +create table d1.t90(n int); +create table d1.t89(n int); +create table d1.t88(n int); +create table d1.t87(n int); +create table d1.t86(n int); +create table d1.t85(n int); +create table d1.t84(n int); +create table d1.t83(n int); +create table d1.t82(n int); +create table d1.t81(n int); +create table d1.t80(n int); +create table d1.t79(n int); +create table d1.t78(n int); +create table d1.t77(n int); +create table d1.t76(n int); +create table d1.t75(n int); +create table d1.t74(n int); +create table d1.t73(n int); +create table d1.t72(n int); +create table d1.t71(n int); +create table d1.t70(n int); +create table d1.t69(n int); +create table d1.t68(n int); +create table d1.t67(n int); +create table d1.t66(n int); +create table d1.t65(n int); +create table d1.t64(n int); +create table d1.t63(n int); +create table d1.t62(n int); +create table d1.t61(n int); +create table d1.t60(n int); +create table d1.t59(n int); +create table d1.t58(n int); +create table d1.t57(n int); +create table d1.t56(n int); +create table d1.t55(n int); +create table d1.t54(n int); +create table d1.t53(n int); +create table d1.t52(n int); +create table d1.t51(n int); +create table d1.t50(n int); +create table d1.t49(n int); +create table d1.t48(n int); +create table d1.t47(n int); +create table d1.t46(n int); +create table d1.t45(n int); +create table d1.t44(n int); +create table d1.t43(n int); +create table d1.t42(n int); +create table d1.t41(n int); +create table d1.t40(n int); +create table d1.t39(n int); +create table d1.t38(n int); +create table d1.t37(n int); +create table d1.t36(n int); +create table d1.t35(n int); +create table d1.t34(n int); +create table d1.t33(n int); +create table d1.t32(n int); +create table d1.t31(n int); +create table d1.t30(n int); +create table d1.t29(n int); +create table d1.t28(n int); +create table d1.t27(n int); +create table d1.t26(n int); +create table d1.t25(n int); +create table d1.t24(n int); +create table d1.t23(n int); +create table d1.t22(n int); +create table d1.t21(n int); +create table d1.t20(n int); +create table d1.t19(n int); +create table d1.t18(n int); +create table d1.t17(n int); +create table d1.t16(n int); +create table d1.t15(n int); +create table d1.t14(n int); +create table d1.t13(n int); +create table d1.t12(n int); +create table d1.t11(n int); +create table d1.t10(n int); +create table d1.t9(n int); +create table d1.t8(n int); +create table d1.t7(n int); +create table d1.t6(n int); +create table d1.t5(n int); +create table d1.t4(n int); +create table d1.t3(n int); +create table d1.t2(n int); +create table d1.t1(n int); +drop database d1; +ERROR HY000: Error dropping database (can't rmdir './d1/', errno: 17) +use d1; +show tables; +Tables_in_d1 use test; create table t1 (n int); insert into t1 values (1234); diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test index ef0ab4be6fd..71dc22f705f 100644 --- a/mysql-test/t/rpl_drop_db.test +++ b/mysql-test/t/rpl_drop_db.test @@ -17,6 +17,19 @@ create table d1.t3 (n int); drop database d1; use d1; show tables; + +# test the branch of the code that deals with the query buffer overflow + +let $1=1000; +while ($1) +{ + eval create table d1.t$1(n int); + dec $1; +} +--error 1010 +drop database d1; +use d1; +show tables; use test; create table t1 (n int); insert into t1 values (1234); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 946bb117e9e..0af3ea3af63 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -447,7 +447,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, bool drop_temporary, bool log_query); int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables, bool if_exists, bool drop_temporary, - bool log_query, List *dropped_tables); + bool log_query); int quick_rm_table(enum db_type base,const char *db, const char *table_name); bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 0155fca0466..6dcc7be0904 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -25,14 +25,20 @@ #include #endif +#define MAX_DROP_TABLE_Q_LEN 1024 + const char *del_exts[]= {".frm", ".BAK", ".TMD",".opt", NullS}; static TYPELIB deletable_extentions= {array_elements(del_exts)-1,"del_exts", del_exts, NULL}; static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, - const char *db, const char *path, - uint level, List *dropped_tables); + const char *db, const char *path, uint level, + TABLE_LIST** dropped_tables); + +static inline void write_to_binlog(THD* thd, char* query, uint q_len, + char* db, uint db_len); + /* Database options hash */ static HASH dboptions; static my_bool dboptions_init= 0; @@ -57,6 +63,19 @@ static byte* dboptions_get_key(my_dbopt_t *opt, uint *length, return (byte*) opt->name; } +/* + Helper function to write a query to binlog used by mysql_rm_db() + */ +static inline void write_to_binlog(THD* thd, char* query, uint q_len, + char* db, uint db_len) +{ + Query_log_event qinfo(thd, query, q_len, 0, 0); + qinfo.error_code= 0; + qinfo.db= db; + qinfo.db_len= db_len; + mysql_bin_log.write(&qinfo); +} + /* Function to free dboptions hash element @@ -584,8 +603,8 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) int error= 0; char path[FN_REFLEN+16], tmp_db[NAME_LEN+1]; MY_DIR *dirp; - List dropped_tables; uint length; + TABLE_LIST* dropped_tables= 0; DBUG_ENTER("mysql_rm_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); @@ -625,7 +644,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) error= -1; if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0, - &dropped_tables)) >= 0) + &dropped_tables)) >= 0) { ha_drop_database(path); query_cache_invalidate1(db); @@ -675,36 +694,44 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) send_ok(thd, (ulong) deleted); thd->server_status&= ~SERVER_STATUS_DB_DROPPED; } - else if (!dropped_tables.is_empty() && mysql_bin_log.is_open()) + else if (mysql_bin_log.is_open()) { - List_iterator it(dropped_tables); - String* dropped_table; - int q_len= 11; /* drop table */ - int db_len= strlen(db); + char* query= thd->alloc(MAX_DROP_TABLE_Q_LEN); - for (;(dropped_table= it++);) - { - q_len += dropped_table->length() + 2 + db_len; - } - q_len--; /* no last comma */ - - char* query= thd->alloc(q_len); if (!query) goto exit; /* not much else we can do */ char* p= strmov(query,"drop table "); - it.rewind(); + char* p_end= query + MAX_DROP_TABLE_Q_LEN; + TABLE_LIST* tbl; + bool last_query_needs_write= 0; + uint db_len= strlen(db); - for (;(dropped_table= it++);) + for (tbl= dropped_tables;tbl;tbl= tbl->next) { - p= strmov(p,db); - *p++ = '.'; - p= strnmov(p,dropped_table->ptr(),dropped_table->length()); + if (!tbl->was_dropped) + continue; + + /* 3 for the quotes and the comma*/ + uint tbl_name_len= strlen(tbl->real_name) + 3; + if (p + tbl_name_len + 1 >= p_end) + { + *--p= 0; /* kill , */ + write_to_binlog(thd, query, p - query, db, db_len); + p= query + 11; /* reuse the initial "drop table" */ + } + + *p++ = '`'; + p= strmov(p,tbl->real_name); + *p++ = '`'; *p++ = ','; + last_query_needs_write= 1; } - *--p= 0; - Query_log_event qinfo(thd, query, q_len, 0, 0); - qinfo.error_code= 0; - mysql_bin_log.write(&qinfo); + + if (last_query_needs_write) + { + *--p= 0; + write_to_binlog(thd, query, p - query, db, db_len); + } } exit: @@ -750,7 +777,7 @@ exit2: */ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, - const char *org_path, uint level, List *dropped_tables) + const char *org_path, uint level, TABLE_LIST** dropped_tables) { long deleted=0; ulong found_other_files=0; @@ -839,8 +866,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, } } if (thd->killed || - (tot_list && mysql_rm_table_part2_with_lock(thd, tot_list, 1, 0, - 1,dropped_tables))) + (tot_list && mysql_rm_table_part2_with_lock(thd, tot_list, 1, 0, 1))) goto err; /* Remove RAID directories */ @@ -853,6 +879,9 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, } my_dirend(dirp); + if (dropped_tables) + *dropped_tables= tot_list; + /* If the directory is a symbolic link, remove the link first, then remove the directory the symbolic link pointed at diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e948a65f301..80ac9e007b9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -156,8 +156,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables, bool if_exists, - bool drop_temporary, bool dont_log_query, - List* dropped_tables) + bool drop_temporary, bool dont_log_query) { int error; thd->mysys_var->current_mutex= &LOCK_open; @@ -166,23 +165,6 @@ int mysql_rm_table_part2_with_lock(THD *thd, error=mysql_rm_table_part2(thd,tables, if_exists, drop_temporary, dont_log_query); - /* - For now we assume that if we got success all the tables in the list - were actually dropped, otherwise, assume none were dropped. - TODO: fix it to work with a partial drop - extremely rare case, but - can happen. - */ - if (!error && dropped_tables) - { - TABLE_LIST* tbl; - - for (tbl= tables; tbl; tbl= tbl->next) - { - String *dropped_table= new (thd->mem_root) - String(tbl->real_name,&my_charset_latin1); - dropped_tables->push_back(dropped_table); - } - } pthread_mutex_unlock(&LOCK_open); @@ -238,6 +220,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, for (table=tables ; table ; table=table->next) { char *db=table->db; + table->was_dropped= 0; mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL); if (!close_temporary_table(thd, db, table->real_name)) { @@ -298,6 +281,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, wrong_tables.append(','); wrong_tables.append(String(table->real_name,system_charset_info)); } + else + table->was_dropped= 1; } thd->tmp_table_used= tmp_table_deleted; error= 0; diff --git a/sql/table.h b/sql/table.h index 77153e5d8cd..fb742acf804 100644 --- a/sql/table.h +++ b/sql/table.h @@ -235,6 +235,9 @@ typedef struct st_table_list bool cacheable_table; /* stop PS caching */ /* used in multi-upd privelege check */ bool table_in_update_from_clause; + + /* used for proper partially successful DROP DATABASE binlogging */ + bool was_dropped; } TABLE_LIST; typedef struct st_changed_table_list From bbbb56df8f29ba3f9601e0c45cbc8564d5b2d5e0 Mon Sep 17 00:00:00 2001 From: "elliot@mysql.com" <> Date: Fri, 19 Aug 2005 17:55:28 -0400 Subject: [PATCH 12/20] Fix ctype_cp932 test to be deterministic on different machines. --- mysql-test/r/ctype_cp932.result | 13 ++++++++----- mysql-test/t/ctype_cp932.test | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result index 85e317481d1..0711f251a07 100644 --- a/mysql-test/r/ctype_cp932.result +++ b/mysql-test/r/ctype_cp932.result @@ -8576,16 +8576,19 @@ FC4B DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; +RESET MASTER; CREATE TABLE t1(f1 blob); PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)'; SET @var1= x'8300'; EXECUTE stmt1 USING @var1; -SHOW BINLOG EVENTS FROM 27642; +SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.000001 27642 Query 1 27642 use `test`; CREATE TABLE t1(f1 blob) -master-bin.000001 27701 Query 1 27701 use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=95,COLLATION_CONNECTION=95,COLLATION_DATABASE=95,COLLATION_SERVER=8 -master-bin.000001 27837 User var 1 27837 @`var1`=_binary 0x8300 COLLATE binary -master-bin.000001 27876 Query 1 27876 use `test`; INSERT INTO t1 VALUES(@'var1') +master-bin.000001 # Start 1 # Server ver: 4.1.15-debug-log, Binlog ver: 3 +master-bin.000001 # Query 1 # use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=95,COLLATION_CONNECTION=95,COLLATION_DATABASE=95,COLLATION_SERVER=8 +master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(f1 blob) +master-bin.000001 # Query 1 # use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=95,COLLATION_CONNECTION=95,COLLATION_DATABASE=95,COLLATION_SERVER=8 +master-bin.000001 # User var 1 # @`var1`=_binary 0x8300 COLLATE binary +master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES(@'var1') SELECT HEX(f1) FROM t1; HEX(f1) 8300 diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test index 34bf7965248..8f471ebb979 100644 --- a/mysql-test/t/ctype_cp932.test +++ b/mysql-test/t/ctype_cp932.test @@ -403,6 +403,7 @@ DROP TABLE t3; # Test prepared statement with 0x8300 sequence in parameter while # running with cp932 client character set. +RESET MASTER; CREATE TABLE t1(f1 blob); PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)'; SET @var1= x'8300'; @@ -417,7 +418,8 @@ SET @var1= x'8300'; # code (and I have used it to test the fix) until there is some way to # exercise this code from mysql-test-run. EXECUTE stmt1 USING @var1; -SHOW BINLOG EVENTS FROM 27642; +--replace_column 2 # 5 # +SHOW BINLOG EVENTS; SELECT HEX(f1) FROM t1; DROP table t1; # end test for bug#11338 From ddcbf609c48ce867cc15d772a8d9d88c509a9643 Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Mon, 22 Aug 2005 12:48:01 +0200 Subject: [PATCH 13/20] Ensure that a failing test does not stop testing or the whole RPM build process. --- support-files/mysql.spec.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index b563972e08a..af9abd2fce1 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -308,7 +308,7 @@ BuildMySQL "--enable-shared \ --with-comment=\"MySQL Community Edition - Max (GPL)\" \ --with-server-suffix='-Max'" -make test +make test-force || true # Save mysqld-max mv sql/mysqld sql/mysqld-max @@ -359,7 +359,7 @@ BuildMySQL "--disable-shared \ --without-openssl" nm --numeric-sort sql/mysqld > sql/mysqld.sym -make test +make test-force || true %install RBR=$RPM_BUILD_ROOT From f70beef6c7cb0f57211776854fba8d030f8389c8 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Mon, 22 Aug 2005 15:48:50 -0700 Subject: [PATCH 14/20] Use the hostname with which the user authenticated when determining which user to update with 'SET PASSWORD = ...'. (Bug #12302) --- mysql-test/r/grant2.result | 26 ++++++++++++++++++++++++++ mysql-test/t/grant2.test | 38 ++++++++++++++++++++++++++++++++++++++ sql/set_var.cc | 13 ++++++++++++- sql/sql_acl.cc | 19 +++++++++++-------- 4 files changed, 87 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index ada205f6f23..8bd39b0225e 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -94,5 +94,31 @@ i 2 3 REVOKE ALL ON mysqltest_1.t1 FROM mysqltest_1@'127.0.0.0/255.0.0.0'; +delete from mysql.user where user like 'mysqltest\_1'; +flush privileges; drop table mysqltest_1.t1; +grant all on mysqltest_1.* to mysqltest_1@'127.0.0.1'; +select current_user(); +current_user() +mysqltest_1@127.0.0.1 +set password = password('changed'); +select host, length(password) from mysql.user where user like 'mysqltest\_1'; +host length(password) +127.0.0.1 41 +revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.1'; +delete from mysql.user where user like 'mysqltest\_1'; +flush privileges; +grant all on mysqltest_1.* to mysqltest_1@'127.0.0.0/255.0.0.0'; +select current_user(); +current_user() +mysqltest_1@127.0.0.0/255.0.0.0 +set password = password('changed'); +select host, length(password) from mysql.user where user like 'mysqltest\_1'; +host length(password) +127.0.0.0/255.0.0.0 41 +revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.0/255.0.0.0'; +delete from mysql.user where user like 'mysqltest\_1'; +flush privileges; drop database mysqltest_1; +set password = password("changed"); +ERROR 42000: Access denied for user ''@'localhost' to database 'mysql' diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index f347869d9ec..e3e733a50c3 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -122,7 +122,45 @@ select * from t1; disconnect n1; connection default; REVOKE ALL ON mysqltest_1.t1 FROM mysqltest_1@'127.0.0.0/255.0.0.0'; +delete from mysql.user where user like 'mysqltest\_1'; +flush privileges; drop table mysqltest_1.t1; + +# +# Bug #12302: 'SET PASSWORD = ...' didn't work if connecting hostname != +# hostname the current user is authenticated as. Note that a test for this +# was also added to the test above. +# +grant all on mysqltest_1.* to mysqltest_1@'127.0.0.1'; +connect (b12302,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,); +connection b12302; +select current_user(); +set password = password('changed'); +disconnect b12302; +connection default; +select host, length(password) from mysql.user where user like 'mysqltest\_1'; +revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.1'; +delete from mysql.user where user like 'mysqltest\_1'; +flush privileges; +grant all on mysqltest_1.* to mysqltest_1@'127.0.0.0/255.0.0.0'; +connect (b12302_2,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,); +connection b12302_2; +select current_user(); +set password = password('changed'); +disconnect b12302_2; +connection default; +select host, length(password) from mysql.user where user like 'mysqltest\_1'; +revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.0/255.0.0.0'; +delete from mysql.user where user like 'mysqltest\_1'; +flush privileges; drop database mysqltest_1; +# But anonymous users can't change their password +connect (n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +connection n5; +--error 1044 +set password = password("changed"); +disconnect n5; +connection default; + # End of 4.1 tests diff --git a/sql/set_var.cc b/sql/set_var.cc index f7700d18607..1b66b68b349 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2944,7 +2944,18 @@ int set_var_password::check(THD *thd) { #ifndef NO_EMBEDDED_ACCESS_CHECKS if (!user->host.str) - user->host.str= (char*) thd->host_or_ip; + { + if (thd->priv_host != 0) + { + user->host.str= (char *) thd->priv_host; + user->host.length= strlen(thd->priv_host); + } + else + { + user->host.str= (char *)"%"; + user->host.length= 1; + } + } /* Returns 1 as the function sends error to client */ return check_change_password(thd, user->host.str, user->user.str, password, strlen(password)) ? 1 : 0; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index d191da32189..813754ad937 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -67,7 +67,8 @@ static ulong get_access(TABLE *form,uint fieldnr, uint *next_field=0); static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b); static ulong get_sort(uint count,...); static void init_check_host(void); -static ACL_USER *find_acl_user(const char *host, const char *user); +static ACL_USER *find_acl_user(const char *host, const char *user, + my_bool exact); static bool update_user_table(THD *thd, const char *host, const char *user, const char *new_password, uint new_password_len); static void update_hostname(acl_host_and_ip *host, const char *hostname); @@ -1188,7 +1189,7 @@ bool check_change_password(THD *thd, const char *host, const char *user, } if (!thd->slave_thread && (strcmp(thd->user,user) || - my_strcasecmp(&my_charset_latin1, host, thd->host_or_ip))) + my_strcasecmp(&my_charset_latin1, host, thd->priv_host))) { if (check_access(thd, UPDATE_ACL, "mysql",0,1,0)) return(1); @@ -1240,7 +1241,7 @@ bool change_password(THD *thd, const char *host, const char *user, VOID(pthread_mutex_lock(&acl_cache->lock)); ACL_USER *acl_user; - if (!(acl_user= find_acl_user(host, user))) + if (!(acl_user= find_acl_user(host, user, TRUE))) { VOID(pthread_mutex_unlock(&acl_cache->lock)); send_error(thd, ER_PASSWORD_NO_MATCH); @@ -1282,7 +1283,7 @@ bool change_password(THD *thd, const char *host, const char *user, */ static ACL_USER * -find_acl_user(const char *host, const char *user) +find_acl_user(const char *host, const char *user, my_bool exact) { DBUG_ENTER("find_acl_user"); DBUG_PRINT("enter",("host: '%s' user: '%s'",host,user)); @@ -1298,7 +1299,9 @@ find_acl_user(const char *host, const char *user) if (!acl_user->user && !user[0] || acl_user->user && !strcmp(user,acl_user->user)) { - if (compare_hostname(&acl_user->host,host,host)) + if (exact ? !my_strcasecmp(&my_charset_latin1, host, + acl_user->host.hostname) : + compare_hostname(&acl_user->host,host,host)) { DBUG_RETURN(acl_user); } @@ -1689,7 +1692,7 @@ static int replace_db_table(TABLE *table, const char *db, } /* Check if there is such a user in user table in memory? */ - if (!find_acl_user(combo.host.str,combo.user.str)) + if (!find_acl_user(combo.host.str,combo.user.str, FALSE)) { my_error(ER_PASSWORD_NO_MATCH,MYF(0)); DBUG_RETURN(-1); @@ -2151,7 +2154,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, The following should always succeed as new users are created before this function is called! */ - if (!find_acl_user(combo.host.str,combo.user.str)) + if (!find_acl_user(combo.host.str,combo.user.str, FALSE)) { my_error(ER_PASSWORD_NO_MATCH,MYF(0)); /* purecov: deadcode */ DBUG_RETURN(-1); /* purecov: deadcode */ @@ -3448,7 +3451,7 @@ void get_privilege_desc(char *to, uint max_length, ulong access) void get_mqh(const char *user, const char *host, USER_CONN *uc) { ACL_USER *acl_user; - if (initialized && (acl_user= find_acl_user(host,user))) + if (initialized && (acl_user= find_acl_user(host,user, FALSE))) uc->user_resources= acl_user->user_resource; else bzero((char*) &uc->user_resources, sizeof(uc->user_resources)); From 28e3fe8759fe36c5db7eeb0765ea921eb252dfce Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Tue, 23 Aug 2005 11:50:24 +0200 Subject: [PATCH 15/20] enabled make of ndb_redo_log_reader --- ndb/src/kernel/blocks/dblqh/Makefile.am | 8 ++++++-- .../blocks/dblqh/redoLogReader/redoLogFileReader.cpp | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ndb/src/kernel/blocks/dblqh/Makefile.am b/ndb/src/kernel/blocks/dblqh/Makefile.am index 854860b269c..bb8efe8c5b8 100644 --- a/ndb/src/kernel/blocks/dblqh/Makefile.am +++ b/ndb/src/kernel/blocks/dblqh/Makefile.am @@ -1,12 +1,16 @@ -#SUBDIRS = redoLogReader - noinst_LIBRARIES = libdblqh.a +EXTRA_PROGRAMS = ndbd_redo_log_reader libdblqh_a_SOURCES = DblqhInit.cpp DblqhMain.cpp +ndbd_redo_log_reader_SOURCES = redoLogReader/records.cpp redoLogReader/redoLogFileReader.cpp include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_kernel.mk.am +LDADD += \ + $(top_builddir)/ndb/src/common/util/libgeneral.la \ + $(top_builddir)/ndb/src/common/portlib/libportlib.la + # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/ndb/src/kernel/blocks/dblqh/redoLogReader/redoLogFileReader.cpp b/ndb/src/kernel/blocks/dblqh/redoLogReader/redoLogFileReader.cpp index 540df7b507e..67e59c48ea6 100644 --- a/ndb/src/kernel/blocks/dblqh/redoLogReader/redoLogFileReader.cpp +++ b/ndb/src/kernel/blocks/dblqh/redoLogReader/redoLogFileReader.cpp @@ -40,7 +40,7 @@ Uint32 readFromFile(FILE * f, Uint32 *toPtr, Uint32 sizeInWords); void readArguments(int argc, const char** argv); void doExit(); -FILE * f; +FILE * f= 0; char fileName[256]; bool thePrintFlag = true; bool theCheckFlag = true; @@ -458,7 +458,7 @@ void readArguments(int argc, const char** argv) void doExit() { ndbout << "Error in redoLogReader(). Exiting!" << endl; - fclose(f); + if (f) fclose(f); delete [] redoLogPage; exit(RETURN_ERROR); } From 653e99dea2099a1d47c82ad8142c0ac3cf4c74cd Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Tue, 23 Aug 2005 12:16:16 +0200 Subject: [PATCH 16/20] removed ndb grep from configure .in --- configure.in | 1 - .../blocks/dblqh/redoLogReader/Makefile | 9 - ndb/src/kernel/blocks/grep/Grep.cpp | 2010 ----------------- ndb/src/kernel/blocks/grep/Grep.hpp | 535 ----- ndb/src/kernel/blocks/grep/GrepInit.cpp | 164 -- ndb/src/kernel/blocks/grep/Makefile.am | 23 - .../kernel/blocks/grep/systab_test/Makefile | 12 - .../grep/systab_test/grep_systab_test.cpp | 138 -- ndb/test/ndbapi/testGrep.cpp | 540 ----- 9 files changed, 3432 deletions(-) delete mode 100644 ndb/src/kernel/blocks/dblqh/redoLogReader/Makefile delete mode 100644 ndb/src/kernel/blocks/grep/Grep.cpp delete mode 100644 ndb/src/kernel/blocks/grep/Grep.hpp delete mode 100644 ndb/src/kernel/blocks/grep/GrepInit.cpp delete mode 100644 ndb/src/kernel/blocks/grep/Makefile.am delete mode 100644 ndb/src/kernel/blocks/grep/systab_test/Makefile delete mode 100644 ndb/src/kernel/blocks/grep/systab_test/grep_systab_test.cpp delete mode 100644 ndb/test/ndbapi/testGrep.cpp diff --git a/configure.in b/configure.in index 9e370dfa680..b9ad38fb59d 100644 --- a/configure.in +++ b/configure.in @@ -3281,7 +3281,6 @@ AC_CONFIG_FILES(ndb/Makefile ndb/include/Makefile dnl ndb/src/kernel/blocks/backup/Makefile dnl ndb/src/kernel/blocks/dbutil/Makefile dnl ndb/src/kernel/blocks/suma/Makefile dnl - ndb/src/kernel/blocks/grep/Makefile dnl ndb/src/kernel/blocks/dbtux/Makefile dnl ndb/src/kernel/vm/Makefile dnl ndb/src/mgmapi/Makefile dnl diff --git a/ndb/src/kernel/blocks/dblqh/redoLogReader/Makefile b/ndb/src/kernel/blocks/dblqh/redoLogReader/Makefile deleted file mode 100644 index a89b648de77..00000000000 --- a/ndb/src/kernel/blocks/dblqh/redoLogReader/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include .defs.mk - -BIN_TARGET := redoLogFileReader - -SOURCES := records.cpp redoLogFileReader.cpp - -TYPE := util - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/grep/Grep.cpp b/ndb/src/kernel/blocks/grep/Grep.cpp deleted file mode 100644 index e89361dab06..00000000000 --- a/ndb/src/kernel/blocks/grep/Grep.cpp +++ /dev/null @@ -1,2010 +0,0 @@ -/* 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 */ - -#include "Grep.hpp" -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CONTINUEB_DELAY 500 -#define SSREPBLOCKNO 2 -#define PSREPBLOCKNO 2 - -//#define DEBUG_GREP -//#define DEBUG_GREP_SUBSCRIPTION -//#define DEBUG_GREP_TRANSFER -//#define DEBUG_GREP_APPLY -//#define DEBUG_GREP_DELETE - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: STARTUP of GREP Block, etc - * ------------------------------------------------------------------------ - **************************************************************************/ -static Uint32 g_TypeOfStart = NodeState::ST_ILLEGAL_TYPE; -void -Grep::getNodeGroupMembers(Signal* signal) { - jam(); - /** - * Ask DIH for nodeGroupMembers - */ - CheckNodeGroups * sd = (CheckNodeGroups*)signal->getDataPtrSend(); - sd->blockRef = reference(); - sd->requestType = - CheckNodeGroups::Direct | - CheckNodeGroups::GetNodeGroupMembers; - sd->nodeId = getOwnNodeId(); - EXECUTE_DIRECT(DBDIH, GSN_CHECKNODEGROUPSREQ, signal, - CheckNodeGroups::SignalLength); - jamEntry(); - - c_nodeGroup = sd->output; - c_noNodesInGroup = 0; - for (int i = 0; i < MAX_NDB_NODES; i++) { - if (sd->mask.get(i)) { - if (i == getOwnNodeId()) c_idInNodeGroup = c_noNodesInGroup; - c_nodesInGroup[c_noNodesInGroup] = i; - c_noNodesInGroup++; - } - } - ndbrequire(c_noNodesInGroup > 0); // at least 1 node in the nodegroup - -#ifdef NODEFAIL_DEBUG - for (Uint32 i = 0; i < c_noNodesInGroup; i++) { - ndbout_c ("Grep: NodeGroup %u, me %u, me in group %u, member[%u] %u", - c_nodeGroup, getOwnNodeId(), c_idInNodeGroup, - i, c_nodesInGroup[i]); - } -#endif -} - - -void -Grep::execSTTOR(Signal* signal) -{ - jamEntry(); - const Uint32 startphase = signal->theData[1]; - const Uint32 typeOfStart = signal->theData[7]; - if (startphase == 3) - { - jam(); - signal->theData[0] = reference(); - g_TypeOfStart = typeOfStart; - sendSignal(NDBCNTR_REF, GSN_READ_NODESREQ, signal, 1, JBB); - return; - } - if(startphase == 5) { - jam(); - /** - * we don't want any log/meta records comming to use - * until we are done with the recovery. - */ - if (g_TypeOfStart == NodeState::ST_NODE_RESTART) { - jam(); - pspart.m_recoveryMode = true; - getNodeGroupMembers(signal); - for (Uint32 i = 0; i < c_noNodesInGroup; i++) { - Uint32 ref =numberToRef(GREP, c_nodesInGroup[i]); - if (ref != reference()) - sendSignal(ref, GSN_GREP_START_ME, signal, - 1 /*SumaStartMe::SignalLength*/, JBB); - } - } else pspart.m_recoveryMode = false; - - } - - if(startphase == 7) { - jam(); - if (g_TypeOfStart == NodeState::ST_NODE_RESTART) { - pspart.m_recoveryMode = false; - } - } - - sendSTTORRY(signal); -} - - -void -Grep::PSPart::execSTART_ME(Signal* signal) -{ - jamEntry(); - GrepStartMe * me =(GrepStartMe*)signal->getDataPtr(); - BlockReference ref = me->senderRef; - GrepAddSubReq* const addReq = (GrepAddSubReq *)signal->getDataPtr(); - - - SubscriptionPtr subPtr; - c_subscriptions.first(c_subPtr); - for(; !c_subPtr.isNull(); c_subscriptions.next(c_subPtr)) { - jam(); - subPtr.i = c_subPtr.curr.i; - subPtr.p = c_subscriptions.getPtr(subPtr.i); - addReq->subscriptionId = subPtr.p->m_subscriptionId; - addReq->subscriptionKey = subPtr.p->m_subscriptionKey; - addReq->subscriberData = subPtr.p->m_subscriberData; - addReq->subscriptionType = subPtr.p->m_subscriptionType; - addReq->senderRef = subPtr.p->m_coordinatorRef; - addReq->subscriberRef =subPtr.p->m_subscriberRef; - - sendSignal(ref, - GSN_GREP_ADD_SUB_REQ, - signal, - GrepAddSubReq::SignalLength, - JBB); - } - - addReq->subscriptionId = 0; - addReq->subscriptionKey = 0; - addReq->subscriberData = 0; - addReq->subscriptionType = 0; - addReq->senderRef = 0; - addReq->subscriberRef = 0; - - sendSignal(ref, - GSN_GREP_ADD_SUB_REQ, - signal, - GrepAddSubReq::SignalLength, - JBB); -} - -void -Grep::PSPart::execGREP_ADD_SUB_REQ(Signal* signal) -{ - jamEntry(); - GrepAddSubReq * const grepReq = (GrepAddSubReq *)signal->getDataPtr(); - const Uint32 subId = grepReq->subscriptionId; - const Uint32 subKey = grepReq->subscriptionKey; - const Uint32 subData = grepReq->subscriberData; - const Uint32 subType = grepReq->subscriptionType; - const Uint32 coordinatorRef = grepReq->senderRef; - - /** - * this is ref to the REP node for this subscription. - */ - const Uint32 subRef = grepReq->subscriberRef; - - if(subId!=0 && subKey!=0) { - jam(); - SubscriptionPtr subPtr; - ndbrequire( c_subscriptionPool.seize(subPtr)); - subPtr.p->m_coordinatorRef = coordinatorRef; - subPtr.p->m_subscriptionId = subId; - subPtr.p->m_subscriptionKey = subKey; - subPtr.p->m_subscriberRef = subRef; - subPtr.p->m_subscriberData = subData; - subPtr.p->m_subscriptionType = subType; - - c_subscriptions.add(subPtr); - } - else { - jam(); - GrepAddSubConf * conf = (GrepAddSubConf *)grepReq; - conf->noOfSub = - c_subscriptionPool.getSize()-c_subscriptionPool.getNoOfFree(); - sendSignal(signal->getSendersBlockRef(), - GSN_GREP_ADD_SUB_CONF, - signal, - GrepAddSubConf::SignalLength, - JBB); - } -} - -void -Grep::PSPart::execGREP_ADD_SUB_REF(Signal* signal) -{ - /** - * @todo fix error stuff - */ -} - -void -Grep::PSPart::execGREP_ADD_SUB_CONF(Signal* signal) -{ - jamEntry(); - GrepAddSubConf* const conf = (GrepAddSubConf *)signal->getDataPtr(); - Uint32 noOfSubscriptions = conf->noOfSub; - Uint32 noOfRestoredSubscriptions = - c_subscriptionPool.getSize()-c_subscriptionPool.getNoOfFree(); - if(noOfSubscriptions!=noOfRestoredSubscriptions) { - jam(); - /** - *@todo send ref signal - */ - ndbrequire(false); - } -} - -void -Grep::execREAD_NODESCONF(Signal* signal) -{ - jamEntry(); - ReadNodesConf * conf = (ReadNodesConf *)signal->getDataPtr(); - -#if 0 - ndbout_c("Grep: Recd READ_NODESCONF"); -#endif - - /****************************** - * Check which REP nodes exist - ******************************/ - Uint32 i; - for (i = 1; i < MAX_NODES; i++) - { - jam(); -#if 0 - ndbout_c("Grep: Found node %d of type %d", i, getNodeInfo(i).getType()); -#endif - if (getNodeInfo(i).getType() == NodeInfo::REP) - { - jam(); - /** - * @todo This should work for more than ONE rep node! - */ - pscoord.m_repRef = numberToRef(PSREPBLOCKNO, i); - pspart.m_repRef = numberToRef(PSREPBLOCKNO, i); -#if 0 - ndbout_c("Grep: REP node %d detected", i); -#endif - } - } - - /***************************** - * Check which DB nodes exist - *****************************/ - m_aliveNodes.clear(); - - Uint32 count = 0; - for(i = 0; iallNodes, i)) - { - jam(); - count++; - - NodePtr node; - ndbrequire(m_nodes.seize(node)); - - node.p->nodeId = i; - if (NodeBitmask::get(conf->inactiveNodes, i)) - { - node.p->alive = 0; - } - else - { - node.p->alive = 1; - m_aliveNodes.set(i); - } - } - } - m_masterNodeId = conf->masterNodeId; - ndbrequire(count == conf->noOfNodes); - sendSTTORRY(signal); -} - -void -Grep::sendSTTORRY(Signal* signal) -{ - signal->theData[0] = 0; - signal->theData[3] = 1; - signal->theData[4] = 3; - signal->theData[5] = 5; - signal->theData[6] = 7; - signal->theData[7] = 255; // No more start phases from missra - sendSignal(NDBCNTR_REF, GSN_STTORRY, signal, 8, JBB); -} - -void -Grep::execNDB_STTOR(Signal* signal) -{ - jamEntry(); -} - -void -Grep::execDUMP_STATE_ORD(Signal* signal) -{ - jamEntry(); - //Uint32 tCase = signal->theData[0]; - -#if 0 - if(sscoord.m_repRef == 0) - { - ndbout << "Grep: Recd DUMP signal but has no connection with REP node" - << endl; - return; - } -#endif - - /* - switch (tCase) - { - case 8100: sscoord.grepReq(signal, GrepReq::START_SUBSCR); break; - case 8102: sscoord.grepReq(signal, GrepReq::START_METALOG); break; - case 8104: sscoord.grepReq(signal, GrepReq::START_METASCAN); break; - case 8106: sscoord.grepReq(signal, GrepReq::START_DATALOG); break; - case 8108: sscoord.grepReq(signal, GrepReq::START_DATASCAN); break; - case 8110: sscoord.grepReq(signal, GrepReq::STOP_SUBSCR); break; - case 8500: sscoord.grepReq(signal, GrepReq::REMOVE_BUFFERS); break; - case 8300: sscoord.grepReq(signal, GrepReq::SLOWSTOP); break; - case 8400: sscoord.grepReq(signal, GrepReq::FASTSTOP); break; - case 8600: sscoord.grepReq(signal, GrepReq::CREATE_SUBSCR); break; - case 8700: sscoord.dropTable(signal,(Uint32)signal->theData[1]);break; - default: break; - } - */ -} - -/** - * Signal received when REP node has failed - */ -void -Grep::execAPI_FAILREQ(Signal* signal) -{ - jamEntry(); - //Uint32 failedApiNode = signal->theData[0]; - //BlockReference retRef = signal->theData[1]; - - /** - * @todo We should probably do something smart if the - * PS REP node fails???? /Lars - */ - -#if 0 - ndbout_c("Grep: API_FAILREQ received for API node %d.", failedApiNode); -#endif - - /** - * @note This signal received is NOT allowed to send any CONF - * signal, since this would screw up TC/DICT to API - * "connections". - */ -} - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: GREP Control - * ------------------------------------------------------------------------ - **************************************************************************/ -void -Grep::execGREP_REQ(Signal* signal) -{ - jamEntry(); - - //GrepReq * req = (GrepReq *)signal->getDataPtr(); - - /** - * @todo Fix so that request is redirected to REP Server - * Obsolete? - * Was: sscoord.grepReq(signal, req->request); - */ - ndbout_c("Warning! REP commands can only be executed at REP SERVER prompt!"); -} - - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: NODE STATE HANDLING - * ------------------------------------------------------------------------ - **************************************************************************/ -void -Grep::execNODE_FAILREP(Signal* signal) -{ - jamEntry(); - NodeFailRep * rep = (NodeFailRep*)signal->getDataPtr(); - bool changed = false; - - NodePtr nodePtr; - for(m_nodes.first(nodePtr); nodePtr.i != RNIL; m_nodes.next(nodePtr)) - { - jam(); - if (NodeBitmask::get(rep->theNodes, nodePtr.p->nodeId)) - { - jam(); - - if (nodePtr.p->alive) - { - jam(); - ndbassert(m_aliveNodes.get(nodePtr.p->nodeId)); - changed = true; - } - else - { - ndbassert(!m_aliveNodes.get(nodePtr.p->nodeId)); - } - - nodePtr.p->alive = 0; - m_aliveNodes.clear(nodePtr.p->nodeId); - } - } - - - /** - * Problem: Fix a node failure running a protocol - * - * 1. Coordinator node of a protocol dies - * - Elect a new coordinator - * - send ref to user - * - * 2. Non-coordinator dies. - * - make coordinator aware of this - * so that coordinator does not wait for - * conf from faulty node - * - node recovery will restore the non-coordinator. - * - */ -} - -void -Grep::execINCL_NODEREQ(Signal* signal) -{ - jamEntry(); - - //const Uint32 senderRef = signal->theData[0]; - const Uint32 inclNode = signal->theData[1]; - - NodePtr node; - for(m_nodes.first(node); node.i != RNIL; m_nodes.next(node)) - { - jam(); - const Uint32 nodeId = node.p->nodeId; - if (inclNode == nodeId) { - jam(); - - ndbrequire(node.p->alive == 0); - ndbassert(!m_aliveNodes.get(nodeId)); - - node.p->alive = 1; - m_aliveNodes.set(nodeId); - - break; - } - } - - /** - * @todo: if we include this DIH's got to be prepared, later if needed... - */ -#if 0 - signal->theData[0] = reference(); - - sendSignal(senderRef, GSN_INCL_NODECONF, signal, 1, JBB); -#endif -} - - -/** - * Helper methods - */ -void -Grep::PSCoord::prepareOperationRec(SubCoordinatorPtr subPtr, - BlockReference subscriber, - Uint32 subId, - Uint32 subKey, - Uint32 request) -{ - subPtr.p->m_coordinatorRef = reference(); - subPtr.p->m_subscriberRef = subscriber; - subPtr.p->m_subscriberData = subPtr.i; - subPtr.p->m_subscriptionId = subId; - subPtr.p->m_subscriptionKey = subKey; - subPtr.p->m_outstandingRequest = request; -} - - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: CREATE SUBSCRIPTION ID - * ------------------------------------------------------------------------ - * - * Requests SUMA to create a unique subscription id - **************************************************************************/ - -void -Grep::PSCoord::execGREP_CREATE_SUBID_REQ(Signal* signal) -{ - jamEntry(); - - CreateSubscriptionIdReq * req = - (CreateSubscriptionIdReq*)signal->getDataPtr(); - BlockReference ref = signal->getSendersBlockRef(); - - SubCoordinatorPtr subPtr; - if( !c_subCoordinatorPool.seize(subPtr)) { - jam(); - SubCoordinator sub; - sub.m_subscriberRef = ref; - sub.m_subscriptionId = 0; - sub.m_subscriptionKey = 0; - sendRefToSS(signal, sub, GrepError::SUBSCRIPTION_ID_NOMEM ); - return; - } - prepareOperationRec(subPtr, - ref, - 0,0, - GSN_CREATE_SUBID_REQ); - - - ndbout_c("SUBID_REQ Ref %d",ref); - req->senderData=subPtr.p->m_subscriberData; - - sendSignal(SUMA_REF, GSN_CREATE_SUBID_REQ, signal, - SubCreateReq::SignalLength, JBB); - -#if 1 //def DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSCoord: Sent CREATE_SUBID_REQ to SUMA"); -#endif -} - -void -Grep::PSCoord::execCREATE_SUBID_CONF(Signal* signal) -{ - jamEntry(); - CreateSubscriptionIdConf const * conf = - (CreateSubscriptionIdConf *)signal->getDataPtr(); - Uint32 subId = conf->subscriptionId; - Uint32 subKey = conf->subscriptionKey; - Uint32 subData = conf->subscriberData; - -#if 1 //def DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSCoord: Recd GREP_SUBID_CONF (subId:%d, subKey:%d)", - subId, subKey); -#endif - - SubCoordinatorPtr subPtr; - c_subCoordinatorPool.getPtr(subPtr, subData); - BlockReference repRef = subPtr.p->m_subscriberRef; - - { // Check that id/key is unique - SubCoordinator key; - SubCoordinatorPtr tmp; - key.m_subscriptionId = subId; - key.m_subscriptionKey = subKey; - if(c_runningSubscriptions.find(tmp, key)){ - jam(); - SubCoordinator sub; - sub.m_subscriberRef=repRef; - sub.m_subscriptionId = subId; - sub.m_subscriptionKey = subKey; - sendRefToSS(signal,sub, GrepError::SUBSCRIPTION_ID_NOT_UNIQUE ); - return; - } - } - - sendSignal(subPtr.p->m_subscriberRef, GSN_GREP_CREATE_SUBID_CONF, signal, - CreateSubscriptionIdConf::SignalLength, JBB); - c_subCoordinatorPool.release(subData); - - m_grep->sendEventRep(signal, - EventReport::GrepSubscriptionInfo, - GrepEvent::GrepPS_CreateSubIdConf, - subId, - subKey, - (Uint32)GrepError::GE_NO_ERROR); -} - -void -Grep::PSCoord::execCREATE_SUBID_REF(Signal* signal) { - jamEntry(); - CreateSubscriptionIdRef const * ref = - (CreateSubscriptionIdRef *)signal->getDataPtr(); - Uint32 subData = ref->subscriberData; - GrepError::GE_Code err; - - Uint32 sendersBlockRef = signal->getSendersBlockRef(); - if(sendersBlockRef == SUMA_REF) - { - jam(); - err = GrepError::SUBSCRIPTION_ID_SUMA_FAILED_CREATE; - } else { - jam(); - ndbrequire(false); /* Added since errorcode err unhandled - * TODO: fix correct errorcode - */ - err= GrepError::GE_NO_ERROR; // remove compiler warning - } - - SubCoordinatorPtr subPtr; - c_runningSubscriptions.getPtr(subPtr, subData); - BlockReference repref = subPtr.p->m_subscriberRef; - - SubCoordinator sub; - sub.m_subscriberRef = repref; - sub.m_subscriptionId = 0; - sub.m_subscriptionKey = 0; - sendRefToSS(signal,sub, err); - -} - - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: CREATE SUBSCRIPTION - * ------------------------------------------------------------------------ - * - * Creates a subscription for every GREP to its local SUMA. - * GREP node that executes createSubscription becomes the GREP Coord. - **************************************************************************/ - -/** - * Request to create a subscription (sent from SS) - */ -void -Grep::PSCoord::execGREP_SUB_CREATE_REQ(Signal* signal) -{ - jamEntry(); - GrepSubCreateReq const * grepReq = (GrepSubCreateReq *)signal->getDataPtr(); - Uint32 subId = grepReq->subscriptionId; - Uint32 subKey = grepReq->subscriptionKey; - Uint32 subType = grepReq->subscriptionType; - BlockReference rep = signal->getSendersBlockRef(); - - GrepCreateReq * req =(GrepCreateReq*)grepReq; - - SubCoordinatorPtr subPtr; - - if( !c_subCoordinatorPool.seize(subPtr)) { - jam(); - SubCoordinator sub; - sub.m_subscriberRef = rep; - sub.m_subscriptionId = 0; - sub.m_subscriptionKey = 0; - sub.m_outstandingRequest = GSN_GREP_CREATE_REQ; - sendRefToSS(signal, sub, GrepError::NOSPACE_IN_POOL); - return; - } - prepareOperationRec(subPtr, - numberToRef(PSREPBLOCKNO, refToNode(rep)), subId, subKey, - GSN_GREP_CREATE_REQ); - - /* Get the payload of the signal. - */ - SegmentedSectionPtr selectedTablesPtr; - if(subType == SubCreateReq::SelectiveTableSnapshot) { - jam(); - ndbrequire(signal->getNoOfSections()==1); - signal->getSection(selectedTablesPtr,0); - signal->header.m_noOfSections = 0; - } - /** - * Prepare the signal to be sent to Grep participatns - */ - subPtr.p->m_subscriptionType = subType; - req->senderRef = reference(); - req->subscriberRef = numberToRef(PSREPBLOCKNO, refToNode(rep)); - req->subscriberData = subPtr.p->m_subscriberData; - req->subscriptionId = subId; - req->subscriptionKey = subKey; - req->subscriptionType = subType; - - /*add payload if it is a selectivetablesnap*/ - if(subType == SubCreateReq::SelectiveTableSnapshot) { - jam(); - signal->setSection(selectedTablesPtr, 0); - } - - /****************************** - * Send to all PS participants - ******************************/ - NodeReceiverGroup rg(GREP, m_grep->m_aliveNodes); - subPtr.p->m_outstandingParticipants = rg; - sendSignal(rg, - GSN_GREP_CREATE_REQ, signal, - GrepCreateReq::SignalLength, JBB); - - -#ifdef DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSCoord: Sent GREP_CREATE_REQ " - "(subId:%d, subKey:%d, subData:%d, subType:%d) to parts", - subId, subKey, subPtr.p->m_subscriberData, subType); -#endif -} - -void -Grep::PSPart::execGREP_CREATE_REQ(Signal* signal) -{ - jamEntry(); - GrepCreateReq * const grepReq = (GrepCreateReq *)signal->getDataPtr(); - const Uint32 subId = grepReq->subscriptionId; - const Uint32 subKey = grepReq->subscriptionKey; - const Uint32 subData = grepReq->subscriberData; - const Uint32 subType = grepReq->subscriptionType; - const Uint32 coordinatorRef = grepReq->senderRef; - const Uint32 subRef = grepReq->subscriberRef; //this is ref to the - //REP node for this - //subscription. - - SubscriptionPtr subPtr; - ndbrequire( c_subscriptionPool.seize(subPtr)); - subPtr.p->m_coordinatorRef = coordinatorRef; - subPtr.p->m_subscriptionId = subId; - subPtr.p->m_subscriptionKey = subKey; - subPtr.p->m_subscriberRef = subRef; - subPtr.p->m_subscriberData = subPtr.i; - subPtr.p->m_subscriptionType = subType; - subPtr.p->m_outstandingRequest = GSN_GREP_CREATE_REQ; - subPtr.p->m_operationPtrI = subData; - - c_subscriptions.add(subPtr); - - SegmentedSectionPtr selectedTablesPtr; - if(subType == SubCreateReq::SelectiveTableSnapshot) { - jam(); - ndbrequire(signal->getNoOfSections()==1); - signal->getSection(selectedTablesPtr,0);// SubCreateReq::TABLE_LIST); - signal->header.m_noOfSections = 0; - } - - /** - * Prepare signal to be sent to SUMA - */ - SubCreateReq * sumaReq = (SubCreateReq *)grepReq; - sumaReq->subscriberRef = GREP_REF; - sumaReq->subscriberData = subPtr.p->m_subscriberData; - sumaReq->subscriptionId = subPtr.p->m_subscriptionId; - sumaReq->subscriptionKey = subPtr.p->m_subscriptionKey; - sumaReq->subscriptionType = subPtr.p->m_subscriptionType; - /*add payload if it is a selectivetablesnap*/ - if(subType == SubCreateReq::SelectiveTableSnapshot) { - jam(); - signal->setSection(selectedTablesPtr, 0); - } - sendSignal(SUMA_REF, - GSN_SUB_CREATE_REQ, - signal, - SubCreateReq::SignalLength, - JBB); -} - -void -Grep::PSPart::execSUB_CREATE_CONF(Signal* signal) -{ - jamEntry(); - - SubCreateConf * const conf = (SubCreateConf *)signal->getDataPtr(); - Uint32 subData = conf->subscriberData; - - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - /** - @todo check why this can fuck up -johan - - ndbrequire(subPtr.p->m_subscriptionId == conf->subscriptionId); - ndbrequire(subPtr.p->m_subscriptionKey == conf->subscriptionKey); - */ -#ifdef DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSPart: Recd SUB_CREATE_CONF " - "(subId:%d, subKey:%d) from SUMA", - conf->subscriptionId, conf->subscriptionKey); -#endif - - /********************* - * Send conf to coord - *********************/ - GrepCreateConf * grepConf = (GrepCreateConf*)conf; - grepConf->senderNodeId = getOwnNodeId(); - grepConf->senderData = subPtr.p->m_operationPtrI; - sendSignal(subPtr.p->m_coordinatorRef, GSN_GREP_CREATE_CONF, signal, - GrepCreateConf::SignalLength, JBB); - subPtr.p->m_outstandingRequest = 0; -} - -/** - * Handle errors that either occured in: - * 1) PSPart - * or - * 2) propagated from local SUMA - */ -void -Grep::PSPart::execSUB_CREATE_REF(Signal* signal) -{ - jamEntry(); - SubCreateRef * const ref = (SubCreateRef *)signal->getDataPtr(); - Uint32 subData = ref->subscriberData; - GrepError::GE_Code err = (GrepError::GE_Code)ref->err; - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - sendRefToPSCoord(signal, *subPtr.p, err /*error*/); - subPtr.p->m_outstandingRequest = 0; -} - -void -Grep::PSCoord::execGREP_CREATE_CONF(Signal* signal) -{ - jamEntry(); - GrepCreateConf const * conf = (GrepCreateConf *)signal->getDataPtr(); - Uint32 subData = conf->senderData; - Uint32 nodeId = conf->senderNodeId; - - SubCoordinatorPtr subPtr; - c_subCoordinatorPool.getPtr(subPtr, subData); - - ndbrequire(subPtr.p->m_outstandingRequest == GSN_GREP_CREATE_REQ); - - subPtr.p->m_outstandingParticipants.clearWaitingFor(nodeId); - - if(!subPtr.p->m_outstandingParticipants.done()) return; - /******************************** - * All participants have CONF:ed - ********************************/ - Uint32 subId = subPtr.p->m_subscriptionId; - Uint32 subKey = subPtr.p->m_subscriptionKey; - - GrepSubCreateConf * grepConf = (GrepSubCreateConf *)signal->getDataPtr(); - grepConf->subscriptionId = subId; - grepConf->subscriptionKey = subKey; - sendSignal(subPtr.p->m_subscriberRef, GSN_GREP_SUB_CREATE_CONF, signal, - GrepSubCreateConf::SignalLength, JBB); - - /** - * Send event report - */ - m_grep->sendEventRep(signal, - EventReport::GrepSubscriptionInfo, - GrepEvent::GrepPS_SubCreateConf, - subId, - subKey, - (Uint32)GrepError::GE_NO_ERROR); - - c_subCoordinatorPool.release(subPtr); - -} - -/** - * Handle errors that either occured in: - * 1) PSCoord - * or - * 2) propagated from PSPart - */ -void -Grep::PSCoord::execGREP_CREATE_REF(Signal* signal) -{ - jamEntry(); - GrepCreateRef * const ref = (GrepCreateRef *)signal->getDataPtr(); - Uint32 subData = ref->senderData; - Uint32 err = ref->err; - SubCoordinatorPtr subPtr; - c_runningSubscriptions.getPtr(subPtr, subData); - - sendRefToSS(signal, *subPtr.p, (GrepError::GE_Code)err /*error*/); -} - - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: START SUBSCRIPTION - * ------------------------------------------------------------------------ - * - * Starts a subscription at SUMA. - * Each participant starts its own subscription. - **************************************************************************/ - -/** - * Request to start subscription (Sent from SS) - */ -void -Grep::PSCoord::execGREP_SUB_START_REQ(Signal* signal) -{ - jamEntry(); - GrepSubStartReq * const subReq = (GrepSubStartReq *)signal->getDataPtr(); - SubscriptionData::Part part = (SubscriptionData::Part) subReq->part; - Uint32 subId = subReq->subscriptionId; - Uint32 subKey = subReq->subscriptionKey; - BlockReference rep = signal->getSendersBlockRef(); - - SubCoordinatorPtr subPtr; - - if(!c_subCoordinatorPool.seize(subPtr)) { - jam(); - SubCoordinator sub; - sub.m_subscriberRef = rep; - sub.m_subscriptionId = 0; - sub.m_subscriptionKey = 0; - sub.m_outstandingRequest = GSN_GREP_START_REQ; - sendRefToSS(signal, sub, GrepError::NOSPACE_IN_POOL); - return; - } - - prepareOperationRec(subPtr, - numberToRef(PSREPBLOCKNO, refToNode(rep)), - subId, subKey, - GSN_GREP_START_REQ); - - GrepStartReq * const req = (GrepStartReq *) subReq; - req->part = (Uint32) part; - req->subscriptionId = subPtr.p->m_subscriptionId; - req->subscriptionKey = subPtr.p->m_subscriptionKey; - req->senderData = subPtr.p->m_subscriberData; - - /*************************** - * Send to all participants - ***************************/ - NodeReceiverGroup rg(GREP, m_grep->m_aliveNodes); - subPtr.p->m_outstandingParticipants = rg; - sendSignal(rg, - GSN_GREP_START_REQ, - signal, - GrepStartReq::SignalLength, JBB); - -#ifdef DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSCoord: Sent GREP_START_REQ " - "(subId:%d, subKey:%d, senderData:%d, part:%d) to all participants", - req->subscriptionId, req->subscriptionKey, req->senderData, part); -#endif -} - - -void -Grep::PSPart::execGREP_START_REQ(Signal* signal) -{ - jamEntry(); - GrepStartReq * const grepReq = (GrepStartReq *) signal->getDataPtr(); - SubscriptionData::Part part = (SubscriptionData::Part)grepReq->part; - Uint32 subId = grepReq->subscriptionId; - Uint32 subKey = grepReq->subscriptionKey; - Uint32 operationPtrI = grepReq->senderData; - - Subscription key; - key.m_subscriptionId = subId; - key.m_subscriptionKey = subKey; - SubscriptionPtr subPtr; - ndbrequire(c_subscriptions.find(subPtr, key));; - subPtr.p->m_outstandingRequest = GSN_GREP_START_REQ; - subPtr.p->m_operationPtrI = operationPtrI; - /** - * send SUB_START_REQ to local SUMA - */ - SubStartReq * sumaReq = (SubStartReq *) grepReq; - sumaReq->subscriptionId = subId; - sumaReq->subscriptionKey = subKey; - sumaReq->subscriberData = subPtr.i; - sumaReq->part = (Uint32) part; - - sendSignal(SUMA_REF, GSN_SUB_START_REQ, signal, - SubStartReq::SignalLength, JBB); -#ifdef DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSPart: Sent SUB_START_REQ (subId:%d, subKey:%d, part:%d)", - subId, subKey, (Uint32)part); -#endif -} - - -void -Grep::PSPart::execSUB_START_CONF(Signal* signal) -{ - jamEntry(); - - SubStartConf * const conf = (SubStartConf *) signal->getDataPtr(); - SubscriptionData::Part part = (SubscriptionData::Part)conf->part; - Uint32 subId = conf->subscriptionId; - Uint32 subKey = conf->subscriptionKey; - Uint32 subData = conf->subscriberData; - Uint32 firstGCI = conf->firstGCI; -#ifdef DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSPart: Recd SUB_START_CONF " - "(subId:%d, subKey:%d, subData:%d)", - subId, subKey, subData); -#endif - - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - ndbrequire(subPtr.p->m_subscriptionId == subId); - ndbrequire(subPtr.p->m_subscriptionKey == subKey); - - GrepStartConf * grepConf = (GrepStartConf *)conf; - grepConf->senderData = subPtr.p->m_operationPtrI; - grepConf->part = (Uint32) part; - grepConf->subscriptionKey = subKey; - grepConf->subscriptionId = subId; - grepConf->firstGCI = firstGCI; - grepConf->senderNodeId = getOwnNodeId(); - sendSignal(subPtr.p->m_coordinatorRef, GSN_GREP_START_CONF, signal, - GrepStartConf::SignalLength, JBB); - subPtr.p->m_outstandingRequest = 0; - -#ifdef DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSPart: Sent GREP_START_CONF " - "(subId:%d, subKey:%d, subData:%d, part:%d)", - subId, subKey, subData, part); -#endif -} - - -/** - * Handle errors that either occured in: - * 1) PSPart - * or - * 2) propagated from local SUMA - * - * Propagates REF signal to PSCoord - */ -void -Grep::PSPart::execSUB_START_REF(Signal* signal) -{ - SubStartRef * const ref = (SubStartRef *)signal->getDataPtr(); - Uint32 subData = ref->subscriberData; - GrepError::GE_Code err = (GrepError::GE_Code)ref->err; - SubscriptionData::Part part = (SubscriptionData::Part)ref->part; - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - sendRefToPSCoord(signal, *subPtr.p, err /*error*/, part); - subPtr.p->m_outstandingRequest = 0; -} - - -/** - * Logging has started... (says PS Participant) - */ -void -Grep::PSCoord::execGREP_START_CONF(Signal* signal) -{ - jamEntry(); - - GrepStartConf * const conf = (GrepStartConf *) signal->getDataPtr(); - Uint32 subData = conf->senderData; - SubscriptionData::Part part = (SubscriptionData::Part)conf->part; - Uint32 subId = conf->subscriptionId; - Uint32 subKey = conf->subscriptionKey; - Uint32 firstGCI = conf->firstGCI; - - SubCoordinatorPtr subPtr; - c_subCoordinatorPool.getPtr(subPtr, subData); - ndbrequire(subPtr.p->m_outstandingRequest == GSN_GREP_START_REQ); - - subPtr.p->m_outstandingParticipants.clearWaitingFor(conf->senderNodeId); - - if(!subPtr.p->m_outstandingParticipants.done()) return; - jam(); - - /************************* - * All participants ready - *************************/ - GrepSubStartConf * grepConf = (GrepSubStartConf *) conf; - grepConf->part = part; - grepConf->subscriptionId = subId; - grepConf->subscriptionKey = subKey; - grepConf->firstGCI = firstGCI; - - bool ok = false; - switch(part) { - case SubscriptionData::MetaData: - ok = true; - sendSignal(subPtr.p->m_subscriberRef, GSN_GREP_SUB_START_CONF, signal, - GrepSubStartConf::SignalLength, JBB); - - /** - * Send event report - */ - m_grep->sendEventRep(signal, - EventReport::GrepSubscriptionInfo, - GrepEvent::GrepPS_SubStartMetaConf, - subId, subKey, - (Uint32)GrepError::GE_NO_ERROR); - - c_subCoordinatorPool.release(subPtr); - break; - case SubscriptionData::TableData: - ok = true; - sendSignal(subPtr.p->m_subscriberRef, GSN_GREP_SUB_START_CONF, signal, - GrepSubStartConf::SignalLength, JBB); - - /** - * Send event report - */ - m_grep->sendEventRep(signal, - EventReport::GrepSubscriptionInfo, - GrepEvent::GrepPS_SubStartDataConf, - subId, subKey, - (Uint32)GrepError::GE_NO_ERROR); - - - c_subCoordinatorPool.release(subPtr); - break; - } - ndbrequire(ok); - -#ifdef DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSCoord: Recd SUB_START_CONF (subId:%d, subKey:%d, part:%d) " - "from all slaves", - subId, subKey, (Uint32)part); -#endif -} - -/** - * Handle errors that either occured in: - * 1) PSCoord - * or - * 2) propagated from PSPart - */ -void -Grep::PSCoord::execGREP_START_REF(Signal* signal) -{ - jamEntry(); - GrepStartRef * const ref = (GrepStartRef *)signal->getDataPtr(); - Uint32 subData = ref->senderData; - GrepError::GE_Code err = (GrepError::GE_Code)ref->err; - SubscriptionData::Part part = (SubscriptionData::Part)ref->part; - - SubCoordinatorPtr subPtr; - c_runningSubscriptions.getPtr(subPtr, subData); - sendRefToSS(signal, *subPtr.p, err /*error*/, part); -} - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: REMOVE SUBSCRIPTION - * ------------------------------------------------------------------------ - * - * Remove a subscription at SUMA. - * Each participant removes its own subscription. - * We start by deleting the subscription inside the requestor - * since, we don't know if nodes (REP nodes or DB nodes) - * have disconnected after we sent out this and - * if we dont delete the sub in the requestor now, - * we won't be able to create a new subscription - **************************************************************************/ - -/** - * Request to abort subscription (Sent from SS) - */ -void -Grep::PSCoord::execGREP_SUB_REMOVE_REQ(Signal* signal) -{ - jamEntry(); - GrepSubRemoveReq * const subReq = (GrepSubRemoveReq *)signal->getDataPtr(); - Uint32 subId = subReq->subscriptionId; - Uint32 subKey = subReq->subscriptionKey; - BlockReference rep = signal->getSendersBlockRef(); - - SubCoordinatorPtr subPtr; - if( !c_subCoordinatorPool.seize(subPtr)) { - jam(); - SubCoordinator sub; - sub.m_subscriberRef = rep; - sub.m_subscriptionId = 0; - sub.m_subscriptionKey = 0; - sub.m_outstandingRequest = GSN_GREP_REMOVE_REQ; - sendRefToSS(signal, sub, GrepError::NOSPACE_IN_POOL); - return; - } - - - prepareOperationRec(subPtr, - numberToRef(PSREPBLOCKNO, refToNode(rep)), - subId, subKey, - GSN_GREP_REMOVE_REQ); - - c_runningSubscriptions.add(subPtr); - - GrepRemoveReq * req = (GrepRemoveReq *) subReq; - req->subscriptionId = subPtr.p->m_subscriptionId; - req->subscriptionKey = subPtr.p->m_subscriptionKey; - req->senderData = subPtr.p->m_subscriberData; - req->senderRef = subPtr.p->m_coordinatorRef; - - /*************************** - * Send to all participants - ***************************/ - NodeReceiverGroup rg(GREP, m_grep->m_aliveNodes); - subPtr.p->m_outstandingParticipants = rg; - sendSignal(rg, - GSN_GREP_REMOVE_REQ, signal, - GrepRemoveReq::SignalLength, JBB); -} - - -void -Grep::PSPart::execGREP_REMOVE_REQ(Signal* signal) -{ - jamEntry(); - GrepRemoveReq * const grepReq = (GrepRemoveReq *) signal->getDataPtr(); - Uint32 subId = grepReq->subscriptionId; - Uint32 subKey = grepReq->subscriptionKey; - Uint32 subData = grepReq->senderData; - Uint32 coordinator = grepReq->senderRef; - - Subscription key; - key.m_subscriptionId = subId; - key.m_subscriptionKey = subKey; - SubscriptionPtr subPtr; - - if(!c_subscriptions.find(subPtr, key)) - { - /** - * The subscription was not found, so it must be deleted. - * Send CONF back, since it does not exist (thus, it is removed) - */ - GrepRemoveConf * grepConf = (GrepRemoveConf *)grepReq; - grepConf->subscriptionKey = subKey; - grepConf->subscriptionId = subId; - grepConf->senderData = subData; - grepConf->senderNodeId = getOwnNodeId(); - sendSignal(coordinator, GSN_GREP_REMOVE_CONF, signal, - GrepRemoveConf::SignalLength, JBB); - return; - } - - subPtr.p->m_operationPtrI = subData; - subPtr.p->m_coordinatorRef = coordinator; - subPtr.p->m_outstandingRequest = GSN_GREP_REMOVE_REQ; - - /** - * send SUB_REMOVE_REQ to local SUMA - */ - SubRemoveReq * sumaReq = (SubRemoveReq *) grepReq; - sumaReq->subscriptionId = subId; - sumaReq->subscriptionKey = subKey; - sumaReq->senderData = subPtr.i; - sendSignal(SUMA_REF, GSN_SUB_REMOVE_REQ, signal, - SubStartReq::SignalLength, JBB); -} - - -/** - * SUB_REMOVE_CONF (from local SUMA) - */ -void -Grep::PSPart::execSUB_REMOVE_CONF(Signal* signal) -{ - jamEntry(); - SubRemoveConf * const conf = (SubRemoveConf *) signal->getDataPtr(); - Uint32 subId = conf->subscriptionId; - Uint32 subKey = conf->subscriptionKey; - Uint32 subData = conf->subscriberData; - - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - ndbrequire(subPtr.p->m_subscriptionId == subId); - ndbrequire(subPtr.p->m_subscriptionKey == subKey); - subPtr.p->m_outstandingRequest = 0; - GrepRemoveConf * grepConf = (GrepRemoveConf *)conf; - grepConf->subscriptionKey = subKey; - grepConf->subscriptionId = subId; - grepConf->senderData = subPtr.p->m_operationPtrI; - grepConf->senderNodeId = getOwnNodeId(); - sendSignal(subPtr.p->m_coordinatorRef, GSN_GREP_REMOVE_CONF, signal, - GrepRemoveConf::SignalLength, JBB); - c_subscriptions.release(subPtr); - -} - - -/** - * SUB_REMOVE_CONF (from local SUMA) - */ -void -Grep::PSPart::execSUB_REMOVE_REF(Signal* signal) -{ - jamEntry(); - SubRemoveRef * const ref = (SubRemoveRef *)signal->getDataPtr(); - Uint32 subData = ref->subscriberData; - /* GrepError::GE_Code err = (GrepError::GE_Code)ref->err;*/ - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - - //sendSubRemoveRef_PSCoord(signal, *subPtr.p, err /*error*/); -} - - -/** - * Aborting has been carried out (says Participants) - */ -void -Grep::PSCoord::execGREP_REMOVE_CONF(Signal* signal) -{ - jamEntry(); - GrepRemoveConf * const conf = (GrepRemoveConf *) signal->getDataPtr(); - Uint32 subId = conf->subscriptionId; - Uint32 subKey = conf->subscriptionKey; - Uint32 senderNodeId = conf->senderNodeId; - Uint32 subData = conf->senderData; - SubCoordinatorPtr subPtr; - c_subCoordinatorPool.getPtr(subPtr, subData); - - ndbrequire(subPtr.p->m_outstandingRequest == GSN_GREP_REMOVE_REQ); - - subPtr.p->m_outstandingParticipants.clearWaitingFor(senderNodeId); - - if(!subPtr.p->m_outstandingParticipants.done()) { - jam(); - return; - } - jam(); - - /************************* - * All participants ready - *************************/ - - m_grep->sendEventRep(signal, - EventReport::GrepSubscriptionInfo, - GrepEvent::GrepPS_SubRemoveConf, - subId, subKey, - GrepError::GE_NO_ERROR); - - GrepSubRemoveConf * grepConf = (GrepSubRemoveConf *) conf; - grepConf->subscriptionId = subId; - grepConf->subscriptionKey = subKey; - sendSignal(subPtr.p->m_subscriberRef, GSN_GREP_SUB_REMOVE_CONF, signal, - GrepSubRemoveConf::SignalLength, JBB); - - c_subCoordinatorPool.release(subPtr); -} - - - -void -Grep::PSCoord::execGREP_REMOVE_REF(Signal* signal) -{ - jamEntry(); - GrepRemoveRef * const ref = (GrepRemoveRef *)signal->getDataPtr(); - Uint32 subData = ref->senderData; - Uint32 err = ref->err; - SubCoordinatorPtr subPtr; - - /** - * Get the operationrecord matching subdata and remove it. Subsequent - * execGREP_REMOVE_REF will simply be ignored at this stage. - */ - for( c_runningSubscriptions.first(c_subPtr); - !c_subPtr.isNull(); c_runningSubscriptions.next(c_subPtr)) { - jam(); - subPtr.i = c_subPtr.curr.i; - subPtr.p = c_runningSubscriptions.getPtr(subPtr.i); - if(subData == subPtr.i) - { - sendRefToSS(signal, *subPtr.p, (GrepError::GE_Code)err /*error*/); - c_runningSubscriptions.release(subPtr); - return; - } - } - return; -} - - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: LOG RECORDS (COMING IN FROM LOCAL SUMA) - * ------------------------------------------------------------------------ - * - * After the subscription is started, we get log records from SUMA. - * Both table data and meta data log records are received. - * - * TODO: - * @todo Changes in meta data is currently not - * allowed during global replication - **************************************************************************/ - -void -Grep::PSPart::execSUB_META_DATA(Signal* signal) -{ - jamEntry(); - if(m_recoveryMode) { - jam(); - return; - } - /** - * METASCAN and METALOG - */ - SubMetaData * data = (SubMetaData *) signal->getDataPtrSend(); - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, data->subscriberData); - - /*************************** - * Forward data to REP node - ***************************/ - sendSignal(subPtr.p->m_subscriberRef, GSN_SUB_META_DATA, signal, - SubMetaData::SignalLength, JBB); -#ifdef DEBUG_GREP_SUBSCRIPTION - ndbout_c("Grep::PSPart: Sent SUB_META_DATA to REP " - "(TableId: %d, SenderData: %d, GCI: %d)", - data->tableId, data->senderData, data->gci); -#endif -} - -/** - * Receive table data from SUMA and dispatches it to REP node. - */ -void -Grep::PSPart::execSUB_TABLE_DATA(Signal* signal) -{ - jamEntry(); - if(m_recoveryMode) { - jam(); - return; - } - ndbrequire(m_repRef!=0); - - if(!assembleFragments(signal)) { jam(); return; } - - /** - * Check if it is SCAN or LOG data that has arrived - */ - if(signal->getNoOfSections() == 2) - { - jam(); - /** - * DATASCAN - Not marked with GCI, so mark with latest seen GCI - */ - if(m_firstScanGCI == 1 && m_lastScanGCI == 0) { - m_firstScanGCI = m_latestSeenGCI; - m_lastScanGCI = m_latestSeenGCI; - } - SubTableData * data = (SubTableData*)signal->getDataPtrSend(); - Uint32 subData = data->senderData; - data->gci = m_latestSeenGCI; - data->logType = SubTableData::SCAN; - - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - sendSignal(subPtr.p->m_subscriberRef, GSN_SUB_TABLE_DATA, signal, - SubTableData::SignalLength, JBB); -#ifdef DEBUG_GREP - ndbout_c("Grep::PSPart: Sent SUB_TABLE_DATA (Scan, GCI: %d)", - data->gci); -#endif - } - else - { - jam(); - /** - * DATALOG (TRIGGER) - Already marked with GCI - */ - SubTableData * data = (SubTableData*)signal->getDataPtrSend(); - data->logType = SubTableData::LOG; - Uint32 subData = data->senderData; - if (data->gci > m_latestSeenGCI) m_latestSeenGCI = data->gci; - - // Reformat to sections and send to replication node. - LinearSectionPtr ptr[3]; - ptr[0].p = signal->theData + 25; - ptr[0].sz = data->noOfAttributes; - ptr[1].p = signal->theData + 25 + MAX_ATTRIBUTES_IN_TABLE; - ptr[1].sz = data->dataSize; - - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - sendSignal(subPtr.p->m_subscriberRef, GSN_SUB_TABLE_DATA, - signal, SubTableData::SignalLength, JBB, ptr, 2); -#ifdef DEBUG_GREP - ndbout_c("Grep::PSPart: Sent SUB_TABLE_DATA (Log, GCI: %d)", - data->gci); -#endif - } -} - - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: START SYNCHRONIZATION - * ------------------------------------------------------------------------ - * - * - **************************************************************************/ - -/** - * Request to start sync (from Rep SS) - */ -void -Grep::PSCoord::execGREP_SUB_SYNC_REQ(Signal* signal) -{ - jamEntry(); - GrepSubSyncReq * const subReq = (GrepSubSyncReq*)signal->getDataPtr(); - SubscriptionData::Part part = (SubscriptionData::Part) subReq->part; - Uint32 subId = subReq->subscriptionId; - Uint32 subKey = subReq->subscriptionKey; - BlockReference rep = signal->getSendersBlockRef(); - - SubCoordinatorPtr subPtr; - if( !c_subCoordinatorPool.seize(subPtr)) { - jam(); - SubCoordinator sub; - sub.m_subscriberRef = rep; - sub.m_subscriptionId = 0; - sub.m_subscriptionKey = 0; - sub.m_outstandingRequest = GSN_GREP_SYNC_REQ; - sendRefToSS(signal, sub, GrepError::NOSPACE_IN_POOL); - return; - } - - prepareOperationRec(subPtr, - numberToRef(PSREPBLOCKNO, refToNode(rep)), - subId, subKey, - GSN_GREP_SYNC_REQ); - - GrepSyncReq * req = (GrepSyncReq *)subReq; - req->subscriptionId = subPtr.p->m_subscriptionId; - req->subscriptionKey = subPtr.p->m_subscriptionKey; - req->senderData = subPtr.p->m_subscriberData; - req->part = (Uint32)part; - - /*************************** - * Send to all participants - ***************************/ - NodeReceiverGroup rg(GREP, m_grep->m_aliveNodes); - subPtr.p->m_outstandingParticipants = rg; - sendSignal(rg, - GSN_GREP_SYNC_REQ, signal, GrepSyncReq::SignalLength, JBB); -} - - -/** - * Sync req from Grep::PSCoord to PS particpant - */ -void -Grep::PSPart::execGREP_SYNC_REQ(Signal* signal) -{ - jamEntry(); - - GrepSyncReq * const grepReq = (GrepSyncReq *) signal->getDataPtr(); - Uint32 part = grepReq->part; - Uint32 subId = grepReq->subscriptionId; - Uint32 subKey = grepReq->subscriptionKey; - Uint32 subData = grepReq->senderData; - - Subscription key; - key.m_subscriptionId = subId; - key.m_subscriptionKey = subKey; - SubscriptionPtr subPtr; - ndbrequire(c_subscriptions.find(subPtr, key)); - subPtr.p->m_operationPtrI = subData; - subPtr.p->m_outstandingRequest = GSN_GREP_SYNC_REQ; - /********************************** - * Send SUB_SYNC_REQ to local SUMA - **********************************/ - SubSyncReq * sumaReq = (SubSyncReq *)grepReq; - sumaReq->subscriptionId = subId; - sumaReq->subscriptionKey = subKey; - sumaReq->subscriberData = subPtr.i; - sumaReq->part = part; - sendSignal(SUMA_REF, GSN_SUB_SYNC_REQ, signal, - SubSyncReq::SignalLength, JBB); -} - - -/** - * SYNC conf from SUMA - */ -void -Grep::PSPart::execSUB_SYNC_CONF(Signal* signal) -{ - jamEntry(); - - SubSyncConf * const conf = (SubSyncConf *) signal->getDataPtr(); - Uint32 part = conf->part; - Uint32 subId = conf->subscriptionId; - Uint32 subKey = conf->subscriptionKey; - Uint32 subData = conf->subscriberData; - - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - - ndbrequire(subPtr.p->m_subscriptionId == subId); - ndbrequire(subPtr.p->m_subscriptionKey == subKey); - - GrepSyncConf * grepConf = (GrepSyncConf *)conf; - grepConf->senderNodeId = getOwnNodeId(); - grepConf->part = part; - grepConf->firstGCI = m_firstScanGCI; - grepConf->lastGCI = m_lastScanGCI; - grepConf->subscriptionId = subId; - grepConf->subscriptionKey = subKey; - grepConf->senderData = subPtr.p->m_operationPtrI; - sendSignal(subPtr.p->m_coordinatorRef, GSN_GREP_SYNC_CONF, signal, - GrepSyncConf::SignalLength, JBB); - - m_firstScanGCI = 1; - m_lastScanGCI = 0; - subPtr.p->m_outstandingRequest = 0; -} - -/** - * Handle errors that either occured in: - * 1) PSPart - * or - * 2) propagated from local SUMA - * - * Propagates REF signal to PSCoord - */ -void -Grep::PSPart::execSUB_SYNC_REF(Signal* signal) { - jamEntry(); - SubSyncRef * const ref = (SubSyncRef *)signal->getDataPtr(); - Uint32 subData = ref->subscriberData; - GrepError::GE_Code err = (GrepError::GE_Code)ref->err; - SubscriptionData::Part part = (SubscriptionData::Part)ref->part; - - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr, subData); - sendRefToPSCoord(signal, *subPtr.p, err /*error*/ ,part); - subPtr.p->m_outstandingRequest = 0; -} - -/** - * Syncing has started... (says PS Participant) - */ -void -Grep::PSCoord::execGREP_SYNC_CONF(Signal* signal) -{ - jamEntry(); - - GrepSyncConf const * conf = (GrepSyncConf *)signal->getDataPtr(); - Uint32 part = conf->part; - Uint32 firstGCI = conf->firstGCI; - Uint32 lastGCI = conf->lastGCI; - Uint32 subId = conf->subscriptionId; - Uint32 subKey = conf->subscriptionKey; - Uint32 subData = conf->senderData; - - SubCoordinatorPtr subPtr; - c_subCoordinatorPool.getPtr(subPtr, subData); - ndbrequire(subPtr.p->m_outstandingRequest == GSN_GREP_SYNC_REQ); - - subPtr.p->m_outstandingParticipants.clearWaitingFor(conf->senderNodeId); - if(!subPtr.p->m_outstandingParticipants.done()) return; - - /** - * Send event - */ - GrepEvent::Subscription event; - if(part == SubscriptionData::MetaData) - event = GrepEvent::GrepPS_SubSyncMetaConf; - else - event = GrepEvent::GrepPS_SubSyncDataConf; - - /* @todo Johan: Add firstGCI here. /Lars */ - m_grep->sendEventRep(signal, EventReport::GrepSubscriptionInfo, - event, subId, subKey, - (Uint32)GrepError::GE_NO_ERROR, - lastGCI); - - /************************* - * All participants ready - *************************/ - GrepSubSyncConf * grepConf = (GrepSubSyncConf *)conf; - grepConf->part = part; - grepConf->firstGCI = firstGCI; - grepConf->lastGCI = lastGCI; - grepConf->subscriptionId = subId; - grepConf->subscriptionKey = subKey; - - sendSignal(subPtr.p->m_subscriberRef, GSN_GREP_SUB_SYNC_CONF, signal, - GrepSubSyncConf::SignalLength, JBB); - c_subCoordinatorPool.release(subPtr); -} - -/** - * Handle errors that either occured in: - * 1) PSCoord - * or - * 2) propagated from PSPart - */ -void -Grep::PSCoord::execGREP_SYNC_REF(Signal* signal) { - jamEntry(); - GrepSyncRef * const ref = (GrepSyncRef *)signal->getDataPtr(); - Uint32 subData = ref->senderData; - SubscriptionData::Part part = (SubscriptionData::Part)ref->part; - GrepError::GE_Code err = (GrepError::GE_Code)ref->err; - SubCoordinatorPtr subPtr; - c_runningSubscriptions.getPtr(subPtr, subData); - sendRefToSS(signal, *subPtr.p, err /*error*/, part); -} - - - -void -Grep::PSCoord::sendRefToSS(Signal * signal, - SubCoordinator sub, - GrepError::GE_Code err, - SubscriptionData::Part part) { - /** - - GrepCreateRef * ref = (GrepCreateRef*)signal->getDataPtrSend(); - ref->senderData = sub.m_subscriberData; - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - ref->err = err; - sendSignal(sub.m_coordinatorRef, GSN_GREP_CREATE_REF, signal, - GrepCreateRef::SignalLength, JBB); -*/ - - jam(); - GrepEvent::Subscription event; - switch(sub.m_outstandingRequest) { - case GSN_GREP_CREATE_SUBID_REQ: - { - jam(); - CreateSubscriptionIdRef * ref = - (CreateSubscriptionIdRef*)signal->getDataPtrSend(); - ref->err = (Uint32)err; - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - sendSignal(sub.m_subscriberRef, - GSN_GREP_CREATE_SUBID_REF, - signal, - CreateSubscriptionIdRef::SignalLength, - JBB); - event = GrepEvent::GrepPS_CreateSubIdRef; - } - break; - case GSN_GREP_CREATE_REQ: - { - jam(); - GrepSubCreateRef * ref = (GrepSubCreateRef*)signal->getDataPtrSend(); - ref->err = (Uint32)err; - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - sendSignal(sub.m_subscriberRef, GSN_GREP_SUB_CREATE_REF, signal, - GrepSubCreateRef::SignalLength, JBB); - event = GrepEvent::GrepPS_SubCreateRef; - } - break; - case GSN_GREP_SYNC_REQ: - { - jam(); - GrepSubSyncRef * ref = (GrepSubSyncRef*)signal->getDataPtrSend(); - ref->err = (Uint32)err; - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - ref->part = (SubscriptionData::Part) part; - sendSignal(sub.m_subscriberRef, - GSN_GREP_SUB_SYNC_REF, - signal, - GrepSubSyncRef::SignalLength, - JBB); - if(part == SubscriptionData::MetaData) - event = GrepEvent::GrepPS_SubSyncMetaRef; - else - event = GrepEvent::GrepPS_SubSyncDataRef; - } - break; - case GSN_GREP_START_REQ: - { - jam(); - GrepSubStartRef * ref = (GrepSubStartRef*)signal->getDataPtrSend(); - ref->err = (Uint32)err; - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - - sendSignal(sub.m_subscriberRef, GSN_GREP_SUB_START_REF, - signal, GrepSubStartRef::SignalLength, JBB); - if(part == SubscriptionData::MetaData) - event = GrepEvent::GrepPS_SubStartMetaRef; - else - event = GrepEvent::GrepPS_SubStartDataRef; - /** - * Send event report - */ - m_grep->sendEventRep(signal, - EventReport::GrepSubscriptionAlert, - event, - sub.m_subscriptionId, - sub.m_subscriptionKey, - (Uint32)err); - } - break; - case GSN_GREP_REMOVE_REQ: - { - jam(); - GrepSubRemoveRef * ref = (GrepSubRemoveRef*)signal->getDataPtrSend(); - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - ref->err = (Uint32)err; - - sendSignal(sub.m_subscriberRef, - GSN_GREP_SUB_REMOVE_REF, - signal, - GrepSubRemoveRef::SignalLength, - JBB); - - event = GrepEvent::GrepPS_SubRemoveRef; - } - break; - default: - ndbrequire(false); - event= GrepEvent::Rep_Disconnect; // remove compiler warning - } - /** - * Finally, send an event. - */ - m_grep->sendEventRep(signal, - EventReport::GrepSubscriptionAlert, - event, - sub.m_subscriptionId, - sub.m_subscriptionKey, - err); - -} - - -void -Grep::PSPart::sendRefToPSCoord(Signal * signal, - Subscription sub, - GrepError::GE_Code err, - SubscriptionData::Part part) { - - jam(); - GrepEvent::Subscription event; - switch(sub.m_outstandingRequest) { - - case GSN_GREP_CREATE_REQ: - { - GrepCreateRef * ref = (GrepCreateRef*)signal->getDataPtrSend(); - ref->senderData = sub.m_subscriberData; - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - ref->err = err; - sendSignal(sub.m_coordinatorRef, GSN_GREP_CREATE_REF, signal, - GrepCreateRef::SignalLength, JBB); - - event = GrepEvent::GrepPS_SubCreateRef; - } - break; - case GSN_GREP_SYNC_REQ: - { - GrepSyncRef * ref = (GrepSyncRef*)signal->getDataPtrSend(); - ref->senderData = sub.m_subscriberData; - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - ref->part = part; - ref->err = err; - sendSignal(sub.m_coordinatorRef, - GSN_GREP_SYNC_REF, signal, - GrepSyncRef::SignalLength, JBB); - if(part == SubscriptionData::MetaData) - event = GrepEvent::GrepPS_SubSyncMetaRef; - else - event = GrepEvent::GrepPS_SubSyncDataRef; - } - break; - case GSN_GREP_START_REQ: - { - jam(); - GrepStartRef * ref = (GrepStartRef*)signal->getDataPtrSend(); - ref->senderData = sub.m_subscriberData; - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - ref->part = (Uint32) part; - ref->err = err; - sendSignal(sub.m_coordinatorRef, GSN_GREP_START_REF, signal, - GrepStartRef::SignalLength, JBB); - if(part == SubscriptionData::MetaData) - event = GrepEvent::GrepPS_SubStartMetaRef; - else - event = GrepEvent::GrepPS_SubStartDataRef; - } - break; - - case GSN_GREP_REMOVE_REQ: - { - jamEntry(); - GrepRemoveRef * ref = (GrepRemoveRef*)signal->getDataPtrSend(); - ref->senderData = sub.m_operationPtrI; - ref->subscriptionId = sub.m_subscriptionId; - ref->subscriptionKey = sub.m_subscriptionKey; - ref->err = err; - sendSignal(sub.m_coordinatorRef, GSN_GREP_REMOVE_REF, signal, - GrepCreateRef::SignalLength, JBB); - - } - break; - default: - ndbrequire(false); - event= GrepEvent::Rep_Disconnect; // remove compiler warning - } - - /** - * Finally, send an event. - */ - m_grep->sendEventRep(signal, - EventReport::GrepSubscriptionAlert, - event, - sub.m_subscriptionId, - sub.m_subscriptionKey, - err); - -} - -/************************************************************************** - * ------------------------------------------------------------------------ - * MODULE: GREP PS Coordinator GCP - * ------------------------------------------------------------------------ - * - * - **************************************************************************/ - -void -Grep::PSPart::execSUB_GCP_COMPLETE_REP(Signal* signal) -{ - jamEntry(); - if(m_recoveryMode) { - jam(); - return; - } - SubGcpCompleteRep * rep = (SubGcpCompleteRep *)signal->getDataPtrSend(); - rep->senderRef = reference(); - - if (rep->gci > m_latestSeenGCI) m_latestSeenGCI = rep->gci; - SubscriptionPtr subPtr; - c_subscriptions.first(c_subPtr); - for(; !c_subPtr.isNull(); c_subscriptions.next(c_subPtr)) { - - subPtr.i = c_subPtr.curr.i; - subPtr.p = c_subscriptions.getPtr(subPtr.i); - sendSignal(subPtr.p->m_subscriberRef, GSN_SUB_GCP_COMPLETE_REP, signal, - SubGcpCompleteRep::SignalLength, JBB); - } - -#ifdef DEBUG_GREP - ndbout_c("Grep::PSPart: Recd SUB_GCP_COMPLETE_REP " - "(GCI: %d, nodeId: %d) from SUMA", - rep->gci, refToNode(rep->senderRef)); -#endif -} - - -void -Grep::PSPart::execSUB_SYNC_CONTINUE_REQ(Signal* signal) -{ - jamEntry(); - SubSyncContinueReq * const req = (SubSyncContinueReq*)signal->getDataPtr(); - Uint32 subData = req->subscriberData; - - SubscriptionPtr subPtr; - c_subscriptions.getPtr(subPtr,subData); - - /** - * @todo Figure out how to control how much data we can receive? - */ - SubSyncContinueConf * conf = (SubSyncContinueConf*)req; - conf->subscriptionId = subPtr.p->m_subscriptionId; - conf->subscriptionKey = subPtr.p->m_subscriptionKey; - sendSignal(SUMA_REF, GSN_SUB_SYNC_CONTINUE_CONF, signal, - SubSyncContinueConf::SignalLength, JBB); -} - -void -Grep::sendEventRep(Signal * signal, - EventReport::EventType type, - GrepEvent::Subscription event, - Uint32 subId, - Uint32 subKey, - Uint32 err, - Uint32 other) { - jam(); - signal->theData[0] = type; - signal->theData[1] = event; - signal->theData[2] = subId; - signal->theData[3] = subKey; - signal->theData[4] = err; - - if(other==0) - sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 5 ,JBB); - else { - signal->theData[5] = other; - sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 6 ,JBB); - } -} diff --git a/ndb/src/kernel/blocks/grep/Grep.hpp b/ndb/src/kernel/blocks/grep/Grep.hpp deleted file mode 100644 index 7d3dd916ecc..00000000000 --- a/ndb/src/kernel/blocks/grep/Grep.hpp +++ /dev/null @@ -1,535 +0,0 @@ -/* 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 */ - -#ifndef GREP_HPP -#define GREP_HPP - -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include - - -/** - * Module in block (Should be placed elsewhere) - */ -class BlockComponent { -public: - BlockComponent(SimulatedBlock *); - BlockReference reference() { return m_sb->reference(); }; - BlockNumber number() { return m_sb->number(); }; - - void sendSignal(NodeReceiverGroup rg, - GlobalSignalNumber gsn, - Signal* signal, - Uint32 length, - JobBufferLevel jbuf ) const { - m_sb->sendSignal(rg, gsn, signal, length, jbuf); - } - - void sendSignal(BlockReference ref, - GlobalSignalNumber gsn, - Signal* signal, - Uint32 length, - JobBufferLevel jbuf ) const { - m_sb->sendSignal(ref, gsn, signal, length, jbuf); - } - - void sendSignal(BlockReference ref, - GlobalSignalNumber gsn, - Signal* signal, - Uint32 length, - JobBufferLevel jbuf, - LinearSectionPtr ptr[3], - Uint32 noOfSections) const { - m_sb->sendSignal(ref, gsn, signal, length, jbuf, ptr, noOfSections); - } - - void sendSignalWithDelay(BlockReference ref, - GlobalSignalNumber gsn, - Signal* signal, - Uint32 delayInMilliSeconds, - Uint32 length) const { - - m_sb->sendSignalWithDelay(ref, gsn, signal, delayInMilliSeconds, length); - } - - NodeId getOwnNodeId() const { - return m_sb->getOwnNodeId(); - } - - bool assembleFragments(Signal * signal) { - return m_sb->assembleFragments(signal); - } - - void progError(int line, int err_code, const char* extra) { - m_sb->progError(line, err_code, extra); - } - -private: - SimulatedBlock * m_sb; -}; - - - -/** - * Participant of GREP Protocols (not necessarily a protocol coordinator) - * - * This object is only used on primary system - */ -#if 0 -class GrepParticipant : public SimulatedBlock -{ -protected: - GrepParticipant(const Configuration & conf); - virtual ~GrepParticipant(); - BLOCK_DEFINES(GrepParticipant); - -protected: - /*************************************************************************** - * SUMA Signal Interface - ***************************************************************************/ - void execSUB_CREATE_CONF(Signal*); - void execSUB_STARTCONF(Signal*); - void execSUB_REMOVE_CONF(Signal*); - - void execSUB_META_DATA(Signal*); - void execSUB_TABLE_DATA(Signal*); - - void execSUB_SYNC_CONF(Signal*); - - void execSUB_GCP_COMPLETE_REP(Signal*); - void execSUB_SYNC_CONTINUE_REQ(Signal*); - - /*************************************************************************** - * GREP Coordinator Signal Interface - ***************************************************************************/ - void execGREP_CREATE_REQ(Signal*); - void execGREP_START_REQ(Signal*); - void execGREP_SYNC_REQ(Signal*); - void execGREP_REMOVE_REQ(Signal*); - - -protected: - BlockReference m_repRef; ///< Replication node (only one rep node per grep) - -private: - BlockReference m_coordinator; - Uint32 m_latestSeenGCI; -}; -#endif - - -/** - * GREP Coordinator - */ -class Grep : public SimulatedBlock //GrepParticipant -{ - BLOCK_DEFINES(Grep); - -public: - Grep(const Configuration & conf); - virtual ~Grep(); - -private: - /*************************************************************************** - * General Signal Recivers - ***************************************************************************/ - void execSTTOR(Signal*); - void sendSTTORRY(Signal*); - void execNDB_STTOR(Signal*); - void execDUMP_STATE_ORD(Signal*); - void execREAD_NODESCONF(Signal*); - void execNODE_FAILREP(Signal*); - void execINCL_NODEREQ(Signal*); - void execGREP_REQ(Signal*); - void execAPI_FAILREQ(Signal*); - /** - * Forwarded to PSCoord - */ - //CONF - void fwdGREP_CREATE_CONF(Signal* s) { - pscoord.execGREP_CREATE_CONF(s); }; - void fwdGREP_START_CONF(Signal* s) { - pscoord.execGREP_START_CONF(s); }; - void fwdGREP_SYNC_CONF(Signal* s) { - pscoord.execGREP_SYNC_CONF(s); }; - void fwdGREP_REMOVE_CONF(Signal* s) { - pscoord.execGREP_REMOVE_CONF(s); }; - void fwdCREATE_SUBID_CONF(Signal* s) { - pscoord.execCREATE_SUBID_CONF(s); }; - - //REF - - void fwdGREP_CREATE_REF(Signal* s) { - pscoord.execGREP_CREATE_REF(s); }; - void fwdGREP_START_REF(Signal* s) { - pscoord.execGREP_START_REF(s); }; - void fwdGREP_SYNC_REF(Signal* s) { - pscoord.execGREP_SYNC_REF(s); }; - - void fwdGREP_REMOVE_REF(Signal* s) { - pscoord.execGREP_REMOVE_REF(s); }; - - void fwdCREATE_SUBID_REF(Signal* s) { - pscoord.execCREATE_SUBID_REF(s); }; - - //REQ - void fwdGREP_SUB_CREATE_REQ(Signal* s) { - pscoord.execGREP_SUB_CREATE_REQ(s); }; - void fwdGREP_SUB_START_REQ(Signal* s) { - pscoord.execGREP_SUB_START_REQ(s); }; - void fwdGREP_SUB_SYNC_REQ(Signal* s) { - pscoord.execGREP_SUB_SYNC_REQ(s); }; - void fwdGREP_SUB_REMOVE_REQ(Signal* s) { - pscoord.execGREP_SUB_REMOVE_REQ(s); }; - void fwdGREP_CREATE_SUBID_REQ(Signal* s) { - pscoord.execGREP_CREATE_SUBID_REQ(s); }; - - /** - * Forwarded to PSPart - */ - - void fwdSTART_ME(Signal* s){ - pspart.execSTART_ME(s); - }; - void fwdGREP_ADD_SUB_REQ(Signal* s){ - pspart.execGREP_ADD_SUB_REQ(s); - }; - void fwdGREP_ADD_SUB_REF(Signal* s){ - pspart.execGREP_ADD_SUB_REF(s); - }; - void fwdGREP_ADD_SUB_CONF(Signal* s){ - pspart.execGREP_ADD_SUB_CONF(s); - }; - - //CONF - void fwdSUB_CREATE_CONF(Signal* s) { - pspart.execSUB_CREATE_CONF(s); }; - void fwdSUB_START_CONF(Signal* s) { - pspart.execSUB_START_CONF(s); }; - void fwdSUB_REMOVE_CONF(Signal* s) { - pspart.execSUB_REMOVE_CONF(s); }; - void fwdSUB_SYNC_CONF(Signal* s) { - pspart.execSUB_SYNC_CONF(s); }; - - //REF - - void fwdSUB_CREATE_REF(Signal* s) { - pspart.execSUB_CREATE_REF(s); }; - void fwdSUB_START_REF(Signal* s) { - pspart.execSUB_START_REF(s); }; - void fwdSUB_REMOVE_REF(Signal* s) { - pspart.execSUB_REMOVE_REF(s); }; - void fwdSUB_SYNC_REF(Signal* s) { - pspart.execSUB_SYNC_REF(s); }; - - //REQ - void fwdSUB_SYNC_CONTINUE_REQ(Signal* s) { - pspart.execSUB_SYNC_CONTINUE_REQ(s); }; - void fwdGREP_CREATE_REQ(Signal* s) { - pspart.execGREP_CREATE_REQ(s); }; - void fwdGREP_START_REQ(Signal* s) { - pspart.execGREP_START_REQ(s); }; - void fwdGREP_SYNC_REQ(Signal* s) { - pspart.execGREP_SYNC_REQ(s); }; - void fwdGREP_REMOVE_REQ(Signal* s) { - pspart.execGREP_REMOVE_REQ(s); }; - - void fwdSUB_META_DATA(Signal* s) { - pspart.execSUB_META_DATA(s); }; - void fwdSUB_TABLE_DATA(Signal* s) { - pspart.execSUB_TABLE_DATA(s); }; - - void fwdSUB_GCP_COMPLETE_REP(Signal* s) { - pspart.execSUB_GCP_COMPLETE_REP(s); }; - - void sendEventRep(Signal * signal, - EventReport::EventType type, - GrepEvent::Subscription event, - Uint32 subId, - Uint32 subKey, - Uint32 err, - Uint32 gci=0); - - void getNodeGroupMembers(Signal* signal); - - - /*************************************************************************** - * Block Data - ***************************************************************************/ - struct Node { - Uint32 nodeId; - Uint32 alive; - Uint32 nextList; - union { Uint32 prevList; Uint32 nextPool; }; - }; - typedef Ptr NodePtr; - - NodeId m_masterNodeId; - SLList m_nodes; - NdbNodeBitmask m_aliveNodes; - ArrayPool m_nodePool; - - /** - * for all Suma's to keep track of other Suma's in Node group - */ - Uint32 c_nodeGroup; - Uint32 c_noNodesInGroup; - Uint32 c_idInNodeGroup; - NodeId c_nodesInGroup[4]; - - -public: - /*************************************************************************** - * GREP PS Coordinator - ***************************************************************************/ - class PSCoord : public BlockComponent { - - private: - - struct SubCoordinator { - Uint32 m_subscriberRef; - Uint32 m_subscriberData; - Uint32 m_coordinatorRef; - Uint32 m_subscriptionId; - Uint32 m_subscriptionKey; - Uint32 m_subscriptionType; - NdbNodeBitmask m_participants; - Uint32 m_outstandingRequest; - SignalCounter m_outstandingParticipants; - - Uint32 nextHash; - union { Uint32 prevHash; Uint32 nextPool; }; - - Uint32 hashValue() const { - return m_subscriptionId + m_subscriptionKey; - } - - bool equal(const SubCoordinator & s) const { - return - m_subscriptionId == s.m_subscriptionId && - m_subscriptionKey == s.m_subscriptionKey; - } - - }; - - typedef Ptr SubCoordinatorPtr; - ArrayPool c_subCoordinatorPool; - DLHashTable::Iterator c_subPtr; - DLHashTable c_runningSubscriptions; - - void prepareOperationRec(SubCoordinatorPtr ptr, - BlockReference subscriber, - Uint32 subId, - Uint32 subKey, - Uint32 request); - - public: - PSCoord(class Grep *); - - void execGREP_CREATE_CONF(Signal*); - void execGREP_START_CONF(Signal*); - void execGREP_SYNC_CONF(Signal*); - void execGREP_REMOVE_CONF(Signal*); - - void execGREP_CREATE_REF(Signal*); - void execGREP_START_REF(Signal*); - void execGREP_SYNC_REF(Signal*); - void execGREP_REMOVE_REF(Signal*); - - - void execCREATE_SUBID_CONF(Signal*); //comes from SUMA - void execGREP_CREATE_SUBID_REQ(Signal*); - - void execGREP_SUB_CREATE_REQ(Signal*); - void execGREP_SUB_START_REQ(Signal*); - void execGREP_SUB_SYNC_REQ(Signal*); - void execGREP_SUB_REMOVE_REQ(Signal*); - - - - void execCREATE_SUBID_REF(Signal*); - - - - void sendCreateSubIdRef_SS(Signal * signal, - Uint32 subId, - Uint32 subKey, - BlockReference to, - GrepError::GE_Code err); - - - void sendSubRemoveRef_SS(Signal * signal, - SubCoordinator sub, - GrepError::GE_Code err); - - void sendRefToSS(Signal * signal, - SubCoordinator sub, - GrepError::GE_Code err, - SubscriptionData::Part part = (SubscriptionData::Part)0); - - void setRepRef(BlockReference rr) { m_repRef = rr; }; - //void setAliveNodes(NdbNodeBitmask an) { m_aliveNodes = an; }; - - BlockReference m_repRef; ///< Rep node (only one rep node per grep) - // NdbNodeBitmask m_aliveNodes; - - Uint32 m_outstandingRequest; - SignalCounter m_outstandingParticipants; - - Grep * m_grep; - } pscoord; - friend class PSCoord; - - /*************************************************************************** - * GREP PS Participant - *************************************************************************** - * Participant of GREP Protocols (not necessarily a protocol coordinator) - * - * This object is only used on primary system - ***************************************************************************/ - class PSPart: public BlockComponent - { - //protected: - //GrepParticipant(const Configuration & conf); - //virtual ~GrepParticipant(); - //BLOCK_DEFINES(GrepParticipant); - - struct Subscription { - Uint32 m_subscriberRef; - Uint32 m_subscriberData; - Uint32 m_subscriptionId; - Uint32 m_subscriptionKey; - Uint32 m_subscriptionType; - Uint32 m_coordinatorRef; - Uint32 m_outstandingRequest; - Uint32 m_operationPtrI; - Uint32 nextHash; - union { Uint32 prevHash; Uint32 nextPool; }; - - Uint32 hashValue() const { - return m_subscriptionId + m_subscriptionKey; - } - - bool equal(const Subscription & s) const { - return - m_subscriptionId == s.m_subscriptionId && - m_subscriptionKey == s.m_subscriptionKey; - } - - }; - typedef Ptr SubscriptionPtr; - - DLHashTable c_subscriptions; - DLHashTable::Iterator c_subPtr; - ArrayPool c_subscriptionPool; - - public: - PSPart(class Grep *); - - - //protected: - /************************************************************************* - * SUMA Signal Interface - *************************************************************************/ - void execSUB_CREATE_CONF(Signal*); - void execSUB_START_CONF(Signal*); - void execSUB_SYNC_CONF(Signal*); - void execSUB_REMOVE_CONF(Signal*); - - void execSUB_CREATE_REF(Signal*); - void execSUB_START_REF(Signal*); - void execSUB_SYNC_REF(Signal*); - void execSUB_REMOVE_REF(Signal*); - - - void execSUB_META_DATA(Signal*); - void execSUB_TABLE_DATA(Signal*); - - - void execSUB_GCP_COMPLETE_REP(Signal*); - void execSUB_SYNC_CONTINUE_REQ(Signal*); - - /************************************************************************* - * GREP Coordinator Signal Interface - *************************************************************************/ - void execGREP_CREATE_REQ(Signal*); - void execGREP_START_REQ(Signal*); - void execGREP_SYNC_REQ(Signal*); - void execGREP_REMOVE_REQ(Signal*); - - /** - * NR/NF signals - */ - void execSTART_ME(Signal *); - void execGREP_ADD_SUB_REQ(Signal *); - void execGREP_ADD_SUB_REF(Signal *); - void execGREP_ADD_SUB_CONF(Signal *); - - /************************************************************************* - * GREP Coordinator error handling interface - *************************************************************************/ - - void sendRefToPSCoord(Signal * signal, - Subscription sub, - GrepError::GE_Code err, - SubscriptionData::Part part = (SubscriptionData::Part)0); - - //protected: - BlockReference m_repRef; ///< Replication node - ///< (only one rep node per grep) - bool m_recoveryMode; - - private: - BlockReference m_coordinator; - Uint32 m_firstScanGCI; - Uint32 m_lastScanGCI; - Uint32 m_latestSeenGCI; - Grep * m_grep; - } pspart; - friend class PSPart; - - /*************************************************************************** - * AddRecSignal Stuff (should maybe be gerneralized) - ***************************************************************************/ - typedef void (Grep::* ExecSignalLocal1) (Signal* signal); - typedef void (Grep::PSCoord::* ExecSignalLocal2) (Signal* signal); - typedef void (Grep::PSPart::* ExecSignalLocal4) (Signal* signal); -}; - - -/************************************************************************* - * Requestor - * - * The following methods are callbacks (registered functions) - * for the Requestor. The Requestor calls these when it needs - * something to be done. - *************************************************************************/ -void startSubscription(void * cbObj, Signal*, int type); -void scanSubscription(void * cbObj, Signal*, int type); - -#endif diff --git a/ndb/src/kernel/blocks/grep/GrepInit.cpp b/ndb/src/kernel/blocks/grep/GrepInit.cpp deleted file mode 100644 index d764fb1f473..00000000000 --- a/ndb/src/kernel/blocks/grep/GrepInit.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* 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 */ - -#include "Grep.hpp" -#include -#include - -/***************************************************************************** - * Grep Participant - *****************************************************************************/ -#if 0 -GrepParticipant::GrepParticipant(const Configuration & conf) : - SimulatedBlock(GREP, conf) -{ - BLOCK_CONSTRUCTOR(Grep); - //m_repRef = 0; - m_latestSeenGCI = 0; -} - -GrepParticipant::~GrepParticipant() -{ -} - -BLOCK_FUNCTIONS(GrepParticipant); -#endif - -/***************************************************************************** - * Grep Coordinator - *****************************************************************************/ -Grep::Grep(const Configuration & conf) : - // GrepParticipant(conf), - SimulatedBlock(GREP, conf), - m_nodes(m_nodePool), - pscoord(this), - pspart(this) -{ - m_nodePool.setSize(MAX_NDB_NODES); - m_masterNodeId = getOwnNodeId(); - - /*************************************************************************** - * General Signals - ***************************************************************************/ - addRecSignal(GSN_STTOR, &Grep::execSTTOR); - addRecSignal(GSN_NDB_STTOR, &Grep::execNDB_STTOR); - addRecSignal(GSN_DUMP_STATE_ORD, &Grep::execDUMP_STATE_ORD); - addRecSignal(GSN_READ_NODESCONF, &Grep::execREAD_NODESCONF); - addRecSignal(GSN_NODE_FAILREP, &Grep::execNODE_FAILREP); - addRecSignal(GSN_INCL_NODEREQ, &Grep::execINCL_NODEREQ); - - addRecSignal(GSN_GREP_REQ, &Grep::execGREP_REQ); - addRecSignal(GSN_API_FAILREQ, &Grep::execAPI_FAILREQ); - - - /*************************************************************************** - * Grep::PSCoord Signal Interface - ***************************************************************************/ - /** - * From Grep::PSPart - */ - addRecSignal(GSN_GREP_CREATE_CONF, &Grep::fwdGREP_CREATE_CONF); - addRecSignal(GSN_GREP_START_CONF, &Grep::fwdGREP_START_CONF); - addRecSignal(GSN_GREP_SYNC_CONF, &Grep::fwdGREP_SYNC_CONF); - addRecSignal(GSN_GREP_REMOVE_CONF, &Grep::fwdGREP_REMOVE_CONF); - - addRecSignal(GSN_GREP_CREATE_REF, &Grep::fwdGREP_CREATE_REF); - addRecSignal(GSN_GREP_START_REF, &Grep::fwdGREP_START_REF); - addRecSignal(GSN_GREP_REMOVE_REF, &Grep::fwdGREP_REMOVE_REF); - - /** - * From Grep::SSCoord to Grep::PSCoord - */ - addRecSignal(GSN_GREP_SUB_START_REQ, &Grep::fwdGREP_SUB_START_REQ); - addRecSignal(GSN_GREP_SUB_CREATE_REQ, &Grep::fwdGREP_SUB_CREATE_REQ); - addRecSignal(GSN_GREP_SUB_SYNC_REQ, &Grep::fwdGREP_SUB_SYNC_REQ); - addRecSignal(GSN_GREP_SUB_REMOVE_REQ, &Grep::fwdGREP_SUB_REMOVE_REQ); - addRecSignal(GSN_GREP_CREATE_SUBID_REQ, &Grep::fwdGREP_CREATE_SUBID_REQ); - - /**************************************************************************** - * PSPart - ***************************************************************************/ - /** - * From SUMA to GREP PS Participant. If suma is not a coodinator - */ - addRecSignal(GSN_SUB_START_CONF, &Grep::fwdSUB_START_CONF); - addRecSignal(GSN_SUB_CREATE_CONF, &Grep::fwdSUB_CREATE_CONF); - addRecSignal(GSN_SUB_SYNC_CONF, &Grep::fwdSUB_SYNC_CONF); - addRecSignal(GSN_SUB_REMOVE_CONF, &Grep::fwdSUB_REMOVE_CONF); - addRecSignal(GSN_SUB_CREATE_REF, &Grep::fwdSUB_CREATE_REF); - addRecSignal(GSN_SUB_START_REF, &Grep::fwdSUB_START_REF); - addRecSignal(GSN_SUB_SYNC_REF, &Grep::fwdSUB_SYNC_REF); - addRecSignal(GSN_SUB_REMOVE_REF, &Grep::fwdSUB_REMOVE_REF); - - addRecSignal(GSN_SUB_SYNC_CONTINUE_REQ, - &Grep::fwdSUB_SYNC_CONTINUE_REQ); - - /** - * From Suma to Grep::PSPart. Data signals. - */ - addRecSignal(GSN_SUB_META_DATA, &Grep::fwdSUB_META_DATA); - addRecSignal(GSN_SUB_TABLE_DATA, &Grep::fwdSUB_TABLE_DATA); - addRecSignal(GSN_SUB_GCP_COMPLETE_REP, &Grep::fwdSUB_GCP_COMPLETE_REP); - - /** - * From Grep::PSCoord to Grep::PSPart - */ - addRecSignal(GSN_GREP_CREATE_REQ, &Grep::fwdGREP_CREATE_REQ); - addRecSignal(GSN_GREP_START_REQ, &Grep::fwdGREP_START_REQ); - addRecSignal(GSN_GREP_REMOVE_REQ, &Grep::fwdGREP_REMOVE_REQ); - addRecSignal(GSN_GREP_SYNC_REQ, &Grep::fwdGREP_SYNC_REQ); - addRecSignal(GSN_CREATE_SUBID_CONF, &Grep::fwdCREATE_SUBID_CONF); - addRecSignal(GSN_GREP_START_ME, &Grep::fwdSTART_ME); - addRecSignal(GSN_GREP_ADD_SUB_REQ, &Grep::fwdGREP_ADD_SUB_REQ); - addRecSignal(GSN_GREP_ADD_SUB_REF, &Grep::fwdGREP_ADD_SUB_REF); - addRecSignal(GSN_GREP_ADD_SUB_CONF, &Grep::fwdGREP_ADD_SUB_CONF); -} - -Grep::~Grep() -{ -} - -BLOCK_FUNCTIONS(Grep) - -Grep::PSPart::PSPart(Grep * sb) : - BlockComponent(sb), - c_subscriptions(c_subscriptionPool) -{ - m_grep = sb; - - m_firstScanGCI = 1; // Empty interval = [1,0] - m_lastScanGCI = 0; - - m_latestSeenGCI = 0; - - c_subscriptions.setSize(10); - c_subscriptionPool.setSize(10); -} - -Grep::PSCoord::PSCoord(Grep * sb) : - BlockComponent(sb), - c_runningSubscriptions(c_subCoordinatorPool) -{ - m_grep = sb; - c_runningSubscriptions.setSize(10); - c_subCoordinatorPool.setSize(2); -} - -//BLOCK_FUNCTIONS(Grep::PSCoord); - -BlockComponent::BlockComponent(SimulatedBlock * sb) { - m_sb = sb; -} diff --git a/ndb/src/kernel/blocks/grep/Makefile.am b/ndb/src/kernel/blocks/grep/Makefile.am deleted file mode 100644 index 6d2b422784b..00000000000 --- a/ndb/src/kernel/blocks/grep/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -noinst_LIBRARIES = libgrep.a - -libgrep_a_SOURCES = Grep.cpp GrepInit.cpp - -include $(top_srcdir)/ndb/config/common.mk.am -include $(top_srcdir)/ndb/config/type_kernel.mk.am - -# Don't update the files from bitkeeper -%::SCCS/s.% - -windoze-dsp: libgrep.dsp - -libgrep.dsp: Makefile \ - $(top_srcdir)/ndb/config/win-lib.am \ - $(top_srcdir)/ndb/config/win-name \ - $(top_srcdir)/ndb/config/win-includes \ - $(top_srcdir)/ndb/config/win-sources \ - $(top_srcdir)/ndb/config/win-libraries - cat $(top_srcdir)/ndb/config/win-lib.am > $@ - @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) - @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) - @$(top_srcdir)/ndb/config/win-sources $@ $(libgrep_a_SOURCES) - @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/grep/systab_test/Makefile b/ndb/src/kernel/blocks/grep/systab_test/Makefile deleted file mode 100644 index bd69e0f3799..00000000000 --- a/ndb/src/kernel/blocks/grep/systab_test/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include .defs.mk - -TYPE := kernel - -BIN_TARGET := grep_systab_test -BIN_TARGET_ARCHIVES := portlib general - -CCFLAGS_LOC += -I.. - -SOURCES = ../GrepSystemTable.cpp grep_systab_test.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/grep/systab_test/grep_systab_test.cpp b/ndb/src/kernel/blocks/grep/systab_test/grep_systab_test.cpp deleted file mode 100644 index e3a77af4e4e..00000000000 --- a/ndb/src/kernel/blocks/grep/systab_test/grep_systab_test.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* 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 */ - -/** - * Unit Test for GrepSystemTable - */ - -#include "../GrepSystemTable.hpp" -#include - -#define EXEC(X) ( ndbout << endl, ndbout_c(#X), X ) - -int -main () { - GrepSystemTable st; - - Uint32 f, l; - - ndbout_c("*************************************"); - ndbout_c("* GrepSystemTable Unit Test Program *"); - ndbout_c("*************************************"); - - ndbout_c("--------------------------------------------------------"); - ndbout_c("Test 1: Clear"); - ndbout_c("--------------------------------------------------------"); - - EXEC(st.set(GrepSystemTable::PS, 22, 26)); - st.print(); - st.require(GrepSystemTable::PS, 22, 26); - - EXEC(st.clear(GrepSystemTable::PS, 20, 24)); - st.print(); - st.require(GrepSystemTable::PS, 25, 26); - - EXEC(st.clear(GrepSystemTable::PS, 0, 100)); - st.print(); - st.require(GrepSystemTable::PS, 1, 0); - - EXEC(st.set(GrepSystemTable::PS, 22, 26)); - st.print(); - st.require(GrepSystemTable::PS, 22, 26); - - EXEC(st.clear(GrepSystemTable::PS, 24, 28)); - st.print(); - st.require(GrepSystemTable::PS, 22, 23); - - EXEC(st.clear(GrepSystemTable::PS, 0, 100)); - st.print(); - st.require(GrepSystemTable::PS, 1, 0); - - EXEC(st.set(GrepSystemTable::PS, 22, 26)); - st.print(); - st.require(GrepSystemTable::PS, 22, 26); - - EXEC(st.clear(GrepSystemTable::PS, 24, 26)); - st.print(); - st.require(GrepSystemTable::PS, 22, 23); - - EXEC(st.clear(GrepSystemTable::PS, 0, 100)); - st.print(); - st.require(GrepSystemTable::PS, 1, 0); - - EXEC(st.set(GrepSystemTable::PS, 22, 26)); - st.print(); - st.require(GrepSystemTable::PS, 22, 26); - - EXEC(st.clear(GrepSystemTable::PS, 22, 24)); - st.print(); - st.require(GrepSystemTable::PS, 25, 26); - - ndbout_c("--------------------------------------------------------"); - ndbout_c("Test 2: PS --> SSreq"); - ndbout_c("--------------------------------------------------------"); - - EXEC(st.set(GrepSystemTable::PS, 22, 26)); - st.print(); - st.require(GrepSystemTable::PS, 22, 26); - st.require(GrepSystemTable::SSReq, 1, 0); - - if (!EXEC(st.copy(GrepSystemTable::PS, GrepSystemTable::SSReq, 3, &f, &l))) - ndbout_c("%s:%d: Illegal copy!", __FILE__, __FILE__); - ndbout_c("f=%d, l=%d", f, l); - st.print(); - st.require(GrepSystemTable::PS, 22, 26); - st.require(GrepSystemTable::SSReq, 22, 24); - - EXEC(st.clear(GrepSystemTable::PS, 22, 22)); - st.print(); - st.require(GrepSystemTable::PS, 23, 26); - st.require(GrepSystemTable::SSReq, 22, 24); - - if (!EXEC(st.copy(GrepSystemTable::PS, GrepSystemTable::SSReq, 2, &f, &l))) - ndbout_c("%s:%d: Illegal copy!", __FILE__, __LINE__); - ndbout_c("f=%d, l=%d", f, l); - st.print(); - st.require(GrepSystemTable::PS, 23, 26); - st.require(GrepSystemTable::SSReq, 22, 26); - - st.set(GrepSystemTable::SS, 7, 9); - st.set(GrepSystemTable::InsReq, 7, 9); - if (EXEC(st.movable(GrepSystemTable::SS, GrepSystemTable::InsReq))) - ndbout_c("%s:%d: Illegal move!", __FILE__, __LINE__); - st.print(); - st.require(GrepSystemTable::SS, 7, 9); - st.require(GrepSystemTable::InsReq, 7, 9); - - EXEC(st.intervalMinus(7, 9, 7, 7, &f, &l)); - ndbout_c("f=%d, l=%d", f, l); - - st.clear(GrepSystemTable::InsReq, 8, 9); - st.require(GrepSystemTable::SS, 7, 9); - st.require(GrepSystemTable::InsReq, 7, 7); - if (EXEC(st.movable(GrepSystemTable::SS, GrepSystemTable::InsReq)) != 2) - ndbout_c("%s:%d: Illegal move!", __FILE__, __LINE__); - st.print(); - - EXEC(st.copy(GrepSystemTable::SS, GrepSystemTable::InsReq, &f)); - st.print(); - st.require(GrepSystemTable::SS, 7, 9); - st.require(GrepSystemTable::InsReq, 7, 8); - - ndbout_c("--------------------------------------------------------"); - ndbout_c("Test completed"); - ndbout_c("--------------------------------------------------------"); -} diff --git a/ndb/test/ndbapi/testGrep.cpp b/ndb/test/ndbapi/testGrep.cpp deleted file mode 100644 index 713aefbeafa..00000000000 --- a/ndb/test/ndbapi/testGrep.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/* 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 */ - -#include -#include -#include -#include -#include - - -#define CHECK(b) if (!(b)) { \ - g_err << "ERR: "<< step->getName() \ - << " failed on line " << __LINE__ << endl; \ - result = NDBT_FAILED; \ - continue; } - - -int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){ - - int records = ctx->getNumRecords(); - HugoTransactions hugoTrans(*ctx->getTab()); - if (hugoTrans.loadTable(GETNDB(step), records) != 0){ - return NDBT_FAILED; - } - return NDBT_OK; -} - -int runPkUpdate(NDBT_Context* ctx, NDBT_Step* step){ - int loops = ctx->getNumLoops(); - int records = ctx->getNumRecords(); - int batchSize = ctx->getProperty("BatchSize", 1); - int i = 0; - HugoTransactions hugoTrans(*ctx->getTab()); - while (igetTab(); - pNdb->getDictionary()->dropTable(tab->getName()); - - if (restarter.restartAll(true) != 0) - return NDBT_FAILED; - - return NDBT_OK; -} - -int runRestarter(NDBT_Context* ctx, NDBT_Step* step){ - int result = NDBT_OK; - int loops = ctx->getNumLoops(); - NdbRestarter restarter; - int i = 0; - int lastId = 0; - - if (restarter.getNumDbNodes() < 2){ - ctx->stopTest(); - return NDBT_OK; - } - - if(restarter.waitClusterStarted(60) != 0){ - g_err << "Cluster failed to start" << endl; - return NDBT_FAILED; - } - - loops *= restarter.getNumDbNodes(); - while(iisTestStopped()){ - - int id = lastId % restarter.getNumDbNodes(); - int nodeId = restarter.getDbNodeId(id); - ndbout << "Restart node " << nodeId << endl; - if(restarter.restartOneDbNode(nodeId) != 0){ - g_err << "Failed to restartNextDbNode" << endl; - result = NDBT_FAILED; - break; - } - - if(restarter.waitClusterStarted(60) != 0){ - g_err << "Cluster failed to start" << endl; - result = NDBT_FAILED; - break; - } - - NdbSleep_SecSleep(1); - - lastId++; - i++; - } - - ctx->stopTest(); - - return result; -} - -int runCheckAllNodesStarted(NDBT_Context* ctx, NDBT_Step* step){ - NdbRestarter restarter; - - if(restarter.waitClusterStarted(1) != 0){ - g_err << "All nodes was not started " << endl; - return NDBT_FAILED; - } - - return NDBT_OK; -} - - -bool testMaster = true; -bool testSlave = false; - -int setMaster(NDBT_Context* ctx, NDBT_Step* step){ - testMaster = true; - testSlave = false; - return NDBT_OK; -} -int setMasterAsSlave(NDBT_Context* ctx, NDBT_Step* step){ - testMaster = true; - testSlave = true; - return NDBT_OK; -} -int setSlave(NDBT_Context* ctx, NDBT_Step* step){ - testMaster = false; - testSlave = true; - return NDBT_OK; -} - -int runAbort(NDBT_Context* ctx, NDBT_Step* step){ - - - NdbGrep grep(GETNDB(step)->getNodeId()+1); - NdbRestarter restarter; - - if (restarter.getNumDbNodes() < 2){ - ctx->stopTest(); - return NDBT_OK; - } - - if(restarter.waitClusterStarted(60) != 0){ - g_err << "Cluster failed to start" << endl; - return NDBT_FAILED; - } - - if (testMaster) { - if (testSlave) { - if (grep.NFMasterAsSlave(restarter) == -1){ - return NDBT_FAILED; - } - } else { - if (grep.NFMaster(restarter) == -1){ - return NDBT_FAILED; - } - } - } else { - if (grep.NFSlave(restarter) == -1){ - return NDBT_FAILED; - } - } - - return NDBT_OK; -} - -int runFail(NDBT_Context* ctx, NDBT_Step* step){ - NdbGrep grep(GETNDB(step)->getNodeId()+1); - - NdbRestarter restarter; - - if (restarter.getNumDbNodes() < 2){ - ctx->stopTest(); - return NDBT_OK; - } - - if(restarter.waitClusterStarted(60) != 0){ - g_err << "Cluster failed to start" << endl; - return NDBT_FAILED; - } - - if (testMaster) { - if (testSlave) { - if (grep.FailMasterAsSlave(restarter) == -1){ - return NDBT_FAILED; - } - } else { - if (grep.FailMaster(restarter) == -1){ - return NDBT_FAILED; - } - } - } else { - if (grep.FailSlave(restarter) == -1){ - return NDBT_FAILED; - } - } - - return NDBT_OK; -} - -int runGrepBasic(NDBT_Context* ctx, NDBT_Step* step){ - NdbGrep grep(GETNDB(step)->getNodeId()+1); - unsigned grepId = 0; - - if (grep.start() == -1){ - return NDBT_FAILED; - } - ndbout << "Started grep " << grepId << endl; - ctx->setProperty("GrepId", grepId); - - return NDBT_OK; -} - - - - -int runVerifyBasic(NDBT_Context* ctx, NDBT_Step* step){ - NdbGrep grep(GETNDB(step)->getNodeId()+1, ctx->getRemoteMgm()); - ndbout_c("no of nodes %d" ,grep.getNumDbNodes()); - int result; - if ((result = grep.verify(ctx)) == -1){ - return NDBT_FAILED; - } - return result; -} - - - -int runClearTable(NDBT_Context* ctx, NDBT_Step* step){ - int records = ctx->getNumRecords(); - - UtilTransactions utilTrans(*ctx->getTab()); - if (utilTrans.clearTable2(GETNDB(step), records) != 0){ - return NDBT_FAILED; - } - return NDBT_OK; -} - -#include "bank/Bank.hpp" - -int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){ - Bank bank; - int overWriteExisting = true; - if (bank.createAndLoadBank(overWriteExisting) != NDBT_OK) - return NDBT_FAILED; - return NDBT_OK; -} - -int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){ - Bank bank; - int wait = 30; // Max seconds between each "day" - int yield = 1; // Loops before bank returns - - while (ctx->isTestStopped() == false) { - bank.performIncreaseTime(wait, yield); - } - return NDBT_OK; -} - -int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){ - Bank bank; - int wait = 10; // Max ms between each transaction - int yield = 100; // Loops before bank returns - - while (ctx->isTestStopped() == false) { - bank.performTransactions(wait, yield); - } - return NDBT_OK; -} - -int runBankGL(NDBT_Context* ctx, NDBT_Step* step){ - Bank bank; - int yield = 20; // Loops before bank returns - int result = NDBT_OK; - - while (ctx->isTestStopped() == false) { - if (bank.performMakeGLs(yield) != NDBT_OK){ - ndbout << "bank.performMakeGLs FAILED" << endl; - result = NDBT_FAILED; - } - } - return NDBT_OK; -} - -int runBankSum(NDBT_Context* ctx, NDBT_Step* step){ - Bank bank; - int wait = 2000; // Max ms between each sum of accounts - int yield = 1; // Loops before bank returns - int result = NDBT_OK; - - while (ctx->isTestStopped() == false) { - if (bank.performSumAccounts(wait, yield) != NDBT_OK){ - ndbout << "bank.performSumAccounts FAILED" << endl; - result = NDBT_FAILED; - } - } - return result ; -} - -int runDropBank(NDBT_Context* ctx, NDBT_Step* step){ - Bank bank; - if (bank.dropBank() != NDBT_OK) - return NDBT_FAILED; - return NDBT_OK; -} - -int runGrepBank(NDBT_Context* ctx, NDBT_Step* step){ - int loops = ctx->getNumLoops(); - int l = 0; - int maxSleep = 30; // Max seconds between each grep - Ndb* pNdb = GETNDB(step); - NdbGrep grep(GETNDB(step)->getNodeId()+1); - unsigned minGrepId = ~0; - unsigned maxGrepId = 0; - unsigned grepId = 0; - int result = NDBT_OK; - - while (l < loops && result != NDBT_FAILED){ - - if (pNdb->waitUntilReady() != 0){ - result = NDBT_FAILED; - continue; - } - - // Sleep for a while - NdbSleep_SecSleep(maxSleep); - - // Perform grep - if (grep.start() != 0){ - ndbout << "grep.start failed" << endl; - result = NDBT_FAILED; - continue; - } - ndbout << "Started grep " << grepId << endl; - - // Remember min and max grepid - if (grepId < minGrepId) - minGrepId = grepId; - - if (grepId > maxGrepId) - maxGrepId = grepId; - - ndbout << " maxGrepId = " << maxGrepId - << ", minGrepId = " << minGrepId << endl; - ctx->setProperty("MinGrepId", minGrepId); - ctx->setProperty("MaxGrepId", maxGrepId); - - l++; - } - - ctx->stopTest(); - - return result; -} -/* -int runRestoreBankAndVerify(NDBT_Context* ctx, NDBT_Step* step){ - NdbRestarter restarter; - NdbGrep grep(GETNDB(step)->getNodeId()+1); - unsigned minGrepId = ctx->getProperty("MinGrepId"); - unsigned maxGrepId = ctx->getProperty("MaxGrepId"); - unsigned grepId = minGrepId; - int result = NDBT_OK; - int errSumAccounts = 0; - int errValidateGL = 0; - - ndbout << " maxGrepId = " << maxGrepId << endl; - ndbout << " minGrepId = " << minGrepId << endl; - - while (grepId <= maxGrepId){ - - // TEMPORARY FIX - // To erase all tables from cache(s) - // To be removed, maybe replaced by ndb.invalidate(); - { - Bank bank; - - if (bank.dropBank() != NDBT_OK){ - result = NDBT_FAILED; - break; - } - } - // END TEMPORARY FIX - - ndbout << "Performing initial restart" << endl; - if (restarter.restartAll(true) != 0) - return NDBT_FAILED; - - if (restarter.waitClusterStarted() != 0) - return NDBT_FAILED; - - ndbout << "Restoring grep " << grepId << endl; - if (grep.restore(grepId) == -1){ - return NDBT_FAILED; - } - ndbout << "Grep " << grepId << " restored" << endl; - - // Let bank verify - Bank bank; - - int wait = 0; - int yield = 1; - if (bank.performSumAccounts(wait, yield) != 0){ - ndbout << "bank.performSumAccounts FAILED" << endl; - ndbout << " grepId = " << grepId << endl << endl; - result = NDBT_FAILED; - errSumAccounts++; - } - - if (bank.performValidateAllGLs() != 0){ - ndbout << "bank.performValidateAllGLs FAILED" << endl; - ndbout << " grepId = " << grepId << endl << endl; - result = NDBT_FAILED; - errValidateGL++; - } - - grepId++; - } - - if (result != NDBT_OK){ - ndbout << "Verification of grep failed" << endl - << " errValidateGL="< Date: Wed, 24 Aug 2005 17:27:46 +0300 Subject: [PATCH 17/20] ha_innodb.cc: Fix bug #12779 : never give a row count estimate of 0 to the MySQL query optimizer, as then left join optimizer may beleive it KNOWS that the table is empty; note that this fix may change query optimization of many other queries where one table is empty; note that the proper fix would be to make the query optimizer to know that the row count estimates it receives really are just estimates, it cannot assume they are certain --- sql/ha_innodb.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index bcd07198f5c..3ae56f13478 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4109,6 +4109,7 @@ ha_innobase::info( dict_table_t* ib_table; dict_index_t* index; ha_rows rec_per_key; + ib_longlong n_rows; ulong j; ulong i; @@ -4151,7 +4152,30 @@ ha_innobase::info( } if (flag & HA_STATUS_VARIABLE) { - records = (ha_rows)ib_table->stat_n_rows; + n_rows = ib_table->stat_n_rows; + + /* Because we do not protect stat_n_rows by any mutex in a + delete, it is theoretically possible that the value can be + smaller than zero! TODO: fix this race. + + The MySQL optimizer seems to assume in a left join that n_rows + is an accurate estimate if it is zero. Of course, it is not, + since we do not have any locks on the rows yet at this phase. + Since SHOW TABLE STATUS seems to call this function with the + HA_STATUS_TIME flag set, while the left join optizer does not + set that flag, we add one to a zero value if the flag is not + set. That way SHOW TABLE STATUS will show the best estimate, + while the optimizer never sees the table empty. */ + + if (n_rows < 0) { + n_rows = 0; + } + + if (n_rows == 0 && !(flag & HA_STATUS_TIME)) { + n_rows++; + } + + records = (ha_rows)n_rows; deleted = 0; data_file_length = ((ulonglong) ib_table->stat_clustered_index_size) From 4bedb3091c5b6869ea8611ca728dd7c1fdb03651 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Wed, 24 Aug 2005 18:05:54 +0300 Subject: [PATCH 18/20] subselect2.result: Update test result to reflect the fix of Bug #12779 : EXPLAIN SELECT of a subquery is now different --- mysql-test/r/subselect2.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/subselect2.result b/mysql-test/r/subselect2.result index b04fec26c6f..148c670c589 100644 --- a/mysql-test/r/subselect2.result +++ b/mysql-test/r/subselect2.result @@ -120,9 +120,9 @@ DOCID DOCNAME DOCTYPEID FOLDERID AUTHOR CREATED TITLE SUBTITLE DOCABSTRACT PUBLI c373e9f5ad07993f3859444553544200 Last Discussion c373e9f5ad079174ff17444553544200 c373e9f5ad0796c0eca4444553544200 Goldilocks 2003-06-09 11:21:06 Title: Last Discussion NULL Setting new abstract and keeping doc checked out 2003-06-09 10:51:26 2003-06-09 10:51:26 NULL NULL NULL 03eea05112b845949f3fd03278b5fe43 2003-06-09 11:21:06 admin 0 NULL Discussion NULL NULL EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 system PRIMARY NULL NULL NULL 0 const row not found 1 PRIMARY t2 ALL DDOCTYPEID_IDX NULL NULL NULL 9 Using where 1 PRIMARY t4 eq_ref PRIMARY PRIMARY 32 test.t2.DOCTYPEID 1 +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 32 test.t2.DOCID 1 2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where 3 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where 4 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where From 8e6aa0e7eacc22d061b1129fe8bf540414f6a036 Mon Sep 17 00:00:00 2001 From: "monty@mishka.local" <> Date: Wed, 24 Aug 2005 19:37:27 +0300 Subject: [PATCH 19/20] Review fixes --- mysql-test/r/ctype_cp932.result | 3 +- mysql-test/r/rpl_drop_db.result | 1034 +------------------------------ mysql-test/t/ctype_cp932.test | 2 +- mysql-test/t/rpl_drop_db.test | 34 +- sql/sql_db.cc | 94 ++- 5 files changed, 84 insertions(+), 1083 deletions(-) diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result index 0711f251a07..d8221a58b9e 100644 --- a/mysql-test/r/ctype_cp932.result +++ b/mysql-test/r/ctype_cp932.result @@ -8581,9 +8581,8 @@ CREATE TABLE t1(f1 blob); PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)'; SET @var1= x'8300'; EXECUTE stmt1 USING @var1; -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 79; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.000001 # Start 1 # Server ver: 4.1.15-debug-log, Binlog ver: 3 master-bin.000001 # Query 1 # use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=95,COLLATION_CONNECTION=95,COLLATION_DATABASE=95,COLLATION_SERVER=8 master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(f1 blob) master-bin.000001 # Query 1 # use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=95,COLLATION_CONNECTION=95,COLLATION_DATABASE=95,COLLATION_SERVER=8 diff --git a/mysql-test/r/rpl_drop_db.result b/mysql-test/r/rpl_drop_db.result index 01a2af5341b..3d1dfba5b05 100644 --- a/mysql-test/r/rpl_drop_db.result +++ b/mysql-test/r/rpl_drop_db.result @@ -4,1029 +4,29 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; -drop database if exists d1; -create database d1; -create table d1.t1 (n int); -insert into d1.t1 values (1); -select * from d1.t1 into outfile 'd1/f1.txt'; -create table d1.t2 (n int); -create table d1.t3 (n int); -drop database d1; -ERROR HY000: Error dropping database (can't rmdir './d1/', errno: 17) -use d1; +drop database if exists mysqltest; +create database mysqltest; +create table mysqltest.t1 (n int); +insert into mysqltest.t1 values (1); +select * from mysqltest.t1 into outfile 'mysqltest/f1.txt'; +create table mysqltest.t2 (n int); +create table mysqltest.t3 (n int); +drop database mysqltest; +ERROR HY000: Error dropping database (can't rmdir './mysqltest/', errno: 17) +use mysqltest; show tables; -Tables_in_d1 -create table d1.t1000(n int); -create table d1.t999(n int); -create table d1.t998(n int); -create table d1.t997(n int); -create table d1.t996(n int); -create table d1.t995(n int); -create table d1.t994(n int); -create table d1.t993(n int); -create table d1.t992(n int); -create table d1.t991(n int); -create table d1.t990(n int); -create table d1.t989(n int); -create table d1.t988(n int); -create table d1.t987(n int); -create table d1.t986(n int); -create table d1.t985(n int); -create table d1.t984(n int); -create table d1.t983(n int); -create table d1.t982(n int); -create table d1.t981(n int); -create table d1.t980(n int); -create table d1.t979(n int); -create table d1.t978(n int); -create table d1.t977(n int); -create table d1.t976(n int); -create table d1.t975(n int); -create table d1.t974(n int); -create table d1.t973(n int); -create table d1.t972(n int); -create table d1.t971(n int); -create table d1.t970(n int); -create table d1.t969(n int); -create table d1.t968(n int); -create table d1.t967(n int); -create table d1.t966(n int); -create table d1.t965(n int); -create table d1.t964(n int); -create table d1.t963(n int); -create table d1.t962(n int); -create table d1.t961(n int); -create table d1.t960(n int); -create table d1.t959(n int); -create table d1.t958(n int); -create table d1.t957(n int); -create table d1.t956(n int); -create table d1.t955(n int); -create table d1.t954(n int); -create table d1.t953(n int); -create table d1.t952(n int); -create table d1.t951(n int); -create table d1.t950(n int); -create table d1.t949(n int); -create table d1.t948(n int); -create table d1.t947(n int); -create table d1.t946(n int); -create table d1.t945(n int); -create table d1.t944(n int); -create table d1.t943(n int); -create table d1.t942(n int); -create table d1.t941(n int); -create table d1.t940(n int); -create table d1.t939(n int); -create table d1.t938(n int); -create table d1.t937(n int); -create table d1.t936(n int); -create table d1.t935(n int); -create table d1.t934(n int); -create table d1.t933(n int); -create table d1.t932(n int); -create table d1.t931(n int); -create table d1.t930(n int); -create table d1.t929(n int); -create table d1.t928(n int); -create table d1.t927(n int); -create table d1.t926(n int); -create table d1.t925(n int); -create table d1.t924(n int); -create table d1.t923(n int); -create table d1.t922(n int); -create table d1.t921(n int); -create table d1.t920(n int); -create table d1.t919(n int); -create table d1.t918(n int); -create table d1.t917(n int); -create table d1.t916(n int); -create table d1.t915(n int); -create table d1.t914(n int); -create table d1.t913(n int); -create table d1.t912(n int); -create table d1.t911(n int); -create table d1.t910(n int); -create table d1.t909(n int); -create table d1.t908(n int); -create table d1.t907(n int); -create table d1.t906(n int); -create table d1.t905(n int); -create table d1.t904(n int); -create table d1.t903(n int); -create table d1.t902(n int); -create table d1.t901(n int); -create table d1.t900(n int); -create table d1.t899(n int); -create table d1.t898(n int); -create table d1.t897(n int); -create table d1.t896(n int); -create table d1.t895(n int); -create table d1.t894(n int); -create table d1.t893(n int); -create table d1.t892(n int); -create table d1.t891(n int); -create table d1.t890(n int); -create table d1.t889(n int); -create table d1.t888(n int); -create table d1.t887(n int); -create table d1.t886(n int); -create table d1.t885(n int); -create table d1.t884(n int); -create table d1.t883(n int); -create table d1.t882(n int); -create table d1.t881(n int); -create table d1.t880(n int); -create table d1.t879(n int); -create table d1.t878(n int); -create table d1.t877(n int); -create table d1.t876(n int); -create table d1.t875(n int); -create table d1.t874(n int); -create table d1.t873(n int); -create table d1.t872(n int); -create table d1.t871(n int); -create table d1.t870(n int); -create table d1.t869(n int); -create table d1.t868(n int); -create table d1.t867(n int); -create table d1.t866(n int); -create table d1.t865(n int); -create table d1.t864(n int); -create table d1.t863(n int); -create table d1.t862(n int); -create table d1.t861(n int); -create table d1.t860(n int); -create table d1.t859(n int); -create table d1.t858(n int); -create table d1.t857(n int); -create table d1.t856(n int); -create table d1.t855(n int); -create table d1.t854(n int); -create table d1.t853(n int); -create table d1.t852(n int); -create table d1.t851(n int); -create table d1.t850(n int); -create table d1.t849(n int); -create table d1.t848(n int); -create table d1.t847(n int); -create table d1.t846(n int); -create table d1.t845(n int); -create table d1.t844(n int); -create table d1.t843(n int); -create table d1.t842(n int); -create table d1.t841(n int); -create table d1.t840(n int); -create table d1.t839(n int); -create table d1.t838(n int); -create table d1.t837(n int); -create table d1.t836(n int); -create table d1.t835(n int); -create table d1.t834(n int); -create table d1.t833(n int); -create table d1.t832(n int); -create table d1.t831(n int); -create table d1.t830(n int); -create table d1.t829(n int); -create table d1.t828(n int); -create table d1.t827(n int); -create table d1.t826(n int); -create table d1.t825(n int); -create table d1.t824(n int); -create table d1.t823(n int); -create table d1.t822(n int); -create table d1.t821(n int); -create table d1.t820(n int); -create table d1.t819(n int); -create table d1.t818(n int); -create table d1.t817(n int); -create table d1.t816(n int); -create table d1.t815(n int); -create table d1.t814(n int); -create table d1.t813(n int); -create table d1.t812(n int); -create table d1.t811(n int); -create table d1.t810(n int); -create table d1.t809(n int); -create table d1.t808(n int); -create table d1.t807(n int); -create table d1.t806(n int); -create table d1.t805(n int); -create table d1.t804(n int); -create table d1.t803(n int); -create table d1.t802(n int); -create table d1.t801(n int); -create table d1.t800(n int); -create table d1.t799(n int); -create table d1.t798(n int); -create table d1.t797(n int); -create table d1.t796(n int); -create table d1.t795(n int); -create table d1.t794(n int); -create table d1.t793(n int); -create table d1.t792(n int); -create table d1.t791(n int); -create table d1.t790(n int); -create table d1.t789(n int); -create table d1.t788(n int); -create table d1.t787(n int); -create table d1.t786(n int); -create table d1.t785(n int); -create table d1.t784(n int); -create table d1.t783(n int); -create table d1.t782(n int); -create table d1.t781(n int); -create table d1.t780(n int); -create table d1.t779(n int); -create table d1.t778(n int); -create table d1.t777(n int); -create table d1.t776(n int); -create table d1.t775(n int); -create table d1.t774(n int); -create table d1.t773(n int); -create table d1.t772(n int); -create table d1.t771(n int); -create table d1.t770(n int); -create table d1.t769(n int); -create table d1.t768(n int); -create table d1.t767(n int); -create table d1.t766(n int); -create table d1.t765(n int); -create table d1.t764(n int); -create table d1.t763(n int); -create table d1.t762(n int); -create table d1.t761(n int); -create table d1.t760(n int); -create table d1.t759(n int); -create table d1.t758(n int); -create table d1.t757(n int); -create table d1.t756(n int); -create table d1.t755(n int); -create table d1.t754(n int); -create table d1.t753(n int); -create table d1.t752(n int); -create table d1.t751(n int); -create table d1.t750(n int); -create table d1.t749(n int); -create table d1.t748(n int); -create table d1.t747(n int); -create table d1.t746(n int); -create table d1.t745(n int); -create table d1.t744(n int); -create table d1.t743(n int); -create table d1.t742(n int); -create table d1.t741(n int); -create table d1.t740(n int); -create table d1.t739(n int); -create table d1.t738(n int); -create table d1.t737(n int); -create table d1.t736(n int); -create table d1.t735(n int); -create table d1.t734(n int); -create table d1.t733(n int); -create table d1.t732(n int); -create table d1.t731(n int); -create table d1.t730(n int); -create table d1.t729(n int); -create table d1.t728(n int); -create table d1.t727(n int); -create table d1.t726(n int); -create table d1.t725(n int); -create table d1.t724(n int); -create table d1.t723(n int); -create table d1.t722(n int); -create table d1.t721(n int); -create table d1.t720(n int); -create table d1.t719(n int); -create table d1.t718(n int); -create table d1.t717(n int); -create table d1.t716(n int); -create table d1.t715(n int); -create table d1.t714(n int); -create table d1.t713(n int); -create table d1.t712(n int); -create table d1.t711(n int); -create table d1.t710(n int); -create table d1.t709(n int); -create table d1.t708(n int); -create table d1.t707(n int); -create table d1.t706(n int); -create table d1.t705(n int); -create table d1.t704(n int); -create table d1.t703(n int); -create table d1.t702(n int); -create table d1.t701(n int); -create table d1.t700(n int); -create table d1.t699(n int); -create table d1.t698(n int); -create table d1.t697(n int); -create table d1.t696(n int); -create table d1.t695(n int); -create table d1.t694(n int); -create table d1.t693(n int); -create table d1.t692(n int); -create table d1.t691(n int); -create table d1.t690(n int); -create table d1.t689(n int); -create table d1.t688(n int); -create table d1.t687(n int); -create table d1.t686(n int); -create table d1.t685(n int); -create table d1.t684(n int); -create table d1.t683(n int); -create table d1.t682(n int); -create table d1.t681(n int); -create table d1.t680(n int); -create table d1.t679(n int); -create table d1.t678(n int); -create table d1.t677(n int); -create table d1.t676(n int); -create table d1.t675(n int); -create table d1.t674(n int); -create table d1.t673(n int); -create table d1.t672(n int); -create table d1.t671(n int); -create table d1.t670(n int); -create table d1.t669(n int); -create table d1.t668(n int); -create table d1.t667(n int); -create table d1.t666(n int); -create table d1.t665(n int); -create table d1.t664(n int); -create table d1.t663(n int); -create table d1.t662(n int); -create table d1.t661(n int); -create table d1.t660(n int); -create table d1.t659(n int); -create table d1.t658(n int); -create table d1.t657(n int); -create table d1.t656(n int); -create table d1.t655(n int); -create table d1.t654(n int); -create table d1.t653(n int); -create table d1.t652(n int); -create table d1.t651(n int); -create table d1.t650(n int); -create table d1.t649(n int); -create table d1.t648(n int); -create table d1.t647(n int); -create table d1.t646(n int); -create table d1.t645(n int); -create table d1.t644(n int); -create table d1.t643(n int); -create table d1.t642(n int); -create table d1.t641(n int); -create table d1.t640(n int); -create table d1.t639(n int); -create table d1.t638(n int); -create table d1.t637(n int); -create table d1.t636(n int); -create table d1.t635(n int); -create table d1.t634(n int); -create table d1.t633(n int); -create table d1.t632(n int); -create table d1.t631(n int); -create table d1.t630(n int); -create table d1.t629(n int); -create table d1.t628(n int); -create table d1.t627(n int); -create table d1.t626(n int); -create table d1.t625(n int); -create table d1.t624(n int); -create table d1.t623(n int); -create table d1.t622(n int); -create table d1.t621(n int); -create table d1.t620(n int); -create table d1.t619(n int); -create table d1.t618(n int); -create table d1.t617(n int); -create table d1.t616(n int); -create table d1.t615(n int); -create table d1.t614(n int); -create table d1.t613(n int); -create table d1.t612(n int); -create table d1.t611(n int); -create table d1.t610(n int); -create table d1.t609(n int); -create table d1.t608(n int); -create table d1.t607(n int); -create table d1.t606(n int); -create table d1.t605(n int); -create table d1.t604(n int); -create table d1.t603(n int); -create table d1.t602(n int); -create table d1.t601(n int); -create table d1.t600(n int); -create table d1.t599(n int); -create table d1.t598(n int); -create table d1.t597(n int); -create table d1.t596(n int); -create table d1.t595(n int); -create table d1.t594(n int); -create table d1.t593(n int); -create table d1.t592(n int); -create table d1.t591(n int); -create table d1.t590(n int); -create table d1.t589(n int); -create table d1.t588(n int); -create table d1.t587(n int); -create table d1.t586(n int); -create table d1.t585(n int); -create table d1.t584(n int); -create table d1.t583(n int); -create table d1.t582(n int); -create table d1.t581(n int); -create table d1.t580(n int); -create table d1.t579(n int); -create table d1.t578(n int); -create table d1.t577(n int); -create table d1.t576(n int); -create table d1.t575(n int); -create table d1.t574(n int); -create table d1.t573(n int); -create table d1.t572(n int); -create table d1.t571(n int); -create table d1.t570(n int); -create table d1.t569(n int); -create table d1.t568(n int); -create table d1.t567(n int); -create table d1.t566(n int); -create table d1.t565(n int); -create table d1.t564(n int); -create table d1.t563(n int); -create table d1.t562(n int); -create table d1.t561(n int); -create table d1.t560(n int); -create table d1.t559(n int); -create table d1.t558(n int); -create table d1.t557(n int); -create table d1.t556(n int); -create table d1.t555(n int); -create table d1.t554(n int); -create table d1.t553(n int); -create table d1.t552(n int); -create table d1.t551(n int); -create table d1.t550(n int); -create table d1.t549(n int); -create table d1.t548(n int); -create table d1.t547(n int); -create table d1.t546(n int); -create table d1.t545(n int); -create table d1.t544(n int); -create table d1.t543(n int); -create table d1.t542(n int); -create table d1.t541(n int); -create table d1.t540(n int); -create table d1.t539(n int); -create table d1.t538(n int); -create table d1.t537(n int); -create table d1.t536(n int); -create table d1.t535(n int); -create table d1.t534(n int); -create table d1.t533(n int); -create table d1.t532(n int); -create table d1.t531(n int); -create table d1.t530(n int); -create table d1.t529(n int); -create table d1.t528(n int); -create table d1.t527(n int); -create table d1.t526(n int); -create table d1.t525(n int); -create table d1.t524(n int); -create table d1.t523(n int); -create table d1.t522(n int); -create table d1.t521(n int); -create table d1.t520(n int); -create table d1.t519(n int); -create table d1.t518(n int); -create table d1.t517(n int); -create table d1.t516(n int); -create table d1.t515(n int); -create table d1.t514(n int); -create table d1.t513(n int); -create table d1.t512(n int); -create table d1.t511(n int); -create table d1.t510(n int); -create table d1.t509(n int); -create table d1.t508(n int); -create table d1.t507(n int); -create table d1.t506(n int); -create table d1.t505(n int); -create table d1.t504(n int); -create table d1.t503(n int); -create table d1.t502(n int); -create table d1.t501(n int); -create table d1.t500(n int); -create table d1.t499(n int); -create table d1.t498(n int); -create table d1.t497(n int); -create table d1.t496(n int); -create table d1.t495(n int); -create table d1.t494(n int); -create table d1.t493(n int); -create table d1.t492(n int); -create table d1.t491(n int); -create table d1.t490(n int); -create table d1.t489(n int); -create table d1.t488(n int); -create table d1.t487(n int); -create table d1.t486(n int); -create table d1.t485(n int); -create table d1.t484(n int); -create table d1.t483(n int); -create table d1.t482(n int); -create table d1.t481(n int); -create table d1.t480(n int); -create table d1.t479(n int); -create table d1.t478(n int); -create table d1.t477(n int); -create table d1.t476(n int); -create table d1.t475(n int); -create table d1.t474(n int); -create table d1.t473(n int); -create table d1.t472(n int); -create table d1.t471(n int); -create table d1.t470(n int); -create table d1.t469(n int); -create table d1.t468(n int); -create table d1.t467(n int); -create table d1.t466(n int); -create table d1.t465(n int); -create table d1.t464(n int); -create table d1.t463(n int); -create table d1.t462(n int); -create table d1.t461(n int); -create table d1.t460(n int); -create table d1.t459(n int); -create table d1.t458(n int); -create table d1.t457(n int); -create table d1.t456(n int); -create table d1.t455(n int); -create table d1.t454(n int); -create table d1.t453(n int); -create table d1.t452(n int); -create table d1.t451(n int); -create table d1.t450(n int); -create table d1.t449(n int); -create table d1.t448(n int); -create table d1.t447(n int); -create table d1.t446(n int); -create table d1.t445(n int); -create table d1.t444(n int); -create table d1.t443(n int); -create table d1.t442(n int); -create table d1.t441(n int); -create table d1.t440(n int); -create table d1.t439(n int); -create table d1.t438(n int); -create table d1.t437(n int); -create table d1.t436(n int); -create table d1.t435(n int); -create table d1.t434(n int); -create table d1.t433(n int); -create table d1.t432(n int); -create table d1.t431(n int); -create table d1.t430(n int); -create table d1.t429(n int); -create table d1.t428(n int); -create table d1.t427(n int); -create table d1.t426(n int); -create table d1.t425(n int); -create table d1.t424(n int); -create table d1.t423(n int); -create table d1.t422(n int); -create table d1.t421(n int); -create table d1.t420(n int); -create table d1.t419(n int); -create table d1.t418(n int); -create table d1.t417(n int); -create table d1.t416(n int); -create table d1.t415(n int); -create table d1.t414(n int); -create table d1.t413(n int); -create table d1.t412(n int); -create table d1.t411(n int); -create table d1.t410(n int); -create table d1.t409(n int); -create table d1.t408(n int); -create table d1.t407(n int); -create table d1.t406(n int); -create table d1.t405(n int); -create table d1.t404(n int); -create table d1.t403(n int); -create table d1.t402(n int); -create table d1.t401(n int); -create table d1.t400(n int); -create table d1.t399(n int); -create table d1.t398(n int); -create table d1.t397(n int); -create table d1.t396(n int); -create table d1.t395(n int); -create table d1.t394(n int); -create table d1.t393(n int); -create table d1.t392(n int); -create table d1.t391(n int); -create table d1.t390(n int); -create table d1.t389(n int); -create table d1.t388(n int); -create table d1.t387(n int); -create table d1.t386(n int); -create table d1.t385(n int); -create table d1.t384(n int); -create table d1.t383(n int); -create table d1.t382(n int); -create table d1.t381(n int); -create table d1.t380(n int); -create table d1.t379(n int); -create table d1.t378(n int); -create table d1.t377(n int); -create table d1.t376(n int); -create table d1.t375(n int); -create table d1.t374(n int); -create table d1.t373(n int); -create table d1.t372(n int); -create table d1.t371(n int); -create table d1.t370(n int); -create table d1.t369(n int); -create table d1.t368(n int); -create table d1.t367(n int); -create table d1.t366(n int); -create table d1.t365(n int); -create table d1.t364(n int); -create table d1.t363(n int); -create table d1.t362(n int); -create table d1.t361(n int); -create table d1.t360(n int); -create table d1.t359(n int); -create table d1.t358(n int); -create table d1.t357(n int); -create table d1.t356(n int); -create table d1.t355(n int); -create table d1.t354(n int); -create table d1.t353(n int); -create table d1.t352(n int); -create table d1.t351(n int); -create table d1.t350(n int); -create table d1.t349(n int); -create table d1.t348(n int); -create table d1.t347(n int); -create table d1.t346(n int); -create table d1.t345(n int); -create table d1.t344(n int); -create table d1.t343(n int); -create table d1.t342(n int); -create table d1.t341(n int); -create table d1.t340(n int); -create table d1.t339(n int); -create table d1.t338(n int); -create table d1.t337(n int); -create table d1.t336(n int); -create table d1.t335(n int); -create table d1.t334(n int); -create table d1.t333(n int); -create table d1.t332(n int); -create table d1.t331(n int); -create table d1.t330(n int); -create table d1.t329(n int); -create table d1.t328(n int); -create table d1.t327(n int); -create table d1.t326(n int); -create table d1.t325(n int); -create table d1.t324(n int); -create table d1.t323(n int); -create table d1.t322(n int); -create table d1.t321(n int); -create table d1.t320(n int); -create table d1.t319(n int); -create table d1.t318(n int); -create table d1.t317(n int); -create table d1.t316(n int); -create table d1.t315(n int); -create table d1.t314(n int); -create table d1.t313(n int); -create table d1.t312(n int); -create table d1.t311(n int); -create table d1.t310(n int); -create table d1.t309(n int); -create table d1.t308(n int); -create table d1.t307(n int); -create table d1.t306(n int); -create table d1.t305(n int); -create table d1.t304(n int); -create table d1.t303(n int); -create table d1.t302(n int); -create table d1.t301(n int); -create table d1.t300(n int); -create table d1.t299(n int); -create table d1.t298(n int); -create table d1.t297(n int); -create table d1.t296(n int); -create table d1.t295(n int); -create table d1.t294(n int); -create table d1.t293(n int); -create table d1.t292(n int); -create table d1.t291(n int); -create table d1.t290(n int); -create table d1.t289(n int); -create table d1.t288(n int); -create table d1.t287(n int); -create table d1.t286(n int); -create table d1.t285(n int); -create table d1.t284(n int); -create table d1.t283(n int); -create table d1.t282(n int); -create table d1.t281(n int); -create table d1.t280(n int); -create table d1.t279(n int); -create table d1.t278(n int); -create table d1.t277(n int); -create table d1.t276(n int); -create table d1.t275(n int); -create table d1.t274(n int); -create table d1.t273(n int); -create table d1.t272(n int); -create table d1.t271(n int); -create table d1.t270(n int); -create table d1.t269(n int); -create table d1.t268(n int); -create table d1.t267(n int); -create table d1.t266(n int); -create table d1.t265(n int); -create table d1.t264(n int); -create table d1.t263(n int); -create table d1.t262(n int); -create table d1.t261(n int); -create table d1.t260(n int); -create table d1.t259(n int); -create table d1.t258(n int); -create table d1.t257(n int); -create table d1.t256(n int); -create table d1.t255(n int); -create table d1.t254(n int); -create table d1.t253(n int); -create table d1.t252(n int); -create table d1.t251(n int); -create table d1.t250(n int); -create table d1.t249(n int); -create table d1.t248(n int); -create table d1.t247(n int); -create table d1.t246(n int); -create table d1.t245(n int); -create table d1.t244(n int); -create table d1.t243(n int); -create table d1.t242(n int); -create table d1.t241(n int); -create table d1.t240(n int); -create table d1.t239(n int); -create table d1.t238(n int); -create table d1.t237(n int); -create table d1.t236(n int); -create table d1.t235(n int); -create table d1.t234(n int); -create table d1.t233(n int); -create table d1.t232(n int); -create table d1.t231(n int); -create table d1.t230(n int); -create table d1.t229(n int); -create table d1.t228(n int); -create table d1.t227(n int); -create table d1.t226(n int); -create table d1.t225(n int); -create table d1.t224(n int); -create table d1.t223(n int); -create table d1.t222(n int); -create table d1.t221(n int); -create table d1.t220(n int); -create table d1.t219(n int); -create table d1.t218(n int); -create table d1.t217(n int); -create table d1.t216(n int); -create table d1.t215(n int); -create table d1.t214(n int); -create table d1.t213(n int); -create table d1.t212(n int); -create table d1.t211(n int); -create table d1.t210(n int); -create table d1.t209(n int); -create table d1.t208(n int); -create table d1.t207(n int); -create table d1.t206(n int); -create table d1.t205(n int); -create table d1.t204(n int); -create table d1.t203(n int); -create table d1.t202(n int); -create table d1.t201(n int); -create table d1.t200(n int); -create table d1.t199(n int); -create table d1.t198(n int); -create table d1.t197(n int); -create table d1.t196(n int); -create table d1.t195(n int); -create table d1.t194(n int); -create table d1.t193(n int); -create table d1.t192(n int); -create table d1.t191(n int); -create table d1.t190(n int); -create table d1.t189(n int); -create table d1.t188(n int); -create table d1.t187(n int); -create table d1.t186(n int); -create table d1.t185(n int); -create table d1.t184(n int); -create table d1.t183(n int); -create table d1.t182(n int); -create table d1.t181(n int); -create table d1.t180(n int); -create table d1.t179(n int); -create table d1.t178(n int); -create table d1.t177(n int); -create table d1.t176(n int); -create table d1.t175(n int); -create table d1.t174(n int); -create table d1.t173(n int); -create table d1.t172(n int); -create table d1.t171(n int); -create table d1.t170(n int); -create table d1.t169(n int); -create table d1.t168(n int); -create table d1.t167(n int); -create table d1.t166(n int); -create table d1.t165(n int); -create table d1.t164(n int); -create table d1.t163(n int); -create table d1.t162(n int); -create table d1.t161(n int); -create table d1.t160(n int); -create table d1.t159(n int); -create table d1.t158(n int); -create table d1.t157(n int); -create table d1.t156(n int); -create table d1.t155(n int); -create table d1.t154(n int); -create table d1.t153(n int); -create table d1.t152(n int); -create table d1.t151(n int); -create table d1.t150(n int); -create table d1.t149(n int); -create table d1.t148(n int); -create table d1.t147(n int); -create table d1.t146(n int); -create table d1.t145(n int); -create table d1.t144(n int); -create table d1.t143(n int); -create table d1.t142(n int); -create table d1.t141(n int); -create table d1.t140(n int); -create table d1.t139(n int); -create table d1.t138(n int); -create table d1.t137(n int); -create table d1.t136(n int); -create table d1.t135(n int); -create table d1.t134(n int); -create table d1.t133(n int); -create table d1.t132(n int); -create table d1.t131(n int); -create table d1.t130(n int); -create table d1.t129(n int); -create table d1.t128(n int); -create table d1.t127(n int); -create table d1.t126(n int); -create table d1.t125(n int); -create table d1.t124(n int); -create table d1.t123(n int); -create table d1.t122(n int); -create table d1.t121(n int); -create table d1.t120(n int); -create table d1.t119(n int); -create table d1.t118(n int); -create table d1.t117(n int); -create table d1.t116(n int); -create table d1.t115(n int); -create table d1.t114(n int); -create table d1.t113(n int); -create table d1.t112(n int); -create table d1.t111(n int); -create table d1.t110(n int); -create table d1.t109(n int); -create table d1.t108(n int); -create table d1.t107(n int); -create table d1.t106(n int); -create table d1.t105(n int); -create table d1.t104(n int); -create table d1.t103(n int); -create table d1.t102(n int); -create table d1.t101(n int); -create table d1.t100(n int); -create table d1.t99(n int); -create table d1.t98(n int); -create table d1.t97(n int); -create table d1.t96(n int); -create table d1.t95(n int); -create table d1.t94(n int); -create table d1.t93(n int); -create table d1.t92(n int); -create table d1.t91(n int); -create table d1.t90(n int); -create table d1.t89(n int); -create table d1.t88(n int); -create table d1.t87(n int); -create table d1.t86(n int); -create table d1.t85(n int); -create table d1.t84(n int); -create table d1.t83(n int); -create table d1.t82(n int); -create table d1.t81(n int); -create table d1.t80(n int); -create table d1.t79(n int); -create table d1.t78(n int); -create table d1.t77(n int); -create table d1.t76(n int); -create table d1.t75(n int); -create table d1.t74(n int); -create table d1.t73(n int); -create table d1.t72(n int); -create table d1.t71(n int); -create table d1.t70(n int); -create table d1.t69(n int); -create table d1.t68(n int); -create table d1.t67(n int); -create table d1.t66(n int); -create table d1.t65(n int); -create table d1.t64(n int); -create table d1.t63(n int); -create table d1.t62(n int); -create table d1.t61(n int); -create table d1.t60(n int); -create table d1.t59(n int); -create table d1.t58(n int); -create table d1.t57(n int); -create table d1.t56(n int); -create table d1.t55(n int); -create table d1.t54(n int); -create table d1.t53(n int); -create table d1.t52(n int); -create table d1.t51(n int); -create table d1.t50(n int); -create table d1.t49(n int); -create table d1.t48(n int); -create table d1.t47(n int); -create table d1.t46(n int); -create table d1.t45(n int); -create table d1.t44(n int); -create table d1.t43(n int); -create table d1.t42(n int); -create table d1.t41(n int); -create table d1.t40(n int); -create table d1.t39(n int); -create table d1.t38(n int); -create table d1.t37(n int); -create table d1.t36(n int); -create table d1.t35(n int); -create table d1.t34(n int); -create table d1.t33(n int); -create table d1.t32(n int); -create table d1.t31(n int); -create table d1.t30(n int); -create table d1.t29(n int); -create table d1.t28(n int); -create table d1.t27(n int); -create table d1.t26(n int); -create table d1.t25(n int); -create table d1.t24(n int); -create table d1.t23(n int); -create table d1.t22(n int); -create table d1.t21(n int); -create table d1.t20(n int); -create table d1.t19(n int); -create table d1.t18(n int); -create table d1.t17(n int); -create table d1.t16(n int); -create table d1.t15(n int); -create table d1.t14(n int); -create table d1.t13(n int); -create table d1.t12(n int); -create table d1.t11(n int); -create table d1.t10(n int); -create table d1.t9(n int); -create table d1.t8(n int); -create table d1.t7(n int); -create table d1.t6(n int); -create table d1.t5(n int); -create table d1.t4(n int); -create table d1.t3(n int); -create table d1.t2(n int); -create table d1.t1(n int); -drop database d1; -ERROR HY000: Error dropping database (can't rmdir './d1/', errno: 17) -use d1; +Tables_in_mysqltest +drop database mysqltest; +ERROR HY000: Error dropping database (can't rmdir './mysqltest/', errno: 17) +use mysqltest; show tables; -Tables_in_d1 +Tables_in_mysqltest use test; create table t1 (n int); insert into t1 values (1234); -use d1; +use mysqltest; show tables; -Tables_in_d1 +Tables_in_mysqltest use test; select * from t1; n diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test index 8f471ebb979..8e6c53af095 100644 --- a/mysql-test/t/ctype_cp932.test +++ b/mysql-test/t/ctype_cp932.test @@ -419,7 +419,7 @@ SET @var1= x'8300'; # exercise this code from mysql-test-run. EXECUTE stmt1 USING @var1; --replace_column 2 # 5 # -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 79; SELECT HEX(f1) FROM t1; DROP table t1; # end test for bug#11338 diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test index 71dc22f705f..7b4a56910d6 100644 --- a/mysql-test/t/rpl_drop_db.test +++ b/mysql-test/t/rpl_drop_db.test @@ -5,30 +5,32 @@ connection master; --disable_warnings -drop database if exists d1; +drop database if exists mysqltest; --enable_warnings -create database d1; -create table d1.t1 (n int); -insert into d1.t1 values (1); -select * from d1.t1 into outfile 'd1/f1.txt'; -create table d1.t2 (n int); -create table d1.t3 (n int); +create database mysqltest; +create table mysqltest.t1 (n int); +insert into mysqltest.t1 values (1); +select * from mysqltest.t1 into outfile 'mysqltest/f1.txt'; +create table mysqltest.t2 (n int); +create table mysqltest.t3 (n int); --error 1010 -drop database d1; -use d1; +drop database mysqltest; +use mysqltest; show tables; # test the branch of the code that deals with the query buffer overflow -let $1=1000; +disable_query_log; +let $1=50; while ($1) { - eval create table d1.t$1(n int); + eval create table mysqltest.mysql_test_long_table_name$1 (n int); dec $1; } +enable_query_log; --error 1010 -drop database d1; -use d1; +drop database mysqltest; +use mysqltest; show tables; use test; create table t1 (n int); @@ -36,7 +38,7 @@ insert into t1 values (1234); sync_slave_with_master; connection slave; -use d1; +use mysqltest; show tables; use test; select * from t1; @@ -48,5 +50,7 @@ sync_slave_with_master; #cleanup connection slave; stop slave; -system rm -rf var/master-data/d1; +system rm -rf var/master-data/mysqltest; + +# End of 4.1 tests diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 6dcc7be0904..a279fae93a9 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -33,12 +33,8 @@ static TYPELIB deletable_extentions= static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, const char *path, uint level, - TABLE_LIST** dropped_tables); + TABLE_LIST **dropped_tables); - -static inline void write_to_binlog(THD* thd, char* query, uint q_len, - char* db, uint db_len); - /* Database options hash */ static HASH dboptions; static my_bool dboptions_init= 0; @@ -56,6 +52,7 @@ typedef struct my_dbopt_st /* Function we use in the creation of our hash to get key. */ + static byte* dboptions_get_key(my_dbopt_t *opt, uint *length, my_bool not_used __attribute__((unused))) { @@ -63,17 +60,19 @@ static byte* dboptions_get_key(my_dbopt_t *opt, uint *length, return (byte*) opt->name; } + /* - Helper function to write a query to binlog used by mysql_rm_db() - */ -static inline void write_to_binlog(THD* thd, char* query, uint q_len, - char* db, uint db_len) + Helper function to write a query to binlog used by mysql_rm_db() +*/ + +static inline void write_to_binlog(THD *thd, char *query, uint q_len, + char *db, uint db_len) { - Query_log_event qinfo(thd, query, q_len, 0, 0); - qinfo.error_code= 0; - qinfo.db= db; - qinfo.db_len= db_len; - mysql_bin_log.write(&qinfo); + Query_log_event qinfo(thd, query, q_len, 0, 0); + qinfo.error_code= 0; + qinfo.db= db; + qinfo.db_len= db_len; + mysql_bin_log.write(&qinfo); } @@ -644,7 +643,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) error= -1; if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0, - &dropped_tables)) >= 0) + &dropped_tables)) >= 0) { ha_drop_database(path); query_cache_invalidate1(db); @@ -696,42 +695,40 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) } else if (mysql_bin_log.is_open()) { - char* query= thd->alloc(MAX_DROP_TABLE_Q_LEN); + char *query, *query_pos, *query_end, *query_data_start; + TABLE_LIST *tbl; + uint db_len; + + if (!(query= thd->alloc(MAX_DROP_TABLE_Q_LEN))) + goto exit; /* not much else we can do */ + query_pos= query_data_start= strmov(query,"drop table "); + query_end= query + MAX_DROP_TABLE_Q_LEN; + db_len= strlen(db); - if (!query) - goto exit; /* not much else we can do */ - char* p= strmov(query,"drop table "); - char* p_end= query + MAX_DROP_TABLE_Q_LEN; - TABLE_LIST* tbl; - bool last_query_needs_write= 0; - uint db_len= strlen(db); - - for (tbl= dropped_tables;tbl;tbl= tbl->next) - { - if (!tbl->was_dropped) - continue; + for (tbl= dropped_tables; tbl; tbl= tbl->next) + { + uint tbl_name_len; + if (!tbl->was_dropped) + continue; - /* 3 for the quotes and the comma*/ - uint tbl_name_len= strlen(tbl->real_name) + 3; - if (p + tbl_name_len + 1 >= p_end) - { - *--p= 0; /* kill , */ - write_to_binlog(thd, query, p - query, db, db_len); - p= query + 11; /* reuse the initial "drop table" */ - } + /* 3 for the quotes and the comma*/ + tbl_name_len= strlen(tbl->real_name) + 3; + if (query_pos + tbl_name_len + 1 >= query_end) + { + write_to_binlog(thd, query, query_pos -1 - query, db, db_len); + query_pos= query_data_start; + } - *p++ = '`'; - p= strmov(p,tbl->real_name); - *p++ = '`'; - *p++ = ','; - last_query_needs_write= 1; - } + *query_pos++ = '`'; + query_pos= strmov(query_pos,tbl->real_name); + *query_pos++ = '`'; + *query_pos++ = ','; + } - if (last_query_needs_write) - { - *--p= 0; - write_to_binlog(thd, query, p - query, db, db_len); - } + if (query_pos != query_data_start) + { + write_to_binlog(thd, query, query_pos -1 - query, db, db_len); + } } exit: @@ -777,7 +774,8 @@ exit2: */ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, - const char *org_path, uint level, TABLE_LIST** dropped_tables) + const char *org_path, uint level, + TABLE_LIST **dropped_tables) { long deleted=0; ulong found_other_files=0; From f16c7b3c5c1493cf4fd572cc630f211e1a410be3 Mon Sep 17 00:00:00 2001 From: "monty@mishka.local" <> Date: Thu, 25 Aug 2005 09:38:06 +0300 Subject: [PATCH 20/20] After merge fixes --- mysql-test/r/subselect2.result | 2 +- sql/handler.cc | 2 +- sql/sql_acl.cc | 17 ++++++++++------- sql/sql_db.cc | 6 +++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/subselect2.result b/mysql-test/r/subselect2.result index 4488af8206c..bc902ea7b0f 100644 --- a/mysql-test/r/subselect2.result +++ b/mysql-test/r/subselect2.result @@ -121,8 +121,8 @@ c373e9f5ad07993f3859444553544200 Last Discussion c373e9f5ad079174ff1744455354420 EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion'; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL DDOCTYPEID_IDX NULL NULL NULL 9 Using where +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 34 test.t2.DOCID 1 1 PRIMARY t4 eq_ref PRIMARY PRIMARY 34 test.t2.DOCTYPEID 1 -1 PRIMARY t1 eq_ref PRIMARY PRIMARY 32 test.t2.DOCID 1 2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 34 func 1 Using index; Using where 3 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 34 func 1 Using index; Using where 4 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 34 func 1 Using index; Using where diff --git a/sql/handler.cc b/sql/handler.cc index 0b247f83af1..cf1fbfec465 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1023,7 +1023,7 @@ bool mysql_xa_recover(THD *thd) DBUG_RETURN(1); pthread_mutex_lock(&LOCK_xid_cache); - while (xs=(XID_STATE*)hash_element(&xid_cache, i++)) + while ((xs= (XID_STATE*)hash_element(&xid_cache, i++))) { if (xs->xa_state==XA_PREPARED) { diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 13d84129d8e..4629752c6a7 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2494,7 +2494,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, The following should always succeed as new users are created before this function is called! */ - if (!find_acl_user(combo.host.str,combo.user.str)) + if (!find_acl_user(combo.host.str, combo.user.str, FALSE)) { my_error(ER_PASSWORD_NO_MATCH,MYF(0)); DBUG_RETURN(-1); @@ -4611,11 +4611,12 @@ static int handle_grant_struct(uint struct_no, bool drop, ACL_DB *acl_db; GRANT_NAME *grant_name; DBUG_ENTER("handle_grant_struct"); + DBUG_PRINT("info",("scan struct: %u search: '%s'@'%s'", + struct_no, user_from->user.str, user_from->host.str)); + LINT_INIT(acl_user); LINT_INIT(acl_db); LINT_INIT(grant_name); - DBUG_PRINT("info",("scan struct: %u search: '%s'@'%s'", - struct_no, user_from->user.str, user_from->host.str)); /* Get the number of elements in the in-memory structure. */ switch (struct_no) { @@ -5311,10 +5312,12 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, combo->user.str= thd->user; - if (!find_acl_user(combo->host.str=(char*)thd->host_or_ip, combo->user.str) && - !find_acl_user(combo->host.str=(char*)thd->host, combo->user.str) && - !find_acl_user(combo->host.str=(char*)thd->ip, combo->user.str) && - !find_acl_user(combo->host.str=(char*)"%", combo->user.str)) + if (!find_acl_user(combo->host.str=(char*)thd->host_or_ip, combo->user.str, + FALSE) && + !find_acl_user(combo->host.str=(char*)thd->host, combo->user.str, + FALSE) && + !find_acl_user(combo->host.str=(char*)thd->ip, combo->user.str, FALSE) && + !find_acl_user(combo->host.str=(char*)"%", combo->user.str, FALSE)) DBUG_RETURN(TRUE); bzero((char*)tables, sizeof(TABLE_LIST)); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 27f20753475..5ca3f07f0bd 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -706,14 +706,14 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) query_end= query + MAX_DROP_TABLE_Q_LEN; db_len= strlen(db); - for (tbl= dropped_tables; tbl; tbl= tbl->next) + for (tbl= dropped_tables; tbl; tbl= tbl->next_local) { uint tbl_name_len; if (!tbl->was_dropped) continue; /* 3 for the quotes and the comma*/ - tbl_name_len= strlen(tbl->real_name) + 3; + tbl_name_len= strlen(tbl->table_name) + 3; if (query_pos + tbl_name_len + 1 >= query_end) { write_to_binlog(thd, query, query_pos -1 - query, db, db_len); @@ -721,7 +721,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) } *query_pos++ = '`'; - query_pos= strmov(query_pos,tbl->real_name); + query_pos= strmov(query_pos,tbl->table_name); *query_pos++ = '`'; *query_pos++ = ','; }