Commit b99dc409 authored by unknown's avatar unknown

Merge akishkin@work.mysql.com:/home/bk/mysql-4.0

into mysql.com:/home/walrus/bk/40
parents 0ae40871 14620f86
#!@PERL@ #!@PERL@
# -*- perl -*-
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
# #
# This library is free software; you can redistribute it and/or # This library is free software; you can redistribute it and/or
...@@ -68,6 +69,10 @@ usage() if ($opt_help || $opt_Information); ...@@ -68,6 +69,10 @@ usage() if ($opt_help || $opt_Information);
$opt_suffix = '-'.$opt_suffix if (length($opt_suffix) != 0); $opt_suffix = '-'.$opt_suffix if (length($opt_suffix) != 0);
$opt_config_file = "$pwd/$opt_dir/$opt_server$opt_suffix.cfg" if (length($opt_config_file) == 0); $opt_config_file = "$pwd/$opt_dir/$opt_server$opt_suffix.cfg" if (length($opt_config_file) == 0);
$log_prefix=' ###'; # prefix for log lines in result file
$safe_query_log='';
$safe_query_result_log='';
$log{"crash-me"}="";
#!!! #!!!
...@@ -167,11 +172,11 @@ $prompt="drop table require cascade/restrict"; ...@@ -167,11 +172,11 @@ $prompt="drop table require cascade/restrict";
$drop_attr=""; $drop_attr="";
$dbh->do("drop table crash_me"); $dbh->do("drop table crash_me");
$dbh->do("drop table crash_me cascade"); $dbh->do("drop table crash_me cascade");
if (!safe_query(["create table crash_me (a integer not null)", if (!safe_query_l('drop_requires_cascade',["create table crash_me (a integer not null)",
"drop table crash_me"])) "drop table crash_me"]))
{ {
$dbh->do("drop table crash_me cascade"); $dbh->do("drop table crash_me cascade");
if (safe_query(["create table crash_me (a integer not null)", if (safe_query_l('drop_requires_cascade',["create table crash_me (a integer not null)",
"drop table crash_me cascade"])) "drop table crash_me cascade"]))
{ {
save_config_data('drop_requires_cascade',"yes","$prompt"); save_config_data('drop_requires_cascade',"yes","$prompt");
...@@ -196,10 +201,10 @@ $dbh->do("drop table crash_q $drop_attr"); ...@@ -196,10 +201,10 @@ $dbh->do("drop table crash_q $drop_attr");
$dbh->do("drop table crash_q1 $drop_attr"); $dbh->do("drop table crash_q1 $drop_attr");
$prompt="Tables without primary key"; $prompt="Tables without primary key";
if (!safe_query(["create table crash_me (a integer not null,b char(10) not null)", if (!safe_query_l('no_primary_key',["create table crash_me (a integer not null,b char(10) not null)",
"insert into crash_me (a,b) values (1,'a')"])) "insert into crash_me (a,b) values (1,'a')"]))
{ {
if (!safe_query(["create table crash_me (a integer not null,b char(10) not null, primary key (a))", if (!safe_query_l('no_primary_key',["create table crash_me (a integer not null,b char(10) not null, primary key (a))",
"insert into crash_me (a,b) values (1,'a')"])) "insert into crash_me (a,b) values (1,'a')"]))
{ {
die "Can't create table 'crash_me' with one record: $DBI::errstr\n"; die "Can't create table 'crash_me' with one record: $DBI::errstr\n";
...@@ -421,9 +426,9 @@ check_and_report("Group on column with null values",'group_by_null', ...@@ -421,9 +426,9 @@ check_and_report("Group on column with null values",'group_by_null',
$prompt="Having"; $prompt="Having";
if (!defined($limits{'having'})) if (!defined($limits{'having'}))
{ # Complicated because of postgreSQL { # Complicated because of postgreSQL
if (!safe_query_result("select a from crash_me group by a having a > 0",1,0)) if (!safe_query_result_l("having","select a from crash_me group by a having a > 0",1,0))
{ {
if (!safe_query_result("select a from crash_me group by a having a < 0", if (!safe_query_result_l("having","select a from crash_me group by a having a < 0",
1,0)) 1,0))
{ save_config_data("having","error",$prompt); } { save_config_data("having","error",$prompt); }
else else
...@@ -465,7 +470,7 @@ $logical_value= $limits{'logical_value'}; ...@@ -465,7 +470,7 @@ $logical_value= $limits{'logical_value'};
$false=0; $false=0;
$result="no"; $result="no";
if ($res=safe_query("select (1=1)=true $end_query")) { if ($res=safe_query_l('has_true_false',"select (1=1)=true $end_query")) {
$false="false"; $false="false";
$result="yes"; $result="yes";
} }
...@@ -730,33 +735,33 @@ if (($limits{'type_extra_float(2_arg)'} eq "yes" || ...@@ -730,33 +735,33 @@ if (($limits{'type_extra_float(2_arg)'} eq "yes" ||
my $type=$limits{'type_extra_float(2_arg)'} eq "yes" ? "float(4,1)" : my $type=$limits{'type_extra_float(2_arg)'} eq "yes" ? "float(4,1)" :
"decimal(4,1)"; "decimal(4,1)";
my $result="undefined"; my $result="undefined";
if (execute_and_check(["create table crash_q (q1 $type)", if (execute_and_check("storage_of_float",["create table crash_q (q1 $type)",
"insert into crash_q values(1.14)"], "insert into crash_q values(1.14)"],
"select q1 from crash_q", "select q1 from crash_q",
["drop table crash_q $drop_attr"],1.1,0) && ["drop table crash_q $drop_attr"],1.1,0) &&
execute_and_check(["create table crash_q (q1 $type)", execute_and_check("storage_of_float",["create table crash_q (q1 $type)",
"insert into crash_q values(1.16)"], "insert into crash_q values(1.16)"],
"select q1 from crash_q", "select q1 from crash_q",
["drop table crash_q $drop_attr"],1.1,0)) ["drop table crash_q $drop_attr"],1.1,0))
{ {
$result="truncate"; $result="truncate";
} }
elsif (execute_and_check(["create table crash_q (q1 $type)", elsif (execute_and_check("storage_of_float",["create table crash_q (q1 $type)",
"insert into crash_q values(1.14)"], "insert into crash_q values(1.14)"],
"select q1 from crash_q", "select q1 from crash_q",
["drop table crash_q $drop_attr"],1.1,0) && ["drop table crash_q $drop_attr"],1.1,0) &&
execute_and_check(["create table crash_q (q1 $type)", execute_and_check("storage_of_float",["create table crash_q (q1 $type)",
"insert into crash_q values(1.16)"], "insert into crash_q values(1.16)"],
"select q1 from crash_q", "select q1 from crash_q",
["drop table crash_q $drop_attr"],1.2,0)) ["drop table crash_q $drop_attr"],1.2,0))
{ {
$result="round"; $result="round";
} }
elsif (execute_and_check(["create table crash_q (q1 $type)", elsif (execute_and_check("storage_of_float",["create table crash_q (q1 $type)",
"insert into crash_q values(1.14)"], "insert into crash_q values(1.14)"],
"select q1 from crash_q", "select q1 from crash_q",
["drop table crash_q $drop_attr"],1.14,0) && ["drop table crash_q $drop_attr"],1.14,0) &&
execute_and_check(["create table crash_q (q1 $type)", execute_and_check("storage_of_float",["create table crash_q (q1 $type)",
"insert into crash_q values(1.16)"], "insert into crash_q values(1.16)"],
"select q1 from crash_q", "select q1 from crash_q",
["drop table crash_q $drop_attr"],1.16,0)) ["drop table crash_q $drop_attr"],1.16,0))
...@@ -1202,6 +1207,7 @@ if ($limits{'functions'} eq 'yes') ...@@ -1202,6 +1207,7 @@ if ($limits{'functions'} eq 'yes')
"select $tmp $end_query",[], undef(),4); "select $tmp $end_query",[], undef(),4);
} }
$prompt="Need to cast NULL for arithmetic"; $prompt="Need to cast NULL for arithmetic";
add_log("Need_cast_for_null"," Check if numeric_null ($numeric_null) is 'NULL'");
save_config_data("Need_cast_for_null", save_config_data("Need_cast_for_null",
($numeric_null eq "NULL") ? "no" : "yes", ($numeric_null eq "NULL") ? "no" : "yes",
$prompt); $prompt);
...@@ -1220,15 +1226,15 @@ else ...@@ -1220,15 +1226,15 @@ else
save_incomplete('func_extra_noround','Function NOROUND'); save_incomplete('func_extra_noround','Function NOROUND');
# 1) check if noround() function is supported # 1) check if noround() function is supported
$error = safe_query("select noround(22.6) $end_query"); $error = safe_query_l('func_extra_noround',"select noround(22.6) $end_query");
if ($error ne 1) # syntax error -- noround is not supported if ($error ne 1) # syntax error -- noround is not supported
{ {
$resultat = 'no' $resultat = 'no'
} else # Ok, now check if it really works } else # Ok, now check if it really works
{ {
$error=safe_query( "create table crash_me_nr (a int)", $error=safe_query_l('func_extra_noround', [ "create table crash_me_nr (a int)",
"insert into crash_me_nr values(noround(10.2))", "insert into crash_me_nr values(noround(10.2))",
"drop table crash_me_nr $drop_attr"); "drop table crash_me_nr $drop_attr"]);
if ($error eq 1) { if ($error eq 1) {
$resultat = "syntax only"; $resultat = "syntax only";
} else { } else {
...@@ -1246,26 +1252,23 @@ check_parenthesis("func_sql_","USER"); ...@@ -1246,26 +1252,23 @@ check_parenthesis("func_sql_","USER");
# Test: WEEK() # Test: WEEK()
{ {
my $explain="";
my $resultat="no"; my $resultat="no";
my $error; my $error;
print "WEEK:"; print "WEEK:";
save_incomplete('func_odbc_week','WEEK'); save_incomplete('func_odbc_week','WEEK');
$error = safe_query_result("select week(DATE '1997-02-01') $end_query",5,0); $error = safe_query_result_l('func_odbc_week',"select week(DATE '1997-02-01') $end_query",5,0);
# actually this query must return 4 or 5 in the $last_result, # actually this query must return 4 or 5 in the $last_result,
# $error can be 1 (not supported at all) , -1 ( probably USA weeks) # $error can be 1 (not supported at all) , -1 ( probably USA weeks)
# and 0 - EURO weeks # and 0 - EURO weeks
if ($error == -1) { if ($error == -1) {
if ($last_result == 4) { if ($last_result == 4) {
$resultat = 'USA'; $resultat = 'USA';
$explain = ' started from Sunday';
} else { } else {
$resultat='error'; $resultat='error';
$explain = " must return 4 or 5, but $last_error"; add_log('func_odbc_week'," must return 4 or 5, but $last_result");
} }
} elsif ($error == 0) { } elsif ($error == 0) {
$resultat = 'EURO'; $resultat = 'EURO';
$explain = ' started from Monday';
} }
print " $resultat\n"; print " $resultat\n";
save_config_data('func_odbc_week',$resultat,"WEEK $explain"); save_config_data('func_odbc_week',$resultat,"WEEK $explain");
...@@ -1486,27 +1489,27 @@ report("index in create table",'index_in_create', ...@@ -1486,27 +1489,27 @@ report("index in create table",'index_in_create',
# later # later
if (!(defined($limits{'create_index'}) && defined($limits{'drop_index'}))) if (!(defined($limits{'create_index'}) && defined($limits{'drop_index'})))
{ {
if ($res=safe_query("create index crash_q on crash_me (a)")) if ($res=safe_query_l('create_index',"create index crash_q on crash_me (a)"))
{ {
$res="yes"; $res="yes";
$drop_res="yes"; $drop_res="yes";
$end_drop_keyword=""; $end_drop_keyword="";
if (!safe_query("drop index crash_q")) if (!safe_query_l('drop_index',"drop index crash_q"))
{ {
# Can't drop the standard way; Check if mSQL # Can't drop the standard way; Check if mSQL
if (safe_query("drop index crash_q from crash_me")) if (safe_query_l('drop_index',"drop index crash_q from crash_me"))
{ {
$drop_res="with 'FROM'"; # Drop is not ANSI SQL $drop_res="with 'FROM'"; # Drop is not ANSI SQL
$end_drop_keyword="drop index %i from %t"; $end_drop_keyword="drop index %i from %t";
} }
# else check if Access or MySQL # else check if Access or MySQL
elsif (safe_query("drop index crash_q on crash_me")) elsif (safe_query_l('drop_index',"drop index crash_q on crash_me"))
{ {
$drop_res="with 'ON'"; # Drop is not ANSI SQL $drop_res="with 'ON'"; # Drop is not ANSI SQL
$end_drop_keyword="drop index %i on %t"; $end_drop_keyword="drop index %i on %t";
} }
# else check if MS-SQL # else check if MS-SQL
elsif (safe_query("drop index crash_me.crash_q")) elsif (safe_query_l('drop_index',"drop index crash_me.crash_q"))
{ {
$drop_res="with 'table.index'"; # Drop is not ANSI SQL $drop_res="with 'table.index'"; # Drop is not ANSI SQL
$end_drop_keyword="drop index %t.%i"; $end_drop_keyword="drop index %t.%i";
...@@ -1516,7 +1519,7 @@ if (!(defined($limits{'create_index'}) && defined($limits{'drop_index'}))) ...@@ -1516,7 +1519,7 @@ if (!(defined($limits{'create_index'}) && defined($limits{'drop_index'})))
{ {
# Old MySQL 3.21 supports only the create index syntax # Old MySQL 3.21 supports only the create index syntax
# This means that the second create doesn't give an error. # This means that the second create doesn't give an error.
$res=safe_query(["create index crash_q on crash_me (a)", $res=safe_query_l('create_index',["create index crash_q on crash_me (a)",
"create index crash_q on crash_me (a)", "create index crash_q on crash_me (a)",
"drop index crash_q"]); "drop index crash_q"]);
$res= $res ? 'ignored' : 'yes'; $res= $res ? 'ignored' : 'yes';
...@@ -1760,17 +1763,17 @@ report("views","views", ...@@ -1760,17 +1763,17 @@ report("views","views",
save_incomplete('foreign_key','foreign keys'); save_incomplete('foreign_key','foreign keys');
# 1) check if foreign keys are supported # 1) check if foreign keys are supported
safe_query(create_table("crash_me_qf",["a integer not null"], safe_query_l('foreign_key',create_table("crash_me_qf",["a integer not null"],
["primary key (a)"])); ["primary key (a)"]));
$error = safe_query( create_table("crash_me_qf2",["a integer not null", $error = safe_query_l('foreign_key', create_table("crash_me_qf2",["a integer not null",
"foreign key (a) references crash_me_qf (a)"], [])); "foreign key (a) references crash_me_qf (a)"], []));
if ($error eq 1) # OK -- syntax is supported if ($error eq 1) # OK -- syntax is supported
{ {
$resultat = 'error'; $resultat = 'error';
# now check if foreign key really works # now check if foreign key really works
safe_query( "insert into crash_me_qf values (1)"); safe_query_l('foreign_key', "insert into crash_me_qf values (1)");
if (safe_query( "insert into crash_me_qf2 values (2)") eq 1) { if (safe_query_l('foreign_key', "insert into crash_me_qf2 values (2)") eq 1) {
$resultat = 'syntax only'; $resultat = 'syntax only';
} else { } else {
$resultat = 'yes'; $resultat = 'yes';
...@@ -1779,7 +1782,7 @@ report("views","views", ...@@ -1779,7 +1782,7 @@ report("views","views",
} else { } else {
$resultat = "no"; $resultat = "no";
} }
safe_query( "drop table crash_me_qf2 $drop_attr","drop table crash_me_qf $drop_attr"); safe_query_l('foreign_key', "drop table crash_me_qf2 $drop_attr","drop table crash_me_qf $drop_attr");
print "$resultat\n"; print "$resultat\n";
save_config_data('foreign_key',$resultat,"foreign keys"); save_config_data('foreign_key',$resultat,"foreign keys");
} }
...@@ -2056,6 +2059,7 @@ if ($limits{'create_index'} ne 'no') ...@@ -2056,6 +2059,7 @@ if ($limits{'create_index'} ne 'no')
if ($limits{'create_index'} eq 'ignored' || if ($limits{'create_index'} eq 'ignored' ||
$limits{'unique_in_create'} eq 'yes') $limits{'unique_in_create'} eq 'yes')
{ # This should be true { # This should be true
add_log('max_index'," max_unique_index=$limits{'max_unique_index'} ,so max_index must be same");
save_config_data('max_index',$limits{'max_unique_index'},"max index"); save_config_data('max_index',$limits{'max_unique_index'},"max index");
print "indexes: $limits{'max_index'}\n"; print "indexes: $limits{'max_index'}\n";
} }
...@@ -2063,10 +2067,10 @@ if ($limits{'create_index'} ne 'no') ...@@ -2063,10 +2067,10 @@ if ($limits{'create_index'} ne 'no')
{ {
if (!defined($limits{'max_index'})) if (!defined($limits{'max_index'}))
{ {
assert("create table crash_q ($key_definitions)"); safe_query_l('max_index',"create table crash_q ($key_definitions)");
for ($i=1; $i <= min($limits{'max_columns'},$max_keys) ; $i++) for ($i=1; $i <= min($limits{'max_columns'},$max_keys) ; $i++)
{ {
last if (!safe_query("create index crash_q$i on crash_q (q$i)")); last if (!safe_query_l('max_index',"create index crash_q$i on crash_q (q$i)"));
} }
save_config_data('max_index',$i == $max_keys ? $max_keys : $i, save_config_data('max_index',$i == $max_keys ? $max_keys : $i,
"max index"); "max index");
...@@ -2082,10 +2086,10 @@ if ($limits{'create_index'} ne 'no') ...@@ -2082,10 +2086,10 @@ if ($limits{'create_index'} ne 'no')
print "indexs: $limits{'max_index'}\n"; print "indexs: $limits{'max_index'}\n";
if (!defined($limits{'max_unique_index'})) if (!defined($limits{'max_unique_index'}))
{ {
assert("create table crash_q ($key_definitions)"); safe_query_l('max_unique_index',"create table crash_q ($key_definitions)");
for ($i=0; $i < min($limits{'max_columns'},$max_keys) ; $i++) for ($i=0; $i < min($limits{'max_columns'},$max_keys) ; $i++)
{ {
last if (!safe_query("create unique index crash_q$i on crash_q (q$i)")); last if (!safe_query_l('max_unique_index',"create unique index crash_q$i on crash_q (q$i)"));
} }
save_config_data('max_unique_index',$i == $max_keys ? $max_keys : $i, save_config_data('max_unique_index',$i == $max_keys ? $max_keys : $i,
"max unique index"); "max unique index");
...@@ -2101,7 +2105,7 @@ if ($limits{'create_index'} ne 'no') ...@@ -2101,7 +2105,7 @@ if ($limits{'create_index'} ne 'no')
print "unique indexes: $limits{'max_unique_index'}\n"; print "unique indexes: $limits{'max_unique_index'}\n";
if (!defined($limits{'max_index_parts'})) if (!defined($limits{'max_index_parts'}))
{ {
assert("create table crash_q ($key_definitions)"); safe_query_l('max_index_parts',"create table crash_q ($key_definitions)");
$end_drop=$end_drop_keyword; $end_drop=$end_drop_keyword;
$end_drop =~ s/%i/crash_q1%d/; $end_drop =~ s/%i/crash_q1%d/;
$end_drop =~ s/%t/crash_q/; $end_drop =~ s/%t/crash_q/;
...@@ -2182,23 +2186,23 @@ if (!defined($limits{$key})) ...@@ -2182,23 +2186,23 @@ if (!defined($limits{$key}))
{ {
print "$prompt="; print "$prompt=";
save_incomplete($key,$prompt); save_incomplete($key,$prompt);
if (!safe_query($server->create("crash_me_a",["a decimal(10,2)","b decimal(10,2)"]))) if (!safe_query_l($key,$server->create("crash_me_a",["a decimal(10,2)","b decimal(10,2)"])))
{ {
print DBI->errstr(); print DBI->errstr();
die "Can't create table 'crash_me_a' $DBI::errstr\n"; die "Can't create table 'crash_me_a' $DBI::errstr\n";
}; };
if (!safe_query(["insert into crash_me_a (a,b) values (11.4,18.9)"])) if (!safe_query_l($key,["insert into crash_me_a (a,b) values (11.4,18.9)"]))
{ {
die "Can't insert into table 'crash_me_a' a record: $DBI::errstr\n"; die "Can't insert into table 'crash_me_a' a record: $DBI::errstr\n";
}; };
$arithmetic_safe = 'no'; $arithmetic_safe = 'no';
$arithmetic_safe = 'yes' $arithmetic_safe = 'yes'
if ( (safe_query_result('select count(*) from crash_me_a where a+b=30.3',1,0) == 0) if ( (safe_query_result_l($key,'select count(*) from crash_me_a where a+b=30.3',1,0) == 0)
and (safe_query_result('select count(*) from crash_me_a where a+b-30.3 = 0',1,0) == 0) and (safe_query_result_l($key,'select count(*) from crash_me_a where a+b-30.3 = 0',1,0) == 0)
and (safe_query_result('select count(*) from crash_me_a where a+b-30.3 < 0',0,0) == 0) and (safe_query_result_l($key,'select count(*) from crash_me_a where a+b-30.3 < 0',0,0) == 0)
and (safe_query_result('select count(*) from crash_me_a where a+b-30.3 > 0',0,0) == 0) ); and (safe_query_result_l($key,'select count(*) from crash_me_a where a+b-30.3 > 0',0,0) == 0) );
save_config_data($key,$arithmetic_safe,$prompt); save_config_data($key,$arithmetic_safe,$prompt);
print "$arithmetic_safe\n"; print "$arithmetic_safe\n";
assert("drop table crash_me_a $drop_attr"); assert("drop table crash_me_a $drop_attr");
...@@ -2214,11 +2218,12 @@ if (!safe_query($server->create("crash_me_n",["i integer","r integer"]))) ...@@ -2214,11 +2218,12 @@ if (!safe_query($server->create("crash_me_n",["i integer","r integer"])))
print DBI->errstr(); print DBI->errstr();
die "Can't create table 'crash_me_n' $DBI::errstr\n"; die "Can't create table 'crash_me_n' $DBI::errstr\n";
}; };
assert("insert into crash_me_n (i) values(1)");
assert("insert into crash_me_n values(2,2)"); safe_query_l("position_of_null",["insert into crash_me_n (i) values(1)",
assert("insert into crash_me_n values(3,3)"); "insert into crash_me_n values(2,2)",
assert("insert into crash_me_n values(4,4)"); "insert into crash_me_n values(3,3)",
assert("insert into crash_me_n (i) values(5)"); "insert into crash_me_n values(4,4)",
"insert into crash_me_n (i) values(5)"]);
$key = "position_of_null"; $key = "position_of_null";
$prompt ="Where is null values in sorted recordset"; $prompt ="Where is null values in sorted recordset";
...@@ -2228,7 +2233,8 @@ if (!defined($limits{$key})) ...@@ -2228,7 +2233,8 @@ if (!defined($limits{$key}))
print "$prompt="; print "$prompt=";
$sth=$dbh->prepare("select r from crash_me_n order by r "); $sth=$dbh->prepare("select r from crash_me_n order by r ");
$sth->execute; $sth->execute;
$limit= detect_null_position($sth); add_log($key,"< select r from crash_me_n order by r ");
$limit= detect_null_position($key,$sth);
$sth->finish; $sth->finish;
print "$limit\n"; print "$limit\n";
save_config_data($key,$limit,$prompt); save_config_data($key,$limit,$prompt);
...@@ -2244,7 +2250,8 @@ if (!defined($limits{$key})) ...@@ -2244,7 +2250,8 @@ if (!defined($limits{$key}))
print "$prompt="; print "$prompt=";
$sth=$dbh->prepare("select r from crash_me_n order by r desc"); $sth=$dbh->prepare("select r from crash_me_n order by r desc");
$sth->execute; $sth->execute;
$limit= detect_null_position($sth); add_log($key,"< select r from crash_me_n order by r desc");
$limit= detect_null_position($key,$sth);
$sth->finish; $sth->finish;
print "$limit\n"; print "$limit\n";
save_config_data($key,$limit,$prompt); save_config_data($key,$limit,$prompt);
...@@ -2269,18 +2276,31 @@ $dbh->disconnect || warn $dbh->errstr; ...@@ -2269,18 +2276,31 @@ $dbh->disconnect || warn $dbh->errstr;
save_all_config_data(); save_all_config_data();
exit 0; exit 0;
# End of test
#
$dbh->do("drop table crash_me $drop_attr"); # Remove temporary table
print "crash-me safe: $limits{'crash_me_safe'}\n";
print "reconnected $reconnect_count times\n";
$dbh->disconnect || warn $dbh->errstr;
save_all_config_data();
exit 0;
# Check where is nulls in the sorted result (for) # Check where is nulls in the sorted result (for)
# it expects exactly 5 rows in the result # it expects exactly 5 rows in the result
sub detect_null_position sub detect_null_position
{ {
my $key = shift;
my $sth = shift; my $sth = shift;
my ($z,$r1,$r2,$r3,$r4,$r5); my ($z,$r1,$r2,$r3,$r4,$r5);
$r1 = $sth->fetchrow_array; $r1 = $sth->fetchrow_array; add_log($key,"> $r1");
$r2 = $sth->fetchrow_array; $r2 = $sth->fetchrow_array; add_log($key,"> $r2");
$r3 = $sth->fetchrow_array; $r3 = $sth->fetchrow_array; add_log($key,"> $r3");
$r4 = $sth->fetchrow_array; $r4 = $sth->fetchrow_array; add_log($key,"> $r4");
$r5 = $sth->fetchrow_array; $r5 = $sth->fetchrow_array; add_log($key,"> $r5");
return "first" if ( !defined($r1) && !defined($r2) && defined($r3)); return "first" if ( !defined($r1) && !defined($r2) && defined($r3));
return "last" if ( !defined($r5) && !defined($r4) && defined($r3)); return "last" if ( !defined($r5) && !defined($r4) && defined($r3));
return "random"; return "random";
...@@ -2291,16 +2311,24 @@ sub check_parenthesis { ...@@ -2291,16 +2311,24 @@ sub check_parenthesis {
my $fn=shift; my $fn=shift;
my $resultat='no'; my $resultat='no';
my $param_name=$prefix.lc($fn); my $param_name=$prefix.lc($fn);
my $r;
save_incomplete($param_name,$fn); save_incomplete($param_name,$fn);
if (safe_query("select $fn $end_query") == 1) $r = safe_query("select $fn $end_query");
add_log($param_name,$safe_query_log);
if ($r == 1)
{ {
$resultat="yes"; $resultat="yes";
} }
elsif ( safe_query("select $fn() $end_query") == 1) else{
$r = safe_query("select $fn() $end_query");
add_log($param_name,$safe_query_log);
if ( $r == 1)
{ {
$resultat="with_parenthesis"; $resultat="with_parenthesis";
} }
}
save_config_data($param_name,$resultat,$fn); save_config_data($param_name,$resultat,$fn);
} }
...@@ -2313,16 +2341,22 @@ sub check_constraint { ...@@ -2313,16 +2341,22 @@ sub check_constraint {
save_incomplete($key,$prompt); save_incomplete($key,$prompt);
print "$prompt="; print "$prompt=";
my $res = 'no'; my $res = 'no';
my $t;
if ( ($t=safe_query($create)) == 1) $t=safe_query($create);
add_log($key,$safe_query_log);
if ( $t == 1)
{ {
$res='yes'; $res='yes';
if (safe_query($check) == 1) $t= safe_query($check);
add_log($key,$safe_query_log);
if ($t == 1)
{ {
$res='syntax only'; $res='syntax only';
} }
} }
safe_query($drop); safe_query($drop);
add_log($key,$safe_query_log);
save_config_data($key,$res,$prompt); save_config_data($key,$res,$prompt);
print "$res\n"; print "$res\n";
} }
...@@ -2633,6 +2667,15 @@ sub check_connect ...@@ -2633,6 +2667,15 @@ sub check_connect
# #
# print query if debugging # print query if debugging
# #
sub repr_query {
my $query=shift;
if (length($query) > 130)
{
$query=substr($query,0,120) . "...(" . (length($query)-120) . ")";
}
return $query;
}
sub print_query sub print_query
{ {
my ($query)=@_; my ($query)=@_;
...@@ -2652,10 +2695,19 @@ sub print_query ...@@ -2652,10 +2695,19 @@ sub print_query
# Note that all rows are executed (to ensure that we execute drop table commands) # Note that all rows are executed (to ensure that we execute drop table commands)
# #
sub safe_query_l {
my $key = shift;
my $q = shift;
my $r = safe_query($q);
add_log($key,$safe_query_log);
return $r;
}
sub safe_query sub safe_query
{ {
my($queries)=@_; my($queries)=@_;
my($query,$ok,$retry_ok,$retry,@tmp,$sth); my($query,$ok,$retry_ok,$retry,@tmp,$sth);
$safe_query_log="";
$ok=1; $ok=1;
if (ref($queries) ne "ARRAY") if (ref($queries) ne "ARRAY")
{ {
...@@ -2666,9 +2718,11 @@ sub safe_query ...@@ -2666,9 +2718,11 @@ sub safe_query
{ {
printf "query1: %-80.80s ...(%d - %d)\n",$query,length($query),$retry_limit if ($opt_log_all_queries); printf "query1: %-80.80s ...(%d - %d)\n",$query,length($query),$retry_limit if ($opt_log_all_queries);
print LOG "$query;\n" if ($opt_log); print LOG "$query;\n" if ($opt_log);
$safe_query_log .= "< $query\n";
if (length($query) > $query_size) if (length($query) > $query_size)
{ {
$ok=0; $ok=0;
$safe_query_log .= "Query is too long\n";
next; next;
} }
...@@ -2678,6 +2732,7 @@ sub safe_query ...@@ -2678,6 +2732,7 @@ sub safe_query
if (! ($sth=$dbh->prepare($query))) if (! ($sth=$dbh->prepare($query)))
{ {
print_query($query); print_query($query);
$safe_query_log .= "> couldn't prepare:". $dbh->errstr. "\n";
$retry=100 if (!$server->abort_if_fatal_error()); $retry=100 if (!$server->abort_if_fatal_error());
# Force a reconnect because of Access drop table bug! # Force a reconnect because of Access drop table bug!
if ($retry == $retry_limit-2) if ($retry == $retry_limit-2)
...@@ -2692,6 +2747,7 @@ sub safe_query ...@@ -2692,6 +2747,7 @@ sub safe_query
if (!$sth->execute()) if (!$sth->execute())
{ {
print_query($query); print_query($query);
$safe_query_log .= "> execute error:". $dbh->errstr. "\n";
$retry=100 if (!$server->abort_if_fatal_error()); $retry=100 if (!$server->abort_if_fatal_error());
# Force a reconnect because of Access drop table bug! # Force a reconnect because of Access drop table bug!
if ($retry == $retry_limit-2) if ($retry == $retry_limit-2)
...@@ -2705,6 +2761,8 @@ sub safe_query ...@@ -2705,6 +2761,8 @@ sub safe_query
{ {
$retry = $retry_limit; $retry = $retry_limit;
$retry_ok = 1; $retry_ok = 1;
$safe_query_log .= "> OK\n";
} }
$sth->finish; $sth->finish;
} }
...@@ -2912,7 +2970,7 @@ sub check_reserved_words ...@@ -2912,7 +2970,7 @@ sub check_reserved_words
); );
$dbh->do("drop table crash_me10"); safe_query("drop table crash_me10 $drop_attr");
foreach my $keyword (sort {$a cmp $b} keys %reserved_words) foreach my $keyword (sort {$a cmp $b} keys %reserved_words)
{ {
...@@ -2921,24 +2979,10 @@ sub check_reserved_words ...@@ -2921,24 +2979,10 @@ sub check_reserved_words
$prompt= "Keyword ".$keyword; $prompt= "Keyword ".$keyword;
$config= "reserved_word_".$keywords_ext[$keyword_type]."_".lc($keyword); $config= "reserved_word_".$keywords_ext[$keyword_type]."_".lc($keyword);
$dbh->{RaiseError}= 1; report_fail($prompt,$config,
"create table crash_me10 ($keyword int not null)",
$answer= "yes"; "drop table crash_me10 $drop_attr"
);
eval {
$dbh->do("create table crash_me10 ($keyword int not null)");
};
$dbh->{RaiseError}= 0;
if (!$@)
{
$answer= "no";
$dbh->do("drop table crash_me10");
}
save_config_data($config,$answer,$prompt);
print "$prompt: ",$limits{$config},"\n"; print "$prompt: ",$limits{$config},"\n";
} }
} }
...@@ -3002,7 +3046,17 @@ sub report ...@@ -3002,7 +3046,17 @@ sub report
print "$prompt: "; print "$prompt: ";
if (!defined($limits{$limit})) if (!defined($limits{$limit}))
{ {
save_config_data($limit,safe_query(\@queries) ? "yes" : "no",$prompt); my $queries_result = safe_query(\@queries);
add_log($limit, $safe_query_log);
my $report_result;
if ( $queries_result) {
$report_result= "yes";
add_log($limit,"As far as all queries returned OK, result is YES");
} else {
$report_result= "no";
add_log($limit,"As far as some queries didnt return OK, result is NO");
}
save_config_data($limit,$report_result,$prompt);
} }
print "$limits{$limit}\n"; print "$limits{$limit}\n";
return $limits{$limit} ne "no"; return $limits{$limit} ne "no";
...@@ -3014,7 +3068,17 @@ sub report_fail ...@@ -3014,7 +3068,17 @@ sub report_fail
print "$prompt: "; print "$prompt: ";
if (!defined($limits{$limit})) if (!defined($limits{$limit}))
{ {
save_config_data($limit,safe_query(\@queries) ? "no" : "yes",$prompt); my $queries_result = safe_query(\@queries);
add_log($limit, $safe_query_log);
my $report_result;
if ( $queries_result) {
$report_result= "no";
add_log($limit,"As far as all queries returned OK, result is NO");
} else {
$report_result= "yes";
add_log($limit,"As far as some queries didnt return OK, result is YES");
}
save_config_data($limit,$report_result,$prompt);
} }
print "$limits{$limit}\n"; print "$limits{$limit}\n";
return $limits{$limit} ne "no"; return $limits{$limit} ne "no";
...@@ -3034,7 +3098,7 @@ sub report_one ...@@ -3034,7 +3098,7 @@ sub report_one
$result="no"; $result="no";
foreach $query (@$queries) foreach $query (@$queries)
{ {
if (safe_query($query->[0])) if (safe_query_l($limit,$query->[0]))
{ {
$result= $query->[1]; $result= $query->[1];
last; last;
...@@ -3058,6 +3122,7 @@ sub report_result ...@@ -3058,6 +3122,7 @@ sub report_result
{ {
save_incomplete($limit,$prompt); save_incomplete($limit,$prompt);
$error=safe_query_result($query,"1",2); $error=safe_query_result($query,"1",2);
add_log($limit,$safe_query_result_log);
save_config_data($limit,$error ? "not supported" :$last_result,$prompt); save_config_data($limit,$error ? "not supported" :$last_result,$prompt);
} }
print "$limits{$limit}\n"; print "$limits{$limit}\n";
...@@ -3078,16 +3143,19 @@ sub report_trans ...@@ -3078,16 +3143,19 @@ sub report_trans
$dbh->rollback; $dbh->rollback;
$dbh->{AutoCommit} = 1; $dbh->{AutoCommit} = 1;
if (safe_query_result($check,"","")) { if (safe_query_result($check,"","")) {
add_log($limit,$safe_query_result_log);
save_config_data($limit,"yes",$limit); save_config_data($limit,"yes",$limit);
} }
safe_query($clear); safe_query($clear);
} else { } else {
add_log($limit,$safe_query_log);
save_config_data($limit,"error",$limit); save_config_data($limit,"error",$limit);
} }
$dbh->{AutoCommit} = 1; $dbh->{AutoCommit} = 1;
} }
else else
{ {
add_log($limit,"Couldnt undef autocommit ?? ");
save_config_data($limit,"no",$limit); save_config_data($limit,"no",$limit);
} }
safe_query($clear); safe_query($clear);
...@@ -3106,20 +3174,26 @@ sub report_rollback ...@@ -3106,20 +3174,26 @@ sub report_rollback
{ {
if (safe_query(\@$queries)) if (safe_query(\@$queries))
{ {
add_log($limit,$safe_query_log);
$dbh->rollback; $dbh->rollback;
$dbh->{AutoCommit} = 1; $dbh->{AutoCommit} = 1;
if (safe_query($check)) { if (safe_query($check)) {
add_log($limit,$safe_query_log);
save_config_data($limit,"no",$limit); save_config_data($limit,"no",$limit);
} else { } else {
add_log($limit,$safe_query_log);
save_config_data($limit,"yes",$limit); save_config_data($limit,"yes",$limit);
}; };
safe_query($clear); safe_query($clear);
} else { } else {
add_log($limit,$safe_query_log);
save_config_data($limit,"error",$limit); save_config_data($limit,"error",$limit);
} }
} }
else else
{ {
add_log($limit,'Couldnt undef Autocommit??');
save_config_data($limit,"error",$limit); save_config_data($limit,"error",$limit);
} }
safe_query($clear); safe_query($clear);
...@@ -3141,8 +3215,14 @@ sub check_and_report ...@@ -3141,8 +3215,14 @@ sub check_and_report
{ {
save_incomplete($limit,$prompt); save_incomplete($limit,$prompt);
$tmp=1-safe_query(\@$pre); $tmp=1-safe_query(\@$pre);
$tmp=safe_query_result($query,$answer,$string_type) if (!$tmp); add_log($limit,$safe_query_log);
if (!$tmp)
{
$tmp=safe_query_result($query,$answer,$string_type) ;
add_log($limit,$safe_query_result_log);
};
safe_query(\@$post); safe_query(\@$post);
add_log($limit,$safe_query_log);
delete $limits{$limit}; delete $limits{$limit};
if ($function == 3) # Report error as 'no'. if ($function == 3) # Report error as 'no'.
{ {
...@@ -3180,7 +3260,7 @@ sub try_and_report ...@@ -3180,7 +3260,7 @@ sub try_and_report
foreach $test (@tests) foreach $test (@tests)
{ {
my $tmp_type= shift(@$test); my $tmp_type= shift(@$test);
if (safe_query(\@$test)) if (safe_query_l($limit,\@$test))
{ {
$type=$tmp_type; $type=$tmp_type;
goto outer; goto outer;
...@@ -3199,32 +3279,44 @@ sub try_and_report ...@@ -3199,32 +3279,44 @@ sub try_and_report
sub execute_and_check sub execute_and_check
{ {
my ($pre,$query,$post,$answer,$string_type)=@_; my ($key,$pre,$query,$post,$answer,$string_type)=@_;
my ($tmp); my ($tmp);
$tmp=safe_query(\@$pre); $tmp=safe_query_l($key,\@$pre);
$tmp=safe_query_result($query,$answer,$string_type) == 0 if ($tmp);
safe_query(\@$post); $tmp=safe_query_result_l($key,$query,$answer,$string_type) == 0 if ($tmp);
safe_query_l($key,\@$post);
return $tmp; return $tmp;
} }
# returns 0 if ok, 1 if error, -1 if wrong answer # returns 0 if ok, 1 if error, -1 if wrong answer
# Sets $last_result to value of query # Sets $last_result to value of query
sub safe_query_result_l{
my ($key,$query,$answer,$result_type)=@_;
my $r = safe_query_result($query,$answer,$result_type);
add_log($key,$safe_query_result_log);
return $r;
}
sub safe_query_result sub safe_query_result
{ {
my ($query,$answer,$result_type)=@_; my ($query,$answer,$result_type)=@_;
my ($sth,$row,$result,$retry); my ($sth,$row,$result,$retry);
undef($last_result); undef($last_result);
$safe_query_result_log="";
printf "\nquery3: %-80.80s\n",$query if ($opt_log_all_queries); printf "\nquery3: %-80.80s\n",$query if ($opt_log_all_queries);
print LOG "$query;\n" if ($opt_log); print LOG "$query;\n" if ($opt_log);
$safe_query_result_log="<".$query."\n";
for ($retry=0; $retry < $retry_limit ; $retry++) for ($retry=0; $retry < $retry_limit ; $retry++)
{ {
if (!($sth=$dbh->prepare($query))) if (!($sth=$dbh->prepare($query)))
{ {
print_query($query); print_query($query);
$safe_query_result_log .= "> prepare failed:".$dbh->errstr."\n";
if ($server->abort_if_fatal_error()) if ($server->abort_if_fatal_error())
{ {
check_connect(); # Check that server is still up check_connect(); # Check that server is still up
...@@ -3236,6 +3328,7 @@ sub safe_query_result ...@@ -3236,6 +3328,7 @@ sub safe_query_result
if (!$sth->execute) if (!$sth->execute)
{ {
print_query($query); print_query($query);
$safe_query_result_log .= "> execute failed:".$dbh->errstr."\n";
if ($server->abort_if_fatal_error()) if ($server->abort_if_fatal_error())
{ {
check_connect(); # Check that server is still up check_connect(); # Check that server is still up
...@@ -3252,6 +3345,7 @@ sub safe_query_result ...@@ -3252,6 +3345,7 @@ sub safe_query_result
if (!($row=$sth->fetchrow_arrayref)) if (!($row=$sth->fetchrow_arrayref))
{ {
print "\nquery: $query didn't return any result\n" if ($opt_debug); print "\nquery: $query didn't return any result\n" if ($opt_debug);
$safe_query_result_log .= "> didn't return any result:".$dbh->errstr."\n";
$sth->finish; $sth->finish;
return ($result_type == 8) ? 0 : 1; return ($result_type == 8) ? 0 : 1;
} }
...@@ -3262,7 +3356,7 @@ sub safe_query_result ...@@ -3262,7 +3356,7 @@ sub safe_query_result
} }
$result=0; # Ok $result=0; # Ok
$last_result= $row->[0]; # Save for report_result; $last_result= $row->[0]; # Save for report_result;
$safe_query_result_log .= ">".$last_result."\n";
# Note: # Note:
# if ($result_type == 2) We accept any return value as answer # if ($result_type == 2) We accept any return value as answer
...@@ -3273,34 +3367,55 @@ sub safe_query_result ...@@ -3273,34 +3367,55 @@ sub safe_query_result
(abs($row->[0]) + abs($answer))) > 0.01) (abs($row->[0]) + abs($answer))) > 0.01)
{ {
$result=-1; $result=-1;
$safe_query_result_log .= "We expected '$answer' but got '$last_result' \n";
} }
} }
elsif ($result_type == 1) # Compare where end space may differ elsif ($result_type == 1) # Compare where end space may differ
{ {
$row->[0] =~ s/\s+$//; $row->[0] =~ s/\s+$//;
$result=-1 if ($row->[0] ne $answer); if ($row->[0] ne $answer)
{
$result=-1;
$safe_query_result_log .= "We expected '$answer' but got '$last_result' \n";
} ;
} }
elsif ($result_type == 3) # This should be a exact match elsif ($result_type == 3) # This should be a exact match
{ {
$result= -1 if ($row->[0] ne $answer); if ($row->[0] ne $answer)
{
$result= -1;
$safe_query_result_log .= "we expected '$answer' but got '$last_result' \n";
};
} }
elsif ($result_type == 4) # If results should be NULL elsif ($result_type == 4) # If results should be NULL
{ {
$result= -1 if (defined($row->[0])); if (defined($row->[0]))
{
$result= -1;
$safe_query_result_log .= "We expected NULL but got '$last_result' \n";
};
} }
elsif ($result_type == 5) # Result should have given prefix elsif ($result_type == 5) # Result should have given prefix
{ {
$result= -1 if (length($row->[0]) < length($answer) && if (length($row->[0]) < length($answer) &&
substr($row->[0],1,length($answer)) ne $answer); substr($row->[0],1,length($answer)) ne $answer)
{
$result= -1 ;
$safe_query_result_log .= "result must have prefix '$answer', but '$last_result' \n";
};
} }
elsif ($result_type == 6) # Exact match but ignore errors elsif ($result_type == 6) # Exact match but ignore errors
{ {
$result= 1 if ($row->[0] ne $answer); if ($row->[0] ne $answer)
{ $result= 1;
$safe_query_result_log .= "We expected '$answer' but got '$last_result' \n";
} ;
} }
elsif ($result_type == 7) # Compare against array of numbers elsif ($result_type == 7) # Compare against array of numbers
{ {
if ($row->[0] != $answer->[0]) if ($row->[0] != $answer->[0])
{ {
$safe_query_result_log .= "must be '$answer->[0]' \n";
$result= -1; $result= -1;
} }
else else
...@@ -3309,16 +3424,20 @@ sub safe_query_result ...@@ -3309,16 +3424,20 @@ sub safe_query_result
shift @$answer; shift @$answer;
while (($row=$sth->fetchrow_arrayref)) while (($row=$sth->fetchrow_arrayref))
{ {
$safe_query_result_log .= ">$row\n";
$value=shift(@$answer); $value=shift(@$answer);
if (!defined($value)) if (!defined($value))
{ {
print "\nquery: $query returned to many results\n" print "\nquery: $query returned to many results\n"
if ($opt_debug); if ($opt_debug);
$safe_query_result_log .= "It returned to many results \n";
$result= 1; $result= 1;
last; last;
} }
if ($row->[0] != $value) if ($row->[0] != $value)
{ {
$safe_query_result_log .= "Must return $value here \n";
$result= -1; $result= -1;
last; last;
} }
...@@ -3327,6 +3446,7 @@ sub safe_query_result ...@@ -3327,6 +3446,7 @@ sub safe_query_result
{ {
print "\nquery: $query returned too few results\n" print "\nquery: $query returned too few results\n"
if ($opt_debug); if ($opt_debug);
$safe_query_result_log .= "It returned too few results \n";
$result= 1; $result= 1;
} }
} }
...@@ -3345,7 +3465,7 @@ sub safe_query_result ...@@ -3345,7 +3465,7 @@ sub safe_query_result
sub find_limit() sub find_limit()
{ {
my ($prompt,$limit,$query)=@_; my ($prompt,$limit,$query)=@_;
my ($first,$end,$i,$tmp); my ($first,$end,$i,$tmp,@tmp_array, $queries);
print "$prompt: "; print "$prompt: ";
if (defined($end=$limits{$limit})) if (defined($end=$limits{$limit}))
{ {
...@@ -3353,10 +3473,30 @@ sub find_limit() ...@@ -3353,10 +3473,30 @@ sub find_limit()
return $end; return $end;
} }
save_incomplete($limit,$prompt); save_incomplete($limit,$prompt);
add_log($limit,"We are trying (example with N=5):");
$queries = $query->query(5);
if (ref($queries) ne "ARRAY")
{
push(@tmp_array,$queries);
$queries= \@tmp_array;
}
foreach $tmp (@$queries)
{ add_log($limit,repr_query($tmp)); }
if (defined($queries = $query->check_query()))
{
if (ref($queries) ne "ARRAY")
{
@tmp_array=();
push(@tmp_array,$queries);
$queries= \@tmp_array;
}
foreach $tmp (@$queries)
{ add_log($limit,repr_query($tmp)); }
}
if (defined($query->{'init'}) && !defined($end=$limits{'restart'}{'tohigh'})) if (defined($query->{'init'}) && !defined($end=$limits{'restart'}{'tohigh'}))
{ {
if (!safe_query($query->{'init'})) if (!safe_query_l($limit,$query->{'init'}))
{ {
$query->cleanup(); $query->cleanup();
return "error"; return "error";
...@@ -3384,7 +3524,7 @@ sub find_limit() ...@@ -3384,7 +3524,7 @@ sub find_limit()
$end= $query->max_limit(); $end= $query->max_limit();
$i=int(($end+$first)/2); $i=int(($end+$first)/2);
} }
my $log_str = "";
unless(limit_query($query,0+$end)) { unless(limit_query($query,0+$end)) {
while ($first < $end) while ($first < $end)
{ {
...@@ -3393,11 +3533,13 @@ sub find_limit() ...@@ -3393,11 +3533,13 @@ sub find_limit()
if (limit_query($query,$i)) if (limit_query($query,$i))
{ {
$first=$i; $first=$i;
$log_str .= " $i:OK";
$i=$first+int(($end-$first+1)/2); # to be a bit faster to go up $i=$first+int(($end-$first+1)/2); # to be a bit faster to go up
} }
else else
{ {
$end=$i-1; $end=$i-1;
$log_str .= " $i:FAIL";
$i=$first+int(($end-$first+4)/5); # Prefere lower on errors $i=$first+int(($end-$first+4)/5); # Prefere lower on errors
} }
} }
...@@ -3409,6 +3551,7 @@ sub find_limit() ...@@ -3409,6 +3551,7 @@ sub find_limit()
$end= $query->{'max_limit'}; $end= $query->{'max_limit'};
} }
print "$end\n"; print "$end\n";
add_log($limit,$log_str);
save_config_data($limit,$end,$prompt); save_config_data($limit,$end,$prompt);
delete $limits{'restart'}; delete $limits{'restart'};
return $end; return $end;
...@@ -3460,6 +3603,7 @@ sub read_config_data ...@@ -3460,6 +3603,7 @@ sub read_config_data
{ {
$limits{$key}=$limit eq "null"? undef : $limit; $limits{$key}=$limit eq "null"? undef : $limit;
$prompts{$key}=length($prompt) ? substr($prompt,2) : ""; $prompts{$key}=length($prompt) ? substr($prompt,2) : "";
$last_read=$key;
delete $limits{'restart'}; delete $limits{'restart'};
} }
else else
...@@ -3473,6 +3617,11 @@ sub read_config_data ...@@ -3473,6 +3617,11 @@ sub read_config_data
} }
} }
} }
elsif (/\s*###(.*)$/) # log line
{
# add log line for previously read key
$log{$last_read} .= "$1\n";
}
elsif (!/^\s*$/ && !/^\#/) elsif (!/^\s*$/ && !/^\#/)
{ {
die "Wrong config row: $_\n"; die "Wrong config row: $_\n";
...@@ -3494,6 +3643,18 @@ sub save_config_data ...@@ -3494,6 +3643,18 @@ sub save_config_data
print CONFIG_FILE "$key=$limit\t# $prompt\n"; print CONFIG_FILE "$key=$limit\t# $prompt\n";
$limits{$key}=$limit; $limits{$key}=$limit;
$limit_changed=1; $limit_changed=1;
# now write log lines (immediatelly after limits)
my $line;
my $last_line_was_empty=0;
foreach $line (split /\n/, $log{$key})
{
print CONFIG_FILE " ###$line\n"
unless ( ($last_line_was_empty eq 1)
&& ($line =~ /^\s+$/) );
$last_line_was_empty= ($line =~ /^\s+$/)?1:0;
};
if (($opt_restart && $limits{'operating_system'} =~ /windows/i) || if (($opt_restart && $limits{'operating_system'} =~ /windows/i) ||
($limits{'operating_system'} =~ /NT/)) ($limits{'operating_system'} =~ /NT/))
{ {
...@@ -3504,6 +3665,12 @@ sub save_config_data ...@@ -3504,6 +3665,12 @@ sub save_config_data
} }
} }
sub add_log
{
my $key = shift;
my $line = shift;
$log{$key} .= $line . "\n";
}
sub save_all_config_data sub save_all_config_data
{ {
...@@ -3523,6 +3690,16 @@ sub save_all_config_data ...@@ -3523,6 +3690,16 @@ sub save_all_config_data
$tmp="$key=$limits{$key}"; $tmp="$key=$limits{$key}";
print CONFIG_FILE $tmp . ("\t" x (int((32-min(length($tmp),32)+7)/8)+1)) . print CONFIG_FILE $tmp . ("\t" x (int((32-min(length($tmp),32)+7)/8)+1)) .
"# $prompts{$key}\n"; "# $prompts{$key}\n";
my $line;
my $last_line_was_empty=0;
foreach $line (split /\n/, $log{$key})
{
print CONFIG_FILE " ###$line\n"
unless ( ($last_line_was_empty eq 1)
&& ($line =~ /^\s+$/) );
$last_line_was_empty= ($line =~ /^\s+$/)?1:0;
};
} }
close CONFIG_FILE; close CONFIG_FILE;
} }
...@@ -3800,7 +3977,6 @@ sub new ...@@ -3800,7 +3977,6 @@ sub new
bless $self; bless $self;
} }
sub query sub query
{ {
my ($self,$i)=@_; my ($self,$i)=@_;
......
#!@PERL@ #!@PERL@
# -*- perl -*-
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
# #
# This library is free software; you can redistribute it and/or # This library is free software; you can redistribute it and/or
...@@ -671,9 +672,9 @@ sub create ...@@ -671,9 +672,9 @@ sub create
$field =~ s/int\(\d*\)/int/; $field =~ s/int\(\d*\)/int/;
$field =~ s/float\(\d*,\d*\)/float/; $field =~ s/float\(\d*,\d*\)/float/;
$field =~ s/ double/ float/; $field =~ s/ double/ float/;
$field =~ s/ decimal/ float/i; # $field =~ s/ decimal/ float/i;
$field =~ s/ big_decimal/ float/i; # $field =~ s/ big_decimal/ float/i;
$field =~ s/ date/ int/i; # $field =~ s/ date/ int/i;
# Pg doesn't have blob, it has text instead # Pg doesn't have blob, it has text instead
$field =~ s/ blob/ text/; $field =~ s/ blob/ text/;
$query.= $field . ','; $query.= $field . ',';
...@@ -946,9 +947,9 @@ sub create ...@@ -946,9 +947,9 @@ sub create
$field =~ s/ double/ float/i; $field =~ s/ double/ float/i;
# Solid doesn't have blob, it has long varchar # Solid doesn't have blob, it has long varchar
$field =~ s/ blob/ long varchar/; $field =~ s/ blob/ long varchar/;
$field =~ s/ decimal/ float/i; # $field =~ s/ decimal/ float/i;
$field =~ s/ big_decimal/ float/i; # $field =~ s/ big_decimal/ float/i;
$field =~ s/ date/ int/i; # $field =~ s/ date/ int/i;
$query.= $field . ','; $query.= $field . ',';
} }
substr($query,-1)=")"; # Remove last ','; substr($query,-1)=")"; # Remove last ',';
...@@ -1194,9 +1195,9 @@ sub create ...@@ -1194,9 +1195,9 @@ sub create
$field =~ s/ blob/ text/; $field =~ s/ blob/ text/;
$field =~ s/ varchar\((\d+)\)/ char($1,3)/; $field =~ s/ varchar\((\d+)\)/ char($1,3)/;
$field =~ s/ char\((\d+)\)/ char($1,3)/; $field =~ s/ char\((\d+)\)/ char($1,3)/;
$field =~ s/ decimal/ float/i; # $field =~ s/ decimal/ float/i;
$field =~ s/ big_decimal/ longfloat/i; # $field =~ s/ big_decimal/ longfloat/i;
$field =~ s/ date/ int/i; # $field =~ s/ date/ int/i;
$field =~ s/ float(.*)/ float/i; $field =~ s/ float(.*)/ float/i;
if ($field =~ / int\((\d+)\)/) { if ($field =~ / int\((\d+)\)/) {
if ($1 > 4) { if ($1 > 4) {
...@@ -2896,8 +2897,8 @@ sub create ...@@ -2896,8 +2897,8 @@ sub create
$query="create table $table_name ("; $query="create table $table_name (";
foreach $field (@$fields) foreach $field (@$fields)
{ {
$field =~ s/ decimal/ double(10,2)/i; # $field =~ s/ decimal/ double(10,2)/i;
$field =~ s/ big_decimal/ double(10,2)/i; # $field =~ s/ big_decimal/ double(10,2)/i;
$field =~ s/ tinyint\(.*\)/ smallint/i; $field =~ s/ tinyint\(.*\)/ smallint/i;
$field =~ s/ smallint\(.*\)/ smallint/i; $field =~ s/ smallint\(.*\)/ smallint/i;
$field =~ s/ mediumint/ integer/i; $field =~ s/ mediumint/ integer/i;
...@@ -3092,7 +3093,7 @@ sub create ...@@ -3092,7 +3093,7 @@ sub create
$query="create table $table_name ("; $query="create table $table_name (";
foreach $field (@$fields) foreach $field (@$fields)
{ {
$field =~ s/ big_decimal/ decimal/i; # $field =~ s/ big_decimal/ decimal/i;
$field =~ s/ double/ double precision/i; $field =~ s/ double/ double precision/i;
$field =~ s/ tinyint/ smallint/i; $field =~ s/ tinyint/ smallint/i;
$field =~ s/ mediumint/ integer/i; $field =~ s/ mediumint/ integer/i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment