[freeside-commits] freeside/FS/FS Upgrade.pm,1.11,1.12
Ivan,,,
ivan at wavetail.420.am
Tue Jun 10 16:24:20 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv20043
Modified Files:
Upgrade.pm
Log Message:
start of better error reporting for RADIUS upgrade errors
Index: Upgrade.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Upgrade.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Upgrade.pm 30 May 2008 01:34:29 -0000 1.11
+++ Upgrade.pm 10 Jun 2008 23:24:16 -0000 1.12
@@ -121,6 +121,9 @@
( map $part_export->option($_), qw ( datasrc username password ) ),
{ PrintError => 0, PrintWarn => 0 }
);
+
+ my $errmsg = 'Error adding FreesideStatus to '.
+ $part_export->option('datasrc'). ': ';
my $str2time = str2time_sql( $dbh->{Driver}->{Name} );
my $group = "UserName";
@@ -130,18 +133,32 @@
my $sth_alter = $dbh->prepare(
"ALTER TABLE radacct ADD COLUMN FreesideStatus varchar(32) NULL"
);
- if ( $sth_alter && $sth_alter->execute ) {
- my $sth_update = $dbh->prepare(
- "UPDATE radacct SET FreesideStatus = 'done' WHERE FreesideStatus IS NULL"
- ) or die $dbh->errstr;
- $sth_update->execute or die $sth_update->errstr;
+ if ( $sth_alter ) {
+ if ( $sth_alter->execute ) {
+ my $sth_update = $dbh->prepare(
+ "UPDATE radacct SET FreesideStatus = 'done' WHERE FreesideStatus IS NULL"
+ ) or die $errmsg.$dbh->errstr;
+ $sth_update->execute or die $errmsg.$sth_update->errstr;
+ } else {
+ my $error = $sth_alter->errstr;
+ warn $errmsg.$error; #unless $error =~ /exists/i;
+ }
+ } else {
+ my $error = $dbh->errstr;
+ warn $errmsg.$error; #unless $error =~ /exists/i;
}
my $sth_index = $dbh->prepare(
"CREATE INDEX FreesideStatus ON radacct ( FreesideStatus )"
);
if ( $sth_index ) {
- $sth_index->execute;
+ unless ( $sth_index->execute ) {
+ my $error = $sth_index->errstr;
+ warn $errmsg.$error; #unless $error =~ /exists/i;
+ }
+ } else {
+ my $error = $dbh->errstr;
+ warn $errmsg.$error; #unless $error =~ /exists/i;
}
my $sth = $dbh->prepare("SELECT UserName,
@@ -154,8 +171,8 @@
AND AcctStopTime != 0
GROUP BY $group
")
- or die $dbh->errstr;
- $sth->execute() or die $sth->errstr;
+ or die $errmsg.$dbh->errstr;
+ $sth->execute() or die $errmsg.$sth->errstr;
while (my $row = $sth->fetchrow_arrayref ) {
my ($username, $realm, $start, $stop) = @$row;
More information about the freeside-commits
mailing list