From: zardozwildman@hotmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #7791: create database with owner, owner does not get usage on schema
Date: Sun, 06 Jan 2013 06:14:04 +0000
Message-ID: <E1TrjUi-0007ep-BQ@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 7791
Logged by: Brice Breeden
Email address: zardozwildman@hotmail.com
PostgreSQL version: 9.1.7
Operating system: windows x64
Description:
This database creation script was executed via the postgres superuser.
Executes create database and the "with owner" clause.
Create database assigns ownership to a role (myta_admin_role). This is not a
login role.
After database creation, script creates a schema. I later discovered that
the role never gets usage permission on the schema. Even though it is the
database owner.
My workaround was to remove the "with owner" clause. And explicitly set
schema permissions on the role.
I am providing a portion of the script for reference.
do
$$
begin
if (not exists (select * from information_schema.enabled_roles where
lower(role_name)=lower('myta_admin_role'))) then
create role myta_admin_role superuser createdb createrole replication;
end if;
end;
$$;
do
$$
begin
if (not exists (select * from information_schema.enabled_roles where
lower(role_name)=lower('myta_svc_role'))) then
create role myta_svc_role;
end if;
end;
$$;
-- Database creation can't be made conditional in postgres.
-- NOTE: Declaring one of our roles as owner doesn't seem to work.
-- Postgres doesn't give myta_admin_role usage rights on the myta schema.
-- Even though it's declared as the owner.
-- So we'll let ownership default to the superuser. And grant
-- the rights ourselves.
create database mytadb
with owner=myta_admin_role
encoding='UTF8'
tablespace=pg_default
LC_COLLATE='English_United States.1252'
LC_CTYPE='English_United States.1252'
CONNECTION LIMIT = -1;
\connect mytadb
do
$$
begin
if (not exists (select * from pg_namespace where nspname='myta')) then
create schema myta;
end if;
end;
$$;
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: zardozwildman@hotmail.com
Subject: Re: BUG #7791: create database with owner, owner does not get usage on schema
In-Reply-To: <E1TrjUi-0007ep-BQ@wrigleys.postgresql.org>
References: <E1TrjUi-0007ep-BQ@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox