| | @@ -53,19 +53,10 @@ |
| 53 | 53 | */ |
| 54 | 54 | #if !defined(SQLITE_OS_WINRT) |
| 55 | 55 | # define SQLITE_OS_WINRT 0 |
| 56 | 56 | #endif |
| 57 | 57 | |
| 58 | | -/* |
| 59 | | -** If SQLITE_SHELL_FIDDLE is defined then the shell is modified |
| 60 | | -** somewhat for use as a WASM module in a web browser. This flag |
| 61 | | -** should only be used when building the "fiddle" web application, as |
| 62 | | -** the browser-mode build has much different user input requirements |
| 63 | | -** and this build mode rewires the user input subsystem to account for |
| 64 | | -** that. |
| 65 | | -*/ |
| 66 | | - |
| 67 | 58 | /* |
| 68 | 59 | ** Warning pragmas copied from msvc.h in the core. |
| 69 | 60 | */ |
| 70 | 61 | #if defined(_MSC_VER) |
| 71 | 62 | #pragma warning(disable : 4054) |
| | @@ -254,10 +245,21 @@ |
| 254 | 245 | #else |
| 255 | 246 | # define setBinaryMode(X,Y) |
| 256 | 247 | # define setTextMode(X,Y) |
| 257 | 248 | #endif |
| 258 | 249 | |
| 250 | +/* |
| 251 | +** When compiling with emcc (a.k.a. emscripten), we're building a |
| 252 | +** WebAssembly (WASM) bundle and need to disable and rewire a few |
| 253 | +** things. |
| 254 | +*/ |
| 255 | +#ifdef __EMSCRIPTEN__ |
| 256 | +#define SQLITE_SHELL_WASM_MODE |
| 257 | +#else |
| 258 | +#undef SQLITE_SHELL_WASM_MODE |
| 259 | +#endif |
| 260 | + |
| 259 | 261 | /* True if the timer is enabled */ |
| 260 | 262 | static int enableTimer = 0; |
| 261 | 263 | |
| 262 | 264 | /* Return the current wall-clock time */ |
| 263 | 265 | static sqlite3_int64 timeOfDay(void){ |
| | @@ -715,11 +717,11 @@ |
| 715 | 717 | ** |
| 716 | 718 | ** The result is stored in space obtained from malloc() and must either |
| 717 | 719 | ** be freed by the caller or else passed back into this routine via the |
| 718 | 720 | ** zPrior argument for reuse. |
| 719 | 721 | */ |
| 720 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 722 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 721 | 723 | static char *one_input_line(FILE *in, char *zPrior, int isContinuation){ |
| 722 | 724 | char *zPrompt; |
| 723 | 725 | char *zResult; |
| 724 | 726 | if( in!=0 ){ |
| 725 | 727 | zResult = local_getline(zPrior, in); |
| | @@ -735,11 +737,11 @@ |
| 735 | 737 | if( zResult && *zResult ) shell_add_history(zResult); |
| 736 | 738 | #endif |
| 737 | 739 | } |
| 738 | 740 | return zResult; |
| 739 | 741 | } |
| 740 | | -#endif /* !SQLITE_SHELL_FIDDLE */ |
| 742 | +#endif /* !SQLITE_SHELL_WASM_MODE */ |
| 741 | 743 | |
| 742 | 744 | /* |
| 743 | 745 | ** Return the value of a hexadecimal digit. Return -1 if the input |
| 744 | 746 | ** is not a hex digit. |
| 745 | 747 | */ |
| | @@ -3792,11 +3794,10 @@ |
| 3792 | 3794 | #define re_compile sqlite3re_compile |
| 3793 | 3795 | #define re_free sqlite3re_free |
| 3794 | 3796 | |
| 3795 | 3797 | /* The end-of-input character */ |
| 3796 | 3798 | #define RE_EOF 0 /* End of input */ |
| 3797 | | -#define RE_START 0xfffffff /* Start of input - larger than an UTF-8 */ |
| 3798 | 3799 | |
| 3799 | 3800 | /* The NFA is implemented as sequence of opcodes taken from the following |
| 3800 | 3801 | ** set. Each opcode has a single integer argument. |
| 3801 | 3802 | */ |
| 3802 | 3803 | #define RE_OP_MATCH 1 /* Match the one character in the argument */ |
| | @@ -3814,37 +3815,10 @@ |
| 3814 | 3815 | #define RE_OP_DIGIT 13 /* digit: [0-9] */ |
| 3815 | 3816 | #define RE_OP_NOTDIGIT 14 /* Not a digit */ |
| 3816 | 3817 | #define RE_OP_SPACE 15 /* space: [ \t\n\r\v\f] */ |
| 3817 | 3818 | #define RE_OP_NOTSPACE 16 /* Not a digit */ |
| 3818 | 3819 | #define RE_OP_BOUNDARY 17 /* Boundary between word and non-word */ |
| 3819 | | -#define RE_OP_ATSTART 18 /* Currently at the start of the string */ |
| 3820 | | - |
| 3821 | | -#if defined(SQLITE_DEBUG) |
| 3822 | | -/* Opcode names used for symbolic debugging */ |
| 3823 | | -static const char *ReOpName[] = { |
| 3824 | | - "EOF", |
| 3825 | | - "MATCH", |
| 3826 | | - "ANY", |
| 3827 | | - "ANYSTAR", |
| 3828 | | - "FORK", |
| 3829 | | - "GOTO", |
| 3830 | | - "ACCEPT", |
| 3831 | | - "CC_INC", |
| 3832 | | - "CC_EXC", |
| 3833 | | - "CC_VALUE", |
| 3834 | | - "CC_RANGE", |
| 3835 | | - "WORD", |
| 3836 | | - "NOTWORD", |
| 3837 | | - "DIGIT", |
| 3838 | | - "NOTDIGIT", |
| 3839 | | - "SPACE", |
| 3840 | | - "NOTSPACE", |
| 3841 | | - "BOUNDARY", |
| 3842 | | - "ATSTART", |
| 3843 | | -}; |
| 3844 | | -#endif /* SQLITE_DEBUG */ |
| 3845 | | - |
| 3846 | 3820 | |
| 3847 | 3821 | /* Each opcode is a "state" in the NFA */ |
| 3848 | 3822 | typedef unsigned short ReStateNumber; |
| 3849 | 3823 | |
| 3850 | 3824 | /* Because this is an NFA and not a DFA, multiple states can be active at |
| | @@ -3875,11 +3849,11 @@ |
| 3875 | 3849 | const char *zErr; /* Error message to return */ |
| 3876 | 3850 | char *aOp; /* Operators for the virtual machine */ |
| 3877 | 3851 | int *aArg; /* Arguments to each operator */ |
| 3878 | 3852 | unsigned (*xNextChar)(ReInput*); /* Next character function */ |
| 3879 | 3853 | unsigned char zInit[12]; /* Initial text to match */ |
| 3880 | | - int nInit; /* Number of bytes in zInit */ |
| 3854 | + int nInit; /* Number of characters in zInit */ |
| 3881 | 3855 | unsigned nState; /* Number of entries in aOp[] and aArg[] */ |
| 3882 | 3856 | unsigned nAlloc; /* Slots allocated for aOp[] and aArg[] */ |
| 3883 | 3857 | }; |
| 3884 | 3858 | |
| 3885 | 3859 | /* Add a state to the given state set if it is not already there */ |
| | @@ -3948,11 +3922,11 @@ |
| 3948 | 3922 | ReStateSet aStateSet[2], *pThis, *pNext; |
| 3949 | 3923 | ReStateNumber aSpace[100]; |
| 3950 | 3924 | ReStateNumber *pToFree; |
| 3951 | 3925 | unsigned int i = 0; |
| 3952 | 3926 | unsigned int iSwap = 0; |
| 3953 | | - int c = RE_START; |
| 3927 | + int c = RE_EOF+1; |
| 3954 | 3928 | int cPrev = 0; |
| 3955 | 3929 | int rc = 0; |
| 3956 | 3930 | ReInput in; |
| 3957 | 3931 | |
| 3958 | 3932 | in.z = zIn; |
| | @@ -3967,11 +3941,10 @@ |
| 3967 | 3941 | strncmp((const char*)zIn+in.i, (const char*)pRe->zInit, pRe->nInit)!=0) |
| 3968 | 3942 | ){ |
| 3969 | 3943 | in.i++; |
| 3970 | 3944 | } |
| 3971 | 3945 | if( in.i+pRe->nInit>in.mx ) return 0; |
| 3972 | | - c = RE_START-1; |
| 3973 | 3946 | } |
| 3974 | 3947 | |
| 3975 | 3948 | if( pRe->nState<=(sizeof(aSpace)/(sizeof(aSpace[0])*2)) ){ |
| 3976 | 3949 | pToFree = 0; |
| 3977 | 3950 | aStateSet[0].aState = aSpace; |
| | @@ -3996,14 +3969,10 @@ |
| 3996 | 3969 | switch( pRe->aOp[x] ){ |
| 3997 | 3970 | case RE_OP_MATCH: { |
| 3998 | 3971 | if( pRe->aArg[x]==c ) re_add_state(pNext, x+1); |
| 3999 | 3972 | break; |
| 4000 | 3973 | } |
| 4001 | | - case RE_OP_ATSTART: { |
| 4002 | | - if( cPrev==RE_START ) re_add_state(pThis, x+1); |
| 4003 | | - break; |
| 4004 | | - } |
| 4005 | 3974 | case RE_OP_ANY: { |
| 4006 | 3975 | if( c!=0 ) re_add_state(pNext, x+1); |
| 4007 | 3976 | break; |
| 4008 | 3977 | } |
| 4009 | 3978 | case RE_OP_WORD: { |
| | @@ -4081,13 +4050,11 @@ |
| 4081 | 4050 | } |
| 4082 | 4051 | } |
| 4083 | 4052 | } |
| 4084 | 4053 | } |
| 4085 | 4054 | for(i=0; i<pNext->nState; i++){ |
| 4086 | | - int x = pNext->aState[i]; |
| 4087 | | - while( pRe->aOp[x]==RE_OP_GOTO ) x += pRe->aArg[x]; |
| 4088 | | - if( pRe->aOp[x]==RE_OP_ACCEPT ){ rc = 1; break; } |
| 4055 | + if( pRe->aOp[pNext->aState[i]]==RE_OP_ACCEPT ){ rc = 1; break; } |
| 4089 | 4056 | } |
| 4090 | 4057 | re_match_end: |
| 4091 | 4058 | sqlite3_free(pToFree); |
| 4092 | 4059 | return rc; |
| 4093 | 4060 | } |
| | @@ -4238,10 +4205,11 @@ |
| 4238 | 4205 | const char *zErr; |
| 4239 | 4206 | while( (c = p->xNextChar(&p->sIn))!=0 ){ |
| 4240 | 4207 | iStart = p->nState; |
| 4241 | 4208 | switch( c ){ |
| 4242 | 4209 | case '|': |
| 4210 | + case '$': |
| 4243 | 4211 | case ')': { |
| 4244 | 4212 | p->sIn.i--; |
| 4245 | 4213 | return 0; |
| 4246 | 4214 | } |
| 4247 | 4215 | case '(': { |
| | @@ -4274,18 +4242,10 @@ |
| 4274 | 4242 | case '?': { |
| 4275 | 4243 | if( iPrev<0 ) return "'?' without operand"; |
| 4276 | 4244 | re_insert(p, iPrev, RE_OP_FORK, p->nState - iPrev+1); |
| 4277 | 4245 | break; |
| 4278 | 4246 | } |
| 4279 | | - case '$': { |
| 4280 | | - re_append(p, RE_OP_MATCH, RE_EOF); |
| 4281 | | - break; |
| 4282 | | - } |
| 4283 | | - case '^': { |
| 4284 | | - re_append(p, RE_OP_ATSTART, 0); |
| 4285 | | - break; |
| 4286 | | - } |
| 4287 | 4247 | case '{': { |
| 4288 | 4248 | int m = 0, n = 0; |
| 4289 | 4249 | int sz, j; |
| 4290 | 4250 | if( iPrev<0 ) return "'{m,n}' without operand"; |
| 4291 | 4251 | while( (c=rePeek(p))>='0' && c<='9' ){ m = m*10 + c - '0'; p->sIn.i++; } |
| | @@ -4300,11 +4260,10 @@ |
| 4300 | 4260 | p->sIn.i++; |
| 4301 | 4261 | sz = p->nState - iPrev; |
| 4302 | 4262 | if( m==0 ){ |
| 4303 | 4263 | if( n==0 ) return "both m and n are zero in '{m,n}'"; |
| 4304 | 4264 | re_insert(p, iPrev, RE_OP_FORK, sz+1); |
| 4305 | | - iPrev++; |
| 4306 | 4265 | n--; |
| 4307 | 4266 | }else{ |
| 4308 | 4267 | for(j=1; j<m; j++) re_copy(p, iPrev, sz); |
| 4309 | 4268 | } |
| 4310 | 4269 | for(j=m; j<n; j++){ |
| | @@ -4419,11 +4378,15 @@ |
| 4419 | 4378 | zErr = re_subcompile_re(pRe); |
| 4420 | 4379 | if( zErr ){ |
| 4421 | 4380 | re_free(pRe); |
| 4422 | 4381 | return zErr; |
| 4423 | 4382 | } |
| 4424 | | - if( pRe->sIn.i>=pRe->sIn.mx ){ |
| 4383 | + if( rePeek(pRe)=='$' && pRe->sIn.i+1>=pRe->sIn.mx ){ |
| 4384 | + re_append(pRe, RE_OP_MATCH, RE_EOF); |
| 4385 | + re_append(pRe, RE_OP_ACCEPT, 0); |
| 4386 | + *ppRe = pRe; |
| 4387 | + }else if( pRe->sIn.i>=pRe->sIn.mx ){ |
| 4425 | 4388 | re_append(pRe, RE_OP_ACCEPT, 0); |
| 4426 | 4389 | *ppRe = pRe; |
| 4427 | 4390 | }else{ |
| 4428 | 4391 | re_free(pRe); |
| 4429 | 4392 | return "unrecognized character"; |
| | @@ -4502,71 +4465,10 @@ |
| 4502 | 4465 | } |
| 4503 | 4466 | if( setAux ){ |
| 4504 | 4467 | sqlite3_set_auxdata(context, 0, pRe, (void(*)(void*))re_free); |
| 4505 | 4468 | } |
| 4506 | 4469 | } |
| 4507 | | - |
| 4508 | | -#if defined(SQLITE_DEBUG) |
| 4509 | | -/* |
| 4510 | | -** This function is used for testing and debugging only. It is only available |
| 4511 | | -** if the SQLITE_DEBUG compile-time option is used. |
| 4512 | | -** |
| 4513 | | -** Compile a regular expression and then convert the compiled expression into |
| 4514 | | -** text and return that text. |
| 4515 | | -*/ |
| 4516 | | -static void re_bytecode_func( |
| 4517 | | - sqlite3_context *context, |
| 4518 | | - int argc, |
| 4519 | | - sqlite3_value **argv |
| 4520 | | -){ |
| 4521 | | - const char *zPattern; |
| 4522 | | - const char *zErr; |
| 4523 | | - ReCompiled *pRe; |
| 4524 | | - sqlite3_str *pStr; |
| 4525 | | - int i; |
| 4526 | | - int n; |
| 4527 | | - char *z; |
| 4528 | | - |
| 4529 | | - zPattern = (const char*)sqlite3_value_text(argv[0]); |
| 4530 | | - if( zPattern==0 ) return; |
| 4531 | | - zErr = re_compile(&pRe, zPattern, sqlite3_user_data(context)!=0); |
| 4532 | | - if( zErr ){ |
| 4533 | | - re_free(pRe); |
| 4534 | | - sqlite3_result_error(context, zErr, -1); |
| 4535 | | - return; |
| 4536 | | - } |
| 4537 | | - if( pRe==0 ){ |
| 4538 | | - sqlite3_result_error_nomem(context); |
| 4539 | | - return; |
| 4540 | | - } |
| 4541 | | - pStr = sqlite3_str_new(0); |
| 4542 | | - if( pStr==0 ) goto re_bytecode_func_err; |
| 4543 | | - if( pRe->nInit>0 ){ |
| 4544 | | - sqlite3_str_appendf(pStr, "INIT "); |
| 4545 | | - for(i=0; i<pRe->nInit; i++){ |
| 4546 | | - sqlite3_str_appendf(pStr, "%02x", pRe->zInit[i]); |
| 4547 | | - } |
| 4548 | | - sqlite3_str_appendf(pStr, "\n"); |
| 4549 | | - } |
| 4550 | | - for(i=0; i<pRe->nState; i++){ |
| 4551 | | - sqlite3_str_appendf(pStr, "%-8s %4d\n", |
| 4552 | | - ReOpName[(unsigned char)pRe->aOp[i]], pRe->aArg[i]); |
| 4553 | | - } |
| 4554 | | - n = sqlite3_str_length(pStr); |
| 4555 | | - z = sqlite3_str_finish(pStr); |
| 4556 | | - if( n==0 ){ |
| 4557 | | - sqlite3_free(z); |
| 4558 | | - }else{ |
| 4559 | | - sqlite3_result_text(context, z, n-1, sqlite3_free); |
| 4560 | | - } |
| 4561 | | - |
| 4562 | | -re_bytecode_func_err: |
| 4563 | | - re_free(pRe); |
| 4564 | | -} |
| 4565 | | - |
| 4566 | | -#endif /* SQLITE_DEBUG */ |
| 4567 | | - |
| 4568 | 4470 | |
| 4569 | 4471 | /* |
| 4570 | 4472 | ** Invoke this routine to register the regexp() function with the |
| 4571 | 4473 | ** SQLite database connection. |
| 4572 | 4474 | */ |
| | @@ -4588,23 +4490,16 @@ |
| 4588 | 4490 | /* The regexpi(PATTERN,STRING) function is a case-insensitive version |
| 4589 | 4491 | ** of regexp(PATTERN,STRING). */ |
| 4590 | 4492 | rc = sqlite3_create_function(db, "regexpi", 2, |
| 4591 | 4493 | SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC, |
| 4592 | 4494 | (void*)db, re_sql_func, 0, 0); |
| 4593 | | -#if defined(SQLITE_DEBUG) |
| 4594 | | - if( rc==SQLITE_OK ){ |
| 4595 | | - rc = sqlite3_create_function(db, "regexp_bytecode", 1, |
| 4596 | | - SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC, |
| 4597 | | - 0, re_bytecode_func, 0, 0); |
| 4598 | | - } |
| 4599 | | -#endif /* SQLITE_DEBUG */ |
| 4600 | 4495 | } |
| 4601 | 4496 | return rc; |
| 4602 | 4497 | } |
| 4603 | 4498 | |
| 4604 | 4499 | /************************* End ../ext/misc/regexp.c ********************/ |
| 4605 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 4500 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 4606 | 4501 | /************************* Begin ../ext/misc/fileio.c ******************/ |
| 4607 | 4502 | /* |
| 4608 | 4503 | ** 2014-06-13 |
| 4609 | 4504 | ** |
| 4610 | 4505 | ** The author disclaims copyright to this source code. In place of |
| | @@ -12353,19 +12248,19 @@ |
| 12353 | 12248 | int nIndent; /* Size of array aiIndent[] */ |
| 12354 | 12249 | int iIndent; /* Index of current op in aiIndent[] */ |
| 12355 | 12250 | char *zNonce; /* Nonce for temporary safe-mode excapes */ |
| 12356 | 12251 | EQPGraph sGraph; /* Information for the graphical EXPLAIN QUERY PLAN */ |
| 12357 | 12252 | ExpertInfo expert; /* Valid if previous command was ".expert OPT..." */ |
| 12358 | | -#ifdef SQLITE_SHELL_FIDDLE |
| 12253 | +#ifdef SQLITE_SHELL_WASM_MODE |
| 12359 | 12254 | struct { |
| 12360 | 12255 | const char * zInput; /* Input string from wasm/JS proxy */ |
| 12361 | 12256 | const char * zPos; /* Cursor pos into zInput */ |
| 12362 | 12257 | } wasm; |
| 12363 | 12258 | #endif |
| 12364 | 12259 | }; |
| 12365 | 12260 | |
| 12366 | | -#ifdef SQLITE_SHELL_FIDDLE |
| 12261 | +#ifdef SQLITE_SHELL_WASM_MODE |
| 12367 | 12262 | static ShellState shellState; |
| 12368 | 12263 | #endif |
| 12369 | 12264 | |
| 12370 | 12265 | |
| 12371 | 12266 | /* Allowed values for ShellState.autoEQP |
| | @@ -13029,11 +12924,11 @@ |
| 13029 | 12924 | UNUSED_PARAMETER(zA2); |
| 13030 | 12925 | UNUSED_PARAMETER(zA3); |
| 13031 | 12926 | UNUSED_PARAMETER(zA4); |
| 13032 | 12927 | switch( op ){ |
| 13033 | 12928 | case SQLITE_ATTACH: { |
| 13034 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 12929 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 13035 | 12930 | /* In WASM builds the filesystem is a virtual sandbox, so |
| 13036 | 12931 | ** there's no harm in using ATTACH. */ |
| 13037 | 12932 | failIfSafeMode(p, "cannot run ATTACH in safe mode"); |
| 13038 | 12933 | #endif |
| 13039 | 12934 | break; |
| | @@ -15443,11 +15338,11 @@ |
| 15443 | 15338 | ** There must be two or more spaces between the end of the command and the |
| 15444 | 15339 | ** start of the description of what that command does. |
| 15445 | 15340 | */ |
| 15446 | 15341 | static const char *(azHelp[]) = { |
| 15447 | 15342 | #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE) \ |
| 15448 | | - && !defined(SQLITE_SHELL_FIDDLE) |
| 15343 | + && !defined(SQLITE_SHELL_WASM_MODE) |
| 15449 | 15344 | ".archive ... Manage SQL archives", |
| 15450 | 15345 | " Each command must have exactly one of the following options:", |
| 15451 | 15346 | " -c, --create Create a new archive", |
| 15452 | 15347 | " -u, --update Add or update files with changed mtime", |
| 15453 | 15348 | " -i, --insert Like -u but always add even if unchanged", |
| | @@ -15469,23 +15364,23 @@ |
| 15469 | 15364 | " http://sqlite.org/cli.html#sqlite_archive_support", |
| 15470 | 15365 | #endif |
| 15471 | 15366 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 15472 | 15367 | ".auth ON|OFF Show authorizer callbacks", |
| 15473 | 15368 | #endif |
| 15474 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15369 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15475 | 15370 | ".backup ?DB? FILE Backup DB (default \"main\") to FILE", |
| 15476 | 15371 | " Options:", |
| 15477 | 15372 | " --append Use the appendvfs", |
| 15478 | 15373 | " --async Write to FILE without journal and fsync()", |
| 15479 | 15374 | #endif |
| 15480 | 15375 | ".bail on|off Stop after hitting an error. Default OFF", |
| 15481 | 15376 | ".binary on|off Turn binary output on or off. Default OFF", |
| 15482 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15377 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15483 | 15378 | ".cd DIRECTORY Change the working directory to DIRECTORY", |
| 15484 | 15379 | #endif |
| 15485 | 15380 | ".changes on|off Show number of rows changed by SQL", |
| 15486 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15381 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15487 | 15382 | ".check GLOB Fail if output since .testcase does not match", |
| 15488 | 15383 | ".clone NEWDB Clone data into NEWDB from the existing database", |
| 15489 | 15384 | #endif |
| 15490 | 15385 | ".connection [close] [#] Open or close an auxiliary database connection", |
| 15491 | 15386 | ".databases List names and files of attached databases", |
| | @@ -15507,15 +15402,15 @@ |
| 15507 | 15402 | #ifdef SQLITE_DEBUG |
| 15508 | 15403 | " test Show raw EXPLAIN QUERY PLAN output", |
| 15509 | 15404 | " trace Like \"full\" but enable \"PRAGMA vdbe_trace\"", |
| 15510 | 15405 | #endif |
| 15511 | 15406 | " trigger Like \"full\" but also show trigger bytecode", |
| 15512 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15407 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15513 | 15408 | ".excel Display the output of next command in spreadsheet", |
| 15514 | 15409 | " --bom Put a UTF8 byte-order mark on intermediate file", |
| 15515 | 15410 | #endif |
| 15516 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15411 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15517 | 15412 | ".exit ?CODE? Exit this program with return-code CODE", |
| 15518 | 15413 | #endif |
| 15519 | 15414 | ".expert EXPERIMENTAL. Suggest indexes for queries", |
| 15520 | 15415 | ".explain ?on|off|auto? Change the EXPLAIN formatting mode. Default: auto", |
| 15521 | 15416 | ".filectrl CMD ... Run various sqlite3_file_control() operations", |
| | @@ -15522,11 +15417,11 @@ |
| 15522 | 15417 | " --schema SCHEMA Use SCHEMA instead of \"main\"", |
| 15523 | 15418 | " --help Show CMD details", |
| 15524 | 15419 | ".fullschema ?--indent? Show schema and the content of sqlite_stat tables", |
| 15525 | 15420 | ".headers on|off Turn display of headers on or off", |
| 15526 | 15421 | ".help ?-all? ?PATTERN? Show help text for PATTERN", |
| 15527 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15422 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15528 | 15423 | ".import FILE TABLE Import data from FILE into TABLE", |
| 15529 | 15424 | " Options:", |
| 15530 | 15425 | " --ascii Use \\037 and \\036 as column and row separators", |
| 15531 | 15426 | " --csv Use , and \\n as column and row separators", |
| 15532 | 15427 | " --skip N Skip the first N rows of input", |
| | @@ -15551,14 +15446,14 @@ |
| 15551 | 15446 | #endif |
| 15552 | 15447 | ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT", |
| 15553 | 15448 | ".lint OPTIONS Report potential schema issues.", |
| 15554 | 15449 | " Options:", |
| 15555 | 15450 | " fkey-indexes Find missing foreign key indexes", |
| 15556 | | -#if !defined(SQLITE_OMIT_LOAD_EXTENSION) && !defined(SQLITE_SHELL_FIDDLE) |
| 15451 | +#if !defined(SQLITE_OMIT_LOAD_EXTENSION) && !defined(SQLITE_SHELL_WASM_MODE) |
| 15557 | 15452 | ".load FILE ?ENTRY? Load an extension library", |
| 15558 | 15453 | #endif |
| 15559 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15454 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15560 | 15455 | ".log FILE|off Turn logging on or off. FILE can be stderr/stdout", |
| 15561 | 15456 | #endif |
| 15562 | 15457 | ".mode MODE ?OPTIONS? Set output mode", |
| 15563 | 15458 | " MODE is one of:", |
| 15564 | 15459 | " ascii Columns/rows delimited by 0x1F and 0x1E", |
| | @@ -15581,15 +15476,15 @@ |
| 15581 | 15476 | " --wordwrap B Wrap or not at word boundaries per B (on/off)", |
| 15582 | 15477 | " --ww Shorthand for \"--wordwrap 1\"", |
| 15583 | 15478 | " --quote Quote output text as SQL literals", |
| 15584 | 15479 | " --noquote Do not quote output text", |
| 15585 | 15480 | " TABLE The name of SQL table used for \"insert\" mode", |
| 15586 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15481 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15587 | 15482 | ".nonce STRING Suspend safe mode for one command if nonce matches", |
| 15588 | 15483 | #endif |
| 15589 | 15484 | ".nullvalue STRING Use STRING in place of NULL values", |
| 15590 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15485 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15591 | 15486 | ".once ?OPTIONS? ?FILE? Output for the next SQL command only to FILE", |
| 15592 | 15487 | " If FILE begins with '|' then open as a pipe", |
| 15593 | 15488 | " --bom Put a UTF8 byte-order mark at the beginning", |
| 15594 | 15489 | " -e Send output to the system text editor", |
| 15595 | 15490 | " -x Send output as CSV to a spreadsheet (same as \".excel\")", |
| | @@ -15607,11 +15502,11 @@ |
| 15607 | 15502 | #endif |
| 15608 | 15503 | " --new Initialize FILE to an empty database", |
| 15609 | 15504 | " --nofollow Do not follow symbolic links", |
| 15610 | 15505 | " --readonly Open FILE readonly", |
| 15611 | 15506 | " --zip FILE is a ZIP archive", |
| 15612 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15507 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15613 | 15508 | ".output ?FILE? Send output to FILE or stdout if FILE is omitted", |
| 15614 | 15509 | " If FILE begins with '|' then open it as a pipe.", |
| 15615 | 15510 | " Options:", |
| 15616 | 15511 | " --bom Prefix output with a UTF8 byte-order mark", |
| 15617 | 15512 | " -e Send output to the system text editor", |
| | @@ -15631,11 +15526,11 @@ |
| 15631 | 15526 | " --once Do no more than one progress interrupt", |
| 15632 | 15527 | " --quiet|-q No output except at interrupts", |
| 15633 | 15528 | " --reset Reset the count for each input and interrupt", |
| 15634 | 15529 | #endif |
| 15635 | 15530 | ".prompt MAIN CONTINUE Replace the standard prompts", |
| 15636 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15531 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15637 | 15532 | ".quit Exit this program", |
| 15638 | 15533 | ".read FILE Read input from FILE or command output", |
| 15639 | 15534 | " If FILE begins with \"|\", it is a command that generates the input.", |
| 15640 | 15535 | #endif |
| 15641 | 15536 | #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) |
| | @@ -15644,11 +15539,11 @@ |
| 15644 | 15539 | " --recovery-db NAME Store recovery metadata in database file NAME", |
| 15645 | 15540 | " --lost-and-found TABLE Alternative name for the lost-and-found table", |
| 15646 | 15541 | " --no-rowids Do not attempt to recover rowid values", |
| 15647 | 15542 | " that are not also INTEGER PRIMARY KEYs", |
| 15648 | 15543 | #endif |
| 15649 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15544 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15650 | 15545 | ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE", |
| 15651 | 15546 | ".save ?OPTIONS? FILE Write database to FILE (an alias for .backup ...)", |
| 15652 | 15547 | #endif |
| 15653 | 15548 | ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off", |
| 15654 | 15549 | ".schema ?PATTERN? Show the CREATE statements matching PATTERN", |
| | @@ -15681,24 +15576,24 @@ |
| 15681 | 15576 | " --sha3-224 Use the sha3-224 algorithm", |
| 15682 | 15577 | " --sha3-256 Use the sha3-256 algorithm (default)", |
| 15683 | 15578 | " --sha3-384 Use the sha3-384 algorithm", |
| 15684 | 15579 | " --sha3-512 Use the sha3-512 algorithm", |
| 15685 | 15580 | " Any other argument is a LIKE pattern for tables to hash", |
| 15686 | | -#if !defined(SQLITE_NOHAVE_SYSTEM) && !defined(SQLITE_SHELL_FIDDLE) |
| 15581 | +#if !defined(SQLITE_NOHAVE_SYSTEM) && !defined(SQLITE_SHELL_WASM_MODE) |
| 15687 | 15582 | ".shell CMD ARGS... Run CMD ARGS... in a system shell", |
| 15688 | 15583 | #endif |
| 15689 | 15584 | ".show Show the current values for various settings", |
| 15690 | 15585 | ".stats ?ARG? Show stats or turn stats on or off", |
| 15691 | 15586 | " off Turn off automatic stat display", |
| 15692 | 15587 | " on Turn on automatic stat display", |
| 15693 | 15588 | " stmt Show statement stats", |
| 15694 | 15589 | " vmstep Show the virtual machine step count only", |
| 15695 | | -#if !defined(SQLITE_NOHAVE_SYSTEM) && !defined(SQLITE_SHELL_FIDDLE) |
| 15590 | +#if !defined(SQLITE_NOHAVE_SYSTEM) && !defined(SQLITE_SHELL_WASM_MODE) |
| 15696 | 15591 | ".system CMD ARGS... Run CMD ARGS... in a system shell", |
| 15697 | 15592 | #endif |
| 15698 | 15593 | ".tables ?TABLE? List names of tables matching LIKE pattern TABLE", |
| 15699 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 15594 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 15700 | 15595 | ".testcase NAME Begin redirecting output to 'testcase-out.txt'", |
| 15701 | 15596 | #endif |
| 15702 | 15597 | ".testctrl CMD ... Run various sqlite3_test_control() operations", |
| 15703 | 15598 | " Run \".testctrl\" with no arguments for details", |
| 15704 | 15599 | ".timeout MS Try opening locked tables for MS milliseconds", |
| | @@ -16247,11 +16142,11 @@ |
| 16247 | 16142 | sqlite3_uint_init(p->db, 0, 0); |
| 16248 | 16143 | sqlite3_decimal_init(p->db, 0, 0); |
| 16249 | 16144 | sqlite3_regexp_init(p->db, 0, 0); |
| 16250 | 16145 | sqlite3_ieee_init(p->db, 0, 0); |
| 16251 | 16146 | sqlite3_series_init(p->db, 0, 0); |
| 16252 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 16147 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 16253 | 16148 | sqlite3_fileio_init(p->db, 0, 0); |
| 16254 | 16149 | sqlite3_completion_init(p->db, 0, 0); |
| 16255 | 16150 | #endif |
| 16256 | 16151 | #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) |
| 16257 | 16152 | sqlite3_dbdata_init(p->db, 0, 0); |
| | @@ -19377,19 +19272,19 @@ |
| 19377 | 19272 | } |
| 19378 | 19273 | }else |
| 19379 | 19274 | #endif |
| 19380 | 19275 | |
| 19381 | 19276 | #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) \ |
| 19382 | | - && !defined(SQLITE_SHELL_FIDDLE) |
| 19277 | + && !defined(SQLITE_SHELL_WASM_MODE) |
| 19383 | 19278 | if( c=='a' && strncmp(azArg[0], "archive", n)==0 ){ |
| 19384 | 19279 | open_db(p, 0); |
| 19385 | 19280 | failIfSafeMode(p, "cannot run .archive in safe mode"); |
| 19386 | 19281 | rc = arDotCommand(p, 0, azArg, nArg); |
| 19387 | 19282 | }else |
| 19388 | 19283 | #endif |
| 19389 | 19284 | |
| 19390 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 19285 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 19391 | 19286 | if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0) |
| 19392 | 19287 | || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0) |
| 19393 | 19288 | ){ |
| 19394 | 19289 | const char *zDestFile = 0; |
| 19395 | 19290 | const char *zDb = 0; |
| | @@ -19454,11 +19349,11 @@ |
| 19454 | 19349 | utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); |
| 19455 | 19350 | rc = 1; |
| 19456 | 19351 | } |
| 19457 | 19352 | close_db(pDest); |
| 19458 | 19353 | }else |
| 19459 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 19354 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 19460 | 19355 | |
| 19461 | 19356 | if( c=='b' && n>=3 && strncmp(azArg[0], "bail", n)==0 ){ |
| 19462 | 19357 | if( nArg==2 ){ |
| 19463 | 19358 | bail_on_error = booleanValue(azArg[1]); |
| 19464 | 19359 | }else{ |
| | @@ -19485,11 +19380,11 @@ |
| 19485 | 19380 | */ |
| 19486 | 19381 | if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){ |
| 19487 | 19382 | test_breakpoint(); |
| 19488 | 19383 | }else |
| 19489 | 19384 | |
| 19490 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 19385 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 19491 | 19386 | if( c=='c' && strcmp(azArg[0],"cd")==0 ){ |
| 19492 | 19387 | failIfSafeMode(p, "cannot run .cd in safe mode"); |
| 19493 | 19388 | if( nArg==2 ){ |
| 19494 | 19389 | #if defined(_WIN32) || defined(WIN32) |
| 19495 | 19390 | wchar_t *z = sqlite3_win32_utf8_to_unicode(azArg[1]); |
| | @@ -19505,11 +19400,11 @@ |
| 19505 | 19400 | }else{ |
| 19506 | 19401 | raw_printf(stderr, "Usage: .cd DIRECTORY\n"); |
| 19507 | 19402 | rc = 1; |
| 19508 | 19403 | } |
| 19509 | 19404 | }else |
| 19510 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 19405 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 19511 | 19406 | |
| 19512 | 19407 | if( c=='c' && n>=3 && strncmp(azArg[0], "changes", n)==0 ){ |
| 19513 | 19408 | if( nArg==2 ){ |
| 19514 | 19409 | setOrClearFlag(p, SHFLG_CountChanges, azArg[1]); |
| 19515 | 19410 | }else{ |
| | @@ -19516,11 +19411,11 @@ |
| 19516 | 19411 | raw_printf(stderr, "Usage: .changes on|off\n"); |
| 19517 | 19412 | rc = 1; |
| 19518 | 19413 | } |
| 19519 | 19414 | }else |
| 19520 | 19415 | |
| 19521 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 19416 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 19522 | 19417 | /* Cancel output redirection, if it is currently set (by .testcase) |
| 19523 | 19418 | ** Then read the content of the testcase-out.txt file and compare against |
| 19524 | 19419 | ** azArg[1]. If there are differences, report an error and exit. |
| 19525 | 19420 | */ |
| 19526 | 19421 | if( c=='c' && n>=3 && strncmp(azArg[0], "check", n)==0 ){ |
| | @@ -19541,23 +19436,23 @@ |
| 19541 | 19436 | utf8_printf(stdout, "testcase-%s ok\n", p->zTestcase); |
| 19542 | 19437 | p->nCheck++; |
| 19543 | 19438 | } |
| 19544 | 19439 | sqlite3_free(zRes); |
| 19545 | 19440 | }else |
| 19546 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 19441 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 19547 | 19442 | |
| 19548 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 19443 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 19549 | 19444 | if( c=='c' && strncmp(azArg[0], "clone", n)==0 ){ |
| 19550 | 19445 | failIfSafeMode(p, "cannot run .clone in safe mode"); |
| 19551 | 19446 | if( nArg==2 ){ |
| 19552 | 19447 | tryToClone(p, azArg[1]); |
| 19553 | 19448 | }else{ |
| 19554 | 19449 | raw_printf(stderr, "Usage: .clone FILENAME\n"); |
| 19555 | 19450 | rc = 1; |
| 19556 | 19451 | } |
| 19557 | 19452 | }else |
| 19558 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 19453 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 19559 | 19454 | |
| 19560 | 19455 | if( c=='c' && strncmp(azArg[0], "connection", n)==0 ){ |
| 19561 | 19456 | if( nArg==1 ){ |
| 19562 | 19457 | /* List available connections */ |
| 19563 | 19458 | int i; |
| | @@ -19842,11 +19737,11 @@ |
| 19842 | 19737 | raw_printf(stderr, "Usage: .eqp off|on|trace|trigger|full\n"); |
| 19843 | 19738 | rc = 1; |
| 19844 | 19739 | } |
| 19845 | 19740 | }else |
| 19846 | 19741 | |
| 19847 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 19742 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 19848 | 19743 | if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){ |
| 19849 | 19744 | if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc); |
| 19850 | 19745 | rc = 2; |
| 19851 | 19746 | }else |
| 19852 | 19747 | #endif |
| | @@ -20102,11 +19997,11 @@ |
| 20102 | 19997 | }else{ |
| 20103 | 19998 | showHelp(p->out, 0); |
| 20104 | 19999 | } |
| 20105 | 20000 | }else |
| 20106 | 20001 | |
| 20107 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 20002 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 20108 | 20003 | if( c=='i' && strncmp(azArg[0], "import", n)==0 ){ |
| 20109 | 20004 | char *zTable = 0; /* Insert data into this table */ |
| 20110 | 20005 | char *zSchema = 0; /* within this schema (may default to "main") */ |
| 20111 | 20006 | char *zFile = 0; /* Name of file to extra content from */ |
| 20112 | 20007 | sqlite3_stmt *pStmt = NULL; /* A statement */ |
| | @@ -20393,11 +20288,11 @@ |
| 20393 | 20288 | utf8_printf(p->out, |
| 20394 | 20289 | "Added %d rows with %d errors using %d lines of input\n", |
| 20395 | 20290 | sCtx.nRow, sCtx.nErr, sCtx.nLine-1); |
| 20396 | 20291 | } |
| 20397 | 20292 | }else |
| 20398 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 20293 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 20399 | 20294 | |
| 20400 | 20295 | #ifndef SQLITE_UNTESTABLE |
| 20401 | 20296 | if( c=='i' && strncmp(azArg[0], "imposter", n)==0 ){ |
| 20402 | 20297 | char *zSql; |
| 20403 | 20298 | char *zCollist = 0; |
| | @@ -20583,11 +20478,11 @@ |
| 20583 | 20478 | if( c=='l' && n>2 && strncmp(azArg[0], "lint", n)==0 ){ |
| 20584 | 20479 | open_db(p, 0); |
| 20585 | 20480 | lintDotCommand(p, azArg, nArg); |
| 20586 | 20481 | }else |
| 20587 | 20482 | |
| 20588 | | -#if !defined(SQLITE_OMIT_LOAD_EXTENSION) && !defined(SQLITE_SHELL_FIDDLE) |
| 20483 | +#if !defined(SQLITE_OMIT_LOAD_EXTENSION) && !defined(SQLITE_SHELL_WASM_MODE) |
| 20589 | 20484 | if( c=='l' && strncmp(azArg[0], "load", n)==0 ){ |
| 20590 | 20485 | const char *zFile, *zProc; |
| 20591 | 20486 | char *zErrMsg = 0; |
| 20592 | 20487 | failIfSafeMode(p, "cannot run .load in safe mode"); |
| 20593 | 20488 | if( nArg<2 ){ |
| | @@ -20605,11 +20500,11 @@ |
| 20605 | 20500 | rc = 1; |
| 20606 | 20501 | } |
| 20607 | 20502 | }else |
| 20608 | 20503 | #endif |
| 20609 | 20504 | |
| 20610 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 20505 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 20611 | 20506 | if( c=='l' && strncmp(azArg[0], "log", n)==0 ){ |
| 20612 | 20507 | failIfSafeMode(p, "cannot run .log in safe mode"); |
| 20613 | 20508 | if( nArg!=2 ){ |
| 20614 | 20509 | raw_printf(stderr, "Usage: .log FILENAME\n"); |
| 20615 | 20510 | rc = 1; |
| | @@ -20742,11 +20637,11 @@ |
| 20742 | 20637 | rc = 1; |
| 20743 | 20638 | } |
| 20744 | 20639 | p->cMode = p->mode; |
| 20745 | 20640 | }else |
| 20746 | 20641 | |
| 20747 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 20642 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 20748 | 20643 | if( c=='n' && strcmp(azArg[0], "nonce")==0 ){ |
| 20749 | 20644 | if( nArg!=2 ){ |
| 20750 | 20645 | raw_printf(stderr, "Usage: .nonce NONCE\n"); |
| 20751 | 20646 | rc = 1; |
| 20752 | 20647 | }else if( p->zNonce==0 || strcmp(azArg[1],p->zNonce)!=0 ){ |
| | @@ -20757,11 +20652,11 @@ |
| 20757 | 20652 | p->bSafeMode = 0; |
| 20758 | 20653 | return 0; /* Return immediately to bypass the safe mode reset |
| 20759 | 20654 | ** at the end of this procedure */ |
| 20760 | 20655 | } |
| 20761 | 20656 | }else |
| 20762 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 20657 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 20763 | 20658 | |
| 20764 | 20659 | if( c=='n' && strncmp(azArg[0], "nullvalue", n)==0 ){ |
| 20765 | 20660 | if( nArg==2 ){ |
| 20766 | 20661 | sqlite3_snprintf(sizeof(p->nullValue), p->nullValue, |
| 20767 | 20662 | "%.*s", (int)ArraySize(p->nullValue)-1, azArg[1]); |
| | @@ -20779,11 +20674,11 @@ |
| 20779 | 20674 | int openMode = SHELL_OPEN_UNSPEC; |
| 20780 | 20675 | |
| 20781 | 20676 | /* Check for command-line arguments */ |
| 20782 | 20677 | for(iName=1; iName<nArg; iName++){ |
| 20783 | 20678 | const char *z = azArg[iName]; |
| 20784 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 20679 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 20785 | 20680 | if( optionMatch(z,"new") ){ |
| 20786 | 20681 | newFlag = 1; |
| 20787 | 20682 | #ifdef SQLITE_HAVE_ZLIB |
| 20788 | 20683 | }else if( optionMatch(z, "zip") ){ |
| 20789 | 20684 | openMode = SHELL_OPEN_ZIPFILE; |
| | @@ -20801,11 +20696,11 @@ |
| 20801 | 20696 | openMode = SHELL_OPEN_HEXDB; |
| 20802 | 20697 | }else if( optionMatch(z, "maxsize") && iName+1<nArg ){ |
| 20803 | 20698 | p->szMax = integerValue(azArg[++iName]); |
| 20804 | 20699 | #endif /* SQLITE_OMIT_DESERIALIZE */ |
| 20805 | 20700 | }else |
| 20806 | | -#endif /* !SQLITE_SHELL_FIDDLE */ |
| 20701 | +#endif /* !SQLITE_SHELL_WASM_MODE */ |
| 20807 | 20702 | if( z[0]=='-' ){ |
| 20808 | 20703 | utf8_printf(stderr, "unknown option: %s\n", z); |
| 20809 | 20704 | rc = 1; |
| 20810 | 20705 | goto meta_command_exit; |
| 20811 | 20706 | }else if( zFN ){ |
| | @@ -20829,11 +20724,11 @@ |
| 20829 | 20724 | p->szMax = 0; |
| 20830 | 20725 | |
| 20831 | 20726 | /* If a filename is specified, try to open it first */ |
| 20832 | 20727 | if( zFN || p->openMode==SHELL_OPEN_HEXDB ){ |
| 20833 | 20728 | if( newFlag && zFN && !p->bSafeMode ) shellDeleteFile(zFN); |
| 20834 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 20729 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 20835 | 20730 | if( p->bSafeMode |
| 20836 | 20731 | && p->openMode!=SHELL_OPEN_HEXDB |
| 20837 | 20732 | && zFN |
| 20838 | 20733 | && strcmp(zFN,":memory:")!=0 |
| 20839 | 20734 | ){ |
| | @@ -20862,11 +20757,11 @@ |
| 20862 | 20757 | p->pAuxDb->zDbFilename = 0; |
| 20863 | 20758 | open_db(p, 0); |
| 20864 | 20759 | } |
| 20865 | 20760 | }else |
| 20866 | 20761 | |
| 20867 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 20762 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 20868 | 20763 | if( (c=='o' |
| 20869 | 20764 | && (strncmp(azArg[0], "output", n)==0||strncmp(azArg[0], "once", n)==0)) |
| 20870 | 20765 | || (c=='e' && n==5 && strcmp(azArg[0],"excel")==0) |
| 20871 | 20766 | ){ |
| 20872 | 20767 | char *zFile = 0; |
| | @@ -20978,11 +20873,11 @@ |
| 20978 | 20873 | sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile); |
| 20979 | 20874 | } |
| 20980 | 20875 | } |
| 20981 | 20876 | sqlite3_free(zFile); |
| 20982 | 20877 | }else |
| 20983 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 20878 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 20984 | 20879 | |
| 20985 | 20880 | if( c=='p' && n>=3 && strncmp(azArg[0], "parameter", n)==0 ){ |
| 20986 | 20881 | open_db(p,0); |
| 20987 | 20882 | if( nArg<=1 ) goto parameter_syntax_error; |
| 20988 | 20883 | |
| | @@ -21148,17 +21043,17 @@ |
| 21148 | 21043 | if( nArg >= 3) { |
| 21149 | 21044 | strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1); |
| 21150 | 21045 | } |
| 21151 | 21046 | }else |
| 21152 | 21047 | |
| 21153 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 21048 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 21154 | 21049 | if( c=='q' && strncmp(azArg[0], "quit", n)==0 ){ |
| 21155 | 21050 | rc = 2; |
| 21156 | 21051 | }else |
| 21157 | 21052 | #endif |
| 21158 | 21053 | |
| 21159 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 21054 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 21160 | 21055 | if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 ){ |
| 21161 | 21056 | FILE *inSaved = p->in; |
| 21162 | 21057 | int savedLineno = p->lineno; |
| 21163 | 21058 | failIfSafeMode(p, "cannot run .read in safe mode"); |
| 21164 | 21059 | if( nArg!=2 ){ |
| | @@ -21189,13 +21084,13 @@ |
| 21189 | 21084 | fclose(p->in); |
| 21190 | 21085 | } |
| 21191 | 21086 | p->in = inSaved; |
| 21192 | 21087 | p->lineno = savedLineno; |
| 21193 | 21088 | }else |
| 21194 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 21089 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 21195 | 21090 | |
| 21196 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 21091 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 21197 | 21092 | if( c=='r' && n>=3 && strncmp(azArg[0], "restore", n)==0 ){ |
| 21198 | 21093 | const char *zSrcFile; |
| 21199 | 21094 | const char *zDb; |
| 21200 | 21095 | sqlite3 *pSrc; |
| 21201 | 21096 | sqlite3_backup *pBackup; |
| | @@ -21243,11 +21138,11 @@ |
| 21243 | 21138 | utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); |
| 21244 | 21139 | rc = 1; |
| 21245 | 21140 | } |
| 21246 | 21141 | close_db(pSrc); |
| 21247 | 21142 | }else |
| 21248 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 21143 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 21249 | 21144 | |
| 21250 | 21145 | if( c=='s' && strncmp(azArg[0], "scanstats", n)==0 ){ |
| 21251 | 21146 | if( nArg==2 ){ |
| 21252 | 21147 | p->scanstatsOn = (u8)booleanValue(azArg[1]); |
| 21253 | 21148 | #ifndef SQLITE_ENABLE_STMT_SCANSTATUS |
| | @@ -21869,11 +21764,11 @@ |
| 21869 | 21764 | shell_exec(p, zSql, 0); |
| 21870 | 21765 | } |
| 21871 | 21766 | sqlite3_free(zSql); |
| 21872 | 21767 | }else |
| 21873 | 21768 | |
| 21874 | | -#if !defined(SQLITE_NOHAVE_SYSTEM) && !defined(SQLITE_SHELL_FIDDLE) |
| 21769 | +#if !defined(SQLITE_NOHAVE_SYSTEM) && !defined(SQLITE_SHELL_WASM_MODE) |
| 21875 | 21770 | if( c=='s' |
| 21876 | 21771 | && (strncmp(azArg[0], "shell", n)==0 || strncmp(azArg[0],"system",n)==0) |
| 21877 | 21772 | ){ |
| 21878 | 21773 | char *zCmd; |
| 21879 | 21774 | int i, x; |
| | @@ -21890,11 +21785,11 @@ |
| 21890 | 21785 | } |
| 21891 | 21786 | x = zCmd!=0 ? system(zCmd) : 1; |
| 21892 | 21787 | sqlite3_free(zCmd); |
| 21893 | 21788 | if( x ) raw_printf(stderr, "System command returns %d\n", x); |
| 21894 | 21789 | }else |
| 21895 | | -#endif /* !defined(SQLITE_NOHAVE_SYSTEM) && !defined(SQLITE_SHELL_FIDDLE) */ |
| 21790 | +#endif /* !defined(SQLITE_NOHAVE_SYSTEM) && !defined(SQLITE_SHELL_WASM_MODE) */ |
| 21896 | 21791 | |
| 21897 | 21792 | if( c=='s' && strncmp(azArg[0], "show", n)==0 ){ |
| 21898 | 21793 | static const char *azBool[] = { "off", "on", "trigger", "full"}; |
| 21899 | 21794 | const char *zOut; |
| 21900 | 21795 | int i; |
| | @@ -22070,11 +21965,11 @@ |
| 22070 | 21965 | |
| 22071 | 21966 | for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]); |
| 22072 | 21967 | sqlite3_free(azResult); |
| 22073 | 21968 | }else |
| 22074 | 21969 | |
| 22075 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 21970 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 22076 | 21971 | /* Begin redirecting output to the file "testcase-out.txt" */ |
| 22077 | 21972 | if( c=='t' && strcmp(azArg[0],"testcase")==0 ){ |
| 22078 | 21973 | output_reset(p); |
| 22079 | 21974 | p->out = output_file_open("testcase-out.txt", 0); |
| 22080 | 21975 | if( p->out==0 ){ |
| | @@ -22084,11 +21979,11 @@ |
| 22084 | 21979 | sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, "%s", azArg[1]); |
| 22085 | 21980 | }else{ |
| 22086 | 21981 | sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, "?"); |
| 22087 | 21982 | } |
| 22088 | 21983 | }else |
| 22089 | | -#endif /* !defined(SQLITE_SHELL_FIDDLE) */ |
| 21984 | +#endif /* !defined(SQLITE_SHELL_WASM_MODE) */ |
| 22090 | 21985 | |
| 22091 | 21986 | #ifndef SQLITE_UNTESTABLE |
| 22092 | 21987 | if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 ){ |
| 22093 | 21988 | static const struct { |
| 22094 | 21989 | const char *zCtrlName; /* Name of a test-control option */ |
| | @@ -22756,11 +22651,11 @@ |
| 22756 | 22651 | |
| 22757 | 22652 | static void echo_group_input(ShellState *p, const char *zDo){ |
| 22758 | 22653 | if( ShellHasFlag(p, SHFLG_Echo) ) utf8_printf(p->out, "%s\n", zDo); |
| 22759 | 22654 | } |
| 22760 | 22655 | |
| 22761 | | -#ifdef SQLITE_SHELL_FIDDLE |
| 22656 | +#ifdef SQLITE_SHELL_WASM_MODE |
| 22762 | 22657 | /* |
| 22763 | 22658 | ** Alternate one_input_line() impl for wasm mode. This is not in the primary impl |
| 22764 | 22659 | ** because we need the global shellState and cannot access it from that function |
| 22765 | 22660 | ** without moving lots of code around (creating a larger/messier diff). |
| 22766 | 22661 | */ |
| | @@ -22787,11 +22682,11 @@ |
| 22787 | 22682 | shell_check_oom(zLine); |
| 22788 | 22683 | memcpy(zLine, zBegin, (size_t)nZ); |
| 22789 | 22684 | zLine[nZ] = 0; |
| 22790 | 22685 | return zLine; |
| 22791 | 22686 | } |
| 22792 | | -#endif /* SQLITE_SHELL_FIDDLE */ |
| 22687 | +#endif /* SQLITE_SHELL_WASM_MODE */ |
| 22793 | 22688 | |
| 22794 | 22689 | /* |
| 22795 | 22690 | ** Read input from *in and process it. If *in==0 then input |
| 22796 | 22691 | ** is interactive - the user is typing it it. Otherwise, input |
| 22797 | 22692 | ** is coming from a file or device. A prompt is issued and history |
| | @@ -23170,11 +23065,11 @@ |
| 23170 | 23065 | # else |
| 23171 | 23066 | # define SQLITE_SHELL_IS_UTF8 (1) |
| 23172 | 23067 | # endif |
| 23173 | 23068 | #endif |
| 23174 | 23069 | |
| 23175 | | -#ifdef SQLITE_SHELL_FIDDLE |
| 23070 | +#ifdef SQLITE_SHELL_WASM_MODE |
| 23176 | 23071 | # define main fiddle_main |
| 23177 | 23072 | #endif |
| 23178 | 23073 | |
| 23179 | 23074 | #if SQLITE_SHELL_IS_UTF8 |
| 23180 | 23075 | int SQLITE_CDECL main(int argc, char **argv){ |
| | @@ -23184,11 +23079,11 @@ |
| 23184 | 23079 | #endif |
| 23185 | 23080 | #ifdef SQLITE_DEBUG |
| 23186 | 23081 | sqlite3_int64 mem_main_enter = sqlite3_memory_used(); |
| 23187 | 23082 | #endif |
| 23188 | 23083 | char *zErrMsg = 0; |
| 23189 | | -#ifdef SQLITE_SHELL_FIDDLE |
| 23084 | +#ifdef SQLITE_SHELL_WASM_MODE |
| 23190 | 23085 | # define data shellState |
| 23191 | 23086 | #else |
| 23192 | 23087 | ShellState data; |
| 23193 | 23088 | #endif |
| 23194 | 23089 | const char *zInitFile = 0; |
| | @@ -23204,11 +23099,11 @@ |
| 23204 | 23099 | int argcToFree = 0; |
| 23205 | 23100 | #endif |
| 23206 | 23101 | |
| 23207 | 23102 | setBinaryMode(stdin, 0); |
| 23208 | 23103 | setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */ |
| 23209 | | -#ifdef SQLITE_SHELL_FIDDLE |
| 23104 | +#ifdef SQLITE_SHELL_WASM_MODE |
| 23210 | 23105 | stdin_is_interactive = 0; |
| 23211 | 23106 | stdout_is_console = 1; |
| 23212 | 23107 | #else |
| 23213 | 23108 | stdin_is_interactive = isatty(0); |
| 23214 | 23109 | stdout_is_console = isatty(1); |
| | @@ -23466,11 +23361,11 @@ |
| 23466 | 23361 | utf8_printf(stderr,"%s: Error: no database filename specified\n", Argv0); |
| 23467 | 23362 | return 1; |
| 23468 | 23363 | #endif |
| 23469 | 23364 | } |
| 23470 | 23365 | data.out = stdout; |
| 23471 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 23366 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 23472 | 23367 | sqlite3_appendvfs_init(0,0,0); |
| 23473 | 23368 | #endif |
| 23474 | 23369 | |
| 23475 | 23370 | /* Go ahead and open the database file if it already exists. If the |
| 23476 | 23371 | ** file does not exist, delay opening it. This prevents empty database |
| | @@ -23734,11 +23629,11 @@ |
| 23734 | 23629 | }else{ |
| 23735 | 23630 | data.in = stdin; |
| 23736 | 23631 | rc = process_input(&data); |
| 23737 | 23632 | } |
| 23738 | 23633 | } |
| 23739 | | -#ifndef SQLITE_SHELL_FIDDLE |
| 23634 | +#ifndef SQLITE_SHELL_WASM_MODE |
| 23740 | 23635 | /* In WASM mode we have to leave the db state in place so that |
| 23741 | 23636 | ** client code can "push" SQL into it after this call returns. */ |
| 23742 | 23637 | free(azCmd); |
| 23743 | 23638 | set_table_name(&data, 0); |
| 23744 | 23639 | if( data.db ){ |
| | @@ -23769,16 +23664,16 @@ |
| 23769 | 23664 | if( sqlite3_memory_used()>mem_main_enter ){ |
| 23770 | 23665 | utf8_printf(stderr, "Memory leaked: %u bytes\n", |
| 23771 | 23666 | (unsigned int)(sqlite3_memory_used()-mem_main_enter)); |
| 23772 | 23667 | } |
| 23773 | 23668 | #endif |
| 23774 | | -#endif /* !SQLITE_SHELL_FIDDLE */ |
| 23669 | +#endif /* !SQLITE_SHELL_WASM_MODE */ |
| 23775 | 23670 | return rc; |
| 23776 | 23671 | } |
| 23777 | 23672 | |
| 23778 | 23673 | |
| 23779 | | -#ifdef SQLITE_SHELL_FIDDLE |
| 23674 | +#ifdef SQLITE_SHELL_WASM_MODE |
| 23780 | 23675 | /* Only for emcc experimentation purposes. */ |
| 23781 | 23676 | int fiddle_experiment(int a,int b){ |
| 23782 | 23677 | return a + b; |
| 23783 | 23678 | } |
| 23784 | 23679 | |
| | @@ -23895,6 +23790,6 @@ |
| 23895 | 23790 | shellState.wasm.zPos = zSql; |
| 23896 | 23791 | process_input(&shellState); |
| 23897 | 23792 | memset(&shellState.wasm, 0, sizeof(shellState.wasm)); |
| 23898 | 23793 | } |
| 23899 | 23794 | } |
| 23900 | | -#endif /* SQLITE_SHELL_FIDDLE */ |
| 23795 | +#endif /* SQLITE_SHELL_WASM_MODE */ |
| 23901 | 23796 | |