Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Adjust copy_file() lsmtest function so it works properly for locked database files on Win32. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
54a3855583deac93c955ed77fe82be6a |
User & Date: | mistachkin 2017-07-07 20:35:14.495 |
Context
2017-07-07
| ||
21:15 | For lsmtest, use a more portable means of setting open() files to binary. (check-in: aea6e0ffd3 user: mistachkin tags: trunk) | |
20:35 | Adjust copy_file() lsmtest function so it works properly for locked database files on Win32. (check-in: 54a3855583 user: mistachkin tags: trunk) | |
20:06 | Add the "PRAGMA secure_delete=FAST" option, which overwrites most deleted content without increasing the amount of I/O. Deleted content might persist on the free page list, however. And extra CPU cycles are used for zeroing, of course. (check-in: 38978ce65b user: drh tags: trunk) | |
Changes
Changes to ext/lsm1/lsm-test/lsmtest6.c.
︙ | ︙ | |||
253 254 255 256 257 258 259 | unlink(zFile); unlink(zLog); unlink(zShm); testFree(zLog); testFree(zShm); } | | > | > > > > > | | | | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | unlink(zFile); unlink(zLog); unlink(zShm); testFree(zLog); testFree(zShm); } static void copy_file(const char *zFrom, const char *zTo, int isDatabase){ if( access(zFrom, F_OK) ){ unlink(zTo); }else{ int fd1; int fd2; off_t sz; off_t i; struct stat buf; u8 *aBuf; fd1 = open(zFrom, O_RDONLY, 0644); fd2 = open(zTo, O_RDWR | O_CREAT, 0644); fstat(fd1, &buf); sz = buf.st_size; ftruncate(fd2, sz); aBuf = testMalloc(4096); for(i=0; i<sz; i+=4096){ int bLockPage = isDatabase && i == 0; int nByte = MIN((bLockPage ? 4066 : 4096), sz - i); memset(aBuf, 0, 4096); read(fd1, aBuf, nByte); write(fd2, aBuf, nByte); if( bLockPage ){ lseek(fd1, 4096, SEEK_SET); lseek(fd2, 4096, SEEK_SET); } } testFree(aBuf); close(fd1); close(fd2); } } void testCopyLsmdb(const char *zFrom, const char *zTo){ char *zLog1 = testMallocPrintf("%s-log", zFrom); char *zLog2 = testMallocPrintf("%s-log", zTo); char *zShm1 = testMallocPrintf("%s-shm", zFrom); char *zShm2 = testMallocPrintf("%s-shm", zTo); unlink(zShm2); unlink(zLog2); unlink(zTo); copy_file(zFrom, zTo, 1); copy_file(zLog1, zLog2, 0); copy_file(zShm1, zShm2, 0); testFree(zLog1); testFree(zLog2); testFree(zShm1); testFree(zShm2); } /* ** File zFile is the path to a database. This function makes backups ** of the database file and its log as follows: |
︙ | ︙ | |||
318 319 320 321 322 323 324 | void testSaveDb(const char *zFile, const char *zAux){ char *zLog = testMallocPrintf("%s-%s", zFile, zAux); char *zFileSave = testMallocPrintf("%s-save", zFile); char *zLogSave = testMallocPrintf("%s-%s-save", zFile, zAux); unlink(zFileSave); unlink(zLogSave); | | | | | | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | void testSaveDb(const char *zFile, const char *zAux){ char *zLog = testMallocPrintf("%s-%s", zFile, zAux); char *zFileSave = testMallocPrintf("%s-save", zFile); char *zLogSave = testMallocPrintf("%s-%s-save", zFile, zAux); unlink(zFileSave); unlink(zLogSave); copy_file(zFile, zFileSave, 1); copy_file(zLog, zLogSave, 0); testFree(zLog); testFree(zFileSave); testFree(zLogSave); } /* ** File zFile is the path to a database. This function restores ** a backup of the database made by a previous call to testSaveDb(). ** Specifically, it does the equivalent of: ** ** cp $(zFile)-save $(zFile) ** cp $(zFile)-save-$(zAux) $(zFile)-$(zAux) */ void testRestoreDb(const char *zFile, const char *zAux){ char *zLog = testMallocPrintf("%s-%s", zFile, zAux); char *zFileSave = testMallocPrintf("%s-save", zFile); char *zLogSave = testMallocPrintf("%s-%s-save", zFile, zAux); copy_file(zFileSave, zFile, 1); copy_file(zLogSave, zLog, 0); testFree(zLog); testFree(zFileSave); testFree(zLogSave); } static int lsmWriteStr(lsm_db *pDb, const char *zKey, const char *zVal){ int nKey = strlen(zKey); |
︙ | ︙ |
Changes to ext/lsm1/lsm-test/lsmtest_main.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include "stdarg.h" #include "lsmtest.h" #include "stdio.h" #include "assert.h" #include "string.h" #include "stdlib.h" #include <sqlite3.h> #ifndef _WIN32 # include <unistd.h> #endif #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> void test_failed(){ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include "stdarg.h" #include "lsmtest.h" #include "stdio.h" #include "assert.h" #include "string.h" #include "stdlib.h" #include <sqlite3.h> #ifndef _WIN32 # include <unistd.h> #endif #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> void test_failed(){ |
︙ | ︙ | |||
1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 | #ifdef LSM_DEBUG_MEM FILE *pReport = 0; /* lsm malloc() report file */ const char *zReport = "malloc.txt generated"; #else const char *zReport = "malloc.txt NOT generated"; #endif testMallocInstall(tdb_lsm_env()); if( argc<2 ){ testPrintError("Usage: %s sub-command ?args...?\n", argv[0]); return -1; } | > > > > | 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 | #ifdef LSM_DEBUG_MEM FILE *pReport = 0; /* lsm malloc() report file */ const char *zReport = "malloc.txt generated"; #else const char *zReport = "malloc.txt NOT generated"; #endif #if defined(_MSC_VER) || defined(__MSVCRT__) _set_fmode(_O_BINARY); #endif testMallocInstall(tdb_lsm_env()); if( argc<2 ){ testPrintError("Usage: %s sub-command ?args...?\n", argv[0]); return -1; } |
︙ | ︙ |