- Timestamp:
- Aug 30, 2013, 4:48:58 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130711/ippTools/src
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
stacktool.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130711/ippTools/src
- Property svn:mergeinfo changed
/trunk/ippTools/src (added) merged: 35856,35888,35896-35897,35955,35960,36009,36019,36041,36046
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20130711/ippTools/src/stacktool.c
r34800 r36071 44 44 static bool tosummaryMode(pxConfig *config); 45 45 static bool addsummaryMode(pxConfig *config); 46 static bool summaryMode(pxConfig *config); 46 47 static bool pendingcleanuprunMode(pxConfig *config); 47 48 static bool pendingcleanupskyfileMode(pxConfig *config); … … 84 85 MODECASE(STACKTOOL_MODE_TOSUMMARY, tosummaryMode); 85 86 MODECASE(STACKTOOL_MODE_ADDSUMMARY, addsummaryMode); 87 MODECASE(STACKTOOL_MODE_SUMMARY, summaryMode); 86 88 MODECASE(STACKTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 87 89 MODECASE(STACKTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode); … … 748 750 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 749 751 PXOPT_COPY_STR(config->args, where, "-label", "stackRun.label", "=="); 752 PXOPT_COPY_STR(config->args, where, "-data_group", "stackRun.data_group", "=="); 750 753 PXOPT_COPY_STR(config->args, where, "-state", "stackRun.state", "=="); 751 754 PXOPT_COPY_S64(config->args, where, "-sass_id", "stackAssociationMap.sass_id", "=="); … … 1475 1478 // generate where strings for arguments that require extra processing 1476 1479 // beyond PXOPT_COPY* 1480 psString whereClause; 1477 1481 if (psListLength(where->list)) { 1478 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1479 psStringAppend(&query, " AND %s", whereClause); 1480 psFree(whereClause); 1482 whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1483 psStringPrepend(&whereClause, "\n AND "); 1481 1484 } else if (!all) { 1482 1485 psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required"); 1486 psFree(whereClause); 1483 1487 return false; 1484 1488 } … … 1493 1497 } 1494 1498 1495 if (!p_psDBRunQuery (config->dbh, query)) {1499 if (!p_psDBRunQueryF(config->dbh, query, whereClause)) { 1496 1500 psError(PS_ERR_UNKNOWN, false, "database error"); 1501 psFree(whereClause); 1497 1502 psFree(query); 1498 1503 return false; 1499 1504 } 1505 psFree(whereClause); 1500 1506 psFree(query); 1501 1507 … … 1564 1570 } 1565 1571 1572 static bool summaryMode(pxConfig *config) 1573 { 1574 PS_ASSERT_PTR_NON_NULL(config, false); 1575 1576 psMetadata *where = psMetadataAlloc(); 1577 PXOPT_COPY_S64(config->args, where, "-sass_id", "stackSummary.sass_id", "=="); 1578 PXOPT_COPY_STR(config->args, where, "-projection_cell", "stackAssociation.projection_cell", "=="); 1579 PXOPT_COPY_STR(config->args, where, "-tess_id", "stackAssociation.tess_id", "LIKE"); 1580 PXOPT_COPY_STR(config->args, where, "-filter", "stackAssociation.filter", "LIKE"); 1581 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackSumSkyfile.stack_id", "=="); 1582 pxAddLabelSearchArgs(config, where, "-data_group", "stackAssociation.data_group", "LIKE"); 1583 PXOPT_COPY_STR(config->args, where, "-skycell_id", "stackRun.skycell_id", "LIKE"); 1584 // PXOPT_COPY_STR(config->args, where, "-state", "stackRun.state", "=="); 1585 pxAddLabelSearchArgs(config, where, "-label", "stackRun.label", "LIKE"); 1586 // PXOPT_COPY_S16(config->args, where, "-fault", "stackSumSkyfile.fault", "=="); 1587 // PXOPT_COPY_F64(config->args, where, "-mjd_obs_begin", "stackSumSkyfile.mjd_obs", ">="); 1588 // PXOPT_COPY_F64(config->args, where, "-mjd_obs_end", "stackSumSkyfile.mjd_obs", "<="); 1589 // PXOPT_COPY_S16(config->args, where, "-background_model","stackSumSkyfile.background_model", "=="); 1590 1591 // PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 1592 1593 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1594 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1595 1596 psString query = pxDataGet("stacktool_summary.sql"); 1597 if (!query) { 1598 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1599 return false; 1600 } 1601 1602 if (psListLength(where->list)) { 1603 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1604 psStringAppend(&query, " WHERE %s", whereClause); 1605 psFree(whereClause); 1606 } else { 1607 psError(PXTOOLS_ERR_CONFIG, true, "search parameters are required"); 1608 return false; 1609 } 1610 1611 psFree(where); 1612 1613 // treat limit == 0 as "no limit" 1614 if (limit) { 1615 psString limitString = psDBGenerateLimitSQL(limit); 1616 psStringAppend(&query, " %s", limitString); 1617 psFree(limitString); 1618 } 1619 1620 if (!p_psDBRunQuery(config->dbh, query)) { 1621 psError(PS_ERR_UNKNOWN, false, "database error"); 1622 psFree(query); 1623 return false; 1624 } 1625 psFree(query); 1626 1627 psArray *output = p_psDBFetchResult(config->dbh); 1628 if (!output) { 1629 psErrorCode err = psErrorCodeLast(); 1630 switch (err) { 1631 case PS_ERR_DB_CLIENT: 1632 psError(PXTOOLS_ERR_SYS, false, "database error"); 1633 case PS_ERR_DB_SERVER: 1634 psError(PXTOOLS_ERR_PROG, false, "database error"); 1635 default: 1636 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1637 } 1638 1639 return false; 1640 } 1641 if (!psArrayLength(output)) { 1642 psTrace("stacktool", PS_LOG_INFO, "no rows found"); 1643 psFree(output); 1644 return true; 1645 } 1646 1647 if (psArrayLength(output)) { 1648 if (!ippdbPrintMetadatas(stdout, output, "stackSummary", !simple)) { 1649 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1650 psFree(output); 1651 return false; 1652 } 1653 } 1654 1655 psFree(output); 1656 1657 return true; 1658 } 1659 1566 1660 static bool pendingcleanuprunMode(pxConfig *config) 1567 1661 {
Note:
See TracChangeset
for help on using the changeset viewer.
