duckdb / sqlite_scanner

DuckDB extension to read and write to SQLite databases
MIT License
189 stars 19 forks source link

ATTACH succeeds when database does not exist, while CALL fails #75

Closed szarnyasg closed 5 months ago

szarnyasg commented 7 months ago

What happens?

The documentation says:

For example with the bundled sakila.db file: ATTACH 'sakila.db' (TYPE sqlite); -- or CALL sqlite_attach('sakila.db');

When the file is not available, ATTACH succeeds but CALL fails.

To Reproduce

Works:

ATTACH 'sakila.db' (TYPE sqlite);
Run Time (s): real 0.004 user 0.000234 sys 0.000092

Fails:

CALL sqlite_attach('sakila.db');
Run Time (s): real 0.028 user 0.194032 sys 0.021092
Error: Invalid Error: Unable to open database "sakila.db": unable to open database file

OS:

macOS Sonoma

SQLite Version:

n/a

DuckDB Version:

0.9.0

DuckDB Client:

CLI

Full Name:

Gabor Szarnyas

Affiliation:

DuckDB Labs

Have you tried this on the latest main branch?

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

Mytherin commented 5 months ago

Thanks for the report! CALL sqlite_attach is read-only, ATTACH is read-write, so this seems consistent/correct to me. Attaching a file that does not exist creates the file which matches DuckDB's behavior (and SQLite's default behavior).