Skip to content

Commit a50823c

Browse files
committed
data housekeeping
- removed naked pointers from Data interfaces - fixed GH pocoproject#82: name conflict in Data::Keywords::bind - fixed GH pocoproject#157: MySQL: cannot bind to 'long' data type on Windows/Visual C++ - fixed GH pocoproject#158: MySQL: MYSQL_BIND 'is_unsigned' member is not set
1 parent c620798 commit a50823c

34 files changed

+671
-599
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ Release 1.5.2 (2013-04-29)
3939
- fixed GH #141: Application::run() documentation/implementation discrepancy
4040
- changed RowFormatter to SharedPtr<RowFormatter> in Data::RecordSet interface (breaking change!)
4141
- fixed GH #144: Poco::Dynamic emits invalid JSON
42+
- removed naked pointers from Data interfaces
43+
- fixed GH #82: name conflict in Data::Keywords::bind
44+
- fixed GH #157: MySQL: cannot bind to 'long' data type on Windows/Visual C++
45+
- fixed GH #158: MySQL: MYSQL_BIND 'is_unsigned' member is not set
4246

4347
Release 1.5.1 (2013-01-11)
4448
==========================

Data/MySQL/MySQL_vs110.vcxproj

Lines changed: 84 additions & 80 deletions
Large diffs are not rendered by default.

Data/MySQL/include/Poco/Data/MySQL/Binder.h

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,54 +54,53 @@ class MySQL_API Binder: public Poco::Data::AbstractBinder
5454
/// Binds placeholders in the sql query to the provided values. Performs data types mapping.
5555
{
5656
public:
57+
typedef SharedPtr<Binder> Ptr;
5758

5859
Binder();
5960
/// Creates the Binder.
6061

6162
virtual ~Binder();
6263
/// Destroys the Binder.
63-
64+
6465
virtual void bind(std::size_t pos, const Poco::Int8& val, Direction dir);
6566
/// Binds an Int8.
6667

6768
virtual void bind(std::size_t pos, const Poco::UInt8& val, Direction dir);
6869
/// Binds an UInt8.
69-
70+
7071
virtual void bind(std::size_t pos, const Poco::Int16& val, Direction dir);
7172
/// Binds an Int16.
72-
73+
7374
virtual void bind(std::size_t pos, const Poco::UInt16& val, Direction dir);
7475
/// Binds an UInt16.
75-
76+
7677
virtual void bind(std::size_t pos, const Poco::Int32& val, Direction dir);
7778
/// Binds an Int32.
78-
79+
7980
virtual void bind(std::size_t pos, const Poco::UInt32& val, Direction dir);
8081
/// Binds an UInt32.
81-
82+
8283
virtual void bind(std::size_t pos, const Poco::Int64& val, Direction dir);
8384
/// Binds an Int64.
84-
85+
8586
virtual void bind(std::size_t pos, const Poco::UInt64& val, Direction dir);
8687
/// Binds an UInt64.
8788

88-
#ifndef POCO_LONG_IS_64_BIT
8989
virtual void bind(std::size_t pos, const long& val, Direction dir = PD_IN);
9090
/// Binds a long.
9191

9292
virtual void bind(std::size_t pos, const unsigned long& val, Direction dir = PD_IN);
9393
/// Binds an unsigned long.
94-
#endif
95-
94+
9695
virtual void bind(std::size_t pos, const bool& val, Direction dir);
9796
/// Binds a boolean.
98-
97+
9998
virtual void bind(std::size_t pos, const float& val, Direction dir);
10099
/// Binds a float.
101-
100+
102101
virtual void bind(std::size_t pos, const double& val, Direction dir);
103102
/// Binds a double.
104-
103+
105104
virtual void bind(std::size_t pos, const char& val, Direction dir);
106105
/// Binds a single character.
107106

@@ -154,27 +153,27 @@ class MySQL_API Binder: public Poco::Data::AbstractBinder
154153
virtual void bind(std::size_t pos, const std::vector<Poco::Int32>& val, Direction dir = PD_IN);
155154

156155
virtual void bind(std::size_t pos, const std::deque<Poco::Int32>& val, Direction dir = PD_IN);
157-
156+
158157
virtual void bind(std::size_t pos, const std::list<Poco::Int32>& val, Direction dir = PD_IN);
159-
158+
160159
virtual void bind(std::size_t pos, const std::vector<Poco::UInt32>& val, Direction dir = PD_IN);
161-
160+
162161
virtual void bind(std::size_t pos, const std::deque<Poco::UInt32>& val, Direction dir = PD_IN);
163-
162+
164163
virtual void bind(std::size_t pos, const std::list<Poco::UInt32>& val, Direction dir = PD_IN);
165-
164+
166165
virtual void bind(std::size_t pos, const std::vector<Poco::Int64>& val, Direction dir = PD_IN);
167-
166+
168167
virtual void bind(std::size_t pos, const std::deque<Poco::Int64>& val, Direction dir = PD_IN);
169-
168+
170169
virtual void bind(std::size_t pos, const std::list<Poco::Int64>& val, Direction dir = PD_IN);
171-
170+
172171
virtual void bind(std::size_t pos, const std::vector<Poco::UInt64>& val, Direction dir = PD_IN);
173-
172+
174173
virtual void bind(std::size_t pos, const std::deque<Poco::UInt64>& val, Direction dir = PD_IN);
175-
174+
176175
virtual void bind(std::size_t pos, const std::list<Poco::UInt64>& val, Direction dir = PD_IN);
177-
176+
178177
virtual void bind(std::size_t pos, const std::vector<bool>& val, Direction dir = PD_IN);
179178

180179
virtual void bind(std::size_t pos, const std::deque<bool>& val, Direction dir = PD_IN);
@@ -261,7 +260,7 @@ class MySQL_API Binder: public Poco::Data::AbstractBinder
261260
{
262261
}
263262

264-
void realBind(std::size_t pos, enum_field_types type, const void* buffer, int length);
263+
void realBind(std::size_t pos, enum_field_types type, const void* buffer, int length, bool isUnsigned = false);
265264
/// Common bind implementation
266265

267266
private:

Data/MySQL/include/Poco/Data/MySQL/Extractor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class MySQL_API Extractor: public Poco::Data::AbstractExtractor
6262
/// If NULL is received, the incoming val value is not changed and false is returned
6363
{
6464
public:
65+
typedef SharedPtr<Extractor> Ptr;
66+
6567
Extractor(StatementExecutor& st, ResultMetadata& md);
6668
/// Creates the Extractor.
6769

Data/MySQL/include/Poco/Data/MySQL/MySQLStatementImpl.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class MySQL_API MySQLStatementImpl: public Poco::Data::StatementImpl
5959
/// Implements statement functionality needed for MySQL
6060
{
6161
public:
62-
6362
MySQLStatementImpl(SessionImpl& s);
6463
/// Creates the MySQLStatementImpl.
6564

@@ -69,7 +68,7 @@ class MySQL_API MySQLStatementImpl: public Poco::Data::StatementImpl
6968
protected:
7069

7170
virtual std::size_t columnsReturned() const;
72-
/// Returns number of columns returned by query.
71+
/// Returns number of columns returned by query.
7372

7473
virtual std::size_t affectedRowCount() const;
7574
/// Returns the number of affected rows.
@@ -97,10 +96,10 @@ class MySQL_API MySQLStatementImpl: public Poco::Data::StatementImpl
9796
virtual void bindImpl();
9897
/// Binds parameters
9998

100-
virtual AbstractExtractor& extractor();
99+
virtual Poco::Data::AbstractExtractor::Ptr extractor();
101100
/// Returns the concrete extractor used by the statement.
102101

103-
virtual AbstractBinder& binder();
102+
virtual Poco::Data::AbstractBinder::Ptr binder();
104103
/// Returns the concrete binder used by the statement.
105104

106105
private:
@@ -113,8 +112,8 @@ class MySQL_API MySQLStatementImpl: public Poco::Data::StatementImpl
113112

114113
StatementExecutor _stmt;
115114
ResultMetadata _metadata;
116-
Binder _binder;
117-
Extractor _extractor;
115+
Binder::Ptr _pBinder;
116+
Extractor::Ptr _pExtractor;
118117
int _hasNext;
119118
};
120119

Data/MySQL/src/Binder.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ Binder::Binder()
4949

5050
Binder::~Binder()
5151
{
52-
for (std::vector<MYSQL_TIME*>::iterator it = _dates.begin(); it != _dates.end(); ++it)
53-
{
54-
delete *it;
55-
*it = 0;
56-
}
52+
for (std::vector<MYSQL_TIME*>::iterator it = _dates.begin(); it != _dates.end(); ++it)
53+
{
54+
delete *it;
55+
*it = 0;
56+
}
5757
}
5858

5959

@@ -67,7 +67,7 @@ void Binder::bind(std::size_t pos, const Poco::Int8& val, Direction dir)
6767
void Binder::bind(std::size_t pos, const Poco::UInt8& val, Direction dir)
6868
{
6969
poco_assert(dir == PD_IN);
70-
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
70+
realBind(pos, MYSQL_TYPE_TINY, &val, 0, true);
7171
}
7272

7373

@@ -81,7 +81,7 @@ void Binder::bind(std::size_t pos, const Poco::Int16& val, Direction dir)
8181
void Binder::bind(std::size_t pos, const Poco::UInt16& val, Direction dir)
8282
{
8383
poco_assert(dir == PD_IN);
84-
realBind(pos, MYSQL_TYPE_SHORT, &val, 0);
84+
realBind(pos, MYSQL_TYPE_SHORT, &val, 0, true);
8585
}
8686

8787

@@ -95,7 +95,7 @@ void Binder::bind(std::size_t pos, const Poco::Int32& val, Direction dir)
9595
void Binder::bind(std::size_t pos, const Poco::UInt32& val, Direction dir)
9696
{
9797
poco_assert(dir == PD_IN);
98-
realBind(pos, MYSQL_TYPE_LONG, &val, 0);
98+
realBind(pos, MYSQL_TYPE_LONG, &val, 0, true);
9999
}
100100

101101

@@ -109,24 +109,30 @@ void Binder::bind(std::size_t pos, const Poco::Int64& val, Direction dir)
109109
void Binder::bind(std::size_t pos, const Poco::UInt64& val, Direction dir)
110110
{
111111
poco_assert(dir == PD_IN);
112-
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
112+
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0, true);
113113
}
114114

115115

116-
#ifndef POCO_LONG_IS_64_BIT
117116
void Binder::bind(std::size_t pos, const long& val, Direction dir)
118117
{
119118
poco_assert(dir == PD_IN);
119+
#ifdef POCO_LONG_IS_64_BIT
120120
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
121+
#else
122+
realBind(pos, MYSQL_TYPE_LONG, &val, 0);
123+
#endif
121124
}
122125

123126

124127
void Binder::bind(std::size_t pos, const unsigned long& val, Direction dir)
125128
{
126129
poco_assert(dir == PD_IN);
127-
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
128-
}
130+
#ifdef POCO_LONG_IS_64_BIT
131+
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0, true);
132+
#else
133+
realBind(pos, MYSQL_TYPE_LONG, &val, 0, true);
129134
#endif
135+
}
130136

131137

132138
void Binder::bind(std::size_t pos, const bool& val, Direction dir)
@@ -290,7 +296,7 @@ MYSQL_BIND* Binder::getBindArray() const
290296
//
291297
////////////////////
292298

293-
void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer, int length)
299+
void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer, int length, bool isUnsigned)
294300
{
295301
if (pos >= _bindArray.size())
296302
{
@@ -303,8 +309,9 @@ void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer
303309
MYSQL_BIND b = {0};
304310

305311
b.buffer_type = type;
306-
b.buffer = const_cast<void*>(buffer);
312+
b.buffer = const_cast<void*>(buffer);
307313
b.buffer_length = length;
314+
b.is_unsigned = isUnsigned;
308315

309316
_bindArray[pos] = b;
310317
}

Data/MySQL/src/MySQLStatementImpl.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ namespace MySQL {
4444
MySQLStatementImpl::MySQLStatementImpl(SessionImpl& h) :
4545
Poco::Data::StatementImpl(h),
4646
_stmt(h.handle()),
47-
_extractor(_stmt, _metadata),
47+
_pBinder(new Binder),
48+
_pExtractor(new Extractor(_stmt, _metadata)),
4849
_hasNext(NEXT_DONTKNOW)
4950
{
5051
}
@@ -160,21 +161,21 @@ void MySQLStatementImpl::bindImpl()
160161
pos += (*it)->numOfColumnsHandled();
161162
}
162163

163-
_stmt.bindParams(_binder.getBindArray(), _binder.size());
164+
_stmt.bindParams(_pBinder->getBindArray(), _pBinder->size());
164165
_stmt.execute();
165166
_hasNext = NEXT_DONTKNOW;
166167
}
167168

168169

169-
AbstractExtractor& MySQLStatementImpl::extractor()
170+
Poco::Data::AbstractExtractor::Ptr MySQLStatementImpl::extractor()
170171
{
171-
return _extractor;
172+
return _pExtractor;
172173
}
173174

174175

175-
AbstractBinder& MySQLStatementImpl::binder()
176+
Poco::Data::AbstractBinder::Ptr MySQLStatementImpl::binder()
176177
{
177-
return _binder;
178+
return _pBinder;
178179
}
179180

180181

0 commit comments

Comments
 (0)