Re: TODO item: Allow more complex user/database default GUC settings

Lists: pgsql-hackers
From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: TODO item: Allow more complex user/database default GUC settings
Date: 2009-08-11 22:19:21
Message-ID: 20090811221921.GK16362@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

There's a longstanding TODO item, in subject. Previous discussion was
here:

http://archives.postgresql.org/pgsql-hackers/2006-09/msg02341.php

In looking what it would take to implement it, I find that it is
trivial. The only part that looks complex is the UI for it. Is anyone
interested in giving this patch a shot?

Implementation-side, it requires a new catalog (pg_settings), with the
following columns:

setdatabase oid
setrole oid
setconfig text[]

datconfig and rolconfig are removed.

ALTER DATABASE / SET sets setdatabase to the OID of the database in
command, and setrole to 0 (InvalidOid); ALTER ROLE / SET sets setrole
and leaves setdatabase 0.

A new command allows one to set a config that applies to both database
and role.

At startup, the settings are applied in the following order:
database=value role=0
database=0 role=value
database=value role=value

This way, current behavior is maintained (ALTER ROLE trumps ALTER
DATABASE).

The only real work in this is figuring out what the grammar for the new
command looks like. Maybe we could have some like

ALTER ROLE foo ALTER DATABASE bar SET config

There are of course many possible variations but this looks the most
reasonable one. Any better ideas?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-08-26 02:17:38
Message-ID: 20090826021738.GR12604@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:

> Implementation-side, it requires a new catalog (pg_settings), with the
> following columns:

So, I've come up with the attached patch. It does not have the new
command yet, so you can do ALTER USER and ALTER DATABASE and it works,
but there's no way to set user-and-database-specific settings, short of
INSERT into the catalog. Apart from that it works nicely.

I'm just posting in case somebody has thoughts on the UI part of it.

Other things that need fixed:

- need to figure out locking for roles; this stuff must be synchronized
with role drop
- pg_shadow and pg_roles need a join to obtain settings
- two regression tests need their expected file updated
- catalog version bump

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment Content-Type Size
setting.patch text/x-diff 41.2 KB

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-18 20:03:27
Message-ID: D3841E5AEEF5930860A00358@amenophis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 25. August 2009 22:17:38 -0400 Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:

> I'm just posting in case somebody has thoughts on the UI part of it.
>
> Other things that need fixed:
>
> - need to figure out locking for roles; this stuff must be synchronized
> with role drop
> - pg_shadow and pg_roles need a join to obtain settings
> - two regression tests need their expected file updated
> - catalog version bump

Here's a first shot on this for my current review round. Patch needed to
re-merged into current CVS HEAD due to some merge conflicts, i've also
adjusted the regression tests (minor). On a first look, i like the patch
(especially the code for the utility commands accessing the settings is
better modularized now, which looks much nicer).

--
Thanks

Bernd

Attachment Content-Type Size
complex_guc_review_v1.patch application/octet-stream 32.3 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-21 02:56:53
Message-ID: 603c8f070909201956g2a66a829kf088c1d7226aa289@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Sep 18, 2009 at 4:03 PM, Bernd Helmle <mailings(at)oopsware(dot)de> wrote:
>
>
> --On 25. August 2009 22:17:38 -0400 Alvaro Herrera
> <alvherre(at)commandprompt(dot)com> wrote:
>
>> I'm just posting in case somebody has thoughts on the UI part of it.
>>
>> Other things that need fixed:
>>
>> - need to figure out locking for roles; this stuff must be synchronized
>>  with role drop
>> - pg_shadow and pg_roles need a join to obtain settings
>> - two regression tests need their expected file updated
>> - catalog version bump
>
> Here's a first shot on this for my current review round. Patch needed to
> re-merged into current CVS HEAD due to some merge conflicts, i've also
> adjusted the regression tests (minor). On a first look, i like the patch
> (especially the code for the utility commands accessing the settings is
> better modularized now, which looks much nicer).

So is this ready to commit, or what?

...Robert


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-21 04:21:43
Message-ID: 20090921042143.GL13076@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas escribió:

> > Here's a first shot on this for my current review round. Patch needed to
> > re-merged into current CVS HEAD due to some merge conflicts, i've also
> > adjusted the regression tests (minor). On a first look, i like the patch
> > (especially the code for the utility commands accessing the settings is
> > better modularized now, which looks much nicer).
>
> So is this ready to commit, or what?

Not really :-( It needs some minor tweaks to qualify as a cleanup
patch, and further extra coding for there to be an actual new feature.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-21 11:42:21
Message-ID: F608FE9232C9EBB3E6D6599C@amenophis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 20. September 2009 22:56:53 -0400 Robert Haas <robertmhaas(at)gmail(dot)com>
wrote:

> So is this ready to commit, or what?

Not yet, see the comments Alvaro did upthread. Please note that i'm still
reviewing this one and i hope to post results tomorrow (there wasn't plenty
of free time over the weekend, i'm sorry).

--
Thanks

Bernd


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-21 15:08:05
Message-ID: 603c8f070909210808n5c4f418clcf7ce3be9ae2fda3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Sep 21, 2009 at 12:21 AM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Robert Haas escribió:
>
>> > Here's a first shot on this for my current review round. Patch needed to
>> > re-merged into current CVS HEAD due to some merge conflicts, i've also
>> > adjusted the regression tests (minor). On a first look, i like the patch
>> > (especially the code for the utility commands accessing the settings is
>> > better modularized now, which looks much nicer).
>>
>> So is this ready to commit, or what?
>
> Not really :-(  It needs some minor tweaks to qualify as a cleanup
> patch, and further extra coding for there to be an actual new feature.

So here's the followup question - do you intend to do one of those
things for this CommitFest, or should we mark this as Returned with
Feedback once Bernd posts the rest of his review?

...Robert


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-21 16:23:44
Message-ID: 20090921162344.GG29793@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas escribió:

> So here's the followup question - do you intend to do one of those
> things for this CommitFest, or should we mark this as Returned with
> Feedback once Bernd posts the rest of his review?

What feedback is it supposed to be returned with? Precisely what I
wanted is some feedback on the general idea. Brendan's "I like the
approach" is good, but is it enough to deter a later veto from someone
else?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-21 16:24:59
Message-ID: 20090921162459.GH29793@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera escribió:

> What feedback is it supposed to be returned with? Precisely what I
> wanted is some feedback on the general idea. Brendan's "I like the
> approach" is good, but is it enough to deter a later veto from someone
> else?

s/Brendan/Bernd/

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-21 22:46:53
Message-ID: A4B6B958EC4E1CBEAF5AD22B@amenophis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 21. September 2009 13:42:21 +0200 Bernd Helmle <mailings(at)oopsware(dot)de>
wrote:

>
>
> --On 20. September 2009 22:56:53 -0400 Robert Haas
> <robertmhaas(at)gmail(dot)com> wrote:
>
>> So is this ready to commit, or what?
>
> Not yet, see the comments Alvaro did upthread. Please note that i'm still
> reviewing this one and i hope to post results tomorrow (there wasn't
> plenty of free time over the weekend, i'm sorry).
>

Here some further comments on the current patch:

- I'm not sure i like the name of the new system catalog pg_setting. Wie
already have pg_settings, i think this can be confusing. Maybe we need a
different name, e.g. pg_user_setting? This seems along the line with the
other *user* system objects (e.g. pg_stat_user_tables), where only "user
specific" objects are displayed.

- I have thought a little bit about the changes in the system views.
pg_roles and pg_shadow (as Alvaro already mentioned), need to be adjusted
(joined to the new catalog), to display rolconfig/useconfig. However, it's
unclear *how* to expose those information, for example, do we want to
expose roleconfig specific for the current database or for all databases
the role has a specific config for ?

- The code mentions the lack of lock synchronization. Maybe i'm missing
something obvious (its late here), but is there a reason this can't be done
by obtaining a lock on pg_authid (not sure about the backend user
initialization phase though) ?

- Regarding the missing UI: i go with Alvaro's proposal:

ALTER ROLE <rolename> [ALTER] DATABASE <dbname> SET <config> TO <value>;

Maybe we can make the 2nd ALTER optional.

Thoughts?

--
Thanks

Bernd


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-21 23:44:52
Message-ID: 603c8f070909211644p49b64e28m5f6ec3612f2b2ad3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Sep 21, 2009 at 12:23 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Robert Haas escribió:
>
>> So here's the followup question - do you intend to do one of those
>> things for this CommitFest, or should we mark this as Returned with
>> Feedback once Bernd posts the rest of his review?
>
> What feedback is it supposed to be returned with?  Precisely what I
> wanted is some feedback on the general idea.  Brendan's "I like the
> approach" is good, but is it enough to deter a later veto from someone
> else?

Well, you've hit there on one of the things that we don't always do
well. Many a patch author has posted an idea, received no feedback,
proceeded to implementation, and then the knives come out. On a good
day, the CommitFest process ensures that every patch gets a second
opinion, but it doesn't guarantee that a third opinion won't come
crawling out of the woodwork at a later date. In this respect, you're
actually operating at a slight advantage relative to most of us,
because you can post your revised patch and commit it if no one
objects too strongly, whereas I (for example) have to convince one of
about two people - Tom or Peter, for nearly anything I'm likely to
develop - to take an affirmative action on my behalf.

This whole phenomenon of proposals to which no objection was made at
the outset later getting flak for one reason or another is, I think, a
source of much frustration and discourages people from putting effort
into projects they might otherwise be willing to undertake. But I
haven't the least idea how to fix it, and I can't offer you any
guarantees with respect to the present situation either.

...Robert


From: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-22 03:31:14
Message-ID: 65937bea0909212031l88be1f3wfee4496d2ee892ed@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Sep 22, 2009 at 4:16 AM, Bernd Helmle <mailings(at)oopsware(dot)de> wrote:

>
>
> --On 21. September 2009 13:42:21 +0200 Bernd Helmle <mailings(at)oopsware(dot)de>
> wrote:
>
>
>>
>> --On 20. September 2009 22:56:53 -0400 Robert Haas
>> <robertmhaas(at)gmail(dot)com> wrote:
>>
>> So is this ready to commit, or what?
>>>
>>
>> Not yet, see the comments Alvaro did upthread. Please note that i'm still
>> reviewing this one and i hope to post results tomorrow (there wasn't
>> plenty of free time over the weekend, i'm sorry).
>>
>>
> Here some further comments on the current patch:
>
> - I'm not sure i like the name of the new system catalog pg_setting. Wie
> already have pg_settings, i think this can be confusing. Maybe we need a
> different name, e.g. pg_user_setting? This seems along the line with the
> other *user* system objects (e.g. pg_stat_user_tables), where only "user
> specific" objects are displayed.
>
> - I have thought a little bit about the changes in the system views.
> pg_roles and pg_shadow (as Alvaro already mentioned), need to be adjusted
> (joined to the new catalog), to display rolconfig/useconfig. However, it's
> unclear *how* to expose those information, for example, do we want to expose
> roleconfig specific for the current database or for all databases the role
> has a specific config for ?
>
> - The code mentions the lack of lock synchronization. Maybe i'm missing
> something obvious (its late here), but is there a reason this can't be done
> by obtaining a lock on pg_authid (not sure about the backend user
> initialization phase though) ?
>
> - Regarding the missing UI: i go with Alvaro's proposal:
>
> ALTER ROLE <rolename> [ALTER] DATABASE <dbname> SET <config> TO <value>;
>
> Maybe we can make the 2nd ALTER optional.
>
> Thoughts?

ON instead of second ALTER looks better, and IMHO DATABASE <dbname> should
be optional too:

ALTER ROLE <rolename> [ON DATABASE <dbname>] SET <config> TO <value>;

Best regards,
--
Lets call it Postgres

EnterpriseDB http://www.enterprisedb.com

gurjeet[(dot)singh](at)EnterpriseDB(dot)com

singh(dot)gurjeet(at){ gmail | hotmail | indiatimes | yahoo }.com
Twitter: singh_gurjeet
Skype: singh_gurjeet

Mail sent from my BlackLaptop device


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-22 04:07:40
Message-ID: 1677.1253592460@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> writes:
> ON instead of second ALTER looks better, and IMHO DATABASE <dbname> should
> be optional too:

> ALTER ROLE <rolename> [ON DATABASE <dbname>] SET <config> TO <value>;

IN, not ON.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-23 18:10:39
Message-ID: 5046.1253729439@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Robert Haas escribi:
>> So here's the followup question - do you intend to do one of those
>> things for this CommitFest, or should we mark this as Returned with
>> Feedback once Bernd posts the rest of his review?

> What feedback is it supposed to be returned with? Precisely what I
> wanted is some feedback on the general idea. Brendan's "I like the
> approach" is good, but is it enough to deter a later veto from someone
> else?

FWIW, I looked the patch over quickly, and I think it will be fine once
Bernd's comments are addressed. In particular I agree with the
objection to the name "pg_setting" as being confusingly close to
"pg_settings". But "pg_user_setting" isn't better. Maybe
"pg_db_role_settings"?

As far as the lock issue goes, I don't see any reason why the catalog
change creates a reason for new/different locking than we had before.
Any attempt to make concurrent updates to the same row will generate an
error, and that seems enough to me ...

regards, tom lane


From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-23 19:03:27
Message-ID: 6063DBF0F78466053435E217@amenophis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 23. September 2009 14:10:39 -0400 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> FWIW, I looked the patch over quickly, and I think it will be fine once
> Bernd's comments are addressed. In particular I agree with the
> objection to the name "pg_setting" as being confusingly close to
> "pg_settings". But "pg_user_setting" isn't better. Maybe
> "pg_db_role_settings"?

Jepp, that's better, +1 from me.

I'm done with this, too, so i will mark this as "Returned with Feedback",
if no one objects?

--
Thanks

Bernd


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-23 19:27:03
Message-ID: 603c8f070909231227n18a8719fvc3c08a03382fa1ea@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Sep 23, 2009 at 3:03 PM, Bernd Helmle <mailings(at)oopsware(dot)de> wrote:
>
>
> --On 23. September 2009 14:10:39 -0400 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> FWIW, I looked the patch over quickly, and I think it will be fine once
>> Bernd's comments are addressed.  In particular I agree with the
>> objection to the name "pg_setting" as being confusingly close to
>> "pg_settings".  But "pg_user_setting" isn't better.  Maybe
>> "pg_db_role_settings"?
>
> Jepp, that's better, +1 from me.
>
> I'm done with this, too, so i will mark this as "Returned with Feedback", if
> no one objects?

It can be marked "Waiting on Author" if it's going to be reworked in
the next few days. If no plans to rework, or if the rework doesn't
materialize, then "Returned with Feedback".

...Robert


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-24 21:00:52
Message-ID: 20090924210052.GI3914@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane escribió:
> Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> writes:
> > ON instead of second ALTER looks better, and IMHO DATABASE <dbname> should
> > be optional too:
>
> > ALTER ROLE <rolename> [ON DATABASE <dbname>] SET <config> TO <value>;
>
> IN, not ON.

This creates a parser conflict with
CREATE ROLE foo IN ROLE bar

I think it can be solved by splitting OptRoleElem in a set of
productions for ALTER and a superset of that for ALTER. I'll go try
that.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-26 00:05:25
Message-ID: 20090926000525.GX3914@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera escribió:

> I think it can be solved by splitting OptRoleElem in a set of
> productions for ALTER and a superset of that for ALTER. I'll go try
> that.

Right, that works. Updated patch attached; should solve the issues
raised in the thread. I renamed the catalog pg_db_role_setting as
suggested by Tom.

I have updated the pg_user and pg_roles definitions so that they include
the settings for the role, but only those that are not specific to any
database.

I have also added a view, whose only purpose is to convert the role and
database OIDs into names. It's been named pg_db_role_settings, but if
anyone has a better suggestion I'm all ears.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment Content-Type Size
settings-3.patch text/x-diff 56.0 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-26 15:59:07
Message-ID: 21863.1253980747@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Right, that works. Updated patch attached; should solve the issues
> raised in the thread. I renamed the catalog pg_db_role_setting as
> suggested by Tom.
> ...
> I have also added a view, whose only purpose is to convert the role and
> database OIDs into names. It's been named pg_db_role_settings, but if
> anyone has a better suggestion I'm all ears.

I dislike the idea of having a catalog and a view whose names are the
same except for a plural. It's confusing as heck, because no one will
remember which is which.

Since pg_settings is the existing user view, I think pg_db_role_settings
is a reasonable choice for the new view, but then we need a different
name for the catalog. The only thing that comes to mind right now is
"pg_db_role_default", but I don't like it much. Anybody have other
suggestions?

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-26 16:12:30
Message-ID: 0A4BA455-38B6-4510-9DF1-24CF597091D1@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sep 26, 2009, at 11:59 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
>> Right, that works. Updated patch attached; should solve the issues
>> raised in the thread. I renamed the catalog pg_db_role_setting as
>> suggested by Tom.
>> ...
>> I have also added a view, whose only purpose is to convert the role
>> and
>> database OIDs into names. It's been named pg_db_role_settings, but
>> if
>> anyone has a better suggestion I'm all ears.
>
> I dislike the idea of having a catalog and a view whose names are the
> same except for a plural. It's confusing as heck, because no one will
> remember which is which.
>
> Since pg_settings is the existing user view, I think
> pg_db_role_settings
> is a reasonable choice for the new view, but then we need a different
> name for the catalog. The only thing that comes to mind right now is
> "pg_db_role_default", but I don't like it much. Anybody have other
> suggestions?

The problem of having both a table and a closely related view is, IME,
one that comes up a lot. I think you just need to pick a convention
and stick with it. Mine is to append "_view" to the table name.

Renaming the underlying table doesn't seem like it helps at all.

...Robert


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-27 03:44:02
Message-ID: 20090927034402.GD5944@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas escribió:

> The problem of having both a table and a closely related view is,
> IME, one that comes up a lot. I think you just need to pick a
> convention and stick with it. Mine is to append "_view" to the
> table name.

That would make the difference clear, but since what the user normally
wants to see is the view, it seems a poor solution to make the view the
more difficult one to type (and the one that isn't tab-completed first
in psql). I'd go with naming the view pg_db_role_setting and append
"_internal" to the catalog or something similar, except that we don't
have any catalog with such a bad name yet and I don't want to start.

Maybe name the table pg_configuration?

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-28 01:58:46
Message-ID: 603c8f070909271858w5aabad20jd0959dbee01f91f0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Sep 26, 2009 at 11:44 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Robert Haas escribió:
>
>> The problem of having both a table and a closely related view is,
>> IME, one that comes up a lot. I think you just need to pick a
>> convention and stick with it.  Mine is to append "_view" to the
>> table name.
>
> That would make the difference clear, but since what the user normally
> wants to see is the view, it seems a poor solution to make the view the
> more difficult one to type (and the one that isn't tab-completed first
> in psql).  I'd go with naming the view pg_db_role_setting and append
> "_internal" to the catalog or something similar, except that we don't
> have any catalog with such a bad name yet and I don't want to start.
>
> Maybe name the table pg_configuration?

That seems to me to be just confusing the issue. Now the table name
and the view name are just totally different with no obvious
connection between them. We have enough nonsense of this type already
(e.g. pg_stats vs. pg_statistic; pg_authid vs. pg_roles vs.
pg_shadow). I think we need to settle on a system for handling
problems of this type and document it in the fine manual or perhaps a
README somewhere, and stick with it. Inventing random unconnected
names is just craziness.

Now, if you/others don't like my _view convention; that's fine. Just
pick something else. Really, I don't believe the tab-completion thing
is much of a problem, you just type underscore-tab and you're there.
But I am 100% OK with whatever we pick, as long as it is something
easy to remember that we have a chance of being able to apply
consistently.

...Robert


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-28 01:59:37
Message-ID: 603c8f070909271859p70e9fb1ao9b326c9360cbd76a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Sep 25, 2009 at 8:05 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Alvaro Herrera escribió:
>
>> I think it can be solved by splitting OptRoleElem in a set of
>> productions for ALTER and a superset of that for ALTER.  I'll go try
>> that.
>
> Right, that works.  Updated patch attached; should solve the issues
> raised in the thread.  I renamed the catalog pg_db_role_setting as
> suggested by Tom.
>
> I have updated the pg_user and pg_roles definitions so that they include
> the settings for the role, but only those that are not specific to any
> database.
>
> I have also added a view, whose only purpose is to convert the role and
> database OIDs into names.  It's been named pg_db_role_settings, but if
> anyone has a better suggestion I'm all ears.

Bernd,

Can you review this new version and mark this as Ready for Committer
if it looks OK, or else respond with comments and set it back to
Waiting on Author?

Thanks,

...Robert


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-28 02:19:42
Message-ID: 12692.1254104382@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> That seems to me to be just confusing the issue. Now the table name
> and the view name are just totally different with no obvious
> connection between them. We have enough nonsense of this type already
> (e.g. pg_stats vs. pg_statistic; pg_authid vs. pg_roles vs.
> pg_shadow). I think we need to settle on a system for handling
> problems of this type and document it in the fine manual or perhaps a
> README somewhere, and stick with it. Inventing random unconnected
> names is just craziness.

Actually, to the extent that we have any convention at all, it's
to use plurals for system view names (pg_tables, pg_views, etc)
and singular for underlying catalogs (pg_index). The only exception
to this on the catalog side is pg_auth_members, which is arguably
misnamed. (pg_inherits is sort of an exception, but it's weird in a
different way: its name is a verb not a noun.) The apparent exceptions
on the view side (pg_group, pg_shadow, pg_user) are actually views that
are backward compatible substitutes for former catalogs, so they are not
really intentional exceptions.

Now it's also the case that we've tended to use tech-speak names
for catalogs (eg, pg_class, pg_namespace not pg_table, pg_schema)
and so that gives us an additional degree of separation between
those names and the more user-facing names chosen for views.

What we seem to be lacking in this case is a good tech-speak
option for the underlying catalog name. I'm still not happy
with having a catalog and a view that are exactly the same
except for "s", especially since as Alvaro notes that won't
lead to desirable tab-completion behavior. OTOH, we have
survived with pg_index vs pg_indexes, so maybe it wouldn't
kill us.

BTW, have we thought much about the simplest possible solution,
which is to not have the view? How badly do we need it? Seems
like dropping the functionality into a psql \d command might be
a viable alternative.

regards, tom lane


From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-28 22:33:03
Message-ID: 70D710A15F9A4E6E2CCFBF25@amenophis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 27. September 2009 21:59:37 -0400 Robert Haas <robertmhaas(at)gmail(dot)com>
wrote:

> Bernd,
>
> Can you review this new version and mark this as Ready for Committer
> if it looks OK, or else respond with comments and set it back to
> Waiting on Author?

Seems Alvaro forgot to include pg_db_role_setting.h, it doesn't compile
anymore with this error:

catalog.c:34:40: error: catalog/pg_db_role_setting.h: No such file or
directory
catalog.c: In function ‘IsSharedRelation’:
catalog.c:311: error: ‘DbRoleSettingRelationId’ undeclared (first use
in this function)

--
Thanks

Bernd


From: decibel <decibel(at)decibel(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-28 22:52:18
Message-ID: CC66F887-4067-4745-97B5-48F7E2B168AC@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sep 27, 2009, at 9:19 PM, Tom Lane wrote:
> What we seem to be lacking in this case is a good tech-speak
> option for the underlying catalog name. I'm still not happy
> with having a catalog and a view that are exactly the same
> except for "s", especially since as Alvaro notes that won't
> lead to desirable tab-completion behavior. OTOH, we have
> survived with pg_index vs pg_indexes, so maybe it wouldn't
> kill us.

Another option is to revisit the set of system views (http://
pgfoundry.org/projects/newsysviews/). IIRC there was some other
recent reason we wanted to do that.
--
Decibel!, aka Jim C. Nasby, Database Architect decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-28 22:57:17
Message-ID: 20090928225717.GG5269@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bernd Helmle escribió:

> Seems Alvaro forgot to include pg_db_role_setting.h, it doesn't
> compile anymore with this error:

Huh, you're right, I did :-( Let me unpack the laptop ...

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-28 23:02:34
Message-ID: 20090928230234.GZ3914@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bernd Helmle escribió:

> Seems Alvaro forgot to include pg_db_role_setting.h, it doesn't
> compile anymore with this error:

Here they are.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Attachment Content-Type Size
pg_db_role_setting.c text/x-csrc 6.1 KB
pg_db_role_setting.h text/x-chdr 1.9 KB

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-29 11:19:50
Message-ID: 7EFA00BE2E799EDB8D25252E@amenophis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 28. September 2009 19:02:34 -0400 Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:

>> Seems Alvaro forgot to include pg_db_role_setting.h, it doesn't
>> compile anymore with this error:
>
> Here they are.

I'll see if i can get to it tonight. I'm currently travelling, so it could
be delayed until Thursday.

--
Thanks

Bernd


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 14:34:29
Message-ID: 20090930143429.GB8280@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

And here's the last necessary bit, which is pg_dump support for all
this.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment Content-Type Size
setting-pgdump.patch text/x-diff 5.8 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 15:19:35
Message-ID: 15377.1254323975@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> And here's the last necessary bit, which is pg_dump support for all
> this.

> + /* Dump role/database settings */
> + if (!tablespaces_only)
> + {
> + if (server_version >= 80500)
> + dumpDbRoleConfig(conn);
> + }

Hmm ... I would kind of think that --roles-only should suppress this too.
Otherwise you're going to be dumping commands that might refer to
nonexistent databases.

regards, tom lane


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 15:50:25
Message-ID: 20090930155025.GD8280@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane escribió:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > And here's the last necessary bit, which is pg_dump support for all
> > this.
>
> > + /* Dump role/database settings */
> > + if (!tablespaces_only)
> > + {
> > + if (server_version >= 80500)
> > + dumpDbRoleConfig(conn);
> > + }
>
> Hmm ... I would kind of think that --roles-only should suppress this too.
> Otherwise you're going to be dumping commands that might refer to
> nonexistent databases.

Those double negatives are confusing as hell. I propose to add
something like this:

do_tablespaces = true;
do_databases = true;
do_roles = true;
if (globals_only)
do_databases = false;
if (tablespaces_only)
{
do_roles = false;
do_databases = false;
}
if (roles_only)
{
do_databases = false;
do_tablespaces = false;
}

Then we can have the new block this way:

/* Dump role/database settings */
if (do_databases && do_roles)
{
if (server_version >= 80500)
dumpDbRoleConfig(conn);
}

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 16:00:46
Message-ID: 20090930160046.GE8280@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane escribió:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > And here's the last necessary bit, which is pg_dump support for all
> > this.
>
> > + /* Dump role/database settings */
> > + if (!tablespaces_only)
> > + {
> > + if (server_version >= 80500)
> > + dumpDbRoleConfig(conn);
> > + }
>
> Hmm ... I would kind of think that --roles-only should suppress this too.
> Otherwise you're going to be dumping commands that might refer to
> nonexistent databases.

Hmm. The problem I have with this idea is that the only way to dump the
per-database role settings is if you are also dumping the contents of
all databases. Which seems like a pain to me because the usage I
usually recommend is to backup global objects with pg_dumpall -g.

I wonder if pg_dumpall should have a method for dumping database
creation and settings, excluding contents (leaving that for plain
pg_dump).

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 16:13:55
Message-ID: 24553.1254327235@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Tom Lane escribi:
>> Hmm ... I would kind of think that --roles-only should suppress this too.
>> Otherwise you're going to be dumping commands that might refer to
>> nonexistent databases.

> Hmm. The problem I have with this idea is that the only way to dump the
> per-database role settings is if you are also dumping the contents of
> all databases. Which seems like a pain to me because the usage I
> usually recommend is to backup global objects with pg_dumpall -g.

Huh? --globals-only would still dump them, no?

> I wonder if pg_dumpall should have a method for dumping database
> creation and settings, excluding contents (leaving that for plain
> pg_dump).

Perhaps. People keep speculating about refactoring the division of
labor between pg_dump and pg_dumpall. I'd advise leaving that for
a separate patch though ...

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 17:14:30
Message-ID: 603c8f070909301014x3553b62dq62d0adecfe1ed4f7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Sep 30, 2009 at 10:34 AM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> And here's the last necessary bit, which is pg_dump support for all
> this.

I think it would be helpful if you could post ONE patch with all the
changes and all the new files in the diff. AIUI, "the" patch is now
split across three separate emails. :-(

...Robert


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 17:19:53
Message-ID: 20090930171953.GF8280@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas escribió:
> On Wed, Sep 30, 2009 at 10:34 AM, Alvaro Herrera
> <alvherre(at)commandprompt(dot)com> wrote:
> > And here's the last necessary bit, which is pg_dump support for all
> > this.
>
> I think it would be helpful if you could post ONE patch with all the
> changes and all the new files in the diff. AIUI, "the" patch is now
> split across three separate emails. :-(

That's correct, here it is.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Attachment Content-Type Size
settings-4.patch text/x-diff 71.7 KB

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 19:59:07
Message-ID: 20090930195907.GJ8280@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane escribió:

> BTW, have we thought much about the simplest possible solution,
> which is to not have the view? How badly do we need it? Seems
> like dropping the functionality into a psql \d command might be
> a viable alternative.

FWIW I came up with a preliminary patch for a new psql command \dus that
shows settings. It takes a pattern that's used to constrain on roles.
Thus there is no way to view settings for a database. If there's a need
for that we could use another command, say \dls.

Sample output

alvherre=# \dus fo*
List of settings
role | database | settings
------+----------+-----------------------
fob | | log_duration=true
foo | alvherre | work_mem=256MB
: statement_timeout=10s
foo | | work_mem=512MB
: statement_timeout=1s
(3 rows)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment Content-Type Size
settings-psql.patch text/x-diff 2.6 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 20:05:47
Message-ID: 5575.1254341147@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> FWIW I came up with a preliminary patch for a new psql command \dus that
> shows settings. It takes a pattern that's used to constrain on roles.
> Thus there is no way to view settings for a database. If there's a need
> for that we could use another command, say \dls.

Why not two pattern arguments?

\drds [ role-pattern [ db-pattern ]]

Omitted patterns are presumed to be *

regards, tom lane


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-09-30 21:01:50
Message-ID: 20090930210150.GL8280@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane escribió:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > FWIW I came up with a preliminary patch for a new psql command \dus that
> > shows settings. It takes a pattern that's used to constrain on roles.
> > Thus there is no way to view settings for a database. If there's a need
> > for that we could use another command, say \dls.
>
> Why not two pattern arguments?
>
> \drds [ role-pattern [ db-pattern ]]

Hmm, interesting idea, patch attached. This required changing the API
of processSQLNamePattern to return a bool indicating whether a clause
was added; otherwise, when processing the second pattern it was
impossible to figure out if we needed a WHERE or not.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Attachment Content-Type Size
settings-psql-2.patch text/x-diff 6.1 KB

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-10-01 21:07:32
Message-ID: BA6C3DBDFBD60B546A5D69EB@amenophis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 30. September 2009 13:19:53 -0400 Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:

>> I think it would be helpful if you could post ONE patch with all the
>> changes and all the new files in the diff. AIUI, "the" patch is now
>> split across three separate emails. :-(
>
> That's correct, here it is.

Some additional notes:

- ALTER ROLE ... IN DATABASE is missing some documentation. If you want, i
can work on this.

- The patch as is has still some locking problems (AlterRoleSet() has a XXX
about that): I've managed to create dead entries for a role or a database
in pg_db_role_setting while altering and dropping a role/database in two
concurrent sessions.

--
Thanks

Bernd


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-10-01 21:22:06
Message-ID: 20091001212206.GL5607@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bernd Helmle escribió:
>
>
> --On 30. September 2009 13:19:53 -0400 Alvaro Herrera
> <alvherre(at)commandprompt(dot)com> wrote:
>
> >>I think it would be helpful if you could post ONE patch with all the
> >>changes and all the new files in the diff. AIUI, "the" patch is now
> >>split across three separate emails. :-(
> >
> >That's correct, here it is.
>
> Some additional notes:
>
> - ALTER ROLE ... IN DATABASE is missing some documentation. If you
> want, i can work on this.

Please.

> - The patch as is has still some locking problems (AlterRoleSet()
> has a XXX about that): I've managed to create dead entries for a
> role or a database in pg_db_role_setting while altering and dropping
> a role/database in two concurrent sessions.

Yeah, I was playing with that too. I think we need a few extra
LockSharedObject calls, and not only in the new code :-( (This troubles
me in the case of databases, because we already grab a lock on it during
connection establishing, so this could cause extra contention there.)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-10-02 12:19:40
Message-ID: 046C5E177A54BCA672D4F97A@[172.26.14.62]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 1. Oktober 2009 17:22:06 -0400 Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:

>> - ALTER ROLE ... IN DATABASE is missing some documentation. If you
>> want, i can work on this.
>
> Please.

Here's a patch for this. I've kept it separately, so it's easier for you to
merge it into
your version.

--
Thanks

Bernd

Attachment Content-Type Size
alter_role_docs.patch application/octet-stream 4.7 KB

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Allow more complex user/database default GUC settings
Date: 2009-10-03 11:31:10
Message-ID: CD63991E42BA76CFF61AC182@amenophis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 1. Oktober 2009 17:22:06 -0400 Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:

>> - The patch as is has still some locking problems (AlterRoleSet()
>> has a XXX about that): I've managed to create dead entries for a
>> role or a database in pg_db_role_setting while altering and dropping
>> a role/database in two concurrent sessions.
>
> Yeah, I was playing with that too. I think we need a few extra
> LockSharedObject calls, and not only in the new code :-( (This troubles
> me in the case of databases, because we already grab a lock on it during
> connection establishing, so this could cause extra contention there.)

I have marked the patch as "Ready For Committer", so it can be taken by a
committer to help to resolve the remaining locking issue. There seems no
other issues left. If this is too hasty, i can set it back to whatever you
think its appropriate.

--
Thanks

Bernd