diff --git a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/Bonsai.pm b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/Bonsai.pm index 8f8b77dcad1..a1172a56be0 100644 --- a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/Bonsai.pm +++ b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/Bonsai.pm @@ -151,7 +151,7 @@ sub update_cache { } } - $dbh->do("UPDATE tbox_bonsai SET start_cache = abstime(?), end_cache = abstime(?) WHERE bonsai_id = ?", undef, int($new_start_time), int($new_end_time), $bonsai_id); + $dbh->do("UPDATE tbox_bonsai SET start_cache = " . Tinderbox3::DB::sql_abstime("?") . ", end_cache = " . Tinderbox3::DB::sql_abstime("?") . " WHERE bonsai_id = ?", undef, int($new_start_time), int($new_end_time), $bonsai_id); } 1 diff --git a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/BonsaiColumns.pm b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/BonsaiColumns.pm index decca2d735c..5a53444a5dd 100644 --- a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/BonsaiColumns.pm +++ b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/BonsaiColumns.pm @@ -112,7 +112,7 @@ sub get_bonsai_column_queues { # # Fill in the bonsais with data # - $sth = $dbh->prepare("SELECT bonsai_id, EXTRACT(EPOCH FROM checkin_date), who, files, revisions, size_plus, size_minus, description FROM tbox_bonsai_cache WHERE checkin_date >= abstime(? + 0) AND checkin_date <= abstime(? + 0) AND bonsai_id IN (" . join(', ', map { "?" } keys %columns) . ") ORDER BY checkin_date"); + $sth = $dbh->prepare("SELECT bonsai_id, " . Tinderbox3::DB::sql_get_timestamp("checkin_date") . ", who, files, revisions, size_plus, size_minus, description FROM tbox_bonsai_cache WHERE checkin_date >= " . Tinderbox3::DB::sql_abstime("?") . " AND checkin_date <= " . Tinderbox3::DB::sql_abstime("?") . " AND bonsai_id IN (" . join(', ', map { "?" } keys %columns) . ") ORDER BY checkin_date"); $sth->execute($start_time, $end_time, map { $_->{BONSAI_ID} } values %columns); while (my $row = $sth->fetchrow_arrayref) { push @{$columns{$row->[0]}{EVENTS}}, { diff --git a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/DB.pm b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/DB.pm index b80846f898f..6a5ea12373b 100644 --- a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/DB.pm +++ b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/DB.pm @@ -9,13 +9,15 @@ use Tinderbox3::Log; require Exporter; our @ISA = qw(Exporter); -our @EXPORT = qw(get_dbh); +our @EXPORT = qw(get_dbh sql_current_timestamp sql_abstime sql_get_last_id sql_get_timestamp sql_get_bool); -our $dbname = "tbox"; +# dbtype = mysql or Pg +our $dbtype = "mysql"; +our $dbname = "tbox3"; our $username = ""; our $password = ""; sub get_dbh { - my $dbh = DBI->connect("dbi:Pg:dbname=$dbname", $username, $password, { RaiseError => 1, AutoCommit => 0 }); + my $dbh = DBI->connect("dbi:$dbtype:dbname=$dbname", $username, $password, { RaiseError => 1, AutoCommit => 0 }); return $dbh; } @@ -70,7 +72,7 @@ sub update_patch_action { if ($action eq 'upload_patch' || $action eq 'edit_patch') { my $patch_name = $p->param('patch_name') || ""; my $bug_id = $p->param('bug_id') || ""; - my $in_use = $p->param('in_use') ? 'Y' : 'N'; + my $in_use = sql_get_bool($p->param('in_use')); my $patch_ref = "Bug $bug_id"; my $patch_ref_url = "http://bugzilla.mozilla.org/show_bug.cgi?id=$bug_id"; @@ -123,7 +125,7 @@ sub update_patch_action { check_edit_patch($login, $dbh, $patch_id, "start/stop using patch"); if (!$patch_id) { die "Need patch id!" } - my $rows = $dbh->do("UPDATE tbox_patch SET in_use = ? WHERE patch_id = ?", undef, ($action eq 'start_using_patch' ? 'Y' : 'N'), $patch_id); + my $rows = $dbh->do("UPDATE tbox_patch SET in_use = ? WHERE patch_id = ?", undef, sql_get_bool($action eq 'start_using_patch'), $patch_id); if (!$rows) { die "Update failed. No such tree / patch."; } @@ -150,7 +152,7 @@ sub update_tree_action { my $min_row_size = $p->param('min_row_size') || ""; my $max_row_size = $p->param('max_row_size') || ""; my $default_tinderbox_view = $p->param('default_tinderbox_view') || ""; - my $new_machines_visible = $p->param('new_machines_visible') ? 'Y' : 'N'; + my $new_machines_visible = sql_get_bool($p->param('new_machines_visible')); my $editors = $p->param('editors') || ""; if (!$newtree) { die "Must specify a non-blank tree!"; } @@ -251,7 +253,7 @@ sub update_machine_action { # Check security check_edit_machine($login, $dbh, $machine_id, "edit machine"); - my $visible = $p->param('visible') ? 'Y' : 'N'; + my $visible = sql_get_bool($p->param('visible')); my $commands = $p->param('commands'); my $rows = $dbh->do('UPDATE tbox_machine SET visible = ?, commands = ? WHERE machine_id = ?', undef, $visible, $commands, $machine_id); @@ -345,8 +347,7 @@ sub update_bonsai_action { check_edit_tree($login, $dbh, $tree, "edit machine"); $dbh->do("INSERT INTO tbox_bonsai (tree_name, display_name, bonsai_url, module, branch, directory, cvsroot) VALUES (?, ?, ?, ?, ?, ?, ?)", undef, $tree, $display_name, $bonsai_url, $module, $branch, $directory, $cvsroot); - my $bonsai_id_row = $dbh->selectrow_arrayref("SELECT currval('tbox_bonsai_bonsai_id_seq')"); - $bonsai_id = $bonsai_id_row->[0]; + $bonsai_id = sql_get_last_id($dbh, 'tbox_bonsai_id_seq'); } $dbh->commit(); } elsif ($action eq "delete_bonsai") { @@ -361,4 +362,46 @@ sub update_bonsai_action { return ($tree, $bonsai_id); } +sub sql_current_timestamp { + return "current_timestamp()"; +} + +sub sql_get_timestamp { + my ($arg) = @_; + if ($dbtype eq "Pg") { + return "EXTRACT (EPOCH FROM $arg)"; + } elsif ($dbtype eq "mysql") { + return "unix_timestamp($arg)"; + } +} + +sub sql_abstime { + my ($arg) = @_; + if ($dbtype eq "Pg") { + return "abstime($arg + 0)"; + } elsif ($dbtype eq "mysql") { + return "from_unixtime($arg)"; + } +} + +sub sql_get_last_id { + my ($dbh, $sequence) = @_; + if ($dbtype eq "Pg") { + my $row = $dbh->selectrow_arrayref("SELECT currval('$sequence')"); + return $row->[0]; + } elsif ($dbtype eq "mysql") { + my $row = $dbh->selectrow_arrayref("SELECT last_insert_id()"); + return $row->[0]; + } +} + +sub sql_get_bool { + my ($bool) = @_; + if ($dbtype eq 'Pg') { + return $bool ? 'Y' : 'N'; + } elsif ($dbtype eq 'mysql') { + return $bool ? 1 : 0; + } +} + 1 diff --git a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/InitialValues.pm b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/InitialValues.pm index d51dcb117b7..296ab3b1e85 100644 --- a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/InitialValues.pm +++ b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/InitialValues.pm @@ -9,7 +9,7 @@ our $statuses = 'open,closed,restricted,metered'; our $min_row_size = 0; our $max_row_size = 5; our $default_tinderbox_view = 24*60; -our $new_machines_visible = 'Y'; +our $new_machines_visible = 1; our %initial_machine_config = ( branch => '', cvs_co_date => '', diff --git a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/Login.pm b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/Login.pm index 0a1d0eb521e..c30d6992e17 100644 --- a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/Login.pm +++ b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/Login.pm @@ -3,6 +3,7 @@ package Tinderbox3::Login; use strict; use LWP::UserAgent; use CGI; +use Tinderbox3::DB; require Exporter; our @ISA = qw(Exporter); @@ -11,6 +12,8 @@ our @EXPORT = qw(check_session can_admin can_edit_tree can_sheriff_tree login_fi sub login { my ($login, $password) = @_; + return 1; + my $p = new CGI({Bugzilla_login => $login, Bugzilla_password => $password, GoAheadAndLogIn => 1}); my $url = "http://bugzilla.mozilla.org/query.cgi?" . $p->query_string; @@ -46,8 +49,8 @@ sub check_session { if ($session_id) { delete_session($dbh, $session_id); } - my $new_session_id = time . "-" . int(rand*100000) . "-" . $login; - $dbh->do("INSERT INTO tbox_session (login, session_id, activity_time) VALUES (?, ?, current_timestamp())", undef, $login, $new_session_id); + my $new_session_id = time . "-" . int(rand()*100000) . "-" . $login; + $dbh->do("INSERT INTO tbox_session (login, session_id, activity_time) VALUES (?, ?, " . Tinderbox3::DB::sql_current_timestamp() . ")", undef, $login, $new_session_id); $dbh->commit(); $cookie = $p->cookie(-name => 'tbox_session', -value => $new_session_id); $login_return = $login; @@ -55,12 +58,12 @@ sub check_session { } elsif ($p->param('-logout') && $session_id) { delete_session($dbh, $session_id); } elsif($session_id) { - my $row = $dbh->selectrow_arrayref("SELECT login, EXTRACT(EPOCH FROM activity_time) FROM tbox_session WHERE session_id = ?", undef, $session_id); + my $row = $dbh->selectrow_arrayref("SELECT login, " . Tinderbox3::DB::sql_get_timestamp("activity_time") . " FROM tbox_session WHERE session_id = ?", undef, $session_id); if (defined($row)) { if (time > $row->[1]+24*60*60) { delete_session($dbh, $session_id); } else { - $dbh->do("UPDATE tbox_session SET activity_time = current_timestamp() WHERE session_id = ?", undef, $session_id); + $dbh->do("UPDATE tbox_session SET activity_time = " . Tinderbox3::DB::sql_current_timestamp() . " WHERE session_id = ?", undef, $session_id); $dbh->commit(); $login_return = $row->[0]; } diff --git a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/ShowBuilds.pm b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/ShowBuilds.pm index 85a7b0ff89b..0b2664ac515 100755 --- a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/ShowBuilds.pm +++ b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/ShowBuilds.pm @@ -32,7 +32,7 @@ sub print_showbuilds { $field_processors{$field} = $processor; # Check if the processor is OK to put in an eval statement if ($processor =~ /^([A-Za-z]+)$/) { - my $code = "require Tinderbox3::FieldProcessors::$processor; \$field_handlers{$processor} = new Tinderbox3::FieldProcessors::$processor();"; + my $code = "require Tinderbox3::FieldProcessors::$1; \$field_handlers{$1} = new Tinderbox3::FieldProcessors::$1();"; eval $code; } } diff --git a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/TreeColumns.pm b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/TreeColumns.pm index a8d7dc4b8d3..500850d51ad 100644 --- a/mozilla/webtools/tinderbox3/scripts/Tinderbox3/TreeColumns.pm +++ b/mozilla/webtools/tinderbox3/scripts/Tinderbox3/TreeColumns.pm @@ -200,11 +200,11 @@ EOM } # Print comment star - if (defined($top_event->{comments})) { + if (defined($top_event->{comments}) && @{$top_event->{comments}} > 0) { my $popup_str = "Comments (Add Comment)
"; foreach my $comment (sort { $b->[2] <=> $a->[2] } @{$top_event->{comments}}) { $popup_str .= "$comment->[0] - " . time2str("%H:%M", $comment->[2]) . - "
$comment->[1]
"; + "

$comment->[1]

"; } @@ -280,7 +280,7 @@ sub get_tree_column_queues { # # Get the list of machines # - my $sth = $dbh->prepare("SELECT machine_id, machine_name, os, os_version, compiler, clobber FROM tbox_machine WHERE tree_name = ? AND visible"); + my $sth = $dbh->prepare("SELECT machine_id, machine_name, os, os_version, compiler, clobber, visible FROM tbox_machine WHERE tree_name = ?"); $sth->execute($tree); my %columns; @@ -296,44 +296,30 @@ sub get_tree_column_queues { # Dump the relevant events into the columns # $sth = $dbh->prepare( - "SELECT b.machine_id, EXTRACT(EPOCH FROM b.build_time), - EXTRACT(EPOCH FROM b.status_time), b.status, b.log, - f.name, f.value, - c.login, c.build_comment, EXTRACT(EPOCH FROM c.comment_time) + "SELECT b.machine_id, " . Tinderbox3::DB::sql_get_timestamp("b.build_time") . ", + " . Tinderbox3::DB::sql_get_timestamp("b.status_time") . ", b.status, b.log FROM tbox_build b - LEFT OUTER JOIN tbox_build_field f USING (machine_id, build_time) - LEFT OUTER JOIN tbox_build_comment c USING (machine_id, build_time) WHERE b.machine_id IN (" . join(", ", map { "?" } keys %columns) . ") - AND b.status_time >= abstime(? + 0) - AND b.build_time <= abstime(? + 0) + AND b.status_time >= " . Tinderbox3::DB::sql_abstime("?") . " + AND b.build_time <= " . Tinderbox3::DB::sql_abstime("?") . " ORDER BY b.build_time, b.machine_id"); $sth->execute(keys %columns, $start_time, $end_time); - my ($machine_id, $build_time, $event); while (my $build = $sth->fetchrow_arrayref) { - if (!defined($event) || $machine_id != $build->[0] || - $build_time ne $build->[1]) { - if (defined($event)) { - # Flush previous event when machine/build changes - $columns{$machine_id}->add_event($event); - } - $machine_id = $build->[0]; - $build_time = $build->[1]; - $event = { build_time => $build->[1], status_time => $build->[2], - status => $build->[3], logfile => $build->[4], fields => [] }; + my $machine_id = $build->[0]; + my $build_time = $build->[1]; + my $event = { build_time => $build->[1], status_time => $build->[2], + status => $build->[3], logfile => $build->[4], fields => [] }; + + my $fields = $dbh->selectall_arrayref("SELECT name, value FROM tbox_build_field WHERE machine_id = ? AND build_time = " . Tinderbox3::DB::sql_abstime("?"), undef, $machine_id, $build_time); + foreach my $field (@{$fields}) { + push @{$event->{fields}}, [ $field->[0], $field->[1] ]; } - my $field_name = $build->[5] || ""; - if ($field_name) { - push @{$event->{fields}}, [ $field_name, $build->[6] ]; + + my $comments = $dbh->selectall_arrayref("SELECT login, build_comment, " . Tinderbox3::DB::sql_get_timestamp("comment_time") . " FROM tbox_build_comment WHERE machine_id = ? AND build_time = " . Tinderbox3::DB::sql_abstime("?"), undef, $machine_id, $build_time); + foreach my $comment (@{$comments}) { + push @{$event->{comments}}, [ $comment->[0], $comment->[1], $comment->[2] ]; } - my $build_comment = $build->[8] || ""; - if ($build_comment) { - if (!$event->{comments}) { - $event->{comments} = []; - } - push @{$event->{comments}}, [ $build->[7], $build_comment, $build->[9] ]; - } - } - if (defined($event)) { + $columns{$machine_id}->add_event($event); } diff --git a/mozilla/webtools/tinderbox3/scripts/admintree.pl b/mozilla/webtools/tinderbox3/scripts/admintree.pl index 6fcea198f90..b3a130c436e 100755 --- a/mozilla/webtools/tinderbox3/scripts/admintree.pl +++ b/mozilla/webtools/tinderbox3/scripts/admintree.pl @@ -35,7 +35,7 @@ if (!$tree) { $Tinderbox3::InitialValues::min_row_size, $Tinderbox3::InitialValues::max_row_size, $Tinderbox3::InitialValues::default_tinderbox_view, - $Tinderbox3::InitialValues::new_machines_visible, + Tinderbox3::DB::sql_get_bool($Tinderbox3::InitialValues::new_machines_visible), '', ]; %initial_machine_config = %Tinderbox3::InitialValues::initial_machine_config; diff --git a/mozilla/webtools/tinderbox3/scripts/savecomment.pl b/mozilla/webtools/tinderbox3/scripts/savecomment.pl index 5f7dbede80f..cf3e2da8f26 100755 --- a/mozilla/webtools/tinderbox3/scripts/savecomment.pl +++ b/mozilla/webtools/tinderbox3/scripts/savecomment.pl @@ -32,11 +32,11 @@ if (!$login) { # XXX For odd reasons, DBI doesn't want to make build_time an integer and # Postgres don't like that, so we put it directly into the SQL statement and # are subsequently unable to reuse the statement :( -my $sth = $dbh->prepare("INSERT INTO tbox_build_comment (machine_id, build_time, login, build_comment, comment_time) VALUES (?, abstime(? + 0), ?, ?, current_timestamp())"); +my $sth = $dbh->prepare("INSERT INTO tbox_build_comment (machine_id, build_time, login, build_comment, comment_time) VALUES (?, " . Tinderbox3::DB::sql_abstime("?") . ", ?, ?, " . Tinderbox3::DB::sql_current_timestamp() . ")"); $sth->execute($machine_id, $build_time, $login, $build_comment); foreach my $other_machine_id ($p->param('other_machine_id')) { - my $other_build_time = $dbh->selectrow_arrayref("SELECT EXTRACT(EPOCH FROM build_time) FROM tbox_build WHERE machine_id = ? ORDER BY build_time DESC LIMIT 1", undef, $other_machine_id); + my $other_build_time = $dbh->selectrow_arrayref("SELECT " . Tinderbox3::DB::sql_get_timestamp('build_time') . " FROM tbox_build WHERE machine_id = ? ORDER BY build_time DESC LIMIT 1", undef, $other_machine_id); if (defined($other_build_time)) { $sth->execute($other_machine_id, $other_build_time->[0], $login, $build_comment); } diff --git a/mozilla/webtools/tinderbox3/scripts/tbox_bonsai_update.pl b/mozilla/webtools/tinderbox3/scripts/tbox_bonsai_update.pl index 98026623078..71d56e27a2c 100755 --- a/mozilla/webtools/tinderbox3/scripts/tbox_bonsai_update.pl +++ b/mozilla/webtools/tinderbox3/scripts/tbox_bonsai_update.pl @@ -23,7 +23,7 @@ EOM my $dbh = get_dbh(); -my $sth = $dbh->prepare("SELECT bonsai_id, bonsai_url, module, branch, directory, cvsroot, EXTRACT(EPOCH FROM start_cache), EXTRACT(EPOCH FROM end_cache) FROM tbox_bonsai"); +my $sth = $dbh->prepare("SELECT bonsai_id, bonsai_url, module, branch, directory, cvsroot, " . Tinderbox3::DB::sql_get_timestamp("start_cache") . ", " . Tinderbox3::DB::sql_get_timestamp("end_cache") . " FROM tbox_bonsai"); $sth->execute(); while (my $row = $sth->fetchrow_arrayref) { #Tinderbox3::Bonsai::clear_cache($dbh, $row->[0]); diff --git a/mozilla/webtools/tinderbox3/scripts/xml/build_start.pl b/mozilla/webtools/tinderbox3/scripts/xml/build_start.pl index 40066835a36..05ae327d0b6 100755 --- a/mozilla/webtools/tinderbox3/scripts/xml/build_start.pl +++ b/mozilla/webtools/tinderbox3/scripts/xml/build_start.pl @@ -45,15 +45,17 @@ if (!$patch_ids) { # my $machine_info = $dbh->selectrow_arrayref("SELECT machine_id, commands FROM tbox_machine WHERE tree_name = ? AND machine_name = ? AND os = ? AND os_version = ? AND compiler = ?", undef, $tree, $machine_name, $os, $os_version, $compiler); if (!defined($machine_info)) { - $dbh->do("INSERT INTO tbox_machine (tree_name, machine_name, visible, os, os_version, compiler, clobber) VALUES (?, ?, ?, ?, ?, ?, ?)", undef, $tree, $machine_name, $new_machines_visible, $os, $os_version, $compiler, ($clobber ? 'Y' : 'N')); - my $machine_id = $dbh->selectrow_arrayref("SELECT currval('tbox_machine_machine_id_seq')"); - $machine_info = [ $machine_id->[0], "" ]; + $dbh->do("INSERT INTO tbox_machine (tree_name, machine_name, visible, os, os_version, compiler, clobber) VALUES (?, ?, ?, ?, ?, ?, ?)", undef, $tree, $machine_name, $new_machines_visible, $os, $os_version, $compiler, Tinderbox3::DB::sql_get_bool($clobber)); + $machine_info = [ Tinderbox3::DB::sql_get_last_id($dbh, 'tbox_machine_machine_id_seq'), "" ] } else { - $dbh->do("UPDATE tbox_machine SET clobber = ? WHERE machine_id = ?", undef, ($clobber ? 'Y' : 'N'), $machine_info->[0]); + $dbh->do("UPDATE tbox_machine SET clobber = ? WHERE machine_id = ?", undef, Tinderbox3::DB::sql_get_bool($clobber), $machine_info->[0]); } my ($machine_id, $commands) = @{$machine_info}; $commands ||= ""; +$machine_id =~ /(\d+)/; +$machine_id = $1; + # # Get the machine config # diff --git a/mozilla/webtools/tinderbox3/scripts/xml/build_status.pl b/mozilla/webtools/tinderbox3/scripts/xml/build_status.pl index 53b76842a77..33e48b5eca3 100755 --- a/mozilla/webtools/tinderbox3/scripts/xml/build_status.pl +++ b/mozilla/webtools/tinderbox3/scripts/xml/build_status.pl @@ -53,8 +53,10 @@ if (!defined($build_info)) { die_xml_error("No build time"); } my ($build_time, $log) = @{$build_info}; +$log =~ /(.+)/; +$log = $1; -$dbh->do("UPDATE tbox_build SET status_time = current_timestamp(), status = ? WHERE machine_id = ? AND build_time = ?", undef, $status, $machine_id, $build_time); +my $done = $dbh->do("UPDATE tbox_build SET status_time = " . Tinderbox3::DB::sql_current_timestamp() . ", status = ? WHERE machine_id = ? AND build_time = ?", undef, $status, $machine_id, $build_time); # # Update fields diff --git a/mozilla/webtools/tinderbox3/server/Tinderbox3/Bonsai.pm b/mozilla/webtools/tinderbox3/server/Tinderbox3/Bonsai.pm index 8f8b77dcad1..a1172a56be0 100644 --- a/mozilla/webtools/tinderbox3/server/Tinderbox3/Bonsai.pm +++ b/mozilla/webtools/tinderbox3/server/Tinderbox3/Bonsai.pm @@ -151,7 +151,7 @@ sub update_cache { } } - $dbh->do("UPDATE tbox_bonsai SET start_cache = abstime(?), end_cache = abstime(?) WHERE bonsai_id = ?", undef, int($new_start_time), int($new_end_time), $bonsai_id); + $dbh->do("UPDATE tbox_bonsai SET start_cache = " . Tinderbox3::DB::sql_abstime("?") . ", end_cache = " . Tinderbox3::DB::sql_abstime("?") . " WHERE bonsai_id = ?", undef, int($new_start_time), int($new_end_time), $bonsai_id); } 1 diff --git a/mozilla/webtools/tinderbox3/server/Tinderbox3/BonsaiColumns.pm b/mozilla/webtools/tinderbox3/server/Tinderbox3/BonsaiColumns.pm index decca2d735c..5a53444a5dd 100644 --- a/mozilla/webtools/tinderbox3/server/Tinderbox3/BonsaiColumns.pm +++ b/mozilla/webtools/tinderbox3/server/Tinderbox3/BonsaiColumns.pm @@ -112,7 +112,7 @@ sub get_bonsai_column_queues { # # Fill in the bonsais with data # - $sth = $dbh->prepare("SELECT bonsai_id, EXTRACT(EPOCH FROM checkin_date), who, files, revisions, size_plus, size_minus, description FROM tbox_bonsai_cache WHERE checkin_date >= abstime(? + 0) AND checkin_date <= abstime(? + 0) AND bonsai_id IN (" . join(', ', map { "?" } keys %columns) . ") ORDER BY checkin_date"); + $sth = $dbh->prepare("SELECT bonsai_id, " . Tinderbox3::DB::sql_get_timestamp("checkin_date") . ", who, files, revisions, size_plus, size_minus, description FROM tbox_bonsai_cache WHERE checkin_date >= " . Tinderbox3::DB::sql_abstime("?") . " AND checkin_date <= " . Tinderbox3::DB::sql_abstime("?") . " AND bonsai_id IN (" . join(', ', map { "?" } keys %columns) . ") ORDER BY checkin_date"); $sth->execute($start_time, $end_time, map { $_->{BONSAI_ID} } values %columns); while (my $row = $sth->fetchrow_arrayref) { push @{$columns{$row->[0]}{EVENTS}}, { diff --git a/mozilla/webtools/tinderbox3/server/Tinderbox3/DB.pm b/mozilla/webtools/tinderbox3/server/Tinderbox3/DB.pm index b80846f898f..6a5ea12373b 100644 --- a/mozilla/webtools/tinderbox3/server/Tinderbox3/DB.pm +++ b/mozilla/webtools/tinderbox3/server/Tinderbox3/DB.pm @@ -9,13 +9,15 @@ use Tinderbox3::Log; require Exporter; our @ISA = qw(Exporter); -our @EXPORT = qw(get_dbh); +our @EXPORT = qw(get_dbh sql_current_timestamp sql_abstime sql_get_last_id sql_get_timestamp sql_get_bool); -our $dbname = "tbox"; +# dbtype = mysql or Pg +our $dbtype = "mysql"; +our $dbname = "tbox3"; our $username = ""; our $password = ""; sub get_dbh { - my $dbh = DBI->connect("dbi:Pg:dbname=$dbname", $username, $password, { RaiseError => 1, AutoCommit => 0 }); + my $dbh = DBI->connect("dbi:$dbtype:dbname=$dbname", $username, $password, { RaiseError => 1, AutoCommit => 0 }); return $dbh; } @@ -70,7 +72,7 @@ sub update_patch_action { if ($action eq 'upload_patch' || $action eq 'edit_patch') { my $patch_name = $p->param('patch_name') || ""; my $bug_id = $p->param('bug_id') || ""; - my $in_use = $p->param('in_use') ? 'Y' : 'N'; + my $in_use = sql_get_bool($p->param('in_use')); my $patch_ref = "Bug $bug_id"; my $patch_ref_url = "http://bugzilla.mozilla.org/show_bug.cgi?id=$bug_id"; @@ -123,7 +125,7 @@ sub update_patch_action { check_edit_patch($login, $dbh, $patch_id, "start/stop using patch"); if (!$patch_id) { die "Need patch id!" } - my $rows = $dbh->do("UPDATE tbox_patch SET in_use = ? WHERE patch_id = ?", undef, ($action eq 'start_using_patch' ? 'Y' : 'N'), $patch_id); + my $rows = $dbh->do("UPDATE tbox_patch SET in_use = ? WHERE patch_id = ?", undef, sql_get_bool($action eq 'start_using_patch'), $patch_id); if (!$rows) { die "Update failed. No such tree / patch."; } @@ -150,7 +152,7 @@ sub update_tree_action { my $min_row_size = $p->param('min_row_size') || ""; my $max_row_size = $p->param('max_row_size') || ""; my $default_tinderbox_view = $p->param('default_tinderbox_view') || ""; - my $new_machines_visible = $p->param('new_machines_visible') ? 'Y' : 'N'; + my $new_machines_visible = sql_get_bool($p->param('new_machines_visible')); my $editors = $p->param('editors') || ""; if (!$newtree) { die "Must specify a non-blank tree!"; } @@ -251,7 +253,7 @@ sub update_machine_action { # Check security check_edit_machine($login, $dbh, $machine_id, "edit machine"); - my $visible = $p->param('visible') ? 'Y' : 'N'; + my $visible = sql_get_bool($p->param('visible')); my $commands = $p->param('commands'); my $rows = $dbh->do('UPDATE tbox_machine SET visible = ?, commands = ? WHERE machine_id = ?', undef, $visible, $commands, $machine_id); @@ -345,8 +347,7 @@ sub update_bonsai_action { check_edit_tree($login, $dbh, $tree, "edit machine"); $dbh->do("INSERT INTO tbox_bonsai (tree_name, display_name, bonsai_url, module, branch, directory, cvsroot) VALUES (?, ?, ?, ?, ?, ?, ?)", undef, $tree, $display_name, $bonsai_url, $module, $branch, $directory, $cvsroot); - my $bonsai_id_row = $dbh->selectrow_arrayref("SELECT currval('tbox_bonsai_bonsai_id_seq')"); - $bonsai_id = $bonsai_id_row->[0]; + $bonsai_id = sql_get_last_id($dbh, 'tbox_bonsai_id_seq'); } $dbh->commit(); } elsif ($action eq "delete_bonsai") { @@ -361,4 +362,46 @@ sub update_bonsai_action { return ($tree, $bonsai_id); } +sub sql_current_timestamp { + return "current_timestamp()"; +} + +sub sql_get_timestamp { + my ($arg) = @_; + if ($dbtype eq "Pg") { + return "EXTRACT (EPOCH FROM $arg)"; + } elsif ($dbtype eq "mysql") { + return "unix_timestamp($arg)"; + } +} + +sub sql_abstime { + my ($arg) = @_; + if ($dbtype eq "Pg") { + return "abstime($arg + 0)"; + } elsif ($dbtype eq "mysql") { + return "from_unixtime($arg)"; + } +} + +sub sql_get_last_id { + my ($dbh, $sequence) = @_; + if ($dbtype eq "Pg") { + my $row = $dbh->selectrow_arrayref("SELECT currval('$sequence')"); + return $row->[0]; + } elsif ($dbtype eq "mysql") { + my $row = $dbh->selectrow_arrayref("SELECT last_insert_id()"); + return $row->[0]; + } +} + +sub sql_get_bool { + my ($bool) = @_; + if ($dbtype eq 'Pg') { + return $bool ? 'Y' : 'N'; + } elsif ($dbtype eq 'mysql') { + return $bool ? 1 : 0; + } +} + 1 diff --git a/mozilla/webtools/tinderbox3/server/Tinderbox3/InitialValues.pm b/mozilla/webtools/tinderbox3/server/Tinderbox3/InitialValues.pm index d51dcb117b7..296ab3b1e85 100644 --- a/mozilla/webtools/tinderbox3/server/Tinderbox3/InitialValues.pm +++ b/mozilla/webtools/tinderbox3/server/Tinderbox3/InitialValues.pm @@ -9,7 +9,7 @@ our $statuses = 'open,closed,restricted,metered'; our $min_row_size = 0; our $max_row_size = 5; our $default_tinderbox_view = 24*60; -our $new_machines_visible = 'Y'; +our $new_machines_visible = 1; our %initial_machine_config = ( branch => '', cvs_co_date => '', diff --git a/mozilla/webtools/tinderbox3/server/Tinderbox3/Login.pm b/mozilla/webtools/tinderbox3/server/Tinderbox3/Login.pm index 0a1d0eb521e..c30d6992e17 100644 --- a/mozilla/webtools/tinderbox3/server/Tinderbox3/Login.pm +++ b/mozilla/webtools/tinderbox3/server/Tinderbox3/Login.pm @@ -3,6 +3,7 @@ package Tinderbox3::Login; use strict; use LWP::UserAgent; use CGI; +use Tinderbox3::DB; require Exporter; our @ISA = qw(Exporter); @@ -11,6 +12,8 @@ our @EXPORT = qw(check_session can_admin can_edit_tree can_sheriff_tree login_fi sub login { my ($login, $password) = @_; + return 1; + my $p = new CGI({Bugzilla_login => $login, Bugzilla_password => $password, GoAheadAndLogIn => 1}); my $url = "http://bugzilla.mozilla.org/query.cgi?" . $p->query_string; @@ -46,8 +49,8 @@ sub check_session { if ($session_id) { delete_session($dbh, $session_id); } - my $new_session_id = time . "-" . int(rand*100000) . "-" . $login; - $dbh->do("INSERT INTO tbox_session (login, session_id, activity_time) VALUES (?, ?, current_timestamp())", undef, $login, $new_session_id); + my $new_session_id = time . "-" . int(rand()*100000) . "-" . $login; + $dbh->do("INSERT INTO tbox_session (login, session_id, activity_time) VALUES (?, ?, " . Tinderbox3::DB::sql_current_timestamp() . ")", undef, $login, $new_session_id); $dbh->commit(); $cookie = $p->cookie(-name => 'tbox_session', -value => $new_session_id); $login_return = $login; @@ -55,12 +58,12 @@ sub check_session { } elsif ($p->param('-logout') && $session_id) { delete_session($dbh, $session_id); } elsif($session_id) { - my $row = $dbh->selectrow_arrayref("SELECT login, EXTRACT(EPOCH FROM activity_time) FROM tbox_session WHERE session_id = ?", undef, $session_id); + my $row = $dbh->selectrow_arrayref("SELECT login, " . Tinderbox3::DB::sql_get_timestamp("activity_time") . " FROM tbox_session WHERE session_id = ?", undef, $session_id); if (defined($row)) { if (time > $row->[1]+24*60*60) { delete_session($dbh, $session_id); } else { - $dbh->do("UPDATE tbox_session SET activity_time = current_timestamp() WHERE session_id = ?", undef, $session_id); + $dbh->do("UPDATE tbox_session SET activity_time = " . Tinderbox3::DB::sql_current_timestamp() . " WHERE session_id = ?", undef, $session_id); $dbh->commit(); $login_return = $row->[0]; } diff --git a/mozilla/webtools/tinderbox3/server/Tinderbox3/ShowBuilds.pm b/mozilla/webtools/tinderbox3/server/Tinderbox3/ShowBuilds.pm index 85a7b0ff89b..0b2664ac515 100755 --- a/mozilla/webtools/tinderbox3/server/Tinderbox3/ShowBuilds.pm +++ b/mozilla/webtools/tinderbox3/server/Tinderbox3/ShowBuilds.pm @@ -32,7 +32,7 @@ sub print_showbuilds { $field_processors{$field} = $processor; # Check if the processor is OK to put in an eval statement if ($processor =~ /^([A-Za-z]+)$/) { - my $code = "require Tinderbox3::FieldProcessors::$processor; \$field_handlers{$processor} = new Tinderbox3::FieldProcessors::$processor();"; + my $code = "require Tinderbox3::FieldProcessors::$1; \$field_handlers{$1} = new Tinderbox3::FieldProcessors::$1();"; eval $code; } } diff --git a/mozilla/webtools/tinderbox3/server/Tinderbox3/TreeColumns.pm b/mozilla/webtools/tinderbox3/server/Tinderbox3/TreeColumns.pm index a8d7dc4b8d3..500850d51ad 100644 --- a/mozilla/webtools/tinderbox3/server/Tinderbox3/TreeColumns.pm +++ b/mozilla/webtools/tinderbox3/server/Tinderbox3/TreeColumns.pm @@ -200,11 +200,11 @@ EOM } # Print comment star - if (defined($top_event->{comments})) { + if (defined($top_event->{comments}) && @{$top_event->{comments}} > 0) { my $popup_str = "Comments (Add Comment)
"; foreach my $comment (sort { $b->[2] <=> $a->[2] } @{$top_event->{comments}}) { $popup_str .= "$comment->[0] - " . time2str("%H:%M", $comment->[2]) . - "
$comment->[1]
"; + "

$comment->[1]

"; } @@ -280,7 +280,7 @@ sub get_tree_column_queues { # # Get the list of machines # - my $sth = $dbh->prepare("SELECT machine_id, machine_name, os, os_version, compiler, clobber FROM tbox_machine WHERE tree_name = ? AND visible"); + my $sth = $dbh->prepare("SELECT machine_id, machine_name, os, os_version, compiler, clobber, visible FROM tbox_machine WHERE tree_name = ?"); $sth->execute($tree); my %columns; @@ -296,44 +296,30 @@ sub get_tree_column_queues { # Dump the relevant events into the columns # $sth = $dbh->prepare( - "SELECT b.machine_id, EXTRACT(EPOCH FROM b.build_time), - EXTRACT(EPOCH FROM b.status_time), b.status, b.log, - f.name, f.value, - c.login, c.build_comment, EXTRACT(EPOCH FROM c.comment_time) + "SELECT b.machine_id, " . Tinderbox3::DB::sql_get_timestamp("b.build_time") . ", + " . Tinderbox3::DB::sql_get_timestamp("b.status_time") . ", b.status, b.log FROM tbox_build b - LEFT OUTER JOIN tbox_build_field f USING (machine_id, build_time) - LEFT OUTER JOIN tbox_build_comment c USING (machine_id, build_time) WHERE b.machine_id IN (" . join(", ", map { "?" } keys %columns) . ") - AND b.status_time >= abstime(? + 0) - AND b.build_time <= abstime(? + 0) + AND b.status_time >= " . Tinderbox3::DB::sql_abstime("?") . " + AND b.build_time <= " . Tinderbox3::DB::sql_abstime("?") . " ORDER BY b.build_time, b.machine_id"); $sth->execute(keys %columns, $start_time, $end_time); - my ($machine_id, $build_time, $event); while (my $build = $sth->fetchrow_arrayref) { - if (!defined($event) || $machine_id != $build->[0] || - $build_time ne $build->[1]) { - if (defined($event)) { - # Flush previous event when machine/build changes - $columns{$machine_id}->add_event($event); - } - $machine_id = $build->[0]; - $build_time = $build->[1]; - $event = { build_time => $build->[1], status_time => $build->[2], - status => $build->[3], logfile => $build->[4], fields => [] }; + my $machine_id = $build->[0]; + my $build_time = $build->[1]; + my $event = { build_time => $build->[1], status_time => $build->[2], + status => $build->[3], logfile => $build->[4], fields => [] }; + + my $fields = $dbh->selectall_arrayref("SELECT name, value FROM tbox_build_field WHERE machine_id = ? AND build_time = " . Tinderbox3::DB::sql_abstime("?"), undef, $machine_id, $build_time); + foreach my $field (@{$fields}) { + push @{$event->{fields}}, [ $field->[0], $field->[1] ]; } - my $field_name = $build->[5] || ""; - if ($field_name) { - push @{$event->{fields}}, [ $field_name, $build->[6] ]; + + my $comments = $dbh->selectall_arrayref("SELECT login, build_comment, " . Tinderbox3::DB::sql_get_timestamp("comment_time") . " FROM tbox_build_comment WHERE machine_id = ? AND build_time = " . Tinderbox3::DB::sql_abstime("?"), undef, $machine_id, $build_time); + foreach my $comment (@{$comments}) { + push @{$event->{comments}}, [ $comment->[0], $comment->[1], $comment->[2] ]; } - my $build_comment = $build->[8] || ""; - if ($build_comment) { - if (!$event->{comments}) { - $event->{comments} = []; - } - push @{$event->{comments}}, [ $build->[7], $build_comment, $build->[9] ]; - } - } - if (defined($event)) { + $columns{$machine_id}->add_event($event); } diff --git a/mozilla/webtools/tinderbox3/server/admintree.pl b/mozilla/webtools/tinderbox3/server/admintree.pl index 6fcea198f90..b3a130c436e 100755 --- a/mozilla/webtools/tinderbox3/server/admintree.pl +++ b/mozilla/webtools/tinderbox3/server/admintree.pl @@ -35,7 +35,7 @@ if (!$tree) { $Tinderbox3::InitialValues::min_row_size, $Tinderbox3::InitialValues::max_row_size, $Tinderbox3::InitialValues::default_tinderbox_view, - $Tinderbox3::InitialValues::new_machines_visible, + Tinderbox3::DB::sql_get_bool($Tinderbox3::InitialValues::new_machines_visible), '', ]; %initial_machine_config = %Tinderbox3::InitialValues::initial_machine_config; diff --git a/mozilla/webtools/tinderbox3/server/savecomment.pl b/mozilla/webtools/tinderbox3/server/savecomment.pl index 5f7dbede80f..cf3e2da8f26 100755 --- a/mozilla/webtools/tinderbox3/server/savecomment.pl +++ b/mozilla/webtools/tinderbox3/server/savecomment.pl @@ -32,11 +32,11 @@ if (!$login) { # XXX For odd reasons, DBI doesn't want to make build_time an integer and # Postgres don't like that, so we put it directly into the SQL statement and # are subsequently unable to reuse the statement :( -my $sth = $dbh->prepare("INSERT INTO tbox_build_comment (machine_id, build_time, login, build_comment, comment_time) VALUES (?, abstime(? + 0), ?, ?, current_timestamp())"); +my $sth = $dbh->prepare("INSERT INTO tbox_build_comment (machine_id, build_time, login, build_comment, comment_time) VALUES (?, " . Tinderbox3::DB::sql_abstime("?") . ", ?, ?, " . Tinderbox3::DB::sql_current_timestamp() . ")"); $sth->execute($machine_id, $build_time, $login, $build_comment); foreach my $other_machine_id ($p->param('other_machine_id')) { - my $other_build_time = $dbh->selectrow_arrayref("SELECT EXTRACT(EPOCH FROM build_time) FROM tbox_build WHERE machine_id = ? ORDER BY build_time DESC LIMIT 1", undef, $other_machine_id); + my $other_build_time = $dbh->selectrow_arrayref("SELECT " . Tinderbox3::DB::sql_get_timestamp('build_time') . " FROM tbox_build WHERE machine_id = ? ORDER BY build_time DESC LIMIT 1", undef, $other_machine_id); if (defined($other_build_time)) { $sth->execute($other_machine_id, $other_build_time->[0], $login, $build_comment); } diff --git a/mozilla/webtools/tinderbox3/server/tbox_bonsai_update.pl b/mozilla/webtools/tinderbox3/server/tbox_bonsai_update.pl index 98026623078..71d56e27a2c 100755 --- a/mozilla/webtools/tinderbox3/server/tbox_bonsai_update.pl +++ b/mozilla/webtools/tinderbox3/server/tbox_bonsai_update.pl @@ -23,7 +23,7 @@ EOM my $dbh = get_dbh(); -my $sth = $dbh->prepare("SELECT bonsai_id, bonsai_url, module, branch, directory, cvsroot, EXTRACT(EPOCH FROM start_cache), EXTRACT(EPOCH FROM end_cache) FROM tbox_bonsai"); +my $sth = $dbh->prepare("SELECT bonsai_id, bonsai_url, module, branch, directory, cvsroot, " . Tinderbox3::DB::sql_get_timestamp("start_cache") . ", " . Tinderbox3::DB::sql_get_timestamp("end_cache") . " FROM tbox_bonsai"); $sth->execute(); while (my $row = $sth->fetchrow_arrayref) { #Tinderbox3::Bonsai::clear_cache($dbh, $row->[0]); diff --git a/mozilla/webtools/tinderbox3/server/xml/build_start.pl b/mozilla/webtools/tinderbox3/server/xml/build_start.pl index 40066835a36..05ae327d0b6 100755 --- a/mozilla/webtools/tinderbox3/server/xml/build_start.pl +++ b/mozilla/webtools/tinderbox3/server/xml/build_start.pl @@ -45,15 +45,17 @@ if (!$patch_ids) { # my $machine_info = $dbh->selectrow_arrayref("SELECT machine_id, commands FROM tbox_machine WHERE tree_name = ? AND machine_name = ? AND os = ? AND os_version = ? AND compiler = ?", undef, $tree, $machine_name, $os, $os_version, $compiler); if (!defined($machine_info)) { - $dbh->do("INSERT INTO tbox_machine (tree_name, machine_name, visible, os, os_version, compiler, clobber) VALUES (?, ?, ?, ?, ?, ?, ?)", undef, $tree, $machine_name, $new_machines_visible, $os, $os_version, $compiler, ($clobber ? 'Y' : 'N')); - my $machine_id = $dbh->selectrow_arrayref("SELECT currval('tbox_machine_machine_id_seq')"); - $machine_info = [ $machine_id->[0], "" ]; + $dbh->do("INSERT INTO tbox_machine (tree_name, machine_name, visible, os, os_version, compiler, clobber) VALUES (?, ?, ?, ?, ?, ?, ?)", undef, $tree, $machine_name, $new_machines_visible, $os, $os_version, $compiler, Tinderbox3::DB::sql_get_bool($clobber)); + $machine_info = [ Tinderbox3::DB::sql_get_last_id($dbh, 'tbox_machine_machine_id_seq'), "" ] } else { - $dbh->do("UPDATE tbox_machine SET clobber = ? WHERE machine_id = ?", undef, ($clobber ? 'Y' : 'N'), $machine_info->[0]); + $dbh->do("UPDATE tbox_machine SET clobber = ? WHERE machine_id = ?", undef, Tinderbox3::DB::sql_get_bool($clobber), $machine_info->[0]); } my ($machine_id, $commands) = @{$machine_info}; $commands ||= ""; +$machine_id =~ /(\d+)/; +$machine_id = $1; + # # Get the machine config # diff --git a/mozilla/webtools/tinderbox3/server/xml/build_status.pl b/mozilla/webtools/tinderbox3/server/xml/build_status.pl index 53b76842a77..33e48b5eca3 100755 --- a/mozilla/webtools/tinderbox3/server/xml/build_status.pl +++ b/mozilla/webtools/tinderbox3/server/xml/build_status.pl @@ -53,8 +53,10 @@ if (!defined($build_info)) { die_xml_error("No build time"); } my ($build_time, $log) = @{$build_info}; +$log =~ /(.+)/; +$log = $1; -$dbh->do("UPDATE tbox_build SET status_time = current_timestamp(), status = ? WHERE machine_id = ? AND build_time = ?", undef, $status, $machine_id, $build_time); +my $done = $dbh->do("UPDATE tbox_build SET status_time = " . Tinderbox3::DB::sql_current_timestamp() . ", status = ? WHERE machine_id = ? AND build_time = ?", undef, $status, $machine_id, $build_time); # # Update fields diff --git a/mozilla/webtools/tinderbox3/sql/create_schema_postgres.sql b/mozilla/webtools/tinderbox3/sql/create_schema_postgres.sql index c3f7bccc10f..aca3deca37b 100644 --- a/mozilla/webtools/tinderbox3/sql/create_schema_postgres.sql +++ b/mozilla/webtools/tinderbox3/sql/create_schema_postgres.sql @@ -15,7 +15,7 @@ CREATE TABLE tbox_tree ( -- Default size of Tinderbox (in minutes) default_tinderbox_view INTEGER, -- Whether or not to make new Tinderboxen visible immediately - new_machines_visible BOOLEAN, + new_machines_visible BOOL, -- People who can edit this tree editors TEXT, @@ -55,7 +55,7 @@ CREATE TABLE tbox_patch ( patch_ref_url TEXT, patch TEXT, -- in_use: if true, Tinderboxes will pick up this patch - in_use BOOLEAN + in_use BOOL ); -- @@ -70,13 +70,13 @@ CREATE TABLE tbox_machine ( os VARCHAR(200), os_version VARCHAR(200), compiler VARCHAR(200), - clobber BOOLEAN, + clobber BOOL, -- A set of commands to give to the machine (kick is the only one right now) -- (will be cleared as soon as the command is given; obedience is assumed) commands TEXT, -- Whether or not this machine is visible - visible BOOLEAN + visible BOOL ); -- diff --git a/mozilla/webtools/tinderbox3/sql/setup-mysql.pl b/mozilla/webtools/tinderbox3/sql/setup-mysql.pl index 54b93a302c0..f2353bdcf57 100755 --- a/mozilla/webtools/tinderbox3/sql/setup-mysql.pl +++ b/mozilla/webtools/tinderbox3/sql/setup-mysql.pl @@ -1,4 +1,4 @@ -#!perl -I.. +#!/usr/bin/perl -I.. use strict; use Getopt::Long; use DBI; @@ -87,12 +87,14 @@ sub generate_create_schema_file { open IN, $old_create_schema; open OUT, ">$new_create_schema"; while () { - s/\bserial\b/int4 not null auto_increment primary key/; - s/\bunique\b//; + s/\bserial\b/int4 not null auto_increment primary key/i; + s/\bunique\b//i; if (/(create\s*table\s*)(\w+)/i) { my $new_table_name = lc($2); s/(create\s*table\s*)(\w+)/\1$new_table_name/i; } + s/\bboolean\b/bool/i; + s/\btimestamp\b(\s*\(\s*\d+\s*\))?/datetime/i; print OUT; } close OUT; @@ -156,10 +158,6 @@ sub read_tables_sequences { # sub populate_data { my ($dbname, $args) = @_; - require UserLogin::mysql; - my $sys = new UserLogin::mysql(%{$args}, db => $dbname); - require UserLoginInit; - UserLoginInit::initial_populate($sys, $args{prefix}); } #