/ Check-in [fee9734c]
Login

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

Overview
Comment:Add tests and fixes for SELECT multiplex_control(op, val);
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | multiplex-enhancements
Files: files | file ages | folders
SHA1: fee9734c193a8bec9599e02e16938179e642bf5e
User & Date: shaneh 2011-03-31 13:14:12
Original Comment: Tests and bug fixes for SELECT multiplex_control(op, val); Add tests and fixes for SELECT multiplex_control(op, val);
Context
2011-03-31
15:11
Enable/disable support. check-in: b3c6d9aa user: shaneh tags: multiplex-enhancements
13:14
Add tests and fixes for SELECT multiplex_control(op, val); check-in: fee9734c user: shaneh tags: multiplex-enhancements
05:31
Additional test cases; Round chunk size up to a multiple of max page size; check-in: 36e364a3 user: shaneh tags: multiplex-enhancements
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_multiplex.c.

   201    201   static void multiplexControlFunc(
   202    202     sqlite3_context *context,
   203    203     int argc,
   204    204     sqlite3_value **argv
   205    205   ){
   206    206     extern const char *sqlite3TestErrorName(int);
   207    207     extern int multiplexFileControl(sqlite3_file *, int, void *);
   208         -  // pPager->fd
   209         -  sqlite3 *db = (sqlite3 *)sqlite3_user_data(context);
   210         -  int op = sqlite3_value_int(argv[0]);
   211         -  int iVal = sqlite3_value_int(argv[1]);
   212    208     int rc = SQLITE_OK;
   213         -  switch( op ){
   214         -    case 1: 
   215         -      op = MULTIPLEX_CTRL_ENABLE; 
   216         -      break;
   217         -    case 2: 
   218         -      op = MULTIPLEX_CTRL_SET_CHUNK_SIZE; 
   219         -      break;
   220         -    case 3: 
   221         -      op = MULTIPLEX_CTRL_SET_MAX_CHUNKS; 
   222         -      break;
   223         -    default:
   224         -      rc = SQLITE_ERROR;
   225         -      break;
          209  +  sqlite3 *db = sqlite3_context_db_handle(context);
          210  +  int op;
          211  +  int iVal;
          212  +
          213  +  if( !db || argc!=2 ){ 
          214  +    rc = SQLITE_ERROR; 
          215  +  }else{
          216  +    /* extract params */
          217  +    op = sqlite3_value_int(argv[0]);
          218  +    iVal = sqlite3_value_int(argv[1]);
          219  +    /* map function op to file_control op */
          220  +    switch( op ){
          221  +      case 1: 
          222  +        op = MULTIPLEX_CTRL_ENABLE; 
          223  +        break;
          224  +      case 2: 
          225  +        op = MULTIPLEX_CTRL_SET_CHUNK_SIZE; 
          226  +        break;
          227  +      case 3: 
          228  +        op = MULTIPLEX_CTRL_SET_MAX_CHUNKS; 
          229  +        break;
          230  +      default:
          231  +        rc = SQLITE_ERROR;
          232  +        break;
          233  +    }
   226    234     }
   227    235     if( rc==SQLITE_OK ){
   228         -    sqlite3_file *f = (sqlite3_file *)db;
   229         -    rc = multiplexFileControl(f, op, &iVal);
          236  +    rc = sqlite3_file_control(db, 0, op, &iVal);
   230    237     }
   231    238     sqlite3_result_text(context, (char *)sqlite3TestErrorName(rc), -1, SQLITE_TRANSIENT);
   232    239   }
   233    240   
   234    241   /*
   235         -** This is the entry point to register the extension for the multiplex_control() function.
          242  +** This is the entry point to register the auto-extension for the multiplex_control() function.
   236    243   */
   237    244   static int multiplexFuncInit(
   238    245     sqlite3 *db, 
   239    246     char **pzErrMsg, 
   240    247     const sqlite3_api_routines *pApi
   241    248   ){
   242    249     int rc;
   243    250     rc = sqlite3_create_function(db, "multiplex_control", 2, SQLITE_ANY, 
   244         -    db, multiplexControlFunc, 0, 0);
          251  +    0, multiplexControlFunc, 0, 0);
   245    252     return rc;
   246    253   }
   247    254   
   248    255   /************************* VFS Method Wrappers *****************************/
   249    256   
   250    257   /*
   251    258   ** This is the xOpen method used for the "multiplex" VFS.

Changes to src/test_multiplex.h.

    52     52   ** Use the VFS named zOrigVfsName as the VFS that does the actual work.  
    53     53   ** Use the default if zOrigVfsName==NULL.  
    54     54   **
    55     55   ** The multiplex VFS shim is named "multiplex".  It will become the default
    56     56   ** VFS if makeDefault is non-zero.
    57     57   **
    58     58   ** An auto-extension is registered which will make the function 
    59         -** multiplex_control() available to open database connections.  This
           59  +** multiplex_control() available to database connections.  This
    60     60   ** function gives access to the xFileControl interface of the 
    61     61   ** multiplex VFS shim.
    62     62   **
    63         -** multiplex_control(<op>,<val>) 
           63  +** SELECT multiplex_control(<op>,<val>) ;
    64     64   ** 
    65     65   **   <op>=1 MULTIPLEX_CTRL_ENABLE
           66  +**   <val>=0 disable
    66     67   **   <val>=1 enable
    67         -**   <val>=2 disable
    68     68   ** 
    69     69   **   <op>=1 MULTIPLEX_CTRL_SET_CHUNK_SIZE
    70     70   **   <val> int, chunk size
    71     71   ** 
    72     72   **   <op>=1 MULTIPLEX_CTRL_SET_MAX_CHUNKS
    73     73   **   <val> int, max chunks
    74     74   **

Changes to test/multiplex.test.

    82     82   do_test multiplex-1.9.6 { multiplex_set db main 31 16 }           {SQLITE_OK}
    83     83   do_test multiplex-1.9.7 { multiplex_set db main 32768 100 }       {SQLITE_MISUSE}
    84     84   do_test multiplex-1.9.8 { db close }                              {}
    85     85   do_test multiplex-1.9.9 { sqlite3_multiplex_shutdown }            {SQLITE_OK}
    86     86   
    87     87   do_test multiplex-1.10.1 { sqlite3_multiplex_initialize "" 1 }                {SQLITE_OK}
    88     88   do_test multiplex-1.10.2 { sqlite3 db test.db }                               {}
    89         -if { 0 } {
    90     89   do_test multiplex-1.10.3 { execsql { SELECT multiplex_control(2, 32768); } }  {SQLITE_OK}
    91     90   do_test multiplex-1.10.4 { execsql { SELECT multiplex_control(3, -1); } }     {SQLITE_MISUSE}
    92     91   do_test multiplex-1.10.5 { execsql { SELECT multiplex_control(2, -1); } }     {SQLITE_MISUSE}
    93     92   do_test multiplex-1.10.6 { execsql { SELECT multiplex_control(2, 31); } }     {SQLITE_OK}
    94     93   do_test multiplex-1.10.7 { execsql { SELECT multiplex_control(3, 100); } }    {SQLITE_MISUSE}
    95         -}
    96     94   do_test multiplex-1.10.8 { db close }                                         {}
    97     95   do_test multiplex-1.10.9 { sqlite3_multiplex_shutdown }                       {SQLITE_OK}
    98     96   
    99     97   #-------------------------------------------------------------------------
   100     98   # Some simple warm-body tests with a single database file in rollback 
   101     99   # mode:
   102    100   #