9 #define SOCI_MYSQL_SOURCE 16 #pragma warning(disable:4355) 26 : session_(session), result_(NULL),
27 rowsAffectedBulk_(-1LL), justDescribed_(false),
28 hasIntoElements_(false), hasVectorIntoElements_(false),
29 hasUseElements_(false), hasVectorUseElements_(false)
55 enum { eNormal, eInQuotes, eInName } state = eNormal;
61 for (std::string::const_iterator it = query.begin(), end = query.end();
74 const std::string::const_iterator next_it = it + 1;
77 if (next_it != end && *next_it ==
'=')
93 if (*it ==
'\'' && !escaped)
102 escaped = *it ==
'\\' && !escaped;
105 if (std::isalnum(*it) || *it ==
'_')
121 if (state == eInName)
152 "Bulk use with single into elements is not supported.");
156 int numberOfExecutions = 1;
168 "Binding for use elements must be either by position " 171 long long rowsAffectedBulkTemp = 0;
172 for (
int i = 0; i != numberOfExecutions; ++i)
174 std::vector<char *> paramValues;
182 for (UseByPosBuffersMap::iterator
187 char **buffers = it->second;
189 paramValues.push_back(buffers[i]);
196 for (std::vector<std::string>::iterator
200 UseByNameBuffersMap::iterator b
205 "Missing use element for bind by name (");
210 char **buffers = b->second;
211 paramValues.push_back(buffers[i]);
219 throw soci_error(
"Wrong number of parameters.");
222 std::vector<std::string>::const_iterator ci
224 for (std::vector<char*>::const_iterator
225 pi = paramValues.begin(), end = paramValues.end();
226 pi != end; ++ci, ++pi)
235 if (numberOfExecutions > 1)
249 rowsAffectedBulkTemp +=
static_cast<long long>(mysql_affected_rows(
session_.
conn_));
253 throw soci_error(
"The query shouldn't have returned" 254 " any data but it did.");
260 if (numberOfExecutions > 1)
288 int numrows =
static_cast<int>(mysql_num_rows(
result_));
290 for (
int i = 0; i < numrows; i++)
317 return fetch(number);
375 return static_cast<long long>(mysql_affected_rows(
session_.
conn_));
384 std::string
const &query)
386 std::string newQuery(
"select ");
401 data_type & type, std::string & columnName)
403 int pos = colNum - 1;
404 MYSQL_FIELD *field = mysql_fetch_field_direct(
result_, pos);
407 case FIELD_TYPE_CHAR:
408 case FIELD_TYPE_SHORT:
409 case FIELD_TYPE_INT24:
412 case FIELD_TYPE_LONG:
416 case FIELD_TYPE_LONGLONG:
420 case FIELD_TYPE_FLOAT:
421 case FIELD_TYPE_DOUBLE:
422 case FIELD_TYPE_DECIMAL:
430 case FIELD_TYPE_TIMESTAMP:
431 case FIELD_TYPE_DATE:
432 case FIELD_TYPE_TIME:
433 case FIELD_TYPE_DATETIME:
434 case FIELD_TYPE_YEAR:
435 case FIELD_TYPE_NEWDATE:
439 case FIELD_TYPE_VAR_STRING:
440 case FIELD_TYPE_STRING:
441 case FIELD_TYPE_BLOB:
442 case FIELD_TYPE_TINY_BLOB:
443 case FIELD_TYPE_MEDIUM_BLOB:
444 case FIELD_TYPE_LONG_BLOB:
451 columnName = field->name;
virtual exec_fetch_result execute(int number)
virtual int get_number_of_rows()
virtual void prepare(std::string const &query, details::statement_type eType)
virtual mysql_vector_use_type_backend * make_vector_use_type_backend()
long long rowsAffectedBulk_
bool hasVectorUseElements_
std::vector< MYSQL_ROW_OFFSET > resultRowOffsets_
virtual std::string rewrite_for_procedure_call(std::string const &query)
mysql_session_backend & session_
std::vector< std::string > names_
virtual int prepare_for_describe()
bool hasVectorIntoElements_
virtual long long get_affected_rows()
virtual mysql_vector_into_type_backend * make_vector_into_type_backend()
virtual mysql_standard_use_type_backend * make_use_type_backend()
UseByNameBuffersMap useByNameBuffers_
virtual mysql_standard_into_type_backend * make_into_type_backend()
std::vector< std::string > queryChunks_
virtual void describe_column(int colNum, data_type &dtype, std::string &columnName)
mysql_statement_backend(mysql_session_backend &session)
virtual exec_fetch_result fetch(int number)
UseByPosBuffersMap useByPosBuffers_