Issue Details (XML | Word | Printable)

Key: ODBC-145
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Alexander Potapchenko
Reporter: Jojakim Stahl
Votes: 0
Watchers: 1

If you were logged in you would be able to see more operations.
ODBC Driver

SQLPutData does not advance param counter when SQL_NULL_DATA is passed - SQLParamData always returns SQL_NEED_DATA

Created: 31/May/12 01:36 PM   Updated: 01/Jan/15 03:31 PM
Component/s: None
Affects Version/s: 2.0.1
Fix Version/s: 2.0.2

Environment: Windows 7 with Firebird 2.5 x64

 Description  « Hide
With Parameters declared as SQL_DATA_AT_EXEC the following bug appears:

After passing SQL_NULL_DATA as length parameter to SQLPutData, the parameter pointer is not advanced and the next call to SQLParamData returns SQL_NEED_DATA for the same parameter.

This is for all parameter types - blob AND not blob.
See #ODBC-134 - seems to be related.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jojakim Stahl added a comment - 31/May/12 02:05 PM
The problem was, that binding->startedTransfer flag was not set, when SQLPutData has been called with SQL_NEED_DATA.
I changed it now this way, that also for SQL_NULL_DATA the standard field setter routine is sqlPutData is used. This sets SQL_NULL_DATA for the appDescriptor and the impDescriptor.
I removed the setNull function from DescRecord class becaus it was used only in sqlPutData and seems to be dangerous. It sets a *(short*) value. When my research is right, this is only correct if the DescRecord is used for the implementationParamDescriptor. The applicationParamDescriptor should set *indicatorPtr without cast, because ODBC uses SQLLEN. Should one call setNull for the application side, the value will not be correct (high-word not modified).
I think, that this fix also solves the ticket #ODBC-134 but I could not test this in the short time frame I had.

--- e:\ 2010-10-24 12:27:15.000000000 +0200
+++ ./DescRecord.h 2012-05-24 12:05:55.296222200 +0200
@@ -47,12 +47,6 @@
     void putBlobSegmentData (int length, const void *bytes);
     void endBlobDataTransfer();
- void setNull()
- {
- if ( indicatorPtr )
- *(short*)indicatorPtr = -1;
- }
  int getBufferLength()
  return ( octetLength + 1 ) * headSqlVarPtr->getSqlMultiple();
--- e:\ 2012-03-01 11:33:55.000000000 +0100
+++ ./OdbcStatement.cpp 2012-05-24 14:14:04.793788400 +0200
@@ -3108,12 +3106,7 @@
  DescRecord *binding = applicationParamDescriptor->getDescRecord (parameterNeedData);
- if (valueSize == SQL_NULL_DATA)
- {
- binding->setNull();
- *binding->indicatorPtr = SQL_NULL_DATA;
- }
- else if ( binding->isBlobOrArray )
+ if ( valueSize != SQL_NULL_DATA && binding->isBlobOrArray )
  if ( !binding->startedTransfer )

Alexander Potapchenko added a comment - 04/Aug/12 09:48 AM
fixed in CVS