mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Modifications so that the sessions extension works with blob handles.
FossilOrigin-Name: 82ac16c4f873d3bd7c22f36ba7b974b4903a2d50
This commit is contained in:
@@ -30,6 +30,8 @@ struct Incrblob {
|
||||
BtCursor *pCsr; /* Cursor pointing at blob row */
|
||||
sqlite3_stmt *pStmt; /* Statement holding cursor open */
|
||||
sqlite3 *db; /* The associated database */
|
||||
char *zDb; /* Database name */
|
||||
Table *pTab; /* Table object */
|
||||
};
|
||||
|
||||
|
||||
@@ -194,6 +196,8 @@ int sqlite3_blob_open(
|
||||
sqlite3BtreeLeaveAll(db);
|
||||
goto blob_open_out;
|
||||
}
|
||||
pBlob->pTab = pTab;
|
||||
pBlob->zDb = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zName;
|
||||
|
||||
/* Now search pTab for the exact column. */
|
||||
for(iCol=0; iCol<pTab->nCol; iCol++) {
|
||||
@@ -386,6 +390,30 @@ static int blobReadWrite(
|
||||
*/
|
||||
assert( db == v->db );
|
||||
sqlite3BtreeEnterCursor(p->pCsr);
|
||||
|
||||
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
if( xCall==sqlite3BtreePutData ){
|
||||
/* If a pre-update hook is registered and this is a write cursor,
|
||||
** invoke it here.
|
||||
**
|
||||
** TODO: The preupdate-hook is passed SQLITE_DELETE, even though this
|
||||
** operation should really be an SQLITE_UPDATE. This is probably
|
||||
** incorrect, but is convenient because at this point the new.* values
|
||||
** are not easily obtainable. And for the sessions module, an
|
||||
** SQLITE_UPDATE where the PK columns do not change is handled in the
|
||||
** same way as an SQLITE_DELETE (the SQLITE_DELETE code is actually
|
||||
** slightly more efficient). Since you cannot write to a PK column
|
||||
** using the incremental-blob API, this works. For the sessions module
|
||||
** anyhow.
|
||||
*/
|
||||
sqlite3_int64 iKey;
|
||||
sqlite3BtreeKeySize(p->pCsr, &iKey);
|
||||
sqlite3VdbePreUpdateHook(
|
||||
v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);
|
||||
sqlite3BtreeLeaveCursor(p->pCsr);
|
||||
if( rc==SQLITE_ABORT ){
|
||||
|
||||
Reference in New Issue
Block a user