[HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Pavel Stehule
Hello I am thinking about allowing 2D array from multicolumn subselect (all columns have to share same type, ofcourse). Is there some real limit, why this functionality is disallowed? Regards Pavel Stehule -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Robert Haas
On Tue, Nov 18, 2008 at 10:06 AM, Pavel Stehule [EMAIL PROTECTED] wrote: Hello I am thinking about allowing 2D array from multicolumn subselect (all columns have to share same type, ofcourse). Is there some real limit, why this functionality is disallowed? Seems like you could just write

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread David Fetter
On Tue, Nov 18, 2008 at 10:29:53AM -0500, Robert Haas wrote: On Tue, Nov 18, 2008 at 10:06 AM, Pavel Stehule [EMAIL PROTECTED] wrote: Hello I am thinking about allowing 2D array from multicolumn subselect (all columns have to share same type, ofcourse). Is there some real limit, why

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Sam Mason
On Tue, Nov 18, 2008 at 07:37:44AM -0800, David Fetter wrote: On Tue, Nov 18, 2008 at 10:29:53AM -0500, Robert Haas wrote: Seems like you could just write SELECT ARRAY[col1, col2, col3] instead of SELECT col1, col2, col3. If I understand this right, Pavel is thinking that

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Pavel Stehule
2008/11/18 David Fetter [EMAIL PROTECTED]: On Tue, Nov 18, 2008 at 10:29:53AM -0500, Robert Haas wrote: On Tue, Nov 18, 2008 at 10:06 AM, Pavel Stehule [EMAIL PROTECTED] wrote: Hello I am thinking about allowing 2D array from multicolumn subselect (all columns have to share same type,

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Pavel Stehule
2008/11/18 Sam Mason [EMAIL PROTECTED]: On Tue, Nov 18, 2008 at 07:37:44AM -0800, David Fetter wrote: On Tue, Nov 18, 2008 at 10:29:53AM -0500, Robert Haas wrote: Seems like you could just write SELECT ARRAY[col1, col2, col3] instead of SELECT col1, col2, col3. If I understand this right,

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Sam Mason
On Tue, Nov 18, 2008 at 05:20:27PM +0100, Pavel Stehule wrote: 2008/11/18 Sam Mason [EMAIL PROTECTED]: I've used this syntax before and got a surprising message back. I'd expect to be able to do the following: ARRAY((SELECT col1, col2 FROM (VALUES ('a',1), ('b',2)) x(col1,col2)));

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Sam Mason
On Tue, Nov 18, 2008 at 05:19:12PM +0100, Pavel Stehule wrote: there are some not necessary limits, because we should some operations: postgres=# select array(select * from foo); ERROR: subquery must return only one column LINE 1: select array(select * from foo); The current limitation

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Pavel Stehule
2008/11/18 Sam Mason [EMAIL PROTECTED]: On Tue, Nov 18, 2008 at 05:19:12PM +0100, Pavel Stehule wrote: there are some not necessary limits, because we should some operations: postgres=# select array(select * from foo); ERROR: subquery must return only one column LINE 1: select array(select

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Pavel Stehule
2008/11/18 Sam Mason [EMAIL PROTECTED]: On Tue, Nov 18, 2008 at 05:20:27PM +0100, Pavel Stehule wrote: 2008/11/18 Sam Mason [EMAIL PROTECTED]: I've used this syntax before and got a surprising message back. I'd expect to be able to do the following: ARRAY((SELECT col1, col2 FROM

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Tom Lane
Sam Mason [EMAIL PROTECTED] writes: I've used this syntax before and got a surprising message back. I'd expect to be able to do the following: ARRAY((SELECT col1, col2 FROM (VALUES ('a',1), ('b',2)) x(col1,col2))); and get the following back {(a,1),(b,2)}. So I think I'm with David. I

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Pavel Stehule
2008/11/18 Tom Lane [EMAIL PROTECTED]: Sam Mason [EMAIL PROTECTED] writes: I've used this syntax before and got a surprising message back. I'd expect to be able to do the following: and get the following back {(a,1),(b,2)}. So I think I'm with David. I concur --- if we support something

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Sam Mason
On Tue, Nov 18, 2008 at 06:55:26PM +0100, Pavel Stehule wrote: 2008/11/18 Sam Mason [EMAIL PROTECTED]: On Tue, Nov 18, 2008 at 05:20:27PM +0100, Pavel Stehule wrote: 2008/11/18 Sam Mason [EMAIL PROTECTED]: I've used this syntax before and got a surprising message back. I'd expect to be

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Pavel Stehule
2008/11/18 Sam Mason [EMAIL PROTECTED]: On Tue, Nov 18, 2008 at 06:55:26PM +0100, Pavel Stehule wrote: 2008/11/18 Sam Mason [EMAIL PROTECTED]: On Tue, Nov 18, 2008 at 05:20:27PM +0100, Pavel Stehule wrote: 2008/11/18 Sam Mason [EMAIL PROTECTED]: I've used this syntax before and got a

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Sam Mason
On Tue, Nov 18, 2008 at 06:22:21PM +, Sam Mason wrote: I've always been taught to design things so that the that the basic semantics should be as simple as possible which maintaining useful this should of course be while! ^ performance. CREATE FUNCTION

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Tom Lane
Pavel Stehule [EMAIL PROTECTED] writes: there are clean rules. you do array from input - when input is 1D array, then result is 2D array, when input is record, then result is 1D array of record. Where should be problem? That seems all right, but it's *not* what you first proposed, and what you

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Pavel Stehule
2008/11/18 Sam Mason [EMAIL PROTECTED]: On Tue, Nov 18, 2008 at 06:22:21PM +, Sam Mason wrote: I've always been taught to design things so that the that the basic semantics should be as simple as possible which maintaining useful this should of course be while! ^

Re: [HACKERS] is any reason why only one columns subselect are allowed in array()?

2008-11-18 Thread Sam Mason
On Tue, Nov 18, 2008 at 07:32:33PM +0100, Pavel Stehule wrote: 2008/11/18 Sam Mason [EMAIL PROTECTED]: this is what I think you want to do in the context of aggregates: CREATE FUNCTION array_concat_(ANYARRAY,ANYARRAY) RETURNS ANYARRAY AS $$ SELECT array_cat($1,ARRAY[$2]); $$