Author: wyoung
Date: Sun Mar 23 04:07:51 2008
New Revision: 2256
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2256&view=rev
Log:
MySQL 3.23 portability improvements. NOT COMPLETE, but it's a start for
the person who wants to have it. Complete portability requires one
change that's too invasive to accept for everyone, and the examples
don't run right as-is due to InnoDB requirement.
Modified:
trunk/lib/dbdriver.cpp
trunk/lib/dbdriver.h
trunk/lib/field.h
trunk/lib/options.cpp
trunk/lib/options.h
trunk/lib/type_info.h
Modified: trunk/lib/dbdriver.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/dbdriver.cpp?rev=2256&r1=2255&r2=2256&view=diff
==============================================================================
--- trunk/lib/dbdriver.cpp (original)
+++ trunk/lib/dbdriver.cpp Sun Mar 23 04:07:51 2008
@@ -170,7 +170,12 @@
if ((n == 1) &&
(o >= CLIENT_LONG_PASSWORD) &&
- (o <= CLIENT_MULTI_RESULTS)) {
+#if MYSQL_VERSION_ID > 40000 // highest flag value varies by version
+ (o <= CLIENT_MULTI_RESULTS)
+#else
+ (o <= CLIENT_TRANSACTIONS)
+#endif
+ ) {
// Option value seems sane, so go ahead and set/clear the flag
if (arg) {
mysql_.client_flag |= o;
Modified: trunk/lib/dbdriver.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/dbdriver.h?rev=2256&r1=2255&r2=2256&view=diff
==============================================================================
--- trunk/lib/dbdriver.h (original)
+++ trunk/lib/dbdriver.h Sun Mar 23 04:07:51 2008
@@ -61,7 +61,8 @@
enum nr_code {
nr_more_results, ///< success, with more results to come
nr_last_result, ///< success, last result recieved
- nr_error ///< problem retrieving next
result
+ nr_error, ///< problem retrieving next
result
+ nr_not_supported ///< this C API doesn't support "next
result"
};
/// \brief Create object
@@ -298,11 +299,15 @@
/// enum values.
nr_code next_result()
{
- switch (mysql_next_result(&mysql_)) {
- case 0: return nr_more_results;
- case -1: return nr_last_result;
- default: return nr_error;
- }
+ #if MYSQL_VERSION_ID > 41000 // only in MySQL v4.1 +
+ switch (mysql_next_result(&mysql_)) {
+ case 0: return nr_more_results;
+ case -1: return nr_last_result;
+ default: return nr_error;
+ }
+ #else
+ return nr_not_supported;
+ #endif
}
/// \brief Returns the number of fields in the given result set
@@ -460,7 +465,12 @@
///
/// This exists because the MySQL C API library allocates some
per-thread
/// memory which it doesn't release until you call this.
- static void thread_end() { mysql_thread_end(); }
+ static void thread_end()
+ {
+ #if MYSQL_VERSION_ID > 40000 // only in MySQL v4.0 +
+ mysql_thread_end();
+ #endif
+ }
/// \brief Returns the MySQL server thread ID for this connection
///
@@ -486,7 +496,14 @@
/// any MySQL++ objects. If you use a DBDriverPool object, this
/// applies; DBDriverPool isn't smart enough to call this for you,
/// and the MySQL C API won't do it, either.
- static bool thread_start() { return !mysql_thread_init(); }
+ static bool thread_start()
+ {
+ #if MYSQL_VERSION_ID > 40000 // only in MySQL v4.0 +
+ return !mysql_thread_init();
+ #else
+ return false;
+ #endif
+ }
/// \brief Returns a result set from the last-executed query which
/// we can walk through in linear fashion, which doesn't store all
Modified: trunk/lib/field.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/field.h?rev=2256&r1=2255&r2=2256&view=diff
==============================================================================
--- trunk/lib/field.h (original)
+++ trunk/lib/field.h Sun Mar 23 04:07:51 2008
@@ -58,7 +58,9 @@
Field(const MYSQL_FIELD* pf) :
name_(pf->name),
table_(pf->table),
+#if MYSQL_VERSION_ID > 40000 // only in 4.0 +
db_(pf->db),
+#endif
type_(pf->type, (pf->flags & UNSIGNED_FLAG) != 0,
(pf->flags & NOT_NULL_FLAG) == 0),
length_(pf->length),
Modified: trunk/lib/options.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/options.cpp?rev=2256&r1=2255&r2=2256&view=diff
==============================================================================
--- trunk/lib/options.cpp (original)
+++ trunk/lib/options.cpp Sun Mar 23 04:07:51 2008
@@ -178,6 +178,7 @@
}
+#if MYSQL_VERSION_ID > 40000 // only in 4.0 +
Option::Error
ProtocolOption::set(DBDriver* dbd)
{
@@ -185,6 +186,7 @@
dbd->set_option(MYSQL_OPT_PROTOCOL, &arg_) ?
Option::err_NONE : Option::err_api_reject;
}
+#endif
Option::Error
Modified: trunk/lib/options.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/options.h?rev=2256&r1=2255&r2=2256&view=diff
==============================================================================
--- trunk/lib/options.h (original)
+++ trunk/lib/options.h Sun Mar 23 04:07:51 2008
@@ -264,6 +264,7 @@
};
+#if MYSQL_VERSION_ID > 40000 // only in 4.0 +
/// \brief Set type of protocol to use
class MYSQLPP_EXPORT ProtocolOption : public IntegerOption
{
@@ -275,6 +276,7 @@
Error set(DBDriver* dbd);
#endif
};
+#endif
/// \brief Override use of my.cnf
Modified: trunk/lib/type_info.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/type_info.h?rev=2256&r1=2255&r2=2256&view=diff
==============================================================================
--- trunk/lib/type_info.h (original)
+++ trunk/lib/type_info.h Sun Mar 23 04:07:51 2008
@@ -68,7 +68,13 @@
mysql_ti_sql_type_info() :
sql_name_(0),
c_type_(0),
- base_type_(MYSQL_TYPE_NULL),
+ base_type_(
+#if MYSQL_VERSION_ID > 40000
+ MYSQL_TYPE_NULL
+#else
+ FIELD_TYPE_NULL
+#endif
+ ),
flags_(0)
{
}
@@ -261,7 +267,12 @@
///
/// We expose this because other parts of MySQL++ need to know
/// what the string constant is at the moment.
- static const enum_field_types string_type = MYSQL_TYPE_STRING;
+ static const enum_field_types string_type =
+#if MYSQL_VERSION_ID > 40000
+ MYSQL_TYPE_STRING;
+#else
+ FIELD_TYPE_STRING;
+#endif
private:
typedef mysql_ti_sql_type_info sql_type_info;
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits