Ignore:
Timestamp:
07/02/10 12:54:37 (14 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/scripts/sourcefile

    r9604 r9605  
    254254
    255255# function to get the join of a step
    256 #  (normal join but using different primaries)
    257256#  from the dependencies-file steps.rc
     257# $1 gives the step
     258# $2 gives the type of join
    258259function getjoin()
    259260{
    260261   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://"
    271263}
    272264
     
    276268   getdbsetup
    277269   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
     274function 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
    278283}
    279284
     
    289294      needprims=( `getprimary $need` )
    290295      # 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
    306304      fi
    307305   done
     
    310308   # add condition for the status of the peceding steps
    311309   counter=0
     310   specialneedjoin=
    312311   for need in $needs
    313312   do
     
    316315         query=$query" AND "
    317316      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" = " " ]
    326319      then
     320         # condition for step with same primaries
    327321         query=$query" NOT ISNULL("$need"Status.fStartTime) AND "
    328322         query=$query" NOT ISNULL("$need"Status.fStopTime) AND "
    329323         query=$query" ISNULL("$need"Status.fReturnCode) "
     324         specialneedjoin=
    330325      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
    345336         query=$query" AND NOT ISNULL(fStartTime) "
    346337         query=$query" AND NOT ISNULL(fStopTime) "
     
    500491   query=" UPDATE "$step"Status "
    501492   # add joins to the influenced tables
    502    stepspecialjoin=""
     493   specialinfljoin=`getjoin $step "SpecialInfluence"`
     494   if ! [ "$specialinfljoin" = "" ]
     495   then
     496      query=$query" "$specialinfljoin
     497   fi
    503498   for influence in $influences
    504499   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[@]}) "
    513505      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
    536507      fi
    537508   done
Note: See TracChangeset for help on using the changeset viewer.