diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2016-02-21 15:47:30 -0600 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2016-02-27 01:15:30 +0100 |
commit | eae0369d1cfbe2ae18373e33cfaf5be8d85896d0 (patch) | |
tree | 0ad5a688befdf279b5cf6d48acdb03ee362ceabf /src/sql/drivers | |
parent | 2c678d13f2c0d818c2c63a46d449c998732f3a79 (diff) | |
download | tqt3-eae0369d1cfbe2ae18373e33cfaf5be8d85896d0.tar.gz tqt3-eae0369d1cfbe2ae18373e33cfaf5be8d85896d0.zip |
Automated update from Qt3
(cherry picked from commit 3add7b436c617c6a45b72cca11878ee3b648cf33)
Diffstat (limited to 'src/sql/drivers')
-rw-r--r-- | src/sql/drivers/mysql/qsql_mysql.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index aad846243..9d49c962e 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -466,7 +466,7 @@ bool TQMYSQLDriver::open( const TQString& db, if ( isOpen() ) close(); - unsigned int optionFlags = 0; + unsigned int clientOptionFlags = 0; TQStringList raw = TQStringList::split( ';', connOpts ); TQStringList opts; @@ -487,38 +487,44 @@ bool TQMYSQLDriver::open( const TQString& db, opts << tmp; } } - + + if (!(d->mysql = mysql_init((MYSQL*) 0))) { + setLastError( qMakeError( "Unable to connect", TQSqlError::Connection, d ) ); + mysql_close( d->mysql ); + setOpenError( TRUE ); + return FALSE; + } + for ( it = opts.begin(); it != opts.end(); ++it ) { TQString opt( (*it).upper() ); if ( opt == "CLIENT_COMPRESS" ) - optionFlags |= CLIENT_COMPRESS; + clientOptionFlags |= CLIENT_COMPRESS; else if ( opt == "CLIENT_FOUND_ROWS" ) - optionFlags |= CLIENT_FOUND_ROWS; + clientOptionFlags |= CLIENT_FOUND_ROWS; else if ( opt == "CLIENT_IGNORE_SPACE" ) - optionFlags |= CLIENT_IGNORE_SPACE; + clientOptionFlags |= CLIENT_IGNORE_SPACE; else if ( opt == "CLIENT_INTERACTIVE" ) - optionFlags |= CLIENT_INTERACTIVE; + clientOptionFlags |= CLIENT_INTERACTIVE; else if ( opt == "CLIENT_NO_SCHEMA" ) - optionFlags |= CLIENT_NO_SCHEMA; + clientOptionFlags |= CLIENT_NO_SCHEMA; else if ( opt == "CLIENT_ODBC" ) - optionFlags |= CLIENT_ODBC; + clientOptionFlags |= CLIENT_ODBC; else if ( opt == "CLIENT_SSL" ) - optionFlags |= CLIENT_SSL; + clientOptionFlags |= CLIENT_SSL; else if ( opt == "MYSQL_OPT_RECONNECT" ) - optionFlags |= MYSQL_OPT_RECONNECT; + mysql_options(d->mysql, MYSQL_OPT_RECONNECT, NULL); else tqWarning( "TQMYSQLDriver::open: Unknown connect option '%s'", (*it).latin1() ); } - if ( (d->mysql = mysql_init((MYSQL*) 0)) && - mysql_real_connect( d->mysql, + if ( mysql_real_connect( d->mysql, host, user, password, db.isNull() ? TQString("") : db, (port > -1) ? port : 0, NULL, - optionFlags ) ) + clientOptionFlags ) ) { if ( !db.isEmpty() && mysql_select_db( d->mysql, db )) { setLastError( qMakeError("Unable open database '" + db + "'", TQSqlError::Connection, d ) ); |