From d7d2f93cbbc43a55d9868159107206bde83c1309 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Sat, 1 Sep 2007 17:00:12 +0000 Subject: [PATCH] Remove code for calling the SQL function randstr() with 0 or 1 argument, as it is registered with sqlite as requiring exactly 2. Also test io errors in sqlite3_release_memory(). (CVS 4365) FossilOrigin-Name: 5842f68c1ba838f24e9ba02c818d308540d591a4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 28 +++++++++++++--------------- test/ioerr.test | 23 ++++++++++++++++++++++- 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index 0ed9054d08..11214b63c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\ssyncOk\sargument\sto\spager_recycle.\sNow\sthat\ssqlite3_memory_release\suses\sa\sglobal\slru\slist\sof\spage,\sit\sis\sno\slonger\srequired.\s(CVS\s4364) -D 2007-09-01T16:16:15 +C Remove\scode\sfor\scalling\sthe\sSQL\sfunction\srandstr()\swith\s0\sor\s1\sargument,\sas\sit\sis\sregistered\swith\ssqlite\sas\srequiring\sexactly\s2.\sAlso\stest\sio\serrors\sin\ssqlite3_release_memory().\s(CVS\s4365) +D 2007-09-01T17:00:13 F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -91,7 +91,7 @@ F src/date.c af235f38f50809abd0a96da3bb3e0cc32be6226e F src/delete.c 849846d06d29851dde0d9f424a5de5817eb140d1 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/expr.c 95f3674736ff4b3238f7f2d252fbd93aea55e610 -F src/func.c 10135a09d37f89b524bfea7c36368699e9c3b89a +F src/func.c 7c59882c72b2a2b7bf5a2e121f0727e7527bf7cd F src/hash.c 8fe2fa52bd17869c87748e42cff5b1e7fbf90822 F src/hash.h 3ad3da76bfb954978d227bf495568b0e6da2c19e F src/insert.c b11e5ca0d68bf2a7a56f47a052a0ee67dd4e2f89 @@ -326,7 +326,7 @@ F test/insert4.test 1e27f0a3e5670d5f03c1636f699aa44270945bca F test/interrupt.test 81555fb0f8179bb2d0dc7151fd75428223f93cf2 F test/intpkey.test af4fd826c4784ec5c93b444de07adea0254d0d30 F test/io.test f0203ae4a6d954ec843cb7e446f9774004b04c6a -F test/ioerr.test 491d42c49bbec598966d26b01ed7901f55e5ee2d +F test/ioerr.test 4b175825ed42b04f935e00f57cfb2a9f0c13de7d F test/ioerr2.test f938eadb12108048813869b86beee4a2f98e34b8 F test/join.test af0443185378b64878750aa1cf4b83c216f246b4 F test/join2.test f2171c265e57ee298a27e57e7051d22962f9f324 @@ -568,7 +568,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P fde6142b7bb33198b3d6b65cfbddfad61694b1fb -R 5e0055f11989e9e05101c27a19df02f2 +P fb27692ab10b22851b265348bb6b3e1dececd60f +R 8691eaca2d86eeb9c8f0223ed070263c U danielk1977 -Z 10eb73331132f5b8e253fba21e5676db +Z 57e05a1c340e3f153329a367979054dc diff --git a/manifest.uuid b/manifest.uuid index 47282e2c2d..998e406530 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fb27692ab10b22851b265348bb6b3e1dececd60f \ No newline at end of file +5842f68c1ba838f24e9ba02c818d308540d591a4 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 6a8ea56820..334dfd9fb7 100644 --- a/src/func.c +++ b/src/func.c @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.172 2007/08/30 16:30:27 danielk1977 Exp $ +** $Id: func.c,v 1.173 2007/09/01 17:00:13 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -1016,20 +1016,18 @@ static void randStr(sqlite3_context *context, int argc, sqlite3_value **argv){ ".-!,:*^+=_|?/<> "; int iMin, iMax, n, r, i; unsigned char zBuf[1000]; - if( argc>=1 ){ - iMin = sqlite3_value_int(argv[0]); - if( iMin<0 ) iMin = 0; - if( iMin>=sizeof(zBuf) ) iMin = sizeof(zBuf)-1; - }else{ - iMin = 1; - } - if( argc>=2 ){ - iMax = sqlite3_value_int(argv[1]); - if( iMax=sizeof(zBuf) ) iMax = sizeof(zBuf)-1; - }else{ - iMax = 50; - } + + /* It used to be possible to call randstr() with any number of arguments, + ** but now it is registered with SQLite as requiring exactly 2. + */ + assert(argc==2); + + iMin = sqlite3_value_int(argv[0]); + if( iMin<0 ) iMin = 0; + if( iMin>=sizeof(zBuf) ) iMin = sizeof(zBuf)-1; + iMax = sqlite3_value_int(argv[1]); + if( iMax=sizeof(zBuf) ) iMax = sizeof(zBuf)-1; n = iMin; if( iMax>iMin ){ sqlite3Randomness(sizeof(r), &r); diff --git a/test/ioerr.test b/test/ioerr.test index 4717b36c2c..9fb2668b09 100644 --- a/test/ioerr.test +++ b/test/ioerr.test @@ -15,7 +15,7 @@ # The tests in this file use special facilities that are only # available in the SQLite test fixture. # -# $Id: ioerr.test,v 1.31 2007/03/17 10:26:59 danielk1977 Exp $ +# $Id: ioerr.test,v 1.32 2007/09/01 17:00:13 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -266,4 +266,25 @@ do_ioerr_test ioerr-11 -erc 1 -sqlprep { UPDATE A SET Id = 2, Name = 'Name2' WHERE Id = 1; } +# Test that an io error encountered in a sync() caused by a call to +# sqlite3_release_memory() is handled Ok. Only try this if +# memory-management is enabled. +# +ifcapable memorymanage { + do_ioerr_test memmanage-ioerr1 -sqlprep { + BEGIN; + CREATE TABLE t1(a, b, c); + INSERT INTO t1 VALUES(randstr(50,50), randstr(100,100), randstr(10,10)); + INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1; + INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1; + INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1; + INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1; + INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1; + } -tclbody { + sqlite3_release_memory + } -sqlbody { + COMMIT; + } +} + finish_test -- 2.47.3