Re: [PATCH] Re: Adding XMLEXISTS to the grammar

From: Mike Fowler <mike(at)mlfowler(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Re: Adding XMLEXISTS to the grammar
Date: 2010-06-27 22:22:38
Message-ID: 4C27CF2E.1010001@mlfowler.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas wrote:
> On Sun, Jun 27, 2010 at 12:04 PM, Mike Fowler <mike(at)mlfowler(dot)com> wrote:
>
>> Thanks again for your help Robert, turns out the fault was in the pg_proc
>> entry (the 3 up there should've been a two!). Once I took the grammar out it
>> was quickly obvious where I'd gone wrong.
>>
>
> Glad it was a helpful suggestion.
>
>
>> Attached is a patch with the revised XMLEXISTS function, complete with
>> grammar support and regression tests. The implemented grammar is:
>>
>> XMLEXISTS ( xpath_expression PASSING BY REF xml_value [BY REF] )
>>
>> Though the full grammar makes everything after the xpath_expression
>> optional, I've left it has mandatory simply to avoid lots of rework of the
>> function (would need new null checks, memory handling would need reworking).
>>
>
> So if you don't specify the xml_value, what does the xpath_expression
> get applied to?
>
From what I can gather the xpath_expression would be evalutated against
an empty document thereby returning false for every xpath_expression
except for 'true()'. Apache Derby has made the xml_value mandatory as
well (though I'll stress my conclusion wasn't based on this fact). If
you think it would better to adhere more closely to the standard I can
certainly look to do so. From a cursory glance at libxml's API I think
it should be straight forward to query against an empty document such
that I wouldn't need ot code for the exceptional case (or cases if I've
missed others).

Regards,

--
Mike Fowler
Registered Linux user: 379787

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Aaron W. Swenson 2010-06-27 22:38:09 Re: Why are these modules built without respecting my LDFLAGS?
Previous Message Tom Lane 2010-06-27 22:19:02 Re: pg_dump's checkSeek() seems inadequate