From: larrybr Date: Wed, 6 Apr 2022 16:19:16 +0000 (+0000) Subject: Add sqlite3x build target. Cure CLI build warning. Tweak CLI test. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5ad1c8a62c6cc2570f3746fd872dbc6a91aeb7f;p=thirdparty%2Fsqlite.git Add sqlite3x build target. Cure CLI build warning. Tweak CLI test. FossilOrigin-Name: 45736d46cdca75d0f6eb1a0b9f2702b86851bd1da85f34c0687a3aaadf628975 --- diff --git a/Makefile.in b/Makefile.in index 62c64e2102..bbd6ae231d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -633,6 +633,9 @@ FUZZCHECK_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB FUZZCHECK_SRC = $(TOP)/test/fuzzcheck.c $(TOP)/test/ossfuzz.c DBFUZZ_OPT = +# +SHELL_OPT_NOEXT = $(SHELL_OPT) -DSHELL_OMIT_EXTENSIONS=7 + # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # @@ -656,6 +659,11 @@ libtclsqlite3.la: tclsqlite.lo libsqlite3.la -avoid-version sqlite3$(TEXE): shell.c sqlite3.c + $(LTLINK) $(READLINE_FLAGS) $(SHELL_OPT_NOEXT) -o $@ \ + shell.c sqlite3.c \ + $(LIBREADLINE) $(TLIBS) -rpath "$(libdir)" + +sqlite3x$(TEXE): shell.c sqlite3.c $(LTLINK) $(READLINE_FLAGS) $(SHELL_OPT) -o $@ \ shell.c sqlite3.c \ $(LIBREADLINE) $(TLIBS) -rpath "$(libdir)" diff --git a/manifest b/manifest index 0858fb3c0d..d91bbaaf7a 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C For\sshell\sextension\swriters,\sreduce\sboilerplate\s(mimicing\sSQLITE_EXTENSION_INIT#\smacros) -D 2022-04-04T17:27:59.089 +C Add\ssqlite3x\sbuild\starget.\sCure\sCLI\sbuild\swarning.\sTweak\sCLI\stest. +D 2022-04-06T16:19:16.378 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 39fc2a1f2ba85066c41c33c229e84e26fa51e953efa6bb703856153a308d70e2 +F Makefile.in 204f3f2e09c721ef2e0414e0e4cda0bbf52428b9557d44e26ab81c4f2558fe95 F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241 F Makefile.msc b28a8a7a977e7312f6859f560348e1eb110c21bd6cf9fab0d16537c0a514eef3 F README.md 2dd87a5c1d108b224921f3dd47dea567973f706e1f6959386282a626f459a70c @@ -556,7 +556,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c F src/resolve.c ea935b87d6fb36c78b70cdc7b28561dc8f33f2ef37048389549c7b5ef9b0ba5e F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c c366c05e48e836ea04f8ecefb9c1225745dc250c3f01bdb39e9cbb0dc25e3610 -F src/shell.c.in 37740ab1661dcd54ec9577f632afc968692aa86001a7ce21f839a6077ec3c36c x +F src/shell.c.in e9b6e41a5eda0a0f44bda420198c415f2bf65607aa721b02b49af3ea1ae9d93b x F src/shext_linkage.h 307e241b9fdc42ca02387303b0abdffd5afd04a5a8540807a5061a97fb2c26cd F src/sqlite.h.in 2a35f62185eb5e7ecc64a2f68442b538ce9be74f80f28a00abc24837edcf1c17 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1394,7 +1394,7 @@ F test/sharedA.test 49d87ec54ab640fbbc3786ee3c01de94aaa482a3a9f834ad3fe92770eb69 F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test f78eb024b6466668d281beed69267ba7bc3d76e9244c7d2c6b4bfe9c292b27f4 +F test/shell1.test 9401659c4f7319586ddd36aac15aaadff0092caa786589fc20ad069fc2cb1c74 F test/shell2.test fc6bb55f5ceaaffa284cb994aa00fd56f7ead09949c9db01c3846d65a76a7748 F test/shell3.test 4ddea2bd182e7e03249911b23ae249e7cb8a91cdc86e695198725affabe8ecd3 F test/shell4.test b232688061cce531f42ec067f3b5760e31d12409e566e2ae230951036dd156f1 @@ -1951,8 +1951,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 fa492ff57ca9d89ac623734e8ed0411e29ed6a926c2f534f2a91e41fad994b46 -R 79ea17b79c197cddd70007ce0ce4c0bc +P 761208132d99ad602b80c3fe2f0780020c54a3a4ca5be3d2b69b2e3c25e83bc1 +R 18602373e73fcb3f0aaeaf27861e5ee2 U larrybr -Z 9520f9c90493a0493ae4b54df22d1805 +Z 64853d04da23969e3518d3d6c5835753 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b36e21ac63..9863c49ef0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -761208132d99ad602b80c3fe2f0780020c54a3a4ca5be3d2b69b2e3c25e83bc1 \ No newline at end of file +45736d46cdca75d0f6eb1a0b9f2702b86851bd1da85f34c0687a3aaadf628975 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index d50bf39281..e2f106d628 100755 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -458,9 +458,10 @@ static volatile int seenInterrupt = 0; static char *Argv0; static char startupDir[PATH_MAX+1] = {0}; #if defined(_WIN32) || defined(WIN32) -# define initStartupDir() _getwd(startupDir) +# define initStartupDir() (_getwd(startupDir)!=0) #else -# define initStartupDir() getcwd(startupDir, sizeof(startupDir)) +# define initStartupDir() (getcwd(startupDir, sizeof(startupDir))!=0) + /* The useless expression silences a "unused result" warning. */ #endif /* @@ -7878,6 +7879,10 @@ FROM (\ } } +static FILE *currentOutputFile(ShellExState *p){ + return ISS(p)->out; +} + #if SHELL_DYNAMIC_EXTENSION /* Ensure there is room in loaded extension info list for one being loaded. * On exit, psi->ixExtPending can be used to index into psi->pShxLoaded. @@ -7962,7 +7967,6 @@ static int register_scripting(ShellExState *p, ExtensionId eid, return SQLITE_OK; } -#if SHELL_DYNAMIC_EXTENSION /* * Subscribe to (or unsubscribe from) messages about various changes. * Unsubscribe, effected when nkMin==NK_Unsubscribe, always succeeds. @@ -8039,11 +8043,6 @@ static void unsubscribe_extensions(ShellInState *psi){ }else ++esix; } } -#endif - -static FILE *currentOutputFile(ShellExState *p){ - return ISS(p)->out; -} static struct InSource *currentInputSource(ShellExState *p){ return ISS(p)->pInSource; @@ -13591,7 +13590,9 @@ typedef struct MetaMatchIter { const char *zPattern; union { MetaCommand *pMC; +#if SHELL_DYNAMIC_EXTENSION sqlite3_stmt *stmt; +#endif }; } MetaMatchIter; @@ -13600,32 +13601,28 @@ typedef struct MetaMatchIter { static MetaMatchIter findMatchingMetaCmds(const char *cmdFragment, ShellExState *psx){ MetaMatchIter rv = { psx, 0, 0 }; - if( psx->dbShell==0 || ISS(psx)->bDbDispatch==0 ){ - rv.zPattern = smprintf("%s*", cmdFragment? cmdFragment : ""); - shell_check_oom((void *)rv.zPattern); - rv.pMC = (MetaCommand *)command_table; - }else{ +#if SHELL_DYNAMIC_EXTENSION + if( psx->dbShell!=0 && ISS(psx)->bDbDispatch ){ /* Prepare rv.stmt to yield results glob-matching cmdFragment. */ const char *zSql = "SELECT name, extIx, cmdIx FROM "SHELL_DISP_VIEW" " "WHERE name glob (?||'*') ORDER BY name"; sqlite3_prepare_v2(psx->dbShell, zSql, -1, &rv.stmt, 0); sqlite3_bind_text(rv.stmt, 1, cmdFragment? cmdFragment : "", -1, 0); + }else +#endif + { + rv.zPattern = smprintf("%s*", cmdFragment? cmdFragment : ""); + shell_check_oom((void *)rv.zPattern); + rv.pMC = (MetaCommand *)command_table; } return rv; } /* Produce the next MetaCommand pointer from the iterator, or 0 if no next. */ static MetaCommand * nextMatchingMetaCmd(MetaMatchIter *pMMI){ MetaCommand *rv = 0; - if( pMMI->zPattern!=0 ){ - struct CommandInfo *pCI = (struct CommandInfo *)(pMMI->pMC); - assert(pCI>=command_table && pCI<=command_table+numCommands); - while( pCIzPattern, pCI->cmdName)==0 ) rv = pMMI->pMC; - pMMI->pMC = (MetaCommand *)(++pCI); - if( rv!=0 ) break; - } - }else{ +#if SHELL_DYNAMIC_EXTENSION + if( pMMI->zPattern==0 ){ int rc = sqlite3_step(pMMI->stmt); if( rc==SQLITE_ROW ){ int extIx = sqlite3_column_int(pMMI->stmt, 1); @@ -13635,6 +13632,16 @@ static MetaCommand * nextMatchingMetaCmd(MetaMatchIter *pMMI){ sqlite3_finalize(pMMI->stmt); pMMI->stmt = 0; } + }else +#endif + { + struct CommandInfo *pCI = (struct CommandInfo *)(pMMI->pMC); + assert(pCI>=command_table && pCI<=command_table+numCommands); + while( pCIzPattern, pCI->cmdName)==0 ) rv = pMMI->pMC; + pMMI->pMC = (MetaCommand *)(++pCI); + if( rv!=0 ) break; + } } return rv; } @@ -13644,10 +13651,13 @@ static void freeMetaMatchIter(MetaMatchIter *pMMI){ sqlite3_free((void *)pMMI->zPattern); pMMI->zPattern = 0; pMMI->pMC = 0; - }else{ + } +#if SHELL_DYNAMIC_EXTENSION + else{ sqlite3_finalize(pMMI->stmt); pMMI->stmt = 0; } +#endif } /***************** @@ -14453,7 +14463,9 @@ static DotCmdRC process_input(ShellInState *psi){ /* line-group processing loop (per SQL block, dot-command or comment) */ while( !bInputEnd && termKind==DCR_Ok && !bInterrupted ){ +#if SHELL_DYNAMIC_EXTENSION ScriptSupport *pSS = psi->script; +#endif int nGroupLines = 0; /* count of lines belonging to this group */ int ncLineIn = 0; /* how many (non-zero) chars are in zLineInput */ int ncLineAcc = 0; /* how many (non-zero) chars are in zLineAccum */ @@ -14628,7 +14640,9 @@ static DotCmdRC process_input(ShellInState *psi){ grow_line_buffer(&zLineAccum, &naAccum, ncLineAcc+ncLineIn+2); /* Join lines as setup by exam of previous line(s). */ if( cLineEnd!=0 ) zLineAccum[ncLineAcc++] = cLineEnd; +#if SHELL_EXTENDED_PARSING cLineEnd = '\n'; /* reset to default after use */ +#endif memcpy(zLineAccum+ncLineAcc, zLineInput, ncLineIn); iLastLine = ncLineAcc; ncLineAcc += ncLineIn; diff --git a/test/shell1.test b/test/shell1.test index bf55a72554..cdfb94ab5a 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -353,7 +353,7 @@ do_test shell1-3.7.4 { # .header(s) ON|OFF Turn display of headers on or off do_test shell1-3.9.1 { catchcmd "test.db" ".header" -} {1 {Error: Too few arguments for ".header", need 1}} +} {1 {Error: Too few arguments for ".headers", need 1}} do_test shell1-3.9.2 { catchcmd "test.db" ".header ON" } {0 {}} @@ -363,7 +363,7 @@ do_test shell1-3.9.3 { do_test shell1-3.9.4 { # too many arguments catchcmd "test.db" ".header OFF BAD" -} {1 {Error: Too many arguments for ".header", over 1}} +} {1 {Error: Too many arguments for ".headers", over 1}} # .headers is accepted alias do_test shell1-3.9.5 { catchcmd "test.db" ".headers ON"