+2006-09-30 Helge Hess <helge.hess@opengroupware.org>
+
+ * v.4.5.48
+
+ * always use UTF-8 as the transport encoding (was Latin1 before),
+ enforce that by setting the connection client encoding (when
+ possible)
+
+ * added category to convert EOKeyGlobalIDs to SQL (required by OGo
+ trunk)
+
+ * moved NSNull/pgval category to own file
+
+ * moved PostgreSQL version detection to pgconfig.h file, properly
+ detect new PostgreSQL versions by a missing PG_MAJOR_VERSION
+ define (and enable NG_SET_CLIENT_ENCODING etc in this case)
+
2006-07-04 Helge Hess <helge.hess@opengroupware.org>
* fixed some 64bit issues (v4.5.47)
--- /dev/null
+/*
+ EOKeyGlobalID+PGVal.m
+
+ Copyright (C) 2006 SKYRIX Software AG and Helge Hess
+
+ Author: Helge Hess (helge.hess@opengroupware.org)
+
+ This file is part of the PostgreSQL Adaptor Library
+
+ 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.
+*/
+
+#include <EOControl/EOKeyGlobalID.h>
+#include "PostgreSQL72Channel.h"
+#include "common.h"
+
+@implementation EOKeyGlobalID(PostgreSQL72Values)
+
+- (NSString *)stringValueForPostgreSQLType:(NSString *)_type
+ attribute:(EOAttribute *)_attribute
+{
+ if (self->count == 0) {
+ NSLog(@"ERROR(%s): got a EOKeyGlobalID w/o key values: %@",
+ __PRETTY_FUNCTION__, self);
+ return nil;
+ }
+
+ return [self->values[0] stringValueForPostgreSQLType:_type
+ attribute:_attribute];
+}
+
+@end /* EOKeyGlobalID(PostgreSQL72Values) */
#
# GNUmakefile
#
-# Copyright (C) 2004-2005 SKYRIX Software AG
+# Copyright (C) 2004-2006 SKYRIX Software AG
#
# Author: Helge Hess (helge.hess@skyrix.com)
#
PostgreSQL_OBJC_FILES = \
PGConnection.m \
+ PGResultSet.m \
PostgreSQL72Expression.m \
PostgreSQL72Adaptor.m \
PostgreSQL72Context.m \
PostgreSQL72Channel.m \
PostgreSQL72Channel+Model.m \
PostgreSQL72Exception.m \
- PostgreSQL72Values.m \
NSString+PostgreSQL72.m \
EOAttribute+PostgreSQL72.m \
NSString+PGVal.m \
NSData+PGVal.m \
NSCalendarDate+PGVal.m \
NSNumber+PGVal.m \
+ EOKeyGlobalID+PGVal.m \
+ NSNull+PGVal.m \
+ PostgreSQL72DataTypeMappingException.m
PostgreSQL_PRINCIPAL_CLASS = PostgreSQL72Adaptor
return @"";
if (enc == 0) {
- enc = [NSString defaultCStringEncoding];
- NSLog(@"Note: PostgreSQL72 adaptor using '%@' encoding for data=>string "
+ // enc = [NSString defaultCStringEncoding];
+ enc = NSUTF8StringEncoding;
+ NSLog(@"Note: PostgreSQL adaptor using '%@' encoding for data=>string "
@"conversion.",
[NSString localizedNameOfStringEncoding:enc]);
}
--- /dev/null
+/*
+ NSNull+PGVal.m
+
+ Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
+ Copyright (C) 2000-2006 SKYRIX Software AG and Helge Hess
+
+ Author: Helge Hess (helge@opengroupware.org)
+
+ This file is part of the PostgreSQL72 Adaptor Library
+
+ 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.
+*/
+
+#include "common.h"
+
+@implementation NSNull(PostgreSQL72Values)
+
+- (NSString *)stringValueForPostgreSQLType:(NSString *)_type
+ attribute:(EOAttribute *)_attribute
+{
+ return @"null";
+}
+
+@end /* NSNull(PostgreSQL72Values) */
/*
NSString+PGVal.m
- Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
- Copyright (C) 2000-2005 SKYRIX Software AG and Helge Hess
+ Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
+ Copyright (C) 2000-2006 SKYRIX Software AG and Helge Hess
Author: Helge Hess (helge.hess@opengroupware.org)
- This file is part of the PostgreSQL72 Adaptor Library
+ This file is part of the PostgreSQL Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
static Class NSStringClass = Nil;
static Class EOExprClass = Nil;
+static id (*ctor)(id, SEL, const char *) = NULL;
+ (id)valueFromCString:(const char *)_cstr length:(int)_length
postgreSQLType:(NSString *)_type
attribute:(EOAttribute *)_attribute
adaptorChannel:(PostgreSQL72Channel *)_channel
{
+ // TODO: would be better if this would return a retained object to avoid
+ // the dreaded autorelease pool
if (_cstr == NULL) return nil;
if (*_cstr == '\0') return @"";
+
if (NSStringClass == Nil) NSStringClass = [NSString class];
+ if (ctor == NULL) {
+ ctor = (void *)
+ [NSStringClass methodForSelector:@selector(stringWithUTF8String:)];
+ }
+
// TODO: cache IMP of selector
- return [NSStringClass stringWithCString:_cstr];
+ return ctor != NULL
+ ? ctor(NSStringClass, @selector(stringWithUTF8String:), _cstr)
+ : [NSStringClass stringWithUTF8String:_cstr];
}
+ (id)valueFromBytes:(const void *)_bytes length:(int)_length
if (len < 4)
return self;
- _type = [_type lowercaseString];
+ _type = [_type lowercaseString]; // looks slow
if (!([_type hasPrefix:@"char"] ||
[_type hasPrefix:@"varchar"] ||
/*
NSString+PostgreSQL72.m
- Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
- Copyright (C) 2000-2005 SKYRIX Software AG and Helge Hess
+ Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
+ Copyright (C) 2000-2006 SKYRIX Software AG and Helge Hess
Author: Helge Hess (helge.hess@opengroupware.org)
@implementation NSString(PostgreSQL72MiscStrings)
- (NSString *)_pgModelMakeInstanceVarName {
+ unsigned clen;
+ unichar *us;
+ int cnt, cnt2;
+
if ([self length] == 0)
return @"";
- else {
- unsigned clen = 0;
- char *s = NULL;
- int cnt, cnt2;
-
- clen = [self cStringLength];
- s = malloc(clen + 10);
-
- [self getCString:s maxLength:clen];
-
- for (cnt = cnt2 = 0; cnt < clen; cnt++, cnt2++) {
- if ((s[cnt] == '_') && (s[cnt + 1] != '\0')) {
- s[cnt2] = toupper(s[cnt + 1]);
- cnt++;
- }
- else if ((s[cnt] == '2') && (s[cnt + 1] != '\0')) {
- s[cnt2] = s[cnt];
- cnt++;
- cnt2++;
- s[cnt2] = toupper(s[cnt]);
- }
- else
- s[cnt2] = tolower(s[cnt]);
+
+ // TODO: do use UTF-8 here
+ clen = [self length];
+ us = malloc((clen + 10) * sizeof(unichar));
+
+ [self getCharacters:us];
+ us[clen] = 0;
+
+ // Note: upper/lower detection is not strictly correct ... (no unicode)
+ for (cnt = cnt2 = 0; cnt < clen; cnt++, cnt2++) {
+ if ((us[cnt] == '_') && (us[cnt + 1] != '\0')) {
+ us[cnt2] = toupper(us[cnt + 1]);
+ cnt++;
}
- s[cnt2] = '\0';
-
- return [[[NSString alloc]
- initWithCStringNoCopy:s length:strlen(s) freeWhenDone:YES]
- autorelease];
+ else if ((us[cnt] == '2') && (us[cnt + 1] != '\0')) {
+ us[cnt2] = us[cnt];
+ cnt++;
+ cnt2++;
+ us[cnt2] = toupper(us[cnt]);
+ }
+ else
+ us[cnt2] = tolower(us[cnt]);
}
+ us[cnt2] = '\0';
+
+ return [NSString stringWithCharacters:us length:cnt2];
}
- (NSString *)_pgModelMakeClassName {
+ unsigned clen = 0;
+ unichar *us;
+ int cnt, cnt2;
+
if ([self length] == 0)
return @"";
- else {
- unsigned clen = 0;
- char *s = NULL;
- int cnt, cnt2;
-
- clen = [self cStringLength];
- s = malloc(clen + 10);
- [self getCString:s maxLength:clen];
-
- for (cnt = cnt2 = 0; cnt < clen; cnt++, cnt2++) {
- if ((s[cnt] == '_') && (s[cnt + 1] != '\0')) {
- s[cnt2] = toupper(s[cnt + 1]);
- cnt++;
- }
- else if ((s[cnt] == '2') && (s[cnt + 1] != '\0')) {
- s[cnt2] = s[cnt];
- cnt++;
- cnt2++;
- s[cnt2] = toupper(s[cnt]);
- }
- else
- s[cnt2] = tolower(s[cnt]);
+ // TODO: use UTF-8 here
+ clen = [self cStringLength];
+ us = malloc((clen + 10) * sizeof(unichar));
+
+ [self getCharacters:us];
+ us[clen] = 0;
+
+ for (cnt = cnt2 = 0; cnt < clen; cnt++, cnt2++) {
+ if ((us[cnt] == '_') && (us[cnt + 1] != '\0')) {
+ us[cnt2] = toupper(us[cnt + 1]);
+ cnt++;
}
- s[cnt2] = '\0';
+ else if ((us[cnt] == '2') && (us[cnt + 1] != '\0')) {
+ us[cnt2] = us[cnt];
+ cnt++;
+ cnt2++;
+ us[cnt2] = toupper(us[cnt]);
+ }
+ else
+ us[cnt2] = tolower(us[cnt]);
+ }
+ us[cnt2] = '\0';
- s[0] = toupper(s[0]);
+ us[0] = toupper(us[0]);
- return [[[NSString alloc]
- initWithCStringNoCopy:s length:strlen(s)
- freeWhenDone:YES]
- autorelease];
- }
+ return [NSString stringWithCharacters:us length:cnt2];
}
+static NSCharacterSet *upperSet = nil;
+static NSCharacterSet *spaceSet = nil;
+
- (NSString *)_pgStringWithCapitalizedFirstChar {
- NSCharacterSet *upperSet = [NSCharacterSet uppercaseLetterCharacterSet];
+ if (upperSet == nil)
+ upperSet = [[NSCharacterSet uppercaseLetterCharacterSet] retain];
if ([self length] == 0)
return @"";
- else if ([upperSet characterIsMember:[self characterAtIndex:0]])
+
+ if ([upperSet characterIsMember:[self characterAtIndex:0]])
return [[self copy] autorelease];
- else {
+
+ {
NSMutableString *str = [NSMutableString stringWithCapacity:[self length]];
[str appendString:[[self substringToIndex:1] uppercaseString]];
}
- (NSString *)_pgStripEndSpaces {
- if ([self length] > 0) {
- NSCharacterSet *spaceSet;
- NSMutableString *str;
- unichar (*charAtIndex)(id, SEL, int);
- NSRange range;
+ NSMutableString *str;
+ unichar (*charAtIndex)(id, SEL, int);
+ NSRange range;
- spaceSet = [NSCharacterSet whitespaceCharacterSet];
- str = [NSMutableString stringWithCapacity:[self length]];
+ if ([self length] == 0)
+ return @"";
- charAtIndex = (unichar (*)(id, SEL, int))
- [self methodForSelector:@selector(characterAtIndex:)];
- range.length = 0;
+ if (spaceSet == nil)
+ spaceSet = [[NSCharacterSet whitespaceCharacterSet] retain];
+
+ str = [NSMutableString stringWithCapacity:[self length]];
+
+ charAtIndex = (unichar (*)(id, SEL, int))
+ [self methodForSelector:@selector(characterAtIndex:)];
+ range.length = 0;
- for (range.location = ([self length] - 1);
+ for (range.location = ([self length] - 1);
range.location >= 0;
range.location++, range.length++) {
unichar c;
c = charAtIndex(self, @selector(characterAtIndex:), range.location);
if (![spaceSet characterIsMember:c])
break;
- }
+ }
- if (range.length > 0) {
- [str appendString:self];
- [str deleteCharactersInRange:range];
- return AUTORELEASE([str copy]);
- }
+ if (range.length > 0) {
+ [str appendString:self];
+ [str deleteCharactersInRange:range];
+ return AUTORELEASE([str copy]);
}
+
return AUTORELEASE([self copy]);
}
/*
PGConnection.h
- Copyright (C) 2004 SKYRIX Software AG and Helge Hess
+ Copyright (C) 2004-2006 SKYRIX Software AG and Helge Hess
Author: Helge Hess (helge.hess@opengroupware.org)
- (void)clearRawResults:(void *)_ptr;
- (PGResultSet *)execute:(NSString *)_sql;
+/* support */
+
+- (const char *)_cstrFromString:(NSString *)_s;
+- (NSString *)_stringFromCString:(const char *)_cstr;
+
@end
+
+
@interface PGResultSet : NSObject
{
@protected
/*
PGConnection.m
- Copyright (C) 2004-2005 SKYRIX Software AG and Helge Hess
+ Copyright (C) 2004-2006 SKYRIX Software AG and Helge Hess
Author: Helge Hess (helge.hess@opengroupware.org)
#include "PGConnection.h"
#include "common.h"
#include <libpq-fe.h>
-
-#if PG_MAJOR_VERSION >= 6 && PG_MINOR_VERSION > 3
-# define NG_HAS_NOTICE_PROCESSOR 1
-# define NG_HAS_BINARY_TUPLES 1
-# define NG_HAS_FMOD 1
-#endif
-
-#if PG_MAJOR_VERSION >= 7 && PG_MINOR_VERSION > 3
-# define NG_SET_CLIENT_ENCODING 1
-#endif
+#include "pgconfig.h"
@implementation PGConnection
- (const char *)_cstrFromString:(NSString *)_s {
// TODO: fix API, check what the API string encoding is
- return [_s cString];
+ return [_s UTF8String];
}
- (NSString *)_stringFromCString:(const char *)_cstr {
- return [NSString stringWithCString:_cstr];
+ return [NSString stringWithUTF8String:_cstr];
}
/* accessors */
@end /* PGConnection */
-@implementation PGResultSet
-
-/* wraps PGresult */
-
-- (id)initWithConnection:(PGConnection *)_con handle:(void *)_handle {
- if (_handle == NULL) {
- [self release];
- return nil;
- }
- if ((self = [super init])) {
- self->connection = [_con retain];
- self->results = _handle;
- }
- return self;
-}
-
-- (void)dealloc {
- [self clear];
- [self->connection release];
- [super dealloc];
-}
-
-/* accessors */
-
-- (BOOL)isValid {
- return self->results != NULL ? YES : NO;
-}
-
-- (BOOL)containsBinaryTuples {
-#if NG_HAS_BINARY_TUPLES
- if (self->results == NULL) return NO;
- return PQbinaryTuples(self->results) ? YES : NO;
-#else
- return NO;
-#endif
-}
-
-- (NSString *)commandStatus {
- char *cstr;
-
- if (self->results == NULL)
- return nil;
- if ((cstr = PQcmdStatus(self->results)) == NULL)
- return nil;
- return [NSString stringWithCString:cstr];
-}
-
-- (NSString *)commandTuples {
- char *cstr;
-
- if (self->results == NULL)
- return nil;
- if ((cstr = PQcmdTuples(self->results)) == NULL)
- return nil;
- return [NSString stringWithCString:cstr];
-}
-
-/* fields */
-
-- (unsigned)fieldCount {
- return self->results != NULL ? PQnfields(self->results) : 0;
-}
-
-- (NSString *)fieldNameAtIndex:(unsigned int)_idx {
- // TODO: charset
- if (self->results == NULL) return nil;
- return [NSString stringWithCString:PQfname(self->results, _idx)];
-}
-
-- (int)indexOfFieldNamed:(NSString *)_name {
- return PQfnumber(self->results, [_name cString]);
-}
-
-- (int)fieldSizeAtIndex:(unsigned int)_idx {
- if (self->results == NULL) return 0;
- return PQfsize(self->results, _idx);
-}
-
-- (int)modifierAtIndex:(unsigned int)_idx {
- if (self->results == NULL) return 0;
-#if NG_HAS_FMOD
- return PQfmod(self->results, _idx);
-#else
- return 0;
-#endif
-}
-
-/* tuples */
-
-- (unsigned int)tupleCount {
- if (self->results == NULL) return 0;
- return PQntuples(self->results);
-}
-
-- (BOOL)isNullTuple:(int)_tuple atIndex:(unsigned int)_idx {
- if (self->results == NULL) return NO;
- return PQgetisnull(self->results, _tuple, _idx) ? YES : NO;
-}
-
-- (void *)rawValueOfTuple:(int)_tuple atIndex:(unsigned int)_idx {
- if (self->results == NULL) return NULL;
- return PQgetvalue(self->results, _tuple, _idx);
-}
-
-- (int)lengthOfTuple:(int)_tuple atIndex:(unsigned int)_idx {
- if (self->results == NULL) return 0;
- return PQgetlength(self->results, _tuple, _idx);
-}
-
-/* operations */
-
-- (void)clear {
- if (self->results == NULL) return;
- PQclear(self->results);
- self->results = NULL;
-}
-
-@end /* PGResultSet */
--- /dev/null
+/*
+ PGConnection.m
+
+ Copyright (C) 2004-2006 SKYRIX Software AG and Helge Hess
+
+ Author: Helge Hess (helge.hess@opengroupware.org)
+
+ This file is part of the PostgreSQL72 Adaptor Library
+
+ 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.
+*/
+
+#include "PGConnection.h"
+#include "common.h"
+#include <libpq-fe.h>
+#include "pgconfig.h"
+
+@implementation PGResultSet
+
+/* wraps PGresult */
+
+- (id)initWithConnection:(PGConnection *)_con handle:(void *)_handle {
+ if (_handle == NULL) {
+ [self release];
+ return nil;
+ }
+ if ((self = [super init])) {
+ self->connection = [_con retain];
+ self->results = _handle;
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [self clear];
+ [self->connection release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (BOOL)isValid {
+ return self->results != NULL ? YES : NO;
+}
+
+- (BOOL)containsBinaryTuples {
+#if NG_HAS_BINARY_TUPLES
+ if (self->results == NULL) return NO;
+ return PQbinaryTuples(self->results) ? YES : NO;
+#else
+ return NO;
+#endif
+}
+
+- (NSString *)commandStatus {
+ char *cstr;
+
+ if (self->results == NULL)
+ return nil;
+ if ((cstr = PQcmdStatus(self->results)) == NULL)
+ return nil;
+ return [self->connection _stringFromCString:cstr];
+}
+
+- (NSString *)commandTuples {
+ char *cstr;
+
+ if (self->results == NULL)
+ return nil;
+ if ((cstr = PQcmdTuples(self->results)) == NULL)
+ return nil;
+ return [self->connection _stringFromCString:cstr];
+}
+
+/* fields */
+
+- (unsigned)fieldCount {
+ return self->results != NULL ? PQnfields(self->results) : 0;
+}
+
+- (NSString *)fieldNameAtIndex:(unsigned int)_idx {
+ // TODO: charset
+ if (self->results == NULL) return nil;
+ return [self->connection _stringFromCString:PQfname(self->results, _idx)];
+}
+
+- (int)indexOfFieldNamed:(NSString *)_name {
+ return PQfnumber(self->results, [_name cString]);
+}
+
+- (int)fieldSizeAtIndex:(unsigned int)_idx {
+ if (self->results == NULL) return 0;
+ return PQfsize(self->results, _idx);
+}
+
+- (int)modifierAtIndex:(unsigned int)_idx {
+ if (self->results == NULL) return 0;
+#if NG_HAS_FMOD
+ return PQfmod(self->results, _idx);
+#else
+ return 0;
+#endif
+}
+
+/* tuples */
+
+- (unsigned int)tupleCount {
+ if (self->results == NULL) return 0;
+ return PQntuples(self->results);
+}
+
+- (BOOL)isNullTuple:(int)_tuple atIndex:(unsigned int)_idx {
+ if (self->results == NULL) return NO;
+ return PQgetisnull(self->results, _tuple, _idx) ? YES : NO;
+}
+
+- (void *)rawValueOfTuple:(int)_tuple atIndex:(unsigned int)_idx {
+ if (self->results == NULL) return NULL;
+ return PQgetvalue(self->results, _tuple, _idx);
+}
+
+- (int)lengthOfTuple:(int)_tuple atIndex:(unsigned int)_idx {
+ if (self->results == NULL) return 0;
+ return PQgetlength(self->results, _tuple, _idx);
+}
+
+/* operations */
+
+- (void)clear {
+ if (self->results == NULL) return;
+ PQclear(self->results);
+ self->results = NULL;
+}
+
+@end /* PGResultSet */
#import "EOAttribute+PostgreSQL72.h"
#include "PGConnection.h"
+#include "pgconfig.h"
+
#ifndef MIN
# define MIN(x, y) ((x > y) ? y : x)
#endif
-#if PG_MAJOR_VERSION >= 6 && PG_MINOR_VERSION > 3
-# define NG_HAS_NOTICE_PROCESSOR 1
-# define NG_HAS_BINARY_TUPLES 1
-# define NG_HAS_FMOD 1
-#endif
-
-#if PG_MAJOR_VERSION >= 7 && PG_MINOR_VERSION > 3
-# define NG_SET_CLIENT_ENCODING 1
-#endif
-
+// TODO: what does this do?
#define MAX_CHAR_BUF 16384
@interface PostgreSQL72Channel(Privates)
@implementation PostgreSQL72Channel
#if NG_SET_CLIENT_ENCODING
-static NSString *PGClientEncoding = @"Latin1";
+static NSString *PGClientEncoding = @"UTF8";
#endif
static int MaxOpenConnectionCount = -1;
static BOOL debugOn = NO;
static void _pgMessageProcessor(void *_channel, const char *_msg) {
[(id)_channel receivedMessage:
- _msg ? [StringClass stringWithCString:_msg] : nil];
+ _msg ? [StringClass stringWithUTF8String:_msg] : nil];
}
/* cleanup */
- (NSArray *)describeResults:(BOOL)_beautifyNames {
int cnt;
- NSMutableArray *result = nil;
- NSMutableDictionary *usedNames = nil;
+ NSMutableArray *result;
+ NSMutableDictionary *usedNames;
if (![self isFetchInProgress]) {
[PostgreSQL72Exception raise:@"NoFetchInProgress"
result = [[NSMutableArray alloc] initWithCapacity:self->fieldCount];
usedNames = [[MDictClass alloc] initWithCapacity:self->fieldCount];
-
+
for (cnt = 0; cnt < self->fieldCount; cnt++) {
EOAttribute *attribute = nil;
NSString *columnName;
NSString *attrName;
columnName =
- [[StringClass alloc] initWithCString:self->fieldInfo[cnt].name];
+ [[StringClass alloc] initWithUTF8String:self->fieldInfo[cnt].name];
+
attrName = _beautifyNames
? [columnName _pgModelMakeInstanceVarName]
: columnName;
sprintf(buf, "%i", cnt2);
- s = [[StringClass alloc] initWithCString:buf];
+ s = [[StringClass alloc] initWithUTF8String:buf];
newAttrName = [attrName stringByAppendingString:s];
[s release]; s= nil;
@end /* PostgreSQL72DataTypeMappingException */
-@implementation NSNull(PostgreSQL72Values)
-
-- (NSString *)stringValueForPostgreSQLType:(NSString *)_type
- attribute:(EOAttribute *)_attribute
-{
- return @"null";
-}
-
-@end /* NSNull(PostgreSQL72Values) */
-
void __link_PostgreSQL72Values() {
// used to force linking of object file
/*
PostgreSQL72Expression.m
- Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
+ Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
+ Copyright (C) 2000-2006 SKYRIX Software AG and Helge Hess
+
+ Author: Helge Hess (helge@opengroupware.org)
- Author: Helge Hess (helge@mdlink.de)
-
- This file is part of the PostgreSQL72 Adaptor Library
+ This file is part of the PostgreSQL Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
NSEnumerator *enumerator;
BOOL first = YES;
id key;
-
- fromClause = [NSMutableString stringWithCString:" "];
+
+ fromClause = [NSMutableString stringWithCapacity:64];
enumerator = [fromListEntities objectEnumerator];
+
+ [fromClause appendString:@" "];
// Compute the FROM list from all the aliases found in
// entitiesAndPropertiesAliases dictionary. Note that this dictionary
// contains entities and relationships. The last ones are there for
// flattened attributes over reflexive relationships.
- while((key = [enumerator nextObject])) {
+ while ((key = [enumerator nextObject]) != nil) {
if(first) first = NO;
else [fromClause appendString:@", "];
-
- [fromClause appendFormat:@"%@ %@",
+
+ [fromClause appendString:
[key isKindOfClass:[EORelationship class]]
- ? [[key destinationEntity] externalName] // flattened attribute
- : [key externalName], // EOEntity
- [entitiesAndPropertiesAliases objectForKey:key]];
+ ? [[key destinationEntity] externalName]
+ // flattened attribute
+ : [key externalName]];
+ // EOEntity
+
+ [fromClause appendString:@" "];
+ [fromClause appendString:
+ [[entitiesAndPropertiesAliases objectForKey:key] stringValue]];
#if 0
if (lock) [fromClause appendString:@" HOLDLOCK"];
# version file
-SUBMINOR_VERSION:=47
+SUBMINOR_VERSION:=48
# v4.5.41 requires libGDLAccess v4.5.50
--- /dev/null
+/*
+ PostgreSQL72Channel.m
+
+ Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
+ Copyright (C) 2000-2006 SKYRIX Software AG and Helge Hess
+
+ Author: Helge Hess (helge.hess@opengroupware.org)
+
+ This file is part of the PostgreSQL Adaptor Library
+
+ 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.
+*/
+
+#ifndef PG_MAJOR_VERSION
+/* PostgreSQL 7.4 and up do not have those versioning checks */
+
+
+#define NG_HAS_NOTICE_PROCESSOR 1
+#define NG_HAS_BINARY_TUPLES 1
+#define NG_HAS_FMOD 1
+#define NG_SET_CLIENT_ENCODING 1
+
+
+#else /* PG_MAJOR_VERSION processing */
+
+
+#if PG_MAJOR_VERSION >= 6 && PG_MINOR_VERSION > 3
+# define NG_HAS_NOTICE_PROCESSOR 1
+# define NG_HAS_BINARY_TUPLES 1
+# define NG_HAS_FMOD 1
+#endif
+
+#if PG_MAJOR_VERSION >= 7 && PG_MINOR_VERSION > 3
+# define NG_SET_CLIENT_ENCODING 1
+#endif
+
+
+#endif /* PG_MAJOR_VERSION processing */