/ Check-in [366469f5]
Login

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

Overview
Comment:In the shell, include the ".archive" command only if compiling with SQLITE_HAVE_ZLIB. Add ".archive" to the ".help" output.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 366469f5603367fabcadfc9ffe8cd1e23c649fea49a560178ca0858a16a7e4d1
User & Date: drh 2018-01-06 19:19:50
Context
2018-01-06
21:46
The shell detects and opens ZIP archives using the zipfile extension. check-in: 05c99eb8 user: drh tags: trunk
19:19
In the shell, include the ".archive" command only if compiling with SQLITE_HAVE_ZLIB. Add ".archive" to the ".help" output. check-in: 366469f5 user: drh tags: trunk
15:49
Better whitespace in the "CREATE TABLE sqlar()" statement for the ".ar" command. check-in: 252ee55a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

  2891   2891     return rc;
  2892   2892   }
  2893   2893   
  2894   2894   /*
  2895   2895   ** Text of a help message
  2896   2896   */
  2897   2897   static char zHelp[] =
         2898  +#if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
         2899  +  ".archive ...           Manage SQL archives: \".archive --help\" for details\n"
         2900  +#endif
  2898   2901   #ifndef SQLITE_OMIT_AUTHORIZATION
  2899   2902     ".auth ON|OFF           Show authorizer callbacks\n"
  2900   2903   #endif
  2901   2904     ".backup ?DB? FILE      Backup DB (default \"main\") to FILE\n"
  2902   2905     ".bail on|off           Stop after hitting an error.  Default OFF\n"
  2903   2906     ".binary on|off         Turn binary output on or off.  Default OFF\n"
  2904   2907     ".cd DIRECTORY          Change the working directory to DIRECTORY\n"
................................................................................
  4292   4295    usage:
  4293   4296     raw_printf(stderr, "Usage %s sub-command ?switches...?\n", azArg[0]);
  4294   4297     raw_printf(stderr, "Where sub-commands are:\n");
  4295   4298     raw_printf(stderr, "    fkey-indexes\n");
  4296   4299     return SQLITE_ERROR;
  4297   4300   }
  4298   4301   
         4302  +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
         4303  +/*********************************************************************************
         4304  +** The ".archive" or ".ar" command.
         4305  +*/
  4299   4306   static void shellPrepare(
  4300   4307     sqlite3 *db, 
  4301   4308     int *pRc, 
  4302   4309     const char *zSql, 
  4303   4310     sqlite3_stmt **ppStmt
  4304   4311   ){
  4305   4312     *ppStmt = 0;
................................................................................
  4361   4368       if( rc!=SQLITE_OK ){
  4362   4369         sqlite3 *db = sqlite3_db_handle(pStmt);
  4363   4370         raw_printf(stderr, "SQL error: %s\n", sqlite3_errmsg(db));
  4364   4371       }
  4365   4372       *pRc = rc;
  4366   4373     }
  4367   4374   }
  4368         -
  4369         -/* 
         4375  +/*
  4370   4376   ** Structure representing a single ".ar" command.
  4371   4377   */
  4372   4378   typedef struct ArCommand ArCommand;
  4373   4379   struct ArCommand {
  4374   4380     int eCmd;                       /* An AR_CMD_* value */
  4375   4381     const char *zFile;              /* --file argument, or NULL */
  4376   4382     const char *zDir;               /* --directory argument, or NULL */
................................................................................
  5030   5036       if( cmd.zFile ){
  5031   5037         sqlite3_close(db);
  5032   5038       }
  5033   5039     }
  5034   5040   
  5035   5041     return rc;
  5036   5042   }
         5043  +/* End of the ".archive" or ".ar" command logic
         5044  +**********************************************************************************/
         5045  +#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) */
  5037   5046   
  5038   5047   /*
  5039   5048   ** Implementation of ".expert" dot command.
  5040   5049   */
  5041   5050   static int expertDotCommand(
  5042   5051     ShellState *pState,             /* Current shell tool state */
  5043   5052     char **azArg,                   /* Array of arguments passed to dot command */
................................................................................
  5152   5161         sqlite3_set_authorizer(p->db, shellAuth, p);
  5153   5162       }else{
  5154   5163         sqlite3_set_authorizer(p->db, 0, 0);
  5155   5164       }
  5156   5165     }else
  5157   5166   #endif
  5158   5167   
  5159         -#ifndef SQLITE_OMIT_VIRTUALTABLE
  5160         -  if( c=='a' && strncmp(azArg[0], "ar", n)==0 ){
         5168  +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
         5169  +  if( c=='a' && strncmp(azArg[0], "archive", n)==0 ){
  5161   5170       open_db(p, 0);
  5162   5171       rc = arDotCommand(p, azArg, nArg);
  5163   5172     }else
  5164   5173   #endif
  5165   5174   
  5166   5175     if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0)
  5167   5176      || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0)