aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-06-05 21:50:19 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-06-05 21:50:19 +0000
commit7dab4f75ca60f1c04ed9e7ff9d4ca8d71e572b29 (patch)
tree54dc4451d658d8d77d349f5fa4fc62b8dea72696
parent31edbadf4af45dd4eecebcb732702ec6d7ae1819 (diff)
downloadpostgresql-7dab4f75ca60f1c04ed9e7ff9d4ca8d71e572b29.tar.gz
postgresql-7dab4f75ca60f1c04ed9e7ff9d4ca8d71e572b29.zip
Minor editorialization: don't flush plan cache without need.
-rw-r--r--src/backend/utils/misc/guc.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 3428d0a172f..6e412e328a1 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.394 2007/06/05 20:00:41 wieck Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.395 2007/06/05 21:50:19 tgl Exp $
*
*--------------------------------------------------------------------
*/
@@ -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;
}