List:Commits« Previous MessageNext Message »
From:pharvey Date:May 16 2006 6:42pm
Subject:Connector/ODBC 5 commit: r246 - MYSQLPlus/MYSQLPlusLib
View as plain text  
Modified:
   MYSQLPlus/MYSQLPlusLib/MResult.cpp
   MYSQLPlus/MYSQLPlusLib/MResult.h
Log:


Modified: MYSQLPlus/MYSQLPlusLib/MResult.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.cpp	2006-05-16 18:12:02 UTC (rev 245)
+++ MYSQLPlus/MYSQLPlusLib/MResult.cpp	2006-05-16 18:42:41 UTC (rev 246)
@@ -76,22 +76,18 @@
 
 /*!
     \internal
-    \brief
+    \brief          Gets a columns data from the current row in the result set.
 
-    \param nColumnNumber
-    \param nTargetType
-    \param pTargetValue
-    \param nBufferLength
-    \param pnLength
-    \param pnIndicator
-    \param pDescriptorRecord    IRD, ARD or APD descriptor record to be used for
precision and scale in SQL_NUMERIC_STRUCT.
-                                - IRD if we are a plain SQLGetData call. This means we
use precision and scale found in
-                                  the metadata.
-                                - ARD if we are being called to get data for a bound
column. This means we use precision and
-                                  scale specified by app for bind.
-                                - APD if we are being called to get data for a bound
parameter. This means we use precision and
-                                  scale specified by app for bind.
+                    This method has been created to implement most (if not all) of
SQLGetData() functionality. In
+                    fact; it takes all the same/similar arguments and returns the same
return values/states.
 
+    \param nColumnNumber    The desired column number as per SQLGetData().
+    \param nTargetType      The desired C data type for pTargetValue as per SQLGetData().
+    \param pTargetValue     A viable buffer where we can put the column value as per
SQLGetData().
+    \param nBufferLength    The size of the buffer at pTargetValue as per SQLGetData().
+    \param pnLength         The number of bytes available in column as per SQLGetData().
+    \param pnIndicator      A buffer to be used to indicate whether or not the column is
NULL as per SQLGetData().
+
     \return SQLRETURN
 
     \retval SQL_SUCCESS
@@ -150,8 +146,8 @@
                     Examples in the spec. (not the spec. itself) 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 type as the
-                    app can not use the numeric struct fields to do this ("they are
output only").
+                    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").
 
                     \note
 
@@ -163,6 +159,17 @@
                 */
                 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();
@@ -184,7 +191,7 @@
         case SQL_C_DEFAULT:
             {
                 MDescriptorRecordIRD *pDescriptorRecord = getImpRowDesc()->getRecord(
nColumnNumber );
-                MYODBCDbgReturn( getData( SQLUSMALLINT nColumnNumber,
MDescriptorRecordIRD *pDescriptorRecord, SQLPOINTER pTargetValue, SQLINTEGER
nBufferLength, SQLINTEGER *pnLength, SQLINTEGER *pnIndicator ) );
+                MYODBCDbgReturn( getData( SQLUSMALLINT nColumnNumber, pDescriptorRecord,
SQLPOINTER pTargetValue, SQLINTEGER nBufferLength, SQLINTEGER *pnLength, SQLINTEGER
*pnIndicator ) );
             }
             break;
 
@@ -245,7 +252,19 @@
 
         case SQL_C_NUMERIC:
             {
-                /* see also SQL_ARD_TYPE */
+                /*!
+                    \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    */
@@ -372,8 +391,15 @@
 }
 
 /*!
-    \brief  This gets column data from the drivers row buffers.
+    \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.
 
@@ -381,7 +407,7 @@
 
     \sa     getData
 */
-SQLRETURN MResult::getData( SQLUSMALLINT nColumn, MDescriptorRecord *pDescriptorRecord )
+SQLRETURN MResult::getData( SQLUSMALLINT nColumn, MDescriptorRecordARD *pDescriptorRecord
)
 {
     MYODBCDbgEnter();
 
@@ -419,6 +445,8 @@
     \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"
@@ -756,41 +784,30 @@
     MYODBCDbgReturn( SQL_SUCCESS );
 }
 
-SQLRETURN MResult::getData( const QVariant &variantData, SQL_NUMERIC_STRUCT *pTarget,
SQLINTEGER *pnLength );
-{
-    MYODBCDbgEnter();
+/*!
+    \brief          Attempts to get the data in a SQL_NUMERIC_STRUCT.
 
-    SQL_NUMERIC_STRUCT *pNumericStruct = (SQL_NUMERIC_STRUCT *)pTargetValue;
+                    The precision and scale fields of SQL_NUMERIC_STRUCT are for output
only. In other
+                    words the app can not set them and expect it to mean anything. This
is according to
+                    the ODBC specification. But we are an internal method used to support
higher-level
+                    versions of getData() and as such we expect precision and scale
fields to hold viable
+                    values as per ODBC rules.
 
-    /*!
-        \internal ODBC RULE
+    \note           Not all source data can be converted to a SQL_NUMERIC_STRUCT. There
are ODBC rules
+                    which govern this.
 
-        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.
+    \param variantData  Source data.
+    \param pTarget      Pointer to a SQL_NUMERIC_STRUCT.
+    \param pnLength     Buffer where we can set the length (number of bytes) we have
available.
 
-        In otherwords...
+    \return SQLRETURN
 
-            IF GetData THEN
-                getImpRowDesc()->getRecord( nColumn )->getPrecision();
-                getImpRowDesc()->getRecord( nColumn )->getScale();
-            ELIF BoundColumn THEN
-                getAppRowDesc()->getRecord( nColumn )->getPrecision();
-                getAppRowDesc()->getRecord( nColumn )->getScale();
-            ELIF BoundParam THEN
-                getAppParamDesc()->getRecord( nColumn )->getPrecision();
-                getAppParamDesc()->getRecord( nColumn )->getScale();
-            ENDIF
+    \sa getData()
+*/
+SQLRETURN MResult::getData( const QVariant &variantData, SQL_NUMERIC_STRUCT *pTarget,
SQLINTEGER *pnLength );
+{
+    MYODBCDbgEnter();
 
-        We assume caller has given as the proper descripor record!!
-    */
-    pNumericStruct->precision   = pDescriptorRecord->getPrecision();
-    pNumericStruct->scale       = pDescriptorRecord->getScale();
-
     /*!
         \internal ODBC RULE
 
@@ -804,15 +821,8 @@
 
     memset( pNumericStruct->val, 0, SQL_MAX_NUMERIC_LEN );
 
-    if ( pDescriptorRecord->className() == "MDescriptor" )
-    {
-    }
+++++++++++++++++
 
-    if ( !variantData.canConvert<double>() ) 
-        MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_07006 ) );
-    *((double *)pNumericStruct->val) = (double)variantData.toDouble();
-    if ( pnLength ) *pnLength = sizeof(SQL_NUMERIC_STRUCT);
-
     /*!
         \internal ODBC RULE
 

Modified: MYSQLPlus/MYSQLPlusLib/MResult.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.h	2006-05-16 18:12:02 UTC (rev 245)
+++ MYSQLPlus/MYSQLPlusLib/MResult.h	2006-05-16 18:42:41 UTC (rev 246)
@@ -86,8 +86,8 @@
     MDescriptor *   getImpParamDesc();
     MDescriptor *   getImpRowDesc();
 
-    SQLRETURN       getData( SQLUSMALLINT nColumn, MDescriptorRecord *pDescriptorRecord
); /* MDescriptorRecord needs to be a MDescriptorRecordARD or MDescriptorRecordAPD as
this is to support bound cols/params */
-    SQLRETURN       getData( SQLUSMALLINT nColumn, MDescriptorRecordIRD
*pDescriptorRecord, SQLPOINTER pTargetValue, SQLINTEGER nBufferLength, SQLINTEGER
*pnLength, SQLINTEGER *pnIndicator ); /* supports SQL_C_DEFAULT */
+    SQLRETURN       getData( SQLUSMALLINT nColumn, MDescriptorRecordARD
*pDescriptorRecord );
+    SQLRETURN       getData( SQLUSMALLINT nColumn, MDescriptorRecordIRD
*pDescriptorRecord, SQLPOINTER pTargetValue, SQLINTEGER nBufferLength, SQLINTEGER
*pnLength, SQLINTEGER *pnIndicator );
 
     SQLRETURN       getData( const QVariant &variantData, SQLWCHAR *psTarget,
SQLINTEGER nCharsMax, SQLINTEGER *nCharsAvailable );
     SQLRETURN       getData( const QVariant &variantData, short int *pnTarget,
SQLINTEGER *pnLength );

Thread
Connector/ODBC 5 commit: r246 - MYSQLPlus/MYSQLPlusLibpharvey16 May