Changeset 16588
- Timestamp:
- Feb 21, 2008, 6:09:46 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
dbconfig/tasks.md (modified) (3 diffs)
-
ippTools/share/pztool_find_completed_exp.sql (modified) (1 diff)
-
ippTools/share/pztool_pendingimfile.sql (modified) (1 diff)
-
ippTools/share/pztool_revertcopied.sql (modified) (1 diff)
-
ippTools/src/pxadminConfig.c (modified) (2 diffs)
-
ippTools/src/pxtables.c (modified) (2 diffs)
-
ippTools/src/pzgetexp.c (modified) (2 diffs)
-
ippTools/src/pzgetimfiles.c (modified) (2 diffs)
-
ippTools/src/pztool.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dbconfig/tasks.md
r16509 r16588 1 # $Id: tasks.md,v 1.14 7 2008-02-15 19:54:44 eugeneExp $1 # $Id: tasks.md,v 1.148 2008-02-22 04:09:46 jhoblitt Exp $ 2 2 3 3 # this table records all exposure ID ever seen from the summit … … 43 43 # list of source images -- updated as exposures/filesets are queried 44 44 summitImfile METADATA 45 exp_name STR 64 # Primary Key 45 exp_name STR 64 # Primary Key fkey(exp_name, camera, telescope) ref summitExp(exp_name, camera, telescope) 46 46 camera STR 64 # Primary Key 47 47 telescope STR 64 # Primary Key … … 56 56 # list of exposures that have had their imfiles/files registered (but not 57 57 # downloaded) 58 pzPendingExp METADATA 59 exp_name STR 64 # Primary Key 60 camera STR 64 # Primary Key 61 telescope STR 64 # Primary Key 62 END 63 64 pzPendingImfile METADATA 65 exp_name STR 64 # Primary Key 66 camera STR 64 # Primary Key 67 telescope STR 64 # Primary Key 68 class STR 64 # Primary Key 69 class_id STR 64 # Primary Key 70 END 71 72 # list of exposures that have had all of their imfiles downloaded 73 pzDoneExp METADATA 74 exp_name STR 64 # Primary Key 75 camera STR 64 # Primary Key 76 telescope STR 64 # Primary Key 77 END 78 79 pzDoneImfile METADATA 80 exp_name STR 64 # Primary Key 81 camera STR 64 # Primary Key 58 pzDownloadExp METADATA 59 exp_name STR 64 # Primary Key fkey(exp_name, camera, telescope) ref summitExp(exp_name, camera, telescope) 60 camera STR 64 # Primary Key 61 telescope STR 64 # Primary Key 62 state STR 64 # Key 63 END 64 65 pzDownloadImfile METADATA 66 exp_name STR 64 # Primary Key fkey(exp_name, camera, telescope) ref pzDownloadExp(exp_name, camera, telescope) 67 camera STR 64 # Primary Key fkey(exp_name, camera, telescope, class, class_id) ref summitImfile(exp_name, camera, telescope, class, class_id) 82 68 telescope STR 64 # Primary Key 83 69 class STR 64 # Primary Key -
trunk/ippTools/share/pztool_find_completed_exp.sql
r16334 r16588 1 1 SELECT DISTINCT 2 exp_name, -- return should match pzDo neExp2 exp_name, -- return should match pzDownloadExp 3 3 camera, 4 telescope 4 telescope, 5 state 5 6 FROM ( 6 7 SELECT 7 pzDoneImfile.*, 8 pzDownloadImfile.*, 9 pzDownloadExp.state, 8 10 summitExp.imfiles 9 FROM pzDo neExp11 FROM pzDownloadExp 10 12 JOIN summitExp 11 13 USING(exp_name, camera, telescope) 12 LEFT JOIN pzDo neImfile14 LEFT JOIN pzDownloadImfile 13 15 USING(exp_name, camera, telescope) 14 16 LEFT JOIN newExp 15 ON pzDo neExp.exp_name = newExp.tmp_exp_name16 AND pzDo neExp.camera = newExp.tmp_camera17 AND pzDo neExp.telescope = newExp.tmp_telescope17 ON pzDownloadExp.exp_name = newExp.tmp_exp_name 18 AND pzDownloadExp.camera = newExp.tmp_camera 19 AND pzDownloadExp.telescope = newExp.tmp_telescope 18 20 WHERE 19 newExp.tmp_exp_name IS NULL 21 pzDownloadExp.state = 'run' 22 AND newExp.tmp_exp_name IS NULL 20 23 AND newExp.tmp_camera IS NULL 21 24 AND newExp.tmp_telescope IS NULL 22 25 GROUP BY 23 pzDo neExp.exp_name,24 pzDo neExp.camera,25 pzDo neExp.telescope26 -- it doesn't matter which field in pzDo neImfile we count as we've already27 -- donea group by26 pzDownloadExp.exp_name, 27 pzDownloadExp.camera, 28 pzDownloadExp.telescope 29 -- it doesn't matter which field in pzDownloadImfile we count as we've 30 -- already Download a group by 28 31 HAVING 29 COUNT(pzDo neImfile.exp_name) = summitExp.imfiles30 AND SUM(pzDo neImfile.fault) = 032 COUNT(pzDownloadImfile.exp_name) = summitExp.imfiles 33 AND SUM(pzDownloadImfile.fault) = 0 31 34 ) as Foo -
trunk/ippTools/share/pztool_pendingimfile.sql
r15821 r16588 4 4 summitImfile.*, 5 5 summitExp.dateobs 6 FROM pzPendingImfile 7 JOIN summitImfile 6 FROM summitImfile 7 JOIN pzDownloadExp 8 USING(exp_name, camera, telescope) 9 JOIN pzDownloadImfile 8 10 USING(exp_name, camera, telescope, class, class_id) 9 11 JOIN summitExp 10 12 USING(exp_name, camera, telescope) 13 WHERE 14 pzDownloadExp.state = 'run' 11 15 ORDER BY 12 16 summitExp.dateobs -
trunk/ippTools/share/pztool_revertcopied.sql
r16364 r16588 1 DELETE FROM pzDo neImfile1 DELETE FROM pzDownloadImfile 2 2 WHERE 3 3 fault != 0 -
trunk/ippTools/src/pxadminConfig.c
r16507 r16588 31 31 bool status; 32 32 33 fprintf (stderr, "\nPan-STARRS Phase 2Admin Tool\n\n");33 fprintf (stderr, "\nPan-STARRS DataBase Admin Tool\n\n"); 34 34 fprintf (stderr, "Usage: %s [mode]\n", program); 35 35 fprintf (stderr, " [mode] : -create | -delete\n\n"); … … 90 90 // paul's argument parsing convention requires: -key value 91 91 psMetadataAddStr(arguments, PS_LIST_TAIL, "-create", 0, 92 "create the P2tables", "");92 "create all IPP tables", ""); 93 93 psMetadataAddStr(arguments, PS_LIST_TAIL, "-delete", 0, 94 "delete the P2tables", "");94 "delete all IPP tables", ""); 95 95 psMetadataAddStr(arguments, PS_LIST_TAIL, "-recreate", 0, 96 "delete and recreate the P2tables", "");96 "delete and recreate all tables", ""); 97 97 98 98 if (config->mode == PXADMIN_MODE_NONE) { -
trunk/ippTools/src/pxtables.c
r16508 r16588 54 54 CREATE_TABLE(summitExpCreateTable); 55 55 CREATE_TABLE(summitImfileCreateTable); 56 CREATE_TABLE(pzPendingExpCreateTable); 57 CREATE_TABLE(pzPendingImfileCreateTable); 58 CREATE_TABLE(pzDoneExpCreateTable); 59 CREATE_TABLE(pzDoneImfileCreateTable); 56 // CREATE_TABLE(pzPendingExpCreateTable); 57 // CREATE_TABLE(pzPendingImfileCreateTable); 58 // CREATE_TABLE(pzDoneExpCreateTable); 59 // CREATE_TABLE(pzDoneImfileCreateTable); 60 CREATE_TABLE(pzDownloadExpCreateTable); 61 CREATE_TABLE(pzDownloadImfileCreateTable); 60 62 CREATE_TABLE(newExpCreateTable); 61 63 CREATE_TABLE(newImfileCreateTable); … … 151 153 DROP_TABLE(summitExpDropTable); 152 154 DROP_TABLE(summitImfileDropTable); 153 DROP_TABLE(pzPendingExpDropTable); 154 DROP_TABLE(pzPendingImfileDropTable); 155 DROP_TABLE(pzDoneExpDropTable); 156 DROP_TABLE(pzDoneImfileDropTable); 155 // DROP_TABLE(pzPendingExpDropTable); 156 // DROP_TABLE(pzPendingImfileDropTable); 157 // DROP_TABLE(pzDoneExpDropTable); 158 // DROP_TABLE(pzDoneImfileDropTable); 159 DROP_TABLE(pzDownloadExpDropTable); 160 DROP_TABLE(pzDownloadImfileDropTable); 157 161 DROP_TABLE(newExpDropTable); 158 162 DROP_TABLE(newImfileDropTable); -
trunk/ippTools/src/pzgetexp.c
r16170 r16588 2 2 * pzgetexp.c 3 3 * 4 * Copyright (C) 2006 Joshua Hoblitt4 * Copyright (C) 2006-2008 Joshua Hoblitt 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it … … 186 186 psFree(newSummitExps); 187 187 188 // add new exps to pzPendingExp -- must be done before the new exps are189 // added to summitExp because of the SQL logic190 {191 char *query =192 "INSERT INTO pzPendingExp"193 " SElECT"194 " incoming.exp_name,"195 " incoming.camera,"196 " incoming.telescope"197 " FROM incoming"198 " LEFT JOIN summitExp"199 " USING(exp_name, camera, telescope)"200 " WHERE"201 " summitExp.exp_name is NULL"202 " AND summitExp.camera is NULL"203 " AND summitExp.telescope is NULL";204 205 if (!p_psDBRunQuery(config->dbh, query)) {206 // rollback207 if (!psDBRollback(config->dbh)) {208 psError(PS_ERR_UNKNOWN, false, "database error");209 }210 psError(PS_ERR_UNKNOWN, false, "database error");211 return false;212 }213 }214 215 188 // add new exps to summitExp 216 189 { -
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 } -
trunk/ippTools/src/pztool.c
r16509 r16588 45 45 static psArray *pzGetPendingCameras(pxConfig *config); 46 46 static psArray *pzArrayZip(psArray *arraySet, psS64 limit); 47 static bool pzDownloadExpSetState(pxConfig *config, const char *exp_name, const char *camera, const char *telescope, const char *state); 47 48 48 49 # define MODECASE(caseName, func) \ … … 204 205 "SELECT" 205 206 " summitExp.*" 206 " FROM pzPendingExp"207 " JOIN summitExp"207 " FROM summitExp" 208 " LEFT JOIN pzDownloadExp" 208 209 " USING(exp_name, camera, telescope)" 210 " WHERE" 211 " pzDownloadExp.exp_name IS NULL" 212 " AND pzDownloadExp.camera IS NULL" 213 " AND pzDownloadExp.telescope IS NULL" 209 214 ); 210 215 211 216 if (config->where) { 212 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pz PendingExp");217 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pzDownloadExp"); 213 218 psStringAppend(&query, " AND %s", whereClause); 214 219 psFree(whereClause); … … 281 286 282 287 if (config->where) { 283 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pz PendingImfile");288 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pzDownloadImfile"); 284 289 psStringAppend(&query, " AND %s", whereClause); 285 290 psFree(whereClause); … … 355 360 356 361 // need to know exp_name, camera, telescope, class, class_id (to find the 357 // pz PendingImfile entry and the URI for the newImfile entry.362 // pzDownloadImfile entry and the URI for the newImfile entry. 358 363 359 364 // start a transaction so it's all rows or nothing … … 363 368 } 364 369 365 // cp the imfile into pzDo neImfile370 // cp the imfile into pzDownloadImfile 366 371 { 367 372 char *query = 368 "INSERT INTO pzDo neImfile"373 "INSERT INTO pzDownloadImfile" 369 374 " SELECT" 370 " pzPendingImfile.*," 375 " exp_name," 376 " camera," 377 " telescope," 378 " class," 379 " class_id," 371 380 " '%s'," // uri of downloaded file 372 381 " '%d'" // fault code 373 " FROM pzPendingImfile"382 " FROM summitImfile" 374 383 " WHERE" 375 " pzPendingImfile.exp_name = '%s'"376 " AND pzPendingImfile.camera = '%s'"377 " AND pzPendingImfile.telescope = '%s'"378 " AND pzPendingImfile.class = '%s'"379 " AND pzPendingImfile.class_id = '%s'";384 " summitImfile.exp_name = '%s'" 385 " AND summitImfile.camera = '%s'" 386 " AND summitImfile.telescope = '%s'" 387 " AND summitImfile.class = '%s'" 388 " AND summitImfile.class_id = '%s'"; 380 389 381 390 if (!p_psDBRunQuery(config->dbh, query, uri, code, exp_name, camera, telescope, class, class_id)) { … … 400 409 } 401 410 402 // removve the entry from pzPendingImfile 403 { 404 char *query = 405 "DELETE FROM pzPendingImfile" 406 " WHERE" 407 " pzPendingImfile.exp_name = '%s'" 408 " AND pzPendingImfile.camera = '%s'" 409 " AND pzPendingImfile.telescope = '%s'" 410 " AND pzPendingImfile.class = '%s'" 411 " AND pzPendingImfile.class_id = '%s'"; 412 413 if (!p_psDBRunQuery(config->dbh, query, exp_name, camera, telescope, class, class_id)) { 414 // rollback 415 if (!psDBRollback(config->dbh)) { 416 psError(PS_ERR_UNKNOWN, false, "database error"); 417 } 411 if (!copydoneCompleteExp(config)) { 412 // rollback 413 if (!psDBRollback(config->dbh)) { 418 414 psError(PS_ERR_UNKNOWN, false, "database error"); 419 return false; 420 } 421 422 // sanity check: we should have removed only one row 423 psU64 affected = psDBAffectedRows(config->dbh); 424 if (psDBAffectedRows(config->dbh) != 1) { 425 // rollback 426 if (!psDBRollback(config->dbh)) { 427 psError(PS_ERR_UNKNOWN, false, "database error"); 428 } 429 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row but %" PRIu64 " rows were modified", affected); 430 return false; 431 } 415 } 416 psError(PS_ERR_UNKNOWN, false, "copydoneCompleteExp() failed"); 417 return false; 432 418 } 433 419 … … 439 425 } 440 426 psError(PS_ERR_UNKNOWN, false, "database error"); 441 return false;442 }443 444 if (!copydoneCompleteExp(config)) {445 psError(PS_ERR_UNKNOWN, false, "copydoneCompleteExp() failed");446 427 return false; 447 428 } … … 493 474 } 494 475 495 // start a transaction so all newExp's can start off with a state of run496 if (!psDBTransaction(config->dbh)) {497 psError(PS_ERR_UNKNOWN, false, "database error");498 psFree(output);499 return false;500 }501 502 503 476 for (long i = 0; i < psArrayLength(output); i++) { 504 477 psMetadata *row = output->data[i]; 505 478 506 pzDo neExpRow *doneExp = pzDoneExpObjectFromMetadata(row);479 pzDownloadExpRow *doneExp = pzDownloadExpObjectFromMetadata(row); 507 480 508 481 if (!newExpInsert(config->dbh, … … 521 494 ) 522 495 ) { 523 // rollback524 if (!psDBRollback(config->dbh)) {525 psError(PS_ERR_UNKNOWN, false, "database error");526 }527 496 psError(PS_ERR_UNKNOWN, false, "database error"); 528 497 psFree(doneExp); … … 533 502 psS64 exp_id = psDBLastInsertID(config->dbh); 534 503 535 // insert new all pzDoneImfile for the exp into newImfile504 // insert newImfiles 536 505 { 537 506 char *query = … … 539 508 " SElECT" 540 509 " %" PRId64 "," // exp_id 541 " pzDo neImfile.class_id," // tmp_class_id542 " pzDo neImfile.uri" // uri543 " FROM pzDo neImfile"510 " pzDownloadImfile.class_id," // tmp_class_id 511 " pzDownloadImfile.uri" // uri 512 " FROM pzDownloadImfile" 544 513 " WHERE" 545 " pzDo neImfile.exp_name = '%s'"546 " AND pzDo neImfile.camera = '%s'"547 " AND pzDo neImfile.telescope = '%s'";514 " pzDownloadImfile.exp_name = '%s'" 515 " AND pzDownloadImfile.camera = '%s'" 516 " AND pzDownloadImfile.telescope = '%s'"; 548 517 549 518 if (!p_psDBRunQuery(config->dbh, query, exp_id, doneExp->exp_name, doneExp->camera, doneExp->telescope)) { 550 // rollback551 if (!psDBRollback(config->dbh)) {552 psError(PS_ERR_UNKNOWN, false, "database error");553 }554 519 psError(PS_ERR_UNKNOWN, false, "database error"); 555 520 psFree(doneExp); … … 561 526 psU64 affected = psDBAffectedRows(config->dbh); 562 527 if (psDBAffectedRows(config->dbh) < 1) { 563 // rollback564 if (!psDBRollback(config->dbh)) {565 psError(PS_ERR_UNKNOWN, false, "database error");566 }567 528 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row but %" PRIu64 " rows were modified", affected); 568 529 psFree(doneExp); … … 572 533 } 573 534 535 // set pzDownloadExp.state to 'stop' 536 if (!pzDownloadExpSetState(config, doneExp->exp_name, doneExp->camera, doneExp->telescope, "stop")) { 537 psError(PS_ERR_UNKNOWN, false, "failed to change pzDownloadExp.state for %s:%s:%s", doneExp->exp_name, doneExp->camera, doneExp->telescope); 538 psFree(doneExp); 539 psFree(output); 540 return false; 541 } 542 574 543 psFree(doneExp); 575 544 } … … 577 546 psFree(output); 578 547 579 if (!psDBCommit(config->dbh)) {580 psError(PS_ERR_UNKNOWN, false, "database error");581 return false;582 }583 584 548 return true; 585 549 } … … 588 552 { 589 553 // get a list of cameras we've seen exps for 590 if (!p_psDBRunQuery(config->dbh, "SELECT DISTINCT camera FROM pz PendingImfile")) {554 if (!p_psDBRunQuery(config->dbh, "SELECT DISTINCT camera FROM pzDownloadExp")) { 591 555 psError(PS_ERR_UNKNOWN, false, "database error"); 592 556 return false; … … 666 630 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 667 631 668 psString query = psStringCopy("SELECT * FROM pzDo neImfile");632 psString query = psStringCopy("SELECT * FROM pzDownloadImfile"); 669 633 670 634 if (faulted) { 671 635 // list only faulted rows 672 psStringAppend(&query, " %s", "WHERE pzDo neImfile.fault != 0");636 psStringAppend(&query, " %s", "WHERE pzDownloadImfile.fault != 0"); 673 637 } else { 674 638 // don't list faulted rows 675 psStringAppend(&query, " %s", "WHERE pzDo neImfile.fault = 0");639 psStringAppend(&query, " %s", "WHERE pzDownloadImfile.fault = 0"); 676 640 } 677 641 678 642 if (psListLength(where->list)) { 679 psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDo neImfile");643 psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDownloadImfile"); 680 644 psStringAppend(&query, " AND %s", whereClause); 681 645 psFree(whereClause); … … 727 691 PXOPT_LOOKUP_S16(code, config->args, "-code", true, false); 728 692 729 if (!pxSetFaultCode(config->dbh, "pzDo neImfile", config->where, code)) {693 if (!pxSetFaultCode(config->dbh, "pzDownloadImfile", config->where, code)) { 730 694 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 731 695 return false; … … 747 711 748 712 if (config->where) { 749 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pzDo neImfile");713 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pzDownloadImfile"); 750 714 psStringAppend(&query, " AND %s", whereClause); 751 715 psFree(whereClause); … … 768 732 769 733 734 static bool pzDownloadExpSetState(pxConfig *config, const char *exp_name, const char *camera, const char *telescope, const char *state) 735 { 736 PS_ASSERT_PTR_NON_NULL(state, false); 737 738 // check that state is a valid string value 739 if (!( 740 (strncmp(state, "run", 4) == 0) 741 || (strncmp(state, "stop", 5) == 0) 742 || (strncmp(state, "reg", 4) == 0) 743 ) 744 ) { 745 psError(PS_ERR_UNKNOWN, false, 746 "invalid pzDownloadExp state: %s", state); 747 return false; 748 } 749 750 char *query = "UPDATE pzDownloadExp SET state = '%s' WHERE exp_name = '%s' and camera = '%s' and telescope = '%s'"; 751 if (!p_psDBRunQuery(config->dbh, query, state, exp_name, camera, telescope)) { 752 psError(PS_ERR_UNKNOWN, false, "failed to change state for %s:%s:%s", exp_name, camera, telescope); 753 return false; 754 } 755 756 return true; 757 } 758 759 770 760 #if 0 771 761 static psArray *pzArrayAddArray(psArray *array, psArray *input)
Note:
See TracChangeset
for help on using the changeset viewer.
