Changeset 23 for trunk/DNSDB.pm
- Timestamp:
- 10/20/09 14:47:36 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r22 r23 226 226 local $dbh->{RaiseError} = 1; 227 227 228 my $failmsg = ''; 229 228 230 # Wrap all the SQL in a transaction 229 231 eval { 230 232 my $sth = $dbh->prepare("delete from records where domain_id=?"); 233 $failmsg = "Failure removing domain records"; 231 234 $sth->execute($domid); 232 235 $sth = $dbh->prepare("delete from domains where domain_id=?"); 236 $failmsg = "Failure removing domain"; 233 237 $sth->execute($domid); 234 238 235 #die "full of fail\n";236 239 # once we get here, we should have suceeded. 237 #$dbh->commit;240 $dbh->commit; 238 241 }; # end eval 239 242 … … 241 244 my $msg = $@; 242 245 eval { $dbh->rollback; }; 243 return ('FAIL', $msg);246 return ('FAIL',"$failmsg: $msg"); 244 247 } else { 245 248 return ('OK','OK'); … … 340 343 341 344 ##fixme: locate "knowable" error conditions and deal with them before the eval 345 # ... or inside, whatever. 342 346 # -> domains still exist in group 343 347 # -> ... 348 my $failmsg = ''; 344 349 345 350 # Wrap all the SQL in a transaction 346 351 eval { 347 my $sth = $dbh->prepare("delete from default_records where group_id=?"); 352 my $sth = $dbh->prepare("SELECT count(*) FROM domains WHERE group_id=?"); 353 $sth->execute($groupid); 354 my ($domcnt) = $sth->fetchrow_array; 355 $failmsg = "Can't remove group ".groupName($dbh,$groupid); 356 die "$domcnt domains still in group\n" if $domcnt; 357 358 $sth = $dbh->prepare("delete from default_records where group_id=?"); 359 $failmsg = "Failed to delete default records for ".groupName($dbh,$groupid); 348 360 $sth->execute($groupid); 349 361 $sth = $dbh->prepare("delete from groups where group_id=?"); 362 $failmsg = "Failed to remove group ".groupName($dbh,$groupid); 350 363 $sth->execute($groupid); 351 364 352 die "epic group fail FTW!\n";353 365 # once we get here, we should have suceeded. 354 366 $dbh->commit; … … 358 370 my $msg = $@; 359 371 eval { $dbh->rollback; }; 360 return ('FAIL', $msg);372 return ('FAIL',"$failmsg: $msg"); 361 373 } else { 362 374 return ('OK','OK'); … … 447 459 $sql .= " records where domain_id=$id and type=$reverse_typemap{SOA}"; 448 460 } 449 #print "getSOA DEBUG: $sql<br>\n";450 461 my $sth = $dbh->prepare($sql); 451 462 $sth->execute; … … 649 660 $sth->execute($id); 650 661 651 return ('FAIL', $sth->errstr) if $sth->err;662 return ('FAIL',"Couldn't remove record: ".$sth->errstr) if $sth->err; 652 663 653 664 return ('OK','OK');
Note:
See TracChangeset
for help on using the changeset viewer.