/ Check-in [67c4a8c6]
Login

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

Overview
Comment:Modify the sqltclsh startup script to look for a properly formatted SQLAR at the end of the executable. Fix the CLI so that it automatically links against appendvfs and so that the --append command-line option works.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4
User & Date: drh 2018-01-07 20:38:10
Context
2018-01-07
21:58
Remove the dependency on test_windirent.h from the generated shell.c file. check-in: 0a50c9e3 user: drh tags: trunk
20:38
Modify the sqltclsh startup script to look for a properly formatted SQLAR at the end of the executable. Fix the CLI so that it automatically links against appendvfs and so that the --append command-line option works. check-in: 67c4a8c6 user: drh tags: trunk
19:52
Improved comments on the sqlar.c and compress.c extensions that describe the differences between the "zlib format" used by SQLAR, the raw deflate format used by ZIP, and the custom format used by compress.c. No changes to code. check-in: c13415c5 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   990    990   keywordhash.h:	$(TOP)/tool/mkkeywordhash.c
   991    991   	$(BCC) -o mkkeywordhash$(BEXE) $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)/tool/mkkeywordhash.c
   992    992   	./mkkeywordhash$(BEXE) >keywordhash.h
   993    993   
   994    994   # Source files that go into making shell.c
   995    995   SHELL_SRC = \
   996    996   	$(TOP)/src/shell.c.in \
          997  +        $(TOP)/ext/misc/appendvfs.c \
   997    998   	$(TOP)/ext/misc/shathree.c \
   998    999   	$(TOP)/ext/misc/fileio.c \
   999   1000   	$(TOP)/ext/misc/completion.c \
  1000   1001   	$(TOP)/ext/misc/sqlar.c \
  1001   1002   	$(TOP)/ext/expert/sqlite3expert.c \
  1002   1003   	$(TOP)/ext/expert/sqlite3expert.h \
  1003   1004   	$(TOP)/ext/misc/zipfile.c \

Changes to Makefile.msc.

  2079   2079   
  2080   2080   keywordhash.h:	$(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe
  2081   2081   	.\mkkeywordhash.exe > keywordhash.h
  2082   2082   
  2083   2083   # Source files that go into making shell.c
  2084   2084   SHELL_SRC = \
  2085   2085   	$(TOP)\src\shell.c.in \
         2086  +        $(TOP)\ext\misc\appendvfs.c \
  2086   2087   	$(TOP)\ext\misc\shathree.c \
  2087   2088   	$(TOP)\ext\misc\fileio.c \
  2088   2089   	$(TOP)\ext\misc\completion.c \
  2089   2090   	$(TOP)\ext\expert\sqlite3expert.c \
  2090   2091   	$(TOP)\ext\expert\sqlite3expert.h \
  2091   2092   	$(TOP)\src\test_windirent.c
  2092   2093   

Changes to ext/misc/appendvfs.c.

    43     43   ** to read or write past the 1GB mark.  This restriction might be lifted in
    44     44   ** future versions.  For now, if you need a large database, then keep the
    45     45   ** database in a separate file.
    46     46   **
    47     47   ** If the file being opened is not an appended database, then this shim is
    48     48   ** a pass-through into the default underlying VFS.
    49     49   **/
    50         -#if !defined(SQLITEINT_H)
    51         -#include <sqlite3ext.h>
    52         -#endif
           50  +#include "sqlite3ext.h"
    53     51   SQLITE_EXTENSION_INIT1
    54     52   #include <string.h>
    55     53   #include <assert.h>
    56     54   
    57     55   /* The append mark at the end of the database is:
    58     56   **
    59     57   **     Start-Of-SQLite3-NNNNNNNN

Changes to main.mk.

   690    690   keywordhash.h:	$(TOP)/tool/mkkeywordhash.c
   691    691   	$(BCC) -o mkkeywordhash $(OPTS) $(TOP)/tool/mkkeywordhash.c
   692    692   	./mkkeywordhash >keywordhash.h
   693    693   
   694    694   # Source files that go into making shell.c
   695    695   SHELL_SRC = \
   696    696   	$(TOP)/src/shell.c.in \
          697  +        $(TOP)/ext/misc/appendvfs.c \
   697    698   	$(TOP)/ext/misc/shathree.c \
   698    699   	$(TOP)/ext/misc/fileio.c \
   699    700   	$(TOP)/ext/misc/completion.c \
   700    701   	$(TOP)/ext/misc/sqlar.c \
   701    702   	$(TOP)/ext/expert/sqlite3expert.c \
   702    703   	$(TOP)/ext/expert/sqlite3expert.h \
   703    704   	$(TOP)/ext/misc/zipfile.c \

Changes to src/shell.c.in.

   890    890   #if defined(_WIN32) && defined(_MSC_VER)
   891    891   INCLUDE test_windirent.c
   892    892   #define dirent DIRENT
   893    893   #endif
   894    894   INCLUDE ../ext/misc/shathree.c
   895    895   INCLUDE ../ext/misc/fileio.c
   896    896   INCLUDE ../ext/misc/completion.c
          897  +INCLUDE ../ext/misc/appendvfs.c
   897    898   #ifdef SQLITE_HAVE_ZLIB
   898    899   INCLUDE ../ext/misc/zipfile.c
   899    900   INCLUDE ../ext/misc/sqlar.c
   900    901   #endif
   901    902   INCLUDE ../ext/expert/sqlite3expert.h
   902    903   INCLUDE ../ext/expert/sqlite3expert.c
   903    904   
................................................................................
  7948   7949         sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));
  7949   7950         if( pVfs ){
  7950   7951           sqlite3_vfs_register(pVfs, 1);
  7951   7952         }else{
  7952   7953           utf8_printf(stderr, "no such VFS: \"%s\"\n", argv[i]);
  7953   7954           exit(1);
  7954   7955         }
         7956  +#ifdef SQLITE_HAVE_ZIP
         7957  +    }else if( strcmp(z,"-zip")==0 ){
         7958  +      data.openMode = SHELL_OPEN_ZIPFILE;
         7959  +#endif
         7960  +    }else if( strcmp(z,"-append")==0 ){
         7961  +      data.openMode = SHELL_OPEN_APPENDVFS;
  7955   7962       }
  7956   7963     }
  7957   7964     if( data.zDbFilename==0 ){
  7958   7965   #ifndef SQLITE_OMIT_MEMORYDB
  7959   7966       data.zDbFilename = ":memory:";
  7960   7967       warnInmemoryDb = argc==1;
  7961   7968   #else
  7962   7969       utf8_printf(stderr,"%s: Error: no database filename specified\n", Argv0);
  7963   7970       return 1;
  7964   7971   #endif
  7965   7972     }
  7966   7973     data.out = stdout;
         7974  +  sqlite3_appendvfs_init(0,0,0);
  7967   7975   
  7968   7976     /* Go ahead and open the database file if it already exists.  If the
  7969   7977     ** file does not exist, delay opening it.  This prevents empty database
  7970   7978     ** files from being created if a user mistypes the database name argument
  7971   7979     ** to the sqlite command-line tool.
  7972   7980     */
  7973   7981     if( access(data.zDbFilename, 0)==0 ){

Changes to tool/sqltclsh.c.in.

    25     25   #define SQLITE_OMIT_DEPRECATED 1
    26     26   #define SQLITE_OMIT_PROGRESS_CALLBACK 1
    27     27   #define SQLITE_OMIT_SHARED_CACHE 1
    28     28   #define SQLITE_DEFAULT_MEMSTATUS 0
    29     29   #define SQLITE_MAX_EXPR_DEPTH 0
    30     30   INCLUDE sqlite3.c
    31     31   INCLUDE $ROOT/ext/misc/appendvfs.c
           32  +INCLUDE $ROOT/ext/misc/zipfile.c
           33  +INCLUDE $ROOT/ext/misc/sqlar.c
    32     34   INCLUDE $ROOT/src/tclsqlite.c
    33     35   
    34     36   const char *sqlite3_tclapp_init_proc(Tcl_Interp *interp){
    35     37     (void)interp;
    36     38     sqlite3_appendvfs_init(0,0,0);
           39  +  sqlite3_auto_extension((void(*)(void))sqlite3_sqlar_init);
           40  +  sqlite3_auto_extension((void(*)(void))sqlite3_zipfile_init);
           41  +
    37     42     return
    38     43   BEGIN_STRING
    39     44   INCLUDE $ROOT/tool/sqltclsh.tcl
    40     45   END_STRING
    41     46   ;
    42     47   }

Changes to tool/sqltclsh.tcl.

     2      2   # field where "scripts.name" is 'main.tcl'
     3      3   #
     4      4   catch {
     5      5     if {![file exists $argv0] && [file exists $argv0.exe]} {
     6      6       append argv0 .exe
     7      7     }
     8      8     sqlite3 db $argv0 -vfs apndvfs -create 0
     9         -  set mainscript [db one {SELECT data FROM scripts WHERE name='main.tcl'}]
            9  +  set mainscript [db one {
           10  +      SELECT sqlar_uncompress(data,sz) FROM sqlar WHERE name='main.tcl'
           11  +  }]
    10     12   }
    11     13   if {[info exists mainscript]} {
    12     14     eval $mainscript
    13     15     return
    14     16   } else {
    15     17     catch {db close}
    16     18   }