pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make all ereport() calls within gram.y provide error locations.
Date: Thu, 31 Oct 2024 20:09:38 +0000
Message-ID: <E1t6bUA-003L1a-OS@gemulon.postgresql.org> (raw)

Make all ereport() calls within gram.y provide error locations.

This patch responds to a comment that I (tgl) made in the
discussion leading up to 774171c4f, that really all errors
occurring during raw parsing should provide error cursors.
Syntax errors reported by Bison will have one, and most of
the handwritten ereport's in gram.y already provide one,
but there were a few stragglers.

(It is not claimed that this handles every failure reachable
during raw parsing --- out-of-memory is an obvious exception.
But this makes a good start on cases that are likely to occur.)

While we're at it, clean up the reported positions for errors
associated with LIMIT/OFFSET clauses.  Previously we were
relying on applying exprLocation() to the contained expressions,
but that leads to slightly odd cursor placement, e.g.

regression=# (select * from foo limit 10) limit 10;
ERROR:  multiple LIMIT clauses not allowed
LINE 1: (select * from foo limit 10) limit 10;
                                           ^

We can afford to keep a little more state in the transient
SelectLimit structs in order to make that better.

Jian He and Tom Lane (extracted from a larger patch by Jian,
with some additional work by me)

Discussion: https://postgr.es/m/CACJufxEmONE3P2En=jopZy1m=cCCUs65M4+1o52MW5og9oaUPA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2d8bff603c9ee7b284b85016fd1a8849ee36368d

Modified Files
--------------
src/backend/parser/gram.y                  | 74 +++++++++++++++++++++---------
src/test/regress/expected/create_table.out |  2 +
src/test/regress/expected/limit.out        |  4 ++
src/test/regress/expected/sqljson.out      |  4 ++
4 files changed, 62 insertions(+), 22 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1t6bUA-003L1a-OS@gemulon.postgresql.org>
Permalink:  ../E1t6bUA-003L1a-OS@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1t6bUA-003L1a-OS@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Make all ereport() calls within gram.y provide error locations.
  In-Reply-To: <E1t6bUA-003L1a-OS@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox