diff options
| author | Tom Lane | 2005-11-17 22:14:56 +0000 |
|---|---|---|
| committer | Tom Lane | 2005-11-17 22:14:56 +0000 |
| commit | cecb6075594a407b7adcd9c9a0c243ca4b43c9a3 (patch) | |
| tree | d3febb775476b082255aa6122b0ba80a8ba79b37 /src/pl | |
| parent | c859308aba7edef428994e6de90ff35f35a328c5 (diff) | |
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.
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plpgsql/src/pl_comp.c | 6 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 28 |
2 files changed, 17 insertions, 17 deletions
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index 2c84899519b..f899bb25262 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.94 2005/10/15 02:49:49 momjian Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.95 2005/11/17 22:14:55 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -787,6 +787,7 @@ fetchArgInfo(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, numargs = ARR_DIMS(arr)[0]; if (ARR_NDIM(arr) != 1 || numargs < 0 || + ARR_HASNULL(arr) || ARR_ELEMTYPE(arr) != OIDOID) elog(ERROR, "proallargtypes is not a 1-D Oid array"); Assert(numargs >= procStruct->pronargs); @@ -814,7 +815,7 @@ fetchArgInfo(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, { deconstruct_array(DatumGetArrayTypeP(proargnames), TEXTOID, -1, false, 'i', - &elems, &nelems); + &elems, NULL, &nelems); if (nelems != numargs) /* should not happen */ elog(ERROR, "proargnames must have the same number of elements as the function has arguments"); *p_argnames = (char **) palloc(sizeof(char *) * numargs); @@ -834,6 +835,7 @@ fetchArgInfo(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, arr = DatumGetArrayTypeP(proargmodes); /* ensure not toasted */ if (ARR_NDIM(arr) != 1 || ARR_DIMS(arr)[0] != numargs || + ARR_HASNULL(arr) || ARR_ELEMTYPE(arr) != CHAROID) elog(ERROR, "proargmodes is not a 1-D char array"); *p_argmodes = (char *) palloc(numargs * sizeof(char)); diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index df82dd3dc1b..608854cbb5f 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.154 2005/10/24 15:10:22 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.155 2005/11/17 22:14:55 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -3331,11 +3331,7 @@ exec_assign_value(PLpgSQL_execstate * estate, if (arraytyplen > 0) /* fixed-length array? */ return; - oldarrayval = construct_md_array(NULL, 0, NULL, NULL, - arrayelemtypeid, - elemtyplen, - elemtypbyval, - elemtypalign); + oldarrayval = construct_empty_array(arrayelemtypeid); } else oldarrayval = (ArrayType *) DatumGetPointer(oldarraydatum); @@ -3354,18 +3350,11 @@ exec_assign_value(PLpgSQL_execstate * estate, nsubscripts, subscriptvals, coerced_value, + *isNull, arraytyplen, elemtyplen, elemtypbyval, - elemtypalign, - isNull); - - /* - * Assign it to the base variable. - */ - exec_assign_value(estate, target, - PointerGetDatum(newarrayval), - arraytypeid, isNull); + elemtypalign); /* * Avoid leaking the result of exec_simple_cast_value, if it @@ -3375,6 +3364,15 @@ exec_assign_value(PLpgSQL_execstate * estate, pfree(DatumGetPointer(coerced_value)); /* + * Assign the new array to the base variable. It's never + * NULL at this point. + */ + *isNull = false; + exec_assign_value(estate, target, + PointerGetDatum(newarrayval), + arraytypeid, isNull); + + /* * Avoid leaking the modified array value, too. */ pfree(newarrayval); |
