1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Tests to improve coverage of vdbemem.c. (CVS 2200)

FossilOrigin-Name: 319bb4a9064deb062a888fdc31067619c9b749bb
This commit is contained in:
danielk1977
2005-01-12 07:15:04 +00:00
parent c8f9079c61
commit b5402fbf05
12 changed files with 101 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sa\sbug\sin\stclsqlite.c.\s(CVS\s2199) C Tests\sto\simprove\scoverage\sof\svdbemem.c.\s(CVS\s2200)
D 2005-01-12T00:08:25 D 2005-01-12T07:15:05
F Makefile.in ecf441ac5ca1ccfc8748a8a9537706e69893dfa4 F Makefile.in ecf441ac5ca1ccfc8748a8a9537706e69893dfa4
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@@ -29,8 +29,8 @@ F sqlite3.def dbaeb20c153e1d366e8f421b55a573f5dfc00863
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689 F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea
F src/btree.c 5ec669c8839d98dd9e283cc6d4547da4adb37a81 F src/btree.c bd2fd7fed9cc1ec84e70fe9f01dfcb474b53bbe5
F src/btree.h 861e40b759a195ba63819740e484390012cf81ab F src/btree.h 74d19cf40ab49fd69abe9e4e12a6c321ad86c497
F src/build.c af1296e8a21a406b4f4c4f1e1365e075071219f3 F src/build.c af1296e8a21a406b4f4c4f1e1365e075071219f3
F src/cursor.c f883813759742068890b1f699335872bfa8fdf41 F src/cursor.c f883813759742068890b1f699335872bfa8fdf41
F src/date.c 65536e7ea04fdde6e0551264fca15966966e171f F src/date.c 65536e7ea04fdde6e0551264fca15966966e171f
@@ -62,10 +62,10 @@ F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c af6ffcf0201f8f4e2697eea25689077dc61c6109 F src/select.c af6ffcf0201f8f4e2697eea25689077dc61c6109
F src/shell.c e8f4f486cbf6e60d81173146ac8a6522c930fa51 F src/shell.c e8f4f486cbf6e60d81173146ac8a6522c930fa51
F src/sqlite.h.in 0d5e48e506845b74a845c9470e01d3f472b59611 F src/sqlite.h.in 0d5e48e506845b74a845c9470e01d3f472b59611
F src/sqliteInt.h a362fd46ba14f67e8e088d30ecbbe228545c43fe F src/sqliteInt.h 087d21946d79c6eec1b84a32122def5fd99ee03b
F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9 F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
F src/tclsqlite.c 75a8dc9cd7ac0f41482bd7b96b99d54e62b6e98f F src/tclsqlite.c 75a8dc9cd7ac0f41482bd7b96b99d54e62b6e98f
F src/test1.c d684fb31dccd68434e148bef51d9c0a24b09bdf0 F src/test1.c 30584dd0b7eb501534c5f4b2292b13a32ef58651
F src/test2.c b11fa244fff02190707dd0879987c37c75e61fc8 F src/test2.c b11fa244fff02190707dd0879987c37c75e61fc8
F src/test3.c a72f20066cccd5a7b9f20b7b78fa9b05b47b3020 F src/test3.c a72f20066cccd5a7b9f20b7b78fa9b05b47b3020
F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df
@@ -73,18 +73,18 @@ F src/test5.c 64f08b2a50ef371a1bd68ff206829e7b1b9997f5
F src/tokenize.c c1d124ec41422c9ec14360ea3a1f98ca4acf7cf1 F src/tokenize.c c1d124ec41422c9ec14360ea3a1f98ca4acf7cf1
F src/trigger.c 98f3b07c08ba01b34cff139ef9687883d325ae8e F src/trigger.c 98f3b07c08ba01b34cff139ef9687883d325ae8e
F src/update.c 0979397c41ac29c54fe0cc687a356d8629a633af F src/update.c 0979397c41ac29c54fe0cc687a356d8629a633af
F src/utf.c e45ce11be6922408cd381561721f6cca7d3b992a F src/utf.c 9bece2c7b94d9002ab1bb900a7658c6f826b0f74
F src/util.c bf42625f35492864faa6fe14aa5a858de25cc2a0 F src/util.c 4511559caf83e70a036deb5c56f10ddf35a688fb
F src/vacuum.c 1a9db113a027461daaf44724c71dd1ebbd064203 F src/vacuum.c 1a9db113a027461daaf44724c71dd1ebbd064203
F src/vdbe.c 8ef389f567e233768a845e7dffacb21308e4f3e8 F src/vdbe.c b8e619fbaa59be3e537804469d8cedd4a98d3c2e
F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181 F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181
F src/vdbeInt.h 0f74561e629af86172de7cdf0ecaea014c51696c F src/vdbeInt.h 0f74561e629af86172de7cdf0ecaea014c51696c
F src/vdbeapi.c 0cf3bdc1072616bedc8eec7fc22e3f5a169d33fd F src/vdbeapi.c 0cf3bdc1072616bedc8eec7fc22e3f5a169d33fd
F src/vdbeaux.c 60c24559b458d4da368694c0d322326b22edffd1 F src/vdbeaux.c 60c24559b458d4da368694c0d322326b22edffd1
F src/vdbemem.c 5876c8abf4374fef671f4fd8dc333ef3fc95a2f0 F src/vdbemem.c 5d9fd8de5d4f5d1f3446c9a90a7b3f8c38557821
F src/where.c 3a0d08505e298242f6f151f019a05129a4f8704c F src/where.c 3a0d08505e298242f6f151f019a05129a4f8704c
F tclinstaller.tcl 36478c3bbfc5b93ceac42d94e3c736937b808432 F tclinstaller.tcl 36478c3bbfc5b93ceac42d94e3c736937b808432
F test/all.test 87cc4ea3cff6da70aefd789c6ef539dbb1c27eec F test/all.test 387e2e3bed9325bfdc538ebb7f2238cce69620e9
F test/alter.test 95c57a4f461fa81293e0dccef7f83889aadb169a F test/alter.test 95c57a4f461fa81293e0dccef7f83889aadb169a
F test/attach.test f39069efd4394422798f249df9a31489aa941ee1 F test/attach.test f39069efd4394422798f249df9a31489aa941ee1
F test/attach2.test eeb987770f4dbe68bd29afdbc2e8cff0142e6eb5 F test/attach2.test eeb987770f4dbe68bd29afdbc2e8cff0142e6eb5
@@ -150,7 +150,7 @@ F test/lock.test 32fe28e5030f25f23bcf6beef440675b0d848413
F test/lock2.test 59c3dd7d9b24d1bf7ec91b2d1541c37e97939d5f F test/lock2.test 59c3dd7d9b24d1bf7ec91b2d1541c37e97939d5f
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9 F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
F test/main.test a60a1d234b5f5784097973bd395514ca56003ef1 F test/main.test a60a1d234b5f5784097973bd395514ca56003ef1
F test/malloc.test 74b9d6b8e6b388102e2c5dbcda7da4341e00e6b5 F test/malloc.test 79c5e0676a8346884b3197c811f2eac60b0521cc
F test/memdb.test 532aac7128a3da494cddc4461d76c6e3988f771b F test/memdb.test 532aac7128a3da494cddc4461d76c6e3988f771b
F test/memleak.test f1fa233f8295dd1d955a00d5e5ee857850f27f29 F test/memleak.test f1fa233f8295dd1d955a00d5e5ee857850f27f29
F test/minmax.test e7048476940df0af11d0f2cf687572f557cd0b29 F test/minmax.test e7048476940df0af11d0f2cf687572f557cd0b29
@@ -268,7 +268,7 @@ F www/tclsqlite.tcl e73f8f8e5f20e8277619433f7970060ab01088fc
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618 F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl c3b50d3ac31c54be2a1af9b488a89d22f1e6e746 F www/whentouse.tcl c3b50d3ac31c54be2a1af9b488a89d22f1e6e746
P 1bee1bb91d39ff8a33efe662b6cab6dbd2d50e3c P 50f1e229652610b386745bb39fed45549cc74aa7
R 6de97aaefc689d9641defe44416179bf R bf4878fa2c84d42762e103055cb55fd1
U drh U danielk1977
Z 686cf7812785575d0f1d1fe10b0b7525 Z 3c12901d279d54cf5f64fafd62ec59a5

View File

@@ -1 +1 @@
50f1e229652610b386745bb39fed45549cc74aa7 319bb4a9064deb062a888fdc31067619c9b749bb

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give. ** May you share freely, never taking more than you give.
** **
************************************************************************* *************************************************************************
** $Id: btree.c,v 1.230 2005/01/11 10:25:07 danielk1977 Exp $ ** $Id: btree.c,v 1.231 2005/01/12 07:15:05 danielk1977 Exp $
** **
** This file implements a external (disk-based) database using BTrees. ** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to ** For a detailed discussion of BTrees, refer to
@@ -4743,12 +4743,11 @@ int sqlite3BtreeFlags(BtCursor *pCur){
return pPage ? pPage->aData[pPage->hdrOffset] : 0; return pPage ? pPage->aData[pPage->hdrOffset] : 0;
} }
#ifdef SQLITE_DEBUG
/* /*
** Print a disassembly of the given page on standard output. This routine ** Print a disassembly of the given page on standard output. This routine
** is used for debugging and testing only. ** is used for debugging and testing only.
*/ */
#ifdef SQLITE_TEST
#ifndef SQLITE_OMIT_BTREEPAGEDUMP
static int btreePageDump(Btree *pBt, int pgno, int recursive, MemPage *pParent){ static int btreePageDump(Btree *pBt, int pgno, int recursive, MemPage *pParent){
int rc; int rc;
MemPage *pPage; MemPage *pPage;
@@ -4845,11 +4844,8 @@ static int btreePageDump(Btree *pBt, int pgno, int recursive, MemPage *pParent){
fflush(stdout); fflush(stdout);
return SQLITE_OK; return SQLITE_OK;
} }
#endif
int sqlite3BtreePageDump(Btree *pBt, int pgno, int recursive){ int sqlite3BtreePageDump(Btree *pBt, int pgno, int recursive){
#ifndef SQLITE_OMIT_BTREEPAGEDUMP
return btreePageDump(pBt, pgno, recursive, 0); return btreePageDump(pBt, pgno, recursive, 0);
#endif
} }
#endif #endif

View File

@@ -13,7 +13,7 @@
** subsystem. See comments in the source code for a detailed description ** subsystem. See comments in the source code for a detailed description
** of what each interface routine does. ** of what each interface routine does.
** **
** @(#) $Id: btree.h,v 1.60 2004/11/05 15:45:10 danielk1977 Exp $ ** @(#) $Id: btree.h,v 1.61 2005/01/12 07:15:05 danielk1977 Exp $
*/ */
#ifndef _BTREE_H_ #ifndef _BTREE_H_
#define _BTREE_H_ #define _BTREE_H_
@@ -127,8 +127,12 @@ struct Pager *sqlite3BtreePager(Btree*);
#ifdef SQLITE_TEST #ifdef SQLITE_TEST
int sqlite3BtreeCursorInfo(BtCursor*, int*, int); int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
void sqlite3BtreeCursorList(Btree*); void sqlite3BtreeCursorList(Btree*);
int sqlite3BtreePageDump(Btree*, int, int recursive);
#endif #endif
#ifdef SQLITE_DEBUG
int sqlite3BtreePageDump(Btree*, int, int recursive);
#else
#define sqlite3BtreePageDump(X,Y,Z) SQLITE_OK
#endif
#endif /* _BTREE_H_ */ #endif /* _BTREE_H_ */

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** Internal interface definitions for SQLite. ** Internal interface definitions for SQLite.
** **
** @(#) $Id: sqliteInt.h,v 1.351 2005/01/08 18:42:28 drh Exp $ ** @(#) $Id: sqliteInt.h,v 1.352 2005/01/12 07:15:05 danielk1977 Exp $
*/ */
#ifndef _SQLITEINT_H_ #ifndef _SQLITEINT_H_
#define _SQLITEINT_H_ #define _SQLITEINT_H_
@@ -231,7 +231,7 @@ struct BusyHandler {
** each malloc() and free(). This output can be analyzed ** each malloc() and free(). This output can be analyzed
** by an AWK script to determine if there are any leaks. ** by an AWK script to determine if there are any leaks.
*/ */
#ifdef SQLITE_DEBUG #ifdef SQLITE_TEST
# define sqliteMalloc(X) sqlite3Malloc_(X,1,__FILE__,__LINE__) # define sqliteMalloc(X) sqlite3Malloc_(X,1,__FILE__,__LINE__)
# define sqliteMallocRaw(X) sqlite3Malloc_(X,0,__FILE__,__LINE__) # define sqliteMallocRaw(X) sqlite3Malloc_(X,0,__FILE__,__LINE__)
# define sqliteFree(X) sqlite3Free_(X,__FILE__,__LINE__) # define sqliteFree(X) sqlite3Free_(X,__FILE__,__LINE__)
@@ -257,7 +257,7 @@ extern int sqlite3_malloc_failed;
** The following global variables are used for testing and debugging ** The following global variables are used for testing and debugging
** only. They only work if SQLITE_DEBUG is defined. ** only. They only work if SQLITE_DEBUG is defined.
*/ */
#ifdef SQLITE_DEBUG #ifdef SQLITE_TEST
extern int sqlite3_nMalloc; /* Number of sqliteMalloc() calls */ extern int sqlite3_nMalloc; /* Number of sqliteMalloc() calls */
extern int sqlite3_nFree; /* Number of sqliteFree() calls */ extern int sqlite3_nFree; /* Number of sqliteFree() calls */
extern int sqlite3_iMallocFail; /* Fail sqliteMalloc() after this many calls */ extern int sqlite3_iMallocFail; /* Fail sqliteMalloc() after this many calls */
@@ -1280,7 +1280,7 @@ int sqlite3IsNumber(const char*, int*, u8);
int sqlite3Compare(const char *, const char *); int sqlite3Compare(const char *, const char *);
int sqlite3SortCompare(const char *, const char *); int sqlite3SortCompare(const char *, const char *);
void sqlite3RealToSortable(double r, char *); void sqlite3RealToSortable(double r, char *);
#ifdef SQLITE_DEBUG #ifdef SQLITE_TEST
void *sqlite3Malloc_(int,int,char*,int); void *sqlite3Malloc_(int,int,char*,int);
void sqlite3Free_(void*,char*,int); void sqlite3Free_(void*,char*,int);
void *sqlite3Realloc_(void*,int,char*,int); void *sqlite3Realloc_(void*,int,char*,int);

View File

@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated ** is not included in the SQLite library. It is used for automated
** testing of the SQLite library. ** testing of the SQLite library.
** **
** $Id: test1.c,v 1.119 2005/01/11 16:54:15 drh Exp $ ** $Id: test1.c,v 1.120 2005/01/12 07:15:05 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@@ -756,7 +756,7 @@ static int sqlite3_mprintf_stronly(
** **
** Turn off this mechanism and reset the sqlite3_malloc_failed variable is N==0. ** Turn off this mechanism and reset the sqlite3_malloc_failed variable is N==0.
*/ */
#ifdef SQLITE_DEBUG #ifdef SQLITE_TEST
static int sqlite_malloc_fail( static int sqlite_malloc_fail(
void *NotUsed, void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
@@ -787,7 +787,7 @@ static int sqlite_malloc_fail(
** **
** Return the number of prior calls to sqliteMalloc() and sqliteFree(). ** Return the number of prior calls to sqliteMalloc() and sqliteFree().
*/ */
#ifdef SQLITE_DEBUG #ifdef SQLITE_TEST
static int sqlite_malloc_stat( static int sqlite_malloc_stat(
void *NotUsed, void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
@@ -2749,7 +2749,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_create_aggregate", (Tcl_CmdProc*)test_create_aggregate }, { "sqlite3_create_aggregate", (Tcl_CmdProc*)test_create_aggregate },
{ "sqlite_register_test_function", (Tcl_CmdProc*)test_register_func }, { "sqlite_register_test_function", (Tcl_CmdProc*)test_register_func },
{ "sqlite_abort", (Tcl_CmdProc*)sqlite_abort }, { "sqlite_abort", (Tcl_CmdProc*)sqlite_abort },
#ifdef SQLITE_DEBUG #ifdef SQLITE_TEST
{ "sqlite_malloc_fail", (Tcl_CmdProc*)sqlite_malloc_fail }, { "sqlite_malloc_fail", (Tcl_CmdProc*)sqlite_malloc_fail },
{ "sqlite_malloc_stat", (Tcl_CmdProc*)sqlite_malloc_stat }, { "sqlite_malloc_stat", (Tcl_CmdProc*)sqlite_malloc_stat },
#endif #endif

View File

@@ -12,7 +12,7 @@
** This file contains routines used to translate between UTF-8, ** This file contains routines used to translate between UTF-8,
** UTF-16, UTF-16BE, and UTF-16LE. ** UTF-16, UTF-16BE, and UTF-16LE.
** **
** $Id: utf.c,v 1.30 2004/11/14 21:56:30 drh Exp $ ** $Id: utf.c,v 1.31 2005/01/12 07:15:06 danielk1977 Exp $
** **
** Notes on UTF-8: ** Notes on UTF-8:
** **
@@ -252,7 +252,7 @@ int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){
assert( pMem->enc!=0 ); assert( pMem->enc!=0 );
assert( pMem->n>=0 ); assert( pMem->n>=0 );
#ifdef TRANSLATE_TRACE #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)
{ {
char zBuf[100]; char zBuf[100];
sqlite3VdbeMemPrettyPrint(pMem, zBuf, 100); sqlite3VdbeMemPrettyPrint(pMem, zBuf, 100);
@@ -368,7 +368,7 @@ int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){
pMem->z = zOut; pMem->z = zOut;
translate_out: translate_out:
#ifdef TRANSLATE_TRACE #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)
{ {
char zBuf[100]; char zBuf[100];
sqlite3VdbeMemPrettyPrint(pMem, zBuf, 100); sqlite3VdbeMemPrettyPrint(pMem, zBuf, 100);

View File

@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing ** This file contains functions for allocating memory, comparing
** strings, and stuff like that. ** strings, and stuff like that.
** **
** $Id: util.c,v 1.124 2005/01/11 15:28:33 drh Exp $ ** $Id: util.c,v 1.125 2005/01/12 07:15:06 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <stdarg.h> #include <stdarg.h>
@@ -44,10 +44,10 @@ void print_stack_trace(){
int sqlite3_malloc_failed = 0; int sqlite3_malloc_failed = 0;
/* /*
** If SQLITE_DEBUG is defined, then use versions of malloc() and ** If SQLITE_TEST is defined, then use versions of malloc() and
** free() that track memory usage and check for buffer overruns. ** free() that track memory usage and check for buffer overruns.
*/ */
#ifdef SQLITE_DEBUG #ifdef SQLITE_TEST
/* /*
** For keeping track of the number of mallocs and frees. This ** For keeping track of the number of mallocs and frees. This
@@ -251,7 +251,7 @@ void sqlite3FreeX(void *p){
** The following versions of malloc() and free() are for use in a ** The following versions of malloc() and free() are for use in a
** normal build. ** normal build.
*/ */
#if !defined(SQLITE_DEBUG) #if !defined(SQLITE_TEST)
/* /*
** Allocate new memory and set it to zero. Return NULL if ** Allocate new memory and set it to zero. Return NULL if
@@ -329,7 +329,7 @@ char *sqlite3StrNDup(const char *z, int n){
} }
return zNew; return zNew;
} }
#endif /* !defined(SQLITE_DEBUG) */ #endif /* !defined(SQLITE_TEST) */
/* /*
** Create a string from the 2nd and subsequent arguments (up to the ** Create a string from the 2nd and subsequent arguments (up to the

View File

@@ -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.440 2005/01/11 13:02:34 danielk1977 Exp $ ** $Id: vdbe.c,v 1.441 2005/01/12 07:15:06 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -303,7 +303,7 @@ static void applyAffinity(Mem *pRec, char affinity, u8 enc){
} }
} }
#ifndef NDEBUG #ifdef SQLITE_DEBUG
/* /*
** Write a nice string representation of the contents of cell pMem ** Write a nice string representation of the contents of cell pMem
** into buffer zBuf, length nBuf. ** into buffer zBuf, length nBuf.
@@ -4519,6 +4519,8 @@ default: {
sqlite3SetString(&p->zErrMsg, "jump destination out of range", (char*)0); sqlite3SetString(&p->zErrMsg, "jump destination out of range", (char*)0);
rc = SQLITE_INTERNAL; rc = SQLITE_INTERNAL;
} }
#ifdef SQLITE_DEBUG
/* Code for tracing the vdbe stack. */
if( p->trace && pTos>=p->aStack ){ if( p->trace && pTos>=p->aStack ){
int i; int i;
fprintf(p->trace, "Stack:"); fprintf(p->trace, "Stack:");
@@ -4541,7 +4543,8 @@ default: {
if( rc!=0 ) fprintf(p->trace," rc=%d",rc); if( rc!=0 ) fprintf(p->trace," rc=%d",rc);
fprintf(p->trace,"\n"); fprintf(p->trace,"\n");
} }
#endif #endif /* SQLITE_DEBUG */
#endif /* NDEBUG */
} /* The end of the for(;;) loop the loops through opcodes */ } /* The end of the for(;;) loop the loops through opcodes */
/* If we reach this point, it means that execution is finished. /* If we reach this point, it means that execution is finished.

View File

@@ -394,6 +394,8 @@ int sqlite3VdbeMemSetStr(
pMem->type = enc==0 ? SQLITE_BLOB : SQLITE_TEXT; pMem->type = enc==0 ? SQLITE_BLOB : SQLITE_TEXT;
pMem->n = n; pMem->n = n;
assert( enc==0 || enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE
|| enc==SQLITE_UTF16BE );
switch( enc ){ switch( enc ){
case 0: case 0:
pMem->flags |= MEM_Blob; pMem->flags |= MEM_Blob;
@@ -418,11 +420,7 @@ int sqlite3VdbeMemSetStr(
if( sqlite3VdbeMemHandleBom(pMem) ){ if( sqlite3VdbeMemHandleBom(pMem) ){
return SQLITE_NOMEM; return SQLITE_NOMEM;
} }
break;
#endif /* SQLITE_OMIT_UTF16 */ #endif /* SQLITE_OMIT_UTF16 */
default:
assert(0);
} }
if( pMem->flags&MEM_Ephem ){ if( pMem->flags&MEM_Ephem ){
return sqlite3VdbeMemMakeWriteable(pMem); return sqlite3VdbeMemMakeWriteable(pMem);

View File

@@ -10,7 +10,7 @@
#*********************************************************************** #***********************************************************************
# This file runs all tests. # This file runs all tests.
# #
# $Id: all.test,v 1.25 2005/01/08 02:35:44 danielk1977 Exp $ # $Id: all.test,v 1.26 2005/01/12 07:15:07 danielk1977 Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -55,7 +55,6 @@ set EXCLUDE {
malloc.test malloc.test
misuse.test misuse.test
memleak.test memleak.test
corrupt.test
} }
# Test files btree2.test and btree4.test don't work if the # Test files btree2.test and btree4.test don't work if the

View File

@@ -14,7 +14,7 @@
# special feature is used to see what happens in the library if a malloc # special feature is used to see what happens in the library if a malloc
# were to really fail due to an out-of-memory situation. # were to really fail due to an out-of-memory situation.
# #
# $Id: malloc.test,v 1.13 2005/01/11 13:02:34 danielk1977 Exp $ # $Id: malloc.test,v 1.14 2005/01/12 07:15:07 danielk1977 Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -316,10 +316,13 @@ for {set go 1; set i 1} {$go} {incr i} {
INSERT INTO t1 VALUES(1, 2); INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(3, 4); INSERT INTO t1 VALUES(3, 4);
INSERT INTO t1 VALUES(5, 6); INSERT INTO t1 VALUES(5, 6);
INSERT INTO t1 VALUES(7, randstr(1200,1200));
} }
sqlite_malloc_fail $i sqlite_malloc_fail $i
set v [catch {execsql { set v [catch {execsql {
SELECT min(a) FROM t1 GROUP BY b; SELECT min(a) FROM t1 WHERE a<6 GROUP BY b;
SELECT a FROM t1 WHERE a<6 ORDER BY a;
SELECT b FROM t1 WHERE a>6;
}} msg] }} msg]
set leftover [lindex [sqlite_malloc_stat] 2] set leftover [lindex [sqlite_malloc_stat] 2]
if {$leftover>0} { if {$leftover>0} {
@@ -334,8 +337,53 @@ for {set go 1; set i 1} {$go} {incr i} {
} {1 1} } {1 1}
} }
# This block is designed to test that some malloc failures that may
# occur in vdbeapi.c. Specifically, if a malloc failure that occurs
# when converting UTF-16 text to integers and real numbers is handled
# correctly.
#
# This doesn't actually return an error to the user. That could be
# viewed as a bug.
#
for {set go 1; set i 1} {$go && $::sqlite_options(utf16)} {incr i} {
do_test malloc-8.$i {
sqlite_malloc_fail 0
catch {db close}
catch {file delete -force test.db}
catch {file delete -force test.db-journal}
set ::DB [sqlite3 db test.db]
set sql "SELECT '[string repeat abc 20]', '[string repeat def 20]', ?"
set ::STMT [sqlite3_prepare $::DB $sql -1 X]
sqlite3_step $::STMT
if { $::tcl_platform(byteOrder)=="littleEndian" } {
set ::bomstr "\xFF\xFE"
} else {
set ::bomstr "\xFE\xFF"
}
append ::bomstr [encoding convertto unicode "123456789_123456789_12345678"]
sqlite_malloc_fail $i
catch {
sqlite3_column_text16 $::STMT 0
sqlite3_column_int $::STMT 0
sqlite3_column_text16 $::STMT 1
sqlite3_column_double $::STMT 1
sqlite3_reset $::STMT
sqlite3_bind_text16 $::STMT 1 $::bomstr 60
} msg
sqlite3_finalize $::STMT
if {[lindex [sqlite_malloc_stat] 2]>0} {
set ::go 0
}
expr 0
} {0}
}
# Ensure that no file descriptors were leaked. # Ensure that no file descriptors were leaked.
do_test malloc-6.X { do_test malloc-99.X {
catch {db close} catch {db close}
set sqlite_open_file_count set sqlite_open_file_count
} {0} } {0}