IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 18, 2009, 4:48:52 PM (17 years ago)
Author:
jhoblitt
Message:

rework delete_instance() to avoid requiring an index on instance.uri

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r24412 r24500  
    15811581TRANS: while (1) {
    15821582        eval {
     1583            my $instances;
    15831584            my $so_id;
    1584             my $instances;
    1585             # get so_id
     1585            my $ins_id;
     1586            # find so_id for key and get count of instances
    15861587            {
    1587                 my $query = $db->prepare_cached( $sql->get_object_from_uri );
    1588                 my $rows = $query->execute( $uri );
    1589 
     1588                my $query = $db->prepare_cached( $sql->get_instance_count_by_ext_id );
     1589                my $rows = $query->execute($key->path);
    15901590                unless ( $rows > 0 ) {
    15911591                    $query->finish;
     1592                    die( "$key has no associated instances - this should not happen" );
     1593                }
     1594
     1595                my $record = $query->fetchrow_hashref;
     1596                $so_id      = $record->{ 'so_id' };
     1597                $instances  = $record->{ 'count(ins_id)' };
     1598                $query->finish;
     1599            }
     1600
     1601            # find ins_id for uri
     1602            {
     1603                my $query = $db->prepare_cached( $sql->get_instance_by_uri );
     1604                my $rows = $query->execute($so_id, $uri);
     1605                unless ( $rows > 0) {
     1606                    $query->finish;
    15921607                    die( "no instance is associated with uri" );
    15931608                }
    15941609
    1595                 $so_id = $query->fetchrow_hashref->{ 'so_id' };
    1596                 $query->finish;
    1597 
    1598             }
    1599 
    1600             {
    1601                 my $query = $db->prepare_cached( $sql->get_instance_count );
    1602                 $query->execute( $so_id );
    1603 
    1604                 $instances = $query->fetchrow_hashref->{ 'count(ins_id)' };
     1610                $ins_id = $query->fetchrow_hashref->{ 'ins_id' };
    16051611                $query->finish;
    16061612            }
     
    16081614            # remove instance
    16091615            {
    1610                 my $query = $db->prepare_cached( $sql->delete_instance );
    1611                 my $rows = $query->execute( $uri );
     1616                my $query = $db->prepare_cached( $sql->delete_instance_by_ins_id );
     1617                my $rows = $query->execute( $ins_id );
    16121618                $query->finish;
    16131619               
    1614                 # if we affected something other then two rows something very bad
    1615                 # has happened
     1620                # if we affected something other then one row something very
     1621                # bad has happened
    16161622                unless ( $rows == 1 ) {
    16171623                    die( "affected row count is $rows instead of 1" );
Note: See TracChangeset for help on using the changeset viewer.