Improve reporting for syntax errors in multi-line JSON data.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 1 Mar 2021 21:44:17 +0000 (16:44 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 1 Mar 2021 21:44:17 +0000 (16:44 -0500)
commitffd3944ab9d481906137bc7d20f5325a2bd68acc
tree6c9b03abc608dc3ea73d8baf9179e9426016ca5d
parentbd69ddfcdbf650f11af4317f3f6686c012cf66d0
Improve reporting for syntax errors in multi-line JSON data.

Point to the specific line where the error was detected; the
previous code tended to include several preceding lines as well.
Avoid re-scanning the entire input to recompute which line that
was.  Simplify the logic a bit.  Add test cases.

Simon Riggs and Hamid Akhtar, reviewed by Daniel Gustafsson and myself

Discussion: https://postgr.es/m/CANbhV-EPBnXm3MF_TTWBwwqgn1a1Ghmep9VHfqmNBQ8BT0f+_g@mail.gmail.com
src/backend/utils/adt/jsonfuncs.c
src/common/jsonapi.c
src/include/common/jsonapi.h
src/test/regress/expected/json.out
src/test/regress/expected/jsonb.out
src/test/regress/sql/json.sql
src/test/regress/sql/jsonb.sql