Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Andrus
The example script works for me. What PG version are you running? I have a vague recollection that we've fixed bugs-of-omission in DROP OWNED in the past. I'm using "PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled by gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 64-bit" In "PostgreSQL

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Tom Lane
"Andrus" writes: >> The example script works for me. What PG version are you running? I have >> a vague recollection that we've fixed bugs-of-omission in DROP OWNED in >> the past. > I'm using > "PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled by gcc-4.4.real >

Ynt: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Neslisah Demirci
; Is this helpful? Neslisah. Gönderen: pgsql-general-ow...@postgresql.org <pgsql-general-ow...@postgresql.org> adına Andrus <kobrule...@hot.ee> Gönderildi: 07 Ekim 2015 Çarşamba 13:42 Kime: pgsql-general Konu: [GENERAL] How to drop user if objects depe

[GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Andrus
Hi! Database idd owner is role idd_owner Database has 2 data schemas: public and firma1. User may have directly or indirectly assigned rights in this database and objects. User is not owner of any object. It has only rights assigned to objects. How to drop such user ? I tried revoke

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Thom Brown
On 7 October 2015 at 11:42, Andrus wrote: > Hi! > > Database idd owner is role idd_owner > Database has 2 data schemas: public and firma1. > User may have directly or indirectly assigned rights in this database and > objects. > User is not owner of any object. It has only

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Melvin Davidson
Can you connect as user postgres? IE: psql -U postgres -d If so, then you should have the ability to execute the commands without any problem. On Wed, Oct 7, 2015 at 9:53 AM, Adrian Klaver wrote: > On 10/07/2015 05:12 AM, Andrus wrote: > >> Hi! >> >> The objects

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Andrus
Hi! The objects can't be owned by nothing, so you will need to reassign ownership: REASSIGN OWNED BY old_role TO new_role; e.g. REASSIGN OWNED BY vantaa TO postgres; Then you can drop the role. User who deletes other users is not superuser. It is created using CREATE ROLE admin LOGIN

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Adrian Klaver
On 10/07/2015 05:12 AM, Andrus wrote: Hi! The objects can't be owned by nothing, so you will need to reassign ownership: REASSIGN OWNED BY old_role TO new_role; e.g. REASSIGN OWNED BY vantaa TO postgres; Then you can drop the role. User who deletes other users is not superuser. It is created

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Andrus
Hi! No. You need to be a superuser to reassign objects unless you own the object. 1. first connect as user postgres 2. REASSIGN all the tables owned by the missing user first. 3. Then you can drop the missing user AFTER you have reassigned all the objects they own. Script reassign owned by

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Andrus
Hi! I tried So to be clear admin is doing the below, correct? Yes. I copied provided user definition which invokes delete command from pgadmin code window for this user . permission denied to reassign objects . Is the above a blanket error or does it mention specific objects? postgres

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Melvin Davidson
No. You need to be a superuser to reassign objects unless you own the object. You must also be a superuser to drop roles. So. 1. first connect as user postgres 2. REASSIGN all the tables owned by the missing user first. 3. Then you can drop the missing user AFTER you have reassigned all the

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Tom Lane
"Andrus" writes: > ALTER DEFAULT PRIVILEGES IN SCHEMA public,firma1 GRANT all ON TABLES TO > vantaa; I am not sure that REASSIGN OWNED will get rid of default-privilege specifiers --- you might have to reverse this step separately. In general, REASSIGN OWNED has to be done

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Andrus
Hi! Can you connect as user postgres? IE: psql -U postgres -d Applicaton has admin users which should be able to delete other users. Those users dont have superuser rights. I can connect as user postgres for testing only. I'm looking for a way to delete users without superuser right. If

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Melvin Davidson
Andrus, >is running by superuser but it still causes the error. That does not sound right. Please verify you are running as user postgres with: SELECT current_user; Then make sure postgres is still a superuser with: SELECT rolname as user, CASE WHEN rolcanlogin THEN 'user'

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Tom Lane
"Andrus" writes: >> A little further review shows that DROP OWNED is the way to get rid of >> leftover privileges. So in general you need to do REASSIGN OWNED to move >> the ownership of objects, then DROP OWNED to get rid of privileges granted >> on non-owned objects, before

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Andrus
A little further review shows that DROP OWNED is the way to get rid of leftover privileges. So in general you need to do REASSIGN OWNED to move the ownership of objects, then DROP OWNED to get rid of privileges granted on non-owned objects, before you can drop a role. I tried this in database

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Tom Lane
I wrote: > "Andrus" writes: >> ALTER DEFAULT PRIVILEGES IN SCHEMA public,firma1 GRANT all ON TABLES TO >> vantaa; > I am not sure that REASSIGN OWNED will get rid of default-privilege > specifiers --- you might have to reverse this step separately. A little further review

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Andrus
ALTER DEFAULT PRIVILEGES IN SCHEMA public,firma1 GRANT all ON TABLES TO vantaa; I am not sure that REASSIGN OWNED will get rid of default-privilege specifiers --- you might have to reverse this step separately. In general, REASSIGN OWNED has to be done by a role that has privileges of (is a

Re: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Adrian Klaver
On 10/07/2015 09:50 AM, Andrus wrote: ALTER DEFAULT PRIVILEGES IN SCHEMA public,firma1 GRANT all ON TABLES TO vantaa; I am not sure that REASSIGN OWNED will get rid of default-privilege specifiers --- you might have to reverse this step separately. In general, REASSIGN OWNED has to be done by

Re: Ynt: [GENERAL] How to drop user if objects depend on it

2015-10-07 Thread Jerry Sievers
rg> ad?na Andrus <kobrule...@hot.ee> > G?nderildi: 07 Ekim 2015 ?ar?amba 13:42 > Kime: pgsql-general > Konu: [GENERAL] How to drop user if objects depend on it > > Hi! > > Database idd owner is role idd_owner > Database has 2 data schemas: public and firma1.