diff options
author | Michael Paquier <michael@paquier.xyz> | 2025-10-14 16:20:42 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2025-10-14 16:20:42 +0900 |
commit | cd0be131ba6f7e8b1323d188db20d15c2504b021 (patch) | |
tree | 773bf11eb2a49e9195ac3c1ce4b4d90704e8991f /src/include/fe_utils/version.h | |
parent | 1c05fe11abb6a1588b158e3f39b668053e24cdae (diff) |
Introduce frontend API able to retrieve the contents of PG_VERSION
get_pg_version() is able to return a version number, that can be used
for comparisons based on PG_VERSION_NUM. A macro is added to convert
the result to a major version number, to work with PG_MAJORVERSION_NUM.
It is possible to pass to the routine an optional argument, where the
contents retrieved from PG_VERSION are saved. This requirement matters
for some of the frontend code (one example: pg_upgrade wants that for
tablespace paths with a version number strictly older than v10).
This will be used by a set of follow-up patches, to be consumed in
various frontend tools that duplicate a logic similar to do what this
new routine does, like:
- pg_resetwal
- pg_combinebackup
- pg_createsubscriber
- pg_upgrade
This routine supports both the post-v10 version number and the older
flavor (aka 9.6), as required at least by pg_upgrade.
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/include/fe_utils/version.h')
-rw-r--r-- | src/include/fe_utils/version.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/include/fe_utils/version.h b/src/include/fe_utils/version.h new file mode 100644 index 00000000000..cea9d8020bc --- /dev/null +++ b/src/include/fe_utils/version.h @@ -0,0 +1,23 @@ +/*------------------------------------------------------------------------- + * + * Routines to retrieve information of PG_VERSION + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/fe_utils/version.h + * + *------------------------------------------------------------------------- + */ +#ifndef PG_VERSION_H +#define PG_VERSION_H + +/* + * Retrieve the version major number, useful for major version checks + * based on PG_MAJORVERSION_NUM. + */ +#define GET_PG_MAJORVERSION_NUM(v) ((v) / 10000) + +extern uint32 get_pg_version(const char *datadir, char **version_str); + +#endif /* PG_VERSION_H */ |