Skip to content

Commit 3444c14

Browse files
authored
Added wrapper around XML functions to support OPENXML without WITH clause (#622)
To add support for OPENXML without WITH clause in Babelfish, we need following functions xml_parse(...), pg_xmlCharStrndup(...) and parse_xml_decl(...). Although these functions are defined as static on engine side. And in order to facilitate support for OPENXML without WITH clause, This commit added wrapper functions. Extension PR: babelfish-for-postgresql/babelfish_extensions#4091 Task: BABEL-6046 Signed-off-by: Rohit Bhagat <[email protected]>
1 parent 3e22092 commit 3444c14

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/backend/utils/adt/xml.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5114,3 +5114,28 @@ XmlTableDestroyOpaque(TableFuncScanState *state)
51145114
NO_XML_SUPPORT();
51155115
#endif /* not USE_LIBXML */
51165116
}
5117+
5118+
#ifdef USE_LIBXML
5119+
xmlDocPtr
5120+
xml_parse_wrapper(text *data, XmlOptionType xmloption_arg,
5121+
bool preserve_whitespace, int encoding,
5122+
XmlOptionType *parsed_xmloptiontype, xmlNodePtr *parsed_nodes,
5123+
Node *escontext)
5124+
{
5125+
return xml_parse(data, xmloption_arg, preserve_whitespace,
5126+
encoding, parsed_xmloptiontype, parsed_nodes, escontext);
5127+
}
5128+
5129+
xmlChar *
5130+
pg_xmlCharStrndup_wrapper(const char *str, size_t len)
5131+
{
5132+
return pg_xmlCharStrndup(str, len);
5133+
}
5134+
5135+
int
5136+
parse_xml_decl_wrapper(const xmlChar *str, size_t *lenp,
5137+
xmlChar **version, xmlChar **encoding, int *standalone)
5138+
{
5139+
return parse_xml_decl(str, lenp, version, encoding, standalone);
5140+
}
5141+
#endif /* USE_LIBXML */

src/include/utils/xml.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include "fmgr.h"
2020
#include "nodes/execnodes.h"
2121
#include "nodes/primnodes.h"
22+
#ifdef USE_LIBXML
23+
#include <libxml/tree.h>
24+
#endif
2225

2326
typedef struct varlena xmltype;
2427

@@ -85,6 +88,16 @@ extern char *map_sql_identifier_to_xml_name(const char *ident, bool fully_escape
8588
extern char *map_xml_name_to_sql_identifier(const char *name);
8689
extern char *map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings);
8790

91+
#ifdef USE_LIBXML
92+
extern xmlDocPtr xml_parse_wrapper(text *data, XmlOptionType xmloption_arg,
93+
bool preserve_whitespace, int encoding,
94+
XmlOptionType *parsed_xmloptiontype, xmlNodePtr *parsed_nodes,
95+
Node *escontext);
96+
extern xmlChar *pg_xmlCharStrndup_wrapper(const char *str, size_t len);
97+
extern int parse_xml_decl_wrapper(const xmlChar *str, size_t *lenp,
98+
xmlChar **version, xmlChar **encoding, int *standalone);
99+
#endif /* USE_LIBXML */
100+
88101
extern PGDLLIMPORT int xmlbinary; /* XmlBinaryType, but int for guc enum */
89102

90103
extern PGDLLIMPORT int xmloption; /* XmlOptionType, but int for guc enum */

0 commit comments

Comments
 (0)