Changeset 24038 for trunk/ippTools/src/receivetool.c
- Timestamp:
- May 1, 2009, 5:28:52 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/receivetool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/receivetool.c
r23898 r24038 1 1 /* 2 * disttool.c2 * receivetool.c 3 3 * 4 4 * Copyright (C) 2008 … … 36 36 static bool updatelastMode(pxConfig *config); 37 37 static bool pendingfilesetMode(pxConfig *config); 38 static bool updatefilesetMode(pxConfig *config); 38 39 static bool addfileMode(pxConfig *config); 39 40 static bool pendingfileMode(pxConfig *config); 40 41 static bool addresultMode(pxConfig *config); 42 static bool toadvanceMode(pxConfig *config); 41 43 static bool revertMode(pxConfig *config); 42 44 … … 65 67 MODECASE(RECEIVETOOL_MODE_UPDATELAST, updatelastMode); 66 68 MODECASE(RECEIVETOOL_MODE_PENDINGFILESET, pendingfilesetMode); 69 MODECASE(RECEIVETOOL_MODE_UPDATEFILESET, updatefilesetMode); 70 MODECASE(RECEIVETOOL_MODE_TOADVANCE, toadvanceMode); 67 71 MODECASE(RECEIVETOOL_MODE_ADDFILE, addfileMode); 68 72 MODECASE(RECEIVETOOL_MODE_PENDINGFILE, pendingfileMode); … … 102 106 PXOPT_LOOKUP_STR(comment, config->args, "-comment", false, false); 103 107 PXOPT_LOOKUP_STR(last, config->args, "-last", false, false); 104 105 if (!receiveSourceInsert(config->dbh, 0, source, product, workdir, comment, last)) { 108 PXOPT_LOOKUP_STR(status_product, config->args, "-status_product", false, false); 109 PXOPT_LOOKUP_STR(ds_dbname, config->args, "-ds_dbname", false, false); 110 PXOPT_LOOKUP_STR(ds_dbhost, config->args, "-ds_dbhost", false, false); 111 112 if (!receiveSourceInsert(config->dbh, 0, source, product, workdir, comment, last, status_product, ds_dbname, ds_dbhost)) { 106 113 psError(PS_ERR_UNKNOWN, false, "Database error"); 107 114 return false; … … 231 238 psFree(output); 232 239 233 if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset )) {240 if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset, "new", NULL, 0)) { 234 241 psError(PS_ERR_UNKNOWN, false, "Unable to add fileset"); 235 242 psFree(source_id_str); … … 391 398 PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "=="); 392 399 PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE"); 393 PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveFile.file_id", "=="); 400 PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveFile.fileset_id", "=="); 401 PXOPT_COPY_S64(config->args, where, "-file_id", "receiveFile.file_id", "=="); 394 402 395 403 // optional … … 499 507 return true; 500 508 } 509 static bool toadvanceMode(pxConfig *config) 510 { 511 PS_ASSERT_PTR_NON_NULL(config, false); 512 513 psMetadata *where = psMetadataAlloc(); // WHERE conditions 514 515 // optional 516 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 517 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 518 519 psString query = pxDataGet("receivetool_toadvance.sql"); 520 if (!query) { 521 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); 522 psFree(where); 523 return false; 524 } 525 526 if (psListLength(where->list)) { 527 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 528 psStringAppend(&query, " AND %s", whereClause); 529 psFree(whereClause); 530 } 531 psFree(where); 532 533 if (limit) { 534 psString limitString = psDBGenerateLimitSQL(limit); 535 psStringAppend(&query, " %s", limitString); 536 psFree(limitString); 537 } 538 539 if (!p_psDBRunQueryF(config->dbh, query)) { 540 psError(PS_ERR_UNKNOWN, false, "Database error"); 541 psFree(query); 542 return false; 543 } 544 psFree(query); 545 546 psArray *output = p_psDBFetchResult(config->dbh); 547 if (!output) { 548 psError(PS_ERR_UNKNOWN, false, "Database error"); 549 return false; 550 } 551 if (!psArrayLength(output)) { 552 psTrace("receivetool", PS_LOG_INFO, "No rows found"); 553 psFree(output); 554 return true; 555 } 556 if (!ippdbPrintMetadatas(stdout, output, "toadvanceFilesets", !simple)) { 557 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 558 psFree(output); 559 return false; 560 } 561 psFree(output); 562 563 return true; 564 } 565 566 static bool updatefilesetMode(pxConfig *config) 567 { 568 PS_ASSERT_PTR_NON_NULL(config, false); 569 570 // required 571 PXOPT_LOOKUP_S64(fileset_id, config->args, "-fileset_id", true, false); 572 573 // to chanage 574 PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false); 575 PXOPT_LOOKUP_STR(dbinfo_uri, config->args, "-dbinfo_uri", false, false); 576 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 577 578 if (!fault && !dbinfo_uri && !state) { 579 psError(PS_ERR_UNKNOWN, true, "one of -fault, -dbinfo_uri, -set_state are required"); 580 return false; 581 } 582 583 psString query = NULL; // Query to execute 584 psStringAppend(&query, "UPDATE receiveFileset SET "); 585 586 psString sep = ""; 587 if (fault) { 588 psStringAppend(&query, "%s fault = %d", sep, fault); 589 sep = ","; 590 } 591 if (dbinfo_uri) { 592 psStringAppend(&query, "%s dbinfo_uri = '%s'", sep, dbinfo_uri); 593 sep = ","; 594 } 595 if (state) { 596 psStringAppend(&query, "%s state = '%s'", sep, state); 597 sep = ","; 598 } 599 600 psStringAppend(&query, " WHERE fileset_id = %" PRId64, fileset_id); 601 602 if (!p_psDBRunQuery(config->dbh, query)) { 603 psError(PS_ERR_UNKNOWN, false, "Database error"); 604 psFree(query); 605 return false; 606 } 607 psFree(query); 608 609 return true; 610 }
Note:
See TracChangeset
for help on using the changeset viewer.
