/ Check-in [7571345d]
Login

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

Overview
Comment:Allow sqlite3GetInt32 to recognize 10-digit decimal numbers as 32-bit. (CVS 4362)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7571345d2078fb52029f9b9924d833ec36d443e6
User & Date: danielk1977 2007-09-01 10:01:13
Context
2007-09-01
11:04
Test sqlite3_bind_zeroblob(). Only include sqlite3Utf8To8 in builds if SQLITE_DEBUG is defined. (CVS 4363) check-in: fde6142b user: danielk1977 tags: trunk
10:01
Allow sqlite3GetInt32 to recognize 10-digit decimal numbers as 32-bit. (CVS 4362) check-in: 7571345d user: danielk1977 tags: trunk
09:02
Fix a problem handling a malloc() failure in printf.c. Also some other things to improve test coverage. (CVS 4361) check-in: 595bfe72 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/util.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
416
417
418
419
420
421
422
423
424
425






426
427
428
429
430
431
432
433
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.211 2007/08/21 19:33:57 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>


/*
................................................................................
  if( zNum[0]=='-' ){
    neg = 1;
    zNum++;
  }else if( zNum[0]=='+' ){
    zNum++;
  }
  while( zNum[0]=='0' ) zNum++;
  for(i=0; i<10 && (c = zNum[i] - '0')>=0 && c<=9; i++){
    v = v*10 + c;
  }






  if( i>9 ){
    return 0;
  }
  if( v-neg>2147483647 ){
    return 0;
  }
  if( neg ){
    v = -v;







|







 







|


>
>
>
>
>
>
|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.212 2007/09/01 10:01:13 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>


/*
................................................................................
  if( zNum[0]=='-' ){
    neg = 1;
    zNum++;
  }else if( zNum[0]=='+' ){
    zNum++;
  }
  while( zNum[0]=='0' ) zNum++;
  for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){
    v = v*10 + c;
  }

  /* The longest decimal representation of a 32 bit integer is 10 digits:
  **
  **             1234567890
  **     2^31 -> 2147483648
  */
  if( i>10 ){
    return 0;
  }
  if( v-neg>2147483647 ){
    return 0;
  }
  if( neg ){
    v = -v;

Changes to test/expr.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
684
685
686
687
688
689
690






691
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing expressions.
#
# $Id: expr.test,v 1.57 2007/06/26 11:13:27 danielk1977 Exp $

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

# Create a table to work with.
#
execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
................................................................................
} {1 {near "THEN": syntax error}}
do_test expr-12.2 {
  catchsql {
    SELECT (CASE WHEN a>4 THEN 1 ELSE 0) FROM test1;
  }
} {1 {near ")": syntax error}}







finish_test







|







 







>
>
>
>
>
>

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
684
685
686
687
688
689
690
691
692
693
694
695
696
697
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing expressions.
#
# $Id: expr.test,v 1.58 2007/09/01 10:01:13 danielk1977 Exp $

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

# Create a table to work with.
#
execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
................................................................................
} {1 {near "THEN": syntax error}}
do_test expr-12.2 {
  catchsql {
    SELECT (CASE WHEN a>4 THEN 1 ELSE 0) FROM test1;
  }
} {1 {near ")": syntax error}}

do_test expr-13.1 {
  execsql {
    SELECT 12345678901234567890;
  }
} {1.23456789012346e+19}

finish_test

Changes to test/incrvacuum.test.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
540
541
542
543
544
545
546

547
548
549
550
551
552
553
554
555
556
557
558
559
560


561
562
563
564
565
566
567
568
569
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the incremental vacuum feature.
#
# Note: There are also some tests for incremental vacuum and IO 
# errors in incrvacuum_ioerr.test.
#
# $Id: incrvacuum.test,v 1.13 2007/08/10 16:41:09 drh Exp $

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

# If this build of the library does not support auto-vacuum, omit this
# whole file.
ifcapable {!autovacuum || !pragma} {
................................................................................
  execsql {
    PRAGMA incremental_vacuum('1');
  }
  expr [file size test.db] / 1024
} {22}

do_test incrvacuum-10.5 {

  execsql {
    PRAGMA incremental_vacuum("3");
  }
  expr [file size test.db] / 1024
} {19}

do_test incrvacuum-10.6 {
  execsql {
    PRAGMA incremental_vacuum = 1;
  }
  expr [file size test.db] / 1024
} {18}

do_test incrvacuum-10.7 {


  execsql {
    PRAGMA incremental_vacuum(0);
  }
  expr [file size test.db] / 1024
} {1}

#----------------------------------------------------------------
# Test that if we set the auto_vacuum mode to 'incremental', then
# create a database, thereafter that database defaults to incremental 







|







 







>

|












>
>

|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the incremental vacuum feature.
#
# Note: There are also some tests for incremental vacuum and IO 
# errors in incrvacuum_ioerr.test.
#
# $Id: incrvacuum.test,v 1.14 2007/09/01 10:01:13 danielk1977 Exp $

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

# If this build of the library does not support auto-vacuum, omit this
# whole file.
ifcapable {!autovacuum || !pragma} {
................................................................................
  execsql {
    PRAGMA incremental_vacuum('1');
  }
  expr [file size test.db] / 1024
} {22}

do_test incrvacuum-10.5 {
breakpoint
  execsql {
    PRAGMA incremental_vacuum("+3");
  }
  expr [file size test.db] / 1024
} {19}

do_test incrvacuum-10.6 {
  execsql {
    PRAGMA incremental_vacuum = 1;
  }
  expr [file size test.db] / 1024
} {18}

do_test incrvacuum-10.7 {
  # Use a really big number as an argument to incremetal_vacuum. Should
  # be interpreted as "free all possible space".
  execsql {
    PRAGMA incremental_vacuum(2147483649);
  }
  expr [file size test.db] / 1024
} {1}

#----------------------------------------------------------------
# Test that if we set the auto_vacuum mode to 'incremental', then
# create a database, thereafter that database defaults to incremental 

Changes to test/printf.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
177
178
179
180
181
182
183



184
185
186
187
188
189
190
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the sqlite_*_printf() interface.
#
# $Id: printf.test,v 1.25 2007/09/01 09:02:54 danielk1977 Exp $

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

set n 1
foreach v {1 2 5 10 99 100 1000000 999999999 0 -1 -2 -5 -10 -99 -100 -9999999} {
  set v32 [expr {$v&0xffffffff}]
................................................................................
} {2147483647 2147483648 4294967296}
do_test printf-8.5 {
  sqlite3_mprintf_int64 {%llx %llx %llx} 2147483647 2147483648 4294967296
} {7fffffff 80000000 100000000}
do_test printf-8.6 {
  sqlite3_mprintf_int64 {%llx %llo %lld} -1 -1 -1
} {ffffffffffffffff 1777777777777777777777 -1}




do_test printf-9.1 {
  sqlite3_mprintf_int {%*.*c} 4 4 65
} {AAAA}
do_test printf-9.2 {
  sqlite3_mprintf_int {%*.*c} -4 1 66
} {B   }
................................................................................
} {abcdefghijklmnopqrstuvwxyz}

# Now test malloc() failure within a sqlite3_mprintf():
#
foreach var {a b c d} {
  set $var [string repeat $var 400]
}

set str1 "[string repeat A 360]%d%d%s"
set str2 [string repeat B 5000]
set zSuccess "[string repeat A 360]11[string repeat B 5000]"
foreach ::iRepeat {0 1} {
  set nTestNum 1
  while {1} {
    sqlite3_memdebug_fail $nTestNum -repeat $::iRepeat







|







 







>
>
>







 







<







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
...
297
298
299
300
301
302
303

304
305
306
307
308
309
310
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the sqlite_*_printf() interface.
#
# $Id: printf.test,v 1.26 2007/09/01 10:01:13 danielk1977 Exp $

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

set n 1
foreach v {1 2 5 10 99 100 1000000 999999999 0 -1 -2 -5 -10 -99 -100 -9999999} {
  set v32 [expr {$v&0xffffffff}]
................................................................................
} {2147483647 2147483648 4294967296}
do_test printf-8.5 {
  sqlite3_mprintf_int64 {%llx %llx %llx} 2147483647 2147483648 4294967296
} {7fffffff 80000000 100000000}
do_test printf-8.6 {
  sqlite3_mprintf_int64 {%llx %llo %lld} -1 -1 -1
} {ffffffffffffffff 1777777777777777777777 -1}
do_test printf-8.7 {
  sqlite3_mprintf_int64 {%llx %llx %llx} +2147483647 +2147483648 +4294967296
} {7fffffff 80000000 100000000}

do_test printf-9.1 {
  sqlite3_mprintf_int {%*.*c} 4 4 65
} {AAAA}
do_test printf-9.2 {
  sqlite3_mprintf_int {%*.*c} -4 1 66
} {B   }
................................................................................
} {abcdefghijklmnopqrstuvwxyz}

# Now test malloc() failure within a sqlite3_mprintf():
#
foreach var {a b c d} {
  set $var [string repeat $var 400]
}

set str1 "[string repeat A 360]%d%d%s"
set str2 [string repeat B 5000]
set zSuccess "[string repeat A 360]11[string repeat B 5000]"
foreach ::iRepeat {0 1} {
  set nTestNum 1
  while {1} {
    sqlite3_memdebug_fail $nTestNum -repeat $::iRepeat