flatsql 3.1.0 → 3.3.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.
package/README.md CHANGED
@@ -765,6 +765,28 @@ SELECT _source, COUNT(*) as count FROM User GROUP BY _source;
765
765
  SELECT * FROM User WHERE _source = 'satellite-1';
766
766
  ```
767
767
 
768
+ ## Database-key encryption
769
+
770
+ Fields marked `(encrypted)` in the schema are stored encrypted under the database key and decrypted when SQL reads them. The format is FlatBuffers field-encryption format 3: each record gets its own key, derived from the database key and the record's index, and each encrypted value gets its own IV, its position in the record. No two records and no two values share a key stream.
771
+
772
+ The record index is the record's sequence, its `rowid`. Records are numbered 1, 2, 3, ... in stream order, so the stream carries the index: an exported stream loaded into an empty database (`loadAndRebuild`) gives every record the index it was encrypted with. Load an encrypted stream into an empty database only.
773
+
774
+ ```javascript
775
+ db.registerFileId('SECR', 'Secret');
776
+ db.setEncryptionKey(key); // 32 bytes
777
+ const seq = db.ingestOneEncrypted(record, bfbs); // encrypted as record `seq`
778
+ db.query('SELECT code FROM Secret'); // plaintext
779
+ ```
780
+
781
+ - `bfbs` is the table's binary schema with builtin attributes (`flatc -b --schema --bfbs-builtins`). It must mark the same fields `(encrypted)` as the database schema, or the call is refused.
782
+ - `ingestOneEncrypted(record, bfbs, source?)` assigns the sequence and encrypts under it in one step. `encryptBuffer(record, bfbs, recordIndex)` and `decryptBuffer(record, bfbs, recordIndex)` take the index explicitly.
783
+ - `(encrypted)` columns are never indexed. A predicate on one scans and decrypts.
784
+ - A database that already holds records in tables with `(encrypted)` columns needs their format declared: `setEncryptionKey(key, { format: 3 })`. Nothing in the stream marks the format.
785
+
786
+ **Crypto backend.** Format 3 derives keys with HKDF-SHA256 and encrypts with AES-256-CTR, and `computeHMAC`/`verifyHMAC` are HMAC-SHA256 under the database key. All three come from the FlatBuffers crypto backend. Native builds use OpenSSL when CMake finds it. The wasm builds (`flatsql.wasm`, `flatsql-wasi.wasm`, `flatsql-wasi-noeh.wasm`) and native builds without OpenSSL compile the FlatBuffers fallback backend, which implements them from FlatBuffers 8af3053e on and derives the same keys as OpenSSL: the same key and record give the same stored bytes in every build. Built against an older FlatBuffers, the fallback's key derivation is not HKDF-SHA256 (it had 256 outputs, so records would share key streams); such a build refuses a key for a database with `(encrypted)` columns, with an error that names HKDF-SHA256. `FlatSQLDatabase::recordEncryptionAvailable()` checks the backend against an HKDF-SHA256 known answer.
787
+
788
+ **Format 2 (flatsql 3.2.0 and earlier).** Those versions encrypted every record under the same field keys, those of record 0, derived by the fallback backend. This version refuses format 2: `setEncryptionKey(key, { format: 2 })` throws, and a database that holds records must declare format 3. To migrate, use flatsql 3.2.0 and the old key to read each record of `exportData()` back as plaintext with `decryptBuffer(record, bfbs)`. Then ingest the plaintext records into a new database with `ingestOneEncrypted`.
789
+
768
790
  ## License
769
791
 
770
792
  [PolyForm Noncommercial License 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0/) — source-available, free for any noncommercial purpose. Commercial use requires a separate license from Edgesource Corporation See [LICENSE](LICENSE).
@@ -5,7 +5,9 @@ partition logs, one writer per partition on a pinned pool, durable acks,
5
5
  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
- reclamation, meta-segment retirement, disk accounting and quota. The design is
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
11
  the stack's `docs/architecture/flatsql-partition-store.md` (§22 overrides
10
12
  §0–§21; §22.4 holds the owner rulings). This file records what was built, how
11
13
  to run it, the measured acceptance, and every place the build departs from the
@@ -771,7 +773,7 @@ appended.
771
773
  first posting (FIRST or REPEAT) is also among them: a copy never leaves
772
774
  DEAD, and no older run holds any of its postings. A full fold drops every
773
775
  dead copy. GONE and REHOME entries stay: they are keyed by gseq for
774
- arrivals order, and arrivals are not compacted yet (§30).
776
+ arrivals order, and leave with their arrival entries (T3b, §33).
775
777
  - **Reader gate in production.** The writer is its own wasm instance: the host
776
778
  reads every reader instance's lane announcements
777
779
  (`FlatsqlPsReaderLayout.laneAnnounce`) and passes the minimum through
@@ -829,11 +831,11 @@ lines of `flatsql_ps_test` (RelWithDebInfo) on the task-branch build landed on
829
831
 
830
832
  | # | Acceptance | Result | Where |
831
833
  |---|---|---|---|
832
- | 1 | A partition with 50% dead bytes compacts to ≤ 55% of its prior disk bytes; owner commit p99 and interactive lane p99 ≤ 1.5× baseline during compaction; 1,000 pre-SWAP statements complete correctly | **Size and statements pass; the latency ratio is not met on the Mac (needs a quiet Linux-8 box).** Mac mem, load 31–35: 4 partitions × 20,000 OMM records, half killed: 106.4 MB → 51.9 MB (0.488×); 1,003 bulk statements that started before a SWAP returned exactly the live rows with their bytes, 0 errors (2,177 SWAPs). Latency over the whole SWAP period (the compaction plus the re-compactions that produced those statements; 16,093 samples): ack p99 0.133 → 18.5 ms, interactive lane p99 0.339 → 3.75 ms, commit round p99 1.05 ms. | `compaction_half_dead_T3_1_full` |
834
+ | 1 | A partition with 50% dead bytes compacts to ≤ 55% of its prior disk bytes; owner commit p99 and interactive lane p99 ≤ 1.5× baseline during compaction; 1,000 pre-SWAP statements complete correctly | **Size and statements pass; the latency ratio is not met on the Mac (needs a quiet Linux-8 box; T3b's Linux runs: §34).** Mac mem, load 31–35: 4 partitions × 20,000 OMM records, half killed: 106.4 MB → 51.9 MB (0.488×); 1,003 bulk statements that started before a SWAP returned exactly the live rows with their bytes, 0 errors (2,177 SWAPs). Latency over the whole SWAP period (the compaction plus the re-compactions that produced those statements; 16,093 samples): ack p99 0.133 → 18.5 ms, interactive lane p99 0.339 → 3.75 ms, commit round p99 1.05 ms. | `compaction_half_dead_T3_1_full` |
833
835
  | 2 | CAT supersede, 20% changed per cycle, 100 cycles: disk plateaus ≤ 1.3× live bytes; A9: `m` bytes ≤ one active plus one sealed segment | **Pass with the 15% trigger (deviation 24), "live bytes" read as the live set's compacted footprint.** Mac mem, load 31–33: 20,000 CAT objects, 100 cycles (each updates a random 20%), the store measured at rest after each cycle: disk peaked at 1.120× the footprint of the same live set fully compacted (19.5 MB); 346 compactions, 520 meta segments retired, 5,291 files unlinked; at most 1 meta segment on disk (A9). With §11's 25% trigger it peaks at 1.31–1.38× (six runs). Against the records' own bytes (Σ len − 4 of live PUTs, 4.9 MB) the disk is 4.5×: a fully compacted CAT record costs about 4× its frame in rows, attributes and postings, which no compaction removes | `compaction_cat_supersede_plateau_T3_2_full` |
834
836
  | 3 | Quota at 80% of current bytes: oldest records evicted first; no supersede-lane head evicted; disk ≤ cap within 3 passes; each eviction step ≤ 10 ms | **Pass (arrival order, §22.4-3).** Mac mem, load 33–35: the store with its type logs 14.1 MB, cap 11.3 MB: under the cap after 1 pass (14 segments), 0 of 256 CAT heads evicted, in each partition the evicted records are exactly its oldest (0 holes); step max 3.4 ms over 15 steps. Across partitions eviction is by whole segment, so a survivor can be older than an evicted record of another partition (288 of 6,367 records here). The 10 ms bound is enforced on a quiet box (the wasm suite at load 41 measured past it). | `quota_arrival_order_heads_spared_T3_3` |
835
837
  | 4 | 1,000 crash points during compaction: exactly one of the old or new set is live, 0 orphans, 0 acked records lost; A12: crash points inside the grace window, Σ on-disk sizes = Σ `disk_bytes` after each reopen | **Pass.** Mac mem, load 28–38: 3,224 trials, 1,000 with a compaction planned but not applied at the crash, 1,744 with retired files waiting; all five crash modes (664 drop-all, 637 drop-subset, 658 torn, 623 reordered, 642 kill -9); 41,825 compactions, 291,864 files unlinked, 24,719 meta segments retired (partitions and the type's), 723,969 dead catalog entries folded out; after every reopen each partition directory and the type directory held exactly the named files with sizes equal to the engine's disk bytes, every acked live record live with its bytes, every acked kill dead, counters equal to a recount; once labels caught up, `first_live_count` equal to the live records and 16 catalog lookups right. 507 s. The T1 crash harness (merges, A9, reclamation; compaction off: its oracle keeps dead bytes) checks the partition directories after every reopen too; the wasm build runs it ×1000. | `orphan_crash_points_during_compaction_T3_4_full`, `crash_faults_T1_1` |
836
- | 5 | Hot split at 4× single-writer capacity with 4 helpers | **Not built** (§30). | – |
838
+ | 5 | Hot split at 4× single-writer capacity with 4 helpers | **Built in T3b** (§32); ratio and correctness in §34–§35. | `hot_split_*`, `flatsql_ps_bench --mode=hotsplit` |
837
839
  | 6 | Fill the disk to ENOSPC under ingest: ingest resumes with 0 acked losses and no operator action | **Pass.** Mac mem, load 34–35, a 16 MiB device, 1 MiB ballast, two OMM producers for 4 s: 17 episodes, the ballast released 17 times and restored 16, 41,112 records acked after a recovery, 6,318 alive at the end; in each partition the surviving acked records are exactly its newest (0 holes); after a reopen (before the engine starts) the partition and type directories hold exactly the named files at the engine's disk bytes. Before type-log reclamation the type logs filled 16 of the device's 17 MB and the run ended in the emergency with no survivor. | `quota_disk_full_resumes_without_operator_T3_6` |
838
840
 
839
841
  §22 amendments naming T3:
@@ -844,8 +846,8 @@ lines of `flatsql_ps_test` (RelWithDebInfo) on the task-branch build landed on
844
846
  | A11 intents | INTENT_COMPACT built; merge and compaction intents coexist in one batch. |
845
847
  | A12 reclamation lifecycle | Built (§25): RETIRE/UNLINKED, reader gate twice a grace apart, open replays the set. |
846
848
  | A13 ENOSPC, ballast, arrival order | Built with deviations 12–13. |
847
- | A15 arrivals compaction | **Half built**: dead catalog copies are folded out of the type's runs and the type logs are reclaimed and counted (§25–§27); arrivals entries and GONE postings of dead gseqs stay (§30). |
848
- | A26 stage-1 prep states | Not built (with #5). |
849
+ | A15 arrivals compaction | Type-log half built here (§25–§27); the arrivals half in T3b (§33). |
850
+ | A26 stage-1 prep states | Built in T3b (§32, deviations 27–28, 31). |
849
851
 
850
852
  ## 29. Design deviations (T3)
851
853
 
@@ -942,26 +944,8 @@ lines of `flatsql_ps_test` (RelWithDebInfo) on the task-branch build landed on
942
944
 
943
945
  ## 30. Not built yet; running the T3 tests
944
946
 
945
- Remaining T3 scope:
946
-
947
- - **#5 hot split** with stage-1 helpers and sealed-segment re-homing (§12), and
948
- A26's ring prep states (FREE → CLAIMED(epoch) → PREPARED). Sealed segments'
949
- merges and compactions already build off the owner (deviation 1 here, T1
950
- deviation 1); what is missing is stage-1 (verify, sha256, key extraction
951
- claimed in ranges by idle writers) and its trigger. Its acceptance (≥ 2.5×
952
- the unsplit rate with 4 helpers) is a throughput ratio that needs a quiet
953
- many-core box to mean anything.
954
- - **A15 arrivals compaction**: arrivals entries (24 B) and the GONE posting
955
- of every dead gseq stay, about 40 B per record ever ingested; the quota
956
- counts them but nothing shrinks them (the type-log test: 2.4 MB of catalog
957
- runs, mostly GONE, and 2.5 MB of arrivals after 104,100 records with 835
958
- alive). The type-log half (catalog runs, manifests, meta segments, dead
959
- catalog copies) is built (§25). The arrivals half must drop an entry and its
960
- GONE posting in one commit, or offset paging (live = entries − GONE, T2)
961
- miscounts: the plan is to rewrite sealed arrivals segments inside the type
962
- merge that drops their GONE postings, named by the merge's generation in
963
- its manifest.
964
- - **#1 latency ratio** on a quiet Linux-8 box.
947
+ The T3 scope left open at 697a177 (#5 hot split, A15's arrivals half, A26,
948
+ and the #1 latency ratio on a quiet Linux-8 box) went to T3b: §32–§35.
965
949
 
966
950
  ```
967
951
  cpp/build/flatsql_ps_test --test=compaction_ # basic, T3 #1 and #2 (short forms)
@@ -973,8 +957,434 @@ cpp/build/flatsql_ps_test --test=type_logs_reclaimed_under_readers
973
957
  ```
974
958
 
975
959
  **T3 #1 on a quiet Linux-8 box** (8 cores, ext4, nothing else running), from a
976
- checkout at the landed commit; the test enforces the 1.5× bounds on such a box:
960
+ checkout at the landed commit; the test enforces the 1.5× bounds on such a box
961
+ (what it enforces since T3b: §34):
977
962
 
978
963
  ```
979
964
  cpp/build/flatsql_ps_test --test=compaction_half_dead_T3_1_full --dir=<ext4 dir>
980
965
  ```
966
+
967
+ # Part IV: T3b
968
+
969
+ ## 31. store-migrate gseqs, the entry-size setting, tag conditions
970
+
971
+ store-migrate (T6, design §16.1-5) gives every migrated FIRST copy gseq = its
972
+ legacy `sdn_record_index.rowid`, so per-schema MaxRowID and the FTS rowids
973
+ carry over.
974
+
975
+ - **Input.** `RecordAttr.migrated_gseq` (`ulong`, field 6, appended to
976
+ `schemas/flatsql_attr.fbs`; absent = 0, so older attributes are
977
+ unchanged byte for byte). `buildRecordAttr(..., migratedGseq)` writes it.
978
+ - **Row.** A new PUT whose attribute carries one gets row flag
979
+ `MIGRATED_GSEQ` (0x80). The gseq stays in the attribute (in the same meta
980
+ batch, `ATTR_IN_M`): the RecRow has no spare u64 (offsets 108–127 hold
981
+ `supersedeHash`, `tagHash` and `aux`), and the attribute is as durable as
982
+ the row. Deviation from the T6 proposal "(b) the RecRow reserved u64 at
983
+ offset 116", which T1's layout had already given to `tagHash`.
984
+ - **Labeling.** The type owner reads the flagged rows' attributes in windows
985
+ over the chunk it labels (one read per chunk of up to 4,096 rows when the
986
+ attributes fit in 1 MiB). A flagged copy labeled FIRST keeps its gseq when it
987
+ is above the type's committed `gseq_hi` and no arrival of the same type
988
+ commit holds it; the engine's gseq counter is then raised to at least gseq
989
+ + 1. Otherwise it gets an allocated gseq and counts a fallback; a flagged
990
+ copy labeled REPEAT counts a fallback too. A type commit's new arrivals are
991
+ sorted by gseq before they are appended, so arrivals stay strictly
992
+ increasing whatever order partitions are labeled in.
993
+ - **Counters.** `EngineStats::migratedGseqs` and `migratedGseqFallbacks`,
994
+ appended to `flatsql_ps_stats` (entries 24 and 25). store-migrate's
995
+ verification (§16.1-7) needs fallbacks = 0; they are counted per labeling
996
+ decision, so a type commit that fails and is relabeled counts again.
997
+ - **Crash.** The gseq is read from durable rows and attributes, so a crash
998
+ that loses the type commit relabels the same copies with the same gseqs.
999
+ An allocated fallback gseq that was never published can be reassigned
1000
+ (as for every allocated gseq).
1001
+ - **What T6 must do** (its (d)): feed each type's FIRST copies in rowid
1002
+ order and wait for `labeled_through` before crossing partitions, and run
1003
+ with fallbacks = 0. gseqs are unique per type; across types a fallback could
1004
+ reuse a legacy rowid another type migrates later, which is one more reason
1005
+ a fallback fails the migration.
1006
+ - **Entry size.** Writer TLV 19 = `maxEntryBytes` (u64; default 1 MiB +
1007
+ 4 KiB, clamped to [64 KiB, 1 GiB]): the largest ring entry (header,
1008
+ RecordAttr and frame). Each writer's arena grows to at least 4 ×
1009
+ (maxEntryBytes + 4 KiB), so the frames half holds two entries. Frames
1010
+ larger than a segment (A27 jumbo segments) are still not built.
1011
+
1012
+ Tests: `type_migrated_gseq_preserved_fallback_and_stats` (kept, fallback
1013
+ below `gseq_hi`, REPEAT copy, ordinary allocation continues above, flags on
1014
+ disk, reopen), `type_migrated_gseq_one_commit_sorted_and_crash_reopen` (two
1015
+ partitions' interleaved gseqs in one type commit come out sorted; a crash
1016
+ before and after the type commit gives the same arrivals),
1017
+ `writer_max_entry_bytes_configurable` (a 9 MiB frame refused by default,
1018
+ stored and read back at 10 MiB), `writer_capi_tlv19_max_entry_and_stats`
1019
+ (tag 19 through `flatsql_ps_init`, the 26-entry stats array).
1020
+
1021
+ ### 31.1 Tag conditions match any live tag instance (A2)
1022
+
1023
+ `_provider`, `_batch`, `_peer_id`, `_source` and `_source_name` conditions
1024
+ have the legacy tag table's ANY-row semantics (`indexedRecordWindowSQL`: a
1025
+ CID matches when one of its tag rows satisfies every requested condition).
1026
+ In format 2 a record's tag instances are its PUT's own tag and its RETAG rows
1027
+ (A2). As T2 built it, the vtab scanned tag postings (which name every
1028
+ instance, RETAGs included) but left each constraint for SQLite to re-check
1029
+ against the projected column, which shows only the PUT's own tag, so every
1030
+ record matched through a RETAG was dropped (T6 #7 on a migrated copy: a
1031
+ provider window of 200 read as 100; a source + batch window lost the
1032
+ re-tagged records).
1033
+
1034
+ Now `xBestIndex` consumes every tag condition (`omit = 1`) and the vtab
1035
+ evaluates them all on one instance:
1036
+
1037
+ - A tag or source posting scan (the plan's key) checks the remaining
1038
+ conditions on the instance the posting names (its RecordAttr), then emits
1039
+ the instance's record. A single condition that is the scanned key needs no
1040
+ attribute read unless the key was capped (over 512 bytes).
1041
+ - Any other plan (CID, column index, epoch, arrivals order, full scan)
1042
+ keeps a record when one of its live tag instances matches every condition
1043
+ (`RowFilter::hasLiveTag`, the TAG_OF postings), as the alias table's source
1044
+ filter already did.
1045
+ - An untagged record matches no tag condition (as the index-driven plans
1046
+ already behaved, T2 deviation 8), and conditions that contradict each other
1047
+ (two sources) return no rows.
1048
+ - `_source = '<TYPE>@<name>'` is compared as the column projects it: the type
1049
+ prefix is case-sensitive (a lower-case prefix returned no rows before
1050
+ either, after SQLite's re-check).
1051
+ - `_peer_id` conditions match the tag's producer peer (the TAG_PEER postings
1052
+ the T2 plan scanned); the `_peer_id` column still projects the storing
1053
+ call's `RecordAttr.peer_id`. Before, SQLite compared that BLOB column with
1054
+ the argument, so a text argument never matched.
1055
+ - `<TYPE>_current` groups first and filters after, as SQL says: its tag
1056
+ conditions stay SQLite's (the current version's own tag).
1057
+ - Projected columns are unchanged: they show the PUT's own tag.
1058
+
1059
+ Test: `lane_tag_conditions_match_any_instance_A2` (two partitions, PUT tags,
1060
+ RETAGs and REPEAT copies; eleven condition sets at type and partition level
1061
+ against an ANY-instance oracle, the full `_source` form, the alias, an
1062
+ epoch-ordered window, column and CID plans). With `omit = 0` restored it
1063
+ fails 18 checks.
1064
+
1065
+ ## 32. Hot-partition split: stage-1 helpers and prep states (§12, A26)
1066
+
1067
+ A partition keeps one appender, its owner, split or not. Splitting is a
1068
+ runtime state of the owner: nothing on disk changes, so open, readers and the
1069
+ crash rules are those of an unsplit partition.
1070
+
1071
+ **Code.** `ps/stage1.h` (slot protocol), `src/ps/stage1.cpp` (publish, take,
1072
+ stage-1 computation, helpers), `src/ps/hot_split.cpp` (trigger, split, merge
1073
+ back). `partition_log.cpp` stages from a prepared result when there is one.
1074
+
1075
+ **Trigger (§12).** A partition is split when its backlog stays above
1076
+ `hotSplitBacklogPct` (50) of its ring cap for `hotSplitAfterMs` (30 s) while no
1077
+ other partition of its owner has a backlog, on an engine with 2 writers or
1078
+ more. It merges back when the backlog stays under `hotUnsplitPct` (10) for
1079
+ `hotUnsplitAfterMs` (30 s). `Engine::setHotSplit(pid, on)` forces either
1080
+ (tests, hosts); a forced split stays until it is forced off. A quarantined
1081
+ partition merges back. Up to 16 split partitions are offered to helpers; a
1082
+ 17th is split but its owner prepares everything itself.
1083
+
1084
+ **Window.** The first split allocates the partition's prep window (2,048
1085
+ slots, 1.7 MB, heap, never freed while the engine runs). The owner publishes
1086
+ the upcoming ring entries (position, length, kind) in ordinal order, up to
1087
+ 2,048 ahead of the entry it will stage next, and tops the window up when fewer
1088
+ than half are ahead. A split partition's ring pages are mapped for the whole
1089
+ ring (the producer runs a full ring ahead of the owner, so helpers always have
1090
+ entries), and it commits up to `hotCommitFrames` (4,096) frames per round
1091
+ instead of `commitFrames` (1,024).
1092
+
1093
+ **Slot states (A26).** Each slot's state word is `{ordinal << 3 | state}` and
1094
+ moves by CAS:
1095
+
1096
+ | From | To | By |
1097
+ |---|---|---|
1098
+ | (taken) | FREE(k) | the owner publishes ordinal k |
1099
+ | FREE(k) | CLAIMED(k) | a helper, after taking k from the claim counter |
1100
+ | CLAIMED(k) | WRITING(k) | the helper, its result computed |
1101
+ | WRITING(k) | READY(k) | the helper, its result copied into the slot |
1102
+ | FREE(k) or CLAIMED(k) | OWNER(k) | the owner, staging k itself |
1103
+
1104
+ The owner takes ordinals in ring order. READY: it stages from the result.
1105
+ FREE: it takes the entry. CLAIMED: it waits up to `prepClaimWaitUs` (20 µs)
1106
+ for the helper, then takes the entry (counted as stolen). WRITING: it waits
1107
+ for one result copy. Ordinals never repeat, so a helper whose entry was taken
1108
+ fails its CLAIMED → WRITING CAS and discards what it computed (counted as
1109
+ wasted), even if the ring pages it read were recycled meanwhile.
1110
+
1111
+ **Helpers.** An idle writer (no work of its own) prepares up to
1112
+ `prepHelpBudget` (256) entries per iteration; a publish wakes up to
1113
+ `hotHelpers` (4) writers. A helper writes nothing but its claimed slot: no
1114
+ file, no ring slab, no partition state. Per record entry it runs what
1115
+ `stageRecord` does before it touches partition state: the frame check, the CID
1116
+ check or computation (sha256), the attribute check, the tag and lane hashes,
1117
+ the CRC32C of the stored bytes, and the key extraction (kept when its strings
1118
+ fit in 480 bytes). It also looks the CID up among the owner's committed
1119
+ postings (the dedupe hint): the owner publishes its L1 run set (by version)
1120
+ and the CID entries and blooms of its unmerged L0 blocks (immutable copies),
1121
+ and a helper searches those with its own file handles. The owner then
1122
+ searches only the L0 blocks committed after the hint and the entries it has
1123
+ staged. Dedupe, supersede, pseq assignment, rows, postings and the commit stay
1124
+ with the owner.
1125
+
1126
+ **Rebalance and stop.** A HANDOFF of a split partition moves it split: the
1127
+ window's positions belong to the partition, and the new owner continues from
1128
+ them. A helper counts
1129
+ itself into the window before it reads the split flag; the owner leaves the
1130
+ window only when it is unsplit and no helper is inside. `Engine::stop` drops
1131
+ the helpers' views before it closes files.
1132
+
1133
+ **Counters.** `EngineStats` splits, unsplits, prepPrepared, prepUsed,
1134
+ prepStolen, prepWasted, prepHinted, l0FullStalls; `flatsql_ps_stats` entries
1135
+ 26–33.
1136
+
1137
+ **A fix to T1's L0 accelerator** found by the crash harness with splits: when
1138
+ the partition's accelerator memory could not hold a block's bloom, the loader
1139
+ stopped at that kind and the kinds after it (TAG_OF among them) read as having
1140
+ no postings in the block, so a kill missed the record's tag instances and its
1141
+ lane counters went wrong. The loader now lists every kind and leaves out only
1142
+ the blooms it cannot hold. Split partitions map their whole ring and made the
1143
+ memory run out in the harness; any partition could.
1144
+
1145
+ Deviations from §12 and A26:
1146
+
1147
+ 26. **No SPLIT frame and no time boundary.** Sealed segments' merges and
1148
+ compactions already build off the owner (T1 deviation 1, T3 deviation 1),
1149
+ so §12's re-homing needs nothing new; what a split adds is stage 1. A
1150
+ split therefore writes nothing and survives nothing: after a restart the
1151
+ trigger decides again.
1152
+ 27. **Entries are claimed one at a time from a published window**, not in
1153
+ ranges: a helper that stalls holds one entry, which the owner takes after
1154
+ 20 µs.
1155
+ 28. **Prep states carry an ordinal, not an epoch** (A26: FREE →
1156
+ CLAIMED(epoch) → PREPARED): helpers write no file and no slab, so the
1157
+ owner's epoch guards nothing they do; the ordinal is what makes a stale
1158
+ claim fail. WRITING and OWNER are added so the owner can take an entry
1159
+ without waiting on a stalled helper.
1160
+ 29. **Merge back** (not in §12) at under 10% for 30 s, and a forced split
1161
+ (`setHotSplit`).
1162
+ 30. **Dedupe hints** (not in §12): after stage 1 the owner's largest per-entry
1163
+ cost was the CID lookup in its runs.
1164
+ 31. **A26's "helpers SIGSTOPped for 100 ms"** is a 100 ms sleep inside every
1165
+ Nth claim (`testPrepStallNs`, `testPrepStallEvery`): a single thread
1166
+ cannot be SIGSTOPped.
1167
+
1168
+ Tests:
1169
+
1170
+ - `hot_split_equals_unsplit_reference_T3_5`: the same CAT workload (puts,
1171
+ supersedes, re-tags, duplicates, kills) through a split and an unsplit
1172
+ engine with an injected clock: rows, frames, attributes and SQL results
1173
+ equal; one appending thread per ownership interval; pseqs gap-free.
1174
+ - `hot_split_rebalance_stalled_helpers_A26` (6 s; `_full` 600 s): a split
1175
+ partition flooded while 5 others trickle in a 48 MiB slab pool (slabs
1176
+ recycle across partitions), rebalances every 50 ms, a 100 ms helper stall
1177
+ every 97 claims: 0 non-owner writes, one (writer, thread) per
1178
+ ownership epoch, contiguous pseqs, and after a reopen every stored frame
1179
+ hashes to its row's CID and CRC with every sent CID present.
1180
+ - `hot_split_trigger_splits_and_merges_back`: the §12 trigger and the merge
1181
+ back with an injected clock.
1182
+ - `hot_split_throughput_T3_5` (`_full`): the §18 ratio, enforced on a quiet
1183
+ box only.
1184
+ - The T1 crash harness splits up to 16 partitions in half its stores, at
1185
+ setup and after every reopen.
1186
+
1187
+ ## 33. Arrivals compaction (A15, arrivals half)
1188
+
1189
+ T3 built the type-log half of A15 (§25). The arrivals half removes the
1190
+ arrival entries of dead gseqs, with their GONE postings.
1191
+
1192
+ **Rule.** A type merge that folds GONE postings looks at every sealed arrivals
1193
+ segment (its fence entry, fixed when the merge is planned). A segment whose
1194
+ entries those GONE postings cover by at least `arrivalsCompactRatio` (0.25) is
1195
+ rewritten without them into `ga-<gen>.fsg`, `<gen>` being the merge's output
1196
+ generation, and the merge's run leaves out those GONE postings and the REHOME
1197
+ postings of the same gseqs. Entries and their GONE postings leave in the same
1198
+ MERGE_DONE, so live = entries − GONE holds in every snapshot and offset paging
1199
+ (T2) is unchanged. GONE postings of other runs, and of the active segment,
1200
+ stay with their entries. `arrivalsCompactRatio = 0` turns the rewrite off.
1201
+
1202
+ **Manifest.** The type manifest carries an arrivals table (magic FSAC) after
1203
+ its retire set (T3 deviation 18): per rewritten segment {seg, gen, offset,
1204
+ count, first gseq, last gseq}, 40 bytes. Readers and open take a segment's
1205
+ entries from its `ga` file at that offset and its count from the table; the
1206
+ fence file is unchanged. Manifests without the table read as before.
1207
+
1208
+ **Files.** A rewritten segment's `g-<seg>` and a superseded `ga` file are
1209
+ retired through the type's retire set (A12, letters `g` and `G`). When a
1210
+ merge rewrites segments, a `ga` file that holds entries for less than half of
1211
+ its bytes is written again, so old `ga` files do not pin bytes. Open sweeps
1212
+ `ga` files that no manifest names, and counts in the disk bytes the `ga`
1213
+ files the manifest names instead of the originals they replace; a merge in
1214
+ flight counts its outputs.
1215
+
1216
+ **Quota.** The quota planner triggers the rewrite through its evictions: an
1217
+ evicted record's GONE posting reaches the next type merge. The planner does
1218
+ not request type merges itself (deviation 32).
1219
+
1220
+ **Counters.** `EngineStats` arrivalSegsCompacted and arrivalEntriesDropped;
1221
+ `flatsql_ps_stats` entries 34–35.
1222
+
1223
+ Deviation:
1224
+
1225
+ 32. **The quota planner does not start type merges** (A15: "can be triggered
1226
+ by the quota planner"). Its evictions produce the GONE postings, and the
1227
+ type owner merges on its own cadence (L0 fill); an eviction wave that
1228
+ frees little arrivals space frees it at the next merge.
1229
+
1230
+ Tests:
1231
+
1232
+ - `type_arrivals_compaction_A15`: 3 partitions, 150 records each per round,
1233
+ 70% of the live records killed per round, 3 s, with offset paging over
1234
+ arrivals (`ORDER BY _gseq LIMIT 40 OFFSET n`) and `count(*)` checked against
1235
+ the live records' gseqs every 10 rounds, then a reopen; the same run with
1236
+ the rewrite off for comparison. Mac mem, load 10: off, 191,228 entries
1237
+ appended and 191,228 kept, 4,589,472 bytes of arrivals (24 per appended
1238
+ entry); on, 151,188 appended and 425 kept (211 records live), 10,200 bytes
1239
+ (0.067 per appended entry), 7,838 segments rewritten, 150,763 entries
1240
+ dropped, 204 paging checks, 0 wrong; the type directory holds exactly the
1241
+ named files at the engine's type disk bytes, before and after the reopen.
1242
+ - `orphan_crash_points_during_compaction_T3_4` (`_full`): half the stores
1243
+ seal arrivals segments every 48 entries; after each reopen, arrivals strictly
1244
+ increasing, no dead gseq's entry visible past its segment's fence, offset
1245
+ pages equal to the live gseqs. Mac mem, load 7–12, `_full`: 2,787 trials,
1246
+ 1,000 crash points during compaction, 1,649 in the grace window, 7,592
1247
+ arrivals segments rewritten, 76,499 entries dropped, all five crash modes
1248
+ (567 drop-all, 583 drop-subset, 538 torn, 545 reordered, 554 kill -9),
1249
+ 394 s.
1250
+ - The T1 crash harness keeps every published gseq's entry (its oracle), so it
1251
+ runs with the rewrite off.
1252
+
1253
+ ## 34. T3 #1 and #5 on Linux-8 (T3b item 3)
1254
+
1255
+ **Machine.** The Linux-8 of T2: Docker Engine 29.2.0 (Docker Desktop's
1256
+ linux/arm64 VM, kernel 6.12.67-linuxkit, 16 vCPUs) on the owner's Mac Studio
1257
+ (Apple M3 Ultra, 28 cores, 256 GB), an `ubuntu:22.04` container limited to 8
1258
+ CPUs with `--cpus 8` (CFS quota 800000/100000) or pinned with
1259
+ `--cpuset-cpus 0-7`, `--memory 24g`, g++ 11.4 RelWithDebInfo, ext4 on the VM's
1260
+ virtual disk (a file on the Mac's APFS). It is not quiet: the Mac ran other
1261
+ lanes throughout (1-minute load 6–16 on 28 cores), and the VM's load average,
1262
+ recorded before each run, includes the benchmarks' own threads. Source: a `git
1263
+ archive` of the landed tree's `cpp/`.
1264
+
1265
+ ```
1266
+ docker run --rm --platform linux/arm64 --cpus 8 --memory 24g \
1267
+ -v <checkout>:/src:ro -v <flatbuffers c72a8bed>:/fb:ro ubuntu:22.04 bash -c '
1268
+ apt-get update && apt-get install -y cmake g++ make
1269
+ cmake -S /src/cpp -B /tmp/b -DCMAKE_BUILD_TYPE=RelWithDebInfo -DFLATBUFFERS_DIR=/fb
1270
+ cmake --build /tmp/b -j 8 --target flatsql_ps_test flatsql_ps_bench
1271
+ /tmp/b/flatsql_ps_bench --mode=hotsplit --records=2000000 # x3
1272
+ /tmp/b/flatsql_ps_bench --mode=hotsplit --io=fs --dir=/tmp/hs --records=1000000 # x2
1273
+ /tmp/b/flatsql_ps_test --test=compaction_half_dead_T3_1_full --dir=/tmp/c1 # ext4
1274
+ /tmp/b/flatsql_ps_test --test=compaction_half_dead_T3_1_full' # in memory
1275
+ ```
1276
+
1277
+ ### T3 #5: hot split throughput
1278
+
1279
+ One partition, one closed-loop producer (the ring stays full: the offered load
1280
+ is whatever the partition takes), 5 writers, the same engine unsplit and then
1281
+ split with 4 helpers. `mem` is the in-memory host; `ext4` commits with
1282
+ fdatasync.
1283
+
1284
+ | Run | Unsplit rec/s | Split rec/s | Ratio |
1285
+ |---|---|---|---|
1286
+ | mem, `--cpus 8`, VM load 2.0 | 185,205 | 450,587 | 2.43 |
1287
+ | mem, `--cpus 8`, 3.8 | 179,775 | 467,213 | 2.60 |
1288
+ | mem, `--cpus 8`, 5.7 | 182,512 | 472,698 | 2.59 |
1289
+ | mem, `--cpuset-cpus 0-7`, 5.1 | 176,825 | 479,294 | 2.71 |
1290
+ | mem, `--cpuset-cpus 0-7`, 5.4 | 185,216 | 479,830 | 2.59 |
1291
+ | mem, `--cpuset-cpus 0-7`, 5.6 | 176,934 | 476,050 | 2.69 |
1292
+ | ext4, `--cpus 8`, 6.5 | 142,799 | 320,235 | 2.24 |
1293
+ | ext4, `--cpus 8`, 6.9 | 157,696 | 326,783 | 2.07 |
1294
+ | ext4, `--cpuset-cpus 0-7`, 5.5 | 156,950 | 324,930 | 2.07 |
1295
+ | ext4, `--cpuset-cpus 0-7`, 5.1 | 150,486 | 333,085 | 2.21 |
1296
+
1297
+ In memory: 2.43–2.71×, median 2.60, at least 2.5 in 5 of 6 runs. The build
1298
+ before the accelerator fix (49d4a1d, the same split path) measured 2.61, 2.63,
1299
+ 2.56 (`--cpus 8`) and 2.51, 2.59, 2.56 (`--cpuset-cpus`) in memory, 1.64–2.30
1300
+ on ext4.
1301
+
1302
+ The split partition's stage-1 results: about 1.86 M of 2 M entries prepared
1303
+ with a dedupe hint the owner used, 57–151 taken back from a helper after
1304
+ 20 µs. With fdatasync every commit, the owner's syncs do not shrink with
1305
+ helpers, so the ext4 ratio is lower (the owner's CPU is no longer the whole
1306
+ cost).
1307
+
1308
+ ### T3 #1: latency during compaction
1309
+
1310
+ `compaction_half_dead_T3_1_full`: 4 partitions × 20,000 OMM records, every
1311
+ other one killed; a paced producer on a fifth partition (ack latency), an
1312
+ interactive lane asking 100-row windows, 3 bulk lanes reading whole
1313
+ partitions; a 3 s baseline, then the compaction **pass** (every sealed
1314
+ segment of the four compacted once), then the **storm**: forced
1315
+ re-compactions until 1,000 bulk statements started before a SWAP. Ratios are
1316
+ p99 during / p99 at baseline; commit round and maintenance step p99 come from
1317
+ the engine's histograms (quarter-octave buckets), ack and lane p99 from every
1318
+ sample.
1319
+
1320
+ | Run | Pass s | Commit round | Lane | Ack | Storm: commit / lane / ack |
1321
+ |---|---|---|---|---|---|
1322
+ | ext4 a, `--cpus 8`, VM load 2.0 | 0.64 | 1.57 / 2.62 ms = 0.60 | 0.49 / 0.81 ms = 0.61 | 26.5 / 8.8 ms = 3.01 | 2.8 / 0.76 / 3.9 |
1323
+ | ext4 b, `--cpus 8`, 5.7 | 2.97 | 41.9 / 21.0 = 2.00 | 0.45 / 0.83 = 0.55 | 102.9 / 77.9 = 1.32 | 2.8 / 0.51 / 1.8 |
1324
+ | ext4 c¹, `--cpus 8`, 2.8 | 0.71 | 1.00 | 1.34 / 0.91 = 1.47 | 27.6 / 14.6 = 1.89 | – |
1325
+ | ext4 d¹, `--cpus 8`, 8.9 | 3.90 | 1.67 | 1.62 / 0.85 = 1.90 | 263.4 / 56.6 = 4.66 | – |
1326
+ | ext4 e¹, `--cpus 8`, 10.2 | 1.89 | 3.50 | 0.53 / 0.57 = 0.92 | 176.9 / 43.0 = 4.11 | – |
1327
+ | ext4 f, `--cpus 8`, 6.8 | 0.80 | 4.19 / 4.19 = 1.00 | 0.56 / 0.86 = 0.65 | 51.4 / 21.0 = 2.45 | 1.0 / 0.62 / 2.9 |
1328
+ | ext4 g, `--cpuset-cpus 0-7`, 5.5 | 0.69 | 3.67 / 2.10 = 1.75 | 0.85 / 0.61 = 1.39 | 31.9 / 11.8 = 2.70 | 1.5 / 0.85 / 4.0 |
1329
+ | mem, `--cpus 8`, 9.6 | 0.16 | 0.082 / 0.066 = 1.25 | 0.44 / 0.68 = 0.65 | 0.139 / 0.234 = 0.60 | 40 / 7.1 / 50 |
1330
+ | mem, `--cpus 8`, 7.2 | 0.17 | 0.066 / 0.066 = 1.00 | 0.39 / 0.66 = 0.60 | 0.143 / 0.249 = 0.57 | 32 / 7.0 / 46 |
1331
+ | mem, `--cpuset-cpus 0-7`, 5.7 | 0.16 | 0.066 / 0.057 = 1.14 | 0.42 / 0.73 = 0.57 | 0.138 / 0.216 = 0.64 | 46 / 6.4 / 51 |
1332
+
1333
+ ¹ The "once at the end" half of the A/B runs in the notes below (the landed
1334
+ behavior); their log kept the pass ratios and the ack and lane baselines
1335
+ only. Rows a, b and the first in-memory row ran the working tree just before
1336
+ the landed commit (the same engine and test). The in-memory passes gave
1337
+ 81–85 lane samples, under the 100 the test needs to enforce.
1338
+
1339
+ - **In memory** the pass stays within 1.5× on all three.
1340
+ - **On ext4** the lane p99 stays within 1.5× in 6 of 7 runs, the commit round
1341
+ p99 in 3 of 7, the ack p99 in 1 of 7. The baseline itself moves by 9× from
1342
+ run to run (ack p99 8.8–78 ms): the virtual disk shares the Mac's SSD with
1343
+ the other lanes. The builder syncing its outputs every 1 MiB instead of
1344
+ once at the end (three runs of each, interleaved) gave ack ratios 1.07,
1345
+ 1.80, 6.67 against 1.89, 4.66, 4.11 and commit round ratios 2.5, 1.67, 19.2
1346
+ against 1.0, 1.67, 3.5: nothing the variance does not cover, so it is not
1347
+ kept.
1348
+ - **The storm** (5,000–7,000 forced SWAPs) raises ack p99 1.8–4× on ext4 and
1349
+ 46–51× in memory, and the in-memory lane p99 6–7×. Its SWAPs are the test's
1350
+ device for collecting pre-SWAP statements, not compactions the trigger
1351
+ would start.
1352
+
1353
+ So **T3 #1's latency ratio is not shown on this machine**: the pass meets it
1354
+ in memory, the ext4 runs are dominated by the virtual disk. It needs a quiet
1355
+ Linux box with its own disk; the test enforces the bound there (deviation
1356
+ 33).
1357
+
1358
+ Deviation:
1359
+
1360
+ 33. **T3 #1 is measured and enforced on the compaction pass** with the
1361
+ design's two metrics (owner commit round p99, interactive lane p99), when
1362
+ the pass gives 100 samples of each; the storm and the ack p99 are
1363
+ reported. T3 enforced ack and lane p99 over the storm, whose thousands of
1364
+ back-to-back SWAPs are not "the compaction" of §18.
1365
+
1366
+ ## 35. T3b acceptance, what remains
1367
+
1368
+ | Item | Result |
1369
+ |---|---|
1370
+ | 0: store-migrate gseqs, TLV 19, tag conditions | **Done** (ad07b80, §31); released as 3.2.0 by T6. |
1371
+ | 1: T3 #5 hot split, A26 | **Built** (§32). Correctness: split = unsplit reference (rows, frames, attributes, SQL), gap-free pseqs, one appending thread per ownership interval; A26 (6 s, Mac mem, load 5–48): 108 rebalances, 163 helper stalls of 100 ms, 44 ownership intervals, 0 non-owner writes, after a reopen 1,094,610 rows checked with 0 corrupt frames. Throughput on the Docker Linux-8 in memory: 2.43–2.71×, median 2.60, ≥ 2.5 in 5 of 6 runs; on ext4 with fdatasync 2.07–2.24× (§34). |
1372
+ | 2: A15 arrivals half | **Built** (§33): 0.067 bytes of arrivals per appended entry under churn against 24 without it, offset paging exact, disk bytes = the files, 1,000 crash points with arrivals rewrites. The planner triggers it through its evictions only (deviation 32). |
1373
+ | 3: ratios on quiet Linux-8 | Measured on the Docker Linux-8 (§34): #5 as above; **#1 not shown** there (ext4 variance), met in memory. |
1374
+ | 4: artifact, CI, gauntlet | `wasm/flatsql-ps-threads.wasm` rebuilt with the Linux wasi-sdk 30 (exports unchanged). |
1375
+
1376
+ Remaining:
1377
+
1378
+ - **T3 #1 on a quiet Linux-8 box with a local disk**: `cpp/build/flatsql_ps_test
1379
+ --test=compaction_half_dead_T3_1_full --dir=<ext4 dir>` (it enforces the
1380
+ bound when the load is under a quarter of the cores); and the hot split's
1381
+ ext4 ratio there (`flatsql_ps_bench --mode=hotsplit --io=fs --dir=<dir>`).
1382
+ - The quota planner requesting type merges (deviation 32).
1383
+
1384
+ ```
1385
+ cpp/build/flatsql_ps_test --test=hot_split_ # T3 #5, A26, trigger
1386
+ cpp/build/flatsql_ps_test --test=hot_split_rebalance_stalled_helpers_A26_full # 10 min
1387
+ cpp/build/flatsql_ps_test --test=type_arrivals_compaction_A15 [--seconds=N]
1388
+ cpp/build/flatsql_ps_test --test=orphan_crash_points_during_compaction_T3_4_full
1389
+ cpp/build/flatsql_ps_bench --mode=hotsplit [--helpers=4] [--io=mem|fs] [--dir=D] [--records=N]
1390
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatsql",
3
- "version": "3.1.0",
3
+ "version": "3.3.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["Ra"]()}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_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_viij,dynCall_iid,dynCall_dii,dynCall_iiiiiiiiii,dynCall_iiiiiiii,dynCall_viijii,dynCall_di,dynCall_iiiid,dynCall_iij,dynCall_viidi,dynCall_vid,dynCall_vidd,dynCall_dd,dynCall_ddd,dynCall_jiiii,dynCall_viiiiiiii,dynCall_iiiddddddddi,dynCall_iiiij,dynCall_vijii,dynCall_iijj,dynCall_iijii,dynCall_ji,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["Ta"];_malloc=Module["_malloc"]=wasmExports["Ua"];_flatsql_create_db=Module["_flatsql_create_db"]=wasmExports["Va"];_flatsql_open_db=Module["_flatsql_open_db"]=wasmExports["Wa"];_flatsql_is_disk_backed=Module["_flatsql_is_disk_backed"]=wasmExports["Xa"];_flatsql_open_state=Module["_flatsql_open_state"]=wasmExports["Ya"];_flatsql_reindex_all=Module["_flatsql_reindex_all"]=wasmExports["Za"];_flatsql_reindex_step=Module["_flatsql_reindex_step"]=wasmExports["_a"];_flatsql_flush_index=Module["_flatsql_flush_index"]=wasmExports["$a"];_flatsql_flushed_offset=Module["_flatsql_flushed_offset"]=wasmExports["ab"];_flatsql_stream_path=Module["_flatsql_stream_path"]=wasmExports["bb"];_flatsql_destroy_db=Module["_flatsql_destroy_db"]=wasmExports["cb"];_flatsql_register_file_id=Module["_flatsql_register_file_id"]=wasmExports["db"];_flatsql_enable_demo_extractors=Module["_flatsql_enable_demo_extractors"]=wasmExports["eb"];_flatsql_ingest=Module["_flatsql_ingest"]=wasmExports["fb"];_flatsql_ingest_one=Module["_flatsql_ingest_one"]=wasmExports["gb"];_flatsql_register_source=Module["_flatsql_register_source"]=wasmExports["hb"];_flatsql_create_unified_views=Module["_flatsql_create_unified_views"]=wasmExports["ib"];_flatsql_ingest_with_source=Module["_flatsql_ingest_with_source"]=wasmExports["jb"];_flatsql_ingest_one_with_source=Module["_flatsql_ingest_one_with_source"]=wasmExports["kb"];_flatsql_set_arena_limit=Module["_flatsql_set_arena_limit"]=wasmExports["lb"];_flatsql_query=Module["_flatsql_query"]=wasmExports["mb"];_flatsql_query_params=Module["_flatsql_query_params"]=wasmExports["nb"];_flatsql_query_many=Module["_flatsql_query_many"]=wasmExports["ob"];_flatsql_batch_result_count=Module["_flatsql_batch_result_count"]=wasmExports["pb"];_flatsql_select_batch_result=Module["_flatsql_select_batch_result"]=wasmExports["qb"];_flatsql_get_error=Module["_flatsql_get_error"]=wasmExports["rb"];_flatsql_build_query_cache_key=Module["_flatsql_build_query_cache_key"]=wasmExports["sb"];_flatsql_build_response_artifact_cache_key=Module["_flatsql_build_response_artifact_cache_key"]=wasmExports["tb"];_flatsql_register_query_template=Module["_flatsql_register_query_template"]=wasmExports["ub"];_flatsql_query_template=Module["_flatsql_query_template"]=wasmExports["vb"];_flatsql_clear_query_cache=Module["_flatsql_clear_query_cache"]=wasmExports["wb"];_flatsql_configure_query_cache=Module["_flatsql_configure_query_cache"]=wasmExports["xb"];_flatsql_query_cache_hits=Module["_flatsql_query_cache_hits"]=wasmExports["yb"];_flatsql_query_cache_misses=Module["_flatsql_query_cache_misses"]=wasmExports["zb"];_flatsql_query_cache_size=Module["_flatsql_query_cache_size"]=wasmExports["Ab"];_flatsql_query_cache_generation=Module["_flatsql_query_cache_generation"]=wasmExports["Bb"];_flatsql_query_cache_max_entries=Module["_flatsql_query_cache_max_entries"]=wasmExports["Cb"];_flatsql_query_cache_max_rows=Module["_flatsql_query_cache_max_rows"]=wasmExports["Db"];_flatsql_result_column_count=Module["_flatsql_result_column_count"]=wasmExports["Eb"];_flatsql_result_row_count=Module["_flatsql_result_row_count"]=wasmExports["Fb"];_flatsql_result_column_name=Module["_flatsql_result_column_name"]=wasmExports["Gb"];_flatsql_result_cell_type=Module["_flatsql_result_cell_type"]=wasmExports["Hb"];_flatsql_result_cell_number=Module["_flatsql_result_cell_number"]=wasmExports["Ib"];_flatsql_result_cell_string=Module["_flatsql_result_cell_string"]=wasmExports["Jb"];_flatsql_result_cell_blob=Module["_flatsql_result_cell_blob"]=wasmExports["Kb"];_flatsql_result_cell_blob_size=Module["_flatsql_result_cell_blob_size"]=wasmExports["Lb"];_flatsql_export_data=Module["_flatsql_export_data"]=wasmExports["Mb"];_flatsql_query_raw_flatbuffer_stream=Module["_flatsql_query_raw_flatbuffer_stream"]=wasmExports["Nb"];_flatsql_query_sandboxed=Module["_flatsql_query_sandboxed"]=wasmExports["Ob"];_flatsql_response_artifact_data=Module["_flatsql_response_artifact_data"]=wasmExports["Pb"];_flatsql_response_artifact_size=Module["_flatsql_response_artifact_size"]=wasmExports["Qb"];_flatsql_response_artifact_cache_hit=Module["_flatsql_response_artifact_cache_hit"]=wasmExports["Rb"];_flatsql_configure_raw_stream_cache=Module["_flatsql_configure_raw_stream_cache"]=wasmExports["Sb"];_flatsql_raw_stream_cache_hits=Module["_flatsql_raw_stream_cache_hits"]=wasmExports["Tb"];_flatsql_raw_stream_cache_misses=Module["_flatsql_raw_stream_cache_misses"]=wasmExports["Ub"];_flatsql_raw_stream_cache_size=Module["_flatsql_raw_stream_cache_size"]=wasmExports["Vb"];_flatsql_raw_stream_cache_total_bytes=Module["_flatsql_raw_stream_cache_total_bytes"]=wasmExports["Wb"];_flatsql_response_artifact_row_count=Module["_flatsql_response_artifact_row_count"]=wasmExports["Xb"];_flatsql_response_artifact_column_count=Module["_flatsql_response_artifact_column_count"]=wasmExports["Yb"];_flatsql_export_size=Module["_flatsql_export_size"]=wasmExports["Zb"];_flatsql_load_and_rebuild=Module["_flatsql_load_and_rebuild"]=wasmExports["_b"];_flatsql_reserve_storage=Module["_flatsql_reserve_storage"]=wasmExports["$b"];_flatsql_load_from_db=Module["_flatsql_load_from_db"]=wasmExports["ac"];_flatsql_create_test_user=Module["_flatsql_create_test_user"]=wasmExports["bc"];_flatsql_test_buffer_size=Module["_flatsql_test_buffer_size"]=wasmExports["cc"];_flatsql_create_test_post=Module["_flatsql_create_test_post"]=wasmExports["dc"];_flatsql_create_test_mpe=Module["_flatsql_create_test_mpe"]=wasmExports["ec"];_flatsql_create_test_telemetry=Module["_flatsql_create_test_telemetry"]=wasmExports["fc"];_flatsql_create_test_publish_event=Module["_flatsql_create_test_publish_event"]=wasmExports["gc"];_flatsql_get_stats_count=Module["_flatsql_get_stats_count"]=wasmExports["hc"];_flatsql_get_stat_table_name=Module["_flatsql_get_stat_table_name"]=wasmExports["ic"];_flatsql_get_stat_file_id=Module["_flatsql_get_stat_file_id"]=wasmExports["jc"];_flatsql_get_stat_record_count=Module["_flatsql_get_stat_record_count"]=wasmExports["kc"];_flatsql_reset_ingest_profile=Module["_flatsql_reset_ingest_profile"]=wasmExports["lc"];_flatsql_get_ingest_profile_record_count=Module["_flatsql_get_ingest_profile_record_count"]=wasmExports["mc"];_flatsql_get_ingest_profile_byte_count=Module["_flatsql_get_ingest_profile_byte_count"]=wasmExports["nc"];_flatsql_get_ingest_profile_decode_nanos=Module["_flatsql_get_ingest_profile_decode_nanos"]=wasmExports["oc"];_flatsql_get_ingest_profile_append_nanos=Module["_flatsql_get_ingest_profile_append_nanos"]=wasmExports["pc"];_flatsql_get_ingest_profile_index_nanos=Module["_flatsql_get_ingest_profile_index_nanos"]=wasmExports["qc"];_flatsql_mark_deleted=Module["_flatsql_mark_deleted"]=wasmExports["rc"];_flatsql_get_deleted_count=Module["_flatsql_get_deleted_count"]=wasmExports["sc"];_flatsql_clear_tombstones=Module["_flatsql_clear_tombstones"]=wasmExports["tc"];_flatsql_get_sources_count=Module["_flatsql_get_sources_count"]=wasmExports["uc"];_flatsql_get_source_name=Module["_flatsql_get_source_name"]=wasmExports["vc"];_flatsql_get_flatbuffer_by_id=Module["_flatsql_get_flatbuffer_by_id"]=wasmExports["wc"];_flatsql_get_flatbuffer_by_email=Module["_flatsql_get_flatbuffer_by_email"]=wasmExports["xc"];_flatsql_get_flatbuffer_by_index=Module["_flatsql_get_flatbuffer_by_index"]=wasmExports["yc"];_flatsql_get_raw_flatbuffer_size=Module["_flatsql_get_raw_flatbuffer_size"]=wasmExports["zc"];_flatsql_get_raw_flatbuffer_sequence=Module["_flatsql_get_raw_flatbuffer_sequence"]=wasmExports["Ac"];_flatsql_get_storage_buffer=Module["_flatsql_get_storage_buffer"]=wasmExports["Bc"];_flatsql_get_storage_size=Module["_flatsql_get_storage_size"]=wasmExports["Cc"];_flatsql_set_encryption_key=Module["_flatsql_set_encryption_key"]=wasmExports["Dc"];_flatsql_is_encrypted=Module["_flatsql_is_encrypted"]=wasmExports["Ec"];_flatsql_encrypt_buffer=Module["_flatsql_encrypt_buffer"]=wasmExports["Fc"];_flatsql_decrypt_buffer=Module["_flatsql_decrypt_buffer"]=wasmExports["Gc"];_flatsql_set_hmac_verification=Module["_flatsql_set_hmac_verification"]=wasmExports["Hc"];_flatsql_is_hmac_enabled=Module["_flatsql_is_hmac_enabled"]=wasmExports["Ic"];_flatsql_compute_hmac=Module["_flatsql_compute_hmac"]=wasmExports["Jc"];_flatsql_verify_hmac=Module["_flatsql_verify_hmac"]=wasmExports["Kc"];_setThrew=wasmExports["Lc"];__emscripten_tempret_set=wasmExports["Mc"];__emscripten_stack_restore=wasmExports["Nc"];__emscripten_stack_alloc=wasmExports["Oc"];_emscripten_stack_get_current=wasmExports["Pc"];___cxa_decrement_exception_refcount=wasmExports["Qc"];___cxa_increment_exception_refcount=wasmExports["Rc"];___cxa_can_catch=wasmExports["Sc"];___cxa_get_exception_ptr=wasmExports["Tc"];dynCall_v=wasmExports["Uc"];dynCall_ii=wasmExports["Vc"];dynCall_iii=wasmExports["Wc"];dynCall_viiiiii=wasmExports["Xc"];dynCall_vii=wasmExports["Yc"];dynCall_viii=wasmExports["Zc"];dynCall_iiii=wasmExports["_c"];dynCall_iiiiii=wasmExports["$c"];dynCall_vi=wasmExports["ad"];dynCall_viiii=wasmExports["bd"];dynCall_jii=wasmExports["cd"];dynCall_viiiii=wasmExports["dd"];dynCall_iiiiiii=wasmExports["ed"];dynCall_iiiii=wasmExports["fd"];dynCall_i=wasmExports["gd"];dynCall_iiij=wasmExports["hd"];dynCall_iiid=wasmExports["id"];dynCall_viijij=wasmExports["jd"];dynCall_viiijj=wasmExports["kd"];dynCall_jiiiii=wasmExports["ld"];dynCall_iiiiiiiiiiii=wasmExports["md"];dynCall_vij=wasmExports["nd"];dynCall_iiji=wasmExports["od"];dynCall_iijiii=wasmExports["pd"];dynCall_viijj=wasmExports["qd"];dynCall_viij=wasmExports["rd"];dynCall_iid=wasmExports["sd"];dynCall_dii=wasmExports["td"];dynCall_iiiiiiiiii=wasmExports["ud"];dynCall_iiiiiiii=wasmExports["vd"];dynCall_viijii=wasmExports["wd"];dynCall_di=wasmExports["xd"];dynCall_iiiid=wasmExports["yd"];dynCall_iij=wasmExports["zd"];dynCall_viidi=wasmExports["Ad"];dynCall_vid=wasmExports["Bd"];dynCall_vidd=wasmExports["dynCall_vidd"];dynCall_dd=wasmExports["dynCall_dd"];dynCall_ddd=wasmExports["dynCall_ddd"];dynCall_jiiii=wasmExports["Cd"];dynCall_viiiiiiii=wasmExports["Dd"];dynCall_iiiddddddddi=wasmExports["Ed"];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_iidiiii=wasmExports["dynCall_iidiiii"];dynCall_j=wasmExports["Fd"];dynCall_iiiiij=wasmExports["Gd"];dynCall_iiiiid=wasmExports["Hd"];dynCall_iiiiiiiiiii=wasmExports["dynCall_iiiiiiiiiii"];dynCall_iiiiiiiiiiiii=wasmExports["dynCall_iiiiiiiiiiiii"];dynCall_fiii=wasmExports["Id"];dynCall_diii=wasmExports["Jd"];dynCall_viiiiiii=wasmExports["Kd"];dynCall_viiiiiiiiii=wasmExports["Ld"];dynCall_viiiiiiiiiiiiiii=wasmExports["Md"];dynCall_iiiiiiiii=wasmExports["dynCall_iiiiiiiii"];dynCall_iiiiijj=wasmExports["dynCall_iiiiijj"];dynCall_iiiiiijj=wasmExports["dynCall_iiiiiijj"];memory=wasmMemory=wasmExports["Qa"];__indirect_function_table=wasmTable=wasmExports["Sa"]}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,$:___cxa_rethrow,o:___cxa_throw,ga:___cxa_uncaught_exceptions,e:___resumeException,Ga:___syscall_chmod,Ia:___syscall_faccessat,Ha:___syscall_fchmod,Fa:___syscall_fchown32,z:___syscall_fcntl64,Ea:___syscall_fstat64,za:___syscall_ftruncate64,ya:___syscall_getcwd,Ba:___syscall_lstat64,ua:___syscall_mkdirat,Ca:___syscall_newfstatat,qa:___syscall_openat,oa:___syscall_readlinkat,na:___syscall_rmdir,Da:___syscall_stat64,la:___syscall_unlinkat,ka:___syscall_utimensat,ea:__abort_js,sa:__localtime_js,ta:__tzset_js,ra:_clock_time_get,T:_emscripten_date_now,S:_emscripten_get_now,ia:_emscripten_resize_heap,wa:_environ_get,xa:_environ_sizes_get,U:_fd_close,ja:_fd_fdstat_get,pa:_fd_read,va:_fd_seek,Aa:_fd_sync,ma:_fd_write,Y:_flatsql_io_close,A:_flatsql_io_open,Z:_flatsql_io_read,_:_flatsql_io_size,W:_flatsql_io_sync,Ja:_flatsql_io_truncate,X:_flatsql_io_write,x:invoke_di,J:invoke_dii,L:invoke_diii,Q:invoke_fiii,t:invoke_i,c:invoke_ii,O:invoke_iid,g:invoke_iii,K:invoke_iiid,Ka:invoke_iiiddddddddi,h:invoke_iiii,I:invoke_iiiid,n:invoke_iiiii,fa:invoke_iiiiid,m:invoke_iiiiii,s:invoke_iiiiiii,M:invoke_iiiiiiii,N:invoke_iiiiiiiiii,F:invoke_iiiiiiiiiiii,R:invoke_iiiiij,Pa:invoke_iiij,Ma:invoke_iij,E:invoke_iiji,Na:invoke_iijiii,ha:invoke_j,B:invoke_jii,D:invoke_jiiii,ba:invoke_jiiiii,f:invoke_v,k:invoke_vi,H:invoke_vid,b:invoke_vii,V:invoke_viidi,i:invoke_viii,j:invoke_viiii,u:invoke_viiiii,r:invoke_viiiiii,w:invoke_viiiiiii,La:invoke_viiiiiiii,C:invoke_viiiiiiiiii,G:invoke_viiiiiiiiiiiiiii,ca:invoke_viiijj,da:invoke_viij,P:invoke_viijii,Oa:invoke_viijij,aa: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_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_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_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_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_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_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["Ua"]=makeWrapper_pp(wasmExports["Ua"]);wasmExports["Oc"]=makeWrapper_pp(wasmExports["Oc"]);wasmExports["Pc"]=makeWrapper_p(wasmExports["Pc"]);wasmExports["Tc"]=makeWrapper_pp(wasmExports["Tc"]);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["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})}
2
2
  ;return moduleRtn}export default FlatSQL;
package/wasm/flatsql.wasm CHANGED
Binary file
package/wasm/index.d.ts CHANGED
@@ -296,14 +296,21 @@ export interface FlatSQLDatabase {
296
296
  destroy(): void;
297
297
 
298
298
  // ==================== Encryption ====================
299
+ //
300
+ // The (encrypted) fields of a record are encrypted under FlatBuffers field
301
+ // encryption format 3: each record under its own key, with its sequence
302
+ // (rowid) as the record index, so no two records share a key stream.
299
303
 
300
304
  /**
301
- * Set the encryption key for field-level FlatBuffer decryption.
302
- * Fields marked with (encrypted) in the schema will be transparently
305
+ * Set the database key. Fields marked with (encrypted) in the schema are
303
306
  * decrypted when read through SQL queries.
304
307
  * @param key 32-byte AES-256 key
308
+ * @param options.format The field-encryption format of the records the
309
+ * database already holds in tables with (encrypted) columns: required (3)
310
+ * when it holds any. Format 2 (records encrypted by flatsql 3.2.0 or
311
+ * earlier) is refused: see README "Database-key encryption".
305
312
  */
306
- setEncryptionKey(key: Uint8Array): void;
313
+ setEncryptionKey(key: Uint8Array, options?: { format?: 3 }): void;
307
314
 
308
315
  /**
309
316
  * Check if encryption is enabled
@@ -311,20 +318,33 @@ export interface FlatSQLDatabase {
311
318
  isEncrypted(): boolean;
312
319
 
313
320
  /**
314
- * Encrypt a FlatBuffer using the database's encryption key
315
- * @param buffer FlatBuffer data
316
- * @param schema Binary schema (.bfbs)
321
+ * Encrypt the (encrypted) fields of a FlatBuffer as the record with index
322
+ * `recordIndex`, the sequence it has or gets in this database. To write
323
+ * encrypted records use ingestOneEncrypted.
324
+ * @param buffer FlatBuffer data (no size prefix)
325
+ * @param schema Binary schema (.bfbs) with builtin attributes (flatc --bfbs-builtins)
326
+ * @param recordIndex The record's sequence (1 to 4294967295)
317
327
  * @returns Encrypted buffer copy
318
328
  */
319
- encryptBuffer(buffer: Uint8Array, schema: Uint8Array): Uint8Array;
329
+ encryptBuffer(buffer: Uint8Array, schema: Uint8Array, recordIndex: number): Uint8Array;
320
330
 
321
331
  /**
322
- * Decrypt a FlatBuffer using the database's encryption key
323
- * @param buffer Encrypted FlatBuffer data
324
- * @param schema Binary schema (.bfbs)
332
+ * Decrypt the (encrypted) fields of a stored FlatBuffer
333
+ * @param buffer Encrypted FlatBuffer data (no size prefix)
334
+ * @param schema Binary schema (.bfbs) with builtin attributes (flatc --bfbs-builtins)
335
+ * @param recordIndex The record's sequence (1 to 4294967295)
325
336
  * @returns Decrypted buffer copy
326
337
  */
327
- decryptBuffer(buffer: Uint8Array, schema: Uint8Array): Uint8Array;
338
+ decryptBuffer(buffer: Uint8Array, schema: Uint8Array, recordIndex: number): Uint8Array;
339
+
340
+ /**
341
+ * Encrypt a plaintext FlatBuffer under the sequence it gets and ingest it
342
+ * @param data FlatBuffer data (no size prefix)
343
+ * @param schema Binary schema (.bfbs) with builtin attributes (flatc --bfbs-builtins)
344
+ * @param source Source name, as for ingestOne
345
+ * @returns The record's sequence
346
+ */
347
+ ingestOneEncrypted(data: Uint8Array, schema: Uint8Array, source?: string | null): number;
328
348
 
329
349
  // ==================== HMAC Authentication ====================
330
350
 
package/wasm/index.js CHANGED
@@ -367,11 +367,12 @@ export async function initFlatSQL(moduleFactoryOrOptions) {
367
367
  getStorageBuffer: Module.cwrap('flatsql_get_storage_buffer', 'number', ['number']),
368
368
  getStorageSize: Module.cwrap('flatsql_get_storage_size', 'number', ['number']),
369
369
 
370
- // Encryption
371
- setEncryptionKey: Module.cwrap('flatsql_set_encryption_key', 'number', ['number', 'number', 'number']),
370
+ // Encryption (field-encryption format 3; the record index is the sequence)
371
+ setEncryptionKey: Module.cwrap('flatsql_set_encryption_key', 'number', ['number', 'number', 'number', 'number']),
372
372
  isEncrypted: Module.cwrap('flatsql_is_encrypted', 'number', ['number']),
373
- encryptBuffer: Module.cwrap('flatsql_encrypt_buffer', 'number', ['number', 'number', 'number', 'number', 'number']),
374
- decryptBuffer: Module.cwrap('flatsql_decrypt_buffer', 'number', ['number', 'number', 'number', 'number', 'number']),
373
+ encryptBuffer: Module.cwrap('flatsql_encrypt_buffer', 'number', ['number', 'number', 'number', 'number', 'number', 'number']),
374
+ decryptBuffer: Module.cwrap('flatsql_decrypt_buffer', 'number', ['number', 'number', 'number', 'number', 'number', 'number']),
375
+ ingestOneEncrypted: Module.cwrap('flatsql_ingest_one_encrypted', 'number', ['number', 'number', 'number', 'number', 'number', 'string']),
375
376
 
376
377
  // HMAC Authentication
377
378
  setHMACVerification: Module.cwrap('flatsql_set_hmac_verification', 'number', ['number', 'number']),
@@ -424,6 +425,15 @@ function setHeapBytes(data, ptr) {
424
425
  Module.HEAPU8.set(data, wasmPointerToByteOffset(ptr));
425
426
  }
426
427
 
428
+ // A record index is the record's sequence (rowid): 1 to 4294967295.
429
+ function requireRecordIndex(method, recordIndex) {
430
+ if (!Number.isInteger(recordIndex) || recordIndex < 1 || recordIndex > 0xFFFFFFFF) {
431
+ throw new TypeError(
432
+ `${method}: recordIndex must be the record's sequence, an integer from 1 to 4294967295 ` +
433
+ '(field-encryption format 2, without a record index, is not supported)');
434
+ }
435
+ }
436
+
427
437
  function withHeapBytes(data, callback) {
428
438
  const ptr = Module._malloc(data.length);
429
439
  try {
@@ -1131,16 +1141,26 @@ export class FlatSQLDatabase {
1131
1141
  }
1132
1142
 
1133
1143
  // ==================== Encryption API ====================
1144
+ //
1145
+ // The (encrypted) fields of a record are encrypted under FlatBuffers field
1146
+ // encryption format 3: each record under its own key, with its sequence
1147
+ // (rowid) as the record index, so no two records share a key stream.
1134
1148
 
1135
1149
  /**
1136
- * Set the encryption key for field-level FlatBuffer decryption.
1150
+ * Set the database key. SQL decrypts the (encrypted) columns with it.
1137
1151
  * @param {Uint8Array} key - 32-byte AES-256 key
1152
+ * @param {{format?: number}} [options] - format: the field-encryption format
1153
+ * of the records the database already holds in tables with (encrypted)
1154
+ * columns. Required (3) when it holds any. Format 2 (records encrypted by
1155
+ * flatsql 3.2.0 or earlier) is refused: see README "Database-key encryption".
1138
1156
  */
1139
- setEncryptionKey(key) {
1140
- const ptr = Module._malloc(key.length);
1141
- setHeapBytes(key, ptr);
1142
- const result = api.setEncryptionKey(this._handle, ptr, key.length);
1143
- Module._free(ptr);
1157
+ setEncryptionKey(key, options = {}) {
1158
+ const format = options && options.format !== undefined ? options.format : 0;
1159
+ if (!Number.isInteger(format) || format < 0 || format > 255) {
1160
+ throw new TypeError('setEncryptionKey: options.format must be 3');
1161
+ }
1162
+ const result = withHeapBytes(key, (ptr) =>
1163
+ api.setEncryptionKey(this._handle, ptr, key.length, format));
1144
1164
  if (!result) throw new Error(api.getError());
1145
1165
  }
1146
1166
 
@@ -1153,41 +1173,60 @@ export class FlatSQLDatabase {
1153
1173
  }
1154
1174
 
1155
1175
  /**
1156
- * Encrypt a FlatBuffer in-place using the database's encryption key.
1157
- * @param {Uint8Array} buffer - FlatBuffer data
1158
- * @param {Uint8Array} schema - Binary schema (.bfbs)
1176
+ * Encrypt the (encrypted) fields of a FlatBuffer as the record with index
1177
+ * `recordIndex`: the sequence it has, or gets, in this database. To write
1178
+ * encrypted records use ingestOneEncrypted, which assigns and uses the
1179
+ * sequence together.
1180
+ * @param {Uint8Array} buffer - FlatBuffer data (no size prefix)
1181
+ * @param {Uint8Array} schema - Binary schema (.bfbs) with builtin attributes (flatc --bfbs-builtins)
1182
+ * @param {number} recordIndex - The record's sequence (1 to 4294967295)
1159
1183
  * @returns {Uint8Array} Encrypted buffer (copy)
1160
1184
  */
1161
- encryptBuffer(buffer, schema) {
1162
- const bufPtr = Module._malloc(buffer.length);
1163
- setHeapBytes(buffer, bufPtr);
1164
- const schemaPtr = Module._malloc(schema.length);
1165
- setHeapBytes(schema, schemaPtr);
1166
- const result = api.encryptBuffer(this._handle, bufPtr, buffer.length, schemaPtr, schema.length);
1167
- const encrypted = copyHeapBytes(bufPtr, buffer.length);
1168
- Module._free(bufPtr);
1169
- Module._free(schemaPtr);
1170
- if (!result) throw new Error(api.getError());
1171
- return encrypted;
1185
+ encryptBuffer(buffer, schema, recordIndex) {
1186
+ requireRecordIndex('encryptBuffer', recordIndex);
1187
+ return this._cipherBuffer(api.encryptBuffer, buffer, schema, recordIndex);
1172
1188
  }
1173
1189
 
1174
1190
  /**
1175
- * Decrypt a FlatBuffer in-place using the database's encryption key.
1176
- * @param {Uint8Array} buffer - Encrypted FlatBuffer data
1177
- * @param {Uint8Array} schema - Binary schema (.bfbs)
1191
+ * Decrypt the (encrypted) fields of a stored FlatBuffer.
1192
+ * @param {Uint8Array} buffer - Encrypted FlatBuffer data (no size prefix)
1193
+ * @param {Uint8Array} schema - Binary schema (.bfbs) with builtin attributes (flatc --bfbs-builtins)
1194
+ * @param {number} recordIndex - The record's sequence (1 to 4294967295)
1178
1195
  * @returns {Uint8Array} Decrypted buffer (copy)
1179
1196
  */
1180
- decryptBuffer(buffer, schema) {
1197
+ decryptBuffer(buffer, schema, recordIndex) {
1198
+ requireRecordIndex('decryptBuffer', recordIndex);
1199
+ return this._cipherBuffer(api.decryptBuffer, buffer, schema, recordIndex);
1200
+ }
1201
+
1202
+ _cipherBuffer(cipher, buffer, schema, recordIndex) {
1181
1203
  const bufPtr = Module._malloc(buffer.length);
1182
- setHeapBytes(buffer, bufPtr);
1183
1204
  const schemaPtr = Module._malloc(schema.length);
1184
- setHeapBytes(schema, schemaPtr);
1185
- const result = api.decryptBuffer(this._handle, bufPtr, buffer.length, schemaPtr, schema.length);
1186
- const decrypted = copyHeapBytes(bufPtr, buffer.length);
1187
- Module._free(bufPtr);
1188
- Module._free(schemaPtr);
1189
- if (!result) throw new Error(api.getError());
1190
- return decrypted;
1205
+ try {
1206
+ setHeapBytes(buffer, bufPtr);
1207
+ setHeapBytes(schema, schemaPtr);
1208
+ const result = cipher(this._handle, bufPtr, buffer.length, schemaPtr, schema.length, recordIndex);
1209
+ if (!result) throw new Error(api.getError());
1210
+ return copyHeapBytes(bufPtr, buffer.length);
1211
+ } finally {
1212
+ Module._free(bufPtr);
1213
+ Module._free(schemaPtr);
1214
+ }
1215
+ }
1216
+
1217
+ /**
1218
+ * Encrypt a plaintext FlatBuffer under the sequence it gets and ingest it.
1219
+ * @param {Uint8Array} data - FlatBuffer data (no size prefix)
1220
+ * @param {Uint8Array} schema - Binary schema (.bfbs) with builtin attributes (flatc --bfbs-builtins)
1221
+ * @param {string|null} [source] - Source name, as for ingestOne
1222
+ * @returns {number} The record's sequence
1223
+ */
1224
+ ingestOneEncrypted(data, schema, source = null) {
1225
+ const result = withHeapBytes(data, (dataPtr) =>
1226
+ withHeapBytes(schema, (schemaPtr) =>
1227
+ api.ingestOneEncrypted(this._handle, dataPtr, data.length, schemaPtr, schema.length, source)));
1228
+ if (result < 0) throw new Error(api.getError());
1229
+ return result;
1191
1230
  }
1192
1231
 
1193
1232
  // ==================== HMAC Authentication API ====================
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "algorithm": "sha384",
3
- "hash": "CrgBjfUgUmme/mK6Hy8eYtPWLr3p+P1MmCFiSbTmb3Fi+X1pz2V8+LtE5JqRDOGt",
4
- "sri": "sha384-CrgBjfUgUmme/mK6Hy8eYtPWLr3p+P1MmCFiSbTmb3Fi+X1pz2V8+LtE5JqRDOGt",
5
- "size": 2139350,
3
+ "hash": "JWRTdWbV8EJ/0t0YI2Dun2xEqFT/5CBm53E8feeI9+4ULvqj+BpHfWPpW21DAOiM",
4
+ "sri": "sha384-JWRTdWbV8EJ/0t0YI2Dun2xEqFT/5CBm53E8feeI9+4ULvqj+BpHfWPpW21DAOiM",
5
+ "size": 2171442,
6
6
  "files": {
7
7
  "flatsql-ps-threads.wasm": {
8
- "sha256": "075dd0a104694df39b2776c34dc6444be224442717967d9cea5dd9af15964379",
9
- "sri": "sha384-6COvEIcsSPYQ2gaha+/n5bdRTDysR84pfSw92d4F+Sxss3kCxYj2XNkPIfA9zEhC",
10
- "size": 2237656
8
+ "sha256": "e61120642b300997f59ef064d7cc6375bfc937e7cc4d551b47695f6d23ef03e6",
9
+ "sri": "sha384-ob8andGalOK7VXlHEfja2VGzhmiwnXyT6CVZhOqElGEv7mvKUXPn/tUSvba9L1WB",
10
+ "size": 2325490
11
11
  },
12
12
  "flatsql-wasi-noeh.wasm": {
13
- "sha256": "fd744d4c502310669bc74ab555a36de1692030a0fa6e22fdb1df744809eeacbe",
14
- "sri": "sha384-C+YX2MFlWf2gFNXZjjPnjVSWccdowlc3CtoDFFh1sUkOoVDVgbpFrSMvBW256ReW",
15
- "size": 2035757
13
+ "sha256": "7315eb0361513578c7a011db8b1e10a7d41625e8fae59c276b61e2d1529bb591",
14
+ "sri": "sha384-sbtoG+Ne4mkC7j/hfJ3nvx/IOzvB3bjv24x+pkTn8CVuF0ghKtBbZ01ZdIxki7Rj",
15
+ "size": 2062044
16
16
  },
17
17
  "flatsql-wasi.wasm": {
18
- "sha256": "0ca7b261d5026d7d1c45c14623a0c1fed21380c84f03e4feeff3592f37c0f70d",
19
- "sri": "sha384-FxD9itLxJAPNkv8eROaZviiFrNzlmMSbnIDWoOHPEc2KALOiEHH7LN5kZaVesgpH",
20
- "size": 2118848
18
+ "sha256": "989ea9fc7be9539bda7878e5202bee46b4ba45fd59d8718b01a2a8a6c7cb1afd",
19
+ "sri": "sha384-avovLPDagClSRBYZRRA7k6ys490F67ef9i5G/0WMckwDRyTUKo5lYT/3kCUBzZad",
20
+ "size": 2147171
21
21
  },
22
22
  "flatsql.wasm": {
23
- "sha256": "7b422662b0e49daf292968fb6a8730d2c278bce45bf7ed30120a4ff50818e13e",
24
- "sri": "sha384-CrgBjfUgUmme/mK6Hy8eYtPWLr3p+P1MmCFiSbTmb3Fi+X1pz2V8+LtE5JqRDOGt",
25
- "size": 2139350
23
+ "sha256": "45e291c9293fc0c2c27e87cd410c813cd54f97ba6c3459d328122c1c37909d1f",
24
+ "sri": "sha384-JWRTdWbV8EJ/0t0YI2Dun2xEqFT/5CBm53E8feeI9+4ULvqj+BpHfWPpW21DAOiM",
25
+ "size": 2171442
26
26
  }
27
27
  }
28
28
  }