Commit a73e6126 authored by unknown's avatar unknown
Browse files

Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into mysql.com:/Users/kent/mysql/bk/mysql-5.1-new

parents fa0b07d8 a5d9932b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@
#ifndef yaSSL_NEW_HPP
#define yaSSL_NEW_HPP

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


#ifdef __sun
 
+20 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ sub mtr_record_dead_children ();
sub mtr_exit ($);
sub sleep_until_file_created ($$$);
sub mtr_kill_processes ($);
sub mtr_kill_process ($$$$);

# static in C
sub spawn_impl ($$$$$$$$);
@@ -875,6 +876,25 @@ sub mtr_kill_processes ($) {
  }
}


sub mtr_kill_process ($$$$) {
  my $pid= shift;
  my $signal= shift;
  my $retries= shift;
  my $timeout= shift;

  while (1)
  {
    kill($signal, $pid);

    last unless kill (0, $pid) and $retries--;

    mtr_debug("Sleep $timeout second waiting for processes to die");

    sleep($timeout);
  }
}

##############################################################################
#
#  When we exit, we kill off all children
+73 −13
Original line number Diff line number Diff line
@@ -929,6 +929,7 @@ sub command_line_setup () {
   path_err =>        "$opt_vardir/log/im.err",
   path_log =>        "$opt_vardir/log/im.log",
   path_pid =>        "$opt_vardir/run/im.pid",
   path_angel_pid =>  "$opt_vardir/run/im.angel.pid",
   path_sock =>       "$sockdir/im.sock",
   port =>            $im_port,
   start_timeout =>   $master->[0]->{'start_timeout'},
@@ -1220,6 +1221,7 @@ sub environment_setup () {
  $ENV{'NDB_STATUS_OK'}=      "YES";

  $ENV{'IM_PATH_PID'}=        $instance_manager->{path_pid};
  $ENV{'IM_PATH_ANGEL_PID'}=  $instance_manager->{path_angel_pid};
  $ENV{'IM_PORT'}=            $instance_manager->{port};

  $ENV{'IM_MYSQLD1_SOCK'}=    $instance_manager->{instances}->[0]->{path_sock};
@@ -1999,6 +2001,7 @@ sub im_create_defaults_file($) {

[manager]
pid-file            = $instance_manager->{path_pid}
angel-pid-file      = $instance_manager->{path_angel_pid}
socket              = $instance_manager->{path_sock}
port                = $instance_manager->{port}
password-file       = $instance_manager->{password_file}
@@ -3061,6 +3064,18 @@ sub im_start($$) {
sub im_stop($) {
  my $instance_manager = shift;

  # Obtain mysqld-process pids before we start stopping IM (it can delete pid
  # files).

  my @mysqld_pids = ();
  my $instances = $instance_manager->{'instances'};

  push(@mysqld_pids, mtr_get_pid_from_file($instances->[0]->{'path_pid'}))
    if -r $instances->[0]->{'path_pid'};

  push(@mysqld_pids, mtr_get_pid_from_file($instances->[1]->{'path_pid'}))
    if -r $instances->[1]->{'path_pid'};

  # Re-read pid from the file, since during tests Instance Manager could have
  # been restarted, so its pid could have been changed.

@@ -3068,34 +3083,79 @@ sub im_stop($) {
    mtr_get_pid_from_file($instance_manager->{'path_pid'})
      if -f $instance_manager->{'path_pid'};

  if (-f $instance_manager->{'path_angel_pid'})
  {
    $instance_manager->{'angel_pid'} =
      mtr_get_pid_from_file($instance_manager->{'path_angel_pid'})
  }
  else
  {
    $instance_manager->{'angel_pid'} = undef;
  }

  # Inspired from mtr_stop_mysqld_servers().

  start_reap_all();

  # Create list of pids. We should stop Instance Manager and all started
  # mysqld-instances. Some of them may be nonguarded, so IM will not stop them
  # on shutdown.
  # Try graceful shutdown.

  my @pids = ( $instance_manager->{'pid'} );
  my $instances = $instance_manager->{'instances'};
  mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10, 1);

  if ( -r $instances->[0]->{'path_pid'} )
  # Check that all processes died.

  my $clean_shutdown= 0;

  while (1)
  {
    push(@pids, mtr_get_pid_from_file($instances->[0]->{'path_pid'}));
  }
    last if kill (0, $instance_manager->{'pid'});

  if ( -r $instances->[1]->{'path_pid'} )
    last if (defined $instance_manager->{'angel_pid'}) &&
            kill (0, $instance_manager->{'angel_pid'});

    foreach my $pid (@mysqld_pids)
    {
    push(@pids, mtr_get_pid_from_file($instances->[1]->{'path_pid'}));
      last if kill (0, $pid);
    }

    $clean_shutdown= 1;
    last;
  }

  # Kill processes.
  # Kill leftovers (the order is important).

  unless ($clean_shutdown)
  {
    mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
      if defined $instance_manager->{'angel_pid'};
    
    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_kill_processes(\@mysqld_pids);

    # Complain in error log so that a warning will be shown.

    my $errlog= "$opt_vardir/log/mysql-test-run.pl.err";

    open (ERRLOG, ">>$errlog") ||
      mtr_error("Can not open error log ($errlog)");

    my $ts= localtime();
    print ERRLOG
      "Warning: [$ts] Instance Manager did not shutdown gracefully.\n";

    close ERRLOG;
  }

  mtr_kill_processes(\@pids);
  # That's all.

  stop_reap_all();

  $instance_manager->{'pid'} = undef;
  $instance_manager->{'angel_pid'} = undef;
}


+4 −0
Original line number Diff line number Diff line
@@ -53,3 +53,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1	SIMPLE		ref	0,01	0	5	const	1	Using where; Using index
drop table ;
set names latin1;
select 3 into @v1;
explain select 3 into @v1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+22 −0
Original line number Diff line number Diff line
@@ -1154,3 +1154,25 @@ id select_type table type possible_keys key key_len ref rows Extra
1	SIMPLE	t1	index	PRIMARY,name	name	23	NULL	3	Using where; Using index
1	SIMPLE	t2	ref	fkey	fkey	5	test.t1.id	1	Using where; Using index
DROP TABLE t1,t2;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a int);
CREATE table t2 (b int);
INSERT INTO t1 VALUES (1), (2), (3), (4), (1), (1), (3);
INSERT INTO t2 VALUES (2), (3);
CREATE VIEW v1 AS SELECT a FROM t1 JOIN t2 ON t1.a=t2.b;
CREATE VIEW v2 AS SELECT b FROM t2 JOIN t1 ON t2.b=t1.a;
SELECT v1.a, v2. b 
FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3)
GROUP BY v1.a;
a	b
2	NULL
3	3
SELECT v1.a, v2. b 
FROM { OJ v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) }
GROUP BY v1.a;
a	b
2	NULL
3	3
DROP VIEW v1,v2;
DROP TABLE t1,t2;
Loading