xml.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*-------------------------------------------------------------------------
  2. *
  3. * xml.h
  4. * Declarations for XML data type support.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2016, 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. #ifndef XML_H
  15. #define XML_H
  16. #include "fmgr.h"
  17. #include "nodes/execnodes.h"
  18. #include "nodes/primnodes.h"
  19. typedef struct varlena xmltype;
  20. typedef enum
  21. {
  22. XML_STANDALONE_YES,
  23. XML_STANDALONE_NO,
  24. XML_STANDALONE_NO_VALUE,
  25. XML_STANDALONE_OMITTED
  26. } XmlStandaloneType;
  27. typedef enum
  28. {
  29. XMLBINARY_BASE64,
  30. XMLBINARY_HEX
  31. } XmlBinaryType;
  32. typedef enum
  33. {
  34. PG_XML_STRICTNESS_LEGACY, /* ignore errors unless function result
  35. * indicates error condition */
  36. PG_XML_STRICTNESS_WELLFORMED, /* ignore non-parser messages */
  37. PG_XML_STRICTNESS_ALL /* report all notices/warnings/errors */
  38. } PgXmlStrictness;
  39. /* struct PgXmlErrorContext is private to xml.c */
  40. typedef struct PgXmlErrorContext PgXmlErrorContext;
  41. #define DatumGetXmlP(X) ((xmltype *) PG_DETOAST_DATUM(X))
  42. #define XmlPGetDatum(X) PointerGetDatum(X)
  43. #define PG_GETARG_XML_P(n) DatumGetXmlP(PG_GETARG_DATUM(n))
  44. #define PG_RETURN_XML_P(x) PG_RETURN_POINTER(x)
  45. extern Datum xml_in(PG_FUNCTION_ARGS);
  46. extern Datum xml_out(PG_FUNCTION_ARGS);
  47. extern Datum xml_recv(PG_FUNCTION_ARGS);
  48. extern Datum xml_send(PG_FUNCTION_ARGS);
  49. extern Datum xmlcomment(PG_FUNCTION_ARGS);
  50. extern Datum xmlconcat2(PG_FUNCTION_ARGS);
  51. extern Datum texttoxml(PG_FUNCTION_ARGS);
  52. extern Datum xmltotext(PG_FUNCTION_ARGS);
  53. extern Datum xmlvalidate(PG_FUNCTION_ARGS);
  54. extern Datum xpath(PG_FUNCTION_ARGS);
  55. extern Datum xpath_exists(PG_FUNCTION_ARGS);
  56. extern Datum xmlexists(PG_FUNCTION_ARGS);
  57. extern Datum xml_is_well_formed(PG_FUNCTION_ARGS);
  58. extern Datum xml_is_well_formed_document(PG_FUNCTION_ARGS);
  59. extern Datum xml_is_well_formed_content(PG_FUNCTION_ARGS);
  60. extern Datum table_to_xml(PG_FUNCTION_ARGS);
  61. extern Datum query_to_xml(PG_FUNCTION_ARGS);
  62. extern Datum cursor_to_xml(PG_FUNCTION_ARGS);
  63. extern Datum table_to_xmlschema(PG_FUNCTION_ARGS);
  64. extern Datum query_to_xmlschema(PG_FUNCTION_ARGS);
  65. extern Datum cursor_to_xmlschema(PG_FUNCTION_ARGS);
  66. extern Datum table_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
  67. extern Datum query_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
  68. extern Datum schema_to_xml(PG_FUNCTION_ARGS);
  69. extern Datum schema_to_xmlschema(PG_FUNCTION_ARGS);
  70. extern Datum schema_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
  71. extern Datum database_to_xml(PG_FUNCTION_ARGS);
  72. extern Datum database_to_xmlschema(PG_FUNCTION_ARGS);
  73. extern Datum database_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
  74. extern void pg_xml_init_library(void);
  75. extern PgXmlErrorContext *pg_xml_init(PgXmlStrictness strictness);
  76. extern void pg_xml_done(PgXmlErrorContext *errcxt, bool isError);
  77. extern bool pg_xml_error_occurred(PgXmlErrorContext *errcxt);
  78. extern void xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode,
  79. const char *msg);
  80. extern xmltype *xmlconcat(List *args);
  81. extern xmltype *xmlelement(XmlExprState *xmlExpr, ExprContext *econtext);
  82. extern xmltype *xmlparse(text *data, XmlOptionType xmloption, bool preserve_whitespace);
  83. extern xmltype *xmlpi(char *target, text *arg, bool arg_is_null, bool *result_is_null);
  84. extern xmltype *xmlroot(xmltype *data, text *version, int standalone);
  85. extern bool xml_is_document(xmltype *arg);
  86. extern text *xmltotext_with_xmloption(xmltype *data, XmlOptionType xmloption_arg);
  87. extern char *escape_xml(const char *str);
  88. extern char *map_sql_identifier_to_xml_name(char *ident, bool fully_escaped, bool escape_period);
  89. extern char *map_xml_name_to_sql_identifier(char *name);
  90. extern char *map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings);
  91. extern int xmlbinary; /* XmlBinaryType, but int for guc enum */
  92. extern int xmloption; /* XmlOptionType, but int for guc enum */
  93. #endif /* XML_H */