Modified:
trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp
trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.h
trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:
more work on SQLSpecialColumns - about to take a detour to add a bunch of getInfo*()
methods to MConnection.
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp 2006-06-26 21:24:12 UTC (rev 397)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp 2006-06-26 21:55:08 UTC (rev 398)
@@ -687,6 +687,59 @@
MYODBCDbgReturn( nReturn );
}
+SQLRETURN MResultPlus::doSpecialColumns( const QString &stringCatalog, const QString
&stringSchema, const QString &stringTable, SQLSMALLINT nScope, SQLSMALLINT
nNullable )
+{
+ MYODBCDbgEnter();
+
+ SQLRETURN nReturn;
+
+ /* create empty resultset */
+ MDescriptor *pDescriptor;
+
+ doClear();
+ getDiagnostic()->setRowCount( 0 );
+
+ pDescriptor = getImpRowDesc();
+ pDescriptor->doAppend( SQL_SMALLINT, "SCOPE", SQL_NULLABLE );
+ pDescriptor->doAppend( SQL_VARCHAR, "COLUMN_NAME", SQL_NO_NULLS );
+ pDescriptor->doAppend( SQL_SMALLINT, "DATA_TYPE", SQL_NO_NULLS );
+ pDescriptor->doAppend( SQL_VARCHAR, "TYPE_NAME", SQL_NO_NULLS );
+ pDescriptor->doAppend( SQL_INTEGER, "COLUMN_SIZE", SQL_NULLABLE );
+ pDescriptor->doAppend( SQL_INTEGER, "BUFFER_LENGTH", SQL_NULLABLE );
+ pDescriptor->doAppend( SQL_SMALLINT, "DECIMAL_DIGITS", SQL_NULLABLE );
+ pDescriptor->doAppend( SQL_SMALLINT, "PSEUDO_COLUMN", SQL_NULLABLE );
+
+ /* do it */
+// nReturn = doAppendSpecialColumnsCatalogs( stringCatalog, stringSchema, stringTable,
stringColumn );
+
+ /*!
+ \internal ODBC RULE
+
+ When SQLExecute, SQLExecDirect, SQLBulkOperations, SQLSetPos, or SQLMoreResults
is called, the SQL_DIAG_ROW_COUNT
+ field of the diagnostic data structure is set to the row count, and the row count
is cached in an implementation-dependent
+ way. SQLRowCount returns the cached row count value. The cached row count value
is valid until the statement handle is set
+ back to the prepared or allocated state, the statement is reexecuted, or
SQLCloseCursor is called. Note that if a function
+ has been called since the SQL_DIAG_ROW_COUNT field was set, the value returned by
SQLRowCount might be different from the
+ value in the SQL_DIAG_ROW_COUNT field because the SQL_DIAG_ROW_COUNT field is
reset to 0 by any function call.
+
+ \internal MYODBC RULE
+
+ Wet set SQL_DIAG_ROW_COUNT when any result set is requested - for example we also
set SQL_DIAG_ROW_COUNT for catalog
+ functions.
+ */
+ qulonglong nRows = -1;
+ if ( !SQL_SUCCEEDED( getRows( &nRows ) ) )
+ getDiagnostic()->setRowCount( -1 );
+ else
+ getDiagnostic()->setRowCount( nRows );
+
+ /* we should be at last record so next will make us eof and a subsequent next will be
first record */
+ setState( STATE_EXECUTED );
+ doNext();
+
+ MYODBCDbgReturn( nReturn );
+}
+
BOOLEAN MResultPlus::isValidRow()
{
BOOLEAN b;
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.h
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.h 2006-06-26 21:24:12 UTC (rev 397)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.h 2006-06-26 21:55:08 UTC (rev 398)
@@ -70,8 +70,9 @@
SQLRETURN doSkip( qlonglong nRows );
SQLRETURN doCommit();
- SQLRETURN doTables( const QString &stringCatalogName, const QString
&stringSchemaName, const QString &stringTableName, const QString
&stringTableType );
- SQLRETURN doColumns( const QString &stringCatalogName, const QString
&stringSchemaName, const QString &stringTableName, const QString
&stringColumn );
+ SQLRETURN doTables( const QString &stringCatalog, const QString
&stringSchema, const QString &stringTable, const QString &stringTableType );
+ SQLRETURN doColumns( const QString &stringCatalog, const QString
&stringSchema, const QString &stringTable, const QString &stringColumn );
+ SQLRETURN doSpecialColumns( const QString &stringCatalog, const QString
&stringSchema, const QString &stringTable, SQLSMALLINT nScope, SQLSMALLINT
nNullable );
/* isers */
BOOLEAN isValidRow();
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-06-26 21:24:12 UTC (rev 397)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-06-26 21:55:08 UTC (rev 398)
@@ -1951,18 +1951,27 @@
/*!
\internal ODBC RULE
- A schema was specified, and the driver or data source does not support
- schemas.
+ A catalog was specified, and the driver or data source does not support catalogs.
\internal MYODBC RULE
- We do not support schemas so the only valid values are; NULL, SQL_ALL_SCHEMAS,
- and "" - with some additional restrictions.
+ We can continue if value is; NULL, SQL_ALL_CATALOGS, or "".
*/
- if ( !stringSchema.isEmpty() && stringSchema != SQL_ALL_SCHEMAS )
+ if ( getConnection()->getInfoCatalogUsage() == 0 &&
!stringCatalog.isEmpty() && stringCatalog != SQL_ALL_CATALOGS )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
+ /*!
+ \internal ODBC RULE
+ A schema was specified, and the driver or data source does not support schema.
+
+ \internal MYODBC RULE
+
+ We can continue if value is; NULL, SQL_ALL_SCHEMAS, or "".
+ */
+ if ( getConnection()->getInfoSchemaUsage() == 0 && !stringSchema.isEmpty()
&& stringSchema != SQL_ALL_SCHEMAS )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
+
/*!
\internal MYODBC RULE
@@ -3207,41 +3216,89 @@
}
/*!
+ \internal ODBC RULE
+
+ The TableName argument was a null pointer.
+ */
+ if ( !psTableName )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY009 ) );
+
+ /*!
+ \internal ODBC RULE
+
+ The SQL_ATTR_METADATA_ID statement attribute was set to SQL_TRUE, the CatalogName
+ argument was a null pointer, and the SQL_CATALOG_NAME InfoType returns that
catalog
+ names are supported.
+ */
+ if ( getMetadataID() == SQL_TRUE && !psCatalogName &&
getConnection()->getInfoCatalogName() == "Y" )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY009 ) );
+
+
+ /* do it */
+ QString stringCatalog;
+ QString stringSchema;
+ QString stringTable;
+
+ if ( psCatalogName && nLength1 != 0 )
+ stringCatalog = QString::fromUtf16( psCatalogName, ( nLength1 == SQL_NTS ? -1 :
nLength1 ) );
+ if ( psSchemaName && nLength2 != 0 )
+ stringSchema = QString::fromUtf16( psSchemaName, ( nLength2 == SQL_NTS ? -1 :
nLength2 ) );
+ if ( psTableName && nLength3 != 0 )
+ stringTable = QString::fromUtf16( psTableName, ( nLength3 == SQL_NTS ? -1 :
nLength3 ) );
+
+ /*!
\internal ODBC RULE
A catalog was specified, and the driver or data source does not support catalogs.
+
+ \internal MYODBC RULE
+
+ We can continue if value is; NULL, SQL_ALL_CATALOGS, or "".
*/
- if ( psCatalogName && getConnection()->getInfoCatalogUsage() == 0 )
+ if ( getConnection()->getInfoCatalogUsage() == 0 &&
!stringCatalog.isEmpty() && stringCatalog != SQL_ALL_CATALOGS )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
/*!
\internal ODBC RULE
A schema was specified, and the driver or data source does not support schema.
+
+ \internal MYODBC RULE
+
+ We can continue if value is; NULL, SQL_ALL_SCHEMAS, or "".
*/
- if ( psSchemaName && getConnection()->getInfoSchemaUsage() == 0 )
+ if ( getConnection()->getInfoSchemaUsage() == 0 && !stringSchema.isEmpty()
&& stringSchema != SQL_ALL_SCHEMAS )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
+
/*!
- \internal ODBC RULE
+ \internal MYODBC RULE
- The TableName argument was a null pointer.
+ We undo any prepare - no worries.
*/
- if ( !psTableName )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY009 ) );
+ SQLRETURN nReturn;
+ if ( getState() > STATE_S1 )
+ {
+ nReturn = doStateRollBack( STATE_S1 );
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( nReturn );
+ }
- /*!
- \internal ODBC RULE
+ /* generate result */
+ MResultPlus *pResult = new MResultPlus( this );
- The SQL_ATTR_METADATA_ID statement attribute was set to SQL_TRUE, the CatalogName
- argument was a null pointer, and the SQL_CATALOG_NAME InfoType returns that
catalog
- names are supported.
- */
- if ( getMetadataID() == SQL_TRUE && !psCatalogName &&
getConnection()->getInfoCatalogName() == "Y" )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY009 ) );
+ nReturn = pResult->doSpecialColumns( nIdentifierType, stringCatalog, stringSchema,
stringTable, nScope, nNullable );
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ {
+ delete pResult;
+ MYODBCDbgReturn( nReturn );
+ }
+ setImplicitPrepare( true );
+ this->pResult = pResult;
+ setState( STATE_S5 );
- MYODBCDbgReturn( SQL_SUCCESS );
+ MYODBCDbgReturn( nReturn );
}
SQLRETURN MStatement::doStatistics( SQLWCHAR *psCatalogName, SQLSMALLINT nNameLength1,
SQLWCHAR *psSchemaName, SQLSMALLINT nNameLength2, SQLWCHAR *psTableName, SQLSMALLINT
nNameLength3, SQLUSMALLINT nUnique, SQLUSMALLINT nReserved )
@@ -3370,15 +3427,25 @@
/*!
\internal ODBC RULE
- A schema was specified, and the driver or data source does not support
- schemas.
+ A catalog was specified, and the driver or data source does not support catalogs.
\internal MYODBC RULE
+
+ We can continue if value is; NULL, SQL_ALL_CATALOGS, or "".
+ */
+ if ( getConnection()->getInfoCatalogUsage() == 0 &&
!stringCatalog.isEmpty() && stringCatalog != SQL_ALL_CATALOGS )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
- We do not support schemas so the only valid values are; NULL, SQL_ALL_SCHEMAS,
- and "" - with some additional restrictions.
+ /*!
+ \internal ODBC RULE
+
+ A schema was specified, and the driver or data source does not support schema.
+
+ \internal MYODBC RULE
+
+ We can continue if value is; NULL, SQL_ALL_SCHEMAS, or "".
*/
- if ( !stringSchema.isEmpty() && stringSchema != SQL_ALL_SCHEMAS )
+ if ( getConnection()->getInfoSchemaUsage() == 0 && !stringSchema.isEmpty()
&& stringSchema != SQL_ALL_SCHEMAS )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
/*!
| Thread |
|---|
| • Connector/ODBC 5 commit: r398 - trunk/MYSQLPlus/MYSQLPlusLib | pharvey | 26 Jun |