Changeset 15828 for trunk/ippTools/src/dettool_correction.c
- Timestamp:
- Dec 14, 2007, 1:35:32 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool_correction.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool_correction.c
r15783 r15828 95 95 psFree(runs); 96 96 97 98 // point of no return for det_id creation 97 // print the new detRun 98 psS64 new_det_id = psDBLastInsertID(config->dbh); 99 99 100 if (!psDBCommit(config->dbh)) { 100 101 psError(PS_ERR_UNKNOWN, false, "database error"); 102 return false; 103 } 104 105 psArray *detRuns = NULL; 106 { 107 psMetadata *where = psMetadataAlloc(); 108 psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", new_det_id); 109 detRuns = psDBSelectRows(config->dbh, "detRun", where, 0); 110 psFree(where); 111 } 112 if (!detRuns) { 113 psError(PS_ERR_UNKNOWN, false, "can't find the detRun we just created"); 114 return false; 115 } 116 // sanity check results 117 if (psArrayLength(detRuns) != 1) { 118 psAbort("found more then one detRun matching det_id %" PRId64 "(this should not happen)", new_det_id); 119 return false; 120 } 121 122 if (!convertIdToStr(detRuns)) { 123 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings"); 124 psFree(detRuns); 101 125 return false; 102 126 } … … 112 136 } 113 137 114 #if 0115 // print the new det_id116 psArray *detRuns = NULL;117 {118 psMetadata *where = psMetadataAlloc();119 psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", det_id);120 detRuns = psDBSelectRows(config->dbh, "detRun", where, 0);121 psFree(where);122 }123 if (!detRuns) {124 psError(PS_ERR_UNKNOWN, false, "can't find the detRun we just created");125 return false;126 }127 // sanity check results128 if (psArrayLength(detRuns) != 1) {129 psAbort("found more then one detRun matching det_id %" PRId64 " (this should not happen)", det_id);130 return false;131 }132 133 if (!convertIdToStr(detRuns)) {134 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");135 psFree(detRuns);136 return false;137 }138 139 138 // negative simple so the default is true 140 139 if (!ippdbPrintMetadatas(stdout, detRuns, "detRun", !simple)) { … … 144 143 } 145 144 psFree(detRuns); 146 #endif147 145 148 146 return true; 149 147 } 148 149 bool tocorrectexpMode(pxConfig *config) 150 { 151 PS_ASSERT_PTR_NON_NULL(config, false); 152 153 bool status = false; 154 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 155 if (!status) { 156 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 157 return false; 158 } 159 160 psString query = pxDataGet("dettool_tocorrectexp.sql"); 161 if (!query) { 162 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 163 return false; 164 } 165 166 // treat limit == 0 as "no limit" 167 if (limit) { 168 psString limitString = psDBGenerateLimitSQL(limit); 169 psStringAppend(&query, " %s", limitString); 170 psFree(limitString); 171 } 172 173 if (!p_psDBRunQuery(config->dbh, query)) { 174 psError(PS_ERR_UNKNOWN, false, "database error"); 175 psFree(query); 176 return false; 177 } 178 psFree(query); 179 180 psArray *output = p_psDBFetchResult(config->dbh); 181 if (!output) { 182 psError(PS_ERR_UNKNOWN, false, "database error"); 183 return false; 184 } 185 if (!psArrayLength(output)) { 186 psTrace("dettool", PS_LOG_INFO, "no rows found"); 187 psFree(output); 188 return true; 189 } 190 191 bool simple = false; 192 { 193 bool status = false; 194 simple = psMetadataLookupBool(&status, config->args, "-simple"); 195 if (!status) { 196 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 197 return false; 198 } 199 } 200 201 // negative simple so the default is true 202 if (!ippdbPrintMetadatas(stdout, output, "detRun", !simple)) { 203 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 204 psFree(output); 205 return false; 206 } 207 208 psFree(output); 209 210 return true; 211 } 212 213 bool tocorrectimfileMode(pxConfig *config) 214 { 215 PS_ASSERT_PTR_NON_NULL(config, false); 216 217 bool status = false; 218 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 219 if (!status) { 220 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 221 return false; 222 } 223 224 psString query = pxDataGet("dettool_tocorrectimfile.sql"); 225 if (!query) { 226 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 227 return false; 228 } 229 230 if (config->where) { 231 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "det1"); 232 psStringAppend(&query, " AND %s", whereClause); 233 psFree(whereClause); 234 } 235 236 // treat limit == 0 as "no limit" 237 if (limit) { 238 psString limitString = psDBGenerateLimitSQL(limit); 239 psStringAppend(&query, " %s", limitString); 240 psFree(limitString); 241 } 242 243 if (!p_psDBRunQuery(config->dbh, query)) { 244 psError(PS_ERR_UNKNOWN, false, "database error"); 245 psFree(query); 246 return false; 247 } 248 psFree(query); 249 250 psArray *output = p_psDBFetchResult(config->dbh); 251 if (!output) { 252 psError(PS_ERR_UNKNOWN, false, "database error"); 253 return false; 254 } 255 if (!psArrayLength(output)) { 256 psTrace("dettool", PS_LOG_INFO, "no rows found"); 257 psFree(output); 258 return true; 259 } 260 261 bool simple = false; 262 { 263 bool status = false; 264 simple = psMetadataLookupBool(&status, config->args, "-simple"); 265 if (!status) { 266 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 267 return false; 268 } 269 } 270 271 // negative simple so the default is true 272 if (!ippdbPrintMetadatas(stdout, output, "detPendingCorrectImfile", !simple)) { 273 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 274 psFree(output); 275 return false; 276 } 277 278 psFree(output); 279 280 return true; 281 }
Note:
See TracChangeset
for help on using the changeset viewer.
