Re: Bug in error reporting for multi-line JSON

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: "tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>, Hamid Akhtar <hamid.akhtar@gmail.com>, Simon Riggs <simon.riggs@enterprisedb.com>, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Date: 2021-08-25T14:55:52Z
Lists: pgsql-bugs, pgsql-hackers
Daniel Gustafsson <daniel@yesql.se> writes:
>> On 25 Aug 2021, at 10:22, tanghy.fnst@fujitsu.com wrote:
>> I think the while condition "context_start < context_end" added in commit ffd3944ab9 is useless. Thoughts?

> Judging by the diff it’s likely a leftover from the previous coding.  I don’t
> see a case for when it would hit, but it also doesn’t seem to do any harm apart
> from potentially causing static analyzers to get angry.

Yeah.  I think that while reviewing this patch I read the while-condition
as a range check on context_start, but it isn't --- both inequalities
are in the same direction.  I suppose there could be some quibble
about what happens if context_end - context_start is so large as to
overflow an integer, but that's never gonna happen (and if it did,
we'd have other issues, for instance the lack of any check-for-interrupt
in this loop).

Will fix.

			regards, tom lane



Commits

  1. Remove redundant test.

  2. Improve reporting for syntax errors in multi-line JSON data.