Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2eNo-0006HK-EW for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Jan 2021 18:08:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2eNn-0001KN-7P for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Jan 2021 18:08:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2eNn-0001KG-1M for pgsql-bugs@lists.postgresql.org; Thu, 21 Jan 2021 18:08:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2eNk-00071N-7R for pgsql-bugs@postgresql.org; Thu, 21 Jan 2021 18:08:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 10LI8SeU914795; Thu, 21 Jan 2021 13:08:29 -0500 From: Tom Lane To: Simon Riggs cc: pgsql-bugs@postgresql.org Subject: Re: Bug in error reporting for multi-line JSON In-reply-to: References: Comments: In-reply-to Simon Riggs message dated "Wed, 20 Jan 2021 06:58:09 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <914793.1611252508.1@sss.pgh.pa.us> Date: Thu, 21 Jan 2021 13:08:28 -0500 Message-ID: <914794.1611252508@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Simon Riggs writes: > JSON parsing reports the line number and relevant context info > incorrectly when the JSON contains newlines. Current code mostly just > says "LINE 1" and is misleading for error correction. There were no > tests for this previously. Couple thoughts: * I think you are wrong to have removed the line number bump that happened when report_json_context advances context_start over a newline. The case is likely harder to get to now, but it can still happen can't it? If it can't, we should remove that whole stanza. * I'd suggest naming the new JsonLexContext field "pos_last_newline"; "linefeed" is not usually the word we use for this concept. (Although actually, it might work better if you make that point to the char *after* the newline, in which case "last_linestart" might be the right name.) * I'm not enthused about back-patching. This behavior seems like an improvement, but that doesn't mean people will appreciate changing it in stable branches. regards, tom lane