Adding XMLEXISTS to the grammar - Mailing list pgsql-hackers

From Mike Fowler
Subject Adding XMLEXISTS to the grammar
Date
Msg-id 4C0F6DBF.9000001@mlfowler.com
Whole thread Raw
Responses Re: Adding XMLEXISTS to the grammar  (Robert Haas <robertmhaas@gmail.com>)
List 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
youneed 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



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: failover vs. read only queries
Next
From: Greg Stark
Date:
Subject: Re: How about closing some Open Items?