diff options
author | Jan Wieck | 2007-06-05 20:00:41 +0000 |
---|---|---|
committer | Jan Wieck | 2007-06-05 20:00:41 +0000 |
commit | 960cce2d1b5405a82ddbeeebfc68d276d1ae3197 (patch) | |
tree | 3bfa2a574c2c81b99e6acffd079d6670bb320cf5 | |
parent | 753ad29e7bac93309b5943d7ed5a27f3c0c9f175 (diff) |
The session_replication_role actually can be changed at will during
a session regardless of the existence of cached plans. The plancache
only needs to be invalidated so that rules affected by the new setting
will be reflected in the new query plans.
Jan
-rw-r--r-- | src/backend/utils/cache/plancache.c | 11 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 13 | ||||
-rw-r--r-- | src/include/utils/plancache.h | 1 |
3 files changed, 9 insertions, 16 deletions
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c index 3971a74fd2..be161ff4de 100644 --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@ -944,14 +944,3 @@ InvalRelid(Oid relid, LOCKMODE lockmode, InvalRelidContext *context) if (relid == context->inval_relid || context->inval_relid == InvalidOid) context->plan->dead = true; } - - -/* - * HaveCachedPlans - * Check if the plancache has stored any plans at all. - */ -bool -HaveCachedPlans(void) -{ - return (cached_plans_list != NIL); -} diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index e09072f819..861034ad97 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -6270,24 +6270,29 @@ assign_defaultxactisolevel(const char *newval, bool doit, GucSource source) static const char * assign_session_replication_role(const char *newval, bool doit, GucSource source) { - if (HaveCachedPlans()) - elog(ERROR, "session_replication_role cannot be changed " - "after prepared plans have been cached"); - if (pg_strcasecmp(newval, "origin") == 0) { if (doit) + { + ResetPlanCache(); SessionReplicationRole = SESSION_REPLICATION_ROLE_ORIGIN; + } } else if (pg_strcasecmp(newval, "replica") == 0) { if (doit) + { + ResetPlanCache(); SessionReplicationRole = SESSION_REPLICATION_ROLE_REPLICA; + } } else if (pg_strcasecmp(newval, "local") == 0) { if (doit) + { + ResetPlanCache(); SessionReplicationRole = SESSION_REPLICATION_ROLE_LOCAL; + } } else return NULL; diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h index d3502b707d..dae720fba8 100644 --- a/src/include/utils/plancache.h +++ b/src/include/utils/plancache.h @@ -106,7 +106,6 @@ extern CachedPlan *RevalidateCachedPlan(CachedPlanSource *plansource, bool useResOwner); extern void ReleaseCachedPlan(CachedPlan *plan, bool useResOwner); extern TupleDesc PlanCacheComputeResultDesc(List *stmt_list); -extern bool HaveCachedPlans(void); extern void ResetPlanCache(void); |