Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Begin fleshing out the key/value accessor implementation. This is an incremental check-in. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sqlite3_kv |
Files: | files | file ages | folders |
SHA1: |
02d60e196fe2a07ef90a5cfad0daa460 |
User & Date: | drh 2017-01-18 19:54:07.280 |
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) | |
17:20 | Baseline interface definition for the experimental sqlite3_kv accessor object. (check-in: a435841e71 user: drh tags: sqlite3_kv) | |
Changes
Changes to src/kvapi.c.
︙ | ︙ | |||
28 29 30 31 32 33 34 35 | struct sqlite3_kv { sqlite3 *db; /* The database holding the table to be accessed */ u8 iDb; /* Database containing the table to access */ u32 iRoot; /* Root page of the table */ sqlite3_int64 iRowid; /* Current rowid */ }; int sqlite3_kv_open( | > > > > | | | > > | > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 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 | struct sqlite3_kv { sqlite3 *db; /* The database holding the table to be accessed */ u8 iDb; /* Database containing the table to access */ u32 iRoot; /* Root page of the table */ sqlite3_int64 iRowid; /* Current rowid */ }; /* ** Create a new sqlite3_kv object open on zDb.zTable and return ** a pointer to that object. */ int sqlite3_kv_open( sqlite3 *db, /* The database connection */ const char *zDb, /* Schema containing zTable. NULL for "main" */ const char *zTable, /* Name of table the key/value table */ unsigned int flags, /* Must be zero. Reserved for future expansion. */ sqlite3_kv **ppKvOut /* Store the new sqlite3_kv object here */ ){ sqlite3_kv *pKv; Table *pTab; int rc = SQLITE_ERROR; #ifdef SQLITE_ENABLE_API_ARMOR if( ppKvOut==0 ){ return SQLITE_MISUSE_BKPT; } #endif *ppKvOut = 0; #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) || zTable==0 ){ return SQLITE_MISUSE_BKPT; } #endif sqlite3_mutex_enter(db->mutex); sqlite3BtreeEnterAll(db); pTab = sqlite3FindTable(db, zTable, zDb); if( pTab==0 ){ goto kv_open_done; } if( !((pTab->nCol==1 && pTab->iPKey<0) || (pTab->nCol==2 && pTab->iPKey==0)) ){ /* Must be an single-column table without an INTEGER PRIMARY KEY, ** or a two-column table where the first column is the INTEGER PRIMARY KEY */ goto kv_open_done; } if( pTab->pIndex!=0 || pTab->pFKey!=0 || pTab->pCheck!=0 ){ /* Do not allow secondary indexes, foreign keys, or CHECK constraints */ goto kv_open_done; } if( pTab->tabFlags & (TF_Autoincrement|TF_Virtual|TF_WithoutRowid) ){ /* Must not have autoincrement. Must not be a virtual table or a ** without rowid table */ goto kv_open_done; } *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){ |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
8472 8473 8474 8475 8476 8477 8478 | ** goes wrong. */ int sqlite3_kv_open( sqlite3 *db, const char *zDb, const char *zTable, unsigned int flags, /* Must be zero. Reserved for future expansion. */ | | | 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 | ** goes wrong. */ int sqlite3_kv_open( sqlite3 *db, const char *zDb, const char *zTable, unsigned int flags, /* Must be zero. Reserved for future expansion. */ sqlite3_kv **ppKvOut ); /* ** CAPI3REF: Close a key/value accessor object ** DESTRUCTOR: sqlite3_kv ** EXPERIMENTAL ** |
︙ | ︙ |