Changeset 29299 for trunk/ippTools/src/difftool.c
- Timestamp:
- Oct 1, 2010, 2:14:57 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/difftool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/difftool.c
r29225 r29299 60 60 static bool tofullskyfileMode(pxConfig *config); 61 61 static bool listrunMode(pxConfig *config); 62 static bool listssrunMode(pxConfig *config); 62 63 static bool setskyfiletoupdateMode(pxConfig *config); 63 64 … … 108 109 MODECASE(DIFFTOOL_MODE_TOFULLSKYFILE, tofullskyfileMode); 109 110 MODECASE(DIFFTOOL_MODE_LISTRUN, listrunMode); 111 MODECASE(DIFFTOOL_MODE_LISTSSRUN, listssrunMode); 110 112 MODECASE(DIFFTOOL_MODE_SETSKYFILETOUPDATE, setskyfiletoupdateMode); 111 113 … … 2870 2872 psMetadata *where = psMetadataAlloc(); 2871 2873 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 2872 PXOPT_COPY_STR(config->args, where, "-tess_id", "diffRun.tess_id", " ==");2874 PXOPT_COPY_STR(config->args, where, "-tess_id", "diffRun.tess_id", "LIKE"); 2873 2875 PXOPT_COPY_S64(config->args, where, "-magicked", "diffRun.magicked", "=="); 2874 2876 PXOPT_COPY_STR(config->args, where, "-state", "diffRun.state", "=="); … … 2979 2981 return true; 2980 2982 } 2983 static bool listssrunMode(pxConfig *config) 2984 { 2985 PS_ASSERT_PTR_NON_NULL(config, false); 2986 2987 psMetadata *where = psMetadataAlloc(); 2988 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 2989 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackInput.stack_id", "=="); 2990 PXOPT_COPY_S64(config->args, where, "-template_stack_id", "stackTemplate.stack_id", "=="); 2991 PXOPT_COPY_STR(config->args, where, "-tess_id", "diffRun.tess_id", "LIKE"); 2992 PXOPT_COPY_STR(config->args, where, "-state", "diffRun.state", "=="); 2993 pxAddLabelSearchArgs (config, where, "-label", "diffRun.label", "LIKE"); 2994 pxAddLabelSearchArgs (config, where, "-data_group", "diffRun.data_group", "LIKE"); 2995 pxAddLabelSearchArgs (config, where, "-dist_group", "diffRun.dist_group", "LIKE"); 2996 2997 // lookup these so we don't compare to zero if they are not supplied 2998 PXOPT_LOOKUP_F64(mjd_obs_begin, config->args, "-mjd_obs_begin", false, false); 2999 PXOPT_LOOKUP_F64(mjd_obs_end, config->args, "-mjd_obs_end", false, false); 3000 3001 PXOPT_LOOKUP_BOOL(template, config->args, "-template", false); 3002 3003 if (!template) { 3004 if (mjd_obs_begin) { 3005 PXOPT_COPY_F64(config->args, where, "-mjd_obs_begin", "stackInput.mjd_obs", ">="); 3006 } 3007 if (mjd_obs_end) { 3008 PXOPT_COPY_F64(config->args, where, "-mjd_obs_end", "stackInput.mjd_obs", "<="); 3009 } 3010 PXOPT_COPY_STR(config->args, where, "-filter", "stackInputRun.filter", "LIKE"); 3011 } else { 3012 if (mjd_obs_begin) { 3013 PXOPT_COPY_F64(config->args, where, "-mjd_obs_begin", "stackTemplate.mjd_obs", ">="); 3014 } 3015 if (mjd_obs_end) { 3016 PXOPT_COPY_F64(config->args, where, "-mjd_obs_end", "stackTemplate.mjd_obs", "<="); 3017 } 3018 PXOPT_COPY_STR(config->args, where, "-filter", "stackTemplateRun.filter", "LIKE"); 3019 } 3020 3021 PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 3022 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 3023 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 3024 PXOPT_LOOKUP_BOOL(pstamp_order, config->args, "-pstamp_order", false); 3025 3026 psString where2 = NULL; 3027 psString query = pxDataGet("difftool_listssrun.sql"); 3028 if (!query) { 3029 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 3030 return false; 3031 } 3032 3033 if (psListLength(where->list)) { 3034 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 3035 psStringAppend(&query, " AND %s", whereClause); 3036 psFree(whereClause); 3037 } else if (where2) { 3038 psStringAppend(&query, " AND %s", where2); 3039 } else if (!all) { 3040 psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required"); 3041 return false; 3042 } 3043 psFree(where); 3044 3045 if (pstamp_order) { 3046 if (template) { 3047 psStringAppend(&query, " ORDER BY stackTemplate.stack_id, diff_id DESC"); 3048 } else { 3049 psStringAppend(&query, " ORDER BY stackInput.stack_id, diff_id DESC"); 3050 } 3051 } 3052 3053 // treat limit == 0 as "no limit" 3054 if (limit) { 3055 psString limitString = psDBGenerateLimitSQL(limit); 3056 psStringAppend(&query, " %s", limitString); 3057 psFree(limitString); 3058 } 3059 3060 if (!p_psDBRunQuery(config->dbh, query)) { 3061 psError(PS_ERR_UNKNOWN, false, "database error"); 3062 psFree(query); 3063 return false; 3064 } 3065 psFree(query); 3066 3067 psArray *output = p_psDBFetchResult(config->dbh); 3068 if (!output) { 3069 psErrorCode err = psErrorCodeLast(); 3070 switch (err) { 3071 case PS_ERR_DB_CLIENT: 3072 psError(PXTOOLS_ERR_SYS, false, "database error"); 3073 case PS_ERR_DB_SERVER: 3074 psError(PXTOOLS_ERR_PROG, false, "database error"); 3075 default: 3076 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 3077 } 3078 3079 return false; 3080 } 3081 if (!psArrayLength(output)) { 3082 psTrace("difftool", PS_LOG_INFO, "no rows found"); 3083 psFree(output); 3084 return true; 3085 } 3086 3087 if (psArrayLength(output)) { 3088 // negative simple so the default is true 3089 if (!ippdbPrintMetadatas(stdout, output, "diffRun", !simple)) { 3090 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 3091 psFree(output); 3092 return false; 3093 } 3094 } 3095 3096 psFree(output); 3097 3098 return true; 3099 } 2981 3100 // a very specfic function to queue a cleaned warpSkyfile to be updated 2982 3101 static bool setskyfiletoupdateMode(pxConfig *config)
Note:
See TracChangeset
for help on using the changeset viewer.
