/ Check-in [0fbc0fce]
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 | SQL archive
Timelines: family | ancestors | descendants | both | memdb-warning
Files: files | file ages | folders
SHA1: 0fbc0fcec1b3a67065fa0ebb49375bf675789edc
User & Date: drh 2014-02-10 19:27:05
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: c9eba2f7 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: 0fbc0fce user: drh tags: memdb-warning
16:13
Modify the command-line shell to print a warning when using an in-memory database. check-in: 90e9deae user: drh tags: memdb-warning
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  3496   3496     sqlite3_config(SQLITE_CONFIG_URI, 1);
  3497   3497     sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
  3498   3498     sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
  3499   3499     sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,"   ...> ");
  3500   3500     sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
  3501   3501   }
  3502   3502   
         3503  +/*
         3504  +** Arrange for subsequent text console output to be RED or normal.  Use
         3505  +** the SetConsoleTextAttribute() function on windows.  On all other
         3506  +** platforms, assume VT100 escape sequences are recognized.
         3507  +*/
         3508  +#ifdef _WIN32
         3509  +static void outputRed(void){
         3510  +   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
         3511  +         FOREGROUND_RED|FOREGROUND_INTENSITY);
         3512  +}
         3513  +static void outputNormal(void){
         3514  +  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
         3515  +         FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
         3516  +}
         3517  +#else
         3518  +static void outputRed(void){
         3519  +  printf("\033[1;31m");
         3520  +}
         3521  +static void outputNormal(void){
         3522  +  printf("\033[0m");
         3523  +}
         3524  +#endif
         3525  +
  3503   3526   /*
  3504   3527   ** Get the argument to an --option.  Throw an error and die if no argument
  3505   3528   ** is available.
  3506   3529   */
  3507   3530   static char *cmdline_option_value(int argc, char **argv, int i){
  3508   3531     if( i==argc ){
  3509   3532       fprintf(stderr, "%s: Error: missing argument to %s\n",
................................................................................
  3611   3634           exit(1);
  3612   3635         }
  3613   3636       }
  3614   3637     }
  3615   3638     if( data.zDbFilename==0 ){
  3616   3639   #ifndef SQLITE_OMIT_MEMORYDB
  3617   3640       data.zDbFilename = ":memory:";
  3618         -    warnInmemoryDb = 1;
         3641  +    warnInmemoryDb = argc==1;
  3619   3642   #else
  3620   3643       fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
  3621   3644       return 1;
  3622   3645   #endif
  3623   3646     }
  3624   3647     data.out = stdout;
  3625   3648   
................................................................................
  3748   3771       */
  3749   3772       if( stdin_is_interactive ){
  3750   3773         char *zHome;
  3751   3774         char *zHistory = 0;
  3752   3775         int nHistory;
  3753   3776         printf(
  3754   3777           "SQLite version %s %.19s\n" /*extra-version-info*/
  3755         -        "Enter \".help\" for instructions\n"
  3756         -        "Enter SQL statements terminated with a \";\"\n",
         3778  +        "Enter \".help\" for usage hints.\n",
  3757   3779           sqlite3_libversion(), sqlite3_sourceid()
  3758   3780         );
  3759   3781         if( warnInmemoryDb ){
  3760         -         printf(
  3761         -            "Warning: connected to an in-memory database. "
  3762         -            "Use \".open FILENAME\" to change\nto a persistent "
  3763         -            "on-disk database.\n"
  3764         -         );
         3782  +        printf("Connected to a ");
         3783  +        outputRed();
         3784  +        printf("transient in-memory database");
         3785  +        outputNormal();
         3786  +        printf(".\nUse \".open FILENAME\" to reopen on a "
         3787  +               "persistent database.\n");
  3765   3788         }
  3766   3789         zHome = find_home_dir();
  3767   3790         if( zHome ){
  3768   3791           nHistory = strlen30(zHome) + 20;
  3769   3792           if( (zHistory = malloc(nHistory))!=0 ){
  3770   3793             sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
  3771   3794           }