PostgreSQL Source Code  git master
xml.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * xml.h
4  * Declarations for XML data type support.
5  *
6  *
7  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/utils/xml.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 
15 #ifndef XML_H
16 #define XML_H
17 
18 #include "executor/tablefunc.h"
19 #include "fmgr.h"
20 #include "nodes/execnodes.h"
21 #include "nodes/primnodes.h"
22 
23 typedef struct varlena xmltype;
24 
25 typedef enum
26 {
32 
33 typedef enum
34 {
38 
39 typedef enum
40 {
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 */
46 
47 /* struct PgXmlErrorContext is private to xml.c */
49 
50 static inline xmltype *
52 {
53  return (xmltype *) PG_DETOAST_DATUM(X);
54 }
55 
56 static inline Datum
58 {
59  return PointerGetDatum(X);
60 }
61 
62 #define PG_GETARG_XML_P(n) DatumGetXmlP(PG_GETARG_DATUM(n))
63 #define PG_RETURN_XML_P(x) PG_RETURN_POINTER(x)
64 
65 extern void pg_xml_init_library(void);
67 extern void pg_xml_done(PgXmlErrorContext *errcxt, bool isError);
69 extern void xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode,
70  const char *msg);
71 
72 extern xmltype *xmlconcat(List *args);
73 extern xmltype *xmlelement(XmlExpr *xexpr,
74  Datum *named_argvalue, bool *named_argnull,
75  Datum *argvalue, bool *argnull);
76 extern xmltype *xmlparse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace);
77 extern xmltype *xmlpi(const char *target, text *arg, bool arg_is_null, bool *result_is_null);
78 extern xmltype *xmlroot(xmltype *data, text *version, int standalone);
79 extern bool xml_is_document(xmltype *arg);
80 extern text *xmltotext_with_xmloption(xmltype *data, XmlOptionType xmloption_arg);
81 extern char *escape_xml(const char *str);
82 
83 extern char *map_sql_identifier_to_xml_name(const char *ident, bool fully_escaped, bool escape_period);
84 extern char *map_xml_name_to_sql_identifier(const char *name);
85 extern char *map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings);
86 
87 extern PGDLLIMPORT int xmlbinary; /* XmlBinaryType, but int for guc enum */
88 
89 extern PGDLLIMPORT int xmloption; /* XmlOptionType, but int for guc enum */
90 
92 
93 #endif /* XML_H */
#define PGDLLIMPORT
Definition: c.h:1252
const char * name
Definition: encode.c:561
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:240
static struct @143 value
void * arg
const void * data
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:670
uintptr_t Datum
Definition: postgres.h:412
unsigned int Oid
Definition: postgres_ext.h:31
XmlOptionType
Definition: primnodes.h:1319
Definition: pg_list.h:52
Definition: c.h:623
XmlStandaloneType
Definition: xml.h:26
@ XML_STANDALONE_OMITTED
Definition: xml.h:30
@ XML_STANDALONE_NO_VALUE
Definition: xml.h:29
@ XML_STANDALONE_YES
Definition: xml.h:27
@ XML_STANDALONE_NO
Definition: xml.h:28
xmltype * xmlconcat(List *args)
Definition: xml.c:511
struct PgXmlErrorContext PgXmlErrorContext
Definition: xml.h:48
PGDLLIMPORT int xmloption
Definition: xml.c:98
static xmltype * DatumGetXmlP(Datum X)
Definition: xml.h:51
void xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode, const char *msg)
static Datum XmlPGetDatum(const xmltype *X)
Definition: xml.h:57
xmltype * xmlparse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace)
Definition: xml.c:751
char * map_sql_identifier_to_xml_name(const char *ident, bool fully_escaped, bool escape_period)
Definition: xml.c:2035
text * xmltotext_with_xmloption(xmltype *data, XmlOptionType xmloption_arg)
Definition: xml.c:614
PGDLLIMPORT int xmlbinary
Definition: xml.c:97
bool xml_is_document(xmltype *arg)
Definition: xml.c:887
bool pg_xml_error_occurred(PgXmlErrorContext *errcxt)
char * escape_xml(const char *str)
Definition: xml.c:2352
char * map_xml_name_to_sql_identifier(const char *name)
Definition: xml.c:2091
xmltype * xmlpi(const char *target, text *arg, bool arg_is_null, bool *result_is_null)
Definition: xml.c:769
void pg_xml_done(PgXmlErrorContext *errcxt, bool isError)
PgXmlErrorContext * pg_xml_init(PgXmlStrictness strictness)
PGDLLIMPORT const TableFuncRoutine XmlTableRoutine
Definition: xml.c:207
void pg_xml_init_library(void)
char * map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings)
Definition: xml.c:2133
xmltype * xmlelement(XmlExpr *xexpr, Datum *named_argvalue, bool *named_argnull, Datum *argvalue, bool *argnull)
Definition: xml.c:627
XmlBinaryType
Definition: xml.h:34
@ XMLBINARY_BASE64
Definition: xml.h:35
@ XMLBINARY_HEX
Definition: xml.h:36
xmltype * xmlroot(xmltype *data, text *version, int standalone)
Definition: xml.c:821
PgXmlStrictness
Definition: xml.h:40
@ PG_XML_STRICTNESS_LEGACY
Definition: xml.h:41
@ PG_XML_STRICTNESS_ALL
Definition: xml.h:44
@ PG_XML_STRICTNESS_WELLFORMED
Definition: xml.h:43