Skip to content

Commit 112cde5

Browse files
committed
WL14216: Support query attributes
1 parent 9f63f84 commit 112cde5

15 files changed

+1091
-164
lines changed

cppconn/statement.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ class Statement
9696
virtual void setQueryTimeout(unsigned int seconds) = 0;
9797

9898
virtual Statement * setResultSetType(sql::ResultSet::enum_type type) = 0;
99+
100+
virtual int setQueryAttrBigInt(const sql::SQLString &name, const sql::SQLString& value) = 0;
101+
virtual int setQueryAttrBoolean(const sql::SQLString &name, bool value) = 0;
102+
virtual int setQueryAttrDateTime(const sql::SQLString &name, const sql::SQLString& value) = 0;
103+
virtual int setQueryAttrDouble(const sql::SQLString &name, double value) = 0;
104+
virtual int setQueryAttrInt(const sql::SQLString &name, int32_t value) = 0;
105+
virtual int setQueryAttrUInt(const sql::SQLString &name, uint32_t value) = 0;
106+
virtual int setQueryAttrInt64(const sql::SQLString &name, int64_t value) = 0;
107+
virtual int setQueryAttrUInt64(const sql::SQLString &name, uint64_t value) = 0;
108+
virtual int setQueryAttrNull(const sql::SQLString &name) = 0;
109+
virtual int setQueryAttrString(const sql::SQLString &name, const sql::SQLString& value) = 0;
110+
111+
virtual void clearAttributes() = 0;
112+
99113
};
100114

101115
} /* namespace sql */

driver/mysql_prepared_statement.cpp

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class BlobIsNull : public boost::static_visitor<bool>
203203
};
204204

205205

206-
void resetBlobBind(MYSQL_BIND & param)
206+
void resetBlobBind(MYSQL_BIND & param)
207207
{
208208
delete [] static_cast<char *>(param.buffer);
209209

@@ -1266,6 +1266,134 @@ MySQL_Prepared_Statement::setResultSetType(sql::ResultSet::enum_type /* type */)
12661266
/* }}} */
12671267

12681268

1269+
/* {{{ MySQL_Prepared_Statement::setQueryAttrBigInt() -U- */
1270+
int
1271+
MySQL_Prepared_Statement::setQueryAttrBigInt(const sql::SQLString &name, const sql::SQLString& value)
1272+
{
1273+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrBigInt");
1274+
CPP_INFO_FMT("this=%p", this);
1275+
CPP_INFO_FMT("name=%s value=%s", name.c_str(), value.c_str());
1276+
return 0;
1277+
}
1278+
/* }}} */
1279+
1280+
1281+
/* {{{ MySQL_Prepared_Statement::setQueryAttrBoolean() -U- */
1282+
int
1283+
MySQL_Prepared_Statement::setQueryAttrBoolean(const sql::SQLString &name, bool value)
1284+
{
1285+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrBoolean");
1286+
CPP_INFO_FMT("this=%p", this);
1287+
CPP_INFO_FMT("name=%s value=%s", name.c_str(), value ? "true" : "false");
1288+
return 0;
1289+
}
1290+
/* }}} */
1291+
1292+
1293+
/* {{{ MySQL_Prepared_Statement::setQueryAttrDateTime() -U- */
1294+
int
1295+
MySQL_Prepared_Statement::setQueryAttrDateTime(const sql::SQLString &name, const sql::SQLString& value)
1296+
{
1297+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrDateTime");
1298+
CPP_INFO_FMT("this=%p", this);
1299+
CPP_INFO_FMT("name=%s value=%s", name.c_str(), value.c_str());
1300+
return 0;
1301+
}
1302+
/* }}} */
1303+
1304+
1305+
/* {{{ MySQL_Prepared_Statement::setQueryAttrDouble() -U- */
1306+
int
1307+
MySQL_Prepared_Statement::setQueryAttrDouble(const sql::SQLString &name, double value)
1308+
{
1309+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrDouble");
1310+
CPP_INFO_FMT("this=%p", this);
1311+
CPP_INFO_FMT("name=%s value=%f", name.c_str(), value);
1312+
return 0;
1313+
}
1314+
/* }}} */
1315+
1316+
1317+
/* {{{ MySQL_Prepared_Statement::setQueryAttrInt() -U- */
1318+
int
1319+
MySQL_Prepared_Statement::setQueryAttrInt(const sql::SQLString &name, int32_t value)
1320+
{
1321+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrInt");
1322+
CPP_INFO_FMT("this=%p", this);
1323+
CPP_INFO_FMT("name=%s value=%f", name.c_str(), value);
1324+
return 0;
1325+
}
1326+
/* }}} */
1327+
1328+
1329+
/* {{{ MySQL_Prepared_Statement::setQueryAttrUInt() -U- */
1330+
int
1331+
MySQL_Prepared_Statement::setQueryAttrUInt(const sql::SQLString &name, uint32_t value)
1332+
{
1333+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrUInt");
1334+
CPP_INFO_FMT("this=%p", this);
1335+
CPP_INFO_FMT("name=%s value=%f", name.c_str(), value);
1336+
return 0;
1337+
}
1338+
/* }}} */
1339+
1340+
1341+
/* {{{ MySQL_Prepared_Statement::setQueryAttrInt64() -U- */
1342+
int
1343+
MySQL_Prepared_Statement::setQueryAttrInt64(const sql::SQLString &name, int64_t value)
1344+
{
1345+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrInt64");
1346+
CPP_INFO_FMT("this=%p", this);
1347+
CPP_INFO_FMT("name=%s value=%f", name.c_str(), value);
1348+
return 0;
1349+
}
1350+
/* }}} */
1351+
1352+
1353+
/* {{{ MySQL_Prepared_Statement::setQueryAttrUInt64() -U- */
1354+
int
1355+
MySQL_Prepared_Statement::setQueryAttrUInt64(const sql::SQLString &name, uint64_t value)
1356+
{
1357+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrUInt64");
1358+
CPP_INFO_FMT("this=%p", this);
1359+
CPP_INFO_FMT("name=%s value=%f", name.c_str(), value);
1360+
return 0;
1361+
}
1362+
/* }}} */
1363+
1364+
1365+
/* {{{ MySQL_Prepared_Statement::setQueryAttrNull() -U- */
1366+
int
1367+
MySQL_Prepared_Statement::setQueryAttrNull(const sql::SQLString &name)
1368+
{
1369+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrNull");
1370+
CPP_INFO_FMT("this=%p", this);
1371+
CPP_INFO_FMT("name=%s", name.c_str());
1372+
return 0;
1373+
}
1374+
/* }}} */
1375+
1376+
1377+
/* {{{ MySQL_Prepared_Statement::setQueryAttrString() -U- */
1378+
int
1379+
MySQL_Prepared_Statement::setQueryAttrString(const sql::SQLString &name, const sql::SQLString& value)
1380+
{
1381+
CPP_ENTER("MySQL_Prepared_Statement::setQueryAttrString");
1382+
CPP_INFO_FMT("this=%p", this);
1383+
CPP_INFO_FMT("name=%s value=%f", name.c_str(), value.c_str());
1384+
return 0;
1385+
}
1386+
/* }}} */
1387+
1388+
1389+
/* {{{ MySQL_Prepared_Statement::clearAttributes() -U- */
1390+
void
1391+
MySQL_Prepared_Statement::clearAttributes()
1392+
{
1393+
}
1394+
/* }}} */
1395+
1396+
12691397
/* {{{ MySQL_Prepared_Statement::checkClosed() -I- */
12701398
void
12711399
MySQL_Prepared_Statement::checkClosed()

driver/mysql_prepared_statement.h

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -97,86 +97,99 @@ class MySQL_Prepared_Statement : public sql::PreparedStatement
9797
boost::shared_ptr< MySQL_DebugLogger > & log);
9898
virtual ~MySQL_Prepared_Statement();
9999

100-
sql::Connection *getConnection();
100+
sql::Connection *getConnection() override;
101101

102-
void cancel();
102+
void cancel() override;
103103

104-
void clearParameters();
104+
void clearParameters() override;
105105

106-
void clearWarnings();
106+
void clearWarnings() override;
107107

108-
void close();
108+
void close() override;
109109

110-
bool execute();
111-
bool execute(const sql::SQLString& sql);
110+
bool execute() override;
111+
bool execute(const sql::SQLString& sql) override;
112112

113-
sql::ResultSet *executeQuery();
114-
sql::ResultSet *executeQuery(const sql::SQLString& sql);
113+
sql::ResultSet *executeQuery() override;
114+
sql::ResultSet *executeQuery(const sql::SQLString& sql) override;
115115

116-
int executeUpdate();
117-
int executeUpdate(const sql::SQLString& sql);
116+
int executeUpdate() override;
117+
int executeUpdate(const sql::SQLString& sql) override;
118118

119-
size_t getFetchSize();
119+
size_t getFetchSize() override;
120120

121-
unsigned int getMaxFieldSize();
121+
unsigned int getMaxFieldSize() override;
122122

123-
sql::ResultSetMetaData * getMetaData();
123+
sql::ResultSetMetaData * getMetaData() override;
124124

125-
uint64_t getMaxRows();
125+
uint64_t getMaxRows() override;
126126

127-
bool getMoreResults();
127+
bool getMoreResults() override;
128128

129-
sql::ParameterMetaData * getParameterMetaData();
129+
sql::ParameterMetaData * getParameterMetaData() override;
130130

131-
unsigned int getQueryTimeout();
131+
unsigned int getQueryTimeout() override;
132132

133-
sql::ResultSet * getResultSet();
133+
sql::ResultSet * getResultSet() override;
134134

135-
sql::ResultSet::enum_type getResultSetType();
135+
sql::ResultSet::enum_type getResultSetType() override;
136136

137-
uint64_t getUpdateCount();
137+
uint64_t getUpdateCount() override;
138138

139-
const SQLWarning * getWarnings();/* should return different type */
139+
const SQLWarning * getWarnings() override;/* should return different type */
140140

141141
Statement * setBuffered();
142142

143-
void setBlob(unsigned int parameterIndex, std::istream * blob);
143+
void setBlob(unsigned int parameterIndex, std::istream * blob) override;
144144

145-
void setBoolean(unsigned int parameterIndex, bool value);
145+
void setBoolean(unsigned int parameterIndex, bool value) override;
146146

147-
void setBigInt(unsigned int parameterIndex, const sql::SQLString& value);
147+
void setBigInt(unsigned int parameterIndex, const sql::SQLString& value) override;
148148

149-
void setCursorName(const sql::SQLString &name);
149+
void setCursorName(const sql::SQLString &name) override;
150150

151-
void setDateTime(unsigned int parameterIndex, const sql::SQLString& value);
151+
void setDateTime(unsigned int parameterIndex, const sql::SQLString& value) override;
152152

153-
void setDouble(unsigned int parameterIndex, double value);
153+
void setDouble(unsigned int parameterIndex, double value) override;
154154

155-
void setEscapeProcessing(bool enable);
155+
void setEscapeProcessing(bool enable) override;
156156

157-
void setFetchSize(size_t rows);
157+
void setFetchSize(size_t rows) override;
158158

159-
void setInt(unsigned int parameterIndex, int32_t value);
159+
void setInt(unsigned int parameterIndex, int32_t value) override;
160160

161-
void setUInt(unsigned int parameterIndex, uint32_t value);
161+
void setUInt(unsigned int parameterIndex, uint32_t value) override;
162162

163-
void setInt64(unsigned int parameterIndex, int64_t value);
163+
void setInt64(unsigned int parameterIndex, int64_t value) override;
164164

165-
void setUInt64(unsigned int parameterIndex, uint64_t value);
165+
void setUInt64(unsigned int parameterIndex, uint64_t value) override;
166166

167-
void setMaxFieldSize(unsigned int max);
167+
void setMaxFieldSize(unsigned int max) override;
168168

169-
void setMaxRows(unsigned int max);
169+
void setMaxRows(unsigned int max) override;
170170

171-
void setNull(unsigned int parameterIndex, int sqlType);
171+
void setNull(unsigned int parameterIndex, int sqlType) override;
172172

173173
void setResultSetConcurrency(int concurrencyFlag);
174174

175-
void setString(unsigned int parameterIndex, const sql::SQLString& value);
175+
void setString(unsigned int parameterIndex, const sql::SQLString& value) override;
176176

177-
void setQueryTimeout(unsigned int seconds);
177+
void setQueryTimeout(unsigned int seconds) override;
178178

179-
sql::PreparedStatement * setResultSetType(sql::ResultSet::enum_type type);
179+
sql::PreparedStatement * setResultSetType(sql::ResultSet::enum_type type) override;
180+
181+
int setQueryAttrBigInt(const sql::SQLString &name, const sql::SQLString& value) override;
182+
int setQueryAttrBoolean(const sql::SQLString &name, bool value) override;
183+
int setQueryAttrDateTime(const sql::SQLString &name, const sql::SQLString& value) override;
184+
int setQueryAttrDouble(const sql::SQLString &name, double value) override;
185+
int setQueryAttrInt(const sql::SQLString &name, int32_t value) override;
186+
int setQueryAttrUInt(const sql::SQLString &name, uint32_t value) override;
187+
int setQueryAttrInt64(const sql::SQLString &name, int64_t value) override;
188+
int setQueryAttrUInt64(const sql::SQLString &name, uint64_t value) override;
189+
int setQueryAttrNull(const sql::SQLString &name) override;
190+
int setQueryAttrString(const sql::SQLString &name, const sql::SQLString& value) override;
191+
192+
void clearAttributes() override;
180193

181194
private:
182195
/* Prevent use of these */

0 commit comments

Comments
 (0)