90{
91 static struct option long_options[] = {
93 {NULL, 0, NULL, 0}
94 };
95
97 bool crc_ok;
99 time_t time_tmp;
101 char pgctime_str[128];
102 char ckpttime_str[128];
104 const char *strftime_fmt = "%c";
110
114
115 if (argc > 1)
116 {
117 if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
118 {
120 exit(0);
121 }
122 if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
123 {
124 puts("pg_controldata (PostgreSQL) " PG_VERSION);
125 exit(0);
126 }
127 }
128
129 while ((
c =
getopt_long(argc, argv,
"D:", long_options, NULL)) != -1)
130 {
132 {
133 case 'D':
135 break;
136
137 default:
138
140 exit(1);
141 }
142 }
143
145 {
148 else
150 }
151
152
154 {
155 pg_log_error(
"too many command-line arguments (first is \"%s\")",
158 exit(1);
159 }
160
162 {
165 exit(1);
166 }
167
168
171 {
172 pg_log_warning(
"control file version (%u) does not match the version understood by this program (%u)",
174 pg_log_warning_detail(
"Either the control file has been created with a different version of PostgreSQL, "
175 "or it is corrupt. The results below are untrustworthy.");
176 }
177 else if (!crc_ok)
178 {
179 pg_log_warning(
"calculated CRC checksum does not match value stored in control file");
180 pg_log_warning_detail(
"Either the control file is corrupt, or it has a different layout than this program "
181 "is expecting. The results below are untrustworthy.");
182 }
183
184
186
188 {
190 "invalid WAL segment size in control file (%d bytes)",
195 }
196
197
198
199
200
201
202
203
204
205
207 tm_tmp = localtime(&time_tmp);
208
209 if (tm_tmp != NULL)
210 strftime(pgctime_str, sizeof(pgctime_str), strftime_fmt, tm_tmp);
211 else
212 snprintf(pgctime_str,
sizeof(pgctime_str),
_(
"???"));
213
215 tm_tmp = localtime(&time_tmp);
216
217 if (tm_tmp != NULL)
218 strftime(ckpttime_str, sizeof(ckpttime_str), strftime_fmt, tm_tmp);
219 else
220 snprintf(ckpttime_str,
sizeof(ckpttime_str),
_(
"???"));
221
222
223
224
225
226
227
228
229
231 {
233
237 }
238 else
239 strcpy(xlogfilename,
_(
"???"));
240
242 snprintf(&mock_auth_nonce_str[
i * 2], 3,
"%02x",
244
245 printf(
_(
"pg_control version number: %u\n"),
247 printf(
_(
"Catalog version number: %u\n"),
249 printf(
_(
"Database system identifier: %" PRIu64
"\n"),
251 printf(
_(
"Database cluster state: %s\n"),
253 printf(
_(
"pg_control last modified: %s\n"),
254 pgctime_str);
255 printf(
_(
"Latest checkpoint location: %X/%08X\n"),
257 printf(
_(
"Latest checkpoint's REDO location: %X/%08X\n"),
259 printf(
_(
"Latest checkpoint's REDO WAL file: %s\n"),
260 xlogfilename);
261 printf(
_(
"Latest checkpoint's TimeLineID: %u\n"),
263 printf(
_(
"Latest checkpoint's PrevTimeLineID: %u\n"),
265 printf(
_(
"Latest checkpoint's full_page_writes: %s\n"),
267 printf(
_(
"Latest checkpoint's NextXID: %u:%u\n"),
270 printf(
_(
"Latest checkpoint's NextOID: %u\n"),
272 printf(
_(
"Latest checkpoint's NextMultiXactId: %u\n"),
274 printf(
_(
"Latest checkpoint's NextMultiOffset: %u\n"),
276 printf(
_(
"Latest checkpoint's oldestXID: %u\n"),
278 printf(
_(
"Latest checkpoint's oldestXID's DB: %u\n"),
280 printf(
_(
"Latest checkpoint's oldestActiveXID: %u\n"),
282 printf(
_(
"Latest checkpoint's oldestMultiXid: %u\n"),
284 printf(
_(
"Latest checkpoint's oldestMulti's DB: %u\n"),
286 printf(
_(
"Latest checkpoint's oldestCommitTsXid:%u\n"),
288 printf(
_(
"Latest checkpoint's newestCommitTsXid:%u\n"),
290 printf(
_(
"Time of latest checkpoint: %s\n"),
291 ckpttime_str);
292 printf(
_(
"Fake LSN counter for unlogged rels: %X/%08X\n"),
294 printf(
_(
"Minimum recovery ending location: %X/%08X\n"),
296 printf(
_(
"Min recovery ending loc's timeline: %u\n"),
298 printf(
_(
"Backup start location: %X/%08X\n"),
300 printf(
_(
"Backup end location: %X/%08X\n"),
302 printf(
_(
"End-of-backup record required: %s\n"),
304 printf(
_(
"wal_level setting: %s\n"),
306 printf(
_(
"wal_log_hints setting: %s\n"),
308 printf(
_(
"max_connections setting: %d\n"),
310 printf(
_(
"max_worker_processes setting: %d\n"),
312 printf(
_(
"max_wal_senders setting: %d\n"),
314 printf(
_(
"max_prepared_xacts setting: %d\n"),
316 printf(
_(
"max_locks_per_xact setting: %d\n"),
318 printf(
_(
"track_commit_timestamp setting: %s\n"),
320 printf(
_(
"Maximum data alignment: %u\n"),
322
323 printf(
_(
"Database block size: %u\n"),
325 printf(
_(
"Blocks per segment of large relation: %u\n"),
327 printf(
_(
"Pages per SLRU segment: %u\n"),
329 printf(
_(
"WAL block size: %u\n"),
331 printf(
_(
"Bytes per WAL segment: %u\n"),
333 printf(
_(
"Maximum length of identifiers: %u\n"),
335 printf(
_(
"Maximum columns in an index: %u\n"),
337 printf(
_(
"Maximum size of a TOAST chunk: %u\n"),
339 printf(
_(
"Size of a large-object chunk: %u\n"),
341
342 printf(
_(
"Date/time type storage: %s\n"),
343 _(
"64-bit integers"));
344 printf(
_(
"Float8 argument passing: %s\n"),
346 printf(
_(
"Data page checksum version: %u\n"),
348 printf(
_(
"Default char data signedness: %s\n"),
350 printf(
_(
"Mock authentication nonce: %s\n"),
351 mock_auth_nonce_str);
352 return 0;
353}
static void usage(const char *progname)
static const char * dbState(DBState state)
static const char * wal_level_str(WalLevel wal_level)
#define ngettext(s, p, n)
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
ControlFileData * get_controlfile(const char *DataDir, bool *crc_ok_p)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
void pg_logging_init(const char *argv0)
#define pg_log_error(...)
#define pg_log_error_hint(...)
#define pg_log_warning_detail(...)
#define PG_CONTROL_VERSION
#define MOCK_AUTH_NONCE_LEN
PGDLLIMPORT char * optarg
#define pg_log_warning(...)
const char * get_progname(const char *argv0)
MultiXactOffset nextMultiOffset
TransactionId newestCommitTsXid
TimeLineID PrevTimeLineID
TimeLineID ThisTimeLineID
TransactionId oldestActiveXid
FullTransactionId nextXid
TransactionId oldestCommitTsXid
char mock_authentication_nonce[MOCK_AUTH_NONCE_LEN]
uint32 pg_control_version
XLogRecPtr backupStartPoint
bool track_commit_timestamp
CheckPoint checkPointCopy
uint32 slru_pages_per_segment
XLogRecPtr backupEndPoint
XLogRecPtr minRecoveryPoint
uint32 data_checksum_version
bool default_char_signedness
uint32 catalog_version_no
TimeLineID minRecoveryPointTLI
uint32 toast_max_chunk_size
#define EpochFromFullTransactionId(x)
#define XidFromFullTransactionId(x)
static ControlFileData * ControlFile
#define IsValidWalSegSize(size)
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)
#define LSN_FORMAT_ARGS(lsn)