Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iO3OG-0002q6-4O for pgsql-bugs@arkaria.postgresql.org; Fri, 25 Oct 2019 17:28:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iO3OE-0005Mg-SK for pgsql-bugs@arkaria.postgresql.org; Fri, 25 Oct 2019 17:28:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iO3OE-0005MZ-L8 for pgsql-bugs@lists.postgresql.org; Fri, 25 Oct 2019 17:28:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iO3OC-0007va-Ew for pgsql-bugs@lists.postgresql.org; Fri, 25 Oct 2019 17:28:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x9PHRq5D027893; Fri, 25 Oct 2019 13:27:52 -0400 From: Tom Lane To: Chapman Flack cc: mostafa_bit0108@hotmail.com, pgsql-bugs@lists.postgresql.org, Markus Winand , Pavel Stehule Subject: Re: BUG #16046: xpath returns CDATA tag along with the value in postgres 12 In-reply-to: <5DB253C8.4020501@anastigmatix.net> References: <16046-a04d0611e7a0c03a@postgresql.org> <10621.1571953091@sss.pgh.pa.us> <5DB23068.3080601@anastigmatix.net> <5DB253C8.4020501@anastigmatix.net> Comments: In-reply-to Chapman Flack message dated "Thu, 24 Oct 2019 21:45:44 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27891.1572024472.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 25 Oct 2019 13:27:52 -0400 Message-ID: <27892.1572024472@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Chapman Flack writes: > On 10/24/19 19:14, Chapman Flack wrote: >> Which may or may not be a good thing. Perhaps it could lead the unwary >> in some cases to think such a query is giving a directly usable >> text string back, which will be harmless until the one time a value >> with escaping comes back. (The no-surprises way to get back a directly >> usable text string, if that's what's wanted, would be with XMLTABLE >> and an output column of text type.) > If the original reporter is happy with getting xml back, instead of > raw text, but only wants the form of escaping to be the same as it was > in pg11, the xpath //cname/aname/text() can just be rewritten as > string(//cname/aname), which will lose any CDATA-ness and consistently > produce the form where individual characters are escaped, in 11 or 12. > I think. Yeah, that does work the same for me in 11 and HEAD: regression=3D# SELECT unnest(xpath('string(//cname/aname)','= 4]]>'::xml)); unnest = --------------- select 5>4 (1 row) So I'm inclined to write this off as an intended, or at least not unwanted, change. However, this complaint does reinforce Alvaro's original choice not to back-patch 251cf2e27. The v12 release notes don't call this out as a compatibility issue, nor mention anything about CDATA handling: * Fix assorted bugs in XML functions (Pavel Stehule, Markus Winand, Chapman Flack) Specifically, in XMLTABLE, xpath(), and xmlexists(), fix some cases where nothing was output for a node, or an unexpected error was thrown, or necessary escaping of XML special characters was omitted. Should we extend that item (if so, what to say exactly?) and/or move it into the "Observe the following incompatibilities" list? regards, tom lane