Lists: | pgsql-hackers |
---|
From: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 10:59:07 |
Message-ID: | 20140924105907.GA18922@toroid.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi.
I can never remember that pg_controldata takes only a dirname rather
than "-D dirname", and I gather I'm not the only one. Here's a tiny
patch to make it work either way. As far as I can see, it doesn't
break anything, not even if you have a data directory named "-D".
-- Abhijit
Attachment | Content-Type | Size |
---|---|---|
0001-Make-pg_controldata-ignore-a-D-before-DataDir.patch | text/x-diff | 761 bytes |
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>, <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 11:03:41 |
Message-ID: | 5422A50D.8080709@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 09/24/2014 01:59 PM, Abhijit Menon-Sen wrote:
> Hi.
>
> I can never remember that pg_controldata takes only a dirname rather
> than "-D dirname", and I gather I'm not the only one. Here's a tiny
> patch to make it work either way. As far as I can see, it doesn't
> break anything, not even if you have a data directory named "-D".
Ah, I frequently run into that too; but with pg_resetxlog.
- Heikki
From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 11:04:07 |
Message-ID: | CABUevEz6NDS9OACZe6w8jmiHSEgfoHnOF3GHVmX5EX6KQ8=Saw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, Sep 24, 2014 at 12:59 PM, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com> wrote:
> Hi.
>
> I can never remember that pg_controldata takes only a dirname rather
> than "-D dirname", and I gather I'm not the only one. Here's a tiny
> patch to make it work either way. As far as I can see, it doesn't
> break anything, not even if you have a data directory named "-D".
I haven't looked at the code, but definitely +1 for the feature.
That's really quite annoying.
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
From: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 11:21:03 |
Message-ID: | 20140924112103.GA19894@toroid.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
At 2014-09-24 14:03:41 +0300, hlinnakangas(at)vmware(dot)com wrote:
>
> Ah, I frequently run into that too; but with pg_resetxlog.
Well, that's no fun. Patch attached.
-- Abhijit
Attachment | Content-Type | Size |
---|---|---|
0001-Make-pg_resetxlog-also-accept-D-datadir.patch | text/x-diff | 1.5 KB |
From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com> |
Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 11:44:56 |
Message-ID: | CAB7nPqSdnHEFmSDGRQgHXegqviKJt20pKJN8LRvgR7z3DQUrxQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, Sep 24, 2014 at 7:59 PM, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com> wrote:
> I can never remember that pg_controldata takes only a dirname rather
> than "-D dirname", and I gather I'm not the only one. Here's a tiny
> patch to make it work either way. As far as I can see, it doesn't
> break anything, not even if you have a data directory named "-D".
+1. I forget it all the time as well...
--
Michael
From: | Rajeev rastogi <rajeev(dot)rastogi(at)huawei(dot)com> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com> |
Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 11:52:05 |
Message-ID: | BF2827DCCE55594C8D7A8F7FFD3AB77158E53660@SZXEML508-MBX.china.huawei.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 24 September 2014 17:15, Michael Paquier Wrote:
> On Wed, Sep 24, 2014 at 7:59 PM, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>
> wrote:
> > I can never remember that pg_controldata takes only a dirname rather
> > than "-D dirname", and I gather I'm not the only one. Here's a tiny
> > patch to make it work either way. As far as I can see, it doesn't
> > break anything, not even if you have a data directory named "-D".
> +1. I forget it all the time as well...
+1, always I get confused once pg_controldata does not work with -D.
From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Magnus Hagander <magnus(at)hagander(dot)net> |
Cc: | Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 12:48:28 |
Message-ID: | 20140924124828.GL5311@eldon.alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Magnus Hagander wrote:
> On Wed, Sep 24, 2014 at 12:59 PM, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com> wrote:
> > Hi.
> >
> > I can never remember that pg_controldata takes only a dirname rather
> > than "-D dirname", and I gather I'm not the only one. Here's a tiny
> > patch to make it work either way. As far as I can see, it doesn't
> > break anything, not even if you have a data directory named "-D".
>
> I haven't looked at the code, but definitely +1 for the feature.
> That's really quite annoying.
+1
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From: | Thom Brown <thom(at)linux(dot)com> |
---|---|
To: | Magnus Hagander <magnus(at)hagander(dot)net> |
Cc: | Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 12:57:47 |
Message-ID: | CAA-aLv5fv4jDG2QdX2pM9Op5LQfQz9v1FwerEB4nWf9gZh1fsQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 24 September 2014 12:04, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Wed, Sep 24, 2014 at 12:59 PM, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>
> wrote:
> > Hi.
> >
> > I can never remember that pg_controldata takes only a dirname rather
> > than "-D dirname", and I gather I'm not the only one. Here's a tiny
> > patch to make it work either way. As far as I can see, it doesn't
> > break anything, not even if you have a data directory named "-D".
>
> I haven't looked at the code, but definitely +1 for the feature.
> That's really quite annoying.
>
And here I was thinking it was just me.
+1
Thom
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
Cc: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 13:02:29 |
Message-ID: | 5422C0E5.9050102@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 09/24/2014 02:21 PM, Abhijit Menon-Sen wrote:
> At 2014-09-24 14:03:41 +0300, hlinnakangas(at)vmware(dot)com wrote:
>>
>> Ah, I frequently run into that too; but with pg_resetxlog.
>
> Well, that's no fun. Patch attached.
Thanks. Please update the docs and usage(), too.
- Heikki
From: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 13:16:06 |
Message-ID: | 20140924131606.GA21184@toroid.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
At 2014-09-24 16:02:29 +0300, hlinnakangas(at)vmware(dot)com wrote:
>
> Thanks. Please update the docs and usage(), too.
I'm sorry, but I don't think it would be an improvement to make the docs
explain that it's valid to use either "-D datadir" or specify it without
an option. If both commands were changed to *require* "-D datadir", that
would be worth documenting. But of course I didn't want to change any
behaviour for people who have a better memory than I do.
I think it's all right as a quick hack to remove an inconsistency that
has clearly annoyed many people, but not much more.
Would you be OK with my just sticking a "[-D]" before DATADIR in the
usage() message for both programs, with no further explanation? (But
to be honest, I don't think even that is necessary or desirable.)
-- Abhijit
From: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 13:18:38 |
Message-ID: | 20140924131838.GA21315@toroid.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
To put it another way, I doubt any of the people who were surprised by
it looked at either the usage message or the docs. ;-)
-- Abhijit
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
Cc: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 13:25:12 |
Message-ID: | 15084.1411565112@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> writes:
> At 2014-09-24 16:02:29 +0300, hlinnakangas(at)vmware(dot)com wrote:
>> Thanks. Please update the docs and usage(), too.
> I'm sorry, but I don't think it would be an improvement to make the docs
> explain that it's valid to use either "-D datadir" or specify it without
> an option.
What's so hard about [ -D ] before the datadir argument?
regards, tom lane
From: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 13:49:20 |
Message-ID: | 20140924134920.GA21547@toroid.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
At 2014-09-24 09:25:12 -0400, tgl(at)sss(dot)pgh(dot)pa(dot)us wrote:
>
> What's so hard about [ -D ] before the datadir argument?
I'm sorry to have given you the impression that I objected to it because
it was hard. Since I proposed the same thing a few lines after what you
quoted, I guess I have to agree it's not hard.
I think it's pointless, because if you're going to look at the usage
message to begin with, why not do what it already says? But I don't
care enough to argue about it any further.
Patches attached.
-- Abhijit
P.S. Trivia: I can't find any other options in Postgres where the
argument is mandatory but the option is optional.
Attachment | Content-Type | Size |
---|---|---|
0001-Make-pg_controldata-ignore-a-D-before-DataDir.patch | text/x-diff | 1.2 KB |
0002-Make-pg_resetxlog-also-accept-D-datadir.patch | text/x-diff | 1.9 KB |
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 13:54:27 |
Message-ID: | 5422CD13.4040706@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 09/24/2014 04:49 PM, Abhijit Menon-Sen wrote:
> At 2014-09-24 09:25:12 -0400, tgl(at)sss(dot)pgh(dot)pa(dot)us wrote:
>>
>> What's so hard about [ -D ] before the datadir argument?
>
> I'm sorry to have given you the impression that I objected to it because
> it was hard. Since I proposed the same thing a few lines after what you
> quoted, I guess I have to agree it's not hard.
>
> I think it's pointless, because if you're going to look at the usage
> message to begin with, why not do what it already says? But I don't
> care enough to argue about it any further.
There's also the reverse situation: you see that a script contains a
line like "pg_controldata -D foo". You're accustomed to doing just
"pg_controldata foo", and you wonder what the -D option does. So you
look it up in the docs or "pg_controldata --help".
- Heikki
From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 13:58:49 |
Message-ID: | 20140924135849.GO5311@eldon.alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Abhijit Menon-Sen wrote:
> P.S. Trivia: I can't find any other options in Postgres where the
> argument is mandatory but the option is optional.
psql behaves similarly with its -d and -U switches also; note --help:
Usage:
psql [OPTION]... [DBNAME [USERNAME]]
...
-d, --dbname=DBNAME database name to connect to (default: "alvherre")
...
-U, --username=USERNAME database user name (default: "alvherre")
Both are optional and have defaults. Datadir for pg_controldata is also
optional and --help contains this blurb:
If no data directory (DATADIR) is specified, the environment variable PGDATA
is used.
I think you could replace those lines with
-D data directory blah (default: "value of $PGDATA")
But psql --help doesn't use $PGUSER to expand the default value for -U;
I'm not clear if this means we shouldn't expand PGDATA in the help line
for pg_controldata, or need to fix psql to expand PGUSER in -U.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-24 14:48:14 |
Message-ID: | 20140924144814.GA22087@toroid.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Updated patches attached.
-- Abhijit
Attachment | Content-Type | Size |
---|---|---|
0001-Make-pg_controldata-ignore-a-D-before-DataDir.patch | text/x-diff | 2.5 KB |
0002-Make-pg_resetxlog-also-accept-D-datadir.patch | text/x-diff | 3.7 KB |
0003-Use-user-not-env-as-the-default-for-U.patch | text/x-diff | 921 bytes |
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-09-25 10:38:46 |
Message-ID: | 5423F0B6.6090506@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 09/24/2014 05:48 PM, Abhijit Menon-Sen wrote:
> Updated patches attached.
Thanks, applied some version of these.
- Heikki
From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-10-24 08:36:02 |
Message-ID: | CAB7nPqSpGPYDVAGCvPp_3TJ=0QHms4o=8zdDvzqV90rG_mwPEg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Sep 25, 2014 at 12:38 PM, Heikki Linnakangas <
hlinnakangas(at)vmware(dot)com> wrote:
> On 09/24/2014 05:48 PM, Abhijit Menon-Sen wrote:
>
>> Updated patches attached.
>>
>
> Thanks, applied some version of these.
>
This set of patches has been applied as b0d81ad but patch 0001 did not make
it in, so pg_controldata is not yet able to accept -D:
$ pg_controldata -D /foo/path
pg_controldata: could not open file "-D/global/pg_control" for reading: No
such file or directory
$ pg_controldata /foo/path
pg_controldata: could not open file "/foo/path/global/pg_control" for
reading: No such file or directory
--
Michael
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "PostgreSQL mailing lists" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-10-24 16:20:51 |
Message-ID: | 544A7C63.5010209@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 10/24/2014 11:36 AM, Michael Paquier wrote:
> On Thu, Sep 25, 2014 at 12:38 PM, Heikki Linnakangas <
> hlinnakangas(at)vmware(dot)com> wrote:
>
>> On 09/24/2014 05:48 PM, Abhijit Menon-Sen wrote:
>>
>>> Updated patches attached.
>>>
>>
>> Thanks, applied some version of these.
>>
> This set of patches has been applied as b0d81ad but patch 0001 did not make
> it in, so pg_controldata is not yet able to accept -D:
> $ pg_controldata -D /foo/path
> pg_controldata: could not open file "-D/global/pg_control" for reading: No
> such file or directory
> $ pg_controldata /foo/path
> pg_controldata: could not open file "/foo/path/global/pg_control" for
> reading: No such file or directory
Argh, looks like I forgot the actual code changes required.
I just noticed that pg_controldata and pg_resetxlog don't check for
extra arguments:
$ pg_resetxlog data fds sdf sdf
Transaction log reset
Fixed that too.
- Heikki
From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make pg_controldata accept "-D dirname" |
Date: | 2014-10-26 04:34:44 |
Message-ID: | CAB7nPqRRxweoyhq7xBXOg2ORrP-WPvJJDkGTEOW-FDGcc8BG=Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Sat, Oct 25, 2014 at 1:20 AM, Heikki Linnakangas
<hlinnakangas(at)vmware(dot)com> wrote:
> Argh, looks like I forgot the actual code changes required.
> I just noticed that pg_controldata and pg_resetxlog don't check for extra
> arguments:
> $ pg_resetxlog data fds sdf sdf
> Transaction log reset
I think that it would be good to add as well a set of TAP tests for
all those things. So attached are two patches, one to complete the
tests of pg_controldata, and a second one to add TAP tests for
pg_resetxlog.
--
Michael
Attachment | Content-Type | Size |
---|---|---|
0001-Add-more-TAP-tests-for-pg_controldata.patch | text/x-diff | 1.6 KB |
0002-Add-TAP-tests-for-pg_resetxlog.patch | text/x-diff | 2.4 KB |