Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YJqFf-0003Va-JW for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Feb 2015 21:15:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YJqFf-0007VJ-2f for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Feb 2015 21:15:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YJprp-0006UA-34 for pgsql-bugs@postgresql.org; Fri, 06 Feb 2015 20:51:09 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YJprj-0007mI-RI for pgsql-bugs@postgresql.org; Fri, 06 Feb 2015 20:51:07 +0000 MIME-Version: 1.0 Subject: BUG #12743: error in xml conversion To: pgsql-bugs@postgresql.org From: barrera@mail.bpa.cu Date: Fri, 06 Feb 2015 20:50:09 +0000 Message-ID: <20150206205009.25253.37595@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 12743 Logged by: Jorge barrera Email address: barrera@mail.bpa.cu PostgreSQL version: 9.2.10 Operating system: windows 7 32 bits Description: I have the following function for converting xml data in a Postgresql table written in plpgsql: CREATE OR REPLACE FUNCTION inicio_actualizacion(dato xml) RETURNS character varying AS $BODY$ DECLARE VAR TEXT; BEGIN DELETE FROM p11; EXECUTE 'CREATE OR REPLACE VIEW tempinicio AS WITH xml_import (xml_data) AS ( SELECT XMLPARSE(DOCUMENT'||quote_literal(dato)||')),otemp1 AS ( SELECT UNNEST(XPATH('||quote_literal('/pl:entrada/pl:row')||', xml_data, ARRAY[array['||quote_literal('pl')||', '||quote_literal('http://xxx.yy.zz/')||']])) AS vector FROM xml_import) SELECT CAST((XPATH('||quote_literal('/row/p3c1/text()')||', vector)::VARCHAR[])[1] AS integer) AS p1c1, XMLPARSE(CONTENT (XPATH('||quote_literal('/row/p3c3/text()')||', vector)::VARCHAR[])[1]) AS p1c2 ' ||'FROM otemp1'; INSERT INTO p11 SELECT * FROM tempinicio; RETURN '00'; END; $BODY$ LANGUAGE plpgsql VOLATILE; When I execute this function in Postgres version 9.2 with the table entrada: entrada (p3c1 integer, p3c3xml) containing the following two rows: 1;"a123b]]>" 2;"c345d" I get following results for p11: P11(p1c1 integer, p1c2 xml) 1;"<a>a123b</a>" 2;NULL But the correct result should be: 1;”a123b” 2;NULL As can be seen, the characters < and > are substituted incorrectly for < and > respectively. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs