39{
43 char *p;
81 int rc;
83
84
85
86
87
104 if (
getenv(
"LC_MESSAGES"))
106
112#ifndef WIN32
114#else
115
117#endif
120 setenv(
"LC_MESSAGES",
"C", 1);
121
122
123
124
126 {
127
128 snprintf(cmd,
sizeof(cmd),
"\"%s/pg_controldata\" \"%s\"",
131
133 pg_fatal(
"could not get control data using %s: %m", cmd);
134
135
137 {
139 {
141
144
145 p++;
146
147
148
149
150
151
152
153
154
155
157 while (*p == ' ')
158 p++;
159 if (
strcmp(p,
"shut down in recovery") == 0)
160 {
162 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.");
163 else
164 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.");
165 }
166 else if (
strcmp(p,
"shut down") != 0)
167 {
169 pg_fatal(
"The source cluster was not shut down cleanly, state reported as: \"%s\"", p);
170 else
171 pg_fatal(
"The target cluster was not shut down cleanly, state reported as: \"%s\"", p);
172 }
174 }
175 }
176
178 if (rc != 0)
179 pg_fatal(
"could not get control data using %s: %s",
181
183 {
185 pg_fatal(
"The source cluster lacks cluster state information:");
186 else
187 pg_fatal(
"The target cluster lacks cluster state information:");
188 }
189 }
190
191
194 else
196 snprintf(cmd,
sizeof(cmd),
"\"%s/%s \"%s\"",
201
203 pg_fatal(
"could not get control data using %s: %m", cmd);
204
205
207 {
208 cluster->controldata.data_checksum_version = 0;
210 }
211
212
214 {
215
218
220 {
222
225
226 p++;
228 }
230 {
232
235
236 p++;
238 }
239 else if ((p =
strstr(
bufin,
"Latest checkpoint's TimeLineID:")) !=
NULL)
240 {
242
245
246 p++;
249 }
250 else if ((p =
strstr(
bufin,
"First log file ID after reset:")) !=
NULL)
251 {
253
256
257 p++;
260 }
261 else if ((p =
strstr(
bufin,
"First log file segment after reset:")) !=
NULL)
262 {
264
267
268 p++;
271 }
273 {
275
278
279 p++;
281
282
283
284
285
286
287
292 else
294
297
298 p++;
301 }
303 {
305
308
309 p++;
312 }
313 else if ((p =
strstr(
bufin,
"Latest checkpoint's NextMultiXactId:")) !=
NULL)
314 {
316
319
320 p++;
323 }
324 else if ((p =
strstr(
bufin,
"Latest checkpoint's oldestXID:")) !=
NULL)
325 {
327
330
331 p++;
334 }
335 else if ((p =
strstr(
bufin,
"Latest checkpoint's oldestMultiXid:")) !=
NULL)
336 {
338
341
342 p++;
345 }
346 else if ((p =
strstr(
bufin,
"Latest checkpoint's NextMultiOffset:")) !=
NULL)
347 {
349
352
353 p++;
356 }
357 else if ((p =
strstr(
bufin,
"First log segment after reset:")) !=
NULL)
358 {
359
363 p =
strpbrk(p,
"01234567890ABCDEF");
366
367
368 if (
strspn(p,
"0123456789ABCDEF") != 24)
370
373 }
375 {
377
380
381 p++;
382
385 }
387 {
389
392
393 p++;
396 }
398 {
400
403
404 p++;
407 }
408 else if ((p =
strstr(
bufin,
"Blocks per segment of large relation:")) !=
NULL)
409 {
411
414
415 p++;
418 }
420 {
422
425
426 p++;
429 }
431 {
433
436
437 p++;
440 }
441 else if ((p =
strstr(
bufin,
"Maximum length of identifiers:")) !=
NULL)
442 {
444
447
448 p++;
451 }
453 {
455
458
459 p++;
462 }
463 else if ((p =
strstr(
bufin,
"Maximum size of a TOAST chunk:")) !=
NULL)
464 {
466
469
470 p++;
473 }
475 {
477
480
481 p++;
484 }
486 {
488
491
492 p++;
495 }
497 {
499
502
503 p++;
506 }
508 {
510
513
514
515 p++;
516 while (
isspace((
unsigned char) *p))
517 p++;
518
519
520 if (
strcmp(p,
"signed") != 0 &&
strcmp(p,
"unsigned") != 0)
522
523 cluster->controldata.default_char_signedness =
strcmp(p,
"signed") == 0;
525 }
526 }
527
529 if (rc != 0)
530 pg_fatal(
"could not get control data using %s: %s",
532
533
534
535
536
547 if (lang)
549 else
557 else
559
569
570
571
572
573
574
575
577 {
579 {
583 }
584 }
585
586
587
588
589
590
592 {
594#if CHAR_MIN != 0
595 cluster->controldata.default_char_signedness =
true;
596#else
597 cluster->controldata.default_char_signedness =
false;
598#endif
599 }
600
601
615 {
618 "The source cluster lacks some required control information:");
619 else
621 "The target cluster lacks some required control information:");
622
625
628
631
635
638
641
644
647
650
653
656
659
662
665
668
671
675
678
679
682
683
686
687 pg_fatal(
"Cannot continue without required control information, terminating");
688 }
689}
#define Assert(condition)
void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
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)