array support patch phase 1 patch

From: Joe Conway <mail(at)joeconway(dot)com>
To: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: array support patch phase 1 patch
Date: 2003-03-25 05:45:20
Message-ID: 3E7FECF0.7060904@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

This patch is starting to get large enough that it is a challenge to
keep in sync with cvs, and it is reasonably complete as a package, so I
was hoping it could be reviewed and committed as "array support phase
1". The most notable missing item is documentation, but if possible I'd
like to defer that until a few more items are complete (see
"Yet-to-come" below).

If a more complete package (e.g. want to wait for items 1-5 of
"Yet-to-come") is preferred, please let me know and I'll keep plugging
along.

Note that the gram.y changes are a bit ugly, but I struggled with
getting anything less ugly to work.

As is, it passes all regression tests (make installcheck), and covers
the following:
----------------------------------------------------------------------
1. Support for polymorphic functions, accepting and returning ANYARRAY
and ANYELEMENT datatypes that are "tied" to each other and resolved to
an actual type at runtime. This also includes the ability to define
aggregates using the polymorphic functions.

2. Array handling functions:
- singleton_array(ANYELEMENT) returns ANYARRAY
- array_push(ANYARRAY, ANYELEMENT) returns ANYARRAY
- array_accum(ANYARRAY, ANYELEMENT) returns ANYARRAY
- array_assign(ANYARRAY, int, ANYELEMENT) returns ANYARRAY
- array_subscript(ANYARRAY, int) returns ANYELEMENT

3. Grammar and underlying support for the following (examples):

create table foo(f1 integer ARRAY);
create table foo(f1 integer ARRAY[]);
create table foo(f1 integer ARRAY[x]);
create table foo(f1 integer ARRAY[][]); (and more [] etc)
create table foo(f1 integer ARRAY[x][y]); (and more [] etc)

select ARRAY[1,2,3];
select ARRAY[[1,2,3],[4,5,6]];
select ARRAY[ARRAY[1,2,3],ARRAY[4,5,6]];
etc up to 6 dimensions

select ARRAY(select oid from pg_class order by relname);

Yet-to-come:
---------------------------------
1. Functions:
- str_to_array(str TEXT, delim TEXT) returns TEXT[]
- array_to_str(array ANYARRAY, delim TEXT) returns TEXT

2. Grammar:
select ARRAY[1,2] || 3;
select ARRAY[1,2] || ARRAY[3,4];
select ARRAY[[1,2],[3,4]] || 5;
select ARRAY[[1,2],[3,4]] || [5,6]

3. Documentation update:
Update "User's Guide"->"Data Types"->"Arrays" documentation
create a new section: "User's Guide"->
"Functions and Operators"->
"Array Functions and Operators"

4. PL/pgSQL support for polymorphic types

5. SQL function support for polymorphic types.

6. Move as much of contrib/array into backend as makes sense (I haven't
looked too close yet), including migration to use polymorphic
semantics.

7. Move as much of contrib/intarray into backend as makes sense (I
haven't looked too close yet), including migration to use
polymorphic semantics (therefore make work on other than int
where possible).

8. Additional documentation and regression test updates

Thanks,

Joe

Attachment Content-Type Size
array-gen.17.patch.gz application/x-gzip 19.9 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-03-25 06:42:35 Re: array support patch phase 1 patch
Previous Message Joe Conway 2003-03-24 18:57:50 Re: SQL99 ARRAY support proposal