Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied on schema in PostgreSQL

I can't find why I am getting an permission denied error in my database.

The role owns the schema and has access to the table, but still the log says:

ERROR: permission denied for schema myschema at character 20
QUERY: SELECT 1 FROM ONLY "myshema"."mytable" x WHERE "id" OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF x
like image 248
jnas Avatar asked Dec 30 '25 07:12

jnas


1 Answers

There is a foreign key in a table referring to a table in the schema in question, to which the table owner role does not have access granted. Foreign key checks are done with the permissions of the role that owns the table, not the role performing the query.

The query is actually doing the internal foreign key check.

like image 165
jnas Avatar answered Jan 01 '26 22:01

jnas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!