]> granicus.if.org Git - postgresql/blob - src/bin/pg_upgrade/controldata.c
Revert "Allow on-line enabling and disabling of data checksums"
[postgresql] / src / bin / pg_upgrade / controldata.c
1 /*
2  *      controldata.c
3  *
4  *      controldata functions
5  *
6  *      Copyright (c) 2010-2018, PostgreSQL Global Development Group
7  *      src/bin/pg_upgrade/controldata.c
8  */
9
10 #include "postgres_fe.h"
11
12 #include "pg_upgrade.h"
13
14 #include <ctype.h>
15
16 /*
17  * get_control_data()
18  *
19  * gets pg_control information in "ctrl". Assumes that bindir and
20  * datadir are valid absolute paths to postgresql bin and pgdata
21  * directories respectively *and* pg_resetwal is version compatible
22  * with datadir. The main purpose of this function is to get pg_control
23  * data in a version independent manner.
24  *
25  * The approach taken here is to invoke pg_resetwal with -n option
26  * and then pipe its output. With little string parsing we get the
27  * pg_control data.  pg_resetwal cannot be run while the server is running
28  * so we use pg_controldata;  pg_controldata doesn't provide all the fields
29  * we need to actually perform the upgrade, but it provides enough for
30  * check mode.  We do not implement pg_resetwal -n because it is hard to
31  * return valid xid data for a running server.
32  */
33 void
34 get_control_data(ClusterInfo *cluster, bool live_check)
35 {
36         char            cmd[MAXPGPATH];
37         char            bufin[MAX_STRING];
38         FILE       *output;
39         char       *p;
40         bool            got_tli = false;
41         bool            got_log_id = false;
42         bool            got_log_seg = false;
43         bool            got_xid = false;
44         bool            got_oid = false;
45         bool            got_multi = false;
46         bool            got_oldestmulti = false;
47         bool            got_mxoff = false;
48         bool            got_nextxlogfile = false;
49         bool            got_float8_pass_by_value = false;
50         bool            got_align = false;
51         bool            got_blocksz = false;
52         bool            got_largesz = false;
53         bool            got_walsz = false;
54         bool            got_walseg = false;
55         bool            got_ident = false;
56         bool            got_index = false;
57         bool            got_toast = false;
58         bool            got_large_object = false;
59         bool            got_date_is_int = false;
60         bool            got_data_checksum_version = false;
61         char       *lc_collate = NULL;
62         char       *lc_ctype = NULL;
63         char       *lc_monetary = NULL;
64         char       *lc_numeric = NULL;
65         char       *lc_time = NULL;
66         char       *lang = NULL;
67         char       *language = NULL;
68         char       *lc_all = NULL;
69         char       *lc_messages = NULL;
70         uint32          tli = 0;
71         uint32          logid = 0;
72         uint32          segno = 0;
73         char       *resetwal_bin;
74
75
76         /*
77          * Because we test the pg_resetwal output as strings, it has to be in
78          * English.  Copied from pg_regress.c.
79          */
80         if (getenv("LC_COLLATE"))
81                 lc_collate = pg_strdup(getenv("LC_COLLATE"));
82         if (getenv("LC_CTYPE"))
83                 lc_ctype = pg_strdup(getenv("LC_CTYPE"));
84         if (getenv("LC_MONETARY"))
85                 lc_monetary = pg_strdup(getenv("LC_MONETARY"));
86         if (getenv("LC_NUMERIC"))
87                 lc_numeric = pg_strdup(getenv("LC_NUMERIC"));
88         if (getenv("LC_TIME"))
89                 lc_time = pg_strdup(getenv("LC_TIME"));
90         if (getenv("LANG"))
91                 lang = pg_strdup(getenv("LANG"));
92         if (getenv("LANGUAGE"))
93                 language = pg_strdup(getenv("LANGUAGE"));
94         if (getenv("LC_ALL"))
95                 lc_all = pg_strdup(getenv("LC_ALL"));
96         if (getenv("LC_MESSAGES"))
97                 lc_messages = pg_strdup(getenv("LC_MESSAGES"));
98
99         pg_putenv("LC_COLLATE", NULL);
100         pg_putenv("LC_CTYPE", NULL);
101         pg_putenv("LC_MONETARY", NULL);
102         pg_putenv("LC_NUMERIC", NULL);
103         pg_putenv("LC_TIME", NULL);
104         pg_putenv("LANG",
105 #ifndef WIN32
106                           NULL);
107 #else
108         /* On Windows the default locale cannot be English, so force it */
109                           "en");
110 #endif
111         pg_putenv("LANGUAGE", NULL);
112         pg_putenv("LC_ALL", NULL);
113         pg_putenv("LC_MESSAGES", "C");
114
115         /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
116         if (GET_MAJOR_VERSION(cluster->bin_version) < 1000)
117                 resetwal_bin = "pg_resetxlog\" -n";
118         else
119                 resetwal_bin = "pg_resetwal\" -n";
120         snprintf(cmd, sizeof(cmd), "\"%s/%s \"%s\"",
121                          cluster->bindir,
122                          live_check ? "pg_controldata\"" : resetwal_bin,
123                          cluster->pgdata);
124         fflush(stdout);
125         fflush(stderr);
126
127         if ((output = popen(cmd, "r")) == NULL)
128                 pg_fatal("could not get control data using %s: %s\n",
129                                  cmd, strerror(errno));
130
131         /* Only in <= 9.2 */
132         if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
133         {
134                 cluster->controldata.data_checksum_version = 0;
135                 got_data_checksum_version = true;
136         }
137
138         /* we have the result of cmd in "output". so parse it line by line now */
139         while (fgets(bufin, sizeof(bufin), output))
140         {
141                 pg_log(PG_VERBOSE, "%s", bufin);
142
143                 if ((p = strstr(bufin, "pg_control version number:")) != NULL)
144                 {
145                         p = strchr(p, ':');
146
147                         if (p == NULL || strlen(p) <= 1)
148                                 pg_fatal("%d: pg_resetwal problem\n", __LINE__);
149
150                         p++;                            /* remove ':' char */
151                         cluster->controldata.ctrl_ver = str2uint(p);
152                 }
153                 else if ((p = strstr(bufin, "Catalog version number:")) != NULL)
154                 {
155                         p = strchr(p, ':');
156
157                         if (p == NULL || strlen(p) <= 1)
158                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
159
160                         p++;                            /* remove ':' char */
161                         cluster->controldata.cat_ver = str2uint(p);
162                 }
163                 else if ((p = strstr(bufin, "Latest checkpoint's TimeLineID:")) != NULL)
164                 {
165                         p = strchr(p, ':');
166
167                         if (p == NULL || strlen(p) <= 1)
168                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
169
170                         p++;                            /* remove ':' char */
171                         tli = str2uint(p);
172                         got_tli = true;
173                 }
174                 else if ((p = strstr(bufin, "First log file ID after reset:")) != NULL)
175                 {
176                         p = strchr(p, ':');
177
178                         if (p == NULL || strlen(p) <= 1)
179                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
180
181                         p++;                            /* remove ':' char */
182                         logid = str2uint(p);
183                         got_log_id = true;
184                 }
185                 else if ((p = strstr(bufin, "First log file segment after reset:")) != NULL)
186                 {
187                         p = strchr(p, ':');
188
189                         if (p == NULL || strlen(p) <= 1)
190                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
191
192                         p++;                            /* remove ':' char */
193                         segno = str2uint(p);
194                         got_log_seg = true;
195                 }
196                 else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
197                 {
198                         p = strchr(p, ':');
199
200                         if (p == NULL || strlen(p) <= 1)
201                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
202
203                         p++;                            /* remove ':' char */
204                         cluster->controldata.chkpnt_nxtepoch = str2uint(p);
205
206                         /*
207                          * Delimiter changed from '/' to ':' in 9.6.  We don't test for
208                          * the catalog version of the change because the catalog version
209                          * is pulled from pg_controldata too, and it isn't worth adding an
210                          * order dependency for this --- we just check the string.
211                          */
212                         if (strchr(p, '/') != NULL)
213                                 p = strchr(p, '/');
214                         else if (GET_MAJOR_VERSION(cluster->major_version) >= 906)
215                                 p = strchr(p, ':');
216                         else
217                                 p = NULL;
218
219                         if (p == NULL || strlen(p) <= 1)
220                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
221
222                         p++;                            /* remove '/' or ':' char */
223                         cluster->controldata.chkpnt_nxtxid = str2uint(p);
224                         got_xid = true;
225                 }
226                 else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
227                 {
228                         p = strchr(p, ':');
229
230                         if (p == NULL || strlen(p) <= 1)
231                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
232
233                         p++;                            /* remove ':' char */
234                         cluster->controldata.chkpnt_nxtoid = str2uint(p);
235                         got_oid = true;
236                 }
237                 else if ((p = strstr(bufin, "Latest checkpoint's NextMultiXactId:")) != NULL)
238                 {
239                         p = strchr(p, ':');
240
241                         if (p == NULL || strlen(p) <= 1)
242                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
243
244                         p++;                            /* remove ':' char */
245                         cluster->controldata.chkpnt_nxtmulti = str2uint(p);
246                         got_multi = true;
247                 }
248                 else if ((p = strstr(bufin, "Latest checkpoint's oldestMultiXid:")) != NULL)
249                 {
250                         p = strchr(p, ':');
251
252                         if (p == NULL || strlen(p) <= 1)
253                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
254
255                         p++;                            /* remove ':' char */
256                         cluster->controldata.chkpnt_oldstMulti = str2uint(p);
257                         got_oldestmulti = true;
258                 }
259                 else if ((p = strstr(bufin, "Latest checkpoint's NextMultiOffset:")) != NULL)
260                 {
261                         p = strchr(p, ':');
262
263                         if (p == NULL || strlen(p) <= 1)
264                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
265
266                         p++;                            /* remove ':' char */
267                         cluster->controldata.chkpnt_nxtmxoff = str2uint(p);
268                         got_mxoff = true;
269                 }
270                 else if ((p = strstr(bufin, "First log segment after reset:")) != NULL)
271                 {
272                         /* Skip the colon and any whitespace after it */
273                         p = strchr(p, ':');
274                         if (p == NULL || strlen(p) <= 1)
275                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
276                         p = strpbrk(p, "01234567890ABCDEF");
277                         if (p == NULL || strlen(p) <= 1)
278                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
279
280                         /* Make sure it looks like a valid WAL file name */
281                         if (strspn(p, "0123456789ABCDEF") != 24)
282                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
283
284                         strlcpy(cluster->controldata.nextxlogfile, p, 25);
285                         got_nextxlogfile = true;
286                 }
287                 else if ((p = strstr(bufin, "Float8 argument passing:")) != NULL)
288                 {
289                         p = strchr(p, ':');
290
291                         if (p == NULL || strlen(p) <= 1)
292                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
293
294                         p++;                            /* remove ':' char */
295                         /* used later for contrib check */
296                         cluster->controldata.float8_pass_by_value = strstr(p, "by value") != NULL;
297                         got_float8_pass_by_value = true;
298                 }
299                 else if ((p = strstr(bufin, "Maximum data alignment:")) != NULL)
300                 {
301                         p = strchr(p, ':');
302
303                         if (p == NULL || strlen(p) <= 1)
304                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
305
306                         p++;                            /* remove ':' char */
307                         cluster->controldata.align = str2uint(p);
308                         got_align = true;
309                 }
310                 else if ((p = strstr(bufin, "Database block size:")) != NULL)
311                 {
312                         p = strchr(p, ':');
313
314                         if (p == NULL || strlen(p) <= 1)
315                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
316
317                         p++;                            /* remove ':' char */
318                         cluster->controldata.blocksz = str2uint(p);
319                         got_blocksz = true;
320                 }
321                 else if ((p = strstr(bufin, "Blocks per segment of large relation:")) != NULL)
322                 {
323                         p = strchr(p, ':');
324
325                         if (p == NULL || strlen(p) <= 1)
326                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
327
328                         p++;                            /* remove ':' char */
329                         cluster->controldata.largesz = str2uint(p);
330                         got_largesz = true;
331                 }
332                 else if ((p = strstr(bufin, "WAL block size:")) != NULL)
333                 {
334                         p = strchr(p, ':');
335
336                         if (p == NULL || strlen(p) <= 1)
337                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
338
339                         p++;                            /* remove ':' char */
340                         cluster->controldata.walsz = str2uint(p);
341                         got_walsz = true;
342                 }
343                 else if ((p = strstr(bufin, "Bytes per WAL segment:")) != NULL)
344                 {
345                         p = strchr(p, ':');
346
347                         if (p == NULL || strlen(p) <= 1)
348                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
349
350                         p++;                            /* remove ':' char */
351                         cluster->controldata.walseg = str2uint(p);
352                         got_walseg = true;
353                 }
354                 else if ((p = strstr(bufin, "Maximum length of identifiers:")) != NULL)
355                 {
356                         p = strchr(p, ':');
357
358                         if (p == NULL || strlen(p) <= 1)
359                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
360
361                         p++;                            /* remove ':' char */
362                         cluster->controldata.ident = str2uint(p);
363                         got_ident = true;
364                 }
365                 else if ((p = strstr(bufin, "Maximum columns in an index:")) != NULL)
366                 {
367                         p = strchr(p, ':');
368
369                         if (p == NULL || strlen(p) <= 1)
370                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
371
372                         p++;                            /* remove ':' char */
373                         cluster->controldata.index = str2uint(p);
374                         got_index = true;
375                 }
376                 else if ((p = strstr(bufin, "Maximum size of a TOAST chunk:")) != NULL)
377                 {
378                         p = strchr(p, ':');
379
380                         if (p == NULL || strlen(p) <= 1)
381                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
382
383                         p++;                            /* remove ':' char */
384                         cluster->controldata.toast = str2uint(p);
385                         got_toast = true;
386                 }
387                 else if ((p = strstr(bufin, "Size of a large-object chunk:")) != NULL)
388                 {
389                         p = strchr(p, ':');
390
391                         if (p == NULL || strlen(p) <= 1)
392                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
393
394                         p++;                            /* remove ':' char */
395                         cluster->controldata.large_object = str2uint(p);
396                         got_large_object = true;
397                 }
398                 else if ((p = strstr(bufin, "Date/time type storage:")) != NULL)
399                 {
400                         p = strchr(p, ':');
401
402                         if (p == NULL || strlen(p) <= 1)
403                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
404
405                         p++;                            /* remove ':' char */
406                         cluster->controldata.date_is_int = strstr(p, "64-bit integers") != NULL;
407                         got_date_is_int = true;
408                 }
409                 else if ((p = strstr(bufin, "checksum")) != NULL)
410                 {
411                         p = strchr(p, ':');
412
413                         if (p == NULL || strlen(p) <= 1)
414                                 pg_fatal("%d: controldata retrieval problem\n", __LINE__);
415
416                         p++;                            /* remove ':' char */
417                         /* used later for contrib check */
418                         cluster->controldata.data_checksum_version = str2uint(p);
419                         got_data_checksum_version = true;
420                 }
421         }
422
423         pclose(output);
424
425         /*
426          * Restore environment variables
427          */
428         pg_putenv("LC_COLLATE", lc_collate);
429         pg_putenv("LC_CTYPE", lc_ctype);
430         pg_putenv("LC_MONETARY", lc_monetary);
431         pg_putenv("LC_NUMERIC", lc_numeric);
432         pg_putenv("LC_TIME", lc_time);
433         pg_putenv("LANG", lang);
434         pg_putenv("LANGUAGE", language);
435         pg_putenv("LC_ALL", lc_all);
436         pg_putenv("LC_MESSAGES", lc_messages);
437
438         pg_free(lc_collate);
439         pg_free(lc_ctype);
440         pg_free(lc_monetary);
441         pg_free(lc_numeric);
442         pg_free(lc_time);
443         pg_free(lang);
444         pg_free(language);
445         pg_free(lc_all);
446         pg_free(lc_messages);
447
448         /*
449          * Before 9.3, pg_resetwal reported the xlogid and segno of the first log
450          * file after reset as separate lines. Starting with 9.3, it reports the
451          * WAL file name. If the old cluster is older than 9.3, we construct the
452          * WAL file name from the xlogid and segno.
453          */
454         if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
455         {
456                 if (got_tli && got_log_id && got_log_seg)
457                 {
458                         snprintf(cluster->controldata.nextxlogfile, 25, "%08X%08X%08X",
459                                          tli, logid, segno);
460                         got_nextxlogfile = true;
461                 }
462         }
463
464         /* verify that we got all the mandatory pg_control data */
465         if (!got_xid || !got_oid ||
466                 !got_multi ||
467                 (!got_oldestmulti &&
468                  cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
469                 !got_mxoff || (!live_check && !got_nextxlogfile) ||
470                 !got_float8_pass_by_value || !got_align || !got_blocksz ||
471                 !got_largesz || !got_walsz || !got_walseg || !got_ident ||
472                 !got_index || !got_toast ||
473                 (!got_large_object &&
474                  cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
475                 !got_date_is_int || !got_data_checksum_version)
476         {
477                 if (cluster == &old_cluster)
478                         pg_log(PG_REPORT,
479                                    "The source cluster lacks some required control information:\n");
480                 else
481                         pg_log(PG_REPORT,
482                                    "The target cluster lacks some required control information:\n");
483
484                 if (!got_xid)
485                         pg_log(PG_REPORT, "  checkpoint next XID\n");
486
487                 if (!got_oid)
488                         pg_log(PG_REPORT, "  latest checkpoint next OID\n");
489
490                 if (!got_multi)
491                         pg_log(PG_REPORT, "  latest checkpoint next MultiXactId\n");
492
493                 if (!got_oldestmulti &&
494                         cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
495                         pg_log(PG_REPORT, "  latest checkpoint oldest MultiXactId\n");
496
497                 if (!got_mxoff)
498                         pg_log(PG_REPORT, "  latest checkpoint next MultiXactOffset\n");
499
500                 if (!live_check && !got_nextxlogfile)
501                         pg_log(PG_REPORT, "  first WAL segment after reset\n");
502
503                 if (!got_float8_pass_by_value)
504                         pg_log(PG_REPORT, "  float8 argument passing method\n");
505
506                 if (!got_align)
507                         pg_log(PG_REPORT, "  maximum alignment\n");
508
509                 if (!got_blocksz)
510                         pg_log(PG_REPORT, "  block size\n");
511
512                 if (!got_largesz)
513                         pg_log(PG_REPORT, "  large relation segment size\n");
514
515                 if (!got_walsz)
516                         pg_log(PG_REPORT, "  WAL block size\n");
517
518                 if (!got_walseg)
519                         pg_log(PG_REPORT, "  WAL segment size\n");
520
521                 if (!got_ident)
522                         pg_log(PG_REPORT, "  maximum identifier length\n");
523
524                 if (!got_index)
525                         pg_log(PG_REPORT, "  maximum number of indexed columns\n");
526
527                 if (!got_toast)
528                         pg_log(PG_REPORT, "  maximum TOAST chunk size\n");
529
530                 if (!got_large_object &&
531                         cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
532                         pg_log(PG_REPORT, "  large-object chunk size\n");
533
534                 if (!got_date_is_int)
535                         pg_log(PG_REPORT, "  dates/times are integers?\n");
536
537                 /* value added in Postgres 9.3 */
538                 if (!got_data_checksum_version)
539                         pg_log(PG_REPORT, "  data checksum version\n");
540
541                 pg_fatal("Cannot continue without required control information, terminating\n");
542         }
543 }
544
545
546 /*
547  * check_control_data()
548  *
549  * check to make sure the control data settings are compatible
550  */
551 void
552 check_control_data(ControlData *oldctrl,
553                                    ControlData *newctrl)
554 {
555         if (oldctrl->align == 0 || oldctrl->align != newctrl->align)
556                 pg_fatal("old and new pg_controldata alignments are invalid or do not match\n"
557                                  "Likely one cluster is a 32-bit install, the other 64-bit\n");
558
559         if (oldctrl->blocksz == 0 || oldctrl->blocksz != newctrl->blocksz)
560                 pg_fatal("old and new pg_controldata block sizes are invalid or do not match\n");
561
562         if (oldctrl->largesz == 0 || oldctrl->largesz != newctrl->largesz)
563                 pg_fatal("old and new pg_controldata maximum relation segment sizes are invalid or do not match\n");
564
565         if (oldctrl->walsz == 0 || oldctrl->walsz != newctrl->walsz)
566                 pg_fatal("old and new pg_controldata WAL block sizes are invalid or do not match\n");
567
568         if (oldctrl->walseg == 0 || oldctrl->walseg != newctrl->walseg)
569                 pg_fatal("old and new pg_controldata WAL segment sizes are invalid or do not match\n");
570
571         if (oldctrl->ident == 0 || oldctrl->ident != newctrl->ident)
572                 pg_fatal("old and new pg_controldata maximum identifier lengths are invalid or do not match\n");
573
574         if (oldctrl->index == 0 || oldctrl->index != newctrl->index)
575                 pg_fatal("old and new pg_controldata maximum indexed columns are invalid or do not match\n");
576
577         if (oldctrl->toast == 0 || oldctrl->toast != newctrl->toast)
578                 pg_fatal("old and new pg_controldata maximum TOAST chunk sizes are invalid or do not match\n");
579
580         /* large_object added in 9.5, so it might not exist in the old cluster */
581         if (oldctrl->large_object != 0 &&
582                 oldctrl->large_object != newctrl->large_object)
583                 pg_fatal("old and new pg_controldata large-object chunk sizes are invalid or do not match\n");
584
585         if (oldctrl->date_is_int != newctrl->date_is_int)
586                 pg_fatal("old and new pg_controldata date/time storage types do not match\n");
587
588         /*
589          * float8_pass_by_value does not need to match, but is used in
590          * check_for_isn_and_int8_passing_mismatch().
591          */
592
593         /*
594          * We might eventually allow upgrades from checksum to no-checksum
595          * clusters.
596          */
597         if (oldctrl->data_checksum_version == 0 &&
598                 newctrl->data_checksum_version != 0)
599                 pg_fatal("old cluster does not use data checksums but the new one does\n");
600         else if (oldctrl->data_checksum_version != 0 &&
601                          newctrl->data_checksum_version == 0)
602                 pg_fatal("old cluster uses data checksums but the new one does not\n");
603         else if (oldctrl->data_checksum_version != newctrl->data_checksum_version)
604                 pg_fatal("old and new cluster pg_controldata checksum versions do not match\n");
605 }
606
607
608 void
609 disable_old_cluster(void)
610 {
611         char            old_path[MAXPGPATH],
612                                 new_path[MAXPGPATH];
613
614         /* rename pg_control so old server cannot be accidentally started */
615         prep_status("Adding \".old\" suffix to old global/pg_control");
616
617         snprintf(old_path, sizeof(old_path), "%s/global/pg_control", old_cluster.pgdata);
618         snprintf(new_path, sizeof(new_path), "%s/global/pg_control.old", old_cluster.pgdata);
619         if (pg_mv_file(old_path, new_path) != 0)
620                 pg_fatal("Unable to rename %s to %s.\n", old_path, new_path);
621         check_ok();
622
623         pg_log(PG_REPORT, "\n"
624                    "If you want to start the old cluster, you will need to remove\n"
625                    "the \".old\" suffix from %s/global/pg_control.old.\n"
626                    "Because \"link\" mode was used, the old cluster cannot be safely\n"
627                    "started once the new cluster has been started.\n\n", old_cluster.pgdata);
628 }