From: drh Date: Tue, 15 Apr 2008 04:02:40 +0000 (+0000) Subject: Fix a bug in the RTRIM collating sequence discovered while working X-Git-Tag: version-3.6.10~1167 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f3a367bf399767fe151becf2eaca42c036b1372;p=thirdparty%2Fsqlite.git Fix a bug in the RTRIM collating sequence discovered while working on condition/decision branch coverage. Increase test coverage of the date/time functions. (CVS 5010) FossilOrigin-Name: c5435f71efa0b34c759bac4a15fdf43abf39ddfc --- diff --git a/manifest b/manifest index 8a96ab11c9..2b8053dd66 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sout-of-range\stests\son\sthe\sfirst\sparameter\sto\ssqlite3_limit().\nAdd\sthe\sability\sto\srecord\stests\sthat\shave\sbeen\sskipped\sdue\sto\nconfiguration\slimitations.\s(CVS\s5009) -D 2008-04-15T02:36:34 +C Fix\sa\sbug\sin\sthe\sRTRIM\scollating\ssequence\sdiscovered\swhile\sworking\non\scondition/decision\sbranch\scoverage.\s\sIncrease\stest\scoverage\sof\nthe\sdate/time\sfunctions.\s(CVS\s5010) +D 2008-04-15T04:02:41 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -104,7 +104,7 @@ F src/insert.c 5208f16ddfc77d9e72bb30041a1d04a18b18a170 F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2 F src/legacy.c 8267890e6a0a71f13b680794520999c642299081 F src/loadext.c 5c20a5afeb154e68d62ed6d9c634add1b21387fd -F src/main.c 8f3ce9735280fc099d4b64e13ca0e0ce28f14fe9 +F src/main.c e025166b656a33dfa091a3d8cb99fb1172876a5f F src/malloc.c 12c1ae98ef1eff34b13c9eb526e0b7b479e1e820 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217 F src/mem1.c fc716ff521b6dd3e43eaa211967383308800e70a @@ -233,7 +233,7 @@ F test/collate6.test 8be65a182abaac8011a622131486dafb8076e907 F test/collate7.test e23677b1fd271505302643a98178952bb65b6f21 F test/collate8.test 7ed2461305ac959886a064dc1e3cf15e155a183f F test/collate9.test 0867eabc1222ab0bc308fc09a7fb30770334c3cd -F test/collateA.test 84ff3239d530c1a2c784159594b2ae05238e3ff7 +F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/colmeta.test 087c42997754b8c648819832241daf724f813322 F test/conflict.test bb29b052c60a1f7eb6382be77902061d1f305318 F test/corrupt.test 18c7a995b1af76a8c8600b996257f2c7b7bff083 @@ -251,7 +251,7 @@ F test/crash7.test e20a7b9ee1d16eaef7c94a4cb7ed2191b4d05970 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test 199cf68f44e5d9e87a0b8afc7130fdeb4def3272 F test/cse.test 4b8a49decaefccb835ecc67249277be491713f6c -F test/date.test 8db95a0ba2c8f4c8762ce66859a036c51959a6be +F test/date.test be0a3a30f5009b1cbc1a9c396b1fe96bd18522cc F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb F test/delete.test 57533e88e886608bf5ae0f394e14c2eb1b1f7754 F test/delete2.test c06be3806ba804bc8c6f134476816080280b40e3 @@ -629,7 +629,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 1863e87c40499ee3d9fd9cba6670e9a0e946d390 -R 326cf8a2b7ebf9f02937bb1cbd68fb2c +P b7ffc6f0f33b14430ab84a6c60110bc07514f056 +R 39eb77e983bc30708ab7dd070f56763f U drh -Z df93ea55892e12cf9b9e914f17244e03 +Z c185fe19fbf753e76e5d68ad2182c5d1 diff --git a/manifest.uuid b/manifest.uuid index cabe1a1e3a..1897bf45fa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b7ffc6f0f33b14430ab84a6c60110bc07514f056 \ No newline at end of file +c5435f71efa0b34c759bac4a15fdf43abf39ddfc \ No newline at end of file diff --git a/src/main.c b/src/main.c index 3c1a4e905f..e714722974 100644 --- a/src/main.c +++ b/src/main.c @@ -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.432 2008/04/15 02:36:34 drh Exp $ +** $Id: main.c,v 1.433 2008/04/15 04:02:41 drh Exp $ */ #include "sqliteInt.h" #include @@ -62,7 +62,7 @@ void sqlite3Coverage(int x){ ** Return true if the buffer z[0..n-1] contains all spaces. */ static int allSpaces(const char *z, int n){ - while( n>0 && z[--n]==' ' ){} + while( n>0 && z[n-1]==' ' ){ n--; } return n==0; } diff --git a/test/collateA.test b/test/collateA.test index 55166d28a9..3f7ebd9242 100644 --- a/test/collateA.test +++ b/test/collateA.test @@ -13,7 +13,7 @@ # focus of this script is the built-in RTRIM collating # API. # -# $Id: collateA.test,v 1.2 2008/01/21 16:47:16 drh Exp $ +# $Id: collateA.test,v 1.3 2008/04/15 04:02:41 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -25,18 +25,20 @@ do_test collateA-1.1 { b TEXT COLLATE BINARY, c TEXT COLLATE RTRIM ); - INSERT INTO t1 VALUES(1, 'hello','hello'); + INSERT INTO t1 VALUES(1, 'abcde','abcde'); INSERT INTO t1 VALUES(2, 'xyzzy ','xyzzy '); INSERT INTO t1 VALUES(3, 'xyzzy ','xyzzy '); INSERT INTO t1 VALUES(4, 'xyzzy ','xyzzy '); + INSERT INTO t1 VALUES(5, ' ', ' '); + INSERT INTO t1 VALUES(6, '', ''); SELECT count(*) FROM t1; } -} {4} +} {6} do_test collateA-1.2 { - execsql {SELECT a FROM t1 WHERE b='hello '} + execsql {SELECT a FROM t1 WHERE b='abcde '} } {} do_test collateA-1.3 { - execsql {SELECT a FROM t1 WHERE c='hello '} + execsql {SELECT a FROM t1 WHERE c='abcde '} } {1} do_test collateA-1.4 { execsql {SELECT a FROM t1 WHERE b='xyzzy'} @@ -77,6 +79,36 @@ do_test collateA-1.15 { do_test collateA-1.16 { execsql {SELECT ''<>' ' COLLATE RTRIM, ''<>' ' COLLATE BINARY, ''<>' '} } {0 1 1} +do_test collateA-1.17 { + execsql {SELECT a FROM t1 WHERE c='xyzz'} +} {} +do_test collateA-1.18 { + execsql {SELECT a FROM t1 WHERE c='xyzzyy '} +} {} +do_test collateA-1.19 { + execsql {SELECT a FROM t1 WHERE c='xyzz '} +} {} +do_test collateA-1.20 { + execsql {SELECT a FROM t1 WHERE c='abcd '} +} {} +do_test collateA-1.21 { + execsql {SELECT a FROM t1 WHERE c='abcd'} +} {} +do_test collateA-1.22 { + execsql {SELECT a FROM t1 WHERE c='abc'} +} {} +do_test collateA-1.23 { + execsql {SELECT a FROM t1 WHERE c='abcdef '} +} {} +do_test collateA-1.24 { + execsql {SELECT a FROM t1 WHERE c=''} +} {5 6} +do_test collateA-1.25 { + execsql {SELECT a FROM t1 WHERE c=' '} +} {5 6} +do_test collateA-1.26 { + execsql {SELECT a FROM t1 WHERE c=' '} +} {5 6} do_test collateA-2.1 { @@ -87,10 +119,10 @@ do_test collateA-2.1 { } } {ok} do_test collateA-2.2 { - execsql {SELECT a FROM t1 WHERE b='hello '} + execsql {SELECT a FROM t1 WHERE b='abcde '} } {} do_test collateA-2.3 { - execsql {SELECT a FROM t1 WHERE c='hello '} + execsql {SELECT a FROM t1 WHERE c='abcde '} } {1} do_test collateA-2.4 { execsql {SELECT a FROM t1 WHERE b='xyzzy'} @@ -113,6 +145,37 @@ do_test collateA-2.9 { do_test collateA-2.10 { execsql {SELECT a FROM t1 WHERE c='xyzzy '} } {2 3 4} +do_test collateA-2.17 { + execsql {SELECT a FROM t1 WHERE c='xyzz'} +} {} +do_test collateA-2.18 { + execsql {SELECT a FROM t1 WHERE c='xyzzyy '} +} {} +do_test collateA-2.19 { + execsql {SELECT a FROM t1 WHERE c='xyzz '} +} {} +do_test collateA-2.20 { + execsql {SELECT a FROM t1 WHERE c='abcd '} +} {} +do_test collateA-2.21 { + execsql {SELECT a FROM t1 WHERE c='abcd'} +} {} +do_test collateA-2.22 { + execsql {SELECT a FROM t1 WHERE c='abc'} +} {} +do_test collateA-2.23 { + execsql {SELECT a FROM t1 WHERE c='abcdef '} +} {} +do_test collateA-2.24 { + execsql {SELECT a FROM t1 WHERE c=''} +} {5 6} +do_test collateA-2.25 { + execsql {SELECT a FROM t1 WHERE c=' '} +} {5 6} +do_test collateA-2.26 { + execsql {SELECT a FROM t1 WHERE c=' '} +} {5 6} + do_test collateA-3.1 { db close @@ -123,10 +186,10 @@ do_test collateA-3.1 { } } {ok} do_test collateA-3.2 { - execsql {SELECT a FROM t1 WHERE b='hello '} + execsql {SELECT a FROM t1 WHERE b='abcde '} } {} do_test collateA-3.3 { - execsql {SELECT a FROM t1 WHERE c='hello '} + execsql {SELECT a FROM t1 WHERE c='abcde '} } {1} do_test collateA-3.4 { execsql {SELECT a FROM t1 WHERE b='xyzzy'} diff --git a/test/date.test b/test/date.test index ce0b84266e..caeb5b134f 100644 --- a/test/date.test +++ b/test/date.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing date and time functions. # -# $Id: date.test,v 1.25 2008/02/21 20:40:44 drh Exp $ +# $Id: date.test,v 1.26 2008/04/15 04:02:41 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -122,10 +122,20 @@ datetest 2.39 {datetime('2003-10-22 12:24','+1 abcdefghi')} NULL set sqlite_current_time 1199243045 datetest 2.40 {datetime()} {2008-01-02 03:04:05} set sqlite_current_time 0 - +datetest 2.41 {datetime('2003-10-22 12:24','23 seconds')} {2003-10-22 12:24:23} +datetest 2.42 {datetime('2003-10-22 12:24','345 second')} {2003-10-22 12:29:45} +datetest 2.43 {datetime('2003-10-22 12:24','4 second')} {2003-10-22 12:24:04} +datetest 2.44 {datetime('2003-10-22 12:24','56 second')} {2003-10-22 12:24:56} +datetest 2.45 {datetime('2003-10-22 12:24','60 second')} {2003-10-22 12:25:00} +datetest 2.46 {datetime('2003-10-22 12:24','70 second')} {2003-10-22 12:25:10} +datetest 2.47 {datetime('2003-10-22 12:24','8.6 seconds')} {2003-10-22 12:24:08} +datetest 2.48 {datetime('2003-10-22 12:24','9.4 second')} {2003-10-22 12:24:09} +datetest 2.49 {datetime('2003-10-22 12:24','0000 second')} {2003-10-22 12:24:00} +datetest 2.50 {datetime('2003-10-22 12:24','0001 second')} {2003-10-22 12:24:01} +datetest 2.51 {datetime('2003-10-22 12:24','nonsense')} NULL datetest 3.1 {strftime('%d','2003-10-31 12:34:56.432')} 31 -datetest 3.2.1 {strftime('%f','2003-10-31 12:34:56.432')} 56.432 +datetest 3.2.1 {strftime('pre%fpost','2003-10-31 12:34:56.432')} pre56.432post datetest 3.2.2 {strftime('%f','2003-10-31 12:34:59.9999999')} 59.999 datetest 3.3 {strftime('%H','2003-10-31 12:34:56.432')} 12 datetest 3.4 {strftime('%j','2003-10-31 12:34:56.432')} 304 @@ -139,7 +149,7 @@ datetest 3.11.1 {strftime('%W','2003-10-31 12:34:56.432')} 43 datetest 3.11.2 {strftime('%W','2004-01-01')} 00 datetest 3.11.3 {strftime('%W','2004-01-02')} 00 datetest 3.11.4 {strftime('%W','2004-01-03')} 00 -datetest 3.11.5 {strftime('%W','2004-01-04')} 00 +datetest 3.11.5 {strftime('abc%Wxyz','2004-01-04')} abc00xyz datetest 3.11.6 {strftime('%W','2004-01-05')} 01 datetest 3.11.7 {strftime('%W','2004-01-06')} 01 datetest 3.11.8 {strftime('%W','2004-01-07')} 01 @@ -176,6 +186,12 @@ datetest 3.16 "strftime('[repeat 200 %Y]','2003-10-31')" [repeat 200 2003] datetest 3.17 "strftime('[repeat 200 abc%m123]','2003-10-31')" \ [repeat 200 abc10123] +foreach c {a b c e g h i k l n o p q r t v x y z + A B C D E F G I K L N O P Q R T U V Z + 0 1 2 3 4 5 6 6 7 9 _} { + datetest 3.18.$c "strftime('%$c','2003-10-31')" NULL +} + # Ticket #2276. Make sure leading zeros are inserted where appropriate. # datetest 3.20 \