SQLite

Check-in [0fbc0fcec1]
Login

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

Overview
Comment:In the command-line shell, on the banner, warn about the use of a transient in-memory database in bold red text.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | memdb-warning
Files: files | file ages | folders
SHA1: 0fbc0fcec1b3a67065fa0ebb49375bf675789edc
User & Date: drh 2014-02-10 19:27:05.611
Context
2014-02-10
19:36
On unix, make the "transient in-memory database" text bold, but not red. Leave the text read on windows. (check-in: c9eba2f7be user: drh tags: memdb-warning)
19:27
In the command-line shell, on the banner, warn about the use of a transient in-memory database in bold red text. (check-in: 0fbc0fcec1 user: drh tags: memdb-warning)
16:13
Modify the command-line shell to print a warning when using an in-memory database. (check-in: 90e9deae4a user: drh tags: memdb-warning)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/shell.c.
3496
3497
3498
3499
3500
3501
3502























3503
3504
3505
3506
3507
3508
3509
  sqlite3_config(SQLITE_CONFIG_URI, 1);
  sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
  sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
  sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,"   ...> ");
  sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
}
























/*
** Get the argument to an --option.  Throw an error and die if no argument
** is available.
*/
static char *cmdline_option_value(int argc, char **argv, int i){
  if( i==argc ){
    fprintf(stderr, "%s: Error: missing argument to %s\n",







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
  sqlite3_config(SQLITE_CONFIG_URI, 1);
  sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
  sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
  sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,"   ...> ");
  sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
}

/*
** Arrange for subsequent text console output to be RED or normal.  Use
** the SetConsoleTextAttribute() function on windows.  On all other
** platforms, assume VT100 escape sequences are recognized.
*/
#ifdef _WIN32
static void outputRed(void){
   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
         FOREGROUND_RED|FOREGROUND_INTENSITY);
}
static void outputNormal(void){
  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
         FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
}
#else
static void outputRed(void){
  printf("\033[1;31m");
}
static void outputNormal(void){
  printf("\033[0m");
}
#endif

/*
** Get the argument to an --option.  Throw an error and die if no argument
** is available.
*/
static char *cmdline_option_value(int argc, char **argv, int i){
  if( i==argc ){
    fprintf(stderr, "%s: Error: missing argument to %s\n",
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
        exit(1);
      }
    }
  }
  if( data.zDbFilename==0 ){
#ifndef SQLITE_OMIT_MEMORYDB
    data.zDbFilename = ":memory:";
    warnInmemoryDb = 1;
#else
    fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
    return 1;
#endif
  }
  data.out = stdout;








|







3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
        exit(1);
      }
    }
  }
  if( data.zDbFilename==0 ){
#ifndef SQLITE_OMIT_MEMORYDB
    data.zDbFilename = ":memory:";
    warnInmemoryDb = argc==1;
#else
    fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
    return 1;
#endif
  }
  data.out = stdout;

3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760

3761

3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
    */
    if( stdin_is_interactive ){
      char *zHome;
      char *zHistory = 0;
      int nHistory;
      printf(
        "SQLite version %s %.19s\n" /*extra-version-info*/
        "Enter \".help\" for instructions\n"
        "Enter SQL statements terminated with a \";\"\n",
        sqlite3_libversion(), sqlite3_sourceid()
      );
      if( warnInmemoryDb ){
         printf(

            "Warning: connected to an in-memory database. "

            "Use \".open FILENAME\" to change\nto a persistent "
            "on-disk database.\n"
         );
      }
      zHome = find_home_dir();
      if( zHome ){
        nHistory = strlen30(zHome) + 20;
        if( (zHistory = malloc(nHistory))!=0 ){
          sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
        }







|
<



|
>
|
>
|
|
<







3771
3772
3773
3774
3775
3776
3777
3778

3779
3780
3781
3782
3783
3784
3785
3786
3787

3788
3789
3790
3791
3792
3793
3794
    */
    if( stdin_is_interactive ){
      char *zHome;
      char *zHistory = 0;
      int nHistory;
      printf(
        "SQLite version %s %.19s\n" /*extra-version-info*/
        "Enter \".help\" for usage hints.\n",

        sqlite3_libversion(), sqlite3_sourceid()
      );
      if( warnInmemoryDb ){
        printf("Connected to a ");
        outputRed();
        printf("transient in-memory database");
        outputNormal();
        printf(".\nUse \".open FILENAME\" to reopen on a "
               "persistent database.\n");

      }
      zHome = find_home_dir();
      if( zHome ){
        nHistory = strlen30(zHome) + 20;
        if( (zHistory = malloc(nHistory))!=0 ){
          sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
        }