Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gFtgZ-0007Gp-Nq for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Oct 2018 04:25:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gFtgX-0007aY-Kf for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Oct 2018 04:25:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gFtgW-0007aR-Kp for pgsql-hackers@lists.postgresql.org; Fri, 26 Oct 2018 04:25:20 +0000 Received: from bay.acenet.us ([173.230.252.50]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gFtgO-0006xo-2y for pgsql-hackers@postgresql.org; Fri, 26 Oct 2018 04:25:18 +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=Djzif2qMUQjT36p3qkouE14q6wCAMQK8f/Az97N13kU=; b=T/JYfLZM3GmOTsK+PmEGVkt6HY fHrLJAotSHTSD81/8DL8G0XVsY+Tm6t8yukShAoYNoBv/jfUiFjaqG5r+hJBDkBHbi4QiTpOaNcGi y35s/+mCstyityhZ1lJNJZ2qx5ovgUD8K8T+xLe1iaP9/65tZV4oD0H7qSDInVsRHvjOdCYtKoZ+v hpzCa42rkw12axjdwAo/OfZBZPxFhcRMSxkv3qKuzmTAOFrqRbmWjiX0/0ynP24hwfZzjLtGhzQms 7SKnRsxBe2fyt5huUZ6VjiL05HVcXJigGHyHn+s5JoVx1c3Hl6XHN56r/smjGtfYX6c0F58TAZJ/g JQ5BArMA==; Received: from [184.19.49.99] (port=37408) by bay.acenet.us with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1gFtgL-004Yg0-TN; Fri, 26 Oct 2018 00:25:10 -0400 Subject: Re: PostgreSQL vs SQL/XML Standards To: Pavel Stehule References: <2a7715e1-6170-c3f6-12c7-7e5dda84cecd@anastigmatix.net> <20181025150849.j4py2nkqjx3cgw26@alvherre.pgsql> <5BD24640.50105@anastigmatix.net> Cc: Alvaro Herrera , Tom Lane , PostgreSQL Hackers From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5BD29725.1020603@anastigmatix.net> Date: Fri, 26 Oct 2018 00:25:09 -0400 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: 8bit X-OutGoing-Spam-Status: No, score=-95.0 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/only user confirmed/virtual account not confirmed X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/25/18 23:16, Pavel Stehule wrote: >> XMLTABLE would be the headache. Using the standard name for something >> that ain't the standard function has not left any painless way that the >> standard function could be added. OTOH, it has only been in the wild >> since 10, so renaming it to something else (xpath_table?) will probably >> be more painless if done soon than it ever would be later. >> > I don't share your opinion. XMLTABLE implements subset of standard. More it > is well compatible with Oracle (in this subset). > > If we have library with XPath 2.0 or higher, we can continue with it. The difficulty here is that the expression language required by the standard is XQuery, and an XPath expression (whether 1.0 or 2.0+) can always be parsed as an XQuery expression. (So, /syntactically/, yes, "subset".) For XPath 2.0, that is no problem, because an XPath 2.0 expression and the identically-spelled XQuery expression /mean the same thing/. For XPath 1.0, it is very definitely a problem, because an XPath 1.0 expression and the identically-spelled XQuery expression /do not mean the same thing/. Some of the important semantic differences are in [1]. So, if a future PostgreSQL version has an XMLTABLE function that accepts XQuery, as the standard requires, and existing users upgrade and they have XMLTABLE query expressions written as XPath 1.0, those queries will be accepted and parsed, but they will not mean the same thing. The function will not be able to tell when it is being called with XQuery semantics intended, vs. when it is being called with XPath 1.0 semantics intended. Now, perhaps there is a nicer way than renaming the function. It could work like overloading. Create two trivial domains over text, say xpath1 and xquery, and have two XMLTABLE functions with different first parameter types. Then if you called with the expression '"cat" < "dog"'::xquery you would get the correct result 't', and with '"cat" < "dog"'::xpath1 you would get the (also correct) result 'f'. (It would not be exactly overloading, because of the special sugared syntax known to the parser, but it could look like overloading, and be intuitive to the user.) If you have convenient access to Oracle to check compatibility, could you compare this query? SELECT * FROM XMLTABLE('.' PASSING '' COLUMNS a boolean PATH 'string("cat" < "dog")', b boolean PATH 'string("cat" > "dog")', c boolean PATH 'string(sale/@taxable = false())'); (I suspect in Oracle it would also work without the string() wrappings, but just to make it easy, I think this way it will work in both Oracle and PG—that is, not error, though results may differ.) -Chap [1] https://wiki.postgresql.org/wiki/PostgreSQL_vs_SQL/XML_Standards#Related_to_version_of_XPath