Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit adce422

Browse files
committed
Updated contrib/online-analyze from sigaev.ru (b51c5ba)
1 parent 243437b commit adce422

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

contrib/online_analyze/online_analyze.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ makeAnalyze(Oid relOid, CmdKind operation, int64 naffected)
557557
&vacstmt, NULL, true, GetAccessStrategy(BAS_VACUUM)
558558
#endif
559559
);
560-
560+
561561
/* Make changes visible to subsequent calls */
562562
CommandCounterIncrement();
563563

@@ -850,13 +850,38 @@ onlineAnalyzeHookerUtility(
850850
{
851851
VacuumStmt *vac = (VacuumStmt*)parsetree;
852852

853-
tblnames = list_make1(vac->relation);
853+
if (vac->relation)
854+
tblnames = list_make1(vac->relation);
854855

855856
if (vac->options & (VACOPT_VACUUM | VACOPT_FULL | VACOPT_FREEZE))
857+
{
856858
/* optionally with analyze */
857859
op = CK_VACUUM;
860+
861+
/* drop all collected stat */
862+
if (tblnames == NIL)
863+
relstatsInit();
864+
}
858865
else if (vac->options & VACOPT_ANALYZE)
866+
{
859867
op = CK_ANALYZE;
868+
869+
/* should reset all counters */
870+
if (tblnames == NIL)
871+
{
872+
HASH_SEQ_STATUS hs;
873+
OnlineAnalyzeTableStat *rstat;
874+
TimestampTz now = GetCurrentTimestamp();
875+
876+
hash_seq_init(&hs, relstats);
877+
878+
while((rstat = hash_seq_search(&hs)) != NULL)
879+
{
880+
rstat->changes_since_analyze = 0;
881+
rstat->analyze_timestamp = now;
882+
}
883+
}
884+
}
860885
else
861886
tblnames = NIL;
862887
}

0 commit comments

Comments
 (0)