kubo/rust-oracle

Request for REF_CURSOR type

Closed this issue · 9 comments

I have a program which iterates through millions of rows, some tables having ~50 columns and doing this through the existing functions seems to be quite slow when there are a lot of columns.

In a similar program written in Java I switched to using REF CURSORs through the JDBC driver and this drastically improved performance. I'd like to be able to use the same in Rust.

kubo commented

I tried it and it worked on my local machine. However it is dirty work. I cannot decide its API design now. Well, I'll decide it and release the next version within a few weeks.

No rush from me. I'm doing this as a hobby project at the moment and trying to narrow down its performance issues. If you want to pre-release a test version I can give it a try.

kubo commented

I added REF_CURSOR support to the git master branch.

I have not written documents about it. oracle::sql_type::RefCursor type has four query methods. See this test code also.

Implicit statement results are also supported. See this doc comment.

I was having a look at this this morning. I use r2d2-oracle for connection pooling and when I link that to 0.5.3-dev of rust-oracle (current git master) it complains about some async methods:

error[E0277]: `*mut oracle::binding::dpiConn` cannot be shared between threads safely
  --> src/lib.rs:76:5
   |
76 |     type Connection = oracle::Connection;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut oracle::binding::dpiConn` cannot be shared between threads safely
   | 
  ::: /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/r2d2-0.8.9/src/lib.rs:72:22
   |
72 |     type Connection: Send + 'static;
   |                      ---- required by this bound in `r2d2::ManageConnection::Connection`
   |
   = help: within `oracle::connection::InnerConn`, the trait `Sync` is not implemented for `*mut oracle::binding::dpiConn`
   = note: required because it appears within the type `oracle::connection::InnerConn`
   = note: required because of the requirements on the impl of `Send` for `Arc<oracle::connection::InnerConn>`
   = note: required because it appears within the type `Connection`

error[E0277]: `*mut oracle::binding::dpiConn` cannot be sent between threads safely
  --> src/lib.rs:76:5
   |
76 |     type Connection = oracle::Connection;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut oracle::binding::dpiConn` cannot be sent between threads safely
   | 
  ::: /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/r2d2-0.8.9/src/lib.rs:72:22
   |
72 |     type Connection: Send + 'static;
   |                      ---- required by this bound in `r2d2::ManageConnection::Connection`
   |
   = help: within `oracle::connection::InnerConn`, the trait `Send` is not implemented for `*mut oracle::binding::dpiConn`
   = note: required because it appears within the type `oracle::connection::InnerConn`
   = note: required because of the requirements on the impl of `Send` for `Arc<oracle::connection::InnerConn>`
   = note: required because it appears within the type `Connection`

error: aborting due to 2 previous errors

Is this an oversight or are changes needed to r2d2-oracle as well?

kubo commented

Thanks for the report. I'll fix it.

It is an incompatible change. The Connection struct implements Sync and Send at 0.5.2. However it doesn't at git master.

kubo commented

@daviessm
Fixed. Could you try the latest git master?

Yes - I can use REF_CURSORs exactly as expected now, thanks. Happy to close this issue.

kubo commented

OK. I closed this issue.
The next version 0.5.3 will be released this weekend.

kubo commented

The next version 0.5.3 will be released this weekend.

It is postponed by one week. I'll change structs for lob locator types: oracle::sql_type::Clob and oracle::sql_type::Blob, which are new features in the next version.