--- sql/oracle/parser3oracle.C 2004/01/26 14:59:08 1.49 +++ sql/oracle/parser3oracle.C 2004/03/30 08:18:24 1.55 @@ -7,7 +7,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.49 2004/01/26 14:59:08 paf Exp $"; +static const char *RCSId="$Id: parser3oracle.C,v 1.55 2004/03/30 08:18:24 paf Exp $"; #include "config_includes.h" @@ -173,8 +173,8 @@ static sb4 cbf_get_data(dvoid *ctxp, ub1 *piecep, dvoid **indpp, ub2 **rcodepp); -void tolower(char *out, const char *in, size_t size); -void toupper(char *out, const char *in, size_t size); +static void tolower_str(char *out, const char *in, size_t size); +static void toupper_str(char *out, const char *in, size_t size); static const char *options2env(char *s, Connection::Options* options) { while(s) { @@ -183,7 +183,7 @@ static const char *options2env(char *s, if(char *value=lsplit(key, '=')) { if( strcmp( key, "ClientCharset" ) == 0 ) { if(options) { - toupper(value, value, strlen(value)); + toupper_str(value, value, strlen(value)); options->cstrClientCharset = value; } continue; @@ -261,12 +261,12 @@ public: void connect( char *used_only_in_connect_url, SQL_Driver_services& services, - void **aconnection ///< output: Connection * + void **connection_ref ///< output: Connection * ) { - // connections are cross-request, do not use services._alloc [linked with request] - Connection& connection=*(Connection *)::calloc(sizeof(Connection), 1); + Connection& connection=*(Connection *)services.malloc(sizeof(Connection)); connection.services=&services; connection.options.bLowerCaseColumnNames = true; + *connection_ref=&connection; char *user=used_only_in_connect_url; char *service=lsplit(user, '@'); @@ -341,9 +341,6 @@ public: (dvoid *)connection.svchp, (ub4)OCI_HTYPE_SVCCTX, (dvoid *)connection.usrhp, (ub4)0, OCI_ATTR_SESSION, connection.errhp)); - - // return created connection - *(Connection **)aconnection=&connection; } void disconnect(void *aconnection) { Connection& connection=*static_cast(aconnection); @@ -423,18 +420,20 @@ public: SQL_Driver_query_event_handlers& handlers) { Connection& connection=*static_cast(aconnection); + const char* cstrClientCharset=connection.options.cstrClientCharset; OracleSQL_query_lobs lobs={{0}, 0}; OCIStmt *stmthp=0; SQL_Driver_services& services=*connection.services; // transcode from $request:charset to connect-string?client_charset - size_t transcoded_statement_size; - if(const char* cstrClientCharset=connection.options.cstrClientCharset) + if(cstrClientCharset) { + size_t transcoded_statement_size; services.transcode(astatement, strlen(astatement), astatement, transcoded_statement_size, services.request_charset(), cstrClientCharset); + } bool failed=false; if(setjmp(connection.mark)) { @@ -653,6 +652,7 @@ private: // private funcs OCIStmt *stmthp, unsigned long offset, unsigned long limit, SQL_Driver_query_event_handlers& handlers) { + const char* cstrClientCharset=connection.options.cstrClientCharset; SQL_Driver_services& services=*connection.services; ub4 prefetch_rows=100; @@ -669,7 +669,7 @@ private: // private funcs OCIParam *mypard; ub2 dtype; - text *col_name; + const char* col_name; struct Col { ub2 type; @@ -707,13 +707,20 @@ private: // private funcs (dvoid*) mypard, (ub4)OCI_DTYPE_PARAM, (dvoid**) &col_name, (ub4 *) &col_name_len, (ub4)OCI_ATTR_NAME, (OCIError *)connection.errhp)); - + // transcode to $request:charset from connect-string?client_charset + if(cstrClientCharset) { + services.transcode(col_name, col_name_len, + col_name, col_name_len, + cstrClientCharset, + services.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(ptr, (char *)col_name, length); + tolower_str(ptr, col_name, length); else memcpy(ptr, col_name, length); ptr[length]=0; @@ -820,16 +827,11 @@ private: // private funcs if(str && length) { // transcode to $request:charset from connect-string?client_charset - if(const char* cstrClientCharset=connection.options.cstrClientCharset) { - const char* dest; - size_t dest_length; + if(cstrClientCharset) services.transcode(str, length, - dest, dest_length, + str, length, cstrClientCharset, services.request_charset()); - str=dest; - length=dest_length; - } } check(connection, handlers.add_row_cell(connection.sql_error, str, length)); @@ -1116,11 +1118,11 @@ static sb4 cbf_get_data(dvoid *ctxp, return OCI_CONTINUE; } -void tolower(char *out, const char *in, size_t size) { +static void tolower_str(char *out, const char *in, size_t size) { while(size--) *out++=(char)tolower(*in++); } -void toupper(char *out, const char *in, size_t size) { +static void toupper_str(char *out, const char *in, size_t size) { while(size--) *out++=(char)toupper(*in++); }