pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work
4+ messages / 3 participants
[nested] [flat]

* BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work
@ 2011-12-05 02:35 maxim.boguk@gmail.com
  2011-12-05 03:05 ` Re: BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: maxim.boguk@gmail.com @ 2011-12-05 02:35 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      6326
Logged by:          Maksym Boguk
Email address:      maxim.boguk@gmail.com
PostgreSQL version: 9.1.1
Operating system:   Linux
Description:        

SELECT ARRAY(SELECT ...) 
doesn't work when subselect return any array.

Test case:

db=# SELECT ARRAY(SELECT 1 UNION ALL SELECT 2);
 ?column?
----------
 {1,2}

All good... now:

db=# SELECT ARRAY(SELECT array[1,2]::float[] UNION ALL SELECT
array[3,4]::float[]);
ERROR:  could not find array type for data type double precision[]
db=# SELECT ARRAY(SELECT array[1,2]::integer[] UNION ALL SELECT
array[3,4]::integer[]);
ERROR:  could not find array type for data type integer[]

Is that syntax supposed to work with anyarray types?





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work
  2011-12-05 02:35 BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work maxim.boguk@gmail.com
@ 2011-12-05 03:05 ` Tom Lane <tgl@sss.pgh.pa.us>
  2011-12-05 03:25   ` Re: BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work Maxim Boguk <maxim.boguk@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2011-12-05 03:05 UTC (permalink / raw)
  To: maxim.boguk@gmail.com; +Cc: pgsql-bugs

maxim.boguk@gmail.com writes:
> SELECT ARRAY(SELECT ...) 
> doesn't work when subselect return any array.
> Is that syntax supposed to work with anyarray types?

No.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work
  2011-12-05 02:35 BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work maxim.boguk@gmail.com
  2011-12-05 03:05 ` Re: BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work Tom Lane <tgl@sss.pgh.pa.us>
@ 2011-12-05 03:25   ` Maxim Boguk <maxim.boguk@gmail.com>
  2011-12-05 03:40     ` Re: BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Maxim Boguk @ 2011-12-05 03:25 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

On Mon, Dec 5, 2011 at 2:05 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> maxim.boguk@gmail.com writes:
> > SELECT ARRAY(SELECT ...)
> > doesn't work when subselect return any array.
> > Is that syntax supposed to work with anyarray types?
>
> No.
>
>                        regards, tom lane
>

Hi.

Thank you very much for answer.

Ok the second problem (possible related to first becuse error is the same):

array_agg doesn't work with anyarray as well:

sports=# select array_agg(val) FROM (SELECT array[1,2]::integer[] as val
UNION ALL SELECT array[3,4]::integer[]) as t;
ERROR:  could not find array type for data type integer[]


PS: I try create two-dimentional integer array from  query results:

select val1::integer, val2::integer from somequery

to get integer[][] with content like:
[[val1-1,val1-2], [val2-1, val2-2], val[3-1, val3-2]... ]

Is there any way to perform that task it with reasonable efficiency?


-- 
Maxim Boguk
Senior Postgresql DBA.

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work
  2011-12-05 02:35 BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work maxim.boguk@gmail.com
  2011-12-05 03:05 ` Re: BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work Tom Lane <tgl@sss.pgh.pa.us>
  2011-12-05 03:25   ` Re: BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work Maxim Boguk <maxim.boguk@gmail.com>
@ 2011-12-05 03:40     ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2011-12-05 03:40 UTC (permalink / raw)
  To: Maxim Boguk <maxim.boguk@gmail.com>; +Cc: pgsql-bugs

Maxim Boguk <maxim.boguk@gmail.com> writes:
> PS: I try create two-dimentional integer array from  query results:

Well, you could do that with a suitably defined aggregate having the
signature "agg(anyarray) returns anyarray".  But array_agg has the
signature "array_agg(anyelement) returns anyarray" so you can't use
it on an array input.  2-D arrays are not distinct from 1-D arrays
so far as the type system is concerned.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2011-12-05 03:40 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-12-05 02:35 BUG #6326: SELECT ARRAY(SELECT ...) syntax and array[] results doesn't work maxim.boguk@gmail.com
2011-12-05 03:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-12-05 03:25   ` Maxim Boguk <maxim.boguk@gmail.com>
2011-12-05 03:40     ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox