You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Binding an input parameter of C type "double" to an SQL INSERT statement that writes it to a NUMERIC column in the database completely unexpectedly changes the value of the input parameter.
This happens because OdbcConvert::convDoubleToLong(), which is called from OdbcStatement::inputParam() in turn called by executeStatement() and sqlExecute(), uses a non-const reference to the from value that it then proceeds to modify. The following trivial patch fixes the problem:
diff --git a/cygdrive/d/src/3rdparty/ODBCFb-2.0.1.152/OdbcConvert.cpp b/cygdrive/d/src/3rdparty/ODBCFb-2.0.1.152.my/OdbcConvert.cpp
index e92754e..3975dbf 100755
--- a/cygdrive/d/src/3rdparty/ODBCFb-2.0.1.152/OdbcConvert.cpp
+++ b/cygdrive/d/src/3rdparty/ODBCFb-2.0.1.152.my/OdbcConvert.cpp
@@ -1217,7 +1217,7 @@ int OdbcConvert::conv##TYPE_FROM##To##TYPE_TO(DescRecord * from, DescRecord * to
IOW simple make a copy of the input value instead of modifying it in place.
I hope this can be applied soon because this is really unexpected and none of the other ODBC drivers I tested (PostgreSQL, MS SQL Server, Oracle) behaves in this way.
Submitted by: Vadim Zeitlin (vz)
Binding an input parameter of C type "double" to an SQL INSERT statement that writes it to a NUMERIC column in the database completely unexpectedly changes the value of the input parameter.
This happens because OdbcConvert::convDoubleToLong(), which is called from OdbcStatement::inputParam() in turn called by executeStatement() and sqlExecute(), uses a non-const reference to the from value that it then proceeds to modify. The following trivial patch fixes the problem:
diff --git a/cygdrive/d/src/3rdparty/ODBCFb-2.0.1.152/OdbcConvert.cpp b/cygdrive/d/src/3rdparty/ODBCFb-2.0.1.152.my/OdbcConvert.cpp
index e92754e..3975dbf 100755
--- a/cygdrive/d/src/3rdparty/ODBCFb-2.0.1.152/OdbcConvert.cpp
+++ b/cygdrive/d/src/3rdparty/ODBCFb-2.0.1.152.my/OdbcConvert.cpp
@@ -1217,7 +1217,7 @@ int OdbcConvert::conv##TYPE_FROM##To##TYPE_TO(DescRecord * from, DescRecord * to
- C_TYPE_FROM &valFrom = *(C_TYPE_FROM*)getAdressBindDataFrom((char*)from->dataPtr); \
+ C_TYPE_FROM valFrom = *(C_TYPE_FROM*)getAdressBindDataFrom((char*)from->dataPtr); \
if ( to->scale )
\
valFrom *= (C_TYPE_FROM)(QUAD)listScale[to->scale]; \
if ( valFrom < 0 )valFrom -= 0.5;
\
IOW simple make a copy of the input value instead of modifying it in place.
I hope this can be applied soon because this is really unexpected and none of the other ODBC drivers I tested (PostgreSQL, MS SQL Server, Oracle) behaves in this way.
Thanks!
Commits: d5cd549 6d7c3bf
The text was updated successfully, but these errors were encountered: