/ Check-in [2348045f]
Login

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

Overview
Comment:Backport changes to shell.c into shell.c.in.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2348045fbc3fc99e2b46095cc86db99815cd1f9254d30a3b72c2b15c02076a84
User & Date: drh 2017-08-28 14:33:27
Context
2017-08-28
15:51
Remove the rarely-used scratch memory allocator. This makes the code smaller, faster, and easier to maintain. In place of the scratch allocator, add the SQLITE_CONFIG_SMALL_MALLOC configuration option that provides a hint to SQLite that large memory allocations should be avoided. check-in: 54b00024 user: drh tags: trunk
14:33
Backport changes to shell.c into shell.c.in. check-in: 2348045f user: drh tags: trunk
11:12
Fix the ".dump", ".schema", and ".fullschema" commands of the command-line shell so that they work even if PRAGMA empty_result_callbacks is enabled. Fix for ticket [02f0f4c54f281]. check-in: cf0d3715 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

  1295   1295     char **azArg,    /* Text of each result column */
  1296   1296     char **azCol,    /* Column names */
  1297   1297     int *aiType      /* Column types */
  1298   1298   ){
  1299   1299     int i;
  1300   1300     ShellState *p = (ShellState*)pArg;
  1301   1301   
         1302  +  if( azArg==0 ) return 0;
  1302   1303     switch( p->cMode ){
  1303   1304       case MODE_Line: {
  1304   1305         int w = 5;
  1305   1306         if( azArg==0 ) break;
  1306   1307         for(i=0; i<nArg; i++){
  1307   1308           int len = strlen30(azCol[i] ? azCol[i] : "");
  1308   1309           if( len>w ) w = len;
................................................................................
  1645   1646   ** This is the callback routine from sqlite3_exec() that appends all
  1646   1647   ** output onto the end of a ShellText object.
  1647   1648   */
  1648   1649   static int captureOutputCallback(void *pArg, int nArg, char **azArg, char **az){
  1649   1650     ShellText *p = (ShellText*)pArg;
  1650   1651     int i;
  1651   1652     UNUSED_PARAMETER(az);
         1653  +  if( azArg==0 ) return 0;
  1652   1654     if( p->n ) appendText(p, "|", 0);
  1653   1655     for(i=0; i<nArg; i++){
  1654   1656       if( i ) appendText(p, ",", 0);
  1655   1657       if( azArg[i] ) appendText(p, azArg[i], 0);
  1656   1658     }
  1657   1659     return 0;
  1658   1660   }
................................................................................
  2526   2528     int rc;
  2527   2529     const char *zTable;
  2528   2530     const char *zType;
  2529   2531     const char *zSql;
  2530   2532     ShellState *p = (ShellState *)pArg;
  2531   2533   
  2532   2534     UNUSED_PARAMETER(azNotUsed);
  2533         -  if( nArg!=3 ) return 1;
         2535  +  if( nArg!=3 || azArg==0 ) return 0;
  2534   2536     zTable = azArg[0];
  2535   2537     zType = azArg[1];
  2536   2538     zSql = azArg[2];
  2537   2539   
  2538   2540     if( strcmp(zTable, "sqlite_sequence")==0 ){
  2539   2541       raw_printf(p->out, "DELETE FROM sqlite_sequence;\n");
  2540   2542     }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){
................................................................................
  6659   6661   
  6660   6662     setBinaryMode(stdin, 0);
  6661   6663     setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
  6662   6664     stdin_is_interactive = isatty(0);
  6663   6665     stdout_is_console = isatty(1);
  6664   6666   
  6665   6667   #if USE_SYSTEM_SQLITE+0!=1
  6666         -  if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){
         6668  +  if( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,60)!=0 ){
  6667   6669       utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
  6668   6670               sqlite3_sourceid(), SQLITE_SOURCE_ID);
  6669   6671       exit(1);
  6670   6672     }
  6671   6673   #endif
  6672   6674     main_init(&data);
  6673   6675   #if !SQLITE_SHELL_IS_UTF8

Changes to tool/mkshellc.tcl.

    21     21   ** source file to help make the command-line program easier to compile.
    22     22   **
    23     23   ** To modify this program, get a copy of the canonical SQLite source tree,
    24     24   ** edit the src/shell.c.in" and/or some of the other files that are included
    25     25   ** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script.
    26     26   */}
    27     27   set in [open $topdir/src/shell.c.in rb]
    28         -while {![eof $in]} {
           28  +while {1} {
    29     29     set lx [gets $in]
           30  +  if {[eof $in]} break;
    30     31     if {[regexp {^INCLUDE } $lx]} {
    31     32       set cfile [lindex $lx 1]
    32     33       puts $out "/************************* Begin $cfile ******************/"
    33     34       set in2 [open $topdir/src/$cfile rb]
    34     35       while {![eof $in2]} {
    35     36         set lx [gets $in2]
    36     37         if {[regexp {^#include "sqlite} $lx]} continue