Skip to content

Accessing views from pg_duckdb is inconsistent with PostgreSQL #948

@ggnmstr

Description

@ggnmstr

What happens?

In PostgreSQL, when accessing views, rights of user are checked in planner.
It is possible to set different rights for different users.
Here's the example:

postgres=# create user user1;
CREATE ROLE
postgres=# create table test(a int);
CREATE TABLE
postgres=# insert into test (a) values (1);
INSERT 0 1
postgres=# create view pgv as select * from test ;
CREATE VIEW

postgres=# set role user1 ;
SET
postgres=> select * from pgv;
ERROR:  permission denied for view pgv

postgres=> set role jorq;
SET
postgres=# grant select on pgv to user1 ;
GRANT

postgres=# set role user1;
SET
postgres=> select * from pgv;
 a
---
 1
(1 row)

However, in pg_duckdb planner they are not checked.

Due to that any view that calls duckdb can be accessed by any user, and only postgres_role matters here.
GRANT / REVOKE on these views are useless. This is inconsistent to recognized PostgreSQL behavior

To Reproduce

(see above)

OS:

Linux

pg_duckdb Version (if built from source use commit hash):

main

Postgres Version (if built from source use commit hash):

17

Hardware:

No response

Full Name:

Jora Babayan

Affiliation:

Postgres Professional

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have not tested with any build

Did you include all relevant data sets for reproducing the issue?

No - Other reason (please specify in the issue body)

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecurityAn issue with a security impact

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions