1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 10:08:52 +08:00

Pre-built custom sql.js for sqliteviz (#62)

* Proof-of-concept pre-built custom sql.js

* Rewrite Makefile as a couple of comprehensible Python scripts

* Add link to a blog post about transitive closure in SQLite

* Remove eval extension -- no much point as it only returns a string

* Consistently use existing Path objects

* Add basic tests scalar functions from extension-functions.c

* Test presence of functions from the rest of built extensions

* Use the same sqlite.com domain

* Add a couple SQLite compile flags that may make it a bit faster

* Add regexpi function test

* Add node about regexpi and REGEXP operator

* Workaround first build failure, rebuild lock file and minor fixes
This commit is contained in:
saaj
2021-07-03 16:43:43 +02:00
committed by GitHub
parent 418809d27d
commit 3a6628cab9
12 changed files with 737 additions and 27 deletions

9
lib/sql-js/Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM emscripten/emsdk:2.0.24
WORKDIR /tmp/build
COPY configure.py .
RUN python3.8 configure.py
COPY build.py .
RUN python3.8 build.py

73
lib/sql-js/README.md Normal file
View File

@@ -0,0 +1,73 @@
# SQLite WebAssembly build
This directory contains Docker-based build script, `make.sh`, that builds
a custom version of [sql.js][1]. It allows sqliteviz to have more recent
version of SQLite build with a number of useful extensions.
`Makefile` from [sql.js][1] is rewritten as more comprehensible `configure.py`
and `build.py` Python scripts that run in `emscripten/emsdk` Docker container.
## Extension
SQLite [amalgamation][2] extensions included:
1. [FTS5][4] -- virtual table module that provides full-text search
functionality
SQLite [miscellaneous extensions][3] included:
1. `generate_series` table-valued [series function][6] ([series.c][7])
2. `transitive_closure` virtual table for
[Querying Tree Structures in SQLite][11] ([closure.c][8])
3. `uuid`, `uuid_str` and `uuid_blob` RFC-4122 UUID functions ([uuid.c][9])
4. `regexp` (hence `REGEXP` operator) and `regexpi` functions ([regexp.c][10])
SQLite 3rd party extensions included:
1. [pivot_vtab][5] -- a pivot virtual table
To ease the step to have working clone locally, the build is committed into
the repository.
## Build method
Basically it's extended amalgamation and `SQLITE_EXTRA_INIT` concisely
described in [this message from SQLite Forum][12]:
> Simply append it to the end of the amalgamation file. The real problem is
> how you get the init function called. The easiest way (to me at any rate) is
> to append a function (after the extensions you want to add are all appended)
> that adds the init function for each extension to the auto extension list
> for new connections, and set the pre-processor symbol SQLITE_EXTRA_INIT to
> the name of this function. [...]
>
> An example `SQLITE_EXTRA_INIT` function looks like this:
>
> ```
> int core_init(const char* dummy)
> {
> int nErr = 0;
>
> nErr += sqlite3_auto_extension((void*)sqlite3_autobusy_init);
> nErr += sqlite3_auto_extension((void*)sqlite3_ipaddress_init);
>
> return nErr ? SQLITE_ERROR : SQLITE_OK;
> }
> ```
>
> so you would then define `SQLITE_EXTRA_INIT=core_init` when compiling the
> amalgamation code and the extensions would thereafter be automatically
> initialized on each connection.
[1]: https://github.com/sql-js/sql.js
[2]: https://sqlite.org/amalgamation.html
[3]: https://sqlite.org/src/dir?ci=trunk&name=ext/misc
[4]: https://sqlite.org/fts5.html
[5]: https://github.com/jakethaw/pivot_vtab
[6]: https://sqlite.org/series.html
[7]: https://sqlite.org/src/file/ext/misc/series.c
[8]: https://sqlite.org/src/file/ext/misc/closure.c
[9]: https://sqlite.org/src/file/ext/misc/uuid.c
[10]: https://sqlite.org/src/file/ext/misc/regexp.c
[11]: https://charlesleifer.com/blog/querying-tree-structures-in-sqlite-using-python-and-the-transitive-closure-extension/
[12]: https://sqlite.org/forum/forumpost/6ad7d4f4bebe5e06?raw

83
lib/sql-js/build.py Normal file
View File

@@ -0,0 +1,83 @@
import logging
import subprocess
from pathlib import Path
cflags = (
'-O2',
'-DSQLITE_OMIT_LOAD_EXTENSION',
'-DSQLITE_DISABLE_LFS',
'-DSQLITE_ENABLE_FTS3',
'-DSQLITE_ENABLE_FTS3_PARENTHESIS',
'-DSQLITE_ENABLE_FTS5',
'-DSQLITE_ENABLE_JSON1',
'-DSQLITE_THREADSAFE=0',
'-DSQLITE_ENABLE_NORMALIZE',
'-DSQLITE_EXTRA_INIT=extra_init',
'-DSQLITE_DEFAULT_MEMSTATUS=0',
'-DSQLITE_USE_ALLOCA',
)
emflags = (
# Base
'--memory-init-file', '0',
'-s', 'RESERVED_FUNCTION_POINTERS=64',
'-s', 'ALLOW_TABLE_GROWTH=1',
'-s', 'SINGLE_FILE=0',
# WASM
'-s', 'WASM=1',
'-s', 'ALLOW_MEMORY_GROWTH=1',
# Optimisation
'-s', 'INLINING_LIMIT=50',
'-O3',
'-flto',
'--closure', '1',
# sql.js
'-s', 'EXPORTED_FUNCTIONS=@src/sqljs/exported_functions.json',
'-s', 'EXPORTED_RUNTIME_METHODS=@src/sqljs/exported_runtime_methods.json',
'--pre-js', 'src/sqljs/api.js',
)
def build(src: Path, dst: Path):
out = Path('out')
out.mkdir()
logging.info('Building LLVM bitcode for sqlite3.c')
subprocess.check_call([
'emcc',
*cflags,
'-c', src / 'sqlite3.c',
'-o', out / 'sqlite3.bc',
])
logging.info('Building LLVM bitcode for extension-functions.c')
subprocess.check_call([
'emcc',
*cflags,
'-c', src / 'extension-functions.c',
'-o', out / 'extension-functions.bc',
])
logging.info('Building WASM from bitcode')
subprocess.check_call([
'emcc',
*emflags,
out / 'sqlite3.bc',
out / 'extension-functions.bc',
'-o', out / 'sql-wasm.js',
])
logging.info('Post-processing build and copying to dist')
(out / 'sql-wasm.wasm').rename(dst / 'sql-wasm.wasm')
with (dst / 'sql-wasm.js').open('w') as f:
f.write((src / 'sqljs' / 'shell-pre.js').read_text())
f.write((out / 'sql-wasm.js').read_text())
f.write((src / 'sqljs' / 'shell-post.js').read_text())
if __name__ == '__main__':
logging.basicConfig(level='INFO', format='%(asctime)s %(levelname)s %(name)s %(message)s')
src = Path('src')
dst = Path('dist')
dst.mkdir()
build(src, dst)

105
lib/sql-js/configure.py Normal file
View File

@@ -0,0 +1,105 @@
import logging
import shutil
import subprocess
import sys
import zipfile
from io import BytesIO
from pathlib import Path
from urllib import request
amalgamation_url = 'https://sqlite.org/2021/sqlite-amalgamation-3360000.zip'
# Extension-functions
# ===================
# It breaks amalgamation if appended as other extension because it redefines
# several functions, so build it separately. Note that sql.js registers these
# extension functions by calling ``registerExtensionFunctions`` itself.
contrib_functions_url = 'https://sqlite.org/contrib/download/extension-functions.c?get=25'
extension_urls = (
# Miscellaneous extensions
# ========================
('https://sqlite.org/src/raw/c6bd5d24?at=series.c', 'sqlite3_series_init'),
('https://sqlite.org/src/raw/dbfd8543?at=closure.c', 'sqlite3_closure_init'),
('https://sqlite.org/src/raw/5bb2264c?at=uuid.c', 'sqlite3_uuid_init'),
('https://sqlite.org/src/raw/5853b0e5?at=regexp.c', 'sqlite3_regexp_init'),
# Third-party extension
# =====================
('https://github.com/jakethaw/pivot_vtab/raw/08ab0797/pivot_vtab.c', 'sqlite3_pivotvtab_init'),
)
sqljs_url = 'https://github.com/sql-js/sql.js/archive/refs/tags/v1.5.0.zip'
def _generate_extra_init_c_function(init_function_names):
auto_ext_calls = '\n'.join([
'nErr += sqlite3_auto_extension((void*){});'.format(init_fn)
for init_fn in init_function_names
])
return '''
int extra_init(const char* dummy)
{
int nErr = 0;
%s
return nErr ? SQLITE_ERROR : SQLITE_OK;
}
''' % auto_ext_calls
def _get_amalgamation(tgt: Path):
logging.info('Downloading and extracting SQLite amalgamation %s', amalgamation_url)
archive = zipfile.ZipFile(BytesIO(request.urlopen(amalgamation_url).read()))
archive_root_dir = zipfile.Path(archive, archive.namelist()[0])
for zpath in archive_root_dir.iterdir():
with zpath.open() as fr, (tgt / zpath.name).open('wb') as fw:
shutil.copyfileobj(fr, fw)
def _get_contrib_functions(tgt: Path):
request.urlretrieve(contrib_functions_url, tgt / 'extension-functions.c')
def _get_extensions(tgt: Path):
init_functions = []
sqlite3_c = tgt / 'sqlite3.c'
with sqlite3_c.open('ab') as f:
for url, init_fn in extension_urls:
logging.info('Downloading and appending to amalgamation %s', url)
with request.urlopen(url) as resp:
shutil.copyfileobj(resp, f)
init_functions.append(init_fn)
logging.info('Appending SQLITE_EXTRA_INIT to amalgamation')
f.write(_generate_extra_init_c_function(init_functions).encode())
def _get_sqljs(tgt: Path):
logging.info('Downloading and extracting sql.js %s', sqljs_url)
archive = zipfile.ZipFile(BytesIO(request.urlopen(sqljs_url).read()))
archive_root_dir = zipfile.Path(archive, archive.namelist()[0])
(tgt / 'sqljs').mkdir()
for zpath in (archive_root_dir / 'src').iterdir():
with zpath.open() as fr, (tgt / 'sqljs' / zpath.name).open('wb') as fw:
shutil.copyfileobj(fr, fw)
def configure(tgt: Path):
_get_amalgamation(tgt)
_get_contrib_functions(tgt)
_get_extensions(tgt)
_get_sqljs(tgt)
subprocess.check_call(['emcc', '--version'])
if __name__ == '__main__':
if sys.version_info < (3, 8):
print('Python 3.8 or higher is expected', file=sys.stderr)
sys.exit(1)
logging.basicConfig(level='INFO', format='%(asctime)s %(levelname)s %(name)s %(message)s')
src = Path('src')
src.mkdir()
configure(src)

201
lib/sql-js/dist/sql-wasm.js vendored Normal file
View File

@@ -0,0 +1,201 @@
// We are modularizing this manually because the current modularize setting in Emscripten has some issues:
// https://github.com/kripken/emscripten/issues/5820
// In addition, When you use emcc's modularization, it still expects to export a global object called `Module`,
// which is able to be used/called before the WASM is loaded.
// The modularization below exports a promise that loads and resolves to the actual sql.js module.
// That way, this module can't be used before the WASM is finished loading.
// We are going to define a function that a user will call to start loading initializing our Sql.js library
// However, that function might be called multiple times, and on subsequent calls, we don't actually want it to instantiate a new instance of the Module
// Instead, we want to return the previously loaded module
// TODO: Make this not declare a global if used in the browser
var initSqlJsPromise = undefined;
var initSqlJs = function (moduleConfig) {
if (initSqlJsPromise){
return initSqlJsPromise;
}
// If we're here, we've never called this function before
initSqlJsPromise = new Promise(function (resolveModule, reject) {
// We are modularizing this manually because the current modularize setting in Emscripten has some issues:
// https://github.com/kripken/emscripten/issues/5820
// The way to affect the loading of emcc compiled modules is to create a variable called `Module` and add
// properties to it, like `preRun`, `postRun`, etc
// We are using that to get notified when the WASM has finished loading.
// Only then will we return our promise
// If they passed in a moduleConfig object, use that
// Otherwise, initialize Module to the empty object
var Module = typeof moduleConfig !== 'undefined' ? moduleConfig : {};
// EMCC only allows for a single onAbort function (not an array of functions)
// So if the user defined their own onAbort function, we remember it and call it
var originalOnAbortFunction = Module['onAbort'];
Module['onAbort'] = function (errorThatCausedAbort) {
reject(new Error(errorThatCausedAbort));
if (originalOnAbortFunction){
originalOnAbortFunction(errorThatCausedAbort);
}
};
Module['postRun'] = Module['postRun'] || [];
Module['postRun'].push(function () {
// When Emscripted calls postRun, this promise resolves with the built Module
resolveModule(Module);
});
// There is a section of code in the emcc-generated code below that looks like this:
// (Note that this is lowercase `module`)
// if (typeof module !== 'undefined') {
// module['exports'] = Module;
// }
// When that runs, it's going to overwrite our own modularization export efforts in shell-post.js!
// The only way to tell emcc not to emit it is to pass the MODULARIZE=1 or MODULARIZE_INSTANCE=1 flags,
// but that carries with it additional unnecessary baggage/bugs we don't want either.
// So, we have three options:
// 1) We undefine `module`
// 2) We remember what `module['exports']` was at the beginning of this function and we restore it later
// 3) We write a script to remove those lines of code as part of the Make process.
//
// Since those are the only lines of code that care about module, we will undefine it. It's the most straightforward
// of the options, and has the side effect of reducing emcc's efforts to modify the module if its output were to change in the future.
// That's a nice side effect since we're handling the modularization efforts ourselves
module = undefined;
// The emcc-generated code and shell-post.js code goes below,
// meaning that all of it runs inside of this promise. If anything throws an exception, our promise will abort
var e;e||(e=typeof Module !== 'undefined' ? Module : {});null;
e.onRuntimeInitialized=function(){function a(h,l){this.Ra=h;this.db=l;this.Qa=1;this.lb=[]}function b(h,l){this.db=l;l=ba(h)+1;this.eb=ca(l);if(null===this.eb)throw Error("Unable to allocate memory for the SQL string");k(h,n,this.eb,l);this.jb=this.eb;this.$a=this.pb=null}function c(h){this.filename="dbfile_"+(4294967295*Math.random()>>>0);if(null!=h){var l=this.filename,p=l?r("//"+l):"/";l=da(!0,!0);p=ea(p,(void 0!==l?l:438)&4095|32768,0);if(h){if("string"===typeof h){for(var q=Array(h.length),B=
0,ha=h.length;B<ha;++B)q[B]=h.charCodeAt(B);h=q}fa(p,l|146);q=v(p,577);ka(q,h,0,h.length,0,void 0);la(q);fa(p,l)}}this.handleError(g(this.filename,d));this.db=x(d,"i32");ic(this.db);this.fb={};this.Xa={}}var d=y(4),f=e.cwrap,g=f("sqlite3_open","number",["string","number"]),m=f("sqlite3_close_v2","number",["number"]),t=f("sqlite3_exec","number",["number","string","number","number","number"]),w=f("sqlite3_changes","number",["number"]),u=f("sqlite3_prepare_v2","number",["number","string","number","number",
"number"]),C=f("sqlite3_sql","string",["number"]),H=f("sqlite3_normalized_sql","string",["number"]),aa=f("sqlite3_prepare_v2","number",["number","number","number","number","number"]),jc=f("sqlite3_bind_text","number",["number","number","number","number","number"]),rb=f("sqlite3_bind_blob","number",["number","number","number","number","number"]),kc=f("sqlite3_bind_double","number",["number","number","number"]),lc=f("sqlite3_bind_int","number",["number","number","number"]),mc=f("sqlite3_bind_parameter_index",
"number",["number","string"]),nc=f("sqlite3_step","number",["number"]),oc=f("sqlite3_errmsg","string",["number"]),pc=f("sqlite3_column_count","number",["number"]),qc=f("sqlite3_data_count","number",["number"]),rc=f("sqlite3_column_double","number",["number","number"]),sc=f("sqlite3_column_text","string",["number","number"]),tc=f("sqlite3_column_blob","number",["number","number"]),uc=f("sqlite3_column_bytes","number",["number","number"]),vc=f("sqlite3_column_type","number",["number","number"]),wc=
f("sqlite3_column_name","string",["number","number"]),xc=f("sqlite3_reset","number",["number"]),yc=f("sqlite3_clear_bindings","number",["number"]),zc=f("sqlite3_finalize","number",["number"]),Ac=f("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),Bc=f("sqlite3_value_type","number",["number"]),Cc=f("sqlite3_value_bytes","number",["number"]),Dc=f("sqlite3_value_text","string",["number"]),Ec=f("sqlite3_value_blob","number",["number"]),
Fc=f("sqlite3_value_double","number",["number"]),Gc=f("sqlite3_result_double","",["number","number"]),sb=f("sqlite3_result_null","",["number"]),Hc=f("sqlite3_result_text","",["number","string","number","number"]),Ic=f("sqlite3_result_blob","",["number","number","number","number"]),Jc=f("sqlite3_result_int","",["number","number"]),tb=f("sqlite3_result_error","",["number","string","number"]),ic=f("RegisterExtensionFunctions","number",["number"]);a.prototype.bind=function(h){if(!this.Ra)throw"Statement closed";
this.reset();return Array.isArray(h)?this.Bb(h):null!=h&&"object"===typeof h?this.Cb(h):!0};a.prototype.step=function(){if(!this.Ra)throw"Statement closed";this.Qa=1;var h=nc(this.Ra);switch(h){case 100:return!0;case 101:return!1;default:throw this.db.handleError(h);}};a.prototype.Hb=function(h){null==h&&(h=this.Qa,this.Qa+=1);return rc(this.Ra,h)};a.prototype.Ib=function(h){null==h&&(h=this.Qa,this.Qa+=1);return sc(this.Ra,h)};a.prototype.getBlob=function(h){null==h&&(h=this.Qa,this.Qa+=1);var l=
uc(this.Ra,h);h=tc(this.Ra,h);for(var p=new Uint8Array(l),q=0;q<l;q+=1)p[q]=z[h+q];return p};a.prototype.get=function(h){null!=h&&this.bind(h)&&this.step();h=[];for(var l=qc(this.Ra),p=0;p<l;p+=1)switch(vc(this.Ra,p)){case 1:case 2:h.push(this.Hb(p));break;case 3:h.push(this.Ib(p));break;case 4:h.push(this.getBlob(p));break;default:h.push(null)}return h};a.prototype.getColumnNames=function(){for(var h=[],l=pc(this.Ra),p=0;p<l;p+=1)h.push(wc(this.Ra,p));return h};a.prototype.getAsObject=function(h){h=
this.get(h);for(var l=this.getColumnNames(),p={},q=0;q<l.length;q+=1)p[l[q]]=h[q];return p};a.prototype.getSQL=function(){return C(this.Ra)};a.prototype.getNormalizedSQL=function(){return H(this.Ra)};a.prototype.run=function(h){null!=h&&this.bind(h);this.step();return this.reset()};a.prototype.Fb=function(h,l){null==l&&(l=this.Qa,this.Qa+=1);h=ma(h);var p=na(h);this.lb.push(p);this.db.handleError(jc(this.Ra,l,p,h.length-1,0))};a.prototype.Ab=function(h,l){null==l&&(l=this.Qa,this.Qa+=1);var p=na(h);
this.lb.push(p);this.db.handleError(rb(this.Ra,l,p,h.length,0))};a.prototype.Eb=function(h,l){null==l&&(l=this.Qa,this.Qa+=1);this.db.handleError((h===(h|0)?lc:kc)(this.Ra,l,h))};a.prototype.Db=function(h){null==h&&(h=this.Qa,this.Qa+=1);rb(this.Ra,h,0,0,0)};a.prototype.tb=function(h,l){null==l&&(l=this.Qa,this.Qa+=1);switch(typeof h){case "string":this.Fb(h,l);return;case "number":case "boolean":this.Eb(h+0,l);return;case "object":if(null===h){this.Db(l);return}if(null!=h.length){this.Ab(h,l);return}}throw"Wrong API use : tried to bind a value of an unknown type ("+
h+").";};a.prototype.Cb=function(h){var l=this;Object.keys(h).forEach(function(p){var q=mc(l.Ra,p);0!==q&&l.tb(h[p],q)});return!0};a.prototype.Bb=function(h){for(var l=0;l<h.length;l+=1)this.tb(h[l],l+1);return!0};a.prototype.reset=function(){return 0===yc(this.Ra)&&0===xc(this.Ra)};a.prototype.freemem=function(){for(var h;void 0!==(h=this.lb.pop());)oa(h)};a.prototype.free=function(){var h=0===zc(this.Ra);delete this.db.fb[this.Ra];this.Ra=0;return h};b.prototype.next=function(){if(null===this.eb)return{done:!0};
null!==this.$a&&(this.$a.free(),this.$a=null);if(!this.db.db)throw this.nb(),Error("Database closed");var h=pa(),l=y(4);qa(d);qa(l);try{this.db.handleError(aa(this.db.db,this.jb,-1,d,l));this.jb=x(l,"i32");var p=x(d,"i32");if(0===p)return this.nb(),{done:!0};this.$a=new a(p,this.db);this.db.fb[p]=this.$a;return{value:this.$a,done:!1}}catch(q){throw this.pb=A(this.jb),this.nb(),q;}finally{ra(h)}};b.prototype.nb=function(){oa(this.eb);this.eb=null};b.prototype.getRemainingSQL=function(){return null!==
this.pb?this.pb:A(this.jb)};"function"===typeof Symbol&&"symbol"===typeof Symbol.iterator&&(b.prototype[Symbol.iterator]=function(){return this});c.prototype.run=function(h,l){if(!this.db)throw"Database closed";if(l){h=this.prepare(h,l);try{h.step()}finally{h.free()}}else this.handleError(t(this.db,h,0,0,d));return this};c.prototype.exec=function(h,l){if(!this.db)throw"Database closed";var p=pa(),q=null;try{var B=ba(h)+1,ha=y(B);k(h,z,ha,B);var D=ha;var ia=y(4);for(h=[];0!==x(D,"i8");){qa(d);qa(ia);
this.handleError(aa(this.db,D,-1,d,ia));var ja=x(d,"i32");D=x(ia,"i32");if(0!==ja){B=null;q=new a(ja,this);for(null!=l&&q.bind(l);q.step();)null===B&&(B={columns:q.getColumnNames(),values:[]},h.push(B)),B.values.push(q.get());q.free()}}return h}catch(E){throw q&&q.free(),E;}finally{ra(p)}};c.prototype.each=function(h,l,p,q){"function"===typeof l&&(q=p,p=l,l=void 0);h=this.prepare(h,l);try{for(;h.step();)p(h.getAsObject())}finally{h.free()}if("function"===typeof q)return q()};c.prototype.prepare=function(h,
l){qa(d);this.handleError(u(this.db,h,-1,d,0));h=x(d,"i32");if(0===h)throw"Nothing to prepare";var p=new a(h,this);null!=l&&p.bind(l);return this.fb[h]=p};c.prototype.iterateStatements=function(h){return new b(h,this)};c.prototype["export"]=function(){Object.values(this.fb).forEach(function(l){l.free()});Object.values(this.Xa).forEach(sa);this.Xa={};this.handleError(m(this.db));var h=ta(this.filename);this.handleError(g(this.filename,d));this.db=x(d,"i32");return h};c.prototype.close=function(){null!==
this.db&&(Object.values(this.fb).forEach(function(h){h.free()}),Object.values(this.Xa).forEach(sa),this.Xa={},this.handleError(m(this.db)),ua("/"+this.filename),this.db=null)};c.prototype.handleError=function(h){if(0===h)return null;h=oc(this.db);throw Error(h);};c.prototype.getRowsModified=function(){return w(this.db)};c.prototype.create_function=function(h,l){Object.prototype.hasOwnProperty.call(this.Xa,h)&&(sa(this.Xa[h]),delete this.Xa[h]);var p=va(function(q,B,ha){for(var D,ia=[],ja=0;ja<B;ja+=
1){var E=x(ha+4*ja,"i32"),T=Bc(E);if(1===T||2===T)E=Fc(E);else if(3===T)E=Dc(E);else if(4===T){T=E;E=Cc(T);T=Ec(T);for(var wb=new Uint8Array(E),Ba=0;Ba<E;Ba+=1)wb[Ba]=z[T+Ba];E=wb}else E=null;ia.push(E)}try{D=l.apply(null,ia)}catch(Mc){tb(q,Mc,-1);return}switch(typeof D){case "boolean":Jc(q,D?1:0);break;case "number":Gc(q,D);break;case "string":Hc(q,D,-1,-1);break;case "object":null===D?sb(q):null!=D.length?(B=na(D),Ic(q,B,D.length,-1),oa(B)):tb(q,"Wrong API use : tried to return a value of an unknown type ("+
D+").",-1);break;default:sb(q)}});this.Xa[h]=p;this.handleError(Ac(this.db,h,l.length,1,0,p,0,0,0));return this};e.Database=c};var wa={},F;for(F in e)e.hasOwnProperty(F)&&(wa[F]=e[F]);var xa="./this.program",ya=!1,za=!1,Aa=!1,Ca=!1;ya="object"===typeof window;za="function"===typeof importScripts;Aa="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;Ca=!ya&&!Aa&&!za;var G="",Da,Ea,Fa,Ga,Ha;
if(Aa)G=za?require("path").dirname(G)+"/":__dirname+"/",Da=function(a,b){Ga||(Ga=require("fs"));Ha||(Ha=require("path"));a=Ha.normalize(a);return Ga.readFileSync(a,b?null:"utf8")},Fa=function(a){a=Da(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},1<process.argv.length&&(xa=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),"undefined"!==typeof module&&(module.exports=e),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",I),e.inspect=function(){return"[Emscripten Module object]"};
else if(Ca)"undefined"!=typeof read&&(Da=function(a){return read(a)}),Fa=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");assert("object"===typeof a);return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(ya||za)za?G=self.location.href:"undefined"!==typeof document&&document.currentScript&&(G=document.currentScript.src),
G=0!==G.indexOf("blob:")?G.substr(0,G.lastIndexOf("/")+1):"",Da=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},za&&(Fa=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}),Ea=function(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=function(){200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)};
var Ia=e.print||console.log.bind(console),J=e.printErr||console.warn.bind(console);for(F in wa)wa.hasOwnProperty(F)&&(e[F]=wa[F]);wa=null;e.thisProgram&&(xa=e.thisProgram);var Ja=[],Ka;function sa(a){Ka.delete(K.get(a));Ja.push(a)}
function va(a){if(!Ka){Ka=new WeakMap;for(var b=0;b<K.length;b++){var c=K.get(b);c&&Ka.set(c,b)}}if(Ka.has(a))a=Ka.get(a);else{if(Ja.length)b=Ja.pop();else{try{K.grow(1)}catch(g){if(!(g instanceof RangeError))throw g;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";}b=K.length-1}try{K.set(b,a)}catch(g){if(!(g instanceof TypeError))throw g;if("function"===typeof WebAssembly.Function){var d={i:"i32",j:"i64",f:"f32",d:"f64"},f={parameters:[],results:[]};for(c=1;4>c;++c)f.parameters.push(d["viii"[c]]);
c=new WebAssembly.Function(f,a)}else{d=[1,0,1,96];f={i:127,j:126,f:125,d:124};d.push(3);for(c=0;3>c;++c)d.push(f["iii"[c]]);d.push(0);d[1]=d.length-2;c=new Uint8Array([0,97,115,109,1,0,0,0].concat(d,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0]));c=new WebAssembly.Module(c);c=(new WebAssembly.Instance(c,{e:{f:a}})).exports.f}K.set(b,c)}Ka.set(a,b);a=b}return a}var La;e.wasmBinary&&(La=e.wasmBinary);var noExitRuntime=e.noExitRuntime||!0;"object"!==typeof WebAssembly&&I("no native wasm support detected");
function qa(a){var b="i32";"*"===b.charAt(b.length-1)&&(b="i32");switch(b){case "i1":z[a>>0]=0;break;case "i8":z[a>>0]=0;break;case "i16":Ma[a>>1]=0;break;case "i32":L[a>>2]=0;break;case "i64":M=[0,(N=0,1<=+Math.abs(N)?0<N?(Math.min(+Math.floor(N/4294967296),4294967295)|0)>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)];L[a>>2]=M[0];L[a+4>>2]=M[1];break;case "float":Na[a>>2]=0;break;case "double":Oa[a>>3]=0;break;default:I("invalid type for setValue: "+b)}}
function x(a,b){b=b||"i8";"*"===b.charAt(b.length-1)&&(b="i32");switch(b){case "i1":return z[a>>0];case "i8":return z[a>>0];case "i16":return Ma[a>>1];case "i32":return L[a>>2];case "i64":return L[a>>2];case "float":return Na[a>>2];case "double":return Oa[a>>3];default:I("invalid type for getValue: "+b)}return null}var Pa,Qa=!1;function assert(a,b){a||I("Assertion failed: "+b)}function Ra(a){var b=e["_"+a];assert(b,"Cannot call unknown function "+a+", make sure it is exported");return b}
function Sa(a,b,c,d){var f={string:function(u){var C=0;if(null!==u&&void 0!==u&&0!==u){var H=(u.length<<2)+1;C=y(H);k(u,n,C,H)}return C},array:function(u){var C=y(u.length);z.set(u,C);return C}},g=Ra(a),m=[];a=0;if(d)for(var t=0;t<d.length;t++){var w=f[c[t]];w?(0===a&&(a=pa()),m[t]=w(d[t])):m[t]=d[t]}c=g.apply(null,m);c=function(u){return"string"===b?A(u):"boolean"===b?!!u:u}(c);0!==a&&ra(a);return c}var Ta=0,Ua=1;
function na(a){var b=Ta==Ua?y(a.length):ca(a.length);a.subarray||a.slice?n.set(a,b):n.set(new Uint8Array(a),b);return b}var Va="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function Wa(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&Va)return Va.decode(a.subarray(b,c));for(d="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))d+=String.fromCharCode((f&31)<<6|g);else{var m=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|m:(f&7)<<18|g<<12|m<<6|a[b++]&63;65536>f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d}function A(a,b){return a?Wa(n,a,b):""}
function k(a,b,c,d){if(!(0<d))return 0;var f=c;d=c+d-1;for(var g=0;g<a.length;++g){var m=a.charCodeAt(g);if(55296<=m&&57343>=m){var t=a.charCodeAt(++g);m=65536+((m&1023)<<10)|t&1023}if(127>=m){if(c>=d)break;b[c++]=m}else{if(2047>=m){if(c+1>=d)break;b[c++]=192|m>>6}else{if(65535>=m){if(c+2>=d)break;b[c++]=224|m>>12}else{if(c+3>=d)break;b[c++]=240|m>>18;b[c++]=128|m>>12&63}b[c++]=128|m>>6&63}b[c++]=128|m&63}}b[c]=0;return c-f}
function ba(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:b+4}return b}function Xa(a){var b=ba(a)+1,c=ca(b);c&&k(a,z,c,b);return c}var Ya,z,n,Ma,L,Na,Oa;
function Za(){var a=Pa.buffer;Ya=a;e.HEAP8=z=new Int8Array(a);e.HEAP16=Ma=new Int16Array(a);e.HEAP32=L=new Int32Array(a);e.HEAPU8=n=new Uint8Array(a);e.HEAPU16=new Uint16Array(a);e.HEAPU32=new Uint32Array(a);e.HEAPF32=Na=new Float32Array(a);e.HEAPF64=Oa=new Float64Array(a)}var K,$a=[],ab=[],bb=[];function cb(){var a=e.preRun.shift();$a.unshift(a)}var db=0,eb=null,fb=null;e.preloadedImages={};e.preloadedAudios={};
function I(a){if(e.onAbort)e.onAbort(a);J(a);Qa=!0;throw new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");}function gb(){return O.startsWith("data:application/octet-stream;base64,")}var O;O="sql-wasm.wasm";if(!gb()){var hb=O;O=e.locateFile?e.locateFile(hb,G):G+hb}function ib(){var a=O;try{if(a==O&&La)return new Uint8Array(La);if(Fa)return Fa(a);throw"both async and sync fetching of the wasm failed";}catch(b){I(b)}}
function jb(){if(!La&&(ya||za)){if("function"===typeof fetch&&!O.startsWith("file://"))return fetch(O,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+O+"'";return a.arrayBuffer()}).catch(function(){return ib()});if(Ea)return new Promise(function(a,b){Ea(O,function(c){a(new Uint8Array(c))},b)})}return Promise.resolve().then(function(){return ib()})}var N,M;
function kb(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(e);else{var c=b.Rb;"number"===typeof c?void 0===b.mb?K.get(c)():K.get(c)(b.mb):c(void 0===b.mb?null:b.mb)}}}function lb(a){return a.replace(/\b_Z[\w\d_]+/g,function(b){return b===b?b:b+" ["+b+"]"})}
function mb(){function a(m){return(m=m.toTimeString().match(/\(([A-Za-z ]+)\)$/))?m[1]:"GMT"}if(!nb){nb=!0;var b=(new Date).getFullYear(),c=new Date(b,0,1),d=new Date(b,6,1);b=c.getTimezoneOffset();var f=d.getTimezoneOffset(),g=Math.max(b,f);L[ob()>>2]=60*g;L[pb()>>2]=Number(b!=f);c=a(c);d=a(d);c=Xa(c);d=Xa(d);f<b?(L[qb()>>2]=c,L[qb()+4>>2]=d):(L[qb()>>2]=d,L[qb()+4>>2]=c)}}var nb;
function ub(a,b){for(var c=0,d=a.length-1;0<=d;d--){var f=a[d];"."===f?a.splice(d,1):".."===f?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a}function r(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=ub(a.split("/").filter(function(d){return!!d}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
function vb(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function xb(a){if("/"===a)return"/";a=r(a);a=a.replace(/\/$/,"");var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}
function yb(){if("object"===typeof crypto&&"function"===typeof crypto.getRandomValues){var a=new Uint8Array(1);return function(){crypto.getRandomValues(a);return a[0]}}if(Aa)try{var b=require("crypto");return function(){return b.randomBytes(1)[0]}}catch(c){}return function(){I("randomDevice")}}
function zb(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=ub(a.split("/").filter(function(d){return!!d}),!b).join("/");return(b?"/":"")+a||"."}var Ab=[];function Bb(a,b){Ab[a]={input:[],output:[],cb:b};Cb(a,Db)}
var Db={open:function(a){var b=Ab[a.node.rdev];if(!b)throw new P(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.cb.flush(a.tty)},flush:function(a){a.tty.cb.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.cb.xb)throw new P(60);for(var f=0,g=0;g<d;g++){try{var m=a.tty.cb.xb(a.tty)}catch(t){throw new P(29);}if(void 0===m&&0===f)throw new P(6);if(null===m||void 0===m)break;f++;b[c+g]=m}f&&(a.node.timestamp=Date.now());return f},write:function(a,b,c,d){if(!a.tty||!a.tty.cb.qb)throw new P(60);
try{for(var f=0;f<d;f++)a.tty.cb.qb(a.tty,b[c+f])}catch(g){throw new P(29);}d&&(a.node.timestamp=Date.now());return f}},Eb={xb:function(a){if(!a.input.length){var b=null;if(Aa){var c=Buffer.zb?Buffer.zb(256):new Buffer(256),d=0;try{d=Ga.readSync(process.stdin.fd,c,0,256,null)}catch(f){if(f.toString().includes("EOF"))d=0;else throw f;}0<d?b=c.slice(0,d).toString("utf-8"):b=null}else"undefined"!=typeof window&&"function"==typeof window.prompt?(b=window.prompt("Input: "),null!==b&&(b+="\n")):"function"==
typeof readline&&(b=readline(),null!==b&&(b+="\n"));if(!b)return null;a.input=ma(b,!0)}return a.input.shift()},qb:function(a,b){null===b||10===b?(Ia(Wa(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(Ia(Wa(a.output,0)),a.output=[])}},Fb={qb:function(a,b){null===b||10===b?(J(Wa(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(J(Wa(a.output,0)),a.output=[])}},Q={Va:null,Wa:function(){return Q.createNode(null,
"/",16895,0)},createNode:function(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new P(63);Q.Va||(Q.Va={dir:{node:{Ua:Q.Ma.Ua,Ta:Q.Ma.Ta,lookup:Q.Ma.lookup,gb:Q.Ma.gb,rename:Q.Ma.rename,unlink:Q.Ma.unlink,rmdir:Q.Ma.rmdir,readdir:Q.Ma.readdir,symlink:Q.Ma.symlink},stream:{Za:Q.Na.Za}},file:{node:{Ua:Q.Ma.Ua,Ta:Q.Ma.Ta},stream:{Za:Q.Na.Za,read:Q.Na.read,write:Q.Na.write,sb:Q.Na.sb,hb:Q.Na.hb,ib:Q.Na.ib}},link:{node:{Ua:Q.Ma.Ua,Ta:Q.Ma.Ta,readlink:Q.Ma.readlink},stream:{}},ub:{node:{Ua:Q.Ma.Ua,
Ta:Q.Ma.Ta},stream:Gb}});c=Hb(a,b,c,d);R(c.mode)?(c.Ma=Q.Va.dir.node,c.Na=Q.Va.dir.stream,c.Oa={}):32768===(c.mode&61440)?(c.Ma=Q.Va.file.node,c.Na=Q.Va.file.stream,c.Sa=0,c.Oa=null):40960===(c.mode&61440)?(c.Ma=Q.Va.link.node,c.Na=Q.Va.link.stream):8192===(c.mode&61440)&&(c.Ma=Q.Va.ub.node,c.Na=Q.Va.ub.stream);c.timestamp=Date.now();a&&(a.Oa[b]=c,a.timestamp=c.timestamp);return c},Sb:function(a){return a.Oa?a.Oa.subarray?a.Oa.subarray(0,a.Sa):new Uint8Array(a.Oa):new Uint8Array(0)},vb:function(a,
b){var c=a.Oa?a.Oa.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Oa,a.Oa=new Uint8Array(b),0<a.Sa&&a.Oa.set(c.subarray(0,a.Sa),0))},Ob:function(a,b){if(a.Sa!=b)if(0==b)a.Oa=null,a.Sa=0;else{var c=a.Oa;a.Oa=new Uint8Array(b);c&&a.Oa.set(c.subarray(0,Math.min(b,a.Sa)));a.Sa=b}},Ma:{Ua:function(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;R(a.mode)?b.size=4096:32768===(a.mode&61440)?b.size=a.Sa:
40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.Gb=4096;b.blocks=Math.ceil(b.size/b.Gb);return b},Ta:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=b.timestamp);void 0!==b.size&&Q.Ob(a,b.size)},lookup:function(){throw Ib[44];},gb:function(a,b,c,d){return Q.createNode(a,b,c,d)},rename:function(a,b,c){if(R(a.mode)){try{var d=Jb(b,c)}catch(g){}if(d)for(var f in d.Oa)throw new P(55);
}delete a.parent.Oa[a.name];a.parent.timestamp=Date.now();a.name=c;b.Oa[c]=a;b.timestamp=a.parent.timestamp;a.parent=b},unlink:function(a,b){delete a.Oa[b];a.timestamp=Date.now()},rmdir:function(a,b){var c=Jb(a,b),d;for(d in c.Oa)throw new P(55);delete a.Oa[b];a.timestamp=Date.now()},readdir:function(a){var b=[".",".."],c;for(c in a.Oa)a.Oa.hasOwnProperty(c)&&b.push(c);return b},symlink:function(a,b,c){a=Q.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new P(28);
return a.link}},Na:{read:function(a,b,c,d,f){var g=a.node.Oa;if(f>=a.node.Sa)return 0;a=Math.min(a.node.Sa-f,d);if(8<a&&g.subarray)b.set(g.subarray(f,f+a),c);else for(d=0;d<a;d++)b[c+d]=g[f+d];return a},write:function(a,b,c,d,f,g){b.buffer===z.buffer&&(g=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Oa||a.Oa.subarray)){if(g)return a.Oa=b.subarray(c,c+d),a.Sa=d;if(0===a.Sa&&0===f)return a.Oa=b.slice(c,c+d),a.Sa=d;if(f+d<=a.Sa)return a.Oa.set(b.subarray(c,c+d),f),d}Q.vb(a,f+
d);if(a.Oa.subarray&&b.subarray)a.Oa.set(b.subarray(c,c+d),f);else for(g=0;g<d;g++)a.Oa[f+g]=b[c+g];a.Sa=Math.max(a.Sa,f+d);return d},Za:function(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.Sa);if(0>b)throw new P(28);return b},sb:function(a,b,c){Q.vb(a.node,b+c);a.node.Sa=Math.max(a.node.Sa,b+c)},hb:function(a,b,c,d,f,g){if(0!==b)throw new P(28);if(32768!==(a.node.mode&61440))throw new P(43);a=a.node.Oa;if(g&2||a.buffer!==Ya){if(0<d||d+c<a.length)a.subarray?a=a.subarray(d,
d+c):a=Array.prototype.slice.call(a,d,d+c);d=!0;g=65536*Math.ceil(c/65536);for(b=ca(g);c<g;)z[b+c++]=0;c=b;if(!c)throw new P(48);z.set(a,c)}else d=!1,c=a.byteOffset;return{Nb:c,kb:d}},ib:function(a,b,c,d,f){if(32768!==(a.node.mode&61440))throw new P(43);if(f&2)return 0;Q.Na.write(a,b,0,d,c,!1);return 0}}},Kb=null,Lb={},S=[],Mb=1,U=null,Nb=!0,V={},P=null,Ib={};
function W(a,b){a=zb("/",a);b=b||{};if(!a)return{path:"",node:null};var c={wb:!0,rb:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.rb)throw new P(32);a=ub(a.split("/").filter(function(m){return!!m}),!1);var f=Kb;c="/";for(d=0;d<a.length;d++){var g=d===a.length-1;if(g&&b.parent)break;f=Jb(f,a[d]);c=r(c+"/"+a[d]);f.ab&&(!g||g&&b.wb)&&(f=f.ab.root);if(!g||b.Ya)for(g=0;40960===(f.mode&61440);)if(f=Ob(c),c=zb(vb(c),f),f=W(c,{rb:b.rb}).node,40<g++)throw new P(32);}return{path:c,node:f}}
function Pb(a){for(var b;;){if(a===a.parent)return a=a.Wa.yb,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}}function Qb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%U.length}function Rb(a){var b=Qb(a.parent.id,a.name);if(U[b]===a)U[b]=a.bb;else for(b=U[b];b;){if(b.bb===a){b.bb=a.bb;break}b=b.bb}}
function Jb(a,b){var c;if(c=(c=Sb(a,"x"))?c:a.Ma.lookup?0:2)throw new P(c,a);for(c=U[Qb(a.id,b)];c;c=c.bb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.Ma.lookup(a,b)}function Hb(a,b,c,d){a=new Tb(a,b,c,d);b=Qb(a.parent.id,a.name);a.bb=U[b];return U[b]=a}function R(a){return 16384===(a&61440)}var Ub={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090};function Vb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}
function Sb(a,b){if(Nb)return 0;if(!b.includes("r")||a.mode&292){if(b.includes("w")&&!(a.mode&146)||b.includes("x")&&!(a.mode&73))return 2}else return 2;return 0}function Wb(a,b){try{return Jb(a,b),20}catch(c){}return Sb(a,"wx")}function Xb(a,b,c){try{var d=Jb(a,b)}catch(f){return f.Pa}if(a=Sb(a,"wx"))return a;if(c){if(!R(d.mode))return 54;if(d===d.parent||"/"===Pb(d))return 10}else if(R(d.mode))return 31;return 0}function Yb(a){var b=4096;for(a=a||0;a<=b;a++)if(!S[a])return a;throw new P(33);}
function Zb(a,b){$b||($b=function(){},$b.prototype={});var c=new $b,d;for(d in a)c[d]=a[d];a=c;b=Yb(b);a.fd=b;return S[b]=a}var Gb={open:function(a){a.Na=Lb[a.node.rdev].Na;a.Na.open&&a.Na.open(a)},Za:function(){throw new P(70);}};function Cb(a,b){Lb[a]={Na:b}}
function ac(a,b){var c="/"===b,d=!b;if(c&&Kb)throw new P(10);if(!c&&!d){var f=W(b,{wb:!1});b=f.path;f=f.node;if(f.ab)throw new P(10);if(!R(f.mode))throw new P(54);}b={type:a,Tb:{},yb:b,Lb:[]};a=a.Wa(b);a.Wa=b;b.root=a;c?Kb=a:f&&(f.ab=b,f.Wa&&f.Wa.Lb.push(b))}function ea(a,b,c){var d=W(a,{parent:!0}).node;a=xb(a);if(!a||"."===a||".."===a)throw new P(28);var f=Wb(d,a);if(f)throw new P(f);if(!d.Ma.gb)throw new P(63);return d.Ma.gb(d,a,b,c)}
function X(a,b){return ea(a,(void 0!==b?b:511)&1023|16384,0)}function bc(a,b,c){"undefined"===typeof c&&(c=b,b=438);ea(a,b|8192,c)}function cc(a,b){if(!zb(a))throw new P(44);var c=W(b,{parent:!0}).node;if(!c)throw new P(44);b=xb(b);var d=Wb(c,b);if(d)throw new P(d);if(!c.Ma.symlink)throw new P(63);c.Ma.symlink(c,b,a)}
function ua(a){var b=W(a,{parent:!0}).node,c=xb(a),d=Jb(b,c),f=Xb(b,c,!1);if(f)throw new P(f);if(!b.Ma.unlink)throw new P(63);if(d.ab)throw new P(10);try{V.willDeletePath&&V.willDeletePath(a)}catch(g){J("FS.trackingDelegate['willDeletePath']('"+a+"') threw an exception: "+g.message)}b.Ma.unlink(b,c);Rb(d);try{if(V.onDeletePath)V.onDeletePath(a)}catch(g){J("FS.trackingDelegate['onDeletePath']('"+a+"') threw an exception: "+g.message)}}
function Ob(a){a=W(a).node;if(!a)throw new P(44);if(!a.Ma.readlink)throw new P(28);return zb(Pb(a.parent),a.Ma.readlink(a))}function dc(a,b){a=W(a,{Ya:!b}).node;if(!a)throw new P(44);if(!a.Ma.Ua)throw new P(63);return a.Ma.Ua(a)}function ec(a){return dc(a,!0)}function fa(a,b){a="string"===typeof a?W(a,{Ya:!0}).node:a;if(!a.Ma.Ta)throw new P(63);a.Ma.Ta(a,{mode:b&4095|a.mode&-4096,timestamp:Date.now()})}
function fc(a){a="string"===typeof a?W(a,{Ya:!0}).node:a;if(!a.Ma.Ta)throw new P(63);a.Ma.Ta(a,{timestamp:Date.now()})}function hc(a,b){if(0>b)throw new P(28);a="string"===typeof a?W(a,{Ya:!0}).node:a;if(!a.Ma.Ta)throw new P(63);if(R(a.mode))throw new P(31);if(32768!==(a.mode&61440))throw new P(28);var c=Sb(a,"w");if(c)throw new P(c);a.Ma.Ta(a,{size:b,timestamp:Date.now()})}
function v(a,b,c,d){if(""===a)throw new P(44);if("string"===typeof b){var f=Ub[b];if("undefined"===typeof f)throw Error("Unknown file open mode: "+b);b=f}c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;if("object"===typeof a)var g=a;else{a=r(a);try{g=W(a,{Ya:!(b&131072)}).node}catch(m){}}f=!1;if(b&64)if(g){if(b&128)throw new P(20);}else g=ea(a,c,0),f=!0;if(!g)throw new P(44);8192===(g.mode&61440)&&(b&=-513);if(b&65536&&!R(g.mode))throw new P(54);if(!f&&(c=g?40960===(g.mode&61440)?32:R(g.mode)&&
("r"!==Vb(b)||b&512)?31:Sb(g,Vb(b)):44))throw new P(c);b&512&&hc(g,0);b&=-131713;d=Zb({node:g,path:Pb(g),flags:b,seekable:!0,position:0,Na:g.Na,Qb:[],error:!1},d);d.Na.open&&d.Na.open(d);!e.logReadFiles||b&1||(Kc||(Kc={}),a in Kc||(Kc[a]=1,J("FS.trackingDelegate error on read file: "+a)));try{V.onOpenFile&&(g=0,1!==(b&2097155)&&(g|=1),0!==(b&2097155)&&(g|=2),V.onOpenFile(a,g))}catch(m){J("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+m.message)}return d}
function la(a){if(null===a.fd)throw new P(8);a.ob&&(a.ob=null);try{a.Na.close&&a.Na.close(a)}catch(b){throw b;}finally{S[a.fd]=null}a.fd=null}function Lc(a,b,c){if(null===a.fd)throw new P(8);if(!a.seekable||!a.Na.Za)throw new P(70);if(0!=c&&1!=c&&2!=c)throw new P(28);a.position=a.Na.Za(a,b,c);a.Qb=[]}
function Nc(a,b,c,d,f){if(0>d||0>f)throw new P(28);if(null===a.fd)throw new P(8);if(1===(a.flags&2097155))throw new P(8);if(R(a.node.mode))throw new P(31);if(!a.Na.read)throw new P(28);var g="undefined"!==typeof f;if(!g)f=a.position;else if(!a.seekable)throw new P(70);b=a.Na.read(a,b,c,d,f);g||(a.position+=b);return b}
function ka(a,b,c,d,f,g){if(0>d||0>f)throw new P(28);if(null===a.fd)throw new P(8);if(0===(a.flags&2097155))throw new P(8);if(R(a.node.mode))throw new P(31);if(!a.Na.write)throw new P(28);a.seekable&&a.flags&1024&&Lc(a,0,2);var m="undefined"!==typeof f;if(!m)f=a.position;else if(!a.seekable)throw new P(70);b=a.Na.write(a,b,c,d,f,g);m||(a.position+=b);try{if(a.path&&V.onWriteToFile)V.onWriteToFile(a.path)}catch(t){J("FS.trackingDelegate['onWriteToFile']('"+a.path+"') threw an exception: "+t.message)}return b}
function ta(a){var b={encoding:"binary"};b=b||{};b.flags=b.flags||0;b.encoding=b.encoding||"binary";if("utf8"!==b.encoding&&"binary"!==b.encoding)throw Error('Invalid encoding type "'+b.encoding+'"');var c,d=v(a,b.flags);a=dc(a).size;var f=new Uint8Array(a);Nc(d,f,0,a,0);"utf8"===b.encoding?c=Wa(f,0):"binary"===b.encoding&&(c=f);la(d);return c}
function Oc(){P||(P=function(a,b){this.node=b;this.Pb=function(c){this.Pa=c};this.Pb(a);this.message="FS error"},P.prototype=Error(),P.prototype.constructor=P,[44].forEach(function(a){Ib[a]=new P(a);Ib[a].stack="<generic error, no stack>"}))}var Pc;function da(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}
function Qc(a,b,c){a=r("/dev/"+a);var d=da(!!b,!!c);Rc||(Rc=64);var f=Rc++<<8|0;Cb(f,{open:function(g){g.seekable=!1},close:function(){c&&c.buffer&&c.buffer.length&&c(10)},read:function(g,m,t,w){for(var u=0,C=0;C<w;C++){try{var H=b()}catch(aa){throw new P(29);}if(void 0===H&&0===u)throw new P(6);if(null===H||void 0===H)break;u++;m[t+C]=H}u&&(g.node.timestamp=Date.now());return u},write:function(g,m,t,w){for(var u=0;u<w;u++)try{c(m[t+u])}catch(C){throw new P(29);}w&&(g.node.timestamp=Date.now());return u}});
bc(a,d,f)}var Rc,Y={},$b,Kc,Sc={};
function Tc(a,b,c){try{var d=a(b)}catch(f){if(f&&f.node&&r(b)!==r(Pb(f.node)))return-54;throw f;}L[c>>2]=d.dev;L[c+4>>2]=0;L[c+8>>2]=d.ino;L[c+12>>2]=d.mode;L[c+16>>2]=d.nlink;L[c+20>>2]=d.uid;L[c+24>>2]=d.gid;L[c+28>>2]=d.rdev;L[c+32>>2]=0;M=[d.size>>>0,(N=d.size,1<=+Math.abs(N)?0<N?(Math.min(+Math.floor(N/4294967296),4294967295)|0)>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)];L[c+40>>2]=M[0];L[c+44>>2]=M[1];L[c+48>>2]=4096;L[c+52>>2]=d.blocks;L[c+56>>2]=d.atime.getTime()/1E3|0;L[c+60>>2]=
0;L[c+64>>2]=d.mtime.getTime()/1E3|0;L[c+68>>2]=0;L[c+72>>2]=d.ctime.getTime()/1E3|0;L[c+76>>2]=0;M=[d.ino>>>0,(N=d.ino,1<=+Math.abs(N)?0<N?(Math.min(+Math.floor(N/4294967296),4294967295)|0)>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)];L[c+80>>2]=M[0];L[c+84>>2]=M[1];return 0}var Uc=void 0;function Vc(){Uc+=4;return L[Uc-4>>2]}function Z(a){a=S[a];if(!a)throw new P(8);return a}var Wc;
Aa?Wc=function(){var a=process.hrtime();return 1E3*a[0]+a[1]/1E6}:"undefined"!==typeof dateNow?Wc=dateNow:Wc=function(){return performance.now()};var Xc={};function Yc(){if(!Zc){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"===typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:xa||"./this.program"},b;for(b in Xc)void 0===Xc[b]?delete a[b]:a[b]=Xc[b];var c=[];for(b in a)c.push(b+"="+a[b]);Zc=c}return Zc}var Zc;
function Tb(a,b,c,d){a||(a=this);this.parent=a;this.Wa=a.Wa;this.ab=null;this.id=Mb++;this.name=b;this.mode=c;this.Ma={};this.Na={};this.rdev=d}Object.defineProperties(Tb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Oc();U=Array(4096);ac(Q,"/");X("/tmp");X("/home");X("/home/web_user");
(function(){X("/dev");Cb(259,{read:function(){return 0},write:function(b,c,d,f){return f}});bc("/dev/null",259);Bb(1280,Eb);Bb(1536,Fb);bc("/dev/tty",1280);bc("/dev/tty1",1536);var a=yb();Qc("random",a);Qc("urandom",a);X("/dev/shm");X("/dev/shm/tmp")})();
(function(){X("/proc");var a=X("/proc/self");X("/proc/self/fd");ac({Wa:function(){var b=Hb(a,"fd",16895,73);b.Ma={lookup:function(c,d){var f=S[+d];if(!f)throw new P(8);c={parent:null,Wa:{yb:"fake"},Ma:{readlink:function(){return f.path}}};return c.parent=c}};return b}},"/proc/self/fd")})();function ma(a,b){var c=Array(ba(a)+1);a=k(a,c,0,c.length);b&&(c.length=a);return c}
var cd={a:function(a,b,c,d){I("Assertion failed: "+A(a)+", at: "+[b?A(b):"unknown filename",c,d?A(d):"unknown function"])},s:function(a,b){mb();a=new Date(1E3*L[a>>2]);L[b>>2]=a.getSeconds();L[b+4>>2]=a.getMinutes();L[b+8>>2]=a.getHours();L[b+12>>2]=a.getDate();L[b+16>>2]=a.getMonth();L[b+20>>2]=a.getFullYear()-1900;L[b+24>>2]=a.getDay();var c=new Date(a.getFullYear(),0,1);L[b+28>>2]=(a.getTime()-c.getTime())/864E5|0;L[b+36>>2]=-(60*a.getTimezoneOffset());var d=(new Date(a.getFullYear(),6,1)).getTimezoneOffset();
c=c.getTimezoneOffset();a=(d!=c&&a.getTimezoneOffset()==Math.min(c,d))|0;L[b+32>>2]=a;a=L[qb()+(a?4:0)>>2];L[b+40>>2]=a;return b},F:function(a,b){try{a=A(a);if(b&-8)var c=-28;else{var d;(d=W(a,{Ya:!0}).node)?(a="",b&4&&(a+="r"),b&2&&(a+="w"),b&1&&(a+="x"),c=a&&Sb(d,a)?-2:0):c=-44}return c}catch(f){return"undefined"!==typeof Y&&f instanceof P||I(f),-f.Pa}},h:function(a,b){try{return a=A(a),fa(a,b),0}catch(c){return"undefined"!==typeof Y&&c instanceof P||I(c),-c.Pa}},y:function(a){try{return a=A(a),
fc(a),0}catch(b){return"undefined"!==typeof Y&&b instanceof P||I(b),-b.Pa}},i:function(a,b){try{var c=S[a];if(!c)throw new P(8);fa(c.node,b);return 0}catch(d){return"undefined"!==typeof Y&&d instanceof P||I(d),-d.Pa}},z:function(a){try{var b=S[a];if(!b)throw new P(8);fc(b.node);return 0}catch(c){return"undefined"!==typeof Y&&c instanceof P||I(c),-c.Pa}},b:function(a,b,c){Uc=c;try{var d=Z(a);switch(b){case 0:var f=Vc();return 0>f?-28:v(d.path,d.flags,0,f).fd;case 1:case 2:return 0;case 3:return d.flags;
case 4:return f=Vc(),d.flags|=f,0;case 12:return f=Vc(),Ma[f+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-28;case 9:return L[$c()>>2]=28,-1;default:return-28}}catch(g){return"undefined"!==typeof Y&&g instanceof P||I(g),-g.Pa}},j:function(a,b){try{var c=Z(a);return Tc(dc,c.path,b)}catch(d){return"undefined"!==typeof Y&&d instanceof P||I(d),-d.Pa}},E:function(a,b,c){try{var d=S[a];if(!d)throw new P(8);if(0===(d.flags&2097155))throw new P(28);hc(d.node,c);return 0}catch(f){return"undefined"!==
typeof Y&&f instanceof P||I(f),-f.Pa}},C:function(a,b){try{if(0===b)return-28;if(b<ba("/")+1)return-68;k("/",n,a,b);return a}catch(c){return"undefined"!==typeof Y&&c instanceof P||I(c),-c.Pa}},x:function(){return 0},d:function(){return 42},k:function(a,b){try{return a=A(a),Tc(ec,a,b)}catch(c){return"undefined"!==typeof Y&&c instanceof P||I(c),-c.Pa}},J:function(a,b){try{return a=A(a),a=r(a),"/"===a[a.length-1]&&(a=a.substr(0,a.length-1)),X(a,b),0}catch(c){return"undefined"!==typeof Y&&c instanceof
P||I(c),-c.Pa}},G:function(a,b,c,d,f,g){try{a:{g<<=12;var m=!1;if(0!==(d&16)&&0!==a%65536)var t=-28;else{if(0!==(d&32)){var w=ad(65536,b);if(!w){t=-48;break a}bd(w,0,b);m=!0}else{var u=S[f];if(!u){t=-8;break a}var C=g;if(0!==(c&2)&&0===(d&2)&&2!==(u.flags&2097155))throw new P(2);if(1===(u.flags&2097155))throw new P(2);if(!u.Na.hb)throw new P(43);var H=u.Na.hb(u,a,b,C,c,d);w=H.Nb;m=H.kb}Sc[w]={Kb:w,Jb:b,kb:m,fd:f,Mb:c,flags:d,offset:g};t=w}}return t}catch(aa){return"undefined"!==typeof Y&&aa instanceof
P||I(aa),-aa.Pa}},H:function(a,b){try{if(-1===(a|0)||0===b)var c=-28;else{var d=Sc[a];if(d&&b===d.Jb){var f=S[d.fd];if(f&&d.Mb&2){var g=d.flags,m=d.offset,t=n.slice(a,a+b);f&&f.Na.ib&&f.Na.ib(f,t,m,b,g)}Sc[a]=null;d.kb&&oa(d.Kb)}c=0}return c}catch(w){return"undefined"!==typeof Y&&w instanceof P||I(w),-w.Pa}},I:function(a,b,c){Uc=c;try{var d=A(a),f=c?Vc():0;return v(d,b,f).fd}catch(g){return"undefined"!==typeof Y&&g instanceof P||I(g),-g.Pa}},A:function(a,b,c){try{a=A(a);if(0>=c)var d=-28;else{var f=
Ob(a),g=Math.min(c,ba(f)),m=z[b+g];k(f,n,b,c+1);z[b+g]=m;d=g}return d}catch(t){return"undefined"!==typeof Y&&t instanceof P||I(t),-t.Pa}},u:function(a){try{a=A(a);var b=W(a,{parent:!0}).node,c=xb(a),d=Jb(b,c),f=Xb(b,c,!0);if(f)throw new P(f);if(!b.Ma.rmdir)throw new P(63);if(d.ab)throw new P(10);try{V.willDeletePath&&V.willDeletePath(a)}catch(g){J("FS.trackingDelegate['willDeletePath']('"+a+"') threw an exception: "+g.message)}b.Ma.rmdir(b,c);Rb(d);try{if(V.onDeletePath)V.onDeletePath(a)}catch(g){J("FS.trackingDelegate['onDeletePath']('"+
a+"') threw an exception: "+g.message)}return 0}catch(g){return"undefined"!==typeof Y&&g instanceof P||I(g),-g.Pa}},e:function(a,b){try{return a=A(a),Tc(dc,a,b)}catch(c){return"undefined"!==typeof Y&&c instanceof P||I(c),-c.Pa}},w:function(a){try{return a=A(a),ua(a),0}catch(b){return"undefined"!==typeof Y&&b instanceof P||I(b),-b.Pa}},l:function(){return 2147483648},n:function(a,b,c){n.copyWithin(a,b,b+c)},c:function(a){var b=n.length;a>>>=0;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=b*
(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(a,d);0<d%65536&&(d+=65536-d%65536);a:{try{Pa.grow(Math.min(2147483648,d)-Ya.byteLength+65535>>>16);Za();var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},r:function(a){for(var b=Wc();Wc()-b<a;);},p:function(a,b){try{var c=0;Yc().forEach(function(d,f){var g=b+c;f=L[a+4*f>>2]=g;for(g=0;g<d.length;++g)z[f++>>0]=d.charCodeAt(g);z[f>>0]=0;c+=d.length+1});return 0}catch(d){return"undefined"!==typeof Y&&d instanceof P||I(d),d.Pa}},q:function(a,b){try{var c=
Yc();L[a>>2]=c.length;var d=0;c.forEach(function(f){d+=f.length+1});L[b>>2]=d;return 0}catch(f){return"undefined"!==typeof Y&&f instanceof P||I(f),f.Pa}},f:function(a){try{var b=Z(a);la(b);return 0}catch(c){return"undefined"!==typeof Y&&c instanceof P||I(c),c.Pa}},o:function(a,b){try{var c=Z(a);z[b>>0]=c.tty?2:R(c.mode)?3:40960===(c.mode&61440)?7:4;return 0}catch(d){return"undefined"!==typeof Y&&d instanceof P||I(d),d.Pa}},t:function(a,b,c,d){try{a:{for(var f=Z(a),g=a=0;g<c;g++){var m=L[b+(8*g+4)>>
2],t=Nc(f,z,L[b+8*g>>2],m,void 0);if(0>t){var w=-1;break a}a+=t;if(t<m)break}w=a}L[d>>2]=w;return 0}catch(u){return"undefined"!==typeof Y&&u instanceof P||I(u),u.Pa}},m:function(a,b,c,d,f){try{var g=Z(a);a=4294967296*c+(b>>>0);if(-9007199254740992>=a||9007199254740992<=a)return-61;Lc(g,a,d);M=[g.position>>>0,(N=g.position,1<=+Math.abs(N)?0<N?(Math.min(+Math.floor(N/4294967296),4294967295)|0)>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)];L[f>>2]=M[0];L[f+4>>2]=M[1];g.ob&&0===a&&0===d&&(g.ob=
null);return 0}catch(m){return"undefined"!==typeof Y&&m instanceof P||I(m),m.Pa}},D:function(a){try{var b=Z(a);return b.Na&&b.Na.fsync?-b.Na.fsync(b):0}catch(c){return"undefined"!==typeof Y&&c instanceof P||I(c),c.Pa}},v:function(a,b,c,d){try{a:{for(var f=Z(a),g=a=0;g<c;g++){var m=ka(f,z,L[b+8*g>>2],L[b+(8*g+4)>>2],void 0);if(0>m){var t=-1;break a}a+=m}t=a}L[d>>2]=t;return 0}catch(w){return"undefined"!==typeof Y&&w instanceof P||I(w),w.Pa}},g:function(a){var b=Date.now();L[a>>2]=b/1E3|0;L[a+4>>2]=
b%1E3*1E3|0;return 0},K:function(a){var b=Date.now()/1E3|0;a&&(L[a>>2]=b);return b},B:function(a,b){if(b){var c=b+8;b=1E3*L[c>>2];b+=L[c+4>>2]/1E3}else b=Date.now();a=A(a);try{var d=W(a,{Ya:!0}).node;d.Ma.Ta(d,{timestamp:Math.max(b,b)});var f=0}catch(g){if(!(g instanceof P)){b:{f=Error();if(!f.stack){try{throw Error();}catch(m){f=m}if(!f.stack){f="(no stack trace available)";break b}}f=f.stack.toString()}e.extraStackTrace&&(f+="\n"+e.extraStackTrace());f=lb(f);throw g+" : "+f;}f=g.Pa;L[$c()>>2]=f;
f=-1}return f}};
(function(){function a(f){e.asm=f.exports;Pa=e.asm.L;Za();K=e.asm.Da;ab.unshift(e.asm.M);db--;e.monitorRunDependencies&&e.monitorRunDependencies(db);0==db&&(null!==eb&&(clearInterval(eb),eb=null),fb&&(f=fb,fb=null,f()))}function b(f){a(f.instance)}function c(f){return jb().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){J("failed to asynchronously prepare wasm: "+g);I(g)})}var d={a:cd};db++;e.monitorRunDependencies&&e.monitorRunDependencies(db);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){return J("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){return La||"function"!==typeof WebAssembly.instantiateStreaming||gb()||O.startsWith("file://")||"function"!==typeof fetch?c(b):fetch(O,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){J("wasm streaming compile failed: "+g);J("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.M).apply(null,arguments)};
var bd=e._memset=function(){return(bd=e._memset=e.asm.N).apply(null,arguments)};e._sqlite3_free=function(){return(e._sqlite3_free=e.asm.O).apply(null,arguments)};var $c=e.___errno_location=function(){return($c=e.___errno_location=e.asm.P).apply(null,arguments)};e._sqlite3_step=function(){return(e._sqlite3_step=e.asm.Q).apply(null,arguments)};e._sqlite3_finalize=function(){return(e._sqlite3_finalize=e.asm.R).apply(null,arguments)};
e._sqlite3_prepare_v2=function(){return(e._sqlite3_prepare_v2=e.asm.S).apply(null,arguments)};e._sqlite3_reset=function(){return(e._sqlite3_reset=e.asm.T).apply(null,arguments)};e._sqlite3_clear_bindings=function(){return(e._sqlite3_clear_bindings=e.asm.U).apply(null,arguments)};e._sqlite3_value_blob=function(){return(e._sqlite3_value_blob=e.asm.V).apply(null,arguments)};e._sqlite3_value_text=function(){return(e._sqlite3_value_text=e.asm.W).apply(null,arguments)};
e._sqlite3_value_bytes=function(){return(e._sqlite3_value_bytes=e.asm.X).apply(null,arguments)};e._sqlite3_value_double=function(){return(e._sqlite3_value_double=e.asm.Y).apply(null,arguments)};e._sqlite3_value_int=function(){return(e._sqlite3_value_int=e.asm.Z).apply(null,arguments)};e._sqlite3_value_type=function(){return(e._sqlite3_value_type=e.asm._).apply(null,arguments)};e._sqlite3_result_blob=function(){return(e._sqlite3_result_blob=e.asm.$).apply(null,arguments)};
e._sqlite3_result_double=function(){return(e._sqlite3_result_double=e.asm.aa).apply(null,arguments)};e._sqlite3_result_error=function(){return(e._sqlite3_result_error=e.asm.ba).apply(null,arguments)};e._sqlite3_result_int=function(){return(e._sqlite3_result_int=e.asm.ca).apply(null,arguments)};e._sqlite3_result_int64=function(){return(e._sqlite3_result_int64=e.asm.da).apply(null,arguments)};e._sqlite3_result_null=function(){return(e._sqlite3_result_null=e.asm.ea).apply(null,arguments)};
e._sqlite3_result_text=function(){return(e._sqlite3_result_text=e.asm.fa).apply(null,arguments)};e._sqlite3_column_count=function(){return(e._sqlite3_column_count=e.asm.ga).apply(null,arguments)};e._sqlite3_data_count=function(){return(e._sqlite3_data_count=e.asm.ha).apply(null,arguments)};e._sqlite3_column_blob=function(){return(e._sqlite3_column_blob=e.asm.ia).apply(null,arguments)};e._sqlite3_column_bytes=function(){return(e._sqlite3_column_bytes=e.asm.ja).apply(null,arguments)};
e._sqlite3_column_double=function(){return(e._sqlite3_column_double=e.asm.ka).apply(null,arguments)};e._sqlite3_column_text=function(){return(e._sqlite3_column_text=e.asm.la).apply(null,arguments)};e._sqlite3_column_type=function(){return(e._sqlite3_column_type=e.asm.ma).apply(null,arguments)};e._sqlite3_column_name=function(){return(e._sqlite3_column_name=e.asm.na).apply(null,arguments)};e._sqlite3_bind_blob=function(){return(e._sqlite3_bind_blob=e.asm.oa).apply(null,arguments)};
e._sqlite3_bind_double=function(){return(e._sqlite3_bind_double=e.asm.pa).apply(null,arguments)};e._sqlite3_bind_int=function(){return(e._sqlite3_bind_int=e.asm.qa).apply(null,arguments)};e._sqlite3_bind_text=function(){return(e._sqlite3_bind_text=e.asm.ra).apply(null,arguments)};e._sqlite3_bind_parameter_index=function(){return(e._sqlite3_bind_parameter_index=e.asm.sa).apply(null,arguments)};e._sqlite3_sql=function(){return(e._sqlite3_sql=e.asm.ta).apply(null,arguments)};
e._sqlite3_normalized_sql=function(){return(e._sqlite3_normalized_sql=e.asm.ua).apply(null,arguments)};e._sqlite3_errmsg=function(){return(e._sqlite3_errmsg=e.asm.va).apply(null,arguments)};e._sqlite3_exec=function(){return(e._sqlite3_exec=e.asm.wa).apply(null,arguments)};e._sqlite3_changes=function(){return(e._sqlite3_changes=e.asm.xa).apply(null,arguments)};e._sqlite3_close_v2=function(){return(e._sqlite3_close_v2=e.asm.ya).apply(null,arguments)};
e._sqlite3_create_function_v2=function(){return(e._sqlite3_create_function_v2=e.asm.za).apply(null,arguments)};e._sqlite3_open=function(){return(e._sqlite3_open=e.asm.Aa).apply(null,arguments)};var ca=e._malloc=function(){return(ca=e._malloc=e.asm.Ba).apply(null,arguments)},oa=e._free=function(){return(oa=e._free=e.asm.Ca).apply(null,arguments)};e._RegisterExtensionFunctions=function(){return(e._RegisterExtensionFunctions=e.asm.Ea).apply(null,arguments)};
var qb=e.__get_tzname=function(){return(qb=e.__get_tzname=e.asm.Fa).apply(null,arguments)},pb=e.__get_daylight=function(){return(pb=e.__get_daylight=e.asm.Ga).apply(null,arguments)},ob=e.__get_timezone=function(){return(ob=e.__get_timezone=e.asm.Ha).apply(null,arguments)},pa=e.stackSave=function(){return(pa=e.stackSave=e.asm.Ia).apply(null,arguments)},ra=e.stackRestore=function(){return(ra=e.stackRestore=e.asm.Ja).apply(null,arguments)},y=e.stackAlloc=function(){return(y=e.stackAlloc=e.asm.Ka).apply(null,
arguments)},ad=e._memalign=function(){return(ad=e._memalign=e.asm.La).apply(null,arguments)};e.cwrap=function(a,b,c,d){c=c||[];var f=c.every(function(g){return"number"===g});return"string"!==b&&f&&!d?Ra(a):function(){return Sa(a,b,c,arguments)}};e.UTF8ToString=A;e.stackSave=pa;e.stackRestore=ra;e.stackAlloc=y;var dd;fb=function ed(){dd||fd();dd||(fb=ed)};
function fd(){function a(){if(!dd&&(dd=!0,e.calledRun=!0,!Qa)){e.noFSInit||Pc||(Pc=!0,Oc(),e.stdin=e.stdin,e.stdout=e.stdout,e.stderr=e.stderr,e.stdin?Qc("stdin",e.stdin):cc("/dev/tty","/dev/stdin"),e.stdout?Qc("stdout",null,e.stdout):cc("/dev/tty","/dev/stdout"),e.stderr?Qc("stderr",null,e.stderr):cc("/dev/tty1","/dev/stderr"),v("/dev/stdin",0),v("/dev/stdout",1),v("/dev/stderr",1));Nb=!1;kb(ab);if(e.onRuntimeInitialized)e.onRuntimeInitialized();if(e.postRun)for("function"==typeof e.postRun&&(e.postRun=
[e.postRun]);e.postRun.length;){var b=e.postRun.shift();bb.unshift(b)}kb(bb)}}if(!(0<db)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)cb();kb($a);0<db||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}e.run=fd;if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();fd();
// The shell-pre.js and emcc-generated code goes above
return Module;
}); // The end of the promise being returned
return initSqlJsPromise;
} // The end of our initSqlJs function
// This bit below is copied almost exactly from what you get when you use the MODULARIZE=1 flag with emcc
// However, we don't want to use the emcc modularization. See shell-pre.js
if (typeof exports === 'object' && typeof module === 'object'){
module.exports = initSqlJs;
// This will allow the module to be used in ES6 or CommonJS
module.exports.default = initSqlJs;
}
else if (typeof define === 'function' && define['amd']) {
define([], function() { return initSqlJs; });
}
else if (typeof exports === 'object'){
exports["Module"] = initSqlJs;
}

BIN
lib/sql-js/dist/sql-wasm.wasm vendored Normal file

Binary file not shown.

9
lib/sql-js/make.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash -e
docker build -t sqliteviz/sqljs .
rm -r dist || true
CONTAINER=$(docker create sqliteviz/sqljs)
docker cp $CONTAINER:/tmp/build/dist .
docker rm $CONTAINER

4
lib/sql-js/package.json Normal file
View File

@@ -0,0 +1,4 @@
{
"name": "sql.js",
"main": "./dist/sql-wasm.js"
}

35
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "sqliteviz", "name": "sqliteviz",
"version": "0.13.0", "version": "0.13.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "sqliteviz", "name": "sqliteviz",
"version": "0.13.0", "version": "0.13.1",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"codemirror": "^5.57.0", "codemirror": "^5.57.0",
@@ -18,7 +18,7 @@
"react": "^16.13.1", "react": "^16.13.1",
"react-chart-editor": "^0.45.0", "react-chart-editor": "^0.45.0",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"sql.js": "^1.5.0", "sql.js": "file:./lib/sql-js",
"sqlite-parser": "^1.0.1", "sqlite-parser": "^1.0.1",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-codemirror": "^4.0.6", "vue-codemirror": "^4.0.6",
@@ -54,6 +54,7 @@
"worker-loader": "^3.0.8" "worker-loader": "^3.0.8"
} }
}, },
"lib/sql-js": {},
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
"version": "7.12.13", "version": "7.12.13",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz",
@@ -2530,7 +2531,6 @@
"merge-source-map": "^1.1.0", "merge-source-map": "^1.1.0",
"postcss": "^7.0.14", "postcss": "^7.0.14",
"postcss-selector-parser": "^6.0.2", "postcss-selector-parser": "^6.0.2",
"prettier": "^1.18.2",
"source-map": "~0.6.1", "source-map": "~0.6.1",
"vue-template-es2015-compiler": "^1.9.0" "vue-template-es2015-compiler": "^1.9.0"
}, },
@@ -7947,8 +7947,7 @@
"esprima": "^4.0.1", "esprima": "^4.0.1",
"estraverse": "^4.2.0", "estraverse": "^4.2.0",
"esutils": "^2.0.2", "esutils": "^2.0.2",
"optionator": "^0.8.1", "optionator": "^0.8.1"
"source-map": "~0.6.1"
}, },
"bin": { "bin": {
"escodegen": "bin/escodegen.js", "escodegen": "bin/escodegen.js",
@@ -10757,7 +10756,6 @@
"minimist": "^1.2.5", "minimist": "^1.2.5",
"neo-async": "^2.6.0", "neo-async": "^2.6.0",
"source-map": "^0.6.1", "source-map": "^0.6.1",
"uglify-js": "^3.1.4",
"wordwrap": "^1.0.0" "wordwrap": "^1.0.0"
}, },
"bin": { "bin": {
@@ -12543,8 +12541,7 @@
"esprima": "^2.7.1", "esprima": "^2.7.1",
"estraverse": "^1.9.1", "estraverse": "^1.9.1",
"esutils": "^2.0.2", "esutils": "^2.0.2",
"optionator": "^0.8.1", "optionator": "^0.8.1"
"source-map": "~0.2.0"
}, },
"bin": { "bin": {
"escodegen": "bin/escodegen.js", "escodegen": "bin/escodegen.js",
@@ -13149,7 +13146,6 @@
"anymatch": "^2.0.0", "anymatch": "^2.0.0",
"async-each": "^1.0.1", "async-each": "^1.0.1",
"braces": "^2.3.2", "braces": "^2.3.2",
"fsevents": "^1.2.7",
"glob-parent": "^3.1.0", "glob-parent": "^3.1.0",
"inherits": "^2.0.3", "inherits": "^2.0.3",
"is-binary-path": "^1.0.0", "is-binary-path": "^1.0.0",
@@ -18331,9 +18327,6 @@
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.46.0.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.46.0.tgz",
"integrity": "sha512-qPGoUBNl+Z8uNu0z7pD3WPTABWRbcOwIrO/5ccDJzmrtzn0LVf6Lj91+L5CcWhXl6iWf23FQ6m8Jkl2CmN1O7Q==", "integrity": "sha512-qPGoUBNl+Z8uNu0z7pD3WPTABWRbcOwIrO/5ccDJzmrtzn0LVf6Lj91+L5CcWhXl6iWf23FQ6m8Jkl2CmN1O7Q==",
"dev": true, "dev": true,
"dependencies": {
"fsevents": "~2.3.1"
},
"bin": { "bin": {
"rollup": "dist/bin/rollup" "rollup": "dist/bin/rollup"
}, },
@@ -19440,9 +19433,8 @@
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
}, },
"node_modules/sql.js": { "node_modules/sql.js": {
"version": "1.5.0", "resolved": "lib/sql-js",
"resolved": "https://registry.npmjs.org/sql.js/-/sql.js-1.5.0.tgz", "link": true
"integrity": "sha512-Qqr6HgX/hCDpLFWdN0BNoNpYQ2c1tOl1c3HGI0cshjaFSAWszKICuLZ9CyFUvRFPpEGW8RzHzwuXWWvXVGTKBg=="
}, },
"node_modules/sqlite-parser": { "node_modules/sqlite-parser": {
"version": "1.0.1", "version": "1.0.1",
@@ -21618,7 +21610,6 @@
"peer": true, "peer": true,
"dependencies": { "dependencies": {
"source-map": "~0.5.1", "source-map": "~0.5.1",
"uglify-to-browserify": "~1.0.0",
"yargs": "~3.10.0" "yargs": "~3.10.0"
}, },
"bin": { "bin": {
@@ -22008,10 +21999,8 @@
"integrity": "sha512-ymVbbQP40MFTp+cNMvpyBpBtygHnPzPkHqoIwRRj/0B8KhqQwV8LaKjtbaxF2lK4vl8zN9wCxS46IFCU5K4W0g==", "integrity": "sha512-ymVbbQP40MFTp+cNMvpyBpBtygHnPzPkHqoIwRRj/0B8KhqQwV8LaKjtbaxF2lK4vl8zN9wCxS46IFCU5K4W0g==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"chokidar": "^3.4.0",
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
"neo-async": "^2.5.0", "neo-async": "^2.5.0"
"watchpack-chokidar2": "^2.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"chokidar": "^3.4.0", "chokidar": "^3.4.0",
@@ -22412,7 +22401,6 @@
"anymatch": "^2.0.0", "anymatch": "^2.0.0",
"async-each": "^1.0.1", "async-each": "^1.0.1",
"braces": "^2.3.2", "braces": "^2.3.2",
"fsevents": "^1.2.7",
"glob-parent": "^3.1.0", "glob-parent": "^3.1.0",
"inherits": "^2.0.3", "inherits": "^2.0.3",
"is-binary-path": "^1.0.0", "is-binary-path": "^1.0.0",
@@ -22782,7 +22770,6 @@
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"graceful-fs": "^4.1.6",
"universalify": "^2.0.0" "universalify": "^2.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {
@@ -40106,9 +40093,7 @@
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
}, },
"sql.js": { "sql.js": {
"version": "1.5.0", "version": "file:lib/sql-js"
"resolved": "https://registry.npmjs.org/sql.js/-/sql.js-1.5.0.tgz",
"integrity": "sha512-Qqr6HgX/hCDpLFWdN0BNoNpYQ2c1tOl1c3HGI0cshjaFSAWszKICuLZ9CyFUvRFPpEGW8RzHzwuXWWvXVGTKBg=="
}, },
"sqlite-parser": { "sqlite-parser": {
"version": "1.0.1", "version": "1.0.1",

View File

@@ -19,7 +19,6 @@
"react": "^16.13.1", "react": "^16.13.1",
"react-chart-editor": "^0.45.0", "react-chart-editor": "^0.45.0",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"sql.js": "^1.5.0",
"sqlite-parser": "^1.0.1", "sqlite-parser": "^1.0.1",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-codemirror": "^4.0.6", "vue-codemirror": "^4.0.6",
@@ -27,7 +26,8 @@
"vue-router": "^3.2.0", "vue-router": "^3.2.0",
"vuejs-paginate": "^2.1.0", "vuejs-paginate": "^2.1.0",
"vuera": "^0.2.7", "vuera": "^0.2.7",
"vuex": "^3.4.0" "vuex": "^3.4.0",
"sql.js": "file:./lib/sql-js"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^4.4.0", "@vue/cli-plugin-babel": "^4.4.0",

View File

@@ -0,0 +1,238 @@
import chai from 'chai'
import database from '@/lib/database'
const expect = chai.expect
describe('SQLite extensions', function () {
let db
beforeEach(() => {
db = database.getNewDatabase()
})
afterEach(() => {
db.shutDown()
})
it('supports contrib trigonometric functions', async function () {
const actual = await db.execute(`
SELECT
abs(3.1415926 - pi()) < 0.000001,
abs(1 - cos(2 * pi())) < 0.000001,
abs(0 - sin(pi())) < 0.000001,
abs(0 - tan(0)) < 0.000001,
abs(0 - cot(pi() / 2)) < 0.000001,
abs(1 - acos(cos(1))) < 0.000001,
abs(1 - asin(sin(1))) < 0.000001,
abs(1 - atan(tan(1))) < 0.000001,
abs(1 - cosh(0)) < 0.000001,
abs(0 - sinh(0)) < 0.000001,
abs(tanh(1) + tanh(-1)) < 0.000001,
abs(coth(1) + coth(-1)) < 0.000001,
abs(1 - acosh(cosh(1))) < 0.000001,
abs(1 - asinh(sinh(1))) < 0.000001,
abs(1 - atanh(tanh(1))) < 0.000001,
abs(180 - degrees(pi())) < 0.000001,
abs(pi() - radians(180)) < 0.000001,
abs(pi() / 2 - atan2(1, 0)) < 0.000001
`)
expect(actual.values).to.eql([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])
})
it('supports contrib math functions', async function () {
const actual = await db.execute(`
SELECT
exp(0),
log(exp(1)),
log10(10000),
power(2, 3),
sign(-10) + sign(20),
sqrt(square(16)),
ceil(-1.95) + ceil(1.95),
floor(-1.95) + floor(1.95)
`)
expect(actual.values).to.eql([[1, 1, 4, 8, 0, 16, 1, -1]])
})
it('supports contrib string functions', async function () {
const actual = await db.execute(`
SELECT
replicate('ab', 4),
charindex('ab', 'foobarabbarfoo'),
charindex('ab', 'foobarabbarfoo', 8),
leftstr('foobar', 2),
rightstr('foobar', 2),
reverse('foobar'),
proper('fooBar'),
padl('foo', 5),
padr('foo', 5),
padc('foo', 5),
strfilter('abcba', 'bc')
`)
expect(actual.values).to.eql([
['abababab', 7, 0, 'fo', 'ar', 'raboof', 'Foobar', ' foo', 'foo ', ' foo ', 'bcb']
])
})
it('supports contrib aggregate functions', async function () {
const actual = await db.execute(`
WITH RECURSIVE series(x) AS (
SELECT 1
UNION ALL
SELECT x + 1
FROM series
WHERE x + 1 <= 12
)
SELECT
abs( 3.77406806 - stdev(x)) < 0.000001,
abs(14.24358974 - variance(x)) < 0.000001,
mode(x),
median(x),
lower_quartile(x),
upper_quartile(x)
FROM (
SELECT x
FROM series
UNION ALL
VALUES (1)
)
`)
expect(actual.values).to.eql([[1, 1, 1, 6, 3, 9]])
})
it('supports generate_series', async function () {
const actual = await db.execute(`
SELECT value
FROM generate_series(5, 20, 5)
`)
expect(actual.values).to.eql([[5], [10], [15], [20]])
})
it('supports transitive_closure', async function () {
const actual = await db.execute(`
CREATE TABLE node(
node_id INTEGER NOT NULL PRIMARY KEY,
parent_id INTEGER,
name VARCHAR(127),
FOREIGN KEY (parent_id) REFERENCES node(node_id)
);
CREATE INDEX node_parent_id_idx ON node(parent_id);
CREATE VIRTUAL TABLE node_closure USING transitive_closure(
tablename = "node",
idcolumn = "node_id",
parentcolumn = "parent_id"
);
INSERT INTO node VALUES
(1, NULL, 'tests'),
(2, 1, 'lib'),
(3, 2, 'database'),
(4, 2, 'utils'),
(5, 2, 'storedQueries.spec.js'),
(6, 3, '_sql.spec.js'),
(7, 3, '_statements.spec.js'),
(8, 3, 'database.spec.js'),
(9, 3, 'sqliteExtensions.spec.js'),
(10, 4, 'fileIo.spec.js'),
(11, 4, 'time.spec.js');
SELECT name
FROM node
WHERE node_id IN (
SELECT nc.id
FROM node_closure AS nc
WHERE nc.root = 2 AND nc.depth = 2
);
`)
expect(actual.values).to.eql([
['_sql.spec.js'],
['_statements.spec.js'],
['database.spec.js'],
['sqliteExtensions.spec.js'],
['fileIo.spec.js'],
['time.spec.js']
])
})
it('supports UUID functions', async function () {
const actual = await db.execute(`
SELECT
length(uuid()),
uuid_str(uuid_blob('26a8349c8a7f4cbeb519bf792c3d7ac6'))
`)
expect(actual.values).to.eql([[36, '26a8349c-8a7f-4cbe-b519-bf792c3d7ac6']])
})
it('supports regexp', async function () {
const actual = await db.execute(`
SELECT
regexp('=\\s?\\d+', 'const foo = 123; const bar = "bar"'),
regexpi('=\\s?\\d+', 'const foo = 123; const bar = "bar"'),
'const foo = 123; const bar = "bar"' REGEXP '=\\s?\\d+'
`)
expect(actual.values).to.eql([[1, 1, 1]])
})
it('supports pivot virtual table', async function () {
const actual = await db.execute(`
CREATE TABLE point(x REAL, y REAL, z REAL);
INSERT INTO point VALUES
(5,3,3.2), (5,6,4.3), (5,9,5.4),
(10,3,4), (10,6,3.8), (10,9,3.6),
(15,3,4.8), (15,6,4), (15,9,3.5);
CREATE VIRTUAL TABLE pivot USING pivot_vtab(
(SELECT y FROM point GROUP BY y),
(SELECT x, x FROM point GROUP BY x),
(SELECT z FROM point WHERE y = :y AND x = :x)
);
CREATE TEMPORARY TABLE surface AS
SELECT xt.x, p.*
FROM (
SELECT row_number() OVER () rownum, *
FROM pivot
) p
JOIN (
SELECT row_number() OVER () rownum, x
FROM point
GROUP BY x
) xt USING(rownum);
ALTER TABLE surface DROP COLUMN rownum;
SELECT * FROM surface;
`)
expect(actual.columns).to.eql(['x', 'y', '5.0', '10.0', '15.0'])
expect(actual.values).to.eql([
[5, 3, 3.2, 4, 4.8],
[10, 6, 4.3, 3.8, 4],
[15, 9, 5.4, 3.6, 3.5]
])
})
it('supports FTS5', async function () {
const actual = await db.execute(`
CREATE VIRTUAL TABLE email USING fts5(sender, title, body, tokenize = 'porter ascii');
INSERT INTO email VALUES
(
'foo@localhost',
'fts3/4',
'FTS3 and FTS4 are SQLite virtual table modules that allows users to perform '
|| 'full-text searches on a set of documents.'
),
(
'bar@localhost',
'fts4',
'FTS5 is an SQLite virtual table module that provides full-text search '
|| 'functionality to database applications.'
);
SELECT sender
FROM email
WHERE body MATCH '"full-text" NOT document'
ORDER BY rank;
`)
expect(actual.values).to.eql([['bar@localhost']])
})
})

View File

@@ -3,6 +3,9 @@ const WorkboxPlugin = require('workbox-webpack-plugin')
module.exports = { module.exports = {
publicPath: '', publicPath: '',
// Workaround for https://github.com/vuejs/vue-cli/issues/5399 as described
// in https://stackoverflow.com/a/63185174
lintOnSave: process.env.NODE_ENV === 'development',
configureWebpack: { configureWebpack: {
plugins: [ plugins: [
new CopyPlugin([ new CopyPlugin([