title: Create simple C function for PostgreSQL with array input and array output
body: <p>Can anyone share an example how I can create C function for PostgreSQL which takes array of two integers as input and returns array as output?</p>
  
  <p>For simple integer I have:</p>
  
  <pre><code>#include "postgres.h"
  #include &lt;fmgr.h&gt;
  
  #ifdef PG_MODULE_MAGIC
  PG_MODULE_MAGIC;
  #endif
  
  int
  add_one(int arg) {
      arg++;
      return arg;
  }
  </code></pre>
  
  <p>And after compilation in PostgreSQL:</p>
  
  <pre><code>load '/usr/lib/postgresql/9.1/lib/add_one';
  
      create or replace function add_one(integer)
        returns integer as
      '/usr/lib/postgresql/9.1/lib/add_one', 'add_one'
        language c;
  
      select add_one(1);
  </code></pre>
  
  <p>I need something like:</p>
  
  <pre><code>#include "postgres.h"
  #include &lt;fmgr.h&gt;
  
  #ifdef PG_MODULE_MAGIC
  PG_MODULE_MAGIC;
  #endif
  
  int
  add_one(int[] arg) {
      arg[1]++;
      arg[2] = arg[2] + 2
      return arg[];
  }
  </code></pre>
  
  <p>And in PostgreSQL:</p>
  
  <pre><code>load '/usr/lib/postgresql/9.1/lib/add_one';
  
  create or replace function add_one(integer[])
       returns integer[] as
      '/usr/lib/postgresql/9.1/lib/add_one', 'add_one'
        language c;
  
      select add_one(ARRAY[1::int,1::int]);
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/20329959/create-copy-of-postgresql-internal-c-function-and-load-it-as-user-defined-functi">I have tried</a> to modify some function from numeric.c, but without any success so far.</p>