Bug #68934 extractValue does not work correctly with xpath last()
Submitted: 11 Apr 2013 14:21 Modified: 11 Apr 2013 20:19
Reporter: Zbyszek Wieczorek Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.6.10 OS:Any
Assigned to: CPU Architecture:Any
Tags: extractvalue xpath last()

[11 Apr 2013 14:21] Zbyszek Wieczorek
Description:
extractValue does not work correctly with xpath last()

How to repeat:
mysql> Select EXTRACTVALUE('<a><b><c>1</c></b><b><c>2</c></b><b><c>3</c></b></a>','//c');
+----------------------------------------------------------------------------+
| EXTRACTVALUE('<a><b><c>1</c></b><b><c>2</c></b><b><c>3</c></b></a>','//c') |
+----------------------------------------------------------------------------+
| 1 2 3                                                                      |
+----------------------------------------------------------------------------+
1 row in set (0.00 sec)

this works fine, but  combination  with xpath last() fails
mysql> Select EXTRACTVALUE('<a><b><c>1</c></b><b><c>2</c></b><b><c>3</c></b></a>','//c[last()]');
+------------------------------------------------------------------------------------+
| EXTRACTVALUE('<a><b><c>1</c></b><b><c>2</c></b><b><c>3</c></b></a>','//c[last()]') |
+------------------------------------------------------------------------------------+
|                                                                                    |
+------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

with simpler xml this wokrs fine

mysql> Select EXTRACTVALUE('<a><b><c>1</c></b><b><c>2</c></b><b><c>3</c></b></a>','//c[last()]');
+------------------------------------------------------------------------------------+
| EXTRACTVALUE('<a><b><c>1</c></b><b><c>2</c></b><b><c>3</c></b></a>','//c[last()]') |
+------------------------------------------------------------------------------------+
|                                                                                    |
+------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
[11 Apr 2013 14:22] Zbyszek Wieczorek
last example shoud be:

mysql> Select EXTRACTVALUE('<c>1</c><c>2</c><c>3</c>','//c[last()]');
+--------------------------------------------------------+
| EXTRACTVALUE('<c>1</c><c>2</c><c>3</c>','//c[last()]') |
+--------------------------------------------------------+
| 3                                                      |
+--------------------------------------------------------+
1 row in set (0.00 sec)
[11 Apr 2013 20:19] MySQL Verification Team
Thank you for the bug report. Verified as described.