Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLTYPE as "real" XML #162

Open
daviessm opened this issue Jun 6, 2021 · 3 comments
Open

XMLTYPE as "real" XML #162

daviessm opened this issue Jun 6, 2021 · 3 comments

Comments

@daviessm
Copy link

daviessm commented Jun 6, 2021

  1. Describe your new request in detail

I would like to be able to read XMLTYPE data as XML without having to re-parse it from a string. Of course, this would need to be able to return data larger than VARCHAR2(4000) as well.

  1. Give supporting information about tools and operating systems. Give relevant product version numbers

My use case for this would be through implementation in rust-oracle in both Linux and Windows.

@cjbj
Copy link
Member

cjbj commented Jun 8, 2021

Noted. Historically the XML team hadn't exposed necessary APIs through the Oracle Client C libraries, but that may have been resolved.

@kubo
Copy link

kubo commented Jun 28, 2021

XML APIs seem to be available at least since Oracle instant client 11.2.0.4.

I tested it using this code. It is compilable since Oracle instant client SDK 18.3 as it is. Oracle instant client SDK 11.2.0.4 doesn't include necessary header files. However it is compilable by copying orastruc.h, xmlerr.h and xmlproc.h and it runs fine.

The code inserts the following XML and fetches it. The total size is about 640k.

<data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
  <data>xxxx ... omitted (the size is 64k - 2) ...xxx</data>
</data>

Note that the maximum size of one text node seems "64k - 2". If the size (see here) is changed to "64k - 1" or bigger, it crashes by segmentation fault.

The 64k limitation may be overcome by Orastream APIs.
In https://docs.oracle.com/en/database/oracle/oracle-database/19/caxml/package-Orastream-API.html

Orastream APIs support handling of text and binary nodes that exceed 64K in an XML document.

@cjbj
Copy link
Member

cjbj commented Jun 28, 2021

There might have been some historic 'thunking' issues on Windows, possibly fixed in 18.1 (with various backports).
Overall the topic is a bit murky and would take some effort to productize. Aside from direct API support @anthony-tuininga logged at least one enhancement request to the XML team for default conversion improvements; I can see this is still open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants