Changeset 8527
- Timestamp:
- Aug 23, 2006, 1:39:46 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r8504 r8527 3689 3689 PS_ASSERT_PTR_NON_NULL(config, false); 3690 3690 3691 // det_id is required 3692 // XXX this isn't strictly nessicary but not having the det_id complicates 3693 // incrementing the iteration number 3694 bool status = false; 3695 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 3696 if (!status) { 3697 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 3698 return false; 3699 } 3700 if (!det_id) { 3701 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 3702 return false; 3703 } 3691 3704 // either -rerun or -stop must be specified 3692 bool status = false;3693 3705 bool again = psMetadataLookupBool(&status, config->args, "-again"); 3694 3706 if (!status) { … … 3707 3719 if (again && stop) { 3708 3720 psError(PS_ERR_UNKNOWN, true, "either -again or -stop must be specified"); 3721 return false; 3722 } 3723 3724 // XXX stop deson't actually do anything at this point 3725 if (stop) { 3726 return true; 3727 } 3728 3729 // else 3730 // -again 3731 3732 // select detRun.position 3733 // select detRun.iteration 3734 // select detInputExp.exp_id 3735 // select detResidExp.accept 3736 // by: 3737 // find the current iteration bassed on det_id 3738 // find all exp_ids in the current det_id/iteration from detInputExp 3739 // find all exp_ids in the current det_id/iteration from detResidExp 3740 // compare the counts of exp_ids 3741 3742 psString query = psStringCopy( 3743 "SELECT DISTINCT" 3744 " detRun.position AS det_id," 3745 " detRun.iteration," 3746 " detInputExp.exp_id," 3747 " detResidExp.accept" 3748 " FROM detRun" 3749 " LEFT JOIN detInputExp" 3750 " ON detRun.position = detInputExp.det_id" 3751 " AND detRun.iteration = detInputExp.iteration" 3752 " LEFT JOIN detResidExp" 3753 " ON detRun.position = detResidExp.det_id" 3754 " AND detRun.iteration = detResidExp.iteration" 3755 " AND detInputExp.exp_id = detResidExp.exp_id" 3756 " WHERE" 3757 " detInputExp.exp_id IS NOT NULL" 3758 " AND detResidExp.accept IS NOT NULL" 3759 " GROUP BY" 3760 " detRun.position," 3761 " detRun.iteration," 3762 " detInputExp.exp_id" 3763 " HAVING" 3764 " COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)" 3765 ); 3766 3767 if (!p_psDBRunQuery(config->dbh, query)) { 3768 psError(PS_ERR_UNKNOWN, false, "database error"); 3769 psFree(query); 3770 return false; 3771 } 3772 psFree(query); 3773 3774 psArray *output = p_psDBFetchResult(config->dbh); 3775 if (!output) { 3776 // XXX check psError here 3777 psError(PS_ERR_UNKNOWN, false, "no completed detrun iterations found"); 3778 return false; 3779 } 3780 3781 // start a transaction so we don't end up with an incremented iteration 3782 // count but no detInputExps 3783 if (!psDBTransaction(config->dbh)) { 3784 psError(PS_ERR_UNKNOWN, false, "database error"); 3785 psFree(output); 3786 return false; 3787 } 3788 3789 // up the detRuns iteration count for for the single det_id we are 3790 // operating on 3791 // XXX this will have to changed in order to support multiple det_ids with 3792 // a single invocation of this functions 3793 psS32 newIteration = incrementIteration(config, det_id); 3794 if (!newIteration) { 3795 // rollback 3796 if (!psDBRollback(config->dbh)) { 3797 psError(PS_ERR_UNKNOWN, false, "database error"); 3798 } 3799 psFree(output); 3800 return false; 3801 } 3802 3803 for (long i = 0; i < psArrayLength(output); i++) { 3804 psMetadata *row = output->data[i]; 3805 psString exp_id = psMetadataLookupStr(&status, row, "exp_id"); 3806 if (!status) { 3807 // rollback 3808 if (!psDBRollback(config->dbh)) { 3809 psError(PS_ERR_UNKNOWN, false, "database error"); 3810 } 3811 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_id"); 3812 psFree(output); 3813 return false; 3814 } 3815 bool accept = psMetadataLookupBool(&status, row, "accept"); 3816 if (!status) { 3817 // rollback 3818 if (!psDBRollback(config->dbh)) { 3819 psError(PS_ERR_UNKNOWN, false, "database error"); 3820 } 3821 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for accept"); 3822 psFree(output); 3823 return false; 3824 } 3825 3826 // detResidExp.include is used to set detInputExp.include 3827 if (!detInputExpInsert( 3828 config->dbh, 3829 (psS32)atol(det_id), 3830 newIteration, 3831 exp_id, 3832 accept 3833 ) 3834 ) { 3835 // rollback 3836 if (!psDBRollback(config->dbh)) { 3837 psError(PS_ERR_UNKNOWN, false, "database error"); 3838 } 3839 psError(PS_ERR_UNKNOWN, false, "database error"); 3840 psFree(output); 3841 return false; 3842 } 3843 } 3844 3845 psFree(output); 3846 3847 // point of no return for det_id creation 3848 if (!psDBCommit(config->dbh)) { 3849 psError(PS_ERR_UNKNOWN, false, "database error"); 3709 3850 return false; 3710 3851 }
Note:
See TracChangeset
for help on using the changeset viewer.
