-C Stop\sa\smemory\sleak\sin\s.import,\sand\sadd\sleak\scomplaint\sto\sCLI\sdebug\sbuilds.
-D 2022-05-07T03:53:14.691
+C Simplify\s.import\sleak\splug\sand\sarrange\sfor\sCLI\sto\sbe\srun\sunder\svalgrind.
+D 2022-05-09T12:29:47.606
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/resolve.c e9ee235c4151d2b7fa47435a219bfd30bf516a804d2f004639858087ebf3137b
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c 151adca2c9ea6f51215e4351bb8eb4f0012bf98c3d5a5c991d4a019c7cbb143e
-F src/shell.c.in 6b7ddce6ebfb52633236c174928f84558fa7471eed99ce189014d40df990c97b
+F src/shell.c.in 0ad33896c3e79a9578c507c8f0589290cbc98b0af1f31ca0cf8ddbb7601e60ef
F src/sqlite.h.in 2a35f62185eb5e7ecc64a2f68442b538ce9be74f80f28a00abc24837edcf1c17
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h f49e28c25bd941e79794db5415fdf7b202deb3bc072ed6f1ed273d578703684e
F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e
F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939
F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304
-F test/shell1.test f7a2ef8260aa01f20be3185118213b1ae70518fdcd2105f3e25b021b5ca800ac
+F test/shell1.test e4b4de56f454708e0747b52915135baa2cbfec4965406d6eaf02a4a5c22a9880
F test/shell2.test 7a3a23a9f57b99453f1679b1fe8072cb30e382a622874c0c4d97695fadb0a787
-F test/shell3.test a50628ab1d78d90889d9d3f32fb2c084ee15674771e96afe954aaa0accd1de3c
-F test/shell4.test 8f6c0fce4abed19a8a7f7262517149812a04caa905d01bdc8f5e92573504b759
-F test/shell5.test 78a7a8516b1e7de560748881424f621321549023d3e5f7ed2e1c56497f64c06c
+F test/shell3.test 91febeac0412812bf6370abb8ed72700e32bf8f9878849414518f662dfd55e8a
+F test/shell4.test 7dc8a515705bc093d8ffe381670e8fa7a969661e8ed177c35c847e3c6dfc35e2
+F test/shell5.test c8b6c54f26ec537f8558273d7ed293ca3725ef42e6b12b8f151718628bd1473b
F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3
F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f
-F test/shell8.test 388471d16e4de767333107e30653983f186232c0e863f4490bb230419e830aae
+F test/shell8.test 3fd093d481aaa94dc77fb73f1044c1f19c7efe3477a395cc4f7450133bc54915
F test/shmlock.test 3dbf017d34ab0c60abe6a44e447d3552154bd0c87b41eaf5ceacd408dd13fda5
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5
F test/temptable2.test d2940417496e2b9548e01d09990763fbe88c316504033256d51493e1f1a5ce6a
F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637
F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc
-F test/tester.tcl 18448c7801d44cc5f2690f54f803da49ed994b3968f73a393cff329e55926679
+F test/tester.tcl eea76fe47703d4bd2d12ddc761fb0be623f9a7b878e50a2dcb7bd6fe4b3040f1
F test/thread001.test b61a29dd87cf669f5f6ac96124a7c97d71b0c80d9012746072055877055cf9ef
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 4a4cecab23ef2aab20b1db466d045d56921590eb67563ab5a31f7b0a0f75c533
-R fa3a4ab48fbdc17706ad46278227efc1
+P f5f09368b33b6af00f96e5b8f763e7ee2d00ba6af2aee0f2ca86bb58c03d0b71
+R 84088aa54a74f88fa3741dd082a651c8
U larrybr
-Z 88cf4bfe2e519f3edccdf0d39a577138
+Z 4cea09d549ba44b05dc5240e31984b9e
# Remove this line to create a well-formed Fossil manifest.
-f5f09368b33b6af00f96e5b8f763e7ee2d00ba6af2aee0f2ca86bb58c03d0b71
\ No newline at end of file
+0d3e2380197aa3e725591266acaeb0d43a7e794ca9153e6c56253cdcf60720b1
\ No newline at end of file
failIfSafeMode(p, "cannot run .import in safe mode");
memset(&sCtx, 0, sizeof(sCtx));
- sCtx.z = sqlite3_malloc64(120);
- if( sCtx.z==0 ){
- import_cleanup(&sCtx);
- shell_out_of_memory();
- }
if( p->mode==MODE_Ascii ){
xRead = ascii_read_one_field;
}else{
xRead = csv_read_one_field;
}
+ rc = 1;
for(i=1; i<nArg; i++){
char *z = azArg[i];
if( z[0]=='-' && z[1]=='-' ) z++;
}else{
utf8_printf(p->out, "ERROR: extra argument: \"%s\". Usage:\n", z);
showHelp(p->out, "import");
- goto import_cleanup_fail;
+ goto meta_command_exit;
}
}else if( strcmp(z,"-v")==0 ){
eVerbose++;
}else{
utf8_printf(p->out, "ERROR: unknown option: \"%s\". Usage:\n", z);
showHelp(p->out, "import");
- goto import_cleanup_fail;
+ goto meta_command_exit;
}
}
if( zTable==0 ){
utf8_printf(p->out, "ERROR: missing %s argument. Usage:\n",
zFile==0 ? "FILE" : "TABLE");
showHelp(p->out, "import");
- import_cleanup_fail:
- rc = 1;
- import_cleanup(&sCtx);
goto meta_command_exit;
}
seenInterrupt = 0;
if( nSep==0 ){
raw_printf(stderr,
"Error: non-null column separator required for import\n");
- goto import_cleanup_fail;
+ goto meta_command_exit;
}
if( nSep>1 ){
- raw_printf(stderr,
+ raw_printf(stderr,
"Error: multi-character column separators not allowed"
" for import\n");
- goto import_cleanup_fail;
+ goto meta_command_exit;
}
nSep = strlen30(p->rowSeparator);
if( nSep==0 ){
raw_printf(stderr,
"Error: non-null row separator required for import\n");
- rc = 1;
- goto import_cleanup_fail;
+ goto meta_command_exit;
}
if( nSep==2 && p->mode==MODE_Csv && strcmp(p->rowSeparator,SEP_CrLf)==0 ){
/* When importing CSV (only), if the row separator is set to the
if( nSep>1 ){
raw_printf(stderr, "Error: multi-character row separators not allowed"
" for import\n");
- goto import_cleanup_fail;
+ goto meta_command_exit;
}
sCtx.cColSep = p->colSeparator[0];
sCtx.cRowSep = p->rowSeparator[0];
if( sCtx.zFile[0]=='|' ){
#ifdef SQLITE_OMIT_POPEN
raw_printf(stderr, "Error: pipes are not supported in this OS\n");
- goto import_cleanup_fail;
+ goto meta_command_exit;
#else
sCtx.in = popen(sCtx.zFile+1, "r");
sCtx.zFile = "<pipe>";
}
if( sCtx.in==0 ){
utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
- goto import_cleanup_fail;
+ goto meta_command_exit;
}
+ rc = 0;
if( eVerbose>=2 || (eVerbose>=1 && useOutputMode) ){
char zSep[2];
zSep[1] = 0;
output_c_string(p->out, zSep);
utf8_printf(p->out, "\n");
}
+ sCtx.z = sqlite3_malloc64(120);
+ if( sCtx.z==0 ){
+ import_cleanup(&sCtx);
+ shell_out_of_memory();
+ }
/* Below, resources must be freed before exit. */
while( (nSkip--)>0 ){
while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-set CLI [test_find_cli]
+set CLI [test_cli_invocation]
db close
forcedelete test.db test.db-journal test.db-wal
sqlite3 db test.db
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-set CLI [test_find_cli]
+set CLI [test_cli_invocation]
db close
forcedelete test.db test.db-journal test.db-wal
sqlite3 db test.db
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-set CLI [test_find_cli]
+set CLI [test_cli_invocation]
+set CLI_ONLY [test_find_cli]
db close
forcedelete test.db test.db-journal test.db-wal
sqlite3 db test.db
set fd [open t1.txt wb]
puts $fd "SELECT 'squirrel';"
close $fd
- exec $::CLI :memory: --interactive ".read t1.txt"
+ exec $::CLI_ONLY :memory: --interactive ".read t1.txt"
} {squirrel}
do_test shell4-3.2 {
set fd [open t1.txt wb]
puts $fd "SELECT 'pound: \302\243';"
close $fd
- exec $::CLI :memory: --interactive ".read t1.txt"
+ exec $::CLI_ONLY :memory: --interactive ".read t1.txt"
} {pound: £}
do_test shell4-4.1 {
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-set CLI [test_find_cli]
+set CLI [test_cli_invocation]
db close
forcedelete test.db test.db-journal test.db-wal
ifcapable !vtab {
finish_test; return
}
-set CLI [test_find_cli]
+set CLI [test_cli_invocation]
# Check to make sure the shell has been compiled with ".archive" support.
#
}
# Find the name of the 'shell' executable (e.g. "sqlite3.exe") to use for
-# the tests in shell[1-5].test. If no such executable can be found, invoke
+# the tests in shell*.test. If no such executable can be found, invoke
# [finish_test ; return] in the callers context.
#
proc test_find_cli {} {
return $prog
}
+# Find invocation of the 'shell' executable (e.g. "sqlite3.exe") to use
+# for the tests in shell*.test with optional valgrind prefix when the
+# environment variable SQLITE_CLI_VALGRIND_OPT is set. The set value
+# operates as follows:
+# empty or 0 => no valgrind prefix;
+# 1 => valgrind options for memory leak check;
+# other => use value as valgrind options.
+# If shell not found, invoke [finish_test ; return] in callers context.
+#
+proc test_cli_invocation {} {
+ set prog [test_find_binary sqlite3]
+ if {$prog==""} { return -code return }
+ if {[info exists ::env(SQLITE_CLI_VALGRIND_OPT)]} {
+ set vgo $::env(SQLITE_CLI_VALGRIND_OPT)
+ if {$vgo == 0 || $vgo eq ""} {
+ return $prog
+ } elseif {$vgo == 1} {
+ return "valgrind -q --leak-check=yes $prog"
+ } else {
+ return "valgrind $vgo $prog"
+ }
+ } else {
+ return $prog
+ }
+}
+
# Find the name of the 'sqldiff' executable (e.g. "sqlite3.exe") to use for
# the tests in sqldiff tests. If no such executable can be found, invoke
# [finish_test ; return] in the callers context.