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

Commit 1c8d024

Browse files
committed
Fix crashing on database-wide vacuum/analyze
1 parent 31e2328 commit 1c8d024

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

online_analyze.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,13 +847,38 @@ onlineAnalyzeHookerUtility(
847847
{
848848
VacuumStmt *vac = (VacuumStmt*)parsetree;
849849

850-
tblnames = list_make1(vac->relation);
850+
if (vac->relation)
851+
tblnames = list_make1(vac->relation);
851852

852853
if (vac->options & (VACOPT_VACUUM | VACOPT_FULL | VACOPT_FREEZE))
854+
{
853855
/* optionally with analyze */
854856
op = CK_VACUUM;
857+
858+
/* drop all collected stat */
859+
if (tblnames == NIL)
860+
relstatsInit();
861+
}
855862
else if (vac->options & VACOPT_ANALYZE)
863+
{
856864
op = CK_ANALYZE;
865+
866+
/* should reset all counters */
867+
if (tblnames == NIL)
868+
{
869+
HASH_SEQ_STATUS hs;
870+
OnlineAnalyzeTableStat *rstat;
871+
TimestampTz now = GetCurrentTimestamp();
872+
873+
hash_seq_init(&hs, relstats);
874+
875+
while((rstat = hash_seq_search(&hs)) != NULL)
876+
{
877+
rstat->changes_since_analyze = 0;
878+
rstat->analyze_timestamp = now;
879+
}
880+
}
881+
}
857882
else
858883
tblnames = NIL;
859884
}

0 commit comments

Comments
 (0)