- Timestamp:
- Jul 21, 2008, 12:12:59 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080719/ippTools/src/dettool_stack.c
r18641 r18643 314 314 return true; 315 315 } 316 317 bool pendingcleanup_stackedMode(pxConfig *config) 318 { 319 PS_ASSERT_PTR_NON_NULL(config, NULL); 320 321 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", false, false); 322 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 323 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 324 325 psMetadata *where = psMetadataAlloc(); 326 if (chip_id) { 327 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 328 } 329 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 330 331 psString query = pxDataGet("dettool_pendingcleanup_stacked.sql"); 332 if (!query) { 333 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 334 return false; 335 } 336 337 if (where && psListLength(where->list)) { 338 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 339 psStringAppend(&query, " AND %s", whereClause); 340 psFree(whereClause); 341 } 342 psFree(where); 343 344 // treat limit == 0 as "no limit" 345 if (limit) { 346 psString limitString = psDBGenerateLimitSQL(limit); 347 psStringAppend(&query, " %s", limitString); 348 psFree(limitString); 349 } 350 351 if (!p_psDBRunQuery(config->dbh, query)) { 352 psError(PS_ERR_UNKNOWN, false, "database error"); 353 psFree(query); 354 return false; 355 } 356 psFree(query); 357 358 psArray *output = p_psDBFetchResult(config->dbh); 359 if (!output) { 360 psError(PS_ERR_UNKNOWN, false, "database error"); 361 return false; 362 } 363 if (!psArrayLength(output)) { 364 psTrace("dettool", PS_LOG_INFO, "no rows found"); 365 psFree(output); 366 return true; 367 } 368 369 // negative simple so the default is true 370 if (!ippdbPrintMetadatas(stdout, output, "detPendingCleanup_stacked", !simple)) { 371 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 372 psFree(output); 373 return false; 374 } 375 376 psFree(output); 377 378 return true; 379 } 380 381 382 bool donecleanup_stackedMode(pxConfig *config) 383 { 384 PS_ASSERT_PTR_NON_NULL(config, NULL); 385 386 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 387 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 388 389 psMetadata *where = psMetadataAlloc(); 390 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 391 392 psString query = pxDataGet("dettool_donecleanup_stacked.sql"); 393 if (!query) { 394 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 395 return false; 396 } 397 398 if (where && psListLength(where->list)) { 399 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 400 psStringAppend(&query, " AND %s", whereClause); 401 psFree(whereClause); 402 } 403 psFree(where); 404 405 // treat limit == 0 as "no limit" 406 if (limit) { 407 psString limitString = psDBGenerateLimitSQL(limit); 408 psStringAppend(&query, " %s", limitString); 409 psFree(limitString); 410 } 411 412 if (!p_psDBRunQuery(config->dbh, query)) { 413 psError(PS_ERR_UNKNOWN, false, "database error"); 414 psFree(query); 415 return false; 416 } 417 psFree(query); 418 419 psArray *output = p_psDBFetchResult(config->dbh); 420 if (!output) { 421 psError(PS_ERR_UNKNOWN, false, "database error"); 422 return false; 423 } 424 if (!psArrayLength(output)) { 425 psTrace("dettool", PS_LOG_INFO, "no rows found"); 426 psFree(output); 427 return true; 428 } 429 430 // negative simple so the default is true 431 if (!ippdbPrintMetadatas(stdout, output, "detDoneCleanup_stacked", !simple)) { 432 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 433 psFree(output); 434 return false; 435 } 436 437 psFree(output); 438 439 return true; 440 } 441
Note:
See TracChangeset
for help on using the changeset viewer.
