/ Check-in [c7da1c01]
Login

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

Overview
Comment:Previous check-in to fix [b47e3627ecaadbde] was incomplete. This check-in completes the fix and adds a test cases.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c7da1c01f1f239e68c2173ac5748b8c5798271e43bdcee68f51f97cd0ca92bd5
User & Date: drh 2019-10-22 11:29:22
Context
2019-10-22
19:51
Disqualify row-value comparisons for use by an index if the right-hand side has an affinity that does not match the index. Fix for ticket [6ef984af8972c2eb] check-in: 5c118617 user: drh tags: trunk
12:02
Merge changes on trunk into the generated-columns branch. check-in: ba123b8c user: drh tags: generated-columns
11:29
Previous check-in to fix [b47e3627ecaadbde] was incomplete. This check-in completes the fix and adds a test cases. check-in: c7da1c01 user: drh tags: trunk
01:00
Move the sqlite3LocateCollSeq(), sqlite3FindCollSeq(), and sqlite3GetCollSeq() routines so that they are all beside one another in the callback.c source file. No logic changes. check-in: 9ff80a9b user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/whereexpr.c.

107
108
109
110
111
112
113


114
115

116
117
118
119
120
121
122
}

/*
** Commute a comparison operator.  Expressions of the form "X op Y"
** are converted into "Y op X".
*/
static u16 exprCommute(Parse *pParse, Expr *pExpr){


  if( sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight) !=
      sqlite3BinaryCompareCollSeq(pParse, pExpr->pRight, pExpr->pLeft) ){

    pExpr->flags ^= EP_Commuted;
  }
  SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
  if( pExpr->op>=TK_GT ){
    assert( TK_LT==TK_GT+2 );
    assert( TK_GE==TK_LE+2 );
    assert( TK_GT>TK_EQ );







>
>
|
|
>







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
}

/*
** Commute a comparison operator.  Expressions of the form "X op Y"
** are converted into "Y op X".
*/
static u16 exprCommute(Parse *pParse, Expr *pExpr){
  if( pExpr->pLeft->op==TK_VECTOR
   || pExpr->pRight->op==TK_VECTOR
   || sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight) !=
      sqlite3BinaryCompareCollSeq(pParse, pExpr->pRight, pExpr->pLeft)
  ){
    pExpr->flags ^= EP_Commuted;
  }
  SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
  if( pExpr->op>=TK_GT ){
    assert( TK_LT==TK_GT+2 );
    assert( TK_GE==TK_LE+2 );
    assert( TK_GT>TK_EQ );

Changes to test/rowvalue.test.

565
566
567
568
569
570
571
572
















573
  SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1) IN (SELECT 3,4);
  SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1) IN (SELECT 5,6);
  SELECT (SELECT 3,4 UNION SELECT 5,6 ORDER BY 1 DESC) IN (SELECT 3,4);
  SELECT (SELECT 3,4 UNION SELECT 5,6 ORDER BY 1 DESC) IN (SELECT 5,6);
  SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1 DESC) IN (SELECT 3,4);
  SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1 DESC) IN (SELECT 5,6);
} {1 0 1 0 0 1 0 1}

















finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
  SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1) IN (SELECT 3,4);
  SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1) IN (SELECT 5,6);
  SELECT (SELECT 3,4 UNION SELECT 5,6 ORDER BY 1 DESC) IN (SELECT 3,4);
  SELECT (SELECT 3,4 UNION SELECT 5,6 ORDER BY 1 DESC) IN (SELECT 5,6);
  SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1 DESC) IN (SELECT 3,4);
  SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1 DESC) IN (SELECT 5,6);
} {1 0 1 0 0 1 0 1}

# 2019-10-21 Ticket b47e3627ecaadbde
#
do_execsql_test 23.100 {
  DROP TABLE IF EXISTS t0;
  CREATE TABLE t0(aa COLLATE NOCASE, bb);
  INSERT INTO t0 VALUES('a', 'A');
  SELECT (+bb,1) >= (aa, 1), (aa,1)<=(+bb,1) FROM t0;
  SELECT 2 FROM t0 WHERE (+bb,1) >= (aa,1);
  SELECT 3 FROM t0 WHERE (aa,1) <= (+bb,1);
} {0 1 3}
do_execsql_test 23.110 {
  SELECT (SELECT +bb,1) >= (aa, 1), (aa,1)<=(SELECT +bb,1) FROM t0;
  SELECT 2 FROM t0 WHERE (SELECT +bb,1) >= (aa,1);
  SELECT 3 FROM t0 WHERE (aa,1) <= (SELECT +bb,1);
} {0 1 3}

finish_test