Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xEBR6-00000000y68-24bu for pgsql-bugs@arkaria.postgresql.org; Tue, 06 Oct 2026 20:06:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xEBR5-00000001eBn-2Isq for pgsql-bugs@arkaria.postgresql.org; Tue, 06 Oct 2026 20:06:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xEBR5-00000001eBf-0hEu for pgsql-bugs@lists.postgresql.org; Tue, 06 Oct 2026 20:06:51 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xEBR3-00000000hh0-0dhJ for pgsql-bugs@lists.postgresql.org; Tue, 06 Oct 2026 20:06:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 696K6lQU1503343; Tue, 6 Oct 2026 16:06:47 -0400 From: Tom Lane To: kehan5800@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19747: pg_dump does not pin array_nulls, so restore mangles NULL array elements In-reply-to: <1201948.1791236086@sss.pgh.pa.us> References: <19747-69b01e7fc190cd58@postgresql.org> <1201948.1791236086@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 05 Oct 2026 17:34:46 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1503197.1791317074.0@sss.pgh.pa.us> Date: Tue, 06 Oct 2026 16:06:47 -0400 Message-ID: <1503342.1791317207@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1503197.1791317074.1@sss.pgh.pa.us> I wrote: > PG Bug reporting form writes: >> pg_dump writes a null array element as the unquoted word NULL. Whether the >> array input function reads that as a null depends on array_nulls, which is >> PGC_USERSET and can be persisted with ALTER DATABASE/ROLE ... SET. The >> dump's preamble (_doSetFixedOutputState(), src/bin/pg_dump/ >> pg_backup_archiver.c:3431) pins the other input-side settings >> (client_encoding, standard_conforming_strings, check_function_bodies, >> xmloption, row_security, ...) but not array_nulls, so the restoring session >> inherits the target database's value. > Meh. TBH, that GUC was past its shelf life ten years ago. What > I'd rather do about this report is just summarily remove the GUC. > If we make pg_dump issue a SET for it then we'll never be able > to remove it. Concretely, about like this. (BTW, another argument for doing this rather than fixing pg_dump is that there are a ton of other applications that will likely misbehave if array_nulls is turned on underneath them.) regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="v1-0001-Remove-array_nulls-GUC-parameter.patch"; charset="us-ascii" Content-ID: <1503197.1791317074.2@sss.pgh.pa.us> Content-Description: v1-0001-Remove-array_nulls-GUC-parameter.patch Content-Transfer-Encoding: quoted-printable =46rom 7e560c03b0304aa85c7411396ed634dc62e2a495 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 6 Oct 2026 16:01:33 -0400 Subject: [PATCH v1] Remove "array_nulls" GUC parameter. This backwards-compatibility hack was introduced twenty years ago (in 8.2), and has surely been of no value for at least the last ten years. However, we shouldn't just leave it sit, because as was just pointed out it creates a dump/reload hazard: if it's set in the receiving environment then array contents will not be restored correctly. Our precedent for retiring some other comparable parameters, such as standard_conforming_strings, has been to leave the parameter in existence but force it to a fixed value. I judge however that that's not worth the trouble here, because there's no reason to believe that a non-negligible number of applications are either setting or reading this value. Let's just delete it in the master branch and be done with it. Bug: #19747 Reported-by: Ke Author: Tom Lane Discussion: https://postgr.es/m/19747-69b01e7fc190cd58@postgresql.org --- doc/src/sgml/array.sgml | 5 +--- doc/src/sgml/config.sgml | 26 ------------------- src/backend/utils/adt/arrayfuncs.c | 7 +---- src/backend/utils/misc/guc_parameters.dat | 7 ----- src/backend/utils/misc/postgresql.conf.sample | 1 - src/include/utils/array.h | 5 ---- 6 files changed, 2 insertions(+), 49 deletions(-) diff --git a/doc/src/sgml/array.sgml b/doc/src/sgml/array.sgml index ce338c770c9..5b8ef5cabe6 100644 --- a/doc/src/sgml/array.sgml +++ b/doc/src/sgml/array.sgml @@ -756,10 +756,7 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2 If the value written for an element is NULL (in any= case variant), the element is taken to be NULL. The presence of any quotes or backslashes disables this and allows the literal string value - NULL to be entered. Also, for backward compatibility w= ith - pre-8.2 versions of PostgreSQL, the configuration parameter can be turned - off to suppress recognition of NULL as a NULL. + NULL to be entered. = diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index f36fbb60101..e537b3b0043 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11941,32 +11941,6 @@ dynamic_library_path =3D '/usr/local/lib/postgres= ql:$libdir' = = - - array_nulls (boolean) - - array_nulls configuration parameter - - - - - This controls whether the array input parser recognizes - unquoted NULL as specifying a null array eleme= nt. - By default, this is on, allowing array values = containing - null values to be entered. However, PostgreSQL versions - before 8.2 did not support null values in arrays, and therefore w= ould - treat NULL as specifying a normal array elemen= t with - the string value NULL. For backward compatibility= with - applications that require the old behavior, this variable can be - turned off. - - - - Note that it is possible to create array values containing null v= alues - even when this variable is off. - - - - backslash_quote (enum) stringsbackslash quotes diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/ar= rayfuncs.c index ef66182b047..f1f6336e5c8 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -38,11 +38,6 @@ #include "utils/typcache.h" = = -/* - * GUC parameter - */ -bool Array_nulls =3D true; - /* * Local definitions */ @@ -925,7 +920,7 @@ unquoted_element: elembuf->len =3D dstlen; *srcptr =3D p; /* Check if it's unquoted "NULL" */ - if (Array_nulls && !has_escapes && + if (!has_escapes && pg_strcasecmp(elembuf->data, "NULL") =3D=3D 0) return ATOK_ELEM_NULL; else diff --git a/src/backend/utils/misc/guc_parameters.dat b/src/backend/utils= /misc/guc_parameters.dat index c57441f7d98..380679a76c0 100644 --- a/src/backend/utils/misc/guc_parameters.dat +++ b/src/backend/utils/misc/guc_parameters.dat @@ -105,13 +105,6 @@ max =3D> 'INT_MAX / 2', }, = -{ name =3D> 'array_nulls', type =3D> 'bool', context =3D> 'PGC_USERSET', = group =3D> 'COMPAT_OPTIONS_PREVIOUS', - short_desc =3D> 'Enables input of NULL elements in arrays.', - long_desc =3D> 'When turned on, unquoted NULL in an array input value m= eans a null value; otherwise it is taken literally.', - variable =3D> 'Array_nulls', - boot_val =3D> 'true', -}, - { name =3D> 'authentication_timeout', type =3D> 'int', context =3D> 'PGC_= SIGHUP', group =3D> 'CONN_AUTH_AUTH', short_desc =3D> 'Sets the maximum allowed time to complete client authe= ntication.', flags =3D> 'GUC_UNIT_S', diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/u= tils/misc/postgresql.conf.sample index e759f06b50f..01f98de8a9f 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -892,7 +892,6 @@ = # - Previous PostgreSQL Versions - = -#array_nulls =3D on #backslash_quote =3D safe_encoding # on, off, or safe_encoding #lo_compat_privileges =3D off #quote_all_identifiers =3D off diff --git a/src/include/utils/array.h b/src/include/utils/array.h index 88e4f4d70d8..e7ee184034e 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -343,11 +343,6 @@ typedef struct ArrayIteratorData *ArrayIterator; (a)->xpn.lbound : ARR_LBOUND((ArrayType *) (a))) = = -/* - * GUC parameter - */ -extern PGDLLIMPORT bool Array_nulls; - /* * prototypes for functions defined in arrayfuncs.c */ -- = 2.52.0 ------- =_aaaaaaaaaa0--