Prevent use of NaN with Oracle numbers since it produces corrupt data
(https://github.com/oracle/python-cx_Oracle/issues/91).
This commit is contained in:
parent
9311ab9c4e
commit
c5fab177f9
@ -248,6 +248,12 @@ static int PythonFloatToOracleNumber(
|
|||||||
sword status;
|
sword status;
|
||||||
|
|
||||||
doubleValue = PyFloat_AS_DOUBLE(pythonValue);
|
doubleValue = PyFloat_AS_DOUBLE(pythonValue);
|
||||||
|
if (isnan(doubleValue)) {
|
||||||
|
PyErr_SetString(g_DatabaseErrorException,
|
||||||
|
"value is not a number (NaN) and cannot be used in Oracle "
|
||||||
|
"numbers");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
status = OCINumberFromReal(environment->errorHandle, &doubleValue,
|
status = OCINumberFromReal(environment->errorHandle, &doubleValue,
|
||||||
sizeof(double), oracleValue);
|
sizeof(double), oracleValue);
|
||||||
return Environment_CheckForError(environment, status,
|
return Environment_CheckForError(environment, status,
|
||||||
|
|||||||
@ -18,10 +18,18 @@
|
|||||||
#include <datetime.h>
|
#include <datetime.h>
|
||||||
#include <structmember.h>
|
#include <structmember.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <math.h>
|
||||||
#include <oci.h>
|
#include <oci.h>
|
||||||
#include <orid.h>
|
#include <orid.h>
|
||||||
#include <xa.h>
|
#include <xa.h>
|
||||||
|
|
||||||
|
// define isnan for older versions of Visual Studio which only define _isnan
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifndef isnan
|
||||||
|
#define isnan _isnan
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// validate OCI library
|
// validate OCI library
|
||||||
#if !defined(OCI_MAJOR_VERSION) || (OCI_MAJOR_VERSION < 11) || \
|
#if !defined(OCI_MAJOR_VERSION) || (OCI_MAJOR_VERSION < 11) || \
|
||||||
((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION < 2))
|
((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION < 2))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user