Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-16 Thread Tom Lane
Peter Eisentraut 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, > Uniqu

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 differ

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread Tom Lane
David Fetter writes: > On Mon, Nov 15, 2010 at 10:13:40AM -0500, Tom Lane wrote: >> Itagaki Takahiro 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 ch

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 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 of optimizing at all.

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread Tom Lane
Itagaki Takahiro 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 (pgsql-hackers@postgresql.org) To make chan

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 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 Arr

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread Pavel Stehule
2010/11/15 Itagaki Takahiro : > On Mon, Nov 15, 2010 at 14:37, Pavel Stehule 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 possib

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-15 Thread Itagaki Takahiro
On Mon, Nov 15, 2010 at 14:37, Pavel Stehule 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 sure how much it is use

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-14 Thread Pavel Stehule
Hello 2010/11/15 Itagaki Takahiro : > On Fri, Nov 12, 2010 at 00:02, Itagaki Takahiro > 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 pa

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-14 Thread Itagaki Takahiro
On Fri, Nov 12, 2010 at 00:02, Itagaki Takahiro 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 function supports. Note that m

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 wrote: > > Robert Haas writes: > >> On Thu, Nov 11, 2010 at 10:02 AM, Itagaki Takahiro > >> wrote: > >>> If we reuse type IDs of arrays for multisets, the multisets would > >>> have some spe

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-12 Thread Tom Lane
Robert Haas writes: > On Fri, Nov 12, 2010 at 12:21 AM, Tom Lane 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 entry in pg_type. That > doesn't qual

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 wrote: > Robert Haas writes: >> On Thu, Nov 11, 2010 at 10:02 AM, Itagaki Takahiro >> 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 val

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Tom Lane
Robert Haas writes: > On Thu, Nov 11, 2010 at 10:02 AM, Itagaki Takahiro > 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 Robert Haas
On Thu, Nov 11, 2010 at 10:02 AM, Itagaki Takahiro 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 standard doesn't mention abou

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Itagaki Takahiro
On Fri, Nov 12, 2010 at 06:06, Darren Duncan 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 design > would be to make

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Itagaki Takahiro
On Fri, Nov 12, 2010 at 03:05, Tom Lane wrote: > "David E. Wheeler" 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.

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 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 th

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 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 lets yo

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 scala

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

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 subscriptio

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 an

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Nicolas Barbier
2010/11/11 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

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, loose

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 func

Re: [HACKERS] MULTISET and additional functions for ARRAY

2010-11-11 Thread Tom Lane
"David E. Wheeler" 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 work that way now

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

[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 the