--- sql/oracle/parser3oracle.C 2004/05/19 09:32:50 1.57 +++ sql/oracle/parser3oracle.C 2004/06/18 11:29:55 1.59 @@ -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.57 2004/05/19 09:32:50 paf Exp $"; +static const char *RCSId="$Id: parser3oracle.C,v 1.59 2004/06/18 11:29:55 paf Exp $"; #include "config_includes.h" @@ -83,7 +83,6 @@ static int pa_setenv(const char *name, c strcat(buf, value); value=buf; } - return setenv(name, value, 1/*overwrite*/); } else { unsetenv(name); @@ -246,7 +245,7 @@ public: } /** connect - @param used_only_in_connect_url + @param url format: @b user:pass@service? ORACLE_HOME=/u01/app/oracle/product/8.1.5& ORA_NLS33=/u01/app/oracle/product/8.1.5/ocommon/nls/admin/data& @@ -254,20 +253,21 @@ public: ORA_ENCRYPT_LOGIN=TRUE @todo environment manupulation doesnt look thread safe + @todo allocate 'aused_only_in_connect_url' on gc heap, so it can be manipulated directly */ void connect( - char *used_only_in_connect_url, + char *url, SQL_Driver_services& services, void **connection_ref ///< output: Connection * ) { // connections are cross-request, do not use services._alloc [linked with request] - Connection& connection=*(Connection *)::calloc(1, sizeof(Connection)); + 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 *user=url; char *service=lsplit(user, '@'); char *pwd=lsplit(user, ':'); char *options=lsplit(service, '?'); @@ -344,13 +344,15 @@ public: void disconnect(void *aconnection) { Connection& connection=*static_cast(aconnection); - // free fetch buffers + // free fetch buffers. leave that to GC [no such services func. yet?] + /* for(int i=0; ifree(fetch_buffer); else break; - } + } + */ // Terminate a user session OCISessionEnd( @@ -371,8 +373,8 @@ public: OCIHandleFree( (dvoid *)connection.envhp, (ub4)OCI_HTYPE_ENV); - // connections are cross-request, do not use services._alloc [linked with request] - ::free(&connection); + // free connection. leave that to GC [no such services func. yet?] + // connection.services->free(&connection); } void commit(void *aconnection) { Connection& connection=*static_cast(aconnection); @@ -453,9 +455,12 @@ public: check(connection, "alloc output var desc", OCIDescriptorAlloc( (dvoid *)connection.envhp, (dvoid **)&item.locator, (ub4)OCI_DTYPE_LOB, 0, 0)); - check(connection, "bind output", OCIBindByPos(stmthp, + char placeholder_buf[MAX_STRING]; + sb4 placeh_len=snprintf(placeholder_buf, sizeof(placeholder_buf), + ":%.*s", item.name_size, item.name_ptr); + check(connection, "bind lob", OCIBindByName(stmthp, &item.bind, connection.errhp, - (ub4)1+i, + (text*)placeholder_buf, placeh_len, (dvoid *)&item.locator, (sword)sizeof (item.locator), SQLT_CLOB, (dvoid *)0, (ub2 *)0, (ub2 *)0, (ub4)0, (ub4 *)0, OCI_DATA_AT_EXEC)); @@ -747,7 +752,7 @@ private: // private funcs char*& buf=connection.fetch_buffers[column_count-1]; ptr=buf; // get cached buffer if(!ptr) // allocate if needed, caching it - ptr=buf=(char *)::/*see disconnect*/malloc(MAX_OUT_STRING_LENGTH+1/*terminator*/); + ptr=buf=(char *)services.malloc_atomic(MAX_OUT_STRING_LENGTH+1/*terminator*/); col.str=(char*)ptr; size=MAX_OUT_STRING_LENGTH; break; @@ -892,6 +897,11 @@ private: // conn client library funcs ub2 dty, dvoid *indp, ub2 *alenp, ub2 *rcodep, ub4 maxarr_len, ub4 *curelep, ub4 mode)); + OCI_DECL(BindByName, (OCIStmt *stmtp, OCIBind **bindp, OCIError *errhp, + text* placeholder, sb4 placeh_len, dvoid *valuep, sb4 value_sz, + ub2 dty, dvoid *indp, ub2 *alenp, ub2 *rcodep, + ub4 maxarr_len, ub4 *curelep, ub4 mode)); + OCI_DECL(BindDynamic, (OCIBind *bindp, OCIError *errhp, dvoid *ictxp, OCICallbackInBind icbfp, dvoid *octxp, OCICallbackOutBind ocbfp)); @@ -983,7 +993,7 @@ private: // conn client library funcs li OCI_LINK(Initialize); OCI_LINK(EnvInit); OCI_LINK(AttrGet); OCI_LINK(AttrSet); - OCI_LINK(BindByPos); OCI_LINK(BindDynamic); + OCI_LINK(BindByPos); OCI_LINK(BindByName); OCI_LINK(BindDynamic); OCI_LINK(DefineByPos); OCI_LINK(DescriptorAlloc); OCI_LINK(DescriptorFree); OCI_LINK(ErrorGet);