You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for the method .query() for XML data type (#4845)
Currently, Babelfish supports .exist() and .value() XML methods but .query() was unsupported and threw an error.
With this change, .query(xpath) is now supported and returns XML results (for XPath 1.0 compatible queries).
The implementation follows the same 3-stage architecture like .exist() and .value():
ANTLR rewriting: @x.query('/path') is rewritten to sys.bbf_xmlquery('/path', @x)
Grammar: BBF_XMLQUERY is mapped in gram-tsql-rule.y
PL/pgSQL function sys.bbf_xmlquery(): validates the input type, checks QUOTED_IDENTIFIER, calls PostgreSQL's
xpath(), and returns the result as XML
Task: BABEL-5224
Signed-off-by: Japleen Kaur <amjj@amazon.com>
Copy file name to clipboardExpand all lines: test/JDBC/expected/forxml-path-elements-before-17_10-or-18_4-vu-verify.out
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1116,9 +1116,10 @@ varchar
1116
1116
-- Using .query() method on XSINIL result
1117
1117
SELECT (SELECT ID, Name, Department FROM forxml_path_elements_t1 FOR XML PATH('Employee'), ROOT('Data'), ELEMENTS XSINIL, TYPE).query('/Data/Employee[1]') AS query_result;
1118
1118
GO
1119
-
~~ERROR (Code: 33557097)~~
1120
-
1121
-
~~ERROR (Message: 'XML QUERY' is not currently supported in Babelfish)~~
Copy file name to clipboardExpand all lines: test/JDBC/expected/forxml-path-elements-vu-verify.out
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1202,9 +1202,10 @@ varchar
1202
1202
-- Using .query() method on XSINIL result
1203
1203
SELECT (SELECT ID, Name, Department FROM forxml_path_elements_t1 FOR XML PATH('Employee'), ROOT('Data'), ELEMENTS XSINIL, TYPE).query('/Data/Employee[1]') AS query_result;
1204
1204
GO
1205
-
~~ERROR (Code: 33557097)~~
1206
-
1207
-
~~ERROR (Message: 'XML QUERY' is not currently supported in Babelfish)~~
0 commit comments