Обсуждение:
Below attached patch is implementing following todo item..
machine-readable pg_controldata?
http://www.postgresql.org/message-id/4B901D73.8030003@agliodbs.com
Possible approaches:
1. Implement as backend function and provide a view to user.
- But In this approach user can only get this information when server is running.
2. Extend pg_controldata tool to provide value of an individual attribute.
A first draft version of the patch is attached in the mail, implemented using approach 2.
Description of the patch:
1. Below is the list of the option which are exposed by pg_controldata (all checkpoint, redo and backup related options are exposed).
I think we don’t need to expose options for other parameters, because they will not be useful for using independently. (user can simply print all values same as old behavior)
-v, --catalog-version catalog version
-l, --latest-chcekpoint-loc Latest checkpoint location
-L, --prev-chcekpoint-loc Prior checkpoint location
-r, --latest-checkpoint-redoloc Latest checkpoint's REDO location
-t, --latest-checkpoint-timeline Latest checkpoint's TimeLineID
-T, --latest-checkpoint-prevtimeline Latest checkpoint's PrevTimeLineID
-c, --latest-checkpoint-time Time of latest checkpoint
-x, --latest-checkpoint-nextxid Latest checkpoint's NextXID
-o, --latest-checkpoint-nextoid Latest Latest checkpoint's NextOID
-X, --latest-checkpoint-nextmulti-xactid Latest checkpoint's NextMultiXactId
-O, --latest-checkpoint-nextmulti-offset Latest checkpoint's NextMultiOffset
-q, --latest-checkpoint-oldestxid Latest checkpoint's oldestXID
-a, --latest-checkpoint-oldest-activexid Latest checkpoint's oldestActiveXID
-m, --latest-checkpoint-oldest-multixid Latest checkpoint's oldestMultiXid
-e, --min-recovery-endloc Minimum recovery ending location
-E, --min-recovery-endloc-timeline Min recovery ending loc's timeline
-b, --backup-start-location Backup start location
-B, --backup-end-location Backup end location
2. If user provide individual option, then direct value of that parameter will be printed (as shown in below example), parameter name is not printed as output so that user need not to parse the output.
./pg_controldata --latest-checkpoint-time -- run with latest-checkpoint-time option
Tue 07 Jan 2014 05:22:42 PM IST --output is direct value
3. This feature can save parsing effort for user where user need to get the value of individual parameter
i.e Time of latest checkpoint for Standby lag monitoring.
Please provide your suggestion…
Regards,
Dilip
Вложения
On Tue, Jan 7, 2014 at 10:55 PM, Dilip kumar <dilip.kumar@huawei.com> wrote: > Below attached patch is implementing following todo item.. > > machine-readable pg_controldata? > > http://www.postgresql.org/message-id/4B901D73.8030003@agliodbs.com > > Possible approaches: > > 1. Implement as backend function and provide a view to user. I think this would be useful. > - But In this approach user can only get this information when > server is running. That is true, but we also have the command-line tool for when it isn't. > 2. Extend pg_controldata tool to provide value of an individual > attribute. > > A first draft version of the patch is attached in the mail, implemented > using approach 2. I think this is really ugly, and I don't see what it accomplishes. If the user wants only one setting from pg_controldata, they can just grep for the line that contains that value. You mention that the patch skips printing the name of the field, avoiding parsing difficulties for the user, but the parsing here is trivial: just skip everything up to the first colon, plus any subsequent whitespace. It's worth keeping in mind that the information in pg_controldata is, by and large, not something we expect users to need all the time. Are there use cases for wanting to look at it? Sure. But not a ton of them. If we thought that everyone who works with PostgreSQL would need to write a script to fetch, say, the catalog version number, then it might be worth having pg_controldata --catalog-version to make that easy so that everyone doesn't have to write pg_controldata | grep '^Catalog version' | sed 's/.*: *//' , but considering that it's only something that comes up rarely, I don't really think it's worth the extra code and documentation to add an option for it. And similarly for the other pg_controldata fields. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
On Wed, Jan 08, 2014 at 03:55:38AM +0000, Dilip kumar wrote: > Below attached patch is implementing following todo item.. > machine-readable pg_controldata? > http://www.postgresql.org/message-id/4B901D73.8030003@agliodbs.com Please put this in the upcoming Commitfest :) https://commitfest.postgresql.org/action/commitfest_view?id=21 Cheers, David. -- David Fetter <david@fetter.org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
<div dir="ltr"><div class="gmail_extra"><br />On Thu, Jan 9, 2014 at 2:50 PM, Robert Haas <<a href="mailto:robertmhaas@gmail.com">robertmhaas@gmail.com</a>>wrote:<br />><br />> On Tue, Jan 7, 2014 at 10:55PM, Dilip kumar <<a href="mailto:dilip.kumar@huawei.com">dilip.kumar@huawei.com</a>> wrote:<br /> > > Belowattached patch is implementing following todo item..<br />> ><br />> > machine-readable pg_controldata?<br/>> ><br />> > <a href="http://www.postgresql.org/message-id/4B901D73.8030003@agliodbs.com">http://www.postgresql.org/message-id/4B901D73.8030003@agliodbs.com</a><br />> ><br />> > Possible approaches:<br />> ><br />> > 1. Implement as backend function andprovide a view to user.<br />><br />> I think this would be useful.<br />><br /><br /></div><div class="gmail_extra">Hi,<br /><br /></div><div class="gmail_extra">Joe Conway already created this feature [1] some time ago.I think this code can be reused to create an extension.<br /><br /></div><div class="gmail_extra">Regards,<br /></div><divclass="gmail_extra"><br />[1] <a href="https://github.com/jconway/pg_controldata">https://github.com/jconway/pg_controldata</a><br/></div><div class="gmail_extra"><br/>--<br />Fabrízio de Royes Mello<br />Consultoria/Coaching PostgreSQL<br />>> Timbira: <a href="http://www.timbira.com.br">http://www.timbira.com.br</a><br/> >> Blog sobre TI: <a href="http://fabriziomello.blogspot.com">http://fabriziomello.blogspot.com</a><br/>>> Perfil Linkedin: <a href="http://br.linkedin.com/in/fabriziomello">http://br.linkedin.com/in/fabriziomello</a><br/> >> Twitter: <a href="http://twitter.com/fabriziomello">http://twitter.com/fabriziomello</a></div></div>