/ Check-in [c41ff235]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Updates to multiplex.test script; misc. bug fixes;
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | multiplex-enhancements
Files: files | file ages | folders
SHA1: c41ff2358e8af0fe2186ab4173b81fba204a57ab
User & Date: shaneh 2011-03-30 21:03:07
Context
2011-03-31
05:31
Additional test cases; Round chunk size up to a multiple of max page size; check-in: 36e364a3 user: shaneh tags: multiplex-enhancements
2011-03-30
21:03
Updates to multiplex.test script; misc. bug fixes; check-in: c41ff235 user: shaneh tags: multiplex-enhancements
2011-03-29
05:06
In-progress changes - do not use; Removed prefix support; Added file control interface to enable/disable and adjust chunk size; added app-def function for same; check-in: bc02d0c1 user: shaneh tags: multiplex-enhancements
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/test_multiplex.c.

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
212
213
214
215
216
217
218
219
220
221
222

223
224
225
226
227
228
229
230
231
232
...
682
683
684
685
686
687
688





689
690
691
692
693
694
695
696
697
698
699
700
*/
#include "sqlite3.h"
#include <string.h>
#include <assert.h>
#include "sqliteInt.h"
#include "test_multiplex.h"

#include "sqlite3ext.h"
SQLITE_EXTENSION_INIT1

/*
** For a build without mutexes, no-op the mutex calls.
*/
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)
#define sqlite3_mutex_free(X)
#define sqlite3_mutex_enter(X)
................................................................................
  sqlite3_result_text(context, (char *)sqlite3TestErrorName(rc), -1, SQLITE_TRANSIENT);
}

/*
** This is the entry point to register the extension for the multiplex_control() function.
*/
static int multiplexFuncInit(
  sqlite3 *db, 
  char **pzErrMsg, 
  const sqlite3_api_routines *pApi
){

  sqlite3_create_function(db, "multiplex_control", 2, SQLITE_ANY, 
    db, multiplexControlFunc, 0, 0);
  return 0;
}

/************************* VFS Method Wrappers *****************************/

/*
** This is the xOpen method used for the "multiplex" VFS.
**
................................................................................
          rc = SQLITE_MISUSE;
        }else{
          pGroup->nMaxChunks = nMaxChunks;
          rc = SQLITE_OK;
        }
      }
      break;





    default:
  pSubOpen = multiplexSubOpen(p, 0, &rc, NULL);
  if( pSubOpen ){
        rc = pSubOpen->pMethods->xFileControl(pSubOpen, op, pArg);
  }
      break;
  }
  return rc;
}

/* Pass xSectorSize requests through to the original VFS unchanged.
*/







<
<
<







 







|
<
<

>
|

|







 







>
>
>
>
>

|
|

|







21
22
23
24
25
26
27



28
29
30
31
32
33
34
...
209
210
211
212
213
214
215
216


217
218
219
220
221
222
223
224
225
226
227
228
...
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
*/
#include "sqlite3.h"
#include <string.h>
#include <assert.h>
#include "sqliteInt.h"
#include "test_multiplex.h"




/*
** For a build without mutexes, no-op the mutex calls.
*/
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)
#define sqlite3_mutex_free(X)
#define sqlite3_mutex_enter(X)
................................................................................
  sqlite3_result_text(context, (char *)sqlite3TestErrorName(rc), -1, SQLITE_TRANSIENT);
}

/*
** This is the entry point to register the extension for the multiplex_control() function.
*/
static int multiplexFuncInit(
  sqlite3 *db


){
  int rc;
  rc = sqlite3_create_function(db, "multiplex_control", 2, SQLITE_ANY, 
    db, multiplexControlFunc, 0, 0);
  return rc;
}

/************************* VFS Method Wrappers *****************************/

/*
** This is the xOpen method used for the "multiplex" VFS.
**
................................................................................
          rc = SQLITE_MISUSE;
        }else{
          pGroup->nMaxChunks = nMaxChunks;
          rc = SQLITE_OK;
        }
      }
      break;
    case SQLITE_FCNTL_SIZE_HINT:
    case SQLITE_FCNTL_CHUNK_SIZE:
      /* no-op these */
      rc = SQLITE_OK;
      break;
    default:
      pSubOpen = multiplexSubOpen(p, 0, &rc, NULL);
      if( pSubOpen ){
        rc = pSubOpen->pMethods->xFileControl(pSubOpen, op, pArg);
      }
      break;
  }
  return rc;
}

/* Pass xSectorSize requests through to the original VFS unchanged.
*/

Changes to test/multiplex.test.

199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216

217
218
219
220
221
222
223
224
225
226
227
228
...
260
261
262
263
264
265
266

267
268
269
270
271
272
273
274
275
276
277
...
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
do_test multiplex-2.5.10 { file size [multiplex_name test.db 1] } [list $g_chunk_size]

do_test multiplex-2.5.99 {
  db close
  sqlite3_multiplex_shutdown
} {SQLITE_OK}

return

# TBD fix the below

set all_journal_modes {delete persist truncate memory off}
foreach jmode $all_journal_modes {
  for {set sz 151} {$sz<8000} {set sz [expr $sz+419]} {

    do_test multiplex-2.6.1.$sz.$jmode {
      multiplex_delete test.db
      sqlite3_multiplex_initialize "" 1

      multiplex_set db main $sz 32
    } {SQLITE_OK}

    do_test multiplex-2.6.2.$sz.$jmode {
      sqlite3 db test.db
      db eval {
        PRAGMA page_size = 1024;
        PRAGMA auto_vacuum = off;
      }
      db eval "PRAGMA journal_mode = $jmode;"
    } $jmode

................................................................................
#
#   multiplex-3.2.*: Two connections to each of several database files (that
#                are in the same multiplex group).
#
do_test multiplex-3.1.1 {
  multiplex_delete test.db
  sqlite3_multiplex_initialize "" 1

  multiplex_set db main 32768 16
} {SQLITE_OK}
do_test multiplex-3.1.2 {
  sqlite3 db test.db
  execsql {
    PRAGMA page_size = 1024;
    PRAGMA journal_mode = delete;
    PRAGMA auto_vacuum = off;
    CREATE TABLE t1(a PRIMARY KEY, b);
    INSERT INTO t1 VALUES(1, 'one');
  }
................................................................................
        INSERT INTO t1 VALUES(2, randomblob(1100));
        INSERT INTO t1 VALUES(3, randomblob(1100));
        INSERT INTO t1 VALUES(4, randomblob(1100));
        INSERT INTO t1 VALUES(5, randomblob(1100));
      }
      db close
      sqlite3_multiplex_initialize "" 1
      multiplex_set db main 4096 16
      sqlite3 db test.db
    } {}
    do_test multiplex-5.6.3.$jmode {
      catchsql {
        INSERT INTO t1 VALUES(6, randomblob(1100));
      }
    } {1 {disk I/O error}}
    do_test multiplex-5.6.4.$jmode {
      db close
    } {}
  }
}

catch { sqlite3_multiplex_shutdown }
finish_test







<
<
<








>




<







 







>



<







 







|
|
|













199
200
201
202
203
204
205



206
207
208
209
210
211
212
213
214
215
216
217
218

219
220
221
222
223
224
225
...
257
258
259
260
261
262
263
264
265
266
267

268
269
270
271
272
273
274
...
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
do_test multiplex-2.5.10 { file size [multiplex_name test.db 1] } [list $g_chunk_size]

do_test multiplex-2.5.99 {
  db close
  sqlite3_multiplex_shutdown
} {SQLITE_OK}





set all_journal_modes {delete persist truncate memory off}
foreach jmode $all_journal_modes {
  for {set sz 151} {$sz<8000} {set sz [expr $sz+419]} {

    do_test multiplex-2.6.1.$sz.$jmode {
      multiplex_delete test.db
      sqlite3_multiplex_initialize "" 1
      sqlite3 db test.db
      multiplex_set db main $sz 32
    } {SQLITE_OK}

    do_test multiplex-2.6.2.$sz.$jmode {

      db eval {
        PRAGMA page_size = 1024;
        PRAGMA auto_vacuum = off;
      }
      db eval "PRAGMA journal_mode = $jmode;"
    } $jmode

................................................................................
#
#   multiplex-3.2.*: Two connections to each of several database files (that
#                are in the same multiplex group).
#
do_test multiplex-3.1.1 {
  multiplex_delete test.db
  sqlite3_multiplex_initialize "" 1
  sqlite3 db test.db
  multiplex_set db main 32768 16
} {SQLITE_OK}
do_test multiplex-3.1.2 {

  execsql {
    PRAGMA page_size = 1024;
    PRAGMA journal_mode = delete;
    PRAGMA auto_vacuum = off;
    CREATE TABLE t1(a PRIMARY KEY, b);
    INSERT INTO t1 VALUES(1, 'one');
  }
................................................................................
        INSERT INTO t1 VALUES(2, randomblob(1100));
        INSERT INTO t1 VALUES(3, randomblob(1100));
        INSERT INTO t1 VALUES(4, randomblob(1100));
        INSERT INTO t1 VALUES(5, randomblob(1100));
      }
      db close
      sqlite3_multiplex_initialize "" 1
      sqlite3 db test.db
      multiplex_set db main 4096 16
    } {SQLITE_OK}
    do_test multiplex-5.6.3.$jmode {
      catchsql {
        INSERT INTO t1 VALUES(6, randomblob(1100));
      }
    } {1 {disk I/O error}}
    do_test multiplex-5.6.4.$jmode {
      db close
    } {}
  }
}

catch { sqlite3_multiplex_shutdown }
finish_test