IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2010, 4:21:40 PM (16 years ago)
Author:
eugene
Message:

NULL is PS_MAX_S64 for id fields; added code to set state to "new" when insert is done

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/difftool.c

    r26945 r26949  
    9090        MODECASE(DIFFTOOL_MODE_DEFINEWARPSTACK,       definewarpstackMode);
    9191        MODECASE(DIFFTOOL_MODE_DEFINEWARPWARP,        definewarpwarpMode);
    92         MODECASE(DIFFTOOL_MODE_DEFINESTACKSTACK,      definestackstackMode);
     92        MODECASE(DIFFTOOL_MODE_DEFINESTACKSTACK,      definestackstackMode);
    9393        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN,     pendingcleanuprunMode);
    9494        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode);
     
    18491849  PXOPT_COPY_F32(config->args, stack1Where, "-good_frac", "stackSumSkyfile.good_frac", ">=");
    18501850  PXOPT_COPY_F32(config->args, stack2Where, "-good_frac", "stackSumSkyfile.good_frac", ">=");
    1851  
     1851
    18521852  PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); // required option
    18531853  PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); // option
     
    18571857  PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false);
    18581858  PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false);
    1859  
     1859
    18601860  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    18611861  PXOPT_LOOKUP_BOOL(reRun, config->args, "-rerun", false);
     
    18681868    PXOPT_LOOKUP_STR(label,config->args, "-input_label",true,false);
    18691869  }
    1870  
     1870
    18711871  // Organize the config information into queries.
    18721872  psString stack1Query = NULL;
     
    19051905    return(false);
    19061906  }
    1907  
     1907
    19081908  if (!psDBTransaction(config->dbh)) {
    19091909    psError(PS_ERR_UNKNOWN, false, "database error");
     
    19701970    psString this_dist_group = psMetadataLookupStr(&mdok,row,"INPUT_dist_group");
    19711971    psString this_label = psMetadataLookupStr(&mdok,row,"INPUT_label");
    1972    
     1972
    19731973    psString this_stack1Query = psStringCopy(stack1Query);
    1974    
     1974
    19751975    psString thisWhere = psDBGenerateWhereConditionSQL(row,NULL);
    19761976    psStringSubstitute(&thisWhere,"stackRun.","INPUT_");
    19771977    psStringAppend(&this_stack1Query,"\n AND %s", thisWhere);
    19781978    psFree(thisWhere);
    1979    
     1979
    19801980/*     psTrace("difftool",1, query,stack2Query,diffQuery,this_stack1Query,this_stack1Query); */
    19811981    if (!psDBTransaction(config->dbh)) {
     
    19831983      return(false);
    19841984    }
    1985    
     1985
    19861986    if (!p_psDBRunQueryF(config->dbh, query, stack2Query, diffQuery, this_stack1Query, this_stack1Query)) {
    19871987      psError(PS_ERR_UNKNOWN, false, "database error");
    19881988      psFree(query);
    19891989      if (!psDBRollback(config->dbh)) {
    1990         psError(PS_ERR_UNKNOWN, false, "database error");
     1990        psError(PS_ERR_UNKNOWN, false, "database error");
    19911991      }
    19921992      return false;
    19931993    }
    19941994    psFree(this_stack1Query);
    1995    
     1995
    19961996    psArray *diff_id_output = p_psDBFetchResult(config->dbh);
    19971997    if (!diff_id_output) {
     
    19991999      switch (err) {
    20002000      case PS_ERR_DB_CLIENT:
    2001         psError(PXTOOLS_ERR_SYS, false, "database error");
    2002         break;
     2001        psError(PXTOOLS_ERR_SYS, false, "database error");
     2002        break;
    20032003      case PS_ERR_DB_SERVER:
    2004         psError(PXTOOLS_ERR_PROG, false, "database error");
    2005         break;
     2004        psError(PXTOOLS_ERR_PROG, false, "database error");
     2005        break;
    20062006      default:
    2007         psError(PXTOOLS_ERR_PROG, false, "unknown error");
    2008         break;
     2007        psError(PXTOOLS_ERR_PROG, false, "unknown error");
     2008        break;
    20092009      }
    20102010      if (!psDBRollback(config->dbh)) {
    2011         psError(PS_ERR_UNKNOWN, false, "database error");
     2011        psError(PS_ERR_UNKNOWN, false, "database error");
    20122012      }
    20132013      return false;
     
    20172017      psFree(diff_id_output);
    20182018      if (!psDBCommit(config->dbh)) {
    2019         psError(PS_ERR_UNKNOWN, false, "database error");
    2020         return false;
     2019        psError(PS_ERR_UNKNOWN, false, "database error");
     2020        return false;
    20212021      }
    20222022      return true;
    20232023    }
    2024    
     2024
    20252025    // ok we've got one create the diffRun
    20262026    diffRunRow *run = diffRunRowAlloc(
    2027                                       0,          // ID
    2028                                       "reg",      // state
    2029                                       workdir,
    2030                                       label ? label : this_label,
    2031                                       data_group ? data_group : this_data_group,
    2032                                       dist_group ? dist_group : this_dist_group,
    2033                                       reduction,
    2034                                       NULL,       // dvodb
    2035                                       registered,
    2036                                       tess_id,
    2037                                       false,                 // bothways
    2038                                       false,                 // exposure
    2039                                       0,       // magicked
    2040                                       note
    2041                                       );
     2027                                      0,          // ID
     2028                                      "reg",      // state
     2029                                      workdir,
     2030                                      label ? label : this_label,
     2031                                      data_group ? data_group : this_data_group,
     2032                                      dist_group ? dist_group : this_dist_group,
     2033                                      reduction,
     2034                                      NULL,       // dvodb
     2035                                      registered,
     2036                                      tess_id,
     2037                                      false,                 // bothways
     2038                                      false,                 // exposure
     2039                                      0,       // magicked
     2040                                      note
     2041                                      );
    20422042    // Commit to database
    20432043    if (!diffRunInsertObject(config->dbh, run)) {
     
    20452045      psFree(run);
    20462046      if (!psDBRollback(config->dbh)) {
    2047         psError(PS_ERR_UNKNOWN, false, "database error");
     2047        psError(PS_ERR_UNKNOWN, false, "database error");
    20482048      }
    20492049      return false;
     
    20602060      psTrace("difftool",1,"%s %ld %ld %s\n",in_skycell_id,in_input_stack_id,in_template_stack_id,in_tess_id);
    20612061      diffInputSkyfileRow *input = diffInputSkyfileRowAlloc(
    2062                                                             run->diff_id,   // ID
    2063                                                             in_skycell_id,
    2064                                                             NULL, // warp1_id
    2065                                                             in_input_stack_id, // stack1
    2066                                                             NULL, // warp2_id
    2067                                                             in_template_stack_id, // stack2
    2068                                                             in_tess_id,
    2069                                                             0 // diff_skyfile_id
    2070                                                             );
     2062                                                            run->diff_id,   // ID
     2063                                                            in_skycell_id,
     2064                                                            PS_MAX_S64, // warp1_id -> NULL
     2065                                                            in_input_stack_id, // stack1
     2066                                                            PS_MAX_S64, // warp2_id -> NULL
     2067                                                            in_template_stack_id, // stack2
     2068                                                            in_tess_id,
     2069                                                            0 // diff_skyfile_id
     2070                                                            );
    20712071      // Commit to database the input
    20722072      if (!diffInputSkyfileInsertObject(config->dbh, input)) {
    2073         psError(PS_ERR_UNKNOWN, false, "database error");
    2074         psFree(input);
    2075         if (!psDBRollback(config->dbh)) {
    2076           psError(PS_ERR_UNKNOWN, false, "database error");
    2077         }
    2078         return false;
     2073        psError(PS_ERR_UNKNOWN, false, "database error");
     2074        psFree(input);
     2075        if (!psDBRollback(config->dbh)) {
     2076          psError(PS_ERR_UNKNOWN, false, "database error");
     2077        }
     2078        return false;
    20792079      }
     2080
    20802081      //      diffInputSkyfilePrintObject(stdout,input,1);
    20812082      psFree(input);
    20822083    }
     2084
     2085    if (!setdiffRunState(config, run->diff_id, "new", false)) {
     2086        psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, run->diff_id);
     2087        psFree(stack1Query);
     2088        psFree(stack2Query);
     2089        psFree(diffQuery);
     2090        psFree(run);
     2091        if (!psDBRollback(config->dbh)) {
     2092            psError(PS_ERR_UNKNOWN, false, "database error");
     2093        }
     2094        return false;
     2095    }
     2096
    20832097    psFree(run);
    20842098  }
     
    20882102  psFree(diffQuery);
    20892103  psFree(output);
    2090  
     2104
    20912105  return(true);
    20922106}
     
    21112125    psFree(query);
    21122126    query = queryCopy;
    2113    
     2127
    21142128    if (where && psListLength(where->list)) {
    21152129        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    2116         psStringAppend(&whereClause, " AND ");
    2117         psStringSubstitute(&query,whereClause,"@INNERCONSTRAINT@");
     2130        psStringAppend(&whereClause, " AND ");
     2131        psStringSubstitute(&query,whereClause,"@INNERCONSTRAINT@");
    21182132        psFree(whereClause);
    21192133    }
     
    23172331      PXOPT_LOOKUP_S64(set_magicked, config->args, "-magicked", 0, false);
    23182332      magicked = set_magicked;
    2319   } 
     2333  }
    23202334
    23212335  psString query = pxDataGet("difftool_change_skyfile_data_state.sql");
Note: See TracChangeset for help on using the changeset viewer.