List:Commits« Previous MessageNext Message »
From:pharvey Date:June 1 2006 8:30pm
Subject:Connector/ODBC 5 commit: r305 - MYSQLPlus/MYSQLPlusLib
View as plain text  
Modified:
   MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:


Modified: MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-06-01 19:56:42 UTC (rev 304)
+++ MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-06-01 20:30:38 UTC (rev 305)
@@ -1486,7 +1486,7 @@
     MYODBCDbgReturn( doStateRollBack( STATE_S3 ) );
 }
 
-SQLRETURN MStatement::doColAttribute( SQLUSMALLINT nColumnNumber, SQLUSMALLINT
nFieldIdentifier, SQLPOINTER psCharacterAttributePtr, SQLSMALLINT nBufferLength,
SQLSMALLINT *pnStringLengthPtr, SQLPOINTER pnNumericAttributePtr )
+SQLRETURN MStatement::doColAttribute( SQLUSMALLINT nColumnNumber, SQLUSMALLINT
nFieldIdentifier, SQLPOINTER psCharacterAttribute, SQLSMALLINT nBufferLength, SQLSMALLINT
*pnStringLength, SQLPOINTER pnNumericAttribute )
 {
     MYODBCDbgEnter();
 
@@ -1499,38 +1499,72 @@
 
     SQLPOINTER pPointer = NULL;
 
-    MYODBCDbgEnter( "MYODBCDrvColAttribute" );
+    /*!
+        \internal ODBC RULE (DM)
 
-    /*! 
-        \todo More checks as per spec. Some of which may already be in 
-        MYODBCDrvGetDescField - some may not.
-    */           
+        The function was called prior to calling SQLPrepare, SQLExecDirect, or a catalog
function for 
+        the StatementHandle.
+    */
+    if ( getState() < STATE_S2 )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
-        \internal ODBC Rule
+        \internal ODBC RULE
 
-        The statement associated with the StatementHandle did not return 
-        a result set and FieldIdentifier was not SQL_DESC_COUNT. There 
-        were no columns to describe.
+        The statement associated with the StatementHandle did not return a result set and
FieldIdentifier was 
+        not SQL_DESC_COUNT. There were no columns to describe.
+    */
+    if ( getState() == STATE_S4 && nFieldIdentifier != SQL_DESC_COUNT )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_07005 ) );
 
-        NOTE
+    /*!
+        \internal MYODBC RULE
 
-        SQL_COLUMN_COUNT should have been mapped to SQL_DESC_COUNT by
-        driver or by SQLColAttributes() so no need to check for it.
-    */      
-    if ( !pStm->hRes && nFieldIdentifier != SQL_DESC_COUNT )
-        MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_07005, 0, NULL ) );
+        Only server-side prepared statements (MResultStmt) can give us meta data on the
resultset
+        when we are in the prepared state.
+    */
+    if ( getState() == STATE_S5 && pResult->objectName() != "MResultStmt" )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010, 0, tr("column
attributes unknown at this time") ) );
 
     /*!
-        \internal ODBC Rule
+        \internal ODBC RULE (DM)
 
-        The value specified for the argument ColumnNumber was greater than 
-        the number of columns in the result set.
+        An asynchronously executing function (not this one) was called 
+        for the StatementHandle and was still executing when this function 
+        was called.
     */
-    if ( nColumnNumber > pStm->attr_imp_row_desc->desc_count )
-        MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_07009, 0, NULL ) );
+    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
+
+        The value specified for the argument ColumnNumber was greater than the number of
columns 
+        in the result set.
+    */
+    if ( nColumnNumber > getImpRowDesc()->getCount() )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_07009 ) );
+
+    /*!
+        \internal ODBC RULE (DM)
+
+        The value specified for ColumnNumber was equal to 0, and the
SQL_ATTR_USE_BOOKMARKS statement 
+        attribute was SQL_UB_OFF.
+    */
+    if ( nColumnNumber == 0 && getUseBookmarks() == SQL_UB_OFF )
+        MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_07009 ) );
+
+    /*!
         \internal ODBC Rule
 
         An ODBC 3.x driver must support all the ODBC 3.x FieldIdentifiers 
@@ -1543,81 +1577,75 @@
     switch ( nFieldIdentifier )
     {
         case SQL_DESC_AUTO_UNIQUE_VALUE:
-            pPointer = pnNumericAttributePtr;
+            pPointer = pnNumericAttribute;
             break;
         case SQL_DESC_BASE_COLUMN_NAME:
         case SQL_DESC_BASE_TABLE_NAME:
-            pPointer = pszCharacterAttributePtr;
+            pPointer = psCharacterAttribute;
             break;
         case SQL_DESC_CASE_SENSITIVE:
-            pPointer = pnNumericAttributePtr;
+            pPointer = pnNumericAttribute;
             break;
         case SQL_DESC_CATALOG_NAME:
-            pPointer = pszCharacterAttributePtr;
+            pPointer = psCharacterAttribute;
             break;
         case SQL_DESC_CONCISE_TYPE:
         case SQL_DESC_COUNT:
         case SQL_DESC_DISPLAY_SIZE:
         case SQL_DESC_FIXED_PREC_SCALE:
-            pPointer = pnNumericAttributePtr;
+            pPointer = pnNumericAttribute;
             break;
         case SQL_DESC_LABEL:
-            pPointer = pszCharacterAttributePtr;
+            pPointer = psCharacterAttribute;
             break;
         case SQL_DESC_LENGTH:
-            pPointer = pnNumericAttributePtr;
+            pPointer = pnNumericAttribute;
             break;
         case SQL_DESC_LITERAL_PREFIX:
         case SQL_DESC_LITERAL_SUFFIX:
         case SQL_DESC_LOCAL_TYPE_NAME:
         case SQL_DESC_NAME:
-            pPointer = pszCharacterAttributePtr;
+            pPointer = psCharacterAttribute;
             break;
         case SQL_DESC_NULLABLE:
         case SQL_DESC_NUM_PREC_RADIX:
         case SQL_DESC_OCTET_LENGTH:
         case SQL_DESC_PRECISION:
         case SQL_DESC_SCALE:
-            pPointer = pnNumericAttributePtr;
+            pPointer = pnNumericAttribute;
             break;
         case SQL_DESC_SCHEMA_NAME:
-            pPointer = pszCharacterAttributePtr;
+            pPointer = psCharacterAttribute;
             break;
         case SQL_DESC_SEARCHABLE:
-            pPointer = pnNumericAttributePtr;
+            pPointer = pnNumericAttribute;
             break;
         case SQL_DESC_TABLE_NAME:
-            pPointer = pszCharacterAttributePtr;
+            pPointer = psCharacterAttribute;
             break;
         case SQL_DESC_TYPE:
-            pPointer = pnNumericAttributePtr;
+            pPointer = pnNumericAttribute;
             break;
         case SQL_DESC_TYPE_NAME:
-            pPointer = pszCharacterAttributePtr;
+            pPointer = psCharacterAttribute;
             break;
         case SQL_DESC_UNNAMED:
         case SQL_DESC_UNSIGNED:
         case SQL_DESC_UPDATABLE:
-            pPointer = pnNumericAttributePtr;
+            pPointer = pnNumericAttribute;
             break;
         default:
-            MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_HY091, 0, NULL )
);
+            MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY091 ) );
     }
 
-    /* 
-        Keep things safe & simple for now; use MYODBCDrvGetDescField.
+    /*!
+        \internal 
+        \todo 
 
-        Call was made using standard SQL_DESC_* field. So call maps well
-        to MYODBCDrvGetDescField with IRD descriptor.
+        We may loose some spec compliance by mapping this out to getDescField - not sure.
The fields
+        map very well so we take the short-cut.
     */
-    MYODBCDbgReturn( MYODBCDrvGetDescField( pStm->attr_imp_row_desc, 
-                                            nColumnNumber, 
-                                            nFieldIdentifier, 
-                                            pPointer, 
-                                            nBufferLength, 
-                                            (SQLINTEGER*)pnStringLengthPtr ) );
-
-    MYODBCDbgReturn( SQL_ERROR );
+    MYODBCDbgReturn( getImpRowDesc()->getDescField( nColumnNumber, nFieldIdentifier,
pPointer, nBufferLength, (SQLINTEGER*)pnStringLength ) );
 }
 
 SQLRETURN MStatement::doColumnPrivileges( SQLWCHAR *psCatalogName, SQLSMALLINT
nNameLength1, SQLWCHAR *psSchemaName, SQLSMALLINT nNameLength2, SQLWCHAR *psTableName,
SQLSMALLINT nNameLength3, SQLWCHAR *psColumnName, SQLSMALLINT nNameLength4 )
@@ -2050,7 +2078,7 @@
         but we do NOT do that because it provides inconsistent behaviour. The app should
use 
         server side prepared if col count needed before execute.
     */
-    if ( getState() == STATE_S4 && pResult->objectName() != "MResultStmt" )
+    if ( getState() == STATE_S5 && pResult->objectName() != "MResultStmt" )
         MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010, 0, tr("column
count unknown at this time") ) );
 
     /*!

Thread
Connector/ODBC 5 commit: r305 - MYSQLPlus/MYSQLPlusLibpharvey1 Jun