LCOV - differential code coverage report
Current view: top level - src/bin/pg_upgrade - controldata.c (source / functions) Coverage Total Hit LBC UBC GBC CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 67.8 % 441 299 142 2 297
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 3 3 3
Baseline: lcov-20250906-005545-baseline Branches: 47.8 % 414 198 2 214 2 196
Baseline Date: 2025-09-05 08:21:35 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 72.4 % 29 21 8 21
(360..) days: 67.5 % 412 278 134 2 276
Function coverage date bins:
(30,360] days: 100.0 % 1 1 1
(360..) days: 100.0 % 2 2 2
Branch coverage date bins:
(30,360] days: 53.3 % 30 16 14 16
(360..) days: 47.4 % 384 182 2 200 2 180

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*
                                  2                 :                :  *  controldata.c
                                  3                 :                :  *
                                  4                 :                :  *  controldata functions
                                  5                 :                :  *
                                  6                 :                :  *  Copyright (c) 2010-2025, PostgreSQL Global Development Group
                                  7                 :                :  *  src/bin/pg_upgrade/controldata.c
                                  8                 :                :  */
                                  9                 :                : 
                                 10                 :                : #include "postgres_fe.h"
                                 11                 :                : 
                                 12                 :                : #include <ctype.h>
                                 13                 :                : #include <limits.h>               /* for CHAR_MIN */
                                 14                 :                : 
                                 15                 :                : #include "access/xlog_internal.h"
                                 16                 :                : #include "common/string.h"
                                 17                 :                : #include "pg_upgrade.h"
                                 18                 :                : 
                                 19                 :                : 
                                 20                 :                : /*
                                 21                 :                :  * get_control_data()
                                 22                 :                :  *
                                 23                 :                :  * gets pg_control information in "ctrl". Assumes that bindir and
                                 24                 :                :  * datadir are valid absolute paths to postgresql bin and pgdata
                                 25                 :                :  * directories respectively *and* pg_resetwal is version compatible
                                 26                 :                :  * with datadir. The main purpose of this function is to get pg_control
                                 27                 :                :  * data in a version independent manner.
                                 28                 :                :  *
                                 29                 :                :  * The approach taken here is to invoke pg_resetwal with -n option
                                 30                 :                :  * and then pipe its output. With little string parsing we get the
                                 31                 :                :  * pg_control data.  pg_resetwal cannot be run while the server is running
                                 32                 :                :  * so we use pg_controldata;  pg_controldata doesn't provide all the fields
                                 33                 :                :  * we need to actually perform the upgrade, but it provides enough for
                                 34                 :                :  * check mode.  We do not implement pg_resetwal -n because it is hard to
                                 35                 :                :  * return valid xid data for a running server.
                                 36                 :                :  */
                                 37                 :                : void
  407 nathan@postgresql.or       38                 :CBC          32 : get_control_data(ClusterInfo *cluster)
                                 39                 :                : {
                                 40                 :                :     char        cmd[MAXPGPATH];
                                 41                 :                :     char        bufin[MAX_STRING];
                                 42                 :                :     FILE       *output;
                                 43                 :                :     char       *p;
 3616 bruce@momjian.us           44                 :             32 :     bool        got_tli = false;
                                 45                 :             32 :     bool        got_log_id = false;
                                 46                 :             32 :     bool        got_log_seg = false;
 5596                            47                 :             32 :     bool        got_xid = false;
                                 48                 :             32 :     bool        got_oid = false;
 4609 alvherre@alvh.no-ip.       49                 :             32 :     bool        got_multi = false;
                                 50                 :             32 :     bool        got_oldestmulti = false;
 1503 bruce@momjian.us           51                 :             32 :     bool        got_oldestxid = false;
 3616                            52                 :             32 :     bool        got_mxoff = false;
                                 53                 :             32 :     bool        got_nextxlogfile = false;
                                 54                 :             32 :     bool        got_float8_pass_by_value = false;
 5596                            55                 :             32 :     bool        got_align = false;
                                 56                 :             32 :     bool        got_blocksz = false;
                                 57                 :             32 :     bool        got_largesz = false;
                                 58                 :             32 :     bool        got_walsz = false;
                                 59                 :             32 :     bool        got_walseg = false;
                                 60                 :             32 :     bool        got_ident = false;
                                 61                 :             32 :     bool        got_index = false;
                                 62                 :             32 :     bool        got_toast = false;
 4014                            63                 :             32 :     bool        got_large_object = false;
 5596                            64                 :             32 :     bool        got_date_is_int = false;
 4512 simon@2ndQuadrant.co       65                 :             32 :     bool        got_data_checksum_version = false;
 2597 bruce@momjian.us           66                 :             32 :     bool        got_cluster_state = false;
  197 msawada@postgresql.o       67                 :             32 :     bool        got_default_char_signedness = false;
 5478 bruce@momjian.us           68                 :             32 :     char       *lc_collate = NULL;
                                 69                 :             32 :     char       *lc_ctype = NULL;
                                 70                 :             32 :     char       *lc_monetary = NULL;
                                 71                 :             32 :     char       *lc_numeric = NULL;
                                 72                 :             32 :     char       *lc_time = NULL;
 5596                            73                 :             32 :     char       *lang = NULL;
 5478                            74                 :             32 :     char       *language = NULL;
                                 75                 :             32 :     char       *lc_all = NULL;
                                 76                 :             32 :     char       *lc_messages = NULL;
 3616                            77                 :             32 :     uint32      tli = 0;
 4820 heikki.linnakangas@i       78                 :             32 :     uint32      logid = 0;
                                 79                 :             32 :     uint32      segno = 0;
                                 80                 :                :     char       *resetwal_bin;
                                 81                 :                :     int         rc;
  407 nathan@postgresql.or       82   [ +  +  -  + ]:             32 :     bool        live_check = (cluster == &old_cluster && user_opts.live_check);
                                 83                 :                : 
                                 84                 :                :     /*
                                 85                 :                :      * Because we test the pg_resetwal output as strings, it has to be in
                                 86                 :                :      * English.  Copied from pg_regress.c.
                                 87                 :                :      */
 5478 bruce@momjian.us           88         [ -  + ]:             32 :     if (getenv("LC_COLLATE"))
 5436 bruce@momjian.us           89                 :UBC           0 :         lc_collate = pg_strdup(getenv("LC_COLLATE"));
 5478 bruce@momjian.us           90         [ -  + ]:CBC          32 :     if (getenv("LC_CTYPE"))
 5436 bruce@momjian.us           91                 :UBC           0 :         lc_ctype = pg_strdup(getenv("LC_CTYPE"));
 5478 bruce@momjian.us           92         [ -  + ]:CBC          32 :     if (getenv("LC_MONETARY"))
 5436 bruce@momjian.us           93                 :UBC           0 :         lc_monetary = pg_strdup(getenv("LC_MONETARY"));
 5478 bruce@momjian.us           94         [ +  - ]:CBC          32 :     if (getenv("LC_NUMERIC"))
 5436 bruce@momjian.us           95                 :GBC          32 :         lc_numeric = pg_strdup(getenv("LC_NUMERIC"));
 5478 bruce@momjian.us           96         [ -  + ]:CBC          32 :     if (getenv("LC_TIME"))
 5436 bruce@momjian.us           97                 :UBC           0 :         lc_time = pg_strdup(getenv("LC_TIME"));
 5596 bruce@momjian.us           98         [ +  - ]:CBC          32 :     if (getenv("LANG"))
 5436                            99                 :             32 :         lang = pg_strdup(getenv("LANG"));
 5478                           100         [ -  + ]:             32 :     if (getenv("LANGUAGE"))
 5436 bruce@momjian.us          101                 :UBC           0 :         language = pg_strdup(getenv("LANGUAGE"));
 5478 bruce@momjian.us          102         [ -  + ]:CBC          32 :     if (getenv("LC_ALL"))
 5436 bruce@momjian.us          103                 :UBC           0 :         lc_all = pg_strdup(getenv("LC_ALL"));
 5478 bruce@momjian.us          104         [ +  - ]:CBC          32 :     if (getenv("LC_MESSAGES"))
 5436                           105                 :             32 :         lc_messages = pg_strdup(getenv("LC_MESSAGES"));
                                106                 :                : 
 1711 tgl@sss.pgh.pa.us         107                 :             32 :     unsetenv("LC_COLLATE");
                                108                 :             32 :     unsetenv("LC_CTYPE");
                                109                 :             32 :     unsetenv("LC_MONETARY");
                                110                 :             32 :     unsetenv("LC_NUMERIC");
                                111                 :             32 :     unsetenv("LC_TIME");
                                112                 :                : #ifndef WIN32
                                113                 :             32 :     unsetenv("LANG");
                                114                 :                : #else
                                115                 :                :     /* On Windows the default locale may not be English, so force it */
                                116                 :                :     setenv("LANG", "en", 1);
                                117                 :                : #endif
                                118                 :             32 :     unsetenv("LANGUAGE");
                                119                 :             32 :     unsetenv("LC_ALL");
                                120                 :             32 :     setenv("LC_MESSAGES", "C", 1);
                                121                 :                : 
                                122                 :                :     /*
                                123                 :                :      * Check for clean shutdown
                                124                 :                :      */
 2594 bruce@momjian.us          125   [ -  +  -  - ]:             32 :     if (!live_check || cluster == &new_cluster)
                                126                 :                :     {
                                127                 :                :         /* only pg_controldata outputs the cluster state */
                                128                 :             32 :         snprintf(cmd, sizeof(cmd), "\"%s/pg_controldata\" \"%s\"",
                                129                 :                :                  cluster->bindir, cluster->pgdata);
 1104 tgl@sss.pgh.pa.us         130                 :             32 :         fflush(NULL);
                                131                 :                : 
 2594 bruce@momjian.us          132         [ -  + ]:             32 :         if ((output = popen(cmd, "r")) == NULL)
  543 michael@paquier.xyz       133                 :UBC           0 :             pg_fatal("could not get control data using %s: %m", cmd);
                                134                 :                : 
                                135                 :                :         /* we have the result of cmd in "output". so parse it line by line now */
 2594 bruce@momjian.us          136         [ +  + ]:CBC        1696 :         while (fgets(bufin, sizeof(bufin), output))
                                137                 :                :         {
                                138         [ +  + ]:           1632 :             if ((p = strstr(bufin, "Database cluster state:")) != NULL)
                                139                 :                :             {
                                140                 :             32 :                 p = strchr(p, ':');
                                141                 :                : 
                                142   [ +  -  -  + ]:             32 :                 if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         143                 :UBC           0 :                     pg_fatal("%d: database cluster state problem", __LINE__);
                                144                 :                : 
 2299 tgl@sss.pgh.pa.us         145                 :CBC          32 :                 p++;            /* remove ':' char */
                                146                 :                : 
                                147                 :                :                 /*
                                148                 :                :                  * We checked earlier for a postmaster lock file, and if we
                                149                 :                :                  * found one, we tried to start/stop the server to replay the
                                150                 :                :                  * WAL.  However, pg_ctl -m immediate doesn't leave a lock
                                151                 :                :                  * file, but does require WAL replay, so we check here that
                                152                 :                :                  * the server was shut down cleanly, from the controldata
                                153                 :                :                  * perspective.
                                154                 :                :                  */
                                155                 :                :                 /* Remove trailing newline and leading spaces */
  779 dgustafsson@postgres      156                 :             32 :                 (void) pg_strip_crlf(p);
 2594 bruce@momjian.us          157         [ +  + ]:            512 :                 while (*p == ' ')
                                158                 :            480 :                     p++;
  779 dgustafsson@postgres      159         [ -  + ]:             32 :                 if (strcmp(p, "shut down in recovery") == 0)
                                160                 :                :                 {
 2577 bruce@momjian.us          161         [ #  # ]:UBC           0 :                     if (cluster == &old_cluster)
 1152 tgl@sss.pgh.pa.us         162                 :              0 :                         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                 :              0 :                         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                 :                :                 }
  779 dgustafsson@postgres      166         [ -  + ]:CBC          32 :                 else if (strcmp(p, "shut down") != 0)
                                167                 :                :                 {
 2594 bruce@momjian.us          168         [ #  # ]:UBC           0 :                     if (cluster == &old_cluster)
  779 dgustafsson@postgres      169                 :              0 :                         pg_fatal("The source cluster was not shut down cleanly, state reported as: \"%s\"", p);
                                170                 :                :                     else
                                171                 :              0 :                         pg_fatal("The target cluster was not shut down cleanly, state reported as: \"%s\"", p);
                                172                 :                :                 }
 2594 bruce@momjian.us          173                 :CBC          32 :                 got_cluster_state = true;
                                174                 :                :             }
                                175                 :                :         }
                                176                 :                : 
 1026 peter@eisentraut.org      177                 :             32 :         rc = pclose(output);
                                178         [ -  + ]:             32 :         if (rc != 0)
 1026 peter@eisentraut.org      179                 :UBC           0 :             pg_fatal("could not get control data using %s: %s",
                                180                 :                :                      cmd, wait_result_to_str(rc));
                                181                 :                : 
 2594 bruce@momjian.us          182         [ -  + ]:CBC          32 :         if (!got_cluster_state)
                                183                 :                :         {
 2594 bruce@momjian.us          184         [ #  # ]:UBC           0 :             if (cluster == &old_cluster)
 1152 tgl@sss.pgh.pa.us         185                 :              0 :                 pg_fatal("The source cluster lacks cluster state information:");
                                186                 :                :             else
                                187                 :              0 :                 pg_fatal("The target cluster lacks cluster state information:");
                                188                 :                :         }
                                189                 :                :     }
                                190                 :                : 
                                191                 :                :     /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
 1796 bruce@momjian.us          192         [ -  + ]:CBC          32 :     if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
 3125 rhaas@postgresql.org      193                 :UBC           0 :         resetwal_bin = "pg_resetxlog\" -n";
                                194                 :                :     else
 3125 rhaas@postgresql.org      195                 :CBC          32 :         resetwal_bin = "pg_resetwal\" -n";
 4142 heikki.linnakangas@i      196         [ -  + ]:             32 :     snprintf(cmd, sizeof(cmd), "\"%s/%s \"%s\"",
                                197                 :                :              cluster->bindir,
                                198                 :                :              live_check ? "pg_controldata\"" : resetwal_bin,
                                199                 :                :              cluster->pgdata);
 1104 tgl@sss.pgh.pa.us         200                 :             32 :     fflush(NULL);
                                201                 :                : 
 5596 bruce@momjian.us          202         [ -  + ]:             32 :     if ((output = popen(cmd, "r")) == NULL)
  543 michael@paquier.xyz       203                 :UBC           0 :         pg_fatal("could not get control data using %s: %m", cmd);
                                204                 :                : 
                                205                 :                :     /* Only in <= 9.2 */
 4551 simon@2ndQuadrant.co      206         [ -  + ]:CBC          32 :     if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
                                207                 :                :     {
 4512 simon@2ndQuadrant.co      208                 :UBC           0 :         cluster->controldata.data_checksum_version = 0;
                                209                 :              0 :         got_data_checksum_version = true;
                                210                 :                :     }
                                211                 :                : 
                                212                 :                :     /* we have the result of cmd in "output". so parse it line by line now */
 5596 bruce@momjian.us          213         [ +  + ]:CBC        1184 :     while (fgets(bufin, sizeof(bufin), output))
                                214                 :                :     {
                                215                 :                :         /* In verbose mode, log each line */
 1152 tgl@sss.pgh.pa.us         216                 :           1152 :         pg_strip_crlf(bufin);
 4926 bruce@momjian.us          217                 :           1152 :         pg_log(PG_VERBOSE, "%s", bufin);
                                218                 :                : 
 5596                           219         [ +  + ]:           1152 :         if ((p = strstr(bufin, "pg_control version number:")) != NULL)
                                220                 :                :         {
                                221                 :             32 :             p = strchr(p, ':');
                                222                 :                : 
                                223   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         224                 :UBC           0 :                 pg_fatal("%d: pg_resetwal problem", __LINE__);
                                225                 :                : 
 4013 bruce@momjian.us          226                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           227                 :             32 :             cluster->controldata.ctrl_ver = str2uint(p);
                                228                 :                :         }
 5596                           229         [ +  + ]:           1120 :         else if ((p = strstr(bufin, "Catalog version number:")) != NULL)
                                230                 :                :         {
                                231                 :             32 :             p = strchr(p, ':');
                                232                 :                : 
                                233   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         234                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                235                 :                : 
 4013 bruce@momjian.us          236                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           237                 :             32 :             cluster->controldata.cat_ver = str2uint(p);
                                238                 :                :         }
 3616                           239         [ +  + ]:           1088 :         else if ((p = strstr(bufin, "Latest checkpoint's TimeLineID:")) != NULL)
                                240                 :                :         {
 5596                           241                 :             32 :             p = strchr(p, ':');
                                242                 :                : 
                                243   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         244                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                245                 :                : 
 4013 bruce@momjian.us          246                 :CBC          32 :             p++;                /* remove ':' char */
 3616                           247                 :             32 :             tli = str2uint(p);
                                248                 :             32 :             got_tli = true;
                                249                 :                :         }
                                250         [ -  + ]:           1056 :         else if ((p = strstr(bufin, "First log file ID after reset:")) != NULL)
                                251                 :                :         {
 5596 bruce@momjian.us          252                 :UBC           0 :             p = strchr(p, ':');
                                253                 :                : 
                                254   [ #  #  #  # ]:              0 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         255                 :              0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                256                 :                : 
 4013 bruce@momjian.us          257                 :              0 :             p++;                /* remove ':' char */
 3616                           258                 :              0 :             logid = str2uint(p);
                                259                 :              0 :             got_log_id = true;
                                260                 :                :         }
 3616 bruce@momjian.us          261         [ -  + ]:CBC        1056 :         else if ((p = strstr(bufin, "First log file segment after reset:")) != NULL)
                                262                 :                :         {
 5596 bruce@momjian.us          263                 :UBC           0 :             p = strchr(p, ':');
                                264                 :                : 
                                265   [ #  #  #  # ]:              0 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         266                 :              0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                267                 :                : 
 4013 bruce@momjian.us          268                 :              0 :             p++;                /* remove ':' char */
 3616                           269                 :              0 :             segno = str2uint(p);
                                270                 :              0 :             got_log_seg = true;
                                271                 :                :         }
 5596 bruce@momjian.us          272         [ +  + ]:CBC        1056 :         else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
                                273                 :                :         {
 4019                           274                 :             32 :             p = strchr(p, ':');
                                275                 :                : 
                                276   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         277                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                278                 :                : 
 4013 bruce@momjian.us          279                 :CBC          32 :             p++;                /* remove ':' char */
 4019                           280                 :             32 :             cluster->controldata.chkpnt_nxtepoch = str2uint(p);
                                281                 :                : 
                                282                 :                :             /*
                                283                 :                :              * Delimiter changed from '/' to ':' in 9.6.  We don't test for
                                284                 :                :              * the catalog version of the change because the catalog version
                                285                 :                :              * is pulled from pg_controldata too, and it isn't worth adding an
                                286                 :                :              * order dependency for this --- we just check the string.
                                287                 :                :              */
 3494 mail@joeconway.com        288         [ -  + ]:             32 :             if (strchr(p, '/') != NULL)
 3494 mail@joeconway.com        289                 :UBC           0 :                 p = strchr(p, '/');
 3494 mail@joeconway.com        290         [ +  - ]:CBC          32 :             else if (GET_MAJOR_VERSION(cluster->major_version) >= 906)
                                291                 :             32 :                 p = strchr(p, ':');
                                292                 :                :             else
 3494 mail@joeconway.com        293                 :UBC           0 :                 p = NULL;
                                294                 :                : 
 4019 bruce@momjian.us          295   [ +  -  -  + ]:CBC          32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         296                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                297                 :                : 
 3494 mail@joeconway.com        298                 :CBC          32 :             p++;                /* remove '/' or ':' char */
 4019 bruce@momjian.us          299                 :             32 :             cluster->controldata.chkpnt_nxtxid = str2uint(p);
 5596                           300                 :             32 :             got_xid = true;
                                301                 :                :         }
                                302         [ +  + ]:           1024 :         else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
                                303                 :                :         {
                                304                 :             32 :             p = strchr(p, ':');
                                305                 :                : 
                                306   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         307                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                308                 :                : 
 4013 bruce@momjian.us          309                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           310                 :             32 :             cluster->controldata.chkpnt_nxtoid = str2uint(p);
 5596                           311                 :             32 :             got_oid = true;
                                312                 :                :         }
 4609 alvherre@alvh.no-ip.      313         [ +  + ]:            992 :         else if ((p = strstr(bufin, "Latest checkpoint's NextMultiXactId:")) != NULL)
                                314                 :                :         {
                                315                 :             32 :             p = strchr(p, ':');
                                316                 :                : 
                                317   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         318                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                319                 :                : 
 4013 bruce@momjian.us          320                 :CBC          32 :             p++;                /* remove ':' char */
 4609 alvherre@alvh.no-ip.      321                 :             32 :             cluster->controldata.chkpnt_nxtmulti = str2uint(p);
                                322                 :             32 :             got_multi = true;
                                323                 :                :         }
 1503 bruce@momjian.us          324         [ +  + ]:            960 :         else if ((p = strstr(bufin, "Latest checkpoint's oldestXID:")) != NULL)
                                325                 :                :         {
                                326                 :             32 :             p = strchr(p, ':');
                                327                 :                : 
                                328   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         329                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                330                 :                : 
 1503 bruce@momjian.us          331                 :CBC          32 :             p++;                /* remove ':' char */
                                332                 :             32 :             cluster->controldata.chkpnt_oldstxid = str2uint(p);
                                333                 :             32 :             got_oldestxid = true;
                                334                 :                :         }
 4609 alvherre@alvh.no-ip.      335         [ +  + ]:            928 :         else if ((p = strstr(bufin, "Latest checkpoint's oldestMultiXid:")) != NULL)
                                336                 :                :         {
                                337                 :             32 :             p = strchr(p, ':');
                                338                 :                : 
                                339   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         340                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                341                 :                : 
 4013 bruce@momjian.us          342                 :CBC          32 :             p++;                /* remove ':' char */
 4609 alvherre@alvh.no-ip.      343                 :             32 :             cluster->controldata.chkpnt_oldstMulti = str2uint(p);
                                344                 :             32 :             got_oldestmulti = true;
                                345                 :                :         }
                                346         [ +  + ]:            896 :         else if ((p = strstr(bufin, "Latest checkpoint's NextMultiOffset:")) != NULL)
                                347                 :                :         {
                                348                 :             32 :             p = strchr(p, ':');
                                349                 :                : 
                                350   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         351                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                352                 :                : 
 4013 bruce@momjian.us          353                 :CBC          32 :             p++;                /* remove ':' char */
 4609 alvherre@alvh.no-ip.      354                 :             32 :             cluster->controldata.chkpnt_nxtmxoff = str2uint(p);
                                355                 :             32 :             got_mxoff = true;
                                356                 :                :         }
 1087 tgl@sss.pgh.pa.us         357         [ +  + ]:            864 :         else if ((p = strstr(bufin, "First log segment after reset:")) != NULL)
                                358                 :                :         {
                                359                 :                :             /* Skip the colon and any whitespace after it */
 3768 bruce@momjian.us          360                 :             32 :             p = strchr(p, ':');
                                361   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         362                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
 3768 bruce@momjian.us          363                 :CBC          32 :             p = strpbrk(p, "01234567890ABCDEF");
                                364   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         365                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                366                 :                : 
                                367                 :                :             /* Make sure it looks like a valid WAL file name */
 3768 bruce@momjian.us          368         [ -  + ]:CBC          32 :             if (strspn(p, "0123456789ABCDEF") != 24)
 1152 tgl@sss.pgh.pa.us         369                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                370                 :                : 
 3768 bruce@momjian.us          371                 :CBC          32 :             strlcpy(cluster->controldata.nextxlogfile, p, 25);
                                372                 :             32 :             got_nextxlogfile = true;
                                373                 :                :         }
 3616                           374         [ +  + ]:            832 :         else if ((p = strstr(bufin, "Float8 argument passing:")) != NULL)
                                375                 :                :         {
                                376                 :             32 :             p = strchr(p, ':');
                                377                 :                : 
                                378   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         379                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                380                 :                : 
 3616 bruce@momjian.us          381                 :CBC          32 :             p++;                /* remove ':' char */
                                382                 :                :             /* used later for contrib check */
                                383                 :             32 :             cluster->controldata.float8_pass_by_value = strstr(p, "by value") != NULL;
                                384                 :             32 :             got_float8_pass_by_value = true;
                                385                 :                :         }
 5596                           386         [ +  + ]:            800 :         else if ((p = strstr(bufin, "Maximum data alignment:")) != NULL)
                                387                 :                :         {
                                388                 :             32 :             p = strchr(p, ':');
                                389                 :                : 
                                390   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         391                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                392                 :                : 
 4013 bruce@momjian.us          393                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           394                 :             32 :             cluster->controldata.align = str2uint(p);
 5596                           395                 :             32 :             got_align = true;
                                396                 :                :         }
                                397         [ +  + ]:            768 :         else if ((p = strstr(bufin, "Database block size:")) != NULL)
                                398                 :                :         {
                                399                 :             32 :             p = strchr(p, ':');
                                400                 :                : 
                                401   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         402                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                403                 :                : 
 4013 bruce@momjian.us          404                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           405                 :             32 :             cluster->controldata.blocksz = str2uint(p);
 5596                           406                 :             32 :             got_blocksz = true;
                                407                 :                :         }
                                408         [ +  + ]:            736 :         else if ((p = strstr(bufin, "Blocks per segment of large relation:")) != NULL)
                                409                 :                :         {
                                410                 :             32 :             p = strchr(p, ':');
                                411                 :                : 
                                412   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         413                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                414                 :                : 
 4013 bruce@momjian.us          415                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           416                 :             32 :             cluster->controldata.largesz = str2uint(p);
 5596                           417                 :             32 :             got_largesz = true;
                                418                 :                :         }
                                419         [ +  + ]:            704 :         else if ((p = strstr(bufin, "WAL block size:")) != NULL)
                                420                 :                :         {
                                421                 :             32 :             p = strchr(p, ':');
                                422                 :                : 
                                423   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         424                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                425                 :                : 
 4013 bruce@momjian.us          426                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           427                 :             32 :             cluster->controldata.walsz = str2uint(p);
 5596                           428                 :             32 :             got_walsz = true;
                                429                 :                :         }
                                430         [ +  + ]:            672 :         else if ((p = strstr(bufin, "Bytes per WAL segment:")) != NULL)
                                431                 :                :         {
                                432                 :             32 :             p = strchr(p, ':');
                                433                 :                : 
                                434   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         435                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                436                 :                : 
 4013 bruce@momjian.us          437                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           438                 :             32 :             cluster->controldata.walseg = str2uint(p);
 5596                           439                 :             32 :             got_walseg = true;
                                440                 :                :         }
                                441         [ +  + ]:            640 :         else if ((p = strstr(bufin, "Maximum length of identifiers:")) != NULL)
                                442                 :                :         {
                                443                 :             32 :             p = strchr(p, ':');
                                444                 :                : 
                                445   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         446                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                447                 :                : 
 4013 bruce@momjian.us          448                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           449                 :             32 :             cluster->controldata.ident = str2uint(p);
 5596                           450                 :             32 :             got_ident = true;
                                451                 :                :         }
                                452         [ +  + ]:            608 :         else if ((p = strstr(bufin, "Maximum columns in an index:")) != NULL)
                                453                 :                :         {
                                454                 :             32 :             p = strchr(p, ':');
                                455                 :                : 
                                456   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         457                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                458                 :                : 
 4013 bruce@momjian.us          459                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           460                 :             32 :             cluster->controldata.index = str2uint(p);
 5596                           461                 :             32 :             got_index = true;
                                462                 :                :         }
                                463         [ +  + ]:            576 :         else if ((p = strstr(bufin, "Maximum size of a TOAST chunk:")) != NULL)
                                464                 :                :         {
                                465                 :             32 :             p = strchr(p, ':');
                                466                 :                : 
                                467   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         468                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                469                 :                : 
 4013 bruce@momjian.us          470                 :CBC          32 :             p++;                /* remove ':' char */
 5457                           471                 :             32 :             cluster->controldata.toast = str2uint(p);
 5596                           472                 :             32 :             got_toast = true;
                                473                 :                :         }
 4014                           474         [ +  + ]:            544 :         else if ((p = strstr(bufin, "Size of a large-object chunk:")) != NULL)
                                475                 :                :         {
                                476                 :             32 :             p = strchr(p, ':');
                                477                 :                : 
                                478   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         479                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                480                 :                : 
 4013 bruce@momjian.us          481                 :CBC          32 :             p++;                /* remove ':' char */
 4014                           482                 :             32 :             cluster->controldata.large_object = str2uint(p);
                                483                 :             32 :             got_large_object = true;
                                484                 :                :         }
 5596                           485         [ +  + ]:            512 :         else if ((p = strstr(bufin, "Date/time type storage:")) != NULL)
                                486                 :                :         {
                                487                 :             32 :             p = strchr(p, ':');
                                488                 :                : 
                                489   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         490                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                491                 :                : 
 4013 bruce@momjian.us          492                 :CBC          32 :             p++;                /* remove ':' char */
 5596                           493                 :             32 :             cluster->controldata.date_is_int = strstr(p, "64-bit integers") != NULL;
                                494                 :             32 :             got_date_is_int = true;
                                495                 :                :         }
 4512 simon@2ndQuadrant.co      496         [ +  + ]:            480 :         else if ((p = strstr(bufin, "checksum")) != NULL)
                                497                 :                :         {
 4551                           498                 :             32 :             p = strchr(p, ':');
                                499                 :                : 
                                500   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
 1152 tgl@sss.pgh.pa.us         501                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                502                 :                : 
 4013 bruce@momjian.us          503                 :CBC          32 :             p++;                /* remove ':' char */
 4512 simon@2ndQuadrant.co      504                 :             32 :             cluster->controldata.data_checksum_version = str2uint(p);
                                505                 :             32 :             got_data_checksum_version = true;
                                506                 :                :         }
  197 msawada@postgresql.o      507         [ +  + ]:            448 :         else if ((p = strstr(bufin, "Default char data signedness:")) != NULL)
                                508                 :                :         {
                                509                 :             32 :             p = strchr(p, ':');
                                510                 :                : 
                                511   [ +  -  -  + ]:             32 :             if (p == NULL || strlen(p) <= 1)
  197 msawada@postgresql.o      512                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                513                 :                : 
                                514                 :                :             /* Skip the colon and any whitespace after it */
  197 msawada@postgresql.o      515                 :CBC          32 :             p++;
                                516         [ +  + ]:            320 :             while (isspace((unsigned char) *p))
                                517                 :            288 :                 p++;
                                518                 :                : 
                                519                 :                :             /* The value should be either 'signed' or 'unsigned' */
                                520   [ +  +  -  + ]:             32 :             if (strcmp(p, "signed") != 0 && strcmp(p, "unsigned") != 0)
  197 msawada@postgresql.o      521                 :UBC           0 :                 pg_fatal("%d: controldata retrieval problem", __LINE__);
                                522                 :                : 
  197 msawada@postgresql.o      523                 :CBC          32 :             cluster->controldata.default_char_signedness = strcmp(p, "signed") == 0;
                                524                 :             32 :             got_default_char_signedness = true;
                                525                 :                :         }
                                526                 :                :     }
                                527                 :                : 
 1026 peter@eisentraut.org      528                 :             32 :     rc = pclose(output);
                                529         [ -  + ]:             32 :     if (rc != 0)
 1026 peter@eisentraut.org      530                 :UBC           0 :         pg_fatal("could not get control data using %s: %s",
                                531                 :                :                  cmd, wait_result_to_str(rc));
                                532                 :                : 
                                533                 :                :     /*
                                534                 :                :      * Restore environment variables.  Note all but LANG and LC_MESSAGES were
                                535                 :                :      * unset above.
                                536                 :                :      */
 1711 tgl@sss.pgh.pa.us         537         [ -  + ]:CBC          32 :     if (lc_collate)
 1711 tgl@sss.pgh.pa.us         538                 :UBC           0 :         setenv("LC_COLLATE", lc_collate, 1);
 1711 tgl@sss.pgh.pa.us         539         [ -  + ]:CBC          32 :     if (lc_ctype)
 1711 tgl@sss.pgh.pa.us         540                 :UBC           0 :         setenv("LC_CTYPE", lc_ctype, 1);
 1711 tgl@sss.pgh.pa.us         541         [ -  + ]:CBC          32 :     if (lc_monetary)
 1711 tgl@sss.pgh.pa.us         542                 :UBC           0 :         setenv("LC_MONETARY", lc_monetary, 1);
 1711 tgl@sss.pgh.pa.us         543         [ +  - ]:CBC          32 :     if (lc_numeric)
 1711 tgl@sss.pgh.pa.us         544                 :GBC          32 :         setenv("LC_NUMERIC", lc_numeric, 1);
 1711 tgl@sss.pgh.pa.us         545         [ -  + ]:CBC          32 :     if (lc_time)
 1711 tgl@sss.pgh.pa.us         546                 :UBC           0 :         setenv("LC_TIME", lc_time, 1);
 1711 tgl@sss.pgh.pa.us         547         [ +  - ]:CBC          32 :     if (lang)
                                548                 :             32 :         setenv("LANG", lang, 1);
                                549                 :                :     else
 1711 tgl@sss.pgh.pa.us         550                 :UBC           0 :         unsetenv("LANG");
 1711 tgl@sss.pgh.pa.us         551         [ -  + ]:CBC          32 :     if (language)
 1711 tgl@sss.pgh.pa.us         552                 :UBC           0 :         setenv("LANGUAGE", language, 1);
 1711 tgl@sss.pgh.pa.us         553         [ -  + ]:CBC          32 :     if (lc_all)
 1711 tgl@sss.pgh.pa.us         554                 :UBC           0 :         setenv("LC_ALL", lc_all, 1);
 1711 tgl@sss.pgh.pa.us         555         [ +  - ]:CBC          32 :     if (lc_messages)
                                556                 :             32 :         setenv("LC_MESSAGES", lc_messages, 1);
                                557                 :                :     else
 1711 tgl@sss.pgh.pa.us         558                 :UBC           0 :         unsetenv("LC_MESSAGES");
                                559                 :                : 
 5478 bruce@momjian.us          560                 :CBC          32 :     pg_free(lc_collate);
                                561                 :             32 :     pg_free(lc_ctype);
                                562                 :             32 :     pg_free(lc_monetary);
                                563                 :             32 :     pg_free(lc_numeric);
                                564                 :             32 :     pg_free(lc_time);
                                565                 :             32 :     pg_free(lang);
                                566                 :             32 :     pg_free(language);
                                567                 :             32 :     pg_free(lc_all);
                                568                 :             32 :     pg_free(lc_messages);
                                569                 :                : 
                                570                 :                :     /*
                                571                 :                :      * Before 9.3, pg_resetwal reported the xlogid and segno of the first log
                                572                 :                :      * file after reset as separate lines. Starting with 9.3, it reports the
                                573                 :                :      * WAL file name. If the old cluster is older than 9.3, we construct the
                                574                 :                :      * WAL file name from the xlogid and segno.
                                575                 :                :      */
 4820 heikki.linnakangas@i      576         [ -  + ]:             32 :     if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
                                577                 :                :     {
 3768 bruce@momjian.us          578   [ #  #  #  #  :UBC           0 :         if (got_tli && got_log_id && got_log_seg)
                                              #  # ]
                                579                 :                :         {
 4818 alvherre@alvh.no-ip.      580                 :              0 :             snprintf(cluster->controldata.nextxlogfile, 25, "%08X%08X%08X",
                                581                 :                :                      tli, logid, segno);
 4820 heikki.linnakangas@i      582                 :              0 :             got_nextxlogfile = true;
                                583                 :                :         }
                                584                 :                :     }
                                585                 :                : 
                                586                 :                :     /*
                                587                 :                :      * Pre-v18 database clusters don't have the default char signedness
                                588                 :                :      * information. We use the char signedness of the platform where
                                589                 :                :      * pg_upgrade was built.
                                590                 :                :      */
  197 msawada@postgresql.o      591         [ -  + ]:CBC          32 :     if (cluster->controldata.cat_ver < DEFAULT_CHAR_SIGNEDNESS_CAT_VER)
                                592                 :                :     {
  197 msawada@postgresql.o      593         [ #  # ]:UBC           0 :         Assert(!got_default_char_signedness);
                                594                 :                : #if CHAR_MIN != 0
                                595                 :              0 :         cluster->controldata.default_char_signedness = true;
                                596                 :                : #else
                                597                 :                :         cluster->controldata.default_char_signedness = false;
                                598                 :                : #endif
                                599                 :                :     }
                                600                 :                : 
                                601                 :                :     /* verify that we got all the mandatory pg_control data */
 5596 bruce@momjian.us          602   [ +  -  +  - ]:CBC          32 :     if (!got_xid || !got_oid ||
 1503                           603   [ +  -  +  - ]:             32 :         !got_multi || !got_oldestxid ||
 4573 alvherre@alvh.no-ip.      604         [ -  + ]:             32 :         (!got_oldestmulti &&
 4573 alvherre@alvh.no-ip.      605         [ #  # ]:UBC           0 :          cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
 3768 bruce@momjian.us          606   [ +  -  +  -  :CBC          32 :         !got_mxoff || (!live_check && !got_nextxlogfile) ||
                                              +  - ]
 3616                           607   [ +  -  +  -  :             32 :         !got_float8_pass_by_value || !got_align || !got_blocksz ||
                                              +  - ]
                                608   [ +  -  +  -  :             32 :         !got_largesz || !got_walsz || !got_walseg || !got_ident ||
                                        +  -  +  - ]
                                609   [ +  -  +  - ]:             32 :         !got_index || !got_toast ||
 4014                           610         [ -  + ]:             32 :         (!got_large_object &&
 4014 bruce@momjian.us          611         [ #  # ]:UBC           0 :          cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
  197 msawada@postgresql.o      612   [ +  -  +  - ]:CBC          32 :         !got_date_is_int || !got_data_checksum_version ||
                                613         [ -  + ]:             32 :         (!got_default_char_signedness &&
  197 msawada@postgresql.o      614         [ #  # ]:UBC           0 :          cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
                                615                 :                :     {
 2976 alvherre@alvh.no-ip.      616         [ #  # ]:              0 :         if (cluster == &old_cluster)
                                617                 :              0 :             pg_log(PG_REPORT,
                                618                 :                :                    "The source cluster lacks some required control information:");
                                619                 :                :         else
                                620                 :              0 :             pg_log(PG_REPORT,
                                621                 :                :                    "The target cluster lacks some required control information:");
                                622                 :                : 
 5596 bruce@momjian.us          623         [ #  # ]:              0 :         if (!got_xid)
 1152 tgl@sss.pgh.pa.us         624                 :              0 :             pg_log(PG_REPORT, "  checkpoint next XID");
                                625                 :                : 
 5596 bruce@momjian.us          626         [ #  # ]:              0 :         if (!got_oid)
 1152 tgl@sss.pgh.pa.us         627                 :              0 :             pg_log(PG_REPORT, "  latest checkpoint next OID");
                                628                 :                : 
 4609 alvherre@alvh.no-ip.      629         [ #  # ]:              0 :         if (!got_multi)
 1152 tgl@sss.pgh.pa.us         630                 :              0 :             pg_log(PG_REPORT, "  latest checkpoint next MultiXactId");
                                631                 :                : 
 4573 alvherre@alvh.no-ip.      632         [ #  # ]:              0 :         if (!got_oldestmulti &&
                                633         [ #  # ]:              0 :             cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
 1152 tgl@sss.pgh.pa.us         634                 :              0 :             pg_log(PG_REPORT, "  latest checkpoint oldest MultiXactId");
                                635                 :                : 
 1503 bruce@momjian.us          636         [ #  # ]:              0 :         if (!got_oldestxid)
 1152 tgl@sss.pgh.pa.us         637                 :              0 :             pg_log(PG_REPORT, "  latest checkpoint oldestXID");
                                638                 :                : 
 3768 bruce@momjian.us          639         [ #  # ]:              0 :         if (!got_mxoff)
 1152 tgl@sss.pgh.pa.us         640                 :              0 :             pg_log(PG_REPORT, "  latest checkpoint next MultiXactOffset");
                                641                 :                : 
 4820 heikki.linnakangas@i      642   [ #  #  #  # ]:              0 :         if (!live_check && !got_nextxlogfile)
 1152 tgl@sss.pgh.pa.us         643                 :              0 :             pg_log(PG_REPORT, "  first WAL segment after reset");
                                644                 :                : 
 3616 bruce@momjian.us          645         [ #  # ]:              0 :         if (!got_float8_pass_by_value)
 1152 tgl@sss.pgh.pa.us         646                 :              0 :             pg_log(PG_REPORT, "  float8 argument passing method");
                                647                 :                : 
 5596 bruce@momjian.us          648         [ #  # ]:              0 :         if (!got_align)
 1152 tgl@sss.pgh.pa.us         649                 :              0 :             pg_log(PG_REPORT, "  maximum alignment");
                                650                 :                : 
 5596 bruce@momjian.us          651         [ #  # ]:              0 :         if (!got_blocksz)
 1152 tgl@sss.pgh.pa.us         652                 :              0 :             pg_log(PG_REPORT, "  block size");
                                653                 :                : 
 5596 bruce@momjian.us          654         [ #  # ]:              0 :         if (!got_largesz)
 1152 tgl@sss.pgh.pa.us         655                 :              0 :             pg_log(PG_REPORT, "  large relation segment size");
                                656                 :                : 
 5596 bruce@momjian.us          657         [ #  # ]:              0 :         if (!got_walsz)
 1152 tgl@sss.pgh.pa.us         658                 :              0 :             pg_log(PG_REPORT, "  WAL block size");
                                659                 :                : 
 5596 bruce@momjian.us          660         [ #  # ]:              0 :         if (!got_walseg)
 1152 tgl@sss.pgh.pa.us         661                 :              0 :             pg_log(PG_REPORT, "  WAL segment size");
                                662                 :                : 
 5596 bruce@momjian.us          663         [ #  # ]:              0 :         if (!got_ident)
 1152 tgl@sss.pgh.pa.us         664                 :              0 :             pg_log(PG_REPORT, "  maximum identifier length");
                                665                 :                : 
 5596 bruce@momjian.us          666         [ #  # ]:              0 :         if (!got_index)
 1152 tgl@sss.pgh.pa.us         667                 :              0 :             pg_log(PG_REPORT, "  maximum number of indexed columns");
                                668                 :                : 
 5596 bruce@momjian.us          669         [ #  # ]:              0 :         if (!got_toast)
 1152 tgl@sss.pgh.pa.us         670                 :              0 :             pg_log(PG_REPORT, "  maximum TOAST chunk size");
                                671                 :                : 
 4014 bruce@momjian.us          672         [ #  # ]:              0 :         if (!got_large_object &&
                                673         [ #  # ]:              0 :             cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
 1152 tgl@sss.pgh.pa.us         674                 :              0 :             pg_log(PG_REPORT, "  large-object chunk size");
                                675                 :                : 
 5596 bruce@momjian.us          676         [ #  # ]:              0 :         if (!got_date_is_int)
 1152 tgl@sss.pgh.pa.us         677                 :              0 :             pg_log(PG_REPORT, "  dates/times are integers?");
                                678                 :                : 
                                679                 :                :         /* value added in Postgres 9.3 */
 4512 simon@2ndQuadrant.co      680         [ #  # ]:              0 :         if (!got_data_checksum_version)
 1152 tgl@sss.pgh.pa.us         681                 :              0 :             pg_log(PG_REPORT, "  data checksum version");
                                682                 :                : 
                                683                 :                :         /* value added in Postgres 18 */
  197 msawada@postgresql.o      684         [ #  # ]:              0 :         if (!got_default_char_signedness)
                                685                 :              0 :             pg_log(PG_REPORT, "  default char signedness");
                                686                 :                : 
 1152 tgl@sss.pgh.pa.us         687                 :              0 :         pg_fatal("Cannot continue without required control information, terminating");
                                688                 :                :     }
 5596 bruce@momjian.us          689                 :CBC          32 : }
                                690                 :                : 
                                691                 :                : 
                                692                 :                : /*
                                693                 :                :  * check_control_data()
                                694                 :                :  *
                                695                 :                :  * check to make sure the control data settings are compatible
                                696                 :                :  */
                                697                 :                : void
 5436                           698                 :             16 : check_control_data(ControlData *oldctrl,
                                699                 :                :                    ControlData *newctrl)
                                700                 :                : {
 5596                           701   [ +  -  -  + ]:             16 :     if (oldctrl->align == 0 || oldctrl->align != newctrl->align)
 1152 tgl@sss.pgh.pa.us         702                 :UBC           0 :         pg_fatal("old and new pg_controldata alignments are invalid or do not match.\n"
                                703                 :                :                  "Likely one cluster is a 32-bit install, the other 64-bit");
                                704                 :                : 
 5596 bruce@momjian.us          705   [ +  -  -  + ]:CBC          16 :     if (oldctrl->blocksz == 0 || oldctrl->blocksz != newctrl->blocksz)
 1152 tgl@sss.pgh.pa.us         706                 :UBC           0 :         pg_fatal("old and new pg_controldata block sizes are invalid or do not match");
                                707                 :                : 
 5596 bruce@momjian.us          708   [ +  -  -  + ]:CBC          16 :     if (oldctrl->largesz == 0 || oldctrl->largesz != newctrl->largesz)
 1152 tgl@sss.pgh.pa.us         709                 :UBC           0 :         pg_fatal("old and new pg_controldata maximum relation segment sizes are invalid or do not match");
                                710                 :                : 
 5596 bruce@momjian.us          711   [ +  -  -  + ]:CBC          16 :     if (oldctrl->walsz == 0 || oldctrl->walsz != newctrl->walsz)
 1152 tgl@sss.pgh.pa.us         712                 :UBC           0 :         pg_fatal("old and new pg_controldata WAL block sizes are invalid or do not match");
                                713                 :                : 
 5596 bruce@momjian.us          714   [ +  -  -  + ]:CBC          16 :     if (oldctrl->walseg == 0 || oldctrl->walseg != newctrl->walseg)
 1152 tgl@sss.pgh.pa.us         715                 :UBC           0 :         pg_fatal("old and new pg_controldata WAL segment sizes are invalid or do not match");
                                716                 :                : 
 5596 bruce@momjian.us          717   [ +  -  -  + ]:CBC          16 :     if (oldctrl->ident == 0 || oldctrl->ident != newctrl->ident)
 1152 tgl@sss.pgh.pa.us         718                 :UBC           0 :         pg_fatal("old and new pg_controldata maximum identifier lengths are invalid or do not match");
                                719                 :                : 
 5596 bruce@momjian.us          720   [ +  -  -  + ]:CBC          16 :     if (oldctrl->index == 0 || oldctrl->index != newctrl->index)
 1152 tgl@sss.pgh.pa.us         721                 :UBC           0 :         pg_fatal("old and new pg_controldata maximum indexed columns are invalid or do not match");
                                722                 :                : 
 5596 bruce@momjian.us          723   [ +  -  -  + ]:CBC          16 :     if (oldctrl->toast == 0 || oldctrl->toast != newctrl->toast)
 1152 tgl@sss.pgh.pa.us         724                 :UBC           0 :         pg_fatal("old and new pg_controldata maximum TOAST chunk sizes are invalid or do not match");
                                725                 :                : 
                                726                 :                :     /* large_object added in 9.5, so it might not exist in the old cluster */
 4014 bruce@momjian.us          727         [ +  - ]:CBC          16 :     if (oldctrl->large_object != 0 &&
                                728         [ -  + ]:             16 :         oldctrl->large_object != newctrl->large_object)
 1152 tgl@sss.pgh.pa.us         729                 :UBC           0 :         pg_fatal("old and new pg_controldata large-object chunk sizes are invalid or do not match");
                                730                 :                : 
 5596 bruce@momjian.us          731         [ -  + ]:CBC          16 :     if (oldctrl->date_is_int != newctrl->date_is_int)
 1152 tgl@sss.pgh.pa.us         732                 :UBC           0 :         pg_fatal("old and new pg_controldata date/time storage types do not match");
                                733                 :                : 
                                734                 :                :     /*
                                735                 :                :      * float8_pass_by_value does not need to match, but is used in
                                736                 :                :      * check_for_isn_and_int8_passing_mismatch().
                                737                 :                :      */
                                738                 :                : 
                                739                 :                :     /*
                                740                 :                :      * We might eventually allow upgrades from checksum to no-checksum
                                741                 :                :      * clusters.
                                742                 :                :      */
 3860 bruce@momjian.us          743         [ -  + ]:CBC          16 :     if (oldctrl->data_checksum_version == 0 &&
 3860 bruce@momjian.us          744         [ #  # ]:UBC           0 :         newctrl->data_checksum_version != 0)
 1152 tgl@sss.pgh.pa.us         745                 :              0 :         pg_fatal("old cluster does not use data checksums but the new one does");
 3860 bruce@momjian.us          746         [ +  - ]:CBC          16 :     else if (oldctrl->data_checksum_version != 0 &&
                                747         [ -  + ]:             16 :              newctrl->data_checksum_version == 0)
 1152 tgl@sss.pgh.pa.us         748                 :UBC           0 :         pg_fatal("old cluster uses data checksums but the new one does not");
 3860 bruce@momjian.us          749         [ -  + ]:CBC          16 :     else if (oldctrl->data_checksum_version != newctrl->data_checksum_version)
 1152 tgl@sss.pgh.pa.us         750                 :UBC           0 :         pg_fatal("old and new cluster pg_controldata checksum versions do not match");
 5596 bruce@momjian.us          751                 :CBC          16 : }
                                752                 :                : 
                                753                 :                : 
                                754                 :                : void
  165 nathan@postgresql.or      755                 :              2 : disable_old_cluster(transferMode transfer_mode)
                                756                 :                : {
                                757                 :                :     char        old_path[MAXPGPATH],
                                758                 :                :                 new_path[MAXPGPATH];
                                759                 :                : 
                                760                 :                :     /* rename pg_control so old server cannot be accidentally started */
                                761                 :                :     /* translator: %s is the file path of the control file */
  141 fujii@postgresql.org      762                 :              2 :     prep_status("Adding \".old\" suffix to old \"%s\"", XLOG_CONTROL_FILE);
                                763                 :                : 
  152                           764                 :              2 :     snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, XLOG_CONTROL_FILE);
                                765                 :              2 :     snprintf(new_path, sizeof(new_path), "%s/%s.old", old_cluster.pgdata, XLOG_CONTROL_FILE);
 5596 bruce@momjian.us          766         [ -  + ]:              2 :     if (pg_mv_file(old_path, new_path) != 0)
 1152 tgl@sss.pgh.pa.us         767                 :UBC           0 :         pg_fatal("could not rename file \"%s\" to \"%s\": %m",
                                768                 :                :                  old_path, new_path);
 5436 bruce@momjian.us          769                 :CBC           2 :     check_ok();
                                770                 :                : 
  165 nathan@postgresql.or      771         [ +  + ]:              2 :     if (transfer_mode == TRANSFER_MODE_LINK)
                                772                 :                :         /* translator: %s/%s is the file path of the control file */
                                773                 :              1 :         pg_log(PG_REPORT, "\n"
                                774                 :                :                "If you want to start the old cluster, you will need to remove\n"
                                775                 :                :                "the \".old\" suffix from \"%s/%s.old\".\n"
                                776                 :                :                "Because \"link\" mode was used, the old cluster cannot be safely\n"
                                777                 :                :                "started once the new cluster has been started.",
                                778                 :                :                old_cluster.pgdata, XLOG_CONTROL_FILE);
                                779         [ +  - ]:              1 :     else if (transfer_mode == TRANSFER_MODE_SWAP)
                                780                 :              1 :         pg_log(PG_REPORT, "\n"
                                781                 :                :                "Because \"swap\" mode was used, the old cluster can no longer be\n"
                                782                 :                :                "safely started.");
                                783                 :                :     else
  165 nathan@postgresql.or      784                 :UBC           0 :         pg_fatal("unrecognized transfer mode");
 5596 bruce@momjian.us          785                 :CBC           2 : }
        

Generated by: LCOV version 2.4-beta