Re: MULTISET and additional functions for ARRAY
Darren Duncan <darren@darrenduncan.net>
From: Darren Duncan <darren@darrenduncan.net>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2010-11-11T18:19:08Z
Lists: pgsql-hackers
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, loosely speaking. The association of a multiset-typed attribute of a table with said table is like the association of a child and parent table in a many-to-one. So reuse your structure for tables to hold multisets. -- Darren Duncan 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. > > It looks easy to support additional array functions. There > might be some confusion to treat multi-dimensional arrays > with them, but we could treat all arrays as one-dimensional > like as unnest(). > > 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? > > 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 about multi-dimensional arrays. > So, we can use typmod = -1 as a free-size and free-dimensional > array for backward compatibility. > > If we have troublesome issues to support multiset data types, > I'm thinking to add multiset functions that receives ARRAY > types instead at time first time, because an ARRAY is a > MULTISET by definition. Some of functions for multisets > seems to be useful for arrays, too. > > Comments and suggestions welcome.