-C For\ssqlite3x,\srudimentary\stesting\sin\splace\sas\smake\starget\sshellxtest\s.\sMore\sto\scome.
-D 2022-04-17T00:48:49.519
+C Move\sshell\sextension\sload\sfunctionality\sinto\sits\sown\s.shxload\scommand\sfor\susage\sand\scode\ssimplicity.
+D 2022-04-17T19:22:42.509
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
-F Makefile.in a39224b4ea1038f67c9ae5049c832e6ab8a6485ea1580dc5c54c13a37a8479d0
+F Makefile.in 3a2d4e3a13c497b24b92fa36e93f80dc49844f1ca62e5a7848b899afe7105a37
F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241
F Makefile.msc 689726a2785027e0eb34ea9ce8e67ac94bc4aebbaa6def20ddb6fa9f7b0c43b5
F README.md 2dd87a5c1d108b224921f3dd47dea567973f706e1f6959386282a626f459a70c
F src/resolve.c 18d99e7146852d6064559561769fcca0743eb32b14a97da6dbed373a30ee0e76
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c 7c106b3f36d483242b0a9c696614cd53d6f29e1ac81da6a3f0e9ea92f4211cc3
-F src/shell.c.in 47c84d1511e44ef28fb215c70a80065c6c103650579743ac60a129f541af17b2
+F src/shell.c.in 80745b0842e8becc6dc6934e7c2e4d31928108285ce4d1199466042509b5fd9f
F src/shext_linkage.h 41e7e665fffd125b38b8211dc650233d4fe54941acd8177f23d3deb9d6f70154
F src/sqlite.h.in 2a35f62185eb5e7ecc64a2f68442b538ce9be74f80f28a00abc24837edcf1c17
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3
F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f
F test/shell8.test 388471d16e4de767333107e30653983f186232c0e863f4490bb230419e830aae
-F test/shell_x/shell10.test 9b396b83c3b150ffb4c3bca62600f28ed91d0e31a4f82d4de482e20f3b84570a
+F test/shell_x/shell10.test 80bf84e9d31ca4ec3db02dcecf9fb3febc4e76d717cd567141b2e2b64c816862
F test/shell_x/shell9.test 22f15500ccdec5561cbedb3a4c28f0f2175a2b8eff1b837cc127de59c3bc0f73
F test/shmlock.test 3dbf017d34ab0c60abe6a44e447d3552154bd0c87b41eaf5ceacd408dd13fda5
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P d238fcf4beb0b121e4754e288df9906cb61d38a827f1fe38cf4aaa784520fc08
-Q +82366436ef74838dae1f379f3e5b8ad187225a30ec58fb49f047ab7c08a263cf
-R ef5b2dbf2d2afa126edf6b3816e08feb
+P b73928befb013622a369bf8f9904b5aeca626a5598884b4030229a33f684960f
+R 2c7fd3e4c92debe95d6c8ccc2dc84824
U larrybr
-Z a3ff9fe808da85c8206c0da625259951
+Z bbb8449a12e35ee62f13674b7218bc2e
# Remove this line to create a well-formed Fossil manifest.
#define SHEXT_PARSING_BIT 0
#define SHELL_EXTENDED_PARSING \
NOT_IFDEF_BIT(SHELL_OMIT_EXTENSIONS, SHEXT_PARSING_BIT)
-/* Whether build will include runtime extension via .load -extension */
+/* Whether build will include runtime extension via .shxload */
#define SHEXT_DYNEXT_BIT 1
#define SHELL_DYNAMIC_EXTENSION ( !SHELL_OMIT_LOAD_EXTENSION \
&& NOT_IFDEF_BIT(SHELL_OMIT_EXTENSIONS, SHEXT_DYNEXT_BIT) )
}
return DCR_Ok;
}
+
+/*****************
+ * The .limits and .load commands
+ */
+COLLECT_HELP_TEXT[
+ ",limits ?LIMIT_NAME? Display limit selected by its name, or all limits",
+ ".load FILE ?ENTRY? Load a SQLite extension library",
+ " If ENTRY is provided, the entry point \"sqlite_ENTRY_init\" is called.",
+ " Otherwise, the entry point name is derived from the FILE's name.",
+];
+
DISPATCHABLE_COMMAND( limits 5 1 3 ){
static const struct {
const char *zLimitName; /* Name of a limit */
return DCR_Ok|(rc!=0);
}
+DISPATCHABLE_COMMAND( load ? 2 3 ){
+ const char *zFile = 0, *zProc = 0;
+ int ai = 1, rc;
+ if( ISS(p)->bSafeMode ) return DCR_AbortError;
+ while( ai<nArg ){
+ const char *zA = azArg[ai++];
+ if( zFile==0 ) zFile = zA;
+ else if( zProc==0 ) zProc = zA;
+ else return DCR_TooMany|ai;
+ }
+ open_db(p, 0);
+ rc = sqlite3_load_extension(DBX(p), zFile, zProc, pzErr);
+ return DCR_Ok|(rc!=SQLITE_OK);
+}
+
DISPATCHABLE_COMMAND( log ? 2 2 ){
const char *zFile = azArg[1];
if( ISS(p)->bSafeMode ) return DCR_AbortError;
psi->mode = modeNominal;
}
-/*****************
- * The .load command
- * This is out of order to alleviate code clarity concerns.
- */
-#if SHELL_DYNAMIC_EXTENSION /* Avoid confusing users or mkshellc.tcl here. */
-# define LDEXT_OPTS "?ENTRY? ?..?"
-# define LDEXT_MAXARGS 0
-#else
-# define LDEXT_OPTS "?ENTRY? "
-# define LDEXT_MAXARGS 3
-#endif
-COLLECT_HELP_TEXT[
- ".load FILE "LDEXT_OPTS" Load an extension library",
-#if SHELL_DYNAMIC_EXTENSION
- " If option -shext follows the first 1 or 2 arguments, then the library",
- " will be loaded as a shell extension, and any subsequent arguments will",
- " be passed to the extension's init function. That function is named per",
- " the docs for sqlite3_load_extension(), with ENTRY taking zProc's role.",
-#else
- " If ENTRY is provided, the entry point \"sqlite_ENTRY_init\" is called.",
- " Otherwise, the entry point name is derived from the FILE's name.",
-#endif
-];
-DISPATCHABLE_COMMAND( load ? 2 LDEXT_MAXARGS ){
- const char *zFile = 0, *zProc = 0;
- char *zErrMsg = 0;
- int ai = 1, rc;
-#if SHELL_DYNAMIC_EXTENSION
- char **pzShext = 0;
-#else
- if( nArg>3 ) return DCR_TooMany|3;
-#endif
- if( ISS(p)->bSafeMode ) return DCR_AbortError;
- while( ai<nArg ){
- const char *zA = azArg[ai++];
-#if SHELL_DYNAMIC_EXTENSION
- if( optionMatch(zA, "shext") ){
- if( zFile==0 ) return DCR_Missing;
- pzShext = azArg + ai;
- break;
- }else if( zFile==0 ) zFile = zA;
- else if( zProc==0 ) zProc = zA;
-#else
- if( zFile==0 ) zFile = zA;
- else if( zProc==0 ) zProc = zA;
- else return DCR_TooMany|ai;
-#endif
- }
- open_db(p, 0);
-#if SHELL_DYNAMIC_EXTENSION
- if( pzShext ){
- rc = load_shell_extension(p, zFile, zProc, pzErr, nArg-ai, pzShext);
- }else
-#endif
- {
- rc = sqlite3_load_extension(DBX(p), zFile, zProc, pzErr);
- }
- return DCR_Ok|(rc!=SQLITE_OK);
-}
-
/*****************
* The .mode command
*/
}
/*****************
- * The .selftest*, .shell, .show, .shxopts, .stats and .system commands
+ * The .selftest*, .shell, and .show commands
*/
CONDITION_COMMAND( selftest_bool defined(SQLITE_DEBUG) );
CONDITION_COMMAND( selftest_int defined(SQLITE_DEBUG) );
-CONDITION_COMMAND( shell !defined(SQLITE_NOHAVE_SYSTEM) );
-CONDITION_COMMAND( shxopts (SHELL_EXTENSIONS)!=0 );
-CONDITION_COMMAND( system !defined(SQLITE_NOHAVE_SYSTEM) );
COLLECT_HELP_TEXT[
",selftest ?OPTIONS? Run tests defined in the SELFTEST table",
" Options:",
" -v Verbose output",
",selftest_bool ?ARGS? Show boolean values of ARGS as flag tokens",
",selftest_int ?ARGS? Show integer values of ARGS as integer tokens",
- ".shell CMD ARGS... Run CMD ARGS... in a system shell",
".show Show the current values for various settings",
- ".shxopts ?SIGNED_OPTS? Show or alter shell extension options",
- " Run without arguments to see their self-descriptive names",
- ".stats ?ARG? Show stats or turn stats on or off",
- " off Turn off automatic stat display",
- " on Turn on automatic stat display",
- " stmt Show statement stats",
- " vmstep Show the virtual machine step count only",
- ".system CMD ARGS... Run CMD ARGS... in a system shell",
];
DISPATCHABLE_COMMAND( selftest_bool 10 0 0 ){
return rc > 0;
}
-DISPATCHABLE_COMMAND( shell ? 2 0 ){
+/*****************
+ * The .shell, .stats and .system commands
+ */
+CONDITION_COMMAND( shell !defined(SQLITE_NOHAVE_SYSTEM) );
+CONDITION_COMMAND( system !defined(SQLITE_NOHAVE_SYSTEM) );
+COLLECT_HELP_TEXT[
+ ".shell CMD ARGS... Run CMD ARGS... in a system shell",
+ ".stats ?ARG? Show stats or turn stats on or off",
+ " off Turn off automatic stat display",
+ " on Turn on automatic stat display",
+ " stmt Show statement stats",
+ " vmstep Show the virtual machine step count only",
+ ".system CMD ARGS... Run CMD ARGS... in a system shell",
+];
+
+#ifndef SQLITE_NOHAVE_SYSTEM
+static DotCmdRC shellOut(char *azArg[], int nArg,
+ ShellExState *psx, char **pzErr){
char *zCmd;
int i, x;
- if( ISS(p)->bSafeMode ) return DCR_AbortError;
+ if( ISS(psx)->bSafeMode ) return DCR_AbortError;
zCmd = smprintf(strchr(azArg[1],' ')==0?"%s":"\"%s\"", azArg[1]);
- shell_check_oom(zCmd);
for(i=2; i<nArg; i++){
zCmd = smprintf(strchr(azArg[i],' ')==0?"%z %s":"%z \"%s\"",
zCmd, azArg[i]);
- shell_check_oom(zCmd);
}
+ shell_check_oom(zCmd);
x = system(zCmd);
sqlite3_free(zCmd);
if( x ) raw_printf(STD_ERR, "%s command returns %d\n", azArg[0], x);
return DCR_Ok;
}
+#endif
+DISPATCHABLE_COMMAND( shell ? 2 0 ){
+ return shellOut(azArg, nArg, p, pzErr);
+}
+
+DISPATCHABLE_COMMAND( system ? 2 0 ){
+ return shellOut(azArg, nArg, p, pzErr);
+}
+
+/*****************
+ * The .shxload and .shxopts commands
+ */
+CONDITION_COMMAND( shxload (SHELL_DYNAMIC_EXTENSION)!=0 );
+CONDITION_COMMAND( shxopts (SHELL_EXTENSIONS)!=0 );
+COLLECT_HELP_TEXT[
+ ".shxload FILE ?OPTIONS? Load a CLI shell extension library",
+ " The first option may name the init function to be called upon load.",
+ " Otherwise, its name is derived from FILE. Either way, the entry point"
+ " \"sqlite_NAME_init\" is called. All options after \"--\" are passed to",
+ " the extension's init function in the ShellExtensionLink struct.",
+ ".shxopts ?SIGNED_OPTS? Show or alter shell extension options",
+ " Run without arguments to see their self-descriptive names",
+];
+
+DISPATCHABLE_COMMAND( shxload 4 2 0 ){
+ const char *zFile = 0, *zProc = 0;
+ int ai = 1, rc;
+ char **pzExtArgs = 0;
+ if( ISS(p)->bSafeMode ) return DCR_AbortError;
+ while( ai<nArg ){
+ const char *zA = azArg[ai++];
+ if( strcmp(zA, "--")==0 ){
+ pzExtArgs = azArg + ai;
+ break;
+ }
+ if( zFile==0 ) zFile = zA;
+ else if( zProc==0 ) zProc = zA;
+ }
+ if( zFile==0 ) return DCR_Missing;
+ if( pzExtArgs==0 ) pzExtArgs = azArg + ai;
+ rc = load_shell_extension(p, zFile, zProc, pzErr, nArg-ai, pzExtArgs);
+ return DCR_Ok|(rc!=SQLITE_OK);
+}
+
DISPATCHABLE_COMMAND( shxopts 3 0 0 ){
static struct { const char *name; u8 mask; } shopts[] = {
#if SHELL_DYNAMIC_COMMANDS
raw_printf(STD_ERR, "Error: %s %s\n", zAbout, zMoan);
return DCR_CmdErred;
}
-DISPATCHABLE_COMMAND( system ? 2 0 ){
- return shellCommand(azArg, nArg, p, pzErr);
-}
DISPATCHABLE_COMMAND( show ? 1 1 ){
static const char *azBool[] = { "off", "on", "trigger", "full"};
const char *zOut;
if( hoKind==HO_Undoc ){
int ixct = 0;
utf8_printf(out, "%s\n%s\n",
- "The following commands are used for internal SQLite testing.",
- "They are undocumented and subject to change without notice.");
+ "The following commands are for SQLite diagnosis and internal testing.",
+ "They are undocumented and subject to change without notice.");
/* Bypass command lookup/resolution. This is just for internal commands. */
while( ixct<numCommands ){
struct CommandInfo *pci = &command_table[ixct];