Modified:
trunk/MYODBCDriver/MYODBCDriverLib/SQLGetFunctions.cpp
trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp
trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:
- start add SQLTablePrivileges feature
Modified: trunk/MYODBCDriver/MYODBCDriverLib/SQLGetFunctions.cpp
===================================================================
--- trunk/MYODBCDriver/MYODBCDriverLib/SQLGetFunctions.cpp 2006-08-10 13:46:58 UTC (rev
480)
+++ trunk/MYODBCDriver/MYODBCDriverLib/SQLGetFunctions.cpp 2006-08-10 14:15:52 UTC (rev
481)
@@ -115,7 +115,7 @@
SQL_API_SQLPROCEDURES,
/* SQL_API_SQLSETPOS, */
/* SQL_API_SQLSETSCROLLOPTIONS, Dep */
-/* SQL_API_SQLTABLEPRIVILEGES */
+ SQL_API_SQLTABLEPRIVILEGES
};
/*!
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp 2006-08-10 13:46:58 UTC (rev 480)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp 2006-08-10 14:15:52 UTC (rev 481)
@@ -1020,12 +1020,10 @@
MYODBCDbgReturn( nReturn );
}
-SQLRETURN MResultPlus::doProcedures( const QString &stringCatalog, const QString
&stringSchema, const QString &stringProcedure )
+SQLRETURN MResultPlus::doProcedures( const QString &stringCatalog, const QString
&, const QString &stringProcedure )
{
MYODBCDbgEnter();
- SQLRETURN nReturn;
-
/* create empty resultset */
MDescriptor *pDescriptor;
@@ -1054,7 +1052,7 @@
" ROUTINE_COMMENT AS REMARKS,"
" ROUTINE_TYPE AS PROCEDURE_TYPE "
"FROM INFORMATION_SCHEMA.ROUTINES "
- "WHERE ROUTINE_SCHEMA LIKE '" + stringCatalog + "' AND "
+ "WHERE ROUTINE_SCHEMA = '" + stringCatalog + "' AND "
" ROUTINE_NAME LIKE '" + stringProcedure + "' "
"ORDER BY PROCEDURE_CAT, PROCEDURE_NAME";
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-08-10 13:46:58 UTC (rev 480)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-08-10 14:15:52 UTC (rev 481)
@@ -3512,6 +3512,7 @@
*/
pDiagnostic->doClear();
+
MYODBCDbgReturn( SQL_ERROR );
}
@@ -4367,7 +4368,7 @@
MYODBCDbgReturn( nReturn );
}
-SQLRETURN MStatement::doTablePrivileges( SQLWCHAR *psCatalogName, SQLSMALLINT
nNameLength1, SQLWCHAR *psSchemaName, SQLSMALLINT nNameLength2, SQLWCHAR *psTableName,
SQLSMALLINT nNameLength3 )
+SQLRETURN MStatement::doTablePrivileges( SQLWCHAR *psCatalog, SQLSMALLINT nLength1,
SQLWCHAR *psSchema, SQLSMALLINT nLength2, SQLWCHAR *psTable, SQLSMALLINT nLength3 )
{
MYODBCDbgEnter();
@@ -4378,7 +4379,131 @@
*/
pDiagnostic->doClear();
- MYODBCDbgReturn( SQL_ERROR );
+ /*!
+ \internal ODBC RULE (DM)
+
+ A cursor was open on the StatementHandle, and SQLFetch or
+ SQLFetchScroll had been called.
+ */
+ if ( getState() == STATE_S6 )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_24000 ) );
+
+ /*!
+ \internal ODBC RULE (DM)
+
+ A cursor was open on the StatementHandle, but SQLFetch or SQLFetchScroll
+ had not been called.
+ */
+ if ( getState() == STATE_S5 )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_24000 ) );
+
+ /*!
+ \internal ODBC RULE (DM)
+
+ An asynchronously executing function was called for the
+ StatementHandle and was still executing when this function
+ was called.
+
+ \note
+
+ DM should handle this but check here in case where app is linked
+ directly to driver.
+ */
+ if ( isAsyncInProgress() )
+ MYODBCDbgReturn( getDiagnostic()->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( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
+
+ /*!
+ \internal ODBC RULE (DM)
+
+ The value of one of the length arguments was less than 0 but
+ not equal to SQL_NTS.
+ */
+ if ( nLength1 < 0 && nLength1 != SQL_NTS )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
+ if ( nLength2 < 0 && nLength2 != SQL_NTS )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
+ if ( nLength3 < 0 && nLength3 != SQL_NTS )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
+
+ /*!
+ \internal ODBC RULE (DM)
+
+ The value of one of the name length arguments exceeded the maximum length
+ value for the corresponding name.
+ */
+ if ( nLength1 > getConnection()->getInfoMaxCatalogNameLen() )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
+ if ( nLength2 > getConnection()->getInfoMaxSchemaNameLen() )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
+ if ( nLength3 > getConnection()->getInfoMaxTableNameLen() )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
+
+ /* get our strings into a QString */
+ QString stringCatalog;
+ QString stringSchema;
+ QString stringTable;
+
+ if ( psCatalog && nLength1 != 0 )
+ stringCatalog = QString::fromUtf16( psCatalog, ( nLength1 == SQL_NTS ? -1 :
nLength1 ) );
+ if ( psSchema && nLength2 != 0 )
+ stringSchema = QString::fromUtf16( psSchema, ( nLength2 == SQL_NTS ? -1 :
nLength2 ) );
+ if ( psTable && nLength3 != 0 )
+ stringTable = QString::fromUtf16( psTable, ( nLength3 == SQL_NTS ? -1 : nLength3
) );
+
+ /*!
+ \internal ODBC RULE
+
+ A catalog was specified, and the driver or data source does not support catalogs.
+ */
+ if ( stringCatalog.isNull() )
+ stringCatalog = "";
+ if ( getConnection()->getInfoCatalogUsage() == 0 &&
!stringCatalog.isEmpty() )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
+
+ /*!
+ \internal ODBC RULE
+
+ A schema was specified, and the driver or data source does not support schema.
+ */
+ if ( stringSchema.isNull() )
+ stringSchema = "";
+ if ( getConnection()->getInfoSchemaUsage() == 0 && !stringSchema.isEmpty()
&& stringSchema != SQL_ALL_SCHEMAS )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
+
+ /* silently roll-back state as needed */
+ SQLRETURN nReturn;
+ if ( isPrepared() )
+ {
+ nReturn = doStateRollBack( STATE_S1 );
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( nReturn );
+ }
+
+ /* generate result */
+ MResultPlus *pResult = new MResultPlus( this );
+
+ nReturn = pResult->doTablePrivileges( stringCatalog, stringSchema, stringProcedure
);
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ {
+ delete pResult;
+ MYODBCDbgReturn( nReturn );
+ }
+
+ setImplicitPrepare( true );
+ setState( STATE_S5 );
+
+ MYODBCDbgReturn( nReturn );
}
SQLRETURN MStatement::doTables( SQLWCHAR *psCatalog, SQLSMALLINT nLength1, SQLWCHAR
*psSchema, SQLSMALLINT nLength2, SQLWCHAR *psTable, SQLSMALLINT nLength3, SQLWCHAR
*psTableType, SQLSMALLINT nLength4 )
| Thread |
|---|
| • Connector/ODBC 5 commit: r481 - in trunk: MYODBCDriver/MYODBCDriverLib MYSQLPlus/MYSQLPlusLib | pharvey | 10 Aug |