Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-16 Thread Peter Eisentraut
On fre, 2010-11-12 at 09:44 -0500, Tom Lane wrote: But I'm still not convinced that this feature is useful enough to justify the implementation effort. AFAICS there's nothing here that you couldn't get with some non-default operators on regular arrays, Unique constraints would behave

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-16 Thread Tom Lane
Peter Eisentraut pete...@gmx.net writes: On fre, 2010-11-12 at 09:44 -0500, Tom Lane wrote: But I'm still not convinced that this feature is useful enough to justify the implementation effort. AFAICS there's nothing here that you couldn't get with some non-default operators on regular arrays,

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread Itagaki Takahiro
On Mon, Nov 15, 2010 at 14:37, Pavel Stehule pavel.steh...@gmail.com wrote: Maybe can be useful to implement a searching on sorted array. You can hold a flag if multiset is sorted or not. Are you suggesting to add an IS_SORTED bit to for each ArrayType value? It might be possible, but I'm not

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread Pavel Stehule
2010/11/15 Itagaki Takahiro itagaki.takah...@gmail.com: On Mon, Nov 15, 2010 at 14:37, Pavel Stehule pavel.steh...@gmail.com wrote: Maybe can be useful to implement a searching on sorted array. You can hold a flag if multiset is sorted or not. Are you suggesting to add an IS_SORTED bit to for

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread Andres Freund
On Monday 15 November 2010 09:47:15 Itagaki Takahiro wrote: On Mon, Nov 15, 2010 at 14:37, Pavel Stehule pavel.steh...@gmail.com wrote: Maybe can be useful to implement a searching on sorted array. You can hold a flag if multiset is sorted or not. Are you suggesting to add an IS_SORTED

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread Tom Lane
Itagaki Takahiro itagaki.takah...@gmail.com writes: Another issue for sorting is that we have 4 kinds of sorting: ASC/DESC and NULLS FIRST/LAST. We have a lot more kinds than that. See USING. regards, tom lane -- Sent via pgsql-hackers mailing list

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread David Fetter
On Mon, Nov 15, 2010 at 10:13:40AM -0500, Tom Lane wrote: Itagaki Takahiro itagaki.takah...@gmail.com writes: Another issue for sorting is that we have 4 kinds of sorting: ASC/DESC and NULLS FIRST/LAST. We have a lot more kinds than that. See USING. USING pretty much gives us no chance

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread Tom Lane
David Fetter da...@fetter.org writes: On Mon, Nov 15, 2010 at 10:13:40AM -0500, Tom Lane wrote: Itagaki Takahiro itagaki.takah...@gmail.com writes: Another issue for sorting is that we have 4 kinds of sorting: ASC/DESC and NULLS FIRST/LAST. We have a lot more kinds than that. See USING.

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-14 Thread Itagaki Takahiro
On Fri, Nov 12, 2010 at 00:02, Itagaki Takahiro itagaki.takah...@gmail.com wrote: Postgres supports ARRAY data types well, but there are some more array functions in the SQL standard. Also, the standard has MULTISET data type, that is an unordered array. Here is a WIP patch for multiset

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-14 Thread Pavel Stehule
Hello 2010/11/15 Itagaki Takahiro itagaki.takah...@gmail.com: On Fri, Nov 12, 2010 at 00:02, Itagaki Takahiro itagaki.takah...@gmail.com wrote: Postgres supports ARRAY data types well, but there are some more array functions in the SQL standard. Also, the standard has MULTISET data type,

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-12 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Fri, Nov 12, 2010 at 12:21 AM, Tom Lane t...@sss.pgh.pa.us wrote: The problem is not with the type system: as long as you give multisets different type OIDs from arrays, everything will work fine. And thus you must create a THIRD copy of every

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-12 Thread David Fetter
On Fri, Nov 12, 2010 at 12:53:09AM -0500, Robert Haas wrote: On Fri, Nov 12, 2010 at 12:21 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Thu, Nov 11, 2010 at 10:02 AM, Itagaki Takahiro itagaki.takah...@gmail.com wrote: If we reuse type IDs of arrays

[HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Itagaki Takahiro
Postgres supports ARRAY data types well, but there are some more array functions in the SQL standard. Also, the standard has MULTISET data type, that is an unordered array. It looks easy to support additional array functions. There might be some confusion to treat multi-dimensional arrays with

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread David E. Wheeler
On Nov 11, 2010, at 7:02 AM, Itagaki Takahiro wrote: MULTISET supports are more difficult. We have corresponding type IDs for each array, but we might not want to add additional IDs for multiset for each type. Any ideas for the issue? Why not? If we reuse type IDs of arrays for multisets,

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Tom Lane
David E. Wheeler da...@kineticode.com writes: So are you planning to implement multisets? It's a feature I'd love to see What actual functionality does it buy? AFAICT from Itagaki-san's description, it's an array only you ignore the specific element order. So what? You can write functions that

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread David E. Wheeler
On Nov 11, 2010, at 10:05 AM, Tom Lane wrote: So are you planning to implement multisets? It's a feature I'd love to see What actual functionality does it buy? AFAICT from Itagaki-san's description, it's an array only you ignore the specific element order. So what? You can write functions

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Darren Duncan
I think that it would be best to implement MULTISET in the same way that a TABLE is implemented. Logically and structurally they are the same thing, but that a MULTISET typically is used as a field value of a table row. Aka, a table and a multiset are just different names for a relation,

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Nicolas Barbier
2010/11/11 David E. Wheeler da...@kineticode.com: On Nov 11, 2010, at 10:05 AM, Tom Lane wrote: So are you planning to implement multisets? It's a feature I'd love to see What actual functionality does it buy?  AFAICT from Itagaki-san's description, it's an array only you ignore the

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread David E. Wheeler
On Nov 11, 2010, at 10:19 AM, Darren Duncan wrote: I think that it would be best to implement MULTISET in the same way that a TABLE is implemented. Logically and structurally they are the same thing, but that a MULTISET typically is used as a field value of a table row. Aka, a table and a

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread David E. Wheeler
On Nov 11, 2010, at 10:24 AM, Nicolas Barbier wrote: Also, no dupes. The multi in multiset indicates that duplicate elements are explicitly allowed and tracked. D'oh! Right. D -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription:

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Alvaro Herrera
Excerpts from David E. Wheeler's message of jue nov 11 15:45:55 -0300 2010: On Nov 11, 2010, at 10:19 AM, Darren Duncan wrote: I think that it would be best to implement MULTISET in the same way that a TABLE is implemented. Logically and structurally they are the same thing, but that a

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread David E. Wheeler
On Nov 11, 2010, at 12:08 PM, Alvaro Herrera wrote: That sounds like a composite type to me. No, it's perpendicular in the sense that while a composite type allows you to have different columns, this multiset thing lets you have rows (I initially thought about them as sets of scalars, but

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Merlin Moncure
On Thu, Nov 11, 2010 at 3:42 PM, David E. Wheeler da...@kineticode.com wrote: On Nov 11, 2010, at 12:08 PM, Alvaro Herrera wrote: That sounds like a composite type to me. No, it's perpendicular in the sense that while a composite type allows you to have different columns, this multiset thing

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Darren Duncan
Merlin Moncure wrote: On Thu, Nov 11, 2010 at 3:42 PM, David E. Wheeler da...@kineticode.com wrote: On Nov 11, 2010, at 12:08 PM, Alvaro Herrera wrote: That sounds like a composite type to me. No, it's perpendicular in the sense that while a composite type allows you to have different

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Itagaki Takahiro
On Fri, Nov 12, 2010 at 03:05, Tom Lane t...@sss.pgh.pa.us wrote: David E. Wheeler da...@kineticode.com writes: So are you planning to implement multisets? It's a feature I'd love to see What actual functionality does it buy?  AFAICT from Itagaki-san's description, it's an array only you

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Itagaki Takahiro
On Fri, Nov 12, 2010 at 06:06, Darren Duncan dar...@darrenduncan.net wrote: This is one place that SQL made things more complicated than they needed to be.  Multisets have generally the same structure *and* operators (union, etc) as tables, but they use different syntax for each.  A better

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Robert Haas
On Thu, Nov 11, 2010 at 10:02 AM, Itagaki Takahiro itagaki.takah...@gmail.com wrote: If we reuse type IDs of arrays for multisets, the multisets would have some special typmod. For example, typmod = 0 means multiset, and positive value means array with max cardinality. Note that the SQL

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Thu, Nov 11, 2010 at 10:02 AM, Itagaki Takahiro itagaki.takah...@gmail.com wrote: If we reuse type IDs of arrays for multisets, the multisets would have some special typmod. For example, typmod = 0 means multiset, and positive value means array

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Robert Haas
On Fri, Nov 12, 2010 at 12:21 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Thu, Nov 11, 2010 at 10:02 AM, Itagaki Takahiro itagaki.takah...@gmail.com wrote: If we reuse type IDs of arrays for multisets, the multisets would have some special typmod. For