Hi,

I've done a bit of testing now and it seems that both sets of XML
functions will coexist in the same database (they both load OK and I can
use functions from both without any apparent problem).

I have changed the name of the new parse function to xml_valid and fixed
a reference to SortMem which meant that the code as supplied would work
against 7.3 and 7.4 but wouldn't work in CVS. Oops! Patch is attached.

Regards

John


? config.log
? contrib/xml-patch2004-03-07
? src/test/regress/sql/out1
Index: contrib/xml2/README.pgxml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/xml2/README.pgxml,v
retrieving revision 1.1
diff -c -r1.1 README.pgxml
*** contrib/xml2/README.pgxml   5 Mar 2004 03:57:58 -0000       1.1
--- contrib/xml2/README.pgxml   7 Mar 2004 18:38:57 -0000
***************
*** 27,33 ****
  
  The first set of functions are straightforward XML parsing and XPath queries:
  
! pgxml_parse(document) RETURNS bool
  
  This parses the document text in its parameter and returns true if the
  document is well-formed XML.
--- 27,33 ----
  
  The first set of functions are straightforward XML parsing and XPath queries:
  
! xml_valid(document) RETURNS bool
  
  This parses the document text in its parameter and returns true if the
  document is well-formed XML.
Index: contrib/xml2/pgxml.sql.in
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/xml2/pgxml.sql.in,v
retrieving revision 1.1
diff -c -r1.1 pgxml.sql.in
*** contrib/xml2/pgxml.sql.in   5 Mar 2004 03:57:58 -0000       1.1
--- contrib/xml2/pgxml.sql.in   7 Mar 2004 18:38:57 -0000
***************
*** 1,6 ****
  --SQL for XML parser
  
! CREATE OR REPLACE FUNCTION pgxml_parse(text) RETURNS bool
        AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);
  
  CREATE OR REPLACE FUNCTION xpath_string(text,text) RETURNS text
--- 1,6 ----
  --SQL for XML parser
  
! CREATE OR REPLACE FUNCTION xml_valid(text) RETURNS bool
        AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);
  
  CREATE OR REPLACE FUNCTION xpath_string(text,text) RETURNS text
Index: contrib/xml2/xpath.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/xml2/xpath.c,v
retrieving revision 1.1
diff -c -r1.1 xpath.c
*** contrib/xml2/xpath.c        5 Mar 2004 03:57:58 -0000       1.1
--- contrib/xml2/xpath.c        7 Mar 2004 18:38:59 -0000
***************
*** 39,45 ****
  static xmlXPathObjectPtr pgxml_xpath(text *document, xmlChar* xpath);
  
  
! Datum         pgxml_parse(PG_FUNCTION_ARGS);
  Datum           xpath_nodeset(PG_FUNCTION_ARGS);
  Datum         xpath_string(PG_FUNCTION_ARGS);
  Datum         xpath_number(PG_FUNCTION_ARGS);
--- 39,45 ----
  static xmlXPathObjectPtr pgxml_xpath(text *document, xmlChar* xpath);
  
  
! Datum         xml_valid(PG_FUNCTION_ARGS);
  Datum           xpath_nodeset(PG_FUNCTION_ARGS);
  Datum         xpath_string(PG_FUNCTION_ARGS);
  Datum         xpath_number(PG_FUNCTION_ARGS);
***************
*** 162,173 ****
  
  /* Returns true if document is well-formed */
  
! PG_FUNCTION_INFO_V1(pgxml_parse);
  
  Datum
! pgxml_parse(PG_FUNCTION_ARGS)
  {
!       /* called as pgxml_parse(document) */
        xmlDocPtr       doctree;
        text       *t = PG_GETARG_TEXT_P(0);            /* document buffer */
        int32           docsize = VARSIZE(t) - VARHDRSZ;
--- 162,173 ----
  
  /* Returns true if document is well-formed */
  
! PG_FUNCTION_INFO_V1(xml_valid);
  
  Datum
! xml_valid(PG_FUNCTION_ARGS)
  {
!       /* called as xml_valid(document) */
        xmlDocPtr       doctree;
        text       *t = PG_GETARG_TEXT_P(0);            /* document buffer */
        int32           docsize = VARSIZE(t) - VARHDRSZ;
***************
*** 646,656 ****
    per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
    oldcontext = MemoryContextSwitchTo(per_query_ctx);
  
! /* Create the tuplestore - SortMem is the max in-memory size before it is
!  * shipped to a disk heap file. Just like ... SortMem!
   */
  
!   tupstore = tuplestore_begin_heap(true, false, SortMem);
  
    MemoryContextSwitchTo(oldcontext);
  
--- 646,656 ----
    per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
    oldcontext = MemoryContextSwitchTo(per_query_ctx);
  
! /* Create the tuplestore - work_mem is the max in-memory size before a
!  * file is created on disk to hold it.
   */
  
!   tupstore = tuplestore_begin_heap(true, false, work_mem);
  
    MemoryContextSwitchTo(oldcontext);
  
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to