mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
file format change (CVS 120)
FossilOrigin-Name: 67f8af377c8a92ac155f55afc75e9957bec4e787
This commit is contained in:
@ -30,7 +30,7 @@
|
||||
** relatively simple to convert to a different database such
|
||||
** as NDBM, SDBM, or BerkeleyDB.
|
||||
**
|
||||
** $Id: dbbe.c,v 1.17 2000/07/31 13:38:26 drh Exp $
|
||||
** $Id: dbbe.c,v 1.18 2000/08/02 12:26:29 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <gdbm.h>
|
||||
@ -629,6 +629,7 @@ int sqliteDbbeNew(DbbeCursor *pCursr){
|
||||
for(i=0; i<4; i++){
|
||||
iKey = (iKey<<8) + rc4byte(pRc4);
|
||||
}
|
||||
if( iKey==0 ) continue;
|
||||
key.dptr = (char*)&iKey;
|
||||
key.dsize = 4;
|
||||
go = gdbm_exists(pCursr->pFile->dbf, key);
|
||||
|
@ -23,7 +23,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.27 2000/07/29 13:06:59 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.28 2000/08/02 12:26:29 drh Exp $
|
||||
*/
|
||||
#include "sqlite.h"
|
||||
#include "dbbe.h"
|
||||
@ -123,7 +123,7 @@ struct sqlite {
|
||||
Dbbe *pBe; /* The backend driver */
|
||||
int flags; /* Miscellanous flags */
|
||||
void *pBusyArg; /* 1st Argument to the busy callback */
|
||||
int (*xBusyCallback)(void *,const char*,int);
|
||||
int (*xBusyCallback)(void *,const char*,int); /* The busy callback */
|
||||
Table *apTblHash[N_HASH]; /* All tables of the database */
|
||||
Index *apIdxHash[N_HASH]; /* All indices of the database */
|
||||
};
|
||||
|
70
src/vdbe.c
70
src/vdbe.c
@ -41,7 +41,7 @@
|
||||
** But other routines are also provided to help in building up
|
||||
** a program instruction by instruction.
|
||||
**
|
||||
** $Id: vdbe.c,v 1.37 2000/07/30 20:04:43 drh Exp $
|
||||
** $Id: vdbe.c,v 1.38 2000/08/02 12:26:29 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <unistd.h>
|
||||
@ -2143,17 +2143,23 @@ int sqliteVdbeExec(
|
||||
if( i>=0 && i<p->nCursor && (pCrsr = p->aCsr[i].pCursor)!=0 ){
|
||||
int *aIdx;
|
||||
int nIdx;
|
||||
int j;
|
||||
int j, k;
|
||||
nIdx = sqliteDbbeDataLength(pCrsr)/sizeof(int);
|
||||
aIdx = (int*)sqliteDbbeReadData(pCrsr, 0);
|
||||
for(j=p->aCsr[i].index; j<nIdx; j++){
|
||||
if( nIdx>1 ){
|
||||
k = *(aIdx++);
|
||||
if( k>nIdx-1 ) k = nIdx-1;
|
||||
}else{
|
||||
k = nIdx;
|
||||
}
|
||||
for(j=p->aCsr[i].index; j<k; j++){
|
||||
if( aIdx[j]!=0 ){
|
||||
p->aStack[tos].i = aIdx[j];
|
||||
p->aStack[tos].flags = STK_Int;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( j>=nIdx ){
|
||||
if( j>=k ){
|
||||
j = -1;
|
||||
pc = pOp->p2 - 1;
|
||||
PopStack(p, 1);
|
||||
@ -2193,14 +2199,38 @@ int sqliteVdbeExec(
|
||||
/* Extend the existing record */
|
||||
int nIdx;
|
||||
int *aIdx;
|
||||
int k;
|
||||
|
||||
nIdx = sqliteDbbeDataLength(pCrsr)/sizeof(int);
|
||||
aIdx = sqliteMalloc( sizeof(int)*(nIdx+1) );
|
||||
if( aIdx==0 ) goto no_mem;
|
||||
sqliteDbbeCopyData(pCrsr, 0, nIdx*sizeof(int), (char*)aIdx);
|
||||
aIdx[nIdx] = newVal;
|
||||
sqliteDbbePut(pCrsr, p->aStack[tos].n, p->zStack[tos],
|
||||
sizeof(int)*(nIdx+1), (char*)aIdx);
|
||||
sqliteFree(aIdx);
|
||||
if( nIdx==1 ){
|
||||
aIdx = sqliteMalloc( sizeof(int)*4 );
|
||||
if( aIdx==0 ) goto no_mem;
|
||||
aIdx[0] = 2;
|
||||
sqliteDbbeCopyData(pCrsr, 0, sizeof(int), (char*)&aIdx[1]);
|
||||
aIdx[2] = newVal;
|
||||
sqliteDbbePut(pCrsr, p->aStack[tos].n, p->zStack[tos],
|
||||
sizeof(int)*4, (char*)aIdx);
|
||||
sqliteFree(aIdx);
|
||||
}else{
|
||||
aIdx = (int*)sqliteDbbeReadData(pCrsr, 0);
|
||||
k = aIdx[0];
|
||||
if( k<nIdx-1 ){
|
||||
aIdx[k+1] = newVal;
|
||||
aIdx[0]++;
|
||||
sqliteDbbePut(pCrsr, p->aStack[tos].n, p->zStack[tos],
|
||||
sizeof(int)*nIdx, (char*)aIdx);
|
||||
}else{
|
||||
nIdx *= 2;
|
||||
aIdx = sqliteMalloc( sizeof(int)*nIdx );
|
||||
if( aIdx==0 ) goto no_mem;
|
||||
sqliteDbbeCopyData(pCrsr, 0, sizeof(int)*(k+1), (char*)aIdx);
|
||||
aIdx[k+1] = newVal;
|
||||
aIdx[0]++;
|
||||
sqliteDbbePut(pCrsr, p->aStack[tos].n, p->zStack[tos],
|
||||
sizeof(int)*nIdx, (char*)aIdx);
|
||||
sqliteFree(aIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PopStack(p, 2);
|
||||
@ -2229,7 +2259,7 @@ int sqliteVdbeExec(
|
||||
if( i>=0 && i<p->nCursor && (pCrsr = p->aCsr[i].pCursor)!=0 ){
|
||||
int *aIdx;
|
||||
int nIdx;
|
||||
int j;
|
||||
int j, k;
|
||||
int r;
|
||||
int oldVal;
|
||||
Integerify(p, nos);
|
||||
@ -2239,14 +2269,20 @@ int sqliteVdbeExec(
|
||||
if( r==0 ) break;
|
||||
nIdx = sqliteDbbeDataLength(pCrsr)/sizeof(int);
|
||||
aIdx = (int*)sqliteDbbeReadData(pCrsr, 0);
|
||||
for(j=0; j<nIdx && aIdx[j]!=oldVal; j++){}
|
||||
if( j>=nIdx ) break;
|
||||
aIdx[j] = aIdx[nIdx-1];
|
||||
if( nIdx==1 ){
|
||||
if( (nIdx==1 && aIdx[0]==oldVal) || (aIdx[0]==1 && aIdx[1]==oldVal) ){
|
||||
sqliteDbbeDelete(pCrsr, p->aStack[tos].n, p->zStack[tos]);
|
||||
}else{
|
||||
k = aIdx[0];
|
||||
for(j=1; j<=k && aIdx[j]!=oldVal; j++){}
|
||||
if( j>k ) break;
|
||||
aIdx[j] = aIdx[k];
|
||||
aIdx[k] = 0;
|
||||
aIdx[0]--;
|
||||
if( aIdx[0]*3 + 1 < nIdx ){
|
||||
nIdx /= 2;
|
||||
}
|
||||
sqliteDbbePut(pCrsr, p->aStack[tos].n, p->zStack[tos],
|
||||
sizeof(int)*(nIdx-1), (char*)aIdx);
|
||||
sizeof(int)*nIdx, (char*)aIdx);
|
||||
}
|
||||
}
|
||||
PopStack(p, 2);
|
||||
|
Reference in New Issue
Block a user