List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:June 20 2006 4:04pm
Subject:bk commit into 5.1 tree (anozdrin:1.2229)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of alik. When alik does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2229 06/06/20 18:04:06 anozdrin@stripped +19 -0
  Merge mysql.com:/home/alik/MySQL/devel/5.0-to-be-merged
  into  mysql.com:/home/alik/MySQL/devel/5.1-merged

  sql/sql_insert.cc
    1.205 06/06/20 18:04:03 anozdrin@stripped +0 -0
    Manually merged.

  server-tools/instance-manager/manager.cc
    1.35 06/06/20 18:04:03 anozdrin@stripped +0 -0
    Manually merged.

  server-tools/instance-manager/guardian.cc
    1.24 06/06/20 18:04:03 anozdrin@stripped +0 -0
    Manually merged.

  mysql-test/t/insert.test
    1.25 06/06/20 18:04:03 anozdrin@stripped +10 -0
    Manually merged.

  mysql-test/t/im_utils.imtest
    1.3 06/06/20 18:04:03 anozdrin@stripped +0 -6
    Manually merged.

  mysql-test/t/im_life_cycle.imtest
    1.7 06/06/20 18:04:02 anozdrin@stripped +0 -63
    Manually merged.

  mysql-test/t/im_daemon_life_cycle.imtest
    1.3 06/06/20 18:04:02 anozdrin@stripped +0 -3
    Manually merged.

  mysql-test/r/insert.result
    1.27 06/06/20 18:04:02 anozdrin@stripped +6 -0
    Manually merged.

  mysql-test/r/im_life_cycle.result
    1.9 06/06/20 18:04:02 anozdrin@stripped +0 -35
    Manually merged.

  server-tools/instance-manager/instance_map.cc
    1.29 06/06/20 17:50:09 anozdrin@stripped +0 -0
    Auto merged

  mysql-test/t/trigger.test
    1.48 06/06/20 17:50:09 anozdrin@stripped +0 -0
    Auto merged

  mysql-test/t/im_daemon_life_cycle-im.opt
    1.4 06/06/20 17:50:09 anozdrin@stripped +0 -1
    Auto merged

  mysql-test/r/trigger.result
    1.44 06/06/20 17:50:09 anozdrin@stripped +0 -0
    Auto merged

  mysql-test/r/im_utils.result
    1.7 06/06/20 17:50:09 anozdrin@stripped +0 -0
    Auto merged

  mysql-test/r/im_daemon_life_cycle.result
    1.4 06/06/20 17:50:09 anozdrin@stripped +0 -0
    Auto merged

  mysql-test/mysql-test-run.pl
    1.127 06/06/20 17:50:09 anozdrin@stripped +0 -0
    Auto merged

  mysql-test/lib/mtr_process.pl
    1.34 06/06/20 17:50:09 anozdrin@stripped +0 -0
    Auto merged

  BitKeeper/deleted/.del-im_utils-im.opt
    1.2 06/06/20 17:50:08 anozdrin@stripped +0 -0
    Delete: mysql-test/t/im_utils-im.opt

  BitKeeper/deleted/.del-im_life_cycle-im.opt
    1.2 06/06/20 17:50:01 anozdrin@stripped +0 -0
    Delete: mysql-test/t/im_life_cycle-im.opt

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	anozdrin
# Host:	booka.site
# Root:	/home/alik/MySQL/devel/5.1-merged/RESYNC

--- 1.204/sql/sql_insert.cc	2006-06-18 14:20:28 +04:00
+++ 1.205/sql/sql_insert.cc	2006-06-20 18:04:03 +04:00
@@ -1083,16 +1083,19 @@ int write_record(THD *thd, TABLE *table,
 	  to convert the latter operation internally to an UPDATE.
           We also should not perform this conversion if we have 
           timestamp field with ON UPDATE which is different from DEFAULT.
+          Another case when conversion should not be performed is when
+          we have ON DELETE trigger on table so user may notice that
+          we cheat here. Note that it is ok to do such conversion for
+          tables which have ON UPDATE but have no ON DELETE triggers,
+          we just should not expose this fact to users by invoking
+          ON UPDATE triggers.
 	*/
 	if (last_uniq_key(table,key_nr) &&
 	    !table->file->referenced_by_foreign_key() &&
             (table->timestamp_field_type == TIMESTAMP_NO_AUTO_SET ||
-             table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH))
+             table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH) &&
+            (!table->triggers || !table->triggers->has_delete_triggers()))
         {
-          if (table->triggers &&
-              table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
-                                                TRG_ACTION_BEFORE, TRUE))
-            goto before_trg_err;
           if (thd->clear_next_insert_id)
           {
             /* Reset auto-increment cacheing if we do an update */
@@ -1103,13 +1106,11 @@ int write_record(THD *thd, TABLE *table,
 					        table->record[0])))
             goto err;
           info->deleted++;
-          trg_error= (table->triggers &&
-                      table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
-                                                        TRG_ACTION_AFTER,
-                                                        TRUE));
-          /* Update logfile and count */
-          info->copied++;
-          goto ok_or_after_trg_err;
+          /*
+            Since we pretend that we have done insert we should call
+            its after triggers.
+          */
+          goto after_trg_n_copied_inc;
         }
         else
         {
@@ -1133,10 +1134,6 @@ int write_record(THD *thd, TABLE *table,
         }
       }
     }
-    info->copied++;
-    trg_error= (table->triggers &&
-                table->triggers->process_triggers(thd, TRG_EVENT_INSERT,
-                                                  TRG_ACTION_AFTER, TRUE));
     /*
       Restore column maps if they where replaced during an duplicate key
       problem.
@@ -1151,14 +1148,14 @@ int write_record(THD *thd, TABLE *table,
 	(error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE))
       goto err;
     table->file->restore_auto_increment();
+    goto ok_or_after_trg_err;
   }
-  else
-  {
-    info->copied++;
-    trg_error= (table->triggers &&
-                table->triggers->process_triggers(thd, TRG_EVENT_INSERT,
-                                                  TRG_ACTION_AFTER, TRUE));
-  }
+
+after_trg_n_copied_inc:
+  info->copied++;
+  trg_error= (table->triggers &&
+              table->triggers->process_triggers(thd, TRG_EVENT_INSERT,
+                                                TRG_ACTION_AFTER, TRUE));
 
 ok_or_after_trg_err:
   if (key)

--- 1.3/mysql-test/r/im_daemon_life_cycle.result	2006-05-22 14:04:59 +04:00
+++ 1.4/mysql-test/r/im_daemon_life_cycle.result	2006-06-20 17:50:09 +04:00
@@ -1,3 +1,4 @@
+Success: the process has been started.
 SHOW INSTANCES;
 instance_name	state
 mysqld1	online

--- 1.8/mysql-test/r/im_life_cycle.result	2006-05-22 14:05:09 +04:00
+++ 1.9/mysql-test/r/im_life_cycle.result	2006-06-20 18:04:02 +04:00
@@ -2,6 +2,7 @@
 --------------------------------------------------------------------
 -- 1.1.1.
 --------------------------------------------------------------------
+Success: the process has been started.
 SHOW INSTANCES;
 instance_name	state
 mysqld1	online
@@ -11,10 +12,7 @@ mysqld2	offline
 -- 1.1.2.
 --------------------------------------------------------------------
 START INSTANCE mysqld2;
-SHOW INSTANCES;
-instance_name	state
-mysqld1	online
-mysqld2	online
+Success: the process has been started.
 SHOW VARIABLES LIKE 'port';
 Variable_name	Value
 port	IM_MYSQLD2_PORT
@@ -23,16 +21,7 @@ port	IM_MYSQLD2_PORT
 -- 1.1.3.
 --------------------------------------------------------------------
 STOP INSTANCE mysqld2;
-SHOW INSTANCES;
-instance_name	state
-mysqld1	online
-mysqld2	offline
-SHOW INSTANCE STATUS mysqld1;
-instance_name	state	version_number	version	mysqld_compatible
-mysqld1	online	VERSION_NUMBER	VERSION	no
-SHOW INSTANCE STATUS mysqld2;
-instance_name	state	version_number	version	mysqld_compatible
-mysqld2	offline	VERSION_NUMBER	VERSION	no
+Success: the process has been stopped.
 
 --------------------------------------------------------------------
 -- 1.1.4.
@@ -66,18 +55,15 @@ SHOW INSTANCES;
 instance_name	state
 mysqld1	online
 mysqld2	offline
+
+--------------------------------------------------------------------
+-- 1.1.7.
+--------------------------------------------------------------------
 START INSTANCE mysqld2;
-SHOW INSTANCES;
-instance_name	state
-mysqld1	online
-mysqld2	online
+Success: the process has been started.
 Killing the process...
 Sleeping...
 Success: the process was killed.
-SHOW INSTANCES;
-instance_name	state
-mysqld1	online
-mysqld2	offline
 
 --------------------------------------------------------------------
 -- 1.1.8.

--- 1.6/mysql-test/r/im_utils.result	2006-05-22 14:05:11 +04:00
+++ 1.7/mysql-test/r/im_utils.result	2006-06-20 17:50:09 +04:00
@@ -1,3 +1,4 @@
+Success: the process has been started.
 SHOW INSTANCES;
 instance_name	state
 mysqld1	online
@@ -42,7 +43,9 @@ skip-ndbcluster	VALUE
 nonguarded	VALUE
 log-output	VALUE
 START INSTANCE mysqld2;
+Success: the process has been started.
 STOP INSTANCE mysqld2;
+Success: the process has been stopped.
 SHOW mysqld1 LOG FILES;
 Logfile	Path	File size
 ERROR LOG	PATH	FILE_SIZE

--- 1.2/mysql-test/t/im_daemon_life_cycle.imtest	2006-05-18 18:57:43 +04:00
+++ 1.3/mysql-test/t/im_daemon_life_cycle.imtest	2006-06-20 18:04:02 +04:00
@@ -10,9 +10,22 @@
 
 ###########################################################################
 
+# Wait for mysqld1 (guarded instance) to start.
+
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
+
+# Let IM detect that mysqld1 is online. This delay should be longer than
+# monitoring interval.
+
 --sleep 3
-# should be longer than monitoring interval and enough to start instance.
+
+# Check that start conditions are as expected.
 
 SHOW INSTANCES;
 
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted
+###########################################################################
+
+# Kill the IM main process and check that the IM Angel will restart the main
+# process.
+
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30

--- 1.6/mysql-test/t/im_life_cycle.imtest	2006-05-18 18:57:43 +04:00
+++ 1.7/mysql-test/t/im_life_cycle.imtest	2006-06-20 18:04:02 +04:00
@@ -22,8 +22,16 @@
 --echo -- 1.1.1.
 --echo --------------------------------------------------------------------
 
+# Wait for mysqld1 (guarded instance) to start.
+
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
+
+# Let IM detect that mysqld1 is online. This delay should be longer than
+# monitoring interval.
+
 --sleep 3
-# should be longer than monitoring interval and enough to start instance.
+
+# Check that start conditions are as expected.
 
 SHOW INSTANCES;
 
@@ -44,10 +52,12 @@ SHOW INSTANCES;
 
 START INSTANCE mysqld2;
 # FIXME: START INSTANCE should be synchronous.
---sleep 3
-# should be longer than monitoring interval and enough to start instance.
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
 
-SHOW INSTANCES;
+# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
+# synchronous. Even waiting for mysqld to start by looking at its pid file is
+# not enough, because IM may not detect that mysqld has started.
+# SHOW INSTANCES;
 
 --connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD2_PORT,$IM_MYSQLD2_SOCK)
 --connection mysql_con
@@ -74,14 +84,12 @@ SHOW VARIABLES LIKE 'port';
 
 STOP INSTANCE mysqld2;
 # FIXME: STOP INSTANCE should be synchronous.
---sleep 3
-# should be longer than monitoring interval and enough to stop instance.
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
 
-SHOW INSTANCES;
---replace_column 3 VERSION_NUMBER 4 VERSION
-SHOW INSTANCE STATUS mysqld1;
---replace_column 3 VERSION_NUMBER 4 VERSION
-SHOW INSTANCE STATUS mysqld2;
+# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
+# synchronous. Even waiting for mysqld to start by looking at its pid file is
+# not enough, because IM may not detect that mysqld has started.
+# SHOW INSTANCES;
 
 ###########################################################################
 #
@@ -140,10 +148,14 @@ STOP INSTANCE mysqld3;
 
 SHOW INSTANCES;
 
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30
+
+# Give some time to IM to detect that mysqld was restarted. It should be longer
+# than monitoring interval.
 
 --sleep 3
-# should be longer than monitoring interval and enough to start instance.
+
+SHOW INSTANCES;
 
 ###########################################################################
 #
@@ -156,18 +168,21 @@ SHOW INSTANCES;
 --echo -- 1.1.7.
 --echo --------------------------------------------------------------------
 
-SHOW INSTANCES;
-
 START INSTANCE mysqld2;
 # FIXME: START INSTANCE should be synchronous.
---sleep 3
-# should be longer than monitoring interval and enough to start instance.
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
 
-SHOW INSTANCES;
-
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed
-
-SHOW INSTANCES;
+# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
+# synchronous. Even waiting for mysqld to start by looking at its pid file is
+# not enough, because IM may not detect that mysqld has started.
+# SHOW INSTANCES;
+
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10
+
+# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
+# synchronous. Even waiting for mysqld to start by looking at its pid file is
+# not enough, because IM may not detect that mysqld has started.
+# SHOW INSTANCES;
 
 ###########################################################################
 #

--- 1.2/mysql-test/t/im_utils.imtest	2006-05-18 18:57:43 +04:00
+++ 1.3/mysql-test/t/im_utils.imtest	2006-06-20 18:04:03 +04:00
@@ -17,8 +17,16 @@
 #  - the second instance is offline;
 #
 
+# Wait for mysqld1 (guarded instance) to start.
+
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
+
+# Let IM detect that mysqld1 is online. This delay should be longer than
+# monitoring interval.
+
 --sleep 3
-# should be longer than monitoring interval and enough to start instance.
+
+# Check that start conditions are as expected.
 
 SHOW INSTANCES;
 
@@ -43,12 +51,10 @@ SHOW INSTANCE OPTIONS mysqld2;
 #
 
 START INSTANCE mysqld2;
-
-# FIXME: START INSTANCE should be synchronous.
---sleep 3
-# should be longer than monitoring interval and enough to start instance.
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
 
 STOP INSTANCE mysqld2;
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
 
 #
 # Check 'SHOW LOG FILES' command:

--- 1.43/mysql-test/r/trigger.result	2006-05-18 12:53:09 +04:00
+++ 1.44/mysql-test/r/trigger.result	2006-06-20 17:50:09 +04:00
@@ -169,21 +169,22 @@ select @log;
 @log
 (BEFORE_INSERT: new=(id=1, data=2))
 set @log:= "";
-replace t1 values (1, 3), (2, 2);
+insert into t1 (id, data) values (1, 3), (2, 2) on duplicate key update data= data + 1;
 select @log;
 @log
-(BEFORE_INSERT: new=(id=1, data=3))(BEFORE_UPDATE: old=(id=1, data=1) new=(id=1,
data=3))(AFTER_UPDATE: old=(id=1, data=1) new=(id=1, data=3))(BEFORE_INSERT: new=(id=2,
data=2))(AFTER_INSERT: new=(id=2, data=2))
-alter table t1 add ts timestamp default now();
+(BEFORE_INSERT: new=(id=1, data=3))(BEFORE_UPDATE: old=(id=1, data=1) new=(id=1,
data=2))(AFTER_UPDATE: old=(id=1, data=1) new=(id=1, data=2))(BEFORE_INSERT: new=(id=2,
data=2))(AFTER_INSERT: new=(id=2, data=2))
 set @log:= "";
-replace t1 (id, data) values (1, 4);
+replace t1 values (1, 4), (3, 3);
 select @log;
 @log
-(BEFORE_INSERT: new=(id=1, data=4))(BEFORE_DELETE: old=(id=1, data=3))(AFTER_DELETE:
old=(id=1, data=3))(AFTER_INSERT: new=(id=1, data=4))
+(BEFORE_INSERT: new=(id=1, data=4))(BEFORE_DELETE: old=(id=1, data=2))(AFTER_DELETE:
old=(id=1, data=2))(AFTER_INSERT: new=(id=1, data=4))(BEFORE_INSERT: new=(id=3,
data=3))(AFTER_INSERT: new=(id=3, data=3))
+drop trigger t1_bd;
+drop trigger t1_ad;
 set @log:= "";
-insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2;
+replace t1 values (1, 5);
 select @log;
 @log
-(BEFORE_INSERT: new=(id=1, data=5))(BEFORE_UPDATE: old=(id=1, data=4) new=(id=1,
data=6))(AFTER_UPDATE: old=(id=1, data=4) new=(id=1, data=6))(BEFORE_INSERT: new=(id=3,
data=3))(AFTER_INSERT: new=(id=3, data=3))
+(BEFORE_INSERT: new=(id=1, data=5))(AFTER_INSERT: new=(id=1, data=5))
 drop table t1;
 create table t1 (id int primary key, data varchar(10), fk int);
 create table t2 (event varchar(100));
@@ -493,15 +494,9 @@ select * from t1;
 i	k
 3	13
 replace into t1 values (3, 3);
-ERROR 42S22: Unknown column 'at' in 'NEW'
-select * from t1;
-i	k
-3	3
-alter table t1 add ts timestamp default now();
-replace into t1 (i, k) values (3, 13);
 ERROR 42S22: Unknown column 'at' in 'OLD'
 select * from t1;
-i	k	ts
+i	k
 drop table t1, t2;
 create table t1 (i int, bt int, k int, key(k)) engine=myisam;
 create table t2 (i int);
@@ -574,18 +569,11 @@ i	k
 1	1
 2	2
 replace into t1 values (2, 4);
-ERROR 42S22: Unknown column 'bt' in 'NEW'
+ERROR 42S22: Unknown column 'bt' in 'OLD'
 select * from t1;
 i	k
 1	1
 2	2
-alter table t1 add ts timestamp default now();
-replace into t1 (i, k) values (2, 11);
-ERROR 42S22: Unknown column 'bt' in 'OLD'
-select * from t1;
-i	k	ts
-1	1	0000-00-00 00:00:00
-2	2	0000-00-00 00:00:00
 drop table t1, t2;
 drop function if exists bug5893;
 create table t1 (col1 int, col2 int);

--- 1.47/mysql-test/t/trigger.test	2006-05-18 12:53:09 +04:00
+++ 1.48/mysql-test/t/trigger.test	2006-06-20 17:50:09 +04:00
@@ -185,24 +185,26 @@ select @log;
 set @log:= "";
 insert ignore t1 values (1, 2);
 select @log;
-# REPLACE: before insert trigger should be called for both records,
-#          but then for first one update will be executed (and both update
-#          triggers should fire). For second after insert trigger will be
-#          called as for usual insert
+# INSERT ... ON DUPLICATE KEY UPDATE ...
 set @log:= "";
-replace t1 values (1, 3), (2, 2);
+insert into t1 (id, data) values (1, 3), (2, 2) on duplicate key update data= data + 1;
 select @log;
-# Now let us change table in such way that REPLACE on won't be executed
-# using update.
-alter table t1 add ts timestamp default now();
+# REPLACE (also test for bug#13479 "REPLACE activates UPDATE trigger,
+#          not the DELETE and INSERT triggers")
+# We define REPLACE as INSERT which DELETEs old rows which conflict with
+# row being inserted. So for the first record in statement below we will
+# call before insert trigger, then delete will be executed (and both delete
+# triggers should fire). Finally after insert trigger will be called.
+# For the second record we will just call both on insert triggers.
 set @log:= "";
-# This REPLACE should be executed via DELETE and INSERT so proper 
-# triggers should be invoked.
-replace t1 (id, data) values (1, 4);
+replace t1 values (1, 4), (3, 3);
 select @log;
-# Finally let us test INSERT ... ON DUPLICATE KEY UPDATE ...
+# Now we will drop ON DELETE triggers to test REPLACE which is internally
+# executed via update
+drop trigger t1_bd;
+drop trigger t1_ad;
 set @log:= "";
-insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2; 
+replace t1 values (1, 5);
 select @log;
 
 # This also drops associated triggers
@@ -531,14 +533,11 @@ alter table t1 add primary key (i);
 --error 1054
 insert into t1 values (3, 4) on duplicate key update k= k + 10;
 select * from t1;
+# The following statement will delete old row and won't
+# insert new one since after delete trigger will fail.
 --error 1054
 replace into t1 values (3, 3);
 select * from t1;
-# Change table in such way that REPLACE will delete row
-alter table t1 add ts timestamp default now();
---error 1054
-replace into t1 (i, k) values (3, 13);
-select * from t1;
 # Also drops all triggers
 drop table t1, t2;
 
@@ -593,11 +592,6 @@ insert into t1 values (2, 4) on duplicat
 select * from t1;
 --error 1054
 replace into t1 values (2, 4);
-select * from t1;
-# Change table in such way that REPLACE will delete row
-alter table t1 add ts timestamp default now();
---error 1054
-replace into t1 (i, k) values (2, 11);
 select * from t1;
 # Also drops all triggers
 drop table t1, t2;

--- 1.33/mysql-test/lib/mtr_process.pl	2006-05-18 12:53:09 +04:00
+++ 1.34/mysql-test/lib/mtr_process.pl	2006-06-20 17:50:09 +04:00
@@ -880,19 +880,28 @@ sub mtr_kill_processes ($) {
 sub mtr_kill_process ($$$$) {
   my $pid= shift;
   my $signal= shift;
-  my $retries= shift;
+  my $total_retries= shift;
   my $timeout= shift;
 
-  while (1)
+  for (my $cur_attempt= 1; $cur_attempt <= $total_retries; ++$cur_attempt)
   {
+    mtr_debug("Sending $signal to $pid...");
+
     kill($signal, $pid);
 
-    last unless kill (0, $pid) and $retries--;
+    unless (kill (0, $pid))
+    {
+      mtr_debug("Process $pid died.");
+      return;
+    }
 
-    mtr_debug("Sleep $timeout second waiting for processes to die");
+    mtr_debug("Sleeping $timeout second(s) waiting for processes to die...");
 
     sleep($timeout);
   }
+
+  mtr_debug("Process $pid is still alive after $total_retries " .
+            "of sending signal $signal.");
 }
 
 ##############################################################################

--- 1.126/mysql-test/mysql-test-run.pl	2006-06-20 15:38:56 +04:00
+++ 1.127/mysql-test/mysql-test-run.pl	2006-06-20 17:50:09 +04:00
@@ -3120,22 +3120,58 @@ sub im_stop($) {
 
   # Try graceful shutdown.
 
+  mtr_debug("IM-main pid: $instance_manager->{'pid'}");
+  mtr_debug("Stopping IM-main...");
+
   mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10, 1);
 
+  # If necessary, wait for angel process to die.
+
+  if (defined $instance_manager->{'angel_pid'})
+  {
+    mtr_debug("IM-angel pid: $instance_manager->{'angel_pid'}");
+    mtr_debug("Waiting for IM-angel to die...");
+
+    my $total_attempts= 10;
+
+    for (my $cur_attempt=1; $cur_attempt <= $total_attempts; ++$cur_attempt)
+    {
+      unless (kill (0, $instance_manager->{'angel_pid'}))
+      {
+        mtr_debug("IM-angel died.");
+        last;
+      }
+
+      sleep(1);
+    }
+  }
+
   # Check that all processes died.
 
   my $clean_shutdown= 0;
 
   while (1)
   {
-    last if kill (0, $instance_manager->{'pid'});
+    if (kill (0, $instance_manager->{'pid'}))
+    {
+      mtr_debug("IM-main is still alive.");
+      last;
+    }
 
-    last if (defined $instance_manager->{'angel_pid'}) &&
-            kill (0, $instance_manager->{'angel_pid'});
+    if (defined $instance_manager->{'angel_pid'} &&
+        kill (0, $instance_manager->{'angel_pid'}))
+    {
+      mtr_debug("IM-angel is still alive.");
+      last;
+    }
 
     foreach my $pid (@mysqld_pids)
     {
-      last if kill (0, $pid);
+      if (kill (0, $pid))
+      {
+        mtr_debug("Guarded mysqld ($pid) is still alive.");
+        last;
+      }
     }
 
     $clean_shutdown= 1;
@@ -3146,15 +3182,21 @@ sub im_stop($) {
 
   unless ($clean_shutdown)
   {
-    mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
-      if defined $instance_manager->{'angel_pid'};
+
+    if (defined $instance_manager->{'angel_pid'})
+    {
+      mtr_debug("Killing IM-angel...");
+      mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
+    }
     
+    mtr_debug("Killing IM-main...");
     mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10, 1);
 
     # Shutdown managed mysqld-processes. Some of them may be nonguarded, so IM
     # will not stop them on shutdown. So, we should firstly try to end them
     # legally.
 
+    mtr_debug("Killing guarded mysqld(s)...");
     mtr_kill_processes(\@mysqld_pids);
 
     # Complain in error log so that a warning will be shown.

--- 1.34/server-tools/instance-manager/manager.cc	2006-05-30 17:07:39 +04:00
+++ 1.35/server-tools/instance-manager/manager.cc	2006-06-20 18:04:03 +04:00
@@ -198,6 +198,25 @@ void manager()
   if (create_pid_file(Options::Main::pid_file_name, manager_pid))
     return; /* necessary logging has been already done. */
 
+  /*
+    Initialize signals and alarm-infrastructure.
+
+    NOTE: To work nicely with LinuxThreads, the signal thread is the first
+    thread in the process.
+
+    NOTE:
+      After init_thr_alarm() call it's possible to call thr_alarm() (from
+      different threads), that results in sending ALARM signal to the alarm
+      thread (which can be the main thread). That signal can interrupt
+      blocking calls.
+
+      In other words, a blocking call can be interrupted in the main thread
+      after init_thr_alarm().
+  */
+
+  sigset_t mask;
+  set_signals(&mask);
+
   /* create guardian thread */
   {
     pthread_t guardian_thd_id;
@@ -205,9 +224,16 @@ void manager()
     int rc;
 
     /*
-       NOTE: Guardian should be shutdown first. Only then all other threads
-       need to be stopped. This should be done, as guardian is responsible for
-       shutting down the instances, and this is a long operation.
+      NOTE: Guardian should be shutdown first. Only then all other threads
+      need to be stopped. This should be done, as guardian is responsible
+      for shutting down the instances, and this is a long operation.
+
+      NOTE: Guardian uses thr_alarm() when detects current state of
+      instances (is_running()), but it is not interfere with
+      flush_instances() later in the code, because until flush_instances()
+      complete in the main thread, Guardian thread is not permitted to
+      process instances. And before flush_instances() there is no instances
+      to proceed.
     */
 
     pthread_attr_init(&guardian_thd_attr);
@@ -223,10 +249,8 @@ void manager()
 
   }
 
-  /*
-    To work nicely with LinuxThreads, the signal thread is the first thread
-    in the process.
-  */
+  /* Load instances. */
+
 
   {
     instance_map.guardian->lock();
@@ -245,11 +269,6 @@ void manager()
       return;
     }
   }
-
-  /* Initialize signals and alarm-infrastructure. */
-
-  sigset_t mask;
-  set_signals(&mask);
 
   /* create the listener */
   {

--- 1.26/mysql-test/r/insert.result	2006-06-04 19:52:00 +04:00
+++ 1.27/mysql-test/r/insert.result	2006-06-20 18:04:02 +04:00
@@ -321,3 +321,35 @@ ERROR 42000: Column 'b' specified twice
 INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
 ERROR 42000: Column 'b' specified twice
 drop table t1;
+create table t1 (n int);
+create view  v1 as select * from t1;
+insert delayed into v1 values (1);
+ERROR HY000: 'test.v1' is not BASE TABLE
+drop table t1;
+drop view  v1;
+create table t1 (id int primary key, data int);
+insert into t1 values (1, 1), (2, 2), (3, 3);
+select row_count();
+row_count()
+3
+insert ignore into t1 values (1, 1);
+select row_count();
+row_count()
+0
+replace into t1 values (1, 11);
+select row_count();
+row_count()
+2
+replace into t1 values (4, 4);
+select row_count();
+row_count()
+1
+insert into t1 values (2, 2) on duplicate key update data= data + 10;
+select row_count();
+row_count()
+2
+insert into t1 values (5, 5) on duplicate key update data= data + 10;
+select row_count();
+row_count()
+1
+drop table t1;

--- 1.24/mysql-test/t/insert.test	2006-06-04 19:52:05 +04:00
+++ 1.25/mysql-test/t/insert.test	2006-06-20 18:04:03 +04:00
@@ -201,3 +201,36 @@ insert into t1 (b,b) select 1,2;
 --error 1110
 INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
 drop table t1;
+# Test for INSERT DELAYED INTO a <view>
+# BUG#13683: INSERT DELAYED into a view creates an infinite loop
+#
+
+create table t1 (n int);
+create view  v1 as select * from t1;
+--error 1347
+insert delayed into v1 values (1);
+drop table t1;
+drop view  v1;
+
+#
+# Test for values returned by ROW_COUNT() function
+# (and thus for values returned by mysql_affected_rows())
+# for various forms of INSERT
+#
+create table t1 (id int primary key, data int);
+insert into t1 values (1, 1), (2, 2), (3, 3);
+select row_count();
+insert ignore into t1 values (1, 1);
+select row_count();
+# Reports that 2 rows are affected (1 deleted + 1 inserted)
+replace into t1 values (1, 11);
+select row_count();
+replace into t1 values (4, 4);
+select row_count();
+# Reports that 2 rows are affected. This conforms to documentation.
+# (Useful for differentiating inserts from updates).
+insert into t1 values (2, 2) on duplicate key update data= data + 10;
+select row_count();
+insert into t1 values (5, 5) on duplicate key update data= data + 10;
+select row_count();
+drop table t1;

--- 1.28/server-tools/instance-manager/instance_map.cc	2006-05-19 04:51:19 +04:00
+++ 1.29/server-tools/instance-manager/instance_map.cc	2006-06-20 17:50:09 +04:00
@@ -293,7 +293,7 @@ int Instance_map::flush_instances()
             get_instance_key, delete_instance, 0);
 
   rc= load();
-  guardian->init();
+  guardian->init(); // TODO: check error status.
   return rc;
 }
 
Thread
bk commit into 5.1 tree (anozdrin:1.2229)Alexander Nozdrin20 Jun