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. === Array functions === - [FUNCTION] cardinality(anyarray) => integer - [FUNCTION] trim_array(anyarray, nTrimmed integer) => anyarray === Multiset functions === - [FUNCTION] cardinality(anymultiset) => integer - [FUNCTION] element(anymultiset) => anyelement - [FUNCTION] multiset_member_of(anymultiset, anyelement) => boolean [SYNTAX] $2 MEMBER OF $1 - [FUNCTION] multiset_is_a_set(anymultiset) => boolean [SYNTAX] $1 IS A SET - [FUNCTION] multiset_sub_multiset_of(anymultiset, anymultiset) => boolean [SYNTAX] $2 SUB MULTISET OF $1 - [FUNCTION] multiset_union[_all](anymultiset, anymultiset) => anymultiset [SYNTAX] $1 MULTISET UNION [ALL | DISTINCT] $2 - [FUNCTION] multiset_intersect[_all](anymultiset, anymultiset) => anymultiset [SYNTAX] $1 MULTISET INTERSECT [ALL | DISTINCT] $2 - [FUNCTION] multiset_except[_all](anymultiset, anymultiset) => anymultiset [SYNTAX] $1 MULTISET EXCEPT [ALL | DISTINCT] $2 - [AGGREGATE] collect(anyelement) => anymultiset - [AGGREGATE] fusion(anymultiset) => anymultiset - [AGGREGATE] intersection(anymultiset) => anymultiset See also secondary sources. http://waelchatila.com/2005/05/18/1116485743467.html http://farrago.sourceforge.net/design/CollectionTypes.html http://publib.boulder.ibm.com/infocenter/db2luw/v9r8/index.jsp?topic=/com.ibm.db2.luw.apdv.sqlpl.doc/doc/t0053486.html http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/conditions006.htm http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/operators006.htm -- Itagaki Takahiro -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers