diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-27 00:33:26 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-27 00:33:26 +0000 |
commit | b3c0551edaf390ab7bde4ebcc2299d1b0da686c5 (patch) | |
tree | 46512d8ab2d8eeb570722878904f367effb1383d /src/include/utils/array.h | |
parent | 0c985ab5a86b4ca9d8e312bfd0db5536b2be121e (diff) | |
download | postgresql-b3c0551edaf390ab7bde4ebcc2299d1b0da686c5.tar.gz postgresql-b3c0551edaf390ab7bde4ebcc2299d1b0da686c5.zip |
Create real array comparison functions (that use the element datatype's
comparison functions), replacing the highly bogus bitwise array_eq. Create
a btree index opclass for ANYARRAY --- it is now possible to create indexes
on array columns.
Arrange to cache the results of catalog lookups across multiple array
operations, instead of repeating the lookups on every call.
Add string_to_array and array_to_string functions.
Remove singleton_array, array_accum, array_assign, and array_subscript
functions, since these were for proof-of-concept and not intended to become
supported functions.
Minor adjustments to behavior in some corner cases with empty or
zero-dimensional arrays.
Joe Conway (with some editorializing by Tom Lane).
Diffstat (limited to 'src/include/utils/array.h')
-rw-r--r-- | src/include/utils/array.h | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/src/include/utils/array.h b/src/include/utils/array.h index 23a32d3459e..0d99816c246 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: array.h,v 1.40 2003/06/25 21:30:33 momjian Exp $ + * $Id: array.h,v 1.41 2003/06/27 00:33:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -32,6 +32,37 @@ typedef struct Oid elemtype; /* element type OID */ } ArrayType; +typedef struct ArrayBuildState +{ + MemoryContext mcontext; /* where all the temp stuff is kept */ + Datum *dvalues; /* array of accumulated Datums */ + /* + * The allocated size of dvalues[] is always a multiple of + * ARRAY_ELEMS_CHUNKSIZE + */ +#define ARRAY_ELEMS_CHUNKSIZE 64 + int nelems; /* number of valid Datums in dvalues[] */ + Oid element_type; /* data type of the Datums */ + int16 typlen; /* needed info about datatype */ + bool typbyval; + char typalign; +} ArrayBuildState; + +/* + * structure to cache type metadata needed for array manipulation + */ +typedef struct ArrayMetaState +{ + Oid element_type; + int16 typlen; + bool typbyval; + char typalign; + char typdelim; + Oid typelem; + Oid typiofunc; + FmgrInfo proc; +} ArrayMetaState; + /* * fmgr macros for array objects */ @@ -86,11 +117,15 @@ extern Datum array_recv(PG_FUNCTION_ARGS); extern Datum array_send(PG_FUNCTION_ARGS); extern Datum array_length_coerce(PG_FUNCTION_ARGS); extern Datum array_eq(PG_FUNCTION_ARGS); +extern Datum array_ne(PG_FUNCTION_ARGS); +extern Datum array_lt(PG_FUNCTION_ARGS); +extern Datum array_gt(PG_FUNCTION_ARGS); +extern Datum array_le(PG_FUNCTION_ARGS); +extern Datum array_ge(PG_FUNCTION_ARGS); +extern Datum btarraycmp(PG_FUNCTION_ARGS); extern Datum array_dims(PG_FUNCTION_ARGS); extern Datum array_lower(PG_FUNCTION_ARGS); extern Datum array_upper(PG_FUNCTION_ARGS); -extern Datum array_assign(PG_FUNCTION_ARGS); -extern Datum array_subscript(PG_FUNCTION_ARGS); extern Datum array_type_coerce(PG_FUNCTION_ARGS); extern Datum array_ref(ArrayType *array, int nSubscripts, int *indx, @@ -124,7 +159,14 @@ extern void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, int *nelemsp); - +extern ArrayBuildState *accumArrayResult(ArrayBuildState *astate, + Datum dvalue, bool disnull, + Oid element_type, + MemoryContext rcontext); +extern Datum makeArrayResult(ArrayBuildState *astate, + MemoryContext rcontext); +extern Datum makeMdArrayResult(ArrayBuildState *astate, int ndims, + int *dims, int *lbs, MemoryContext rcontext); /* * prototypes for functions defined in arrayutils.c @@ -141,12 +183,11 @@ extern int mda_next_tuple(int n, int *curr, int *span); /* * prototypes for functions defined in array_userfuncs.c */ -extern Datum singleton_array(PG_FUNCTION_ARGS); extern Datum array_push(PG_FUNCTION_ARGS); -extern Datum array_accum(PG_FUNCTION_ARGS); extern Datum array_cat(PG_FUNCTION_ARGS); -extern ArrayType *create_singleton_array(Oid element_type, +extern ArrayType *create_singleton_array(FunctionCallInfo fcinfo, + Oid element_type, Datum element, int ndims); |