/*
- EOAttribute+SQLite.h
+ EOAttribute+MySQL4.h
Copyright (C) 2003-2004 Helge Hess
Author: Helge Hess (helge.hess@opengroupware.org)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite_EOAttribute_H___
-#define ___SQLite_EOAttribute_H___
+#ifndef ___MySQL4_EOAttribute_H___
+#define ___MySQL4_EOAttribute_H___
#import <GDLAccess/EOAttribute.h>
#include <sqlite3.h>
@class NSString;
-@interface EOAttribute(SQLiteAttributeAdditions)
+@interface EOAttribute(MySQL4AttributeAdditions)
-- (void)loadValueClassAndTypeUsingSQLiteType:(int)_type
+- (void)loadValueClassAndTypeUsingMySQL4Type:(int)_type
size:(int)_size
modification:(int)_modification
binary:(BOOL)_isBinary;
-- (void)loadValueClassForExternalSQLiteType:(NSString *)_type;
+- (void)loadValueClassForExternalMySQL4Type:(NSString *)_type;
@end
-#endif /* ___SQLite_EOAttribute_H___ */
+#endif /* ___MySQL4_EOAttribute_H___ */
/*
- EOAttribute+SQLite.m
+ EOAttribute+MySQL4.m
Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
Author: Helge Hess (helge@mdlink.de)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
*/
#include "common.h"
-#import "EOAttribute+SQLite.h"
+#import "EOAttribute+MySQL4.h"
static NSString *SQLITE3_DATETIME_FORMAT = @"%b %d %Y %I:%M:%S:000%p";
static NSString *SQLITE3_TIMESTAMP_FORMAT = @"%Y-%m-%d %H:%M:%S%z";
-@implementation EOAttribute(SQLiteAttributeAdditions)
+@implementation EOAttribute(MySQL4AttributeAdditions)
-- (void)loadValueClassAndTypeUsingSQLiteType:(int)_type
+- (void)loadValueClassAndTypeUsingMySQL4Type:(int)_type
size:(int)_size
modification:(int)_modification
binary:(BOOL)_isBinary
{
- /* This method makes no sense with SQLite? */
+ /* This method makes no sense with MySQL4? */
if (_isBinary)
[self setValueClassName:@"NSData"];
#endif
}
-- (void)loadValueClassForExternalSQLiteType:(NSString *)_type {
+- (void)loadValueClassForExternalMySQL4Type:(NSString *)_type {
if ([_type isEqualToString:@"bool"]) {
[self setValueClassName:@"NSNumber"];
[self setValueType:@"i"];
NSLog(@"invalid argument %@", _type);
[NSException raise:@"InvalidArgumentException"
- format:@"invalid SQLite type %@ passed to %s",
+ format:@"invalid MySQL4 type %@ passed to %s",
_type, __PRETTY_FUNCTION__];
}
}
-@end /* EOAttribute(SQLite) */
+@end /* EOAttribute(MySQL4) */
-void __link_EOAttributeSQLite() {
+void __link_EOAttributeMySQL4() {
// used to force linking of object file
- __link_EOAttributeSQLite();
+ __link_EOAttributeMySQL4();
}
/*
- SQLiteAdaptor.h
+ MySQL4Adaptor.h
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite_Adaptor_H___
-#define ___SQLite_Adaptor_H___
+#ifndef ___MySQL4_Adaptor_H___
+#define ___MySQL4_Adaptor_H___
/*
- The SQLite adaptor.
+ The MySQL4 adaptor.
The connection dictionary of this adaptor understands these keys:
databaseName
@class NSString, NSMutableDictionary;
-@interface SQLiteAdaptor : EOAdaptor
+@interface MySQL4Adaptor : EOAdaptor
{
}
// classes used
-- (Class)adaptorContextClass; // SQLiteContext
-- (Class)adaptorChannelClass; // SQLiteChannel
-- (Class)expressionClass; // SQLiteExpression
+- (Class)adaptorContextClass; // MySQL4Context
+- (Class)adaptorChannelClass; // MySQL4Channel
+- (Class)expressionClass; // MySQL4Expression
@end
/*
- SQLiteAdaptor.m
+ MySQL4Adaptor.m
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
*/
#import "common.h"
-#import "SQLiteAdaptor.h"
-#import "SQLiteContext.h"
-#import "SQLiteChannel.h"
-#import "SQLiteExpression.h"
-#import "SQLiteValues.h"
+#import "MySQL4Adaptor.h"
+#import "MySQL4Context.h"
+#import "MySQL4Channel.h"
+#import "MySQL4Expression.h"
+#import "MySQL4Values.h"
-@implementation SQLiteAdaptor
+@implementation MySQL4Adaptor
- (NSDictionary *)connectionDictionaryForNSURL:(NSURL *)_url {
/*
"Database URLs"
We use the schema:
- SQLite3://localhost/dbpath/foldername
+ MySQL43://localhost/dbpath/foldername
*/
NSMutableDictionary *md;
NSString *p;
- (id)formatValue:(id)value forAttribute:(EOAttribute *)attribute {
NSString *result;
- result = [value stringValueForSQLite3Type:[attribute externalType]
+ result = [value stringValueForMySQL43Type:[attribute externalType]
attribute:attribute];
//NSLog(@"formatting value %@ result %@", value, result);
/* adaptor info */
- (Class)adaptorContextClass {
- return [SQLiteContext class];
+ return [MySQL4Context class];
}
- (Class)adaptorChannelClass {
- return [SQLiteChannel class];
+ return [MySQL4Channel class];
}
- (Class)expressionClass {
- return [SQLiteExpression class];
+ return [MySQL4Expression class];
}
-@end /* SQLiteAdaptor */
+@end /* MySQL4Adaptor */
-void __linkSQLiteAdaptor(void) {
- extern void __link_EOAttributeSQLite();
- extern void __link_NSStringSQLite();
- extern void __link_SQLiteChannelModel();
- extern void __link_SQLiteValues();
+void __linkMySQL4Adaptor(void) {
+ extern void __link_EOAttributeMySQL4();
+ extern void __link_NSStringMySQL4();
+ extern void __link_MySQL4ChannelModel();
+ extern void __link_MySQL4Values();
;
- [SQLiteChannel class];
- [SQLiteContext class];
- [SQLiteException class];
- [SQLiteExpression class];
- __link_EOAttributeSQLite();
- __link_NSStringSQLite();
- //__link_SQLiteChannelModel();
- __link_SQLiteValues();
- __linkSQLiteAdaptor();
+ [MySQL4Channel class];
+ [MySQL4Context class];
+ [MySQL4Exception class];
+ [MySQL4Expression class];
+ __link_EOAttributeMySQL4();
+ __link_NSStringMySQL4();
+ //__link_MySQL4ChannelModel();
+ __link_MySQL4Values();
+ __linkMySQL4Adaptor();
}
/*
- SQLiteChannel+Model.h
+ MySQL4Channel+Model.h
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite_ModelFetching_H___
-#define ___SQLite_ModelFetching_H___
+#ifndef ___MySQL4_ModelFetching_H___
+#define ___MySQL4_ModelFetching_H___
-#import "SQLiteChannel.h"
+#import "MySQL4Channel.h"
@class NSArray;
@class EOModel;
-@interface SQLiteChannel(ModelFetching)
+@interface MySQL4Channel(ModelFetching)
- (EOModel *)describeModelWithTableNames:(NSArray *)_tableNames;
- (NSArray *)describeTableNames;
/*
- SQLiteChannel+Model.m
+ MySQL4Channel+Model.m
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include "SQLiteChannel.h"
-#include "NSString+SQLite.h"
-#include "EOAttribute+SQLite.h"
+#include "MySQL4Channel.h"
+#include "NSString+MySQL4.h"
+#include "EOAttribute+MySQL4.h"
#include "common.h"
@interface EORelationship(FixMe)
- (void)addJoin:(id)_join;
@end
-@implementation SQLiteChannel(ModelFetching)
+@implementation MySQL4Channel(ModelFetching)
- (NSArray *)_attributesForTableName:(NSString *)_tableName {
NSMutableArray *attributes;
if (attributes == nil) {
#if 1
// TODO: we would need to parse the SQL field of 'sqlite_master'?
- NSLog(@"ERROR(%s): operation not supported on SQLite!",
+ NSLog(@"ERROR(%s): operation not supported on MySQL4!",
__PRETTY_FUNCTION__);
return nil;
#else
[attribute setColumnName:columnName];
[attribute setName:attrName];
[attribute setExternalType:externalType];
- [attribute loadValueClassForExternalSQLiteType:externalType];
+ [attribute loadValueClassForExternalMySQL4Type:externalType];
[attributes addObject:attribute];
[attribute release];
}
if ([_tableName length] == 0)
return nil;
- NSLog(@"ERROR(%s): operation not supported on SQLite!", __PRETTY_FUNCTION__);
+ NSLog(@"ERROR(%s): operation not supported on MySQL4!", __PRETTY_FUNCTION__);
return nil;
}
}
}
*/
- [model setAdaptorName:@"SQLite"];
- [model setAdaptorClassName:@"SQLiteAdaptor"];
+ [model setAdaptorName:@"MySQL4"];
+ [model setAdaptorClassName:@"MySQL4Adaptor"];
[model setConnectionDictionary:
[[adaptorContext adaptor] connectionDictionary]];
return tableNames;
}
-@end /* SQLiteChannel(ModelFetching) */
+@end /* MySQL4Channel(ModelFetching) */
-void __link_SQLiteChannelModel() {
+void __link_MySQL4ChannelModel() {
// used to force linking of object file
- __link_SQLiteChannelModel();
+ __link_MySQL4ChannelModel();
}
/*
- SQLiteChannel.h
+ MySQL4Channel.h
Copyright (C) 2003-2005 Helge Hess
Author: Helge Hess (helge.hess@opengroupware.org)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite_Channel_H___
-#define ___SQLite_Channel_H___
+#ifndef ___MySQL4_Channel_H___
+#define ___MySQL4_Channel_H___
#import <GDLAccess/EOAdaptorChannel.h>
#include <sqlite3.h>
@class NSArray, NSString, NSMutableDictionary;
-@interface SQLiteChannel : EOAdaptorChannel
+@interface MySQL4Channel : EOAdaptorChannel
{
// connection is valid after an openChannel call
void *_connection;
@interface NSObject(Sybase10ChannelDelegate)
-- (NSArray*)sqlite3Channel:(SQLiteChannel *)channel
+- (NSArray*)sqlite3Channel:(MySQL4Channel *)channel
willFetchAttributes:(NSArray *)attributes;
-- (BOOL)sqlite3Channel:(SQLiteChannel *)channel
+- (BOOL)sqlite3Channel:(MySQL4Channel *)channel
willReturnRow:(NSDictionary *)row;
@end
-#endif /* ___SQLite_Channel_H___ */
+#endif /* ___MySQL4_Channel_H___ */
/*
- SQLiteChannel.m
+ MySQL4Channel.m
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
#include <ctype.h>
#include <string.h>
#include <strings.h>
-#include "SQLiteChannel.h"
-#include "SQLiteAdaptor.h"
-#include "SQLiteException.h"
-#include "NSString+SQLite.h"
-#include "SQLiteValues.h"
-#include "EOAttribute+SQLite.h"
+#include "MySQL4Channel.h"
+#include "MySQL4Adaptor.h"
+#include "MySQL4Exception.h"
+#include "NSString+MySQL4.h"
+#include "MySQL4Values.h"
+#include "EOAttribute+MySQL4.h"
#include "common.h"
#ifndef MIN
#define MAX_CHAR_BUF 16384
-@implementation SQLiteChannel
+@implementation MySQL4Channel
static EONull *null = nil;
- (id)initWithAdaptorContext:(EOAdaptorContext*)_adaptorContext {
if ((self = [super initWithAdaptorContext:_adaptorContext])) {
[self setDebugEnabled:[[NSUserDefaults standardUserDefaults]
- boolForKey:@"SQLiteDebugEnabled"]];
+ boolForKey:@"MySQL4DebugEnabled"]];
self->_attributesForTableName =
[[NSMutableDictionary alloc] initWithCapacity:16];
MaxOpenConnectionCount =
[[NSUserDefaults standardUserDefaults]
- integerForKey:@"SQLiteMaxOpenConnectionCount"];
+ integerForKey:@"MySQL4MaxOpenConnectionCount"];
if (MaxOpenConnectionCount == 0)
MaxOpenConnectionCount = 15;
return MaxOpenConnectionCount;
- (BOOL)openChannel {
const unsigned char *cDBName;
- SQLiteAdaptor *adaptor;
+ MySQL4Adaptor *adaptor;
int rc;
if (self->_connection) {
return NO;
}
- adaptor = (SQLiteAdaptor *)[adaptorContext adaptor];
+ adaptor = (MySQL4Adaptor *)[adaptorContext adaptor];
if (![super openChannel])
return NO;
if (openConnectionCount > [self maxOpenConnectionCount]) {
- [SQLiteCouldNotOpenChannelException
+ [MySQL4CouldNotOpenChannelException
raise:@"NoMoreConnections"
format:@"cannot open a additional connection !"];
return NO;
if (rc != SQLITE_OK) {
// could not login ..
// Note: connection *is* set! (might be required to deallocate)
- NSLog(@"WARNING: could not open SQLite connection to database '%@': %s",
+ NSLog(@"WARNING: could not open MySQL4 connection to database '%@': %s",
[adaptor databaseName], sqlite3_errmsg(self->_connection));
sqlite3_close(self->_connection);
return NO;
}
if (isDebuggingEnabled)
- NSLog(@"SQLite connection established 0x%08X", self->_connection);
+ NSLog(@"MySQL4 connection established 0x%08X", self->_connection);
#if 0
NSLog(@"---------- %s: %@ opens channel count[%d]", __PRETTY_FUNCTION__,
#endif
if (isDebuggingEnabled) {
- NSLog(@"SQLite channel 0x%08X opened (connection=0x%08X,%s)",
+ NSLog(@"MySQL4 channel 0x%08X opened (connection=0x%08X,%s)",
(unsigned)self, self->_connection, cDBName);
}
return YES;
if (isDebuggingEnabled) {
fprintf(stderr,
- "SQLite connection dropped 0x%08X (channel=0x%08X)\n",
+ "MySQL4 connection dropped 0x%08X (channel=0x%08X)\n",
(unsigned)self->_connection, (unsigned)self);
}
self->_connection = NULL;
/* fetching rows */
-- (NSException *)_makeSQLiteStep {
+- (NSException *)_makeMySQL4Step {
NSString *r;
const char *em;
int rc;
if (rc == SQLITE_ERROR)
r = [NSString stringWithUTF8String:sqlite3_errmsg(self->_connection)];
else if (rc == SQLITE_MISUSE)
- r = @"The SQLite step function was called in an incorrect way";
+ r = @"The MySQL4 step function was called in an incorrect way";
else if (rc == SQLITE_BUSY)
- r = @"The SQLite is busy.";
+ r = @"The MySQL4 is busy.";
else
- r = [NSString stringWithFormat:@"Unexpected SQLite error: %i", rc];
+ r = [NSString stringWithFormat:@"Unexpected MySQL4 error: %i", rc];
if ((em = sqlite3_errmsg(self->_connection)) != NULL)
r = [r stringByAppendingFormat:@": %s", em];
- return [SQLiteException exceptionWithName:@"FetchFailed"
+ return [MySQL4Exception exceptionWithName:@"FetchFailed"
reason:r userInfo:nil];
}
yesObj = [NSNumber numberWithBool:YES];
if (![self isFetchInProgress]) {
- [SQLiteException raise:@"NoFetchInProgress"
+ [MySQL4Exception raise:@"NoFetchInProgress"
format:@"No fetch in progress (channel=%@)", self];
}
if (!self->hasPendingRow) {
NSException *error;
- if ((error = [self _makeSQLiteStep]) != nil) {
+ if ((error = [self _makeMySQL4Step]) != nil) {
[self cancelFetch];
[error raise]; // raise error, TODO: make exception-less method
return nil;
[attribute setValueClassName:@"NSData"];
break;
case SQLITE_NULL:
- NSLog(@"WARNING(%s): got SQLite NULL type at column %i, can't derive "
+ NSLog(@"WARNING(%s): got MySQL4 NULL type at column %i, can't derive "
@"type information.",
__PRETTY_FUNCTION__, cnt);
[attribute setExternalType:@"NULL"];
[attribute setValueClassName:@"NSNull"];
break;
default:
- NSLog(@"ERROR(%s): unexpected SQLite type at column %i",
+ NSLog(@"ERROR(%s): unexpected MySQL4 type at column %i",
__PRETTY_FUNCTION__, cnt);
break;
}
- (BOOL)isColumnNullInCurrentRow:(int)_column {
/*
- Note: NULL is SQLite is represented as empty strings ..., don't know
+ Note: NULL is MySQL4 is represented as empty strings ..., don't know
what to do about that?
At least Sybase 10 doesn't support empty strings strings as well
and converts them to a single space. So maybe it is reasonable to
}
if (!self->hasPendingRow && !self->isDone) {
- if ((error = [self _makeSQLiteStep]) != nil) {
+ if ((error = [self _makeMySQL4Step]) != nil) {
[self cancelFetch];
[error raise]; // raise error, TODO: make exception-less method
return nil;
switch (sqlite3_column_type(self->statement, cnt)) {
case SQLITE_INTEGER:
value = [[valueClass alloc]
- initWithSQLiteInt:sqlite3_column_int(self->statement, cnt)];
+ initWithMySQL4Int:sqlite3_column_int(self->statement, cnt)];
break;
case SQLITE_FLOAT:
value = [[valueClass alloc]
- initWithSQLiteDouble:
+ initWithMySQL4Double:
sqlite3_column_double(self->statement, cnt)];
break;
case SQLITE_TEXT:
value = [[valueClass alloc]
- initWithSQLiteText:
+ initWithMySQL4Text:
sqlite3_column_text(self->statement, cnt)];
break;
case SQLITE_BLOB:
value = [[valueClass alloc]
- initWithSQLiteData:
+ initWithMySQL4Data:
sqlite3_column_blob(self->statement, cnt)
length:sqlite3_column_bytes(self->statement, cnt)];
break;
value = [null retain];
break;
default:
- NSLog(@"ERROR(%s): unexpected SQLite type at column %i",
+ NSLog(@"ERROR(%s): unexpected MySQL4 type at column %i",
__PRETTY_FUNCTION__, cnt);
continue;
}
/* check some preconditions */
if (![self isOpen]) {
- return [SQLiteException exceptionWithName:@"ChannelNotOpenException"
- reason:@"SQLite connection is not open"
+ return [MySQL4Exception exceptionWithName:@"ChannelNotOpenException"
+ reason:@"MySQL4 connection is not open"
userInfo:nil];
}
if (self->statement != NULL) {
- return [SQLiteException exceptionWithName:@"CommandInProgressException"
+ return [MySQL4Exception exceptionWithName:@"CommandInProgressException"
reason:@"an evaluation is in progress"
userInfo:nil];
return NO;
r = [NSString stringWithFormat:@"could not parse SQL statement: %s",
sqlite3_errmsg(self->_connection)];
- return [SQLiteException exceptionWithName:@"ExecutionFailed"
+ return [MySQL4Exception exceptionWithName:@"ExecutionFailed"
reason:r userInfo:nil];
}
NSAssert(self->statement, @"missing statement");
}
else {
- if ((error = [self _makeSQLiteStep]) != nil) {
+ if ((error = [self _makeMySQL4Step]) != nil) {
[self cancelFetch];
return error;
}
return ms;
}
-@end /* SQLiteChannel */
+@end /* MySQL4Channel */
-@implementation SQLiteChannel(PrimaryKeyGeneration)
+@implementation MySQL4Channel(PrimaryKeyGeneration)
- (NSDictionary *)primaryKeyForNewRowWithEntity:(EOEntity *)_entity {
NSArray *pkeys;
- SQLiteAdaptor *adaptor;
+ MySQL4Adaptor *adaptor;
NSString *seqName, *seq;
NSDictionary *pkey;
if ([self evaluateExpression:seq]) {
id key = nil;
- NSLog(@"ERROR: new key creation is not implemented in SQLite yet!");
+ NSLog(@"ERROR: new key creation is not implemented in MySQL4 yet!");
if ([self isFetchInProgress]) {
NSLog(@"Primary key eval returned results ..");
}
return pkey;
}
-@end /* SQLiteChannel(PrimaryKeyGeneration) */
+@end /* MySQL4Channel(PrimaryKeyGeneration) */
-void __link_SQLiteChannel() {
+void __link_MySQL4Channel() {
// used to force linking of object file
- __link_SQLiteChannel();
+ __link_MySQL4Channel();
}
/*
- SQLiteContext.h
+ MySQL4Context.h
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite_Context_H___
-#define ___SQLite_Context_H___
+#ifndef ___MySQL4_Context_H___
+#define ___MySQL4_Context_H___
#import <GDLAccess/EOAdaptorContext.h>
-@interface SQLiteContext : EOAdaptorContext
+@interface MySQL4Context : EOAdaptorContext
- (BOOL)primaryBeginTransaction;
- (BOOL)primaryCommitTransaction;
/*
- SQLiteContext.m
+ MySQL4Context.m
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include "SQLiteContext.h"
-#include "SQLiteChannel.h"
+#include "MySQL4Context.h"
+#include "MySQL4Channel.h"
#include "common.h"
-@implementation SQLiteContext
+@implementation MySQL4Context
- (void)channelDidInit:_channel {
if ([channels count] > 0) {
[NSException raise:@"TooManyOpenChannelsException"
- format:@"SQLite3 only supports one channel per context"];
+ format:@"MySQL43 only supports one channel per context"];
}
[super channelDidInit:_channel];
}
return [self retain];
}
-@end /* SQLiteContext */
+@end /* MySQL4Context */
-void __link_SQLiteContext() {
+void __link_MySQL4Context() {
// used to force linking of object file
- __link_SQLiteContext();
+ __link_MySQL4Context();
}
/*
- SQLiteException.h
+ MySQL4Exception.h
Copyright (C) 1999-2005 MDlink online service center GmbH and Helge Hess
Author: Helge Hess (helge@mdlink.de)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite_Exception_H___
-#define ___SQLite_Exception_H___
+#ifndef ___MySQL4_Exception_H___
+#define ___MySQL4_Exception_H___
#import <Foundation/NSException.h>
-@interface SQLiteException : NSException
+@interface MySQL4Exception : NSException
{
}
@end
-@interface SQLiteCouldNotOpenChannelException : SQLiteException
+@interface MySQL4CouldNotOpenChannelException : MySQL4Exception
{
}
@end
-@interface SQLiteCouldNotConnectException : SQLiteCouldNotOpenChannelException
+@interface MySQL4CouldNotConnectException : MySQL4CouldNotOpenChannelException
{
}
@end
-@interface SQLiteCouldNotBindException : SQLiteException
+@interface MySQL4CouldNotBindException : MySQL4Exception
{
}
@end
-#endif /* ___SQLite_Exception_H___ */
+#endif /* ___MySQL4_Exception_H___ */
/*
- SQLiteException.m
+ MySQL4Exception.m
Copyright (C) 2003-2005 Helge Hess
Author: Helge Hess (helge.hess@opengroupware.org)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
*/
#import <GDLAccess/GDLAccess.h>
-#import "SQLiteException.h"
+#import "MySQL4Exception.h"
#include "common.h"
-@implementation SQLiteException
+@implementation MySQL4Exception
+ (void)raiseWithFormat:(NSString *)_format, ... {
NSString *tmp = nil;
@end
-@implementation SQLiteCouldNotOpenChannelException
+@implementation MySQL4CouldNotOpenChannelException
@end
-@implementation SQLiteCouldNotConnectException
+@implementation MySQL4CouldNotConnectException
@end
-@implementation SQLiteCouldNotBindException
+@implementation MySQL4CouldNotBindException
@end
-void __link_SQLiteException() {
+void __link_MySQL4Exception() {
// used to force linking of object file
- __link_SQLiteException();
+ __link_MySQL4Exception();
}
/*
- SQLiteExpression.h
+ MySQL4Expression.h
Copyright (C) 1999-2005 MDlink online service center GmbH and Helge Hess
Author: Helge Hess (helge@mdlink.de)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite3_SQLExpression_H___
-#define ___SQLite3_SQLExpression_H___
+#ifndef ___MySQL43_SQLExpression_H___
+#define ___MySQL43_SQLExpression_H___
#include <GDLAccess/EOSQLExpression.h>
@class NSString, NSArray;
@class EOSQLQualifier, EOAdaptorChannel;
-@interface SQLiteExpression : EOSQLExpression
+@interface MySQL4Expression : EOSQLExpression
+ (Class)selectExpressionClass;
@end
-@interface SQLiteSelectSQLExpression : EOSelectSQLExpression
+@interface MySQL4SelectSQLExpression : EOSelectSQLExpression
{
BOOL lock;
}
@end
-#endif /* ___SQLite3_SQLExpression_H___ */
+#endif /* ___MySQL43_SQLExpression_H___ */
/*
- SQLiteExpression.m
+ MySQL4Expression.m
Copyright (C) 2003-2005 Helge Hess
Author: Helge Hess (helge.hess@opengroupware.org)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
#include <Foundation/Foundation.h>
#include <GDLAccess/GDLAccess.h>
-#include "SQLiteExpression.h"
+#include "MySQL4Expression.h"
-@implementation SQLiteExpression
+@implementation MySQL4Expression
+ (Class)selectExpressionClass {
- return [SQLiteSelectSQLExpression class];
+ return [MySQL4SelectSQLExpression class];
}
-@end /* SQLiteExpression */
+@end /* MySQL4Expression */
-@implementation SQLiteSelectSQLExpression
+@implementation MySQL4SelectSQLExpression
- (id)selectExpressionForAttributes:(NSArray *)attributes
lock:(BOOL)flag
return fromClause;
}
-@end /* SQLiteSelectSQLExpression */
+@end /* MySQL4SelectSQLExpression */
-void __link_SQLiteExpression() {
+void __link_MySQL4Expression() {
// used to force linking of object file
- __link_SQLiteExpression();
+ __link_MySQL4Expression();
}
/*
- SQLiteValues.h
+ MySQL4Values.h
Copyright (C) 1999-2005 MDlink online service center GmbH and Helge Hess
Author: Helge Hess (helge@mdlink.de)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite_Values_H___
-#define ___SQLite_Values_H___
+#ifndef ___MySQL4_Values_H___
+#define ___MySQL4_Values_H___
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>
#import <Foundation/NSData.h>
#import <Foundation/NSDate.h>
#import <GDLAccess/EONull.h>
-#import "SQLiteException.h"
+#import "MySQL4Exception.h"
@class EOAttribute;
-@class SQLiteChannel;
+@class MySQL4Channel;
-@interface SQLiteDataTypeMappingException : SQLiteException
+@interface MySQL4DataTypeMappingException : MySQL4Exception
- (id)initWithObject:(id)_obj
forAttribute:(EOAttribute *)_attr
- andSQLite3Type:(NSString *)_dt
- inChannel:(SQLiteChannel *)_channel;
+ andMySQL43Type:(NSString *)_dt
+ inChannel:(MySQL4Channel *)_channel;
@end
-@protocol SQLiteValues
+@protocol MySQL4Values
-- (NSString *)stringValueForSQLite3Type:(NSString *)_type
+- (NSString *)stringValueForMySQL43Type:(NSString *)_type
attribute:(EOAttribute *)_attribute;
@end
-@interface NSObject(SQLiteValues)
+@interface NSObject(MySQL4Values)
-- (id)initWithSQLiteInt:(int)_value;
-- (id)initWithSQLiteText:(const unsigned char *)_value;
-- (id)initWithSQLiteDouble:(double)_value;
-- (id)initWithSQLiteData:(const void *)_data length:(int)_length;
+- (id)initWithMySQL4Int:(int)_value;
+- (id)initWithMySQL4Text:(const unsigned char *)_value;
+- (id)initWithMySQL4Double:(double)_value;
+- (id)initWithMySQL4Data:(const void *)_data length:(int)_length;
@end
-@interface NSString(SQLiteValues) < SQLiteValues >
+@interface NSString(MySQL4Values) < MySQL4Values >
@end
-@interface NSNumber(SQLiteValues) < SQLiteValues >
+@interface NSNumber(MySQL4Values) < MySQL4Values >
@end
-@interface NSData(SQLiteValues) < SQLiteValues >
+@interface NSData(MySQL4Values) < MySQL4Values >
@end
-@interface NSCalendarDate(SQLiteValues) < SQLiteValues >
+@interface NSCalendarDate(MySQL4Values) < MySQL4Values >
@end
-@interface EONull(SQLiteValues)
+@interface EONull(MySQL4Values)
-- (NSString *)stringValueForSQLite3Type:(NSString *)_type
+- (NSString *)stringValueForMySQL43Type:(NSString *)_type
attribute:(EOAttribute *)_attribute;
@end
-#endif /* ___SQLite_Values_H___ */
+#endif /* ___MySQL4_Values_H___ */
/*
- SQLiteValues.m
+ MySQL4Values.m
Copyright (C) 1999-2005 MDlink online service center GmbH and Helge Hess
Author: Helge Hess (helge@mdlink.de)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#import "SQLiteValues.h"
+#import "MySQL4Values.h"
#import "common.h"
-@implementation SQLiteDataTypeMappingException
+@implementation MySQL4DataTypeMappingException
- (id)initWithObject:(id)_obj
forAttribute:(EOAttribute *)_attr
- andSQLite3Type:(NSString *)_dt
- inChannel:(SQLiteChannel *)_channel;
+ andMySQL43Type:(NSString *)_dt
+ inChannel:(MySQL4Channel *)_channel;
{
NSDictionary *ui;
NSString *typeName = nil;
r = [NSString stringWithFormat:
@"mapping between %@<Class:%@> and "
- @"SQLite type %@ is not supported",
+ @"MySQL4 type %@ is not supported",
[_obj description],
NSStringFromClass([_obj class]),
typeName];
userInfo:ui];
}
-@end /* SQLiteDataTypeMappingException */
+@end /* MySQL4DataTypeMappingException */
-@implementation NSNull(SQLiteValues)
+@implementation NSNull(MySQL4Values)
-- (NSString *)stringValueForSQLite3Type:(NSString *)_type
+- (NSString *)stringValueForMySQL43Type:(NSString *)_type
attribute:(EOAttribute *)_attribute
{
return @"null";
}
-@end /* NSNull(SQLiteValues) */
+@end /* NSNull(MySQL4Values) */
-@implementation NSObject(SQLiteValues)
+@implementation NSObject(MySQL4Values)
-- (id)initWithSQLiteInt:(int)_value {
+- (id)initWithMySQL4Int:(int)_value {
if ([self respondsToSelector:@selector(initWithInt:)])
return [(NSNumber *)self initWithInt:_value];
return nil;
}
-- (id)initWithSQLiteDouble:(double)_value {
+- (id)initWithMySQL4Double:(double)_value {
if ([self respondsToSelector:@selector(initWithDouble:)])
return [(NSNumber *)self initWithDouble:_value];
return nil;
}
-- (id)initWithSQLiteText:(const unsigned char *)_value {
+- (id)initWithMySQL4Text:(const unsigned char *)_value {
if ([self respondsToSelector:@selector(initWithString:)]) {
NSString *s;
return nil;
}
-- (id)initWithSQLiteData:(const void *)_data length:(int)_length {
+- (id)initWithMySQL4Data:(const void *)_data length:(int)_length {
if ([self respondsToSelector:@selector(initWithBytes:length:)])
return [(NSData *)self initWithBytes:_data length:_length];
return nil;
}
-@end /* NSObject(SQLiteValues) */
+@end /* NSObject(MySQL4Values) */
-void __link_SQLiteValues() {
+void __link_MySQL4Values() {
// used to force linking of object file
- __link_SQLiteValues();
+ __link_MySQL4Values();
}
/*
- NSCalendarDate+SQLiteVal.m
+ NSCalendarDate+MySQL4Val.m
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
#import <Foundation/NSString.h>
-#include "SQLiteChannel.h"
+#include "MySQL4Channel.h"
#include "common.h"
#if COCOA_Foundation_LIBRARY || NeXT_Foundation_LIBRARY
static NSString *SQLITE3_DATETIME_FORMAT = @"%b %d %Y %I:%M:%S:000%p";
-@implementation NSCalendarDate(SQLiteValues)
+@implementation NSCalendarDate(MySQL4Values)
/*
Format: '2001-07-26 14:00:00+02'
static NSTimeZone *gmt01 = nil;
static NSTimeZone *gmt02 = nil;
-- (id)initWithSQLiteData:(const void *)_value length:(int)_length {
+- (id)initWithMySQL4Data:(const void *)_value length:(int)_length {
static unsigned char buf[28]; // reused buffer, THREAD
const char *_cstr = _value;
unsigned char *p;
return date;
}
-- (id)initWithSQLiteDouble:(double)_value {
+- (id)initWithMySQL4Double:(double)_value {
return [self initWithTimeIntervalSince1970:_value];
}
-- (id)initWithSQLiteInt:(int)_value {
- return [self initWithSQLiteDouble:_value];
+- (id)initWithMySQL4Int:(int)_value {
+ return [self initWithMySQL4Double:_value];
}
-- (id)initWithSQLiteText:(const unsigned char *)_value {
- return [self initWithSQLiteData:_value length:strlen(_value)];
+- (id)initWithMySQL4Text:(const unsigned char *)_value {
+ return [self initWithMySQL4Data:_value length:strlen(_value)];
}
/* generating value */
-- (NSString *)stringValueForSQLite3Type:(NSString *)_type
+- (NSString *)stringValueForMySQL43Type:(NSString *)_type
attribute:(EOAttribute *)_attribute
{
#if 0
if ((serverTimeZone = [_attribute serverTimeZone]) == nil ) {
if (DefServerTimezone == nil) {
DefServerTimezone = [[NSTimeZone localTimeZone] retain];
- NSLog(@"Note: SQLite adaptor using timezone '%@' as default",
+ NSLog(@"Note: MySQL4 adaptor using timezone '%@' as default",
DefServerTimezone);
}
serverTimeZone = DefServerTimezone;
return [val autorelease];
}
-@end /* NSCalendarDate(SQLiteValues) */
+@end /* NSCalendarDate(MySQL4Values) */
/*
- NSData+SQLiteVal.m
+ NSData+MySQL4Val.m
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include "SQLiteValues.h"
-#include "SQLiteChannel.h"
+#include "MySQL4Values.h"
+#include "MySQL4Channel.h"
#import <Foundation/NSData.h>
#include "common.h"
-@implementation NSData(SQLiteValues)
+@implementation NSData(MySQL4Values)
-- (id)initWithSQLiteInt:(int)_value {
+- (id)initWithMySQL4Int:(int)_value {
return [self initWithBytes:&_value length:sizeof(int)];
}
-- (id)initWithSQLiteDouble:(double)_value {
+- (id)initWithMySQL4Double:(double)_value {
return [self initWithBytes:&_value length:sizeof(double)];
}
-- (id)initWithSQLiteText:(const unsigned char *)_value {
+- (id)initWithMySQL4Text:(const unsigned char *)_value {
return [self initWithBytes:_value length:strlen(_value)];
}
-- (id)initWithSQLiteData:(const void *)_value length:(int)_length {
+- (id)initWithMySQL4Data:(const void *)_value length:(int)_length {
return [self initWithBytes:_value length:_length];
}
-- (NSString *)stringValueForSQLite3Type:(NSString *)_type
+- (NSString *)stringValueForMySQL43Type:(NSString *)_type
attribute:(EOAttribute *)_attribute
{
// TODO: UNICODE
if (enc == 0) {
enc = [NSString defaultCStringEncoding];
- NSLog(@"Note: SQLite adaptor using '%@' encoding for data=>string "
+ NSLog(@"Note: MySQL4 adaptor using '%@' encoding for data=>string "
@"conversion.",
[NSString localizedNameOfStringEncoding:enc]);
}
[t hasPrefix:@"varchar"] ||
[t hasPrefix:@"money"] ||
[t hasPrefix:@"text"]) {
- t = [[str stringValueForSQLite3Type:_type
+ t = [[str stringValueForMySQL43Type:_type
attribute:_attribute] retain];
[str release];
return [t autorelease];
return [str autorelease];;
}
-@end /* NSData(SQLiteValues) */
+@end /* NSData(MySQL4Values) */
/*
- SQLiteAdaptor.h
+ MySQL4Adaptor.h
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
*/
#import <Foundation/NSString.h>
-#include "SQLiteChannel.h"
+#include "MySQL4Channel.h"
#include "common.h"
-@implementation NSNumber(SQLiteValues)
+@implementation NSNumber(MySQL4Values)
-- (id)initWithSQLiteInt:(int)_value {
+- (id)initWithMySQL4Int:(int)_value {
return [self initWithInt:_value];
}
-- (id)initWithSQLiteDouble:(double)_value {
+- (id)initWithMySQL4Double:(double)_value {
return [self initWithDouble:_value];
}
-- (id)initWithSQLiteText:(const unsigned char *)_value {
+- (id)initWithMySQL4Text:(const unsigned char *)_value {
return index(_value, '.') != NULL
? [self initWithDouble:atof(_value)]
: [self initWithInt:atoi(_value)];
}
-- (id)initWithSQLiteData:(const void *)_value length:(int)_length {
+- (id)initWithMySQL4Data:(const void *)_value length:(int)_length {
switch (_length) {
case 1: return [self initWithUnsignedChar:*(char *)_value];
case 2: return [self initWithShort:*(short *)_value];
return nil;
}
-- (NSString *)stringValueForSQLite3Type:(NSString *)_type
+- (NSString *)stringValueForMySQL43Type:(NSString *)_type
attribute:(EOAttribute *)_attribute
{
// TODO: can we avoid the lowercaseString?
return [self stringValue];
}
-@end /* NSNumber(SQLiteValues) */
+@end /* NSNumber(MySQL4Values) */
/*
- NSString+SQLite.h
+ NSString+MySQL4.h
Copyright (C) 1999-2005 MDlink online service center GmbH and Helge Hess
Author: Helge Hess (helge@mdlink.de)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite_NSString_H___
-#define ___SQLite_NSString_H___
+#ifndef ___MySQL4_NSString_H___
+#define ___MySQL4_NSString_H___
#import <Foundation/NSString.h>
-@interface NSString(SQLiteMiscStrings)
+@interface NSString(MySQL4MiscStrings)
- (NSString *)_sqlite3ModelMakeInstanceVarName;
- (NSString *)_sqlite3ModelMakeClassName;
@end
-#endif /* ___SQLite_NSString_H___ */
+#endif /* ___MySQL4_NSString_H___ */
/*
- NSString+SQLite.m
+ NSString+MySQL4.m
Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
Author: Helge Hess (helge@mdlink.de)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-// $Id: NSString+SQLite.m,v 1.1 2004/06/14 14:27:44 helge Exp $
+// $Id: NSString+MySQL4.m,v 1.1 2004/06/14 14:27:44 helge Exp $
#if LIB_FOUNDATION_BOEHM_GC
# include <objc/gc.h>
#import <objc/objc-api.h>
#include "common.h"
-#import "NSString+SQLite.h"
+#import "NSString+MySQL4.h"
-@implementation NSString(SQLiteMiscStrings)
+@implementation NSString(MySQL4MiscStrings)
- (NSString *)_sqlite3ModelMakeInstanceVarName {
if ([self length] == 0)
@end
-void __link_NSStringSQLite() {
+void __link_NSStringMySQL4() {
// used to force linking of object file
- __link_NSStringSQLite();
+ __link_NSStringMySQL4();
}
/*
- SQLiteAdaptor.h
+ MySQL4Adaptor.h
Copyright (C) 2003-2005 SKYRIX Software AG
Author: Helge Hess (helge.hess@skyrix.com)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include "SQLiteChannel.h"
+#include "MySQL4Channel.h"
#include <NGExtensions/NSString+Ext.h>
#import <Foundation/NSString.h>
#include "common.h"
-@implementation NSString(SQLiteValues)
+@implementation NSString(MySQL4Values)
static Class EOExprClass = Nil;
-- (id)initWithSQLiteInt:(int)_value {
+- (id)initWithMySQL4Int:(int)_value {
char buf[256];
sprintf(buf, "%i", _value);
return [self initWithCString:buf];
}
-- (id)initWithSQLiteDouble:(double)_value {
+- (id)initWithMySQL4Double:(double)_value {
char buf[256];
sprintf(buf, "%g", _value);
return [self initWithCString:buf];
}
-- (id)initWithSQLiteText:(const unsigned char *)_value {
+- (id)initWithMySQL4Text:(const unsigned char *)_value {
return [self initWithUTF8String:_value];
}
-- (id)initWithSQLiteData:(const void *)_value length:(int)_length {
+- (id)initWithMySQL4Data:(const void *)_value length:(int)_length {
NSData *d;
d = [[NSData alloc] initWithBytes:_value length:_length];
/* generate SQL value */
-- (NSString *)stringValueForSQLite3Type:(NSString *)_type
+- (NSString *)stringValueForMySQL43Type:(NSString *)_type
attribute:(EOAttribute *)_attribute
{
// TODO: all this looks slow ...
return self;
}
-@end /* NSString(SQLiteValues) */
+@end /* NSString(MySQL4Values) */
Author: Helge Hess (helge@mdlink.de)
- This file is part of the SQLite3 Adaptor Library
+ This file is part of the MySQL43 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ___SQLite3_common_H___
-#define ___SQLite3_common_H___
+#ifndef ___MySQL43_common_H___
+#define ___MySQL43_common_H___
#import <objc/objc-api.h>
#include <GDLAccess/GDLAccess.h>
#include <NGExtensions/NGExtensions.h>
-#endif /* ___SQLite3_common_H___ */
+#endif /* ___MySQL43_common_H___ */
Author: Helge Hess (helge@mdlink.de)
- This file is part of the SQLite Adaptor Library
+ This file is part of the MySQL4 Adaptor Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
conDict = [NSDictionary dictionaryWithContentsOfFile:@"condict.plist"];
NSLog(@"condict is %@", conDict);
- if ((a = [EOAdaptor adaptorWithName:@"SQLite3"]) == nil) {
- NSLog(@"found no SQLite3 adaptor ..");
+ if ((a = [EOAdaptor adaptorWithName:@"MySQL43"]) == nil) {
+ NSLog(@"found no MySQL43 adaptor ..");
exit(1);
}