/ Check-in [cf0d3715]
Login

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

Overview
Comment: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].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cf0d3715caac9149e65bb4802fd179d0952cfaf9add17ac243c6ca87cbd6e6b7
User & Date: drh 2017-08-28 11:12:57
Context
2017-08-28
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
2017-08-25
19:51
Fix a few over-length source code lines. No functional changes. check-in: 1783c54c user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  2655   2655     char **azArg,    /* Text of each result column */
  2656   2656     char **azCol,    /* Column names */
  2657   2657     int *aiType      /* Column types */
  2658   2658   ){
  2659   2659     int i;
  2660   2660     ShellState *p = (ShellState*)pArg;
  2661   2661   
         2662  +  if( azArg==0 ) return 0;
  2662   2663     switch( p->cMode ){
  2663   2664       case MODE_Line: {
  2664   2665         int w = 5;
  2665   2666         if( azArg==0 ) break;
  2666   2667         for(i=0; i<nArg; i++){
  2667   2668           int len = strlen30(azCol[i] ? azCol[i] : "");
  2668   2669           if( len>w ) w = len;
................................................................................
  3005   3006   ** This is the callback routine from sqlite3_exec() that appends all
  3006   3007   ** output onto the end of a ShellText object.
  3007   3008   */
  3008   3009   static int captureOutputCallback(void *pArg, int nArg, char **azArg, char **az){
  3009   3010     ShellText *p = (ShellText*)pArg;
  3010   3011     int i;
  3011   3012     UNUSED_PARAMETER(az);
         3013  +  if( azArg==0 ) return 0;
  3012   3014     if( p->n ) appendText(p, "|", 0);
  3013   3015     for(i=0; i<nArg; i++){
  3014   3016       if( i ) appendText(p, ",", 0);
  3015   3017       if( azArg[i] ) appendText(p, azArg[i], 0);
  3016   3018     }
  3017   3019     return 0;
  3018   3020   }
................................................................................
  3886   3888     int rc;
  3887   3889     const char *zTable;
  3888   3890     const char *zType;
  3889   3891     const char *zSql;
  3890   3892     ShellState *p = (ShellState *)pArg;
  3891   3893   
  3892   3894     UNUSED_PARAMETER(azNotUsed);
  3893         -  if( nArg!=3 ) return 1;
         3895  +  if( nArg!=3 || azArg==0 ) return 0;
  3894   3896     zTable = azArg[0];
  3895   3897     zType = azArg[1];
  3896   3898     zSql = azArg[2];
  3897   3899   
  3898   3900     if( strcmp(zTable, "sqlite_sequence")==0 ){
  3899   3901       raw_printf(p->out, "DELETE FROM sqlite_sequence;\n");
  3900   3902     }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){