From acdb53f933afe0ee1a916a67141d529ceebf8eff Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 28 Apr 2011 20:20:27 +0000 Subject: [PATCH] Merge --- libs/libmysqlxx/include/mysqlxx/ResultBase.h | 5 ---- .../include/mysqlxx/StoreQueryResult.h | 5 ---- .../include/mysqlxx/UseQueryResult.h | 7 ----- libs/libmysqlxx/src/ResultBase.cpp | 28 +------------------ libs/libmysqlxx/src/StoreQueryResult.cpp | 27 ++---------------- 5 files changed, 4 insertions(+), 68 deletions(-) diff --git a/libs/libmysqlxx/include/mysqlxx/ResultBase.h b/libs/libmysqlxx/include/mysqlxx/ResultBase.h index cde8594211f..7df77d87ea9 100644 --- a/libs/libmysqlxx/include/mysqlxx/ResultBase.h +++ b/libs/libmysqlxx/include/mysqlxx/ResultBase.h @@ -21,8 +21,6 @@ class ResultBase { public: ResultBase(MYSQL_RES * res_, Connection * conn_, const Query * query_); - ResultBase(const ResultBase & x); - ResultBase & operator= (const ResultBase & x); Connection * getConnection() { return conn; } MYSQL_FIELDS getFields() { return fields; } @@ -41,9 +39,6 @@ protected: const Query * query; MYSQL_FIELDS fields; unsigned num_fields; - -private: - void init(); }; } diff --git a/libs/libmysqlxx/include/mysqlxx/StoreQueryResult.h b/libs/libmysqlxx/include/mysqlxx/StoreQueryResult.h index 705a1cf6e8c..84e2d2fbff1 100644 --- a/libs/libmysqlxx/include/mysqlxx/StoreQueryResult.h +++ b/libs/libmysqlxx/include/mysqlxx/StoreQueryResult.h @@ -26,9 +26,6 @@ class StoreQueryResult : public std::vector, public ResultBase public: StoreQueryResult(MYSQL_RES * res_, Connection * conn_, const Query * query_); - StoreQueryResult(const StoreQueryResult & x); - StoreQueryResult & operator= (const StoreQueryResult & x); - size_t num_rows() const { return size(); } private: @@ -42,8 +39,6 @@ private: */ typedef std::vector Lengths; Lengths lengths; - - void init(); }; } diff --git a/libs/libmysqlxx/include/mysqlxx/UseQueryResult.h b/libs/libmysqlxx/include/mysqlxx/UseQueryResult.h index 374e13bb978..1dec79e04e1 100644 --- a/libs/libmysqlxx/include/mysqlxx/UseQueryResult.h +++ b/libs/libmysqlxx/include/mysqlxx/UseQueryResult.h @@ -27,13 +27,6 @@ class UseQueryResult : public ResultBase public: UseQueryResult(MYSQL_RES * res_, Connection * conn_, const Query * query_); - UseQueryResult(const UseQueryResult & x) : ResultBase(x) {} - UseQueryResult & operator= (const UseQueryResult & x) - { - ResultBase::operator=(x); - return *this; - } - Row fetch(); /// Для совместимости diff --git a/libs/libmysqlxx/src/ResultBase.cpp b/libs/libmysqlxx/src/ResultBase.cpp index 1ef24384ca1..4dca88ea584 100644 --- a/libs/libmysqlxx/src/ResultBase.cpp +++ b/libs/libmysqlxx/src/ResultBase.cpp @@ -5,36 +5,10 @@ namespace mysqlxx { -void ResultBase::init() +ResultBase::ResultBase(MYSQL_RES * res_, Connection * conn_, const Query * query_) : res(res_), conn(conn_), query(query_) { fields = mysql_fetch_fields(res); num_fields = mysql_num_fields(res); } -ResultBase::ResultBase(MYSQL_RES * res_, Connection * conn_, const Query * query_) : res(res_), conn(conn_), query(query_) -{ - init(); -} - -ResultBase::ResultBase(const ResultBase & x) -{ - res = x.res; - conn = x.conn; - query = x.query; - - init(); -} - -ResultBase & ResultBase::operator= (const ResultBase & x) -{ - mysql_free_result(res); - - res = x.res; - conn = x.conn; - query = x.query; - - init(); - return *this; -} - } diff --git a/libs/libmysqlxx/src/StoreQueryResult.cpp b/libs/libmysqlxx/src/StoreQueryResult.cpp index cbd36648076..e75f258e82a 100644 --- a/libs/libmysqlxx/src/StoreQueryResult.cpp +++ b/libs/libmysqlxx/src/StoreQueryResult.cpp @@ -5,42 +5,21 @@ namespace mysqlxx { -void StoreQueryResult::init() +StoreQueryResult::StoreQueryResult(MYSQL_RES * res_, Connection * conn_, const Query * query_) : ResultBase(res_, conn_, query_) { UInt64 rows = mysql_num_rows(res); UInt32 fields = getNumFields(); reserve(rows); lengths.resize(rows * fields); - + for (UInt64 i = 0; MYSQL_ROW row = mysql_fetch_row(res); ++i) { MYSQL_LENGTHS lengths_for_row = mysql_fetch_lengths(res); memcpy(&lengths[i * fields], lengths_for_row, sizeof(lengths[0]) * fields); - + push_back(Row(row, this, &lengths[i * fields])); } checkError(conn->getDriver()); } - -StoreQueryResult::StoreQueryResult(MYSQL_RES * res_, Connection * conn_, const Query * query_) : ResultBase(res_, conn_, query_) -{ - init(); -} - -StoreQueryResult::StoreQueryResult(const StoreQueryResult & x) : ResultBase(x) -{ - init(); -} - -StoreQueryResult & StoreQueryResult::operator= (const StoreQueryResult & x) -{ - ResultBase::operator=(x); - clear(); - lengths.clear(); - - init(); - return *this; -} - }