Re: Permission Denied on INSERT

From: Sam Stearns <sam(dot)stearns(at)dat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>, Julie Mather <julie(dot)mather(at)dat(dot)com>, Peter Garza <peter(dot)garza(at)dat(dot)com>, Henry Ashu <henry(dot)ashu(at)dat(dot)com>
Subject: Re: Permission Denied on INSERT
Date: 2025-06-27 16:59:45
Message-ID: CAN6TVjn4SAHC8_-4xN9qcWzYSUAZQPoqK-pqAXQdjHF-iKMbHA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

You are right, Tom. That was the problem. Thank you!

Sam

On Fri, Jun 27, 2025 at 8:26 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Sam Stearns <sam. stearns@ dat. com> writes: > We're getting a permission
> denied error on an INSERT and cannot figure out > why: > *[postgres@
> thiludbapql01 log]$ psql -U treg csbtestPassword for user > treg: psql (16.
> 6)Type "help"
> ZjQcmQRYFpfptBannerStart
> This Message Is From an External Sender
> This message came from outside your organization.
>
> ZjQcmQRYFpfptBannerEnd
>
> Sam Stearns <sam(dot)stearns(at)dat(dot)com> writes:
> > We're getting a permission denied error on an INSERT and cannot figure out
> > why:
> > *[postgres(at)thiludbapql01 log]$ psql -U treg csbtestPassword for user
> > treg:psql (16.6)Type "help" for help.csbtest=# show search_path;
> > search_path---------------------------- csbtfsprd, interface, treg(1
> > row)csbtest=# grant usage on schema treg to treg;GRANTcsbtest=# GRANT
> > SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA treg TO
> > treg;GRANTcsbtest=# GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA treg TO
> > treg;GRANTcsbtest=# GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA treg TO
> > treg;GRANTcsbtest=# insert into treg.cd_combined_office_mappings
> > (combined_office_id, tcsi_office_id, sb2_account_id, account_name, city,
> > postal_code, state, category, is_preferred, is_closed, is_parent)csbtest-#
> > values (('734309'::int8),('S.668863.785512'),('668863'::int4),('Testing
> > Something'),('Beaverton'),('97008'),('OR'),('Carrier'),('Y'),('N'),('Y'));ERROR:
> > permission denied for schema tregLINE 1: SELECT 1 FROM ONLY
> > "treg"."cd_combined_offices" x WHERE "com...
> > ^QUERY: SELECT 1 FROM ONLY "treg"."cd_combined_offices" x WHERE
> > "combined_office_id" OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF xcsbtest=#*
>
> The error appears to be getting thrown in a generated
> foreign-key-constraint-enforcement query. From memory,
> those are executed as the owner of the table (I think
> owner of the referencing table, in this case). You've
> apparently not granted usage on treg to that role.
>
> regards, tom lane
>
>

--

Samuel Stearns
Team Lead - Database
c: 971 762 6879 | o: 971 762 6879 | DAT.com

<https://www.dat.com/?utm_medium=email&utm_source=DAT_email_signature_link>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message DINESH NAIR 2025-06-30 03:01:57 Re: Permission Denied on INSERT
Previous Message Tom Lane 2025-06-27 15:26:33 Re: Permission Denied on INSERT