1 /*-------------------------------------------------------------------------
4 * Declarations for XML data type support.
7 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/utils/xml.h
12 *-------------------------------------------------------------------------
18 #include "executor/tablefunc.h"
20 #include "nodes/execnodes.h"
21 #include "nodes/primnodes.h"
23 typedef struct varlena xmltype
;
29 XML_STANDALONE_NO_VALUE
,
30 XML_STANDALONE_OMITTED
41 PG_XML_STRICTNESS_LEGACY
, /* ignore errors unless function result
42 * indicates error condition */
43 PG_XML_STRICTNESS_WELLFORMED
, /* ignore non-parser messages */
44 PG_XML_STRICTNESS_ALL
/* report all notices/warnings/errors */
47 /* struct PgXmlErrorContext is private to xml.c */
48 typedef struct PgXmlErrorContext PgXmlErrorContext
;
50 #define DatumGetXmlP(X) ((xmltype *) PG_DETOAST_DATUM(X))
51 #define XmlPGetDatum(X) PointerGetDatum(X)
53 #define PG_GETARG_XML_P(n) DatumGetXmlP(PG_GETARG_DATUM(n))
54 #define PG_RETURN_XML_P(x) PG_RETURN_POINTER(x)
56 extern void pg_xml_init_library(void);
57 extern PgXmlErrorContext
*pg_xml_init(PgXmlStrictness strictness
);
58 extern void pg_xml_done(PgXmlErrorContext
*errcxt
, bool isError
);
59 extern bool pg_xml_error_occurred(PgXmlErrorContext
*errcxt
);
60 extern void xml_ereport(PgXmlErrorContext
*errcxt
, int level
, int sqlcode
,
63 extern xmltype
*xmlconcat(List
*args
);
64 extern xmltype
*xmlelement(XmlExpr
*xexpr
,
65 Datum
*named_argvalue
, bool *named_argnull
,
66 Datum
*argvalue
, bool *argnull
);
67 extern xmltype
*xmlparse(text
*data
, XmlOptionType xmloption
, bool preserve_whitespace
);
68 extern xmltype
*xmlpi(const char *target
, text
*arg
, bool arg_is_null
, bool *result_is_null
);
69 extern xmltype
*xmlroot(xmltype
*data
, text
*version
, int standalone
);
70 extern bool xml_is_document(xmltype
*arg
);
71 extern text
*xmltotext_with_xmloption(xmltype
*data
, XmlOptionType xmloption_arg
);
72 extern char *escape_xml(const char *str
);
74 extern char *map_sql_identifier_to_xml_name(const char *ident
, bool fully_escaped
, bool escape_period
);
75 extern char *map_xml_name_to_sql_identifier(const char *name
);
76 extern char *map_sql_value_to_xml_value(Datum value
, Oid type
, bool xml_escape_strings
);
78 extern int xmlbinary
; /* XmlBinaryType, but int for guc enum */
80 extern int xmloption
; /* XmlOptionType, but int for guc enum */
82 extern const TableFuncRoutine XmlTableRoutine
;