From: shaneh Date: Thu, 31 Mar 2011 13:14:12 +0000 (+0000) Subject: Tests and bug fixes for SELECT multiplex_control(op, val); X-Git-Tag: version-3.7.6~62^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d8ce22bbb7cb52e8bd3c19e4cddbc98821525217;p=thirdparty%2Fsqlite.git Tests and bug fixes for SELECT multiplex_control(op, val); Add tests and fixes for SELECT multiplex_control(op, val); FossilOrigin-Name: fee9734c193a8bec9599e02e16938179e642bf5e --- diff --git a/manifest b/manifest index 266e9254d8..d4d42b146b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\stest\scases;\s\sRound\schunk\ssize\sup\sto\sa\smultiple\sof\smax\spage\ssize; -D 2011-03-31T05:31:24.274 +C Tests\sand\sbug\sfixes\sfor\sSELECT\smultiplex_control(op,\sval);\nAdd\stests\sand\sfixes\sfor\sSELECT\smultiplex_control(op,\sval); +D 2011-03-31T13:14:12.476 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -209,8 +209,8 @@ F src/test_intarray.h 489edb9068bb926583445cb02589344961054207 F src/test_journal.c 785edd54f963aefb3c1628124170a56697c68c70 F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e F src/test_malloc.c fd6188b1501c0010fb4241ddc9f0d5ac402c688d -F src/test_multiplex.c 6edf785c1ca9468f7d5ead21e73aeec350931588 -F src/test_multiplex.h 7bb4e7505e38996125d346177eab7ac4f8a2cbef +F src/test_multiplex.c 07dff88008c801899680eec3b9b0ea30be9fba62 +F src/test_multiplex.h bf7b2d303688c32cdd1cee3ffdc377f13391e311 F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec F src/test_osinst.c f408c6a181f2fb04c56273afd5c3e1e82f60392c @@ -576,7 +576,7 @@ F test/misc5.test 45b2e3ed5f79af2b4f38ae362eaf4c49674575bd F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test 29032efcd3d826fbd409e2a7af873e7939f4a4e3 F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33 -F test/multiplex.test e58dbe5b5a3b84a1f5b96408e29efdcd6f833f16 +F test/multiplex.test 74009eeb9b1186855a56ad522f5daf9bcf6ee134 F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 F test/nan.test a44e04df1486fcfb02d32468cbcd3c8e1e433723 @@ -914,7 +914,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c41ff2358e8af0fe2186ab4173b81fba204a57ab -R 038c75157e031b60cfa85be2f04c19c6 +P 36e364a3fe7d3a9a521189ff0262611a492c21dc +R 139c8e5f53872b2a8fa7c9d64e54233c U shaneh -Z 4af569247c03e0c4e633f1be2df20cf9 +Z 22cc15d919103b40af9da38b0122d8bd diff --git a/manifest.uuid b/manifest.uuid index 661c0bd7e0..eb27bb55e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -36e364a3fe7d3a9a521189ff0262611a492c21dc \ No newline at end of file +fee9734c193a8bec9599e02e16938179e642bf5e \ No newline at end of file diff --git a/src/test_multiplex.c b/src/test_multiplex.c index ff3be68509..214cddcaf1 100644 --- a/src/test_multiplex.c +++ b/src/test_multiplex.c @@ -205,34 +205,41 @@ static void multiplexControlFunc( ){ extern const char *sqlite3TestErrorName(int); extern int multiplexFileControl(sqlite3_file *, int, void *); - // pPager->fd - sqlite3 *db = (sqlite3 *)sqlite3_user_data(context); - int op = sqlite3_value_int(argv[0]); - int iVal = sqlite3_value_int(argv[1]); int rc = SQLITE_OK; - switch( op ){ - case 1: - op = MULTIPLEX_CTRL_ENABLE; - break; - case 2: - op = MULTIPLEX_CTRL_SET_CHUNK_SIZE; - break; - case 3: - op = MULTIPLEX_CTRL_SET_MAX_CHUNKS; - break; - default: - rc = SQLITE_ERROR; - break; + sqlite3 *db = sqlite3_context_db_handle(context); + int op; + int iVal; + + if( !db || argc!=2 ){ + rc = SQLITE_ERROR; + }else{ + /* extract params */ + op = sqlite3_value_int(argv[0]); + iVal = sqlite3_value_int(argv[1]); + /* map function op to file_control op */ + switch( op ){ + case 1: + op = MULTIPLEX_CTRL_ENABLE; + break; + case 2: + op = MULTIPLEX_CTRL_SET_CHUNK_SIZE; + break; + case 3: + op = MULTIPLEX_CTRL_SET_MAX_CHUNKS; + break; + default: + rc = SQLITE_ERROR; + break; + } } if( rc==SQLITE_OK ){ - sqlite3_file *f = (sqlite3_file *)db; - rc = multiplexFileControl(f, op, &iVal); + rc = sqlite3_file_control(db, 0, op, &iVal); } sqlite3_result_text(context, (char *)sqlite3TestErrorName(rc), -1, SQLITE_TRANSIENT); } /* -** This is the entry point to register the extension for the multiplex_control() function. +** This is the entry point to register the auto-extension for the multiplex_control() function. */ static int multiplexFuncInit( sqlite3 *db, @@ -241,7 +248,7 @@ static int multiplexFuncInit( ){ int rc; rc = sqlite3_create_function(db, "multiplex_control", 2, SQLITE_ANY, - db, multiplexControlFunc, 0, 0); + 0, multiplexControlFunc, 0, 0); return rc; } diff --git a/src/test_multiplex.h b/src/test_multiplex.h index a277e7afdb..1a574c1a87 100644 --- a/src/test_multiplex.h +++ b/src/test_multiplex.h @@ -56,15 +56,15 @@ ** VFS if makeDefault is non-zero. ** ** An auto-extension is registered which will make the function -** multiplex_control() available to open database connections. This +** multiplex_control() available to database connections. This ** function gives access to the xFileControl interface of the ** multiplex VFS shim. ** -** multiplex_control(,) +** SELECT multiplex_control(,) ; ** ** =1 MULTIPLEX_CTRL_ENABLE +** =0 disable ** =1 enable -** =2 disable ** ** =1 MULTIPLEX_CTRL_SET_CHUNK_SIZE ** int, chunk size diff --git a/test/multiplex.test b/test/multiplex.test index ab84c1e72c..2d6642e243 100644 --- a/test/multiplex.test +++ b/test/multiplex.test @@ -86,13 +86,11 @@ do_test multiplex-1.9.9 { sqlite3_multiplex_shutdown } {SQLITE_OK} do_test multiplex-1.10.1 { sqlite3_multiplex_initialize "" 1 } {SQLITE_OK} do_test multiplex-1.10.2 { sqlite3 db test.db } {} -if { 0 } { do_test multiplex-1.10.3 { execsql { SELECT multiplex_control(2, 32768); } } {SQLITE_OK} do_test multiplex-1.10.4 { execsql { SELECT multiplex_control(3, -1); } } {SQLITE_MISUSE} do_test multiplex-1.10.5 { execsql { SELECT multiplex_control(2, -1); } } {SQLITE_MISUSE} do_test multiplex-1.10.6 { execsql { SELECT multiplex_control(2, 31); } } {SQLITE_OK} do_test multiplex-1.10.7 { execsql { SELECT multiplex_control(3, 100); } } {SQLITE_MISUSE} -} do_test multiplex-1.10.8 { db close } {} do_test multiplex-1.10.9 { sqlite3_multiplex_shutdown } {SQLITE_OK}