Changeset 24683 for trunk/ippTools/src/magicdstool.c
- Timestamp:
- Jul 6, 2009, 12:52:22 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magicdstool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magicdstool.c
r24552 r24683 40 40 static bool toremoveMode(pxConfig *config); 41 41 static bool torestoreMode(pxConfig *config); 42 static bool torevertMode(pxConfig *config); 42 43 43 44 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state); … … 72 73 MODECASE(MAGICDSTOOL_MODE_TOREMOVE, toremoveMode); 73 74 MODECASE(MAGICDSTOOL_MODE_TORESTORE, torestoreMode); 75 MODECASE(MAGICDSTOOL_MODE_TOREVERT, torevertMode); 74 76 default: 75 77 psAbort("invalid option (this should not happen)"); … … 502 504 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 503 505 506 if (!strcmp(stage, "camera")) { 507 // no there is no magicked column in camProcessedExp 508 psFree(output); 509 return true; 510 } 504 511 505 512 // chose the appropriate query based on the stage … … 570 577 } else if (!strcmp(stage, "chip")) { 571 578 query = "UPDATE chipRun SET magicked = %" PRId64 " where chip_id = %" PRId64; 579 } else if (!strcmp(stage, "camera")) { 580 query = "UPDATE camRun SET magicked = %" PRId64 " where cam_id = %" PRId64; 572 581 } else if (!strcmp(stage, "warp")) { 573 582 query = "UPDATE warpRun SET magicked = %" PRId64 " where warp_id = %" PRId64; … … 674 683 } else if (!strcmp(stage, "chip")) { 675 684 stageNum = 1; 685 } else if (!strcmp(stage, "camera")) { 686 stageNum = 2; 676 687 } else if (!strcmp(stage, "warp")) { 677 stageNum = 2;688 stageNum = 3; 678 689 } else { 679 690 psError(PXTOOLS_ERR_DATA, true, "%s is not a valid value for stage", stage); … … 718 729 *stage_id = psMetadataLookupS64(NULL, row, "chip_id"); 719 730 } else if (stageNum == 2) { 731 *stage_id = *cam_id; 732 } else if (stageNum == 3) { 720 733 *stage_id = psMetadataLookupS64(NULL, row, "warp_id"); 721 734 } … … 1039 1052 return true; 1040 1053 } 1054 1055 1056 static bool torevertMode(pxConfig *config) 1057 { 1058 PS_ASSERT_PTR_NON_NULL(config, false); 1059 1060 psMetadata *where = psMetadataAlloc(); 1061 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 1062 1063 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "=="); 1064 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 1065 pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "=="); 1066 1067 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1068 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1069 1070 psString sql_file = NULL; 1071 psStringAppend(&sql_file, "magicdstool_torevert_%s.sql", stage); 1072 1073 psString query = pxDataGet(sql_file); 1074 if (!query) { 1075 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", sql_file); 1076 psFree(sql_file); 1077 return false; 1078 } 1079 psFree(sql_file); 1080 1081 if (psListLength(where->list)) { 1082 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1083 psStringAppend(&query, " AND %s", whereClause); 1084 psFree(whereClause); 1085 } 1086 psFree(where); 1087 1088 // treat limit == 0 as "no limit" 1089 if (limit) { 1090 psString limitString = psDBGenerateLimitSQL(limit); 1091 psStringAppend(&query, " %s", limitString); 1092 psFree(limitString); 1093 } 1094 1095 if (!p_psDBRunQuery(config->dbh, query)) { 1096 psError(PS_ERR_UNKNOWN, false, "database error"); 1097 psFree(query); 1098 return false; 1099 } 1100 psFree(query); 1101 1102 psArray *output = p_psDBFetchResult(config->dbh); 1103 if (!output) { 1104 psErrorCode err = psErrorCodeLast(); 1105 switch (err) { 1106 case PS_ERR_DB_CLIENT: 1107 psError(PXTOOLS_ERR_SYS, false, "database error"); 1108 case PS_ERR_DB_SERVER: 1109 psError(PXTOOLS_ERR_PROG, false, "database error"); 1110 default: 1111 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1112 } 1113 1114 return false; 1115 } 1116 if (!psArrayLength(output)) { 1117 psTrace("magicdstool", PS_LOG_INFO, "no rows found"); 1118 psFree(output); 1119 return true; 1120 } 1121 1122 if (psArrayLength(output)) { 1123 // negative simple so the default is true 1124 if (!ippdbPrintMetadatas(stdout, output, "torevert", !simple)) { 1125 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1126 psFree(output); 1127 return false; 1128 } 1129 } 1130 1131 psFree(output); 1132 1133 return true; 1134 } 1135 1136
Note:
See TracChangeset
for help on using the changeset viewer.
