summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-10-20 16:14:47 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-10-20 16:14:47 +0000
commit01145f963fe4979714ffb1517903e42d56e56592 (patch)
treebde8b2948ffcbd10a8f47a31c468aa434914f876
parent52e98f84154fb288791214043dfddbc1ef8dd2c9 (diff)
Prevent core dump in contrib version of autovacuum when a table has been
dropped. Per report from daveg (not his patch, though).
-rw-r--r--contrib/pg_autovacuum/pg_autovacuum.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/contrib/pg_autovacuum/pg_autovacuum.c b/contrib/pg_autovacuum/pg_autovacuum.c
index 3775157d668..d202d189859 100644
--- a/contrib/pg_autovacuum/pg_autovacuum.c
+++ b/contrib/pg_autovacuum/pg_autovacuum.c
@@ -142,7 +142,7 @@ init_table_info(PGresult *res, int row, db_info * dbi)
void
update_table_thresholds(db_info * dbi, tbl_info * tbl, int vacuum_type)
{
- PGresult *res = NULL;
+ PGresult *res;
int disconnect = 0;
char query[128];
@@ -156,7 +156,7 @@ update_table_thresholds(db_info * dbi, tbl_info * tbl, int vacuum_type)
{
snprintf(query, sizeof(query), PAGES_QUERY, tbl->relid);
res = send_query(query, dbi);
- if (res != NULL)
+ if (res != NULL && PQntuples(res) > 0)
{
tbl->reltuples =
atof(PQgetvalue(res, 0, PQfnumber(res, "reltuples")));
@@ -178,8 +178,6 @@ update_table_thresholds(db_info * dbi, tbl_info * tbl, int vacuum_type)
(args->analyze_base_threshold + args->analyze_scaling_factor * tbl->reltuples);
tbl->CountAtLastAnalyze = tbl->curr_analyze_count;
- PQclear(res);
-
/*
* If the stats collector is reporting fewer updates then we
* have on record then the stats were probably reset, so we
@@ -192,6 +190,8 @@ update_table_thresholds(db_info * dbi, tbl_info * tbl, int vacuum_type)
tbl->CountAtLastVacuum = tbl->curr_vacuum_count;
}
}
+
+ PQclear(res);
}
if (disconnect)
db_disconnect(dbi);