add xml support function

Started by fangfang liuabout 16 years ago10 messages
#1fangfang liu
yisuoyanyu888@gmail.com

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!

#2Robert Haas
robertmhaas@gmail.com
In reply to: fangfang liu (#1)
Re: add xml support function

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

#3fangfang liu
yisuoyanyu888@gmail.com
In reply to: Robert Haas (#2)
Re: add xml support function

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>

Show quoted text

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

#4Peter Eisentraut
peter_e@gmx.net
In reply to: fangfang liu (#3)
Re: add xml support function

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.

#5fangfang liu
yisuoyanyu888@gmail.com
In reply to: Peter Eisentraut (#4)
Re: add xml support function

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>

Show quoted text

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.

#6Andrew Dunstan
andrew@dunslane.net
In reply to: fangfang liu (#5)
Re: add xml support function

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&gt;

cheers

andrew

#7Alvaro Herrera
alvherre@commandprompt.com
In reply to: fangfang liu (#3)
Re: add xml support function

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

#8fangfang liu
yisuoyanyu888@gmail.com
In reply to: Alvaro Herrera (#7)
Re: add xml support function

yes,whereever xmlconcat appears.

2009/12/31 Alvaro Herrera <alvherre@commandprompt.com>

Show quoted text

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/ <http://www.commandprompt.com/&gt;
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#9fangfang liu
yisuoyanyu888@gmail.com
In reply to: Andrew Dunstan (#6)
Re: add xml support function

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>

Show quoted text

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&gt;

cheers

andrew

#10fangfang liu
yisuoyanyu888@gmail.com
In reply to: fangfang liu (#9)
Re: add xml support function

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>

Show quoted text

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&gt;

cheers

andrew