From: drh Date: Mon, 8 Apr 2013 13:48:29 +0000 (+0000) Subject: Add the vfsname() and eval() SQL functions to mptest.c. X-Git-Tag: version-3.7.17~105^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bf44c7acba2a3bdfb2d2843402cce6a9b1733f0;p=thirdparty%2Fsqlite.git Add the vfsname() and eval() SQL functions to mptest.c. Enhancements to the test/config01.test script. FossilOrigin-Name: 91397a147ce4f67a7ea1182f06a7dda3a96ec465 --- diff --git a/manifest b/manifest index 3e8ee81047..6766f10a07 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\s--if,\s--else,\s--endif\sprocessing\sto\smptest.c. -D 2013-04-08T13:13:43.458 +C Add\sthe\svfsname()\sand\seval()\sSQL\sfunctions\sto\smptest.c.\s\nEnhancements\sto\sthe\stest/config01.test\sscript. +D 2013-04-08T13:48:29.192 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in aafa71d66bab7e87fb2f348152340645f79f0244 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -110,8 +110,8 @@ F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac F mkopcodec.awk f6fccee29e68493bfd90a2e0466ede5fa94dd2fc F mkopcodeh.awk 29b84656502eee5f444c3147f331ee686956ab0e F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 -F mptest/config01.test 058a9bc2b0db710d36003ab06dc1618566f27b52 -F mptest/mptest.c b4030a7ef4a2bfd2913062d637ae3f55fb9443c2 +F mptest/config01.test 3f4ddeb152a4f83872f0fa7fcb48d9fd609893da +F mptest/mptest.c 6614ad2110ce44a78b4745036880275ef939bc6e F mptest/multiwrite01.test aef0af17f1ce1beacd158e403a45a21008d7a70c F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b @@ -1047,7 +1047,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 15cb0db7583c3a24cbea0c72576047a93fba0801 -R ebe6490efbbe63db101a13263cb552f3 +P 51265acae3088a51ac0ce6ab8731e6e15a48d4ae +R 70ae859a3e60d8d3ce14cc3f23701768 U drh -Z bd1b6a8c139e5f3d36fca35a646773b9 +Z 17c730545a4fcc3406090d39f090bdb3 diff --git a/manifest.uuid b/manifest.uuid index b0847befc9..e40c60c705 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -51265acae3088a51ac0ce6ab8731e6e15a48d4ae \ No newline at end of file +91397a147ce4f67a7ea1182f06a7dda3a96ec465 \ No newline at end of file diff --git a/mptest/config01.test b/mptest/config01.test index be6b570678..75ba2f8fc2 100644 --- a/mptest/config01.test +++ b/mptest/config01.test @@ -1,6 +1,7 @@ /* ** Configure five tasks in different ways, then run tests. */ +--if vfsname() GLOB 'unix' PRAGMA page_size=8192; --task 1 PRAGMA journal_mode=PERSIST; @@ -17,3 +18,26 @@ PRAGMA page_size=8192; PRAGMA journal_mode=OFF; --end --source multiwrite01.test +--wait all +PRAGMA page_size=16384; +VACUUM; +CREATE TABLE pgsz(taskid, sz INTEGER); +--task 1 + INSERT INTO pgsz VALUES(1, eval('PRAGMA page_size')); +--end +--task 2 + INSERT INTO pgsz VALUES(2, eval('PRAGMA page_size')); +--end +--task 3 + INSERT INTO pgsz VALUES(3, eval('PRAGMA page_size')); +--end +--task 4 + INSERT INTO pgsz VALUES(4, eval('PRAGMA page_size')); +--end +--task 5 + INSERT INTO pgsz VALUES(5, eval('PRAGMA page_size')); +--end +--source multiwrite01.test +--wait all +SELECT sz FROM pgsz; +--match 16384 16384 16384 16384 16384 diff --git a/mptest/mptest.c b/mptest/mptest.c index 9a19ef2cd6..8fc13d069a 100644 --- a/mptest/mptest.c +++ b/mptest/mptest.c @@ -269,6 +269,22 @@ static int clipLength(const char *z){ return n; } +/* +** Auxiliary SQL function to return the name of the VFS +*/ +static void vfsNameFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + sqlite3 *db = sqlite3_context_db_handle(context); + char *zVfs = 0; + sqlite3_file_control(db, "main", SQLITE_FCNTL_VFSNAME, &zVfs); + if( zVfs ){ + sqlite3_result_text(context, zVfs, -1, sqlite3_free); + } +} + /* ** Busy handler with a g.iTimeout-millisecond timeout */ @@ -450,6 +466,32 @@ static int evalSql(String *p, const char *zFormat, ...){ return rc; } +/* +** Auxiliary SQL function to recursively evaluate SQL. +*/ +static void evalFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + sqlite3 *db = sqlite3_context_db_handle(context); + const char *zSql = (const char*)sqlite3_value_text(argv[0]); + String res; + char *zErrMsg = 0; + int rc; + memset(&res, 0, sizeof(res)); + rc = sqlite3_exec(db, zSql, evalCallback, &res, &zErrMsg); + if( zErrMsg ){ + sqlite3_result_error(context, zErrMsg, -1); + sqlite3_free(zErrMsg); + }else if( rc ){ + sqlite3_result_error_code(context, rc); + }else{ + sqlite3_result_text(context, res.z, -1, SQLITE_TRANSIENT); + } + stringFree(&res); +} + /* ** Look up the next task for client iClient in the database. ** Return the task script and the task number and mark that @@ -841,6 +883,15 @@ static void runScript( stringReset(&sResult); }else + /* + ** --output + ** + ** Output the result of the previous SQL. + */ + if( strcmp(zCmd, "output")==0 ){ + logMessage("%s", sResult.z); + }else + /* ** --source FILENAME ** @@ -1117,6 +1168,10 @@ int main(int argc, char **argv){ rc = sqlite3_open_v2(g.zDbFile, &g.db, openFlags, g.zVfs); if( rc ) fatalError("cannot open [%s]", g.zDbFile); sqlite3_busy_handler(g.db, busyHandler, 0); + sqlite3_create_function(g.db, "vfsname", 0, SQLITE_UTF8, 0, + vfsNameFunc, 0, 0); + sqlite3_create_function(g.db, "eval", 1, SQLITE_UTF8, 0, + evalFunc, 0, 0); g.iTimeout = DEFAULT_TIMEOUT; if( g.bSqlTrace ) sqlite3_trace(g.db, sqlTraceCallback, 0); if( iClient>0 ){