array_cat_nulls.patch

application/octet-stream

Filename: array_cat_nulls.patch
Type: application/octet-stream
Part: 0
Message: NULLs in array_cat vs array || array

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/utils/adt/array_userfuncs.c 6 13
diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c
index 499d357..67394e5 100644
--- a/src/backend/utils/adt/array_userfuncs.c
+++ b/src/backend/utils/adt/array_userfuncs.c
@@ -197,19 +197,12 @@ array_cat(PG_FUNCTION_ARGS)
 	Oid			element_type2;
 	int32		dataoffset;
 
-	/* Concatenating a null array is a no-op, just return the other input */
-	if (PG_ARGISNULL(0))
-	{
-		if (PG_ARGISNULL(1))
-			PG_RETURN_NULL();
-		result = PG_GETARG_ARRAYTYPE_P(1);
-		PG_RETURN_ARRAYTYPE_P(result);
-	}
-	if (PG_ARGISNULL(1))
-	{
-		result = PG_GETARG_ARRAYTYPE_P(0);
-		PG_RETURN_ARRAYTYPE_P(result);
-	}
+	/*
+	 * Concatenating a null array results in a null array as per
+	 * || operator concatenation
+	*/
+	if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
+		PG_RETURN_NULL();
 
 	v1 = PG_GETARG_ARRAYTYPE_P(0);
 	v2 = PG_GETARG_ARRAYTYPE_P(1);