Fixes to the appendvfs.c extension. Add the "sqltclsh" application that
uses appendvfs.c to find its scripts. FossilOrigin-Name: ee248b529c2396c5480fb99b0a1dc31032627ec8241eca4a8c0fff257bb4a088
This commit is contained in:
parent
233ff96ec5
commit
dd2a43a225
@ -556,7 +556,8 @@ TESTPROGS = \
|
||||
sqlite3$(TEXE) \
|
||||
sqlite3_analyzer$(TEXE) \
|
||||
sqldiff$(TEXE) \
|
||||
dbhash$(TEXE)
|
||||
dbhash$(TEXE) \
|
||||
sqltclsh$(TEXE)
|
||||
|
||||
# Databases containing fuzzer test cases
|
||||
#
|
||||
@ -1190,6 +1191,12 @@ sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $
|
||||
sqlite3_analyzer$(TEXE): sqlite3_analyzer.c
|
||||
$(LTLINK) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS)
|
||||
|
||||
sqltclsh.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/sqltclsh.tcl $(TOP)/ext/misc/appendvfs.c $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in
|
||||
$(TCLSH_CMD) $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in >sqltclsh.c
|
||||
|
||||
sqltclsh$(TEXE): sqltclsh.c
|
||||
$(LTLINK) sqltclsh.c -o $@ $(LIBTCL) $(TLIBS)
|
||||
|
||||
CHECKER_DEPS =\
|
||||
$(TOP)/tool/mkccode.tcl \
|
||||
sqlite3.c \
|
||||
|
@ -47,7 +47,9 @@
|
||||
** If the file being opened is not an appended database, then this shim is
|
||||
** a pass-through into the default underlying VFS.
|
||||
**/
|
||||
#if !defined(SQLITEINT_H)
|
||||
#include <sqlite3ext.h>
|
||||
#endif
|
||||
SQLITE_EXTENSION_INIT1
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
@ -458,6 +460,7 @@ static int apndOpen(
|
||||
}
|
||||
if( (flags & SQLITE_OPEN_CREATE)==0 ){
|
||||
pSubFile->pMethods->xClose(pSubFile);
|
||||
pFile->pMethods = 0;
|
||||
return SQLITE_CANTOPEN;
|
||||
}
|
||||
p->iPgOne = (sz+0xfff) & ~(sqlite3_int64)0xfff;
|
||||
|
9
main.mk
9
main.mk
@ -484,7 +484,8 @@ TESTPROGS = \
|
||||
sqlite3_analyzer$(EXE) \
|
||||
sqlite3_checker$(EXE) \
|
||||
sqldiff$(EXE) \
|
||||
dbhash$(EXE)
|
||||
dbhash$(EXE) \
|
||||
sqltclsh$(EXE)
|
||||
|
||||
# Databases containing fuzzer test cases
|
||||
#
|
||||
@ -809,6 +810,12 @@ sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $
|
||||
sqlite3_analyzer$(EXE): sqlite3_analyzer.c
|
||||
$(TCCX) $(TCL_FLAGS) sqlite3_analyzer.c -o $@ $(LIBTCL) $(THREADLIB)
|
||||
|
||||
sqltclsh.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/sqltclsh.tcl $(TOP)/ext/misc/appendvfs.c $(TOP)/tool/mkccode.tcl
|
||||
tclsh $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in >sqltclsh.c
|
||||
|
||||
sqltclsh$(EXE): sqltclsh.c
|
||||
$(TCCX) $(TCL_FLAGS) sqltclsh.c -o $@ $(LIBTCL) $(THREADLIB)
|
||||
|
||||
CHECKER_DEPS =\
|
||||
$(TOP)/tool/mkccode.tcl \
|
||||
sqlite3.c \
|
||||
|
18
manifest
18
manifest
@ -1,6 +1,6 @@
|
||||
C The\s"apndvfs"\sVFS\sshim\snow\sappears\sto\sbe\sworking\sfor\sboth\sreads\sand\swrites.
|
||||
D 2017-12-14T16:57:11.644
|
||||
F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8
|
||||
C Fixes\sto\sthe\sappendvfs.c\sextension.\s\sAdd\sthe\s"sqltclsh"\sapplication\sthat\nuses\sappendvfs.c\sto\sfind\sits\sscripts.
|
||||
D 2017-12-14T19:24:00.444
|
||||
F Makefile.in 053284f237e955fba2f386fd9f87020199e6dbcbce9f48bc02cf431458afbe07
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc a2492b29176edc3c754aa7a2f7daa20cd3fa20a56e3ee64e376092836177c42a
|
||||
F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681
|
||||
@ -260,7 +260,7 @@ F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f607
|
||||
F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2
|
||||
F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87
|
||||
F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb
|
||||
F ext/misc/appendvfs.c ee71fbc918ab4c526a5935a3153c1cc4e0b601c081da8f9a549e0e9d01bdbca5
|
||||
F ext/misc/appendvfs.c 8cc3ae6633e7d97ca9c3c9a48c647e9ba23f8d24f3d5f5f596272a81dc50c398
|
||||
F ext/misc/btreeinfo.c d7fd9a2fe2fa33ba28488e2fce703ebecc759219ea9e0bb3b254784866c0a676
|
||||
F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005
|
||||
F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704
|
||||
@ -396,7 +396,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f
|
||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
|
||||
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
||||
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
|
||||
F main.mk 6123b0b2db806ddb482c24786ad6603a289df720382a3bce8f532d76a94c84b1
|
||||
F main.mk d0278b8833203dc60ed81eed12412d90559fcd3470e0fd5d509d41ef74a3d64b
|
||||
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
|
||||
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
|
||||
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
|
||||
@ -1650,6 +1650,8 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd
|
||||
F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec883030b710c
|
||||
F tool/sqldiff.c 30879bbc8de686df4624e86adce2d8981f500904c1cfb55b5d1eea2ffd9341eb
|
||||
F tool/sqlite3_analyzer.c.in 7eeaae8b0d7577662acaabbb11107af0659d1b41bc1dfdd4d91422de27127968
|
||||
F tool/sqltclsh.c.in e1f48150f755bfbe0194478cba50aa9f2f5183bb1efbdd6456532cce3cd2e18d
|
||||
F tool/sqltclsh.tcl 71bdb62c8f6b37c05b2d377e870c3dd13ee96cc4fee5b5ae5215ae9a0aca088d
|
||||
F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f
|
||||
F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43
|
||||
F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d
|
||||
@ -1681,7 +1683,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P e343c63cbd754f37c33c939cd0b6f1ecc6202e60c6e66cd65c23cc8d571a994e
|
||||
R 427fca803286f3061d4cdb1346b5bd46
|
||||
P 7f7b72d83633922e2b5dbf0d3455d0fea72cc6b8925ffcb78dfbad7b3c4b26e9
|
||||
R 4666f6f48678fbbcc815c221172efa48
|
||||
U drh
|
||||
Z 919006b84ebd33ef7833311db2cf1160
|
||||
Z 47302a3d5371e2c5e325f342d15c1218
|
||||
|
@ -1 +1 @@
|
||||
7f7b72d83633922e2b5dbf0d3455d0fea72cc6b8925ffcb78dfbad7b3c4b26e9
|
||||
ee248b529c2396c5480fb99b0a1dc31032627ec8241eca4a8c0fff257bb4a088
|
42
tool/sqltclsh.c.in
Normal file
42
tool/sqltclsh.c.in
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
** This is the source code to a "tclsh" that has SQLite built-in.
|
||||
**
|
||||
** The startup script is located as follows:
|
||||
**
|
||||
** (1) Open the executable as an appended SQLite database and try to
|
||||
** read the startup script out of that database.
|
||||
**
|
||||
** (2) If the first argument is a readable file, try to open that file
|
||||
** as an SQLite database and read the startup script out of that
|
||||
** database.
|
||||
**
|
||||
** (3) If the first argument is a readable file with a ".tcl" extension,
|
||||
** then try to run that script directly.
|
||||
**
|
||||
** If none of the above steps work, then the program runs as an interactive
|
||||
** tclsh.
|
||||
*/
|
||||
#define TCLSH_INIT_PROC sqlite3_tclapp_init_proc
|
||||
#define SQLITE_ENABLE_DBSTAT_VTAB 1
|
||||
#undef SQLITE_THREADSAFE
|
||||
#define SQLITE_THREADSAFE 0
|
||||
#undef SQLITE_ENABLE_COLUMN_METADATA
|
||||
#define SQLITE_OMIT_DECLTYPE 1
|
||||
#define SQLITE_OMIT_DEPRECATED 1
|
||||
#define SQLITE_OMIT_PROGRESS_CALLBACK 1
|
||||
#define SQLITE_OMIT_SHARED_CACHE 1
|
||||
#define SQLITE_DEFAULT_MEMSTATUS 0
|
||||
#define SQLITE_MAX_EXPR_DEPTH 0
|
||||
INCLUDE sqlite3.c
|
||||
INCLUDE $ROOT/ext/misc/appendvfs.c
|
||||
INCLUDE $ROOT/src/tclsqlite.c
|
||||
|
||||
const char *sqlite3_tclapp_init_proc(Tcl_Interp *interp){
|
||||
(void)interp;
|
||||
sqlite3_appendvfs_init(0,0,0);
|
||||
return
|
||||
BEGIN_STRING
|
||||
INCLUDE $ROOT/tool/sqltclsh.tcl
|
||||
END_STRING
|
||||
;
|
||||
}
|
66
tool/sqltclsh.tcl
Normal file
66
tool/sqltclsh.tcl
Normal file
@ -0,0 +1,66 @@
|
||||
# Try to open the executable as a database and read the "scripts.data"
|
||||
# field where "scripts.name" is 'main.tcl'
|
||||
#
|
||||
catch {
|
||||
sqlite3 db $argv0 -vfs apndvfs -create 0
|
||||
set mainscript [db one {SELECT data FROM scripts WHERE name='main.tcl'}]
|
||||
}
|
||||
if {[info exists mainscript]} {
|
||||
eval $mainscript
|
||||
return
|
||||
} else {
|
||||
catch {db close}
|
||||
}
|
||||
|
||||
# Try to open file named in the first argument as a database and
|
||||
# read the "scripts.data" field where "scripts.name" is 'main.tcl'
|
||||
#
|
||||
if {[llength $argv]>0 && [file readable [lindex $argv 0]]} {
|
||||
catch {
|
||||
sqlite3 db [lindex $argv 0] -vfs apndvfs -create 0
|
||||
set mainscript [db one {SELECT data FROM scripts WHERE name='main.tcl'}]
|
||||
set argv0 [lindex $argv 0]
|
||||
set argv [lrange $argv 1 end]
|
||||
}
|
||||
if {[info exists mainscript]} {
|
||||
eval $mainscript
|
||||
return
|
||||
} else {
|
||||
catch {db close}
|
||||
}
|
||||
if {[string match *.tcl [lindex $argv 0]]} {
|
||||
set fd [open [lindex $argv 0] rb]
|
||||
set mainscript [read $fd]
|
||||
close $fd
|
||||
unset fd
|
||||
set argv0 [lindex $argv 0]
|
||||
set argv [lrange $argv 1 end]
|
||||
}
|
||||
if {[info exists mainscript]} {
|
||||
eval $mainscript
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
# If all else fails, do an interactive loop
|
||||
#
|
||||
set line {}
|
||||
while {![eof stdin]} {
|
||||
if {$line!=""} {
|
||||
puts -nonewline "> "
|
||||
} else {
|
||||
puts -nonewline "% "
|
||||
}
|
||||
flush stdout
|
||||
append line [gets stdin]
|
||||
if {[info complete $line]} {
|
||||
if {[catch {uplevel #0 $line} result]} {
|
||||
puts stderr "Error: $result"
|
||||
} elseif {$result!=""} {
|
||||
puts $result
|
||||
}
|
||||
set line {}
|
||||
} else {
|
||||
append line \\n"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user