From 6a691167ec2efaf80e059207f4f5eb4b9f0d0459 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 5 Jun 2007 21:50:19 +0000 Subject: [PATCH] Minor editorialization: don't flush plan cache without need. --- src/backend/utils/misc/guc.c | 37 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 861034ad97..f6fced430f 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -6270,32 +6270,27 @@ assign_defaultxactisolevel(const char *newval, bool doit, GucSource source) static const char * assign_session_replication_role(const char *newval, bool doit, GucSource source) { + int newrole; + if (pg_strcasecmp(newval, "origin") == 0) - { - if (doit) - { - ResetPlanCache(); - SessionReplicationRole = SESSION_REPLICATION_ROLE_ORIGIN; - } - } + newrole = SESSION_REPLICATION_ROLE_ORIGIN; else if (pg_strcasecmp(newval, "replica") == 0) - { - if (doit) - { - ResetPlanCache(); - SessionReplicationRole = SESSION_REPLICATION_ROLE_REPLICA; - } - } + newrole = SESSION_REPLICATION_ROLE_REPLICA; else if (pg_strcasecmp(newval, "local") == 0) - { - if (doit) - { - ResetPlanCache(); - SessionReplicationRole = SESSION_REPLICATION_ROLE_LOCAL; - } - } + newrole = SESSION_REPLICATION_ROLE_LOCAL; else return NULL; + + /* + * Must flush the plan cache when changing replication role; but don't + * flush unnecessarily. + */ + if (doit && SessionReplicationRole != newrole) + { + ResetPlanCache(); + SessionReplicationRole = newrole; + } + return newval; } -- 2.39.5