Обсуждение: add xml support function

Поиск
Список
Период
Сортировка

add xml support function

От
fangfang liu
Дата:
Hi - Does anyone know how to add a xml support function into postgresql?
 
I want to add a function named xmlquery into postgresql.
 
I modify gram.y by adding xmlquery relatedcode wherever other xml support functions appear.
but the parser can not find xmlquery, the makeXmlExpr is not called at all.
 
 

Thanks!

Re: add xml support function

От
Robert Haas
Дата:
On Thu, Dec 31, 2009 at 3:33 AM, fangfang liu <yisuoyanyu888@gmail.com> wrote:
> Hi - Does anyone know how to add a xml support function into postgresql?
>
> I want to add a function named xmlquery into postgresql.
>
> I modify gram.y by adding xmlquery relatedcode wherever other xml support
> functions appear.
> but the parser can not find xmlquery, the makeXmlExpr is not called at all.

How about CREATE OR REPLACE FUNCTION xmlquery(...) ?

If that doesn't meet your needs, you'll need to explain what you're
trying to do - and probably provide a patch showing what you've tried
so far.

...Robert


Re: add xml support function

От
fangfang liu
Дата:
Actually, I expect the function looks like xmlquery(xmlcontent,xquery) and return the query result.
So xmlconcat(xml1,xml2) become a good example to study.
 
starting from gram.y, I try to make parser to call xmlquery,the following is the result of diff:
 
diff gram.y c:\new_gram.y
449c449
<       XMLPI XMLQUERY XMLROOT XMLSERIALIZE
---
>       XMLPI XMLROOT XMLSERIALIZE
8270,8273d8269
<                       | XMLQUERY '(' expr_list ')'
<                               {
<                                       $$ = makeXmlExpr(IS_XMLQUERY, NULL, NIL,$3);
<                               }
8287d8282
<
9296d9290
<                       | XMLQUERY
 
IS_XMLQUERY is added in primenodes.h
 
but the parser can not find xmlquery, the makeXmlExpr is not called at all.

thanks
2009/12/31 Robert Haas <robertmhaas@gmail.com>
On Thu, Dec 31, 2009 at 3:33 AM, fangfang liu <yisuoyanyu888@gmail.com> wrote:
> Hi - Does anyone know how to add a xml support function into postgresql?
>
> I want to add a function named xmlquery into postgresql.
>
> I modify gram.y by adding xmlquery relatedcode wherever other xml support
> functions appear.
> but the parser can not find xmlquery, the makeXmlExpr is not called at all.

How about CREATE OR REPLACE FUNCTION xmlquery(...) ?

If that doesn't meet your needs, you'll need to explain what you're
trying to do - and probably provide a patch showing what you've tried
so far.

...Robert

Re: add xml support function

От
Peter Eisentraut
Дата:
On tor, 2009-12-31 at 19:22 +0800, fangfang liu wrote:
> Actually, I expect the function looks like xmlquery(xmlcontent,xquery)
> and return the query result.

You don't need to modify the parser for that at all.  You can implement
that in user-space as a user-defined function.





Re: add xml support function

От
fangfang liu
Дата:
you mean create and replace funtion xmlquery()?
maybe you are right, but I still want to know why parser does not find xmlquery.
 
thanks.

2009/12/31 Peter Eisentraut <peter_e@gmx.net>
On tor, 2009-12-31 at 19:22 +0800, fangfang liu wrote:
> Actually, I expect the function looks like xmlquery(xmlcontent,xquery)
> and return the query result.

You don't need to modify the parser for that at all.  You can implement
that in user-space as a user-defined function.




Re: add xml support function

От
Andrew Dunstan
Дата:

fangfang liu wrote:
> you mean create and replace funtion xmlquery()?
> maybe you are right, but I still want to know why parser does not find 
> xmlquery.
>  
>
>

We would have to see your code to know why it didn't do what you expect.

What exactly are you intending that this function would do anyway? If 
you're looking at XQuery support, there are serious issues regarding 
what library to use, see 
<http://archives.postgresql.org/pgsql-hackers/2009-11/msg01445.php>

cheers

andrew


Re: add xml support function

От
Alvaro Herrera
Дата:
fangfang liu escribió:

> IS_XMLQUERY is added in primenodes.h
> 
> but the parser can not find xmlquery, the makeXmlExpr is not called at all.

Did you add it to keywords.c etc?

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: add xml support function

От
fangfang liu
Дата:
yes,whereever xmlconcat appears.<br /><br /><div class="gmail_quote">2009/12/31 Alvaro Herrera <span dir="ltr"><<a
href="mailto:alvherre@commandprompt.com">alvherre@commandprompt.com</a>></span><br/><blockquote class="gmail_quote"
style="PADDING-LEFT:1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">fangfang liu escribió:<br /><div
class="im"><br/>> IS_XMLQUERY is added in primenodes.h<br />><br />> but the parser can not find xmlquery, the
makeXmlExpris not called at all.<br /><br /></div>Did you add it to keywords.c etc?<br /><font color="#888888"><br />
--<br/>Alvaro Herrera                                <a href="http://www.commandprompt.com/"
target="_blank">http://www.CommandPrompt.com/</a><br/>PostgreSQL Replication, Consulting, Custom Development, 24x7
support<br/></font></blockquote></div><br /> 

Re: add xml support function

От
fangfang liu
Дата:
thanks for Xquery info, I do not start to implenment the xmlquery() itself , maybe call xqilla lib or sth else in the future.
I think xmltable is almost equal to xmlquery , except that it retuns talbeset insead of xml.
 
I take xmlconcat as an example , add xmlquery whereever xmlconcat appers and nothing else.
the first problem is ,  I have to make xmlquery accepted by the parser.

2009/12/31 Andrew Dunstan <andrew@dunslane.net>


fangfang liu wrote:
you mean create and replace funtion xmlquery()?
maybe you are right, but I still want to know why parser does not find xmlquery.
 


We would have to see your code to know why it didn't do what you expect.

What exactly are you intending that this function would do anyway? If you're looking at XQuery support, there are serious issues regarding what library to use, see <http://archives.postgresql.org/pgsql-hackers/2009-11/msg01445.php>

cheers

andrew

Re: add xml support function

От
fangfang liu
Дата:
Sorry,guys, my mistakes, the keywords list should be sorted , and I just append xmlquery at the end of keyword list , that is why parser does not call makexmlexpr.Instead, the parser try to find a function to match xmlquery and faild.

2009/12/31 fangfang liu <yisuoyanyu888@gmail.com>
thanks for Xquery info, I do not start to implenment the xmlquery() itself , maybe call xqilla lib or sth else in the future.
I think xmltable is almost equal to xmlquery , except that it retuns talbeset insead of xml.
 
I take xmlconcat as an example , add xmlquery whereever xmlconcat appers and nothing else.
the first problem is ,  I have to make xmlquery accepted by the parser.

2009/12/31 Andrew Dunstan <andrew@dunslane.net>



fangfang liu wrote:
you mean create and replace funtion xmlquery()?
maybe you are right, but I still want to know why parser does not find xmlquery.
 


We would have to see your code to know why it didn't do what you expect.

What exactly are you intending that this function would do anyway? If you're looking at XQuery support, there are serious issues regarding what library to use, see <http://archives.postgresql.org/pgsql-hackers/2009-11/msg01445.php>

cheers

andrew