Changeset 9605 for trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
- Timestamp:
- 07/02/10 12:54:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
r9604 r9605 254 254 255 255 # function to get the join of a step 256 # (normal join but using different primaries)257 256 # from the dependencies-file steps.rc 257 # $1 gives the step 258 # $2 gives the type of join 258 259 function getjoin() 259 260 { 260 261 getdbsetup 261 grep $@"[.]Join:" $steps | grep -v '#' | sed -e "s/$@[.]Join://" 262 } 263 264 # function to get the special join of a step 265 # (i.e. join with a different table) 266 # from the dependencies-file steps.rc 267 function getspecialjoin() 268 { 269 getdbsetup 270 grep $@"[.]SpecialJoin:" $steps | grep -v '#' | sed -e "s/$@[.]SpecialJoin://" 262 grep $1"[.]"$2"Join:" $steps | grep -v '#' | sed -e "s/$1[.]$2Join://" 271 263 } 272 264 … … 276 268 getdbsetup 277 269 grep $@"[.]Needs:" $steps | sed -e "s/$@[.]Needs://" 270 } 271 272 # subquery which is needed to check the 273 # status of the steps with different primaries 274 function subquerypart() 275 { 276 query=$query" SELECT COUNT(*) FROM "$need"Status " 277 query=$query" "`getjoin $need "SpecialInfluence"`" " 278 query=$query" WHERE "$step"Status."`echo ${prims[0]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[0]} | sed -e 's/,//g'` 279 for (( j=1 ; j < ${#prims[@]} ; j++ )) 280 do 281 query=$query" AND "$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'` 282 done 278 283 } 279 284 … … 289 294 needprims=( `getprimary $need` ) 290 295 # make sure that the correct joins are used 291 # in case the primaries of the step and the need are 292 # the same, the tables are join with these primaries 293 # otherwise it is checked whether there has to be a 294 # join with different primaries (indicated as 'Join' 295 # in the steps.rc 296 # 'SpecialJoins' do not have to be taken into account here 297 if [ "`echo ${needprims[@]}`" == "`echo ${prims[@]}`" ] 298 then 299 query=$query" LEFT JOIN "$need"Status USING (${prims[@]}) " 300 else 301 stdjoin=`getjoin $need` 302 if ! [ "$stdjoin" = "" ] 303 then 304 query=$query" "$stdjoin" " 305 fi 296 specialneedjoin=`getjoin $need "SpecialNeed"` 297 if [ "$specialneedjoin" = "" ] 298 then 299 query=$query" LEFT JOIN "$need"Status USING (${needprims[@]}) " 300 else 301 query=$query" "$specialneedjoin" " 302 query=$query" LEFT JOIN "$need"Status USING (${needprims[@]}) " 303 break 306 304 fi 307 305 done … … 310 308 # add condition for the status of the peceding steps 311 309 counter=0 310 specialneedjoin= 312 311 for need in $needs 313 312 do … … 316 315 query=$query" AND " 317 316 fi 318 needprims=( `getprimary $need` ) 319 # in case the primaries of the tables agree 320 # or there is just a normal 'Join' needed 321 # only the condition is added to the query 322 # for tables which need a join with a different 323 # table, a special query is added using the 324 # 'SpecialJoin' from the steps.rc 325 if [ "`echo ${needprims[@]}`" == "`echo ${prims[@]}`" ] || ! [ "$stdjoin" = "" ] 317 specialneedjoin=$specialneedjoin" "`getjoin $need "SpecialNeed"` 318 if [ "$specialneedjoin" = " " ] 326 319 then 320 # condition for step with same primaries 327 321 query=$query" NOT ISNULL("$need"Status.fStartTime) AND " 328 322 query=$query" NOT ISNULL("$need"Status.fStopTime) AND " 329 323 query=$query" ISNULL("$need"Status.fReturnCode) " 324 specialneedjoin= 330 325 else 331 query=$query" (SELECT COUNT(*) FROM "$need"Status " 332 query=$query" "`getspecialjoin $need`" " 333 query=$query" WHERE "$step"Status."`echo ${prims[0]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[0]} | sed -e 's/,//g'` 334 for (( j=1 ; j < ${#prims[@]} ; j++ )) 335 do 336 query=$query" AND "$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'` 337 done 338 query=$query") = (SELECT COUNT(*) FROM "$need"Status " 339 query=$query" "`getspecialjoin $need`" " 340 query=$query" WHERE "$step"Status."`echo ${prims[0]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[0]} | sed -e 's/,//g'` 341 for (( j=1 ; j < ${#prims[@]} ; j++ )) 342 do 343 query=$query" AND "$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'` 344 done 326 # special query to check steps which 327 # do not have the same primaries 328 # comparison of 329 # number of rows 330 # with 331 # number of rows which are done 332 query=$query" ( " 333 subquerypart 334 query=$query" ) = ( " 335 subquerypart 345 336 query=$query" AND NOT ISNULL(fStartTime) " 346 337 query=$query" AND NOT ISNULL(fStopTime) " … … 500 491 query=" UPDATE "$step"Status " 501 492 # add joins to the influenced tables 502 stepspecialjoin="" 493 specialinfljoin=`getjoin $step "SpecialInfluence"` 494 if ! [ "$specialinfljoin" = "" ] 495 then 496 query=$query" "$specialinfljoin 497 fi 503 498 for influence in $influences 504 499 do 505 inflprims=( `getprimary $influence` ) 506 # make sure that the correct joins are used 507 # in case the primaries of the step and the influence are 508 # the same, the tables are join with these primaries 509 # otherwise they are joined with the primaries of the influence 510 if [ "`echo ${inflprims[@]}`" == "`echo ${prims[@]}`" ] 511 then 512 query=$query" LEFT JOIN "$influence"Status USING (${prims[@]}) " 500 infljoin=`getjoin $influence "Influence"` 501 if [ "$infljoin" = "" ] 502 then 503 inflprims=( `getprimary $influence` ) 504 query=$query" LEFT JOIN "$influence"Status USING (${inflprims[@]}) " 513 505 else 514 prims2=`getprimary $step | sed -e "s/\ //g"` 515 primstest=`echo ${inflprims[@]} | sed -e "s/\ //g" | sed -e "s/$prims2//g"` 516 if [ "$primstest" == "`echo ${inflprims[@]} | sed -e "s/\ //g"`" ] 517 then 518 if [ "$stepspecialjoin" == "" ] 519 then 520 stepspecialjoin=`getspecialjoin $step` 521 query=$query" "$stepspecialjoin" " 522 fi 523 query=$query" LEFT JOIN "$influence"Status USING (${inflprims[@]}) " 524 else 525 infljoin=`getjoin $influence` 526 if [ "$infljoin" = "" ] 527 then 528 query=$query" LEFT JOIN "$influence"Status USING (${prims[@]}) " 529 else 530 query=$query" "$infljoin 531 # warning: this is a workaround 532 # it has to be checked whether it works for all steps 533 stepspecialjoin="not empty" 534 fi 535 fi 506 query=$query" "$infljoin 536 507 fi 537 508 done
Note:
See TracChangeset
for help on using the changeset viewer.