[MDEV-5709] ExtractValue() with XPath variable references returns wrong result Created: 2014-02-20  Updated: 2022-12-02  Resolved: 2022-12-01

Status: Closed
Project: MariaDB Server
Component/s: N/A
Affects Version/s: 5.5.35
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Cannot Reproduce Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-5689 ExtractValue(xml, 'substring(/x,/y)')... Closed

 Description   

This script returns correct results:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT, b VARCHAR(10));
INSERT INTO t1 VALUES (1,'b1'),(2,'b2');
SELECT *,IF(@i:=a,ExtractValue('<a><b>b1</b><b>b2</b></a>','//b[$@i]'),0) AS xpath FROM t1;
+------+------+-------+
| a    | b    | xpath |
+------+------+-------+
|    1 | b1   | b1    |
|    2 | b2   | b2    |
+------+------+-------+
2 rows in set (0.00 sec)

If I move ExtractValue() from the SELECT list to the WHERE condition,
the results are not as expected:

mysql> SELECT * FROM t1 WHERE b=IF(@i:=a,ExtractValue('<a><b>b1</b><b>b2</b></a>','//b[$@i]'),0);
+------+------+
| a    | b    |
+------+------+
|    1 | b1   |
+------+------+
1 row in set (0.00 sec)

The expected result would be to return both rows.



 Comments   
Comment by Alexander Barkov [ 2014-03-23 ]

Pushed into 10.0 as a joint patch for MDEV-5689
TODO: backport to 5.5.

Comment by Alice Sherepa [ 2022-12-01 ]

10.3 4e9206736c4032069-10.10 return the correct result.

Generated at Thu Feb 08 07:06:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.