Peter Eisentraut wrote: > It was pointed out to me today that a zero-dimensional > matrix is a scalar. This makes a bit of sense, if you say > that > > '{{56}}' is of type int[][], 2 dimensions > '{56}' is of type int[], 1 dimension > '56' is of type int, 0 dimensions > > Notice that the number of brace pairs in the literal > matches the number of bracket pairs in the type > declaration. > > By that logic, '{}' has one dimension. I think this also > works best in practice, for example with array > concatenation.
When I think about this, I think that '{x}' has dimension 1 greater than 'x'. So '{x}' may be a 2-D array, if 'x' is a 1-D array. But it is always the case that dim('{x}')>= 1. It seems logical therefore to treat '{}' as an empty array of something (possibly other arrays), but its precise meaning is undefined until you actually coerce it into a specific type. Thus you could have: '{}'::int - illegal '{}'::int[] - empty array of integers '{}'::int[][] - empty 2-D array of integers However, I would say that '{{}}' isn't an empty array, since the outer array has 1 element ('{}'). So this leads to: '{{}}'::int - illegal '{{}}'::int[] - illegal '{{}}'::int[][] - non-empty array containing an empty array of integers (ie. a 1x0 matrix) '{{},{}}'::int[][] - non-empty array containing 2 empty arrays of integers (ie. a 2x0 matrix) I don't know if Nx0 matrices actually have any use, but that's where the logic takes me. Dean _________________________________________________________________ Win £1000 John Lewis shopping sprees with BigSnapSearch.com http://clk.atdmt.com/UKM/go/117442309/direct/01/ -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers