From cecb6075594a407b7adcd9c9a0c243ca4b43c9a3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 17 Nov 2005 22:14:56 +0000 Subject: 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. --- src/backend/utils/misc/guc.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/backend/utils/misc/guc.c') diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 79e162efc0..6b83f36321 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut . * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.299 2005/11/04 23:50:30 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.300 2005/11/17 22:14:54 tgl Exp $ * *-------------------------------------------------------------------- */ @@ -876,6 +876,16 @@ static struct config_bool ConfigureNamesBool[] = &check_function_bodies, true, NULL, NULL }, + { + {"array_nulls", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, + gettext_noop("Enable input of NULL elements in arrays."), + gettext_noop("When turned on, unquoted NULL in an array input " + "value means a NULL value; " + "otherwise it is taken literally.") + }, + &Array_nulls, + true, NULL, NULL + }, { {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, gettext_noop("Create new tables with OIDs by default."), @@ -5383,14 +5393,13 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value) } } - isnull = false; a = array_set(array, 1, &index, datum, - -1 /* varlenarray */ , + false, + -1 /* varlena array */ , -1 /* TEXT's typlen */ , false /* TEXT's typbyval */ , - 'i' /* TEXT's typalign */ , - &isnull); + 'i' /* TEXT's typalign */ ); } else a = construct_array(&datum, 1, @@ -5456,14 +5465,13 @@ GUCArrayDelete(ArrayType *array, const char *name) /* else add it to the output array */ if (newarray) { - isnull = false; newarray = array_set(newarray, 1, &index, d, + false, -1 /* varlenarray */ , -1 /* TEXT's typlen */ , false /* TEXT's typbyval */ , - 'i' /* TEXT's typalign */ , - &isnull); + 'i' /* TEXT's typalign */ ); } else newarray = construct_array(&d, 1, -- cgit v1.2.1