Re: pgsql: Allow units to be specified in relation option setting value.

Lists: pgsql-committerspgsql-hackers
From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 07:15:35
Message-ID: E1XMtvj-0006DF-QW@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Allow units to be specified in relation option setting value.

This introduces an infrastructure which allows us to specify the units
like ms (milliseconds) in integer relation option, like GUC parameter.
Currently only autovacuum_vacuum_cost_delay reloption can accept
the units.

Reviewed by Michael Paquier

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e23014f3d40f7d2c23bc97207fd28efbe5ba102b

Modified Files
--------------
src/backend/access/common/reloptions.c | 40 ++++++++++++++++-------------
src/include/access/reloptions.h | 3 ++-
src/test/regress/expected/alter_table.out | 14 ++++++++++
src/test/regress/sql/alter_table.sql | 6 +++++
4 files changed, 44 insertions(+), 19 deletions(-)


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Fujii Masao <fujii(at)postgresql(dot)org>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 12:11:33
Message-ID: 20140828121133.GF17329@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Hi,

On 2014-08-28 07:15:35 +0000, Fujii Masao wrote:
> Allow units to be specified in relation option setting value.
>
> This introduces an infrastructure which allows us to specify the units
> like ms (milliseconds) in integer relation option, like GUC parameter.
> Currently only autovacuum_vacuum_cost_delay reloption can accept
> the units.

This apparently broke pg_upgrade. I've not checked what's up there.

See
http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prairiedog&dt=2014-08-28%2007%3A16%3A04
and many others.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 12:28:05
Message-ID: CAHGQGwHsUmMTAPS=mRSd01jdN-VsBXsk4ZKDeDmif7VG3m0sPw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Thu, Aug 28, 2014 at 9:11 PM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> Hi,
>
> On 2014-08-28 07:15:35 +0000, Fujii Masao wrote:
>> Allow units to be specified in relation option setting value.
>>
>> This introduces an infrastructure which allows us to specify the units
>> like ms (milliseconds) in integer relation option, like GUC parameter.
>> Currently only autovacuum_vacuum_cost_delay reloption can accept
>> the units.
>
> This apparently broke pg_upgrade. I've not checked what's up there.
>
> See
> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prairiedog&dt=2014-08-28%2007%3A16%3A04
> and many others.

Oh,, will check.

Regards,

--
Fujii Masao


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 13:51:54
Message-ID: CAB7nPqSeVWnhk-TA-GJBDgea-1ZLT8WFYwSp_63ut2ia8W9wrQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Thu, Aug 28, 2014 at 9:28 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> Oh,, will check.

That's a problem with pg_dump not able to put quotes where for a
reloption units are used.
For example this table:
create table test (a int) with (autovacuum_vacuum_cost_delay = '80ms');
Results in the following dump:
CREATE TABLE test (
a integer
)
WITH (autovacuum_vacuum_cost_delay=80ms);

Because of how reloptions is registered in pg_class:
=# select relname,reloptions from pg_class where relname = 'test';
relname | reloptions
---------+-------------------------------------
test | {autovacuum_vacuum_cost_delay=80ms}
(1 row)
Regards,
--
Michael


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 14:10:09
Message-ID: CAB7nPqTpdGLqLTxuGhBC2GabGNiFRAtLjFbxu=aGy1rX_DgwUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Thu, Aug 28, 2014 at 10:51 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> Because of how reloptions is registered in pg_class:
The patch attached fixes pg_upgrade by putting quotes when generating
reloptions and it passes check-world. I imagine that having quotes by
default in the value of reloptions in pg_class is the price to pay for
supporting units. If this is not considered as a correct approach,
then reverting the patch would be wiser I guess.
Regards,
--
Michael

Attachment Content-Type Size
20140828_relopt_unit_fix.patch text/x-diff 11.8 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgresql(dot)org, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 14:14:53
Message-ID: 25150.1409235293@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
> The patch attached fixes pg_upgrade by putting quotes when generating
> reloptions and it passes check-world. I imagine that having quotes by
> default in the value of reloptions in pg_class is the price to pay for
> supporting units. If this is not considered as a correct approach,
> then reverting the patch would be wiser I guess.

Ugh. I'm not sure what the best solution is, but I don't think I like
that one.

Given that this patch broke both pg_dump and pg_upgrade, I think it should
be reverted for the time being, rather than applying a hasty hack.
Obviously more thought and testing is needed.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Fujii Masao <fujii(at)postgresql(dot)org>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 14:30:57
Message-ID: 20140828143057.GF25984@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On 2014-08-28 14:11:33 +0200, Andres Freund wrote:
> Hi,
>
> On 2014-08-28 07:15:35 +0000, Fujii Masao wrote:
> > Allow units to be specified in relation option setting value.
> >
> > This introduces an infrastructure which allows us to specify the units
> > like ms (milliseconds) in integer relation option, like GUC parameter.
> > Currently only autovacuum_vacuum_cost_delay reloption can accept
> > the units.
>
> This apparently broke pg_upgrade. I've not checked what's up there.
>
> See
> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prairiedog&dt=2014-08-28%2007%3A16%3A04
> and many others.

The specific error is an unquoted 80ms in WITH
(autovacuum_vacuum_cost_delay=80ms);

Independent of that being fixable with some quoting or such, I'm a bit
doubtful about unconditionally adding the ms here. Won't that make it
unnecessarily hard to get 9.5 dumps into <9.5? I know that we don't make
any promises, but it mostly works nonetheless. And this doesn't seem
worth the breakage.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 16:22:28
Message-ID: CAHGQGwFtd6OYy9iCzsspH9eAOW8aTmK4RZUoraUDYj9nRvYW1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Thu, Aug 28, 2014 at 11:14 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
>> The patch attached fixes pg_upgrade by putting quotes when generating
>> reloptions and it passes check-world. I imagine that having quotes by
>> default in the value of reloptions in pg_class is the price to pay for
>> supporting units. If this is not considered as a correct approach,
>> then reverting the patch would be wiser I guess.
>
> Ugh. I'm not sure what the best solution is, but I don't think I like
> that one.

Another approach is to change pg_dump so that it encloses the relopt
values with single quotes. This is the same approach as what
pg_dumpall does for database or role-specific settings. Obvious
drawback of this approach is that it prevents pg_dump with 9.4 or
before from outputting the restorable dump. Maybe we can live with
this because there is no guarantee that older version of pg_dump can
work properly with newer major version of server. But maybe
someone cannot live with that. Not sure.

Further other approach is to change the reloptions code so that it
always stores the plain value without the units (i.e., 1000 is stored
if 1s is specified in autovacuum_vacuum_cost_delay)in pg_class.
This approach doesn't prevent older version of pg_dump from taking
the dump from v9.5 server. One drawback of this approach is that
reloption values are always stored without the units, which might
make it a bit hard for a user to see the reloption values from pg_class.

Regards,

--
Fujii Masao


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 16:31:31
Message-ID: CA+TgmoYVabQLRWXcKq2+zpZsdbcJ1XVk1tucquR2qELjjLN1QA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Thu, Aug 28, 2014 at 12:22 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Thu, Aug 28, 2014 at 11:14 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
>>> The patch attached fixes pg_upgrade by putting quotes when generating
>>> reloptions and it passes check-world. I imagine that having quotes by
>>> default in the value of reloptions in pg_class is the price to pay for
>>> supporting units. If this is not considered as a correct approach,
>>> then reverting the patch would be wiser I guess.
>>
>> Ugh. I'm not sure what the best solution is, but I don't think I like
>> that one.
>
> Another approach is to change pg_dump so that it encloses the relopt
> values with single quotes. This is the same approach as what
> pg_dumpall does for database or role-specific settings. Obvious
> drawback of this approach is that it prevents pg_dump with 9.4 or
> before from outputting the restorable dump. Maybe we can live with
> this because there is no guarantee that older version of pg_dump can
> work properly with newer major version of server. But maybe
> someone cannot live with that. Not sure.

To me, this doesn't seem nearly important enough to justify breaking
pg_dump compatibility. AAUI, this is just a cosmetic improvement, so
we shouldn't break functional things for that.

> Further other approach is to change the reloptions code so that it
> always stores the plain value without the units (i.e., 1000 is stored
> if 1s is specified in autovacuum_vacuum_cost_delay)in pg_class.
> This approach doesn't prevent older version of pg_dump from taking
> the dump from v9.5 server. One drawback of this approach is that
> reloption values are always stored without the units, which might
> make it a bit hard for a user to see the reloption values from pg_class.

This seems like the way to go.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 19:34:15
Message-ID: 31170.1409254455@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Thu, Aug 28, 2014 at 12:22 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>> Another approach is to change pg_dump so that it encloses the relopt
>> values with single quotes. This is the same approach as what
>> pg_dumpall does for database or role-specific settings.

> To me, this doesn't seem nearly important enough to justify breaking
> pg_dump compatibility. AAUI, this is just a cosmetic improvement, so
> we shouldn't break functional things for that.

Indeed. I am not convinced that pg_dump is the only client-side code
that would get broken, either.

>> Further other approach is to change the reloptions code so that it
>> always stores the plain value without the units (i.e., 1000 is stored
>> if 1s is specified in autovacuum_vacuum_cost_delay)in pg_class.

> This seems like the way to go.

Yeah, it's the best idea I can think of either. It's a tad annoying but
I think we don't want to take the compatibility risks of storing
unit-ified values in reloptions.

In the meantime, the buildfarm is still all red. Can we please revert
this patch until a fixed version is ready?

regards, tom lane


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-08-28 20:27:54
Message-ID: CAHGQGwFhVS1ySwYN80gVZu3+W3fkTjftOrq+WoMVppOYmXZRXw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Fri, Aug 29, 2014 at 4:34 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Thu, Aug 28, 2014 at 12:22 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>>> Another approach is to change pg_dump so that it encloses the relopt
>>> values with single quotes. This is the same approach as what
>>> pg_dumpall does for database or role-specific settings.
>
>> To me, this doesn't seem nearly important enough to justify breaking
>> pg_dump compatibility. AAUI, this is just a cosmetic improvement, so
>> we shouldn't break functional things for that.
>
> Indeed. I am not convinced that pg_dump is the only client-side code
> that would get broken, either.
>
>>> Further other approach is to change the reloptions code so that it
>>> always stores the plain value without the units (i.e., 1000 is stored
>>> if 1s is specified in autovacuum_vacuum_cost_delay)in pg_class.
>
>> This seems like the way to go.

Agreed.

>
> Yeah, it's the best idea I can think of either. It's a tad annoying but
> I think we don't want to take the compatibility risks of storing
> unit-ified values in reloptions.
>
> In the meantime, the buildfarm is still all red. Can we please revert
> this patch until a fixed version is ready?

OK, reverted.

Regards,

--
Fujii Masao


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Allow units to be specified in relation option setting value.
Date: 2014-09-20 03:57:22
Message-ID: CAB7nPqQrHfEOQ0E-v_wKW_XQAxSWVajkorrnrHEiQ1soHkkFbw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Thu, Aug 28, 2014 at 3:27 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> OK, reverted.
As this patch needs more care in the way it is stored in pg_class as
reloptions (need more logic to parse correctly units from the actual
values that are store), I just marked it as returned with feedback.
--
Michael