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 1eor5n-0004My-DT for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Feb 2018 13:39:23 +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 1eor5m-0003p8-5N for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Feb 2018 13:39:22 +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 1eor4z-0003nM-B8 for pgsql-bugs@lists.postgresql.org; Thu, 22 Feb 2018 13:38:33 +0000 Received: from data.blset.com ([62.210.103.53]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eor4w-00011h-3Z for pgsql-bugs@postgresql.org; Thu, 22 Feb 2018 13:38:32 +0000 Received: by data.blset.com (Postfix, from userid 122) id 76F74E0AA3; Thu, 22 Feb 2018 14:38:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=blset.com; s=mail; t=1519306708; bh=1v+qIUN+i/USNdeIB9MWxocxDw8F+hY+0JzMv5Hn1ho=; h=From:Subject:Date:To:From; b=Ey6s9jsg1b3d0UxG38JRHVqh7BBxOfgUMNr2/LL+idBwo7c6uhO0PFCJrFYElAqoo XsgRJnphJPVn9MlHohnrdSXjotIs3fXvyysiO/fy91yH9rdHXQEhkaxbOPcAYKlNqe MEm0SWBl5pFpA6nHKZYbYFg+RttR13K861Ozpl5Q= X-Spam-Report: * -100 USER_IN_WHITELIST From: address is in the user's white-list * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 HTML_MESSAGE BODY: HTML included in message * 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. * See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block * for more information. * [URIs: blset.com] * 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid X-Spam-Status: No, score=-101.0 required=5.0 tests=ALL_TRUSTED,HTML_MESSAGE, T_DKIM_INVALID,URIBL_BLOCKED,USER_IN_WHITELIST autolearn=ham autolearn_force=no version=3.4.0 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on data.blset.com Received: from [192.168.1.121] (LPuteaux-658-1-176-11.w92-154.abo.wanadoo.fr [92.154.111.11]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: pbarbedor@blset.com) by data.blset.com (Postfix) with ESMTPSA id 71064E01D3 for ; Thu, 22 Feb 2018 14:38:25 +0100 (CET) Authentication-Results: "data.blset.com"; dmarc=fail header.from=blset.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=blset.com; s=mail; t=1519306705; bh=1v+qIUN+i/USNdeIB9MWxocxDw8F+hY+0JzMv5Hn1ho=; h=From:Subject:Date:To:From; b=FteDU3AiX9zRL+tYvj4/YdHS5w553HxHVcmiUw0JVBJoxSbmPJhcCBYKtaBMtJlNT nMrL58bZibvtYSCJd90sglXq10LfkxkaLdomnZSttuVzzBQm0U7ugW7hq6/uSWc1kW l8rGfn5xg3XcNiwTjQM96POxeOhzTamvyqpujqUw= From: Pascal Barbedor Content-Type: multipart/alternative; boundary="Apple-Mail=_107503CC-8DBA-4BB7-AF3A-E2557A08FAA3" Subject: bug in jsonb_set porstgresql 5.5 Message-Id: Date: Thu, 22 Feb 2018 14:38:25 +0100 To: pgsql-bugs@postgresql.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_107503CC-8DBA-4BB7-AF3A-E2557A08FAA3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hello I noticed a problem with a jsonb field and jsonb_set function - table1 is a table with history a jsonb field, and obs a text field = which is null Those three instructions were sent to postgresql 1- this one is ok, set the field to an empty object update table1 set history=3D=E2=80=98{}=E2=80=99 2- this one is ok, creates a key q1 initialized at an empty object update table1 set history=3Djsonb_set(history,=E2=80=99{q1}=E2=80=99, = =E2=80=98{}=E2=80=99) 3- this one resets completely the jsonb field, not only the key obs is = not set to null but the entire jsonb field is now null update table1 set history=3Djsonb_set(history,=E2=80=99{q1,obs}=E2=80=99, = to_jsonb(obs)) this is on postgresql 5.5 Best regards Pascal BARBEDOR tel 01 45 34 55 25 mob 06 82 32 69 63 http://www.blset.com tel 01 46 23 86 74 fax 09 72 42 01 93 --Apple-Mail=_107503CC-8DBA-4BB7-AF3A-E2557A08FAA3 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hello


I noticed a problem with a jsonb field and = jsonb_set function


- table1 is a table with history a jsonb field, and obs a text = field which is null


Those three instructions = were sent to postgresql

1- this one is ok, set the field to an empty = object
update table1 set history=3D=E2=80=98{}=E2=80=99


2- this one is ok, creates a key q1 = initialized at an empty object
update table1 set = history=3Djsonb_set(history,=E2=80=99{q1}=E2=80=99, = =E2=80=98{}=E2=80=99)



3- this one resets completely the jsonb field, = not only the key obs is not set to null but the entire jsonb field is = now null

update table1 = set history=3Djsonb_set(history,=E2=80=99{q1,obs}=E2=80=99, = to_jsonb(obs))



this is on postgresql 5.5

Best regards





Pascal = BARBEDOR

tel 01 45 34 55 = 25
mob 06 82 32 69 63


tel  01 46 23 = 86 74
fax   09 = 72 42 01 93






= --Apple-Mail=_107503CC-8DBA-4BB7-AF3A-E2557A08FAA3--