/ Check-in [bde431b1]
Login

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

Overview
Comment:Add the "--newlines" option to the ".dump" command in the shell to disable the newline escaping mechanism.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bde431b1e332feaeb516dc46d180e2b2f42820c471feed7eda89452ada898dc9
User & Date: drh 2017-07-10 18:04:41
Context
2017-07-10
18:33
In LSM, avoid calling the VFS xTestLock method to test for a lock that conflicts with one held by the same process. The results of such a call are considered undefined (since they are different under win32 and posix). check-in: a82a9bea user: dan tags: trunk
18:04
Add the "--newlines" option to the ".dump" command in the shell to disable the newline escaping mechanism. check-in: bde431b1 user: drh tags: trunk
17:00
When multiple constraints need to be evaluated for a row, do any constraints that involve correlated subqueries last. Hence, the priority is index-covered constraints first, correlated subquery constraints last, and all others in the middle. This is a follow-on and improvement to the push-down optimization of check-in [d7bb79ed]. check-in: c4cb9048 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  1519   1519   ** These are the allowed shellFlgs values
  1520   1520   */
  1521   1521   #define SHFLG_Scratch        0x00000001 /* The --scratch option is used */
  1522   1522   #define SHFLG_Pagecache      0x00000002 /* The --pagecache option is used */
  1523   1523   #define SHFLG_Lookaside      0x00000004 /* Lookaside memory is used */
  1524   1524   #define SHFLG_Backslash      0x00000008 /* The --backslash option is used */
  1525   1525   #define SHFLG_PreserveRowid  0x00000010 /* .dump preserves rowid values */
  1526         -#define SHFLG_CountChanges   0x00000020 /* .changes setting */
  1527         -#define SHFLG_Echo           0x00000040 /* .echo or --echo setting */
         1526  +#define SHFLG_Newlines       0x00000020 /* .dump --newline flag */
         1527  +#define SHFLG_CountChanges   0x00000040 /* .changes setting */
         1528  +#define SHFLG_Echo           0x00000080 /* .echo or --echo setting */
  1528   1529   
  1529   1530   /*
  1530   1531   ** Macros for testing and setting shellFlgs
  1531   1532   */
  1532   1533   #define ShellHasFlag(P,X)    (((P)->shellFlgs & (X))!=0)
  1533   1534   #define ShellSetFlag(P,X)    ((P)->shellFlgs|=(X))
  1534   1535   #define ShellClearFlag(P,X)  ((P)->shellFlgs&=(~(X)))
................................................................................
  2191   2192         }
  2192   2193         p->cnt++;
  2193   2194         for(i=0; i<nArg; i++){
  2194   2195           raw_printf(p->out, i>0 ? "," : " VALUES(");
  2195   2196           if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
  2196   2197             utf8_printf(p->out,"NULL");
  2197   2198           }else if( aiType && aiType[i]==SQLITE_TEXT ){
  2198         -          output_quoted_escaped_string(p->out, azArg[i]);
         2199  +          if( ShellHasFlag(p, SHFLG_Newlines) ){
         2200  +            output_quoted_string(p->out, azArg[i]);
         2201  +          }else{
         2202  +            output_quoted_escaped_string(p->out, azArg[i]);
         2203  +          }
  2199   2204           }else if( aiType && aiType[i]==SQLITE_INTEGER ){
  2200   2205             utf8_printf(p->out,"%s", azArg[i]);
  2201   2206           }else if( aiType && aiType[i]==SQLITE_FLOAT ){
  2202   2207             char z[50];
  2203   2208             double r = sqlite3_column_double(p->pStmt, i);
  2204   2209             sqlite3_snprintf(50,z,"%!.20g", r);
  2205   2210             raw_printf(p->out, "%s", z);
  2206   2211           }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
  2207   2212             const void *pBlob = sqlite3_column_blob(p->pStmt, i);
  2208   2213             int nBlob = sqlite3_column_bytes(p->pStmt, i);
  2209   2214             output_hex_blob(p->out, pBlob, nBlob);
  2210   2215           }else if( isNumber(azArg[i], 0) ){
  2211   2216             utf8_printf(p->out,"%s", azArg[i]);
         2217  +        }else if( ShellHasFlag(p, SHFLG_Newlines) ){
         2218  +          output_quoted_string(p->out, azArg[i]);
  2212   2219           }else{
  2213   2220             output_quoted_escaped_string(p->out, azArg[i]);
  2214   2221           }
  2215   2222         }
  2216   2223         raw_printf(p->out,");\n");
  2217   2224         break;
  2218   2225       }
................................................................................
  4926   4933       rc = shell_dbinfo_command(p, nArg, azArg);
  4927   4934     }else
  4928   4935   
  4929   4936     if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
  4930   4937       const char *zLike = 0;
  4931   4938       int i;
  4932   4939       int savedShowHeader = p->showHeader;
  4933         -    ShellClearFlag(p, SHFLG_PreserveRowid);
         4940  +    ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines);
  4934   4941       for(i=1; i<nArg; i++){
  4935   4942         if( azArg[i][0]=='-' ){
  4936   4943           const char *z = azArg[i]+1;
  4937   4944           if( z[0]=='-' ) z++;
  4938   4945           if( strcmp(z,"preserve-rowids")==0 ){
  4939   4946   #ifdef SQLITE_OMIT_VIRTUALTABLE
  4940   4947             raw_printf(stderr, "The --preserve-rowids option is not compatible"
................................................................................
  4941   4948                                " with SQLITE_OMIT_VIRTUALTABLE\n");
  4942   4949             rc = 1;
  4943   4950             goto meta_command_exit;
  4944   4951   #else
  4945   4952             ShellSetFlag(p, SHFLG_PreserveRowid);
  4946   4953   #endif
  4947   4954           }else
         4955  +        if( strcmp(z,"newlines")==0 ){
         4956  +          ShellSetFlag(p, SHFLG_Newlines);
         4957  +        }else
  4948   4958           {
  4949   4959             raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
  4950   4960             rc = 1;
  4951   4961             goto meta_command_exit;
  4952   4962           }
  4953   4963         }else if( zLike ){
  4954         -        raw_printf(stderr, "Usage: .dump ?--preserve-rowids? ?LIKE-PATTERN?\n");
         4964  +        raw_printf(stderr, "Usage: .dump ?--preserve-rowids? "
         4965  +                           "?--newlines? ?LIKE-PATTERN?\n");
  4955   4966           rc = 1;
  4956   4967           goto meta_command_exit;
  4957   4968         }else{
  4958   4969           zLike = azArg[i];
  4959   4970         }
  4960   4971       }
  4961   4972       open_db(p, 0);

Changes to test/shell1.test.

   296    296     set res [catchcmd "test.db" ".dump FOO"]
   297    297     list [regexp {BEGIN TRANSACTION;} $res] \
   298    298          [regexp {COMMIT;} $res]
   299    299   } {1 1}
   300    300   do_test shell1-3.4.3 {
   301    301     # too many arguments
   302    302     catchcmd "test.db" ".dump FOO BAD"
   303         -} {1 {Usage: .dump ?--preserve-rowids? ?LIKE-PATTERN?}}
          303  +} {1 {Usage: .dump ?--preserve-rowids? ?--newlines? ?LIKE-PATTERN?}}
   304    304   
   305    305   # .echo ON|OFF           Turn command echo on or off
   306    306   do_test shell1-3.5.1 {
   307    307     catchcmd "test.db" ".echo"
   308    308   } {1 {Usage: .echo on|off}}
   309    309   do_test shell1-3.5.2 {
   310    310     catchcmd "test.db" ".echo ON"