1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

Add support for xmlval IS DOCUMENT expression.

This commit is contained in:
Peter Eisentraut
2007-01-14 13:11:54 +00:00
parent 62c06186f5
commit 2f8f76bcd5
11 changed files with 156 additions and 11 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.16 2007/01/12 21:47:26 petere Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.17 2007/01/14 13:11:54 petere Exp $
*
*-------------------------------------------------------------------------
*/
@ -515,6 +515,50 @@ xmlvalidate(PG_FUNCTION_ARGS)
}
bool
xml_is_document(xmltype *arg)
{
#ifdef USE_LIBXML
bool result;
xmlDocPtr doc = NULL;
MemoryContext ccxt = CurrentMemoryContext;
PG_TRY();
{
doc = xml_parse((text *) arg, true, true);
result = true;
}
PG_CATCH();
{
ErrorData *errdata;
MemoryContext ecxt;
ecxt = MemoryContextSwitchTo(ccxt);
errdata = CopyErrorData();
if (errdata->sqlerrcode == ERRCODE_INVALID_XML_DOCUMENT)
{
FlushErrorState();
result = false;
}
else
{
MemoryContextSwitchTo(ecxt);
PG_RE_THROW();
}
}
PG_END_TRY();
if (doc)
xmlFreeDoc(doc);
return result;
#else /* not USE_LIBXML */
NO_XML_SUPPORT();
return false;
#endif /* not USE_LIBXML */
}
#ifdef USE_LIBXML
/*