Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C8B7A9FBA29 for ; Wed, 18 Jul 2007 12:09:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 97386-10 for ; Wed, 18 Jul 2007 12:09:17 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from kuber.nabble.com (kuber.nabble.com [216.139.236.158]) by postgresql.org (Postfix) with ESMTP id CE4359FBD2F for ; Wed, 18 Jul 2007 12:09:13 -0300 (ADT) Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1IBB9M-0006VO-5B for pgsql-admin@postgresql.org; Wed, 18 Jul 2007 08:09:12 -0700 Message-ID: <11670425.post@talk.nabble.com> Date: Wed, 18 Jul 2007 08:09:12 -0700 (PDT) From: km4hr To: pgsql-admin@postgresql.org Subject: Re: What user privileges do I need to CREATE FUNCTION's? In-Reply-To: <11670119.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: km4hr@netscape.net References: <11656315.post@talk.nabble.com> <11670119.post@talk.nabble.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.315 tagged_above=0 required=5 tests=AWL=1.315, BAYES_50=0.001 X-Spam-Level: * X-Archive-Number: 200707/207 X-Sequence-Number: 26188 Please disregard my last post about creating a schema. I found the answer. You have to be connected to a database to create a schema in that database. km4hr wrote: >=20 > Thanks Milen. Assigning superuser role worked.=20 >=20 > Speaking of schema's, I logged in as user "postgres" and created a schema > called "schema1" as follows: > CREATE SCHEMA schema1 AUTHORIZATION newuser; >=20 > I then typed "\dn" and saw "schema1" in the list. >=20 > I then logged in as "newuser" and typed "\dn". "schema1" was not in the > list! Why not? > I then created a table. Next I entered: "select * from schema1.newtable". > An error message > indicated that "schema1" doesn't exist. How do I make "newuser" aware of > his new schema? >=20 > thanks >=20 > =20 >=20 > Milen A. Radev-2 wrote: >>=20 >> km4hr =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0: >>> I'm installing an application that provides a ".sql" script to create >>> tables >>> and other objects in a postgresql database. When I run the script as >>> user >>> "postgres" the script executes without errors. But then all the tables >>> and >>> other objects are owned by "postgres". A user that I created to access >>> the >>> tables, "newuser", doesn't have privileges needed to use them.=20 >>>=20 >>> If I login as "newuser" and execute the install script, I get errors >>> indicating "newuser" doesn't have privileges to CREATE FUNCTION's .=20 >>>=20 >>> How should I execute the install script so that all the objects are >>> owned by >>> "newuser" and the FUNCTIONS are created? >>=20 >> You need to create all DB objects with one preferably administrative >> role and then GRANT only some privileges to other, everyday roles. >> Something like (assuming those are run as a administrator): >>=20 >> CREATE TABLE example_table ( >> id integer PRIMARY KEY, >> ... >> ); >>=20 >> REVOKE ALL PRIVILEGES ON TABLE example_table FROM PUBLIC; >> GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE example_table TO newuser; >>=20 >> REVOKE ALL PRIVILEGES ON SEQUENCE example_table_id_seq FROM PUBLIC; >> GRANT USAGE ON SEQUENCE example_table_id_seq TO newuser; >>=20 >>=20 >> CREATE FUNCTION example_func(...) RETURNS ... AS $$ >> ... >> $$ LANGUAGE SQL; >>=20 >> REVOKE ALL PRIVILEGES ON FUNCTION example_func FROM PUBLIC; >> GRANT EXECUTE ON FUNCTION example_func TO newuser; >>=20 >>=20 >>=20 >> Or you could change the owner of the newly created DB object: >>=20 >> ALTER TABLE example_table OWNER TO newuser; >> ALTER FUNCTION example_func(...) OWNER TO newuser; >>=20 >>=20 >> This way the new owner has all the privileges on that object. Of >> course I prefer the first method of dealing with the needed privileges. >>=20 >>=20 >>> What privileges does "newuser" need to create functions? I can't find >>> that >>> described in the postgres manual? >>=20 >> I suppose the role should be the owner of the schema or a superuser. >>=20 >>=20 >> --=20 >> Milen A. Radev >>=20 >>=20 >> ---------------------------(end of broadcast)--------------------------- >> TIP 5: don't forget to increase your free space map settings >>=20 >>=20 >=20 >=20 --=20 View this message in context: http://www.nabble.com/What-user-privileges-do= -I-need-to-CREATE-FUNCTION%27s--tf4099063.html#a11670425 Sent from the PostgreSQL - admin mailing list archive at Nabble.com.