title: PostgreSQL multidimensional arrays
body: <p>I'm trying to pass data around as a multidimensional array, and I'm getting behavior that seems odd to me. Specifically I'm trying to get a single element out of a 2 dimensional array (so a 1 dimensional array out of my 2 dimension array), and it doesn't work the way I'd expect.</p>
  
  <p>In the following examples #2, 4, &amp; 5 work the way I'd expect, but 1 &amp; 3 do not.</p>
  
  <pre><code>db=&gt; select s.col[2] from (select array[[1,2,3],[4,5,6]] as col) s;
   col
  -----
  
  (1 row)
  
  db=&gt; select s.col[2:2] from (select array[[1,2,3],[4,5,6]] as col) s;
   col 
  -----
   {{4,5,6}}
  (1 row)
  
  db=&gt; select array[s.col[2]] from (select array[[1,2,3],[4,5,6]] as col) s;
   array  
  --------
   {NULL}
  (1 row)
  
  db=&gt; select array[s.col[2:2]] from (select array[[1,2,3],[4,5,6]] as col) s;
      array    
   -------------
   {{{4,5,6}}}
  (1 row)
  
  db=&gt; select s.col[2][1] from (select array[[1,2,3],[4,5,6]] as col) s;
   col 
  -----
     4
  (1 row)
  </code></pre>
  
  <p>Is there doc on this? I have something that's working well enough for me right now, but it's ugly and I worry it won't do the things I want to do next. Technically I'm getting a 2 dimensional array, where 1 dimension only has 1 element. I'd rather just get an array.</p>
  
  <p>I've read (among others):</p>
  
  <ul>
  <li><a href="http://www.postgresql.org/docs/9.1/static/arrays.html" rel="noreferrer">http://www.postgresql.org/docs/9.1/static/arrays.html</a></li>
  <li><a href="http://www.postgresql.org/docs/9.1/static/functions-array.html" rel="noreferrer">http://www.postgresql.org/docs/9.1/static/functions-array.html</a></li>
  <li><a href="http://www.postgresql.org/docs/9.1/static/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS" rel="noreferrer">http://www.postgresql.org/docs/9.1/static/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS</a></li>
  </ul>
  
  <p>And I'm just not seeing what I'm looking for.</p>