From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | David Helgason <david(at)uti(dot)is> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: array faults? |
Date: | 2004-01-09 15:25:49 |
Message-ID: | 23933.1073661949@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
David Helgason <david(at)uti(dot)is> writes:
> EXAMPLE 1:
> maint=# select ('{{1,2,3},{4,5,6}}'::int[])[1][1:3];
> int4
> -----------
> {{1,2,3}}
> (1 row)
> Shouldn't this have been just {1,2,3} ?
Nope. It's equivalent to (...)[1:1][1:3]. See section 8.10.3 "Accessing
Arrays" in the current documentation. Note in particular where it says
An array subscripting operation is always taken to represent an array
slice if any of the subscripts are written in the form lower:upper. A
lower bound of 1 is assumed for any subscript where only one value is
specified, ...
> Shouldn't this have been just {4,5,6} (or maybe {{4,5,6}} accepting the
> result of example 1) ?
See above. You need to write [2:2] not [2].
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Gerwin Philippo | 2004-01-09 15:57:55 | Re: Trouble with MsAccess and records above 13000 |
Previous Message | Antonio Gallardo | 2004-01-09 15:02:42 | Invalid UNICODE character sequence found(0xc000) |