IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29664


Ignore:
Timestamp:
Nov 4, 2010, 12:05:06 PM (16 years ago)
Author:
eugene
Message:

fix the diff query for stackstack and update to use the @word@ replacement technique

Location:
branches/eam_branches/ipp-20101103/ippTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/ippTools/share/difftool_definestackstack_part0.sql

    r26958 r29664  
    2222           stackRun.state = 'full' AND
    2323           stackSumSkyfile.fault = 0 AND stackSumSkyfile.quality = 0
    24            -- template where hook %s
     24           @STACK2_QUERY@ -- template condition
    2525     GROUP BY
    2626           skycell_id,
     
    3838          JOIN stackSumSkyfile USING(stack_id)
    3939          WHERE 1
    40           -- input where hook %s
     40          @STACK1_QUERY@ -- input condition
    4141) AS diffExp ON diffExp.stack1 = stackRun.stack_id AND diffExp.stack2 = template.max_stack_id
    4242WHERE
    4343        stackSumSkyfile.fault = 0 AND stackSumSkyfile.quality = 0
    44         -- diff where hook %s
    45         -- input where hook again %s
     44        @DIFF0_QUERY@  -- diff constraint
     45        @STACK1_QUERY@ -- input constraint
    4646ORDER BY stackRun.data_group,stackRun.filter
  • branches/eam_branches/ipp-20101103/ippTools/share/difftool_definestackstack_part1.sql

    r29553 r29664  
    2323           stackRun.state = 'full' AND
    2424           stackSumSkyfile.fault = 0 AND stackSumSkyfile.quality = 0
    25            -- template where hook %s
     25           @STACK2_QUERY@ -- template constraint
    2626     GROUP BY
    2727           skycell_id,
     
    3939          JOIN stackSumSkyfile USING(stack_id)
    4040          WHERE 1
    41           -- input where hook %s
     41          @STACK1_QUERY@ -- input constraint
    4242) AS diffExp ON diffExp.stack1 = stackRun.stack_id AND diffExp.stack2 = template.max_stack_id
    4343WHERE
    4444        stackSumSkyfile.fault = 0 AND stackSumSkyfile.quality = 0
    45         -- diff where hook %s
    46         -- input where hook again %s
     45        @STACK1_QUERY@ -- input constraint
    4746group by stackRun.stack_id,
    4847       stackRun.data_group,
     
    5453       template.max_stack_id,
    5554       template.template_label
     55       @DIFF1_QUERY@  -- diff constraint
    5656ORDER BY stackRun.data_group,stackRun.filter,stackRun.skycell_id
  • branches/eam_branches/ipp-20101103/ippTools/src/difftool.c

    r29553 r29664  
    20092009    if (psListLength(stack1Where->list)) {
    20102010        psString whereClause = psDBGenerateWhereConditionSQL(stack1Where, NULL);
    2011         psStringAppend(&stack1Query, "\n AND %s", whereClause);
     2011        psStringAppend(&stack1Query, "AND %s", whereClause);
    20122012        psFree(whereClause);
    2013     } else {
    2014         stack1Query = psStringCopy("\n");
    2015     }
     2013    }
    20162014    psFree(stack1Where);
    20172015
    20182016    if (psListLength(stack2Where->list)) {
    20192017        psString whereClause = psDBGenerateWhereConditionSQL(stack2Where, NULL);
    2020         psStringAppend(&stack2Query, "\n AND %s", whereClause);
     2018        psStringAppend(&stack2Query, "AND %s", whereClause);
    20212019        psFree(whereClause);
    2022     } else {
    2023         stack2Query = psStringCopy("\n");
    2024     }
     2020    }
    20252021    psFree(stack2Where);
    2026 
    20272022 
    20282023    // don't queue for stacks that have already been diffed unless requested
     
    20302025    psString diffQuery1 = NULL;
    20312026    if (! (reRun || newTemplates) ) {
    2032         psStringAppend(&diffQuery0, "\n AND diffExp.diff_id IS NULL");
    2033         psStringAppend(&diffQuery1, "\n AND n_diff = 0");
    2034     } else {
    2035         diffQuery0 = psStringCopy("\n");
    2036         diffQuery1 = psStringCopy("\n");
    2037     }
     2027        psStringAppend(&diffQuery0, "AND diffExp.diff_id IS NULL");
     2028        psStringAppend(&diffQuery1, "HAVING n_diff = 0");
     2029    }
    20382030
    20392031    // find the distinct set of data_groups and filters
     
    20502042    }
    20512043
    2052     if (!p_psDBRunQueryF(config->dbh, query, stack2Query, stack1Query, diffQuery0, stack1Query)) {
     2044    psStringSubstitute(&query, stack1Query, "@STACK1_QUERY@");
     2045    psStringSubstitute(&query, stack2Query, "@STACK2_QUERY@");
     2046    psStringSubstitute(&query, diffQuery0,  "@DIFF0_QUERY@");
     2047
     2048    if (!p_psDBRunQuery(config->dbh, query)) {
    20532049        psError(PS_ERR_UNKNOWN, false, "database error");
    20542050        psFree(query);
     
    21182114        psString thisWhere = psDBGenerateWhereConditionSQL(row,NULL);
    21192115        psStringSubstitute(&thisWhere,"stackRun.","INPUT_");
    2120         psStringAppend(&this_stack1Query,"\n AND %s", thisWhere);
     2116        psStringAppend(&this_stack1Query,"AND %s", thisWhere);
    21212117        psFree(thisWhere);
    21222118
    2123         psTrace("difftool",1, query,stack2Query,this_stack1Query,diffQuery1,this_stack1Query);
     2119        psStringSubstitute(&query, this_stack1Query, "@STACK1_QUERY@");
     2120        psStringSubstitute(&query, stack2Query,      "@STACK2_QUERY@");
     2121        psStringSubstitute(&query, diffQuery1,       "@DIFF1_QUERY@");
     2122
     2123        psTrace("difftool", 1, "%s", query);
    21242124        if (!psDBTransaction(config->dbh)) {
    21252125            psError(PS_ERR_UNKNOWN, false, "database error");
     
    21272127        }
    21282128
    2129         if (!p_psDBRunQueryF(config->dbh, query, stack2Query, this_stack1Query, diffQuery1, this_stack1Query)) {
     2129        if (!p_psDBRunQuery(config->dbh, query)) {
    21302130            psError(PS_ERR_UNKNOWN, false, "database error");
    21312131            psFree(query);
Note: See TracChangeset for help on using the changeset viewer.