diff options
| author | Michael Paquier <michael@paquier.xyz> | 2025-10-14 16:27:13 +0900 |
|---|---|---|
| committer | Michael Paquier <michael@paquier.xyz> | 2025-10-14 16:27:13 +0900 |
| commit | a7d8052910d6254688ef66840554f1bba80a2238 (patch) | |
| tree | 6a444d992edfd0a1fd58f47356a0bf342ef94211 /src/bin/pg_upgrade/server.c | |
| parent | cd0be131ba6f7e8b1323d188db20d15c2504b021 (diff) | |
pg_upgrade: Use new routine to retrieve data of PG_VERSION
Unsurprisingly, this shaves code. get_major_server_version() can be
replaced by the new routine added by cd0be131ba6f, with the contents of
PG_VERSION stored in an allocated buffer instead of a fixed-sized one.
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/aOiirvWJzwdVCXph@paquier.xyz
Diffstat (limited to 'src/bin/pg_upgrade/server.c')
| -rw-r--r-- | src/bin/pg_upgrade/server.c | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index 7eb15bc7d5a..d51bee885b8 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -148,45 +148,6 @@ executeQueryOrDie(PGconn *conn, const char *fmt,...) } -/* - * get_major_server_version() - * - * gets the version (in unsigned int form) for the given datadir. Assumes - * that datadir is an absolute path to a valid pgdata directory. The version - * is retrieved by reading the PG_VERSION file. - */ -uint32 -get_major_server_version(ClusterInfo *cluster) -{ - FILE *version_fd; - char ver_filename[MAXPGPATH]; - int v1 = 0, - v2 = 0; - - snprintf(ver_filename, sizeof(ver_filename), "%s/PG_VERSION", - cluster->pgdata); - if ((version_fd = fopen(ver_filename, "r")) == NULL) - pg_fatal("could not open version file \"%s\": %m", ver_filename); - - if (fscanf(version_fd, "%63s", cluster->major_version_str) == 0 || - sscanf(cluster->major_version_str, "%d.%d", &v1, &v2) < 1) - pg_fatal("could not parse version file \"%s\"", ver_filename); - - fclose(version_fd); - - if (v1 < 10) - { - /* old style, e.g. 9.6.1 */ - return v1 * 10000 + v2 * 100; - } - else - { - /* new style, e.g. 10.1 */ - return v1 * 10000; - } -} - - static void stop_postmaster_atexit(void) { |
