oracle / odpi

ODPI-C: Oracle Database Programming Interface for Drivers and Applications
https://oracle.github.io/odpi/
Other
265 stars 75 forks source link

Size of the data with dynamic bind #113

Closed camillehuot closed 5 years ago

camillehuot commented 5 years ago

Hi Anthony

Thanks for this very clean wrapper. I have one question about a specific case.

I see that you set the maximum size of the data to INT_MAX here: https://github.com/oracle/odpi/blob/master/src/dpiOci.c#L797

The documentation states: "OCI_DATA_AT_EXEC - When this mode is selected, the value_sz parameter defines the maximum size of the data that can be provided at run time." https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/bind-define-describe-functions.html#GUID-D28DF5A7-3C75-4E52-82F7-A5D6D5714E69

I would expect the client to count and set the maximum size of the data to be sent. I'm very interested to know why do you set INT_MAX? And is it dangerous for the client or server? (memory exhaustion, etc)

Thank you! Camille

anthony-tuininga commented 5 years ago

As you noted, this is only for dynamic binds, which are generally quite large. Setting the value_sz parameter to INT_MAX simply permits that amount of data to be tranferred. It does not allocate any space on either the client or server. If the actual length was used, then you would have to ensure that the bind was performed before every execution -- since the actual length can change for each execution -- so I avoid that necessity by simply setting an arbitrarily large value.

camillehuot commented 5 years ago

Thanks for this insight. It helps a lot.