--- sql/mysql/parser3mysql.C 2009/04/08 11:13:00 1.35 +++ sql/mysql/parser3mysql.C 2010/10/18 21:48:22 1.37 @@ -1,16 +1,16 @@ /** @file Parser MySQL driver. - Copyright(c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright(c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - 2001.07.30 using MySQL 3.23.22b + 2001-07-30 using MySQL 3.23.22b - 2001.11.06 numrows on "HP-UX istok1 B.11.00 A 9000/869 448594332 two-user license" + 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.35 2009/04/08 11:13:00 misha Exp $"; +static const char *RCSId="$Id: parser3mysql.C,v 1.37 2010/10/18 21:48:22 moko Exp $"; #include "config_includes.h" @@ -29,14 +29,16 @@ static const char *RCSId="$Id: parser3my #endif // for mysql < 4.1 +#if !defined(CLIENT_MULTI_RESULTS) || !defined(CLIENT_MULTI_STATEMENTS) +# define OLD_MYSQL_CLIENT 1 +#endif + #ifndef CLIENT_MULTI_RESULTS -#define CLIENT_MULTI_RESULTS (1UL << 17) -#define OLD_MYSQL_CLIENT 1 +# define CLIENT_MULTI_RESULTS (1UL << 17) #endif + #ifndef CLIENT_MULTI_STATEMENTS -#define CLIENT_MULTI_STATEMENTS (1UL << 16) -#undef OLD_MYSQL_CLIENT -#define OLD_MYSQL_CLIENT 1 +# define CLIENT_MULTI_STATEMENTS (1UL << 16) #endif static char *lsplit(char *string, char delim){ @@ -251,16 +253,63 @@ public: return mysql_ping(connection.handle)==0; } - const char* quote(void *aconnection, const char *from, unsigned int length) { + // charset here is services.request_charset(), not connection.client_charset + // thus we can't use the sql server quoting support + const char* quote(void *aconnection, const char *str, unsigned int length) { + const char* from; + const char* from_end=str+length; + + size_t quoted=0; + + for(from=str; from(aconnection); - /* - 3.23.22b - You must allocate the to buffer to be at least length*2+1 bytes long. - (In the worse case, each character may need to be encoded as using two bytes, - and you need room for the terminating null byte.) - */ - char *result=(char*)connection.services->malloc_atomic(length*2+1); - mysql_escape_string(result, from, length); + char *result=(char*)connection.services->malloc_atomic(length + quoted + 1); + char *to = result; + + for(from=str; from