/ Check-in [09233770]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Add the --raw option to the ".read" dot-command of the command-line shell, to cause the named file to be read and sent directly into sqlite3_exec() without any interpretation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 09233770b24d69a305556241a6beeb5e4d77c0d7
User & Date: drh 2016-11-11 04:37:00
Context
2016-11-11
05:19
In the command line shell, avoid using utf8_printf() in a couple places where it is superfluous. check-in: 6311a8bd user: mistachkin tags: trunk
04:37
Add the --raw option to the ".read" dot-command of the command-line shell, to cause the named file to be read and sent directly into sqlite3_exec() without any interpretation. check-in: 09233770 user: drh tags: trunk
03:37
Take care not to try to generate code for the ATTACH and DETACH commands if there were syntax errors during parsing. Fix for ticket [2f1b168ab4d4844] check-in: b0ff183b user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.

4201
4202
4203
4204
4205
4206
4207


4208
4209
4210
4211
4212





























4213
4214
4215
4216
4217
4218
4219

4220
4221
4222
4223
4224
4225
4226

  if( c=='q' && strncmp(azArg[0], "quit", n)==0 ){
    rc = 2;
  }else

  if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 ){
    FILE *alt;


    if( nArg!=2 ){
      raw_printf(stderr, "Usage: .read FILE\n");
      rc = 1;
      goto meta_command_exit;
    }





























    alt = fopen(azArg[1], "rb");
    if( alt==0 ){
      utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
      rc = 1;
    }else{
      rc = process_input(p, alt);
      fclose(alt);

    }
  }else

  if( c=='r' && n>=3 && strncmp(azArg[0], "restore", n)==0 ){
    const char *zSrcFile;
    const char *zDb;
    sqlite3 *pSrc;







>
>
|
|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
>







4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258

  if( c=='q' && strncmp(azArg[0], "quit", n)==0 ){
    rc = 2;
  }else

  if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 ){
    FILE *alt;
    char *zFile;
    int rawMode = 0;
    if( nArg!=2 && nArg!=3 ){
      raw_printf(stderr, "Usage: .read [--raw] FILE\n");
      rc = 1;
      goto meta_command_exit;
    }
    if( nArg==3 ){
      const char *z = azArg[1];
      while( z[0]=='-' ) z++;
      if( strcmp(z,"raw")==0 ){
        rawMode = 1;
      }
      else{
        raw_printf(stderr, "unknown option: \"%s\"\n", azArg[1]);
        rc = 1;
        goto meta_command_exit;
      }
    }
    zFile = azArg[nArg-1];
    if( rawMode ){
      char *z = readFile(zFile);
      if( z==0 ){
        utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
        rc = 1;
      }else{
        char *zErr = 0;
        open_db(p, 1);
        rc = sqlite3_exec(p->db, z, callback, p, &zErr);
        sqlite3_free(z);
        if( zErr ){
          utf8_printf(stdout, "%s", zErr);
          sqlite3_free(zErr);
        }
      }
    }else{
      alt = fopen(zFile, "rb");
      if( alt==0 ){
        utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
        rc = 1;
      }else{
        rc = process_input(p, alt);
        fclose(alt);
      }
    }
  }else

  if( c=='r' && n>=3 && strncmp(azArg[0], "restore", n)==0 ){
    const char *zSrcFile;
    const char *zDb;
    sqlite3 *pSrc;