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 1girGE-00055j-Uf for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jan 2019 01:41:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1girGD-0004JM-3x for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jan 2019 01:41:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1girGC-0004JF-E3 for pgsql-hackers@lists.postgresql.org; Mon, 14 Jan 2019 01:41:52 +0000 Received: from bay.acenet.us ([173.230.252.50]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1girG5-0001Zj-5M for pgsql-hackers@postgresql.org; Mon, 14 Jan 2019 01:41:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=iww4qUoa3Xb2OPQ0KJZvHzzpWWuau1kE6r7ZwS1TrGA=; b=X+YqCjwb3+3SsimB9Owf0klKWA +XOjLj0UptZqnti3ufVd6hYHAdPMYKTugZ4gIEuIY2eNESbO5xn0xXtRxRgVpxn42QqpooGFydFWL jm8ruaU8VVJY7DlVuikoWiT0OOboym0mD3YlKx4eU9yKy5tp8AzZjSVOXcz8qYhrnmYH/uGcVBSYS BbK0y7ZjH2qH+zZBQtggiHj5Km1BpMk6T6DdBIU5teQvNK6xrxPbwG0m/m6oDT6OUGjml4F9+OtDJ Zt6cT1tHsU8ZFhE6dJA+7AYxY2vjsUjaNsMnLMv75Q63JqpmWMyhUXMvoIywmgSkOUbxraZnIKJ+Z fJKMFDLw==; Received: from [192.182.57.242] (port=45373) by bay.acenet.us with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1girG1-008yIN-K2; Sun, 13 Jan 2019 20:41:42 -0500 Subject: Re: PostgreSQL vs SQL/XML Standards To: Pavel Stehule References: <20181025194720.ylmw64xqlnjr5wja@alvherre.pgsql> <45C74339-3531-46BD-A595-37183C6730A1@winand.at> <5C283168.8060001@anastigmatix.net> <5C291741.9060506@anastigmatix.net> <5C297BB7.9070509@anastigmatix.net> <5C3A7A90.3070207@anastigmatix.net> Cc: Markus Winand , Alvaro Herrera , Tom Lane , PostgreSQL Hackers From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5C3BE8CE.8010606@anastigmatix.net> Date: Sun, 13 Jan 2019 20:41:34 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=-99.5 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk There is a bug that remains, in the else if (xpathobj->type == XPATH_STRING) case. As it is now, it simply passes the string value of the result into the output column's type-input function, regardless of the output column type. If the output column type is xml, this will attempt to parse the string as xml. The result should simply be xml content consisting of a text node representing the string (as by XMLTEXT()). If it contains XML metacharacters, they should be escaped. For a non-xml output column, the string should be used directly, as it is now. # select * from xmltable('.' passing xmlelement(name a) columns a text path '""', b xml path '""'); a | b --------+-------- | Oracle fiddle for comparison: https://dbfiddle.uk/?rdbms=oracle_18&fiddle=26f91a9e55a6908c2bcf848b464ca381 A B <foo/> -Chap