Fix handling of maxAutoFrameSize parameter.

FossilOrigin-Name: d65e5855743534cb8db0d77d107579eae6daafc25c2f6035efa12c3ff0abbe7a
This commit is contained in:
dan
2018-02-13 20:08:47 +00:00
parent 3f9402e115
commit 109346f437
5 changed files with 109 additions and 11 deletions
+3 -2
View File
@@ -31,8 +31,9 @@ is the name of the database table to read and optional argument
influence creation of the zonefile file.
Currently the only <parameters> attribute supported is
<i>maxAutoFrameSize</i>, which sets the maximum frame size in bytes for
automatically generated zonefile frames.
<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
+13
View File
@@ -67,6 +67,10 @@ typedef unsigned long u32;
#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;
@@ -75,6 +79,9 @@ struct ZonefileWrite {
int maxAutoFrameSize;
};
/*
** A structure to store a deserialized zonefile header in.
*/
typedef struct ZonefileHeader ZonefileHeader;
struct ZonefileHeader {
u32 magicNumber;
@@ -90,6 +97,9 @@ struct ZonefileHeader {
u8 extendedHeaderSize;
};
/*
** Buffer structure used by the zonefile_write() implementation.
*/
typedef struct ZonefileBuffer ZonefileBuffer;
struct ZonefileBuffer {
u8 *a;
@@ -218,6 +228,9 @@ static int zonefileGetParams(
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);
+84
View File
@@ -64,5 +64,89 @@ 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
+8 -8
View File
@@ -1,5 +1,5 @@
C Enhance\sext/zonefile/README.md\sto\sdescribe\sthe\scurrently\savailable\nfunctionality.
D 2018-02-13T19:01:08.333
C Fix\shandling\sof\smaxAutoFrameSize\sparameter.
D 2018-02-13T20:08:47.555
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 7a3f714b4fcf793108042b7b0a5c720b0b310ec84314d61ba7f3f49f27e550ea
@@ -408,9 +408,9 @@ F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386
F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3
F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f
F ext/zonefile/README.md fd8039cb0b421059ef90d014b4d71a1e376cb7d1210e80a896d76908708669e4
F ext/zonefile/zonefile.c 212c9a8778759c292685a0915ff5bcbdb9d279c2fe791021572617971c896c5b
F ext/zonefile/zonefile1.test 8904658bd8332dc0d0c77c0c74c9c83dce4123a442bb971d5baf00170f6d0afe
F ext/zonefile/README.md c42739c8276080be1c6d90ec47d98610af40336211dd382f87d1a8d2db7a3cdc
F ext/zonefile/zonefile.c 0e2ace4a2590b96ea1ed6ecff98af7504e6774755961e42bf982d268d5366856
F ext/zonefile/zonefile1.test 872ec8d549af0f1423601acdfe29390803fab3e14b8d5715f2f4bbd11431f1f5
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
@@ -1708,7 +1708,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 8bf5154bc6e31e206931d97c743eadaba4ef938c11e006082d795439dadaeb8f
R ac88557d5661bd1ac981fca2d5815858
P 100137c7f68b2d9a329d6d43e6c0a81b6ac843678b670ab6cce5f510bc58b7a8
R 9583ab6dfe2f7414596de2b26e5de239
U dan
Z 857bf6fa80777d961d06ea17c5dbe1b2
Z 59c419e27cd53a130879134eaf3f69b6
+1 -1
View File
@@ -1 +1 @@
100137c7f68b2d9a329d6d43e6c0a81b6ac843678b670ab6cce5f510bc58b7a8
d65e5855743534cb8db0d77d107579eae6daafc25c2f6035efa12c3ff0abbe7a