Re: Fix XML handling with DOCTYPE
Chapman Flack <chap@anastigmatix.net>
From: Chapman Flack <chap@anastigmatix.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Ryan Lambert <ryan@rustprooflabs.com>, pgsql-hackers@postgresql.org
Date: 2019-03-17T17:11:28Z
Lists: pgsql-hackers
On 03/17/19 11:45, Tom Lane wrote: > Chapman Flack <chap@anastigmatix.net> writes: >> On 03/16/19 17:21, Tom Lane wrote: >>> (1) always try to parse as document. If successful, we're done. >>> (2) otherwise, if allowed by xmloption, try to parse using our > >> What I don't like about that is that (a) the input could be >> arbitrarily long and complex to parse (not that you can't imagine >> a database populated with lots of short little XML snippets, but >> at the same time, a query could quite plausibly deal in yooge ones), >> and (b), step (1) could fail at the last byte of the input, followed >> by total reparsing as (2). > > That doesn't seem particularly likely to me: based on what's been > said here, I'd expect parsing with the wrong expectation to usually > fail near the start of the input. In any case, the other patch > also requires repeat parsing, no? It's just doing that in a different > set of cases. I'll do up a version with the open-coded prescan I proposed last night. Whether parsing with the wrong expectation is likely to fail near the start of the input depends on both the input and the expectation. If your expectation is DOCUMENT and the input is CONTENT, it's possible for the determining difference to be something that follows the first element, and a first element can be (and often is) nearly all of the input. 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. 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. Regards, -Chap
Commits
-
Improve documentation about our XML functionality
- 728c49779ba8 11.6 landed
- 603a28b44973 10.11 landed
-
Improve documentation about our XML functionality.
- 12d46ac392d0 12.0 landed
-
Doc: clarify that REASSIGN OWNED doesn't handle default privileges.
- 50973687f185 9.6.13 cited
- 24df8662e4a4 11.3 cited
-
Suppress Append and MergeAppend plan nodes that have a single child.
- 8edd0e79460b 12.0 cited
-
Accept XML documents when xmloption = content, as required by SQL:2006+.
- 8d1dadb25bb5 12.0 landed
- da45927cef78 9.5.17 landed
- d7cfd5ee4591 9.6.13 landed
- 849f87a1c334 11.3 landed
- 78f84fe0f478 9.4.22 landed
- 754ffcd42006 10.8 landed
-
Ensure xmloption = content while restoring pg_dump output.
- 4870dce37fab 12.0 landed
- 8ba485422933 9.4.22 landed
- 08d8cfe3cfd6 9.5.17 landed
- de922529fe62 10.8 landed
- 7c89f350f109 11.3 landed
- 687acb598308 9.6.13 landed