49#include <libxml/chvalid.h>
50#include <libxml/entities.h>
51#include <libxml/parser.h>
52#include <libxml/parserInternals.h>
53#include <libxml/tree.h>
54#include <libxml/uri.h>
55#include <libxml/xmlerror.h>
56#include <libxml/xmlsave.h>
57#include <libxml/xmlversion.h>
58#include <libxml/xmlwriter.h>
59#include <libxml/xpath.h>
60#include <libxml/xpathInternals.h>
67#if LIBXML_VERSION >= 20704
68#define HAVE_XMLSTRUCTUREDERRORCONTEXT 1
74#if LIBXML_VERSION >= 21200
75#define PgXmlErrorPtr const xmlError *
77#define PgXmlErrorPtr xmlErrorPtr
114#define ERRCXT_MAGIC 68275028
134 int sqlcode,
const char *msg);
140#ifdef USE_LIBXMLCONTEXT
175 const char *
targetns,
bool top_level);
189 const char *
targetns,
bool top_level);
194#define XMLTABLE_CONTEXT_MAGIC 46922182
216 const char *path,
int colnum);
219 Oid typid,
int32 typmod,
bool *isnull);
234#define NO_XML_SUPPORT() \
236 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \
237 errmsg("unsupported XML feature"), \
238 errdetail("This functionality requires the server to be built with libxml support.")))
242#define NAMESPACE_XSD "http://www.w3.org/2001/XMLSchema"
243#define NAMESPACE_XSI "http://www.w3.org/2001/XMLSchema-instance"
244#define NAMESPACE_SQLXML "http://standards.iso.org/iso/9075/2003/sqlxml"
257 errmsg(
"invalid encoding name \"%s\"",
300#define PG_XML_DEFAULT_VERSION "1.0"
388 nbytes =
buf->len -
buf->cursor;
506 errmsg(
"invalid XML comment")));
511 errmsg(
"invalid XML comment")));
544 "could not allocate xmlChar");
711 (
Node *) &escontext);
719 errmsg(
"not an XML document")));
746 "could not allocate xmlBuffer");
766 "could not allocate xmlSaveCtxt");
773 "could not save document to xmlBuffer");
790 "could not allocate xml node");
803 "could not append xml node list");
815 "could not allocate xml node");
826 "could not save newline to xmlBuffer");
834 "could not save content to xmlBuffer");
845 "could not close xmlSaveCtxtPtr");
856 while (
len > 0 && (
str[
len - 1] ==
'\n' ||
895 const Datum *named_argvalue,
const bool *named_argnull,
896 const Datum *argvalue,
const bool *argnull)
923 if (named_argnull[
i])
958 "could not allocate xmlBuffer");
962 "could not allocate xmlTextWriter");
967 "could not start xml element");
981 "could not write xml attribute");
992 "could not write raw xml text");
998 "could not end xml element");
1063 errmsg(
"invalid XML processing instruction"),
1064 errdetail(
"XML processing instruction target name cannot be \"%s\".", target)));
1086 errmsg(
"invalid XML processing instruction"),
1087 errdetail(
"XML processing instruction cannot contain \"?>\".")));
1166 errmsg(
"xmlvalidate is not implemented")));
1220 if (
sizeof(
char) !=
sizeof(
xmlChar))
1222 (
errmsg(
"could not initialize XML library"),
1223 errdetail(
"libxml2 has incompatible char type: sizeof(char)=%zu, sizeof(xmlChar)=%zu.",
1224 sizeof(
char),
sizeof(
xmlChar))));
1226#ifdef USE_LIBXMLCONTEXT
1266 errcxt->err_occurred =
false;
1278#ifdef HAVE_XMLSTRUCTUREDERRORCONTEXT
1300#ifdef HAVE_XMLSTRUCTUREDERRORCONTEXT
1309 errmsg(
"could not set up XML error handler"),
1310 errhint(
"This probably indicates that the version of libxml2"
1311 " being used is not compatible with the libxml2"
1312 " header files that PostgreSQL was built with.")));
1354#ifdef HAVE_XMLSTRUCTUREDERRORCONTEXT
1361 elog(
WARNING,
"libxml error handling state is out of sync with xml.c");
1385 return errcxt->err_occurred;
1398#define CHECK_XML_SPACE(p) \
1400 if (!xmlIsBlank_ch(*(p))) \
1401 return XML_ERR_SPACE_REQUIRED; \
1404#define SKIP_XML_SPACE(p) \
1405 while (xmlIsBlank_ch(*(p))) (p)++
1409#define PG_XMLISNAMECHAR(c) \
1410 (xmlIsBaseChar_ch(c) || xmlIsIdeographicQ(c) \
1411 || xmlIsDigit_ch(c) \
1412 || c == '.' || c == '-' || c == '_' || c == ':' \
1413 || xmlIsCombiningQ(c) \
1414 || xmlIsExtender_ch(c))
1533 if (*p ==
'\'' || *p ==
'"')
1561 if (*p ==
'\'' || *p ==
'"')
1741 if (!p || p[2] !=
'>')
1875 "could not allocate parser context");
1900 "invalid XML document");
1904 "invalid XML content");
1914 "could not allocate XML document");
1920 "could not allocate XML document");
1936 "invalid XML content");
1982#ifdef USE_LIBXMLCONTEXT
2071 elog(
ERROR,
"xml_ereport called with invalid PgXmlErrorContext");
2074 errcxt->err_occurred =
false;
2077 if (
errcxt->err_buf.len > 0)
2078 detail =
errcxt->err_buf.data;
2103 int sqlcode,
const char *msg)
2109 elog(
ERROR,
"xml_errsave called with invalid PgXmlErrorContext");
2112 errcxt->err_occurred =
false;
2115 if (
errcxt->err_buf.len > 0)
2116 detail =
errcxt->err_buf.data;
2139 int domain =
error->domain;
2140 int level =
error->level;
2150 elog(
FATAL,
"xml_errorHandler called with invalid PgXmlErrorContext");
2160 switch (
error->code)
2220 if (
error->line > 0)
2358 while (
str->len > 0 &&
str->data[
str->len - 1] ==
'\n')
2359 str->data[--
str->len] =
'\0';
2401 ||
c ==
'_' ||
c ==
':');
2411 ||
c ==
'.' ||
c ==
'-' ||
c ==
'_' ||
c ==
':'
2441 else if (*p ==
'_' && *(p + 1) ==
'x')
2487 if (*p ==
'_' && *(p + 1) ==
'x'
2488 &&
isxdigit((
unsigned char) *(p + 2))
2489 &&
isxdigit((
unsigned char) *(p + 3))
2490 &&
isxdigit((
unsigned char) *(p + 4))
2491 &&
isxdigit((
unsigned char) *(p + 5))
2541 &elem_values, &elem_nulls,
2546 for (
i = 0;
i < num_elems;
i++)
2596 errmsg(
"date out of range"),
2597 errdetail(
"XML does not support infinite date values.")));
2618 errmsg(
"timestamp out of range"),
2619 errdetail(
"XML does not support infinite timestamp values.")));
2625 errmsg(
"timestamp out of range")));
2636 const char *tzn =
NULL;
2645 errmsg(
"timestamp out of range"),
2646 errdetail(
"XML does not support infinite timestamp values.")));
2652 errmsg(
"timestamp out of range")));
2673 "could not allocate xmlBuffer");
2677 "could not allocate xmlTextWriter");
2745 for (p =
str; *p; p++)
2836 elog(
ERROR,
"SPI_execute returned %s for %s",
2863 " WHERE relnamespace = %u AND relkind IN ("
2867 " AND pg_catalog.has_table_privilege (oid, 'SELECT')"
2868 " ORDER BY relname;",
nspid);
2878#define XML_VISIBLE_SCHEMAS_EXCLUDE "(nspname ~ '^pg_' OR nspname = 'information_schema')"
2880#define XML_VISIBLE_SCHEMAS "SELECT oid FROM pg_catalog.pg_namespace WHERE pg_catalog.has_schema_privilege (oid, 'USAGE') AND NOT " XML_VISIBLE_SCHEMAS_EXCLUDE
2895 " WHERE relkind IN ("
2899 " AND pg_catalog.has_table_privilege(pg_class.oid, 'SELECT')"
2912 const char *
targetns,
bool top_level)
2980 errmsg(
"cursor \"%s\" does not exist",
name)));
3045 const char *
targetns,
bool top_level)
3062 errmsg(
"invalid query")));
3120 elog(
ERROR,
"SPI_prepare(\"%s\") failed", query);
3123 elog(
ERROR,
"SPI_cursor_open(\"%s\") failed", query);
3150 errmsg(
"cursor \"%s\" does not exist",
name)));
3154 errmsg(
"portal \"%s\" does not return tuples",
name)));
3201 elog(
ERROR,
"SPI_prepare(\"%s\") failed", query);
3204 elog(
ERROR,
"SPI_cursor_open(\"%s\") failed", query);
3296 " targetNamespace=\"%s\"\n"
3297 " elementFormDefault=\"qualified\"",
3576 elog(
ERROR,
"cache lookup failed for relation %u", relid);
3611 "<xsd:complexType name=\"%s\">\n"
3612 " <xsd:sequence>\n",
3615 for (
i = 0;
i < tupdesc->
natts;
i++)
3619 if (att->attisdropped)
3622 " <xsd:element name=\"%s\" type=\"%s\"%s></xsd:element>\n",
3626 nulls ?
" nillable=\"true\"" :
" minOccurs=\"0\"");
3630 " </xsd:sequence>\n"
3631 "</xsd:complexType>\n\n");
3636 "<xsd:complexType name=\"%s\">\n"
3638 " <xsd:element name=\"row\" type=\"%s\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n"
3639 " </xsd:sequence>\n"
3640 "</xsd:complexType>\n\n",
3644 "<xsd:element name=\"%s\" type=\"%s\"/>\n\n",
3649 "<xsd:element name=\"%s\" type=\"%s\"/>\n\n",
3692 " <xsd:sequence>\n");
3706 " <xsd:element name=\"%s\" type=\"%s\"/>\n",
3710 " <xsd:element name=\"%s\" type=\"%s\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n",
3719 " </xsd:sequence>\n");
3721 "</xsd:complexType>\n\n");
3724 "<xsd:element name=\"%s\" type=\"%s\"/>\n\n",
3772 " <xsd:element name=\"%s\" type=\"%s\"/>\n",
3779 "</xsd:complexType>\n\n");
3782 "<xsd:element name=\"%s\" type=\"%s\"/>\n\n",
3818 ((typmod -
VARHDRSZ) >> 16) & 0xffff,
3876 elog(
ERROR,
"cache lookup failed for type %u", typeoid);
3910 for (
i = 0;
i < tupdesc->
natts;
i++)
3914 if (att->attisdropped)
3963 "<xsd:complexType mixed=\"true\">\n"
3965 " <xsd:any name=\"element\" minOccurs=\"0\" maxOccurs=\"unbounded\" processContents=\"skip\"/>\n"
3966 " </xsd:sequence>\n"
3967 "</xsd:complexType>\n");
3972 "<xsd:simpleType name=\"%s\">\n",
typename);
3980 " <xsd:restriction base=\"xsd:string\">\n");
3983 " <xsd:maxLength value=\"%d\"/>\n",
3990 " <xsd:restriction base=\"xsd:%s\">\n"
3991 " </xsd:restriction>\n",
3998 " <xsd:restriction base=\"xsd:decimal\">\n"
3999 " <xsd:totalDigits value=\"%d\"/>\n"
4000 " <xsd:fractionDigits value=\"%d\"/>\n"
4001 " </xsd:restriction>\n",
4002 ((typmod -
VARHDRSZ) >> 16) & 0xffff,
4008 " <xsd:restriction base=\"xsd:short\">\n"
4009 " <xsd:maxInclusive value=\"%d\"/>\n"
4010 " <xsd:minInclusive value=\"%d\"/>\n"
4011 " </xsd:restriction>\n",
4017 " <xsd:restriction base=\"xsd:int\">\n"
4018 " <xsd:maxInclusive value=\"%d\"/>\n"
4019 " <xsd:minInclusive value=\"%d\"/>\n"
4020 " </xsd:restriction>\n",
4026 " <xsd:restriction base=\"xsd:long\">\n"
4029 " </xsd:restriction>\n",
4036 " <xsd:restriction base=\"xsd:float\"></xsd:restriction>\n");
4041 " <xsd:restriction base=\"xsd:double\"></xsd:restriction>\n");
4046 " <xsd:restriction base=\"xsd:boolean\"></xsd:restriction>\n");
4052 const char *tz = (typeoid ==
TIMETZOID ?
"(\\+|-)\\p{Nd}{2}:\\p{Nd}{2}" :
"");
4056 " <xsd:restriction base=\"xsd:time\">\n"
4057 " <xsd:pattern value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}(.\\p{Nd}+)?%s\"/>\n"
4058 " </xsd:restriction>\n", tz);
4059 else if (typmod == 0)
4061 " <xsd:restriction base=\"xsd:time\">\n"
4062 " <xsd:pattern value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}%s\"/>\n"
4063 " </xsd:restriction>\n", tz);
4066 " <xsd:restriction base=\"xsd:time\">\n"
4067 " <xsd:pattern value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}.\\p{Nd}{%d}%s\"/>\n"
4068 " </xsd:restriction>\n", typmod -
VARHDRSZ, tz);
4075 const char *tz = (typeoid ==
TIMESTAMPTZOID ?
"(\\+|-)\\p{Nd}{2}:\\p{Nd}{2}" :
"");
4079 " <xsd:restriction base=\"xsd:dateTime\">\n"
4080 " <xsd:pattern value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}T\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}(.\\p{Nd}+)?%s\"/>\n"
4081 " </xsd:restriction>\n", tz);
4082 else if (typmod == 0)
4084 " <xsd:restriction base=\"xsd:dateTime\">\n"
4085 " <xsd:pattern value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}T\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}%s\"/>\n"
4086 " </xsd:restriction>\n", tz);
4089 " <xsd:restriction base=\"xsd:dateTime\">\n"
4090 " <xsd:pattern value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}T\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}.\\p{Nd}{%d}%s\"/>\n"
4091 " </xsd:restriction>\n", typmod -
VARHDRSZ, tz);
4097 " <xsd:restriction base=\"xsd:date\">\n"
4098 " <xsd:pattern value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}\"/>\n"
4099 " </xsd:restriction>\n");
4106 int32 base_typmod = -1;
4111 " <xsd:restriction base=\"%s\"/>\n",
4130 const char *
targetns,
bool top_level)
4215 "could not allocate xmlBuffer");
4232 "could not copy node");
4237 if (bytes == -1 ||
xmlerrcxt->err_occurred)
4239 "could not dump node");
4263 "could not allocate xmlChar");
4347 elog(
ERROR,
"xpath expression result type %d is unsupported",
4403 ndim = namespaces ?
ARR_NDIM(namespaces) : 0;
4410 if (ndim != 2 || dims[1] != 2)
4413 errmsg(
"invalid array for XML namespace mapping"),
4414 errdetail(
"The array must be two-dimensional with length of the second axis equal to 2.")));
4438 errmsg(
"empty XPath expression")));
4466 "could not allocate parser context");
4471 "could not parse XML document");
4475 "could not allocate XPath context");
4490 errmsg(
"neither namespace name nor URI may be null")));
4497 (
errmsg(
"could not register XML namespace with name \"%s\" and URI \"%s\"",
4511 "invalid XPath expression");
4523 "could not create XPath object");
4712 elog(
ERROR,
"%s called with invalid TableFuncScanState", fname);
4715 elog(
ERROR,
"%s called with invalid TableFuncScanState", fname);
4742 xtCxt->natts = natts;
4754 "could not allocate parser context");
4808 "could not parse XML document");
4812 "could not allocate XPath context");
4846 errmsg(
"DEFAULT namespace is not supported")));
4853 "could not set XML namespace");
4875 errmsg(
"row path filter must not be empty string")));
4885 "invalid XPath expression");
4909 errmsg(
"column path filter must not be empty string")));
4917 if (
xtCxt->xpathscomp[colnum] ==
NULL ||
xtCxt->xmlerrcxt->err_occurred)
4919 "invalid XPath expression");
4946 "could not create XPath object");
4948 xtCxt->row_count = 0;
4953 if (
xtCxt->xpathobj->nodesetval !=
NULL)
4955 if (
xtCxt->row_count++ <
xtCxt->xpathobj->nodesetval->nodeNr)
4977 Oid typid,
int32 typmod,
bool *isnull)
5003 cur =
xtCxt->xpathobj->nodesetval->nodeTab[
xtCxt->row_count - 1];
5010 "could not create XPath object");
5024 count =
xpathobj->nodesetval->nodeNr;
5039 for (
int i = 0;
i < count;
i++)
5056 errmsg(
"more than one value returned by column XPath expression")));
5106 state->typioparams[colnum],
#define PG_GETARG_ARRAYTYPE_P(n)
#define DatumGetArrayTypeP(X)
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
ArrayBuildState * initArrayResult(Oid element_type, MemoryContext rcontext, bool subcontext)
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
void deconstruct_array(const ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
void j2date(int jd, int *year, int *month, int *day)
void EncodeDateTime(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str)
void EncodeDateOnly(struct pg_tm *tm, int style, char *str)
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
#define TextDatumGetCString(d)
#define Assert(condition)
#define OidIsValid(objectId)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
#define TIMESTAMP_NOT_FINITE(j)
#define POSTGRES_EPOCH_JDATE
#define DATE_NOT_FINITE(j)
static DateADT DatumGetDateADT(Datum X)
int errcode(int sqlerrcode)
#define errsave(context,...)
int int errdetail_internal(const char *fmt,...) pg_attribute_printf(1
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
#define palloc_object(type)
#define palloc0_array(type, count)
#define palloc0_object(type)
Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
char * OidOutputFunctionCall(Oid functionId, Datum val)
#define PG_GETARG_TEXT_PP(n)
#define PG_RETURN_BYTEA_P(x)
#define DatumGetByteaPP(X)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_NAME(n)
#define PG_RETURN_TEXT_P(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
#define PG_RETURN_BOOL(x)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
List * lappend(List *list, void *datum)
List * lappend_oid(List *list, Oid datum)
List * list_append_unique_oid(List *list, Oid datum)
char * get_rel_name(Oid relid)
char * get_database_name(Oid dbid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
char get_typtype(Oid typid)
Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod)
Oid getBaseType(Oid typid)
char * get_namespace_name(Oid nspid)
void get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
#define type_is_array_domain(typid)
int GetDatabaseEncoding(void)
int pg_mblen_cstr(const char *mbstr)
char * pg_any_to_server(const char *s, int len, int encoding)
unsigned char * pg_do_encoding_conversion(unsigned char *src, int len, int src_encoding, int dest_encoding)
int pg_get_client_encoding(void)
void pg_unicode_to_server(char32_t c, unsigned char *s)
char * pg_server_to_any(const char *s, int len, int encoding)
int pg_encoding_mb2wchar_with_len(int encoding, const char *from, pg_wchar *to, int len)
char * MemoryContextStrdup(MemoryContext context, const char *string)
void * MemoryContextAlloc(MemoryContext context, Size size)
char * pstrdup(const char *in)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
MemoryContext TopMemoryContext
MemoryContext CurrentMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define SOFT_ERROR_OCCURRED(escontext)
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Oid exprType(const Node *expr)
#define IsA(nodeptr, _type_)
FormData_pg_attribute * Form_pg_attribute
#define ERRCODE_DATA_CORRUPTED
FormData_pg_class * Form_pg_class
#define forboth(cell1, list1, cell2, list2)
#define list_make2(x1, x2)
static char buf[DEFAULT_XLOG_SEG_SIZE]
END_CATALOG_STRUCT typedef FormData_pg_type * Form_pg_type
#define MAX_MULTIBYTE_CHAR_LEN
#define MAX_UNICODE_EQUIVALENT_STRING
#define pg_encoding_to_char
#define pg_char_to_encoding
int pg_strcasecmp(const char *s1, const char *s2)
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Oid DatumGetObjectId(Datum X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static char * DatumGetCString(Datum X)
static Datum Float8GetDatum(float8 X)
static Datum CStringGetDatum(const char *X)
Datum regclassout(PG_FUNCTION_ARGS)
Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber)
const char * SPI_result_code_string(int code)
SPITupleTable * SPI_tuptable
Portal SPI_cursor_find(const char *name)
Portal SPI_cursor_open(const char *name, SPIPlanPtr plan, const Datum *Values, const char *Nulls, bool read_only)
void SPI_cursor_fetch(Portal portal, bool forward, long count)
SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes)
void SPI_cursor_close(Portal portal)
void * SPI_palloc(Size size)
int SPI_execute(const char *src, bool read_only, long tcount)
Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
char * SPI_fname(TupleDesc tupdesc, int fnumber)
struct StringInfoData * StringInfo
StringInfo makeStringInfo(void)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
#define appendStringInfoCharMacro(str, ch)
void(* InitOpaque)(TableFuncScanState *state, int natts)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
struct TupleDescData * TupleDesc
static Timestamp DatumGetTimestamp(Datum X)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static Size VARSIZE(const void *PTR)
static char * VARDATA(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)
static void appendStringInfoText(StringInfo str, const text *t)
text * cstring_to_text_with_len(const char *s, int len)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)
int pg_encoding_mblen(int encoding, const char *mbstr)
Datum xml_in(PG_FUNCTION_ARGS)
Datum cursor_to_xmlschema(PG_FUNCTION_ARGS)
Datum table_to_xml(PG_FUNCTION_ARGS)
Datum query_to_xmlschema(PG_FUNCTION_ARGS)
Datum database_to_xml(PG_FUNCTION_ARGS)
static const char * map_sql_catalog_to_xmlschema_types(List *nspid_list, bool nulls, bool tableforest, const char *targetns)
xmltype * xmlroot(xmltype *data, text *version, int standalone)
static void XmlTableInitOpaque(struct TableFuncScanState *state, int natts)
static const char * map_sql_type_to_xml_name(Oid typeoid, int typmod)
static const char * map_sql_type_to_xmlschema_type(Oid typeoid, int typmod)
Datum texttoxml(PG_FUNCTION_ARGS)
static char * xml_out_internal(xmltype *x, pg_enc target_encoding)
char * map_sql_identifier_to_xml_name(const char *ident, bool fully_escaped, bool escape_period)
static void xsd_schema_element_start(StringInfo result, const char *targetns)
Datum query_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
Datum xmltotext(PG_FUNCTION_ARGS)
Datum schema_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
Datum xmlexists(PG_FUNCTION_ARGS)
Datum xmltext(PG_FUNCTION_ARGS)
static char * map_multipart_sql_identifier_to_xml_name(const char *a, const char *b, const char *c, const char *d)
static StringInfo database_to_xmlschema_internal(bool nulls, bool tableforest, const char *targetns)
Datum database_to_xmlschema(PG_FUNCTION_ARGS)
static List * schema_get_xml_visible_tables(Oid nspid)
Datum schema_to_xmlschema(PG_FUNCTION_ARGS)
text * xmltotext_with_options(xmltype *data, XmlOptionType xmloption_arg, bool indent)
static void xmldata_root_element_start(StringInfo result, const char *eltname, const char *xmlschema, const char *targetns, bool top_level)
char * map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings)
Datum xml_send(PG_FUNCTION_ARGS)
static const char * map_sql_schema_to_xmlschema_types(Oid nspid, List *relid_list, bool nulls, bool tableforest, const char *targetns)
const TableFuncRoutine XmlTableRoutine
Datum xmlcomment(PG_FUNCTION_ARGS)
static void XmlTableSetNamespace(struct TableFuncScanState *state, const char *name, const char *uri)
Datum xmlconcat2(PG_FUNCTION_ARGS)
static void XmlTableSetRowFilter(struct TableFuncScanState *state, const char *path)
static List * database_get_xml_visible_schemas(void)
static void xmldata_root_element_end(StringInfo result, const char *eltname)
xmltype * xmlconcat(List *args)
static Datum XmlTableGetValue(struct TableFuncScanState *state, int colnum, Oid typid, int32 typmod, bool *isnull)
char * escape_xml(const char *str)
xmltype * xmlparse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace, Node *escontext)
Datum xml_is_well_formed_document(PG_FUNCTION_ARGS)
Datum query_to_xml(PG_FUNCTION_ARGS)
static StringInfo database_to_xml_internal(const char *xmlschema, bool nulls, bool tableforest, const char *targetns)
static xmltype * stringinfo_to_xmltype(StringInfo buf)
Datum xml_is_well_formed_content(PG_FUNCTION_ARGS)
#define XML_VISIBLE_SCHEMAS
static List * database_get_xml_visible_tables(void)
bool xml_is_document(xmltype *arg)
static StringInfo schema_to_xmlschema_internal(const char *schemaname, bool nulls, bool tableforest, const char *targetns)
Datum table_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
Datum xmlvalidate(PG_FUNCTION_ARGS)
static xmltype * cstring_to_xmltype(const char *string)
static List * query_to_oid_list(const char *query)
static void XmlTableSetDocument(struct TableFuncScanState *state, Datum value)
static void XmlTableDestroyOpaque(struct TableFuncScanState *state)
static const char * map_sql_typecoll_to_xmlschema_types(List *tupdesc_list)
#define PG_XML_DEFAULT_VERSION
Datum table_to_xmlschema(PG_FUNCTION_ARGS)
static StringInfo query_to_xml_internal(const char *query, char *tablename, const char *xmlschema, bool nulls, bool tableforest, const char *targetns, bool top_level)
static void SPI_sql_row_to_xmlelement(uint64 rownum, StringInfo result, char *tablename, bool nulls, bool tableforest, const char *targetns, bool top_level)
static StringInfo schema_to_xml_internal(Oid nspid, const char *xmlschema, bool nulls, bool tableforest, const char *targetns, bool top_level)
static StringInfo table_to_xml_internal(Oid relid, const char *xmlschema, bool nulls, bool tableforest, const char *targetns, bool top_level)
Datum schema_to_xml(PG_FUNCTION_ARGS)
char * map_xml_name_to_sql_identifier(const char *name)
Datum database_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
static bool XmlTableFetchRow(struct TableFuncScanState *state)
Datum cursor_to_xml(PG_FUNCTION_ARGS)
Datum xpath_exists(PG_FUNCTION_ARGS)
Datum xml_is_well_formed(PG_FUNCTION_ARGS)
static char * _SPI_strdup(const char *s)
static void XmlTableSetColumnFilter(struct TableFuncScanState *state, const char *path, int colnum)
static const char * map_sql_table_to_xmlschema(TupleDesc tupdesc, Oid relid, bool nulls, bool tableforest, const char *targetns)
Datum xml_out(PG_FUNCTION_ARGS)
Datum xml_recv(PG_FUNCTION_ARGS)
xmltype * xmlelement(XmlExpr *xexpr, const Datum *named_argvalue, const bool *named_argnull, const Datum *argvalue, const bool *argnull)
xmltype * xmlpi(const char *target, text *arg, bool arg_is_null, bool *result_is_null)
Datum xpath(PG_FUNCTION_ARGS)
static void xsd_schema_element_end(StringInfo result)
@ XML_STANDALONE_NO_VALUE
struct PgXmlErrorContext PgXmlErrorContext
PgXmlErrorContext * pg_xml_init(PgXmlStrictness strictness)
#define PG_RETURN_XML_P(x)
void xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode, const char *msg)
bool pg_xml_error_occurred(PgXmlErrorContext *errcxt)
static xmltype * DatumGetXmlP(Datum X)
void pg_xml_done(PgXmlErrorContext *errcxt, bool isError)
#define PG_GETARG_XML_P(n)
void pg_xml_init_library(void)
@ PG_XML_STRICTNESS_LEGACY
@ PG_XML_STRICTNESS_WELLFORMED