From: Petr Jelinek Date: Mon, 15 Aug 2011 09:51:09 +0000 (+0200) Subject: support global SQL/MED cluster options X-Git-Tag: plproxy_2_3_rc1~6 X-Git-Url: http://git.postgresql.org/gitweb/edit?a=commitdiff_plain;h=f00da38326562145e82038136333b5911f1bb2df;p=plproxy.git support global SQL/MED cluster options --- diff --git a/src/cluster.c b/src/cluster.c index 4d43aed..234f4a1 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -391,6 +391,28 @@ extract_part_num(const char *partname, int *part_num) return false; } +/* + * Validate single cluster option + */ +static void +validate_cluster_option(const char *name, const char *arg) +{ + const char **opt; + + /* see that a valid config option is specified */ + for (opt = cluster_config_options; *opt; opt++) + { + if (pg_strcasecmp(*opt, name) == 0) + break; + } + + if (*opt == NULL) + elog(ERROR, "Pl/Proxy: invalid server option: %s", name); + else if (strspn(arg, "0123456789") != strlen(arg)) + elog(ERROR, "Pl/Proxy: only integer options are allowed: %s=%s", + name, arg); +} + /* * Validate the generic option given to servers or user mappings defined with * plproxy foreign data wrapper. Raise an ERROR if the option or its value is @@ -435,20 +457,7 @@ plproxy_fdw_validator(PG_FUNCTION_ARGS) } else { - const char **opt; - - /* see that a valid config option is specified */ - for (opt = cluster_config_options; *opt; opt++) - { - if (pg_strcasecmp(*opt, def->defname) == 0) - break; - } - - if (*opt == NULL) - elog(ERROR, "Pl/Proxy: invalid server option: %s", def->defname); - else if (strspn(arg, "0123456789") != strlen(arg)) - elog(ERROR, "Pl/Proxy: only integer options are allowed: %s=%s", - def->defname, arg); + validate_cluster_option(def->defname, arg); } } else if (catalog == UserMappingRelationId) @@ -465,8 +474,7 @@ plproxy_fdw_validator(PG_FUNCTION_ARGS) } else if (catalog == ForeignDataWrapperRelationId) { - /* At the moment there are no options to the fdw itself */ - elog(WARNING, "Pl/Proxy: foreign data wrapper takes no options"); + validate_cluster_option(def->defname, arg); } } @@ -553,6 +561,16 @@ reload_sqlmed_cluster(ProxyFunction *func, ProxyCluster *cluster, appendStringInfo(user_options, "%s='%s' ", def->defname, strVal(def->arg)); } + /* + * Collect the configuration definitions from foreign data wrapper. + */ + foreach(cell, fdw->options) + { + DefElem *def = lfirst(cell); + + set_config_key(func, &cluster->config, def->defname, strVal(def->arg)); + } + /* * Collect the cluster configuration and partition definitions from foreign * server options. At first pass just collect the cluster options and count