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

Request for REF_CURSOR type #38

Closed
daviessm opened this issue Jun 18, 2021 · 9 comments
Closed

Request for REF_CURSOR type #38

daviessm opened this issue Jun 18, 2021 · 9 comments

Comments

@daviessm
Copy link
Contributor

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
Copy link
Owner

kubo commented Jun 21, 2021

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.

@daviessm
Copy link
Contributor Author

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
Copy link
Owner

kubo commented Jul 26, 2021

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.

@daviessm
Copy link
Contributor Author

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.lhy31512.workers.dev-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.lhy31512.workers.dev-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
Copy link
Owner

kubo commented Jul 28, 2021

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
Copy link
Owner

kubo commented Jul 28, 2021

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

@daviessm
Copy link
Contributor Author

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

@kubo
Copy link
Owner

kubo commented Jul 29, 2021

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

@kubo kubo closed this as completed Jul 29, 2021
@kubo
Copy link
Owner

kubo commented Aug 1, 2021

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.

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

No branches or pull requests

2 participants