/ Check-in [c7303d01]
Login

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

Overview
Comment:Add the "eForce" parameter to the sqlite3_multiplex_shutdown() entry point in test_multiplex.c. Shutdown is forced if true. Shutdown is not done if there are pending database connections and eForce is false, but an error log entry is made instead.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c7303d0139f7e7f4fa7060b52942e6c6c6d4b622
User & Date: drh 2014-07-30 15:43:05
Context
2014-07-30
21:10
Add three new static mutexes for use by the application. This is a partial import of changes from the threads branch. check-in: 3aad0196 user: drh tags: trunk
15:43
Add the "eForce" parameter to the sqlite3_multiplex_shutdown() entry point in test_multiplex.c. Shutdown is forced if true. Shutdown is not done if there are pending database connections and eForce is false, but an error log entry is made instead. check-in: c7303d01 user: drh tags: trunk
13:56
Ensure that the correct number of columns in a UNIQUE index are checked for uniqueness, regardless of whether or not the original table has a ROWID or if the columns are NOT NULL, etc. Ticket [9a6daf340df99ba93c]. check-in: 6b785e92 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_multiplex.c.

  1172   1172   **
  1173   1173   ** All SQLite database connections must be closed before calling this
  1174   1174   ** routine.
  1175   1175   **
  1176   1176   ** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once while
  1177   1177   ** shutting down in order to free all remaining multiplex groups.
  1178   1178   */
  1179         -int sqlite3_multiplex_shutdown(void){
         1179  +int sqlite3_multiplex_shutdown(int eForce){
         1180  +  int rc = SQLITE_OK;
  1180   1181     if( gMultiplex.isInitialized==0 ) return SQLITE_MISUSE;
  1181         -  if( gMultiplex.pGroups ) return SQLITE_MISUSE;
         1182  +  if( gMultiplex.pGroups ){
         1183  +    sqlite3_log(SQLITE_MISUSE, "sqlite3_multiplex_shutdown() called "
         1184  +                "while database connections are still open");
         1185  +    if( !eForce ) return SQLITE_MISUSE;
         1186  +    rc = SQLITE_MISUSE;
         1187  +  }
  1182   1188     gMultiplex.isInitialized = 0;
  1183   1189     sqlite3_mutex_free(gMultiplex.pMutex);
  1184   1190     sqlite3_vfs_unregister(&gMultiplex.sThisVfs);
  1185   1191     memset(&gMultiplex, 0, sizeof(gMultiplex));
  1186         -  return SQLITE_OK;
         1192  +  return rc;
  1187   1193   }
  1188   1194   
  1189   1195   /***************************** Test Code ***********************************/
  1190   1196   #ifdef SQLITE_TEST
  1191   1197   #include <tcl.h>
  1192   1198   extern const char *sqlite3ErrName(int);
  1193   1199   
................................................................................
  1232   1238     int objc,
  1233   1239     Tcl_Obj *CONST objv[]
  1234   1240   ){
  1235   1241     int rc;                         /* Value returned by multiplex_shutdown() */
  1236   1242   
  1237   1243     UNUSED_PARAMETER(clientData);
  1238   1244   
  1239         -  if( objc!=1 ){
  1240         -    Tcl_WrongNumArgs(interp, 1, objv, "");
         1245  +  if( objc==2 && strcmp(Tcl_GetString(objv[1]),"-force")!=0 ){
         1246  +    objc = 3;
         1247  +  }
         1248  +  if( (objc!=1 && objc!=2) ){
         1249  +    Tcl_WrongNumArgs(interp, 1, objv, "?-force?");
  1241   1250       return TCL_ERROR;
  1242   1251     }
  1243   1252   
  1244   1253     /* Call sqlite3_multiplex_shutdown() */
  1245         -  rc = sqlite3_multiplex_shutdown();
         1254  +  rc = sqlite3_multiplex_shutdown(objc==2);
  1246   1255     Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);
  1247   1256   
  1248   1257     return TCL_OK;
  1249   1258   }
  1250   1259   
  1251   1260   /*
  1252   1261   ** tclcmd:  sqlite3_multiplex_dump

Changes to src/test_multiplex.h.

    86     86   **
    87     87   ** All SQLite database connections must be closed before calling this
    88     88   ** routine.
    89     89   **
    90     90   ** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once while
    91     91   ** shutting down in order to free all remaining multiplex groups.
    92     92   */
    93         -extern int sqlite3_multiplex_shutdown(void);
           93  +extern int sqlite3_multiplex_shutdown(int eForce);
    94     94   
    95     95   #ifdef __cplusplus
    96     96   }  /* End of the 'extern "C"' block */
    97     97   #endif
    98     98   
    99     99   #endif /* _TEST_MULTIPLEX_H */

Changes to test/multiplex.test.

    64     64       forcedelete [multiplex_name $name $i]
    65     65       forcedelete [multiplex_name $name-journal $i]
    66     66       forcedelete [multiplex_name $name-wal $i]
    67     67     }
    68     68   }
    69     69   
    70     70   db close
           71  +sqlite3_shutdown
           72  +test_sqlite3_log xLog
           73  +proc xLog {error_code msg} {
           74  +  lappend ::log $error_code $msg 
           75  +}
           76  +unset -nocomplain log
    71     77   
    72     78   multiplex_delete test.db
    73     79   multiplex_delete test2.db
    74     80   
    75     81   #-------------------------------------------------------------------------
    76     82   #   multiplex-1.1.*: Test initialize and shutdown.
    77     83   
................................................................................
   184    190   
   185    191   do_test multiplex-2.3.1 {
   186    192     sqlite3 db2 test2.x
   187    193     db2 close
   188    194   } {}
   189    195   
   190    196   
          197  +unset -nocomplain ::log
   191    198   do_test multiplex-2.4.1 {
   192    199     sqlite3_multiplex_shutdown
   193    200   } {SQLITE_MISUSE}
   194    201   do_test multiplex-2.4.2 {
   195    202     execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }
   196    203   } {}
          204  +do_test multiplex-2.4.3 {
          205  +  set ::log
          206  +} {SQLITE_MISUSE {sqlite3_multiplex_shutdown() called while database connections are still open}}
   197    207   do_test multiplex-2.4.4 { file size [multiplex_name test.x 0] } {7168}
   198    208   do_test multiplex-2.4.5 {
   199    209     db close
   200    210     sqlite3 db test.x
   201    211     db eval vacuum
   202    212     db close
   203    213     glob test.x*