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 1hJk3I-0001sn-Dm for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2019 19:29:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hJk3H-0006pc-5t for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2019 19:28:59 +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 1hJk3G-0006VY-My for pgsql-hackers@lists.postgresql.org; Thu, 25 Apr 2019 19:28:58 +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 1hJk3E-0002wW-2z for pgsql-hackers@lists.postgresql.org; Thu, 25 Apr 2019 19:28:57 +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 x3PJSqiu028020; Thu, 25 Apr 2019 15:28:53 -0400 From: Tom Lane To: Alexander Korotkov cc: John Naylor , PostgreSQL Hackers Subject: Re: jsonpath In-reply-to: References: <23e82578-b648-ab57-a4af-791abccff344@2ndQuadrant.com> <4971.1553779874@sss.pgh.pa.us> <5656.1553781027@sss.pgh.pa.us> <19611.1554593792@sss.pgh.pa.us> <20190409161557.xwc4xwqeaimxcb4d@development> <1ccb6aa8-0ba5-a14c-d3a3-8c0b7f73244b@2ndQuadrant.com> <14890.1555523005@sss.pgh.pa.us> <28819.1555886387@sss.pgh.pa.! us> Comments: In-reply-to Alexander Korotkov message dated "Thu, 25 Apr 2019 21:03:54 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28018.1556220532.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 25 Apr 2019 15:28:52 -0400 Message-ID: <28019.1556220532@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alexander Korotkov writes: > I'm going to commit these adjustments if no objections. Sorry for not getting to this sooner. Looking quickly at the v2 patch, it seems like you didn't entirely take to heart the idea of preferring a useful primary error message over a boilerplate primary with errdetail. In particular, in places like - errmsg(ERRMSG_SINGLETON_JSON_ITEM_REQUIRED), - errdetail("expression should return a singleton boolean"= ))); + errmsg("singleton SQL/JSON item required"), + errdetail("Singleton boolean result is expected."))); why bother with errdetail at all? It's not conveying any useful increment of information. In this example I think errmsg("expression should return a singleton boolean") is sufficient and well-phrased. Likewise, a bit further down, + errmsg("SQL/JSON member not found"), + errdetail("JSON object does not contain key = \"%s\".", there is nothing being said here that wouldn't fit perfectly well into one errmsg. > My question regarding jsonpath_yyerror() vs. bison errors is still > relevant. Should we bother making bison-based errdetail() a complete > sentence starting from uppercase character? If not, should we make > other yyerror() calls look the same? Or should we rather move bison > error from errdetail() to errmsg()? The latter I think. The core lexer just presents the yyerror message as primary: scanner_yyerror(const char *message, core_yyscan_t yyscanner) { ... ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), /* translator: %s is typically the translation of "syntax error" *= / errmsg("%s at end of input", _(message)), lexer_errposition())); and in a quick look at what jsonpath is doing, I'm not really seeing the point of it being different. You could do something like /* translator: %s is typically the translation of "syntax error" *= / errmsg("%s in jsonpath input", _(message)) to preserve the information that this is about jsonpath, but beyond that I don't see that splitting off an errdetail is helping much. Or, perhaps, provide an errdetail giving the full jsonpath input string? That might or might not be redundant with other context information, so I'm not sure how useful it'd be. Anyway, my main criticism is still that this is way too eager to use an errdetail message when it could perfectly well fit all the info into the primary error. regards, tom lane