pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to get more detailed error messages?
6+ messages / 5 participants
[nested] [flat]

* How to get more detailed error messages?
@ 2002-04-12 06:11 Markus Wagner <wagner@imsd.uni-mainz.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Markus Wagner @ 2002-04-12 06:11 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; +Cc: pgsql-sql

Hi,

we have a union query over three select queries with some hundred lines of 
SQL code, created as a view.

When executing the code we get an error message "ERROR:  UNION types "text" 
and "int4" not matched" with only the line number of the terminating 
semicolon included.

This is a problem that we have with many other sql things, too. The line 
number of the semicolon is the only thing we know. If we had the line number 
of the error itself we could save much time. Alternatively, if we had the 
name of the variables (in the case above) or a little quote of the problem 
area, we would have much less trouble.

Isn't there a way to get the parser to talk more precisely???

Thank you very much,

Markus Wagner



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* how to get more detailed error messages?
@ 2002-04-12 07:04 Markus Wagner <wagner@imsd.uni-mainz.de>
  2002-04-12 17:40 ` Re: [SQL] how to get more detailed error messages? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Markus Wagner @ 2002-04-12 07:04 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; +Cc: pgsql-sql

Hi,

we have a union query over three select queries with some hundred lines of 
SQL code, created as a view.

When executing the code we get an error message "ERROR:  UNION types "text" 
and "int4" not matched" with only the line number of the terminating 
semicolon included.

This is a problem that we have with many other sql things, too. The line 
number of the semicolon is the only thing we know. If we had the line number 
of the error itself we could save much time. Alternatively, if we had the 
name of the variables (in the case above) or a little quote of the problem 
area, we would have much less trouble.

Isn't there a way to get the parser to talk more precisely???

Thank you very much,

Markus Wagner



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] how to get more detailed error messages?
  2002-04-12 07:04 how to get more detailed error messages? Markus Wagner <wagner@imsd.uni-mainz.de>
@ 2002-04-12 17:40 ` Tom Lane <tgl@sss.pgh.pa.us>
  2002-04-12 18:05   ` Re: [SQL] how to get more detailed error messages? Alvaro Herrera <alvherre@atentus.com>
  2002-04-12 18:20   ` Re: [SQL] how to get more detailed error messages? Richard Emberson <emberson@phc.net>
  2002-04-12 18:26   ` Re: [SQL] how to get more detailed error messages? Josh Berkus <josh@agliodbs.com>
  0 siblings, 3 replies; 6+ messages in thread

From: Tom Lane @ 2002-04-12 17:40 UTC (permalink / raw)
  To: Markus Wagner <wagner@imsd.uni-mainz.de>; +Cc: pgsql-general@postgresql.org; pgsql-sql

Markus Wagner <wagner@imsd.uni-mainz.de> writes:
> we have a union query over three select queries with some hundred lines of 
> SQL code, created as a view.

> When executing the code we get an error message "ERROR:  UNION types "text" 
> and "int4" not matched" with only the line number of the terminating 
> semicolon included.

> Isn't there a way to get the parser to talk more precisely???

Not at present.  This sort of error comes from deep inside the parser;
the code is working with a querytree that does not have any direct
connection anymore to source text.  Line numbers are not to be had,
and your suggestion of variable names is rather pointless also, at
least for this example --- there's no guarantee that the expressions
causing the problem involve any variables at all.

I have occasionally toyed with the idea of labeling querytree elements
with back-pointers showing the segment of source text that they came
from, but AFAICT this would impose a nontrivial cost on parsing activity
--- a cost that'd be paid all the time, even on correct queries.  Not
sure if it'd be a net benefit or not.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] how to get more detailed error messages?
  2002-04-12 07:04 how to get more detailed error messages? Markus Wagner <wagner@imsd.uni-mainz.de>
  2002-04-12 17:40 ` Re: [SQL] how to get more detailed error messages? Tom Lane <tgl@sss.pgh.pa.us>
@ 2002-04-12 18:05   ` Alvaro Herrera <alvherre@atentus.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Alvaro Herrera @ 2002-04-12 18:05 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: PgSQL general <pgsql-general@postgresql.org>

En Fri, 12 Apr 2002 13:40:06 -0400
Tom Lane <tgl@sss.pgh.pa.us> escribió:

> Markus Wagner <wagner@imsd.uni-mainz.de> writes:

> > When executing the code we get an error message "ERROR:  UNION types "text" 
> > and "int4" not matched" with only the line number of the terminating 
> > semicolon included.
> 
> > Isn't there a way to get the parser to talk more precisely???

[...]

> I have occasionally toyed with the idea of labeling querytree elements
> with back-pointers showing the segment of source text that they came
> from, but AFAICT this would impose a nontrivial cost on parsing activity
> --- a cost that'd be paid all the time, even on correct queries.  Not
> sure if it'd be a net benefit or not.

Is there a way to tell the parser to only include those backpointer on
demand (say, set them to NULL unless explicitly told to do the
backreference)? That way, correct queries do not have to pay the price,
but there is a way to debug a query if one wants to. Say,

DEBUG <sql-stmt>

or something like that (just like EXPLAIN etc).

-- 
Alvaro Herrera (<alvherre[a]atentus.com>)
"El destino baraja y nosotros jugamos" (A. Schopenhauer)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] how to get more detailed error messages?
  2002-04-12 07:04 how to get more detailed error messages? Markus Wagner <wagner@imsd.uni-mainz.de>
  2002-04-12 17:40 ` Re: [SQL] how to get more detailed error messages? Tom Lane <tgl@sss.pgh.pa.us>
@ 2002-04-12 18:20   ` Richard Emberson <emberson@phc.net>
  2 siblings, 0 replies; 6+ messages in thread

From: Richard Emberson @ 2002-04-12 18:20 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Markus Wagner <wagner@imsd.uni-mainz.de>; pgsql-general@postgresql.org; pgsql-sql


When an error occurs in the parser, have the parser inform the top-level
(whatever that is)
and the query is reparsed this time keeping the context information so that a
more
meaningful error message maybe generated.
This has the overhead of setting up the catch block (I guess it would be a
longjmp)
and also the parser would have to check a flag to see if context information
(backpointers)
should be generated - unless you have two versions of the parser ... compile
time flags.

Richard

Tom Lane wrote:

> Markus Wagner <wagner@imsd.uni-mainz.de> writes:
> > we have a union query over three select queries with some hundred lines of
> > SQL code, created as a view.
>
> > When executing the code we get an error message "ERROR:  UNION types "text"
> > and "int4" not matched" with only the line number of the terminating
> > semicolon included.
>
> > Isn't there a way to get the parser to talk more precisely???
>
> Not at present.  This sort of error comes from deep inside the parser;
> the code is working with a querytree that does not have any direct
> connection anymore to source text.  Line numbers are not to be had,
> and your suggestion of variable names is rather pointless also, at
> least for this example --- there's no guarantee that the expressions
> causing the problem involve any variables at all.
>
> I have occasionally toyed with the idea of labeling querytree elements
> with back-pointers showing the segment of source text that they came
> from, but AFAICT this would impose a nontrivial cost on parsing activity
> --- a cost that'd be paid all the time, even on correct queries.  Not
> sure if it'd be a net benefit or not.
>
>                         regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] how to get more detailed error messages?
  2002-04-12 07:04 how to get more detailed error messages? Markus Wagner <wagner@imsd.uni-mainz.de>
  2002-04-12 17:40 ` Re: [SQL] how to get more detailed error messages? Tom Lane <tgl@sss.pgh.pa.us>
@ 2002-04-12 18:26   ` Josh Berkus <josh@agliodbs.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Josh Berkus @ 2002-04-12 18:26 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Markus Wagner <wagner@imsd.uni-mainz.de>; +Cc: pgsql-general@postgresql.org; pgsql-sql

Tom,

> I have occasionally toyed with the idea of labeling querytree
> elements
> with back-pointers showing the segment of source text that they came
> from, but AFAICT this would impose a nontrivial cost on parsing
> activity
> --- a cost that'd be paid all the time, even on correct queries.  Not
> sure if it'd be a net benefit or not.

I'd suggest it as a compile-time option, if that's feasable.  This is
only a concern, IME, for development machines.  On a production
machine, presumably all of the queries and functions are already
tested.

Thus, if we had the compile-time option of --explicit-query-errors then
it would add this functionality for testers without slowing down
PostgreSQL overall.  Don't know if compile-time options for the parser
are reasonable, though.  Also, I would personally rate this below
several other improvement projects in priority, such as in-database
replication, point-in-time recovery and nested transactions.

-Josh Berkus



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2002-04-12 18:26 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-04-12 06:11 How to get more detailed error messages? Markus Wagner <wagner@imsd.uni-mainz.de>
2002-04-12 07:04 how to get more detailed error messages? Markus Wagner <wagner@imsd.uni-mainz.de>
2002-04-12 17:40 ` Re: [SQL] how to get more detailed error messages? Tom Lane <tgl@sss.pgh.pa.us>
2002-04-12 18:05   ` Re: [SQL] how to get more detailed error messages? Alvaro Herrera <alvherre@atentus.com>
2002-04-12 18:20   ` Re: [SQL] how to get more detailed error messages? Richard Emberson <emberson@phc.net>
2002-04-12 18:26   ` Re: [SQL] how to get more detailed error messages? Josh Berkus <josh@agliodbs.com>

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