Content-Length: 333359 | pFad | http://github.com/tonybelloni/postgres/commit/c59f94e81e56fe24428952f116f3c9555f42cc4f

DF Revert "Delete contrib/xml2's legacy implementation of xml_is_well_fo… · tonybelloni/postgres@c59f94e · GitHub
Skip to content

Commit c59f94e

Browse files
committed
Revert "Delete contrib/xml2's legacy implementation of xml_is_well_formed()."
This partly reverts commit 2054071. Since we've given up on adding PGDLLEXPORT markers to PG_FUNCTION_INFO_V1, there's no need to remove the legacy compatibility function. I kept the documentation changes, though, as they seem appropriate anyway.
1 parent 33cb96b commit c59f94e

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

contrib/xml2/xpath.c

+45
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,51 @@ pgxml_parser_init(PgXmlStrictness strictness)
8181
}
8282

8383

84+
/*
85+
* Returns true if document is well-formed
86+
*
87+
* Note: this has been superseded by a core function. We still have to
88+
* have it in the contrib module so that existing SQL-level references
89+
* to the function won't fail; but in normal usage with up-to-date SQL
90+
* definitions for the contrib module, this won't be called.
91+
*/
92+
93+
PG_FUNCTION_INFO_V1(xml_is_well_formed);
94+
95+
Datum
96+
xml_is_well_formed(PG_FUNCTION_ARGS)
97+
{
98+
text *t = PG_GETARG_TEXT_P(0); /* document buffer */
99+
bool result = false;
100+
int32 docsize = VARSIZE(t) - VARHDRSZ;
101+
xmlDocPtr doctree;
102+
PgXmlErrorContext *xmlerrcxt;
103+
104+
xmlerrcxt = pgxml_parser_init(PG_XML_STRICTNESS_LEGACY);
105+
106+
PG_TRY();
107+
{
108+
doctree = xmlParseMemory((char *) VARDATA(t), docsize);
109+
110+
result = (doctree != NULL);
111+
112+
if (doctree != NULL)
113+
xmlFreeDoc(doctree);
114+
}
115+
PG_CATCH();
116+
{
117+
pg_xml_done(xmlerrcxt, true);
118+
119+
PG_RE_THROW();
120+
}
121+
PG_END_TRY();
122+
123+
pg_xml_done(xmlerrcxt, false);
124+
125+
PG_RETURN_BOOL(result);
126+
}
127+
128+
84129
/* Encodes special characters (<, >, &, " and \r) as XML entities */
85130

86131
PG_FUNCTION_INFO_V1(xml_encode_special_chars);

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tonybelloni/postgres/commit/c59f94e81e56fe24428952f116f3c9555f42cc4f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy