/ Check-in [0dfdbdee]
Login

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

Overview
Comment:Add the --append option to the ".backup" command in the CLI.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0dfdbdee527b0c429703bc2696bf8d8e44a852aafe0aca742b9d7152eb1f932e
User & Date: drh 2018-05-14 00:23:08
Context
2018-05-14
00:41
Export the deduceDatabaseType() function the shell.c source file. check-in: d0f35739 user: drh tags: trunk
00:23
Add the --append option to the ".backup" command in the CLI. check-in: 0dfdbdee user: drh tags: trunk
2018-05-12
23:56
In the CLI, allow comment lines that begin with '#', but only in a context where a dot-command is allowed. In other words, '#' at the beginning of a line in the middle of an SQL statement is just part of the SQL. check-in: 4ee136d6 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

  3319   3319   #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
  3320   3320     ".archive ...           Manage SQL archives: \".archive --help\" for details\n"
  3321   3321   #endif
  3322   3322   #ifndef SQLITE_OMIT_AUTHORIZATION
  3323   3323     ".auth ON|OFF           Show authorizer callbacks\n"
  3324   3324   #endif
  3325   3325     ".backup ?DB? FILE      Backup DB (default \"main\") to FILE\n"
         3326  +  "                         Add \"--append\" to open using appendvfs.\n"
  3326   3327     ".bail on|off           Stop after hitting an error.  Default OFF\n"
  3327   3328     ".binary on|off         Turn binary output on or off.  Default OFF\n"
  3328   3329     ".cd DIRECTORY          Change the working directory to DIRECTORY\n"
  3329   3330     ".changes on|off        Show number of rows changed by SQL\n"
  3330   3331     ".check GLOB            Fail if output since .testcase does not match\n"
  3331   3332     ".clone NEWDB           Clone data into NEWDB from the existing database\n"
  3332   3333     ".databases             List names and files of attached databases\n"
................................................................................
  5616   5617      || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0)
  5617   5618     ){
  5618   5619       const char *zDestFile = 0;
  5619   5620       const char *zDb = 0;
  5620   5621       sqlite3 *pDest;
  5621   5622       sqlite3_backup *pBackup;
  5622   5623       int j;
         5624  +    const char *zVfs = 0;
  5623   5625       for(j=1; j<nArg; j++){
  5624   5626         const char *z = azArg[j];
  5625   5627         if( z[0]=='-' ){
  5626         -        while( z[0]=='-' ) z++;
  5627         -        /* No options to process at this time */
         5628  +        if( z[1]=='-' ) z++;
         5629  +        if( strcmp(z, "-append")==0 ){
         5630  +          zVfs = "apndvfs";
         5631  +        }else
  5628   5632           {
  5629   5633             utf8_printf(stderr, "unknown option: %s\n", azArg[j]);
  5630   5634             return 1;
  5631   5635           }
  5632   5636         }else if( zDestFile==0 ){
  5633   5637           zDestFile = azArg[j];
  5634   5638         }else if( zDb==0 ){
  5635   5639           zDb = zDestFile;
  5636   5640           zDestFile = azArg[j];
  5637   5641         }else{
  5638         -        raw_printf(stderr, "too many arguments to .backup\n");
         5642  +        raw_printf(stderr, "Usage: .backup ?DB? ?--append? FILENAME\n");
  5639   5643           return 1;
  5640   5644         }
  5641   5645       }
  5642   5646       if( zDestFile==0 ){
  5643   5647         raw_printf(stderr, "missing FILENAME argument on .backup\n");
  5644   5648         return 1;
  5645   5649       }
  5646   5650       if( zDb==0 ) zDb = "main";
  5647         -    rc = sqlite3_open(zDestFile, &pDest);
         5651  +    rc = sqlite3_open_v2(zDestFile, &pDest, 
         5652  +                  SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, zVfs);
  5648   5653       if( rc!=SQLITE_OK ){
  5649   5654         utf8_printf(stderr, "Error: cannot open \"%s\"\n", zDestFile);
  5650   5655         sqlite3_close(pDest);
  5651   5656         return 1;
  5652   5657       }
  5653   5658       open_db(p, 0);
  5654   5659       pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);

Changes to test/shell1.test.

   252    252   } {0 {}}
   253    253   do_test shell1-3.1.3 {
   254    254     catchcmd "test.db" ".backup FOO BAR"
   255    255   } {1 {Error: unknown database FOO}}
   256    256   do_test shell1-3.1.4 {
   257    257     # too many arguments
   258    258     catchcmd "test.db" ".backup FOO BAR BAD"
   259         -} {1 {too many arguments to .backup}}
          259  +} {1 {Usage: .backup ?DB? ?--append? FILENAME}}
   260    260   
   261    261   # .bail ON|OFF           Stop after hitting an error.  Default OFF
   262    262   do_test shell1-3.2.1 {
   263    263     catchcmd "test.db" ".bail"
   264    264   } {1 {Usage: .bail on|off}}
   265    265   do_test shell1-3.2.2 {
   266    266     catchcmd "test.db" ".bail ON"