/ Check-in [b323f0f2]
Login
Overview
Comment:Fix bug reported on the mailing list for WHERE clauses like (rowid<'2'). (CVS 2357)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b323f0f2832ac5d225d880db6f56314d2f766a25
User & Date: danielk1977 2005-02-22 09:47:18
Context
2005-02-23
00:26
The script that cross-compiles the windows DLLs now exports the symbols Tclsqlite_Init and Sqlite_Init used to initialize the TCL extension. Ticket #1137. (CVS 2358) check-in: f1870477 user: drh tags: trunk
2005-02-22
09:47
Fix bug reported on the mailing list for WHERE clauses like (rowid<'2'). (CVS 2357) check-in: b323f0f2 user: danielk1977 tags: trunk
2005-02-20
02:25
Version 3.1.3 (CVS 2356) check-in: 36dbf5e9 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/where.c.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
....
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
** This module contains C code that generates VDBE code used to process
** the WHERE clause of SQL statements.  This module is reponsible for
** generating the code that loops through a table looking for applicable
** rows.  Indices are selected and used to speed the search when doing
** so is applicable.  Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.134 2005/02/02 01:10:45 danielk1977 Exp $
*/
#include "sqliteInt.h"

/*
** The query generator uses an array of instances of this structure to
** help it analyze the subexpressions of the WHERE clause.  Each WHERE
** clause subexpression is separated from the others by an AND operator.
................................................................................
      start = sqlite3VdbeCurrentAddr(v);
      pLevel->op = bRev ? OP_Prev : OP_Next;
      pLevel->p1 = iCur;
      pLevel->p2 = start;
      if( testOp!=OP_Noop ){
        sqlite3VdbeAddOp(v, OP_Recno, iCur, 0);
        sqlite3VdbeAddOp(v, OP_MemLoad, pLevel->iMem, 0);
        sqlite3VdbeAddOp(v, testOp, 0, brk);
      }
    }else if( pIdx==0 ){
      /* Case 4:  There is no usable index.  We must do a complete
      **          scan of the entire database table.
      */
      int start;
      int opRewind;







|







 







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
....
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
** This module contains C code that generates VDBE code used to process
** the WHERE clause of SQL statements.  This module is reponsible for
** generating the code that loops through a table looking for applicable
** rows.  Indices are selected and used to speed the search when doing
** so is applicable.  Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.135 2005/02/22 09:47:18 danielk1977 Exp $
*/
#include "sqliteInt.h"

/*
** The query generator uses an array of instances of this structure to
** help it analyze the subexpressions of the WHERE clause.  Each WHERE
** clause subexpression is separated from the others by an AND operator.
................................................................................
      start = sqlite3VdbeCurrentAddr(v);
      pLevel->op = bRev ? OP_Prev : OP_Next;
      pLevel->p1 = iCur;
      pLevel->p2 = start;
      if( testOp!=OP_Noop ){
        sqlite3VdbeAddOp(v, OP_Recno, iCur, 0);
        sqlite3VdbeAddOp(v, OP_MemLoad, pLevel->iMem, 0);
        sqlite3VdbeAddOp(v, testOp, (int)(('n'<<8)&0x0000FF00), brk);
      }
    }else if( pIdx==0 ){
      /* Case 4:  There is no usable index.  We must do a complete
      **          scan of the entire database table.
      */
      int start;
      int opRewind;

Changes to test/intpkey.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
515
516
517
518
519
520
521



522


































523

#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the special processing associated
# with INTEGER PRIMARY KEY columns.
#
# $Id: intpkey.test,v 1.20 2004/11/03 13:59:06 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Create a table with a primary key and a datatype other than
# integer
#
................................................................................
}
do_test intpkey-13.5 {
  catchsql {
    INSERT INTO t1 VALUES('+1234567890',3,4);
  }
} {0 {}}







































finish_test








|







 







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

>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the special processing associated
# with INTEGER PRIMARY KEY columns.
#
# $Id: intpkey.test,v 1.21 2005/02/22 09:47:19 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Create a table with a primary key and a datatype other than
# integer
#
................................................................................
}
do_test intpkey-13.5 {
  catchsql {
    INSERT INTO t1 VALUES('+1234567890',3,4);
  }
} {0 {}}

# Compare an INTEGER PRIMARY KEY against a TEXT expression. The INTEGER
# affinity should be applied to the text value before the comparison
# takes place.
#
do_test intpkey-14.1 {
  execsql {
    CREATE TABLE t3(a INTEGER PRIMARY KEY, b INTEGER, c TEXT);
    INSERT INTO t3 VALUES(1, 1, 'one');
    INSERT INTO t3 VALUES(2, 2, '2');
    INSERT INTO t3 VALUES(3, 3, 3);
  }
} {}
do_test intpkey-14.2 {
  execsql {
    SELECT * FROM t3 WHERE a>2;
  }
} {3 3 3}
do_test intpkey-14.3 {
  execsql {
    SELECT * FROM t3 WHERE a>'2';
  }
} {3 3 3}
do_test intpkey-14.4 {
  execsql {
    SELECT * FROM t3 WHERE a<'2';
  }
} {1 1 one}
do_test intpkey-14.5 {
  execsql {
    SELECT * FROM t3 WHERE a<c;
  }
} {1 1 one}
do_test intpkey-14.6 {
  execsql {
    SELECT * FROM t3 WHERE a=c;
  }
} {2 2 2 3 3 3}

finish_test