/ Check-in [9321e742]
Login

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

Overview
Comment:Fix a bug meant real numbers with a negative sign were being stored as strings by default (instead of IEEE floats). (CVS 1388)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9321e7426337e04064b5791c48dd5fc3c1eecaa2
User & Date: danielk1977 2004-05-16 22:55:28
Context
2004-05-17
10:48
More changes to support the new types model. Compound SELECTs are currently broken. (CVS 1389) check-in: 0f6c9b05 user: danielk1977 tags: trunk
2004-05-16
22:55
Fix a bug meant real numbers with a negative sign were being stored as strings by default (instead of IEEE floats). (CVS 1388) check-in: 9321e742 user: danielk1977 tags: trunk
16:24
Fix a bug in the BTree balancing routine. (CVS 1387) check-in: 6c73544b user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to src/expr.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.119 2004/05/16 11:57:28 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

static char exprAffinity(Expr *pExpr){
  if( pExpr->op==TK_AS ){
    return exprAffinity(pExpr->pLeft);
................................................................................
      if( pExpr->pLeft->op==TK_FLOAT || pExpr->pLeft->op==TK_INTEGER ){
        Token *p = &pExpr->pLeft->token;
        char *z = sqliteMalloc( p->n + 2 );
        sprintf(z, "-%.*s", p->n, p->z);
        if( pExpr->pLeft->op==TK_INTEGER && sqlite3FitsIn32Bits(z) ){
          sqlite3VdbeAddOp(v, OP_Integer, atoi(z), 0);
        }else{
          sqlite3VdbeAddOp(v, OP_String, 0, 0);
        }
        sqlite3VdbeChangeP3(v, -1, z, p->n+1);
        sqliteFree(z);
        break;
      }
      /* Fall through into TK_NOT */
    }







|







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.120 2004/05/16 22:55:28 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

static char exprAffinity(Expr *pExpr){
  if( pExpr->op==TK_AS ){
    return exprAffinity(pExpr->pLeft);
................................................................................
      if( pExpr->pLeft->op==TK_FLOAT || pExpr->pLeft->op==TK_INTEGER ){
        Token *p = &pExpr->pLeft->token;
        char *z = sqliteMalloc( p->n + 2 );
        sprintf(z, "-%.*s", p->n, p->z);
        if( pExpr->pLeft->op==TK_INTEGER && sqlite3FitsIn32Bits(z) ){
          sqlite3VdbeAddOp(v, OP_Integer, atoi(z), 0);
        }else{
          sqlite3VdbeAddOp(v, OP_Real, 0, 0);
        }
        sqlite3VdbeChangeP3(v, -1, z, p->n+1);
        sqliteFree(z);
        break;
      }
      /* Fall through into TK_NOT */
    }

Changes to test/index.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
#    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 CREATE INDEX statement.
#
# $Id: index.test,v 1.25 2004/05/14 11:00:53 danielk1977 Exp $

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

# Create a basic index and verify it is added to sqlite_master
#
do_test index-1.1 {
................................................................................
# is true in indices.
#
# Updated for sqlite v3: SQLite will now store these values as numbers
# (because the affinity of column a is NUMERIC) so the quirky
# representations are not retained. i.e. '+1.0' becomes '1'.
do_test index-12.1 {
  execsql {
    CREATE TABLE t4(a,b);
    INSERT INTO t4 VALUES('0.0',1);
    INSERT INTO t4 VALUES('0.00',2);
    INSERT INTO t4 VALUES('abc',3);
    INSERT INTO t4 VALUES('-1.0',4);
    INSERT INTO t4 VALUES('+1.0',5);
    INSERT INTO t4 VALUES('0',6);
    INSERT INTO t4 VALUES('00000',7);







|







 







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
#    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 CREATE INDEX statement.
#
# $Id: index.test,v 1.26 2004/05/16 22:55:28 danielk1977 Exp $

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

# Create a basic index and verify it is added to sqlite_master
#
do_test index-1.1 {
................................................................................
# is true in indices.
#
# Updated for sqlite v3: SQLite will now store these values as numbers
# (because the affinity of column a is NUMERIC) so the quirky
# representations are not retained. i.e. '+1.0' becomes '1'.
do_test index-12.1 {
  execsql {
    CREATE TABLE t4(a NUM,b);
    INSERT INTO t4 VALUES('0.0',1);
    INSERT INTO t4 VALUES('0.00',2);
    INSERT INTO t4 VALUES('abc',3);
    INSERT INTO t4 VALUES('-1.0',4);
    INSERT INTO t4 VALUES('+1.0',5);
    INSERT INTO t4 VALUES('0',6);
    INSERT INTO t4 VALUES('00000',7);

Changes to test/types.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
51
52
53
54
55
56
57


58
59
60
61
62
63
64
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. Specfically
# it tests that the different storage classes (integer, real, text etc.)
# all work correctly.
#
# $Id: types.test,v 1.2 2004/05/16 11:15:42 danielk1977 Exp $

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

# Tests in this file are organized roughly as follows:
#
# types-1.*.*: Test that values are stored using the expected storage
................................................................................
# four value are the storage classes that would be used if the
# literal were inserted into a column with affinity INTEGER, NUMERIC, TEXT
# or NONE, respectively.
set values [list \
  [list 5.0   INTEGER REAL    TEXT REAL] \
  [list 5     INTEGER INTEGER TEXT INTEGER] \
  [list '5.0' INTEGER REAL    TEXT TEXT] \


  [list '5'   INTEGER INTEGER TEXT TEXT] \
  [list 'abc' TEXT    TEXT    TEXT TEXT] \
  [list NULL  NULL    NULL    NULL NULL] \
]

# This code tests that the storage classes specified above (in the $values
# table) are correctly assigned when values are inserted using a statement







|







 







>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. Specfically
# it tests that the different storage classes (integer, real, text etc.)
# all work correctly.
#
# $Id: types.test,v 1.3 2004/05/16 22:55:28 danielk1977 Exp $

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

# Tests in this file are organized roughly as follows:
#
# types-1.*.*: Test that values are stored using the expected storage
................................................................................
# four value are the storage classes that would be used if the
# literal were inserted into a column with affinity INTEGER, NUMERIC, TEXT
# or NONE, respectively.
set values [list \
  [list 5.0   INTEGER REAL    TEXT REAL] \
  [list 5     INTEGER INTEGER TEXT INTEGER] \
  [list '5.0' INTEGER REAL    TEXT TEXT] \
  [list '-5.0' INTEGER REAL    TEXT TEXT] \
  [list '-5.0' INTEGER REAL    TEXT TEXT] \
  [list '5'   INTEGER INTEGER TEXT TEXT] \
  [list 'abc' TEXT    TEXT    TEXT TEXT] \
  [list NULL  NULL    NULL    NULL NULL] \
]

# This code tests that the storage classes specified above (in the $values
# table) are correctly assigned when values are inserted using a statement