From 8b260fb9e80aef0a38b20080a936a5f9780135e7 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Fri, 16 Nov 2012 15:28:45 +0200 Subject: [PATCH] Accept 't' proargmode, use symbolic names. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Also throw error on unknown proargmode. Fixes crash reported by Sébastien Lardière. --- src/function.c | 32 +++++++++++++++++++++++--------- src/plproxy.h | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) 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 */ -- 2.39.5