/ Check-in [e0d6f61c]
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:Omit the SQLITE_AFF_INTEGER type affinity. All numeric values are now of type real, though an integer representation is still sometimes used internally for efficiency. (CVS 2753)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e0d6f61c7de2c03b8fd17ef37cf1a0add36ee618
User & Date: drh 2005-11-01 15:48:24
Context
2005-11-03
00:41
First cut at supporting CHECK constraints. Everything appears to work, but much more testing is needed as well as documentation. (CVS 2754) check-in: 2313d912 user: drh tags: trunk
2005-11-01
15:48
Omit the SQLITE_AFF_INTEGER type affinity. All numeric values are now of type real, though an integer representation is still sometimes used internally for efficiency. (CVS 2753) check-in: e0d6f61c user: drh tags: trunk
2005-10-29
15:48
Fix the shift operators so that they work with 64-bit quantities. (CVS 2752) check-in: 0d3357b5 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/analyze.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code associated with the ANALYZE command.
    13     13   **
    14         -** @(#) $Id: analyze.c,v 1.9 2005/09/20 17:42:23 drh Exp $
           14  +** @(#) $Id: analyze.c,v 1.10 2005/11/01 15:48:24 drh Exp $
    15     15   */
    16     16   #ifndef SQLITE_OMIT_ANALYZE
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** This routine generates code that opens the sqlite_stat1 table on cursor
    21     21   ** iStatCur.
................................................................................
   184    184       for(i=0; i<nCol; i++){
   185    185         sqlite3VdbeAddOp(v, OP_MemLoad, iMem, 0);
   186    186         sqlite3VdbeAddOp(v, OP_MemLoad, iMem+i+1, 0);
   187    187         sqlite3VdbeAddOp(v, OP_Add, 0, 0);
   188    188         sqlite3VdbeAddOp(v, OP_AddImm, -1, 0);
   189    189         sqlite3VdbeAddOp(v, OP_MemLoad, iMem+i+1, 0);
   190    190         sqlite3VdbeAddOp(v, OP_Divide, 0, 0);
          191  +      sqlite3VdbeAddOp(v, OP_ToInt, 0, 0);
   191    192         if( i==nCol-1 ){
   192    193           sqlite3VdbeAddOp(v, OP_Concat, nCol*2-1, 0);
   193    194         }else{
   194    195           sqlite3VdbeAddOp(v, OP_Dup, 1, 0);
   195    196         }
   196    197       }
   197    198       sqlite3VdbeOp3(v, OP_MakeRecord, 3, 0, "ttt", 0);

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.351 2005/09/20 17:42:23 drh Exp $
           25  +** $Id: build.c,v 1.352 2005/11/01 15:48:24 drh Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   #include <ctype.h>
    29     29   
    30     30   /*
    31     31   ** This routine is called when a new SQL statement is beginning to
    32     32   ** be parsed.  Initialize the pParse structure as needed.
................................................................................
   878    878   ** associated affinity type.
   879    879   **
   880    880   ** This routine does a case-independent search of zType for the 
   881    881   ** substrings in the following table. If one of the substrings is
   882    882   ** found, the corresponding affinity is returned. If zType contains
   883    883   ** more than one of the substrings, entries toward the top of 
   884    884   ** the table take priority. For example, if zType is 'BLOBINT', 
   885         -** SQLITE_AFF_INTEGER is returned.
          885  +** SQLITE_AFF_NUMERIC is returned.
   886    886   **
   887    887   ** Substring     | Affinity
   888    888   ** --------------------------------
   889    889   ** 'INT'         | SQLITE_AFF_INTEGER
   890    890   ** 'CHAR'        | SQLITE_AFF_TEXT
   891    891   ** 'CLOB'        | SQLITE_AFF_TEXT
   892    892   ** 'TEXT'        | SQLITE_AFF_TEXT
   893    893   ** 'BLOB'        | SQLITE_AFF_NONE
   894    894   **
   895    895   ** If none of the substrings in the above table are found,
   896    896   ** SQLITE_AFF_NUMERIC is returned.
          897  +**
          898  +** The SQLITE_AFF_INTEGER type is only returned if useIntType is true.
          899  +** If useIntType is false, then SQLITE_AFF_INTEGER is reported back
          900  +** as SQLITE_AFF_NUMERIC
   897    901   */
   898         -char sqlite3AffinityType(const Token *pType){
          902  +char sqlite3AffinityType(const Token *pType, int useIntType){
   899    903     u32 h = 0;
   900    904     char aff = SQLITE_AFF_NUMERIC;
   901    905     const unsigned char *zIn = pType->z;
   902    906     const unsigned char *zEnd = &pType->z[pType->n];
   903    907   
   904    908     while( zIn!=zEnd ){
   905    909       h = (h<<8) + sqlite3UpperToLower[*zIn];
................................................................................
   910    914         aff = SQLITE_AFF_TEXT;
   911    915       }else if( h==(('t'<<24)+('e'<<16)+('x'<<8)+'t') ){       /* TEXT */
   912    916         aff = SQLITE_AFF_TEXT;
   913    917       }else if( h==(('b'<<24)+('l'<<16)+('o'<<8)+'b')          /* BLOB */
   914    918           && aff==SQLITE_AFF_NUMERIC ){
   915    919         aff = SQLITE_AFF_NONE;
   916    920       }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){    /* INT */
   917         -      aff = SQLITE_AFF_INTEGER; 
          921  +      aff = useIntType ? SQLITE_AFF_INTEGER : SQLITE_AFF_NUMERIC; 
   918    922         break;
   919    923       }
   920    924     }
   921    925   
   922    926     return aff;
   923    927   }
   924    928   
................................................................................
   938    942   
   939    943     if( (p = pParse->pNewTable)==0 ) return;
   940    944     i = p->nCol-1;
   941    945     if( i<0 ) return;
   942    946     pCol = &p->aCol[i];
   943    947     sqliteFree(pCol->zType);
   944    948     pCol->zType = sqlite3NameFromToken(pType);
   945         -  pCol->affinity = sqlite3AffinityType(pType);
          949  +  pCol->affinity = sqlite3AffinityType(pType, 0);
   946    950   }
   947    951   
   948    952   /*
   949    953   ** The expression is the default value for the most recently added column
   950    954   ** of the table currently under construction.
   951    955   **
   952    956   ** Default value expressions must be constant.  Raise an exception if this

Changes to src/expr.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.231 2005/10/06 16:53:15 drh Exp $
           15  +** $Id: expr.c,v 1.232 2005/11/01 15:48:24 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Return the 'affinity' of the expression pExpr if any.
    22     22   **
................................................................................
    39     39       return sqlite3ExprAffinity(pExpr->pLeft);
    40     40     }
    41     41     if( op==TK_SELECT ){
    42     42       return sqlite3ExprAffinity(pExpr->pSelect->pEList->a[0].pExpr);
    43     43     }
    44     44   #ifndef SQLITE_OMIT_CAST
    45     45     if( op==TK_CAST ){
    46         -    return sqlite3AffinityType(&pExpr->token);
           46  +    return sqlite3AffinityType(&pExpr->token, 0);
    47     47     }
    48     48   #endif
    49     49     return pExpr->affinity;
    50     50   }
    51     51   
    52     52   /*
    53     53   ** Return the default collation sequence for the expression pExpr. If
................................................................................
    71     71   ** pExpr is an operand of a comparison operator.  aff2 is the
    72     72   ** type affinity of the other operand.  This routine returns the
    73     73   ** type affinity that should be used for the comparison operator.
    74     74   */
    75     75   char sqlite3CompareAffinity(Expr *pExpr, char aff2){
    76     76     char aff1 = sqlite3ExprAffinity(pExpr);
    77     77     if( aff1 && aff2 ){
    78         -    /* Both sides of the comparison are columns. If one has numeric or
    79         -    ** integer affinity, use that. Otherwise use no affinity.
           78  +    /* Both sides of the comparison are columns. If one has numeric
           79  +    ** affinity, use that. Otherwise use no affinity.
    80     80       */
    81         -    if( aff1==SQLITE_AFF_INTEGER || aff2==SQLITE_AFF_INTEGER ){
    82         -      return SQLITE_AFF_INTEGER;
    83         -    }else if( aff1==SQLITE_AFF_NUMERIC || aff2==SQLITE_AFF_NUMERIC ){
           81  +    if( aff1==SQLITE_AFF_NUMERIC || aff2==SQLITE_AFF_NUMERIC ){
    84     82         return SQLITE_AFF_NUMERIC;
    85     83       }else{
    86     84         return SQLITE_AFF_NONE;
    87     85       }
    88     86     }else if( !aff1 && !aff2 ){
    89     87       /* Neither side of the comparison is a column.  Compare the
    90     88       ** results directly.
    91     89       */
    92         -    /* return SQLITE_AFF_NUMERIC;  // Ticket #805 */
    93     90       return SQLITE_AFF_NONE;
    94     91     }else{
    95     92       /* One side is a column, the other is not. Use the columns affinity. */
    96     93       assert( aff1==0 || aff2==0 );
    97     94       return (aff1 + aff2);
    98     95     }
    99     96   }
................................................................................
   125    122   ** pExpr is a comparison expression, eg. '=', '<', IN(...) etc.
   126    123   ** idx_affinity is the affinity of an indexed column. Return true
   127    124   ** if the index with affinity idx_affinity may be used to implement
   128    125   ** the comparison in pExpr.
   129    126   */
   130    127   int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){
   131    128     char aff = comparisonAffinity(pExpr);
   132         -  return 
   133         -    (aff==SQLITE_AFF_NONE) ||
   134         -    (aff==SQLITE_AFF_NUMERIC && idx_affinity==SQLITE_AFF_INTEGER) ||
   135         -    (aff==SQLITE_AFF_INTEGER && idx_affinity==SQLITE_AFF_NUMERIC) ||
   136         -    (aff==idx_affinity);
          129  +  return (aff==SQLITE_AFF_NONE) || (aff==idx_affinity);
   137    130   }
   138    131   
   139    132   /*
   140    133   ** Return the P1 value that should be used for a binary comparison
   141    134   ** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2.
   142    135   ** If jumpIfNull is true, then set the low byte of the returned
   143    136   ** P1 value to tell the opcode to jump if either expression
................................................................................
   940    933   
   941    934       /*
   942    935       ** Perhaps the name is a reference to the ROWID
   943    936       */
   944    937       if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){
   945    938         cnt = 1;
   946    939         pExpr->iColumn = -1;
   947         -      pExpr->affinity = SQLITE_AFF_INTEGER;
          940  +      pExpr->affinity = SQLITE_AFF_NUMERIC;
   948    941       }
   949    942   
   950    943       /*
   951    944       ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
   952    945       ** might refer to an result-set alias.  This happens, for example, when
   953    946       ** we are resolving names in the WHERE clause of the following command:
   954    947       **
................................................................................
  1520   1513         break;
  1521   1514       }
  1522   1515   #ifndef SQLITE_OMIT_CAST
  1523   1516       case TK_CAST: {
  1524   1517         /* Expressions of the form:   CAST(pLeft AS token) */
  1525   1518         int aff, op;
  1526   1519         sqlite3ExprCode(pParse, pExpr->pLeft);
  1527         -      aff = sqlite3AffinityType(&pExpr->token);
         1520  +      aff = sqlite3AffinityType(&pExpr->token, 1);
  1528   1521         switch( aff ){
  1529   1522           case SQLITE_AFF_INTEGER:   op = OP_ToInt;      break;
  1530   1523           case SQLITE_AFF_NUMERIC:   op = OP_ToNumeric;  break;
  1531   1524           case SQLITE_AFF_TEXT:      op = OP_ToText;     break;
  1532   1525           case SQLITE_AFF_NONE:      op = OP_ToBlob;     break;
  1533   1526         }
  1534   1527         sqlite3VdbeAddOp(v, op, 0, 0);

Changes to src/insert.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle INSERT statements in SQLite.
    14     14   **
    15         -** $Id: insert.c,v 1.143 2005/09/20 17:42:23 drh Exp $
           15  +** $Id: insert.c,v 1.144 2005/11/01 15:48:24 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Set P3 of the most recently inserted opcode to a column affinity
    21     21   ** string for index pIdx. A column affinity string has one character
    22     22   ** for each column in the table, according to the affinity of the column:
    23     23   **
    24     24   **  Character      Column affinity
    25     25   **  ------------------------------
    26     26   **  'n'            NUMERIC
    27         -**  'i'            INTEGER
    28     27   **  't'            TEXT
    29     28   **  'o'            NONE
    30     29   */
    31     30   void sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){
    32     31     if( !pIdx->zColAff ){
    33     32       /* The first time a column affinity string for a particular index is
    34     33       ** required, it is allocated and populated here. It is then stored as
................................................................................
    58     57   ** string for table pTab. A column affinity string has one character
    59     58   ** for each column indexed by the index, according to the affinity of the
    60     59   ** column:
    61     60   **
    62     61   **  Character      Column affinity
    63     62   **  ------------------------------
    64     63   **  'n'            NUMERIC
    65         -**  'i'            INTEGER
    66     64   **  't'            TEXT
    67     65   **  'o'            NONE
    68     66   */
    69     67   void sqlite3TableAffinityStr(Vdbe *v, Table *pTab){
    70     68     /* The first time a column affinity string for a particular table
    71     69     ** is required, it is allocated and populated here. It is then 
    72     70     ** stored as a member of the Table structure for subsequent use.

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.423 2005/10/13 02:09:50 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.424 2005/11/01 15:48:24 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** Many people are failing to set -DNDEBUG=1 when compiling SQLite.
    21     21   ** Setting NDEBUG makes the code smaller and run faster.  So the following
................................................................................
   581    581   */
   582    582   #define SQLITE_SO_ASC       0  /* Sort in ascending order */
   583    583   #define SQLITE_SO_DESC      1  /* Sort in ascending order */
   584    584   
   585    585   /*
   586    586   ** Column affinity types.
   587    587   */
   588         -#define SQLITE_AFF_INTEGER  'i'
   589    588   #define SQLITE_AFF_NUMERIC  'n'
          589  +#define SQLITE_AFF_INTEGER  'i'  /* Used for CAST operators only */
   590    590   #define SQLITE_AFF_TEXT     't'
   591    591   #define SQLITE_AFF_NONE     'o'
   592    592   
   593    593   
   594    594   /*
   595    595   ** Each SQL table is represented in memory by an instance of the
   596    596   ** following structure.
................................................................................
  1642   1642   void sqlite3CodeSubselect(Parse *, Expr *);
  1643   1643   int sqlite3SelectResolve(Parse *, Select *, NameContext *);
  1644   1644   void sqlite3ColumnDefault(Vdbe *, Table *, int);
  1645   1645   void sqlite3AlterFinishAddColumn(Parse *, Token *);
  1646   1646   void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
  1647   1647   const char *sqlite3TestErrorName(int);
  1648   1648   CollSeq *sqlite3GetCollSeq(sqlite3*, CollSeq *, const char *, int);
  1649         -char sqlite3AffinityType(const Token*);
         1649  +char sqlite3AffinityType(const Token*, int);
  1650   1650   void sqlite3Analyze(Parse*, Token*, Token*);
  1651   1651   int sqlite3InvokeBusyHandler(BusyHandler*);
  1652   1652   int sqlite3FindDb(sqlite3*, Token*);
  1653   1653   void sqlite3AnalysisLoad(sqlite3*,int iDB);
  1654   1654   void sqlite3DefaultRowEst(Index*);
  1655   1655   void sqlite3RegisterLikeFunctions(sqlite3*, int);
  1656   1656   int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
  1657   1657   
  1658   1658   #ifdef SQLITE_SSE
  1659   1659   #include "sseInt.h"
  1660   1660   #endif
  1661   1661   
  1662   1662   #endif

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.494 2005/10/29 15:48:31 drh Exp $
           46  +** $Id: vdbe.c,v 1.495 2005/11/01 15:48:24 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
   190    190   /*
   191    191   ** Apply any conversion required by the supplied column affinity to
   192    192   ** memory cell pRec. affinity may be one of:
   193    193   **
   194    194   ** SQLITE_AFF_NUMERIC
   195    195   ** SQLITE_AFF_TEXT
   196    196   ** SQLITE_AFF_NONE
   197         -** SQLITE_AFF_INTEGER
   198         -**
   199    197   */
   200    198   static void applyAffinity(Mem *pRec, char affinity, u8 enc){
   201    199     if( affinity==SQLITE_AFF_NONE ){
   202    200       /* do nothing */
   203    201     }else if( affinity==SQLITE_AFF_TEXT ){
   204    202       /* Only attempt the conversion to TEXT if there is an integer or real
   205    203       ** representation (blob and NULL do not get converted) but no string
................................................................................
   220    218         if( pRec->flags&MEM_Str && sqlite3IsNumber(pRec->z, &realnum, enc) ){
   221    219           if( realnum ){
   222    220             Realify(pRec);
   223    221           }else{
   224    222             Integerify(pRec);
   225    223           }
   226    224         }
   227         -    }
   228         -
   229         -    if( affinity==SQLITE_AFF_INTEGER ){
   230         -      /* For INTEGER affinity, try to convert a real value to an int */
   231         -      if( (pRec->flags&MEM_Real) && !(pRec->flags&MEM_Int) ){
   232         -        pRec->i = pRec->r;
   233         -        if( ((double)pRec->i)==pRec->r ){
   234         -          pRec->flags |= MEM_Int;
   235         -        }
   236         -      }
          225  +    }else if( pRec->flags & MEM_Real ){
          226  +      sqlite3VdbeIntegerAffinity(pRec);
   237    227       }
   238    228     }
   239    229   }
   240    230   
   241    231   /*
   242    232   ** Exported version of applyAffinity(). This one works on sqlite3_value*, 
   243    233   ** not the internal Mem* type.
................................................................................
   641    631     pTos->flags = MEM_Str|MEM_Static|MEM_Term;
   642    632     pTos->z = pOp->p3;
   643    633     pTos->n = strlen(pTos->z);
   644    634     pTos->enc = SQLITE_UTF8;
   645    635     pTos->r = sqlite3VdbeRealValue(pTos);
   646    636     pTos->flags |= MEM_Real;
   647    637     sqlite3VdbeChangeEncoding(pTos, db->enc);
          638  +  sqlite3VdbeIntegerAffinity(pTos);
   648    639     break;
   649    640   }
   650    641   
   651    642   /* Opcode: String8 * * P3
   652    643   **
   653    644   ** P3 points to a nul terminated UTF-8 string. This opcode is transformed
   654    645   ** into an OP_String before it is executed for the first time.
................................................................................
  1026   1017       b = pNos->i;
  1027   1018       switch( pOp->opcode ){
  1028   1019         case OP_Add:         b += a;       break;
  1029   1020         case OP_Subtract:    b -= a;       break;
  1030   1021         case OP_Multiply:    b *= a;       break;
  1031   1022         case OP_Divide: {
  1032   1023           if( a==0 ) goto divide_by_zero;
         1024  +        if( b%a!=0 ) goto floating_point_divide;
  1033   1025           b /= a;
  1034   1026           break;
  1035   1027         }
  1036   1028         default: {
  1037   1029           if( a==0 ) goto divide_by_zero;
  1038   1030           b %= a;
  1039   1031           break;
................................................................................
  1042   1034       Release(pTos);
  1043   1035       pTos--;
  1044   1036       Release(pTos);
  1045   1037       pTos->i = b;
  1046   1038       pTos->flags = MEM_Int;
  1047   1039     }else{
  1048   1040       double a, b;
         1041  +    floating_point_divide:
  1049   1042       a = sqlite3VdbeRealValue(pTos);
  1050   1043       b = sqlite3VdbeRealValue(pNos);
  1051   1044       switch( pOp->opcode ){
  1052   1045         case OP_Add:         b += a;       break;
  1053   1046         case OP_Subtract:    b -= a;       break;
  1054   1047         case OP_Multiply:    b *= a;       break;
  1055   1048         case OP_Divide: {
................................................................................
  1066   1059         }
  1067   1060       }
  1068   1061       Release(pTos);
  1069   1062       pTos--;
  1070   1063       Release(pTos);
  1071   1064       pTos->r = b;
  1072   1065       pTos->flags = MEM_Real;
         1066  +    sqlite3VdbeIntegerAffinity(pTos);
  1073   1067     }
  1074   1068     break;
  1075   1069   
  1076   1070   divide_by_zero:
  1077   1071     Release(pTos);
  1078   1072     pTos--;
  1079   1073     Release(pTos);
................................................................................
  1263   1257   ** convert it into the least integer that is greater than or equal to its
  1264   1258   ** current value if P1==0, or to the least integer that is strictly
  1265   1259   ** greater than its current value if P1==1.
  1266   1260   */
  1267   1261   case OP_ForceInt: {            /* no-push */
  1268   1262     i64 v;
  1269   1263     assert( pTos>=p->aStack );
  1270         -  applyAffinity(pTos, SQLITE_AFF_INTEGER, db->enc);
         1264  +  applyAffinity(pTos, SQLITE_AFF_NUMERIC, db->enc);
  1271   1265     if( (pTos->flags & (MEM_Int|MEM_Real))==0 ){
  1272   1266       Release(pTos);
  1273   1267       pTos--;
  1274   1268       pc = pOp->p2 - 1;
  1275   1269       break;
  1276   1270     }
  1277   1271     if( pTos->flags & MEM_Int ){
................................................................................
  1297   1291   **
  1298   1292   ** If the top of the stack is not an integer and P2 is not zero and
  1299   1293   ** P1 is 1, then the stack is popped.  In all other cases, the depth
  1300   1294   ** of the stack is unchanged.
  1301   1295   */
  1302   1296   case OP_MustBeInt: {            /* no-push */
  1303   1297     assert( pTos>=p->aStack );
  1304         -  applyAffinity(pTos, SQLITE_AFF_INTEGER, db->enc);
         1298  +  applyAffinity(pTos, SQLITE_AFF_NUMERIC, db->enc);
  1305   1299     if( (pTos->flags & MEM_Int)==0 ){
  1306   1300       if( pOp->p2==0 ){
  1307   1301         rc = SQLITE_MISMATCH;
  1308   1302         goto abort_due_to_error;
  1309   1303       }else{
  1310   1304         if( pOp->p1 ) popStack(&pTos, 1);
  1311   1305         pc = pOp->p2 - 1;
................................................................................
  1313   1307     }else{
  1314   1308       Release(pTos);
  1315   1309       pTos->flags = MEM_Int;
  1316   1310     }
  1317   1311     break;
  1318   1312   }
  1319   1313   
  1320         -#ifndef SQLITE_OMIT_CAST
  1321   1314   /* Opcode: ToInt * * *
  1322   1315   **
  1323   1316   ** Force the value on the top of the stack to be an integer.  If
  1324   1317   ** The value is currently a real number, drop its fractional part.
  1325   1318   ** If the value is text or blob, try to convert it to an integer using the
  1326   1319   ** equivalent of atoi() and store 0 if no such conversion is possible.
  1327   1320   **
................................................................................
  1328   1321   ** A NULL value is not changed by this routine.  It remains NULL.
  1329   1322   */
  1330   1323   case OP_ToInt: {                  /* no-push */
  1331   1324     assert( pTos>=p->aStack );
  1332   1325     if( pTos->flags & MEM_Null ) break;
  1333   1326     assert( MEM_Str==(MEM_Blob>>3) );
  1334   1327     pTos->flags |= (pTos->flags&MEM_Blob)>>3;
  1335         -  applyAffinity(pTos, SQLITE_AFF_INTEGER, db->enc);
         1328  +  applyAffinity(pTos, SQLITE_AFF_NUMERIC, db->enc);
  1336   1329     sqlite3VdbeMemIntegerify(pTos);
  1337   1330     break;
  1338   1331   }
  1339   1332   
         1333  +#ifndef SQLITE_OMIT_CAST
  1340   1334   /* Opcode: ToNumeric * * *
  1341   1335   **
  1342   1336   ** Force the value on the top of the stack to be numeric (either an
  1343   1337   ** integer or a floating-point number.
  1344   1338   ** If the value is text or blob, try to convert it to an using the
  1345   1339   ** equivalent of atoi() or atof() and store 0 if no such conversion 
  1346   1340   ** is possible.
................................................................................
  1418   1412   ** both operands are converted to integers prior to comparison.
  1419   1413   ** NULL operands are converted to zero and non-NULL operands are
  1420   1414   ** converted to 1.  Thus, for example, with 0x200 set,  NULL==NULL is true
  1421   1415   ** whereas it would normally be NULL.  Similarly,  NULL==123 is false when
  1422   1416   ** 0x200 is set but is NULL when the 0x200 bit of P1 is clear.
  1423   1417   **
  1424   1418   ** The least significant byte of P1 (mask 0xff) must be an affinity character -
  1425         -** 'n', 't', 'i' or 'o' - or 0x00. An attempt is made to coerce both values
         1419  +** 'n', 't', or 'o' - or 0x00. An attempt is made to coerce both values
  1426   1420   ** according to the affinity before the comparison is made. If the byte is
  1427   1421   ** 0x00, then numeric affinity is used.
  1428   1422   **
  1429   1423   ** Once any conversions have taken place, and neither value is NULL, 
  1430   1424   ** the values are compared. If both values are blobs, or both are text,
  1431   1425   ** then memcmp() is used to determine the results of the comparison. If
  1432   1426   ** both values are numeric, then a numeric comparison is used. If the
................................................................................
  1610   1604   ** with its absolute value. If the top of the stack is NULL
  1611   1605   ** its value is unchanged.
  1612   1606   */
  1613   1607   case OP_Negative:              /* same as TK_UMINUS, no-push */
  1614   1608   case OP_AbsValue: {
  1615   1609     assert( pTos>=p->aStack );
  1616   1610     if( pTos->flags & MEM_Real ){
         1611  +    neg_abs_real_case:
  1617   1612       Release(pTos);
  1618   1613       if( pOp->opcode==OP_Negative || pTos->r<0.0 ){
  1619   1614         pTos->r = -pTos->r;
  1620   1615       }
  1621   1616       pTos->flags = MEM_Real;
         1617  +    sqlite3VdbeIntegerAffinity(pTos);
  1622   1618     }else if( pTos->flags & MEM_Int ){
  1623   1619       Release(pTos);
  1624   1620       if( pOp->opcode==OP_Negative || pTos->i<0 ){
  1625   1621         pTos->i = -pTos->i;
  1626   1622       }
  1627   1623       pTos->flags = MEM_Int;
  1628   1624     }else if( pTos->flags & MEM_Null ){
  1629   1625       /* Do nothing */
  1630   1626     }else{
  1631   1627       Realify(pTos);
  1632         -    if( pOp->opcode==OP_Negative || pTos->r<0.0 ){
  1633         -      pTos->r = -pTos->r;
  1634         -    }
  1635         -    pTos->flags = MEM_Real;
         1628  +    goto neg_abs_real_case;
  1636   1629     }
  1637   1630     break;
  1638   1631   }
  1639   1632   
  1640   1633   /* Opcode: Not * * *
  1641   1634   **
  1642   1635   ** Interpret the top of the stack as a boolean value.  Replace it
................................................................................
  2079   2072   ** P3 may be a string that is P1 characters long.  The nth character of the
  2080   2073   ** string indicates the column affinity that should be used for the nth
  2081   2074   ** field of the index key (i.e. the first character of P3 corresponds to the
  2082   2075   ** lowest element on the stack).
  2083   2076   **
  2084   2077   ** The mapping from character to affinity is as follows:
  2085   2078   **    'n' = NUMERIC.
  2086         -**    'i' = INTEGER.
  2087   2079   **    't' = TEXT.
  2088   2080   **    'o' = NONE.
  2089   2081   **
  2090   2082   ** If P3 is NULL then all index fields have the affinity NONE.
  2091   2083   **
  2092   2084   ** See also OP_MakeIdxRec
  2093   2085   */

Changes to src/vdbeInt.h.

   356    356   void sqlite3VdbeMemSetNull(Mem*);
   357    357   int sqlite3VdbeMemMakeWriteable(Mem*);
   358    358   int sqlite3VdbeMemDynamicify(Mem*);
   359    359   int sqlite3VdbeMemStringify(Mem*, int);
   360    360   i64 sqlite3VdbeIntValue(Mem*);
   361    361   int sqlite3VdbeMemIntegerify(Mem*);
   362    362   double sqlite3VdbeRealValue(Mem*);
          363  +void sqlite3VdbeIntegerAffinity(Mem*);
   363    364   int sqlite3VdbeMemRealify(Mem*);
   364    365   int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);
   365    366   void sqlite3VdbeMemRelease(Mem *p);
   366    367   void sqlite3VdbeMemFinalize(Mem*, FuncDef*);
   367    368   #ifndef NDEBUG
   368    369   void sqlite3VdbeMemSanity(Mem*, u8);
   369    370   int sqlite3VdbeOpcodeNoPush(u8);

Changes to src/vdbemem.c.

   169    169   
   170    170     /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8
   171    171     ** string representation of the value. Then, if the required encoding
   172    172     ** is UTF-16le or UTF-16be do a translation.
   173    173     ** 
   174    174     ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16.
   175    175     */
   176         -  if( fg & MEM_Real ){
   177         -    sqlite3_snprintf(NBFS, z, "%!.15g", pMem->r);
          176  +  if( fg & MEM_Int ){
          177  +    sqlite3_snprintf(NBFS, z, "%lld", pMem->i);
   178    178     }else{
   179         -    assert( fg & MEM_Int );
   180         -    sqlite3_snprintf(NBFS, z, "%lld", pMem->i);
          179  +    assert( fg & MEM_Real );
          180  +    sqlite3_snprintf(NBFS, z, "%!.15g", pMem->r);
   181    181     }
   182    182     pMem->n = strlen(z);
   183    183     pMem->z = z;
   184    184     pMem->enc = SQLITE_UTF8;
   185    185     pMem->flags |= MEM_Str | MEM_Short | MEM_Term;
   186    186     sqlite3VdbeChangeEncoding(pMem, enc);
   187    187     return rc;
................................................................................
   296    296       return val;
   297    297     }else{
   298    298       return 0.0;
   299    299     }
   300    300   }
   301    301   
   302    302   /*
   303         -** Convert pMem so that it is of type MEM_Real.  Invalidate any
   304         -** prior representations.
          303  +** The MEM structure is already a MEM_Real.  Try to also make it a
          304  +** MEM_Int if we can.
          305  +*/
          306  +void sqlite3VdbeIntegerAffinity(Mem *pMem){
          307  +  assert( pMem->flags & MEM_Real );
          308  +  pMem->i = pMem->r;
          309  +  if( ((double)pMem->i)==pMem->r ){
          310  +    pMem->flags |= MEM_Int;
          311  +  }
          312  +}
          313  +
          314  +
          315  +/*
          316  +** Convert pMem so that it is of type MEM_Real and also MEM_Int if
          317  +** possible.  Invalidate any prior representations.
   305    318   */
   306    319   int sqlite3VdbeMemRealify(Mem *pMem){
   307    320     pMem->r = sqlite3VdbeRealValue(pMem);
   308    321     sqlite3VdbeMemRelease(pMem);
   309    322     pMem->flags = MEM_Real;
          323  +  sqlite3VdbeIntegerAffinity(pMem);
   310    324     return SQLITE_OK;
   311    325   }
   312    326   
   313    327   /*
   314    328   ** Delete any previous value and set the value stored in *pMem to NULL.
   315    329   */
   316    330   void sqlite3VdbeMemSetNull(Mem *pMem){

Changes to test/cast.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the CAST operator.
    13     13   #
    14         -# $Id: cast.test,v 1.2 2005/06/25 19:31:48 drh Exp $
           14  +# $Id: cast.test,v 1.3 2005/11/01 15:48:25 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Only run these tests if the build includes the CAST operator
    20     20   ifcapable !cast {
    21     21     finish_test
................................................................................
    34     34     execsql {SELECT CAST(x'616263' AS text)}
    35     35   } abc
    36     36   do_test cast-1.4 {
    37     37     execsql {SELECT typeof(CAST(x'616263' AS text))}
    38     38   } text
    39     39   do_test cast-1.5 {
    40     40     execsql {SELECT CAST(x'616263' AS numeric)}
    41         -} 0.0
           41  +} 0
    42     42   do_test cast-1.6 {
    43     43     execsql {SELECT typeof(CAST(x'616263' AS numeric))}
    44         -} real
           44  +} integer
    45     45   do_test cast-1.7 {
    46     46     execsql {SELECT CAST(x'616263' AS blob)}
    47     47   } abc
    48     48   do_test cast-1.8 {
    49     49     execsql {SELECT typeof(CAST(x'616263' AS blob))}
    50     50   } blob
    51     51   do_test cast-1.9 {
................................................................................
   154    154     execsql {SELECT CAST('123abc' AS text)}
   155    155   } {123abc}
   156    156   do_test cast-1.44 {
   157    157     execsql {SELECT typeof(CAST('123abc' AS text))}
   158    158   } text
   159    159   do_test cast-1.45 {
   160    160     execsql {SELECT CAST('123abc' AS numeric)}
   161         -} 123.0
          161  +} 123
   162    162   do_test cast-1.46 {
   163    163     execsql {SELECT typeof(CAST('123abc' AS numeric))}
   164         -} real
          164  +} integer
   165    165   do_test cast-1.47 {
   166    166     execsql {SELECT CAST('123abc' AS blob)}
   167    167   } {123abc}
   168    168   do_test cast-1.48 {
   169    169     execsql {SELECT typeof(CAST('123abc' AS blob))}
   170    170   } blob
   171    171   do_test cast-1.49 {

Changes to test/collate1.test.

     8      8   #    May you find forgiveness for yourself and forgive others.
     9      9   #    May you share freely, never taking more than you give.
    10     10   #
    11     11   #***********************************************************************
    12     12   # This file implements regression tests for SQLite library.  The
    13     13   # focus of this script is page cache subsystem.
    14     14   #
    15         -# $Id: collate1.test,v 1.3 2004/08/20 18:34:20 drh Exp $
           15  +# $Id: collate1.test,v 1.4 2005/11/01 15:48:25 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   #
    21     21   # Tests are roughly organised as follows:
    22     22   #
................................................................................
   210    210       SELECT c2 FROM collate1t1 ORDER BY 1;
   211    211     }
   212    212   } {{} 1 101 12}
   213    213   do_test collate1-4.3 {
   214    214     execsql {
   215    215       SELECT c2+0 FROM collate1t1 ORDER BY 1;
   216    216     }
   217         -} {{} 1.0 12.0 101.0}
          217  +} {{} 1 12 101}
   218    218   do_test collate1-4.4 {
   219    219     execsql {
   220    220       SELECT c1||'' FROM collate1t1 ORDER BY 1;
   221    221     }
   222    222   } {{} 1 101 12}
   223    223   do_test collate1-4.5 {
   224    224     execsql {
   225    225       DROP TABLE collate1t1;
   226    226     }
   227    227   } {}
   228    228   
   229    229   finish_test

Changes to test/expr.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing expressions.
    13     13   #
    14         -# $Id: expr.test,v 1.46 2005/10/29 15:48:32 drh Exp $
           14  +# $Id: expr.test,v 1.47 2005/11/01 15:48:25 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a table to work with.
    20     20   #
    21     21   execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
................................................................................
    25     25       execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;}
    26     26     } $settings $expr] $result
    27     27   }
    28     28   
    29     29   test_expr expr-1.1 {i1=10, i2=20} {i1+i2} 30
    30     30   test_expr expr-1.2 {i1=10, i2=20} {i1-i2} -10
    31     31   test_expr expr-1.3 {i1=10, i2=20} {i1*i2} 200
    32         -# update for sqlite3 v3: Change 0.5 to 0 in expr1.4 due to manifest types.
    33         -test_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0
           32  +test_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0.5
    34     33   test_expr expr-1.5 {i1=10, i2=20} {i2/i1} 2
    35     34   test_expr expr-1.6 {i1=10, i2=20} {i2<i1} 0
    36     35   test_expr expr-1.7 {i1=10, i2=20} {i2<=i1} 0
    37     36   test_expr expr-1.8 {i1=10, i2=20} {i2>i1} 1
    38     37   test_expr expr-1.9 {i1=10, i2=20} {i2>=i1} 1
    39     38   test_expr expr-1.10 {i1=10, i2=20} {i2!=i1} 1
    40     39   test_expr expr-1.11 {i1=10, i2=20} {i2=i1} 0
................................................................................
    44     43   test_expr expr-1.15 {i1=20, i2=20} {i2<=i1} 1
    45     44   test_expr expr-1.16 {i1=20, i2=20} {i2>i1} 0
    46     45   test_expr expr-1.17 {i1=20, i2=20} {i2>=i1} 1
    47     46   test_expr expr-1.18 {i1=20, i2=20} {i2!=i1} 0
    48     47   test_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1
    49     48   test_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0
    50     49   test_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1
    51         -test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7.0}
    52         -test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9.0}
           50  +test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7}
           51  +test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9}
    53     52   test_expr expr-1.24 {i1=1, i2=2} {min(i1,i2,i1+i2,i1-i2)} {-1}
    54     53   test_expr expr-1.25 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
    55     54   test_expr expr-1.26 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
    56     55   test_expr expr-1.27 {i1=1, i2=2} {i1==1 AND i2=2} {1}
    57     56   test_expr expr-1.28 {i1=1, i2=2} {i1=2 AND i2=1} {0}
    58     57   test_expr expr-1.29 {i1=1, i2=2} {i1=1 AND i2=1} {0}
    59     58   test_expr expr-1.30 {i1=1, i2=2} {i1=2 AND i2=2} {0}
................................................................................
   157    156   test_expr expr-2.17 {r1=2.34, r2=2.34} {r2>=r1} 1
   158    157   test_expr expr-2.18 {r1=2.34, r2=2.34} {r2!=r1} 0
   159    158   test_expr expr-2.19 {r1=2.34, r2=2.34} {r2=r1} 1
   160    159   test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0
   161    160   test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1
   162    161   test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11}
   163    162   test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}
   164         -test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3.0
   165         -test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0
          163  +test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3
          164  +test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99
   166    165   
   167    166   test_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1
   168    167   test_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0
   169    168   test_expr expr-3.3 {t1='abc', t2='abc'} {t1<t2} 0
   170    169   test_expr expr-3.4 {t1='abc', t2='xyz'} {t1<=t2} 1
   171    170   test_expr expr-3.5 {t1='xyz', t2='abc'} {t1<=t2} 0
   172    171   test_expr expr-3.6 {t1='abc', t2='abc'} {t1<=t2} 1

Changes to test/func.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing built-in functions.
    13     13   #
    14         -# $Id: func.test,v 1.40 2005/09/08 20:37:44 drh Exp $
           14  +# $Id: func.test,v 1.41 2005/11/01 15:48:25 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a table to work with.
    20     20   #
    21     21   do_test func-0.0 {
................................................................................
   507    507     }
   508    508   } {9902}
   509    509   do_test func-18.2 {
   510    510     execsql {
   511    511       INSERT INTO t5 VALUES(0.0);
   512    512       SELECT sum(x) FROM t5;
   513    513     }
   514         -} {9902.0}
          514  +} {9902}
   515    515   
   516    516   # The sum of nothing is NULL.  But the sum of all NULLs is NULL.
   517    517   #
   518    518   do_test func-18.3 {
   519    519     execsql {
   520    520       DELETE FROM t5;
   521    521       SELECT sum(x) FROM t5;

Changes to test/index.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the CREATE INDEX statement.
    13     13   #
    14         -# $Id: index.test,v 1.37 2005/01/21 03:12:16 danielk1977 Exp $
           14  +# $Id: index.test,v 1.38 2005/11/01 15:48:25 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a basic index and verify it is added to sqlite_master
    20     20   #
    21     21   do_test index-1.1 {
................................................................................
   368    368       INSERT INTO t4 VALUES('abc',3);
   369    369       INSERT INTO t4 VALUES('-1.0',4);
   370    370       INSERT INTO t4 VALUES('+1.0',5);
   371    371       INSERT INTO t4 VALUES('0',6);
   372    372       INSERT INTO t4 VALUES('00000',7);
   373    373       SELECT a FROM t4 ORDER BY b;
   374    374     }
   375         -} {0.0 0.0 abc -1.0 1.0 0 0}
          375  +} {0 0 abc -1 1 0 0}
   376    376   do_test index-12.2 {
   377    377     execsql {
   378    378       SELECT a FROM t4 WHERE a==0 ORDER BY b
   379    379     }
   380         -} {0.0 0.0 0 0}
          380  +} {0 0 0 0}
   381    381   do_test index-12.3 {
   382    382     execsql {
   383    383       SELECT a FROM t4 WHERE a<0.5 ORDER BY b
   384    384     }
   385         -} {0.0 0.0 -1.0 0 0}
          385  +} {0 0 -1 0 0}
   386    386   do_test index-12.4 {
   387    387     execsql {
   388    388       SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
   389    389     }
   390         -} {0.0 0.0 abc 1.0 0 0}
          390  +} {0 0 abc 1 0 0}
   391    391   do_test index-12.5 {
   392    392     execsql {
   393    393       CREATE INDEX t4i1 ON t4(a);
   394    394       SELECT a FROM t4 WHERE a==0 ORDER BY b
   395    395     }
   396         -} {0.0 0.0 0 0}
          396  +} {0 0 0 0}
   397    397   do_test index-12.6 {
   398    398     execsql {
   399    399       SELECT a FROM t4 WHERE a<0.5 ORDER BY b
   400    400     }
   401         -} {0.0 0.0 -1.0 0 0}
          401  +} {0 0 -1 0 0}
   402    402   do_test index-12.7 {
   403    403     execsql {
   404    404       SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
   405    405     }
   406         -} {0.0 0.0 abc 1.0 0 0}
          406  +} {0 0 abc 1 0 0}
   407    407   integrity_check index-12.8
   408    408   
   409    409   # Make sure we cannot drop an automatically created index.
   410    410   #
   411    411   do_test index-13.1 {
   412    412     execsql {
   413    413      CREATE TABLE t5(

Changes to test/main.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is exercising the code in main.c.
    13     13   #
    14         -# $Id: main.test,v 1.22 2005/10/23 11:29:40 drh Exp $
           14  +# $Id: main.test,v 1.23 2005/11/01 15:48:25 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Only do the next group of tests if the sqlite3_complete API is available
    20     20   #
    21     21   ifcapable {complete} {
................................................................................
   298    298       insert into T1 values(-5.1e-2);
   299    299       insert into T1 values(0.5e2);
   300    300       insert into T1 values(0.5E+02);
   301    301       insert into T1 values(5E+02);
   302    302       insert into T1 values(5.0E+03);
   303    303       select x*10 from T1 order by x*5;
   304    304     }
   305         -} {-0.51 -0.5 0.05 0.5 5.0 500.0 500.0 500.0 5000.0 50000.0}
          305  +} {-0.51 -0.5 0.05 0.5 5 500 500 500 5000 50000}
   306    306   do_test main-3.4 {
   307    307     set v [catch {execsql {create bogus}} msg]
   308    308     lappend v $msg
   309    309   } {1 {near "bogus": syntax error}}
   310    310   do_test main-3.5 {
   311    311     set v [catch {execsql {create}} msg]
   312    312     lappend v $msg

Changes to test/misc1.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for miscellanous features that were
    14     14   # left out of other test files.
    15     15   #
    16         -# $Id: misc1.test,v 1.38 2005/09/08 10:37:01 drh Exp $
           16  +# $Id: misc1.test,v 1.39 2005/11/01 15:48:25 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Mimic the SQLite 2 collation type NUMERIC.
    22     22   db collate numeric numeric_collate
    23     23   proc numeric_collate {lhs rhs} {
................................................................................
   312    312   } {101}
   313    313   do_test misc1-10.7 {
   314    314     regsub "x0=0" $::where "x0=100" ::where
   315    315     catchsql "UPDATE manycol SET x1=x1+1 $::where"
   316    316   } {0 {}}
   317    317   do_test misc1-10.8 {
   318    318     execsql {SELECT x1 FROM manycol WHERE x0=100}
   319         -} {102.0}
          319  +} {102}
   320    320   do_test misc1-10.9 {
   321    321     catchsql "UPDATE manycol SET x1=x1+1 $::where AND rowid>0"
   322    322   } {0 {}}
   323    323   do_test misc1-10.10 {
   324    324     execsql {SELECT x1 FROM manycol WHERE x0=100}
   325         -} {103.0}
          325  +} {103}
   326    326   
   327    327   # Make sure the initialization works even if a database is opened while
   328    328   # another process has the database locked.
   329    329   #
   330    330   # Update for v3: The BEGIN doesn't lock the database so the schema is read
   331    331   # and the SELECT returns successfully.
   332    332   do_test misc1-11.1 {
................................................................................
   404    404   #
   405    405   # Update: In v3, it is an error again.
   406    406   #
   407    407   #do_test misc1-12.10 {
   408    408   #  catchsql {
   409    409   #    SELECT * FROM t6 ORDER BY a COLLATE unknown;
   410    410   #  }
   411         -#} {0 {0 0.0 y 0}}
          411  +#} {0 {0 0 y 0}}
   412    412   do_test misc1-12.11 {
   413    413     execsql {
   414    414       CREATE TABLE t8(x TEXT COLLATE numeric, y INTEGER COLLATE text, z);
   415    415       INSERT INTO t8 VALUES(0,0,1);
   416    416       INSERT INTO t8 VALUES(0.0,0,2);
   417    417       INSERT INTO t8 VALUES(0,0.0,3);
   418    418       INSERT INTO t8 VALUES(0.0,0.0,4);
................................................................................
   568    568       END;
   569    569       INSERT INTO TempTable(TestString) VALUES ('1');
   570    570       INSERT INTO TempTable(TestString) VALUES ('2');
   571    571       UPDATE TempTable SET TestString = TestString + 1 WHERE TestID=1 OR TestId=2;
   572    572       COMMIT;
   573    573       SELECT TestString FROM RealTable ORDER BY 1;
   574    574     }
   575         -} {2.0 3.0}
          575  +} {2 3}
   576    576   }
   577    577   
   578    578   finish_test

Changes to test/misc5.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for miscellanous features that were
    14     14   # left out of other test files.
    15     15   #
    16         -# $Id: misc5.test,v 1.5 2005/08/23 11:31:26 drh Exp $
           16  +# $Id: misc5.test,v 1.6 2005/11/01 15:48:25 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Build records using the MakeRecord opcode such that the size of the 
    22     22   # header is at the transition point in the size of a varint.
    23     23   #
................................................................................
   490    490   # Ticket #1371.  Allow floating point numbers of the form .N  or N.
   491    491   #
   492    492   do_test misc5-5.1 {
   493    493     execsql {SELECT .1 }
   494    494   } 0.1
   495    495   do_test misc5-5.2 {
   496    496     execsql {SELECT 2. }
   497         -} 2.0
          497  +} 2
   498    498   do_test misc5-5.3 {
   499    499     execsql {SELECT 3.e0 }
   500         -} 3.0
          500  +} 3
   501    501   do_test misc5-5.4 {
   502    502     execsql {SELECT .4e+1}
   503         -} 4.0
          503  +} 4
   504    504   
   505    505   
   506    506   finish_test

Changes to test/quote.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is the ability to specify table and column names
    13     13   # as quoted strings.
    14     14   #
    15         -# $Id: quote.test,v 1.5 2005/08/13 18:15:43 drh Exp $
           15  +# $Id: quote.test,v 1.6 2005/11/01 15:48:25 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Create a table with a strange name and with strange column names.
    21     21   #
    22     22   do_test quote-1.0 {
................................................................................
    42     42       SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'
    43     43     }
    44     44   } {0 {hello 10}}
    45     45   do_test quote-1.3.1 {
    46     46     catchsql {
    47     47       SELECT '!pqr', '#xyz'+5 FROM '@abc'
    48     48     }
    49         -} {0 {!pqr 5.0}}
           49  +} {0 {!pqr 5}}
    50     50   do_test quote-1.3.2 {
    51     51     catchsql {
    52     52       SELECT "!pqr", "#xyz"+5 FROM '@abc'
    53     53     }
    54     54   } {0 {hello 10}}
    55     55   do_test quote-1.3.3 {
    56     56     catchsql {

Changes to test/select3.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing aggregate functions and the
    13     13   # GROUP BY and HAVING clauses of SELECT statements.
    14     14   #
    15         -# $Id: select3.test,v 1.16 2005/09/08 20:37:44 drh Exp $
           15  +# $Id: select3.test,v 1.17 2005/11/01 15:48:25 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Build some test data
    21     21   #
    22     22   do_test select3-1.0 {
................................................................................
    53     53   #
    54     54   do_test select3-2.1 {
    55     55     execsql {SELECT log, count(*) FROM t1 GROUP BY log ORDER BY log}
    56     56   } {0 1 1 1 2 2 3 4 4 8 5 15}
    57     57   do_test select3-2.2 {
    58     58     execsql {SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log}
    59     59   } {0 1 1 2 2 3 3 5 4 9 5 17}
    60         -do_test select3-2.3 {
           60  +do_test select3-2.3.1 {
    61     61     execsql {SELECT log, avg(n) FROM t1 GROUP BY log ORDER BY log}
    62     62   } {0 1.0 1 2.0 2 3.5 3 6.5 4 12.5 5 24.0}
    63         -do_test select3-2.3 {
           63  +do_test select3-2.3.2 {
    64     64     execsql {SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log}
    65         -} {0 2.0 1 3.0 2 4.5 3 7.5 4 13.5 5 25.0}
           65  +} {0 2 1 3 2 4.5 3 7.5 4 13.5 5 25}
    66     66   do_test select3-2.4 {
    67     67     execsql {SELECT log, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}
    68         -} {0 0.0 1 0.0 2 0.5 3 1.5 4 3.5 5 7.0}
           68  +} {0 0 1 0 2 0.5 3 1.5 4 3.5 5 7}
    69     69   do_test select3-2.5 {
    70     70     execsql {SELECT log*2+1, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}
    71         -} {1 0.0 3 0.0 5 0.5 7 1.5 9 3.5 11 7.0}
           71  +} {1 0 3 0 5 0.5 7 1.5 9 3.5 11 7}
    72     72   do_test select3-2.6 {
    73     73     execsql {
    74     74       SELECT log*2+1 as x, count(*) FROM t1 GROUP BY x ORDER BY x
    75     75     }
    76     76   } {1 1 3 1 5 2 7 4 9 8 11 15}
    77     77   do_test select3-2.7 {
    78     78     execsql {

Changes to test/select6.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing SELECT statements that contain
    13     13   # subqueries in their FROM clause.
    14     14   #
    15         -# $Id: select6.test,v 1.19 2005/09/07 22:48:16 drh Exp $
           15  +# $Id: select6.test,v 1.20 2005/11/01 15:48:25 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Omit this whole file if the library is build without subquery support.
    21     21   ifcapable !subquery {
    22     22     finish_test
................................................................................
   182    182       SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1 WHERE y=4)
   183    183     }
   184    184   } {11.5 4.0 15.5}
   185    185   do_test select6-3.5 {
   186    186     execsql {
   187    187       SELECT x,y,x+y FROM (SELECT avg(a) as 'x', avg(b) as 'y' FROM t2 WHERE a=4)
   188    188     }
   189         -} {4.0 3.0 7.0}
          189  +} {4.0 3.0 7}
   190    190   do_test select6-3.6 {
   191    191     execsql {
   192    192       SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)
   193    193       WHERE a>10
   194    194     }
   195    195   } {10.5 3.7 14.2}
   196    196   do_test select6-3.7 {
................................................................................
   213    213     }
   214    214   } {}
   215    215   do_test select6-3.10 {
   216    216     execsql {
   217    217       SELECT a,b,a+b FROM (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)
   218    218       ORDER BY a
   219    219     }
   220         -} {1.0 1 2.0 2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23.0}
          220  +} {1.0 1 2 2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23}
   221    221   do_test select6-3.11 {
   222    222     execsql {
   223    223       SELECT a,b,a+b FROM 
   224    224          (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)
   225    225       WHERE b<4 ORDER BY a
   226    226     }
   227         -} {1.0 1 2.0 2.5 2 4.5 5.5 3 8.5}
          227  +} {1.0 1 2 2.5 2 4.5 5.5 3 8.5}
   228    228   do_test select6-3.12 {
   229    229     execsql {
   230    230       SELECT a,b,a+b FROM 
   231    231          (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b HAVING a>1)
   232    232       WHERE b<4 ORDER BY a
   233    233     }
   234    234   } {2.5 2 4.5 5.5 3 8.5}
   235    235   do_test select6-3.13 {
   236    236     execsql {
   237    237       SELECT a,b,a+b FROM 
   238    238          (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b HAVING a>1)
   239    239       ORDER BY a
   240    240     }
   241         -} {2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23.0}
          241  +} {2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23}
   242    242   do_test select6-3.14 {
   243    243     execsql {
   244    244       SELECT [count(*)],y FROM (SELECT count(*), y FROM t1 GROUP BY y)
   245    245       ORDER BY [count(*)]
   246    246     }
   247    247   } {1 1 2 2 4 3 5 5 8 4}
   248    248   do_test select6-3.15 {

Changes to test/sort.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the CREATE TABLE statement.
    13     13   #
    14         -# $Id: sort.test,v 1.23 2005/09/01 17:47:52 drh Exp $
           14  +# $Id: sort.test,v 1.24 2005/11/01 15:48:25 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a bunch of data to sort against
    20     20   #
    21     21   do_test sort-1.0 {
................................................................................
    58     58     execsql {SELECT n FROM t1 ORDER BY v}
    59     59   } {8 5 4 1 7 6 3 2}
    60     60   do_test sort-1.4 {
    61     61     execsql {SELECT n FROM t1 ORDER BY v DESC}
    62     62   } {2 3 6 7 1 4 5 8}
    63     63   do_test sort-1.5 {
    64     64     execsql {SELECT flt FROM t1 ORDER BY flt}
    65         -} {-11 -1.6 -0.0013442 0.123 2.15 3.141592653 123.0 4221.0}
           65  +} {-11 -1.6 -0.0013442 0.123 2.15 3.141592653 123 4221}
    66     66   do_test sort-1.6 {
    67     67     execsql {SELECT flt FROM t1 ORDER BY flt DESC}
    68         -} {4221.0 123.0 3.141592653 2.15 0.123 -0.0013442 -1.6 -11}
           68  +} {4221 123 3.141592653 2.15 0.123 -0.0013442 -1.6 -11}
    69     69   do_test sort-1.7 {
    70     70     execsql {SELECT roman FROM t1 ORDER BY roman}
    71     71   } {I II III IV V VI VII VIII}
    72     72   do_test sort-1.8 {
    73     73     execsql {SELECT n FROM t1 ORDER BY log, flt}
    74     74   } {1 2 3 5 4 6 7 8}
    75     75   do_test sort-1.8.1 {
................................................................................
   102    102   #
   103    103   do_test sort-2.1.1 {
   104    104     execsql {
   105    105       UPDATE t1 SET v='x' || -flt;
   106    106       UPDATE t1 SET v='x-2b' where v=='x-0.123';
   107    107       SELECT v FROM t1 ORDER BY v;
   108    108     }
   109         -} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11}
          109  +} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
   110    110   do_test sort-2.1.2 {
   111    111     execsql {
   112    112       SELECT v FROM t1 ORDER BY substr(v,2,999);
   113    113     }
   114         -} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11}
          114  +} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
   115    115   do_test sort-2.1.3 {
   116    116     execsql {
   117    117       SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0;
   118    118     }
   119         -} {x-4221.0 x-123.0 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11}
          119  +} {x-4221 x-123 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11}
   120    120   do_test sort-2.1.4 {
   121    121     execsql {
   122    122       SELECT v FROM t1 ORDER BY substr(v,2,999) DESC;
   123    123     }
   124         -} {x11 x1.6 x0.0013442 x-4221.0 x-3.141592653 x-2b x-2.15 x-123.0}
          124  +} {x11 x1.6 x0.0013442 x-4221 x-3.141592653 x-2b x-2.15 x-123}
   125    125   do_test sort-2.1.5 {
   126    126     execsql {
   127    127       SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0 DESC;
   128    128     }
   129         -} {x11 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123.0 x-4221.0}
          129  +} {x11 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123 x-4221}
   130    130   
   131    131   # This is a bug fix for 2.2.4.
   132    132   # Strings are normally mapped to upper-case for a caseless comparison.
   133    133   # But this can cause problems for characters in between 'Z' and 'a'.
   134    134   #
   135    135   do_test sort-3.1 {
   136    136     execsql {
................................................................................
   192    192       SELECT n+0 FROM t1 ORDER BY 1 DESC;
   193    193     }
   194    194   } {12 11 10 9 8 7 6 5 4 3 2 1}
   195    195   do_test sort-4.6 {
   196    196     execsql {
   197    197       SELECT v FROM t1 ORDER BY 1;
   198    198     }
   199         -} {x-123.0 x-2.15 x-2b x-3.141592653 x-4.0e9 x-4221.0 x0.0013442 x01234567890123456789 x1.6 x11 x2.7 x5.0e10}
          199  +} {x-123 x-2.15 x-2b x-3.141592653 x-4.0e9 x-4221 x0.0013442 x01234567890123456789 x1.6 x11 x2.7 x5.0e10}
   200    200   do_test sort-4.7 {
   201    201     execsql {
   202    202       SELECT v FROM t1 ORDER BY 1 DESC;
   203    203     }
   204         -} {x5.0e10 x2.7 x11 x1.6 x01234567890123456789 x0.0013442 x-4221.0 x-4.0e9 x-3.141592653 x-2b x-2.15 x-123.0}
          204  +} {x5.0e10 x2.7 x11 x1.6 x01234567890123456789 x0.0013442 x-4221 x-4.0e9 x-3.141592653 x-2b x-2.15 x-123}
   205    205   do_test sort-4.8 {
   206    206     execsql {
   207    207       SELECT substr(v,2,99) FROM t1 ORDER BY 1;
   208    208     }
   209         -} {-123.0 -2.15 -2b -3.141592653 -4.0e9 -4221.0 0.0013442 01234567890123456789 1.6 11 2.7 5.0e10}
          209  +} {-123 -2.15 -2b -3.141592653 -4.0e9 -4221 0.0013442 01234567890123456789 1.6 11 2.7 5.0e10}
   210    210   #do_test sort-4.9 {
   211    211   #  execsql {
   212    212   #    SELECT substr(v,2,99)+0.0 FROM t1 ORDER BY 1;
   213    213   #  }
   214    214   #} {-4000000000 -4221 -123 -3.141592653 -2.15 -2 0.0013442 1.6 2.7 11 50000000000 1.23456789012346e+18}
   215    215   
   216    216   do_test sort-5.1 {
................................................................................
   358    358   do_test sort-8.1 {
   359    359     execsql {
   360    360       CREATE TABLE t5(a real, b text);
   361    361       INSERT INTO t5 VALUES(100,'A1');
   362    362       INSERT INTO t5 VALUES(100.0,'A2');
   363    363       SELECT * FROM t5 ORDER BY a, b;
   364    364     }
   365         -} {100 A1 100.0 A2}
          365  +} {100 A1 100 A2}
   366    366   
   367    367   
   368    368   ifcapable {bloblit} {
   369    369   # BLOBs should sort after TEXT
   370    370   #
   371    371   do_test sort-9.1 {
   372    372     execsql {

Changes to test/types.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library. Specfically
    12     12   # it tests that the different storage classes (integer, real, text etc.)
    13     13   # all work correctly.
    14     14   #
    15         -# $Id: types.test,v 1.14 2004/11/14 21:56:31 drh Exp $
           15  +# $Id: types.test,v 1.15 2005/11/01 15:48:25 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Tests in this file are organized roughly as follows:
    21     21   #
    22     22   # types-1.*.*: Test that values are stored using the expected storage
................................................................................
    52     52   # Each element of the following list represents one test case.
    53     53   #
    54     54   # The first value of each sub-list is an SQL literal. The following
    55     55   # four value are the storage classes that would be used if the
    56     56   # literal were inserted into a column with affinity INTEGER, NUMERIC, TEXT
    57     57   # or NONE, respectively.
    58     58   set values {
    59         -  { 5.0    integer real    text real    }
           59  +  { 5.0    integer integer text integer }
           60  +  { 5.1    real    real    text real    }
    60     61     { 5      integer integer text integer }
    61         -  { '5.0'  integer real    text text    }
    62         -  { '-5.0' integer real    text text    }
    63         -  { '-5.0' integer real    text text    }
           62  +  { '5.0'  integer integer text text    }
           63  +  { '5.1'  real    real    text text    }
           64  +  { '-5.0' integer integer text text    }
           65  +  { '-5.0' integer integer text text    }
    64     66     { '5'    integer integer text text    }
    65     67     { 'abc'  text    text    text text    }
    66     68     { NULL   null    null    null null    }
    67     69   }
    68     70   ifcapable {bloblit} {
    69     71     lappend values  { X'00'  blob    blob    blob blob    }
    70     72   }
................................................................................
   217    219       INSERT INTO t2 VALUES(-12345.678);
   218    220     }
   219    221   } {}
   220    222   do_test types-2.2.2 {
   221    223     execsql {
   222    224       SELECT a FROM t2;
   223    225     }
   224         -} {0.0 12345.678 -12345.678}
          226  +} {0 12345.678 -12345.678}
   225    227   
   226    228   # Check that all the record sizes are as we expected.
   227    229   do_test types-2.2.3 {
   228    230     set root [db eval {select rootpage from sqlite_master where name = 't2'}]
   229    231     record_sizes $root
   230         -} {10 10 10}
          232  +} {3 10 10}
   231    233   
   232    234   # Insert a NULL. This should be a two byte record.
   233    235   do_test types-2.3.1 {
   234    236     execsql {
   235    237       CREATE TABLE t3(a nullvalue);
   236    238       INSERT INTO t3 VALUES(NULL);
   237    239     }

Changes to test/types3.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library. The focus
    12     12   # of this file is testing the interaction of SQLite manifest types
    13     13   # with Tcl dual-representations.
    14     14   #
    15         -# $Id: types3.test,v 1.1 2005/06/25 19:31:48 drh Exp $
           15  +# $Id: types3.test,v 1.2 2005/11/01 15:48:25 drh Exp $
    16     16   #
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # A variable with only a string representation comes in as TEXT
    22     22   do_test types3-1.1 {
................................................................................
    64     64     set V [db one {SELECT 123}]
    65     65     tcl_variable_type V
    66     66   } int
    67     67   do_test types3-2.3 {
    68     68     set V [db one {SELECT 1234567890123456}]
    69     69     tcl_variable_type V
    70     70   } wideInt
    71         -do_test types3-2.4 {
    72         -  set V [db one {SELECT 1234567890123456.0}]
           71  +do_test types3-2.4.1 {
           72  +  set V [db one {SELECT 1234567890123456.1}]
           73  +  tcl_variable_type V
           74  +} wideInt
           75  +do_test types3-2.4.2 {
           76  +  set V [db one {SELECT 1234567890123.456}]
    73     77     tcl_variable_type V
    74     78   } double
    75     79   do_test types3-2.5 {
    76     80     set V [db one {SELECT '1234567890123456.0'}]
    77     81     tcl_variable_type V
    78     82   } {}
    79     83   do_test types3-2.6 {
    80     84     set V [db one {SELECT NULL}]
    81     85     tcl_variable_type V
    82     86   } {}
    83     87   
    84     88   finish_test