summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Kreen2012-04-02 10:11:03 +0000
committerMarko Kreen2012-04-02 10:11:03 +0000
commitf4d3658782d3ba4deb70b3c1fda604c9cc662e13 (patch)
treeb694120905f3d4b139ee58e2a64dbf4e9f2255b8
parent5fbaab61e6530b04a87a2330de3831c6df342e65 (diff)
Clear old config before loading new one.
This allows falling back to defaults when some value is dropped from config.
-rw-r--r--src/cluster.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cluster.c b/src/cluster.c
index eed1cbc..f32df7f 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -288,6 +288,13 @@ get_version(ProxyFunction *func, Datum dname)
return DatumGetInt32(bin_val);
}
+/* forget old values */
+static void
+clear_config(ProxyConfig *cf)
+{
+ memset(cf, 0, sizeof(*cf));
+}
+
/* set a configuration option. */
static void
set_config_key(ProxyFunction *func, ProxyConfig *cf, const char *key, const char *val)
@@ -336,6 +343,8 @@ get_config(ProxyCluster *cluster, Datum dname, ProxyFunction *func)
if (SPI_gettypeid(desc, 2) != TEXTOID)
plproxy_error(func, "Config column 2 must be text");
+ clear_config(&cluster->config);
+
/* fill values */
for (i = 0; i < SPI_processed; i++)
{
@@ -648,6 +657,9 @@ reload_sqlmed_cluster(ProxyFunction *func, ProxyCluster *cluster,
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, ACL_KIND_FOREIGN_SERVER, foreign_server->servername);
+ /* drop old config values */
+ clear_config(&cluster->config);
+
/*
* Collect the configuration definitions from foreign data wrapper.
*/