kubo / rust-oracle

Oracle driver for Rust
191 stars 44 forks source link

Segfault while trying to print a float #19

Closed mexus closed 4 years ago

mexus commented 4 years ago

Dear Kubo-san,

First of all, thanks for the great wrapper library!

However, there is a small issue with Object::get_by_attr method: when using FLOAT data type, a call to dpiObject_getAttributeValue results in a segfault, because internally ODPI-C library treats FLOAT as a subtype of NUMBER and expects a buffer in asBytes.ptr, which is currently set only when the attr.oratype is OracleType::Number (.. which corresponds to NUMBER, but not to FLOAT).

I am unsure whether it is a bug in oracle's documentation of dpiObject_getAttributeValue which only mentions DPI_ORACLE_TYPE_NUMBER or not, but nevertheless is seems like we need to utilize dpiData_setBytes also for attr.oratype being OracleType::Number.

We made a local circumvention by migrating from FLOAT to NUMBER in our database, so unfortunately we can't test whether adding a simple if condition for OracleType::Float would work, hence we are not providing a PR, sorry :(

kubo commented 4 years ago

Thanks for your reporting the issue. It isn't a bug in the document of dpiObject_getAttributeValue. It is a bug in rust-oracle. Rust-oracle distinguishes NUMBER and FLOAT. On the other hand ODPI treats both as DPI_ORACLE_TYPE_NUMBER.

I'll release 0.3.2 in a few days.

mexus commented 4 years ago

Sounds great, thanks! ;)

kubo commented 4 years ago

0.3.2 was released.