Re: review: xml_is_well_formed - Mailing list pgsql-hackers

From Mike Fowler
Subject Re: review: xml_is_well_formed
Date
Msg-id 4C5D8005.4030304@mlfowler.com
Whole thread Raw
In response to Re: review: xml_is_well_formed  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: review: xml_is_well_formed  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
On 06/08/10 21:55, Peter Eisentraut wrote:
> On fre, 2010-08-06 at 14:43 +0100, Mike Fowler wrote:
>>> Or perhaps it could return a string instead of a boolean: content,
>>> document, or NULL if it's neither.
>>>
>>
>> I like the sound of that. In fact this helps workaround the IS
>> DOCUMENT
>> and IS CONTENT limitations such that you can you can select only
>> content, only documents or both is you use IS NOT NULL.
>>
>> Unless anyone sees a reason that this function needs to remain a
>> boolean function, I'll rework the patch over the weekend.
>
> What is the actual use case for this function?  Is the above behavior
> actually useful?

The idea is to be able to filter a table that contains XML in TEXT that 
might not be well formed. Knowing that you're only dealing with well 
formed XML prevents you blowing up when you attempt the cast.

>
> One reason to stick with boolean is backward compatibility.
>

To be honest I'm happiest with returning a boolean, even if there is 
some confusion over content only being valid. Though changing the return 
value to DOCUMENT/CONTENT/NULL makes things a touch more explicit, the 
same results can be achieved by simply running:

SELECT data::xml FROM mixed WHERE xml_is_well_formed(data) AND data::xml 
IS DOCUMENT;

Regards,
-- 
Mike Fowler
Registered Linux user: 379787


pgsql-hackers by date:

Previous
From: Mike Fowler
Date:
Subject: Re: Review: Re: [PATCH] Re: Adding xpath_exists function
Next
From: Simon Riggs
Date:
Subject: Moderator on Committers?