Modified:
MYSQLPlus/MYSQLPlusLib/MResult.cpp
MYSQLPlus/MYSQLPlusLib/MResult.h
Log:
Modified: MYSQLPlus/MYSQLPlusLib/MResult.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.cpp 2006-05-17 20:20:50 UTC (rev 251)
+++ MYSQLPlus/MYSQLPlusLib/MResult.cpp 2006-05-17 21:32:46 UTC (rev 252)
@@ -37,12 +37,17 @@
nTargetType = SQL_C_DEFAULT;
pTarget = NULL;
nBytesOrCharsMax = 0;
+ pnBytesOrCharsRemaining = NULL;
+ pnIndicator = NULL;
+
+ nTargetTypeAdjusted = SQL_C_CHAR;
nBytesOrCharsRemaining = 0;
nIndicator = SQL_NO_TOTAL;
variantData.clear();
pDescriptorRecordIRD = NULL;
pDescriptorRecordARD = NULL;
+
MYODBCDbgReturn2();
}
@@ -149,123 +154,107 @@
if ( nColumnNumber > getImpRowDesc()->getCount() )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_07009 ) );
-
/* are we being called a second (or more) time on same column to get large data? */
if ( resultGetData.isChunkingRequest( nColumnNumber, nTargetType,
resultGetData.pDescriptorRecordIRD->getConciseType() ) )
{
- }
+ /*!
+ \internal
+ \note
- if ( nTargetType == SQL_ARD_TYPE )
- {
+ We assume that none of the cached items in resultGetData has changed by other
means!!
+ */
}
else
{
- }
+ resultGetData.nBytesOrCharsMax = nBufferLength;
+ resultGetData.nColumn = nColumnNumber;
+ resultGetData.nTargetType = nTargetType;
+ resultGetData.nTargetTypeAdjusted = nTargetType;
+ resultGetData.pDescriptorRecordIRD = getImpRowDesc()->getRecord(
nColumnNumber );
+ resultGetData.pnBytesOrCharsRemaining = pnLength;
+ resultGetData.pnIndicator = pnIndicator;
- MResultDataTarget dataTarget;
- dataTarget.nBytesOrCharsMax = nBufferLength;
- dataTarget.nColumn = nColumnNumber;
- dataTarget.nTargetType = nTargetType;
- dataTarget.pnBytesOrCharsRemaining = pnLength;
- dataTarget.pnIndicator = pnIndicator;
- dataTarget.pTarget = pTargetValue;
-
- /* get our col data from current row (as variant) */
- SQLRETURN nReturn = getData( nColumnNumber, dataTarget.variantData );
- if ( !SQL_SUCCEEDED(nReturn) )
- MYODBCDbgReturn( nReturn );
+ /* get our col data from current row (as variant) */
+ SQLRETURN nReturn = getData( nColumnNumber, resultGetData.variantData );
+ if ( !SQL_SUCCEEDED(nReturn) )
+ MYODBCDbgReturn( nReturn );
- /* get indicator value; no need to process further if we are null */
- if ( dataTarget.variantData.isNull() )
- {
- if ( dataTarget.pnIndicator )
+ /* get indicator value; no need to process further if we are null */
+ if ( resultGetData.variantData.isNull() )
{
- *dataTarget.pnIndicator = SQL_NULL_DATA;
- MYODBCDbgReturn( SQL_SUCCESS );
+ resultGetData.nIndicator = SQL_NULL_DATA;
+ if ( resultGetData.pnIndicator )
+ {
+ *resultGetData.pnIndicator = resultGetData.nIndicator;
+ MYODBCDbgReturn( SQL_SUCCESS );
+ }
+ else
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_22002 )
);
}
- else
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_22002 ) );
- }
- if ( dataTarget.pnIndicator ) *dataTarget.pnIndicator = 0;
+ resultGetData.nIndicator = 0;
+ if ( resultGetData.pnIndicator ) *resultGetData.pnIndicator =
resultGetData.nIndicator;
- /* get data and data length, convert data as needed */
- switch ( nTargetType )
- {
- /*!
- \internal ODBC RULE
+ if ( nTargetType == SQL_ARD_TYPE )
+ {
+ /*!
+ \internal ODBC RULE
- If TargetType is SQL_ARD_TYPE, the driver uses the type identifier specified
in the
- SQL_DESC_CONCISE_TYPE field of the ARD.
- */
- case SQL_ARD_TYPE:
- {
- /*!
- \internal ODBC RULE
+ The TargetType argument was SQL_ARD_TYPE, and the value in the
SQL_DESC_COUNT
+ field of the ARD was less than the ColumnNumber argument.
+ */
+ if ( nColumnNumber > getAppRowDesc()->getCount() )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_07009 )
);
- The TargetType argument was SQL_ARD_TYPE, and the value in the
SQL_DESC_COUNT
- field of the ARD was less than the ColumnNumber argument.
- */
- if ( nColumnNumber > getAppRowDesc()->getCount() )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_07009
) );
+ /*!
+ \internal ODBC RULE
- /*!
- \internal ODBC RULE
+ If TargetType is SQL_ARD_TYPE, the driver uses the type identifier
specified in the
+ SQL_DESC_CONCISE_TYPE field of the ARD.
- Examples in the spec. shows SQL_ARD_TYPE being used during
- a SQLGetData() to tell the driver to use not just the concise type
but also the
- precision and scale. Specifying the precision and scale in this way
adjusts the
- behaviour of SQLGetData when SQL_C_NUMERIC (SQL_NUMERIC_STRUCT) is
the target type
- as the app can not use the numeric struct fields to do this ("they
are output only").
+ The precision and scale fields of the SQL_C_NUMERIC data type are never
used for input from
+ an application, only for output from the driver to the application. When
the driver writes a
+ numeric value into the SQL_NUMERIC_STRUCT, it will use its own
driver-specific default as the
+ value for the precision field, and it will use the value in the
SQL_DESC_SCALE field of the
+ application descriptor (which defaults to 0) for the scale field. An
application can provide
+ its own values for precision and scale by setting the SQL_DESC_PRECISION
and SQL_DESC_SCALE
+ fields of the application descriptor.
- \note
+ If any default precision or scale is not appropriate, the application
should explicitly
+ set the appropriate descriptor field by a call to SQLSetDescField or
SQLSetDescRec. It
+ can set the SQL_DESC_CONCISE_TYPE field to SQL_C_NUMERIC and call
SQLGetData with a
+ TargetType argument of SQL_ARD_TYPE, which will cause the precision and
scale values in
+ the descriptor fields to be used.
+ */
+ resultGetData.pDescriptorRecordARD = getAppRowDesc()->getRecord(
nColumnNumber );
+ resultGetData.nTargetTypeAdjusted =
resultGetData.pDescriptorRecordARD->getConciseType();
+ }
+ else if ( nTargetType == SQL_C_DEFAULT )
+ {
+ /*!
+ \internal ODBC RULE
+
+ If it is SQL_C_DEFAULT, the driver selects the default C data type based
on the SQL
+ data type of the source.
+
+ \note
+
+ The logic for selecting the C data type is spelled out in the ODBC
specification.
+ */
+ SQLRETURN nReturn = setGetDataDefault();
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( nReturn );
+ }
+ }
- IMHO this is like climbing out of the window having painted self into
a corner.
+ /* get data and data length, convert data as needed */
+ switch ( resultGetData.nTargetTypeAdjusted )
+ {
+ case SQL_ARD_TYPE:
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Should not have reached SQL_ARD_TYPE") ) );
- \sa
-
- http://support.microsoft.com/default.aspx?scid=kb;en-us;222831
- */
- MDescriptorRecord *pDescriptorRecordARD = getAppRowDesc()->getRecord(
nColumnNumber );
-
- if ( pDescriptorRecordARD->getConciseType() == SQL_C_NUMERIC )
- {
- /*!
- \internal ODBC RULE
-
- The precision and scale fields of the SQL_C_NUMERIC data type are
never used for input from
- an application, only for output from the driver to the
application. When the driver writes a
- numeric value into the SQL_NUMERIC_STRUCT, it will use its own
driver-specific default as the
- value for the precision field, and it will use the value in the
SQL_DESC_SCALE field of the
- application descriptor (which defaults to 0) for the scale field.
An application can provide
- its own values for precision and scale by setting the
SQL_DESC_PRECISION and SQL_DESC_SCALE
- fields of the application descriptor.
- */
- SQL_NUMERIC_STRUCT *pNumeric = (SQL_NUMERIC_STRUCT *)pTargetValue;
-
- pNumeric->precision = pDescriptorRecordARD->getPrecision();
- pNumeric->scale = pDescriptorRecordARD->getScale();
-
- MYODBCDbgReturn( getData( variantData, pNumeric, pnLength ) );
- }
-
- /* try again - call ourself with the type */
- MYODBCDbgReturn( getDataARDType( nColumnNumber,
pDescriptorRecordARD->getConciseType(), pTargetValue, nBufferLength, pnLength,
pnIndicator ) );
- }
- break;
-
- /*!
- \internal ODBC RULE
-
- If it is SQL_C_DEFAULT, the driver selects the default C data type based on
the SQL
- data type of the source.
-
- \note
-
- The logic for selecting the C data type is spelled out in the ODBC
specification.
- */
case SQL_C_DEFAULT:
- MYODBCDbgReturn( getDataDefault( nColumnNumber,
(MDescriptorRecordIRD*)getImpRowDesc()->getRecord( nColumnNumber ), pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Should not have reached SQL_C_DEFAULT") ) );
case SQL_CHAR:
case SQL_VARCHAR:
@@ -273,7 +262,7 @@
case SQL_WCHAR:
case SQL_WVARCHAR:
case SQL_WLONGVARCHAR:
- MYODBCDbgReturn( fromCharacterSQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromCharacterSQL();
case SQL_DECIMAL:
case SQL_NUMERIC:
@@ -284,32 +273,32 @@
case SQL_REAL:
case SQL_FLOAT:
case SQL_DOUBLE:
- MYODBCDbgReturn( fromNumericSQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromNumericSQL();
case SQL_BIT:
- MYODBCDbgReturn( fromBitSQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromBitSQL();
case SQL_BINARY:
case SQL_VARBINARY:
case SQL_LONGVARBINARY:
- MYODBCDbgReturn( fromBinarySQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromBinarySQL();
case SQL_TYPE_DATE:
- MYODBCDbgReturn( fromDateSQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromDateSQL();
case SQL_GUID:
- MYODBCDbgReturn( fromGuidSQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromGuidSQL();
case SQL_TYPE_TIME:
- MYODBCDbgReturn( fromTimeSQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromTimeSQL();
case SQL_TYPE_TIMESTAMP:
- MYODBCDbgReturn( fromTimeStampSQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromTimeStampSQL();
case SQL_INTERVAL_YEAR:
case SQL_INTERVAL_MONTH:
case SQL_INTERVAL_YEAR_TO_MONTH:
- MYODBCDbgReturn( fromIntervalYearMonthSQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromIntervalYearMonthSQL();
case SQL_INTERVAL_DAY:
case SQL_INTERVAL_HOUR:
@@ -321,33 +310,8 @@
case SQL_INTERVAL_HOUR_TO_MINUTE:
case SQL_INTERVAL_HOUR_TO_SECOND:
case SQL_INTERVAL_MINUTE_TO_SECOND:
- MYODBCDbgReturn( fromIntervalDayTimeSQL(
(MDescrptorRecordIRD*)(getImpRowDesc()->getRecord( nColumnNumber )), &dataTarget )
);
+ MYODBCDbgReturn( fromIntervalDayTimeSQL();
-++++++++++++
- case SQL_C_NUMERIC:
- {
- /*!
- \internal ODBC RULE
-
- The precision and scale fields of the SQL_C_NUMERIC data type are
never used for input from
- an application, only for output from the driver to the application.
When the driver writes a
- numeric value into the SQL_NUMERIC_STRUCT, it will use its own
driver-specific default as the
- value for the precision field, and it will use the value in the
SQL_DESC_SCALE field of the
- application descriptor (which defaults to 0) for the scale field. An
application can provide
- its own values for precision and scale by setting the
SQL_DESC_PRECISION and SQL_DESC_SCALE
- fields of the application descriptor.
-
- \sa SQL_ARD_TYPE
- */
- SQL_NUMERIC_STRUCT *pNumeric = (SQL_NUMERIC_STRUCT *)pTargetValue;
-
- pNumeric->precision = 10; /* default precision */
- pNumeric->scale = 0; /* default scale */
-
- MYODBCDbgReturn( getData( getImpRowDesc()->getConciseType(),
variantData, pNumeric, pnLength ) );
- }
- break;
-
default:
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY003 ) );
}
@@ -445,38 +409,6 @@
}
/*!
- \brief Gets data based upon a descriptor for a bound column.
-
- This is used to support bound columns functionality. Calling this will
get
- nColumn's data from the current row and put a copy in the buffer
described
- by the descriptor.
-
- This version of getData() is probably only called from within a MResult
once
- the cursor arrives upon a viable row (changes to a viable row).
-
- \param nColumn The column we are dealing with.
- \param pDescriptorRecord This is a bound ARD.
-
- \return SQLRETURN
-
- \sa getData
-*/
-SQLRETURN MResult::getDataARDType( SQLUSMALLINT nColumn, MDescriptorRecordARD
*pDescriptorRecord )
-{
- MYODBCDbgEnter();
-
- Q_ASSERT( !pDescriptorRecord );
-
- MYODBCDbgReturn( getData( nColumn,
- pDescriptorRecord->getConciseType(),
- pDescriptorRecord->getDataPtr(),
- pDescriptorRecord->getOctetLength(),
- pDescriptorRecord->getOctetLengthPtr(),
- pDescriptorRecord->getIndicatorPtr(),
- pDescriptorRecord ) );
-}
-
-/*!
\brief Gets data based upon the type information in the data source.
This is used to support SQLGetData() (and such) when the type is
SQL_C_DEFAULT. In such a case
@@ -506,7 +438,7 @@
"Converting Data from SQL to C Data Types"
"http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconverting_data_from_sql_to_c_data_types.asp"
*/
-SQLRETURN MResult::getDataDefault( SQLUSMALLINT nColumn, MDescriptorRecordIRD
*pDescriptorRecordIRD, SQLPOINTER pTargetValue, SQLINTEGER nBufferLength, SQLINTEGER
*pnLength, SQLINTEGER *pnIndicator )
+SQLRETURN MResult::setGetDataDefault()
{
MYODBCDbgEnter();
@@ -523,17 +455,19 @@
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconverting_data_from_sql_to_c_data_types.asp
*/
- switch ( pDescriptorRecord->getConciseType() )
+ switch ( resultGetData.pDescriptorRecordIRD->getConciseType() )
{
case SQL_CHAR:
case SQL_VARCHAR:
case SQL_LONGVARCHAR:
- MYODBCDbgReturn( getData( nColumn, SQL_C_CHAR, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_CHAR;
+ break;
case SQL_WCHAR:
case SQL_WVARCHAR:
case SQL_WLONGVARCHAR:
- MYODBCDbgReturn( getData( nColumn, SQL_C_WCHAR, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_WCHAR;
+ break;
case SQL_DECIMAL:
case SQL_NUMERIC:
@@ -542,92 +476,122 @@
This conversion is SQL_C_CHAR, not SQL_C_NUMERIC - as one may otherwise
expect.
*/
- MYODBCDbgReturn( getData( nColumn, SQL_C_CHAR, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_CHAR;
+ break;
case SQL_BIT:
- MYODBCDbgReturn( getData( nColumn, SQL_C_BIT, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_BIT;
+ break;
case SQL_TINYINT:
if ( pDescriptorRecord->getUnsigned() == SQL_TRUE )
- MYODBCDbgReturn( getData( nColumn, SQL_C_STINYINT, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
- MYODBCDbgReturn( getData( nColumn, SQL_C_UTINYINT, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_STINYINT;
+ else
+ resultGetData.nTargetTypeAdjusted = SQL_C_UTINYINT;
+ break;
case SQL_SMALLINT:
if ( pDescriptorRecord->getUnsigned() == SQL_TRUE )
- MYODBCDbgReturn( getData( nColumn, SQL_C_SSHORT, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
- MYODBCDbgReturn( getData( nColumn, SQL_C_USHORT, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_SSHORT;
+ else
+ resultGetData.nTargetTypeAdjusted = SQL_C_USHORT;
+ break;
case SQL_INTEGER:
if ( pDescriptorRecord->getUnsigned() == SQL_TRUE )
- MYODBCDbgReturn( getData( nColumn, SQL_C_SLONG, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
- MYODBCDbgReturn( getData( nColumn, SQL_C_ULONG, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_SLONG;
+ else
+ resultGetData.nTargetTypeAdjusted = SQL_C_ULONG;
+ break;
case SQL_BIGINT:
if ( pDescriptorRecord->getUnsigned() == SQL_TRUE )
- MYODBCDbgReturn( getData( nColumn, SQL_C_SBIGINT, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
- MYODBCDbgReturn( getData( nColumn, SQL_C_UBIGINT, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_SBIGINT;
+ else
+ resultGetData.nTargetTypeAdjusted = SQL_C_UBIGINT;
+ break;
case SQL_REAL:
- MYODBCDbgReturn( getData( nColumn, SQL_C_FLOAT, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_FLOAT;
+ break;
case SQL_FLOAT:
- MYODBCDbgReturn( getData( nColumn, SQL_C_DOUBLE, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_DOUBLE;
+ break;
case SQL_DOUBLE:
- MYODBCDbgReturn( getData( nColumn, SQL_C_DOUBLE, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_DOUBLE;
+ break;
case SQL_BINARY:
case SQL_VARBINARY:
case SQL_LONGVARBINARY:
- MYODBCDbgReturn( getData( nColumn, SQL_C_BINARY, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_BINARY;
+ break;
case SQL_TYPE_DATE:
- MYODBCDbgReturn( getData( nColumn, SQL_C_TYPE_DATE, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_TYPE_DATE;
+ break;
case SQL_TYPE_TIME:
- MYODBCDbgReturn( getData( nColumn, SQL_C_TYPE_TIME, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_TYPE_TIME;
+ break;
case SQL_TYPE_TIMESTAMP:
- MYODBCDbgReturn( getData( nColumn, SQL_C_TYPE_TIMESTAMP, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_TYPE_TIMESTAMP;
+ break;
case SQL_INTERVAL_MONTH:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_MONTH, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_MONTH;
+ break;
case SQL_INTERVAL_YEAR:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_YEAR, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_YEAR;
+ break;
case SQL_INTERVAL_YEAR_TO_MONTH:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_YEAR_TO_MONTH,
pTargetValue, nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_YEAR_TO_MONTH;
+ break;
case SQL_INTERVAL_DAY:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_DAY, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_DAY;
+ break;
case SQL_INTERVAL_HOUR:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_HOUR, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_HOUR;
+ break;
case SQL_INTERVAL_MINUTE:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_MINUTE, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_MINUTE;
+ break;
case SQL_INTERVAL_SECOND:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_SECOND, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_SECOND;
+ break;
case SQL_INTERVAL_DAY_TO_HOUR:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_DAY_TO_HOUR, pTargetValue,
nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_DAY_TO_HOUR;
+ break;
case SQL_INTERVAL_DAY_TO_MINUTE:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_DAY_TO_MINUTE,
pTargetValue, nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_DAY_TO_MINUTE;
+ break;
case SQL_INTERVAL_DAY_TO_SECOND:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_DAY_TO_SECOND,
pTargetValue, nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_DAY_TO_SECOND;
+ break;
case SQL_INTERVAL_HOUR_TO_MINUTE:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_HOUR_TO_MINUTE,
pTargetValue, nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_HOUR_TO_MINUTE;
+ break;
case SQL_INTERVAL_HOUR_TO_SECOND:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_HOUR_TO_SECOND,
pTargetValue, nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_HOUR_TO_SECOND;
+ break;
case SQL_INTERVAL_MINUTE_TO_SECOND:
- MYODBCDbgReturn( getData( nColumn, SQL_C_INTERVAL_MINUTE_TO_SECOND,
pTargetValue, nBufferLength, pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_MINUTE_TO_SECOND;
+ break;
case SQL_GUID:
/*!
@@ -635,7 +599,8 @@
This conversion is SQL_C_CHAR, not SQL_C_GUID - as one may otherwise
expect.
*/
- MYODBCDbgReturn( getData( nColumn, SQL_C_CHAR, pTargetValue, nBufferLength,
pnLength, pnIndicator ) );
+ resultGetData.nTargetTypeAdjusted = SQL_C_CHAR;
+ break;
default:
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_07006 ) );
@@ -1293,9 +1258,30 @@
{
MYODBCDbgEnter();
+
/*!
\internal ODBC RULE
+ The precision and scale fields of the SQL_C_NUMERIC data type are never used for
input from
+ an application, only for output from the driver to the application. When the
driver writes a
+ numeric value into the SQL_NUMERIC_STRUCT, it will use its own driver-specific
default as the
+ value for the precision field, and it will use the value in the SQL_DESC_SCALE
field of the
+ application descriptor (which defaults to 0) for the scale field. An application
can provide
+ its own values for precision and scale by setting the SQL_DESC_PRECISION and
SQL_DESC_SCALE
+ fields of the application descriptor.
+
+ \sa SQL_ARD_TYPE
+ */
+ SQL_NUMERIC_STRUCT *pNumeric = (SQL_NUMERIC_STRUCT *)pTargetValue;
+
+ pNumeric->precision = 10; /* default precision */
+ pNumeric->scale = 0; /* default scale */
+
+ MYODBCDbgReturn( getData( getImpRowDesc()->getConciseType(), variantData,
pNumeric, pnLength ) );
++++++++++++++++
+ /*!
+ \internal ODBC RULE
+
A number is stored in the val field of the SQL_NUMERIC_STRUCT structure as a
scaled integer,
in little endian mode (the leftmost byte being the least-significant byte). For
example, the
number 10.001 base 10, with a scale of 4, is scaled to an integer of 100010.
Because this is
Modified: MYSQLPlus/MYSQLPlusLib/MResult.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.h 2006-05-17 20:20:50 UTC (rev 251)
+++ MYSQLPlus/MYSQLPlusLib/MResult.h 2006-05-17 21:32:46 UTC (rev 252)
@@ -31,17 +31,21 @@
BOOLEAN isChunkingRequest( SQLUSMALLINT nColumnNumber, SQLSMALLINT nTargetType,
SQLSMALLINT nType );
+ /* these are from last (or possibly current) getData call and reflect the calls args
*/
SQLUSMALLINT nColumn; /*!< column number as per
SQLGetData */
SQLSMALLINT nTargetType; /*!< C data type desired for
value in pTarget */
SQLPOINTER pTarget; /*!< buffer to return cell
data */
SQLINTEGER nBytesOrCharsMax; /*!< size of pTarget buffer as
per SQLGetData */
- SQLINTEGER nBytesOrCharsRemaining; /*!< bytes or chars remaining
in cell at end of last getData - we get
- more IF nColumn is requested
again AND nBytesOrCharsRemaining > 0
- AND nBytesOrCharsRemaining
< data length */
- SQLINTEGER nIndicator; /*!< value indicates whether
or not the cell is NULL as per SQLGetData */
+ SQLINTEGER * pnBytesOrCharsRemaining; /*!< bytes or chars remaining
in cell (possibly at end of last getData) */
+ SQLINTEGER * pnIndicator; /*!< value indicates whether
or not the cell is NULL as per SQLGetData */
+
+ /* these are additional fields which assist in maintaining our getData state */
+ SQLSMALLINT nTargetTypeAdjusted; /*!< is nTargetType,
SQL_C_DEFAULT derived, or ARD derived */
+ SQLINTEGER nBytesOrCharsRemaining; /*!< cached ver of value at
pnBytesOrCharsRemaining */
+ SQLINTEGER nIndicator; /*!< cached ver of value at
pnIndicator */
QVariant variantData; /*!< resultset cell data
*/
MDescriptorRecordIRD * pDescriptorRecordIRD; /*!< descriptor describing the
resultset column */
- MDescriptorRecordARD * pDescriptorRecordARD; /*!< this is set if
SQL_ARD_TYPE was used - otherwise this is null */
+ MDescriptorRecordARD * pDescriptorRecordARD; /*!< set if nTargetType ==
SQL_ARD_TYPE - otherwise this is null */
};
/*!
@@ -120,9 +124,6 @@
MDescriptor * getImpParamDesc();
MDescriptor * getImpRowDesc();
- /* support for getData: this is called when target C type is SQL_ARD_TYPE (derive
type from ARD) */
- SQLRETURN getDataARDType( SQLUSMALLINT nColumn, MDescriptorRecordARD
*pDescriptorRecord );
-
/* support for getData: this is called when target C type is SQL_C_DEFAULT (derive
type from IRD) */
SQLRETURN getDataDefault( SQLUSMALLINT nColumn, MDescriptorRecordIRD
*pDescriptorRecordIRD, SQLPOINTER pTargetValue, SQLINTEGER nBufferLength, SQLINTEGER
*pnLength, SQLINTEGER *pnIndicator );
| Thread |
|---|
| • Connector/ODBC 5 commit: r252 - MYSQLPlus/MYSQLPlusLib | pharvey | 17 May |