Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions pg_probackup2/init_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,32 @@ def __init__(self):
else:
self.verbose = False

self._pg_config = testgres.get_pg_config()
self.is_enterprise = self._pg_config.get('PGPRO_EDITION', None) == 'enterprise'
self.is_shardman = self._pg_config.get('PGPRO_EDITION', None) == 'shardman'
self.is_pgpro = 'PGPRO_EDITION' in self._pg_config
self.is_nls_enabled = 'enable-nls' in self._pg_config['CONFIGURE']
self.is_lz4_enabled = '-llz4' in self._pg_config['LIBS']
version = self._pg_config['VERSION'].rstrip('develalphabetapre')
parts = [*version.split(' ')[1].split('.'), '0', '0'][:3]
pg_bin = os.getenv('PG_BIN', shutil.which('postgres'))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shutil.which('postgres') - может неявно задать неправильную версию.


if pg_bin is None:
raise Exception(
"Failed to determine the Postgres binary. Specify the path to 'postgres' in PG_BIN or put it to the system PATH.')

pgpro_edition = subprocess.run(
[pg_bin, "-C", "pgpro_edition"],
capture_output=True,
encoding='utf-8').stdout[:-1] # remove the trailing newline
self.is_enterprise = pgpro_edition == 'enterprise'
self.is_shardman = pgpro_edition == 'shardman'
self.is_pgpro = pgpro_edition != ''
# TODO: Always test with NLS support and remove this flag
self.is_nls_enabled = True
Comment thread
demonolock marked this conversation as resolved.
ldd = subprocess.run(
['ldd', pg_bin],
capture_output=True,
encoding='utf-8').stdout
self.is_lz4_enabled = 'liblz4.so' in ldd

server_version = subprocess.run(
[pg_bin, "-C", "server_version"],
capture_output=True,
encoding='utf-8').stdout.rstrip('develalphabetapre\n')
parts = [*server_version.split('.'), '0', '0'][:3]
parts[0] = re.match(r'\d+', parts[0]).group()
self.pg_config_version = reduce(lambda v, x: v * 100 + int(x), parts, 0)

Expand Down Expand Up @@ -102,7 +120,7 @@ def __init__(self):

if not self.probackup_path:
probackup_path_tmp = os.path.join(
testgres.get_pg_config()['BINDIR'], 'pg_probackup')
os.path.dirname(pg_bin), 'pg_probackup')

if os.path.isfile(probackup_path_tmp):
if not os.access(probackup_path_tmp, os.X_OK):
Expand Down