Changeset 23932 for trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
- Timestamp:
- Apr 20, 2009, 11:15:20 AM (17 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
lib/Nebulous/Server/SQL.pm (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server
-
Property svn:mergeinfo
set to
/branches/neb_distrib_20081210/Nebulous-Server merged eligible /trunk/Nebulous-Server merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r23699 r23932 8 8 use warnings FATAL => qw( all ); 9 9 10 our $VERSION = '0.0 2';10 our $VERSION = '0.04'; 11 11 12 12 use base qw( Class::Accessor::Fast ); … … 26 26 new_object => qq{ 27 27 INSERT INTO storage_object 28 (so_id, ext_id, type)29 VALUES (?, ?, 'REG_FILE')28 (so_id, ext_id, ext_id_basename, type, dir_id) 29 VALUES (?, ?, ?, 'REG_FILE', ?) 30 30 }, 31 31 new_object_attr => qq{ … … 60 60 USING (so_id) 61 61 WHERE ext_id = ? 62 }, 63 get_directory => qq{ 64 SELECT 65 dir_id 66 FROM directory 67 WHERE parent_id = ? 68 AND dirname = ? 69 }, 70 new_directory => qq{ 71 INSERT INTO directory 72 (dirname, parent_id) 73 VALUES (?, ?) 62 74 }, 63 75 check_object_name => qq{ … … 297 309 USING(vol_id) 298 310 }, 299 find_objects => qq{ 300 SELECT * 301 FROM storage_object 302 WHERE ext_id REGEXP ? 311 find_object_by_ext_id => qq{ 312 SELECT ext_id, ext_id_basename 313 FROM storage_object 314 WHERE ext_id = ? 315 }, 316 find_object_by_dir_id => qq{ 317 SELECT ext_id, ext_id_basename 318 FROM storage_object 319 WHERE dir_id = ? 303 320 }, 304 321 rename_object => qq{ 305 322 UPDATE storage_object 306 SET ext_id = ? 323 SET ext_id = ?, ext_id_basename = ?, dir_id = ? 307 324 WHERE ext_id = ? 308 325 }, … … 330 347 GROUP BY so_id 331 348 HAVING available_instances < instances OR instances < copies 349 }, 350 find_objects_with_extra_instances_by_xattr => qq{ 351 SELECT 352 so.so_id, 353 so.ext_id, 354 count(ins_id) as instances, 355 mv.name as volume_name, 356 mv.host as volume_host, 357 count(mv.vol_id) as available_instances, 358 xattr.value as copies 359 FROM storage_object AS so 360 JOIN storage_object_xattr as xattr 361 ON so.so_id = xattr.so_id 362 AND xattr.name = 'user.copies' 363 JOIN instance AS i 364 ON so.so_id = i.so_id 365 JOIN mountedvol AS mv 366 USING(vol_id) 367 WHERE 368 mv.available = 1 369 GROUP BY so_id 370 HAVING available_instances > copies 371 limit 5; 332 372 }, 333 373 find_objects_with_extra_instances => qq{ … … 387 427 DROP TABLE IF EXISTS log; 388 428 DROP TABLE IF EXISTS mountedvol; 429 DROP TABLE IF EXISTS directory; 389 430 DROP PROCEDURE IF EXISTS getmountedvol; 390 431 SET FOREIGN_KEY_CHECKS=1 … … 408 449 409 450 __DATA__ 451 CREATE TABLE directory ( 452 dir_id BIGINT NOT NULL AUTO_INCREMENT, 453 dirname CHAR(255) NOT NULL, 454 parent_id BIGINT NOT NULL, 455 FOREIGN KEY(parent_id) REFERENCES directory(dir_id), 456 PRIMARY KEY(dir_id), 457 KEY(parent_id) 458 ) ENGINE=innodb DEFAULT CHARSET=latin1; 459 460 ### 461 462 INSERT INTO directory (dir_id, dirname, parent_id) VALUES (1, '/', 1); 463 464 ### 465 410 466 CREATE TABLE storage_object ( 411 467 so_id BIGINT NOT NULL AUTO_INCREMENT, 412 468 ext_id VARCHAR(255) NOT NULL UNIQUE, 469 ext_id_basename VARCHAR(255) NOT NULL, 470 dir_id BIGINT NOT NULL, 471 FOREIGN KEY(dir_id) REFERENCES directory(dir_id), 413 472 type enum('REG_FILE'), 414 473 PRIMARY KEY(so_id),
Note:
See TracChangeset
for help on using the changeset viewer.
