/ Check-in [7b6a605b]
Login

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

Overview
Comment:Add the --async option to the ".backup" command in the CLI.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | vacuum-into
Files: files | file ages | folders
SHA3-256: 7b6a605b1883dfcbe237b0a58f6f0c233a109e88b521c3b3d97198526c8a0317
User & Date: drh 2018-12-08 01:09:14
Context
2018-12-10
00:40
Merge fixes from trunk. check-in: ab1e58fa user: drh tags: vacuum-into
2018-12-08
01:09
Add the --async option to the ".backup" command in the CLI. check-in: 7b6a605b user: drh tags: vacuum-into
00:43
Allow the INTO clause of VACUUM to be a text-valued expression. check-in: af172b53 user: drh tags: vacuum-into
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

  3373   3373     "      http://sqlite.org/cli.html#sqlar_archive_support",
  3374   3374   #endif
  3375   3375   #ifndef SQLITE_OMIT_AUTHORIZATION
  3376   3376     ".auth ON|OFF             Show authorizer callbacks",
  3377   3377   #endif
  3378   3378     ".backup ?DB? FILE        Backup DB (default \"main\") to FILE",
  3379   3379     "       --append            Use the appendvfs",
         3380  +  "       --async             Write to FILE without a journal and without fsync()",
  3380   3381     ".bail on|off             Stop after hitting an error.  Default OFF",
  3381   3382     ".binary on|off           Turn binary output on or off.  Default OFF",
  3382   3383     ".cd DIRECTORY            Change the working directory to DIRECTORY",
  3383   3384     ".changes on|off          Show number of rows changed by SQL",
  3384   3385     ".check GLOB              Fail if output since .testcase does not match",
  3385   3386     ".clone NEWDB             Clone data into NEWDB from the existing database",
  3386   3387     ".databases               List names and files of attached databases",
................................................................................
  5836   5837      || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0)
  5837   5838     ){
  5838   5839       const char *zDestFile = 0;
  5839   5840       const char *zDb = 0;
  5840   5841       sqlite3 *pDest;
  5841   5842       sqlite3_backup *pBackup;
  5842   5843       int j;
         5844  +    int bAsync = 0;
  5843   5845       const char *zVfs = 0;
  5844   5846       for(j=1; j<nArg; j++){
  5845   5847         const char *z = azArg[j];
  5846   5848         if( z[0]=='-' ){
  5847   5849           if( z[1]=='-' ) z++;
  5848   5850           if( strcmp(z, "-append")==0 ){
  5849   5851             zVfs = "apndvfs";
         5852  +        }else
         5853  +        if( strcmp(z, "-async")==0 ){
         5854  +          bAsync = 1;
  5850   5855           }else
  5851   5856           {
  5852   5857             utf8_printf(stderr, "unknown option: %s\n", azArg[j]);
  5853   5858             return 1;
  5854   5859           }
  5855   5860         }else if( zDestFile==0 ){
  5856   5861           zDestFile = azArg[j];
  5857   5862         }else if( zDb==0 ){
  5858   5863           zDb = zDestFile;
  5859   5864           zDestFile = azArg[j];
  5860   5865         }else{
  5861         -        raw_printf(stderr, "Usage: .backup ?DB? ?--append? FILENAME\n");
         5866  +        raw_printf(stderr, "Usage: .backup ?DB? ?OPTIONS? FILENAME\n");
  5862   5867           return 1;
  5863   5868         }
  5864   5869       }
  5865   5870       if( zDestFile==0 ){
  5866   5871         raw_printf(stderr, "missing FILENAME argument on .backup\n");
  5867   5872         return 1;
  5868   5873       }
................................................................................
  5870   5875       rc = sqlite3_open_v2(zDestFile, &pDest, 
  5871   5876                     SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, zVfs);
  5872   5877       if( rc!=SQLITE_OK ){
  5873   5878         utf8_printf(stderr, "Error: cannot open \"%s\"\n", zDestFile);
  5874   5879         close_db(pDest);
  5875   5880         return 1;
  5876   5881       }
         5882  +    if( bAsync ){
         5883  +      sqlite3_exec(pDest, "PRAGMA synchronous=OFF; PRAGMA journal_mode=OFF;",
         5884  +                   0, 0, 0);
         5885  +    }
  5877   5886       open_db(p, 0);
  5878   5887       pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);
  5879   5888       if( pBackup==0 ){
  5880   5889         utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(pDest));
  5881   5890         close_db(pDest);
  5882   5891         return 1;
  5883   5892       }