Fossil

Check-in [f9c14d7d]
Login

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

Overview
Comment:Further enhance the 'sqlite3' command and make use of it in the json test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f9c14d7d6d9d3f19db5802a36adb498570bb435a
User & Date: mistachkin 2016-02-07 23:22:42
Context
2016-02-07
23:35
Robustify '--with-miniz' option handling in 'auto.def'. check-in: 7cadfc97 user: mistachkin tags: trunk
23:22
Further enhance the 'sqlite3' command and make use of it in the json test. check-in: f9c14d7d user: mistachkin tags: trunk
23:22
Make the read-only json test work on Windows. check-in: 938122da user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqlcmd.c.

   195    195   **
   196    196   ** Usage example for files_of_checkin:
   197    197   **
   198    198   **     CREATE VIRTUAL TABLE temp.foci USING files_of_checkin;
   199    199   **     SELECT * FROM foci WHERE checkinID=symbolic_name_to_rid('trunk');
   200    200   */
   201    201   void cmd_sqlite3(void){
          202  +  int noRepository;
   202    203     extern int sqlite3_shell(int, char**);
   203         -  if( find_option("no-repository", 0, 0)==0 ){
          204  +  noRepository = find_option("no-repository", 0, 0)!=0;
          205  +  if( !noRepository ){
   204    206       db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
   205         -    db_close(1);
   206    207     }
          208  +  fossil_close(1, noRepository);
   207    209     sqlite3_shutdown();
   208    210     sqlite3_shell(g.argc-1, g.argv+1);
   209    211     sqlite3_cancel_auto_extension((void(*)(void))sqlcmd_autoinit);
   210         -  g.db = 0;
   211         -  g.zMainDbType = 0;
   212         -  g.repositoryOpen = 0;
   213         -  g.localOpen = 0;
          212  +  fossil_close(0, noRepository);
   214    213   }
   215    214   
   216    215   /*
   217    216   ** This routine is called by the patched sqlite3 command-line shell in order
   218    217   ** to load the name and database connection for the open Fossil database.
   219    218   */
   220    219   void fossil_open(const char **pzRepoName){
   221    220     sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
   222    221     *pzRepoName = g.zRepositoryName;
   223    222   }
          223  +
          224  +/*
          225  +** This routine closes the Fossil databases and/or invalidates the global
          226  +** state variables that keep track of them.
          227  +*/
          228  +void fossil_close(int bDb, int noRepository){
          229  +  if( bDb ) db_close(1);
          230  +  if( noRepository ) g.zRepositoryName = 0;
          231  +  g.db = 0;
          232  +  g.zMainDbType = 0;
          233  +  g.repositoryOpen = 0;
          234  +  g.localOpen = 0;
          235  +}

Changes to test/json.test.

   748    748   
   749    749   # FOSSIL-1103 FSL_JSON_E_UNKNOWN
   750    750   #     Unknown error
   751    751   
   752    752   write_file bad.sql  {
   753    753   CREATE TABLE spam(a integer, b text);
   754    754   }
   755         -exec sqlite3 bad.fossil <bad.sql
   756         -#exec $::fossilexe sqlite3 --no-repository bad.fossil <bad.sql
          755  +exec $::fossilexe sqlite3 --no-repository bad.fossil <bad.sql
   757    756   #fossil_json HAI -R bad.fossil -expectError
   758    757   
   759    758   # FOSSIL-1104 FSL_JSON_E_TIMEOUT
   760    759   #     Timeout reached
   761    760   # FOSSIL-1105 FSL_JSON_E_ASSERT
   762    761   #     Assertion failed
   763    762   # FOSSIL-1106 FSL_JSON_E_ALLOC