From: Marko Kreen Date: Fri, 16 Nov 2012 13:28:45 +0000 (+0200) Subject: Accept 't' proargmode, use symbolic names. X-Git-Tag: plproxy_2_5~6 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=8b260fb9e80aef0a38b20080a936a5f9780135e7;p=plproxy.git Accept 't' proargmode, use symbolic names. Also throw error on unknown proargmode. Fixes crash reported by Sébastien Lardière. --- diff --git a/src/function.c b/src/function.c index 6107795..19b77ad 100644 --- a/src/function.c +++ b/src/function.c @@ -356,15 +356,29 @@ fn_get_arguments(ProxyFunction *func, for (i = 0; i < total; i++) { - if (modes && modes[i] == 'o') - continue; - type = plproxy_find_type_info(func, types[i], 1); - pos = func->arg_count++; - func->arg_types[pos] = type; - if (names && names[i]) - func->arg_names[pos] = plproxy_func_strdup(func, names[i]); - else - func->arg_names[pos] = NULL; + char mode = modes ? modes[i] : PROARGMODE_IN; + switch (mode) { + case PROARGMODE_IN: + case PROARGMODE_INOUT: + type = plproxy_find_type_info(func, types[i], 1); + pos = func->arg_count++; + func->arg_types[pos] = type; + if (names && names[i]) + func->arg_names[pos] = plproxy_func_strdup(func, names[i]); + else + func->arg_names[pos] = NULL; + break; + case PROARGMODE_VARIADIC: + elog(ERROR, "PL/Proxy does not support variadic args"); + break; + case PROARGMODE_OUT: + case PROARGMODE_TABLE: + /* output args, ignore */ + break; + default: + elog(ERROR, "PL/Proxy: unknown value in proargmodes: %c", mode); + break; + } } } diff --git a/src/plproxy.h b/src/plproxy.h index da9b9d4..38185bd 100644 --- a/src/plproxy.h +++ b/src/plproxy.h @@ -95,6 +95,26 @@ #endif #endif +/* + * backwards compat with 8.4 + */ +#ifndef PROARGMODE_IN +#define PROARGMODE_IN 'i' +#endif +#ifndef PROARGMODE_OUT +#define PROARGMODE_OUT 'o' +#endif +#ifndef PROARGMODE_INOUT +#define PROARGMODE_INOUT 'b' +#endif +#ifndef PROARGMODE_VARIADIC +#define PROARGMODE_VARIADIC 'v' +#endif +#ifndef PROARGMODE_TABLE +#define PROARGMODE_TABLE 't' +#endif + + /* * Determine if this argument is to SPLIT */