- Timestamp:
- Sep 17, 2026, 11:33:59 AM (8 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-pstamp-20260421/ippTools/src/stacktool.c
r43013 r43094 34 34 static bool definerunMode(pxConfig *config); 35 35 static bool updaterunMode(pxConfig *config); 36 static bool listrunMode(pxConfig *config); 36 37 static bool addinputskyfileMode(pxConfig *config); 37 38 static bool inputskyfileMode(pxConfig *config); … … 79 80 MODECASE(STACKTOOL_MODE_DEFINERUN, definerunMode); 80 81 MODECASE(STACKTOOL_MODE_UPDATERUN, updaterunMode); 82 MODECASE(STACKTOOL_MODE_LISTRUN, listrunMode); 81 83 MODECASE(STACKTOOL_MODE_ADDINPUTSKYFILE, addinputskyfileMode); 82 84 MODECASE(STACKTOOL_MODE_INPUTSKYFILE, inputskyfileMode); … … 750 752 } 751 753 752 753 754 static bool updaterunMode(pxConfig *config) 754 755 { … … 815 816 } 816 817 818 static bool listrunMode(pxConfig *config) 819 { 820 PS_ASSERT_PTR_NON_NULL(config, false); 821 822 psMetadata *where = psMetadataAlloc(); 823 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 824 PXOPT_COPY_STR(config->args, where, "-tess_id", "stackRun.tess_id", "LIKE"); 825 PXOPT_COPY_STR(config->args, where, "-skycell_id", "stackRun.skycell_id", "LIKE"); 826 PXOPT_COPY_STR(config->args, where, "-filter", "stackRun.filter", "LIKE"); 827 PXOPT_COPY_STR(config->args, where, "-state", "stackRun.state", "=="); 828 pxAddLabelSearchArgs(config, where, "-label", "stackRun.label", "LIKE"); 829 pxAddLabelSearchArgs(config, where, "-data_group", "stackRun.data_group", "LIKE"); 830 pxAddLabelSearchArgs(config, where, "-dist_group", "stackRun.dist_group", "LIKE"); 831 832 PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 833 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 834 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 835 836 psString query = psStringCopy ("SELECT stackRun.* FROM stackRun"); 837 838 if (psListLength(where->list)) { 839 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 840 psStringAppend(&query, " WHERE %s", whereClause); 841 psFree(whereClause); 842 } else if (!all) { 843 psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required"); 844 return false; 845 } 846 psFree(where); 847 848 // treat limit == 0 as "no limit" 849 if (limit) { 850 psString limitString = psDBGenerateLimitSQL(limit); 851 psStringAppend(&query, " %s", limitString); 852 psFree(limitString); 853 } 854 855 if (!p_psDBRunQuery(config->dbh, query)) { 856 psError(PS_ERR_UNKNOWN, false, "database error"); 857 psFree(query); 858 return false; 859 } 860 psFree(query); 861 862 psArray *output = p_psDBFetchResult(config->dbh); 863 if (!output) { 864 psErrorCode err = psErrorCodeLast(); 865 switch (err) { 866 case PS_ERR_DB_CLIENT: 867 psError(PXTOOLS_ERR_SYS, false, "database error"); 868 case PS_ERR_DB_SERVER: 869 psError(PXTOOLS_ERR_PROG, false, "database error"); 870 default: 871 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 872 } 873 874 return false; 875 } 876 if (!psArrayLength(output)) { 877 psTrace("stacktool", PS_LOG_INFO, "no rows found"); 878 psFree(output); 879 return true; 880 } 881 882 if (psArrayLength(output)) { 883 if (!ippdbPrintMetadatas(stdout, output, "stackRun", !simple)) { 884 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 885 psFree(output); 886 return false; 887 } 888 } 889 890 psFree(output); 891 892 return true; 893 } 817 894 818 895 static bool addinputskyfileMode(pxConfig *config) … … 1211 1288 } 1212 1289 1213 1214 1290 static bool sumskyfileMode(pxConfig *config) 1215 1291 {
Note:
See TracChangeset
for help on using the changeset viewer.
