Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add a prototype of the sqlite3_kv_reset() interface. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | sqlite3_kv |
Files: | files | file ages | folders |
SHA1: |
088c590379f844c1443b0ccdf8695f15 |
User & Date: | drh 2017-01-19 12:07:08.814 |
Context
2017-01-19
| ||
12:07 | Add a prototype of the sqlite3_kv_reset() interface. (Leaf check-in: 088c590379 user: drh tags: sqlite3_kv) | |
2017-01-18
| ||
19:54 | Begin fleshing out the key/value accessor implementation. This is an incremental check-in. (check-in: 02d60e196f user: drh tags: sqlite3_kv) | |
Changes
Changes to src/kvapi.c.
︙ | ︙ | |||
23 24 25 26 27 28 29 | ** This is an opaque object. The public interface sees pointers to this ** object, but not the internals. So the internal composition of this ** object is free to change from one release to the next without breaking ** compatibility. */ struct sqlite3_kv { sqlite3 *db; /* The database holding the table to be accessed */ | < > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ** This is an opaque object. The public interface sees pointers to this ** object, but not the internals. So the internal composition of this ** object is free to change from one release to the next without breaking ** compatibility. */ struct sqlite3_kv { sqlite3 *db; /* The database holding the table to be accessed */ u32 iRoot; /* Root page of the table */ int iGen; /* Schema generation number */ int iCookie; /* Schema cookie number from the database file */ Schema *pSchema; /* Schema holding the table */ sqlite3_int64 iRowid; /* Current rowid */ }; /* ** Create a new sqlite3_kv object open on zDb.zTable and return ** a pointer to that object. */ |
︙ | ︙ | |||
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | } *ppKvOut = pKv = sqlite3_malloc(sizeof(*pKv)); if( pKv==0 ){ rc = SQLITE_NOMEM; goto kv_open_done; } pKv->db = db; rc = SQLITE_OK; kv_open_done: sqlite3BtreeLeaveAll(db); sqlite3_mutex_leave(db->mutex); return rc; } /* ** Free the key/value accessor at pKv */ int sqlite3_kv_close(sqlite3_kv *pKv){ sqlite3_free(pKv); return SQLITE_OK; } int sqlite3_kv_seek(sqlite3_kv *pKv, sqlite3_int64 rowid){ return SQLITE_MISUSE; } int sqlite3_kv_bytes(sqlite3_kv *pKv){ return -1; } int sqlite3_kv_read(sqlite3_kv *pKv, void *pBuf, int amt, int offset){ return SQLITE_MISUSE; } int sqlite3_kv_insert(sqlite3_kv *pKv, sqlite3_int64 rid, int sz, void *pBuf){ return SQLITE_MISUSE; } #endif /* #ifndef SQLITE_OMIT_KEYVALU_ACCESSOR */ | > > > > > > > | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | } *ppKvOut = pKv = sqlite3_malloc(sizeof(*pKv)); if( pKv==0 ){ rc = SQLITE_NOMEM; goto kv_open_done; } pKv->db = db; pKv->iGen = pTab->pSchema->iGeneration; pKv->iCookie = pTab->pSchema->schema_cookie; pKv->pSchema = pTab->pSchema; pKv->iRoot = pTab->tnum; rc = SQLITE_OK; kv_open_done: sqlite3BtreeLeaveAll(db); sqlite3_mutex_leave(db->mutex); return rc; } /* ** Free the key/value accessor at pKv */ int sqlite3_kv_close(sqlite3_kv *pKv){ sqlite3_free(pKv); return SQLITE_OK; } int sqlite3_kv_seek(sqlite3_kv *pKv, sqlite3_int64 rowid){ return SQLITE_MISUSE; } int sqlite3_kv_reset(sqlite3_kv *pKv){ return SQLITE_MISUSE; } int sqlite3_kv_bytes(sqlite3_kv *pKv){ return -1; } int sqlite3_kv_read(sqlite3_kv *pKv, void *pBuf, int amt, int offset){ return SQLITE_MISUSE; } int sqlite3_kv_insert(sqlite3_kv *pKv, sqlite3_int64 rid, int sz, void *pBuf){ return SQLITE_MISUSE; } #endif /* #ifndef SQLITE_OMIT_KEYVALU_ACCESSOR */ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 | ** SQLITE_OK on success or an error code if it is unable to complete ** the operation. If no record exists with rowid I, then sqlite3_kv_seek(P,I) ** attempts to position itself at another nearby record and returns ** either SQLITE_KV_BEFORE or SQLITE_KV_AFTER depending on whether the ** record the accessor is left pointing to is less than or greater than I, ** respectively. If the table is empty, sqlite3_kv_seek(P,I) returns ** SQLITE_EMPTY. */ int sqlite3_kv_seek(sqlite3_kv*, sqlite3_int64 rowid); /* ** CAPI3REF: Find the size of the value for a key/value pair ** METHOD: sqlite3_kv ** EXPERIMENTAL ** ** The sqlite3_kv_bytes(P) interface returns the size of the value ** in the key/value pair that the key/value accessor object P is currently | > > > > > > > > > > > > > > | 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 | ** SQLITE_OK on success or an error code if it is unable to complete ** the operation. If no record exists with rowid I, then sqlite3_kv_seek(P,I) ** attempts to position itself at another nearby record and returns ** either SQLITE_KV_BEFORE or SQLITE_KV_AFTER depending on whether the ** record the accessor is left pointing to is less than or greater than I, ** respectively. If the table is empty, sqlite3_kv_seek(P,I) returns ** SQLITE_EMPTY. ** ** A successful sqlite3_kv_seek(P,I) call leave the key/value accessor ** P holding a read transaction open on the database. Use sqlite3_kv_reset(P) ** or sqlite3_kv_close(P) to release this transaction. */ int sqlite3_kv_seek(sqlite3_kv*, sqlite3_int64 rowid); /* ** CAPI3REF: Reset a key/value accessor object ** METHOD: sqlite3_kv ** EXPERIMENTAL ** ** The sqlite3_kv_reset(P) interface restores the key/value accessor P ** back to its original state, releasing any transactions held. */ int sqlite3_kv_reset(sqlite3_kv*); /* ** CAPI3REF: Find the size of the value for a key/value pair ** METHOD: sqlite3_kv ** EXPERIMENTAL ** ** The sqlite3_kv_bytes(P) interface returns the size of the value ** in the key/value pair that the key/value accessor object P is currently |
︙ | ︙ |