mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-08-01 21:51:48 +02:00
Update POCO to 1.11.0
This commit is contained in:
5
vendor/POCO/Data/MySQL/Makefile
vendored
5
vendor/POCO/Data/MySQL/Makefile
vendored
@@ -6,8 +6,9 @@
|
||||
|
||||
include $(POCO_BASE)/build/rules/global
|
||||
|
||||
SYSLIBS += -L/usr/local/lib -L/usr/local/lib$(LIB64SUFFIX)/mysql -L/usr/lib$(LIB64SUFFIX)/mysql -L/usr/mysql/lib$(LIB64SUFFIX) -L/usr/mysql/lib$(LIB64SUFFIX)/mysql -L/usr/local/mysql/lib$(LIB64SUFFIX) -lmysqlclient
|
||||
INCLUDE += -I/usr/local/include/mysql/ -I/usr/include/mysql/ -I/usr/mysql/include/mysql -I/usr/local/mysql/include
|
||||
include MySQL.make
|
||||
|
||||
SYSLIBS += -lmysqlclient
|
||||
SYSFLAGS += -DTHREADSAFE -DNO_TCL
|
||||
|
||||
objects = Binder Extractor SessionImpl Connector \
|
||||
|
32
vendor/POCO/Data/MySQL/MySQL.make
vendored
Normal file
32
vendor/POCO/Data/MySQL/MySQL.make
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# MySQL.make
|
||||
#
|
||||
# Makefile fragment for finding MySQL library
|
||||
#
|
||||
|
||||
ifndef POCO_MYSQL_INCLUDE
|
||||
ifeq (0, $(shell test -d /usr/local/include/mysql; echo $$?))
|
||||
POCO_MYSQL_INCLUDE = /usr/local/include
|
||||
else
|
||||
ifeq (0, $(shell test -d /usr/local/opt/mysql-client/include; echo $$?))
|
||||
POCO_MYSQL_INCLUDE = /usr/local/opt/mysql-client/include
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef POCO_MYSQL_LIB
|
||||
ifeq (0, $(shell test -d /usr/local/include/mysql; echo $$?))
|
||||
POCO_MYSQL_LIB = /usr/local/lib
|
||||
else
|
||||
ifeq (0, $(shell test -d /usr/local/opt/mysql-client/lib; echo $$?))
|
||||
POCO_MYSQL_LIB = /usr/local/opt/mysql-client/lib
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef POCO_MYSQL_INCLUDE
|
||||
INCLUDE += -I$(POCO_MYSQL_INCLUDE)
|
||||
endif
|
||||
ifdef POCO_MYSQL_LIB
|
||||
SYSLIBS += -L$(POCO_MYSQL_LIB)
|
||||
endif
|
@@ -22,7 +22,7 @@
|
||||
#include "Poco/Data/AbstractBinder.h"
|
||||
#include "Poco/Data/LOB.h"
|
||||
#include "Poco/Data/MySQL/MySQLException.h"
|
||||
#include <mysql.h>
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
|
||||
virtual void bind(std::size_t pos, const unsigned long& val, Direction dir = PD_IN);
|
||||
/// Binds an unsigned long.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
virtual void bind(std::size_t pos, const bool& val, Direction dir);
|
||||
/// Binds a boolean.
|
||||
@@ -104,6 +104,9 @@ public:
|
||||
virtual void bind(std::size_t pos, const Time& val, Direction dir);
|
||||
/// Binds a Time.
|
||||
|
||||
virtual void bind(std::size_t pos, const UUID& val, Direction dir);
|
||||
/// Binds a UUID.
|
||||
|
||||
virtual void bind(std::size_t pos, const NullData& val, Direction dir);
|
||||
/// Binds a null.
|
||||
|
||||
|
@@ -110,6 +110,9 @@ public:
|
||||
virtual bool extract(std::size_t pos, Time& val);
|
||||
/// Extracts a Time. Returns false if null was received.
|
||||
|
||||
virtual bool extract(std::size_t pos, UUID& val);
|
||||
/// Extracts a UUID. Returns false if null was received.
|
||||
|
||||
virtual bool extract(std::size_t pos, Any& val);
|
||||
/// Extracts an Any. Returns false if null was received.
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
|
||||
//
|
||||
@@ -54,7 +55,11 @@
|
||||
#if !defined(MySQL_EXPORTS)
|
||||
#pragma comment(lib, "PocoDataMySQL" POCO_LIB_SUFFIX)
|
||||
#endif
|
||||
#pragma comment(lib, "libmysql")
|
||||
#if defined(LIBMARIADB)
|
||||
#pragma comment(lib, "libmariadb")
|
||||
#else
|
||||
#pragma comment(lib, "libmysql")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -20,9 +20,9 @@
|
||||
|
||||
#include "Poco/Data/MySQL/MySQL.h"
|
||||
#include "Poco/Data/DataException.h"
|
||||
#include <mysql/mysql.h>
|
||||
#include <typeinfo>
|
||||
#include <string>
|
||||
#include <mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
@@ -18,9 +18,9 @@
|
||||
#define Data_MySQL_ResultMetadata_INCLUDED
|
||||
|
||||
|
||||
#include <mysql.h>
|
||||
#include <vector>
|
||||
#include "Poco/Data/MetaColumn.h"
|
||||
#include <mysql/mysql.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#if LIBMYSQL_VERSION_ID >= 80000
|
||||
|
@@ -18,8 +18,8 @@
|
||||
#define Data_MySQL_SessionHandle_INCLUDED
|
||||
|
||||
|
||||
#include <mysql.h>
|
||||
#include "Poco/Data/MySQL/MySQLException.h"
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
@@ -18,8 +18,8 @@
|
||||
#define Data_MySQL_StatementHandle_INCLUDED
|
||||
|
||||
|
||||
#include <mysql.h>
|
||||
#include "Poco/Data/MySQL/MySQLException.h"
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
/// Fetches the column.
|
||||
|
||||
int getAffectedRowCount() const;
|
||||
|
||||
|
||||
operator MYSQL_STMT* ();
|
||||
/// Cast operator to native handle type.
|
||||
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "Poco/Data/MySQL/MySQL.h"
|
||||
#include "Poco/Data/Session.h"
|
||||
#include <mysql.h>
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
7
vendor/POCO/Data/MySQL/src/Binder.cpp
vendored
7
vendor/POCO/Data/MySQL/src/Binder.cpp
vendored
@@ -211,6 +211,13 @@ void Binder::bind(std::size_t pos, const Time& val, Direction dir)
|
||||
}
|
||||
|
||||
|
||||
void Binder::bind(std::size_t pos, const UUID& val, Direction dir)
|
||||
{
|
||||
std::string str = val.toString();
|
||||
bind(pos, str, dir);
|
||||
}
|
||||
|
||||
|
||||
void Binder::bind(std::size_t pos, const NullData&, Direction dir)
|
||||
{
|
||||
poco_assert(dir == PD_IN);
|
||||
|
4
vendor/POCO/Data/MySQL/src/Connector.cpp
vendored
4
vendor/POCO/Data/MySQL/src/Connector.cpp
vendored
@@ -16,7 +16,7 @@
|
||||
#include "Poco/Data/MySQL/SessionImpl.h"
|
||||
#include "Poco/Data/SessionFactory.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <mysql.h>
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -46,7 +46,7 @@ const std::string& Connector::name() const
|
||||
Poco::AutoPtr<Poco::Data::SessionImpl> Connector::createSession(const std::string& connectionString,
|
||||
std::size_t timeout)
|
||||
{
|
||||
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString, timeout));
|
||||
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString, timeout));
|
||||
}
|
||||
|
||||
|
||||
|
12
vendor/POCO/Data/MySQL/src/Extractor.cpp
vendored
12
vendor/POCO/Data/MySQL/src/Extractor.cpp
vendored
@@ -204,6 +204,18 @@ bool Extractor::extract(std::size_t pos, Time& val)
|
||||
}
|
||||
|
||||
|
||||
bool Extractor::extract(std::size_t pos, UUID& val)
|
||||
{
|
||||
std::string str;
|
||||
if (extract(pos, str))
|
||||
{
|
||||
val.parse(str);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
bool Extractor::extract(std::size_t pos, Any& val)
|
||||
{
|
||||
return false;
|
||||
|
@@ -12,8 +12,13 @@
|
||||
//
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
|
||||
#include "Poco/Data/MySQL/MySQLException.h"
|
||||
#include <mysql.h>
|
||||
#include <mysql/mysql.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
1
vendor/POCO/Data/MySQL/src/SessionHandle.cpp
vendored
1
vendor/POCO/Data/MySQL/src/SessionHandle.cpp
vendored
@@ -183,6 +183,7 @@ void SessionHandle::rollback()
|
||||
|
||||
void SessionHandle::reset()
|
||||
{
|
||||
//#if ((defined (MYSQL_VERSION_ID)) && (MYSQL_VERSION_ID >= 50700)) || ((defined (MARIADB_PACKAGE_VERSION_ID)) && (MARIADB_PACKAGE_VERSION_ID >= 30000))
|
||||
#if ((POCO_OS == POCO_OS_LINUX) && defined (HAVE_MYSQL_RESET_CONNECTION)) && (((defined (MYSQL_VERSION_ID)) && (MYSQL_VERSION_ID >= 50700)) || ((defined (MARIADB_PACKAGE_VERSION_ID)) && (MARIADB_PACKAGE_VERSION_ID >= 30000)))
|
||||
if (mysql_reset_connection(_pHandle) != 0)
|
||||
#else
|
||||
|
@@ -12,9 +12,9 @@
|
||||
//
|
||||
|
||||
|
||||
#include <mysql.h>
|
||||
#include "Poco/Data/MySQL/StatementExecutor.h"
|
||||
#include "Poco/Format.h"
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -52,7 +52,7 @@ void StatementExecutor::prepare(const std::string& query)
|
||||
_state = STMT_COMPILED;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int rc = mysql_stmt_prepare(_pHandle, query.c_str(), static_cast<unsigned int>(query.length()));
|
||||
if (rc != 0)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ bool StatementExecutor::fetch()
|
||||
int res = mysql_stmt_fetch(_pHandle);
|
||||
|
||||
// we have specified zero buffers for BLOBs, so DATA_TRUNCATED is normal in this case
|
||||
if ((res != 0) && (res != MYSQL_NO_DATA) && (res != MYSQL_DATA_TRUNCATED))
|
||||
if ((res != 0) && (res != MYSQL_NO_DATA) && (res != MYSQL_DATA_TRUNCATED))
|
||||
throw StatementException("mysql_stmt_fetch error", _pHandle, _query);
|
||||
|
||||
return (res == 0) || (res == MYSQL_DATA_TRUNCATED);
|
||||
|
2
vendor/POCO/Data/MySQL/src/Utility.cpp
vendored
2
vendor/POCO/Data/MySQL/src/Utility.cpp
vendored
@@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
#include "Poco/Data/MySQL/Utility.h"
|
||||
#include <mysql.h>
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
4
vendor/POCO/Data/MySQL/testsuite/Makefile
vendored
4
vendor/POCO/Data/MySQL/testsuite/Makefile
vendored
@@ -6,10 +6,10 @@
|
||||
|
||||
include $(POCO_BASE)/build/rules/global
|
||||
|
||||
INCLUDE += -I./../include -I/usr/local/include/mysql -I/usr/include/mysql/ -I/usr/mysql/include/mysql -I/usr/local/mysql/include
|
||||
include $(POCO_BASE)/Data/MySQL/MySQL.make
|
||||
|
||||
# Note: linking order is important, do not change it.
|
||||
SYSLIBS += -L/usr/local/lib -L/usr/local/lib$(LIB64SUFFIX)/mysql -L/usr/lib$(LIB64SUFFIX)/mysql -L/usr/mysql/lib$(LIB64SUFFIX) -L/usr/mysql/lib$(LIB64SUFFIX)/mysql -L/usr/local/mysql/lib$(LIB64SUFFIX) -lmysqlclient -lz -lpthread -ldl
|
||||
SYSLIBS += -lmysqlclient -lz -lpthread -ldl
|
||||
|
||||
objects = MySQLTestSuite Driver MySQLTest SQLExecutor
|
||||
|
||||
|
@@ -45,7 +45,9 @@ Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = 0;
|
||||
#define MYSQL_USER "pocotest"
|
||||
#define MYSQL_PWD "pocotest"
|
||||
#define MYSQL_HOST "127.0.0.1"
|
||||
#ifndef MYSQL_PORT
|
||||
#define MYSQL_PORT 3306
|
||||
#endif
|
||||
#define MYSQL_DB "pocotest"
|
||||
|
||||
//
|
||||
@@ -494,6 +496,15 @@ void MySQLTest::testDouble()
|
||||
}
|
||||
|
||||
|
||||
void MySQLTest::testUUID()
|
||||
{
|
||||
if (!_pSession) fail ("Test not available.");
|
||||
|
||||
recreateUUIDsTable();
|
||||
_pExecutor->uuids();
|
||||
}
|
||||
|
||||
|
||||
void MySQLTest::testTuple()
|
||||
{
|
||||
if (!_pSession) fail ("Test not available.");
|
||||
@@ -777,6 +788,15 @@ void MySQLTest::recreateFloatsTable()
|
||||
}
|
||||
|
||||
|
||||
void MySQLTest::recreateUUIDsTable()
|
||||
{
|
||||
dropTable("Strings");
|
||||
try { *_pSession << "CREATE TABLE Strings (str CHAR(36))", now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail ("recreateUUIDsTable()"); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail ("recreateUUIDsTable()"); }
|
||||
}
|
||||
|
||||
|
||||
void MySQLTest::recreateTuplesTable()
|
||||
{
|
||||
dropTable("Tuples");
|
||||
@@ -902,6 +922,7 @@ CppUnit::Test* MySQLTest::suite()
|
||||
CppUnit_addTest(pSuite, MySQLTest, testUnsignedInts);
|
||||
CppUnit_addTest(pSuite, MySQLTest, testFloat);
|
||||
CppUnit_addTest(pSuite, MySQLTest, testDouble);
|
||||
CppUnit_addTest(pSuite, MySQLTest, testUUID);
|
||||
CppUnit_addTest(pSuite, MySQLTest, testTuple);
|
||||
CppUnit_addTest(pSuite, MySQLTest, testTupleVector);
|
||||
CppUnit_addTest(pSuite, MySQLTest, testInternalExtraction);
|
||||
|
@@ -24,7 +24,7 @@
|
||||
class MySQLTest: public CppUnit::TestCase
|
||||
/// MySQL test class
|
||||
/// Tested:
|
||||
///
|
||||
///
|
||||
/// Driver | DB | OS
|
||||
/// ----------------+---------------------------+------------------------------------------
|
||||
/// 03.51.12.00 | MySQL 5.0.27-community-nt | MS Windows XP Professional x64 v.2003/SP1
|
||||
@@ -84,6 +84,8 @@ public:
|
||||
void testFloat();
|
||||
void testDouble();
|
||||
|
||||
void testUUID();
|
||||
|
||||
void testTuple();
|
||||
void testTupleVector();
|
||||
|
||||
@@ -119,6 +121,7 @@ private:
|
||||
void recreateIntsTable();
|
||||
void recreateUnsignedIntsTable();
|
||||
void recreateFloatsTable();
|
||||
void recreateUUIDsTable();
|
||||
void recreateTuplesTable();
|
||||
void recreateVectorsTable();
|
||||
void recreateNullableIntTable();
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "MySQLTestSuite.h"
|
||||
#include "MySQLTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* MySQLTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MySQLTestSuite");
|
||||
|
109
vendor/POCO/Data/MySQL/testsuite/src/SQLExecutor.cpp
vendored
109
vendor/POCO/Data/MySQL/testsuite/src/SQLExecutor.cpp
vendored
@@ -27,9 +27,9 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Winsock2.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <mysql.h>
|
||||
#include <mysql/mysql.h>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
@@ -141,7 +141,7 @@ private:
|
||||
} } // namespace Poco::Data
|
||||
|
||||
|
||||
SQLExecutor::SQLExecutor(const std::string& name, Poco::Data::Session* pSession):
|
||||
SQLExecutor::SQLExecutor(const std::string& name, Poco::Data::Session* pSession):
|
||||
CppUnit::TestCase(name),
|
||||
_pSession(pSession)
|
||||
{
|
||||
@@ -161,22 +161,22 @@ void SQLExecutor::bareboneMySQLTest(const char* host, const char* user, const ch
|
||||
|
||||
MYSQL* tmp = mysql_real_connect(hsession, host, user, pwd, db, port, 0, 0);
|
||||
assertTrue (tmp == hsession);
|
||||
|
||||
|
||||
MYSQL_STMT* hstmt = mysql_stmt_init(hsession);
|
||||
assertTrue (hstmt != 0);
|
||||
|
||||
|
||||
std::string sql = "DROP TABLE Test";
|
||||
mysql_real_query(hsession, sql.c_str(), static_cast<unsigned long>(sql.length()));
|
||||
|
||||
|
||||
sql = tableCreateString;
|
||||
rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast<unsigned long>(sql.length()));
|
||||
rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast<unsigned long>(sql.length()));
|
||||
assertTrue (rc == 0);
|
||||
|
||||
rc = mysql_stmt_execute(hstmt);
|
||||
assertTrue (rc == 0);
|
||||
|
||||
sql = "INSERT INTO Test VALUES (?,?,?,?,?)";
|
||||
rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast<unsigned long>(sql.length()));
|
||||
rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast<unsigned long>(sql.length()));
|
||||
assertTrue (rc == 0);
|
||||
|
||||
std::string str[3] = { "111", "222", "333" };
|
||||
@@ -219,7 +219,7 @@ void SQLExecutor::bareboneMySQLTest(const char* host, const char* user, const ch
|
||||
fifth = 0.0f;
|
||||
|
||||
MYSQL_BIND bind_result[5] = {{0}};
|
||||
|
||||
|
||||
bind_result[0].buffer = chr[0];
|
||||
bind_result[0].buffer_length = sizeof(chr[0]);
|
||||
bind_result[0].buffer_type = MYSQL_TYPE_STRING;
|
||||
@@ -279,15 +279,15 @@ void SQLExecutor::simpleAccess()
|
||||
std::string result;
|
||||
|
||||
count = 0;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Statement stmt(*_pSession);
|
||||
stmt << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(age);//, now;
|
||||
stmt << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(age);//, now;
|
||||
stmt.execute();
|
||||
}
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
|
||||
|
||||
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
@@ -545,11 +545,34 @@ void SQLExecutor::doubles()
|
||||
}
|
||||
|
||||
|
||||
void SQLExecutor::uuids()
|
||||
{
|
||||
std::string funct = "uuids()";
|
||||
Poco::UUID data("da8b9c4d-faa0-44e1-b834-ece1e7d31cd5");
|
||||
Poco::UUID ret;
|
||||
|
||||
try { *_pSession << "INSERT INTO Strings VALUES (?)", use(data), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
|
||||
int count = 0;
|
||||
try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assertTrue (count == 1);
|
||||
|
||||
try { *_pSession << "SELECT str FROM Strings", into(ret), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assertTrue (ret == data);
|
||||
}
|
||||
|
||||
|
||||
void SQLExecutor::insertSingleBulkVec()
|
||||
{
|
||||
std::string funct = "insertSingleBulkVec()";
|
||||
std::vector<int> data;
|
||||
|
||||
|
||||
for (int x = 0; x < 100; ++x)
|
||||
data.push_back(x);
|
||||
|
||||
@@ -938,7 +961,7 @@ void SQLExecutor::multiMapComplex()
|
||||
people.insert(std::make_pair("LN1", p1));
|
||||
people.insert(std::make_pair("LN1", p1));
|
||||
people.insert(std::make_pair("LN2", p2));
|
||||
|
||||
|
||||
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(people), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
@@ -1000,7 +1023,7 @@ void SQLExecutor::selectIntoSingleStep()
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assertTrue (count == 2);
|
||||
Person result;
|
||||
Statement stmt = (*_pSession << "SELECT * FROM Person", into(result), limit(1));
|
||||
Statement stmt = (*_pSession << "SELECT * FROM Person", into(result), limit(1));
|
||||
stmt.execute();
|
||||
assertTrue (result == p1);
|
||||
assertTrue (!stmt.done());
|
||||
@@ -1264,7 +1287,7 @@ void SQLExecutor::dateTime()
|
||||
std::string firstName("Simpson");
|
||||
std::string address("Springfield");
|
||||
DateTime birthday(1980, 4, 1, 5, 45, 12, 354, 879);
|
||||
|
||||
|
||||
int count = 0;
|
||||
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
@@ -1273,14 +1296,14 @@ void SQLExecutor::dateTime()
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assertTrue (count == 1);
|
||||
|
||||
|
||||
DateTime bd;
|
||||
assertTrue (bd != birthday);
|
||||
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assertTrue (bd == birthday);
|
||||
|
||||
|
||||
std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
|
||||
}
|
||||
|
||||
@@ -1292,7 +1315,7 @@ void SQLExecutor::date()
|
||||
std::string firstName("Simpson");
|
||||
std::string address("Springfield");
|
||||
Date birthday(1980, 4, 1);
|
||||
|
||||
|
||||
int count = 0;
|
||||
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
@@ -1301,14 +1324,14 @@ void SQLExecutor::date()
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assertTrue (count == 1);
|
||||
|
||||
|
||||
Date bd;
|
||||
assertTrue (bd != birthday);
|
||||
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assertTrue (bd == birthday);
|
||||
|
||||
|
||||
std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
|
||||
}
|
||||
|
||||
@@ -1320,7 +1343,7 @@ void SQLExecutor::time()
|
||||
std::string firstName("Simpson");
|
||||
std::string address("Springfield");
|
||||
Time birthday(1, 2, 3);
|
||||
|
||||
|
||||
int count = 0;
|
||||
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
@@ -1329,14 +1352,14 @@ void SQLExecutor::time()
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assertTrue (count == 1);
|
||||
|
||||
|
||||
Time bd;
|
||||
assertTrue (bd != birthday);
|
||||
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assertTrue (bd == birthday);
|
||||
|
||||
|
||||
std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
|
||||
}
|
||||
|
||||
@@ -1436,7 +1459,7 @@ void SQLExecutor::tupleVector()
|
||||
typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType;
|
||||
std::string funct = "tupleVector()";
|
||||
TupleType t(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
|
||||
Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int>
|
||||
Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int>
|
||||
t10(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29);
|
||||
TupleType t100(100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119);
|
||||
std::vector<TupleType> v;
|
||||
@@ -1475,8 +1498,8 @@ void SQLExecutor::internalExtraction()
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Statement stmt = (*_pSession << "SELECT * FROM Vectors", now);
|
||||
RecordSet rset(stmt);
|
||||
|
||||
@@ -1523,7 +1546,7 @@ void SQLExecutor::internalExtraction()
|
||||
assertTrue ("5" == s);
|
||||
i = rset.value("str0", 2);
|
||||
assertTrue (5 == i);
|
||||
|
||||
|
||||
const Column<int>& col = rset.column<int>(0);
|
||||
Column<int>::Iterator it = col.begin();
|
||||
Column<int>::Iterator end = col.end();
|
||||
@@ -1563,7 +1586,7 @@ void SQLExecutor::internalExtraction()
|
||||
|
||||
try { rset.value<std::string>(0,0); fail ("must fail"); }
|
||||
catch (BadCastException&) { }
|
||||
|
||||
|
||||
stmt = (*_pSession << "DELETE FROM Vectors", now);
|
||||
rset = stmt;
|
||||
|
||||
@@ -1579,10 +1602,10 @@ void SQLExecutor::internalExtraction()
|
||||
void SQLExecutor::doNull()
|
||||
{
|
||||
std::string funct = "null()";
|
||||
|
||||
*_pSession << "INSERT INTO Vectors VALUES (?, ?, ?)",
|
||||
use(Poco::Data::Keywords::null),
|
||||
use(Poco::Data::Keywords::null),
|
||||
|
||||
*_pSession << "INSERT INTO Vectors VALUES (?, ?, ?)",
|
||||
use(Poco::Data::Keywords::null),
|
||||
use(Poco::Data::Keywords::null),
|
||||
use(Poco::Data::Keywords::null), now;
|
||||
|
||||
int count = 0;
|
||||
@@ -1615,19 +1638,19 @@ void SQLExecutor::doNull()
|
||||
|
||||
|
||||
void SQLExecutor::setTransactionIsolation(Session& session, Poco::UInt32 ti)
|
||||
{
|
||||
{
|
||||
if (session.hasTransactionIsolation(ti))
|
||||
{
|
||||
std::string funct = "setTransactionIsolation()";
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
Transaction t(session, false);
|
||||
t.setIsolation(ti);
|
||||
|
||||
|
||||
assertTrue (ti == t.getIsolation());
|
||||
assertTrue (t.isIsolation(ti));
|
||||
|
||||
|
||||
assertTrue (ti == session.getTransactionIsolation());
|
||||
assertTrue (session.isTransactionIsolation(ti));
|
||||
}
|
||||
@@ -1789,11 +1812,11 @@ void SQLExecutor::transaction(const std::string& connect)
|
||||
Transaction trans((*_pSession));
|
||||
assertTrue (trans.isActive());
|
||||
assertTrue (_pSession->isTransaction());
|
||||
|
||||
|
||||
try { (*_pSession) << "INSERT INTO Person VALUES (?,?,?,?)", use(lastNames), use(firstNames), use(addresses), use(ages), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
|
||||
|
||||
assertTrue (_pSession->isTransaction());
|
||||
assertTrue (trans.isActive());
|
||||
|
||||
@@ -1885,7 +1908,7 @@ void SQLExecutor::transaction(const std::string& connect)
|
||||
assertTrue (0 == count);
|
||||
|
||||
trans.execute(sql);
|
||||
|
||||
|
||||
local << "SELECT COUNT(*) FROM Person", into(locCount), now;
|
||||
assertTrue (2 == locCount);
|
||||
|
||||
@@ -1921,9 +1944,9 @@ void SQLExecutor::reconnect()
|
||||
assertTrue (_pSession->isConnected());
|
||||
_pSession->close();
|
||||
assertTrue (!_pSession->isConnected());
|
||||
try
|
||||
try
|
||||
{
|
||||
(*_pSession) << "SELECT LastName FROM Person", into(result), now;
|
||||
(*_pSession) << "SELECT LastName FROM Person", into(result), now;
|
||||
fail ("must fail");
|
||||
}
|
||||
catch(NotConnectedException&){ }
|
||||
|
@@ -26,7 +26,7 @@ public:
|
||||
PB_IMMEDIATE,
|
||||
PB_AT_EXEC
|
||||
};
|
||||
|
||||
|
||||
enum DataExtraction
|
||||
{
|
||||
DE_MANUAL,
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
~SQLExecutor();
|
||||
|
||||
void bareboneMySQLTest(const char* host, const char* user, const char* pwd, const char* db, int port, const char* tableCreateString);
|
||||
/// This function uses "bare bone" MySQL API calls (i.e. calls are not
|
||||
/// This function uses "bare bone" MySQL API calls (i.e. calls are not
|
||||
/// "wrapped" in PocoData framework structures).
|
||||
/// The purpose of the function is to verify that driver behaves
|
||||
/// correctly. If this test passes, subsequent tests failures are likely ours.
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
void unsignedInts();
|
||||
void floats();
|
||||
void doubles();
|
||||
void uuids();
|
||||
void tuples();
|
||||
void tupleVector();
|
||||
|
||||
|
Reference in New Issue
Block a user