|
10 | 10 | * Written by Peter Eisentraut <peter_e@gmx.net>. |
11 | 11 | * |
12 | 12 | * IDENTIFICATION |
13 | | - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.394 2007/06/0520:00:41 wieck Exp $ |
| 13 | + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.395 2007/06/0521:50:19 tgl Exp $ |
14 | 14 | * |
15 | 15 | *-------------------------------------------------------------------- |
16 | 16 | */ |
@@ -6270,32 +6270,27 @@ assign_defaultxactisolevel(const char *newval, bool doit, GucSource source) |
6270 | 6270 | staticconstchar* |
6271 | 6271 | assign_session_replication_role(constchar*newval,booldoit,GucSourcesource) |
6272 | 6272 | { |
| 6273 | +intnewrole; |
| 6274 | + |
6273 | 6275 | if (pg_strcasecmp(newval,"origin")==0) |
6274 | | -{ |
6275 | | -if (doit) |
6276 | | -{ |
6277 | | -ResetPlanCache(); |
6278 | | -SessionReplicationRole=SESSION_REPLICATION_ROLE_ORIGIN; |
6279 | | -} |
6280 | | -} |
| 6276 | +newrole=SESSION_REPLICATION_ROLE_ORIGIN; |
6281 | 6277 | elseif (pg_strcasecmp(newval,"replica")==0) |
6282 | | -{ |
6283 | | -if (doit) |
6284 | | -{ |
6285 | | -ResetPlanCache(); |
6286 | | -SessionReplicationRole=SESSION_REPLICATION_ROLE_REPLICA; |
6287 | | -} |
6288 | | -} |
| 6278 | +newrole=SESSION_REPLICATION_ROLE_REPLICA; |
6289 | 6279 | elseif (pg_strcasecmp(newval,"local")==0) |
6290 | | -{ |
6291 | | -if (doit) |
6292 | | -{ |
6293 | | -ResetPlanCache(); |
6294 | | -SessionReplicationRole=SESSION_REPLICATION_ROLE_LOCAL; |
6295 | | -} |
6296 | | -} |
| 6280 | +newrole=SESSION_REPLICATION_ROLE_LOCAL; |
6297 | 6281 | else |
6298 | 6282 | returnNULL; |
| 6283 | + |
| 6284 | +/* |
| 6285 | + * Must flush the plan cache when changing replication role; but don't |
| 6286 | + * flush unnecessarily. |
| 6287 | + */ |
| 6288 | +if (doit&&SessionReplicationRole!=newrole) |
| 6289 | +{ |
| 6290 | +ResetPlanCache(); |
| 6291 | +SessionReplicationRole=newrole; |
| 6292 | +} |
| 6293 | + |
6299 | 6294 | returnnewval; |
6300 | 6295 | } |
6301 | 6296 |
|
|