Changeset 14023 for trunk/ippTools/src/pzgetimfiles.c
- Timestamp:
- Jul 5, 2007, 3:16:08 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pzgetimfiles.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pzgetimfiles.c
r12131 r14023 161 161 "UPDATE summitExp" 162 162 " SET imfiles = %d" 163 " WHERE exp_ id= '%s'"163 " WHERE exp_name = '%s'" 164 164 " AND camera = '%s'" 165 165 " AND telescope = '%s'"; … … 178 178 "DELETE FROM pzPendingExp" 179 179 " WHERE" 180 " exp_ id= '%s'"180 " exp_name = '%s'" 181 181 " AND camera = '%s'" 182 182 " AND telescope = '%s'"; … … 220 220 { 221 221 char *query = 222 "CREATE TEMPORARY TABLE incoming (exp_ id VARCHAR(64), camera VARCHAR(64), telescope VARCHAR(64), file_id VARCHAR(64), bytes INT, md5sum VARCHAR(32), class VARCHAR(64), class_id VARCHAR(64), uri VARCHAR(255), PRIMARY KEY(exp_id, camera, telescope, class, class_id)) ENGINE=MEMORY";222 "CREATE TEMPORARY TABLE incoming (exp_name VARCHAR(64), camera VARCHAR(64), telescope VARCHAR(64), file_id VARCHAR(64), bytes INT, md5sum VARCHAR(32), class VARCHAR(64), class_id VARCHAR(64), uri VARCHAR(255), PRIMARY KEY(exp_name, camera, telescope, class, class_id)) ENGINE=MEMORY"; 223 223 224 224 if (!p_psDBRunQuery(config->dbh, query)) { … … 235 235 // load the imfiles (files) into the temp table 236 236 { 237 char *query = "INSERT INTO incoming (exp_ id, camera, telescope, file_id, bytes, md5sum, class, class_id, uri) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";237 char *query = "INSERT INTO incoming (exp_name, camera, telescope, file_id, bytes, md5sum, class, class_id, uri) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; 238 238 239 239 long inserted = p_psDBRunQueryPrepared(config->dbh, newImfiles, query); … … 270 270 "INSERT INTO pzPendingImfile" 271 271 " SElECT" 272 " incoming.exp_ id,"272 " incoming.exp_name," 273 273 " incoming.camera," 274 274 " incoming.telescope," 275 275 " incoming.class," 276 276 " incoming.class_id," 277 " NULL" // exp_ tag, will be assigned later277 " NULL" // exp_id, will be assigned later 278 278 " FROM incoming" 279 279 " JOIN pzPendingExp" 280 " USING(exp_ id, camera, telescope)"280 " USING(exp_name, camera, telescope)" 281 281 " LEFT JOIN summitImfile" 282 " USING(exp_ id, camera, telescope, class, class_id)"282 " USING(exp_name, camera, telescope, class, class_id)" 283 283 " WHERE" 284 " summitImfile.exp_ idis NULL"284 " summitImfile.exp_name is NULL" 285 285 " AND summitImfile.camera is NULL" 286 286 " AND summitImfile.telescope is NULL" … … 303 303 "INSERT INTO summitImfile" 304 304 " SElECT" 305 " incoming.exp_ id,"305 " incoming.exp_name," 306 306 " incoming.camera," 307 307 " incoming.telescope," … … 314 314 " FROM incoming" 315 315 " LEFT JOIN summitImfile" 316 " USING(exp_ id, camera, telescope, class, class_id)"316 " USING(exp_name, camera, telescope, class, class_id)" 317 317 " WHERE" 318 " summitImfile.exp_ idis NULL"318 " summitImfile.exp_name is NULL" 319 319 " AND summitImfile.camera is NULL" 320 320 " AND summitImfile.telescope is NULL" … … 338 338 " SET imfiles = (SELECT COUNT(*) FROM summitImfile" 339 339 " WHERE" 340 " exp_ id= '%s'"340 " exp_name = '%s'" 341 341 " AND camera = '%s'" 342 342 " AND telescope = '%s'" 343 343 ")" 344 344 " WHERE" 345 " exp_ id= '%s'"345 " exp_name = '%s'" 346 346 " AND camera = '%s'" 347 347 " AND telescope = '%s'"; … … 367 367 } 368 368 369 // copy the summitExp row into newExp in order to create a new exp_ tag370 { 371 psString exp_ tag= pxGenExpTag(config, filesetid);372 if (!exp_ tag) {369 // copy the summitExp row into newExp in order to create a new exp_id 370 { 371 psString exp_id = pxGenExpTag(config, filesetid); 372 if (!exp_id) { 373 373 // rollback 374 374 if (!psDBRollback(config->dbh)) { … … 382 382 "INSERT INTO newExp" 383 383 " SElECT" 384 " '%s'," // exp_ tag385 " summitExp.exp_ id,"384 " '%s'," // exp_id 385 " summitExp.exp_name," 386 386 " summitExp.camera," 387 387 " summitExp.telescope," … … 392 392 " FROM summitExp" 393 393 " WHERE" 394 " summitExp.exp_ id= '%s'"394 " summitExp.exp_name = '%s'" 395 395 " AND summitExp.camera = '%s'" 396 396 " AND summitExp.telescope = '%s'"; 397 397 398 if (!p_psDBRunQuery(config->dbh, query, exp_ tag, filesetid, camera, telescope)) {399 // rollback 400 if (!psDBRollback(config->dbh)) { 401 psError(PS_ERR_UNKNOWN, false, "database error"); 402 } 403 psError(PS_ERR_UNKNOWN, false, "database error"); 404 psFree(exp_ tag);405 return false; 406 } 407 psFree(exp_ tag);398 if (!p_psDBRunQuery(config->dbh, query, exp_id, filesetid, camera, telescope)) { 399 // rollback 400 if (!psDBRollback(config->dbh)) { 401 psError(PS_ERR_UNKNOWN, false, "database error"); 402 } 403 psError(PS_ERR_UNKNOWN, false, "database error"); 404 psFree(exp_id); 405 return false; 406 } 407 psFree(exp_id); 408 408 409 409 // sanity check: we should have inserted only one row … … 419 419 } 420 420 421 // set the exp_ tagfor the imfiles (files) in the exposure (fileset) that421 // set the exp_id for the imfiles (files) in the exposure (fileset) that 422 422 // we are investigating 423 423 { 424 424 char *query = 425 425 "UPDATE pzPendingImfile" 426 " SET exp_ tag = (SELECT exp_tagfrom newExp"427 " WHERE exp_ id= '%s'"426 " SET exp_id = (SELECT exp_id from newExp" 427 " WHERE exp_name = '%s'" 428 428 " AND camera = '%s'" 429 429 " AND telescope = '%s')" 430 430 " WHERE" 431 " exp_ id= '%s'"431 " exp_name = '%s'" 432 432 " AND camera = '%s'" 433 433 " AND telescope = '%s'"; … … 450 450 " FROM pzPendingExp" 451 451 " WHERE" 452 " pzPendingExp.exp_ id= '%s'"452 " pzPendingExp.exp_name = '%s'" 453 453 " AND pzPendingExp.camera = '%s'" 454 454 " AND pzPendingExp.telescope = '%s'"; … … 479 479 "DELETE FROM pzPendingExp" 480 480 " WHERE" 481 " exp_ id= '%s'"481 " exp_name = '%s'" 482 482 " AND camera = '%s'" 483 483 " AND telescope = '%s'"; … … 524 524 // any work 525 525 bool status = false; 526 psString exp_ id= psMetadataLookupStr(&status, config->args, "-filesetid");526 psString exp_name = psMetadataLookupStr(&status, config->args, "-filesetid"); 527 527 if (!status) { 528 528 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for '-filesetid'"); 529 529 return NULL; 530 530 } 531 if (!exp_ id) {531 if (!exp_name) { 532 532 psError(PS_ERR_UNKNOWN, true, "-filesetid is required"); 533 533 return NULL; … … 596 596 // create a new metadata to represent this line and it's values 597 597 psMetadata *md = psMetadataAlloc(); 598 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_ id", 0, NULL, exp_id)) {599 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");598 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_name", 0, NULL, exp_name)) { 599 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 600 600 psFree(md); 601 601 psFree(tokenCursor);
Note:
See TracChangeset
for help on using the changeset viewer.
