--- sql/oracle/parser3oracle.C 2008/07/08 08:07:49 1.72 +++ sql/oracle/parser3oracle.C 2011/07/28 07:15:08 1.74 @@ -8,7 +8,7 @@ 2001.07.30 using Oracle 8.1.6 [@test tested with Oracle 7.x.x] */ -static const char *RCSId="$Id: parser3oracle.C,v 1.72 2008/07/08 08:07:49 misha Exp $"; +static const char *RCSId="$Id: parser3oracle.C,v 1.74 2011/07/28 07:15:08 moko Exp $"; #include "config_includes.h" @@ -275,8 +275,8 @@ public: if(!error) OCIInitialize((ub4)OCI_THREADED/*| OCI_OBJECT*/, (dvoid *)0, - (dvoid * (*)(void *, unsigned int))0, - (dvoid * (*)(void*, void*, unsigned int))0, + (dvoid * (*)(void *, size_t))0, + (dvoid * (*)(void*, void*, size_t))0, (void (*)(void*, void*))0 ); } @@ -445,20 +445,33 @@ public: return true; } - 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) { - Connection& connection=*static_cast(aconnection); - char *result=(char*)connection.services->malloc_atomic(length*2+1); - char *to=result; - while(length--) { - switch(*from) { - case '\'': // "'" -> "''" - *to++='\''; - break; - } - *to++=*from++; + const char* from; + const char* from_end=str+length; + + size_t quoted=0; + + for(from=str; from(aconnection); + char *result=(char*)connection.services->malloc_atomic(length + quoted + 1); + char *to = result; + + for(from=str; from '' + *to++=*from; + } + *to=0; return result; } @@ -882,17 +895,17 @@ private: // private funcs (dvoid**) &col_name, (ub4 *) &col_name_len, (ub4)OCI_ATTR_NAME, (OCIError *)connection.errhp)); + size_t length=(size_t)col_name_len; if(transcode_needed){ // transcode column name from ?ClientCharset to $request:charset services.transcode(col_name, col_name_len, - col_name, col_name_len, + col_name, length, client_charset, request_charset); } Col& col=cols[column_count-1]; { - size_t length=(size_t)col_name_len; char *ptr=(char *)services.malloc_atomic(length+1); if( connection.options.bLowerCaseColumnNames ) tolower_str(ptr, col_name, length);