Modified:
trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp
Log:
more work to flesh out MCommands
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp 2006-07-10 06:31:33 UTC (rev 432)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp 2006-07-10 07:14:15 UTC (rev 433)
@@ -45,8 +45,83 @@
{
MYODBCDbgEnter();
- SQLRETURN nReturn = SQL_SUCCESS;
+ SQLRETURN nReturn = SQL_SUCCESS;
+ QChar cQuote; // the quote char we are trying to close (if any)
+ QChar cSeparater( ';' ); // our command separater (';' is according to
ODBC spec.)
+ QString stringQuotes = "\"'"; // the quote chars we respect
+ QString stringCommand;
+ for ( int nChar = 0; nChar < stringCommands.length(); nChar++ )
+ {
+ QChar cChar = stringCommands.at( nChar );
+ BOOLEAN bLastChar = ( nChar == (stringCommands.length() - 1) );
+
+ /* catch some last char problems */
+ if ( bLastChar && /* we are
on last char */
+ ( !cQuote.isNull() && cQuote != cChar ) || /* last
char is not going to close our quote */
+ ( cQuote.isNull() && stringQuotes.contains( cChar ) ) ) /* last
char is going to open a quote */
+ {
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( tr("unclosed quote near: ") ).arg( stringCommand ) ) );
+ }
+
+ /* catch command separator (including implied after last command) */
+ if ( bLastChar || /* we are on last char
*/
+ ( cQuote.isNull() && cChar == cSeparater ) ) /* command
separater */
+ {
+ if ( cChar != cSeparater )
+ stringCommand += cChar;
+
+ if ( !stringCommand.isEmpty() )
+ {
+ if ( pStatement )
+ {
+ MCommand command( pStatement );
+ SQLRETURN n = command.setCommand( stringCommand );
+ switch ( n )
+ {
+ case SQL_SUCCESS:
+ break;
+ case SQL_SUCCESS_WITH_INFO:
+ nReturn = n;
+ break;
+ default:
+ nReturn = n;
+ MYODBCDbgReturn( nReturn );
+ }
+ append( command );
+ }
+ else
+ {
+ MCommand command( pConnection );
+ SQLRETURN n = command.setCommand( stringCommand );
+ switch ( n )
+ {
+ case SQL_SUCCESS:
+ break;
+ case SQL_SUCCESS_WITH_INFO:
+ nReturn = n;
+ break;
+ default:
+ nReturn = n;
+ MYODBCDbgReturn( nReturn );
+ }
+ append( command );
+ }
+ stringCommand.clear();
+ }
+ continue;
+ }
+
+ /* quote opening */
+ if ( cQuote.isNull() && stringQuotes.contains( cChar ) )
+ cQuote = cChar;
+ /* quote closing */
+ else if ( !cQuote.isNull() && cQuote == cChar )
+ cQuote = '\0';
+
+ stringCommand += cChar;
+ }
+
this->stringCommands = stringCommands;
MYODBCDbgReturn( nReturn );
| Thread |
|---|
| • Connector/ODBC 5 commit: r433 - trunk/MYSQLPlus/MYSQLPlusLib | pharvey | 10 Jul |