Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
334af053
Commit
334af053
authored
Apr 07, 2006
by
bar@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug#16319: XML: extractvalue() returns syntax errors for some functions
parent
3c2e84f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
1 deletion
+55
-1
mysql-test/r/xml.result
mysql-test/r/xml.result
+24
-0
mysql-test/t/xml.test
mysql-test/t/xml.test
+14
-0
sql/item_xmlfunc.cc
sql/item_xmlfunc.cc
+17
-1
No files found.
mysql-test/r/xml.result
View file @
334af053
...
@@ -468,6 +468,30 @@ extractValue(@xml, '/a/@b[substring(.,2,1)="1"]')
...
@@ -468,6 +468,30 @@ extractValue(@xml, '/a/@b[substring(.,2,1)="1"]')
select extractValue(@xml, '/a/@b[substring(.,2,1)="2"]');
select extractValue(@xml, '/a/@b[substring(.,2,1)="2"]');
extractValue(@xml, '/a/@b[substring(.,2,1)="2"]')
extractValue(@xml, '/a/@b[substring(.,2,1)="2"]')
12 22
12 22
SET @xml='<a><b>b1</b><b>b2</b></a>';
SELECT extractValue(@xml, '/a/b[string-length("x")=1]');
extractValue(@xml, '/a/b[string-length("x")=1]')
b1 b2
SELECT extractValue(@xml, '/a/b[string-length("xx")=2]');
extractValue(@xml, '/a/b[string-length("xx")=2]')
b1 b2
SELECT extractValue(@xml, '/a/b[string-length("xxx")=2]');
extractValue(@xml, '/a/b[string-length("xxx")=2]')
SELECT extractValue(@xml, '/a/b[string-length("x")]');
extractValue(@xml, '/a/b[string-length("x")]')
b1
SELECT extractValue(@xml, '/a/b[string-length("xx")]');
extractValue(@xml, '/a/b[string-length("xx")]')
b2
SELECT extractValue(@xml, '/a/b[string-length()]');
extractValue(@xml, '/a/b[string-length()]')
b2
SELECT extractValue(@xml, 'string-length()');
ERROR HY000: XPATH syntax error: ''
SELECT extractValue(@xml, 'string-length("x")');
extractValue(@xml, 'string-length("x")')
1
SET @xml='<a b="b11" b="b12" b="b21" b="22"/>';
SET @xml='<a b="b11" b="b12" b="b21" b="22"/>';
select extractValue(@xml,'/a/@b');
select extractValue(@xml,'/a/@b');
extractValue(@xml,'/a/@b')
extractValue(@xml,'/a/@b')
...
...
mysql-test/t/xml.test
View file @
334af053
...
@@ -192,6 +192,20 @@ select extractValue(@xml, '/a/@b[substring(.,1,1)="2"]');
...
@@ -192,6 +192,20 @@ select extractValue(@xml, '/a/@b[substring(.,1,1)="2"]');
select
extractValue
(
@
xml
,
'/a/@b[substring(.,2,1)="1"]'
);
select
extractValue
(
@
xml
,
'/a/@b[substring(.,2,1)="1"]'
);
select
extractValue
(
@
xml
,
'/a/@b[substring(.,2,1)="2"]'
);
select
extractValue
(
@
xml
,
'/a/@b[substring(.,2,1)="2"]'
);
#
# Bug#16319: XML: extractvalue() returns syntax errors for some functions
#
SET
@
xml
=
'<a><b>b1</b><b>b2</b></a>'
;
SELECT
extractValue
(
@
xml
,
'/a/b[string-length("x")=1]'
);
SELECT
extractValue
(
@
xml
,
'/a/b[string-length("xx")=2]'
);
SELECT
extractValue
(
@
xml
,
'/a/b[string-length("xxx")=2]'
);
SELECT
extractValue
(
@
xml
,
'/a/b[string-length("x")]'
);
SELECT
extractValue
(
@
xml
,
'/a/b[string-length("xx")]'
);
SELECT
extractValue
(
@
xml
,
'/a/b[string-length()]'
);
--
error
1105
SELECT
extractValue
(
@
xml
,
'string-length()'
);
SELECT
extractValue
(
@
xml
,
'string-length("x")'
);
SET
@
xml
=
'<a b="b11" b="b12" b="b21" b="22"/>'
;
SET
@
xml
=
'<a b="b11" b="b12" b="b21" b="22"/>'
;
select
extractValue
(
@
xml
,
'/a/@b'
);
select
extractValue
(
@
xml
,
'/a/@b'
);
select
extractValue
(
@
xml
,
'/a/@b[contains(.,"1")]'
);
select
extractValue
(
@
xml
,
'/a/@b[contains(.,"1")]'
);
...
...
sql/item_xmlfunc.cc
View file @
334af053
...
@@ -1133,6 +1133,13 @@ static Item *create_func_number(MY_XPATH *xpath, Item **args, uint nargs)
...
@@ -1133,6 +1133,13 @@ static Item *create_func_number(MY_XPATH *xpath, Item **args, uint nargs)
}
}
static
Item
*
create_func_string_length
(
MY_XPATH
*
xpath
,
Item
**
args
,
uint
nargs
)
{
Item
*
arg
=
nargs
?
args
[
0
]
:
xpath
->
context
;
return
arg
?
new
Item_func_char_length
(
arg
)
:
0
;
}
static
Item
*
create_func_round
(
MY_XPATH
*
xpath
,
Item
**
args
,
uint
nargs
)
static
Item
*
create_func_round
(
MY_XPATH
*
xpath
,
Item
**
args
,
uint
nargs
)
{
{
return
new
Item_func_round
(
args
[
0
],
new
Item_int
((
char
*
)
"0"
,
0
,
1
),
0
);
return
new
Item_func_round
(
args
[
0
],
new
Item_int
((
char
*
)
"0"
,
0
,
1
),
0
);
...
@@ -1243,9 +1250,11 @@ static MY_XPATH_FUNC my_func_names[] =
...
@@ -1243,9 +1250,11 @@ static MY_XPATH_FUNC my_func_names[] =
{
"substring"
,
9
,
2
,
3
,
create_func_substr
},
{
"substring"
,
9
,
2
,
3
,
create_func_substr
},
{
"translate"
,
9
,
3
,
3
,
0
},
{
"translate"
,
9
,
3
,
3
,
0
},
{
"local-name"
,
10
,
0
,
1
,
0
},
{
"local-name"
,
10
,
0
,
1
,
0
},
{
"starts-with"
,
11
,
2
,
2
,
0
},
{
"starts-with"
,
11
,
2
,
2
,
0
},
{
"namespace-uri"
,
13
,
0
,
1
,
0
},
{
"namespace-uri"
,
13
,
0
,
1
,
0
},
{
"string-length"
,
13
,
0
,
1
,
create_func_string_length
},
{
"substring-after"
,
15
,
2
,
2
,
0
},
{
"substring-after"
,
15
,
2
,
2
,
0
},
{
"normalize-space"
,
15
,
0
,
1
,
0
},
{
"normalize-space"
,
15
,
0
,
1
,
0
},
{
"substring-before"
,
16
,
2
,
2
,
0
},
{
"substring-before"
,
16
,
2
,
2
,
0
},
...
@@ -1849,7 +1858,12 @@ static int my_xpath_parse_FunctionCall(MY_XPATH *xpath)
...
@@ -1849,7 +1858,12 @@ static int my_xpath_parse_FunctionCall(MY_XPATH *xpath)
for
(
nargs
=
0
;
nargs
<
func
->
maxargs
;
)
for
(
nargs
=
0
;
nargs
<
func
->
maxargs
;
)
{
{
if
(
!
my_xpath_parse_Expr
(
xpath
))
if
(
!
my_xpath_parse_Expr
(
xpath
))
return
0
;
{
if
(
nargs
<
func
->
minargs
)
return
0
;
else
goto
right_paren
;
}
args
[
nargs
++
]
=
xpath
->
item
;
args
[
nargs
++
]
=
xpath
->
item
;
if
(
!
my_xpath_parse_term
(
xpath
,
MY_XPATH_LEX_COMMA
))
if
(
!
my_xpath_parse_term
(
xpath
,
MY_XPATH_LEX_COMMA
))
{
{
...
@@ -1859,6 +1873,8 @@ static int my_xpath_parse_FunctionCall(MY_XPATH *xpath)
...
@@ -1859,6 +1873,8 @@ static int my_xpath_parse_FunctionCall(MY_XPATH *xpath)
break
;
break
;
}
}
}
}
right_paren:
if
(
!
my_xpath_parse_term
(
xpath
,
MY_XPATH_LEX_RP
))
if
(
!
my_xpath_parse_term
(
xpath
,
MY_XPATH_LEX_RP
))
return
0
;
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment