Changeset 16588 for trunk/ippTools/src/pzgetimfiles.c
- Timestamp:
- Feb 21, 2008, 6:09:46 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pzgetimfiles.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pzgetimfiles.c
r16170 r16588 226 226 psFree(newImfiles); 227 227 228 // queue the imfiles (files) dest. for pzPendingImfile in pending -- must229 // be done before the imfile is insterted into summitImfile (after that230 // happens when don't know which imfiles are new anymore (well thats not231 // exactly true but it may be someday if we have to beable to resync to232 // modified datastore entries)233 {234 char *query =235 "INSERT IGNORE INTO pzPendingImfile"236 " SElECT"237 " incoming.exp_name,"238 " incoming.camera,"239 " incoming.telescope,"240 " incoming.class,"241 " incoming.class_id"242 " FROM incoming";243 244 if (!p_psDBRunQuery(config->dbh, query)) {245 // rollback246 if (!psDBRollback(config->dbh)) {247 psError(PS_ERR_UNKNOWN, false, "database error");248 }249 psError(PS_ERR_UNKNOWN, false, "database error");250 return false;251 }252 }253 254 228 // copy imfiles (files) from the temp table into summitImfiles 255 229 { 256 230 char *query = 257 231 "INSERT IGNORE INTO summitImfile" 258 " SE lECT"232 " SELECT" 259 233 " incoming.exp_name," 260 234 " incoming.camera," … … 313 287 } 314 288 315 // cp the pzPendingExp entry to pzDoneExp 289 // add new exps to pzDownloadExp -- must be done before the new exps are 290 // added to summitExp because of the SQL logic 316 291 { 317 292 char *query = 318 "INSERT INTO pzDo neExp"293 "INSERT INTO pzDownloadExp" 319 294 " SELECT" 320 " pzPendingExp.*" 321 " FROM pzPendingExp" 295 " incoming.exp_name," 296 " incoming.camera," 297 " incoming.telescope," 298 " \"run\"" 299 " FROM incoming" 300 " LEFT JOIN pzDownloadExp" 301 " USING(exp_name, camera, telescope)" 322 302 " WHERE" 323 " pzPendingExp.exp_name = '%s'" 324 " AND pzPendingExp.camera = '%s'" 325 " AND pzPendingExp.telescope = '%s'"; 326 if (!p_psDBRunQuery(config->dbh, query, filesetid, camera, telescope)) { 327 // rollback 328 if (!psDBRollback(config->dbh)) { 329 psError(PS_ERR_UNKNOWN, false, "database error"); 330 } 331 psError(PS_ERR_UNKNOWN, false, "database error"); 332 return false; 333 } 334 335 // sanity check: we should have inserted only one row 336 psU64 affected = psDBAffectedRows(config->dbh); 337 if (psDBAffectedRows(config->dbh) != 1) { 338 // rollback 339 if (!psDBRollback(config->dbh)) { 340 psError(PS_ERR_UNKNOWN, false, "database error"); 341 } 342 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row but %" PRIu64 " rows were modified", affected); 343 return false; 344 } 345 } 346 347 // remove the pzPendingExp entry for this exp (fileset) 348 { 349 char *query = 350 "DELETE FROM pzPendingExp" 351 " WHERE" 352 " exp_name = '%s'" 353 " AND camera = '%s'" 354 " AND telescope = '%s'"; 355 if (!p_psDBRunQuery(config->dbh, query, filesetid, camera, telescope)) { 356 // rollback 357 if (!psDBRollback(config->dbh)) { 358 psError(PS_ERR_UNKNOWN, false, "database error"); 359 } 360 psError(PS_ERR_UNKNOWN, false, "database error"); 361 return false; 362 } 363 364 // sanity check: we should have removed only one row 365 psU64 affected = psDBAffectedRows(config->dbh); 366 if (psDBAffectedRows(config->dbh) != 1) { 367 // rollback 368 if (!psDBRollback(config->dbh)) { 369 psError(PS_ERR_UNKNOWN, false, "database error"); 370 } 371 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row but %" PRIu64 " rows were modified", affected); 303 " pzDownloadExp.exp_name is NULL" 304 " AND pzDownloadExp.camera is NULL" 305 " AND pzDownloadExp.telescope is NULL" 306 " GROUP BY" 307 " incoming.exp_name," 308 " incoming.camera," 309 " incoming.telescope"; 310 311 if (!p_psDBRunQuery(config->dbh, query)) { 312 // rollback 313 if (!psDBRollback(config->dbh)) { 314 psError(PS_ERR_UNKNOWN, false, "database error"); 315 } 316 psError(PS_ERR_UNKNOWN, false, "database error"); 372 317 return false; 373 318 }
Note:
See TracChangeset
for help on using the changeset viewer.
