Added:
MYODBCRes/MYODBCResLib/MYODBCResClient.cpp
MYODBCRes/include/MYODBCResClient.h
Modified:
MYODBCRes/MYODBCResLib/MYODBCResServer.cpp
MYODBCRes/include/MYODBCResServer.h
Log:
UNICODE:
- mostly some internal doc updates
Added: MYODBCRes/MYODBCResLib/MYODBCResClient.cpp
===================================================================
--- MYODBCRes/MYODBCResLib/MYODBCResClient.cpp 2006-02-13 17:22:45 UTC (rev 56)
+++ MYODBCRes/MYODBCResLib/MYODBCResClient.cpp 2006-02-13 19:38:05 UTC (rev 57)
@@ -0,0 +1 @@
+
Modified: MYODBCRes/MYODBCResLib/MYODBCResServer.cpp
===================================================================
--- MYODBCRes/MYODBCResLib/MYODBCResServer.cpp 2006-02-13 17:22:45 UTC (rev 56)
+++ MYODBCRes/MYODBCResLib/MYODBCResServer.cpp 2006-02-13 19:38:05 UTC (rev 57)
@@ -60,9 +60,11 @@
/*!
\brief Sets a column value in a result-set.
- This is not implemented as of yet. This exists in part for completeness but
also
- because it may be used as part of positioned update.
-
+ 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.
+
+ \todo Implement MYODBCResServer::setData.
+
\param nColumn The column to set. This is 1-based with 0 being reserved for the
read-only bookmark.
variantData The value to use to set the column.
@@ -96,6 +98,8 @@
row is not valid - the current row will be before the 1st row and
SQL_NO_DATA will be returned.
+ The row data will be refreshed and any bound columns will be updated.
+
\param nRow The desired row in the result-set. This is 1-based however;
0 can be used to make the current row - the row before the 1st
row.
@@ -155,15 +159,17 @@
\brief Use this to get a column value.
This will get the value of a column at the current row in the result-set.
This
- assumes that all of the bound column buffers have been loaded with column
data
+ assumes that all of the bound column buffers have been refreshed with column
data
reflecting the current row.
\param pnColumns Pointer to be used to return the number of columns.
+ variantData The column value is return here.
\return SQLRETURN
\sa doGetData
doBindCol
+ doRefresh
*/
SQLRETURN MYODBCResServer::getData( uint nColumn, QVariant &variantData )
{
@@ -243,7 +249,7 @@
This will get the current row number in the result-set.
- \param pnRow Pointer to be used to return the row number.
+ \param pnRow Reference to storage for the row number.
\return SQLRETURN
@@ -269,11 +275,12 @@
This will get the number of rows in the result-set. nRow is
1-based so nRows is a valid row.
- \param pnRows Pointer to be used to return the number of rows.
+ \param pnRows Reference to storage for the number of rows.
\return SQLRETURN
- \sa setColumns
+ \sa getColumns
+ getRow
*/
SQLRETURN MYODBCResServer::getRows( qulonglong *pnRows )
{
@@ -292,8 +299,11 @@
/*!
\brief Use this to append a new, blank, row.
- This is not implemented yet.
-
+ This will append a new blank row at the end of the result-set and make it the
+ current row.
+
+ \todo Implement MYODBCResServer::doAppend (if needed).
+
\return SQLRETURN
\sa doDelete
@@ -307,9 +317,9 @@
}
/*!
- \brief Use this to reset the result-set start state.
+ \brief Use this to reset the result-set to start state.
- This will clear the result-set (if any) and the prepare.
+ This clears the result-set (if any) and the prepare.
\return SQLRETURN
@@ -329,8 +339,11 @@
/*!
\brief Use this to delete the current row.
- This is not implemented yet.
-
+ This causes a DELETE statement to be sent to the server and, if successful,
+ causes the row to be marked as deleted.
+
+ \todo Implement MYODBCResServer::doDelete (if needed).
+
\return SQLRETURN
\sa doAppend
@@ -343,6 +356,18 @@
MYODBCDbgReturn( getDia()->doAppend( MYODBC_DIA_HY000, 0, "doDelete not supported
here at this time." ) );
}
+/*!
+ \brief Use this to execute a prepared statement.
+
+ This will execute the prepared statement. A prepared statement must exist and
all
+ required parameters must have been supplied.
+
+ The current row will be before the 1st row.
+
+ \return SQLRETURN
+
+ \sa doPrepare
+*/
SQLRETURN MYODBCResServer::doExecute()
{
MYODBCDbgEnter();
@@ -366,6 +391,26 @@
MYODBCDbgReturn( SQL_SUCCESS );
}
+/*!
+ \brief Make the 1st row in the result-set the current row.
+
+ This will make the 1st row in the result-set the current row.
+ If no rows exist the current row will be invalid and SQL_NO_DATA will be
+ returned.
+
+ The row data will be refreshed and any bound columns will be updated.
+
+ \return SQLRETURN
+
+ \sa setRow
+ getRow
+ getRows
+ doNext
+ doPrev
+ doFirst
+ doLast
+ doSkip
+*/
SQLRETURN MYODBCResServer::doFirst()
{
MYODBCDbgEnter();
@@ -382,6 +427,8 @@
nRow = 1;
mysql_stmt_data_seek( pstm, nRow - 1 );
+ doRefresh();
+
MYODBCDbgReturn( SQL_SUCCESS );
}
@@ -392,6 +439,26 @@
MYODBCDbgReturn( getDia()->doAppend( MYODBC_DIA_HY000, 0, "doInsert not supported
here at this time." ) );
}
+/*!
+ \brief Make the last row in the result-set the current row.
+
+ This will make the last row in the result-set the current row.
+ If no rows exist the current row will be invalid and SQL_NO_DATA will be
+ returned.
+
+ The row data will be refreshed and any bound columns will be updated.
+
+ \return SQLRETURN
+
+ \sa setRow
+ getRow
+ getRows
+ doNext
+ doPrev
+ doFirst
+ doLast
+ doSkip
+*/
SQLRETURN MYODBCResServer::doLast()
{
MYODBCDbgEnter();
@@ -410,9 +477,34 @@
nRow = nRows;
mysql_stmt_data_seek( pstm, nRow - 1 );
+ doRefresh();
+
MYODBCDbgReturn( SQL_SUCCESS );
}
+/*!
+ \brief Make the next row in the result-set the current row.
+
+ This will make the next row in the result-set the current row.
+
+ If this call causes the current row to move beyond the last row then
+ the current row is invalid and SQL_NO_DATA is returned. A subsequent call
+ to doNext will make the 1st row current. A subsequent call to doPrev
+ will make the last row current.
+
+ The row data will be refreshed and any bound columns will be updated.
+
+ \return SQLRETURN
+
+ \sa setRow
+ getRow
+ getRows
+ doNext
+ doPrev
+ doFirst
+ doLast
+ doSkip
+*/
SQLRETURN MYODBCResServer::doNext()
{
MYODBCDbgEnter();
@@ -429,9 +521,23 @@
mysql_stmt_data_seek( pstm, nRow - 1 );
+ doRefresh();
+
MYODBCDbgReturn( SQL_SUCCESS );
}
+/*!
+ \brief Prepares the provided statement.
+
+ This is called get the server to prepare the statement and to load the
result-set meta-data
+ into the IRD.
+
+ \param stringStatement Statement to prepare.
+
+ \return SQLRETURN
+
+ \sa doPrepare
+*/
SQLRETURN MYODBCResServer::doPrepare( const QString &stringStatement )
{
MYODBCDbgEnter();
@@ -449,12 +555,35 @@
this->stringStatement = stringStatement;
nRow = 0;
- /* store FIELD info in the IRD and bind all columns (opt latter bit later) */
+ /* get result-set meta-data */
MYODBCResStoreMetaData( pRes );
MYODBCDbgReturn( SQL_SUCCESS );
}
+/*!
+ \brief Make the previous row in the result-set the current row.
+
+ This will make the previous row in the result-set the current row.
+
+ If this call causes the current row to move before the first row then
+ the current row is invalid and SQL_NO_DATA is returned. A subsequent call
+ to doPrev will make the last row current. A subsequent call to doNext
+ will make the first row current.
+
+ The row data will be refreshed and any bound columns will be updated.
+
+ \return SQLRETURN
+
+ \sa setRow
+ getRow
+ getRows
+ doNext
+ doPrev
+ doFirst
+ doLast
+ doSkip
+*/
SQLRETURN MYODBCResServer::doPrev()
{
MYODBCDbgEnter();
@@ -471,9 +600,33 @@
mysql_stmt_data_seek( pstm, nRow - 1 );
+ doRefresh();
+
MYODBCDbgReturn( SQL_SUCCESS );
}
+/*!
+ \brief Set the current row relative to where we are now.
+
+ This call does not actually skip through rows - it simply jumps to the row at
nRows
+ from current row.
+
+ If the resulting row is invalid SQL_NO_DATA is returned and the current row
becomes
+ the row before the first row in the result-set.
+
+ The row data will be refreshed and any bound columns will be updated.
+
+ \return SQLRETURN
+
+ \sa setRow
+ getRow
+ getRows
+ doNext
+ doPrev
+ doFirst
+ doLast
+ doSkip
+*/
SQLRETURN MYODBCResServer::doSkip( qlonglong nRows )
{
MYODBCDbgEnter();
@@ -489,37 +642,31 @@
nRow += nRows;
mysql_stmt_data_seek( pstm, nRow - 1 );
+ doRefresh();
MYODBCDbgReturn( SQL_SUCCESS );
}
-bool MYODBCResServer::isValidRow()
-{
- bool b;
+/*!
+ \brief Refreshs the row data.
- MYODBCDbgEnter();
-
- b = isValidRow( nRow );
-
- MYODBCDbgReturn3( "%d", b );
-}
-
-bool MYODBCResServer::isValidRow( qulonglong nRow )
+ This call causes the drivers column data buffers to get refreshed and for any
bound columns (as per ARD)
+ to be refreshed. This action includes data type conversions from the driver
column data buffers to any
+ bound columns.
+
+ \return SQLRETURN
+
+ \sa setRow
+ getRow
+ getRows
+ doNext
+ doPrev
+ doFirst
+ doLast
+ doSkip
+*/
+SQLRETURN MYODBCResServer::doRefresh()
{
- SQLRETURN nReturn;
- qulonglong nRows;
-
- MYODBCDbgEnter();
-
- nReturn = getRows( &nRows );
- if ( !SQL_SUCCEEDED( nReturn ) )
- MYODBCDbgReturn3( "%d", false );
-
- MYODBCDbgReturn3( "%d", ( nRow > 0 && nRow <= nRows ) );
-}
-
-doRefreshRowData()
-{
uint nOffset = 0;
int nResult;
@@ -541,49 +688,68 @@
}
}
-SQLRETURN MYODBCResServer::doInitBindCol( MYODBC_BIND_COL *pbind, uint nColumn,
SQLSMALLINT nTargetType, SQLPOINTER pTarget, SQLINTEGER nTargetSize, SQLINTEGER
*pnStrLenInd )
-{
-}
+/*!
+ \brief Informs called whether or not the current row is a valid row.
-SQLRETURN MYODBCResServer::doFiniBindCol( MYODBC_BIND_COL *pbind )
+ The current row is either valid or position at 0 (invalid). When the current
row is positioned
+ at 0; a doNext will do same as a doFirst while a doPrev will do same as a
doLast.
+
+ \return bool
+
+ \sa getRow
+ getRows
+*/
+bool MYODBCResServer::isValidRow()
{
-}
+ bool b;
-SQLRETURN MYODBCResServer::getData( MYODBC_BIND_COL *pbind )
-{
- /* bookmark */
- if ( pbind->nColumn == 0 )
- {
- /* nothing special to do here as fetch will have updated the bookmark for us */
- MYSQL_ROW_OFFSET n = mysql_stmt_row_tell();
- pbind->bind.buffer = &n;
- }
- else
- {
- mysql_stmt_fetch_column( pstm, &pbind->bind, pbind->nColumn, 0 );
- }
+ MYODBCDbgEnter();
- doConvert( pbind );
+ b = isValidRow( nRow );
+
+ MYODBCDbgReturn3( "%d", b );
}
-SQLRETURN MYODBCResServer::doBind( MYSQL_BIND *pbind, uint nColumn )
+/*!
+ \brief Informs called whether or not the provided row is a valid row.
+
+ This is used to validate a row position before requesting it become current
and
+ to support isValidRow().
+
+ \param nRow Row to be checked.
+
+ \return bool
+
+ \sa getRow
+ getRows
+*/
+bool MYODBCResServer::isValidRow( qulonglong nRow )
{
+ SQLRETURN nReturn;
+ qulonglong nRows;
+
MYODBCDbgEnter();
- MYODBCDesRec *pdesrec = getImpRowDesc()->getRec( nColumn );
+ nReturn = getRows( &nRows );
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn3( "%d", false );
- if ( !pdesrec )
- MYODBCDbgReturn( getDia()->doAppend( MYODBC_DIA_HY000, 0, "Invalid column
requested." ) );
+ MYODBCDbgReturn3( "%d", ( nRow > 0 && nRow <= nRows ) );
+}
- pbind.buffer_type = pField->type;
- pbind.buffer_length = pField->max_length + 1;
+/*!
+ \brief Loads result-set meta data.
- /* we could use a data ptr if column is bound by app */
- pbind.buffer = MYODBCC::getMem( pField->max_length + 1 );
+ This is called (by doPrepare) after a statement is prepared and is loaded
into
+ the IRD.
- MYODBCDbgReturn( SQL_SUCCESS );
-}
+ Also during this process a set of MYSQL_BIND structures (on for each
result-set column)
+ is created - these are used during a doRefresh.
+ \return SQLRETURN
+
+ \sa doPrepare
+*/
SQLRETURN MYODBCResServer::doLoadMetaData()
{
MYSQL_RES *pMetaData;
Added: MYODBCRes/include/MYODBCResClient.h
===================================================================
--- MYODBCRes/include/MYODBCResClient.h 2006-02-13 17:22:45 UTC (rev 56)
+++ MYODBCRes/include/MYODBCResClient.h 2006-02-13 19:38:05 UTC (rev 57)
@@ -0,0 +1,47 @@
+#ifndef MYODBC_RES_CLIENT_H
+#define MYODBC_RES_CLIENT_H
+
+#include "MYODBCRes.h"
+
+class MYODBCResClient : public MYODBCRes
+{
+public:
+ MYODBCResClient( MYODBCAttStatement *patt, MYSQL *pmysql );
+ ~MYODBCResClient();
+
+ SQLRETURN setData( uint nColumn, const QVariant &variantData );
+ SQLRETURN setRow( qulonglong nRow );
+
+ SQLRETURN getColumns( uint *pnColumns );
+ SQLRETURN getData( uint nColumn, QVariant &variantData );
+ SQLRETURN getRow( qulonglong *pnRow );
+ SQLRETURN getRows( qulonglong *pnRows );
+
+ SQLRETURN doAppend( int nToAppend = 1 );
+ SQLRETURN doClear();
+ SQLRETURN doDelete();
+ SQLRETURN doExecute();
+ SQLRETURN doFirst();
+ SQLRETURN doInsert();
+ SQLRETURN doLast();
+ SQLRETURN doNext();
+ SQLRETURN doPrepare( const QString &stringStatement );
+ SQLRETURN doPrev();
+ SQLRETURN doSkip( qlonglong nRows );
+
+ bool isValidRow();
+ bool isValidRow( qulonglong nRow );
+
+protected:
+ MYSQL_STMT * pstm; /* MySQL prepared statement
*/
+ qulonglong nRow;
+ QString stringStatement; /* SQL statement as provided to doPrepare()
*/
+
+ SQLRETURN doLoadMetaData(); /* load resultset meta data (IRD)
*/
+ SQLRETURN doLoadMetaDataField( unsigned int nField, MYSQL_FIELD *pField ); /* load
resultset column meta data (IRD) */
+ void doInit();
+ void doFini();
+};
+
+#endif
+
Modified: MYODBCRes/include/MYODBCResServer.h
===================================================================
--- MYODBCRes/include/MYODBCResServer.h 2006-02-13 17:22:45 UTC (rev 56)
+++ MYODBCRes/include/MYODBCResServer.h 2006-02-13 19:38:05 UTC (rev 57)
@@ -48,6 +48,7 @@
SQLRETURN doPrepare( const QString &stringStatement );
SQLRETURN doPrev();
SQLRETURN doSkip( qlonglong nRows );
+ SQLRETURN doRefresh();
bool isValidRow();
bool isValidRow( qulonglong nRow );
| Thread |
|---|
| • Connector/ODBC 5 commit: r57 - in MYODBCRes: MYODBCResLib include | pharvey | 13 Feb |