Skip to content

Commit 4a920c5

Browse files
authored
Merge pull request IvorySQL#1222 from NotHimmel/IVORY_REL_5_STABLE
Add two-argument and three-argument EXTRACT function forms to grammar
2 parents 4dfba1d + 31801a4 commit 4a920c5

2 files changed

Lines changed: 68 additions & 30 deletions

File tree

contrib/ivorysql_ora/expected/ora_xml_functions.out

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,69 @@ INSERT INTO xmlnstest VALUES(1, xmltype('<soapenv:Envelope xmlns:soapenv="http:/
2727
-- extrct(XML)
2828
--
2929
SELECT extract(XMLType('<AA><ID>1</ID></AA>'), '/AA/ID') from dual;
30-
ERROR: syntax error at or near "("
31-
LINE 1: SELECT extract(XMLType('<AA><ID>1</ID></AA>'), '/AA/ID') fro...
32-
^
30+
extract
31+
------------
32+
<ID>1</ID>
33+
(1 row)
34+
3335
SELECT extract(XMLType('<AA><ID>1</ID></AA>'), '/AA') from dual;
34-
ERROR: syntax error at or near "("
35-
LINE 1: SELECT extract(XMLType('<AA><ID>1</ID></AA>'), '/AA') from d...
36-
^
36+
extract
37+
--------------
38+
<AA> +
39+
<ID>1</ID>+
40+
</AA>
41+
(1 row)
42+
3743
SELECT extract(XMLType('<Co Attr ="Test Attr"><ID>1</ID></Co>'), '/Co') from dual;
38-
ERROR: syntax error at or near "("
39-
LINE 1: SELECT extract(XMLType('<Co Attr ="Test Attr"><ID>1</ID></Co...
40-
^
44+
extract
45+
-----------------------
46+
<Co Attr="Test Attr">+
47+
<ID>1</ID> +
48+
</Co>
49+
(1 row)
50+
4151
SELECT extract(XMLType('<Co Attr ="Test Attr"><ID>1</ID></Co>'), '/Co/@ Attr') from dual;
42-
ERROR: syntax error at or near "("
43-
LINE 1: SELECT extract(XMLType('<Co Attr ="Test Attr"><ID>1</ID></Co...
44-
^
52+
extract
53+
-----------
54+
Test Attr
55+
(1 row)
56+
4557
SELECT extract(XMLType('<a><b>b1</b><b>b2</b></a>'),'/a/b[2]') from dual;
46-
ERROR: syntax error at or near "("
47-
LINE 1: SELECT extract(XMLType('<a><b>b1</b><b>b2</b></a>'),'/a/b[2]...
48-
^
58+
extract
59+
-----------
60+
<b>b2</b>
61+
(1 row)
62+
4963
SELECT extract(XMLType('<a><b>b1</b><b>b2</b></a>'),'/a/b[3]') from dual;
50-
ERROR: syntax error at or near "("
51-
LINE 1: SELECT extract(XMLType('<a><b>b1</b><b>b2</b></a>'),'/a/b[3]...
52-
^
64+
extract
65+
---------
66+
67+
(1 row)
68+
5369
SELECT extract(b, '/a/b') from inaf where a = 2;
54-
ERROR: syntax error at or near ","
55-
LINE 1: SELECT extract(b, '/a/b') from inaf where a = 2;
56-
^
70+
extract
71+
---------
72+
73+
(1 row)
74+
5775
SELECT extract(XMLType('<a><b>b1</b><b>b2</b></a>'),'') from dual;
58-
ERROR: syntax error at or near "("
59-
LINE 1: SELECT extract(XMLType('<a><b>b1</b><b>b2</b></a>'),'') from...
60-
^
76+
extract
77+
---------
78+
79+
(1 row)
80+
6181
SELECT extract(XMLType('<a><b>b1</b><b>b2</b></a>'),null) from dual;
62-
ERROR: syntax error at or near "("
63-
LINE 1: SELECT extract(XMLType('<a><b>b1</b><b>b2</b></a>'),null) fr...
64-
^
82+
extract
83+
---------
84+
85+
(1 row)
86+
6587
SELECT extract(data, 'soapenv:Envelope/soapenv:Body/web:BBB/typ:EEE', 'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://www.def.com" xmlns:web="http://www.abc.com"') from xmlnstest where id = 1;
66-
ERROR: syntax error at or near "data"
67-
LINE 1: SELECT extract(data, 'soapenv:Envelope/soapenv:Body/web:BBB/...
68-
^
88+
extract
89+
------------------------------------------------------
90+
<typ:EEE xmlns:typ="http://www.def.com">41</typ:EEE>
91+
(1 row)
92+
6993
--
7094
-- extractvalue
7195
--

src/backend/oracle_parser/ora_gram.y

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18025,6 +18025,20 @@ func_expr_common_subexpr:
1802518025
COERCE_SQL_SYNTAX,
1802618026
@1);
1802718027
}
18028+
| EXTRACT '(' a_expr ',' a_expr ')'
18029+
{
18030+
$$ = (Node *) makeFuncCall(list_make1(makeString("extract")),
18031+
list_make2($3, $5),
18032+
COERCE_EXPLICIT_CALL,
18033+
@1);
18034+
}
18035+
| EXTRACT '(' a_expr ',' a_expr ',' a_expr ')'
18036+
{
18037+
$$ = (Node *) makeFuncCall(list_make1(makeString("extract")),
18038+
list_make3($3, $5, $7),
18039+
COERCE_EXPLICIT_CALL,
18040+
@1);
18041+
}
1802818042
/* End - ReqID:SRS-SQL-XML */
1802918043
| NORMALIZE '(' a_expr ')'
1803018044
{

0 commit comments

Comments
 (0)