Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_bloat for Windows and use PGPASSFILE #728

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
12 changes: 9 additions & 3 deletions agents/plugins/mk_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ def __init__(self, db_user, pg_binary_path, instance, process_match_patterns):
self.pg_passfile = instance.get("pg_passfile", "")
self.pg_version = instance.get("pg_version")
self.my_env = os.environ.copy()
self.my_env["PGPASSFILE"] = instance.get("pg_passfile", "")
if instance.get("pg_passfile", ""):
self.my_env["PGPASSFILE"] = instance.get("pg_passfile", "")
self.sep = os.sep

self.psql_binary_name = "psql"
if pg_binary_path is None:
self.psql_binary_path = self.get_psql_binary_path()
Expand Down Expand Up @@ -737,12 +740,15 @@ def get_bloat(self, databases, numeric_version):
query = "\\pset footer off \\\\"

cur_rows_only = False
output = ""
for idx, database in enumerate(databases):
query = "%s \\c %s \\\\ %s" % (query, database, bloat_query)
if idx == 0:
query = "%s \\pset tuples_only on" % query

return self.run_sql_as_db_user(query, mixed_cmd=True, rows_only=cur_rows_only)
output += self.run_sql_as_db_user(query, mixed_cmd=True, rows_only=cur_rows_only)
cur_rows_only = True
query = "\\pset footer off \\\\"
return output


class PostgresLinux(PostgresBase):
Expand Down
Loading