1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Make SQL arrays support null elements. This commit fixes the core array

functionality, but I still need to make another pass looking at places
that incidentally use arrays (such as ACL manipulation) to make sure they
are null-safe.  Contrib needs work too.
I have not changed the behaviors that are still under discussion about
array comparison and what to do with lower bounds.
This commit is contained in:
Tom Lane
2005-11-17 22:14:56 +00:00
parent c859308aba
commit cecb607559
35 changed files with 2149 additions and 950 deletions

View File

@ -87,7 +87,7 @@ GetPGArray(PGARRAY * p, AggState *aggstate, bool fAdd)
p = (PGARRAY *) MemoryContextAlloc(aggstate->aggcontext, cb);
p->a.size = cb;
p->a.ndim = 1;
p->a.flags = 0;
p->a.dataoffset = 0; /* we don't support nulls, for now */
p->a.elemtype = INT4OID;
p->items = 0;
p->lower = START_NUM;

View File

@ -208,12 +208,13 @@ ArrayType *
new_intArrayType(int num)
{
ArrayType *r;
int nbytes = ARR_OVERHEAD(NDIM) + sizeof(int) * num;
int nbytes = ARR_OVERHEAD_NONULLS(NDIM) + sizeof(int) * num;
r = (ArrayType *) palloc0(nbytes);
ARR_SIZE(r) = nbytes;
ARR_NDIM(r) = NDIM;
r->dataoffset = 0; /* marker for no null bitmap */
ARR_ELEMTYPE(r) = INT4OID;
*((int *) ARR_DIMS(r)) = num;
*((int *) ARR_LBOUND(r)) = 1;
@ -224,7 +225,7 @@ new_intArrayType(int num)
ArrayType *
resize_intArrayType(ArrayType *a, int num)
{
int nbytes = ARR_OVERHEAD(NDIM) + sizeof(int) * num;
int nbytes = ARR_OVERHEAD_NONULLS(NDIM) + sizeof(int) * num;
if (num == ARRNELEMS(a))
return a;

View File

@ -232,7 +232,7 @@ rewrite_accum(PG_FUNCTION_ARGS) {
if (ARR_ELEMTYPE(qa) != tsqOid)
elog(ERROR, "array should contain tsquery type");
deconstruct_array(qa, tsqOid, -1, false, 'i', &elemsp, &nelemsp);
deconstruct_array(qa, tsqOid, -1, false, 'i', &elemsp, NULL, &nelemsp);
q = (QUERYTYPE*)DatumGetPointer( elemsp[0] );
if ( q->size == 0 ) {