#include "fmgr.h"
#include "nodes/execnodes.h"
#include "nodes/primnodes.h"
Go to the source code of this file.
#define DatumGetXmlP | ( | X | ) | ((xmltype *) PG_DETOAST_DATUM(X)) |
Definition at line 49 of file xml.h.
Referenced by ExecEvalXml(), and xmlconcat().
#define PG_GETARG_XML_P | ( | n | ) | DatumGetXmlP(PG_GETARG_DATUM(n)) |
Definition at line 52 of file xml.h.
Referenced by xml_out(), xml_send(), xmlconcat2(), xmlexists(), xmltotext(), xpath(), and xpath_exists().
#define PG_RETURN_XML_P | ( | x | ) | PG_RETURN_POINTER(x) |
Definition at line 53 of file xml.h.
Referenced by cursor_to_xml(), cursor_to_xmlschema(), database_to_xml(), database_to_xml_and_xmlschema(), database_to_xmlschema(), query_to_xml(), query_to_xml_and_xmlschema(), query_to_xmlschema(), schema_to_xml(), schema_to_xml_and_xmlschema(), schema_to_xmlschema(), table_to_xml(), table_to_xml_and_xmlschema(), table_to_xmlschema(), texttoxml(), xml_in(), xml_recv(), xmlcomment(), and xmlconcat2().
typedef struct PgXmlErrorContext PgXmlErrorContext |
enum PgXmlStrictness |
Definition at line 38 of file xml.h.
{ PG_XML_STRICTNESS_LEGACY, /* ignore errors unless function result * indicates error condition */ PG_XML_STRICTNESS_WELLFORMED, /* ignore non-parser messages */ PG_XML_STRICTNESS_ALL /* report all notices/warnings/errors */ } PgXmlStrictness;
enum XmlBinaryType |
Definition at line 32 of file xml.h.
{ XMLBINARY_BASE64, XMLBINARY_HEX } XmlBinaryType;
enum XmlStandaloneType |
Definition at line 24 of file xml.h.
{ XML_STANDALONE_YES, XML_STANDALONE_NO, XML_STANDALONE_NO_VALUE, XML_STANDALONE_OMITTED } XmlStandaloneType;
Datum cursor_to_xml | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2375 of file xml.c.
References ereport, errcode(), errmsg(), ERROR, i, initStringInfo(), NULL, PG_GETARG_BOOL, PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, SPI_connect(), SPI_cursor_fetch(), SPI_cursor_find(), SPI_finish(), SPI_processed, SPI_sql_row_to_xmlelement(), stringinfo_to_xmltype(), and text_to_cstring().
{ char *name = text_to_cstring(PG_GETARG_TEXT_PP(0)); int32 count = PG_GETARG_INT32(1); bool nulls = PG_GETARG_BOOL(2); bool tableforest = PG_GETARG_BOOL(3); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(4)); StringInfoData result; Portal portal; int i; initStringInfo(&result); SPI_connect(); portal = SPI_cursor_find(name); if (portal == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_CURSOR), errmsg("cursor \"%s\" does not exist", name))); SPI_cursor_fetch(portal, true, count); for (i = 0; i < SPI_processed; i++) SPI_sql_row_to_xmlelement(i, &result, NULL, nulls, tableforest, targetns, true); SPI_finish(); PG_RETURN_XML_P(stringinfo_to_xmltype(&result)); }
Datum cursor_to_xmlschema | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2547 of file xml.c.
References _SPI_strdup(), cstring_to_xmltype(), ereport, errcode(), errmsg(), ERROR, InvalidOid, map_sql_table_to_xmlschema(), NULL, PG_GETARG_BOOL, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, SPI_connect(), SPI_cursor_find(), SPI_finish(), text_to_cstring(), and PortalData::tupDesc.
{ char *name = text_to_cstring(PG_GETARG_TEXT_PP(0)); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); const char *xmlschema; Portal portal; SPI_connect(); portal = SPI_cursor_find(name); if (portal == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_CURSOR), errmsg("cursor \"%s\" does not exist", name))); xmlschema = _SPI_strdup(map_sql_table_to_xmlschema(portal->tupDesc, InvalidOid, nulls, tableforest, targetns)); SPI_finish(); PG_RETURN_XML_P(cstring_to_xmltype(xmlschema)); }
Datum database_to_xml | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2854 of file xml.c.
References database_to_xml_internal(), NULL, PG_GETARG_BOOL, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, stringinfo_to_xmltype(), and text_to_cstring().
{ bool nulls = PG_GETARG_BOOL(0); bool tableforest = PG_GETARG_BOOL(1); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(2)); PG_RETURN_XML_P(stringinfo_to_xmltype(database_to_xml_internal(NULL, nulls, tableforest, targetns))); }
Datum database_to_xml_and_xmlschema | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2921 of file xml.c.
References StringInfoData::data, database_to_xml_internal(), database_to_xmlschema_internal(), PG_GETARG_BOOL, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, stringinfo_to_xmltype(), and text_to_cstring().
{ bool nulls = PG_GETARG_BOOL(0); bool tableforest = PG_GETARG_BOOL(1); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(2)); StringInfo xmlschema; xmlschema = database_to_xmlschema_internal(nulls, tableforest, targetns); PG_RETURN_XML_P(stringinfo_to_xmltype(database_to_xml_internal(xmlschema->data, nulls, tableforest, targetns))); }
Datum database_to_xmlschema | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2909 of file xml.c.
References database_to_xmlschema_internal(), PG_GETARG_BOOL, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, stringinfo_to_xmltype(), and text_to_cstring().
{ bool nulls = PG_GETARG_BOOL(0); bool tableforest = PG_GETARG_BOOL(1); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(2)); PG_RETURN_XML_P(stringinfo_to_xmltype(database_to_xmlschema_internal(nulls, tableforest, targetns))); }
char* escape_xml | ( | const char * | str | ) |
Definition at line 2175 of file xml.c.
References appendStringInfoCharMacro, appendStringInfoString(), StringInfoData::data, and initStringInfo().
Referenced by ExplainProperty(), ExplainPropertyList(), and map_sql_value_to_xml_value().
{ StringInfoData buf; const char *p; initStringInfo(&buf); for (p = str; *p; p++) { switch (*p) { case '&': appendStringInfoString(&buf, "&"); break; case '<': appendStringInfoString(&buf, "<"); break; case '>': appendStringInfoString(&buf, ">"); break; case '\r': appendStringInfoString(&buf, "
"); break; default: appendStringInfoCharMacro(&buf, *p); break; } } return buf.data; }
Definition at line 1836 of file xml.c.
References appendBinaryStringInfo(), appendStringInfo(), Assert, StringInfoData::data, initStringInfo(), NO_XML_SUPPORT, pg_mblen(), and pg_strncasecmp().
Referenced by database_to_xml_internal(), map_multipart_sql_identifier_to_xml_name(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), query_to_xml_internal(), schema_to_xml_internal(), SPI_sql_row_to_xmlelement(), and transformXmlExpr().
{ #ifdef USE_LIBXML StringInfoData buf; char *p; /* * SQL/XML doesn't make use of this case anywhere, so it's probably a * mistake. */ Assert(fully_escaped || !escape_period); initStringInfo(&buf); for (p = ident; *p; p += pg_mblen(p)) { if (*p == ':' && (p == ident || fully_escaped)) appendStringInfo(&buf, "_x003A_"); else if (*p == '_' && *(p + 1) == 'x') appendStringInfo(&buf, "_x005F_"); else if (fully_escaped && p == ident && pg_strncasecmp(p, "xml", 3) == 0) { if (*p == 'x') appendStringInfo(&buf, "_x0078_"); else appendStringInfo(&buf, "_x0058_"); } else if (escape_period && *p == '.') appendStringInfo(&buf, "_x002E_"); else { pg_wchar u = sqlchar_to_unicode(p); if ((p == ident) ? !is_valid_xml_namefirst(u) : !is_valid_xml_namechar(u)) appendStringInfo(&buf, "_x%04X_", (unsigned int) u); else appendBinaryStringInfo(&buf, p, pg_mblen(p)); } } return buf.data; #else /* not USE_LIBXML */ NO_XML_SUPPORT(); return NULL; #endif /* not USE_LIBXML */ }
Definition at line 1956 of file xml.c.
References appendStringInfoString(), ARR_ELEMTYPE, BOOLOID, BYTEAOID, StringInfoData::data, DATE_NOT_FINITE, DATEOID, DatumGetArrayTypeP, DatumGetBool, DatumGetByteaPP, DatumGetDateADT, DatumGetTimestamp, deconstruct_array(), EncodeDateOnly(), EncodeDateTime(), ereport, errcode(), errdetail(), errmsg(), ERROR, escape_xml(), get_typlenbyvalalign(), getBaseType(), getTypeOutputInfo(), i, initStringInfo(), j2date(), map_sql_value_to_xml_value(), MAXDATELEN, NULL, OidOutputFunctionCall(), pfree(), PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pg_xml_done(), pg_xml_init(), PG_XML_STRICTNESS_ALL, POSTGRES_EPOCH_JDATE, pstrdup(), timestamp2tm(), TIMESTAMP_NOT_FINITE, TIMESTAMPOID, TIMESTAMPTZOID, pg_tm::tm_mday, pg_tm::tm_mon, pg_tm::tm_year, type_is_array_domain, USE_XSD_DATES, VARDATA_ANY, VARSIZE_ANY_EXHDR, xml_ereport(), xmlbinary, XMLBINARY_BASE64, and XMLOID.
Referenced by ExecEvalXml(), map_sql_value_to_xml_value(), SPI_sql_row_to_xmlelement(), and xmlelement().
{ if (type_is_array_domain(type)) { ArrayType *array; Oid elmtype; int16 elmlen; bool elmbyval; char elmalign; int num_elems; Datum *elem_values; bool *elem_nulls; StringInfoData buf; int i; array = DatumGetArrayTypeP(value); elmtype = ARR_ELEMTYPE(array); get_typlenbyvalalign(elmtype, &elmlen, &elmbyval, &elmalign); deconstruct_array(array, elmtype, elmlen, elmbyval, elmalign, &elem_values, &elem_nulls, &num_elems); initStringInfo(&buf); for (i = 0; i < num_elems; i++) { if (elem_nulls[i]) continue; appendStringInfoString(&buf, "<element>"); appendStringInfoString(&buf, map_sql_value_to_xml_value(elem_values[i], elmtype, true)); appendStringInfoString(&buf, "</element>"); } pfree(elem_values); pfree(elem_nulls); return buf.data; } else { Oid typeOut; bool isvarlena; char *str; /* * Flatten domains; the special-case treatments below should apply * to, eg, domains over boolean not just boolean. */ type = getBaseType(type); /* * Special XSD formatting for some data types */ switch (type) { case BOOLOID: if (DatumGetBool(value)) return "true"; else return "false"; case DATEOID: { DateADT date; struct pg_tm tm; char buf[MAXDATELEN + 1]; date = DatumGetDateADT(value); /* XSD doesn't support infinite values */ if (DATE_NOT_FINITE(date)) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("date out of range"), errdetail("XML does not support infinite date values."))); j2date(date + POSTGRES_EPOCH_JDATE, &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday)); EncodeDateOnly(&tm, USE_XSD_DATES, buf); return pstrdup(buf); } case TIMESTAMPOID: { Timestamp timestamp; struct pg_tm tm; fsec_t fsec; char buf[MAXDATELEN + 1]; timestamp = DatumGetTimestamp(value); /* XSD doesn't support infinite values */ if (TIMESTAMP_NOT_FINITE(timestamp)) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("timestamp out of range"), errdetail("XML does not support infinite timestamp values."))); else if (timestamp2tm(timestamp, NULL, &tm, &fsec, NULL, NULL) == 0) EncodeDateTime(&tm, fsec, false, 0, NULL, USE_XSD_DATES, buf); else ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("timestamp out of range"))); return pstrdup(buf); } case TIMESTAMPTZOID: { TimestampTz timestamp; struct pg_tm tm; int tz; fsec_t fsec; const char *tzn = NULL; char buf[MAXDATELEN + 1]; timestamp = DatumGetTimestamp(value); /* XSD doesn't support infinite values */ if (TIMESTAMP_NOT_FINITE(timestamp)) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("timestamp out of range"), errdetail("XML does not support infinite timestamp values."))); else if (timestamp2tm(timestamp, &tz, &tm, &fsec, &tzn, NULL) == 0) EncodeDateTime(&tm, fsec, true, tz, tzn, USE_XSD_DATES, buf); else ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("timestamp out of range"))); return pstrdup(buf); } #ifdef USE_LIBXML case BYTEAOID: { bytea *bstr = DatumGetByteaPP(value); PgXmlErrorContext *xmlerrcxt; volatile xmlBufferPtr buf = NULL; volatile xmlTextWriterPtr writer = NULL; char *result; xmlerrcxt = pg_xml_init(PG_XML_STRICTNESS_ALL); PG_TRY(); { buf = xmlBufferCreate(); if (buf == NULL || xmlerrcxt->err_occurred) xml_ereport(xmlerrcxt, ERROR, ERRCODE_OUT_OF_MEMORY, "could not allocate xmlBuffer"); writer = xmlNewTextWriterMemory(buf, 0); if (writer == NULL || xmlerrcxt->err_occurred) xml_ereport(xmlerrcxt, ERROR, ERRCODE_OUT_OF_MEMORY, "could not allocate xmlTextWriter"); if (xmlbinary == XMLBINARY_BASE64) xmlTextWriterWriteBase64(writer, VARDATA_ANY(bstr), 0, VARSIZE_ANY_EXHDR(bstr)); else xmlTextWriterWriteBinHex(writer, VARDATA_ANY(bstr), 0, VARSIZE_ANY_EXHDR(bstr)); /* we MUST do this now to flush data out to the buffer */ xmlFreeTextWriter(writer); writer = NULL; result = pstrdup((const char *) xmlBufferContent(buf)); } PG_CATCH(); { if (writer) xmlFreeTextWriter(writer); if (buf) xmlBufferFree(buf); pg_xml_done(xmlerrcxt, true); PG_RE_THROW(); } PG_END_TRY(); xmlBufferFree(buf); pg_xml_done(xmlerrcxt, false); return result; } #endif /* USE_LIBXML */ } /* * otherwise, just use the type's native text representation */ getTypeOutputInfo(type, &typeOut, &isvarlena); str = OidOutputFunctionCall(typeOut, value); /* ... exactly as-is for XML, and when escaping is not wanted */ if (type == XMLOID || !xml_escape_strings) return str; /* otherwise, translate special characters as needed */ return escape_xml(str); } }
char* map_xml_name_to_sql_identifier | ( | char * | name | ) |
Definition at line 1916 of file xml.c.
References appendBinaryStringInfo(), appendStringInfoString(), StringInfoData::data, initStringInfo(), pg_mblen(), and unicode_to_sqlchar().
Referenced by get_rule_expr().
{ StringInfoData buf; char *p; initStringInfo(&buf); for (p = name; *p; p += pg_mblen(p)) { if (*p == '_' && *(p + 1) == 'x' && isxdigit((unsigned char) *(p + 2)) && isxdigit((unsigned char) *(p + 3)) && isxdigit((unsigned char) *(p + 4)) && isxdigit((unsigned char) *(p + 5)) && *(p + 6) == '_') { unsigned int u; sscanf(p + 2, "%X", &u); appendStringInfoString(&buf, unicode_to_sqlchar(u)); p += 6; } else appendBinaryStringInfo(&buf, p, pg_mblen(p)); } return buf.data; }
void pg_xml_done | ( | PgXmlErrorContext * | errcxt, | |
bool | isError | |||
) |
Referenced by map_sql_value_to_xml_value(), pgxml_xpath(), xml_is_well_formed(), xmlelement(), xpath_table(), and xslt_process().
bool pg_xml_error_occurred | ( | PgXmlErrorContext * | errcxt | ) |
PgXmlErrorContext* pg_xml_init | ( | PgXmlStrictness | strictness | ) |
Referenced by map_sql_value_to_xml_value(), pgxml_parser_init(), and xmlelement().
void pg_xml_init_library | ( | void | ) |
Datum query_to_xml | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2361 of file xml.c.
References NULL, PG_GETARG_BOOL, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, query_to_xml_internal(), stringinfo_to_xmltype(), and text_to_cstring().
{ char *query = text_to_cstring(PG_GETARG_TEXT_PP(0)); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); PG_RETURN_XML_P(stringinfo_to_xmltype(query_to_xml_internal(query, NULL, NULL, nulls, tableforest, targetns, true))); }
Datum query_to_xml_and_xmlschema | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2594 of file xml.c.
References _SPI_strdup(), elog, ERROR, InvalidOid, map_sql_table_to_xmlschema(), NULL, PG_GETARG_BOOL, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, query_to_xml_internal(), SPI_connect(), SPI_cursor_close(), SPI_cursor_open(), SPI_finish(), SPI_prepare(), stringinfo_to_xmltype(), text_to_cstring(), and PortalData::tupDesc.
{ char *query = text_to_cstring(PG_GETARG_TEXT_PP(0)); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); const char *xmlschema; SPIPlanPtr plan; Portal portal; SPI_connect(); if ((plan = SPI_prepare(query, 0, NULL)) == NULL) elog(ERROR, "SPI_prepare(\"%s\") failed", query); if ((portal = SPI_cursor_open(NULL, plan, NULL, NULL, true)) == NULL) elog(ERROR, "SPI_cursor_open(\"%s\") failed", query); xmlschema = _SPI_strdup(map_sql_table_to_xmlschema(portal->tupDesc, InvalidOid, nulls, tableforest, targetns)); SPI_cursor_close(portal); SPI_finish(); PG_RETURN_XML_P(stringinfo_to_xmltype(query_to_xml_internal(query, NULL, xmlschema, nulls, tableforest, targetns, true))); }
Datum query_to_xmlschema | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2518 of file xml.c.
References _SPI_strdup(), cstring_to_xmltype(), elog, ERROR, InvalidOid, map_sql_table_to_xmlschema(), NULL, PG_GETARG_BOOL, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, SPI_connect(), SPI_cursor_close(), SPI_cursor_open(), SPI_finish(), SPI_prepare(), text_to_cstring(), and PortalData::tupDesc.
{ char *query = text_to_cstring(PG_GETARG_TEXT_PP(0)); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); const char *result; SPIPlanPtr plan; Portal portal; SPI_connect(); if ((plan = SPI_prepare(query, 0, NULL)) == NULL) elog(ERROR, "SPI_prepare(\"%s\") failed", query); if ((portal = SPI_cursor_open(NULL, plan, NULL, NULL, true)) == NULL) elog(ERROR, "SPI_cursor_open(\"%s\") failed", query); result = _SPI_strdup(map_sql_table_to_xmlschema(portal->tupDesc, InvalidOid, nulls, tableforest, targetns)); SPI_cursor_close(portal); SPI_finish(); PG_RETURN_XML_P(cstring_to_xmltype(result)); }
Datum schema_to_xml | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2676 of file xml.c.
References LookupExplicitNamespace(), NameStr, NULL, PG_GETARG_BOOL, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, schema_to_xml_internal(), stringinfo_to_xmltype(), and text_to_cstring().
{ Name name = PG_GETARG_NAME(0); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); char *schemaname; Oid nspid; schemaname = NameStr(*name); nspid = LookupExplicitNamespace(schemaname, false); PG_RETURN_XML_P(stringinfo_to_xmltype(schema_to_xml_internal(nspid, NULL, nulls, tableforest, targetns, true))); }
Datum schema_to_xml_and_xmlschema | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2780 of file xml.c.
References StringInfoData::data, LookupExplicitNamespace(), NameStr, PG_GETARG_BOOL, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, schema_to_xml_internal(), schema_to_xmlschema_internal(), stringinfo_to_xmltype(), and text_to_cstring().
{ Name name = PG_GETARG_NAME(0); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); char *schemaname; Oid nspid; StringInfo xmlschema; schemaname = NameStr(*name); nspid = LookupExplicitNamespace(schemaname, false); xmlschema = schema_to_xmlschema_internal(schemaname, nulls, tableforest, targetns); PG_RETURN_XML_P(stringinfo_to_xmltype(schema_to_xml_internal(nspid, xmlschema->data, nulls, tableforest, targetns, true))); }
Datum schema_to_xmlschema | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2767 of file xml.c.
References NameStr, PG_GETARG_BOOL, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, schema_to_xmlschema_internal(), stringinfo_to_xmltype(), and text_to_cstring().
{ Name name = PG_GETARG_NAME(0); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); PG_RETURN_XML_P(stringinfo_to_xmltype(schema_to_xmlschema_internal(NameStr(*name), nulls, tableforest, targetns))); }
Datum table_to_xml | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2347 of file xml.c.
References NULL, PG_GETARG_BOOL, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, stringinfo_to_xmltype(), table_to_xml_internal(), and text_to_cstring().
{ Oid relid = PG_GETARG_OID(0); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); PG_RETURN_XML_P(stringinfo_to_xmltype(table_to_xml_internal(relid, NULL, nulls, tableforest, targetns, true))); }
Datum table_to_xml_and_xmlschema | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2573 of file xml.c.
References AccessShareLock, heap_close, heap_open(), map_sql_table_to_xmlschema(), NoLock, PG_GETARG_BOOL, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, RelationData::rd_att, stringinfo_to_xmltype(), table_to_xml_internal(), and text_to_cstring().
{ Oid relid = PG_GETARG_OID(0); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); Relation rel; const char *xmlschema; rel = heap_open(relid, AccessShareLock); xmlschema = map_sql_table_to_xmlschema(rel->rd_att, relid, nulls, tableforest, targetns); heap_close(rel, NoLock); PG_RETURN_XML_P(stringinfo_to_xmltype(table_to_xml_internal(relid, xmlschema, nulls, tableforest, targetns, true))); }
Datum table_to_xmlschema | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2499 of file xml.c.
References AccessShareLock, cstring_to_xmltype(), heap_close, heap_open(), map_sql_table_to_xmlschema(), NoLock, PG_GETARG_BOOL, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_XML_P, RelationData::rd_att, and text_to_cstring().
{ Oid relid = PG_GETARG_OID(0); bool nulls = PG_GETARG_BOOL(1); bool tableforest = PG_GETARG_BOOL(2); const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3)); const char *result; Relation rel; rel = heap_open(relid, AccessShareLock); result = map_sql_table_to_xmlschema(rel->rd_att, relid, nulls, tableforest, targetns); heap_close(rel, NoLock); PG_RETURN_XML_P(cstring_to_xmltype(result)); }
Datum texttoxml | ( | PG_FUNCTION_ARGS | ) |
Definition at line 547 of file xml.c.
References PG_GETARG_TEXT_P, PG_RETURN_XML_P, xmloption, and xmlparse().
{ text *data = PG_GETARG_TEXT_P(0); PG_RETURN_XML_P(xmlparse(data, xmloption, true)); }
void xml_ereport | ( | PgXmlErrorContext * | errcxt, | |
int | level, | |||
int | sqlcode, | |||
const char * | msg | |||
) |
Referenced by map_sql_value_to_xml_value(), pgxml_xpath(), xmlelement(), xpath_table(), and xslt_process().
Datum xml_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 206 of file xml.c.
References cstring_to_text(), GetDatabaseEncoding(), NO_XML_SUPPORT, PG_GETARG_CSTRING, PG_RETURN_XML_P, and xmloption.
{ #ifdef USE_LIBXML char *s = PG_GETARG_CSTRING(0); xmltype *vardata; xmlDocPtr doc; vardata = (xmltype *) cstring_to_text(s); /* * Parse the data to check if it is well-formed XML data. Assume that * ERROR occurred if parsing failed. */ doc = xml_parse(vardata, xmloption, true, GetDatabaseEncoding()); xmlFreeDoc(doc); PG_RETURN_XML_P(vardata); #else NO_XML_SUPPORT(); return 0; #endif }
Definition at line 839 of file xml.c.
References CopyErrorData(), CurrentMemoryContext, FlushErrorState(), GetDatabaseEncoding(), MemoryContextSwitchTo(), NO_XML_SUPPORT, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, ErrorData::sqlerrcode, and XMLOPTION_DOCUMENT.
Referenced by ExecEvalXml(), and xmltotext_with_xmloption().
{ #ifdef USE_LIBXML bool result; volatile xmlDocPtr doc = NULL; MemoryContext ccxt = CurrentMemoryContext; /* We want to catch ereport(INVALID_XML_DOCUMENT) and return false */ PG_TRY(); { doc = xml_parse((text *) arg, XMLOPTION_DOCUMENT, true, GetDatabaseEncoding()); 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 */ }
Datum xml_is_well_formed | ( | PG_FUNCTION_ARGS | ) |
Definition at line 108 of file xpath.c.
References NO_XML_SUPPORT, NULL, PG_CATCH, PG_END_TRY, PG_GETARG_TEXT_P, PG_RE_THROW, PG_RETURN_BOOL, PG_TRY, pg_xml_done(), PG_XML_STRICTNESS_LEGACY, pgxml_parser_init(), VARDATA, VARSIZE, and xmloption.
{ text *t = PG_GETARG_TEXT_P(0); /* document buffer */ bool result = false; int32 docsize = VARSIZE(t) - VARHDRSZ; xmlDocPtr doctree; PgXmlErrorContext *xmlerrcxt; xmlerrcxt = pgxml_parser_init(PG_XML_STRICTNESS_LEGACY); PG_TRY(); { doctree = xmlParseMemory((char *) VARDATA(t), docsize); result = (doctree != NULL); if (doctree != NULL) xmlFreeDoc(doctree); } PG_CATCH(); { pg_xml_done(xmlerrcxt, true); PG_RE_THROW(); } PG_END_TRY(); pg_xml_done(xmlerrcxt, false); PG_RETURN_BOOL(result); }
Datum xml_is_well_formed_content | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4062 of file xml.c.
References NO_XML_SUPPORT, PG_GETARG_TEXT_P, PG_RETURN_BOOL, and XMLOPTION_CONTENT.
{ #ifdef USE_LIBXML text *data = PG_GETARG_TEXT_P(0); PG_RETURN_BOOL(wellformed_xml(data, XMLOPTION_CONTENT)); #else NO_XML_SUPPORT(); return 0; #endif /* not USE_LIBXML */ }
Datum xml_is_well_formed_document | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4049 of file xml.c.
References NO_XML_SUPPORT, PG_GETARG_TEXT_P, PG_RETURN_BOOL, and XMLOPTION_DOCUMENT.
{ #ifdef USE_LIBXML text *data = PG_GETARG_TEXT_P(0); PG_RETURN_BOOL(wellformed_xml(data, XMLOPTION_DOCUMENT)); #else NO_XML_SUPPORT(); return 0; #endif /* not USE_LIBXML */ }
Datum xml_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 284 of file xml.c.
References PG_GETARG_XML_P, PG_RETURN_CSTRING, and xml_out_internal().
{ xmltype *x = PG_GETARG_XML_P(0); /* * xml_out removes the encoding property in all cases. This is because we * cannot control from here whether the datum will be converted to a * different client encoding, so we'd do more harm than good by including * it. */ PG_RETURN_CSTRING(xml_out_internal(x, 0)); }
Datum xml_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 299 of file xml.c.
References buf, cstring_to_text(), StringInfoData::cursor, encoding, GetDatabaseEncoding(), StringInfoData::len, NO_XML_SUPPORT, NULL, palloc(), pfree(), pg_do_encoding_conversion(), PG_GETARG_POINTER, PG_RETURN_XML_P, pq_getmsgbytes(), SET_VARSIZE, VARDATA, VARHDRSZ, and xmloption.
{ #ifdef USE_LIBXML StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); xmltype *result; char *str; char *newstr; int nbytes; xmlDocPtr doc; xmlChar *encodingStr = NULL; int encoding; /* * Read the data in raw format. We don't know yet what the encoding is, as * that information is embedded in the xml declaration; so we have to * parse that before converting to server encoding. */ nbytes = buf->len - buf->cursor; str = (char *) pq_getmsgbytes(buf, nbytes); /* * We need a null-terminated string to pass to parse_xml_decl(). Rather * than make a separate copy, make the temporary result one byte bigger * than it needs to be. */ result = palloc(nbytes + 1 + VARHDRSZ); SET_VARSIZE(result, nbytes + VARHDRSZ); memcpy(VARDATA(result), str, nbytes); str = VARDATA(result); str[nbytes] = '\0'; parse_xml_decl((const xmlChar *) str, NULL, NULL, &encodingStr, NULL); /* * If encoding wasn't explicitly specified in the XML header, treat it as * UTF-8, as that's the default in XML. This is different from xml_in(), * where the input has to go through the normal client to server encoding * conversion. */ encoding = encodingStr ? xmlChar_to_encoding(encodingStr) : PG_UTF8; /* * Parse the data to check if it is well-formed XML data. Assume that * xml_parse will throw ERROR if not. */ doc = xml_parse(result, xmloption, true, encoding); xmlFreeDoc(doc); /* Now that we know what we're dealing with, convert to server encoding */ newstr = (char *) pg_do_encoding_conversion((unsigned char *) str, nbytes, encoding, GetDatabaseEncoding()); if (newstr != str) { pfree(result); result = (xmltype *) cstring_to_text(newstr); pfree(newstr); } PG_RETURN_XML_P(result); #else NO_XML_SUPPORT(); return 0; #endif }
Datum xml_send | ( | PG_FUNCTION_ARGS | ) |
Definition at line 369 of file xml.c.
References buf, pfree(), pg_get_client_encoding(), PG_GETARG_XML_P, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), pq_sendtext(), and xml_out_internal().
{ xmltype *x = PG_GETARG_XML_P(0); char *outval; StringInfoData buf; /* * xml_out_internal doesn't convert the encoding, it just prints the right * declaration. pq_sendtext will do the conversion. */ outval = xml_out_internal(x, pg_get_client_encoding()); pq_begintypsend(&buf); pq_sendtext(&buf, outval, strlen(outval)); pfree(outval); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); }
Datum xmlcomment | ( | PG_FUNCTION_ARGS | ) |
Definition at line 422 of file xml.c.
References appendStringInfo(), appendStringInfoText(), arg, ereport, errcode(), errmsg(), ERROR, i, initStringInfo(), NO_XML_SUPPORT, PG_GETARG_TEXT_P, PG_RETURN_XML_P, stringinfo_to_xmltype(), VARDATA, and VARSIZE.
{ #ifdef USE_LIBXML text *arg = PG_GETARG_TEXT_P(0); char *argdata = VARDATA(arg); int len = VARSIZE(arg) - VARHDRSZ; StringInfoData buf; int i; /* check for "--" in string or "-" at the end */ for (i = 1; i < len; i++) { if (argdata[i] == '-' && argdata[i - 1] == '-') ereport(ERROR, (errcode(ERRCODE_INVALID_XML_COMMENT), errmsg("invalid XML comment"))); } if (len > 0 && argdata[len - 1] == '-') ereport(ERROR, (errcode(ERRCODE_INVALID_XML_COMMENT), errmsg("invalid XML comment"))); initStringInfo(&buf); appendStringInfo(&buf, "<!--"); appendStringInfoText(&buf, arg); appendStringInfo(&buf, "-->"); PG_RETURN_XML_P(stringinfo_to_xmltype(&buf)); #else NO_XML_SUPPORT(); return 0; #endif }
Definition at line 463 of file xml.c.
References appendStringInfoString(), StringInfoData::data, DatumGetXmlP, initStringInfo(), lfirst, NO_XML_SUPPORT, NULL, pfree(), PointerGetDatum, stringinfo_to_xmltype(), text_to_cstring(), and VARSIZE.
Referenced by ExecEvalXml(), and xmlconcat2().
{ #ifdef USE_LIBXML int global_standalone = 1; xmlChar *global_version = NULL; bool global_version_no_value = false; StringInfoData buf; ListCell *v; initStringInfo(&buf); foreach(v, args) { xmltype *x = DatumGetXmlP(PointerGetDatum(lfirst(v))); size_t len; xmlChar *version; int standalone; char *str; len = VARSIZE(x) - VARHDRSZ; str = text_to_cstring((text *) x); parse_xml_decl((xmlChar *) str, &len, &version, NULL, &standalone); if (standalone == 0 && global_standalone == 1) global_standalone = 0; if (standalone < 0) global_standalone = -1; if (!version) global_version_no_value = true; else if (!global_version) global_version = version; else if (xmlStrcmp(version, global_version) != 0) global_version_no_value = true; appendStringInfoString(&buf, str + len); pfree(str); } if (!global_version_no_value || global_standalone >= 0) { StringInfoData buf2; initStringInfo(&buf2); print_xml_decl(&buf2, (!global_version_no_value) ? global_version : NULL, 0, global_standalone); appendStringInfoString(&buf2, buf.data); buf = buf2; } return stringinfo_to_xmltype(&buf); #else NO_XML_SUPPORT(); return NULL; #endif }
Datum xmlconcat2 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 529 of file xml.c.
References list_make2, PG_ARGISNULL, PG_GETARG_XML_P, PG_RETURN_NULL, PG_RETURN_XML_P, and xmlconcat().
{ if (PG_ARGISNULL(0)) { if (PG_ARGISNULL(1)) PG_RETURN_NULL(); else PG_RETURN_XML_P(PG_GETARG_XML_P(1)); } else if (PG_ARGISNULL(1)) PG_RETURN_XML_P(PG_GETARG_XML_P(0)); else PG_RETURN_XML_P(xmlconcat(list_make2(PG_GETARG_XML_P(0), PG_GETARG_XML_P(1)))); }
xmltype* xmlelement | ( | XmlExprState * | xmlExpr, | |
ExprContext * | econtext | |||
) |
Definition at line 579 of file xml.c.
References arg, XmlExpr::arg_names, XmlExprState::args, ERROR, ExecEvalExpr, ExprState::expr, exprType(), forboth, i, lappend(), lfirst, map_sql_value_to_xml_value(), XmlExpr::name, XmlExprState::named_args, NIL, NO_XML_SUPPORT, NULL, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pg_xml_done(), pg_xml_init(), PG_XML_STRICTNESS_ALL, strVal, value, xml_ereport(), and XmlExprState::xprstate.
Referenced by ExecEvalXml().
{ #ifdef USE_LIBXML XmlExpr *xexpr = (XmlExpr *) xmlExpr->xprstate.expr; xmltype *result; List *named_arg_strings; List *arg_strings; int i; ListCell *arg; ListCell *narg; PgXmlErrorContext *xmlerrcxt; volatile xmlBufferPtr buf = NULL; volatile xmlTextWriterPtr writer = NULL; /* * We first evaluate all the arguments, then start up libxml and create * the result. This avoids issues if one of the arguments involves a call * to some other function or subsystem that wants to use libxml on its own * terms. */ named_arg_strings = NIL; i = 0; foreach(arg, xmlExpr->named_args) { ExprState *e = (ExprState *) lfirst(arg); Datum value; bool isnull; char *str; value = ExecEvalExpr(e, econtext, &isnull, NULL); if (isnull) str = NULL; else str = map_sql_value_to_xml_value(value, exprType((Node *) e->expr), false); named_arg_strings = lappend(named_arg_strings, str); i++; } arg_strings = NIL; foreach(arg, xmlExpr->args) { ExprState *e = (ExprState *) lfirst(arg); Datum value; bool isnull; char *str; value = ExecEvalExpr(e, econtext, &isnull, NULL); /* here we can just forget NULL elements immediately */ if (!isnull) { str = map_sql_value_to_xml_value(value, exprType((Node *) e->expr), true); arg_strings = lappend(arg_strings, str); } } /* now safe to run libxml */ xmlerrcxt = pg_xml_init(PG_XML_STRICTNESS_ALL); PG_TRY(); { buf = xmlBufferCreate(); if (buf == NULL || xmlerrcxt->err_occurred) xml_ereport(xmlerrcxt, ERROR, ERRCODE_OUT_OF_MEMORY, "could not allocate xmlBuffer"); writer = xmlNewTextWriterMemory(buf, 0); if (writer == NULL || xmlerrcxt->err_occurred) xml_ereport(xmlerrcxt, ERROR, ERRCODE_OUT_OF_MEMORY, "could not allocate xmlTextWriter"); xmlTextWriterStartElement(writer, (xmlChar *) xexpr->name); forboth(arg, named_arg_strings, narg, xexpr->arg_names) { char *str = (char *) lfirst(arg); char *argname = strVal(lfirst(narg)); if (str) xmlTextWriterWriteAttribute(writer, (xmlChar *) argname, (xmlChar *) str); } foreach(arg, arg_strings) { char *str = (char *) lfirst(arg); xmlTextWriterWriteRaw(writer, (xmlChar *) str); } xmlTextWriterEndElement(writer); /* we MUST do this now to flush data out to the buffer ... */ xmlFreeTextWriter(writer); writer = NULL; result = xmlBuffer_to_xmltype(buf); } PG_CATCH(); { if (writer) xmlFreeTextWriter(writer); if (buf) xmlBufferFree(buf); pg_xml_done(xmlerrcxt, true); PG_RE_THROW(); } PG_END_TRY(); xmlBufferFree(buf); pg_xml_done(xmlerrcxt, false); return result; #else NO_XML_SUPPORT(); return NULL; #endif }
Datum xmlexists | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3963 of file xml.c.
References NO_XML_SUPPORT, NULL, PG_GETARG_TEXT_P, PG_GETARG_XML_P, and PG_RETURN_BOOL.
{ #ifdef USE_LIBXML text *xpath_expr_text = PG_GETARG_TEXT_P(0); xmltype *data = PG_GETARG_XML_P(1); int res_nitems; xpath_internal(xpath_expr_text, data, NULL, &res_nitems, NULL); PG_RETURN_BOOL(res_nitems > 0); #else NO_XML_SUPPORT(); return 0; #endif }
xmltype* xmlparse | ( | text * | data, | |
XmlOptionType | xmloption, | |||
bool | preserve_whitespace | |||
) |
Definition at line 703 of file xml.c.
References GetDatabaseEncoding(), and NO_XML_SUPPORT.
Referenced by ExecEvalXml(), and texttoxml().
{ #ifdef USE_LIBXML xmlDocPtr doc; doc = xml_parse(data, xmloption_arg, preserve_whitespace, GetDatabaseEncoding()); xmlFreeDoc(doc); return (xmltype *) data; #else NO_XML_SUPPORT(); return NULL; #endif }
Definition at line 721 of file xml.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), StringInfoData::data, ereport, errcode(), errdetail(), errmsg(), ERROR, initStringInfo(), NO_XML_SUPPORT, NULL, pfree(), pg_strcasecmp(), stringinfo_to_xmltype(), and text_to_cstring().
Referenced by ExecEvalXml().
{ #ifdef USE_LIBXML xmltype *result; StringInfoData buf; if (pg_strcasecmp(target, "xml") == 0) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), /* really */ errmsg("invalid XML processing instruction"), errdetail("XML processing instruction target name cannot be \"%s\".", target))); /* * Following the SQL standard, the null check comes after the syntax check * above. */ *result_is_null = arg_is_null; if (*result_is_null) return NULL; initStringInfo(&buf); appendStringInfo(&buf, "<?%s", target); if (arg != NULL) { char *string; string = text_to_cstring(arg); if (strstr(string, "?>") != NULL) ereport(ERROR, (errcode(ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION), errmsg("invalid XML processing instruction"), errdetail("XML processing instruction cannot contain \"?>\"."))); appendStringInfoChar(&buf, ' '); appendStringInfoString(&buf, string + strspn(string, " ")); pfree(string); } appendStringInfoString(&buf, "?>"); result = stringinfo_to_xmltype(&buf); pfree(buf.data); return result; #else NO_XML_SUPPORT(); return NULL; #endif }
Definition at line 773 of file xml.c.
References appendStringInfoString(), initStringInfo(), NO_XML_SUPPORT, NULL, stringinfo_to_xmltype(), text_to_cstring(), VARSIZE, XML_STANDALONE_NO, XML_STANDALONE_NO_VALUE, XML_STANDALONE_OMITTED, and XML_STANDALONE_YES.
Referenced by ExecEvalXml().
{ #ifdef USE_LIBXML char *str; size_t len; xmlChar *orig_version; int orig_standalone; StringInfoData buf; len = VARSIZE(data) - VARHDRSZ; str = text_to_cstring((text *) data); parse_xml_decl((xmlChar *) str, &len, &orig_version, NULL, &orig_standalone); if (version) orig_version = xml_text2xmlChar(version); else orig_version = NULL; switch (standalone) { case XML_STANDALONE_YES: orig_standalone = 1; break; case XML_STANDALONE_NO: orig_standalone = 0; break; case XML_STANDALONE_NO_VALUE: orig_standalone = -1; break; case XML_STANDALONE_OMITTED: /* leave original value */ break; } initStringInfo(&buf); print_xml_decl(&buf, orig_version, 0, orig_standalone); appendStringInfoString(&buf, str + len); return stringinfo_to_xmltype(&buf); #else NO_XML_SUPPORT(); return NULL; #endif }
Datum xmltotext | ( | PG_FUNCTION_ARGS | ) |
Definition at line 556 of file xml.c.
References PG_GETARG_XML_P, and PG_RETURN_TEXT_P.
{ xmltype *data = PG_GETARG_XML_P(0); /* It's actually binary compatible. */ PG_RETURN_TEXT_P((text *) data); }
text* xmltotext_with_xmloption | ( | xmltype * | data, | |
XmlOptionType | xmloption_arg | |||
) |
Definition at line 566 of file xml.c.
References ereport, errcode(), errmsg(), ERROR, xml_is_document(), and XMLOPTION_DOCUMENT.
Referenced by ExecEvalXml().
{ if (xmloption_arg == XMLOPTION_DOCUMENT && !xml_is_document(data)) ereport(ERROR, (errcode(ERRCODE_NOT_AN_XML_DOCUMENT), errmsg("not an XML document"))); /* It's actually binary compatible, save for the above check. */ return (text *) data; }
Datum xmlvalidate | ( | PG_FUNCTION_ARGS | ) |
Datum xpath | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3936 of file xml.c.
References construct_empty_array(), CurrentMemoryContext, makeArrayResult(), NO_XML_SUPPORT, PG_GETARG_ARRAYTYPE_P, PG_GETARG_TEXT_P, PG_GETARG_XML_P, PG_RETURN_ARRAYTYPE_P, and XMLOID.
{ #ifdef USE_LIBXML text *xpath_expr_text = PG_GETARG_TEXT_P(0); xmltype *data = PG_GETARG_XML_P(1); ArrayType *namespaces = PG_GETARG_ARRAYTYPE_P(2); int res_nitems; ArrayBuildState *astate; xpath_internal(xpath_expr_text, data, namespaces, &res_nitems, &astate); if (res_nitems == 0) PG_RETURN_ARRAYTYPE_P(construct_empty_array(XMLOID)); else PG_RETURN_ARRAYTYPE_P(makeArrayResult(astate, CurrentMemoryContext)); #else NO_XML_SUPPORT(); return 0; #endif }
Datum xpath_exists | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3986 of file xml.c.
References NO_XML_SUPPORT, NULL, PG_GETARG_ARRAYTYPE_P, PG_GETARG_TEXT_P, PG_GETARG_XML_P, and PG_RETURN_BOOL.
{ #ifdef USE_LIBXML text *xpath_expr_text = PG_GETARG_TEXT_P(0); xmltype *data = PG_GETARG_XML_P(1); ArrayType *namespaces = PG_GETARG_ARRAYTYPE_P(2); int res_nitems; xpath_internal(xpath_expr_text, data, namespaces, &res_nitems, NULL); PG_RETURN_BOOL(res_nitems > 0); #else NO_XML_SUPPORT(); return 0; #endif }
int xmlbinary |
Definition at line 95 of file xml.c.
Referenced by map_sql_type_to_xmlschema_type(), and map_sql_value_to_xml_value().
int xmloption |
Definition at line 96 of file xml.c.
Referenced by _copyXmlExpr(), _copyXmlSerialize(), _equalXmlExpr(), _equalXmlSerialize(), _outXmlExpr(), _outXmlSerialize(), _readXmlExpr(), texttoxml(), xml_in(), xml_is_well_formed(), and xml_recv().