From a3673cf98d089159cb006c29ec080f00c1f66670 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Wed, 28 Jul 2010 17:44:48 +0300 Subject: [PATCH] Fix returning of many-column result types MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Old code used FUNC_MAX_ARGS as limit for number of columns, but composite types can be larger. Use dynamic allocation instead. Patch by Hans-Jürgen Schönig --- src/result.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/result.c b/src/result.c index 38ef3eb..8b4bf2b 100644 --- a/src/result.c +++ b/src/result.c @@ -144,12 +144,16 @@ return_composite(ProxyFunction *func, ProxyConnection *conn, FunctionCallInfo fc { int i, col; - char *values[FUNC_MAX_ARGS]; - int fmts[FUNC_MAX_ARGS]; - int lengths[FUNC_MAX_ARGS]; + char **values; + int *fmts; + int *lengths; HeapTuple tup; ProxyComposite *meta = func->ret_composite; + values = palloc(meta->tupdesc->natts * sizeof(char *)); + fmts = palloc(meta->tupdesc->natts * sizeof(int)); + lengths = palloc(meta->tupdesc->natts * sizeof(int)); + for (i = 0; i < meta->tupdesc->natts; i++) { col = func->result_map[i]; @@ -167,6 +171,11 @@ return_composite(ProxyFunction *func, ProxyConnection *conn, FunctionCallInfo fc } } tup = plproxy_recv_composite(meta, values, lengths, fmts); + + pfree(lengths); + pfree(fmts); + pfree(values); + return HeapTupleGetDatum(tup); } -- 2.39.5