pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Leland Weathers <leland@lcweathers.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Permission denied on schema for all users on insert to table with fk
Date: Wed, 25 Jul 2018 09:32:35 -0700
Message-ID: <0357d12a-2b1e-14ac-b9b5-7b0062c529fc@aklaver.com> (raw)
In-Reply-To: <CA+QX6VWofLQLC9FP3mCeyczy7_w8m8mGGxKejiRcrBEqdNosyg@mail.gmail.com>
References: <CA+QX6VWofLQLC9FP3mCeyczy7_w8m8mGGxKejiRcrBEqdNosyg@mail.gmail.com>

On 07/25/2018 06:40 AM, Leland Weathers wrote:
> I just ran into an issue on 9.5.13 after creating a new schema with a 
> set of tables in them, that no accounts (including schema / table 
> owners) can insert into a table with a fk relation. A snippet of the 
> error output in log files is as follows and looks like it is permissions 
> related to the parent table:____

Is the FK to a table in another schema?

Can we see the schema definitions for the affected tables?

> 
> __ __
> 
> “permission denied for schema <schemaname>",,,"SELECT 1 FROM ONLY 
> <schemaname>.<tablename> x WHERE ""id"" OPERATOR(pg_catalog.=) $1 FOR 
> KEY SHARE OF x",20____
> 
> __ __
> 
> __ __
> 
> The schema and tables are all owned by the same group role, and members 
> of the owner role are also getting the error. So far, all users both 
> owner and non-owner have been able to successfully execute the select 
> statement used by trigger and get either a 1 back, or no rows when the 
> correct id is entered. When run from the application, writes to this 
> table are immediately after writes to the parent table so that the id 
> can be returned for the child table writes. Writes to both parent/child 
> tables are occurring with the same account. The following short snippet 
> are a couple of the commands run by an account which is in the group 
> role owning the database, schema and tables in question:____
> 
> __ __
> 
> <database>=# SELECT 1 FROM ONLY "<schema>"."<table>" x WHERE "id" 
> OPERATOR(pg_catalog.=) 3 FOR____
> 
> KEY SHARE OF x;____
> 
> ?column?____
> 
> ----------____
> 
>          1____
> 
> (1 row)____
> 
> __ __
> 
> <database>=# INSERT INTO <schema>.sentryhistoryitem____
> 
> <database>-#   
> (batchid,datasourceid,sequence_order,description,causedfailure,"timestamp",modulename,modulebasename)____
> 
> <database>-# VALUES____
> 
> <database>-#   (3,20,1,'Found datasource [Id: 20, Name: 
> ds1].',False,'07/24/2018 03:05:58.668','Datasource','Object')____
> 
> <database>-# ;____
> 
> ERROR:  permission denied for schema <schema>____
> 
> LINE 1: SELECT 1 FROM ONLY "<schema>"."<table>"...____
> 
>                             ^____
> 
> QUERY:  SELECT 1 FROM ONLY "<schema>"."<table>" x WHERE "id" 
> OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF x____
> 
> __ __
> 
> I’ve spent a bit of time searching on different sites trying to find 
> pointers to this particular case and haven’t found any good ideas yet 
> for next steps on troubleshooting or pointing at root cause. Any 
> pointers to next steps would be appreciated.
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (7+ messages)  latest in thread

Message-ID: <0357d12a-2b1e-14ac-b9b5-7b0062c529fc@aklaver.com>
Permalink:  ../0357d12a-2b1e-14ac-b9b5-7b0062c529fc@aklaver.com/
Also on:    postgresql.org/message-id/0357d12a-2b1e-14ac-b9b5-7b0062c529fc@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, leland@lcweathers.net
  Subject: Re: Permission denied on schema for all users on insert to table with fk
  In-Reply-To: <0357d12a-2b1e-14ac-b9b5-7b0062c529fc@aklaver.com>
  References: <CA+QX6VWofLQLC9FP3mCeyczy7_w8m8mGGxKejiRcrBEqdNosyg@mail.gmail.com> <0357d12a-2b1e-14ac-b9b5-7b0062c529fc@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox