Adding XMLEXISTS to the grammar

From: Mike Fowler <mike(at)mlfowler(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Adding XMLEXISTS to the grammar
Date: 2010-06-09 10:32:31
Message-ID: 4C0F6DBF.9000001@mlfowler.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I've been working to improve the syntax of the XMLEXISTS function that I
put a patch forward for and have been attempting to get my head around
how you modify the grammar. I admit I'm not getting much anywhere
probably as I don't know bison but I'm starting to wonder if it's worth
the pain given recent comments on this list about not changing the
grammar for JSON support. At this point I can see a way of implementing
the following abridged syntax (abridged as I'm not doing full XQuery
support at this stage) in a conventional plain function call by handling
the PG_FUNCTION_ARGS approriately, but would this acceptable?

XMLEXISTS
(
xpath_expression
[
PASSING BY REF xml_expression [BY REF]
]
)

In case it isn't, and indeed to help me with the XML schema validation
work I'm doing, I would still like some help on how the grammar works.
From what I've greped and seen in the comments you need to modify the
following files:

- src/backend/parser/gram.y
- src/backend/parser/parse_expr.c
- src/backend/utils/ruleutils.c
- src/include/parser/kwlist.h

From what I can tell, you add the keywords to the lists in gram.y and
kwlist.h. At the appropriate place in gram.y you define the syntax and
pull out what you need and stuff it into a node (in my case using the
makeXmlExpr). You then modify parse_expr.c and ruleutils.c to handle the
new values in the fields of the XmlExpr node. Assuming I'm right so far,
the step I'm failing to figure out is where the actual c function that
implements the function gets called/associated within the grammar. What
am I missing?

Thanks in advance,

--
Mike Fowler
Registered Linux user: 379787

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2010-06-09 10:34:29 Re: How about closing some Open Items?
Previous Message Fujii Masao 2010-06-09 09:49:19 Re: failover vs. read only queries