/ Check-in [da0e4bff]
Login

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

Overview
Comment:Implicit string->numeric conversion should go to an integer value when possible. Ticket #3257. (CVS 5502)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:da0e4bff30a77f72ae283406b547401c2ebb42c5
User & Date: drh 2008-07-30 13:27:11
Context
2008-07-30
15:27
In the unix OS implementation, replace inode hash tables with linked lists. (CVS 5503) check-in: db4022db user: drh tags: trunk
13:27
Implicit string->numeric conversion should go to an integer value when possible. Ticket #3257. (CVS 5502) check-in: da0e4bff user: drh tags: trunk
13:15
Make sure everything is deallocated before calling sqlite3_shutdown(). Ticket #3259. (CVS 5501) check-in: 4a6ee886 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
....
1175
1176
1177
1178
1179
1180
1181


1182
1183
1184
1185
1186
1187
1188
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.768 2008/07/30 13:14:55 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
#include "vdbeInt.h"

/*
** The following global variable is incremented every time a cursor
................................................................................
*/
case OP_Add:                   /* same as TK_PLUS, in1, in2, out3 */
case OP_Subtract:              /* same as TK_MINUS, in1, in2, out3 */
case OP_Multiply:              /* same as TK_STAR, in1, in2, out3 */
case OP_Divide:                /* same as TK_SLASH, in1, in2, out3 */
case OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */
  int flags;


  flags = pIn1->flags | pIn2->flags;
  if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null;
  if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){
    i64 a, b;
    a = pIn1->u.i;
    b = pIn2->u.i;
    switch( pOp->opcode ){







|







 







>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
....
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.769 2008/07/30 13:27:11 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
#include "vdbeInt.h"

/*
** The following global variable is incremented every time a cursor
................................................................................
*/
case OP_Add:                   /* same as TK_PLUS, in1, in2, out3 */
case OP_Subtract:              /* same as TK_MINUS, in1, in2, out3 */
case OP_Multiply:              /* same as TK_STAR, in1, in2, out3 */
case OP_Divide:                /* same as TK_SLASH, in1, in2, out3 */
case OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */
  int flags;
  applyNumericAffinity(pIn1);
  applyNumericAffinity(pIn2);
  flags = pIn1->flags | pIn2->flags;
  if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null;
  if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){
    i64 a, b;
    a = pIn1->u.i;
    b = pIn2->u.i;
    switch( pOp->opcode ){

Changes to test/expr.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
698
699
700
701
702
703
704
705









































706
#    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.63 2008/07/15 00:27:35 drh 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 ")": syntax error}}

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










































finish_test







|







 








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

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
#    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.64 2008/07/30 13:27:11 drh 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 ")": syntax error}}

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

# Implicit String->Integer conversion is used when possible.
#
do_test expr-13.2 {
  execsql {
    SELECT 0+'9223372036854775807'
  }
} {9223372036854775807}
do_test expr-13.3 {
  execsql {
    SELECT '9223372036854775807'+0
  }
} {9223372036854775807}

# If the value is too large, use String->Float conversion.
#
do_test expr-13.4 {
  execsql {
    SELECT 0+'9223372036854775808'
  }
} {9.22337203685478e+18}
do_test expr-13.5 {
  execsql {
    SELECT '9223372036854775808'+0
  }
} {9.22337203685478e+18}

# Use String->float conversion if the value is explicitly a floating
# point value.
#
do_test expr-13.6 {
  execsql {
    SELECT 0+'9223372036854775807.0'
  }
} {9.22337203685478e+18}
do_test expr-13.7 {
  execsql {
    SELECT '9223372036854775807.0'+0
  }
} {9.22337203685478e+18}


finish_test