/ Check-in [52559ad5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Assert that if two functions compare equal in every other way, then they must both have OVER clauses, or neither has an OVER clause. Use this fact to simplify expression comparison.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 52559ad58ce412af40f1f34e80bfe9fadc6a93f3ca0cfaf69f94d615bbb99831
User & Date: drh 2018-07-10 07:25:42
Context
2018-07-10
07:39
Fix a harmless warning about comment formatting in the previous check-in. Simplify the ORDER BY dereferencing logic so that it avoids unreachable branches. check-in: 0f6ec605 user: drh tags: trunk
07:25
Assert that if two functions compare equal in every other way, then they must both have OVER clauses, or neither has an OVER clause. Use this fact to simplify expression comparison. check-in: 52559ad5 user: drh tags: trunk
06:47
Enhance the sqlite3ExprCompare() routine so that it knows to compare the OVER clause of window functions. check-in: 0a7649af user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  4948   4948       assert( (combinedFlags & EP_Reduced)==0 );
  4949   4949       if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
  4950   4950         if( pA->iColumn!=pB->iColumn ) return 2;
  4951   4951         if( pA->iTable!=pB->iTable 
  4952   4952          && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
  4953   4953       }
  4954   4954   #ifndef SQLITE_OMIT_WINDOWFUNC
         4955  +    /* Justification for the assert():
         4956  +    /* window functions have p->op==TK_FUNCTION but aggregate functions
         4957  +    ** have p->op==TK_AGG_FUNCTION.  So any comparison between an aggregate
         4958  +    ** function and a window function should have failed before reaching
         4959  +    ** this point.  And, it is not possible to have a window function and
         4960  +    ** a scalar function with the same name and number of arguments.  So
         4961  +    ** if we reach this point, either A and B both window functions or
         4962  +    ** neither are a window functions. */
         4963  +    assert( (pA->pWin==0)==(pB->pWin==0) );
         4964  +
  4955   4965       if( pA->pWin!=0 ){
  4956         -      if( pB->pWin==0 ) return 2;
  4957   4966         if( sqlite3WindowCompare(pParse,pA->pWin,pB->pWin)!=0 ) return 2;
  4958         -    }else if( pB->pWin!=0 ){
  4959         -      return 2;
  4960   4967       }
  4961   4968   #endif
  4962   4969     }
  4963   4970     return 0;
  4964   4971   }
  4965   4972   
  4966   4973   /*