The session_replication_role actually can be changed at will during
authorJan Wieck <JanWieck@Yahoo.com>
Tue, 5 Jun 2007 20:00:41 +0000 (20:00 +0000)
committerJan Wieck <JanWieck@Yahoo.com>
Tue, 5 Jun 2007 20:00:41 +0000 (20:00 +0000)
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

src/backend/utils/cache/plancache.c
src/backend/utils/misc/guc.c
src/include/utils/plancache.h

index 3971a74fd207e02ed26897c57d743da874b79c2c..be161ff4de68bc6ab51a6cfec2582a8798393e29 100644 (file)
@@ -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);
-}
index e09072f8190ab4e6ea56e890ca8a5bd0ff10890e..861034ad9757248aec4fede54af9405da643c158 100644 (file)
@@ -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;
index d3502b707de34930fdd1d7c4f5125cd87a8fb550..dae720fba8a5e4fe23c1c318ae22583975abd392 100644 (file)
@@ -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);