-C Removing\ssome\ssurplus\sfiles.\s(CVS\s1723)
-D 2001-09-15T00:59:33
+C Limit\sthe\stotal\sdata\sin\sa\ssingle\srow\sto\s2^16-1\sbytes.\s(CVS\s248)
+D 2001-09-15T13:15:13
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
F Makefile.in 6f4536369ce59b0ee7941f743c65c2c7f703ad2a
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
F notes/notes2b.txt 1c17a5b7f6b44a75cd3eb98ed2c24db1eefb06c3
F notes/notes3.txt 71e47be517e3d2578b3b9343a45b772d43b7ba16
F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
-F src/btree.c 3adf545b8e072000923f7e0f7f91d33072a9f869
+F src/btree.c 56a7d11c558bda94611eb62f91744c2c4dc46d08
F src/btree.h a3d9c20fa876e837680745ac60500be697026b7b
F src/build.c 8359e553db8138d09f44957e2d1bcc9b8720117b
F src/delete.c c84b5a26e29fda3c3de51345073a76bb161271fd
F src/main.c 73be8d00a8a9bbec715a6260840a19020a074090
F src/md5.c 52f677bfc590e09f71d07d7e327bd59da738d07c
F src/pager.c 048c20ac85485ca87ed33d6b7711375a3444f817
-F src/pager.h bb9136e833de46bc84aafd8403713d3c46fcbfdf
+F src/pager.h 61573be9fbbb658997bea92b26173b441b9fb3c3
F src/parse.y 8b30e072208c3dfabd97c7d06f0924f194919533
F src/printf.c b1e22a47be8cdf707815647239991e08e8cb69f9
F src/random.c b626726c4f0066610739e52e7431adae7ccd9651
F src/select.c f1673b4d06c24665097faf28d76c4533bce18b84
F src/shell.c 1fcdf8c4180098bcfdee12501e01b4c8eb21d726
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
-F src/sqlite.h.in 1d6a7d13284c3861e61bd0b71491fda613613c68
-F src/sqliteInt.h c7c0580ceb9b5ce92c6fc7ef9434320952b14dc0
+F src/sqlite.h.in 7446bbd8c4f519b78614893d517b405c4dfb10a4
+F src/sqliteInt.h b8738f1f16ae31a0a79bcb2ee01cea2b0979d1a2
F src/table.c adcaf074f6c1075e86359174e68701fa2acfc4d6
F src/tclsqlite.c d328970848c028e13e61e173bef79adcc379568a
F src/test1.c abb3cb427e735ae87e6533f5b3b7164b7da91bc4
F src/test3.c 1fc103f198cbd0447d1a12c3ce48795755ec1a53
F src/tokenize.c 2d4d1534b321422384de0f311d417ffce14fedc6
F src/update.c 8a9d514c7f3bfe5d99fe3dfc1ad92ed3e9daea47
-F src/util.c f3f1550fb7a02348c3d0a0969951e489806e055b
-F src/vdbe.c d5bb5d8dda994779e4d20de5e4a31edf995269ff
+F src/util.c fedf96bcda329ff56e0eff7bc212c99d29ad0397
+F src/vdbe.c 1568f677376cb4b7ee5d278676703099a2f00eef
F src/vdbe.h b9d60d90aeb3acb5dbc1cdac6b0201991921b272
F src/where.c b831b506e17cb592d9781ed066f3459cef768318
F test/all.test 5cefdb035b45639ddbb9f80324185b0f0a9ebda2
F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
F www/tclsqlite.tcl 06f81c401f79a04f2c5ebfb97e7c176225c0aef2
F www/vdbe.tcl 0c8aaa529dd216ccbf7daaabd80985e413d5f9ad
-P 264f23315e682909abb47912f48733f641772a4c
-R b059993507a776d66a3417f913643af9
+P 8ad996fdac6801768e94ca1710a0a3da03e1e7ea
+R fb8c894a127521efc4c282893bba574b
U drh
-Z 6c5da555882197ba94055adde72070fe
+Z 73558ca3364f1614cb7a802241ae4415
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
-** $Id: vdbe.c,v 1.67 2001/09/15 00:57:29 drh Exp $
+** $Id: vdbe.c,v 1.68 2001/09/15 13:15:13 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
i = p->nLabel++;
if( i>=p->nLabelAlloc ){
p->nLabelAlloc = p->nLabelAlloc*2 + 10;
- p->aLabel = sqliteRealloc( p->aLabel, p->nLabelAlloc*sizeof(int));
+ p->aLabel = sqliteRealloc( p->aLabel, p->nLabelAlloc*sizeof(p->aLabel[0]));
}
if( p->aLabel==0 ){
p->nLabel = 0;
** Convert the top P1 entries of the stack into a single entry
** suitable for use as a data record in a database table. To do this
** all entries (except NULLs) are converted to strings and
-** concatenated. The null-terminators are preserved by the concatation
-** and serve as a boundry marker between columns. The lowest entry
+** concatenated. The null-terminators are included on all string
+** except for NULL columns which are represented by zero bytes.
+** The lowest entry
** on the stack is the first in the concatenation and the top of
** the stack is the last. After all columns are concatenated, an
-** index header is added. The index header consists of P1 integers
+** index header is added. The index header consists of P1 16-bit integers
** which hold the offset of the beginning of each column data from the
-** beginning of the completed record including the header. Header
-** entries for NULL fields point to where the first byte of the column
-** would have been stored if the column had held any bytes.
+** beginning of the completed record including the header.
+**
+** The OP_Column opcode is used to unpack a record manufactured with
+** the opcode.
*/
case OP_MakeRecord: {
char *zNewRecord;
int nByte;
int nField;
int i, j;
- int addr;
+ u16 addr;
nField = pOp->p1;
VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
nByte += aStack[i].n;
}
}
- nByte += sizeof(int)*nField;
+ nByte += sizeof(addr)*nField;
+ if( nByte>65535 ){
+ rc = SQLITE_TOOBIG;
+ goto abort_due_to_error;
+ }
zNewRecord = sqliteMalloc( nByte );
if( zNewRecord==0 ) goto no_mem;
j = 0;
- addr = sizeof(int)*nField;
+ addr = sizeof(addr)*nField;
for(i=p->tos-nField+1; i<=p->tos; i++){
- memcpy(&zNewRecord[j], (char*)&addr, sizeof(int));
- j += sizeof(int);
+ memcpy(&zNewRecord[j], (char*)&addr, sizeof(addr));
+ j += sizeof(addr);
if( (aStack[i].flags & STK_Null)==0 ){
addr += aStack[i].n;
}
nField = pOp->p1;
VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
- nByte = sizeof(int);
+ nByte = sizeof(u32);
for(i=p->tos-nField+1; i<=p->tos; i++){
if( aStack[i].flags & STK_Null ){
nByte++;
}
zNewKey[j++] = 0;
Integerify(p, p->tos-nField);
- memcpy(&zNewKey[j], &aStack[p->tos-nField].i, sizeof(int));
+ memcpy(&zNewKey[j], &aStack[p->tos-nField].i, sizeof(u32));
PopStack(p, nField+1);
VERIFY( NeedStack(p, p->tos+1); )
p->tos++;
/* Opcode: Column P1 P2 *
**
-** Interpret the data in the most recent fetch from cursor P1
-** is a structure built using the MakeRecord instruction.
-** Push onto the stack the value of the P2-th field of that
-** structure.
-**
-** The value pushed is a pointer to the data stored in the cursor.
-** The value will go away the next time the cursor is modified in
-** any way. Make a copy of the string (using
-** "Concat 1 0 0") if it needs to persist longer than that.
+** Interpret the data that cursor P1 points to as
+** a structure built using the MakeRecord instruction.
+** (See the MakeRecord opcode for additional information about
+** the format of the data.)
+** Push onto the stack the value of the P2-th column contained
+** in the data.
**
** If the KeyAsData opcode has previously executed on this cursor,
** then the field might be extracted from the key rather than the
*/
case OP_Column: {
int amt, offset, nCol, payloadSize;
- int aHdr[10];
+ u16 aHdr[10];
static const int mxHdr = sizeof(aHdr)/sizeof(aHdr[0]);
int i = pOp->p1;
int p2 = pOp->p2;
** three times.
*/
(*xSize)(pCrsr, &payloadSize);
- if( payloadSize < sizeof(int)*(p2+1) ){
+ if( payloadSize < sizeof(aHdr[0])*(p2+1) ){
rc = SQLITE_CORRUPT;
goto abort_due_to_error;
}
if( p2+1<mxHdr ){
(*xRead)(pCrsr, 0, sizeof(aHdr[0])*(p2+2), (char*)aHdr);
nCol = aHdr[0];
- nCol /= sizeof(int);
+ nCol /= sizeof(aHdr[0]);
offset = aHdr[p2];
if( p2 == nCol-1 ){
amt = payloadSize - offset;
amt = aHdr[p2+1] - offset;
}
}else{
- sqliteBtreeData(pCrsr, 0, sizeof(int), (char*)&nCol);
- nCol /= sizeof(int);
+ sqliteBtreeData(pCrsr, 0, sizeof(aHdr[0]), (char*)aHdr);
+ nCol = aHdr[0]/sizeof(aHdr[0]);
if( p2 == nCol-1 ){
- (*xRead)(pCrsr, sizeof(int)*p2, sizeof(int), (char*)&offset);
+ (*xRead)(pCrsr, sizeof(aHdr[0])*p2, sizeof(aHdr[0]), (char*)aHdr);
+ offset = aHdr[0];
amt = payloadSize - offset;
}else{
- (*xRead)(pCrsr, sizeof(int)*p2, sizeof(int)*2, (char*)aHdr);
+ (*xRead)(pCrsr, sizeof(aHdr[0])*p2, sizeof(aHdr[0])*2, (char*)aHdr);
offset = aHdr[0];
amt = aHdr[1] - offset;
}
rc = SQLITE_CORRUPT;
goto abort_due_to_error;
}
+
+ /* amt and offset now hold the offset to the start of data and the
+ ** amount of data. Go get the data and put it on the stack.
+ */
if( amt==0 ){
aStack[tos].flags = STK_Null;
}else{
if( p->aCsr[i].recnoIsValid ){
v = p->aCsr[i].lastRecno;
}else{
- sqliteBtreeKey(pCrsr, 0, sizeof(int), (char*)&v);
+ sqliteBtreeKey(pCrsr, 0, sizeof(u32), (char*)&v);
}
aStack[tos].i = v;
aStack[tos].flags = STK_Int;
if( rx!=SQLITE_OK ) goto abort_due_to_error;
}
sqliteBtreeKeySize(pCur, &size);
- if( res>0 || size!=pCrsr->nKey+sizeof(int) ||
+ if( res>0 || size!=pCrsr->nKey+sizeof(u32) ||
sqliteBtreeKey(pCur, 0, pCrsr->nKey, pCrsr->zBuf)!=pCrsr->nKey ||
strncmp(pCrsr->zKey, pCrsr->zBuf, pCrsr->nKey)!=0
){
POPSTACK;
}else{
int recno;
- sqliteBtreeKey(pCur, pCrsr->nKey, sizeof(int), (char*)&recno);
+ sqliteBtreeKey(pCur, pCrsr->nKey, sizeof(u32), (char*)&recno);
p->aCsr[i].lastRecno = aStack[tos].i = recno;
p->aCsr[i].recnoIsValid = 1;
aStack[tos].flags = STK_Int;
VERIFY( if( p->tos<0 ) goto not_enough_stack; )
pKeylist = p->apList[i];
if( pKeylist==0 || pKeylist->nUsed>=pKeylist->nKey ){
- pKeylist = sqliteMalloc( sizeof(Keylist)+999*sizeof(int) );
+ pKeylist = sqliteMalloc( sizeof(Keylist)+999*sizeof(pKeylist->aKey[0]) );
if( pKeylist==0 ) goto no_mem;
pKeylist->nKey = 1000;
pKeylist->nRead = 0;
}else if( aStack[i].flags & STK_Real ){
fprintf(p->trace, " r:%g", aStack[i].r);
}else if( aStack[i].flags & STK_Str ){
- if( aStack[i].flags & STK_Dyn ){
- fprintf(p->trace, " z:[%.11s]", zStack[i]);
- }else{
- fprintf(p->trace, " s:[%.11s]", zStack[i]);
+ int j, k;
+ char zBuf[100];
+ zBuf[0] = ' ';
+ zBuf[1] = (aStack[i].flags & STK_Dyn)!=0 ? 'z' : 's';
+ zBuf[2] = ':';
+ k = 3;
+ for(j=0; j<15 && j<aStack[i].n; j++){
+ int c = zStack[i][j];
+ if( c==0 && j==aStack[i].n-1 ) break;
+ if( isprint(c) && !isspace(c) ){
+ zBuf[k++] = c;
+ }else{
+ zBuf[k++] = '.';
+ }
}
+ zBuf[k++] = 0;
+ fprintf(p->trace, "%s", zBuf);
}else{
fprintf(p->trace, " ???");
}