mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-14 23:07:56 +02:00
ODBC fixes and tests (Oracle, SQL Server, MySQL on Windows)
MySQL back-end compile fixes on Windows Nullable/NullType
This commit is contained in:
@@ -1,93 +1,93 @@
|
||||
//
|
||||
// MySQLException.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Data/MySQL/src/Connector.cpp#1 $
|
||||
//
|
||||
// Library: Data
|
||||
// Package: MySQL
|
||||
// Module: Connector
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Data/MySQL/Connector.h"
|
||||
#include "Poco/Data/MySQL/SessionImpl.h"
|
||||
#include "Poco/Data/SessionFactory.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
#include <mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace MySQL {
|
||||
|
||||
|
||||
std::string Connector::KEY("mysql");
|
||||
|
||||
|
||||
Connector::Connector()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Connector::~Connector()
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& Connector::name() const
|
||||
{
|
||||
return KEY;
|
||||
}
|
||||
|
||||
//
|
||||
// MySQLException.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Data/MySQL/src/Connector.cpp#1 $
|
||||
//
|
||||
// Library: Data
|
||||
// Package: MySQL
|
||||
// Module: Connector
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Data/MySQL/Connector.h"
|
||||
#include "Poco/Data/MySQL/SessionImpl.h"
|
||||
#include "Poco/Data/SessionFactory.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
#include <mysql.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace MySQL {
|
||||
|
||||
|
||||
std::string Connector::KEY("mysql");
|
||||
|
||||
|
||||
Connector::Connector()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Connector::~Connector()
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& Connector::name() const
|
||||
{
|
||||
return KEY;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
void Connector::registerConnector()
|
||||
{
|
||||
if (mysql_library_init(0, 0, 0) != 0)
|
||||
{
|
||||
throw Exception("mysql_library_init error");
|
||||
}
|
||||
|
||||
Poco::Data::SessionFactory::instance().add(new Connector());
|
||||
}
|
||||
|
||||
|
||||
void Connector::unregisterConnector()
|
||||
{
|
||||
Poco::Data::SessionFactory::instance().remove(KEY);
|
||||
mysql_library_end();
|
||||
}
|
||||
|
||||
|
||||
} } } // namespace Poco::Data::MySQL
|
||||
|
||||
std::size_t timeout)
|
||||
{
|
||||
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString, timeout));
|
||||
}
|
||||
|
||||
|
||||
void Connector::registerConnector()
|
||||
{
|
||||
if (mysql_library_init(0, 0, 0) != 0)
|
||||
{
|
||||
throw Exception("mysql_library_init error");
|
||||
}
|
||||
|
||||
Poco::Data::SessionFactory::instance().add(new Connector());
|
||||
}
|
||||
|
||||
|
||||
void Connector::unregisterConnector()
|
||||
{
|
||||
Poco::Data::SessionFactory::instance().remove(KEY);
|
||||
mysql_library_end();
|
||||
}
|
||||
|
||||
|
||||
} } } // namespace Poco::Data::MySQL
|
||||
|
||||
|
@@ -41,10 +41,10 @@ namespace Data {
|
||||
namespace MySQL {
|
||||
|
||||
|
||||
MySQLStatementImpl::MySQLStatementImpl(SessionImpl& h)
|
||||
: Poco::Data::StatementImpl(h),
|
||||
_stmt(h.handle()),
|
||||
_extractor(_stmt, _metadata),
|
||||
MySQLStatementImpl::MySQLStatementImpl(SessionImpl& h) :
|
||||
Poco::Data::StatementImpl(h),
|
||||
_stmt(h.handle()),
|
||||
_extractor(_stmt, _metadata),
|
||||
_hasNext(NEXT_DONTKNOW)
|
||||
{
|
||||
}
|
||||
@@ -63,7 +63,7 @@ std::size_t MySQLStatementImpl::columnsReturned() const
|
||||
|
||||
std::size_t MySQLStatementImpl::affectedRowCount() const
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ std::size_t MySQLStatementImpl::next()
|
||||
}
|
||||
|
||||
_hasNext = NEXT_DONTKNOW;
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ bool MySQLStatementImpl::canCompile() const
|
||||
return (_stmt.state() < StatementExecutor::STMT_COMPILED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MySQLStatementImpl::compileImpl()
|
||||
{
|
||||
_metadata.reset();
|
||||
@@ -147,7 +147,7 @@ void MySQLStatementImpl::compileImpl()
|
||||
_stmt.bindResult(_metadata.row());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MySQLStatementImpl::bindImpl()
|
||||
{
|
||||
Poco::Data::AbstractBindingVec& binds = bindings();
|
||||
@@ -165,13 +165,13 @@ void MySQLStatementImpl::bindImpl()
|
||||
_hasNext = NEXT_DONTKNOW;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AbstractExtractor& MySQLStatementImpl::extractor()
|
||||
{
|
||||
return _extractor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AbstractBinder& MySQLStatementImpl::binder()
|
||||
{
|
||||
return _binder;
|
||||
|
@@ -96,7 +96,7 @@ void SessionHandle::options(mysql_option opt, unsigned int i)
|
||||
void SessionHandle::connect(const char* host, const char* user, const char* password, const char* db, unsigned int port)
|
||||
{
|
||||
if (!mysql_real_connect(_pHandle, host, user, password, db, port, 0, 0))
|
||||
throw ConnectionFailedException("mysql_real_connect error");
|
||||
throw ConnectionFailedException(mysql_error(_pHandle));
|
||||
}
|
||||
|
||||
|
||||
@@ -112,21 +112,21 @@ void SessionHandle::close()
|
||||
|
||||
void SessionHandle::startTransaction()
|
||||
{
|
||||
if (mysql_autocommit(_pHandle, false) != 0)
|
||||
if (mysql_autocommit(_pHandle, false) != 0)
|
||||
throw TransactionException("Start transaction failed.", _pHandle);
|
||||
}
|
||||
|
||||
|
||||
void SessionHandle::commit()
|
||||
{
|
||||
if (mysql_commit(_pHandle) != 0)
|
||||
if (mysql_commit(_pHandle) != 0)
|
||||
throw TransactionException("Commit failed.", _pHandle);
|
||||
}
|
||||
|
||||
|
||||
void SessionHandle::rollback()
|
||||
{
|
||||
if (mysql_rollback(_pHandle) != 0)
|
||||
if (mysql_rollback(_pHandle) != 0)
|
||||
throw TransactionException("Rollback failed.", _pHandle);
|
||||
}
|
||||
|
||||
|
@@ -184,21 +184,21 @@ void SessionImpl::begin()
|
||||
if (_inTransaction)
|
||||
throw Poco::InvalidAccessException("Already in transaction.");
|
||||
|
||||
_handle.startTransaction();
|
||||
_handle.startTransaction();
|
||||
_inTransaction = true;
|
||||
}
|
||||
|
||||
|
||||
void SessionImpl::commit()
|
||||
{
|
||||
_handle.commit();
|
||||
_handle.commit();
|
||||
_inTransaction = false;
|
||||
}
|
||||
|
||||
|
||||
void SessionImpl::rollback()
|
||||
{
|
||||
_handle.rollback();
|
||||
_handle.rollback();
|
||||
_inTransaction = false;
|
||||
}
|
||||
|
||||
|
@@ -67,17 +67,17 @@ int StatementExecutor::state() const
|
||||
|
||||
void StatementExecutor::prepare(const std::string& query)
|
||||
{
|
||||
if (_state >= STMT_COMPILED)
|
||||
{
|
||||
_state = STMT_COMPILED;
|
||||
return;
|
||||
}
|
||||
if (_state >= STMT_COMPILED)
|
||||
{
|
||||
_state = STMT_COMPILED;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mysql_stmt_prepare(_pHandle, query.c_str(), static_cast<unsigned int>(query.length())) != 0)
|
||||
throw StatementException("mysql_stmt_prepare error", _pHandle, query);
|
||||
if (mysql_stmt_prepare(_pHandle, query.c_str(), static_cast<unsigned int>(query.length())) != 0)
|
||||
throw StatementException("mysql_stmt_prepare error", _pHandle, query);
|
||||
|
||||
_query = query;
|
||||
_state = STMT_COMPILED;
|
||||
_query = query;
|
||||
_state = STMT_COMPILED;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user