xml_is_document and selective pg_re_throw

From: Nikhil Sontakke <nikkhils(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: xml_is_document and selective pg_re_throw
Date: 2012-06-12 11:18:45
Message-ID: CANgU5ZcgN0dDFPCbm6TY9SZTfgCMGjL3RKqnEZALHQOWV-mVaA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Consider:

SELECT xml '<foo>bar</foo><bar>foo</bar>' IS DOCUMENT;

And I was looking at xml_is_document() source code. It calls xml_parse
which throws an error with code set to ERRCODE_INVALID_XML_DOCUMENT. The
catch block of xml_parse then rethrows.

Now xml_is_document does a selective rethrow only if the error is not
ERRCODE_INVALID_XML_DOCUMENT. I can understand that this function does this
to return true/false, but doesn't this behavior of not propagating the
error up all the way dangerous? InterruptHoldoffCount inconsistencies for
instance?

A better way would have been to modify xml_parse to take an additional
boolean argument "to_rethrow" and not to rethrow if that is false?
Thoughts?

Regards,
Nikhils

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2012-06-12 11:43:07 Re: Skip checkpoint on promoting from streaming replication
Previous Message Thom Brown 2012-06-12 09:47:24 Re: pg_basebackup --xlog compatibility break