Changeset 28177
- Timestamp:
- Jun 1, 2010, 1:45:42 PM (16 years ago)
- Location:
- branches/haf_branches/ipp.20100512
- Files:
-
- 4 edited
-
ippScripts/scripts/minidvodb_createdb.pl (modified) (1 diff)
-
ippScripts/scripts/minidvodb_merge.pl (modified) (2 diffs)
-
ippTools/src/addtool.c (modified) (18 diffs)
-
ippTools/src/addtoolConfig.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/haf_branches/ipp.20100512/ippScripts/scripts/minidvodb_createdb.pl
r28171 r28177 204 204 my $parser = DateTime::Format::Strptime->new( pattern => '%Y-%m-%dT%H:%M:%S', time_zone => "HST" ); 205 205 my $creation_dt = $parser->parse_datetime( $creation_date )->mjd; 206 if ($mjd_start- $creation_dt > $minidvodb_interval) { # && $addRun_count > 0 ) { 207 #if ($mjd_start- $creation_dt > $minidvodb_interval && $addRun_count > 0 ) { 206 if ($mjd_start- $creation_dt > $minidvodb_interval && $addRun_count > 0 ) { 208 207 #db is old and has stuff in it, want to create_new 209 208 $create_new = 1; -
branches/haf_branches/ipp.20100512/ippScripts/scripts/minidvodb_merge.pl
r28171 r28177 87 87 unless ($no_op) { 88 88 if (defined $mergedvodbReal) { 89 my $mjd_relphot_start = DateTime->now->mjd;90 my $lame = 1;91 if ($lame ==2){92 89 { 93 90 my $command = "$addstar -resort"; … … 125 122 $dtime_relphot = 86400.0*(DateTime->now->mjd - $mjd_relphot_start); # MJD of starting script 126 123 print "relphot time $dtime_relphot\n"; 127 } }124 } 128 125 129 126 { -
branches/haf_branches/ipp.20100512/ippTools/src/addtool.c
r28171 r28177 776 776 PXOPT_LOOKUP_STR(mergedvodb_path, config->args, "-set_mergedvodb_path", true, false); 777 777 778 779 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-set_minidvodb_name", false, false); 780 781 PXOPT_LOOKUP_STR(minidvodb_path, config->args, "-set_minidvodb_path", false, false); 782 778 //optional 779 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-set_minidvodb_name", false, false); 780 PXOPT_LOOKUP_STR(minidvodb_path, config->args, "-set_minidvodb_path", false, false); 783 781 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 784 782 785 786 if (!psDBTransaction(config->dbh)) { 787 psError(PS_ERR_UNKNOWN, false, "database error"); 788 789 return false; 790 } 791 //psMetadata *where = psMetadataAlloc(); 792 793 //PXOPT_COPY_S64(config->args, where, "-set_minidvodb_name", "minidvodb_name", "=="); 794 // PXOPT_COPY_S64(config->args, where, "-set_minidvodb_path", "minidvodb_path", "=="); 795 //PXOPT_COPY_STR(config->args, where, "-set_mergedvodb_path", "mergedvodb_path", "=="); 796 797 798 // psString query = NULL; 799 // psStringAppend(&query, "INSERT INTO minidvodbRun SET minidvodb_path = '%s' ,",minidvodb_path); 800 // if (minidvodb_name) {psStringAppend(&query, "minidvodb_name = '%s' ,",minidvodb_name);} 801 // psStringAppend(&query, "mergedvodb_path = '%s',",mergedvodb_path); 802 // if (minidvodb_path) {psStringAppend(&query, "minidvodb_group = '%s'",minidvodb_group);} 803 // if (state) { 804 // psStringAppend(&query, ",state = '%s';", state); 805 // } else { 806 // psStringAppend(&query, ",state = 'new';"); 807 // // } 808 809 810 //if (!query) { 811 // psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 812 // return false; 813 // } 814 815 //if (!p_psDBRunQuery(config->dbh, query)) { 816 // psError(PS_ERR_UNKNOWN, false, "database error %s", query); 817 // psFree(query); 818 // return false; 819 // } 820 // psFree(query); 821 822 //psArray *output = p_psDBFetchResult(config->dbh); 823 // if (!output) { 824 // psError(PS_ERR_UNKNOWN, false, "database error"); 825 // return false; 826 // } 827 // if (!psArrayLength(output)) { 828 // psTrace("addtool", PS_LOG_INFO, "no rows found"); 829 // psFree(output); 830 // return true; 831 // } 832 //if (!psDBTransaction(config->dbh)) { 833 // psError(PS_ERR_UNKNOWN, false, "database error"); 834 // psFree(output); 835 // return false; 836 // // } 783 if (!psDBTransaction(config->dbh)) { 784 psError(PS_ERR_UNKNOWN, false, "database error"); 785 return false; 786 } 787 837 788 psString minidvodbpath = "NULL"; 838 839 789 840 790 // I don't know how to get around the complaints of minidvodb_path can't be null. this 'fixes' it, but someone smarter can fix it properly. 841 791 if (minidvodb_path) { … … 843 793 } 844 794 845 if (!minidvodbRunInsert(config->dbh,846 0, // job_id795 if (!minidvodbRunInsert(config->dbh, 796 0, // job_id 847 797 minidvodb_name, 848 798 minidvodb_group, … … 852 802 0 853 803 )) { 854 psError(PS_ERR_UNKNOWN, false, "database error");855 return false;856 }804 psError(PS_ERR_UNKNOWN, false, "database error"); 805 return false; 806 } 857 807 858 psU64 affected = psDBAffectedRows(config->dbh);859 if (affected != 1) {860 psError(PS_ERR_UNKNOWN, false,808 psU64 affected = psDBAffectedRows(config->dbh); 809 if (affected != 1) { 810 psError(PS_ERR_UNKNOWN, false, 861 811 "should have affected one row but %" PRIu64 " rows were modified", 862 812 affected); 863 return false; 864 } 865 866 psS64 minidvodb_id = psDBLastInsertID(config->dbh); 867 printf("%" PRId64 "\n", minidvodb_id); 868 869 870 if (!minidvodb_name) { 871 psStringAppend(&minidvodb_name, "%s.%" PRIu64,minidvodb_group,minidvodb_id); 872 } 873 874 875 876 if (!minidvodb_path) { 877 psStringAppend(&minidvodb_path,"%s/%s",mergedvodb_path,minidvodb_name); 878 879 } 880 881 882 psString query = NULL; 883 884 psStringAppend(&query, "UPDATE minidvodbRun SET minidvodb_path = '%s', minidvodb_name = '%s' where minidvodb_id = %" PRIu64";", minidvodb_path, minidvodb_name, minidvodb_id); 885 886 if (!p_psDBRunQuery(config->dbh, query)) { 887 psError(PS_ERR_UNKNOWN, false, "database error"); 888 psFree(query); 889 return false; 890 } 891 892 893 894 if (!psDBCommit(config->dbh)) { 895 psError(PS_ERR_UNKNOWN, false, "database error"); 896 return false; 897 } 898 899 900 return true; 813 return false; 814 } 815 816 psS64 minidvodb_id = psDBLastInsertID(config->dbh); 817 printf("%" PRId64 "\n", minidvodb_id); 818 819 820 if (!minidvodb_name) { 821 psStringAppend(&minidvodb_name, "%s.%" PRIu64,minidvodb_group,minidvodb_id); 822 } 823 824 if (!minidvodb_path) { 825 psStringAppend(&minidvodb_path,"%s/%s",mergedvodb_path,minidvodb_name); 826 } 827 828 psString query = NULL; 829 830 psStringAppend(&query, "UPDATE minidvodbRun SET minidvodb_path = '%s', minidvodb_name = '%s' where minidvodb_id = %" PRIu64";", minidvodb_path, minidvodb_name, minidvodb_id); 831 832 if (!p_psDBRunQuery(config->dbh, query)) { 833 psError(PS_ERR_UNKNOWN, false, "database error"); 834 psFree(query); 835 return false; 836 } 837 838 if (!psDBCommit(config->dbh)) { 839 psError(PS_ERR_UNKNOWN, false, "database error"); 840 return false; 841 } 842 843 return true; 901 844 } 902 845 … … 920 863 921 864 if (!psListLength(where->list)) { 922 psFree(where);923 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");924 return false;865 psFree(where); 866 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 867 return false; 925 868 } 926 869 … … 929 872 psString comma = ","; 930 873 if (minidvodb_name) { 931 psStringAppend(&query, " minidvodb_name = '%s'", minidvodb_name); 932 cnt++; 933 } 934 935 if (minidvodb_path) { 936 if (cnt) { 937 psStringAppend(&query,comma); 938 } 939 940 psStringAppend(&query, " minidvodb_path = '%s'", minidvodb_path); 941 cnt++; 942 } 943 944 if (state) { 945 if (cnt) { 946 psStringAppend(&query,comma); 947 } 948 psStringAppend(&query, " state = '%s'", state); 949 cnt++; 950 } 951 952 if (mergedvodb_path) { 953 if (cnt) { 954 psStringAppend(&query,comma); 955 } 956 psStringAppend(&query, " mergedvodb_path = '%s'", mergedvodb_path); 957 cnt++; 958 } 959 960 if (minidvodb_group) { 961 if (cnt) { 962 psStringAppend(&query,comma); 963 } 964 psStringAppend(&query, " minidvodb_group = '%s'", minidvodb_group); 965 cnt++; 966 } 967 968 969 970 971 // pxUpdateRun gets parameters from config->args and runs the update query 874 psStringAppend(&query, " minidvodb_name = '%s'", minidvodb_name); 875 cnt++; 876 } 877 878 if (minidvodb_path) { 879 if (cnt) { 880 psStringAppend(&query,comma); 881 } 882 883 psStringAppend(&query, " minidvodb_path = '%s'", minidvodb_path); 884 cnt++; 885 } 886 887 if (state) { 888 if (cnt) { 889 psStringAppend(&query,comma); 890 } 891 psStringAppend(&query, " state = '%s'", state); 892 cnt++; 893 } 894 895 if (mergedvodb_path) { 896 if (cnt) { 897 psStringAppend(&query,comma); 898 } 899 psStringAppend(&query, " mergedvodb_path = '%s'", mergedvodb_path); 900 cnt++; 901 } 902 903 if (minidvodb_group) { 904 if (cnt) { 905 psStringAppend(&query,comma); 906 } 907 psStringAppend(&query, " minidvodb_group = '%s'", minidvodb_group); 908 cnt++; 909 } 972 910 973 911 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 974 912 psStringAppend(&query, " WHERE %s", whereClause); 975 913 976 if (!p_psDBRunQuery(config->dbh, query)) { 977 psError(PS_ERR_UNKNOWN, false, "database error"); 978 psFree(query); 979 return false; 980 } 981 982 983 984 914 if (!p_psDBRunQuery(config->dbh, query)) { 915 psError(PS_ERR_UNKNOWN, false, "database error"); 916 psFree(query); 917 return false; 918 } 919 985 920 psFree(query); 986 921 psFree(where); … … 988 923 return true; 989 924 990 991 925 } 992 926 993 927 static bool flipminidvodbrunMode(pxConfig *config) { 994 928 PS_ASSERT_PTR_NON_NULL(config, false); 995 996 psMetadata *where = psMetadataAlloc(); 997 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-minidvodb_group",true, false); 998 999 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "minidvodb_group", "=="); 929 930 psMetadata *where = psMetadataAlloc(); 931 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-minidvodb_group",true, false); 932 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "minidvodb_group", "=="); 1000 933 1001 934 //this flips the new - > active … … 1006 939 1007 940 // start a transaction eraly so it will contain any row level locks 1008 if (!psDBTransaction(config->dbh)) { 1009 psError(PS_ERR_UNKNOWN, false, "database error"); 1010 return false; 1011 } 1012 1013 1014 1015 1016 1017 psString firstquery = psStringCopy("SELECT * from minidvodbRun where state = 'new' and minidvodb_name is NOT NULL and minidvodb_group IS NOT NULL and minidvodb_path IS NOT NULL and mergedvodb_path IS NOT NULL"); 1018 1019 psString firstwhereClause = psDBGenerateWhereConditionSQL(where, NULL); 1020 psStringAppend(&firstquery, " AND %s", firstwhereClause); 1021 1022 1023 1024 if (!p_psDBRunQuery(config->dbh, firstquery)) { 1025 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1026 if (!psDBRollback(config->dbh)) { 1027 psError(PS_ERR_UNKNOWN, false, "database error"); 1028 } 1029 return false; 1030 1031 } 1032 psFree(firstquery); 941 if (!psDBTransaction(config->dbh)) { 942 psError(PS_ERR_UNKNOWN, false, "database error"); 943 return false; 944 } 945 946 psString firstquery = psStringCopy("SELECT * from minidvodbRun where state = 'new' and minidvodb_name is NOT NULL and minidvodb_group IS NOT NULL and minidvodb_path IS NOT NULL and mergedvodb_path IS NOT NULL"); 947 948 psString firstwhereClause = psDBGenerateWhereConditionSQL(where, NULL); 949 psStringAppend(&firstquery, " AND %s", firstwhereClause); 950 951 952 953 if (!p_psDBRunQuery(config->dbh, firstquery)) { 954 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 955 if (!psDBRollback(config->dbh)) { 956 psError(PS_ERR_UNKNOWN, false, "database error"); 957 } 958 return false; 959 } 960 psFree(firstquery); 1033 961 1034 962 //we don't care what the stuff is that is found, just that there is stuff. This is a check to see that there is something in the 'new' state, before flipping (so that if there is nothing in new, it won't flip the active to waiting. the flipminidvo is just to make it easy to flip from new -> active. 1035 963 1036 psArray *output = p_psDBFetchResult(config->dbh); 1037 if (!output) { 1038 psError(PS_ERR_UNKNOWN, false, "database error"); 1039 return false; 1040 } 1041 if (!psArrayLength(output)) { 1042 psTrace("addtool", PS_LOG_INFO, "no rows found"); 1043 psFree(output); 1044 return true; 1045 } 1046 1047 1048 1049 1050 1051 1052 // psString query = psStringCopy("UPDATE minidvodbRun SET state = case when state = 'new' then 'active' else 'waiting' end WHERE state in ('new', 'active')"); 1053 psString query = psStringCopy("UPDATE minidvodbRun SET state = 'waiting' WHERE state = 'active' "); 1054 // pxUpdateRun gets parameters from config->args and runs the update query 1055 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1056 psStringAppend(&query, " AND %s", whereClause); 1057 1058 1059 1060 1061 1062 1063 if (!p_psDBRunQuery(config->dbh, query)) { 1064 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1065 if (!psDBRollback(config->dbh)) { 1066 psError(PS_ERR_UNKNOWN, false, "database error"); 1067 } 1068 return false; 1069 1070 1071 } 1072 1073 //if (!psDBTransaction(config->dbh)) { 1074 // psError(PS_ERR_UNKNOWN, false, "database error"); 1075 // psFree(output); 1076 // return false; 1077 // } 1078 1079 1080 1081 1082 1083 psString query2 = psStringCopy("UPDATE minidvodbRun SET state = 'active' WHERE state = 'new' AND minidvodb_name is NOT NULL and minidvodb_group IS NOT NULL and minidvodb_path IS NOT NULL and mergedvodb_path IS NOT NULL "); 1084 1085 1086 psStringAppend(&query2, " AND minidvodb_group = '%s' limit 1;", minidvodb_group); 1087 1088 1089 1090 if (!p_psDBRunQuery(config->dbh, query2)) { 1091 psError(PS_ERR_UNKNOWN, false, "database error"); 1092 if (!psDBRollback(config->dbh)) { 1093 psError(PS_ERR_UNKNOWN, false, "database error"); 1094 } 1095 psFree(query); 1096 return false; 1097 1098 } 1099 1100 1101 1102 1103 1104 if (!psDBCommit(config->dbh)) { 1105 psError(PS_ERR_UNKNOWN, false, "database error"); 1106 if (!psDBRollback(config->dbh)) { 1107 psError(PS_ERR_UNKNOWN, false, "database error"); 1108 } 1109 psFree(query); 964 psArray *output = p_psDBFetchResult(config->dbh); 965 if (!output) { 966 psError(PS_ERR_UNKNOWN, false, "database error"); 967 return false; 968 } 969 if (!psArrayLength(output)) { 970 psTrace("addtool", PS_LOG_INFO, "no rows found"); 971 psFree(output); 972 return true; 973 } 974 975 976 //ok, there's something, so flip active -> waiting 977 978 psString query = psStringCopy("UPDATE minidvodbRun SET state = 'waiting' WHERE state = 'active' "); 979 980 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 981 psStringAppend(&query, " AND %s", whereClause); 982 983 984 if (!p_psDBRunQuery(config->dbh, query)) { 985 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 986 if (!psDBRollback(config->dbh)) { 987 psError(PS_ERR_UNKNOWN, false, "database error"); 988 } 989 return false; 990 } 991 992 993 //now flip new -> active 994 psString query2 = psStringCopy("UPDATE minidvodbRun SET state = 'active' WHERE state = 'new' AND minidvodb_name is NOT NULL and minidvodb_group IS NOT NULL and minidvodb_path IS NOT NULL and mergedvodb_path IS NOT NULL "); 995 psStringAppend(&query2, " AND minidvodb_group = '%s' limit 1;", minidvodb_group); 996 if (!p_psDBRunQuery(config->dbh, query2)) { 997 psError(PS_ERR_UNKNOWN, false, "database error"); 998 if (!psDBRollback(config->dbh)) { 999 psError(PS_ERR_UNKNOWN, false, "database error"); 1000 } 1001 psFree(query); 1002 return false; 1003 } 1004 1005 1006 if (!psDBCommit(config->dbh)) { 1007 psError(PS_ERR_UNKNOWN, false, "database error"); 1008 if (!psDBRollback(config->dbh)) { 1009 psError(PS_ERR_UNKNOWN, false, "database error"); 1010 } 1011 psFree(query); 1110 1012 return false; 1111 }1013 } 1112 1014 psFree(query2); 1113 psFree(where);1114 1115 return true;1116 1015 psFree(where); 1016 1017 return true; 1018 1117 1019 } 1118 1020 … … 1121 1023 PS_ASSERT_PTR_NON_NULL(config, false); 1122 1024 psMetadata *where = psMetadataAlloc(); 1025 1026 //this checks to see if a minidvod_group/name is has completed addRun processing 1123 1027 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "minidvodbRun.minidvodb_group", "=="); 1124 1028 PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidvodbRun.minidvodb_name", "=="); … … 1128 1032 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1129 1033 PXOPT_LOOKUP_BOOL(all_addrun_states, config->args, "-all_addrun_states", false); 1034 //this doesn't care what state the addRun is in (useful for counting addRuns) 1130 1035 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1131 1036 … … 1145 1050 1146 1051 if (psListLength(where->list)) { 1147 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);1052 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1148 1053 psStringAppend(&query, " WHERE %s", whereClause); 1149 1054 psFree(whereClause); … … 1160 1065 } 1161 1066 1162 1163 1164 1165 1166 if (!p_psDBRunQuery(config->dbh, query)) { 1167 psError(PS_ERR_UNKNOWN, false, "database error");1067 1068 if (!p_psDBRunQuery(config->dbh, query)) { 1069 psError(PS_ERR_UNKNOWN, false, "database error"); 1070 psFree(query); 1071 return false; 1072 } 1168 1073 psFree(query); 1169 return false; 1170 } 1171 psFree(query); 1172 psArray *output = p_psDBFetchResult(config->dbh); 1173 if (!output) { 1174 psError(PS_ERR_UNKNOWN, false, "database error"); 1175 return false; 1176 } 1177 if (!psArrayLength(output)) { 1178 psTrace("addtool", PS_LOG_INFO, "no rows found"); 1074 psArray *output = p_psDBFetchResult(config->dbh); 1075 if (!output) { 1076 psError(PS_ERR_UNKNOWN, false, "database error"); 1077 return false; 1078 } 1079 if (!psArrayLength(output)) { 1080 psTrace("addtool", PS_LOG_INFO, "no rows found"); 1081 psFree(output); 1082 return true; 1083 } 1084 1085 if (!ippdbPrintMetadatas(stdout, output, "minidvodbRun", !simple)) { 1086 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1087 psFree(output); 1088 return false; 1089 } 1090 1179 1091 psFree(output); 1180 return true;1181 }1182 1183 if (!ippdbPrintMetadatas(stdout, output, "addProcessedExp", !simple)) {1184 psError(PS_ERR_UNKNOWN, false, "failed to print array");1185 psFree(output);1186 return false;1187 }1188 1189 psFree(output);1190 1191 1092 1192 1093 return true; … … 1199 1100 psMetadata *where = psMetadataAlloc(); 1200 1101 1201 //PXOPT_LOOKUP_BOOL(finished_addrun, config->args, "-finished_addrun", false); 1202 //if (finished_addrun) { //too many selects, and I couldn't figure out how to rename it 1203 // PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidbn", "=="); 1204 // PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "minidbg", "=="); 1205 //} else { 1206 PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidvodbRun.minidvodb_name", "LIKE"); 1207 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "minidvodbRun.minidvodb_group", "=="); 1208 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbRun.minidvodb_id", "=="); 1209 //pxAddLabelSearchArgs (config, where, "-minidvodb_group", "addRun.minidvodb_group", "=="); 1210 // } 1102 PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidvodbRun.minidvodb_name", "LIKE"); 1103 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "minidvodbRun.minidvodb_group", "=="); 1104 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbRun.minidvodb_id", "=="); 1105 1211 1106 PXOPT_COPY_STR(config->args, where, "-state", "minidvodbRun.state", "=="); 1212 1107 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1213 1214 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1215 1216 1217 if (!psListLength(where->list)) { 1218 psFree(where); 1219 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 1220 return false; 1221 } 1222 1223 //there is a different starting query, depending on if it is limited to list minidvodbs with finished addRun processing or not. 1224 psString query = NULL; 1225 psString query1 = pxDataGet("addtool_find_minidvodbrun.sql"); 1226 //psString query2 = pxDataGet("addtool_find_minidvodbrun2.sql"); 1227 //if (finished_addrun) { 1228 // psStringAppend(&query, "%s",query2); 1229 //} else { 1230 psStringAppend(&query, "%s",query1); 1231 //} 1232 //psString query = pxDataGet("addtool_find_minidvodbrun.sql"); 1233 if (!query) { 1234 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1235 return false; 1236 } 1237 1238 1239 1240 //if (finished_addrun) { //finished addrun does not need the WHERE 1241 // if (psListLength(where->list)) { 1242 // psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1243 // psStringAppend(&query, " AND %s", whereClause); 1244 // psFree(whereClause); 1245 // } } else { 1246 if (psListLength(where->list)) { 1247 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1248 psStringAppend(&query, " WHERE %s", whereClause); 1249 psFree(whereClause); 1250 } 1251 //} 1252 1253 //if (!finished_addrun) { 1254 //finished_addrun does not need this 1255 // psStringAppend(&query, " %s", " GROUP BY minidvodbRun.minidvodb_name ORDER BY minidvodbRun.minidvodb_name "); 1256 //} 1257 1258 1259 if (limit) { 1260 psString limitString = psDBGenerateLimitSQL(limit); 1261 psStringAppend(&query, " %s", limitString); 1262 psFree(limitString); 1263 } 1264 1265 // psError(PS_ERR_UNKNOWN, false, "%s", query); 1266 //return false; 1108 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1109 1110 1111 if (!psListLength(where->list)) { 1112 psFree(where); 1113 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 1114 return false; 1115 } 1267 1116 1268 if (!p_psDBRunQuery(config->dbh, query)) { 1269 psError(PS_ERR_UNKNOWN, false, "database error"); 1270 psFree(query); 1271 return false; 1272 } 1273 psFree(query); 1274 psArray *output = p_psDBFetchResult(config->dbh); 1275 if (!output) { 1276 psError(PS_ERR_UNKNOWN, false, "database error"); 1277 return false; 1278 } 1279 if (!psArrayLength(output)) { 1280 psTrace("addtool", PS_LOG_INFO, "no rows found"); 1281 psFree(output); 1282 return true; 1283 } 1284 1285 if (!ippdbPrintMetadatas(stdout, output, "minidvodbRun", !simple)) { 1286 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1287 psFree(output); 1288 return false; 1289 } 1290 1291 psFree(output); 1292 1293 1294 1295 return true; 1296 } 1297 1298 static bool addminidvodbprocessedMode(pxConfig *config) { 1299 1300 PS_ASSERT_PTR_NON_NULL(config, false); 1301 1302 // required 1303 PXOPT_LOOKUP_U64(minidvodb_id, config->args, "-minidvodb_id", true, false); 1304 1305 // optional 1306 PXOPT_LOOKUP_U64(merge_order, config->args, "-merge_order", false, false); 1307 PXOPT_LOOKUP_F32(dtime_relphot, config->args, "-dtime_relphot", false, false); 1308 PXOPT_LOOKUP_F32(dtime_resort, config->args, "-dtime_resort", false, false); 1309 PXOPT_LOOKUP_F32(dtime_merge, config->args, "-dtime_merge", false, false); 1310 PXOPT_LOOKUP_TIME(epoch, config->args, "-epoch", false, false); 1311 PXOPT_LOOKUP_STR(mergedvodb_path, config->args, "-mergedvodb_path", true, false); 1312 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-minidvodb_group", true, false); 1313 1314 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1315 //generate restrictions 1316 psMetadata *where = psMetadataAlloc(); 1317 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbRun.minidvodb_id", "=="); 1318 1319 1320 if (!psDBTransaction(config->dbh)) { 1321 psError(PS_ERR_UNKNOWN, false, "database error"); 1322 1323 return false; 1324 } 1325 1326 1327 psString query = pxDataGet("addtool_find_pendingmergeprocess.sql"); 1117 psString query = pxDataGet("addtool_find_minidvodbrun.sql"); 1118 1328 1119 if (!query) { 1329 1120 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1330 1121 return false; 1331 1122 } 1332 // use psDBGenerateWhereSQL because the SQL yields an intermediate table 1123 1333 1124 if (psListLength(where->list)) { 1334 psString whereClaus = psDBGenerateWhereConditionSQL(where, NULL); 1335 psStringAppend(&query, " AND %s", whereClaus); 1336 psFree(whereClaus); 1337 } 1338 psFree(where); 1339 1125 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1126 psStringAppend(&query, " WHERE %s", whereClause); 1127 psFree(whereClause); 1128 } 1129 1130 if (limit) { 1131 psString limitString = psDBGenerateLimitSQL(limit); 1132 psStringAppend(&query, " %s", limitString); 1133 psFree(limitString); 1134 } 1135 1340 1136 if (!p_psDBRunQuery(config->dbh, query)) { 1341 1137 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1343 1139 return false; 1344 1140 } 1141 1345 1142 psFree(query); 1346 1347 1143 psArray *output = p_psDBFetchResult(config->dbh); 1348 1144 if (!output) { … … 1355 1151 return true; 1356 1152 } 1357 1358 //if (!psDBTransaction(config->dbh)) { 1359 // psError(PS_ERR_UNKNOWN, false, "database error"); 1360 // psFree(output); 1361 // return false; 1362 // } 1363 minidvodbRunRow *pendingRow = minidvodbRunObjectFromMetadata(output->data[0]); 1364 psFree(output); 1365 minidvodbProcessedRow *row = minidvodbProcessedRowAlloc( 1153 1154 if (!ippdbPrintMetadatas(stdout, output, "minidvodbRun", !simple)) { 1155 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1156 psFree(output); 1157 return false; 1158 } 1159 1160 psFree(output); 1161 1162 return true; 1163 } 1164 1165 static bool addminidvodbprocessedMode(pxConfig *config) { 1166 1167 PS_ASSERT_PTR_NON_NULL(config, false); 1168 1169 // required 1170 PXOPT_LOOKUP_U64(minidvodb_id, config->args, "-minidvodb_id", true, false); 1171 PXOPT_LOOKUP_STR(mergedvodb_path, config->args, "-mergedvodb_path", true, false); 1172 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-minidvodb_group", true, false); 1173 1174 // optional 1175 PXOPT_LOOKUP_U64(merge_order, config->args, "-merge_order", false, false); 1176 PXOPT_LOOKUP_F32(dtime_relphot, config->args, "-dtime_relphot", false, false); 1177 PXOPT_LOOKUP_F32(dtime_resort, config->args, "-dtime_resort", false, false); 1178 PXOPT_LOOKUP_F32(dtime_merge, config->args, "-dtime_merge", false, false); 1179 PXOPT_LOOKUP_TIME(epoch, config->args, "-epoch", false, false); 1180 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1181 //generate restrictions 1182 psMetadata *where = psMetadataAlloc(); 1183 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbRun.minidvodb_id", "=="); 1184 1185 1186 if (!psDBTransaction(config->dbh)) { 1187 psError(PS_ERR_UNKNOWN, false, "database error"); 1188 return false; 1189 } 1190 1191 1192 psString query = pxDataGet("addtool_find_pendingmergeprocess.sql"); 1193 if (!query) { 1194 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1195 return false; 1196 } 1197 // use psDBGenerateWhereSQL because the SQL yields an intermediate table 1198 if (psListLength(where->list)) { 1199 psString whereClaus = psDBGenerateWhereConditionSQL(where, NULL); 1200 psStringAppend(&query, " AND %s", whereClaus); 1201 psFree(whereClaus); 1202 } 1203 psFree(where); 1204 1205 if (!p_psDBRunQuery(config->dbh, query)) { 1206 psError(PS_ERR_UNKNOWN, false, "database error"); 1207 psFree(query); 1208 return false; 1209 } 1210 psFree(query); 1211 1212 psArray *output = p_psDBFetchResult(config->dbh); 1213 if (!output) { 1214 psError(PS_ERR_UNKNOWN, false, "database error"); 1215 return false; 1216 } 1217 if (!psArrayLength(output)) { 1218 psTrace("addtool", PS_LOG_INFO, "no rows found"); 1219 psFree(output); 1220 return true; 1221 } 1222 1223 minidvodbRunRow *pendingRow = minidvodbRunObjectFromMetadata(output->data[0]); 1224 psFree(output); 1225 minidvodbProcessedRow *row = minidvodbProcessedRowAlloc( 1366 1226 pendingRow->minidvodb_id, 1367 1227 merge_order, … … 1374 1234 ); 1375 1235 1376 if (!minidvodbProcessedInsertObject(config->dbh, row)) { 1377 // rollback 1378 if (!psDBRollback(config->dbh)) { 1379 psError(PS_ERR_UNKNOWN, false, "database error"); 1380 } 1381 psError(PS_ERR_UNKNOWN, false, "database error"); 1382 psFree(row); 1383 psFree(pendingRow); 1384 return false; 1385 } 1386 1387 // since there is only one exp per 'new' set addRun.state = 'full' 1236 if (!minidvodbProcessedInsertObject(config->dbh, row)) { 1237 // rollback 1238 if (!psDBRollback(config->dbh)) { 1239 psError(PS_ERR_UNKNOWN, false, "database error"); 1240 } 1241 psError(PS_ERR_UNKNOWN, false, "database error"); 1242 psFree(row); 1243 psFree(pendingRow); 1244 return false; 1245 } 1246 1247 // since there is only one exp per 'new' set mindvodbRun.state = 'merging' 1248 1249 psString query2 = NULL ; 1250 psStringAppend(&query2, "UPDATE minidvodbRun SET state = 'merging' WHERE minidvodb_id = %'" PRIu64, row->minidvodb_id); 1388 1251 1389 psString query2 = NULL ; 1390 psStringAppend(&query2, "UPDATE minidvodbRun SET state = 'merging' WHERE minidvodb_id = %'" PRIu64, row->minidvodb_id); 1252 if (!p_psDBRunQuery(config->dbh, query2)) { 1253 // rollback 1254 if (!psDBRollback(config->dbh)) { 1255 psError(PS_ERR_UNKNOWN, false, "database error"); 1256 } 1257 psError(PS_ERR_UNKNOWN, false, "database error"); 1258 psFree(query2); 1259 return false; 1260 } 1261 1262 1263 1264 1265 //this finds the # of merged things (for the merge order) 1266 psString query3 = NULL; 1267 psStringAppend(&query3, "select count(*) from minidvodbRun join minidvodbProcessed using (minidvodb_id) where state = 'merged' and minidvodb_group = '%s';", minidvodb_group); 1268 1269 if (!p_psDBRunQuery(config->dbh, query3)) { 1270 // rollback 1271 if (!psDBRollback(config->dbh)) { 1272 psError(PS_ERR_UNKNOWN, false, "database error"); 1273 } 1274 psError(PS_ERR_UNKNOWN, false, "database error"); 1275 psFree(query3); 1276 return false; 1277 } 1278 psArray *output2 = p_psDBFetchResult(config->dbh); 1279 if (!output2) { 1280 psError(PS_ERR_UNKNOWN, false, "database error"); 1281 return false; 1282 } 1283 if (!psArrayLength(output2)) { 1284 psTrace("addtool", PS_LOG_INFO, "no rows found"); 1285 psFree(output); 1286 return true; 1287 } 1288 bool status; 1289 psS64 m_order = psMetadataLookupS64(&status, output2->data[0], "count(*)"); 1290 if (!status) { 1291 1292 psAbort("failed to lookup value for count column"); 1293 return false; 1294 } 1295 psString final = NULL; 1296 psStringAppend(&final, "%" PRIu64, m_order); 1297 //return false; 1298 psFree(query3); 1299 psFree(output2); 1300 1301 1302 1303 //update the merge_order 1304 1305 psString query4 = NULL; 1306 psStringAppend(&query4, "update minidvodbProcessed set merge_order = %"PRIu64,m_order); 1307 psStringAppend(&query4," where minidvodb_id = %" PRIu64, minidvodb_id); 1308 printf("%s", query4); 1309 if (!p_psDBRunQuery(config->dbh, query4)) { 1310 // rollback 1311 if (!psDBRollback(config->dbh)) { 1312 psError(PS_ERR_UNKNOWN, false, "database error"); 1313 } 1314 psError(PS_ERR_UNKNOWN, false, "database error"); 1315 psFree(query4); 1316 return false; 1317 } 1318 // 1319 1320 1321 psFree(query4); 1322 psFree(row); 1323 psFree(pendingRow); 1324 1325 1326 1327 1328 1329 //commit the changes 1330 if (!psDBCommit(config->dbh)) { 1331 psError(PS_ERR_UNKNOWN, false, "database error"); 1332 return false; 1333 } 1391 1334 1392 if (!p_psDBRunQuery(config->dbh, query2)) { 1393 // rollback 1394 if (!psDBRollback(config->dbh)) { 1395 psError(PS_ERR_UNKNOWN, false, "database error"); 1396 } 1397 psError(PS_ERR_UNKNOWN, false, "database error"); 1398 psFree(query2); 1399 return false; 1400 } 1401 1402 //this finds the # of merged things (for the merge order) 1403 psString query3 = NULL; 1404 psStringAppend(&query3, "select count(*) from minidvodbRun join minidvodbProcessed using (minidvodb_id) where state = 'merged' and minidvodb_group = '%s';", minidvodb_group); 1405 1406 if (!p_psDBRunQuery(config->dbh, query3)) { 1407 // rollback 1408 if (!psDBRollback(config->dbh)) { 1409 psError(PS_ERR_UNKNOWN, false, "database error"); 1410 } 1411 psError(PS_ERR_UNKNOWN, false, "database error"); 1412 psFree(query3); 1413 return false; 1414 } 1415 psArray *output2 = p_psDBFetchResult(config->dbh); 1416 if (!output2) { 1417 psError(PS_ERR_UNKNOWN, false, "database error"); 1418 return false; 1419 } 1420 if (!psArrayLength(output2)) { 1421 psTrace("addtool", PS_LOG_INFO, "no rows found"); 1422 psFree(output); 1423 return true; 1424 } 1425 bool status; 1426 psS64 m_order = psMetadataLookupS64(&status, output2->data[0], "count(*)"); 1427 if (!status) { 1428 1429 psAbort("failed to lookup value for count column"); 1430 return false; 1431 } 1432 psString final = NULL; 1433 psStringAppend(&final, "%" PRIu64, m_order); 1434 printf("%s", final); 1435 //return false; 1436 1437 1438 1439 psFree(query3); 1440 1441 1442 psFree(output2); 1443 1444 1445 psString query4 = NULL; 1446 psStringAppend(&query4, "update minidvodbProcessed set merge_order = %"PRIu64,m_order); 1447 psStringAppend(&query4," where minidvodb_id = %" PRIu64, minidvodb_id); 1448 printf("%s", query4); 1449 if (!p_psDBRunQuery(config->dbh, query4)) { 1450 // rollback 1451 if (!psDBRollback(config->dbh)) { 1452 psError(PS_ERR_UNKNOWN, false, "database error"); 1453 } 1454 psError(PS_ERR_UNKNOWN, false, "database error"); 1455 psFree(query4); 1456 return false; 1457 } 1458 // 1459 1460 1461 psFree(query4); 1462 psFree(row); 1463 psFree(pendingRow); 1464 1465 if (!psDBCommit(config->dbh)) { 1466 psError(PS_ERR_UNKNOWN, false, "database error"); 1467 return false; 1468 } 1469 1470 1471 printf("%s", final); 1472 psFree(final); 1473 1474 return true; 1475 } 1476 1335 1336 //print the merge_order (why not!) 1337 printf("%s", final); 1338 psFree(final); 1339 1340 return true; 1341 } 1342 1343 1344 1477 1345 static bool listminidvodbprocessedMode(pxConfig *config) { 1478 1346 psMetadata *where = psMetadataAlloc(); … … 1520 1388 psFree(where); 1521 1389 1522 1523 //psStringAppend(&query, " GROUP BY minidvodb_name");1524 1525 1390 // order by epoch 1526 1391 psStringAppend(&query, " ORDER BY minidvodb_id"); … … 1563 1428 } 1564 1429 1430 1431 1565 1432 static bool revertminidvodbprocessedMode(pxConfig *config) { 1566 1433 psMetadata *where = psMetadataAlloc(); 1567 PS_ASSERT_PTR_NON_NULL(config, false); 1568 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbProcessed.minidvodb_id", "=="); 1569 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "addRun.minidvodb_group", "=="); 1570 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { 1571 psFree(where); 1572 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 1573 return false; 1574 } 1575 1576 if (!psDBTransaction(config->dbh)) { 1577 psError(PS_ERR_UNKNOWN, false, "database error"); 1578 psFree(where); 1579 return false; 1580 } 1581 1582 { 1434 PS_ASSERT_PTR_NON_NULL(config, false); 1435 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbProcessed.minidvodb_id", "=="); 1436 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "addRun.minidvodb_group", "=="); 1437 1438 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { 1439 psFree(where); 1440 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 1441 return false; 1442 } 1443 1444 if (!psDBTransaction(config->dbh)) { 1445 psError(PS_ERR_UNKNOWN, false, "database error"); 1446 psFree(where); 1447 return false; 1448 } 1449 1450 { 1583 1451 psString query = pxDataGet("addtool_reset_faulted_minidvodbruns.sql"); 1584 1452 if (!query) { … … 1587 1455 return false; 1588 1456 } 1589 1457 1590 1458 // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE 1591 1592 if (where && psListLength(where->list)) {1593 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);1594 psStringAppend(&query, " AND %s", whereClause);1595 psFree(whereClause);1596 }1597 1459 1460 if (where && psListLength(where->list)) { 1461 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1462 psStringAppend(&query, " AND %s", whereClause); 1463 psFree(whereClause); 1464 } 1465 1598 1466 if (!p_psDBRunQuery(config->dbh, query)) { 1599 // rollback1467 // rollback 1600 1468 if (!psDBRollback(config->dbh)) { 1601 psError(PS_ERR_UNKNOWN, false, "database error");1602 }1603 psError(PS_ERR_UNKNOWN, false, "database error");1604 psFree(query);1605 psFree(where);1606 return false;1469 psError(PS_ERR_UNKNOWN, false, "database error"); 1470 } 1471 psError(PS_ERR_UNKNOWN, false, "database error"); 1472 psFree(query); 1473 psFree(where); 1474 return false; 1607 1475 } 1608 1476 psFree(query); 1609 } 1610 { 1611 psString query = pxDataGet("addtool_revertminidvodbprocessed.sql"); 1612 if (!query) { 1613 // rollback 1614 if (!psDBRollback(config->dbh)) { 1615 psError(PS_ERR_UNKNOWN, false, "database error"); 1616 } 1617 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1618 psFree(where); 1477 } 1478 { 1479 psString query = pxDataGet("addtool_revertminidvodbprocessed.sql"); 1480 if (!query) { 1481 // rollback 1482 if (!psDBRollback(config->dbh)) { 1483 psError(PS_ERR_UNKNOWN, false, "database error"); 1484 } 1485 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1486 psFree(where); 1487 return false; 1488 } 1489 1490 // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE 1491 if (where && psListLength(where->list)) { 1492 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1493 psStringAppend(&query, " AND %s", whereClause); 1494 psFree(whereClause); 1495 } 1496 1497 if (!p_psDBRunQuery(config->dbh, query)) { 1498 // rollback 1499 if (!psDBRollback(config->dbh)) { 1500 psError(PS_ERR_UNKNOWN, false, "database error"); 1501 } 1502 psError(PS_ERR_UNKNOWN, false, "database error"); 1503 psFree(query); 1504 psFree(where); 1619 1505 return false; 1620 } 1621 1622 // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE 1623 if (where && psListLength(where->list)) { 1624 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1625 psStringAppend(&query, " AND %s", whereClause); 1626 psFree(whereClause); 1627 } 1628 1629 if (!p_psDBRunQuery(config->dbh, query)) { 1630 // rollback 1631 if (!psDBRollback(config->dbh)) { 1632 psError(PS_ERR_UNKNOWN, false, "database error"); 1633 } 1634 psError(PS_ERR_UNKNOWN, false, "database error"); 1635 psFree(query); 1636 psFree(where); 1637 return false; 1638 } 1639 psFree(query); 1640 } 1641 psFree(where); 1642 1643 if (!psDBCommit(config->dbh)) { 1644 psError(PS_ERR_UNKNOWN, false, "database error"); 1645 return false; 1646 } 1647 1648 1649 1650 return true; 1651 } 1506 } 1507 psFree(query); 1508 } 1509 psFree(where); 1510 1511 if (!psDBCommit(config->dbh)) { 1512 psError(PS_ERR_UNKNOWN, false, "database error"); 1513 return false; 1514 } 1515 1516 return true; 1517 } 1518 1519 1652 1520 1653 1521 static bool updateminidvodbprocessedMode(pxConfig *config) { 1654 1522 PS_ASSERT_PTR_NON_NULL(config, false); 1655 1656 psMetadata *where = psMetadataAlloc(); 1657 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbProcessed.minidvodb_id", "=="); 1658 PXOPT_LOOKUP_U64(minidvodb_id, config->args, "-minidvodb_id", true, false); 1659 PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidvodbRun.minidvodb_name", "=="); 1660 1661 PXOPT_LOOKUP_U64(merge_order, config->args, "-set_merge_order", false, false); 1662 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 1663 PXOPT_LOOKUP_F32(dtime_relphot, config->args, "-set_dtime_relphot", false, false); 1664 PXOPT_LOOKUP_F32(dtime_resort, config->args, "-set_dtime_resort", false, false); 1665 PXOPT_LOOKUP_F32(dtime_merge, config->args, "-set_dtime_merge", false, false); 1666 1667 1668 1669 if (!psListLength(where->list)) { 1670 psFree(where); 1671 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 1672 return false; 1673 } 1674 1675 psString query = psStringCopy("UPDATE minidvodbProcessed JOIN minidvodbRun USING (minidvodb_id) SET "); 1676 int cnt = 0; 1677 psString comma = ","; 1678 if (fault) { 1679 psStringAppend(&query, " fault = %d", fault); 1523 psMetadata *where = psMetadataAlloc(); 1524 1525 PXOPT_LOOKUP_U64(minidvodb_id, config->args, "-minidvodb_id", true, false); 1526 PXOPT_LOOKUP_U64(merge_order, config->args, "-set_merge_order", false, false); 1527 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 1528 PXOPT_LOOKUP_F32(dtime_relphot, config->args, "-set_dtime_relphot", false, false); 1529 PXOPT_LOOKUP_F32(dtime_resort, config->args, "-set_dtime_resort", false, false); 1530 PXOPT_LOOKUP_F32(dtime_merge, config->args, "-set_dtime_merge", false, false); 1531 1532 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbProcessed.minidvodb_id", "=="); 1533 PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidvodbRun.minidvodb_name", "=="); 1534 1535 1536 if (!psListLength(where->list)) { 1537 psFree(where); 1538 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 1539 return false; 1540 } 1541 1542 psString query = psStringCopy("UPDATE minidvodbProcessed JOIN minidvodbRun USING (minidvodb_id) SET "); 1543 int cnt = 0; 1544 psString comma = ","; 1545 if (fault) { 1546 psStringAppend(&query, " fault = %d", fault); 1680 1547 cnt++; 1681 }1682 1683 if (merge_order) {1684 if (cnt) {1685 psStringAppend(&query,comma);1686 }1687 1688 psStringAppend(&query, " merge_order = %" PRId64, merge_order);1689 cnt++;1690 }1691 1692 if (dtime_relphot) {1693 if (cnt) {1694 psStringAppend(&query,comma);1695 }1696 psStringAppend(&query, " dtime_relphot = %f", dtime_relphot);1697 cnt++;1698 }1699 1700 if (dtime_resort) {1701 if (cnt) {1702 psStringAppend(&query,comma);1703 }1704 psStringAppend(&query, " dtime_resort = %f", dtime_resort);1705 cnt++;1706 }1707 1708 if (dtime_merge) {1709 if (cnt) {1710 psStringAppend(&query,comma);1711 }1712 psStringAppend(&query, " dtime_merge = %f", dtime_merge);1713 cnt++;1548 } 1549 1550 if (merge_order) { 1551 if (cnt) { 1552 psStringAppend(&query,comma); 1553 } 1554 1555 psStringAppend(&query, " merge_order = %" PRId64, merge_order); 1556 cnt++; 1557 } 1558 1559 if (dtime_relphot) { 1560 if (cnt) { 1561 psStringAppend(&query,comma); 1562 } 1563 psStringAppend(&query, " dtime_relphot = %f", dtime_relphot); 1564 cnt++; 1565 } 1566 1567 if (dtime_resort) { 1568 if (cnt) { 1569 psStringAppend(&query,comma); 1570 } 1571 psStringAppend(&query, " dtime_resort = %f", dtime_resort); 1572 cnt++; 1573 } 1574 1575 if (dtime_merge) { 1576 if (cnt) { 1577 psStringAppend(&query,comma); 1578 } 1579 psStringAppend(&query, " dtime_merge = %f", dtime_merge); 1580 cnt++; 1714 1581 } 1715 1582 1716 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);1717 psStringAppend(&query, " WHERE %s", whereClause);1718 1719 if (!p_psDBRunQuery(config->dbh, query)) {1583 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1584 psStringAppend(&query, " WHERE %s", whereClause); 1585 1586 if (!p_psDBRunQuery(config->dbh, query)) { 1720 1587 psError(PS_ERR_UNKNOWN, false, "database error %s", query); 1721 psFree(query); 1722 return false; 1723 } 1724 1725 1726 1727 psFree(query); 1728 psFree(where); 1729 1730 1731 1732 1733 return true; 1734 } 1735 1736 1588 psFree(query); 1589 return false; 1590 } 1591 1592 psFree(query); 1593 psFree(where); 1594 1595 return true; 1596 } 1597 1598 -
branches/haf_branches/ipp.20100512/ippTools/src/addtoolConfig.c
r28171 r28177 86 86 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define new dist_group", NULL); 87 87 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "define new note", NULL); 88 88 89 // -pendingexp 89 90 psMetadata *pendingexpArgs = psMetadataAlloc(); … … 155 156 // -updateminidvodbruns 156 157 psMetadata *updateminidvodbrunArgs = psMetadataAlloc(); 157 psMetadataAddU64(updateminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_id", 0, "search by minidvodb_id ", 0);158 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_group", 0, "search by minidvodb_name (LIKE)", NULL);159 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_name", 0, "search by minidvodb_name (LIKE)", NULL);158 psMetadataAddU64(updateminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_id", 0, "search by minidvodb_id ", 0); 159 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_group", 0, "search by minidvodb_name (LIKE)", NULL); 160 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_name", 0, "search by minidvodb_name (LIKE)", NULL); 160 161 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_path", 0, "search by path for minidvodb", NULL); 161 162 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-mergedvodb_path", 0, "search by path for the merged dvodb", NULL); 162 163 163 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-state", 0, "search by state", NULL); 164 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-set_minidvodb_name", 0, "define minidvodb_name", NULL);164 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-set_minidvodb_name", 0, "define minidvodb_name", NULL); 165 165 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-set_minidvodb_path", 0, "define path for minidvodb", NULL); 166 166 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-set_mergedvodb_path", 0, "define path for minidvodb", NULL); 167 167 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-set_minidvodb_group", 0, "define path for the merged dvodb", NULL); 168 168 psMetadataAddStr(updateminidvodbrunArgs, PS_LIST_TAIL, "-set_state", 0, "define state", NULL); 169 169 170 // -listminidvodbrunArgs 170 171 psMetadata *listminidvodbrunArgs = psMetadataAlloc(); 171 psMetadataAddU64(listminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_id", 0, "search by minidvodb_id", 0);172 psMetadataAddU64(listminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_id", 0, "search by minidvodb_id", 0); 172 173 psMetadataAddStr(listminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_name", 0, "search by minidvodb_name (LIKE)", NULL); 173 174 psMetadataAddStr(listminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_group", 0, "search by minidvodb.minidvodb_group", NULL); … … 175 176 psMetadataAddU64(listminidvodbrunArgs, PS_LIST_TAIL, "-limit", 0, "limit to N items", 0); 176 177 psMetadataAddBool(listminidvodbrunArgs, PS_LIST_TAIL, "-simple", 0, "simple output", false); 178 177 179 //psMetadataAddBool(listminidvodbrunArgs, PS_LIST_TAIL, "-finished_addrun", 0, "limit to minidvodbs with completed addRuns (none in new state)", false); 178 179 180 psMetadata *flipminidvodbrunArgs = psMetadataAlloc(); 180 181 psMetadataAddStr(flipminidvodbrunArgs, PS_LIST_TAIL, "-minidvodb_group", 0, "for the supplied minidvodb_group (required): flip the current 'new' to 'active', the current 'active' to 'waiting'", NULL); … … 196 197 psMetadataAddTime(addminidvodbprocessedArgs, PS_LIST_TAIL, "-epoch", 0, "time merge is finished", NULL); 197 198 psMetadataAddStr(addminidvodbprocessedArgs, PS_LIST_TAIL, "-mergedvodb_path",0, "path of merged dvodb", NULL); 198 psMetadataAddStr(addminidvodbprocessedArgs, PS_LIST_TAIL, "-minidvodb_group",0, "minidvodb_group", NULL);199 psMetadataAddStr(addminidvodbprocessedArgs, PS_LIST_TAIL, "-minidvodb_group",0, "minidvodb_group", NULL); 199 200 psMetadataAddS16(addminidvodbprocessedArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0); 200 201 … … 236 237 PXOPT_ADD_MODE("-listminidvodbrun", "list minidvodbs", ADDTOOL_MODE_LISTMINIDVODBRUN, listminidvodbrunArgs); 237 238 PXOPT_ADD_MODE("-flipminidvodbrun", "flip minidvodbs", ADDTOOL_MODE_FLIPMINIDVODBRUN, flipminidvodbrunArgs); 238 PXOPT_ADD_MODE("-checkminidvodbrunaddrun", "check minidvodbs to see if addRuns are completed",ADDTOOL_MODE_CHECKMINIDVODBRUNADDRUN, checkminidvodbrunaddrunArgs);239 PXOPT_ADD_MODE("-checkminidvodbrunaddrun", "check minidvodbs to see if addRuns are completed", ADDTOOL_MODE_CHECKMINIDVODBRUNADDRUN, checkminidvodbrunaddrunArgs); 239 240 PXOPT_ADD_MODE("-addminidvodbprocessed","add a processed minidvodb", ADDTOOL_MODE_ADDMINIDVODBPROCESSED, addminidvodbprocessedArgs); 240 241 PXOPT_ADD_MODE("-listminidvodbprocessed","list processed minidvodbs", ADDTOOL_MODE_LISTMINIDVODBPROCESSED, listminidvodbprocessedArgs); … … 243 244 244 245 245 246 246 247 247
Note:
See TracChangeset
for help on using the changeset viewer.
