Re: xpath_array with namespaces support - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: xpath_array with namespaces support
Date
Msg-id 200703031941.l23Jfch20859@momjian.us
Whole thread Raw
In response to xpath_array with namespaces support  ("Nikolay Samokhvalov" <samokhvalov@gmail.com>)
Responses Re: xpath_array with namespaces support
List pgsql-patches
I tried this patch bug found this regression failure:

  -- Considering only built-in procs (prolang = 12), look for multiple uses
  -- of the same internal function (ie, matching prosrc fields).  It's OK to
  -- have several entries with different pronames for the same internal function,
  -- but conflicts in the number of arguments and other critical items should
  -- be complained of.  (We don't check data types here; see next query.)
  -- Note: ignore aggregate functions here, since they all point to the same
  -- dummy built-in function.
  SELECT p1.oid, p1.proname, p2.oid, p2.proname
  FROM pg_proc AS p1, pg_proc AS p2
  WHERE p1.oid < p2.oid AND
      p1.prosrc = p2.prosrc AND
      p1.prolang = 12 AND p2.prolang = 12 AND
      (p1.proisagg = false OR p2.proisagg = false) AND
      (p1.prolang != p2.prolang OR
       p1.proisagg != p2.proisagg OR
       p1.prosecdef != p2.prosecdef OR
       p1.proisstrict != p2.proisstrict OR
       p1.proretset != p2.proretset OR
       p1.provolatile != p2.provolatile OR
       p1.pronargs != p2.pronargs);
   oid  |   proname   | oid  |   proname
  ------+-------------+------+-------------
   2931 | xpath_array | 2932 | xpath_array
  (1 row)

This is because you are calling xpath_array with 2 and 3 arguments.
Seems we don't do this anywhere else.

I also had to add a #ifdef USE_LIBXML around xml_xmlnodetotext(). Please
research a fix to this an resubmit.  Thanks.


---------------------------------------------------------------------------

Nikolay Samokhvalov wrote:
> As a result of discussion with Peter, I provide modified patch for
> xpath_array() with namespaces support.
>
> The signature is:
>   _xml xpath_array(text xpathQuery, xml xmlValue[, _text namespacesBindings])
>
> The third argument is 2-dimensional array defining bindings for
> namespaces. Simple examples:
>
> xmltest=# SELECT xpath_array('//text()', '<local:data
> xmlns:local="http://127.0.0.1"><local:piece id="1">number
> one</local:piece><local:piece id="2" /></local:data>');
>   xpath_array
> ----------------
>  {"number one"}
> (1 row)
>
> xmltest=# SELECT xpath_array('//loc:piece/@id', '<local:data
> xmlns:local="http://127.0.0.1"><local:piece id="1">number
> one</local:piece><local:piece id="2" /></local:data>',
> ARRAY[ARRAY['loc'], ARRAY['http://127.0.0.1']]);
>  xpath_array
> -------------
>  {1,2}
> (1 row)
>
> Thoughts regarding other XPath functions were exposed a couple of days
> ago: http://archives.postgresql.org/pgsql-patches/2007-02/msg00373.php
>
> If there is no objections, we could call the function provided in this
> patch as xpath() or xmlpath() (the latter is similar to SQL/XML
> functions).
>
> Also, maybe someone can suggest better approach for passing namespace
> bindings (more convenient than ARRAY[ARRAY[...], ARRAY[...]])?
>
> --
> Best regards,
> Nikolay

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org

--
  Bruce Momjian  <bruce@momjian.us>          http://momjian.us
  EnterpriseDB                               http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: resetStringInfo
Next
From: Neil Conway
Date:
Subject: Re: resetStringInfo