Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dtwJJ-0005f4-PN for pgsql-docs@arkaria.postgresql.org; Mon, 18 Sep 2017 13:42:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dtwJJ-0001HT-C1 for pgsql-docs@arkaria.postgresql.org; Mon, 18 Sep 2017 13:42:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dtwJI-0001Ge-Ve for pgsql-docs@postgresql.org; Mon, 18 Sep 2017 13:42:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dtwJF-0006wh-DB for pgsql-docs@postgresql.org; Mon, 18 Sep 2017 13:42:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v8IDfwj1008946; Mon, 18 Sep 2017 09:41:58 -0400 From: Tom Lane To: athinivas cc: pgsql-docs@postgresql.org Subject: Re: Creating variable argument user defined functions in C In-reply-to: <1505721147356-0.post@n3.nabble.com> References: <1505721147356-0.post@n3.nabble.com> Comments: In-reply-to athinivas message dated "Mon, 18 Sep 2017 00:52:27 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8944.1505742118.1@sss.pgh.pa.us> Date: Mon, 18 Sep 2017 09:41:58 -0400 Message-ID: <8945.1505742118@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org athinivas writes: > For my project, I need to create a variable argument function which accepts > multiple strings & returns some transformed string. I've gone through the > https://www.postgresql.org/docs/9.6/static/xfunc-c.html doc..But there's no > clear documentation for variable args. For ordinary array types the VARIADIC marking makes no difference so far as the function is concerned; you just treat the last argument as a normal array. If you want to do VARIADIC ANY then the rules are different, since the arguments aren't necessarily all the same type and so can't be folded into an array. > I'able to understand we can have ArrayType as data type for same. But how to > iterate & process it??? Kindly help. There's plenty of examples in the core code. For the normal-array case look at anything that takes an array, e.g. json_extract_path. For VARIADIC ANY you might look at concat() or format(). regards, tom lane -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs