1
SET @xml='<a aa1="aa1" aa2="aa2">a1<b ba1="ba1">b1<c>c1</c>b2</b>a2</a>';
2
SELECT extractValue(@xml,'/a');
3
extractValue(@xml,'/a')
5
SELECT extractValue(@xml,'/a/b');
6
extractValue(@xml,'/a/b')
8
SELECT extractValue(@xml,'/a/b/c');
9
extractValue(@xml,'/a/b/c')
11
SELECT extractValue(@xml,'/a/@aa1');
12
extractValue(@xml,'/a/@aa1')
14
SELECT extractValue(@xml,'/a/@aa2');
15
extractValue(@xml,'/a/@aa2')
17
SELECT extractValue(@xml,'/a/@*');
18
extractValue(@xml,'/a/@*')
20
SELECT extractValue(@xml,'//@ba1');
21
extractValue(@xml,'//@ba1')
23
SELECT extractValue(@xml,'//a');
24
extractValue(@xml,'//a')
26
SELECT extractValue(@xml,'//b');
27
extractValue(@xml,'//b')
29
SELECT extractValue(@xml,'//c');
30
extractValue(@xml,'//c')
32
SELECT extractValue(@xml,'/a//b');
33
extractValue(@xml,'/a//b')
35
SELECT extractValue(@xml,'/a//c');
36
extractValue(@xml,'/a//c')
38
SELECT extractValue(@xml,'//*');
39
extractValue(@xml,'//*')
41
SELECT extractValue(@xml,'/a//*');
42
extractValue(@xml,'/a//*')
44
SELECT extractValue(@xml,'/./a');
45
extractValue(@xml,'/./a')
47
SELECT extractValue(@xml,'/a/b/.');
48
extractValue(@xml,'/a/b/.')
50
SELECT extractValue(@xml,'/a/b/..');
51
extractValue(@xml,'/a/b/..')
53
SELECT extractValue(@xml,'/a/b/../@aa1');
54
extractValue(@xml,'/a/b/../@aa1')
56
SELECT extractValue(@xml,'/*');
57
extractValue(@xml,'/*')
59
SELECT extractValue(@xml,'/*/*');
60
extractValue(@xml,'/*/*')
62
SELECT extractValue(@xml,'/*/*/*');
63
extractValue(@xml,'/*/*/*')
65
SELECT extractValue(@xml,'/a/child::*');
66
extractValue(@xml,'/a/child::*')
68
SELECT extractValue(@xml,'/a/self::*');
69
extractValue(@xml,'/a/self::*')
71
SELECT extractValue(@xml,'/a/descendant::*');
72
extractValue(@xml,'/a/descendant::*')
74
SELECT extractValue(@xml,'/a/descendant-or-self::*');
75
extractValue(@xml,'/a/descendant-or-self::*')
77
SELECT extractValue(@xml,'/a/attribute::*');
78
extractValue(@xml,'/a/attribute::*')
80
SELECT extractValue(@xml,'/a/b/c/parent::*');
81
extractValue(@xml,'/a/b/c/parent::*')
83
SELECT extractValue(@xml,'/a/b/c/ancestor::*');
84
extractValue(@xml,'/a/b/c/ancestor::*')
86
SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*');
87
extractValue(@xml,'/a/b/c/ancestor-or-self::*')
89
SELECT extractValue(@xml,'/descendant-or-self::*');
90
extractValue(@xml,'/descendant-or-self::*')
92
SET @xml='<a>a11<b ba="ba11" ba="ba12">b11</b><b ba="ba21" ba="ba22">b21<c>c1</c>b22</b>a12</a>';
93
SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*');
94
extractValue(@xml,'/a/b/c/ancestor-or-self::*')
96
SELECT extractValue(@xml,'//@ba');
97
extractValue(@xml,'//@ba')
99
SET @xml='<a><b>b</b><c>c</c></a>';
100
SELECT extractValue(@xml,'/a/b');
101
extractValue(@xml,'/a/b')
103
SELECT extractValue(@xml,'/a/c');
104
extractValue(@xml,'/a/c')
106
SELECT extractValue(@xml,'/a/child::b');
107
extractValue(@xml,'/a/child::b')
109
SELECT extractValue(@xml,'/a/child::c');
110
extractValue(@xml,'/a/child::c')
112
SET @xml='<a><b>b1</b><c>c1</c><b>b2</b><c>c2</c></a>';
113
SELECT extractValue(@xml,'/a/b[1]');
114
extractValue(@xml,'/a/b[1]')
116
SELECT extractValue(@xml,'/a/b[2]');
117
extractValue(@xml,'/a/b[2]')
119
SELECT extractValue(@xml,'/a/c[1]');
120
extractValue(@xml,'/a/c[1]')
122
SELECT extractValue(@xml,'/a/c[2]');
123
extractValue(@xml,'/a/c[2]')
125
SET @xml='<a><b x="xb1" x="xb2"/><c x="xc1" x="xc2"/></a>';
126
SELECT extractValue(@xml,'/a//@x');
127
extractValue(@xml,'/a//@x')
129
SELECT extractValue(@xml,'/a//@x[1]');
130
extractValue(@xml,'/a//@x[1]')
132
SELECT extractValue(@xml,'/a//@x[2]');
133
extractValue(@xml,'/a//@x[2]')
135
SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b></a>';
136
SELECT extractValue(@xml,'//b[1]');
137
extractValue(@xml,'//b[1]')
139
SELECT extractValue(@xml,'/descendant::b[1]');
140
extractValue(@xml,'/descendant::b[1]')
142
SET @xml='<a><b>b1</b><b>b2</b></a>';
143
SELECT extractValue(@xml,'/a/b[1+0]');
144
extractValue(@xml,'/a/b[1+0]')
146
SELECT extractValue(@xml,'/a/b[1*1]');
147
extractValue(@xml,'/a/b[1*1]')
149
SELECT extractValue(@xml,'/a/b[--1]');
150
extractValue(@xml,'/a/b[--1]')
152
SELECT extractValue(@xml,'/a/b[2*1-1]');
153
extractValue(@xml,'/a/b[2*1-1]')
155
SELECT extractValue(@xml,'/a/b[1+1]');
156
extractValue(@xml,'/a/b[1+1]')
158
SELECT extractValue(@xml,'/a/b[1*2]');
159
extractValue(@xml,'/a/b[1*2]')
161
SELECT extractValue(@xml,'/a/b[--2]');
162
extractValue(@xml,'/a/b[--2]')
164
SELECT extractValue(@xml,'/a/b[1*(3-1)]');
165
extractValue(@xml,'/a/b[1*(3-1)]')
167
SELECT extractValue(@xml,'//*[1=1]');
168
extractValue(@xml,'//*[1=1]')
170
SELECT extractValue(@xml,'//*[1!=1]');
171
extractValue(@xml,'//*[1!=1]')
173
SELECT extractValue(@xml,'//*[1>1]');
174
extractValue(@xml,'//*[1>1]')
176
SELECT extractValue(@xml,'//*[2>1]');
177
extractValue(@xml,'//*[2>1]')
179
SELECT extractValue(@xml,'//*[1>2]');
180
extractValue(@xml,'//*[1>2]')
182
SELECT extractValue(@xml,'//*[1>=1]');
183
extractValue(@xml,'//*[1>=1]')
185
SELECT extractValue(@xml,'//*[2>=1]');
186
extractValue(@xml,'//*[2>=1]')
188
SELECT extractValue(@xml,'//*[1>=2]');
189
extractValue(@xml,'//*[1>=2]')
191
SELECT extractValue(@xml,'//*[1<1]');
192
extractValue(@xml,'//*[1<1]')
194
SELECT extractValue(@xml,'//*[2<1]');
195
extractValue(@xml,'//*[2<1]')
197
SELECT extractValue(@xml,'//*[1<2]');
198
extractValue(@xml,'//*[1<2]')
200
SELECT extractValue(@xml,'//*[1<=1]');
201
extractValue(@xml,'//*[1<=1]')
203
SELECT extractValue(@xml,'//*[2<=1]');
204
extractValue(@xml,'//*[2<=1]')
206
SELECT extractValue(@xml,'//*[1<=2]');
207
extractValue(@xml,'//*[1<=2]')
209
SET @xml='<a><b>b11<c>c11</c></b><b>b21<c>c21</c></b></a>';
210
SELECT extractValue(@xml,'/a/b[c="c11"]');
211
extractValue(@xml,'/a/b[c="c11"]')
213
SELECT extractValue(@xml,'/a/b[c="c21"]');
214
extractValue(@xml,'/a/b[c="c21"]')
216
SET @xml='<a><b c="c11">b11</b><b c="c21">b21</b></a>';
217
SELECT extractValue(@xml,'/a/b[@c="c11"]');
218
extractValue(@xml,'/a/b[@c="c11"]')
220
SELECT extractValue(@xml,'/a/b[@c="c21"]');
221
extractValue(@xml,'/a/b[@c="c21"]')
223
SET @xml='<a>a1<b c="c11">b11<d>d11</d></b><b c="c21">b21<d>d21</d></b></a>';
224
SELECT extractValue(@xml, '/a/b[@c="c11"]/d');
225
extractValue(@xml, '/a/b[@c="c11"]/d')
227
SELECT extractValue(@xml, '/a/b[@c="c21"]/d');
228
extractValue(@xml, '/a/b[@c="c21"]/d')
230
SELECT extractValue(@xml, '/a/b[d="d11"]/@c');
231
extractValue(@xml, '/a/b[d="d11"]/@c')
233
SELECT extractValue(@xml, '/a/b[d="d21"]/@c');
234
extractValue(@xml, '/a/b[d="d21"]/@c')
236
SELECT extractValue(@xml, '/a[b="b11"]');
237
extractValue(@xml, '/a[b="b11"]')
239
SELECT extractValue(@xml, '/a[b/@c="c11"]');
240
extractValue(@xml, '/a[b/@c="c11"]')
242
SELECT extractValue(@xml, '/a[b/d="d11"]');
243
extractValue(@xml, '/a[b/d="d11"]')
245
SELECT extractValue(@xml, '/a[/a/b="b11"]');
246
extractValue(@xml, '/a[/a/b="b11"]')
248
SELECT extractValue(@xml, '/a[/a/b/@c="c11"]');
249
extractValue(@xml, '/a[/a/b/@c="c11"]')
251
SELECT extractValue(@xml, '/a[/a/b/d="d11"]');
252
extractValue(@xml, '/a[/a/b/d="d11"]')
254
SELECT extractValue('<a>a</a>', '/a[false()]');
255
extractValue('<a>a</a>', '/a[false()]')
257
SELECT extractValue('<a>a</a>', '/a[true()]');
258
extractValue('<a>a</a>', '/a[true()]')
260
SELECT extractValue('<a>a</a>', '/a[not(false())]');
261
extractValue('<a>a</a>', '/a[not(false())]')
263
SELECT extractValue('<a>a</a>', '/a[not(true())]');
264
extractValue('<a>a</a>', '/a[not(true())]')
266
SELECT extractValue('<a>a</a>', '/a[true() and true()]');
267
extractValue('<a>a</a>', '/a[true() and true()]')
269
SELECT extractValue('<a>a</a>', '/a[true() and false()]');
270
extractValue('<a>a</a>', '/a[true() and false()]')
272
SELECT extractValue('<a>a</a>', '/a[false()and false()]');
273
extractValue('<a>a</a>', '/a[false()and false()]')
275
SELECT extractValue('<a>a</a>', '/a[false()and true()]');
276
extractValue('<a>a</a>', '/a[false()and true()]')
278
SELECT extractValue('<a>a</a>', '/a[true() or true()]');
279
extractValue('<a>a</a>', '/a[true() or true()]')
281
SELECT extractValue('<a>a</a>', '/a[true() or false()]');
282
extractValue('<a>a</a>', '/a[true() or false()]')
284
SELECT extractValue('<a>a</a>', '/a[false()or false()]');
285
extractValue('<a>a</a>', '/a[false()or false()]')
287
SELECT extractValue('<a>a</a>', '/a[false()or true()]');
288
extractValue('<a>a</a>', '/a[false()or true()]')
290
SET @xml='<a>ab<b c="c" c="e">b1</b><b c="d">b2</b><b c="f" c="e">b3</b></a>';
291
select extractValue(@xml,'/a/b[@c="c"]');
292
extractValue(@xml,'/a/b[@c="c"]')
294
select extractValue(@xml,'/a/b[@c="d"]');
295
extractValue(@xml,'/a/b[@c="d"]')
297
select extractValue(@xml,'/a/b[@c="e"]');
298
extractValue(@xml,'/a/b[@c="e"]')
300
select extractValue(@xml,'/a/b[not(@c="e")]');
301
extractValue(@xml,'/a/b[not(@c="e")]')
303
select extractValue(@xml,'/a/b[@c!="e"]');
304
extractValue(@xml,'/a/b[@c!="e"]')
306
select extractValue(@xml,'/a/b[@c="c" or @c="d"]');
307
extractValue(@xml,'/a/b[@c="c" or @c="d"]')
309
select extractValue(@xml,'/a/b[@c="c" and @c="e"]');
310
extractValue(@xml,'/a/b[@c="c" and @c="e"]')
312
SET @xml='<a><b c="c" d="d">b1</b><b d="d" e="e">b2</b></a>';
313
select extractValue(@xml,'/a/b[@c]');
314
extractValue(@xml,'/a/b[@c]')
316
select extractValue(@xml,'/a/b[@d]');
317
extractValue(@xml,'/a/b[@d]')
319
select extractValue(@xml,'/a/b[@e]');
320
extractValue(@xml,'/a/b[@e]')
322
select extractValue(@xml,'/a/b[not(@c)]');
323
extractValue(@xml,'/a/b[not(@c)]')
325
select extractValue(@xml,'/a/b[not(@d)]');
326
extractValue(@xml,'/a/b[not(@d)]')
328
select extractValue(@xml,'/a/b[not(@e)]');
329
extractValue(@xml,'/a/b[not(@e)]')
331
select extractValue(@xml, '/a/b[boolean(@c) or boolean(@d)]');
332
extractValue(@xml, '/a/b[boolean(@c) or boolean(@d)]')
334
select extractValue(@xml, '/a/b[boolean(@c) or boolean(@e)]');
335
extractValue(@xml, '/a/b[boolean(@c) or boolean(@e)]')
337
select extractValue(@xml, '/a/b[boolean(@d) or boolean(@e)]');
338
extractValue(@xml, '/a/b[boolean(@d) or boolean(@e)]')
340
select extractValue(@xml, '/a/b[boolean(@c) and boolean(@d)]');
341
extractValue(@xml, '/a/b[boolean(@c) and boolean(@d)]')
343
select extractValue(@xml, '/a/b[boolean(@c) and boolean(@e)]');
344
extractValue(@xml, '/a/b[boolean(@c) and boolean(@e)]')
346
select extractValue(@xml, '/a/b[boolean(@d) and boolean(@e)]');
347
extractValue(@xml, '/a/b[boolean(@d) and boolean(@e)]')
349
select extractValue(@xml, '/a/b[@c or @d]');
350
extractValue(@xml, '/a/b[@c or @d]')
352
select extractValue(@xml, '/a/b[@c or @e]');
353
extractValue(@xml, '/a/b[@c or @e]')
355
select extractValue(@xml, '/a/b[@d or @e]');
356
extractValue(@xml, '/a/b[@d or @e]')
358
select extractValue(@xml, '/a/b[@c and @d]');
359
extractValue(@xml, '/a/b[@c and @d]')
361
select extractValue(@xml, '/a/b[@c and @e]');
362
extractValue(@xml, '/a/b[@c and @e]')
364
select extractValue(@xml, '/a/b[@d and @e]');
365
extractValue(@xml, '/a/b[@d and @e]')
367
SET @xml='<a><b c="c">b1</b><b>b2</b></a>';
368
SELECT extractValue(@xml,'/a/b[@*]');
369
extractValue(@xml,'/a/b[@*]')
371
SELECT extractValue(@xml,'/a/b[not(@*)]');
372
extractValue(@xml,'/a/b[not(@*)]')
374
SELECT extractValue('<a>a</a>', '/a[ceiling(3.1)=4]');
375
extractValue('<a>a</a>', '/a[ceiling(3.1)=4]')
377
SELECT extractValue('<a>a</a>', '/a[floor(3.1)=3]');
378
extractValue('<a>a</a>', '/a[floor(3.1)=3]')
380
SELECT extractValue('<a>a</a>', '/a[round(3.1)=3]');
381
extractValue('<a>a</a>', '/a[round(3.1)=3]')
383
SELECT extractValue('<a>a</a>', '/a[round(3.8)=4]');
384
extractValue('<a>a</a>', '/a[round(3.8)=4]')
386
SELECT extractValue('<a><b>b</b><c>c</c></a>', '/a/b | /a/c');
387
extractValue('<a><b>b</b><c>c</c></a>', '/a/b | /a/c')
389
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=1]');
390
extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=1]')
392
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=2]');
393
extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=2]')
395
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3]');
396
extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3]')
398
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[1=position()]');
399
extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[1=position()]')
401
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2=position()]');
402
extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2=position()]')
404
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[3=position()]');
405
extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[3=position()]')
407
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2>=position()]');
408
extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2>=position()]')
410
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2<=position()]');
411
extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2<=position()]')
413
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3 or position()=2]');
414
extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3 or position()=2]')
416
SELECT extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=0]');
417
extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=0]')
419
SELECT extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=1]');
420
extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=1]')
422
select extractValue('<a>a1<b ba="1" ba="2">b1</b><b>b2</b>4</a>','/a/b[sum(@ba)=3]');
423
extractValue('<a>a1<b ba="1" ba="2">b1</b><b>b2</b>4</a>','/a/b[sum(@ba)=3]')
425
select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[1]');
426
extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[1]')
428
select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[boolean(1)]');
429
extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[boolean(1)]')
431
select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[true()]');
432
extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[true()]')
434
select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[number(true())]');
435
extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[number(true())]')
437
select extractValue('<a>ab</a>','/a[contains("abc","b")]');
438
extractValue('<a>ab</a>','/a[contains("abc","b")]')
440
select extractValue('<a>ab</a>','/a[contains(.,"a")]');
441
extractValue('<a>ab</a>','/a[contains(.,"a")]')
443
select extractValue('<a>ab</a>','/a[contains(.,"b")]');
444
extractValue('<a>ab</a>','/a[contains(.,"b")]')
446
select extractValue('<a>ab</a>','/a[contains(.,"c")]');
447
extractValue('<a>ab</a>','/a[contains(.,"c")]')
449
select extractValue('<a b="1">ab</a>','/a[concat(@b,"2")="12"]');
450
extractValue('<a b="1">ab</a>','/a[concat(@b,"2")="12"]')
452
SET @xml='<a b="11" b="12" b="21" b="22">ab</a>';
453
select extractValue(@xml, '/a/@b[substring(.,2)="1"]');
454
extractValue(@xml, '/a/@b[substring(.,2)="1"]')
456
select extractValue(@xml, '/a/@b[substring(.,2)="2"]');
457
extractValue(@xml, '/a/@b[substring(.,2)="2"]')
459
select extractValue(@xml, '/a/@b[substring(.,1,1)="1"]');
460
extractValue(@xml, '/a/@b[substring(.,1,1)="1"]')
462
select extractValue(@xml, '/a/@b[substring(.,1,1)="2"]');
463
extractValue(@xml, '/a/@b[substring(.,1,1)="2"]')
465
select extractValue(@xml, '/a/@b[substring(.,2,1)="1"]');
466
extractValue(@xml, '/a/@b[substring(.,2,1)="1"]')
468
select extractValue(@xml, '/a/@b[substring(.,2,1)="2"]');
469
extractValue(@xml, '/a/@b[substring(.,2,1)="2"]')
471
SET @xml='<a><b>b1</b><b>b2</b></a>';
472
SELECT extractValue(@xml, '/a/b[string-length("x")=1]');
473
extractValue(@xml, '/a/b[string-length("x")=1]')
475
SELECT extractValue(@xml, '/a/b[string-length("xx")=2]');
476
extractValue(@xml, '/a/b[string-length("xx")=2]')
478
SELECT extractValue(@xml, '/a/b[string-length("xxx")=2]');
479
extractValue(@xml, '/a/b[string-length("xxx")=2]')
481
SELECT extractValue(@xml, '/a/b[string-length("x")]');
482
extractValue(@xml, '/a/b[string-length("x")]')
484
SELECT extractValue(@xml, '/a/b[string-length("xx")]');
485
extractValue(@xml, '/a/b[string-length("xx")]')
487
SELECT extractValue(@xml, '/a/b[string-length()]');
488
extractValue(@xml, '/a/b[string-length()]')
490
SELECT extractValue(@xml, 'string-length()');
491
ERROR HY000: XPATH syntax error: ''
492
SELECT extractValue(@xml, 'string-length("x")');
493
extractValue(@xml, 'string-length("x")')
495
SET @xml='<a b="b11" b="b12" b="b21" b="22"/>';
496
select extractValue(@xml,'/a/@b');
497
extractValue(@xml,'/a/@b')
499
select extractValue(@xml,'/a/@b[contains(.,"1")]');
500
extractValue(@xml,'/a/@b[contains(.,"1")]')
502
select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")]');
503
extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")]')
505
select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")][2]');
506
extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")][2]')
508
SET @xml='<a>a1<b>b1<c>c1</c>b2</b>a2</a>';
509
select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','+++++++++');
510
UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','+++++++++')
511
<a>a1<b>b1+++++++++b2</b>a2</a>
512
select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1>+++++++++</c1>');
513
UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1>+++++++++</c1>')
514
<a>a1<b>b1<c1>+++++++++</c1>b2</b>a2</a>
515
select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1/>');
516
UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1/>')
517
<a>a1<b>b1<c1/>b2</b>a2</a>
518
SET @xml='<a><b>bb</b></a>';
519
select UpdateXML(@xml, '/a/b', '<b>ccc</b>');
520
UpdateXML(@xml, '/a/b', '<b>ccc</b>')
522
SET @xml='<a aa1="aa1" aa2="aa2"><b bb1="bb1" bb2="bb2">bb</b></a>';
523
select UpdateXML(@xml, '/a/b', '<b>ccc</b>');
524
UpdateXML(@xml, '/a/b', '<b>ccc</b>')
525
<a aa1="aa1" aa2="aa2"><b>ccc</b></a>
526
select UpdateXML(@xml, '/a/@aa1', '');
527
UpdateXML(@xml, '/a/@aa1', '')
528
<a aa2="aa2"><b bb1="bb1" bb2="bb2">bb</b></a>
529
select UpdateXML(@xml, '/a/@aa1', 'aa3="aa3"');
530
UpdateXML(@xml, '/a/@aa1', 'aa3="aa3"')
531
<a aa3="aa3" aa2="aa2"><b bb1="bb1" bb2="bb2">bb</b></a>
532
select UpdateXML(@xml, '/a/@aa2', '');
533
UpdateXML(@xml, '/a/@aa2', '')
534
<a aa1="aa1" ><b bb1="bb1" bb2="bb2">bb</b></a>
535
select UpdateXML(@xml, '/a/@aa2', 'aa3="aa3"');
536
UpdateXML(@xml, '/a/@aa2', 'aa3="aa3"')
537
<a aa1="aa1" aa3="aa3"><b bb1="bb1" bb2="bb2">bb</b></a>
538
select UpdateXML(@xml, '/a/b/@bb1', '');
539
UpdateXML(@xml, '/a/b/@bb1', '')
540
<a aa1="aa1" aa2="aa2"><b bb2="bb2">bb</b></a>
541
select UpdateXML(@xml, '/a/b/@bb1', 'bb3="bb3"');
542
UpdateXML(@xml, '/a/b/@bb1', 'bb3="bb3"')
543
<a aa1="aa1" aa2="aa2"><b bb3="bb3" bb2="bb2">bb</b></a>
544
select UpdateXML(@xml, '/a/b/@bb2', '');
545
UpdateXML(@xml, '/a/b/@bb2', '')
546
<a aa1="aa1" aa2="aa2"><b bb1="bb1" >bb</b></a>
547
select UpdateXML(@xml, '/a/b/@bb2', 'bb3="bb3"');
548
UpdateXML(@xml, '/a/b/@bb2', 'bb3="bb3"')
549
<a aa1="aa1" aa2="aa2"><b bb1="bb1" bb3="bb3">bb</b></a>
550
select updatexml('<div><div><span>1</span><span>2</span></div></div>',
551
'/','<tr><td>1</td><td>2</td></tr>') as upd1;
553
<tr><td>1</td><td>2</td></tr>
554
select updatexml('', '/', '') as upd2;
557
SET @xml= '<order><clerk>lesser wombat</clerk></order>';
558
select extractvalue(@xml,'order/clerk');
559
extractvalue(@xml,'order/clerk')
561
select extractvalue(@xml,'/order/clerk');
562
extractvalue(@xml,'/order/clerk')
564
select extractvalue('<a><b>B</b></a>','/a|/b');
565
extractvalue('<a><b>B</b></a>','/a|/b')
567
select extractvalue('<a><b>B</b></a>','/a|b');
568
extractvalue('<a><b>B</b></a>','/a|b')
570
select extractvalue('<a>a<b>B</b></a>','/a|/b');
571
extractvalue('<a>a<b>B</b></a>','/a|/b')
573
select extractvalue('<a>a<b>B</b></a>','/a|b');
574
extractvalue('<a>a<b>B</b></a>','/a|b')
576
select extractvalue('<a>a<b>B</b></a>','a|/b');
577
extractvalue('<a>a<b>B</b></a>','a|/b')
579
select extractvalue('<a>A</a>','/<a>');
580
ERROR HY000: XPATH error: comparison of two nodesets is not supported: '<a>'
581
select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
582
ERROR HY000: XPATH syntax error: '!'
583
select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
584
extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*')
586
select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*');
587
extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*')
589
select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*');
590
extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*')
592
select extractvalue('<A_B>A</A_B>','/A_B');
593
extractvalue('<A_B>A</A_B>','/A_B')
595
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[position()]');
596
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[position()]')
598
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=last()]');
599
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=last()]')
601
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()]');
602
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()]')
604
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()-1]');
605
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()-1]')
607
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=1]');
608
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=1]')
610
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=2]');
611
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=2]')
613
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=position()]');
614
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=position()]')
616
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)]');
617
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)]')
619
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)-1]');
620
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)-1]')
622
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=1]');
623
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=1]')
625
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=2]');
626
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=2]')
628
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=position()]');
629
extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=position()]')
631
select extractvalue('<a>Jack</a>','/a[contains(../a,"J")]');
632
extractvalue('<a>Jack</a>','/a[contains(../a,"J")]')
634
select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]');
635
extractvalue('<a>Jack</a>','/a[contains(../a,"j")]')
637
select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin);
638
extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin)
640
select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');
641
extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]')
643
select ExtractValue('<tag1><![CDATA[test]]></tag1>','/tag1');
644
ExtractValue('<tag1><![CDATA[test]]></tag1>','/tag1')
646
select extractValue('<a>a','/a');
647
extractValue('<a>a','/a')
650
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 5: unexpected END-OF-INPUT'
651
select extractValue('<a>a<','/a');
652
extractValue('<a>a<','/a')
655
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 6: END-OF-INPUT unexpected (ident or '/' wanted)'
656
select extractValue('<a>a</','/a');
657
extractValue('<a>a</','/a')
660
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 7: END-OF-INPUT unexpected (ident wanted)'
661
select extractValue('<a>a</a','/a');
662
extractValue('<a>a</a','/a')
665
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 8: END-OF-INPUT unexpected ('>' wanted)'
666
select extractValue('<a>a</a></b>','/a');
667
extractValue('<a>a</a></b>','/a')
670
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 12: '</b>' unexpected (END-OF-INPUT wanted)'
671
select extractValue('<a b=>a</a>','/a');
672
extractValue('<a b=>a</a>','/a')
675
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 7: '>' unexpected (ident or string wanted)'
676
select extractValue('<e>1</e>','position()');
677
ERROR HY000: XPATH syntax error: ''
678
select extractValue('<e>1</e>','last()');
679
ERROR HY000: XPATH syntax error: ''
680
select extractValue('<e><a>1</a></e>','/e/');
681
ERROR HY000: XPATH syntax error: ''
683
select extractValue('<Ă‘><r>r</r></Ă‘>','/Ă‘/r');
684
extractValue('<Ă‘><r>r</r></Ă‘>','/Ă‘/r')
686
select extractValue('<r><Ă‘>Ă‘</Ă‘></r>','/r/Ă‘');
687
extractValue('<r><Ă‘>Ă‘</Ă‘></r>','/r/Ă‘')
689
select extractValue('<Ă‘ r="r"/>','/Ă‘/@r');
690
extractValue('<Ă‘ r="r"/>','/Ă‘/@r')
692
select extractValue('<r Ă‘="Ă‘"/>','/r/@Ă‘');
693
extractValue('<r Ă‘="Ă‘"/>','/r/@Ă‘')
695
DROP PROCEDURE IF EXISTS p2;
696
CREATE PROCEDURE p2 ()
698
DECLARE p LONGTEXT CHARACTER SET UTF8 DEFAULT '<Ă‘><r>A</r></Ă‘>';
699
SELECT EXTRACTVALUE(p,'/Ă‘/r');
702
EXTRACTVALUE(p,'/Ă‘/r')
705
select extractValue('<ns:element xmlns:ns="myns"/>','count(ns:element)');
706
extractValue('<ns:element xmlns:ns="myns"/>','count(ns:element)')
708
select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element');
709
extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element')
711
select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns');
712
extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns')
714
select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/foo.bar');
715
extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/foo.bar')
717
select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/something');
718
extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/something')
720
select extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','/zot/tim0/02');
721
ERROR HY000: XPATH syntax error: '02'
722
select extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','//*');
723
extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','//*')
726
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 13: unknown token unexpected (ident or '/' wanted)'
727
select extractValue('<.>test</.>','//*');
728
extractValue('<.>test</.>','//*')
731
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)'
732
select extractValue('<->test</->','//*');
733
extractValue('<->test</->','//*')
736
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)'
737
select extractValue('<:>test</:>','//*');
738
extractValue('<:>test</:>','//*')
740
select extractValue('<_>test</_>','//*');
741
extractValue('<_>test</_>','//*')
743
select extractValue('<x.-_:>test</x.-_:>','//*');
744
extractValue('<x.-_:>test</x.-_:>','//*')
746
set @xml= "<entry><id>pt10</id><pt>10</pt></entry><entry><id>pt50</id><pt>50</pt></entry>";
747
select ExtractValue(@xml, "/entry[(pt=10)]/id");
748
ExtractValue(@xml, "/entry[(pt=10)]/id")
750
select ExtractValue(@xml, "/entry[(pt!=10)]/id");
751
ExtractValue(@xml, "/entry[(pt!=10)]/id")
753
select ExtractValue(@xml, "/entry[(pt<10)]/id");
754
ExtractValue(@xml, "/entry[(pt<10)]/id")
756
select ExtractValue(@xml, "/entry[(pt<=10)]/id");
757
ExtractValue(@xml, "/entry[(pt<=10)]/id")
759
select ExtractValue(@xml, "/entry[(pt>10)]/id");
760
ExtractValue(@xml, "/entry[(pt>10)]/id")
762
select ExtractValue(@xml, "/entry[(pt>=10)]/id");
763
ExtractValue(@xml, "/entry[(pt>=10)]/id")
765
select ExtractValue(@xml, "/entry[(pt=50)]/id");
766
ExtractValue(@xml, "/entry[(pt=50)]/id")
768
select ExtractValue(@xml, "/entry[(pt!=50)]/id");
769
ExtractValue(@xml, "/entry[(pt!=50)]/id")
771
select ExtractValue(@xml, "/entry[(pt<50)]/id");
772
ExtractValue(@xml, "/entry[(pt<50)]/id")
774
select ExtractValue(@xml, "/entry[(pt<=50)]/id");
775
ExtractValue(@xml, "/entry[(pt<=50)]/id")
777
select ExtractValue(@xml, "/entry[(pt>50)]/id");
778
ExtractValue(@xml, "/entry[(pt>50)]/id")
780
select ExtractValue(@xml, "/entry[(pt>=50)]/id");
781
ExtractValue(@xml, "/entry[(pt>=50)]/id")
783
select ExtractValue(@xml, "/entry[(10=pt)]/id");
784
ExtractValue(@xml, "/entry[(10=pt)]/id")
786
select ExtractValue(@xml, "/entry[(10!=pt)]/id");
787
ExtractValue(@xml, "/entry[(10!=pt)]/id")
789
select ExtractValue(@xml, "/entry[(10>pt)]/id");
790
ExtractValue(@xml, "/entry[(10>pt)]/id")
792
select ExtractValue(@xml, "/entry[(10>=pt)]/id");
793
ExtractValue(@xml, "/entry[(10>=pt)]/id")
795
select ExtractValue(@xml, "/entry[(10<pt)]/id");
796
ExtractValue(@xml, "/entry[(10<pt)]/id")
798
select ExtractValue(@xml, "/entry[(10<=pt)]/id");
799
ExtractValue(@xml, "/entry[(10<=pt)]/id")
801
select ExtractValue(@xml, "/entry[(50=pt)]/id");
802
ExtractValue(@xml, "/entry[(50=pt)]/id")
804
select ExtractValue(@xml, "/entry[(50!=pt)]/id");
805
ExtractValue(@xml, "/entry[(50!=pt)]/id")
807
select ExtractValue(@xml, "/entry[(50>pt)]/id");
808
ExtractValue(@xml, "/entry[(50>pt)]/id")
810
select ExtractValue(@xml, "/entry[(50>=pt)]/id");
811
ExtractValue(@xml, "/entry[(50>=pt)]/id")
813
select ExtractValue(@xml, "/entry[(50<pt)]/id");
814
ExtractValue(@xml, "/entry[(50<pt)]/id")
816
select ExtractValue(@xml, "/entry[(50<=pt)]/id");
817
ExtractValue(@xml, "/entry[(50<=pt)]/id")
819
select ExtractValue('<a><b><Text>test</Text></b></a>','/a/b/Text');
820
ExtractValue('<a><b><Text>test</Text></b></a>','/a/b/Text')
822
select ExtractValue('<a><b><comment>test</comment></b></a>','/a/b/comment');
823
ExtractValue('<a><b><comment>test</comment></b></a>','/a/b/comment')
825
select ExtractValue('<a><b><node>test</node></b></a>','/a/b/node');
826
ExtractValue('<a><b><node>test</node></b></a>','/a/b/node')
828
select ExtractValue('<a><b><processing-instruction>test</processing-instruction></b></a>','/a/b/processing-instruction');
829
ExtractValue('<a><b><processing-instruction>test</processing-instruction></b></a>','/a/b/processing-instruction')
831
select ExtractValue('<a><and>test</and></a>', '/a/and');
832
ExtractValue('<a><and>test</and></a>', '/a/and')
834
select ExtractValue('<a><or>test</or></a>', '/a/or');
835
ExtractValue('<a><or>test</or></a>', '/a/or')
837
select ExtractValue('<a><mod>test</mod></a>', '/a/mod');
838
ExtractValue('<a><mod>test</mod></a>', '/a/mod')
840
select ExtractValue('<a><div>test</div></a>', '/a/div');
841
ExtractValue('<a><div>test</div></a>', '/a/div')
843
select ExtractValue('<a><and:and>test</and:and></a>', '/a/and:and');
844
ExtractValue('<a><and:and>test</and:and></a>', '/a/and:and')
846
select ExtractValue('<a><or:or>test</or:or></a>', '/a/or:or');
847
ExtractValue('<a><or:or>test</or:or></a>', '/a/or:or')
849
select ExtractValue('<a><mod:mod>test</mod:mod></a>', '/a/mod:mod');
850
ExtractValue('<a><mod:mod>test</mod:mod></a>', '/a/mod:mod')
852
select ExtractValue('<a><div:div>test</div:div></a>', '/a/div:div');
853
ExtractValue('<a><div:div>test</div:div></a>', '/a/div:div')
855
select ExtractValue('<a><ancestor>test</ancestor></a>', '/a/ancestor');
856
ExtractValue('<a><ancestor>test</ancestor></a>', '/a/ancestor')
858
select ExtractValue('<a><ancestor-or-self>test</ancestor-or-self></a>', '/a/ancestor-or-self');
859
ExtractValue('<a><ancestor-or-self>test</ancestor-or-self></a>', '/a/ancestor-or-self')
861
select ExtractValue('<a><attribute>test</attribute></a>', '/a/attribute');
862
ExtractValue('<a><attribute>test</attribute></a>', '/a/attribute')
864
select ExtractValue('<a><child>test</child></a>', '/a/child');
865
ExtractValue('<a><child>test</child></a>', '/a/child')
867
select ExtractValue('<a><descendant>test</descendant></a>', '/a/descendant');
868
ExtractValue('<a><descendant>test</descendant></a>', '/a/descendant')
870
select ExtractValue('<a><descendant-or-self>test</descendant-or-self></a>', '/a/descendant-or-self');
871
ExtractValue('<a><descendant-or-self>test</descendant-or-self></a>', '/a/descendant-or-self')
873
select ExtractValue('<a><following>test</following></a>', '/a/following');
874
ExtractValue('<a><following>test</following></a>', '/a/following')
876
select ExtractValue('<a><following-sibling>test</following-sibling></a>', '/a/following-sibling');
877
ExtractValue('<a><following-sibling>test</following-sibling></a>', '/a/following-sibling')
879
select ExtractValue('<a><namespace>test</namespace></a>', '/a/namespace');
880
ExtractValue('<a><namespace>test</namespace></a>', '/a/namespace')
882
select ExtractValue('<a><parent>test</parent></a>', '/a/parent');
883
ExtractValue('<a><parent>test</parent></a>', '/a/parent')
885
select ExtractValue('<a><preceding>test</preceding></a>', '/a/preceding');
886
ExtractValue('<a><preceding>test</preceding></a>', '/a/preceding')
888
select ExtractValue('<a><preceding-sibling>test</preceding-sibling></a>', '/a/preceding-sibling');
889
ExtractValue('<a><preceding-sibling>test</preceding-sibling></a>', '/a/preceding-sibling')
891
select ExtractValue('<a><self>test</self></a>', '/a/self');
892
ExtractValue('<a><self>test</self></a>', '/a/self')
895
select ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]');
896
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]')
899
select ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]');
900
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]')
903
select ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]');
904
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]')
906
CREATE PROCEDURE spxml(xml VARCHAR(128))
909
DECLARE i INT DEFAULT 1;
910
SET c= ExtractValue(xml,'count(/a/b)');
914
SELECT i, @i, ExtractValue(xml,'/a/b[$i]'), ExtractValue(xml,'/a/b[$@i]');
920
call spxml('<a><b>b1</b><b>b2</b><b>b3</b></a>');
921
i @i ExtractValue(xml,'/a/b[$i]') ExtractValue(xml,'/a/b[$@i]')
923
i @i ExtractValue(xml,'/a/b[$i]') ExtractValue(xml,'/a/b[$@i]')
925
i @i ExtractValue(xml,'/a/b[$i]') ExtractValue(xml,'/a/b[$@i]')
927
drop procedure spxml;
928
Multiple matches, but no index specification
929
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b');
930
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b')
933
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/c');
934
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/c')
937
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[-1]');
938
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[-1]')
940
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[10]');
941
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[10]')
943
With string-to-number conversion
944
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["1"]');
945
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["1"]')
947
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["1 and string"]');
948
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["1 and string"]')
951
Warning 1292 Truncated incorrect INTEGER value: '1 and string"]'
952
Warning 1292 Truncated incorrect INTEGER value: '1 and string"]'
953
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["string and 1"]');
954
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["string and 1"]')
957
Warning 1292 Truncated incorrect INTEGER value: 'string and 1"]'
958
Warning 1292 Truncated incorrect INTEGER value: 'string and 1"]'
959
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["string"]');
960
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["string"]')
963
Warning 1292 Truncated incorrect INTEGER value: 'string"]'
964
Warning 1292 Truncated incorrect INTEGER value: 'string"]'
965
String-to-number conversion from a user variable
967
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]');
968
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]')
970
SET @i='1 and string';
971
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]');
972
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]')
974
SET @i='string and 1';
975
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]');
976
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]')
979
SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]');
980
ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]')
982
String-to-number conversion with a CHAR SP variable
983
CREATE PROCEDURE spxml(xml VARCHAR(128), i CHAR(16))
985
SELECT ExtractValue(xml,'/a/b[$i]');
987
CALL spxml('<a><b>b1</b><b>b2</b></a>', '1');
988
ExtractValue(xml,'/a/b[$i]')
990
CALL spxml('<a><b>b1</b><b>b2</b></a>', '1 and string');
991
ExtractValue(xml,'/a/b[$i]')
994
Warning 1292 Truncated incorrect INTEGER value: '1 and string '
995
Warning 1292 Truncated incorrect INTEGER value: '1 and string '
996
CALL spxml('<a><b>b1</b><b>b2</b></a>', 'string and 1');
997
ExtractValue(xml,'/a/b[$i]')
1000
Warning 1292 Truncated incorrect INTEGER value: 'string and 1 '
1001
Warning 1292 Truncated incorrect INTEGER value: 'string and 1 '
1002
CALL spxml('<a><b>b1</b><b>b2</b></a>', 'string');
1003
ExtractValue(xml,'/a/b[$i]')
1006
Warning 1292 Truncated incorrect INTEGER value: 'string '
1007
Warning 1292 Truncated incorrect INTEGER value: 'string '
1008
DROP PROCEDURE spxml;
1009
select UpdateXML('<a>a</a>',repeat('a b ',1000),'');
1010
ERROR HY000: XPATH syntax error: 'b a b a b a b a b a b a b a b a '
1011
select ExtractValue('<a>a</a>', '/a[@x=@y0123456789_0123456789_0123456789_0123456789]');
1012
ERROR HY000: XPATH error: comparison of two nodesets is not supported: '=@y0123456789_0123456789_0123456'
1013
select ExtractValue('<a>a</a>', '/a[@x=$y0123456789_0123456789_0123456789_0123456789]');
1014
ERROR HY000: Unknown XPATH variable at: '$y0123456789_0123456789_01234567'
1015
select updatexml(NULL, 1, 1), updatexml(1, NULL, 1), updatexml(1, 1, NULL);
1016
updatexml(NULL, 1, 1) updatexml(1, NULL, 1) updatexml(1, 1, NULL)
1018
select updatexml(NULL, NULL, 1), updatexml(1, NULL, NULL),
1019
updatexml(NULL, 1, NULL);
1020
updatexml(NULL, NULL, 1) updatexml(1, NULL, NULL) updatexml(NULL, 1, NULL)
1022
select updatexml(NULL, NULL, NULL);
1023
updatexml(NULL, NULL, NULL)
1025
CREATE TABLE t1(a INT NOT NULL);
1026
INSERT INTO t1 VALUES (0), (0);
1027
SELECT 1 FROM t1 ORDER BY(UPDATEXML(a, '1', '1'));