Modified:
MYODBCShell/MYODBCShell.cpp
MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp
MYSQLPlus/MYSQLPlusLib/MResultPlus.h
MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:
Modified: MYODBCShell/MYODBCShell.cpp
===================================================================
--- MYODBCShell/MYODBCShell.cpp 2006-06-01 20:30:38 UTC (rev 305)
+++ MYODBCShell/MYODBCShell.cpp 2006-06-01 22:53:51 UTC (rev 306)
@@ -329,6 +329,7 @@
{
QString stringTable;
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
// init
if ( !hDbc )
{
@@ -372,8 +373,10 @@
// process results (if any)
doResults();
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
// fini
SQLFreeHandle( SQL_HANDLE_STMT, hStm );
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
hStm = NULL;
return true;
@@ -528,6 +531,7 @@
SQLSMALLINT nCols;
SQLINTEGER nRows = 0;
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
if ( !hStm )
{
*pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
@@ -578,7 +582,9 @@
switch ( nResultFormat )
{
case RESULT_FORMAT_NORMAL:
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
doFooterNormal( nRows );
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
break;
case RESULT_FORMAT_HTML:
doFooterHTMLTable();
@@ -587,6 +593,7 @@
break;
}
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
return true;
}
@@ -638,22 +645,28 @@
if ( !SQL_SUCCEEDED( SQLNumResultCols( hStm, &nColumns ) ) )
nColumns = -1;
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
nReturn = SQLFetch( hStm );
while ( SQL_SUCCEEDED( nReturn ) )
{
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
for ( nColumn = 1; nColumn <= nColumns; nColumn++ )
{
+printf( "[PAH][%s][%d] nColumn = %d\n", __FILE__, __LINE__, nColumn );
nReturn = SQLGetData( hStm, nColumn, SQL_C_WCHAR, (SQLPOINTER)sColumnValue,
sizeof(sColumnValue), &nIndicator );
if ( SQL_SUCCEEDED( nReturn ) && nIndicator != SQL_NULL_DATA )
{
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
*pstreamStdOut << stringFormatBuffer.sprintf( "| %-*.*ls",
vectorOptimalDisplayWidths[nColumn], vectorOptimalDisplayWidths[nColumn], sColumnValue );
}
else if ( nReturn == SQL_ERROR )
{
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
break;
}
else
{
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
*pstreamStdOut << stringFormatBuffer.sprintf( "| %-*s",
vectorOptimalDisplayWidths[nColumn], "" );
}
@@ -679,14 +692,18 @@
*pstreamStdOut << stringSepLine << endl;
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
if ( SQLRowCount( hStm, &nRowsAffected ) != SQL_SUCCESS )
{
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
if ( bVerbose ) doErrors( hEnv, hDbc, hStm );
}
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
*pstreamStdOut << nRowsAffected << " rows affected" << endl;
*pstreamStdOut << nRows << " rows fetched" << endl;
+printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
return true;
}
Modified: MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp 2006-06-01 20:30:38 UTC (rev 305)
+++ MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp 2006-06-01 22:53:51 UTC (rev 306)
@@ -23,6 +23,7 @@
setObjectName( "MResultPlus" );
nRow = 0;
+ stringlistTableTypesPossible << "SYSTEM TABLE" << "TABLE";
setStatementType( STATEMENT_TYPE_PLUS );
setState( STATE_INITIALIZED );
@@ -520,7 +521,7 @@
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010, 0,
tr("Resultset is read-only.") ) );
}
-SQLRETURN MResultPlus::doTables( const QString &stringCatalogName, const QString
&stringSchemaName, const QString &stringTableName, const QString
&stringTableType )
+SQLRETURN MResultPlus::doTables( const QString &stringCatalog, const QString
&stringSchema, const QString &stringTable, const QString &stringTableType )
{
MYODBCDbgEnter();
@@ -547,9 +548,9 @@
empty strings, the result set contains a list of valid table types for the data
source.
(All columns except the TABLE_TYPE column contain NULLs.)
*/
- if ( stringCatalogName == "" &&
- stringSchemaName == "" &&
- stringTableName == "" &&
+ if ( ( stringCatalog.isEmpty() && !stringCatalog.isNull() ) &&
+ ( stringSchema.isEmpty() && !stringSchema.isNull() ) &&
+ ( stringTable.isEmpty() && !stringTable.isNull() ) &&
stringTableType == SQL_ALL_TABLE_TYPES )
{
nReturn = doAppendTablesTableTypes();
@@ -561,9 +562,9 @@
set contains a list of valid schemas for the data source. (All columns except the
TABLE_SCHEM
column contain NULLs.)
*/
- else if ( stringCatalogName == "" &&
- stringSchemaName == SQL_ALL_SCHEMAS &&
- stringTableName == "" )
+ else if ( ( stringCatalog.isEmpty() && !stringCatalog.isNull() ) &&
+ stringSchema == SQL_ALL_SCHEMAS &&
+ ( stringTable.isEmpty() && !stringTable.isNull() ) )
{
nReturn = doAppendTablesSchemas();
}
@@ -574,9 +575,9 @@
contains a list of valid catalogs for the data source. (All columns except the
TABLE_CAT column
contain NULLs.)
*/
- else if ( stringCatalogName == SQL_ALL_CATALOGS &&
- stringSchemaName == "" &&
- stringTableName == "" )
+ else if ( stringCatalog == SQL_ALL_CATALOGS &&
+ ( stringSchema.isEmpty() && !stringSchema.isNull() ) &&
+ ( stringTable.isEmpty() && !stringTable.isNull() ) )
{
nReturn = doAppendTablesCatalogs();
}
@@ -588,7 +589,7 @@
*/
else
{
- nReturn = doAppendTablesTableTypes( stringCatalogName, stringSchemaName,
stringTableName, stringTableType );
+ nReturn = doAppendTablesTableTypes( stringCatalog, stringSchema, stringTable,
stringTableType );
}
/*!
@@ -694,12 +695,9 @@
MYODBCDbgEnter();
QStringList stringlistTableTypes;
- QStringList stringlistTableTypesPossible;
- stringlistTableTypesPossible << "SYSTEM TABLE" << "TABLE" <<
"VIEW";
-
/* empty string... */
- if ( stringFilter.isEmpty() )
+ if ( stringFilter.isEmpty() && !stringFilter.isNull() )
{
MYODBCDbgReturn3( "%p", stringlistTableTypes );
}
@@ -767,7 +765,7 @@
- return a "" when wild card is NULL, "", or "%"
- return nothing otherwise
*/
- if ( stringSchemaFilter != SQL_ALL_SCHEMAS )
+ if ( stringSchemaFilter.isEmpty() || stringSchemaFilter == SQL_ALL_SCHEMAS )
stringlistSchemas += "";
MYODBCDbgReturn3( "%p", stringlistSchemas );
@@ -1257,7 +1255,7 @@
MYODBCDbgReturn( nReturn );
}
-SQLRETURN MResultPlus::doAppendTablesSchemas( const QString &stringCatalogName, const
QString &stringSchemaFilter, const QString &stringTableFilter, const QString
&stringTableType )
+SQLRETURN MResultPlus::doAppendTablesSchemas( const QString &stringCatalog, const
QString &stringSchemaFilter, const QString &stringTableFilter, const QString
&stringTableType )
{
MYODBCDbgEnter();
@@ -1269,7 +1267,7 @@
However, a zero-length search pattern zero */
- QStringList stringlistSchemas = getSchemas( stringCatalogName, "%" );
+ QStringList stringlistSchemas = getSchemas( stringCatalog, "%" );
BOOLEAN bWildCard = ( getStatement()->getMetadataID() == SQL_FALSE );
QString stringWildCard = stringSchemaFilter;
@@ -1292,7 +1290,7 @@
if ( bMatch )
{
- nReturn = doAppendTablesSchemas( stringCatalogName, stringlistSchemas[n],
stringTableFilter, stringTableType );
+ nReturn = doAppendTablesTables( stringCatalog, stringlistSchemas[n],
stringTableFilter, stringTableType );
if ( !SQL_SUCCEEDED( nReturn ) )
break;
}
@@ -1301,7 +1299,7 @@
MYODBCDbgReturn( nReturn );
}
-SQLRETURN MResultPlus::doAppendTablesTables( const QString &stringCatalogName, const
QString &stringSchemaName, const QString &stringTableFilter, const QString
&stringTableType )
+SQLRETURN MResultPlus::doAppendTablesTables( const QString &stringCatalog, const
QString &stringSchema, const QString &stringTableFilter, const QString
&stringTableType )
{
MYODBCDbgEnter();
@@ -1313,7 +1311,7 @@
catalog is mysql - we are 'good like that'.
*/
/* handle "SYSTEM TABLE" */
- if ( stringTableType == "SYSTEM TABLE" && stringCatalogName != "mysql" )
+ if ( stringTableType == "SYSTEM TABLE" && stringCatalog != "mysql" )
MYODBCDbgReturn( SQL_SUCCESS );
/*!
@@ -1330,7 +1328,7 @@
will result in no matchs here.
*/
/* handle "TABLE" */
- if ( stringTableType != "TABLE" || stringTableType != "SYSTEM TABLE" )
+ if ( !stringlistTableTypesPossible.contains( stringTableType ) )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
SQLRETURN nReturn = SQL_SUCCESS;
@@ -1341,7 +1339,7 @@
Support VIEW etc
*/
- QStringList stringlistTables = getTables( stringCatalogName, stringSchemaName, "%" );
+ QStringList stringlistTables = getTables( stringCatalog, stringSchema, "%" );
BOOLEAN bWildCard = ( getStatement()->getMetadataID() == SQL_FALSE );
QString stringWildCard = stringTableFilter;
@@ -1363,7 +1361,7 @@
bMatch = stringlistTables[n] == stringTableFilter;
if ( bMatch )
- doAppendTables( stringCatalogName, stringSchemaName, stringlistTables[n],
stringTableType );
+ doAppendTables( stringCatalog, stringSchema, stringlistTables[n],
stringTableType );
}
MYODBCDbgReturn( nReturn );
Modified: MYSQLPlus/MYSQLPlusLib/MResultPlus.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultPlus.h 2006-06-01 20:30:38 UTC (rev 305)
+++ MYSQLPlus/MYSQLPlusLib/MResultPlus.h 2006-06-01 22:53:51 UTC (rev 306)
@@ -90,6 +90,7 @@
#endif
qulonglong nRow; /* 1 -based (0 as BOS/EOS) */
+ QStringList stringlistTableTypesPossible; /*!< supports SQLTables
*/
QStringList getTableTypes( const QString &stringFilter );
QStringList getCatalogs( const QString &stringFilter );
Modified: MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-06-01 20:30:38 UTC (rev 305)
+++ MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-06-01 22:53:51 UTC (rev 306)
@@ -1523,7 +1523,7 @@
Only server-side prepared statements (MResultStmt) can give us meta data on the
resultset
when we are in the prepared state.
*/
- if ( getState() == STATE_S5 && pResult->objectName() != "MResultStmt" )
+ if ( getState() < STATE_S4 && pResult->objectName() != "MResultStmt" )
MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010, 0, tr("column
attributes unknown at this time") ) );
/*!
@@ -2078,7 +2078,7 @@
but we do NOT do that because it provides inconsistent behaviour. The app should
use
server side prepared if col count needed before execute.
*/
- if ( getState() == STATE_S5 && pResult->objectName() != "MResultStmt" )
+ if ( getState() < STATE_S4 && pResult->objectName() != "MResultStmt" )
MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010, 0, tr("column
count unknown at this time") ) );
/*!
@@ -2095,7 +2095,7 @@
The number of columns returned by SQLNumResultCols is the same value as the
SQL_DESC_COUNT field
of the IRD.
*/
- *pnColumnCount = getImpRowDesc()->getCount();
+ *pnColumnCount = max( getImpRowDesc()->getCount() - 1, 0 );
MYODBCDbgReturn( SQL_SUCCESS );
}
@@ -2454,7 +2454,7 @@
MYODBCDbgReturn( SQL_ERROR );
}
-SQLRETURN MStatement::doTables( SQLWCHAR *psCatalogName, SQLSMALLINT nNameLength1,
SQLWCHAR *psSchemaName, SQLSMALLINT nNameLength2, SQLWCHAR *psTableName, SQLSMALLINT
nNameLength3, SQLWCHAR *psTableType, SQLSMALLINT nNameLength4 )
+SQLRETURN MStatement::doTables( SQLWCHAR *psCatalog, SQLSMALLINT nLength1, SQLWCHAR
*psSchema, SQLSMALLINT nLength2, SQLWCHAR *psTable, SQLSMALLINT nLength3, SQLWCHAR
*psTableType, SQLSMALLINT nLength4 )
{
MYODBCDbgEnter();
@@ -2516,18 +2516,27 @@
not equal to SQL_NTS or the value of one of the name length arguments
exceeded the maximum length value for the corresponding name.
*/
- if ( (nNameLength1 < 0 && nNameLength1 != SQL_NTS) || nNameLength1 >
SQL_MAX_CATALOG_NAME_LEN )
+ if ( (nLength1 < 0 && nLength1 != SQL_NTS) || nLength1 >
SQL_MAX_CATALOG_NAME_LEN )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
- if ( (nNameLength2 < 0 && nNameLength2 != SQL_NTS) || nNameLength2 >
SQL_MAX_SCHEMA_NAME_LEN )
+ if ( (nLength2 < 0 && nLength2 != SQL_NTS) || nLength2 >
SQL_MAX_SCHEMA_NAME_LEN )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
- if ( (nNameLength3 < 0 && nNameLength3 != SQL_NTS) || nNameLength3 >
SQL_MAX_TABLE_NAME_LEN )
+ if ( (nLength3 < 0 && nLength3 != SQL_NTS) || nLength3 >
SQL_MAX_TABLE_NAME_LEN )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
- QString stringCatalogName = QString::fromUtf16( psCatalogName, ( nNameLength1 ==
SQL_NTS ? -1 : nNameLength1 ) );
- QString stringSchemaName = QString::fromUtf16( psSchemaName, ( nNameLength2 ==
SQL_NTS ? -1 : nNameLength2 ) );
- QString stringTableName = QString::fromUtf16( psTableName, ( nNameLength3 ==
SQL_NTS ? -1 : nNameLength3 ) );
- QString stringTableType = QString::fromUtf16( psTableType, ( nNameLength4 ==
SQL_NTS ? -1 : nNameLength4 ) );
+ QString stringCatalog;
+ QString stringSchema;
+ QString stringTable;
+ QString stringTableType;
+ 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
) );
+ if ( psTableType && nLength4 != 0 )
+ stringTableType = QString::fromUtf16( psTableType, ( nLength4 == SQL_NTS ? -1 :
nLength4 ) );
+
/*!
\internal ODBC RULE
@@ -2539,7 +2548,7 @@
We do not support schemas so the only valid values are; NULL, SQL_ALL_SCHEMAS,
and "" - with some additional restrictions.
*/
- if ( !stringSchemaName.isEmpty() && stringSchemaName != SQL_ALL_SCHEMAS )
+ if ( !stringSchema.isEmpty() && stringSchema != SQL_ALL_SCHEMAS )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 ) );
/*!
@@ -2551,13 +2560,13 @@
The alternative is to return an empty result set.
*/
- if ( stringCatalogName == "" ||
- stringSchemaName == "" ||
- stringTableName == "" )
+ if ( ( stringCatalog.isEmpty() && !stringCatalog.isNull() ) ||
+ ( stringSchema.isEmpty() && !stringSchema.isNull() ) ||
+ ( stringTable.isEmpty() && !stringTable.isNull() ) )
{
- if ( stringCatalogName != "" ||
- stringSchemaName != "" ||
- stringTableName != "" ||
+ if ( !( stringCatalog.isEmpty() && !stringCatalog.isNull() ) ||
+ !( stringSchema.isEmpty() && !stringSchema.isNull() ) ||
+ !( stringTable.isEmpty() && !stringTable.isNull() ) ||
stringTableType != SQL_ALL_TABLE_TYPES )
{
/* Commented out. We return empty result as it is more consistent with other
drivers. - PAH */
@@ -2581,7 +2590,7 @@
/* generate result */
MResultPlus *pResult = new MResultPlus( this );
- nReturn = pResult->doTables( stringCatalogName, stringSchemaName, stringTableName,
stringTableType );
+ nReturn = pResult->doTables( stringCatalog, stringSchema, stringTable,
stringTableType );
if ( !SQL_SUCCEEDED( nReturn ) )
{
delete pResult;
| Thread |
|---|
| • Connector/ODBC 5 commit: r306 - MYODBCShell MYSQLPlus/MYSQLPlusLib | pharvey | 2 Jun |