--- sql/mysql/parser3mysql.C 2004/04/01 11:42:53 1.22 +++ sql/mysql/parser3mysql.C 2007/09/17 17:00:58 1.28 @@ -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.22 2004/04/01 11:42:53 paf Exp $"; +static const char *RCSId="$Id: parser3mysql.C,v 1.28 2007/09/17 17:00:58 misha Exp $"; #include "config_includes.h" @@ -46,6 +46,17 @@ static char *lsplit(char **string_ref, c return result; } +static char* rsplit(char* string, char delim) { + if(string) { + char* v=strrchr(string, delim); + if(v) { + *v=0; + return v+1; + } + } + return NULL; +} + static void toupper_str(char *out, const char *in, size_t size) { while(size--) *out++=(char)toupper(*in++); @@ -76,23 +87,25 @@ public: dlink(dlopen_file_spec):"client library column is empty"; } /** connect - @param used_only_in_connect_url + @param url format: @b user:pass@host[:port]|[/unix/socket]/database? charset=cp1251_koi8& timeout=3& 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 *used_only_in_connect_url, + char *url, SQL_Driver_services& services, void **connection_ref ///< output: Connection* ) { - char *user=used_only_in_connect_url; - char *s=lsplit(user, '@'); + char *user=url; + char *s=rsplit(user, '@'); char *host=0; char *unix_socket=0; if(s && s[0]=='[') { // unix socket @@ -150,17 +163,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_STATEMENTS)) 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); @@ -214,15 +227,19 @@ public: mysql_escape_string(result, from, length); return result; } - void query( - void *aconnection, - const char *astatement, unsigned long offset, unsigned long limit, + void query(void *aconnection, + const char *astatement, + size_t placeholders_count, Placeholder* placeholders, + unsigned long offset, unsigned long limit, SQL_Driver_query_event_handlers& handlers) { Connection& connection=*static_cast(aconnection); SQL_Driver_services& services=*connection.services; const char* cstrClientCharset=connection.cstrClientCharset; MYSQL_RES *res=NULL; + if(placeholders_count>0) + services._throw("bind variables not supported (yet)"); + // transcode from $request:charset to connect-string?client_charset if(cstrClientCharset) { size_t transcoded_statement_size; @@ -375,8 +392,12 @@ private: // mysql client library funcs l if(lt_dlinit()) return lt_dlerror(); lt_dlhandle handle=lt_dlopen(dlopen_file_spec); - if (!handle) + if (!handle) { + if(const char* result=lt_dlerror()) + return result; + return "can not open the dynamic link module"; + } #define DSLINK(name, action) \ name=(t_##name)lt_dlsym(handle, #name); \