Below attached patch is implementing following todo item..
machine-readable pg_controldata?
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 
  -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 
  -O, --latest-checkpoint-nextmulti-offset             Latest checkpoint's 
  -q, --latest-checkpoint-oldestxid                            Latest 
checkpoint's oldestXID
  -a, --latest-checkpoint-oldest-activexid               Latest checkpoint's 
  -m, --latest-checkpoint-oldest-multixid               Latest checkpoint's 
  -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 

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 
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...


Attachment: controldata_v1.patch
Description: controldata_v1.patch

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to