Skip to content

Commit 1352e35

Browse files
committed
Remove warnings from build.
1 parent a490ec4 commit 1352e35

File tree

8 files changed

+1054
-1056
lines changed

8 files changed

+1054
-1056
lines changed

driver/mysql_prepared_statement.cpp

Lines changed: 716 additions & 718 deletions
Large diffs are not rendered by default.

driver/mysql_ps_resultset.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ MySQL_Prepared_ResultSet::MySQL_Prepared_ResultSet(
9191
MySQL_Prepared_Statement * par,
9292
boost::shared_ptr< MySQL_DebugLogger > & l
9393
)
94-
: row(NULL), proxy(s), last_queried_column(-1), row_position(0), parent(par),
94+
: row(NULL), proxy(s), last_queried_column(std::numeric_limits<uint32_t>::max()), row_position(0), parent(par),
9595
is_valid(true), logger(l), result_bind(r_bind), resultset_type(rset_type)
9696
{
9797
CPP_ENTER("MySQL_Prepared_ResultSet::MySQL_Prepared_ResultSet");
@@ -215,7 +215,9 @@ MySQL_Prepared_ResultSet::checkScrollable() const
215215
throw sql::NonScrollableException("Nonscrollable result set");
216216
}
217217
// reset last_queried_column
218-
last_queried_column = -1;
218+
last_queried_column = std::numeric_limits<uint32_t>::max();
219+
220+
219221
}
220222
/* }}} */
221223

@@ -1265,7 +1267,7 @@ MySQL_Prepared_ResultSet::next()
12651267
CPP_INFO_FMT("new_row_position=%llu ret=%d", row_position, ret);
12661268
} else {
12671269
// reset last_queried_column
1268-
last_queried_column = -1;
1270+
last_queried_column = std::numeric_limits<uint32_t>::max();
12691271
int result = proxy->fetch();
12701272
if (!result || result == MYSQL_DATA_TRUNCATED) {
12711273
ret = true;
@@ -1418,7 +1420,7 @@ MySQL_Prepared_ResultSet::wasNull() const
14181420
if (isBeforeFirstOrAfterLast()) {
14191421
throw sql::InvalidArgumentException("MySQL_Prepared_ResultSet::wasNull: can't fetch because not on result set");
14201422
}
1421-
if (last_queried_column == -1) {
1423+
if (last_queried_column == std::numeric_limits<uint32_t>::max()) {
14221424
throw sql::InvalidArgumentException("MySQL_Prepared_ResultSet::wasNull: should be called only after one of the getter methods");
14231425
}
14241426
return *result_bind->rbind[last_queried_column - 1].is_null != 0;

driver/mysql_resultset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ MySQL_ResultSet::wasNull() const
10621062
if (isBeforeFirstOrAfterLast()) {
10631063
throw sql::InvalidArgumentException("MySQL_ResultSet::wasNull: can't fetch because not on result set");
10641064
}
1065-
if (last_queried_column == -1) {
1065+
if (last_queried_column == std::numeric_limits<uint32_t>::max()) {
10661066
throw sql::InvalidArgumentException("MySQL_ResultSet::wasNull: should be called only after one of the getter methods");
10671067
}
10681068
return was_null;

driver/mysql_uri.cpp

Lines changed: 123 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2626
#include <stdlib.h>
2727
#include "mysql_uri.h"
2828
#include "mysql_util.h"
29+
#include "exception.h"
2930

3031
namespace sql
3132
{
@@ -43,91 +44,95 @@ static const int DEFAULT_TCP_PORT= 3306;
4344

4445
/* {{{ MySQL_Uri::MySQL_Uri() -I- */
4546
MySQL_Uri::MySQL_Uri()
46-
: protocol(NativeAPI::PROTOCOL_TCP),
47-
port (DEFAULT_TCP_PORT),
48-
/* Perhaps `localhost` has to be default. so w/out any parameter
49-
driver will still connect? */
50-
host (""),
51-
schema ("")
47+
: protocol(NativeAPI::PROTOCOL_TCP),
48+
port (DEFAULT_TCP_PORT),
49+
/* Perhaps `localhost` has to be default. so w/out any parameter
50+
driver will still connect? */
51+
host (""),
52+
schema ("")
5253
{}
5354
/* }}} */
5455

5556

5657
/* {{{ MySQL_Uri::Host() -I- */
5758
const sql::SQLString & MySQL_Uri::Host()
5859
{
59-
static const sql::SQLString hostValue4Pipe(".");
60-
static const sql::SQLString hostValue4sock(util::LOCALHOST);
61-
62-
switch (Protocol())
63-
{
64-
case NativeAPI::PROTOCOL_TCP:
65-
return host;
66-
case NativeAPI::PROTOCOL_PIPE:
67-
return hostValue4Pipe;
68-
case NativeAPI::PROTOCOL_SOCKET:
69-
return hostValue4sock;
70-
}
71-
72-
// throw smoething maybe?
73-
return host;
60+
static const sql::SQLString hostValue4Pipe(".");
61+
static const sql::SQLString hostValue4sock(util::LOCALHOST);
62+
63+
switch (Protocol())
64+
{
65+
case NativeAPI::PROTOCOL_TCP:
66+
return host;
67+
case NativeAPI::PROTOCOL_PIPE:
68+
return hostValue4Pipe;
69+
case NativeAPI::PROTOCOL_SOCKET:
70+
return hostValue4sock;
71+
72+
case NativeAPI::PROTOCOL_COUNT:
73+
throw sql::InvalidArgumentException("NativeAPI::PROTOCOL_COUNT shouldn't be used.");
74+
break;
75+
}
76+
77+
// throw smoething maybe?
78+
return host;
7479
}
7580
/* }}} */
7681

7782

7883
/* {{{ MySQL_Uri::SocketOrPipe() -I- */
7984
const sql::SQLString & MySQL_Uri::SocketOrPipe()
8085
{
81-
if (tcpProtocol(*this))
82-
{
83-
static const sql::SQLString emptystr(util::EMPTYSTR);
84-
return emptystr;
85-
}
86+
if (tcpProtocol(*this))
87+
{
88+
static const sql::SQLString emptystr(util::EMPTYSTR);
89+
return emptystr;
90+
}
8691

87-
return host;
92+
return host;
8893
}
8994
/* }}} */
9095

9196

9297
/* {{{ MySQL_Uri::setHost() -I- */
9398
void MySQL_Uri::setHost(const sql::SQLString &h)
9499
{
95-
setProtocol(NativeAPI::PROTOCOL_TCP);
96-
host= h.c_str();
100+
setProtocol(NativeAPI::PROTOCOL_TCP);
101+
host= h.c_str();
97102
}
98103
/* }}} */
99104

100105

101106
/* {{{ MySQL_Uri::setSocket() -I- */
102107
void MySQL_Uri::setSocket(const sql::SQLString &s)
103108
{
104-
setProtocol(NativeAPI::PROTOCOL_SOCKET);
105-
host= s.c_str();
109+
setProtocol(NativeAPI::PROTOCOL_SOCKET);
110+
host= s.c_str();
106111
}
107112
/* }}} */
108113

109114

110115
/* {{{ MySQL_Uri::setPipe() -I- */
111116
void MySQL_Uri::setPipe(const sql::SQLString &p)
112117
{
113-
setProtocol(NativeAPI::PROTOCOL_PIPE);
114-
host= p.c_str();
118+
setProtocol(NativeAPI::PROTOCOL_PIPE);
119+
host= p.c_str();
115120
}
116121
/* }}} */
117122

118123

119124
/* {{{ MySQL_Uri::setPort() -I- */
120125
void MySQL_Uri::setPort(unsigned int p)
121126
{
122-
setProtocol(NativeAPI::PROTOCOL_TCP);
123-
port= p;
127+
setProtocol(NativeAPI::PROTOCOL_TCP);
128+
port= p;
124129
}
125130

126131

127132
/* {{{ tcpProtocol() -I- */
128133
bool tcpProtocol(MySQL_Uri& uri)
129134
{
130-
return uri.Protocol() == NativeAPI::PROTOCOL_TCP;
135+
return uri.Protocol() == NativeAPI::PROTOCOL_TCP;
131136
}
132137
/* }}} */
133138

@@ -139,88 +144,88 @@ bool tcpProtocol(MySQL_Uri& uri)
139144
*/
140145
bool parseUri(const sql::SQLString & str, MySQL_Uri& uri)
141146
{
142-
if (!str.compare(0, sizeof(MYURI_SOCKET_PREFIX) - 1, MYURI_SOCKET_PREFIX))
143-
{
144-
uri.setSocket(str.substr(sizeof(MYURI_SOCKET_PREFIX) - 1, sql::SQLString::npos));
145-
146-
return true;
147-
}
148-
149-
if (!str.compare(0, sizeof(MYURI_PIPE_PREFIX) - 1 , MYURI_PIPE_PREFIX))
150-
{
151-
uri.setPipe(str.substr(sizeof(MYURI_PIPE_PREFIX) - 1, sql::SQLString::npos));
152-
153-
return true;
154-
}
155-
156-
sql::SQLString host;
157-
size_t start_sep, end_sep;
158-
159-
/* i wonder how did it work with "- 1"*/
160-
if (!str.compare(0, sizeof(MYURI_TCP_PREFIX) - 1, MYURI_TCP_PREFIX) )
161-
{
162-
host= str.substr(sizeof(MYURI_TCP_PREFIX) - 1, sql::SQLString::npos);
163-
}
164-
else
165-
{
166-
/* allowing to have port and schema specified even w/out protocol
167-
specifier("tcp://") */
168-
host= str.c_str();
169-
}
170-
171-
if (host[0] == MYURI_HOST_BEGIN)
172-
{
173-
end_sep= host.find(MYURI_HOST_END);
174-
175-
/* No closing ] after [*/
176-
if (end_sep == sql::SQLString::npos)
177-
{
178-
return false;
179-
}
180-
181-
uri.setHost(host.substr(1, end_sep - 1));
182-
/* Cutting host to continue w/ port and schema reading */
183-
host= host.substr(end_sep + 1);
184-
}
185-
186-
/* Looking where schema part begins */
187-
start_sep = host.find('/');
188-
189-
if (start_sep != sql::SQLString::npos)
190-
{
191-
if ((host.length() - start_sep) > 1/*Slash*/)
192-
{
193-
uri.setSchema(host.substr(start_sep + 1, host.length() - start_sep - 1));
194-
}
195-
196-
host= host.substr(0, start_sep);
197-
}
198-
else
199-
{
200-
uri.setSchema("");
201-
}
202-
203-
/* Looking where port part begins*/
204-
start_sep = host.find_last_of(':', sql::SQLString::npos);
205-
206-
if (start_sep != sql::SQLString::npos)
207-
{
208-
uri.setPort(atoi(host.substr(start_sep + 1, sql::SQLString::npos).c_str()));
209-
host = host.substr(0, start_sep);
210-
}
211-
else
212-
{
213-
uri.setPort(DEFAULT_TCP_PORT);
214-
}
215-
216-
/* If host was enclosed in [], it has been already set, and "host" variable is
217-
empty */
218-
if (host.length() > 0)
219-
{
220-
uri.setHost(host);
221-
}
222-
223-
return true;
147+
if (!str.compare(0, sizeof(MYURI_SOCKET_PREFIX) - 1, MYURI_SOCKET_PREFIX))
148+
{
149+
uri.setSocket(str.substr(sizeof(MYURI_SOCKET_PREFIX) - 1, sql::SQLString::npos));
150+
151+
return true;
152+
}
153+
154+
if (!str.compare(0, sizeof(MYURI_PIPE_PREFIX) - 1 , MYURI_PIPE_PREFIX))
155+
{
156+
uri.setPipe(str.substr(sizeof(MYURI_PIPE_PREFIX) - 1, sql::SQLString::npos));
157+
158+
return true;
159+
}
160+
161+
sql::SQLString host;
162+
size_t start_sep, end_sep;
163+
164+
/* i wonder how did it work with "- 1"*/
165+
if (!str.compare(0, sizeof(MYURI_TCP_PREFIX) - 1, MYURI_TCP_PREFIX) )
166+
{
167+
host= str.substr(sizeof(MYURI_TCP_PREFIX) - 1, sql::SQLString::npos);
168+
}
169+
else
170+
{
171+
/* allowing to have port and schema specified even w/out protocol
172+
specifier("tcp://") */
173+
host= str.c_str();
174+
}
175+
176+
if (host[0] == MYURI_HOST_BEGIN)
177+
{
178+
end_sep= host.find(MYURI_HOST_END);
179+
180+
/* No closing ] after [*/
181+
if (end_sep == sql::SQLString::npos)
182+
{
183+
return false;
184+
}
185+
186+
uri.setHost(host.substr(1, end_sep - 1));
187+
/* Cutting host to continue w/ port and schema reading */
188+
host= host.substr(end_sep + 1);
189+
}
190+
191+
/* Looking where schema part begins */
192+
start_sep = host.find('/');
193+
194+
if (start_sep != sql::SQLString::npos)
195+
{
196+
if ((host.length() - start_sep) > 1/*Slash*/)
197+
{
198+
uri.setSchema(host.substr(start_sep + 1, host.length() - start_sep - 1));
199+
}
200+
201+
host= host.substr(0, start_sep);
202+
}
203+
else
204+
{
205+
uri.setSchema("");
206+
}
207+
208+
/* Looking where port part begins*/
209+
start_sep = host.find_last_of(':', sql::SQLString::npos);
210+
211+
if (start_sep != sql::SQLString::npos)
212+
{
213+
uri.setPort(atoi(host.substr(start_sep + 1, sql::SQLString::npos).c_str()));
214+
host = host.substr(0, start_sep);
215+
}
216+
else
217+
{
218+
uri.setPort(DEFAULT_TCP_PORT);
219+
}
220+
221+
/* If host was enclosed in [], it has been already set, and "host" variable is
222+
empty */
223+
if (host.length() > 0)
224+
{
225+
uri.setHost(host);
226+
}
227+
228+
return true;
224229
}
225230

226231

0 commit comments

Comments
 (0)