40{
44 char *p;
82 int rc;
84
85
86
87
88
105 if (
getenv(
"LC_MESSAGES"))
107
113#ifndef WIN32
115#else
116
118#endif
121 setenv(
"LC_MESSAGES",
"C", 1);
122
123
124
125
127 {
128
129 snprintf(cmd,
sizeof(cmd),
"\"%s/pg_controldata\" \"%s\"",
132
134 pg_fatal(
"could not get control data using %s: %m", cmd);
135
136
138 {
140 {
142
145
146 p++;
147
148
149
150
151
152
153
154
155
156
158 while (*p == ' ')
159 p++;
160 if (
strcmp(p,
"shut down in recovery") == 0)
161 {
163 pg_fatal(
"The source cluster was shut down while in recovery mode. To upgrade, use \"rsync\" as documented or shut it down as a primary.");
164 else
165 pg_fatal(
"The target cluster was shut down while in recovery mode. To upgrade, use \"rsync\" as documented or shut it down as a primary.");
166 }
167 else if (
strcmp(p,
"shut down") != 0)
168 {
170 pg_fatal(
"The source cluster was not shut down cleanly, state reported as: \"%s\"", p);
171 else
172 pg_fatal(
"The target cluster was not shut down cleanly, state reported as: \"%s\"", p);
173 }
175 }
176 }
177
179 if (rc != 0)
180 pg_fatal(
"could not get control data using %s: %s",
182
184 {
186 pg_fatal(
"The source cluster lacks cluster state information:");
187 else
188 pg_fatal(
"The target cluster lacks cluster state information:");
189 }
190 }
191
192
195 else
197 snprintf(cmd,
sizeof(cmd),
"\"%s/%s \"%s\"",
202
204 pg_fatal(
"could not get control data using %s: %m", cmd);
205
206
208 {
211 }
212
213
215 {
216
219
221 {
223
226
227 p++;
229 }
231 {
233
236
237 p++;
239 }
240 else if ((p =
strstr(
bufin,
"Latest checkpoint's TimeLineID:")) !=
NULL)
241 {
243
246
247 p++;
250 }
251 else if ((p =
strstr(
bufin,
"First log file ID after reset:")) !=
NULL)
252 {
254
257
258 p++;
261 }
262 else if ((p =
strstr(
bufin,
"First log file segment after reset:")) !=
NULL)
263 {
265
268
269 p++;
272 }
274 {
276
279
280 p++;
282
283
284
285
286
287
288
293 else
295
298
299 p++;
302 }
304 {
306
309
310 p++;
313 }
314 else if ((p =
strstr(
bufin,
"Latest checkpoint's NextMultiXactId:")) !=
NULL)
315 {
317
320
321 p++;
324 }
325 else if ((p =
strstr(
bufin,
"Latest checkpoint's oldestXID:")) !=
NULL)
326 {
328
331
332 p++;
335 }
336 else if ((p =
strstr(
bufin,
"Latest checkpoint's oldestMultiXid:")) !=
NULL)
337 {
339
342
343 p++;
346 }
347 else if ((p =
strstr(
bufin,
"Latest checkpoint's NextMultiOffset:")) !=
NULL)
348 {
350
353
354 p++;
357 }
358 else if ((p =
strstr(
bufin,
"First log segment after reset:")) !=
NULL)
359 {
360
364 p =
strpbrk(p,
"01234567890ABCDEF");
367
368
369 if (
strspn(p,
"0123456789ABCDEF") != 24)
371
374 }
376 {
378
381
382 p++;
383
386 }
388 {
390
393
394 p++;
397 }
399 {
401
404
405 p++;
408 }
409 else if ((p =
strstr(
bufin,
"Blocks per segment of large relation:")) !=
NULL)
410 {
412
415
416 p++;
419 }
421 {
423
426
427 p++;
430 }
432 {
434
437
438 p++;
441 }
442 else if ((p =
strstr(
bufin,
"Maximum length of identifiers:")) !=
NULL)
443 {
445
448
449 p++;
452 }
454 {
456
459
460 p++;
463 }
464 else if ((p =
strstr(
bufin,
"Maximum size of a TOAST chunk:")) !=
NULL)
465 {
467
470
471 p++;
474 }
476 {
478
481
482 p++;
485 }
487 {
489
492
493 p++;
496 }
498 {
500
503
504 p++;
507 }
509 {
511
514
515
516 p++;
517 while (
isspace((
unsigned char) *p))
518 p++;
519
520
521 if (
strcmp(p,
"signed") != 0 &&
strcmp(p,
"unsigned") != 0)
523
524 cluster->controldata.default_char_signedness =
strcmp(p,
"signed") == 0;
526 }
527 }
528
530 if (rc != 0)
531 pg_fatal(
"could not get control data using %s: %s",
533
534
535
536
537
548 if (lang)
550 else
558 else
560
570
571
572
573
574
575
576
578 {
580 {
584 }
585 }
586
587
588
589
590
591
593 {
595#if CHAR_MIN != 0
596 cluster->controldata.default_char_signedness =
true;
597#else
598 cluster->controldata.default_char_signedness =
false;
599#endif
600 }
601
602
616 {
619 "The source cluster lacks some required control information:");
620 else
622 "The target cluster lacks some required control information:");
623
626
629
632
636
639
642
645
648
651
654
657
660
663
666
669
672
676
679
680
683
684
687
688 pg_fatal(
"Cannot continue without required control information, terminating");
689 }
690}
#define Assert(condition)
char * pg_strdup(const char *in)
static char * lc_messages
static char * lc_monetary
#define LARGE_OBJECT_SIZE_PG_CONTROL_VER
#define MULTIXACT_FORMATCHANGE_CAT_VER
void void unsigned int str2uint(const char *str)
#define GET_MAJOR_VERSION(v)
#define DEFAULT_CHAR_SIGNEDNESS_CAT_VER
size_t strlcpy(char *dst, const char *src, size_t siz)
int pg_strip_crlf(char *str)
char * wait_result_to_str(int exitstatus)