SQLite

Check-in [5c118617]
Login

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

Overview
Comment: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]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5c118617cf08e17a6edfdfba86e3fc49132a780990b68b52724c2aaeac85f506
User & Date: drh 2019-10-22 19:51:29
Context
2019-10-23
18:09
When a vector comparison appears in the WHERE clause and the constraint side has a COLLATE clause on the first term of the vector, be sure to honor that COLLATE clause. Ticket [135c9da7513e5a97]. (check-in: 978b2d20 user: drh tags: trunk)
18:01
Create new branch named "uuid-funcs" (check-in: 815dc043 user: numist tags: uuid-funcs)
2019-10-22
20:16
Merge the row-value fix from trunk. (check-in: 1fbd7438 user: drh tags: generated-columns)
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)
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)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

66
67
68
69
70
71
72



73
74
75
76
77
78
79
  }
  if( op==TK_SELECT_COLUMN ){
    assert( pExpr->pLeft->flags&EP_xIsSelect );
    return sqlite3ExprAffinity(
        pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
    );
  }



  return pExpr->affExpr;
}

/*
** Set the collating sequence for expression pExpr to be the collating
** sequence named by pToken.   Return a pointer to a new Expr node that
** implements the COLLATE operator.







>
>
>







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  }
  if( op==TK_SELECT_COLUMN ){
    assert( pExpr->pLeft->flags&EP_xIsSelect );
    return sqlite3ExprAffinity(
        pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
    );
  }
  if( op==TK_VECTOR ){
    return sqlite3ExprAffinity(pExpr->x.pList->a[0].pExpr);
  }
  return pExpr->affExpr;
}

/*
** Set the collating sequence for expression pExpr to be the collating
** sequence named by pToken.   Return a pointer to a new Expr node that
** implements the COLLATE operator.

Changes to test/rowvalue.test.

581
582
583
584
585
586
587









588
589
  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







>
>
>
>
>
>
>
>
>


581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
  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}

# 2019-10-22 Ticket 6ef984af8972c2eb
do_execsql_test 24.100 {
  DROP TABLE t0;
  CREATE TABLE t0(c0 TEXT PRIMARY KEY);
  INSERT INTO t0(c0) VALUES ('');
  SELECT (t0.c0, TRUE) > (CAST(0 AS REAL), FALSE) FROM t0;
  SELECT 2 FROM t0 WHERE (t0.c0, TRUE) > (CAST('' AS REAL), FALSE);
} {1 2}

finish_test