]> granicus.if.org Git - postgresql/commitdiff
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 75810caa732dd659acf58601f53b61742a8c221e..21aed6eadbe56086ebdfd539a3f7304fd36a48ba 100644 (file)
@@ -33,7 +33,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.9 2007/05/14 18:13:21 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.10 2007/06/05 20:00:41 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 ec547a66706dd9fe7868d501efa3721b370fa08c..3428d0a172f3e0e75e984445f147f836104b7cc9 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.393 2007/06/03 17:07:34 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.394 2007/06/05 20:00:41 wieck Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -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 aebbbadaf51169b1536f9fdcdd94e1365047d861..d8152142aacbc537ca88227aa5cdd28d587eca8f 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.6 2007/04/16 18:21:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.7 2007/06/05 20:00:41 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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);