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 1goISQ-0003xp-Ck for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jan 2019 01:44:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1goISP-0000v8-70 for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jan 2019 01:44:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goISO-0000uq-TC for pgsql-hackers@lists.postgresql.org; Tue, 29 Jan 2019 01:44:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goISM-0003vU-CS for pgsql-hackers@postgresql.org; Tue, 29 Jan 2019 01:44:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x0T1ieeK001677; Mon, 28 Jan 2019 20:44:40 -0500 From: Tom Lane To: Alexander Korotkov cc: Andres Freund , Nikita Glukhov , Tomas Vondra , Oleg Bartunov , Michael Paquier , Stas Kelvich , PostgreSQL-development , Thomas Munro , David Steele , Andrew Dunstan , Robert Haas , Pavel Stehule Subject: Re: jsonpath In-reply-to: References: <264a6413-7175-9680-b976-d50392c001c0@postgrespro.ru> <9f5f1247-29f4-17cd-edd9-38e9bcd95b14@postgrespro.ru> <20190129010332.i4t64evqc3bwtjzx@alap3.anarazel.de> Comments: In-reply-to Alexander Korotkov message dated "Tue, 29 Jan 2019 04:17:33 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1675.1548726280.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 28 Jan 2019 20:44:40 -0500 Message-ID: <1676.1548726280@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alexander Korotkov writes: > On Tue, Jan 29, 2019 at 4:03 AM Andres Freund wrote= : >> FWIW, I still think this is a terrible idea and shouldn't be merged thi= s >> way. The likelihood of introducing subtle bugs seems way too high - eve= n >> if it's possibly not buggy today, who says that it's not going to be in >> the future? > I'm probably not yet understanding all the risks this code have. So far= I see: > 1) One of functions called here performs database modification, while > it wasn't suppose to. So, it becomes not safe to skip subtransaction. > 2) ERRCODE_DATA_EXCEPTION was thrown for unexpected reason. So, it > might appear that ERRCODE_DATA_EXCEPTION is not safe to ignore. > Could you complete this list? Sure: every errcode we have is unsafe to treat this way. The backend coding rule from day one has been that a thrown error requires (sub)transaction cleanup to be done to make sure that things are back in a good state. You can *not* just decide that it's okay to ignore that, especially not when invoking code outside the immediate area of what you're doing. As a counterexample, for any specific errcode you might claim is safe, a plpgsql function might do something that requires cleanup (which is not equal to "does data modification") and then throw that errcode. You might argue that this code will only ever be used to call certain functions in numeric.c and you've vetted every line of code that those functions can reach ... but even to say that is to expose how fragile the argument is. Every time anybody touched numeric.c, or any code reachable from there, we'd have to wonder whether we just introduced a failure hazard for jsonpath. That's not maintainable. It's even less maintainable if anybody decides they'd like to insert extension hooks into any of that code. I rather imagine that this could be broken today by an ErrorContextCallback function, for example. (That is, even today, "vetting every line" has to include vetting every errcontext subroutine in the system, along with everything it can call. Plus equivalent code in external PLs and so on.) We've rejected code like this every time it was submitted to date, and I don't see a reason to change that policy for jsonpath. regards, tom lane