Skip to content

Commit

Permalink
Fix 'db-djv-pg dbinfo -c' error on PostgreSQL 11 (Raspbian)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-stepanov committed Dec 22, 2022
1 parent bc0565e commit d20a12c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions db_djv_pg/db_djv_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,16 @@ def main():
"D0040: fingerprint hashes of variable size")
db_problem = db_problem or res

res = db_check(cur,
"SELECT n_ins_since_vacuum + n_dead_tup FROM pg_stat_user_tables WHERE relname = 'fingerprints'",
"D0100: vacuum needed")
# Need to take into account older Postgres
cur.execute("SELECT column_name FROM information_schema.columns WHERE table_name = 'pg_stat_user_tables' AND column_name = 'n_ins_since_vacuum'")
if cur.rowcount != 0:
res = db_check(cur,
"SELECT n_ins_since_vacuum + n_dead_tup FROM pg_stat_user_tables WHERE relname = 'fingerprints'",
"D0100: vacuum needed")
else:
res = db_check(cur,
"SELECT n_dead_tup FROM pg_stat_user_tables WHERE relname = 'fingerprints'",
"D0100: vacuum needed")
db_problem = db_problem or res

## AdVent-specific checks
Expand Down

0 comments on commit d20a12c

Please sign in to comment.