On Wed, Mar 25, 2009 at 12:58:46AM -0700, Scara Maccai wrote:
> I've altready asked this some months ago, but I've never seen any answers:
> 
> why do multidimensional arrays have to have matching extents for each
> dimension?

Because the dimensions define the rectangular bounds of the array in
n-dimensional space and not some arbitrarily complex shape.

This would be different from, say, Java where an array is always in
1-dimensional space and to "simulate" n-dimensional arrays you have
arrays whose elements point to other arrays.  These are semantically
different things but modern languages choose to blur the distinction for
reasons of simplicity.

> Is there any way this limit can be removed, even using a custom datatype?

What you're after is a way to have arrays of arrays; I could do the
following to get it sort of working:

  CREATE TABLE foo ( a INT[] );

  INSERT INTO foo VALUES (ARRAY[1,2,3]);
  INSERT INTO foo VALUES (ARRAY[9]);
  INSERT INTO foo VALUES (ARRAY[100,101,102,103,104]);

  SELECT ARRAY(SELECT foo FROM foo);

  SELECT (ARRAY(SELECT foo FROM foo))[1].a[1];

it's not very pretty or nice to work with (the literals look especially
nasty) but it seems to hold together (in 8.3 at least).


  Sam

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to