/ Check-in [f3112e67]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix an incorrect table lookup used to find the appropriate search operator for a WHERE clause on a row-value inequality. The incorrect table lookup was causing an incorrect answer for the less-than operator. Fix for ticket [f484b65f3d6230593c34f11]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f3112e67cdb27c1aec8d2cee3cb91ade061d093e13505894698e26336898b336
User & Date: drh 2018-02-13 18:48:08
Context
2018-02-13
19:13
Improved test cases for the [f484b65f3d6230593c34f] bug. check-in: 1f300514 user: drh tags: trunk
18:48
Fix an incorrect table lookup used to find the appropriate search operator for a WHERE clause on a row-value inequality. The incorrect table lookup was causing an incorrect answer for the less-than operator. Fix for ticket [f484b65f3d6230593c34f11] check-in: f3112e67 user: drh tags: trunk
16:30
Remove an unused variable from FTS4. check-in: 27ea783b user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/wherecode.c.

1391
1392
1393
1394
1395
1396
1397
1398








1399
1400
1401
1402
1403
1404
1405
      testcase( pStart->wtFlags & TERM_VIRTUAL );
      pX = pStart->pExpr;
      assert( pX!=0 );
      testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
      if( sqlite3ExprIsVector(pX->pRight) ){
        r1 = rTemp = sqlite3GetTempReg(pParse);
        codeExprOrVector(pParse, pX->pRight, r1, 1);
        op = aMoveOp[(pX->op - TK_GT) | 0x0001];








      }else{
        r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
        disableTerm(pLevel, pStart);
        op = aMoveOp[(pX->op - TK_GT)];
      }
      sqlite3VdbeAddOp3(v, op, iCur, addrBrk, r1);
      VdbeComment((v, "pk"));







|
>
>
>
>
>
>
>
>







1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
      testcase( pStart->wtFlags & TERM_VIRTUAL );
      pX = pStart->pExpr;
      assert( pX!=0 );
      testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
      if( sqlite3ExprIsVector(pX->pRight) ){
        r1 = rTemp = sqlite3GetTempReg(pParse);
        codeExprOrVector(pParse, pX->pRight, r1, 1);
        testcase( pX->op==TK_GT );
        testcase( pX->op==TK_GE );
        testcase( pX->op==TK_LT );
        testcase( pX->op==TK_LE );
        op = aMoveOp[((pX->op - TK_GT - 1) & 0x3) | 0x1];
        assert( pX->op!=TK_GT || op==OP_SeekGE );
        assert( pX->op!=TK_GE || op==OP_SeekGE );
        assert( pX->op!=TK_LT || op==OP_SeekLE );
        assert( pX->op!=TK_LE || op==OP_SeekLE );
      }else{
        r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
        disableTerm(pLevel, pStart);
        op = aMoveOp[(pX->op - TK_GT)];
      }
      sqlite3VdbeAddOp3(v, op, iCur, addrBrk, r1);
      VdbeComment((v, "pk"));

Changes to test/rowvalue.test.

433
434
435
436
437
438
439
440

441




































































































442
} {1 1 1 1 2 1}
do_execsql_test 18.6 {
  SELECT * FROM b3 JOIN b4 ON b4.a = b3.a
  WHERE (b3.a, b3.b) IN ( SELECT a, b FROM b5 ); 
} {1 1 1 1 2 1}

 
finish_test






































































































finish_test







|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
} {1 1 1 1 2 1}
do_execsql_test 18.6 {
  SELECT * FROM b3 JOIN b4 ON b4.a = b3.a
  WHERE (b3.a, b3.b) IN ( SELECT a, b FROM b5 ); 
} {1 1 1 1 2 1}

 
# 2018-02-13 Ticket https://www.sqlite.org/src/tktview/f484b65f3d6230593c3
# Incorrect result from a row-value comparison in the WHERE clause.
#
do_execsql_test 19.1 {
  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(a INTEGER PRIMARY KEY,b);
  INSERT INTO t1(a,b) VALUES(1,11),(2,22),(3,33),(4,44);
  SELECT * FROM t1 WHERE (a,b)>(0,0) ORDER BY +a;
} {1 11 2 22 3 33 4 44}
do_execsql_test 19.2 {
  SELECT * FROM t1 WHERE (a,b)>=(0,0) ORDER BY +a;
} {1 11 2 22 3 33 4 44}
do_execsql_test 19.3 {
  SELECT * FROM t1 WHERE (a,b)<(5,0) ORDER BY +a;
} {1 11 2 22 3 33 4 44}
do_execsql_test 19.4 {
  SELECT * FROM t1 WHERE (a,b)<=(5,0) ORDER BY +a;
} {1 11 2 22 3 33 4 44}
do_execsql_test 19.5 {
  SELECT * FROM t1 WHERE (a,b)>(3,0) ORDER BY +a;
} {3 33 4 44}
do_execsql_test 19.6 {
  SELECT * FROM t1 WHERE (a,b)>=(3,0) ORDER BY +a;
} {3 33 4 44}
do_execsql_test 19.7 {
  SELECT * FROM t1 WHERE (a,b)<(3,0) ORDER BY +a;
} {1 11 2 22}
do_execsql_test 19.8 {
  SELECT * FROM t1 WHERE (a,b)<=(3,0) ORDER BY +a;
} {1 11 2 22}
do_execsql_test 19.9 {
  SELECT * FROM t1 WHERE (a,b)>(3,32) ORDER BY +a;
} {3 33 4 44}
do_execsql_test 19.10 {
  SELECT * FROM t1 WHERE (a,b)>(3,33) ORDER BY +a;
} {4 44}
do_execsql_test 19.11 {
  SELECT * FROM t1 WHERE (a,b)>=(3,33) ORDER BY +a;
} {3 33 4 44}
do_execsql_test 19.12 {
  SELECT * FROM t1 WHERE (a,b)>=(3,34) ORDER BY +a;
} {4 44}
do_execsql_test 19.13 {
  SELECT * FROM t1 WHERE (a,b)<(3,34) ORDER BY +a;
} {1 11 2 22 3 33}
do_execsql_test 19.14 {
  SELECT * FROM t1 WHERE (a,b)<(3,33) ORDER BY +a;
} {1 11 2 22}
do_execsql_test 19.15 {
  SELECT * FROM t1 WHERE (a,b)<=(3,33) ORDER BY +a;
} {1 11 2 22 3 33}
do_execsql_test 19.16 {
  SELECT * FROM t1 WHERE (a,b)<=(3,32) ORDER BY +a;
} {1 11 2 22}
do_execsql_test 19.21 {
  SELECT * FROM t1 WHERE (0,0)<(a,b) ORDER BY +a;
} {1 11 2 22 3 33 4 44}
do_execsql_test 19.22 {
  SELECT * FROM t1 WHERE (0,0)<=(a,b) ORDER BY +a;
} {1 11 2 22 3 33 4 44}
do_execsql_test 19.23 {
  SELECT * FROM t1 WHERE (5,0)>(a,b) ORDER BY +a;
} {1 11 2 22 3 33 4 44}
do_execsql_test 19.24 {
  SELECT * FROM t1 WHERE (5,0)>=(a,b) ORDER BY +a;
} {1 11 2 22 3 33 4 44}
do_execsql_test 19.25 {
  SELECT * FROM t1 WHERE (3,0)<(a,b) ORDER BY +a;
} {3 33 4 44}
do_execsql_test 19.26 {
  SELECT * FROM t1 WHERE (3,0)<=(a,b) ORDER BY +a;
} {3 33 4 44}
do_execsql_test 19.27 {
  SELECT * FROM t1 WHERE (3,0)>(a,b) ORDER BY +a;
} {1 11 2 22}
do_execsql_test 19.28 {
  SELECT * FROM t1 WHERE (3,0)>=(a,b) ORDER BY +a;
} {1 11 2 22}
do_execsql_test 19.29 {
  SELECT * FROM t1 WHERE (3,32)<(a,b) ORDER BY +a;
} {3 33 4 44}
do_execsql_test 19.30 {
  SELECT * FROM t1 WHERE (3,33)<(a,b) ORDER BY +a;
} {4 44}
do_execsql_test 19.31 {
  SELECT * FROM t1 WHERE (3,33)<=(a,b) ORDER BY +a;
} {3 33 4 44}
do_execsql_test 19.32 {
  SELECT * FROM t1 WHERE (3,34)<=(a,b) ORDER BY +a;
} {4 44}
do_execsql_test 19.33 {
  SELECT * FROM t1 WHERE (3,34)>(a,b) ORDER BY +a;
} {1 11 2 22 3 33}
do_execsql_test 19.34 {
  SELECT * FROM t1 WHERE (3,33)>(a,b) ORDER BY +a;
} {1 11 2 22}
do_execsql_test 19.35 {
  SELECT * FROM t1 WHERE (3,33)>=(a,b) ORDER BY +a;
} {1 11 2 22 3 33}
do_execsql_test 19.36 {
  SELECT * FROM t1 WHERE (3,32)>=(a,b) ORDER BY +a;
} {1 11 2 22}

finish_test