Changeset 63 for trunk/cgi-bin


Ignore:
Timestamp:
11/12/04 11:52:03 (20 years ago)
Author:
Kris Deugau
Message:

/trunk

Clean up some error handling code relating to DB transactions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/main.cgi

    r61 r63  
    118118    $sth = $ip_dbh->prepare("insert into masterblocks values ('$webvar{cidr}')");
    119119    $sth->execute;
    120 # Don't need this with RaiseError, but leave it for now.
    121 #    croak $sth->errstr if ($sth->errstr());
    122120
    123121# Unrouted blocks aren't associated with a city (yet).  We don't rely on this
     
    128126        $cidr->masklen.",'<NULL>','n')");
    129127    $sth->execute;
    130 # Don't need this with RaiseError, but leave it for now.
    131 #    croak $sth->errstr if ($sth->errstr());
    132128
    133129    # If we get here, everything is happy.  Commit changes.
     
    998994# Allow transactions, and make errors much easier to catch.
    999995# Much as I would like to error-track specifically on each ->execute,
    1000 # that's a LOT of code.  :/
    1001     $ip_dbh->{AutoCommit} = 0;
    1002     $ip_dbh->{RaiseError} = 1;
     996# that's a LOT of code, and some SQL blocks MUST be atomic at a
     997# multi-statement level.  :/
     998    local $ip_dbh->{AutoCommit} = 0;    # These need to be local so we don't
     999    local $ip_dbh->{RaiseError} = 1;    # step on our toes by accident.
    10031000
    10041001    if ($webvar{fullcidr} eq $webvar{alloc_from}) {
     
    11331130    syslog "notice", "$full_alloc_types{$webvar{alloctype}} '$webvar{fullcidr}' successfully initialized by $authuser";
    11341131
    1135     # Turn off transactions and exception-on-error'ing
    1136     $ip_dbh->{AutoCommit} = 0;
    1137     $ip_dbh->{RaiseError} = 1;
    1138 
    11391132    print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was sucessfully added as type '$webvar{alloctype}' ($full_alloc_types{$webvar{alloctype}})</div></div>);
    11401133
Note: See TracChangeset for help on using the changeset viewer.