Index: third_party/sqlite/src/src/btree.h |
diff --git a/third_party/sqlite/src/src/btree.h b/third_party/sqlite/src/src/btree.h |
index 09b713f3dbdc4171f366c317e621caf2d5a86508..ae57468e3fd5fec513515d97f842029ec9f9aa7c 100644 |
--- a/third_party/sqlite/src/src/btree.h |
+++ b/third_party/sqlite/src/src/btree.h |
@@ -13,8 +13,8 @@ |
** subsystem. See comments in the source code for a detailed description |
** of what each interface routine does. |
*/ |
-#ifndef _BTREE_H_ |
-#define _BTREE_H_ |
+#ifndef SQLITE_BTREE_H |
+#define SQLITE_BTREE_H |
/* TODO: This definition is just included so other modules compile. It |
** needs to be revisited. |
@@ -39,6 +39,7 @@ |
typedef struct Btree Btree; |
typedef struct BtCursor BtCursor; |
typedef struct BtShared BtShared; |
+typedef struct BtreePayload BtreePayload; |
int sqlite3BtreeOpen( |
@@ -68,7 +69,6 @@ int sqlite3BtreeSetSpillSize(Btree*,int); |
int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64); |
#endif |
int sqlite3BtreeSetPagerFlags(Btree*,unsigned); |
-int sqlite3BtreeSyncDisabled(Btree*); |
int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix); |
int sqlite3BtreeGetPageSize(Btree*); |
int sqlite3BtreeMaxPageCount(Btree*,int); |
@@ -90,7 +90,9 @@ int sqlite3BtreeIsInReadTrans(Btree*); |
int sqlite3BtreeIsInBackup(Btree*); |
void *sqlite3BtreeSchema(Btree *, int, void(*)(void *)); |
int sqlite3BtreeSchemaLocked(Btree *pBtree); |
+#ifndef SQLITE_OMIT_SHARED_CACHE |
int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock); |
+#endif |
int sqlite3BtreeSavepoint(Btree *, int, int); |
const char *sqlite3BtreeGetFilename(Btree *); |
@@ -199,14 +201,24 @@ int sqlite3BtreeNewDb(Btree *p); |
** Flags passed as the third argument to sqlite3BtreeCursor(). |
** |
** For read-only cursors the wrFlag argument is always zero. For read-write |
-** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or |
-** (BTREE_WRCSR). If the BTREE_FORDELETE flag is set, then the cursor will |
+** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or just |
+** (BTREE_WRCSR). If the BTREE_FORDELETE bit is set, then the cursor will |
** only be used by SQLite for the following: |
** |
-** * to seek to and delete specific entries, and/or |
+** * to seek to and then delete specific entries, and/or |
** |
** * to read values that will be used to create keys that other |
** BTREE_FORDELETE cursors will seek to and delete. |
+** |
+** The BTREE_FORDELETE flag is an optimization hint. It is not used by |
+** by this, the native b-tree engine of SQLite, but it is available to |
+** alternative storage engines that might be substituted in place of this |
+** b-tree system. For alternative storage engines in which a delete of |
+** the main table row automatically deletes corresponding index rows, |
+** the FORDELETE flag hint allows those alternative storage engines to |
+** skip a lot of work. Namely: FORDELETE cursors may treat all SEEK |
+** and DELETE operations as no-ops, and any READ operation against a |
+** FORDELETE cursor may return a null row: 0x01 0x00. |
*/ |
#define BTREE_WRCSR 0x00000004 /* read-write cursor */ |
#define BTREE_FORDELETE 0x00000008 /* Cursor is for seek/delete only */ |
@@ -235,27 +247,61 @@ int sqlite3BtreeMovetoUnpacked( |
); |
int sqlite3BtreeCursorHasMoved(BtCursor*); |
int sqlite3BtreeCursorRestore(BtCursor*, int*); |
-int sqlite3BtreeDelete(BtCursor*, int); |
-int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey, |
- const void *pData, int nData, |
- int nZero, int bias, int seekResult); |
+int sqlite3BtreeDelete(BtCursor*, u8 flags); |
+ |
+/* Allowed flags for sqlite3BtreeDelete() and sqlite3BtreeInsert() */ |
+#define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */ |
+#define BTREE_AUXDELETE 0x04 /* not the primary delete operation */ |
+#define BTREE_APPEND 0x08 /* Insert is likely an append */ |
+ |
+/* An instance of the BtreePayload object describes the content of a single |
+** entry in either an index or table btree. |
+** |
+** Index btrees (used for indexes and also WITHOUT ROWID tables) contain |
+** an arbitrary key and no data. These btrees have pKey,nKey set to their |
+** key and pData,nData,nZero set to zero. |
+** |
+** Table btrees (used for rowid tables) contain an integer rowid used as |
+** the key and passed in the nKey field. The pKey field is zero. |
+** pData,nData hold the content of the new entry. nZero extra zero bytes |
+** are appended to the end of the content when constructing the entry. |
+** |
+** This object is used to pass information into sqlite3BtreeInsert(). The |
+** same information used to be passed as five separate parameters. But placing |
+** the information into this object helps to keep the interface more |
+** organized and understandable, and it also helps the resulting code to |
+** run a little faster by using fewer registers for parameter passing. |
+*/ |
+struct BtreePayload { |
+ const void *pKey; /* Key content for indexes. NULL for tables */ |
+ sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */ |
+ const void *pData; /* Data for tables. NULL for indexes */ |
+ struct Mem *aMem; /* First of nMem value in the unpacked pKey */ |
+ u16 nMem; /* Number of aMem[] value. Might be zero */ |
+ int nData; /* Size of pData. 0 if none. */ |
+ int nZero; /* Extra zero data appended after pData,nData */ |
+}; |
+ |
+int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload, |
+ int flags, int seekResult); |
int sqlite3BtreeFirst(BtCursor*, int *pRes); |
int sqlite3BtreeLast(BtCursor*, int *pRes); |
int sqlite3BtreeNext(BtCursor*, int *pRes); |
int sqlite3BtreeEof(BtCursor*); |
int sqlite3BtreePrevious(BtCursor*, int *pRes); |
-int sqlite3BtreeKeySize(BtCursor*, i64 *pSize); |
-int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*); |
-const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt); |
-const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt); |
-int sqlite3BtreeDataSize(BtCursor*, u32 *pSize); |
-int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*); |
+i64 sqlite3BtreeIntegerKey(BtCursor*); |
+int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*); |
+const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); |
+u32 sqlite3BtreePayloadSize(BtCursor*); |
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); |
struct Pager *sqlite3BtreePager(Btree*); |
+#ifndef SQLITE_OMIT_INCRBLOB |
+int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*); |
int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*); |
void sqlite3BtreeIncrblobCursor(BtCursor *); |
+#endif |
void sqlite3BtreeClearCursor(BtCursor *); |
int sqlite3BtreeSetVersion(Btree *pBt, int iVersion); |
int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask); |
@@ -265,6 +311,7 @@ int sqlite3HeaderSizeBtree(void); |
#ifndef NDEBUG |
int sqlite3BtreeCursorIsValid(BtCursor*); |
#endif |
+int sqlite3BtreeCursorIsValidNN(BtCursor*); |
#ifndef SQLITE_OMIT_BTREECOUNT |
int sqlite3BtreeCount(BtCursor *, i64 *); |
@@ -287,15 +334,19 @@ void sqlite3BtreeCursorList(Btree*); |
#ifndef SQLITE_OMIT_SHARED_CACHE |
void sqlite3BtreeEnter(Btree*); |
void sqlite3BtreeEnterAll(sqlite3*); |
+ int sqlite3BtreeSharable(Btree*); |
+ void sqlite3BtreeEnterCursor(BtCursor*); |
+ int sqlite3BtreeConnectionCount(Btree*); |
#else |
# define sqlite3BtreeEnter(X) |
# define sqlite3BtreeEnterAll(X) |
+# define sqlite3BtreeSharable(X) 0 |
+# define sqlite3BtreeEnterCursor(X) |
+# define sqlite3BtreeConnectionCount(X) 1 |
#endif |
#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE |
- int sqlite3BtreeSharable(Btree*); |
void sqlite3BtreeLeave(Btree*); |
- void sqlite3BtreeEnterCursor(BtCursor*); |
void sqlite3BtreeLeaveCursor(BtCursor*); |
void sqlite3BtreeLeaveAll(sqlite3*); |
#ifndef NDEBUG |
@@ -306,9 +357,7 @@ void sqlite3BtreeCursorList(Btree*); |
#endif |
#else |
-# define sqlite3BtreeSharable(X) 0 |
# define sqlite3BtreeLeave(X) |
-# define sqlite3BtreeEnterCursor(X) |
# define sqlite3BtreeLeaveCursor(X) |
# define sqlite3BtreeLeaveAll(X) |
@@ -318,4 +367,4 @@ void sqlite3BtreeCursorList(Btree*); |
#endif |
-#endif /* _BTREE_H_ */ |
+#endif /* SQLITE_BTREE_H */ |