mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-18 15:33:08 +02:00
- Unicode support (Windows only at this time, UNIX T.B.D.)
- SF bug #1836684 fix (ODBC data lengths in subsequent execute calls) - many refactoring/cosmetic changes
This commit is contained in:
parent
fbb1c1fd44
commit
2e10390593
@ -253,10 +253,6 @@
|
||||
RelativePath=".\include\Poco\Data\Column.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Data\Common.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Data\Connector.h"
|
||||
>
|
||||
|
@ -16,9 +16,9 @@ else
|
||||
$(error No ODBC library found. Please install unixODBC or iODBC and try again)
|
||||
endif
|
||||
|
||||
objects = Binder ConnectionHandle TypeInfo EnvironmentHandle \
|
||||
objects = Binder ConnectionHandle Connector EnvironmentHandle \
|
||||
Extractor ODBCColumn ODBCException ODBCStatementImpl Parameter Preparation \
|
||||
SessionImpl Connector Utility
|
||||
SessionImpl TypeInfo Unicode Utility
|
||||
|
||||
target = PocoODBC
|
||||
target_version = $(LIBVERSION)
|
||||
|
@ -41,7 +41,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\include;.\src;..\..\Foundation\include;..\..\Data\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;ODBC_EXPORTS;NO_TCL;THREADSAFE"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;ODBC_EXPORTS;NO_TCL;THREADSAFE;SQL_NOUNICODEMAP"
|
||||
StringPooling="true"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -134,7 +134,7 @@
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories=".\include;.\src;..\..\Foundation\include;..\..\Data\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;ODBC_EXPORTS;NO_TCL;THREADSAFE"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;ODBC_EXPORTS;NO_TCL;THREADSAFE;SQL_NOUNICODEMAP"
|
||||
GeneratePreprocessedFile="0"
|
||||
KeepComments="false"
|
||||
StringPooling="true"
|
||||
@ -273,6 +273,18 @@
|
||||
RelativePath=".\include\Poco\Data\ODBC\TypeInfo.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Data\ODBC\Unicode.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Data\ODBC\Unicode_UNIX.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Data\ODBC\Unicode_WIN32.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Data\ODBC\Utility.h"
|
||||
>
|
||||
@ -329,6 +341,50 @@
|
||||
RelativePath=".\src\TypeInfo.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Unicode.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Unicode_UNIX.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Unicode_WIN32.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Utility.cpp"
|
||||
>
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef DataConnectors_ODBC_Binder_INCLUDED
|
||||
#define DataConnectors_ODBC_Binder_INCLUDED
|
||||
#ifndef Data_ODBC_Binder_INCLUDED
|
||||
#define Data_ODBC_Binder_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
@ -160,6 +160,9 @@ public:
|
||||
/// Transfers the results of non-POD outbound parameters from internal
|
||||
/// holders back into the externally supplied buffers.
|
||||
|
||||
void reset();
|
||||
/// Clears the cached storage.
|
||||
|
||||
private:
|
||||
typedef std::vector<SQLLEN*> LengthVec;
|
||||
typedef std::map<char*, std::string*> StringMap;
|
||||
@ -330,4 +333,4 @@ inline Binder::ParameterBinding Binder::getDataBinding() const
|
||||
} } } // namespace Poco::Data::ODBC
|
||||
|
||||
|
||||
#endif // DataConnectors_ODBC_Binder_INCLUDED
|
||||
#endif // Data_ODBC_Binder_INCLUDED
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_ConnectionHandle_INCLUDED
|
||||
#define ODBC_ConnectionHandle_INCLUDED
|
||||
#ifndef Data_ODBC_ConnectionHandle_INCLUDED
|
||||
#define Data_ODBC_ConnectionHandle_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef DataConnectors_ODBC_Connector_INCLUDED
|
||||
#define DataConnectors_ODBC_Connector_INCLUDED
|
||||
#ifndef Data_ODBC_Connector_INCLUDED
|
||||
#define Data_ODBC_Connector_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
@ -76,4 +76,4 @@ public:
|
||||
} } } // namespace Poco::Data::ODBC
|
||||
|
||||
|
||||
#endif // DataConnectors_ODBC_Connector_INCLUDED
|
||||
#endif // Data_ODBC_Connector_INCLUDED
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_Diagnostics_INCLUDED
|
||||
#define ODBC_Diagnostics_INCLUDED
|
||||
#ifndef Data_ODBC_Diagnostics_INCLUDED
|
||||
#define Data_ODBC_Diagnostics_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
@ -65,14 +65,14 @@ public:
|
||||
static const unsigned int SQL_STATE_SIZE = SQL_SQLSTATE_SIZE + 1;
|
||||
static const unsigned int SQL_MESSAGE_LENGTH = SQL_MAX_MESSAGE_LENGTH + 1;
|
||||
static const unsigned int SQL_NAME_LENGTH = 128;
|
||||
static const std::string DATA_TRUNCATED;
|
||||
static const std::string DATA_TRUNCATED;
|
||||
|
||||
struct DiagnosticFields
|
||||
{
|
||||
/// SQLGetDiagRec fields
|
||||
POCO_SQLCHAR _sqlState[SQL_STATE_SIZE];
|
||||
POCO_SQLCHAR _message[SQL_MESSAGE_LENGTH];
|
||||
SQLINTEGER _nativeError;
|
||||
SQLCHAR _sqlState[SQL_STATE_SIZE];
|
||||
SQLCHAR _message[SQL_MESSAGE_LENGTH];
|
||||
SQLINTEGER _nativeError;
|
||||
};
|
||||
|
||||
typedef std::vector<DiagnosticFields> FieldVec;
|
||||
@ -237,8 +237,8 @@ private:
|
||||
Diagnostics();
|
||||
|
||||
/// SQLGetDiagField fields
|
||||
POCO_SQLCHAR _connectionName[SQL_NAME_LENGTH];
|
||||
POCO_SQLCHAR _serverName[SQL_NAME_LENGTH];
|
||||
SQLCHAR _connectionName[SQL_NAME_LENGTH];
|
||||
SQLCHAR _serverName[SQL_NAME_LENGTH];
|
||||
|
||||
/// Diagnostics container
|
||||
FieldVec _fields;
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_EnvironmentHandle_INCLUDED
|
||||
#define ODBC_EnvironmentHandle_INCLUDED
|
||||
#ifndef Data_ODBC_EnvironmentHandle_INCLUDED
|
||||
#define Data_ODBC_EnvironmentHandle_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_Error_INCLUDED
|
||||
#define ODBC_Error_INCLUDED
|
||||
#ifndef Data_ODBC_Error_INCLUDED
|
||||
#define Data_ODBC_Error_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef DataConnectors_ODBC_Extractor_INCLUDED
|
||||
#define DataConnectors_ODBC_Extractor_INCLUDED
|
||||
#ifndef Data_ODBC_Extractor_INCLUDED
|
||||
#define Data_ODBC_Extractor_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
@ -146,7 +146,7 @@ public:
|
||||
/// Returns true if the current row value at pos column is null.
|
||||
|
||||
void reset();
|
||||
/// Resets the internally cached null value indicators.
|
||||
/// Resets the internally cached length indicators.
|
||||
|
||||
private:
|
||||
static const int CHUNK_SIZE = 1024;
|
||||
@ -317,4 +317,4 @@ inline bool Extractor::isNullLengthIndicator(SQLLEN val) const
|
||||
} } } // namespace Poco::Data::ODBC
|
||||
|
||||
|
||||
#endif // DataConnectors_ODBC_Extractor_INCLUDED
|
||||
#endif // Data_ODBC_Extractor_INCLUDED
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_Handle_INCLUDED
|
||||
#define ODBC_Handle_INCLUDED
|
||||
#ifndef Data_ODBC_Handle_INCLUDED
|
||||
#define Data_ODBC_Handle_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
|
@ -38,11 +38,14 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_ODBC_INCLUDED
|
||||
#define ODBC_ODBC_INCLUDED
|
||||
#ifndef Data_ODBC_ODBC_INCLUDED
|
||||
#define Data_ODBC_ODBC_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
@ -67,7 +70,8 @@
|
||||
#endif
|
||||
|
||||
|
||||
#define POCO_SQLCHAR SQLCHAR
|
||||
|
||||
#include "Poco/Data/ODBC/Unicode.h"
|
||||
|
||||
|
||||
//
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_ODBCColumn_INCLUDED
|
||||
#define ODBC_ODBCColumn_INCLUDED
|
||||
#ifndef Data_ODBC_ODBCColumn_INCLUDED
|
||||
#define Data_ODBC_ODBCColumn_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
@ -79,7 +79,7 @@ private:
|
||||
|
||||
struct ColumnDescription
|
||||
{
|
||||
POCO_SQLCHAR name[NAME_BUFFER_LENGTH];
|
||||
SQLCHAR name[NAME_BUFFER_LENGTH];
|
||||
SQLSMALLINT nameBufferLength;
|
||||
SQLSMALLINT dataType;
|
||||
SQLULEN size;
|
||||
@ -90,7 +90,7 @@ private:
|
||||
void init();
|
||||
void getDescription();
|
||||
|
||||
Poco::Int32 _dataLength;
|
||||
SQLLEN _dataLength;
|
||||
const StatementHandle& _rStmt;
|
||||
ColumnDescription _columnDesc;
|
||||
};
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_ODBCException_INCLUDED
|
||||
#define ODBC_ODBCException_INCLUDED
|
||||
#ifndef Data_ODBC_ODBCException_INCLUDED
|
||||
#define Data_ODBC_ODBCException_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef DataConnectors_ODBC_ODBCStatementImpl_INCLUDED
|
||||
#define DataConnectors_ODBC_ODBCStatementImpl_INCLUDED
|
||||
#ifndef Data_ODBC_ODBCStatementImpl_INCLUDED
|
||||
#define Data_ODBC_ODBCStatementImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
@ -220,4 +220,4 @@ inline const MetaColumn& ODBCStatementImpl::metaColumn(Poco::UInt32 pos) const
|
||||
} } } // namespace Poco::Data::ODBC
|
||||
|
||||
|
||||
#endif // DataConnectors_ODBC_ODBCStatementImpl_INCLUDED
|
||||
#endif // Data_ODBC_ODBCStatementImpl_INCLUDED
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_Parameter_INCLUDED
|
||||
#define ODBC_Parameter_INCLUDED
|
||||
#ifndef Data_ODBC_Parameter_INCLUDED
|
||||
#define Data_ODBC_Parameter_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef DataConnectors_ODBC_Preparation_INCLUDED
|
||||
#define DataConnectors_ODBC_Preparation_INCLUDED
|
||||
#ifndef Data_ODBC_Preparation_INCLUDED
|
||||
#define Data_ODBC_Preparation_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
@ -46,8 +46,6 @@
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/Data/AbstractPreparation.h"
|
||||
#include "Poco/Data/BLOB.h"
|
||||
#include "Poco/Data/Date.h"
|
||||
#include "Poco/Data/Time.h"
|
||||
#include "Poco/Any.h"
|
||||
#include "Poco/DynamicAny.h"
|
||||
#include "Poco/DateTime.h"
|
||||
@ -61,11 +59,15 @@
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace ODBC {
|
||||
|
||||
|
||||
class Date;
|
||||
class Time;
|
||||
|
||||
|
||||
namespace ODBC {
|
||||
|
||||
|
||||
class BLOB;
|
||||
|
||||
|
||||
@ -428,4 +430,4 @@ inline Preparation::DataExtraction Preparation::getDataExtraction() const
|
||||
} } } // namespace Poco::Data::ODBC
|
||||
|
||||
|
||||
#endif // DataConnectors_ODBC_Preparation_INCLUDED
|
||||
#endif // Data_ODBC_Preparation_INCLUDED
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef DataConnectors_ODBC_SessionImpl_INCLUDED
|
||||
#define DataConnectors_ODBC_SessionImpl_INCLUDED
|
||||
#ifndef Data_ODBC_SessionImpl_INCLUDED
|
||||
#define Data_ODBC_SessionImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
@ -65,8 +65,8 @@ public:
|
||||
SessionImpl(const std::string& fileName,
|
||||
Poco::Any maxFieldSize = std::size_t(1024),
|
||||
bool enforceCapability=false,
|
||||
bool autoBind=false,
|
||||
bool autoExtract=false);
|
||||
bool autoBind = true,
|
||||
bool autoExtract = true);
|
||||
/// Creates the SessionImpl. Opens a connection to the database
|
||||
|
||||
~SessionImpl();
|
||||
@ -261,4 +261,4 @@ inline bool SessionImpl::isAutoExtract(const std::string& name)
|
||||
} } } // namespace Poco::Data::ODBC
|
||||
|
||||
|
||||
#endif // DataConnectors_ODBC_SessionImpl_INCLUDED
|
||||
#endif // Data_ODBC_SessionImpl_INCLUDED
|
||||
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_DataTypes_INCLUDED
|
||||
#define ODBC_DataTypes_INCLUDED
|
||||
#ifndef Data_ODBC_DataTypes_INCLUDED
|
||||
#define Data_ODBC_DataTypes_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
|
1000
Data/ODBC/include/Poco/Data/ODBC/Unicode.h
Normal file
1000
Data/ODBC/include/Poco/Data/ODBC/Unicode.h
Normal file
File diff suppressed because it is too large
Load Diff
96
Data/ODBC/include/Poco/Data/ODBC/Unicode_UNIX.h
Normal file
96
Data/ODBC/include/Poco/Data/ODBC/Unicode_UNIX.h
Normal file
@ -0,0 +1,96 @@
|
||||
//
|
||||
// Unicode.h
|
||||
//
|
||||
// $Id: //poco/Main/Data/ODBC/include/Poco/Data/ODBC/Unicode_UNIX.h#4 $
|
||||
//
|
||||
// Library: ODBC
|
||||
// Package: ODBC
|
||||
// Module: Unicode_UNIX
|
||||
//
|
||||
// Definition of Unicode_UNIX.
|
||||
//
|
||||
// Copyright (c) 2006, 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.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Data_ODBC_Unicode_UNIX_INCLUDED
|
||||
#define Data_ODBC_Unicode_UNIX_INCLUDED
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace ODBC {
|
||||
|
||||
|
||||
inline void makeUTF16(SQLCHAR* pSQLChar, SQLINTEGER length, Poco::Buffer<SQLWCHAR>& target)
|
||||
/// Utility function for conversion from ASCII to UTF-16
|
||||
{
|
||||
/*TODO
|
||||
int len = length;
|
||||
if (SQL_NTS == len)
|
||||
len = (int) std::strlen((const char *) pSQLChar);
|
||||
|
||||
UnicodeConverter::toUTF16((const char *) pSQLChar, len, target);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
inline void makeUTF16(SQLCHAR* pSQLChar, SQLSMALLINT length, Poco::Buffer<SQLWCHAR>& target)
|
||||
/// Utility function for conversion from ASCII to UTF-16.
|
||||
{
|
||||
/*TODO
|
||||
makeUTF16(pSQLChar, (SQLINTEGER) length, target);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
inline void makeUTF8(Poco::Buffer<SQLWCHAR>& buffer, int length, SQLPOINTER pTarget, SQLINTEGER targetLength)
|
||||
{
|
||||
/*TODO
|
||||
std::string result;
|
||||
UnicodeConverter::toUTF8(buffer.begin(), length, result);
|
||||
|
||||
std::memset(pTarget, 0, targetLength);
|
||||
std::strncpy((char*) pTarget, result.c_str(), result.size() < targetLength ? result.size() : targetLength);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
inline void makeUTF8(Poco::Buffer<SQLWCHAR>& buffer, int length, SQLPOINTER pTarget, SQLSMALLINT targetLength)
|
||||
{
|
||||
/*TODO
|
||||
makeUTF8(buffer, length, pTarget, (SQLINTEGER) targetLength);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
#endif // POCO_ODBC_UNICODE
|
||||
|
||||
|
||||
} } } // namespace Poco::Data::ODBC
|
||||
|
||||
|
||||
#endif // Data_ODBC_Unicode_UNIX_INCLUDED
|
87
Data/ODBC/include/Poco/Data/ODBC/Unicode_WIN32.h
Normal file
87
Data/ODBC/include/Poco/Data/ODBC/Unicode_WIN32.h
Normal file
@ -0,0 +1,87 @@
|
||||
//
|
||||
// Unicode.h
|
||||
//
|
||||
// $Id: //poco/Main/Data/ODBC/include/Poco/Data/ODBC/Unicode_WIN32.h#4 $
|
||||
//
|
||||
// Library: ODBC
|
||||
// Package: ODBC
|
||||
// Module: Unicode_WIN32
|
||||
//
|
||||
// Definition of Unicode_WIN32.
|
||||
//
|
||||
// Copyright (c) 2006, 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.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Data_ODBC_Unicode_WIN32_INCLUDED
|
||||
#define Data_ODBC_Unicode_WIN32_INCLUDED
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace ODBC {
|
||||
|
||||
|
||||
inline void makeUTF16(SQLCHAR* pSQLChar, SQLINTEGER length, std::wstring& target)
|
||||
/// Utility function for conversion from UTF-8 to UTF-16
|
||||
{
|
||||
int len = length;
|
||||
if (SQL_NTS == len)
|
||||
len = (int) std::strlen((const char *) pSQLChar);
|
||||
|
||||
UnicodeConverter::toUTF16((const char *) pSQLChar, len, target);
|
||||
}
|
||||
|
||||
|
||||
inline void makeUTF16(SQLCHAR* pSQLChar, SQLSMALLINT length, std::wstring& target)
|
||||
/// Utility function for conversion from UTF-8 to UTF-16.
|
||||
{
|
||||
makeUTF16(pSQLChar, (SQLINTEGER) length, target);
|
||||
}
|
||||
|
||||
|
||||
inline void makeUTF8(Poco::Buffer<wchar_t>& buffer, int length, SQLPOINTER pTarget, SQLINTEGER targetLength)
|
||||
/// Utility function for conversion from UTF-16 to UTF-8.
|
||||
{
|
||||
std::string result;
|
||||
UnicodeConverter::toUTF8(buffer.begin(), length, result);
|
||||
|
||||
std::memset(pTarget, 0, targetLength);
|
||||
std::strncpy((char*) pTarget, result.c_str(), result.size() < targetLength ? result.size() : targetLength);
|
||||
}
|
||||
|
||||
|
||||
inline void makeUTF8(Poco::Buffer<wchar_t>& buffer, int length, SQLPOINTER pTarget, SQLSMALLINT targetLength)
|
||||
/// Utility function for conversion from UTF-16 to UTF-8.
|
||||
{
|
||||
makeUTF8(buffer, length, pTarget, (SQLINTEGER) targetLength);
|
||||
}
|
||||
|
||||
|
||||
} } } // namespace Poco::Data::ODBC
|
||||
|
||||
|
||||
#endif // Data_ODBC_Unicode_WIN32_INCLUDED
|
@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBC_Utility_INCLUDED
|
||||
#define ODBC_Utility_INCLUDED
|
||||
#ifndef Data_ODBC_Utility_INCLUDED
|
||||
#define Data_ODBC_Utility_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
@ -47,9 +47,6 @@
|
||||
#include "Poco/DateTime.h"
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <sqltypes.h>
|
||||
|
||||
|
||||
|
@ -92,10 +92,10 @@ void Binder::bind(std::size_t pos, const std::string& val, Direction dir)
|
||||
//On Linux, PostgreSQL driver segfaults on SQLGetDescField, so this is disabled for now
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
SQLHDESC hIPD = 0;
|
||||
if (!Utility::isError(SQLGetStmtAttr(_rStmt, SQL_ATTR_IMP_PARAM_DESC, &hIPD, 0, 0)))
|
||||
if (!Utility::isError(SQLGetStmtAttr(_rStmt, SQL_ATTR_IMP_PARAM_DESC, &hIPD, SQL_IS_POINTER, 0)))
|
||||
{
|
||||
SQLUINTEGER sz = 0;
|
||||
if (!Utility::isError(SQLGetDescField(hIPD, (SQLSMALLINT) pos + 1, SQL_DESC_LENGTH, &sz, sizeof(sz), 0)) &&
|
||||
if (!Utility::isError(SQLGetDescField(hIPD, (SQLSMALLINT) pos + 1, SQL_DESC_LENGTH, &sz, SQL_IS_UINTEGER, 0)) &&
|
||||
sz > 0)
|
||||
{
|
||||
size = sz;
|
||||
@ -402,6 +402,18 @@ void Binder::synchronize()
|
||||
}
|
||||
|
||||
|
||||
void Binder::reset()
|
||||
{
|
||||
LengthVec().swap(_lengthIndicator);
|
||||
_inParams.clear();
|
||||
_outParams.clear();
|
||||
_dates.clear();
|
||||
_times.clear();
|
||||
_timestamps.clear();
|
||||
_strings.clear();
|
||||
}
|
||||
|
||||
|
||||
void Binder::getColSizeAndPrecision(std::size_t pos,
|
||||
SQLSMALLINT cDataType,
|
||||
SQLINTEGER& colSize,
|
||||
|
@ -90,7 +90,7 @@ void ODBCColumn::init()
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
reinterpret_cast<long int*>(&_dataLength))))
|
||||
&_dataLength)))
|
||||
{
|
||||
throw StatementException(_rStmt);
|
||||
}
|
||||
|
@ -39,14 +39,19 @@
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/Data/ODBC/ODBCException.h"
|
||||
#include "Poco/Data/AbstractPrepare.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <limits>
|
||||
#include <sql.h>
|
||||
|
||||
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
#undef max
|
||||
#pragma warning(disable:4312)// 'type cast' : conversion from 'Poco::UInt32' to 'SQLPOINTER' of greater size
|
||||
#endif
|
||||
|
||||
|
||||
using Poco::DataFormatException;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace ODBC {
|
||||
@ -117,7 +122,15 @@ void ODBCStatementImpl::makeInternalExtractors()
|
||||
{
|
||||
if (hasData() && !extractions().size())
|
||||
{
|
||||
fillColumns();
|
||||
try
|
||||
{
|
||||
fillColumns();
|
||||
} catch (DataFormatException&)
|
||||
{
|
||||
if (isStoredProcedure()) return;
|
||||
throw;
|
||||
}
|
||||
|
||||
makeExtractors(columnsReturned());
|
||||
fixupExtraction();
|
||||
}
|
||||
@ -219,9 +232,9 @@ void ODBCStatementImpl::putData()
|
||||
{
|
||||
SQLPOINTER pParam = 0;
|
||||
SQLINTEGER dataSize = 0;
|
||||
SQLRETURN rc = SQLParamData(_stmt, &pParam);
|
||||
SQLRETURN rc;
|
||||
|
||||
do
|
||||
while (SQL_NEED_DATA == (rc = SQLParamData(_stmt, &pParam)))
|
||||
{
|
||||
poco_assert_dbg (pParam);
|
||||
dataSize = (SQLINTEGER) _pBinder->parameterSize(pParam);
|
||||
@ -229,7 +242,7 @@ void ODBCStatementImpl::putData()
|
||||
if (Utility::isError(SQLPutData(_stmt, pParam, dataSize)))
|
||||
throw StatementException(_stmt, "SQLPutData()");
|
||||
|
||||
}while (SQL_NEED_DATA == (rc = SQLParamData(_stmt, &pParam)));
|
||||
}
|
||||
|
||||
checkError(rc, "SQLParamData()");
|
||||
}
|
||||
@ -337,9 +350,6 @@ std::string ODBCStatementImpl::nativeSQL()
|
||||
{
|
||||
std::string statement = toString();
|
||||
|
||||
//Hopefully, double the original statement length is enough.
|
||||
//If it is not, the total available length is indicated in the retlen parameter,
|
||||
//which is in turn used to resize the buffer and request the native SQL again.
|
||||
SQLINTEGER length = (SQLINTEGER) statement.size() * 2;
|
||||
|
||||
char* pNative = 0;
|
||||
@ -351,9 +361,9 @@ std::string ODBCStatementImpl::nativeSQL()
|
||||
memset(pNative, 0, retlen);
|
||||
length = retlen;
|
||||
if (Utility::isError(SQLNativeSql(_rConnection,
|
||||
(POCO_SQLCHAR*) statement.c_str(),
|
||||
(SQLCHAR*) statement.c_str(),
|
||||
(SQLINTEGER) statement.size(),
|
||||
(POCO_SQLCHAR*) pNative,
|
||||
(SQLCHAR*) pNative,
|
||||
length,
|
||||
&retlen)))
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ Preparation::Preparation(const StatementHandle& rStmt,
|
||||
_maxFieldSize(maxFieldSize),
|
||||
_dataExtraction(dataExtraction)
|
||||
{
|
||||
POCO_SQLCHAR* pStr = (POCO_SQLCHAR*) statement.c_str();
|
||||
SQLCHAR* pStr = (SQLCHAR*) statement.c_str();
|
||||
if (Utility::isError(SQLPrepare(_rStmt, pStr, (SQLINTEGER) statement.length())))
|
||||
throw StatementException(_rStmt);
|
||||
}
|
||||
@ -162,6 +162,15 @@ void Preparation::prepareImpl(std::size_t pos)
|
||||
case MetaColumn::FDT_BLOB:
|
||||
return prepareRaw<char>(pos, SQL_C_BINARY, maxDataSize(pos));
|
||||
|
||||
case MetaColumn::FDT_DATE:
|
||||
return prepareRaw<Date>(pos, SQL_C_TYPE_DATE, sizeof(SQL_DATE_STRUCT));
|
||||
|
||||
case MetaColumn::FDT_TIME:
|
||||
return prepareRaw<Time>(pos, SQL_C_TYPE_TIME, sizeof(SQL_TIME_STRUCT));
|
||||
|
||||
case MetaColumn::FDT_TIMESTAMP:
|
||||
return prepareRaw<Time>(pos, SQL_C_TYPE_TIMESTAMP, sizeof(SQL_TIMESTAMP_STRUCT));
|
||||
|
||||
default:
|
||||
throw DataFormatException("Unsupported data type.");
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ void SessionImpl::begin()
|
||||
|
||||
void SessionImpl::open()
|
||||
{
|
||||
POCO_SQLCHAR connectOutput[512] = {0};
|
||||
SQLCHAR connectOutput[512] = {0};
|
||||
SQLSMALLINT result;
|
||||
|
||||
if (Utility::isError(SQLDriverConnect(_db
|
||||
, NULL
|
||||
,(POCO_SQLCHAR*) _connect.c_str()
|
||||
,(SQLCHAR*) _connect.c_str()
|
||||
,(SQLSMALLINT) SQL_NTS
|
||||
, connectOutput
|
||||
, sizeof(connectOutput)
|
||||
|
@ -153,30 +153,31 @@ void TypeInfo::fillTypeInfo(SQLHDBC pHDBC)
|
||||
"NUM_PREC_RADIX", 0,
|
||||
"INTERVAL_PRECISION", 0);
|
||||
|
||||
rc = SQLGetData(hstmt, 1, SQL_C_CHAR, typeName, sizeof(typeName), 0);
|
||||
SQLLEN ind = 0;
|
||||
rc = SQLGetData(hstmt, 1, SQL_C_CHAR, typeName, sizeof(typeName), &ind);
|
||||
ti.set<0>(typeName);
|
||||
rc = SQLGetData(hstmt, 2, SQL_C_SSHORT, &ti.get<1>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 3, SQL_C_SLONG, &ti.get<2>(), sizeof(SQLINTEGER), 0);
|
||||
rc = SQLGetData(hstmt, 4, SQL_C_CHAR, literalPrefix, sizeof(literalPrefix), 0);
|
||||
rc = SQLGetData(hstmt, 2, SQL_C_SSHORT, &ti.get<1>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 3, SQL_C_SLONG, &ti.get<2>(), sizeof(SQLINTEGER), &ind);
|
||||
rc = SQLGetData(hstmt, 4, SQL_C_CHAR, literalPrefix, sizeof(literalPrefix), &ind);
|
||||
ti.set<3>(literalPrefix);
|
||||
rc = SQLGetData(hstmt, 5, SQL_C_CHAR, literalSuffix, sizeof(literalSuffix), 0);
|
||||
rc = SQLGetData(hstmt, 5, SQL_C_CHAR, literalSuffix, sizeof(literalSuffix), &ind);
|
||||
ti.set<4>(literalSuffix);
|
||||
rc = SQLGetData(hstmt, 6, SQL_C_CHAR, createParams, sizeof(createParams), 0);
|
||||
rc = SQLGetData(hstmt, 6, SQL_C_CHAR, createParams, sizeof(createParams), &ind);
|
||||
ti.set<5>(createParams);
|
||||
rc = SQLGetData(hstmt, 7, SQL_C_SSHORT, &ti.get<6>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 8, SQL_C_SSHORT, &ti.get<7>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 9, SQL_C_SSHORT, &ti.get<8>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 10, SQL_C_SSHORT, &ti.get<9>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 11, SQL_C_SSHORT, &ti.get<10>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 12, SQL_C_SSHORT, &ti.get<11>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 13, SQL_C_CHAR, localTypeName, sizeof(localTypeName), 0);
|
||||
rc = SQLGetData(hstmt, 7, SQL_C_SSHORT, &ti.get<6>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 8, SQL_C_SSHORT, &ti.get<7>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 9, SQL_C_SSHORT, &ti.get<8>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 10, SQL_C_SSHORT, &ti.get<9>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 11, SQL_C_SSHORT, &ti.get<10>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 12, SQL_C_SSHORT, &ti.get<11>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 13, SQL_C_CHAR, localTypeName, sizeof(localTypeName), &ind);
|
||||
ti.set<12>(localTypeName);
|
||||
rc = SQLGetData(hstmt, 14, SQL_C_SSHORT, &ti.get<13>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 15, SQL_C_SSHORT, &ti.get<14>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 16, SQL_C_SSHORT, &ti.get<15>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 17, SQL_C_SSHORT, &ti.get<16>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 18, SQL_C_SLONG, &ti.get<17>(), sizeof(SQLINTEGER), 0);
|
||||
rc = SQLGetData(hstmt, 19, SQL_C_SSHORT, &ti.get<18>(), sizeof(SQLSMALLINT), 0);
|
||||
rc = SQLGetData(hstmt, 14, SQL_C_SSHORT, &ti.get<13>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 15, SQL_C_SSHORT, &ti.get<14>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 16, SQL_C_SSHORT, &ti.get<15>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 17, SQL_C_SSHORT, &ti.get<16>(), sizeof(SQLSMALLINT), &ind);
|
||||
rc = SQLGetData(hstmt, 18, SQL_C_SLONG, &ti.get<17>(), sizeof(SQLINTEGER), &ind);
|
||||
rc = SQLGetData(hstmt, 19, SQL_C_SSHORT, &ti.get<18>(), sizeof(SQLSMALLINT), &ind);
|
||||
|
||||
_typeInfo.push_back(ti);
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
//
|
||||
// Common.h
|
||||
// Unicode.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Data/include/Poco/Data/Common.h#4 $
|
||||
// $Id: //poco/Main/Data/ODBC/src/Unicode.cpp#3 $
|
||||
//
|
||||
// Library: Data
|
||||
// Package: DataCore
|
||||
// Module: Common
|
||||
//
|
||||
// This header includes a bunch of Poco Data headers needed frequently.
|
||||
// Library: ODBC
|
||||
// Package: ODBC
|
||||
// Module: Unicode
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -36,15 +34,11 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef Data_Common_INCLUDED
|
||||
#define Data_Common_INCLUDED
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
|
||||
|
||||
// Standard include files
|
||||
#include "Poco/Data/Binding.h"
|
||||
#include "Poco/Data/Extraction.h"
|
||||
#include "Poco/Data/Limit.h"
|
||||
#include "Poco/Data/SessionFactory.h"
|
||||
|
||||
|
||||
#endif // Data_Common_INCLUDED
|
||||
#if defined(POCO_ODBC_UNICODE_WINDOWS)
|
||||
#include "Unicode_WIN32.cpp"
|
||||
#elif defined(POCO_ODBC_UNICODE_UNIX)
|
||||
#include "Unicode_UNIX.cpp"
|
||||
#endif
|
785
Data/ODBC/src/Unicode_UNIX.cpp
Normal file
785
Data/ODBC/src/Unicode_UNIX.cpp
Normal file
@ -0,0 +1,785 @@
|
||||
//
|
||||
// Unicode.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Data/ODBC/src/Unicode_UNIX.cpp#3 $
|
||||
//
|
||||
// Library: ODBC
|
||||
// Package: ODBC
|
||||
// Module: Unicode_UNIX
|
||||
//
|
||||
// Copyright (c) 2006, 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/ODBC/ODBC.h"
|
||||
#include "Poco/Buffer.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
using Poco::Buffer;
|
||||
using Poco::InvalidArgumentException;
|
||||
using Poco::NotImplementedException;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace ODBC {
|
||||
|
||||
|
||||
SQLRETURN SQLColAttribute(SQLHSTMT hstmt,
|
||||
SQLUSMALLINT iCol,
|
||||
SQLUSMALLINT iField,
|
||||
SQLPOINTER pCharAttr,
|
||||
SQLSMALLINT cbCharAttrMax,
|
||||
SQLSMALLINT* pcbCharAttr,
|
||||
NumAttrPtrType pNumAttr)
|
||||
{
|
||||
if (isString(pCharAttr, cbCharAttrMax))
|
||||
{
|
||||
if (0 != cbCharAttrMax % 2)
|
||||
--cbCharAttrMax; // must be even for unicode
|
||||
|
||||
Buffer<SQLWCHAR> buffer(stringLength(pCharAttr, cbCharAttrMax));
|
||||
|
||||
SQLRETURN rc = SQLColAttributeW(hstmt,
|
||||
iCol,
|
||||
iField,
|
||||
buffer.begin(),
|
||||
(SQLSMALLINT) buffer.size() * sizeof(SQLWCHAR),
|
||||
pcbCharAttr,
|
||||
pNumAttr);
|
||||
|
||||
makeUTF8(buffer, *pcbCharAttr, pCharAttr, cbCharAttrMax);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return SQLColAttributeW(hstmt,
|
||||
iCol,
|
||||
iField,
|
||||
pCharAttr,
|
||||
cbCharAttrMax,
|
||||
pcbCharAttr,
|
||||
pNumAttr);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLColAttributes(SQLHSTMT hstmt,
|
||||
SQLUSMALLINT icol,
|
||||
SQLUSMALLINT fDescType,
|
||||
SQLPOINTER rgbDesc,
|
||||
SQLSMALLINT cbDescMax,
|
||||
SQLSMALLINT* pcbDesc,
|
||||
SQLLEN* pfDesc)
|
||||
{
|
||||
return SQLColAttribute(hstmt,
|
||||
icol,
|
||||
fDescType,
|
||||
rgbDesc,
|
||||
cbDescMax,
|
||||
pcbDesc,
|
||||
pfDesc);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLConnect(SQLHDBC hdbc,
|
||||
SQLCHAR* szDSN,
|
||||
SQLSMALLINT cbDSN,
|
||||
SQLCHAR* szUID,
|
||||
SQLSMALLINT cbUID,
|
||||
SQLCHAR* szAuthStr,
|
||||
SQLSMALLINT cbAuthStr)
|
||||
{
|
||||
Buffer<SQLWCHAR> sqlDSN(cbDSN);
|
||||
makeUTF16(szDSN, cbDSN, sqlDSN);
|
||||
|
||||
Buffer<SQLWCHAR> sqlUID(cbUID);
|
||||
makeUTF16(szUID, cbUID, sqlUID);
|
||||
|
||||
Buffer<SQLWCHAR> sqlPWD(cbAuthStr);
|
||||
makeUTF16(szAuthStr, cbAuthStr, sqlPWD);
|
||||
|
||||
return SQLConnectW(hdbc,
|
||||
sqlDSN.begin(), cbDSN,
|
||||
sqlUID.begin(), cbUID,
|
||||
sqlPWD.begin(), cbAuthStr);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLDescribeCol(SQLHSTMT hstmt,
|
||||
SQLUSMALLINT icol,
|
||||
SQLCHAR* szColName,
|
||||
SQLSMALLINT cbColNameMax,
|
||||
SQLSMALLINT* pcbColName,
|
||||
SQLSMALLINT* pfSqlType,
|
||||
SQLULEN* pcbColDef,
|
||||
SQLSMALLINT* pibScale,
|
||||
SQLSMALLINT* pfNullable)
|
||||
{
|
||||
if (0 != cbColNameMax % 2)
|
||||
--cbColNameMax; // must be even for unicode
|
||||
|
||||
Buffer<SQLWCHAR> buffer(cbColNameMax);
|
||||
SQLRETURN rc = SQLDescribeColW(hstmt,
|
||||
icol,
|
||||
(SQLWCHAR*) buffer.begin(),
|
||||
cbColNameMax,
|
||||
pcbColName,
|
||||
pfSqlType,
|
||||
pcbColDef,
|
||||
pibScale,
|
||||
pfNullable);
|
||||
|
||||
makeUTF8(buffer, *pcbColName, szColName, cbColNameMax);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLError(SQLHENV henv,
|
||||
SQLHDBC hdbc,
|
||||
SQLHSTMT hstmt,
|
||||
SQLCHAR* szSqlState,
|
||||
SQLINTEGER* pfNativeError,
|
||||
SQLCHAR* szErrorMsg,
|
||||
SQLSMALLINT cbErrorMsgMax,
|
||||
SQLSMALLINT* pcbErrorMsg)
|
||||
{
|
||||
throw NotImplementedException("SQLError is obsolete. "
|
||||
"Use SQLGetDiagRec instead.");
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLExecDirect(SQLHSTMT hstmt,
|
||||
SQLCHAR* szSqlStr,
|
||||
SQLINTEGER cbSqlStr)
|
||||
{
|
||||
Buffer<SQLWCHAR> sqlStr(cbSqlStr);
|
||||
makeUTF16(szSqlStr, cbSqlStr, sqlStr);
|
||||
|
||||
return SQLExecDirectW(hstmt, sqlStr.begin(), cbSqlStr);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetConnectAttr(SQLHDBC hdbc,
|
||||
SQLINTEGER fAttribute,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax,
|
||||
SQLINTEGER* pcbValue)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
if (0 != cbValueMax % 2)
|
||||
--cbValueMax; // must be even for unicode
|
||||
|
||||
Buffer<SQLWCHAR> buffer(stringLength(rgbValue, cbValueMax));
|
||||
|
||||
SQLRETURN rc = SQLGetConnectAttrW(hdbc,
|
||||
fAttribute,
|
||||
buffer.begin(),
|
||||
cbValueMax,
|
||||
pcbValue);
|
||||
|
||||
makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
return SQLGetConnectAttrW(hdbc,
|
||||
fAttribute,
|
||||
rgbValue,
|
||||
cbValueMax,
|
||||
pcbValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetCursorName(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCursor,
|
||||
SQLSMALLINT cbCursorMax,
|
||||
SQLSMALLINT* pcbCursor)
|
||||
{
|
||||
throw NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetDescField(SQLHDESC hdesc,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLSMALLINT iField,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
if (0 != cbValueMax % 2)
|
||||
--cbValueMax; // must be even for unicode
|
||||
|
||||
Buffer<SQLWCHAR> str(cbValueMax);
|
||||
makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str);
|
||||
|
||||
return SQLSetDescFieldW(hdesc,
|
||||
iRecord,
|
||||
iField,
|
||||
(SQLPOINTER) str.begin(),
|
||||
(SQLINTEGER) str.size() * sizeof(SQLWCHAR));
|
||||
}
|
||||
|
||||
return SQLSetDescFieldW(hdesc,
|
||||
iRecord,
|
||||
iField,
|
||||
rgbValue,
|
||||
cbValueMax);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetDescField(SQLHDESC hdesc,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLSMALLINT iField,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax,
|
||||
SQLINTEGER* pcbValue)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
if (0 != cbValueMax % 2)
|
||||
--cbValueMax; // must be even for unicode
|
||||
|
||||
Buffer<SQLWCHAR> buffer(stringLength(rgbValue, cbValueMax));
|
||||
|
||||
SQLRETURN rc = SQLGetDescFieldW(hdesc,
|
||||
iRecord,
|
||||
iField,
|
||||
buffer.begin(),
|
||||
cbValueMax,
|
||||
pcbValue);
|
||||
|
||||
makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
return SQLGetDescFieldW(hdesc,
|
||||
iRecord,
|
||||
iField,
|
||||
rgbValue,
|
||||
cbValueMax,
|
||||
pcbValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetDescRec(SQLHDESC hdesc,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLCHAR* szName,
|
||||
SQLSMALLINT cbNameMax,
|
||||
SQLSMALLINT* pcbName,
|
||||
SQLSMALLINT* pfType,
|
||||
SQLSMALLINT* pfSubType,
|
||||
SQLLEN* pLength,
|
||||
SQLSMALLINT* pPrecision,
|
||||
SQLSMALLINT* pScale,
|
||||
SQLSMALLINT* pNullable)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetDiagField(SQLSMALLINT fHandleType,
|
||||
SQLHANDLE handle,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLSMALLINT fDiagField,
|
||||
SQLPOINTER rgbDiagInfo,
|
||||
SQLSMALLINT cbDiagInfoMax,
|
||||
SQLSMALLINT* pcbDiagInfo)
|
||||
{
|
||||
if (isString(rgbDiagInfo, cbDiagInfoMax))
|
||||
{
|
||||
if (0 != cbDiagInfoMax % 2)
|
||||
--cbDiagInfoMax; // must be even for unicode
|
||||
|
||||
Buffer<SQLWCHAR> buffer(stringLength(rgbDiagInfo, cbDiagInfoMax));
|
||||
|
||||
SQLRETURN rc = SQLGetDiagFieldW(fHandleType,
|
||||
handle,
|
||||
iRecord,
|
||||
fDiagField,
|
||||
buffer.begin(),
|
||||
cbDiagInfoMax,
|
||||
pcbDiagInfo);
|
||||
|
||||
makeUTF8(buffer, *pcbDiagInfo, rgbDiagInfo, cbDiagInfoMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
return SQLGetDiagFieldW(fHandleType,
|
||||
handle,
|
||||
iRecord,
|
||||
fDiagField,
|
||||
rgbDiagInfo,
|
||||
cbDiagInfoMax,
|
||||
pcbDiagInfo);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetDiagRec(SQLSMALLINT fHandleType,
|
||||
SQLHANDLE handle,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLCHAR* szSqlState,
|
||||
SQLINTEGER* pfNativeError,
|
||||
SQLCHAR* szErrorMsg,
|
||||
SQLSMALLINT cbErrorMsgMax,
|
||||
SQLSMALLINT* pcbErrorMsg)
|
||||
{
|
||||
const SQLINTEGER stateLen = SQL_SQLSTATE_SIZE + 1;
|
||||
Buffer<SQLWCHAR> bufState(stateLen);
|
||||
|
||||
if (0 != cbErrorMsgMax % 2)
|
||||
--cbErrorMsgMax; // must be even for unicode
|
||||
|
||||
Buffer<SQLWCHAR> bufErr(cbErrorMsgMax);
|
||||
|
||||
SQLRETURN rc = SQLGetDiagRecW(fHandleType,
|
||||
handle,
|
||||
iRecord,
|
||||
bufState.begin(),
|
||||
pfNativeError,
|
||||
bufErr.begin(),
|
||||
cbErrorMsgMax,
|
||||
pcbErrorMsg);
|
||||
|
||||
makeUTF8(bufState, stateLen, szSqlState, stateLen);
|
||||
makeUTF8(bufErr, *pcbErrorMsg, szErrorMsg, cbErrorMsgMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLPrepare(SQLHSTMT hstmt,
|
||||
SQLCHAR* szSqlStr,
|
||||
SQLINTEGER cbSqlStr)
|
||||
{
|
||||
Buffer<SQLWCHAR> sqlStr(cbSqlStr);
|
||||
makeUTF16(szSqlStr, cbSqlStr, sqlStr);
|
||||
|
||||
return SQLPrepareW(hstmt, sqlStr.begin(), (SQLINTEGER) sqlStr.size());
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetConnectAttr(SQLHDBC hdbc,
|
||||
SQLINTEGER fAttribute,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValue)
|
||||
{
|
||||
if (isString(rgbValue, cbValue))
|
||||
{
|
||||
Buffer<SQLWCHAR> str(cbValue);
|
||||
makeUTF16((SQLCHAR*) rgbValue, cbValue, str);
|
||||
|
||||
return SQLSetConnectAttrW(hdbc,
|
||||
fAttribute,
|
||||
str.begin(),
|
||||
(SQLINTEGER) str.size() * sizeof(SQLWCHAR));
|
||||
}
|
||||
|
||||
return SQLSetConnectAttrW(hdbc, fAttribute, rgbValue, cbValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetCursorName(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCursor,
|
||||
SQLSMALLINT cbCursor)
|
||||
{
|
||||
throw NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetStmtAttr(SQLHSTMT hstmt,
|
||||
SQLINTEGER fAttribute,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
Buffer<SQLWCHAR> str(cbValueMax);
|
||||
makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str);
|
||||
|
||||
return SQLSetStmtAttrW(hstmt,
|
||||
fAttribute,
|
||||
str.begin(),
|
||||
(SQLINTEGER) str.size());
|
||||
}
|
||||
|
||||
return SQLSetStmtAttrW(hstmt, fAttribute, rgbValue, cbValueMax);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetStmtAttr(SQLHSTMT hstmt,
|
||||
SQLINTEGER fAttribute,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax,
|
||||
SQLINTEGER* pcbValue)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
if (0 != cbValueMax % 2)
|
||||
--cbValueMax; // must be even for unicode
|
||||
|
||||
Buffer<SQLWCHAR> buffer(stringLength(rgbValue, cbValueMax));
|
||||
|
||||
return SQLGetStmtAttrW(hstmt,
|
||||
fAttribute,
|
||||
(SQLPOINTER) buffer.begin(),
|
||||
(SQLINTEGER) buffer.size(),
|
||||
pcbValue);
|
||||
}
|
||||
|
||||
return SQLGetStmtAttrW(hstmt, fAttribute, rgbValue, cbValueMax, pcbValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLColumns(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLCHAR* szColumnName,
|
||||
SQLSMALLINT cbColumnName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetConnectOption(SQLHDBC hdbc,
|
||||
SQLUSMALLINT fOption,
|
||||
SQLPOINTER pvParam)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetInfo(SQLHDBC hdbc,
|
||||
SQLUSMALLINT fInfoType,
|
||||
SQLPOINTER rgbInfoValue,
|
||||
SQLSMALLINT cbInfoValueMax,
|
||||
SQLSMALLINT* pcbInfoValue)
|
||||
{
|
||||
if (cbInfoValueMax)
|
||||
{
|
||||
if (0 != cbInfoValueMax % 2)
|
||||
--cbInfoValueMax; // must be even for unicode
|
||||
|
||||
Buffer<SQLWCHAR> buffer(cbInfoValueMax);
|
||||
|
||||
SQLRETURN rc = SQLGetInfoW(hdbc,
|
||||
fInfoType,
|
||||
(SQLPOINTER) buffer.begin(),
|
||||
(SQLSMALLINT) buffer.size() * sizeof(SQLWCHAR),
|
||||
pcbInfoValue);
|
||||
|
||||
makeUTF8(buffer, *pcbInfoValue, rgbInfoValue, cbInfoValueMax);
|
||||
}
|
||||
|
||||
return SQLGetInfoW(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
|
||||
{
|
||||
return SQLGetTypeInfoW(StatementHandle, DataType);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetConnectOption(SQLHDBC hdbc,
|
||||
SQLUSMALLINT fOption,
|
||||
SQLULEN vParam)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSpecialColumns(SQLHSTMT hstmt,
|
||||
SQLUSMALLINT fColType,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLUSMALLINT fScope,
|
||||
SQLUSMALLINT fNullable)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLStatistics(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLUSMALLINT fUnique,
|
||||
SQLUSMALLINT fAccuracy)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLTables(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLCHAR* szTableType,
|
||||
SQLSMALLINT cbTableType)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLDataSources(SQLHENV henv,
|
||||
SQLUSMALLINT fDirection,
|
||||
SQLCHAR* szDSN,
|
||||
SQLSMALLINT cbDSNMax,
|
||||
SQLSMALLINT* pcbDSN,
|
||||
SQLCHAR* szDesc,
|
||||
SQLSMALLINT cbDescMax,
|
||||
SQLSMALLINT* pcbDesc)
|
||||
{
|
||||
Buffer<SQLWCHAR> bufDSN(cbDSNMax);
|
||||
Buffer<SQLWCHAR> bufDesc(cbDescMax);
|
||||
|
||||
SQLRETURN rc = SQLDataSourcesW(henv,
|
||||
fDirection,
|
||||
bufDSN.begin(),
|
||||
(SQLSMALLINT) bufDSN.size(),
|
||||
pcbDSN,
|
||||
bufDesc.begin(),
|
||||
(SQLSMALLINT) bufDesc.size(),
|
||||
pcbDesc);
|
||||
|
||||
makeUTF8(bufDSN, *pcbDSN, szDSN, cbDSNMax);
|
||||
makeUTF8(bufDesc, *pcbDesc, szDesc, cbDescMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLDriverConnect(SQLHDBC hdbc,
|
||||
SQLHWND hwnd,
|
||||
SQLCHAR* szConnStrIn,
|
||||
SQLSMALLINT cbConnStrIn,
|
||||
SQLCHAR* szConnStrOut,
|
||||
SQLSMALLINT cbConnStrOutMax,
|
||||
SQLSMALLINT* pcbConnStrOut,
|
||||
SQLUSMALLINT fDriverCompletion)
|
||||
{
|
||||
SQLSMALLINT len = cbConnStrIn;
|
||||
if (SQL_NTS == len)
|
||||
len = (SQLSMALLINT) std::strlen((const char*) szConnStrIn) + 1;
|
||||
|
||||
Buffer<SQLWCHAR> connStrIn(len);
|
||||
makeUTF16(szConnStrIn, len, connStrIn);
|
||||
|
||||
Buffer<SQLWCHAR> out(cbConnStrOutMax);
|
||||
SQLRETURN rc = SQLDriverConnectW(hdbc,
|
||||
hwnd,
|
||||
connStrIn.begin(),
|
||||
(SQLSMALLINT) connStrIn.size(),
|
||||
out.begin(),
|
||||
cbConnStrOutMax,
|
||||
pcbConnStrOut,
|
||||
fDriverCompletion);
|
||||
|
||||
makeUTF8(out, *pcbConnStrOut, pcbConnStrOut, cbConnStrOutMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLBrowseConnect(SQLHDBC hdbc,
|
||||
SQLCHAR* szConnStrIn,
|
||||
SQLSMALLINT cbConnStrIn,
|
||||
SQLCHAR* szConnStrOut,
|
||||
SQLSMALLINT cbConnStrOutMax,
|
||||
SQLSMALLINT* pcbConnStrOut)
|
||||
{
|
||||
Buffer<SQLWCHAR> str(cbConnStrIn);
|
||||
makeUTF16(szConnStrIn, cbConnStrIn, str);
|
||||
|
||||
Buffer<SQLWCHAR> bufConnStrOut(cbConnStrOutMax);
|
||||
|
||||
SQLRETURN rc = SQLBrowseConnectW(hdbc,
|
||||
str.begin(),
|
||||
(SQLSMALLINT) str.size(),
|
||||
bufConnStrOut.begin(),
|
||||
(SQLSMALLINT) bufConnStrOut.size(),
|
||||
pcbConnStrOut);
|
||||
|
||||
makeUTF8(bufConnStrOut, *pcbConnStrOut, szConnStrOut, cbConnStrOutMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLColumnPrivileges(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLCHAR* szColumnName,
|
||||
SQLSMALLINT cbColumnName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLForeignKeys(SQLHSTMT hstmt,
|
||||
SQLCHAR* szPkCatalogName,
|
||||
SQLSMALLINT cbPkCatalogName,
|
||||
SQLCHAR* szPkSchemaName,
|
||||
SQLSMALLINT cbPkSchemaName,
|
||||
SQLCHAR* szPkTableName,
|
||||
SQLSMALLINT cbPkTableName,
|
||||
SQLCHAR* szFkCatalogName,
|
||||
SQLSMALLINT cbFkCatalogName,
|
||||
SQLCHAR* szFkSchemaName,
|
||||
SQLSMALLINT cbFkSchemaName,
|
||||
SQLCHAR* szFkTableName,
|
||||
SQLSMALLINT cbFkTableName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLNativeSql(SQLHDBC hdbc,
|
||||
SQLCHAR* szSqlStrIn,
|
||||
SQLINTEGER cbSqlStrIn,
|
||||
SQLCHAR* szSqlStr,
|
||||
SQLINTEGER cbSqlStrMax,
|
||||
SQLINTEGER* pcbSqlStr)
|
||||
{
|
||||
Buffer<SQLWCHAR> str(cbSqlStrIn);
|
||||
makeUTF16(szSqlStrIn, cbSqlStrIn, str);
|
||||
|
||||
Buffer<SQLWCHAR> bufSQLOut(cbSqlStrMax);
|
||||
|
||||
SQLRETURN rc = SQLNativeSqlW(hdbc,
|
||||
str.begin(),
|
||||
(SQLINTEGER) str.size(),
|
||||
bufSQLOut.begin(),
|
||||
(SQLINTEGER) bufSQLOut.size(),
|
||||
pcbSqlStr);
|
||||
|
||||
makeUTF8(bufSQLOut, *pcbSqlStr, szSqlStr, cbSqlStrMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLPrimaryKeys(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLProcedureColumns(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szProcName,
|
||||
SQLSMALLINT cbProcName,
|
||||
SQLCHAR* szColumnName,
|
||||
SQLSMALLINT cbColumnName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLProcedures(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szProcName,
|
||||
SQLSMALLINT cbProcName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLTablePrivileges(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLDrivers(SQLHENV henv,
|
||||
SQLUSMALLINT fDirection,
|
||||
SQLCHAR* szDriverDesc,
|
||||
SQLSMALLINT cbDriverDescMax,
|
||||
SQLSMALLINT* pcbDriverDesc,
|
||||
SQLCHAR* szDriverAttributes,
|
||||
SQLSMALLINT cbDrvrAttrMax,
|
||||
SQLSMALLINT* pcbDrvrAttr)
|
||||
{
|
||||
Buffer<SQLWCHAR> bufDriverDesc(cbDriverDescMax);
|
||||
Buffer<SQLWCHAR> bufDriverAttr(cbDrvrAttrMax);
|
||||
|
||||
SQLRETURN rc = SQLDriversW(henv,
|
||||
fDirection,
|
||||
bufDriverDesc.begin(),
|
||||
(SQLSMALLINT) bufDriverDesc.size(),
|
||||
pcbDriverDesc,
|
||||
bufDriverAttr.begin(),
|
||||
(SQLSMALLINT) bufDriverAttr.size(),
|
||||
pcbDrvrAttr);
|
||||
|
||||
makeUTF8(bufDriverDesc, *pcbDriverDesc, szDriverDesc, cbDriverDescMax);
|
||||
makeUTF8(bufDriverAttr, *pcbDrvrAttr, szDriverAttributes, cbDrvrAttrMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
} } } // namespace Poco::Data::ODBC
|
814
Data/ODBC/src/Unicode_WIN32.cpp
Normal file
814
Data/ODBC/src/Unicode_WIN32.cpp
Normal file
@ -0,0 +1,814 @@
|
||||
//
|
||||
// Unicode.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Data/ODBC/src/Unicode_WIN32.cpp#3 $
|
||||
//
|
||||
// Library: ODBC
|
||||
// Package: ODBC
|
||||
// Module: Unicode_WIN32
|
||||
//
|
||||
// Copyright (c) 2006, 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/ODBC/ODBC.h"
|
||||
#include "Poco/Data/ODBC/Unicode_WIN32.h"
|
||||
#include "Poco/Buffer.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
using Poco::Buffer;
|
||||
using Poco::InvalidArgumentException;
|
||||
using Poco::NotImplementedException;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace ODBC {
|
||||
|
||||
|
||||
SQLRETURN SQLColAttribute(SQLHSTMT hstmt,
|
||||
SQLUSMALLINT iCol,
|
||||
SQLUSMALLINT iField,
|
||||
SQLPOINTER pCharAttr,
|
||||
SQLSMALLINT cbCharAttrMax,
|
||||
SQLSMALLINT* pcbCharAttr,
|
||||
NumAttrPtrType pNumAttr)
|
||||
{
|
||||
if (isString(pCharAttr, cbCharAttrMax))
|
||||
{
|
||||
if (0 != cbCharAttrMax % 2)
|
||||
--cbCharAttrMax; // must be even for unicode
|
||||
|
||||
Buffer<wchar_t> buffer(stringLength(pCharAttr, cbCharAttrMax));
|
||||
|
||||
SQLRETURN rc = SQLColAttributeW(hstmt,
|
||||
iCol,
|
||||
iField,
|
||||
buffer.begin(),
|
||||
(SQLSMALLINT) buffer.size() * sizeof(wchar_t),
|
||||
pcbCharAttr,
|
||||
pNumAttr);
|
||||
|
||||
makeUTF8(buffer, *pcbCharAttr, pCharAttr, cbCharAttrMax);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return SQLColAttributeW(hstmt,
|
||||
iCol,
|
||||
iField,
|
||||
pCharAttr,
|
||||
cbCharAttrMax,
|
||||
pcbCharAttr,
|
||||
pNumAttr);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLColAttributes(SQLHSTMT hstmt,
|
||||
SQLUSMALLINT icol,
|
||||
SQLUSMALLINT fDescType,
|
||||
SQLPOINTER rgbDesc,
|
||||
SQLSMALLINT cbDescMax,
|
||||
SQLSMALLINT* pcbDesc,
|
||||
SQLLEN* pfDesc)
|
||||
{
|
||||
return SQLColAttribute(hstmt,
|
||||
icol,
|
||||
fDescType,
|
||||
rgbDesc,
|
||||
cbDescMax,
|
||||
pcbDesc,
|
||||
pfDesc);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLConnect(SQLHDBC hdbc,
|
||||
SQLCHAR* szDSN,
|
||||
SQLSMALLINT cbDSN,
|
||||
SQLCHAR* szUID,
|
||||
SQLSMALLINT cbUID,
|
||||
SQLCHAR* szAuthStr,
|
||||
SQLSMALLINT cbAuthStr)
|
||||
{
|
||||
std::wstring sqlDSN;
|
||||
makeUTF16(szDSN, cbDSN, sqlDSN);
|
||||
|
||||
std::wstring sqlUID;
|
||||
makeUTF16(szUID, cbUID, sqlUID);
|
||||
|
||||
std::wstring sqlPWD;
|
||||
makeUTF16(szAuthStr, cbAuthStr, sqlPWD);
|
||||
|
||||
return SQLConnectW(hdbc,
|
||||
(SQLWCHAR*) sqlDSN.c_str(),
|
||||
(SQLSMALLINT) sqlDSN.size(),
|
||||
(SQLWCHAR*) sqlUID.c_str(),
|
||||
(SQLSMALLINT) sqlUID.size(),
|
||||
(SQLWCHAR*) sqlPWD.c_str(),
|
||||
(SQLSMALLINT) sqlPWD.size());
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLDescribeCol(SQLHSTMT hstmt,
|
||||
SQLUSMALLINT icol,
|
||||
SQLCHAR* szColName,
|
||||
SQLSMALLINT cbColNameMax,
|
||||
SQLSMALLINT* pcbColName,
|
||||
SQLSMALLINT* pfSqlType,
|
||||
SQLULEN* pcbColDef,
|
||||
SQLSMALLINT* pibScale,
|
||||
SQLSMALLINT* pfNullable)
|
||||
{
|
||||
if (0 != cbColNameMax % 2)
|
||||
--cbColNameMax; // must be even for unicode
|
||||
|
||||
Buffer<wchar_t> buffer(cbColNameMax);
|
||||
SQLRETURN rc = SQLDescribeColW(hstmt,
|
||||
icol,
|
||||
(SQLWCHAR*) buffer.begin(),
|
||||
cbColNameMax,
|
||||
pcbColName,
|
||||
pfSqlType,
|
||||
pcbColDef,
|
||||
pibScale,
|
||||
pfNullable);
|
||||
|
||||
makeUTF8(buffer, *pcbColName, szColName, cbColNameMax);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLError(SQLHENV henv,
|
||||
SQLHDBC hdbc,
|
||||
SQLHSTMT hstmt,
|
||||
SQLCHAR* szSqlState,
|
||||
SQLINTEGER* pfNativeError,
|
||||
SQLCHAR* szErrorMsg,
|
||||
SQLSMALLINT cbErrorMsgMax,
|
||||
SQLSMALLINT* pcbErrorMsg)
|
||||
{
|
||||
throw NotImplementedException("SQLError is obsolete. "
|
||||
"Use SQLGetDiagRec instead.");
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLExecDirect(SQLHSTMT hstmt,
|
||||
SQLCHAR* szSqlStr,
|
||||
SQLINTEGER cbSqlStr)
|
||||
{
|
||||
std::wstring sqlStr;
|
||||
makeUTF16(szSqlStr, cbSqlStr, sqlStr);
|
||||
|
||||
return SQLExecDirectW(hstmt,
|
||||
(SQLWCHAR*) sqlStr.c_str(),
|
||||
(SQLINTEGER) sqlStr.size());
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetConnectAttr(SQLHDBC hdbc,
|
||||
SQLINTEGER fAttribute,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax,
|
||||
SQLINTEGER* pcbValue)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
if (0 != cbValueMax % 2)
|
||||
--cbValueMax; // must be even for unicode
|
||||
|
||||
Buffer<wchar_t> buffer(stringLength(rgbValue, cbValueMax));
|
||||
|
||||
SQLRETURN rc = SQLGetConnectAttrW(hdbc,
|
||||
fAttribute,
|
||||
buffer.begin(),
|
||||
cbValueMax,
|
||||
pcbValue);
|
||||
|
||||
makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
return SQLGetConnectAttrW(hdbc,
|
||||
fAttribute,
|
||||
rgbValue,
|
||||
cbValueMax,
|
||||
pcbValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetCursorName(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCursor,
|
||||
SQLSMALLINT cbCursorMax,
|
||||
SQLSMALLINT* pcbCursor)
|
||||
{
|
||||
throw NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetDescField(SQLHDESC hdesc,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLSMALLINT iField,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
if (0 != cbValueMax % 2)
|
||||
--cbValueMax; // must be even for unicode
|
||||
|
||||
std::wstring str;
|
||||
makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str);
|
||||
|
||||
SQLRETURN rc = SQLSetDescFieldW(hdesc,
|
||||
iRecord,
|
||||
iField,
|
||||
(SQLPOINTER) str.c_str(),
|
||||
(SQLINTEGER) str.size() * sizeof(std::wstring::value_type));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
return SQLSetDescFieldW(hdesc,
|
||||
iRecord,
|
||||
iField,
|
||||
rgbValue,
|
||||
cbValueMax);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetDescField(SQLHDESC hdesc,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLSMALLINT iField,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax,
|
||||
SQLINTEGER* pcbValue)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
if (0 != cbValueMax % 2)
|
||||
--cbValueMax; // must be even for unicode
|
||||
|
||||
Buffer<wchar_t> buffer(stringLength(rgbValue, cbValueMax));
|
||||
|
||||
SQLRETURN rc = SQLGetDescFieldW(hdesc,
|
||||
iRecord,
|
||||
iField,
|
||||
buffer.begin(),
|
||||
cbValueMax,
|
||||
pcbValue);
|
||||
|
||||
makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
return SQLGetDescFieldW(hdesc,
|
||||
iRecord,
|
||||
iField,
|
||||
rgbValue,
|
||||
cbValueMax,
|
||||
pcbValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetDescRec(SQLHDESC hdesc,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLCHAR* szName,
|
||||
SQLSMALLINT cbNameMax,
|
||||
SQLSMALLINT* pcbName,
|
||||
SQLSMALLINT* pfType,
|
||||
SQLSMALLINT* pfSubType,
|
||||
SQLLEN* pLength,
|
||||
SQLSMALLINT* pPrecision,
|
||||
SQLSMALLINT* pScale,
|
||||
SQLSMALLINT* pNullable)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetDiagField(SQLSMALLINT fHandleType,
|
||||
SQLHANDLE handle,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLSMALLINT fDiagField,
|
||||
SQLPOINTER rgbDiagInfo,
|
||||
SQLSMALLINT cbDiagInfoMax,
|
||||
SQLSMALLINT* pcbDiagInfo)
|
||||
{
|
||||
if (isString(rgbDiagInfo, cbDiagInfoMax))
|
||||
{
|
||||
if (0 != cbDiagInfoMax % 2)
|
||||
--cbDiagInfoMax; // must be even for unicode
|
||||
|
||||
Buffer<wchar_t> buffer(stringLength(rgbDiagInfo, cbDiagInfoMax));
|
||||
|
||||
SQLRETURN rc = SQLGetDiagFieldW(fHandleType,
|
||||
handle,
|
||||
iRecord,
|
||||
fDiagField,
|
||||
buffer.begin(),
|
||||
cbDiagInfoMax,
|
||||
pcbDiagInfo);
|
||||
|
||||
makeUTF8(buffer, *pcbDiagInfo, rgbDiagInfo, cbDiagInfoMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
return SQLGetDiagFieldW(fHandleType,
|
||||
handle,
|
||||
iRecord,
|
||||
fDiagField,
|
||||
rgbDiagInfo,
|
||||
cbDiagInfoMax,
|
||||
pcbDiagInfo);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetDiagRec(SQLSMALLINT fHandleType,
|
||||
SQLHANDLE handle,
|
||||
SQLSMALLINT iRecord,
|
||||
SQLCHAR* szSqlState,
|
||||
SQLINTEGER* pfNativeError,
|
||||
SQLCHAR* szErrorMsg,
|
||||
SQLSMALLINT cbErrorMsgMax,
|
||||
SQLSMALLINT* pcbErrorMsg)
|
||||
{
|
||||
const SQLINTEGER stateLen = SQL_SQLSTATE_SIZE + 1;
|
||||
Buffer<wchar_t> bufState(stateLen);
|
||||
|
||||
if (0 != cbErrorMsgMax % 2)
|
||||
--cbErrorMsgMax; // must be even for unicode
|
||||
|
||||
Buffer<wchar_t> bufErr(cbErrorMsgMax);
|
||||
|
||||
SQLRETURN rc = SQLGetDiagRecW(fHandleType,
|
||||
handle,
|
||||
iRecord,
|
||||
bufState.begin(),
|
||||
pfNativeError,
|
||||
bufErr.begin(),
|
||||
cbErrorMsgMax,
|
||||
pcbErrorMsg);
|
||||
|
||||
makeUTF8(bufState, stateLen, szSqlState, stateLen);
|
||||
makeUTF8(bufErr, *pcbErrorMsg, szErrorMsg, cbErrorMsgMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLPrepare(SQLHSTMT hstmt,
|
||||
SQLCHAR* szSqlStr,
|
||||
SQLINTEGER cbSqlStr)
|
||||
{
|
||||
std::wstring sqlStr;
|
||||
makeUTF16(szSqlStr, cbSqlStr, sqlStr);
|
||||
|
||||
return SQLPrepareW(hstmt,
|
||||
(SQLWCHAR*) sqlStr.c_str(),
|
||||
(SQLINTEGER) sqlStr.size());
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetConnectAttr(SQLHDBC hdbc,
|
||||
SQLINTEGER fAttribute,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValue)
|
||||
{
|
||||
if (isString(rgbValue, cbValue))
|
||||
{
|
||||
std::wstring str;
|
||||
makeUTF16((SQLCHAR*) rgbValue, cbValue, str);
|
||||
|
||||
return SQLSetConnectAttrW(hdbc,
|
||||
fAttribute,
|
||||
(SQLWCHAR*) str.c_str(),
|
||||
(SQLINTEGER) str.size() * sizeof(std::wstring::value_type));
|
||||
}
|
||||
|
||||
return SQLSetConnectAttrW(hdbc,
|
||||
fAttribute,
|
||||
rgbValue,
|
||||
cbValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetCursorName(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCursor,
|
||||
SQLSMALLINT cbCursor)
|
||||
{
|
||||
throw NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetStmtAttr(SQLHSTMT hstmt,
|
||||
SQLINTEGER fAttribute,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
std::wstring str;
|
||||
makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str);
|
||||
|
||||
return SQLSetStmtAttrW(hstmt,
|
||||
fAttribute,
|
||||
(SQLPOINTER) str.c_str(),
|
||||
(SQLINTEGER) str.size());
|
||||
}
|
||||
|
||||
return SQLSetStmtAttrW(hstmt,
|
||||
fAttribute,
|
||||
rgbValue,
|
||||
cbValueMax);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetStmtAttr(SQLHSTMT hstmt,
|
||||
SQLINTEGER fAttribute,
|
||||
SQLPOINTER rgbValue,
|
||||
SQLINTEGER cbValueMax,
|
||||
SQLINTEGER* pcbValue)
|
||||
{
|
||||
if (isString(rgbValue, cbValueMax))
|
||||
{
|
||||
if (0 != cbValueMax % 2)
|
||||
--cbValueMax; // must be even for unicode
|
||||
|
||||
Buffer<wchar_t> buffer(stringLength(rgbValue, cbValueMax));
|
||||
|
||||
return SQLGetStmtAttrW(hstmt,
|
||||
fAttribute,
|
||||
(SQLPOINTER) buffer.begin(),
|
||||
(SQLINTEGER) buffer.size(),
|
||||
pcbValue);
|
||||
}
|
||||
|
||||
return SQLGetStmtAttrW(hstmt,
|
||||
fAttribute,
|
||||
rgbValue,
|
||||
cbValueMax,
|
||||
pcbValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLColumns(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLCHAR* szColumnName,
|
||||
SQLSMALLINT cbColumnName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetConnectOption(SQLHDBC hdbc,
|
||||
SQLUSMALLINT fOption,
|
||||
SQLPOINTER pvParam)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetInfo(SQLHDBC hdbc,
|
||||
SQLUSMALLINT fInfoType,
|
||||
SQLPOINTER rgbInfoValue,
|
||||
SQLSMALLINT cbInfoValueMax,
|
||||
SQLSMALLINT* pcbInfoValue)
|
||||
{
|
||||
if (cbInfoValueMax)
|
||||
{
|
||||
if (0 != cbInfoValueMax % 2)
|
||||
--cbInfoValueMax; // must be even for unicode
|
||||
|
||||
Buffer<wchar_t> buffer(cbInfoValueMax);
|
||||
|
||||
SQLRETURN rc = SQLGetInfoW(hdbc,
|
||||
fInfoType,
|
||||
(SQLPOINTER) buffer.begin(),
|
||||
(SQLSMALLINT) buffer.size() * sizeof(wchar_t),
|
||||
pcbInfoValue);
|
||||
|
||||
makeUTF8(buffer, *pcbInfoValue, rgbInfoValue, cbInfoValueMax);
|
||||
}
|
||||
|
||||
return SQLGetInfoW(hdbc,
|
||||
fInfoType,
|
||||
rgbInfoValue,
|
||||
cbInfoValueMax,
|
||||
pcbInfoValue);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
|
||||
{
|
||||
return SQLGetTypeInfoW(StatementHandle, DataType);
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSetConnectOption(SQLHDBC hdbc,
|
||||
SQLUSMALLINT fOption,
|
||||
SQLULEN vParam)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLSpecialColumns(SQLHSTMT hstmt,
|
||||
SQLUSMALLINT fColType,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLUSMALLINT fScope,
|
||||
SQLUSMALLINT fNullable)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLStatistics(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLUSMALLINT fUnique,
|
||||
SQLUSMALLINT fAccuracy)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLTables(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLCHAR* szTableType,
|
||||
SQLSMALLINT cbTableType)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLDataSources(SQLHENV henv,
|
||||
SQLUSMALLINT fDirection,
|
||||
SQLCHAR* szDSN,
|
||||
SQLSMALLINT cbDSNMax,
|
||||
SQLSMALLINT* pcbDSN,
|
||||
SQLCHAR* szDesc,
|
||||
SQLSMALLINT cbDescMax,
|
||||
SQLSMALLINT* pcbDesc)
|
||||
{
|
||||
Buffer<wchar_t> bufDSN(cbDSNMax);
|
||||
Buffer<wchar_t> bufDesc(cbDescMax);
|
||||
|
||||
SQLRETURN rc = SQLDataSourcesW(henv,
|
||||
fDirection,
|
||||
bufDSN.begin(),
|
||||
(SQLSMALLINT) bufDSN.size(),
|
||||
pcbDSN,
|
||||
bufDesc.begin(),
|
||||
(SQLSMALLINT) bufDesc.size(),
|
||||
pcbDesc);
|
||||
|
||||
makeUTF8(bufDSN, *pcbDSN, szDSN, cbDSNMax);
|
||||
makeUTF8(bufDesc, *pcbDesc, szDesc, cbDescMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLDriverConnect(SQLHDBC hdbc,
|
||||
SQLHWND hwnd,
|
||||
SQLCHAR* szConnStrIn,
|
||||
SQLSMALLINT cbConnStrIn,
|
||||
SQLCHAR* szConnStrOut,
|
||||
SQLSMALLINT cbConnStrOutMax,
|
||||
SQLSMALLINT* pcbConnStrOut,
|
||||
SQLUSMALLINT fDriverCompletion)
|
||||
{
|
||||
std::wstring connStrIn;
|
||||
int len = cbConnStrIn;
|
||||
if (SQL_NTS == len)
|
||||
len = (int) std::strlen((const char*) szConnStrIn);
|
||||
|
||||
Poco::UnicodeConverter::toUTF16((const char *) szConnStrIn, len, connStrIn);
|
||||
|
||||
SQLWCHAR* pOut = new SQLWCHAR[cbConnStrOutMax];
|
||||
SQLRETURN rc = SQLDriverConnectW(hdbc,
|
||||
hwnd,
|
||||
(SQLWCHAR*) connStrIn.c_str(),
|
||||
(SQLSMALLINT) connStrIn.size(),
|
||||
pOut,
|
||||
cbConnStrOutMax,
|
||||
pcbConnStrOut,
|
||||
fDriverCompletion);
|
||||
|
||||
std::string result;
|
||||
Poco::UnicodeConverter::toUTF8((const wchar_t*) pOut, (int) cbConnStrOutMax, result);
|
||||
memset(szConnStrOut, 0, cbConnStrOutMax);
|
||||
std::strncpy((char*) szConnStrOut, result.c_str(), cbConnStrOutMax);
|
||||
|
||||
delete [] pOut;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLBrowseConnect(SQLHDBC hdbc,
|
||||
SQLCHAR* szConnStrIn,
|
||||
SQLSMALLINT cbConnStrIn,
|
||||
SQLCHAR* szConnStrOut,
|
||||
SQLSMALLINT cbConnStrOutMax,
|
||||
SQLSMALLINT* pcbConnStrOut)
|
||||
{
|
||||
std::wstring str;
|
||||
makeUTF16(szConnStrIn, cbConnStrIn, str);
|
||||
|
||||
Buffer<wchar_t> bufConnStrOut(cbConnStrOutMax);
|
||||
|
||||
SQLRETURN rc = SQLBrowseConnectW(hdbc,
|
||||
(SQLWCHAR*) str.c_str(),
|
||||
(SQLSMALLINT) str.size(),
|
||||
bufConnStrOut.begin(),
|
||||
(SQLSMALLINT) bufConnStrOut.size(),
|
||||
pcbConnStrOut);
|
||||
|
||||
makeUTF8(bufConnStrOut, *pcbConnStrOut, szConnStrOut, cbConnStrOutMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLColumnPrivileges(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName,
|
||||
SQLCHAR* szColumnName,
|
||||
SQLSMALLINT cbColumnName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLForeignKeys(SQLHSTMT hstmt,
|
||||
SQLCHAR* szPkCatalogName,
|
||||
SQLSMALLINT cbPkCatalogName,
|
||||
SQLCHAR* szPkSchemaName,
|
||||
SQLSMALLINT cbPkSchemaName,
|
||||
SQLCHAR* szPkTableName,
|
||||
SQLSMALLINT cbPkTableName,
|
||||
SQLCHAR* szFkCatalogName,
|
||||
SQLSMALLINT cbFkCatalogName,
|
||||
SQLCHAR* szFkSchemaName,
|
||||
SQLSMALLINT cbFkSchemaName,
|
||||
SQLCHAR* szFkTableName,
|
||||
SQLSMALLINT cbFkTableName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLNativeSql(SQLHDBC hdbc,
|
||||
SQLCHAR* szSqlStrIn,
|
||||
SQLINTEGER cbSqlStrIn,
|
||||
SQLCHAR* szSqlStr,
|
||||
SQLINTEGER cbSqlStrMax,
|
||||
SQLINTEGER* pcbSqlStr)
|
||||
{
|
||||
std::wstring str;
|
||||
makeUTF16(szSqlStrIn, cbSqlStrIn, str);
|
||||
|
||||
Buffer<wchar_t> bufSQLOut(cbSqlStrMax);
|
||||
|
||||
SQLRETURN rc = SQLNativeSqlW(hdbc,
|
||||
(SQLWCHAR*) str.c_str(),
|
||||
(SQLINTEGER) str.size(),
|
||||
bufSQLOut.begin(),
|
||||
(SQLINTEGER) bufSQLOut.size(),
|
||||
pcbSqlStr);
|
||||
|
||||
makeUTF8(bufSQLOut, *pcbSqlStr, szSqlStr, cbSqlStrMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLPrimaryKeys(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLProcedureColumns(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szProcName,
|
||||
SQLSMALLINT cbProcName,
|
||||
SQLCHAR* szColumnName,
|
||||
SQLSMALLINT cbColumnName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLProcedures(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szProcName,
|
||||
SQLSMALLINT cbProcName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLTablePrivileges(SQLHSTMT hstmt,
|
||||
SQLCHAR* szCatalogName,
|
||||
SQLSMALLINT cbCatalogName,
|
||||
SQLCHAR* szSchemaName,
|
||||
SQLSMALLINT cbSchemaName,
|
||||
SQLCHAR* szTableName,
|
||||
SQLSMALLINT cbTableName)
|
||||
{
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
SQLRETURN SQLDrivers(SQLHENV henv,
|
||||
SQLUSMALLINT fDirection,
|
||||
SQLCHAR* szDriverDesc,
|
||||
SQLSMALLINT cbDriverDescMax,
|
||||
SQLSMALLINT* pcbDriverDesc,
|
||||
SQLCHAR* szDriverAttributes,
|
||||
SQLSMALLINT cbDrvrAttrMax,
|
||||
SQLSMALLINT* pcbDrvrAttr)
|
||||
{
|
||||
Buffer<wchar_t> bufDriverDesc(cbDriverDescMax);
|
||||
Buffer<wchar_t> bufDriverAttr(cbDrvrAttrMax);
|
||||
|
||||
SQLRETURN rc = SQLDriversW(henv,
|
||||
fDirection,
|
||||
bufDriverDesc.begin(),
|
||||
(SQLSMALLINT) bufDriverDesc.size(),
|
||||
pcbDriverDesc,
|
||||
bufDriverAttr.begin(),
|
||||
(SQLSMALLINT) bufDriverAttr.size(),
|
||||
pcbDrvrAttr);
|
||||
|
||||
makeUTF8(bufDriverDesc, *pcbDriverDesc, szDriverDesc, cbDriverDescMax);
|
||||
makeUTF8(bufDriverAttr, *pcbDrvrAttr, szDriverAttributes, cbDrvrAttrMax);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
} } } // namespace Poco::Data::ODBC
|
@ -53,12 +53,12 @@ const TypeInfo Utility::_dataTypes;
|
||||
Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
|
||||
{
|
||||
static const EnvironmentHandle henv;
|
||||
const int length = sizeof(POCO_SQLCHAR) * 512;
|
||||
const int length = sizeof(SQLCHAR) * 512;
|
||||
|
||||
POCO_SQLCHAR desc[length];
|
||||
SQLCHAR desc[length];
|
||||
memset(desc, 0, length);
|
||||
SQLSMALLINT len1 = length;
|
||||
POCO_SQLCHAR attr[length];
|
||||
SQLCHAR attr[length];
|
||||
memset(attr, 0, length);
|
||||
SQLSMALLINT len2 = length;
|
||||
RETCODE rc = 0;
|
||||
@ -89,13 +89,13 @@ Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
|
||||
Utility::DSNMap& Utility::dataSources(Utility::DSNMap& dsnMap)
|
||||
{
|
||||
static const EnvironmentHandle henv;
|
||||
const int length = sizeof(POCO_SQLCHAR) * 512;
|
||||
const int dsnLength = sizeof(POCO_SQLCHAR) * (SQL_MAX_DSN_LENGTH + 1);
|
||||
const int length = sizeof(SQLCHAR) * 512;
|
||||
const int dsnLength = sizeof(SQLCHAR) * (SQL_MAX_DSN_LENGTH + 1);
|
||||
|
||||
POCO_SQLCHAR dsn[dsnLength];
|
||||
SQLCHAR dsn[dsnLength];
|
||||
memset(dsn, 0, dsnLength);
|
||||
SQLSMALLINT len1 = sizeof(POCO_SQLCHAR) * SQL_MAX_DSN_LENGTH;
|
||||
POCO_SQLCHAR desc[length];
|
||||
SQLSMALLINT len1 = sizeof(SQLCHAR) * SQL_MAX_DSN_LENGTH;
|
||||
SQLCHAR desc[length];
|
||||
memset(desc, 0, length);
|
||||
SQLSMALLINT len2 = length;
|
||||
RETCODE rc = 0;
|
||||
|
@ -1,28 +1,27 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id: //poco/Main/Data/ODBC/testsuite/Makefile#1 $
|
||||
#
|
||||
# Makefile for Poco SQLite testsuite
|
||||
#
|
||||
|
||||
include $(POCO_BASE)/build/rules/global
|
||||
|
||||
ifeq (0, $(shell test -e /usr/lib/libodbc.so; echo $$?))
|
||||
SYSLIBS += -lodbc -lodbcinst
|
||||
else ifeq (0, $(shell test -e /usr/lib/libiodbc.so; echo $$?))
|
||||
SYSLIBS += -liodbc -liodbcinst
|
||||
else
|
||||
$(error No ODBC library found. Please install unixODBC or iODBC and try again)
|
||||
endif
|
||||
|
||||
objects = ODBCTestSuite Driver \
|
||||
ODBCDB2Test ODBCMySQLTest ODBCOracleTest \
|
||||
ODBCPostgreSQLTest ODBCSQLiteTest ODBCSQLServerTest \
|
||||
SQLExecutor
|
||||
|
||||
target = testrunner
|
||||
target_version = 1
|
||||
target_libs = PocoODBC PocoData PocoFoundation CppUnit
|
||||
|
||||
include $(POCO_BASE)/build/rules/exec
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id: //poco/Main/Data/ODBC/testsuite/Makefile#1 $
|
||||
#
|
||||
# Makefile for Poco SQLite testsuite
|
||||
#
|
||||
|
||||
include $(POCO_BASE)/build/rules/global
|
||||
|
||||
ifeq (0, $(shell test -e /usr/lib/libodbc.so; echo $$?))
|
||||
SYSLIBS += -lodbc -lodbcinst
|
||||
else ifeq (0, $(shell test -e /usr/lib/libiodbc.so; echo $$?))
|
||||
SYSLIBS += -liodbc -liodbcinst
|
||||
else
|
||||
$(error No ODBC library found. Please install unixODBC or iODBC and try again)
|
||||
endif
|
||||
|
||||
objects = ODBCTestSuite Driver \
|
||||
ODBCDB2Test ODBCMySQLTest ODBCOracleTest ODBCPostgreSQLTest \
|
||||
ODBCSQLiteTest ODBCSQLServerTest ODBCTest SQLExecutor
|
||||
|
||||
target = testrunner
|
||||
target_version = 1
|
||||
target_libs = PocoODBC PocoData PocoFoundation CppUnit
|
||||
|
||||
include $(POCO_BASE)/build/rules/exec
|
||||
|
@ -228,6 +228,10 @@
|
||||
RelativePath=".\src\ODBCSQLServerTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\ODBCTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SQLExecutor.h"
|
||||
>
|
||||
@ -264,6 +268,10 @@
|
||||
RelativePath=".\src\ODBCSQLServerTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\ODBCTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SQLExecutor.cpp"
|
||||
>
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Data/Common.h"
|
||||
#include "Poco/Data/BLOB.h"
|
||||
#include "Poco/Data/StatementImpl.h"
|
||||
#include "Poco/Data/ODBC/Connector.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,14 +37,10 @@
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/Session.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "SQLExecutor.h"
|
||||
#include "ODBCTest.h"
|
||||
|
||||
|
||||
class ODBCDB2Test: public CppUnit::TestCase
|
||||
class ODBCDB2Test: public ODBCTest
|
||||
/// IBM DB2 UDB ODBC test class
|
||||
/// Tested:
|
||||
///
|
||||
@ -58,95 +54,16 @@ public:
|
||||
|
||||
void testBareboneODBC();
|
||||
|
||||
void testSimpleAccess();
|
||||
void testComplexType();
|
||||
|
||||
void testSimpleAccessVector();
|
||||
void testComplexTypeVector();
|
||||
void testInsertVector();
|
||||
void testInsertEmptyVector();
|
||||
|
||||
void testSimpleAccessList();
|
||||
void testComplexTypeList();
|
||||
void testInsertList();
|
||||
void testInsertEmptyList();
|
||||
|
||||
void testSimpleAccessDeque();
|
||||
void testComplexTypeDeque();
|
||||
void testInsertDeque();
|
||||
void testInsertEmptyDeque();
|
||||
|
||||
void testInsertSingleBulk();
|
||||
void testInsertSingleBulkVec();
|
||||
|
||||
void testLimit();
|
||||
void testLimitOnce();
|
||||
void testLimitPrepare();
|
||||
void testLimitZero();
|
||||
void testPrepare();
|
||||
void testStep();
|
||||
|
||||
void testSetSimple();
|
||||
void testSetComplex();
|
||||
void testSetComplexUnique();
|
||||
void testMultiSetSimple();
|
||||
void testMultiSetComplex();
|
||||
void testMapComplex();
|
||||
void testMapComplexUnique();
|
||||
void testMultiMapComplex();
|
||||
void testSelectIntoSingle();
|
||||
void testSelectIntoSingleStep();
|
||||
void testSelectIntoSingleFail();
|
||||
void testLowerLimitOk();
|
||||
void testLowerLimitFail();
|
||||
void testCombinedLimits();
|
||||
void testCombinedIllegalLimits();
|
||||
void testRange();
|
||||
void testIllegalRange();
|
||||
void testSingleSelect();
|
||||
void testEmptyDB();
|
||||
|
||||
void testBLOB();
|
||||
void testBLOBStmt();
|
||||
|
||||
void testDate();
|
||||
void testTime();
|
||||
void testDateTime();
|
||||
|
||||
void testFloat();
|
||||
void testDouble();
|
||||
|
||||
void testTuple();
|
||||
void testTupleVector();
|
||||
|
||||
void testInternalExtraction();
|
||||
void testInternalStorageType();
|
||||
|
||||
|
||||
void testStoredProcedure();
|
||||
void testStoredProcedureAny();
|
||||
void testStoredProcedureDynamicAny();
|
||||
void testStoredFunction();
|
||||
|
||||
void testNull();
|
||||
void testRowIterator();
|
||||
|
||||
void testAsync();
|
||||
|
||||
void testAny();
|
||||
void testDynamicAny();
|
||||
|
||||
void testMultipleResults();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
typedef Poco::Data::ODBC::Utility::DriverMap Drivers;
|
||||
typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr;
|
||||
typedef Poco::SharedPtr<SQLExecutor> ExecPtr;
|
||||
|
||||
void dropObject(const std::string& type, const std::string& tableName);
|
||||
void recreatePersonTable();
|
||||
void recreatePersonBLOBTable();
|
||||
@ -161,14 +78,13 @@ private:
|
||||
void recreateAnysTable();
|
||||
void recreateNullsTable(const std::string& notNull = "");
|
||||
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Drivers _drivers;
|
||||
static std::string _dbConnString;
|
||||
static SessionPtr _pSession;
|
||||
static ExecPtr _pExecutor;
|
||||
static const bool bindValues[8];
|
||||
static ODBCTest::SessionPtr _pSession;
|
||||
static ODBCTest::ExecPtr _pExecutor;
|
||||
static std::string _driver;
|
||||
static std::string _dsn;
|
||||
static std::string _uid;
|
||||
static std::string _pwd;
|
||||
static std::string _connectString;
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,14 +37,10 @@
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/Session.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "SQLExecutor.h"
|
||||
#include "ODBCTest.h"
|
||||
|
||||
|
||||
class ODBCMySQLTest: public CppUnit::TestCase
|
||||
class ODBCMySQLTest: public ODBCTest
|
||||
/// MySQL ODBC test class
|
||||
/// Tested:
|
||||
///
|
||||
@ -61,92 +57,18 @@ public:
|
||||
|
||||
void testBareboneODBC();
|
||||
|
||||
void testSimpleAccess();
|
||||
void testComplexType();
|
||||
|
||||
void testSimpleAccessVector();
|
||||
void testComplexTypeVector();
|
||||
void testInsertVector();
|
||||
void testInsertEmptyVector();
|
||||
|
||||
void testSimpleAccessList();
|
||||
void testComplexTypeList();
|
||||
void testInsertList();
|
||||
void testInsertEmptyList();
|
||||
|
||||
void testSimpleAccessDeque();
|
||||
void testComplexTypeDeque();
|
||||
void testInsertDeque();
|
||||
void testInsertEmptyDeque();
|
||||
|
||||
void testInsertSingleBulk();
|
||||
void testInsertSingleBulkVec();
|
||||
|
||||
void testLimit();
|
||||
void testLimitOnce();
|
||||
void testLimitPrepare();
|
||||
void testLimitZero();
|
||||
void testPrepare();
|
||||
void testStep();
|
||||
|
||||
void testSetSimple();
|
||||
void testSetComplex();
|
||||
void testSetComplexUnique();
|
||||
void testMultiSetSimple();
|
||||
void testMultiSetComplex();
|
||||
void testMapComplex();
|
||||
void testMapComplexUnique();
|
||||
void testMultiMapComplex();
|
||||
void testSelectIntoSingle();
|
||||
void testSelectIntoSingleStep();
|
||||
void testSelectIntoSingleFail();
|
||||
void testLowerLimitOk();
|
||||
void testLowerLimitFail();
|
||||
void testCombinedLimits();
|
||||
void testCombinedIllegalLimits();
|
||||
void testRange();
|
||||
void testIllegalRange();
|
||||
void testSingleSelect();
|
||||
void testEmptyDB();
|
||||
|
||||
void testBLOB();
|
||||
void testBLOBStmt();
|
||||
|
||||
void testDate();
|
||||
void testTime();
|
||||
void testDateTime();
|
||||
void testFloat();
|
||||
void testDouble();
|
||||
|
||||
void testTuple();
|
||||
void testTupleVector();
|
||||
|
||||
void testInternalExtraction();
|
||||
void testInternalStorageType();
|
||||
|
||||
void testStoredProcedure();
|
||||
void testStoredFunction();
|
||||
|
||||
void testNull();
|
||||
void testRowIterator();
|
||||
|
||||
void testAsync();
|
||||
|
||||
void testAny();
|
||||
void testDynamicAny();
|
||||
|
||||
|
||||
void testMultipleResults();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
typedef Poco::Data::ODBC::Utility::DriverMap Drivers;
|
||||
typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr;
|
||||
typedef Poco::SharedPtr<SQLExecutor> ExecPtr;
|
||||
|
||||
void dropObject(const std::string& type, const std::string& name);
|
||||
void recreatePersonTable();
|
||||
void recreatePersonBLOBTable();
|
||||
@ -161,14 +83,13 @@ private:
|
||||
void recreateAnysTable();
|
||||
void recreateNullsTable(const std::string& notNull = "");
|
||||
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Drivers _drivers;
|
||||
static std::string _dbConnString;
|
||||
static SessionPtr _pSession;
|
||||
static ExecPtr _pExecutor;
|
||||
static const bool bindValues[8];
|
||||
static ODBCTest::SessionPtr _pSession;
|
||||
static ODBCTest::ExecPtr _pExecutor;
|
||||
static std::string _driver;
|
||||
static std::string _dsn;
|
||||
static std::string _uid;
|
||||
static std::string _pwd;
|
||||
static std::string _connectString;
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,14 +37,10 @@
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/Session.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "SQLExecutor.h"
|
||||
#include "ODBCTest.h"
|
||||
|
||||
|
||||
class ODBCOracleTest: public CppUnit::TestCase
|
||||
class ODBCOracleTest: public ODBCTest
|
||||
/// Oracle ODBC test class
|
||||
/// Tested:
|
||||
///
|
||||
@ -59,67 +55,9 @@ public:
|
||||
|
||||
void testBareboneODBC();
|
||||
|
||||
void testSimpleAccess();
|
||||
void testComplexType();
|
||||
|
||||
void testSimpleAccessVector();
|
||||
void testComplexTypeVector();
|
||||
void testInsertVector();
|
||||
void testInsertEmptyVector();
|
||||
|
||||
void testSimpleAccessList();
|
||||
void testComplexTypeList();
|
||||
void testInsertList();
|
||||
void testInsertEmptyList();
|
||||
|
||||
void testSimpleAccessDeque();
|
||||
void testComplexTypeDeque();
|
||||
void testInsertDeque();
|
||||
void testInsertEmptyDeque();
|
||||
|
||||
void testInsertSingleBulk();
|
||||
void testInsertSingleBulkVec();
|
||||
|
||||
void testLimit();
|
||||
void testLimitOnce();
|
||||
void testLimitPrepare();
|
||||
void testLimitZero();
|
||||
void testPrepare();
|
||||
void testStep();
|
||||
|
||||
void testSetSimple();
|
||||
void testSetComplex();
|
||||
void testSetComplexUnique();
|
||||
void testMultiSetSimple();
|
||||
void testMultiSetComplex();
|
||||
void testMapComplex();
|
||||
void testMapComplexUnique();
|
||||
void testMultiMapComplex();
|
||||
void testSelectIntoSingle();
|
||||
void testSelectIntoSingleStep();
|
||||
void testSelectIntoSingleFail();
|
||||
void testLowerLimitOk();
|
||||
void testLowerLimitFail();
|
||||
void testCombinedLimits();
|
||||
void testCombinedIllegalLimits();
|
||||
void testRange();
|
||||
void testIllegalRange();
|
||||
void testSingleSelect();
|
||||
void testEmptyDB();
|
||||
|
||||
void testBLOB();
|
||||
void testBLOBStmt();
|
||||
|
||||
void testDate();
|
||||
void testDateTime();
|
||||
void testFloat();
|
||||
void testDouble();
|
||||
|
||||
void testTuple();
|
||||
void testTupleVector();
|
||||
|
||||
void testInternalExtraction();
|
||||
void testInternalStorageType();
|
||||
|
||||
void testMultipleResults();
|
||||
|
||||
void testStoredProcedure();
|
||||
void testCursorStoredProcedure();
|
||||
@ -129,25 +67,9 @@ public:
|
||||
void testStoredProcedureDynamicAny();
|
||||
|
||||
void testNull();
|
||||
void testRowIterator();
|
||||
|
||||
void testAsync();
|
||||
|
||||
void testAny();
|
||||
void testDynamicAny();
|
||||
|
||||
void testMultipleResults();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
typedef Poco::Data::ODBC::Utility::DriverMap Drivers;
|
||||
typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr;
|
||||
typedef Poco::SharedPtr<SQLExecutor> ExecPtr;
|
||||
|
||||
static void testBarebone();
|
||||
|
||||
void dropObject(const std::string& type, const std::string& name);
|
||||
@ -163,14 +85,14 @@ private:
|
||||
void recreateAnysTable();
|
||||
void recreateNullsTable(const std::string& notNull = "");
|
||||
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
static ODBCTest::SessionPtr _pSession;
|
||||
static ODBCTest::ExecPtr _pExecutor;
|
||||
static std::string _driver;
|
||||
static std::string _dsn;
|
||||
static std::string _uid;
|
||||
static std::string _pwd;
|
||||
static std::string _connectString;
|
||||
|
||||
static Drivers _drivers;
|
||||
static std::string _dbConnString;
|
||||
static SessionPtr _pSession;
|
||||
static ExecPtr _pExecutor;
|
||||
static const bool bindValues[8];
|
||||
static const std::string MULTI_INSERT;
|
||||
static const std::string MULTI_SELECT;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,18 +37,14 @@
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/Session.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "SQLExecutor.h"
|
||||
#include "ODBCTest.h"
|
||||
|
||||
|
||||
// uncomment to use Mammoth ODBCng driver
|
||||
#define POCO_ODBC_USE_MAMMOTH_NG
|
||||
//#define POCO_ODBC_USE_MAMMOTH_NG
|
||||
|
||||
|
||||
class ODBCPostgreSQLTest: public CppUnit::TestCase
|
||||
class ODBCPostgreSQLTest: public ODBCTest
|
||||
/// PostgreSQL ODBC test class
|
||||
/// Tested:
|
||||
///
|
||||
@ -67,95 +63,15 @@ public:
|
||||
|
||||
void testBareboneODBC();
|
||||
|
||||
void testSimpleAccess();
|
||||
void testComplexType();
|
||||
|
||||
void testSimpleAccessVector();
|
||||
void testComplexTypeVector();
|
||||
void testInsertVector();
|
||||
void testInsertEmptyVector();
|
||||
|
||||
void testSimpleAccessList();
|
||||
void testComplexTypeList();
|
||||
void testInsertList();
|
||||
void testInsertEmptyList();
|
||||
|
||||
void testSimpleAccessDeque();
|
||||
void testComplexTypeDeque();
|
||||
void testInsertDeque();
|
||||
void testInsertEmptyDeque();
|
||||
|
||||
void testInsertSingleBulk();
|
||||
void testInsertSingleBulkVec();
|
||||
|
||||
void testLimit();
|
||||
void testLimitOnce();
|
||||
void testLimitPrepare();
|
||||
void testLimitZero();
|
||||
void testPrepare();
|
||||
void testStep();
|
||||
|
||||
void testSetSimple();
|
||||
void testSetComplex();
|
||||
void testSetComplexUnique();
|
||||
void testMultiSetSimple();
|
||||
void testMultiSetComplex();
|
||||
void testMapComplex();
|
||||
void testMapComplexUnique();
|
||||
void testMultiMapComplex();
|
||||
void testSelectIntoSingle();
|
||||
void testSelectIntoSingleStep();
|
||||
void testSelectIntoSingleFail();
|
||||
void testLowerLimitOk();
|
||||
void testLowerLimitFail();
|
||||
void testCombinedLimits();
|
||||
void testCombinedIllegalLimits();
|
||||
void testRange();
|
||||
void testIllegalRange();
|
||||
void testSingleSelect();
|
||||
void testEmptyDB();
|
||||
|
||||
void testBLOB();
|
||||
void testBLOBStmt();
|
||||
|
||||
void testDateTime();
|
||||
void testDate();
|
||||
void testTime();
|
||||
|
||||
void testFloat();
|
||||
void testDouble();
|
||||
|
||||
void testTuple();
|
||||
void testTupleVector();
|
||||
|
||||
void testInternalExtraction();
|
||||
void testInternalStorageType();
|
||||
|
||||
void testStoredFunction();
|
||||
void testStoredFunctionAny();
|
||||
void testStoredFunctionDynamicAny();
|
||||
|
||||
void testNull();
|
||||
void testRowIterator();
|
||||
void testStdVectorBool();
|
||||
|
||||
void testAsync();
|
||||
|
||||
void testAny();
|
||||
void testDynamicAny();
|
||||
|
||||
void testMultipleResults();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
typedef Poco::Data::ODBC::Utility::DriverMap Drivers;
|
||||
typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr;
|
||||
typedef Poco::SharedPtr<SQLExecutor> ExecPtr;
|
||||
|
||||
void dropObject(const std::string& type, const std::string& name);
|
||||
void recreatePersonTable();
|
||||
void recreatePersonBLOBTable();
|
||||
@ -170,9 +86,6 @@ private:
|
||||
void recreateAnysTable();
|
||||
void recreateNullsTable(const std::string& notNull="");
|
||||
void recreateBoolTable();
|
||||
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
void configurePLPgSQL();
|
||||
/// Configures PL/pgSQL in the database. A reasonable defaults
|
||||
@ -182,17 +95,19 @@ private:
|
||||
/// modify the function and recompile.
|
||||
/// Alternative is direct database configuration for PL/pgSQL usage.
|
||||
|
||||
static Drivers _drivers;
|
||||
static std::string _dbConnString;
|
||||
static SessionPtr _pSession;
|
||||
static ExecPtr _pExecutor;
|
||||
static const bool bindValues[8];
|
||||
|
||||
static const std::string libDir;
|
||||
static const std::string _libDir;
|
||||
/// Varible determining the location of the library directory
|
||||
/// on the database installation system.
|
||||
/// Used to enable PLpgSQL language programmaticaly when
|
||||
/// it is not enabled.
|
||||
|
||||
static SessionPtr _pSession;
|
||||
static ExecPtr _pExecutor;
|
||||
static std::string _driver;
|
||||
static std::string _dsn;
|
||||
static std::string _uid;
|
||||
static std::string _pwd;
|
||||
static std::string _connectString;
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,18 +37,14 @@
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/Session.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "SQLExecutor.h"
|
||||
#include "ODBCTest.h"
|
||||
|
||||
|
||||
// uncomment to use native SQL Server ODBC driver
|
||||
// #define POCO_ODBC_USE_SQL_NATIVE
|
||||
|
||||
|
||||
class ODBCSQLServerTest: public CppUnit::TestCase
|
||||
class ODBCSQLServerTest: public ODBCTest
|
||||
/// SQLServer ODBC test class
|
||||
/// Tested:
|
||||
///
|
||||
@ -65,99 +61,25 @@ public:
|
||||
|
||||
void testBareboneODBC();
|
||||
|
||||
void testSimpleAccess();
|
||||
void testComplexType();
|
||||
|
||||
void testSimpleAccessVector();
|
||||
void testComplexTypeVector();
|
||||
void testInsertVector();
|
||||
void testInsertEmptyVector();
|
||||
|
||||
void testSimpleAccessList();
|
||||
void testComplexTypeList();
|
||||
void testInsertList();
|
||||
void testInsertEmptyList();
|
||||
|
||||
void testSimpleAccessDeque();
|
||||
void testComplexTypeDeque();
|
||||
void testInsertDeque();
|
||||
void testInsertEmptyDeque();
|
||||
|
||||
void testInsertSingleBulk();
|
||||
void testInsertSingleBulkVec();
|
||||
|
||||
void testLimit();
|
||||
void testLimitOnce();
|
||||
void testLimitPrepare();
|
||||
void testLimitZero();
|
||||
void testPrepare();
|
||||
void testStep();
|
||||
|
||||
void testSetSimple();
|
||||
void testSetComplex();
|
||||
void testSetComplexUnique();
|
||||
void testMultiSetSimple();
|
||||
void testMultiSetComplex();
|
||||
void testMapComplex();
|
||||
void testMapComplexUnique();
|
||||
void testMultiMapComplex();
|
||||
void testSelectIntoSingle();
|
||||
void testSelectIntoSingleStep();
|
||||
void testSelectIntoSingleFail();
|
||||
void testLowerLimitOk();
|
||||
void testLowerLimitFail();
|
||||
void testCombinedLimits();
|
||||
void testCombinedIllegalLimits();
|
||||
void testRange();
|
||||
void testIllegalRange();
|
||||
void testSingleSelect();
|
||||
void testEmptyDB();
|
||||
|
||||
void testBLOB();
|
||||
void testBLOBStmt();
|
||||
|
||||
void testDateTime();
|
||||
|
||||
void testFloat();
|
||||
void testDouble();
|
||||
|
||||
void testTuple();
|
||||
void testTupleVector();
|
||||
void testNull();
|
||||
|
||||
void testStoredProcedure();
|
||||
void testCursorStoredProcedure();
|
||||
void testStoredProcedureAny();
|
||||
void testStoredProcedureDynamicAny();
|
||||
|
||||
void testStoredFunction();
|
||||
|
||||
void testInternalExtraction();
|
||||
void testInternalStorageType();
|
||||
|
||||
void testNull();
|
||||
void testRowIterator();
|
||||
void testStdVectorBool();
|
||||
|
||||
void testAsync();
|
||||
|
||||
void testAny();
|
||||
void testDynamicAny();
|
||||
|
||||
void testMultipleResults();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
typedef Poco::Data::ODBC::Utility::DriverMap Drivers;
|
||||
typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr;
|
||||
typedef Poco::SharedPtr<SQLExecutor> ExecPtr;
|
||||
|
||||
void dropObject(const std::string& type, const std::string& name);
|
||||
void recreatePersonTable();
|
||||
void recreatePersonBLOBTable();
|
||||
void recreatePersonDateTimeTable();
|
||||
void recreatePersonDateTable() { /* no-op */ };
|
||||
void recreatePersonTimeTable() { /* no-op */ };
|
||||
void recreateStringsTable();
|
||||
void recreateIntsTable();
|
||||
void recreateFloatsTable();
|
||||
@ -168,14 +90,14 @@ private:
|
||||
void recreateNullsTable(const std::string& notNull = "");
|
||||
void recreateBoolTable();
|
||||
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Drivers _drivers;
|
||||
static std::string _dbConnString;
|
||||
static SessionPtr _pSession;
|
||||
static ExecPtr _pExecutor;
|
||||
static const bool bindValues[8];
|
||||
static std::string _driver;
|
||||
static std::string _dsn;
|
||||
static std::string _uid;
|
||||
static std::string _pwd;
|
||||
static std::string _db;
|
||||
static std::string _connectString;
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,14 +37,10 @@
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/Session.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "SQLExecutor.h"
|
||||
#include "ODBCTest.h"
|
||||
|
||||
|
||||
class ODBCSQLiteTest: public CppUnit::TestCase
|
||||
class ODBCSQLiteTest: public ODBCTest
|
||||
/// SQLite3 ODBC test class
|
||||
/// Tested:
|
||||
///
|
||||
@ -57,87 +53,11 @@ public:
|
||||
~ODBCSQLiteTest();
|
||||
|
||||
void testBareboneODBC();
|
||||
|
||||
void testSimpleAccess();
|
||||
void testComplexType();
|
||||
|
||||
void testSimpleAccessVector();
|
||||
void testComplexTypeVector();
|
||||
void testInsertVector();
|
||||
void testInsertEmptyVector();
|
||||
|
||||
void testSimpleAccessList();
|
||||
void testComplexTypeList();
|
||||
void testInsertList();
|
||||
void testInsertEmptyList();
|
||||
|
||||
void testSimpleAccessDeque();
|
||||
void testComplexTypeDeque();
|
||||
void testInsertDeque();
|
||||
void testInsertEmptyDeque();
|
||||
|
||||
void testInsertSingleBulk();
|
||||
void testInsertSingleBulkVec();
|
||||
|
||||
void testLimit();
|
||||
void testLimitOnce();
|
||||
void testLimitPrepare();
|
||||
void testLimitZero();
|
||||
void testPrepare();
|
||||
void testStep();
|
||||
|
||||
void testSetSimple();
|
||||
void testSetComplex();
|
||||
void testSetComplexUnique();
|
||||
void testMultiSetSimple();
|
||||
void testMultiSetComplex();
|
||||
void testMapComplex();
|
||||
void testMapComplexUnique();
|
||||
void testMultiMapComplex();
|
||||
void testSelectIntoSingle();
|
||||
void testSelectIntoSingleStep();
|
||||
void testSelectIntoSingleFail();
|
||||
void testLowerLimitOk();
|
||||
void testLowerLimitFail();
|
||||
void testCombinedLimits();
|
||||
void testCombinedIllegalLimits();
|
||||
void testRange();
|
||||
void testIllegalRange();
|
||||
void testSingleSelect();
|
||||
void testEmptyDB();
|
||||
|
||||
void testBLOB();
|
||||
void testBLOBStmt();
|
||||
|
||||
void testDateTime();
|
||||
|
||||
void testFloat();
|
||||
void testDouble();
|
||||
|
||||
void testTuple();
|
||||
void testTupleVector();
|
||||
|
||||
void testInternalExtraction();
|
||||
void testInternalStorageType();
|
||||
|
||||
void testNull();
|
||||
void testRowIterator();
|
||||
|
||||
void testAsync();
|
||||
|
||||
void testAny();
|
||||
void testDynamicAny();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
typedef Poco::Data::ODBC::Utility::DriverMap Drivers;
|
||||
typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr;
|
||||
typedef Poco::SharedPtr<SQLExecutor> ExecPtr;
|
||||
|
||||
void dropObject(const std::string& type, const std::string& name);
|
||||
void recreatePersonTable();
|
||||
void recreatePersonBLOBTable();
|
||||
@ -150,14 +70,13 @@ private:
|
||||
void recreateAnysTable();
|
||||
void recreateNullsTable(const std::string& notNull = "");
|
||||
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Drivers _drivers;
|
||||
static std::string _dbConnString;
|
||||
static SessionPtr _pSession;
|
||||
static ExecPtr _pExecutor;
|
||||
static const bool bindValues[8];
|
||||
static ODBCTest::SessionPtr _pSession;
|
||||
static ODBCTest::ExecPtr _pExecutor;
|
||||
static std::string _driver;
|
||||
static std::string _dsn;
|
||||
static std::string _uid;
|
||||
static std::string _pwd;
|
||||
static std::string _connectString;
|
||||
};
|
||||
|
||||
|
||||
|
1084
Data/ODBC/testsuite/src/ODBCTest.cpp
Normal file
1084
Data/ODBC/testsuite/src/ODBCTest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
253
Data/ODBC/testsuite/src/ODBCTest.h
Normal file
253
Data/ODBC/testsuite/src/ODBCTest.h
Normal file
@ -0,0 +1,253 @@
|
||||
//
|
||||
// ODBCTest.h
|
||||
//
|
||||
// $Id: //poco/Main/Data/ODBC/testsuite/src/ODBCTest.h#4 $
|
||||
//
|
||||
// Definition of the ODBCTest class.
|
||||
//
|
||||
// Copyright (c) 2006, 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.
|
||||
//
|
||||
|
||||
|
||||
#ifndef ODBCTest_INCLUDED
|
||||
#define ODBCTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/Session.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "SQLExecutor.h"
|
||||
|
||||
|
||||
class ODBCTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr;
|
||||
typedef Poco::SharedPtr<SQLExecutor> ExecPtr;
|
||||
|
||||
ODBCTest(const std::string& name,
|
||||
SessionPtr pSession,
|
||||
ExecPtr pExecutor,
|
||||
std::string& rDSN,
|
||||
std::string& rUID,
|
||||
std::string& rPwd,
|
||||
std::string& rConnectString);
|
||||
|
||||
~ODBCTest();
|
||||
|
||||
virtual void setUp();
|
||||
virtual void tearDown();
|
||||
|
||||
virtual void testBareboneODBC() = 0;
|
||||
|
||||
virtual void testSimpleAccess();
|
||||
virtual void testComplexType();
|
||||
|
||||
virtual void testSimpleAccessVector();
|
||||
virtual void testComplexTypeVector();
|
||||
virtual void testInsertVector();
|
||||
virtual void testInsertEmptyVector();
|
||||
|
||||
virtual void testSimpleAccessList();
|
||||
virtual void testComplexTypeList();
|
||||
virtual void testInsertList();
|
||||
virtual void testInsertEmptyList();
|
||||
|
||||
virtual void testSimpleAccessDeque();
|
||||
virtual void testComplexTypeDeque();
|
||||
virtual void testInsertDeque();
|
||||
virtual void testInsertEmptyDeque();
|
||||
|
||||
virtual void testInsertSingleBulk();
|
||||
virtual void testInsertSingleBulkVec();
|
||||
|
||||
virtual void testLimit();
|
||||
virtual void testLimitOnce();
|
||||
virtual void testLimitPrepare();
|
||||
virtual void testLimitZero();
|
||||
virtual void testPrepare();
|
||||
virtual void testStep();
|
||||
|
||||
virtual void testSetSimple();
|
||||
virtual void testSetComplex();
|
||||
virtual void testSetComplexUnique();
|
||||
virtual void testMultiSetSimple();
|
||||
virtual void testMultiSetComplex();
|
||||
virtual void testMapComplex();
|
||||
virtual void testMapComplexUnique();
|
||||
virtual void testMultiMapComplex();
|
||||
virtual void testSelectIntoSingle();
|
||||
virtual void testSelectIntoSingleStep();
|
||||
virtual void testSelectIntoSingleFail();
|
||||
virtual void testLowerLimitOk();
|
||||
virtual void testLowerLimitFail();
|
||||
virtual void testCombinedLimits();
|
||||
virtual void testCombinedIllegalLimits();
|
||||
virtual void testRange();
|
||||
virtual void testIllegalRange();
|
||||
virtual void testSingleSelect();
|
||||
virtual void testEmptyDB();
|
||||
|
||||
virtual void testBLOB();
|
||||
virtual void testBLOBStmt();
|
||||
|
||||
virtual void testDateTime();
|
||||
virtual void testDate();
|
||||
virtual void testTime();
|
||||
|
||||
virtual void testFloat();
|
||||
virtual void testDouble();
|
||||
|
||||
virtual void testTuple();
|
||||
virtual void testTupleVector();
|
||||
|
||||
virtual void testInternalExtraction();
|
||||
virtual void testInternalStorageType();
|
||||
|
||||
virtual void testStoredProcedure() { /* no-op */ };
|
||||
virtual void testStoredProcedureAny() { /* no-op */ };
|
||||
virtual void testStoredProcedureDynamicAny() { /* no-op */ };
|
||||
|
||||
virtual void testStoredFunction() { /* no-op */ };
|
||||
virtual void testStoredFunctionAny() { /* no-op */ };
|
||||
virtual void testStoredFunctionDynamicAny() { /* no-op */ };
|
||||
|
||||
virtual void testNull();
|
||||
virtual void testRowIterator();
|
||||
virtual void testStdVectorBool();
|
||||
|
||||
virtual void testAsync();
|
||||
|
||||
virtual void testAny();
|
||||
virtual void testDynamicAny();
|
||||
|
||||
virtual void testMultipleResults();
|
||||
|
||||
protected:
|
||||
typedef Poco::Data::ODBC::Utility::DriverMap Drivers;
|
||||
|
||||
virtual void dropObject(const std::string& type, const std::string& name) { /* no-op */ };
|
||||
virtual void recreatePersonTable() { /* no-op */ };
|
||||
virtual void recreatePersonBLOBTable() { /* no-op */ };
|
||||
virtual void recreatePersonDateTimeTable() { /* no-op */ };
|
||||
virtual void recreatePersonDateTable() { /* no-op */ };
|
||||
virtual void recreatePersonTimeTable() { /* no-op */ };
|
||||
virtual void recreateStringsTable() { /* no-op */ };
|
||||
virtual void recreateIntsTable() { /* no-op */ };
|
||||
virtual void recreateFloatsTable() { /* no-op */ };
|
||||
virtual void recreateTuplesTable() { /* no-op */ };
|
||||
virtual void recreateVectorsTable() { /* no-op */ };
|
||||
virtual void recreateAnysTable() { /* no-op */ };
|
||||
virtual void recreateNullsTable(const std::string& notNull="") { /* no-op */ };
|
||||
virtual void recreateBoolTable() { /* no-op */ };
|
||||
|
||||
static SessionPtr init(const std::string& driver,
|
||||
std::string& dsn,
|
||||
std::string& uid,
|
||||
std::string& pwd,
|
||||
std::string& dbConnString,
|
||||
const std::string& db = "");
|
||||
|
||||
static bool canConnect(const std::string& driver,
|
||||
std::string& dsn,
|
||||
std::string& uid,
|
||||
std::string& pwd,
|
||||
std::string& dbConnString,
|
||||
const std::string& db = "");
|
||||
|
||||
bool bindValue(int i);
|
||||
|
||||
Poco::Data::Session& session();
|
||||
SQLExecutor& executor();
|
||||
|
||||
const std::string& dsn();
|
||||
const std::string& uid();
|
||||
const std::string& pwd();
|
||||
const std::string& dbConnString();
|
||||
|
||||
private:
|
||||
static Drivers _drivers;
|
||||
static const bool _bindValues[8];
|
||||
SessionPtr _pSession;
|
||||
ExecPtr _pExecutor;
|
||||
std::string& _rDSN;
|
||||
std::string& _rUID;
|
||||
std::string& _rPwd;
|
||||
std::string& _rConnectString;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// inlines
|
||||
///
|
||||
inline bool ODBCTest::bindValue(int i)
|
||||
{
|
||||
poco_assert (i < 8);
|
||||
return _bindValues[i];
|
||||
}
|
||||
|
||||
|
||||
inline Poco::Data::Session& ODBCTest::session()
|
||||
{
|
||||
poco_check_ptr (_pSession);
|
||||
return *_pSession;
|
||||
}
|
||||
|
||||
|
||||
inline SQLExecutor& ODBCTest::executor()
|
||||
{
|
||||
poco_check_ptr (_pExecutor);
|
||||
return *_pExecutor;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& ODBCTest::dsn()
|
||||
{
|
||||
return _rDSN;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& ODBCTest::uid()
|
||||
{
|
||||
return _rUID;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& ODBCTest::pwd()
|
||||
{
|
||||
return _rPwd;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& ODBCTest::dbConnString()
|
||||
{
|
||||
return _rConnectString;
|
||||
}
|
||||
|
||||
|
||||
#endif // ODBCTest_INCLUDED
|
@ -47,31 +47,24 @@ CppUnit::Test* ODBCTestSuite::suite()
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCTestSuite");
|
||||
|
||||
// WARNING!
|
||||
// On Win XP Pro:
|
||||
//
|
||||
// 1) The PostgreSQL connection fails if attempted after DB2 w/ following error:
|
||||
// On Win XP Pro, the PostgreSQL connection fails if attempted after DB2 w/ following error:
|
||||
//
|
||||
// sqlState="IM003"
|
||||
// message="Specified driver could not be loaded due to system error 127 (PostgreSQL ANSI)."
|
||||
// nativeError=160
|
||||
// System error 127 is "The specified procedure could not be found."
|
||||
//
|
||||
// Workaround is to connect to DB2 after connecting to PostgreSQL.
|
||||
// This problem does not manifest with Mammoth ODBCng PostgreSQL driver.
|
||||
//
|
||||
// 2) When Oracle driver is found, but no tests executed, the test application does not exit cleanly.
|
||||
//
|
||||
// Workaround is to run barebone ODBC test upon initialization of Oracle test.
|
||||
// (see ODBCOracleTest::init())
|
||||
//
|
||||
// The reason causing the above errors is not known at this time.
|
||||
// Oracle tests do not exit cleanly if Oracle driver is loaded after DB2.
|
||||
//
|
||||
// For the time being, the workaround is to connect to DB2 after connecting to PostgreSQL and Oracle.
|
||||
|
||||
addTest(pSuite, ODBCPostgreSQLTest::suite());
|
||||
addTest(pSuite, ODBCDB2Test::suite());
|
||||
addTest(pSuite, ODBCMySQLTest::suite());
|
||||
addTest(pSuite, ODBCOracleTest::suite());
|
||||
addTest(pSuite, ODBCPostgreSQLTest::suite());
|
||||
addTest(pSuite, ODBCSQLiteTest::suite());
|
||||
addTest(pSuite, ODBCSQLServerTest::suite());
|
||||
addTest(pSuite, ODBCDB2Test::suite());
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
addTest(pSuite, ODBCAccessTest::suite());
|
||||
#endif
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "Poco/DateTime.h"
|
||||
#include "Poco/Stopwatch.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Data/Common.h"
|
||||
#include "Poco/Data/Date.h"
|
||||
#include "Poco/Data/Time.h"
|
||||
#include "Poco/Data/BLOB.h"
|
||||
@ -59,15 +58,6 @@
|
||||
#include <iterator>
|
||||
|
||||
|
||||
#define poco_odbc_check(r, h) \
|
||||
if (!SQL_SUCCEEDED(r)) \
|
||||
{ \
|
||||
StatementException se(h); \
|
||||
std::cout << se.toString() << std::endl; \
|
||||
} \
|
||||
assert (SQL_SUCCEEDED(r));
|
||||
|
||||
|
||||
using namespace Poco::Data;
|
||||
using ODBC::Utility;
|
||||
using ODBC::Preparation;
|
||||
@ -223,74 +213,78 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
|
||||
// Environment begin
|
||||
rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_env (rc, henv);
|
||||
rc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, 0);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_env (rc, henv);
|
||||
|
||||
// Connection begin
|
||||
rc = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_dbc (rc, hdbc);
|
||||
|
||||
POCO_SQLCHAR connectOutput[512] = {0};
|
||||
SQLCHAR connectOutput[1024] = {0};
|
||||
SQLSMALLINT result;
|
||||
rc = SQLDriverConnect(hdbc
|
||||
, NULL
|
||||
,(POCO_SQLCHAR*) dbConnString.c_str()
|
||||
,(SQLCHAR*) dbConnString.c_str()
|
||||
,(SQLSMALLINT) SQL_NTS
|
||||
, connectOutput
|
||||
, sizeof(connectOutput)
|
||||
, &result
|
||||
, SQL_DRIVER_NOPROMPT);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_dbc (rc, hdbc);
|
||||
|
||||
// retrieve datetime type information for this DBMS
|
||||
rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLGetTypeInfo(hstmt, SQL_TIMESTAMP);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
SQLINTEGER dateTimeColSize = 0;
|
||||
SQLSMALLINT dateTimeDecDigits = 0;
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLFetch(hstmt);
|
||||
assert (SQL_SUCCEEDED(rc) || SQL_NO_DATA == rc);
|
||||
|
||||
SQLINTEGER dateTimeColSize = 0;
|
||||
SQLSMALLINT dateTimeDecDigits = 0;
|
||||
if (SQL_SUCCEEDED(rc))
|
||||
{
|
||||
rc = SQLGetData(hstmt, 3, SQL_C_SLONG, &dateTimeColSize, sizeof(SQLINTEGER), 0);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
rc = SQLGetData(hstmt, 14, SQL_C_SSHORT, &dateTimeDecDigits, sizeof(SQLSMALLINT), 0);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
SQLLEN ind = 0;
|
||||
rc = SQLGetData(hstmt, 3, SQL_C_SLONG, &dateTimeColSize, sizeof(SQLINTEGER), &ind);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
rc = SQLGetData(hstmt, 14, SQL_C_SSHORT, &dateTimeDecDigits, sizeof(SQLSMALLINT), &ind);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
assert (sizeof(SQL_TIMESTAMP_STRUCT) <= dateTimeColSize);
|
||||
}
|
||||
else if (SQL_NO_DATA == rc)
|
||||
std::cerr << "Warning: no data type info returned by driver." << std::endl;
|
||||
std::cerr << '[' << name() << ']' << " Warning: no SQL_TIMESTAMP data type info returned by driver." << std::endl;
|
||||
|
||||
rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
// Statement begin
|
||||
rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
std::string sql = "DROP TABLE Test";
|
||||
POCO_SQLCHAR* pStr = (POCO_SQLCHAR*) sql.c_str();
|
||||
SQLCHAR* pStr = (SQLCHAR*) sql.c_str();
|
||||
SQLExecDirect(hstmt, pStr, (SQLINTEGER) sql.length());
|
||||
//no return code check - ignore drop errors
|
||||
|
||||
// create table and go
|
||||
sql = tableCreateString;
|
||||
pStr = (POCO_SQLCHAR*) sql.c_str();
|
||||
pStr = (SQLCHAR*) sql.c_str();
|
||||
rc = SQLPrepare(hstmt, pStr, (SQLINTEGER) sql.length());
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLExecute(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
sql = "INSERT INTO Test VALUES (?,?,?,?,?,?)";
|
||||
pStr = (POCO_SQLCHAR*) sql.c_str();
|
||||
pStr = (SQLCHAR*) sql.c_str();
|
||||
rc = SQLPrepare(hstmt, pStr, (SQLINTEGER) sql.length());
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
std::string str[3] = { "111", "222", "333" };
|
||||
std::string str[3] = { "11111111111", "222222222222222222222222", "333333333333333333333333333" };
|
||||
int fourth = 4;
|
||||
float fifth = 1.5;
|
||||
SQL_TIMESTAMP_STRUCT sixth;
|
||||
@ -305,7 +299,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
|
||||
SQLLEN li = SQL_NTS;
|
||||
SQLINTEGER size = (SQLINTEGER) str[0].size();
|
||||
|
||||
|
||||
if (SQLExecutor::PB_AT_EXEC == bindMode)
|
||||
li = SQL_LEN_DATA_AT_EXEC(size);
|
||||
|
||||
@ -319,11 +313,12 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) str[0].c_str(),
|
||||
size,
|
||||
&li);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
size = (SQLINTEGER) str[1].size();
|
||||
if (SQLExecutor::PB_AT_EXEC == bindMode)
|
||||
li = SQL_LEN_DATA_AT_EXEC(size);
|
||||
else li = SQL_NTS;
|
||||
|
||||
rc = SQLBindParameter(hstmt,
|
||||
(SQLUSMALLINT) 2,
|
||||
@ -335,7 +330,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) str[1].c_str(),
|
||||
size,
|
||||
&li);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
size = (SQLINTEGER) str[2].size();
|
||||
if (SQLExecutor::PB_AT_EXEC == bindMode)
|
||||
@ -352,7 +347,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) str[2].data(),
|
||||
size,
|
||||
&li);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindParameter(hstmt,
|
||||
(SQLUSMALLINT) 4,
|
||||
@ -364,7 +359,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) &fourth,
|
||||
0,
|
||||
0);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindParameter(hstmt,
|
||||
(SQLUSMALLINT) 5,
|
||||
@ -376,7 +371,22 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) &fifth,
|
||||
0,
|
||||
0);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
SQLSMALLINT dataType = 0;
|
||||
SQLULEN parameterSize = 0;
|
||||
SQLSMALLINT decimalDigits = 0;
|
||||
SQLSMALLINT nullable = 0;
|
||||
rc = SQLDescribeParam(hstmt, 6, &dataType, ¶meterSize, &decimalDigits, &nullable);
|
||||
if (SQL_SUCCEEDED(rc))
|
||||
{
|
||||
if (parameterSize)
|
||||
dateTimeColSize = parameterSize;
|
||||
if (decimalDigits)
|
||||
dateTimeDecDigits = decimalDigits;
|
||||
}
|
||||
else
|
||||
std::cerr << '[' << name() << ']' << " Warning: could not get SQL_TIMESTAMP parameter description." << std::endl;
|
||||
|
||||
rc = SQLBindParameter(hstmt,
|
||||
(SQLUSMALLINT) 6,
|
||||
@ -386,13 +396,9 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
dateTimeColSize,
|
||||
dateTimeDecDigits,
|
||||
(SQLPOINTER) &sixth,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
|
||||
size = 0;
|
||||
if (SQLExecutor::PB_AT_EXEC == bindMode)
|
||||
li = SQL_LEN_DATA_AT_EXEC((int) sizeof(int));
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLExecute(hstmt);
|
||||
assert (SQL_NEED_DATA == rc || SQL_SUCCEEDED(rc));
|
||||
@ -400,33 +406,40 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
if (SQL_NEED_DATA == rc)
|
||||
{
|
||||
SQLPOINTER pParam = 0;
|
||||
int i = 1;
|
||||
rc = SQLParamData(hstmt, &pParam);
|
||||
do
|
||||
while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam)))
|
||||
{
|
||||
SQLINTEGER dataSize = 0;
|
||||
// Data size should be ignored for non-null,
|
||||
// non-variable length fields, but SQLite ODBC
|
||||
// driver insists on it always being the actual
|
||||
// data length
|
||||
if (i < 4)
|
||||
dataSize = (SQLINTEGER) str[i-1].size();
|
||||
else if (4 == i) dataSize = sizeof(int);
|
||||
else if (5 == i) dataSize = sizeof(float);
|
||||
else if (6 == i) dataSize = sizeof(SQL_TIMESTAMP_STRUCT);
|
||||
|
||||
if (pParam == (SQLPOINTER) str[0].c_str())
|
||||
dataSize = (SQLINTEGER) str[0].size();
|
||||
else if (pParam == (SQLPOINTER) str[1].c_str())
|
||||
dataSize = (SQLINTEGER) str[1].size();
|
||||
else if (pParam == (SQLPOINTER) str[2].c_str())
|
||||
dataSize = (SQLINTEGER) str[2].size();
|
||||
else if (pParam == (SQLPOINTER) &fourth)
|
||||
dataSize = (SQLINTEGER) sizeof(fourth);
|
||||
else if (pParam == (SQLPOINTER) &fifth)
|
||||
dataSize = (SQLINTEGER) sizeof(fifth);
|
||||
else if (pParam == (SQLPOINTER) &sixth)
|
||||
dataSize = (SQLINTEGER) sizeof(sixth);
|
||||
|
||||
assert (0 != dataSize);
|
||||
rc = SQLPutData(hstmt, pParam, dataSize);
|
||||
++i;
|
||||
}while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam)));
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
}
|
||||
}
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
sql = "SELECT * FROM Test";
|
||||
pStr = (POCO_SQLCHAR*) sql.c_str();
|
||||
pStr = (SQLCHAR*) sql.c_str();
|
||||
rc = SQLPrepare(hstmt, pStr, (SQLINTEGER) sql.length());
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
char chr[3][5] = {{ 0 }};
|
||||
char chr[3][50] = {{ 0 }};
|
||||
SQLLEN lengths[6] = { 0 };
|
||||
fourth = 0;
|
||||
fifth = 0.0f;
|
||||
@ -438,25 +451,25 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
(SQLUSMALLINT) 1,
|
||||
SQL_C_CHAR,
|
||||
(SQLPOINTER) chr[0],
|
||||
(SQLINTEGER) 4,
|
||||
(SQLINTEGER) sizeof(chr[0]),
|
||||
&lengths[0]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindCol(hstmt,
|
||||
(SQLUSMALLINT) 2,
|
||||
SQL_C_CHAR,
|
||||
(SQLPOINTER) chr[1],
|
||||
(SQLINTEGER) 4,
|
||||
(SQLINTEGER) sizeof(chr[1]),
|
||||
&lengths[1]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindCol(hstmt,
|
||||
(SQLUSMALLINT) 3,
|
||||
SQL_C_BINARY,
|
||||
(SQLPOINTER) chr[2],
|
||||
(SQLINTEGER) 4,
|
||||
(SQLINTEGER) sizeof(chr[2]),
|
||||
&lengths[2]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindCol(hstmt,
|
||||
(SQLUSMALLINT) 4,
|
||||
@ -464,7 +477,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) &fourth,
|
||||
(SQLINTEGER) 0,
|
||||
&lengths[3]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindCol(hstmt,
|
||||
(SQLUSMALLINT) 5,
|
||||
@ -472,7 +485,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) &fifth,
|
||||
(SQLINTEGER) 0,
|
||||
&lengths[4]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindCol(hstmt,
|
||||
(SQLUSMALLINT) 6,
|
||||
@ -480,39 +493,57 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) &sixth,
|
||||
(SQLINTEGER) 0,
|
||||
&lengths[5]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
}
|
||||
|
||||
rc = SQLExecute(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
rc = SQLFetch(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
if (SQLExecutor::DE_MANUAL == extractMode)
|
||||
{
|
||||
rc = SQLGetData(hstmt,
|
||||
SQLINTEGER len = lengths[0] = 0;
|
||||
while (SQL_SUCCESS_WITH_INFO == (rc = SQLGetData(hstmt,
|
||||
(SQLUSMALLINT) 1,
|
||||
SQL_C_CHAR,
|
||||
chr[0],
|
||||
4,
|
||||
&lengths[0]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
chr[0] + len,
|
||||
sizeof(chr[0]) - len,
|
||||
&lengths[0])))
|
||||
{
|
||||
len += lengths[0];
|
||||
if (!lengths[0] || len >= sizeof(chr[1]))
|
||||
break;
|
||||
}
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLGetData(hstmt,
|
||||
len = lengths[1] = 0;
|
||||
while (SQL_SUCCESS_WITH_INFO == (rc = SQLGetData(hstmt,
|
||||
(SQLUSMALLINT) 2,
|
||||
SQL_C_CHAR,
|
||||
chr[1],
|
||||
4,
|
||||
&lengths[1]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
chr[1] + len,
|
||||
sizeof(chr[1]) - len,
|
||||
&lengths[1])))
|
||||
{
|
||||
len += lengths[1];
|
||||
if (!lengths[1] || len >= sizeof(chr[1]))
|
||||
break;
|
||||
}
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLGetData(hstmt,
|
||||
len = lengths[2] = 0;
|
||||
while (SQL_SUCCESS_WITH_INFO == (rc = SQLGetData(hstmt,
|
||||
(SQLUSMALLINT) 3,
|
||||
SQL_C_BINARY,
|
||||
chr[2],
|
||||
3,
|
||||
&lengths[2]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
chr[2] + len,
|
||||
sizeof(chr[2]) - len,
|
||||
&lengths[2])))
|
||||
{
|
||||
len += lengths[1];
|
||||
if (!lengths[2] || len >= sizeof(chr[2]))
|
||||
break;
|
||||
}
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLGetData(hstmt,
|
||||
(SQLUSMALLINT) 4,
|
||||
@ -520,7 +551,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
&fourth,
|
||||
0,
|
||||
&lengths[3]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLGetData(hstmt,
|
||||
(SQLUSMALLINT) 5,
|
||||
@ -528,7 +559,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
&fifth,
|
||||
0,
|
||||
&lengths[4]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLGetData(hstmt,
|
||||
(SQLUSMALLINT) 6,
|
||||
@ -536,14 +567,15 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
&sixth,
|
||||
0,
|
||||
&lengths[5]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
}
|
||||
|
||||
assert (0 == strncmp("111", chr[0], 3));
|
||||
assert (0 == strncmp("222", chr[1], 3));
|
||||
assert (0 == strncmp("333", chr[2], 3));
|
||||
assert (0 == strncmp(str[0].c_str(), chr[0], str[0].size()));
|
||||
assert (0 == strncmp(str[1].c_str(), chr[1], str[1].size()));
|
||||
assert (0 == strncmp(str[2].c_str(), chr[2], str[2].size()));
|
||||
assert (4 == fourth);
|
||||
assert (1.5 == fifth);
|
||||
|
||||
assert (1965 == sixth.year);
|
||||
assert (6 == sixth.month);
|
||||
assert (18 == sixth.day);
|
||||
@ -555,25 +587,25 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
}
|
||||
|
||||
rc = SQLCloseCursor(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
sql = "DROP TABLE Test";
|
||||
pStr = (POCO_SQLCHAR*) sql.c_str();
|
||||
pStr = (SQLCHAR*) sql.c_str();
|
||||
rc = SQLExecDirect(hstmt, pStr, (SQLINTEGER) sql.length());
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
// Connection end
|
||||
rc = SQLDisconnect(hdbc);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_dbc (rc, hdbc);
|
||||
rc = SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_dbc (rc, hdbc);
|
||||
|
||||
// Environment end
|
||||
rc = SQLFreeHandle(SQL_HANDLE_ENV, henv);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_env (rc, henv);
|
||||
}
|
||||
|
||||
|
||||
@ -591,65 +623,64 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
|
||||
// Environment begin
|
||||
rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
rc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, 0);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
// Connection begin
|
||||
rc = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
POCO_SQLCHAR connectOutput[512] = {0};
|
||||
SQLCHAR connectOutput[512] = {0};
|
||||
SQLSMALLINT result;
|
||||
rc = SQLDriverConnect(hdbc
|
||||
, NULL
|
||||
,(POCO_SQLCHAR*) dbConnString.c_str()
|
||||
,(SQLCHAR*) dbConnString.c_str()
|
||||
,(SQLSMALLINT) SQL_NTS
|
||||
, connectOutput
|
||||
, sizeof(connectOutput)
|
||||
, &result
|
||||
, SQL_DRIVER_NOPROMPT);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
// Statement begin
|
||||
rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
std::string sql = "DROP TABLE Test";
|
||||
POCO_SQLCHAR* pStr = (POCO_SQLCHAR*) sql.c_str();
|
||||
SQLCHAR* pStr = (SQLCHAR*) sql.c_str();
|
||||
SQLExecDirect(hstmt, pStr, (SQLINTEGER) sql.length());
|
||||
//no return code check - ignore drop errors
|
||||
|
||||
// create table and go
|
||||
sql = tableCreateString;
|
||||
pStr = (POCO_SQLCHAR*) sql.c_str();
|
||||
pStr = (SQLCHAR*) sql.c_str();
|
||||
rc = SQLPrepare(hstmt, pStr, (SQLINTEGER) sql.length());
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLExecute(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
// insert multiple rows
|
||||
pStr = (POCO_SQLCHAR*) insert.c_str();
|
||||
pStr = (SQLCHAR*) insert.c_str();
|
||||
rc = SQLPrepare(hstmt, pStr, (SQLINTEGER) insert.length());
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
rc = SQLExecute(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
do
|
||||
{
|
||||
SQLINTEGER rowCount = 0;
|
||||
SQLLEN rowCount = 0;
|
||||
SQLRowCount(hstmt, &rowCount);
|
||||
assert (1 == rowCount);
|
||||
|
||||
} while (SQL_NO_DATA != SQLMoreResults(hstmt));
|
||||
|
||||
// make sure all five rows made it in
|
||||
sql = "select count(*) from Test";
|
||||
int count = 0;
|
||||
SQLLEN length = 0;
|
||||
pStr = (POCO_SQLCHAR*) sql.c_str();
|
||||
pStr = (SQLCHAR*) sql.c_str();
|
||||
rc = SQLPrepare(hstmt, pStr, (SQLINTEGER) sql.length());
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
if (SQLExecutor::DE_BOUND == extractMode)
|
||||
{
|
||||
rc = SQLBindCol(hstmt,
|
||||
@ -658,14 +689,14 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) &count,
|
||||
(SQLINTEGER) 0,
|
||||
&length);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
}
|
||||
|
||||
rc = SQLExecute(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLFetch(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
if (SQLExecutor::DE_MANUAL == extractMode)
|
||||
{
|
||||
@ -675,17 +706,17 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
&count,
|
||||
0,
|
||||
&length);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
}
|
||||
assert (5 == count);
|
||||
|
||||
rc = SQLCloseCursor(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
// select multiple rows
|
||||
pStr = (POCO_SQLCHAR*) select.c_str();
|
||||
pStr = (SQLCHAR*) select.c_str();
|
||||
rc = SQLPrepare(hstmt, pStr, (SQLINTEGER) select.length());
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
char chr[5] = { 0 };
|
||||
SQLLEN lengths[3] = { 0 };
|
||||
@ -700,7 +731,7 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) chr,
|
||||
(SQLINTEGER) 4,
|
||||
&lengths[0]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindCol(hstmt,
|
||||
(SQLUSMALLINT) 2,
|
||||
@ -708,7 +739,7 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) &second,
|
||||
(SQLINTEGER) 0,
|
||||
&lengths[1]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindCol(hstmt,
|
||||
(SQLUSMALLINT) 3,
|
||||
@ -716,11 +747,11 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
(SQLPOINTER) &third,
|
||||
(SQLINTEGER) 0,
|
||||
&lengths[2]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
}
|
||||
|
||||
rc = SQLExecute(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
char one = 0x31;
|
||||
int two = 2;
|
||||
@ -730,7 +761,7 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
do
|
||||
{
|
||||
rc = SQLFetch(hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
if (SQLExecutor::DE_MANUAL == extractMode)
|
||||
{
|
||||
@ -740,7 +771,7 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
chr,
|
||||
4,
|
||||
&lengths[0]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLGetData(hstmt,
|
||||
(SQLUSMALLINT) 2,
|
||||
@ -748,7 +779,7 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
&second,
|
||||
0,
|
||||
&lengths[1]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLGetData(hstmt,
|
||||
(SQLUSMALLINT) 3,
|
||||
@ -756,7 +787,7 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
&third,
|
||||
0,
|
||||
&lengths[2]);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
}
|
||||
|
||||
assert (one++ == chr[0]);
|
||||
@ -770,22 +801,22 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
assert (5 == count);
|
||||
|
||||
sql = "DROP TABLE Test";
|
||||
pStr = (POCO_SQLCHAR*) sql.c_str();
|
||||
pStr = (SQLCHAR*) sql.c_str();
|
||||
rc = SQLExecDirect(hstmt, pStr, (SQLINTEGER) sql.length());
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
// Connection end
|
||||
rc = SQLDisconnect(hdbc);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
rc = SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
// Environment end
|
||||
rc = SQLFreeHandle(SQL_HANDLE_ENV, henv);
|
||||
poco_odbc_check (rc, hstmt);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
}
|
||||
|
||||
|
||||
@ -2742,4 +2773,3 @@ void SQLExecutor::multipleResults(const std::string& sql)
|
||||
assert (12 == aBart);
|
||||
assert (Person("Simpson", "Lisa", "Springfield", 10) == pLisa);
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,42 @@
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
|
||||
|
||||
#define poco_odbc_check_env(r, h) \
|
||||
if (!SQL_SUCCEEDED(r)) \
|
||||
{ \
|
||||
Poco::Data::ODBC::EnvironmentException ee(h); \
|
||||
std::cout << ee.toString() << std::endl; \
|
||||
} \
|
||||
assert (SQL_SUCCEEDED(r));
|
||||
|
||||
|
||||
#define poco_odbc_check_dbc(r, h) \
|
||||
if (!SQL_SUCCEEDED(r)) \
|
||||
{ \
|
||||
Poco::Data::ODBC::ConnectionException ce(h); \
|
||||
std::cout << ce.toString() << std::endl; \
|
||||
} \
|
||||
assert (SQL_SUCCEEDED(r));
|
||||
|
||||
|
||||
#define poco_odbc_check_stmt(r, h) \
|
||||
if (!SQL_SUCCEEDED(r)) \
|
||||
{ \
|
||||
Poco::Data::ODBC::StatementException se(h); \
|
||||
std::cout << se.toString() << std::endl; \
|
||||
} \
|
||||
assert (SQL_SUCCEEDED(r));
|
||||
|
||||
|
||||
#define poco_odbc_check_desc(r, h) \
|
||||
if (!SQL_SUCCEEDED(r)) \
|
||||
{ \
|
||||
Poco::Data::ODBC::DescriptorException de(h); \
|
||||
std::cout << de.toString() << std::endl; \
|
||||
} \
|
||||
assert (SQL_SUCCEEDED(r));
|
||||
|
||||
|
||||
class SQLExecutor: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
|
Binary file not shown.
@ -168,6 +168,9 @@ public:
|
||||
void bind(std::size_t pos, const DynamicAny& val, Direction dir = PD_IN);
|
||||
/// Binds a DynamicAny.
|
||||
|
||||
virtual void reset();
|
||||
/// Resets a binder. No-op by default. Implement for binders that cache data.
|
||||
|
||||
static bool isOutBound(Direction dir);
|
||||
/// Returns true if direction is out bound;
|
||||
|
||||
@ -179,6 +182,12 @@ public:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline void AbstractBinder::reset()
|
||||
{
|
||||
//no-op
|
||||
}
|
||||
|
||||
|
||||
inline bool AbstractBinder::isOutBound(Direction dir)
|
||||
{
|
||||
return PD_OUT == dir || PD_IN_OUT == dir;
|
||||
|
@ -138,7 +138,6 @@ public:
|
||||
|
||||
virtual void reset();
|
||||
/// Resets any information internally cached by the extractor.
|
||||
/// (e.g. info about underlying DB null values)
|
||||
};
|
||||
|
||||
|
||||
|
@ -99,6 +99,7 @@ public:
|
||||
void reset ()
|
||||
{
|
||||
_bound = false;
|
||||
getBinder()->reset();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -72,13 +72,13 @@ public:
|
||||
~Date();
|
||||
/// Destroys the Date.
|
||||
|
||||
Poco::UInt32 year() const;
|
||||
int year() const;
|
||||
/// Returns the year.
|
||||
|
||||
Poco::UInt32 month() const;
|
||||
int month() const;
|
||||
/// Returns the month.
|
||||
|
||||
Poco::UInt32 day() const;
|
||||
int day() const;
|
||||
/// Returns the day.
|
||||
|
||||
void assign(int year, int month, int day);
|
||||
@ -109,19 +109,19 @@ private:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline Poco::UInt32 Date::year() const
|
||||
inline int Date::year() const
|
||||
{
|
||||
return _year;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt32 Date::month() const
|
||||
inline int Date::month() const
|
||||
{
|
||||
return _month;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt32 Date::day() const
|
||||
inline int Date::day() const
|
||||
{
|
||||
return _day;
|
||||
}
|
||||
|
@ -72,13 +72,13 @@ public:
|
||||
~Time();
|
||||
/// Destroys the Time.
|
||||
|
||||
Poco::UInt32 hour() const;
|
||||
int hour() const;
|
||||
/// Returns the hour.
|
||||
|
||||
Poco::UInt32 minute() const;
|
||||
int minute() const;
|
||||
/// Returns the minute.
|
||||
|
||||
Poco::UInt32 second() const;
|
||||
int second() const;
|
||||
/// Returns the second.
|
||||
|
||||
void assign(int hour, int minute, int second);
|
||||
@ -109,18 +109,24 @@ private:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline Poco::UInt32 Time::hour() const
|
||||
inline int Time::hour() const
|
||||
{
|
||||
return _hour;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt32 Time::minute() const
|
||||
inline int Time::minute() const
|
||||
{
|
||||
return _minute;
|
||||
}
|
||||
|
||||
|
||||
inline int Time::second() const
|
||||
{
|
||||
return _second;
|
||||
}
|
||||
|
||||
|
||||
inline Time& Time::operator = (const DateTime& dt)
|
||||
{
|
||||
assign(dt.hour(), dt.minute(), dt.second());
|
||||
@ -128,12 +134,6 @@ inline Time& Time::operator = (const DateTime& dt)
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt32 Time::second() const
|
||||
{
|
||||
return _second;
|
||||
}
|
||||
|
||||
|
||||
inline bool Time::operator == (const Time& time)
|
||||
{
|
||||
return _hour == time.hour() &&
|
||||
|
@ -40,7 +40,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\Data\include;..\..\..\Data\SQLite\include"
|
||||
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\Data\include;..\..\..\Data\ODBC\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
@ -1,3 +1,4 @@
|
||||
/*
|
||||
//
|
||||
// Binding.cpp
|
||||
//
|
||||
@ -96,3 +97,112 @@ int main(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "Poco/Data/Session.h"
|
||||
//#include "Poco/Data/SQLite/Connector.h"
|
||||
#include "Poco/Tuple.h"
|
||||
#include "Poco/Data/ODBC/Connector.h"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace Poco::Data;
|
||||
|
||||
|
||||
struct Person
|
||||
{
|
||||
std::string name;
|
||||
std::string address;
|
||||
int age;
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// register SQLite connector
|
||||
//Poco::Data::SQLite::Connector::registerConnector();
|
||||
Poco::Data::ODBC::Connector::registerConnector();
|
||||
|
||||
// create a session
|
||||
//Session session("SQLite", "sample.db");
|
||||
Session session("ODBC", "Dsn=PocoDataPgSQLTest;database=postgres;uid=postgres;pwd=postgres");
|
||||
//Session session("ODBC", "Dsn=AstolatV3;description=AstolatV3;uid=astolat;trusted_connection=Yes;database=AstolatV3");
|
||||
//session.setFeature("autoBind", true);
|
||||
// drop sample table, if it exists
|
||||
//session << "DROP TABLE IF EXISTS Person", now;
|
||||
try {
|
||||
session << "DROP TABLE Person", now;
|
||||
}
|
||||
catch(...) { }
|
||||
|
||||
// (re)create table
|
||||
//session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR(3), Age INTEGER(3))", now;
|
||||
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR(30), Age smallint)", now;
|
||||
|
||||
// insert some rows
|
||||
Person person =
|
||||
{
|
||||
"Bart",
|
||||
"Springfield",
|
||||
12
|
||||
};
|
||||
|
||||
/*
|
||||
typedef Poco::Tuple<std::string, std::string, int> Pers;
|
||||
typedef std::vector<Pers> People;
|
||||
People people;
|
||||
people.push_back(Pers("Bart Simpson", "Springfield", 12));
|
||||
people.push_back(Pers("Lisa Simpson", "Springfield", 10));
|
||||
people.push_back(Pers("Marge Simpson","Springfield", 35));
|
||||
*/
|
||||
Statement insert(session);
|
||||
//insert << "INSERT INTO Person VALUES(:name, :address, :age)",
|
||||
insert << "INSERT INTO Person VALUES(?, ?, ?)",
|
||||
use(person.name),
|
||||
use(person.address),
|
||||
use(person.age);
|
||||
|
||||
insert.execute();
|
||||
|
||||
person.name = "Lisa Simpson";
|
||||
person.address = "Springfield";
|
||||
person.age = 10;
|
||||
|
||||
insert.execute();
|
||||
|
||||
person.name = "Marge Simpson";
|
||||
person.address = "Springfield";
|
||||
person.age = 35;
|
||||
|
||||
insert.execute();
|
||||
|
||||
// a simple query
|
||||
Statement select(session);
|
||||
select << "SELECT Name, Address, Age FROM Person",
|
||||
into(person.name),
|
||||
into(person.address),
|
||||
into(person.age),
|
||||
range(0, 1); // iterate over result set one row at a time
|
||||
|
||||
while (!select.done())
|
||||
{
|
||||
select.execute();
|
||||
std::cout << person.name << " " << person.address << " " << person.age << std::endl;
|
||||
}
|
||||
|
||||
// another query - store the result in a container
|
||||
std::vector<std::string> names;
|
||||
session << "SELECT Name FROM Person",
|
||||
into(names),
|
||||
now;
|
||||
|
||||
for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
|
||||
{
|
||||
std::cout << "Name:" << *it << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TypeHandler", "TypeHandler\
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RecordSet", "RecordSet\RecordSet_vs80.vcproj", "{56F66D36-F11E-4AA1-AD37-4518A253059D}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tuple", "Tuple\Tuple_vs80.vcproj", "{79D784CB-663C-444E-BCB2-1A1166D19DFB}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tuple", "Tuple\Tuple_vs80.vcproj", "{08C81227-3322-4DBD-A83F-55CCC933A5F7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -27,10 +27,10 @@ Global
|
||||
{56F66D36-F11E-4AA1-AD37-4518A253059D}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||
{56F66D36-F11E-4AA1-AD37-4518A253059D}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||
{56F66D36-F11E-4AA1-AD37-4518A253059D}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||
{79D784CB-663C-444E-BCB2-1A1166D19DFB}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||
{79D784CB-663C-444E-BCB2-1A1166D19DFB}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||
{79D784CB-663C-444E-BCB2-1A1166D19DFB}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||
{79D784CB-663C-444E-BCB2-1A1166D19DFB}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||
{08C81227-3322-4DBD-A83F-55CCC933A5F7}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||
{08C81227-3322-4DBD-A83F-55CCC933A5F7}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||
{08C81227-3322-4DBD-A83F-55CCC933A5F7}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||
{08C81227-3322-4DBD-A83F-55CCC933A5F7}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -33,7 +33,8 @@
|
||||
#include "DataTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Data/Common.h"
|
||||
#include "Poco/Data/Session.h"
|
||||
#include "Poco/Data/SessionFactory.h"
|
||||
#include "Poco/Data/BLOB.h"
|
||||
#include "Poco/Data/BLOBStream.h"
|
||||
#include "Poco/Data/MetaColumn.h"
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "SessionPoolTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Data/Common.h"
|
||||
#include "Poco/Data/SessionPool.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include "Connector.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user