Re: MULTISET and additional functions for ARRAY

From: Darren Duncan <darren(at)darrenduncan(dot)net>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: MULTISET and additional functions for ARRAY
Date: 2010-11-11 18:19:08
Message-ID: 4CDC339C.30909@darrenduncan.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nicolas Barbier 2010-11-11 18:24:00 Re: MULTISET and additional functions for ARRAY
Previous Message Heikki Linnakangas 2010-11-11 18:12:21 Re: B-tree parent pointer and checkpoints