mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Add comments and assert() statements to show that the return value from
sqlite3BtreeKeySize() and sqlite3BtreeData() usually do not matter. Ticket #3968. Also remove a NEVER() macro that can sometimes be true - discovered while testing the previous change. (CVS 6893) FossilOrigin-Name: 0c710c1be537127511d95b5b261c7bf26e1bc952
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Simplifications\sto\sthe\sPRAGMA\sintegrity_check\slogic.\s\sRemove\sunreachable\scode.\s(CVS\s6892)
|
C Add\scomments\sand\sassert()\sstatements\sto\sshow\sthat\sthe\sreturn\svalue\sfrom\nsqlite3BtreeKeySize()\sand\ssqlite3BtreeData()\susually\sdo\snot\smatter.\nTicket\s#3968.\s\sAlso\sremove\sa\sNEVER()\smacro\sthat\scan\ssometimes\sbe\strue\s-\ndiscovered\swhile\stesting\sthe\sprevious\schange.\s(CVS\s6893)
|
||||||
D 2009-07-14T17:48:06
|
D 2009-07-14T18:35:45
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
|
F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@@ -204,11 +204,11 @@ F src/update.c a1bbe774bce495d62dce3df3f42a5f04c1de173a
|
|||||||
F src/utf.c 9541d28f40441812c0b40f00334372a0542c00ff
|
F src/utf.c 9541d28f40441812c0b40f00334372a0542c00ff
|
||||||
F src/util.c 861d5b5c58be4921f0a254489ea94cb15f550ef8
|
F src/util.c 861d5b5c58be4921f0a254489ea94cb15f550ef8
|
||||||
F src/vacuum.c 3fe0eebea6d2311c1c2ab2962887d11f7a4dcfb0
|
F src/vacuum.c 3fe0eebea6d2311c1c2ab2962887d11f7a4dcfb0
|
||||||
F src/vdbe.c f76edc03ffef53ccbf9e38ecc73a65d29eb5b1bd
|
F src/vdbe.c b6fadd91f509fbcb9108f1d1a5e0985735fb315d
|
||||||
F src/vdbe.h 35a648bc3279a120da24f34d9a25213ec15daf8a
|
F src/vdbe.h 35a648bc3279a120da24f34d9a25213ec15daf8a
|
||||||
F src/vdbeInt.h 831c254a6eef237ef4664c8381a0137586567007
|
F src/vdbeInt.h 831c254a6eef237ef4664c8381a0137586567007
|
||||||
F src/vdbeapi.c 0ab8ada7260b32031ca97f338caecf0812460624
|
F src/vdbeapi.c 0ab8ada7260b32031ca97f338caecf0812460624
|
||||||
F src/vdbeaux.c 5b3cacb685143ebe8ec8660a4dde08a8a45082ce
|
F src/vdbeaux.c 1c3b0698073ddeab7bedc588b13e3fc441346b9e
|
||||||
F src/vdbeblob.c a3f3e0e877fc64ea50165eec2855f5ada4477611
|
F src/vdbeblob.c a3f3e0e877fc64ea50165eec2855f5ada4477611
|
||||||
F src/vdbemem.c 1618f685d19b4bcc96e40b3c478487bafd2ae246
|
F src/vdbemem.c 1618f685d19b4bcc96e40b3c478487bafd2ae246
|
||||||
F src/vtab.c 00902f289521041712fb0293d0bf8688c7af8e48
|
F src/vtab.c 00902f289521041712fb0293d0bf8688c7af8e48
|
||||||
@@ -740,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
|
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
|
||||||
P fa49666fb913f0d82e84bdfa2af3a294be04e47c
|
P 17749fa5480069cc4909acd992ab26d10afb279d
|
||||||
R c96e1acc2f48a31e75ce3ac536c3155e
|
R 35cb54a841da615cb5c38b8f0cb072f6
|
||||||
U drh
|
U drh
|
||||||
Z 197c424f91353d8f0b9f8ad4f802f46f
|
Z 3ca0e11ecfb15e2cf3df9913240d628c
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
17749fa5480069cc4909acd992ab26d10afb279d
|
0c710c1be537127511d95b5b261c7bf26e1bc952
|
||||||
20
src/vdbe.c
20
src/vdbe.c
@@ -43,7 +43,7 @@
|
|||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.871 2009/07/14 02:33:02 drh Exp $
|
** $Id: vdbe.c,v 1.872 2009/07/14 18:35:45 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
@@ -2055,14 +2055,16 @@ case OP_Column: {
|
|||||||
payloadSize = pC->payloadSize;
|
payloadSize = pC->payloadSize;
|
||||||
zRec = (char*)pC->aRow;
|
zRec = (char*)pC->aRow;
|
||||||
}else if( pC->isIndex ){
|
}else if( pC->isIndex ){
|
||||||
sqlite3BtreeKeySize(pCrsr, &payloadSize64);
|
rc = sqlite3BtreeKeySize(pCrsr, &payloadSize64);
|
||||||
|
assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
|
||||||
/* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the
|
/* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the
|
||||||
** payload size, so it is impossible for payloadSize64 to be
|
** payload size, so it is impossible for payloadSize64 to be
|
||||||
** larger than 32 bits. */
|
** larger than 32 bits. */
|
||||||
assert( (payloadSize64 & SQLITE_MAX_U32)==(u64)payloadSize64 );
|
assert( (payloadSize64 & SQLITE_MAX_U32)==(u64)payloadSize64 );
|
||||||
payloadSize = (u32)payloadSize64;
|
payloadSize = (u32)payloadSize64;
|
||||||
}else{
|
}else{
|
||||||
sqlite3BtreeDataSize(pCrsr, &payloadSize);
|
rc = sqlite3BtreeDataSize(pCrsr, &payloadSize);
|
||||||
|
assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
|
||||||
}
|
}
|
||||||
}else if( pC->pseudoTable ){
|
}else if( pC->pseudoTable ){
|
||||||
/* The record is the sole entry of a pseudo-table */
|
/* The record is the sole entry of a pseudo-table */
|
||||||
@@ -3591,7 +3593,8 @@ case OP_NewRowid: { /* out2-prerelease */
|
|||||||
if( res ){
|
if( res ){
|
||||||
v = 1;
|
v = 1;
|
||||||
}else{
|
}else{
|
||||||
sqlite3BtreeKeySize(pC->pCursor, &v);
|
rc = sqlite3BtreeKeySize(pC->pCursor, &v);
|
||||||
|
assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */
|
||||||
if( v==MAX_ROWID ){
|
if( v==MAX_ROWID ){
|
||||||
pC->useRandomRowid = 1;
|
pC->useRandomRowid = 1;
|
||||||
}else{
|
}else{
|
||||||
@@ -3888,13 +3891,15 @@ case OP_RowData: {
|
|||||||
|
|
||||||
if( pC->isIndex ){
|
if( pC->isIndex ){
|
||||||
assert( !pC->isTable );
|
assert( !pC->isTable );
|
||||||
sqlite3BtreeKeySize(pCrsr, &n64);
|
rc = sqlite3BtreeKeySize(pCrsr, &n64);
|
||||||
|
assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
|
||||||
if( n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){
|
if( n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){
|
||||||
goto too_big;
|
goto too_big;
|
||||||
}
|
}
|
||||||
n = (u32)n64;
|
n = (u32)n64;
|
||||||
}else{
|
}else{
|
||||||
sqlite3BtreeDataSize(pCrsr, &n);
|
rc = sqlite3BtreeDataSize(pCrsr, &n);
|
||||||
|
assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
|
||||||
if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
|
if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
|
||||||
goto too_big;
|
goto too_big;
|
||||||
}
|
}
|
||||||
@@ -3958,7 +3963,8 @@ case OP_Rowid: { /* out2-prerelease */
|
|||||||
if( pC->rowidIsValid ){
|
if( pC->rowidIsValid ){
|
||||||
v = pC->lastRowid;
|
v = pC->lastRowid;
|
||||||
}else{
|
}else{
|
||||||
sqlite3BtreeKeySize(pC->pCursor, &v);
|
rc = sqlite3BtreeKeySize(pC->pCursor, &v);
|
||||||
|
assert( rc==SQLITE_OK ); /* Always so because of CursorMoveto() above */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pOut->u.i = v;
|
pOut->u.i = v;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
** to version 2.8.7, all this code was combined into the vdbe.c source file.
|
** to version 2.8.7, all this code was combined into the vdbe.c source file.
|
||||||
** But that file was getting too big so this subroutines were split out.
|
** But that file was getting too big so this subroutines were split out.
|
||||||
**
|
**
|
||||||
** $Id: vdbeaux.c,v 1.473 2009/07/14 14:15:27 drh Exp $
|
** $Id: vdbeaux.c,v 1.474 2009/07/14 18:35:46 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
@@ -2593,8 +2593,10 @@ int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
|
|||||||
/* Get the size of the index entry. Only indices entries of less
|
/* Get the size of the index entry. Only indices entries of less
|
||||||
** than 2GiB are support - anything large must be database corruption.
|
** than 2GiB are support - anything large must be database corruption.
|
||||||
** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so
|
** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so
|
||||||
** this code can safely assume that nCellKey is 32-bits */
|
** this code can safely assume that nCellKey is 32-bits
|
||||||
sqlite3BtreeKeySize(pCur, &nCellKey);
|
*/
|
||||||
|
rc = sqlite3BtreeKeySize(pCur, &nCellKey);
|
||||||
|
assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
|
||||||
assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );
|
assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );
|
||||||
|
|
||||||
/* Read in the complete content of the index entry */
|
/* Read in the complete content of the index entry */
|
||||||
@@ -2669,10 +2671,11 @@ int sqlite3VdbeIdxKeyCompare(
|
|||||||
BtCursor *pCur = pC->pCursor;
|
BtCursor *pCur = pC->pCursor;
|
||||||
Mem m;
|
Mem m;
|
||||||
|
|
||||||
sqlite3BtreeKeySize(pCur, &nCellKey);
|
rc = sqlite3BtreeKeySize(pCur, &nCellKey);
|
||||||
|
assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
|
||||||
/* nCellKey will always be between 0 and 0xffffffff because of the say
|
/* nCellKey will always be between 0 and 0xffffffff because of the say
|
||||||
** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
|
** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
|
||||||
if( NEVER(nCellKey<=0) || nCellKey>0x7fffffff ){
|
if( nCellKey<=0 || nCellKey>0x7fffffff ){
|
||||||
*res = 0;
|
*res = 0;
|
||||||
return SQLITE_CORRUPT;
|
return SQLITE_CORRUPT;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user