Changeset 10024 for trunk/ippTools/src/pzgetimfiles.c
- Timestamp:
- Nov 16, 2006, 2:57:02 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pzgetimfiles.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pzgetimfiles.c
r10021 r10024 139 139 long imfiles = psArrayLength(newImfiles); 140 140 141 // start a transaction so it's all rows or nothing 142 if (!psDBTransaction(config->dbh)) { 143 psError(PS_ERR_UNKNOWN, false, "database error"); 144 return false; 145 } 146 141 147 // if the fileset was empty (no files) then we can bail out early 142 148 if (imfiles == 0) { 149 psFree(newImfiles); 150 143 151 char *query = 144 152 "UPDATE summitExp" … … 148 156 " AND telescope = '%s'"; 149 157 if (!p_psDBRunQuery(config->dbh, query, imfiles, filesetid, camera, telescope)) { 150 psError(PS_ERR_UNKNOWN, false, "database error"); 151 return false; 152 } 153 psFree(newImfiles); 158 // rollback 159 if (!psDBRollback(config->dbh)) { 160 psError(PS_ERR_UNKNOWN, false, "database error"); 161 } 162 psError(PS_ERR_UNKNOWN, false, "database error"); 163 return false; 164 } 165 166 // remove the pzPendingExp entry for this exp (fileset) 167 { 168 char *query = 169 "DELETE FROM pzPendingExp" 170 " WHERE" 171 " exp_id = '%s'" 172 " AND camera = '%s'" 173 " AND telescope = '%s'"; 174 if (!p_psDBRunQuery(config->dbh, query, filesetid, camera, telescope)) { 175 // rollback 176 if (!psDBRollback(config->dbh)) { 177 psError(PS_ERR_UNKNOWN, false, "database error"); 178 } 179 psError(PS_ERR_UNKNOWN, false, "database error"); 180 return false; 181 } 182 } 183 184 // point of no return 185 if (!psDBCommit(config->dbh)) { 186 psError(PS_ERR_UNKNOWN, false, "database error"); 187 return false; 188 } 189 154 190 return true; 155 191 } 156 157 // start a transaction so it's all rows or nothing158 if (!psDBTransaction(config->dbh)) {159 psError(PS_ERR_UNKNOWN, false, "database error");160 return false;161 }162 192 163 193 // try not to insert duplicate pzPendingExp/pzPendingImfile entries … … 179 209 } 180 210 211 // load the imfiles (files) into the temp table 181 212 { 182 213 char *query = "INSERT INTO incoming (exp_id, camera, telescope, bytes, md5sum, class, class_id, uri) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; … … 206 237 psFree(newImfiles); 207 238 239 // queue the imfiles (files) in pzPendingImfile 208 240 { 209 241 char *query = … … 238 270 } 239 271 240 272 // move imfiles (files) from the temp table into summitImfiles 241 273 { 242 274 char *query = … … 271 303 } 272 304 273 // update summitExp.imfiles 305 // update summitExp.imfiles (should have been NULL) 274 306 { 275 307 char *query = 276 308 "UPDATE summitExp" 277 309 " SET imfiles = (SELECT COUNT(*) FROM summitImfile" 278 " WHERE exp_id = '%s'" 310 " WHERE" 311 " exp_id = '%s'" 312 " AND camera = '%s'" 313 " AND telescope = '%s'" 314 ")" 315 " WHERE" 316 " exp_id = '%s'" 279 317 " AND camera = '%s'" 280 " AND telescope = '%s'" 281 ")" 282 " WHERE exp_id = '%s'" 283 " AND camera = '%s'" 284 " AND telescope = '%s'"; 318 " AND telescope = '%s'"; 285 319 if (!p_psDBRunQuery(config->dbh, query, filesetid, camera, telescope, filesetid, camera, telescope)) { 286 psError(PS_ERR_UNKNOWN, false, "database error"); 287 return false; 288 } 289 } 290 320 // rollback 321 if (!psDBRollback(config->dbh)) { 322 psError(PS_ERR_UNKNOWN, false, "database error"); 323 } 324 psError(PS_ERR_UNKNOWN, false, "database error"); 325 return false; 326 } 327 } 328 329 // remove the pzPendingExp entry for this exp (fileset) 330 { 331 char *query = 332 "DELETE FROM pzPendingExp" 333 " WHERE" 334 " exp_id = '%s'" 335 " AND camera = '%s'" 336 " AND telescope = '%s'"; 337 if (!p_psDBRunQuery(config->dbh, query, filesetid, camera, telescope)) { 338 // rollback 339 if (!psDBRollback(config->dbh)) { 340 psError(PS_ERR_UNKNOWN, false, "database error"); 341 } 342 psError(PS_ERR_UNKNOWN, false, "database error"); 343 return false; 344 } 345 } 346 347 // point of no return 291 348 if (!psDBCommit(config->dbh)) { 292 349 psError(PS_ERR_UNKNOWN, false, "database error");
Note:
See TracChangeset
for help on using the changeset viewer.
