diff options
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/cache/plancache.c | 13 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 3 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 44 | ||||
-rw-r--r-- | src/backend/utils/misc/postgresql.conf.sample | 1 |
4 files changed, 58 insertions, 3 deletions
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c index 61a576d35d9..4648b05803e 100644 --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@ -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.2 2007/03/15 23:12:06 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.3 2007/03/19 23:38:29 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -860,3 +860,14 @@ InvalRelid(Oid relid, LOCKMODE lockmode, InvalRelidContext *context) if (relid == context->inval_relid) 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/cache/relcache.c b/src/backend/utils/cache/relcache.c index 4ce955917a5..91b7f146b43 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.257 2007/03/03 20:08:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.258 2007/03/19 23:38:29 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -651,6 +651,7 @@ RelationBuildRuleLock(Relation relation) rule->event = rewrite_form->ev_type - '0'; rule->attrno = rewrite_form->ev_attr; + rule->enabled = rewrite_form->ev_enabled; rule->isInstead = rewrite_form->is_instead; /* diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8088432bac8..f921c75a60b 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.382 2007/03/13 14:32:25 petere Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.383 2007/03/19 23:38:30 wieck Exp $ * *-------------------------------------------------------------------- */ @@ -34,6 +34,7 @@ #include "commands/async.h" #include "commands/vacuum.h" #include "commands/variable.h" +#include "commands/trigger.h" #include "funcapi.h" #include "libpq/auth.h" #include "libpq/pqformat.h" @@ -59,6 +60,7 @@ #include "utils/guc_tables.h" #include "utils/memutils.h" #include "utils/pg_locale.h" +#include "utils/plancache.h" #include "utils/ps_status.h" #include "utils/tzparser.h" #include "utils/xml.h" @@ -124,6 +126,8 @@ static const char *assign_syslog_ident(const char *ident, static const char *assign_defaultxactisolevel(const char *newval, bool doit, GucSource source); +static const char *assign_session_replication_role(const char *newval, bool doit, + GucSource source); static const char *assign_log_min_messages(const char *newval, bool doit, GucSource source); static const char *assign_client_min_messages(const char *newval, @@ -226,6 +230,7 @@ static char *backslash_quote_string; static char *client_encoding_string; static char *datestyle_string; static char *default_iso_level_string; +static char *session_replication_role_string; static char *locale_collate; static char *locale_ctype; static char *regex_flavor_string; @@ -1929,6 +1934,16 @@ static struct config_string ConfigureNamesString[] = }, { + {"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT, + gettext_noop("Sets the sessions behaviour for triggers and rewrite rules."), + gettext_noop("Each session can be either" + " \"origin\", \"replica\" or \"local\".") + }, + &session_replication_role_string, + "origin", assign_session_replication_role, NULL + }, + + { {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER, gettext_noop("Sets the path for dynamically loadable modules."), gettext_noop("If a dynamically loadable module needs to be opened and " @@ -6116,6 +6131,33 @@ 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) + SessionReplicationRole = SESSION_REPLICATION_ROLE_ORIGIN; + } + else if (pg_strcasecmp(newval, "replica") == 0) + { + if (doit) + SessionReplicationRole = SESSION_REPLICATION_ROLE_REPLICA; + } + else if (pg_strcasecmp(newval, "local") == 0) + { + if (doit) + SessionReplicationRole = SESSION_REPLICATION_ROLE_LOCAL; + } + else + return NULL; + return newval; +} + +static const char * assign_log_min_messages(const char *newval, bool doit, GucSource source) { diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index cf2dfdc099e..22f9685bbdc 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -408,6 +408,7 @@ #default_transaction_isolation = 'read committed' #default_transaction_read_only = off #statement_timeout = 0 # 0 is disabled +#session_replication_role = "origin" #vacuum_freeze_min_age = 100000000 #xmlbinary = 'base64' #xmloption = 'content' |