From a7ce1707b72083e2cbff9245ed106b5a57ba7a41 Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 15 Nov 2007 11:17:01 +0000 Subject: [PATCH] applied Ludovics patch git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1547 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-gdl1/Oracle8/ChangeLog | 4 ++ sope-gdl1/Oracle8/GNUmakefile | 18 +++-- sope-gdl1/Oracle8/OracleAdaptorChannel.m | 65 ++++++++++++------- .../Oracle8/OracleAdaptorChannelController.m | 2 + 4 files changed, 60 insertions(+), 29 deletions(-) diff --git a/sope-gdl1/Oracle8/ChangeLog b/sope-gdl1/Oracle8/ChangeLog index 40f031a5..b0438276 100644 --- a/sope-gdl1/Oracle8/ChangeLog +++ b/sope-gdl1/Oracle8/ChangeLog @@ -1,3 +1,7 @@ +2007-11-15 Ludovic Marcotte + + * fixes + 2007-10-19 Ludovic Marcotte * We call OCITerminate() in OracleAdaptorChannel: diff --git a/sope-gdl1/Oracle8/GNUmakefile b/sope-gdl1/Oracle8/GNUmakefile index 496d732e..b60271cb 100644 --- a/sope-gdl1/Oracle8/GNUmakefile +++ b/sope-gdl1/Oracle8/GNUmakefile @@ -28,15 +28,23 @@ include ./Version SOPE_ROOT=../.. ORACLE_VERSION=10.2.0.3 #ORACLE_VERSION=11.1.0.1 -ADDITIONAL_INCLUDE_DIRS += -I../GDLAccess -I.. -I/usr/include/oracle/$(ORACLE_VERSION)/client +ADDITIONAL_INCLUDE_DIRS += -I../../sope-core -I../../sope-core/NGExtensions -I../GDLAccess -I.. -I/usr/include/oracle/$(ORACLE_VERSION)/client + +local_arch = $(subst 64,,$(shell uname -m)) + +ifeq ($(local_arch),ppc) +PPC_LDFLAGS=-L/opt/ibmcmp/lib -libmc++ +else +PPC_LDFLAGS= +endif ifneq ($(frameworks),yes) -Oracle8_BUNDLE_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -lGDLAccess -lEOControl -otest_TOOL_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -lGDLAccess -lEOControl +common_LIBS = -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -L../GDLAccess/obj -lGDLAccess -L../../sope-core/EOControl/obj -lEOControl $(PPC_LDFLAGS) else -Oracle8_BUNDLE_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl -otest_TOOL_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl +common_LIBS = -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl $(PPC_LDFLAGS) endif +Oracle8_BUNDLE_LIBS += $(common_LIBS) +otest_TOOL_LIBS += $(common_LIBS) # Bundle BUNDLE_NAME = Oracle8 diff --git a/sope-gdl1/Oracle8/OracleAdaptorChannel.m b/sope-gdl1/Oracle8/OracleAdaptorChannel.m index bf090d1f..e6323477 100644 --- a/sope-gdl1/Oracle8/OracleAdaptorChannel.m +++ b/sope-gdl1/Oracle8/OracleAdaptorChannel.m @@ -53,14 +53,17 @@ while (c--) { info = [[_row_buffer objectAtIndex: c] pointerValue]; - [_row_buffer removeObjectAtIndex: c]; // We free our LOB object. If it fails, it likely mean it isn't a LOB // so we just free the value instead. - if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS) - { - free(info->value); - } + if (info->value) + { + if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS) + free(info->value); + info->value = NULL; + } + free(info); + [_row_buffer removeObjectAtIndex: c]; } OCIHandleFree(_current_stm, OCI_HTYPE_STMT); @@ -75,6 +78,30 @@ // @implementation OracleAdaptorChannel +static void +DBTerminate() +{ + if (OCITerminate(OCI_DEFAULT)) + NSLog(@"FAILED: OCITerminate()"); + else + NSLog(@"Oracle8: environment shut down"); +} + ++ (void) initialize +{ + // We Initialize the OCI process environment. + if (OCIInitialize((ub4)OCI_DEFAULT, (dvoid *)0, + (dvoid * (*)(dvoid *, size_t)) 0, + (dvoid * (*)(dvoid *, dvoid *, size_t))0, + (void (*)(dvoid *, dvoid *)) 0 )) + NSLog(@"FAILED: OCIInitialize()"); + else + { + NSLog(@"Oracle8: environment initialized"); + atexit(DBTerminate); + } +} + - (id) initWithAdaptorContext: (EOAdaptorContext *) theAdaptorContext { if ((self = [super initWithAdaptorContext: theAdaptorContext])) @@ -134,10 +161,14 @@ NSLog(@"FAILED: OCILogoff()"); } - if (OCITerminate(OCI_DEFAULT)) - { - NSLog(@"FAILED: OCITerminate()"); - } + + OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX); + OCIHandleFree(_oci_err, OCI_HTYPE_ERROR); + // OCIHandleFree(_oci_env, OCI_HTYPE_ENV); + + _oci_ctx = (OCISvcCtx *)0; + _oci_err = (OCIError *)0; + _oci_env = (OCIEnv *)0; } } @@ -151,11 +182,6 @@ [self _cleanup]; RELEASE(_resultSetProperties); - - OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX); - OCIHandleFree(_oci_err, OCI_HTYPE_ERROR); - OCIHandleFree(_oci_env, OCI_HTYPE_ENV); - RELEASE(delegate); [super dealloc]; @@ -368,16 +394,7 @@ return NO; } - // We Initialize the OCI process environment. - if (OCIInitialize((ub4)OCI_DEFAULT, (dvoid *)0, - (dvoid * (*)(dvoid *, size_t)) 0, - (dvoid * (*)(dvoid *, dvoid *, size_t))0, - (void (*)(dvoid *, dvoid *)) 0 )) - { - NSLog(@"FAILED: OCIInitialize()"); - return NO; - } - + if (OCIEnvInit((OCIEnv **)&_oci_env, (ub4)OCI_DEFAULT, (size_t)0, (dvoid **)0)) { NSLog(@"FAILED: OCIEnvInit()"); diff --git a/sope-gdl1/Oracle8/OracleAdaptorChannelController.m b/sope-gdl1/Oracle8/OracleAdaptorChannelController.m index 7f0ec89f..964fbd2e 100644 --- a/sope-gdl1/Oracle8/OracleAdaptorChannelController.m +++ b/sope-gdl1/Oracle8/OracleAdaptorChannelController.m @@ -155,7 +155,9 @@ OCILobFreeTemporary([theChannel serviceContext], [theChannel errorHandle], info->value); OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB); } + free(info); } + [theColumns release]; OCIHandleFree(theStatement, OCI_HTYPE_STMT); } -- 2.39.5