libs-gdl2/EOAdaptors/Postgres95/Postgres95Channel.m

2059 lines
59 KiB
Mathematica
Raw Normal View History

/**
Postgres95Channel.m <title>Postgres95Channel</title>
2003-06-26 Manuel Guesdon <mguesdon@orange-concept.com> * config.h.in: o added EMIT_TODO control * EOAccess/EOAccessFault.m: o commented debug logs * EOAccess/EODatabaseContext.m: o more information in asserts o asserts o fix in -relayPrimaryKey:object:entity: for nil 1:1 relationship value o add -forgetSnapshotForGlobalID call in -refaultObject:withGlobalID:editingContext: o add -forgetSnapshotForGlobalID database call in -forgetSnapshotForGlobalID: * EOAccess/EOEntity.m: o logs o fix in -awakeObject:fromInsertionInEditingContext: to avoid setting already present values o reverted code in -awakeObject:fromInsertionInEditingContext: My (old) tests show that we create 1: object not on mandatory property but on propagatesPrimaryKey one if someone has an example of EOF creating an object here without propagatesPrimaryKey, please send it to me. * EOAccess/EOModelGroup.m: o don't autorelease return model group in -globalModelGroup as it will crash. I haven't find why :-( o logs * EOAccess/EOSQLExpression.m: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause o add detail in sqlStringForSelector:value: exception * EOAdaptors/Postgres95/PostPostgres95Channel.m: o add more information on exceptions * EOAdaptors/Postgres95/Postgres95SQLExpression.m: o fix escaping string in -formatValue:forAttribute: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause * EOAdaptors/Postgres95/Postgres95Value.m: o Change log in +newValueForDateType:length:attribute: * EOControl/EOCheapArray.m o removed some logs * EOAccess/EOClassDescription.m: o fix in -validateForUpdate o logs * EOControl/Debug.h: o donditional define of NSEmitTODO() * EOControl/EODetailDataSource.h/.m: o added -setDetailKey: * EOControl/EOEditingContext.m o logs * EOControl/EOFetchSpecification.m o logs * EOControl/EOKeyValueCoding.m: o fix in computeSum, computeAverage * EOControl/EOQualifier.m o logs * EOControl/EOSortOrdering.m o use valueForKeyPath: instead of valueForKey: to allow sort on related objects * EOControl/EOUndoManager.h o protection of include git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@17037 72102866-910b-0410-8b05-ffd578937521
2003-06-26 08:20:30 +00:00
Copyright (C) 2000-2003 Free Software Foundation, Inc.
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
Date: February 2000
based on the Postgres95 adaptor written by
Mircea Oancea <mircea@jupiter.elcom.pub.ro>
Author: Manuel Guesdon <mguesdon@orange-concept.com>
Date: October 2000
$Revision$
$Date$
<abstract></abstract>
This file is part of the GNUstep Database Library.
<license>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
</license>
**/
#include "config.h"
RCS_ID("$Id$")
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#ifdef GNUSTEP
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#include <Foundation/NSArray.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSString.h>
#include <Foundation/NSSet.h>
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSUtilities.h>
#include <Foundation/NSException.h>
#include <Foundation/NSAutoreleasePool.h>
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#include <Foundation/NSDebug.h>
#else
#include <Foundation/Foundation.h>
#include <GNUstepBase/GSCategories.h>
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#endif
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#include <GNUstepBase/GSCategories.h>
#endif
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#include <EOControl/EONull.h>
#include <EOControl/EOQualifier.h>
#include <EOControl/EOFetchSpecification.h>
#include <EOControl/EONSAddOns.h>
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#include <EOControl/EODebug.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOEntity.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOSQLExpression.h>
#include <Postgres95EOAdaptor/Postgres95Channel.h>
#include <Postgres95EOAdaptor/Postgres95Context.h>
#include <Postgres95EOAdaptor/Postgres95Values.h>
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
#include "Postgres95Private.h"
static void __dummy_function_used_for_linking(void)
{
extern void __postgres95_values_linking_function(void);
__postgres95_values_linking_function();
__dummy_function_used_for_linking();
}
#define EOAdaptorDebugLog(format, args...) \
do { if ([self isDebugEnabled]) { NSLog(format , ## args); } } while (0)
#define NSS_SWF NSString stringWithFormat
static NSDictionary *
pgResultDictionary(PGresult *pgResult)
{
int nfields, ntuples;
int i, j;
NSMutableArray *fields;
NSMutableArray *tuples;
ExecStatusType statusType;
nfields = PQnfields(pgResult);
ntuples = PQntuples(pgResult);
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
fields = [NSMutableArray arrayWithCapacity: nfields];
tuples = [NSMutableArray arrayWithCapacity: ntuples];
for (i = 1; i <= nfields; i++)
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
NSString *fname;
NSNumber *fnumber;
NSNumber *ftype;
NSNumber *fsize;
NSNumber *fmod;
NSDictionary *dict;
char *cfname;
cfname = PQfname(pgResult, i);
fname = [NSString stringWithCString: cfname];
fnumber = [NSNumber numberWithInt: PQfnumber(pgResult, cfname)];
ftype = [NSNumber numberWithUnsignedInt: PQftype(pgResult, i)];
fsize = [NSNumber numberWithInt: PQfsize(pgResult, i)];
fmod = [NSNumber numberWithInt: PQfmod(pgResult, i)];
dict = [NSDictionary dictionaryWithObjectsAndKeys:
fname, @"PQfname",
fnumber, @"PQfnumber",
ftype, @"PQftype",
fsize, @"PQfsize",
fmod, @"PQfmod",
nil];
[fields addObject: dict];
}
for (i = 1; i <= ntuples; i++)
{
NSMutableDictionary *tuple;
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
tuple = [NSMutableDictionary dictionaryWithCapacity: nfields];
for (j = 1; j <= nfields; j++)
{
NSString *tupleInfo;
NSString *tupleKey;
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
tupleKey = [NSString stringWithCString: PQfname(pgResult, j)];
if (PQgetisnull(pgResult, i, j))
{
tupleInfo = @"NULL";
}
else
{
NSString *fmt;
fmt = [NSS_SWF: @"%%%ds", PQgetlength(pgResult, i, j)];
tupleInfo = [NSS_SWF: fmt, PQgetvalue(pgResult, i, j)];
}
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
[tuple setObject: tupleInfo forKey: tupleKey];
}
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
[tuples addObject: tuple];
}
statusType = PQresultStatus(pgResult);
return [NSDictionary dictionaryWithObjectsAndKeys:
[NSS_SWF:@"%d", statusType], @"PQresultStatus",
[NSS_SWF:@"%s", PQresStatus(statusType)], @"PQresStatus",
[NSS_SWF:@"%s", PQresultErrorMessage(pgResult)], @"PQresultErrorMessage",
[NSS_SWF:@"%d", ntuples], @"PQntuples",
[NSS_SWF:@"%d", nfields], @"PQnfields",
[NSS_SWF:@"%d", PQbinaryTuples(pgResult)], @"PQbinaryTuples",
[NSS_SWF:@"%s", PQcmdStatus(pgResult)], @"PQcmdStatus",
[NSS_SWF:@"%s", PQoidStatus(pgResult)], @"PQoidStatus",
[NSS_SWF:@"%d", PQoidValue(pgResult)], @"PQoidValue",
[NSS_SWF:@"%s", PQcmdTuples(pgResult)], @"PQcmdTuples",
tuples, @"tuples",
fields, @"fields",
nil];
}
@implementation Postgres95Channel
COmmit Part 2 * EOAccess/EOAdaptor.m: o optimization in 'for' loops * EOAccess/EODatabase.m: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOAccess/EODatabaseContext.h: o added _snapshotForGlobalIDIMP * EOAccess/EODatabaseContext.m: o commented NSEmitTODO in -objectsForSourceGlobalID:relationshipName:editingContext: o added beter exception format in qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot: o fix compiler warning in -relayPrimaryKey:object:entity: o logs o optimizations in -objectsWithFetchSpecification:editingContext: o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o use _snapshotForGlobalIDIMP o IMP usage optimization * EOAccess/EOAttribute.[hm]: o added EOAdaptorUnknownType o added _adaptorValueType and avoid recomputing it each time o added _valueTypeChar to avoid string comparaisons o use EOPriv classes declarations o Temporary reverted David changes in -adaptorValueByConvertingAttributeValue * EOAccess/EOAttributePriv.h: o added _valueTypeChar to avoid string comparaisons * EOAccess/EOEntityPriv.h: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.h: o moved private -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.m: o better exception in classProperties o fix compiler warning in -setClassProperties:, -setPrimaryKeyAttributes:, -setAttributesUsedForLocking: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLExpression.m: o optimization in -tableListWithRootEntity: o optimization in -formatSQLString:format: o optimization in +sqlPatternFromShellPattern: o optimization in +sqlPatternFromShellPattern:withEscapeCharacter: o fix in -sqlStringForKeyValueQualifier: o added log in -sqlStringForKeyValueQualifier: for not handled readFormat o added log -addInsertListAttribute:value: for not handled writeFormat o added log -addUpdateListAttribute:value: for not handled writeFormat o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLQualifier.m: o implemented EOKeyComparisonQualifier -schemaBasedQualifierWithRootEntity * EOAccess/EOUtilities.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOControl/EOPriv.[hm]: o added. Contains various classes/selectors/IMPs * EOControl/EOClassDescription.m: o handle EONull case in -propagateDeleteForObject:editingContext:, -addObject:toPropertyWithKey:, -snapshot, -removeObject:fromPropertyWithKey:, _setObject:forBothSidesOfRelationshipWithKey:, addObject:toBothSidesOfRelationshipWithKey:, -removeObject:fromBothSidesOfRelationshipWithKey: o fix compiler warning in -dictionaryForInstanceProperties, -shallowCopy, -updateFromSnapshot:, -snapshot o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o replaced isNilOrEONull() by _isNilOrEONull() o fix in -validateForSave o rewritten -validateValue:forKey: selector build * EOControl/EOEditingContext.h: o added -hasUnprocessedChanges * EOControl/EOEditingContext.m: o added -hasUnprocessedChanges o added NS_DURING,... to catch exceptions o replace [EOFault isFault:] by _isFault() o IMP usage optimization * EOControl/EOKeyGlobalID.m: o replaced isNilOrEONull() by _isNilOrEONull() o include <EOCOntrol/EOPriv.h> * EOControl/EOGenericRecord.m: o partially rewritten -description o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o changed variable name type of _infoForInstanceVariableNamed:retType:retSize:retOffset: o rewritten valueForKey:,... to use cString NSKeyValueCoding * EOControl/EOKeyValueCoding.m: o changed NSAssert in NSArray -valueForKey: o optimization in NSDictionary -takeValue:forKeyPath:isSmart: o optimization in NSDictionary -takeStoredValue:forKeyPath: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOKeyValueQualifier.m: o fixes for EONull/nil in -evaluateWithObject: o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOSortOrdering.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAdaptors/Postgres95SQLExpression.m: o float formatting in +formatValue:forAttribute: o added -externalNameQuoteCharacter o added +sqlPatternFromShellPattern: o added +sqlPatternFromShellPattern:withEscapeCharacter: o replaced isNilOrEONull() by _isNilOrEONull() * EOAdaptors/Postgres95Channel.m: o logs * EOAdaptors/Postgres95Values.m: o logs o fix in +setPostgres95Format: o fix calendard format to handle timezone (%z) o optimizations * EOControl/EOMutableKnownKeyDictionary.m o removed EOMKKDArrayMapping +dictionaryFromDictionary:subsetMapping: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOControl/EONSAddOns.[hm]: o added NSString(ShellPattern) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
+ (void) initialize
{
static BOOL initialized=NO;
if (!initialized)
{
Class aClass=Nil;
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
PSQLA_PrivInit();
aClass=[Postgres95Values class]; // Force Initialize;
COmmit Part 2 * EOAccess/EOAdaptor.m: o optimization in 'for' loops * EOAccess/EODatabase.m: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOAccess/EODatabaseContext.h: o added _snapshotForGlobalIDIMP * EOAccess/EODatabaseContext.m: o commented NSEmitTODO in -objectsForSourceGlobalID:relationshipName:editingContext: o added beter exception format in qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot: o fix compiler warning in -relayPrimaryKey:object:entity: o logs o optimizations in -objectsWithFetchSpecification:editingContext: o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o use _snapshotForGlobalIDIMP o IMP usage optimization * EOAccess/EOAttribute.[hm]: o added EOAdaptorUnknownType o added _adaptorValueType and avoid recomputing it each time o added _valueTypeChar to avoid string comparaisons o use EOPriv classes declarations o Temporary reverted David changes in -adaptorValueByConvertingAttributeValue * EOAccess/EOAttributePriv.h: o added _valueTypeChar to avoid string comparaisons * EOAccess/EOEntityPriv.h: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.h: o moved private -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.m: o better exception in classProperties o fix compiler warning in -setClassProperties:, -setPrimaryKeyAttributes:, -setAttributesUsedForLocking: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLExpression.m: o optimization in -tableListWithRootEntity: o optimization in -formatSQLString:format: o optimization in +sqlPatternFromShellPattern: o optimization in +sqlPatternFromShellPattern:withEscapeCharacter: o fix in -sqlStringForKeyValueQualifier: o added log in -sqlStringForKeyValueQualifier: for not handled readFormat o added log -addInsertListAttribute:value: for not handled writeFormat o added log -addUpdateListAttribute:value: for not handled writeFormat o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLQualifier.m: o implemented EOKeyComparisonQualifier -schemaBasedQualifierWithRootEntity * EOAccess/EOUtilities.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOControl/EOPriv.[hm]: o added. Contains various classes/selectors/IMPs * EOControl/EOClassDescription.m: o handle EONull case in -propagateDeleteForObject:editingContext:, -addObject:toPropertyWithKey:, -snapshot, -removeObject:fromPropertyWithKey:, _setObject:forBothSidesOfRelationshipWithKey:, addObject:toBothSidesOfRelationshipWithKey:, -removeObject:fromBothSidesOfRelationshipWithKey: o fix compiler warning in -dictionaryForInstanceProperties, -shallowCopy, -updateFromSnapshot:, -snapshot o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o replaced isNilOrEONull() by _isNilOrEONull() o fix in -validateForSave o rewritten -validateValue:forKey: selector build * EOControl/EOEditingContext.h: o added -hasUnprocessedChanges * EOControl/EOEditingContext.m: o added -hasUnprocessedChanges o added NS_DURING,... to catch exceptions o replace [EOFault isFault:] by _isFault() o IMP usage optimization * EOControl/EOKeyGlobalID.m: o replaced isNilOrEONull() by _isNilOrEONull() o include <EOCOntrol/EOPriv.h> * EOControl/EOGenericRecord.m: o partially rewritten -description o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o changed variable name type of _infoForInstanceVariableNamed:retType:retSize:retOffset: o rewritten valueForKey:,... to use cString NSKeyValueCoding * EOControl/EOKeyValueCoding.m: o changed NSAssert in NSArray -valueForKey: o optimization in NSDictionary -takeValue:forKeyPath:isSmart: o optimization in NSDictionary -takeStoredValue:forKeyPath: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOKeyValueQualifier.m: o fixes for EONull/nil in -evaluateWithObject: o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOSortOrdering.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAdaptors/Postgres95SQLExpression.m: o float formatting in +formatValue:forAttribute: o added -externalNameQuoteCharacter o added +sqlPatternFromShellPattern: o added +sqlPatternFromShellPattern:withEscapeCharacter: o replaced isNilOrEONull() by _isNilOrEONull() * EOAdaptors/Postgres95Channel.m: o logs * EOAdaptors/Postgres95Values.m: o logs o fix in +setPostgres95Format: o fix calendard format to handle timezone (%z) o optimizations * EOControl/EOMutableKnownKeyDictionary.m o removed EOMKKDArrayMapping +dictionaryFromDictionary:subsetMapping: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOControl/EONSAddOns.[hm]: o added NSString(ShellPattern) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
};
};
/* Set DateStyle to use ISO format. */
- (void)_setDateStyle
{
_pgResult = PQexec(_pgConn,
"SET DATESTYLE TO ISO");
if (_pgResult == NULL || PQresultStatus(_pgResult) != PGRES_COMMAND_OK)
{
_pgResult = NULL;
[NSException raise: Postgres95Exception
format: @"cannot set date style to ISO."];
}
PQclear(_pgResult);
_pgResult = NULL;
}
- (id) initWithAdaptorContext: (EOAdaptorContext *)adaptorContext
{
if ((self = [super initWithAdaptorContext: adaptorContext]))
{
EOAttribute *attr = nil;
ASSIGN(_adaptorContext, adaptorContext);//TODO NO
//verify
_oidToTypeName = [[NSMutableDictionary alloc] initWithCapacity: 101];
attr = [[EOAttribute alloc] init];
[attr setName: @"nextval"];
[attr setColumnName: @"nextval"];
[attr setValueType: @"i"];
[attr setValueClassName: @"NSNumber"];
ASSIGN(_pkAttributeArray, [NSArray arrayWithObject: attr]);
RELEASE(attr);
}
return self;
}
- (void)dealloc
{
if ([self isOpen])
[self closeChannel];
DESTROY(_adaptorContext);
DESTROY(_sqlExpression);
DESTROY(_oidToTypeName);
DESTROY(_pkAttributeArray);
[super dealloc];
}
- (BOOL)isOpen
{
return (_pgConn ? YES : NO);
}
- (void)openChannel
{
//OK
NSAssert(!_pgConn, @"Channel already opened");
_pgConn = [(Postgres95Adaptor *)[[self adaptorContext] adaptor] newPGconn];
if (_pgConn)
{
[self _setDateStyle];
[self _readServerVersion];
[self _describeDatabaseTypes];
}
}
- (void)closeChannel
{
NSAssert(_pgConn, @"Channel not opened");
[self _cancelResults];
[(Postgres95Adaptor *)[[self adaptorContext] adaptor] releasePGconn: _pgConn
force: NO];
_pgConn = NULL;
}
- (BOOL)isFetchInProgress
{
return _isFetchInProgress;
}
- (PGconn *)pgConn
{
return _pgConn;
}
- (PGresult *)pgResult
{
return _pgResult;
}
- (void)cancelFetch
{
EOAdaptorContext *adaptorContext = nil;
EOFLOGObjectFnStart();
adaptorContext = [self adaptorContext];
[self cleanupFetch];
//NO ?? [self _cancelResults];//Done in cleanup fetch
// [_adaptorContext autoCommitTransaction];//Done in cleanup fetch
EOFLOGObjectFnStop();
}
- (void)_cancelResults
{
EOFLOGObjectFnStart();
_fetchBlobsOid = NO;
DESTROY(_attributes);
DESTROY(_origAttributes);
if (_pgResult)
{
PQclear(_pgResult);
_pgResult = NULL;
_currentResultRow = -2;
}
_isFetchInProgress = NO;
EOFLOGObjectFnStop();
}
- (BOOL)advanceRow
{
BOOL advanceRow = NO;
// fetch results where read then freed
EOFLOGObjectFnStart();
if (_pgResult)
{
// next row
_currentResultRow++;
// check if result set is finished
if (_currentResultRow >= PQntuples(_pgResult))
{
[self _cancelResults];
}
else
advanceRow = YES;
}
EOFLOGObjectFnStop();
return advanceRow;
}
- (NSArray*)lowLevelResultFieldNames: (PGresult*)res
{
int nb = PQnfields(res);
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
NSMutableArray *names
= AUTORELEASE([PSQLA_alloc(NSMutableArray) initWithCapacity: nb]);
int i;
IMP namesAO=NULL; //addObject:
for (i = 0; i < nb; i++)
{
char *szName = PQfname(res,i);
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
unsigned length = szName ? strlen(szName) : 0;
NSString *name = [(PSQLA_alloc(NSString)) initWithCString: szName
length: length];
PSQLA_AddObjectWithImpPtr(names,&namesAO,name);
RELEASE(name);
}
return names;
}
- (NSMutableDictionary *)fetchRowWithZone: (NSZone *)zone
{
//TODO
/*
//self cleanupFetch quand plus de row !!
valueClassName...externaltype on each attr
self adaptorContext
context adaptor
adaptor databaseEncoding//2
self dictionaryWithObjects:???
forAttributes:_attributes
zone:zone
//end
*/
NSMutableDictionary *dict = nil;
EOFLOGObjectFnStart();
if (_delegateRespondsTo.willFetchRow)
[_delegate adaptorChannelWillFetchRow: self];
NSDebugMLLog(@"gsdb",@"[self isFetchInProgress]: %s",
([self isFetchInProgress] ? "YES" : "NO"));
if ([self isFetchInProgress])
{
NSDebugMLLog(@"gsdb", @"ATTRIBUTES=%@", _attributes);
if (!_attributes)
[self _describeResults];
if ([self advanceRow] == NO)
{
NSDebugMLLog(@"gsdb", @"No Advance Row", "");
// Return nil to indicate that the fetch operation was finished
if (_delegateRespondsTo.didFinishFetching)
[_delegate adaptorChannelDidFinishFetching: self];
[self _cancelResults];
}
else
{
int i;
int count = [_attributes count];
id valueBuffer[100];
id *values = NULL;
IMP attributesOAI=NULL; // objectAtIndex:
NSDebugMLLog(@"gsdb", @"count=%d", count);
if (count > PQnfields(_pgResult))
{
NSDebugMLog(@"attempt to read %d attributes when the result set has only %d columns",
count, PQnfields(_pgResult));
NSDebugMLog(@"_attributes=%@", _attributes);
NSDebugMLog(@"result=%@", [self lowLevelResultFieldNames:
_pgResult]);
[NSException raise: Postgres95Exception
format: @"attempt to read %d attributes "
@"when the result set has only %d columns",
count, PQnfields(_pgResult)];
}
if (count > 100)
values = (id *)NSZoneMalloc(zone, count * sizeof(id));
else
values = valueBuffer;
for (i = 0; i < count; i++)
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
EOAttribute *attr = PSQLA_ObjectAtIndexWithImpPtr(_attributes,&attributesOAI,i);
int length = 0;
const char *string = NULL;
// If the column has the NULL value insert EONull in row
if (PQgetisnull(_pgResult, _currentResultRow, i))
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
values[i] = RETAIN(PSQLA_EONull); //to be compatible with others returned values
}
else
{
string = PQgetvalue(_pgResult, _currentResultRow, i);
length = PQgetlength(_pgResult, _currentResultRow, i);
// if external type for this attribute is "inversion" then this
// column represents an Oid of a large object
if ([[attr externalType] isEqual: @"inversion"])
{
if (!_fetchBlobsOid)
{
string = [self _readBinaryDataRow: (Oid)atol(string)
length:&length zone: zone];
//For efficiency reasons, the returned value is NOT autoreleased !
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
values[i] = PSQLA_Postgres95Values_newValueForBytesLengthAttribute(string,length,attr);
}
else
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
// The documentatin states that for efficiency
// reasons, the returned value is NOT autoreleased
// yet in the case of GNUstep-base it would be more
// efficient if the numberWithLong: method would be
// used as we could often skip alloc / dealloc
// and get a cached value. We could use it and
// send retain, or we could start maintaing our
// own cache.
values[i] = [PSQLA_alloc(NSNumber) initWithLong: atol(string)];
}
}
else
{
//For efficiency reasons, the returned value is NOT autoreleased !
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
values[i] = PSQLA_Postgres95Values_newValueForBytesLengthAttribute(string,length,attr);
}
}
COmmit Part 2 * EOAccess/EOAdaptor.m: o optimization in 'for' loops * EOAccess/EODatabase.m: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOAccess/EODatabaseContext.h: o added _snapshotForGlobalIDIMP * EOAccess/EODatabaseContext.m: o commented NSEmitTODO in -objectsForSourceGlobalID:relationshipName:editingContext: o added beter exception format in qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot: o fix compiler warning in -relayPrimaryKey:object:entity: o logs o optimizations in -objectsWithFetchSpecification:editingContext: o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o use _snapshotForGlobalIDIMP o IMP usage optimization * EOAccess/EOAttribute.[hm]: o added EOAdaptorUnknownType o added _adaptorValueType and avoid recomputing it each time o added _valueTypeChar to avoid string comparaisons o use EOPriv classes declarations o Temporary reverted David changes in -adaptorValueByConvertingAttributeValue * EOAccess/EOAttributePriv.h: o added _valueTypeChar to avoid string comparaisons * EOAccess/EOEntityPriv.h: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.h: o moved private -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.m: o better exception in classProperties o fix compiler warning in -setClassProperties:, -setPrimaryKeyAttributes:, -setAttributesUsedForLocking: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLExpression.m: o optimization in -tableListWithRootEntity: o optimization in -formatSQLString:format: o optimization in +sqlPatternFromShellPattern: o optimization in +sqlPatternFromShellPattern:withEscapeCharacter: o fix in -sqlStringForKeyValueQualifier: o added log in -sqlStringForKeyValueQualifier: for not handled readFormat o added log -addInsertListAttribute:value: for not handled writeFormat o added log -addUpdateListAttribute:value: for not handled writeFormat o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLQualifier.m: o implemented EOKeyComparisonQualifier -schemaBasedQualifierWithRootEntity * EOAccess/EOUtilities.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOControl/EOPriv.[hm]: o added. Contains various classes/selectors/IMPs * EOControl/EOClassDescription.m: o handle EONull case in -propagateDeleteForObject:editingContext:, -addObject:toPropertyWithKey:, -snapshot, -removeObject:fromPropertyWithKey:, _setObject:forBothSidesOfRelationshipWithKey:, addObject:toBothSidesOfRelationshipWithKey:, -removeObject:fromBothSidesOfRelationshipWithKey: o fix compiler warning in -dictionaryForInstanceProperties, -shallowCopy, -updateFromSnapshot:, -snapshot o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o replaced isNilOrEONull() by _isNilOrEONull() o fix in -validateForSave o rewritten -validateValue:forKey: selector build * EOControl/EOEditingContext.h: o added -hasUnprocessedChanges * EOControl/EOEditingContext.m: o added -hasUnprocessedChanges o added NS_DURING,... to catch exceptions o replace [EOFault isFault:] by _isFault() o IMP usage optimization * EOControl/EOKeyGlobalID.m: o replaced isNilOrEONull() by _isNilOrEONull() o include <EOCOntrol/EOPriv.h> * EOControl/EOGenericRecord.m: o partially rewritten -description o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o changed variable name type of _infoForInstanceVariableNamed:retType:retSize:retOffset: o rewritten valueForKey:,... to use cString NSKeyValueCoding * EOControl/EOKeyValueCoding.m: o changed NSAssert in NSArray -valueForKey: o optimization in NSDictionary -takeValue:forKeyPath:isSmart: o optimization in NSDictionary -takeStoredValue:forKeyPath: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOKeyValueQualifier.m: o fixes for EONull/nil in -evaluateWithObject: o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOSortOrdering.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAdaptors/Postgres95SQLExpression.m: o float formatting in +formatValue:forAttribute: o added -externalNameQuoteCharacter o added +sqlPatternFromShellPattern: o added +sqlPatternFromShellPattern:withEscapeCharacter: o replaced isNilOrEONull() by _isNilOrEONull() * EOAdaptors/Postgres95Channel.m: o logs * EOAdaptors/Postgres95Values.m: o logs o fix in +setPostgres95Format: o fix calendard format to handle timezone (%z) o optimizations * EOControl/EOMutableKnownKeyDictionary.m o removed EOMKKDArrayMapping +dictionaryFromDictionary:subsetMapping: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOControl/EONSAddOns.[hm]: o added NSString(ShellPattern) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
NSDebugMLLog(@"gsdb", @"value[%d] (%p)=%@ of class: %@",
i, values[i], values[i], [values[i] class]);
// We don't want to add nil value to dictionary !
NSAssert1(values[i],@"No value for attribute: %@",attr);
}
NSDebugMLLog(@"gsdb", @"values count=%d values=%p", count, values);
NSDebugMLLog(@"gsdb", @"_attributes=%@", _attributes);
dict = [self dictionaryWithObjects: values
forAttributes: _attributes
zone: zone];
/* NO: For efficiency reasons, the returned value is NOT autoreleased !
for (i = 0; i < count; i++)
[values[i] release];
*/
if (values != valueBuffer)
NSZoneFree(zone, values);
if (_delegateRespondsTo.didFetchRow)
[_delegate adaptorChannel: self didFetchRow: dict];
}
}
NSDebugMLLog(@"gsdb", @"row: %@", dict);
EOFLOGObjectFnStop();
return dict; //an EOMutableKnownKeyDictionary
}
- (BOOL)_evaluateCommandsUntilAFetch
{
BOOL ret = NO;
ExecStatusType status;
EOFLOGObjectFnStart();
// Check results
status = PQresultStatus(_pgResult);
NSDebugMLLog(@"gsdb",@"status=%d (%s)",
(int)status,
PQresStatus(status));
switch (status)
{
case PGRES_EMPTY_QUERY:
_isFetchInProgress = NO;
ret = YES;
break;
case PGRES_COMMAND_OK:
_isFetchInProgress = NO;
ret = YES;
break;
case PGRES_TUPLES_OK:
_isFetchInProgress = YES;
_currentResultRow = -1;
ret = YES;
break;
case PGRES_COPY_OUT:
_isFetchInProgress = NO;
ret = YES;
break;
case PGRES_COPY_IN:
_isFetchInProgress = NO;
ret = YES;
break;
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
{
2003-06-26 Manuel Guesdon <mguesdon@orange-concept.com> * config.h.in: o added EMIT_TODO control * EOAccess/EOAccessFault.m: o commented debug logs * EOAccess/EODatabaseContext.m: o more information in asserts o asserts o fix in -relayPrimaryKey:object:entity: for nil 1:1 relationship value o add -forgetSnapshotForGlobalID call in -refaultObject:withGlobalID:editingContext: o add -forgetSnapshotForGlobalID database call in -forgetSnapshotForGlobalID: * EOAccess/EOEntity.m: o logs o fix in -awakeObject:fromInsertionInEditingContext: to avoid setting already present values o reverted code in -awakeObject:fromInsertionInEditingContext: My (old) tests show that we create 1: object not on mandatory property but on propagatesPrimaryKey one if someone has an example of EOF creating an object here without propagatesPrimaryKey, please send it to me. * EOAccess/EOModelGroup.m: o don't autorelease return model group in -globalModelGroup as it will crash. I haven't find why :-( o logs * EOAccess/EOSQLExpression.m: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause o add detail in sqlStringForSelector:value: exception * EOAdaptors/Postgres95/PostPostgres95Channel.m: o add more information on exceptions * EOAdaptors/Postgres95/Postgres95SQLExpression.m: o fix escaping string in -formatValue:forAttribute: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause * EOAdaptors/Postgres95/Postgres95Value.m: o Change log in +newValueForDateType:length:attribute: * EOControl/EOCheapArray.m o removed some logs * EOAccess/EOClassDescription.m: o fix in -validateForUpdate o logs * EOControl/Debug.h: o donditional define of NSEmitTODO() * EOControl/EODetailDataSource.h/.m: o added -setDetailKey: * EOControl/EOEditingContext.m o logs * EOControl/EOFetchSpecification.m o logs * EOControl/EOKeyValueCoding.m: o fix in computeSum, computeAverage * EOControl/EOQualifier.m o logs * EOControl/EOSortOrdering.m o use valueForKeyPath: instead of valueForKey: to allow sort on related objects * EOControl/EOUndoManager.h o protection of include git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@17037 72102866-910b-0410-8b05-ffd578937521
2003-06-26 08:20:30 +00:00
NSString* errorString=[NSString stringWithCString:PQerrorMessage(_pgConn)];
if ([self isDebugEnabled])
2003-06-26 Manuel Guesdon <mguesdon@orange-concept.com> * config.h.in: o added EMIT_TODO control * EOAccess/EOAccessFault.m: o commented debug logs * EOAccess/EODatabaseContext.m: o more information in asserts o asserts o fix in -relayPrimaryKey:object:entity: for nil 1:1 relationship value o add -forgetSnapshotForGlobalID call in -refaultObject:withGlobalID:editingContext: o add -forgetSnapshotForGlobalID database call in -forgetSnapshotForGlobalID: * EOAccess/EOEntity.m: o logs o fix in -awakeObject:fromInsertionInEditingContext: to avoid setting already present values o reverted code in -awakeObject:fromInsertionInEditingContext: My (old) tests show that we create 1: object not on mandatory property but on propagatesPrimaryKey one if someone has an example of EOF creating an object here without propagatesPrimaryKey, please send it to me. * EOAccess/EOModelGroup.m: o don't autorelease return model group in -globalModelGroup as it will crash. I haven't find why :-( o logs * EOAccess/EOSQLExpression.m: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause o add detail in sqlStringForSelector:value: exception * EOAdaptors/Postgres95/PostPostgres95Channel.m: o add more information on exceptions * EOAdaptors/Postgres95/Postgres95SQLExpression.m: o fix escaping string in -formatValue:forAttribute: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause * EOAdaptors/Postgres95/Postgres95Value.m: o Change log in +newValueForDateType:length:attribute: * EOControl/EOCheapArray.m o removed some logs * EOAccess/EOClassDescription.m: o fix in -validateForUpdate o logs * EOControl/Debug.h: o donditional define of NSEmitTODO() * EOControl/EODetailDataSource.h/.m: o added -setDetailKey: * EOControl/EOEditingContext.m o logs * EOControl/EOFetchSpecification.m o logs * EOControl/EOKeyValueCoding.m: o fix in computeSum, computeAverage * EOControl/EOQualifier.m o logs * EOControl/EOSortOrdering.m o use valueForKeyPath: instead of valueForKey: to allow sort on related objects * EOControl/EOUndoManager.h o protection of include git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@17037 72102866-910b-0410-8b05-ffd578937521
2003-06-26 08:20:30 +00:00
NSLog(@"SQL expression '%@' caused %@",
[_sqlExpression statement], errorString);
NSDebugMLLog(@"SQL expression '%@' caused %@",
[_sqlExpression statement], errorString);
[NSException raise: Postgres95Exception
2003-06-26 Manuel Guesdon <mguesdon@orange-concept.com> * config.h.in: o added EMIT_TODO control * EOAccess/EOAccessFault.m: o commented debug logs * EOAccess/EODatabaseContext.m: o more information in asserts o asserts o fix in -relayPrimaryKey:object:entity: for nil 1:1 relationship value o add -forgetSnapshotForGlobalID call in -refaultObject:withGlobalID:editingContext: o add -forgetSnapshotForGlobalID database call in -forgetSnapshotForGlobalID: * EOAccess/EOEntity.m: o logs o fix in -awakeObject:fromInsertionInEditingContext: to avoid setting already present values o reverted code in -awakeObject:fromInsertionInEditingContext: My (old) tests show that we create 1: object not on mandatory property but on propagatesPrimaryKey one if someone has an example of EOF creating an object here without propagatesPrimaryKey, please send it to me. * EOAccess/EOModelGroup.m: o don't autorelease return model group in -globalModelGroup as it will crash. I haven't find why :-( o logs * EOAccess/EOSQLExpression.m: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause o add detail in sqlStringForSelector:value: exception * EOAdaptors/Postgres95/PostPostgres95Channel.m: o add more information on exceptions * EOAdaptors/Postgres95/Postgres95SQLExpression.m: o fix escaping string in -formatValue:forAttribute: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause * EOAdaptors/Postgres95/Postgres95Value.m: o Change log in +newValueForDateType:length:attribute: * EOControl/EOCheapArray.m o removed some logs * EOAccess/EOClassDescription.m: o fix in -validateForUpdate o logs * EOControl/Debug.h: o donditional define of NSEmitTODO() * EOControl/EODetailDataSource.h/.m: o added -setDetailKey: * EOControl/EOEditingContext.m o logs * EOControl/EOFetchSpecification.m o logs * EOControl/EOKeyValueCoding.m: o fix in computeSum, computeAverage * EOControl/EOQualifier.m o logs * EOControl/EOSortOrdering.m o use valueForKeyPath: instead of valueForKey: to allow sort on related objects * EOControl/EOUndoManager.h o protection of include git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@17037 72102866-910b-0410-8b05-ffd578937521
2003-06-26 08:20:30 +00:00
format: @"unexpected result returned by PQresultStatus(): %@",errorString];
EOFLOGObjectFnStop();
return NO;
}
default:
{
2003-06-26 Manuel Guesdon <mguesdon@orange-concept.com> * config.h.in: o added EMIT_TODO control * EOAccess/EOAccessFault.m: o commented debug logs * EOAccess/EODatabaseContext.m: o more information in asserts o asserts o fix in -relayPrimaryKey:object:entity: for nil 1:1 relationship value o add -forgetSnapshotForGlobalID call in -refaultObject:withGlobalID:editingContext: o add -forgetSnapshotForGlobalID database call in -forgetSnapshotForGlobalID: * EOAccess/EOEntity.m: o logs o fix in -awakeObject:fromInsertionInEditingContext: to avoid setting already present values o reverted code in -awakeObject:fromInsertionInEditingContext: My (old) tests show that we create 1: object not on mandatory property but on propagatesPrimaryKey one if someone has an example of EOF creating an object here without propagatesPrimaryKey, please send it to me. * EOAccess/EOModelGroup.m: o don't autorelease return model group in -globalModelGroup as it will crash. I haven't find why :-( o logs * EOAccess/EOSQLExpression.m: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause o add detail in sqlStringForSelector:value: exception * EOAdaptors/Postgres95/PostPostgres95Channel.m: o add more information on exceptions * EOAdaptors/Postgres95/Postgres95SQLExpression.m: o fix escaping string in -formatValue:forAttribute: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause * EOAdaptors/Postgres95/Postgres95Value.m: o Change log in +newValueForDateType:length:attribute: * EOControl/EOCheapArray.m o removed some logs * EOAccess/EOClassDescription.m: o fix in -validateForUpdate o logs * EOControl/Debug.h: o donditional define of NSEmitTODO() * EOControl/EODetailDataSource.h/.m: o added -setDetailKey: * EOControl/EOEditingContext.m o logs * EOControl/EOFetchSpecification.m o logs * EOControl/EOKeyValueCoding.m: o fix in computeSum, computeAverage * EOControl/EOQualifier.m o logs * EOControl/EOSortOrdering.m o use valueForKeyPath: instead of valueForKey: to allow sort on related objects * EOControl/EOUndoManager.h o protection of include git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@17037 72102866-910b-0410-8b05-ffd578937521
2003-06-26 08:20:30 +00:00
NSString* errorString=[NSString stringWithCString:PQerrorMessage(_pgConn)];
if ([self isDebugEnabled])
NSLog(@"SQL expression '%@' returned status %d: %@",
[_sqlExpression statement], status, errorString);
NSDebugMLLog(@"SQL expression '%@' returned status %d: %@",
[_sqlExpression statement], status, errorString);
[NSException raise: Postgres95Exception
2003-06-26 Manuel Guesdon <mguesdon@orange-concept.com> * config.h.in: o added EMIT_TODO control * EOAccess/EOAccessFault.m: o commented debug logs * EOAccess/EODatabaseContext.m: o more information in asserts o asserts o fix in -relayPrimaryKey:object:entity: for nil 1:1 relationship value o add -forgetSnapshotForGlobalID call in -refaultObject:withGlobalID:editingContext: o add -forgetSnapshotForGlobalID database call in -forgetSnapshotForGlobalID: * EOAccess/EOEntity.m: o logs o fix in -awakeObject:fromInsertionInEditingContext: to avoid setting already present values o reverted code in -awakeObject:fromInsertionInEditingContext: My (old) tests show that we create 1: object not on mandatory property but on propagatesPrimaryKey one if someone has an example of EOF creating an object here without propagatesPrimaryKey, please send it to me. * EOAccess/EOModelGroup.m: o don't autorelease return model group in -globalModelGroup as it will crash. I haven't find why :-( o logs * EOAccess/EOSQLExpression.m: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause o add detail in sqlStringForSelector:value: exception * EOAdaptors/Postgres95/PostPostgres95Channel.m: o add more information on exceptions * EOAdaptors/Postgres95/Postgres95SQLExpression.m: o fix escaping string in -formatValue:forAttribute: o fix bug in -assembleSelectStatementWithAttributes:lock:qualifier: fetchOrder:selectString:columnList:tableList: whereClause:joinClause:orderByClause:lockClause: by adding () around where and join clause * EOAdaptors/Postgres95/Postgres95Value.m: o Change log in +newValueForDateType:length:attribute: * EOControl/EOCheapArray.m o removed some logs * EOAccess/EOClassDescription.m: o fix in -validateForUpdate o logs * EOControl/Debug.h: o donditional define of NSEmitTODO() * EOControl/EODetailDataSource.h/.m: o added -setDetailKey: * EOControl/EOEditingContext.m o logs * EOControl/EOFetchSpecification.m o logs * EOControl/EOKeyValueCoding.m: o fix in computeSum, computeAverage * EOControl/EOQualifier.m o logs * EOControl/EOSortOrdering.m o use valueForKeyPath: instead of valueForKey: to allow sort on related objects * EOControl/EOUndoManager.h o protection of include git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@17037 72102866-910b-0410-8b05-ffd578937521
2003-06-26 08:20:30 +00:00
format: @"unexpected result returned by PQresultStatus(): status %d: %@",
status,errorString];
break;
}
}
NSDebugMLLog(@"gsdb", @"ret=%s", (ret ? "YES" : "NO"));
NSDebugMLLog(@"gsdb", @"_isFetchInProgress=%s", (_isFetchInProgress ? "YES" : "NO"));
if (ret == YES)
{
PGnotify *notify = PQnotifies(_pgConn);
const char *insoid = NULL;
if (notify)
{
if (_postgres95DelegateRespondsTo.postgres95Notification)
[_delegate postgres95Channel: self
receivedNotification:
[NSString stringWithCString: notify->relname]];
free(notify);
}
insoid = PQoidStatus(_pgResult);
if (*insoid && _postgres95DelegateRespondsTo.postgres95InsertedRowOid)
{
Oid oid = atol(insoid);
[_delegate postgres95Channel: self insertedRowWithOid: oid];
}
}
NSDebugMLLog(@"gsdb",@"_isFetchInProgress=%s",
(_isFetchInProgress ? "YES" : "NO"));
if ([self isFetchInProgress])// Mirko: TODO remove this !
[self _describeResults];
if ([self isDebugEnabled])
{
NSString *message = [NSString stringWithCString: PQcmdStatus(_pgResult)];
if (status == PGRES_TUPLES_OK)
message = [NSString stringWithFormat:
@"Command status %@. Returned %d rows with %d columns ",
message, PQntuples(_pgResult), PQnfields(_pgResult)];
NSLog (@"Postgres95Adaptor: %@", message);
}
NSDebugMLLog(@"gsdb", @"ret=%s", (ret ? "YES" : "NO"));
EOFLOGObjectFnStop();
return ret;
}
- (BOOL)_evaluateExpression: (EOSQLExpression *)expression
withAttributes: (NSArray*)attributes
{
BOOL result = NO;
EOAdaptorContext *adaptorContext = nil;
EOFLOGObjectFnStart();
NSDebugMLLog(@"gsdb", @"expression=%@", expression);
ASSIGN(_sqlExpression, expression);
ASSIGN(_origAttributes, attributes);
// NSDebugMLLog(@"gsdb",@"EE _origAttributes=%@",_origAttributes);
// NSDebugMLLog(@"gsdb",@"EE _attributes=%@",_attributes);
NSDebugMLLog(@"gsdb", @"Postgres95Adaptor: execute command:\n%@\n",
[expression statement]);
if ([self isDebugEnabled] == YES)
NSLog(@"Postgres95Adaptor: execute command:\n%@\n",
[expression statement]);
//call PostgreSQLChannel numberOfAffectedRows
/* Send the expression to the SQL server */
_pgResult = PQexec(_pgConn, (char *)[[[expression statement] stringByAppendingString:@";"] cString]); // stephane@sente.ch: We need to add ; for INSERT, at least
NSDebugMLLog(@"gsdb", @"_pgResult=%p", (void*)_pgResult);
if (_pgResult == NULL)
{
if ([self isDebugEnabled])
{
adaptorContext = [self adaptorContext];
[(Postgres95Adaptor *)[adaptorContext adaptor]
privateReportError: _pgConn];
}
}
else
{
/* Check command results */
if ([self _evaluateCommandsUntilAFetch] != NO)
result = YES;
}
//self numberOfAffectedRows
NSDebugMLLog(@"gsdb", @"result: %s", (result ? "YES" : "NO"));
// NSDebugMLLog(@"gsdb",@"FF attributes=%@",_attributes);
EOFLOGObjectFnStop();
return result;
}
- (void)evaluateExpression: (EOSQLExpression *)expression // OK quasi
{
Postgres95Context *adaptorContext = nil;
EOFLOGObjectFnStart();
//_evaluationIsDirectCalled=1
adaptorContext = (Postgres95Context *)[self adaptorContext];
//call expression statement
//call adaptorContext adaptor
//call adaptor databaseEncoding
//call self setErrorMessage
//call expre statement
NSDebugMLLog(@"gsdb", @"expression=%@", expression);
if (_delegateRespondsTo.shouldEvaluateExpression)
{
BOOL response
= [_delegate adaptorChannel: self
shouldEvaluateExpression: expression];
if (response == NO)
return;
}
if ([self isOpen] == NO)
[NSException raise: Postgres95Exception
format: @"cannot execute SQL expression. Channel is not opened."];
[self _cancelResults];
[adaptorContext autoBeginTransaction: NO/*YES*/]; //TODO: shouldbe yes ??
if (![self _evaluateExpression: expression
withAttributes: nil])
{
NSDebugMLLog(@"gsdb", @"_evaluateExpression:withAttributes: return NO", "");
[self _cancelResults];
}
else
{
NSDebugMLLog(@"gsdb", @"expression=%@ [self isFetchInProgress]=%d",
expression,
[self isFetchInProgress]);
if (![self isFetchInProgress])//If a fetch is in progress, we don't want to commit because
//it will cancel fetch. I'm not sure it the 'good' way to do
[adaptorContext autoCommitTransaction];
if (_delegateRespondsTo.didEvaluateExpression)
[_delegate adaptorChannel: self didEvaluateExpression: expression];
}
EOFLOGObjectFnStop();
}
- (void)insertRow: (NSDictionary *)row
forEntity: (EOEntity *)entity
{
EOSQLExpression *sqlexpr = nil;
NSMutableDictionary *nrow = nil;
NSEnumerator *enumerator = nil;
NSString *attrName = nil;
Postgres95Context *adaptorContext = nil;
IMP attrEnumNO=NULL; // nextObject
IMP rowOFK=NULL; // objectForKey:
IMP nrowSOFK=NULL; // setObject:forKey:
IMP nrowOFK=NULL; // objectForKey:
EOFLOGObjectFnStart();
NSDebugMLLog(@"gsdb", @"row=%@", row);
if (![self isOpen])
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: attempt to insert rows with no open channel",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
if (!row || !entity)
[NSException raise: NSInvalidArgumentException
format: @"row and entity arguments for insertRow:forEntity:"
@" must not be nil objects"];
if ([self isFetchInProgress])
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: attempt to insert rows with fetch in progress",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
/* Before creating the SQL INSERT expression we have to replace in the
row the large objects as Oids and to insert them with the large
object file-like interface */
nrow = AUTORELEASE([row mutableCopy]);
adaptorContext = (Postgres95Context *)[self adaptorContext];
[self _cancelResults]; //No done by WO
NSDebugMLLog(@"gsdb", @"autoBeginTransaction", "");
[adaptorContext autoBeginTransaction: YES];
/*:
row allKeys
allkey sortedArrayUsingSelector:compare:
each key
*/
enumerator = [row keyEnumerator];
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
while ((attrName = PSQLA_NextObjectWithImpPtr(enumerator,&attrEnumNO)))
{
EOAttribute *attribute = nil;
NSString *externalType = nil;
id value = nil;
NSDebugMLLog(@"gsdb", @"attrName=%@", attrName);
attribute=[entity attributeNamed: attrName];
NSDebugMLLog(@"gsdb", @"attribute=%@", attribute);
if (!attribute)
return; //???????????
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
value = PSQLA_ObjectForKeyWithImpPtr(row,&rowOFK,attrName);
NSDebugMLLog(@"gsdb", @"value=%@", value);
externalType = [attribute externalType];
NSDebugMLLog(@"gsdb", @"externalType=%@", externalType);
/* Insert the binary value into the binaryDataRow dictionary */
if ([externalType isEqual: @"inversion"])
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
id binValue = PSQLA_ObjectForKeyWithImpPtr(nrow,&nrowOFK,attrName);
Oid binOid = [self _insertBinaryData: binValue
forAttribute: attribute];
value = [NSNumber numberWithLong: binOid];
}
else if ([externalType isEqual: @"NSString"]) //??
{
//TODO: database encoding
// [[adaptorContext adaptor] databaseEncoding]
}
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
PSQLA_SetObjectForKeyWithImpPtr(nrow,&nrowSOFK,value,attrName);
}
NSDebugMLLog(@"gsdb", @"nrow=%@", nrow);
if ([nrow count] > 0)
{
sqlexpr = [[[_adaptorContext adaptor] expressionClass]
insertStatementForRow: nrow
entity: entity];
NSDebugMLLog(@"gsdb", @"sqlexpr=%@", sqlexpr);
if ([self _evaluateExpression: sqlexpr withAttributes: nil] == NO) //call evaluateExpression:
[NSException raise: EOGeneralAdaptorException
format: @"%@ -- %@ 0x%x: cannot insert row for entity '%@'",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
[entity name]];
}
[_adaptorContext autoCommitTransaction];
EOFLOGObjectFnStop();
}
- (unsigned)deleteRowsDescribedByQualifier: (EOQualifier *)qualifier
entity: (EOEntity *)entity
{
EOSQLExpression *sqlexpr = nil;
unsigned long rows = 0;
Postgres95Context *adaptorContext;
EOFLOGObjectFnStart();
if (![self isOpen])
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: attempt to delete rows with no open channel",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
if (!qualifier || !entity)
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: qualifier and entity arguments "
@" must not be nil objects",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
if ([self isFetchInProgress])
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: attempt to delete rows with fetch in progress",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
adaptorContext = (Postgres95Context *)[self adaptorContext];
[self _cancelResults];
[_adaptorContext autoBeginTransaction: NO];
sqlexpr = [[[_adaptorContext adaptor] expressionClass]
deleteStatementWithQualifier: qualifier
entity: entity];
if ([self _evaluateExpression: sqlexpr withAttributes: nil])
rows = strtoul(PQcmdTuples(_pgResult), NULL, 10);
[adaptorContext autoCommitTransaction];
EOFLOGObjectFnStop();
return rows;
}
- (void)selectAttributes: (NSArray *)attributes
fetchSpecification: (EOFetchSpecification *)fetchSpecification
lock: (BOOL)flag
entity: (EOEntity *)entity
{
EOSQLExpression *sqlExpr = nil;
//objectForKey:EOAdaptorQuotesExternalNames ret: nil
//lastObject ret NSRegistrationDomain
//objectForKey:NSRegistrationDomain ret dict
//objectForKey:EOAdaptorQuotesExternalNames
//attr count
//PostgreSQLExpression initWithEntity:
//setUseliases:YES
//prepareSelectExpressionWithAttributes:lock:fetchSpecification:
//statement
//adaptorContext
//a con autoBeginTransaction
//end
EOFLOGObjectFnStart();
NSDebugMLLog(@"gsdb",@"%@ -- %@ 0x%x: isFetchInProgress=%s",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
([self isFetchInProgress] ? "YES" : "NO"));
if (![self isOpen])
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: attempt to select attributes with no open channel",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
if ([self isFetchInProgress])
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: attempt to select attributes with fetch in progress",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
if (_delegateRespondsTo.shouldSelectAttributes)
if (![_delegate adaptorChannel: self
shouldSelectAttributes: attributes
fetchSpecification: fetchSpecification
lock: flag
entity: entity])
return;
NSDebugMLLog(@"gsdb", @"%@ -- %@ 0x%x: isFetchInProgress=%s",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
([self isFetchInProgress] ? "YES" : "NO"));
[self _cancelResults];
NSDebugMLLog(@"gsdb", @"%@ -- %@ 0x%x: isFetchInProgress=%s",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
([self isFetchInProgress] ? "YES" : "NO"));
[_adaptorContext autoBeginTransaction: NO];
ASSIGN(_attributes, attributes);
// NSDebugMLLog(@"gsdb",@"00 attributes=%@",_attributes);
NSAssert([attributes count] > 0, @"No Attributes");
sqlExpr = [[[_adaptorContext adaptor] expressionClass]
selectStatementForAttributes: attributes
lock: flag
fetchSpecification: fetchSpecification
entity: entity];
NSDebugMLLog(@"gsdb", @"sqlExpr=%@", sqlExpr);
// NSDebugMLLog(@"gsdb",@"AA attributes=%@",_attributes);
[self _evaluateExpression: sqlExpr
withAttributes: attributes];
NSDebugMLLog(@"gsdb", @"After _evaluate", "");
// NSDebugMLLog(@"gsdb",@"BB attributes=%@",_attributes);
[_adaptorContext autoCommitTransaction];
NSDebugMLLog(@"gsdb", @"After autoCommitTransaction", "");
if (_delegateRespondsTo.didSelectAttributes)
[_delegate adaptorChannel: self
didSelectAttributes: attributes
fetchSpecification: fetchSpecification
lock: flag
entity: entity];
// NSDebugMLLog(@"gsdb",@"CC attributes=%@",_attributes);
EOFLOGObjectFnStop();
}
- (unsigned int)updateValues: (NSDictionary *)values
inRowsDescribedByQualifier: (EOQualifier *)qualifier
entity: (EOEntity *)entity
{
//autoBeginTransaction
//entity attributes
//externaltype on each attr
//adaptor expressionClass
//exprclass alloc initwithentity
//expr setUseAliases:NO
//exp prepareUpdateExpressionWithRow:qualifier:
//self evaluateExpression:
//autoCommitTransaction
//return number of affeted rows
//end
EOSQLExpression *sqlExpr = nil;
NSMutableDictionary *mrow = nil;
NSMutableArray *invAttributes = nil;
NSEnumerator *enumerator = nil;
NSString *attrName = nil;
NSString *externalType = nil;
EOAttribute *attr = nil;
Postgres95Context *adaptorContext = nil;
unsigned long rows = 0;
IMP valuesOFK=NULL; // objectForKey:
EOFLOGObjectFnStart();
if (![self isOpen])
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: attempt to update values with no open channel",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
if ([self isFetchInProgress])
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: attempt to update values with fetch in progress",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
if ([values count] > 0)
{
IMP valueEnumNO=NULL; // nextObject
IMP mrowSOFK=NULL; // setObject:forKey;
mrow = AUTORELEASE([values mutableCopyWithZone: [values zone]]);
// Get EOAttributes involved in update operation
// Modify "inversion" attributes to NSNumber type with the Oid
invAttributes = AUTORELEASE([[NSMutableArray alloc] initWithCapacity: [mrow count]]);
enumerator = [values keyEnumerator];
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
while ((attrName = PSQLA_NextObjectWithImpPtr(enumerator,&valueEnumNO)))
{
attr = [entity attributeNamed: attrName];
externalType = [attr externalType];
if (attr == nil)
return 0; //???
/*
[mrow setObject:[attr adaptorValueByConvertingAttributeValue://Not in WO
[values objectForKey:attrName]]
forKey:attrName];
*/
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
PSQLA_SetObjectForKeyWithImpPtr(mrow,&mrowSOFK,
PSQLA_ObjectForKeyWithImpPtr(values,&valuesOFK,attrName),
attrName);
if ([externalType isEqual: @"inversion"])
[invAttributes addObject: attr];
}
[self _cancelResults]; //Not in WO
adaptorContext = (Postgres95Context *)[self adaptorContext];
[adaptorContext autoBeginTransaction: YES];
if ([invAttributes count])
{
IMP invAttributesNO=NULL; // nextObject
// Select with update qualifier to see there is only one row
// to be updated and to get the large objects (to be updatetd)
// Oid from dataserver - there is a hack here based on the fact that
// in update there in only one table and no flattened attributes
NSDictionary *dbRow = nil;
sqlExpr = [[[_adaptorContext adaptor] expressionClass]
selectStatementForAttributes: invAttributes
lock: NO
fetchSpecification:
[EOFetchSpecification
fetchSpecificationWithEntityName: [entity name]
qualifier: qualifier
sortOrderings: nil]
entity: entity];
[self _evaluateExpression: sqlExpr withAttributes: nil];
_fetchBlobsOid = YES;
dbRow = [self fetchRowWithZone: NULL];
_fetchBlobsOid = NO;
[self _cancelResults];
// Update the large objects and modify the row to update with Oid's
enumerator = [invAttributes objectEnumerator];
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
while ((attr = PSQLA_NextObjectWithImpPtr(enumerator,&invAttributesNO)))
{
Oid oldOid;
Oid newOid;
NSData *data;
attrName = [attr name];
data = [mrow objectForKey: attrName];
oldOid = [[dbRow objectForKey:attrName] longValue];
newOid = [self _updateBinaryDataRow: oldOid data: data];
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
PSQLA_SetObjectForKeyWithImpPtr(mrow,&mrowSOFK,
[NSNumber numberWithUnsignedLong: newOid],
attrName);
}
}
// Now we have all: one and only row to update and binary rows
// (large objects) where updated and their new Oid set in the row
rows = 0;
NSDebugMLLog(@"gsdb", @"[mrow count]=%d", [mrow count]);
if ([mrow count] > 0)
{
sqlExpr = [[[_adaptorContext adaptor] expressionClass]
updateStatementForRow: mrow
qualifier: qualifier
entity: entity];
//wo call evaluateExpression:
if ([self _evaluateExpression: sqlExpr withAttributes: nil])
rows = strtoul(PQcmdTuples(_pgResult), NULL, 10);
}
[adaptorContext autoCommitTransaction];
}
EOFLOGObjectFnStop();
return rows;
}
/* The binaryDataRow should contain only one binary attribute */
- (char *)_readBinaryDataRow: (Oid)oid
length: (int *)length
zone: (NSZone *)zone;
{
int fd;
int len, wrt;
char *bytes;
if (oid == 0)
{
*length = 0;
return NULL;
}
fd = lo_open(_pgConn, oid, INV_READ|INV_WRITE);
if (fd < 0)
[NSException raise: Postgres95Exception
format: @"cannot open large object Oid = %ld", oid];
lo_lseek(_pgConn, fd, 0, SEEK_END);
len = lo_tell(_pgConn, fd);
lo_lseek(_pgConn, fd, 0, SEEK_SET);
if (len < 0)
[NSException raise: Postgres95Exception
format: @"error while getting size of large object Oid = %ld", oid];
bytes = NSZoneMalloc(zone, len);
wrt = lo_read(_pgConn, fd, bytes, len);
if (len != wrt)
{
NSZoneFree(zone, bytes);
[NSException raise: Postgres95Exception
format: @"error while reading large object Oid = %ld", oid];
}
lo_close(_pgConn, fd);
*length = len;
return bytes;
}
- (Oid)_insertBinaryData: (NSData *)binaryData
forAttribute: (EOAttribute *)attr
{
int len;
const char* bytes;
Oid oid;
int fd, wrt;
if ((id)binaryData == [EONull null] || binaryData == nil)
return 0;
len = [binaryData length];
bytes = [binaryData bytes];
oid = lo_creat(_pgConn, INV_READ|INV_WRITE);
if (oid == 0)
[NSException raise: Postgres95Exception
format: @"cannot create large object"];
fd = lo_open(_pgConn, oid, INV_READ|INV_WRITE);
if (fd < 0)
[NSException raise: Postgres95Exception
format: @"cannot open large object Oid = %ld", oid];
wrt = lo_write(_pgConn, fd, (char *)bytes, len);
if (len != wrt)
[NSException raise: Postgres95Exception
format: @"error while writing large object Oid = %ld", oid];
lo_close(_pgConn, fd);
return oid;
}
- (Oid)_updateBinaryDataRow: (Oid)oid
data: (NSData *)binaryData
{
int len;
const char* bytes;
int wrt, fd;
if (oid)
lo_unlink(_pgConn, oid);
if ((id)binaryData == [EONull null] || binaryData == nil)
return 0;
len = [binaryData length];
bytes = [binaryData bytes];
oid = lo_creat(_pgConn, INV_READ|INV_WRITE);
if (oid == 0)
[NSException raise: Postgres95Exception
format: @"cannot create large object"];
fd = lo_open(_pgConn, oid, INV_READ|INV_WRITE);
if (fd < 0)
[NSException raise: Postgres95Exception
format: @"cannot open large object Oid = %ld", oid];
wrt = lo_write(_pgConn, fd, (char*)bytes, len);
if (len != wrt)
[NSException raise: Postgres95Exception
format: @"error while writing large object Oid = %ld", oid];
lo_close(_pgConn, fd);
return oid;
}
/* Read type oid and names from the database server.
Called on each openChannel to refresh info. */
- (void)_describeDatabaseTypes
{
int i, count;
_pgResult = PQexec(_pgConn,
"SELECT oid, typname FROM pg_type WHERE typrelid = 0");
if (_pgResult == NULL || PQresultStatus(_pgResult) != PGRES_TUPLES_OK)
{
_pgResult = NULL;
[NSException raise: Postgres95Exception
format: @"cannot read type name informations from database. "
@"bad response from server"];
}
if (PQnfields(_pgResult) != 2)
{
_pgResult = NULL;
[NSException raise: Postgres95Exception
format: @"cannot read type name informations from database. "
@"results should have two columns"];
}
[_oidToTypeName removeAllObjects];
count = PQntuples(_pgResult);
for (i = 0; i < count; i++)
{
char* oid = PQgetvalue(_pgResult, i, 0);
char* typ = PQgetvalue(_pgResult, i, 1);
[_oidToTypeName setObject: [NSString stringWithCString: typ]
forKey: [NSNumber numberWithLong: atol(oid)]];
}
PQclear(_pgResult);
_pgResult = NULL;
}
- (void)_readServerVersion
{
NSString *version;
_pgResult = PQexec(_pgConn,
"SELECT version()");
if (_pgResult == NULL || PQresultStatus(_pgResult) != PGRES_TUPLES_OK)
{
_pgResult = NULL;
[NSException raise: Postgres95Exception
format: @"cannot read type name informations from database. "
@"bad response from server"];
}
version = [NSString stringWithCString: PQgetvalue(_pgResult, 0, 0)];
_pgVersion = [version parsedFirstVersionSubstring];
PQclear(_pgResult);
_pgResult = NULL;
}
- (NSArray *)attributesToFetch
{
return _attributes;
}
- (void)setAttributesToFetch: (NSArray *)attributes
{
//call adaptorContext
NSDebugMLLog(@"gsdb", @"Postgres95Channel: setAttributesToFetch %p:%@",
attributes, attributes);
ASSIGN(_attributes, attributes);
}
- (NSArray *)describeResults
{
NSArray *desc;
EOFLOGObjectFnStart();
if (![self isFetchInProgress])
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: attempt to describe results with no fetch in progress",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
desc = [self attributesToFetch];
EOFLOGObjectFnStop();
return desc;
}
- (void)_describeResults
{
int colsNumber;
EOFLOGObjectFnStart();
colsNumber=_pgResult ? PQnfields(_pgResult): 0;
NSDebugMLLog(@"gsdb", @"colsNumber=%d", colsNumber);
if (colsNumber == 0)
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
[self setAttributesToFetch: PSQLA_NSArray];
}
else if (!_attributes) //??
{
int i;
id *attributes = NULL;
IMP origAttributesOAI=NULL;
IMP oidToTypeNameOFK=NULL;
attributes = alloca(colsNumber * sizeof(id));
for (i = 0; i < colsNumber; i++)
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
EOAttribute *attribute
= AUTORELEASE([PSQLA_alloc(EOAttribute) init]);
NSString *externalType;
NSString *valueClass = @"NSString";
NSString *valueType = nil;
if (_origAttributes)
{
EOAttribute *origAttr = (EOAttribute *)
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
PSQLA_ObjectAtIndexWithImpPtr(_origAttributes,&origAttributesOAI,i);
[attribute setName: [origAttr name]];
[attribute setColumnName: [origAttr columnName]];
[attribute setExternalType: [origAttr externalType]];
[attribute setValueType: [origAttr valueType]];
[attribute setValueClassName: [origAttr valueClassName]];
}
else
{
NSNumber *externalTypeNumber;
externalTypeNumber
= [NSNumber numberWithLong: PQftype(_pgResult, i)];
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
externalType = PSQLA_ObjectForKeyWithImpPtr(_oidToTypeName,
&oidToTypeNameOFK,externalTypeNumber);
if (!externalType)
[NSException raise: Postgres95Exception
format: @"cannot find type for Oid = %d",
PQftype(_pgResult, i)];
[attribute setName: [NSString stringWithFormat: @"attribute%d", i]];
[attribute setColumnName: @"unknown"];
[attribute setExternalType: externalType];
COmmit Part 2 * EOAccess/EOAdaptor.m: o optimization in 'for' loops * EOAccess/EODatabase.m: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOAccess/EODatabaseContext.h: o added _snapshotForGlobalIDIMP * EOAccess/EODatabaseContext.m: o commented NSEmitTODO in -objectsForSourceGlobalID:relationshipName:editingContext: o added beter exception format in qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot: o fix compiler warning in -relayPrimaryKey:object:entity: o logs o optimizations in -objectsWithFetchSpecification:editingContext: o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o use _snapshotForGlobalIDIMP o IMP usage optimization * EOAccess/EOAttribute.[hm]: o added EOAdaptorUnknownType o added _adaptorValueType and avoid recomputing it each time o added _valueTypeChar to avoid string comparaisons o use EOPriv classes declarations o Temporary reverted David changes in -adaptorValueByConvertingAttributeValue * EOAccess/EOAttributePriv.h: o added _valueTypeChar to avoid string comparaisons * EOAccess/EOEntityPriv.h: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.h: o moved private -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.m: o better exception in classProperties o fix compiler warning in -setClassProperties:, -setPrimaryKeyAttributes:, -setAttributesUsedForLocking: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLExpression.m: o optimization in -tableListWithRootEntity: o optimization in -formatSQLString:format: o optimization in +sqlPatternFromShellPattern: o optimization in +sqlPatternFromShellPattern:withEscapeCharacter: o fix in -sqlStringForKeyValueQualifier: o added log in -sqlStringForKeyValueQualifier: for not handled readFormat o added log -addInsertListAttribute:value: for not handled writeFormat o added log -addUpdateListAttribute:value: for not handled writeFormat o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLQualifier.m: o implemented EOKeyComparisonQualifier -schemaBasedQualifierWithRootEntity * EOAccess/EOUtilities.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOControl/EOPriv.[hm]: o added. Contains various classes/selectors/IMPs * EOControl/EOClassDescription.m: o handle EONull case in -propagateDeleteForObject:editingContext:, -addObject:toPropertyWithKey:, -snapshot, -removeObject:fromPropertyWithKey:, _setObject:forBothSidesOfRelationshipWithKey:, addObject:toBothSidesOfRelationshipWithKey:, -removeObject:fromBothSidesOfRelationshipWithKey: o fix compiler warning in -dictionaryForInstanceProperties, -shallowCopy, -updateFromSnapshot:, -snapshot o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o replaced isNilOrEONull() by _isNilOrEONull() o fix in -validateForSave o rewritten -validateValue:forKey: selector build * EOControl/EOEditingContext.h: o added -hasUnprocessedChanges * EOControl/EOEditingContext.m: o added -hasUnprocessedChanges o added NS_DURING,... to catch exceptions o replace [EOFault isFault:] by _isFault() o IMP usage optimization * EOControl/EOKeyGlobalID.m: o replaced isNilOrEONull() by _isNilOrEONull() o include <EOCOntrol/EOPriv.h> * EOControl/EOGenericRecord.m: o partially rewritten -description o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o changed variable name type of _infoForInstanceVariableNamed:retType:retSize:retOffset: o rewritten valueForKey:,... to use cString NSKeyValueCoding * EOControl/EOKeyValueCoding.m: o changed NSAssert in NSArray -valueForKey: o optimization in NSDictionary -takeValue:forKeyPath:isSmart: o optimization in NSDictionary -takeStoredValue:forKeyPath: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOKeyValueQualifier.m: o fixes for EONull/nil in -evaluateWithObject: o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOSortOrdering.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAdaptors/Postgres95SQLExpression.m: o float formatting in +formatValue:forAttribute: o added -externalNameQuoteCharacter o added +sqlPatternFromShellPattern: o added +sqlPatternFromShellPattern:withEscapeCharacter: o replaced isNilOrEONull() by _isNilOrEONull() * EOAdaptors/Postgres95Channel.m: o logs * EOAdaptors/Postgres95Values.m: o logs o fix in +setPostgres95Format: o fix calendard format to handle timezone (%z) o optimizations * EOControl/EOMutableKnownKeyDictionary.m o removed EOMKKDArrayMapping +dictionaryFromDictionary:subsetMapping: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOControl/EONSAddOns.[hm]: o added NSString(ShellPattern) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
//TODO: Optimize ?
if ([externalType isEqual: @"bool"])
valueClass = @"NSNumber", valueType = @"c";
else if ([externalType isEqual: @"char"])
valueClass = @"NSNumber", valueType = @"c";
else if ([externalType isEqual: @"dt"])
valueClass = @"NSCalendarDate", valueType = nil;
else if ([externalType isEqual: @"date"])
valueClass = @"NSCalendarDate", valueType = nil;
else if ([externalType isEqual: @"time"])
valueClass = @"NSCalendarDate", valueType = nil;
else if ([externalType isEqual: @"float4"])
valueClass = @"NSNumber", valueType = @"f";
else if ([externalType isEqual: @"float8"])
valueClass = @"NSNumber", valueType = @"d";
else if ([externalType isEqual: @"int2"])
valueClass = @"NSNumber", valueType = @"s";
else if ([externalType isEqual: @"int4"])
valueClass = @"NSNumber", valueType = @"i";
else if ([externalType isEqual: @"int8"] || [externalType isEqual: @"bigint"])
valueClass = @"NSNumber", valueType = @"u";
else if ([externalType isEqual: @"oid"])
valueClass = @"NSNumber", valueType = @"l";
else if ([externalType isEqual: @"varchar"])
valueClass = @"NSString", valueType = nil;
else if ([externalType isEqual: @"bpchar"])
valueClass = @"NSString", valueType = nil;
else if ([externalType isEqual: @"text"])
valueClass = @"NSString", valueType = nil;
/* else if ([externalType isEqual:@"cid"])
valueClass = @"NSNumber", valueType = @"";
else if ([externalType isEqual:@"tid"])
valueClass = @"NSNumber", valueType = @"";
else if ([externalType isEqual:@"xid"])
valueClass = @"NSNumber", valueType = @"";*/
[attribute setValueType: valueType];
[attribute setValueClassName: valueClass];
}
attributes[i] = attribute;
}
[self setAttributesToFetch: AUTORELEASE([[NSArray alloc]
initWithObjects: attributes
count: colsNumber])];
}
// NSDebugMLLog(@"gsdb",@"_attributes=%@",_attributes);
EOFLOGObjectFnStop();
}
/* The methods used to generate an model from the meta-information kept by
the database. */
- (NSArray *)describeTableNames
{
int i, count;
NSMutableArray *results = nil;
char *tableSelect;
IMP resultsAO=NULL; // addObject:
if (_pgVersion < 70300)
{
tableSelect = "SELECT tablename FROM pg_tables WHERE tableowner != 'postgres' OR tablename NOT LIKE 'pg_%'";
}
else
{
tableSelect = "SELECT tablename FROM pg_tables WHERE pg_tables.schemaname = 'public'";
}
NSAssert(_pgConn, @"Channel not opened");
_pgResult = PQexec(_pgConn, tableSelect);
if (_pgResult == NULL
|| PQresultStatus(_pgResult) != PGRES_TUPLES_OK)
{
_pgResult = NULL;
[NSException raise: Postgres95Exception
format: @"cannot read list of tables from database. "
@"bad response from server"];
}
count = PQntuples(_pgResult);
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
results= AUTORELEASE([PSQLA_alloc(NSMutableArray) initWithCapacity: count]);
for (i = 0; i < count; i++)
{
char *oid = PQgetvalue(_pgResult, i, 0);
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
PSQLA_AddObjectWithImpPtr(results,&resultsAO,
[NSString stringWithUTF8String: oid]);
}
PQclear(_pgResult);
_pgResult = NULL;
return [NSArray arrayWithArray: results];
}
- (NSArray *)describeStoredProcedureNames
{
// TODO
[self notImplemented: _cmd];
return nil;
}
- (void)_describeBasicEntityWithName:(NSString *)tableName
forModel:(EOModel *)model
{
EOEntity *entity;
NSString *stmt;
EOAttribute *attribute;
NSString *valueClass = @"NSString";
NSString *valueType = nil;
NSString *tableOid;
unsigned int n, k;
int count = 0;
entity = AUTORELEASE([[EOEntity alloc] init]);
[entity setName: tableName];
[entity setExternalName: tableName];
[entity setClassName: @"EOGenericRecord"];
[model addEntity: entity];
stmt = [NSS_SWF: @"SELECT oid FROM pg_class "
@"WHERE relname = '%@' AND relkind = 'r'",tableName];
EOAdaptorDebugLog(@"Postgres95Adaptor: execute command:\n%@", stmt);
_pgResult = PQexec(_pgConn, [stmt cString]);
if (_pgResult == NULL || PQresultStatus(_pgResult) != PGRES_TUPLES_OK)
{
_pgResult = NULL;
[NSException raise: Postgres95Exception
format: @"cannot read type name information from database."
@"bad response from server"];
}
if (PQntuples(_pgResult) != 1)
{
_pgResult = NULL;
[NSException raise: Postgres95Exception
format: @"Table %@ doesn't exist", tableName];
}
tableOid = [NSString stringWithCString: PQgetvalue(_pgResult,0,0)];
[entity setUserInfo: [NSDictionary dictionaryWithObject:tableOid
forKey: @"tableOid"]];
stmt = [NSS_SWF: @"SELECT attname,typname,attnum "
@"FROM pg_attribute LEFT JOIN pg_type ON atttypid = oid "
@"WHERE attnum > 0 AND attrelid=%@"
@"AND attisdropped IS FALSE", tableOid];
EOAdaptorDebugLog(@"Postgres95Adaptor: execute command:\n%@", stmt);
PQclear(_pgResult);
_pgResult = PQexec(_pgConn, [stmt cString]);
count = PQntuples(_pgResult);
if (count>0)
{
for (n = 0; n < count; n++)
{
NSString *columnName;
NSString *externalType;
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
char *name;
unsigned length;
name = PQgetvalue(_pgResult,n,1);
length = name ? strlen(name) : 0;
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
externalType = [(PSQLA_alloc(NSString)) initWithCString: name
length: length];
//TODO optimize ?
if ([externalType isEqual: @"bool"])
valueClass = @"NSNumber", valueType = @"c";
else if ([externalType isEqual: @"char"])
valueClass = @"NSNumber", valueType = @"c";
else if ([externalType isEqual: @"dt"])
valueClass = @"NSCalendarDate", valueType = nil;
else if ([externalType isEqual: @"date"])
valueClass = @"NSCalendarDate", valueType = nil;
else if ([externalType isEqual: @"time"])
valueClass = @"NSCalendarDate", valueType = nil;
else if ([externalType isEqual: @"float4"])
valueClass = @"NSNumber", valueType = @"f";
else if ([externalType isEqual: @"float8"])
valueClass = @"NSNumber", valueType = @"d";
else if ([externalType isEqual: @"int2"])
valueClass = @"NSNumber", valueType = @"i";
else if ([externalType isEqual: @"int4"])
valueClass = @"NSNumber", valueType = @"i";
else if ([externalType isEqual: @"int8"])
valueClass = @"NSNumber", valueType = @"l";
else if ([externalType isEqual: @"oid"])
valueClass = @"NSNumber", valueType = @"l";
else if ([externalType isEqual: @"varchar"])
valueClass = @"NSString", valueType = nil;
else if ([externalType isEqual: @"bpchar"])
valueClass = @"NSString", valueType = nil;
else if ([externalType isEqual: @"text"])
valueClass = @"NSString", valueType = nil;
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
name = PQgetvalue(_pgResult, n, 0);
length = name ? strlen(name) : 0;
columnName = [(PSQLA_alloc(NSString)) initWithCString: name
length: length];
attribute = [PSQLA_alloc(EOAttribute) init];
[attribute setName: columnName];
[attribute setColumnName: columnName];
[attribute setExternalType: externalType];
[attribute setValueType: valueType];
[attribute setValueClassName: valueClass];
[entity addAttribute: attribute];
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
RELEASE(externalType);
RELEASE(attribute);
RELEASE(columnName);
}
};
PQclear(_pgResult);
/* Determint primary key. */
stmt = [NSS_SWF: @"SELECT indkey FROM pg_index "
@"WHERE indrelid='%@' AND indisprimary = 't'",
tableOid];
EOAdaptorDebugLog(@"Postgres95Adaptor: execute command:\n%@", stmt);
_pgResult = PQexec(_pgConn,[stmt cString]);
if (PQntuples(_pgResult))
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
NSString *pkAttNum
= [NSString stringWithCString: PQgetvalue(_pgResult,0,0)];
pkAttNum = [pkAttNum stringByReplacingString:@" "
withString: @", "];
stmt = [NSS_SWF: @"SELECT attname FROM pg_attribute "
@"WHERE attrelid='%@' and attnum in (%@)",
tableOid, pkAttNum];
PQclear(_pgResult);
EOAdaptorDebugLog(@"Postgres95Adaptor: execute command:\n%@", stmt);
_pgResult = PQexec(_pgConn,[stmt cString]);
if (PQntuples(_pgResult))
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
NSMutableArray *pkeys;
count = PQntuples(_pgResult);
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
pkeys = [PSQLA_alloc(NSMutableArray) initWithCapacity: count];
for (k = 0; k < count; k++)
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
//TODO: Optimize, it's probably faster to use a mutable
// string here instead of alloc/dealloing new strings.
NSString *name;
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
const char *cName;
unsigned length;
cName = PQgetvalue(_pgResult,k,0);
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
length = cName ? strlen(cName) : 0;
name = [(PSQLA_alloc(NSString)) initWithCString: cName
length: length];
attribute = [entity attributeNamed: name];
NSDebugMLLog(@"adaptor", @"pk(%d) name: %@", k, name);
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
[pkeys addObject: attribute];
RELEASE(name);
}
NSDebugMLLog(@"adaptor", @"pkeys %@", pkeys);
[entity setPrimaryKeyAttributes: pkeys];
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
RELEASE(pkeys);
}
}
/* </primary key stuff> */
}
- (void)_describeForeignKeysForEntity:(EOEntity *) entity
forModel:(EOModel *) model
{
NSString *stmt;
NSString *tableOid;
unsigned int i, j, n, m;
tableOid = [[entity userInfo] objectForKey: @"tableOid"];
stmt = [NSS_SWF: @"SELECT tgargs FROM pg_trigger "
@"WHERE tgtype=21 AND tgisconstraint='t' AND tgrelid=%@",
tableOid];
PQclear(_pgResult);
EOAdaptorDebugLog(@"Postgres95Adaptor: execute command:\n%@", stmt);
_pgResult = PQexec(_pgConn, [stmt cString]);
for (i = 0, n = PQntuples(_pgResult); i < n; i++)
{
NSString *fkString;
NSArray *fkComp;
NSString *srcEntityName;
NSString *dstEntityName;
EOEntity *srcEntity;
EOEntity *dstEntity;
NSString *relationshipName;
EORelationship *relationship;
NSSet *dstPKSet;
NSMutableSet *dstAttribNames;
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
char *name;
unsigned length;
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
name = PQgetvalue(_pgResult,i,0);
length = name ? strlen(name) : 0;
fkString = AUTORELEASE([(PSQLA_alloc(NSString)) initWithCString: name
length: length]);
NSDebugMLLog(@"adaptor", @"foreign key: %@\n",fkString);
fkComp = [fkString componentsSeparatedByString: @"\\000"];
NSAssert1([fkComp count]>6, @"Illformed constraint:%@", fkString);
NSDebugMLLog(@"adaptor", @"constaint anme: %@",
[fkComp objectAtIndex:0]);
/* This assumes that entityName == tableName. */
srcEntityName = [fkComp objectAtIndex: 1];
dstEntityName = [fkComp objectAtIndex: 2];
srcEntity = [model entityNamed: srcEntityName];
dstEntity = [model entityNamed: dstEntityName];
relationshipName = [NSS_SWF:@"to%@", dstEntityName];
for (j = 1;
([srcEntity anyAttributeNamed: relationshipName] != nil ||
[srcEntity anyRelationshipNamed: relationshipName] != nil);
j++)
{
relationshipName = [NSS_SWF:@"to%@_%d", dstEntityName, j];
}
relationship = AUTORELEASE([EORelationship new]);
[relationship setName: relationshipName];
[srcEntity addRelationship: relationship];
dstAttribNames = (id)[NSMutableSet set];
for (j = 4, m = [fkComp count]; j < m; j = j + 2)
{
NSString *srcAttribName;
NSString *dstAttribName;
EOAttribute *srcAttrib;
EOAttribute *dstAttrib;
EOJoin *join;
srcAttribName = [fkComp objectAtIndex: j];
if ([srcAttribName length] == 0) break;
dstAttribName = [fkComp objectAtIndex: j + 1];
[dstAttribNames addObject: dstAttribName];
srcAttrib = [srcEntity attributeNamed: srcAttribName];
dstAttrib = [dstEntity attributeNamed: dstAttribName];
join
= AUTORELEASE([[EOJoin alloc] initWithSourceAttribute: srcAttrib
destinationAttribute: dstAttrib]);
[relationship addJoin: join];
}
dstPKSet = [NSSet setWithArray: [dstEntity primaryKeyAttributeNames]];
if ([dstPKSet isSubsetOfSet: dstAttribNames])
{
[relationship setToMany: NO];
}
else
{
[relationship setToMany: YES];
}
[relationship setJoinSemantic: EOInnerJoin];
}
}
- (EOModel *)describeModelWithTableNames: (NSArray *)tableNames
{
COmmit Part 2 * EOAccess/EOAdaptor.m: o optimization in 'for' loops * EOAccess/EODatabase.m: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOAccess/EODatabaseContext.h: o added _snapshotForGlobalIDIMP * EOAccess/EODatabaseContext.m: o commented NSEmitTODO in -objectsForSourceGlobalID:relationshipName:editingContext: o added beter exception format in qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot: o fix compiler warning in -relayPrimaryKey:object:entity: o logs o optimizations in -objectsWithFetchSpecification:editingContext: o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o use _snapshotForGlobalIDIMP o IMP usage optimization * EOAccess/EOAttribute.[hm]: o added EOAdaptorUnknownType o added _adaptorValueType and avoid recomputing it each time o added _valueTypeChar to avoid string comparaisons o use EOPriv classes declarations o Temporary reverted David changes in -adaptorValueByConvertingAttributeValue * EOAccess/EOAttributePriv.h: o added _valueTypeChar to avoid string comparaisons * EOAccess/EOEntityPriv.h: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.h: o moved private -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.m: o better exception in classProperties o fix compiler warning in -setClassProperties:, -setPrimaryKeyAttributes:, -setAttributesUsedForLocking: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLExpression.m: o optimization in -tableListWithRootEntity: o optimization in -formatSQLString:format: o optimization in +sqlPatternFromShellPattern: o optimization in +sqlPatternFromShellPattern:withEscapeCharacter: o fix in -sqlStringForKeyValueQualifier: o added log in -sqlStringForKeyValueQualifier: for not handled readFormat o added log -addInsertListAttribute:value: for not handled writeFormat o added log -addUpdateListAttribute:value: for not handled writeFormat o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLQualifier.m: o implemented EOKeyComparisonQualifier -schemaBasedQualifierWithRootEntity * EOAccess/EOUtilities.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOControl/EOPriv.[hm]: o added. Contains various classes/selectors/IMPs * EOControl/EOClassDescription.m: o handle EONull case in -propagateDeleteForObject:editingContext:, -addObject:toPropertyWithKey:, -snapshot, -removeObject:fromPropertyWithKey:, _setObject:forBothSidesOfRelationshipWithKey:, addObject:toBothSidesOfRelationshipWithKey:, -removeObject:fromBothSidesOfRelationshipWithKey: o fix compiler warning in -dictionaryForInstanceProperties, -shallowCopy, -updateFromSnapshot:, -snapshot o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o replaced isNilOrEONull() by _isNilOrEONull() o fix in -validateForSave o rewritten -validateValue:forKey: selector build * EOControl/EOEditingContext.h: o added -hasUnprocessedChanges * EOControl/EOEditingContext.m: o added -hasUnprocessedChanges o added NS_DURING,... to catch exceptions o replace [EOFault isFault:] by _isFault() o IMP usage optimization * EOControl/EOKeyGlobalID.m: o replaced isNilOrEONull() by _isNilOrEONull() o include <EOCOntrol/EOPriv.h> * EOControl/EOGenericRecord.m: o partially rewritten -description o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o changed variable name type of _infoForInstanceVariableNamed:retType:retSize:retOffset: o rewritten valueForKey:,... to use cString NSKeyValueCoding * EOControl/EOKeyValueCoding.m: o changed NSAssert in NSArray -valueForKey: o optimization in NSDictionary -takeValue:forKeyPath:isSmart: o optimization in NSDictionary -takeStoredValue:forKeyPath: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOKeyValueQualifier.m: o fixes for EONull/nil in -evaluateWithObject: o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOSortOrdering.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAdaptors/Postgres95SQLExpression.m: o float formatting in +formatValue:forAttribute: o added -externalNameQuoteCharacter o added +sqlPatternFromShellPattern: o added +sqlPatternFromShellPattern:withEscapeCharacter: o replaced isNilOrEONull() by _isNilOrEONull() * EOAdaptors/Postgres95Channel.m: o logs * EOAdaptors/Postgres95Values.m: o logs o fix in +setPostgres95Format: o fix calendard format to handle timezone (%z) o optimizations * EOControl/EOMutableKnownKeyDictionary.m o removed EOMKKDArrayMapping +dictionaryFromDictionary:subsetMapping: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOControl/EONSAddOns.[hm]: o added NSString(ShellPattern) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
EOModel *model=nil;
EOAdaptor *adaptor=nil;
EOEntity *entity=nil;
NSArray *entityNames=nil;
unsigned int i=0;
int tableNamesCount=[tableNames count];
int entityNamesCount=0;
adaptor = [[self adaptorContext] adaptor];
model = AUTORELEASE([[EOModel alloc] init]);
[model setAdaptorName: [adaptor name]];
[model setConnectionDictionary: [adaptor connectionDictionary]];
COmmit Part 2 * EOAccess/EOAdaptor.m: o optimization in 'for' loops * EOAccess/EODatabase.m: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOAccess/EODatabaseContext.h: o added _snapshotForGlobalIDIMP * EOAccess/EODatabaseContext.m: o commented NSEmitTODO in -objectsForSourceGlobalID:relationshipName:editingContext: o added beter exception format in qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot: o fix compiler warning in -relayPrimaryKey:object:entity: o logs o optimizations in -objectsWithFetchSpecification:editingContext: o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o use _snapshotForGlobalIDIMP o IMP usage optimization * EOAccess/EOAttribute.[hm]: o added EOAdaptorUnknownType o added _adaptorValueType and avoid recomputing it each time o added _valueTypeChar to avoid string comparaisons o use EOPriv classes declarations o Temporary reverted David changes in -adaptorValueByConvertingAttributeValue * EOAccess/EOAttributePriv.h: o added _valueTypeChar to avoid string comparaisons * EOAccess/EOEntityPriv.h: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.h: o moved private -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.m: o better exception in classProperties o fix compiler warning in -setClassProperties:, -setPrimaryKeyAttributes:, -setAttributesUsedForLocking: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLExpression.m: o optimization in -tableListWithRootEntity: o optimization in -formatSQLString:format: o optimization in +sqlPatternFromShellPattern: o optimization in +sqlPatternFromShellPattern:withEscapeCharacter: o fix in -sqlStringForKeyValueQualifier: o added log in -sqlStringForKeyValueQualifier: for not handled readFormat o added log -addInsertListAttribute:value: for not handled writeFormat o added log -addUpdateListAttribute:value: for not handled writeFormat o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLQualifier.m: o implemented EOKeyComparisonQualifier -schemaBasedQualifierWithRootEntity * EOAccess/EOUtilities.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOControl/EOPriv.[hm]: o added. Contains various classes/selectors/IMPs * EOControl/EOClassDescription.m: o handle EONull case in -propagateDeleteForObject:editingContext:, -addObject:toPropertyWithKey:, -snapshot, -removeObject:fromPropertyWithKey:, _setObject:forBothSidesOfRelationshipWithKey:, addObject:toBothSidesOfRelationshipWithKey:, -removeObject:fromBothSidesOfRelationshipWithKey: o fix compiler warning in -dictionaryForInstanceProperties, -shallowCopy, -updateFromSnapshot:, -snapshot o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o replaced isNilOrEONull() by _isNilOrEONull() o fix in -validateForSave o rewritten -validateValue:forKey: selector build * EOControl/EOEditingContext.h: o added -hasUnprocessedChanges * EOControl/EOEditingContext.m: o added -hasUnprocessedChanges o added NS_DURING,... to catch exceptions o replace [EOFault isFault:] by _isFault() o IMP usage optimization * EOControl/EOKeyGlobalID.m: o replaced isNilOrEONull() by _isNilOrEONull() o include <EOCOntrol/EOPriv.h> * EOControl/EOGenericRecord.m: o partially rewritten -description o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o changed variable name type of _infoForInstanceVariableNamed:retType:retSize:retOffset: o rewritten valueForKey:,... to use cString NSKeyValueCoding * EOControl/EOKeyValueCoding.m: o changed NSAssert in NSArray -valueForKey: o optimization in NSDictionary -takeValue:forKeyPath:isSmart: o optimization in NSDictionary -takeStoredValue:forKeyPath: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOKeyValueQualifier.m: o fixes for EONull/nil in -evaluateWithObject: o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOSortOrdering.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAdaptors/Postgres95SQLExpression.m: o float formatting in +formatValue:forAttribute: o added -externalNameQuoteCharacter o added +sqlPatternFromShellPattern: o added +sqlPatternFromShellPattern:withEscapeCharacter: o replaced isNilOrEONull() by _isNilOrEONull() * EOAdaptors/Postgres95Channel.m: o logs * EOAdaptors/Postgres95Values.m: o logs o fix in +setPostgres95Format: o fix calendard format to handle timezone (%z) o optimizations * EOControl/EOMutableKnownKeyDictionary.m o removed EOMKKDArrayMapping +dictionaryFromDictionary:subsetMapping: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOControl/EONSAddOns.[hm]: o added NSString(ShellPattern) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
for (i = 0; i < tableNamesCount; i++)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSString *name;
NS_DURING
name = [tableNames objectAtIndex: i];
[self _describeBasicEntityWithName: name forModel: model];
NS_HANDLER
{
RETAIN(localException);
[pool release];
[AUTORELEASE(localException) raise];
}
NS_ENDHANDLER
[pool release];
}
/* <foreign key stuff> */
entityNames = [model entityNames];
COmmit Part 2 * EOAccess/EOAdaptor.m: o optimization in 'for' loops * EOAccess/EODatabase.m: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOAccess/EODatabaseContext.h: o added _snapshotForGlobalIDIMP * EOAccess/EODatabaseContext.m: o commented NSEmitTODO in -objectsForSourceGlobalID:relationshipName:editingContext: o added beter exception format in qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot: o fix compiler warning in -relayPrimaryKey:object:entity: o logs o optimizations in -objectsWithFetchSpecification:editingContext: o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o use _snapshotForGlobalIDIMP o IMP usage optimization * EOAccess/EOAttribute.[hm]: o added EOAdaptorUnknownType o added _adaptorValueType and avoid recomputing it each time o added _valueTypeChar to avoid string comparaisons o use EOPriv classes declarations o Temporary reverted David changes in -adaptorValueByConvertingAttributeValue * EOAccess/EOAttributePriv.h: o added _valueTypeChar to avoid string comparaisons * EOAccess/EOEntityPriv.h: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.h: o moved private -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.m: o better exception in classProperties o fix compiler warning in -setClassProperties:, -setPrimaryKeyAttributes:, -setAttributesUsedForLocking: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLExpression.m: o optimization in -tableListWithRootEntity: o optimization in -formatSQLString:format: o optimization in +sqlPatternFromShellPattern: o optimization in +sqlPatternFromShellPattern:withEscapeCharacter: o fix in -sqlStringForKeyValueQualifier: o added log in -sqlStringForKeyValueQualifier: for not handled readFormat o added log -addInsertListAttribute:value: for not handled writeFormat o added log -addUpdateListAttribute:value: for not handled writeFormat o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLQualifier.m: o implemented EOKeyComparisonQualifier -schemaBasedQualifierWithRootEntity * EOAccess/EOUtilities.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOControl/EOPriv.[hm]: o added. Contains various classes/selectors/IMPs * EOControl/EOClassDescription.m: o handle EONull case in -propagateDeleteForObject:editingContext:, -addObject:toPropertyWithKey:, -snapshot, -removeObject:fromPropertyWithKey:, _setObject:forBothSidesOfRelationshipWithKey:, addObject:toBothSidesOfRelationshipWithKey:, -removeObject:fromBothSidesOfRelationshipWithKey: o fix compiler warning in -dictionaryForInstanceProperties, -shallowCopy, -updateFromSnapshot:, -snapshot o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o replaced isNilOrEONull() by _isNilOrEONull() o fix in -validateForSave o rewritten -validateValue:forKey: selector build * EOControl/EOEditingContext.h: o added -hasUnprocessedChanges * EOControl/EOEditingContext.m: o added -hasUnprocessedChanges o added NS_DURING,... to catch exceptions o replace [EOFault isFault:] by _isFault() o IMP usage optimization * EOControl/EOKeyGlobalID.m: o replaced isNilOrEONull() by _isNilOrEONull() o include <EOCOntrol/EOPriv.h> * EOControl/EOGenericRecord.m: o partially rewritten -description o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o changed variable name type of _infoForInstanceVariableNamed:retType:retSize:retOffset: o rewritten valueForKey:,... to use cString NSKeyValueCoding * EOControl/EOKeyValueCoding.m: o changed NSAssert in NSArray -valueForKey: o optimization in NSDictionary -takeValue:forKeyPath:isSmart: o optimization in NSDictionary -takeStoredValue:forKeyPath: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOKeyValueQualifier.m: o fixes for EONull/nil in -evaluateWithObject: o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOSortOrdering.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAdaptors/Postgres95SQLExpression.m: o float formatting in +formatValue:forAttribute: o added -externalNameQuoteCharacter o added +sqlPatternFromShellPattern: o added +sqlPatternFromShellPattern:withEscapeCharacter: o replaced isNilOrEONull() by _isNilOrEONull() * EOAdaptors/Postgres95Channel.m: o logs * EOAdaptors/Postgres95Values.m: o logs o fix in +setPostgres95Format: o fix calendard format to handle timezone (%z) o optimizations * EOControl/EOMutableKnownKeyDictionary.m o removed EOMKKDArrayMapping +dictionaryFromDictionary:subsetMapping: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOControl/EONSAddOns.[hm]: o added NSString(ShellPattern) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
entityNamesCount=[entityNames count];
for (i = 0; i < entityNamesCount; i++)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSString *entityName;
NS_DURING
entityName = [entityNames objectAtIndex:i];
entity = [model entityNamed: entityName];
[self _describeForeignKeysForEntity: entity forModel: model];
NS_HANDLER
{
RETAIN(localException);
[pool release];
[AUTORELEASE(localException) raise];
}
NS_ENDHANDLER
[pool release];
}
COmmit Part 2 * EOAccess/EOAdaptor.m: o optimization in 'for' loops * EOAccess/EODatabase.m: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOAccess/EODatabaseContext.h: o added _snapshotForGlobalIDIMP * EOAccess/EODatabaseContext.m: o commented NSEmitTODO in -objectsForSourceGlobalID:relationshipName:editingContext: o added beter exception format in qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot: o fix compiler warning in -relayPrimaryKey:object:entity: o logs o optimizations in -objectsWithFetchSpecification:editingContext: o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o use _snapshotForGlobalIDIMP o IMP usage optimization * EOAccess/EOAttribute.[hm]: o added EOAdaptorUnknownType o added _adaptorValueType and avoid recomputing it each time o added _valueTypeChar to avoid string comparaisons o use EOPriv classes declarations o Temporary reverted David changes in -adaptorValueByConvertingAttributeValue * EOAccess/EOAttributePriv.h: o added _valueTypeChar to avoid string comparaisons * EOAccess/EOEntityPriv.h: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.h: o moved private -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category * EOAccess/EOEntity.m: o better exception in classProperties o fix compiler warning in -setClassProperties:, -setPrimaryKeyAttributes:, -setAttributesUsedForLocking: o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLExpression.m: o optimization in -tableListWithRootEntity: o optimization in -formatSQLString:format: o optimization in +sqlPatternFromShellPattern: o optimization in +sqlPatternFromShellPattern:withEscapeCharacter: o fix in -sqlStringForKeyValueQualifier: o added log in -sqlStringForKeyValueQualifier: for not handled readFormat o added log -addInsertListAttribute:value: for not handled writeFormat o added log -addUpdateListAttribute:value: for not handled writeFormat o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAccess/EOSQLQualifier.m: o implemented EOKeyComparisonQualifier -schemaBasedQualifierWithRootEntity * EOAccess/EOUtilities.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOControl/EOPriv.[hm]: o added. Contains various classes/selectors/IMPs * EOControl/EOClassDescription.m: o handle EONull case in -propagateDeleteForObject:editingContext:, -addObject:toPropertyWithKey:, -snapshot, -removeObject:fromPropertyWithKey:, _setObject:forBothSidesOfRelationshipWithKey:, addObject:toBothSidesOfRelationshipWithKey:, -removeObject:fromBothSidesOfRelationshipWithKey: o fix compiler warning in -dictionaryForInstanceProperties, -shallowCopy, -updateFromSnapshot:, -snapshot o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o replaced isNilOrEONull() by _isNilOrEONull() o fix in -validateForSave o rewritten -validateValue:forKey: selector build * EOControl/EOEditingContext.h: o added -hasUnprocessedChanges * EOControl/EOEditingContext.m: o added -hasUnprocessedChanges o added NS_DURING,... to catch exceptions o replace [EOFault isFault:] by _isFault() o IMP usage optimization * EOControl/EOKeyGlobalID.m: o replaced isNilOrEONull() by _isNilOrEONull() o include <EOCOntrol/EOPriv.h> * EOControl/EOGenericRecord.m: o partially rewritten -description o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() o replace [EOFault isFault:] by _isFault() o changed variable name type of _infoForInstanceVariableNamed:retType:retSize:retOffset: o rewritten valueForKey:,... to use cString NSKeyValueCoding * EOControl/EOKeyValueCoding.m: o changed NSAssert in NSArray -valueForKey: o optimization in NSDictionary -takeValue:forKeyPath:isSmart: o optimization in NSDictionary -takeStoredValue:forKeyPath: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOKeyValueQualifier.m: o fixes for EONull/nil in -evaluateWithObject: o replaced [EONull null] by GDL2EONull o include <EOCOntrol/EOPriv.h> * EOControl/EOSortOrdering.m: o include <EOCOntrol/EOPriv.h> o replaced [EONull null] by GDL2EONull * EOAdaptors/Postgres95SQLExpression.m: o float formatting in +formatValue:forAttribute: o added -externalNameQuoteCharacter o added +sqlPatternFromShellPattern: o added +sqlPatternFromShellPattern:withEscapeCharacter: o replaced isNilOrEONull() by _isNilOrEONull() * EOAdaptors/Postgres95Channel.m: o logs * EOAdaptors/Postgres95Values.m: o logs o fix in +setPostgres95Format: o fix calendard format to handle timezone (%z) o optimizations * EOControl/EOMutableKnownKeyDictionary.m o removed EOMKKDArrayMapping +dictionaryFromDictionary:subsetMapping: o include <EOCOntrol/EOPriv.h> o replaced isNilOrEONull() by _isNilOrEONull() * EOControl/EONSAddOns.[hm]: o added NSString(ShellPattern) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
for (i=0; i < entityNamesCount; i++)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSMutableArray *classProperties;
entity = [model entityNamed:[entityNames objectAtIndex:i]];
classProperties = [NSMutableArray arrayWithArray:[entity attributes]];
[classProperties removeObjectsInArray: [entity primaryKeyAttributes]];
[entity setClassProperties: classProperties];
[pool release];
}
[model beautifyNames];
return model;
}
/* extensions for login panel */
- (NSArray *)describeDatabaseNames
{
NSMutableArray *databaseNames = [NSMutableArray array];
NSString *stmt = [NSS_SWF:@"SELECT datname FROM pg_database LEFT JOIN pg_user "
@"ON datdba = usesysid ORDER BY 1"];
int i;
_pgResult = PQexec(_pgConn, [stmt cString]);
for (i=0; i < PQntuples(_pgResult); i++)
{
[databaseNames addObject: [NSString stringWithCString:PQgetvalue(_pgResult,i,0)]];
}
return (NSArray *)databaseNames;
}
- (BOOL) userNameIsAdministrative:(NSString *)userName
{
NSString *stmt = [NSS_SWF:@"SELECT usecreatedb FROM pg_user WHERE "
@"usename = '%@'",userName];
_pgResult = PQexec(_pgConn, [stmt cString]);
if (_pgResult != NULL)
if (PQntuples(_pgResult))
{
const char *bytes;
bytes = PQgetvalue(_pgResult,0,0);
if (((char *)bytes)[0] == 't' && ((char *)bytes)[1] == 0)
return YES;
if (((char *)bytes)[0] == 'f' && ((char *)bytes)[1] == 0)
return NO;
}
return NO;
}
- (void)setDelegate:delegate
{
[super setDelegate: delegate];
_postgres95DelegateRespondsTo.postgres95InsertedRowOid =
[delegate respondsToSelector:
@selector(postgres95Channel:insertedRowWithOid:)];
_postgres95DelegateRespondsTo.postgres95Notification =
[delegate respondsToSelector:
@selector(postgres95Channel:receivedNotification:)];
}
- (NSDictionary *)primaryKeyForNewRowWithEntity:(EOEntity *)entity
{
//entity primaryKeyAttributes
//self adaptorContext
//on each attr attr: adaptorValueType
//entty externalName
//context autoBeginTransaction
//self cleanupFetch######
//attr name
//dictionary with...
NSDictionary *pk = nil;
NSString *sqlString;
NSString *key = nil;
NSNumber *pkValue = nil;
const char *string = NULL;
int length = 0;
NSString *primaryKeySequenceNameFormat;
NSString *sequenceName;
EOSQLExpression *expr;
EOFLOGObjectFnStart();
primaryKeySequenceNameFormat
= [(Postgres95Context*)[self adaptorContext] primaryKeySequenceNameFormat];
NSAssert(primaryKeySequenceNameFormat, @"No primary sequence name format");
expr = AUTORELEASE([[[_adaptorContext adaptor] expressionClass] new]);
sequenceName = [NSString stringWithFormat: primaryKeySequenceNameFormat,
[entity primaryKeyRootName]];
sequenceName = [expr sqlStringForSchemaObjectName: sequenceName];
sqlString = [NSString stringWithFormat: @"SELECT nextval('%@')",
sequenceName];
[expr setStatement: sqlString];
[self _cancelResults];
[_adaptorContext autoBeginTransaction: NO];
[self _evaluateExpression: expr
withAttributes: _pkAttributeArray];
if ([self isFetchInProgress] == NO
|| [self advanceRow] == NO)
{
[self _cancelResults];
[_adaptorContext autoCommitTransaction];
}
else
{
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
EOAttribute *attr;
string = PQgetvalue(_pgResult, _currentResultRow, 0);
length = PQgetlength(_pgResult, _currentResultRow, 0);
* EOAdaptors/Postgres95/Postgres95Private.m/h: New files based on EOControl/EOPriv.m/h. * EOAdaptors/Postgres95/GNUmakefile.in: Build Postgres95Private.m. * EOAdaptors/Postgres95/Postgres95Adaptor.m: Do not depend on EOControl/EOPriv.m/h but on own private files. (+assignExternalInfoForEntity): Use objectAtIndex: instead of enumerator for speed. * EOAdaptors/Postgres95/Postgres95Channel.m: (+initialize) (-lowLevelResultFieldNames:, -fetchRowWithZone:) (-insertRow:forEntity:, -_describeResults, -describeTableNames) (-updateValues:inRowsDescribedByQualifier:entity:) (-_describeBasicEntityWithName:forModel:) (-_describeForeignKeysForEntity:forModel:) (-primaryKeyForNewRowWithEntity:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. (pgResultDictionary): Simplify unused static local be reverting optimizations. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: (+initialize, +formatValue:forAttribute:) (+sqlPatternFromShellPattern:) (+sqlPatternFromShellPattern:withEscapeCharacter:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. * EOAdaptors/Postgres95/Postgres95Values.h/m (Postgres95CalendarFormat, Postgres95ValuesClass) (Postgres95Values_newValueForBytesLengthAttributeSEL) (Postgres95Values_newValueForBytesLengthAttributeIMP) (Postgres95Values_newValueForBytesLengthAttribute): Remove. ([NSCalendarDate+setPostgres95Format:]): Remove. ([NSCalendarDate+postgres95Format]): Deprecate. (LPSQLA_StringDefaultCStringEncoding): New local static. (+initialize, +newValueForNumberType:length:attribute:) (+newValueForCharactersType:length:attribute:) (+newValueForDateType:length:attribute:): Do not depend on EOControl/EOPriv.m/h but on own private files. Improve optimizations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20750 72102866-910b-0410-8b05-ffd578937521
2005-02-19 12:13:22 +00:00
attr = [_pkAttributeArray objectAtIndex: 0];
pkValue = AUTORELEASE(PSQLA_Postgres95Values_newValueForBytesLengthAttribute(string,length,attr));
NSAssert(pkValue, @"no pk value");
key = [[entity primaryKeyAttributeNames] objectAtIndex: 0];
NSAssert(key, @"pk key");
[self _cancelResults];
[_adaptorContext autoCommitTransaction];
pk = [NSDictionary dictionaryWithObject: pkValue
forKey: key];
}
EOFLOGObjectFnStop();
return pk;
}
- (void)cleanupFetch
{
Postgres95Context *adaptorContext;
EOFLOGObjectFnStart();
adaptorContext = (Postgres95Context *)[self adaptorContext];
NSDebugMLog(@"[self isFetchInProgress]=%s",
([self isFetchInProgress] ? "YES" : "NO"));
if ([self isFetchInProgress])
{
BOOL ok;
[self _cancelResults];
ok = [adaptorContext autoCommitTransaction];
//_isTransactionstarted to 0
//_evaluationIsDirectCalled=0
}
EOFLOGObjectFnStop();
}
@end /* Postgres95Channel */