List:Commits« Previous MessageNext Message »
From:pharvey Date:May 9 2006 4:59am
Subject:Connector/ODBC 5 commit: r209 - MYSQLPlus/MYSQLPlusLib
View as plain text  
Modified:
   MYSQLPlus/MYSQLPlusLib/MDescriptorRecordIPD.cpp
   MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:


Modified: MYSQLPlus/MYSQLPlusLib/MDescriptorRecordIPD.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MDescriptorRecordIPD.cpp	2006-05-08 22:40:45 UTC (rev 208)
+++ MYSQLPlus/MYSQLPlusLib/MDescriptorRecordIPD.cpp	2006-05-09 04:59:53 UTC (rev 209)
@@ -78,7 +78,7 @@
                 
                 IPD: R/W                  
             */
-            MYODBCDbgReturn( setConciseTypeC( (SQLSMALLINT)pValuePtr ) );
+            MYODBCDbgReturn( setConciseTypeSQL( (SQLSMALLINT)pValuePtr ) );
 
         case SQL_DESC_DATA_PTR:
             /*!
@@ -342,7 +342,7 @@
       
                 IPD: R/W
             */
-            MYODBCDbgReturn( setTypeC( (SQLSMALLINT)pValuePtr ) );
+            MYODBCDbgReturn( setTypeSQL( (SQLSMALLINT)pValuePtr ) );
 
         case SQL_DESC_TYPE_NAME:
             /*!

Modified: MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-05-08 22:40:45 UTC (rev 208)
+++ MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-05-09 04:59:53 UTC (rev 209)
@@ -461,7 +461,7 @@
     pDiagnostic->doClear();
 
     /*!
-        \internal ODBC RULE
+        \internal ODBC RULE (DM)
 
         An asynchronously executing function was called for the 
         StatementHandle and was still executing when this function 
@@ -476,23 +476,18 @@
         MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
-        \internal ODBC RULE
+        \internal ODBC RULE (DM)
 
         SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos was 
         called for the StatementHandle and returned SQL_NEED_DATA. 
         This function was called before data was sent for all 
         data-at-execution parameters or columns.
-
-        \note
-
-        DM should handle this but check here in case where app is linked
-        directly to driver.
     */
     if ( isDataNeeded() )
         MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
-        \internal ODBC RULE
+        \internal ODBC RULE 
 
         Columns are numbered in increasing column order starting at 0, 
         where column 0 is the bookmark column. If bookmarks are not 
@@ -668,43 +663,102 @@
 {
     MYODBCDbgEnter();
 
-    SQLRETURN nReturn;
+    SQLRETURN   nReturn;
+    BOOLEAN     bHasInfo = false;
 
     /*!
+        \internal
+
+        \todo
+
+        We use setDescField here to reduce redundant code but some diagnostic
+        information may end up in descriptor->pDiagnostic instead of
+        this->pDiagnostic. One way to solve this is to copy any diagnostic.
+    */
+
+
+    /*!
         \internal ODBC RULE
 
         We clear diagnostic each time an ODBC API call is made (with exceptions).
     */
     pDiagnostic->doClear();
 
+    /*!
+        \internal ODBC RULE (DM)
 
-    /*
-        \internal ODBC Rule
+        An asynchronously executing function was called for the 
+        StatementHandle and was still executing when this function 
+        was called.
 
+        \note
+
+        DM should handle this but check here in case where app is linked
+        directly to driver.
+    */
+    if ( isAsyncInProgress() )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010 ) );
+
+    /*!
+        \internal ODBC RULE (DM)
+
+        SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos was 
+        called for the StatementHandle and returned SQL_NEED_DATA. 
+        This function was called before data was sent for all 
+        data-at-execution parameters or columns.
+    */
+    if ( isDataNeeded() )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010 ) );
+
+    /*!
+        \internal ODBC RULE (DM)
+
+        The value specified for the argument ParameterNumber was less than 1.
+    */
+    if ( nParameterNumber < 1 )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_07009 ) );
+
+    /*!
+        \internal ODBC RULE (DM)
+
+        The argument ParameterValuePtr was a null pointer, the argument StrLen_or_IndPtr 
+        was a null pointer, and the argument InputOutputType was not SQL_PARAM_OUTPUT.
+    */
+    if ( !nParameterValuePtr && !pnStrLenOrIndPtr && nInputOutputType !=
SQL_PARAM_OUTPUT )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY009 ) );
+
+    /*!
+        \internal ODBC RULE (DM)
+
+        SQL_PARAM_OUTPUT, where the argument ParameterValuePtr was a null pointer, the 
+        C-type was char or binary, and the BufferLength (cbValueMax) was greater than 0.
+    */
+    if ( nInputOutputType == SQL_PARAM_OUTPUT && !nParameterValuePtr && (
isCharTypeC( nValueType ) || isBinTypeC( nValueType ) ) && nBufferLength > 0 )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY009 ) );
+
+    /*!
+        \internal ODBC RULE (DM)
+
+        The value in BufferLength was less than 0.
+    */
+    if ( nBufferLength < 0 )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY090 ) );
+
+    /*!
+        \internal ODBC RULE
+
         If ParameterNumber in the call to SQLBindParameter is greater than the 
         value of SQL_DESC_COUNT, SQLSetDescField is called to increase the 
         value of SQL_DESC_COUNT to ParameterNumber.
 
+        \note
+
         The assumption here is that this rule is applied to both the APD 
         and the IPD. 
     */
 
     /* do nothing: this is automatically done by MYODBCDrvSetDescField calls */
 
-    /*
-        \internal ODBC Rule
-
-        An application can set the ParameterValuePtr argument to a null 
-        pointer, as long as *StrLen_or_IndPtr is SQL_NULL_DATA or 
-        SQL_DATA_AT_EXEC. (This applies only to input or input/output 
-        parameters.)
-    */      
-    if ( !nParameterValuePtr && (nInputOutputType == SQL_PARAM_INPUT ||
nInputOutputType == SQL_PARAM_INPUT_OUTPUT) )
-    {
-        if ( !pnStrLenOrIndPtr || ((int)pnStrLenOrIndPtr != SQL_NULL_DATA &&
(int)pnStrLenOrIndPtr != SQL_DATA_AT_EXEC) )
-            MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_HY009, 0, NULL )
);
-    }
-
     /*!
         \internal ODBC Rule
 
@@ -717,126 +771,36 @@
 
         \todo There are other rules to be checked here. See ODBC spec.
     */
-    nReturn = MYODBCDrvSetDescField( pStm->attr_imp_param_desc, nParameterNumber,
SQL_DESC_PARAMETER_TYPE, (SQLPOINTER)(SQLINTEGER)nInputOutputType, SQL_IS_SMALLINT );
+    nReturn = pImpParamDesc->setDescField( nParameterNumber, SQL_DESC_PARAMETER_TYPE,
(SQLPOINTER)(SQLINTEGER)nInputOutputType, SQL_IS_SMALLINT );
     if ( !SQL_SUCCEEDED( nReturn ) )
         MYODBCDbgReturn( nReturn );
 
-    /* 
-        \internal ODBC Rule
+    /*!
+        \internal ODBC RULE 
 
-        This must be one of the values in the C Data Types section of 
-        Appendix D: Data Types.
-
-        Calling MYODBCDrvSetDescField with SQL_DESC_CONCISE_TYPE will set  
-        all 3 fields as required. However; MYODBCDrvSetDescField will allow
-        SQL and C concise types so we must ensure we are just using a C
-        concise type before making the call.
+        The ValueType argument specifies the C data type of the parameter. 
+        This argument sets the SQL_DESC_TYPE, SQL_DESC_CONCISE_TYPE, and 
+        SQL_DESC_DATETIME_INTERVAL_CODE fields of the APD.
     */
-    switch ( nValueType )
-    {
-        case SQL_C_CHAR:
-        case SQL_C_SSHORT:
-        case SQL_C_USHORT:
-        case SQL_C_SLONG:
-        case SQL_C_ULONG:
-        case SQL_C_FLOAT:
-        case SQL_C_DOUBLE:
-        case SQL_C_BIT:
-        case SQL_C_STINYINT:
-        case SQL_C_UTINYINT:
-        case SQL_C_SBIGINT:
-        case SQL_C_UBIGINT:
-        case SQL_C_BINARY:
-/*    case SQL_C_VARBOOKMARK: */
-        case SQL_C_NUMERIC:
-        case SQL_C_GUID:
-        case SQL_C_DEFAULT:
-        case SQL_C_INTERVAL_YEAR:
-        case SQL_C_INTERVAL_MONTH:
-        case SQL_C_INTERVAL_DAY:
-        case SQL_C_INTERVAL_HOUR:
-        case SQL_C_INTERVAL_MINUTE:
-        case SQL_C_INTERVAL_SECOND:
-        case SQL_C_INTERVAL_YEAR_TO_MONTH:
-        case SQL_C_INTERVAL_DAY_TO_HOUR:
-        case SQL_C_INTERVAL_DAY_TO_MINUTE:
-        case SQL_C_INTERVAL_DAY_TO_SECOND:
-        case SQL_C_INTERVAL_HOUR_TO_MINUTE:
-        case SQL_C_INTERVAL_HOUR_TO_SECOND:
-        case SQL_C_INTERVAL_MINUTE_TO_SECOND:
-            nReturn = MYODBCDrvSetDescField( pStm->attr_app_param_desc,
nParameterNumber, SQL_DESC_CONCISE_TYPE, (SQLPOINTER)(SQLINTEGER)nValueType,
SQL_IS_SMALLINT );
-            if ( !SQL_SUCCEEDED( nReturn ) )
-                MYODBCDbgReturn( nReturn );
-            break;
-        default:
-            /*! \todo add support for SQL_C_XML (currently not defined on unixODBC) */
-            MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_HY003, 0, NULL )
);
-    }
+    nReturn = pAppParamDesc->setDescField( nParameterNumber, SQL_DESC_CONCISE_TYPE,
(SQLPOINTER)(SQLINTEGER)nValueType, SQL_IS_SMALLINT );
+    if ( !SQL_SUCCEEDED( nReturn ) )
+        MYODBCDbgReturn( nReturn );
 
-    /*
-        \internal ODBC Rule
+    /*!
+        \internal ODBC RULE
 
-        This must be one of the values listed in the SQL Data Types section of 
-        Appendix D: Data Types, or it must be a driver-specific value. This 
+        This must be one of the values listed in the SQL Data Types section 
+        of Appendix D: Data Types, or it must be a driver-specific value. This 
         argument sets the SQL_DESC_TYPE, SQL_DESC_CONCISE_TYPE, and 
-        SQL_DESC_DATETIME_INTERVAL_CODE fields of the IPD.      
+        SQL_DESC_DATETIME_INTERVAL_CODE fields of the IPD.
+    */
+    nReturn = pImpParamDesc->setDescField( nParameterNumber, SQL_DESC_CONCISE_TYPE,
(SQLPOINTER)(SQLINTEGER)nParameterType, SQL_IS_SMALLINT );
+    if ( !SQL_SUCCEEDED( nReturn ) )
+        MYODBCDbgReturn( nReturn );
 
-        Calling MYODBCDrvSetDescField with SQL_DESC_CONCISE_TYPE will set  
-        all 3 fields as required. However; MYODBCDrvSetDescField will allow
-        SQL and C concise types so we must ensure we are just using a SQL
-        concise type before making the call.
-    */      
-    switch ( nParameterType )
-    {
-        case SQL_CHAR:
-        case SQL_VARCHAR:
-        case SQL_LONGVARCHAR:
-#ifdef UNICODE
-        case SQL_WCHAR:
-        case SQL_WVARCHAR:
-        case SQL_WLONGVARCHAR:
-#endif
-        case SQL_DECIMAL:
-        case SQL_NUMERIC:
-        case SQL_SMALLINT:
-        case SQL_INTEGER:
-        case SQL_REAL:
-        case SQL_FLOAT:
-        case SQL_DOUBLE:
-        case SQL_BIT:
-        case SQL_TINYINT:
-        case SQL_BIGINT:
-        case SQL_BINARY:
-        case SQL_VARBINARY:
-        case SQL_LONGVARBINARY:
-        case SQL_TYPE_DATE:
-        case SQL_TYPE_TIME:
-        case SQL_TYPE_TIMESTAMP:
-        case SQL_INTERVAL_MONTH:
-        case SQL_INTERVAL_YEAR:
-        case SQL_INTERVAL_YEAR_TO_MONTH:
-        case SQL_INTERVAL_DAY:
-        case SQL_INTERVAL_HOUR:
-        case SQL_INTERVAL_MINUTE:
-        case SQL_INTERVAL_SECOND:
-        case SQL_INTERVAL_DAY_TO_HOUR:
-        case SQL_INTERVAL_DAY_TO_MINUTE:
-        case SQL_INTERVAL_DAY_TO_SECOND:
-        case SQL_INTERVAL_HOUR_TO_MINUTE:
-        case SQL_INTERVAL_HOUR_TO_SECOND:
-        case SQL_INTERVAL_MINUTE_TO_SECOND:
-        case SQL_GUID:
-            nReturn = MYODBCDrvSetDescField( pStm->attr_imp_param_desc,
nParameterNumber, SQL_DESC_CONCISE_TYPE, (SQLPOINTER)(SQLINTEGER)nParameterType,
SQL_IS_SMALLINT );
-            if ( !SQL_SUCCEEDED( nReturn ) )
-                MYODBCDbgReturn( nReturn );
-            break;
-        default:
-            MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_HY003, 0, NULL )
);
-    }
+    /*!
+        \internal ODBC RULE
 
-    /*
-        \internal ODBC Rule
-
         If ParameterType is SQL_CHAR, SQL_VARCHAR, SQL_LONGVARCHAR, SQL_BINARY, 
         SQL_VARBINARY, SQL_LONGVARBINARY, or one of the concise SQL datetime or 
         interval data types, the SQL_DESC_LENGTH field of the IPD is set to the 
@@ -855,7 +819,7 @@
         case SQL_FLOAT:
         case SQL_REAL:
         case SQL_DOUBLE:
-            nReturn = MYODBCDrvSetDescField( pStm->attr_imp_param_desc,
nParameterNumber, SQL_DESC_PRECISION, (SQLPOINTER)nColumnSize, SQL_IS_UINTEGER );
+            nReturn = pImpParamDesc->setDescField( nParameterNumber,
SQL_DESC_PRECISION, (SQLPOINTER)nColumnSize, SQL_IS_UINTEGER );
             if ( !SQL_SUCCEEDED( nReturn ) )
                 MYODBCDbgReturn( nReturn );
             break;
@@ -882,7 +846,7 @@
         case SQL_INTERVAL_HOUR_TO_MINUTE:
         case SQL_INTERVAL_HOUR_TO_SECOND:
         case SQL_INTERVAL_MINUTE_TO_SECOND:
-            nReturn = MYODBCDrvSetDescField( pStm->attr_imp_param_desc,
nParameterNumber, SQL_DESC_LENGTH, (SQLPOINTER)nColumnSize, SQL_IS_UINTEGER );
+            nReturn = pImpParamDesc->setDescField( nParameterNumber, SQL_DESC_LENGTH,
(SQLPOINTER)nColumnSize, SQL_IS_UINTEGER );
             if ( !SQL_SUCCEEDED( nReturn ) )
                 MYODBCDbgReturn( nReturn );
             break;
@@ -902,7 +866,7 @@
     {
         case SQL_NUMERIC:
         case SQL_DECIMAL:  
-            nReturn = MYODBCDrvSetDescField( pStm->attr_imp_param_desc,
nParameterNumber, SQL_DESC_SCALE, (SQLPOINTER)(SQLINTEGER)nDecimalDigits, SQL_IS_SMALLINT
);
+            nReturn = pImpParamDesc->setDescField( nParameterNumber, SQL_DESC_SCALE,
(SQLPOINTER)(SQLINTEGER)nDecimalDigits, SQL_IS_SMALLINT );
             if ( !SQL_SUCCEEDED( nReturn ) )
                 MYODBCDbgReturn( nReturn );
             break;
@@ -912,7 +876,7 @@
         case SQL_INTERVAL_DAY_TO_SECOND:
         case SQL_INTERVAL_HOUR_TO_SECOND:
         case SQL_INTERVAL_MINUTE_TO_SECOND:
-            nReturn = MYODBCDrvSetDescField( pStm->attr_imp_param_desc,
nParameterNumber, SQL_DESC_PRECISION, (SQLPOINTER)(SQLINTEGER)nDecimalDigits,
SQL_IS_SMALLINT );
+            nReturn = pImpParamDesc->setDescField( nParameterNumber,
SQL_DESC_PRECISION, (SQLPOINTER)(SQLINTEGER)nDecimalDigits, SQL_IS_SMALLINT );
             if ( !SQL_SUCCEEDED( nReturn ) )
                 MYODBCDbgReturn( nReturn );
             break;
@@ -925,7 +889,7 @@
 
         \todo Factor in the ODBC rules found in the spec.
     */      
-    nReturn = MYODBCDrvSetDescField( pStm->attr_app_param_desc, nParameterNumber,
SQL_DESC_OCTET_LENGTH, (SQLPOINTER)nBufferLen, SQL_IS_INTEGER );
+    nReturn = pAppParamDesc->setDescField( nParameterNumber, SQL_DESC_OCTET_LENGTH,
(SQLPOINTER)nBufferLen, SQL_IS_INTEGER );
     if ( !SQL_SUCCEEDED( nReturn ) )
         MYODBCDbgReturn( nReturn );
 
@@ -938,19 +902,19 @@
     */
     if ( pnStrLenOrIndPtr && *pnStrLenOrIndPtr > 0 )
     {
-        nReturn = MYODBCDrvSetDescField( pStm->attr_app_param_desc, nParameterNumber,
SQL_DESC_INDICATOR_PTR, pnStrLenOrIndPtr, SQL_IS_POINTER );
+        nReturn = pAppParamDesc->setDescField( nParameterNumber,
SQL_DESC_INDICATOR_PTR, pnStrLenOrIndPtr, SQL_IS_POINTER );
         if ( !SQL_SUCCEEDED( nReturn ) )
             MYODBCDbgReturn( nReturn );
-        nReturn = MYODBCDrvSetDescField( pStm->attr_app_param_desc, nParameterNumber,
SQL_DESC_OCTET_LENGTH_PTR, NULL, SQL_IS_POINTER );
+        nReturn = pAppParamDesc->setDescField( nParameterNumber,
SQL_DESC_OCTET_LENGTH_PTR, NULL, SQL_IS_POINTER );
         if ( !SQL_SUCCEEDED( nReturn ) )
             MYODBCDbgReturn( nReturn );
     }
     else
     {
-        nReturn = MYODBCDrvSetDescField( pStm->attr_app_param_desc, nParameterNumber,
SQL_DESC_OCTET_LENGTH_PTR, pnStrLenOrIndPtr, SQL_IS_POINTER );
+        nReturn = pAppParamDesc->setDescField( nParameterNumber,
SQL_DESC_OCTET_LENGTH_PTR, pnStrLenOrIndPtr, SQL_IS_POINTER );
         if ( !SQL_SUCCEEDED( nReturn ) )
             MYODBCDbgReturn( nReturn );
-        nReturn = MYODBCDrvSetDescField( pStm->attr_app_param_desc, nParameterNumber,
SQL_DESC_INDICATOR_PTR, NULL, SQL_IS_POINTER );
+        nReturn = pAppParamDesc->setDescField( nParameterNumber,
SQL_DESC_INDICATOR_PTR, NULL, SQL_IS_POINTER );
         if ( !SQL_SUCCEEDED( nReturn ) )
             MYODBCDbgReturn( nReturn );
     }
@@ -961,7 +925,7 @@
         We want to set this value last, as long as we are using MYODBCDrvSetDescField
         to set the value, because this will cause a deeper validation.
     */       
-    nReturn = MYODBCDrvSetDescField( pStm->attr_app_param_desc, nParameterNumber,
SQL_DESC_DATA_PTR, nParameterValuePtr, SQL_IS_POINTER );
+    nReturn = pAppParamDesc->setDescField( nParameterNumber, SQL_DESC_DATA_PTR,
nParameterValuePtr, SQL_IS_POINTER );
     if ( !SQL_SUCCEEDED( nReturn ) )
         MYODBCDbgReturn( nReturn );
 

Thread
Connector/ODBC 5 commit: r209 - MYSQLPlus/MYSQLPlusLibpharvey9 May