Btree uses signed integers for the rowid. The intToKey() and keyToInt() macros
are now no-ops. (CVS 1364) FossilOrigin-Name: fb3c80301441f0d255164578601439db3e0c7a61
This commit is contained in:
parent
ac69b05efa
commit
4a1c380a4b
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C The\spager\snow\shandles\sfile\s":memory:"\scomplete\sin\smemory\swith\sno\sdisk\sI/O.\s(CVS\s1363)
|
||||
D 2004-05-12T13:30:08
|
||||
C Btree\suses\ssigned\sintegers\sfor\sthe\srowid.\s\sThe\sintToKey()\sand\skeyToInt()\smacros\nare\snow\sno-ops.\s(CVS\s1364)
|
||||
D 2004-05-12T15:15:47
|
||||
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -23,8 +23,8 @@ F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f
|
||||
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
|
||||
F src/attach.c c315c58cb16fd6e913b3bfa6412aedecb4567fa5
|
||||
F src/auth.c 5c2f0bea4729c98c2be3b69d6b466fc51448fe79
|
||||
F src/btree.c 35df9e6d3a30bbe2d32d6b08f51e2a16b835c6e8
|
||||
F src/btree.h 578dc465c801cf4e7666efbb0fa1c46a54758008
|
||||
F src/btree.c 62a870f24d3fa067d206596c7a8686192edf8deb
|
||||
F src/btree.h 5549569274a78d31c941845e0771b878755b07e5
|
||||
F src/btree_rb.c 9d7973e266ee6f9c61ce592f68742ce9cd5b10e5
|
||||
F src/build.c f25e4ac9f102efd70188bc09a459c2b461fe2135
|
||||
F src/copy.c 4d2038602fd0549d80c59bda27d96f13ea9b5e29
|
||||
@ -65,7 +65,7 @@ F src/util.c 778a8cd03ad6e52778602d20a3132c7d2d1b0a0c
|
||||
F src/vacuum.c c134702e023db8778e6be59ac0ea7b02315b5476
|
||||
F src/vdbe.c 9b82d9ed192729e00581ae08d1cd71a27a698fe0
|
||||
F src/vdbe.h 71c02a75d506a3ce9f6bdfc78101528d5edf319b
|
||||
F src/vdbeInt.h 3610b51a3207f1d4e780748a6d8f13cfe98ce2f7
|
||||
F src/vdbeInt.h 608a0b092a2ab3ab7538384e5e3da09ae512d50c
|
||||
F src/vdbeaux.c c976c7fe334a1d1c102dda410546e880549a6060
|
||||
F src/where.c 487e55b1f64c8fbf0f46a9a90c2247fc45ae6a9a
|
||||
F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
|
||||
@ -190,7 +190,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
||||
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
||||
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P 2f16c9ef3c101c4280991ce3cb0c3bea7b6ed439
|
||||
R 34cbf66e13c9fd717a5c35355887a263
|
||||
P 97de9f7ceebab859ef984d155808575ad321afc0
|
||||
R 2679bc087b647fe5d90e5a7c20264be0
|
||||
U drh
|
||||
Z fff149a4adda820449b55f8e9ff0bdd9
|
||||
Z bf6ca6f575d739fe1938b329ef825f50
|
||||
|
@ -1 +1 @@
|
||||
97de9f7ceebab859ef984d155808575ad321afc0
|
||||
fb3c80301441f0d255164578601439db3e0c7a61
|
42
src/btree.c
42
src/btree.c
@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.127 2004/05/11 09:31:32 drh Exp $
|
||||
** $Id: btree.c,v 1.128 2004/05/12 15:15:47 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@ -336,7 +336,7 @@ static void parseCellHeader(
|
||||
MemPage *pPage, /* Page containing the cell */
|
||||
unsigned char *pCell, /* The cell */
|
||||
u64 *pnData, /* Number of bytes of data in payload */
|
||||
u64 *pnKey, /* Number of bytes of key, or key value for intKey */
|
||||
i64 *pnKey, /* Number of bytes of key, or key value for intKey */
|
||||
int *pnHeader /* Size of header in bytes. Offset to payload */
|
||||
){
|
||||
int n;
|
||||
@ -350,7 +350,7 @@ static void parseCellHeader(
|
||||
}else{
|
||||
n += getVarint(&pCell[n], pnData);
|
||||
}
|
||||
n += getVarint(&pCell[n], pnKey);
|
||||
n += getVarint(&pCell[n], (u64*)pnKey);
|
||||
*pnHeader = n;
|
||||
}
|
||||
|
||||
@ -363,7 +363,8 @@ static void parseCellHeader(
|
||||
*/
|
||||
static int cellSize(MemPage *pPage, unsigned char *pCell){
|
||||
int n;
|
||||
u64 nData, nKey;
|
||||
u64 nData;
|
||||
i64 nKey;
|
||||
int nPayload, maxPayload;
|
||||
|
||||
parseCellHeader(pPage, pCell, &nData, &nKey, &n);
|
||||
@ -867,6 +868,7 @@ int sqlite3BtreeOpen(
|
||||
** the right size. This is to guard against size changes that result
|
||||
** when compiling on a different architecture.
|
||||
*/
|
||||
assert( sizeof(i64)==8 );
|
||||
assert( sizeof(u64)==8 );
|
||||
assert( sizeof(u32)==4 );
|
||||
assert( sizeof(u16)==2 );
|
||||
@ -1392,7 +1394,7 @@ static void releaseTempCursor(BtCursor *pCur){
|
||||
** For a table with the INTKEY flag set, this routine returns the key
|
||||
** itself, not the number of bytes in the key.
|
||||
*/
|
||||
int sqlite3BtreeKeySize(BtCursor *pCur, u64 *pSize){
|
||||
int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){
|
||||
MemPage *pPage;
|
||||
unsigned char *cell;
|
||||
|
||||
@ -1471,7 +1473,8 @@ static int getPayload(
|
||||
int rc;
|
||||
MemPage *pPage;
|
||||
Btree *pBt;
|
||||
u64 nData, nKey;
|
||||
u64 nData;
|
||||
i64 nKey;
|
||||
int maxLocal, ovflSize;
|
||||
|
||||
assert( pCur!=0 && pCur->pPage!=0 );
|
||||
@ -1490,7 +1493,7 @@ static int getPayload(
|
||||
}else{
|
||||
aPayload += getVarint(aPayload, &nData);
|
||||
}
|
||||
aPayload += getVarint(aPayload, &nKey);
|
||||
aPayload += getVarint(aPayload, (u64*)&nKey);
|
||||
if( pPage->intKey ){
|
||||
nKey = 0;
|
||||
}
|
||||
@ -1617,7 +1620,8 @@ static const unsigned char *fetchPayload(
|
||||
unsigned char *aPayload;
|
||||
MemPage *pPage;
|
||||
Btree *pBt;
|
||||
u64 nData, nKey;
|
||||
u64 nData;
|
||||
i64 nKey;
|
||||
int maxLocal;
|
||||
|
||||
assert( pCur!=0 && pCur->pPage!=0 );
|
||||
@ -1636,7 +1640,7 @@ static const unsigned char *fetchPayload(
|
||||
}else{
|
||||
aPayload += getVarint(aPayload, &nData);
|
||||
}
|
||||
aPayload += getVarint(aPayload, &nKey);
|
||||
aPayload += getVarint(aPayload, (u64*)&nKey);
|
||||
if( pPage->intKey ){
|
||||
nKey = 0;
|
||||
}
|
||||
@ -1926,7 +1930,7 @@ int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
|
||||
** *pRes>0 The cursor is left pointing at an entry that
|
||||
** is larger than pKey.
|
||||
*/
|
||||
int sqlite3BtreeMoveto(BtCursor *pCur, const void *pKey, u64 nKey, int *pRes){
|
||||
int sqlite3BtreeMoveto(BtCursor *pCur, const void *pKey, i64 nKey, int *pRes){
|
||||
int rc;
|
||||
|
||||
if( pCur->status ){
|
||||
@ -1951,7 +1955,7 @@ int sqlite3BtreeMoveto(BtCursor *pCur, const void *pKey, u64 nKey, int *pRes){
|
||||
pageIntegrity(pPage);
|
||||
while( lwr<=upr ){
|
||||
const void *pCellKey;
|
||||
u64 nCellKey;
|
||||
i64 nCellKey;
|
||||
pCur->idx = (lwr+upr)/2;
|
||||
sqlite3BtreeKeySize(pCur, &nCellKey);
|
||||
if( pPage->intKey ){
|
||||
@ -2269,7 +2273,8 @@ static int freePage(MemPage *pPage){
|
||||
static int clearCell(MemPage *pPage, unsigned char *pCell){
|
||||
Btree *pBt = pPage->pBt;
|
||||
int rc, n, nPayload;
|
||||
u64 nData, nKey;
|
||||
u64 nData;
|
||||
i64 nKey;
|
||||
Pgno ovflPgno;
|
||||
|
||||
parseCellHeader(pPage, pCell, &nData, &nKey, &n);
|
||||
@ -2309,7 +2314,7 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
|
||||
static int fillInCell(
|
||||
MemPage *pPage, /* The page that contains the cell */
|
||||
unsigned char *pCell, /* Complete text of the cell */
|
||||
const void *pKey, u64 nKey, /* The key */
|
||||
const void *pKey, i64 nKey, /* The key */
|
||||
const void *pData,int nData, /* The data */
|
||||
int *pnSize /* Write cell size here */
|
||||
){
|
||||
@ -2333,7 +2338,7 @@ static int fillInCell(
|
||||
if( !pPage->zeroData ){
|
||||
nHeader += putVarint(&pCell[nHeader], nData);
|
||||
}
|
||||
nHeader += putVarint(&pCell[nHeader], nKey);
|
||||
nHeader += putVarint(&pCell[nHeader], *(u64*)&nKey);
|
||||
|
||||
/* Fill in the payload */
|
||||
if( pPage->zeroData ){
|
||||
@ -3166,7 +3171,7 @@ static int checkReadLocks(BtCursor *pCur){
|
||||
*/
|
||||
int sqlite3BtreeInsert(
|
||||
BtCursor *pCur, /* Insert data into the table of this cursor */
|
||||
const void *pKey, u64 nKey, /* The key of the new record */
|
||||
const void *pKey, i64 nKey, /* The key of the new record */
|
||||
const void *pData, int nData /* The data of the new record */
|
||||
){
|
||||
int rc;
|
||||
@ -3194,6 +3199,7 @@ int sqlite3BtreeInsert(
|
||||
rc = sqlite3BtreeMoveto(pCur, pKey, nKey, &loc);
|
||||
if( rc ) return rc;
|
||||
pPage = pCur->pPage;
|
||||
assert( pPage->intKey || nKey>=0 );
|
||||
TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
|
||||
pCur->pgnoRoot, nKey, nData, pPage->pgno,
|
||||
loc==0 ? "overwrite" : "new entry"));
|
||||
@ -3522,7 +3528,8 @@ int sqlite3BtreePageDump(Btree *pBt, int pgno, int recursive){
|
||||
assert( hdr == (pgno==1 ? 100 : 0) );
|
||||
idx = get2byte(&data[hdr+3]);
|
||||
while( idx>0 && idx<=pBt->pageSize ){
|
||||
u64 nData, nKey;
|
||||
u64 nData;
|
||||
i64 nKey;
|
||||
int nHeader;
|
||||
Pgno child;
|
||||
unsigned char *pCell = &data[idx];
|
||||
@ -3818,7 +3825,8 @@ static int checkTreePage(
|
||||
cur.pPage = pPage;
|
||||
for(i=0; i<pPage->nCell; i++){
|
||||
u8 *pCell = pPage->aCell[i];
|
||||
u64 nKey, nData;
|
||||
i64 nKey;
|
||||
u64 nData;
|
||||
int sz, nHeader;
|
||||
|
||||
/* Check payload overflow pages
|
||||
|
@ -13,7 +13,7 @@
|
||||
** subsystem. See comments in the source code for a detailed description
|
||||
** of what each interface routine does.
|
||||
**
|
||||
** @(#) $Id: btree.h,v 1.45 2004/05/11 00:58:56 drh Exp $
|
||||
** @(#) $Id: btree.h,v 1.46 2004/05/12 15:15:47 drh Exp $
|
||||
*/
|
||||
#ifndef _BTREE_H_
|
||||
#define _BTREE_H_
|
||||
@ -73,9 +73,9 @@ int sqlite3BtreeCursor(
|
||||
);
|
||||
|
||||
int sqlite3BtreeCloseCursor(BtCursor*);
|
||||
int sqlite3BtreeMoveto(BtCursor*, const void *pKey, u64 nKey, int *pRes);
|
||||
int sqlite3BtreeMoveto(BtCursor*, const void *pKey, i64 nKey, int *pRes);
|
||||
int sqlite3BtreeDelete(BtCursor*);
|
||||
int sqlite3BtreeInsert(BtCursor*, const void *pKey, u64 nKey,
|
||||
int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
|
||||
const void *pData, int nData);
|
||||
int sqlite3BtreeFirst(BtCursor*, int *pRes);
|
||||
int sqlite3BtreeLast(BtCursor*, int *pRes);
|
||||
@ -83,7 +83,7 @@ int sqlite3BtreeNext(BtCursor*, int *pRes);
|
||||
int sqlite3BtreeEof(BtCursor*);
|
||||
int sqlite3BtreeFlags(BtCursor*);
|
||||
int sqlite3BtreePrevious(BtCursor*, int *pRes);
|
||||
int sqlite3BtreeKeySize(BtCursor*, u64 *pSize);
|
||||
int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
|
||||
int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
|
||||
const void *sqlite3BtreeKeyFetch(BtCursor*, int amt);
|
||||
const void *sqlite3BtreeDataFetch(BtCursor*, int amt);
|
||||
|
@ -17,12 +17,11 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** In the btree layer, a rowid is an unsigned 64-bit integer. In the
|
||||
** schema layer, a rowid is a signed 64-bit integer. The following macros
|
||||
** convert between the two in such a way as to preserve sort order.
|
||||
** intToKey() and keyToInt() used to transform the rowid. But with
|
||||
** the latest versions of the design they are no-ops.
|
||||
*/
|
||||
#define keyToInt(X) (X ^ 0x8000000000000000)
|
||||
#define intToKey(X) (X ^ 0x8000000000000000)
|
||||
#define keyToInt(X) (X)
|
||||
#define intToKey(X) (X)
|
||||
|
||||
/*
|
||||
** The makefile scans this source file and creates the following
|
||||
|
Loading…
x
Reference in New Issue
Block a user