]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Omit the SQLITE_AFF_INTEGER type affinity. All numeric values are now
authordrh <drh@noemail.net>
Tue, 1 Nov 2005 15:48:24 +0000 (15:48 +0000)
committerdrh <drh@noemail.net>
Tue, 1 Nov 2005 15:48:24 +0000 (15:48 +0000)
of type real, though an integer representation is still sometimes used
internally for efficiency. (CVS 2753)

FossilOrigin-Name: e0d6f61c7de2c03b8fd17ef37cf1a0add36ee618

24 files changed:
manifest
manifest.uuid
src/analyze.c
src/build.c
src/expr.c
src/insert.c
src/sqliteInt.h
src/vdbe.c
src/vdbeInt.h
src/vdbemem.c
test/cast.test
test/collate1.test
test/expr.test
test/func.test
test/index.test
test/main.test
test/misc1.test
test/misc5.test
test/quote.test
test/select3.test
test/select6.test
test/sort.test
test/types.test
test/types3.test

index 176abeec217a155b8118bb3e5f58316fe0f91ec6..a4e2a434a4dc2065fe39b23f9d1aeb210f039de7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\sshift\soperators\sso\sthat\sthey\swork\swith\s64-bit\squantities.\s(CVS\s2752)
-D 2005-10-29T15:48:31
+C Omit\sthe\sSQLITE_AFF_INTEGER\stype\saffinity.\s\sAll\snumeric\svalues\sare\snow\nof\stype\sreal,\sthough\san\sinteger\srepresentation\sis\sstill\ssometimes\sused\ninternally\sfor\sefficiency.\s(CVS\s2753)
+D 2005-11-01T15:48:24
 F Makefile.in 12784cdce5ffc8dfb707300c34e4f1eb3b8a14f1
 F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -30,22 +30,22 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
 F sqlite3.def c413e514217736884254739a105c8c942fdf0c2f
 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
 F src/alter.c 149e871e1ad6648da9b72e69feb1bd1407bf5226
-F src/analyze.c 21a4cd125bedd3cb15857595c45c2a49c0556d26
+F src/analyze.c 2afd437e197569f6df6c15e0ae70c6f70f5c6c0c
 F src/attach.c 4b21689700a72ae281fa85dbaff06b2a62bd49ee
 F src/auth.c 31e2304bef67f44d635655f44234387ea7d21454
 F src/btree.c 1ccc3b3931774a68ee0d6a8e2c8ea83f27b853fb
 F src/btree.h 1ed561263ca0e335bc3e81d761c9d5ff8c22f61e
-F src/build.c aa9591839c00731370c1ba53a9c0045f70d764c4
+F src/build.c a9dc62b900e83d70ff4a065e760064ded379c5bf
 F src/callback.c 90ab4f235a2603c4cb8e6a2497091a71fb732bfa
 F src/complete.c 4de937dfdd4c79a501772ab2035b26082f337a79
 F src/date.c 7444b0900a28da77e57e3337a636873cff0ae940
 F src/delete.c 29dac493f4d83b05f91233b116827c133bcdab72
 F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d
-F src/expr.c 6881c8dfe363c1ee5a5dcb463b880704acb77709
+F src/expr.c acf80a3ce4a668f4b7ae40c064049befa2f83d91
 F src/func.c 7d81dccd9c440c6c4e761056333e629192814af0
 F src/hash.c 8747cf51d12de46512880dfcf1b68b4e24072863
 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
-F src/insert.c 1f51566d7cf4b243a2792f5fda37343d6e9377fa
+F src/insert.c b7757ac308a7ea8124f2d6d1a6821ea4ae045a29
 F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b
 F src/main.c 97bb830cdbd378d1f87469618471f52d9d263d09
 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
@@ -67,7 +67,7 @@ F src/random.c 90adff4e73a3b249eb4f1fc2a6ff9cf78c7233a4
 F src/select.c 80c95f3cebd6f7096cdcad1968316e4bb96b18b2
 F src/shell.c 3596c1e559b82663057940d19ba533ad421c7dd3
 F src/sqlite.h.in 8e648e1f386e4509f2f96c09ded7c07b0df0c9a2
-F src/sqliteInt.h 403552a7770a5c5a376af9bdc956f0c78e524b9c
+F src/sqliteInt.h 922d71882bbfc64a3e7ca0f3e173a5f5ef8d00ed
 F src/table.c e03b60eaabaeb54a00d7e931566d77302dfc19b0
 F src/tclsqlite.c 4f274fae3d4a1863451a553dd8e5015747a5d91d
 F src/test1.c 0f1a66f65a54fba029f7e93b7500d49443dc959b
@@ -81,13 +81,13 @@ F src/update.c ac506fb7400158f826ec6c3a0dbe65e7ed3928d5
 F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c
 F src/util.c 48fecbbef4391d102a23096d32f0d74173428406
 F src/vacuum.c 829d9e1a6d7c094b80e0899686670932eafd768c
-F src/vdbe.c 12cbad0abf1ad091e936fe269ba2d1a319f756b8
+F src/vdbe.c e83de8a017fe5c495fcef3093dbdca30fa6b1ea4
 F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
-F src/vdbeInt.h 7bedbb9553a10e86b53f75d99e197f3f00a732bf
+F src/vdbeInt.h 6eba0b967dc4fc4d5dea6e3bcc66e70a44981cc9
 F src/vdbeapi.c 85bbe1d0243a89655433d60711b4bd71979b59cd
 F src/vdbeaux.c eb1ce3a40d37a1a7e92749e0ef72e3224fa5e55f
 F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
-F src/vdbemem.c ff426ff6e72aa3f0300a56ec8c7f18099be96b43
+F src/vdbemem.c 555539999fca277c63acf428dbda830d3c10a05c
 F src/where.c 5252bf20257fb8630959ae7a145fc20076f30543
 F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
 F test/all.test 7f0988442ab811dfa41793b5b550f5828ce316f3
@@ -123,8 +123,8 @@ F test/busy.test 0271c854738e23ad76e10d4096a698e5af29d211
 F test/capi2.test f897209386fb21cfdc9267595e0c667ebaca9164
 F test/capi3.test fc8e573467049add3bfaf81f53827e8ff153cf8f
 F test/capi3b.test 5b6a66f9f295f79f443b5d3f33187fa5ef6cf336
-F test/cast.test 937af85faabdb189b6cd05879977f2469223be59
-F test/collate1.test f79736d2ebf5492167ee4d1f4ab4c09dda776b03
+F test/cast.test 2543165ced4249c89ce5f0352222df503a98b9e5
+F test/collate1.test add9454cef160677bb8b34148b8f277ce7f9f1c4
 F test/collate2.test 224a632ba04907c049804b08162efd234aa7871f
 F test/collate3.test 947a77f5b8227e037a7094d0e338a5504f155cc4
 F test/collate4.test daf498e294dcd596b961d425c3f2dda117e4717e
@@ -145,12 +145,12 @@ F test/distinctagg.test 2b89d1c5220d966a30ba4b40430338669301188b
 F test/enc.test 7a03417a1051fe8bc6c7641cf4c8c3f7e0066d52
 F test/enc2.test 76c13b8c00beaf95b15c152e95dab51292eb1f0d
 F test/enc3.test f6a5f0b7b7f3a88f030d3143729b87cd5c86d837
-F test/expr.test 9698d7bbe4ded9ba66836a4fd50f3f4bf1c0c152
+F test/expr.test e44b37b926a5f5f2ef9f8e69488c7dc137db3f52
 F test/fkey1.test 153004438d51e6769fb1ce165f6313972d6263ce
-F test/func.test 431f8e07a30aadf2a2a0c8c32f918a497bc4331d
+F test/func.test ee08a30ba4e3c24e11285ce15b9805519360acc2
 F test/hook.test f8605cde4c77b2c6a4a73723bf6c507796a64dda
 F test/in.test cead6165aebbe0d451bb2263a307173acfeb6240
-F test/index.test 51e01a0928b4b61228917ddd8c6c0e2466547f6f
+F test/index.test 834494833f29e134295a2fb0f960d4bb23fd4f88
 F test/index2.test 9ad98243fd7fe833795a9cc662f371f0eed4ff4f
 F test/index3.test f66718cd92ce1216819d47e6a156755e4b2c4ca1
 F test/insert.test b0a89e1568fe9890758f8f2b43b68e840e8f1a1a
@@ -172,18 +172,18 @@ F test/limit.test 39f084f4e5f11e0b984cb517b56867cbf88df156
 F test/lock.test 9b7afcb24f53d24da502abb33daaad2cd6d44107
 F test/lock2.test d83ba79d3c4fffdb5b926c7d8ca7a36c34288a55
 F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
-F test/main.test 6e44c86e9efaa913659e189713a339cb5d84bb12
+F test/main.test 54a9a3904d30f915577d397b2b6424b78cc54b57
 F test/malloc.test 666c77a878ce50f5c22b9211ed43e889cabb63a6
 F test/malloc2.test 655b972372d2754a3f6c6ed54d7cfd18fde9bd32
 F test/manydb.test 18bc28e481d8e742a767858a8149bc96056aad46
 F test/memdb.test 1860e060be810bf0775bc57408a5b7c4954bcaea
 F test/memleak.test df2b2b96e77f8ba159a332299535b1e5f18e49ac
 F test/minmax.test cad887abca5504396718e2cd5729ca40758743e8
-F test/misc1.test c991617666991e11513e46cb646fd2e45ae68599
+F test/misc1.test 7aabf32e698ef7cc1253f5e7fc216c65870ce485
 F test/misc2.test 5c699af2fede2694736a9f45aea7e2f052686e15
 F test/misc3.test 7bd937e2c62bcc6be71939faf068d506467b1e03
 F test/misc4.test fbb81c1d520f34deea819a5d94d787d3d38dc35b
-F test/misc5.test 24bd03404039ec727028ac9cf7fd9066fd209ec9
+F test/misc5.test d40d795f0556fab831a78fffab0310624d25f820
 F test/misuse.test 1c7fee3c4c0cb4008717ecccf5c72281fac0008e
 F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
 F test/null.test 012fe5455f4fc3102490b4bad373a674e5741fdd
@@ -195,7 +195,7 @@ F test/pragma.test 95ea907adf68459e1be6f310c9ae94d1d59c465b
 F test/printf.test 9e10c74e16bf889f8495ddb3d6f5f891e75ff1b7
 F test/progress.test 16496001da445e6534afb94562c286708316d82f x
 F test/quick.test a94d12658a2b590c1a5be580bef09bbb04c1266b
-F test/quote.test c1ca5e18800455f1c882baf5b0274755a3836549
+F test/quote.test 5891f2338980916cf7415484b4ce785294044adb
 F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
 F test/rollback.test 94cd981ee3a627d9f6466f69dcf1f7dbfe695d7a
 F test/rowid.test 040a3bef06f970c45f5fcd14b2355f7f4d62f0cf
@@ -203,12 +203,12 @@ F test/safety.test 907b64fee719554a3622853812af3886fddbbb4f
 F test/schema.test 21cbe7dac652f6d7eb058f3dec369bdbf46bbde6
 F test/select1.test 480233d4f5a81d7d59a55e40d05084d97e57ecdf
 F test/select2.test f3c2678c3a9f3cf08ec4988a3845bda64be6d9e3
-F test/select3.test 576df1a5cc5e01dadae9176384e2d506315afdcf
+F test/select3.test 3cb5f742d63cf6b35a14f8967ec7fb57b84c3269
 F test/select4.test c239f516aa31f42f2ef7c6d7cd01105f08f934ca
 F test/select5.test 07a90ab3c7e3f0a241a9cdea1d997b2c8a89ff0b
-F test/select6.test 21b72c56e7cbcefd063fdf9bc6c89342aedabccf
+F test/select6.test 98a98b5596fd554215ce4487bbb0e4ba6d1cca08
 F test/select7.test 1bf795b948c133a15a2a5e99d3270e652ec58ce6
-F test/sort.test 0c33a8ae1c238377ad197387c3872175f40d3843
+F test/sort.test de8e2f17c3fa886ded5dbb52435f84011b68fa3d
 F test/subquery.test e6de53332c0301b3cfa34edc3f3cd5fa1e859efd
 F test/subselect.test 2d13fb7f450db3595adcdd24079a0dd1d2d6abc2
 F test/sync.test d769caaec48456119316775e35e0fdee2fa852d7
@@ -234,9 +234,9 @@ F test/trigger4.test 4bed3705c9df4aaf7a7b164a2d573410d05ca025
 F test/trigger5.test 619391a3e9fc194081d22cefd830d811e7badf83
 F test/trigger6.test 0e411654f122552da6590f0b4e6f781048a4a9b9
 F test/trigger7.test 0afa870be2ce1b132cdb85b17a4a4ef45aa8cece
-F test/types.test f0a98d10c5ecc9865d19dc94486f9873afc6bb6b
+F test/types.test b5e5590d45ea4385345b98ba75ecacf01aa9138a
 F test/types2.test 81dd1897be8ef4b5b73d0006e6076abe40610de3
-F test/types3.test 5c63c9cdbafe8fcb73a70a0beb0ecb65b7fa061d
+F test/types3.test e77b2cd9062cd239efa67993e211c640bdedfaa9
 F test/unique.test 0253c4227a5dc533e312202ce21ecfad18058d18
 F test/update.test 7669ca789d62c258b678e8aa7a22a57eac10f2cf
 F test/utf16.test 5fb019e09601774743858ef7380b6c02103ff120
@@ -315,7 +315,7 @@ F www/tclsqlite.tcl ddcf912ea48695603c8ed7efb29f0812ef8d1b49
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P c9c476dd836c49255eabc6cce83064974c079ce3
-R dec9ff08495d988e05cdebca8c7d5cc0
+P 0d3357b5f65887f7db03db2ae021f28f480f90e4
+R 129a42da3960f8ddb76cd0aa7a6f3c7c
 U drh
-Z 7195dd21fd04b843659e4b75633e96d2
+Z 4057f17a6edfdde3a8a1c1ea6fb897b0
index 886de427aaa2a1639b252fffccca0369d58f2cfb..582316171e597b05d3d3addde0036082c9c67193 100644 (file)
@@ -1 +1 @@
-0d3357b5f65887f7db03db2ae021f28f480f90e4
\ No newline at end of file
+e0d6f61c7de2c03b8fd17ef37cf1a0add36ee618
\ No newline at end of file
index 67d80d534032fc40219e67a48a89b2d142936361..59749704d49caec6e3de34ca66785b403e6f780e 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code associated with the ANALYZE command.
 **
-** @(#) $Id: analyze.c,v 1.9 2005/09/20 17:42:23 drh Exp $
+** @(#) $Id: analyze.c,v 1.10 2005/11/01 15:48:24 drh Exp $
 */
 #ifndef SQLITE_OMIT_ANALYZE
 #include "sqliteInt.h"
@@ -188,6 +188,7 @@ static void analyzeOneTable(
       sqlite3VdbeAddOp(v, OP_AddImm, -1, 0);
       sqlite3VdbeAddOp(v, OP_MemLoad, iMem+i+1, 0);
       sqlite3VdbeAddOp(v, OP_Divide, 0, 0);
+      sqlite3VdbeAddOp(v, OP_ToInt, 0, 0);
       if( i==nCol-1 ){
         sqlite3VdbeAddOp(v, OP_Concat, nCol*2-1, 0);
       }else{
index 9857a8e15b44b2a9972f142402fdd0d18c0d039d..69a652b3347bcfaf3c73b925e861cc6b88551d35 100644 (file)
@@ -22,7 +22,7 @@
 **     COMMIT
 **     ROLLBACK
 **
-** $Id: build.c,v 1.351 2005/09/20 17:42:23 drh Exp $
+** $Id: build.c,v 1.352 2005/11/01 15:48:24 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -882,7 +882,7 @@ void sqlite3AddNotNull(Parse *pParse, int onError){
 ** found, the corresponding affinity is returned. If zType contains
 ** more than one of the substrings, entries toward the top of 
 ** the table take priority. For example, if zType is 'BLOBINT', 
-** SQLITE_AFF_INTEGER is returned.
+** SQLITE_AFF_NUMERIC is returned.
 **
 ** Substring     | Affinity
 ** --------------------------------
@@ -894,8 +894,12 @@ void sqlite3AddNotNull(Parse *pParse, int onError){
 **
 ** If none of the substrings in the above table are found,
 ** SQLITE_AFF_NUMERIC is returned.
+**
+** The SQLITE_AFF_INTEGER type is only returned if useIntType is true.
+** If useIntType is false, then SQLITE_AFF_INTEGER is reported back
+** as SQLITE_AFF_NUMERIC
 */
-char sqlite3AffinityType(const Token *pType){
+char sqlite3AffinityType(const Token *pType, int useIntType){
   u32 h = 0;
   char aff = SQLITE_AFF_NUMERIC;
   const unsigned char *zIn = pType->z;
@@ -914,7 +918,7 @@ char sqlite3AffinityType(const Token *pType){
         && aff==SQLITE_AFF_NUMERIC ){
       aff = SQLITE_AFF_NONE;
     }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){    /* INT */
-      aff = SQLITE_AFF_INTEGER
+      aff = useIntType ? SQLITE_AFF_INTEGER : SQLITE_AFF_NUMERIC
       break;
     }
   }
@@ -942,7 +946,7 @@ void sqlite3AddColumnType(Parse *pParse, Token *pType){
   pCol = &p->aCol[i];
   sqliteFree(pCol->zType);
   pCol->zType = sqlite3NameFromToken(pType);
-  pCol->affinity = sqlite3AffinityType(pType);
+  pCol->affinity = sqlite3AffinityType(pType, 0);
 }
 
 /*
index f1eae86d6483224e44b123dafbbf2fe1ebdee95d..b915059d4ee2ff32ac9a0a17c60b6e3870c2dd7f 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains routines used for analyzing expressions and
 ** for generating VDBE code that evaluates expressions in SQLite.
 **
-** $Id: expr.c,v 1.231 2005/10/06 16:53:15 drh Exp $
+** $Id: expr.c,v 1.232 2005/11/01 15:48:24 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -43,7 +43,7 @@ char sqlite3ExprAffinity(Expr *pExpr){
   }
 #ifndef SQLITE_OMIT_CAST
   if( op==TK_CAST ){
-    return sqlite3AffinityType(&pExpr->token);
+    return sqlite3AffinityType(&pExpr->token, 0);
   }
 #endif
   return pExpr->affinity;
@@ -75,12 +75,10 @@ CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
 char sqlite3CompareAffinity(Expr *pExpr, char aff2){
   char aff1 = sqlite3ExprAffinity(pExpr);
   if( aff1 && aff2 ){
-    /* Both sides of the comparison are columns. If one has numeric or
-    ** integer affinity, use that. Otherwise use no affinity.
+    /* Both sides of the comparison are columns. If one has numeric
+    ** affinity, use that. Otherwise use no affinity.
     */
-    if( aff1==SQLITE_AFF_INTEGER || aff2==SQLITE_AFF_INTEGER ){
-      return SQLITE_AFF_INTEGER;
-    }else if( aff1==SQLITE_AFF_NUMERIC || aff2==SQLITE_AFF_NUMERIC ){
+    if( aff1==SQLITE_AFF_NUMERIC || aff2==SQLITE_AFF_NUMERIC ){
       return SQLITE_AFF_NUMERIC;
     }else{
       return SQLITE_AFF_NONE;
@@ -89,7 +87,6 @@ char sqlite3CompareAffinity(Expr *pExpr, char aff2){
     /* Neither side of the comparison is a column.  Compare the
     ** results directly.
     */
-    /* return SQLITE_AFF_NUMERIC;  // Ticket #805 */
     return SQLITE_AFF_NONE;
   }else{
     /* One side is a column, the other is not. Use the columns affinity. */
@@ -129,11 +126,7 @@ static char comparisonAffinity(Expr *pExpr){
 */
 int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){
   char aff = comparisonAffinity(pExpr);
-  return 
-    (aff==SQLITE_AFF_NONE) ||
-    (aff==SQLITE_AFF_NUMERIC && idx_affinity==SQLITE_AFF_INTEGER) ||
-    (aff==SQLITE_AFF_INTEGER && idx_affinity==SQLITE_AFF_NUMERIC) ||
-    (aff==idx_affinity);
+  return (aff==SQLITE_AFF_NONE) || (aff==idx_affinity);
 }
 
 /*
@@ -944,7 +937,7 @@ static int lookupName(
     if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){
       cnt = 1;
       pExpr->iColumn = -1;
-      pExpr->affinity = SQLITE_AFF_INTEGER;
+      pExpr->affinity = SQLITE_AFF_NUMERIC;
     }
 
     /*
@@ -1524,7 +1517,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
       /* Expressions of the form:   CAST(pLeft AS token) */
       int aff, op;
       sqlite3ExprCode(pParse, pExpr->pLeft);
-      aff = sqlite3AffinityType(&pExpr->token);
+      aff = sqlite3AffinityType(&pExpr->token, 1);
       switch( aff ){
         case SQLITE_AFF_INTEGER:   op = OP_ToInt;      break;
         case SQLITE_AFF_NUMERIC:   op = OP_ToNumeric;  break;
index e19aa7da174c2a0d900427a2bbdea7cd6f94cd3a..dcc57d5718f18739b899c6985763200673bee9f4 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle INSERT statements in SQLite.
 **
-** $Id: insert.c,v 1.143 2005/09/20 17:42:23 drh Exp $
+** $Id: insert.c,v 1.144 2005/11/01 15:48:24 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -24,7 +24,6 @@
 **  Character      Column affinity
 **  ------------------------------
 **  'n'            NUMERIC
-**  'i'            INTEGER
 **  't'            TEXT
 **  'o'            NONE
 */
@@ -62,7 +61,6 @@ void sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){
 **  Character      Column affinity
 **  ------------------------------
 **  'n'            NUMERIC
-**  'i'            INTEGER
 **  't'            TEXT
 **  'o'            NONE
 */
index 7b4f360b62d0380523590f3f2e22ef3e3bc0d9da..51d1ce76c0fe297beb688afd62d650b598ababad 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.423 2005/10/13 02:09:50 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.424 2005/11/01 15:48:24 drh Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -585,8 +585,8 @@ struct CollSeq {
 /*
 ** Column affinity types.
 */
-#define SQLITE_AFF_INTEGER  'i'
 #define SQLITE_AFF_NUMERIC  'n'
+#define SQLITE_AFF_INTEGER  'i'  /* Used for CAST operators only */
 #define SQLITE_AFF_TEXT     't'
 #define SQLITE_AFF_NONE     'o'
 
@@ -1646,7 +1646,7 @@ void sqlite3AlterFinishAddColumn(Parse *, Token *);
 void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
 const char *sqlite3TestErrorName(int);
 CollSeq *sqlite3GetCollSeq(sqlite3*, CollSeq *, const char *, int);
-char sqlite3AffinityType(const Token*);
+char sqlite3AffinityType(const Token*, int);
 void sqlite3Analyze(Parse*, Token*, Token*);
 int sqlite3InvokeBusyHandler(BusyHandler*);
 int sqlite3FindDb(sqlite3*, Token*);
index 09cac04665c7e410657c7d370031070bd362ed2a..30f57be1868186669ec203ba8e1bc90c10889f9a 100644 (file)
@@ -43,7 +43,7 @@
 ** 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.494 2005/10/29 15:48:31 drh Exp $
+** $Id: vdbe.c,v 1.495 2005/11/01 15:48:24 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -194,8 +194,6 @@ static Cursor *allocateCursor(Vdbe *p, int iCur){
 ** SQLITE_AFF_NUMERIC
 ** SQLITE_AFF_TEXT
 ** SQLITE_AFF_NONE
-** SQLITE_AFF_INTEGER
-**
 */
 static void applyAffinity(Mem *pRec, char affinity, u8 enc){
   if( affinity==SQLITE_AFF_NONE ){
@@ -224,16 +222,8 @@ static void applyAffinity(Mem *pRec, char affinity, u8 enc){
           Integerify(pRec);
         }
       }
-    }
-
-    if( affinity==SQLITE_AFF_INTEGER ){
-      /* For INTEGER affinity, try to convert a real value to an int */
-      if( (pRec->flags&MEM_Real) && !(pRec->flags&MEM_Int) ){
-        pRec->i = pRec->r;
-        if( ((double)pRec->i)==pRec->r ){
-          pRec->flags |= MEM_Int;
-        }
-      }
+    }else if( pRec->flags & MEM_Real ){
+      sqlite3VdbeIntegerAffinity(pRec);
     }
   }
 }
@@ -645,6 +635,7 @@ case OP_Real: {            /* same as TK_FLOAT, */
   pTos->r = sqlite3VdbeRealValue(pTos);
   pTos->flags |= MEM_Real;
   sqlite3VdbeChangeEncoding(pTos, db->enc);
+  sqlite3VdbeIntegerAffinity(pTos);
   break;
 }
 
@@ -1030,6 +1021,7 @@ case OP_Remainder: {           /* same as TK_REM, no-push */
       case OP_Multiply:    b *= a;       break;
       case OP_Divide: {
         if( a==0 ) goto divide_by_zero;
+        if( b%a!=0 ) goto floating_point_divide;
         b /= a;
         break;
       }
@@ -1046,6 +1038,7 @@ case OP_Remainder: {           /* same as TK_REM, no-push */
     pTos->flags = MEM_Int;
   }else{
     double a, b;
+    floating_point_divide:
     a = sqlite3VdbeRealValue(pTos);
     b = sqlite3VdbeRealValue(pNos);
     switch( pOp->opcode ){
@@ -1070,6 +1063,7 @@ case OP_Remainder: {           /* same as TK_REM, no-push */
     Release(pTos);
     pTos->r = b;
     pTos->flags = MEM_Real;
+    sqlite3VdbeIntegerAffinity(pTos);
   }
   break;
 
@@ -1267,7 +1261,7 @@ case OP_AddImm: {            /* no-push */
 case OP_ForceInt: {            /* no-push */
   i64 v;
   assert( pTos>=p->aStack );
-  applyAffinity(pTos, SQLITE_AFF_INTEGER, db->enc);
+  applyAffinity(pTos, SQLITE_AFF_NUMERIC, db->enc);
   if( (pTos->flags & (MEM_Int|MEM_Real))==0 ){
     Release(pTos);
     pTos--;
@@ -1301,7 +1295,7 @@ case OP_ForceInt: {            /* no-push */
 */
 case OP_MustBeInt: {            /* no-push */
   assert( pTos>=p->aStack );
-  applyAffinity(pTos, SQLITE_AFF_INTEGER, db->enc);
+  applyAffinity(pTos, SQLITE_AFF_NUMERIC, db->enc);
   if( (pTos->flags & MEM_Int)==0 ){
     if( pOp->p2==0 ){
       rc = SQLITE_MISMATCH;
@@ -1317,7 +1311,6 @@ case OP_MustBeInt: {            /* no-push */
   break;
 }
 
-#ifndef SQLITE_OMIT_CAST
 /* Opcode: ToInt * * *
 **
 ** Force the value on the top of the stack to be an integer.  If
@@ -1332,11 +1325,12 @@ case OP_ToInt: {                  /* no-push */
   if( pTos->flags & MEM_Null ) break;
   assert( MEM_Str==(MEM_Blob>>3) );
   pTos->flags |= (pTos->flags&MEM_Blob)>>3;
-  applyAffinity(pTos, SQLITE_AFF_INTEGER, db->enc);
+  applyAffinity(pTos, SQLITE_AFF_NUMERIC, db->enc);
   sqlite3VdbeMemIntegerify(pTos);
   break;
 }
 
+#ifndef SQLITE_OMIT_CAST
 /* Opcode: ToNumeric * * *
 **
 ** Force the value on the top of the stack to be numeric (either an
@@ -1422,7 +1416,7 @@ case OP_ToBlob: {                  /* no-push */
 ** 0x200 is set but is NULL when the 0x200 bit of P1 is clear.
 **
 ** The least significant byte of P1 (mask 0xff) must be an affinity character -
-** 'n', 't', 'i' or 'o' - or 0x00. An attempt is made to coerce both values
+** 'n', 't', or 'o' - or 0x00. An attempt is made to coerce both values
 ** according to the affinity before the comparison is made. If the byte is
 ** 0x00, then numeric affinity is used.
 **
@@ -1614,11 +1608,13 @@ case OP_Negative:              /* same as TK_UMINUS, no-push */
 case OP_AbsValue: {
   assert( pTos>=p->aStack );
   if( pTos->flags & MEM_Real ){
+    neg_abs_real_case:
     Release(pTos);
     if( pOp->opcode==OP_Negative || pTos->r<0.0 ){
       pTos->r = -pTos->r;
     }
     pTos->flags = MEM_Real;
+    sqlite3VdbeIntegerAffinity(pTos);
   }else if( pTos->flags & MEM_Int ){
     Release(pTos);
     if( pOp->opcode==OP_Negative || pTos->i<0 ){
@@ -1629,10 +1625,7 @@ case OP_AbsValue: {
     /* Do nothing */
   }else{
     Realify(pTos);
-    if( pOp->opcode==OP_Negative || pTos->r<0.0 ){
-      pTos->r = -pTos->r;
-    }
-    pTos->flags = MEM_Real;
+    goto neg_abs_real_case;
   }
   break;
 }
@@ -2083,7 +2076,6 @@ op_column_out:
 **
 ** The mapping from character to affinity is as follows:
 **    'n' = NUMERIC.
-**    'i' = INTEGER.
 **    't' = TEXT.
 **    'o' = NONE.
 **
index 1746ee561f2b642f89ca780baeb3f0099eea1346..e38f809e6ec3aabb913ee0b60f444291d1a445a5 100644 (file)
@@ -360,6 +360,7 @@ int sqlite3VdbeMemStringify(Mem*, int);
 i64 sqlite3VdbeIntValue(Mem*);
 int sqlite3VdbeMemIntegerify(Mem*);
 double sqlite3VdbeRealValue(Mem*);
+void sqlite3VdbeIntegerAffinity(Mem*);
 int sqlite3VdbeMemRealify(Mem*);
 int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);
 void sqlite3VdbeMemRelease(Mem *p);
index 0b7e193bec9a49368d838a60aab8b326938afe6b..7f40af63ade35c3127d577358138da3ba8bff781 100644 (file)
@@ -173,11 +173,11 @@ int sqlite3VdbeMemStringify(Mem *pMem, int enc){
   ** 
   ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16.
   */
-  if( fg & MEM_Real ){
-    sqlite3_snprintf(NBFS, z, "%!.15g", pMem->r);
-  }else{
-    assert( fg & MEM_Int );
+  if( fg & MEM_Int ){
     sqlite3_snprintf(NBFS, z, "%lld", pMem->i);
+  }else{
+    assert( fg & MEM_Real );
+    sqlite3_snprintf(NBFS, z, "%!.15g", pMem->r);
   }
   pMem->n = strlen(z);
   pMem->z = z;
@@ -300,13 +300,27 @@ double sqlite3VdbeRealValue(Mem *pMem){
 }
 
 /*
-** Convert pMem so that it is of type MEM_Real.  Invalidate any
-** prior representations.
+** The MEM structure is already a MEM_Real.  Try to also make it a
+** MEM_Int if we can.
+*/
+void sqlite3VdbeIntegerAffinity(Mem *pMem){
+  assert( pMem->flags & MEM_Real );
+  pMem->i = pMem->r;
+  if( ((double)pMem->i)==pMem->r ){
+    pMem->flags |= MEM_Int;
+  }
+}
+
+
+/*
+** Convert pMem so that it is of type MEM_Real and also MEM_Int if
+** possible.  Invalidate any prior representations.
 */
 int sqlite3VdbeMemRealify(Mem *pMem){
   pMem->r = sqlite3VdbeRealValue(pMem);
   sqlite3VdbeMemRelease(pMem);
   pMem->flags = MEM_Real;
+  sqlite3VdbeIntegerAffinity(pMem);
   return SQLITE_OK;
 }
 
index 3ab64adce55d0178dcf87d12631e9e466f8c6815..82d4d2c37ced207175ed3184db2c3d54b446a805 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the CAST operator.
 #
-# $Id: cast.test,v 1.2 2005/06/25 19:31:48 drh Exp $
+# $Id: cast.test,v 1.3 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -38,10 +38,10 @@ do_test cast-1.4 {
 } text
 do_test cast-1.5 {
   execsql {SELECT CAST(x'616263' AS numeric)}
-} 0.0
+} 0
 do_test cast-1.6 {
   execsql {SELECT typeof(CAST(x'616263' AS numeric))}
-} real
+} integer
 do_test cast-1.7 {
   execsql {SELECT CAST(x'616263' AS blob)}
 } abc
@@ -158,10 +158,10 @@ do_test cast-1.44 {
 } text
 do_test cast-1.45 {
   execsql {SELECT CAST('123abc' AS numeric)}
-} 123.0
+} 123
 do_test cast-1.46 {
   execsql {SELECT typeof(CAST('123abc' AS numeric))}
-} real
+} integer
 do_test cast-1.47 {
   execsql {SELECT CAST('123abc' AS blob)}
 } {123abc}
index 458c9025a2c41eef0792337e3706fae9ee6b9d2a..2f769e86a96a81fbdccad062b0d626bbd790b5a4 100644 (file)
@@ -12,7 +12,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is page cache subsystem.
 #
-# $Id: collate1.test,v 1.3 2004/08/20 18:34:20 drh Exp $
+# $Id: collate1.test,v 1.4 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -214,7 +214,7 @@ do_test collate1-4.3 {
   execsql {
     SELECT c2+0 FROM collate1t1 ORDER BY 1;
   }
-} {{} 1.0 12.0 101.0}
+} {{} 1 12 101}
 do_test collate1-4.4 {
   execsql {
     SELECT c1||'' FROM collate1t1 ORDER BY 1;
index b66d080fcbfcebcf4626bf855ee60db3a23fcd73..bde00e98c22db600a2d420c108b6ad1ec0875dec 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing expressions.
 #
-# $Id: expr.test,v 1.46 2005/10/29 15:48:32 drh Exp $
+# $Id: expr.test,v 1.47 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -29,8 +29,7 @@ proc test_expr {name settings expr result} {
 test_expr expr-1.1 {i1=10, i2=20} {i1+i2} 30
 test_expr expr-1.2 {i1=10, i2=20} {i1-i2} -10
 test_expr expr-1.3 {i1=10, i2=20} {i1*i2} 200
-# update for sqlite3 v3: Change 0.5 to 0 in expr1.4 due to manifest types.
-test_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0
+test_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0.5
 test_expr expr-1.5 {i1=10, i2=20} {i2/i1} 2
 test_expr expr-1.6 {i1=10, i2=20} {i2<i1} 0
 test_expr expr-1.7 {i1=10, i2=20} {i2<=i1} 0
@@ -48,8 +47,8 @@ test_expr expr-1.18 {i1=20, i2=20} {i2!=i1} 0
 test_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1
 test_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0
 test_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1
-test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7.0}
-test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9.0}
+test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7}
+test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9}
 test_expr expr-1.24 {i1=1, i2=2} {min(i1,i2,i1+i2,i1-i2)} {-1}
 test_expr expr-1.25 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
 test_expr expr-1.26 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
@@ -161,8 +160,8 @@ test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0
 test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1
 test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11}
 test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}
-test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3.0
-test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0
+test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3
+test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99
 
 test_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1
 test_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0
index ea11fc30b549b92cc9708fd36f48d63f19c09e91..8af0aeac82ab514f4581e71e691fe63c79c32af8 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing built-in functions.
 #
-# $Id: func.test,v 1.40 2005/09/08 20:37:44 drh Exp $
+# $Id: func.test,v 1.41 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -511,7 +511,7 @@ do_test func-18.2 {
     INSERT INTO t5 VALUES(0.0);
     SELECT sum(x) FROM t5;
   }
-} {9902.0}
+} {9902}
 
 # The sum of nothing is NULL.  But the sum of all NULLs is NULL.
 #
index ce0fe2e25a1f227269d784303029ee2ce3caf480..86a28afd9510a86292e6f42aec64ada086e84a8c 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the CREATE INDEX statement.
 #
-# $Id: index.test,v 1.37 2005/01/21 03:12:16 danielk1977 Exp $
+# $Id: index.test,v 1.38 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -372,38 +372,38 @@ do_test index-12.1 {
     INSERT INTO t4 VALUES('00000',7);
     SELECT a FROM t4 ORDER BY b;
   }
-} {0.0 0.0 abc -1.0 1.0 0 0}
+} {0 0 abc -1 1 0 0}
 do_test index-12.2 {
   execsql {
     SELECT a FROM t4 WHERE a==0 ORDER BY b
   }
-} {0.0 0.0 0 0}
+} {0 0 0 0}
 do_test index-12.3 {
   execsql {
     SELECT a FROM t4 WHERE a<0.5 ORDER BY b
   }
-} {0.0 0.0 -1.0 0 0}
+} {0 0 -1 0 0}
 do_test index-12.4 {
   execsql {
     SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
   }
-} {0.0 0.0 abc 1.0 0 0}
+} {0 0 abc 1 0 0}
 do_test index-12.5 {
   execsql {
     CREATE INDEX t4i1 ON t4(a);
     SELECT a FROM t4 WHERE a==0 ORDER BY b
   }
-} {0.0 0.0 0 0}
+} {0 0 0 0}
 do_test index-12.6 {
   execsql {
     SELECT a FROM t4 WHERE a<0.5 ORDER BY b
   }
-} {0.0 0.0 -1.0 0 0}
+} {0 0 -1 0 0}
 do_test index-12.7 {
   execsql {
     SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
   }
-} {0.0 0.0 abc 1.0 0 0}
+} {0 0 abc 1 0 0}
 integrity_check index-12.8
 
 # Make sure we cannot drop an automatically created index.
index e97e60a6fabca17c12d797ff3e1efae4c0f685a8..576fabdec12e6da238d641e0ee60e84d24f25f18 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is exercising the code in main.c.
 #
-# $Id: main.test,v 1.22 2005/10/23 11:29:40 drh Exp $
+# $Id: main.test,v 1.23 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -302,7 +302,7 @@ do_test main-3.3 {
     insert into T1 values(5.0E+03);
     select x*10 from T1 order by x*5;
   }
-} {-0.51 -0.5 0.05 0.5 5.0 500.0 500.0 500.0 5000.0 50000.0}
+} {-0.51 -0.5 0.05 0.5 5 500 500 500 5000 50000}
 do_test main-3.4 {
   set v [catch {execsql {create bogus}} msg]
   lappend v $msg
index 07fe13311b3d3f3acaee6d66adc860792311dedb..eb2664a2cbcf5a1b50354b5f4ca77723f324ac77 100644 (file)
@@ -13,7 +13,7 @@
 # This file implements tests for miscellanous features that were
 # left out of other test files.
 #
-# $Id: misc1.test,v 1.38 2005/09/08 10:37:01 drh Exp $
+# $Id: misc1.test,v 1.39 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -316,13 +316,13 @@ do_test misc1-10.7 {
 } {0 {}}
 do_test misc1-10.8 {
   execsql {SELECT x1 FROM manycol WHERE x0=100}
-} {102.0}
+} {102}
 do_test misc1-10.9 {
   catchsql "UPDATE manycol SET x1=x1+1 $::where AND rowid>0"
 } {0 {}}
 do_test misc1-10.10 {
   execsql {SELECT x1 FROM manycol WHERE x0=100}
-} {103.0}
+} {103}
 
 # Make sure the initialization works even if a database is opened while
 # another process has the database locked.
@@ -408,7 +408,7 @@ do_test misc1-12.9 {
 #  catchsql {
 #    SELECT * FROM t6 ORDER BY a COLLATE unknown;
 #  }
-#} {0 {0 0.0 y 0}}
+#} {0 {0 0 y 0}}
 do_test misc1-12.11 {
   execsql {
     CREATE TABLE t8(x TEXT COLLATE numeric, y INTEGER COLLATE text, z);
@@ -572,7 +572,7 @@ do_test misc1-17.1 {
     COMMIT;
     SELECT TestString FROM RealTable ORDER BY 1;
   }
-} {2.0 3.0}
+} {2 3}
 }
 
 finish_test
index c50d0791c66a648d0ae71ff081110e8487555098..d15ff3cc6824a6a013518e173a69c729fd310c2c 100644 (file)
@@ -13,7 +13,7 @@
 # This file implements tests for miscellanous features that were
 # left out of other test files.
 #
-# $Id: misc5.test,v 1.5 2005/08/23 11:31:26 drh Exp $
+# $Id: misc5.test,v 1.6 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -494,13 +494,13 @@ do_test misc5-5.1 {
 } 0.1
 do_test misc5-5.2 {
   execsql {SELECT 2. }
-} 2.0
+} 2
 do_test misc5-5.3 {
   execsql {SELECT 3.e0 }
-} 3.0
+} 3
 do_test misc5-5.4 {
   execsql {SELECT .4e+1}
-} 4.0
+} 4
 
 
 finish_test
index 54df546410deeda28297ac19972e5a4bb2b17572..851c2088d72465f2d447b0bc393bdf28c7403688 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is the ability to specify table and column names
 # as quoted strings.
 #
-# $Id: quote.test,v 1.5 2005/08/13 18:15:43 drh Exp $
+# $Id: quote.test,v 1.6 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -46,7 +46,7 @@ do_test quote-1.3.1 {
   catchsql {
     SELECT '!pqr', '#xyz'+5 FROM '@abc'
   }
-} {0 {!pqr 5.0}}
+} {0 {!pqr 5}}
 do_test quote-1.3.2 {
   catchsql {
     SELECT "!pqr", "#xyz"+5 FROM '@abc'
index 3aa605a6d2e79a1ceb7a93798077baf27b9537bf..c48458a51b120dcdbee342a03bba8a38fcef3f5d 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing aggregate functions and the
 # GROUP BY and HAVING clauses of SELECT statements.
 #
-# $Id: select3.test,v 1.16 2005/09/08 20:37:44 drh Exp $
+# $Id: select3.test,v 1.17 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -57,18 +57,18 @@ do_test select3-2.1 {
 do_test select3-2.2 {
   execsql {SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log}
 } {0 1 1 2 2 3 3 5 4 9 5 17}
-do_test select3-2.3 {
+do_test select3-2.3.1 {
   execsql {SELECT log, avg(n) FROM t1 GROUP BY log ORDER BY log}
 } {0 1.0 1 2.0 2 3.5 3 6.5 4 12.5 5 24.0}
-do_test select3-2.3 {
+do_test select3-2.3.2 {
   execsql {SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log}
-} {0 2.0 1 3.0 2 4.5 3 7.5 4 13.5 5 25.0}
+} {0 2 1 3 2 4.5 3 7.5 4 13.5 5 25}
 do_test select3-2.4 {
   execsql {SELECT log, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}
-} {0 0.0 1 0.0 2 0.5 3 1.5 4 3.5 5 7.0}
+} {0 0 1 0 2 0.5 3 1.5 4 3.5 5 7}
 do_test select3-2.5 {
   execsql {SELECT log*2+1, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}
-} {1 0.0 3 0.0 5 0.5 7 1.5 9 3.5 11 7.0}
+} {1 0 3 0 5 0.5 7 1.5 9 3.5 11 7}
 do_test select3-2.6 {
   execsql {
     SELECT log*2+1 as x, count(*) FROM t1 GROUP BY x ORDER BY x
index 4eb6f0ec15c031e3a8fbbf865a60edbc29e24b49..ea02ea1eaa195a00487d2d49911baed4846d2dad 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing SELECT statements that contain
 # subqueries in their FROM clause.
 #
-# $Id: select6.test,v 1.19 2005/09/07 22:48:16 drh Exp $
+# $Id: select6.test,v 1.20 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -186,7 +186,7 @@ do_test select6-3.5 {
   execsql {
     SELECT x,y,x+y FROM (SELECT avg(a) as 'x', avg(b) as 'y' FROM t2 WHERE a=4)
   }
-} {4.0 3.0 7.0}
+} {4.0 3.0 7}
 do_test select6-3.6 {
   execsql {
     SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)
@@ -217,14 +217,14 @@ do_test select6-3.10 {
     SELECT a,b,a+b FROM (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)
     ORDER BY a
   }
-} {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}
+} {1.0 1 2 2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23}
 do_test select6-3.11 {
   execsql {
     SELECT a,b,a+b FROM 
        (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)
     WHERE b<4 ORDER BY a
   }
-} {1.0 1 2.0 2.5 2 4.5 5.5 3 8.5}
+} {1.0 1 2 2.5 2 4.5 5.5 3 8.5}
 do_test select6-3.12 {
   execsql {
     SELECT a,b,a+b FROM 
@@ -238,7 +238,7 @@ do_test select6-3.13 {
        (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b HAVING a>1)
     ORDER BY a
   }
-} {2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23.0}
+} {2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23}
 do_test select6-3.14 {
   execsql {
     SELECT [count(*)],y FROM (SELECT count(*), y FROM t1 GROUP BY y)
index 0bafd0090da540978dd0ed2ef04e00ddab99fc4a..6d7a3685571fe60e2e71550583db57ce016f46b8 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the CREATE TABLE statement.
 #
-# $Id: sort.test,v 1.23 2005/09/01 17:47:52 drh Exp $
+# $Id: sort.test,v 1.24 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -62,10 +62,10 @@ do_test sort-1.4 {
 } {2 3 6 7 1 4 5 8}
 do_test sort-1.5 {
   execsql {SELECT flt FROM t1 ORDER BY flt}
-} {-11 -1.6 -0.0013442 0.123 2.15 3.141592653 123.0 4221.0}
+} {-11 -1.6 -0.0013442 0.123 2.15 3.141592653 123 4221}
 do_test sort-1.6 {
   execsql {SELECT flt FROM t1 ORDER BY flt DESC}
-} {4221.0 123.0 3.141592653 2.15 0.123 -0.0013442 -1.6 -11}
+} {4221 123 3.141592653 2.15 0.123 -0.0013442 -1.6 -11}
 do_test sort-1.7 {
   execsql {SELECT roman FROM t1 ORDER BY roman}
 } {I II III IV V VI VII VIII}
@@ -106,27 +106,27 @@ do_test sort-2.1.1 {
     UPDATE t1 SET v='x-2b' where v=='x-0.123';
     SELECT v FROM t1 ORDER BY v;
   }
-} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11}
+} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
 do_test sort-2.1.2 {
   execsql {
     SELECT v FROM t1 ORDER BY substr(v,2,999);
   }
-} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11}
+} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
 do_test sort-2.1.3 {
   execsql {
     SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0;
   }
-} {x-4221.0 x-123.0 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11}
+} {x-4221 x-123 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11}
 do_test sort-2.1.4 {
   execsql {
     SELECT v FROM t1 ORDER BY substr(v,2,999) DESC;
   }
-} {x11 x1.6 x0.0013442 x-4221.0 x-3.141592653 x-2b x-2.15 x-123.0}
+} {x11 x1.6 x0.0013442 x-4221 x-3.141592653 x-2b x-2.15 x-123}
 do_test sort-2.1.5 {
   execsql {
     SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0 DESC;
   }
-} {x11 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123.0 x-4221.0}
+} {x11 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123 x-4221}
 
 # This is a bug fix for 2.2.4.
 # Strings are normally mapped to upper-case for a caseless comparison.
@@ -196,17 +196,17 @@ do_test sort-4.6 {
   execsql {
     SELECT v FROM t1 ORDER BY 1;
   }
-} {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}
+} {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}
 do_test sort-4.7 {
   execsql {
     SELECT v FROM t1 ORDER BY 1 DESC;
   }
-} {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}
+} {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}
 do_test sort-4.8 {
   execsql {
     SELECT substr(v,2,99) FROM t1 ORDER BY 1;
   }
-} {-123.0 -2.15 -2b -3.141592653 -4.0e9 -4221.0 0.0013442 01234567890123456789 1.6 11 2.7 5.0e10}
+} {-123 -2.15 -2b -3.141592653 -4.0e9 -4221 0.0013442 01234567890123456789 1.6 11 2.7 5.0e10}
 #do_test sort-4.9 {
 #  execsql {
 #    SELECT substr(v,2,99)+0.0 FROM t1 ORDER BY 1;
@@ -362,7 +362,7 @@ do_test sort-8.1 {
     INSERT INTO t5 VALUES(100.0,'A2');
     SELECT * FROM t5 ORDER BY a, b;
   }
-} {100 A1 100.0 A2}
+} {100 A1 100 A2}
 
 
 ifcapable {bloblit} {
index eda9e71057ec636a821a379ad482fb33ba404b81..0a851f49658634388c6168837a78a9eaa9df8ebb 100644 (file)
@@ -12,7 +12,7 @@
 # it tests that the different storage classes (integer, real, text etc.)
 # all work correctly.
 #
-# $Id: types.test,v 1.14 2004/11/14 21:56:31 drh Exp $
+# $Id: types.test,v 1.15 2005/11/01 15:48:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -56,11 +56,13 @@ do_test types-1.1.0 {
 # literal were inserted into a column with affinity INTEGER, NUMERIC, TEXT
 # or NONE, respectively.
 set values {
-  { 5.0    integer real    text real    }
+  { 5.0    integer integer text integer }
+  { 5.1    real    real    text real    }
   { 5      integer integer text integer }
-  { '5.0'  integer real    text text    }
-  { '-5.0' integer real    text text    }
-  { '-5.0' integer real    text text    }
+  { '5.0'  integer integer text text    }
+  { '5.1'  real    real    text text    }
+  { '-5.0' integer integer text text    }
+  { '-5.0' integer integer text text    }
   { '5'    integer integer text text    }
   { 'abc'  text    text    text text    }
   { NULL   null    null    null null    }
@@ -221,13 +223,13 @@ do_test types-2.2.2 {
   execsql {
     SELECT a FROM t2;
   }
-} {0.0 12345.678 -12345.678}
+} {0 12345.678 -12345.678}
 
 # Check that all the record sizes are as we expected.
 do_test types-2.2.3 {
   set root [db eval {select rootpage from sqlite_master where name = 't2'}]
   record_sizes $root
-} {10 10 10}
+} {3 10 10}
 
 # Insert a NULL. This should be a two byte record.
 do_test types-2.3.1 {
index 027af46dff25d7518b67d90d22be3b393f1bac8f..ba0329205d553a0ae79e9f6a8ba24fad89dbd766 100644 (file)
@@ -12,7 +12,7 @@
 # of this file is testing the interaction of SQLite manifest types
 # with Tcl dual-representations.
 #
-# $Id: types3.test,v 1.1 2005/06/25 19:31:48 drh Exp $
+# $Id: types3.test,v 1.2 2005/11/01 15:48:25 drh Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -68,8 +68,12 @@ do_test types3-2.3 {
   set V [db one {SELECT 1234567890123456}]
   tcl_variable_type V
 } wideInt
-do_test types3-2.4 {
-  set V [db one {SELECT 1234567890123456.0}]
+do_test types3-2.4.1 {
+  set V [db one {SELECT 1234567890123456.1}]
+  tcl_variable_type V
+} wideInt
+do_test types3-2.4.2 {
+  set V [db one {SELECT 1234567890123.456}]
   tcl_variable_type V
 } double
 do_test types3-2.5 {