--- sql/mysql/parser3mysql.C 2004/03/04 10:46:52 1.19 +++ sql/mysql/parser3mysql.C 2004/12/23 16:54:52 1.26 @@ -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.19 2004/03/04 10:46:52 paf Exp $"; +static const char *RCSId="$Id: parser3mysql.C,v 1.26 2004/12/23 16:54:52 paf Exp $"; #include "config_includes.h" @@ -46,7 +46,18 @@ static char *lsplit(char **string_ref, c return result; } -static void toupper(char *out, const char *in, size_t size) { +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,7 +87,7 @@ 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& @@ -87,12 +98,12 @@ public: WARNING: must be used only to connect, for buffer doesn't live long */ 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 @@ -122,7 +133,7 @@ public: if(*key) { if(char *value=lsplit(key, '=')) { if(strcmp(key, "ClientCharset" ) == 0) { - toupper(value, value, strlen(value)); + toupper_str(value, value, strlen(value)); connection.cstrClientCharset=value; } else if(strcasecmp(key, "charset")==0) { // left for backward compatibility, consider using ClientCharset cstrBackwardCompAskServerToTranscode=value; @@ -183,6 +194,7 @@ public: connection.handle=0; } void commit(void *aconnection) { + //_asm int 3; Connection& connection=*static_cast(aconnection); if(!connection.autocommit) @@ -213,16 +225,21 @@ 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(const char* cstrClientCharset=connection.cstrClientCharset) { + if(cstrClientCharset) { size_t transcoded_statement_size; services.transcode(astatement, strlen(astatement), astatement, transcoded_statement_size, @@ -272,12 +289,13 @@ public: for(int i=0; iname); - char* str=(char*)services.malloc_atomic(length+1); - memcpy(str, field->name, length+1); + size_t length=strlen(field->name); + char* strm=(char*)services.malloc_atomic(length+1); + memcpy(strm, field->name, length+1); + const char* str=strm; // transcode to $request:charset from connect-string?client_charset - if(const char* cstrClientCharset=connection.cstrClientCharset) { + if(cstrClientCharset) { services.transcode(str, length, str, length, cstrClientCharset, @@ -300,14 +318,15 @@ public: unsigned long *lengths=mysql_fetch_lengths(res); for(int i=0; i