xml_1.out 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417
  1. CREATE TABLE xmltest (
  2. id int,
  3. data xml
  4. );
  5. INSERT INTO xmltest VALUES (1, '<value>one</value>');
  6. ERROR: unsupported XML feature
  7. LINE 1: INSERT INTO xmltest VALUES (1, '<value>one</value>');
  8. ^
  9. DETAIL: This functionality requires the server to be built with libxml support.
  10. HINT: You need to rebuild PostgreSQL using --with-libxml.
  11. INSERT INTO xmltest VALUES (2, '<value>two</value>');
  12. ERROR: unsupported XML feature
  13. LINE 1: INSERT INTO xmltest VALUES (2, '<value>two</value>');
  14. ^
  15. DETAIL: This functionality requires the server to be built with libxml support.
  16. HINT: You need to rebuild PostgreSQL using --with-libxml.
  17. INSERT INTO xmltest VALUES (3, '<wrong');
  18. ERROR: unsupported XML feature
  19. LINE 1: INSERT INTO xmltest VALUES (3, '<wrong');
  20. ^
  21. DETAIL: This functionality requires the server to be built with libxml support.
  22. HINT: You need to rebuild PostgreSQL using --with-libxml.
  23. SELECT * FROM xmltest;
  24. id | data
  25. ----+------
  26. (0 rows)
  27. SELECT xmlcomment('test');
  28. ERROR: unsupported XML feature
  29. DETAIL: This functionality requires the server to be built with libxml support.
  30. HINT: You need to rebuild PostgreSQL using --with-libxml.
  31. SELECT xmlcomment('-test');
  32. ERROR: unsupported XML feature
  33. DETAIL: This functionality requires the server to be built with libxml support.
  34. HINT: You need to rebuild PostgreSQL using --with-libxml.
  35. SELECT xmlcomment('test-');
  36. ERROR: unsupported XML feature
  37. DETAIL: This functionality requires the server to be built with libxml support.
  38. HINT: You need to rebuild PostgreSQL using --with-libxml.
  39. SELECT xmlcomment('--test');
  40. ERROR: unsupported XML feature
  41. DETAIL: This functionality requires the server to be built with libxml support.
  42. HINT: You need to rebuild PostgreSQL using --with-libxml.
  43. SELECT xmlcomment('te st');
  44. ERROR: unsupported XML feature
  45. DETAIL: This functionality requires the server to be built with libxml support.
  46. HINT: You need to rebuild PostgreSQL using --with-libxml.
  47. SELECT xmlconcat(xmlcomment('hello'),
  48. xmlelement(NAME qux, 'foo'),
  49. xmlcomment('world'));
  50. ERROR: unsupported XML feature
  51. DETAIL: This functionality requires the server to be built with libxml support.
  52. HINT: You need to rebuild PostgreSQL using --with-libxml.
  53. SELECT xmlconcat('hello', 'you');
  54. ERROR: unsupported XML feature
  55. LINE 1: SELECT xmlconcat('hello', 'you');
  56. ^
  57. DETAIL: This functionality requires the server to be built with libxml support.
  58. HINT: You need to rebuild PostgreSQL using --with-libxml.
  59. SELECT xmlconcat(1, 2);
  60. ERROR: argument of XMLCONCAT must be type xml, not type integer
  61. LINE 1: SELECT xmlconcat(1, 2);
  62. ^
  63. SELECT xmlconcat('bad', '<syntax');
  64. ERROR: unsupported XML feature
  65. LINE 1: SELECT xmlconcat('bad', '<syntax');
  66. ^
  67. DETAIL: This functionality requires the server to be built with libxml support.
  68. HINT: You need to rebuild PostgreSQL using --with-libxml.
  69. SELECT xmlconcat('<foo/>', NULL, '<?xml version="1.1" standalone="no"?><bar/>');
  70. ERROR: unsupported XML feature
  71. LINE 1: SELECT xmlconcat('<foo/>', NULL, '<?xml version="1.1" standa...
  72. ^
  73. DETAIL: This functionality requires the server to be built with libxml support.
  74. HINT: You need to rebuild PostgreSQL using --with-libxml.
  75. SELECT xmlconcat('<?xml version="1.1"?><foo/>', NULL, '<?xml version="1.1" standalone="no"?><bar/>');
  76. ERROR: unsupported XML feature
  77. LINE 1: SELECT xmlconcat('<?xml version="1.1"?><foo/>', NULL, '<?xml...
  78. ^
  79. DETAIL: This functionality requires the server to be built with libxml support.
  80. HINT: You need to rebuild PostgreSQL using --with-libxml.
  81. SELECT xmlconcat(NULL);
  82. xmlconcat
  83. -----------
  84. (1 row)
  85. SELECT xmlconcat(NULL, NULL);
  86. xmlconcat
  87. -----------
  88. (1 row)
  89. SELECT xmlelement(name element,
  90. xmlattributes (1 as one, 'deuce' as two),
  91. 'content');
  92. ERROR: unsupported XML feature
  93. DETAIL: This functionality requires the server to be built with libxml support.
  94. HINT: You need to rebuild PostgreSQL using --with-libxml.
  95. SELECT xmlelement(name element,
  96. xmlattributes ('unnamed and wrong'));
  97. ERROR: unsupported XML feature
  98. DETAIL: This functionality requires the server to be built with libxml support.
  99. HINT: You need to rebuild PostgreSQL using --with-libxml.
  100. SELECT xmlelement(name element, xmlelement(name nested, 'stuff'));
  101. ERROR: unsupported XML feature
  102. DETAIL: This functionality requires the server to be built with libxml support.
  103. HINT: You need to rebuild PostgreSQL using --with-libxml.
  104. SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp;
  105. ERROR: unsupported XML feature
  106. DETAIL: This functionality requires the server to be built with libxml support.
  107. HINT: You need to rebuild PostgreSQL using --with-libxml.
  108. SELECT xmlelement(name duplicate, xmlattributes(1 as a, 2 as b, 3 as a));
  109. ERROR: unsupported XML feature
  110. DETAIL: This functionality requires the server to be built with libxml support.
  111. HINT: You need to rebuild PostgreSQL using --with-libxml.
  112. SELECT xmlelement(name num, 37);
  113. ERROR: unsupported XML feature
  114. DETAIL: This functionality requires the server to be built with libxml support.
  115. HINT: You need to rebuild PostgreSQL using --with-libxml.
  116. SELECT xmlelement(name foo, text 'bar');
  117. ERROR: unsupported XML feature
  118. DETAIL: This functionality requires the server to be built with libxml support.
  119. HINT: You need to rebuild PostgreSQL using --with-libxml.
  120. SELECT xmlelement(name foo, xml 'bar');
  121. ERROR: unsupported XML feature
  122. DETAIL: This functionality requires the server to be built with libxml support.
  123. HINT: You need to rebuild PostgreSQL using --with-libxml.
  124. SELECT xmlelement(name foo, text 'b<a/>r');
  125. ERROR: unsupported XML feature
  126. DETAIL: This functionality requires the server to be built with libxml support.
  127. HINT: You need to rebuild PostgreSQL using --with-libxml.
  128. SELECT xmlelement(name foo, xml 'b<a/>r');
  129. ERROR: unsupported XML feature
  130. DETAIL: This functionality requires the server to be built with libxml support.
  131. HINT: You need to rebuild PostgreSQL using --with-libxml.
  132. SELECT xmlelement(name foo, array[1, 2, 3]);
  133. ERROR: unsupported XML feature
  134. DETAIL: This functionality requires the server to be built with libxml support.
  135. HINT: You need to rebuild PostgreSQL using --with-libxml.
  136. SET xmlbinary TO base64;
  137. SELECT xmlelement(name foo, bytea 'bar');
  138. ERROR: unsupported XML feature
  139. DETAIL: This functionality requires the server to be built with libxml support.
  140. HINT: You need to rebuild PostgreSQL using --with-libxml.
  141. SET xmlbinary TO hex;
  142. SELECT xmlelement(name foo, bytea 'bar');
  143. ERROR: unsupported XML feature
  144. DETAIL: This functionality requires the server to be built with libxml support.
  145. HINT: You need to rebuild PostgreSQL using --with-libxml.
  146. SELECT xmlelement(name foo, xmlattributes(true as bar));
  147. ERROR: unsupported XML feature
  148. DETAIL: This functionality requires the server to be built with libxml support.
  149. HINT: You need to rebuild PostgreSQL using --with-libxml.
  150. SELECT xmlelement(name foo, xmlattributes('2009-04-09 00:24:37'::timestamp as bar));
  151. ERROR: unsupported XML feature
  152. DETAIL: This functionality requires the server to be built with libxml support.
  153. HINT: You need to rebuild PostgreSQL using --with-libxml.
  154. SELECT xmlelement(name foo, xmlattributes('infinity'::timestamp as bar));
  155. ERROR: unsupported XML feature
  156. DETAIL: This functionality requires the server to be built with libxml support.
  157. HINT: You need to rebuild PostgreSQL using --with-libxml.
  158. SELECT xmlelement(name foo, xmlattributes('<>&"''' as funny, xml 'b<a/>r' as funnier));
  159. ERROR: unsupported XML feature
  160. DETAIL: This functionality requires the server to be built with libxml support.
  161. HINT: You need to rebuild PostgreSQL using --with-libxml.
  162. SELECT xmlparse(content '');
  163. ERROR: unsupported XML feature
  164. DETAIL: This functionality requires the server to be built with libxml support.
  165. HINT: You need to rebuild PostgreSQL using --with-libxml.
  166. SELECT xmlparse(content ' ');
  167. ERROR: unsupported XML feature
  168. DETAIL: This functionality requires the server to be built with libxml support.
  169. HINT: You need to rebuild PostgreSQL using --with-libxml.
  170. SELECT xmlparse(content 'abc');
  171. ERROR: unsupported XML feature
  172. DETAIL: This functionality requires the server to be built with libxml support.
  173. HINT: You need to rebuild PostgreSQL using --with-libxml.
  174. SELECT xmlparse(content '<abc>x</abc>');
  175. ERROR: unsupported XML feature
  176. DETAIL: This functionality requires the server to be built with libxml support.
  177. HINT: You need to rebuild PostgreSQL using --with-libxml.
  178. SELECT xmlparse(content '<invalidentity>&</invalidentity>');
  179. ERROR: unsupported XML feature
  180. DETAIL: This functionality requires the server to be built with libxml support.
  181. HINT: You need to rebuild PostgreSQL using --with-libxml.
  182. SELECT xmlparse(content '<undefinedentity>&idontexist;</undefinedentity>');
  183. ERROR: unsupported XML feature
  184. DETAIL: This functionality requires the server to be built with libxml support.
  185. HINT: You need to rebuild PostgreSQL using --with-libxml.
  186. SELECT xmlparse(content '<invalidns xmlns=''&lt;''/>');
  187. ERROR: unsupported XML feature
  188. DETAIL: This functionality requires the server to be built with libxml support.
  189. HINT: You need to rebuild PostgreSQL using --with-libxml.
  190. SELECT xmlparse(content '<relativens xmlns=''relative''/>');
  191. ERROR: unsupported XML feature
  192. DETAIL: This functionality requires the server to be built with libxml support.
  193. HINT: You need to rebuild PostgreSQL using --with-libxml.
  194. SELECT xmlparse(content '<twoerrors>&idontexist;</unbalanced>');
  195. ERROR: unsupported XML feature
  196. DETAIL: This functionality requires the server to be built with libxml support.
  197. HINT: You need to rebuild PostgreSQL using --with-libxml.
  198. SELECT xmlparse(content '<nosuchprefix:tag/>');
  199. ERROR: unsupported XML feature
  200. DETAIL: This functionality requires the server to be built with libxml support.
  201. HINT: You need to rebuild PostgreSQL using --with-libxml.
  202. SELECT xmlparse(document ' ');
  203. ERROR: unsupported XML feature
  204. DETAIL: This functionality requires the server to be built with libxml support.
  205. HINT: You need to rebuild PostgreSQL using --with-libxml.
  206. SELECT xmlparse(document 'abc');
  207. ERROR: unsupported XML feature
  208. DETAIL: This functionality requires the server to be built with libxml support.
  209. HINT: You need to rebuild PostgreSQL using --with-libxml.
  210. SELECT xmlparse(document '<abc>x</abc>');
  211. ERROR: unsupported XML feature
  212. DETAIL: This functionality requires the server to be built with libxml support.
  213. HINT: You need to rebuild PostgreSQL using --with-libxml.
  214. SELECT xmlparse(document '<invalidentity>&</abc>');
  215. ERROR: unsupported XML feature
  216. DETAIL: This functionality requires the server to be built with libxml support.
  217. HINT: You need to rebuild PostgreSQL using --with-libxml.
  218. SELECT xmlparse(document '<undefinedentity>&idontexist;</abc>');
  219. ERROR: unsupported XML feature
  220. DETAIL: This functionality requires the server to be built with libxml support.
  221. HINT: You need to rebuild PostgreSQL using --with-libxml.
  222. SELECT xmlparse(document '<invalidns xmlns=''&lt;''/>');
  223. ERROR: unsupported XML feature
  224. DETAIL: This functionality requires the server to be built with libxml support.
  225. HINT: You need to rebuild PostgreSQL using --with-libxml.
  226. SELECT xmlparse(document '<relativens xmlns=''relative''/>');
  227. ERROR: unsupported XML feature
  228. DETAIL: This functionality requires the server to be built with libxml support.
  229. HINT: You need to rebuild PostgreSQL using --with-libxml.
  230. SELECT xmlparse(document '<twoerrors>&idontexist;</unbalanced>');
  231. ERROR: unsupported XML feature
  232. DETAIL: This functionality requires the server to be built with libxml support.
  233. HINT: You need to rebuild PostgreSQL using --with-libxml.
  234. SELECT xmlparse(document '<nosuchprefix:tag/>');
  235. ERROR: unsupported XML feature
  236. DETAIL: This functionality requires the server to be built with libxml support.
  237. HINT: You need to rebuild PostgreSQL using --with-libxml.
  238. SELECT xmlpi(name foo);
  239. ERROR: unsupported XML feature
  240. DETAIL: This functionality requires the server to be built with libxml support.
  241. HINT: You need to rebuild PostgreSQL using --with-libxml.
  242. SELECT xmlpi(name xml);
  243. ERROR: unsupported XML feature
  244. DETAIL: This functionality requires the server to be built with libxml support.
  245. HINT: You need to rebuild PostgreSQL using --with-libxml.
  246. SELECT xmlpi(name xmlstuff);
  247. ERROR: unsupported XML feature
  248. DETAIL: This functionality requires the server to be built with libxml support.
  249. HINT: You need to rebuild PostgreSQL using --with-libxml.
  250. SELECT xmlpi(name foo, 'bar');
  251. ERROR: unsupported XML feature
  252. DETAIL: This functionality requires the server to be built with libxml support.
  253. HINT: You need to rebuild PostgreSQL using --with-libxml.
  254. SELECT xmlpi(name foo, 'in?>valid');
  255. ERROR: unsupported XML feature
  256. DETAIL: This functionality requires the server to be built with libxml support.
  257. HINT: You need to rebuild PostgreSQL using --with-libxml.
  258. SELECT xmlpi(name foo, null);
  259. ERROR: unsupported XML feature
  260. DETAIL: This functionality requires the server to be built with libxml support.
  261. HINT: You need to rebuild PostgreSQL using --with-libxml.
  262. SELECT xmlpi(name xml, null);
  263. ERROR: unsupported XML feature
  264. DETAIL: This functionality requires the server to be built with libxml support.
  265. HINT: You need to rebuild PostgreSQL using --with-libxml.
  266. SELECT xmlpi(name xmlstuff, null);
  267. ERROR: unsupported XML feature
  268. DETAIL: This functionality requires the server to be built with libxml support.
  269. HINT: You need to rebuild PostgreSQL using --with-libxml.
  270. SELECT xmlpi(name "xml-stylesheet", 'href="mystyle.css" type="text/css"');
  271. ERROR: unsupported XML feature
  272. DETAIL: This functionality requires the server to be built with libxml support.
  273. HINT: You need to rebuild PostgreSQL using --with-libxml.
  274. SELECT xmlpi(name foo, ' bar');
  275. ERROR: unsupported XML feature
  276. DETAIL: This functionality requires the server to be built with libxml support.
  277. HINT: You need to rebuild PostgreSQL using --with-libxml.
  278. SELECT xmlroot(xml '<foo/>', version no value, standalone no value);
  279. ERROR: unsupported XML feature
  280. LINE 1: SELECT xmlroot(xml '<foo/>', version no value, standalone no...
  281. ^
  282. DETAIL: This functionality requires the server to be built with libxml support.
  283. HINT: You need to rebuild PostgreSQL using --with-libxml.
  284. SELECT xmlroot(xml '<foo/>', version '2.0');
  285. ERROR: unsupported XML feature
  286. LINE 1: SELECT xmlroot(xml '<foo/>', version '2.0');
  287. ^
  288. DETAIL: This functionality requires the server to be built with libxml support.
  289. HINT: You need to rebuild PostgreSQL using --with-libxml.
  290. SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
  291. ERROR: unsupported XML feature
  292. LINE 1: SELECT xmlroot(xml '<foo/>', version no value, standalone ye...
  293. ^
  294. DETAIL: This functionality requires the server to be built with libxml support.
  295. HINT: You need to rebuild PostgreSQL using --with-libxml.
  296. SELECT xmlroot(xml '<?xml version="1.1"?><foo/>', version no value, standalone yes);
  297. ERROR: unsupported XML feature
  298. LINE 1: SELECT xmlroot(xml '<?xml version="1.1"?><foo/>', version no...
  299. ^
  300. DETAIL: This functionality requires the server to be built with libxml support.
  301. HINT: You need to rebuild PostgreSQL using --with-libxml.
  302. SELECT xmlroot(xmlroot(xml '<foo/>', version '1.0'), version '1.1', standalone no);
  303. ERROR: unsupported XML feature
  304. LINE 1: SELECT xmlroot(xmlroot(xml '<foo/>', version '1.0'), version...
  305. ^
  306. DETAIL: This functionality requires the server to be built with libxml support.
  307. HINT: You need to rebuild PostgreSQL using --with-libxml.
  308. SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>', version no value, standalone no);
  309. ERROR: unsupported XML feature
  310. LINE 1: SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>...
  311. ^
  312. DETAIL: This functionality requires the server to be built with libxml support.
  313. HINT: You need to rebuild PostgreSQL using --with-libxml.
  314. SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>', version no value, standalone no value);
  315. ERROR: unsupported XML feature
  316. LINE 1: SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>...
  317. ^
  318. DETAIL: This functionality requires the server to be built with libxml support.
  319. HINT: You need to rebuild PostgreSQL using --with-libxml.
  320. SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>', version no value);
  321. ERROR: unsupported XML feature
  322. LINE 1: SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>...
  323. ^
  324. DETAIL: This functionality requires the server to be built with libxml support.
  325. HINT: You need to rebuild PostgreSQL using --with-libxml.
  326. SELECT xmlroot (
  327. xmlelement (
  328. name gazonk,
  329. xmlattributes (
  330. 'val' AS name,
  331. 1 + 1 AS num
  332. ),
  333. xmlelement (
  334. NAME qux,
  335. 'foo'
  336. )
  337. ),
  338. version '1.0',
  339. standalone yes
  340. );
  341. ERROR: unsupported XML feature
  342. DETAIL: This functionality requires the server to be built with libxml support.
  343. HINT: You need to rebuild PostgreSQL using --with-libxml.
  344. SELECT xmlserialize(content data as character varying(20)) FROM xmltest;
  345. xmlserialize
  346. --------------
  347. (0 rows)
  348. SELECT xmlserialize(content 'good' as char(10));
  349. ERROR: unsupported XML feature
  350. LINE 1: SELECT xmlserialize(content 'good' as char(10));
  351. ^
  352. DETAIL: This functionality requires the server to be built with libxml support.
  353. HINT: You need to rebuild PostgreSQL using --with-libxml.
  354. SELECT xmlserialize(document 'bad' as text);
  355. ERROR: unsupported XML feature
  356. LINE 1: SELECT xmlserialize(document 'bad' as text);
  357. ^
  358. DETAIL: This functionality requires the server to be built with libxml support.
  359. HINT: You need to rebuild PostgreSQL using --with-libxml.
  360. SELECT xml '<foo>bar</foo>' IS DOCUMENT;
  361. ERROR: unsupported XML feature
  362. LINE 1: SELECT xml '<foo>bar</foo>' IS DOCUMENT;
  363. ^
  364. DETAIL: This functionality requires the server to be built with libxml support.
  365. HINT: You need to rebuild PostgreSQL using --with-libxml.
  366. SELECT xml '<foo>bar</foo><bar>foo</bar>' IS DOCUMENT;
  367. ERROR: unsupported XML feature
  368. LINE 1: SELECT xml '<foo>bar</foo><bar>foo</bar>' IS DOCUMENT;
  369. ^
  370. DETAIL: This functionality requires the server to be built with libxml support.
  371. HINT: You need to rebuild PostgreSQL using --with-libxml.
  372. SELECT xml '<abc/>' IS NOT DOCUMENT;
  373. ERROR: unsupported XML feature
  374. LINE 1: SELECT xml '<abc/>' IS NOT DOCUMENT;
  375. ^
  376. DETAIL: This functionality requires the server to be built with libxml support.
  377. HINT: You need to rebuild PostgreSQL using --with-libxml.
  378. SELECT xml 'abc' IS NOT DOCUMENT;
  379. ERROR: unsupported XML feature
  380. LINE 1: SELECT xml 'abc' IS NOT DOCUMENT;
  381. ^
  382. DETAIL: This functionality requires the server to be built with libxml support.
  383. HINT: You need to rebuild PostgreSQL using --with-libxml.
  384. SELECT '<>' IS NOT DOCUMENT;
  385. ERROR: unsupported XML feature
  386. LINE 1: SELECT '<>' IS NOT DOCUMENT;
  387. ^
  388. DETAIL: This functionality requires the server to be built with libxml support.
  389. HINT: You need to rebuild PostgreSQL using --with-libxml.
  390. SELECT xmlagg(data) FROM xmltest;
  391. xmlagg
  392. --------
  393. (1 row)
  394. SELECT xmlagg(data) FROM xmltest WHERE id > 10;
  395. xmlagg
  396. --------
  397. (1 row)
  398. SELECT xmlelement(name employees, xmlagg(xmlelement(name name, name))) FROM emp;
  399. ERROR: unsupported XML feature
  400. DETAIL: This functionality requires the server to be built with libxml support.
  401. HINT: You need to rebuild PostgreSQL using --with-libxml.
  402. -- Check mapping SQL identifier to XML name
  403. SELECT xmlpi(name ":::_xml_abc135.%-&_");
  404. ERROR: unsupported XML feature
  405. DETAIL: This functionality requires the server to be built with libxml support.
  406. HINT: You need to rebuild PostgreSQL using --with-libxml.
  407. SELECT xmlpi(name "123");
  408. ERROR: unsupported XML feature
  409. DETAIL: This functionality requires the server to be built with libxml support.
  410. HINT: You need to rebuild PostgreSQL using --with-libxml.
  411. PREPARE foo (xml) AS SELECT xmlconcat('<foo/>', $1);
  412. ERROR: unsupported XML feature
  413. LINE 1: PREPARE foo (xml) AS SELECT xmlconcat('<foo/>', $1);
  414. ^
  415. DETAIL: This functionality requires the server to be built with libxml support.
  416. HINT: You need to rebuild PostgreSQL using --with-libxml.
  417. SET XML OPTION DOCUMENT;
  418. EXECUTE foo ('<bar/>');
  419. ERROR: prepared statement "foo" does not exist
  420. EXECUTE foo ('bad');
  421. ERROR: prepared statement "foo" does not exist
  422. SELECT xml '<!DOCTYPE a><a/><b/>';
  423. ERROR: unsupported XML feature
  424. LINE 1: SELECT xml '<!DOCTYPE a><a/><b/>';
  425. ^
  426. DETAIL: This functionality requires the server to be built with libxml support.
  427. HINT: You need to rebuild PostgreSQL using --with-libxml.
  428. SET XML OPTION CONTENT;
  429. EXECUTE foo ('<bar/>');
  430. ERROR: prepared statement "foo" does not exist
  431. EXECUTE foo ('good');
  432. ERROR: prepared statement "foo" does not exist
  433. SELECT xml '<!-- in SQL:2006+ a doc is content too--> <?y z?> <!DOCTYPE a><a/>';
  434. ERROR: unsupported XML feature
  435. LINE 1: SELECT xml '<!-- in SQL:2006+ a doc is content too--> <?y z?...
  436. ^
  437. DETAIL: This functionality requires the server to be built with libxml support.
  438. HINT: You need to rebuild PostgreSQL using --with-libxml.
  439. SELECT xml '<?xml version="1.0"?> <!-- hi--> <!DOCTYPE a><a/>';
  440. ERROR: unsupported XML feature
  441. LINE 1: SELECT xml '<?xml version="1.0"?> <!-- hi--> <!DOCTYPE a><a/...
  442. ^
  443. DETAIL: This functionality requires the server to be built with libxml support.
  444. HINT: You need to rebuild PostgreSQL using --with-libxml.
  445. SELECT xml '<!DOCTYPE a><a/>';
  446. ERROR: unsupported XML feature
  447. LINE 1: SELECT xml '<!DOCTYPE a><a/>';
  448. ^
  449. DETAIL: This functionality requires the server to be built with libxml support.
  450. HINT: You need to rebuild PostgreSQL using --with-libxml.
  451. SELECT xml '<!-- hi--> oops <!DOCTYPE a><a/>';
  452. ERROR: unsupported XML feature
  453. LINE 1: SELECT xml '<!-- hi--> oops <!DOCTYPE a><a/>';
  454. ^
  455. DETAIL: This functionality requires the server to be built with libxml support.
  456. HINT: You need to rebuild PostgreSQL using --with-libxml.
  457. SELECT xml '<!-- hi--> <oops/> <!DOCTYPE a><a/>';
  458. ERROR: unsupported XML feature
  459. LINE 1: SELECT xml '<!-- hi--> <oops/> <!DOCTYPE a><a/>';
  460. ^
  461. DETAIL: This functionality requires the server to be built with libxml support.
  462. HINT: You need to rebuild PostgreSQL using --with-libxml.
  463. SELECT xml '<!DOCTYPE a><a/><b/>';
  464. ERROR: unsupported XML feature
  465. LINE 1: SELECT xml '<!DOCTYPE a><a/><b/>';
  466. ^
  467. DETAIL: This functionality requires the server to be built with libxml support.
  468. HINT: You need to rebuild PostgreSQL using --with-libxml.
  469. -- Test backwards parsing
  470. CREATE VIEW xmlview1 AS SELECT xmlcomment('test');
  471. CREATE VIEW xmlview2 AS SELECT xmlconcat('hello', 'you');
  472. ERROR: unsupported XML feature
  473. LINE 1: CREATE VIEW xmlview2 AS SELECT xmlconcat('hello', 'you');
  474. ^
  475. DETAIL: This functionality requires the server to be built with libxml support.
  476. HINT: You need to rebuild PostgreSQL using --with-libxml.
  477. CREATE VIEW xmlview3 AS SELECT xmlelement(name element, xmlattributes (1 as ":one:", 'deuce' as two), 'content&');
  478. ERROR: unsupported XML feature
  479. DETAIL: This functionality requires the server to be built with libxml support.
  480. HINT: You need to rebuild PostgreSQL using --with-libxml.
  481. CREATE VIEW xmlview4 AS SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp;
  482. ERROR: unsupported XML feature
  483. DETAIL: This functionality requires the server to be built with libxml support.
  484. HINT: You need to rebuild PostgreSQL using --with-libxml.
  485. CREATE VIEW xmlview5 AS SELECT xmlparse(content '<abc>x</abc>');
  486. CREATE VIEW xmlview6 AS SELECT xmlpi(name foo, 'bar');
  487. ERROR: unsupported XML feature
  488. DETAIL: This functionality requires the server to be built with libxml support.
  489. HINT: You need to rebuild PostgreSQL using --with-libxml.
  490. CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
  491. ERROR: unsupported XML feature
  492. LINE 1: CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version...
  493. ^
  494. DETAIL: This functionality requires the server to be built with libxml support.
  495. HINT: You need to rebuild PostgreSQL using --with-libxml.
  496. CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
  497. ERROR: unsupported XML feature
  498. LINE 1: ...EATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as ...
  499. ^
  500. DETAIL: This functionality requires the server to be built with libxml support.
  501. HINT: You need to rebuild PostgreSQL using --with-libxml.
  502. CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
  503. ERROR: unsupported XML feature
  504. LINE 1: ...EATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as ...
  505. ^
  506. DETAIL: This functionality requires the server to be built with libxml support.
  507. HINT: You need to rebuild PostgreSQL using --with-libxml.
  508. SELECT table_name, view_definition FROM information_schema.views
  509. WHERE table_name LIKE 'xmlview%' ORDER BY 1;
  510. table_name | view_definition
  511. ------------+--------------------------------------------------------------------------------
  512. xmlview1 | SELECT xmlcomment('test'::text) AS xmlcomment;
  513. xmlview5 | SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
  514. (2 rows)
  515. -- Text XPath expressions evaluation
  516. SELECT xpath('/value', data) FROM xmltest;
  517. xpath
  518. -------
  519. (0 rows)
  520. SELECT xpath(NULL, NULL) IS NULL FROM xmltest;
  521. ?column?
  522. ----------
  523. (0 rows)
  524. SELECT xpath('', '<!-- error -->');
  525. ERROR: unsupported XML feature
  526. LINE 1: SELECT xpath('', '<!-- error -->');
  527. ^
  528. DETAIL: This functionality requires the server to be built with libxml support.
  529. HINT: You need to rebuild PostgreSQL using --with-libxml.
  530. SELECT xpath('//text()', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>');
  531. ERROR: unsupported XML feature
  532. LINE 1: SELECT xpath('//text()', '<local:data xmlns:local="http://12...
  533. ^
  534. DETAIL: This functionality requires the server to be built with libxml support.
  535. HINT: You need to rebuild PostgreSQL using --with-libxml.
  536. SELECT xpath('//loc:piece/@id', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc', 'http://127.0.0.1']]);
  537. ERROR: unsupported XML feature
  538. LINE 1: SELECT xpath('//loc:piece/@id', '<local:data xmlns:local="ht...
  539. ^
  540. DETAIL: This functionality requires the server to be built with libxml support.
  541. HINT: You need to rebuild PostgreSQL using --with-libxml.
  542. SELECT xpath('//loc:piece', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc', 'http://127.0.0.1']]);
  543. ERROR: unsupported XML feature
  544. LINE 1: SELECT xpath('//loc:piece', '<local:data xmlns:local="http:/...
  545. ^
  546. DETAIL: This functionality requires the server to be built with libxml support.
  547. HINT: You need to rebuild PostgreSQL using --with-libxml.
  548. SELECT xpath('//loc:piece', '<local:data xmlns:local="http://127.0.0.1" xmlns="http://127.0.0.2"><local:piece id="1"><internal>number one</internal><internal2/></local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc', 'http://127.0.0.1']]);
  549. ERROR: unsupported XML feature
  550. LINE 1: SELECT xpath('//loc:piece', '<local:data xmlns:local="http:/...
  551. ^
  552. DETAIL: This functionality requires the server to be built with libxml support.
  553. HINT: You need to rebuild PostgreSQL using --with-libxml.
  554. SELECT xpath('//b', '<a>one <b>two</b> three <b>etc</b></a>');
  555. ERROR: unsupported XML feature
  556. LINE 1: SELECT xpath('//b', '<a>one <b>two</b> three <b>etc</b></a>'...
  557. ^
  558. DETAIL: This functionality requires the server to be built with libxml support.
  559. HINT: You need to rebuild PostgreSQL using --with-libxml.
  560. SELECT xpath('//text()', '<root>&lt;</root>');
  561. ERROR: unsupported XML feature
  562. LINE 1: SELECT xpath('//text()', '<root>&lt;</root>');
  563. ^
  564. DETAIL: This functionality requires the server to be built with libxml support.
  565. HINT: You need to rebuild PostgreSQL using --with-libxml.
  566. SELECT xpath('//@value', '<root value="&lt;"/>');
  567. ERROR: unsupported XML feature
  568. LINE 1: SELECT xpath('//@value', '<root value="&lt;"/>');
  569. ^
  570. DETAIL: This functionality requires the server to be built with libxml support.
  571. HINT: You need to rebuild PostgreSQL using --with-libxml.
  572. SELECT xpath('''<<invalid>>''', '<root/>');
  573. ERROR: unsupported XML feature
  574. LINE 1: SELECT xpath('''<<invalid>>''', '<root/>');
  575. ^
  576. DETAIL: This functionality requires the server to be built with libxml support.
  577. HINT: You need to rebuild PostgreSQL using --with-libxml.
  578. SELECT xpath('count(//*)', '<root><sub/><sub/></root>');
  579. ERROR: unsupported XML feature
  580. LINE 1: SELECT xpath('count(//*)', '<root><sub/><sub/></root>');
  581. ^
  582. DETAIL: This functionality requires the server to be built with libxml support.
  583. HINT: You need to rebuild PostgreSQL using --with-libxml.
  584. SELECT xpath('count(//*)=0', '<root><sub/><sub/></root>');
  585. ERROR: unsupported XML feature
  586. LINE 1: SELECT xpath('count(//*)=0', '<root><sub/><sub/></root>');
  587. ^
  588. DETAIL: This functionality requires the server to be built with libxml support.
  589. HINT: You need to rebuild PostgreSQL using --with-libxml.
  590. SELECT xpath('count(//*)=3', '<root><sub/><sub/></root>');
  591. ERROR: unsupported XML feature
  592. LINE 1: SELECT xpath('count(//*)=3', '<root><sub/><sub/></root>');
  593. ^
  594. DETAIL: This functionality requires the server to be built with libxml support.
  595. HINT: You need to rebuild PostgreSQL using --with-libxml.
  596. SELECT xpath('name(/*)', '<root><sub/><sub/></root>');
  597. ERROR: unsupported XML feature
  598. LINE 1: SELECT xpath('name(/*)', '<root><sub/><sub/></root>');
  599. ^
  600. DETAIL: This functionality requires the server to be built with libxml support.
  601. HINT: You need to rebuild PostgreSQL using --with-libxml.
  602. SELECT xpath('/nosuchtag', '<root/>');
  603. ERROR: unsupported XML feature
  604. LINE 1: SELECT xpath('/nosuchtag', '<root/>');
  605. ^
  606. DETAIL: This functionality requires the server to be built with libxml support.
  607. HINT: You need to rebuild PostgreSQL using --with-libxml.
  608. SELECT xpath('root', '<root/>');
  609. ERROR: unsupported XML feature
  610. LINE 1: SELECT xpath('root', '<root/>');
  611. ^
  612. DETAIL: This functionality requires the server to be built with libxml support.
  613. HINT: You need to rebuild PostgreSQL using --with-libxml.
  614. -- Round-trip non-ASCII data through xpath().
  615. DO $$
  616. DECLARE
  617. xml_declaration text := '<?xml version="1.0" encoding="ISO-8859-1"?>';
  618. degree_symbol text;
  619. res xml[];
  620. BEGIN
  621. -- Per the documentation, except when the server encoding is UTF8, xpath()
  622. -- may not work on non-ASCII data. The untranslatable_character and
  623. -- undefined_function traps below, currently dead code, will become relevant
  624. -- if we remove this limitation.
  625. IF current_setting('server_encoding') <> 'UTF8' THEN
  626. RAISE LOG 'skip: encoding % unsupported for xpath',
  627. current_setting('server_encoding');
  628. RETURN;
  629. END IF;
  630. degree_symbol := convert_from('\xc2b0', 'UTF8');
  631. res := xpath('text()', (xml_declaration ||
  632. '<x>' || degree_symbol || '</x>')::xml);
  633. IF degree_symbol <> res[1]::text THEN
  634. RAISE 'expected % (%), got % (%)',
  635. degree_symbol, convert_to(degree_symbol, 'UTF8'),
  636. res[1], convert_to(res[1]::text, 'UTF8');
  637. END IF;
  638. EXCEPTION
  639. -- character with byte sequence 0xc2 0xb0 in encoding "UTF8" has no equivalent in encoding "LATIN8"
  640. WHEN untranslatable_character
  641. -- default conversion function for encoding "UTF8" to "MULE_INTERNAL" does not exist
  642. OR undefined_function
  643. -- unsupported XML feature
  644. OR feature_not_supported THEN
  645. RAISE LOG 'skip: %', SQLERRM;
  646. END
  647. $$;
  648. -- Test xmlexists and xpath_exists
  649. SELECT xmlexists('//town[text() = ''Toronto'']' PASSING BY REF '<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>');
  650. ERROR: unsupported XML feature
  651. LINE 1: ...sts('//town[text() = ''Toronto'']' PASSING BY REF '<towns><t...
  652. ^
  653. DETAIL: This functionality requires the server to be built with libxml support.
  654. HINT: You need to rebuild PostgreSQL using --with-libxml.
  655. SELECT xmlexists('//town[text() = ''Cwmbran'']' PASSING BY REF '<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>');
  656. ERROR: unsupported XML feature
  657. LINE 1: ...sts('//town[text() = ''Cwmbran'']' PASSING BY REF '<towns><t...
  658. ^
  659. DETAIL: This functionality requires the server to be built with libxml support.
  660. HINT: You need to rebuild PostgreSQL using --with-libxml.
  661. SELECT xmlexists('count(/nosuchtag)' PASSING BY REF '<root/>');
  662. ERROR: unsupported XML feature
  663. LINE 1: ...LECT xmlexists('count(/nosuchtag)' PASSING BY REF '<root/>')...
  664. ^
  665. DETAIL: This functionality requires the server to be built with libxml support.
  666. HINT: You need to rebuild PostgreSQL using --with-libxml.
  667. SELECT xpath_exists('//town[text() = ''Toronto'']','<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>'::xml);
  668. ERROR: unsupported XML feature
  669. LINE 1: ...ELECT xpath_exists('//town[text() = ''Toronto'']','<towns><t...
  670. ^
  671. DETAIL: This functionality requires the server to be built with libxml support.
  672. HINT: You need to rebuild PostgreSQL using --with-libxml.
  673. SELECT xpath_exists('//town[text() = ''Cwmbran'']','<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>'::xml);
  674. ERROR: unsupported XML feature
  675. LINE 1: ...ELECT xpath_exists('//town[text() = ''Cwmbran'']','<towns><t...
  676. ^
  677. DETAIL: This functionality requires the server to be built with libxml support.
  678. HINT: You need to rebuild PostgreSQL using --with-libxml.
  679. SELECT xpath_exists('count(/nosuchtag)', '<root/>'::xml);
  680. ERROR: unsupported XML feature
  681. LINE 1: SELECT xpath_exists('count(/nosuchtag)', '<root/>'::xml);
  682. ^
  683. DETAIL: This functionality requires the server to be built with libxml support.
  684. HINT: You need to rebuild PostgreSQL using --with-libxml.
  685. INSERT INTO xmltest VALUES (4, '<menu><beers><name>Budvar</name><cost>free</cost><name>Carling</name><cost>lots</cost></beers></menu>'::xml);
  686. ERROR: unsupported XML feature
  687. LINE 1: INSERT INTO xmltest VALUES (4, '<menu><beers><name>Budvar</n...
  688. ^
  689. DETAIL: This functionality requires the server to be built with libxml support.
  690. HINT: You need to rebuild PostgreSQL using --with-libxml.
  691. INSERT INTO xmltest VALUES (5, '<menu><beers><name>Molson</name><cost>free</cost><name>Carling</name><cost>lots</cost></beers></menu>'::xml);
  692. ERROR: unsupported XML feature
  693. LINE 1: INSERT INTO xmltest VALUES (5, '<menu><beers><name>Molson</n...
  694. ^
  695. DETAIL: This functionality requires the server to be built with libxml support.
  696. HINT: You need to rebuild PostgreSQL using --with-libxml.
  697. INSERT INTO xmltest VALUES (6, '<myns:menu xmlns:myns="http://myns.com"><myns:beers><myns:name>Budvar</myns:name><myns:cost>free</myns:cost><myns:name>Carling</myns:name><myns:cost>lots</myns:cost></myns:beers></myns:menu>'::xml);
  698. ERROR: unsupported XML feature
  699. LINE 1: INSERT INTO xmltest VALUES (6, '<myns:menu xmlns:myns="http:...
  700. ^
  701. DETAIL: This functionality requires the server to be built with libxml support.
  702. HINT: You need to rebuild PostgreSQL using --with-libxml.
  703. INSERT INTO xmltest VALUES (7, '<myns:menu xmlns:myns="http://myns.com"><myns:beers><myns:name>Molson</myns:name><myns:cost>free</myns:cost><myns:name>Carling</myns:name><myns:cost>lots</myns:cost></myns:beers></myns:menu>'::xml);
  704. ERROR: unsupported XML feature
  705. LINE 1: INSERT INTO xmltest VALUES (7, '<myns:menu xmlns:myns="http:...
  706. ^
  707. DETAIL: This functionality requires the server to be built with libxml support.
  708. HINT: You need to rebuild PostgreSQL using --with-libxml.
  709. SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beer' PASSING data);
  710. count
  711. -------
  712. 0
  713. (1 row)
  714. SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beer' PASSING BY REF data BY REF);
  715. count
  716. -------
  717. 0
  718. (1 row)
  719. SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers' PASSING BY REF data);
  720. count
  721. -------
  722. 0
  723. (1 row)
  724. SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers/name[text() = ''Molson'']' PASSING BY REF data);
  725. count
  726. -------
  727. 0
  728. (1 row)
  729. SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beer',data);
  730. count
  731. -------
  732. 0
  733. (1 row)
  734. SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beers',data);
  735. count
  736. -------
  737. 0
  738. (1 row)
  739. SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beers/name[text() = ''Molson'']',data);
  740. count
  741. -------
  742. 0
  743. (1 row)
  744. SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beer',data,ARRAY[ARRAY['myns','http://myns.com']]);
  745. count
  746. -------
  747. 0
  748. (1 row)
  749. SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beers',data,ARRAY[ARRAY['myns','http://myns.com']]);
  750. count
  751. -------
  752. 0
  753. (1 row)
  754. SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beers/myns:name[text() = ''Molson'']',data,ARRAY[ARRAY['myns','http://myns.com']]);
  755. count
  756. -------
  757. 0
  758. (1 row)
  759. CREATE TABLE query ( expr TEXT );
  760. INSERT INTO query VALUES ('/menu/beers/cost[text() = ''lots'']');
  761. SELECT COUNT(id) FROM xmltest, query WHERE xmlexists(expr PASSING BY REF data);
  762. count
  763. -------
  764. 0
  765. (1 row)
  766. -- Test xml_is_well_formed and variants
  767. SELECT xml_is_well_formed_document('<foo>bar</foo>');
  768. ERROR: unsupported XML feature
  769. DETAIL: This functionality requires the server to be built with libxml support.
  770. HINT: You need to rebuild PostgreSQL using --with-libxml.
  771. SELECT xml_is_well_formed_document('abc');
  772. ERROR: unsupported XML feature
  773. DETAIL: This functionality requires the server to be built with libxml support.
  774. HINT: You need to rebuild PostgreSQL using --with-libxml.
  775. SELECT xml_is_well_formed_content('<foo>bar</foo>');
  776. ERROR: unsupported XML feature
  777. DETAIL: This functionality requires the server to be built with libxml support.
  778. HINT: You need to rebuild PostgreSQL using --with-libxml.
  779. SELECT xml_is_well_formed_content('abc');
  780. ERROR: unsupported XML feature
  781. DETAIL: This functionality requires the server to be built with libxml support.
  782. HINT: You need to rebuild PostgreSQL using --with-libxml.
  783. SET xmloption TO DOCUMENT;
  784. SELECT xml_is_well_formed('abc');
  785. ERROR: unsupported XML feature
  786. DETAIL: This functionality requires the server to be built with libxml support.
  787. HINT: You need to rebuild PostgreSQL using --with-libxml.
  788. SELECT xml_is_well_formed('<>');
  789. ERROR: unsupported XML feature
  790. DETAIL: This functionality requires the server to be built with libxml support.
  791. HINT: You need to rebuild PostgreSQL using --with-libxml.
  792. SELECT xml_is_well_formed('<abc/>');
  793. ERROR: unsupported XML feature
  794. DETAIL: This functionality requires the server to be built with libxml support.
  795. HINT: You need to rebuild PostgreSQL using --with-libxml.
  796. SELECT xml_is_well_formed('<foo>bar</foo>');
  797. ERROR: unsupported XML feature
  798. DETAIL: This functionality requires the server to be built with libxml support.
  799. HINT: You need to rebuild PostgreSQL using --with-libxml.
  800. SELECT xml_is_well_formed('<foo>bar</foo');
  801. ERROR: unsupported XML feature
  802. DETAIL: This functionality requires the server to be built with libxml support.
  803. HINT: You need to rebuild PostgreSQL using --with-libxml.
  804. SELECT xml_is_well_formed('<foo><bar>baz</foo>');
  805. ERROR: unsupported XML feature
  806. DETAIL: This functionality requires the server to be built with libxml support.
  807. HINT: You need to rebuild PostgreSQL using --with-libxml.
  808. SELECT xml_is_well_formed('<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>');
  809. ERROR: unsupported XML feature
  810. DETAIL: This functionality requires the server to be built with libxml support.
  811. HINT: You need to rebuild PostgreSQL using --with-libxml.
  812. SELECT xml_is_well_formed('<pg:foo xmlns:pg="http://postgresql.org/stuff">bar</my:foo>');
  813. ERROR: unsupported XML feature
  814. DETAIL: This functionality requires the server to be built with libxml support.
  815. HINT: You need to rebuild PostgreSQL using --with-libxml.
  816. SELECT xml_is_well_formed('<pg:foo xmlns:pg="http://postgresql.org/stuff">bar</pg:foo>');
  817. ERROR: unsupported XML feature
  818. DETAIL: This functionality requires the server to be built with libxml support.
  819. HINT: You need to rebuild PostgreSQL using --with-libxml.
  820. SELECT xml_is_well_formed('<invalidentity>&</abc>');
  821. ERROR: unsupported XML feature
  822. DETAIL: This functionality requires the server to be built with libxml support.
  823. HINT: You need to rebuild PostgreSQL using --with-libxml.
  824. SELECT xml_is_well_formed('<undefinedentity>&idontexist;</abc>');
  825. ERROR: unsupported XML feature
  826. DETAIL: This functionality requires the server to be built with libxml support.
  827. HINT: You need to rebuild PostgreSQL using --with-libxml.
  828. SELECT xml_is_well_formed('<invalidns xmlns=''&lt;''/>');
  829. ERROR: unsupported XML feature
  830. DETAIL: This functionality requires the server to be built with libxml support.
  831. HINT: You need to rebuild PostgreSQL using --with-libxml.
  832. SELECT xml_is_well_formed('<relativens xmlns=''relative''/>');
  833. ERROR: unsupported XML feature
  834. DETAIL: This functionality requires the server to be built with libxml support.
  835. HINT: You need to rebuild PostgreSQL using --with-libxml.
  836. SELECT xml_is_well_formed('<twoerrors>&idontexist;</unbalanced>');
  837. ERROR: unsupported XML feature
  838. DETAIL: This functionality requires the server to be built with libxml support.
  839. HINT: You need to rebuild PostgreSQL using --with-libxml.
  840. SET xmloption TO CONTENT;
  841. SELECT xml_is_well_formed('abc');
  842. ERROR: unsupported XML feature
  843. DETAIL: This functionality requires the server to be built with libxml support.
  844. HINT: You need to rebuild PostgreSQL using --with-libxml.
  845. -- Since xpath() deals with namespaces, it's a bit stricter about
  846. -- what's well-formed and what's not. If we don't obey these rules
  847. -- (i.e. ignore namespace-related errors from libxml), xpath()
  848. -- fails in subtle ways. The following would for example produce
  849. -- the xml value
  850. -- <invalidns xmlns='<'/>
  851. -- which is invalid because '<' may not appear un-escaped in
  852. -- attribute values.
  853. -- Since different libxml versions emit slightly different
  854. -- error messages, we suppress the DETAIL in this test.
  855. \set VERBOSITY terse
  856. SELECT xpath('/*', '<invalidns xmlns=''&lt;''/>');
  857. ERROR: unsupported XML feature at character 20
  858. \set VERBOSITY default
  859. -- Again, the XML isn't well-formed for namespace purposes
  860. SELECT xpath('/*', '<nosuchprefix:tag/>');
  861. ERROR: unsupported XML feature
  862. LINE 1: SELECT xpath('/*', '<nosuchprefix:tag/>');
  863. ^
  864. DETAIL: This functionality requires the server to be built with libxml support.
  865. HINT: You need to rebuild PostgreSQL using --with-libxml.
  866. -- XPath deprecates relative namespaces, but they're not supposed to
  867. -- throw an error, only a warning.
  868. SELECT xpath('/*', '<relativens xmlns=''relative''/>');
  869. ERROR: unsupported XML feature
  870. LINE 1: SELECT xpath('/*', '<relativens xmlns=''relative''/>');
  871. ^
  872. DETAIL: This functionality requires the server to be built with libxml support.
  873. HINT: You need to rebuild PostgreSQL using --with-libxml.
  874. -- External entity references should not leak filesystem information.
  875. SELECT XMLPARSE(DOCUMENT '<!DOCTYPE foo [<!ENTITY c SYSTEM "/etc/passwd">]><foo>&c;</foo>');
  876. ERROR: unsupported XML feature
  877. DETAIL: This functionality requires the server to be built with libxml support.
  878. HINT: You need to rebuild PostgreSQL using --with-libxml.
  879. SELECT XMLPARSE(DOCUMENT '<!DOCTYPE foo [<!ENTITY c SYSTEM "/etc/no.such.file">]><foo>&c;</foo>');
  880. ERROR: unsupported XML feature
  881. DETAIL: This functionality requires the server to be built with libxml support.
  882. HINT: You need to rebuild PostgreSQL using --with-libxml.
  883. -- This might or might not load the requested DTD, but it mustn't throw error.
  884. SELECT XMLPARSE(DOCUMENT '<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"><chapter>&nbsp;</chapter>');
  885. ERROR: unsupported XML feature
  886. DETAIL: This functionality requires the server to be built with libxml support.
  887. HINT: You need to rebuild PostgreSQL using --with-libxml.
  888. -- XMLPATH tests
  889. CREATE TABLE xmldata(data xml);
  890. INSERT INTO xmldata VALUES('<ROWS>
  891. <ROW id="1">
  892. <COUNTRY_ID>AU</COUNTRY_ID>
  893. <COUNTRY_NAME>Australia</COUNTRY_NAME>
  894. <REGION_ID>3</REGION_ID>
  895. </ROW>
  896. <ROW id="2">
  897. <COUNTRY_ID>CN</COUNTRY_ID>
  898. <COUNTRY_NAME>China</COUNTRY_NAME>
  899. <REGION_ID>3</REGION_ID>
  900. </ROW>
  901. <ROW id="3">
  902. <COUNTRY_ID>HK</COUNTRY_ID>
  903. <COUNTRY_NAME>HongKong</COUNTRY_NAME>
  904. <REGION_ID>3</REGION_ID>
  905. </ROW>
  906. <ROW id="4">
  907. <COUNTRY_ID>IN</COUNTRY_ID>
  908. <COUNTRY_NAME>India</COUNTRY_NAME>
  909. <REGION_ID>3</REGION_ID>
  910. </ROW>
  911. <ROW id="5">
  912. <COUNTRY_ID>JP</COUNTRY_ID>
  913. <COUNTRY_NAME>Japan</COUNTRY_NAME>
  914. <REGION_ID>3</REGION_ID><PREMIER_NAME>Sinzo Abe</PREMIER_NAME>
  915. </ROW>
  916. <ROW id="6">
  917. <COUNTRY_ID>SG</COUNTRY_ID>
  918. <COUNTRY_NAME>Singapore</COUNTRY_NAME>
  919. <REGION_ID>3</REGION_ID><SIZE unit="km">791</SIZE>
  920. </ROW>
  921. </ROWS>');
  922. ERROR: unsupported XML feature
  923. LINE 1: INSERT INTO xmldata VALUES('<ROWS>
  924. ^
  925. DETAIL: This functionality requires the server to be built with libxml support.
  926. HINT: You need to rebuild PostgreSQL using --with-libxml.
  927. -- XMLTABLE with columns
  928. SELECT xmltable.*
  929. FROM (SELECT data FROM xmldata) x,
  930. LATERAL XMLTABLE('/ROWS/ROW'
  931. PASSING data
  932. COLUMNS id int PATH '@id',
  933. _id FOR ORDINALITY,
  934. country_name text PATH 'COUNTRY_NAME/text()' NOT NULL,
  935. country_id text PATH 'COUNTRY_ID',
  936. region_id int PATH 'REGION_ID',
  937. size float PATH 'SIZE',
  938. unit text PATH 'SIZE/@unit',
  939. premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
  940. id | _id | country_name | country_id | region_id | size | unit | premier_name
  941. ----+-----+--------------+------------+-----------+------+------+--------------
  942. (0 rows)
  943. CREATE VIEW xmltableview1 AS SELECT xmltable.*
  944. FROM (SELECT data FROM xmldata) x,
  945. LATERAL XMLTABLE('/ROWS/ROW'
  946. PASSING data
  947. COLUMNS id int PATH '@id',
  948. _id FOR ORDINALITY,
  949. country_name text PATH 'COUNTRY_NAME/text()' NOT NULL,
  950. country_id text PATH 'COUNTRY_ID',
  951. region_id int PATH 'REGION_ID',
  952. size float PATH 'SIZE',
  953. unit text PATH 'SIZE/@unit',
  954. premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
  955. SELECT * FROM xmltableview1;
  956. id | _id | country_name | country_id | region_id | size | unit | premier_name
  957. ----+-----+--------------+------------+-----------+------+------+--------------
  958. (0 rows)
  959. \sv xmltableview1
  960. CREATE OR REPLACE VIEW public.xmltableview1 AS
  961. SELECT "xmltable".id,
  962. "xmltable"._id,
  963. "xmltable".country_name,
  964. "xmltable".country_id,
  965. "xmltable".region_id,
  966. "xmltable".size,
  967. "xmltable".unit,
  968. "xmltable".premier_name
  969. FROM ( SELECT xmldata.data
  970. FROM xmldata) x,
  971. LATERAL XMLTABLE(('/ROWS/ROW'::text) PASSING (x.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME/text()'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text))
  972. EXPLAIN (COSTS OFF) SELECT * FROM xmltableview1;
  973. QUERY PLAN
  974. -----------------------------------------
  975. Nested Loop
  976. -> Seq Scan on xmldata
  977. -> Table Function Scan on "xmltable"
  978. (3 rows)
  979. EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM xmltableview1;
  980. QUERY PLAN
  981. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  982. Nested Loop
  983. Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name
  984. -> Seq Scan on public.xmldata
  985. Output: xmldata.data
  986. -> Table Function Scan on "xmltable"
  987. Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name
  988. Table Function Call: XMLTABLE(('/ROWS/ROW'::text) PASSING (xmldata.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME/text()'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text))
  989. (7 rows)
  990. -- errors
  991. SELECT * FROM XMLTABLE (ROW () PASSING null COLUMNS v1 timestamp) AS f (v1, v2);
  992. ERROR: XMLTABLE function has 1 columns available but 2 columns specified
  993. -- XMLNAMESPACES tests
  994. SELECT * FROM XMLTABLE(XMLNAMESPACES('http://x.y' AS zz),
  995. '/zz:rows/zz:row'
  996. PASSING '<rows xmlns="http://x.y"><row><a>10</a></row></rows>'
  997. COLUMNS a int PATH 'zz:a');
  998. ERROR: unsupported XML feature
  999. LINE 3: PASSING '<rows xmlns="http://x.y"><row...
  1000. ^
  1001. DETAIL: This functionality requires the server to be built with libxml support.
  1002. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1003. CREATE VIEW xmltableview2 AS SELECT * FROM XMLTABLE(XMLNAMESPACES('http://x.y' AS zz),
  1004. '/zz:rows/zz:row'
  1005. PASSING '<rows xmlns="http://x.y"><row><a>10</a></row></rows>'
  1006. COLUMNS a int PATH 'zz:a');
  1007. ERROR: unsupported XML feature
  1008. LINE 3: PASSING '<rows xmlns="http://x.y"><row...
  1009. ^
  1010. DETAIL: This functionality requires the server to be built with libxml support.
  1011. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1012. SELECT * FROM xmltableview2;
  1013. ERROR: relation "xmltableview2" does not exist
  1014. LINE 1: SELECT * FROM xmltableview2;
  1015. ^
  1016. SELECT * FROM XMLTABLE(XMLNAMESPACES(DEFAULT 'http://x.y'),
  1017. '/rows/row'
  1018. PASSING '<rows xmlns="http://x.y"><row><a>10</a></row></rows>'
  1019. COLUMNS a int PATH 'a');
  1020. ERROR: unsupported XML feature
  1021. LINE 3: PASSING '<rows xmlns="http://x.y"><row...
  1022. ^
  1023. DETAIL: This functionality requires the server to be built with libxml support.
  1024. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1025. SELECT * FROM XMLTABLE('.'
  1026. PASSING '<foo/>'
  1027. COLUMNS a text PATH 'foo/namespace::node()');
  1028. ERROR: unsupported XML feature
  1029. LINE 2: PASSING '<foo/>'
  1030. ^
  1031. DETAIL: This functionality requires the server to be built with libxml support.
  1032. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1033. -- used in prepare statements
  1034. PREPARE pp AS
  1035. SELECT xmltable.*
  1036. FROM (SELECT data FROM xmldata) x,
  1037. LATERAL XMLTABLE('/ROWS/ROW'
  1038. PASSING data
  1039. COLUMNS id int PATH '@id',
  1040. _id FOR ORDINALITY,
  1041. country_name text PATH 'COUNTRY_NAME' NOT NULL,
  1042. country_id text PATH 'COUNTRY_ID',
  1043. region_id int PATH 'REGION_ID',
  1044. size float PATH 'SIZE',
  1045. unit text PATH 'SIZE/@unit',
  1046. premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
  1047. EXECUTE pp;
  1048. id | _id | country_name | country_id | region_id | size | unit | premier_name
  1049. ----+-----+--------------+------------+-----------+------+------+--------------
  1050. (0 rows)
  1051. SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int);
  1052. COUNTRY_NAME | REGION_ID
  1053. --------------+-----------
  1054. (0 rows)
  1055. SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id FOR ORDINALITY, "COUNTRY_NAME" text, "REGION_ID" int);
  1056. id | COUNTRY_NAME | REGION_ID
  1057. ----+--------------+-----------
  1058. (0 rows)
  1059. SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int);
  1060. id | COUNTRY_NAME | REGION_ID
  1061. ----+--------------+-----------
  1062. (0 rows)
  1063. SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id');
  1064. id
  1065. ----
  1066. (0 rows)
  1067. SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id FOR ORDINALITY);
  1068. id
  1069. ----
  1070. (0 rows)
  1071. SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int, rawdata xml PATH '.');
  1072. id | COUNTRY_NAME | REGION_ID | rawdata
  1073. ----+--------------+-----------+---------
  1074. (0 rows)
  1075. SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int, rawdata xml PATH './*');
  1076. id | COUNTRY_NAME | REGION_ID | rawdata
  1077. ----+--------------+-----------+---------
  1078. (0 rows)
  1079. SELECT * FROM xmltable('/root' passing '<root><element>a1a<!-- aaaa -->a2a<?aaaaa?> <!--z--> bbbb<x>xxx</x>cccc</element></root>' COLUMNS element text);
  1080. ERROR: unsupported XML feature
  1081. LINE 1: SELECT * FROM xmltable('/root' passing '<root><element>a1a<!...
  1082. ^
  1083. DETAIL: This functionality requires the server to be built with libxml support.
  1084. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1085. SELECT * FROM xmltable('/root' passing '<root><element>a1a<!-- aaaa -->a2a<?aaaaa?> <!--z--> bbbb<x>xxx</x>cccc</element></root>' COLUMNS element text PATH 'element/text()'); -- should fail
  1086. ERROR: unsupported XML feature
  1087. LINE 1: SELECT * FROM xmltable('/root' passing '<root><element>a1a<!...
  1088. ^
  1089. DETAIL: This functionality requires the server to be built with libxml support.
  1090. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1091. -- CDATA test
  1092. select * from xmltable('d/r' passing '<d><r><c><![CDATA[<hello> &"<>!<a>foo</a>]]></c></r><r><c>2</c></r></d>' columns c text);
  1093. ERROR: unsupported XML feature
  1094. LINE 1: select * from xmltable('d/r' passing '<d><r><c><![CDATA[<hel...
  1095. ^
  1096. DETAIL: This functionality requires the server to be built with libxml support.
  1097. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1098. -- XML builtin entities
  1099. SELECT * FROM xmltable('/x/a' PASSING '<x><a><ent>&apos;</ent></a><a><ent>&quot;</ent></a><a><ent>&amp;</ent></a><a><ent>&lt;</ent></a><a><ent>&gt;</ent></a></x>' COLUMNS ent text);
  1100. ERROR: unsupported XML feature
  1101. LINE 1: SELECT * FROM xmltable('/x/a' PASSING '<x><a><ent>&apos;</en...
  1102. ^
  1103. DETAIL: This functionality requires the server to be built with libxml support.
  1104. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1105. SELECT * FROM xmltable('/x/a' PASSING '<x><a><ent>&apos;</ent></a><a><ent>&quot;</ent></a><a><ent>&amp;</ent></a><a><ent>&lt;</ent></a><a><ent>&gt;</ent></a></x>' COLUMNS ent xml);
  1106. ERROR: unsupported XML feature
  1107. LINE 1: SELECT * FROM xmltable('/x/a' PASSING '<x><a><ent>&apos;</en...
  1108. ^
  1109. DETAIL: This functionality requires the server to be built with libxml support.
  1110. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1111. EXPLAIN (VERBOSE, COSTS OFF)
  1112. SELECT xmltable.*
  1113. FROM (SELECT data FROM xmldata) x,
  1114. LATERAL XMLTABLE('/ROWS/ROW'
  1115. PASSING data
  1116. COLUMNS id int PATH '@id',
  1117. _id FOR ORDINALITY,
  1118. country_name text PATH 'COUNTRY_NAME' NOT NULL,
  1119. country_id text PATH 'COUNTRY_ID',
  1120. region_id int PATH 'REGION_ID',
  1121. size float PATH 'SIZE',
  1122. unit text PATH 'SIZE/@unit',
  1123. premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
  1124. QUERY PLAN
  1125. -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1126. Nested Loop
  1127. Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name
  1128. -> Seq Scan on public.xmldata
  1129. Output: xmldata.data
  1130. -> Table Function Scan on "xmltable"
  1131. Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name
  1132. Table Function Call: XMLTABLE(('/ROWS/ROW'::text) PASSING (xmldata.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text))
  1133. (7 rows)
  1134. -- test qual
  1135. SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int) WHERE "COUNTRY_NAME" = 'Japan';
  1136. COUNTRY_NAME | REGION_ID
  1137. --------------+-----------
  1138. (0 rows)
  1139. EXPLAIN (VERBOSE, COSTS OFF)
  1140. SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int) WHERE "COUNTRY_NAME" = 'Japan';
  1141. QUERY PLAN
  1142. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1143. Nested Loop
  1144. Output: "xmltable"."COUNTRY_NAME", "xmltable"."REGION_ID"
  1145. -> Seq Scan on public.xmldata
  1146. Output: xmldata.data
  1147. -> Table Function Scan on "xmltable"
  1148. Output: "xmltable"."COUNTRY_NAME", "xmltable"."REGION_ID"
  1149. Table Function Call: XMLTABLE(('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]'::text) PASSING (xmldata.data) COLUMNS "COUNTRY_NAME" text, "REGION_ID" integer)
  1150. Filter: ("xmltable"."COUNTRY_NAME" = 'Japan'::text)
  1151. (8 rows)
  1152. -- should to work with more data
  1153. INSERT INTO xmldata VALUES('<ROWS>
  1154. <ROW id="10">
  1155. <COUNTRY_ID>CZ</COUNTRY_ID>
  1156. <COUNTRY_NAME>Czech Republic</COUNTRY_NAME>
  1157. <REGION_ID>2</REGION_ID><PREMIER_NAME>Milos Zeman</PREMIER_NAME>
  1158. </ROW>
  1159. <ROW id="11">
  1160. <COUNTRY_ID>DE</COUNTRY_ID>
  1161. <COUNTRY_NAME>Germany</COUNTRY_NAME>
  1162. <REGION_ID>2</REGION_ID>
  1163. </ROW>
  1164. <ROW id="12">
  1165. <COUNTRY_ID>FR</COUNTRY_ID>
  1166. <COUNTRY_NAME>France</COUNTRY_NAME>
  1167. <REGION_ID>2</REGION_ID>
  1168. </ROW>
  1169. </ROWS>');
  1170. ERROR: unsupported XML feature
  1171. LINE 1: INSERT INTO xmldata VALUES('<ROWS>
  1172. ^
  1173. DETAIL: This functionality requires the server to be built with libxml support.
  1174. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1175. INSERT INTO xmldata VALUES('<ROWS>
  1176. <ROW id="20">
  1177. <COUNTRY_ID>EG</COUNTRY_ID>
  1178. <COUNTRY_NAME>Egypt</COUNTRY_NAME>
  1179. <REGION_ID>1</REGION_ID>
  1180. </ROW>
  1181. <ROW id="21">
  1182. <COUNTRY_ID>SD</COUNTRY_ID>
  1183. <COUNTRY_NAME>Sudan</COUNTRY_NAME>
  1184. <REGION_ID>1</REGION_ID>
  1185. </ROW>
  1186. </ROWS>');
  1187. ERROR: unsupported XML feature
  1188. LINE 1: INSERT INTO xmldata VALUES('<ROWS>
  1189. ^
  1190. DETAIL: This functionality requires the server to be built with libxml support.
  1191. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1192. SELECT xmltable.*
  1193. FROM (SELECT data FROM xmldata) x,
  1194. LATERAL XMLTABLE('/ROWS/ROW'
  1195. PASSING data
  1196. COLUMNS id int PATH '@id',
  1197. _id FOR ORDINALITY,
  1198. country_name text PATH 'COUNTRY_NAME' NOT NULL,
  1199. country_id text PATH 'COUNTRY_ID',
  1200. region_id int PATH 'REGION_ID',
  1201. size float PATH 'SIZE',
  1202. unit text PATH 'SIZE/@unit',
  1203. premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
  1204. id | _id | country_name | country_id | region_id | size | unit | premier_name
  1205. ----+-----+--------------+------------+-----------+------+------+--------------
  1206. (0 rows)
  1207. SELECT xmltable.*
  1208. FROM (SELECT data FROM xmldata) x,
  1209. LATERAL XMLTABLE('/ROWS/ROW'
  1210. PASSING data
  1211. COLUMNS id int PATH '@id',
  1212. _id FOR ORDINALITY,
  1213. country_name text PATH 'COUNTRY_NAME' NOT NULL,
  1214. country_id text PATH 'COUNTRY_ID',
  1215. region_id int PATH 'REGION_ID',
  1216. size float PATH 'SIZE',
  1217. unit text PATH 'SIZE/@unit',
  1218. premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified')
  1219. WHERE region_id = 2;
  1220. id | _id | country_name | country_id | region_id | size | unit | premier_name
  1221. ----+-----+--------------+------------+-----------+------+------+--------------
  1222. (0 rows)
  1223. EXPLAIN (VERBOSE, COSTS OFF)
  1224. SELECT xmltable.*
  1225. FROM (SELECT data FROM xmldata) x,
  1226. LATERAL XMLTABLE('/ROWS/ROW'
  1227. PASSING data
  1228. COLUMNS id int PATH '@id',
  1229. _id FOR ORDINALITY,
  1230. country_name text PATH 'COUNTRY_NAME' NOT NULL,
  1231. country_id text PATH 'COUNTRY_ID',
  1232. region_id int PATH 'REGION_ID',
  1233. size float PATH 'SIZE',
  1234. unit text PATH 'SIZE/@unit',
  1235. premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified')
  1236. WHERE region_id = 2;
  1237. QUERY PLAN
  1238. -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1239. Nested Loop
  1240. Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name
  1241. -> Seq Scan on public.xmldata
  1242. Output: xmldata.data
  1243. -> Table Function Scan on "xmltable"
  1244. Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name
  1245. Table Function Call: XMLTABLE(('/ROWS/ROW'::text) PASSING (xmldata.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text))
  1246. Filter: ("xmltable".region_id = 2)
  1247. (8 rows)
  1248. -- should fail, NULL value
  1249. SELECT xmltable.*
  1250. FROM (SELECT data FROM xmldata) x,
  1251. LATERAL XMLTABLE('/ROWS/ROW'
  1252. PASSING data
  1253. COLUMNS id int PATH '@id',
  1254. _id FOR ORDINALITY,
  1255. country_name text PATH 'COUNTRY_NAME' NOT NULL,
  1256. country_id text PATH 'COUNTRY_ID',
  1257. region_id int PATH 'REGION_ID',
  1258. size float PATH 'SIZE' NOT NULL,
  1259. unit text PATH 'SIZE/@unit',
  1260. premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
  1261. id | _id | country_name | country_id | region_id | size | unit | premier_name
  1262. ----+-----+--------------+------------+-----------+------+------+--------------
  1263. (0 rows)
  1264. -- if all is ok, then result is empty
  1265. -- one line xml test
  1266. WITH
  1267. x AS (SELECT proname, proowner, procost::numeric, pronargs,
  1268. array_to_string(proargnames,',') as proargnames,
  1269. case when proargtypes <> '' then array_to_string(proargtypes::oid[],',') end as proargtypes
  1270. FROM pg_proc WHERE proname = 'f_leak'),
  1271. y AS (SELECT xmlelement(name proc,
  1272. xmlforest(proname, proowner,
  1273. procost, pronargs,
  1274. proargnames, proargtypes)) as proc
  1275. FROM x),
  1276. z AS (SELECT xmltable.*
  1277. FROM y,
  1278. LATERAL xmltable('/proc' PASSING proc
  1279. COLUMNS proname name,
  1280. proowner oid,
  1281. procost float,
  1282. pronargs int,
  1283. proargnames text,
  1284. proargtypes text))
  1285. SELECT * FROM z
  1286. EXCEPT SELECT * FROM x;
  1287. ERROR: unsupported XML feature
  1288. DETAIL: This functionality requires the server to be built with libxml support.
  1289. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1290. -- multi line xml test, result should be empty too
  1291. WITH
  1292. x AS (SELECT proname, proowner, procost::numeric, pronargs,
  1293. array_to_string(proargnames,',') as proargnames,
  1294. case when proargtypes <> '' then array_to_string(proargtypes::oid[],',') end as proargtypes
  1295. FROM pg_proc),
  1296. y AS (SELECT xmlelement(name data,
  1297. xmlagg(xmlelement(name proc,
  1298. xmlforest(proname, proowner, procost,
  1299. pronargs, proargnames, proargtypes)))) as doc
  1300. FROM x),
  1301. z AS (SELECT xmltable.*
  1302. FROM y,
  1303. LATERAL xmltable('/data/proc' PASSING doc
  1304. COLUMNS proname name,
  1305. proowner oid,
  1306. procost float,
  1307. pronargs int,
  1308. proargnames text,
  1309. proargtypes text))
  1310. SELECT * FROM z
  1311. EXCEPT SELECT * FROM x;
  1312. ERROR: unsupported XML feature
  1313. DETAIL: This functionality requires the server to be built with libxml support.
  1314. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1315. CREATE TABLE xmltest2(x xml, _path text);
  1316. INSERT INTO xmltest2 VALUES('<d><r><ac>1</ac></r></d>', 'A');
  1317. ERROR: unsupported XML feature
  1318. LINE 1: INSERT INTO xmltest2 VALUES('<d><r><ac>1</ac></r></d>', 'A')...
  1319. ^
  1320. DETAIL: This functionality requires the server to be built with libxml support.
  1321. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1322. INSERT INTO xmltest2 VALUES('<d><r><bc>2</bc></r></d>', 'B');
  1323. ERROR: unsupported XML feature
  1324. LINE 1: INSERT INTO xmltest2 VALUES('<d><r><bc>2</bc></r></d>', 'B')...
  1325. ^
  1326. DETAIL: This functionality requires the server to be built with libxml support.
  1327. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1328. INSERT INTO xmltest2 VALUES('<d><r><cc>3</cc></r></d>', 'C');
  1329. ERROR: unsupported XML feature
  1330. LINE 1: INSERT INTO xmltest2 VALUES('<d><r><cc>3</cc></r></d>', 'C')...
  1331. ^
  1332. DETAIL: This functionality requires the server to be built with libxml support.
  1333. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1334. INSERT INTO xmltest2 VALUES('<d><r><dc>2</dc></r></d>', 'D');
  1335. ERROR: unsupported XML feature
  1336. LINE 1: INSERT INTO xmltest2 VALUES('<d><r><dc>2</dc></r></d>', 'D')...
  1337. ^
  1338. DETAIL: This functionality requires the server to be built with libxml support.
  1339. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1340. SELECT xmltable.* FROM xmltest2, LATERAL xmltable('/d/r' PASSING x COLUMNS a int PATH '' || lower(_path) || 'c');
  1341. a
  1342. ---
  1343. (0 rows)
  1344. SELECT xmltable.* FROM xmltest2, LATERAL xmltable(('/d/r/' || lower(_path) || 'c') PASSING x COLUMNS a int PATH '.');
  1345. a
  1346. ---
  1347. (0 rows)
  1348. SELECT xmltable.* FROM xmltest2, LATERAL xmltable(('/d/r/' || lower(_path) || 'c') PASSING x COLUMNS a int PATH 'x' DEFAULT ascii(_path) - 54);
  1349. a
  1350. ---
  1351. (0 rows)
  1352. -- XPath result can be boolean or number too
  1353. SELECT * FROM XMLTABLE('*' PASSING '<a>a</a>' COLUMNS a xml PATH '.', b text PATH '.', c text PATH '"hi"', d boolean PATH '. = "a"', e integer PATH 'string-length(.)');
  1354. ERROR: unsupported XML feature
  1355. LINE 1: SELECT * FROM XMLTABLE('*' PASSING '<a>a</a>' COLUMNS a xml ...
  1356. ^
  1357. DETAIL: This functionality requires the server to be built with libxml support.
  1358. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1359. \x
  1360. SELECT * FROM XMLTABLE('*' PASSING '<e>pre<!--c1--><?pi arg?><![CDATA[&ent1]]><n2>&amp;deep</n2>post</e>' COLUMNS x xml PATH 'node()', y xml PATH '/');
  1361. ERROR: unsupported XML feature
  1362. LINE 1: SELECT * FROM XMLTABLE('*' PASSING '<e>pre<!--c1--><?pi arg?...
  1363. ^
  1364. DETAIL: This functionality requires the server to be built with libxml support.
  1365. HINT: You need to rebuild PostgreSQL using --with-libxml.
  1366. \x
  1367. SELECT * FROM XMLTABLE('.' PASSING XMLELEMENT(NAME a) columns a varchar(20) PATH '"<foo/>"', b xml PATH '"<foo/>"');
  1368. ERROR: unsupported XML feature
  1369. DETAIL: This functionality requires the server to be built with libxml support.
  1370. HINT: You need to rebuild PostgreSQL using --with-libxml.