Changeset 31038
- Timestamp:
- Mar 24, 2011, 2:09:53 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
-
dbconfig/changes.txt (modified) (1 diff)
-
dbconfig/new.md (modified) (1 diff)
-
dbconfig/summitcopy.md (modified) (4 diffs)
-
ippScripts/scripts/summit_copy.pl (modified) (5 diffs)
-
ippTasks/summit.copy.pro (modified) (3 diffs)
-
ippTools/share/pxadmin_create_tables.sql (modified) (7 diffs)
-
ippTools/share/pztool_find_completed_exp.sql (modified) (2 diffs)
-
ippTools/share/pztool_pendingimfile.sql (modified) (1 diff)
-
ippTools/share/regtool_checkburntoolimfile.sql (modified) (1 diff)
-
ippTools/share/regtool_checkstatus.sql (modified) (1 diff)
-
ippTools/share/regtool_pendingburntoolimfile.sql (modified) (1 diff)
-
ippTools/src/pxinject.c (modified) (1 diff)
-
ippTools/src/pzgetexp.c (modified) (1 diff)
-
ippTools/src/pzgetimfiles.c (modified) (9 diffs)
-
ippTools/src/pztool.c (modified) (16 diffs)
-
ippTools/src/pztoolConfig.c (modified) (3 diffs)
-
ippTools/src/regtool.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dbconfig/changes.txt
r30945 r31038 2007 2007 2008 2008 ALTER TABLE stackSumSkyfile ADD column dtime_convolve FLOAT AFTER dtime_match_stdev; 2009 2010 -- Version 1.1.69 2011 2012 ALTER TABLE summitImfile DROP FOREIGN KEY summitImfile_ibfk_1; 2013 ALTER TABLE pzDownloadExp DROP FOREIGN KEY pzDownloadExp_ibfk_1; 2014 2015 ALTER TABLE summitExp DROP PRIMARY KEY; 2016 ALTER TABLE summitExp ADD COLUMN summit_id BIGINT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (summit_id); 2017 ALTER TABLE summitExp ADD KEY (exp_name,camera,telescope); 2018 2019 2020 ALTER TABLE pzDownloadImfile DROP FOREIGN KEY pzDownloadImfile_ibfk_2; 2021 2022 ALTER TABLE summitImfile ADD COLUMN summit_id BIGINT FIRST; 2023 UPDATE summitImfile,summitExp SET summitImfile.summit_id = summitExp.summit_id WHERE summitImfile.exp_name = summitExp.exp_name AND summitImfile.camera = summitExp.camera AND summitImfile.telescope = summitExp.telescope; 2024 2025 ALTER TABLE summitImfile DROP PRIMARY KEY, ADD PRIMARY KEY (summit_id,class,class_id); 2026 ALTER TABLE summitImfile ADD KEY (exp_name,camera,telescope,class,class_id); 2027 ALTER TABLE summitImfile ADD FOREIGN KEY(summit_id) REFERENCES summitExp(summit_id); 2028 ALTER TABLE summitImfile ADD FOREIGN KEY(exp_name,camera,telescope) REFERENCES summitExp(exp_name,camera,telescope); 2029 2030 2031 ALTER TABLE pzDownloadImfile DROP FOREIGN KEY pzDownloadImfile_ibfk_1; 2032 2033 ALTER TABLE pzDownloadExp ADD COLUMN summit_id BIGINT FIRST; 2034 UPDATE pzDownloadExp,summitExp SET pzDownloadExp.summit_id = summitExp.summit_id WHERE pzDownloadExp.exp_name = summitExp.exp_name AND pzDownloadExp.camera = summitExp.camera AND pzDownloadExp.telescope = summitExp.telescope; 2035 2036 ALTER TABLE pzDownloadExp DROP PRIMARY KEY, ADD PRIMARY KEY (summit_id); 2037 ALTER TABLE pzDownloadExp ADD KEY (exp_name,camera,telescope); 2038 ALTER TABLE pzDownloadExp ADD FOREIGN KEY(summit_id) REFERENCES summitExp(summit_id); 2039 ALTER TABLE pzDownloadExp ADD FOREIGN KEY(exp_name,camera,telescope) REFERENCES summitExp(exp_name,camera,telescope); 2040 2041 2042 ALTER TABLE pzDownloadImfile ADD COLUMN summit_id BIGINT FIRST; 2043 UPDATE pzDownloadImfile,pzDownloadExp SET pzDownloadImfile.summit_id = pzDownloadExp.summit_id WHERE pzDownloadImfile.exp_name = pzDownloadExp.exp_name AND pzDownloadImfile.camera = pzDownloadExp.camera AND pzDownloadImfile.telescope = pzDownloadExp.telescope; 2044 2045 ALTER TABLE pzDownloadImfile DROP PRIMARY KEY, ADD PRIMARY KEY (summit_id,class,class_id); 2046 ALTER TABLE pzDownloadImfile ADD FOREIGN KEY(summit_id) REFERENCES pzDownloadExp(summit_id); 2047 ALTER TABLE pzDownloadImfile ADD FOREIGN KEY(summit_id,class,class_id) REFERENCES summitImfile(summit_id,class,class_id); 2048 ALTER TABLE pzDownloadImfile ADD FOREIGN KEY(exp_name,camera,telescope) REFERENCES summitExp(exp_name,camera,telescope); 2049 ALTER TABLE pzDownloadImfile ADD FOREIGN KEY(exp_name,camera,telescope,class,class_id) REFERENCES summitImfile(exp_name,camera,telescope,class,class_id); 2050 2051 2052 ALTER TABLE newExp ADD COLUMN summit_id BIGINT AFTER exp_id; 2053 UPDATE newExp,pzDownloadExp SET newExp.summit_id = pzDownloadExp.summit_id WHERE newExp.tmp_exp_name = pzDownloadExp.exp_name AND newExp.tmp_camera = pzDownloadExp.camera AND newExp.tmp_telescope = pzDownloadExp.telescope; 2054 2055 ALTER TABLE newExp ADD KEY (summit_id); 2056 2057 2058 UPDATE dbversion set schema_version = '1.1.69', updated= CURRENT_TIMESTAMP(); 2059 2060 2061 -
trunk/dbconfig/new.md
r25418 r31038 1 1 newExp METADATA 2 2 exp_id S64 0 # Primary Key AUTO_INCREMENT 3 summit_id S64 0 # Key 3 4 tmp_exp_name STR 64 # Key 4 5 tmp_camera STR 64 # Key -
trunk/dbconfig/summitcopy.md
r26378 r31038 11 11 # -1 as NULL or 0 might be a valid value (empty fileset) 12 12 summitExp METADATA 13 exp_name STR 64 # Primary Key 14 camera STR 64 # Primary Key 15 telescope STR 64 # Primary Key 13 summit_id S64 0 # Primary Key AUTO_INCREMENT 14 exp_name STR 64 # Key 15 camera STR 64 # Key 16 telescope STR 64 # Key 16 17 dateobs UTC NULL 17 18 exp_type STR 64 … … 26 27 # list of source images -- updated as exposures/filesets are queried 27 28 summitImfile METADATA 28 exp_name STR 64 # Primary Key fkey(exp_name, camera, telescope) ref summitExp(exp_name, camera, telescope) 29 camera STR 64 # Primary Key 30 telescope STR 64 # Primary Key 29 summit_id S64 0 # Primary Key fkey(summit_id) ref summitExp(summit_id) 30 exp_name STR 64 # Key fkey(exp_name, camera, telescope) ref summitExp(exp_name, camera, telescope) 31 camera STR 64 # Key 32 telescope STR 64 # Key 31 33 file_id STR 64 # Key 32 34 bytes S32 0 … … 41 43 # downloaded) 42 44 pzDownloadExp METADATA 43 exp_name STR 64 # Primary Key fkey(exp_name, camera, telescope) ref summitExp(exp_name, camera, telescope) 44 camera STR 64 # Primary Key 45 telescope STR 64 # Primary Key 45 summit_id S64 0 # Primary Key fkey(summit_id) ref summitExp(summit_id) 46 exp_name STR 64 # Key fkey(exp_name, camera, telescope) ref summitExp(exp_name, camera, telescope) 47 camera STR 64 # Key 48 telescope STR 64 # Key 46 49 state STR 64 # Key 47 50 epoch UTC 0001-01-01T00:00:00Z … … 49 52 50 53 pzDownloadImfile METADATA 51 exp_name STR 64 # Primary Key fkey(exp_name, camera, telescope) ref pzDownloadExp(exp_name, camera, telescope) 52 camera STR 64 # Primary Key fkey(exp_name, camera, telescope, class, class_id) ref summitImfile(exp_name, camera, telescope, class, class_id) 53 telescope STR 64 # Primary Key 54 class STR 64 # Primary Key 54 summit_id S64 0 # Primary Key fkey(summit_id) ref pzDownloadExp(summit_id) 55 exp_name STR 64 # Key fkey(exp_name, camera, telescope) ref pzDownloadExp(exp_name, camera, telescope) 56 camera STR 64 # Key fkey(exp_name, camera, telescope, class, class_id) ref summitImfile(exp_name, camera, telescope, class, class_id) 57 telescope STR 64 # Key fkey(exp_name, camera, telescope) ref summitExp(exp_name, camera, telescope) 58 class STR 64 # Primary Key fkey(summit_id,class,class_id) ref summitImfile(summit_id,class,class_id) 55 59 class_id STR 64 # Primary Key 56 60 uri STR 255 -
trunk/ippScripts/scripts/summit_copy.pl
r30875 r31038 22 22 23 23 # Parse the command-line arguments 24 my ( $uri, $filename, $compress, $bytes, $md5, $nebulous, $ exp_name, $inst, $telescope, $class, $class_id,24 my ( $uri, $filename, $compress, $bytes, $md5, $nebulous, $summit_id, $exp_name, $inst, $telescope, $class, $class_id, 25 25 $dbname, $verbose, $no_update, $no_op, $timeout, $copies ); 26 26 GetOptions( … … 31 31 'md5=s' => \$md5, # reported md5 checksum 32 32 'nebulous' => \$nebulous, # use nebulous for the target file 33 'summit_id=s' => \$summit_id, # summit_id for this exposure 33 34 'exp_name=s' => \$exp_name, # Exposure name 34 35 'inst=s' => \$inst, # Instrument … … 45 46 46 47 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 47 pod2usage( -msg => "Required options: --uri --filename -- exp_name --inst --telescope --class --class_id",48 pod2usage( -msg => "Required options: --uri --filename --summit_id --exp_name --inst --telescope --class --class_id", 48 49 -exitval => 3) 49 50 unless defined $uri 50 51 and defined $filename 52 and defined $summit_id 51 53 and defined $exp_name 52 54 and defined $inst … … 110 112 $command = "$pztool -copydone"; 111 113 $command .= " -row_lock"; 114 $command .= " -summit_id $summit_id"; 112 115 $command .= " -exp_name $exp_name"; 113 116 $command .= " -inst $inst"; … … 236 239 my $command; 237 240 $command = "$pztool -copydone"; 241 $command .= " -summit_id $summit_id"; 238 242 $command .= " -exp_name $exp_name"; 239 243 $command .= " -inst $inst"; -
trunk/ippTasks/summit.copy.pro
r27895 r31038 429 429 book getword pzPendingImfile $pageName md5sum -var MD5SUM 430 430 book getword pzPendingImfile $pageName dateobs -var DATEOBS 431 book getword pzPendingImfile $pageName summit_id -var SUMMIT_ID 431 432 book getword pzPendingImfile $pageName exp_name -var EXP_NAME 432 433 book getword pzPendingImfile $pageName camera -var CAMERA … … 479 480 end 480 481 481 $run = summit_copy.pl --uri $URI --filename $FILENAME -- exp_name $EXP_NAME --inst $CAMERA --telescope $TELESCOPE --class $CLASS --class_id $CLASS_ID --bytes $BYTES --md5 $MD5SUM --dbname $DBNAME --timeout 600 --verbose --copies 2482 $run = summit_copy.pl --uri $URI --filename $FILENAME --summit_id $SUMMIT_ID --exp_name $EXP_NAME --inst $CAMERA --telescope $TELESCOPE --class $CLASS --class_id $CLASS_ID --bytes $BYTES --md5 $MD5SUM --dbname $DBNAME --timeout 600 --verbose --copies 2 482 483 if ($USECOMPRESS == 1) 483 484 $run = $run --compress … … 625 626 book setword pzPendingAdvance $pageName pantaskState RUN 626 627 628 book getword pzPendingAdvance $pageName summit_id -var SUMMIT_ID 627 629 book getword pzPendingAdvance $pageName exp_name -var EXP_NAME 628 630 book getword pzPendingAdvance $pageName camera -var CAMERA -
trunk/ippTools/share/pxadmin_create_tables.sql
r30945 r31038 14 14 15 15 CREATE TABLE summitExp ( 16 summit_id BIGINT NOT NULL AUTO_INCREMENT, 16 17 exp_name VARCHAR(64), 17 18 camera VARCHAR(64), … … 23 24 fault SMALLINT NOT NULL, 24 25 epoch TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 25 PRIMARY KEY(exp_name, camera, telescope), 26 PRIMARY KEY(summit_id), 27 KEY(exp_name, camera, telescope), 26 28 KEY(fault) 27 29 ) ENGINE=innodb DEFAULT CHARSET=latin1; 28 30 29 31 CREATE TABLE summitImfile ( 32 summit_id BIGINT, 30 33 exp_name VARCHAR(64), 31 34 camera VARCHAR(64), … … 38 41 uri VARCHAR(255), 39 42 epoch TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 40 PRIMARY KEY(exp_name, camera, telescope, class, class_id), 43 PRIMARY KEY(summit_id, class, class_id), 44 KEY(exp_name, camera, telescope, class, class_id), 41 45 KEY(file_id), 46 FOREIGN KEY(summit_id) REFERENCES summitExp(summit_id), 42 47 FOREIGN KEY(exp_name, camera, telescope) REFERENCES summitExp(exp_name, camera, telescope) 43 48 ) ENGINE=innodb DEFAULT CHARSET=latin1; 44 49 45 50 CREATE TABLE pzDownloadExp ( 51 summit_id BIGINT, 46 52 exp_name VARCHAR(64), 47 53 camera VARCHAR(64), … … 49 55 state VARCHAR(64), 50 56 epoch TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 51 PRIMARY KEY(exp_name, camera, telescope), 57 PRIMARY KEY(summit_id), 58 KEY(exp_name, camera, telescope), 52 59 KEY(state), 60 FOREIGN KEY(summit_id) REFERENCES summitExp(summit_id), 53 61 FOREIGN KEY(exp_name, camera, telescope) REFERENCES summitExp(exp_name, camera, telescope) 54 62 ) ENGINE=innodb DEFAULT CHARSET=latin1; 55 63 56 64 CREATE TABLE pzDownloadImfile ( 65 summit_id BIGINT, 57 66 exp_name VARCHAR(64), 58 67 camera VARCHAR(64), … … 66 75 bytes INT, 67 76 md5sum VARCHAR(32), 68 PRIMARY KEY(exp_name, camera, telescope, class, class_id), 69 KEY(fault), 77 PRIMARY KEY(summit_id, class, class_id), 78 KEY(exp_name, camera, telescope, class, class_id), 79 KEY(fault), 80 FOREIGN KEY(summit_id) REFERENCES pzDownloadExp(summit_id), 81 FOREIGN KEY(summit_id, class, class_id) REFERENCES summitImfile(summit_id, class, class_id), 70 82 FOREIGN KEY (exp_name, camera, telescope) REFERENCES pzDownloadExp(exp_name, camera, telescope), 71 83 FOREIGN KEY(exp_name, camera, telescope, class, class_id) REFERENCES summitImfile(exp_name, camera, telescope, class, class_id) … … 74 86 CREATE TABLE newExp ( 75 87 exp_id BIGINT AUTO_INCREMENT, 88 summit_id BIGINT, 76 89 tmp_exp_name VARCHAR(64), 77 90 tmp_camera VARCHAR(64), … … 88 101 PRIMARY KEY(exp_id), 89 102 KEY(exp_id), 103 KEY(summit_id), 90 104 KEY(tmp_exp_name), 91 105 KEY(tmp_camera), -
trunk/ippTools/share/pztool_find_completed_exp.sql
r23643 r31038 1 1 SELECT DISTINCT 2 summit_id, 2 3 exp_name, 3 4 camera, … … 13 14 FROM pzDownloadExp 14 15 JOIN summitExp 15 USING( exp_name, camera, telescope)16 USING(summit_id) 16 17 LEFT JOIN pzDownloadImfile 17 USING( exp_name, camera, telescope)18 USING(summit_id) 18 19 LEFT JOIN newExp 19 ON pzDownloadExp.exp_name = newExp.tmp_exp_name 20 AND pzDownloadExp.camera = newExp.tmp_camera 21 AND pzDownloadExp.telescope = newExp.tmp_telescope 20 USING(summit_id) 22 21 WHERE 23 22 pzDownloadExp.state = 'run' 23 AND newExp.summit_id IS NULL 24 24 AND newExp.tmp_exp_name IS NULL 25 25 AND newExp.tmp_camera IS NULL 26 26 AND newExp.tmp_telescope IS NULL 27 27 GROUP BY 28 pzDownloadExp.exp_name, 29 pzDownloadExp.camera, 30 pzDownloadExp.telescope 28 pzDownloadExp.summit_id, 31 29 -- it doesn't matter which field in pzDownloadImfile we count as we've 32 30 -- already Download a group by -
trunk/ippTools/share/pztool_pendingimfile.sql
r18305 r31038 6 6 FROM summitImfile 7 7 JOIN pzDownloadExp 8 USING(exp_name, camera, telescope)8 USING(summit_id) 9 9 LEFT JOIN pzDownloadImfile 10 USING( exp_name, camera, telescope, class, class_id)10 USING(summit_id, class, class_id) 11 11 JOIN summitExp 12 USING(exp_name, camera, telescope)12 USING(summit_id) 13 13 WHERE 14 14 pzDownloadExp.state = 'run' 15 AND pzDownloadImfile.summit_id IS NULL 15 16 AND pzDownloadImfile.exp_name IS NULL 16 17 AND pzDownloadImfile.camera IS NULL -
trunk/ippTools/share/regtool_checkburntoolimfile.sql
r30283 r31038 21 21 FROM 22 22 summitExp 23 JOIN summitImfile USING( exp_name)24 LEFT JOIN pzDownloadExp USING( exp_name)25 LEFT JOIN newExp ON summitExp.exp_name = tmp_exp_name23 JOIN summitImfile USING(summit_id) 24 LEFT JOIN pzDownloadExp USING(summit_id) 25 LEFT JOIN newExp USING(summit_id) 26 26 LEFT JOIN newImfile ON (summitImfile.class_id = newImfile.tmp_class_id AND newExp.exp_id = newImfile.exp_id) 27 27 LEFT JOIN rawExp ON rawExp.exp_id = newExp.exp_id -
trunk/ippTools/share/regtool_checkstatus.sql
r30997 r31038 20 20 (rawImfile.burntool_state IS NOT NULL) AS is_registered 21 21 FROM summitExp 22 JOIN summitImfile USING( exp_name)23 LEFT JOIN pzDownloadExp USING( exp_name)24 LEFT JOIN newExp ON summitExp.exp_name = tmp_exp_name22 JOIN summitImfile USING(summit_id) 23 LEFT JOIN pzDownloadExp USING(summit_id) 24 LEFT JOIN newExp USING(summit_id) 25 25 LEFT JOIN newImfile ON (summitImfile.class_id = newImfile.tmp_class_id AND newExp.exp_id = newImfile.exp_id) 26 26 LEFT JOIN rawExp ON rawExp.exp_id = newExp.exp_id -
trunk/ippTools/share/regtool_pendingburntoolimfile.sql
r30283 r31038 22 22 FROM 23 23 summitExp 24 JOIN summitImfile USING( exp_name)25 LEFT JOIN pzDownloadExp USING( exp_name)26 LEFT JOIN newExp ON summitExp.exp_name = tmp_exp_name24 JOIN summitImfile USING(summit_id) 25 LEFT JOIN pzDownloadExp USING(summit_id) 26 LEFT JOIN newExp USING(summit_id) 27 27 LEFT JOIN newImfile ON (summitImfile.class_id = newImfile.tmp_class_id AND newExp.exp_id = newImfile.exp_id) 28 28 LEFT JOIN rawExp ON rawExp.exp_id = newExp.exp_id -
trunk/ippTools/src/pxinject.c
r25418 r31038 92 92 if (!newExpInsert(config->dbh, 93 93 0, // exp_id 94 0, // summit_id 94 95 tmp_exp_name, 95 96 tmp_camera, -
trunk/ippTools/src/pzgetexp.c
r21402 r31038 215 215 char *query = 216 216 "INSERT INTO summitExp" 217 " SElECT" 217 " SELECT" 218 " NULL," // summit_id 218 219 " incoming.*," 219 220 " NULL," // imfiles -
trunk/ippTools/src/pzgetimfiles.c
r21402 r31038 99 99 int status = pclose(output); 100 100 101 // We have an id value now, let's get it and use it 102 char *id_query = "SELECT summit_id FROM summitExp WHERE exp_name = '%s' AND camera = '%s' AND telescope = '%s'"; 103 104 if (!p_psDBRunQueryF(config->dbh, id_query, filesetid, camera, telescope)) { 105 psError(PS_ERR_UNKNOWN, false, "database error"); 106 return false; 107 } 108 109 psArray *id_output = p_psDBFetchResult(config->dbh); 110 if (!id_output) { 111 psError(PS_ERR_UNKNOWN, false, "database error"); 112 return false; 113 } 114 if (psArrayLength(id_output) != 1) { 115 psError(PS_ERR_UNKNOWN, false, "database error: incorrect number of results"); 116 return false; 117 } 118 119 psMetadata *id_result = id_output->data[0]; 120 121 psS64 summit_id = psMetadataLookupS64(NULL, id_result, "summit_id"); 122 psFree(id_output); 123 // End of summit_id block. 124 101 125 if (status != 0) { 102 126 // mark the summitExp row as faulted 103 if (!p_psDBRunQueryF(config->dbh, "UPDATE summitExp SET fault = %d WHERE exp_name = '%s' AND camera = '%s' AND telescope = '%s'", WEXITSTATUS(status), filesetid, camera, telescope)) {127 if (!p_psDBRunQueryF(config->dbh, "UPDATE summitExp SET fault = %d WHERE summit_id = %ld", WEXITSTATUS(status), summit_id)) { 104 128 psError(PS_ERR_UNKNOWN, false, "database error"); 105 129 } … … 117 141 // download an "empty" fileset. 118 142 // mark the summitExp row as faulted 119 if (!p_psDBRunQueryF(config->dbh, "UPDATE summitExp SET fault = %d WHERE exp_name = '%s' AND camera = '%s' AND telescope = '%s'", 250, filesetid, camera, telescope)) {143 if (!p_psDBRunQueryF(config->dbh, "UPDATE summitExp SET fault = %d WHERE summit_id = %ld", 250, summit_id)) { 120 144 psError(PS_ERR_UNKNOWN, false, "database error"); 121 145 } … … 142 166 "UPDATE summitExp" 143 167 " SET imfiles = %d" 144 " WHERE exp_name = '%s'" 145 " AND camera = '%s'" 146 " AND telescope = '%s'"; 147 if (!p_psDBRunQueryF(config->dbh, query, imfiles, filesetid, camera, telescope)) { 168 " WHERE summit_id = %ld"; 169 if (!p_psDBRunQueryF(config->dbh, query, imfiles, summit_id)) { 148 170 // rollback 149 171 if (!psDBRollback(config->dbh)) { … … 159 181 "DELETE FROM pzDownloadExp" 160 182 " WHERE" 161 " exp_name = '%s'" 162 " AND camera = '%s'" 163 " AND telescope = '%s'"; 164 if (!p_psDBRunQueryF(config->dbh, query, filesetid, camera, telescope)) { 183 " summit_id = %ld"; 184 if (!p_psDBRunQueryF(config->dbh, query, summit_id)) { 165 185 // rollback 166 186 if (!psDBRollback(config->dbh)) { … … 245 265 "INSERT IGNORE INTO summitImfile" 246 266 " SELECT" 267 " %ld," // summit_id 247 268 " incoming.exp_name," 248 269 " incoming.camera," … … 256 277 " NULL" // epoch 257 278 " FROM incoming"; 258 if (!p_psDBRunQuery (config->dbh, query)) {279 if (!p_psDBRunQueryF(config->dbh, query,summit_id)) { 259 280 // rollback 260 281 if (!psDBRollback(config->dbh)) { … … 272 293 " SET imfiles = (SELECT COUNT(*) FROM summitImfile" 273 294 " WHERE" 274 " exp_name = '%s'" 275 " AND camera = '%s'" 276 " AND telescope = '%s'" 295 " summit_id = %ld" 277 296 ")" 278 297 " WHERE" 279 " exp_name = '%s'" 280 " AND camera = '%s'" 281 " AND telescope = '%s'" 298 " summit_id = %ld" 282 299 " AND imfiles IS NULL"; 283 if (!p_psDBRunQueryF(config->dbh, query, filesetid, camera, telescope, filesetid, camera, telescope)) {300 if (!p_psDBRunQueryF(config->dbh, query, summit_id, summit_id)) { 284 301 // rollback 285 302 if (!psDBRollback(config->dbh)) { … … 308 325 "INSERT IGNORE INTO pzDownloadExp" 309 326 " SELECT" 327 " %ld," // summit_id 310 328 " incoming.exp_name," 311 329 " incoming.camera," … … 319 337 " incoming.telescope"; 320 338 321 if (!p_psDBRunQuery (config->dbh, query)) {339 if (!p_psDBRunQueryF(config->dbh, query,summit_id)) { 322 340 // rollback 323 341 if (!psDBRollback(config->dbh)) { -
trunk/ippTools/src/pztool.c
r30907 r31038 53 53 static psArray *pzGetPendingCameras(pxConfig *config); 54 54 static psArray *pzArrayZip(psArray *arraySet, psS64 limit); 55 static bool pzDownloadExpSetState(pxConfig *config, const char *exp_name, const char *camera, const char *telescope, const char *state);55 static bool pzDownloadExpSetState(pxConfig *config, const psS64 summit_id, const char *state); 56 56 57 57 # define MODECASE(caseName, func) \ … … 222 222 223 223 psMetadata *where = psMetadataAlloc(); 224 PXOPT_COPY_S64(config->args, where, "-summit_id", "summit_id", "=="); 224 225 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 225 226 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); … … 237 238 " FROM summitExp" 238 239 " LEFT JOIN pzDownloadExp" 239 " USING(exp_name, camera, telescope)"240 " USING(summit_id)" 240 241 " WHERE" 241 " pzDownloadExp.exp_name IS NULL" 242 " AND pzDownloadExp.camera IS NULL" 243 " AND pzDownloadExp.telescope IS NULL" 242 " pzDownloadExp.summit_id IS NULL" 244 243 " AND summitExp.fault = 0" 245 244 ); … … 260 259 if (limit) { 261 260 psString limitString = psDBGenerateLimitSQL(limit); 261 262 262 psStringAppend(&query, " %s", limitString); 263 263 psFree(limitString); … … 299 299 300 300 psMetadata *where = psMetadataAlloc(); 301 PXOPT_COPY_S64(config->args, where, "-summit_id", "summit_id", "=="); 301 302 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 302 303 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); … … 401 402 402 403 // required 404 PXOPT_LOOKUP_S64(summit_id, config->args, "-summit_id", true, false); 403 405 PXOPT_LOOKUP_STR(exp_name, config->args, "-exp_name", true, false); 404 406 PXOPT_LOOKUP_STR(camera, config->args, "-inst", true, false); … … 428 430 429 431 psMetadata *where = psMetadataAlloc(); 432 PXOPT_COPY_S64(config->args, where, "-summit_id", "summit_id", "=="); 430 433 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 431 434 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); … … 459 462 460 463 if (!pzDownloadImfileInsert(config->dbh, 464 summit_id, 461 465 exp_name, 462 466 camera, … … 505 509 506 510 psMetadata *where = psMetadataAlloc(); 511 PXOPT_COPY_STR(config->args, where, "-summit_id", "summit_id", "=="); 507 512 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 508 513 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); … … 560 565 561 566 // required 567 PXOPT_LOOKUP_S64(summit_id, config->args, "-summit_id", true, false); 562 568 PXOPT_LOOKUP_STR(exp_name, config->args, "-exp_name", true, false); 563 569 PXOPT_LOOKUP_STR(inst, config->args, "-inst", true, false); … … 579 585 if (!newExpInsert(config->dbh, 580 586 0x0, // exp_id 587 summit_id, // summit_id 581 588 exp_name, // tmp_exp_name 582 589 inst, // tmp_camera … … 597 604 } 598 605 599 psS64 exp_id = psDBLastInsertID(config->dbh);600 601 // insert newImfiles602 {603 char *query =606 psS64 exp_id = psDBLastInsertID(config->dbh); 607 608 // insert newImfiles 609 { 610 char *query = 604 611 "INSERT INTO newImfile" 605 " SE lECT"612 " SELECT" 606 613 " %" PRId64 "," // exp_id 614 " %" PRId64 "," // summit_id 607 615 " pzDownloadImfile.class_id," // tmp_class_id 608 616 " pzDownloadImfile.uri," // uri … … 616 624 " AND pzDownloadImfile.telescope = '%s'"; 617 625 618 if (!p_psDBRunQueryF(config->dbh, query, exp_id, exp_name, inst, telescope)) {619 psError(PS_ERR_UNKNOWN, false, "database error");620 return false;621 }622 623 // sanity check: we should have inserted at least one row624 psU64 affected = psDBAffectedRows(config->dbh);625 if (psDBAffectedRows(config->dbh) < 1) {626 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row but %" PRIu64 " rows were modified", affected);627 return false;628 }626 if (!p_psDBRunQueryF(config->dbh, query, exp_id, summit_id, exp_name, inst, telescope)) { 627 psError(PS_ERR_UNKNOWN, false, "database error"); 628 return false; 629 } 630 631 // sanity check: we should have inserted at least one row 632 psU64 affected = psDBAffectedRows(config->dbh); 633 if (psDBAffectedRows(config->dbh) < 1) { 634 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row but %" PRIu64 " rows were modified", affected); 635 return false; 636 } 629 637 } 630 638 631 639 // set pzDownloadExp.state to 'stop' 632 if (!pzDownloadExpSetState(config, exp_name, inst, telescope, "stop")) {633 psError(PS_ERR_UNKNOWN, false, "failed to change pzDownloadExp.state for % s:%s:%s", exp_name, inst, telescope);640 if (!pzDownloadExpSetState(config, summit_id, "stop")) { 641 psError(PS_ERR_UNKNOWN, false, "failed to change pzDownloadExp.state for %ld", summit_id); 634 642 return false; 635 643 } … … 887 895 888 896 889 static bool pzDownloadExpSetState(pxConfig *config, const char *exp_name, const char *camera, const char *telescope, const char *state)897 static bool pzDownloadExpSetState(pxConfig *config, const psS64 summit_id, const char *state) 890 898 { 891 899 PS_ASSERT_PTR_NON_NULL(state, false); … … 904 912 } 905 913 906 char *query = "UPDATE pzDownloadExp SET state = '%s' WHERE exp_name = '%s' and camera = '%s' and telescope = '%s'";907 if (!p_psDBRunQueryF(config->dbh, query, state, exp_name, camera, telescope)) {908 psError(PS_ERR_UNKNOWN, false, "failed to change state for % s:%s:%s", exp_name, camera, telescope);914 char *query = "UPDATE pzDownloadExp SET state = '%s' WHERE summit_id = %ld"; 915 if (!p_psDBRunQueryF(config->dbh, query, state, summit_id)) { 916 psError(PS_ERR_UNKNOWN, false, "failed to change state for %ld", summit_id); 909 917 return false; 910 918 } … … 916 924 { 917 925 PS_ASSERT_PTR_NON_NULL(config, false); 918 PXOPT_LOOKUP_STR(exp_name, config->args, "-exp_name", true, false); 919 PXOPT_LOOKUP_STR(camera, config->args, "-inst", true, false); 920 PXOPT_LOOKUP_STR(telescope,config->args, "-telescope",true, false); 926 PXOPT_LOOKUP_S64(summit_id, config->args, "-summit_id", true, false); 921 927 PXOPT_LOOKUP_STR(state, config->args, "-set_state",true, false); 922 928 923 if (!pzDownloadExpSetState(config, exp_name,camera,telescope,state)) {924 psError(PS_ERR_UNKNOWN, false, "failed to change state for % s:%s:%s", exp_name, camera, telescope);929 if (!pzDownloadExpSetState(config,summit_id, state)) { 930 psError(PS_ERR_UNKNOWN, false, "failed to change state for %ld", summit_id); 925 931 return false; 926 932 } -
trunk/ippTools/src/pztoolConfig.c
r30437 r31038 63 63 // -pendingexp 64 64 psMetadata *pendingexpArgs = psMetadataAlloc(); 65 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-summit_id", 0, "define summit_id", 0); 65 66 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure ID", NULL); 66 67 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-inst", 0, "define camera ID", NULL); … … 73 74 // -pendingimfile 74 75 psMetadata *pendingimfileArgs = psMetadataAlloc(); 76 psMetadataAddS64(pendingimfileArgs, PS_LIST_TAIL, "-summit_id", 0, "define summit_id", 0); 75 77 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure ID", NULL); 76 78 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-inst", 0, "define camera ID", NULL); … … 85 87 // -copydone 86 88 psMetadata *copydoneArgs = psMetadataAlloc(); 89 psMetadataAddS64(copydoneArgs, PS_LIST_TAIL, "-summit_id", 0, "define summit_id (required)", 0); 87 90 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure ID (required)", NULL); 88 91 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-inst", 0, "define camera ID (required)", NULL); -
trunk/ippTools/src/regtool.c
r30927 r31038 311 311 312 312 // required 313 PXOPT_LOOKUP_STR(dateobs_begin, config->args, "-dateobs_begin",true, false);314 PXOPT_LOOKUP_STR(dateobs_end, config->args, "-dateobs_end", true, false);315 PXOPT_LOOKUP_S32(valid_burntool, config->args, "-valid_burntool", true, false);313 PXOPT_LOOKUP_STR(dateobs_begin, config->args, "-dateobs_begin", true, false); 314 PXOPT_LOOKUP_STR(dateobs_end, config->args, "-dateobs_end", true, false); 315 PXOPT_LOOKUP_S32(valid_burntool, config->args, "-valid_burntool", true, false); 316 316 // optional 317 317 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
Note:
See TracChangeset
for help on using the changeset viewer.
