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 1h5aHe-0004st-FE for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Mar 2019 18:13:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5aHb-0003Az-2d for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Mar 2019 18:13:15 +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 1h5aHa-0003As-RO for pgsql-hackers@lists.postgresql.org; Sun, 17 Mar 2019 18:13:14 +0000 Received: from anastigmatix.net ([68.171.219.55]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5aHY-0002xl-SG for pgsql-hackers@postgresql.org; Sun, 17 Mar 2019 18:13:14 +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=cxWBEu44r3E9NARjAW5i7JpbgGW+hQXMoXzVmblfzvY=; b=TY3KcSCxWU8gMpin/RiVnKRdOT a1sEJqU9hQ+9QE3fHBzmaL9kwHPz/2lt0M6vm7pE5S5zXfatWgUXGT6QLIgwLOg0VlK/38eRB/Hwz U4BCO32/pR3zwGs5wiAMMkmVilLBySXvoRq3VLeNaDCVKUGxFCE9Ek2dNOCMeYsytPKoxm2PqvcC8 m4rdu5o7tx8k0mF9+NVvgf+dyat2n3HXwdN6rygLAWec7WEnd/SGuG96Ge3R04j3rloeUyI3HNfaZ 8aAyoEm/ec+l75RnJBtvBymqgyrXwj2u3k/r82Gw/qKyx1IU3Pa1qKbiQf7RnQaiBVPd06pDzVr51 Pysnf1sA==; Received: from [184.19.63.78] (port=46195) by bay.acenet.us with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1h5aHQ-00FBmX-Cd; Sun, 17 Mar 2019 14:13:10 -0400 Subject: Re: Fix XML handling with DOCTYPE To: Tom Lane References: <5C8D5D16.7090206@anastigmatix.net> <23319.1552769738@sss.pgh.pa.us> <5C8D6681.4070504@anastigmatix.net> <24203.1552771272@sss.pgh.pa.us> <5C8D79AF.7010204@anastigmatix.net> <5146.1552837534@sss.pgh.pa.us> <5C8E7FC0.8040401@anastigmatix.net> <31664.1552842991@sss.pgh.pa.us> Cc: Ryan Lambert , pgsql-hackers@postgresql.org From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5C8E8E2F.9050600@anastigmatix.net> Date: Sun, 17 Mar 2019 14:13:03 -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: <31664.1552842991@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252 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 - 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 03/17/19 13:16, Tom Lane wrote: > Chapman Flack writes: >> What I was doing in the patch is the reverse: parsing with the expectation >> of CONTENT to see if a DTD gets tripped over. It isn't allowed for an >> element to precede a DTD, so that approach can be expected to fail fast >> if the other branch needs to be taken. > > Ah, right. I don't have any problem with trying the CONTENT approach > before the DOCUMENT approach rather than vice-versa. What I was concerned > about was adding a lot of assumptions about exactly how libxml would > report the failure. IMO a maximally-safe patch would just rearrange > things we're already doing without adding new things. > >> But a quick pre-scan for the same thing would have the same property, >> without the libxml dependencies that bother you here. Watch this space. > > Do we need a pre-scan at all? Without it, we double the time to a failure result in every case that should actually fail, as well as in this one corner case that we want to see succeed, and the question you posed earlier about which error message to return becomes thornier. If the query asked for CONTENT, any error result should be one you could get when parsing as CONTENT. If we switch and try parsing as DOCUMENT _because the input is claiming to have the form of a DOCUMENT_, then it's defensible to return errors explaining why it's not a DOCUMENT ... but not in the general case of just throwing DOCUMENT at it any time CONTENT parse fails. Regards, -Chap