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 1xSuNa-00000002EQ0-2f2b for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Nov 2026 10:56:06 +0000 Received: from localhost ([127.0.0.1]:38680 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xSuNZ-00000000NWY-2SPX for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Nov 2026 10:56:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:52360) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xSVt9-0000000FHmh-0g1z for pgsql-hackers@lists.postgresql.org; Sun, 15 Nov 2026 08:47:03 +0000 Received: from mail-yw1-x112c.google.com ([2607:f8b0:4864:20::112c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xSVt6-000000011yb-2ew7 for pgsql-hackers@lists.postgresql.org; Sun, 15 Nov 2026 08:47:01 +0000 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-8b4d6981c67so167757b3.1 for ; Sun, 15 Nov 2026 00:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794732419; x=1795337219; darn=lists.postgresql.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FIHDxgvzzIxuhKlvFYQc0D0Rtky2ubUVdOVODy93zBs=; b=g4NpQuF4kjJtfL0awm/QiC2o9RWWamZQ0McFRr98vTsULtU2HpsascT6s4v1AK4ywN wGa1NYLUjTYvFMFuKptnrWmVB/Vs0djURzwghgkFqBQ3drhpu1NaIuNfw/yvf3K0KTQF 8aZWmfUBtXvoxjOO7fffTmx5zmR7Oe70YL/02H82hhPc7hXYuWq/KreweVAvNX7ASS2c 6zBi4L2YY9AaFGz2MRm2yEHDDO0VbTPLo+xCdlN3YJ9p/dkD+7Pw2JBhCnTjhs4WJ+ZH JmeQh2FgUhQt+bVkmqaRT1HRU55jxoALqzyjjqfvSePRvHLTSCEYywG3cC82Rg6bArpX ayCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794732419; x=1795337219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=FIHDxgvzzIxuhKlvFYQc0D0Rtky2ubUVdOVODy93zBs=; b=oF1u/yJ0Jlu6s/SogjMQcLEdz3Zqp9kWhEPtATaF2QOYroEZB/lZ+Z4c0gULKEKl0V vKdJ2JMpvao375b6EEZ5Ks8HPUZWqdb4gXk8QyAYDzvgrPwvKoTq5VLWLLg56ZwpZfsp klK2gURwbWZmQE7yUMQCmENmKHKhA8SzssVg6w1p/ofzuS0mepSVIhtMU7PsC4g/V5xL JiMgHUa3vkQUWv1Cr1+LsYfGFVoO8iovzrxhKFd7VSzw1njksZRsnXTAdn34R4ijXOaX jZ8O+I+VFSiGzjJ88S3FtiABw97Wu2zmiayc1edbuxAWjkc6DhmmkUQ/hd5S4ZmSkHEY M/9g== X-Forwarded-Encrypted: i=1; AL+hErFom4K77mXqwR3b0lctMbHwuPLWIpgbq3mNcSvXUehNSUpKyDmhvlAdzwi1sqbC6qB6gfutYkaltnzYcu6B@lists.postgresql.org X-Gm-Message-State: APuU4Z/OPMZJ5VTHQQrgGAFCAEOO1jPpSUHDZDWPVw2kj3ItAlziVvyi hUpi+iaQtGWYSTKYjL+YqFpxfzBzSamhJM0nu9GjWCP1nHxAvY4CTakO X-Gm-Gg: AYBFou0cJC4U61Qj64nakDxhOzC5SeW0o/TSX7osDwPZmvNC2VWlQfW0T60kTuDzyoW yjOFE8TlwTKjLDrPB3Vnv4VX85xiLy4tCguS9ULeLg3blA+uxmnrQSYvff9BkoKWzPesW/Dh8+V R99Y2FvIly7BZwui/N25XUvcHiOQ8ZOEga6lLnjUfTVFj3a0ZNOo30UyNMKWtQ7ikLLGvcU/QEy OhtlyRJazBXVNW1cCyUiYjox1d7lSnUr6e++sZKY+Csa7DRwq0XhtO5tTACFIfpU4IKJ/7urOSc QXIFaz7OYk3kTjXl9WGE/ldjT8iPtCpXRBvD1J+u58Wu/o3KuZPhqosbLiOFMne7Yq9p/sqTJ/5 XE9yKY7NDOGDXyMPjksyu5YYeStXTK/thBiBmbgQxHvkHMjCcs7ya2VaVmkObEuCLeWmM+98drd eaFB0kLtA5v0rWo6QfQY5/FLx5MrTWH69JdH0yHs/UOeq7zLGJDknxr9yCSS+MRFKTHwDmXYMtt /obkIXSSNaWtWiHZb7HzuZpsi5+0Z7pT1yaG/LgqmmJd72sPwhqDGXw50p8mb6144RhZK/8BUg8 EK6e6ApJirWl9OXamGBJ5ReH04fmfSnOteEfnMyNbDLylfNuFDe4omFW74vOPnVDtwHpu3coxGm FVDL3krd+C4SEt4omtzDpyJRjh6LEqjV2eijIkaD444yMxF17XLUjp7OhnBeL X-Received: by 2002:a05:690c:3181:b0:8a8:7e5a:dc2f with SMTP id 00721157ae682-8b4aa232e8dmr43122707b3.12.1794732419416; Sun, 15 Nov 2026 00:46:59 -0800 (PST) Received: from NOTEBOOK-LAILA ([2804:14d:5c27:1387:a053:f15d:8c82:ed64]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b4aa987da8sm61539957b3.25.2026.11.15.00.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 00:46:58 -0800 (PST) From: Joao Rito To: Yeongjae Min Cc: Dmitry Dolgov <9erthalion6@gmail.com>, pgsql-hackers@lists.postgresql.org, pgsql-bugs@lists.postgresql.org, theshallow27@gmail.com Subject: Re: BUG #19736: `JSON_OBJECT ... ABSENT ON NULL` accepts invalid keys when the value is NULL Date: Sun, 15 Nov 2026 05:46:50 -0300 Message-ID: <20261115084650.45010-1-joaovictor.rito@gmail.com> X-Mailer: git-send-email 2.53.0.windows.1 In-Reply-To: References: <19736-3a44617ea5534c77@postgresql.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Yeongjae, Thanks for the patch. I tested v3 on current master (81b2179b492, built with cassert and tap tests) and it applies cleanly. On master, with a NULL key and a NULL value, JSON_OBJECT ... ABSENT ON NULL RETURNING json returns {} instead of an error. The same happens for an array key, a ROW key, and json and jsonb keys, with RETURNING json and jsonb, and for a domain over int[] with RETURNING json. A jsonb NULL key with a NULL value already fails on master ("argument 1: key must not be null"), so the NULL key problem is only in the json path. Two aggregate cases, json_object_agg_strict(ARRAY[1], NULL::text) and jsonb_object_agg_strict('{"a":1}'::jsonb, NULL::text), also returned an empty object on master. Dmitry already raised the aggregate case. I only confirm it on current master. With the patch all of these raise an error: "null value not allowed for object key" for the json path and "key value must be scalar, not array, composite, or json" for non-scalar keys. A composite key with a cast to json and a NULL value is now rejected, as it already was with a non-NULL value. A valid key with a NULL value is still omitted (tested with text, int, numeric, bool, timestamptz, name, bytea, int4range and enum keys). A NULL key with a non-NULL value still fails as on master. With WITH UNIQUE KEYS, duplicate keys with omitted values and a NULL key with a NULL value (json) give the same result as master. json_build_object, jsonb_build_object and json_object(text[]) also give the same output as master. The regress suite passes (243 subtests) and the server log has no TRAP or assertion lines. What I did not test: check-world, the isolation and tap suites, pgindent, the docs change and its build, the back branches, other platforms (I ran one Linux build), planning or performance effects, and a detailed read of the C code. I found no problem with the patch from what I could test. Regards, Joao Rito