Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix harmless compiler warnings in the zonefile extension seen with MSVC. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | zonefile |
Files: | files | file ages | folders |
SHA3-256: |
d28003941ceca7fb707fcdb09bf8b00a |
User & Date: | mistachkin 2018-02-23 14:00:38.536 |
Context
2018-02-23
| ||
14:02 | Fix a problem with DROP TABLE statements on zonefile virtual tables. (check-in: d2ed6910b8 user: dan tags: zonefile) | |
14:00 | Fix harmless compiler warnings in the zonefile extension seen with MSVC. (check-in: d28003941c user: mistachkin tags: zonefile) | |
13:58 | Avoid running a test case that requires zstd in non-SQLITE_HAVE_ZSTD builds. (check-in: d716dff444 user: dan tags: zonefile) | |
Changes
Changes to Makefile.msc.
︙ | ︙ | |||
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 | $(TOP)\ext\misc\amatch.c \ $(TOP)\ext\misc\carray.c \ $(TOP)\ext\misc\closure.c \ $(TOP)\ext\misc\csv.c \ $(TOP)\ext\misc\eval.c \ $(TOP)\ext\misc\fileio.c \ $(TOP)\ext\misc\fuzzer.c \ $(TOP)\ext\fts5\fts5_tcl.c \ $(TOP)\ext\fts5\fts5_test_mi.c \ $(TOP)\ext\fts5\fts5_test_tok.c \ $(TOP)\ext\misc\ieee754.c \ $(TOP)\ext\misc\mmapwarm.c \ $(TOP)\ext\misc\nextchar.c \ $(TOP)\ext\misc\normalize.c \ | > | 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 | $(TOP)\ext\misc\amatch.c \ $(TOP)\ext\misc\carray.c \ $(TOP)\ext\misc\closure.c \ $(TOP)\ext\misc\csv.c \ $(TOP)\ext\misc\eval.c \ $(TOP)\ext\misc\fileio.c \ $(TOP)\ext\misc\fuzzer.c \ $(TOP)\ext\zonefile\zonefile.c \ $(TOP)\ext\fts5\fts5_tcl.c \ $(TOP)\ext\fts5\fts5_test_mi.c \ $(TOP)\ext\fts5\fts5_test_tok.c \ $(TOP)\ext\misc\ieee754.c \ $(TOP)\ext\misc\mmapwarm.c \ $(TOP)\ext\misc\nextchar.c \ $(TOP)\ext\misc\normalize.c \ |
︙ | ︙ |
Changes to ext/zonefile/zonefile.c.
︙ | ︙ | |||
998 999 1000 1001 1002 1003 1004 | static void zonefileAppendBlob(ZonefileBuffer *pBuf, const u8 *p, int n){ memcpy(&pBuf->a[pBuf->n], p, n); pBuf->n += n; } static int zonefileFileWrite(FILE *pFd, const u8 *aBuf, int nBuf){ size_t res = fwrite(aBuf, 1, nBuf, pFd); | | | | 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 | static void zonefileAppendBlob(ZonefileBuffer *pBuf, const u8 *p, int n){ memcpy(&pBuf->a[pBuf->n], p, n); pBuf->n += n; } static int zonefileFileWrite(FILE *pFd, const u8 *aBuf, int nBuf){ size_t res = fwrite(aBuf, 1, nBuf, pFd); return res!=(size_t)nBuf ? SQLITE_ERROR : SQLITE_OK; } static int zonefileFileRead(FILE *pFd, u8 *aBuf, int nBuf, i64 iOff){ int rc = fseek(pFd, (long)iOff, SEEK_SET); if( rc==0 ){ rc = fread(aBuf, 1, nBuf, pFd); rc = (rc==nBuf) ? SQLITE_OK : SQLITE_ERROR; } return rc; } |
︙ | ︙ | |||
1072 1073 1074 1075 1076 1077 1078 | ** Parameter nByte is only ever non-zero when running tests. So it doesn't ** matter if this function is inefficient in those cases. */ static int zonefilePad(FILE *pFd, int nByte){ assert( nByte>=0 && nByte<256 ); if( nByte ){ int nRem = nByte; | | | 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | ** Parameter nByte is only ever non-zero when running tests. So it doesn't ** matter if this function is inefficient in those cases. */ static int zonefilePad(FILE *pFd, int nByte){ assert( nByte>=0 && nByte<256 ); if( nByte ){ int nRem = nByte; u8 buf[17] = "0123456789ABCDEF"; while( nRem>0 ){ int n = MIN(nRem, sizeof(buf)); if( zonefileFileWrite(pFd, buf, n) ) return SQLITE_ERROR; nRem -= n; } } return SQLITE_OK; |
︙ | ︙ | |||
1098 1099 1100 1101 1102 1103 1104 | const char *zTbl = 0; /* Database object to read from */ const char *zJson = 0; /* JSON configuration parameters */ ZonefileParam sParam; /* Decoded JSON parameters */ int nKey = 0; /* Number of keys in new zonefile */ int nFrame = 0; /* Number of frames in new zonefile */ sqlite3_stmt *pStmt = 0; /* SQL used to read data from source table */ FILE *pFd = 0; | | | 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 | const char *zTbl = 0; /* Database object to read from */ const char *zJson = 0; /* JSON configuration parameters */ ZonefileParam sParam; /* Decoded JSON parameters */ int nKey = 0; /* Number of keys in new zonefile */ int nFrame = 0; /* Number of frames in new zonefile */ sqlite3_stmt *pStmt = 0; /* SQL used to read data from source table */ FILE *pFd = 0; int rc = SQLITE_OK; sqlite3_value *pPrev = 0; char *zErr = 0; void *pCmp = 0; /* Data compressor handle */ u32 iOff; ZonefileCodec *pCodec = 0; ZonefileBuffer sFrameIdx = {0, 0, 0}; /* Array of frame offsets */ |
︙ | ︙ | |||
1291 1292 1293 1294 1295 1296 1297 | sFrameIdx.n = 0; if( rc ) goto zone_write_out; } /* Create the zonefile header in the in-memory buffer */ memset(aHdr, 0, ZONEFILE_SZ_HEADER); zonefilePut32(&aHdr[0], ZONEFILE_MAGIC_NUMBER); | | | | | | 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 | sFrameIdx.n = 0; if( rc ) goto zone_write_out; } /* Create the zonefile header in the in-memory buffer */ memset(aHdr, 0, ZONEFILE_SZ_HEADER); zonefilePut32(&aHdr[0], ZONEFILE_MAGIC_NUMBER); aHdr[4] = (u8)sParam.pCmpIdx->eType; aHdr[5] = (u8)sParam.pCmpData->eType; iOff = ZONEFILE_SZ_HEADER + sFrameIdx.n + sKeyIdx.n; zonefilePut32(&aHdr[6], sDict.n ? iOff+sParam.debugExtendedHeaderSize : 0); zonefilePut32(&aHdr[10], iOff + sParam.debugExtendedHeaderSize + sDict.n); zonefilePut32(&aHdr[14], nFrame); zonefilePut32(&aHdr[18], nKey); aHdr[22] = (u8)sParam.encryptionType; aHdr[23] = 0; /* Encryption key index */ aHdr[24] = 0; /* extended header version */ aHdr[25] = (u8)sParam.debugExtendedHeaderSize; assert( ZONEFILE_SZ_HEADER>=26 ); rc = zonefileFileWrite(pFd, aHdr, ZONEFILE_SZ_HEADER); if( rc==SQLITE_OK ) rc = zonefilePad(pFd, sParam.debugExtendedHeaderSize); if( rc==SQLITE_OK ) rc = zonefileFileWrite(pFd, sFrameIdx.a, sFrameIdx.n); if( rc==SQLITE_OK ) rc = zonefileFileWrite(pFd, sKeyIdx.a, sKeyIdx.n); if( rc==SQLITE_OK ) rc = zonefileFileWrite(pFd, sDict.a, sDict.n); |
︙ | ︙ | |||
1550 1551 1552 1553 1554 1555 1556 | } static void zonefileJsonHeader(sqlite3_context *pCtx, const char *zFile){ char *zErr = 0; FILE *pFd = zonefileFileOpen(zFile, 0, &zErr); if( pFd ){ int rc; | | | 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 | } static void zonefileJsonHeader(sqlite3_context *pCtx, const char *zFile){ char *zErr = 0; FILE *pFd = zonefileFileOpen(zFile, 0, &zErr); if( pFd ){ int rc; ZonefileHeader hdr = { 0 }; u8 aBuf[ZONEFILE_SZ_HEADER]; rc = zonefileFileRead(pFd, aBuf, ZONEFILE_SZ_HEADER, 0); if( rc==SQLITE_OK ){ zonefileHeaderDeserialize(aBuf, &hdr); } |
︙ | ︙ | |||
1763 1764 1765 1766 1767 1768 1769 | static int zonefilePopulateIndex( ZonefileFilesTab *pTab, const char *zFile, i64 iFileid ){ | | | 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 | static int zonefilePopulateIndex( ZonefileFilesTab *pTab, const char *zFile, i64 iFileid ){ ZonefileHeader hdr = { 0 }; int rc; FILE *pFd = zonefileFileOpen(zFile, 0, &pTab->base.zErrMsg); if( pFd==0 ){ rc = SQLITE_ERROR; }else{ rc = zonefileReadHeader(pFd, zFile, &hdr, &pTab->base.zErrMsg); |
︙ | ︙ | |||
1788 1789 1790 1791 1792 1793 1794 | rc = zonefilePrepare(pTab->db, &pTab->pInsertIdx, &pTab->base.zErrMsg, "INSERT INTO %Q.'%q_shadow_idx'(k, fileid, fofst, fsz, ofst, sz)" "VALUES(?,?,?,?,?,?)", pTab->zDb, pTab->zBase ); } | | | | 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 | rc = zonefilePrepare(pTab->db, &pTab->pInsertIdx, &pTab->base.zErrMsg, "INSERT INTO %Q.'%q_shadow_idx'(k, fileid, fofst, fsz, ofst, sz)" "VALUES(?,?,?,?,?,?)", pTab->zDb, pTab->zBase ); } for(i=0; (u32)i<hdr.numKeys && rc==SQLITE_OK; i++){ u8 *aEntry = &aKey[4*hdr.numFrames + ZONEFILE_SZ_KEYOFFSETS_ENTRY * i]; int iFrame = zonefileGet32(&aEntry[8]); i64 iFrameOff = 0; /* Offset of frame */ int szFrame; /* Compressed size of frame */ i64 iOff; /* Offset of blob within uncompressed frame */ int sz; /* Size of blob within uncompressed frame */ szFrame = zonefileGet32(&aKey[iFrame*4]); if( iFrame>0 ){ iFrameOff = zonefileGet32(&aKey[(iFrame-1)*4]); szFrame -= (int)iFrameOff; } iFrameOff += hdr.byteOffsetFrames; iOff = (i64)zonefileGet32(&aEntry[12]); sz = (int)zonefileGet32(&aEntry[16]); sqlite3_bind_int64(pTab->pInsertIdx, 1, (i64)zonefileGet64(&aEntry[0])); sqlite3_bind_int64(pTab->pInsertIdx, 2, iFileid); |
︙ | ︙ | |||
2533 2534 2535 2536 2537 2538 2539 | static int zonefileValueReadCache(sqlite3_context *pCtx, ZonefileCsr *pCsr){ int rc = SQLITE_OK; ZonefileTab *pTab = (ZonefileTab*)pCsr->base.pVtab; ZonefileFrame *pFrame = 0; i64 iFile = sqlite3_column_int64(pCsr->pSelect, 1); i64 iFrameOff = sqlite3_column_int64(pCsr->pSelect, 2); i64 iKeyOff = sqlite3_column_int64(pCsr->pSelect, 4); | | | | 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 | static int zonefileValueReadCache(sqlite3_context *pCtx, ZonefileCsr *pCsr){ int rc = SQLITE_OK; ZonefileTab *pTab = (ZonefileTab*)pCsr->base.pVtab; ZonefileFrame *pFrame = 0; i64 iFile = sqlite3_column_int64(pCsr->pSelect, 1); i64 iFrameOff = sqlite3_column_int64(pCsr->pSelect, 2); i64 iKeyOff = sqlite3_column_int64(pCsr->pSelect, 4); int nKeySz = sqlite3_column_int(pCsr->pSelect, 5); /* Check if this frame is already in the cache. If not, read it from ** the file. */ pFrame = zonefileCacheFind(pTab, iFile, iFrameOff); if( pFrame==0 ){ const char *zFile = 0; char *zErr = 0; FILE *pFd = 0; ZonefileHeader hdr = { 0 }; ZonefileCompress *pCmpMethod = 0; ZonefileCodec *pCodec = 0; void *pCmp = 0; /* Open the file to read the blob from */ rc = zonefileGetFile(pCtx, pCsr, &zFile); if( rc==SQLITE_OK ){ |
︙ | ︙ |