Documentation Source Text

Check-in [a4e4f94863]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Preliminary documentation for the .sha3sum and .selftest commands of the CLI.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a4e4f94863a9977803c47f344346f755212ea199
User & Date: drh 2017-03-15 13:56:48
Context
2017-03-15
14:08
Fix typos and improve the wording of the .selftest documentation. check-in: 6aaee6c270 user: drh tags: trunk
13:56
Preliminary documentation for the .sha3sum and .selftest commands of the CLI. check-in: a4e4f94863 user: drh tags: trunk
2017-03-14
23:28
Tighten and formalize the hack in althttpd that allows .well-known path prefixes on URIs. check-in: adbefa195f user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to pages/changes.in.

33
34
35
36
37
38
39


40
41
42
43
44
45
46
    [CHECK constraints].
<li>Enhance the query plans for joins to detect empty tables early and
    halt without doing unnecessary work.
<li>Enhance the [sqlite3_mprintf()] family of interfaces and the [printf SQL function]
    to put comma separators at the thousands marks for integers, if the "," format modifier
    is used in between the "%" and the "d" (example: "%,d").
<li>Added the -D[SQLITE_MAX_MEMORY]=<i>N</i> compile-time option.


<li>Various performance improvements.
<p><b>Bug Fixes:</b>
<li>Ensure that indexed expressions with collating sequences are handled correctly.
    Fix for ticket [https://www.sqlite.org/src/info/eb703ba7b50c1a5|eb703ba7b50c1a5].
<li>Fix a bug in the 'start of ...' modifiers for the [date and time functions].
    Ticket [https://www.sqlite.org/src/info/6097cb92745327a1|6097cb92745327a1]
<li>In the [RBU extension], add extra sync operations to avoid the possibility of







>
>







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    [CHECK constraints].
<li>Enhance the query plans for joins to detect empty tables early and
    halt without doing unnecessary work.
<li>Enhance the [sqlite3_mprintf()] family of interfaces and the [printf SQL function]
    to put comma separators at the thousands marks for integers, if the "," format modifier
    is used in between the "%" and the "d" (example: "%,d").
<li>Added the -D[SQLITE_MAX_MEMORY]=<i>N</i> compile-time option.
<li>Added the [.sha3sum dot-command] and the [.selftest dot-command] 
    to the [command-line shell]
<li>Various performance improvements.
<p><b>Bug Fixes:</b>
<li>Ensure that indexed expressions with collating sequences are handled correctly.
    Fix for ticket [https://www.sqlite.org/src/info/eb703ba7b50c1a5|eb703ba7b50c1a5].
<li>Fix a bug in the 'start of ...' modifiers for the [date and time functions].
    Ticket [https://www.sqlite.org/src/info/6097cb92745327a1|6097cb92745327a1]
<li>In the [RBU extension], add extra sync operations to avoid the possibility of

Changes to pages/cli.in.

730
731
732
733
734
735
736


























































737
738
739
740
741
742
743
as a second argument to the ".load" command.

<p>Source code for several useful extensions can be found in the
<a href="http://www.sqlite.org/src/tree?name=ext/misc&ci=trunk">ext/misc</a>
subdirectory of the SQLite source tree.  You can use these extensions
as-is, or as a basis for creating your own custom extensions to address
your own particular needs.



























































<tcl>hd_fragment dotother</tcl>
<h1>Other Dot Commands</h1>

<p>There are many other dot-commands available in the command-line
shell.  See the ".help" command for a complete list for any particular
version and build of SQLite.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
as a second argument to the ".load" command.

<p>Source code for several useful extensions can be found in the
<a href="http://www.sqlite.org/src/tree?name=ext/misc&ci=trunk">ext/misc</a>
subdirectory of the SQLite source tree.  You can use these extensions
as-is, or as a basis for creating your own custom extensions to address
your own particular needs.

<tcl>hd_fragment sha3sum {.sha3sum dot-command}</tcl>
<h1>Cryptographic Hashes Of Database Content</h1>

<p>The ".sha3sum" dot-command computes a
[https://en.wikipedia.org/wiki/SHA-3|SHA3] hash of the <em>content</em>
of the database.  To be clear, the hash is computed over the database content,
not its representation on disk.  This means, for example, that a [VACUUM]
or similar data-preserving transformation does not change the hash.

<p>The ".sha3sum" command supports options "--sha3-224", "--sha3-256", 
"--sha3-384", and "--sha3-512" to define which variety of SHA3 to use
for the hash.  The default is SHA3-256.

<p>The database schema (in the [sqlite_master] table) is not normally
included in the hash, but can be added by the "--schema" option.

<p>The ".sha3sum" command takes a single optional argument which is a
[LIKE] pattern.  If this option is present, only tables whose names match
the [LIKE] pattern will be hashed.

<p>The ".sha3sum" command is implemented with the help of the
[https://www.sqlite.org/src/file/ext/misc/shathree.c|extension function "sha3_query()"]
that is included with the command-line shell.

<tcl>hd_fragment selftest {.selftest dot-command}</tcl>
<h1>Database Content Self-Tests</h1>

<p>The ".selftest" command attempts to verify that a database is
intact and is not corrupt.

<p>The ".selftest" command looks for a table in schema named "selftest"
and defined as follows:

<tcl>DisplayCode {
CREATE TABLE selftest(
  tno INTEGER PRIMARY KEY,  -- Test number
  op TEXT,                  -- 'run' or 'memo'
  cmd TEXT,                 -- SQL command to run, or text of "memo"
  ans TEXT                  -- Expected result of the SQL command
);
}</tcl>

<p>The .selftest command reads the rows of selftest in "tno" order.
For each 'memo' row, it writes the text in 'cmd' to the screen.  For
each 'run' row, it runs the 'cmd' text as SQL and compares the result
to the value in 'ans', and shows an error message if the two differ.

<p>If there is no selftest table, the ".selftest" command runs
a [PRAGMA integrity_check].

<p>The ".selftest --init" command creates the selftest table if it
does not already exists, then appends entries that check the SHA3
hash of the content of all tables.  Subsequent runs of ".selftest"
will verify that the database has not been changed in any way.  To
generates tests to verify that a subset of the tables are unchanged,
simply run ".selftest --init" then [DELETE] the selftest rows that
refer to tables that are not constant.  

<tcl>hd_fragment dotother</tcl>
<h1>Other Dot Commands</h1>

<p>There are many other dot-commands available in the command-line
shell.  See the ".help" command for a complete list for any particular
version and build of SQLite.