From: larrybr Date: Sun, 21 May 2023 05:06:30 +0000 (+0000) Subject: First serious stab at FIDDLE-build-ready. Fix a flub with absent -A option for some... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6452d34e9187f4c0b034a9a69cc0e3e9634b727;p=thirdparty%2Fsqlite.git First serious stab at FIDDLE-build-ready. Fix a flub with absent -A option for some builds. FossilOrigin-Name: bfc36f0f10c37ae89bae6de96da38197998c8d95ab49397775d43d8a1ae7eeef --- diff --git a/manifest b/manifest index 1273e9b3f8..db172f79a4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C CLI\scode\scleanup\sand\sshuffle\sfor\sclarity.\sModerate\srefactoring\sto\sexploit\scommmon\spatterns.\sExtend\sOOM\ssimulation\sfor\sdebug\sbuilds.\sPlug\sone\sleak.\sFix\strivial\snit\scopied\sfrom\strunk. -D 2023-05-21T02:48:51.015 +C First\sserious\sstab\sat\sFIDDLE-build-ready.\sFix\sa\sflub\swith\sabsent\s-A\soption\sfor\ssome\sbuilds. +D 2023-05-21T05:06:30.329 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -643,7 +643,7 @@ F src/resmanage.h 626dc03a581fdbd4a52fc15bcfb49da5dec1acc3be73ebd053ef9a34fa1538 F src/resolve.c 3e53e02ce87c9582bd7e7d22f13f4094a271678d9dc72820fa257a2abb5e4032 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c 738c3a3d6929f8be66c319bad17f6b297bd60a4eb14006075c48a28487dc7786 -F src/shell.c.in 4f5342295a748024d0d8f1109c43420a991bc3377e29be79dbc53c04c18c28a4 +F src/shell.c.in 2399be6f9e2e7270126aaffd1e8e47a21342bf590073b8a6a2e16ef8d76dd001 F src/shext_linkage.h 27dcf7624df05b2a7a6d367834339a6db3636f3035157f641f7db2ec499f8f6d F src/sqlite.h.in c14a4471fcd897a03631ac7ad3d05505e895e7b6419ec5b96cae9bc4df7a9fc6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2081,8 +2081,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1687d12339f18dfc0412624765ae76d899a89e727e007e3054730533fac2a36c -R e9a2871e2bd2f059ace5da0474bfc1e2 +P b64ef7f92e7c369b279dac136983c69ab1e6fedc7f12a7dff65a86506761bce5 +R 2bc4de713d5e36abe65fec53d4e63406 U larrybr -Z 7396478e7e6bc5d5c536321d1a25d997 +Z 28193c513ee8b55c220f72b52c0149d2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 866c66611c..fd143b2db7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b64ef7f92e7c369b279dac136983c69ab1e6fedc7f12a7dff65a86506761bce5 \ No newline at end of file +bfc36f0f10c37ae89bae6de96da38197998c8d95ab49397775d43d8a1ae7eeef \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index bf0b7be66f..c434240330 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -506,6 +506,16 @@ static int console_utf8 = 0; */ static int stdout_is_console = 1; +/* +** Disable certain features for FIDDLE build. +*/ +#ifdef SQLITE_SHELL_FIDDLE +# undef SQLITE_OMIT_DYNAPROMPT +# undef SHELL_OMIT_LOAD_EXTENSION +# define SQLITE_OMIT_DYNAPROMPT 1 +# define SHELL_OMIT_LOAD_EXTENSION 1 +#endif + /* ** This statically allocated variable is used to strip a resource ** stack upon abrupt exits (involving OOM or -safe mode violations. @@ -1105,28 +1115,48 @@ typedef struct InSource { } InSource; #define INSOURCE_STR_REDIR(str, tagTo, isFrom) {isFrom, 0, str, 0, 0, tagTo } #define INSOURCE_FILE_REDIR(fh, tagTo, isFrom) {isFrom, fh, 0, 0, 0, tagTo } -#define INSOURCE_IS_INTERACTIVE(pIS) \ - ((pIS)==&termInSource && stdin_is_interactive ) #define INSOURCE_IS_INVOKEARG(pIS) \ ((pIS)==&cmdInSource) +#ifndef SQLITE_SHELL_FIDDLE +# define INSOURCE_IS_INTERACTIVE(pIS) \ + ((pIS)==&termInSource && stdin_is_interactive ) +#else +# define INSOURCE_IS_INTERACTIVE(pIS) 0 +#endif + /* These instances' addresses are taken as part of interactive input test * or test for other special handling as a command-line argument. */ +static InSource cmdInSource = { 0, 0, 0, 0, 0, "", 0 }; +#ifndef SQLITE_SHELL_FIDDLE static InSource termInSource = { 0, 0, 0, 0, 0, "", 0 }; static InSource stdInSource = { 0, 0, 0, 0, 0, "", 0 }; -static InSource cmdInSource = { 0, 0, 0, 0, 0, "", 0 }; +#else +static InSource fiddleInSource = { 0, 0, 0, 0, 0, "", 0 }; +#endif /* defined(SQLITE_SHELL_FIDDLE) */ -/* Initializer for just above 3 InSource objects */ +/* Initializer for just above 3 (non-FIDDLE) InSource objects */ +#ifndef SQLITE_SHELL_FIDDLE static void init_std_inputs(FILE *pIn ){ termInSource.inFile = pIn; stdInSource.inFile = pIn; cmdInSource.lineno = 0; } +#else +# define init_std_inputs(x) +#endif /* Setup cmdInSource to supply given text as input. */ static void set_invocation_cmd(char *zDo){ cmdInSource.iReadOffset = 0; cmdInSource.zStrIn = zDo; ++cmdInSource.lineno; } +#ifdef SQLITE_SHELL_FIDDLE +static void set_fiddle_input_text(char *zDo){ + fiddleInSource.iReadOffset = 0; + fiddleInSource.zStrIn = zDo; + if( zDo ) ++fiddleInSource.lineno; +} +#endif /* defined(SQLITE_SHELL_FIDDLE) */ /* Close an InSource object and unlink it from redirect nesting. */ static void finish_InSource( InSource **ppIS ){ @@ -1244,7 +1274,6 @@ static char *local_getline(char *zLine, InSource *pInSrc){ return zLine; } -#ifndef SQLITE_SHELL_FIDDLE /* ** Retrieve a single line of input text from designated input source. ** @@ -1305,38 +1334,6 @@ static char *one_input_line(InSource *pInSrc, char *zPrior, return zResult; } } -#else /* !defined(SQLITE_SHELL_FIDDLE) */ -/* -** Alternate one_input_line() impl for wasm mode. This is not in the primary -** impl because we need the global shellState and cannot access it from that -** function without moving lots of code around (creating a larger/messier diff). -*/ -static char *one_input_line(InSource *psrc, char *zPrior, int isContinuation){ - /* Parse the next line from shellState.wasm.zInput. */ - const char *zBegin = shellState.wasm.zPos; - const char *z = zBegin; - char *zLine = 0; - i64 nZ = 0; - - UNUSED_PARAMETER(psrc); - UNUSED_PARAMETER(isContinuation); - if(!z || !*z){ - return 0; - } - while(*z && isspace(*z)) ++z; - zBegin = z; - for(; *z && '\n'!=*z; ++nZ, ++z){} - if(nZ>0 && '\r'==zBegin[nZ-1]){ - --nZ; - } - shellState.wasm.zPos = z; - zLine = realloc(zPrior, nZ+1); - shell_check_oomm(zLine); - memcpy(zLine, zBegin, nZ); - zLine[nZ] = 0; - return zLine; -} -#endif /* SQLITE_SHELL_FIDDLE */ /* For use by shell extensions. See footnote [a] to one_input_line(). */ void free_input_line(char *z){ @@ -1967,11 +1964,7 @@ typedef struct ShellInState { ExpertInfo expert; /* Valid if previous command was ".expert OPT..." */ #ifdef SQLITE_SHELL_FIDDLE - struct { - const char * zInput; /* Input string from wasm/JS proxy */ - const char * zPos; /* Cursor pos into zInput */ - const char * zDefaultDbName; /* Default name for db file */ - } wasm; + const char * zDefaultDbName; /* Default name for db file (? not used here) */ #endif #if SHELL_DYNAMIC_EXTENSION @@ -5210,7 +5203,6 @@ static int shell_exec( sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, 1, 0); } zEQP = smprintf("EXPLAIN QUERY PLAN %s", zStmtSql); - shell_check_ooms(zEQP); rc = s3_prep_noom_free(db, &zEQP, &pExplain); if( rc==SQLITE_OK ){ while( sqlite3_step(pExplain)==SQLITE_ROW ){ @@ -7308,8 +7300,13 @@ void shellReset( } #endif /* !defined SQLITE_OMIT_VIRTUALTABLE */ -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) \ - && !defined(SQLITE_SHELL_FIDDLE) +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) +# define ARCHIVE_ENABLE 1 +#else +# define ARCHIVE_ENABLE 0 +#endif + +#if ARCHIVE_ENABLE && !defined(SQLITE_SHELL_FIDDLE) /****************************************************************************** ** The ".archive" or ".ar" command. */ @@ -8072,7 +8069,7 @@ end_ar_command: } /* End of the ".archive" or ".ar" command logic *******************************************************************************/ -#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) */ +#endif /* ARCHIVE_ENABLE && !defined(SQLITE_SHELL_FIDDLE) */ #if SQLITE_SHELL_HAVE_RECOVER /* @@ -9447,12 +9444,6 @@ DISPATCHABLE_COMMAND( seeargs ? 0 0 azArg nArg p ){ return DCR_Ok; } -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) -# define ARCHIVE_ENABLE 1 -#else -# define ARCHIVE_ENABLE 0 -#endif - CONDITION_COMMAND(archive ARCHIVE_ENABLE && !defined(SQLITE_SHELL_FIDDLE)); /***************** * The .archive command @@ -16299,14 +16290,13 @@ static void main_init(ShellInState *pDatai, ShellExState *pDatax) { #ifndef SQLITE_SHELL_FIDDLE verify_uninitialized(); #else - datai.wasm.zDefaultDbName = "/fiddle.sqlite3"; + datai.zDefaultDbName = "/fiddle.sqlite3"; #endif sqlite3_config(SQLITE_CONFIG_URI, 1); sqlite3_config(SQLITE_CONFIG_LOG, shellLog, pDatai); sqlite3_config(SQLITE_CONFIG_MULTITHREAD); sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); - init_std_inputs(stdin); /* Source at EOF (for now), saying it is command line. */ pDatai->pInSource = &cmdInSource; } @@ -16916,6 +16906,7 @@ int SQLITE_CDECL SHELL_MAIN(int argc, wchar_t **wargv){ /**** Data initialization. ****/ main_init(&datai,&datax); + init_std_inputs(stdin); #if SHELL_DATAIO_EXT datai.pFreeformExporter = (ExportHandler*)&ffExporter; datai.pColumnarExporter = (ExportHandler*)&cmExporter; @@ -17104,7 +17095,12 @@ int SQLITE_CDECL SHELL_MAIN(int argc, wchar_t **wargv){ ** (Former are arguments not naming the DB or beginning with '-'.) ** Run whichever kind there are. */ #if ARCHIVE_ENABLE - if( !argsData.bArCmd ){ + if( argsData.bArCmd ){ + open_db(&datax, OPEN_DB_ZIPFILE); + drc = arDotCommand(&datax, 1, cmdArgsBare.azCmd, cmdArgsBare.nCmd); + }else +#endif /* ARCHIVE_ENABLE */ + { /* Run bare command arguments like separate command-line inputs. */ for(i=0; i2)? 2 : drc; if( drc > DCR_Ok ) break; } - }else -#endif /* ARCHIVE_ENABLE */ - { - open_db(&datax, OPEN_DB_ZIPFILE); - drc = arDotCommand(&datax, 1, cmdArgsBare.azCmd, cmdArgsBare.nCmd); } rc = (drc>2)? 2 : drc; if( rc>0 ) goto shell_bail; }else{ - /* Run commands received from standard input + /* Run commands received from standard input (however defined.) */ +#ifndef SQLITE_SHELL_FIDDLE if( stdin_is_interactive ){ char *zHome; char *zHistory = 0; @@ -17161,7 +17153,6 @@ int SQLITE_CDECL SHELL_MAIN(int argc, wchar_t **wargv){ } datai.pInSource = &termInSource; /* read from stdin interactively */ drc = process_input(&datai); - rc = (drc>2)? 2 : drc; if( !argsData.bQuiet ){ if( zHistory ){ shell_stifle_history(2000); @@ -17172,8 +17163,12 @@ int SQLITE_CDECL SHELL_MAIN(int argc, wchar_t **wargv){ }else{ datai.pInSource = &stdInSource; /* read from stdin without prompts */ drc = process_input(&datai); - rc = (drc>2)? 2 : drc; } +#else /* !defined(SQLITE_SHELL_FIDDLE) */ + datai.pInSource = &fiddleInSource; /* read per set_fiddle_input_text() */ + drc = process_input(&datai); +#endif /* defined(SQLITE_SHELL_FIDDLE) */ + rc = (drc>2)? 2 : drc; } forget_exit_ripper(&mainRipDest); }else{ @@ -17342,10 +17337,9 @@ int fiddle_export_db( int (*xCallback)(unsigned const char *zOut, int n) ){ void fiddle_exec(const char * zSql){ if(zSql && *zSql){ if('.'==*zSql) puts(zSql); - shellStateI.wasm.zInput = zSql; - shellStateI.wasm.zPos = zSql; + set_fiddle_input_text(zSql); process_input(&shellStateI); - shellStateI.wasm.zInput = shellStateI.wasm.zPos = 0; + set_fiddle_input_text(0); } } #endif /* defined(SQLITE_SHELL_FIDDLE) */