Re: Privilege required for IF EXISTS event if the object already exists

2021-12-16 Thread Shay Rojansky
> As I said before, your position seems reasonable. I've also got a couple of reasonable complaints about IF EXISTS out there. But there is little interest in changing the status quo with regards to the promises that IF EXISTS makes. And even with my less constrained views I find that doing anyth

Re: Privilege required for IF EXISTS event if the object already exists

2021-12-16 Thread David G. Johnston
On Thu, Dec 16, 2021 at 3:38 AM Shay Rojansky wrote: > >> Now, before creating tables, the ORM generates CREATE SCHEMA IF NOT > EXISTS, to ensure that the schema exists before CREATE TABLE; that's > reasonable general-purpose behavior. > > > > If the user hasn’t specified they want the schema cre

Re: Privilege required for IF EXISTS event if the object already exists

2021-12-16 Thread Shay Rojansky
>> Now, before creating tables, the ORM generates CREATE SCHEMA IF NOT EXISTS, to ensure that the schema exists before CREATE TABLE; that's reasonable general-purpose behavior. > > If the user hasn’t specified they want the schema created it’s arguable that executing create schema anyway is reasona

Re: Privilege required for IF EXISTS event if the object already exists

2021-12-15 Thread David G. Johnston
On Wednesday, December 15, 2021, Shay Rojansky wrote: > > . Now, before creating tables, the ORM generates CREATE SCHEMA IF NOT > EXISTS, to ensure that the schema exists before CREATE TABLE; that's > reasonable general-purpose behavior. > If the user hasn’t specified they want the schema created

Re: Privilege required for IF EXISTS event if the object already exists

2021-12-15 Thread Shay Rojansky
> I would say it is reasonable in theory. But I cannot think of an actual scenario that would benefit from such a change. Your stated use case is rejected since you explicitly do not want tenants to be able to create schemas - so the simple act of issuing "CREATE SCHEMA" is disallowed. > [...] >

Re: Privilege required for IF EXISTS event if the object already exists

2021-12-15 Thread Chapman Flack
On 12/15/21 11:10, David G. Johnston wrote: >> IF NOT EXISTS(SELECT 1 FROM pg_namespace WHERE nspname = 'foo') THEN Orthogonally to any other comments, IF pg_catalog.to_regnamespace('foo') IS NULL THEN might be tidier, if you don't need to support PG < 9.5. Regards, -Chap

Re: Privilege required for IF EXISTS event if the object already exists

2021-12-15 Thread David G. Johnston
On Wed, Dec 15, 2021 at 5:35 AM Shay Rojansky wrote: > Hi all, > > I've received numerous complaints about CREATE SCHEMA IF NOT EXISTS > failing when the user lacks CREATE privileges on the database - even if the > schema already exists. A typical scenario would be a multi-tenant > schema-per-ten

Re: Privilege required for IF EXISTS event if the object already exists

2021-12-15 Thread Tom Lane
Shay Rojansky writes: > I've received numerous complaints about CREATE SCHEMA IF NOT EXISTS failing > when the user lacks CREATE privileges on the database - even if the schema > already exists. A typical scenario would be a multi-tenant > schema-per-tenant setup, where the schema and tenant user

Privilege required for IF EXISTS event if the object already exists

2021-12-15 Thread Shay Rojansky
Hi all, I've received numerous complaints about CREATE SCHEMA IF NOT EXISTS failing when the user lacks CREATE privileges on the database - even if the schema already exists. A typical scenario would be a multi-tenant schema-per-tenant setup, where the schema and tenant user are created beforehand