mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-07 11:24:30 +02:00
MySQL fixes/additions/improvements
- fixed GH #187: MySQL: allow access to the underlying connection handle - added GH #186: MySQL: support for MYSQL_SECURE_AUTH - fixed GH #174: MySQL: 4GB allocated when reading any largetext or largeblob field
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "Poco/Data/LOB.h"
|
||||
#include "Poco/Data/StatementImpl.h"
|
||||
#include "Poco/Data/MySQL/Connector.h"
|
||||
#include "Poco/Data/MySQL/Utility.h"
|
||||
#include "Poco/Data/MySQL/MySQLException.h"
|
||||
#include "Poco/Nullable.h"
|
||||
#include "Poco/Data/DataException.h"
|
||||
@@ -49,6 +50,7 @@
|
||||
using namespace Poco::Data;
|
||||
using namespace Poco::Data::Keywords;
|
||||
using Poco::Data::MySQL::ConnectionException;
|
||||
using Poco::Data::MySQL::Utility;
|
||||
using Poco::Data::MySQL::StatementException;
|
||||
using Poco::format;
|
||||
using Poco::NotFoundException;
|
||||
@@ -64,7 +66,7 @@ Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = 0;
|
||||
// Parameters for barebone-test
|
||||
#define MYSQL_USER "root"
|
||||
#define MYSQL_PWD "poco"
|
||||
#define MYSQL_HOST "localhost"
|
||||
#define MYSQL_HOST "192.168.1.25"//"localhost"
|
||||
#define MYSQL_PORT 3306
|
||||
#define MYSQL_DB "test"
|
||||
|
||||
@@ -74,7 +76,9 @@ std::string MySQLTest::_dbConnString = "host=" MYSQL_HOST
|
||||
";user=" MYSQL_USER
|
||||
";password=" MYSQL_PWD
|
||||
";db=" MYSQL_DB
|
||||
";compress=true;auto-reconnect=true";
|
||||
";compress=true"
|
||||
";auto-reconnect=true"
|
||||
";secure-auth=true";
|
||||
|
||||
|
||||
MySQLTest::MySQLTest(const std::string& name):
|
||||
@@ -90,6 +94,15 @@ MySQLTest::~MySQLTest()
|
||||
}
|
||||
|
||||
|
||||
void MySQLTest::dbInfo(Session& session)
|
||||
{
|
||||
|
||||
std::cout << "Server Info: " << Utility::serverInfo(Utility::handle(session)) << std::endl;
|
||||
std::cout << "Server Version: " << Utility::serverVersion(Utility::handle(session)) << std::endl;
|
||||
std::cout << "Host Info: " << Utility::hostInfo(Utility::handle(session)) << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void MySQLTest::testConnectNoDB()
|
||||
{
|
||||
std::string dbConnString = "host=" MYSQL_HOST
|
||||
@@ -100,7 +113,9 @@ void MySQLTest::testConnectNoDB()
|
||||
try
|
||||
{
|
||||
Session session(MySQL::Connector::KEY, dbConnString);
|
||||
std::cout << "Connected to [" << "MySQL" << "] without database. Disconnecting ..." << std::endl;
|
||||
std::cout << "Connected to [" << "MySQL" << "] without database." << std::endl;
|
||||
dbInfo(session);
|
||||
std::cout << "Disconnecting ..." << std::endl;
|
||||
session.close();
|
||||
std::cout << "Disconnected." << std::endl;
|
||||
}
|
||||
@@ -434,6 +449,9 @@ void MySQLTest::testBLOB()
|
||||
{
|
||||
if (!_pSession) fail ("Test not available.");
|
||||
|
||||
recreatePersonBLOBTable();
|
||||
_pExecutor->blob();
|
||||
|
||||
const std::size_t maxFldSize = 65534;
|
||||
_pSession->setProperty("maxFieldSize", Poco::Any(maxFldSize-1));
|
||||
recreatePersonBLOBTable();
|
||||
@@ -852,6 +870,7 @@ CppUnit::Test* MySQLTest::suite()
|
||||
}
|
||||
|
||||
std::cout << "*** Connected to [" << "MySQL" << "] test database." << std::endl;
|
||||
dbInfo(*_pSession);
|
||||
|
||||
_pExecutor = new SQLExecutor("MySQL SQL Executor", _pSession);
|
||||
|
||||
|
@@ -142,6 +142,8 @@ private:
|
||||
void recreateNullableIntTable();
|
||||
void recreateNullableStringTable();
|
||||
|
||||
static void dbInfo(Poco::Data::Session& session);
|
||||
|
||||
static std::string _dbConnString;
|
||||
static Poco::SharedPtr<Poco::Data::Session> _pSession;
|
||||
static Poco::SharedPtr<SQLExecutor> _pExecutor;
|
||||
|
@@ -53,6 +53,7 @@
|
||||
|
||||
#include <mysql.h>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
|
||||
using namespace Poco::Data;
|
||||
@@ -500,8 +501,8 @@ void SQLExecutor::insertSingleBulk()
|
||||
void SQLExecutor::unsignedInts()
|
||||
{
|
||||
std::string funct = "unsignedInts()";
|
||||
unsigned int data = UINT32_MAX;
|
||||
unsigned int ret = 0;
|
||||
Poco::UInt32 data = std::numeric_limits<Poco::UInt32>::max();
|
||||
Poco::UInt32 ret = 0;
|
||||
|
||||
try { *_pSession << "INSERT INTO Strings VALUES (?)", use(data), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
@@ -1362,7 +1363,7 @@ void SQLExecutor::time()
|
||||
}
|
||||
|
||||
|
||||
void SQLExecutor::blob(int bigSize)
|
||||
void SQLExecutor::blob(unsigned int bigSize)
|
||||
{
|
||||
std::string funct = "blob()";
|
||||
std::string lastName("lastname");
|
||||
|
@@ -100,7 +100,7 @@ public:
|
||||
void singleSelect();
|
||||
void emptyDB();
|
||||
|
||||
void blob(int bigSize = 1024);
|
||||
void blob(unsigned int bigSize = ~0);
|
||||
void blobStmt();
|
||||
void dateTime();
|
||||
void date();
|
||||
|
Reference in New Issue
Block a user