Index: trunk/DataCheck/Sourcefile.sh
===================================================================
--- trunk/DataCheck/Sourcefile.sh	(revision 19197)
+++ trunk/DataCheck/Sourcefile.sh	(revision 19198)
@@ -173,45 +173,26 @@
 }
 
-# get the db-setup from the sql.rc
-function getdbsetup()
-{
-   db=`grep Database $sqlrc | grep -v '#' | sed -e 's/Database: //' -e 's/ //g'`
-   pw="--password="`grep Password $sqlrc | grep -v '#' | sed -e 's/Password: //' -e 's/ //g'`
-   us=`grep User $sqlrc | grep -v '#' | sed -e 's/User: //' -e 's/ //g'`
-   ho=`grep URL $sqlrc | grep -v '#' | sed -e 's/ //g' -e 's/URL:mysql:\/\///'`
-   if [ "$sqlpw" != "" ]
-   then 
-      sqlpwfile="--defaults-file=$sqlpw"
-      pw=""
-   fi
-#   echo "setup: "
-#   echo " db: "$db
-#   echo " pw: "$pw
-#   echo " us: "$us
-#   echo " ho: "$ho
-}
-
 # function to send a mysql query
 function sendquery()
 {
-   getdbsetup
+   #getdbsetup
    printprocesslog "DEBUG sendquery QUERY: "$query
-   val=`mysql $sqlpwfile -s -u $us $pw --host=$ho $db -e " $query " 2>&1`
+   val=`mysql --defaults-file=$sqlrc -s -e " $query " 2>&1`
    checkmysql=`echo $?`
    if [ $checkmysql -gt 0 ]
    then
-      printprocesslog "ERROR could not query DB "$db" on host "$ho" with user "$us" (program: $program, function sendquery) "
+      printprocesslog "ERROR could not query DB (program: $program, function sendquery, mysqlsetup $sqlrc) "
       printprocesslog "MYSQLERROR [returncode: "$checkmysql"] "$val
       error=`echo $val | grep -E -o 'ERROR [1-9]{1,4}' | grep -E -o '[1-9]{1,4}'`
       # here possible reaction to mysql error
-      if [ $error -eq 1213 ]
+      if [ $error -eq 1213 ] || [ $error -eq 1205 ]
       then 
-         printprocesslog "WARN Deadlock found. Should resend query."
+         #printprocesslog "WARN Deadlock found. Should resend query."
          printprocesslog "DEBUG sendquery QUERY: [2nd try] "$query
-         val=`mysql $sqlpwfile -s -u $us $pw --host=$ho $db -e " $query " 2>&1`
+         val=`mysql --defaults-file=$sqlrc -s -e " $query " 2>&1`
          checkmysql2=`echo $?`
          if [ $checkmysql2 -gt 0 ]
          then
-            printprocesslog "ERROR could not query DB "$db" on host "$ho" with user "$us" (program: $program, function sendquery) [2nd try]"
+            printprocesslog "ERROR could not query DB (program: $program, function sendquery, mysqlsetup $sqlrc) [2nd try]"
             printprocesslog "MYSQLERROR [returncode: "$checkmysql"] "$val" [2nd try]"
             error2=`echo $val | grep -E -o 'ERROR [1-9]{1,4}' | grep -E -o '[1-9]{1,4}'`
@@ -233,5 +214,5 @@
       if [ "$warning" != "" ]
       then
-         printprocesslog "WARN possible problem to query DB "$db" on host "$ho" with user "$us" (program: $program, function sendquery) "
+         printprocesslog "WARN possible problem to query DB (program: $program, function sendquery, mysqlsetup $sqlrc) "
          printprocesslog "MYSQLWARN [returncode: "$checkmysql"] "$val
          val=
@@ -256,5 +237,5 @@
 function getstepinfo()
 {
-   getdbsetup
+   #getdbsetup
    needs=( `getfromsetup $step "Needs"` )
    noderestricted=`getfromsetup $step "NodeRestricted"`
@@ -283,7 +264,18 @@
    for otherstep in ${othersteps[@]}
    do
+      #printprocesslog "DEBUG "$otherstep
       if ! [ "$otherstep" = "$maintable" ]
       then 
-         query=$query" LEFT JOIN "$otherstep"Status USING("`getfromsetup $otherstep "Primaries"`") "
+         # joins for needed steps
+         if [ "$1" = "get" ]
+         then 
+            query=$query" LEFT JOIN "$otherstep"Status USING("`getfromsetup $otherstep "Primaries"`") "
+         fi
+         # joins for influenced steps
+         if [ "$1" = "set" ]
+         then 
+            query=$query" "`getfromsetup $otherstep "SpecialJoin2"`
+            query=$query" LEFT JOIN "$otherstep"Status USING("`getfromsetup $otherstep "Primaries"`") "
+         fi
       fi
    done
@@ -297,5 +289,5 @@
    query=$query" FROM "
    othersteps=${needs[@]}
-   getalljoins
+   getalljoins "get"
    # add condition
    query=$query" WHERE "
@@ -392,8 +384,9 @@
    # execute query
    #numproc=`sendquery `#cannot be done with sendquery, because of row counting
-   if ! numproc=`mysql $sqlpwfile -s -u $us $pw --host=$ho $db -e " $query " | wc -l`
-   then
-      printprocesslog "ERROR could not query number of processes from db (program: $program, function getstatus)"
-      echo `date +%F\ %T`" ERROR could not query number of processes from db (program: $program, function getstatus)"
+   printprocesslog "DEBUG send query "$query
+   if ! numproc=`mysql --default-file=$sqlrc -s -e " $query " | wc -l`
+   then
+      printprocesslog "ERROR could not query number of processes from db (program: $program, function getstatus, mysqlsetup $sqlrc)"
+      echo `date +%F\ %T`" ERROR could not query number of processes from db (program: $program, function getstatus, mysqlsetup $sqlrc)"
       continue
    fi
@@ -429,5 +422,5 @@
                ;;
        stop)   case $check in
-                  ok)  printprocesslog "DEBUB setstatus stop - ok"
+                  ok)  printprocesslog "DEBUG setstatus stop - ok"
                        starttime=noreset
                        stoptime="Now()"
@@ -470,5 +463,5 @@
    # get query
    query=" UPDATE "
-   getalljoins
+   getalljoins "set"
    # set the status values according to the new status of the step
    query=$query" SET "
@@ -668,5 +661,5 @@
                printprocesslog "ERROR "$1" not found."
             else
-               printprocesslog "WARN "$1" not found."
+               printprocesslog "WARN "$1" not found. ("$filenight" - "$checknight")"
             fi
          else
@@ -675,5 +668,5 @@
             if [ $filenight -le $checknight ] 
             then 
-               printprocesslog "WARN "$1" not found."
+               printprocesslog "WARN "$1" not found. ("$filenight" - "$checknight")"
             else
                printprocesslog "INFO "$1" not found."
