From: Teodor Sigaev Date: Fri, 21 Jul 2017 14:05:28 +0000 (+0300) Subject: Fix crashing on database-wide vacuum/analyze X-Git-Url: http://sigaev.ru/git/gitweb.cgi?a=commitdiff_plain;h=1c8d024477ec3268e7c20cbf3777174530fad1c5;p=online_analyze.git Fix crashing on database-wide vacuum/analyze --- diff --git a/online_analyze.c b/online_analyze.c index 53ffd20..b6ccf68 100644 --- a/online_analyze.c +++ b/online_analyze.c @@ -847,13 +847,38 @@ onlineAnalyzeHookerUtility( { VacuumStmt *vac = (VacuumStmt*)parsetree; - tblnames = list_make1(vac->relation); + if (vac->relation) + tblnames = list_make1(vac->relation); if (vac->options & (VACOPT_VACUUM | VACOPT_FULL | VACOPT_FREEZE)) + { /* optionally with analyze */ op = CK_VACUUM; + + /* drop all collected stat */ + if (tblnames == NIL) + relstatsInit(); + } else if (vac->options & VACOPT_ANALYZE) + { op = CK_ANALYZE; + + /* should reset all counters */ + if (tblnames == NIL) + { + HASH_SEQ_STATUS hs; + OnlineAnalyzeTableStat *rstat; + TimestampTz now = GetCurrentTimestamp(); + + hash_seq_init(&hs, relstats); + + while((rstat = hash_seq_search(&hs)) != NULL) + { + rstat->changes_since_analyze = 0; + rstat->analyze_timestamp = now; + } + } + } else tblnames = NIL; }