From f4d3658782d3ba4deb70b3c1fda604c9cc662e13 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Mon, 2 Apr 2012 13:11:03 +0300 Subject: [PATCH] Clear old config before loading new one. This allows falling back to defaults when some value is dropped from config. --- src/cluster.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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. */ -- 2.39.5