Re: Loose ends in PG XML patch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: nikolay(at)samokhvalov(dot)com
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Loose ends in PG XML patch
Date: 2006-12-24 18:15:32
Message-ID: 3920.1166984132@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

"Nikolay Samokhvalov" <samokhvalov(at)gmail(dot)com> writes:
> On 12/24/06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> What I'm wondering about is why this printout is emitted as a separate
>> DEBUG message ... wouldn't it be better to incorporate it as the DETAIL
>> field of the error message?

> Surely, it would. But the thing is that I couldn't manage to format
> libxml2's native messages properly..

I'm not really seeing the problem. Right now I'm getting results like
this:

regression=# \set VERBOSITY verbose
regression=# set client_min_messages TO debug1;
SET
regression=# select '<foo><zit'::xml;
DEBUG: 00000: Entity: line 1: parser error : Couldn't find end of Start Tag zit line 1
<foo><zit
^
Entity: line 1: parser error : Premature end of data in tag foo line 1
<foo><zit
^

LOCATION: xml_ereport_by_code, xml.c:685
ERROR: 2200M: could not parse XML data
DETAIL: Closing tag not found
LOCATION: xml_ereport_by_code, xml.c:857
regression=# select '<?xml><foo><zit'::xml;
DEBUG: 00000: dummy.xml:1: parser error : XML declaration allowed only at the start of the document
<?xml><foo><zit
^
dummy.xml:1: parser error : ParsePI: PI xml space expected
<?xml><foo><zit
^
dummy.xml:1: parser error : ParsePI: PI xml never end ...
<?xml><foo><zit
^
dummy.xml:1: parser error : Start tag expected, '<' not found
<?xml><foo><zit
^

LOCATION: xml_ereport, xml.c:611
ERROR: 2200M: could not parse XML data
DETAIL: Start tag expected, '<' not found.
LOCATION: xml_ereport, xml.c:641
regression=#

I claim the libxml output is just fine as-is for a DETAIL message, and
we could get rid of all the pushups being done in the two versions of
xml_ereport to generate a detail message that's really insufficiently
detailed anyway. In particular, in any respectable-size chunk of XML
I think you'd *really* want some kind of error cursor position, which
the libxml output gives you.

regards, tom lane

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2006-12-24 18:25:59 pgsql: Bring some order and sanity to error handling in the xml patch.
Previous Message Nikolay Samokhvalov 2006-12-24 17:44:00 Re: Loose ends in PG XML patch

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2006-12-24 18:36:19 Re: [HACKERS] How to gain R/W access to developers wiki?
Previous Message Nikolay Samokhvalov 2006-12-24 18:12:55 Re: [HACKERS] How to gain R/W access to developers wiki?