Re: Patch for Improved Syntax Error Reporting

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Page <dpage(at)vale-housing(dot)co(dot)uk>
Cc: "'Fernando Nasser'" <fnasser(at)cygnus(dot)com>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Neil Padgett <npadgett(at)redhat(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Patch for Improved Syntax Error Reporting
Date: 2001-08-02 22:11:40
Message-ID: 14285.996790300@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Dave Page <dpage(at)vale-housing(dot)co(dot)uk> writes:
> However, pgAdmin does pretty much just the reformatting you've suggested,
> including stripping of comments (well that's in the new codebase anyway),
> so:

> -- Simple Query
> SELECT
> oid,
> relname
> FRUM
> pg_class

> becomes:

> SELECT oid, relname FRUM pg_class

> Giving the error

> ERROR: parser: parse error at or near 'frum':
> SELECT oid, relname FRUM pg_class
> ^

> Which would still be useful of course.

Yes, but on that size of query you hardly need a syntax error pointer
anyway. Consider what happens when the query is several thousand
characters long and the error message wraps across several dozen lines
(as does the spaces-and-caret pointer line). Now you really *need* that
error pointer, but good luck making any use of what's displayed :-(

Another reason why the simplistic approach is not all that useful is
that the reformatting might itself be or mask the problem. Suppose I
fat-finger my query so that I have an accidentally unterminated comment,
or the code recognizes a comment where I didn't intend one. The error
message produced by the backend will omit the parts of the query that
the client code thought were comments, which is likely to make it harder
not easier for me to figure out what I did wrong --- not least because
it eliminates cues I might otherwise use to figure out which part of a
large query string is being complained about.

Basically, upgrading syntax-error behavior to something useful will take
some cooperation from the client side as well as the backend. IMHO we
shouldn't dumb down our ambitions to be merely what can be implemented
without any client cooperation.

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Padgett 2001-08-02 22:20:54 Re: Revised Patch to allow multiple table locks in "Unison"
Previous Message Dave Page 2001-08-02 21:59:57 RE: Patch for Improved Syntax Error Reporting