Modified:
trunk/SDK/C/Library/MYODBCC.cpp
trunk/SDK/MYSQLPlus/Library/MResult.cpp
trunk/SDK/MYSQLPlus/Library/MResult.h
Log:
ENH: Make SQLGetData use the new MYODBCC::getCDefault().
Modified: trunk/SDK/C/Library/MYODBCC.cpp
===================================================================
--- trunk/SDK/C/Library/MYODBCC.cpp 2006-11-05 12:05:55 UTC (rev 653)
+++ trunk/SDK/C/Library/MYODBCC.cpp 2006-11-05 12:21:31 UTC (rev 654)
@@ -2061,9 +2061,25 @@
}
/*!
- \brief Returns the SQL_C_* type for the given SQL type.
+ \brief Gets data based upon the type information in the data source.
- This contains the rules for getting the C type when SQL_C_DEFAULT has been
provided.
+ This is used to support SQLGetData(), SQLBindParameter() (and such) when
the type is SQL_C_DEFAULT. In such a case
+ we must return the data in the default C format specified in the
"Converting Data from SQL to C Data Types"
+ table of the ODBC specification.
+
+ \note MySQL does not, at this time, support all SQL types but this method does
;)
+
+ \param nODBCVersion SQL_ATTR_ODBC_VERSION
+ \param nSQLType SQL type (SQL_INTEGER etc etc)
+ \param nUnsigned SQL_TRUE if we are unsigned else SQL_FALSE.
+
+ \return SQLSMALLINT An SQL_C_* type (C data type).
+
+ \sa getData
+ SQLGetData
+ SQLBindParameter
+ "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"
*/
SQLSMALLINT MYODBCC::getCDefault( SQLINTEGER nODBCVersion, SQLSMALLINT nSQLType,
SQLSMALLINT nUnsigned )
{
Modified: trunk/SDK/MYSQLPlus/Library/MResult.cpp
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResult.cpp 2006-11-05 12:05:55 UTC (rev 653)
+++ trunk/SDK/MYSQLPlus/Library/MResult.cpp 2006-11-05 12:21:31 UTC (rev 654)
@@ -1604,216 +1604,6 @@
MYODBCDbgReturn( SQL_SUCCESS );
}
-/*!
- \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
- we must return the data in the default C format specified in the
"Converting Data from SQL to C Data Types"
- table of the ODBC specification.
-
- This version of getData() is probably only called from a higher-level
getData(). In fact; the
- bulk of the work is done by calling a higher-level getData() with the
default C data type specified.
-
- \note MySQL does not, at this time, support all SQL types but this method does
;)
-
- \param nColumn Column number as per SQLGetData().
- \param pDescriptorRecord The IRD record corresponding to nColumn. We use
this determine the SQL type at the
- data source and then use this to determine the
default C data type we will
- return the data as.
- \param pTargetValue Pointer to a data buffer as per SQLGetData().
- \param nBufferLength Size of buffer at pTargetValue as per
SQLGetData().
- \param pnLength Buffer where we can put the number or bytes
available to return as per StrLenIndPtr for SQLGetData().
- This can be NULL.
- \param pnIndicator Buffer where we can put a value to indicate if
NULL data as per StrLenIndPtr for SQLGetData().
- Must NOT be NULL.
-
- \return SQLRETURN
-
- \sa getData
- SQLGetData
- "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::setGetDataDefault()
-{
- MYODBCDbgEnter();
-
- /*!
- \internal ODBC RULE
-
- We use the translation table from the spec under "Converting Data from SQL to C
Data Types".
-
- \note
-
- We do not rely on SQL_C_* values synching up with SQL_* values.
-
- \sa
-
-
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconverting_data_from_sql_to_c_data_types.asp
- */
- switch ( resultGetData.pImpRowDescRec->getConciseType() )
- {
- case SQL_CHAR:
- case SQL_VARCHAR:
- case SQL_LONGVARCHAR:
- resultGetData.nTargetTypeAdjusted = SQL_C_CHAR;
- break;
-
- case SQL_WCHAR:
- case SQL_WVARCHAR:
- case SQL_WLONGVARCHAR:
- resultGetData.nTargetTypeAdjusted = SQL_C_WCHAR;
- break;
-
- case SQL_DECIMAL:
- case SQL_NUMERIC:
- /*!
- \internal ODBC RULE
-
- This conversion is SQL_C_CHAR, not SQL_C_NUMERIC - as one may otherwise
expect.
- */
- resultGetData.nTargetTypeAdjusted = SQL_C_CHAR;
- break;
-
- case SQL_BIT:
- resultGetData.nTargetTypeAdjusted = SQL_C_BIT;
- break;
-
- case SQL_TINYINT:
- if ( resultGetData.pImpRowDescRec->getUnsigned() == SQL_TRUE )
- resultGetData.nTargetTypeAdjusted = SQL_C_UTINYINT;
- else
- resultGetData.nTargetTypeAdjusted = SQL_C_STINYINT;
- break;
-
- case SQL_SMALLINT:
- if ( resultGetData.pImpRowDescRec->getUnsigned() == SQL_TRUE )
- resultGetData.nTargetTypeAdjusted = SQL_C_USHORT;
- else
- resultGetData.nTargetTypeAdjusted = SQL_C_SSHORT;
- break;
-
- case SQL_INTEGER:
- if ( resultGetData.pImpRowDescRec->getUnsigned() == SQL_TRUE )
- resultGetData.nTargetTypeAdjusted = SQL_C_ULONG;
- else
- resultGetData.nTargetTypeAdjusted = SQL_C_SLONG;
- break;
-
- case SQL_BIGINT:
- if ( resultGetData.pImpRowDescRec->getUnsigned() == SQL_TRUE )
- resultGetData.nTargetTypeAdjusted = SQL_C_UBIGINT;
- else
- resultGetData.nTargetTypeAdjusted = SQL_C_SBIGINT;
- break;
-
- case SQL_REAL:
- resultGetData.nTargetTypeAdjusted = SQL_C_FLOAT;
- break;
-
- case SQL_FLOAT:
- resultGetData.nTargetTypeAdjusted = SQL_C_DOUBLE;
- break;
-
- case SQL_DOUBLE:
- resultGetData.nTargetTypeAdjusted = SQL_C_DOUBLE;
- break;
-
- case SQL_BINARY:
- case SQL_VARBINARY:
- case SQL_LONGVARBINARY:
- resultGetData.nTargetTypeAdjusted = SQL_C_BINARY;
- break;
-
- case SQL_TYPE_DATE:
- if ( getEnvironment()->getODBCVersion() == SQL_OV_ODBC2 )
- resultGetData.nTargetTypeAdjusted = SQL_C_DATE;
- else
- resultGetData.nTargetTypeAdjusted = SQL_C_TYPE_DATE;
- break;
-
- case SQL_TYPE_TIME:
- if ( getEnvironment()->getODBCVersion() == SQL_OV_ODBC2 )
- resultGetData.nTargetTypeAdjusted = SQL_C_TIME;
- else
- resultGetData.nTargetTypeAdjusted = SQL_C_TYPE_TIME;
- break;
-
- case SQL_TYPE_TIMESTAMP:
- if ( getEnvironment()->getODBCVersion() == SQL_OV_ODBC2 )
- resultGetData.nTargetTypeAdjusted = SQL_C_TIMESTAMP;
- else
- resultGetData.nTargetTypeAdjusted = SQL_C_TYPE_TIMESTAMP;
- break;
-
- case SQL_INTERVAL_MONTH:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_MONTH;
- break;
-
- case SQL_INTERVAL_YEAR:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_YEAR;
- break;
-
- case SQL_INTERVAL_YEAR_TO_MONTH:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_YEAR_TO_MONTH;
- break;
-
- case SQL_INTERVAL_DAY:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_DAY;
- break;
-
- case SQL_INTERVAL_HOUR:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_HOUR;
- break;
-
- case SQL_INTERVAL_MINUTE:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_MINUTE;
- break;
-
- case SQL_INTERVAL_SECOND:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_SECOND;
- break;
-
- case SQL_INTERVAL_DAY_TO_HOUR:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_DAY_TO_HOUR;
- break;
-
- case SQL_INTERVAL_DAY_TO_MINUTE:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_DAY_TO_MINUTE;
- break;
-
- case SQL_INTERVAL_DAY_TO_SECOND:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_DAY_TO_SECOND;
- break;
-
- case SQL_INTERVAL_HOUR_TO_MINUTE:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_HOUR_TO_MINUTE;
- break;
-
- case SQL_INTERVAL_HOUR_TO_SECOND:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_HOUR_TO_SECOND;
- break;
-
- case SQL_INTERVAL_MINUTE_TO_SECOND:
- resultGetData.nTargetTypeAdjusted = SQL_C_INTERVAL_MINUTE_TO_SECOND;
- break;
-
- case SQL_GUID:
- /*!
- \internal ODBC RULE
-
- This conversion is SQL_C_CHAR, not SQL_C_GUID - as one may otherwise
expect.
- */
- resultGetData.nTargetTypeAdjusted = SQL_C_CHAR;
- break;
-
- default:
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::STATE_07006 ) );
- }
-
- MYODBCDbgReturn( SQL_SUCCESS );
-}
-
void MResult::setState( STATE nState )
{
MYODBCDbgEnter();
@@ -2101,9 +1891,7 @@
The logic for selecting the C data type is spelled out in the ODBC
specification.
*/
- SQLRETURN nReturn = setGetDataDefault();
- if ( !SQL_SUCCEEDED( nReturn ) )
- MYODBCDbgReturn( nReturn );
+ resultGetData.nTargetTypeAdjusted = MYODBCC::getCDefault(
getEnvironment()->getODBCVersion(), resultGetData.pImpRowDescRec->getConciseType(),
resultGetData.pImpRowDescRec->getUnsigned() );
}
}
Modified: trunk/SDK/MYSQLPlus/Library/MResult.h
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResult.h 2006-11-05 12:05:55 UTC (rev 653)
+++ trunk/SDK/MYSQLPlus/Library/MResult.h 2006-11-05 12:21:31 UTC (rev 654)
@@ -379,7 +379,6 @@
virtual SQLRETURN setAfterEnd();
virtual SQLRETURN setBeforeStart();
virtual SQLRETURN setBuffered( BUFFERED bBuffered = BUFFERED_UNBUFFERED );
- SQLRETURN setGetDataDefault(); // support for getData: this is called when
target C type is SQL_C_DEFAULT (derive type from IRD)
void setResultSetRows( qulonglong nResultSetRows, BOOL
bResultSetRowsKnown = false );
void setRowsAffected( qulonglong nRowsAffected );
void setRowSetRows( SQLUINTEGER nRowSetRows );
| Thread |
|---|
| • Connector/ODBC 5 commit: r654 - in trunk/SDK: C/Library MYSQLPlus/Library | pharvey | 5 Nov |