dyedgreen / deno-sqlite

Deno SQLite module
https://deno.land/x/sqlite
MIT License
409 stars 36 forks source link

Add `SQLITE_OMIT_ATTACH ` to build and add documentation #18

Closed dyedgreen closed 4 years ago

dyedgreen commented 4 years ago

I think omitting the ATTACH keyword would be a wise move (since the VFS does not really support different file-names). This means that people could make the following mistake:

ATTACH DATABASE db1 as db1;
ATTACH DATABASE db2 as db2;

Now db1 and db2 point to the same database as the VFS only inspects the first letter of the name. Further, the files would point to the journal file, as journal files are recognised using the length of the file name.

dyedgreen commented 4 years ago

From SQLite docs:

The SQLITEOMIT* options are unsupported.

Indeed, the option results in compiler errors:

wasm-ld: error: /var/folders/6h/7q0mr8_96g9g0j0m4bnbtv5m0000gn/T/sqlite3-63e898.o: undefined symbol:
sqlite3Detach
wasm-ld: error: /var/folders/6h/7q0mr8_96g9g0j0m4bnbtv5m0000gn/T/sqlite3-63e898.o: undefined symbol:
sqlite3Attach
wasm-ld: error: /var/folders/6h/7q0mr8_96g9g0j0m4bnbtv5m0000gn/T/sqlite3-63e898.o: undefined symbol:
sqlite3Vacuum
wasm-ld: error: /var/folders/6h/7q0mr8_96g9g0j0m4bnbtv5m0000gn/T/sqlite3-63e898.o: undefined symbol:
sqlite3Vacuum
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [build] Error 1
dyedgreen commented 4 years ago

Actually, it might simply be necessary to rebuild sqlite from source:

Important Note: The SQLITEOMIT options may not work with the amalgamation. SQLITEOMIT compile-time options usually work correctly only when SQLite is built from canonical source files.

This should probably also be done for the benefit of the current OMIT flags which are in use...