Re: remove contrib/xml2 - Mailing list pgsql-hackers

From M Z
Subject Re: remove contrib/xml2
Date
Msg-id e824728e1002172031q7b592af7u1f344e2e3d76733f@mail.gmail.com
Whole thread Raw
In response to Re: remove contrib/xml2  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: remove contrib/xml2
List pgsql-hackers
Hi Alvaro,

I followed your instruction but put the patch on 8.4.2 as I found it crashes. It looks like the server still crash in the same way. Can you and anyone give me some ideas how to fix this bug?

==============================
conifer=# CREATE TABLE xpath_test (id integer NOT NULL, t xml);
CREATE TABLE
conifer=# INSERT INTO xpath_test VALUES (1, '<doc><int>1</int></doc>');
INSERT 0 1
conifer=# SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true') as t(id int4);
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!>
==============================

Best,
M Z


>
> CREATE TABLE xpath_test (id integer NOT NULL, t xml);
> INSERT INTO xpath_test VALUES (1, '<doc><int>1</int></doc>');
> SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
> as t(id int4);

> Hmm.  Well, all I know is that the first thing I tried crashed the server.
 
This trivial patch lingering on my system fixes this crasher (this is
for the 8.3 branch).  It makes the "problem in alloc set ExprContext"
warning show up instead.

There are still lotsa other holes, but hey, this is a start ...

Index: contrib/xml2/xpath.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/contrib/xml2/xpath.c,v
retrieving revision 1.16.2.1
diff -c -p -r1.16.2.1 xpath.c
*** contrib/xml2/xpath.c        26 Mar 2008 01:19:11 -0000      1.16.2.1
--- contrib/xml2/xpath.c        27 Jan 2010 15:30:56 -0000
*************** xpath_table(PG_FUNCTION_ARGS)
*** 793,798 ****
--- 793,801 ----
  */
       pgxml_parser_init();

+       PG_TRY();
+       {
+
       /* For each row i.e. document returned from SPI */
       for (i = 0; i < proc; i++)
       {
*************** xpath_table(PG_FUNCTION_ARGS)
*** 929,934 ****
--- 932,944 ----
               if (xmldoc)
                       pfree(xmldoc);
       }
+       }
+       PG_CATCH();
+       {
+               xmlCleanupParser();
+               PG_RE_THROW();
+       }
+       PG_END_TRY();

       xmlCleanupParser();
 /* Needed to flag completeness in 7.3.1. 7.4 defines it as a no-op. */

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: NOTIFY/LISTEN on read-only slave?
Next
From: Tom Lane
Date:
Subject: A thought: should we run pgindent now?