Changeset 13251 for trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
- Timestamp:
- May 4, 2007, 1:36:46 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r13245 r13251 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: SQL.pm,v 1. 39 2007-05-04 21:20:43jhoblitt Exp $3 # $Id: SQL.pm,v 1.40 2007-05-04 23:36:46 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server::SQL; … … 274 274 DROP TABLE IF EXISTS class; 275 275 DROP TABLE IF EXISTS log; 276 DROP TABLE IF EXISTS mountedvol; 276 277 DROP PROCEDURE IF EXISTS getmountedvol; 277 278 SET FOREIGN_KEY_CHECKS=1 … … 386 387 ### 387 388 389 CREATE TABLE mountedvol( 390 mountpoint VARCHAR(255) NOT NULL, 391 total BIGINT NOT NULL, 392 used BIGINT NOT NULL, 393 vol_id INT NOT NULL, 394 name VARCHAR(255) NOT NULL, 395 path VARCHAR(255) NOT NULL, 396 allocate BOOLEAN DEFAULT FALSE, 397 available BOOLEAN DEFAULT FALSE, 398 KEY(vol_id), 399 KEY(allocate), 400 KEY(available) 401 ) ENGINE=innodb; 402 403 ### 404 388 405 CREATE PROCEDURE getmountedvol() DETERMINISTIC 389 406 BEGIN … … 401 418 SELECT @@session.tx_isolation INTO trans_level; 402 419 403 -- set trans level 420 -- set trans level to repeatable-read so the volume table does not change 421 -- out from under our cursor 404 422 SET @@session.tx_isolation = 'REPEATABLE-READ'; 405 406 -- create a temp table to hold the merged results of the volume & mount407 -- tables. One would hope the that the transaction isolation level will408 -- stop one session from stomping on another sessions version of this409 -- table.410 411 DROP TABLE IF EXISTS mountedvol;412 CREATE TEMPORARY TABLE mountedvol(413 mountpoint VARCHAR(255) NOT NULL,414 total BIGINT NOT NULL,415 used BIGINT NOT NULL,416 vol_id INT NOT NULL,417 name VARCHAR(255) NOT NULL,418 path VARCHAR(255) NOT NULL,419 allocate BOOLEAN DEFAULT FALSE,420 available BOOLEAN DEFAULT FALSE,421 KEY(vol_id),422 KEY(allocate),423 KEY(available)424 ) ENGINE=MEMORY;425 423 426 424 -- iterate over the volume table finding the coresponding entry in the 427 425 -- mount table and inserting union of the volume & mount row into the 428 426 -- mountedvol table 429 430 427 OPEN cur1; 428 429 DELETE FROM mountedvol; 431 430 432 431 myloop: LOOP … … 446 445 -- restore the original transaction level 447 446 SET @@session.tx_isolation = trans_level; 447 448 COMMIT; 448 449 END
Note:
See TracChangeset
for help on using the changeset viewer.
