duckdb / duckdb-wasm

WebAssembly version of DuckDB
https://shell.duckdb.org
MIT License
1.02k stars 111 forks source link

db.open is broken #1659

Closed dioptre closed 4 months ago

dioptre commented 4 months ago

What happens?

Tried all manner of operations to get db.open to work, and seems to fail.

Main error is:

Error: Opening the database failed with error: tried to read past the end

or

Uncaught (in promise) RuntimeError: memory access out of bounds

To Reproduce

        const response = await fetch(`http://localhost:8010/download-db`);
        const arrayBuffer = await response.arrayBuffer();
        await db.registerFileBuffer('tpch_0_01.db', new Uint8Array(arrayBuffer))
        //await db.open('tpch_0_01.db');
        db.open({ path: `http://localhost:8010/download-db` })

also tried

await conn.query(`ATTACH 'http://localhost:8010/download-db' (READ_ONLY)`)

also

await conn.query(`USE 'tpch_0_01.db'`)

Browser/Environment:

Firefox

Device:

m2

DuckDB-Wasm Version:

106 (0.9.2) db version also matched

DuckDB-Wasm Deployment:

https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.28.1-dev106.0/+esm

Full Name:

Andrew Grosser

Affiliation:

Sourcetable

Seems it should work : https://github.com/duckdb/duckdb-wasm/discussions/1634

carlopi commented 4 months ago
await conn.query(`ATTACH 'http://localhost:8010/filename.db' (READ_ONLY)`);

This + potentially USE 'filename' has to work, for sure in version matching duckdb 0.10.0 (any version published in the last two weeks), probably also before but not sure.

Potentially related, see also this discussion on how to add files to the filesystem: https://github.com/duckdb/duckdb_spatial/discussions/275.

I will add a test demoing this and come back to this.

dioptre commented 4 months ago

Thanks! Exactly doing this in the spatial example works!