Skip to content

"failed to open SQLite DB" when it's a DuckDB file (file permissions? USER MAPPING?) #55

@houstonhaynes

Description

@houstonhaynes

I have two users on a database that's essentially just a set of foreign tables into a duckdb DB file. When I run a query against the postgres endpoint I get the following error in the log

cmsadmin@medptd ERROR: failed to open SQLite DB. rc=1 path=/home/postgres/medptd.db

The 'cmsadmin' is salient here because they are the user that "owns" this database. When I go into a psql prompt as the cmsadmin user on the DB I get the same error.

cmsadmin@cmspsql:~$ psql -d medptd
psql (16.4 (Debian 16.4-1.pgdg120+1))
Type "help" for help.

medptd=# SELECT COUNT(*) FROM cms_view;
ERROR:  failed to open SQLite DB. rc=1 path=/home/postgres/medptd.db
medptd=#

So when I look at this file I see that the cmsadmin group is the "owner" of the file

cmsadmin@cmspsql:~$ ls -lh /home/postgres
total 27G
-rwxr-xr-x 1 cmsadmin cmsadmin 27G Sep  7 09:28 medptd.db

And when I run duckdb as either postgres or cmsadmin I have no issue. (added both user to the "cmsadmin" group which owns the folder and file)

image

So I'm down to a few potential issues I wanted to ask here. When setting up the fdw there's no mention of user mapping. I'm wondering if that matters here.

CREATE USER MAPPING FOR cmsadmin SERVER duckdb_server;

Does this register as meaningful to anyone here? Is there anything else that should be considered when setting up duckdb_server in the postgres instance? I feel like there's some detail I'm missing in understanding how the extension accesses the .db file.

Thanks in advance to anyone that can shed light on this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions