diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 19 | ||||
-rw-r--r-- | src/shell.c.in | 20 | ||||
-rw-r--r-- | src/sqliteInt.h | 4 |
3 files changed, 34 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c index 5d50a1681..732c085a9 100644 --- a/src/main.c +++ b/src/main.c @@ -4285,11 +4285,12 @@ int sqlite3_test_control(int op, ...){ } #ifdef SQLITE_DEBUG - /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, val) + /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue) ** - ** "id" must be an integer between 0 and SQLITE_NTUNE-1. "val" - ** is a 64-bit signed integer. This test-control sets tuning parameter - ** id to the value val. + ** If "id" is an integer between 1 and SQLITE_NTUNE then set the value + ** of the id-th tuning parameter to *piValue. If "id" is between -1 + ** and -SQLITE_NTUNE, then write the current value of the (-id)-th + ** tuning parameter into *piValue. ** ** Tuning parameters are for use during transient development builds, ** to help find the best values for constants in the query planner. @@ -4301,8 +4302,14 @@ int sqlite3_test_control(int op, ...){ */ case SQLITE_TESTCTRL_TUNE: { int id = va_arg(ap, int); - int val = va_arg(ap, sqlite3_int64); - if( id>=0 && id<SQLITE_NTUNE ) Tuning(id) = val; + int *piValue = va_arg(ap, int*); + if( id>0 && id<=SQLITE_NTUNE ){ + Tuning(id) = *piValue; + }else if( id<0 && id>=-SQLITE_NTUNE ){ + *piValue = Tuning(-id); + }else{ + rc = SQLITE_NOTFOUND; + } break; } #endif diff --git a/src/shell.c.in b/src/shell.c.in index 67edb122d..5e1eabfac 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -10131,8 +10131,24 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_TUNE: { if( nArg==4 ){ int id = (int)integerValue(azArg[2]); - i64 val = integerValue(azArg[3]); - rc2 = sqlite3_test_control(testctrl, id, val); + int val = (int)integerValue(azArg[3]); + sqlite3_test_control(testctrl, id, &val); + isOk = 3; + }else if( nArg==3 ){ + int id = (int)integerValue(azArg[2]); + sqlite3_test_control(testctrl, -id, &rc2); + isOk = 1; + }else if( nArg==2 ){ + int id = 1; + while(1){ + int val = 0; + rc2 = sqlite3_test_control(testctrl, -id, &val); + if( rc2!=SQLITE_OK ) break; + if( id>1 ) utf8_printf(p->out, " "); + utf8_printf(p->out, "%d: %d", id, val); + id++; + } + if( id>1 ) utf8_printf(p->out, "\n"); isOk = 3; } break; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 112168ed8..806a1a339 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3747,10 +3747,12 @@ typedef struct { ** optimial values for parameters in the query planner. The should not ** be used on trunk check-ins. They are a temporary mechanism available ** for transient development builds only. +** +** Tuning parameters are numbered starting with 1. */ #define SQLITE_NTUNE 6 /* Should be zero for all trunk check-ins */ #ifdef SQLITE_DEBUG -# define Tuning(X) (sqlite3Config.aTune[X]) +# define Tuning(X) (sqlite3Config.aTune[(X)-1]) #else # define Tuning(X) 0 #endif |