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 1glO3T-0000xF-KJ for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jan 2019 01:07:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1glO3S-0003OH-Ax for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jan 2019 01:07:10 +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 1glO3S-0003KR-2p for pgsql-hackers@lists.postgresql.org; Mon, 21 Jan 2019 01:07:10 +0000 Received: from bay.acenet.us ([173.230.252.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glO3Q-0005mE-92 for pgsql-hackers@lists.postgresql.org; Mon, 21 Jan 2019 01:07:09 +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=l3NX3RmQKTK/H67VAM8azupPV7OY73C6Gh52gYq4DVo=; b=u1cDKCIMHJ42/S50XO72ArJn9U EIVNYv7fexSBHoYcIEKZw2iW2X4vq03JHm03AYIpOiGFi8TdgDFXhOGaicrN8NtJ3wUqGE/Sr2csF vwiuGDQdtQ5xrTRFOJzUipHTbQZwUJ+5Rc1nR4izza76Ir9KmYXSWfxDYk47npIx0oVbA9r7IgYHy PnVqQv+EFkwyW952Ty4xXq6JYPhXhlVN4z0WYgXimF5tnMwvtsFNPAfDY1H8LhewOM4FhnX0kUI9e l0NOZHL4r933ncWYQYyuVtZfp5QBkDq9teADlkrKeUuwj174+M1FmAZHyatOCU1Qpn2aGTbNXdxGV yGIPmlSQ==; Received: from [192.182.57.242] (port=50459) by bay.acenet.us with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1glO3N-00GEQa-Pz; Sun, 20 Jan 2019 20:07:06 -0500 Subject: Re: PostgreSQL vs SQL/XML Standards To: Pavel Stehule References: <5C283168.8060001@anastigmatix.net> <5C291741.9060506@anastigmatix.net> <5C297BB7.9070509@anastigmatix.net> <5C3A7A90.3070207@anastigmatix.net> <5C43FAEB.2070000@anastigmatix.net> <5C4401BE.4080606@anastigmatix.net> <5C449C71.7060903@anastigmatix.net> <5C44B332.6070609@anastigmatix.net> <5C44F26D.5010703@anastigmatix.net> Cc: PostgreSQL Hackers From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5C451B39.90307@anastigmatix.net> Date: Sun, 20 Jan 2019 20:07:05 -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: <5C44F26D.5010703@anastigmatix.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 - lists.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 On 01/20/19 17:13, Chapman Flack wrote: > On 01/20/19 12:48, Pavel Stehule wrote: >> regular Postgres' functions has evaluated all arguments before own >> execution. I think so this note is related much more to expressions used as >> defaults. > > Sure, but again, is there an example, or can one easily be constructed, > that shows the default expressions working in such a way? To make my question more concrete, here is the current regression test query that uses an SQL expression for a default: SELECT xmltable.* FROM xmltest2, xmltable(('/d/r/' || lower(_path) || 'c') PASSING x COLUMNS a int PATH 'x' DEFAULT ascii(_path) - 54); a ---- 11 12 13 14 (4 rows) Here is the same query desugared into a call of the PL/Java "xmltable": SELECT xmltable.* FROM xmltest2, LATERAL (SELECT x AS ".", ascii(_path) - 54 AS "A_DFT") AS p, "xmltable"(('/d/r/' || lower(_path) || 'c'), PASSING => p, COLUMNS => ARRAY[ 'let $a := x return xs:int(if (exists($a)) then $a else $A_DFT)' ] ) AS (a int); a ---- 11 12 13 14 (4 rows) So the PL/Java version works and produces the same results. And yet it certainly is a "regular PostgreSQL function" made with CREATE FUNCTION, no special treatment of arguments, all evaluated before entry in the usual way. So it appears that this example does not depend on any special treatment of the default_expression. Is there an example that can be constructed that would depend on the special treatment (in which case, the PL/Java implementation would be unable to produce the same result)? Regards, -Chap ... the xs:int(...) cast above is needed for now, just because the PL/Java implementation does not yet include the standard's algorithm to find the right cast automatically.