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.96) (envelope-from ) id 1vww6o-005AKq-1O for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Mar 2026 05:46:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vww5o-00FYPT-0n for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Mar 2026 05:45:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vww5n-00FYPK-3B for pgsql-bugs@lists.postgresql.org; Mon, 02 Mar 2026 05:45:19 +0000 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vww5k-00000001yfE-0G8B for pgsql-bugs@lists.postgresql.org; Mon, 02 Mar 2026 05:45:18 +0000 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-7d4c307db9aso2535307a34.3 for ; Sun, 01 Mar 2026 21:45:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772430314; cv=none; d=google.com; s=arc-20240605; b=K5FhDxV/2i8HUtRYYAYNAG8SJMmn/uk/uC/k0SjTUuodDLiPeM4Kv+o9wuupYYhiSN MTurP2N5h773tFzHQbdcP73+iy7RhsreQTS+Ixf2TmitCFSnXJ3We29xPEomFKyz6G0P 98KhGULaQ0dbJd703U9uQ0u9H3dzb1zd3YjwTKoH/8Jbv9nJhWZU1KMhhO6kdEP/tBBv S3t4JrZocjhIcYh0Jhi1QHRwWNozQHCeIsU+3cijDue4w3nSQ+EUku0L5zp3JpVn6A7c 2wW/7Ks2oaYn4PZMVgMSvWT4iFU3Yc4AlqVDp9SgqoqG8BnTllfW9L8Qc/k3dxhI+3bH 7gnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=bcR3Bh9WS+DBxpEmYNq3HKoGvP+jJX0cxS8xvgIVP7k=; fh=XvHAm888ltOuyUTrBZ5SPWvBS1aVyFP3BtZ5lHcAr/c=; b=HQJTzclHJEgoA9d2mlpa6wZFNVsB39li/mmXMlbAFTlpFIQ6ddYCRuapeEy+r/ytsK 4b7ZGRgTMGz9R9qFyNGPPQU0S+BP7m1LbLgWqJV3VF6tNOQRkRaCBjkjDgskVnHLZMtf z66Ya8e9fCd43OU6NYHNazvTGCTC+RnGbg+GcAnKG3pod9pvmdVyFWciu3R+edUHPf+d 7ZcmnQ0x5VTsOrpN/HJp95U7EOC4uXP51FFGMo2tjxUwsFPBXUyE1+d0bm8E10XGinvI smEMO2SgwcSg9DcDUtm0k3mls6FjQz3w8l/xoPdRsIYKI9u4RKLYbTcYZfOlwaSMuxQN gwew==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772430314; x=1773035114; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bcR3Bh9WS+DBxpEmYNq3HKoGvP+jJX0cxS8xvgIVP7k=; b=Zs9hLB4ABUKSLyjX4x6NOlNF2ptLOV0nPBLfDUNAnYcCPZDRagxLs4yqD4UOosidBl QGeqejQII6jTf3QfUrezmF2afNGtb1Zi1yHqt3mRCb7jmzZtXHaXPqb1CTBKLrtDKwTP Q+477XKRLE3yPg/EVqzbRYL6IPnL6WRPL6atFqVkqgX1SOLIbgfKLP1I6CQI5ws/f7th 4y9x6d48kqdCNeUGrkmQAkd4KDYb5vYFqYOhEsXn44G+jE6ESjXMMr5bUS0tObgRVghC CFjgLXyfzLmijpa21VcpgQGLWyIu9ltFiOzNpUfqEJxZsl6FpfvIbH5QGGjPwTQoAc7H 6QeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772430314; x=1773035114; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bcR3Bh9WS+DBxpEmYNq3HKoGvP+jJX0cxS8xvgIVP7k=; b=v03Dlp8CJ6/ktcCCpARQw18OOEQKwyW4RrXvgs2PAS45LFN4pM+O5CEVg1cSfdOmbd Wd2QEWDxpxAW8MRXk+1ux6CbyRW1TYNo+F+NE/I/LYGEDe+WEcYmZcClreRHb4JnaGNv U2X+Tndt8SCj6BXYbaYhhhF51f/7wcSF5VJnmGck1g0DloGc7z4BJ6rW6sY6covGLKqq JkQlISmgcJkxbyEHv9oPHFbjEb4FdIsDzdoB8qIutwS0sCYSeuFLFieln2/NpeikemrY +ozU0+fGWlXbnU6E2zKhx4cqbtd9nR8jLhtmc1L5orV4eAZbEtGpjL7YaGQcNoLwu80y 4SCw== X-Forwarded-Encrypted: i=1; AJvYcCXkf+95nJ0cWyqWDOwNiYWHqkA3/cP/mYKo5hzR817VyrLv3G9uUZ2LKeK/3ryeOhQMn9hi/DrVNLVx@lists.postgresql.org X-Gm-Message-State: AOJu0Yz7Wl3dXHIYb3rZdAdLcNvAcxBHZQ8eI0ak+Bm9JJ9r9+6UUacg 5IuT1NMZm7vSG5lc/ZGfN/GP1PrliUH1VFhACTYS3bjXyEcAWOFjnPard+CV087bhTmmeltiIhr c25OTAh6kVPxVdZ1vqwKp6Vu8NjhLLbQ= X-Gm-Gg: ATEYQzyOiI0m9ZjfmaSLNfv6Ly7opmpamwbKLtL8BhzL5xdYviHTyoJIvYHAuBgBrIV //Q3+vKIG9kKXPF3tBcaWEuGRUVhouhAaqy+n+iVZ4Lc9bZZ+5HHy2M8NMBmZDejUW+nyj+W6Nq Wv7pYyuCqJuNShyR1M6dVo1J8IVyEIvDobziCS41RPPRlMKOjwkXs0ibJ+IRUV2hvt8huxpk5lg 9ATOAIaxDpkCSNsAO/3JOQqToNQYV2qF5NW+E3lYIXXsZgSNevfSmqy9aNMZ9BQtTI2c/aMeMn5 4aXz5zWAcw== X-Received: by 2002:a05:6871:3319:b0:409:43ef:2491 with SMTP id 586e51a60fabf-41627039b32mr6687625fac.27.1772430314543; Sun, 01 Mar 2026 21:45:14 -0800 (PST) MIME-Version: 1.0 References: <19418-591ba1f29862ef5b@postgresql.org> <2abdb464-27f5-4759-bb0b-f09ab5b5ceab@postgresfriends.org> In-Reply-To: From: Richard Guo Date: Mon, 2 Mar 2026 14:45:03 +0900 X-Gm-Features: AaiRm50Eyoyrn6DmnXAkK9LLKCzRhr6rdE5WJs_RovLQttXkb90APVSzOZSTvsE Message-ID: Subject: Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34 To: Vik Fearing Cc: lukas.eder@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form , =?UTF-8?Q?=C3=81lvaro_Herrera?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 2, 2026 at 2:09=E2=80=AFPM Richard Guo = wrote: > On Fri, Feb 27, 2026 at 11:44=E2=80=AFPM Richard Guo wrote: > > I wonder if we can fix it by wrapping the JSON_ARRAYAGG in a COALESCE > > to catch the NULL and convert it to an empty array; ie: > > > > SELECT COALESCE( > > JSON_ARRAYAGG(a [FORMAT] [RETURNING] [ON NULL]), > > '[]'::[RETURNING_TYPE] > > ) FROM (query) q(a) > The attached patch seems to fix it. (cc-ing =C3=81lvaro who committed 7081ac46a) Regarding back-patching, I believe this fix is safe to back-patch to stable branches. However, similar to a nearby bug fix, this will only apply to newly created views. Existing views will continue to exhibit the old behavior until recreated. Additionally, this changes the user-facing output from NULL to [], so users may need to update any application code that relied on the NULL behavior. - Richard