rep-cache-db.sql (302408) | rep-cache-db.sql (362181) |
---|---|
1/* rep-cache-db.sql -- schema for use in rep-caching 2 * This is intended for use with SQLite 3 3 * 4 * ==================================================================== 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file --- 7 unchanged lines hidden (view full) --- 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * ==================================================================== 22 */ 23 | 1/* rep-cache-db.sql -- schema for use in rep-caching 2 * This is intended for use with SQLite 3 3 * 4 * ==================================================================== 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file --- 7 unchanged lines hidden (view full) --- 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * ==================================================================== 22 */ 23 |
24-- STMT_CREATE_SCHEMA | 24-- STMT_CREATE_SCHEMA_V1 |
25/* A table mapping representation hashes to locations in a rev file. */ 26CREATE TABLE rep_cache ( 27 hash TEXT NOT NULL PRIMARY KEY, 28 revision INTEGER NOT NULL, 29 offset INTEGER NOT NULL, 30 size INTEGER NOT NULL, 31 expanded_size INTEGER NOT NULL 32 ); 33 34PRAGMA USER_VERSION = 1; 35 | 25/* A table mapping representation hashes to locations in a rev file. */ 26CREATE TABLE rep_cache ( 27 hash TEXT NOT NULL PRIMARY KEY, 28 revision INTEGER NOT NULL, 29 offset INTEGER NOT NULL, 30 size INTEGER NOT NULL, 31 expanded_size INTEGER NOT NULL 32 ); 33 34PRAGMA USER_VERSION = 1; 35 |
36-- STMT_CREATE_SCHEMA_V2 37/* A table mapping representation hashes to locations in a rev file. 38 Same as in V1 schema, except that it uses the `WITHOUT ROWID` optimization: 39 https://sqlite.org/withoutrowid.html |
|
36 | 40 |
41 Note that this optimization is only supported starting from SQLite version 42 3.8.2 (2013-12-06). To keep compatibility with existing binaries, it is 43 only used for newer filesystem formats that were released together with 44 bumping the minimum required SQLite version. 45 */ 46CREATE TABLE rep_cache ( 47 hash TEXT NOT NULL PRIMARY KEY, 48 revision INTEGER NOT NULL, 49 offset INTEGER NOT NULL, 50 size INTEGER NOT NULL, 51 expanded_size INTEGER NOT NULL 52 ) WITHOUT ROWID; 53 54PRAGMA USER_VERSION = 2; 55 |
|
37-- STMT_GET_REP | 56-- STMT_GET_REP |
57/* Works for both V1 and V2 schemas. */ |
|
38SELECT revision, offset, size, expanded_size 39FROM rep_cache 40WHERE hash = ?1 41 42-- STMT_SET_REP | 58SELECT revision, offset, size, expanded_size 59FROM rep_cache 60WHERE hash = ?1 61 62-- STMT_SET_REP |
43INSERT OR FAIL INTO rep_cache (hash, revision, offset, size, expanded_size) | 63/* Works for both V1 and V2 schemas. */ 64INSERT OR IGNORE INTO rep_cache (hash, revision, offset, size, expanded_size) |
44VALUES (?1, ?2, ?3, ?4, ?5) 45 46-- STMT_GET_REPS_FOR_RANGE | 65VALUES (?1, ?2, ?3, ?4, ?5) 66 67-- STMT_GET_REPS_FOR_RANGE |
68/* Works for both V1 and V2 schemas. */ |
|
47SELECT hash, revision, offset, size, expanded_size 48FROM rep_cache 49WHERE revision >= ?1 AND revision <= ?2 50 51-- STMT_GET_MAX_REV | 69SELECT hash, revision, offset, size, expanded_size 70FROM rep_cache 71WHERE revision >= ?1 AND revision <= ?2 72 73-- STMT_GET_MAX_REV |
74/* Works for both V1 and V2 schemas. */ |
|
52SELECT MAX(revision) 53FROM rep_cache 54 55-- STMT_DEL_REPS_YOUNGER_THAN_REV | 75SELECT MAX(revision) 76FROM rep_cache 77 78-- STMT_DEL_REPS_YOUNGER_THAN_REV |
79/* Works for both V1 and V2 schemas. */ |
|
56DELETE FROM rep_cache 57WHERE revision > ?1 58 59/* An INSERT takes an SQLite reserved lock that prevents other writes 60 but doesn't block reads. The incomplete transaction means that no 61 permanent change is made to the database and the transaction is | 80DELETE FROM rep_cache 81WHERE revision > ?1 82 83/* An INSERT takes an SQLite reserved lock that prevents other writes 84 but doesn't block reads. The incomplete transaction means that no 85 permanent change is made to the database and the transaction is |
62 removed when the database is closed. */ | 86 removed when the database is closed. 87 88 Works for both V1 and V2 schemas. */ |
63-- STMT_LOCK_REP 64BEGIN TRANSACTION; 65INSERT INTO rep_cache VALUES ('dummy', 0, 0, 0, 0) 66 67-- STMT_UNLOCK_REP | 89-- STMT_LOCK_REP 90BEGIN TRANSACTION; 91INSERT INTO rep_cache VALUES ('dummy', 0, 0, 0, 0) 92 93-- STMT_UNLOCK_REP |
94/* Works for both V1 and V2 schemas. */ |
|
68ROLLBACK TRANSACTION; | 95ROLLBACK TRANSACTION; |