From def4c58be62c9c1da55ab68c59f19a0ca0ad0bc3 Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Mon, 29 Aug 2016 17:19:14 +0300 Subject: [PATCH] distinguish unknown and zero number of affected rows --- online_analyze.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/online_analyze.c b/online_analyze.c index c4c2691..4c3e044 100644 --- a/online_analyze.c +++ b/online_analyze.c @@ -318,7 +318,7 @@ makeRangeVarFromOid(Oid relOid) #endif static void -makeAnalyze(Oid relOid, CmdType operation, uint32 naffected) +makeAnalyze(Oid relOid, CmdType operation, int32 naffected) { PgStat_StatTabEntry *tabentry; TimestampTz now = GetCurrentTimestamp(); @@ -326,6 +326,13 @@ makeAnalyze(Oid relOid, CmdType operation, uint32 naffected) if (relOid == InvalidOid) return; + if (naffected == 0) + /* return if there is not changes */ + return; + else if (naffected < 0) + /* number if affected rows is unknown */ + naffected = 0; + if (get_rel_relkind(relOid) != RELKIND_RELATION) return; @@ -479,7 +486,7 @@ extern PGDLLIMPORT void onlineAnalyzeHooker(QueryDesc *queryDesc); void onlineAnalyzeHooker(QueryDesc *queryDesc) { - uint32 naffected = 0; + uint32 naffected = -1; if (queryDesc->estate) naffected = queryDesc->estate->es_processed; @@ -558,7 +565,7 @@ onlineAnalyzeHookerUtility(Node *parsetree, const char *queryString, if (tblname) { Oid tblOid = RangeVarGetRelid(tblname, NoLock, true); - makeAnalyze(tblOid, CMD_INSERT, 0); + makeAnalyze(tblOid, CMD_INSERT, -1); } } #endif -- 2.37.3