Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-2366

If where clause contains both equal and greater then conditions then query may return no results

    XMLWordPrintable

Details

    • Hide

      Run such query against a DB which has 'some_table' table with 'some_field' field which has values 1 to 10 (for example):

      SELECT some_field FROM some_table WHERE some_field = 5 AND some_field > 3

      It should produce a line with some_field = 5, but in fact it produces no lines.

      Show
      Run such query against a DB which has 'some_table' table with 'some_field' field which has values 1 to 10 (for example): SELECT some_field FROM some_table WHERE some_field = 5 AND some_field > 3 It should produce a line with some_field = 5, but in fact it produces no lines.
    • Low

    Description

      If WHERE clause contains '>' and '=' conditions for the same field then query may produce no result - depending on conditions order.

      The problem seems to be in org.teiid.query.rewriter.QueryRewriter class, method rewriteAndConjunct(). Pay attention to following piece of code:

      ... if (cc1.getOperator() == CompareCriteria.EQ) {
      if (!Evaluator.compare(cc1, ((Constant)cc1.getRightExpression()).getValue(), ((Constant)cc.getRightExpression()).getValue()))

      { return FALSE_CRITERIA; }

      Note that cc1 (which is guaranteed to have EQ criterion) is passed to Evaluator.compare. Thus right expressions of cc and cc1 are required to be equal. But if we have one contition EQ and another GT then it should instead check if right side of EQ is bigger then right side of GT.

      Bug TEIID-1704 describes a bit similar situation but it is still a different case.

      Attachments

        Activity

          People

            rhn-engineering-shawkins Steven Hawkins
            paul.lysak_jira Paul Lysak (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: