diff --git a/src/common/backend/utils/cache/plancache.cpp b/src/common/backend/utils/cache/plancache.cpp index 2e3f27a84..0197bae9f 100644 --- a/src/common/backend/utils/cache/plancache.cpp +++ b/src/common/backend/utils/cache/plancache.cpp @@ -845,6 +845,13 @@ List* RevalidateCachedQuery(CachedPlanSource* plansource, bool has_lp) snapshot_set = true; } + /* + * Query Tree is about to be rebuilt, reset is_top_unique_sql, otherwise, unique sql id + * can not be set. + */ + if (IS_UNIQUE_SQL_TRACK_TOP) + SetIsTopUniqueSQL(false); + /* * Run parse analysis and rule rewriting. The parser tends to scribble on * its input, so we must copy the raw parse tree to prevent corruption of