/ Check-in [5c6146b5]
Login

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

Overview
Comment:Handle expressions like "expr IS TRUE COLLATE xyz" in the same way as "expr IS TRUE". Fix for [4d01eda8115b10d1].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5c6146b56a75a94f4baa10e95407c54dd0b9314a57a8702a4b96b15c4d7ac48c
User & Date: dan 2019-06-12 13:49:32
References
2019-06-12
13:50 Closed ticket [4d01eda8]: IS TRUE operator malfunctions with COLLATE and REAL value plus 6 other changes artifact: 75b45c09 user: dan
Context
2019-06-12
20:51
As a special case, casting '-0.0' into numeric should yield 0. Fix for ticket [674385aeba91c774]. check-in: 491f0f9b user: drh tags: trunk
20:11
Enhancements to the printf() logic in order to render a negative zero with a minus sign. Leaf check-in: 6ba4be66 user: drh tags: negative-zero
13:49
Handle expressions like "expr IS TRUE COLLATE xyz" in the same way as "expr IS TRUE". Fix for [4d01eda8115b10d1]. check-in: 5c6146b5 user: dan tags: trunk
2019-06-11
21:02
The affinity of the unlikely() function and its cousins should be "none". Ticket [0c620df60bffd9ef] check-in: 614ecb0a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  1809   1809   }
  1810   1810   
  1811   1811   /*
  1812   1812   ** The argument must be a TK_TRUEFALSE Expr node.  Return 1 if it is TRUE
  1813   1813   ** and 0 if it is FALSE.
  1814   1814   */
  1815   1815   int sqlite3ExprTruthValue(const Expr *pExpr){
         1816  +  pExpr = sqlite3ExprSkipCollate((Expr*)pExpr);
  1816   1817     assert( pExpr->op==TK_TRUEFALSE );
  1817   1818     assert( sqlite3StrICmp(pExpr->u.zToken,"true")==0
  1818   1819          || sqlite3StrICmp(pExpr->u.zToken,"false")==0 );
  1819   1820     return pExpr->u.zToken[4]==0;
  1820   1821   }
  1821   1822   
  1822   1823   /*

Changes to src/resolve.c.

   926    926       }
   927    927       case TK_VARIABLE: {
   928    928         notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
   929    929         break;
   930    930       }
   931    931       case TK_IS:
   932    932       case TK_ISNOT: {
   933         -      Expr *pRight;
          933  +      Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
   934    934         assert( !ExprHasProperty(pExpr, EP_Reduced) );
   935    935         /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE",
   936    936         ** and "x IS NOT FALSE". */
   937         -      if( (pRight = pExpr->pRight)->op==TK_ID ){
          937  +      if( pRight->op==TK_ID ){
   938    938           int rc = resolveExprStep(pWalker, pRight);
   939    939           if( rc==WRC_Abort ) return WRC_Abort;
   940    940           if( pRight->op==TK_TRUEFALSE ){
   941    941             pExpr->op2 = pExpr->op;
   942    942             pExpr->op = TK_TRUTH;
   943    943             return WRC_Continue;
   944    944           }

Changes to src/treeview.c.

   510    510       case TK_TRUTH: {
   511    511         int x;
   512    512         const char *azOp[] = {
   513    513            "IS-FALSE", "IS-TRUE", "IS-NOT-FALSE", "IS-NOT-TRUE"
   514    514         };
   515    515         assert( pExpr->op2==TK_IS || pExpr->op2==TK_ISNOT );
   516    516         assert( pExpr->pRight );
   517         -      assert( pExpr->pRight->op==TK_TRUEFALSE );
          517  +      assert( sqlite3ExprSkipCollate(pExpr->pRight)->op==TK_TRUEFALSE );
   518    518         x = (pExpr->op2==TK_ISNOT)*2 + sqlite3ExprTruthValue(pExpr->pRight);
   519    519         zUniOp = azOp[x];
   520    520         break;
   521    521       }
   522    522   
   523    523       case TK_SPAN: {
   524    524         sqlite3TreeViewLine(pView, "SPAN %Q", pExpr->u.zToken);

Changes to test/istrue.test.

   153    153     INSERT INTO t7(a,b,c) VALUES(2,true,false);
   154    154     ALTER TABLE t7 ADD COLUMN d BOOLEAN DEFAULT false;
   155    155     ALTER TABLE t7 ADD COLUMN e BOOLEAN DEFAULT true;
   156    156     INSERT INTO t7(a,b,c) VALUES(3,true,false);
   157    157     INSERT INTO t7 VALUES(4,false,true,true,false);
   158    158     SELECT *,'x' FROM t7 ORDER BY a;
   159    159   } {1 0 1 0 1 x 2 1 0 0 1 x 3 1 0 0 1 x 4 0 1 1 0 x}
          160  +
          161  +do_execsql_test istrue-710 {
          162  +  SELECT 0.5 IS TRUE COLLATE NOCASE;
          163  +  SELECT 0.5 IS TRUE COLLATE RTRIM;
          164  +  SELECT 0.5 IS TRUE COLLATE BINARY;
          165  +
          166  +  SELECT 0.5 IS TRUE;
          167  +  SELECT 0.5 COLLATE NOCASE IS TRUE;
          168  +  SELECT 0.0 IS FALSE;
          169  +
          170  +  SELECT 0.0 IS FALSE COLLATE NOCASE;
          171  +  SELECT 0.0 IS FALSE COLLATE RTRIM;
          172  +  SELECT 0.0 IS FALSE COLLATE BINARY;
          173  +} {1 1 1   1 1 1  1 1 1}
   160    174   
   161    175   finish_test