flatsql 3.3.1 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,11 +26,26 @@ departure from the design.
26
26
 
27
27
  - Create `env.memory` shared, with a maximum no larger than the import's
28
28
  (browser writer 256 MiB, reader 128 MiB, design §5.5).
29
- - Grow the heap before `flatsql_ps_start` when threads will allocate (alloc
30
- then free a large block through `flatsql_ps_alloc`/`flatsql_ps_free`): V8
31
- (Node 20–25, and browsers) refreshes each thread's view of a shared memory's
32
- size lazily, so a thread touching memory another thread has just grown can
33
- trap. WasmEdge is not affected.
29
+ - **V8 hosts (Node, browsers): grow the heap to the memory's maximum before
30
+ `flatsql_ps_start`, so it never grows while guest threads run.** Allocate
31
+ through `flatsql_ps_alloc` in steps from 1 GiB down to 1 MiB until each
32
+ fails, then free them all (the allocator keeps the blocks; wasm memory never
33
+ shrinks; the guest allocator grows at most 2 GiB per call). V8 bounds-checks
34
+ `memory.fill`/`memory.copy` and atomics against each thread's cached view of
35
+ a shared memory's size, and another thread's `memory.grow` updates that view
36
+ only at this thread's next stack check. A thread that fills a block carved
37
+ from memory another thread has just grown then traps "memory access out of
38
+ bounds" (§4.3). A partial pre-grow only moves the failure: the 1,536 MiB the
39
+ test main used to grow was passed at 1,651 MiB in CI. Stop 16 MiB short of
40
+ 4 GiB with a 4 GiB maximum: a heap segment ending at 2^32 wraps the
41
+ allocator's pointer arithmetic. `createPsNodeInstance` does this
42
+ (`growHeap: false` opts out, `heapBytes` caps it), and the Node host reports
43
+ `memoryGrownWhileThreadsRan` for every guest and warns when it is not 0.
44
+ - **WasmEdge hosts do not pre-grow** (and SDN recycles reader instances on
45
+ their page count). WasmEdge keeps one page count shared by every thread's
46
+ instance and grows in place in a fixed reservation, so a grow is visible to
47
+ every thread at once. WasmEdge 0.16.4's AOT compiler must carry SDN's
48
+ `04-atomic-memarg-offset` patch (§4.3).
34
49
  - Give every guest thread a distinct `tid` below 2^29 (wasi-libc keeps it in
35
50
  mutex words).
36
51
 
@@ -93,8 +108,8 @@ budget fails the crash instead of making it partial.
93
108
  Added tests (`PS_SLOW_TEST`, run only when named): `parity_canonical_dump`,
94
109
  `parity_deterministic_bytes` (`cpp/test/ps/parity_test.cpp`) and
95
110
  `host_crash_ingest` / `host_crash_verify` (`host_crash_test.cpp`). The wasm
96
- test main grows the heap by 1,536 MiB before any thread starts
97
- (`PS_WASM_HEAP_MB`).
111
+ test main grows the heap to the memory's maximum before any thread starts
112
+ (§1; `PS_WASM_HEAP_MB` caps it).
98
113
 
99
114
  ```
100
115
  npm run build:wasm:ps-tests # artifact + test commands
@@ -163,6 +178,67 @@ journal. A negative control (half a data segment cut off) fails the verifier.
163
178
  when `mergeL0Blocks` exceeded the directory cap, so labeling, partition
164
179
  merges and acks stopped (`dac8d89`).
165
180
 
181
+ ### 4.3 The shared-memory grow race (V8) and AOT wait/notify (WasmEdge)
182
+
183
+ **V8.** CI ps-wasm run 36603876540 (attempt 1) trapped "memory access out of
184
+ bounds" in `writeTypeMergeOutputs` on the type-merge helper thread during
185
+ `readers_under_saturating_writers_T2_1`, with memory at 1,651 MiB, past the
186
+ test main's 1,536 MiB pre-grow. A Docker build with the Linux wasi-sdk 30 at
187
+ the CI checkout path reproduces the CI test command exactly (its function
188
+ indices match the trace, and its `flatsql-ps-threads.wasm` is the committed
189
+ artifact's sha256). The trap offset `0x18d31a` is a `memory.fill`: the
190
+ zero-fill of `blocks[i].resize(de.l0Len)` right after its `operator new`.
191
+ Each thread's instance caches the memory size, and V8 bounds-checks
192
+ `memory.fill`/`memory.copy` and atomics against that cache. Another thread's
193
+ `memory.grow` updates the cache only at this thread's next stack check, so a
194
+ block the allocator carves from memory another thread has just grown fails
195
+ that check. Plain loads and stores are checked by guard pages and never trap.
196
+ Measured on the Mac, Node 25.4.0, load 35–65:
197
+
198
+ | Heap before threads start | T2_1 runs | Traps |
199
+ |---|---|---|
200
+ | none (`PS_WASM_HEAP_MB=0`) | 31 | 8, every one a `memory.fill`/`memory.copy` right after an allocation (vector push_back, string copy, the resize above) |
201
+ | 2,000 MiB (past the test's peak) | 30 | 0 |
202
+ | the memory's maximum (§1, now the default) | 500 | 0, and 0 runs grew memory after a thread started (1 run ended in a Node 25.4.0 SIGILL inside V8's JIT code, a host crash) |
203
+
204
+ Natively the same test under ASan+UBSan (Docker linux/arm64, 4 CPUs, a CPU
205
+ hog) found no memory error in 488 runs: the engine never overran.
206
+
207
+ **WasmEdge, the SDN host.** Every thread's instance imports one shared
208
+ `MemoryInstance`. On 64-bit hosts it is reserved in full up front (12 GiB,
209
+ `lib/system/allocator.cpp`) and `memory.grow` maps pages in place, so the
210
+ base never moves. The page count is one field that `memory.fill`/`copy`/
211
+ `init` and atomic wait/notify check live, and plain loads and stores are
212
+ checked by guard pages. The SDN C host I/O resolves every guest pointer per
213
+ call (`WasmEdge_MemoryInstanceGetPointer`), and the Go accessor re-reads the
214
+ page count on a miss. A grow is visible to every thread when the growing
215
+ thread's `memory.grow` returns, and the guest allocator's lock orders it
216
+ before any other thread can allocate from it. Measured: the same T2_1 with
217
+ no pre-grow on the patched WasmEdge 0.16.4, AOT, had 0 traps in 26 completed
218
+ runs.
219
+
220
+ **WasmEdge AOT wait/notify.** Those WasmEdge runs also hung at teardown: 4 of
221
+ 30 with no pre-grow, 5 of 30 with a 1,536 MiB pre-grow. WasmEdge 0.16.4's AOT
222
+ compiler passed `memory.atomic.notify` and `memory.atomic.wait32/64` the bare
223
+ address operand and dropped the instruction's memarg offset; the interpreter
224
+ adds it. wasi-libc addresses its thread-list lock as `i32.const 0;
225
+ memory.atomic.notify offset=<lock>`, so those wakeups went to address 0 and
226
+ thread exit and join hung. A plain spawn/join guest with no flatsql code, 50
227
+ rounds of 16 threads, hung 11 of 20 runs AOT, 0 of 30 interpreted and 0 of 20
228
+ under V8. `sleepNs` (a timed wait on a stack local whose frame offset the
229
+ compiler folds into the memarg) compared another stack word and returned at
230
+ once: 100 × 10 ms took 0.000 s AOT and 1.159 s interpreted. SDN's static
231
+ WasmEdge carries patch `04-atomic-memarg-offset` from SDN `74db37e14`, and
232
+ its substrate self-test checks it (tag `sdn3`, so threaded AOT artifacts
233
+ recompile). With the patch, the plain guest ran 40 of 40, and T2_1 AOT ran
234
+ 140 times with no hang. Two of those runs failed. One ran out of the 4 GiB
235
+ address space: the memio command keeps every file in guest memory, and
236
+ passing runs end near 2.7 GiB. The other run's output was not kept.
237
+ `memory_safety_sleep_and_notify_at_folded_offsets` passes. Without it, that test fails (20 of 20 folded-offset wakeups lost).
238
+ `sleepNs` now passes its address through a volatile, so its wait has a zero
239
+ memarg offset and sleeps even on an unpatched runtime. The artifact still has
240
+ 4 folded wait/notify sites, all in wasi-libc's thread code.
241
+
166
242
  ## 5. Design deviations
167
243
 
168
244
  1. **The Node host's thread spawn is its own pool, not the SDK's Node
@@ -6,8 +6,13 @@ per-commit indexes, type owners, and durable-tail open. Part II (§12–§21) is
6
6
  T2: reader instances and lanes, the snapshot protocol, the SQL surface, the
7
7
  fan-out merge, admission and results. Part III (§23–§30) is T3: compaction,
8
8
  reclamation, meta-segment retirement, disk accounting and quota. Part IV
9
- (§31–) is T3b: store-migrate gseqs, the entry-size setting, hot-partition
10
- splitting and arrivals compaction. The design is
9
+ (§31–§35) is T3b: store-migrate gseqs, the entry-size setting, hot-partition
10
+ splitting and arrivals compaction; §36 records the quota eviction race T3 #3
11
+ met on Linux. Part V (§37) bounds a reader instance's memory. Part VI (§38)
12
+ records the memory-safety and race work: the ps-wasm trap, the sanitizers and
13
+ the first disk-full emergency. Part VII (§39) closes the query gaps T6 found
14
+ on the host-02 fixture and accepts records stored with their own size
15
+ prefix. The design is
11
16
  the stack's `docs/architecture/flatsql-partition-store.md` (§22 overrides
12
17
  §0–§21; §22.4 holds the owner rulings). This file records what was built, how
13
18
  to run it, the measured acceptance, and every place the build departs from the
@@ -456,7 +461,8 @@ vector for T6's Go decoder.
456
461
  and binary-searched. A statement resolves each snapshot's sections once per
457
462
  kind.
458
463
  - **L1 runs** open lazily: footer and TOC, the metadata CRC checked once per
459
- lane, then a kind's fences on first use and its bloom while it fits.
464
+ lane, then a kind's fences a page (128 fences, 5 KiB) at a time and its
465
+ bloom while it fits (§37).
460
466
  - **Ascending scans prime runs lazily.** A run joins a posting merge with a
461
467
  lower bound of its first entry (the scan's `lo`, or its first block's fence
462
468
  prefix) and reads its first 4 KiB block only when it reaches the top of the
@@ -465,13 +471,14 @@ vector for T6's Go decoder.
465
471
  from, not one block from every run of every partition. Descending scans
466
472
  prime eagerly (a fence gives no upper bound).
467
473
  - **The instance's shared cache** holds these immutable pieces (L0
468
- directories and sections, fences, blooms) for every lane: 64 shards, each
469
- only ever try-locked, so a busy shard is a miss and a lane never waits on
470
- another lane (writers never touch it). A lane-private front map serves
471
- repeated hits without any lock.
472
- - Default budgets: 16 MiB shared per instance, 4 MiB private per lane,
473
- 4,096 host handles per lane (the host's handles are virtual; T5 bounds real
474
- fds with its LRU).
474
+ directories and sections, fence pages, blooms) for every lane: one shard
475
+ per MiB of budget (1 to 64), each only ever try-locked, so a busy shard is
476
+ a miss and a lane never waits on another lane (writers never touch it). A
477
+ lane-private front, an LRU by bytes, serves repeated hits without any lock.
478
+ - Default budgets: 16 MiB shared per instance, 4 MiB per lane for each of
479
+ its private cache, its resident runs and its front, 4,096 host handles per
480
+ lane (the host's handles are virtual; T5 bounds real fds with its LRU).
481
+ Every cache is bounded by bytes (§37).
475
482
 
476
483
  ## 18. Arrivals, offset paging, dead history (A14, A15)
477
484
 
@@ -806,9 +813,11 @@ and not counted. The crash tests check the type directory the same way.
806
813
  (`EngineConfig::quotaBytes`, `Engine::setQuota`, `flatsql_ps_set_quota`), it
807
814
  evicts whole sealed segments in arrival order across partitions (their
808
815
  `minArrival` zone) down to 0.85 of the cap: a `TOMB_RANGE{seg, all}` on the
809
- owner (bounded 512-row steps; supersede-lane heads and control kinds are
810
- spared; each step also stops after 4 ms of CPU), then, once the tombstones
811
- are durable, a compaction of the segment. One wave at a time.
816
+ owner that names the segment's rows by pseq (deviation 34; bounded 512-row
817
+ steps; supersede-lane heads and control kinds are spared; each step also
818
+ stops after 4 ms of CPU), then, once the tombstones are durable, a
819
+ compaction of the segment, or of the output it has been coalesced into
820
+ since. One wave at a time.
812
821
  - **ENOSPC.** A commit that fails NOSPACE starts an emergency: record entries
813
822
  stop being consumed (producers see zero credits; nothing is acked), the
814
823
  ballast file (`fsql2/ballast`, `ballastBytes`) is released, and waves evict one
@@ -1388,3 +1397,447 @@ cpp/build/flatsql_ps_test --test=type_arrivals_compaction_A15 [--seconds=N]
1388
1397
  cpp/build/flatsql_ps_test --test=orphan_crash_points_during_compaction_T3_4_full
1389
1398
  cpp/build/flatsql_ps_bench --mode=hotsplit [--helpers=4] [--io=mem|fs] [--dir=D] [--records=N]
1390
1399
  ```
1400
+
1401
+ ## 36. Eviction ranges name rows, not segments (T3 #3 on Linux)
1402
+
1403
+ `quota_arrival_order_heads_spared_T3_3` failed now and then on the ubuntu CI
1404
+ job (holes 585 on 71065d3; 616, then 471 on 49e7ac7). It reproduced in Docker
1405
+ (Debug, the test looped): 3 of 100 runs on linux/arm64 with 4 CPUs, 1 of 150
1406
+ on linux/amd64 with 4 CPUs and stress-ng on 2. Each failure had the same
1407
+ interleaving (traced on arm64, 4 of 100):
1408
+
1409
+ 1. The planner chose partition p's oldest segments from its summary, A
1410
+ (`[0-1]`), B (`2`), C and later, and queued a TOMB_RANGE for each by
1411
+ segment id.
1412
+ 2. A's range started. Its first steps put A past the dead-share trigger, and
1413
+ maintenance compacted A, which left it small.
1414
+ 3. Maintenance coalesced the shrunken A with its small neighbour B into one
1415
+ output named A (`[0-2]`).
1416
+ 4. B's range reached the front of the queue and looked for segment 2. There
1417
+ was none, so it examined nothing and completed.
1418
+
1419
+ B's records outlived C's and every later evicted record, and stayed after the
1420
+ wave had settled: an engine bug, not the test's view.
1421
+
1422
+ 34. **An eviction's TOMB_RANGE names the segment's rows** (§13:
1423
+ `TOMB_RANGE{seg, epoch < t}`). The summary carries each sealed segment's
1424
+ `[firstPseq, endPseq)`, which compaction and coalescing never renumber,
1425
+ and the planner's range examines exactly those rows wherever they live
1426
+ now (`Engine::tombRange(pid, seg, bound, ticket, firstPseq, endPseq)`;
1427
+ without a range, `seg` is still resolved when the range starts). A
1428
+ compaction request for a segment coalesced since compacts the output
1429
+ that holds it. Before, it failed NOENT, the wave's space came back only
1430
+ through maintenance, and the next pass could evict below the low-water
1431
+ mark.
1432
+ 35. **A compaction reads the kills in the active segment's runs.** It
1433
+ collected the runs of the segments that end after its inputs. The active
1434
+ segment has no end until it seals, so the kills a merge had folded into
1435
+ its runs were missed and their rows kept (an eviction's own compaction
1436
+ met this whenever its tombstones merged before the SWAP was planned).
1437
+
1438
+ `quota_tomb_range_follows_rows_coalesced_into_older_segment` replays both:
1439
+ A and B coalesce, B's range runs from the pseqs taken before that, one L0
1440
+ block per step so that some of the tombstones merge into the active segment,
1441
+ then B's compaction request. Before the fix, 0 of B's 157 records die and
1442
+ the request returns NOENT. With deviation 34 but not 35, the compaction
1443
+ drops 29 of the 157.
1444
+
1445
+ The quota tests read the files under the engine's reader gate, the way a
1446
+ statement does (reclamation runs at a 1 ms grace there), and a partition
1447
+ they cannot read fails the test instead of reading as an empty live set.
1448
+ The planner's counters are atomic (ThreadSanitizer: quotaStats() read them
1449
+ while writer 0 counted).
1450
+
1451
+ After the fix (Docker Linux, Debug, the test alone, looped):
1452
+
1453
+ | Commit | Machine | Load | Runs | Failures |
1454
+ |---|---|---|---|---|
1455
+ | bedfe06 (deviation 34) | linux/arm64 | 4 CPUs, stress-ng on 2 | 520 | 0 |
1456
+ | 5f4af36 (34, 35) | linux/amd64 | 4 CPUs, stress-ng on 2 | 520 | 0 |
1457
+ | a416695 | linux/arm64 | 3 CPUs, stress-ng on 3 | 520 | 0 |
1458
+
1459
+ The quota tests also pass under ThreadSanitizer (linux/arm64). The native
1460
+ suite (Mac 76 tests; Linux ctest 14 of 14), `crash_faults_T1_1_full` (10,000
1461
+ trials) and `orphan_crash_points_during_compaction_T3_4_full` pass. The T3 #4
1462
+ harness's arrivals check ran on a second reader instance the reader gate did
1463
+ not cover, so a statement could lose a file to reclamation and end
1464
+ SNAPSHOT_GONE (on 2f6d86e too: seed 9003, trial 48); the gate now covers both.
1465
+
1466
+ `quota_disk_full_resumes_without_operator_T3_6` could stay in its first
1467
+ emergency past the test's minute on a loaded box (one episode, three
1468
+ segments evicted, the ballast never back). It predated this change: on
1469
+ linux/amd64 Debug at a host load near 40, 4 of 100 runs on 2f6d86e and 1 of
1470
+ 100 here; under ThreadSanitizer, 3 of 6 and 1 of 10. Root cause and fix: §38.
1471
+
1472
+ # Part V: reader memory
1473
+
1474
+ ## 37. Reader memory is bounded by bytes, not by the store
1475
+
1476
+ A point reader instance grew while a writer committed: about 5 MB per 20,000
1477
+ statements in SDN's probe, a guest `bad_alloc` at 28 minutes in T6's daemon
1478
+ soak, and flat once ingest stopped. Nothing leaked per statement (SQLite
1479
+ allocates from the lane's fixed arena, every statement is finalized). A cache
1480
+ had no byte bound:
1481
+
1482
+ - **The lane-private front** of the shared cache (`LaneStore::front_`) was
1483
+ bounded by 65,536 entries only. Every shared-cache hit and put entered it,
1484
+ so it kept every L0 directory and section, fence vector and bloom the lane
1485
+ had used after the 16 MiB shared cache evicted them. Every commit and merge
1486
+ adds keys (type L0 sections are keyed by block offset), so under ingest it
1487
+ only grew; the entry cap lay gigabytes away.
1488
+ - A resident run pinned its fences and blooms without charging them to the
1489
+ lane's run budget.
1490
+ - The shared cache inserted an object larger than its shard's share of the
1491
+ budget after emptying the shard (up to 64 x the largest object over
1492
+ budget); the private cache did the same with an object over its budget.
1493
+ - The set of runs a lane had verified grew by one entry per run ever opened.
1494
+ - A run's fences were read whole per kind: 40 bytes per 4 KiB block, about
1495
+ 1% of the run, so a lookup in a large type run held its fences whole.
1496
+
1497
+ Built:
1498
+
1499
+ - The front is an LRU by bytes (`LaneStoreConfig::frontBytes`, set to
1500
+ `ReaderConfig::laneCacheBytes`) and by entries.
1501
+ - `ReaderCache` never caches an object larger than a shard's share, and has
1502
+ one shard per MiB of budget (1 to 64: 16 at the default 16 MiB, so a shard
1503
+ holds the largest L0 sections). The private cache never caches an object
1504
+ larger than its budget. Such an object is read again by the next statement
1505
+ that needs it. A manifest is charged its memory (about 200 bytes per
1506
+ segment), not its file size.
1507
+ - A resident run is charged its blooms.
1508
+ - The verified runs are a 1,024-entry LRU of runs evicted from the lane's
1509
+ run cache (a resident run needs no entry).
1510
+ - **Fence pages.** `FenceView` reads a kind's fences a page at a time
1511
+ (`ReaderConfig::fencePageEntries`, 128 fences, 5 KiB) through the shared
1512
+ cache: lookups binary-search across pages, scans walk them, GONE counts sum
1513
+ them. A lookup holds one page whatever the run's size.
1514
+
1515
+ **The bound.** Per reader instance, index state is at most
1516
+
1517
+ cacheBytes + lanes x (3 x laneCacheBytes + maxHandlesPerLane x 256 B + 1,024 x 128 B)
1518
+
1519
+ (the instance cache; per lane its private cache, resident runs and front,
1520
+ its handle table and verified runs): 42.25 MiB with the defaults (16 MiB,
1521
+ 4 MiB, 2 lanes, 4,096 handles), on top of the fixed arenas and slots. It does
1522
+ not depend on the store's size, the statement count or the commit rate.
1523
+
1524
+ **Tests.** `ps_test_main.cpp` gives every test allocation a 16-byte header
1525
+ and counts the live bytes allocated on reader lane threads, the reader's
1526
+ state beyond its fixed arenas, wherever they are freed.
1527
+
1528
+ - `reader_point_memory_plateaus_under_commits`: a 2-lane point instance with
1529
+ a 1 MiB instance cache and 256 KiB lane caches runs 164,000 statements
1530
+ (GetRecord by CID and a CID IN at type level, a partition point read) from
1531
+ two clients while producers commit and merges run, then idle rounds. It
1532
+ checks the bound, the lanes' budgets after every round, a flat second half
1533
+ and flat idle rounds. Mac, native: 2.7-3.2 MiB against the 3.9 MiB bound;
1534
+ the engine before this change reaches 7.9 MiB in the same run (linear, 1.1
1535
+ MiB per 20,000 statements) and fails. Under the Node wasm host: 2.72-2.76
1536
+ MiB.
1537
+ - `reader_lookups_and_scans_across_fence_pages`: two fences per page against
1538
+ the default and the records written: type and partition point lookups,
1539
+ index range scans both ways, offset paging after deaths (17,986 fence pages
1540
+ past the first read in one run). `fanout_randomized_vs_bruteforce_small_fence_pages`
1541
+ and `offset_paging_matches_reference_small_fence_pages` rerun those
1542
+ suites with two per page; `--fence-page=N` sets it for every reader the
1543
+ fixtures build (the default suite passes with 2).
1544
+ - `reader_memory_soak_writer` and `reader_memory_soak_reader` (slow, named):
1545
+ two processes on one directory. The writer grows the store past
1546
+ `--store-mib` (16 partitions, 1.8 KB records, 12 MiB/s) and appends acked
1547
+ CIDs to a file; the reader (native, or the wasm command under the Node host)
1548
+ looks them up in rounds of 20,000 and reports its lane live bytes and its
1549
+ process memory.
1550
+
1551
+ Soak, store 65 MiB to 1,200 MiB, Mac Studio (Node 25 for wasm, heap
1552
+ pre-grown to `PS_WASM_HEAP_MB`):
1553
+
1554
+ | Reader | Caches | Statements | Lane live bytes | Process |
1555
+ |---|---|---|---|---|
1556
+ | native, before | 2 MiB / 512 KiB | 860,000 | 3.1 -> 57.2 MiB, linear | RSS 21.0 -> 90.2 MiB |
1557
+ | native, after | 2 MiB / 512 KiB | 820,000 | 2.4 -> 3.4 MiB (bound 9.25) | RSS 19.6 -> 28.3 MiB |
1558
+ | native, after | defaults | 840,000 | 2.7 -> 15.1 MiB (bound 44.25), filling its caches | RSS 20.8 -> 42.9 MiB |
1559
+ | wasm, before | 2 MiB / 512 KiB | 800,000 | 2.7 -> 61.4 MiB, linear | linear memory 68.2 -> 103.5 MiB |
1560
+ | wasm, after | 2 MiB / 512 KiB | 1,040,000 | 2.1 -> 3.3 MiB | linear memory 68.2 MiB throughout |
1561
+ | wasm, after | defaults | 800,000 | 2.3 -> 15.7 MiB (bound 44.25) | linear memory 132.2 MiB throughout |
1562
+
1563
+ Native RSS beyond the live bytes is the allocator's high water and the
1564
+ harness's CID list (2.7 MiB). The soak reader's frames are never rebuilt:
1565
+ `ommRecord` computes `0.0001 + meanMotion * 1e-6`, which one target contracts
1566
+ to a fused multiply-add and another does not, so about 11% of a native
1567
+ writer's records have other CIDs when a wasm reader rebuilds them.
1568
+
1569
+ **What else grows with the store** (bytes per record or segment; none is
1570
+ held across statements by the reader beyond the budgets above):
1571
+
1572
+ | Where | What | Size | Status |
1573
+ |---|---|---|---|
1574
+ | reader: `snapshot.cpp` `loadManifest` | a partition's manifest, per statement | about 200 B per segment (3 KiB per GiB at 64 MiB segments) | cached within the lane budget; one larger than it (past about 1.3 TB in one partition) is read per statement: needs a paged manifest |
1575
+ | reader: `LazyRun::open` | the run's metadata CRC, once per lane | reads 1% (fences) plus the blooms (1.25 B per entry) of every run it opens | memory bounded (1 MiB buffer); the reads grow with the run: needs per-page CRCs |
1576
+ | reader: `loadType` | arrivals fence and segment starts, per statement | 48 B per 64 MiB arrivals segment (2.8M records) | small |
1577
+ | reader: labels past 128 partitions, registry, vtab schema | per partition | not per record | small |
1578
+ | writer: `L1Run::load` (`index_l1.cpp:168`) | every run's fences and all its blooms, held by `SegRun::run` for each warm partition's segments and each type's catalog runs | 1% of each run plus 1.25 B per entry | grows with the store: a terabyte store holds gigabytes in the writer instance; needs the reader's paging |
1579
+ | writer: `SegmentInfo::cdir` (`compaction.cpp:382`) | a compacted segment's presence directory, kept once loaded | 0.13 B per record | grows with the store |
1580
+ | writer: `Partition::segs`, `summary`, the file ledger | per segment | a few hundred bytes per segment | grows with segments |
1581
+
1582
+ # Part VI: memory safety and races
1583
+
1584
+ ## 38. The ps-wasm trap, the sanitizers, the first emergency
1585
+
1586
+ Task flatsql-ps-memory-safety-races-20260929. Machines: the owner's Mac
1587
+ Studio (Darwin 25.3.0, arm64, 28 hardware threads) shared with other lanes
1588
+ (1-minute load 17–95 during these runs), and linux/arm64 in Docker Desktop on
1589
+ it (gcc 13 and clang 18, `--cpus 4` with `stress-ng` on one CPU unless noted).
1590
+
1591
+ **The ps-wasm trap is V8's shared-memory grow race, not an engine overrun**
1592
+ (PARTITION-STORE-WASM.md §4.3). CI's trap was a `memory.fill` right after an
1593
+ `operator new` on the type-merge helper, into memory another thread had just
1594
+ grown; V8 bounds-checks it against the thread's stale view of the memory's
1595
+ size. The wasm test main and `createPsNodeInstance` now grow the heap to the
1596
+ memory's maximum before any guest thread starts, and the Node host reports
1597
+ any growth after threads start. Natively, under ASan and UBSan, T2_1 found no
1598
+ memory error (loops below). UBSan found two defects:
1599
+ - A misaligned `uint64_t` reference: `Counters` is packed (on-disk).
1600
+ `Partition::counters` is now 8-aligned.
1601
+ - Null-pointer arithmetic in `EntryIter::next` (index_l0.cpp). That fix
1602
+ lands with flatsql-format2-query-gaps.
1603
+
1604
+ Under WasmEdge the same runs exposed a WasmEdge 0.16.4 AOT defect: atomic
1605
+ wait and notify dropped the memarg offset. SDN's static runtime carries the
1606
+ fix, patch `04-atomic-memarg-offset` (SDN 74db37e14). `sleepNs` passes its
1607
+ address through a volatile, so its wait carries no memarg offset.
1608
+ `memory_safety_sleep_and_notify_at_folded_offsets` fails on a runtime without
1609
+ the fix.
1610
+
1611
+ **ThreadSanitizer.** The whole default suite runs TSAN-clean (Docker, gcc 13
1612
+ `-fsanitize=thread`, `--cpus 6`) apart from the stage-1 races below. Each
1613
+ race found:
1614
+
1615
+ | Where | What | Verdict, change |
1616
+ |---|---|---|
1617
+ | partition_log.cpp:2509 (`partitionPublish`) against type_owner.cpp:671 (`typeStage`) | The owner publishes a partition's commitSeq, pseqHi and L0 directory inside its seqlock; the type owner copies them and retries on a moved sequence. | Benign by design (a seqlock), but a plain copy on both sides is a data race in C++. Both sides now copy 8-byte words with relaxed atomic accesses (`publishPartition`, `readPublishedPartition`, writer.h). The sequence counter's fences order them. `PublishedPart::l0` is 8-aligned. `memory_safety_seqlock_publication_consistent`: readers racing a publishing owner only ever copy out whole states. |
1618
+ | writer_pool.cpp:230 (`SyncPool::runAll`) against `helpOne` | A pool thread reads a slot's `jobs` pointer while the writer publishes its next round; that stale pointer's claim then fails. | Benign by design. The pointer is `std::atomic` (relaxed); the round's `n` (release/acquire) orders the jobs. `memory_safety_sync_pool_rounds_run_each_job_once`: 6 writers × 400 rounds, each job runs exactly once with its own result, and the pool threads help. |
1619
+ | lane_arena.cpp:415 (`mxAlloc`) | Every lane's connection allocates SQLite's static mutexes again, which rewrote their shared wrappers. | Real (same values, rewritten under readers). The wrapper is filled once (`std::call_once`). |
1620
+ | lane.cpp:930 (`oldestActiveStart`) against `~ReaderInstance` | `Engine::setReaderGate` returned while a writer thread could still be inside the previous gate function, and the caller then destroyed the reader instance it reads. | Real: a use-after-free window. `setReaderGate` now clears the gate, waits for the gate calls in flight (a counter), then installs the new pair. |
1621
+ | merge.cpp:732 against open_test.cpp:296; reader_concurrency_test.cpp:216; compaction_test.cpp:565 | Tests read the owner's `nL0` from the main thread, or a latency series without its lock. | Test races. The tests read the published directory and take the lock. |
1622
+ | stage1.cpp:322 against stage1.cpp:499 (prep slots); ring.cpp:125 (a helper copies an entry the owner has consumed) | The owner republishes a slot it stole from a helper while the helper still reads it. | Benign by design (the helper's result is discarded by a failing CAS), and memory-safe (the copy stays inside the slab pool). Atomic slot fields and a racy-copy ring read belong to flatsql-ps-partition-bookkeeping-linear. |
1623
+
1624
+ **T3 #6: the first emergency could stall for good** (§36). Traced under
1625
+ TSAN:
1626
+ - The eviction wave's partition had a full L0 directory (47 blocks) from
1627
+ ingest before the emergency, so its TOMB_RANGE needed a merge first.
1628
+ - Meanwhile the room the ballast gave back was spent by maintenance outside
1629
+ the eviction: the other partition's merges, and a compaction nobody
1630
+ requested. Its build failed NOSPACE and started over with a new intent
1631
+ batch in the meta log about ten times a second. Usage crept 8,960 B/s until
1632
+ the device was exactly full.
1633
+ - From then on no batch committed. The wave's merge could not write outputs
1634
+ and no TOMB step could stage, for the rest of the minute.
1635
+
1636
+ 36. **In a space emergency, maintenance leaves the ballast's room to the
1637
+ eviction** (A13 assumes the ballast holds one segment's tombstones, and
1638
+ says nothing of what else may spend it). Only a partition with eviction
1639
+ work waiting merges (TOMB_RANGE steps, type-level kills, a requested
1640
+ compaction: `partitionWantsMerge`). A compaction the planner did not
1641
+ request does not start (`Writer::maintenance`); one in flight finishes.
1642
+ Ring entries stop `kL0ControlSlots` (4) L0 slots before the directory's
1643
+ cap, which mailbox kills and TOMB_RANGE steps may use, so a wave's first
1644
+ steps never wait for a merge.
1645
+
1646
+ Measured, in Docker:
1647
+ - **Before:** under TSAN, 4 of 12 runs, and 1 of 7 traced ones, stayed in
1648
+ the first emergency until the test's limit (70 s).
1649
+ - **After:** 50 of 50 TSAN runs recovered (whole test 19–43 s), and 340 of
1650
+ 340 Debug runs (gcc `-O0`, 8–10 s each). The test also passes natively on
1651
+ the Mac and under the Node host.
1652
+
1653
+ **Loops** (Docker runs had a CPU hog on one of their CPUs; the Mac ran at
1654
+ load 17–95):
1655
+
1656
+ | Item | Loop | Runs | Result |
1657
+ |---|---|---|---|
1658
+ | The trap | T2_1 under the Node host, heap grown to the maximum (Mac) | 500 | 0 traps. No run grew memory after a thread started. One run ended in a Node 25.4.0 SIGILL inside V8's JIT code (a host crash, not a guest trap). |
1659
+ | The trap | T2_1, native, ASan + UBSan | 488 before the T3 #6 change, then more on these sources | 0 ASan errors. UBSan reports only index_l0.cpp:319. |
1660
+ | The trap | T2_1 memio, WasmEdge 0.16.4 AOT with patch 04, no pre-grow (Mac) | 140 | 0 traps, 0 hangs. 2 failed: the memio command keeps every file in guest memory, and one run ran out of the 4 GiB address space (passing runs end near 2.7 GiB after about 500,000 records). The other run's output was not kept. |
1661
+ | Seqlock, sync pool | `memory_safety_s*` under TSAN | 520 | 0 warnings, 0 failures |
1662
+ | All races | The default suite under TSAN | 1 | Clean except the stage-1 races above. `arrivals_paging_while_writers_produce_T2_6` misses its 60 s label wait under TSAN, exactly as on 14a3075. `reader_point_memory_plateaus_under_commits` misses its idle-round bound under TSAN (0.155 MiB against 64 KiB). Both pass natively and under the Node host. |
1663
+ | T3 #6 | TSAN; Debug | 50; 340 | 0 stalls |
1664
+
1665
+ **Writer memory that grows with the store.** §37's table lists the writer's
1666
+ per-store structures. Measured here with 200,000 OMM records in one partition
1667
+ at the defaults:
1668
+ - A warm partition's L1 accelerators (`SegmentInfo::runs`, loaded for every
1669
+ segment by `partitionWarm`, merge.cpp:172) hold 6.0 B per record of the
1670
+ partition's history. A partition written without a pause never cools
1671
+ (`idleCloseMs`).
1672
+ - A type's catalog accelerators (`TypeOwner::runs`, loaded by `typeWarm`,
1673
+ type_owner.cpp:580) hold 3.45 B per record of the type. A type owner never
1674
+ cools.
1675
+ - Every registered partition keeps a 5,952-byte `Partition` (writer.h:505)
1676
+ plus its ring descriptor, active or not.
1677
+
1678
+ At 10^9 records (a terabyte of OMM-sized records) the catalog alone is
1679
+ 3.4 GB in one writer instance, over the wasm32 limit.
1680
+
1681
+ # Part VII: query gaps
1682
+
1683
+ ## 39. Query gaps found on the host-02 fixture (T6)
1684
+
1685
+ T6 compared format 2 with format 1 on a host-02-sized migrated store (4.36 M
1686
+ records: OMM 1.70 M in one partition, MPE 1.69 M, CAT 141 k, IQC 419 k held by
1687
+ two producers). Five read shapes were slower than format 1, and store-migrate
1688
+ refused one record shape. Each is now an engine plan or check, held to a
1689
+ reference by `cpp/test/ps/query_gaps_test.cpp` (`query_gaps_*`) and to format 1
1690
+ by SDN's fixture comparison.
1691
+
1692
+ **Text CID order (A17).** `ORDER BY _cid [DESC]` with no other index
1693
+ condition is its own plan (`kAccCidOrder`). At type level it reads the cid
1694
+ catalog (`kIxTypeCid`), whose keys are the A17 sort key: one ordered pass
1695
+ gives the live CIDs in text order. A key's entries resolve per copy (the
1696
+ latest type commit wins; DEAD over the rest at an equal tcs, as `catalog()`
1697
+ does); the live FIRST or PROMOTED copy is the record, and only its row is
1698
+ read. An `OFFSET` with no other condition is pushed down and counted from
1699
+ catalog entries alone: no row, frame or posting of a skipped record is read.
1700
+ At partition level the plan reads the partition's CID postings. With other
1701
+ conditions the plan still gives the order; the conditions are checked per
1702
+ row.
1703
+
1704
+ **Per-object point profiles (A18).** Hidden input columns `_asof`,
1705
+ `_forward` and `_nearest` (epoch seconds, `=` only) select `kAccObjPoint`.
1706
+ Per object key it returns every live type-level row at the object's best
1707
+ second: `_asof` the latest second at or before T, `_forward` the earliest at
1708
+ or after, `_nearest` the closer of the two with a tie to the earlier. The
1709
+ plan reads the `OBJECT_EPOCH` postings `(object key, epoch)` of every
1710
+ partition, restricted by the manifests' epoch zone maps to the segments that
1711
+ can hold a candidate, merges the partitions by object key, and reads rows only
1712
+ for the candidates of each object's best seconds (from the closest outward,
1713
+ until one is live). Tag conditions and one `_epoch` range are applied before
1714
+ the choice; any other condition is refused (`SQLITE_CONSTRAINT`: SQLite would
1715
+ apply it after the choice, which is another query). `_object` projects the
1716
+ key: a u64 key in decimal, otherwise the (capped) string, NULL for a record
1717
+ without one. Records without an object key are read only from partitions whose
1718
+ `OBJECT_EPOCH` postings are fewer than their CID postings (the EPOCH index,
1719
+ their frames); each is its own entity. For OMM (NORAD, then OBJECT_ID) and MPE
1720
+ (ENTITY_ID) the object key is the legacy entity key, so SDN ranks the
1721
+ candidates exactly as format 1 did.
1722
+
1723
+ **The sandbox window (A18).** Untrusted SQL reads `<TYPE>`, `<TYPE>@<source>`
1724
+ and every other type-level shape except a CID or gseq lookup from the arrivals
1725
+ tail: the newest N entries (`hotWindow`, dead entries included), the
1726
+ statement's conditions applied per row. An alias or source statement no longer
1727
+ walks every posting of its source; its work is bounded by N whatever the
1728
+ store's size.
1729
+
1730
+ **Tag conditions on every copy (A2).** Type-level tag conditions (`_provider`,
1731
+ `_source_name`, `_batch`, `_peer_id`, `_source`, and the alias source) match a
1732
+ record when a live instance of any live copy (FIRST or REPEAT, any partition
1733
+ the plan reads) meets all of them, as the legacy tag table held every
1734
+ producer's tags per record. This extends §31.1 and T2 deviation 8.
1735
+ Row-driven plans check the FIRST copy's own tag first, then the other copies'
1736
+ own tags (listed by the cid catalog, only when the type has REPEAT postings),
1737
+ then RETAG instances. Posting-driven plans (tag, source, collected pages) let
1738
+ a live REPEAT copy's instance stand for its record: the record's FIRST row is
1739
+ emitted by the first matching copy in (FIRST, then REPEATs by pid, pseq)
1740
+ order, so each record comes once. `<TYPE>@<source>` is `<TYPE>` with that
1741
+ condition. The checks cost little per row: an instance's tuple is its lane's
1742
+ (`RecRow.laneId`, the partition's lane table read once per statement), a copy
1743
+ whose pseq is above the highest `max_pseq` of the lanes that meet the
1744
+ conditions cannot match (its RETAGs come after it), TAG_OF lookups read only
1745
+ the segments that can hold them and resume in the block the previous row's
1746
+ lookup read, and DEAD / TAG_DEAD lookups are skipped for a snapshot that holds
1747
+ no posting of the kind.
1748
+
1749
+ **Gseq-ordered tag pages (A16).** At type level, `ORDER BY _gseq` with tag
1750
+ conditions and a LIMIT (or a closed gseq range) is served in arrivals order
1751
+ with each row's tags checked, unless the lane counters say the tags are rare
1752
+ (at most 262,144 matching instances and under an eighth of the type's
1753
+ arrivals): then the tags' postings are collected (the most selective of batch,
1754
+ source, provider, peer), sorted by gseq and emitted in order. A datasync page
1755
+ by source no longer sorts every match of the source.
1756
+
1757
+ **Records stored with their own size prefix.** A record that carries its own
1758
+ size prefix (a `FinishSizePrefixed` buffer stored as is: SDN's
1759
+ dataset-publication PNMs and the local EPM) was refused with `kRejFid` (its
1760
+ identifier sits at frame offset 12), so store-migrate rejected 131 records of a
1761
+ dev node and refused to activate. `frameRootOffset()` (`extract.h`) finds the
1762
+ FlatBuffer after both prefixes (the record's u32 equals `len - 8` and the
1763
+ identifier is at 12) for the frame check, the verifier (at the record's own
1764
+ alignment origin), key extraction and column projection. The stored bytes and
1765
+ the CID (over the record, prefix included) are unchanged.
1766
+
1767
+ **Reads ahead.** Rows met in ascending pseq order (arrivals order, epoch and
1768
+ tag postings, pseq scans) are read 32 at a time, and a frame read covers the
1769
+ frames of the rows read ahead in its segment (up to 256 KiB).
1770
+ `rowsExamined` still counts the rows a statement uses.
1771
+
1772
+ **Measured** through SDN's storage API on the fixture (`TestZZBench`-style
1773
+ calls, each query twice in a fresh process: the first call pays the
1774
+ instance's warm-up and the page cache; format 1 is the same store before
1775
+ migration). Mac Studio (M3 Ultra, 28 cores), shared with other lanes, load
1776
+ 47–55. Format 2 "before" is T6's run on the same fixture.
1777
+
1778
+ | Gap | Query | Format 1 (call 1 / 2) | Format 2 before | Format 2 after (call 1 / 2) |
1779
+ |---|---|---|---|---|
1780
+ | 1 | OMM CID order, LIMIT 500 OFFSET 1000 | 730 ms / 26 ms | 9.9–28.4 s | 2.65 s / 3.6 ms |
1781
+ | 1 | CAT CID order, LIMIT 200 OFFSET 60000 | 2.39 s / 67 ms | 430–537 ms | 589 ms / 11 ms |
1782
+ | 1 | IQC CID order, LIMIT 1000 OFFSET 100000 | 3.90 s / 153 ms | 5.0–5.5 s | 4.14 s / 35 ms |
1783
+ | 2 | OMM `nearest` (32,015 objects) | 99 s / 22.7 s | 56–79 s | 10.6 s / 2.3 s |
1784
+ | 2 | OMM `as_of`, one source | 36 s / 19.5 s | 9.7–13.1 s | 3.9 s / 4.2 s |
1785
+ | 2 | OMM `forward` | 14.6 s / 19.5 s | 8.4–82 s | 6.8 s / 6.1 s |
1786
+ | 2 | MPE `nearest`, 2 h delta | 50 s / 17.6 s | 29–35 s | 7.1 s / 6.1 s |
1787
+ | 3 | sandbox `SELECT _data FROM "CAT@celestrak-satcat"` (N = 10,000) | 4.4 / 3.9 ms¹ | `timeout` (work budget) | 55 / 11 ms |
1788
+ | 3 | `"CAT@celestrak-satcat-csv"` | 1.3 / 1.3 ms¹ | `timeout` | 3.2 / 4.5 ms |
1789
+ | 3 | `"IQC@IQEngine"` | 14.8 / 13.3 ms¹ | `timeout` | 67 / 32 ms |
1790
+ | 3 | `"MPE@celestrak-gp"` | 3.2 / 4.3 ms¹ | `timeout` | 68 / 7.3 ms |
1791
+ | 4 | IQC source window, LIMIT 1000 (two producers) | 12.7 s / 2.0 s | 111–121 ms (per partition, merged in SDN) | 183 / 30 ms (one statement) |
1792
+ | 5 | IQC datasync by source, 5 pages of 500 | 133 s / 190 s | about 3.8 s a page | 58 / 32 ms (all 5) |
1793
+
1794
+ ¹ Format 1's hot window is an in-memory copy of the newest N records, filled
1795
+ by a hydration (17 s to 5.5 min on this fixture) and held in the arena whose
1796
+ growth is what format 2 replaces. Format 2 reads the window from disk: the
1797
+ engine's own cost for the CAT query is 2.4 ms natively (the rest is the wasm
1798
+ instance, the result ring and SDN's copy). Gap 3's acceptance (the statement
1799
+ answers within the work budget, bounded by N) is met; parity with the
1800
+ in-memory copy is not.
1801
+
1802
+ The first call of a fresh process pays the instance's warm-up and reads the
1803
+ cid catalog's blocks into the page cache (2.65 s for OMM against 730 ms for
1804
+ format 1's index); every later call is faster than format 1.
1805
+ `TestFormat2DaemonReadsEqualTheLegacyFixture` (SDN) passes with every section
1806
+ (windows, A17 exports, A16 syncs, epoch profiles, A18 relations) equal to
1807
+ format 1 on this fixture.
1808
+
1809
+ **store-migrate with size-prefixed records.** A copy of a dev node's store
1810
+ (9.2 GB control database, 163 PNMs in 37 partitions, 1 EPM): 0 copies
1811
+ rejected (131 before), partitions (58) and lanes (58) equal, 9 of 10 CID
1812
+ sequences equal. The tenth (IQC) differs because that store's index holds
1813
+ about 1.06 M IQC rows no producer table holds (orphans the legacy verifier's
1814
+ sequence includes; filed for SDN). `TestStoreMigrateActivatesWithSizePrefixedRecords`
1815
+ (SDN): a store with 12 PNMs in two partitions and an EPM migrates with 0
1816
+ rejects and 0 mismatches, activates, and serves the same bytes.
1817
+
1818
+ **What these cost at 1 TB** (per statement; P partitions of the type, S
1819
+ segments per partition, R type catalog runs):
1820
+
1821
+ - CID order: `(offset + limit) x copies per CID` catalog entries of about
1822
+ 72 B (about 56 per 4 KiB block) plus one row read per emitted record. The
1823
+ skip is linear in the offset, as format 1's b-tree OFFSET is. Per-block live
1824
+ counts in the catalog's fences would make it logarithmic, but a CID's copies
1825
+ die in later type commits than their FIRST labels, so the type owner would
1826
+ have to post a CID-keyed marker when a CID's last copy dies (outside this
1827
+ change: `type_owner.cpp`).
1828
+ - Point profiles: the `OBJECT_EPOCH` postings (about 30 B each) of the
1829
+ segments whose epoch zone can hold a candidate: for `_forward` near the
1830
+ present, the newest segments; for `_asof` and `_nearest`, the segments
1831
+ before (or around) T. No payload is read to rank; rows are read for about one
1832
+ to two candidates per object. Enumerating the objects stays linear in the
1833
+ postings of those segments: a per-partition object directory would make it
1834
+ proportional to the objects.
1835
+ - Sandbox window: at most N arrivals entries (24 B) and N rows, whatever the
1836
+ store's size.
1837
+ - Tag conditions: per row an O(1) lane check, and a TAG_OF lookup only for a
1838
+ copy that a matching lane can still reach; a catalog lookup (R bloom-gated
1839
+ runs) only in a type with REPEAT copies.
1840
+ - Gseq tag pages: LIMIT / selectivity arrival entries and rows per page
1841
+ (arrivals mode), or the tags' matching instances (collected mode, at most
1842
+ 262,144).
1843
+ - Size-prefixed records: nothing (a 4-byte comparison per record).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatsql",
3
- "version": "3.3.1",
3
+ "version": "3.5.0",
4
4
  "description": "SQL queries over raw FlatBuffer storage: the SQLite-backed wasm engine and the multithreaded partition store (flatsql-ps-threads.wasm)",
5
5
  "type": "module",
6
6
  "main": "wasm/index.js",
Binary file
Binary file
Binary file
package/wasm/flatsql.js CHANGED
@@ -1,2 +1,2 @@
1
- async function FlatSQL(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("module");var require=createRequire(import.meta.url)}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("path").dirname(require("url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["Va"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("flatsql.wasm")}return new URL("flatsql.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmExports=applySignatureConversions(wasmExports);assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var exceptionCaught=[];var uncaughtExceptionCount=0;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);function ___cxa_begin_catch(ptr){ptr>>>=0;var info=new ExceptionInfo(ptr);if(!info.get_caught()){info.set_caught(true);uncaughtExceptionCount--}info.set_rethrown(false);exceptionCaught.push(info);return ___cxa_get_exception_ptr(ptr)}var exceptionLast=0;var ___cxa_end_catch=()=>{_setThrew(0,0);var info=exceptionCaught.pop();___cxa_decrement_exception_refcount(info.excPtr);exceptionLast=0};class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>>2>>>0]=type}get_type(){return HEAPU32[this.ptr+4>>>2>>>0]}set_destructor(destructor){HEAPU32[this.ptr+8>>>2>>>0]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>>2>>>0]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12>>>0]=caught}get_caught(){return HEAP8[this.ptr+12>>>0]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13>>>0]=rethrown}get_rethrown(){return HEAP8[this.ptr+13>>>0]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>>2>>>0]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>>2>>>0]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};function ___cxa_find_matching_catch_2(){return findMatchingCatch([])}function ___cxa_find_matching_catch_3(arg0){arg0>>>=0;return findMatchingCatch([arg0])}function ___cxa_find_matching_catch_4(arg0,arg1){arg0>>>=0;arg1>>>=0;return findMatchingCatch([arg0,arg1])}var ___cxa_rethrow=()=>{var info=exceptionCaught.pop();if(!info){abort("no exception to throw")}var ptr=info.excPtr;if(!info.get_rethrown()){exceptionCaught.push(info);info.set_rethrown(true);info.set_caught(false);uncaughtExceptionCount++}___cxa_increment_exception_refcount(ptr);exceptionLast=ptr;throw exceptionLast};function ___cxa_throw(ptr,type,destructor){ptr>>>=0;type>>>=0;destructor>>>=0;var info=new ExceptionInfo(ptr);info.init(type,destructor);___cxa_increment_exception_refcount(ptr);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast}var ___cxa_uncaught_exceptions=()=>uncaughtExceptionCount;function ___resumeException(ptr){ptr>>>=0;if(!exceptionLast){exceptionLast=ptr}throw exceptionLast}function ___syscall_chmod(path,mode){path>>>=0}function ___syscall_faccessat(dirfd,path,amode,flags){path>>>=0}var ___syscall_fchmod=(fd,mode)=>{};var ___syscall_fchown32=(fd,owner,group)=>{};var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{idx>>>=0;var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>{ptr>>>=0;return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead,ignoreNul):""};var SYSCALLS={varargs:undefined,getStr(ptr){var ret=UTF8ToString(ptr);return ret}};function ___syscall_fcntl64(fd,cmd,varargs){varargs>>>=0;SYSCALLS.varargs=varargs;return 0}function ___syscall_fstat64(fd,buf){buf>>>=0}function ___syscall_ftruncate64(fd,length){length=bigintToI53Checked(length)}function ___syscall_getcwd(buf,size){buf>>>=0;size>>>=0}function ___syscall_lstat64(path,buf){path>>>=0;buf>>>=0}function ___syscall_mkdirat(dirfd,path,mode){path>>>=0}function ___syscall_newfstatat(dirfd,path,buf,flags){path>>>=0;buf>>>=0}function ___syscall_openat(dirfd,path,flags,varargs){path>>>=0;varargs>>>=0;SYSCALLS.varargs=varargs}function ___syscall_readlinkat(dirfd,path,buf,bufsize){path>>>=0;buf>>>=0;bufsize>>>=0}function ___syscall_rmdir(path){path>>>=0}function ___syscall_stat64(path,buf){path>>>=0;buf>>>=0}function ___syscall_unlinkat(dirfd,path,flags){path>>>=0}function ___syscall_utimensat(dirfd,path,times,flags){path>>>=0;times>>>=0}var __abort_js=()=>abort("");var isLeapYear=year=>year%4===0&&(year%100!==0||year%400===0);var MONTH_DAYS_LEAP_CUMULATIVE=[0,31,60,91,121,152,182,213,244,274,305,335];var MONTH_DAYS_REGULAR_CUMULATIVE=[0,31,59,90,120,151,181,212,243,273,304,334];var ydayFromDate=date=>{var leap=isLeapYear(date.getFullYear());var monthDaysCumulative=leap?MONTH_DAYS_LEAP_CUMULATIVE:MONTH_DAYS_REGULAR_CUMULATIVE;var yday=monthDaysCumulative[date.getMonth()]+date.getDate()-1;return yday};function __localtime_js(time,tmPtr){time=bigintToI53Checked(time);tmPtr>>>=0;var date=new Date(time*1e3);HEAP32[tmPtr>>>2>>>0]=date.getSeconds();HEAP32[tmPtr+4>>>2>>>0]=date.getMinutes();HEAP32[tmPtr+8>>>2>>>0]=date.getHours();HEAP32[tmPtr+12>>>2>>>0]=date.getDate();HEAP32[tmPtr+16>>>2>>>0]=date.getMonth();HEAP32[tmPtr+20>>>2>>>0]=date.getFullYear()-1900;HEAP32[tmPtr+24>>>2>>>0]=date.getDay();var yday=ydayFromDate(date)|0;HEAP32[tmPtr+28>>>2>>>0]=yday;HEAP32[tmPtr+36>>>2>>>0]=-(date.getTimezoneOffset()*60);var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dst=(summerOffset!=winterOffset&&date.getTimezoneOffset()==Math.min(winterOffset,summerOffset))|0;HEAP32[tmPtr+32>>>2>>>0]=dst}var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{outIdx>>>=0;if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++>>>0]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++>>>0]=192|u>>6;heap[outIdx++>>>0]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++>>>0]=224|u>>12;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++>>>0]=240|u>>18;heap[outIdx++>>>0]=128|u>>12&63;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63;i++}}heap[outIdx>>>0]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var __tzset_js=function(timezone,daylight,std_name,dst_name){timezone>>>=0;daylight>>>=0;std_name>>>=0;dst_name>>>=0;var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>>2>>>0]=stdTimezoneOffset*60;HEAP32[daylight>>>2>>>0]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}};var _emscripten_get_now=()=>performance.now();var _emscripten_date_now=()=>Date.now();var nowIsMonotonic=1;var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;function _clock_time_get(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);ptime>>>=0;if(!checkWasiClock(clk_id)){return 28}var now;if(clk_id===0){now=_emscripten_date_now()}else if(nowIsMonotonic){now=_emscripten_get_now()}else{return 52}var nsec=Math.round(now*1e3*1e3);HEAP64[ptime>>>3>>>0]=BigInt(nsec);return 0}var getHeapMax=()=>4294901760;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};function _emscripten_resize_heap(requestedSize){requestedSize>>>=0;var oldSize=HEAPU8.length;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false}var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};function _environ_get(__environ,environ_buf){__environ>>>=0;environ_buf>>>=0;var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>>2>>>0]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0}var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};function _environ_sizes_get(penviron_count,penviron_buf_size){penviron_count>>>=0;penviron_buf_size>>>=0;var strings=getEnvStrings();HEAPU32[penviron_count>>>2>>>0]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}HEAPU32[penviron_buf_size>>>2>>>0]=bufSize;return 0}var _fd_close=fd=>52;function _fd_fdstat_get(fd,pbuf){pbuf>>>=0;var rightsBase=0;var rightsInheriting=0;var flags=0;{var type=2;if(fd==0){rightsBase=2}else if(fd==1||fd==2){rightsBase=64}flags=1}HEAP8[pbuf>>>0]=type;HEAP16[pbuf+2>>>1>>>0]=flags;HEAP64[pbuf+8>>>3>>>0]=BigInt(rightsBase);HEAP64[pbuf+16>>>3>>>0]=BigInt(rightsInheriting);return 0}function _fd_read(fd,iov,iovcnt,pnum){iov>>>=0;iovcnt>>>=0;pnum>>>=0;return 52}function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);newOffset>>>=0;return 70}var _fd_sync=fd=>52;var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};function _fd_write(fd,iov,iovcnt,pnum){iov>>>=0;iovcnt>>>=0;pnum>>>=0;var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>>2>>>0];var len=HEAPU32[iov+4>>>2>>>0];iov+=8;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j>>>0])}num+=len}HEAPU32[pnum>>>2>>>0]=num;return 0}var flatsqlIoBridge={ERR_GENERIC:-1,ERR_NOENT:-2,ERR_ACCESS:-3,ERR_BADHANDLE:-6,backend:function(){return Module["flatsqlIO"]||null},path:function(ptr,len){return UTF8ToString(ptr,len)}};function _flatsql_io_close(handle){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.close(handle)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_open(pathPtr,pathLen,flags){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.open(flatsqlIoBridge.path(pathPtr,pathLen),flags)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_read(handle,dstPtr,len,offset){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.read(handle,HEAPU8.subarray(dstPtr>>>0,dstPtr+len>>>0),offset)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_size(handle){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.size(handle)}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_sync(handle){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.sync(handle)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_truncate(handle,size){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.truncate(handle,size)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_write(handle,srcPtr,len,offset){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.write(handle,HEAPU8.subarray(srcPtr>>>0,srcPtr+len>>>0),offset)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _llvm_eh_typeid_for(type){type>>>=0;return type}var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer>>>0)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="pointer")return ret>>>0;if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func(...cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret};var cwrap=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}Module["ccall"]=ccall;Module["cwrap"]=cwrap;Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;var _free,_malloc,_flatsql_create_db,_flatsql_open_db,_flatsql_is_disk_backed,_flatsql_open_state,_flatsql_reindex_all,_flatsql_reindex_step,_flatsql_flush_index,_flatsql_flushed_offset,_flatsql_stream_path,_flatsql_destroy_db,_flatsql_register_file_id,_flatsql_enable_demo_extractors,_flatsql_ingest,_flatsql_ingest_one,_flatsql_register_source,_flatsql_create_unified_views,_flatsql_ingest_with_source,_flatsql_ingest_one_with_source,_flatsql_set_arena_limit,_flatsql_query,_flatsql_query_params,_flatsql_query_many,_flatsql_batch_result_count,_flatsql_select_batch_result,_flatsql_get_error,_flatsql_build_query_cache_key,_flatsql_build_response_artifact_cache_key,_flatsql_register_query_template,_flatsql_query_template,_flatsql_clear_query_cache,_flatsql_configure_query_cache,_flatsql_query_cache_hits,_flatsql_query_cache_misses,_flatsql_query_cache_size,_flatsql_query_cache_generation,_flatsql_query_cache_max_entries,_flatsql_query_cache_max_rows,_flatsql_result_column_count,_flatsql_result_row_count,_flatsql_result_column_name,_flatsql_result_cell_type,_flatsql_result_cell_number,_flatsql_result_cell_string,_flatsql_result_cell_blob,_flatsql_result_cell_blob_size,_flatsql_export_data,_flatsql_query_raw_flatbuffer_stream,_flatsql_query_sandboxed,_flatsql_response_artifact_data,_flatsql_response_artifact_size,_flatsql_response_artifact_cache_hit,_flatsql_configure_raw_stream_cache,_flatsql_raw_stream_cache_hits,_flatsql_raw_stream_cache_misses,_flatsql_raw_stream_cache_size,_flatsql_raw_stream_cache_total_bytes,_flatsql_response_artifact_row_count,_flatsql_response_artifact_column_count,_flatsql_export_size,_flatsql_load_and_rebuild,_flatsql_reserve_storage,_flatsql_load_from_db,_flatsql_create_test_user,_flatsql_test_buffer_size,_flatsql_create_test_post,_flatsql_create_test_mpe,_flatsql_create_test_telemetry,_flatsql_create_test_publish_event,_flatsql_get_stats_count,_flatsql_get_stat_table_name,_flatsql_get_stat_file_id,_flatsql_get_stat_record_count,_flatsql_reset_ingest_profile,_flatsql_get_ingest_profile_record_count,_flatsql_get_ingest_profile_byte_count,_flatsql_get_ingest_profile_decode_nanos,_flatsql_get_ingest_profile_append_nanos,_flatsql_get_ingest_profile_index_nanos,_flatsql_mark_deleted,_flatsql_get_deleted_count,_flatsql_clear_tombstones,_flatsql_get_sources_count,_flatsql_get_source_name,_flatsql_get_flatbuffer_by_id,_flatsql_get_flatbuffer_by_email,_flatsql_get_flatbuffer_by_index,_flatsql_get_raw_flatbuffer_size,_flatsql_get_raw_flatbuffer_sequence,_flatsql_get_storage_buffer,_flatsql_get_storage_size,_flatsql_set_encryption_key,_flatsql_is_encrypted,_flatsql_encrypt_buffer,_flatsql_decrypt_buffer,_flatsql_ingest_one_encrypted,_flatsql_set_hmac_verification,_flatsql_is_hmac_enabled,_flatsql_compute_hmac,_flatsql_verify_hmac,_setThrew,__emscripten_tempret_set,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___cxa_decrement_exception_refcount,___cxa_increment_exception_refcount,___cxa_can_catch,___cxa_get_exception_ptr,dynCall_v,dynCall_ii,dynCall_iii,dynCall_viiiiii,dynCall_vii,dynCall_viii,dynCall_iiii,dynCall_iiiiii,dynCall_vi,dynCall_viiii,dynCall_jii,dynCall_viiiii,dynCall_iiiiiii,dynCall_iiiii,dynCall_i,dynCall_iiij,dynCall_iiid,dynCall_viijij,dynCall_viiijj,dynCall_jiiiii,dynCall_iiiiiiiiiiii,dynCall_vij,dynCall_iiji,dynCall_iijiii,dynCall_viijj,dynCall_jiiii,dynCall_viij,dynCall_iiiiiijii,dynCall_iid,dynCall_iiiiiji,dynCall_dii,dynCall_iiiiiiiiii,dynCall_iiiiiiii,dynCall_viijii,dynCall_di,dynCall_iiiid,dynCall_iij,dynCall_viidi,dynCall_vid,dynCall_vidd,dynCall_viiiji,dynCall_dd,dynCall_ddd,dynCall_viiiiiiii,dynCall_iiiddddddddi,dynCall_jiiiiiii,dynCall_iiiij,dynCall_vijii,dynCall_iijj,dynCall_iijii,dynCall_ji,dynCall_jiji,dynCall_iidiiii,dynCall_j,dynCall_iiiiij,dynCall_iiiiid,dynCall_iiiiiiiiiii,dynCall_iiiiiiiiiiiii,dynCall_fiii,dynCall_diii,dynCall_viiiiiii,dynCall_viiiiiiiiii,dynCall_viiiiiiiiiiiiiii,dynCall_iiiiiiiii,dynCall_iiiiijj,dynCall_iiiiiijj,memory,__indirect_function_table,wasmMemory,wasmTable;function assignWasmExports(wasmExports){_free=Module["_free"]=wasmExports["Xa"];_malloc=Module["_malloc"]=wasmExports["Ya"];_flatsql_create_db=Module["_flatsql_create_db"]=wasmExports["Za"];_flatsql_open_db=Module["_flatsql_open_db"]=wasmExports["_a"];_flatsql_is_disk_backed=Module["_flatsql_is_disk_backed"]=wasmExports["$a"];_flatsql_open_state=Module["_flatsql_open_state"]=wasmExports["ab"];_flatsql_reindex_all=Module["_flatsql_reindex_all"]=wasmExports["bb"];_flatsql_reindex_step=Module["_flatsql_reindex_step"]=wasmExports["cb"];_flatsql_flush_index=Module["_flatsql_flush_index"]=wasmExports["db"];_flatsql_flushed_offset=Module["_flatsql_flushed_offset"]=wasmExports["eb"];_flatsql_stream_path=Module["_flatsql_stream_path"]=wasmExports["fb"];_flatsql_destroy_db=Module["_flatsql_destroy_db"]=wasmExports["gb"];_flatsql_register_file_id=Module["_flatsql_register_file_id"]=wasmExports["hb"];_flatsql_enable_demo_extractors=Module["_flatsql_enable_demo_extractors"]=wasmExports["ib"];_flatsql_ingest=Module["_flatsql_ingest"]=wasmExports["jb"];_flatsql_ingest_one=Module["_flatsql_ingest_one"]=wasmExports["kb"];_flatsql_register_source=Module["_flatsql_register_source"]=wasmExports["lb"];_flatsql_create_unified_views=Module["_flatsql_create_unified_views"]=wasmExports["mb"];_flatsql_ingest_with_source=Module["_flatsql_ingest_with_source"]=wasmExports["nb"];_flatsql_ingest_one_with_source=Module["_flatsql_ingest_one_with_source"]=wasmExports["ob"];_flatsql_set_arena_limit=Module["_flatsql_set_arena_limit"]=wasmExports["pb"];_flatsql_query=Module["_flatsql_query"]=wasmExports["qb"];_flatsql_query_params=Module["_flatsql_query_params"]=wasmExports["rb"];_flatsql_query_many=Module["_flatsql_query_many"]=wasmExports["sb"];_flatsql_batch_result_count=Module["_flatsql_batch_result_count"]=wasmExports["tb"];_flatsql_select_batch_result=Module["_flatsql_select_batch_result"]=wasmExports["ub"];_flatsql_get_error=Module["_flatsql_get_error"]=wasmExports["vb"];_flatsql_build_query_cache_key=Module["_flatsql_build_query_cache_key"]=wasmExports["wb"];_flatsql_build_response_artifact_cache_key=Module["_flatsql_build_response_artifact_cache_key"]=wasmExports["xb"];_flatsql_register_query_template=Module["_flatsql_register_query_template"]=wasmExports["yb"];_flatsql_query_template=Module["_flatsql_query_template"]=wasmExports["zb"];_flatsql_clear_query_cache=Module["_flatsql_clear_query_cache"]=wasmExports["Ab"];_flatsql_configure_query_cache=Module["_flatsql_configure_query_cache"]=wasmExports["Bb"];_flatsql_query_cache_hits=Module["_flatsql_query_cache_hits"]=wasmExports["Cb"];_flatsql_query_cache_misses=Module["_flatsql_query_cache_misses"]=wasmExports["Db"];_flatsql_query_cache_size=Module["_flatsql_query_cache_size"]=wasmExports["Eb"];_flatsql_query_cache_generation=Module["_flatsql_query_cache_generation"]=wasmExports["Fb"];_flatsql_query_cache_max_entries=Module["_flatsql_query_cache_max_entries"]=wasmExports["Gb"];_flatsql_query_cache_max_rows=Module["_flatsql_query_cache_max_rows"]=wasmExports["Hb"];_flatsql_result_column_count=Module["_flatsql_result_column_count"]=wasmExports["Ib"];_flatsql_result_row_count=Module["_flatsql_result_row_count"]=wasmExports["Jb"];_flatsql_result_column_name=Module["_flatsql_result_column_name"]=wasmExports["Kb"];_flatsql_result_cell_type=Module["_flatsql_result_cell_type"]=wasmExports["Lb"];_flatsql_result_cell_number=Module["_flatsql_result_cell_number"]=wasmExports["Mb"];_flatsql_result_cell_string=Module["_flatsql_result_cell_string"]=wasmExports["Nb"];_flatsql_result_cell_blob=Module["_flatsql_result_cell_blob"]=wasmExports["Ob"];_flatsql_result_cell_blob_size=Module["_flatsql_result_cell_blob_size"]=wasmExports["Pb"];_flatsql_export_data=Module["_flatsql_export_data"]=wasmExports["Qb"];_flatsql_query_raw_flatbuffer_stream=Module["_flatsql_query_raw_flatbuffer_stream"]=wasmExports["Rb"];_flatsql_query_sandboxed=Module["_flatsql_query_sandboxed"]=wasmExports["Sb"];_flatsql_response_artifact_data=Module["_flatsql_response_artifact_data"]=wasmExports["Tb"];_flatsql_response_artifact_size=Module["_flatsql_response_artifact_size"]=wasmExports["Ub"];_flatsql_response_artifact_cache_hit=Module["_flatsql_response_artifact_cache_hit"]=wasmExports["Vb"];_flatsql_configure_raw_stream_cache=Module["_flatsql_configure_raw_stream_cache"]=wasmExports["Wb"];_flatsql_raw_stream_cache_hits=Module["_flatsql_raw_stream_cache_hits"]=wasmExports["Xb"];_flatsql_raw_stream_cache_misses=Module["_flatsql_raw_stream_cache_misses"]=wasmExports["Yb"];_flatsql_raw_stream_cache_size=Module["_flatsql_raw_stream_cache_size"]=wasmExports["Zb"];_flatsql_raw_stream_cache_total_bytes=Module["_flatsql_raw_stream_cache_total_bytes"]=wasmExports["_b"];_flatsql_response_artifact_row_count=Module["_flatsql_response_artifact_row_count"]=wasmExports["$b"];_flatsql_response_artifact_column_count=Module["_flatsql_response_artifact_column_count"]=wasmExports["ac"];_flatsql_export_size=Module["_flatsql_export_size"]=wasmExports["bc"];_flatsql_load_and_rebuild=Module["_flatsql_load_and_rebuild"]=wasmExports["cc"];_flatsql_reserve_storage=Module["_flatsql_reserve_storage"]=wasmExports["dc"];_flatsql_load_from_db=Module["_flatsql_load_from_db"]=wasmExports["ec"];_flatsql_create_test_user=Module["_flatsql_create_test_user"]=wasmExports["fc"];_flatsql_test_buffer_size=Module["_flatsql_test_buffer_size"]=wasmExports["gc"];_flatsql_create_test_post=Module["_flatsql_create_test_post"]=wasmExports["hc"];_flatsql_create_test_mpe=Module["_flatsql_create_test_mpe"]=wasmExports["ic"];_flatsql_create_test_telemetry=Module["_flatsql_create_test_telemetry"]=wasmExports["jc"];_flatsql_create_test_publish_event=Module["_flatsql_create_test_publish_event"]=wasmExports["kc"];_flatsql_get_stats_count=Module["_flatsql_get_stats_count"]=wasmExports["lc"];_flatsql_get_stat_table_name=Module["_flatsql_get_stat_table_name"]=wasmExports["mc"];_flatsql_get_stat_file_id=Module["_flatsql_get_stat_file_id"]=wasmExports["nc"];_flatsql_get_stat_record_count=Module["_flatsql_get_stat_record_count"]=wasmExports["oc"];_flatsql_reset_ingest_profile=Module["_flatsql_reset_ingest_profile"]=wasmExports["pc"];_flatsql_get_ingest_profile_record_count=Module["_flatsql_get_ingest_profile_record_count"]=wasmExports["qc"];_flatsql_get_ingest_profile_byte_count=Module["_flatsql_get_ingest_profile_byte_count"]=wasmExports["rc"];_flatsql_get_ingest_profile_decode_nanos=Module["_flatsql_get_ingest_profile_decode_nanos"]=wasmExports["sc"];_flatsql_get_ingest_profile_append_nanos=Module["_flatsql_get_ingest_profile_append_nanos"]=wasmExports["tc"];_flatsql_get_ingest_profile_index_nanos=Module["_flatsql_get_ingest_profile_index_nanos"]=wasmExports["uc"];_flatsql_mark_deleted=Module["_flatsql_mark_deleted"]=wasmExports["vc"];_flatsql_get_deleted_count=Module["_flatsql_get_deleted_count"]=wasmExports["wc"];_flatsql_clear_tombstones=Module["_flatsql_clear_tombstones"]=wasmExports["xc"];_flatsql_get_sources_count=Module["_flatsql_get_sources_count"]=wasmExports["yc"];_flatsql_get_source_name=Module["_flatsql_get_source_name"]=wasmExports["zc"];_flatsql_get_flatbuffer_by_id=Module["_flatsql_get_flatbuffer_by_id"]=wasmExports["Ac"];_flatsql_get_flatbuffer_by_email=Module["_flatsql_get_flatbuffer_by_email"]=wasmExports["Bc"];_flatsql_get_flatbuffer_by_index=Module["_flatsql_get_flatbuffer_by_index"]=wasmExports["Cc"];_flatsql_get_raw_flatbuffer_size=Module["_flatsql_get_raw_flatbuffer_size"]=wasmExports["Dc"];_flatsql_get_raw_flatbuffer_sequence=Module["_flatsql_get_raw_flatbuffer_sequence"]=wasmExports["Ec"];_flatsql_get_storage_buffer=Module["_flatsql_get_storage_buffer"]=wasmExports["Fc"];_flatsql_get_storage_size=Module["_flatsql_get_storage_size"]=wasmExports["Gc"];_flatsql_set_encryption_key=Module["_flatsql_set_encryption_key"]=wasmExports["Hc"];_flatsql_is_encrypted=Module["_flatsql_is_encrypted"]=wasmExports["Ic"];_flatsql_encrypt_buffer=Module["_flatsql_encrypt_buffer"]=wasmExports["Jc"];_flatsql_decrypt_buffer=Module["_flatsql_decrypt_buffer"]=wasmExports["Kc"];_flatsql_ingest_one_encrypted=Module["_flatsql_ingest_one_encrypted"]=wasmExports["Lc"];_flatsql_set_hmac_verification=Module["_flatsql_set_hmac_verification"]=wasmExports["Mc"];_flatsql_is_hmac_enabled=Module["_flatsql_is_hmac_enabled"]=wasmExports["Nc"];_flatsql_compute_hmac=Module["_flatsql_compute_hmac"]=wasmExports["Oc"];_flatsql_verify_hmac=Module["_flatsql_verify_hmac"]=wasmExports["Pc"];_setThrew=wasmExports["Qc"];__emscripten_tempret_set=wasmExports["Rc"];__emscripten_stack_restore=wasmExports["Sc"];__emscripten_stack_alloc=wasmExports["Tc"];_emscripten_stack_get_current=wasmExports["Uc"];___cxa_decrement_exception_refcount=wasmExports["Vc"];___cxa_increment_exception_refcount=wasmExports["Wc"];___cxa_can_catch=wasmExports["Xc"];___cxa_get_exception_ptr=wasmExports["Yc"];dynCall_v=wasmExports["Zc"];dynCall_ii=wasmExports["_c"];dynCall_iii=wasmExports["$c"];dynCall_viiiiii=wasmExports["ad"];dynCall_vii=wasmExports["bd"];dynCall_viii=wasmExports["cd"];dynCall_iiii=wasmExports["dd"];dynCall_iiiiii=wasmExports["ed"];dynCall_vi=wasmExports["fd"];dynCall_viiii=wasmExports["gd"];dynCall_jii=wasmExports["hd"];dynCall_viiiii=wasmExports["id"];dynCall_iiiiiii=wasmExports["jd"];dynCall_iiiii=wasmExports["kd"];dynCall_i=wasmExports["ld"];dynCall_iiij=wasmExports["md"];dynCall_iiid=wasmExports["nd"];dynCall_viijij=wasmExports["od"];dynCall_viiijj=wasmExports["pd"];dynCall_jiiiii=wasmExports["qd"];dynCall_iiiiiiiiiiii=wasmExports["rd"];dynCall_vij=wasmExports["sd"];dynCall_iiji=wasmExports["td"];dynCall_iijiii=wasmExports["ud"];dynCall_viijj=wasmExports["vd"];dynCall_jiiii=wasmExports["wd"];dynCall_viij=wasmExports["xd"];dynCall_iiiiiijii=wasmExports["yd"];dynCall_iid=wasmExports["zd"];dynCall_iiiiiji=wasmExports["Ad"];dynCall_dii=wasmExports["Bd"];dynCall_iiiiiiiiii=wasmExports["Cd"];dynCall_iiiiiiii=wasmExports["Dd"];dynCall_viijii=wasmExports["Ed"];dynCall_di=wasmExports["Fd"];dynCall_iiiid=wasmExports["Gd"];dynCall_iij=wasmExports["Hd"];dynCall_viidi=wasmExports["Id"];dynCall_vid=wasmExports["Jd"];dynCall_vidd=wasmExports["dynCall_vidd"];dynCall_viiiji=wasmExports["Kd"];dynCall_dd=wasmExports["dynCall_dd"];dynCall_ddd=wasmExports["dynCall_ddd"];dynCall_viiiiiiii=wasmExports["Ld"];dynCall_iiiddddddddi=wasmExports["Md"];dynCall_jiiiiiii=wasmExports["Nd"];dynCall_iiiij=wasmExports["dynCall_iiiij"];dynCall_vijii=wasmExports["dynCall_vijii"];dynCall_iijj=wasmExports["dynCall_iijj"];dynCall_iijii=wasmExports["dynCall_iijii"];dynCall_ji=wasmExports["dynCall_ji"];dynCall_jiji=wasmExports["dynCall_jiji"];dynCall_iidiiii=wasmExports["dynCall_iidiiii"];dynCall_j=wasmExports["Od"];dynCall_iiiiij=wasmExports["Pd"];dynCall_iiiiid=wasmExports["Qd"];dynCall_iiiiiiiiiii=wasmExports["dynCall_iiiiiiiiiii"];dynCall_iiiiiiiiiiiii=wasmExports["dynCall_iiiiiiiiiiiii"];dynCall_fiii=wasmExports["Rd"];dynCall_diii=wasmExports["Sd"];dynCall_viiiiiii=wasmExports["Td"];dynCall_viiiiiiiiii=wasmExports["Ud"];dynCall_viiiiiiiiiiiiiii=wasmExports["Vd"];dynCall_iiiiiiiii=wasmExports["dynCall_iiiiiiiii"];dynCall_iiiiijj=wasmExports["dynCall_iiiiijj"];dynCall_iiiiiijj=wasmExports["dynCall_iiiiiijj"];memory=wasmMemory=wasmExports["Ua"];__indirect_function_table=wasmTable=wasmExports["Wa"]}var wasmImports={l:___cxa_begin_catch,p:___cxa_end_catch,a:___cxa_find_matching_catch_2,d:___cxa_find_matching_catch_3,v:___cxa_find_matching_catch_4,da:___cxa_rethrow,o:___cxa_throw,ia:___cxa_uncaught_exceptions,e:___resumeException,Ha:___syscall_chmod,Ja:___syscall_faccessat,Ia:___syscall_fchmod,Ga:___syscall_fchown32,z:___syscall_fcntl64,Fa:___syscall_fstat64,Aa:___syscall_ftruncate64,za:___syscall_getcwd,Ca:___syscall_lstat64,va:___syscall_mkdirat,Da:___syscall_newfstatat,ra:___syscall_openat,pa:___syscall_readlinkat,oa:___syscall_rmdir,Ea:___syscall_stat64,na:___syscall_unlinkat,ma:___syscall_utimensat,ga:__abort_js,ta:__localtime_js,ua:__tzset_js,sa:_clock_time_get,X:_emscripten_date_now,W:_emscripten_get_now,ka:_emscripten_resize_heap,xa:_environ_get,ya:_environ_sizes_get,N:_fd_close,la:_fd_fdstat_get,qa:_fd_read,wa:_fd_seek,Ba:_fd_sync,M:_fd_write,aa:_flatsql_io_close,A:_flatsql_io_open,ba:_flatsql_io_read,ca:_flatsql_io_size,_:_flatsql_io_sync,Ka:_flatsql_io_truncate,$:_flatsql_io_write,x:invoke_di,J:invoke_dii,L:invoke_diii,U:invoke_fiii,s:invoke_i,c:invoke_ii,Q:invoke_iid,f:invoke_iii,K:invoke_iiid,Ma:invoke_iiiddddddddi,h:invoke_iiii,I:invoke_iiiid,n:invoke_iiiii,ha:invoke_iiiiid,m:invoke_iiiiii,t:invoke_iiiiiii,O:invoke_iiiiiiii,P:invoke_iiiiiiiiii,F:invoke_iiiiiiiiiiii,R:invoke_iiiiiijii,V:invoke_iiiiij,Oa:invoke_iiiiiji,Ta:invoke_iiij,Pa:invoke_iij,E:invoke_iiji,Ra:invoke_iijiii,ja:invoke_j,C:invoke_jii,B:invoke_jiiii,S:invoke_jiiiii,La:invoke_jiiiiiii,g:invoke_v,j:invoke_vi,H:invoke_vid,b:invoke_vii,Z:invoke_viidi,i:invoke_viii,k:invoke_viiii,u:invoke_viiiii,r:invoke_viiiiii,w:invoke_viiiiiii,Na:invoke_viiiiiiii,D:invoke_viiiiiiiiii,G:invoke_viiiiiiiiiiiiiii,Y:invoke_viiiji,ea:invoke_viiijj,fa:invoke_viij,T:invoke_viijii,Sa:invoke_viijij,Qa:invoke_viijj,y:invoke_vij,q:_llvm_eh_typeid_for};function invoke_v(index){var sp=stackSave();try{dynCall_v(index)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return dynCall_ii(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return dynCall_iii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{dynCall_viiiiii(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{dynCall_vii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vij(index,a1,a2){var sp=stackSave();try{dynCall_vij(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{dynCall_viii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{dynCall_vi(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jii(index,a1,a2){var sp=stackSave();try{return dynCall_jii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return dynCall_iiiiiii(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_i(index){var sp=stackSave();try{return dynCall_i(index)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viijii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viijii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiij(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiij(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiid(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiid(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viijij(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viijij(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viij(index,a1,a2,a3){var sp=stackSave();try{dynCall_viij(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiijj(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiijj(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_jiiiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return dynCall_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiji(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiji(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iijiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iijiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viijj(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viijj(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_jiiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){var sp=stackSave();try{dynCall_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiijii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{return dynCall_iiiiiijii(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iij(index,a1,a2){var sp=stackSave();try{return dynCall_iij(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iid(index,a1,a2){var sp=stackSave();try{return dynCall_iid(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiji(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return dynCall_iiiiiji(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_dii(index,a1,a2){var sp=stackSave();try{return dynCall_dii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{return dynCall_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return dynCall_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_di(index,a1){var sp=stackSave();try{return dynCall_di(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiid(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiiid(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidi(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viidi(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vid(index,a1,a2){var sp=stackSave();try{dynCall_vid(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiji(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiiji(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{dynCall_viiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiddddddddi(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return dynCall_iiiddddddddi(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return dynCall_jiiiiiii(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_j(index){var sp=stackSave();try{return dynCall_j(index)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_iiiiij(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiiij(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiid(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiiid(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_fiii(index,a1,a2,a3){var sp=stackSave();try{return dynCall_fiii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diii(index,a1,a2,a3){var sp=stackSave();try{return dynCall_diii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{dynCall_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15){var sp=stackSave();try{dynCall_viiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function applySignatureConversions(wasmExports){wasmExports=Object.assign({},wasmExports);var makeWrapper_pp=f=>a0=>f(a0)>>>0;var makeWrapper_p=f=>()=>f()>>>0;wasmExports["Ya"]=makeWrapper_pp(wasmExports["Ya"]);wasmExports["Tc"]=makeWrapper_pp(wasmExports["Tc"]);wasmExports["Uc"]=makeWrapper_p(wasmExports["Uc"]);wasmExports["Yc"]=makeWrapper_pp(wasmExports["Yc"]);return wasmExports}function run(){preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;wasmExports=await (createWasm());run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
1
+ async function FlatSQL(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("module");var require=createRequire(import.meta.url)}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("path").dirname(require("url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["Za"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("flatsql.wasm")}return new URL("flatsql.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmExports=applySignatureConversions(wasmExports);assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var exceptionCaught=[];var uncaughtExceptionCount=0;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);function ___cxa_begin_catch(ptr){ptr>>>=0;var info=new ExceptionInfo(ptr);if(!info.get_caught()){info.set_caught(true);uncaughtExceptionCount--}info.set_rethrown(false);exceptionCaught.push(info);return ___cxa_get_exception_ptr(ptr)}var exceptionLast=0;var ___cxa_end_catch=()=>{_setThrew(0,0);var info=exceptionCaught.pop();___cxa_decrement_exception_refcount(info.excPtr);exceptionLast=0};class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>>2>>>0]=type}get_type(){return HEAPU32[this.ptr+4>>>2>>>0]}set_destructor(destructor){HEAPU32[this.ptr+8>>>2>>>0]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>>2>>>0]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12>>>0]=caught}get_caught(){return HEAP8[this.ptr+12>>>0]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13>>>0]=rethrown}get_rethrown(){return HEAP8[this.ptr+13>>>0]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>>2>>>0]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>>2>>>0]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};function ___cxa_find_matching_catch_2(){return findMatchingCatch([])}function ___cxa_find_matching_catch_3(arg0){arg0>>>=0;return findMatchingCatch([arg0])}function ___cxa_find_matching_catch_4(arg0,arg1){arg0>>>=0;arg1>>>=0;return findMatchingCatch([arg0,arg1])}var ___cxa_rethrow=()=>{var info=exceptionCaught.pop();if(!info){abort("no exception to throw")}var ptr=info.excPtr;if(!info.get_rethrown()){exceptionCaught.push(info);info.set_rethrown(true);info.set_caught(false);uncaughtExceptionCount++}___cxa_increment_exception_refcount(ptr);exceptionLast=ptr;throw exceptionLast};function ___cxa_throw(ptr,type,destructor){ptr>>>=0;type>>>=0;destructor>>>=0;var info=new ExceptionInfo(ptr);info.init(type,destructor);___cxa_increment_exception_refcount(ptr);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast}var ___cxa_uncaught_exceptions=()=>uncaughtExceptionCount;function ___resumeException(ptr){ptr>>>=0;if(!exceptionLast){exceptionLast=ptr}throw exceptionLast}function ___syscall_chmod(path,mode){path>>>=0}function ___syscall_faccessat(dirfd,path,amode,flags){path>>>=0}var ___syscall_fchmod=(fd,mode)=>{};var ___syscall_fchown32=(fd,owner,group)=>{};var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{idx>>>=0;var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>{ptr>>>=0;return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead,ignoreNul):""};var SYSCALLS={varargs:undefined,getStr(ptr){var ret=UTF8ToString(ptr);return ret}};function ___syscall_fcntl64(fd,cmd,varargs){varargs>>>=0;SYSCALLS.varargs=varargs;return 0}function ___syscall_fstat64(fd,buf){buf>>>=0}function ___syscall_ftruncate64(fd,length){length=bigintToI53Checked(length)}function ___syscall_getcwd(buf,size){buf>>>=0;size>>>=0}function ___syscall_lstat64(path,buf){path>>>=0;buf>>>=0}function ___syscall_mkdirat(dirfd,path,mode){path>>>=0}function ___syscall_newfstatat(dirfd,path,buf,flags){path>>>=0;buf>>>=0}function ___syscall_openat(dirfd,path,flags,varargs){path>>>=0;varargs>>>=0;SYSCALLS.varargs=varargs}function ___syscall_readlinkat(dirfd,path,buf,bufsize){path>>>=0;buf>>>=0;bufsize>>>=0}function ___syscall_rmdir(path){path>>>=0}function ___syscall_stat64(path,buf){path>>>=0;buf>>>=0}function ___syscall_unlinkat(dirfd,path,flags){path>>>=0}function ___syscall_utimensat(dirfd,path,times,flags){path>>>=0;times>>>=0}var __abort_js=()=>abort("");var isLeapYear=year=>year%4===0&&(year%100!==0||year%400===0);var MONTH_DAYS_LEAP_CUMULATIVE=[0,31,60,91,121,152,182,213,244,274,305,335];var MONTH_DAYS_REGULAR_CUMULATIVE=[0,31,59,90,120,151,181,212,243,273,304,334];var ydayFromDate=date=>{var leap=isLeapYear(date.getFullYear());var monthDaysCumulative=leap?MONTH_DAYS_LEAP_CUMULATIVE:MONTH_DAYS_REGULAR_CUMULATIVE;var yday=monthDaysCumulative[date.getMonth()]+date.getDate()-1;return yday};function __localtime_js(time,tmPtr){time=bigintToI53Checked(time);tmPtr>>>=0;var date=new Date(time*1e3);HEAP32[tmPtr>>>2>>>0]=date.getSeconds();HEAP32[tmPtr+4>>>2>>>0]=date.getMinutes();HEAP32[tmPtr+8>>>2>>>0]=date.getHours();HEAP32[tmPtr+12>>>2>>>0]=date.getDate();HEAP32[tmPtr+16>>>2>>>0]=date.getMonth();HEAP32[tmPtr+20>>>2>>>0]=date.getFullYear()-1900;HEAP32[tmPtr+24>>>2>>>0]=date.getDay();var yday=ydayFromDate(date)|0;HEAP32[tmPtr+28>>>2>>>0]=yday;HEAP32[tmPtr+36>>>2>>>0]=-(date.getTimezoneOffset()*60);var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dst=(summerOffset!=winterOffset&&date.getTimezoneOffset()==Math.min(winterOffset,summerOffset))|0;HEAP32[tmPtr+32>>>2>>>0]=dst}var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{outIdx>>>=0;if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++>>>0]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++>>>0]=192|u>>6;heap[outIdx++>>>0]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++>>>0]=224|u>>12;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++>>>0]=240|u>>18;heap[outIdx++>>>0]=128|u>>12&63;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63;i++}}heap[outIdx>>>0]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var __tzset_js=function(timezone,daylight,std_name,dst_name){timezone>>>=0;daylight>>>=0;std_name>>>=0;dst_name>>>=0;var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>>2>>>0]=stdTimezoneOffset*60;HEAP32[daylight>>>2>>>0]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}};var _emscripten_get_now=()=>performance.now();var _emscripten_date_now=()=>Date.now();var nowIsMonotonic=1;var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;function _clock_time_get(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);ptime>>>=0;if(!checkWasiClock(clk_id)){return 28}var now;if(clk_id===0){now=_emscripten_date_now()}else if(nowIsMonotonic){now=_emscripten_get_now()}else{return 52}var nsec=Math.round(now*1e3*1e3);HEAP64[ptime>>>3>>>0]=BigInt(nsec);return 0}var getHeapMax=()=>4294901760;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};function _emscripten_resize_heap(requestedSize){requestedSize>>>=0;var oldSize=HEAPU8.length;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false}var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};function _environ_get(__environ,environ_buf){__environ>>>=0;environ_buf>>>=0;var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>>2>>>0]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0}var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};function _environ_sizes_get(penviron_count,penviron_buf_size){penviron_count>>>=0;penviron_buf_size>>>=0;var strings=getEnvStrings();HEAPU32[penviron_count>>>2>>>0]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}HEAPU32[penviron_buf_size>>>2>>>0]=bufSize;return 0}var _fd_close=fd=>52;function _fd_fdstat_get(fd,pbuf){pbuf>>>=0;var rightsBase=0;var rightsInheriting=0;var flags=0;{var type=2;if(fd==0){rightsBase=2}else if(fd==1||fd==2){rightsBase=64}flags=1}HEAP8[pbuf>>>0]=type;HEAP16[pbuf+2>>>1>>>0]=flags;HEAP64[pbuf+8>>>3>>>0]=BigInt(rightsBase);HEAP64[pbuf+16>>>3>>>0]=BigInt(rightsInheriting);return 0}function _fd_read(fd,iov,iovcnt,pnum){iov>>>=0;iovcnt>>>=0;pnum>>>=0;return 52}function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);newOffset>>>=0;return 70}var _fd_sync=fd=>52;var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};function _fd_write(fd,iov,iovcnt,pnum){iov>>>=0;iovcnt>>>=0;pnum>>>=0;var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>>2>>>0];var len=HEAPU32[iov+4>>>2>>>0];iov+=8;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j>>>0])}num+=len}HEAPU32[pnum>>>2>>>0]=num;return 0}var flatsqlIoBridge={ERR_GENERIC:-1,ERR_NOENT:-2,ERR_ACCESS:-3,ERR_BADHANDLE:-6,backend:function(){return Module["flatsqlIO"]||null},path:function(ptr,len){return UTF8ToString(ptr,len)}};function _flatsql_io_close(handle){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.close(handle)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_open(pathPtr,pathLen,flags){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.open(flatsqlIoBridge.path(pathPtr,pathLen),flags)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_read(handle,dstPtr,len,offset){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.read(handle,HEAPU8.subarray(dstPtr>>>0,dstPtr+len>>>0),offset)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_size(handle){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.size(handle)}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_sync(handle){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.sync(handle)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_truncate(handle,size){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.truncate(handle,size)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _flatsql_io_write(handle,srcPtr,len,offset){var io=flatsqlIoBridge.backend();if(!io)return flatsqlIoBridge.ERR_ACCESS;try{return io.write(handle,HEAPU8.subarray(srcPtr>>>0,srcPtr+len>>>0),offset)|0}catch(e){return flatsqlIoBridge.ERR_GENERIC}}function _llvm_eh_typeid_for(type){type>>>=0;return type}var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer>>>0)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="pointer")return ret>>>0;if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func(...cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret};var cwrap=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}Module["ccall"]=ccall;Module["cwrap"]=cwrap;Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;var _free,_malloc,_flatsql_create_db,_flatsql_open_db,_flatsql_is_disk_backed,_flatsql_open_state,_flatsql_reindex_all,_flatsql_reindex_step,_flatsql_flush_index,_flatsql_flushed_offset,_flatsql_compact_arena,_flatsql_arena_stat,_flatsql_stream_path,_flatsql_destroy_db,_flatsql_register_file_id,_flatsql_enable_demo_extractors,_flatsql_ingest,_flatsql_ingest_one,_flatsql_register_source,_flatsql_create_unified_views,_flatsql_ingest_with_source,_flatsql_ingest_one_with_source,_flatsql_set_arena_limit,_flatsql_query,_flatsql_query_params,_flatsql_query_many,_flatsql_batch_result_count,_flatsql_select_batch_result,_flatsql_get_error,_flatsql_build_query_cache_key,_flatsql_build_response_artifact_cache_key,_flatsql_register_query_template,_flatsql_query_template,_flatsql_clear_query_cache,_flatsql_configure_query_cache,_flatsql_query_cache_hits,_flatsql_query_cache_misses,_flatsql_query_cache_size,_flatsql_query_cache_generation,_flatsql_query_cache_max_entries,_flatsql_query_cache_max_rows,_flatsql_result_column_count,_flatsql_result_row_count,_flatsql_result_column_name,_flatsql_result_cell_type,_flatsql_result_cell_number,_flatsql_result_cell_string,_flatsql_result_cell_blob,_flatsql_result_cell_blob_size,_flatsql_export_data,_flatsql_query_raw_flatbuffer_stream,_flatsql_query_sandboxed,_flatsql_response_artifact_data,_flatsql_response_artifact_size,_flatsql_response_artifact_cache_hit,_flatsql_configure_raw_stream_cache,_flatsql_raw_stream_cache_hits,_flatsql_raw_stream_cache_misses,_flatsql_raw_stream_cache_size,_flatsql_raw_stream_cache_total_bytes,_flatsql_response_artifact_row_count,_flatsql_response_artifact_column_count,_flatsql_export_size,_flatsql_load_and_rebuild,_flatsql_reserve_storage,_flatsql_load_from_db,_flatsql_create_test_user,_flatsql_test_buffer_size,_flatsql_create_test_post,_flatsql_create_test_mpe,_flatsql_create_test_telemetry,_flatsql_create_test_publish_event,_flatsql_get_stats_count,_flatsql_get_stat_table_name,_flatsql_get_stat_file_id,_flatsql_get_stat_record_count,_flatsql_reset_ingest_profile,_flatsql_get_ingest_profile_record_count,_flatsql_get_ingest_profile_byte_count,_flatsql_get_ingest_profile_decode_nanos,_flatsql_get_ingest_profile_append_nanos,_flatsql_get_ingest_profile_index_nanos,_flatsql_mark_deleted,_flatsql_get_deleted_count,_flatsql_clear_tombstones,_flatsql_get_sources_count,_flatsql_get_source_name,_flatsql_get_flatbuffer_by_id,_flatsql_get_flatbuffer_by_email,_flatsql_get_flatbuffer_by_index,_flatsql_get_raw_flatbuffer_size,_flatsql_get_raw_flatbuffer_sequence,_flatsql_get_storage_buffer,_flatsql_get_storage_size,_flatsql_set_encryption_key,_flatsql_is_encrypted,_flatsql_encrypt_buffer,_flatsql_decrypt_buffer,_flatsql_ingest_one_encrypted,_flatsql_set_hmac_verification,_flatsql_is_hmac_enabled,_flatsql_compute_hmac,_flatsql_verify_hmac,_setThrew,__emscripten_tempret_set,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___cxa_decrement_exception_refcount,___cxa_increment_exception_refcount,___cxa_can_catch,___cxa_get_exception_ptr,dynCall_v,dynCall_ii,dynCall_iii,dynCall_viiiiii,dynCall_vii,dynCall_viii,dynCall_iiii,dynCall_iiiiii,dynCall_vi,dynCall_viiii,dynCall_jii,dynCall_viiiii,dynCall_iiiiiii,dynCall_iiiii,dynCall_i,dynCall_iiij,dynCall_iiid,dynCall_viijij,dynCall_viiijj,dynCall_jiiiii,dynCall_iiiiiiiiiiii,dynCall_vij,dynCall_iiji,dynCall_iijiii,dynCall_viijj,dynCall_jiiii,dynCall_viij,dynCall_jij,dynCall_iij,dynCall_iijjii,dynCall_iiiiji,dynCall_viiji,dynCall_iiiiiijii,dynCall_iid,dynCall_iiiiiji,dynCall_dii,dynCall_iiiiiiiiii,dynCall_iiiiiiii,dynCall_viijii,dynCall_di,dynCall_iiiid,dynCall_iijj,dynCall_viidi,dynCall_vid,dynCall_vidd,dynCall_viiiji,dynCall_dd,dynCall_ddd,dynCall_viiiiiiii,dynCall_iiiddddddddi,dynCall_jiiiiiii,dynCall_iiiij,dynCall_vijii,dynCall_iijii,dynCall_ji,dynCall_jiji,dynCall_iidiiii,dynCall_j,dynCall_iiiiij,dynCall_iiiiid,dynCall_iiiiiiiiiii,dynCall_iiiiiiiiiiiii,dynCall_fiii,dynCall_diii,dynCall_viiiiiii,dynCall_viiiiiiiiii,dynCall_viiiiiiiiiiiiiii,dynCall_iiiiiiiii,dynCall_iiiiijj,dynCall_iiiiiijj,memory,__indirect_function_table,wasmMemory,wasmTable;function assignWasmExports(wasmExports){_free=Module["_free"]=wasmExports["$a"];_malloc=Module["_malloc"]=wasmExports["ab"];_flatsql_create_db=Module["_flatsql_create_db"]=wasmExports["bb"];_flatsql_open_db=Module["_flatsql_open_db"]=wasmExports["cb"];_flatsql_is_disk_backed=Module["_flatsql_is_disk_backed"]=wasmExports["db"];_flatsql_open_state=Module["_flatsql_open_state"]=wasmExports["eb"];_flatsql_reindex_all=Module["_flatsql_reindex_all"]=wasmExports["fb"];_flatsql_reindex_step=Module["_flatsql_reindex_step"]=wasmExports["gb"];_flatsql_flush_index=Module["_flatsql_flush_index"]=wasmExports["hb"];_flatsql_flushed_offset=Module["_flatsql_flushed_offset"]=wasmExports["ib"];_flatsql_compact_arena=Module["_flatsql_compact_arena"]=wasmExports["jb"];_flatsql_arena_stat=Module["_flatsql_arena_stat"]=wasmExports["kb"];_flatsql_stream_path=Module["_flatsql_stream_path"]=wasmExports["lb"];_flatsql_destroy_db=Module["_flatsql_destroy_db"]=wasmExports["mb"];_flatsql_register_file_id=Module["_flatsql_register_file_id"]=wasmExports["nb"];_flatsql_enable_demo_extractors=Module["_flatsql_enable_demo_extractors"]=wasmExports["ob"];_flatsql_ingest=Module["_flatsql_ingest"]=wasmExports["pb"];_flatsql_ingest_one=Module["_flatsql_ingest_one"]=wasmExports["qb"];_flatsql_register_source=Module["_flatsql_register_source"]=wasmExports["rb"];_flatsql_create_unified_views=Module["_flatsql_create_unified_views"]=wasmExports["sb"];_flatsql_ingest_with_source=Module["_flatsql_ingest_with_source"]=wasmExports["tb"];_flatsql_ingest_one_with_source=Module["_flatsql_ingest_one_with_source"]=wasmExports["ub"];_flatsql_set_arena_limit=Module["_flatsql_set_arena_limit"]=wasmExports["vb"];_flatsql_query=Module["_flatsql_query"]=wasmExports["wb"];_flatsql_query_params=Module["_flatsql_query_params"]=wasmExports["xb"];_flatsql_query_many=Module["_flatsql_query_many"]=wasmExports["yb"];_flatsql_batch_result_count=Module["_flatsql_batch_result_count"]=wasmExports["zb"];_flatsql_select_batch_result=Module["_flatsql_select_batch_result"]=wasmExports["Ab"];_flatsql_get_error=Module["_flatsql_get_error"]=wasmExports["Bb"];_flatsql_build_query_cache_key=Module["_flatsql_build_query_cache_key"]=wasmExports["Cb"];_flatsql_build_response_artifact_cache_key=Module["_flatsql_build_response_artifact_cache_key"]=wasmExports["Db"];_flatsql_register_query_template=Module["_flatsql_register_query_template"]=wasmExports["Eb"];_flatsql_query_template=Module["_flatsql_query_template"]=wasmExports["Fb"];_flatsql_clear_query_cache=Module["_flatsql_clear_query_cache"]=wasmExports["Gb"];_flatsql_configure_query_cache=Module["_flatsql_configure_query_cache"]=wasmExports["Hb"];_flatsql_query_cache_hits=Module["_flatsql_query_cache_hits"]=wasmExports["Ib"];_flatsql_query_cache_misses=Module["_flatsql_query_cache_misses"]=wasmExports["Jb"];_flatsql_query_cache_size=Module["_flatsql_query_cache_size"]=wasmExports["Kb"];_flatsql_query_cache_generation=Module["_flatsql_query_cache_generation"]=wasmExports["Lb"];_flatsql_query_cache_max_entries=Module["_flatsql_query_cache_max_entries"]=wasmExports["Mb"];_flatsql_query_cache_max_rows=Module["_flatsql_query_cache_max_rows"]=wasmExports["Nb"];_flatsql_result_column_count=Module["_flatsql_result_column_count"]=wasmExports["Ob"];_flatsql_result_row_count=Module["_flatsql_result_row_count"]=wasmExports["Pb"];_flatsql_result_column_name=Module["_flatsql_result_column_name"]=wasmExports["Qb"];_flatsql_result_cell_type=Module["_flatsql_result_cell_type"]=wasmExports["Rb"];_flatsql_result_cell_number=Module["_flatsql_result_cell_number"]=wasmExports["Sb"];_flatsql_result_cell_string=Module["_flatsql_result_cell_string"]=wasmExports["Tb"];_flatsql_result_cell_blob=Module["_flatsql_result_cell_blob"]=wasmExports["Ub"];_flatsql_result_cell_blob_size=Module["_flatsql_result_cell_blob_size"]=wasmExports["Vb"];_flatsql_export_data=Module["_flatsql_export_data"]=wasmExports["Wb"];_flatsql_query_raw_flatbuffer_stream=Module["_flatsql_query_raw_flatbuffer_stream"]=wasmExports["Xb"];_flatsql_query_sandboxed=Module["_flatsql_query_sandboxed"]=wasmExports["Yb"];_flatsql_response_artifact_data=Module["_flatsql_response_artifact_data"]=wasmExports["Zb"];_flatsql_response_artifact_size=Module["_flatsql_response_artifact_size"]=wasmExports["_b"];_flatsql_response_artifact_cache_hit=Module["_flatsql_response_artifact_cache_hit"]=wasmExports["$b"];_flatsql_configure_raw_stream_cache=Module["_flatsql_configure_raw_stream_cache"]=wasmExports["ac"];_flatsql_raw_stream_cache_hits=Module["_flatsql_raw_stream_cache_hits"]=wasmExports["bc"];_flatsql_raw_stream_cache_misses=Module["_flatsql_raw_stream_cache_misses"]=wasmExports["cc"];_flatsql_raw_stream_cache_size=Module["_flatsql_raw_stream_cache_size"]=wasmExports["dc"];_flatsql_raw_stream_cache_total_bytes=Module["_flatsql_raw_stream_cache_total_bytes"]=wasmExports["ec"];_flatsql_response_artifact_row_count=Module["_flatsql_response_artifact_row_count"]=wasmExports["fc"];_flatsql_response_artifact_column_count=Module["_flatsql_response_artifact_column_count"]=wasmExports["gc"];_flatsql_export_size=Module["_flatsql_export_size"]=wasmExports["hc"];_flatsql_load_and_rebuild=Module["_flatsql_load_and_rebuild"]=wasmExports["ic"];_flatsql_reserve_storage=Module["_flatsql_reserve_storage"]=wasmExports["jc"];_flatsql_load_from_db=Module["_flatsql_load_from_db"]=wasmExports["kc"];_flatsql_create_test_user=Module["_flatsql_create_test_user"]=wasmExports["lc"];_flatsql_test_buffer_size=Module["_flatsql_test_buffer_size"]=wasmExports["mc"];_flatsql_create_test_post=Module["_flatsql_create_test_post"]=wasmExports["nc"];_flatsql_create_test_mpe=Module["_flatsql_create_test_mpe"]=wasmExports["oc"];_flatsql_create_test_telemetry=Module["_flatsql_create_test_telemetry"]=wasmExports["pc"];_flatsql_create_test_publish_event=Module["_flatsql_create_test_publish_event"]=wasmExports["qc"];_flatsql_get_stats_count=Module["_flatsql_get_stats_count"]=wasmExports["rc"];_flatsql_get_stat_table_name=Module["_flatsql_get_stat_table_name"]=wasmExports["sc"];_flatsql_get_stat_file_id=Module["_flatsql_get_stat_file_id"]=wasmExports["tc"];_flatsql_get_stat_record_count=Module["_flatsql_get_stat_record_count"]=wasmExports["uc"];_flatsql_reset_ingest_profile=Module["_flatsql_reset_ingest_profile"]=wasmExports["vc"];_flatsql_get_ingest_profile_record_count=Module["_flatsql_get_ingest_profile_record_count"]=wasmExports["wc"];_flatsql_get_ingest_profile_byte_count=Module["_flatsql_get_ingest_profile_byte_count"]=wasmExports["xc"];_flatsql_get_ingest_profile_decode_nanos=Module["_flatsql_get_ingest_profile_decode_nanos"]=wasmExports["yc"];_flatsql_get_ingest_profile_append_nanos=Module["_flatsql_get_ingest_profile_append_nanos"]=wasmExports["zc"];_flatsql_get_ingest_profile_index_nanos=Module["_flatsql_get_ingest_profile_index_nanos"]=wasmExports["Ac"];_flatsql_mark_deleted=Module["_flatsql_mark_deleted"]=wasmExports["Bc"];_flatsql_get_deleted_count=Module["_flatsql_get_deleted_count"]=wasmExports["Cc"];_flatsql_clear_tombstones=Module["_flatsql_clear_tombstones"]=wasmExports["Dc"];_flatsql_get_sources_count=Module["_flatsql_get_sources_count"]=wasmExports["Ec"];_flatsql_get_source_name=Module["_flatsql_get_source_name"]=wasmExports["Fc"];_flatsql_get_flatbuffer_by_id=Module["_flatsql_get_flatbuffer_by_id"]=wasmExports["Gc"];_flatsql_get_flatbuffer_by_email=Module["_flatsql_get_flatbuffer_by_email"]=wasmExports["Hc"];_flatsql_get_flatbuffer_by_index=Module["_flatsql_get_flatbuffer_by_index"]=wasmExports["Ic"];_flatsql_get_raw_flatbuffer_size=Module["_flatsql_get_raw_flatbuffer_size"]=wasmExports["Jc"];_flatsql_get_raw_flatbuffer_sequence=Module["_flatsql_get_raw_flatbuffer_sequence"]=wasmExports["Kc"];_flatsql_get_storage_buffer=Module["_flatsql_get_storage_buffer"]=wasmExports["Lc"];_flatsql_get_storage_size=Module["_flatsql_get_storage_size"]=wasmExports["Mc"];_flatsql_set_encryption_key=Module["_flatsql_set_encryption_key"]=wasmExports["Nc"];_flatsql_is_encrypted=Module["_flatsql_is_encrypted"]=wasmExports["Oc"];_flatsql_encrypt_buffer=Module["_flatsql_encrypt_buffer"]=wasmExports["Pc"];_flatsql_decrypt_buffer=Module["_flatsql_decrypt_buffer"]=wasmExports["Qc"];_flatsql_ingest_one_encrypted=Module["_flatsql_ingest_one_encrypted"]=wasmExports["Rc"];_flatsql_set_hmac_verification=Module["_flatsql_set_hmac_verification"]=wasmExports["Sc"];_flatsql_is_hmac_enabled=Module["_flatsql_is_hmac_enabled"]=wasmExports["Tc"];_flatsql_compute_hmac=Module["_flatsql_compute_hmac"]=wasmExports["Uc"];_flatsql_verify_hmac=Module["_flatsql_verify_hmac"]=wasmExports["Vc"];_setThrew=wasmExports["Wc"];__emscripten_tempret_set=wasmExports["Xc"];__emscripten_stack_restore=wasmExports["Yc"];__emscripten_stack_alloc=wasmExports["Zc"];_emscripten_stack_get_current=wasmExports["_c"];___cxa_decrement_exception_refcount=wasmExports["$c"];___cxa_increment_exception_refcount=wasmExports["ad"];___cxa_can_catch=wasmExports["bd"];___cxa_get_exception_ptr=wasmExports["cd"];dynCall_v=wasmExports["dd"];dynCall_ii=wasmExports["ed"];dynCall_iii=wasmExports["fd"];dynCall_viiiiii=wasmExports["gd"];dynCall_vii=wasmExports["hd"];dynCall_viii=wasmExports["id"];dynCall_iiii=wasmExports["jd"];dynCall_iiiiii=wasmExports["kd"];dynCall_vi=wasmExports["ld"];dynCall_viiii=wasmExports["md"];dynCall_jii=wasmExports["nd"];dynCall_viiiii=wasmExports["od"];dynCall_iiiiiii=wasmExports["pd"];dynCall_iiiii=wasmExports["qd"];dynCall_i=wasmExports["rd"];dynCall_iiij=wasmExports["sd"];dynCall_iiid=wasmExports["td"];dynCall_viijij=wasmExports["ud"];dynCall_viiijj=wasmExports["vd"];dynCall_jiiiii=wasmExports["wd"];dynCall_iiiiiiiiiiii=wasmExports["xd"];dynCall_vij=wasmExports["yd"];dynCall_iiji=wasmExports["zd"];dynCall_iijiii=wasmExports["Ad"];dynCall_viijj=wasmExports["Bd"];dynCall_jiiii=wasmExports["Cd"];dynCall_viij=wasmExports["Dd"];dynCall_jij=wasmExports["dynCall_jij"];dynCall_iij=wasmExports["Ed"];dynCall_iijjii=wasmExports["Fd"];dynCall_iiiiji=wasmExports["Gd"];dynCall_viiji=wasmExports["Hd"];dynCall_iiiiiijii=wasmExports["Id"];dynCall_iid=wasmExports["Jd"];dynCall_iiiiiji=wasmExports["Kd"];dynCall_dii=wasmExports["Ld"];dynCall_iiiiiiiiii=wasmExports["Md"];dynCall_iiiiiiii=wasmExports["Nd"];dynCall_viijii=wasmExports["Od"];dynCall_di=wasmExports["Pd"];dynCall_iiiid=wasmExports["Qd"];dynCall_iijj=wasmExports["Rd"];dynCall_viidi=wasmExports["Sd"];dynCall_vid=wasmExports["Td"];dynCall_vidd=wasmExports["dynCall_vidd"];dynCall_viiiji=wasmExports["Ud"];dynCall_dd=wasmExports["dynCall_dd"];dynCall_ddd=wasmExports["dynCall_ddd"];dynCall_viiiiiiii=wasmExports["Vd"];dynCall_iiiddddddddi=wasmExports["Wd"];dynCall_jiiiiiii=wasmExports["Xd"];dynCall_iiiij=wasmExports["dynCall_iiiij"];dynCall_vijii=wasmExports["dynCall_vijii"];dynCall_iijii=wasmExports["dynCall_iijii"];dynCall_ji=wasmExports["dynCall_ji"];dynCall_jiji=wasmExports["dynCall_jiji"];dynCall_iidiiii=wasmExports["dynCall_iidiiii"];dynCall_j=wasmExports["Yd"];dynCall_iiiiij=wasmExports["Zd"];dynCall_iiiiid=wasmExports["_d"];dynCall_iiiiiiiiiii=wasmExports["dynCall_iiiiiiiiiii"];dynCall_iiiiiiiiiiiii=wasmExports["dynCall_iiiiiiiiiiiii"];dynCall_fiii=wasmExports["$d"];dynCall_diii=wasmExports["ae"];dynCall_viiiiiii=wasmExports["be"];dynCall_viiiiiiiiii=wasmExports["ce"];dynCall_viiiiiiiiiiiiiii=wasmExports["de"];dynCall_iiiiiiiii=wasmExports["dynCall_iiiiiiiii"];dynCall_iiiiijj=wasmExports["dynCall_iiiiijj"];dynCall_iiiiiijj=wasmExports["dynCall_iiiiiijj"];memory=wasmMemory=wasmExports["Ya"];__indirect_function_table=wasmTable=wasmExports["_a"]}var wasmImports={l:___cxa_begin_catch,p:___cxa_end_catch,a:___cxa_find_matching_catch_2,d:___cxa_find_matching_catch_3,w:___cxa_find_matching_catch_4,ha:___cxa_rethrow,o:___cxa_throw,la:___cxa_uncaught_exceptions,e:___resumeException,Ka:___syscall_chmod,Ma:___syscall_faccessat,La:___syscall_fchmod,Ja:___syscall_fchown32,A:___syscall_fcntl64,Ia:___syscall_fstat64,Da:___syscall_ftruncate64,Ca:___syscall_getcwd,Fa:___syscall_lstat64,ya:___syscall_mkdirat,Ga:___syscall_newfstatat,ua:___syscall_openat,sa:___syscall_readlinkat,ra:___syscall_rmdir,Ha:___syscall_stat64,qa:___syscall_unlinkat,pa:___syscall_utimensat,Xa:__abort_js,wa:__localtime_js,xa:__tzset_js,va:_clock_time_get,_:_emscripten_date_now,Z:_emscripten_get_now,na:_emscripten_resize_heap,Aa:_environ_get,Ba:_environ_sizes_get,P:_fd_close,oa:_fd_fdstat_get,ta:_fd_read,za:_fd_seek,Ea:_fd_sync,O:_fd_write,ea:_flatsql_io_close,B:_flatsql_io_open,fa:_flatsql_io_read,ga:_flatsql_io_size,ba:_flatsql_io_sync,ca:_flatsql_io_truncate,da:_flatsql_io_write,x:invoke_di,J:invoke_dii,W:invoke_diii,X:invoke_fiii,t:invoke_i,c:invoke_ii,F:invoke_iid,f:invoke_iii,L:invoke_iiid,Oa:invoke_iiiddddddddi,h:invoke_iiii,z:invoke_iiiid,n:invoke_iiiii,ka:invoke_iiiiid,m:invoke_iiiiii,u:invoke_iiiiiii,Q:invoke_iiiiiiii,R:invoke_iiiiiiiiii,H:invoke_iiiiiiiiiiii,S:invoke_iiiiiijii,Y:invoke_iiiiij,Ra:invoke_iiiiiji,Ta:invoke_iiiiji,M:invoke_iiij,K:invoke_iij,D:invoke_iiji,Va:invoke_iijiii,Qa:invoke_iijj,T:invoke_iijjii,ma:invoke_j,E:invoke_jii,C:invoke_jiiii,U:invoke_jiiiii,Na:invoke_jiiiiiii,g:invoke_v,j:invoke_vi,I:invoke_vid,b:invoke_vii,aa:invoke_viidi,i:invoke_viii,k:invoke_viiii,v:invoke_viiiii,q:invoke_viiiiii,y:invoke_viiiiiii,Pa:invoke_viiiiiiii,G:invoke_viiiiiiiiii,N:invoke_viiiiiiiiiiiiiii,$:invoke_viiiji,ia:invoke_viiijj,ja:invoke_viij,Sa:invoke_viiji,V:invoke_viijii,Wa:invoke_viijij,Ua:invoke_viijj,s:invoke_vij,r:_llvm_eh_typeid_for};function invoke_v(index){var sp=stackSave();try{dynCall_v(index)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return dynCall_ii(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return dynCall_iii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{dynCall_viiiiii(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{dynCall_vii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vij(index,a1,a2){var sp=stackSave();try{dynCall_vij(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{dynCall_viii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{dynCall_vi(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jii(index,a1,a2){var sp=stackSave();try{return dynCall_jii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return dynCall_iiiiiii(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_i(index){var sp=stackSave();try{return dynCall_i(index)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viijii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viijii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiij(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiij(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiid(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiid(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viijij(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viijij(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viij(index,a1,a2,a3){var sp=stackSave();try{dynCall_viij(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiijj(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiijj(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_jiiiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return dynCall_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiji(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiji(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iijiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iijiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viijj(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viijj(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_jiiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){var sp=stackSave();try{dynCall_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iij(index,a1,a2){var sp=stackSave();try{return dynCall_iij(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iijjii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iijjii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiji(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiiji(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiji(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viiji(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiijii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{return dynCall_iiiiiijii(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iid(index,a1,a2){var sp=stackSave();try{return dynCall_iid(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiji(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return dynCall_iiiiiji(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_dii(index,a1,a2){var sp=stackSave();try{return dynCall_dii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{return dynCall_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return dynCall_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_di(index,a1){var sp=stackSave();try{return dynCall_di(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiid(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiiid(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iijj(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iijj(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidi(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viidi(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vid(index,a1,a2){var sp=stackSave();try{dynCall_vid(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiji(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiiji(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{dynCall_viiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiddddddddi(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return dynCall_iiiddddddddi(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return dynCall_jiiiiiii(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_j(index){var sp=stackSave();try{return dynCall_j(index)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_iiiiij(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiiij(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiid(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiiid(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_fiii(index,a1,a2,a3){var sp=stackSave();try{return dynCall_fiii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diii(index,a1,a2,a3){var sp=stackSave();try{return dynCall_diii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{dynCall_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15){var sp=stackSave();try{dynCall_viiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function applySignatureConversions(wasmExports){wasmExports=Object.assign({},wasmExports);var makeWrapper_pp=f=>a0=>f(a0)>>>0;var makeWrapper_p=f=>()=>f()>>>0;wasmExports["ab"]=makeWrapper_pp(wasmExports["ab"]);wasmExports["Zc"]=makeWrapper_pp(wasmExports["Zc"]);wasmExports["_c"]=makeWrapper_p(wasmExports["_c"]);wasmExports["cd"]=makeWrapper_pp(wasmExports["cd"]);return wasmExports}function run(){preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;wasmExports=await (createWasm());run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
2
2
  ;return moduleRtn}export default FlatSQL;
package/wasm/flatsql.wasm CHANGED
Binary file
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "algorithm": "sha384",
3
- "hash": "JWRTdWbV8EJ/0t0YI2Dun2xEqFT/5CBm53E8feeI9+4ULvqj+BpHfWPpW21DAOiM",
4
- "sri": "sha384-JWRTdWbV8EJ/0t0YI2Dun2xEqFT/5CBm53E8feeI9+4ULvqj+BpHfWPpW21DAOiM",
5
- "size": 2171442,
3
+ "hash": "PAY8EKMzvf5QkghYRLfSmTMOEc7rHYUQyMoV1w+uwGMq+HP3A73Ij/ZyI/KtKFXP",
4
+ "sri": "sha384-PAY8EKMzvf5QkghYRLfSmTMOEc7rHYUQyMoV1w+uwGMq+HP3A73Ij/ZyI/KtKFXP",
5
+ "size": 2246620,
6
6
  "files": {
7
7
  "flatsql-ps-threads.wasm": {
8
- "sha256": "e61120642b300997f59ef064d7cc6375bfc937e7cc4d551b47695f6d23ef03e6",
9
- "sri": "sha384-ob8andGalOK7VXlHEfja2VGzhmiwnXyT6CVZhOqElGEv7mvKUXPn/tUSvba9L1WB",
10
- "size": 2325490
8
+ "sha256": "787adbcccf52a9e9fe2767d6679b6f2d94a4ead41985bf2a7bb0855f821abc72",
9
+ "sri": "sha384-qR37NE4y3sP60hLFJEmxsYz76i2vpTZf9ydfSO0dX1MSD15HKEgEIm6UnkGYS8lo",
10
+ "size": 2484927
11
11
  },
12
12
  "flatsql-wasi-noeh.wasm": {
13
- "sha256": "7315eb0361513578c7a011db8b1e10a7d41625e8fae59c276b61e2d1529bb591",
14
- "sri": "sha384-sbtoG+Ne4mkC7j/hfJ3nvx/IOzvB3bjv24x+pkTn8CVuF0ghKtBbZ01ZdIxki7Rj",
15
- "size": 2062044
13
+ "sha256": "8f11fd49ee2e6961b9c1c22dd891d5a6645d0faf481f815408c0f1f5d3a385ab",
14
+ "sri": "sha384-Y7JqN0TgofROVAG/jtJb623501xOW9G8BZ3QwKUUudEgmGM2f1R8tYitm872ATUg",
15
+ "size": 2154784
16
16
  },
17
17
  "flatsql-wasi.wasm": {
18
- "sha256": "989ea9fc7be9539bda7878e5202bee46b4ba45fd59d8718b01a2a8a6c7cb1afd",
19
- "sri": "sha384-avovLPDagClSRBYZRRA7k6ys490F67ef9i5G/0WMckwDRyTUKo5lYT/3kCUBzZad",
20
- "size": 2147171
18
+ "sha256": "8e6a491141fa8334bcdb4fe2d3c848ea3fe7255b48fd6e9a1e012e873bca8c7a",
19
+ "sri": "sha384-vuSaOKS04thKQ51uvexi4JUNpW6Ptgs6yy6ONdffkjJIBVtULhvaXPY+4k7YFL6v",
20
+ "size": 2249367
21
21
  },
22
22
  "flatsql.wasm": {
23
- "sha256": "45e291c9293fc0c2c27e87cd410c813cd54f97ba6c3459d328122c1c37909d1f",
24
- "sri": "sha384-JWRTdWbV8EJ/0t0YI2Dun2xEqFT/5CBm53E8feeI9+4ULvqj+BpHfWPpW21DAOiM",
25
- "size": 2171442
23
+ "sha256": "eb61e4d65b90e3f5c5651a820b74f85fa200e3e46a0cbd9417fb82ed2db85bf8",
24
+ "sri": "sha384-PAY8EKMzvf5QkghYRLfSmTMOEc7rHYUQyMoV1w+uwGMq+HP3A73Ij/ZyI/KtKFXP",
25
+ "size": 2246620
26
26
  }
27
27
  }
28
28
  }
@@ -144,6 +144,23 @@ if (mode === "pool") {
144
144
  reply(ptr);
145
145
  } else if (msg.op === "read") {
146
146
  reply(mem().slice(msg.ptr, msg.ptr + msg.len));
147
+ } else if (msg.op === "growHeap") {
148
+ // The heap to msg.limitBytes of memory before any guest thread starts
149
+ // (ps-node-host.mjs heapLimitBytes): allocate in steps from 1 GiB
150
+ // down to 1 MiB until each fails, then free them all. The guest
151
+ // allocator keeps the freed blocks; wasm memory never shrinks.
152
+ const { flatsql_ps_alloc: alloc, flatsql_ps_free: free } = instance.exports;
153
+ const held = [];
154
+ for (let step = 2 ** 30; step >= 2 ** 20 && held.length < 64; ) {
155
+ const p = memory.buffer.byteLength + step + 2 ** 20 <= msg.limitBytes ? alloc(step) : 0;
156
+ if (!p) {
157
+ step /= 2;
158
+ continue;
159
+ }
160
+ held.push(p);
161
+ }
162
+ for (const p of held) free(p);
163
+ reply(memory.buffer.byteLength);
147
164
  } else {
148
165
  throw new Error(`unknown op ${msg.op}`);
149
166
  }
@@ -11,6 +11,8 @@ export interface PsThreadReport {
11
11
  workerThreads: number;
12
12
  distinctWorkerThreadIds: number;
13
13
  memoryBytes: number;
14
+ /** Bytes the memory grew after the first guest thread ran (V8: a trap hazard). */
15
+ memoryGrownWhileThreadsRan: number;
14
16
  }
15
17
 
16
18
  export interface PsMount {
@@ -39,6 +41,13 @@ export interface PsHostOptions {
39
41
  deterministic?: { randomSeed?: bigint };
40
42
  initialPages?: number;
41
43
  maximumPages?: number;
44
+ /**
45
+ * createPsNodeInstance grows the guest heap to the memory's maximum before
46
+ * any guest thread starts (V8 can trap a thread touching memory another
47
+ * thread has just grown). false: no pre-grow. heapBytes caps the growth.
48
+ */
49
+ growHeap?: boolean;
50
+ heapBytes?: number;
42
51
  maxHandles?: number;
43
52
  instanceId?: number;
44
53
  }
@@ -165,7 +165,27 @@ function createMemory(bytes, options) {
165
165
  }
166
166
  const initial = Math.max(limits.initial, options.initialPages ?? 0);
167
167
  const maximum = Math.min(limits.maximum ?? 65536, options.maximumPages ?? 65536);
168
- return new WebAssembly.Memory({ initial, maximum, shared: true });
168
+ const memory = new WebAssembly.Memory({ initial, maximum, shared: true });
169
+ MAXIMUM_BYTES.set(memory, maximum * 65536);
170
+ return memory;
171
+ }
172
+
173
+ // The byte size each memory may grow to (createMemory).
174
+ const MAXIMUM_BYTES = new WeakMap();
175
+
176
+ // V8 bounds-checks memory.fill/copy and atomics against each thread's cached
177
+ // view of a shared memory's size, and another thread's memory.grow updates
178
+ // that view only at this thread's next stack check. A guest thread that
179
+ // fills a block carved from memory another thread has just grown traps
180
+ // ("memory access out of bounds"). So the heap grows to the memory's maximum
181
+ // before any guest thread starts, and never grows after (a partial pre-grow
182
+ // only moves the failure). The heap stops 16 MiB short of 4 GiB: a segment
183
+ // ending at 2^32 would wrap the guest allocator's pointer arithmetic.
184
+ // WasmEdge (the SDN host) keeps one shared size and is not affected.
185
+ function heapLimitBytes(memory, options) {
186
+ const max = MAXIMUM_BYTES.get(memory) ?? memory.buffer.byteLength;
187
+ const cap = options.heapBytes ?? Infinity;
188
+ return Math.min(max, 2 ** 32 - 16 * 2 ** 20, memory.buffer.byteLength + cap);
169
189
  }
170
190
 
171
191
  /**
@@ -185,6 +205,9 @@ class Supervisor {
185
205
  this.listeners = new Set();
186
206
  this.stopped = false;
187
207
  this.poolErrors = [];
208
+ // Memory size when the first guest thread was seen running (tick): any
209
+ // growth after it is the precondition of the V8 stale-view trap above.
210
+ this.memoryAtFirstThread = 0;
188
211
  const warm = Math.min(options.warmThreads ?? 16, this.cap);
189
212
  for (let i = 0; i < warm; i += 1) this.startPoolWorker();
190
213
  this.timer = setInterval(() => this.tick(), 2);
@@ -208,6 +231,9 @@ class Supervisor {
208
231
  if (this.stopped) return;
209
232
  const want = Atomics.exchange(this.pool, POOL_WANT, 0);
210
233
  for (let i = 0; i < want; i += 1) this.startPoolWorker();
234
+ if (!this.memoryAtFirstThread && Atomics.load(this.pool, POOL_SPAWNED) > 0) {
235
+ this.memoryAtFirstThread = this.memory.buffer.byteLength;
236
+ }
211
237
  for (const listener of this.listeners) listener();
212
238
  }
213
239
 
@@ -242,6 +268,11 @@ class Supervisor {
242
268
  workerThreads: Atomics.load(c, CONTROL_STARTED),
243
269
  distinctWorkerThreadIds: tids.size,
244
270
  memoryBytes: this.memory.buffer.byteLength,
271
+ // Bytes the memory grew after the first guest thread ran (sampled every
272
+ // 2 ms). Under V8 that growth can trap a thread (heapLimitBytes).
273
+ memoryGrownWhileThreadsRan: this.memoryAtFirstThread
274
+ ? Math.max(0, this.memory.buffer.byteLength - this.memoryAtFirstThread)
275
+ : 0,
245
276
  };
246
277
  }
247
278
 
@@ -372,6 +403,14 @@ export async function createPsNodeInstance(wasm, options = {}) {
372
403
  reject(error);
373
404
  });
374
405
  });
406
+ // Before any guest thread: the heap to the memory's maximum (heapLimitBytes).
407
+ if (options.growHeap !== false) {
408
+ await new Promise((resolve, reject) => {
409
+ const id = nextId++;
410
+ pending.set(id, { resolve, reject });
411
+ worker.postMessage({ op: "growHeap", limitBytes: heapLimitBytes(memory, options), id });
412
+ });
413
+ }
375
414
  const rpc = (msg) => {
376
415
  if (failure) return Promise.reject(failure);
377
416
  const id = nextId++;
@@ -427,5 +466,11 @@ if (invokedDirectly) {
427
466
  `${t.spawnsDeclined ? `, ${t.spawnsDeclined} spawns declined` : ""}; memory ${(t.memoryBytes / 2 ** 20).toFixed(0)} MiB; ` +
428
467
  `${(r.elapsedMs / 1000).toFixed(1)} s\n`,
429
468
  );
469
+ if (t.memoryGrownWhileThreadsRan) {
470
+ process.stderr.write(
471
+ `ps-node-host: WARNING memory grew ${(t.memoryGrownWhileThreadsRan / 2 ** 20).toFixed(0)} MiB while guest ` +
472
+ `threads ran (V8 can trap a thread on memory another thread grew; grow the heap before threads start)\n`,
473
+ );
474
+ }
430
475
  process.exit(r.exitCode);
431
476
  }