shaneh | d50deee | 2011-03-29 05:06:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | ** 2011 March 18 |
| 3 | ** |
| 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
| 6 | ** |
| 7 | ** May you do good and not evil. |
| 8 | ** May you find forgiveness for yourself and forgive others. |
| 9 | ** May you share freely, never taking more than you give. |
| 10 | ** |
| 11 | ************************************************************************* |
| 12 | ** |
| 13 | ** This file contains a VFS "shim" - a layer that sits in between the |
| 14 | ** pager and the real VFS. |
| 15 | ** |
| 16 | ** This particular shim enforces a multiplex system on DB files. |
| 17 | ** This shim shards/partitions a single DB file into smaller |
| 18 | ** "chunks" such that the total DB file size may exceed the maximum |
| 19 | ** file size of the underlying file system. |
| 20 | ** |
| 21 | */ |
| 22 | |
drh | 43f58d6 | 2016-07-09 16:14:45 +0000 | [diff] [blame] | 23 | #ifndef SQLITE_TEST_MULTIPLEX_H |
| 24 | #define SQLITE_TEST_MULTIPLEX_H |
shaneh | d50deee | 2011-03-29 05:06:46 +0000 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | ** CAPI: File-control Operations Supported by Multiplex VFS |
| 28 | ** |
| 29 | ** Values interpreted by the xFileControl method of a Multiplex VFS db file-handle. |
| 30 | ** |
| 31 | ** MULTIPLEX_CTRL_ENABLE: |
| 32 | ** This file control is used to enable or disable the multiplex |
| 33 | ** shim. |
| 34 | ** |
| 35 | ** MULTIPLEX_CTRL_SET_CHUNK_SIZE: |
| 36 | ** This file control is used to set the maximum allowed chunk |
shaneh | 78c4de4 | 2011-03-31 05:31:24 +0000 | [diff] [blame] | 37 | ** size for a multiplex file set. The chunk size should be |
| 38 | ** a multiple of SQLITE_MAX_PAGE_SIZE, and will be rounded up |
| 39 | ** if not. |
shaneh | d50deee | 2011-03-29 05:06:46 +0000 | [diff] [blame] | 40 | ** |
| 41 | ** MULTIPLEX_CTRL_SET_MAX_CHUNKS: |
| 42 | ** This file control is used to set the maximum number of chunks |
| 43 | ** allowed to be used for a mutliplex file set. |
| 44 | */ |
| 45 | #define MULTIPLEX_CTRL_ENABLE 214014 |
| 46 | #define MULTIPLEX_CTRL_SET_CHUNK_SIZE 214015 |
| 47 | #define MULTIPLEX_CTRL_SET_MAX_CHUNKS 214016 |
| 48 | |
drh | 6e227bf | 2012-10-29 14:27:26 +0000 | [diff] [blame] | 49 | #ifdef __cplusplus |
| 50 | extern "C" { |
| 51 | #endif |
| 52 | |
shaneh | 78c4de4 | 2011-03-31 05:31:24 +0000 | [diff] [blame] | 53 | /* |
| 54 | ** CAPI: Initialize the multiplex VFS shim - sqlite3_multiplex_initialize() |
| 55 | ** |
| 56 | ** Use the VFS named zOrigVfsName as the VFS that does the actual work. |
| 57 | ** Use the default if zOrigVfsName==NULL. |
| 58 | ** |
| 59 | ** The multiplex VFS shim is named "multiplex". It will become the default |
| 60 | ** VFS if makeDefault is non-zero. |
| 61 | ** |
| 62 | ** An auto-extension is registered which will make the function |
shaneh | d8ce22b | 2011-03-31 13:14:12 +0000 | [diff] [blame] | 63 | ** multiplex_control() available to database connections. This |
shaneh | 78c4de4 | 2011-03-31 05:31:24 +0000 | [diff] [blame] | 64 | ** function gives access to the xFileControl interface of the |
| 65 | ** multiplex VFS shim. |
| 66 | ** |
shaneh | 3801b65 | 2011-04-01 14:22:46 +0000 | [diff] [blame] | 67 | ** SELECT multiplex_control(<op>,<val>); |
shaneh | 78c4de4 | 2011-03-31 05:31:24 +0000 | [diff] [blame] | 68 | ** |
| 69 | ** <op>=1 MULTIPLEX_CTRL_ENABLE |
shaneh | d8ce22b | 2011-03-31 13:14:12 +0000 | [diff] [blame] | 70 | ** <val>=0 disable |
shaneh | 78c4de4 | 2011-03-31 05:31:24 +0000 | [diff] [blame] | 71 | ** <val>=1 enable |
shaneh | 78c4de4 | 2011-03-31 05:31:24 +0000 | [diff] [blame] | 72 | ** |
shaneh | 3801b65 | 2011-04-01 14:22:46 +0000 | [diff] [blame] | 73 | ** <op>=2 MULTIPLEX_CTRL_SET_CHUNK_SIZE |
shaneh | 78c4de4 | 2011-03-31 05:31:24 +0000 | [diff] [blame] | 74 | ** <val> int, chunk size |
| 75 | ** |
shaneh | 3801b65 | 2011-04-01 14:22:46 +0000 | [diff] [blame] | 76 | ** <op>=3 MULTIPLEX_CTRL_SET_MAX_CHUNKS |
shaneh | 78c4de4 | 2011-03-31 05:31:24 +0000 | [diff] [blame] | 77 | ** <val> int, max chunks |
| 78 | ** |
| 79 | ** THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once |
| 80 | ** during start-up. |
| 81 | */ |
| 82 | extern int sqlite3_multiplex_initialize(const char *zOrigVfsName, int makeDefault); |
| 83 | |
| 84 | /* |
| 85 | ** CAPI: Shutdown the multiplex system - sqlite3_multiplex_shutdown() |
| 86 | ** |
| 87 | ** All SQLite database connections must be closed before calling this |
| 88 | ** routine. |
| 89 | ** |
| 90 | ** THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once while |
| 91 | ** shutting down in order to free all remaining multiplex groups. |
| 92 | */ |
drh | a1a8298 | 2014-07-30 15:43:05 +0000 | [diff] [blame] | 93 | extern int sqlite3_multiplex_shutdown(int eForce); |
shaneh | d50deee | 2011-03-29 05:06:46 +0000 | [diff] [blame] | 94 | |
drh | 6e227bf | 2012-10-29 14:27:26 +0000 | [diff] [blame] | 95 | #ifdef __cplusplus |
| 96 | } /* End of the 'extern "C"' block */ |
| 97 | #endif |
| 98 | |
drh | 43f58d6 | 2016-07-09 16:14:45 +0000 | [diff] [blame] | 99 | #endif /* SQLITE_TEST_MULTIPLEX_H */ |