Error messages on duplicate schema names

Started by Andrusover 5 years ago4 messagesgeneral
Jump to latest
#1Andrus
kobruleht2@hot.ee

Hi!

ALTER DEFAULT PRIVILEGES IN SCHEMA public,public   GRANT all ON TABLES
TO testoig;

Throws strange error

Tuple already updated by self

In other case which I posted duplicate schema causes another strange error

duplicate key value violates unique constraint
"pg_default_acl_role_nsp_obj_index"DETAIL: Key (defaclrole,
defaclnamespace, defaclobjtype)=(30152, 186783649, r) already exists.

Should duplicate schema names accepted or should their usage throw
better error messages.

Andrus.

#2Michael Paquier
michael@paquier.xyz
In reply to: Andrus (#1)
Re: Error messages on duplicate schema names

On Wed, Jan 06, 2021 at 07:15:24PM +0200, Andrus wrote:

Should duplicate schema names accepted or should their usage throw better
error messages.

This means that we are one call of CommandCounterIncrement() short for
such queries, and similar safeguards already exist in this area for
GRANT/REVOKE. The spot where I would put this new CCI is at the end
of SetDefaultACL(), like in the attached with a test added to
privileges.sql.

Any thoughts from others?
--
Michael

Attachments:

alter-default-duplicate.patchtext/x-diff; charset=us-asciiDownload+7-2
#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Michael Paquier (#2)
Re: Error messages on duplicate schema names

On 2021-Jan-15, Michael Paquier wrote:

On Wed, Jan 06, 2021 at 07:15:24PM +0200, Andrus wrote:

Should duplicate schema names accepted or should their usage throw better
error messages.

This means that we are one call of CommandCounterIncrement() short for
such queries, and similar safeguards already exist in this area for
GRANT/REVOKE. The spot where I would put this new CCI is at the end
of SetDefaultACL(), like in the attached with a test added to
privileges.sql.

Any thoughts from others?

Looks to match what we do in ExecGrant_Relation() et al, so +1.

I guess you could make the case that the CCI call should be in the
callers where we actually loop (SetDefaultACLsInSchemas,
RemoveRoleFromObjectACL), but it's hard to get excited about the added
clutter.

--
�lvaro Herrera Valdivia, Chile

#4Michael Paquier
michael@paquier.xyz
In reply to: Alvaro Herrera (#3)
Re: Error messages on duplicate schema names

On Tue, Jan 19, 2021 at 05:37:51PM -0300, Alvaro Herrera wrote:

I guess you could make the case that the CCI call should be in the
callers where we actually loop (SetDefaultACLsInSchemas,
RemoveRoleFromObjectACL), but it's hard to get excited about the added
clutter.

Yeah, that matches my thoughts. And I did not see any harm in putting
the CCI in SetDefaultACL() even for the case of pg_default_acl with
DROP OWNED BY. So applied and backpatched. Thanks, Alvaro and
Andrus.
--
Michael