mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-04-21 13:21:03 +00:00
Compare commits
1 commit
master
...
sqlclient-
Author | SHA1 | Date | |
---|---|---|---|
|
9e470b6ba5 |
24 changed files with 10227 additions and 13616 deletions
302
ECPG.pgm
302
ECPG.pgm
|
@ -40,9 +40,6 @@
|
|||
#include <Foundation/NSAutoreleasePool.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
|
||||
@interface SQLClientECPG : SQLClient
|
||||
|
@ -111,18 +108,18 @@ void SQLErrorHandler()
|
|||
const char *e1 = "Error in transaction processing";
|
||||
|
||||
sqlca.sqlcode = 0; // Reset error code
|
||||
NSLog (@"Raising an exception, %d, %s", code, sqlca.sqlerrm.sqlerrmc);
|
||||
NSLog (@"Raising an exception, %ld, %s", code, sqlca.sqlerrm.sqlerrmc);
|
||||
|
||||
if (strncmp(ptr, e0, strlen(e0)) == 0
|
||||
|| strncmp(ptr, e1, strlen(e1)) == 0)
|
||||
{
|
||||
[NSException raise: SQLConnectionException
|
||||
format: @"SQL Error: SQLCODE=(%d): %s", code, ptr];
|
||||
format: @"SQL Error: SQLCODE=(%ld): %s", code, ptr];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"SQL Error: SQLCODE=(%d): %s", code, ptr];
|
||||
format: @"SQL Error: SQLCODE=(%ld): %s", code, ptr];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +134,7 @@ static NSDate *future = nil;
|
|||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
[future retain];
|
||||
RETAIN(future);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,20 +245,20 @@ static NSDate *future = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char *statement;
|
||||
char *handle;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
unsigned int length;
|
||||
NSString *stmt = [info objectAtIndex: 0];
|
||||
|
||||
length = [stmt length];
|
||||
if (length == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -279,9 +276,9 @@ static NSDate *future = nil;
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
[self name], stmt];
|
||||
|
@ -299,7 +296,7 @@ static NSDate *future = nil;
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
/*
|
||||
* remove line number information from database exception message
|
||||
|
@ -325,14 +322,13 @@ static NSDate *future = nil;
|
|||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return -1;
|
||||
DESTROY(arp);
|
||||
}
|
||||
|
||||
static unsigned int trim(char *str)
|
||||
|
@ -383,7 +379,7 @@ static unsigned int trim(char *str)
|
|||
char *query;
|
||||
char *handle;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSMutableArray *records;
|
||||
BOOL isOpen = NO;
|
||||
BOOL localTransaction = NO;
|
||||
|
@ -391,7 +387,7 @@ static unsigned int trim(char *str)
|
|||
length = [stmt length];
|
||||
if (length == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -403,9 +399,9 @@ static unsigned int trim(char *str)
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
[self name], stmt];
|
||||
|
@ -557,10 +553,7 @@ static unsigned int trim(char *str)
|
|||
case SQL3_CHARACTER_VARYING:
|
||||
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
|
||||
:aString = DATA;
|
||||
if (_shouldTrim)
|
||||
{
|
||||
trim(aString);
|
||||
}
|
||||
trim(aString);
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free(aString);
|
||||
break;
|
||||
|
@ -589,10 +582,7 @@ static unsigned int trim(char *str)
|
|||
default:
|
||||
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
|
||||
:aString = DATA;
|
||||
if (_shouldTrim)
|
||||
{
|
||||
trim(aString);
|
||||
}
|
||||
trim(aString);
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free(aString);
|
||||
if ([self debugging] > 0)
|
||||
|
@ -613,7 +603,7 @@ static unsigned int trim(char *str)
|
|||
keys: keys
|
||||
count: count];
|
||||
[records addObject: record];
|
||||
[record release];
|
||||
RELEASE(record);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -631,8 +621,7 @@ static unsigned int trim(char *str)
|
|||
NSString *n = [localException name];
|
||||
NSString *msg = [localException reason];
|
||||
|
||||
[records release];
|
||||
records = nil;
|
||||
DESTROY(records);
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
|
@ -651,14 +640,14 @@ static unsigned int trim(char *str)
|
|||
|
||||
if ([e isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -680,15 +669,15 @@ static unsigned int trim(char *str)
|
|||
userInfo: nil];
|
||||
}
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN(localException);
|
||||
RELEASE(arp);
|
||||
AUTORELEASE(localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
DESTROY(arp);
|
||||
|
||||
return [records autorelease];
|
||||
return AUTORELEASE(records);
|
||||
}
|
||||
|
||||
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
|
||||
|
@ -946,13 +935,9 @@ static unsigned int trim(char *str)
|
|||
|
||||
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l
|
||||
{
|
||||
char buf[l+32]; /* Allow space to expand buffer. */
|
||||
NSCalendarDate *d;
|
||||
BOOL milliseconds = NO;
|
||||
BOOL timezone = NO;
|
||||
NSString *s;
|
||||
int i;
|
||||
int e;
|
||||
char buf[l+32]; /* Allow space to expend buffer. */
|
||||
NSString *s;
|
||||
int i;
|
||||
|
||||
memcpy(buf, b, l);
|
||||
b = buf;
|
||||
|
@ -975,153 +960,98 @@ static unsigned int trim(char *str)
|
|||
|
||||
if (l == 10)
|
||||
{
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d"
|
||||
locale: nil];
|
||||
}
|
||||
|
||||
i = l;
|
||||
|
||||
/* Convert +/-HH:SS timezone to +/-HHSS
|
||||
*/
|
||||
if (i > 5 && b[i-3] == ':' && (b[i-6] == '+' || b[i-6] == '-'))
|
||||
{
|
||||
b[i-3] = b[i-2];
|
||||
b[i-2] = b[i-1];
|
||||
b[--i] = '\0';
|
||||
}
|
||||
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
e = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
timezone = YES;
|
||||
e = i;
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
i = l;
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
int e = i;
|
||||
|
||||
/*
|
||||
* Ensure we have a four digit timezone value.
|
||||
*/
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone ... append zero minutes
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes ... remove it
|
||||
b[i+3] = b[i+4];
|
||||
b[i+4] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
|
||||
/* kludge for timestamps with fractional second information.
|
||||
* Force it to 3 digit millisecond */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
milliseconds = YES;
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+3], &b[i], e-i);
|
||||
l += 3;
|
||||
memcpy(&b[i], "000", 3);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+2], &b[i], e-i);
|
||||
l += 2;
|
||||
memcpy(&b[i], "00", 2);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+1], &b[i], e-i);
|
||||
l += 1;
|
||||
memcpy(&b[i], "0", 1);
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0 && i < e)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
}
|
||||
b[l] = '\0';
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes
|
||||
b[i+3] = b[i+4];
|
||||
b[i+5] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (YES == timezone)
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
/* FIXME ... horrible kludge for postgres returning timestamps with
|
||||
fractional second information. */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
b[l] = '\0';
|
||||
}
|
||||
}
|
||||
else if (l == 19)
|
||||
{
|
||||
/* A date and time without a timezone ... assume gmt */
|
||||
strcat(b, " +0000");
|
||||
l += 6;
|
||||
}
|
||||
|
||||
|
||||
/* If it's a simple date (YYYY-MM-DD) append time for start of day. */
|
||||
if (l == 10)
|
||||
{
|
||||
strcat(b, " 00:00:00 +0000");
|
||||
l += 15;
|
||||
}
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
}
|
||||
}
|
||||
[d setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
return d;
|
||||
}
|
||||
|
||||
- (NSString*) dbToStringFromBuffer: (char*)b length: (int)l
|
||||
|
@ -1139,8 +1069,8 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
d = [[NSData alloc] initWithBytes: b length: l];
|
||||
s = [[NSString alloc] initWithData: d encoding: NSUTF8StringEncoding];
|
||||
[d release];
|
||||
return [s autorelease];
|
||||
RELEASE(d);
|
||||
return AUTORELEASE(s);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
45
GNUmakefile
45
GNUmakefile
|
@ -1,31 +1,9 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(error You need to set GNUSTEP_MAKEFILES before compiling!)
|
||||
endif
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
# Force sequential build to prevent different versions of the same
|
||||
# bundle overwriting each other's temporary files during building.
|
||||
GNUSTEP_MAKE_PARALLEL_BUILDING=no
|
||||
|
||||
-include config.make
|
||||
|
||||
PACKAGE_NAME = SQLClient
|
||||
PACKAGE_VERSION = 1.9.0
|
||||
PACKAGE_VERSION = 1.5.0
|
||||
CVS_MODULE_NAME = gnustep/dev-libs/SQLClient
|
||||
CVS_TAG_NAME = SQLClient
|
||||
SVN_BASE_URL=svn+ssh://svn.gna.org/svn/gnustep/libs
|
||||
|
@ -38,13 +16,12 @@ TEST_TOOL_NAME=
|
|||
LIBRARY_NAME=SQLClient
|
||||
DOCUMENT_NAME=SQLClient
|
||||
|
||||
SQLClient_INTERFACE_VERSION=1.9
|
||||
SQLClient_INTERFACE_VERSION=1.5
|
||||
|
||||
SQLClient_OBJC_FILES = SQLClient.m SQLClientPool.m
|
||||
SQLClient_LIBRARIES_DEPEND_UPON = -lPerformance $(FND_LIBS) $(OBJC_LIBS)
|
||||
SQLClient_OBJC_FILES = SQLClient.m
|
||||
SQLClient_LIBRARIES_DEPEND_UPON = -lPerformance
|
||||
SQLClient_HEADER_FILES = SQLClient.h
|
||||
SQLClient_AGSDOC_FILES = SQLClient.h
|
||||
SQLClient_AGSDOC_FLAGS = -WordMap '{SQLCLIENT_PRIVATE="";}'
|
||||
|
||||
# Optional Java wrappers for the library
|
||||
JAVA_WRAPPER_NAME = SQLClient
|
||||
|
@ -53,7 +30,7 @@ SQLClient_HEADER_FILES_INSTALL_DIR = SQLClient
|
|||
|
||||
BUNDLE_NAME=
|
||||
|
||||
BUNDLE_INSTALL_DIR=$(GNUSTEP_BUNDLES)/SQLClient$(SQLClient_INTERFACE_VERSION)
|
||||
BUNDLE_INSTALL_DIR=$(GNUSTEP_BUNDLES)/SQLClient
|
||||
|
||||
# In some systems and situations the dynamic linker needs to haved the
|
||||
# SQLClient, gnustep-base, and objc libraries explicityly linked into
|
||||
|
@ -85,7 +62,7 @@ BUNDLE_NAME += ECPG_libs
|
|||
ECPG_libs_OBJC_FILES = ECPG.m
|
||||
ECPG_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
ECPG_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lecpg
|
||||
-lgnustep-base -lobjc -lecpg
|
||||
ECPG_libs_PRINCIPAL_CLASS = SQLClientECPG_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testECPG
|
||||
|
@ -111,7 +88,7 @@ BUNDLE_NAME += Postgres_libs
|
|||
Postgres_libs_OBJC_FILES = Postgres.m
|
||||
Postgres_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
Postgres_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lpq
|
||||
-lgnustep-base -lobjc -lpq
|
||||
Postgres_libs_PRINCIPAL_CLASS = SQLClientPostgres_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testPostgres
|
||||
|
@ -137,7 +114,7 @@ BUNDLE_NAME += JDBC_libs
|
|||
JDBC_libs_OBJC_FILES = JDBC.m
|
||||
JDBC_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR) $(JDBC_VM_LIBDIRS)
|
||||
JDBC_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) $(JDBC_VM_LIBS)
|
||||
-lgnustep-base -lobjc $(JDBC_VM_LIBS)
|
||||
JDBC_libs_PRINCIPAL_CLASS = SQLClientJDBC_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testJDBC
|
||||
|
@ -163,7 +140,7 @@ BUNDLE_NAME += MySQL_libs
|
|||
MySQL_libs_OBJC_FILES = MySQL.m
|
||||
MySQL_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
MySQL_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lmysqlclient
|
||||
-lgnustep-base -lobjc -lmysqlclient
|
||||
MySQL_libs_PRINCIPAL_CLASS = SQLClientMySQL_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testMySQL
|
||||
|
@ -189,7 +166,7 @@ BUNDLE_NAME += SQLite_libs
|
|||
SQLite_libs_OBJC_FILES = SQLite.m
|
||||
SQLite_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
SQLite_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lsqlite3
|
||||
-lgnustep-base -lobjc -lsqlite3
|
||||
SQLite_libs_PRINCIPAL_CLASS = SQLClientSQLite_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testSQLite
|
||||
|
@ -212,7 +189,7 @@ Oracle_libs_OBJC_FILES = Oracle.m
|
|||
Oracle_libs_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./$(GNUSTEP_OBJ_DIR) \
|
||||
$(shell cat $(ORACLE_HOME)/lib/ldflags)
|
||||
Oracle_libs_BUNDLE_LIBS += -lclntsh \
|
||||
-lSQLClient -lPerformance $(FND_LIBS) $(OBJC_LIBS) \
|
||||
-lSQLClient -lPerformance -lgnustep-base -lobjc \
|
||||
$(shell cat $(ORACLE_HOME)/lib/sysliblist) \
|
||||
-ldl -lm
|
||||
Oracle_libs_PRINCIPAL_CLASS = SQLClientOracle_libs
|
||||
|
|
|
@ -13,7 +13,9 @@ ifneq ($(ECPG),)
|
|||
%.m: %.pgm
|
||||
ecpg -o $@ $< $(ADDITIONAL_INCLUDE_DIRS)
|
||||
|
||||
.PRECIOUS: %.m
|
||||
# if you need to see the .m files for debugging, uncomment
|
||||
# the following line
|
||||
#.PRECIOUS: %.m
|
||||
|
||||
endif
|
||||
|
||||
|
@ -23,7 +25,9 @@ ifneq ($(ORACLE_HOME),)
|
|||
%.m: %.pm
|
||||
proc iname=$< oname=$@ mode=ansi parse=none
|
||||
|
||||
.PRECIOUS: %.m
|
||||
# if you need to see the .m files for debugging, uncomment
|
||||
# the following line
|
||||
#.PRECIOUS: %.m
|
||||
|
||||
endif
|
||||
|
||||
|
@ -66,10 +70,6 @@ after-distclean::
|
|||
# Things to do after checking
|
||||
# after-check::
|
||||
|
||||
config.make: config.status
|
||||
if [ -x config.status ]; then \
|
||||
./config.status --recheck; \
|
||||
else \
|
||||
./configure; \
|
||||
fi
|
||||
config.make: config.make.in
|
||||
./configure
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS += -DSOVERSION=\"$(SQLClient_INTERFACE_VERSION)\"
|
||||
# ADDITIONAL_CPPFLAGS +=
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
# ADDITIONAL_OBJCFLAGS +=
|
||||
|
|
147
JDBC.m
147
JDBC.m
|
@ -30,7 +30,6 @@
|
|||
#import <Foundation/NSCharacterSet.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
|
@ -46,14 +45,19 @@
|
|||
#import <Performance/GSTicker.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
|
||||
@interface _JDBCTransaction : SQLTransaction
|
||||
@end
|
||||
|
||||
typedef struct {
|
||||
@defs(SQLClient);
|
||||
} *CDefs;
|
||||
|
||||
typedef struct {
|
||||
@defs(_JDBCTransaction);
|
||||
} *TDefs;
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
static NSString *JDBCException = @"SQLClientJDBCException";
|
||||
|
@ -279,7 +283,7 @@ JNIEnv *SQLClientJNIEnv ()
|
|||
}
|
||||
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL (pool);
|
||||
|
||||
args.version = JNI_VERSION_1_2;
|
||||
args.name = (char *)[[NSString stringWithFormat:
|
||||
|
@ -289,7 +293,7 @@ JNIEnv *SQLClientJNIEnv ()
|
|||
result = (*SQLClientJavaVM)->AttachCurrentThread
|
||||
(SQLClientJavaVM, (void **)&env, &args);
|
||||
|
||||
[pool release];
|
||||
RELEASE (pool);
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
|
@ -760,9 +764,9 @@ static int JDBCVARCHAR = 0;
|
|||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
[future retain];
|
||||
RETAIN(future);
|
||||
null = [NSNull null];
|
||||
[null retain];
|
||||
RETAIN(null);
|
||||
|
||||
[SQLClientJVM startVirtualMachineWithClassPath: nil libraryPath: nil];
|
||||
env = SQLClientJNIEnv();
|
||||
|
@ -1130,16 +1134,16 @@ static int JDBCVARCHAR = 0;
|
|||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSString *stmt = [info objectAtIndex: 0];
|
||||
JNIEnv *env = SQLClientJNIEnv();
|
||||
JInfo *ji;
|
||||
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -1147,7 +1151,7 @@ static int JDBCVARCHAR = 0;
|
|||
if ((*env)->PushLocalFrame (env, 32) < 0)
|
||||
{
|
||||
JExceptionClear(env);
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"No java memory for execute"];
|
||||
}
|
||||
|
@ -1160,7 +1164,7 @@ static int JDBCVARCHAR = 0;
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
|
@ -1228,14 +1232,13 @@ static int JDBCVARCHAR = 0;
|
|||
stmt, localException];
|
||||
}
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return -1;
|
||||
DESTROY(arp);
|
||||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
|
@ -1243,13 +1246,13 @@ static int JDBCVARCHAR = 0;
|
|||
listType: (id)lType
|
||||
{
|
||||
NSMutableArray *records = nil;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
JNIEnv *env = SQLClientJNIEnv();
|
||||
JInfo *ji;
|
||||
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -1257,7 +1260,7 @@ static int JDBCVARCHAR = 0;
|
|||
if ((*env)->PushLocalFrame (env, 32) < 0)
|
||||
{
|
||||
JExceptionClear(env);
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"No java memory for query"];
|
||||
}
|
||||
|
@ -1274,7 +1277,7 @@ static int JDBCVARCHAR = 0;
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
|
@ -1386,7 +1389,7 @@ static int JDBCVARCHAR = 0;
|
|||
if ((*env)->PushLocalFrame (env, fieldCount * 2) < 0)
|
||||
{
|
||||
JExceptionClear(env);
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"No java memory for query"];
|
||||
}
|
||||
|
@ -1477,7 +1480,7 @@ static int JDBCVARCHAR = 0;
|
|||
keys: keys
|
||||
count: fieldCount];
|
||||
[records addObject: record];
|
||||
[record release];
|
||||
RELEASE(record);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1495,7 +1498,7 @@ static int JDBCVARCHAR = 0;
|
|||
(*env)->PopLocalFrame (env, NULL);
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
|
@ -1503,30 +1506,29 @@ static int JDBCVARCHAR = 0;
|
|||
stmt, localException];
|
||||
}
|
||||
}
|
||||
[records release];
|
||||
records = nil;
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
DESTROY(records);
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return [records autorelease];
|
||||
DESTROY(arp);
|
||||
return AUTORELEASE(records);
|
||||
}
|
||||
|
||||
- (SQLTransaction*) batch: (BOOL)stopOnFailure
|
||||
{
|
||||
_JDBCTransaction *transaction;
|
||||
TDefs transaction;
|
||||
|
||||
transaction = (_JDBCTransaction*)NSAllocateObject([_JDBCTransaction class], 0,
|
||||
transaction = (TDefs)NSAllocateObject([_JDBCTransaction class], 0,
|
||||
NSDefaultMallocZone());
|
||||
|
||||
transaction->_owner = [self retain];
|
||||
transaction->_db = RETAIN(self);
|
||||
transaction->_info = [NSMutableArray new];
|
||||
transaction->_batch = YES;
|
||||
transaction->_stop = stopOnFailure;
|
||||
return [(SQLTransaction*)transaction autorelease];
|
||||
return AUTORELEASE((SQLTransaction*)transaction);
|
||||
}
|
||||
|
||||
- (void) begin
|
||||
|
@ -1577,7 +1579,7 @@ static int JDBCVARCHAR = 0;
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -1600,15 +1602,15 @@ static int JDBCVARCHAR = 0;
|
|||
length: 3
|
||||
encoding: NSASCIIStringEncoding];
|
||||
special = [NSCharacterSet characterSetWithCharactersInString: stemp];
|
||||
[stemp release];
|
||||
[special retain];
|
||||
RELEASE(stemp);
|
||||
RETAIN(special);
|
||||
}
|
||||
|
||||
/*
|
||||
* Step through string removing nul characters
|
||||
* and escaping quote characters as required.
|
||||
*/
|
||||
m = [[s mutableCopy] autorelease];
|
||||
m = AUTORELEASE([s mutableCopy]);
|
||||
l = [m length];
|
||||
r = NSMakeRange(0, l);
|
||||
r = [m rangeOfCharacterFromSet: special options: NSLiteralSearch range: r];
|
||||
|
@ -1676,14 +1678,14 @@ static int JDBCVARCHAR = 0;
|
|||
|
||||
- (SQLTransaction*) transaction
|
||||
{
|
||||
_JDBCTransaction *transaction;
|
||||
TDefs transaction;
|
||||
|
||||
transaction = (_JDBCTransaction*)NSAllocateObject([_JDBCTransaction class], 0,
|
||||
transaction = (TDefs)NSAllocateObject([_JDBCTransaction class], 0,
|
||||
NSDefaultMallocZone());
|
||||
|
||||
transaction->_owner = [self retain];
|
||||
transaction->_db = RETAIN(self);
|
||||
transaction->_info = [NSMutableArray new];
|
||||
return [(SQLTransaction*)transaction autorelease];
|
||||
return AUTORELEASE((SQLTransaction*)transaction);
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -1728,55 +1730,41 @@ static int JDBCVARCHAR = 0;
|
|||
{
|
||||
if (_count > 0)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
SQLClientPool *pool;
|
||||
SQLClient *db;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
BOOL wrapped = NO;
|
||||
BOOL batched = NO;
|
||||
JNIEnv *env;
|
||||
JInfo *ji;
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([_db backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute transaction %@",
|
||||
[_db name], self];
|
||||
}
|
||||
|
||||
env = SQLClientJNIEnv();
|
||||
if ((*env)->PushLocalFrame (env, 32) < 0)
|
||||
{
|
||||
JExceptionClear(env);
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"No java memory for execute"];
|
||||
}
|
||||
|
||||
if ([_owner isKindOfClass: [SQLClientPool class]])
|
||||
{
|
||||
pool = (SQLClientPool*)_owner;
|
||||
db = [pool provideClient];
|
||||
}
|
||||
else
|
||||
{
|
||||
pool = nil;
|
||||
db = _owner;
|
||||
}
|
||||
|
||||
ji = [(SQLClientJDBC*)db _backendExtra];
|
||||
ji = [(SQLClientJDBC*)_db _backendExtra];
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
NSMutableArray *statements;
|
||||
unsigned numberOfStatements;
|
||||
unsigned statement;
|
||||
NSTimeInterval _duration;
|
||||
NSTimeInterval _duration = [_db durationLogging];
|
||||
NSTimeInterval start = 0.0;
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([db connect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute transaction %@",
|
||||
[_owner name], self];
|
||||
}
|
||||
|
||||
_duration = [db durationLogging];
|
||||
statements = [NSMutableArray arrayWithCapacity: 100];
|
||||
[self _merge: statements];
|
||||
numberOfStatements = [statements count];
|
||||
|
@ -1786,7 +1774,7 @@ static int JDBCVARCHAR = 0;
|
|||
start = GSTickerTimeNow();
|
||||
}
|
||||
|
||||
if ([db isInTransaction] == NO)
|
||||
if ([_db isInTransaction] == NO)
|
||||
{
|
||||
wrapped = YES;
|
||||
}
|
||||
|
@ -1898,15 +1886,15 @@ static int JDBCVARCHAR = 0;
|
|||
|
||||
(*env)->PopLocalFrame (env, NULL);
|
||||
|
||||
db->_lastOperation = GSTickerTimeNow();
|
||||
((CDefs)_db)->_lastOperation = GSTickerTimeNow();
|
||||
if (_duration >= 0)
|
||||
{
|
||||
NSTimeInterval d;
|
||||
|
||||
d = db->_lastOperation - start;
|
||||
d = ((CDefs)_db)->_lastOperation - start;
|
||||
if (d >= _duration)
|
||||
{
|
||||
[db debug: @"Duration %g for transaction %@",
|
||||
[_db debug: @"Duration %g for transaction %@",
|
||||
d, statements];
|
||||
}
|
||||
}
|
||||
|
@ -1928,12 +1916,7 @@ static int JDBCVARCHAR = 0;
|
|||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
if (nil != pool)
|
||||
{
|
||||
[pool swallowClient: db];
|
||||
}
|
||||
|
||||
[arp release];
|
||||
RELEASE(arp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
231
MySQL.m
231
MySQL.m
|
@ -24,25 +24,21 @@
|
|||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSNull.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSTimeZone.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSNull.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
|
||||
#include <mysql/mysql.h>
|
||||
|
@ -62,12 +58,12 @@ static NSNull *null = nil;
|
|||
{
|
||||
if (future == nil)
|
||||
{
|
||||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
[future retain];
|
||||
RETAIN(future);
|
||||
null = [NSNull null];
|
||||
[null retain];
|
||||
RETAIN(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,11 +97,9 @@ static NSNull *null = nil;
|
|||
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Connect to '%@' as %@",
|
||||
[self database], [self name]];
|
||||
[self debug: @"Connect to '%@' as %@", [self database], [self name]];
|
||||
}
|
||||
extra = mysql_init(0);
|
||||
mysql_options(connection, MYSQL_SET_CHARSET_NAME, "utf8");
|
||||
if (mysql_real_connect(connection,
|
||||
[host UTF8String],
|
||||
[[self user] UTF8String],
|
||||
|
@ -113,13 +107,23 @@ static NSNull *null = nil;
|
|||
[dbase UTF8String],
|
||||
[port intValue],
|
||||
NULL,
|
||||
CLIENT_MULTI_STATEMENTS) == 0)
|
||||
0
|
||||
) == 0)
|
||||
{
|
||||
[self debug: @"Error connecting to '%@' (%@) - %s",
|
||||
[self name], [self database], mysql_error(connection)];
|
||||
mysql_close(connection);
|
||||
extra = 0;
|
||||
}
|
||||
#if 0
|
||||
else if (mysql_query(connection, "SET CHARACTER SET utf8") != 0)
|
||||
{
|
||||
[self debug: @"Error setting utf8 support for '%@' (%@) - %s",
|
||||
[self name], [self database], mysql_error(connection)];
|
||||
mysql_close(connection);
|
||||
extra = 0;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
connected = YES;
|
||||
|
@ -173,30 +177,28 @@ static NSNull *null = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
{
|
||||
NSString *stmt;
|
||||
NSInteger rowCount = 0;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *stmt;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
|
||||
stmt = [info objectAtIndex: 0];
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
const char *statement;
|
||||
unsigned length;
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
|
@ -214,32 +216,8 @@ static NSNull *null = nil;
|
|||
|
||||
if (mysql_real_query(connection, statement, length) != 0)
|
||||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"%s", mysql_error(connection)];
|
||||
if (mysql_ping(connection) == 0)
|
||||
{
|
||||
[NSException raise: SQLException format: @"%@", s];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLConnectionException format: @"%@", s];
|
||||
}
|
||||
}
|
||||
/* See how many rows were modified.
|
||||
*/
|
||||
rowCount = mysql_affected_rows(connection);
|
||||
/* discard any results.
|
||||
*/
|
||||
result = mysql_store_result(connection);
|
||||
if (result != 0) mysql_free_result(result);
|
||||
while (mysql_more_results(connection))
|
||||
{
|
||||
if (mysql_next_result(connection) == 0)
|
||||
{
|
||||
result = mysql_store_result(connection);
|
||||
if (result != 0) mysql_free_result(result);
|
||||
}
|
||||
[NSException raise: SQLException format: @"%s",
|
||||
mysql_error(connection)];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
|
@ -248,21 +226,20 @@ static NSNull *null = nil;
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return rowCount;
|
||||
DESTROY(arp);
|
||||
}
|
||||
|
||||
static unsigned int trim(char *str)
|
||||
|
@ -290,16 +267,16 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
recordType: (id)rtype
|
||||
listType: (id)ltype
|
||||
recordType: (Class)rtype
|
||||
listType: (Class)ltype
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSMutableArray *records = nil;
|
||||
MYSQL_RES *result = 0;
|
||||
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -311,7 +288,7 @@ static unsigned int trim(char *str)
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
|
@ -361,55 +338,60 @@ static unsigned int trim(char *str)
|
|||
{
|
||||
case FIELD_TYPE_TIMESTAMP:
|
||||
{
|
||||
char b[32];
|
||||
NSString *f;
|
||||
NSString *s;
|
||||
|
||||
s = [[NSString alloc] initWithBytes: p
|
||||
length: size encoding: NSASCIIStringEncoding];
|
||||
if (size > 14)
|
||||
{
|
||||
size = 19;
|
||||
f = @"%Y-%m-%d %H:%M:%S %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 14)
|
||||
{
|
||||
f = @"%Y%m%d%H%M%S %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y%m%d%H%M%S"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 12)
|
||||
{
|
||||
f = @"%y%m%d%H%M%S %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d%H%M%S"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 10)
|
||||
{
|
||||
f = @"%y%m%d%H%M %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d%H%M"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 8)
|
||||
{
|
||||
f = @"%y%m%d%H %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d%H"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 6)
|
||||
{
|
||||
f = @"%y%m%d %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 4)
|
||||
{
|
||||
f = @"%y%m %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
f = @"%y %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y"
|
||||
locale: nil];
|
||||
}
|
||||
strncpy(b, (char*)p, size);
|
||||
strncpy(b + size, (char*)" +0000", 6);
|
||||
s = [[NSString alloc] initWithBytes: b
|
||||
length: size + 6
|
||||
encoding: NSASCIIStringEncoding];
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: f
|
||||
locale: nil];
|
||||
RELEASE(s);
|
||||
[v setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
if ([self debugging] > 1)
|
||||
[self debug: @"Parsed '%@' as '%@'\n", s, v];
|
||||
[s release];
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -421,23 +403,11 @@ static unsigned int trim(char *str)
|
|||
case FIELD_TYPE_TINY_BLOB:
|
||||
case FIELD_TYPE_MEDIUM_BLOB:
|
||||
case FIELD_TYPE_LONG_BLOB:
|
||||
if (63 == fields[j].charsetnr)
|
||||
{
|
||||
v = [NSData dataWithBytes: p length: size];
|
||||
}
|
||||
else
|
||||
{
|
||||
v = [[[NSString alloc] initWithBytes: p
|
||||
length: size
|
||||
encoding: NSUTF8StringEncoding] autorelease];
|
||||
}
|
||||
v = [NSData dataWithBytes: p length: size];
|
||||
break;
|
||||
|
||||
default:
|
||||
if (YES == _shouldTrim)
|
||||
{
|
||||
trim((char*)p);
|
||||
}
|
||||
trim((char*)p);
|
||||
v = [NSString stringWithUTF8String: (char*)p];
|
||||
break;
|
||||
}
|
||||
|
@ -448,22 +418,13 @@ static unsigned int trim(char *str)
|
|||
keys: keys
|
||||
count: fieldCount];
|
||||
[records addObject: record];
|
||||
[record release];
|
||||
RELEASE(record);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"%s", mysql_error(connection)];
|
||||
if (mysql_ping(connection) == 0)
|
||||
{
|
||||
[NSException raise: SQLException format: @"%@", s];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLConnectionException format: @"%@", s];
|
||||
}
|
||||
[NSException raise: SQLException format: @"%s",
|
||||
mysql_error(connection)];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
|
@ -472,7 +433,7 @@ static unsigned int trim(char *str)
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
|
@ -483,20 +444,19 @@ static unsigned int trim(char *str)
|
|||
{
|
||||
mysql_free_result(result);
|
||||
}
|
||||
[records release];
|
||||
records = nil;
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
DESTROY(records);
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
DESTROY(arp);
|
||||
if (result != 0)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
}
|
||||
return [records autorelease];
|
||||
return AUTORELEASE(records);
|
||||
}
|
||||
|
||||
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
|
||||
|
@ -549,38 +509,5 @@ static unsigned int trim(char *str)
|
|||
return length;
|
||||
}
|
||||
|
||||
- (NSString*) quote: (id)obj
|
||||
{
|
||||
/* MySQL doesn't support timezones ... convert dates to simple GMT.
|
||||
*/
|
||||
if ([obj isKindOfClass: [NSDate class]] == YES)
|
||||
{
|
||||
NSString *fmt = nil;
|
||||
static NSTimeZone *gmt = nil;
|
||||
|
||||
if (nil == gmt)
|
||||
{
|
||||
gmt = [[NSTimeZone timeZoneForSecondsFromGMT: 0] retain];
|
||||
}
|
||||
if ([obj isKindOfClass: [NSCalendarDate class]] == YES)
|
||||
{
|
||||
fmt = [obj calendarFormat];
|
||||
if ([fmt length] > 17)
|
||||
{
|
||||
fmt = nil; // bad format ... had timezone
|
||||
}
|
||||
}
|
||||
if (nil == fmt)
|
||||
{
|
||||
fmt = @"%Y-%m-%d %H:%M:%S";
|
||||
}
|
||||
fmt = [NSString stringWithFormat: @"'%@'", fmt];
|
||||
return [obj descriptionWithCalendarFormat: fmt
|
||||
timeZone: gmt
|
||||
locale: nil];
|
||||
}
|
||||
return [super quote: obj];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
255
Oracle.pm
255
Oracle.pm
|
@ -216,7 +216,7 @@ void SQLClientOracleErrorHandler()
|
|||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char *statement;
|
||||
|
@ -240,7 +240,7 @@ void SQLClientOracleErrorHandler()
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"(Oracle) Unable to connect to database"];
|
||||
|
@ -273,7 +273,7 @@ void SQLClientOracleErrorHandler()
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
/*
|
||||
* remove line number information from database exception message
|
||||
|
@ -300,7 +300,6 @@ void SQLClientOracleErrorHandler()
|
|||
}
|
||||
NS_ENDHANDLER
|
||||
DESTROY(arp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static unsigned int trim(char *str)
|
||||
|
@ -369,7 +368,7 @@ static unsigned int trim(char *str)
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"(Oracle) Unable to connect to database"];
|
||||
|
@ -554,10 +553,7 @@ static unsigned int trim(char *str)
|
|||
|
||||
/* \0-pad the string. */
|
||||
aString[octetLength] = '\0';
|
||||
if (YES == _shouldTrim)
|
||||
{
|
||||
trim (aString);
|
||||
}
|
||||
trim (aString);
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free(aString);
|
||||
break;
|
||||
|
@ -588,10 +584,7 @@ static unsigned int trim(char *str)
|
|||
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
|
||||
:aString = DATA;
|
||||
aString[octetLength] = '\0';
|
||||
if (YES == _shouldTrim)
|
||||
{
|
||||
trim (aString);
|
||||
}
|
||||
trim (aString);
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free (aString);
|
||||
NSLog(@"(Oracle) Unknown data type (%d) for '%s': '%@'",
|
||||
|
@ -651,7 +644,7 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
if ([e isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
@ -674,7 +667,7 @@ static unsigned int trim(char *str)
|
|||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
_inTransaction = NO;
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -899,15 +892,14 @@ static unsigned int trim(char *str)
|
|||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from a database character buffer to an NSDate.
|
||||
*/
|
||||
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l
|
||||
{
|
||||
char buf[l+32]; /* Allow space to expand buffer. */
|
||||
NSCalendarDate *d;
|
||||
BOOL milliseconds = NO;
|
||||
BOOL timezone = NO;
|
||||
NSString *s;
|
||||
int i;
|
||||
int e;
|
||||
char buf[l+32]; /* Allow space to expend buffer. */
|
||||
NSString *s;
|
||||
int i;
|
||||
|
||||
memcpy(buf, b, l);
|
||||
b = buf;
|
||||
|
@ -930,153 +922,98 @@ static unsigned int trim(char *str)
|
|||
|
||||
if (l == 10)
|
||||
{
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d"
|
||||
locale: nil];
|
||||
}
|
||||
|
||||
i = l;
|
||||
|
||||
/* Convert +/-HH:SS timezone to +/-HHSS
|
||||
*/
|
||||
if (i > 5 && b[i-3] == ':' && (b[i-6] == '+' || b[i-6] == '-'))
|
||||
{
|
||||
b[i-3] = b[i-2];
|
||||
b[i-2] = b[i-1];
|
||||
b[--i] = '\0';
|
||||
}
|
||||
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
e = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
timezone = YES;
|
||||
e = i;
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
i = l;
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
int e = i;
|
||||
|
||||
/*
|
||||
* Ensure we have a four digit timezone value.
|
||||
*/
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone ... append zero minutes
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes ... remove it
|
||||
b[i+3] = b[i+4];
|
||||
b[i+4] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
|
||||
/* kludge for timestamps with fractional second information.
|
||||
* Force it to 3 digit millisecond */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
milliseconds = YES;
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+3], &b[i], e-i);
|
||||
l += 3;
|
||||
memcpy(&b[i], "000", 3);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+2], &b[i], e-i);
|
||||
l += 2;
|
||||
memcpy(&b[i], "00", 2);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+1], &b[i], e-i);
|
||||
l += 1;
|
||||
memcpy(&b[i], "0", 1);
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0 && i < e)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
}
|
||||
b[l] = '\0';
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes
|
||||
b[i+3] = b[i+4];
|
||||
b[i+5] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (YES == timezone)
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
/* FIXME ... horrible kludge for postgres returning timestamps with
|
||||
fractional second information. */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
b[l] = '\0';
|
||||
}
|
||||
}
|
||||
else if (l == 19)
|
||||
{
|
||||
/* A date and time without a timezone ... assume gmt */
|
||||
strcat(b, " +0000");
|
||||
l += 6;
|
||||
}
|
||||
|
||||
|
||||
/* If it's a simple date (YYYY-MM-DD) append time for start of day. */
|
||||
if (l == 10)
|
||||
{
|
||||
strcat(b, " 00:00:00 +0000");
|
||||
l += 15;
|
||||
}
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
}
|
||||
}
|
||||
[d setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
1733
Postgres.m
1733
Postgres.m
File diff suppressed because it is too large
Load diff
1354
SQLClient.h
1354
SQLClient.h
File diff suppressed because it is too large
Load diff
|
@ -72,7 +72,7 @@
|
|||
"add:with:",
|
||||
"append:",
|
||||
"count",
|
||||
"owner",
|
||||
"db",
|
||||
"execute",
|
||||
"reset"
|
||||
);
|
||||
|
|
5991
SQLClient.m
5991
SQLClient.m
File diff suppressed because it is too large
Load diff
1526
SQLClientPool.m
1526
SQLClientPool.m
File diff suppressed because it is too large
Load diff
47
SQLite.m
47
SQLite.m
|
@ -1,6 +1,6 @@
|
|||
/* -*-objc-*- */
|
||||
|
||||
/** Implementation of SQLClientSQLite for GNUStep
|
||||
/** Implementation of SQLClientPostgres for GNUStep
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
@ -41,11 +41,7 @@
|
|||
#import <Foundation/NSValue.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
#include <string.h>
|
||||
#include <sqlite3.h>
|
||||
|
||||
@interface SQLClientSQLite : SQLClient
|
||||
|
@ -132,15 +128,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
{
|
||||
NSString *stmt;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *stmt;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
|
||||
stmt = [info objectAtIndex: 0];
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -155,7 +151,7 @@
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
|
@ -183,33 +179,32 @@
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return -1;
|
||||
DESTROY(arp);
|
||||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
recordType: (id)rtype
|
||||
listType: (id)ltype
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSMutableArray *records = [[ltype alloc] initWithCapacity: 2];
|
||||
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -224,7 +219,7 @@
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
|
@ -293,7 +288,7 @@
|
|||
keys: keys
|
||||
count: columns];
|
||||
[records addObject: record];
|
||||
[record release];
|
||||
RELEASE(record);
|
||||
}
|
||||
while ((result = sqlite3_step(prepared)) == SQLITE_ROW);
|
||||
}
|
||||
|
@ -310,21 +305,21 @@
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return [records autorelease];
|
||||
DESTROY(arp);
|
||||
return AUTORELEASE(records);
|
||||
}
|
||||
|
||||
static char hex[16] = "0123456789ABCDEF";
|
||||
|
|
1326
config.guess
vendored
Executable file
1326
config.guess
vendored
Executable file
File diff suppressed because it is too large
Load diff
1451
config.sub
vendored
Executable file
1451
config.sub
vendored
Executable file
File diff suppressed because it is too large
Load diff
411
configure.ac
411
configure.ac
|
@ -3,22 +3,12 @@ dnl Process this file with autoconf to produce configure.
|
|||
AC_INIT(SQLClient.h)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
if test -z "$GNUSTEP_MAKEFILES"; then
|
||||
GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
|
||||
export GNUSTEP_MAKEFILES
|
||||
fi
|
||||
|
||||
if test -z "$GNUSTEP_MAKEFILES"; then
|
||||
AC_MSG_ERROR([You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!])
|
||||
else
|
||||
. $GNUSTEP_MAKEFILES/GNUstep.sh
|
||||
fi
|
||||
|
||||
if test "x$GNUSTEP_HOST_OS" = "x"; then
|
||||
GNUSTEP_HOST_OS=`gnustep-config --variable=GNUSTEP_HOST_OS`
|
||||
GNUSTEP_HOST_CPU=`gnustep-config --variable=GNUSTEP_HOST_CPU`
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
AC_ARG_WITH(additional-include, [
|
||||
--with-additional-include=flags
|
||||
|
@ -68,24 +58,8 @@ if test "$postgres_topdir" != "no"; then
|
|||
CPPFLAGS="$CPPFLAGS -I$postgres_topdir/include -L$postgres_topdir/lib"
|
||||
INCD="$INCD -I$postgres_topdir/include"
|
||||
LIBD="$LIBD -L$postgres_topdir/lib"
|
||||
else
|
||||
PGINC=`pg_config --includedir`
|
||||
if test "$PGINC" != ""; then
|
||||
CPPFLAGS="$CPPFLAGS -I$PGINC"
|
||||
INCD="$INCD -I$PGINC"
|
||||
fi
|
||||
PGLIB=`pg_config --libdir`
|
||||
if test "$PGLIB" != ""; then
|
||||
CPPFLAGS="$CPPFLAGS -L$PGLIB"
|
||||
LIBD="$LIBD -I$PGLIB"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Call AC_CHECK_HEADERS here as a workaround for a configure bug/feature
|
||||
# which messes up all subsequent tests if the first occurrence in the
|
||||
# file does not get called ... as would otherwise be the case if jdbc
|
||||
# support is disabled.
|
||||
AC_CHECK_HEADERS(stdio.h)
|
||||
|
||||
AC_MSG_CHECKING([if Jdbc support was manually disabled])
|
||||
AC_ARG_ENABLE(jdbc-bundle, [
|
||||
|
@ -99,6 +73,7 @@ AC_ARG_ENABLE(jdbc-bundle, [
|
|||
|
||||
if test "$ac_cv_jdbc_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
JDBC=
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
|
@ -202,41 +177,28 @@ if test "$ac_cv_mysql_bundle" = "no"; then
|
|||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
AC_CHECK_HEADERS(mysql/mysql.h)
|
||||
if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
|
||||
MYSQL=yes
|
||||
else
|
||||
AC_CHECK_HEADERS(mysql/mysql.h)
|
||||
if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
|
||||
MYSQL=yes
|
||||
else
|
||||
MYSQL=
|
||||
echo "*********************************************************"
|
||||
echo "Unable to locate mysqlclient headers (are they installed)"
|
||||
echo "*********************************************************"
|
||||
fi
|
||||
if test "$MYSQL" = "yes"; then
|
||||
AC_CHECK_LIB(mysqlclient,mysql_init)
|
||||
if test "$ac_cv_lib_mysqlclient_mysql_init" != "yes"; then
|
||||
MYSQL=
|
||||
echo "*********************************************************"
|
||||
echo "Unable to locate mysqlclient headers (are they installed)"
|
||||
echo "*********************************************************"
|
||||
fi
|
||||
if test "$MYSQL" = "yes"; then
|
||||
if test -d /usr/lib/mysql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/mysql"
|
||||
LIBD="$LIBD -L/usr/lib/mysql"
|
||||
else
|
||||
if test -d /usr/local/lib/mysql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/mysql"
|
||||
LIBD="$LIBD -L/usr/local/lib/mysql"
|
||||
else
|
||||
if test -d /usr/local/mysql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/mysql/lib"
|
||||
LIBD="$LIBD -L/usr/local/mysql/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_CHECK_LIB(mysqlclient,mysql_init)
|
||||
if test "$ac_cv_lib_mysqlclient_mysql_init" != "yes"; then
|
||||
MYSQL=
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate mysqlclient library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate mysqlclient library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(MYSQL)
|
||||
|
||||
fi
|
||||
|
||||
|
||||
AC_MSG_CHECKING([if Sqllite support was manually disabled])
|
||||
AC_ARG_ENABLE(sqllite-bundle, [
|
||||
|
@ -254,27 +216,28 @@ if test "$ac_cv_sqllite_bundle" = "no"; then
|
|||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
AC_CHECK_HEADERS(sqlite3.h)
|
||||
if test "$ac_cv_header_sqlite3_h" = "yes"; then
|
||||
SQLITE=yes
|
||||
else
|
||||
AC_CHECK_HEADERS(sqlite3.h)
|
||||
if test "$ac_cv_header_sqlite3_h" = "yes"; then
|
||||
SQLITE=yes
|
||||
else
|
||||
SQLITE=
|
||||
echo "*****************************************************"
|
||||
echo "Unable to locate sqlite3 headers (are they installed)"
|
||||
echo "*****************************************************"
|
||||
fi
|
||||
if test "$SQLITE" = "yes"; then
|
||||
AC_CHECK_LIB(sqlite3,sqlite3_open)
|
||||
if test "$ac_cv_lib_sqlite3_sqlite3_open" != "yes"; then
|
||||
SQLITE=
|
||||
echo "*****************************************************"
|
||||
echo "Unable to locate sqlite3 headers (are they installed)"
|
||||
echo "*****************************************************"
|
||||
fi
|
||||
if test "$SQLITE" = "yes"; then
|
||||
AC_CHECK_LIB(sqlite3,sqlite3_open)
|
||||
if test "$ac_cv_lib_sqlite3_sqlite3_open" != "yes"; then
|
||||
SQLITE=
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate sqlite3 library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate sqlite3 library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(SQLITE)
|
||||
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if Postgres support was manually disabled])
|
||||
AC_ARG_ENABLE(postgres-bundle, [
|
||||
--disable-postgres-bundle
|
||||
|
@ -291,211 +254,163 @@ if test "$ac_cv_postgres_bundle" = "no"; then
|
|||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
# Start POSTGRES checks
|
||||
POSTGRES=
|
||||
# Start POSTGRES checks
|
||||
POSTGRES=
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(libpq-fe.h)
|
||||
if test "$ac_cv_header_libpq_fe_h" = "yes"; then
|
||||
POSTGRES=yes
|
||||
fi
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(libpq-fe.h)
|
||||
if test "$ac_cv_header_libpq_fe_h" = "yes"; then
|
||||
POSTGRES=yes
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(ecpglib.h)
|
||||
if test "$ac_cv_header_ecpglib_h" = "yes"; then
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/pgsql/include/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/pgsql/include"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
echo "**************************************************************"
|
||||
echo "Unable to locate libpq (postgres) headers (are they installed)"
|
||||
echo "**************************************************************"
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = "yes"; then
|
||||
# NICOLA - hack
|
||||
if test -d /usr/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/lib/pgsql"
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/pgsql/include/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/pgsql/include"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/pgsql/include/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/pgsql/include"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
echo "**************************************************************"
|
||||
echo "Unable to locate libpq (postgres) headers (are they installed)"
|
||||
echo "**************************************************************"
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
echo "*************************************************************"
|
||||
echo "Unable to locate ecpg (postgres) headers (are they installed)"
|
||||
echo "*************************************************************"
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = "yes"; then
|
||||
# NICOLA - hack
|
||||
if test -d /usr/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/local/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/local/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/pgsql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/pgsql/lib"
|
||||
LIBD="$LIBD -L/usr/local/pgsql/lib"
|
||||
fi
|
||||
if test -d /usr/local/pgsql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/pgsql/lib"
|
||||
LIBD="$LIBD -L/usr/local/pgsql/lib"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(pq,PQfformat)
|
||||
if test "$ac_cv_lib_pq_PQfformat" != "yes"; then
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(pq,PQfformat)
|
||||
if test "$ac_cv_lib_pq_PQfformat" != "yes"; then
|
||||
POSTGRES=
|
||||
AC_CHECK_LIB(pq,PQclear)
|
||||
echo "******************************************************"
|
||||
if test "$ac_cv_lib_pq_PQclear" != "yes"; then
|
||||
echo "Unable to locate postgres pq library (is it installed)"
|
||||
echo "Unable to locate postgres pq library (is it installed)"
|
||||
else
|
||||
echo "Located postgres pq library, but it is too old to use!"
|
||||
echo "Located postgres pq library, but it is too old to use!"
|
||||
fi
|
||||
echo "Perhaps you can try 'configure --with-postgres=dir=path'"
|
||||
echo "to point to the postgres version you wish to use."
|
||||
echo "******************************************************"
|
||||
else
|
||||
AC_CHECK_FUNCS(PQescapeStringConn)
|
||||
fi
|
||||
else
|
||||
AC_CHECK_FUNCS(PQescapeStringConn)
|
||||
fi
|
||||
AC_CHECK_LIB(ecpg,ECPGconnect)
|
||||
if test "$ac_cv_lib_ecpg_ECPGconnect" != "yes"; then
|
||||
ECPG=
|
||||
echo "********************************************************"
|
||||
echo "Unable to locate postgres ecpg library (is it installed)"
|
||||
echo "Perhaps you can try 'configure --with-postgres=dir=path'"
|
||||
echo "to point to the postgres version you wish to use."
|
||||
echo "********************************************************"
|
||||
fi
|
||||
# End POSTGRES checks
|
||||
fi
|
||||
|
||||
# End POSTGRES checks
|
||||
fi
|
||||
|
||||
AC_SUBST(POSTGRES)
|
||||
|
||||
AC_MSG_CHECKING([if ECPG (Old Postgres) support was manually disabled])
|
||||
AC_ARG_ENABLE(ecpg-bundle, [
|
||||
--disable-ecpg-bundle
|
||||
Disable creating the ECPG bundle.
|
||||
Use this option to force the ECPG bundle not to be built
|
||||
even if the Postgres libraries look like being present.
|
||||
],
|
||||
ac_cv_ecpg_bundle=$enableval,
|
||||
ac_cv_ecpg_bundle="yes")
|
||||
|
||||
if test "$ac_cv_ecpg_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
ECPG=
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
# Start ECPG checks
|
||||
ECPG=
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(ecpglib.h)
|
||||
if test "$ac_cv_header_ecpglib_h" = "yes"; then
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/pgsql/include/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/pgsql/include"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
echo "*************************************************************"
|
||||
echo "Unable to locate ecpg (postgres) headers (are they installed)"
|
||||
echo "*************************************************************"
|
||||
fi
|
||||
|
||||
if test "$ECPG" = "yes"; then
|
||||
# NICOLA - hack
|
||||
if test -d /usr/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/local/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/pgsql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/pgsql/lib"
|
||||
LIBD="$LIBD -L/usr/local/pgsql/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(pq,PQfformat)
|
||||
AC_CHECK_LIB(ecpg,ECPGconnect)
|
||||
if test "$ac_cv_lib_ecpg_ECPGconnect" != "yes"; then
|
||||
ECPG=
|
||||
echo "********************************************************"
|
||||
echo "Unable to locate postgres ecpg library (is it installed)"
|
||||
echo "Perhaps you can try 'configure --with-postgres=dir=path'"
|
||||
echo "to point to the postgres version you wish to use."
|
||||
echo "********************************************************"
|
||||
fi
|
||||
fi
|
||||
# End ECPG checks
|
||||
fi
|
||||
AC_SUBST(ECPG)
|
||||
|
||||
|
||||
|
||||
ORACLE_HOME=
|
||||
AC_SUBST(ORACLE_HOME)
|
||||
|
||||
|
|
250
install-sh
Executable file
250
install-sh
Executable file
|
@ -0,0 +1,250 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
|
@ -29,7 +29,7 @@
|
|||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -109,7 +109,7 @@ main()
|
|||
|
||||
if ([records count] != 2)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
|
||||
NSLog(@"Expected 2 records but got %u", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ main()
|
|||
|
||||
NSLog(@"Records - %@", records);
|
||||
|
||||
[pool release];
|
||||
RELEASE(pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
18
testJDBC.m
18
testJDBC.m
|
@ -30,7 +30,7 @@
|
|||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -96,14 +96,14 @@ main()
|
|||
NSLog(@"Start producing");
|
||||
for (i = 0; i < 100000; i++)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSString *destination = [NSString stringWithFormat: @"%d", i];
|
||||
NSString *sid = [NSString stringWithFormat: @"%d", i%100];
|
||||
|
||||
[db execute: @"INSERT INTO Queue (Consumer, Destination, ServiceID, Payload) VALUES (",
|
||||
[db quote: name], @", ", [db quote: destination], @", ", sid, @", ",
|
||||
@"'helo there'", @")", nil];
|
||||
[arp release];
|
||||
RELEASE(arp);
|
||||
}
|
||||
NSLog(@"End producing");
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ main()
|
|||
NSLog(@"Start consuming");
|
||||
for (i = 0; i < 100000;)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
unsigned count;
|
||||
int j;
|
||||
|
||||
|
@ -125,7 +125,7 @@ main()
|
|||
if (count == 0)
|
||||
{
|
||||
[db commit];
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
sleep(1);
|
||||
[db begin];
|
||||
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
|
||||
[db quote: name],
|
||||
|
@ -154,7 +154,7 @@ main()
|
|||
}
|
||||
[db commit];
|
||||
i += count;
|
||||
[arp release];
|
||||
RELEASE(arp);
|
||||
}
|
||||
NSLog(@"End consuming (%d records)", i);
|
||||
/*
|
||||
|
@ -242,7 +242,7 @@ main()
|
|||
r0 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
r1 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] == [r1 lastObject], @"Cache failed");
|
||||
[NSThread sleepForTimeInterval: 2.0];
|
||||
sleep(2);
|
||||
records = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed");
|
||||
|
||||
|
@ -250,7 +250,7 @@ main()
|
|||
|
||||
if ([records count] != 3)
|
||||
{
|
||||
NSLog(@"Expected 3 records but got %"PRIuPTR, [records count]);
|
||||
NSLog(@"Expected 3 records but got %u", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -332,7 +332,7 @@ main()
|
|||
NSLog(@"Records - %@", [GSCache class]);
|
||||
}
|
||||
|
||||
[pool release];
|
||||
RELEASE(pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -109,7 +109,7 @@ main()
|
|||
|
||||
if ([records count] != 2)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
|
||||
NSLog(@"Expected 2 records but got %u", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ main()
|
|||
|
||||
NSLog(@"Records - %@", records);
|
||||
|
||||
[pool release];
|
||||
RELEASE(pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
304
testPostgres.m
304
testPostgres.m
|
@ -27,22 +27,10 @@
|
|||
#import <Performance/GSCache.h>
|
||||
#import "SQLClient.h"
|
||||
|
||||
@interface Logger : NSObject
|
||||
- (void) notified: (NSNotification*)n;
|
||||
@end
|
||||
|
||||
@implementation Logger
|
||||
- (void) notified: (NSNotification*)n
|
||||
{
|
||||
NSLog(@"Received %@", n);
|
||||
}
|
||||
@end
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
SQLClientPool *sp;
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -51,7 +39,6 @@ main()
|
|||
unsigned int i;
|
||||
NSData *data;
|
||||
NSString *name;
|
||||
Logger *l;
|
||||
|
||||
defs = [NSUserDefaults standardUserDefaults];
|
||||
[defs registerDefaults:
|
||||
|
@ -69,84 +56,7 @@ main()
|
|||
nil]
|
||||
];
|
||||
|
||||
sp = [[[SQLClientPool alloc] initWithConfiguration: nil
|
||||
name: @"test"
|
||||
max: 2
|
||||
min: 1] autorelease];
|
||||
#if 0
|
||||
{
|
||||
NSAutoreleasePool *p;
|
||||
NSAutoreleasePool *q;
|
||||
SQLClient *c0;
|
||||
SQLClient *c1;
|
||||
|
||||
[sp setDebugging: 4];
|
||||
p = [NSAutoreleasePool new];
|
||||
c0 = [sp provideClientExclusive];
|
||||
c1 = [sp provideClientExclusive];
|
||||
NSLog(@"Got two clients from pool");
|
||||
[c0 connect];
|
||||
[c1 connect];
|
||||
NSLog(@"Now putting clients back in pool again");
|
||||
[sp swallowClient: c0];
|
||||
[sp swallowClient: c1];
|
||||
NSLog(@"And emptying autorelease pool");
|
||||
[p release];
|
||||
p = [NSAutoreleasePool new];
|
||||
[sp setPurgeAll: 60 min: 1];
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
NSLog(@"Expecting purge to disconnect one client");
|
||||
[sp purge];
|
||||
c0 = [sp provideClientExclusive];
|
||||
c1 = [sp provideClientExclusive];
|
||||
NSLog(@"Expecting connected: %@", [c0 connected] ? @"YES" : @"NO");
|
||||
NSLog(@"Expecting not connected: %@", [c1 connected] ? @"NO" : @"YES");
|
||||
|
||||
NSLog(@"Pool has provided both it's clients ... now try for another with a 15 second timeout");
|
||||
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 15.0]
|
||||
exclusive: YES];
|
||||
NSLog(@"Emptying autorelease pool ... clients should be put back in pool");
|
||||
[p release];
|
||||
p = [NSAutoreleasePool new];
|
||||
NSLog(@"Getting two clients again");
|
||||
c0 = [sp provideClientExclusive];
|
||||
c1 = [sp provideClientExclusive];
|
||||
NSLog(@"Pool has provided both it's clients ... now try for another with a 15 second timeout");
|
||||
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 15.0]
|
||||
exclusive: YES];
|
||||
NSLog(@"Emptying autorelease pool again");
|
||||
[p release];
|
||||
p = [NSAutoreleasePool new];
|
||||
c0 = [sp provideClient];
|
||||
q = [NSAutoreleasePool new];
|
||||
c1 = [sp provideClient];
|
||||
if (c0 != c1)
|
||||
{
|
||||
NSLog(@"ERROR was expecting provideClient to give the same object");
|
||||
exit(1);
|
||||
}
|
||||
[q release];
|
||||
[c0 connect];
|
||||
[p release];
|
||||
|
||||
NSLog(@"Expect to get client immediately");
|
||||
}
|
||||
#endif
|
||||
db = [sp provideClientExclusive];
|
||||
[sp swallowClient: db];
|
||||
|
||||
[sp queryString: @"SELECT CURRENT_TIMESTAMP", nil];
|
||||
db = [sp provideClientExclusive];
|
||||
|
||||
l = [Logger new];
|
||||
[[NSNotificationCenter defaultCenter] addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: SQLClientDidConnectNotification
|
||||
object: db];
|
||||
[[NSNotificationCenter defaultCenter] addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: SQLClientDidDisconnectNotification
|
||||
object: db];
|
||||
db = [SQLClient clientWithConfiguration: nil name: @"test"];
|
||||
|
||||
if ((name = [defs stringForKey: @"Producer"]) != nil)
|
||||
{
|
||||
|
@ -160,7 +70,7 @@ main()
|
|||
@"Delivery TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, "
|
||||
@"Reference CHAR(128), "
|
||||
@"Destination CHAR(15) NOT NULL, "
|
||||
@"Payload CHAR(250) DEFAULT '' NOT NULL,"
|
||||
@"Payload CHAR(250) DEFAULT '' NOT NULL"
|
||||
@")",
|
||||
nil];
|
||||
[db execute:
|
||||
|
@ -184,35 +94,23 @@ main()
|
|||
NSLog(@"Start producing");
|
||||
for (i = 0; i < 100000; i++)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSString *destination = [NSString stringWithFormat: @"%d", i];
|
||||
NSString *sid = [NSString stringWithFormat: @"%d", i%100];
|
||||
|
||||
if (i % 1000 == 999)
|
||||
{
|
||||
[db postNotificationName: @"Producing"
|
||||
payload: [NSString stringWithFormat: @"%d", i]];
|
||||
}
|
||||
[db execute: @"INSERT INTO Queue (Consumer, Destination,"
|
||||
@" ServiceID, Payload) VALUES (",
|
||||
[db quote: name], @", ",
|
||||
[db quote: destination], @", ",
|
||||
sid, @", ",
|
||||
@"'helo there'",
|
||||
@")", nil];
|
||||
[arp release];
|
||||
[db execute: @"INSERT INTO Queue (Consumer, Destination, ServiceID, Payload) VALUES (",
|
||||
[db quote: name], @", ", [db quote: destination], @", ", sid, @", ",
|
||||
@"'helo there'", @")", nil];
|
||||
RELEASE(arp);
|
||||
}
|
||||
NSLog(@"End producing");
|
||||
}
|
||||
else if ((name = [defs stringForKey: @"Consumer"]) != nil)
|
||||
{
|
||||
[db addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: @"Producing"];
|
||||
NSLog(@"Start consuming");
|
||||
for (i = 0; i < 100000;)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
unsigned count;
|
||||
int j;
|
||||
|
||||
|
@ -225,7 +123,7 @@ main()
|
|||
if (count == 0)
|
||||
{
|
||||
[db commit];
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
sleep(1);
|
||||
[db begin];
|
||||
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
|
||||
[db quote: name],
|
||||
|
@ -254,7 +152,7 @@ main()
|
|||
}
|
||||
[db commit];
|
||||
i += count;
|
||||
[arp release];
|
||||
RELEASE(arp);
|
||||
}
|
||||
NSLog(@"End consuming (%d records)", i);
|
||||
/*
|
||||
|
@ -268,18 +166,11 @@ main()
|
|||
else
|
||||
{
|
||||
NSString *oddChars;
|
||||
NSString *oddNoNul;
|
||||
NSString *nonLatin;
|
||||
id e1, e2, e3, e4, e5;
|
||||
id d;
|
||||
id d0;
|
||||
id d1;
|
||||
id d2;
|
||||
id r0;
|
||||
id r1;
|
||||
|
||||
oddChars = @"'a\\b'c\0\r\nd'\\ed\\";
|
||||
oddNoNul = @"'a\\b'c\r\nd'\\ed\\";
|
||||
oddChars = @"'a\\b'c\r\nd'\\ed\\";
|
||||
nonLatin = [[NSString stringWithCString: "\"\\U2A11\""] propertyList];
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
@ -296,64 +187,31 @@ main()
|
|||
|
||||
[db begin];
|
||||
[db execute: @"create table xxx ( "
|
||||
@"id int, "
|
||||
@"k char(40), "
|
||||
@"char1 char(1), "
|
||||
@"boolval BOOL, "
|
||||
@"intval int, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp, "
|
||||
@"b bytea,"
|
||||
@"extra1 int[],"
|
||||
@"extra2 varchar[],"
|
||||
@"extra3 bytea[],"
|
||||
@"extra4 boolean[],"
|
||||
@"extra5 timestamp with time zone[]"
|
||||
@"b bytea"
|
||||
@")",
|
||||
nil];
|
||||
|
||||
if (1 != [db execute: @"INSERT into xxx (id, k, char1, boolval, intval,"
|
||||
@" when1, when2, b, extra1, extra2, extra3, extra4, extra5) "
|
||||
@"values (1,"
|
||||
@"'{hello', "
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
@"1, "
|
||||
@"CURRENT_TIMESTAMP, "
|
||||
@"CURRENT_TIMESTAMP, ",
|
||||
data, @", ",
|
||||
[db quoteArray:
|
||||
(e1 = [NSArray arrayWithObjects: @"1", @"2", [NSNull null], nil])
|
||||
toString: nil
|
||||
quotingStrings: NO], @", ",
|
||||
[db quoteArray:
|
||||
(e2 = [NSArray arrayWithObjects: @"on,e", @"t'wo", @"many", nil])
|
||||
toString: nil
|
||||
quotingStrings: YES], @", ",
|
||||
[db quoteArray:
|
||||
(e3 = [NSArray arrayWithObjects: data, nil])
|
||||
toString: nil
|
||||
quotingStrings: YES], @", ",
|
||||
[db quoteArray:
|
||||
(e4 =[NSArray arrayWithObjects: @"TRUE", @"FALSE", nil])
|
||||
toString: nil
|
||||
quotingStrings: NO], @", ",
|
||||
[db quoteArray:
|
||||
(e5 = [NSArray arrayWithObjects: [NSDate date], nil])
|
||||
toString: nil
|
||||
quotingStrings: YES], @")",
|
||||
nil])
|
||||
{
|
||||
NSLog(@"Insert failed to return row count");
|
||||
}
|
||||
|
||||
[db setDebugging: 0];
|
||||
[db query: @"select * from xxx", nil];
|
||||
[db setDebugging: 0];
|
||||
|
||||
[db execute: @"INSERT into xxx "
|
||||
@"(id, k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (2,"
|
||||
data,
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
|
@ -363,9 +221,9 @@ main()
|
|||
[NSData dataWithBytes: "" length: 0],
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"INSERT into xxx "
|
||||
@"(id, k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (3,",
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
|
@ -378,31 +236,21 @@ main()
|
|||
nil];
|
||||
[db commit];
|
||||
|
||||
r0 = [db cache: 1 query: @"select * from xxx order by id", nil];
|
||||
r1 = [db cache: 1 query: @"select * from xxx order by id", nil];
|
||||
r0 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
r1 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] == [r1 lastObject], @"Cache failed");
|
||||
[NSThread sleepForTimeInterval: 2.0];
|
||||
records = [db cache: 1 query: @"select * from xxx order by id", nil];
|
||||
sleep(2);
|
||||
records = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed");
|
||||
|
||||
db = [[[SQLClient alloc] initWithConfiguration: nil
|
||||
name: @"test"] autorelease];
|
||||
[db addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: @"foo"];
|
||||
|
||||
[db postNotificationName: @"foo" payload: @"hello"];
|
||||
|
||||
[db execute: @"drop table xxx", nil];
|
||||
|
||||
if ([records count] != 3)
|
||||
{
|
||||
NSLog(@"Expected 3 records but got %lu", [records count]);
|
||||
NSLog(@"Expected 3 records but got %u", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
record = [records objectAtIndex: 0];
|
||||
if ([[record objectForKey: @"b"] isEqual: data] == NO)
|
||||
{
|
||||
|
@ -419,100 +267,16 @@ main()
|
|||
{
|
||||
NSLog(@"Retrieved non-latin does not match saved string");
|
||||
}
|
||||
id o = [[record objectForKey: @"k"] stringByTrimmingSpaces];
|
||||
if ([o isEqual: oddNoNul] == NO)
|
||||
if ([[record objectForKey: @"k"] isEqual: oddChars] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved odd chars (%@) does not match oddNoNul (%@)",
|
||||
o, oddNoNul);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Embedded nul correctly removed");
|
||||
}
|
||||
record = [records objectAtIndex: 0];
|
||||
o = [record objectForKey: @"extra1"];
|
||||
if ([o isEqual: e1] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved extra1 (%@) does not match saved (%@)", o, e1);
|
||||
}
|
||||
o = [record objectForKey: @"extra2"];
|
||||
if ([o isEqual: e2] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved extra2 (%@) does not match saved (%@)", o, e2);
|
||||
}
|
||||
o = [record objectForKey: @"extra3"];
|
||||
if ([o isEqual: e3] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved extra3 (%@) does not match saved (%@)", o, e3);
|
||||
}
|
||||
o = [record objectForKey: @"extra4"];
|
||||
if ([o count] != [e4 count])
|
||||
{
|
||||
NSLog(@"Retrieved extra4 (%@) does not match saved (%@)", o, e4);
|
||||
}
|
||||
for (i = 0; i < [o count]; i++)
|
||||
{
|
||||
if ([[o objectAtIndex: i] boolValue]
|
||||
!= [[e4 objectAtIndex: i] boolValue])
|
||||
{
|
||||
NSLog(@"Retrieved extra4 (%@) does not match saved (%@)",
|
||||
o, e4);
|
||||
}
|
||||
}
|
||||
o = [record objectForKey: @"extra5"];
|
||||
if ([o count] != [e5 count])
|
||||
{
|
||||
NSLog(@"Retrieved extra5 (%@) does not match saved (%@)", o, e5);
|
||||
}
|
||||
for (i = 0; i < [o count]; i++)
|
||||
{
|
||||
if (floor([[o objectAtIndex: i] timeIntervalSinceReferenceDate])
|
||||
!= floor([[e5 objectAtIndex: i] timeIntervalSinceReferenceDate]))
|
||||
{
|
||||
NSLog(@"Retrieved extra5 (%@) does not match saved (%@)",
|
||||
o, e5);
|
||||
}
|
||||
NSLog(@"Retrieved odd chars does not match saved string");
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"Records - %@", [GSCache class]);
|
||||
|
||||
d = [NSCalendarDate date];
|
||||
[d setTimeZone: [NSTimeZone timeZoneForSecondsFromGMT: 240]];
|
||||
[db begin];
|
||||
[db execute: @"create table xxx ( "
|
||||
@"id int, "
|
||||
@"when0 timestamp with time zone, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp)",
|
||||
nil];
|
||||
[db execute: @"INSERT into xxx (id, when0, when1, when2) "
|
||||
@"values (99,",
|
||||
d, @", ",
|
||||
[NSDate distantPast], @", ",
|
||||
[NSDate distantFuture], @")",
|
||||
nil];
|
||||
r0 = [[db query: @"select * from xxx where id=99", nil] lastObject];
|
||||
[db execute: @"drop table xxx", nil];
|
||||
[db commit];
|
||||
|
||||
d0 = [r0 objectForKey:@"when0"];
|
||||
NSCAssert(floor([d0 timeIntervalSinceReferenceDate])
|
||||
== floor([d timeIntervalSinceReferenceDate]),
|
||||
NSInternalInconsistencyException);
|
||||
d1 = [r0 objectForKey:@"when1"];
|
||||
NSCAssert([d1 timeIntervalSinceReferenceDate]
|
||||
== [[NSDate distantPast] timeIntervalSinceReferenceDate],
|
||||
NSInternalInconsistencyException);
|
||||
d2 = [r0 objectForKey:@"when2"];
|
||||
NSCAssert([d2 timeIntervalSinceReferenceDate]
|
||||
== [[NSDate distantFuture] timeIntervalSinceReferenceDate],
|
||||
NSInternalInconsistencyException);
|
||||
}
|
||||
|
||||
NSLog(@"Pool stats:\n%@", [sp statistics]);
|
||||
|
||||
[pool release];
|
||||
RELEASE(pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
10
testSQLite.m
10
testSQLite.m
|
@ -29,7 +29,7 @@
|
|||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -91,8 +91,8 @@ main()
|
|||
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, intval, realval, b) "
|
||||
@"values (",
|
||||
[db quoteString: @"hello"], @", "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"1, ",
|
||||
@"12345.6789, ",
|
||||
|
@ -104,7 +104,7 @@ main()
|
|||
|
||||
if ([records count] != 2)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
|
||||
NSLog(@"Expected 2 records but got %u", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ main()
|
|||
|
||||
NSLog(@"Records - %@", records);
|
||||
|
||||
[pool release];
|
||||
RELEASE(pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue