Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1enham-0000z6-7m for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Feb 2018 09:18:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1enhal-0000Kw-3p for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Feb 2018 09:18:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1enhak-0000Kn-CZ for pgsql-bugs@lists.postgresql.org; Mon, 19 Feb 2018 09:18:34 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1enhah-0001Z3-JG for pgsql-bugs@lists.postgresql.org; Mon, 19 Feb 2018 09:18:33 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 0F008165; Mon, 19 Feb 2018 04:18:29 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Mon, 19 Feb 2018 04:18:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=p6sJOmSzkMVSme196Tha8iqKw1TCNiOzErVuMO9cW7o=; b=OVz/deeF vtL9YrfIeZlCu59g5JzAwEaUnlFVT7BrMJ7C3xdX+02CZMNl0gMsvvzXOBVu9zwA S5yfILfwBuS9I3DPJcSlPy9gA8lYmgKz5/QWtwOXWbbD42o7eGRGudFlXrVV9en+ MgTpl0Q2IsVR6AlMrkqqMCe0QIjVisv9EVe+7x/db8X8G+9Q1m6o8uvCh9UTe3KQ ZC8lHHYr0eCiipfjOVjEOc0rPbwqYpnxgtujodnYDfXFf6DQLGOipKKzdMS6FYx+ zCt5l+t7eZcyPvxRLdXPiJi9c15cnF1FlqiRwrAAUp2NFwoVdvP7/zo+kUm445QF JYfr/Aa4gGB6PQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=p6sJOmSzkMVSme196Tha8iqKw1TCN iOzErVuMO9cW7o=; b=UOC/wcIKpzs3bKFDaA3qC44/HtJoi0a3Ck/+Wp+/V5w75 YLu6dvCut85hyffnvR6UH2+Mi8KQMTnn5ENIYB0VfPNTSjyvOFzwvuGEBnPnE3/c fKsyXB9X1LRsRPMLHreAZkq8/Ge4/QceywtuUQkQvDp/akbxEJmPf3DNiLizbJmp vLYVRXAfU9k2FO/R2nl1UZIP7vujYGAo6JWT2OWPGD45bm7uicLK4Hpmk+jhRNS4 hoJNXoGiDQ3J+L6gV6n8z9zPh1rnPd3UL3ys/aZ0P2xvrT1f5/V8nfZCrHTMcZHO X7THG0eKE+1dOCQFiKCZyUeHmMcw8YgDisXy2F9/w== X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 97209240B6; Mon, 19 Feb 2018 04:18:27 -0500 (EST) Date: Mon, 19 Feb 2018 18:18:23 +0900 From: Michael Paquier To: claudel.sylvain@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15075: jsonb_set return [null] if new value is null but not 'null'. Message-ID: <20180219091823.GA42340@paquier.xyz> References: <151902922995.1388.15352428607143555614@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HcAYCG3uE/tztfnV" Content-Disposition: inline In-Reply-To: <151902922995.1388.15352428607143555614@wrigleys.postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 19, 2018 at 08:33:49AM +0000, PG Bug reporting form wrote: > Is this behavior normal ? >=20 > select jsonb_set('{"f1":1,"f2":null,"f3":"bidule"}', '{f3}', null, false); > #> [null] > select jsonb_set('{"f1":1,"f2":null,"f3":"bidule"}', '{f3}', 'null', > false); > #> {"f1":1,"f2":null,"f3":null} >=20 > In a update query, it is dangerous. > It may be better that the request crashes rather than executing with > surprising behavior. jsonb_set is a strict function, meaning that any NULL value from input arguments will make the function return NULL as result, which is what your first example does. In the second query, you are using null as JSON value, which is actually valid as input. So as far as I can see, this is normal. > Sorry if this report is not "clean". No problem. I have been able to decrypt it easily :) -- Michael --HcAYCG3uE/tztfnV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlqKll8ACgkQnvQgOdby QH1V5xAAqEftPX3k1ptUI0oYKhuqOUT1xrNlwRXzcALaGfu81j/mqi6fBbBWYWRw GYhBhG5OePXEr2e4K/9I4VWBbSj4BfWMZnRbv2sLU9WY44zCL1P4sa61SAMrECNU kIMGNVJstzN9IWcBUzBBPX9JEwE7xVFVrDTPbP1aAPIfQqrTTJZDW6rKkw4PXrvy +TlKTcLvVHIJbQvjtoubiT7FEDRKgVoDc+Y72ctcaBk1U3GbSB9mf+BfGxMZACGi gAsuN/XGCl7vIpOnbcGj0HM5FWXB6KgSQaplm9L3AxgncuXhGrntdBB3kCQfBHRa vWBX5l6M0+A5w6e+Z56aO2H0/hFIR+nraL0RkPQ+Js1b1Yhrtxvuug3G/6TFrL4H NXQ+v+ioUL+Nu3pHHUJ9LeKnkW2VILTltrxEhCmAkfzHGM1EUGSqCwD54uirC3ox H4H8y0gQ6RnnJYg6HgJRx+3NAyLOffQXixn5lNUN3MXplQIrfhTCLapcvoPynrAT H5rxz2I9Iffh3QoUexBj7Opw0JcHXQlluSQYx314QNZxc7ykkThjfwSwN7IsdjFa SSG27JiSTAE22M/c6RMIjG1fvEW/gZm+BbtVxWZtqmQioO581GWAAPnRYlxsdgc1 RnqHN0tmXFw+O1RE53HjJ8wJkDgvUXCTwGUq8Y4ZDCByahySUvM= =TpE8 -----END PGP SIGNATURE----- --HcAYCG3uE/tztfnV--