Below is the list of changes that have just been committed into a local
5.1 repository of tsmith. When tsmith 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@stripped, 2006-09-02 07:23:55+02:00, tsmith@stripped +39 -0
Merge maint2.mysql.com:/data/localhome/tsmith/bk/g51
into maint2.mysql.com:/data/localhome/tsmith/bk/51
MERGE: 1.2255.48.21
BUILD/check-cpu@stripped, 2006-09-02 07:16:06+02:00, tsmith@stripped +5 -5
Manual merge.
MERGE: 1.14.1.1
client/mysqltest.c@stripped, 2006-09-02 07:13:52+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.221.2.1
configure.in@stripped, 2006-09-02 07:13:51+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.378.1.1
include/config-netware.h@stripped, 2006-09-02 07:13:52+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.16.2.1
include/mysql_com.h@stripped, 2006-09-02 07:13:52+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.109.1.1
mysql-test/lib/mtr_process.pl@stripped, 2006-09-02 07:13:52+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.45.1.2
mysql-test/mysql-test-run.pl@stripped, 2006-09-02 07:13:52+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.150.3.5
mysql-test/r/func_time.result@stripped, 2006-09-02 07:13:52+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.68.2.1
mysql-test/r/grant.result@stripped, 2006-09-02 07:13:52+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.56.1.4
mysql-test/r/innodb_mysql.result@stripped, 2006-09-02 07:13:52+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.7.1.1
mysql-test/r/partition.result@stripped, 2006-09-02 07:13:52+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.49.4.1
mysql-test/r/partition_mgm.result@stripped, 2006-09-02 07:13:53+02:00,
tsmith@stripped +0 -0
Auto merged
MERGE: 1.5.1.2
mysql-test/t/disabled.def@stripped, 2006-09-02 07:13:53+02:00, tsmith@stripped +0
-0
Auto merged
MERGE: 1.184.1.6
mysql-test/t/func_time.test@stripped, 2006-09-02 07:13:53+02:00, tsmith@stripped +0
-0
Auto merged
MERGE: 1.54.2.1
mysql-test/t/grant.test@stripped, 2006-09-02 07:13:53+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.43.1.3
mysql-test/t/innodb_mysql.test@stripped, 2006-09-02 07:13:53+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.7.1.1
sql/ha_innodb.cc@stripped, 2006-09-02 07:13:53+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.284.4.1
sql/item_func.h@stripped, 2006-09-02 07:13:53+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.144.1.1
sql/item_strfunc.cc@stripped, 2006-09-02 07:13:53+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.285.1.1
sql/item_strfunc.h@stripped, 2006-09-02 07:13:53+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.116.1.1
sql/item_timefunc.cc@stripped, 2006-09-02 07:13:54+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.129.2.1
sql/mysqld.cc@stripped, 2006-09-02 07:13:54+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.574.2.5
sql/sql_acl.cc@stripped, 2006-09-02 07:13:54+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.204.2.2
sql/sql_show.cc@stripped, 2006-09-02 07:13:55+02:00, tsmith@stripped +0 -0
Auto merged
MERGE: 1.361.1.3
storage/innobase/btr/btr0btr.c@stripped, 2006-09-02 07:13:55+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.44.2.1
storage/innobase/buf/buf0buf.c@stripped, 2006-09-02 07:13:55+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.53.2.1
storage/innobase/dict/dict0dict.c@stripped, 2006-09-02 07:13:55+02:00,
tsmith@stripped +0 -0
Auto merged
MERGE: 1.83.2.1
storage/innobase/fil/fil0fil.c@stripped, 2006-09-02 07:13:55+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.65.2.1
storage/innobase/fsp/fsp0fsp.c@stripped, 2006-09-02 07:13:55+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.28.2.1
storage/innobase/include/btr0cur.ic@stripped, 2006-09-02 07:13:55+02:00,
tsmith@stripped +0 -0
Auto merged
MERGE: 1.6.2.1
storage/innobase/include/buf0buf.ic@stripped, 2006-09-02 07:13:55+02:00,
tsmith@stripped +0 -0
Auto merged
MERGE: 1.20.2.1
storage/innobase/log/log0log.c@stripped, 2006-09-02 07:13:56+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.47.2.1
storage/innobase/log/log0recv.c@stripped, 2006-09-02 07:13:56+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.55.2.1
storage/innobase/os/os0file.c@stripped, 2006-09-02 07:13:56+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.116.2.1
storage/innobase/row/row0mysql.c@stripped, 2006-09-02 07:23:38+02:00,
tsmith@stripped +0 -1
Manual (null) merge.
MERGE: 1.128.2.1
storage/innobase/row/row0sel.c@stripped, 2006-09-02 07:13:56+02:00, tsmith@stripped
+0 -0
Auto merged
MERGE: 1.106.2.1
storage/innobase/srv/srv0start.c@stripped, 2006-09-02 07:13:56+02:00,
tsmith@stripped +0 -0
Auto merged
MERGE: 1.93.2.1
storage/innobase/ut/ut0dbg.c@stripped, 2006-09-02 07:13:56+02:00, tsmith@stripped +0
-0
Auto merged
MERGE: 1.11.2.1
tests/mysql_client_test.c@stripped, 2006-09-02 07:13:57+02:00, tsmith@stripped +0
-0
Auto merged
MERGE: 1.204.2.1
# 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: tsmith
# Host: maint2.mysql.com
# Root: /data/localhome/tsmith/bk/51/RESYNC
--- 1.110/include/mysql_com.h 2006-09-02 07:23:30 +02:00
+++ 1.111/include/mysql_com.h 2006-09-02 07:23:30 +02:00
@@ -215,7 +215,13 @@ typedef struct st_net {
char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1];
unsigned int last_errno;
unsigned char error;
+
+ /*
+ 'query_cache_query' should be accessed only via query cache
+ functions and methods to maintain proper locking.
+ */
gptr query_cache_query;
+
my_bool report_error; /* We should report error (we have unreported error) */
my_bool return_errno;
} NET;
--- 1.146/sql/item_func.h 2006-09-02 07:23:30 +02:00
+++ 1.147/sql/item_func.h 2006-09-02 07:23:30 +02:00
@@ -54,7 +54,7 @@ public:
SP_POINTN,SP_GEOMETRYN,SP_INTERIORRINGN,
NOT_FUNC, NOT_ALL_FUNC,
NOW_FUNC, TRIG_COND_FUNC,
- GUSERVAR_FUNC, COLLATE_FUNC,
+ SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC };
enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
OPTIMIZE_EQUAL };
@@ -1196,13 +1196,16 @@ public:
Item_func_set_user_var(LEX_STRING a,Item *b)
:Item_func(b), cached_result_type(INT_RESULT), name(a)
{}
+ enum Functype functype() const { return SUSERVAR_FUNC; }
double val_real();
longlong val_int();
String *val_str(String *str);
my_decimal *val_decimal(my_decimal *);
bool update_hash(void *ptr, uint length, enum Item_result type,
CHARSET_INFO *cs, Derivation dv, bool unsigned_arg= 0);
- bool check();
+ bool send(Protocol *protocol, String *str_arg);
+ void make_field(Send_field *tmp_field);
+ bool check(bool use_result_field);
bool update();
enum Item_result result_type () const { return cached_result_type; }
bool fix_fields(THD *thd, Item **ref);
--- 1.288/sql/item_strfunc.cc 2006-09-02 07:23:30 +02:00
+++ 1.289/sql/item_strfunc.cc 2006-09-02 07:23:30 +02:00
@@ -2053,6 +2053,26 @@ String *Item_func_make_set::val_str(Stri
}
+Item *Item_func_make_set::transform(Item_transformer transformer, byte *arg)
+{
+ DBUG_ASSERT(!current_thd->is_stmt_prepare());
+
+ Item *new_item= item->transform(transformer, arg);
+ if (!new_item)
+ return 0;
+
+ /*
+ THD::change_item_tree() should be called only if the tree was
+ really transformed, i.e. when a new item has been created.
+ Otherwise we'll be allocating a lot of unnecessary memory for
+ change records at each execution.
+ */
+ if (item != new_item)
+ current_thd->change_item_tree(&item, new_item);
+ return Item_str_func::transform(transformer, arg);
+}
+
+
void Item_func_make_set::print(String *str)
{
str->append(STRING_WITH_LEN("make_set("));
--- 1.118/sql/item_strfunc.h 2006-09-02 07:23:30 +02:00
+++ 1.119/sql/item_strfunc.h 2006-09-02 07:23:30 +02:00
@@ -502,14 +502,7 @@ public:
return item->walk(processor, walk_subquery, arg) ||
Item_str_func::walk(processor, walk_subquery, arg);
}
- Item *transform(Item_transformer transformer, byte *arg)
- {
- Item *new_item= item->transform(transformer, arg);
- if (!new_item)
- return 0;
- item= new_item;
- return Item_str_func::transform(transformer, arg);
- }
+ Item *transform(Item_transformer transformer, byte *arg);
void print(String *str);
};
--- 1.578/sql/mysqld.cc 2006-09-02 07:23:30 +02:00
+++ 1.579/sql/mysqld.cc 2006-09-02 07:23:30 +02:00
@@ -2432,10 +2432,8 @@ static int my_message_sql(uint error, co
if ((thd= current_thd))
{
if (thd->spcont &&
- thd->spcont->find_handler(error, MYSQL_ERROR::WARN_LEVEL_ERROR))
+ thd->spcont->handle_error(error, MYSQL_ERROR::WARN_LEVEL_ERROR, thd))
{
- if (! thd->spcont->found_handler_here())
- thd->net.report_error= 1; /* Make "select" abort correctly */
DBUG_RETURN(0);
}
--- 1.210/sql/sql_acl.cc 2006-09-02 07:23:30 +02:00
+++ 1.211/sql/sql_acl.cc 2006-09-02 07:23:30 +02:00
@@ -3044,14 +3044,6 @@ bool mysql_table_grant(THD *thd, TABLE_L
result= TRUE;
continue;
}
- if (Str->host.length > HOSTNAME_LENGTH ||
- Str->user.length > USERNAME_LENGTH)
- {
- my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER),
- MYF(0));
- result= TRUE;
- continue;
- }
/* Create user if needed */
error=replace_user_table(thd, tables[0].table, *Str,
0, revoke_grant, create_new_users,
@@ -3256,15 +3248,6 @@ bool mysql_routine_grant(THD *thd, TABLE
result= TRUE;
continue;
}
- if (Str->host.length > HOSTNAME_LENGTH ||
- Str->user.length > USERNAME_LENGTH)
- {
- if (!no_error)
- my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER),
- MYF(0));
- result= TRUE;
- continue;
- }
/* Create user if needed */
error=replace_user_table(thd, tables[0].table, *Str,
0, revoke_grant, create_new_users,
@@ -3390,14 +3373,6 @@ bool mysql_grant(THD *thd, const char *d
result= TRUE;
continue;
}
- if (Str->host.length > HOSTNAME_LENGTH ||
- Str->user.length > USERNAME_LENGTH)
- {
- my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER),
- MYF(0));
- result= -1;
- continue;
- }
if (replace_user_table(thd, tables[0].table, *Str,
(!db ? rights : 0), revoke_grant, create_new_users,
test(thd->variables.sql_mode &
@@ -4304,14 +4279,6 @@ bool mysql_show_grants(THD *thd,LEX_USER
if (!initialized)
{
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables");
- DBUG_RETURN(TRUE);
- }
-
- if (lex_user->host.length > HOSTNAME_LENGTH ||
- lex_user->user.length > USERNAME_LENGTH)
- {
- my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER),
- MYF(0));
DBUG_RETURN(TRUE);
}
--- 1.365/sql/sql_show.cc 2006-09-02 07:23:30 +02:00
+++ 1.366/sql/sql_show.cc 2006-09-02 07:23:30 +02:00
@@ -1227,9 +1227,10 @@ int store_create_info(THD *thd, TABLE_LI
store_key_options(thd, packet, table, key_info);
if (key_info->parser)
{
- packet->append(" WITH PARSER ", 13);
+ packet->append(STRING_WITH_LEN(" /*!50100 WITH PARSER "));
append_identifier(thd, packet, key_info->parser->name.str,
key_info->parser->name.length);
+ packet->append(STRING_WITH_LEN(" */ "));
}
}
@@ -1255,9 +1256,9 @@ int store_create_info(THD *thd, TABLE_LI
if ((for_str= file->get_tablespace_name(thd)))
{
- packet->append(" TABLESPACE ");
+ packet->append(STRING_WITH_LEN(" /*!50100 TABLESPACE "));
packet->append(for_str, strlen(for_str));
- packet->append(" STORAGE DISK");
+ packet->append(STRING_WITH_LEN(" STORAGE DISK */"));
my_free(for_str, MYF(0));
}
@@ -1296,7 +1297,7 @@ int store_create_info(THD *thd, TABLE_LI
if(create_info.auto_increment_value > 1)
{
- packet->append(" AUTO_INCREMENT=", 16);
+ packet->append(STRING_WITH_LEN(" AUTO_INCREMENT="));
end= longlong10_to_str(create_info.auto_increment_value, buff,10);
packet->append(buff, (uint) (end - buff));
}
--- 1.8/mysql-test/r/innodb_mysql.result 2006-09-02 07:23:30 +02:00
+++ 1.9/mysql-test/r/innodb_mysql.result 2006-09-02 07:23:30 +02:00
@@ -407,3 +407,49 @@ Warnings:
Warning 1071 Specified key was too long; max key length is 765 bytes
insert into t1 values('aaa');
drop table t1;
+CREATE TABLE `t2` (
+`k` int(11) NOT NULL auto_increment,
+`a` int(11) default NULL,
+`c` int(11) default NULL,
+PRIMARY KEY (`k`),
+UNIQUE KEY `idx_1` (`a`)
+) ENGINE=InnoDB;
+insert into t2 ( a ) values ( 6 ) on duplicate key update c =
+ifnull( c,
+0 ) + 1;
+insert into t2 ( a ) values ( 7 ) on duplicate key update c =
+ifnull( c,
+0 ) + 1;
+select last_insert_id();
+last_insert_id()
+2
+select * from t2;
+k a c
+1 6 NULL
+2 7 NULL
+insert into t2 ( a ) values ( 6 ) on duplicate key update c =
+ifnull( c,
+0 ) + 1;
+select last_insert_id();
+last_insert_id()
+1
+select * from t2;
+k a c
+1 6 1
+2 7 NULL
+insert ignore into t2 values (null,6,1),(10,8,1);
+select last_insert_id();
+last_insert_id()
+1
+insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
+select last_insert_id();
+last_insert_id()
+11
+select * from t2;
+k a c
+1 6 1
+2 7 NULL
+10 8 1
+11 15 1
+12 20 1
+drop table t2;
--- 1.8/mysql-test/t/innodb_mysql.test 2006-09-02 07:23:30 +02:00
+++ 1.9/mysql-test/t/innodb_mysql.test 2006-09-02 07:23:30 +02:00
@@ -367,3 +367,40 @@ create table t1(f1 varchar(800) binary n
character set utf8 collate utf8_general_ci;
insert into t1 values('aaa');
drop table t1;
+
+# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
+# UPDATE": now LAST_INSERT_ID() will return the id of the updated
+# row.
+CREATE TABLE `t2` (
+ `k` int(11) NOT NULL auto_increment,
+ `a` int(11) default NULL,
+ `c` int(11) default NULL,
+ PRIMARY KEY (`k`),
+ UNIQUE KEY `idx_1` (`a`)
+) ENGINE=InnoDB;
+ insert into t2 ( a ) values ( 6 ) on duplicate key update c =
+ifnull( c,
+0 ) + 1;
+insert into t2 ( a ) values ( 7 ) on duplicate key update c =
+ifnull( c,
+0 ) + 1;
+select last_insert_id();
+select * from t2;
+insert into t2 ( a ) values ( 6 ) on duplicate key update c =
+ifnull( c,
+0 ) + 1;
+select last_insert_id();
+select * from t2;
+
+# Test of LAST_INSERT_ID() when autogenerated will fail:
+# last_insert_id() should not change
+insert ignore into t2 values (null,6,1),(10,8,1);
+select last_insert_id();
+# First and second autogenerated will fail, last_insert_id() should
+# point to third
+insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
+select last_insert_id();
+select * from t2;
+
+drop table t2;
+
--- 1.47/mysql-test/lib/mtr_process.pl 2006-09-02 07:23:30 +02:00
+++ 1.48/mysql-test/lib/mtr_process.pl 2006-09-02 07:23:30 +02:00
@@ -25,7 +25,28 @@ sub sleep_until_file_created ($$$);
sub mtr_kill_processes ($);
sub mtr_ping_with_timeout($);
sub mtr_ping_port ($);
-sub mtr_kill_process ($$$);
+
+# Private IM-related operations.
+
+sub mtr_im_kill_process ($$$);
+sub mtr_im_load_pids ($);
+sub mtr_im_terminate ($);
+sub mtr_im_check_alive ($);
+sub mtr_im_check_main_alive ($);
+sub mtr_im_check_angel_alive ($);
+sub mtr_im_check_mysqlds_alive ($);
+sub mtr_im_check_mysqld_alive ($$);
+sub mtr_im_cleanup ($);
+sub mtr_im_rm_file ($);
+sub mtr_im_errlog ($);
+sub mtr_im_kill ($);
+sub mtr_im_wait_for_connection ($$$);
+sub mtr_im_wait_for_mysqld($$$);
+
+# Public IM-related operations.
+
+sub mtr_im_start ($$);
+sub mtr_im_stop ($$);
# static in C
sub spawn_impl ($$$$$$$$);
@@ -337,16 +358,27 @@ sub mtr_process_exit_status {
# kill IM manager first, else it will restart the servers
sub mtr_kill_leftovers () {
+ mtr_debug("mtr_kill_leftovers(): started.");
+
+ mtr_im_stop($::instance_manager, 'mtr_kill_leftovers');
+
+ # Start shutdown of masters and slaves. Don't touch IM-managed mysqld
+ # instances -- they should be stopped by mtr_im_stop().
+
+ mtr_debug("Shutting down mysqld-instances...");
+
my @kill_pids;
my %admin_pids;
- my $pid;
- #Start shutdown of instance_managers, masters and slaves
- foreach my $srv ($::instance_manager,
- @{$::instance_manager->{'instances'}},
- @{$::master},@{$::slave})
+ foreach my $srv (@{$::master}, @{$::slave})
{
- $pid= mtr_mysqladmin_start($srv, "shutdown", 70);
+ mtr_debug(" - mysqld " .
+ "(pid: $srv->{pid}; " .
+ "pid file: '$srv->{path_pid}'; " .
+ "socket: '$srv->{path_sock}'; ".
+ "port: $srv->{port})");
+
+ my $pid= mtr_mysqladmin_start($srv, "shutdown", 70);
# Save the pid of the mysqladmin process
$admin_pids{$pid}= 1;
@@ -360,10 +392,17 @@ sub mtr_kill_leftovers () {
$srv->{'pid'}= 0; # Assume we are done with it
}
- # Start shutdown of clusters
+ # Start shutdown of clusters.
+
+ mtr_debug("Shutting down cluster...");
+
foreach my $cluster (@{$::clusters})
{
- $pid= mtr_ndbmgm_start($cluster, "shutdown");
+ mtr_debug(" - cluster " .
+ "(pid: $cluster->{pid}; " .
+ "pid file: '$cluster->{path_pid})");
+
+ my $pid= mtr_ndbmgm_start($cluster, "shutdown");
# Save the pid of the ndb_mgm process
$admin_pids{$pid}= 1;
@@ -378,13 +417,16 @@ sub mtr_kill_leftovers () {
foreach my $ndbd (@{$cluster->{'ndbds'}})
{
+ mtr_debug(" - ndbd " .
+ "(pid: $ndbd->{pid}; " .
+ "pid file: '$ndbd->{path_pid})");
+
push(@kill_pids,{
pid => $ndbd->{'pid'},
pidfile => $ndbd->{'path_pid'},
});
$ndbd->{'pid'}= 0; # Assume we are done with it
}
-
}
# Wait for all the admin processes to complete
@@ -413,6 +455,8 @@ sub mtr_kill_leftovers () {
# FIXME $path_run_dir or something
my $rundir= "$::opt_vardir/run";
+ mtr_debug("Processing PID files in directory '$rundir'...");
+
if ( -d $rundir )
{
opendir(RUNDIR, $rundir)
@@ -426,8 +470,12 @@ sub mtr_kill_leftovers () {
if ( -f $pidfile )
{
+ mtr_debug("Processing PID file: '$pidfile'...");
+
my $pid= mtr_get_pid_from_file($pidfile);
+ mtr_debug("Got pid: $pid from file '$pidfile'");
+
# Race, could have been removed between I tested with -f
# and the unlink() below, so I better check again with -f
@@ -438,14 +486,24 @@ sub mtr_kill_leftovers () {
if ( $::glob_cygwin_perl or kill(0, $pid) )
{
+ mtr_debug("There is process with pid $pid -- scheduling for kill.");
push(@pids, $pid); # We know (cygwin guess) it exists
}
+ else
+ {
+ mtr_debug("There is no process with pid $pid -- skipping.");
+ }
}
}
closedir(RUNDIR);
if ( @pids )
{
+ mtr_debug("Killing the following processes with PID files: " .
+ join(' ', @pids) . "...");
+
+ start_reap_all();
+
if ( $::glob_cygwin_perl )
{
# We have no (easy) way of knowing the Cygwin controlling
@@ -459,6 +517,7 @@ sub mtr_kill_leftovers () {
my $retries= 10; # 10 seconds
do
{
+ mtr_debug("Sending SIGKILL to pids: " . join(' ', @pids));
kill(9, @pids);
mtr_report("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
@@ -469,12 +528,20 @@ sub mtr_kill_leftovers () {
mtr_warning("can't kill process(es) " . join(" ", @pids));
}
}
+
+ stop_reap_all();
}
}
+ else
+ {
+ mtr_debug("Directory for PID files ($rundir) does not exist.");
+ }
# We may have failed everything, but we now check again if we have
# the listen ports free to use, and if they are free, just go for it.
+ mtr_debug("Checking known mysqld servers...");
+
foreach my $srv ( @kill_pids )
{
if ( defined $srv->{'port'} and mtr_ping_port($srv->{'port'}) )
@@ -482,6 +549,8 @@ sub mtr_kill_leftovers () {
mtr_warning("can't kill old process holding port $srv->{'port'}");
}
}
+
+ mtr_debug("mtr_kill_leftovers(): finished.");
}
@@ -738,6 +807,9 @@ sub mtr_ping_with_timeout($) {
my $res= 1; # If we just fall through, we are done
# in the sense that the servers don't
# listen to their ports any longer
+
+ mtr_debug("Waiting for mysqld servers to stop...");
+
TIME:
while ( $timeout-- )
{
@@ -765,7 +837,14 @@ sub mtr_ping_with_timeout($) {
last; # If we got here, we are done
}
- $timeout or mtr_report("At least one server is still listening to its port");
+ if ($res)
+ {
+ mtr_debug("mtr_ping_with_timeout(): All mysqld instances are down.");
+ }
+ else
+ {
+ mtr_report("mtr_ping_with_timeout(): At least one server is alive.");
+ }
return $res;
}
@@ -951,6 +1030,9 @@ sub mtr_ping_port ($) {
{
mtr_error("can't create socket: $!");
}
+
+ mtr_debug("Pinging server (port: $port)...");
+
if ( connect(SOCK, $paddr) )
{
close(SOCK); # FIXME check error?
@@ -1021,34 +1103,12 @@ sub mtr_kill_processes ($) {
{
foreach my $sig (15, 9)
{
- last if mtr_kill_process($pid, $sig, 10);
+ last if mtr_im_kill_process([ $pid ], $sig, 10);
}
}
}
-sub mtr_kill_process ($$$) {
- my $pid= shift;
- my $signal= shift;
- my $timeout= shift; # Seconds to wait for process
- my $max_loop= $timeout*10; # Sleeping 0.1 between each kill attempt
-
- for (my $cur_attempt= 1; $cur_attempt <= $max_loop; ++$cur_attempt)
- {
- mtr_debug("Sending $signal to $pid...");
-
- kill($signal, $pid);
-
- last unless kill (0, $pid) and $max_loop--;
-
- mtr_verbose("Sleep 0.1 second waiting for processes $pid to die");
-
- select(undef, undef, undef, 0.1);
- }
-
- return $max_loop;
-}
-
##############################################################################
#
# When we exit, we kill off all children
@@ -1077,5 +1137,680 @@ sub mtr_exit ($) {
exit($code);
}
+
+##############################################################################
+#
+# Instance Manager management routines.
+#
+##############################################################################
+
+sub mtr_im_kill_process ($$$) {
+ my $pid_lst= shift;
+ my $signal= shift;
+ my $timeout= shift;
+ my $total_attempts= $timeout * 10;
+
+ my %pids;
+
+ foreach my $pid (@{$pid_lst})
+ {
+ $pids{$pid}= 1;
+ }
+
+ for (my $cur_attempt= 1; $cur_attempt <= $total_attempts; ++$cur_attempt)
+ {
+ foreach my $pid (keys %pids)
+ {
+ mtr_debug("Sending $signal to $pid...");
+
+ kill($signal, $pid);
+
+ unless (kill (0, $pid))
+ {
+ mtr_debug("Process $pid died.");
+ delete $pids{$pid};
+ }
+ }
+
+ return if scalar keys %pids == 0;
+
+ mtr_debug("Sleeping 100ms waiting for processes to die...");
+
+ select(undef, undef, undef, 0.1);
+ }
+
+ mtr_debug("Process(es) " .
+ join(' ', keys %pids) .
+ " is still alive after $total_attempts " .
+ "of sending signal $signal.");
+}
+
+###########################################################################
+
+sub mtr_im_load_pids($) {
+ my $instance_manager= shift;
+
+ mtr_debug("Loading PID files...");
+
+ # Obtain mysqld-process pids.
+
+ my $instances = $instance_manager->{'instances'};
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ mtr_debug("IM-guarded mysqld[$idx] PID file: '" .
+ $instances->[$idx]->{'path_pid'} . "'.");
+
+ my $mysqld_pid;
+
+ if (-r $instances->[$idx]->{'path_pid'})
+ {
+ $mysqld_pid= mtr_get_pid_from_file($instances->[$idx]->{'path_pid'});
+ mtr_debug("IM-guarded mysqld[$idx] PID: $mysqld_pid.");
+ }
+ else
+ {
+ $mysqld_pid= undef;
+ mtr_debug("IM-guarded mysqld[$idx]: no PID file.");
+ }
+
+ $instances->[$idx]->{'pid'}= $mysqld_pid;
+ }
+
+ # Re-read Instance Manager PIDs from the file, since during tests Instance
+ # Manager could have been restarted, so its PIDs could have been changed.
+
+ # - IM-main
+
+ mtr_debug("IM-main PID file: '$instance_manager->{path_pid}'.");
+
+ if (-f $instance_manager->{'path_pid'})
+ {
+ $instance_manager->{'pid'} =
+ mtr_get_pid_from_file($instance_manager->{'path_pid'});
+
+ mtr_debug("IM-main PID: $instance_manager->{pid}.");
+ }
+ else
+ {
+ mtr_debug("IM-main: no PID file.");
+ $instance_manager->{'pid'}= undef;
+ }
+
+ # - IM-angel
+
+ mtr_debug("IM-angel PID file: '$instance_manager->{path_angel_pid}'.");
+
+ if (-f $instance_manager->{'path_angel_pid'})
+ {
+ $instance_manager->{'angel_pid'} =
+ mtr_get_pid_from_file($instance_manager->{'path_angel_pid'});
+
+ mtr_debug("IM-angel PID: $instance_manager->{'angel_pid'}.");
+ }
+ else
+ {
+ mtr_debug("IM-angel: no PID file.");
+ $instance_manager->{'angel_pid'} = undef;
+ }
+}
+
+###########################################################################
+
+sub mtr_im_terminate($) {
+ my $instance_manager= shift;
+
+ # Load pids from pid-files. We should do it first of all, because IM deletes
+ # them on shutdown.
+
+ mtr_im_load_pids($instance_manager);
+
+ mtr_debug("Shutting Instance Manager down...");
+
+ # Ignoring SIGCHLD so that all children could rest in peace.
+
+ start_reap_all();
+
+ # Send SIGTERM to IM-main.
+
+ if (defined $instance_manager->{'pid'})
+ {
+ mtr_debug("IM-main pid: $instance_manager->{pid}.");
+ mtr_debug("Stopping IM-main...");
+
+ mtr_im_kill_process([ $instance_manager->{'pid'} ], 'TERM', 10);
+ }
+ else
+ {
+ mtr_debug("IM-main pid: n/a.");
+ }
+
+ # If IM-angel was alive, wait for it 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);
+ }
+ }
+ else
+ {
+ mtr_debug("IM-angel pid: n/a.");
+ }
+
+ stop_reap_all();
+
+ # Re-load PIDs.
+
+ mtr_im_load_pids($instance_manager);
+}
+
+###########################################################################
+
+sub mtr_im_check_alive($) {
+ my $instance_manager= shift;
+
+ mtr_debug("Checking whether IM-components are alive...");
+
+ return 1 if mtr_im_check_main_alive($instance_manager);
+
+ return 1 if mtr_im_check_angel_alive($instance_manager);
+
+ return 1 if mtr_im_check_mysqlds_alive($instance_manager);
+
+ return 0;
+}
+
+###########################################################################
+
+sub mtr_im_check_main_alive($) {
+ my $instance_manager= shift;
+
+ # Check that the process, that we know to be IM's, is dead.
+
+ if (defined $instance_manager->{'pid'})
+ {
+ if (kill (0, $instance_manager->{'pid'}))
+ {
+ mtr_debug("IM-main (PID: $instance_manager->{pid}) is alive.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("IM-main (PID: $instance_manager->{pid}) is dead.");
+ }
+ }
+ else
+ {
+ mtr_debug("No PID file for IM-main.");
+ }
+
+ # Check that IM does not accept client connections.
+
+ if (mtr_ping_port($instance_manager->{'port'}))
+ {
+ mtr_debug("IM-main (port: $instance_manager->{port}) " .
+ "is accepting connections.");
+
+ mtr_im_errlog("IM-main is accepting connections on port " .
+ "$instance_manager->{port}, but there is no " .
+ "process information.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("IM-main (port: $instance_manager->{port}) " .
+ "does not accept connections.");
+ return 0;
+ }
+}
+
+###########################################################################
+
+sub mtr_im_check_angel_alive($) {
+ my $instance_manager= shift;
+
+ # Check that the process, that we know to be the Angel, is dead.
+
+ if (defined $instance_manager->{'angel_pid'})
+ {
+ if (kill (0, $instance_manager->{'angel_pid'}))
+ {
+ mtr_debug("IM-angel (PID: $instance_manager->{angel_pid}) is alive.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("IM-angel (PID: $instance_manager->{angel_pid}) is dead.");
+ return 0;
+ }
+ }
+ else
+ {
+ mtr_debug("No PID file for IM-angel.");
+ return 0;
+ }
+}
+
+###########################################################################
+
+sub mtr_im_check_mysqlds_alive($) {
+ my $instance_manager= shift;
+
+ mtr_debug("Checking for IM-guarded mysqld instances...");
+
+ my $instances = $instance_manager->{'instances'};
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ mtr_debug("Checking mysqld[$idx]...");
+
+ return 1
+ if mtr_im_check_mysqld_alive($instance_manager, $instances->[$idx]);
+ }
+}
+
+###########################################################################
+
+sub mtr_im_check_mysqld_alive($$) {
+ my $instance_manager= shift;
+ my $mysqld_instance= shift;
+
+ # Check that the process is dead.
+
+ if (defined $instance_manager->{'pid'})
+ {
+ if (kill (0, $instance_manager->{'pid'}))
+ {
+ mtr_debug("Mysqld instance (PID: $mysqld_instance->{pid}) is alive.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("Mysqld instance (PID: $mysqld_instance->{pid}) is dead.");
+ }
+ }
+ else
+ {
+ mtr_debug("No PID file for mysqld instance.");
+ }
+
+ # Check that mysqld does not accept client connections.
+
+ if (mtr_ping_port($mysqld_instance->{'port'}))
+ {
+ mtr_debug("Mysqld instance (port: $mysqld_instance->{port}) " .
+ "is accepting connections.");
+
+ mtr_im_errlog("Mysqld is accepting connections on port " .
+ "$mysqld_instance->{port}, but there is no " .
+ "process information.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("Mysqld instance (port: $mysqld_instance->{port}) " .
+ "does not accept connections.");
+ return 0;
+ }
+}
+
+###########################################################################
+
+sub mtr_im_cleanup($) {
+ my $instance_manager= shift;
+
+ mtr_im_rm_file($instance_manager->{'path_pid'});
+ mtr_im_rm_file($instance_manager->{'path_sock'});
+
+ mtr_im_rm_file($instance_manager->{'path_angel_pid'});
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ mtr_im_rm_file($instance_manager->{'instances'}->[$idx]->{'path_pid'});
+ mtr_im_rm_file($instance_manager->{'instances'}->[$idx]->{'path_sock'});
+ }
+}
+
+###########################################################################
+
+sub mtr_im_rm_file($)
+{
+ my $file_path= shift;
+
+ if (-f $file_path)
+ {
+ mtr_debug("Removing '$file_path'...");
+
+ mtr_warning("Can not remove '$file_path'.")
+ unless unlink($file_path);
+ }
+ else
+ {
+ mtr_debug("File '$file_path' does not exist already.");
+ }
+}
+
+###########################################################################
+
+sub mtr_im_errlog($) {
+ my $msg= shift;
+
+ # Complain in error log so that a warning will be shown.
+ #
+ # TODO: unless BUG#20761 is fixed, we will print the warning to stdout, so
+ # that it can be seen on console and does not produce pushbuild error.
+
+ # 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] $msg\n";
+ #
+ # close ERRLOG;
+
+ my $ts= localtime();
+ print "Warning: [$ts] $msg\n";
+}
+
+###########################################################################
+
+sub mtr_im_kill($) {
+ my $instance_manager= shift;
+
+ # Re-load PIDs. That can be useful because some processes could have been
+ # restarted.
+
+ mtr_im_load_pids($instance_manager);
+
+ # Ignoring SIGCHLD so that all children could rest in peace.
+
+ start_reap_all();
+
+ # Kill IM-angel first of all.
+
+ if (defined $instance_manager->{'angel_pid'})
+ {
+ mtr_debug("Killing IM-angel (PID: $instance_manager->{angel_pid})...");
+ mtr_im_kill_process([ $instance_manager->{'angel_pid'} ], 'KILL', 10);
+ }
+ else
+ {
+ mtr_debug("IM-angel is dead.");
+ }
+
+ # Re-load PIDs again.
+
+ mtr_im_load_pids($instance_manager);
+
+ # Kill IM-main.
+
+ if (defined $instance_manager->{'pid'})
+ {
+ mtr_debug("Killing IM-main (PID: $instance_manager->pid})...");
+ mtr_im_kill_process([ $instance_manager->{'pid'} ], 'KILL', 10);
+ }
+ else
+ {
+ mtr_debug("IM-main is dead.");
+ }
+
+ # Re-load PIDs again.
+
+ mtr_im_load_pids($instance_manager);
+
+ # Kill guarded mysqld instances.
+
+ my @mysqld_pids;
+
+ mtr_debug("Collecting PIDs of mysqld instances to kill...");
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ my $pid= $instance_manager->{'instances'}->[$idx]->{'pid'};
+
+ next unless defined $pid;
+
+ mtr_debug(" - IM-guarded mysqld[$idx] PID: $pid.");
+
+ push (@mysqld_pids, $pid);
+ }
+
+ if (scalar @mysqld_pids > 0)
+ {
+ mtr_debug("Killing IM-guarded mysqld instances...");
+ mtr_im_kill_process(\@mysqld_pids, 'KILL', 10);
+ }
+
+ # That's all.
+
+ stop_reap_all();
+}
+
+##############################################################################
+
+sub mtr_im_wait_for_connection($$$) {
+ my $instance_manager= shift;
+ my $total_attempts= shift;
+ my $connect_timeout= shift;
+
+ mtr_debug("Waiting for IM on port $instance_manager->{port} " .
+ "to start accepting connections...");
+
+ for (my $cur_attempt= 1; $cur_attempt <= $total_attempts; ++$cur_attempt)
+ {
+ mtr_debug("Trying to connect to IM ($cur_attempt of $total_attempts)...");
+
+ if (mtr_ping_port($instance_manager->{'port'}))
+ {
+ mtr_debug("IM is accepting connections " .
+ "on port $instance_manager->{port}.");
+ return 1;
+ }
+
+ mtr_debug("Sleeping $connect_timeout...");
+ sleep($connect_timeout);
+ }
+
+ mtr_debug("IM does not accept connections " .
+ "on port $instance_manager->{port} after " .
+ ($total_attempts * $connect_timeout) . " seconds.");
+
+ return 0;
+}
+
+##############################################################################
+
+sub mtr_im_wait_for_mysqld($$$) {
+ my $mysqld= shift;
+ my $total_attempts= shift;
+ my $connect_timeout= shift;
+
+ mtr_debug("Waiting for IM-guarded mysqld on port $mysqld->{port} " .
+ "to start accepting connections...");
+
+ for (my $cur_attempt= 1; $cur_attempt <= $total_attempts; ++$cur_attempt)
+ {
+ mtr_debug("Trying to connect to mysqld " .
+ "($cur_attempt of $total_attempts)...");
+
+ if (mtr_ping_port($mysqld->{'port'}))
+ {
+ mtr_debug("Mysqld is accepting connections " .
+ "on port $mysqld->{port}.");
+ return 1;
+ }
+
+ mtr_debug("Sleeping $connect_timeout...");
+ sleep($connect_timeout);
+ }
+
+ mtr_debug("Mysqld does not accept connections " .
+ "on port $mysqld->{port} after " .
+ ($total_attempts * $connect_timeout) . " seconds.");
+
+ return 0;
+}
+
+##############################################################################
+
+sub mtr_im_start($$) {
+ my $instance_manager = shift;
+ my $opts = shift;
+
+ mtr_debug("Starting Instance Manager...");
+
+ my $args;
+ mtr_init_args(\$args);
+ mtr_add_arg($args, "--defaults-file=%s",
+ $instance_manager->{'defaults_file'});
+
+ foreach my $opt (@{$opts})
+ {
+ mtr_add_arg($args, $opt);
+ }
+
+ $instance_manager->{'pid'} =
+ mtr_spawn(
+ $::exe_im, # path to the executable
+ $args, # cmd-line args
+ '', # stdin
+ $instance_manager->{'path_log'}, # stdout
+ $instance_manager->{'path_err'}, # stderr
+ '', # pid file path (not used)
+ { append_log_file => 1 } # append log files
+ );
+
+ if ( ! $instance_manager->{'pid'} )
+ {
+ mtr_report('Could not start Instance Manager');
+ return;
+ }
+
+ # Instance Manager can be run in daemon mode. In this case, it creates
+ # several processes and the parent process, created by mtr_spawn(), exits just
+ # after start. So, we have to obtain Instance Manager PID from the PID file.
+
+ if ( ! sleep_until_file_created(
+ $instance_manager->{'path_pid'},
+ $instance_manager->{'start_timeout'},
+ -1)) # real PID is still unknown
+ {
+ mtr_report("Instance Manager PID file is missing");
+ return;
+ }
+
+ $instance_manager->{'pid'} =
+ mtr_get_pid_from_file($instance_manager->{'path_pid'});
+
+ mtr_debug("Instance Manager started. PID: $instance_manager->{pid}.");
+
+ # Wait until we can connect to IM.
+
+ my $IM_CONNECT_TIMEOUT= 30;
+
+ unless (mtr_im_wait_for_connection($instance_manager,
+ $IM_CONNECT_TIMEOUT, 1))
+ {
+ mtr_debug("Can not connect to Instance Manager " .
+ "in $IM_CONNECT_TIMEOUT seconds after start.");
+ mtr_debug("Aborting test suite...");
+
+ mtr_kill_leftovers();
+
+ mtr_error("Can not connect to Instance Manager " .
+ "in $IM_CONNECT_TIMEOUT seconds after start.");
+ }
+
+ # Wait until we can connect to guarded mysqld-instances
+ # (in other words -- wait for IM to start guarded instances).
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ my $mysqld= $instance_manager->{'instances'}->[$idx];
+
+ next if exists $mysqld->{'nonguarded'};
+
+ mtr_debug("Waiting for mysqld[$idx] to start...");
+
+ unless (mtr_im_wait_for_mysqld($mysqld, 30, 1))
+ {
+ mtr_debug("Can not connect to mysqld[$idx] " .
+ "in $IM_CONNECT_TIMEOUT seconds after start.");
+ mtr_debug("Aborting test suite...");
+
+ mtr_kill_leftovers();
+
+ mtr_error("Can not connect to mysqld[$idx] " .
+ "in $IM_CONNECT_TIMEOUT seconds after start.");
+ }
+
+ mtr_debug("mysqld[$idx] started.");
+ }
+
+ mtr_debug("Instance Manager started.");
+
+ mtr_im_load_pids($instance_manager);
+}
+
+##############################################################################
+
+sub mtr_im_stop($$) {
+ my $instance_manager= shift;
+ my $where= shift;
+
+ mtr_debug("Stopping Instance Manager...");
+
+ # Try graceful shutdown.
+
+ mtr_im_terminate($instance_manager);
+
+ # Check that all processes died.
+
+ unless (mtr_im_check_alive($instance_manager))
+ {
+ mtr_debug("Instance Manager has been stopped successfully.");
+ mtr_im_cleanup($instance_manager);
+ return 1;
+ }
+
+ # Instance Manager don't want to die. We should kill it.
+
+ mtr_im_errlog("[$where] Instance Manager did not shutdown gracefully.");
+
+ mtr_im_kill($instance_manager);
+
+ # Check again that all IM-related processes have been killed.
+
+ my $im_is_alive= mtr_im_check_alive($instance_manager);
+
+ mtr_im_cleanup($instance_manager);
+
+ if ($im_is_alive)
+ {
+ mtr_error("Can not kill Instance Manager or its children.");
+ return 0;
+ }
+
+ mtr_debug("Instance Manager has been killed successfully.");
+ return 1;
+}
+
+###########################################################################
1;
--- 1.164/mysql-test/mysql-test-run.pl 2006-09-02 07:23:30 +02:00
+++ 1.165/mysql-test/mysql-test-run.pl 2006-09-02 07:23:30 +02:00
@@ -345,7 +345,7 @@ sub snapshot_setup ();
sub executable_setup ();
sub environment_setup ();
sub kill_running_server ();
-sub kill_and_cleanup ();
+sub cleanup_stale_files ();
sub check_ssl_support ();
sub check_running_as_root();
sub check_ndbcluster_support ();
@@ -371,8 +371,6 @@ sub ndb_mgmd_start ($);
sub mysqld_start ($$$);
sub mysqld_arguments ($$$$$);
sub stop_all_servers ();
-sub im_start ($$);
-sub im_stop ($$);
sub run_mysqltest ($);
sub usage ($);
@@ -1653,14 +1651,13 @@ sub kill_running_server () {
mtr_report("Killing Possible Leftover Processes");
mkpath("$opt_vardir/log"); # Needed for mysqladmin log
+
mtr_kill_leftovers();
}
}
-sub kill_and_cleanup () {
-
- kill_running_server ();
+sub cleanup_stale_files () {
mtr_report("Removing Stale Files");
@@ -2219,13 +2216,11 @@ sub run_suite () {
sub initialize_servers () {
if ( ! $glob_use_running_server )
{
- if ( $opt_start_dirty )
- {
- kill_running_server();
- }
- else
+ kill_running_server();
+
+ unless ( $opt_start_dirty )
{
- kill_and_cleanup();
+ cleanup_stale_files();
mysql_install_db();
if ( $opt_force )
{
@@ -2644,10 +2639,9 @@ sub run_testcase ($) {
# Stop Instance Manager if we are processing an IM-test case.
# ----------------------------------------------------------------------
- if ( ! $glob_use_running_server and $tinfo->{'component_id'} eq 'im' and
- $instance_manager->{'pid'} )
+ if ( ! $glob_use_running_server and $tinfo->{'component_id'} eq 'im' )
{
- im_stop($instance_manager, $tinfo->{'name'});
+ mtr_im_stop($instance_manager, $tinfo->{'name'});
}
}
@@ -3184,11 +3178,8 @@ sub stop_all_servers () {
print "Stopping All Servers\n";
- if ( $instance_manager->{'pid'} )
- {
- print "Shutting-down Instance Manager\n";
- im_stop($instance_manager, "stop_all_servers");
- }
+ print "Shutting-down Instance Manager\n";
+ mtr_im_stop($instance_manager, "stop_all_servers");
my %admin_pids; # hash of admin processes that requests shutdown
my @kill_pids; # list of processes to shutdown/kill
@@ -3594,7 +3585,7 @@ sub run_testcase_start_servers($) {
im_create_defaults_file($instance_manager);
- im_start($instance_manager, $tinfo->{im_opts});
+ mtr_im_start($instance_manager, $tinfo->{im_opts});
}
# ----------------------------------------------------------------------
@@ -3657,236 +3648,6 @@ sub run_testcase_start_servers($) {
}
}
}
-
-
-##############################################################################
-#
-# Instance Manager management routines.
-#
-##############################################################################
-
-sub im_start($$) {
- my $instance_manager = shift;
- my $opts = shift;
-
- my $args;
- mtr_init_args(\$args);
- mtr_add_arg($args, "--defaults-file=%s",
- $instance_manager->{'defaults_file'});
-
- if ( $opt_debug )
- {
- mtr_add_arg($args, "--debug=d:t:i:A,%s/log/im.trace",
- $opt_vardir_trace);
- }
-
- foreach my $opt (@{$opts})
- {
- mtr_add_arg($args, $opt);
- }
-
- $instance_manager->{'pid'} =
- mtr_spawn(
- $exe_im, # path to the executable
- $args, # cmd-line args
- '', # stdin
- $instance_manager->{'path_log'}, # stdout
- $instance_manager->{'path_err'}, # stderr
- '', # pid file path (not used)
- { append_log_file => 1 } # append log files
- );
-
- if ( ! $instance_manager->{'pid'} )
- {
- mtr_report('Could not start Instance Manager');
- return;
- }
-
- # Instance Manager can be run in daemon mode. In this case, it creates
- # several processes and the parent process, created by mtr_spawn(), exits just
- # after start. So, we have to obtain Instance Manager PID from the PID file.
-
- if ( ! sleep_until_file_created(
- $instance_manager->{'path_pid'},
- $instance_manager->{'start_timeout'},
- -1)) # real PID is still unknown
- {
- mtr_report("Instance Manager PID file is missing");
- return;
- }
-
- my $pid= mtr_get_pid_from_file($instance_manager->{'path_pid'});
- $instance_manager->{'pid'} = $pid;
- mtr_verbose("im_start: pid: $pid");
-}
-
-
-sub im_stop($$) {
- my $instance_manager = shift;
- my $where = 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.
-
- $instance_manager->{'pid'} =
- 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();
-
- # Try graceful shutdown.
-
- mtr_verbose("Stopping IM-main, pid: $instance_manager->{'pid'}");
- mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10);
-
- # If necessary, wait for angel process to die.
-
- my $pid= $instance_manager->{'angel_pid'};
- if (defined $pid)
- {
- mtr_verbose("Waiting for IM-angel to die, pid: $pid");
-
- my $total_attempts= 10;
-
- for (my $cur_attempt=1; $cur_attempt <= $total_attempts; ++$cur_attempt)
- {
- unless (kill (0, $pid))
- {
- mtr_verbose("IM-angel died.");
- last;
- }
-
- sleep(1);
- }
- }
-
- # Check if all processes shutdown cleanly
- my $clean_shutdown= 0;
-
- while (1)
- {
- # Check that IM-main died.
-
- if (kill (0, $instance_manager->{'pid'}))
- {
- mtr_debug("IM-main is still alive.");
- last;
- }
-
- # Check that IM-angel died.
-
- if (defined $instance_manager->{'angel_pid'} &&
- kill (0, $instance_manager->{'angel_pid'}))
- {
- mtr_debug("IM-angel is still alive.");
- last;
- }
-
- # Check that all guarded mysqld-instances died.
-
- my $guarded_mysqlds_dead= 1;
-
- foreach my $pid (@mysqld_pids)
- {
- if (kill (0, $pid))
- {
- mtr_debug("Guarded mysqld ($pid) is still alive.");
- $guarded_mysqlds_dead= 0;
- last;
- }
- }
-
- last unless $guarded_mysqlds_dead;
-
- # Ok, all necessary processes are dead.
-
- $clean_shutdown= 1;
- last;
- }
-
- # Kill leftovers (the order is important).
-
- if ($clean_shutdown)
- {
- mtr_debug("IM-shutdown was clean -- all processed died.");
- }
- else
- {
- mtr_debug("IM failed to shutdown gracefully. We have to clean the mess...");
- }
-
- unless ($clean_shutdown)
- {
-
- if (defined $instance_manager->{'angel_pid'})
- {
- mtr_verbose("Killing IM-angel, pid: $instance_manager->{'angel_pid'}");
- mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10)
- }
-
- mtr_verbose("Killing IM-main, pid: $instance_manager->{'pid'}");
- mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10);
-
- # 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_verbose("Killing guarded mysqld(s) " . join(" ", @mysqld_pids));
- mtr_kill_processes(\@mysqld_pids);
-
- # Complain in error log so that a warning will be shown.
- #
- # TODO: unless BUG#20761 is fixed, we will print the warning
- # to stdout, so that it can be seen on console and does not
- # produce pushbuild error.
-
- # 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;
-
- my $ts= localtime();
- print "[$where] Warning: [$ts] Instance Manager did not shutdown gracefully.\n";
- }
-
- # That's all.
-
- stop_reap_all();
-
- $instance_manager->{'pid'} = undef;
- $instance_manager->{'angel_pid'} = undef;
-}
-
#
# Run include/check-testcase.test
--- 1.194/mysql-test/t/disabled.def 2006-09-02 07:23:30 +02:00
+++ 1.195/mysql-test/t/disabled.def 2006-09-02 07:23:30 +02:00
@@ -32,7 +32,6 @@ rpl_ndb_innodb2ndb : Bug #19710 C
#rpl_ndb_log : BUG#18947 2006-03-21 tomas CRBR: order in binlog of create
table and insert (on different table) not determ
rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fails on
DELETE FROM statement
rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly
-rpl_row_func003 : BUG#19074 2006-13-04 andrei test failed
rpl_sp : BUG#16456 2006-02-16 jmiller
rpl_sp_effects : BUG#19862 2006-06-15 mkindahl
--- 1.58/mysql-test/r/grant.result 2006-09-02 07:23:31 +02:00
+++ 1.59/mysql-test/r/grant.result 2006-09-02 07:23:31 +02:00
@@ -945,6 +945,31 @@ DROP TABLE mysqltest3.t_nn;
DROP DATABASE mysqltest3;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
DROP USER 'mysqltest_1'@'localhost';
+use test;
create user mysqltest1_thisisreallytoolong;
-ERROR HY000: Operation CREATE USER failed for 'mysqltest1_thisisreallytoolong'@'%'
+ERROR HY000: String 'mysqltest1_thisisreallytoolong' is too long for user name (should be
no longer than 16)
+GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no
longer than 16)
+GRANT CREATE ON mysqltest.* TO
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY'
is too long for host name (should be no longer than 60)
+REVOKE CREATE ON mysqltest.* FROM 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no
longer than 16)
+REVOKE CREATE ON mysqltest.* FROM
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY'
is too long for host name (should be no longer than 60)
+GRANT CREATE ON t1 TO 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no
longer than 16)
+GRANT CREATE ON t1 TO
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY'
is too long for host name (should be no longer than 60)
+REVOKE CREATE ON t1 FROM 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no
longer than 16)
+REVOKE CREATE ON t1 FROM
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY'
is too long for host name (should be no longer than 60)
+GRANT EXECUTE ON PROCEDURE p1 TO 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no
longer than 16)
+GRANT EXECUTE ON PROCEDURE p1 TO
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY'
is too long for host name (should be no longer than 60)
+REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no
longer than 16)
+REVOKE EXECUTE ON PROCEDURE t1 FROM
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY'
is too long for host name (should be no longer than 60)
End of 5.0 tests
--- 1.45/mysql-test/t/grant.test 2006-09-02 07:23:31 +02:00
+++ 1.46/mysql-test/t/grant.test 2006-09-02 07:23:31 +02:00
@@ -807,12 +807,62 @@ DROP DATABASE mysqltest3;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
DROP USER 'mysqltest_1'@'localhost';
-
+# restore the original database
+use test;
#
# Bug #10668: CREATE USER does not enforce username length limit
#
---error ER_CANNOT_USER
+--error ER_WRONG_STRING_LENGTH
create user mysqltest1_thisisreallytoolong;
+#
+# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+#
+# These checks are intended to ensure that appropriate errors are risen when
+# illegal user name or hostname is specified in user-clause of GRANT/REVOKE
+# statements.
+#
+
+# Working with database-level privileges.
+
+--error ER_WRONG_STRING_LENGTH
+GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+GRANT CREATE ON mysqltest.* TO
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE CREATE ON mysqltest.* FROM 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE CREATE ON mysqltest.* FROM
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+# Working with table-level privileges.
+
+--error ER_WRONG_STRING_LENGTH
+GRANT CREATE ON t1 TO 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+GRANT CREATE ON t1 TO
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE CREATE ON t1 FROM 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE CREATE ON t1 FROM
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+# Working with routine-level privileges.
+
+--error ER_WRONG_STRING_LENGTH
+GRANT EXECUTE ON PROCEDURE p1 TO 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+GRANT EXECUTE ON PROCEDURE p1 TO
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE EXECUTE ON PROCEDURE t1 FROM
some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
--echo End of 5.0 tests
--- 1.55/mysql-test/r/partition.result 2006-09-02 07:23:31 +02:00
+++ 1.56/mysql-test/r/partition.result 2006-09-02 07:23:31 +02:00
@@ -1134,12 +1134,12 @@ partition by range (a)
subpartition by hash (a)
(partition p0 VALUES LESS THAN (1) DATA DIRECTORY = 'hello/master-data/tmpdata' INDEX
DIRECTORY = 'hello/master-data/tmpinx'
(SUBPARTITION subpart00, SUBPARTITION subpart01));
+hello/master-data/test/t1.frm
+hello/master-data/test/t1.par
hello/master-data/test/t1#P#p0#SP#subpart00.MYD
hello/master-data/test/t1#P#p0#SP#subpart00.MYI
hello/master-data/test/t1#P#p0#SP#subpart01.MYD
hello/master-data/test/t1#P#p0#SP#subpart01.MYI
-hello/master-data/test/t1.frm
-hello/master-data/test/t1.par
hello/master-data/tmpdata/t1#P#p0#SP#subpart00.MYD
hello/master-data/tmpdata/t1#P#p0#SP#subpart01.MYD
hello/master-data/tmpinx/t1#P#p0#SP#subpart00.MYI
@@ -1149,6 +1149,8 @@ ALTER TABLE t1 REORGANIZE PARTITION p0 I
(SUBPARTITION subpart10, SUBPARTITION subpart11),
partition p2 VALUES LESS THAN (2) DATA DIRECTORY = 'hello/master-data/tmpdata' INDEX
DIRECTORY = 'hello/master-data/tmpinx'
(SUBPARTITION subpart20, SUBPARTITION subpart21));
+hello/master-data/test/t1.frm
+hello/master-data/test/t1.par
hello/master-data/test/t1#P#p1#SP#subpart10.MYD
hello/master-data/test/t1#P#p1#SP#subpart10.MYI
hello/master-data/test/t1#P#p1#SP#subpart11.MYD
@@ -1157,8 +1159,6 @@ hello/master-data/test/t1#P#p2#SP#subpar
hello/master-data/test/t1#P#p2#SP#subpart20.MYI
hello/master-data/test/t1#P#p2#SP#subpart21.MYD
hello/master-data/test/t1#P#p2#SP#subpart21.MYI
-hello/master-data/test/t1.frm
-hello/master-data/test/t1.par
hello/master-data/tmpdata/t1#P#p1#SP#subpart10.MYD
hello/master-data/tmpdata/t1#P#p1#SP#subpart11.MYD
hello/master-data/tmpdata/t1#P#p2#SP#subpart20.MYD
--- 1.15/BUILD/check-cpu 2006-09-02 07:23:31 +02:00
+++ 1.16/BUILD/check-cpu 2006-09-02 07:23:31 +02:00
@@ -3,213 +3,216 @@
# Check cpu of current machine and find the
# best compiler optimization flags for gcc
#
-#
-if test -r /proc/cpuinfo ; then
- # on Linux (and others?) we can get detailed CPU information out of /proc
- cpuinfo="cat /proc/cpuinfo"
-
- # detect CPU family
- cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
- if test -z "$cpu_family" ; then
- cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
- fi
+check_cpu () {
+ if test -r /proc/cpuinfo ; then
+ # on Linux (and others?) we can get detailed CPU information out of /proc
+ cpuinfo="cat /proc/cpuinfo"
+
+ # detect CPU family
+ cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
+ if test -z "$cpu_family" ; then
+ cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
+ fi
- # detect CPU vendor and model
- cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
- model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
- if test -z "$model_name" ; then
- model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1`
- fi
+ # detect CPU vendor and model
+ cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head
-1`
+ model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
+ if test -z "$model_name" ; then
+ model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1`
+ fi
- # fallback: get CPU model from uname output
- if test -z "$model_name" ; then
- model_name=`uname -m`
+ # fallback: get CPU model from uname output
+ if test -z "$model_name" ; then
+ model_name=`uname -m`
+ fi
+
+ # parse CPU flags
+ for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //'`; do
+ eval cpu_flag_$flag=yes
+ done
+ else
+ # Fallback when there is no /proc/cpuinfo
+ case "`uname -s`" in
+ FreeBSD|OpenBSD)
+ cpu_family=`uname -m`;
+ model_name=`sysctl -n hw.model`
+ ;;
+ Darwin)
+ cpu_family=`uname -p`
+ model_name=`machine`
+ ;;
+ *)
+ cpu_family=`uname -m`;
+ model_name=`uname -p`;
+ ;;
+ esac
fi
- # parse CPU flags
- for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //'`; do
- eval cpu_flag_$flag=yes
- done
-else
- # Fallback when there is no /proc/cpuinfo
- case "`uname -s`" in
- FreeBSD|OpenBSD)
- cpu_family=`uname -m`;
- model_name=`sysctl -n hw.model`
- ;;
- Darwin)
- cpu_family=`uname -p`
- model_name=`machine`
- ;;
- *)
- cpu_family=`uname -m`;
- model_name=`uname -p`;
+ # detect CPU shortname as used by gcc options
+ # this list is not complete, feel free to add further entries
+ cpu_arg=""
+ case "$cpu_family--$model_name" in
+ # DEC Alpha
+ Alpha*EV6*)
+ cpu_arg="ev6";
;;
- esac
-fi
-# detect CPU shortname as used by gcc options
-# this list is not complete, feel free to add further entries
-cpu_arg=""
-case "$cpu_family--$model_name" in
- # DEC Alpha
- Alpha*EV6*)
- cpu_arg="ev6";
+ # Intel ia32
+ *X[eE][oO][nN]*)
+ # a Xeon is just another pentium4 ...
+ # ... unless it has the "lm" (long-mode) flag set,
+ # in that case it's a Xeon with EM64T support
+ if [ -z "$cpu_flag_lm" ]; then
+ cpu_arg="pentium4";
+ else
+ cpu_arg="nocona";
+ fi
+ ;;
+ *Pentium*4*Mobile*)
+ cpu_arg="pentium4m";
;;
-
- # Intel ia32
- *X[eE][oO][nN]*)
- # a Xeon is just another pentium4 ...
- # ... unless it has the "lm" (long-mode) flag set,
- # in that case it's a Xeon with EM64T support
- if [ -z "$cpu_flag_lm" ]; then
+ *Pentium*4*)
cpu_arg="pentium4";
- else
- cpu_arg="nocona";
- fi
- ;;
- *Pentium*4*Mobile*)
- cpu_arg="pentium4m";
- ;;
- *Pentium*4*)
- cpu_arg="pentium4";
- ;;
- *Pentium*III*Mobile*)
- cpu_arg="pentium3m";
- ;;
- *Pentium*III*)
- cpu_arg="pentium3";
- ;;
- *Pentium*M*pro*)
- cpu_arg="pentium-m";
- ;;
- *Athlon*64*)
- cpu_arg="athlon64";
- ;;
- *Athlon*)
- cpu_arg="athlon";
+ ;;
+ *Pentium*III*Mobile*)
+ cpu_arg="pentium3m";
;;
- *Opteron*)
- cpu_arg="opteron";
+ *Pentium*III*)
+ cpu_arg="pentium3";
;;
- # MacOSX / Intel
- *i386*i486*)
- cpu_arg="pentium-m";
+ *Pentium*M*pro*)
+ cpu_arg="pentium-m";
;;
+ *Athlon*64*)
+ cpu_arg="athlon64";
+ ;;
+ *Athlon*)
+ cpu_arg="athlon";
+ ;;
+ *Opteron*)
+ cpu_arg="opteron";
+ ;;
+ # MacOSX / Intel
+ *i386*i486*)
+ cpu_arg="pentium-m";
+ ;;
- # Intel ia64
- *Itanium*)
- # Don't need to set any flags for itanium(at the moment)
- cpu_arg="";
- ;;
+ # Intel ia64
+ *Itanium*)
+ # Don't need to set any flags for itanium(at the moment)
+ cpu_arg="";
+ ;;
- #
- *ppc*)
- cpu_arg='powerpc'
- ;;
-
- *powerpc*)
- cpu_arg='powerpc'
- ;;
+ #
+ *ppc*)
+ cpu_arg='powerpc'
+ ;;
+
+ *powerpc*)
+ cpu_arg='powerpc'
+ ;;
- # unknown
- *)
- cpu_arg="";
- ;;
-esac
+ # unknown
+ *)
+ cpu_arg="";
+ ;;
+ esac
-if test -z "$cpu_arg"; then
- echo "BUILD/check-cpu: Oops, could not find out what kind of cpu this machine is
using."
- check_cpu_cflags=""
- return
-fi
-
-# different compiler versions have different option names
-# for CPU specific command line options
-if test -z "$CC" ; then
- cc="gcc";
-else
- cc=$CC
-fi
-
-cc_ver=`$cc --version | sed 1q`
-cc_verno=`echo $cc_ver | sed -e 's/^.*gcc/gcc/g; s/[^0-9. ]//g; s/^ *//g; s/ .*//g'`
-
-case "$cc_ver--$cc_verno" in
- *GCC*)
- # different gcc backends (and versions) have different CPU flags
- case `gcc -dumpmachine` in
- i?86-*)
- case "$cc_verno" in
- 3.4*|3.5*|4.*)
- check_cpu_args='-mtune=$cpu_arg -march=$cpu_arg'
- ;;
- *)
- check_cpu_args='-mcpu=$cpu_arg -march=$cpu_arg'
- ;;
- esac
- ;;
- ppc-*)
- check_cpu_args='-mcpu=$cpu_arg -mtune=$cpu_arg'
- ;;
- x86_64-*)
- check_cpu_args='-mtune=$cpu_arg'
- ;;
- *)
- check_cpu_cflags=""
- return
- ;;
- esac
- ;;
- 2.95.*)
- # GCC 2.95 doesn't expose its name in --version output
- check_cpu_args='-m$cpu_arg'
- ;;
- *)
+ if test -z "$cpu_arg"; then
+ echo "BUILD/check-cpu: Oops, could not find out what kind of cpu this machine is
using." >&2
check_cpu_cflags=""
return
- ;;
-esac
-
-# now we check whether the compiler really understands the cpu type
-touch __test.c
+ fi
-while [ "$cpu_arg" ] ; do
- echo -n testing $cpu_arg "... "
-
- # compile check
- check_cpu_cflags=`eval echo $check_cpu_args`
- if $cc -c $check_cpu_cflags __test.c 2>/dev/null; then
- echo ok
- break;
+ # different compiler versions have different option names
+ # for CPU specific command line options
+ if test -z "$CC" ; then
+ cc="gcc";
+ else
+ cc=$CC
fi
- echo failed
- check_cpu_cflags=""
+ cc_ver=`$cc --version | sed 1q`
+ cc_verno=`echo $cc_ver | sed -e 's/^.*gcc/gcc/g; s/[^0-9. ]//g; s/^ *//g; s/ .*//g'`
- # if compile failed: check whether it supports a predecessor of this CPU
- # this list is not complete, feel free to add further entries
- case "$cpu_arg" in
- # Intel ia32
- nocona) cpu_arg=pentium4 ;;
- prescott) cpu_arg=pentium4 ;;
- pentium4m) cpu_arg=pentium4 ;;
- pentium4) cpu_arg=pentium3 ;;
- pentium3m) cpu_arg=pentium3 ;;
- pentium3) cpu_arg=pentium2 ;;
- pentium2) cpu_arg=pentiumpro ;;
- pentiumpro) cpu_arg=pentium ;;
- pentium) cpu_arg=i486 ;;
- i486) cpu_arg=i386 ;;
+ case "$cc_ver--$cc_verno" in
+ *GCC*)
+ # different gcc backends (and versions) have different CPU flags
+ case `gcc -dumpmachine` in
+ i?86-*)
+ case "$cc_verno" in
+ 3.4*|3.5*|4.*)
+ check_cpu_args='-mtune=$cpu_arg -march=$cpu_arg'
+ ;;
+ *)
+ check_cpu_args='-mcpu=$cpu_arg -march=$cpu_arg'
+ ;;
+ esac
+ ;;
+ ppc-*)
+ check_cpu_args='-mcpu=$cpu_arg -mtune=$cpu_arg'
+ ;;
+ x86_64-*)
+ check_cpu_args='-mtune=$cpu_arg'
+ ;;
+ *)
+ check_cpu_cflags=""
+ return
+ ;;
+ esac
+ ;;
+ 2.95.*)
+ # GCC 2.95 doesn't expose its name in --version output
+ check_cpu_args='-m$cpu_arg'
+ ;;
+ *)
+ check_cpu_cflags=""
+ return
+ ;;
+ esac
- # power / powerPC
- 7450) cpu_arg=7400 ;;
+ # now we check whether the compiler really understands the cpu type
+ touch __test.c
- *) cpu_arg="" ;;
- esac
-done
+ while [ "$cpu_arg" ] ; do
+ # FIXME: echo -n isn't portable - see contortions autoconf goes through
+ echo -n testing $cpu_arg "... " >&2
+
+ # compile check
+ check_cpu_cflags=`eval echo $check_cpu_args`
+ if $cc -c $check_cpu_cflags __test.c 2>/dev/null; then
+ echo ok >&2
+ break;
+ fi
-rm __test.*
+ echo failed >&2
+ check_cpu_cflags=""
+
+ # if compile failed: check whether it supports a predecessor of this CPU
+ # this list is not complete, feel free to add further entries
+ case "$cpu_arg" in
+ # Intel ia32
+ nocona) cpu_arg=pentium4 ;;
+ prescott) cpu_arg=pentium4 ;;
+ pentium4m) cpu_arg=pentium4 ;;
+ pentium4) cpu_arg=pentium3 ;;
+ pentium3m) cpu_arg=pentium3 ;;
+ pentium3) cpu_arg=pentium2 ;;
+ pentium2) cpu_arg=pentiumpro ;;
+ pentiumpro) cpu_arg=pentium ;;
+ pentium) cpu_arg=i486 ;;
+ i486) cpu_arg=i386 ;;
+
+ # power / powerPC
+ 7450) cpu_arg=7400 ;;
+ *) cpu_arg="" ;;
+ esac
+ done
+
+ rm __test.*
+}
+
+check_cpu
| Thread |
|---|
| • bk commit into 5.1 tree (tsmith:1.2306) | tim | 2 Sep |