Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix handling of maxAutoFrameSize parameter. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | zonefile |
Files: | files | file ages | folders |
SHA3-256: |
d65e5855743534cb8db0d77d107579ea |
User & Date: | dan 2018-02-13 20:08:47.555 |
Context
2018-02-13
| ||
20:53 | Note the fact that zonefile depends on json1 in ext/zonefile/README.md. (check-in: fb27d8f6a8 user: dan tags: zonefile) | |
20:08 | Fix handling of maxAutoFrameSize parameter. (check-in: d65e585574 user: dan tags: zonefile) | |
19:01 | Enhance ext/zonefile/README.md to describe the currently available functionality. (check-in: 100137c7f6 user: dan tags: zonefile) | |
Changes
Changes to ext/zonefile/README.md.
︙ | ︙ | |||
27 28 29 30 31 32 33 | where <file> is the name of the file to create on disk, <table> is the name of the database table to read and optional argument <parameters> is a JSON object containing various attributes that influence creation of the zonefile file. Currently the only <parameters> attribute supported is | | | > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | where <file> is the name of the file to create on disk, <table> is the name of the database table to read and optional argument <parameters> is a JSON object containing various attributes that influence creation of the zonefile file. Currently the only <parameters> attribute supported is <i>maxAutoFrameSize</i> (default value 65536), which sets the maximum uncompressed frame size in bytes for automatically generated zonefile frames. For example, to create a zonefile named "test.zonefile" based on the contents of database table "test_input" and with a maximum automatic frame size of 4096 bytes: > SELECT zonefile_write('test.zonefile', 'test_input', > '{"maxAutoFrameSize":4096}' |
︙ | ︙ |
Changes to ext/zonefile/zonefile.c.
︙ | ︙ | |||
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 | ")" #include <stdio.h> #include <string.h> #include <assert.h> typedef struct ZonefileWrite ZonefileWrite; struct ZonefileWrite { int compressionTypeIndexData; int compressionTypeContent; int encryptionType; int maxAutoFrameSize; }; typedef struct ZonefileHeader ZonefileHeader; struct ZonefileHeader { u32 magicNumber; u8 compressionTypeIndexData; u8 compressionTypeContent; u32 byteOffsetDictionary; u32 byteOffsetFrames; u32 numFrames; u32 numKeys; u8 encryptionType; u8 encryptionKeyIdx; u8 extendedHeaderVersion; u8 extendedHeaderSize; }; typedef struct ZonefileBuffer ZonefileBuffer; struct ZonefileBuffer { u8 *a; int n; int nAlloc; }; | > > > > > > > > > > | 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 103 104 105 106 107 108 109 | ")" #include <stdio.h> #include <string.h> #include <assert.h> /* ** A structure to store the parameters for a single zonefile_write() ** invocation. */ typedef struct ZonefileWrite ZonefileWrite; struct ZonefileWrite { int compressionTypeIndexData; int compressionTypeContent; int encryptionType; int maxAutoFrameSize; }; /* ** A structure to store a deserialized zonefile header in. */ typedef struct ZonefileHeader ZonefileHeader; struct ZonefileHeader { u32 magicNumber; u8 compressionTypeIndexData; u8 compressionTypeContent; u32 byteOffsetDictionary; u32 byteOffsetFrames; u32 numFrames; u32 numKeys; u8 encryptionType; u8 encryptionKeyIdx; u8 extendedHeaderVersion; u8 extendedHeaderSize; }; /* ** Buffer structure used by the zonefile_write() implementation. */ typedef struct ZonefileBuffer ZonefileBuffer; struct ZonefileBuffer { u8 *a; int n; int nAlloc; }; |
︙ | ︙ | |||
214 215 216 217 218 219 220 221 222 223 224 225 226 227 | int rc = SQLITE_OK; int rc2; memset(p, 0, sizeof(ZonefileWrite)); p->maxAutoFrameSize = ZONEFILE_DEFAULT_MAXAUTOFRAMESIZE; rc = zonefilePrepare(db, &pStmt, &zErr,"SELECT key, value FROM json_each(?)"); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ const char *zKey = (const char*)sqlite3_column_text(pStmt, 0); int iVal = sqlite3_column_int(pStmt, 1); if( sqlite3_stricmp("maxAutoFrameSize", zKey)==0 ){ p->maxAutoFrameSize = iVal; }else if( sqlite3_stricmp("compressionTypeIndexData", zKey)==0 ){ | > > > | 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | int rc = SQLITE_OK; int rc2; memset(p, 0, sizeof(ZonefileWrite)); p->maxAutoFrameSize = ZONEFILE_DEFAULT_MAXAUTOFRAMESIZE; rc = zonefilePrepare(db, &pStmt, &zErr,"SELECT key, value FROM json_each(?)"); if( rc==SQLITE_OK ){ sqlite3_bind_text(pStmt, 1, zJson, -1, SQLITE_STATIC); } while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ const char *zKey = (const char*)sqlite3_column_text(pStmt, 0); int iVal = sqlite3_column_int(pStmt, 1); if( sqlite3_stricmp("maxAutoFrameSize", zKey)==0 ){ p->maxAutoFrameSize = iVal; }else if( sqlite3_stricmp("compressionTypeIndexData", zKey)==0 ){ |
︙ | ︙ |
Changes to ext/zonefile/zonefile1.test.
︙ | ︙ | |||
59 60 61 62 63 64 65 66 67 68 | DELETE FROM z1_files; SELECT * FROM z1_files; } {} do_execsql_test 1.6 { SELECT count(*) FROM z1_shadow_idx } 0 do_execsql_test 1.7 { DROP TABLE z1 } finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | DELETE FROM z1_files; SELECT * FROM z1_files; } {} do_execsql_test 1.6 { SELECT count(*) FROM z1_shadow_idx } 0 do_execsql_test 1.7 { DROP TABLE z1 } #------------------------------------------------------------------------- reset_db load_static_extension db zonefile do_execsql_test 2.0 { CREATE TABLE zz( k INTEGER PRIMARY KEY, frame INTEGER DEFAULT -1, idx INTEGER DEFAULT -1, v BLOB ); CREATE TABLE rt(k INTEGER PRIMARY KEY, v BLOB); CREATE VIRTUAL TABLE zone USING zonefile; } set nMinByte 0 set nMaxByte 444 foreach {zonefile lKey} { test1.zonefile {195 1238 298 405 297} test2.zonefile {124 1624 82 1929} test3.zonefile {932 683 1751 410 41} test4.zonefile {427 1491} test5.zonefile {1004 473 801 394 1672 816 1577} test6.zonefile {1374 1454 1005} test7.zonefile {450 241 319 133} test8.zonefile {1414 900 1406 1917 127 673} test9.zonefile {1192 226 988 1292 718 1345 1675} test10.zonefile {314} test11.zonefile {1177 1597 60 532 291 1164 812} test12.zonefile {1168 1290 1585 939 1916} test13.zonefile {644 1784 1476 1283 433 506} test14.zonefile {1141 1547 1506 364} test15.zonefile {1756 1885 844 1880 1896 354} test16.zonefile {1383 1928 1371} test17.zonefile {93} test18.zonefile {1067} test19.zonefile {642} test20.zonefile {1380 1857} test21.zonefile {288 293 1968 1207 1739 231 300} test22.zonefile {651 1007 607 830 299 1431} test23.zonefile {81 1651 543 1949 256 119 1088} test24.zonefile {1278 2024 682 1115 194 636 1804} test25.zonefile {514 1155 171 2015 791} test26.zonefile {1615 1228 147 1464} test27.zonefile {55 1130 781 678 78} test28.zonefile {1981 1401 1178} test29.zonefile {1754 864 183 1953 1901} test30.zonefile {1461 817} test31.zonefile {1720 1722 686 1833} } { forcedelete $zonefile execsql { DELETE FROM zz; } foreach k $lKey { execsql { INSERT INTO zz(k, v) VALUES($k, randomblob($k)) } } execsql { INSERT INTO rt SELECT k, v FROM zz } breakpoint execsql { SELECT zonefile_write($zonefile, 'zz', '{"maxAutoFrameSize":2000}'); INSERT INTO zone_files(filename) VALUES($zonefile); } } do_execsql_test 2.1 { SELECT k FROM zone JOIN rt USING (k) WHERE zone.v!=rt.v } do_execsql_test 2.2 { SELECT count(*) FROM zone JOIN rt USING (k); } {135} do_execsql_test 2.3 { SELECT filename, json_extract(header, '$.numKeys'), json_extract(header, '$.numFrames') FROM zone_files WHERE filename IN ('test19.zonefile', 'test20.zonefile', 'test21.zonefile') ORDER BY 1 } { test19.zonefile 1 1 test20.zonefile 2 2 test21.zonefile 7 4 } finish_test |