LCOV - differential code coverage report
Current view: top level - src/bin/pg_upgrade - controldata.c (source / functions) Coverage Total Hit UNC UBC GNC CBC DUB DCB
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 65.5 % 417 273 4 140 3 270 6 2
Current Date: 2024-04-14 14:21:10 Functions: 66.7 % 3 2 1 1 1
Baseline: 16@8cea358b128 Branches: 46.9 % 384 180 2 202 2 178
Baseline Date: 2024-04-14 14:21:09 Line coverage date bins:
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed [..60] days: 0.0 % 2 0 2
(240..) days: 65.8 % 415 273 2 140 3 270
Function coverage date bins:
(240..) days: 66.7 % 3 2 1 1 1
Branch coverage date bins:
(240..) days: 46.9 % 384 180 2 202 2 178

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

Generated by: LCOV version 2.1-beta2-3-g6141622