-
Notifications
You must be signed in to change notification settings - Fork 80
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
Expose OCINumber (dpiNumber) #100
Comments
I will take a look later when I have a bit more time available. |
If it would make things easier, I can isolate the arithmetic issue in a separate commit, since this is the only non-working portion of this development. |
I'm a C noob, but can you use a pointer to some value-received structs? Why not *dpiNumber all the way up? |
Yes, that was my first attempt btw. I'll just revert to that and separate the commits. To answer your question, I did this because I can't make this function call to work, so I tried an alternative. This is the non-working part of the commit. |
So, for the sake of simplicity, I removed all non-working parts of the commit at https://github.com/felipenoris/odpi/tree/fn/numeric, which are related to dpiNumber arithmetic. With this, the patch will only expose a I also updated the first post of this issue. |
@anthony-tuininga , please let me know if you need anything else on this. |
@felipenoris, I don't think I need anything else. Thanks. I'm not sure when this will be implemented. As you're likely aware there are other priorities! |
@anthony-tuininga this would be helpful as for me as I am trying to work with a database explorer which uses erlang/odpi as the driver in erlang. Precision is lost on the way out and I am trying to understand if this is a limitation of Do you have an example reading numeric values similar to |
@acautin, you can tell ODPI-C to fetch the data as a string representation of the OCI number instead of a double precision floating point number (the default). You can see this happening in the sample. If you create variables instead (by calling dpiConn_newVar()), then make sure the |
Hi @anthony-tuininga ! Long time! |
Yes, it has been a while! The commit you reference seems to be simply exposing the 22 bytes of data -- which are in a format that is not easily consumed. How do you intend to consume and generate those 22 bytes of data? |
@anthony-tuininga thanks for the reply! The idea is to let driver developers to access the raw 22 bytes of OraNumber, instead of having to rely on the string representation to get the exact fixed decimal representation. Obviously the driver developer has to parse these 22 bytes. I'm already doing this in Oracle.jl. These bytes are loaded into this 22-bytes struct: struct OraNumber <: Real
len::UInt8
ex::UInt8
mantissa::NTuple{MAX_SIZEOF_MANTISSA, UInt8}
end From that, I can either implement an API around this struct, or translate to other fixed decimal format. Hopefully, using these 22-bytes directly is faster than converting from a string representation. |
One possibility that might make sense: instead of targeting OCINumber directly, I could add a new "native type" called |
@anthony-tuininga, yes, I think that works, as long as it returns a copy of the data and not a volatile reference in memory. The |
I'm not sure what you mean by "volatile reference in memory". The 22 bytes will be stored in the variable buffers and dpiDataBuffer.asOci will be a pointer to that buffer. I believe that's what you meant but can you confirm? |
@anthony-tuininga , yes I think that works. I'm sure you understand the internals of OCI better than I do. I had to rely on If I select the native type |
Yes, you would look at the Oracle Type to determine what actual value you are examining. |
@anthony-tuininga that would be awesome! |
Hi, Go's database/sql seems to get support for decimal handling: golang/go#30870 (comment) Which means I'm interested in getting/setting OCINumbers directly. |
Neat! |
See commit in branch https://github.com/felipenoris/odpi/tree/fn/numeric.
The following changes allow odpi users to bind and read
dpiNumber
from a variablenative type
DPI_NATIVE_TYPE_NUMBER
dpiNumber
struct with 22 bytesasNumber
variant fordpiDataBuffer
. It does not increasesizeof(dpiDataBuffer)
.dpiData_getNumber
anddpiData_setNumber
dpiDataBuffer__fromOracleNumberAsNumber
dpiDataBuffer__toOracleNumberFromNumber
dpiOci__numberAssign
wrapsOCINumberAssign
dpiVar
now reads and writes data of native typeDPI_NATIVE_TYPE_NUMBER
.Ref #4 .
The text was updated successfully, but these errors were encountered: