Add missing CommandCounterIncrement() in stats import functions.
authorJeff Davis <[email protected]>
Tue, 29 Oct 2024 17:14:23 +0000 (10:14 -0700)
committerJeff Davis <[email protected]>
Tue, 29 Oct 2024 17:14:23 +0000 (10:14 -0700)
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/98b2fcf0-f701-369e-d63d-6be9739ce17c@gmail.com

src/backend/statistics/attribute_stats.c
src/backend/statistics/relation_stats.c

index af61fd79e492c1e477fc990a441a54d7a43d759a..4ae0722b781365ae60160b23597120e0d39254af 100644 (file)
@@ -752,6 +752,8 @@ upsert_pg_statistic(Relation starel, HeapTuple oldtup,
    }
 
    heap_freetuple(newtup);
+
+   CommandCounterIncrement();
 }
 
 /*
@@ -762,6 +764,7 @@ delete_pg_statistic(Oid reloid, AttrNumber attnum, bool stainherit)
 {
    Relation    sd = table_open(StatisticRelationId, RowExclusiveLock);
    HeapTuple   oldtup;
+   bool        result = false;
 
    /* Is there already a pg_statistic tuple for this attribute? */
    oldtup = SearchSysCache3(STATRELATTINH,
@@ -773,12 +776,14 @@ delete_pg_statistic(Oid reloid, AttrNumber attnum, bool stainherit)
    {
        CatalogTupleDelete(sd, &oldtup->t_self);
        ReleaseSysCache(oldtup);
-       table_close(sd, RowExclusiveLock);
-       return true;
+       result = true;
    }
 
    table_close(sd, RowExclusiveLock);
-   return false;
+
+   CommandCounterIncrement();
+
+   return result;
 }
 
 /*
index 5a2aabc921e75156860dd2c06442b20bc271862f..ed5dea2e0588fd8ba1e29dc25d304f4f629273fd 100644 (file)
@@ -171,6 +171,8 @@ relation_statistics_update(FunctionCallInfo fcinfo, int elevel)
    /* release the lock, consistent with vac_update_relstats() */
    table_close(crel, RowExclusiveLock);
 
+   CommandCounterIncrement();
+
    return result;
 }