Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Make the benign-fault setting recursive. Make all malloc failures during a rollback benign since there is nothing we can do about them. (CVS 5128) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a9d1d931358637a6f039723a053098f6 |
User & Date: | drh 2008-05-13 13:27:34 |
Context
2008-05-13
| ||
16:41 | Do a slow-path in GetVarint32() for varints that do not fit in 32 bits. This will only happen when trying to interpret a corrupt database file so speed is not critical. (CVS 5129) check-in: 6a6b9437 user: drh tags: trunk | |
13:27 | Make the benign-fault setting recursive. Make all malloc failures during a rollback benign since there is nothing we can do about them. (CVS 5128) check-in: a9d1d931 user: drh tags: trunk | |
00:58 | Update the pager so that it does not try to commit a transaction if there have been no changes to the database. (CVS 5127) check-in: f1ed3689 user: drh tags: trunk | |
Changes
Changes to src/bitvec.c.
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
** Clear operations are exceedingly rare. There are usually between ** 5 and 500 set operations per Bitvec object, though the number of sets can ** sometimes grow into tens of thousands or larger. The size of the ** Bitvec object is the number of pages in the database file at the ** start of a transaction, and is thus usually less than a few thousand, ** but can be as large as 2 billion for a really big database. ** ** @(#) $Id: bitvec.c,v 1.4 2008/04/14 01:00:58 drh Exp $ */ #include "sqliteInt.h" #define BITVEC_SZ 512 /* Round the union size down to the nearest pointer boundary, since that's how ** it will be aligned within the Bitvec struct. */ #define BITVEC_USIZE (((BITVEC_SZ-12)/sizeof(Bitvec*))*sizeof(Bitvec*)) ................................................................................ p->u.aBitmap[i/8] |= 1 << (i&7); return SQLITE_OK; } if( p->iDivisor ){ u32 bin = (i-1)/p->iDivisor; i = (i-1)%p->iDivisor + 1; if( p->u.apSub[bin]==0 ){ sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1); p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor ); sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0); if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM; } return sqlite3BitvecSet(p->u.apSub[bin], i); } h = BITVEC_HASH(i); while( p->u.aHash[h] ){ if( p->u.aHash[h]==i ) return SQLITE_OK; |
|
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
** Clear operations are exceedingly rare. There are usually between ** 5 and 500 set operations per Bitvec object, though the number of sets can ** sometimes grow into tens of thousands or larger. The size of the ** Bitvec object is the number of pages in the database file at the ** start of a transaction, and is thus usually less than a few thousand, ** but can be as large as 2 billion for a really big database. ** ** @(#) $Id: bitvec.c,v 1.5 2008/05/13 13:27:34 drh Exp $ */ #include "sqliteInt.h" #define BITVEC_SZ 512 /* Round the union size down to the nearest pointer boundary, since that's how ** it will be aligned within the Bitvec struct. */ #define BITVEC_USIZE (((BITVEC_SZ-12)/sizeof(Bitvec*))*sizeof(Bitvec*)) ................................................................................ p->u.aBitmap[i/8] |= 1 << (i&7); return SQLITE_OK; } if( p->iDivisor ){ u32 bin = (i-1)/p->iDivisor; i = (i-1)%p->iDivisor + 1; if( p->u.apSub[bin]==0 ){ sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC); p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor ); sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC); if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM; } return sqlite3BitvecSet(p->u.apSub[bin], i); } h = BITVEC_HASH(i); while( p->u.aHash[h] ){ if( p->u.aHash[h]==i ) return SQLITE_OK; |
Changes to src/fault.c.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 ... 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 ... 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
*/ static struct FaultInjector { int iCountdown; /* Number of pending successes before we hit a failure */ int nRepeat; /* Number of times to repeat the failure */ int nBenign; /* Number of benign failures seen since last config */ int nFail; /* Number of failures seen since last config */ u8 enable; /* True if enabled */ u8 benign; /* True if next failure will be benign */ } aFault[SQLITE_FAULTINJECTOR_COUNT]; /* ** This routine configures and enables a fault injector. After ** calling this routine, aFaultStep() will return false (zero) ** nDelay times, then it will return true nRepeat times, ** then it will again begin returning false. ................................................................................ ** an error to be propagated back up to the application interface. ** However, sometimes a fault is easily recoverable. For example, ** if a malloc fails while resizing a hash table, this is completely ** recoverable simply by not carrying out the resize. The hash table ** will continue to function normally. So a malloc failure during ** a hash table resize is a benign fault. */ void sqlite3FaultBenign(int id, int enable){ if( id<0 ){ for(id=0; id<SQLITE_FAULTINJECTOR_COUNT; id++){ aFault[id].benign = enable; } }else{ assert( id>=0 && id<SQLITE_FAULTINJECTOR_COUNT ); aFault[id].benign = enable; } } /* ** This routine exists as a place to set a breakpoint that will ** fire on any simulated fault. */ ................................................................................ } if( aFault[id].iCountdown>0 ){ aFault[id].iCountdown--; return 0; } sqlite3Fault(); aFault[id].nFail++; if( aFault[id].benign ){ aFault[id].nBenign++; } aFault[id].nRepeat--; if( aFault[id].nRepeat<=0 ){ aFault[id].enable = 0; } return 1; } #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| | | > > > > > > > > > > > > | | |
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 ... 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 ... 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
*/ static struct FaultInjector { int iCountdown; /* Number of pending successes before we hit a failure */ int nRepeat; /* Number of times to repeat the failure */ int nBenign; /* Number of benign failures seen since last config */ int nFail; /* Number of failures seen since last config */ u8 enable; /* True if enabled */ i16 benign; /* Positive if next failure will be benign */ } aFault[SQLITE_FAULTINJECTOR_COUNT]; /* ** This routine configures and enables a fault injector. After ** calling this routine, aFaultStep() will return false (zero) ** nDelay times, then it will return true nRepeat times, ** then it will again begin returning false. ................................................................................ ** an error to be propagated back up to the application interface. ** However, sometimes a fault is easily recoverable. For example, ** if a malloc fails while resizing a hash table, this is completely ** recoverable simply by not carrying out the resize. The hash table ** will continue to function normally. So a malloc failure during ** a hash table resize is a benign fault. */ void sqlite3FaultBeginBenign(int id){ if( id<0 ){ for(id=0; id<SQLITE_FAULTINJECTOR_COUNT; id++){ aFault[id].benign++; } }else{ assert( id>=0 && id<SQLITE_FAULTINJECTOR_COUNT ); aFault[id].benign++; } } void sqlite3FaultEndBenign(int id){ if( id<0 ){ for(id=0; id<SQLITE_FAULTINJECTOR_COUNT; id++){ assert( aFault[id].benign>0 ); aFault[id].benign--; } }else{ assert( id>=0 && id<SQLITE_FAULTINJECTOR_COUNT ); assert( aFault[id].benign>0 ); aFault[id].benign--; } } /* ** This routine exists as a place to set a breakpoint that will ** fire on any simulated fault. */ ................................................................................ } if( aFault[id].iCountdown>0 ){ aFault[id].iCountdown--; return 0; } sqlite3Fault(); aFault[id].nFail++; if( aFault[id].benign>0 ){ aFault[id].nBenign++; } aFault[id].nRepeat--; if( aFault[id].nRepeat<=0 ){ aFault[id].enable = 0; } return 1; } #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
Changes to src/hash.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** ** $Id: hash.c,v 1.27 2008/04/02 18:33:08 drh Exp $ */ #include "sqliteInt.h" #include <assert.h> /* Turn bulk memory into a hash table object by initializing the ** fields of the Hash structure. ** ................................................................................ #endif /* There is a call to sqlite3_malloc() inside rehash(). If there is ** already an allocation at pH->ht, then if this malloc() fails it ** is benign (since failing to resize a hash table is a performance ** hit only, not a fatal error). */ sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, pH->htsize>0); new_ht = (struct _ht *)sqlite3MallocZero( new_size*sizeof(struct _ht) ); sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0); if( new_ht==0 ) return; sqlite3_free(pH->ht); pH->ht = new_ht; pH->htsize = new_size; xHash = hashFunction(pH->keyClass); for(elem=pH->first, pH->first=0; elem; elem = next_elem){ |
|
|
|
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** ** $Id: hash.c,v 1.28 2008/05/13 13:27:34 drh Exp $ */ #include "sqliteInt.h" #include <assert.h> /* Turn bulk memory into a hash table object by initializing the ** fields of the Hash structure. ** ................................................................................ #endif /* There is a call to sqlite3_malloc() inside rehash(). If there is ** already an allocation at pH->ht, then if this malloc() fails it ** is benign (since failing to resize a hash table is a performance ** hit only, not a fatal error). */ if( pH->htsize>0 ) sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC); new_ht = (struct _ht *)sqlite3MallocZero( new_size*sizeof(struct _ht) ); if( pH->htsize>0 ) sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC); if( new_ht==0 ) return; sqlite3_free(pH->ht); pH->ht = new_ht; pH->htsize = new_size; xHash = hashFunction(pH->keyClass); for(elem=pH->first, pH->first=0; elem; elem = next_elem){ |
Changes to src/main.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.438 2008/05/05 16:56:35 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #ifdef SQLITE_ENABLE_FTS3 # include "fts3.h" #endif ................................................................................ /* ** Rollback all database files. */ void sqlite3RollbackAll(sqlite3 *db){ int i; int inTrans = 0; assert( sqlite3_mutex_held(db->mutex) ); sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1); for(i=0; i<db->nDb; i++){ if( db->aDb[i].pBt ){ if( sqlite3BtreeIsInTrans(db->aDb[i].pBt) ){ inTrans = 1; } sqlite3BtreeRollback(db->aDb[i].pBt); db->aDb[i].inTrans = 0; } } sqlite3VtabRollback(db); sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0); if( db->flags&SQLITE_InternChanges ){ sqlite3ExpirePreparedStatements(db); sqlite3ResetInternalSchema(db, 0); } /* If one has been configured, invoke the rollback-hook callback */ |
|
|
|
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.439 2008/05/13 13:27:34 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #ifdef SQLITE_ENABLE_FTS3 # include "fts3.h" #endif ................................................................................ /* ** Rollback all database files. */ void sqlite3RollbackAll(sqlite3 *db){ int i; int inTrans = 0; assert( sqlite3_mutex_held(db->mutex) ); sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC); for(i=0; i<db->nDb; i++){ if( db->aDb[i].pBt ){ if( sqlite3BtreeIsInTrans(db->aDb[i].pBt) ){ inTrans = 1; } sqlite3BtreeRollback(db->aDb[i].pBt); db->aDb[i].inTrans = 0; } } sqlite3VtabRollback(db); sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC); if( db->flags&SQLITE_InternChanges ){ sqlite3ExpirePreparedStatements(db); sqlite3ResetInternalSchema(db, 0); } /* If one has been configured, invoke the rollback-hook callback */ |
Changes to src/pager.c.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ... 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 .... 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 .... 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 |
** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: pager.c,v 1.445 2008/05/13 00:58:18 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include <assert.h> #include <string.h> /* ................................................................................ #ifdef SQLITE_MALLOC_SOFT_LIMIT if( N*sizeof(aHash[0])>SQLITE_MALLOC_SOFT_LIMIT ){ N = SQLITE_MALLOC_SOFT_LIMIT/sizeof(aHash[0]); } if( N==pPager->nHash ) return; #endif pagerLeave(pPager); sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, pPager->aHash!=0); aHash = sqlite3MallocZero( sizeof(aHash[0])*N ); sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0); pagerEnter(pPager); if( aHash==0 ){ /* Failure to rehash is not an error. It is only a performance hit. */ return; } sqlite3_free(pPager->aHash); pPager->nHash = N; ................................................................................ ** Execute a rollback if a transaction is active and unlock the ** database file. If the pager has already entered the error state, ** do not attempt the rollback. */ static void pagerUnlockAndRollback(Pager *p){ /* assert( p->state>=PAGER_RESERVED || p->journalOpen==0 ); */ if( p->errCode==SQLITE_OK && p->state>=PAGER_RESERVED ){ sqlite3PagerRollback(p); } pager_unlock(p); #if 0 assert( p->errCode || !p->journalOpen || (p->exclusiveMode&&!p->journalOff) ); assert( p->errCode || !p->stmtOpen || p->exclusiveMode ); #endif } ................................................................................ pPager->pNext->pPrev = pPager->pPrev; } sqlite3_mutex_leave(mutex); } #endif disable_simulated_io_errors(); sqlite3FaultBenign(-1, 1); pPager->errCode = 0; pPager->exclusiveMode = 0; pager_reset(pPager); pagerUnlockAndRollback(pPager); enable_simulated_io_errors(); sqlite3FaultBenign(-1, 0); PAGERTRACE2("CLOSE %d\n", PAGERID(pPager)); IOTRACE(("CLOSE %p\n", pPager)) if( pPager->journalOpen ){ sqlite3OsClose(pPager->jfd); } sqlite3BitvecDestroy(pPager->pInJournal); if( pPager->stmtOpen ){ |
| | | > > | | |
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ... 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 .... 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 .... 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 |
** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: pager.c,v 1.446 2008/05/13 13:27:34 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include <assert.h> #include <string.h> /* ................................................................................ #ifdef SQLITE_MALLOC_SOFT_LIMIT if( N*sizeof(aHash[0])>SQLITE_MALLOC_SOFT_LIMIT ){ N = SQLITE_MALLOC_SOFT_LIMIT/sizeof(aHash[0]); } if( N==pPager->nHash ) return; #endif pagerLeave(pPager); if( pPager->aHash!=0 ) sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC); aHash = sqlite3MallocZero( sizeof(aHash[0])*N ); if( pPager->aHash!=0 ) sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC); pagerEnter(pPager); if( aHash==0 ){ /* Failure to rehash is not an error. It is only a performance hit. */ return; } sqlite3_free(pPager->aHash); pPager->nHash = N; ................................................................................ ** Execute a rollback if a transaction is active and unlock the ** database file. If the pager has already entered the error state, ** do not attempt the rollback. */ static void pagerUnlockAndRollback(Pager *p){ /* assert( p->state>=PAGER_RESERVED || p->journalOpen==0 ); */ if( p->errCode==SQLITE_OK && p->state>=PAGER_RESERVED ){ sqlite3FaultBeginBenign(-1); sqlite3PagerRollback(p); sqlite3FaultEndBenign(-1); } pager_unlock(p); #if 0 assert( p->errCode || !p->journalOpen || (p->exclusiveMode&&!p->journalOff) ); assert( p->errCode || !p->stmtOpen || p->exclusiveMode ); #endif } ................................................................................ pPager->pNext->pPrev = pPager->pPrev; } sqlite3_mutex_leave(mutex); } #endif disable_simulated_io_errors(); sqlite3FaultBeginBenign(-1); pPager->errCode = 0; pPager->exclusiveMode = 0; pager_reset(pPager); pagerUnlockAndRollback(pPager); enable_simulated_io_errors(); sqlite3FaultEndBenign(-1); PAGERTRACE2("CLOSE %d\n", PAGERID(pPager)); IOTRACE(("CLOSE %p\n", pPager)) if( pPager->journalOpen ){ sqlite3OsClose(pPager->jfd); } sqlite3BitvecDestroy(pPager->pInJournal); if( pPager->stmtOpen ){ |
Changes to src/sqliteInt.h.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
|
** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.703 2008/05/09 18:03:14 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build ................................................................................ ** unnecessary code is generated. */ #ifndef SQLITE_OMIT_BUILTIN_TEST void sqlite3FaultConfig(int,int,int); int sqlite3FaultFailures(int); int sqlite3FaultBenignFailures(int); int sqlite3FaultPending(int); void sqlite3FaultBenign(int,int); int sqlite3FaultStep(int); #else # define sqlite3FaultConfig(A,B,C) # define sqlite3FaultFailures(A) 0 # define sqlite3FaultBenignFailures(A) 0 # define sqlite3FaultPending(A) (-1) # define sqlite3FaultBenign(A,B) # define sqlite3FaultStep(A) 0 #endif #define IN_INDEX_ROWID 1 #define IN_INDEX_EPH 2 |
|
|
>
|
>
|
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
|
** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.704 2008/05/13 13:27:34 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build ................................................................................ ** unnecessary code is generated. */ #ifndef SQLITE_OMIT_BUILTIN_TEST void sqlite3FaultConfig(int,int,int); int sqlite3FaultFailures(int); int sqlite3FaultBenignFailures(int); int sqlite3FaultPending(int); void sqlite3FaultBeginBenign(int); void sqlite3FaultEndBenign(int); int sqlite3FaultStep(int); #else # define sqlite3FaultConfig(A,B,C) # define sqlite3FaultFailures(A) 0 # define sqlite3FaultBenignFailures(A) 0 # define sqlite3FaultPending(A) (-1) # define sqlite3FaultBeginBenign(A) # define sqlite3FaultEndBenign(A) # define sqlite3FaultStep(A) 0 #endif #define IN_INDEX_ROWID 1 #define IN_INDEX_EPH 2 |
Changes to src/test8.c.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
|
** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test8.c,v 1.63 2008/05/05 13:23:04 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> #ifndef SQLITE_OMIT_VIRTUALTABLE ................................................................................ echo_vtab *pVtab = (echo_vtab*)tab; int rc; /* Ticket #3083 - Only call xCommit if we have previously started ** a transaction */ assert( pVtab->inTransaction ); sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1); rc = echoTransactionCall(tab, "xCommit"); sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0); pVtab->inTransaction = 0; return rc; } static int echoRollback(sqlite3_vtab *tab){ int rc; echo_vtab *pVtab = (echo_vtab*)tab; |
|
|
|
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
|
** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test8.c,v 1.64 2008/05/13 13:27:34 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> #ifndef SQLITE_OMIT_VIRTUALTABLE ................................................................................ echo_vtab *pVtab = (echo_vtab*)tab; int rc; /* Ticket #3083 - Only call xCommit if we have previously started ** a transaction */ assert( pVtab->inTransaction ); sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC); rc = echoTransactionCall(tab, "xCommit"); sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC); pVtab->inTransaction = 0; return rc; } static int echoRollback(sqlite3_vtab *tab){ int rc; echo_vtab *pVtab = (echo_vtab*)tab; |
Changes to src/vdbe.c.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 ... 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 ... 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** ** $Id: vdbe.c,v 1.739 2008/05/09 18:03:14 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include "vdbeInt.h" /* ** The following global variable is incremented every time a cursor ................................................................................ p->rc = SQLITE_OK; assert( p->explain==0 ); p->pResultSet = 0; db->busyHandler.nBusy = 0; CHECK_FOR_INTERRUPT; sqlite3VdbeIOTraceSql(p); #ifdef SQLITE_DEBUG sqlite3FaultBenign(-1, 1); if( p->pc==0 && ((p->db->flags & SQLITE_VdbeListing)!=0 || sqlite3OsAccess(db->pVfs, "vdbe_explain", SQLITE_ACCESS_EXISTS)==1 ) ){ int i; printf("VDBE Program Listing:\n"); sqlite3VdbePrintSql(p); for(i=0; i<p->nOp; i++){ sqlite3VdbePrintOp(stdout, i, &p->aOp[i]); } } if( sqlite3OsAccess(db->pVfs, "vdbe_trace", SQLITE_ACCESS_EXISTS)==1 ){ p->trace = stdout; } sqlite3FaultBenign(-1, 0); #endif for(pc=p->pc; rc==SQLITE_OK; pc++){ assert( pc>=0 && pc<p->nOp ); if( db->mallocFailed ) goto no_mem; #ifdef VDBE_PROFILE origPc = pc; start = hwtime(); ................................................................................ if( pc==0 ){ printf("VDBE Execution Trace:\n"); sqlite3VdbePrintSql(p); } sqlite3VdbePrintOp(p->trace, pc, pOp); } if( p->trace==0 && pc==0 ){ sqlite3FaultBenign(-1, 1); if( sqlite3OsAccess(db->pVfs, "vdbe_sqltrace", SQLITE_ACCESS_EXISTS)==1 ){ sqlite3VdbePrintSql(p); } sqlite3FaultBenign(-1, 0); } #endif /* Check to see if we need to simulate an interrupt. This only happens ** if we have a special test build. */ |
| | | | | |
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 ... 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 ... 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** ** $Id: vdbe.c,v 1.740 2008/05/13 13:27:34 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include "vdbeInt.h" /* ** The following global variable is incremented every time a cursor ................................................................................ p->rc = SQLITE_OK; assert( p->explain==0 ); p->pResultSet = 0; db->busyHandler.nBusy = 0; CHECK_FOR_INTERRUPT; sqlite3VdbeIOTraceSql(p); #ifdef SQLITE_DEBUG sqlite3FaultBeginBenign(-1); if( p->pc==0 && ((p->db->flags & SQLITE_VdbeListing)!=0 || sqlite3OsAccess(db->pVfs, "vdbe_explain", SQLITE_ACCESS_EXISTS)==1 ) ){ int i; printf("VDBE Program Listing:\n"); sqlite3VdbePrintSql(p); for(i=0; i<p->nOp; i++){ sqlite3VdbePrintOp(stdout, i, &p->aOp[i]); } } if( sqlite3OsAccess(db->pVfs, "vdbe_trace", SQLITE_ACCESS_EXISTS)==1 ){ p->trace = stdout; } sqlite3FaultEndBenign(-1); #endif for(pc=p->pc; rc==SQLITE_OK; pc++){ assert( pc>=0 && pc<p->nOp ); if( db->mallocFailed ) goto no_mem; #ifdef VDBE_PROFILE origPc = pc; start = hwtime(); ................................................................................ if( pc==0 ){ printf("VDBE Execution Trace:\n"); sqlite3VdbePrintSql(p); } sqlite3VdbePrintOp(p->trace, pc, pOp); } if( p->trace==0 && pc==0 ){ sqlite3FaultBeginBenign(-1); if( sqlite3OsAccess(db->pVfs, "vdbe_sqltrace", SQLITE_ACCESS_EXISTS)==1 ){ sqlite3VdbePrintSql(p); } sqlite3FaultEndBenign(-1); } #endif /* Check to see if we need to simulate an interrupt. This only happens ** if we have a special test build. */ |
Changes to src/vdbeaux.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
....
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
|
** ************************************************************************* ** This file contains code used for creating, destroying, and populating ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior ** 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. ** ** $Id: vdbeaux.c,v 1.382 2008/05/08 15:18:10 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include "vdbeInt.h" ................................................................................ ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and ** deleting or truncating journals. If something goes wrong while ** this is happening we don't really care. The integrity of the ** transaction is already guaranteed, but some stray 'cold' journals ** may be lying around. Returning an error code won't help matters. */ disable_simulated_io_errors(); sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1); for(i=0; i<db->nDb; i++){ Btree *pBt = db->aDb[i].pBt; if( pBt ){ sqlite3BtreeCommitPhaseTwo(pBt); } } sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0); enable_simulated_io_errors(); sqlite3VtabCommit(db); } #endif return rc; |
|
|
|
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
....
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
|
** ************************************************************************* ** This file contains code used for creating, destroying, and populating ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior ** 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. ** ** $Id: vdbeaux.c,v 1.383 2008/05/13 13:27:34 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include "vdbeInt.h" ................................................................................ ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and ** deleting or truncating journals. If something goes wrong while ** this is happening we don't really care. The integrity of the ** transaction is already guaranteed, but some stray 'cold' journals ** may be lying around. Returning an error code won't help matters. */ disable_simulated_io_errors(); sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC); for(i=0; i<db->nDb; i++){ Btree *pBt = db->aDb[i].pBt; if( pBt ){ sqlite3BtreeCommitPhaseTwo(pBt); } } sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC); enable_simulated_io_errors(); sqlite3VtabCommit(db); } #endif return rc; |
Changes to test/malloc3.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
|
# #*********************************************************************** # # This file contains tests to ensure that the library handles malloc() failures # correctly. The emphasis of these tests are the _prepare(), _step() and # _finalize() calls. # # $Id: malloc3.test,v 1.21 2008/05/13 00:58:18 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/malloc_common.tcl # Only run these tests if memory debugging is turned on. # ................................................................................ set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign] if {$rc == 0} { # Successful execution of sql. The number of failed malloc() # calls should be equal to the number of benign failures. # Otherwise a malloc() failed and the error was not reported. # if {$nFail!=$nBenign} { # error "Unreported malloc() failure" } if {$ac && !$nac} { # Before the [db eval] the auto-commit flag was set, now it # is clear. We can deduce that a "BEGIN" statement has just # been successfully executed. set begin_pc $pc |
|
|
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
|
# #*********************************************************************** # # This file contains tests to ensure that the library handles malloc() failures # correctly. The emphasis of these tests are the _prepare(), _step() and # _finalize() calls. # # $Id: malloc3.test,v 1.22 2008/05/13 13:27:34 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/malloc_common.tcl # Only run these tests if memory debugging is turned on. # ................................................................................ set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign] if {$rc == 0} { # Successful execution of sql. The number of failed malloc() # calls should be equal to the number of benign failures. # Otherwise a malloc() failed and the error was not reported. # if {$nFail!=$nBenign} { error "Unreported malloc() failure" } if {$ac && !$nac} { # Before the [db eval] the auto-commit flag was set, now it # is clear. We can deduce that a "BEGIN" statement has just # been successfully executed. set begin_pc $pc |