Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iVhmd-00009N-Li for pgsql-general@arkaria.postgresql.org; Fri, 15 Nov 2019 20:01:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iVhmc-0005WX-F9 for pgsql-general@arkaria.postgresql.org; Fri, 15 Nov 2019 20:01:30 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iVhmc-0005WM-1h for pgsql-general@lists.postgresql.org; Fri, 15 Nov 2019 20:01:30 +0000 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iVhmY-0005G7-QR for pgsql-general@lists.postgresql.org; Fri, 15 Nov 2019 20:01:29 +0000 Received: by mail-ot1-x343.google.com with SMTP id l14so9021354oti.10 for ; Fri, 15 Nov 2019 12:01:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:cc:references:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=MwFnVHTY+WRgCDJJjS+AjpbAlmpYM1g6aCNINVoDqPw=; b=HEJRFEuaLaWq7VvGJXmXOAUnqBPniEGHoORHVFVJw9GBb+39omJnsz+sjQtIZ/Pc7b c4lXRt/F8fxEKroVmvGHoqH2SPFoLEbPF7fZ3RNrnBFX1J1nqX/JWwAXHstDELtpAd3G HpHzWIrw9sAzj5Uot6buTaS0gwSxQ6h847+eEKjasCNubP/Uk5DyPEiWZjJU6GHPttNX AkM4hoSCuzO9Xu6ZNxsYl1Et9+7HASge4di7/gs1q7SXQSYkGDY7X+dj2FekX2DTXB0O eT7t7tV/3UjtWXDLXBjuxtbAvTKn9JJJLZeorFPuncMbmdMqIP3I+eAAxkfRQ3eoutj/ X3fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=MwFnVHTY+WRgCDJJjS+AjpbAlmpYM1g6aCNINVoDqPw=; b=ST6xZ5bfGLJsV/3mDAzlrWkj9M3jzUymmsA9BbLQ05jIu6ZpcgwzCz/wDCkIVuSJFo ehmN3EBT8h0loAjNzZI3fhOZweFZb9kJmZtEUMh3/f74txK+oflJ/6dZAe7o7i8iX4q1 l3YUBCQkAw31TlzxSfLXcrCEErnjLUGJwVo0QiBpIES7JqkBsHCZhoE7gAA4nkbKpRPS EN4dAvsmk3YdHxX9NcAF2leSiECiyPtQDoXBokL3Q3rjEixQtMHIT0cgzpar+ThXzXaF oRNJzWTXjU65NP66eFbumR4WHeYSugIjf/Mcf3nkR0DUXLhSyt3Qj1hBm8iYOpqAhX1j Eo/w== X-Gm-Message-State: APjAAAVMsZFDNIxRqwXVBRw75Pj09+Ps03muwQvmwsAjvzFaRBqGOpC/ IiSTtj3hzBR5nzpyuzXZoMeP X-Google-Smtp-Source: APXvYqxda9qjRDVAc7cM4Vy+R3pAD5646VJwQ4DfvG19u0bNTU5paUVOOO+BbpFVvSa9QJn5BaIdEQ== X-Received: by 2002:a05:6830:1f28:: with SMTP id e8mr1067485oth.173.1573848084469; Fri, 15 Nov 2019 12:01:24 -0800 (PST) Received: from [192.168.10.146] (99-10-92-30.lightspeed.rlghnc.sbcglobal.net. [99.10.92.30]) by smtp.gmail.com with ESMTPSA id m25sm3251382otj.62.2019.11.15.12.01.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Nov 2019 12:01:23 -0800 (PST) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: jsonb_set() strictness considered harmful to data To: Pavel Stehule Cc: Tomas Vondra , "David G. Johnston" , Floris Van Nee , Ariadne Conill , Mark Felder , "pgsql-generallists.postgresql.org" , PostgreSQL Hackers References: <20191019192723.luarxhq57qkzuncw@development> <1571560798575.47024@Optiver.com> <34a7ff88-0d86-0990-4eac-48159df8d7f2@2ndQuadrant.com> <5db07acf-bc75-edf8-60af-905c0adadb68@2ndQuadrant.com> <20191020201839.olpuyuzixagcvvud@development> <5b8a26bf-6b46-71f3-a99e-3fb9a8095232@2ndQuadrant.com> <20191021060701.or6a6a7lg3asixom@development> <544ecc1e-681e-69f1-5cde-8b8aaeb45d7f@2ndQuadrant.com> <375873e2-c957-3a8d-64f9-26c43c2b16e7@2ndQuadrant.com> Openpgp: preference=signencrypt Autocrypt: addr=andrew.dunstan@2ndQuadrant.com; prefer-encrypt=mutual; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR0X9FHXT0KnGuz1F5ERO7ZTLSSQ6fJwPj6gOk9K+vvoKvoeql5ABEB AAHNL0FuZHJldyBEdW5zdGFuIDxhbmRyZXcuZHVuc3RhbkAybmRRdWFkcmFudC5jb20+wsCY BBMBAgBCAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAUJDyV6hBYhBOQ+WEYd/Hy/RGkV pZn6f8tZ/DuBBQJcH/EVAhkB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naDbXPcnFsur1Oo9mIHFakgWgOBMuxoWfjONiLjjLh/9+ZIqSSLX Message-ID: Date: Fri, 15 Nov 2019 15:01:19 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-MW List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/15/19 2:14 PM, Pavel Stehule wrote: > Hi > > > > For release 13+, I have given some more thought to what should be > done. > I think the bar for altering the behaviour of a function should be > rather higher than we have in the present case, and the longer the > function has been sanctioned by time the higher the bar should be. > However, I think there is a case to be made for providing a non-strict > jsonb_set type function. To advance th4e discussion, attached is a POC > patch that does that. This can also be done as an extension, meaning > that users of back branches could deploy it immediately. I've tested > this against release 12, but I think it could go probably all the way > back to 9.5. The new function is named jsonb_ set_lax, but I'm open to > bikeshedding. > > > I am sending a review of this patch > > 1. this patch does what was proposed and it is based on discussion. > > 2. there are not any problem with patching or compilation, all regress > tests passed. > > 4. code looks well and it is well commented. > > 5. the patch has enough regress tests > > My notes: > > a) missing documentation > > b) error message is not finalized > > +       ereport(ERROR, > +               (errcode(ERRCODE_INVALID_PARAMETER_VALUE), > +                errmsg("null jsonb value"))); > > Any other looks well, and this function can be very handy. > > Thanks for the review. I will add some docco. What would be a better error message? "null jsonb replacement not permitted"? cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services