| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/sqlite/src/src/backup.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | struct sqlite3_backup { | - | ||||||||||||||||||||||||
| 6 | sqlite3* pDestDb; | - | ||||||||||||||||||||||||
| 7 | Btree *pDest; | - | ||||||||||||||||||||||||
| 8 | u32 iDestSchema; | - | ||||||||||||||||||||||||
| 9 | int bDestLocked; | - | ||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | Pgno iNext; | - | ||||||||||||||||||||||||
| 12 | sqlite3* pSrcDb; | - | ||||||||||||||||||||||||
| 13 | Btree *pSrc; | - | ||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | int rc; | - | ||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||
| 20 | Pgno nRemaining; | - | ||||||||||||||||||||||||
| 21 | Pgno nPagecount; | - | ||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | int isAttached; | - | ||||||||||||||||||||||||
| 24 | sqlite3_backup *pNext; | - | ||||||||||||||||||||||||
| 25 | }; | - | ||||||||||||||||||||||||
| 26 | static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){ | - | ||||||||||||||||||||||||
| 27 | int i = sqlite3FindDbName(pDb, zDb); | - | ||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | if( i==1
| 5-79 | ||||||||||||||||||||||||
| 30 | Parse sParse; | - | ||||||||||||||||||||||||
| 31 | int rc = 0; | - | ||||||||||||||||||||||||
| 32 | memset(&sParse, 0, sizeof(sParse)); | - | ||||||||||||||||||||||||
| 33 | sParse.db = pDb; | - | ||||||||||||||||||||||||
| 34 | if( sqlite3OpenTempDatabase(&sParse)
| 0-5 | ||||||||||||||||||||||||
| 35 | sqlite3ErrorWithMsg(pErrorDb, sParse.rc, "%s", sParse.zErrMsg); | - | ||||||||||||||||||||||||
| 36 | rc = 1; | - | ||||||||||||||||||||||||
| 37 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 38 | sqlite3DbFree(pErrorDb, sParse.zErrMsg); | - | ||||||||||||||||||||||||
| 39 | sqlite3ParserReset(&sParse); | - | ||||||||||||||||||||||||
| 40 | if( rc
| 0-5 | ||||||||||||||||||||||||
| 41 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 42 | } | - | ||||||||||||||||||||||||
| 43 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | if( i<0
| 2-82 | ||||||||||||||||||||||||
| 46 | sqlite3ErrorWithMsg(pErrorDb, 1, "unknown database %s", zDb); | - | ||||||||||||||||||||||||
| 47 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||||||||
| 48 | } | - | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | return executed 82 times by 1 test: pDb->aDb[i].pBt;return pDb->aDb[i].pBt;Executed by:
executed 82 times by 1 test: return pDb->aDb[i].pBt;Executed by:
| 82 | ||||||||||||||||||||||||
| 51 | } | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | static int setDestPgsz(sqlite3_backup *p){ | - | ||||||||||||||||||||||||
| 58 | int rc; | - | ||||||||||||||||||||||||
| 59 | rc = sqlite3BtreeSetPageSize(p->pDest,sqlite3BtreeGetPageSize(p->pSrc),-1,0); | - | ||||||||||||||||||||||||
| 60 | return executed 535 times by 2 tests: rc;return rc;Executed by:
executed 535 times by 2 tests: return rc;Executed by:
| 535 | ||||||||||||||||||||||||
| 61 | } | - | ||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | static int checkReadTransaction(sqlite3 *db, Btree *p){ | - | ||||||||||||||||||||||||
| 70 | if( sqlite3BtreeIsInReadTrans(p)
| 1-39 | ||||||||||||||||||||||||
| 71 | sqlite3ErrorWithMsg(db, 1, "destination database is in use"); | - | ||||||||||||||||||||||||
| 72 | return executed 1 time by 1 test: 1;return 1;Executed by:
executed 1 time by 1 test: return 1;Executed by:
| 1 | ||||||||||||||||||||||||
| 73 | } | - | ||||||||||||||||||||||||
| 74 | return executed 39 times by 1 test: 0;return 0;Executed by:
executed 39 times by 1 test: return 0;Executed by:
| 39 | ||||||||||||||||||||||||
| 75 | } | - | ||||||||||||||||||||||||
| 76 | sqlite3_backup *sqlite3_backup_init( | - | ||||||||||||||||||||||||
| 77 | sqlite3* pDestDb, | - | ||||||||||||||||||||||||
| 78 | const char *zDestDb, | - | ||||||||||||||||||||||||
| 79 | sqlite3* pSrcDb, | - | ||||||||||||||||||||||||
| 80 | const char *zSrcDb | - | ||||||||||||||||||||||||
| 81 | ){ | - | ||||||||||||||||||||||||
| 82 | sqlite3_backup *p; | - | ||||||||||||||||||||||||
| 83 | sqlite3_mutex_enter(pSrcDb->mutex); | - | ||||||||||||||||||||||||
| 84 | sqlite3_mutex_enter(pDestDb->mutex); | - | ||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | if( pSrcDb==pDestDb
| 0-42 | ||||||||||||||||||||||||
| 87 | sqlite3ErrorWithMsg( | - | ||||||||||||||||||||||||
| 88 | pDestDb, 1, "source and destination must be distinct" | - | ||||||||||||||||||||||||
| 89 | ); | - | ||||||||||||||||||||||||
| 90 | p = 0; | - | ||||||||||||||||||||||||
| 91 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | p = (sqlite3_backup *)sqlite3MallocZero(sizeof(sqlite3_backup)); | - | ||||||||||||||||||||||||
| 97 | if( !p
| 0-42 | ||||||||||||||||||||||||
| 98 | sqlite3Error(pDestDb, 7); | - | ||||||||||||||||||||||||
| 99 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 100 | } executed 42 times by 1 test: end of blockExecuted by:
| 42 | ||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | if( p
| 0-42 | ||||||||||||||||||||||||
| 104 | p->pSrc = findBtree(pDestDb, pSrcDb, zSrcDb); | - | ||||||||||||||||||||||||
| 105 | p->pDest = findBtree(pDestDb, pDestDb, zDestDb); | - | ||||||||||||||||||||||||
| 106 | p->pDestDb = pDestDb; | - | ||||||||||||||||||||||||
| 107 | p->pSrcDb = pSrcDb; | - | ||||||||||||||||||||||||
| 108 | p->iNext = 1; | - | ||||||||||||||||||||||||
| 109 | p->isAttached = 0; | - | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | if( 0==p->pSrc
| 1-41 | ||||||||||||||||||||||||
| 112 | || checkReadTransaction(pDestDb, p->pDest)!=0
| 1-39 | ||||||||||||||||||||||||
| 113 | ){ | - | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||
| 119 | sqlite3_free(p); | - | ||||||||||||||||||||||||
| 120 | p = 0; | - | ||||||||||||||||||||||||
| 121 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||
| 122 | } executed 42 times by 1 test: end of blockExecuted by:
| 42 | ||||||||||||||||||||||||
| 123 | if( p
| 3-39 | ||||||||||||||||||||||||
| 124 | p->pSrc->nBackup++; | - | ||||||||||||||||||||||||
| 125 | } executed 39 times by 1 test: end of blockExecuted by:
| 39 | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | sqlite3_mutex_leave(pDestDb->mutex); | - | ||||||||||||||||||||||||
| 128 | sqlite3_mutex_leave(pSrcDb->mutex); | - | ||||||||||||||||||||||||
| 129 | return executed 42 times by 1 test: p;return p;Executed by:
executed 42 times by 1 test: return p;Executed by:
| 42 | ||||||||||||||||||||||||
| 130 | } | - | ||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||
| 137 | static int isFatalError(int rc){ | - | ||||||||||||||||||||||||
| 138 | return executed 3091 times by 2 tests: (rc!=0return (rc!=0 && rc!=5 && (rc!=6));Executed by:
executed 3091 times by 2 tests: return (rc!=0 && rc!=5 && (rc!=6));Executed by:
| 0-3091 | ||||||||||||||||||||||||
| 139 | } | - | ||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | static int backupOnePage( | - | ||||||||||||||||||||||||
| 147 | sqlite3_backup *p, | - | ||||||||||||||||||||||||
| 148 | Pgno iSrcPg, | - | ||||||||||||||||||||||||
| 149 | const u8 *zSrcData, | - | ||||||||||||||||||||||||
| 150 | int bUpdate | - | ||||||||||||||||||||||||
| 151 | ){ | - | ||||||||||||||||||||||||
| 152 | Pager * const pDestPager = sqlite3BtreePager(p->pDest); | - | ||||||||||||||||||||||||
| 153 | const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc); | - | ||||||||||||||||||||||||
| 154 | int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest); | - | ||||||||||||||||||||||||
| 155 | const int nCopy = ((
| 17-98732 | ||||||||||||||||||||||||
| 156 | const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz; | - | ||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||
| 164 | int rc = 0; | - | ||||||||||||||||||||||||
| 165 | i64 iOff; | - | ||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | ((void) (0)) | - | ||||||||||||||||||||||||
| 169 | ; | - | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | ((void) (0)) | - | ||||||||||||||||||||||||
| 172 | ; | - | ||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||
| 174 | ((void) (0)) | - | ||||||||||||||||||||||||
| 175 | ; | - | ||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||
| 177 | ((void) (0)) | - | ||||||||||||||||||||||||
| 178 | ; | - | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | ((void) (0)) | - | ||||||||||||||||||||||||
| 181 | ; | - | ||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | - | |||||||||||||||||||||||||
| 186 | if( nSrcPgsz!=nDestPgsz
| 2-98584 | ||||||||||||||||||||||||
| 187 | rc = 8; | - | ||||||||||||||||||||||||
| 188 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 189 | for(iOff=iEnd-(i64)nSrcPgsz; rc==0
| 275-197387 | ||||||||||||||||||||||||
| 190 | DbPage *pDestPg = 0; | - | ||||||||||||||||||||||||
| 191 | Pgno iDest = (Pgno)(iOff/nDestPgsz)+1; | - | ||||||||||||||||||||||||
| 192 | if( iDest==((Pgno)((sqlite3PendingByte/((p->pDest->pBt)->pageSize))+1))
never executed: continue; | 0-98913 | ||||||||||||||||||||||||
| 193 | if( 0==(rc = sqlite3PagerGet(pDestPager, iDest, &pDestPg, 0))
| 0-98913 | ||||||||||||||||||||||||
| 194 | && 0==(rc = sqlite3PagerWrite(pDestPg))
| 273-98640 | ||||||||||||||||||||||||
| 195 | ){ | - | ||||||||||||||||||||||||
| 196 | const u8 *zIn = &zSrcData[iOff%nSrcPgsz]; | - | ||||||||||||||||||||||||
| 197 | u8 *zDestData = sqlite3PagerGetData(pDestPg); | - | ||||||||||||||||||||||||
| 198 | u8 *zOut = &zDestData[iOff%nDestPgsz]; | - | ||||||||||||||||||||||||
| 199 | memcpy(zOut, zIn, nCopy); | - | ||||||||||||||||||||||||
| 200 | ((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0; | - | ||||||||||||||||||||||||
| 201 | if( iOff==0
| 4-98111 | ||||||||||||||||||||||||
| 202 | sqlite3Put4byte(&zOut[28], sqlite3BtreeLastPage(p->pSrc)); | - | ||||||||||||||||||||||||
| 203 | } executed 525 times by 2 tests: end of blockExecuted by:
| 525 | ||||||||||||||||||||||||
| 204 | } executed 98640 times by 2 tests: end of blockExecuted by:
| 98640 | ||||||||||||||||||||||||
| 205 | sqlite3PagerUnref(pDestPg); | - | ||||||||||||||||||||||||
| 206 | } executed 98913 times by 2 tests: end of blockExecuted by:
| 98913 | ||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||
| 208 | return executed 98749 times by 2 tests: rc;return rc;Executed by:
executed 98749 times by 2 tests: return rc;Executed by:
| 98749 | ||||||||||||||||||||||||
| 209 | } | - | ||||||||||||||||||||||||
| 210 | static int backupTruncateFile(sqlite3_file *pFile, i64 iSize){ | - | ||||||||||||||||||||||||
| 211 | i64 iCurrent; | - | ||||||||||||||||||||||||
| 212 | int rc = sqlite3OsFileSize(pFile, &iCurrent); | - | ||||||||||||||||||||||||
| 213 | if( rc==0
| 0-8 | ||||||||||||||||||||||||
| 214 | rc = sqlite3OsTruncate(pFile, iSize); | - | ||||||||||||||||||||||||
| 215 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 216 | return executed 8 times by 1 test: rc;return rc;Executed by:
executed 8 times by 1 test: return rc;Executed by:
| 8 | ||||||||||||||||||||||||
| 217 | } | - | ||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | - | |||||||||||||||||||||||||
| 223 | static void attachBackupObject(sqlite3_backup *p){ | - | ||||||||||||||||||||||||
| 224 | sqlite3_backup **pp; | - | ||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||
| 226 | ((void) (0)) | - | ||||||||||||||||||||||||
| 227 | ; | - | ||||||||||||||||||||||||
| 228 | pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc)); | - | ||||||||||||||||||||||||
| 229 | p->pNext = *pp; | - | ||||||||||||||||||||||||
| 230 | *pp = p; | - | ||||||||||||||||||||||||
| 231 | p->isAttached = 1; | - | ||||||||||||||||||||||||
| 232 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||
| 237 | int sqlite3_backup_step(sqlite3_backup *p, int nPage){ | - | ||||||||||||||||||||||||
| 238 | int rc; | - | ||||||||||||||||||||||||
| 239 | int destMode; | - | ||||||||||||||||||||||||
| 240 | int pgszSrc = 0; | - | ||||||||||||||||||||||||
| 241 | int pgszDest = 0; | - | ||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||
| 246 | sqlite3_mutex_enter(p->pSrcDb->mutex); | - | ||||||||||||||||||||||||
| 247 | sqlite3BtreeEnter(p->pSrc); | - | ||||||||||||||||||||||||
| 248 | if( p->pDestDb
| 52-498 | ||||||||||||||||||||||||
| 249 | sqlite3_mutex_enter(p->pDestDb->mutex); | - | ||||||||||||||||||||||||
| 250 | } executed 52 times by 1 test: end of blockExecuted by:
| 52 | ||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | rc = p->rc; | - | ||||||||||||||||||||||||
| 253 | if( !isFatalError(rc)
| 1-549 | ||||||||||||||||||||||||
| 254 | Pager * const pSrcPager = sqlite3BtreePager(p->pSrc); | - | ||||||||||||||||||||||||
| 255 | Pager * const pDestPager = sqlite3BtreePager(p->pDest); | - | ||||||||||||||||||||||||
| 256 | int ii; | - | ||||||||||||||||||||||||
| 257 | int nSrcPage = -1; | - | ||||||||||||||||||||||||
| 258 | int bCloseTrans = 0; | - | ||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||
| 263 | if( p->pDestDb
| 2-498 | ||||||||||||||||||||||||
| 264 | rc = 5; | - | ||||||||||||||||||||||||
| 265 | } executed 2 times by 1 test: else{end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 266 | rc = 0; | - | ||||||||||||||||||||||||
| 267 | } executed 547 times by 2 tests: end of blockExecuted by:
| 547 | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||
| 272 | - | |||||||||||||||||||||||||
| 273 | if( rc==0
| 2-547 | ||||||||||||||||||||||||
| 274 | rc = sqlite3BtreeBeginTrans(p->pSrc, 0, 0); | - | ||||||||||||||||||||||||
| 275 | bCloseTrans = 1; | - | ||||||||||||||||||||||||
| 276 | } executed 49 times by 1 test: end of blockExecuted by:
| 49 | ||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||
| 284 | if( p->bDestLocked==0
| 0-540 | ||||||||||||||||||||||||
| 285 | rc = 7; | - | ||||||||||||||||||||||||
| 286 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | if( 0==rc
| 7-542 | ||||||||||||||||||||||||
| 290 | && 0==(rc = sqlite3BtreeBeginTrans(p->pDest, 2,
| 2-533 | ||||||||||||||||||||||||
| 291 | (int*)&p->iDestSchema))
| 2-533 | ||||||||||||||||||||||||
| 292 | ){ | - | ||||||||||||||||||||||||
| 293 | p->bDestLocked = 1; | - | ||||||||||||||||||||||||
| 294 | } executed 533 times by 2 tests: end of blockExecuted by:
| 533 | ||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | pgszSrc = sqlite3BtreeGetPageSize(p->pSrc); | - | ||||||||||||||||||||||||
| 299 | pgszDest = sqlite3BtreeGetPageSize(p->pDest); | - | ||||||||||||||||||||||||
| 300 | destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p->pDest)); | - | ||||||||||||||||||||||||
| 301 | if( 0==rc
| 0-540 | ||||||||||||||||||||||||
| 302 | rc = 8; | - | ||||||||||||||||||||||||
| 303 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | - | |||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||
| 308 | nSrcPage = (int)sqlite3BtreeLastPage(p->pSrc); | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | ((void) (0)) | - | ||||||||||||||||||||||||
| 311 | ; | - | ||||||||||||||||||||||||
| 312 | for(ii=0; (nPage<0
| 0-98035 | ||||||||||||||||||||||||
| 313 | const Pgno iSrcPg = p->iNext; | - | ||||||||||||||||||||||||
| 314 | if( iSrcPg!=((Pgno)((sqlite3PendingByte/((p->pSrc->pBt)->pageSize))+1))
| 202-97284 | ||||||||||||||||||||||||
| 315 | DbPage *pSrcPg; | - | ||||||||||||||||||||||||
| 316 | rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg,0x02); | - | ||||||||||||||||||||||||
| 317 | if( rc==0
| 0-97284 | ||||||||||||||||||||||||
| 318 | rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg), 0); | - | ||||||||||||||||||||||||
| 319 | sqlite3PagerUnref(pSrcPg); | - | ||||||||||||||||||||||||
| 320 | } executed 97284 times by 2 tests: end of blockExecuted by:
| 97284 | ||||||||||||||||||||||||
| 321 | } executed 97284 times by 2 tests: end of blockExecuted by:
| 97284 | ||||||||||||||||||||||||
| 322 | p->iNext++; | - | ||||||||||||||||||||||||
| 323 | } executed 97486 times by 2 tests: end of blockExecuted by:
| 97486 | ||||||||||||||||||||||||
| 324 | if( rc==0
| 265-284 | ||||||||||||||||||||||||
| 325 | p->nPagecount = nSrcPage; | - | ||||||||||||||||||||||||
| 326 | p->nRemaining = nSrcPage+1-p->iNext; | - | ||||||||||||||||||||||||
| 327 | if( p->iNext>(Pgno)nSrcPage
| 7-258 | ||||||||||||||||||||||||
| 328 | rc = 101; | - | ||||||||||||||||||||||||
| 329 | } executed 258 times by 2 tests: else if( !p->isAttachedend of blockExecuted by:
| 0-258 | ||||||||||||||||||||||||
| 330 | attachBackupObject(p); | - | ||||||||||||||||||||||||
| 331 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 332 | } executed 265 times by 2 tests: end of blockExecuted by:
| 265 | ||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||
| 339 | if( rc==101
| 258-291 | ||||||||||||||||||||||||
| 340 | if( nSrcPage==0
| 4-254 | ||||||||||||||||||||||||
| 341 | rc = sqlite3BtreeNewDb(p->pDest); | - | ||||||||||||||||||||||||
| 342 | nSrcPage = 1; | - | ||||||||||||||||||||||||
| 343 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 344 | if( rc==0
| 0-254 | ||||||||||||||||||||||||
| 345 | rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1); | - | ||||||||||||||||||||||||
| 346 | } executed 258 times by 2 tests: end of blockExecuted by:
| 258 | ||||||||||||||||||||||||
| 347 | if( rc==0
| 0-258 | ||||||||||||||||||||||||
| 348 | if( p->pDestDb
| 33-225 | ||||||||||||||||||||||||
| 349 | sqlite3ResetAllSchemasOfConnection(p->pDestDb); | - | ||||||||||||||||||||||||
| 350 | } executed 33 times by 1 test: end of blockExecuted by:
| 33 | ||||||||||||||||||||||||
| 351 | if( destMode==5
| 23-235 | ||||||||||||||||||||||||
| 352 | rc = sqlite3BtreeSetVersion(p->pDest, 2); | - | ||||||||||||||||||||||||
| 353 | } executed 23 times by 1 test: end of blockExecuted by:
| 23 | ||||||||||||||||||||||||
| 354 | } executed 258 times by 2 tests: end of blockExecuted by:
| 258 | ||||||||||||||||||||||||
| 355 | if( rc==0
| 0-258 | ||||||||||||||||||||||||
| 356 | int nDestTruncate; | - | ||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 | ((void) (0)) | - | ||||||||||||||||||||||||
| 359 | ; | - | ||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||
| 361 | ((void) (0)) | - | ||||||||||||||||||||||||
| 362 | ; | - | ||||||||||||||||||||||||
| 363 | if( pgszSrc<pgszDest
| 8-250 | ||||||||||||||||||||||||
| 364 | int ratio = pgszDest/pgszSrc; | - | ||||||||||||||||||||||||
| 365 | nDestTruncate = (nSrcPage+ratio-1)/ratio; | - | ||||||||||||||||||||||||
| 366 | if( nDestTruncate==(int)((Pgno)((sqlite3PendingByte/((p->pDest->pBt)->pageSize))+1))
| 0-8 | ||||||||||||||||||||||||
| 367 | nDestTruncate--; | - | ||||||||||||||||||||||||
| 368 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 369 | } executed 8 times by 1 test: else{end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 370 | nDestTruncate = nSrcPage * (pgszSrc/pgszDest); | - | ||||||||||||||||||||||||
| 371 | } executed 250 times by 2 tests: end of blockExecuted by:
| 250 | ||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | ((void) (0)) | - | ||||||||||||||||||||||||
| 374 | ; | - | ||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||
| 376 | if( pgszSrc<pgszDest
| 8-250 | ||||||||||||||||||||||||
| 377 | const i64 iSize = (i64)pgszSrc * (i64)nSrcPage; | - | ||||||||||||||||||||||||
| 378 | sqlite3_file * const pFile = sqlite3PagerFile(pDestPager); | - | ||||||||||||||||||||||||
| 379 | Pgno iPg; | - | ||||||||||||||||||||||||
| 380 | int nDstPage; | - | ||||||||||||||||||||||||
| 381 | i64 iOff; | - | ||||||||||||||||||||||||
| 382 | i64 iEnd; | - | ||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||
| 385 | ((void) (0)) | - | ||||||||||||||||||||||||
| 386 | ; | - | ||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||
| 388 | ((void) (0)) | - | ||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | - | |||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||
| 393 | ; | - | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | - | |||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | - | |||||||||||||||||||||||||
| 399 | - | |||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||
| 401 | sqlite3PagerPagecount(pDestPager, &nDstPage); | - | ||||||||||||||||||||||||
| 402 | for(iPg=nDestTruncate; rc==0
| 0-26 | ||||||||||||||||||||||||
| 403 | if( iPg!=((Pgno)((sqlite3PendingByte/((p->pDest->pBt)->pageSize))+1))
| 0-18 | ||||||||||||||||||||||||
| 404 | DbPage *pPg; | - | ||||||||||||||||||||||||
| 405 | rc = sqlite3PagerGet(pDestPager, iPg, &pPg, 0); | - | ||||||||||||||||||||||||
| 406 | if( rc==0
| 0-18 | ||||||||||||||||||||||||
| 407 | rc = sqlite3PagerWrite(pPg); | - | ||||||||||||||||||||||||
| 408 | sqlite3PagerUnref(pPg); | - | ||||||||||||||||||||||||
| 409 | } executed 18 times by 1 test: end of blockExecuted by:
| 18 | ||||||||||||||||||||||||
| 410 | } executed 18 times by 1 test: end of blockExecuted by:
| 18 | ||||||||||||||||||||||||
| 411 | } executed 18 times by 1 test: end of blockExecuted by:
| 18 | ||||||||||||||||||||||||
| 412 | if( rc==0
| 0-8 | ||||||||||||||||||||||||
| 413 | rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1); | - | ||||||||||||||||||||||||
| 414 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | iEnd = ((
| 0-8 | ||||||||||||||||||||||||
| 418 | for( | - | ||||||||||||||||||||||||
| 419 | iOff=sqlite3PendingByte+pgszSrc; | - | ||||||||||||||||||||||||
| 420 | rc==0
| 0-8 | ||||||||||||||||||||||||
| 421 | iOff+=pgszSrc | - | ||||||||||||||||||||||||
| 422 | ){ | - | ||||||||||||||||||||||||
| 423 | PgHdr *pSrcPg = 0; | - | ||||||||||||||||||||||||
| 424 | const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1); | - | ||||||||||||||||||||||||
| 425 | rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg, 0); | - | ||||||||||||||||||||||||
| 426 | if( rc==0
| 0 | ||||||||||||||||||||||||
| 427 | u8 *zData = sqlite3PagerGetData(pSrcPg); | - | ||||||||||||||||||||||||
| 428 | rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff); | - | ||||||||||||||||||||||||
| 429 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 430 | sqlite3PagerUnref(pSrcPg); | - | ||||||||||||||||||||||||
| 431 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 432 | if( rc==0
| 0-8 | ||||||||||||||||||||||||
| 433 | rc = backupTruncateFile(pFile, iSize); | - | ||||||||||||||||||||||||
| 434 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | if( rc==0
| 0-8 | ||||||||||||||||||||||||
| 438 | rc = sqlite3PagerSync(pDestPager, 0); | - | ||||||||||||||||||||||||
| 439 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 440 | } executed 8 times by 1 test: else{end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 441 | sqlite3PagerTruncateImage(pDestPager, nDestTruncate); | - | ||||||||||||||||||||||||
| 442 | rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0); | - | ||||||||||||||||||||||||
| 443 | } executed 250 times by 2 tests: end of blockExecuted by:
| 250 | ||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | if( 0==rc
| 95-163 | ||||||||||||||||||||||||
| 447 | && 0==(rc = sqlite3BtreeCommitPhaseTwo(p->pDest, 0))
| 0-163 | ||||||||||||||||||||||||
| 448 | ){ | - | ||||||||||||||||||||||||
| 449 | rc = 101; | - | ||||||||||||||||||||||||
| 450 | } executed 163 times by 2 tests: end of blockExecuted by:
| 163 | ||||||||||||||||||||||||
| 451 | } executed 258 times by 2 tests: end of blockExecuted by:
| 258 | ||||||||||||||||||||||||
| 452 | } executed 258 times by 2 tests: end of blockExecuted by:
| 258 | ||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | - | |||||||||||||||||||||||||
| 459 | if( bCloseTrans
| 49-500 | ||||||||||||||||||||||||
| 460 | ; | - | ||||||||||||||||||||||||
| 461 | sqlite3BtreeCommitPhaseOne(p->pSrc, 0); | - | ||||||||||||||||||||||||
| 462 | sqlite3BtreeCommitPhaseTwo(p->pSrc, 0); | - | ||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||
| 464 | ((void) (0)) | - | ||||||||||||||||||||||||
| 465 | ; | - | ||||||||||||||||||||||||
| 466 | } executed 49 times by 1 test: end of blockExecuted by:
| 49 | ||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||
| 468 | if( rc==(10 | (12<<8))
| 0-549 | ||||||||||||||||||||||||
| 469 | rc = 7; | - | ||||||||||||||||||||||||
| 470 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 471 | p->rc = rc; | - | ||||||||||||||||||||||||
| 472 | } executed 549 times by 2 tests: end of blockExecuted by:
| 549 | ||||||||||||||||||||||||
| 473 | if( p->pDestDb
| 52-498 | ||||||||||||||||||||||||
| 474 | sqlite3_mutex_leave(p->pDestDb->mutex); | - | ||||||||||||||||||||||||
| 475 | } executed 52 times by 1 test: end of blockExecuted by:
| 52 | ||||||||||||||||||||||||
| 476 | sqlite3BtreeLeave(p->pSrc); | - | ||||||||||||||||||||||||
| 477 | sqlite3_mutex_leave(p->pSrcDb->mutex); | - | ||||||||||||||||||||||||
| 478 | return executed 550 times by 2 tests: rc;return rc;Executed by:
executed 550 times by 2 tests: return rc;Executed by:
| 550 | ||||||||||||||||||||||||
| 479 | } | - | ||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | - | |||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||
| 484 | int sqlite3_backup_finish(sqlite3_backup *p){ | - | ||||||||||||||||||||||||
| 485 | sqlite3_backup **pp; | - | ||||||||||||||||||||||||
| 486 | sqlite3 *pSrcDb; | - | ||||||||||||||||||||||||
| 487 | int rc; | - | ||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||
| 489 | - | |||||||||||||||||||||||||
| 490 | if( p==0
never executed: 0;return 0;never executed: return 0; | 0-537 | ||||||||||||||||||||||||
| 491 | pSrcDb = p->pSrcDb; | - | ||||||||||||||||||||||||
| 492 | sqlite3_mutex_enter(pSrcDb->mutex); | - | ||||||||||||||||||||||||
| 493 | sqlite3BtreeEnter(p->pSrc); | - | ||||||||||||||||||||||||
| 494 | if( p->pDestDb
| 39-498 | ||||||||||||||||||||||||
| 495 | sqlite3_mutex_enter(p->pDestDb->mutex); | - | ||||||||||||||||||||||||
| 496 | } executed 39 times by 1 test: end of blockExecuted by:
| 39 | ||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||
| 499 | if( p->pDestDb
| 39-498 | ||||||||||||||||||||||||
| 500 | p->pSrc->nBackup--; | - | ||||||||||||||||||||||||
| 501 | } executed 39 times by 1 test: end of blockExecuted by:
| 39 | ||||||||||||||||||||||||
| 502 | if( p->isAttached
| 7-530 | ||||||||||||||||||||||||
| 503 | pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc)); | - | ||||||||||||||||||||||||
| 504 | while( *
| 0-7 | ||||||||||||||||||||||||
| 505 | pp = &(*pp)->pNext; | - | ||||||||||||||||||||||||
| 506 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 507 | *pp = p->pNext; | - | ||||||||||||||||||||||||
| 508 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 509 | - | |||||||||||||||||||||||||
| 510 | - | |||||||||||||||||||||||||
| 511 | sqlite3BtreeRollback(p->pDest, 0, 0); | - | ||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | rc = (
| 163-374 | ||||||||||||||||||||||||
| 515 | if( p->pDestDb
| 39-498 | ||||||||||||||||||||||||
| 516 | sqlite3Error(p->pDestDb, rc); | - | ||||||||||||||||||||||||
| 517 | - | |||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | sqlite3LeaveMutexAndCloseZombie(p->pDestDb); | - | ||||||||||||||||||||||||
| 520 | } executed 39 times by 1 test: end of blockExecuted by:
| 39 | ||||||||||||||||||||||||
| 521 | sqlite3BtreeLeave(p->pSrc); | - | ||||||||||||||||||||||||
| 522 | if( p->pDestDb
| 39-498 | ||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||
| 525 | - | |||||||||||||||||||||||||
| 526 | sqlite3_free(p); | - | ||||||||||||||||||||||||
| 527 | } executed 39 times by 1 test: end of blockExecuted by:
| 39 | ||||||||||||||||||||||||
| 528 | sqlite3LeaveMutexAndCloseZombie(pSrcDb); | - | ||||||||||||||||||||||||
| 529 | return executed 537 times by 2 tests: rc;return rc;Executed by:
executed 537 times by 2 tests: return rc;Executed by:
| 537 | ||||||||||||||||||||||||
| 530 | } | - | ||||||||||||||||||||||||
| 531 | - | |||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | int sqlite3_backup_remaining(sqlite3_backup *p){ | - | ||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||
| 539 | - | |||||||||||||||||||||||||
| 540 | - | |||||||||||||||||||||||||
| 541 | - | |||||||||||||||||||||||||
| 542 | - | |||||||||||||||||||||||||
| 543 | return never executed: p->nRemaining;return p->nRemaining;never executed: return p->nRemaining; | 0 | ||||||||||||||||||||||||
| 544 | } | - | ||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||
| 548 | - | |||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||
| 550 | int sqlite3_backup_pagecount(sqlite3_backup *p){ | - | ||||||||||||||||||||||||
| 551 | - | |||||||||||||||||||||||||
| 552 | - | |||||||||||||||||||||||||
| 553 | - | |||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||
| 555 | - | |||||||||||||||||||||||||
| 556 | - | |||||||||||||||||||||||||
| 557 | return never executed: p->nPagecount;return p->nPagecount;never executed: return p->nPagecount; | 0 | ||||||||||||||||||||||||
| 558 | } | - | ||||||||||||||||||||||||
| 559 | static __attribute__((noinline)) void backupUpdate( | - | ||||||||||||||||||||||||
| 560 | sqlite3_backup *p, | - | ||||||||||||||||||||||||
| 561 | Pgno iPage, | - | ||||||||||||||||||||||||
| 562 | const u8 *aData | - | ||||||||||||||||||||||||
| 563 | ){ | - | ||||||||||||||||||||||||
| 564 | - | |||||||||||||||||||||||||
| 565 | ((void) (0)) | - | ||||||||||||||||||||||||
| 566 | ; | - | ||||||||||||||||||||||||
| 567 | do{ | - | ||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||
| 569 | ((void) (0)) | - | ||||||||||||||||||||||||
| 570 | ; | - | ||||||||||||||||||||||||
| 571 | if( !isFatalError(p->rc)
| 0-2541 | ||||||||||||||||||||||||
| 572 | - | |||||||||||||||||||||||||
| 573 | - | |||||||||||||||||||||||||
| 574 | - | |||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||
| 576 | int rc; | - | ||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||
| 578 | ((void) (0)) | - | ||||||||||||||||||||||||
| 579 | ; | - | ||||||||||||||||||||||||
| 580 | sqlite3_mutex_enter(p->pDestDb->mutex); | - | ||||||||||||||||||||||||
| 581 | rc = backupOnePage(p, iPage, aData, 1); | - | ||||||||||||||||||||||||
| 582 | sqlite3_mutex_leave(p->pDestDb->mutex); | - | ||||||||||||||||||||||||
| 583 | - | |||||||||||||||||||||||||
| 584 | ((void) (0)) | - | ||||||||||||||||||||||||
| 585 | ; | - | ||||||||||||||||||||||||
| 586 | if( rc!=0
| 0-1465 | ||||||||||||||||||||||||
| 587 | p->rc = rc; | - | ||||||||||||||||||||||||
| 588 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 589 | } executed 1465 times by 1 test: end of blockExecuted by:
| 1465 | ||||||||||||||||||||||||
| 590 | } executed 2541 times by 1 test: while( (end of blockExecuted by:
| 0-2541 | ||||||||||||||||||||||||
| 591 | } executed 2541 times by 1 test: end of blockExecuted by:
| 2541 | ||||||||||||||||||||||||
| 592 | void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){ | - | ||||||||||||||||||||||||
| 593 | if( pBackup
executed 2541 times by 1 test: backupUpdate(pBackup, iPage, aData);Executed by:
| 2541-1492489 | ||||||||||||||||||||||||
| 594 | } executed 1495030 times by 131 tests: end of blockExecuted by:
| 1495030 | ||||||||||||||||||||||||
| 595 | void sqlite3BackupRestart(sqlite3_backup *pBackup){ | - | ||||||||||||||||||||||||
| 596 | sqlite3_backup *p; | - | ||||||||||||||||||||||||
| 597 | for(p=pBackup; p
| 64-205694 | ||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||
| 599 | ((void) (0)) | - | ||||||||||||||||||||||||
| 600 | ; | - | ||||||||||||||||||||||||
| 601 | p->iNext = 1; | - | ||||||||||||||||||||||||
| 602 | } executed 64 times by 1 test: end of blockExecuted by:
| 64 | ||||||||||||||||||||||||
| 603 | } executed 205694 times by 438 tests: end of blockExecuted by:
| 205694 | ||||||||||||||||||||||||
| 604 | int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ | - | ||||||||||||||||||||||||
| 605 | int rc; | - | ||||||||||||||||||||||||
| 606 | sqlite3_file *pFd; | - | ||||||||||||||||||||||||
| 607 | sqlite3_backup b; | - | ||||||||||||||||||||||||
| 608 | sqlite3BtreeEnter(pTo); | - | ||||||||||||||||||||||||
| 609 | sqlite3BtreeEnter(pFrom); | - | ||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||
| 612 | ((void) (0)) | - | ||||||||||||||||||||||||
| 613 | ; | - | ||||||||||||||||||||||||
| 614 | pFd = sqlite3PagerFile(sqlite3BtreePager(pTo)); | - | ||||||||||||||||||||||||
| 615 | if( pFd->pMethods
| 6-492 | ||||||||||||||||||||||||
| 616 | i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom); | - | ||||||||||||||||||||||||
| 617 | rc = sqlite3OsFileControl(pFd, 11, &nByte); | - | ||||||||||||||||||||||||
| 618 | if( rc==12
executed 492 times by 2 tests: rc = 0;Executed by:
| 0-492 | ||||||||||||||||||||||||
| 619 | if( rc
never executed: copy_finished;goto copy_finished;never executed: goto copy_finished; | 0-492 | ||||||||||||||||||||||||
| 620 | } executed 492 times by 2 tests: end of blockExecuted by:
| 492 | ||||||||||||||||||||||||
| 621 | - | |||||||||||||||||||||||||
| 622 | - | |||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||
| 624 | - | |||||||||||||||||||||||||
| 625 | - | |||||||||||||||||||||||||
| 626 | - | |||||||||||||||||||||||||
| 627 | memset(&b, 0, sizeof(b)); | - | ||||||||||||||||||||||||
| 628 | b.pSrcDb = pFrom->db; | - | ||||||||||||||||||||||||
| 629 | b.pSrc = pFrom; | - | ||||||||||||||||||||||||
| 630 | b.pDest = pTo; | - | ||||||||||||||||||||||||
| 631 | b.iNext = 1; | - | ||||||||||||||||||||||||
| 632 | sqlite3_backup_step(&b, 0x7FFFFFFF); | - | ||||||||||||||||||||||||
| 633 | - | |||||||||||||||||||||||||
| 634 | ((void) (0)) | - | ||||||||||||||||||||||||
| 635 | ; | - | ||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||
| 637 | rc = sqlite3_backup_finish(&b); | - | ||||||||||||||||||||||||
| 638 | if( rc==0
| 130-368 | ||||||||||||||||||||||||
| 639 | pTo->pBt->btsFlags &= ~0x0002; | - | ||||||||||||||||||||||||
| 640 | } executed 130 times by 2 tests: else{end of blockExecuted by:
| 130 | ||||||||||||||||||||||||
| 641 | sqlite3PagerClearCache(sqlite3BtreePager(b.pDest)); | - | ||||||||||||||||||||||||
| 642 | } executed 368 times by 1 test: end of blockExecuted by:
| 368 | ||||||||||||||||||||||||
| 643 | - | |||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||
| 645 | ((void) (0)) | - | ||||||||||||||||||||||||
| 646 | ; | - | ||||||||||||||||||||||||
| 647 | copy_finished: code before this statement executed 498 times by 2 tests: copy_finished:Executed by:
| 498 | ||||||||||||||||||||||||
| 648 | sqlite3BtreeLeave(pFrom); | - | ||||||||||||||||||||||||
| 649 | sqlite3BtreeLeave(pTo); | - | ||||||||||||||||||||||||
| 650 | return executed 498 times by 2 tests: rc;return rc;Executed by:
executed 498 times by 2 tests: return rc;Executed by:
| 498 | ||||||||||||||||||||||||
| 651 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |