Compare commits

...

26 Commits

Author SHA1 Message Date
larrybr 29bc92bee2 Improve formatting of changes doc for this branch
FossilOrigin-Name: 2129cfb8c5ff2bec9a9f61fd7bf3d63a7385a14ea0161798d1869fe2b87567e6
2022-03-10 11:10:03 +00:00
larrybr 15cd45cf4d Sync w/Trunk, finish doc/sh_tweak_changes.md
FossilOrigin-Name: 5a1797c2250665d013e0a1818f90c52db1b6f67b2daff82c46c06c9d058080e7
2022-03-09 22:16:38 +00:00
larrybr b742c54cfc Add a .md summarizing CLI changes on this branch and their motivation or purpose.
FossilOrigin-Name: 5ddccc2f2885ae4068e492053dbb4e7215ce7dd052f782bffa0076b4585d175f
2022-03-08 03:10:58 +00:00
larrybr b524e6741a Sync w/3.38, add .parameter ls to CLI
FossilOrigin-Name: 8c9a5fb26ba045edef1269c5f5e8c8d87fa890b88ddb1121be72514a389a845d
2022-02-22 22:28:37 +00:00
larrybr f7394cf9a9 Sync with trunk
FossilOrigin-Name: 2b4a295c58a908288840157c3e08289af8c1d287f72e5f14b7adfd98065bf241
2022-02-15 17:04:37 +00:00
larrybr 4af7ea5b4c CLI extended parsing and .x features mostly tested
FossilOrigin-Name: 9c664984fd61d5858b436952d876bf3560333ee0edd8e1956cfe74cf9649511d
2022-02-06 14:30:16 +00:00
larrybr 4ef0175d06 Sync with trunk. More shell9.test tests to come.
FossilOrigin-Name: 2e72dc4621bcccd6ef4f01d059ff052bc39b8ea122b006d842be6102736460f4
2022-02-06 00:07:18 +00:00
larrybr cf4fb1ac20 CLI cleanup, mode push/pop, parameter list beautification
FossilOrigin-Name: 53d4582a0e9dab594264a5125324e1fab476e5fd806ebc61bd5fc6ffff10e34b
2022-02-05 23:45:07 +00:00
larrybr ab4251820f Fix CLI Windows build, refine its help, re-org ShellState
FossilOrigin-Name: 991a06a4801270fddea7375d141863dc29fa87b737c728af60c81eea8445a0ea
2022-02-05 15:26:39 +00:00
larrybr 12ee7d9acf CLI .param save/load done; many other small refinements
FossilOrigin-Name: 6d415ac2c10da26e97164cb0846683a57e6a7f3717519c5fe889e077321a2cbd
2022-02-04 21:49:47 +00:00
larrybr 7f43d714ad Fix .param edit unable to edit script vars (bad assert)
FossilOrigin-Name: 62d212d0da93102dd3b7dc4368a0c8acf2469a7f8ef8fcf60e57e69fe028600e
2022-02-04 09:39:30 +00:00
larrybr 2540eccd60 Sync to trunk. Shell tests pass.
FossilOrigin-Name: 79275b81dcd0c7d18b83614f42a0878fb30d93408e599574b61510fc8afa8c80
2022-02-03 21:07:01 +00:00
larrybr 2527e8b2f8 Scripting and .parameter enhancements most in; all in working
FossilOrigin-Name: a1581118b07b111edbad8dc930a959ec0b98461b2737619d9976ef4a498b6571
2022-02-03 20:57:47 +00:00
larrybr 23e68222f5 Take CLI's wordwrap from trunk
FossilOrigin-Name: 768c70a926bd3d5338c4d7c07689e61f03973b4bc7d9d2c62c6f83a6c2b85829
2022-02-01 15:08:10 +00:00
larrybr 9ba2dcf540 Sync to trunk
FossilOrigin-Name: f51a17b6271a8dd7c48725e4ec2df1fde0460866c81c7225dc27216ab389591e
2022-01-31 19:52:30 +00:00
larrybr d7596a2a00 Cleanup dot-command handling, make multi-line work, honor exit requests from more contexts
FossilOrigin-Name: 5cf66e89071b619d116a4707b6ff1cd7917edffe5ab504514f37da433a77b61d
2022-01-31 19:23:32 +00:00
larrybr 8d81c85a76 Sync with trunk
FossilOrigin-Name: 59693d3e732bbfd4855d97c55e91ad3fbc9d22ebd2c073c5debe958e8100c93e
2022-01-30 01:35:58 +00:00
larrybr c8a1bd9567 Enhance shell parser for multi-line dot-commands
FossilOrigin-Name: 5ed528e27b84466f165c0af52028242d95cc54dc53d6bb4d7afcbb081e6e11de
2022-01-30 01:21:12 +00:00
larrybr 63255fda5c Take CLI input redirect recursion limit from trunk
FossilOrigin-Name: 5e7020441514d1febdd6d97d6c5be4429f65310e9bcde2eb50c071aa9459a333
2022-01-24 07:11:25 +00:00
larrybr 442f1b06e8 Add CLI .x command, make string redirection work
FossilOrigin-Name: 2f2f1aaed691ba31ba70577012f785aae1f4a53ac7582bf30d26fbbec1eb3f3c
2022-01-24 04:21:20 +00:00
larrybr 10e2866c99 CLI prepared for reading string input
FossilOrigin-Name: 073ded4d185d0133b07b4548dd78f4ad5eb17ce1f5c457d89fee23281420bbff
2022-01-24 00:22:06 +00:00
larrybr 19d77e2791 Factor out DB protection lift and restore in CLI
FossilOrigin-Name: 4462ed896459ee0312f1989d9a813c65150347ebdd15b59b2aa86bbce3abec1c
2022-01-23 20:54:25 +00:00
larrybr 8a6c538ed3 Shell refinements, seeargs, booleans, undocumented commands
FossilOrigin-Name: 8735caf13fc7e30da2fc5dc90921acbb3109f965c63dbf69fa70ef19c02308c0
2022-01-23 04:19:52 +00:00
larrybr 8a30af3e1d Create new branch named "shell-tweaks"
FossilOrigin-Name: 3f13df296b7d623085d2abb1a84fb9117f79f8e653a35956266da83727eeecba
2022-01-23 02:53:25 +00:00
larrybr b6265f854c A WIP checkin, progress toward what .help promises
FossilOrigin-Name: 4688e6dff88527dbff436b811512206d31a9695095776c4e1fdff95da0b0c4d4
2022-01-20 05:20:27 +00:00
larrybr 96b922020c Initial help changes for .script (and enhanced .parameter)
FossilOrigin-Name: a94ab403eb836d3fcb9710d22da5129f58db05d3be145bc77ce1c017761e7894
2022-01-19 21:11:23 +00:00
9 changed files with 2387 additions and 544 deletions
+190
View File
@@ -0,0 +1,190 @@
# <u>Feature changes on shell-tweaks branch.</u>
This section summarizes the changes; motivation is addressed further below.
## (internal) Input stream management improvements:
* line number tracking centralized, done at arbitrary nesting
* source tracking centralized, done at arbitrary nesting
* input from either an open FILE or string content (for .x feature)
* stream switch save/restore simplified in several places
## Extension features made optional at build-time or runtime, for backwards compatibility. (Described further per-feature.)
## (internal) Query output display mode stack implemented and used.
(Associated ShellState reorg supports this, and groups members more by purpose.)
## (internal) Expand temp.sqlite_parameters usage to include "scripts".
An extra column, "uses", limits role of variables to either binding or execution. This is set when variables are created, keyed off their names.
## (internal) Refactoring and interface adjustments.
## Add --schema SCHEMA option to .dump
## Many changes and additions to .parameter subcommands:
### clear ?NAME?
Allowing selective zapping. (Was everything before.)
### edit ?OPT? NAME
Allow editing an existing or new entry. The OPT, if provided, may be -t or -e to select whether the resulting value is stored as text or evaluated as a SQL expression. A hidden option, --editor=\<something\>, may be used in place of having set environment variable DISPLAY before starting shell. This option is mentioned just when needed in an interactive session.
### list/ls output options
These are prettified with optional glob patterns.
### load ?FILE? ?NAMES?
Allow saved parameters to be loaded. With no arguments, a defaulted file in user's HOME directory is the source, and all of its parameters are loaded. With a FILE argument, named file is the source. With more arguments, selective loading from the file is done.
### save ?FILE? ?NAMES?
This is parallel to load except for direction of data flow and intolerance of FILE being read-only.
### set ?TOPT? NAME VALUE
Accept an optional type option to specify storage of the given value as a particular type, bypassing the old, "evaluate as SQL expression" behavior (which can be problematic without two levels of quoting.) Without the type option, the old behavior occurs. Also, if multiple arguments are found where VALUE would be, they are space-joined to form the stored value. (This is convenient for script use.)
### unset ?NAMES?
This is much like "clear ?NAMES?", except that with no names it is a no-op rather than an error as with prior shell versions.
## .shxopts command
This addition is to display or modify extension options.
## .x NAMES command
This will execute named parameters as if their content was fed to the input stream.
## Certain dot-commands become "undocumented".
This means that, in addition to not appearing in the website docs, they do not appear in the normal .help output. Help for them is available by entering ".help -all -all", and this is mentioned in the output of ".help -all" and ".help help".
Undocumented dot commands are: .check, .selftest-*, .seeargs, .testcase, and .testctrl .
## .seeargs command
An "undocumented" dot command to show arguments bounded by '|', for those who are unsure of the shell's quoting and expansion rules.
## For .open command
The --hexdb option without a FILE given can read in a hex DB from the current input stream, including from string sources.
## (internal) Compile option, BOOLNAMES_ARE_BOOLEAN
This adds "false" and "true" to the recognized binary switch values.
## (internal) Utility function, db_text()
This is added for reasons similar those for db_int().
## (internal) Preparation for variable expansion
This is for later addition of expansion within double-quoted command arguments.
## Dot-command parsing extension
This optional extension permits arguments to span more than one line, or more arguments to be added in subsequent lines. This is not the default behavior because it breaks backward compatibility (for ill-formed input with mis-balanced quotes.) It is enabled with either an invocation command-line option or the dot-commad, ".shxopts +parsing". With extended parsing, unclosed arguments may contain literal newlines, and lines may be be spliced if backslash is the final character (other than newline) at the end of an input line.
## (internal) Rewrite of process_input()
It was rewritten to support collection and dispatch of multi-line input in a more regular manner. It is now over-commented to aid initial write and review if desired. Its comment volume is slated for post-merge reduction.
## (semi-internal) An undocumented command-line option, -quiet
This was added to suppress the start-up banner (which contains a version string) and prompts when input is "interactive".
## (internal) Tests added for above new/changed features.
## (internal) mkshellc.tcl usefully handles simple typedefs with comments.
# <u>Motivation or justification for above shell-tweaks branch changes.</u>
The changes marked "(internal)" are generally made to either simplify the code, or to manage its complexity in a more readily understood way. It can mostly be categorized as "showing a little love" for the affected code where not strictly necessary for feature implementation.
## Input stream management improvements
This set of changes makes it easier to manage input streams, as can be seen by the impact on client code where that happens. Additionally, better error reporting is made possible from within nested sources.
## Extension features made optional
The build-time feature trimming option is for resource-constrained environments. It also serves the purpose of showing where code can be chopped out or how it can be adapted if the feature is vetoed. It may also show the feature's impact on code volume.
Runtime feature enable/disable is for features that impact backward compatibility. For example, with present releases, if the last argument for a dot command has an opening quote but no closing quote, it is considered closed by the end-of-line. With the command parsing extension enabled, such a construct begins an argument spanning more than one line. To avoid breaking old script input to the CLI, which may have such ill-formed arguments, the extension is disabled by default.
## Query output display mode stack
This is mainly a clean-up of existing functionality. It also anticipates future mode save/restore that may be exposed to users.
## Expand temp.sqlite_parameters usage to include "scripts"
This internal change reflects an implementation choice in support of scripting. It could have been done with a separate table, but this simplifies the code, UI, and documentation (to come.)
## Refactoring and interface adjustments to allow resuse.
Clean-up and maintenance burden reduction mainly motivates this.
## Add --schema SCHEMA option to .dump
Simplifies scenarios where a user attaches a DB, or creates an attached DB, for the purpose of transfering data to it from a main DB and then saving it out in .dump format. Similar convenience is made available for the TEMP DB.
## Changes and additions to .parameter subcommands
The .parameter command becomes the focal point for managing all kinds of user-alterable parameters and variables. It is easy to remember: If some parameter(s) will be created, modified, reviewed, saved, loaded, or removed, .parameter is how it is done.
### clear or unset ?NAMES?
Make it convenient to remove just selected parameters, (rather than all of them as before), for pre-save cleanup, list de-clutter, or testing effect of unbound query parameters.
### edit ?OPT? NAME
Allow convenient interactive creation or modification of parameter values, particularly ones that may have multiple lines or tax a user's perception when only a line-editor is available. The feature is only enabled for interactive sessions, as it makes little sense to begin an edit session in batch mode. Its hidden option, --editor=\<something\>, is for cases where a user has not set DISPLAY before starting the CLI, or needs to change it. It does not appear in help, but is mentioned when edit is invoked without DISPLAY being set.
### load/save ?FILE? ?NAMES?
This persistence facility is mainly for edited queries, DDL or DML that a user may wish to reuse across sessions. Or it may prove useful for commonly repeated sequences of dot commands. Or both.
### list/ls output options
These make it easier to see what is in the parameters table by using the short, "ls" form, which lists only names, or by specifying glob patterns to restrict output. With the added utility of parameters, there may be a lot more to see or avoid seeing.
### set ?TOPT? NAME VALUE
The new option, TOPT, can force the value's type or to bypass the effective eval trial for text. This makes it more deterministic for those who may not understand the detailed processing or quoting rules. Taking the VALUE to be the space-joined remaining arguments simplifies quoting in many cases.
## Added .shxopts command
By allow certain optional features, which potentially impair backward compatibility, to be enabled or disabled at runtime, users are given control over the trade between compatibility and the convenience of the new features.
## The new dot command, .x NAMES
This is a convenience for those who are often repeating some command, query, or set of commands and/or queries. Many people do not get their queries right on the first write.
## Certain dot-commands become "undocumented"
This is to reduce clutter seen by those who use the CLI to use SQLite rather than to test it. It may also reduce needless doc searches by the curious.
## Compile option, BOOLNAMES_ARE_BOOLEAN
This is a place-holder for until addition of "false" and "true" to the binary switch name set is rejected or accepted. The case for adding them is that they are a natural choice as boolean values and having "true" taken as "false" (as happens today) can be surprising.
## Extended dot-command parsing
This feature, (where arguments and/or dot commands may span line-ends), has several uses. One is for allowing ".param set \<name\> \<value\>" to specify a multi-line value, useful mainly for script creation. (Otherwise, multi-line script, which may contain complex SQL in need of line-structure, can only be created by using ".parameter edit \<name\>".) Another is for .print commands, so that literal multi-line output may be more naturally specified.
## process_input() rewrite
This was needed to support extended dot-command parsing. The difficulty of gaining that support without a rewrite, together with anticipation of later adding a TCL input feature, (which would present similar issues), easily made the rewrite appear advantageous. The code was hard to follow before, but can now be easily adapted to incorporate TCL scripting when (or if) that is added.
## added command-line option, -quiet
This facilitates testing of the ".parameter edit" feature.
## mkshellc.tcl change to handle more typedef repetition than before
This merely reduces the fragility of the feature. It was motivated by added use of a sometimes-redundant typedef which exposed the older fragility.
+13 -11
View File
@@ -1,5 +1,5 @@
C Further\srefinements\sto\sthe\ssqlite_offset()\sfix\sfrom\s[6029514b08b88e3f].
D 2022-03-09T18:29:19.102
C Improve\sformatting\sof\schanges\sdoc\sfor\sthis\sbranch
D 2022-03-10T11:10:03.722
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -41,6 +41,7 @@ F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd
F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f
F doc/lemon.html efc0cd2345d66905505d98f862e1c571512def0ceb5b016cb658fd4918eb76a3
F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710
F doc/sh_tweak_changes.md d7cc2d4f528696722bda07f15e82e68d4fcc4f4dff07cdd5274ee36abdf38aa1
F doc/trusted-schema.md 33625008620e879c7bcfbbfa079587612c434fa094d338b08242288d358c3e8a
F doc/vdbesort-memory.md 4da2639c14cd24a31e0af694b1a8dd37eaf277aff3867e9a8cc14046bc49df56
F doc/vfs-shm.txt e101f27ea02a8387ce46a05be2b1a902a021d37a
@@ -553,7 +554,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
F src/resolve.c ea935b87d6fb36c78b70cdc7b28561dc8f33f2ef37048389549c7b5ef9b0ba5e
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c 4890a3cfee0bc60ff231c3a44db37968859ab0be156983dbcc0c096109832cdd
F src/shell.c.in 69d1e59da4881f096ab47fbd3e6d99794f3e4a43f41fd9e4d2e845c9b8d20fd5
F src/shell.c.in 68eddd95fa2a3545499e3f9c59cf28aff483589884c42fa7de10931afce7aa42
F src/sqlite.h.in e82ac380b307659d0892f502b742f825504e78729f4edaadce946003b9c00816
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h a95cb9ed106e3d39e2118e4dcc15a14faec3fa50d0093425083d340d9dfd96e6
@@ -1390,12 +1391,13 @@ F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8
F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304
F test/shell1.test b224e0793c5f48aa3749e65d8c64b93a30731bd206f2e41e6c5f1bee1bdb16c6
F test/shell2.test 89e4b2db062d52baed75022227b462d085cff495809de1699652779d8e0257d6
F test/shell3.test a50628ab1d78d90889d9d3f32fb2c084ee15674771e96afe954aaa0accd1de3c
F test/shell4.test 8f6c0fce4abed19a8a7f7262517149812a04caa905d01bdc8f5e92573504b759
F test/shell5.test 0a9920d81fae28c45cd5dbd1deb809487a23c5f4b422a49f9d31c85f926d4a9c
F test/shell3.test 4ddea2bd182e7e03249911b23ae249e7cb8a91cdc86e695198725affabe8ecd3
F test/shell4.test 867e0675d7b096d6b93de534541e07c7f5ffafa3e6612695ecf55180802e1115
F test/shell5.test 8f4ac4f22852cfe50259a99c31e9e0c4200ab7e901caf73777c9abca6b601814
F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3
F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f
F test/shell8.test 388471d16e4de767333107e30653983f186232c0e863f4490bb230419e830aae
F test/shell9.test b9a361ea2d33f4950bcedf91fe71201356c663415e24fa049feeb1f86cc25fcb
F test/shmlock.test 3dbf017d34ab0c60abe6a44e447d3552154bd0c87b41eaf5ceacd408dd13fda5
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5
@@ -1878,7 +1880,7 @@ F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61
F tool/mkopcodeh.tcl 5dab48c49a25452257494e9601702ab63adaba6bd54a9b382615fa52661c8f8c
F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa
F tool/mkpragmatab.tcl bd07bd59d45d0f3448e123d6937e9811195f9908a51e09d774609883055bfd3d
F tool/mkshellc.tcl df5d249617f9cc94d5c48eb0401673eb3f31f383ecbc54e8a13ca3dd97e89450
F tool/mkshellc.tcl 5a9e27449694b179d2facde3fa10ff5a2d689be25822526addc20a1f1d9a12ec
F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f
@@ -1944,8 +1946,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 642a0b4752743216271e4f855a465515ef7f6a985f280251e18d67e3d5fb694b
R e003996df7c18cb8469e22c2bd0a359b
U drh
Z b55793a1f68bedfa10993b4fd3b3fa4f
P 5a1797c2250665d013e0a1818f90c52db1b6f67b2daff82c46c06c9d058080e7
R 5c01fa176890fe506ddfbaf5b91b0bb9
U larrybr
Z b98fb326f8f5ba3355de2a5d288c631c
# Remove this line to create a well-formed Fossil manifest.
+1 -1
View File
@@ -1 +1 @@
6f838305e2c848a43b210bd1b7b962fb9e3c41de34de778675e6578fcd99f397
2129cfb8c5ff2bec9a9f61fd7bf3d63a7385a14ea0161798d1869fe2b87567e6
+1911 -526
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -97,9 +97,10 @@ do_test shell3-2.6 {
catchcmd "foo.db" ".tables"
} {0 {}}
do_test shell3-2.7 {
catchcmd "foo.db" "CREATE TABLE"
} {1 {Parse error near line 1: incomplete input}}
catchcmd "foo.db" "CREATE TABLE;"
} {1 {Parse error near line 1: near ";": syntax error
CREATE TABLE;
^--- error here}}
#----------------------------------------------------------------------------
# shell3-3.*: Basic tests for processing odd SQL constructs.
+3 -1
View File
@@ -144,6 +144,8 @@ do_test shell4-4.1 {
puts $fd ".read t1.txt"
close $fd
catchcmd ":memory:" ".read t1.txt"
} {1 {Input nesting limit (25) reached at line 1. Check recursion.}}
} {1 {Input nesting limit (25) reached, from line 1 of "t1.txt"
from line 1 of "t1.txt" from line 1 of "t1.txt" ...
ERROR: Check recursion.}}
finish_test
+1 -1
View File
@@ -486,7 +486,7 @@ do_test shell5-4.4 {
CREATE TEMP TABLE t8(a, b, c);
.import shell5.csv t8
.nullvalue #
SELECT * FROM temp.t8
SELECT * FROM temp.t8;
}]
} {0 1,2,3}
+256
View File
@@ -0,0 +1,256 @@
# 2022 Feb 5
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# The focus of this file is testing the CLI shell tool enhanced parsing,
# new .parameter subcommands and uses, and the new .x meta-command.
#
#
# Test plan:
#
# shell9-1.*: command line parsing and acting accordingly
# shell9-2.*: Basic "dot" command, cross-line token parsing
# shell9-3.*: .parameter set options and types
# shell9-4.*: .parameter save/load operation
# shell9-5.*: Ensure "dot" commands and SQL intermix ok.
# shell9-6.*: .x command operation and refusal
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set CLI [test_find_cli]
db close
forcedelete test.db test.db-journal test.db-wal
forcedelete x.db xn.db
sqlite3 db test.db
#----------------------------------------------------------------------------
# Test cases shell9-1.*: command line parsing and acting accordingly
do_test shell9-1.1 {
set res [catchcmd ":memory: -cmd .quit" ""]
} {0 {}}
do_test shell9-1.2 {
set res [catchcmd ":memory: -shxopts 1 -cmd .shxopts -cmd .quit" ""]
} {0 { name value "-shxopts set"
-------- ----- ---------------
parsing 1 "-shxopts 0x01"
all_opts 0 "-shxopts 0x07"}}
do_test shell9-1.3 {
set res [catchcmd ":memory: -cmd .shxopts -cmd .quit" ""]
} {0 { name value "-shxopts set"
-------- ----- ---------------
parsing 0 "-shxopts 0x01"
all_opts 0 "-shxopts 0x07"}}
#----------------------------------------------------------------------------
# Test cases shell9-2.*: Basic "dot" command, cross-line token parsing
set cmds ".print 'l1\nl2'\n.print 'a\\\nb'"
do_test shell9-2.1 {
set res [catchcmd ":memory: -shxopts 1" $cmds]
} {0 {l1
l2
ab}}
set cmds " .print \"l1\nl2\"\n .print \"a\\\nb\" \n# c\n ## c"
do_test shell9-2.2 {
set res [catchcmd ":memory: -shxopts 1" $cmds]
} {0 {l1
l2
ab}}
set cmds ".echo on\n.seeargs 'a'\\\n'b'\n#!"
do_test shell9-2.3 {
set res [catchcmd ":memory: -shxopts 1" $cmds]
} {0 {.seeargs 'a''b'
a|b|}}
set cmds ".echo on\n.seeargs a\\\nb\n#!"
do_test shell9-2.4 {
set res [catchcmd ":memory: -shxopts 1" $cmds]
} {0 {.seeargs ab
ab|}}
set cmds ".echo 1\n.print \"\\\"\nq\\\"\""
do_test shell9-2.5 {
set res [catchcmd ":memory: -shxopts 1" $cmds]
} {0 {.print "\"
q\""
"
q"}}
#----------------------------------------------------------------------------
# Test cases shell9-3.*: .parameter set options and types
set cmds {
.pa set -b b x'a5a5'
.pa set -i ii 33-11
.pa set -i ir 3.3-1.1
.pa set -n ni 3-1
.pa set -n nr 3.3-1.1
.pa set -r ri 1
.pa set -r rr 1.2
.pa set -t t 123
.mode list
select typeof(value) from temp.sqlite_parameters order by key;
}
do_test shell9-3.1 {
set res [catchcmd ":memory:" $cmds]
} {0 {blob
integer
integer
integer
real
real
real
text}}
set cmds {
.pa set expr 1 + 2 * 3
.pa set text "'1 + 2*3'"
.pa set -t ttext 1 + 2*3
.pa list
}
do_test shell9-3.2 {
set res [catchcmd ":memory:" $cmds]
} {0 {Scripts
name value
expr 7
text 1 + 2*3
ttext 1 + 2*3}}
set cmds {
.pa set a "'a'"
.pa set b "'b'"
.pa set c "'c'"
.pa unset
.pa list
.pa clear a
.pa list
.pa unset b
.pa list
.pa clear
.pa list
.pa set d "'e'"
.pa set e "'e'"
.pa unset d e
.pa list
}
do_test shell9-3.3 {
set res [catchcmd ":memory:" $cmds]
} {0 {Scripts
name value
a a
b b
c c
Scripts
name value
b b
c c
Scripts
name value
c c}}
if {$::tcl_platform(platform)=="unix"} {
proc set_ed {sayWhat} {
global env
set env(VISUAL) "echo SELECT $sayWhat ';' >"
return 1
}
} elseif {$::tcl_platform(platform)=="windows"} {
proc set_ed {sayWhat} {
global env
set env(VISUAL) "echo SELECT $sayWhat ; >"
return 1
}
} else { return 0 }
if {[set_ed @name]} {
set cmds {
.pa set @name Fido
.pa edit -t dog
.x dog
}
do_test shell9-3.4 {
set res [catchcmd ":memory: -quiet 1 -shxopts 1 -interactive" $cmds]
} {0 Fido}
}
#----------------------------------------------------------------------------
# Test cases shell9-4.*: .parameter save/load operation
set cmds {
.pa set -t x '.print Ex'
.pa set -i $n 7
.pa save xn.db
.pa save x.db x
.pa clear
.pa load xn.db
.pa list
.pa clear
.pa load x.db
.pa list
.pa clear
.pa load xn.db $n
.pa list
}
do_test shell9-4.1 {
set res [catchcmd ":memory: -shxopts 1" $cmds]
} {0 {Binding Values:
name value
$n 7
Scripts
name value
x .print Ex
Scripts
name value
x .print Ex
Binding Values:
name value
$n 7}}
forcedelete x.db xn.db
#----------------------------------------------------------------------------
# Test cases shell9-5.*: Ensure "dot" commands and SQL intermix ok.
set cmds {
.pa set -t mixed "
.print Hi.
select 'Hi.';
.print 'Good\
Bye.'
select 'Good'||
' Bye.';
"
.x mixed
}
do_test shell9-5.1 {
set res [catchcmd ":memory: -shxopts 1" $cmds]
} {0 {Hi.
Hi.
Good Bye.
Good Bye.}}
#----------------------------------------------------------------------------
# Test cases shell9-6.*: .x command operation and refusal
set cmds {
.pa set -t $v '.print Ok'
.x $v
}
do_test shell9-6.1 {
set res [catchcmd ":memory: -bail -shxopts 1" $cmds]
} {1 {Skipping badly named $v. Run ".help x"}}
finish_test
+8 -1
View File
@@ -38,7 +38,14 @@ proc omit_redundant_typedefs {line} {
if {[info exists typedef_seen($line)]} {
return "/* $line */"
}
set typedef_seen($line) 1
if {[regexp {\s(\w+)\s*;} $line _ tdname]} {
if {[info exists typedef_seen($tdname)]} {
return "/* [regsub {;} $line {; **/}]"
}
set typedef_seen($tdname) 1
} else {
set typedef_seen($line) 1
}
}
return $line
}