]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make the distinction between text and numeric data. (CVS 710)
authordrh <drh@noemail.net>
Tue, 13 Aug 2002 23:02:57 +0000 (23:02 +0000)
committerdrh <drh@noemail.net>
Tue, 13 Aug 2002 23:02:57 +0000 (23:02 +0000)
FossilOrigin-Name: 310ac4fbaf0ed63f98bfacb55259960be03b0c8b

17 files changed:
VERSION
manifest
manifest.uuid
src/main.c
src/util.c
src/vdbe.c
src/where.c
test/expr.test
test/func.test
test/index.test
test/limit.test
test/misc1.test
test/sort.test
test/table.test
test/version.test
www/changes.tcl
www/formatchng.tcl

diff --git a/VERSION b/VERSION
index ec1cf33c3f6e22d5833bed6199c520a9ee20a0fa..24ba9a38de68d00674ec97b283a967699716b9f4 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.6.3
+2.7.0
index 9f6c6603c20ac75b1e359309b9c5aab2068b650b..e7b4faaea7909f5cd6bb2bec867729357b93410c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,9 +1,9 @@
-C Documentation\sand\smakefile\supdates.\s(CVS\s709)
-D 2002-08-13T20:45:40
+C Make\sthe\sdistinction\sbetween\stext\sand\snumeric\sdata.\s(CVS\s710)
+D 2002-08-13T23:02:57
 F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
-F VERSION f860323f95b110e5af69b3754d006f39304390a0
+F VERSION a8c86d12b1459b66b47ef640f3f0c87822c25901
 F aclocal.m4 11faa843caa38fd451bc6aeb43e248d1723a269d
 F config.guess f38b1e93d1e0fa6f5a6913e9e7b12774b9232588
 F config.sub f14b07d544ca26b5d698259045136b783e18fc7f
@@ -28,7 +28,7 @@ F src/func.c e45cd908b9b723d9b91473d09e12c23f786b3fc2
 F src/hash.c 6a6236b89c8c060c65dabd300a1c8ce7c10edb72
 F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
 F src/insert.c 8aefc998c86a3bd53082e2f8fdd049345fcf3463
-F src/main.c 69f85a56200df5f5ce24ba38b6590d2a9c9f542b
+F src/main.c c7e313ef70d7e4339a6d8ba1deb31f7b51a3473d
 F src/md5.c 0ae1f3e2cac92d06fc6246d1b4b8f61a2fe66d3b
 F src/os.c 9665974085ebe1d40d56d1145045b3d64f12cbce
 F src/os.h 4a361fccfbc4e7609b3e1557f604f94c1e96ad10
@@ -51,10 +51,10 @@ F src/threadtest.c 72bce0a284647314847bbea44616ceb056bfb77f
 F src/tokenize.c b5500e193a82b5b9888fbf947efd90d3b4858178
 F src/trigger.c d88ab4d68d68955c217b38fb6717e090fbbf54a4
 F src/update.c f07e6ed2c517c92871e54d3f5886d1cf56121b11
-F src/util.c 7a99e754c44dd220e881122e30581c08b6d6adef
-F src/vdbe.c aa647946d08e54b71bfff9049ad31135b7af4a8e
+F src/util.c bdbf0aedcec21ede2248126bbbe734bcc070b7c8
+F src/vdbe.c aad57e622827dc864529f1609a8e94240d4ed92a
 F src/vdbe.h a9292f2b5fcecef924fa255fb74609e9cbc776c2
-F src/where.c c250b91886f820d88cfa7eed8f79a9ef24e4b2bb
+F src/where.c 9a6d2783cabead68a2b9e857521b0b841f2c1d55
 F test/all.test 9a6eb262393f74cb7fb09b17156491a34b941fe3
 F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
 F test/btree.test bf326f546a666617367a7033fa2c07451bd4f8e1
@@ -63,21 +63,21 @@ F test/btree3.test 9caa9e22491dd8cd8aa36d7ac3b48b089817c895
 F test/conflict.test 4518cc3c1c40c4ba74220d9ee814257ae7d09c47
 F test/copy.test 55d60a4d5ed342a0fa08b7cd07d46d43ea0d0d7f
 F test/delete.test 5821a95a66061ae09723a88938f23d10d8a881ad
-F test/expr.test 5fadd0bc87c223b424ce6752b576c1df346abf1f
-F test/func.test cae5f27e09736cfdcc978c3719ac1345405b848c
+F test/expr.test 565feb81bd39f703d4f9f9fa3534f05fae5094fe
+F test/func.test bed7ae7a3482df05db0f5eed2debdf25ac2d07fc
 F test/in.test e59461f1702b7387880bf08a0ce6bb777925d282
-F test/index.test 7503d903c4dffecbb415010298720720db8618e0
+F test/index.test 2a5a1b654f50ca0768fb10ae44b72e6a776b1f18
 F test/insert.test a122afb86911e77c181d912348866a5b1a61eeab
 F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
 F test/intpkey.test 69a6a9b41e541f27a2ffcd20264fb35adc3c2680
 F test/ioerr.test 57d9bffaca18b34f9e976f786eadc2591d6efc6a
 F test/join.test 90a620f2a2d015e5139d5a4cde0eeb4cf62523bf
-F test/limit.test 49b44e027a002c0ba336d723b448f07e05b04466
+F test/limit.test dd932f7572fe78e82ef621ef62f0cc480c7e541e
 F test/lock.test f1b55dc61632e99d241643cc8e7c03774f09f623
 F test/main.test c66b564554b770ee7fdbf6a66c0cd90329bc2c85
 F test/malloc.test 7ba32a9ebd3aeed52ae4aaa6d42ca37e444536fd
 F test/minmax.test 29bc5727c3e4c792d5c4745833dd4b505905819e
-F test/misc1.test eb47435bb2d9417f72afdb673d1883b9d783cf6b
+F test/misc1.test 064d7fbbe41285a381ce21832fed41ed245a6a2e
 F test/misuse.test a3aa2b18a97e4c409a1fcaff5151a4dd804a0162
 F test/notnull.test b1f3e42fc475b0b5827b27b2e9b562081995ff30
 F test/null.test 5c2b57307e4b6178aae825eb65ddbee01e76b0fd
@@ -93,9 +93,9 @@ F test/select3.test 3e98cec10e755226cbabdd7073ec37baab9ab148
 F test/select4.test 10ba54f24ef6ca7958a7045b001079378db2370c
 F test/select5.test c2a6c4a003316ee42cbbd689eebef8fdce0db2ac
 F test/select6.test efb8d0c07a440441db87db2c4ade6904e1407e85
-F test/sort.test 3b996ce7ca385f9cd559944ac0f4027a23aa546b
+F test/sort.test 742c07bda828eb16c95f3b1e83fdaea2c0d939b2
 F test/subselect.test f0fea8cf9f386d416d64d152e3c65f9116d0f50f
-F test/table.test bc571115def9be8adab6df93aca0b0c05c007eea
+F test/table.test dedb4d3a73340d811e309672ca14537daa542fb1
 F test/tableapi.test 3c80421a889e1d106df16e5800fa787f0d2914a6
 F test/tclsqlite.test 6f4b9760681c7dbca52a18d0ab46a1679cdc79b9
 F test/temptable.test 9ed7ec0288f887e132de66d90c428ad109105f67
@@ -108,7 +108,7 @@ F test/trigger4.test 9a5c1406344d743020c2753ae8d6dfe6eb75f818
 F test/unique.test 572aa791327c1e8d797932263e9d67f176cfdb44
 F test/update.test 7ffb062d580a972e7870d0f51d5af3ab9bfeae08
 F test/vacuum.test 059871b312eb910bbe49dafde1d01490cc2c6bbe
-F test/version.test f6a264303faba43a865714072d49f8d44c69e274
+F test/version.test c7057526e14c7e3da5718b88e7f566f4182fd5c5
 F test/view.test 3afca084dab44c7a5772d3c6a326adf93ad52050
 F test/where.test 1f87bec674bf85d74ac1cc5b2cd3d89be1e87b1d
 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
@@ -128,13 +128,13 @@ F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4
 F www/arch.tcl 679a0c48817f71bc91d5911ef386e5ef35d4f178
 F www/audit.tcl 90e09d580f79c7efec0c7d6f447b7ec5c2dce5c0
 F www/c_interface.tcl fb87b825b9032b9aa941694c5c9c5aee9424467e
-F www/changes.tcl 73451195af83332eff90feea6a61639ff9908155
+F www/changes.tcl df6f06b1aa97ef285c744bf19ec3efddf707b05f
 F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2
 F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060
 F www/download.tcl 29aa6679ca29621d10613f60ebbbda18f4b91c49
 F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
 F www/faq.tcl e5a752ff431a8408ae24a91ab88ded2dfe699e16
-F www/formatchng.tcl 502847353450adaf76d187d87374bce20dd07e0e
+F www/formatchng.tcl b4449e065d2da38b6563bdf12cf46cfe1d4d765e
 F www/index.tcl 47945cc79706e9f2caf797330412c112d54ad72b
 F www/lang.tcl 8c3d0bda030f110c754b5edbad75eddf5dbe2ed1
 F www/mingw.tcl f1c7c0a7f53387dd9bb4f8c7e8571b7561510ebc
@@ -143,7 +143,7 @@ F www/speed.tcl 7fc83f1b018e1ecc451838449542c3079ed12425
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P f9d3d4c1230a7f1176b2002d72e94857e251c04e
-R d02766c7d8bb513006dc1e531944f320
+P 92c403f485390bbd83a5be472e61c974f76d46b1
+R 4eff7fd5f3310391432b7a4cfb68c2be
 U drh
-Z ee2dcaa9cadd52a5fbd5a9424f9bf06e
+Z 8efada5c2bc32cebfca6eea0d127d8d7
index 99427081384e69f3ef53abd7078a5aba2fc6dd7b..fded00607fbdb4d5796aba9c4c101891860abe0a 100644 (file)
@@ -1 +1 @@
-92c403f485390bbd83a5be472e61c974f76d46b1
\ No newline at end of file
+310ac4fbaf0ed63f98bfacb55259960be03b0c8b
\ No newline at end of file
index 1bb740ffd830b05c8f85226965f3dcce8481f255..1924c8e16a2f7d2dafd5e56a629e3c2516196e05 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.96 2002/08/13 20:45:41 drh Exp $
+** $Id: main.c,v 1.97 2002/08/13 23:02:57 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -280,8 +280,8 @@ int sqliteInit(sqlite *db, char **pzErrMsg){
   */
   if( db->file_format==0 ){
     /* This happens if the database was initially empty */
-    db->file_format = 3;
-  }else if( db->file_format>3 ){
+    db->file_format = 4;
+  }else if( db->file_format>4 ){
     sqliteBtreeCloseCursor(curMain);
     sqliteSetString(pzErrMsg, "unsupported file format", 0);
     return SQLITE_ERROR;
@@ -405,7 +405,7 @@ sqlite *sqlite_open(const char *zFilename, int mode, char **pzErrMsg){
       &zErr);
     if( rc==SQLITE_OK ){
       sqliteBtreeGetMeta(db->pBe, meta);
-      meta[2] = 3;
+      meta[2] = 4;
       sqliteBtreeUpdateMeta(db->pBe, meta);
       sqlite_exec(db, "COMMIT", 0, 0, 0);
     }
index 21736e9ea348e3ee1801a0d420a990e9ea107c76..11f9f752e98ec0d54481f17c2c180ea16617f410 100644 (file)
@@ -14,7 +14,7 @@
 ** This file contains functions for allocating memory, comparing
 ** strings, and stuff like that.
 **
-** $Id: util.c,v 1.47 2002/07/05 21:42:37 drh Exp $
+** $Id: util.c,v 1.48 2002/08/13 23:02:57 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -443,6 +443,7 @@ int sqliteStrNICmp(const char *zLeft, const char *zRight, int N){
   return N<0 ? 0 : *a - *b;
 }
 
+#if 0  /* NOT USED */
 /* 
 ** The sortStrCmp() function below is used to order elements according
 ** to the ORDER BY clause of a SELECT.  The sort order is a little different
@@ -622,6 +623,7 @@ static int sortStrCmp(const char *atext, const char *btext, int useCase){
   }
   return result;
 }
+#endif /* NOT USED */
 
 /*
 ** Return TRUE if z is a pure numeric string.  Return FALSE if the
@@ -651,15 +653,17 @@ static int sqliteIsNumber(const char *z){
 }
 
 /* This comparison routine is what we use for comparison operations
-** in an SQL expression.  (Ex:  name<'Hello' or value<5). 
+** between numeric values in an SQL expression.  "Numeric" is a little
+** bit misleading here.  What we mean is that the strings have a
+** type of "numeric" from the point of view of SQL.  The strings
+** do not necessarily contain numbers.  They could contain text.
 **
-** Numerical strings compare in numerical order.  Numerical strings
-** are always less than non-numeric strings.  Non-numeric strings
-** compare in lexigraphical order (the same order as strcmp()).
-**
-** This is NOT the comparison function used for sorting.  The sort
-** order is a little bit different.  See sqliteSortCompare below
-** for additional information.
+** If the input strings both look like actual numbers then they
+** compare in numerical order.  Numerical strings are always less 
+** than non-numeric strings so if one input string looks like a
+** number and the other does not, then the one that looks like
+** a number is the smaller.  Non-numeric strings compare in 
+** lexigraphical order (the same order as strcmp()).
 */
 int sqliteCompare(const char *atext, const char *btext){
   int result;
@@ -696,16 +700,16 @@ int sqliteCompare(const char *atext, const char *btext){
 
 /*
 ** This routine is used for sorting.  Each key is a list of one or more
-** null-terminated strings.  The list is terminated by two nulls in
-** a row.  For example, the following text is key with three strings:
+** null-terminated elements.  The list is terminated by two nulls in
+** a row.  For example, the following text is a key with three elements
 **
-**            +one\000-two\000+three\000\000
+**            Aone\000Dtwo\000Athree\000\000
 **
-** Both arguments will have the same number of strings.  This routine
+** Both arguments will have the same number of elements.  This routine
 ** returns negative, zero, or positive if the first argument is less
 ** than, equal to, or greater than the first.  (Result is a-b).
 **
-** Each string begins with one of the characters "+", "-", "A", "D".
+** Each element begins with one of the characters "+", "-", "A", "D".
 ** This character determines the sort order and collating sequence:
 **
 **     +      Sort numerically in ascending order
@@ -715,20 +719,21 @@ int sqliteCompare(const char *atext, const char *btext){
 **
 ** For the "+" and "-" sorting, pure numeric strings (strings for which the
 ** isNum() function above returns TRUE) always compare less than strings
-** that are not pure numerics.  Within non-numeric strings, substrings
-** of digits compare in numerical order.  Finally, case is used only
-** to break a tie.
+** that are not pure numerics.  Non-numeric strings compare in memcmp()
+** order.  This is the same sort order as the sqliteCompare() function
+** above generates.
 **
-** Note that the sort order imposed by the rules above is different
-** from the ordering defined by the "<", "<=", ">", and ">=" operators
-** of expressions.  The operators compare non-numeric strings in
-** lexigraphical order.  This routine does the additional processing
-** to sort substrings of digits into numerical order and to use case
-** only as a tie-breaker.
+** The last point is a change from version 2.6.3 to version 2.7.0.  In
+** version 2.6.3 and earlier, substrings of digits compare in numerical 
+** and case was used only to break a tie.
 **
-** The special rules above apply only to numeric sorting, when the
-** prefix is "+" or "-".  If the prefix is "A" or "D" then plain old
-** "strcmp()" is used for the comparison.
+** Elements that begin with 'A' or 'D' compare in memcmp() order regardless
+** of whether or not they look like a number.
+**
+** Note that the sort order imposed by the rules above is the same
+** from the ordering defined by the "<", "<=", ">", and ">=" operators
+** of expressions and for indices.  This was not the case for version
+** 2.6.3 and earlier.
 */
 int sqliteSortCompare(const char *a, const char *b){
   int len;
@@ -770,13 +775,8 @@ int sqliteSortCompare(const char *a, const char *b){
         res = +1;
         break;
       }else{
-        res = sortStrCmp(&a[1],&b[1],0);
-        if( res==0 ){
-          res = sortStrCmp(&a[1],&b[1],1);
-        }
-        if( res!=0 ){
-          break;
-        }
+        res = strcmp(&a[1],&b[1]);
+        if( res ) break;
       }
     }
     len = strlen(&a[1]) + 2;
index 9697e4d24d25064a3ad97bcde06bc9d9c4d16ec0..637905c425487a4c66ce60730de3843442ed9673 100644 (file)
@@ -30,7 +30,7 @@
 ** But other routines are also provided to help in building up
 ** a program instruction by instruction.
 **
-** $Id: vdbe.c,v 1.167 2002/07/31 19:50:27 drh Exp $
+** $Id: vdbe.c,v 1.168 2002/08/13 23:02:57 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -2308,12 +2308,12 @@ case OP_StrGe: {
     c = strcmp(zStack[nos], zStack[tos]);
   }
   switch( pOp->opcode ){
-    case OP_Eq:    c = c==0;     break;
-    case OP_Ne:    c = c!=0;     break;
-    case OP_Lt:    c = c<0;      break;
-    case OP_Le:    c = c<=0;     break;
-    case OP_Gt:    c = c>0;      break;
-    default:       c = c>=0;     break;
+    case OP_StrEq:    c = c==0;     break;
+    case OP_StrNe:    c = c!=0;     break;
+    case OP_StrLt:    c = c<0;      break;
+    case OP_StrLe:    c = c<=0;     break;
+    case OP_StrGt:    c = c>0;      break;
+    default:          c = c>=0;     break;
   }
   POPSTACK;
   POPSTACK;
index dfbbbafcb7352a52ae5fa18c49dc9ed00d5fb994..8211d4239259c7d487f1c932ad4a5b35390ee61e 100644 (file)
@@ -13,7 +13,7 @@
 ** the WHERE clause of SQL statements.  Also found here are subroutines
 ** to generate VDBE code to evaluate expressions.
 **
-** $Id: where.c,v 1.60 2002/08/13 13:15:51 drh Exp $
+** $Id: where.c,v 1.61 2002/08/13 23:02:58 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -749,6 +749,7 @@ WhereInfo *sqliteWhereBegin(
       pLevel->iMem = pParse->nMem++;
       cont = pLevel->cont = sqliteVdbeMakeLabel(v);
       sqliteVdbeAddOp(v, OP_MakeKey, nColumn, 0);
+      sqliteAddIdxKeyType(v, pIdx);
       if( nColumn==pIdx->nColumn ){
         sqliteVdbeAddOp(v, OP_MemStore, pLevel->iMem, 0);
         testOp = OP_IdxGT;
@@ -931,6 +932,7 @@ WhereInfo *sqliteWhereBegin(
       if( testOp!=OP_Noop ){
         pLevel->iMem = pParse->nMem++;
         sqliteVdbeAddOp(v, OP_MakeKey, nEqColumn + (score & 1), 0);
+        sqliteAddIdxKeyType(v, pIdx);
         if( leFlag ){
           sqliteVdbeAddOp(v, OP_IncrKey, 0, 0);
         }
@@ -975,6 +977,7 @@ WhereInfo *sqliteWhereBegin(
       cont = pLevel->cont = sqliteVdbeMakeLabel(v);
       if( nEqColumn>0 || (score&2)!=0 ){
         sqliteVdbeAddOp(v, OP_MakeKey, nEqColumn + ((score&2)!=0), 0);
+        sqliteAddIdxKeyType(v, pIdx);
         if( !geFlag ){
           sqliteVdbeAddOp(v, OP_IncrKey, 0, 0);
         }
index c672988cb7e83bad8314131e8f409b6d2450dba2..8ec0c83d1473d5fc4855a405f8fa11dc7de4ebad 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.25 2002/06/29 02:20:09 drh Exp $
+# $Id: expr.test,v 1.26 2002/08/13 23:02:58 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -189,12 +189,22 @@ test_expr expr-4.1 {t1='abc', t2='Abc'} {t1<t2} 0
 test_expr expr-4.2 {t1='abc', t2='Abc'} {t1>t2} 1
 test_expr expr-4.3 {t1='abc', t2='Bbc'} {t1<t2} 0
 test_expr expr-4.4 {t1='abc', t2='Bbc'} {t1>t2} 1
-test_expr expr-4.5 {t1='0', t2='0.0'} {t1==t2} 1
-test_expr expr-4.6 {t1='0.000', t2='0.0'} {t1==t2} 1
+test_expr expr-4.5 {t1='0', t2='0.0'} {t1==t2} 0
+test_expr expr-4.6 {t1='0.000', t2='0.0'} {t1==t2} 0
 test_expr expr-4.7 {t1=' 0.000', t2=' 0.0'} {t1==t2} 0
 test_expr expr-4.8 {t1='0.0', t2='abc'} {t1<t2} 1
 test_expr expr-4.9 {t1='0.0', t2='abc'} {t1==t2} 0
-test_expr expr-4.10 {t1='0.0', t2='abc'} {t1>t2} 0
+test_expr expr-4.10 {r1='0.0', r2='abc'} {r1>r2} 0
+test_expr expr-4.11 {r1='abc', r2='Abc'} {r1<r2} 0
+test_expr expr-4.12 {r1='abc', r2='Abc'} {r1>r2} 1
+test_expr expr-4.13 {r1='abc', r2='Bbc'} {r1<r2} 0
+test_expr expr-4.14 {r1='abc', r2='Bbc'} {r1>r2} 1
+test_expr expr-4.15 {r1='0', r2='0.0'} {r1==r2} 1
+test_expr expr-4.16 {r1='0.000', r2='0.0'} {r1==r2} 1
+test_expr expr-4.17 {r1=' 0.000', r2=' 0.0'} {r1==r2} 0
+test_expr expr-4.18 {r1='0.0', r2='abc'} {r1<r2} 1
+test_expr expr-4.19 {r1='0.0', r2='abc'} {r1==r2} 0
+test_expr expr-4.20 {r1='0.0', r2='abc'} {r1>r2} 0
 
 test_expr expr-5.1 {t1='abc', t2='xyz'} {t1 LIKE t2} 0
 test_expr expr-5.2 {t1='abc', t2='ABC'} {t1 LIKE t2} 1
index 32cfb395b50d5f0baa44d21fec7ddd0fad24620d..5f37fe66aeb2505734bbcd8ef88e6cc047881157 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.14 2002/07/01 00:31:36 drh Exp $
+# $Id: func.test,v 1.15 2002/08/13 23:02:58 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -107,37 +107,37 @@ do_test func-3.0 {
     execsql "INSERT INTO tbl1 VALUES('$word')"
   }
   execsql {SELECT t1 FROM tbl1 ORDER BY t1}
-} "characters contains hi\u1234ho UTF-8"
+} "UTF-8 characters contains hi\u1234ho"
 do_test func-3.1 {
   execsql {SELECT length(t1) FROM tbl1 ORDER BY t1}
-} {10 8 5 5}
+} {5 10 8 5}
 do_test func-3.2 {
   execsql {SELECT substr(t1,1,2) FROM tbl1 ORDER BY t1}
-} {ch co hi UT}
+} {UT ch co hi}
 do_test func-3.3 {
   execsql {SELECT substr(t1,1,3) FROM tbl1 ORDER BY t1}
-} "cha con hi\u1234 UTF"
+} "UTF cha con hi\u1234"
 do_test func-3.4 {
   execsql {SELECT substr(t1,2,2) FROM tbl1 ORDER BY t1}
-} "ha on i\u1234 TF"
+} "TF ha on i\u1234"
 do_test func-3.5 {
   execsql {SELECT substr(t1,2,3) FROM tbl1 ORDER BY t1}
-} "har ont i\u1234h TF-"
+} "TF- har ont i\u1234h"
 do_test func-3.6 {
   execsql {SELECT substr(t1,3,2) FROM tbl1 ORDER BY t1}
-} "ar nt \u1234h F-"
+} "F- ar nt \u1234h"
 do_test func-3.7 {
   execsql {SELECT substr(t1,4,2) FROM tbl1 ORDER BY t1}
-} "ra ta ho -8"
+} "-8 ra ta ho"
 do_test func-3.8 {
   execsql {SELECT substr(t1,-1,1) FROM tbl1 ORDER BY t1}
-} "s s o 8"
+} "8 s s o"
 do_test func-3.9 {
   execsql {SELECT substr(t1,-3,2) FROM tbl1 ORDER BY t1}
-} "er in \u1234h F-"
+} "F- er in \u1234h"
 do_test func-3.10 {
   execsql {SELECT substr(t1,-4,3) FROM tbl1 ORDER BY t1}
-} "ter ain i\u1234h TF-"
+} "TF- ter ain i\u1234h"
 do_test func-3.99 {
   execsql {DELETE FROM tbl1}
   foreach word {this program is free software} {
index 10e65618e2f10d5a598b489ce3a8e565a7f39b21..dc20dbd750064bda34d02a08d3d53af756cfb167 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.19 2002/07/18 00:34:13 drh Exp $
+# $Id: index.test,v 1.20 2002/08/13 23:02:58 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -74,12 +74,12 @@ do_test index-2.2 {
 #
 set r {}
 for {set i 1} {$i<100} {incr i} {
-  lappend r index$i
+  lappend r [format index%02d $i]
 }
 do_test index-3.1 {
   execsql {CREATE TABLE test1(f1 int, f2 int, f3 int, f4 int, f5 int)}
   for {set i 1} {$i<100} {incr i} {
-    set sql "CREATE INDEX index$i ON test1(f[expr {($i%5)+1}])"
+    set sql "CREATE INDEX [format index%02d $i] ON test1(f[expr {($i%5)+1}])"
     execsql $sql
   }
   execsql {SELECT name FROM sqlite_master 
index bc157fdf66e28e63f5f3fb71eb910d4a3da16a4e..2d655e80e9f034f02a6acffe66be3f6722181cc1 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing the LIMIT ... OFFSET ... clause
 #  of SELECT statements.
 #
-# $Id: limit.test,v 1.4 2002/06/21 23:01:51 drh Exp $
+# $Id: limit.test,v 1.5 2002/08/13 23:02:58 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -115,6 +115,6 @@ do_test limit-4.3 {
     FROM t3 LIMIT 1000;
     SELECT x FROM t4 ORDER BY y DESC LIMIT 1 OFFSET 999;
   }
-} {1}
+} {1000}
 
 finish_test
index 41693c796515d946bf30b2c370a78246fb787c9b..d779605787979399ce77433badf3c185421f6b75 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.11 2002/07/30 18:43:42 drh Exp $
+# $Id: misc1.test,v 1.12 2002/08/13 23:02:58 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -39,7 +39,7 @@ do_test misc1-1.1 {
 do_test misc1-1.2 {
   execsql {SELECT x0, x10, x25, x50, x75 FROM manycol}
 } {0 10 25 50 75}
-do_test misc1-1.3 {
+do_test misc1-1.3.1 {
   for {set j 100} {$j<=1000} {incr j 100} {
     set cmd "INSERT INTO manycol VALUES($j"
     for {set i 1} {$i<=99} {incr i} {
@@ -48,8 +48,11 @@ do_test misc1-1.3 {
     append cmd ")"
     execsql $cmd
   }
-  execsql {SELECT x50 FROM manycol ORDER BY x80}
+  execsql {SELECT x50 FROM manycol ORDER BY x80+0}
 } {50 150 250 350 450 550 650 750 850 950 1050}
+do_test misc1-1.3.2 {
+  execsql {SELECT x50 FROM manycol ORDER BY x80}
+} {1050 150 250 350 450 550 650 750 50 850 950}
 do_test misc1-1.4 {
   execsql {SELECT x75 FROM manycol WHERE x50=350}
 } 375
index 5d37881f8e606668c1e37100b846b01de829802c..049797b13471c0d7975430417da69ffad5dd1e6e 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.4 2002/01/22 14:11:30 drh Exp $
+# $Id: sort.test,v 1.5 2002/08/13 23:02:58 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -101,25 +101,36 @@ do_test sort-1.11 {
 # These tests are designed to reach some hard-to-reach places
 # inside the string comparison routines.
 #
-do_test sort-2.1 {
+# (Later) The sorting behavior changed in 2.7.0.  But we will
+# keep these tests.  You can never have too many test cases!
+#
+do_test sort-2.1.1 {
   execsql {
     UPDATE t1 SET v='x' || -flt;
     UPDATE t1 SET v='x-2b' where v=='x-0.123';
     SELECT v FROM t1 ORDER BY v;
   }
-} {x-2b x-2.15 x-3.141592653 x-123 x-4221 x0.0013442 x1.6 x11}
-do_test sort-2.2 {
+} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
+do_test sort-2.1.2 {
   execsql {
-    UPDATE t1 SET v='x-2_' where v=='x0.0013442';
-    SELECT v FROM t1 ORDER BY v;
+    SELECT v FROM t1 ORDER BY substr(v,2,999);
   }
-} {x-2_ x-2b x-2.15 x-3.141592653 x-123 x-4221 x1.6 x11}
-do_test sort-2.3 {
+} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
+do_test sort-2.1.3 {
   execsql {
-    UPDATE t1 SET v='x ' || (-1.3+0.01*n);
-    SELECT v FROM t1 ORDER BY v;
+    SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0;
+  }
+} {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 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;
   }
-} {{x -1.29} {x -1.28} {x -1.27} {x -1.26} {x -1.25} {x -1.24} {x -1.23} {x -1.22}}
+} {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.
@@ -154,5 +165,58 @@ do_test sort-3.4 {
   }
 } {agna 3 aglientu 1 aglie` 2}
 
+# Version 2.7.0 testing.
+#
+do_test sort-4.1 {
+  execsql {
+    INSERT INTO t1 VALUES(9,'x2.7',3,'IX',4.0e5);
+    INSERT INTO t1 VALUES(10,'x5.0e10',3,'X',-4.0e5);
+    INSERT INTO t1 VALUES(11,'x-4.0e9',3,'XI',4.1e4);
+    INSERT INTO t1 VALUES(12,'x01234567890123456789',3,'XII',-4.2e3);
+    SELECT n FROM t1 ORDER BY n;
+  }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_test sort-4.2 {
+  execsql {
+    SELECT n||'' FROM t1 ORDER BY 1;
+  }
+} {1 10 11 12 2 3 4 5 6 7 8 9}
+do_test sort-4.3 {
+  execsql {
+    SELECT n+0 FROM t1 ORDER BY 1;
+  }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_test sort-4.4 {
+  execsql {
+    SELECT n||'' FROM t1 ORDER BY 1 DESC;
+  }
+} {9 8 7 6 5 4 3 2 12 11 10 1}
+do_test sort-4.5 {
+  execsql {
+    SELECT n+0 FROM t1 ORDER BY 1 DESC;
+  }
+} {12 11 10 9 8 7 6 5 4 3 2 1}
+do_test sort-4.6 {
+  execsql {
+    SELECT v FROM t1 ORDER BY 1;
+  }
+} {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 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 -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;
+  }
+} {-4000000000 -4221 -123 -3.141592653 -2.15 -2 0.0013442 1.6 2.7 11 50000000000 1.23456789012346e+18}
+
+
 
 finish_test
index c4b432070fb76324465dbdac34862a2821fc74de..7b1d9ae29688e2c77593d3b518de807de9fdcc12 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: table.test,v 1.18 2002/07/05 21:42:38 drh Exp $
+# $Id: table.test,v 1.19 2002/08/13 23:02:58 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -192,11 +192,11 @@ do_test table-3.6 {
 #
 set r {}
 for {set i 1} {$i<=100} {incr i} {
-  lappend r test$i
+  lappend r [format test%03d $i]
 }
 do_test table-4.1 {
   for {set i 1} {$i<=100} {incr i} {
-    set sql "CREATE TABLE test$i ("
+    set sql "CREATE TABLE [format test%03d $i] ("
     for {set k 1} {$k<$i} {incr k} {
       append sql "field$k text,"
     }
@@ -215,12 +215,12 @@ do_test table-4.1b {
 #
 set r {}
 for {set i 1} {$i<=100} {incr i 2} {
-  lappend r test$i
+  lappend r [format test%03d $i]
 }
 #execsql {--vdbe-trace-on--}
 do_test table-4.2 {
   for {set i 2} {$i<=100} {incr i 2} {
-    set sql "DROP TABLE TEST$i"
+    set sql "DROP TABLE [format TEST%03d $i]"
     execsql $sql
   }
   execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
@@ -231,7 +231,7 @@ do_test table-4.2 {
 #
 do_test table-4.3 {
   for {set i 1} {$i<=100} {incr i 2} {
-    set sql "DROP TABLE test$i"
+    set sql "DROP TABLE [format test%03d $i]"
     execsql $sql
   }
   execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
@@ -240,9 +240,9 @@ do_test table-4.3 {
 # Try to drop a table that does not exist
 #
 do_test table-5.1 {
-  set v [catch {execsql {DROP TABLE test9}} msg]
+  set v [catch {execsql {DROP TABLE test009}} msg]
   lappend v $msg
-} {1 {no such table: test9}}
+} {1 {no such table: test009}}
 
 # Try to drop sqlite_master
 #
index 30a39cc13872fc84bf69486df40838e39f6a6a24..e131cf44cb3253a4912b492ae4226e1268194908 100644 (file)
 # focus of this file is testing the ability of the library to detect
 # past or future file format version numbers and respond appropriately.
 #
-# $Id: version.test,v 1.5 2002/08/11 20:10:49 drh Exp $
+# $Id: version.test,v 1.6 2002/08/13 23:02:59 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 
 # Current file format version
-set VX 3
+set VX 4
 
 # Create a new database
 #
index 584c0ade6ab300b614b9b98cf6bcdd584787486d..0653ccb6b38122690efa4a276551113121412ccf 100644 (file)
@@ -25,6 +25,12 @@ proc chng {date desc} {
   puts "<DD><P><UL>$desc</UL></P></DD>"
 }
 
+chng {2002 Aug ?? (2.7.0)} {
+<li>Make a distinction between numeric and text values when sorting.
+    Text values sort according to memcmp().  Numeric values sort in
+    numeric order.</li>
+}
+
 chng {2002 Aug 12 (2.6.3)} {
 <li>Add the ability to read both little-endian and big-endian databases.
     So database created under SunOS or MacOSX can be read and written
index 41288d45299a37bb421859915383eb2ce39fbf9c..9456c1b9819d8fe2bb0fbe30991a75eb4aea11a4 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Run this Tcl script to generate the formatchng.html file.
 #
-set rcsid {$Id: formatchng.tcl,v 1.6 2002/07/18 02:07:08 drh Exp $ }
+set rcsid {$Id: formatchng.tcl,v 1.7 2002/08/13 23:02:59 drh Exp $ }
 
 puts {<html>
 <head>
@@ -136,6 +136,27 @@ occurred since version 1.0.0:
   upgraded to the new format.</p>
   </td>
 </tr>
+<tr>
+  <td valign="top">2.6.3 to 2.7.0</td>
+  <td valign="top">2002-Aug-13</td>
+  <td><p>Beginning with version 2.7.0, SQLite understands two different
+  datatypes: text and numeric.  Text data sorts in memcmp() order.
+  Numeric data sorts in numerical order if it looks like a number,
+  or in memcmp() order if it does not.</p>
+
+  <p>When SQLite version 2.7.0 or later opens a 2.6.3 or earlier database,
+  it assumes all columns of all tables have type "numeric".  For 2.7.0
+  and later databases, columns have type "text" if their datatype
+  string contains the substrings "char" or "clob" or "blob" or "text".
+  Otherwise they are of type "numeric".</p>
+
+  <p>Because "text" columns have a different sort order from numeric,
+  indices on "text" columns occur in a different order for version
+  2.7.0 and later database.  Hence version 2.6.3 and earlier of SQLite 
+  will be unable to read a 2.7.0 or later database.  But version 2.7.0
+  and later of SQLite will read earlier database version.</p>
+  </td>
+</tr>
 </table>
 </blockquote>