aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/array.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/utils/array.h')
-rw-r--r--src/include/utils/array.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/include/utils/array.h b/src/include/utils/array.h
index 4fb296671d7..4d915e0665f 100644
--- a/src/include/utils/array.h
+++ b/src/include/utils/array.h
@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: array.h,v 1.25 2000/06/13 07:35:30 tgl Exp $
+ * $Id: array.h,v 1.26 2000/07/17 03:05:32 tgl Exp $
*
* NOTES
* XXX the data array should be MAXALIGN'd -- notice that the array
@@ -24,16 +24,28 @@
#define ARRAY_H
#include "fmgr.h"
-#include "utils/memutils.h"
+/*
+ * Arrays are varlena objects, so must meet the varlena convention that
+ * the first int32 of the object contains the total object size in bytes.
+ */
typedef struct
{
- int size; /* total array size (in bytes) */
+ int32 size; /* total array size (varlena requirement) */
int ndim; /* # of dimensions */
int flags; /* implementation flags */
} ArrayType;
/*
+ * fmgr macros for array objects
+ */
+#define DatumGetArrayTypeP(X) ((ArrayType *) PG_DETOAST_DATUM(X))
+#define DatumGetArrayTypePCopy(X) ((ArrayType *) PG_DETOAST_DATUM_COPY(X))
+#define PG_GETARG_ARRAYTYPE_P(n) DatumGetArrayTypeP(PG_GETARG_DATUM(n))
+#define PG_GETARG_ARRAYTYPE_P_COPY(n) DatumGetArrayTypePCopy(PG_GETARG_DATUM(n))
+#define PG_RETURN_ARRAYTYPE_P(x) PG_RETURN_POINTER(x)
+
+/*
* bitmask of ArrayType flags field:
* 1st bit - large object flag
* 2nd bit - chunk flag (array is chunked if set)
@@ -43,11 +55,9 @@ typedef struct
#define ARR_CHK_FLAG (0x2)
#define ARR_OBJ_MASK (0x1c)
-#define ARR_FLAGS(a) ((ArrayType *) a)->flags
#define ARR_SIZE(a) (((ArrayType *) a)->size)
-
#define ARR_NDIM(a) (((ArrayType *) a)->ndim)
-#define ARR_NDIM_PTR(a) (&(((ArrayType *) a)->ndim))
+#define ARR_FLAGS(a) (((ArrayType *) a)->flags)
#define ARR_IS_LO(a) \
(((ArrayType *) a)->flags & ARR_LOB_FLAG)
@@ -102,7 +112,6 @@ typedef struct
#define RETURN_NULL(type) do { *isNull = true; return (type) 0; } while (0)
#define NAME_LEN 30
-#define MAX_BUFF_SIZE BLCKSZ
typedef struct
{
@@ -134,6 +143,12 @@ extern ArrayType *array_assgn(ArrayType *array, int nSubscripts,
bool elmbyval, int elmlen, bool *isNull);
extern Datum array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType);
+extern ArrayType *construct_array(Datum *elems, int nelems,
+ bool elmbyval, int elmlen, char elmalign);
+extern void deconstruct_array(ArrayType *array,
+ bool elmbyval, int elmlen, char elmalign,
+ Datum **elemsp, int *nelemsp);
+
extern int _LOtransfer(char **destfd, int size, int nitems, char **srcfd,
int isSrcLO, int isDestLO);
extern char *_array_newLO(int *fd, int flag);