List:Commits« Previous MessageNext Message »
From:pharvey Date:May 9 2006 11:14pm
Subject:Connector/ODBC 5 commit: r216 - MYSQLPlus/MYSQLPlusLib
View as plain text  
Modified:
   MYSQLPlus/MYSQLPlusLib/MResult.cpp
   MYSQLPlus/MYSQLPlusLib/MResult.h
   MYSQLPlus/MYSQLPlusLib/MResultPlus.h
   MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp
   MYSQLPlus/MYSQLPlusLib/MResultStmt.h
   MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:


Modified: MYSQLPlus/MYSQLPlusLib/MResult.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.cpp	2006-05-09 21:21:09 UTC (rev 215)
+++ MYSQLPlus/MYSQLPlusLib/MResult.cpp	2006-05-09 23:14:44 UTC (rev 216)
@@ -49,7 +49,8 @@
 
     Q_ASSERT( !pStatement );
 
-    this->pStatement = pStatement;
+    pStatement->getImpParamDesc()->doClear();
+    pStatement->getImpRowDesc()->doClear();
 
     MYODBCDbgReturn2();
 }
@@ -58,6 +59,9 @@
 {
     MYODBCDbgEnter();
 
+    getImpParamDesc()->doClear();
+    getImpRowDesc()->doClear();
+
     MYODBCDbgReturn2();
 }
 
@@ -76,7 +80,7 @@
 {
     MYODBCDbgEnter();
 
-    MYODBCDbgReturn3( "%p", pStatement );
+    MYODBCDbgReturn3( "%p", (MStatement*)parent() );
 }
 
 MDiagnostic * MResult::getDiagnostic()

Modified: MYSQLPlus/MYSQLPlusLib/MResult.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.h	2006-05-09 21:21:09 UTC (rev 215)
+++ MYSQLPlus/MYSQLPlusLib/MResult.h	2006-05-09 23:14:44 UTC (rev 216)
@@ -66,7 +66,7 @@
     MDescriptor *   getImpRowDesc();
 
 private:
-    MStatement *pStatement;
+
 };
 
 #endif

Modified: MYSQLPlus/MYSQLPlusLib/MResultPlus.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultPlus.h	2006-05-09 21:21:09 UTC (rev 215)
+++ MYSQLPlus/MYSQLPlusLib/MResultPlus.h	2006-05-09 23:14:44 UTC (rev 216)
@@ -4,7 +4,7 @@
 #include "MInternal.h"
 
 /*!
-    \brief  This is a statement where the result-set is created and maintained within the
driver.
+    \brief  This is a statement where the result-set is created and maintained within
MYSQLPlus.
 
             We use this to support driver derived result-sets. In most cases, but not
all, the
             data for the result-set comes from the server. The driver will ensure that
the data
@@ -22,9 +22,8 @@
                 - SQLStatistics
                 - SQLTablePrivileges
 
-    \sa MYODBCRes
-        MYODBCResClient
-        MYODBCResServer
+    \sa     MResult
+            MResultStmt
 */
 class MResultPlus : public MResult
 {

Modified: MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp	2006-05-09 21:21:09 UTC (rev 215)
+++ MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp	2006-05-09 23:14:44 UTC (rev 216)
@@ -1,54 +1,24 @@
 #include "MResultStmt.h"
 
 /*! 
-    \brief  Result-set based upon a server-side prepared statement (MYSQL_STMT).
+    \brief  Constructs a new MResultStmt.
                 
-            This result-set utilizes the unique features of MySQL prepared statements.
This 
-            includes such things as;
-
-            - server-side prepared statements
-            - binary protocol
-            - chunking large data values to/from server
-
-            There are pros and cons to using MySQL prepared statements - see the
-            manual for details.
-
-            Here are some not-so-obvious limitations in using MySQL prepared statements
-            to support the ODBC specification;
-
-            - The use of MYSQL_BIND to bind columns means the client-lib and/or server
will 
-            convert the data to the desired target type. This could save the driver some
-            work; however, MySQL does not understand all of the needed ODBC types. For
example; 
-            SQL_NUMERIC_STRUCT, SQL_TIMESTAMP_STRUCT etc. For this reason it is not
always possible 
-            to bind application buffers from the ARD directly to the MYSQL_BIND data
buffer and rely
-            upon the MySQL data conversion.
-            - The ODBC specification requires binding/unbinding at anytime. MySQL has
limitations which
-            means we can not use mysql_stmt_bind_result().
-            - Data chunking column data is only available with mysql_stmt_fetch_column()
- limiting
-            our possible use of mysql_stmt_bind_result().
-
-            The following are considerations with regard to unbuffered result-sets;
-
-            - Random access of rows is not supported with unbuffered result-sets. This is
fine for 
-            forward only cursors but mysql_stmt_store_result() must be called otherwise.
-            - The number of rows in a result-set is often (but not always) needed in ODBC
and is only
-            available with buffered results.
-            - The max_length of a column value in a result-set (actual length of data) is
only
-            available in buffered result-sets (and only if STMT_ATTR_UPDATE_MAX_LENGTH
turned on). This
-            can complicate things slightly when allocating buffers, optimaly, to hold
column data.
-             
-    \param  patt    Reference to statement attributes.
-            pmysql  Reference to our mysql connection.
-
-    \sa     MYODBCRes
-            MYODBCResClient
-            MYODBCResDriver
+    \param  pStatement  Reference to MStatement (parent).
 */
-MResultStmt::MResultStmt( MYODBCAttStatement *patt, MYSQL *pmysql )
-    : MResult( patt, pmysql )
+MResultStmt::MResultStmt( MStatement *pStatement )
+    : MResult( pStatement )
 {
     MYODBCDbgEnter();
 
+    int bUpdateMaxLength = 1;
+
+    pbindColumns    = NULL;
+    nRow            = 0;
+    stringStatement = QString::null;
+    pstm            = mysql_stmt_init(
(MYSQL*)(pStatement->getConnection()->getMySQL()) );
+    Q_ASSERT( !pstm );
+    mysql_stmt_attr_set( pstm, STMT_ATTR_UPDATE_MAX_LENGTH, &bUpdateMaxLength )
+
     MYODBCDbgReturn2();
 }
 
@@ -56,6 +26,9 @@
 {
     MYODBCDbgEnter();
 
+    mysql_stmt_close( pstm );
+    pstm = NULL;
+
     MYODBCDbgReturn2();
 }
 
@@ -63,7 +36,7 @@
     \brief  Sets a column value in a result-set.
                 
             This method is used to set the value of a column and current row in a
result-set. This is used
-            to support SQLPutData etc.
+            to support pos update etc.
 
     \todo   Implement MResultStmt::setData.
                 
@@ -78,9 +51,6 @@
 {
     MYODBCDbgEnter();
 
-    if ( getState() < Executed )
-        MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
-
     if ( !isValidRow() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid row." ) );
 
@@ -91,8 +61,12 @@
     if (  nColumn == 0 )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid column. Bookmark column is read-only." ) );
 
-    /*! \todo */
+    /*! \internal
+        \todo 
 
+        Revisit this method and see about implementing.
+    */
+
     MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0, "setData
not supported here at this time." ) );
 }
 
@@ -123,15 +97,20 @@
 {
     MYODBCDbgEnter();
 
-    if ( getState() < Executed )
-        MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
-
     if ( !isValidRow( nRow ) )
     {
         nRow = 0;
         MYODBCDbgReturn( SQL_NO_DATA );
     }
 
+    Q_ASSERT( !pstm );
+
+    /*!
+        \internal
+        \todo
+
+        Handle return code.
+    */
     mysql_stmt_data_seek( pstm, nRow - 1 ); 
 
     MYODBCDbgReturn( SQL_SUCCESS );
@@ -155,9 +134,6 @@
 
     Q_ASSERT( !pnColumns );
 
-    if ( getState() < Prepared )
-        MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
-
     *pnColumns = getImpRowDesc()->getCount();
 
     MYODBCDbgReturn( SQL_SUCCESS );
@@ -186,9 +162,6 @@
 {
     MYODBCDbgEnter();
 
-    if ( getState() < Executed )
-        MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
-
     if ( !isValidRow() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid row." ) );
 
@@ -196,7 +169,7 @@
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid column." ) );
 
     if ( nColumn == 0 )
-        variantData = nRow; // bookmark - using nRow has limitations  
+        variantData = nRow; // bookmark - using nRow has limitations  !!!
     else
     {
         MYSQL_BIND *pbind = &(pbindColumns[nColumn - 1]);
@@ -262,24 +235,23 @@
 /*!
     \brief  This gets column data from the drivers row buffers.
 
-    \param  nColumn The column we are dealing with.
-    \param  pdesrec This a bound ARD.
-    \param  pbind   This is needs to hold our column data.
+    \param  nColumn             The column we are dealing with.
+    \param  pDescriptorRecord   This a bound ARD.
 
     \return SQLRETURN
 
     \sa     getData
 */
-SQLRETURN MResultStmt::getData( uint nColumn, MYODBCDesRecARD *pdesrec )
+SQLRETURN MResultStmt::getData( uint nColumn, MDescriptorRecordARD *pDescriptorRecord )
 {
     MYODBCDbgEnter();
 
     QVariant        variantData;
     MYSQL_BIND *    pbind           = &(pbindColumns[nColumn]);
     SQLRETURN       nReturn         = getData( nColumn, variantData );
-    SQLPOINTER      pdata           = pdesrec->getDataPtr();
-    SQLINTEGER *    pnIndicator     = pdesrec->getIndicatorPtr();
-    SQLINTEGER *    pnOctetLength   = pdesrec->getOctetLengthPtr();
+    SQLPOINTER      pdata           = pDescriptorRecord->getDataPtr();
+    SQLINTEGER *    pnIndicator     = pDescriptorRecord->getIndicatorPtr();
+    SQLINTEGER *    pnOctetLength   = pDescriptorRecord->getOctetLengthPtr();
 
     if ( variantData.isNull() )
     {
@@ -294,14 +266,14 @@
 
     if ( pnIndicator ) *pnIndicator = 0;
 
-    switch ( pdesrec->getConciseType() )
+    switch ( pDescriptorRecord->getConciseType() )
     {
         case SQL_C_CHAR:
             {
                 if ( !variantData.canConvert<QString>() )
                     MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_07006
) );
                 QString stringData = variantData.asString();
-                MYODBCC::doStrNCpy( (SQLWCHAR)pdata, pdesrec->getOctetLength() /
sizeof(SQLWCHAR), stringData.utf16() );
+                MYODBCC::doStrNCpy( (SQLWCHAR)pdata,
pDescriptorRecord->getOctetLength() / sizeof(SQLWCHAR), stringData.utf16() );
                 if ( pnOctetLength ) *pnOctetLength = stringData.length() *
sizeof(SQLWCHAR);
             }
             break;
@@ -397,7 +369,7 @@
             {
                 QByteArray bytearray = variantData.toByteArray();
 
-                MYODBCC::doMemCpy( pdata, bytearray.constData(),
pdesrec->getOctetLength() );
+                MYODBCC::doMemCpy( pdata, bytearray.constData(),
pDescriptorRecord->getOctetLength() );
                 if ( pnOctetLength ) *pnOctetLength = bytearray.size();
             }
             break;
@@ -473,9 +445,6 @@
         default:
     }
 
-++++++++++++++++++++++++
-
-
     MYODBCDbgReturn( SQL_SUCCESS );
 }
 
@@ -496,9 +465,6 @@
 
     Q_ASSERT( !pnRow );
 
-    if ( getState() < Executed )
-        MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
-
     *pnRow = nRow;
 
     MYODBCDbgReturn( SQL_SUCCESS );
@@ -524,9 +490,12 @@
 
     Q_ASSERT( !pnRow );
 
-    if ( getState() < Executed )
-        MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
+    /*!
+        \internal
+        \todo
 
+        Handle errors.
+    */
     *pnRows = mysql_stmt_num_rows( pstm );
 
     MYODBCDbgReturn( SQL_SUCCESS );
@@ -548,10 +517,6 @@
 SQLRETURN MResultStmt::doAppend()
 {
     MYODBCDbgEnter();
-
-    if ( getState() < Executed )
-        MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
-
     MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0, "doAppend
not supported here at this time." ) );
 }
 
@@ -569,7 +534,12 @@
 {
     MYODBCDbgEnter();
 
-    setState( Initialized );
+    pstm;
+    pbindColumns;
+    nRow            = 0;
+    stringStatement = QString::null;
+    getImpParamDesc()->doClear();
+    getImpRowDesc()->doClear();
 
     MYODBCDbgReturn( SQL_SUCCESS );
 }

Modified: MYSQLPlus/MYSQLPlusLib/MResultStmt.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultStmt.h	2006-05-09 21:21:09 UTC (rev 215)
+++ MYSQLPlus/MYSQLPlusLib/MResultStmt.h	2006-05-09 23:14:44 UTC (rev 216)
@@ -3,19 +3,47 @@
 
 #include "MInternal.h"
 
-/*!
-    \brief  This is a statement based upon a MYSQL_STMT.
+/*! 
+    \brief  Result-set based upon a server-side prepared statement (MYSQL_STMT).
+                
+            This result-set utilizes the unique features of MySQL prepared statements.
This 
+            includes such things as;
 
-            We use this when we want to have the server do more of the work
-            such as prepare the statement text.
+            - server-side prepared statements
+            - binary protocol
+            - chunking large data values to/from server
 
-    \note   There may be limitations due to incomplete implementation of
-            MYSQL_STMT based functionality on the server. For example some
-            SQL is not supported at this time. 
+            There are pros and cons to using MySQL prepared statements - see the
+            manual for details.
 
-    \sa MYODBCRes
-        MYODBCResClient
-        MYODBCResDriver
+            Here are some not-so-obvious limitations in using MySQL prepared statements
+            to support the ODBC specification;
+
+            - The use of MYSQL_BIND to bind columns means the client-lib and/or server
will 
+            convert the data to the desired target type. This could save the driver some
+            work; however, MySQL does not understand all of the needed ODBC types. For
example; 
+            SQL_NUMERIC_STRUCT, SQL_TIMESTAMP_STRUCT etc. For this reason it is not
always possible 
+            to bind application buffers from the ARD directly to the MYSQL_BIND data
buffer and rely
+            upon the MySQL data conversion.
+            - The ODBC specification requires binding/unbinding at anytime. MySQL has
limitations which
+            means we can not use mysql_stmt_bind_result().
+            - Data chunking column data is only available with mysql_stmt_fetch_column()
- limiting
+            our possible use of mysql_stmt_bind_result().
+            - There may be limitations due to incomplete implementation of MYSQL_STMT
based 
+            functionality on the server. For example some SQL is not supported at this
time. 
+
+            The following are considerations with regard to unbuffered result-sets;
+
+            - Random access of rows is not supported with unbuffered result-sets. This is
fine for 
+            forward only cursors but mysql_stmt_store_result() must be called otherwise.
+            - The number of rows in a result-set is often (but not always) needed in ODBC
and is only
+            available with buffered results.
+            - The max_length of a column value in a result-set (actual length of data) is
only
+            available in buffered result-sets (and only if STMT_ATTR_UPDATE_MAX_LENGTH
turned on). This
+            can complicate things slightly when allocating buffers, optimaly, to hold
column data.
+
+    \sa     MResult
+            MResultRes
 */
 class MResultStmt : public MResult
 {
@@ -28,7 +56,7 @@
 
     SQLRETURN getColumns( uint *pnColumns );
     SQLRETURN getData( uint nColumn, QVariant &variantData );
-    SQLRETURN getData( uint nColumn, MYODBCDesRecARD *pdesrec );
+    SQLRETURN getData( uint nColumn, MDescriptorRecordARD *pDescriptorRecord );
     SQLRETURN getRow( qulonglong *pnRow );
     SQLRETURN getRows( qulonglong *pnRows );
 

Modified: MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-05-09 21:21:09 UTC (rev 215)
+++ MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-05-09 23:14:44 UTC (rev 216)
@@ -1477,7 +1477,7 @@
     }
 
     /* what flavour of resultset do we want? */
-    switch ( getStatementType() )
+    switch ( getConnection()->getStatementType() )
     {
         case STATEMENT_RES:     
             /*!
@@ -1503,7 +1503,7 @@
                 - SQL statement
                 - resultset characteristics expected (if possible)
             */
-            MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_01000, 0,
tr("STATEMENT_DYNAMIC is same as STATEMENT_STMT at this time") ) );
+            pDiagnostic->doAppend( MDiagnostic::DIA_01000, 0, tr("STATEMENT_DYNAMIC is
same as STATEMENT_STMT at this time") );
 
         case STATEMENT_STMT:
             pResult = new MResultStmt( this );

Thread
Connector/ODBC 5 commit: r216 - MYSQLPlus/MYSQLPlusLibpharvey10 May