/ Check-in [9bbe1afc]
Login

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

Overview
Comment:Add the ".changes ON|OFF" command to the sqlite3.exe command-line shell, for testing and verifying the sqlite3_changes() and sqlite3_total_changes() interfaces.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9bbe1afc1521b111a0a93803b41ff04e0ee55630
User & Date: drh 2015-12-07 21:46:19
Context
2015-12-07
23:31
Update MSVC batch build tool to the latest Windows 10 SDK version. check-in: 2ad50171 user: mistachkin tags: trunk
21:46
Add the ".changes ON|OFF" command to the sqlite3.exe command-line shell, for testing and verifying the sqlite3_changes() and sqlite3_total_changes() interfaces. check-in: 9bbe1afc user: drh tags: trunk
18:18
Fix the openDirectory() routine in the unix VFS so that it works for databases located in the root of the filesystem and for database files that have no pathname at all. check-in: e7ae120d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

   521    521   typedef struct ShellState ShellState;
   522    522   struct ShellState {
   523    523     sqlite3 *db;           /* The database */
   524    524     int echoOn;            /* True to echo input commands */
   525    525     int autoEQP;           /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
   526    526     int statsOn;           /* True to display memory stats before each finalize */
   527    527     int scanstatsOn;       /* True to display scan stats before each finalize */
          528  +  int countChanges;      /* True to display change counts */
   528    529     int backslashOn;       /* Resolve C-style \x escapes in SQL input text */
   529    530     int outCount;          /* Revert to stdout when reaching zero */
   530    531     int cnt;               /* Number of records displayed so far */
   531    532     FILE *out;             /* Write results here */
   532    533     FILE *traceOut;        /* Output for sqlite3_trace() */
   533    534     int nErr;              /* Number of errors seen */
   534    535     int mode;              /* An output mode setting */
................................................................................
  1781   1782   /*
  1782   1783   ** Text of a help message
  1783   1784   */
  1784   1785   static char zHelp[] =
  1785   1786     ".backup ?DB? FILE      Backup DB (default \"main\") to FILE\n"
  1786   1787     ".bail on|off           Stop after hitting an error.  Default OFF\n"
  1787   1788     ".binary on|off         Turn binary output on or off.  Default OFF\n"
         1789  +  ".changes on|off        Show number of rows changed by SQL\n"
  1788   1790     ".clone NEWDB           Clone data into NEWDB from the existing database\n"
  1789   1791     ".databases             List names and files of attached databases\n"
  1790   1792     ".dbinfo ?DB?           Show status information about the database\n"
  1791   1793     ".dump ?TABLE? ...      Dump the database in an SQL text format\n"
  1792   1794     "                         If TABLE specified, only dump tables matching\n"
  1793   1795     "                         LIKE pattern TABLE.\n"
  1794   1796     ".echo on|off           Turn command echo on or off\n"
................................................................................
  2752   2754   
  2753   2755     /* The undocumented ".breakpoint" command causes a call to the no-op
  2754   2756     ** routine named test_breakpoint().
  2755   2757     */
  2756   2758     if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){
  2757   2759       test_breakpoint();
  2758   2760     }else
         2761  +
         2762  +  if( c=='c' && n>=3 && strncmp(azArg[0], "changes", n)==0 ){
         2763  +    if( nArg==2 ){
         2764  +      p->countChanges = booleanValue(azArg[1]);
         2765  +    }else{
         2766  +      fprintf(stderr, "Usage: .changes on|off\n");
         2767  +      rc = 1;
         2768  +    }
         2769  +  }else
  2759   2770   
  2760   2771     if( c=='c' && strncmp(azArg[0], "clone", n)==0 ){
  2761   2772       if( nArg==2 ){
  2762   2773         tryToClone(p, azArg[1]);
  2763   2774       }else{
  2764   2775         fprintf(stderr, "Usage: .clone FILENAME\n");
  2765   2776         rc = 1;
................................................................................
  4282   4293             fprintf(stderr, "%s %s\n", zPrefix, zErrMsg);
  4283   4294             sqlite3_free(zErrMsg);
  4284   4295             zErrMsg = 0;
  4285   4296           }else{
  4286   4297             fprintf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
  4287   4298           }
  4288   4299           errCnt++;
         4300  +      }else if( p->countChanges ){
         4301  +        fprintf(p->out, "changes: %3d   total_changes: %d\n",
         4302  +                sqlite3_changes(p->db), sqlite3_total_changes(p->db));
  4289   4303         }
  4290   4304         nSql = 0;
  4291   4305         if( p->outCount ){
  4292   4306           output_reset(p);
  4293   4307           p->outCount = 0;
  4294   4308         }
  4295   4309       }else if( nSql && _all_whitespace(zSql) ){