_sqlite3_shutdown
_sqlite3_sourceid
_sqlite3_sql
+_sqlite3_status
+_sqlite3_status64
_sqlite3_step
+_sqlite3_stmt_status
_sqlite3_strglob
_sqlite3_stricmp
_sqlite3_strlike
const aPtr = wasm.xWrap.argAdapter('*');
const nilType = function(){};
wasm.xWrap.argAdapter('sqlite3_filename', aPtr)
- ('sqlite3_stmt*', aPtr)
('sqlite3_context*', aPtr)
('sqlite3_value*', aPtr)
('void*', aPtr)
+ ('sqlite3_stmt*', (v)=>
+ aPtr((v instanceof (sqlite3?.oo1?.Stmt || nilType))
+ ? v.pointer : v))
('sqlite3*', (v)=>
aPtr((v instanceof (sqlite3?.oo1?.DB || nilType))
? v.pointer : v))
'encodings', 'fcntl', 'flock', 'ioCap',
'limits', 'openFlags',
'prepareFlags', 'resultCodes',
- 'serialize', 'syncFlags', 'trace', 'udfFlags',
+ 'serialize', 'sqlite3Status',
+ 'stmtStatus', 'syncFlags',
+ 'trace', 'udfFlags',
'version' ];
if(wasm.bigIntEnabled){
defineGroups.push('vtab');
around the NUL terminator, and get stuck in and
endless loop at the end of the SQL, endlessly
re-preparing an empty statement. */ ){
- wasm.setPtrValue(ppStmt, 0);
- wasm.setPtrValue(pzTail, 0);
+ wasm.setPtrValue([ppStmt, pzTail], 0);
DB.checkRc(this, capi.sqlite3_prepare_v3(
this.pointer, pSql, sqlByteLen, 0, ppStmt, pzTail
));
["sqlite3_shutdown", undefined],
["sqlite3_sourceid", "string"],
["sqlite3_sql", "string", "sqlite3_stmt*"],
+ ["sqlite3_status", "int", "int", "*", "*", "int"],
["sqlite3_step", "int", "sqlite3_stmt*"],
+ ["sqlite3_stmt_status", "int", "sqlite3_stmt*", "int", "int"],
["sqlite3_strglob", "int", "string","string"],
["sqlite3_stricmp", "int", "string", "string"],
["sqlite3_strlike", "int", "string", "string","int"],
["sqlite3_realloc64", "*","*", "i64"],
["sqlite3_result_int64", undefined, "*", "i64"],
["sqlite3_result_zeroblob64", "int", "*", "i64"],
+ ["sqlite3_status64", "int", "int", "*", "*", "int"],
["sqlite3_total_changes64", "i64", ["sqlite3*"]],
["sqlite3_uri_int64", "i64", ["sqlite3_filename", "string", "i64"]],
["sqlite3_value_int64","i64", "sqlite3_value*"],
DefInt(SQLITE_DESERIALIZE_RESIZEABLE);
} _DefGroup;
+ DefGroup(sqlite3Status){
+ DefInt(SQLITE_STATUS_MEMORY_USED);
+ DefInt(SQLITE_STATUS_PAGECACHE_USED);
+ DefInt(SQLITE_STATUS_PAGECACHE_OVERFLOW);
+ DefInt(SQLITE_STATUS_SCRATCH_USED) /* NOT USED */;
+ DefInt(SQLITE_STATUS_SCRATCH_OVERFLOW) /* NOT USED */;
+ DefInt(SQLITE_STATUS_MALLOC_SIZE);
+ DefInt(SQLITE_STATUS_PARSER_STACK);
+ DefInt(SQLITE_STATUS_PAGECACHE_SIZE);
+ DefInt(SQLITE_STATUS_SCRATCH_SIZE) /* NOT USED */;
+ DefInt(SQLITE_STATUS_MALLOC_COUNT);
+ } _DefGroup;
+
+ DefGroup(stmtStatus){
+ DefInt(SQLITE_STMTSTATUS_FULLSCAN_STEP);
+ DefInt(SQLITE_STMTSTATUS_SORT);
+ DefInt(SQLITE_STMTSTATUS_AUTOINDEX);
+ DefInt(SQLITE_STMTSTATUS_VM_STEP);
+ DefInt(SQLITE_STMTSTATUS_REPREPARE);
+ DefInt(SQLITE_STMTSTATUS_RUN);
+ DefInt(SQLITE_STMTSTATUS_FILTER_MISS);
+ DefInt(SQLITE_STMTSTATUS_FILTER_HIT);
+ DefInt(SQLITE_STMTSTATUS_MEMUSED);
+ } _DefGroup;
+
DefGroup(syncFlags) {
DefInt(SQLITE_SYNC_NORMAL);
DefInt(SQLITE_SYNC_FULL);
type triggers an exception if this.bigIntEnabled is
falsy). Throws if given an invalid type.
+ If the first argument is an array, it is treated as an array of
+ addresses and the result is an array of the values from each of
+ those address, using the same 2nd argument for determining the
+ value type to fetch.
+
As a special case, if type ends with a `*`, it is considered to
be a pointer type and is treated as the WASM numeric type
appropriate for the pointer size (`i32`).
See: setMemValue()
*/
- target.getMemValue = function(ptr, type='i8'){
+ target.getMemValue = function f(ptr, type='i8'){
if(type.endsWith('*')) type = ptrIR;
const c = (cache.memory && cache.heapSize === cache.memory.buffer.byteLength)
? cache : heapWrappers();
- switch(type){
- case 'i1':
- case 'i8': return c.HEAP8[ptr>>0];
- case 'i16': return c.HEAP16[ptr>>1];
- case 'i32': return c.HEAP32[ptr>>2];
- case 'i64':
- if(target.bigIntEnabled) return BigInt(c.HEAP64[ptr>>3]);
- break;
- case 'float': case 'f32': return c.HEAP32F[ptr>>2];
- case 'double': case 'f64': return Number(c.HEAP64F[ptr>>3]);
- default: break;
- }
- toss('Invalid type for getMemValue():',type);
+ const list = Array.isArray(ptr) ? [] : undefined;
+ let rc;
+ do{
+ if(list) ptr = arguments[0].shift();
+ switch(type){
+ case 'i1':
+ case 'i8': rc = c.HEAP8[ptr>>0]; break;
+ case 'i16': rc = c.HEAP16[ptr>>1]; break;
+ case 'i32': rc = c.HEAP32[ptr>>2]; break;
+ case 'float': case 'f32': rc = c.HEAP32F[ptr>>2]; break;
+ case 'double': case 'f64': rc = Number(c.HEAP64F[ptr>>3]); break;
+ case 'i64':
+ if(target.bigIntEnabled){
+ rc = BigInt(c.HEAP64[ptr>>3]);
+ break;
+ }
+ /* fallthru */
+ default:
+ toss('Invalid type for getMemValue():',type);
+ }
+ if(list) list.push(rc);
+ }while(list && arguments[0].length);
+ return list || rc;
};
/**
argument ends with `*` then it is treated as a pointer type and
this function behaves as if the 3rd argument were `i32`.
- This function returns itself.
+ If the first argument is an array, it is treated like a list
+ of pointers and the given value is written to each one.
+
+ Returns `this`. (Prior to 2022-12-09 it returns this function.)
ACHTUNG: calling this often, e.g. in a loop, can have a noticably
painful impact on performance. Rather than doing so, use
- heapForSize() to fetch the heap object and assign directly to it.
+ heapForSize() to fetch the heap object and assign directly to it
+ or use the heap's set() method.
*/
- target.setMemValue = function f(ptr, value, type='i8'){
+ target.setMemValue = function(ptr, value, type='i8'){
if (type.endsWith('*')) type = ptrIR;
const c = (cache.memory && cache.heapSize === cache.memory.buffer.byteLength)
? cache : heapWrappers();
- switch (type) {
- case 'i1':
- case 'i8': c.HEAP8[ptr>>0] = value; return f;
- case 'i16': c.HEAP16[ptr>>1] = value; return f;
- case 'i32': c.HEAP32[ptr>>2] = value; return f;
- case 'i64':
- if(c.HEAP64){
- c.HEAP64[ptr>>3] = BigInt(value);
- return f;
- }
- break;
- case 'float': case 'f32': c.HEAP32F[ptr>>2] = value; return f;
- case 'double': case 'f64': c.HEAP64F[ptr>>3] = value; return f;
+ for(const p of (Array.isArray(ptr) ? ptr : [ptr])){
+ switch (type) {
+ case 'i1':
+ case 'i8': c.HEAP8[p>>0] = value; continue;
+ case 'i16': c.HEAP16[p>>1] = value; continue;
+ case 'i32': c.HEAP32[p>>2] = value; continue;
+ case 'float': case 'f32': c.HEAP32F[p>>2] = value; continue;
+ case 'double': case 'f64': c.HEAP64F[p>>3] = value; continue;
+ case 'i64':
+ if(c.HEAP64){
+ c.HEAP64[p>>3] = BigInt(value);
+ continue;
+ }
+ /* fallthru */
+ default:
+ toss('Invalid type for setMemValue(): ' + type);
+ }
}
- toss('Invalid type for setMemValue(): ' + type);
+ return this;
};
+ /**
+ Convenience form of getMemValue() intended for fetching
+ pointer-to-pointer values. If passed a single non-array argument
+ it returns the value of that one pointer address. If passed
+ multiple arguments, or a single array of arguments, it returns an
+ array of their values.
+ */
+ target.getPtrValue = function(...ptr){
+ return target.getMemValue( (1===ptr.length ? ptr[0] : ptr), ptrIR );
+ };
- /** Convenience form of getMemValue() intended for fetching
- pointer-to-pointer values. */
- target.getPtrValue = (ptr)=>target.getMemValue(ptr, ptrIR);
-
- /** Convenience form of setMemValue() intended for setting
- pointer-to-pointer values. */
- target.setPtrValue = (ptr, value)=>target.setMemValue(ptr, value, ptrIR);
+ /**
+ A variant of setMemValue() intended for setting
+ pointer-to-pointer values. Its differences from setMemValue() are
+ that (1) it defaults to a value of 0, (2) it always writes
+ to the pointer-sized heap view, and (3) it returns `this`.
+ */
+ target.setPtrValue = (ptr, value=0)=>target.setMemValue(ptr, value, ptrIR);
/**
Returns true if the given value appears to be legal for use as
T.assert(12n===rc);
w.scopedAllocCall(function(){
- let pI1 = w.scopedAlloc(8), pI2 = pI1+4;
- w.setMemValue(pI1, 0,'*')(pI2, 0, '*');
- let f = w.xWrap('sqlite3_wasm_test_int64_minmax',undefined,['i64*','i64*']);
- let r1 = w.getMemValue(pI1, 'i64'), r2 = w.getMemValue(pI2, 'i64');
+ const pI1 = w.scopedAlloc(8), pI2 = pI1+4;
+ w.setPtrValue([pI1, pI2], 0);
+ const f = w.xWrap('sqlite3_wasm_test_int64_minmax',undefined,['i64*','i64*']);
+ const [r1, r2] = w.getMemValue([pI1, pI2], 'i64');
T.assert(!Number.isSafeInteger(r1)).assert(!Number.isSafeInteger(r2));
});
}
}
};
- T.assert(Number.isInteger(db.pointer))
+ T.assert(wasm.isPtr(db.pointer))
.mustThrowMatching(()=>db.pointer=1, /read-only/)
.assert(0===sqlite3.capi.sqlite3_extended_result_codes(db.pointer,1))
.assert('main'===db.dbName(0))
0, 4096, 12);
T.assert(0 === rc);
}
- }finally{
+ wasm.setPtrValue([pCur, pHi], 0);
+ let [vCur, vHi] = wasm.getPtrValue(pCur, pHi);
+ T.assert(0===vCur).assert(0===vHi);
+ rc = capi.sqlite3_status(capi.SQLITE_STATUS_MEMORY_USED,
+ pCur, pHi, 0);
+ [vCur, vHi] = wasm.getPtrValue([pCur, pHi]);
+ T.assert(vCur!==0).assert(vHi!==0);
+ [vCur, vHi] = wasm.getMemValue([vCur, vHi], 'i32');
+ T.assert(0 === rc).assert(vCur > 0).assert(vHi >= vCur);
+ if(wasm.bigIntEnabled){
+ // Again in 64-bit. Recall that pCur and pHi are allocated
+ // large enough to account for this re-use.
+ wasm.setPtrValue([pCur, pHi], 0)
+ .setMemValue([vCur, vHi], 0, 'i64');
+ rc = capi.sqlite3_status64(capi.SQLITE_STATUS_MEMORY_USED,
+ pCur, pHi, 0);
+ [vCur, vHi] = wasm.getPtrValue([pCur, pHi]);
+ T.assert(vCur!==0).assert(vHi!==0);
+ [vCur, vHi] = wasm.getMemValue([vCur, vHi], 'i64');
+ T.assert(0 === rc).assert(vCur > 0).assert(vHi >= vCur);
+ }
+ }finally{
wasm.pstack.restore(stack);
}
})
);
//debug("statement =",st);
try {
- T.assert(Number.isInteger(st.pointer))
+ T.assert(wasm.isPtr(st.pointer))
.mustThrowMatching(()=>st.pointer=1, /read-only/)
.assert(1===this.db.openStatementCount())
+ .assert(
+ capi.sqlite3_stmt_status(
+ st, capi.SQLITE_STMTSTATUS_RUN, 0
+ ) === 0)
.assert(!st._mayGet)
.assert('a' === st.getColumnName(0))
.assert(1===st.columnCount)
.assert(st._mayGet)
.assert(false===st.step())
.assert(!st._mayGet)
- ;
+ .assert(
+ capi.sqlite3_stmt_status(
+ st, capi.SQLITE_STMTSTATUS_RUN, 0
+ ) > 0);
+
T.assert(0===capi.sqlite3_strglob("*.txt", "foo.txt")).
assert(0!==capi.sqlite3_strglob("*.txt", "foo.xtx")).
assert(0===capi.sqlite3_strlike("%.txt", "foo.txt", 0)).
const pMin = w.scopedAlloc(16);
const pMax = pMin + 8;
const g64 = (p)=>w.getMemValue(p,ptrType64);
- w.setMemValue(pMin, 0, ptrType64);
- w.setMemValue(pMax, 0, ptrType64);
+ w.setMemValue([pMin, pMax], 0, ptrType64);
const minMaxI64 = [
w.xCall('sqlite3_wasm_test_int64_min'),
w.xCall('sqlite3_wasm_test_int64_max')
-C JS\sAPI\sdoc\supdates.
-D 2022-12-09T02:23:15.484
+C Export\ssqlite3_status()\sand\ssqlite3_stmt_status()\sto\swasm.\sExpand\sthe\sarg/return\ssemantics\sof\swasm.get/setPtrValue()\sand\sget/setMemValue()\sto\ssimplify\shandling\sof\smultiple\spointers.
+D 2022-12-09T05:47:42.689
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/wasm/GNUmakefile 54c0db93a5493f625c0a993c12aee5d83951440eee03b2aecfc8aeb998182998
F ext/wasm/README-dist.txt 2d670b426fc7c613b90a7d2f2b05b433088fe65181abead970980f0a4a75ea20
F ext/wasm/README.md ef39861aa21632fdbca0bdd469f78f0096f6449a720f3f39642594af503030e9
-F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 914cbaa9fad42d4ebe33d0ea6c0151d043e6c0237782f2d27eb5e35f54b7c604
+F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api c1a7e0054762cc88a02ab27b0a64b5682bf9c35bfe67ac0a9c6a4c641acb6a09
F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
F ext/wasm/api/README.md 17fb1e10335cc87e366dec496c5b17b061f3f75cdf216e825258de34d97a3e53
F ext/wasm/api/extern-post-js.c-pp.js 8923f76c3d2213159e12d641dc750523ead5c848185dc4996fae5cc12397f88d
F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62
F ext/wasm/api/pre-js.c-pp.js b88499dc303c21fc3f55f2c364a0f814f587b60a95784303881169f9e91c1d5f
F ext/wasm/api/sqlite3-api-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
-F ext/wasm/api/sqlite3-api-glue.js 58efb4f513d9a75bbf1c9f81944047df78c61bd7d5ad8b64f92fa9582bca37bf
-F ext/wasm/api/sqlite3-api-oo1.js e9e6da5f9e4d7d309fe4c338a22fb38575e831cddd10d6506fba7ddc180df6e6
-F ext/wasm/api/sqlite3-api-prologue.js c0411213b696301ba19ee11cf8fea7876c883e7399332ea79d5768cd4121bf13
+F ext/wasm/api/sqlite3-api-glue.js c1d0dac2b00a3341f1caf3f8422140b93d2f7c5196a6133d13409f678655babc
+F ext/wasm/api/sqlite3-api-oo1.js 70747d6482c1dda91d43bacc9b807642200b3631c4be50c372cf4ea98e90976e
+F ext/wasm/api/sqlite3-api-prologue.js b0e1ca687b4470f3ee409c3d5938c3be7ac0c854b1401e217f0d56ba96636346
F ext/wasm/api/sqlite3-api-worker1.js e94ba98e44afccfa482874cd9acb325883ade50ed1f9f9526beb9de1711f182f
F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
F ext/wasm/api/sqlite3-opfs-async-proxy.js 7795b84b66a7a8dedc791340709b310bb497c3c72a80bef364fa2a58e2ddae3f
F ext/wasm/api/sqlite3-v-helper.js 181117ad4c604500599dc07f07314a75f111dd06aab756e77ac8db64dff59d1d
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 78133d710bee4c48a1a30262b44a284bc017a3751caa7967bdc030f5d0178daa
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
-F ext/wasm/api/sqlite3-wasm.c 5d61665dec993e401535730ba536e207e780ed12d7455b6f0a5be48ab5654924
+F ext/wasm/api/sqlite3-wasm.c ecf7af7259c7db4b467b7a3fec2faaa766777f370f201f5e6533593911d4acde
F ext/wasm/api/sqlite3-worker1-promiser.js 0c7a9826dbf82a5ed4e4f7bf7816e825a52aff253afbf3350431f5773faf0e4b
F ext/wasm/api/sqlite3-worker1.js 1e54ea3d540161bcfb2100368a2fc0cad871a207b8336afee1c445715851ec54
F ext/wasm/batch-runner.html 4deeed44fe41496dc6898d9fb17938ea3291f40f4bfb977e29d0cef96fbbe4c8
F ext/wasm/common/SqliteTestUtil.js d8bf97ecb0705a2299765c8fc9e11b1a5ac7f10988bbf375a6558b7ca287067b
F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15
F ext/wasm/common/testing.css 0ff15602a3ab2bad8aef2c3bd120c7ee3fd1c2054ad2ace7e214187ae68d926f
-F ext/wasm/common/whwasmutil.js f0a742270b490748b9fdb0974287429b036698609b40eee81f13fe13e64358a7
+F ext/wasm/common/whwasmutil.js 44a1ef32d56448ccea711cefe1ecd235fe48084a04d96d3947e810bc5ac53042
F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed
F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508
F ext/wasm/demo-123.js ebae30756585bca655b4ab2553ec9236a87c23ad24fc8652115dcedb06d28df6
F ext/wasm/test-opfs-vfs.js 44363db07b2a20e73b0eb1808de4400ca71b703af718d0fa6d962f15e73bf2ac
F ext/wasm/tester1-worker.html d43f3c131d88f10d00aff3e328fed13c858d674ea2ff1ff90225506137f85aa9
F ext/wasm/tester1.c-pp.html d34bef3d48e5cbc1c7c06882ad240fec49bf88f5f65696cc2c72c416933aa406
-F ext/wasm/tester1.c-pp.js 7eebd39ac7603645d501a550387122230a283a0b0ac111497e3221a4505bcdab
+F ext/wasm/tester1.c-pp.js 89bbdebafcf77e129339387490004dc686fdfdc2b0417a3314d0fab6f3d525e4
F ext/wasm/tests/opfs/concurrency/index.html 86d8ac435074d1e7007b91105f4897f368c165e8cecb6a9aa3d81f5cf5dcbe70
F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P c31eb509e5cb1025de058132ee9a45d70c84ee47a6abe18811a65ce339f062a0
-R be70f20baf9f8b1aac1710d7d4bd92be
+P 4f80fd3b8d4c85894664093d8310d6f5299faac4eb879edc608b3ffcd8558e9a
+R 8856fe1b3198fb68043702a2dbe9189a
U stephan
-Z e13c75cc4f01c10c6d98532e21e633db
+Z eb09a3d82a34332e18c8c6ef4a9133cc
# Remove this line to create a well-formed Fossil manifest.
-4f80fd3b8d4c85894664093d8310d6f5299faac4eb879edc608b3ffcd8558e9a
\ No newline at end of file
+e144fd5c88fa4151429a2fef3daf389588402e158267f0afa0dfd142527d76b9
\ No newline at end of file