--- sql/mysql/parser3mysql.C 2004/12/23 16:54:52 1.26 +++ sql/mysql/parser3mysql.C 2008/05/04 07:37:31 1.30 @@ -10,7 +10,7 @@ 2001.11.06 numrows on "HP-UX istok1 B.11.00 A 9000/869 448594332 two-user license" 3.23.42 & 4.0.0.alfa never worked, both subst & .sl version returned 0 */ -static const char *RCSId="$Id: parser3mysql.C,v 1.26 2004/12/23 16:54:52 paf Exp $"; +static const char *RCSId="$Id: parser3mysql.C,v 1.30 2008/05/04 07:37:31 misha Exp $"; #include "config_includes.h" @@ -70,13 +70,18 @@ struct Connection { bool autocommit; }; + /** MySQL server driver */ class MySQL_Driver : public SQL_Driver { public: - MySQL_Driver() : SQL_Driver() { + MySQL_Driver() : SQL_Driver() {} + + ~MySQL_Driver() { + if(mysql_server_end) + mysql_server_end(); } /// get api version @@ -94,8 +99,10 @@ public: compress=1& named_pipe=1 3.23.22b - Currently the only option for @b character_set_name is cp1251_koi8. - WARNING: must be used only to connect, for buffer doesn't live long + Currently the only option for @b character_set_name is cp1251_koi8. + WARNING: must be used only to connect, for buffer doesn't live long + 4.1+ accept not only 'cp1251_koi8' but 'cp1251', 'utf8' and much more + it can be usable for transcoding using sql server */ void connect( char *url, @@ -161,17 +168,17 @@ public: } } - if(connection.cstrClientCharset && cstrBackwardCompAskServerToTranscode) - services._throw("use 'ClientCharset' option only, " - "'charset' option is obsolete and should not be used with new 'ClientCharset' option"); + // if(connection.cstrClientCharset && cstrBackwardCompAskServerToTranscode) + // services._throw("use 'ClientCharset' option only, " + // "'charset' option is obsolete and should not be used with new 'ClientCharset' option"); if(!mysql_real_connect(connection.handle, - host, user, pwd, db, port?port:MYSQL_PORT, unix_socket, 0)) + host, user, pwd, db, port?port:MYSQL_PORT, unix_socket, CLIENT_MULTI_RESULTS)) services._throw(mysql_error(connection.handle)); if(cstrBackwardCompAskServerToTranscode) { // set charset - char statement[MAX_STRING]="set CHARACTER SET "; // cp1251_koi8 + char statement[MAX_STRING]="set CHARACTER SET "; strncat(statement, cstrBackwardCompAskServerToTranscode, MAX_STRING); exec(connection, statement); @@ -346,6 +353,8 @@ private: // mysql client library funcs typedef MYSQL* (STDCALL *t_mysql_init)(MYSQL *); t_mysql_init mysql_init; + typedef void (STDCALL *t_mysql_server_end)(); t_mysql_server_end mysql_server_end; + typedef int (STDCALL *t_mysql_options)(MYSQL *mysql, enum mysql_option option, const char *arg); t_mysql_options mysql_options; typedef MYSQL_RES* (STDCALL *t_mysql_store_result)(MYSQL *); t_mysql_store_result mysql_store_result; @@ -397,8 +406,11 @@ private: // mysql client library funcs l return "can not open the dynamic link module"; } + #define GLINK(name) \ + name=(t_##name)lt_dlsym(handle, #name); + #define DSLINK(name, action) \ - name=(t_##name)lt_dlsym(handle, #name); \ + GLINK(name) \ if(!name) \ action; @@ -406,6 +418,7 @@ private: // mysql client library funcs l #define SLINK(name) DSLINK(name, name=subst_##name) DLINK(mysql_init); + GLINK(mysql_server_end); DLINK(mysql_options); DLINK(mysql_store_result); DLINK(mysql_query); @@ -426,5 +439,6 @@ private: // mysql client library funcs l }; extern "C" SQL_Driver *SQL_DRIVER_CREATE() { - return new MySQL_Driver(); + static MySQL_Driver Driver; + return &Driver; }