Changeset 13071 for trunk/Nebulous/lib
- Timestamp:
- Apr 27, 2007, 2:44:58 PM (19 years ago)
- Location:
- trunk/Nebulous/lib/Nebulous
- Files:
-
- 2 edited
-
Server.pm (modified) (2 diffs)
-
Server/SQL.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/lib/Nebulous/Server.pm
r13047 r13071 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.2 5 2007-04-26 23:45:03jhoblitt Exp $3 # $Id: Server.pm,v 1.26 2007-04-28 00:44:38 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 236 236 } 237 237 238 sub rename_object { 239 my $self = shift; 240 241 my ( $key, $newkey ) = validate_pos( @_, 242 { 243 type => SCALAR, 244 }, 245 { 246 type => SCALAR, 247 }, 248 ); 249 250 my $log = $self->log; 251 my $sql = $self->sql; 252 my $db =$self->db; 253 254 $log->debug( "entered - @_" ); 255 256 eval { 257 # rename storage_object 258 my $query = $db->prepare_cached($sql->rename_object); 259 # this SQL statment takes the new key name as the first param 260 my $rows = $query->execute($newkey, $key); 261 262 # if we affected more then one row something very bad has happened. 263 unless ( $rows == 1 ) { 264 $log->logdie( "affected row count is $rows instead of 1" ); 265 } 266 }; 267 if ($@) { 268 $db->rollback; 269 $log->logdie( "database error: $@" ); 270 } 271 272 eval { 273 $db->commit; 274 }; 275 if ( $@ ) { 276 $db->rollback; 277 $log->logdie( "database error: $@" ); 278 } 279 280 $log->debug( "leaving" ); 281 282 return $newkey; 283 } 284 238 285 sub replicate_object { 239 286 my $self = shift; -
trunk/Nebulous/lib/Nebulous/Server/SQL.pm
r13047 r13071 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: SQL.pm,v 1.2 7 2007-04-26 23:45:03jhoblitt Exp $3 # $Id: SQL.pm,v 1.28 2007-04-28 00:44:38 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server::SQL; … … 153 153 FROM storage_object 154 154 WHERE ext_id REGEXP ? 155 }, 156 rename_object => qq{ 157 UPDATE storage_object 158 SET ext_id = ? 159 WHERE ext_id = ? 155 160 }, 156 161 );
Note:
See TracChangeset
for help on using the changeset viewer.
