Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update the code in test_delete.c to use the "win32" VFS if SQLITE_OS_WIN is defined. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
fa9bb7b768027677f7e7d5a196ba5b24 |
User & Date: | dan 2017-04-13 15:36:47.128 |
Context
2017-04-13
| ||
15:51 | Reinstate the SQLITE_API qualifier on the sqlite3_delete_database() method in test_delete.c. Accidentally removed by the previous commit. (check-in: 59c70108fd user: dan tags: trunk) | |
15:36 | Update the code in test_delete.c to use the "win32" VFS if SQLITE_OS_WIN is defined. (check-in: fa9bb7b768 user: dan tags: trunk) | |
09:45 | Allow a user column name to be used on the LHS of a MATCH operator in FTS5. (check-in: 6f54ffd151 user: dan tags: trunk) | |
Changes
Changes to src/test_delete.c.
︙ | ︙ | |||
15 16 17 18 19 20 21 | ** * The journal file. ** * The wal file. ** * The SQLITE_ENABLE_8_3_NAMES version of the db, journal or wal files. ** * Files created by the test_multiplex.c module to extend any of the ** above. */ | | | < < | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ** * The journal file. ** * The wal file. ** * The SQLITE_ENABLE_8_3_NAMES version of the db, journal or wal files. ** * Files created by the test_multiplex.c module to extend any of the ** above. */ #ifndef SQLITE_OS_WIN # include <unistd.h> # include <errno.h> #endif #include <string.h> #include <assert.h> #include "sqlite3.h" /* The following #defines are copied from test_multiplex.c */ #ifndef MX_CHUNK_NUMBER # define MX_CHUNK_NUMBER 299 #endif #ifndef SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET |
︙ | ︙ | |||
53 54 55 56 57 58 59 | } /* ** zFile is a filename. Assuming no error occurs, if this file exists, ** set *pbExists to true and unlink it. Or, if the file does not exist, ** set *pbExists to false before returning. ** | | < | > > > > | > > > > > > > > > > > < > < | | | > | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | } /* ** zFile is a filename. Assuming no error occurs, if this file exists, ** set *pbExists to true and unlink it. Or, if the file does not exist, ** set *pbExists to false before returning. ** ** If an error occurs, non-zero is returned. Or, if no error occurs, zero. */ static int sqlite3DeleteUnlinkIfExists( sqlite3_vfs *pVfs, const char *zFile, int *pbExists ){ int rc = SQLITE_ERROR; #if SQLITE_OS_WIN if( pVfs ){ if( pbExists ) *pbExists = 1; rc = pVfs->xDelete(pVfs, zFile, 0); if( rc==SQLITE_IOERR_DELETE_NOENT ){ if( pbExists ) *pbExists = 0; rc = SQLITE_OK; } } #else assert( pVfs==0 ); rc = access(zFile, F_OK); if( rc ){ if( errno==ENOENT ){ if( pbExists ) *pbExists = 0; rc = SQLITE_OK; } }else{ if( pbExists ) *pbExists = 1; rc = unlink(zFile); } #endif return rc; } /* ** Delete the database file identified by the string argument passed to this ** function. The string must contain a filename, not an SQLite URI. */ int sqlite3_delete_database( const char *zFile /* File to delete */ ){ char *zBuf; /* Buffer to sprintf() filenames to */ int nBuf; /* Size of buffer in bytes */ int rc = 0; /* System error code */ int i; /* Iterate through azFmt[] and aMFile[] */ |
︙ | ︙ | |||
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | { "%s%03d", 0, 0 }, { "%s-journal%03d", 0, 0 }, { "%s-wal%03d", 0, 0 }, { "%s%03d", 0, 1 }, { "%s-journal%03d", SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET, 1 }, { "%s-wal%03d", SQLITE_MULTIPLEX_WAL_8_3_OFFSET, 1 }, }; /* Allocate a buffer large enough for any of the files that need to be ** deleted. */ nBuf = (int)strlen(zFile) + 100; zBuf = (char*)sqlite3_malloc(nBuf); if( zBuf==0 ) return SQLITE_NOMEM; /* Delete both the regular and 8.3 filenames versions of the database, ** journal, wal and shm files. */ for(i=0; rc==0 && i<sizeof(azFmt)/sizeof(azFmt[0]); i++){ sqlite3_snprintf(nBuf, zBuf, azFmt[i], zFile); | > > > > > > | | | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | { "%s%03d", 0, 0 }, { "%s-journal%03d", 0, 0 }, { "%s-wal%03d", 0, 0 }, { "%s%03d", 0, 1 }, { "%s-journal%03d", SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET, 1 }, { "%s-wal%03d", SQLITE_MULTIPLEX_WAL_8_3_OFFSET, 1 }, }; #ifdef SQLITE_OS_WIN sqlite3_vfs *pVfs = sqlite3_vfs_find("win32"); #else sqlite3_vfs *pVfs = 0; #endif /* Allocate a buffer large enough for any of the files that need to be ** deleted. */ nBuf = (int)strlen(zFile) + 100; zBuf = (char*)sqlite3_malloc(nBuf); if( zBuf==0 ) return SQLITE_NOMEM; /* Delete both the regular and 8.3 filenames versions of the database, ** journal, wal and shm files. */ for(i=0; rc==0 && i<sizeof(azFmt)/sizeof(azFmt[0]); i++){ sqlite3_snprintf(nBuf, zBuf, azFmt[i], zFile); rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, 0); if( rc==0 && i!=0 ){ sqlite3Delete83Name(zBuf); rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, 0); } } /* Delete any multiplexor files */ for(i=0; rc==0 && i<sizeof(aMFile)/sizeof(aMFile[0]); i++){ struct MFile *p = &aMFile[i]; int iChunk; for(iChunk=1; iChunk<=MX_CHUNK_NUMBER; iChunk++){ int bExists; sqlite3_snprintf(nBuf, zBuf, p->zFmt, zFile, iChunk+p->iOffset); if( p->b83 ) sqlite3Delete83Name(zBuf); rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, &bExists); if( bExists==0 || rc!=0 ) break; } } sqlite3_free(zBuf); return (rc ? SQLITE_ERROR : SQLITE_OK); } |